wildcrane 0.11.23 → 0.11.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kanban.mjs +1386 -827
- package/package.json +1 -1
package/dist/kanban.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// ai4kanban 0.11.
|
|
2
|
+
// ai4kanban 0.11.25 — built from the CLI's TypeScript sources by cli/scripts/build.mjs.
|
|
3
3
|
// Do not edit: every change belongs in cli/src/, and a build overwrites this file.
|
|
4
4
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
5
5
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
@@ -1994,8 +1994,8 @@ var require_command = __commonJS({
|
|
|
1994
1994
|
"node_modules/commander/lib/command.js"(exports) {
|
|
1995
1995
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
1996
1996
|
var childProcess = __require("node:child_process");
|
|
1997
|
-
var
|
|
1998
|
-
var
|
|
1997
|
+
var path90 = __require("node:path");
|
|
1998
|
+
var fs91 = __require("node:fs");
|
|
1999
1999
|
var process2 = __require("node:process");
|
|
2000
2000
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
2001
2001
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -2976,7 +2976,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2976
2976
|
* @param {string} subcommandName
|
|
2977
2977
|
*/
|
|
2978
2978
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
2979
|
-
if (
|
|
2979
|
+
if (fs91.existsSync(executableFile)) return;
|
|
2980
2980
|
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";
|
|
2981
2981
|
const executableMissing = `'${executableFile}' does not exist
|
|
2982
2982
|
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
@@ -2994,11 +2994,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2994
2994
|
let launchWithNode = false;
|
|
2995
2995
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
2996
2996
|
function findFile(baseDir, baseName) {
|
|
2997
|
-
const localBin =
|
|
2998
|
-
if (
|
|
2999
|
-
if (sourceExt.includes(
|
|
2997
|
+
const localBin = path90.resolve(baseDir, baseName);
|
|
2998
|
+
if (fs91.existsSync(localBin)) return localBin;
|
|
2999
|
+
if (sourceExt.includes(path90.extname(baseName))) return void 0;
|
|
3000
3000
|
const foundExt = sourceExt.find(
|
|
3001
|
-
(ext) =>
|
|
3001
|
+
(ext) => fs91.existsSync(`${localBin}${ext}`)
|
|
3002
3002
|
);
|
|
3003
3003
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
3004
3004
|
return void 0;
|
|
@@ -3010,21 +3010,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3010
3010
|
if (this._scriptPath) {
|
|
3011
3011
|
let resolvedScriptPath;
|
|
3012
3012
|
try {
|
|
3013
|
-
resolvedScriptPath =
|
|
3013
|
+
resolvedScriptPath = fs91.realpathSync(this._scriptPath);
|
|
3014
3014
|
} catch {
|
|
3015
3015
|
resolvedScriptPath = this._scriptPath;
|
|
3016
3016
|
}
|
|
3017
|
-
executableDir =
|
|
3018
|
-
|
|
3017
|
+
executableDir = path90.resolve(
|
|
3018
|
+
path90.dirname(resolvedScriptPath),
|
|
3019
3019
|
executableDir
|
|
3020
3020
|
);
|
|
3021
3021
|
}
|
|
3022
3022
|
if (executableDir) {
|
|
3023
3023
|
let localFile = findFile(executableDir, executableFile);
|
|
3024
3024
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
3025
|
-
const legacyName =
|
|
3025
|
+
const legacyName = path90.basename(
|
|
3026
3026
|
this._scriptPath,
|
|
3027
|
-
|
|
3027
|
+
path90.extname(this._scriptPath)
|
|
3028
3028
|
);
|
|
3029
3029
|
if (legacyName !== this._name) {
|
|
3030
3030
|
localFile = findFile(
|
|
@@ -3035,7 +3035,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3035
3035
|
}
|
|
3036
3036
|
executableFile = localFile || executableFile;
|
|
3037
3037
|
}
|
|
3038
|
-
launchWithNode = sourceExt.includes(
|
|
3038
|
+
launchWithNode = sourceExt.includes(path90.extname(executableFile));
|
|
3039
3039
|
let proc;
|
|
3040
3040
|
if (process2.platform !== "win32") {
|
|
3041
3041
|
if (launchWithNode) {
|
|
@@ -3882,7 +3882,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3882
3882
|
* @return {Command}
|
|
3883
3883
|
*/
|
|
3884
3884
|
nameFromFilename(filename) {
|
|
3885
|
-
this._name =
|
|
3885
|
+
this._name = path90.basename(filename, path90.extname(filename));
|
|
3886
3886
|
return this;
|
|
3887
3887
|
}
|
|
3888
3888
|
/**
|
|
@@ -3896,9 +3896,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3896
3896
|
* @param {string} [path]
|
|
3897
3897
|
* @return {(string|null|Command)}
|
|
3898
3898
|
*/
|
|
3899
|
-
executableDir(
|
|
3900
|
-
if (
|
|
3901
|
-
this._executableDir =
|
|
3899
|
+
executableDir(path91) {
|
|
3900
|
+
if (path91 === void 0) return this._executableDir;
|
|
3901
|
+
this._executableDir = path91;
|
|
3902
3902
|
return this;
|
|
3903
3903
|
}
|
|
3904
3904
|
/**
|
|
@@ -4843,7 +4843,7 @@ function moveSignal(from, into, fields) {
|
|
|
4843
4843
|
function dismissInboxItems(sourceIds, by, reason = "") {
|
|
4844
4844
|
const waiting = bySource(readInbox());
|
|
4845
4845
|
const ignored = bySource(readAllDismissed());
|
|
4846
|
-
const
|
|
4846
|
+
const why2 = reason.trim();
|
|
4847
4847
|
return [...new Set(sourceIds)].map((sourceId) => {
|
|
4848
4848
|
const missing = { sourceId, ok: false, error: `nothing waiting in triage is ${sourceId}` };
|
|
4849
4849
|
const found2 = waiting.get(sourceId);
|
|
@@ -4853,7 +4853,7 @@ function dismissInboxItems(sourceIds, by, reason = "") {
|
|
|
4853
4853
|
const at2 = moveSignal(path11.join(TRIAGE, path11.basename(found2.relPath)), SIGNALS_DISMISSED, {
|
|
4854
4854
|
dismissed_at: formatStamp(/* @__PURE__ */ new Date()),
|
|
4855
4855
|
dismissed_by: by,
|
|
4856
|
-
...
|
|
4856
|
+
...why2 ? { dismissed_reason: why2 } : {}
|
|
4857
4857
|
});
|
|
4858
4858
|
return at2 ? { sourceId, ok: true, relPath: at2 } : missing;
|
|
4859
4859
|
});
|
|
@@ -5759,7 +5759,7 @@ var init_package = __esm({
|
|
|
5759
5759
|
"package.json"() {
|
|
5760
5760
|
package_default = {
|
|
5761
5761
|
name: "wildcrane",
|
|
5762
|
-
version: "0.11.
|
|
5762
|
+
version: "0.11.25",
|
|
5763
5763
|
akbContract: 7,
|
|
5764
5764
|
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.",
|
|
5765
5765
|
keywords: [
|
|
@@ -6344,14 +6344,14 @@ function currentTurn() {
|
|
|
6344
6344
|
function forgetFileMemos() {
|
|
6345
6345
|
turn++;
|
|
6346
6346
|
}
|
|
6347
|
-
function memoByFiles(paths,
|
|
6347
|
+
function memoByFiles(paths, read5) {
|
|
6348
6348
|
let last = null;
|
|
6349
6349
|
return () => {
|
|
6350
6350
|
const now = currentTurn();
|
|
6351
6351
|
if (last?.turn !== now) {
|
|
6352
6352
|
const seen = stamp3(paths());
|
|
6353
6353
|
if (last?.stamp === seen) last.turn = now;
|
|
6354
|
-
else last = { stamp: seen, turn: now, value:
|
|
6354
|
+
else last = { stamp: seen, turn: now, value: read5() };
|
|
6355
6355
|
}
|
|
6356
6356
|
return copy(last.value);
|
|
6357
6357
|
};
|
|
@@ -6367,15 +6367,15 @@ var init_file_memo = __esm({
|
|
|
6367
6367
|
});
|
|
6368
6368
|
|
|
6369
6369
|
// ../cloud/src/board-files.ts
|
|
6370
|
-
function isBoardPath(
|
|
6371
|
-
if (!
|
|
6372
|
-
if (
|
|
6373
|
-
if (
|
|
6374
|
-
if (
|
|
6375
|
-
if (SETTINGS.includes(
|
|
6376
|
-
if (
|
|
6377
|
-
if (
|
|
6378
|
-
return ROOTS.some((root2) =>
|
|
6370
|
+
function isBoardPath(path90) {
|
|
6371
|
+
if (!path90 || path90.length > 500 || path90.startsWith("/") || path90.includes("\\") || path90.includes("\0")) return false;
|
|
6372
|
+
if (path90.split("/").some((part) => !part || part === "." || part === "..")) return false;
|
|
6373
|
+
if (path90 === "todo/README.md" || path90.split("/").includes(".sync")) return false;
|
|
6374
|
+
if (path90.startsWith("workflows/")) return true;
|
|
6375
|
+
if (SETTINGS.includes(path90)) return true;
|
|
6376
|
+
if (path90.startsWith("rules/")) return isSettingsPath(path90);
|
|
6377
|
+
if (path90.startsWith("assets/")) return path90.endsWith(".json");
|
|
6378
|
+
return ROOTS.some((root2) => path90.startsWith(root2)) && path90.endsWith(".md");
|
|
6379
6379
|
}
|
|
6380
6380
|
var ROOTS, SETTINGS, isSettingsPath, BOARD_FILE_LIMIT, cardSlug, workflowFolder, workflowName, draftFolder;
|
|
6381
6381
|
var init_board_files = __esm({
|
|
@@ -6383,7 +6383,7 @@ var init_board_files = __esm({
|
|
|
6383
6383
|
"use strict";
|
|
6384
6384
|
ROOTS = ["todo/", ".archive/", "memory/", "workflows/", "triage/", "assets/", "rules/"];
|
|
6385
6385
|
SETTINGS = ["modules.md", "config.md"];
|
|
6386
|
-
isSettingsPath = (
|
|
6386
|
+
isSettingsPath = (path90) => SETTINGS.includes(path90) || /^rules\/(?:workflows\/)?[^/]+\.md$/.test(path90);
|
|
6387
6387
|
BOARD_FILE_LIMIT = 256 * 1024;
|
|
6388
6388
|
cardSlug = (task) => task.toLowerCase().replace(/_/g, "-");
|
|
6389
6389
|
workflowFolder = (id) => id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
@@ -6392,6 +6392,93 @@ var init_board_files = __esm({
|
|
|
6392
6392
|
}
|
|
6393
6393
|
});
|
|
6394
6394
|
|
|
6395
|
+
// src/lib/agents/icon.ts
|
|
6396
|
+
function readIcon(raw) {
|
|
6397
|
+
if (raw === void 0 || raw === "") return void 0;
|
|
6398
|
+
if (typeof raw === "string") return ICON_NAMES.includes(raw.trim()) ? raw.trim() : { problem: `"${raw}" is not a glyph name` };
|
|
6399
|
+
if (!Array.isArray(raw) || !raw.length || raw.length > 12) return { problem: "the value is neither a glyph name nor a list of 1 to 12 parts" };
|
|
6400
|
+
const parts = [];
|
|
6401
|
+
for (const [i, item] of raw.entries()) {
|
|
6402
|
+
const at2 = `part ${i + 1}`;
|
|
6403
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) return { problem: `${at2} is not a map of \`d\`, \`f\`, \`o\`, \`s\`, \`w\`` };
|
|
6404
|
+
const { d: d2, f: f2, o: o3, s, w: w2, ...extra } = item;
|
|
6405
|
+
if (Object.keys(extra).length) return { problem: `${at2} has \`${Object.keys(extra).join("`, `")}\`` };
|
|
6406
|
+
if (typeof d2 !== "string" || !PATH.test(d2)) return { problem: `${at2} has no \`d\` of SVG path commands and numbers` };
|
|
6407
|
+
const part = { d: d2.trim() };
|
|
6408
|
+
for (const [key, value] of [["f", f2], ["s", s]]) {
|
|
6409
|
+
if (value === void 0) continue;
|
|
6410
|
+
if (typeof value !== "string" || !isColor(value)) return { problem: `${at2} colours \`${key}\` with "${String(value)}"` };
|
|
6411
|
+
part[key] = value;
|
|
6412
|
+
}
|
|
6413
|
+
if (o3 !== void 0) {
|
|
6414
|
+
if (o3 !== "true") return { problem: `${at2} has \`o: ${String(o3)}\`, not \`true\`` };
|
|
6415
|
+
part.o = true;
|
|
6416
|
+
}
|
|
6417
|
+
if (w2 !== void 0) {
|
|
6418
|
+
const width = typeof w2 === "string" ? Number(w2) : NaN;
|
|
6419
|
+
if (!(width > 0 && width <= 3)) return { problem: `${at2} has \`w: ${String(w2)}\`, not above 0 and up to 3` };
|
|
6420
|
+
part.w = width;
|
|
6421
|
+
}
|
|
6422
|
+
parts.push(part);
|
|
6423
|
+
}
|
|
6424
|
+
return parts;
|
|
6425
|
+
}
|
|
6426
|
+
var ICON_NAMES, ICON_COLORS, PATH, isColor;
|
|
6427
|
+
var init_icon = __esm({
|
|
6428
|
+
"src/lib/agents/icon.ts"() {
|
|
6429
|
+
"use strict";
|
|
6430
|
+
ICON_NAMES = [
|
|
6431
|
+
"file",
|
|
6432
|
+
"text",
|
|
6433
|
+
"article",
|
|
6434
|
+
"outline",
|
|
6435
|
+
"script",
|
|
6436
|
+
"prompt",
|
|
6437
|
+
"email",
|
|
6438
|
+
"image",
|
|
6439
|
+
"post-image",
|
|
6440
|
+
"social-image",
|
|
6441
|
+
"cover",
|
|
6442
|
+
"carousel",
|
|
6443
|
+
"carousel-outline",
|
|
6444
|
+
"slides",
|
|
6445
|
+
"wireframe",
|
|
6446
|
+
"screen",
|
|
6447
|
+
"video",
|
|
6448
|
+
"storyboard",
|
|
6449
|
+
"template",
|
|
6450
|
+
"shots",
|
|
6451
|
+
"api",
|
|
6452
|
+
"schema",
|
|
6453
|
+
"compare",
|
|
6454
|
+
"stack",
|
|
6455
|
+
"workflow",
|
|
6456
|
+
"code",
|
|
6457
|
+
"checklist",
|
|
6458
|
+
"card",
|
|
6459
|
+
"plan",
|
|
6460
|
+
"proposal",
|
|
6461
|
+
"dismissed",
|
|
6462
|
+
"inbox",
|
|
6463
|
+
"notebook",
|
|
6464
|
+
"squeeze",
|
|
6465
|
+
"folder",
|
|
6466
|
+
"reply",
|
|
6467
|
+
"feedback",
|
|
6468
|
+
"software",
|
|
6469
|
+
"product-video",
|
|
6470
|
+
"social-post",
|
|
6471
|
+
"blog",
|
|
6472
|
+
"deck",
|
|
6473
|
+
"video-clone",
|
|
6474
|
+
"workflow-kit"
|
|
6475
|
+
];
|
|
6476
|
+
ICON_COLORS = ["k", "w", "c", "g", "o", "p", "s", "m", "l", "r", "y"];
|
|
6477
|
+
PATH = /^[MmLlHhVvCcSsQqTtAaZz0-9.,\s-]+$/;
|
|
6478
|
+
isColor = (v) => ICON_COLORS.includes(v);
|
|
6479
|
+
}
|
|
6480
|
+
});
|
|
6481
|
+
|
|
6395
6482
|
// src/lib/agents/yaml.ts
|
|
6396
6483
|
function stripComment(value) {
|
|
6397
6484
|
let from = 0;
|
|
@@ -6506,8 +6593,8 @@ var init_yaml2 = __esm({
|
|
|
6506
6593
|
// src/lib/agents/parse.ts
|
|
6507
6594
|
function parseSpecAgent(text5, from, file, builtIn = false, list = () => []) {
|
|
6508
6595
|
let named2 = "";
|
|
6509
|
-
const bad = (
|
|
6510
|
-
problem: `${from}: ${
|
|
6596
|
+
const bad = (why2, old2) => ({
|
|
6597
|
+
problem: `${from}: ${why2}`,
|
|
6511
6598
|
...named2 ? { name: named2 } : {},
|
|
6512
6599
|
...old2 ? { old: old2 } : {}
|
|
6513
6600
|
});
|
|
@@ -6542,6 +6629,12 @@ function parseSpecAgent(text5, from, file, builtIn = false, list = () => []) {
|
|
|
6542
6629
|
if (!Array.isArray(components) || components.some((value) => typeof value !== "string" || !value.trim())) {
|
|
6543
6630
|
return bad(`\`${name}\` declares \`akb.components\` that is not a list of component IDs`);
|
|
6544
6631
|
}
|
|
6632
|
+
const icon = readIcon(akb.icon);
|
|
6633
|
+
if (icon && typeof icon === "object" && "problem" in icon) {
|
|
6634
|
+
return bad(
|
|
6635
|
+
`\`${name}\` declares an \`akb.icon\` where ${icon.problem} \u2014 use one of ${ICON_NAMES.join(", ")}, or 1 to 12 parts \`{ d, f?, o?: true, s?, w? }\` coloured with ${ICON_COLORS.join(", ")}`
|
|
6636
|
+
);
|
|
6637
|
+
}
|
|
6545
6638
|
const workspace = memoryPaths(akb.memoryFiles);
|
|
6546
6639
|
if (typeof workspace === "string") return bad(`\`${name}\` declares ${workspace}`);
|
|
6547
6640
|
const instructions = body.trim();
|
|
@@ -6553,6 +6646,7 @@ function parseSpecAgent(text5, from, file, builtIn = false, list = () => []) {
|
|
|
6553
6646
|
...when ? { when } : {},
|
|
6554
6647
|
after: after2,
|
|
6555
6648
|
components: [...new Set(components.map((value) => value.trim()))],
|
|
6649
|
+
...icon ? { icon } : {},
|
|
6556
6650
|
i18n: readTranslations(akb.i18n),
|
|
6557
6651
|
...declaredReads ? { reads: declaredReads } : {},
|
|
6558
6652
|
...declaredSession ? { session: "new" } : {},
|
|
@@ -6601,6 +6695,7 @@ var OLD_ROLE_KEYS, AGENT_NAME, SCHEDULE_READS, isScheduleReads, names, str, map;
|
|
|
6601
6695
|
var init_parse = __esm({
|
|
6602
6696
|
"src/lib/agents/parse.ts"() {
|
|
6603
6697
|
"use strict";
|
|
6698
|
+
init_icon();
|
|
6604
6699
|
init_yaml2();
|
|
6605
6700
|
OLD_ROLE_KEYS = ["lead", "hook", "stage", "kind"];
|
|
6606
6701
|
AGENT_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
@@ -6654,6 +6749,12 @@ function parseWorkflowFile(id, source, from) {
|
|
|
6654
6749
|
problem: `${from}: \`${old.join("`, `")}\` ${old.length > 1 ? "are" : "is"} no longer read \u2014 list the agents under \`previews\`, \`land\` and \`scheduled\` instead (\`akb guide write-agent\`), or ask the Workflow builder to rewrite it`
|
|
6655
6750
|
};
|
|
6656
6751
|
}
|
|
6752
|
+
const icon = readIcon(raw.icon);
|
|
6753
|
+
if (icon && typeof icon === "object" && "problem" in icon) {
|
|
6754
|
+
return {
|
|
6755
|
+
problem: `${from}: its \`icon\` is wrong \u2014 ${icon.problem}; use one of ${ICON_NAMES.join(", ")}, or 1 to 12 parts \`{ d, f?, o?: true, s?, w? }\` coloured with ${ICON_COLORS.join(", ")}`
|
|
6756
|
+
};
|
|
6757
|
+
}
|
|
6657
6758
|
const previews = readPreviews(raw.previews);
|
|
6658
6759
|
if (typeof previews === "string") return { problem: `${from}: ${previews}` };
|
|
6659
6760
|
const land = readGroup(raw.land);
|
|
@@ -6678,6 +6779,7 @@ function parseWorkflowFile(id, source, from) {
|
|
|
6678
6779
|
description: text(raw.description),
|
|
6679
6780
|
when: text(raw.when),
|
|
6680
6781
|
needsArtifact: text(raw.needsArtifact) === "true",
|
|
6782
|
+
...icon ? { icon } : {},
|
|
6681
6783
|
previews,
|
|
6682
6784
|
land,
|
|
6683
6785
|
scheduled,
|
|
@@ -6689,6 +6791,7 @@ var WORKFLOW_ID, OLD_KEYS, box, text, readGroup;
|
|
|
6689
6791
|
var init_workflow_def = __esm({
|
|
6690
6792
|
"src/lib/agent/workflow-def.ts"() {
|
|
6691
6793
|
"use strict";
|
|
6794
|
+
init_icon();
|
|
6692
6795
|
init_yaml2();
|
|
6693
6796
|
init_spec_agent_names();
|
|
6694
6797
|
WORKFLOW_ID = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
@@ -6699,6 +6802,36 @@ var init_workflow_def = __esm({
|
|
|
6699
6802
|
}
|
|
6700
6803
|
});
|
|
6701
6804
|
|
|
6805
|
+
// src/lib/agent/workflow-diagram.ts
|
|
6806
|
+
function workflowDiagram(def, agentOf3) {
|
|
6807
|
+
const step = (name) => {
|
|
6808
|
+
const agent = ROLES[name] ? null : agentOf3(name);
|
|
6809
|
+
const en2 = agent?.i18n.en?.title || name;
|
|
6810
|
+
return {
|
|
6811
|
+
agent: name,
|
|
6812
|
+
title: ROLES[name] ?? { en: en2, zh: agent?.i18n.zh?.title || en2 },
|
|
6813
|
+
...agent?.icon ? { icon: agent.icon } : {},
|
|
6814
|
+
...agent?.when ? { optional: true } : {}
|
|
6815
|
+
};
|
|
6816
|
+
};
|
|
6817
|
+
const previews = def.previews.filter((h3) => !h3.off).map((h3) => h3.agent);
|
|
6818
|
+
const after2 = (name) => (agentOf3(name)?.after ?? []).filter((other) => previews.includes(other));
|
|
6819
|
+
return {
|
|
6820
|
+
version: 1,
|
|
6821
|
+
rounds: stagesOf(previews, after2).map((round) => round.map(step)),
|
|
6822
|
+
land: def.land.filter((h3) => !h3.off).map((h3) => step(h3.agent)),
|
|
6823
|
+
scheduled: def.scheduled.map((s) => ({ ...step(s.agent), ...s.cadence ? { cadence: s.cadence } : {} }))
|
|
6824
|
+
};
|
|
6825
|
+
}
|
|
6826
|
+
var ROLES;
|
|
6827
|
+
var init_workflow_diagram = __esm({
|
|
6828
|
+
"src/lib/agent/workflow-diagram.ts"() {
|
|
6829
|
+
"use strict";
|
|
6830
|
+
init_workflow_def();
|
|
6831
|
+
ROLES = { builder: { en: "Build and merge", zh: "\u5B9E\u73B0\u5E76\u5408\u5165" } };
|
|
6832
|
+
}
|
|
6833
|
+
});
|
|
6834
|
+
|
|
6702
6835
|
// ../cloud/src/v1/workflow-files.ts
|
|
6703
6836
|
function folderPath(file, top) {
|
|
6704
6837
|
const parts = file.split("/");
|
|
@@ -6707,13 +6840,13 @@ function folderPath(file, top) {
|
|
|
6707
6840
|
return [parts[1], parts.slice(2).join("/")];
|
|
6708
6841
|
}
|
|
6709
6842
|
function mcpProblem(text5) {
|
|
6710
|
-
let
|
|
6843
|
+
let read5;
|
|
6711
6844
|
try {
|
|
6712
|
-
|
|
6845
|
+
read5 = JSON.parse(text5);
|
|
6713
6846
|
} catch {
|
|
6714
6847
|
return "is not JSON";
|
|
6715
6848
|
}
|
|
6716
|
-
const servers =
|
|
6849
|
+
const servers = read5?.mcpServers;
|
|
6717
6850
|
if (!servers || typeof servers !== "object" || Array.isArray(servers)) return "must hold `mcpServers`, an object of name \u2192 server";
|
|
6718
6851
|
for (const [name, server] of Object.entries(servers)) {
|
|
6719
6852
|
const { command, args, ...rest } = server ?? {};
|
|
@@ -6745,6 +6878,7 @@ function checkWorkflowFiles(value, official = false) {
|
|
|
6745
6878
|
if (problem) return fail(file, problem);
|
|
6746
6879
|
continue;
|
|
6747
6880
|
}
|
|
6881
|
+
if (official && isAboutFile(file)) continue;
|
|
6748
6882
|
if (official && file.startsWith("skills/")) {
|
|
6749
6883
|
if (!folderPath(file, "skills")) return fail(file, "is not inside skills/<name>/");
|
|
6750
6884
|
skills.add(file.split("/")[1]);
|
|
@@ -6760,9 +6894,9 @@ function checkWorkflowFiles(value, official = false) {
|
|
|
6760
6894
|
}
|
|
6761
6895
|
const source = value[WORKFLOW_FILE];
|
|
6762
6896
|
if (source === void 0) return fail(WORKFLOW_FILE, "is missing");
|
|
6763
|
-
const
|
|
6764
|
-
if ("problem" in
|
|
6765
|
-
const def =
|
|
6897
|
+
const read5 = parseWorkflowFile("workflow", source, WORKFLOW_FILE);
|
|
6898
|
+
if ("problem" in read5) return fail(WORKFLOW_FILE, read5.problem.replace(`${WORKFLOW_FILE}: `, ""));
|
|
6899
|
+
const def = read5.def;
|
|
6766
6900
|
const agents = /* @__PURE__ */ new Map();
|
|
6767
6901
|
for (const [name, own] of folders2) {
|
|
6768
6902
|
const from = `agents/${name}/AGENT.md`;
|
|
@@ -6778,17 +6912,18 @@ function checkWorkflowFiles(value, official = false) {
|
|
|
6778
6912
|
...def.land.filter((h3) => !LAND_ROLES.includes(h3.agent)).map((h3) => [h3.agent, "it lands with"]),
|
|
6779
6913
|
...def.scheduled.map((s) => [s.agent, "it schedules"])
|
|
6780
6914
|
];
|
|
6781
|
-
for (const [name,
|
|
6782
|
-
if (!agents.has(name)) return fail(WORKFLOW_FILE, `${
|
|
6915
|
+
for (const [name, why2] of named2) {
|
|
6916
|
+
if (!agents.has(name)) return fail(WORKFLOW_FILE, `${why2} \`${name}\`, which has no agents/${name}/AGENT.md`);
|
|
6783
6917
|
}
|
|
6784
6918
|
return { ok: true, def, files: value };
|
|
6785
6919
|
}
|
|
6786
|
-
var WORKFLOW_FILE, MCP_FILE, KB, FILE_LIMITS, LAND_ROLES, landsOf, SEGMENT, bytes;
|
|
6920
|
+
var WORKFLOW_FILE, MCP_FILE, KB, FILE_LIMITS, LAND_ROLES, landsOf, SEGMENT, isAboutFile, bytes;
|
|
6787
6921
|
var init_workflow_files = __esm({
|
|
6788
6922
|
"../cloud/src/v1/workflow-files.ts"() {
|
|
6789
6923
|
"use strict";
|
|
6790
6924
|
init_workflow_def();
|
|
6791
6925
|
init_parse();
|
|
6926
|
+
init_workflow_diagram();
|
|
6792
6927
|
WORKFLOW_FILE = "WORKFLOW.md";
|
|
6793
6928
|
MCP_FILE = "mcp.json";
|
|
6794
6929
|
KB = 1024;
|
|
@@ -6796,6 +6931,7 @@ var init_workflow_files = __esm({
|
|
|
6796
6931
|
LAND_ROLES = ["builder"];
|
|
6797
6932
|
landsOf = (def) => ({ lands: def.land.some((h3) => !h3.off) });
|
|
6798
6933
|
SEGMENT = /^[\w.-]+$/;
|
|
6934
|
+
isAboutFile = (file) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file);
|
|
6799
6935
|
bytes = (text5) => new TextEncoder().encode(text5).length;
|
|
6800
6936
|
}
|
|
6801
6937
|
});
|
|
@@ -6818,20 +6954,21 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
|
6818
6954
|
return [name, Object.fromEntries(filesOf(dir).sort().map((f2) => [f2, fs20.readFileSync(path21.join(dir, f2), "utf8")]))];
|
|
6819
6955
|
}));
|
|
6820
6956
|
for (const [name, own] of Object.entries(loose ? {} : agentFiles)) {
|
|
6821
|
-
const
|
|
6822
|
-
if ("problem" in
|
|
6957
|
+
const read5 = parseSpecAgent(own["AGENT.md"] ?? "", `official/agents/${name}/AGENT.md`, (p2) => own[p2] ?? null, true);
|
|
6958
|
+
if ("problem" in read5) throw new Error(read5.problem);
|
|
6823
6959
|
}
|
|
6824
6960
|
const workflowsDir = path21.join(root2, "workflows");
|
|
6825
6961
|
return dirs(workflowsDir).map((folder) => {
|
|
6826
6962
|
const dir = path21.join(workflowsDir, folder);
|
|
6827
6963
|
const files2 = {};
|
|
6828
6964
|
for (const f2 of filesOf(dir).sort()) {
|
|
6829
|
-
if (f2 === WORKFLOW_FILE || f2 === MCP_FILE || f2.startsWith("skills/")) files2[f2] = fs20.readFileSync(path21.join(dir, f2), "utf8");
|
|
6965
|
+
if (f2 === WORKFLOW_FILE || f2 === MCP_FILE || f2.startsWith("skills/") || /^ABOUT(\.[a-z]{2})?\.md$/.test(f2)) files2[f2] = fs20.readFileSync(path21.join(dir, f2), "utf8");
|
|
6966
|
+
else if (isAboutFile(f2)) files2[f2] = `data:${MIME[path21.extname(f2)]};base64,${fs20.readFileSync(path21.join(dir, f2)).toString("base64")}`;
|
|
6830
6967
|
}
|
|
6831
|
-
const
|
|
6968
|
+
const read5 = checkWorkflowFiles({ [WORKFLOW_FILE]: files2[WORKFLOW_FILE], ...Object.fromEntries(
|
|
6832
6969
|
Object.entries(agentFiles).flatMap(([name, own]) => Object.entries(own).map(([f2, t]) => [`agents/${name}/${f2}`, t]))
|
|
6833
6970
|
) });
|
|
6834
|
-
if (!
|
|
6971
|
+
if (!read5.ok && !loose) throw new Error(`official/workflows/${folder}: ${read5.file}: ${read5.reason}`);
|
|
6835
6972
|
const parsed = parseWorkflowFile(folder, files2[WORKFLOW_FILE] ?? "", WORKFLOW_FILE);
|
|
6836
6973
|
if ("problem" in parsed) throw new Error(parsed.problem);
|
|
6837
6974
|
const def = parsed.def;
|
|
@@ -6853,13 +6990,14 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
|
6853
6990
|
};
|
|
6854
6991
|
});
|
|
6855
6992
|
}
|
|
6856
|
-
var OFFICIAL, dirs, officialId, hashOf;
|
|
6993
|
+
var OFFICIAL, MIME, dirs, officialId, hashOf;
|
|
6857
6994
|
var init_pack = __esm({
|
|
6858
6995
|
"../official/pack.ts"() {
|
|
6859
6996
|
init_parse();
|
|
6860
6997
|
init_workflow_def();
|
|
6861
6998
|
init_workflow_files();
|
|
6862
6999
|
OFFICIAL = path21.dirname(fileURLToPath(import.meta.url));
|
|
7000
|
+
MIME = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
|
|
6863
7001
|
dirs = (dir) => fs20.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
|
|
6864
7002
|
officialId = (folder) => `wf_builtin_${folder.replace(/-/g, "_")}`;
|
|
6865
7003
|
hashOf = (files2) => crypto4.createHash("sha256").update(JSON.stringify(Object.entries(files2).sort(([a2], [b2]) => a2 < b2 ? -1 : 1))).digest("hex");
|
|
@@ -6904,18 +7042,18 @@ function pinMissing() {
|
|
|
6904
7042
|
async function versionOf(id, version) {
|
|
6905
7043
|
const held4 = readVersion(id, version);
|
|
6906
7044
|
if (held4) return { ok: true, value: held4 };
|
|
6907
|
-
const
|
|
6908
|
-
if (!
|
|
6909
|
-
saveVersion(
|
|
6910
|
-
return
|
|
7045
|
+
const read5 = await call("GET", `/v1/workflows/${encodeURIComponent(id)}`);
|
|
7046
|
+
if (!read5.ok) return read5;
|
|
7047
|
+
saveVersion(read5.value);
|
|
7048
|
+
return read5;
|
|
6911
7049
|
}
|
|
6912
7050
|
async function pinTask(task) {
|
|
6913
7051
|
const pin = readPin(task);
|
|
6914
7052
|
const held4 = pin && readVersion(pin.workflow, pin.version);
|
|
6915
7053
|
if (held4) return { ok: true, value: held4 };
|
|
6916
|
-
const
|
|
6917
|
-
if (!
|
|
6918
|
-
const value = { id:
|
|
7054
|
+
const read5 = await call("GET", `/v1/tasks/${encodeURIComponent(task)}/workflow`);
|
|
7055
|
+
if (!read5.ok) return read5;
|
|
7056
|
+
const value = { id: read5.value.workflow, version: read5.value.version, name: read5.value.name, files: read5.value.files };
|
|
6919
7057
|
savePin(task, value);
|
|
6920
7058
|
return { ok: true, value };
|
|
6921
7059
|
}
|
|
@@ -6934,12 +7072,12 @@ async function syncWorkflows(force = false) {
|
|
|
6934
7072
|
if (fresh && !force) return;
|
|
6935
7073
|
let workspace = held4?.workspace;
|
|
6936
7074
|
if (!workspace) {
|
|
6937
|
-
const
|
|
6938
|
-
if (!
|
|
6939
|
-
offline = !
|
|
7075
|
+
const read5 = await call("GET", `/v1/projects/${encodeURIComponent(project)}`);
|
|
7076
|
+
if (!read5.ok) {
|
|
7077
|
+
offline = !read5.code;
|
|
6940
7078
|
return;
|
|
6941
7079
|
}
|
|
6942
|
-
workspace =
|
|
7080
|
+
workspace = read5.value.workspace;
|
|
6943
7081
|
}
|
|
6944
7082
|
const listed = [];
|
|
6945
7083
|
let after2 = null;
|
|
@@ -6957,9 +7095,9 @@ async function syncWorkflows(force = false) {
|
|
|
6957
7095
|
} while (after2);
|
|
6958
7096
|
const kept2 = [];
|
|
6959
7097
|
for (const w2 of listed) {
|
|
6960
|
-
const
|
|
6961
|
-
if (
|
|
6962
|
-
else if (!
|
|
7098
|
+
const read5 = await versionOf(w2.id, w2.version);
|
|
7099
|
+
if (read5.ok) kept2.push({ id: read5.value.id, version: read5.value.version });
|
|
7100
|
+
else if (!read5.code) offline = true;
|
|
6963
7101
|
}
|
|
6964
7102
|
writeJson(listFile(project), { at: (/* @__PURE__ */ new Date()).toISOString(), workspace, workflows: kept2 });
|
|
6965
7103
|
} catch {
|
|
@@ -7032,9 +7170,9 @@ var init_cloud_workflows = __esm({
|
|
|
7032
7170
|
workflowsOffline = () => offline;
|
|
7033
7171
|
flowOf = (held4) => {
|
|
7034
7172
|
const id = workflowName(held4.id);
|
|
7035
|
-
const
|
|
7036
|
-
if ("problem" in
|
|
7037
|
-
return { def:
|
|
7173
|
+
const read5 = parseWorkflowFile(id, held4.files["WORKFLOW.md"] ?? "", `the \`${id}\` workflow`);
|
|
7174
|
+
if ("problem" in read5) return null;
|
|
7175
|
+
return { def: read5.def, cloudId: held4.id, version: held4.version, builtIn: held4.id.startsWith("wf_builtin_"), files: held4.files };
|
|
7038
7176
|
};
|
|
7039
7177
|
sources = () => {
|
|
7040
7178
|
if (devFolder()) return [devFolder()];
|
|
@@ -7066,16 +7204,16 @@ function readCatalog() {
|
|
|
7066
7204
|
const agents = [];
|
|
7067
7205
|
const problems = [];
|
|
7068
7206
|
const refused = [];
|
|
7069
|
-
const take = (
|
|
7070
|
-
if ("problem" in
|
|
7071
|
-
if (!
|
|
7072
|
-
if (!
|
|
7073
|
-
const { file, name: name2, old } =
|
|
7074
|
-
const cause =
|
|
7207
|
+
const take = (read5, folder) => {
|
|
7208
|
+
if ("problem" in read5) {
|
|
7209
|
+
if (!read5.missing) problems.push(read5.problem);
|
|
7210
|
+
if (!read5.file) return;
|
|
7211
|
+
const { file, name: name2, old } = read5;
|
|
7212
|
+
const cause = read5.missing ? "noFile" : old ? "oldKeys" : "file";
|
|
7075
7213
|
refused.push({ folder, file, cause, ...name2 ? { name: name2 } : {}, ...old ? { keys: old.keys } : {} });
|
|
7076
7214
|
return;
|
|
7077
7215
|
}
|
|
7078
|
-
const { name, from, builtIn } =
|
|
7216
|
+
const { name, from, builtIn } = read5.agent;
|
|
7079
7217
|
const refuse3 = (cause, problem) => {
|
|
7080
7218
|
problems.push(problem);
|
|
7081
7219
|
if (!builtIn) refused.push({ folder, name, file: from, cause });
|
|
@@ -7099,14 +7237,14 @@ function readCatalog() {
|
|
|
7099
7237
|
`${from}: its folder is \`${folder}\` but it calls itself \`${name}\`. An agent is asked for by its folder name \u2014 make the two match.`
|
|
7100
7238
|
);
|
|
7101
7239
|
}
|
|
7102
|
-
agents.push(
|
|
7240
|
+
agents.push(read5.agent);
|
|
7103
7241
|
};
|
|
7104
7242
|
for (const folder of bundledFolders()) take(readBundled(folder), folder);
|
|
7105
7243
|
for (const folder of projectFolders(AGENTS)) {
|
|
7106
|
-
const
|
|
7107
|
-
take(
|
|
7108
|
-
if ("agent" in
|
|
7109
|
-
problems.push(`${
|
|
7244
|
+
const read5 = readProject(AGENTS, folder);
|
|
7245
|
+
take(read5, folder);
|
|
7246
|
+
if ("agent" in read5 && read5.agent.from.endsWith(LEGACY_AGENT_FILE)) {
|
|
7247
|
+
problems.push(`${read5.agent.from}: rename it to ${AGENT_FILE}`);
|
|
7110
7248
|
}
|
|
7111
7249
|
}
|
|
7112
7250
|
for (const folder of projectFolders(LEGACY_AGENTS)) {
|
|
@@ -7211,10 +7349,10 @@ function readProject(root2, folder) {
|
|
|
7211
7349
|
const missing = rel(path23.join(dir, AGENT_FILE));
|
|
7212
7350
|
if (!found2) return { problem: `${missing} is missing`, file: missing, missing: true };
|
|
7213
7351
|
const from = rel(path23.join(dir, found2.name));
|
|
7214
|
-
const
|
|
7215
|
-
if ("problem" in
|
|
7216
|
-
if ("agent" in
|
|
7217
|
-
return
|
|
7352
|
+
const read5 = parseSpecAgent(found2.text, from, file, false, () => ownFiles(walkFolder(dir, "")));
|
|
7353
|
+
if ("problem" in read5) return { ...read5, file: from };
|
|
7354
|
+
if ("agent" in read5) Object.assign(read5.agent, { dir, text: found2.text });
|
|
7355
|
+
return read5;
|
|
7218
7356
|
}
|
|
7219
7357
|
var specAgentCatalog, bundledFolders, AGENT_FILE, LEGACY_AGENT_FILE, AGENT_FILES, ownFiles;
|
|
7220
7358
|
var init_catalog2 = __esm({
|
|
@@ -8256,10 +8394,10 @@ function findRollout(threadId) {
|
|
|
8256
8394
|
}
|
|
8257
8395
|
for (const name of names3) {
|
|
8258
8396
|
if (!name.startsWith("rollout-") || !name.endsWith(tail2)) continue;
|
|
8259
|
-
const
|
|
8397
|
+
const path90 = join(dir, name);
|
|
8260
8398
|
try {
|
|
8261
|
-
const at2 = statSync(
|
|
8262
|
-
if (!newest2 || at2 > newest2.at) newest2 = { path:
|
|
8399
|
+
const at2 = statSync(path90).mtimeMs;
|
|
8400
|
+
if (!newest2 || at2 > newest2.at) newest2 = { path: path90, at: at2 };
|
|
8263
8401
|
} catch {
|
|
8264
8402
|
}
|
|
8265
8403
|
}
|
|
@@ -8267,11 +8405,11 @@ function findRollout(threadId) {
|
|
|
8267
8405
|
return newest2?.path;
|
|
8268
8406
|
}
|
|
8269
8407
|
function readCodexRunFacts(threadId) {
|
|
8270
|
-
const
|
|
8271
|
-
if (!
|
|
8408
|
+
const path90 = findRollout(threadId);
|
|
8409
|
+
if (!path90) return void 0;
|
|
8272
8410
|
let raw;
|
|
8273
8411
|
try {
|
|
8274
|
-
raw = readFileSync(
|
|
8412
|
+
raw = readFileSync(path90, "utf8");
|
|
8275
8413
|
} catch {
|
|
8276
8414
|
return void 0;
|
|
8277
8415
|
}
|
|
@@ -8399,8 +8537,8 @@ function renderCompleted(item) {
|
|
|
8399
8537
|
const changes = Array.isArray(item.changes) ? item.changes : [];
|
|
8400
8538
|
return changes.map((raw) => {
|
|
8401
8539
|
const change2 = obj(raw);
|
|
8402
|
-
const
|
|
8403
|
-
return
|
|
8540
|
+
const path90 = str2(change2.path);
|
|
8541
|
+
return path90 ? `\u23FA ${str2(change2.kind) || "change"}(${path90})
|
|
8404
8542
|
` : "";
|
|
8405
8543
|
}).join("");
|
|
8406
8544
|
}
|
|
@@ -8662,10 +8800,10 @@ function readKimiRunFacts(sessionId) {
|
|
|
8662
8800
|
const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
|
|
8663
8801
|
let model;
|
|
8664
8802
|
let holding = 0;
|
|
8665
|
-
for (const { path:
|
|
8803
|
+
for (const { path: path90, main } of wireFiles(entry.sessionDir)) {
|
|
8666
8804
|
let raw;
|
|
8667
8805
|
try {
|
|
8668
|
-
raw = readFileSync2(
|
|
8806
|
+
raw = readFileSync2(path90, "utf8");
|
|
8669
8807
|
} catch {
|
|
8670
8808
|
continue;
|
|
8671
8809
|
}
|
|
@@ -8728,9 +8866,9 @@ function toolCalls(row) {
|
|
|
8728
8866
|
}).join("");
|
|
8729
8867
|
}
|
|
8730
8868
|
function retry(row) {
|
|
8731
|
-
const
|
|
8869
|
+
const why2 = str2(row.error_message) || str2(row.error_name) || "the provider failed";
|
|
8732
8870
|
const attempt2 = `${num(row.next_attempt)}/${num(row.max_attempts)}`;
|
|
8733
|
-
return `[retry ${attempt2}] ${
|
|
8871
|
+
return `[retry ${attempt2}] ${why2}
|
|
8734
8872
|
`;
|
|
8735
8873
|
}
|
|
8736
8874
|
function createKimiStreamRenderer(cwd) {
|
|
@@ -8819,10 +8957,10 @@ function connect(stdout, stdin, onCall, dialect = {}) {
|
|
|
8819
8957
|
} catch {
|
|
8820
8958
|
}
|
|
8821
8959
|
};
|
|
8822
|
-
const closed2 = (
|
|
8960
|
+
const closed2 = (why2) => {
|
|
8823
8961
|
if (gone) return;
|
|
8824
|
-
gone =
|
|
8825
|
-
for (const { fail } of waiting.values()) fail(new Error(
|
|
8962
|
+
gone = why2;
|
|
8963
|
+
for (const { fail } of waiting.values()) fail(new Error(why2));
|
|
8826
8964
|
waiting.clear();
|
|
8827
8965
|
};
|
|
8828
8966
|
stdout.on("data", (chunk) => {
|
|
@@ -8946,8 +9084,8 @@ var init_tail = __esm({
|
|
|
8946
9084
|
import fs28 from "node:fs";
|
|
8947
9085
|
function whereHint(update2, title) {
|
|
8948
9086
|
const locations = Array.isArray(update2.locations) ? update2.locations : [];
|
|
8949
|
-
const
|
|
8950
|
-
return
|
|
9087
|
+
const path90 = str2(obj(locations[0]).path);
|
|
9088
|
+
return path90 && !title.includes(path90) ? hint(path90) : "";
|
|
8951
9089
|
}
|
|
8952
9090
|
function saidBy(update2) {
|
|
8953
9091
|
const content = Array.isArray(update2.content) ? update2.content : [];
|
|
@@ -9112,12 +9250,12 @@ async function oneTurn(io, options) {
|
|
|
9112
9250
|
const usage3 = usageOf2(done2.usage) ?? usageOf2(spent, true);
|
|
9113
9251
|
costUsd ??= ticksUsd(spent.costUsdTicks);
|
|
9114
9252
|
if (stopReason2 && stopReason2 !== "end_turn") {
|
|
9115
|
-
const
|
|
9116
|
-
io.log(`[error] ${
|
|
9253
|
+
const why2 = STOPPED[stopReason2] ?? `the agent stopped: ${stopReason2}`;
|
|
9254
|
+
io.log(`[error] ${why2}
|
|
9117
9255
|
`);
|
|
9118
|
-
events.error(
|
|
9256
|
+
events.error(why2);
|
|
9119
9257
|
emit();
|
|
9120
|
-
return { ok: false, result, error:
|
|
9258
|
+
return { ok: false, result, error: why2, usage: usage3, context, costUsd };
|
|
9121
9259
|
}
|
|
9122
9260
|
emit();
|
|
9123
9261
|
return { ok: true, result, usage: usage3, context, costUsd };
|
|
@@ -9147,8 +9285,8 @@ function update(raw, tail2, gotCost, gotContext) {
|
|
|
9147
9285
|
}
|
|
9148
9286
|
case "tool_call_update": {
|
|
9149
9287
|
if (change2.status !== "failed") return;
|
|
9150
|
-
const
|
|
9151
|
-
tail2.line(`[error] ${str2(change2.title) || "that tool call"} failed${
|
|
9288
|
+
const why2 = saidBy(change2);
|
|
9289
|
+
tail2.line(`[error] ${str2(change2.title) || "that tool call"} failed${why2 ? `: ${why2}` : ""}`);
|
|
9152
9290
|
return;
|
|
9153
9291
|
}
|
|
9154
9292
|
case "usage_update": {
|
|
@@ -9262,8 +9400,8 @@ function createParts(tail2) {
|
|
|
9262
9400
|
tail2.line(`\u23FA ${title}${whereHint2(state.input, title)}`);
|
|
9263
9401
|
}
|
|
9264
9402
|
if (str2(state.status) === "error") {
|
|
9265
|
-
const
|
|
9266
|
-
tail2.line(`[error] ${title} failed${
|
|
9403
|
+
const why2 = str2(state.error).trim();
|
|
9404
|
+
tail2.line(`[error] ${title} failed${why2 ? `: ${why2}` : ""}`);
|
|
9267
9405
|
}
|
|
9268
9406
|
},
|
|
9269
9407
|
/** A piece of one part, as `part.delta` sends it. */
|
|
@@ -9296,18 +9434,18 @@ function createParts(tail2) {
|
|
|
9296
9434
|
toolUpdate(payload) {
|
|
9297
9435
|
if (str2(payload.kind) !== "error") return;
|
|
9298
9436
|
const name = named2.get(str2(payload.toolCallId)) ?? "tool";
|
|
9299
|
-
const
|
|
9300
|
-
tail2.line(`[error] ${name} failed${
|
|
9437
|
+
const why2 = str2(obj(payload.error).message).split("\n")[0].trim();
|
|
9438
|
+
tail2.line(`[error] ${name} failed${why2 ? `: ${why2.slice(0, 200)}` : ""}`);
|
|
9301
9439
|
}
|
|
9302
9440
|
};
|
|
9303
9441
|
}
|
|
9304
9442
|
function createZcodeClient(options = {}) {
|
|
9305
9443
|
return { turn: (io) => oneTurn2(io, options) };
|
|
9306
9444
|
}
|
|
9307
|
-
function stopped(io,
|
|
9308
|
-
io.log(`[error] ${
|
|
9445
|
+
function stopped(io, why2) {
|
|
9446
|
+
io.log(`[error] ${why2}
|
|
9309
9447
|
`);
|
|
9310
|
-
if (MISSING_KEY.test(
|
|
9448
|
+
if (MISSING_KEY.test(why2)) {
|
|
9311
9449
|
io.log("[board] paste a Z.AI or BigModel Coding Plan key into ZCode's key box in Configuration.\n");
|
|
9312
9450
|
}
|
|
9313
9451
|
}
|
|
@@ -9397,9 +9535,9 @@ async function oneTurn2(io, options) {
|
|
|
9397
9535
|
const usage3 = done2.usage ?? await tokensOf(rpc, sessionId);
|
|
9398
9536
|
const context = await contextOf(rpc, sessionId);
|
|
9399
9537
|
if (!done2.ok) {
|
|
9400
|
-
const
|
|
9401
|
-
stopped(io,
|
|
9402
|
-
return { ok: false, result, error:
|
|
9538
|
+
const why2 = done2.error ?? "the agent stopped without saying why";
|
|
9539
|
+
stopped(io, why2);
|
|
9540
|
+
return { ok: false, result, error: why2, usage: usage3, context };
|
|
9403
9541
|
}
|
|
9404
9542
|
return { ok: true, result, usage: usage3, context };
|
|
9405
9543
|
} catch (e2) {
|
|
@@ -9418,8 +9556,8 @@ async function tokensOf(rpc, sessionId) {
|
|
|
9418
9556
|
}
|
|
9419
9557
|
async function contextOf(rpc, sessionId) {
|
|
9420
9558
|
try {
|
|
9421
|
-
const
|
|
9422
|
-
const state = obj(
|
|
9559
|
+
const read5 = await rpc.call("session/read", { sessionId, messageLimit: 1 });
|
|
9560
|
+
const state = obj(read5.projection);
|
|
9423
9561
|
const used = num(state.contextUsed);
|
|
9424
9562
|
const limit = num(state.contextWindow);
|
|
9425
9563
|
return used > 0 ? { used, limit: limit > 0 ? limit : void 0 } : void 0;
|
|
@@ -11135,12 +11273,12 @@ var init_language = __esm({
|
|
|
11135
11273
|
|
|
11136
11274
|
// src/lib/agent/proxy.ts
|
|
11137
11275
|
import { execFileSync } from "node:child_process";
|
|
11138
|
-
function withSystemProxy(env2 = process.env, platform = process.platform,
|
|
11276
|
+
function withSystemProxy(env2 = process.env, platform = process.platform, read5 = () => execFileSync("/usr/sbin/scutil", ["--proxy"], { encoding: "utf8", timeout: 1e3, stdio: ["ignore", "pipe", "ignore"] })) {
|
|
11139
11277
|
const out = { ...env2 };
|
|
11140
11278
|
if (platform !== "darwin" || PROXY_KEYS.some((key) => env2[key] !== void 0)) return out;
|
|
11141
11279
|
let raw;
|
|
11142
11280
|
try {
|
|
11143
|
-
raw =
|
|
11281
|
+
raw = read5();
|
|
11144
11282
|
} catch {
|
|
11145
11283
|
return out;
|
|
11146
11284
|
}
|
|
@@ -11780,12 +11918,12 @@ function readAnswers(raw) {
|
|
|
11780
11918
|
if (!Array.isArray(raw)) return void 0;
|
|
11781
11919
|
const answers2 = raw.flatMap((entry) => {
|
|
11782
11920
|
if (!entry || entry.outcome !== "changed" && entry.outcome !== "unchanged") return [];
|
|
11783
|
-
const
|
|
11784
|
-
if (!
|
|
11921
|
+
const why2 = text3(entry.why);
|
|
11922
|
+
if (!why2) return [];
|
|
11785
11923
|
return [
|
|
11786
11924
|
{
|
|
11787
11925
|
outcome: entry.outcome,
|
|
11788
|
-
why,
|
|
11926
|
+
why: why2,
|
|
11789
11927
|
at: typeof entry.at === "number" ? entry.at : 0,
|
|
11790
11928
|
actedAt: typeof entry.actedAt === "number" ? entry.actedAt : void 0
|
|
11791
11929
|
}
|
|
@@ -12212,12 +12350,12 @@ function writeConfig(change2) {
|
|
|
12212
12350
|
try {
|
|
12213
12351
|
cfg = readConfigRaw();
|
|
12214
12352
|
} catch (e2) {
|
|
12215
|
-
const
|
|
12353
|
+
const why2 = e2 instanceof Error ? e2.message : String(e2);
|
|
12216
12354
|
return {
|
|
12217
12355
|
ok: false,
|
|
12218
|
-
...refusal("fileParse", `couldn't save: ${UI_CONFIG} won't parse (${
|
|
12356
|
+
...refusal("fileParse", `couldn't save: ${UI_CONFIG} won't parse (${why2}). Fix the file, then try again.`, {
|
|
12219
12357
|
path: UI_CONFIG,
|
|
12220
|
-
details:
|
|
12358
|
+
details: why2
|
|
12221
12359
|
})
|
|
12222
12360
|
};
|
|
12223
12361
|
}
|
|
@@ -12228,8 +12366,8 @@ function writeConfig(change2) {
|
|
|
12228
12366
|
forgetFileMemos();
|
|
12229
12367
|
return { ok: true };
|
|
12230
12368
|
} catch (e2) {
|
|
12231
|
-
const
|
|
12232
|
-
return { ok: false, ...refusal("fileWrite", `couldn't write ${UI_CONFIG}: ${
|
|
12369
|
+
const why2 = e2 instanceof Error ? e2.message : String(e2);
|
|
12370
|
+
return { ok: false, ...refusal("fileWrite", `couldn't write ${UI_CONFIG}: ${why2}`, { path: UI_CONFIG, details: why2 }) };
|
|
12233
12371
|
}
|
|
12234
12372
|
}
|
|
12235
12373
|
function parseLine(line) {
|
|
@@ -12275,12 +12413,12 @@ function ensureIgnored() {
|
|
|
12275
12413
|
fs34.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${IGNORE_BLOCK}`);
|
|
12276
12414
|
return { ok: true };
|
|
12277
12415
|
} catch (e2) {
|
|
12278
|
-
const
|
|
12416
|
+
const why2 = e2 instanceof Error ? e2.message : String(e2);
|
|
12279
12417
|
return {
|
|
12280
12418
|
ok: false,
|
|
12281
|
-
...refusal("gitignoreWrite", `couldn't write ${KANBAN_GITIGNORE} to keep the key out of git: ${
|
|
12419
|
+
...refusal("gitignoreWrite", `couldn't write ${KANBAN_GITIGNORE} to keep the key out of git: ${why2}`, {
|
|
12282
12420
|
path: KANBAN_GITIGNORE,
|
|
12283
|
-
details:
|
|
12421
|
+
details: why2
|
|
12284
12422
|
})
|
|
12285
12423
|
};
|
|
12286
12424
|
}
|
|
@@ -12292,8 +12430,8 @@ function setSecret(name, value) {
|
|
|
12292
12430
|
try {
|
|
12293
12431
|
lines = fs34.existsSync(ENV_FILE) ? fs34.readFileSync(ENV_FILE, "utf8").split("\n") : [];
|
|
12294
12432
|
} catch (e2) {
|
|
12295
|
-
const
|
|
12296
|
-
return { ok: false, ...refusal("fileRead", `couldn't read ${ENV_FILE}: ${
|
|
12433
|
+
const why2 = e2 instanceof Error ? e2.message : String(e2);
|
|
12434
|
+
return { ok: false, ...refusal("fileRead", `couldn't read ${ENV_FILE}: ${why2}`, { path: ENV_FILE, details: why2 }) };
|
|
12297
12435
|
}
|
|
12298
12436
|
const next = value.trim();
|
|
12299
12437
|
const kept2 = [];
|
|
@@ -12316,8 +12454,8 @@ function setSecret(name, value) {
|
|
|
12316
12454
|
fs34.writeFileSync(ENV_FILE, text5, { mode: 384 });
|
|
12317
12455
|
return { ok: true };
|
|
12318
12456
|
} catch (e2) {
|
|
12319
|
-
const
|
|
12320
|
-
return { ok: false, ...refusal("fileWrite", `couldn't write ${ENV_FILE}: ${
|
|
12457
|
+
const why2 = e2 instanceof Error ? e2.message : String(e2);
|
|
12458
|
+
return { ok: false, ...refusal("fileWrite", `couldn't write ${ENV_FILE}: ${why2}`, { path: ENV_FILE, details: why2 }) };
|
|
12321
12459
|
}
|
|
12322
12460
|
}
|
|
12323
12461
|
function stampSchedule(key, when) {
|
|
@@ -13595,12 +13733,12 @@ function readFolder2(id, problems) {
|
|
|
13595
13733
|
problems.push(`${rel(fileOf(id))} is missing`);
|
|
13596
13734
|
return null;
|
|
13597
13735
|
}
|
|
13598
|
-
const
|
|
13599
|
-
if ("problem" in
|
|
13600
|
-
problems.push(
|
|
13736
|
+
const read5 = parseWorkflowFile(id, source, rel(fileOf(id)));
|
|
13737
|
+
if ("problem" in read5) {
|
|
13738
|
+
problems.push(read5.problem);
|
|
13601
13739
|
return null;
|
|
13602
13740
|
}
|
|
13603
|
-
return
|
|
13741
|
+
return read5.def;
|
|
13604
13742
|
}
|
|
13605
13743
|
function boardWorkflowDefs() {
|
|
13606
13744
|
const problems = [];
|
|
@@ -13761,8 +13899,8 @@ function writeDraft(def, settings) {
|
|
|
13761
13899
|
try {
|
|
13762
13900
|
writeWorkflowDef(def);
|
|
13763
13901
|
} catch (e2) {
|
|
13764
|
-
const
|
|
13765
|
-
return { ok: false, ...refusal("fileWrite", `couldn't write the "${def.name}" workflow: ${
|
|
13902
|
+
const why2 = e2 instanceof Error ? e2.message : String(e2);
|
|
13903
|
+
return { ok: false, ...refusal("fileWrite", `couldn't write the "${def.name}" workflow: ${why2}`, { path: def.id, details: why2 }) };
|
|
13766
13904
|
}
|
|
13767
13905
|
return settings ? save2(settings) : { ok: true };
|
|
13768
13906
|
}
|
|
@@ -14718,8 +14856,8 @@ function takeUnchanged(delivery) {
|
|
|
14718
14856
|
for (const answer2 of live.answers ?? []) if (!answer2.actedAt && answer2.outcome === "unchanged") answer2.actedAt = now;
|
|
14719
14857
|
});
|
|
14720
14858
|
}
|
|
14721
|
-
function recordAnswer(deliveryId, outcome,
|
|
14722
|
-
const line =
|
|
14859
|
+
function recordAnswer(deliveryId, outcome, why2) {
|
|
14860
|
+
const line = why2.trim();
|
|
14723
14861
|
if (!line) return { ok: false, error: "say in one sentence what the answers did \u2014 an unexplained conclusion is not one." };
|
|
14724
14862
|
return withStore((store) => {
|
|
14725
14863
|
const delivery = store.deliveries.find((d2) => d2.deliveryId === deliveryId);
|
|
@@ -15534,6 +15672,14 @@ var init_Storyboard = __esm({
|
|
|
15534
15672
|
}
|
|
15535
15673
|
});
|
|
15536
15674
|
|
|
15675
|
+
// src/components/Workflow.md
|
|
15676
|
+
var Workflow_default;
|
|
15677
|
+
var init_Workflow = __esm({
|
|
15678
|
+
"src/components/Workflow.md"() {
|
|
15679
|
+
Workflow_default = '# Workflow\n\nShow how a workflow runs with `<Workflow src=".assets/<card id>/workflow.json" label="..." />` alone in a paragraph. Inline and fenced examples remain text.\n\n- **Data**: `akb workflow diagram <workflow id> <card id>` writes the file from the workflow and prints the tag; never write or edit the JSON by hand. Rerun it after changing the workflow.\n';
|
|
15680
|
+
}
|
|
15681
|
+
});
|
|
15682
|
+
|
|
15537
15683
|
// src/lib/components.ts
|
|
15538
15684
|
function agentComponents(names3, documents = DOCUMENTS) {
|
|
15539
15685
|
const docs = /* @__PURE__ */ new Map();
|
|
@@ -15566,11 +15712,12 @@ var init_components = __esm({
|
|
|
15566
15712
|
init_Asset();
|
|
15567
15713
|
init_Compare();
|
|
15568
15714
|
init_Storyboard();
|
|
15715
|
+
init_Workflow();
|
|
15569
15716
|
init_agents();
|
|
15570
15717
|
init_io();
|
|
15571
15718
|
init_paths();
|
|
15572
15719
|
init_workflows();
|
|
15573
|
-
DOCUMENTS = { Asset: Asset_default, Compare: Compare_default, Storyboard: Storyboard_default };
|
|
15720
|
+
DOCUMENTS = { Asset: Asset_default, Compare: Compare_default, Storyboard: Storyboard_default, Workflow: Workflow_default };
|
|
15574
15721
|
componentDocsText = (docs) => docs.map((doc) => doc.text.trim()).join("\n\n");
|
|
15575
15722
|
}
|
|
15576
15723
|
});
|
|
@@ -15715,8 +15862,8 @@ import path51 from "node:path";
|
|
|
15715
15862
|
function stopReason(deliveryId) {
|
|
15716
15863
|
const delivery = findDelivery(deliveryId);
|
|
15717
15864
|
if (!delivery) return void 0;
|
|
15718
|
-
const
|
|
15719
|
-
if (
|
|
15865
|
+
const why2 = firstLine(delivery.review?.stopped?.why);
|
|
15866
|
+
if (why2) return why2;
|
|
15720
15867
|
const ids = new Set(delivery.sessions);
|
|
15721
15868
|
const last = readRuns().filter((r2) => ids.has(r2.sessionId) && r2.action === "implement" && r2.status !== "running").at(-1);
|
|
15722
15869
|
if (!last) return void 0;
|
|
@@ -16530,9 +16677,9 @@ function endedDeliveryRefusal(r2, refusals) {
|
|
|
16530
16677
|
if (refusals?.has(r2.deliveryId)) return refusals.get(r2.deliveryId);
|
|
16531
16678
|
const delivery = findDelivery(r2.deliveryId);
|
|
16532
16679
|
const ended = delivery && delivery.status !== "active" && (delivery.status !== "failed" || delivery.worktree);
|
|
16533
|
-
const
|
|
16534
|
-
refusals?.set(r2.deliveryId,
|
|
16535
|
-
return
|
|
16680
|
+
const why2 = ended ? resumeRefusal(delivery) : void 0;
|
|
16681
|
+
refusals?.set(r2.deliveryId, why2);
|
|
16682
|
+
return why2;
|
|
16536
16683
|
}
|
|
16537
16684
|
function retryAsk(r2) {
|
|
16538
16685
|
if (r2.resumedFrom && r2.action !== "create" || isRetired(r2.action)) return void 0;
|
|
@@ -16863,7 +17010,7 @@ function planningSession(cardId2, cwd = REPO_ROOT) {
|
|
|
16863
17010
|
function carriedSession(req) {
|
|
16864
17011
|
const carries = PLANNING.has(req.action) || req.action === "implement" && !!req.carry?.resumeId;
|
|
16865
17012
|
if (!Number.isInteger(req.id) || !carries) return void 0;
|
|
16866
|
-
const fresh = (
|
|
17013
|
+
const fresh = (why2) => ({ note: `new session \u2014 ${why2}` });
|
|
16867
17014
|
if (req.session === "new") return fresh("the earlier one is gone, so this step was started again");
|
|
16868
17015
|
const agent = agentForRun(req);
|
|
16869
17016
|
const own = planRun(randomUUID5(), REPO_ROOT, agent, req.runtime ? { pin: req.runtime } : {});
|
|
@@ -17447,7 +17594,7 @@ var init_sessions = __esm({
|
|
|
17447
17594
|
asksPathOf = (sessionId) => path52.join(SESSIONS_DIR, `${sessionId}.asks.json`);
|
|
17448
17595
|
carriesSession = (r2) => !!(r2.resumedFrom || r2.continues && !r2.continues.fork);
|
|
17449
17596
|
canPickUp = (r2) => (r2.status === "error" || r2.status === "interrupted" || r2.status === "stopped") && !(r2.action === "create" && readRuns().some((next) => next.resumedFrom === r2.sessionId));
|
|
17450
|
-
neverStarted = (r2) => r2.unspawned === true || !!r2.errorWhy?.some((
|
|
17597
|
+
neverStarted = (r2) => r2.unspawned === true || !!r2.errorWhy?.some((why2) => why2.kind === "notInstalled");
|
|
17451
17598
|
lacksSession = (r2) => neverStarted(r2) || !resumeIdOf(r2);
|
|
17452
17599
|
carriesOn = (r2) => resumesUnder(r2.harness) || restartable(r2);
|
|
17453
17600
|
CARDLESS = /* @__PURE__ */ new Set(["prune-memory", "review-memory", "review-dismissals", "describe-project"]);
|
|
@@ -17828,7 +17975,7 @@ function storyboardAttrs(raw) {
|
|
|
17828
17975
|
const text5 = label ? (label[1] ?? label[2]).trim() : "";
|
|
17829
17976
|
return { src: src[1] ?? src[2], ...text5 ? { label: text5 } : {} };
|
|
17830
17977
|
}
|
|
17831
|
-
function storyboardMarkers(body) {
|
|
17978
|
+
function storyboardMarkers(body, tagOf = storyboardTag) {
|
|
17832
17979
|
const lines = body.replace(/\r\n/g, "\n").split("\n");
|
|
17833
17980
|
const found2 = [];
|
|
17834
17981
|
let fence = null;
|
|
@@ -17842,7 +17989,7 @@ function storyboardMarkers(body) {
|
|
|
17842
17989
|
fence = delimiter[1];
|
|
17843
17990
|
return;
|
|
17844
17991
|
}
|
|
17845
|
-
const src =
|
|
17992
|
+
const src = tagOf(line);
|
|
17846
17993
|
if (src !== null && !lines[i - 1]?.trim() && !lines[i + 1]?.trim()) found2.push({ src, line: i + 1 });
|
|
17847
17994
|
});
|
|
17848
17995
|
return found2;
|
|
@@ -17859,7 +18006,7 @@ function assetName(src, cardId2, exts, nested = false) {
|
|
|
17859
18006
|
if (!name.includes(".") || !exts.includes(ext)) return { expected, actual: `file type ${JSON.stringify(name.includes(".") ? ext : "")}` };
|
|
17860
18007
|
return { name };
|
|
17861
18008
|
}
|
|
17862
|
-
var TAG2, attr, SRC_ATTR, LABEL_ATTR, SEGMENT2, storyboardTag;
|
|
18009
|
+
var TAG2, attr, SRC_ATTR, LABEL_ATTR, SEGMENT2, storyboardTag, workflowTag;
|
|
17863
18010
|
var init_storyboard = __esm({
|
|
17864
18011
|
"src/lib/storyboard.ts"() {
|
|
17865
18012
|
"use strict";
|
|
@@ -17869,12 +18016,492 @@ var init_storyboard = __esm({
|
|
|
17869
18016
|
LABEL_ATTR = attr("label");
|
|
17870
18017
|
SEGMENT2 = /^(?!\.)[^/\\]+$/;
|
|
17871
18018
|
storyboardTag = (raw) => storyboardAttrs(raw)?.src ?? null;
|
|
18019
|
+
workflowTag = (raw) => {
|
|
18020
|
+
const m = /^<Workflow\b([^<>]*?)\/>$/.exec(raw.trim());
|
|
18021
|
+
const src = m ? SRC_ATTR.exec(m[1]) : null;
|
|
18022
|
+
return src ? src[1] ?? src[2] : null;
|
|
18023
|
+
};
|
|
17872
18024
|
}
|
|
17873
18025
|
});
|
|
17874
18026
|
|
|
17875
|
-
// src/
|
|
18027
|
+
// ../artifact-sdk/src/builtin/compare.json
|
|
18028
|
+
var compare_default;
|
|
18029
|
+
var init_compare2 = __esm({
|
|
18030
|
+
"../artifact-sdk/src/builtin/compare.json"() {
|
|
18031
|
+
compare_default = '{\n "name": "compare",\n "title": { "en": "Compare", "zh": "\u5BF9\u6BD4" },\n "types": ["compare"],\n "schema": {\n "type": "object",\n "required": ["a", "b"],\n "properties": { "a": { "type": "string" }, "b": { "type": "string" } }\n },\n "references": [\n { "json": "/a", "types": ["storyboard", "compare"] },\n { "json": "/b", "types": ["storyboard", "compare"] },\n { "json": "/shots", "types": ["storyboard", "compare"] }\n ]\n}\n';
|
|
18032
|
+
}
|
|
18033
|
+
});
|
|
18034
|
+
|
|
18035
|
+
// ../artifact-sdk/src/builtin/html.json
|
|
18036
|
+
var html_default;
|
|
18037
|
+
var init_html = __esm({
|
|
18038
|
+
"../artifact-sdk/src/builtin/html.json"() {
|
|
18039
|
+
html_default = `{
|
|
18040
|
+
"name": "html",
|
|
18041
|
+
"title": { "en": "Page", "zh": "\u9875\u9762" },
|
|
18042
|
+
"types": ["html"],
|
|
18043
|
+
"references": [
|
|
18044
|
+
{ "text": "<[a-z][^<>]*?\\\\ssrc\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
|
|
18045
|
+
{ "text": "<[a-z][^<>]*?\\\\sposter\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
|
|
18046
|
+
{ "text": "<[a-z][^<>]*?\\\\ssrcset\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']", "list": "," },
|
|
18047
|
+
{ "text": "<link\\\\b[^<>]*?\\\\shref\\\\s*=\\\\s*[\\"']([^\\"']+)[\\"']" },
|
|
18048
|
+
{ "text": "url\\\\(\\\\s*[\\"']?([^\\"')]+?)[\\"']?\\\\s*\\\\)" }
|
|
18049
|
+
]
|
|
18050
|
+
}
|
|
18051
|
+
`;
|
|
18052
|
+
}
|
|
18053
|
+
});
|
|
18054
|
+
|
|
18055
|
+
// ../artifact-sdk/src/builtin/image.json
|
|
18056
|
+
var image_default;
|
|
18057
|
+
var init_image = __esm({
|
|
18058
|
+
"../artifact-sdk/src/builtin/image.json"() {
|
|
18059
|
+
image_default = '{ "name": "image", "title": { "en": "Image", "zh": "\u56FE\u7247" }, "types": ["image"] }\n';
|
|
18060
|
+
}
|
|
18061
|
+
});
|
|
18062
|
+
|
|
18063
|
+
// ../artifact-sdk/src/builtin/markdown.json
|
|
18064
|
+
var markdown_default;
|
|
18065
|
+
var init_markdown = __esm({
|
|
18066
|
+
"../artifact-sdk/src/builtin/markdown.json"() {
|
|
18067
|
+
markdown_default = '{ "name": "markdown", "title": { "en": "Document", "zh": "\u6587\u6863" }, "types": ["markdown"] }\n';
|
|
18068
|
+
}
|
|
18069
|
+
});
|
|
18070
|
+
|
|
18071
|
+
// ../artifact-sdk/src/builtin/storyboard.json
|
|
18072
|
+
var storyboard_default;
|
|
18073
|
+
var init_storyboard2 = __esm({
|
|
18074
|
+
"../artifact-sdk/src/builtin/storyboard.json"() {
|
|
18075
|
+
storyboard_default = '{\n "name": "storyboard",\n "title": { "en": "Storyboard", "zh": "\u5206\u955C" },\n "types": ["storyboard"],\n "schema": {\n "type": "object",\n "anyOf": [{ "required": ["shots"] }, { "required": ["slides"] }],\n "properties": {\n "shots": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": { "frames": { "type": "array", "items": { "type": "object", "properties": { "src": { "type": "string" } } } } }\n }\n },\n "slides": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": {\n "preview": { "type": "object", "properties": { "src": { "type": "string" } } },\n "assets": { "type": "array", "items": { "type": "string" } }\n }\n }\n }\n }\n },\n "references": [\n { "json": "/shots/*/frames/*/src" },\n { "json": "/slides/*/preview/src" },\n { "json": "/slides/*/assets/*" }\n ]\n}\n';
|
|
18076
|
+
}
|
|
18077
|
+
});
|
|
18078
|
+
|
|
18079
|
+
// ../artifact-sdk/src/builtin/video.json
|
|
18080
|
+
var video_default;
|
|
18081
|
+
var init_video = __esm({
|
|
18082
|
+
"../artifact-sdk/src/builtin/video.json"() {
|
|
18083
|
+
video_default = '{ "name": "video", "title": { "en": "Video", "zh": "\u89C6\u9891" }, "types": ["video"] }\n';
|
|
18084
|
+
}
|
|
18085
|
+
});
|
|
18086
|
+
|
|
18087
|
+
// ../artifact-sdk/src/builtin/workflow.json
|
|
18088
|
+
var workflow_default;
|
|
18089
|
+
var init_workflow = __esm({
|
|
18090
|
+
"../artifact-sdk/src/builtin/workflow.json"() {
|
|
18091
|
+
workflow_default = '{\n "name": "workflow",\n "title": { "en": "Workflow", "zh": "\u5DE5\u4F5C\u6D41" },\n "types": ["workflow"],\n "schema": {\n "type": "object",\n "required": ["rounds", "land", "scheduled"],\n "properties": {\n "rounds": {\n "type": "array",\n "items": {\n "type": "array",\n "minItems": 1,\n "items": { "type": "object", "required": ["agent", "title"], "properties": { "agent": { "type": "string" }, "title": { "type": "object", "required": ["en"] } } }\n }\n },\n "land": { "type": "array", "items": { "type": "object", "required": ["agent", "title"] } },\n "scheduled": { "type": "array", "items": { "type": "object", "required": ["agent", "title"] } }\n }\n }\n}\n';
|
|
18092
|
+
}
|
|
18093
|
+
});
|
|
18094
|
+
|
|
18095
|
+
// ../artifact-sdk/src/builtin/index.ts
|
|
18096
|
+
var read, builtin_default;
|
|
18097
|
+
var init_builtin = __esm({
|
|
18098
|
+
"../artifact-sdk/src/builtin/index.ts"() {
|
|
18099
|
+
"use strict";
|
|
18100
|
+
init_compare2();
|
|
18101
|
+
init_html();
|
|
18102
|
+
init_image();
|
|
18103
|
+
init_markdown();
|
|
18104
|
+
init_storyboard2();
|
|
18105
|
+
init_video();
|
|
18106
|
+
init_workflow();
|
|
18107
|
+
read = (m) => typeof m === "string" ? JSON.parse(m) : m;
|
|
18108
|
+
builtin_default = [html_default, image_default, video_default, markdown_default, storyboard_default, compare_default, workflow_default].map(read);
|
|
18109
|
+
}
|
|
18110
|
+
});
|
|
18111
|
+
|
|
18112
|
+
// ../artifact-sdk/src/internal/schema.ts
|
|
18113
|
+
function typeOk(type, v) {
|
|
18114
|
+
const types = Array.isArray(type) ? type : [type];
|
|
18115
|
+
return types.some(
|
|
18116
|
+
(t) => t === "null" ? v === null : t === "array" ? Array.isArray(v) : t === "object" ? isObj(v) : t === "integer" ? Number.isInteger(v) : t === "number" ? typeof v === "number" && Number.isFinite(v) : typeof v === t
|
|
18117
|
+
);
|
|
18118
|
+
}
|
|
18119
|
+
function schemaProblem(schema, value, at2 = "") {
|
|
18120
|
+
if (!isObj(schema)) return null;
|
|
18121
|
+
const s = schema;
|
|
18122
|
+
const here = at2 || "/";
|
|
18123
|
+
if (s.type !== void 0 && !typeOk(s.type, value)) return here;
|
|
18124
|
+
if (Array.isArray(s.enum) && !s.enum.some((e2) => JSON.stringify(e2) === JSON.stringify(value))) return here;
|
|
18125
|
+
if (s.const !== void 0 && JSON.stringify(s.const) !== JSON.stringify(value)) return here;
|
|
18126
|
+
if (Array.isArray(s.anyOf) && !s.anyOf.some((x2) => !schemaProblem(x2, value, at2))) return here;
|
|
18127
|
+
if (typeof value === "string") {
|
|
18128
|
+
if (typeof s.minLength === "number" && value.length < s.minLength) return here;
|
|
18129
|
+
if (typeof s.maxLength === "number" && value.length > s.maxLength) return here;
|
|
18130
|
+
if (typeof s.pattern === "string") {
|
|
18131
|
+
try {
|
|
18132
|
+
if (!new RegExp(s.pattern, "u").test(value)) return here;
|
|
18133
|
+
} catch {
|
|
18134
|
+
}
|
|
18135
|
+
}
|
|
18136
|
+
}
|
|
18137
|
+
if (typeof value === "number") {
|
|
18138
|
+
if (typeof s.minimum === "number" && value < s.minimum) return here;
|
|
18139
|
+
if (typeof s.maximum === "number" && value > s.maximum) return here;
|
|
18140
|
+
}
|
|
18141
|
+
if (Array.isArray(value)) {
|
|
18142
|
+
if (typeof s.minItems === "number" && value.length < s.minItems) return here;
|
|
18143
|
+
if (typeof s.maxItems === "number" && value.length > s.maxItems) return here;
|
|
18144
|
+
if (isObj(s.items)) {
|
|
18145
|
+
for (let i = 0; i < value.length; i++) {
|
|
18146
|
+
const bad = schemaProblem(s.items, value[i], `${at2}/${i}`);
|
|
18147
|
+
if (bad) return bad;
|
|
18148
|
+
}
|
|
18149
|
+
}
|
|
18150
|
+
}
|
|
18151
|
+
if (isObj(value)) {
|
|
18152
|
+
const props = isObj(s.properties) ? s.properties : {};
|
|
18153
|
+
if (Array.isArray(s.required)) {
|
|
18154
|
+
for (const k2 of s.required) if (typeof k2 === "string" && !(k2 in value)) return `${at2}/${k2}`;
|
|
18155
|
+
}
|
|
18156
|
+
for (const [k2, v] of Object.entries(value)) {
|
|
18157
|
+
if (k2 in props) {
|
|
18158
|
+
const bad = schemaProblem(props[k2], v, `${at2}/${k2}`);
|
|
18159
|
+
if (bad) return bad;
|
|
18160
|
+
} else if (s.additionalProperties === false) return `${at2}/${k2}`;
|
|
18161
|
+
else if (isObj(s.additionalProperties)) {
|
|
18162
|
+
const bad = schemaProblem(s.additionalProperties, v, `${at2}/${k2}`);
|
|
18163
|
+
if (bad) return bad;
|
|
18164
|
+
}
|
|
18165
|
+
}
|
|
18166
|
+
}
|
|
18167
|
+
return null;
|
|
18168
|
+
}
|
|
18169
|
+
var isObj;
|
|
18170
|
+
var init_schema = __esm({
|
|
18171
|
+
"../artifact-sdk/src/internal/schema.ts"() {
|
|
18172
|
+
"use strict";
|
|
18173
|
+
isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
18174
|
+
}
|
|
18175
|
+
});
|
|
18176
|
+
|
|
18177
|
+
// ../artifact-sdk/src/internal/manifest.ts
|
|
18178
|
+
function typeOf(data, types) {
|
|
18179
|
+
for (const type of types) if (!schemaProblem(manifestOf(type)?.schema, data)) return { type };
|
|
18180
|
+
if (types.length !== 1) return { type: null };
|
|
18181
|
+
return { type: types[0], problem: `does not match ${types[0]} at ${schemaProblem(manifestOf(types[0])?.schema, data)}` };
|
|
18182
|
+
}
|
|
18183
|
+
function mapJson(node, keys, at2, visit) {
|
|
18184
|
+
if (!keys.length) return typeof node === "string" && node ? visit(node, at2) : node;
|
|
18185
|
+
const [key, ...rest] = keys;
|
|
18186
|
+
if (Array.isArray(node)) {
|
|
18187
|
+
if (key === "*") return node.map((x2, i2) => mapJson(x2, rest, `${at2}/${i2}`, visit));
|
|
18188
|
+
const i = Number(key);
|
|
18189
|
+
return Number.isInteger(i) && i in node ? node.map((x2, j2) => j2 === i ? mapJson(x2, rest, `${at2}/${j2}`, visit) : x2) : node;
|
|
18190
|
+
}
|
|
18191
|
+
if (!isObject(node)) return node;
|
|
18192
|
+
const out = { ...node };
|
|
18193
|
+
for (const k2 of key === "*" ? Object.keys(node) : key in node ? [key] : []) out[k2] = mapJson(node[k2], rest, `${at2}/${k2}`, visit);
|
|
18194
|
+
return out;
|
|
18195
|
+
}
|
|
18196
|
+
function mapText(text5, rule, visit) {
|
|
18197
|
+
let out = "";
|
|
18198
|
+
let last = 0;
|
|
18199
|
+
for (const m of text5.matchAll(new RegExp(rule.text, "gid"))) {
|
|
18200
|
+
const span = m.indices?.[1];
|
|
18201
|
+
if (!span || m[1] === void 0) continue;
|
|
18202
|
+
const line = text5.slice(0, span[0]).split("\n").length;
|
|
18203
|
+
const one = (src) => remote(src) ? src : visit(src, line);
|
|
18204
|
+
const value = rule.list ? m[1].split(rule.list).map((part) => part.replace(/^(\s*)(\S+)/, (_2, space, src) => space + one(src))).join(rule.list) : one(m[1]);
|
|
18205
|
+
out += text5.slice(last, span[0]) + value;
|
|
18206
|
+
last = span[1];
|
|
18207
|
+
}
|
|
18208
|
+
return out + text5.slice(last);
|
|
18209
|
+
}
|
|
18210
|
+
function mapReferences(manifest, content, map2) {
|
|
18211
|
+
for (const rule of manifest?.references ?? []) {
|
|
18212
|
+
const types = rule.types ?? [];
|
|
18213
|
+
if ("json" in rule) {
|
|
18214
|
+
if (typeof content !== "string") content = mapJson(content, rule.json.split("/").filter(Boolean), "", (src, at2) => map2(src, { src, types, text: false, at: at2 || "/" }));
|
|
18215
|
+
} else if (typeof content === "string") {
|
|
18216
|
+
content = mapText(content, rule, (src, line) => map2(src, { src, types, text: true, line }));
|
|
18217
|
+
}
|
|
18218
|
+
}
|
|
18219
|
+
return content;
|
|
18220
|
+
}
|
|
18221
|
+
function referencesOf(manifest, content) {
|
|
18222
|
+
const found2 = [];
|
|
18223
|
+
mapReferences(manifest, content, (src, ref) => (found2.push(ref), src));
|
|
18224
|
+
return found2;
|
|
18225
|
+
}
|
|
18226
|
+
var BUILTINS, manifestOf, isObject, remote;
|
|
18227
|
+
var init_manifest = __esm({
|
|
18228
|
+
"../artifact-sdk/src/internal/manifest.ts"() {
|
|
18229
|
+
"use strict";
|
|
18230
|
+
init_builtin();
|
|
18231
|
+
init_schema();
|
|
18232
|
+
BUILTINS = builtin_default;
|
|
18233
|
+
manifestOf = (type) => BUILTINS.find((m) => m.types.includes(type));
|
|
18234
|
+
isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
18235
|
+
remote = (src) => !src || /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src);
|
|
18236
|
+
}
|
|
18237
|
+
});
|
|
18238
|
+
|
|
18239
|
+
// ../artifact-sdk/src/internal/references.ts
|
|
18240
|
+
function bodyReferences(body) {
|
|
18241
|
+
const lines = body.replace(/<!--[^]*?-->/g, "").split(/\r?\n/);
|
|
18242
|
+
let fence = "";
|
|
18243
|
+
let inTag = false;
|
|
18244
|
+
const out = [];
|
|
18245
|
+
const visible = [];
|
|
18246
|
+
for (const line of lines) {
|
|
18247
|
+
const delimiter = /^ {0,3}(`{3,}|~{3,})/.exec(line)?.[1];
|
|
18248
|
+
if (fence) {
|
|
18249
|
+
if (delimiter && delimiter[0] === fence[0] && delimiter.length >= fence.length) fence = "";
|
|
18250
|
+
visible.push("");
|
|
18251
|
+
continue;
|
|
18252
|
+
}
|
|
18253
|
+
if (delimiter) {
|
|
18254
|
+
fence = delimiter;
|
|
18255
|
+
visible.push("");
|
|
18256
|
+
continue;
|
|
18257
|
+
}
|
|
18258
|
+
const kept2 = inTag || !/^(?: {4}|\t)/.test(line);
|
|
18259
|
+
visible.push(kept2 ? line : "");
|
|
18260
|
+
if (kept2 && /^ {0,3}<(?:Asset|Mockup|Compare|Storyboard|Workflow)\b/.test(line)) inTag = true;
|
|
18261
|
+
if (line.includes("/>")) inTag = false;
|
|
18262
|
+
}
|
|
18263
|
+
const text5 = visible.join("\n").replace(/(`+)[^]*?\1/g, "");
|
|
18264
|
+
const tag = /<(Asset|Mockup|Compare|Storyboard|Workflow)\b([^<>]*?)\/>/g;
|
|
18265
|
+
const blocks = text5.matchAll(/^ {0,3}(?:<(?:Asset|Mockup|Compare|Storyboard|Workflow)\b[^<>]*?\/>[ \t]*(?:\n[ \t]*)?)+$/gm);
|
|
18266
|
+
for (const block of blocks) {
|
|
18267
|
+
const tags = [...block[0].matchAll(tag)];
|
|
18268
|
+
for (const m of tags) {
|
|
18269
|
+
const a2 = {};
|
|
18270
|
+
for (const p2 of m[2].matchAll(/([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) a2[p2[1]] = p2[2] ?? p2[3];
|
|
18271
|
+
if (m[1] === "Compare") {
|
|
18272
|
+
if (!a2.a || !a2.b) continue;
|
|
18273
|
+
for (const k2 of ["a", "b", "shots"]) if (a2[k2]) out.push({ src: a2[k2], types: COMPARE });
|
|
18274
|
+
} else if (a2.src) {
|
|
18275
|
+
out.push({ src: a2.src, types: m[1] === "Storyboard" ? STORYBOARD : m[1] === "Workflow" ? WORKFLOW : [] });
|
|
18276
|
+
if (a2.variants) {
|
|
18277
|
+
try {
|
|
18278
|
+
const v = JSON.parse(a2.variants);
|
|
18279
|
+
if (isObject2(v)) {
|
|
18280
|
+
for (const src of Object.values(v)) if (typeof src === "string" && src) out.push({ src, types: [] });
|
|
18281
|
+
}
|
|
18282
|
+
} catch {
|
|
18283
|
+
}
|
|
18284
|
+
}
|
|
18285
|
+
}
|
|
18286
|
+
}
|
|
18287
|
+
}
|
|
18288
|
+
for (const m of text5.replace(tag, "").matchAll(/\]\(\s*<?([^\s)>]+)>?(?:\s+["'][^]*?["'])?\s*\)/g)) out.push({ src: m[1], types: [] });
|
|
18289
|
+
return out;
|
|
18290
|
+
}
|
|
18291
|
+
function kindOf(ext) {
|
|
18292
|
+
if (ext === ".tsx" || ext === ".html") return "html";
|
|
18293
|
+
if (ext === ".md" || ext === ".mdx") return "markdown";
|
|
18294
|
+
const type = TYPES[ext] ?? "";
|
|
18295
|
+
if (type.startsWith("image/")) return "image";
|
|
18296
|
+
return type.startsWith("video/") || type.startsWith("audio/") ? "video" : "asset";
|
|
18297
|
+
}
|
|
18298
|
+
var STORYBOARD, WORKFLOW, COMPARE, isObject2, bodySources, TYPES;
|
|
18299
|
+
var init_references = __esm({
|
|
18300
|
+
"../artifact-sdk/src/internal/references.ts"() {
|
|
18301
|
+
"use strict";
|
|
18302
|
+
STORYBOARD = ["storyboard"];
|
|
18303
|
+
WORKFLOW = ["workflow"];
|
|
18304
|
+
COMPARE = ["storyboard", "compare"];
|
|
18305
|
+
isObject2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
18306
|
+
bodySources = (body) => [...new Set(bodyReferences(body).map((r2) => r2.src))];
|
|
18307
|
+
TYPES = {
|
|
18308
|
+
".png": "image/png",
|
|
18309
|
+
".jpg": "image/jpeg",
|
|
18310
|
+
".jpeg": "image/jpeg",
|
|
18311
|
+
".gif": "image/gif",
|
|
18312
|
+
".webp": "image/webp",
|
|
18313
|
+
".svg": "image/svg+xml",
|
|
18314
|
+
".mp4": "video/mp4",
|
|
18315
|
+
".webm": "video/webm",
|
|
18316
|
+
".mp3": "audio/mpeg",
|
|
18317
|
+
".pdf": "application/pdf",
|
|
18318
|
+
".html": "text/html",
|
|
18319
|
+
".md": "text/markdown",
|
|
18320
|
+
".mdx": "text/markdown",
|
|
18321
|
+
".mov": "video/quicktime",
|
|
18322
|
+
".wav": "audio/wav",
|
|
18323
|
+
".m4a": "audio/mp4",
|
|
18324
|
+
".json": "application/json",
|
|
18325
|
+
".txt": "text/plain",
|
|
18326
|
+
".otf": "font/otf",
|
|
18327
|
+
".ttf": "font/ttf",
|
|
18328
|
+
".woff": "font/woff",
|
|
18329
|
+
".woff2": "font/woff2",
|
|
18330
|
+
".css": "text/css"
|
|
18331
|
+
};
|
|
18332
|
+
}
|
|
18333
|
+
});
|
|
18334
|
+
|
|
18335
|
+
// ../artifact-sdk/src/internal/collect.ts
|
|
18336
|
+
function collect(body, card, host2) {
|
|
18337
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
18338
|
+
const active2 = /* @__PURE__ */ new Set();
|
|
18339
|
+
const out = [];
|
|
18340
|
+
const visit = (src, types, owner) => {
|
|
18341
|
+
const path90 = src.replace(/[?#].*$/, "");
|
|
18342
|
+
let resolved2;
|
|
18343
|
+
try {
|
|
18344
|
+
resolved2 = host2.resolve(path90, owner);
|
|
18345
|
+
} catch (error) {
|
|
18346
|
+
if (owner !== card) return { key: null, error: why(error) };
|
|
18347
|
+
if (!nodes.has(src)) {
|
|
18348
|
+
const node2 = { key: src, file: null, kind: kindAt(path90, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
|
|
18349
|
+
nodes.set(src, node2);
|
|
18350
|
+
out.push(node2);
|
|
18351
|
+
}
|
|
18352
|
+
return { key: src, error: nodes.get(src).error };
|
|
18353
|
+
}
|
|
18354
|
+
if (!resolved2) return { key: null };
|
|
18355
|
+
const { key, file } = resolved2;
|
|
18356
|
+
if (active2.has(key)) throw new Error(`${owner}: ${src}: \u8D44\u6E90\u4F9D\u8D56\u5FAA\u73AF`);
|
|
18357
|
+
const json = !!file && extOf(file) === ".json";
|
|
18358
|
+
const held4 = nodes.get(key);
|
|
18359
|
+
if (held4) {
|
|
18360
|
+
if (owner === card) held4.aliases.add(src);
|
|
18361
|
+
if (held4.error || !json || !types.length || held4.kind !== "asset") return { key, error: held4.error };
|
|
18362
|
+
out.splice(out.indexOf(held4), 1);
|
|
18363
|
+
}
|
|
18364
|
+
const node = { key, file, kind: "asset", problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: held4?.aliases ?? /* @__PURE__ */ new Set([key]) };
|
|
18365
|
+
if (owner === card) node.aliases.add(src);
|
|
18366
|
+
nodes.set(key, node);
|
|
18367
|
+
active2.add(key);
|
|
18368
|
+
const child = (ref, from) => {
|
|
18369
|
+
const found2 = visit(ref.src, ref.types, from);
|
|
18370
|
+
if (found2.key) node.dependencies.set(ref.src, found2.key);
|
|
18371
|
+
else if (found2.error) node.problems.push({ src: ref.src, ..."line" in ref ? { line: ref.line } : {}, ..."at" in ref ? { at: ref.at } : {}, message: found2.error });
|
|
18372
|
+
node.error ??= found2.error;
|
|
18373
|
+
};
|
|
18374
|
+
if (file) {
|
|
18375
|
+
if (json) {
|
|
18376
|
+
try {
|
|
18377
|
+
node.data = JSON.parse(host2.read(file));
|
|
18378
|
+
const typed = typeOf(node.data, types);
|
|
18379
|
+
node.kind = typed.type ?? "asset";
|
|
18380
|
+
if (typed.problem) node.problems.push({ src: file, message: `${typed.problem}: ${file}` });
|
|
18381
|
+
} catch {
|
|
18382
|
+
node.problems.push({ src: file, message: `not valid JSON: ${file}` });
|
|
18383
|
+
}
|
|
18384
|
+
} else {
|
|
18385
|
+
node.kind = kindOf(extOf(file));
|
|
18386
|
+
try {
|
|
18387
|
+
if (manifestOf(node.kind)?.references) node.data = host2.read(file);
|
|
18388
|
+
} catch (error) {
|
|
18389
|
+
node.problems.push({ src: file, message: why(error) });
|
|
18390
|
+
}
|
|
18391
|
+
}
|
|
18392
|
+
node.error = node.problems[0]?.message;
|
|
18393
|
+
if (!node.error) for (const ref of referencesOf(manifestOf(node.kind), node.data)) child(ref, file);
|
|
18394
|
+
} else {
|
|
18395
|
+
for (const ref of host2.retained(key)) child(ref, card);
|
|
18396
|
+
}
|
|
18397
|
+
active2.delete(key);
|
|
18398
|
+
out.push(node);
|
|
18399
|
+
return { key, error: node.error };
|
|
18400
|
+
};
|
|
18401
|
+
for (const ref of bodyReferences(body)) visit(ref.src, ref.types, card);
|
|
18402
|
+
const sorted = [];
|
|
18403
|
+
const done2 = /* @__PURE__ */ new Set();
|
|
18404
|
+
const order = (node) => {
|
|
18405
|
+
if (done2.has(node.key)) return;
|
|
18406
|
+
done2.add(node.key);
|
|
18407
|
+
for (const key of node.dependencies.values()) {
|
|
18408
|
+
const child = nodes.get(key);
|
|
18409
|
+
if (child) order(child);
|
|
18410
|
+
}
|
|
18411
|
+
sorted.push(node);
|
|
18412
|
+
};
|
|
18413
|
+
for (const node of out) order(node);
|
|
18414
|
+
return sorted;
|
|
18415
|
+
}
|
|
18416
|
+
var extOf, why, kindAt;
|
|
18417
|
+
var init_collect = __esm({
|
|
18418
|
+
"../artifact-sdk/src/internal/collect.ts"() {
|
|
18419
|
+
"use strict";
|
|
18420
|
+
init_manifest();
|
|
18421
|
+
init_references();
|
|
18422
|
+
extOf = (file) => /\.[^./\\]+$/.exec(file)?.[0].toLowerCase() ?? "";
|
|
18423
|
+
why = (error) => error instanceof Error ? error.message : String(error);
|
|
18424
|
+
kindAt = (src, types) => extOf(src) === ".json" ? types[0] ?? "asset" : kindOf(extOf(src));
|
|
18425
|
+
}
|
|
18426
|
+
});
|
|
18427
|
+
|
|
18428
|
+
// src/lib/dress-page.ts
|
|
17876
18429
|
import fs51 from "node:fs";
|
|
17877
18430
|
import path54 from "node:path";
|
|
18431
|
+
function dressPage(file) {
|
|
18432
|
+
const folder = path54.dirname(file);
|
|
18433
|
+
const html = fs51.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
|
|
18434
|
+
const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
|
|
18435
|
+
if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
|
|
18436
|
+
const at3 = path54.resolve(folder, href);
|
|
18437
|
+
if (!at3.startsWith(folder + path54.sep) || !fs51.existsSync(at3)) return tag;
|
|
18438
|
+
const css = fs51.readFileSync(at3, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole2, quote, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole2 : `url(${quote}${path54.relative(folder, path54.resolve(path54.dirname(at3), src)).split(path54.sep).join("/")}${quote})`);
|
|
18439
|
+
return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
|
|
18440
|
+
});
|
|
18441
|
+
const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
|
|
18442
|
+
return /<!doctype\b|<html[\s>]|<head[\s>]/i.test(html) ? html.slice(0, at2) + head + html.slice(at2) : `<!doctype html><html><head>${head}</head><body>${html}</body></html>`;
|
|
18443
|
+
}
|
|
18444
|
+
var CSP, head, referenceText;
|
|
18445
|
+
var init_dress_page = __esm({
|
|
18446
|
+
"src/lib/dress-page.ts"() {
|
|
18447
|
+
"use strict";
|
|
18448
|
+
CSP = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; media-src data: blob:; font-src data: blob:; worker-src 'none'; base-uri 'none'; form-action 'none'";
|
|
18449
|
+
head = `<meta http-equiv="Content-Security-Policy" content="${CSP}"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html{overflow-x:hidden;overscroll-behavior:contain}</style>`;
|
|
18450
|
+
referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) : fs51.readFileSync(file, "utf8");
|
|
18451
|
+
}
|
|
18452
|
+
});
|
|
18453
|
+
|
|
18454
|
+
// src/lib/preview-files.ts
|
|
18455
|
+
import fs52 from "node:fs";
|
|
18456
|
+
import path55 from "node:path";
|
|
18457
|
+
function resolver(card, id) {
|
|
18458
|
+
const roots = [KANBAN, path55.join(ASSETS, String(id)), path55.join(MOCKUPS, String(id))];
|
|
18459
|
+
const real2 = (p2) => fs52.existsSync(p2) ? fs52.realpathSync(p2) : p2;
|
|
18460
|
+
const inside2 = (p2) => roots.some((root2) => p2.startsWith(real2(root2) + path55.sep));
|
|
18461
|
+
return (src, owner) => {
|
|
18462
|
+
if (/^[a-z][\w+.-]*:/i.test(src) || src.startsWith("#") || src.startsWith("//")) return null;
|
|
18463
|
+
if (path55.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
|
|
18464
|
+
const held4 = /^\.(assets|mockups)\//.exec(src);
|
|
18465
|
+
const file = held4 ? path55.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path55.resolve(path55.dirname(owner), src);
|
|
18466
|
+
if (!inside2(path55.resolve(file)) || fs52.existsSync(file) && !inside2(fs52.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
|
|
18467
|
+
if (!fs52.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
|
|
18468
|
+
return { key: fs52.realpathSync(file), file };
|
|
18469
|
+
};
|
|
18470
|
+
}
|
|
18471
|
+
function validatePreviewFiles(card, id, text5) {
|
|
18472
|
+
const resolve2 = resolver(card, id);
|
|
18473
|
+
const errors = [];
|
|
18474
|
+
const graph = collect(text5, card, {
|
|
18475
|
+
resolve: (src, owner) => {
|
|
18476
|
+
if (owner !== card) return resolve2(src, owner);
|
|
18477
|
+
try {
|
|
18478
|
+
return resolve2(src, owner);
|
|
18479
|
+
} catch {
|
|
18480
|
+
return null;
|
|
18481
|
+
}
|
|
18482
|
+
},
|
|
18483
|
+
read: referenceText,
|
|
18484
|
+
retained: () => []
|
|
18485
|
+
});
|
|
18486
|
+
for (const node of graph) {
|
|
18487
|
+
for (const p2 of node.problems) {
|
|
18488
|
+
errors.push({ file: rel(node.file ?? card), line: p2.line ?? 1, rule: "preview-file", message: `${p2.at ? `${p2.at}: ` : ""}${p2.src}: ${p2.message}. Fix the reference or add the file.` });
|
|
18489
|
+
}
|
|
18490
|
+
}
|
|
18491
|
+
return errors;
|
|
18492
|
+
}
|
|
18493
|
+
var init_preview_files = __esm({
|
|
18494
|
+
"src/lib/preview-files.ts"() {
|
|
18495
|
+
"use strict";
|
|
18496
|
+
init_collect();
|
|
18497
|
+
init_dress_page();
|
|
18498
|
+
init_paths();
|
|
18499
|
+
}
|
|
18500
|
+
});
|
|
18501
|
+
|
|
18502
|
+
// src/lib/spec-contract.ts
|
|
18503
|
+
import fs53 from "node:fs";
|
|
18504
|
+
import path56 from "node:path";
|
|
17878
18505
|
function scanCardLines(lines, start = 0) {
|
|
17879
18506
|
const visible = lines.map(() => "");
|
|
17880
18507
|
let fence = null;
|
|
@@ -17907,18 +18534,18 @@ function scanCardLines(lines, start = 0) {
|
|
|
17907
18534
|
}
|
|
17908
18535
|
function snapshotSpecs() {
|
|
17909
18536
|
const out = /* @__PURE__ */ new Map();
|
|
17910
|
-
if (!
|
|
18537
|
+
if (!fs53.existsSync(TODO)) return out;
|
|
17911
18538
|
for (const file of walkMd(TODO)) {
|
|
17912
|
-
if (isLegacyRecurring(
|
|
17913
|
-
const id = idPrefix(
|
|
17914
|
-
if (id !== null) out.set(file, { id, text:
|
|
18539
|
+
if (isLegacyRecurring(path56.relative(TODO, file))) continue;
|
|
18540
|
+
const id = idPrefix(path56.basename(file) === "root.md" ? path56.basename(path56.dirname(file)) : path56.basename(file));
|
|
18541
|
+
if (id !== null) out.set(file, { id, text: fs53.readFileSync(file, "utf8") });
|
|
17915
18542
|
}
|
|
17916
18543
|
return out;
|
|
17917
18544
|
}
|
|
17918
18545
|
function enclosingGroups(file) {
|
|
17919
18546
|
const ids = [];
|
|
17920
18547
|
for (let root2 = enclosingGroupRoot(file); root2; root2 = enclosingGroupRoot(root2)) {
|
|
17921
|
-
const id = idPrefix(
|
|
18548
|
+
const id = idPrefix(path56.basename(path56.dirname(root2)));
|
|
17922
18549
|
if (id !== null) ids.push(id);
|
|
17923
18550
|
}
|
|
17924
18551
|
return ids;
|
|
@@ -18016,8 +18643,8 @@ function validateSpec(file, text5, id) {
|
|
|
18016
18643
|
if (device !== void 0 && device !== "mobile" && device !== "desktop") add(i + 1, "mockup-device", `device="${device}" is not a device. Use device="mobile" or device="desktop".`);
|
|
18017
18644
|
const src = line.match(/\bsrc="([^"]*)"/)?.[1] ?? "";
|
|
18018
18645
|
const variants = line.match(/\bvariants='([^']*)'/)?.[1];
|
|
18019
|
-
const
|
|
18020
|
-
if (
|
|
18646
|
+
const why2 = variants === void 0 ? null : variantsProblem(variants, src, id);
|
|
18647
|
+
if (why2) add(i + 1, "mockup-variants", why2);
|
|
18021
18648
|
else if (id !== void 0 && src.startsWith(".assets/") && !inside(ASSETS, src.slice(".assets/".length))) {
|
|
18022
18649
|
add(i + 1, "asset-src", `src="${src}" names no file. Write it as ${rel(ASSETS)}/${src.slice(".assets/".length)}, or fix the path.`);
|
|
18023
18650
|
}
|
|
@@ -18025,13 +18652,16 @@ function validateSpec(file, text5, id) {
|
|
|
18025
18652
|
if (/^\s*<Storyboard\b/.test(line) && (storyboardTag(line) === null || lines[i - 1]?.trim() || lines[i + 1]?.trim())) {
|
|
18026
18653
|
add(i + 1, "storyboard-block", 'Put one self-closing <Storyboard src=".assets/<card id>/storyboard.json" /> tag on its own line, with blank lines around it.');
|
|
18027
18654
|
}
|
|
18655
|
+
if (/^\s*<Workflow\b/.test(line) && (workflowTag(line) === null || !/\blabel="[^"]+"/.test(line) || lines[i - 1]?.trim() || lines[i + 1]?.trim())) {
|
|
18656
|
+
add(i + 1, "workflow-block", 'Put one self-closing <Workflow src=".assets/<card id>/workflow.json" label="..." /> tag on its own line, with blank lines around it.');
|
|
18657
|
+
}
|
|
18028
18658
|
if (/^\s*<Compare\b/.test(line)) {
|
|
18029
18659
|
const attrs = compareAttrs(line);
|
|
18030
18660
|
if (!attrs || lines[i - 1]?.trim() || lines[i + 1]?.trim()) add(i + 1, "compare-block", 'Put one self-closing <Compare a="..." b="..." label="..." /> tag on its own line, with blank lines around it.');
|
|
18031
18661
|
else if (!attrs.a || !attrs.b || !attrs.label) add(i + 1, "compare-attributes", 'Add non-empty a="...", b="..." and label="..." attributes to the Compare tag.');
|
|
18032
18662
|
else if (id !== void 0) {
|
|
18033
|
-
const
|
|
18034
|
-
if (
|
|
18663
|
+
const why2 = compareProblem(attrs, id);
|
|
18664
|
+
if (why2) add(i + 1, why2.rule, why2.message);
|
|
18035
18665
|
}
|
|
18036
18666
|
}
|
|
18037
18667
|
}
|
|
@@ -18068,14 +18698,14 @@ function validateSpec(file, text5, id) {
|
|
|
18068
18698
|
const next = headings.find((h3) => h3.line > todo.line)?.line ?? lines.length + 1;
|
|
18069
18699
|
if (!visible.slice(todo.line, next - 1).some((line) => /^\s*[-*+]\s*\[[ xX]?\]/.test(line))) add(todo.line, "todos", "## Todo needs at least one checkbox step, for example - [ ] Implement the requested behavior.");
|
|
18070
18700
|
}
|
|
18071
|
-
if (id !== void 0) errors.push(...validateStoryboards(file, id, text5));
|
|
18701
|
+
if (id !== void 0) errors.push(...validateStoryboards(file, id, text5), ...validatePreviewFiles(file, id, text5));
|
|
18072
18702
|
return errors;
|
|
18073
18703
|
}
|
|
18074
18704
|
function inside(dir, name) {
|
|
18075
18705
|
try {
|
|
18076
|
-
const root2 =
|
|
18077
|
-
const real2 =
|
|
18078
|
-
return real2.startsWith(root2 +
|
|
18706
|
+
const root2 = fs53.realpathSync(dir);
|
|
18707
|
+
const real2 = fs53.realpathSync(path56.join(dir, name));
|
|
18708
|
+
return real2.startsWith(root2 + path56.sep) && fs53.statSync(real2).isFile() ? real2 : null;
|
|
18079
18709
|
} catch {
|
|
18080
18710
|
return null;
|
|
18081
18711
|
}
|
|
@@ -18093,7 +18723,7 @@ function variantsProblem(raw, src, id) {
|
|
|
18093
18723
|
if (files2.length < 2 || !files2.every((f2) => typeof f2 === "string" && f2)) return `variants needs at least two labels, each naming a file. ${shape}`;
|
|
18094
18724
|
if (!files2.includes(src)) return `src="${src}" is not one of the variants. Set src to the version shown first.`;
|
|
18095
18725
|
if (id === void 0) return null;
|
|
18096
|
-
const dir =
|
|
18726
|
+
const dir = path56.join(ASSETS, String(id));
|
|
18097
18727
|
for (const f2 of files2) {
|
|
18098
18728
|
const parts = f2.split("/");
|
|
18099
18729
|
if (parts.length !== 3 || parts[0] !== ".assets" || parts[1] !== String(id) || !inside(dir, parts[2])) {
|
|
@@ -18103,7 +18733,7 @@ function variantsProblem(raw, src, id) {
|
|
|
18103
18733
|
return null;
|
|
18104
18734
|
}
|
|
18105
18735
|
function compareProblem(attrs, id) {
|
|
18106
|
-
const dir =
|
|
18736
|
+
const dir = path56.join(ASSETS, String(id));
|
|
18107
18737
|
const src = (message) => ({ rule: "compare-src", message });
|
|
18108
18738
|
const shots = (message) => ({ rule: "compare-shots", message });
|
|
18109
18739
|
for (const side of ["a", "b"]) {
|
|
@@ -18117,23 +18747,23 @@ function compareProblem(attrs, id) {
|
|
|
18117
18747
|
if (!script && kind !== compareKind(attrs.b)) return src("Compare a and b must both be images or both be videos.");
|
|
18118
18748
|
if (attrs.shots === void 0) return script ? shots('shots is required when b is a storyboard. Add shots="..." naming a storyboard or shots list of video a.') : null;
|
|
18119
18749
|
if (kind !== "video") return shots("shots is for videos only. Remove it from this Compare tag.");
|
|
18120
|
-
const
|
|
18750
|
+
const read5 = (at2) => {
|
|
18121
18751
|
const named2 = assetName(at2, id, ["json"]);
|
|
18122
18752
|
if (!("name" in named2)) return { message: `Compare shots is ${named2.actual}; expected ${named2.expected}.` };
|
|
18123
18753
|
const file = inside(dir, named2.name);
|
|
18124
18754
|
if (!file) return { message: `Compare shots ${at2} names no file in this card's asset folder. Write the JSON there or fix the path.` };
|
|
18125
18755
|
try {
|
|
18126
|
-
return { data: JSON.parse(
|
|
18756
|
+
return { data: JSON.parse(fs53.readFileSync(file, "utf8")) };
|
|
18127
18757
|
} catch {
|
|
18128
18758
|
return { message: `${at2} is not valid JSON.` };
|
|
18129
18759
|
}
|
|
18130
18760
|
};
|
|
18131
|
-
const list =
|
|
18761
|
+
const list = read5(attrs.shots);
|
|
18132
18762
|
if ("message" in list) return shots(list.message);
|
|
18133
|
-
const
|
|
18134
|
-
if (
|
|
18763
|
+
const why2 = Array.isArray(list.data) ? shotsProblem(list.data) : storyboardProblem(list.data);
|
|
18764
|
+
if (why2) return shots(`${attrs.shots}: ${why2}`);
|
|
18135
18765
|
if (!script) return null;
|
|
18136
|
-
const b2 =
|
|
18766
|
+
const b2 = read5(attrs.b);
|
|
18137
18767
|
if ("message" in b2) return src(b2.message);
|
|
18138
18768
|
const bad = storyboardProblem(b2.data);
|
|
18139
18769
|
if (bad) return src(`${attrs.b}: ${bad}`);
|
|
@@ -18143,12 +18773,17 @@ function compareProblem(attrs, id) {
|
|
|
18143
18773
|
}
|
|
18144
18774
|
function validateStoryboards(file, id, text5) {
|
|
18145
18775
|
const errors = [];
|
|
18146
|
-
const dir =
|
|
18147
|
-
for (const
|
|
18148
|
-
|
|
18149
|
-
|
|
18150
|
-
|
|
18151
|
-
|
|
18776
|
+
const dir = path56.join(ASSETS, String(id));
|
|
18777
|
+
for (const [tag, tagOf, rule, fix] of [
|
|
18778
|
+
["Storyboard", storyboardTag, "storyboard-src", "Write the JSON there or fix the path."],
|
|
18779
|
+
["Workflow", workflowTag, "workflow-src", "Write it with `akb workflow diagram <workflow id> <card id>` or fix the path."]
|
|
18780
|
+
]) {
|
|
18781
|
+
for (const marker of storyboardMarkers(text5, tagOf)) {
|
|
18782
|
+
const named2 = assetName(marker.src, id, ["json"]);
|
|
18783
|
+
const add = (message) => errors.push({ file: rel(file), line: marker.line, rule, message });
|
|
18784
|
+
if (!("name" in named2)) add(`${tag} src is ${named2.actual}; expected ${named2.expected}.`);
|
|
18785
|
+
else if (!inside(dir, named2.name)) add(`${tag} src ${marker.src} names no file in this card's asset folder. ${fix}`);
|
|
18786
|
+
}
|
|
18152
18787
|
}
|
|
18153
18788
|
return errors;
|
|
18154
18789
|
}
|
|
@@ -18209,19 +18844,20 @@ var init_spec_contract = __esm({
|
|
|
18209
18844
|
init_paths();
|
|
18210
18845
|
init_compare();
|
|
18211
18846
|
init_storyboard();
|
|
18847
|
+
init_preview_files();
|
|
18212
18848
|
init_validate();
|
|
18213
18849
|
}
|
|
18214
18850
|
});
|
|
18215
18851
|
|
|
18216
18852
|
// src/lib/reconcile.ts
|
|
18217
|
-
import
|
|
18218
|
-
import
|
|
18853
|
+
import fs54 from "node:fs";
|
|
18854
|
+
import path57 from "node:path";
|
|
18219
18855
|
function liveIds() {
|
|
18220
18856
|
const ids = /* @__PURE__ */ new Set();
|
|
18221
18857
|
for (const file of walkMd(TODO)) {
|
|
18222
|
-
const base =
|
|
18858
|
+
const base = path57.basename(file);
|
|
18223
18859
|
if (base === "README.md") continue;
|
|
18224
|
-
const id = base === "root.md" ? idPrefix(
|
|
18860
|
+
const id = base === "root.md" ? idPrefix(path57.basename(path57.dirname(file))) : idPrefix(base);
|
|
18225
18861
|
if (id != null) ids.add(id);
|
|
18226
18862
|
}
|
|
18227
18863
|
return ids;
|
|
@@ -18229,16 +18865,16 @@ function liveIds() {
|
|
|
18229
18865
|
function indexableCards() {
|
|
18230
18866
|
const out = [];
|
|
18231
18867
|
for (const dir of walkDirs(TODO)) {
|
|
18232
|
-
const id = idPrefix(
|
|
18233
|
-
if (id != null &&
|
|
18234
|
-
out.push({ id, rel:
|
|
18868
|
+
const id = idPrefix(path57.basename(dir));
|
|
18869
|
+
if (id != null && fs54.existsSync(path57.join(dir, "root.md"))) {
|
|
18870
|
+
out.push({ id, rel: path57.join(path57.relative(TODO, dir), "root.md").split(path57.sep).join("/") });
|
|
18235
18871
|
}
|
|
18236
18872
|
}
|
|
18237
18873
|
for (const file of walkMd(TODO)) {
|
|
18238
|
-
const base =
|
|
18874
|
+
const base = path57.basename(file);
|
|
18239
18875
|
if (base === "README.md" || base === "root.md") continue;
|
|
18240
|
-
const relTODO =
|
|
18241
|
-
const segs = relTODO.split(
|
|
18876
|
+
const relTODO = path57.relative(TODO, file);
|
|
18877
|
+
const segs = relTODO.split(path57.sep);
|
|
18242
18878
|
if (segs.length !== 1) continue;
|
|
18243
18879
|
const id = idPrefix(base);
|
|
18244
18880
|
if (id != null) out.push({ id, rel: segs.join("/") });
|
|
@@ -18247,7 +18883,7 @@ function indexableCards() {
|
|
|
18247
18883
|
}
|
|
18248
18884
|
function readmeComplaints(fix) {
|
|
18249
18885
|
const said3 = [];
|
|
18250
|
-
const lines =
|
|
18886
|
+
const lines = fs54.readFileSync(README, "utf8").split("\n");
|
|
18251
18887
|
const indexed = /* @__PURE__ */ new Set();
|
|
18252
18888
|
let fixed = 0;
|
|
18253
18889
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -18256,13 +18892,13 @@ function readmeComplaints(fix) {
|
|
|
18256
18892
|
const id = Number(m[1]);
|
|
18257
18893
|
const linkPath = m[2];
|
|
18258
18894
|
indexed.add(id);
|
|
18259
|
-
if (
|
|
18895
|
+
if (fs54.existsSync(path57.join(TODO, linkPath))) continue;
|
|
18260
18896
|
const found2 = locate(id);
|
|
18261
18897
|
if (!found2) {
|
|
18262
18898
|
said3.push(`README links #${id} \u2192 ${linkPath}, but no card with that id exists (removed by hand?). Drop the entry or restore the file.`);
|
|
18263
18899
|
continue;
|
|
18264
18900
|
}
|
|
18265
|
-
const want = (found2.kind === "group" ?
|
|
18901
|
+
const want = (found2.kind === "group" ? path57.join(found2.rel, "root.md") : found2.rel).split(path57.sep).join("/");
|
|
18266
18902
|
if (want === linkPath) continue;
|
|
18267
18903
|
if (!fix) {
|
|
18268
18904
|
said3.push(`README links #${id} \u2192 ${linkPath}, which isn't there any more; the card is at ${want}.`);
|
|
@@ -18272,7 +18908,7 @@ function readmeComplaints(fix) {
|
|
|
18272
18908
|
said3.push(`README link #${id} pointed at missing ${linkPath} \u2192 repointed to ${want}.`);
|
|
18273
18909
|
fixed++;
|
|
18274
18910
|
}
|
|
18275
|
-
if (fixed)
|
|
18911
|
+
if (fixed) fs54.writeFileSync(README, lines.join("\n"));
|
|
18276
18912
|
for (const c2 of indexableCards()) {
|
|
18277
18913
|
if (!indexed.has(c2.id)) {
|
|
18278
18914
|
said3.push(`card ${c2.rel} (#${c2.id}) is not in the README index. Add it under "## ${TASKS_HEADING}".`);
|
|
@@ -18284,11 +18920,11 @@ function crossRefComplaints() {
|
|
|
18284
18920
|
const said3 = [];
|
|
18285
18921
|
const live = liveIds();
|
|
18286
18922
|
for (const file of walkMd(TODO)) {
|
|
18287
|
-
const base =
|
|
18923
|
+
const base = path57.basename(file);
|
|
18288
18924
|
if (base === "README.md") continue;
|
|
18289
|
-
const ownerId = base === "root.md" ? idPrefix(
|
|
18925
|
+
const ownerId = base === "root.md" ? idPrefix(path57.basename(path57.dirname(file))) : idPrefix(base);
|
|
18290
18926
|
if (ownerId == null) continue;
|
|
18291
|
-
const { meta } = parseFrontmatter(
|
|
18927
|
+
const { meta } = parseFrontmatter(fs54.readFileSync(file, "utf8"));
|
|
18292
18928
|
if (!meta) continue;
|
|
18293
18929
|
for (const field2 of ["blocked_by", "related"]) {
|
|
18294
18930
|
for (const ref of meta[field2] || []) {
|
|
@@ -18301,11 +18937,11 @@ function crossRefComplaints() {
|
|
|
18301
18937
|
return said3;
|
|
18302
18938
|
}
|
|
18303
18939
|
function reconcileBoard() {
|
|
18304
|
-
if (!
|
|
18940
|
+
if (!fs54.existsSync(README)) return;
|
|
18305
18941
|
for (const line of [...readmeComplaints(true), ...crossRefComplaints()]) warn2(line);
|
|
18306
18942
|
}
|
|
18307
18943
|
function boardComplaints() {
|
|
18308
|
-
if (!
|
|
18944
|
+
if (!fs54.existsSync(README)) return [];
|
|
18309
18945
|
try {
|
|
18310
18946
|
return [...readmeComplaints(false), ...crossRefComplaints()];
|
|
18311
18947
|
} catch {
|
|
@@ -18325,8 +18961,8 @@ var init_reconcile = __esm({
|
|
|
18325
18961
|
});
|
|
18326
18962
|
|
|
18327
18963
|
// src/commands/card.ts
|
|
18328
|
-
import
|
|
18329
|
-
import
|
|
18964
|
+
import fs55 from "node:fs";
|
|
18965
|
+
import path58 from "node:path";
|
|
18330
18966
|
function defaultBody(summary = "<\u7528\u4E00\u5C0F\u6BB5\u8BDD\u5148\u8BB2\u53D1\u751F\u4E86\u4EC0\u4E48\u3001\u7528\u6237\u9047\u5230\u4EC0\u4E48\uFF0C\u518D\u8BB2\u8FD9\u5F20\u5361\u8981\u8FBE\u5230\u7684\u7ED3\u679C\u3002>") {
|
|
18331
18967
|
return [
|
|
18332
18968
|
summary,
|
|
@@ -18352,7 +18988,7 @@ function bodyFromFile(opts) {
|
|
|
18352
18988
|
if (opts.body === false) die("pass --body-file or --no-body, not both");
|
|
18353
18989
|
let text5;
|
|
18354
18990
|
try {
|
|
18355
|
-
text5 =
|
|
18991
|
+
text5 = fs55.readFileSync(opts.bodyFile, "utf8");
|
|
18356
18992
|
} catch {
|
|
18357
18993
|
die(`can't read ${opts.bodyFile} \u2014 write the body to a file, then pass its path`, { kind: "needs-input" });
|
|
18358
18994
|
}
|
|
@@ -18432,20 +19068,20 @@ function cmdCreate(opts) {
|
|
|
18432
19068
|
const start = opts.id;
|
|
18433
19069
|
const slug2 = slugify(opts.slug !== void 0 ? opts.slug : title);
|
|
18434
19070
|
const fileRel = `${start}-${slug2}.md`;
|
|
18435
|
-
const file =
|
|
19071
|
+
const file = path58.join(TODO, fileRel);
|
|
18436
19072
|
const held4 = locate(start) ?? locateArchived(start);
|
|
18437
|
-
if (held4 &&
|
|
19073
|
+
if (held4 && path58.basename(held4.target) === `${start}-${slug2}.md`) {
|
|
18438
19074
|
say(start);
|
|
18439
19075
|
say(` ${rel(held4.target)} was already written`);
|
|
18440
19076
|
return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
|
|
18441
19077
|
}
|
|
18442
19078
|
if (held4) die(`#${start} is already a card here (${rel(held4.target)})`, { kind: "id-taken", id: start });
|
|
18443
|
-
if (
|
|
19079
|
+
if (fs55.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
|
|
18444
19080
|
countBoardEvent(triage ? "cards_created_proposed" : "cards_created_asked");
|
|
18445
19081
|
const meta = { title, priority, status: "todo", blocked_by, related, modules, workflow, previews, stages, triage, source, questions };
|
|
18446
19082
|
const scaffolded = !written && opts.body !== false;
|
|
18447
19083
|
const body = written ?? (scaffolded ? defaultBody() : "");
|
|
18448
|
-
|
|
19084
|
+
fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
|
|
18449
19085
|
const indexed = addReadmeRef(start, title, fileRel);
|
|
18450
19086
|
say(start);
|
|
18451
19087
|
say(
|
|
@@ -18492,8 +19128,8 @@ function cmdUpdate(id, flags) {
|
|
|
18492
19128
|
if (creating) die(creating, { kind: "card-being-created", id });
|
|
18493
19129
|
const found2 = locate(id);
|
|
18494
19130
|
if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
|
|
18495
|
-
const file = found2.kind === "group" ?
|
|
18496
|
-
const { meta, body } = parseFrontmatter(
|
|
19131
|
+
const file = found2.kind === "group" ? path58.join(found2.target, "root.md") : found2.target;
|
|
19132
|
+
const { meta, body } = parseFrontmatter(fs55.readFileSync(file, "utf8"));
|
|
18497
19133
|
if (!meta) die(`${rel(file)} has no frontmatter \u2014 run \`migrate\` first`);
|
|
18498
19134
|
if (flags.blockedBy !== void 0 && flags.addBlockedBy !== void 0) die("--blocked-by replaces the list and --add-blocked-by appends to it \u2014 pass one");
|
|
18499
19135
|
if (flags.related !== void 0 && flags.addRelated !== void 0) die("--related replaces the list and --add-related appends to it \u2014 pass one");
|
|
@@ -18567,26 +19203,26 @@ function cmdUpdate(id, flags) {
|
|
|
18567
19203
|
meta.status = "todo";
|
|
18568
19204
|
changes.push("status\u2192todo (open questions)");
|
|
18569
19205
|
}
|
|
18570
|
-
const curRel =
|
|
19206
|
+
const curRel = path58.relative(TODO, file);
|
|
18571
19207
|
const isSubtask = found2.kind === "file" && enclosingGroupRoot(file) !== null;
|
|
18572
|
-
let base =
|
|
19208
|
+
let base = path58.basename(file);
|
|
18573
19209
|
if (flags.slug !== void 0) {
|
|
18574
19210
|
if (found2.kind === "group") die("renaming a group root by script is not supported");
|
|
18575
19211
|
base = `${id}-${slugify(flags.slug)}.md`;
|
|
18576
19212
|
}
|
|
18577
|
-
const destRel =
|
|
18578
|
-
const dest =
|
|
19213
|
+
const destRel = path58.join(path58.dirname(curRel), base);
|
|
19214
|
+
const dest = path58.join(TODO, destRel);
|
|
18579
19215
|
const moving = dest !== file;
|
|
18580
|
-
if (moving &&
|
|
18581
|
-
|
|
18582
|
-
if (moving)
|
|
19216
|
+
if (moving && fs55.existsSync(dest)) die(`${rel(dest)} already exists`);
|
|
19217
|
+
fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
|
|
19218
|
+
if (moving) fs55.renameSync(file, dest);
|
|
18583
19219
|
if (isSubtask) {
|
|
18584
19220
|
if (moving || changes.includes("title")) repointReadmeLink(id, curRel, destRel, meta.title);
|
|
18585
|
-
if (moving) changes.push(`renamed \u2192 ${destRel.split(
|
|
19221
|
+
if (moving) changes.push(`renamed \u2192 ${destRel.split(path58.sep).join("/")}`);
|
|
18586
19222
|
} else if (moving) {
|
|
18587
19223
|
stripReadmeRefs({ kind: "file", rel: curRel });
|
|
18588
19224
|
addReadmeRef(id, meta.title, destRel);
|
|
18589
|
-
changes.push(`renamed \u2192 ${destRel.split(
|
|
19225
|
+
changes.push(`renamed \u2192 ${destRel.split(path58.sep).join("/")}`);
|
|
18590
19226
|
} else if (changes.includes("title")) {
|
|
18591
19227
|
stripReadmeRefs({ kind: "file", rel: curRel });
|
|
18592
19228
|
addReadmeRef(id, meta.title, curRel);
|
|
@@ -18598,8 +19234,8 @@ function cmdUpdateQuestions(id, input) {
|
|
|
18598
19234
|
const ops = readQuestionOps(input.ops ?? []);
|
|
18599
19235
|
const found2 = locate(id);
|
|
18600
19236
|
if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
|
|
18601
|
-
const file = found2.kind === "group" ?
|
|
18602
|
-
const { meta, body } = parseFrontmatter(
|
|
19237
|
+
const file = found2.kind === "group" ? path58.join(found2.target, "root.md") : found2.target;
|
|
19238
|
+
const { meta, body } = parseFrontmatter(fs55.readFileSync(file, "utf8"));
|
|
18603
19239
|
if (!meta) die(`${rel(file)} has no frontmatter \u2014 run \`migrate\` first`);
|
|
18604
19240
|
if (insideRun() && ops.some((op) => op.kind === "skip" || op.kind === "unskip")) {
|
|
18605
19241
|
die("only the user skips or reopens a question \u2014 a run leaves questions for them to answer");
|
|
@@ -18672,7 +19308,7 @@ function cmdUpdateQuestions(id, input) {
|
|
|
18672
19308
|
meta.status = "todo";
|
|
18673
19309
|
changes.push("status\u2192todo (open questions)");
|
|
18674
19310
|
}
|
|
18675
|
-
|
|
19311
|
+
fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
|
|
18676
19312
|
for (const kind of closed2) countBoardEvent(kind);
|
|
18677
19313
|
settleDelivery2(id, skipped, unskipped);
|
|
18678
19314
|
say(
|
|
@@ -18747,13 +19383,13 @@ var init_config_template = __esm({
|
|
|
18747
19383
|
});
|
|
18748
19384
|
|
|
18749
19385
|
// src/lib/agent/local.ts
|
|
18750
|
-
import
|
|
18751
|
-
import
|
|
19386
|
+
import fs56 from "node:fs";
|
|
19387
|
+
import path59 from "node:path";
|
|
18752
19388
|
function takeLocalModels(board2) {
|
|
18753
|
-
const file =
|
|
19389
|
+
const file = path59.join(board2, ".local.json");
|
|
18754
19390
|
let held4;
|
|
18755
19391
|
try {
|
|
18756
|
-
held4 = configBlock(JSON.parse(
|
|
19392
|
+
held4 = configBlock(JSON.parse(fs56.readFileSync(file, "utf8")));
|
|
18757
19393
|
} catch {
|
|
18758
19394
|
return {};
|
|
18759
19395
|
}
|
|
@@ -18771,7 +19407,7 @@ function takeLocalModels(board2) {
|
|
|
18771
19407
|
}
|
|
18772
19408
|
if (!Object.keys(agents).length) return out;
|
|
18773
19409
|
delete held4.agents;
|
|
18774
|
-
|
|
19410
|
+
fs56.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
|
|
18775
19411
|
return out;
|
|
18776
19412
|
}
|
|
18777
19413
|
var LOCAL_IGNORE_LINE;
|
|
@@ -18832,12 +19468,12 @@ var init_identity2 = __esm({
|
|
|
18832
19468
|
});
|
|
18833
19469
|
|
|
18834
19470
|
// src/lib/signals/migrate.ts
|
|
18835
|
-
import
|
|
18836
|
-
import
|
|
19471
|
+
import fs57 from "node:fs";
|
|
19472
|
+
import path60 from "node:path";
|
|
18837
19473
|
function readHandled() {
|
|
18838
19474
|
let text5;
|
|
18839
19475
|
try {
|
|
18840
|
-
text5 =
|
|
19476
|
+
text5 = fs57.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
|
|
18841
19477
|
} catch {
|
|
18842
19478
|
return [];
|
|
18843
19479
|
}
|
|
@@ -18854,57 +19490,57 @@ function readHandled() {
|
|
|
18854
19490
|
return held4;
|
|
18855
19491
|
}
|
|
18856
19492
|
function lift(from, into) {
|
|
18857
|
-
|
|
18858
|
-
|
|
19493
|
+
fs57.mkdirSync(into, { recursive: true });
|
|
19494
|
+
fs57.renameSync(from, path60.join(into, freeName(into, path60.basename(from))));
|
|
18859
19495
|
}
|
|
18860
19496
|
function repoint(dir, from, into) {
|
|
18861
19497
|
let entries;
|
|
18862
19498
|
try {
|
|
18863
|
-
entries =
|
|
19499
|
+
entries = fs57.readdirSync(dir, { withFileTypes: true });
|
|
18864
19500
|
} catch {
|
|
18865
19501
|
return;
|
|
18866
19502
|
}
|
|
18867
19503
|
for (const entry of entries) {
|
|
18868
19504
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
18869
|
-
const file =
|
|
18870
|
-
const text5 =
|
|
18871
|
-
if (text5.includes(from))
|
|
19505
|
+
const file = path60.join(dir, entry.name);
|
|
19506
|
+
const text5 = fs57.readFileSync(file, "utf8");
|
|
19507
|
+
if (text5.includes(from)) fs57.writeFileSync(file, text5.split(from).join(into));
|
|
18872
19508
|
}
|
|
18873
19509
|
}
|
|
18874
19510
|
function dropIfEmpty2(dir) {
|
|
18875
19511
|
try {
|
|
18876
|
-
|
|
19512
|
+
fs57.rmdirSync(dir);
|
|
18877
19513
|
} catch {
|
|
18878
19514
|
}
|
|
18879
19515
|
}
|
|
18880
19516
|
function liftInbox() {
|
|
18881
|
-
if (!
|
|
18882
|
-
const oldFiles =
|
|
18883
|
-
if (
|
|
18884
|
-
for (const entry of
|
|
18885
|
-
if (entry.isFile()) lift(
|
|
19517
|
+
if (!fs57.existsSync(SIGNALS_OLD_INBOX)) return;
|
|
19518
|
+
const oldFiles = path60.join(SIGNALS_OLD_INBOX, "files");
|
|
19519
|
+
if (fs57.existsSync(oldFiles)) {
|
|
19520
|
+
for (const entry of fs57.readdirSync(oldFiles, { withFileTypes: true })) {
|
|
19521
|
+
if (entry.isFile()) lift(path60.join(oldFiles, entry.name), SIGNALS_FILES);
|
|
18886
19522
|
}
|
|
18887
19523
|
dropIfEmpty2(oldFiles);
|
|
18888
19524
|
}
|
|
18889
19525
|
const held4 = new Set(readFolder(TRIAGE).map((signal2) => signal2.sourceId));
|
|
18890
|
-
for (const entry of
|
|
19526
|
+
for (const entry of fs57.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
|
|
18891
19527
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
18892
|
-
const from =
|
|
19528
|
+
const from = path60.join(SIGNALS_OLD_INBOX, entry.name);
|
|
18893
19529
|
const item = parse(from);
|
|
18894
19530
|
if (item && held4.has(item.sourceId)) {
|
|
18895
|
-
|
|
19531
|
+
fs57.rmSync(from, { force: true });
|
|
18896
19532
|
continue;
|
|
18897
19533
|
}
|
|
18898
19534
|
if (item) held4.add(item.sourceId);
|
|
18899
19535
|
lift(from, TRIAGE);
|
|
18900
19536
|
}
|
|
18901
|
-
const wasAt = asWritten(
|
|
19537
|
+
const wasAt = asWritten(path60.join(SIGNALS_OLD_INBOX, "files"));
|
|
18902
19538
|
const nowAt = asWritten(SIGNALS_FILES);
|
|
18903
19539
|
for (const dir of [TRIAGE, SIGNALS_ARCHIVED, SIGNALS_DISMISSED]) repoint(dir, wasAt, nowAt);
|
|
18904
19540
|
dropIfEmpty2(SIGNALS_OLD_INBOX);
|
|
18905
19541
|
}
|
|
18906
19542
|
function liftHandled() {
|
|
18907
|
-
if (!
|
|
19543
|
+
if (!fs57.existsSync(SIGNALS_OLD_HANDLED)) return;
|
|
18908
19544
|
const lines = readHandled();
|
|
18909
19545
|
const held4 = /* @__PURE__ */ new Set([
|
|
18910
19546
|
...readFolder(TRIAGE).map((signal2) => signal2.sourceId),
|
|
@@ -18914,7 +19550,7 @@ function liftHandled() {
|
|
|
18914
19550
|
for (const { sourceId, when } of lines) {
|
|
18915
19551
|
if (held4.has(sourceId)) continue;
|
|
18916
19552
|
held4.add(sourceId);
|
|
18917
|
-
|
|
19553
|
+
fs57.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
|
|
18918
19554
|
const name = freeName(SIGNALS_DISMISSED, fileName("", sourceId));
|
|
18919
19555
|
const front = [
|
|
18920
19556
|
"---",
|
|
@@ -18924,13 +19560,13 @@ function liftHandled() {
|
|
|
18924
19560
|
"---",
|
|
18925
19561
|
""
|
|
18926
19562
|
];
|
|
18927
|
-
|
|
19563
|
+
fs57.writeFileSync(path60.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
|
|
18928
19564
|
`);
|
|
18929
19565
|
}
|
|
18930
|
-
|
|
19566
|
+
fs57.rmSync(SIGNALS_OLD_HANDLED, { force: true });
|
|
18931
19567
|
}
|
|
18932
19568
|
function migrateTriage() {
|
|
18933
|
-
if (!
|
|
19569
|
+
if (!fs57.existsSync(SIGNALS_OLD_INBOX) && !fs57.existsSync(SIGNALS_OLD_HANDLED)) return;
|
|
18934
19570
|
try {
|
|
18935
19571
|
liftInbox();
|
|
18936
19572
|
liftHandled();
|
|
@@ -18945,13 +19581,13 @@ var init_migrate = __esm({
|
|
|
18945
19581
|
init_yaml();
|
|
18946
19582
|
init_inbox();
|
|
18947
19583
|
HANDLED_LINE = /^-\s+(.+?)\s+—\s+(.+)$/;
|
|
18948
|
-
asWritten = (dir) => `${rel(dir).split(
|
|
19584
|
+
asWritten = (dir) => `${rel(dir).split(path60.sep).join("/")}/`;
|
|
18949
19585
|
}
|
|
18950
19586
|
});
|
|
18951
19587
|
|
|
18952
19588
|
// src/lib/signals/add.ts
|
|
18953
|
-
import
|
|
18954
|
-
import
|
|
19589
|
+
import fs58 from "node:fs";
|
|
19590
|
+
import path61 from "node:path";
|
|
18955
19591
|
import { createHash as createHash4 } from "node:crypto";
|
|
18956
19592
|
function linkTitle(url) {
|
|
18957
19593
|
let at2;
|
|
@@ -18964,7 +19600,7 @@ function linkTitle(url) {
|
|
|
18964
19600
|
return oneLine(where) || url.slice(0, TITLE_MAX);
|
|
18965
19601
|
}
|
|
18966
19602
|
function asText(file) {
|
|
18967
|
-
const ext =
|
|
19603
|
+
const ext = path61.extname(file.name).toLowerCase();
|
|
18968
19604
|
if (!file.type.startsWith("text/") && file.type !== "application/json" && !TEXT_EXTENSIONS.has(ext)) return null;
|
|
18969
19605
|
try {
|
|
18970
19606
|
const text5 = new TextDecoder("utf-8", { fatal: true }).decode(file.data);
|
|
@@ -18974,9 +19610,9 @@ function asText(file) {
|
|
|
18974
19610
|
}
|
|
18975
19611
|
}
|
|
18976
19612
|
function fileName2(name, data) {
|
|
18977
|
-
const base =
|
|
18978
|
-
const ext =
|
|
18979
|
-
const word =
|
|
19613
|
+
const base = path61.basename(name);
|
|
19614
|
+
const ext = path61.extname(base).toLowerCase().slice(0, 12);
|
|
19615
|
+
const word = path61.basename(base, path61.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
|
|
18980
19616
|
const hash2 = createHash4("sha256").update(data).digest("hex").slice(0, 8);
|
|
18981
19617
|
return `${word}-${hash2}${ext}`;
|
|
18982
19618
|
}
|
|
@@ -18985,20 +19621,20 @@ function addToInbox(drop) {
|
|
|
18985
19621
|
const typed = (drop.text ?? "").trim();
|
|
18986
19622
|
const file = drop.file;
|
|
18987
19623
|
if (!typed && !file) return { ok: false, error: "nothing to add \u2014 paste a link or some text, or drop a file." };
|
|
18988
|
-
if (file && file.data.length === 0) return { ok: false, error: `${
|
|
19624
|
+
if (file && file.data.length === 0) return { ok: false, error: `${path61.basename(file.name)} is empty.` };
|
|
18989
19625
|
if (file && file.data.length > MAX_BYTES) {
|
|
18990
|
-
return { ok: false, error: `${
|
|
19626
|
+
return { ok: false, error: `${path61.basename(file.name)} is over ${MAX_BYTES / 1024 / 1024} MB \u2014 too big for the board.` };
|
|
18991
19627
|
}
|
|
18992
|
-
const
|
|
18993
|
-
const keep2 =
|
|
19628
|
+
const read5 = describe(typed, file);
|
|
19629
|
+
const keep2 = read5.keep;
|
|
18994
19630
|
const said3 = drop.source?.trim() ?? "";
|
|
18995
19631
|
const hit = said3 ? matchSourceType(said3) : "";
|
|
18996
19632
|
const kept2 = said3 && !hit ? metaPair("source", said3) : null;
|
|
18997
19633
|
const incoming = {
|
|
18998
|
-
...
|
|
19634
|
+
...read5.incoming,
|
|
18999
19635
|
...drop.title?.trim() ? { title: oneLine(drop.title) } : {},
|
|
19000
19636
|
...hit ? { sourceType: hit } : {},
|
|
19001
|
-
...kept2 ? { meta: [kept2, ...
|
|
19637
|
+
...kept2 ? { meta: [kept2, ...read5.incoming.meta] } : {},
|
|
19002
19638
|
...drop.agent ? { agent: drop.agent } : {},
|
|
19003
19639
|
...drop.workflow ? { workflow: drop.workflow } : {}
|
|
19004
19640
|
};
|
|
@@ -19009,8 +19645,8 @@ ${incoming.summary}`);
|
|
|
19009
19645
|
if (seen.status === "pending" || seen.status === "archived") return { ok: false, error: `${sayHit(seen)}.` };
|
|
19010
19646
|
try {
|
|
19011
19647
|
if (keep2) {
|
|
19012
|
-
|
|
19013
|
-
|
|
19648
|
+
fs58.mkdirSync(SIGNALS_FILES, { recursive: true });
|
|
19649
|
+
fs58.writeFileSync(keep2.at, keep2.data);
|
|
19014
19650
|
}
|
|
19015
19651
|
return { ok: true, signal: writeSignal({ ...incoming, sourceId }, formatStamp(/* @__PURE__ */ new Date()), drop.slug) };
|
|
19016
19652
|
} catch (e2) {
|
|
@@ -19024,7 +19660,7 @@ function describe(typed, file) {
|
|
|
19024
19660
|
return only ? [only] : [];
|
|
19025
19661
|
};
|
|
19026
19662
|
if (file) {
|
|
19027
|
-
const name =
|
|
19663
|
+
const name = path61.basename(file.name);
|
|
19028
19664
|
const text5 = asText(file);
|
|
19029
19665
|
const note = typed ? `
|
|
19030
19666
|
|
|
@@ -19036,7 +19672,7 @@ ${typed}` : "";
|
|
|
19036
19672
|
const at2 = keepAt(file);
|
|
19037
19673
|
return {
|
|
19038
19674
|
incoming: {
|
|
19039
|
-
title:
|
|
19675
|
+
title: path61.basename(name, path61.extname(name)) || name,
|
|
19040
19676
|
summary: `${name} \u2014 ${boardRel2(at2)}${note}`,
|
|
19041
19677
|
...named2
|
|
19042
19678
|
},
|
|
@@ -19074,73 +19710,73 @@ var init_add = __esm({
|
|
|
19074
19710
|
MAX_BYTES = 25 * 1024 * 1024;
|
|
19075
19711
|
TITLE_MAX = 120;
|
|
19076
19712
|
TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".text", ".csv", ".json", ".yml", ".yaml", ".log"]);
|
|
19077
|
-
boardRel2 = (file) => rel(file).split(
|
|
19713
|
+
boardRel2 = (file) => rel(file).split(path61.sep).join("/");
|
|
19078
19714
|
oneLine = (text5) => {
|
|
19079
19715
|
const first = text5.split("\n").find((line) => line.trim()) ?? "";
|
|
19080
19716
|
const clean = first.replace(/^#+\s*/, "").trim();
|
|
19081
19717
|
return clean.length > TITLE_MAX ? `${clean.slice(0, TITLE_MAX - 1).trimEnd()}\u2026` : clean;
|
|
19082
19718
|
};
|
|
19083
|
-
keepAt = (file) =>
|
|
19719
|
+
keepAt = (file) => path61.join(SIGNALS_FILES, fileName2(file.name, file.data));
|
|
19084
19720
|
}
|
|
19085
19721
|
});
|
|
19086
19722
|
|
|
19087
19723
|
// src/lib/recurring.ts
|
|
19088
|
-
import
|
|
19089
|
-
import
|
|
19724
|
+
import fs59 from "node:fs";
|
|
19725
|
+
import path62 from "node:path";
|
|
19090
19726
|
function migratePruneMemoryCard() {
|
|
19091
19727
|
const dir = recurringDir();
|
|
19092
19728
|
let names3;
|
|
19093
19729
|
try {
|
|
19094
|
-
names3 =
|
|
19730
|
+
names3 = fs59.readdirSync(dir);
|
|
19095
19731
|
} catch {
|
|
19096
19732
|
return null;
|
|
19097
19733
|
}
|
|
19098
19734
|
const name = names3.find((entry) => entry.endsWith(`-${PRUNE_SLUG}.md`));
|
|
19099
19735
|
if (!name) return null;
|
|
19100
|
-
const file =
|
|
19736
|
+
const file = path62.join(dir, name);
|
|
19101
19737
|
try {
|
|
19102
|
-
const { meta } = parseFrontmatter(
|
|
19738
|
+
const { meta } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
|
|
19103
19739
|
const cadence = meta?.cadence;
|
|
19104
19740
|
if (typeof cadence === "string") adoptMemoryPruneCadence(cadence);
|
|
19105
19741
|
} catch {
|
|
19106
19742
|
}
|
|
19107
|
-
|
|
19743
|
+
fs59.rmSync(file, { force: true });
|
|
19108
19744
|
return rel(file);
|
|
19109
19745
|
}
|
|
19110
19746
|
function legacyCards() {
|
|
19111
19747
|
const dir = recurringDir();
|
|
19112
|
-
if (!
|
|
19748
|
+
if (!fs59.existsSync(dir)) return [];
|
|
19113
19749
|
const cards = [];
|
|
19114
|
-
for (const entry of
|
|
19750
|
+
for (const entry of fs59.readdirSync(dir, { withFileTypes: true })) {
|
|
19115
19751
|
const id = idPrefix(entry.name);
|
|
19116
19752
|
if (id === null) continue;
|
|
19117
|
-
const full =
|
|
19753
|
+
const full = path62.join(dir, entry.name);
|
|
19118
19754
|
const slug2 = entry.name.replace(/\.md$/, "").replace(/^\d+-?/, "");
|
|
19119
19755
|
if (entry.isFile() && entry.name.endsWith(".md")) cards.push({ id, slug: slug2, file: full });
|
|
19120
|
-
else if (entry.isDirectory() &&
|
|
19121
|
-
cards.push({ id, slug: slug2, file:
|
|
19756
|
+
else if (entry.isDirectory() && fs59.existsSync(path62.join(full, "root.md"))) {
|
|
19757
|
+
cards.push({ id, slug: slug2, file: path62.join(full, "root.md"), folder: full });
|
|
19122
19758
|
}
|
|
19123
19759
|
}
|
|
19124
19760
|
return cards.sort((a2, b2) => a2.id - b2.id);
|
|
19125
19761
|
}
|
|
19126
19762
|
function mergeInto2(from, to, skip = []) {
|
|
19127
|
-
|
|
19128
|
-
for (const entry of
|
|
19763
|
+
fs59.mkdirSync(to, { recursive: true });
|
|
19764
|
+
for (const entry of fs59.readdirSync(from, { withFileTypes: true })) {
|
|
19129
19765
|
if (skip.includes(entry.name)) continue;
|
|
19130
|
-
const source =
|
|
19131
|
-
const target =
|
|
19132
|
-
if (!
|
|
19133
|
-
else if (entry.isDirectory() &&
|
|
19766
|
+
const source = path62.join(from, entry.name);
|
|
19767
|
+
const target = path62.join(to, entry.name);
|
|
19768
|
+
if (!fs59.existsSync(target)) fs59.renameSync(source, target);
|
|
19769
|
+
else if (entry.isDirectory() && fs59.statSync(target).isDirectory()) mergeInto2(source, target);
|
|
19134
19770
|
}
|
|
19135
|
-
if (isEmpty(from))
|
|
19771
|
+
if (isEmpty(from)) fs59.rmSync(from, { recursive: true, force: true });
|
|
19136
19772
|
}
|
|
19137
19773
|
function moveSideFolders() {
|
|
19138
19774
|
const dir = recurringDir();
|
|
19139
|
-
for (const entry of
|
|
19775
|
+
for (const entry of fs59.readdirSync(dir, { withFileTypes: true })) {
|
|
19140
19776
|
if (!entry.isDirectory() || idPrefix(entry.name) !== null) continue;
|
|
19141
|
-
const from =
|
|
19142
|
-
if (isEmpty(from))
|
|
19143
|
-
else mergeInto2(from,
|
|
19777
|
+
const from = path62.join(dir, entry.name);
|
|
19778
|
+
if (isEmpty(from)) fs59.rmSync(from, { recursive: true, force: true });
|
|
19779
|
+
else mergeInto2(from, path62.join(AGENTS, entry.name));
|
|
19144
19780
|
}
|
|
19145
19781
|
}
|
|
19146
19782
|
function sections(body) {
|
|
@@ -19190,8 +19826,8 @@ function agentName(card, text5) {
|
|
|
19190
19826
|
const known2 = /* @__PURE__ */ new Set([...specAgentCatalog().agents.map((a2) => a2.name), ...ROLE_NAMES]);
|
|
19191
19827
|
for (const name of [slug2, `${slug2}-${card.id}`]) {
|
|
19192
19828
|
if (!AGENT_NAME.test(name)) continue;
|
|
19193
|
-
const file =
|
|
19194
|
-
const written =
|
|
19829
|
+
const file = path62.join(AGENTS, name, AGENT_FILE3);
|
|
19830
|
+
const written = fs59.existsSync(file) ? fs59.readFileSync(file, "utf8") : null;
|
|
19195
19831
|
if (written === text5(name)) return name;
|
|
19196
19832
|
if (written === null && !known2.has(name)) return name;
|
|
19197
19833
|
}
|
|
@@ -19208,11 +19844,11 @@ ${q3.options.map((o3) => `- ${o3}`).join("\n")}` : "";
|
|
|
19208
19844
|
function removeCard(card) {
|
|
19209
19845
|
dropCrossRefs(card.id);
|
|
19210
19846
|
const target = card.folder ?? card.file;
|
|
19211
|
-
stripReadmeRefs({ kind: card.folder ? "group" : "file", rel:
|
|
19212
|
-
|
|
19847
|
+
stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path62.relative(TODO, target).split(path62.sep).join("/") });
|
|
19848
|
+
fs59.rmSync(target, { recursive: true, force: true });
|
|
19213
19849
|
}
|
|
19214
19850
|
function migrateCard(card) {
|
|
19215
|
-
const { meta, body } = parseFrontmatter(
|
|
19851
|
+
const { meta, body } = parseFrontmatter(fs59.readFileSync(card.file, "utf8"));
|
|
19216
19852
|
if (!meta) throw new Error("its frontmatter cannot be read");
|
|
19217
19853
|
const raw = meta;
|
|
19218
19854
|
const said3 = (key) => typeof raw[key] === "string" ? raw[key].trim() : "";
|
|
@@ -19222,19 +19858,19 @@ function migrateCard(card) {
|
|
|
19222
19858
|
if (!flow) throw new Error("this board has no workflow to put it in");
|
|
19223
19859
|
const text5 = (name2) => agentText(name2, meta.title || card.slug, body);
|
|
19224
19860
|
const name = agentName(card, text5);
|
|
19225
|
-
const dir =
|
|
19226
|
-
const file =
|
|
19227
|
-
const madeDir = !
|
|
19228
|
-
const wrote = !
|
|
19861
|
+
const dir = path62.join(AGENTS, name);
|
|
19862
|
+
const file = path62.join(dir, AGENT_FILE3);
|
|
19863
|
+
const madeDir = !fs59.existsSync(dir);
|
|
19864
|
+
const wrote = !fs59.existsSync(file);
|
|
19229
19865
|
try {
|
|
19230
|
-
|
|
19231
|
-
if (wrote)
|
|
19866
|
+
fs59.mkdirSync(dir, { recursive: true });
|
|
19867
|
+
if (wrote) fs59.writeFileSync(file, text5(name));
|
|
19232
19868
|
const adopted = adoptWorkflowScheduled(flow.id, name, { cadence, lastRun });
|
|
19233
19869
|
if (!adopted.ok) throw new Error(adopted.error);
|
|
19234
19870
|
questionsToTriage(meta, name);
|
|
19235
19871
|
} catch (e2) {
|
|
19236
|
-
if (madeDir)
|
|
19237
|
-
else if (wrote)
|
|
19872
|
+
if (madeDir) fs59.rmSync(dir, { recursive: true, force: true });
|
|
19873
|
+
else if (wrote) fs59.rmSync(file, { force: true });
|
|
19238
19874
|
throw e2;
|
|
19239
19875
|
}
|
|
19240
19876
|
if (card.folder) mergeInto2(card.folder, dir, ["root.md"]);
|
|
@@ -19244,7 +19880,7 @@ function migrateCard(card) {
|
|
|
19244
19880
|
function migrateRecurringCards() {
|
|
19245
19881
|
const done2 = { agents: [], removed: [], failed: [] };
|
|
19246
19882
|
const dir = recurringDir();
|
|
19247
|
-
if (!
|
|
19883
|
+
if (!fs59.existsSync(dir)) return done2;
|
|
19248
19884
|
migratePruneMemoryCard();
|
|
19249
19885
|
moveSideFolders();
|
|
19250
19886
|
for (const card of legacyCards()) {
|
|
@@ -19257,7 +19893,7 @@ function migrateRecurringCards() {
|
|
|
19257
19893
|
done2.failed.push({ card: rel(card.file), why: e2 instanceof Error ? e2.message : String(e2) });
|
|
19258
19894
|
}
|
|
19259
19895
|
}
|
|
19260
|
-
if (isEmpty(dir))
|
|
19896
|
+
if (isEmpty(dir)) fs59.rmSync(dir, { recursive: true, force: true });
|
|
19261
19897
|
return done2;
|
|
19262
19898
|
}
|
|
19263
19899
|
function recurringMigrationLines(done2) {
|
|
@@ -19290,14 +19926,14 @@ var init_recurring = __esm({
|
|
|
19290
19926
|
PRUNE_SLUG = "prune-the-memory";
|
|
19291
19927
|
FETCH_SLUG = "fetch-triage-items";
|
|
19292
19928
|
AGENT_FILE3 = "AGENT.md";
|
|
19293
|
-
recurringDir = () =>
|
|
19294
|
-
isEmpty = (dir) =>
|
|
19929
|
+
recurringDir = () => path62.join(TODO, LEGACY_RECURRING);
|
|
19930
|
+
isEmpty = (dir) => fs59.readdirSync(dir).every((name) => name === ".DS_Store");
|
|
19295
19931
|
SECTION = /^##\s+(.+?)\s*$/;
|
|
19296
19932
|
}
|
|
19297
19933
|
});
|
|
19298
19934
|
|
|
19299
19935
|
// src/commands/init.ts
|
|
19300
|
-
import
|
|
19936
|
+
import fs60 from "node:fs";
|
|
19301
19937
|
function boardReadme() {
|
|
19302
19938
|
return `# Board
|
|
19303
19939
|
|
|
@@ -19310,20 +19946,20 @@ _(none)_
|
|
|
19310
19946
|
`;
|
|
19311
19947
|
}
|
|
19312
19948
|
function writeConfigIfMissing() {
|
|
19313
|
-
if (
|
|
19314
|
-
|
|
19315
|
-
|
|
19949
|
+
if (fs60.existsSync(CONFIG)) return false;
|
|
19950
|
+
fs60.mkdirSync(KANBAN, { recursive: true });
|
|
19951
|
+
fs60.writeFileSync(CONFIG, CONFIG_TEMPLATE);
|
|
19316
19952
|
return true;
|
|
19317
19953
|
}
|
|
19318
19954
|
function writeModulesIfMissing() {
|
|
19319
|
-
if (
|
|
19320
|
-
|
|
19321
|
-
|
|
19955
|
+
if (fs60.existsSync(MODULES_MD)) return false;
|
|
19956
|
+
fs60.mkdirSync(KANBAN, { recursive: true });
|
|
19957
|
+
fs60.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
|
|
19322
19958
|
return true;
|
|
19323
19959
|
}
|
|
19324
19960
|
function writeGitignoreIfMissing() {
|
|
19325
|
-
|
|
19326
|
-
const text5 =
|
|
19961
|
+
fs60.mkdirSync(KANBAN, { recursive: true });
|
|
19962
|
+
const text5 = fs60.existsSync(KANBAN_GITIGNORE) ? fs60.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
|
|
19327
19963
|
const has = (rule) => text5.split("\n").some((line) => line.trim() === rule.line);
|
|
19328
19964
|
const missing = IGNORE_RULES.filter((rule) => !has(rule));
|
|
19329
19965
|
if (!missing.length) return false;
|
|
@@ -19331,37 +19967,37 @@ function writeGitignoreIfMissing() {
|
|
|
19331
19967
|
${rule.line}
|
|
19332
19968
|
`).join("");
|
|
19333
19969
|
const separator = !text5 || text5.endsWith("\n") ? "" : "\n";
|
|
19334
|
-
|
|
19970
|
+
fs60.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${block}`);
|
|
19335
19971
|
return true;
|
|
19336
19972
|
}
|
|
19337
19973
|
function writeSkeletonIfMissing() {
|
|
19338
19974
|
const added = [];
|
|
19339
|
-
if (!
|
|
19340
|
-
|
|
19975
|
+
if (!fs60.existsSync(TODO)) {
|
|
19976
|
+
fs60.mkdirSync(TODO, { recursive: true });
|
|
19341
19977
|
added.push(`${rel(TODO)}/`);
|
|
19342
19978
|
}
|
|
19343
|
-
if (!
|
|
19344
|
-
|
|
19979
|
+
if (!fs60.existsSync(README)) {
|
|
19980
|
+
fs60.writeFileSync(README, boardReadme());
|
|
19345
19981
|
added.push(rel(README));
|
|
19346
19982
|
}
|
|
19347
19983
|
return added;
|
|
19348
19984
|
}
|
|
19349
19985
|
function retireReleases() {
|
|
19350
19986
|
const done2 = [];
|
|
19351
|
-
if (
|
|
19352
|
-
|
|
19987
|
+
if (fs60.existsSync(RELEASES)) {
|
|
19988
|
+
fs60.rmSync(RELEASES);
|
|
19353
19989
|
done2.push(`deleted ${rel(RELEASES)}`);
|
|
19354
19990
|
}
|
|
19355
19991
|
let cards = 0;
|
|
19356
19992
|
for (const dir of [TODO, ARCHIVE]) {
|
|
19357
|
-
if (!
|
|
19993
|
+
if (!fs60.existsSync(dir)) continue;
|
|
19358
19994
|
for (const file of walkMd(dir)) {
|
|
19359
|
-
const text5 =
|
|
19995
|
+
const text5 = fs60.readFileSync(file, "utf8");
|
|
19360
19996
|
const end2 = text5.startsWith("---\n") ? text5.indexOf("\n---", 3) : -1;
|
|
19361
19997
|
if (end2 < 0) continue;
|
|
19362
19998
|
const head2 = text5.slice(0, end2).replace(/\nrelease:[^\n]*/, "");
|
|
19363
19999
|
if (head2.length === end2) continue;
|
|
19364
|
-
|
|
20000
|
+
fs60.writeFileSync(file, head2 + text5.slice(end2));
|
|
19365
20001
|
cards++;
|
|
19366
20002
|
}
|
|
19367
20003
|
}
|
|
@@ -19369,7 +20005,7 @@ function retireReleases() {
|
|
|
19369
20005
|
return done2.join(", ");
|
|
19370
20006
|
}
|
|
19371
20007
|
function cmdInit() {
|
|
19372
|
-
if (
|
|
20008
|
+
if (fs60.existsSync(KANBAN)) {
|
|
19373
20009
|
const added = [
|
|
19374
20010
|
...writeSkeletonIfMissing(),
|
|
19375
20011
|
writeConfigIfMissing() && rel(CONFIG),
|
|
@@ -19404,8 +20040,8 @@ function cmdInit() {
|
|
|
19404
20040
|
}
|
|
19405
20041
|
return { board: rel(KANBAN), created: false, added, memory_paths: scaffolded.map((s) => rel(s.dir)) };
|
|
19406
20042
|
}
|
|
19407
|
-
|
|
19408
|
-
|
|
20043
|
+
fs60.mkdirSync(TODO, { recursive: true });
|
|
20044
|
+
fs60.writeFileSync(README, boardReadme());
|
|
19409
20045
|
writeConfigIfMissing();
|
|
19410
20046
|
scaffoldProjectMemory();
|
|
19411
20047
|
writeModulesIfMissing();
|
|
@@ -19494,25 +20130,25 @@ var init_scheduled = __esm({
|
|
|
19494
20130
|
});
|
|
19495
20131
|
|
|
19496
20132
|
// src/lib/card-age.ts
|
|
19497
|
-
import
|
|
19498
|
-
import
|
|
20133
|
+
import fs61 from "node:fs";
|
|
20134
|
+
import path63 from "node:path";
|
|
19499
20135
|
function staleAfterIn(config) {
|
|
19500
20136
|
const days = Number(LINE.exec(config)?.[1]);
|
|
19501
20137
|
return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
|
|
19502
20138
|
}
|
|
19503
20139
|
function staleAfter() {
|
|
19504
|
-
if (!
|
|
19505
|
-
return staleAfterIn(
|
|
20140
|
+
if (!fs61.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
|
|
20141
|
+
return staleAfterIn(fs61.readFileSync(CONFIG, "utf8"));
|
|
19506
20142
|
}
|
|
19507
20143
|
function todoPathspec(top) {
|
|
19508
|
-
const from =
|
|
19509
|
-
if (!from || from.startsWith("..") ||
|
|
19510
|
-
return from.split(
|
|
20144
|
+
const from = path63.relative(real(top), real(TODO));
|
|
20145
|
+
if (!from || from.startsWith("..") || path63.isAbsolute(from)) return null;
|
|
20146
|
+
return from.split(path63.sep).join("/");
|
|
19511
20147
|
}
|
|
19512
20148
|
function cardFile2(spec, printed) {
|
|
19513
20149
|
const p2 = unquotePath(printed);
|
|
19514
20150
|
if (!p2.startsWith(`${spec}/`)) return null;
|
|
19515
|
-
return
|
|
20151
|
+
return path63.join(TODO, ...p2.slice(spec.length + 1).split("/"));
|
|
19516
20152
|
}
|
|
19517
20153
|
function dirtyCards(top, spec) {
|
|
19518
20154
|
const out = git(["status", "--porcelain", "--untracked-files=all", "--", spec], top);
|
|
@@ -19559,9 +20195,9 @@ var init_card_age = __esm({
|
|
|
19559
20195
|
gitTop = () => git(["rev-parse", "--show-toplevel"])?.trim() || null;
|
|
19560
20196
|
real = (p2) => {
|
|
19561
20197
|
try {
|
|
19562
|
-
return
|
|
20198
|
+
return fs61.realpathSync(p2);
|
|
19563
20199
|
} catch {
|
|
19564
|
-
return
|
|
20200
|
+
return path63.resolve(p2);
|
|
19565
20201
|
}
|
|
19566
20202
|
};
|
|
19567
20203
|
unquotePath = (line) => {
|
|
@@ -19596,8 +20232,8 @@ var init_card_holds = __esm({
|
|
|
19596
20232
|
});
|
|
19597
20233
|
|
|
19598
20234
|
// src/commands/list.ts
|
|
19599
|
-
import
|
|
19600
|
-
import
|
|
20235
|
+
import fs62 from "node:fs";
|
|
20236
|
+
import path64 from "node:path";
|
|
19601
20237
|
function summaryLine(body) {
|
|
19602
20238
|
const lines = body.split("\n");
|
|
19603
20239
|
let i = 0;
|
|
@@ -19613,13 +20249,13 @@ function summaryLine(body) {
|
|
|
19613
20249
|
function openRows() {
|
|
19614
20250
|
const rows = [];
|
|
19615
20251
|
for (const file of walkMd(TODO)) {
|
|
19616
|
-
const base =
|
|
20252
|
+
const base = path64.basename(file);
|
|
19617
20253
|
if (base === "README.md") continue;
|
|
19618
20254
|
const isRoot = base === "root.md";
|
|
19619
|
-
const id = isRoot ? idPrefix(
|
|
20255
|
+
const id = isRoot ? idPrefix(path64.basename(path64.dirname(file))) : idPrefix(base);
|
|
19620
20256
|
if (id == null) continue;
|
|
19621
|
-
if (isLegacyRecurring(
|
|
19622
|
-
const { meta, body } = parseFrontmatter(
|
|
20257
|
+
if (isLegacyRecurring(path64.relative(TODO, file))) continue;
|
|
20258
|
+
const { meta, body } = parseFrontmatter(fs62.readFileSync(file, "utf8"));
|
|
19623
20259
|
rows.push({
|
|
19624
20260
|
id,
|
|
19625
20261
|
file,
|
|
@@ -19661,15 +20297,15 @@ function cmdStale(rows, all2, scope, mod) {
|
|
|
19661
20297
|
}
|
|
19662
20298
|
function archivedFiles() {
|
|
19663
20299
|
const files2 = /* @__PURE__ */ new Map();
|
|
19664
|
-
if (!
|
|
20300
|
+
if (!fs62.existsSync(ARCHIVE)) return files2;
|
|
19665
20301
|
for (const file of walkMd(ARCHIVE)) {
|
|
19666
|
-
const id = idPrefix(
|
|
20302
|
+
const id = idPrefix(path64.basename(file));
|
|
19667
20303
|
if (id !== null) files2.set(id, file);
|
|
19668
20304
|
}
|
|
19669
20305
|
for (const dir of walkDirs(ARCHIVE)) {
|
|
19670
|
-
const id = idPrefix(
|
|
19671
|
-
const root2 =
|
|
19672
|
-
if (id !== null &&
|
|
20306
|
+
const id = idPrefix(path64.basename(dir));
|
|
20307
|
+
const root2 = path64.join(dir, "root.md");
|
|
20308
|
+
if (id !== null && fs62.existsSync(root2)) files2.set(id, root2);
|
|
19673
20309
|
}
|
|
19674
20310
|
return files2;
|
|
19675
20311
|
}
|
|
@@ -19780,14 +20416,14 @@ var init_list = __esm({
|
|
|
19780
20416
|
});
|
|
19781
20417
|
|
|
19782
20418
|
// src/commands/misc.ts
|
|
19783
|
-
import
|
|
19784
|
-
import
|
|
20419
|
+
import fs63 from "node:fs";
|
|
20420
|
+
import path65 from "node:path";
|
|
19785
20421
|
function extractOldMeta(text5, file) {
|
|
19786
20422
|
const grab = (re3) => {
|
|
19787
20423
|
const m = text5.match(re3);
|
|
19788
20424
|
return m ? m[1].trim() : null;
|
|
19789
20425
|
};
|
|
19790
|
-
const title = grab(/^#\s+(.+)$/m) || slugify(
|
|
20426
|
+
const title = grab(/^#\s+(.+)$/m) || slugify(path65.basename(file, ".md").replace(/^\d+-/, "")).replace(/-/g, " ");
|
|
19791
20427
|
const norm = (raw) => {
|
|
19792
20428
|
const v = (raw || "").toLowerCase();
|
|
19793
20429
|
return LEVELS.includes(v) ? v : "med";
|
|
@@ -19814,11 +20450,11 @@ function stripOldHeader(text5) {
|
|
|
19814
20450
|
}
|
|
19815
20451
|
function cmdMigrate(opts) {
|
|
19816
20452
|
const dry = opts.dryRun === true;
|
|
19817
|
-
const files2 = walkMd(TODO).filter((f2) =>
|
|
20453
|
+
const files2 = walkMd(TODO).filter((f2) => path65.basename(f2) !== "README.md");
|
|
19818
20454
|
let changed = 0;
|
|
19819
20455
|
let skipped = 0;
|
|
19820
20456
|
for (const file of files2) {
|
|
19821
|
-
const text5 =
|
|
20457
|
+
const text5 = fs63.readFileSync(file, "utf8");
|
|
19822
20458
|
if (text5.trimStart().startsWith("---")) {
|
|
19823
20459
|
skipped++;
|
|
19824
20460
|
continue;
|
|
@@ -19827,7 +20463,7 @@ function cmdMigrate(opts) {
|
|
|
19827
20463
|
const out = serializeFrontmatter(meta) + "\n\n" + stripOldHeader(text5).replace(/^\n+/, "");
|
|
19828
20464
|
if (dry) say(`would migrate ${rel(file)} (priority=${meta.priority})`);
|
|
19829
20465
|
else {
|
|
19830
|
-
|
|
20466
|
+
fs63.writeFileSync(file, out.endsWith("\n") ? out : out + "\n");
|
|
19831
20467
|
say(`migrated ${rel(file)}`);
|
|
19832
20468
|
}
|
|
19833
20469
|
changed++;
|
|
@@ -19848,8 +20484,8 @@ var init_misc = __esm({
|
|
|
19848
20484
|
});
|
|
19849
20485
|
|
|
19850
20486
|
// src/lib/card-sources.ts
|
|
19851
|
-
import
|
|
19852
|
-
import
|
|
20487
|
+
import fs64 from "node:fs";
|
|
20488
|
+
import path66 from "node:path";
|
|
19853
20489
|
function planById(id) {
|
|
19854
20490
|
const found2 = readPlan(`plans/${id}-.md`);
|
|
19855
20491
|
return found2?.text.trim() ? found2 : null;
|
|
@@ -19859,8 +20495,8 @@ function cardLink(id) {
|
|
|
19859
20495
|
const found2 = open3 ?? locateArchived(id);
|
|
19860
20496
|
if (!found2) return null;
|
|
19861
20497
|
try {
|
|
19862
|
-
const file = found2.kind === "group" ?
|
|
19863
|
-
const title = parseFrontmatter(
|
|
20498
|
+
const file = found2.kind === "group" ? path66.join(found2.target, "root.md") : found2.target;
|
|
20499
|
+
const title = parseFrontmatter(fs64.readFileSync(file, "utf8")).meta?.title ?? "";
|
|
19864
20500
|
return { kind: "card", ref: String(id), title, ...open3 ? {} : { archived: true } };
|
|
19865
20501
|
} catch {
|
|
19866
20502
|
return null;
|
|
@@ -19885,7 +20521,7 @@ function link(ref, items) {
|
|
|
19885
20521
|
if (ref.kind === "plan") return planLink(ref.id);
|
|
19886
20522
|
if (ref.kind === "card") return cardLink(ref.id);
|
|
19887
20523
|
if (ref.kind === "url") return urlLink(ref.url);
|
|
19888
|
-
const item = items().find((signal2) =>
|
|
20524
|
+
const item = items().find((signal2) => path66.basename(signal2.relPath) === ref.file);
|
|
19889
20525
|
return item ? itemLink(item) : null;
|
|
19890
20526
|
}
|
|
19891
20527
|
function cardSources(meta, body) {
|
|
@@ -19926,12 +20562,12 @@ var init_card_sources = __esm({
|
|
|
19926
20562
|
});
|
|
19927
20563
|
|
|
19928
20564
|
// src/lib/view/read.ts
|
|
19929
|
-
import
|
|
19930
|
-
import
|
|
20565
|
+
import fs65 from "node:fs";
|
|
20566
|
+
import path67 from "node:path";
|
|
19931
20567
|
function readCard(file, relFromTodo) {
|
|
19932
|
-
const id = idPrefix(
|
|
20568
|
+
const id = idPrefix(path67.basename(relFromTodo));
|
|
19933
20569
|
if (id === null) {
|
|
19934
|
-
const parts = relFromTodo.split(
|
|
20570
|
+
const parts = relFromTodo.split(path67.sep);
|
|
19935
20571
|
const folderId = idPrefix(parts[parts.length - 2] || "");
|
|
19936
20572
|
if (folderId === null) return null;
|
|
19937
20573
|
return buildCard(folderId, file, relFromTodo);
|
|
@@ -19939,10 +20575,10 @@ function readCard(file, relFromTodo) {
|
|
|
19939
20575
|
return buildCard(id, file, relFromTodo);
|
|
19940
20576
|
}
|
|
19941
20577
|
function buildCard(id, file, relFromTodo) {
|
|
19942
|
-
const text5 =
|
|
20578
|
+
const text5 = fs65.readFileSync(file, "utf8");
|
|
19943
20579
|
const { meta, body } = parseFrontmatter(text5);
|
|
19944
20580
|
if (!meta) return null;
|
|
19945
|
-
const relPath = relFromTodo.split(
|
|
20581
|
+
const relPath = relFromTodo.split(path67.sep).join("/");
|
|
19946
20582
|
const flow = workflowFor(meta.workflow);
|
|
19947
20583
|
const plan = !!meta.workflow && archivesOnApproval(flow);
|
|
19948
20584
|
const stages = cardStages(meta, flow).length;
|
|
@@ -19951,7 +20587,7 @@ function buildCard(id, file, relFromTodo) {
|
|
|
19951
20587
|
// Derived from the file exactly as it is on disk (lib/board/revision.ts), so a card
|
|
19952
20588
|
// read here and a card read by the contract agree on what version this is.
|
|
19953
20589
|
revision: revisionOf(text5),
|
|
19954
|
-
updatedAt:
|
|
20590
|
+
updatedAt: fs65.statSync(file).mtime.toISOString(),
|
|
19955
20591
|
relPath,
|
|
19956
20592
|
title: meta.title,
|
|
19957
20593
|
priority: meta.priority,
|
|
@@ -19972,22 +20608,22 @@ function buildCard(id, file, relFromTodo) {
|
|
|
19972
20608
|
};
|
|
19973
20609
|
}
|
|
19974
20610
|
function readGroup2(folderName) {
|
|
19975
|
-
const groupDir =
|
|
19976
|
-
const rootFile =
|
|
19977
|
-
if (!
|
|
19978
|
-
const root2 = readCard(rootFile,
|
|
20611
|
+
const groupDir = path67.join(TODO, folderName);
|
|
20612
|
+
const rootFile = path67.join(groupDir, "root.md");
|
|
20613
|
+
if (!fs65.existsSync(rootFile)) return null;
|
|
20614
|
+
const root2 = readCard(rootFile, path67.join(folderName, "root.md"));
|
|
19979
20615
|
if (!root2) return null;
|
|
19980
20616
|
root2.isGroup = true;
|
|
19981
20617
|
const { total, resolved: resolved2 } = subtaskLines(root2.body);
|
|
19982
20618
|
root2.subtaskLines = { total, resolved: resolved2 };
|
|
19983
20619
|
const subCards = [];
|
|
19984
20620
|
const recurse = (dir, relDir) => {
|
|
19985
|
-
for (const entry of
|
|
19986
|
-
const childRel =
|
|
20621
|
+
for (const entry of fs65.readdirSync(dir, { withFileTypes: true })) {
|
|
20622
|
+
const childRel = path67.join(relDir, entry.name);
|
|
19987
20623
|
if (entry.isDirectory()) {
|
|
19988
|
-
recurse(
|
|
20624
|
+
recurse(path67.join(dir, entry.name), childRel);
|
|
19989
20625
|
} else if (entry.name.endsWith(".md") && entry.name !== "README.md" && entry.name !== "root.md") {
|
|
19990
|
-
const c2 = readCard(
|
|
20626
|
+
const c2 = readCard(path67.join(dir, entry.name), childRel);
|
|
19991
20627
|
if (c2) {
|
|
19992
20628
|
c2.parent = { id: root2.id, title: root2.title };
|
|
19993
20629
|
subCards.push(c2);
|
|
@@ -20008,12 +20644,12 @@ function readGroup2(folderName) {
|
|
|
20008
20644
|
return { root: root2, subCards };
|
|
20009
20645
|
}
|
|
20010
20646
|
function standaloneCards(dirRel) {
|
|
20011
|
-
const dir = dirRel ?
|
|
20012
|
-
if (!
|
|
20647
|
+
const dir = dirRel ? path67.join(TODO, dirRel) : TODO;
|
|
20648
|
+
if (!fs65.existsSync(dir)) return [];
|
|
20013
20649
|
const cards = [];
|
|
20014
|
-
for (const entry of
|
|
20650
|
+
for (const entry of fs65.readdirSync(dir, { withFileTypes: true })) {
|
|
20015
20651
|
if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
|
|
20016
|
-
const c2 = readCard(
|
|
20652
|
+
const c2 = readCard(path67.join(dir, entry.name), path67.join(dirRel, entry.name));
|
|
20017
20653
|
if (c2) cards.push(c2);
|
|
20018
20654
|
}
|
|
20019
20655
|
}
|
|
@@ -20025,7 +20661,7 @@ function collectCards() {
|
|
|
20025
20661
|
const top = standaloneCards("");
|
|
20026
20662
|
board2.push(...top);
|
|
20027
20663
|
every.push(...top);
|
|
20028
|
-
for (const entry of
|
|
20664
|
+
for (const entry of fs65.readdirSync(TODO, { withFileTypes: true })) {
|
|
20029
20665
|
if (!entry.isDirectory()) continue;
|
|
20030
20666
|
if (isGroupFolder(entry.name)) {
|
|
20031
20667
|
const g3 = readGroup2(entry.name);
|
|
@@ -20057,7 +20693,7 @@ function findCard(id) {
|
|
|
20057
20693
|
}
|
|
20058
20694
|
function attachSources(card) {
|
|
20059
20695
|
try {
|
|
20060
|
-
const { meta, body } = parseFrontmatter(
|
|
20696
|
+
const { meta, body } = parseFrontmatter(fs65.readFileSync(path67.join(TODO, card.relPath), "utf8"));
|
|
20061
20697
|
const sources2 = meta ? cardSources(meta, body) : [];
|
|
20062
20698
|
if (sources2.length) card.sources = sources2;
|
|
20063
20699
|
} catch {
|
|
@@ -20162,10 +20798,10 @@ var init_read = __esm({
|
|
|
20162
20798
|
});
|
|
20163
20799
|
|
|
20164
20800
|
// src/lib/group-close.ts
|
|
20165
|
-
import
|
|
20801
|
+
import fs66 from "node:fs";
|
|
20166
20802
|
function groupCloses(rootFile) {
|
|
20167
20803
|
try {
|
|
20168
|
-
return groupCloseOf(
|
|
20804
|
+
return groupCloseOf(fs66.readFileSync(rootFile, "utf8"));
|
|
20169
20805
|
} catch {
|
|
20170
20806
|
return false;
|
|
20171
20807
|
}
|
|
@@ -20178,12 +20814,12 @@ var init_group_close = __esm({
|
|
|
20178
20814
|
});
|
|
20179
20815
|
|
|
20180
20816
|
// src/commands/remove.ts
|
|
20181
|
-
import
|
|
20182
|
-
import
|
|
20817
|
+
import fs67 from "node:fs";
|
|
20818
|
+
import path68 from "node:path";
|
|
20183
20819
|
function leavingIds(id, found2) {
|
|
20184
20820
|
const ids = /* @__PURE__ */ new Set([id]);
|
|
20185
20821
|
if (found2.kind === "group") {
|
|
20186
|
-
const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) =>
|
|
20822
|
+
const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) => path68.basename(f2));
|
|
20187
20823
|
for (const name of names3) {
|
|
20188
20824
|
const n = idPrefix(name);
|
|
20189
20825
|
if (n !== null) ids.add(n);
|
|
@@ -20195,10 +20831,10 @@ function findMentions(ids) {
|
|
|
20195
20831
|
const hits = [];
|
|
20196
20832
|
const re3 = new RegExp(ids.map((id) => `#${id}(?!\\d)`).join("|"));
|
|
20197
20833
|
for (const dir of [TODO, MEMORY]) {
|
|
20198
|
-
if (!
|
|
20834
|
+
if (!fs67.existsSync(dir)) continue;
|
|
20199
20835
|
for (const file of walkMd(dir)) {
|
|
20200
|
-
if (
|
|
20201
|
-
const lines =
|
|
20836
|
+
if (path68.basename(file) === "README.md") continue;
|
|
20837
|
+
const lines = fs67.readFileSync(file, "utf8").split("\n");
|
|
20202
20838
|
const fmEnd = frontmatterEnd(lines);
|
|
20203
20839
|
lines.forEach((line, i) => {
|
|
20204
20840
|
if (!re3.test(line)) return;
|
|
@@ -20214,12 +20850,12 @@ function findMentions(ids) {
|
|
|
20214
20850
|
return hits;
|
|
20215
20851
|
}
|
|
20216
20852
|
function leavingCards(id, found2) {
|
|
20217
|
-
const own = found2.kind === "group" ?
|
|
20853
|
+
const own = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
|
|
20218
20854
|
const cards = [{ id, file: own }];
|
|
20219
20855
|
if (found2.kind !== "group") return cards;
|
|
20220
20856
|
for (const file of walkMd(found2.target)) {
|
|
20221
20857
|
if (file === own) continue;
|
|
20222
|
-
const n = idPrefix(
|
|
20858
|
+
const n = idPrefix(path68.basename(file));
|
|
20223
20859
|
if (n !== null) cards.push({ id: n, file });
|
|
20224
20860
|
}
|
|
20225
20861
|
return cards;
|
|
@@ -20228,10 +20864,10 @@ function stampLeaving(cards, rejection) {
|
|
|
20228
20864
|
const day = formatDay();
|
|
20229
20865
|
const stamp4 = rejection && !rejection.discard ? { reason: rejection.reason, at: (/* @__PURE__ */ new Date()).toISOString(), by: insideRun() ? "agent" : "user" } : rejection && { reason: rejection.reason };
|
|
20230
20866
|
for (const card of cards) {
|
|
20231
|
-
if (!
|
|
20232
|
-
const text5 =
|
|
20867
|
+
if (!fs67.existsSync(card.file)) continue;
|
|
20868
|
+
const text5 = fs67.readFileSync(card.file, "utf8");
|
|
20233
20869
|
const stamped = stampLeavingIn(text5, day, stamp4);
|
|
20234
|
-
if (stamped !== text5)
|
|
20870
|
+
if (stamped !== text5) fs67.writeFileSync(card.file, stamped);
|
|
20235
20871
|
}
|
|
20236
20872
|
}
|
|
20237
20873
|
function unfinishedDelivery(id) {
|
|
@@ -20247,7 +20883,7 @@ function unfinishedDelivery(id) {
|
|
|
20247
20883
|
}[gap];
|
|
20248
20884
|
return `#${id} is not finished: ${what}.`;
|
|
20249
20885
|
}
|
|
20250
|
-
const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !
|
|
20886
|
+
const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs67.existsSync(path68.join(ASSETS, src.slice(".assets/".length))));
|
|
20251
20887
|
return missing ? `#${id} is not finished: ${missing} is not on this machine.` : null;
|
|
20252
20888
|
}
|
|
20253
20889
|
function agentDecisions(text5) {
|
|
@@ -20278,8 +20914,8 @@ function removeCard2(id, metric, options) {
|
|
|
20278
20914
|
const unfinished = metric === "completed" ? unfinishedDelivery(id) : null;
|
|
20279
20915
|
if (unfinished) die(unfinished, { kind: "plan-delivery-unfinished" });
|
|
20280
20916
|
const dest = options.cleanupDiscarded && locateArchived(id) ? null : archiveDest(found2);
|
|
20281
|
-
const cardFile3 = found2.kind === "group" ?
|
|
20282
|
-
const cardText =
|
|
20917
|
+
const cardFile3 = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
|
|
20918
|
+
const cardText = fs67.existsSync(cardFile3) ? fs67.readFileSync(cardFile3, "utf8") : "";
|
|
20283
20919
|
const { meta: cardMeta3 } = parseFrontmatter(cardText);
|
|
20284
20920
|
const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f2) => f2 !== cardFile3).map((f2) => rel(f2)).sort() : [];
|
|
20285
20921
|
const leftIds = leavingIds(id, found2);
|
|
@@ -20310,10 +20946,10 @@ function removeCard2(id, metric, options) {
|
|
|
20310
20946
|
const groupRoot = found2.kind === "file" && !options.closing ? enclosingGroupRoot(found2.target) : null;
|
|
20311
20947
|
if (dest) {
|
|
20312
20948
|
stampLeaving(leaving, metric === "rejected" ? { reason: options.reason?.trim() ?? "", discard: options.discard === true } : null);
|
|
20313
|
-
|
|
20314
|
-
|
|
20949
|
+
fs67.mkdirSync(ARCHIVE, { recursive: true });
|
|
20950
|
+
fs67.renameSync(found2.target, dest);
|
|
20315
20951
|
} else {
|
|
20316
|
-
|
|
20952
|
+
fs67.rmSync(found2.target, { recursive: true, force: true });
|
|
20317
20953
|
}
|
|
20318
20954
|
const removedRefs = stripReadmeRefs(found2);
|
|
20319
20955
|
let marked2 = null;
|
|
@@ -20362,14 +20998,14 @@ function removeCard2(id, metric, options) {
|
|
|
20362
20998
|
};
|
|
20363
20999
|
}
|
|
20364
21000
|
function closeGroup(rootFile) {
|
|
20365
|
-
const rootId = idPrefix(
|
|
21001
|
+
const rootId = idPrefix(path68.basename(path68.dirname(rootFile)));
|
|
20366
21002
|
if (rootId === null) return null;
|
|
20367
21003
|
if (runnerProject(KANBAN)) return null;
|
|
20368
21004
|
if (!groupCloses(rootFile)) return null;
|
|
20369
21005
|
say(`
|
|
20370
21006
|
every subtask line on #${rootId} is resolved \u2014 closing the group:`);
|
|
20371
21007
|
try {
|
|
20372
|
-
const { meta, body } = parseFrontmatter(
|
|
21008
|
+
const { meta, body } = parseFrontmatter(fs67.readFileSync(rootFile, "utf8"));
|
|
20373
21009
|
const res = cmdRemove(rootId, "completed", { closing: true });
|
|
20374
21010
|
return {
|
|
20375
21011
|
id: rootId,
|
|
@@ -20426,7 +21062,7 @@ function cleanupDiscardedCards(sessionId) {
|
|
|
20426
21062
|
if (card.pending) throw new Error(`Discarding #${card.id} did not finish. Retry the discard.`);
|
|
20427
21063
|
while (locate(card.id)) cmdRemove(card.id, "rejected", { discard: true, cleanupDiscarded: true });
|
|
20428
21064
|
dropCrossRefs(card.id);
|
|
20429
|
-
stripReadmeRefs({ kind: "file", rel:
|
|
21065
|
+
stripReadmeRefs({ kind: "file", rel: path68.relative(TODO, path68.resolve(REPO_ROOT, card.path)).split(path68.sep).join("/") });
|
|
20430
21066
|
}
|
|
20431
21067
|
return discarded.map((c2) => c2.id);
|
|
20432
21068
|
});
|
|
@@ -20434,8 +21070,8 @@ function cleanupDiscardedCards(sessionId) {
|
|
|
20434
21070
|
function recoveredArchiveHandoff(id, source) {
|
|
20435
21071
|
const found2 = locateArchived(id);
|
|
20436
21072
|
if (!found2) throw new Error(`No archived card #${id} was found.`);
|
|
20437
|
-
const file = found2.kind === "group" ?
|
|
20438
|
-
const { meta } = parseFrontmatter(
|
|
21073
|
+
const file = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
|
|
21074
|
+
const { meta } = parseFrontmatter(fs67.readFileSync(file, "utf8"));
|
|
20439
21075
|
stripReadmeRefs(source ?? found2);
|
|
20440
21076
|
const root2 = source?.kind === "file" ? enclosingGroupRoot(source.target) : null;
|
|
20441
21077
|
if (root2) markSubtask(root2, id, "tick");
|
|
@@ -20533,8 +21169,8 @@ var init_memory_file = __esm({
|
|
|
20533
21169
|
});
|
|
20534
21170
|
|
|
20535
21171
|
// src/commands/rule.ts
|
|
20536
|
-
import
|
|
20537
|
-
import
|
|
21172
|
+
import fs68 from "node:fs";
|
|
21173
|
+
import path69 from "node:path";
|
|
20538
21174
|
function cmdRule(askedName, flags) {
|
|
20539
21175
|
const agent = askedName.trim();
|
|
20540
21176
|
if (!agentRoster().some((a2) => a2.name === agent)) {
|
|
@@ -20543,7 +21179,7 @@ function cmdRule(askedName, flags) {
|
|
|
20543
21179
|
const rule = readRuleText(flags.file, flags.text);
|
|
20544
21180
|
const res = setAgentRule(agent, rule);
|
|
20545
21181
|
if (!res.ok) die(res.error);
|
|
20546
|
-
const file = rel(
|
|
21182
|
+
const file = rel(path69.join(RULES, `${agent}.md`));
|
|
20547
21183
|
say(rule ? `wrote the \`${agent}\` rule (${file})` : `cleared the \`${agent}\` rule`);
|
|
20548
21184
|
return { agent, file, cleared: !rule };
|
|
20549
21185
|
}
|
|
@@ -20551,7 +21187,7 @@ function readRuleText(file, text5) {
|
|
|
20551
21187
|
if (file !== void 0 && text5 !== void 0) die("pass --file or --text, not both");
|
|
20552
21188
|
if (file !== void 0) {
|
|
20553
21189
|
try {
|
|
20554
|
-
return
|
|
21190
|
+
return fs68.readFileSync(file, "utf8").trim();
|
|
20555
21191
|
} catch {
|
|
20556
21192
|
die(`can't read ${file} \u2014 write the rule to a file, then pass its path`);
|
|
20557
21193
|
}
|
|
@@ -20870,7 +21506,7 @@ var shared_exports = {};
|
|
|
20870
21506
|
__export(shared_exports, {
|
|
20871
21507
|
InvalidArgumentError: () => InvalidArgumentError,
|
|
20872
21508
|
cardId: () => cardId,
|
|
20873
|
-
collect: () =>
|
|
21509
|
+
collect: () => collect2,
|
|
20874
21510
|
collectList: () => collectList,
|
|
20875
21511
|
ctxOf: () => ctxOf,
|
|
20876
21512
|
intInRange: () => intInRange,
|
|
@@ -20966,7 +21602,7 @@ function ordered(into) {
|
|
|
20966
21602
|
return value ?? "";
|
|
20967
21603
|
};
|
|
20968
21604
|
}
|
|
20969
|
-
var HELP_WIDTH,
|
|
21605
|
+
var HELP_WIDTH, collect2;
|
|
20970
21606
|
var init_shared = __esm({
|
|
20971
21607
|
"src/lib/cli/shared.ts"() {
|
|
20972
21608
|
"use strict";
|
|
@@ -20975,7 +21611,7 @@ var init_shared = __esm({
|
|
|
20975
21611
|
init_board_cli();
|
|
20976
21612
|
init_moved();
|
|
20977
21613
|
HELP_WIDTH = 100;
|
|
20978
|
-
|
|
21614
|
+
collect2 = (value, previous = []) => previous.concat(value);
|
|
20979
21615
|
}
|
|
20980
21616
|
});
|
|
20981
21617
|
|
|
@@ -20985,8 +21621,8 @@ __export(board_exports, {
|
|
|
20985
21621
|
buildBoardProgram: () => buildBoardProgram
|
|
20986
21622
|
});
|
|
20987
21623
|
import crypto5 from "node:crypto";
|
|
20988
|
-
import
|
|
20989
|
-
import
|
|
21624
|
+
import fs69 from "node:fs";
|
|
21625
|
+
import path70 from "node:path";
|
|
20990
21626
|
async function dispatch(move, cmd, args, opts, cli) {
|
|
20991
21627
|
const ctx = ctxOf(cmd, cli.program);
|
|
20992
21628
|
const data = await runAction(ctx, {}, async () => {
|
|
@@ -21026,7 +21662,7 @@ async function cloudCard(task, opts) {
|
|
|
21026
21662
|
let request2;
|
|
21027
21663
|
if (typeof opts.bodyFile === "string") {
|
|
21028
21664
|
try {
|
|
21029
|
-
request2 =
|
|
21665
|
+
request2 = fs69.readFileSync(opts.bodyFile, "utf8");
|
|
21030
21666
|
} catch {
|
|
21031
21667
|
}
|
|
21032
21668
|
}
|
|
@@ -21056,7 +21692,7 @@ async function cloudCard(task, opts) {
|
|
|
21056
21692
|
const file = creationReceipt(`${checked.value}:${requestId}`, slot);
|
|
21057
21693
|
const journal = readCreation(file, said3);
|
|
21058
21694
|
if (!journal.made) {
|
|
21059
|
-
const key = `akb-${
|
|
21695
|
+
const key = `akb-${path70.basename(file, ".json").slice(0, 40)}`;
|
|
21060
21696
|
const made = await createProjectTask(checked.value, journal.said, key);
|
|
21061
21697
|
if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
|
|
21062
21698
|
journal.made = made.value;
|
|
@@ -21086,13 +21722,13 @@ function buildBoardProgram(cli) {
|
|
|
21086
21722
|
const inOrder = ordered(asked);
|
|
21087
21723
|
move("create").summary("write exactly one card \u2014 its fields, its body template and its index entry").description(
|
|
21088
21724
|
'Write exactly ONE card: allocate its id, write its frontmatter and a body template, and index it. There is no separate id-reservation mode. --blocked-by and --related take ids of existing open cards; for a group, create the root first, then create each subtask related to its id (see "Group tasks" in `akb guide add-task`). The script owns the frontmatter and writes the body scaffold; fill only the body by hand. Without --id, Cloud assigns the number in the linked project (no source task required). A failed local write can resume the same creation without making another Cloud task. Missing or invalid project links and denied access exit with code 1 using the existing error envelope. --body-file accepts a short draft or full card body. Invalid bodies fail before allocating a task or writing a card, with repair instructions. Cloud moves the card on by itself once it reaches the board: do not refine it here. Turning what a user just asked for into a card goes through `akb create` instead: this move only writes what you already decided. Example: akb raw create --title "Add a delete command" --body-file /tmp/delete-command.md'
|
|
21089
|
-
).requiredOption("--title <title>", "what the card is called").addOption(new Option("--recurring").hideHelp()).option("--priority <level>", `how much it matters: ${LEVELS.join(" | ")} (default: med)`, oneOf(LEVELS)).option("--blocked-by <ids>", "ids of open cards this one waits on", collectList).option("--related <ids>", "ids of open cards this one relates to", collectList).option("--modules <names>", "the parts of the project it touches, validated against modules.md", collectList).option("--question <text>", "an open question; needs its --option choices. Repeatable; follow `akb guide update-questions`", inOrder("question")).option("--option <text>", "a choice for the --question before it", inOrder("option")).option("--recommended-option <text>", "a choice for the --question before it, ticked to start", inOrder("recommended-option")).option("--mode <mode>", "how many choices the --question before it takes: single | multi", inOrder("mode")).option("--slug <slug>", "the filename to write it under (default: from the title)").option("--no-body", "write the frontmatter and no body template").option("--body-file <path>", "a short draft or full card body, written to a file first").addOption(new Option("--cadence <cadence>").hideHelp()).option("--workflow <id>", "the workflow it runs through (`akb workflow list`). Left off, the board's default").option("--previews <agents>", `the preview agents it chose, from its workflow's; "" chooses none`, collectList).addOption(new Option("--id <n>", "the number Cloud gave this card's task; for the Runner").argParser(cardId).hideHelp()).option("--triage <source-id>", "the triage item this card is made of, so the item is never carded twice").option("--source <ref>", "where it came from: a plan's path, plan:<id>, #<id> or a URL. Repeatable",
|
|
21725
|
+
).requiredOption("--title <title>", "what the card is called").addOption(new Option("--recurring").hideHelp()).option("--priority <level>", `how much it matters: ${LEVELS.join(" | ")} (default: med)`, oneOf(LEVELS)).option("--blocked-by <ids>", "ids of open cards this one waits on", collectList).option("--related <ids>", "ids of open cards this one relates to", collectList).option("--modules <names>", "the parts of the project it touches, validated against modules.md", collectList).option("--question <text>", "an open question; needs its --option choices. Repeatable; follow `akb guide update-questions`", inOrder("question")).option("--option <text>", "a choice for the --question before it", inOrder("option")).option("--recommended-option <text>", "a choice for the --question before it, ticked to start", inOrder("recommended-option")).option("--mode <mode>", "how many choices the --question before it takes: single | multi", inOrder("mode")).option("--slug <slug>", "the filename to write it under (default: from the title)").option("--no-body", "write the frontmatter and no body template").option("--body-file <path>", "a short draft or full card body, written to a file first").addOption(new Option("--cadence <cadence>").hideHelp()).option("--workflow <id>", "the workflow it runs through (`akb workflow list`). Left off, the board's default").option("--previews <agents>", `the preview agents it chose, from its workflow's; "" chooses none`, collectList).addOption(new Option("--id <n>", "the number Cloud gave this card's task; for the Runner").argParser(cardId).hideHelp()).option("--triage <source-id>", "the triage item this card is made of, so the item is never carded twice").option("--source <ref>", "where it came from: a plan's path, plan:<id>, #<id> or a URL. Repeatable", collect2).action(async function() {
|
|
21090
21726
|
refuseRecurring(this);
|
|
21091
21727
|
await dispatch("create", this, [], { ...this.opts(), asked }, cli);
|
|
21092
21728
|
});
|
|
21093
21729
|
move("update").argument("<id>", ID, cardId).summary("rewrite a card's fields").description(
|
|
21094
21730
|
"Rewrite a card's frontmatter fields. --slug renames it. Body and questions are left untouched \u2014 those have their own moves."
|
|
21095
|
-
).option("--title <title>", "what the card is called").option("--priority <level>", LEVELS.join(" | "), oneOf(LEVELS)).option("--status <status>", STATUSES.join(" | "), oneOf(STATUSES)).option("--blocked-by <ids>", "ids of open cards this one waits on", collectList).option("--related <ids>", "ids of open cards this one relates to", collectList).option("--add-blocked-by <ids>", "append ids to blocked_by, keeping the ids already there", collectList).option("--add-related <ids>", "append ids to related, keeping the ids already there", collectList).option("--modules <names>", "the parts of the project it touches", collectList).option("--source <ref>", `where it came from: a plan's path, plan:<id>, #<id> or a URL. Repeatable; "" clears the list`,
|
|
21731
|
+
).option("--title <title>", "what the card is called").option("--priority <level>", LEVELS.join(" | "), oneOf(LEVELS)).option("--status <status>", STATUSES.join(" | "), oneOf(STATUSES)).option("--blocked-by <ids>", "ids of open cards this one waits on", collectList).option("--related <ids>", "ids of open cards this one relates to", collectList).option("--add-blocked-by <ids>", "append ids to blocked_by, keeping the ids already there", collectList).option("--add-related <ids>", "append ids to related, keeping the ids already there", collectList).option("--modules <names>", "the parts of the project it touches", collectList).option("--source <ref>", `where it came from: a plan's path, plan:<id>, #<id> or a URL. Repeatable; "" clears the list`, collect2).option("--add-source <ref>", "append one source, keeping the ones already there. Repeatable", collect2).option("--previews <agents>", `the preview agents it chose, from its workflow's; "" chooses none`, collectList).option("--phase <n>", "the approval it is on, 1-based").option("--slug <slug>", "rename the file").option("--workflow <id>", 'the workflow it runs through; "" puts it back on the default. The card goes back to todo and is re-planned').addOption(new Option("--cadence <cadence>").hideHelp()).action(async function(id) {
|
|
21096
21732
|
refuseRecurring(this);
|
|
21097
21733
|
await dispatch("update", this, [String(id)], this.opts(), cli);
|
|
21098
21734
|
});
|
|
@@ -21198,16 +21834,16 @@ var init_board2 = __esm({
|
|
|
21198
21834
|
});
|
|
21199
21835
|
|
|
21200
21836
|
// src/lib/board-cli.ts
|
|
21201
|
-
import
|
|
21202
|
-
import
|
|
21837
|
+
import fs70 from "node:fs";
|
|
21838
|
+
import path71 from "node:path";
|
|
21203
21839
|
function useBoard(found2, dirNamed) {
|
|
21204
|
-
if (!found2.named && found2.board ===
|
|
21840
|
+
if (!found2.named && found2.board === path71.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
|
|
21205
21841
|
else setBoardDir(found2.board, found2.root);
|
|
21206
21842
|
useProjectState();
|
|
21207
21843
|
}
|
|
21208
21844
|
function whole(found2, move) {
|
|
21209
21845
|
if (move === MAKES_A_BOARD) return found2;
|
|
21210
|
-
if (!
|
|
21846
|
+
if (!fs70.existsSync(path71.join(found2.board, "todo"))) {
|
|
21211
21847
|
die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
|
|
21212
21848
|
kind: "board-incomplete",
|
|
21213
21849
|
dir: found2.root
|
|
@@ -21216,13 +21852,13 @@ function whole(found2, move) {
|
|
|
21216
21852
|
return found2;
|
|
21217
21853
|
}
|
|
21218
21854
|
function findBoardUpward(from, move) {
|
|
21219
|
-
let dir =
|
|
21855
|
+
let dir = path71.resolve(from);
|
|
21220
21856
|
for (; ; ) {
|
|
21221
|
-
if (hasBoard(dir)) return { root: dir, board:
|
|
21857
|
+
if (hasBoard(dir)) return { root: dir, board: path71.join(dir, "docs", "kanban") };
|
|
21222
21858
|
if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
|
|
21223
|
-
const kept2 =
|
|
21224
|
-
if (move !== MAKES_A_BOARD &&
|
|
21225
|
-
const up =
|
|
21859
|
+
const kept2 = path71.join(dir, ".akb", "kanban");
|
|
21860
|
+
if (move !== MAKES_A_BOARD && fs70.existsSync(path71.join(kept2, "todo"))) return { root: dir, board: kept2 };
|
|
21861
|
+
const up = path71.dirname(dir);
|
|
21226
21862
|
if (up === dir) return null;
|
|
21227
21863
|
dir = up;
|
|
21228
21864
|
}
|
|
@@ -21230,11 +21866,11 @@ function findBoardUpward(from, move) {
|
|
|
21230
21866
|
function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
21231
21867
|
const named2 = board2 ?? boardFromEnv();
|
|
21232
21868
|
if (named2) {
|
|
21233
|
-
const folder =
|
|
21234
|
-
if (!
|
|
21869
|
+
const folder = path71.resolve(cwd, named2);
|
|
21870
|
+
if (!fs70.existsSync(folder) && move !== MAKES_A_BOARD) {
|
|
21235
21871
|
die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
|
|
21236
21872
|
}
|
|
21237
|
-
if (
|
|
21873
|
+
if (fs70.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
|
|
21238
21874
|
die(`${folder} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
|
|
21239
21875
|
kind: "no-board",
|
|
21240
21876
|
dir: folder
|
|
@@ -21243,24 +21879,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
|
21243
21879
|
return { root: projectRootOf(folder), board: folder, named: true };
|
|
21244
21880
|
}
|
|
21245
21881
|
if (dir !== null) {
|
|
21246
|
-
const root2 =
|
|
21247
|
-
if (!
|
|
21248
|
-
const kept2 =
|
|
21249
|
-
if (!hasBoard(root2) && move !== MAKES_A_BOARD &&
|
|
21882
|
+
const root2 = path71.resolve(dir);
|
|
21883
|
+
if (!fs70.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
|
|
21884
|
+
const kept2 = path71.join(root2, ".akb", "kanban");
|
|
21885
|
+
if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs70.existsSync(path71.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
|
|
21250
21886
|
if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
|
|
21251
21887
|
die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
|
|
21252
21888
|
kind: "no-board",
|
|
21253
21889
|
dir: root2
|
|
21254
21890
|
});
|
|
21255
21891
|
}
|
|
21256
|
-
return whole({ root: root2, board:
|
|
21892
|
+
return whole({ root: root2, board: path71.join(root2, "docs", "kanban") }, move);
|
|
21257
21893
|
}
|
|
21258
21894
|
const found2 = findBoardUpward(cwd, move);
|
|
21259
21895
|
if (found2) return whole(found2, move);
|
|
21260
|
-
if (move === MAKES_A_BOARD) return { root:
|
|
21896
|
+
if (move === MAKES_A_BOARD) return { root: path71.resolve(cwd), board: path71.join(path71.resolve(cwd), "docs", "kanban") };
|
|
21261
21897
|
die(
|
|
21262
|
-
`no board here. Looked in ${
|
|
21263
|
-
{ kind: "no-board", dir:
|
|
21898
|
+
`no board here. Looked in ${path71.resolve(cwd)} and every folder above it for docs/kanban/. ${installHint}\uFF0C\u6216\u7528 --board \u6307\u5B9A\u5DF2\u6709\u770B\u677F\u3002`,
|
|
21899
|
+
{ kind: "no-board", dir: path71.resolve(cwd) }
|
|
21264
21900
|
);
|
|
21265
21901
|
}
|
|
21266
21902
|
function editDistance(a2, b2) {
|
|
@@ -21342,8 +21978,8 @@ var init_board_cli = __esm({
|
|
|
21342
21978
|
init_io();
|
|
21343
21979
|
init_pointer();
|
|
21344
21980
|
MAKES_A_BOARD = "init";
|
|
21345
|
-
hasBoard = (dir) =>
|
|
21346
|
-
isBoardDir = (dir) =>
|
|
21981
|
+
hasBoard = (dir) => fs70.existsSync(path71.join(dir, "docs", "kanban"));
|
|
21982
|
+
isBoardDir = (dir) => fs70.existsSync(path71.join(dir, "todo")) && fs70.existsSync(path71.join(dir, "config.md"));
|
|
21347
21983
|
boardFromEnv = () => {
|
|
21348
21984
|
const named2 = process.env.AI4KANBAN_BOARD?.trim();
|
|
21349
21985
|
return named2 ? named2 : null;
|
|
@@ -21451,7 +22087,7 @@ var init_review_rejections = __esm({
|
|
|
21451
22087
|
var refine_default;
|
|
21452
22088
|
var init_refine = __esm({
|
|
21453
22089
|
"src/guide/refine.md"() {
|
|
21454
|
-
refine_default = '# Refine a card\n\nPlan one card in this session until it can be built
|
|
22090
|
+
refine_default = '# Refine a card\n\nPlan one card in this session until it can be built.\n\n- **\u91CD\u590D\u5361\u7247**: \u82E5\u53D1\u73B0\u53E6\u4E00\u5F20\u4EFB\u52A1\u5B8C\u6574\u8986\u76D6\u672C\u5361\uFF0C\u5373\u4F7F\u5BF9\u65B9\u5C1A\u672A\u5B9E\u65BD\uFF0C\u4E5F\u5148\u5C06\u5176\u7F3A\u5C11\u7684\u6709\u7528\u4FE1\u606F\u8865\u5165\u5E76\u786E\u8BA4\u4FDD\u5B58\u6210\u529F\uFF1B\n \u4FDD\u5B58\u5931\u8D25\u5219\u4FDD\u7559\u672C\u5361\u5E76\u505C\u6B62\u3002\u6CA1\u6709\u4FE1\u606F\u9700\u8981\u8865\u5145\u6216\u5DF2\u4FDD\u5B58\u6210\u529F\u540E\uFF0C\u8FD0\u884C\n `akb raw reject <id> --reason "<\u627F\u63A5\u4EFB\u52A1\u7F16\u53F7\u53CA\u5B8C\u6574\u8986\u76D6\u539F\u56E0>"` \u5E76\u505C\u6B62\u3002\n \u4E0D\u8BF7\u6C42\u786E\u8BA4\uFF0C\u4E0D\u8FD0\u884C\u9884\u89C8\uFF1B\u4EC5\u90E8\u5206\u91CD\u53E0\u4E0D\u4E22\u5F03\u3002\n- **Unchecked card**: a card with `triage:` set and an empty `## Scope` was never checked\n against the project. Check it first; when the project already does\n the work, or what it concerns no longer exists, run\n `akb raw reject <id> --reason "<what shows it>"` and stop.\n- **Gone or already done**: for any other card, append a question asking the user whether to\n discard it, run no preview agent, and stop.\n- **Workflow rules**: write the card as the workflow rules at the end of this prompt say.\n- **Preview agents**: an agent\'s `After` names the previews it waits for; the board approves\n previews in stages, one stage per Approve, and the card\'s `previews` were chosen when its\n goal was written. A card without `previews` has not chosen: choose and save them first, as\n the list says, then run only its first stage. Run each agent the list above names whose\n section is missing or outdated with `akb previews <agent> <id> --print`, one at a time in this\n session; leave out `--print` only for an agent the list says runs in a session of its own.\n- **Stale mentions**: rewrite any sentence that relies on a card no longer on the board.\n- **Questions**: settle every decision you can and record the answers as `akb guide writing`\n says; ask only what `akb guide update-questions` says to ask.\n- **Write**: shape the card as `akb guide writing` says, then run `akb raw validate <id>` and\n fix every reported line.\n- **Ready**: settle every fact from the project and authoritative sources. Once the card\n validates, judge whether it can be built as written, or before its last Approve: if so, run\n `akb raw update <id> --status ready`; otherwise leave what blocks it as an open question.\n\nFollow any closing steps the flow printed, then stop: the user approves the previews or starts\nthe build.\n';
|
|
21455
22091
|
}
|
|
21456
22092
|
});
|
|
21457
22093
|
|
|
@@ -21507,7 +22143,7 @@ var init_troubleshoot = __esm({
|
|
|
21507
22143
|
var write_agent_default;
|
|
21508
22144
|
var init_write_agent = __esm({
|
|
21509
22145
|
"src/guide/write-agent.md"() {
|
|
21510
|
-
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---\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\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 zh:\n # Display name; does not change the agent's name.\n title: \u754C\u9762\u6587\u6848\u5E08\n description: \u64B0\u5199\u754C\u9762\u4E0A\u7684\u6587\u5B57\u3002\n when: \u5361\u7247\u65B0\u589E\u6216\u4FEE\u6539\u754C\u9762\u6587\u5B57\u65F6\u3002\n```\n\n## Files\n\nEvery file beside `AGENT.md`, in any subfolder, is named to the run by its path and opened only\nwhen the work calls for it. Put long material there and keep `AGENT.md` short.\n\n- **Scripts**: every agent owns its task scripts in its own folder, including built-in agents.\n Keep business validation there, outside the CLI's board logic. Document the runtime, inputs\n and invocation beside the script; consumers use the owner's script. Built-in files can be\n saved through `akb raw agent-file <agent> <path>` and run locally with their relative layout\n intact; custom agents use their existing folders.\n\n## Imported skills\n\nAn agent may carry several skills, each whole in its own `skills/<skill>/` folder.\n\n- **Keep the capability**: copy the skill's instructions, scripts, resources and license\n unchanged; never reduce it to rewritten instructions. Leave out installed packages and caches,\n and name any file it refers to that you could not get.\n- **Record the source**: list each in a `## Skills` section of `AGENT.md` as\n `- **<skill>**: <when to use it>. Source: <URL or pasted> @ <commit, tag or snapshot date>`.\n- **Adapt outside it**: say in `AGENT.md` when to use each skill and how its result becomes\n this agent's output; paths inside a skill resolve from its folder. Keep the skill folder\n untouched so an update can replace it whole.\n- **Runtime needs**: check every command, package and credential the skill needs on this\n machine. Name what is missing under its bullet and tell the user; never call the agent usable\n while anything is missing, and never copy a key into the folder.\n- **Update and remove**: update only when the user asks \u2014 replace the folder, show the diff and\n change the version. Remove a skill with its folder and bullet. Each agent owns its copies, so\n no change reaches another agent.\n\n## Memory\n\n`docs/kanban/memory/agents/<name>/` is read into every run. Keep none unless a user's\ncorrection should change the agent's next output. Otherwise say in `AGENT.md`:\n\n- **Files**: each file and what it holds; `## General` for what always holds, and a heading per\n situation (a format, a recipe, a channel) for what holds only there.\n- **When**: which file to apply before which step, and which answers or corrections to record.\n- **What goes in**: lasting preferences, decisions and corrections only \u2014 never raw feedback,\n run history, or what the instructions already say.\n- **Shared material**: what other agents also use goes in a global memory under `akb.memory`;\n its rules arrive with every run, so `AGENT.md` never restates them.\n\n## Output\n\nDeclare the preview components the agent uses in `akb.components` (Asset, Compare, Storyboard).\nTheir usage documentation is supplied with the run; omitted declarations default to Asset.\nUse `akb 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 previews`. Read all trigger conditions with `akb 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 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 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";
|
|
22146
|
+
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\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 zh:\n # Display name; does not change the agent's name.\n title: \u754C\u9762\u6587\u6848\u5E08\n description: \u64B0\u5199\u754C\u9762\u4E0A\u7684\u6587\u5B57\u3002\n when: \u5361\u7247\u65B0\u589E\u6216\u4FEE\u6539\u754C\u9762\u6587\u5B57\u65F6\u3002\n```\n\n## Files\n\nEvery file beside `AGENT.md`, in any subfolder, is named to the run by its path and opened only\nwhen the work calls for it. Put long material there and keep `AGENT.md` short.\n\n- **Scripts**: every agent owns its task scripts in its own folder, including built-in agents.\n Keep business validation there, outside the CLI's board logic. Document the runtime, inputs\n and invocation beside the script; consumers use the owner's script. Built-in files can be\n saved through `akb raw agent-file <agent> <path>` and run locally with their relative layout\n intact; custom agents use their existing folders.\n\n## Imported skills\n\nAn agent may carry several skills, each whole in its own `skills/<skill>/` folder.\n\n- **Keep the capability**: copy the skill's instructions, scripts, resources and license\n unchanged; never reduce it to rewritten instructions. Leave out installed packages and caches,\n and name any file it refers to that you could not get.\n- **Record the source**: list each in a `## Skills` section of `AGENT.md` as\n `- **<skill>**: <when to use it>. Source: <URL or pasted> @ <commit, tag or snapshot date>`.\n- **Adapt outside it**: say in `AGENT.md` when to use each skill and how its result becomes\n this agent's output; paths inside a skill resolve from its folder. Keep the skill folder\n untouched so an update can replace it whole.\n- **Runtime needs**: check every command, package and credential the skill needs on this\n machine. Name what is missing under its bullet and tell the user; never call the agent usable\n while anything is missing, and never copy a key into the folder.\n- **Update and remove**: update only when the user asks \u2014 replace the folder, show the diff and\n change the version. Remove a skill with its folder and bullet. Each agent owns its copies, so\n no change reaches another agent.\n\n## Memory\n\n`docs/kanban/memory/agents/<name>/` is read into every run. Keep none unless a user's\ncorrection should change the agent's next output. Otherwise say in `AGENT.md`:\n\n- **Files**: each file and what it holds; `## General` for what always holds, and a heading per\n situation (a format, a recipe, a channel) for what holds only there.\n- **When**: which file to apply before which step, and which answers or corrections to record.\n- **What goes in**: lasting preferences, decisions and corrections only \u2014 never raw feedback,\n run history, or what the instructions already say.\n- **Shared material**: what other agents also use goes in a global memory under `akb.memory`;\n its rules arrive with every run, so `AGENT.md` never restates them.\n\n## Output\n\nDeclare the preview components the agent uses in `akb.components` (Asset, Compare, Storyboard).\nTheir usage documentation is supplied with the run; omitted declarations default to Asset.\nUse `akb 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 previews`. Read all trigger conditions with `akb 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 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 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";
|
|
21511
22147
|
}
|
|
21512
22148
|
});
|
|
21513
22149
|
|
|
@@ -21600,8 +22236,8 @@ var init_guide = __esm({
|
|
|
21600
22236
|
});
|
|
21601
22237
|
|
|
21602
22238
|
// src/lib/agent/approve.ts
|
|
21603
|
-
import
|
|
21604
|
-
import
|
|
22239
|
+
import fs77 from "node:fs";
|
|
22240
|
+
import path78 from "node:path";
|
|
21605
22241
|
function approvalRequest(req) {
|
|
21606
22242
|
const id = req.id;
|
|
21607
22243
|
const card = id === void 0 ? null : findCard(id);
|
|
@@ -21619,12 +22255,12 @@ function advancePhase(id) {
|
|
|
21619
22255
|
const card = findCard(id);
|
|
21620
22256
|
const found2 = locate(id);
|
|
21621
22257
|
if (!card || !found2 || !awaitingApproval(card)) return { error: `#${id} is no longer waiting on approval.` };
|
|
21622
|
-
const file = found2.kind === "group" ?
|
|
21623
|
-
const { meta, body } = parseFrontmatter(
|
|
22258
|
+
const file = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
|
|
22259
|
+
const { meta, body } = parseFrontmatter(fs77.readFileSync(file, "utf8"));
|
|
21624
22260
|
if (!meta) return { error: `#${id} has no frontmatter` };
|
|
21625
22261
|
meta.phase = card.stage + 1;
|
|
21626
22262
|
meta.status = "todo";
|
|
21627
|
-
|
|
22263
|
+
fs77.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
|
|
21628
22264
|
return null;
|
|
21629
22265
|
}
|
|
21630
22266
|
var init_approve = __esm({
|
|
@@ -21757,16 +22393,16 @@ var init_start = __esm({
|
|
|
21757
22393
|
});
|
|
21758
22394
|
|
|
21759
22395
|
// src/lib/agent/task-chats.ts
|
|
21760
|
-
import
|
|
21761
|
-
import
|
|
22396
|
+
import fs78 from "node:fs";
|
|
22397
|
+
import path79 from "node:path";
|
|
21762
22398
|
function taskChatFile(task, home3) {
|
|
21763
22399
|
if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
|
|
21764
|
-
return
|
|
22400
|
+
return path79.join(taskChatsDir(home3), `${task}.jsonl`);
|
|
21765
22401
|
}
|
|
21766
22402
|
function readTaskChat(task, home3) {
|
|
21767
22403
|
let text5;
|
|
21768
22404
|
try {
|
|
21769
|
-
text5 =
|
|
22405
|
+
text5 = fs78.readFileSync(taskChatFile(task, home3), "utf8");
|
|
21770
22406
|
} catch {
|
|
21771
22407
|
return [];
|
|
21772
22408
|
}
|
|
@@ -21787,13 +22423,13 @@ var init_task_chats = __esm({
|
|
|
21787
22423
|
"use strict";
|
|
21788
22424
|
init_home();
|
|
21789
22425
|
TASK = /^[\w-]{1,100}$/;
|
|
21790
|
-
taskChatsDir = (home3 = machineHome()) =>
|
|
22426
|
+
taskChatsDir = (home3 = machineHome()) => path79.join(home3, "chats");
|
|
21791
22427
|
}
|
|
21792
22428
|
});
|
|
21793
22429
|
|
|
21794
22430
|
// src/lib/agent/memory-review.ts
|
|
21795
|
-
import
|
|
21796
|
-
import
|
|
22431
|
+
import fs79 from "node:fs";
|
|
22432
|
+
import path80 from "node:path";
|
|
21797
22433
|
function taskChatsToReview(tasks) {
|
|
21798
22434
|
const out = [];
|
|
21799
22435
|
for (const ref of [...new Set(tasks)]) {
|
|
@@ -21815,8 +22451,8 @@ function readArchived2(id) {
|
|
|
21815
22451
|
const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
|
|
21816
22452
|
if (!found2) return null;
|
|
21817
22453
|
try {
|
|
21818
|
-
const file = found2.kind === "group" ?
|
|
21819
|
-
const { meta, body } = parseFrontmatter(
|
|
22454
|
+
const file = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
|
|
22455
|
+
const { meta, body } = parseFrontmatter(fs79.readFileSync(file, "utf8"));
|
|
21820
22456
|
if (!meta) return null;
|
|
21821
22457
|
return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
|
|
21822
22458
|
} catch {
|
|
@@ -21885,17 +22521,17 @@ var init_memory_review = __esm({
|
|
|
21885
22521
|
});
|
|
21886
22522
|
|
|
21887
22523
|
// src/lib/agent/dismissal-review.ts
|
|
21888
|
-
import
|
|
21889
|
-
import
|
|
22524
|
+
import fs80 from "node:fs";
|
|
22525
|
+
import path81 from "node:path";
|
|
21890
22526
|
function rejectionsToReview() {
|
|
21891
|
-
const dir =
|
|
21892
|
-
if (!
|
|
22527
|
+
const dir = path81.join(ARCHIVE, REJECTIONS_TO_REVIEW);
|
|
22528
|
+
if (!fs80.existsSync(dir)) return [];
|
|
21893
22529
|
const found2 = [];
|
|
21894
22530
|
for (const file of walkMd(dir)) {
|
|
21895
22531
|
const id = archivedId(file);
|
|
21896
22532
|
if (id === null) continue;
|
|
21897
22533
|
try {
|
|
21898
|
-
const { meta } = parseFrontmatter(
|
|
22534
|
+
const { meta } = parseFrontmatter(fs80.readFileSync(file, "utf8"));
|
|
21899
22535
|
if (!meta?.rejected || meta.rejected_by !== "user" || !meta.rejected_reason.trim()) continue;
|
|
21900
22536
|
found2.push({ id, title: meta.title, file: rel(file), reason: meta.rejected_reason.trim(), rejectedAt: meta.rejected_at });
|
|
21901
22537
|
} catch {
|
|
@@ -21925,7 +22561,7 @@ function citedSources(text5) {
|
|
|
21925
22561
|
function withdrawnSources() {
|
|
21926
22562
|
const cited = [...new Set(plannerCopies("rejected.md").flatMap((file) => {
|
|
21927
22563
|
try {
|
|
21928
|
-
return citedSources(
|
|
22564
|
+
return citedSources(fs80.readFileSync(file, "utf8"));
|
|
21929
22565
|
} catch {
|
|
21930
22566
|
return [];
|
|
21931
22567
|
}
|
|
@@ -21950,8 +22586,8 @@ var init_dismissal_review = __esm({
|
|
|
21950
22586
|
});
|
|
21951
22587
|
|
|
21952
22588
|
// src/lib/agent/flow.ts
|
|
21953
|
-
import
|
|
21954
|
-
import
|
|
22589
|
+
import fs81 from "node:fs";
|
|
22590
|
+
import path82 from "node:path";
|
|
21955
22591
|
function readCard2(id, home3 = "board") {
|
|
21956
22592
|
const pending = activeDelivery(id)?.completions?.some((c2) => !c2.finished);
|
|
21957
22593
|
const found2 = home3 === "archive" ? locateArchived(id) : locate(id) ?? (pending ? locateArchived(id) : null);
|
|
@@ -21961,10 +22597,10 @@ function readCard2(id, home3 = "board") {
|
|
|
21961
22597
|
{ kind: "card-not-found", id }
|
|
21962
22598
|
);
|
|
21963
22599
|
}
|
|
21964
|
-
const file = found2.kind === "group" ?
|
|
22600
|
+
const file = found2.kind === "group" ? path82.join(found2.target, "root.md") : found2.target;
|
|
21965
22601
|
let text5;
|
|
21966
22602
|
try {
|
|
21967
|
-
text5 =
|
|
22603
|
+
text5 = fs81.readFileSync(file, "utf8");
|
|
21968
22604
|
} catch {
|
|
21969
22605
|
die(`#${id} is on the board but ${rel(file)} can't be read.`, { kind: "card-unreadable", id });
|
|
21970
22606
|
}
|
|
@@ -22652,94 +23288,6 @@ var init_refine2 = __esm({
|
|
|
22652
23288
|
}
|
|
22653
23289
|
});
|
|
22654
23290
|
|
|
22655
|
-
// ../artifact-sdk/src/internal/references.ts
|
|
22656
|
-
function bodyReferences(body) {
|
|
22657
|
-
const lines = body.replace(/<!--[^]*?-->/g, "").split(/\r?\n/);
|
|
22658
|
-
let fence = "";
|
|
22659
|
-
let inTag = false;
|
|
22660
|
-
const out = [];
|
|
22661
|
-
const visible = [];
|
|
22662
|
-
for (const line of lines) {
|
|
22663
|
-
const delimiter = /^ {0,3}(`{3,}|~{3,})/.exec(line)?.[1];
|
|
22664
|
-
if (fence) {
|
|
22665
|
-
if (delimiter && delimiter[0] === fence[0] && delimiter.length >= fence.length) fence = "";
|
|
22666
|
-
visible.push("");
|
|
22667
|
-
continue;
|
|
22668
|
-
}
|
|
22669
|
-
if (delimiter) {
|
|
22670
|
-
fence = delimiter;
|
|
22671
|
-
visible.push("");
|
|
22672
|
-
continue;
|
|
22673
|
-
}
|
|
22674
|
-
const kept2 = inTag || !/^(?: {4}|\t)/.test(line);
|
|
22675
|
-
visible.push(kept2 ? line : "");
|
|
22676
|
-
if (kept2 && /^ {0,3}<(?:Asset|Mockup|Compare|Storyboard)\b/.test(line)) inTag = true;
|
|
22677
|
-
if (line.includes("/>")) inTag = false;
|
|
22678
|
-
}
|
|
22679
|
-
const text5 = visible.join("\n").replace(/(`+)[^]*?\1/g, "");
|
|
22680
|
-
const tag = /<(Asset|Mockup|Compare|Storyboard)\b([^<>]*?)\/>/g;
|
|
22681
|
-
const blocks = text5.matchAll(/^ {0,3}(?:<(?:Asset|Mockup|Compare|Storyboard)\b[^<>]*?\/>[ \t]*(?:\n[ \t]*)?)+$/gm);
|
|
22682
|
-
for (const block of blocks) {
|
|
22683
|
-
const tags = [...block[0].matchAll(tag)];
|
|
22684
|
-
for (const m of tags) {
|
|
22685
|
-
const a2 = {};
|
|
22686
|
-
for (const p2 of m[2].matchAll(/([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) a2[p2[1]] = p2[2] ?? p2[3];
|
|
22687
|
-
if (m[1] === "Compare") {
|
|
22688
|
-
if (!a2.a || !a2.b) continue;
|
|
22689
|
-
for (const k2 of ["a", "b", "shots"]) if (a2[k2]) out.push({ src: a2[k2], purpose: "compare" });
|
|
22690
|
-
} else if (a2.src) {
|
|
22691
|
-
out.push({ src: a2.src, purpose: m[1] === "Storyboard" ? "storyboard" : "asset" });
|
|
22692
|
-
if (a2.variants) {
|
|
22693
|
-
try {
|
|
22694
|
-
const v = JSON.parse(a2.variants);
|
|
22695
|
-
if (isObject(v)) {
|
|
22696
|
-
for (const src of Object.values(v)) if (typeof src === "string" && src) out.push({ src, purpose: "asset" });
|
|
22697
|
-
}
|
|
22698
|
-
} catch {
|
|
22699
|
-
}
|
|
22700
|
-
}
|
|
22701
|
-
}
|
|
22702
|
-
}
|
|
22703
|
-
}
|
|
22704
|
-
for (const m of text5.replace(tag, "").matchAll(/\]\(\s*<?([^\s)>]+)>?(?:\s+["'][^]*?["'])?\s*\)/g)) out.push({ src: m[1], purpose: "asset" });
|
|
22705
|
-
return out;
|
|
22706
|
-
}
|
|
22707
|
-
function kindOf2(ext) {
|
|
22708
|
-
if (ext === ".tsx" || ext === ".html") return "html";
|
|
22709
|
-
if (ext === ".md" || ext === ".mdx") return "markdown";
|
|
22710
|
-
const type = TYPES2[ext] ?? "";
|
|
22711
|
-
if (type.startsWith("image/")) return "image";
|
|
22712
|
-
return type.startsWith("video/") || type.startsWith("audio/") ? "video" : "asset";
|
|
22713
|
-
}
|
|
22714
|
-
var isObject, bodySources, TYPES2;
|
|
22715
|
-
var init_references = __esm({
|
|
22716
|
-
"../artifact-sdk/src/internal/references.ts"() {
|
|
22717
|
-
"use strict";
|
|
22718
|
-
isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
22719
|
-
bodySources = (body) => [...new Set(bodyReferences(body).map((r2) => r2.src))];
|
|
22720
|
-
TYPES2 = {
|
|
22721
|
-
".png": "image/png",
|
|
22722
|
-
".jpg": "image/jpeg",
|
|
22723
|
-
".jpeg": "image/jpeg",
|
|
22724
|
-
".gif": "image/gif",
|
|
22725
|
-
".webp": "image/webp",
|
|
22726
|
-
".svg": "image/svg+xml",
|
|
22727
|
-
".mp4": "video/mp4",
|
|
22728
|
-
".webm": "video/webm",
|
|
22729
|
-
".mp3": "audio/mpeg",
|
|
22730
|
-
".pdf": "application/pdf",
|
|
22731
|
-
".html": "text/html",
|
|
22732
|
-
".md": "text/markdown",
|
|
22733
|
-
".mdx": "text/markdown",
|
|
22734
|
-
".mov": "video/quicktime",
|
|
22735
|
-
".wav": "audio/wav",
|
|
22736
|
-
".m4a": "audio/mp4",
|
|
22737
|
-
".json": "application/json",
|
|
22738
|
-
".txt": "text/plain"
|
|
22739
|
-
};
|
|
22740
|
-
}
|
|
22741
|
-
});
|
|
22742
|
-
|
|
22743
23291
|
// node_modules/react/cjs/react.production.js
|
|
22744
23292
|
var require_react_production = __commonJS({
|
|
22745
23293
|
"node_modules/react/cjs/react.production.js"(exports) {
|
|
@@ -30263,13 +30811,13 @@ var require_react_dom_server_node_production = __commonJS({
|
|
|
30263
30811
|
var target = currentView;
|
|
30264
30812
|
0 < writtenBytes && (target = currentView.subarray(writtenBytes));
|
|
30265
30813
|
target = textEncoder.encodeInto(chunk, target);
|
|
30266
|
-
var
|
|
30814
|
+
var read5 = target.read;
|
|
30267
30815
|
writtenBytes += target.written;
|
|
30268
|
-
|
|
30816
|
+
read5 < chunk.length && (writeToDestination(
|
|
30269
30817
|
destination,
|
|
30270
30818
|
currentView.subarray(0, writtenBytes)
|
|
30271
30819
|
), currentView = new Uint8Array(4096), writtenBytes = textEncoder.encodeInto(
|
|
30272
|
-
chunk.slice(
|
|
30820
|
+
chunk.slice(read5),
|
|
30273
30821
|
currentView
|
|
30274
30822
|
).written);
|
|
30275
30823
|
4096 === writtenBytes && (writeToDestination(destination, currentView), currentView = new Uint8Array(4096), writtenBytes = 0);
|
|
@@ -44019,13 +44567,13 @@ var require_react_dom_server_node_development = __commonJS({
|
|
|
44019
44567
|
var target = currentView;
|
|
44020
44568
|
0 < writtenBytes && (target = currentView.subarray(writtenBytes));
|
|
44021
44569
|
target = textEncoder.encodeInto(chunk, target);
|
|
44022
|
-
var
|
|
44570
|
+
var read5 = target.read;
|
|
44023
44571
|
writtenBytes += target.written;
|
|
44024
|
-
|
|
44572
|
+
read5 < chunk.length && (writeToDestination(
|
|
44025
44573
|
destination,
|
|
44026
44574
|
currentView.subarray(0, writtenBytes)
|
|
44027
44575
|
), currentView = new Uint8Array(4096), writtenBytes = textEncoder.encodeInto(
|
|
44028
|
-
chunk.slice(
|
|
44576
|
+
chunk.slice(read5),
|
|
44029
44577
|
currentView
|
|
44030
44578
|
).written);
|
|
44031
44579
|
4096 === writtenBytes && (writeToDestination(destination, currentView), currentView = new Uint8Array(4096), writtenBytes = 0);
|
|
@@ -63947,8 +64495,8 @@ var require_JSXTransformer = __commonJS({
|
|
|
63947
64495
|
}
|
|
63948
64496
|
if (this.isAutomaticRuntime) {
|
|
63949
64497
|
if (this.importProcessor) {
|
|
63950
|
-
for (const [
|
|
63951
|
-
prefix += `var ${resolvedName} = require("${
|
|
64498
|
+
for (const [path90, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
|
|
64499
|
+
prefix += `var ${resolvedName} = require("${path90}");`;
|
|
63952
64500
|
}
|
|
63953
64501
|
} else {
|
|
63954
64502
|
const { createElement: createElementResolution, ...otherResolutions } = this.esmAutomaticImportNameResolutions;
|
|
@@ -64141,11 +64689,11 @@ var require_JSXTransformer = __commonJS({
|
|
|
64141
64689
|
}
|
|
64142
64690
|
claimAutoImportedName(funcName, importPathSuffix) {
|
|
64143
64691
|
if (this.importProcessor) {
|
|
64144
|
-
const
|
|
64145
|
-
if (!this.cjsAutomaticModuleNameResolutions[
|
|
64146
|
-
this.cjsAutomaticModuleNameResolutions[
|
|
64692
|
+
const path90 = this.jsxImportSource + importPathSuffix;
|
|
64693
|
+
if (!this.cjsAutomaticModuleNameResolutions[path90]) {
|
|
64694
|
+
this.cjsAutomaticModuleNameResolutions[path90] = this.importProcessor.getFreeIdentifierForPath(path90);
|
|
64147
64695
|
}
|
|
64148
|
-
return `${this.cjsAutomaticModuleNameResolutions[
|
|
64696
|
+
return `${this.cjsAutomaticModuleNameResolutions[path90]}.${funcName}`;
|
|
64149
64697
|
} else {
|
|
64150
64698
|
if (!this.esmAutomaticImportNameResolutions[funcName]) {
|
|
64151
64699
|
this.esmAutomaticImportNameResolutions[funcName] = this.nameManager.claimFreeName(
|
|
@@ -64581,7 +65129,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
64581
65129
|
*/
|
|
64582
65130
|
pruneTypeOnlyImports() {
|
|
64583
65131
|
this.nonTypeIdentifiers = _getNonTypeIdentifiers.getNonTypeIdentifiers.call(void 0, this.tokens, this.options);
|
|
64584
|
-
for (const [
|
|
65132
|
+
for (const [path90, importInfo] of this.importInfoByPath.entries()) {
|
|
64585
65133
|
if (importInfo.hasBareImport || importInfo.hasStarExport || importInfo.exportStarNames.length > 0 || importInfo.namedExports.length > 0) {
|
|
64586
65134
|
continue;
|
|
64587
65135
|
}
|
|
@@ -64591,7 +65139,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
64591
65139
|
...importInfo.namedImports.map(({ localName }) => localName)
|
|
64592
65140
|
];
|
|
64593
65141
|
if (names3.every((name) => this.shouldAutomaticallyElideImportedName(name))) {
|
|
64594
|
-
this.importsToReplace.set(
|
|
65142
|
+
this.importsToReplace.set(path90, "");
|
|
64595
65143
|
}
|
|
64596
65144
|
}
|
|
64597
65145
|
}
|
|
@@ -64599,7 +65147,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
64599
65147
|
return this.isTypeScriptTransformEnabled && !this.keepUnusedImports && !this.nonTypeIdentifiers.has(name);
|
|
64600
65148
|
}
|
|
64601
65149
|
generateImportReplacements() {
|
|
64602
|
-
for (const [
|
|
65150
|
+
for (const [path90, importInfo] of this.importInfoByPath.entries()) {
|
|
64603
65151
|
const {
|
|
64604
65152
|
defaultNames,
|
|
64605
65153
|
wildcardNames,
|
|
@@ -64609,17 +65157,17 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
64609
65157
|
hasStarExport
|
|
64610
65158
|
} = importInfo;
|
|
64611
65159
|
if (defaultNames.length === 0 && wildcardNames.length === 0 && namedImports.length === 0 && namedExports.length === 0 && exportStarNames.length === 0 && !hasStarExport) {
|
|
64612
|
-
this.importsToReplace.set(
|
|
65160
|
+
this.importsToReplace.set(path90, `require('${path90}');`);
|
|
64613
65161
|
continue;
|
|
64614
65162
|
}
|
|
64615
|
-
const primaryImportName = this.getFreeIdentifierForPath(
|
|
65163
|
+
const primaryImportName = this.getFreeIdentifierForPath(path90);
|
|
64616
65164
|
let secondaryImportName;
|
|
64617
65165
|
if (this.enableLegacyTypeScriptModuleInterop) {
|
|
64618
65166
|
secondaryImportName = primaryImportName;
|
|
64619
65167
|
} else {
|
|
64620
|
-
secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(
|
|
65168
|
+
secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path90);
|
|
64621
65169
|
}
|
|
64622
|
-
let requireCode = `var ${primaryImportName} = require('${
|
|
65170
|
+
let requireCode = `var ${primaryImportName} = require('${path90}');`;
|
|
64623
65171
|
if (wildcardNames.length > 0) {
|
|
64624
65172
|
for (const wildcardName of wildcardNames) {
|
|
64625
65173
|
const moduleExpr = this.enableLegacyTypeScriptModuleInterop ? primaryImportName : `${this.helperManager.getHelperName("interopRequireWildcard")}(${primaryImportName})`;
|
|
@@ -64647,7 +65195,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
64647
65195
|
"createStarExport"
|
|
64648
65196
|
)}(${primaryImportName});`;
|
|
64649
65197
|
}
|
|
64650
|
-
this.importsToReplace.set(
|
|
65198
|
+
this.importsToReplace.set(path90, requireCode);
|
|
64651
65199
|
for (const defaultName of defaultNames) {
|
|
64652
65200
|
this.identifierReplacements.set(defaultName, `${secondaryImportName}.default`);
|
|
64653
65201
|
}
|
|
@@ -64656,8 +65204,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
64656
65204
|
}
|
|
64657
65205
|
}
|
|
64658
65206
|
}
|
|
64659
|
-
getFreeIdentifierForPath(
|
|
64660
|
-
const components =
|
|
65207
|
+
getFreeIdentifierForPath(path90) {
|
|
65208
|
+
const components = path90.split("/");
|
|
64661
65209
|
const lastComponent = components[components.length - 1];
|
|
64662
65210
|
const baseName = lastComponent.replace(/\W/g, "");
|
|
64663
65211
|
return this.nameManager.claimFreeName(`_${baseName}`);
|
|
@@ -64702,8 +65250,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
64702
65250
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
64703
65251
|
throw new Error("Expected string token at the end of import statement.");
|
|
64704
65252
|
}
|
|
64705
|
-
const
|
|
64706
|
-
const importInfo = this.getImportInfo(
|
|
65253
|
+
const path90 = this.tokens.stringValueAtIndex(index);
|
|
65254
|
+
const importInfo = this.getImportInfo(path90);
|
|
64707
65255
|
importInfo.defaultNames.push(...defaultNames);
|
|
64708
65256
|
importInfo.wildcardNames.push(...wildcardNames);
|
|
64709
65257
|
importInfo.namedImports.push(...namedImports);
|
|
@@ -64770,8 +65318,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
64770
65318
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
64771
65319
|
throw new Error("Expected string token at the end of import statement.");
|
|
64772
65320
|
}
|
|
64773
|
-
const
|
|
64774
|
-
const importInfo = this.getImportInfo(
|
|
65321
|
+
const path90 = this.tokens.stringValueAtIndex(index);
|
|
65322
|
+
const importInfo = this.getImportInfo(path90);
|
|
64775
65323
|
importInfo.namedExports.push(...namedImports);
|
|
64776
65324
|
}
|
|
64777
65325
|
preprocessExportStarAtIndex(index) {
|
|
@@ -64786,8 +65334,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
64786
65334
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
64787
65335
|
throw new Error("Expected string token at the end of star export statement.");
|
|
64788
65336
|
}
|
|
64789
|
-
const
|
|
64790
|
-
const importInfo = this.getImportInfo(
|
|
65337
|
+
const path90 = this.tokens.stringValueAtIndex(index);
|
|
65338
|
+
const importInfo = this.getImportInfo(path90);
|
|
64791
65339
|
if (exportedName !== null) {
|
|
64792
65340
|
importInfo.exportStarNames.push(exportedName);
|
|
64793
65341
|
} else {
|
|
@@ -64827,8 +65375,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
64827
65375
|
* Get a mutable import info object for this path, creating one if it doesn't
|
|
64828
65376
|
* exist yet.
|
|
64829
65377
|
*/
|
|
64830
|
-
getImportInfo(
|
|
64831
|
-
const existingInfo = this.importInfoByPath.get(
|
|
65378
|
+
getImportInfo(path90) {
|
|
65379
|
+
const existingInfo = this.importInfoByPath.get(path90);
|
|
64832
65380
|
if (existingInfo) {
|
|
64833
65381
|
return existingInfo;
|
|
64834
65382
|
}
|
|
@@ -64841,7 +65389,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
64841
65389
|
exportStarNames: [],
|
|
64842
65390
|
hasStarExport: false
|
|
64843
65391
|
};
|
|
64844
|
-
this.importInfoByPath.set(
|
|
65392
|
+
this.importInfoByPath.set(path90, newInfo);
|
|
64845
65393
|
return newInfo;
|
|
64846
65394
|
}
|
|
64847
65395
|
addExportBinding(localName, exportedName) {
|
|
@@ -65421,16 +65969,16 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
65421
65969
|
}
|
|
65422
65970
|
function parseFileUrl(input) {
|
|
65423
65971
|
const match = fileRegex.exec(input);
|
|
65424
|
-
const
|
|
65425
|
-
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(
|
|
65972
|
+
const path90 = match[2];
|
|
65973
|
+
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path90) ? path90 : "/" + path90, match[3] || "", match[4] || "");
|
|
65426
65974
|
}
|
|
65427
|
-
function makeUrl(scheme, user, host2, port,
|
|
65975
|
+
function makeUrl(scheme, user, host2, port, path90, query, hash2) {
|
|
65428
65976
|
return {
|
|
65429
65977
|
scheme,
|
|
65430
65978
|
user,
|
|
65431
65979
|
host: host2,
|
|
65432
65980
|
port,
|
|
65433
|
-
path:
|
|
65981
|
+
path: path90,
|
|
65434
65982
|
query,
|
|
65435
65983
|
hash: hash2,
|
|
65436
65984
|
type: 7
|
|
@@ -65460,11 +66008,11 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
65460
66008
|
url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
|
|
65461
66009
|
return url;
|
|
65462
66010
|
}
|
|
65463
|
-
function stripPathFilename(
|
|
65464
|
-
if (
|
|
65465
|
-
return
|
|
65466
|
-
const index =
|
|
65467
|
-
return
|
|
66011
|
+
function stripPathFilename(path90) {
|
|
66012
|
+
if (path90.endsWith("/.."))
|
|
66013
|
+
return path90;
|
|
66014
|
+
const index = path90.lastIndexOf("/");
|
|
66015
|
+
return path90.slice(0, index + 1);
|
|
65468
66016
|
}
|
|
65469
66017
|
function mergePaths(url, base) {
|
|
65470
66018
|
normalizePath(base, base.type);
|
|
@@ -65502,14 +66050,14 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
65502
66050
|
pieces[pointer++] = piece;
|
|
65503
66051
|
positive++;
|
|
65504
66052
|
}
|
|
65505
|
-
let
|
|
66053
|
+
let path90 = "";
|
|
65506
66054
|
for (let i = 1; i < pointer; i++) {
|
|
65507
|
-
|
|
66055
|
+
path90 += "/" + pieces[i];
|
|
65508
66056
|
}
|
|
65509
|
-
if (!
|
|
65510
|
-
|
|
66057
|
+
if (!path90 || addTrailingSlash && !path90.endsWith("/..")) {
|
|
66058
|
+
path90 += "/";
|
|
65511
66059
|
}
|
|
65512
|
-
url.path =
|
|
66060
|
+
url.path = path90;
|
|
65513
66061
|
}
|
|
65514
66062
|
function resolve2(input, base) {
|
|
65515
66063
|
if (!input && !base)
|
|
@@ -65550,13 +66098,13 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
65550
66098
|
case 3:
|
|
65551
66099
|
return queryHash;
|
|
65552
66100
|
case 4: {
|
|
65553
|
-
const
|
|
65554
|
-
if (!
|
|
66101
|
+
const path90 = url.path.slice(1);
|
|
66102
|
+
if (!path90)
|
|
65555
66103
|
return queryHash || ".";
|
|
65556
|
-
if (isRelative(base || input) && !isRelative(
|
|
65557
|
-
return "./" +
|
|
66104
|
+
if (isRelative(base || input) && !isRelative(path90)) {
|
|
66105
|
+
return "./" + path90 + queryHash;
|
|
65558
66106
|
}
|
|
65559
|
-
return
|
|
66107
|
+
return path90 + queryHash;
|
|
65560
66108
|
}
|
|
65561
66109
|
case 5:
|
|
65562
66110
|
return url.path + queryHash;
|
|
@@ -65655,12 +66203,12 @@ var require_trace_mapping_umd = __commonJS({
|
|
|
65655
66203
|
module2.exports = __toCommonJS(trace_mapping_exports);
|
|
65656
66204
|
var import_sourcemap_codec = __toESM2(require_sourcemap_codec());
|
|
65657
66205
|
var import_resolve_uri = __toESM2(require_resolve_uri());
|
|
65658
|
-
function stripFilename(
|
|
65659
|
-
if (!
|
|
65660
|
-
const index =
|
|
65661
|
-
return
|
|
66206
|
+
function stripFilename(path90) {
|
|
66207
|
+
if (!path90) return "";
|
|
66208
|
+
const index = path90.lastIndexOf("/");
|
|
66209
|
+
return path90.slice(0, index + 1);
|
|
65662
66210
|
}
|
|
65663
|
-
function
|
|
66211
|
+
function resolver2(mapUrl, sourceRoot) {
|
|
65664
66212
|
const from = stripFilename(mapUrl);
|
|
65665
66213
|
const prefix = sourceRoot ? sourceRoot + "/" : "";
|
|
65666
66214
|
return (source) => (0, import_resolve_uri.default)(prefix + (source || ""), from);
|
|
@@ -65909,7 +66457,7 @@ var require_trace_mapping_umd = __commonJS({
|
|
|
65909
66457
|
this.sources = sources2;
|
|
65910
66458
|
this.sourcesContent = sourcesContent;
|
|
65911
66459
|
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
|
|
65912
|
-
const resolve2 =
|
|
66460
|
+
const resolve2 = resolver2(mapUrl, sourceRoot);
|
|
65913
66461
|
this.resolvedSources = sources2.map(resolve2);
|
|
65914
66462
|
const { mappings } = parsed;
|
|
65915
66463
|
if (typeof mappings === "string") {
|
|
@@ -66866,9 +67414,9 @@ var require_util2 = __commonJS({
|
|
|
66866
67414
|
/** @class */
|
|
66867
67415
|
(function(_super) {
|
|
66868
67416
|
__extends(VError2, _super);
|
|
66869
|
-
function VError2(
|
|
67417
|
+
function VError2(path90, message) {
|
|
66870
67418
|
var _this = _super.call(this, message) || this;
|
|
66871
|
-
_this.path =
|
|
67419
|
+
_this.path = path90;
|
|
66872
67420
|
Object.setPrototypeOf(_this, VError2.prototype);
|
|
66873
67421
|
return _this;
|
|
66874
67422
|
}
|
|
@@ -66928,26 +67476,26 @@ var require_util2 = __commonJS({
|
|
|
66928
67476
|
(_b = this._messages).push.apply(_b, best._messages);
|
|
66929
67477
|
}
|
|
66930
67478
|
};
|
|
66931
|
-
DetailContext2.prototype.getError = function(
|
|
67479
|
+
DetailContext2.prototype.getError = function(path90) {
|
|
66932
67480
|
var msgParts = [];
|
|
66933
67481
|
for (var i = this._propNames.length - 1; i >= 0; i--) {
|
|
66934
67482
|
var p2 = this._propNames[i];
|
|
66935
|
-
|
|
67483
|
+
path90 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
|
|
66936
67484
|
var m = this._messages[i];
|
|
66937
67485
|
if (m) {
|
|
66938
|
-
msgParts.push(
|
|
67486
|
+
msgParts.push(path90 + " " + m);
|
|
66939
67487
|
}
|
|
66940
67488
|
}
|
|
66941
|
-
return new VError(
|
|
67489
|
+
return new VError(path90, msgParts.join("; "));
|
|
66942
67490
|
};
|
|
66943
|
-
DetailContext2.prototype.getErrorDetail = function(
|
|
67491
|
+
DetailContext2.prototype.getErrorDetail = function(path90) {
|
|
66944
67492
|
var details = [];
|
|
66945
67493
|
for (var i = this._propNames.length - 1; i >= 0; i--) {
|
|
66946
67494
|
var p2 = this._propNames[i];
|
|
66947
|
-
|
|
67495
|
+
path90 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
|
|
66948
67496
|
var message = this._messages[i];
|
|
66949
67497
|
if (message) {
|
|
66950
|
-
details.push({ path:
|
|
67498
|
+
details.push({ path: path90, message });
|
|
66951
67499
|
}
|
|
66952
67500
|
}
|
|
66953
67501
|
var detail = null;
|
|
@@ -67760,8 +68308,8 @@ var require_dist = __commonJS({
|
|
|
67760
68308
|
this.checkerPlain = this.ttype.getChecker(suite, false);
|
|
67761
68309
|
this.checkerStrict = this.ttype.getChecker(suite, true);
|
|
67762
68310
|
}
|
|
67763
|
-
Checker2.prototype.setReportedPath = function(
|
|
67764
|
-
this._path =
|
|
68311
|
+
Checker2.prototype.setReportedPath = function(path90) {
|
|
68312
|
+
this._path = path90;
|
|
67765
68313
|
};
|
|
67766
68314
|
Checker2.prototype.check = function(value) {
|
|
67767
68315
|
return this._doCheck(this.checkerPlain, value);
|
|
@@ -73194,9 +73742,9 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
73194
73742
|
if (shouldElideImport) {
|
|
73195
73743
|
this.tokens.removeToken();
|
|
73196
73744
|
} else {
|
|
73197
|
-
const
|
|
73198
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
73199
|
-
this.tokens.appendCode(this.importProcessor.claimImportCode(
|
|
73745
|
+
const path90 = this.tokens.stringValue();
|
|
73746
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
|
|
73747
|
+
this.tokens.appendCode(this.importProcessor.claimImportCode(path90));
|
|
73200
73748
|
}
|
|
73201
73749
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
73202
73750
|
if (this.tokens.matches1(_types.TokenType.semi)) {
|
|
@@ -73776,8 +74324,8 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
73776
74324
|
}
|
|
73777
74325
|
if (this.tokens.matchesContextual(_keywords.ContextualKeyword._from)) {
|
|
73778
74326
|
this.tokens.removeToken();
|
|
73779
|
-
const
|
|
73780
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
74327
|
+
const path90 = this.tokens.stringValue();
|
|
74328
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
|
|
73781
74329
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
73782
74330
|
} else {
|
|
73783
74331
|
this.tokens.appendCode(exportStatements.join(" "));
|
|
@@ -73791,8 +74339,8 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
73791
74339
|
while (!this.tokens.matches1(_types.TokenType.string)) {
|
|
73792
74340
|
this.tokens.removeToken();
|
|
73793
74341
|
}
|
|
73794
|
-
const
|
|
73795
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
74342
|
+
const path90 = this.tokens.stringValue();
|
|
74343
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
|
|
73796
74344
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
73797
74345
|
if (this.tokens.matches1(_types.TokenType.semi)) {
|
|
73798
74346
|
this.tokens.removeToken();
|
|
@@ -103646,9 +104194,9 @@ var init_bundle_mjs = __esm({
|
|
|
103646
104194
|
processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
|
|
103647
104195
|
}
|
|
103648
104196
|
};
|
|
103649
|
-
getPart = (classPartObject,
|
|
104197
|
+
getPart = (classPartObject, path90) => {
|
|
103650
104198
|
let current = classPartObject;
|
|
103651
|
-
const parts =
|
|
104199
|
+
const parts = path90.split(CLASS_PART_SEPARATOR);
|
|
103652
104200
|
const len = parts.length;
|
|
103653
104201
|
for (let i = 0; i < len; i++) {
|
|
103654
104202
|
const part = parts[i];
|
|
@@ -106898,8 +107446,8 @@ var init_dist = __esm({
|
|
|
106898
107446
|
});
|
|
106899
107447
|
|
|
106900
107448
|
// src/lib/draw-mockup.ts
|
|
106901
|
-
import
|
|
106902
|
-
import
|
|
107449
|
+
import fs82 from "node:fs";
|
|
107450
|
+
import path84 from "node:path";
|
|
106903
107451
|
import vm from "node:vm";
|
|
106904
107452
|
async function loadPackage(id) {
|
|
106905
107453
|
if (id === "react") return import_react3.default;
|
|
@@ -106912,22 +107460,22 @@ async function loadPackage(id) {
|
|
|
106912
107460
|
return { __esModule: true, ...await load() };
|
|
106913
107461
|
}
|
|
106914
107462
|
function resolveFile(id, from, folder) {
|
|
106915
|
-
const at2 =
|
|
106916
|
-
if (at2 !== folder && !at2.startsWith(folder +
|
|
106917
|
-
const tries =
|
|
106918
|
-
const file = tries.find((f2) =>
|
|
107463
|
+
const at2 = path84.resolve(path84.dirname(from), id);
|
|
107464
|
+
if (at2 !== folder && !at2.startsWith(folder + path84.sep)) throw new Error(`${id} is outside the mockup's folder`);
|
|
107465
|
+
const tries = path84.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path84.join(at2, `index${e2}`))];
|
|
107466
|
+
const file = tries.find((f2) => fs82.statSync(f2, { throwIfNoEntry: false })?.isFile());
|
|
106919
107467
|
if (!file) throw new Error(`no such file: ${id}`);
|
|
106920
107468
|
return file;
|
|
106921
107469
|
}
|
|
106922
107470
|
async function readGraph(entry) {
|
|
106923
|
-
const folder =
|
|
107471
|
+
const folder = path84.dirname(entry);
|
|
106924
107472
|
const graph = { code: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), sheets: [], packages: /* @__PURE__ */ new Map() };
|
|
106925
107473
|
const walk3 = async (file) => {
|
|
106926
107474
|
if (graph.code.has(file)) return;
|
|
106927
107475
|
if (graph.code.size >= MAX_FILES) throw new Error(`a mockup imports more than ${MAX_FILES} files`);
|
|
106928
107476
|
let location = file;
|
|
106929
107477
|
try {
|
|
106930
|
-
const js = (0, import_sucrase.transform)(
|
|
107478
|
+
const js = (0, import_sucrase.transform)(fs82.readFileSync(file, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file }).code;
|
|
106931
107479
|
graph.code.set(file, js);
|
|
106932
107480
|
const link2 = /* @__PURE__ */ new Map();
|
|
106933
107481
|
graph.links.set(file, link2);
|
|
@@ -106941,7 +107489,7 @@ async function readGraph(entry) {
|
|
|
106941
107489
|
const target = resolveFile(id, file, folder);
|
|
106942
107490
|
link2.set(id, target);
|
|
106943
107491
|
if (!target.endsWith(".css")) await walk3(target);
|
|
106944
|
-
else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content:
|
|
107492
|
+
else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs82.readFileSync(target, "utf8") });
|
|
106945
107493
|
}
|
|
106946
107494
|
} catch (error) {
|
|
106947
107495
|
throw new Error(`${location}: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -106958,29 +107506,17 @@ function run2(script, context, name, deadline, lineOffset = 0) {
|
|
|
106958
107506
|
async function tailwindFor(markup, sheets) {
|
|
106959
107507
|
const source = sheets.length ? sheets.map((s) => s.content).join("\n") : '@import "tailwindcss";';
|
|
106960
107508
|
const compiler = await rc(source, {
|
|
106961
|
-
base: sheets.length ?
|
|
107509
|
+
base: sheets.length ? path84.dirname(sheets[0].path) : "/",
|
|
106962
107510
|
loadStylesheet: async (id, from) => {
|
|
106963
107511
|
if (id === "tailwindcss" || id.startsWith("tailwindcss/")) return { path: "tailwindcss/index.css", base: "/", content: tailwindcss_default };
|
|
106964
107512
|
if (!id.startsWith(".")) throw new Error(`a mockup cannot import ${id}`);
|
|
106965
|
-
const at2 =
|
|
106966
|
-
return { path: at2, base:
|
|
107513
|
+
const at2 = path84.resolve(from, id);
|
|
107514
|
+
return { path: at2, base: path84.dirname(at2), content: fs82.readFileSync(at2, "utf8") };
|
|
106967
107515
|
}
|
|
106968
107516
|
});
|
|
106969
107517
|
const classes = [...markup.matchAll(/class="([^"]*)"/g)].flatMap((m) => m[1].split(/\s+/));
|
|
106970
107518
|
return compiler.build(classes.filter(Boolean));
|
|
106971
107519
|
}
|
|
106972
|
-
function dressPage(file) {
|
|
106973
|
-
const folder = path81.dirname(file);
|
|
106974
|
-
const html = fs79.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
|
|
106975
|
-
const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
|
|
106976
|
-
if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
|
|
106977
|
-
const at3 = path81.resolve(folder, href);
|
|
106978
|
-
if (!at3.startsWith(folder + path81.sep) || !fs79.existsSync(at3)) return tag;
|
|
106979
|
-
return `<style>${fs79.readFileSync(at3, "utf8").replace(/<\/style/gi, "<\\/style")}</style>`;
|
|
106980
|
-
});
|
|
106981
|
-
const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
|
|
106982
|
-
return /<!doctype\b|<html[\s>]|<head[\s>]/i.test(html) ? html.slice(0, at2) + head + html.slice(at2) : `<!doctype html><html><head>${head}</head><body>${html}</body></html>`;
|
|
106983
|
-
}
|
|
106984
107520
|
async function drawMockup(entry) {
|
|
106985
107521
|
if (entry.toLowerCase().endsWith(".html")) return dressPage(entry);
|
|
106986
107522
|
const graph = await readGraph(entry);
|
|
@@ -107027,7 +107563,7 @@ ${graph.code.get(file)}
|
|
|
107027
107563
|
const css = (await tailwindFor(markup, graph.sheets)).replace(/<\/style/gi, "<\\/style");
|
|
107028
107564
|
return `<!doctype html><html><head>${head}<style>${css}</style></head><body>${markup}</body></html>`;
|
|
107029
107565
|
}
|
|
107030
|
-
var import_react3, JSX, import_server, import_sucrase, DRAW_MS, MAX_FILES, CODE_EXTS, REQUIRES, NOTHING, NEXT_LINK, NEXT_IMAGE, NEXT_NAVIGATION, PACKAGES
|
|
107566
|
+
var import_react3, JSX, import_server, import_sucrase, DRAW_MS, MAX_FILES, CODE_EXTS, REQUIRES, NOTHING, NEXT_LINK, NEXT_IMAGE, NEXT_NAVIGATION, PACKAGES;
|
|
107031
107567
|
var init_draw_mockup = __esm({
|
|
107032
107568
|
"src/lib/draw-mockup.ts"() {
|
|
107033
107569
|
"use strict";
|
|
@@ -107037,6 +107573,7 @@ var init_draw_mockup = __esm({
|
|
|
107037
107573
|
import_sucrase = __toESM(require_dist2(), 1);
|
|
107038
107574
|
init_lib();
|
|
107039
107575
|
init_tailwindcss();
|
|
107576
|
+
init_dress_page();
|
|
107040
107577
|
DRAW_MS = 5e3;
|
|
107041
107578
|
MAX_FILES = 60;
|
|
107042
107579
|
CODE_EXTS = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
|
|
@@ -107079,14 +107616,12 @@ var init_draw_mockup = __esm({
|
|
|
107079
107616
|
"tailwind-merge": () => Promise.resolve().then(() => (init_bundle_mjs(), bundle_mjs_exports)),
|
|
107080
107617
|
"class-variance-authority": () => Promise.resolve().then(() => (init_dist(), dist_exports))
|
|
107081
107618
|
};
|
|
107082
|
-
CSP = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data:; media-src data:; font-src data:; worker-src 'none'; base-uri 'none'; form-action 'none'";
|
|
107083
|
-
head = `<meta http-equiv="Content-Security-Policy" content="${CSP}"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html{overflow-x:hidden;overscroll-behavior:contain}</style>`;
|
|
107084
107619
|
}
|
|
107085
107620
|
});
|
|
107086
107621
|
|
|
107087
107622
|
// src/lib/preview-validation.ts
|
|
107088
|
-
import
|
|
107089
|
-
import
|
|
107623
|
+
import fs83 from "node:fs";
|
|
107624
|
+
import path85 from "node:path";
|
|
107090
107625
|
function renderError(error) {
|
|
107091
107626
|
if (!error || typeof error !== "object") return String(error);
|
|
107092
107627
|
const { message, stack } = error;
|
|
@@ -107097,7 +107632,7 @@ function renderError(error) {
|
|
|
107097
107632
|
async function validateScreens(files2) {
|
|
107098
107633
|
const errors = [];
|
|
107099
107634
|
const entries = /* @__PURE__ */ new Map();
|
|
107100
|
-
for (const file of files2) entries.set(
|
|
107635
|
+
for (const file of files2) entries.set(fs83.existsSync(file) ? fs83.realpathSync(file) : path85.resolve(file), path85.resolve(file));
|
|
107101
107636
|
for (const file of entries.values()) {
|
|
107102
107637
|
try {
|
|
107103
107638
|
await drawMockup(file);
|
|
@@ -107116,7 +107651,7 @@ async function validatePreview(file, text5) {
|
|
|
107116
107651
|
if (/^ {0,3}<!--\s*agent\s*-->\s*$/.test(line)) own = false;
|
|
107117
107652
|
if (own) section.push(line);
|
|
107118
107653
|
}
|
|
107119
|
-
const files2 = bodySources(section.join("\n")).filter((src) => !/^[a-z][\w+.-]*:|^#|^\/\//i.test(src) &&
|
|
107654
|
+
const files2 = bodySources(section.join("\n")).filter((src) => !/^[a-z][\w+.-]*:|^#|^\/\//i.test(src) && kindOf(path85.extname(src).toLowerCase()) === "html").map((src) => src.startsWith(".assets/") ? path85.join(ASSETS, src.slice(8)) : src.startsWith(".mockups/") ? path85.join(MOCKUPS, src.slice(9)) : path85.resolve(path85.dirname(file), src));
|
|
107120
107655
|
return validateScreens(files2);
|
|
107121
107656
|
}
|
|
107122
107657
|
var init_preview_validation = __esm({
|
|
@@ -107273,7 +107808,7 @@ __export(watch_exports, {
|
|
|
107273
107808
|
watchRun: () => watchRun
|
|
107274
107809
|
});
|
|
107275
107810
|
import { spawn as spawn4 } from "node:child_process";
|
|
107276
|
-
import
|
|
107811
|
+
import fs84 from "node:fs";
|
|
107277
107812
|
async function watchRun(sessionId, resume = startResume) {
|
|
107278
107813
|
const spec = readSpec(sessionId);
|
|
107279
107814
|
const run3 = peekRun(sessionId);
|
|
@@ -107309,11 +107844,11 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
107309
107844
|
const record = claimed ?? run3;
|
|
107310
107845
|
const sub = record.action === "sub";
|
|
107311
107846
|
if (claim) await setCardStatus(claim.cardId, claim.status);
|
|
107312
|
-
|
|
107313
|
-
const logFile =
|
|
107847
|
+
fs84.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
107848
|
+
const logFile = fs84.createWriteStream(record.logPath, { flags: "a" });
|
|
107314
107849
|
logFile.on("error", () => {
|
|
107315
107850
|
});
|
|
107316
|
-
const eventsFile =
|
|
107851
|
+
const eventsFile = fs84.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
|
|
107317
107852
|
eventsFile.on("error", () => {
|
|
107318
107853
|
});
|
|
107319
107854
|
const event2 = (e2) => eventsFile.write(`${JSON.stringify(e2)}
|
|
@@ -107792,8 +108327,8 @@ function brokeBoard(wasBroken) {
|
|
|
107792
108327
|
if (!broke.length) return null;
|
|
107793
108328
|
const shown = broke.slice(0, MAX_BROKEN);
|
|
107794
108329
|
const rest = broke.length - shown.length;
|
|
107795
|
-
const
|
|
107796
|
-
return { why, note: [
|
|
108330
|
+
const why2 = { kind: "broken", args: { n: String(broke.length), more: String(rest) }, lines: shown };
|
|
108331
|
+
return { why: why2, note: [
|
|
107797
108332
|
`the work is done, but the board came out of this run inconsistent \u2014 ${broke.length} thing${broke.length === 1 ? "" : "s"} to put right:`,
|
|
107798
108333
|
...shown.map((line) => ` ${line}`),
|
|
107799
108334
|
...rest ? [` \u2026 and ${rest} more`] : [],
|
|
@@ -107907,7 +108442,7 @@ var init_watch = __esm({
|
|
|
107907
108442
|
});
|
|
107908
108443
|
|
|
107909
108444
|
// src/kanban.ts
|
|
107910
|
-
import
|
|
108445
|
+
import fs90 from "node:fs";
|
|
107911
108446
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
107912
108447
|
|
|
107913
108448
|
// src/lib/cli/agent.ts
|
|
@@ -108390,8 +108925,8 @@ async function testAgent(args) {
|
|
|
108390
108925
|
}
|
|
108391
108926
|
|
|
108392
108927
|
// src/commands/cloud.ts
|
|
108393
|
-
import
|
|
108394
|
-
import
|
|
108928
|
+
import fs72 from "node:fs";
|
|
108929
|
+
import path73 from "node:path";
|
|
108395
108930
|
|
|
108396
108931
|
// src/lib/cloud/avatar.ts
|
|
108397
108932
|
init_session();
|
|
@@ -108439,13 +108974,13 @@ init_config();
|
|
|
108439
108974
|
init_home();
|
|
108440
108975
|
init_config();
|
|
108441
108976
|
init_session();
|
|
108442
|
-
import
|
|
108443
|
-
import
|
|
108977
|
+
import fs71 from "node:fs";
|
|
108978
|
+
import path72 from "node:path";
|
|
108444
108979
|
var FRESH_MS2 = 10 * 6e4;
|
|
108445
108980
|
var GRACE_MS = 7 * 24 * 60 * 6e4;
|
|
108446
|
-
var heldFile = () =>
|
|
108981
|
+
var heldFile = () => path72.join(machineHome(), "pro.json");
|
|
108447
108982
|
function forgetPro() {
|
|
108448
|
-
|
|
108983
|
+
fs71.rmSync(heldFile(), { force: true });
|
|
108449
108984
|
}
|
|
108450
108985
|
|
|
108451
108986
|
// src/lib/cloud/account.ts
|
|
@@ -108622,10 +109157,10 @@ async function cloudImage(opts, program2) {
|
|
|
108622
109157
|
const prompt = opts.prompt.trim();
|
|
108623
109158
|
if (!prompt) usage("Missing the prompt.", line);
|
|
108624
109159
|
const references = opts.refs.map((file) => {
|
|
108625
|
-
const type = REF_TYPES[
|
|
109160
|
+
const type = REF_TYPES[path73.extname(file).toLowerCase()];
|
|
108626
109161
|
if (!type) usage(`--ref ${file}: use a PNG, JPEG or WebP file.`, line);
|
|
108627
109162
|
try {
|
|
108628
|
-
return `data:${type};base64,${
|
|
109163
|
+
return `data:${type};base64,${fs72.readFileSync(file).toString("base64")}`;
|
|
108629
109164
|
} catch (e2) {
|
|
108630
109165
|
usage(`--ref ${file}: ${e2 instanceof Error ? e2.message : String(e2)}`, line);
|
|
108631
109166
|
}
|
|
@@ -108731,8 +109266,8 @@ async function generate(g3) {
|
|
|
108731
109266
|
refuse(g3.failed, g3.fallback);
|
|
108732
109267
|
}
|
|
108733
109268
|
const out = g3.outFor?.(res, g3.out) ?? g3.out;
|
|
108734
|
-
|
|
108735
|
-
|
|
109269
|
+
fs72.mkdirSync(path73.dirname(path73.resolve(out)), { recursive: true });
|
|
109270
|
+
fs72.writeFileSync(out, Buffer.from(await res.arrayBuffer()));
|
|
108736
109271
|
say(`${out} (${g3.label(res)})`);
|
|
108737
109272
|
return { out };
|
|
108738
109273
|
}
|
|
@@ -108741,35 +109276,35 @@ async function generate(g3) {
|
|
|
108741
109276
|
init_board_files();
|
|
108742
109277
|
init_workflow_files();
|
|
108743
109278
|
import crypto6 from "node:crypto";
|
|
108744
|
-
import
|
|
108745
|
-
import
|
|
109279
|
+
import fs74 from "node:fs";
|
|
109280
|
+
import path75 from "node:path";
|
|
108746
109281
|
|
|
108747
109282
|
// src/lib/agents/shared-memory.ts
|
|
108748
109283
|
init_bundled();
|
|
108749
109284
|
init_parse();
|
|
108750
|
-
import
|
|
108751
|
-
import
|
|
109285
|
+
import fs73 from "node:fs";
|
|
109286
|
+
import path74 from "node:path";
|
|
108752
109287
|
function sharedMemory(board2) {
|
|
108753
109288
|
const declared = /* @__PURE__ */ new Map();
|
|
108754
109289
|
const take = (folder, text5, builtIn) => {
|
|
108755
109290
|
if (text5 === null || declared.has(folder)) return;
|
|
108756
|
-
const
|
|
108757
|
-
if ("agent" in
|
|
109291
|
+
const read5 = parseSpecAgent(text5, folder, () => null, builtIn);
|
|
109292
|
+
if ("agent" in read5 && read5.agent.name === folder) declared.set(folder, read5.agent.memoryFiles.workspace);
|
|
108758
109293
|
};
|
|
108759
109294
|
for (const [key, text5] of Object.entries(shippedAgentFiles())) {
|
|
108760
109295
|
const at2 = /^([^/]+)\/AGENT\.md$/.exec(key);
|
|
108761
109296
|
if (at2) take(at2[1], text5, officialAgent(at2[1]));
|
|
108762
109297
|
}
|
|
108763
|
-
const root2 =
|
|
109298
|
+
const root2 = path74.join(board2, "agents");
|
|
108764
109299
|
let folders2 = [];
|
|
108765
109300
|
try {
|
|
108766
|
-
folders2 =
|
|
109301
|
+
folders2 = fs73.readdirSync(root2, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).map((e2) => e2.name);
|
|
108767
109302
|
} catch {
|
|
108768
109303
|
}
|
|
108769
109304
|
for (const folder of folders2.sort()) {
|
|
108770
109305
|
let text5 = null;
|
|
108771
109306
|
try {
|
|
108772
|
-
text5 =
|
|
109307
|
+
text5 = fs73.readFileSync(path74.join(root2, folder, "AGENT.md"), "utf8");
|
|
108773
109308
|
} catch {
|
|
108774
109309
|
}
|
|
108775
109310
|
take(folder, text5, false);
|
|
@@ -108859,27 +109394,27 @@ async function findProject(asked) {
|
|
|
108859
109394
|
}
|
|
108860
109395
|
throw new Refused(`No project of yours has the id or prefix "${asked}".`, "not_found");
|
|
108861
109396
|
}
|
|
108862
|
-
var
|
|
109397
|
+
var read2 = (file) => fs74.readFileSync(file, "utf8");
|
|
108863
109398
|
var bytes2 = (text5) => Buffer.byteLength(text5, "utf8");
|
|
108864
109399
|
function files(dir) {
|
|
108865
|
-
if (!
|
|
109400
|
+
if (!fs74.existsSync(dir)) return [];
|
|
108866
109401
|
const out = [];
|
|
108867
|
-
for (const entry of
|
|
109402
|
+
for (const entry of fs74.readdirSync(dir, { withFileTypes: true })) {
|
|
108868
109403
|
if (entry.name.startsWith(".")) continue;
|
|
108869
|
-
const full =
|
|
109404
|
+
const full = path75.join(dir, entry.name);
|
|
108870
109405
|
if (entry.isDirectory()) out.push(...files(full));
|
|
108871
109406
|
else if (entry.isFile()) out.push(full);
|
|
108872
109407
|
}
|
|
108873
109408
|
return out;
|
|
108874
109409
|
}
|
|
108875
|
-
var posix = (p2) => p2.split(
|
|
109410
|
+
var posix = (p2) => p2.split(path75.sep).join("/");
|
|
108876
109411
|
function openCards() {
|
|
108877
109412
|
const out = [];
|
|
108878
109413
|
for (const file of walkMd(TODO)) {
|
|
108879
|
-
const rel2 = posix(
|
|
109414
|
+
const rel2 = posix(path75.relative(TODO, file));
|
|
108880
109415
|
if (rel2 === "README.md") continue;
|
|
108881
109416
|
const parts = rel2.split("/");
|
|
108882
|
-
const text5 =
|
|
109417
|
+
const text5 = read2(file);
|
|
108883
109418
|
const meta = parseFrontmatter(text5).meta;
|
|
108884
109419
|
if (!meta) continue;
|
|
108885
109420
|
const name = parts[parts.length - 1];
|
|
@@ -108963,12 +109498,12 @@ function draftsOf(text5) {
|
|
|
108963
109498
|
const at2 = /^\.(assets|mockups)\/(.+)$/.exec(name);
|
|
108964
109499
|
if (!at2) continue;
|
|
108965
109500
|
const base = at2[1] === "assets" ? ASSETS : MOCKUPS;
|
|
108966
|
-
const file =
|
|
108967
|
-
if (file.startsWith(base +
|
|
109501
|
+
const file = path75.resolve(base, at2[2]);
|
|
109502
|
+
if (file.startsWith(base + path75.sep) && fs74.statSync(file, { throwIfNoEntry: false })?.isFile()) out.set(name, file);
|
|
108968
109503
|
}
|
|
108969
109504
|
return [...out].map(([name, file]) => ({ name, file }));
|
|
108970
109505
|
}
|
|
108971
|
-
var
|
|
109506
|
+
var TYPES2 = {
|
|
108972
109507
|
".png": "image/png",
|
|
108973
109508
|
".jpg": "image/jpeg",
|
|
108974
109509
|
".jpeg": "image/jpeg",
|
|
@@ -108985,10 +109520,10 @@ var TYPES = {
|
|
|
108985
109520
|
".wav": "audio/wav",
|
|
108986
109521
|
".json": "application/json"
|
|
108987
109522
|
};
|
|
108988
|
-
function
|
|
109523
|
+
function kindOf2(ext) {
|
|
108989
109524
|
if (ext === ".html") return "html";
|
|
108990
109525
|
if (ext === ".md" || ext === ".mdx") return "markdown";
|
|
108991
|
-
const type =
|
|
109526
|
+
const type = TYPES2[ext] ?? "";
|
|
108992
109527
|
if (type.startsWith("image/")) return "image";
|
|
108993
109528
|
return type.startsWith("video/") || type.startsWith("audio/") ? "video" : "asset";
|
|
108994
109529
|
}
|
|
@@ -108998,10 +109533,10 @@ async function uploadDrafts(task, drafts) {
|
|
|
108998
109533
|
const assets = {};
|
|
108999
109534
|
for (const { name, file } of drafts) {
|
|
109000
109535
|
if (!card.body.includes(name)) continue;
|
|
109001
|
-
const ext =
|
|
109002
|
-
const type =
|
|
109003
|
-
const data =
|
|
109004
|
-
const artifact = await api("POST", `/v1/tasks/${task}/artifacts`, { type:
|
|
109536
|
+
const ext = path75.extname(file).toLowerCase();
|
|
109537
|
+
const type = TYPES2[ext] ?? "application/octet-stream";
|
|
109538
|
+
const data = fs74.readFileSync(file);
|
|
109539
|
+
const artifact = await api("POST", `/v1/tasks/${task}/artifacts`, { type: kindOf2(ext), name: name.slice(0, 200) });
|
|
109005
109540
|
const upload = await api("POST", `/v1/artifacts/${artifact.id}/uploads`, { content_type: type, size: Math.max(data.length, 1) });
|
|
109006
109541
|
await api("PUT", `/v1/uploads/${upload.id}`, void 0, { bytes: data, type });
|
|
109007
109542
|
const version = await api("POST", `/v1/artifacts/${artifact.id}/versions`, { upload: upload.id });
|
|
@@ -109043,7 +109578,7 @@ usage: ${program2} cloud import --project <id or prefix> [--dry-run]`, { kind: "
|
|
|
109043
109578
|
function localWorkflowFolders() {
|
|
109044
109579
|
let folders2;
|
|
109045
109580
|
try {
|
|
109046
|
-
folders2 =
|
|
109581
|
+
folders2 = fs74.readdirSync(WORKFLOWS, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".") && !e2.name.startsWith("task-")).map((e2) => e2.name).sort((a2, b2) => a2.localeCompare(b2, "en", { numeric: true }));
|
|
109047
109582
|
} catch {
|
|
109048
109583
|
return [];
|
|
109049
109584
|
}
|
|
@@ -109054,19 +109589,19 @@ function localWorkflowFolders() {
|
|
|
109054
109589
|
});
|
|
109055
109590
|
}
|
|
109056
109591
|
function filesUnder(dir, base = dir) {
|
|
109057
|
-
return
|
|
109058
|
-
const full =
|
|
109059
|
-
return e2.isDirectory() ? filesUnder(full, base) : [posix(
|
|
109592
|
+
return fs74.readdirSync(dir, { withFileTypes: true }).flatMap((e2) => {
|
|
109593
|
+
const full = path75.join(dir, e2.name);
|
|
109594
|
+
return e2.isDirectory() ? filesUnder(full, base) : [posix(path75.relative(base, full))];
|
|
109060
109595
|
});
|
|
109061
109596
|
}
|
|
109062
109597
|
function packLocalWorkflow(id, def, shipped) {
|
|
109063
|
-
const dir =
|
|
109064
|
-
const out = Object.fromEntries(filesUnder(dir).map((f2) => [f2,
|
|
109598
|
+
const dir = path75.join(WORKFLOWS, id);
|
|
109599
|
+
const out = Object.fromEntries(filesUnder(dir).map((f2) => [f2, fs74.readFileSync(path75.join(dir, f2), "utf8")]));
|
|
109065
109600
|
const named2 = [...def.previews, ...def.land, ...def.scheduled].map((h3) => h3.agent).filter((a2) => !LAND_ROLES2.includes(a2));
|
|
109066
109601
|
for (const agent of new Set(named2)) {
|
|
109067
|
-
const at2 =
|
|
109068
|
-
if (
|
|
109069
|
-
for (const file of filesUnder(at2)) out[`agents/${agent}/${file}`] =
|
|
109602
|
+
const at2 = path75.join(AGENTS, agent);
|
|
109603
|
+
if (fs74.existsSync(path75.join(at2, "AGENT.md"))) {
|
|
109604
|
+
for (const file of filesUnder(at2)) out[`agents/${agent}/${file}`] = fs74.readFileSync(path75.join(at2, file), "utf8");
|
|
109070
109605
|
continue;
|
|
109071
109606
|
}
|
|
109072
109607
|
for (const [key, text5] of Object.entries(shipped)) if (key.startsWith(`${agent}/`)) out[`agents/${key}`] = text5;
|
|
@@ -109076,10 +109611,10 @@ function packLocalWorkflow(id, def, shipped) {
|
|
|
109076
109611
|
async function run(asked, dryRun) {
|
|
109077
109612
|
const project = await findProject(asked);
|
|
109078
109613
|
const cloudFlows2 = await all(`/v1/workflows?workspace=${encodeURIComponent(project.workspace)}`);
|
|
109079
|
-
const board2 = crypto6.createHash("sha256").update(
|
|
109614
|
+
const board2 = crypto6.createHash("sha256").update(fs74.realpathSync(KANBAN)).digest("hex").slice(0, 16);
|
|
109080
109615
|
const cards = openCards();
|
|
109081
109616
|
const problems = [];
|
|
109082
|
-
const where = (file) => posix(
|
|
109617
|
+
const where = (file) => posix(path75.relative(KANBAN, file));
|
|
109083
109618
|
const own = [];
|
|
109084
109619
|
for (const f2 of localWorkflowFolders()) {
|
|
109085
109620
|
if (f2.def) own.push({ id: f2.id, name: f2.def.name, def: f2.def });
|
|
@@ -109108,10 +109643,10 @@ async function run(asked, dryRun) {
|
|
|
109108
109643
|
const root2 = `projects/${project.id}/`;
|
|
109109
109644
|
const boardFiles = [];
|
|
109110
109645
|
for (const file of [...files(MEMORY), ...files(RULES), CONFIG, MODULES_MD]) {
|
|
109111
|
-
if (!
|
|
109646
|
+
if (!fs74.existsSync(file)) continue;
|
|
109112
109647
|
const rel2 = where(file);
|
|
109113
109648
|
if (!isBoardPath(rel2)) continue;
|
|
109114
|
-
const content =
|
|
109649
|
+
const content = read2(file);
|
|
109115
109650
|
if (bytes2(content) > BOARD_FILE_LIMIT) {
|
|
109116
109651
|
problems.push({ file: rel2, reason: { zh: "\u8D85\u8FC7 256 KB", en: "over 256 KB" } });
|
|
109117
109652
|
continue;
|
|
@@ -109219,16 +109754,16 @@ async function run(asked, dryRun) {
|
|
|
109219
109754
|
}
|
|
109220
109755
|
function leftLocal(own) {
|
|
109221
109756
|
const out = [];
|
|
109222
|
-
const count4 = (dir) =>
|
|
109757
|
+
const count4 = (dir) => fs74.existsSync(dir) ? walkMd(dir).length : 0;
|
|
109223
109758
|
const archived = count4(ARCHIVE);
|
|
109224
109759
|
if (archived) out.push(`.archive/ (${archived})`);
|
|
109225
109760
|
const triage = count4(TRIAGE);
|
|
109226
109761
|
if (triage) out.push(`triage/ (${triage})`);
|
|
109227
|
-
if (
|
|
109228
|
-
if (
|
|
109762
|
+
if (fs74.existsSync(DELIVERIES)) out.push("deliveries/");
|
|
109763
|
+
if (fs74.existsSync(path75.join(KANBAN, "metrics.csv"))) out.push("metrics.csv");
|
|
109229
109764
|
const named2 = new Set(own.flatMap((w2) => [...w2.def.previews, ...w2.def.land, ...w2.def.scheduled].map((h3) => h3.agent)));
|
|
109230
|
-
if (
|
|
109231
|
-
for (const e2 of
|
|
109765
|
+
if (fs74.existsSync(AGENTS)) {
|
|
109766
|
+
for (const e2 of fs74.readdirSync(AGENTS, { withFileTypes: true })) {
|
|
109232
109767
|
if (e2.isDirectory() && !e2.name.startsWith(".") && !named2.has(e2.name)) out.push(`agents/${e2.name}/`);
|
|
109233
109768
|
}
|
|
109234
109769
|
}
|
|
@@ -109246,8 +109781,8 @@ init_session();
|
|
|
109246
109781
|
init_io();
|
|
109247
109782
|
init_paths();
|
|
109248
109783
|
import { createHash as createHash5 } from "node:crypto";
|
|
109249
|
-
import
|
|
109250
|
-
import
|
|
109784
|
+
import fs75 from "node:fs";
|
|
109785
|
+
import path76 from "node:path";
|
|
109251
109786
|
var SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
109252
109787
|
var CAPTURED = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})$/;
|
|
109253
109788
|
var MAX_BYTES3 = 50 * 1024 * 1024;
|
|
@@ -109346,10 +109881,10 @@ This template has no preview.`);
|
|
|
109346
109881
|
const written = [];
|
|
109347
109882
|
for (const p2 of previews) {
|
|
109348
109883
|
const bytes3 = Buffer.from(await (await ask(`/${at2}/previews/${route(p2.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
109349
|
-
const file =
|
|
109350
|
-
const out =
|
|
109351
|
-
|
|
109352
|
-
|
|
109884
|
+
const file = path76.basename(p2.path);
|
|
109885
|
+
const out = path76.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
|
|
109886
|
+
fs75.mkdirSync(opts.to, { recursive: true });
|
|
109887
|
+
fs75.writeFileSync(out, bytes3);
|
|
109353
109888
|
written.push(out);
|
|
109354
109889
|
say(out);
|
|
109355
109890
|
}
|
|
@@ -109362,15 +109897,15 @@ async function templateGet(name, opts, program2) {
|
|
|
109362
109897
|
const { template } = await asJson(await ask(`/${at2}`, {}, WITHOUT));
|
|
109363
109898
|
const fetched = [];
|
|
109364
109899
|
for (const f2 of template.files) {
|
|
109365
|
-
const out =
|
|
109366
|
-
if (!out.startsWith(
|
|
109900
|
+
const out = path76.resolve(to, f2.path);
|
|
109901
|
+
if (!out.startsWith(path76.resolve(to) + path76.sep)) refuse2(T.corrupt, WITHOUT);
|
|
109367
109902
|
const bytes3 = Buffer.from(await (await ask(`/${at2}/files/${route(f2.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
109368
109903
|
if (bytes3.byteLength !== f2.size || createHash5("sha256").update(bytes3).digest("hex") !== f2.sha256) {
|
|
109369
109904
|
refuse2(T.corrupt, WITHOUT);
|
|
109370
109905
|
}
|
|
109371
109906
|
fetched.push({ out, bytes: bytes3 });
|
|
109372
109907
|
}
|
|
109373
|
-
const taken = fetched.filter((f2) =>
|
|
109908
|
+
const taken = fetched.filter((f2) => fs75.existsSync(f2.out)).map((f2) => path76.relative(to, f2.out));
|
|
109374
109909
|
if (taken.length > 0) {
|
|
109375
109910
|
refuse2({
|
|
109376
109911
|
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`,
|
|
@@ -109378,8 +109913,8 @@ async function templateGet(name, opts, program2) {
|
|
|
109378
109913
|
});
|
|
109379
109914
|
}
|
|
109380
109915
|
for (const f2 of fetched) {
|
|
109381
|
-
|
|
109382
|
-
|
|
109916
|
+
fs75.mkdirSync(path76.dirname(f2.out), { recursive: true });
|
|
109917
|
+
fs75.writeFileSync(f2.out, f2.bytes);
|
|
109383
109918
|
}
|
|
109384
109919
|
say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
|
|
109385
109920
|
Fetched ${name}: ${fetched.length} files into ${to}`);
|
|
@@ -109397,25 +109932,25 @@ async function templateSource(name, opts) {
|
|
|
109397
109932
|
say(`evidence: ${e2.path}`);
|
|
109398
109933
|
continue;
|
|
109399
109934
|
}
|
|
109400
|
-
const out =
|
|
109401
|
-
|
|
109402
|
-
|
|
109935
|
+
const out = path76.join(opts.to, `${name}-${path76.basename(e2.path)}`);
|
|
109936
|
+
fs75.mkdirSync(opts.to, { recursive: true });
|
|
109937
|
+
fs75.writeFileSync(out, Buffer.from(await (await ask(`/${at2}/evidence/${route(e2.path)}`)).arrayBuffer()));
|
|
109403
109938
|
written.push(out);
|
|
109404
109939
|
say(out);
|
|
109405
109940
|
}
|
|
109406
109941
|
return { name, source, evidence: written.length > 0 ? written : evidence.map((e2) => e2.path) };
|
|
109407
109942
|
}
|
|
109408
109943
|
async function templatePublish(dir, opts) {
|
|
109409
|
-
const root2 =
|
|
109410
|
-
const manifest =
|
|
109411
|
-
if (!
|
|
109412
|
-
const meta = readTemplateMeta(
|
|
109944
|
+
const root2 = path76.resolve(dir);
|
|
109945
|
+
const manifest = path76.join(root2, "template.md");
|
|
109946
|
+
if (!fs75.existsSync(manifest)) invalid("\u6587\u4EF6\u5939\u9876\u5C42\u7F3A\u5C11 template.md\u3002", "template.md is missing from the folder\u2019s top level.");
|
|
109947
|
+
const meta = readTemplateMeta(fs75.readFileSync(manifest, "utf8"));
|
|
109413
109948
|
const files2 = walk2(root2);
|
|
109414
|
-
const total = files2.reduce((sum, f2) => sum +
|
|
109949
|
+
const total = files2.reduce((sum, f2) => sum + fs75.statSync(path76.join(root2, f2)).size, 0);
|
|
109415
109950
|
if (total > MAX_BYTES3) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
|
|
109416
109951
|
for (const extra of [...opts.preview, ...opts.evidence]) {
|
|
109417
|
-
if (!
|
|
109418
|
-
if (
|
|
109952
|
+
if (!fs75.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
|
|
109953
|
+
if (path76.resolve(extra).startsWith(root2 + path76.sep)) {
|
|
109419
109954
|
invalid(
|
|
109420
109955
|
`${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`,
|
|
109421
109956
|
`${extra} is inside the template folder; keep previews and evidence outside it.`
|
|
@@ -109427,10 +109962,10 @@ async function templatePublish(dir, opts) {
|
|
|
109427
109962
|
}
|
|
109428
109963
|
const form = new FormData();
|
|
109429
109964
|
form.set("meta", JSON.stringify({ ...meta, replace: !!opts.replace }));
|
|
109430
|
-
const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([
|
|
109431
|
-
for (const f2 of files2) add("files", f2,
|
|
109432
|
-
for (const f2 of opts.preview) add("previews",
|
|
109433
|
-
for (const f2 of opts.evidence) add("evidence",
|
|
109965
|
+
const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs75.readFileSync(file)]), path76.basename(name));
|
|
109966
|
+
for (const f2 of files2) add("files", f2, path76.join(root2, f2));
|
|
109967
|
+
for (const f2 of opts.preview) add("previews", path76.basename(f2), f2);
|
|
109968
|
+
for (const f2 of opts.evidence) add("evidence", path76.basename(f2), f2);
|
|
109434
109969
|
const done2 = await asJson(await ask("", { method: "POST", body: form }));
|
|
109435
109970
|
say(
|
|
109436
109971
|
done2.replaced ? `\u5DF2\u66FF\u6362 ${done2.name}\uFF1A${files2.length} \u4E2A\u6587\u4EF6\u3002
|
|
@@ -109446,11 +109981,11 @@ Deleted ${name} from the catalog.`);
|
|
|
109446
109981
|
return { name, deleted: true };
|
|
109447
109982
|
}
|
|
109448
109983
|
async function templateShowcase(name, dir) {
|
|
109449
|
-
const file =
|
|
109450
|
-
if (!
|
|
109984
|
+
const file = path76.join(dir, "showcase.json");
|
|
109985
|
+
if (!fs75.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
|
|
109451
109986
|
let meta;
|
|
109452
109987
|
try {
|
|
109453
|
-
meta = JSON.parse(
|
|
109988
|
+
meta = JSON.parse(fs75.readFileSync(file, "utf8"));
|
|
109454
109989
|
} catch {
|
|
109455
109990
|
return invalid("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
|
|
109456
109991
|
}
|
|
@@ -109462,9 +109997,9 @@ async function templateShowcase(name, dir) {
|
|
|
109462
109997
|
const form = new FormData();
|
|
109463
109998
|
form.set("meta", JSON.stringify(meta));
|
|
109464
109999
|
for (const p2 of new Set(named2)) {
|
|
109465
|
-
const at2 =
|
|
109466
|
-
if (!
|
|
109467
|
-
form.append(`media:${p2}`, new Blob([
|
|
110000
|
+
const at2 = path76.join(dir, p2);
|
|
110001
|
+
if (!fs75.existsSync(at2)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at2}\u3002`, `${at2} does not exist.`);
|
|
110002
|
+
form.append(`media:${p2}`, new Blob([fs75.readFileSync(at2)]), p2);
|
|
109468
110003
|
}
|
|
109469
110004
|
const done2 = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
|
|
109470
110005
|
say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done2.files} \u4E2A\u6587\u4EF6\u3002
|
|
@@ -109473,7 +110008,7 @@ Updated ${name}'s showcase: ${done2.files} files.`);
|
|
|
109473
110008
|
}
|
|
109474
110009
|
function walk2(root2, sub = "") {
|
|
109475
110010
|
const out = [];
|
|
109476
|
-
for (const entry of
|
|
110011
|
+
for (const entry of fs75.readdirSync(path76.join(root2, sub), { withFileTypes: true })) {
|
|
109477
110012
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
109478
110013
|
const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
|
|
109479
110014
|
if (entry.isDirectory()) out.push(...walk2(root2, rel2));
|
|
@@ -109623,10 +110158,15 @@ function cmdGuide(topic, program2 = "akb") {
|
|
|
109623
110158
|
}
|
|
109624
110159
|
|
|
109625
110160
|
// src/commands/workflow.ts
|
|
110161
|
+
init_agents();
|
|
110162
|
+
init_cards();
|
|
109626
110163
|
init_io();
|
|
109627
110164
|
init_paths();
|
|
110165
|
+
init_workflow_diagram();
|
|
109628
110166
|
init_cloud_workflows();
|
|
109629
110167
|
init_workflows();
|
|
110168
|
+
import fs76 from "node:fs";
|
|
110169
|
+
import path77 from "node:path";
|
|
109630
110170
|
var found = (id) => {
|
|
109631
110171
|
const flow = workflowById(id);
|
|
109632
110172
|
if (!flow) {
|
|
@@ -109686,6 +110226,22 @@ function cmdWorkflowRename(id, name) {
|
|
|
109686
110226
|
say(`renamed ${id} to "${name.trim()}"`);
|
|
109687
110227
|
return { id, name: name.trim() };
|
|
109688
110228
|
}
|
|
110229
|
+
function cmdWorkflowDiagram(id, card) {
|
|
110230
|
+
const flow = found(id);
|
|
110231
|
+
const cardId2 = Number(card);
|
|
110232
|
+
if (!Number.isInteger(cardId2) || !locate(cardId2)) die(`no card #${card} on this board`, "no-such-card");
|
|
110233
|
+
const diagram = workflowDiagram({ previews: previewMembers(flow), land: flow.land, scheduled: scheduledMembers(flow) }, (name) => {
|
|
110234
|
+
const agent = findSpecAgent(name);
|
|
110235
|
+
return agent ? { ...agent, after: agentAfter(name) } : null;
|
|
110236
|
+
});
|
|
110237
|
+
const file = path77.join(ASSETS, String(cardId2), "workflow.json");
|
|
110238
|
+
fs76.mkdirSync(path77.dirname(file), { recursive: true });
|
|
110239
|
+
fs76.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
|
|
110240
|
+
`);
|
|
110241
|
+
const tag = `<Workflow src=".assets/${cardId2}/workflow.json" label="${flow.name.replace(/"/g, "")}" />`;
|
|
110242
|
+
say(tag);
|
|
110243
|
+
return { file, tag, diagram };
|
|
110244
|
+
}
|
|
109689
110245
|
|
|
109690
110246
|
// src/commands/run.ts
|
|
109691
110247
|
init_progress();
|
|
@@ -109836,7 +110392,7 @@ init_opencode();
|
|
|
109836
110392
|
init_locate();
|
|
109837
110393
|
init_store();
|
|
109838
110394
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
109839
|
-
import
|
|
110395
|
+
import path83 from "node:path";
|
|
109840
110396
|
var AGENTS2 = {
|
|
109841
110397
|
claude: "claude-code",
|
|
109842
110398
|
codex: "codex",
|
|
@@ -109851,10 +110407,10 @@ var AGENTS2 = {
|
|
|
109851
110407
|
var RUNTIMES = /* @__PURE__ */ new Set(["node", "bun", "deno"]);
|
|
109852
110408
|
function agentOf2(args) {
|
|
109853
110409
|
const words = args.trim().split(/\s+/);
|
|
109854
|
-
const first =
|
|
110410
|
+
const first = path83.basename(words[0] ?? "");
|
|
109855
110411
|
const script = RUNTIMES.has(first) ? words[1] ?? "" : words[0] ?? "";
|
|
109856
110412
|
if (script.includes("/@anthropic-ai/claude-code/")) return "claude-code";
|
|
109857
|
-
return AGENTS2[
|
|
110413
|
+
return AGENTS2[path83.basename(script).replace(/\.(m?js|cjs|exe)$/, "")];
|
|
109858
110414
|
}
|
|
109859
110415
|
function processChain() {
|
|
109860
110416
|
if (process.platform === "win32") return [];
|
|
@@ -109918,8 +110474,8 @@ init_tasks();
|
|
|
109918
110474
|
init_read();
|
|
109919
110475
|
init_rules();
|
|
109920
110476
|
init_board();
|
|
109921
|
-
import
|
|
109922
|
-
import
|
|
110477
|
+
import fs85 from "node:fs";
|
|
110478
|
+
import path86 from "node:path";
|
|
109923
110479
|
var FOLLOW_MS = 400;
|
|
109924
110480
|
async function cmdStartRun(action, args, opts, program2 = "akb") {
|
|
109925
110481
|
const { req, follow: follow2, print } = readRequest(action, args, opts);
|
|
@@ -110006,8 +110562,8 @@ async function approveInCloud(project, id) {
|
|
|
110006
110562
|
say(`approved #${id} in Cloud`);
|
|
110007
110563
|
return { id, task: approved.value.key, approved: true };
|
|
110008
110564
|
}
|
|
110009
|
-
async function cmdReject(id,
|
|
110010
|
-
const reason =
|
|
110565
|
+
async function cmdReject(id, why2, opts) {
|
|
110566
|
+
const reason = why2.trim();
|
|
110011
110567
|
const discard = opts.discard === true;
|
|
110012
110568
|
if (!discard && !reason) die("say why the card is being dropped, or pass --discard to just drop it");
|
|
110013
110569
|
const res = await rejectCard(id, { reason, discard }, true);
|
|
@@ -110167,7 +110723,7 @@ async function cmdSubStart(words, opts) {
|
|
|
110167
110723
|
let prompt = words.join(" ");
|
|
110168
110724
|
if (opts.file) {
|
|
110169
110725
|
try {
|
|
110170
|
-
prompt =
|
|
110726
|
+
prompt = fs85.readFileSync(path86.resolve(opts.file), "utf8");
|
|
110171
110727
|
} catch {
|
|
110172
110728
|
die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
|
|
110173
110729
|
}
|
|
@@ -110458,7 +111014,7 @@ function cmdCompleteDelivery(id, options) {
|
|
|
110458
111014
|
// src/commands/triage.ts
|
|
110459
111015
|
init_scheduled();
|
|
110460
111016
|
init_workflows();
|
|
110461
|
-
import
|
|
111017
|
+
import fs87 from "node:fs";
|
|
110462
111018
|
|
|
110463
111019
|
// src/lib/signals/index.ts
|
|
110464
111020
|
init_cards();
|
|
@@ -110468,16 +111024,16 @@ init_yaml();
|
|
|
110468
111024
|
// src/lib/signals/config.ts
|
|
110469
111025
|
init_settings2();
|
|
110470
111026
|
init_paths();
|
|
110471
|
-
import
|
|
110472
|
-
import
|
|
111027
|
+
import fs86 from "node:fs";
|
|
111028
|
+
import path87 from "node:path";
|
|
110473
111029
|
var TOKEN_KEY = "TRIAGE_ENDPOINT_TOKEN";
|
|
110474
111030
|
var ENDPOINT_SETTING = "Triage endpoint";
|
|
110475
111031
|
var LINE2 = /^- \*\*Triage endpoint\*\*\s*[—-]\s*(.+)$/m;
|
|
110476
|
-
var boardRel3 = (file) => rel(file).split(
|
|
111032
|
+
var boardRel3 = (file) => rel(file).split(path87.sep).join("/");
|
|
110477
111033
|
function signalEndpoint() {
|
|
110478
111034
|
let text5;
|
|
110479
111035
|
try {
|
|
110480
|
-
text5 =
|
|
111036
|
+
text5 = fs86.readFileSync(CONFIG, "utf8");
|
|
110481
111037
|
} catch {
|
|
110482
111038
|
return "";
|
|
110483
111039
|
}
|
|
@@ -110521,7 +111077,7 @@ function readMeta(sent) {
|
|
|
110521
111077
|
}
|
|
110522
111078
|
return pairs;
|
|
110523
111079
|
}
|
|
110524
|
-
function
|
|
111080
|
+
function read3(raw) {
|
|
110525
111081
|
const missing = REQUIRED.filter((field2) => !text4(raw[field2]));
|
|
110526
111082
|
if (missing.length > 0) return { ok: false, why: `missing ${missing.join(", ")}` };
|
|
110527
111083
|
const sent = text4(raw.collected_at);
|
|
@@ -110571,8 +111127,8 @@ async function fetchSignals() {
|
|
|
110571
111127
|
});
|
|
110572
111128
|
} catch (e2) {
|
|
110573
111129
|
const late = e2 instanceof Error && (e2.name === "TimeoutError" || e2.name === "AbortError");
|
|
110574
|
-
const
|
|
110575
|
-
die(`${endpoint2} ${
|
|
111130
|
+
const why2 = late ? `did not answer within ${ANSWER_BY_MS2 / 1e3}s` : `could not be reached: ${e2 instanceof Error ? e2.message : String(e2)}`;
|
|
111131
|
+
die(`${endpoint2} ${why2}`, { kind: "triage-unreachable" });
|
|
110576
111132
|
}
|
|
110577
111133
|
if (!response.ok) {
|
|
110578
111134
|
die(`${endpoint2} answered ${response.status}.`, { kind: "triage-endpoint-refused" });
|
|
@@ -110597,7 +111153,7 @@ async function fetchSignals() {
|
|
|
110597
111153
|
report3.failed.push({ which: `item ${at2 + 1}`, why: "not an object" });
|
|
110598
111154
|
return;
|
|
110599
111155
|
}
|
|
110600
|
-
const found2 =
|
|
111156
|
+
const found2 = read3(raw);
|
|
110601
111157
|
if (!found2.ok) {
|
|
110602
111158
|
report3.failed.push({ which: text4(raw.source_id) || `item ${at2 + 1}`, why: found2.why });
|
|
110603
111159
|
return;
|
|
@@ -110653,7 +111209,7 @@ async function cmdTriageAdd(opts) {
|
|
|
110653
111209
|
let body = opts.text;
|
|
110654
111210
|
if (opts.file !== void 0) {
|
|
110655
111211
|
try {
|
|
110656
|
-
body =
|
|
111212
|
+
body = fs87.readFileSync(opts.file, "utf8");
|
|
110657
111213
|
} catch {
|
|
110658
111214
|
die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
|
|
110659
111215
|
}
|
|
@@ -110689,13 +111245,13 @@ function cmdTriageArchive(sourceId, cardId2) {
|
|
|
110689
111245
|
function cmdTriageDismiss(sourceId, reason) {
|
|
110690
111246
|
const said3 = sourceId.trim();
|
|
110691
111247
|
if (!said3) die('say which one: `dismiss <source-id> --reason "<why>"`', { kind: "needs-input" });
|
|
110692
|
-
const
|
|
110693
|
-
if (!
|
|
111248
|
+
const why2 = reason.trim();
|
|
111249
|
+
if (!why2) die('say why it is being ignored: --reason "<why>"', { kind: "needs-input" });
|
|
110694
111250
|
migrateTriage();
|
|
110695
|
-
const done2 = dismissInboxItem(said3, "agent",
|
|
111251
|
+
const done2 = dismissInboxItem(said3, "agent", why2);
|
|
110696
111252
|
if (!done2.ok) die(done2.error, { kind: "triage-item-gone" });
|
|
110697
111253
|
say(`${said3} \u2014 ignored: ${done2.relPath}`);
|
|
110698
|
-
return { source_id: said3, reason:
|
|
111254
|
+
return { source_id: said3, reason: why2, file: done2.relPath };
|
|
110699
111255
|
}
|
|
110700
111256
|
function cmdTriageRestore(sourceId) {
|
|
110701
111257
|
const said3 = sourceId.trim();
|
|
@@ -110905,8 +111461,8 @@ function declareRuns(program2, cli) {
|
|
|
110905
111461
|
};
|
|
110906
111462
|
for (const flow of FLOWS) declareFlow(flow.group ? groups[flow.group] : program2, flow, cli);
|
|
110907
111463
|
withShared(groups.card.command("reject")).argument("<id>", "the card's id", cardId).argument("[why...]", "why the card is being dropped \u2014 required unless --discard").summary("drop the card").option("--discard", "just drop it: the why may be left off, and nothing learns from it").action(async function(...vals) {
|
|
110908
|
-
const [id,
|
|
110909
|
-
await onBoard2(this, cli, () => cmdReject(id,
|
|
111464
|
+
const [id, why2] = positional(vals);
|
|
111465
|
+
await onBoard2(this, cli, () => cmdReject(id, why2.join(" "), this.opts()));
|
|
110910
111466
|
});
|
|
110911
111467
|
declareRunning(groups.run, cli);
|
|
110912
111468
|
declareDelivery(groups.delivery, cli);
|
|
@@ -111050,6 +111606,9 @@ List trigger conditions: ${cli.program} previews --triggers --json`).action(asyn
|
|
|
111050
111606
|
flowWord("rename").argument("<id>", "the draft, from `workflow list`").argument("<name...>", "what to call it now").summary("rename the Workflow builder draft. Only inside that task's run.").action(async function(id, name) {
|
|
111051
111607
|
await onBoard2(this, cli, () => cmdWorkflowRename(id, name.join(" ")));
|
|
111052
111608
|
});
|
|
111609
|
+
flowWord("diagram").argument("<id>", "the workflow, from `workflow list`").argument("<card>", "the card whose asset folder gets workflow.json").summary("write the workflow's diagram to .assets/<card>/workflow.json and print the <Workflow> tag that shows it").action(async function(id, card) {
|
|
111610
|
+
await onBoard2(this, cli, () => cmdWorkflowDiagram(id, card));
|
|
111611
|
+
});
|
|
111053
111612
|
withShared(program2.command("components")).summary("list an agent or workflow\u2019s preview components and their usage").option("--agent <name>", "one agent\u2019s components").option("--workflow <id>", "all components used by a workflow").option("--docs", "include component usage documentation").action(async function() {
|
|
111054
111613
|
const ctx = ctxOf(this, cli.program);
|
|
111055
111614
|
useBoard(resolveBoard("components", { board: ctx.board, dir: ctx.dir, cwd: cli.cwd, installHint: cli.installHint }), ctx.dir !== null);
|
|
@@ -111226,8 +111785,8 @@ function declareAgent(program2, cli) {
|
|
|
111226
111785
|
}
|
|
111227
111786
|
|
|
111228
111787
|
// src/lib/cli/setup.ts
|
|
111229
|
-
import
|
|
111230
|
-
import
|
|
111788
|
+
import fs89 from "node:fs";
|
|
111789
|
+
import path89 from "node:path";
|
|
111231
111790
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
111232
111791
|
|
|
111233
111792
|
// src/commands/update.ts
|
|
@@ -111241,8 +111800,8 @@ init_paths();
|
|
|
111241
111800
|
init_memory();
|
|
111242
111801
|
init_yaml2();
|
|
111243
111802
|
init_version();
|
|
111244
|
-
import
|
|
111245
|
-
import
|
|
111803
|
+
import fs88 from "node:fs";
|
|
111804
|
+
import path88 from "node:path";
|
|
111246
111805
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
111247
111806
|
var NAME = "wildcrane";
|
|
111248
111807
|
var REPO = "https://github.com/ai4kanban/ai4kanban";
|
|
@@ -111264,10 +111823,10 @@ var Report = class {
|
|
|
111264
111823
|
for (const line of this.notes) say(` ! ${line}`);
|
|
111265
111824
|
}
|
|
111266
111825
|
};
|
|
111267
|
-
var
|
|
111826
|
+
var read4 = (file) => fs88.existsSync(file) ? fs88.readFileSync(file, "utf8") : null;
|
|
111268
111827
|
function statOf(p2) {
|
|
111269
111828
|
try {
|
|
111270
|
-
return
|
|
111829
|
+
return fs88.lstatSync(p2);
|
|
111271
111830
|
} catch {
|
|
111272
111831
|
return null;
|
|
111273
111832
|
}
|
|
@@ -111292,10 +111851,10 @@ async function cmdUpdate2(ctx) {
|
|
|
111292
111851
|
return { updated: ctx.dir, from, to: SKILL_VERSION };
|
|
111293
111852
|
}
|
|
111294
111853
|
async function repairBoard(root2, report3, named2) {
|
|
111295
|
-
const legacy2 =
|
|
111296
|
-
const kept2 =
|
|
111297
|
-
const board2 = named2 ?? (
|
|
111298
|
-
if (!
|
|
111854
|
+
const legacy2 = path88.join(root2, "docs", "kanban");
|
|
111855
|
+
const kept2 = path88.join(root2, ".akb", "kanban");
|
|
111856
|
+
const board2 = named2 ?? (fs88.existsSync(legacy2) ? legacy2 : kept2);
|
|
111857
|
+
if (!fs88.existsSync(board2)) {
|
|
111299
111858
|
report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
|
|
111300
111859
|
return false;
|
|
111301
111860
|
}
|
|
@@ -111326,20 +111885,20 @@ function moveRuntimes(root2, board2, report3) {
|
|
|
111326
111885
|
}
|
|
111327
111886
|
}
|
|
111328
111887
|
function moveLegacyMemory(board2, report3) {
|
|
111329
|
-
const memory =
|
|
111888
|
+
const memory = path88.join(board2, "memory");
|
|
111330
111889
|
const moved = [];
|
|
111331
111890
|
for (const name of MEMORY_FILES) {
|
|
111332
|
-
const from =
|
|
111891
|
+
const from = path88.join(board2, name);
|
|
111333
111892
|
const st2 = statOf(from);
|
|
111334
111893
|
if (!st2 || !st2.isFile()) continue;
|
|
111335
|
-
|
|
111336
|
-
const to =
|
|
111337
|
-
const there =
|
|
111894
|
+
fs88.mkdirSync(memory, { recursive: true });
|
|
111895
|
+
const to = path88.join(memory, name);
|
|
111896
|
+
const there = read4(to);
|
|
111338
111897
|
if (there === null) {
|
|
111339
|
-
|
|
111898
|
+
fs88.renameSync(from, to);
|
|
111340
111899
|
moved.push(name);
|
|
111341
|
-
} else if (there ===
|
|
111342
|
-
|
|
111900
|
+
} else if (there === read4(from)) {
|
|
111901
|
+
fs88.rmSync(from);
|
|
111343
111902
|
moved.push(name);
|
|
111344
111903
|
} else {
|
|
111345
111904
|
report3.notes.push(`both docs/kanban/${name} and docs/kanban/memory/${name} exist and differ \u2014 merge them by hand`);
|
|
@@ -111348,23 +111907,23 @@ function moveLegacyMemory(board2, report3) {
|
|
|
111348
111907
|
if (moved.length) report3.did.push(`moved the memory set into docs/kanban/memory/: ${moved.join(", ")}`);
|
|
111349
111908
|
}
|
|
111350
111909
|
function dropRecordFile(board2) {
|
|
111351
|
-
const file =
|
|
111352
|
-
if (!
|
|
111353
|
-
|
|
111910
|
+
const file = path88.join(board2, "record.csv");
|
|
111911
|
+
if (!fs88.existsSync(file)) return null;
|
|
111912
|
+
fs88.rmSync(file);
|
|
111354
111913
|
return "removed docs/kanban/record.csv (the planning scores it fed are gone)";
|
|
111355
111914
|
}
|
|
111356
111915
|
function dropModuleGoals(board2, report3) {
|
|
111357
|
-
const memory =
|
|
111358
|
-
if (!
|
|
111359
|
-
const root2 =
|
|
111916
|
+
const memory = path88.join(board2, "memory");
|
|
111917
|
+
if (!fs88.existsSync(memory)) return;
|
|
111918
|
+
const root2 = read4(path88.join(memory, "goal.md"));
|
|
111360
111919
|
let dropped = 0;
|
|
111361
|
-
for (const entry of
|
|
111920
|
+
for (const entry of fs88.readdirSync(memory, { withFileTypes: true })) {
|
|
111362
111921
|
if (!entry.isDirectory()) continue;
|
|
111363
|
-
const file =
|
|
111364
|
-
const text5 =
|
|
111922
|
+
const file = path88.join(memory, entry.name, "goal.md");
|
|
111923
|
+
const text5 = read4(file);
|
|
111365
111924
|
if (text5 === null) continue;
|
|
111366
111925
|
if (text5 === root2 || text5.includes(UNFILLED) || !goalWords(text5)) {
|
|
111367
|
-
|
|
111926
|
+
fs88.rmSync(file);
|
|
111368
111927
|
dropped++;
|
|
111369
111928
|
} else {
|
|
111370
111929
|
report3.notes.push(
|
|
@@ -111386,10 +111945,10 @@ var PLAN_LEADS = {
|
|
|
111386
111945
|
var GONE_LEADS = ["software-planner", "planner"];
|
|
111387
111946
|
function planLeads(board2) {
|
|
111388
111947
|
const leads = { ...PLAN_LEADS };
|
|
111389
|
-
const root2 =
|
|
111390
|
-
for (const entry of
|
|
111948
|
+
const root2 = path88.join(board2, "workflows");
|
|
111949
|
+
for (const entry of fs88.existsSync(root2) ? fs88.readdirSync(root2, { withFileTypes: true }) : []) {
|
|
111391
111950
|
if (!entry.isDirectory()) continue;
|
|
111392
|
-
const meta = splitFrontmatter(
|
|
111951
|
+
const meta = splitFrontmatter(read4(path88.join(root2, entry.name, "WORKFLOW.md")) ?? "").meta;
|
|
111393
111952
|
const stages = meta === null ? void 0 : parseYamlBlock(meta).stages;
|
|
111394
111953
|
const plan = stages && typeof stages === "object" && !Array.isArray(stages) ? stages.plan : void 0;
|
|
111395
111954
|
const lead = plan && typeof plan === "object" && !Array.isArray(plan) && typeof plan.lead === "string" ? plan.lead.trim() : "";
|
|
@@ -111398,30 +111957,30 @@ function planLeads(board2) {
|
|
|
111398
111957
|
return leads;
|
|
111399
111958
|
}
|
|
111400
111959
|
function movePlanRules(board2, report3) {
|
|
111401
|
-
const rules =
|
|
111960
|
+
const rules = path88.join(board2, "rules");
|
|
111402
111961
|
const moved = [];
|
|
111403
111962
|
for (const [id, leads] of Object.entries(planLeads(board2))) {
|
|
111404
111963
|
for (const lead of leads) {
|
|
111405
|
-
const from =
|
|
111406
|
-
const rule =
|
|
111964
|
+
const from = path88.join(rules, `${lead}.md`);
|
|
111965
|
+
const rule = read4(from)?.trim();
|
|
111407
111966
|
if (!rule) continue;
|
|
111408
|
-
const to =
|
|
111409
|
-
const there =
|
|
111967
|
+
const to = path88.join(rules, "workflows", `${id}.md`);
|
|
111968
|
+
const there = read4(to)?.trim() ?? "";
|
|
111410
111969
|
if (!there.includes(rule)) {
|
|
111411
|
-
|
|
111412
|
-
|
|
111970
|
+
fs88.mkdirSync(path88.dirname(to), { recursive: true });
|
|
111971
|
+
fs88.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
|
|
111413
111972
|
`);
|
|
111414
111973
|
moved.push(`${lead} \u2192 ${id}`);
|
|
111415
111974
|
}
|
|
111416
111975
|
}
|
|
111417
111976
|
}
|
|
111418
|
-
for (const lead of GONE_LEADS)
|
|
111977
|
+
for (const lead of GONE_LEADS) fs88.rmSync(path88.join(rules, `${lead}.md`), { force: true });
|
|
111419
111978
|
if (moved.length) report3.did.push(`made each plan agent's rule its workflow's card rule (docs/kanban/rules/workflows/): ${moved.join(", ")}`);
|
|
111420
111979
|
}
|
|
111421
111980
|
function noteOldWorkflows(board2, report3) {
|
|
111422
111981
|
const old = (dir, file, keys) => {
|
|
111423
|
-
const root2 =
|
|
111424
|
-
return (
|
|
111982
|
+
const root2 = path88.join(board2, dir);
|
|
111983
|
+
return (fs88.existsSync(root2) ? fs88.readdirSync(root2, { withFileTypes: true }) : []).filter((e2) => e2.isDirectory() && keys.test(splitFrontmatter(read4(path88.join(root2, e2.name, file)) ?? "").meta ?? "")).map((e2) => `docs/kanban/${dir}/${e2.name}/${file}`);
|
|
111425
111984
|
};
|
|
111426
111985
|
const files2 = [...old("workflows", "WORKFLOW.md", /^(stages|delivers):/m), ...old("agents", "AGENT.md", /^\s+(hook|lead):/m)];
|
|
111427
111986
|
if (files2.length) {
|
|
@@ -111431,7 +111990,7 @@ function noteOldWorkflows(board2, report3) {
|
|
|
111431
111990
|
}
|
|
111432
111991
|
}
|
|
111433
111992
|
function checkConfig(board2, report3) {
|
|
111434
|
-
const current =
|
|
111993
|
+
const current = read4(path88.join(board2, "config.md"));
|
|
111435
111994
|
if (!current) return;
|
|
111436
111995
|
const added = missingConfigKeys(current);
|
|
111437
111996
|
if (added.length) {
|
|
@@ -111441,7 +112000,7 @@ function checkConfig(board2, report3) {
|
|
|
111441
112000
|
}
|
|
111442
112001
|
}
|
|
111443
112002
|
function checkModules(board2, report3) {
|
|
111444
|
-
const map2 =
|
|
112003
|
+
const map2 = read4(path88.join(board2, "modules.md"));
|
|
111445
112004
|
if (map2 && map2.includes(UNFILLED)) {
|
|
111446
112005
|
report3.notes.push(
|
|
111447
112006
|
"docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
|
|
@@ -111495,14 +112054,14 @@ function declareSetup(program2, cli) {
|
|
|
111495
112054
|
program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
|
|
111496
112055
|
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");
|
|
111497
112056
|
const where = (cmd) => {
|
|
111498
|
-
const dir =
|
|
111499
|
-
if (!
|
|
112057
|
+
const dir = path89.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
|
|
112058
|
+
if (!fs89.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
|
|
111500
112059
|
return dir;
|
|
111501
112060
|
};
|
|
111502
112061
|
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() {
|
|
111503
112062
|
const dir = where(this);
|
|
111504
112063
|
const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
|
|
111505
|
-
const board2 = named2 ?
|
|
112064
|
+
const board2 = named2 ? path89.resolve(cli.cwd, named2) : null;
|
|
111506
112065
|
await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
|
|
111507
112066
|
});
|
|
111508
112067
|
program2.command("__rules", { hidden: true }).action(function() {
|
|
@@ -111547,7 +112106,7 @@ function invokedDirectly() {
|
|
|
111547
112106
|
const entry = process.argv[1];
|
|
111548
112107
|
if (!entry) return false;
|
|
111549
112108
|
try {
|
|
111550
|
-
return
|
|
112109
|
+
return fs90.realpathSync(entry) === fs90.realpathSync(SELF2);
|
|
111551
112110
|
} catch {
|
|
111552
112111
|
return false;
|
|
111553
112112
|
}
|