wildcrane 0.11.39 → 0.11.41
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 +696 -558
- package/package.json +2 -2
package/dist/kanban.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// ai4kanban 0.11.
|
|
2
|
+
// ai4kanban 0.11.41 — 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)
|
|
@@ -3485,10 +3485,10 @@ function findRollout(threadId) {
|
|
|
3485
3485
|
}
|
|
3486
3486
|
for (const name of names3) {
|
|
3487
3487
|
if (!name.startsWith("rollout-") || !name.endsWith(tail)) continue;
|
|
3488
|
-
const
|
|
3488
|
+
const path86 = join(dir, name);
|
|
3489
3489
|
try {
|
|
3490
|
-
const at = statSync(
|
|
3491
|
-
if (!newest2 || at > newest2.at) newest2 = { path:
|
|
3490
|
+
const at = statSync(path86).mtimeMs;
|
|
3491
|
+
if (!newest2 || at > newest2.at) newest2 = { path: path86, at };
|
|
3492
3492
|
} catch {
|
|
3493
3493
|
}
|
|
3494
3494
|
}
|
|
@@ -3496,11 +3496,11 @@ function findRollout(threadId) {
|
|
|
3496
3496
|
return newest2?.path;
|
|
3497
3497
|
}
|
|
3498
3498
|
function readCodexRunFacts(threadId) {
|
|
3499
|
-
const
|
|
3500
|
-
if (!
|
|
3499
|
+
const path86 = findRollout(threadId);
|
|
3500
|
+
if (!path86) return void 0;
|
|
3501
3501
|
let raw;
|
|
3502
3502
|
try {
|
|
3503
|
-
raw = readFileSync(
|
|
3503
|
+
raw = readFileSync(path86, "utf8");
|
|
3504
3504
|
} catch {
|
|
3505
3505
|
return void 0;
|
|
3506
3506
|
}
|
|
@@ -3628,8 +3628,8 @@ function renderCompleted(item) {
|
|
|
3628
3628
|
const changes = Array.isArray(item.changes) ? item.changes : [];
|
|
3629
3629
|
return changes.map((raw) => {
|
|
3630
3630
|
const change2 = obj(raw);
|
|
3631
|
-
const
|
|
3632
|
-
return
|
|
3631
|
+
const path86 = str(change2.path);
|
|
3632
|
+
return path86 ? `\u23FA ${str(change2.kind) || "change"}(${path86})
|
|
3633
3633
|
` : "";
|
|
3634
3634
|
}).join("");
|
|
3635
3635
|
}
|
|
@@ -3891,10 +3891,10 @@ function readKimiRunFacts(sessionId) {
|
|
|
3891
3891
|
const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
|
|
3892
3892
|
let model;
|
|
3893
3893
|
let holding = 0;
|
|
3894
|
-
for (const { path:
|
|
3894
|
+
for (const { path: path86, main } of wireFiles(entry.sessionDir)) {
|
|
3895
3895
|
let raw;
|
|
3896
3896
|
try {
|
|
3897
|
-
raw = readFileSync2(
|
|
3897
|
+
raw = readFileSync2(path86, "utf8");
|
|
3898
3898
|
} catch {
|
|
3899
3899
|
continue;
|
|
3900
3900
|
}
|
|
@@ -4208,8 +4208,8 @@ var init_package = __esm({
|
|
|
4208
4208
|
"package.json"() {
|
|
4209
4209
|
package_default = {
|
|
4210
4210
|
name: "wildcrane",
|
|
4211
|
-
version: "0.11.
|
|
4212
|
-
akbContract:
|
|
4211
|
+
version: "0.11.41",
|
|
4212
|
+
akbContract: 11,
|
|
4213
4213
|
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.",
|
|
4214
4214
|
keywords: [
|
|
4215
4215
|
"kanban",
|
|
@@ -4285,8 +4285,8 @@ var init_version = __esm({
|
|
|
4285
4285
|
import fs17 from "node:fs";
|
|
4286
4286
|
function whereHint(update2, title) {
|
|
4287
4287
|
const locations = Array.isArray(update2.locations) ? update2.locations : [];
|
|
4288
|
-
const
|
|
4289
|
-
return
|
|
4288
|
+
const path86 = str(obj(locations[0]).path);
|
|
4289
|
+
return path86 && !title.includes(path86) ? hint(path86) : "";
|
|
4290
4290
|
}
|
|
4291
4291
|
function saidBy(update2) {
|
|
4292
4292
|
const content = Array.isArray(update2.content) ? update2.content : [];
|
|
@@ -8564,7 +8564,7 @@ ${rest}`);
|
|
|
8564
8564
|
}
|
|
8565
8565
|
function legacyModuleDirs() {
|
|
8566
8566
|
try {
|
|
8567
|
-
return fs27.readdirSync(MEMORY, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name !== RESERVED_MEMORY_DIR && !isGlobalMemory(e.name)).map((e) => e.name);
|
|
8567
|
+
return fs27.readdirSync(MEMORY, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name !== RESERVED_MEMORY_DIR && e.name !== STUDIO_MEMORY_DIR && !isGlobalMemory(e.name)).map((e) => e.name);
|
|
8568
8568
|
} catch {
|
|
8569
8569
|
return [];
|
|
8570
8570
|
}
|
|
@@ -8661,7 +8661,7 @@ ${rest}`);
|
|
|
8661
8661
|
fs27.rmSync(goal, { force: true });
|
|
8662
8662
|
return words ? `moved the goal to the top of ${rel(agentMemoryFile(PLANNER, "decisions.md"))}` : "removed the empty goal";
|
|
8663
8663
|
}
|
|
8664
|
-
var isGlobalMemory, PLANNER, PLANNER_MEMORY_FILES, BOARD_MEMORY_FILES, STARTERS, onlyStarter, unraw, setOf, RESERVED_MEMORY_DIR, KEPT_MEMORY_FOLDERS, agentMemoryDir, agentMemoryFile, writtenMemoryNames, memoryNamesOf, agentMemoryFiles, legacyAgentMemoryFile, HEADINGS, HEADING_RE, stripHeading, FOLDED_UNDER, moveMemory, RESERVED_MODULE_NAMES, isModule, moduleMemoryFile, plannerCopies, memoryFile, ENTRY_RE, entriesOf2, demote, promote, PRODUCT_STARTER, SEEDED_GOAL_PARAGRAPHS;
|
|
8664
|
+
var isGlobalMemory, PLANNER, PLANNER_MEMORY_FILES, BOARD_MEMORY_FILES, STARTERS, onlyStarter, unraw, setOf, RESERVED_MEMORY_DIR, STUDIO_MEMORY_DIR, KEPT_MEMORY_FOLDERS, agentMemoryDir, agentMemoryFile, writtenMemoryNames, memoryNamesOf, agentMemoryFiles, legacyAgentMemoryFile, HEADINGS, HEADING_RE, stripHeading, FOLDED_UNDER, moveMemory, RESERVED_MODULE_NAMES, isModule, moduleMemoryFile, plannerCopies, memoryFile, ENTRY_RE, entriesOf2, demote, promote, PRODUCT_STARTER, SEEDED_GOAL_PARAGRAPHS;
|
|
8665
8665
|
var init_memory = __esm({
|
|
8666
8666
|
"src/lib/memory.ts"() {
|
|
8667
8667
|
"use strict";
|
|
@@ -8708,6 +8708,7 @@ edits here do not last.
|
|
|
8708
8708
|
unraw = (text4) => text4.trim().replace("`akb raw ", "`akb ");
|
|
8709
8709
|
setOf = (names3) => Object.fromEntries(names3.map((name) => [name, STARTERS[name]]));
|
|
8710
8710
|
RESERVED_MEMORY_DIR = "agents";
|
|
8711
|
+
STUDIO_MEMORY_DIR = "studios";
|
|
8711
8712
|
KEPT_MEMORY_FOLDERS = { "hyperframes-editor": "video-assets" };
|
|
8712
8713
|
agentMemoryDir = (agent) => path29.join(AGENT_MEMORY, KEPT_MEMORY_FOLDERS[agent] ?? agent);
|
|
8713
8714
|
agentMemoryFile = (agent, name) => path29.join(agentMemoryDir(agent), name);
|
|
@@ -8813,11 +8814,12 @@ function specAgentInstructions(agent, entries = specAgentEntries()) {
|
|
|
8813
8814
|
function agentFilesBlock(agent) {
|
|
8814
8815
|
if (!agent.files.length) return "";
|
|
8815
8816
|
const dir = agent.dir;
|
|
8817
|
+
const studio = dir ? "" : agentStudio(agent.name);
|
|
8816
8818
|
return [
|
|
8817
8819
|
"Read one only when the work calls for it:",
|
|
8818
8820
|
"",
|
|
8819
8821
|
...agent.files.map(
|
|
8820
|
-
(f) => dir ? `- \`${rel(path30.join(dir, f))}\`` : `- \`${f}\` \u2014 \`${rawMove(`agent-file ${agent.name} ${f}`)}\``
|
|
8822
|
+
(f) => dir ? `- \`${rel(path30.join(dir, f))}\`` : `- \`${f}\` \u2014 \`${rawMove(studio ? `file ${studio} agents/${agent.name}/${f}` : `agent-file ${agent.name} ${f}`)}\``
|
|
8821
8823
|
)
|
|
8822
8824
|
].join("\n");
|
|
8823
8825
|
}
|
|
@@ -9192,9 +9194,19 @@ var init_roles = __esm({
|
|
|
9192
9194
|
}
|
|
9193
9195
|
});
|
|
9194
9196
|
|
|
9197
|
+
// src/lib/shared/file-limits.ts
|
|
9198
|
+
var BOARD_FILE_LIMIT, ASSET_FILE_LIMIT;
|
|
9199
|
+
var init_file_limits = __esm({
|
|
9200
|
+
"src/lib/shared/file-limits.ts"() {
|
|
9201
|
+
"use strict";
|
|
9202
|
+
BOARD_FILE_LIMIT = 10 * 1024 * 1024;
|
|
9203
|
+
ASSET_FILE_LIMIT = 100 * 1024 * 1024;
|
|
9204
|
+
}
|
|
9205
|
+
});
|
|
9206
|
+
|
|
9195
9207
|
// src/lib/shared/board-files.ts
|
|
9196
|
-
function studioRenamed(
|
|
9197
|
-
const to =
|
|
9208
|
+
function studioRenamed(path86, content) {
|
|
9209
|
+
const to = path86.replace(/^(rules\/)?workflows\//, "$1studios/").replace(/^(studios\/[^/]+)\/WORKFLOW\.md$/, "$1/STUDIO.md");
|
|
9198
9210
|
if (!to.endsWith(".md")) return { path: to, content };
|
|
9199
9211
|
if (to.startsWith("studios/")) return { path: to, content: content.replace(/^(icon:\s*["']?)workflow(-kit)?(["']?\s*)$/gm, "$1studio$2$3") };
|
|
9200
9212
|
const front = /^(?:todo|triage)\//.test(to) ? /^---\r?\n[\s\S]*?\r?\n---/.exec(content)?.[0] : void 0;
|
|
@@ -9203,11 +9215,11 @@ function studioRenamed(path85, content) {
|
|
|
9203
9215
|
const renamed = front.replace(/^workflow:[ \t]*(.*)$/m, (_, id) => `studio: ${id === "workflow-builder" ? "studio-builder" : id}`);
|
|
9204
9216
|
return { path: to, content: renamed + body };
|
|
9205
9217
|
}
|
|
9206
|
-
var
|
|
9218
|
+
var cardSlug, studioFolder, studioName, draftFolder;
|
|
9207
9219
|
var init_board_files = __esm({
|
|
9208
9220
|
"src/lib/shared/board-files.ts"() {
|
|
9209
9221
|
"use strict";
|
|
9210
|
-
|
|
9222
|
+
init_file_limits();
|
|
9211
9223
|
cardSlug = (task) => task.toLowerCase().replace(/_/g, "-");
|
|
9212
9224
|
studioFolder = (id) => id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
9213
9225
|
studioName = (id) => id.startsWith("wf_builtin_") ? id.slice("wf_builtin_".length).replace(/_/g, "-") : studioFolder(id);
|
|
@@ -9500,7 +9512,7 @@ function readTranslations(raw) {
|
|
|
9500
9512
|
}
|
|
9501
9513
|
return out;
|
|
9502
9514
|
}
|
|
9503
|
-
function memoryPaths(raw) {
|
|
9515
|
+
function memoryPaths(raw, folder = "memory/agents/<name>/") {
|
|
9504
9516
|
if (raw === void 0) return [];
|
|
9505
9517
|
const block = map(raw);
|
|
9506
9518
|
const extra = block ? Object.keys(block).filter((key) => key !== "workspace") : [];
|
|
@@ -9512,7 +9524,7 @@ function memoryPaths(raw) {
|
|
|
9512
9524
|
}
|
|
9513
9525
|
const paths = [...new Set(list.map((v) => v.trim()))];
|
|
9514
9526
|
const outside = paths.find((p) => p.startsWith("/") || p.includes("\\") || p.split("/").some((part) => part === ".." || part === "."));
|
|
9515
|
-
if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside
|
|
9527
|
+
if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`${folder}\``;
|
|
9516
9528
|
return paths;
|
|
9517
9529
|
}
|
|
9518
9530
|
var OLD_ROLE_KEYS, AGENT_NAME, SCHEDULE_READS, isScheduleReads, names, str3, map;
|
|
@@ -9603,6 +9615,8 @@ function parseStudioFile(id, source, from) {
|
|
|
9603
9615
|
if (!agent || scheduled.some((s) => s.agent === agent)) continue;
|
|
9604
9616
|
scheduled.push({ agent, ...text3(row.cadence) ? { cadence: text3(row.cadence) } : {} });
|
|
9605
9617
|
}
|
|
9618
|
+
const workspace2 = memoryPaths(raw.memoryFiles, `memory/studios/${id}/`);
|
|
9619
|
+
if (typeof workspace2 === "string") return { problem: `${from}: declares ${workspace2}` };
|
|
9606
9620
|
const names3 = Object.fromEntries(Object.entries(box(raw.names)).map(([lang, said2]) => [lang, text3(said2)]).filter(([, said2]) => said2));
|
|
9607
9621
|
return {
|
|
9608
9622
|
def: {
|
|
@@ -9616,6 +9630,7 @@ function parseStudioFile(id, source, from) {
|
|
|
9616
9630
|
previews,
|
|
9617
9631
|
land,
|
|
9618
9632
|
scheduled,
|
|
9633
|
+
...workspace2.length ? { memoryFiles: { workspace: workspace2 } } : {},
|
|
9619
9634
|
rules: body.trim()
|
|
9620
9635
|
}
|
|
9621
9636
|
};
|
|
@@ -9625,6 +9640,7 @@ var init_studio_def = __esm({
|
|
|
9625
9640
|
"src/lib/agent/studio-def.ts"() {
|
|
9626
9641
|
"use strict";
|
|
9627
9642
|
init_icon();
|
|
9643
|
+
init_parse();
|
|
9628
9644
|
init_yaml2();
|
|
9629
9645
|
init_spec_agent_names();
|
|
9630
9646
|
init_yaml();
|
|
@@ -9656,7 +9672,12 @@ function studioDiagram(def, agentOf2) {
|
|
|
9656
9672
|
const after2 = (name) => (agentOf2(name)?.after ?? []).filter((other) => previews.includes(other));
|
|
9657
9673
|
return {
|
|
9658
9674
|
version: 1,
|
|
9659
|
-
rounds: stagesOf(previews, after2).map(
|
|
9675
|
+
rounds: stagesOf(previews, after2).map(
|
|
9676
|
+
(round) => round.map((name) => {
|
|
9677
|
+
const waits = after2(name);
|
|
9678
|
+
return waits.length ? { ...step(name), after: waits } : step(name);
|
|
9679
|
+
})
|
|
9680
|
+
),
|
|
9660
9681
|
land: def.land.filter((h) => !h.off).map((h) => step(h.agent)),
|
|
9661
9682
|
scheduled: def.scheduled.map((s) => ({ ...step(s.agent), ...s.cadence ? { cadence: s.cadence } : {} }))
|
|
9662
9683
|
};
|
|
@@ -9724,7 +9745,7 @@ function inspect(value, official) {
|
|
|
9724
9745
|
if (size > FILE_LIMITS.file) return fail(file, `is larger than ${FILE_LIMITS.file / KB} KB`, true);
|
|
9725
9746
|
total += size;
|
|
9726
9747
|
if (total > FILE_LIMITS.total) return fail("files", `are larger than ${FILE_LIMITS.total / KB / KB} MB together`, true);
|
|
9727
|
-
if (file === STUDIO_FILE) continue;
|
|
9748
|
+
if (file === STUDIO_FILE || file === CARD_TEMPLATE_FILE) continue;
|
|
9728
9749
|
if (official && file === MCP_FILE) {
|
|
9729
9750
|
const problem = mcpProblem(text4);
|
|
9730
9751
|
if (problem) fail(file, problem);
|
|
@@ -9736,9 +9757,10 @@ function inspect(value, official) {
|
|
|
9736
9757
|
else skills.add(file.split("/")[1]);
|
|
9737
9758
|
continue;
|
|
9738
9759
|
}
|
|
9760
|
+
if (isSharedFile(file)) continue;
|
|
9739
9761
|
const at = folderPath(file, "agents");
|
|
9740
9762
|
if (!at) {
|
|
9741
|
-
fail(file, `is neither ${STUDIO_FILE} nor inside agents/<name>/`);
|
|
9763
|
+
fail(file, `is neither ${STUDIO_FILE}, ${CARD_TEMPLATE_FILE}, shared/ nor inside agents/<name>/`);
|
|
9742
9764
|
continue;
|
|
9743
9765
|
}
|
|
9744
9766
|
if (!folders2.has(at[0])) folders2.set(at[0], /* @__PURE__ */ new Map());
|
|
@@ -9776,7 +9798,7 @@ function inspect(value, official) {
|
|
|
9776
9798
|
}
|
|
9777
9799
|
return { problems, def, files };
|
|
9778
9800
|
}
|
|
9779
|
-
var STUDIO_FILE, MCP_FILE, VERSION_FILE, versionText, KB, FILE_LIMITS, officialId, hashInput, landsOf, SEGMENT, isAboutFile, bytes, studioFilesProblems;
|
|
9801
|
+
var STUDIO_FILE, MCP_FILE, CARD_TEMPLATE_FILE, SHARED_DIR, RULES_FILE, VERSION_FILE, versionText, KB, FILE_LIMITS, officialId, hashInput, landsOf, SEGMENT, isAboutFile, bytes, isSharedFile, studioFilesProblems;
|
|
9780
9802
|
var init_studio_files = __esm({
|
|
9781
9803
|
"src/lib/shared/studio-files.ts"() {
|
|
9782
9804
|
"use strict";
|
|
@@ -9785,6 +9807,9 @@ var init_studio_files = __esm({
|
|
|
9785
9807
|
init_studio_diagram();
|
|
9786
9808
|
STUDIO_FILE = "STUDIO.md";
|
|
9787
9809
|
MCP_FILE = "mcp.json";
|
|
9810
|
+
CARD_TEMPLATE_FILE = "CARD.md";
|
|
9811
|
+
SHARED_DIR = "shared/";
|
|
9812
|
+
RULES_FILE = "shared/RULES.md";
|
|
9788
9813
|
VERSION_FILE = "version.json";
|
|
9789
9814
|
versionText = (id, version) => `${JSON.stringify({ id, version })}
|
|
9790
9815
|
`;
|
|
@@ -9796,6 +9821,10 @@ var init_studio_files = __esm({
|
|
|
9796
9821
|
SEGMENT = /^[\w.-]+$/;
|
|
9797
9822
|
isAboutFile = (file) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file);
|
|
9798
9823
|
bytes = (text4) => new TextEncoder().encode(text4).length;
|
|
9824
|
+
isSharedFile = (file) => {
|
|
9825
|
+
const parts = file.split("/");
|
|
9826
|
+
return parts.length > 1 && parts[0] === "shared" && parts.slice(1).every((p) => SEGMENT.test(p) && p !== "." && p !== "..");
|
|
9827
|
+
};
|
|
9799
9828
|
studioFilesProblems = (value, official = false) => inspect(value, official).problems;
|
|
9800
9829
|
}
|
|
9801
9830
|
});
|
|
@@ -9843,7 +9872,7 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
|
9843
9872
|
const dir = path33.join(studiosDir, folder);
|
|
9844
9873
|
const files = {};
|
|
9845
9874
|
for (const f of filesOf(dir).sort()) {
|
|
9846
|
-
if (f === STUDIO_FILE || f === MCP_FILE || f.startsWith("skills/") || isAboutFile(f)) files[f] = readStudioFile(dir, f);
|
|
9875
|
+
if (f === STUDIO_FILE || f === CARD_TEMPLATE_FILE || f === MCP_FILE || f.startsWith("skills/") || f.startsWith(SHARED_DIR) || isAboutFile(f)) files[f] = readStudioFile(dir, f);
|
|
9847
9876
|
}
|
|
9848
9877
|
const read3 = checkStudioFiles({ [STUDIO_FILE]: files[STUDIO_FILE], ...Object.fromEntries(
|
|
9849
9878
|
Object.entries(agentFiles).flatMap(([name, own]) => Object.entries(own).map(([f, t]) => [`agents/${name}/${f}`, t]))
|
|
@@ -10275,6 +10304,7 @@ function studioFileText(def) {
|
|
|
10275
10304
|
if (def.when) lines.push(`when: ${scalar(def.when)}`);
|
|
10276
10305
|
lines.push(`needsArtifact: ${def.needsArtifact}`);
|
|
10277
10306
|
lines.push(...groupLines("previews", def.previews), ...groupLines("land", def.land));
|
|
10307
|
+
if (def.memoryFiles?.workspace.length) lines.push("memoryFiles:", ` workspace: [${def.memoryFiles.workspace.map(scalar).join(", ")}]`);
|
|
10278
10308
|
if (def.scheduled.length) {
|
|
10279
10309
|
lines.push("scheduled:");
|
|
10280
10310
|
for (const s of def.scheduled) {
|
|
@@ -12032,8 +12062,8 @@ var require_command = __commonJS({
|
|
|
12032
12062
|
"node_modules/commander/lib/command.js"(exports) {
|
|
12033
12063
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
12034
12064
|
var childProcess = __require("node:child_process");
|
|
12035
|
-
var
|
|
12036
|
-
var
|
|
12065
|
+
var path86 = __require("node:path");
|
|
12066
|
+
var fs88 = __require("node:fs");
|
|
12037
12067
|
var process2 = __require("node:process");
|
|
12038
12068
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
12039
12069
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -13014,7 +13044,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13014
13044
|
* @param {string} subcommandName
|
|
13015
13045
|
*/
|
|
13016
13046
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
13017
|
-
if (
|
|
13047
|
+
if (fs88.existsSync(executableFile)) return;
|
|
13018
13048
|
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";
|
|
13019
13049
|
const executableMissing = `'${executableFile}' does not exist
|
|
13020
13050
|
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
@@ -13032,11 +13062,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13032
13062
|
let launchWithNode = false;
|
|
13033
13063
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
13034
13064
|
function findFile(baseDir, baseName) {
|
|
13035
|
-
const localBin =
|
|
13036
|
-
if (
|
|
13037
|
-
if (sourceExt.includes(
|
|
13065
|
+
const localBin = path86.resolve(baseDir, baseName);
|
|
13066
|
+
if (fs88.existsSync(localBin)) return localBin;
|
|
13067
|
+
if (sourceExt.includes(path86.extname(baseName))) return void 0;
|
|
13038
13068
|
const foundExt = sourceExt.find(
|
|
13039
|
-
(ext) =>
|
|
13069
|
+
(ext) => fs88.existsSync(`${localBin}${ext}`)
|
|
13040
13070
|
);
|
|
13041
13071
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
13042
13072
|
return void 0;
|
|
@@ -13048,21 +13078,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13048
13078
|
if (this._scriptPath) {
|
|
13049
13079
|
let resolvedScriptPath;
|
|
13050
13080
|
try {
|
|
13051
|
-
resolvedScriptPath =
|
|
13081
|
+
resolvedScriptPath = fs88.realpathSync(this._scriptPath);
|
|
13052
13082
|
} catch {
|
|
13053
13083
|
resolvedScriptPath = this._scriptPath;
|
|
13054
13084
|
}
|
|
13055
|
-
executableDir =
|
|
13056
|
-
|
|
13085
|
+
executableDir = path86.resolve(
|
|
13086
|
+
path86.dirname(resolvedScriptPath),
|
|
13057
13087
|
executableDir
|
|
13058
13088
|
);
|
|
13059
13089
|
}
|
|
13060
13090
|
if (executableDir) {
|
|
13061
13091
|
let localFile = findFile(executableDir, executableFile);
|
|
13062
13092
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
13063
|
-
const legacyName =
|
|
13093
|
+
const legacyName = path86.basename(
|
|
13064
13094
|
this._scriptPath,
|
|
13065
|
-
|
|
13095
|
+
path86.extname(this._scriptPath)
|
|
13066
13096
|
);
|
|
13067
13097
|
if (legacyName !== this._name) {
|
|
13068
13098
|
localFile = findFile(
|
|
@@ -13073,7 +13103,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13073
13103
|
}
|
|
13074
13104
|
executableFile = localFile || executableFile;
|
|
13075
13105
|
}
|
|
13076
|
-
launchWithNode = sourceExt.includes(
|
|
13106
|
+
launchWithNode = sourceExt.includes(path86.extname(executableFile));
|
|
13077
13107
|
let proc;
|
|
13078
13108
|
if (process2.platform !== "win32") {
|
|
13079
13109
|
if (launchWithNode) {
|
|
@@ -13920,7 +13950,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13920
13950
|
* @return {Command}
|
|
13921
13951
|
*/
|
|
13922
13952
|
nameFromFilename(filename) {
|
|
13923
|
-
this._name =
|
|
13953
|
+
this._name = path86.basename(filename, path86.extname(filename));
|
|
13924
13954
|
return this;
|
|
13925
13955
|
}
|
|
13926
13956
|
/**
|
|
@@ -13934,9 +13964,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13934
13964
|
* @param {string} [path]
|
|
13935
13965
|
* @return {(string|null|Command)}
|
|
13936
13966
|
*/
|
|
13937
|
-
executableDir(
|
|
13938
|
-
if (
|
|
13939
|
-
this._executableDir =
|
|
13967
|
+
executableDir(path87) {
|
|
13968
|
+
if (path87 === void 0) return this._executableDir;
|
|
13969
|
+
this._executableDir = path87;
|
|
13940
13970
|
return this;
|
|
13941
13971
|
}
|
|
13942
13972
|
/**
|
|
@@ -16156,7 +16186,7 @@ function globalMemories() {
|
|
|
16156
16186
|
} catch {
|
|
16157
16187
|
}
|
|
16158
16188
|
for (const name of folders2) {
|
|
16159
|
-
if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR) continue;
|
|
16189
|
+
if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR || name === STUDIO_MEMORY_DIR) continue;
|
|
16160
16190
|
const file = path51.join(MEMORY, name, GLOBAL_MEMORY_FILE);
|
|
16161
16191
|
if (!fs49.existsSync(file)) continue;
|
|
16162
16192
|
const memory = readMemory(fs49.readFileSync(file, "utf8"), false, name);
|
|
@@ -16254,8 +16284,82 @@ var init_archive = __esm({
|
|
|
16254
16284
|
}
|
|
16255
16285
|
});
|
|
16256
16286
|
|
|
16257
|
-
// src/lib/agent/
|
|
16287
|
+
// src/lib/agent/studio-shared.ts
|
|
16288
|
+
import fs51 from "node:fs";
|
|
16258
16289
|
import path53 from "node:path";
|
|
16290
|
+
function studioFiles(studio) {
|
|
16291
|
+
const flow = cloudFlows().find((f) => f.def.id === studio || f.cloudId === studio);
|
|
16292
|
+
if (flow) return flow.files;
|
|
16293
|
+
if (studio && draftId() === studio) {
|
|
16294
|
+
try {
|
|
16295
|
+
return readStudioFolder(path53.join(STUDIOS, studio));
|
|
16296
|
+
} catch {
|
|
16297
|
+
return null;
|
|
16298
|
+
}
|
|
16299
|
+
}
|
|
16300
|
+
return null;
|
|
16301
|
+
}
|
|
16302
|
+
function readStudioMemory(studio) {
|
|
16303
|
+
const dir = studioMemoryDir(studio);
|
|
16304
|
+
let names3 = [];
|
|
16305
|
+
try {
|
|
16306
|
+
names3 = fs51.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".md")).map((e) => e.name).sort();
|
|
16307
|
+
} catch {
|
|
16308
|
+
return [];
|
|
16309
|
+
}
|
|
16310
|
+
return names3.flatMap((name) => {
|
|
16311
|
+
try {
|
|
16312
|
+
return [{ name, text: fs51.readFileSync(path53.join(dir, name), "utf8").trim() }];
|
|
16313
|
+
} catch {
|
|
16314
|
+
return [];
|
|
16315
|
+
}
|
|
16316
|
+
});
|
|
16317
|
+
}
|
|
16318
|
+
function studioSections(studio, opts = {}) {
|
|
16319
|
+
const files = studio ? studioFiles(studio) : null;
|
|
16320
|
+
if (!studio || !files) return [];
|
|
16321
|
+
const rules = files[RULES_FILE]?.trim();
|
|
16322
|
+
const own = opts.agent ? Object.keys(files).filter((f) => f.startsWith(`agents/${opts.agent}/`) && f !== `agents/${opts.agent}/AGENT.md`).sort() : [];
|
|
16323
|
+
const listed = [...sharedFiles(files), ...own];
|
|
16324
|
+
const remembered = opts.memory ? readStudioMemory(studio) : [];
|
|
16325
|
+
return [
|
|
16326
|
+
rules ? `\u2014\u2014\u2014 your studio's rules \u2014\u2014\u2014
|
|
16327
|
+
|
|
16328
|
+
${rules}` : "",
|
|
16329
|
+
listed.length ? `\u2014\u2014\u2014 your studio's files \u2014\u2014\u2014
|
|
16330
|
+
|
|
16331
|
+
Read one only when the work calls for it:
|
|
16332
|
+
|
|
16333
|
+
${listed.map((f) => fileLine(studio, f)).join("\n")}` : "",
|
|
16334
|
+
remembered.length ? `\u2014\u2014\u2014 what your studio remembers \u2014\u2014\u2014
|
|
16335
|
+
|
|
16336
|
+
From \`${rel(studioMemoryDir(studio))}/\`:
|
|
16337
|
+
|
|
16338
|
+
${remembered.map((m) => `### \`${m.name}\`
|
|
16339
|
+
|
|
16340
|
+
${m.text || "_(empty)_"}`).join("\n\n")}` : ""
|
|
16341
|
+
].filter(Boolean);
|
|
16342
|
+
}
|
|
16343
|
+
var sharedFiles, studioMemoryDir, fileLine, studioHoldsAgent;
|
|
16344
|
+
var init_studio_shared = __esm({
|
|
16345
|
+
"src/lib/agent/studio-shared.ts"() {
|
|
16346
|
+
"use strict";
|
|
16347
|
+
init_memory();
|
|
16348
|
+
init_paths();
|
|
16349
|
+
init_studio_files();
|
|
16350
|
+
init_command();
|
|
16351
|
+
init_cloud_studios();
|
|
16352
|
+
init_studio_file();
|
|
16353
|
+
init_studio_folder();
|
|
16354
|
+
sharedFiles = (files) => Object.keys(files).filter((f) => f.startsWith(SHARED_DIR) && f !== RULES_FILE).sort();
|
|
16355
|
+
studioMemoryDir = (studio) => path53.join(MEMORY, STUDIO_MEMORY_DIR, studio);
|
|
16356
|
+
fileLine = (studio, file) => `- \`${file}\` \u2014 \`${rawMove(`file ${studio} ${file}`)}\``;
|
|
16357
|
+
studioHoldsAgent = (studio, agent) => !!studio && Object.keys(studioFiles(studio) ?? {}).some((f) => f.startsWith(`agents/${agent}/`));
|
|
16358
|
+
}
|
|
16359
|
+
});
|
|
16360
|
+
|
|
16361
|
+
// src/lib/agent/prompts.ts
|
|
16362
|
+
import path54 from "node:path";
|
|
16259
16363
|
function stopReason(deliveryId) {
|
|
16260
16364
|
const delivery = findDelivery(deliveryId);
|
|
16261
16365
|
if (!delivery) return void 0;
|
|
@@ -16316,7 +16420,7 @@ ${text4}` : "";
|
|
|
16316
16420
|
}
|
|
16317
16421
|
function cardFileOf(id) {
|
|
16318
16422
|
const found2 = id === void 0 ? null : locate(id);
|
|
16319
|
-
return found2 ? found2.kind === "group" ?
|
|
16423
|
+
return found2 ? found2.kind === "group" ? path54.join(found2.target, "root.md") : found2.target : "";
|
|
16320
16424
|
}
|
|
16321
16425
|
function realPaths(text4, req) {
|
|
16322
16426
|
if (req.action !== "scheduled" && req.action !== "sub") return text4;
|
|
@@ -16343,14 +16447,26 @@ function studioRulesBlock(req) {
|
|
|
16343
16447
|
const where = req.id !== void 0 && stages > 1 ? `#${req.id} awaits Approve ${stage} of ${stages}: write only the previews this Approve covers${stage < stages ? "; the next previews start once the user approves" : ""}.` : "";
|
|
16344
16448
|
const end2 = landAgents(flow).length ? "After the last approval, the studio agents complete the approved outcome and archive the card." : "The last Approve archives the card: nothing is built, so leave no todo for a build.";
|
|
16345
16449
|
const own = userStudioRules(flow);
|
|
16450
|
+
const template = studioFiles(flow.id)?.[CARD_TEMPLATE_FILE]?.trim();
|
|
16346
16451
|
const body = [where, end2, flow.rules.trim()].filter(Boolean).join("\n\n");
|
|
16347
16452
|
return [
|
|
16348
|
-
|
|
16349
|
-
|
|
16350
|
-
|
|
16351
|
-
|
|
16352
|
-
|
|
16353
|
-
|
|
16453
|
+
[
|
|
16454
|
+
`<studio name="${flow.name}">`,
|
|
16455
|
+
"How a card on this studio is written.",
|
|
16456
|
+
body,
|
|
16457
|
+
"</studio>",
|
|
16458
|
+
...template ? ["", "<card-template>", "Write the card from this template: keep only the parts that fit this card, and fill them in.", template, "</card-template>"] : [],
|
|
16459
|
+
...own ? ["", "<rules>", "The user's own rules for cards on this studio; they win over the studio above.", own, "</rules>"] : []
|
|
16460
|
+
].join("\n"),
|
|
16461
|
+
...studioSections(flow.id)
|
|
16462
|
+
].join("\n\n");
|
|
16463
|
+
}
|
|
16464
|
+
function ownFiles2(studio, agent, files) {
|
|
16465
|
+
const sections2 = studioSections(studio, { agent, memory: true });
|
|
16466
|
+
const listed = !!agent && studioHoldsAgent(studio, agent);
|
|
16467
|
+
return [...sections2, ...files && !listed ? [`\u2014\u2014\u2014 your own files \u2014\u2014\u2014
|
|
16468
|
+
|
|
16469
|
+
${files}`] : []];
|
|
16354
16470
|
}
|
|
16355
16471
|
function landBlock(req) {
|
|
16356
16472
|
if (req.action !== "implement") return "";
|
|
@@ -16358,6 +16474,7 @@ function landBlock(req) {
|
|
|
16358
16474
|
const flow = frozen ? void 0 : studioFor(studioForRun(req));
|
|
16359
16475
|
const rows = frozen ? frozen.land ?? [] : flow ? landAgents(flow) : [];
|
|
16360
16476
|
const delivery = deliveryFor(req);
|
|
16477
|
+
const studio = frozen?.id ?? flow?.id;
|
|
16361
16478
|
const step = delivery ? deliveryStep(delivery) : 0;
|
|
16362
16479
|
const agents = rows.slice(step, step + 1).flatMap((h) => {
|
|
16363
16480
|
const agent = findSpecAgent(h.agent);
|
|
@@ -16369,9 +16486,7 @@ function landBlock(req) {
|
|
|
16369
16486
|
`\u2014\u2014\u2014 ${agents.length > 1 ? `step ${i + 1}: ` : ""}you, the \`${agent.name}\` agent \u2014 where this differs from the shared flow, follow this \u2014\u2014\u2014
|
|
16370
16487
|
|
|
16371
16488
|
${agent.body}`,
|
|
16372
|
-
agentFilesBlock(agent)
|
|
16373
|
-
|
|
16374
|
-
${agentFilesBlock(agent)}` : "",
|
|
16489
|
+
...ownFiles2(studio, agent.name, agentFilesBlock(agent)),
|
|
16375
16490
|
globalMemoryBlock(agent) ? `\u2014\u2014\u2014 global memories \u2014\u2014\u2014
|
|
16376
16491
|
|
|
16377
16492
|
${globalMemoryBlock(agent)}` : "",
|
|
@@ -16403,7 +16518,7 @@ function frozenRules(req) {
|
|
|
16403
16518
|
function archivedCardFile(id) {
|
|
16404
16519
|
const found2 = locateArchived(id);
|
|
16405
16520
|
if (!found2) return `${rel(ARCHIVE)}/`;
|
|
16406
|
-
return rel(found2.kind === "group" ?
|
|
16521
|
+
return rel(found2.kind === "group" ? path54.join(found2.target, "root.md") : found2.target);
|
|
16407
16522
|
}
|
|
16408
16523
|
function shippedLines(cardId2) {
|
|
16409
16524
|
const delivery = endedDelivery(`${cardId2}`);
|
|
@@ -16502,7 +16617,7 @@ function actionPrompt(req, command, notes) {
|
|
|
16502
16617
|
case "prune-memory":
|
|
16503
16618
|
return [
|
|
16504
16619
|
`${kb}. Prune this board's memory following \`akb guide prune-memory\`.`,
|
|
16505
|
-
`Cover the board's own record at \`${rel(MEMORY)}/\` and every agent's memory at \`${rel(MEMORY)}/agents/<agent>/\`, the ${PLANNER}'s among them
|
|
16620
|
+
`Cover the board's own record at \`${rel(MEMORY)}/\` and every agent's memory at \`${rel(MEMORY)}/agents/<agent>/\`, the ${PLANNER}'s among them, and each studio's at \`${rel(MEMORY)}/studios/<studio>/\`.`,
|
|
16506
16621
|
`Change nothing but those files: no card, no question for anyone.`
|
|
16507
16622
|
].join(" ");
|
|
16508
16623
|
// Reading back over the conversations (#748). It names nothing either: which ones have
|
|
@@ -16546,7 +16661,7 @@ function actionPrompt(req, command, notes) {
|
|
|
16546
16661
|
case "spec": {
|
|
16547
16662
|
const agent = findSpecAgent(req.specAgent ?? "");
|
|
16548
16663
|
const found2 = req.id === void 0 ? null : locate(req.id);
|
|
16549
|
-
const cardFile3 = found2 ? rel(found2.kind === "group" ?
|
|
16664
|
+
const cardFile3 = found2 ? rel(found2.kind === "group" ? path54.join(found2.target, "root.md") : found2.target) : `task #${req.id}`;
|
|
16550
16665
|
const own = agent ? specAgentInstructions(agent) : null;
|
|
16551
16666
|
if (own) notes.push(...own.notes);
|
|
16552
16667
|
const memory = agent ? agentMemoryBlock(agent) : "";
|
|
@@ -16564,9 +16679,7 @@ function actionPrompt(req, command, notes) {
|
|
|
16564
16679
|
agent && own ? `\u2014\u2014\u2014 you, the \`${agent.name}\` agent \u2014\u2014\u2014
|
|
16565
16680
|
|
|
16566
16681
|
${own.instructions}` : "",
|
|
16567
|
-
|
|
16568
|
-
|
|
16569
|
-
${own.files}` : "",
|
|
16682
|
+
...ownFiles2(studioForRun(req), agent?.name, own?.files),
|
|
16570
16683
|
memory ? `\u2014\u2014\u2014 what you remember \u2014\u2014\u2014
|
|
16571
16684
|
|
|
16572
16685
|
${memory}` : "",
|
|
@@ -16599,9 +16712,7 @@ ${shared}` : "",
|
|
|
16599
16712
|
agent && own ? `\u2014\u2014\u2014 you, the \`${agent.name}\` agent \u2014\u2014\u2014
|
|
16600
16713
|
|
|
16601
16714
|
${own.instructions}` : "",
|
|
16602
|
-
|
|
16603
|
-
|
|
16604
|
-
${own.files}` : "",
|
|
16715
|
+
...ownFiles2(flow?.id, agent?.name, own?.files),
|
|
16605
16716
|
extra ? `\u2014\u2014\u2014 what this studio asks of you here \u2014\u2014\u2014
|
|
16606
16717
|
|
|
16607
16718
|
${extra}` : "",
|
|
@@ -16635,9 +16746,7 @@ ${req.description ?? ""}`,
|
|
|
16635
16746
|
agent && own ? `\u2014\u2014\u2014 you, the \`${agent.name}\` agent \u2014\u2014\u2014
|
|
16636
16747
|
|
|
16637
16748
|
${own.instructions}` : "",
|
|
16638
|
-
|
|
16639
|
-
|
|
16640
|
-
${own.files}` : "",
|
|
16749
|
+
...ownFiles2(studioForRun(req), agent?.name, own?.files),
|
|
16641
16750
|
memory ? `\u2014\u2014\u2014 what you remember \u2014\u2014\u2014
|
|
16642
16751
|
|
|
16643
16752
|
${memory}` : "",
|
|
@@ -16686,6 +16795,8 @@ var init_prompts = __esm({
|
|
|
16686
16795
|
init_flows();
|
|
16687
16796
|
init_resolve();
|
|
16688
16797
|
init_runner();
|
|
16798
|
+
init_studio_shared();
|
|
16799
|
+
init_studio_files();
|
|
16689
16800
|
init_studios();
|
|
16690
16801
|
init_catalog();
|
|
16691
16802
|
init_roles();
|
|
@@ -16726,16 +16837,16 @@ var init_prompts = __esm({
|
|
|
16726
16837
|
|
|
16727
16838
|
// src/lib/agent/stop.ts
|
|
16728
16839
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
16729
|
-
import
|
|
16840
|
+
import fs52 from "node:fs";
|
|
16730
16841
|
function markedInProc(entry, strict = false) {
|
|
16731
16842
|
const pids = [];
|
|
16732
|
-
for (const name of
|
|
16843
|
+
for (const name of fs52.readdirSync("/proc")) {
|
|
16733
16844
|
if (!/^\d+$/.test(name)) continue;
|
|
16734
16845
|
try {
|
|
16735
|
-
if (
|
|
16846
|
+
if (fs52.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
|
|
16736
16847
|
} catch (error) {
|
|
16737
16848
|
if (strict && !["ENOENT", "ESRCH"].includes(error.code ?? "")) {
|
|
16738
|
-
const stat =
|
|
16849
|
+
const stat = fs52.statSync(`/proc/${name}`, { throwIfNoEntry: false });
|
|
16739
16850
|
if (stat?.uid === process.getuid?.()) throw error;
|
|
16740
16851
|
}
|
|
16741
16852
|
}
|
|
@@ -16890,10 +17001,10 @@ var init_stop = __esm({
|
|
|
16890
17001
|
});
|
|
16891
17002
|
|
|
16892
17003
|
// src/lib/agent/creation-lock.ts
|
|
16893
|
-
import
|
|
17004
|
+
import path55 from "node:path";
|
|
16894
17005
|
function withCreationLock(fn) {
|
|
16895
17006
|
if (depth2) return fn();
|
|
16896
|
-
return withLock(
|
|
17007
|
+
return withLock(path55.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
|
|
16897
17008
|
depth2++;
|
|
16898
17009
|
try {
|
|
16899
17010
|
return fn();
|
|
@@ -16914,8 +17025,8 @@ var init_creation_lock = __esm({
|
|
|
16914
17025
|
|
|
16915
17026
|
// src/lib/agent/sessions.ts
|
|
16916
17027
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
16917
|
-
import
|
|
16918
|
-
import
|
|
17028
|
+
import fs53 from "node:fs";
|
|
17029
|
+
import path56 from "node:path";
|
|
16919
17030
|
function reap(runs, reaped = [], restore = []) {
|
|
16920
17031
|
let changed = false;
|
|
16921
17032
|
const now = Date.now();
|
|
@@ -16935,7 +17046,7 @@ function reap(runs, reaped = [], restore = []) {
|
|
|
16935
17046
|
}
|
|
16936
17047
|
function stampDuration(run2, endedAt) {
|
|
16937
17048
|
try {
|
|
16938
|
-
|
|
17049
|
+
fs53.appendFileSync(run2.logPath, durationLine(endedAt - run2.startedAt));
|
|
16939
17050
|
} catch {
|
|
16940
17051
|
}
|
|
16941
17052
|
}
|
|
@@ -16949,7 +17060,7 @@ function cardNow(cardId2) {
|
|
|
16949
17060
|
try {
|
|
16950
17061
|
const file = cardFile(cardId2);
|
|
16951
17062
|
if (!file) return null;
|
|
16952
|
-
const { meta } = parseFrontmatter(
|
|
17063
|
+
const { meta } = parseFrontmatter(fs53.readFileSync(file, "utf8"));
|
|
16953
17064
|
if (!meta) return null;
|
|
16954
17065
|
return { status: meta.status || "todo", questions: meta.questions.length, title: meta.title };
|
|
16955
17066
|
} catch {
|
|
@@ -17082,9 +17193,9 @@ function leftBoardOnLanding(id) {
|
|
|
17082
17193
|
function archivedRejected(id) {
|
|
17083
17194
|
const filed = locateArchived(id);
|
|
17084
17195
|
if (!filed) return null;
|
|
17085
|
-
const file = filed.kind === "group" ?
|
|
17196
|
+
const file = filed.kind === "group" ? path56.join(filed.target, "root.md") : filed.target;
|
|
17086
17197
|
try {
|
|
17087
|
-
return !!parseFrontmatter(
|
|
17198
|
+
return !!parseFrontmatter(fs53.readFileSync(file, "utf8")).meta?.rejected;
|
|
17088
17199
|
} catch {
|
|
17089
17200
|
return false;
|
|
17090
17201
|
}
|
|
@@ -17334,7 +17445,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID4(), said2) {
|
|
|
17334
17445
|
return { run: record, spec };
|
|
17335
17446
|
}
|
|
17336
17447
|
function planningSession(cardId2, cwd = REPO_ROOT) {
|
|
17337
|
-
const here = (dir) => !dir ||
|
|
17448
|
+
const here = (dir) => !dir || path56.resolve(dir) === cwd;
|
|
17338
17449
|
const planned = readRuns().filter((r) => r.status === "done" && r.cardId === cardId2 && PLANNING.has(r.action)).sort((a, b) => b.startedAt - a.startedAt)[0];
|
|
17339
17450
|
if (!planned) return { none: "unrecorded" };
|
|
17340
17451
|
if (!here(planned.cwd)) return { none: "elsewhere" };
|
|
@@ -17554,8 +17665,8 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
|
|
|
17554
17665
|
if (inherited.asks.length || inherited.refines.length) writeAsks(sessionId, inherited);
|
|
17555
17666
|
clearAsks(prev.sessionId);
|
|
17556
17667
|
try {
|
|
17557
|
-
|
|
17558
|
-
|
|
17668
|
+
fs53.unlinkSync(prev.logPath);
|
|
17669
|
+
fs53.rmSync(eventsPathOf(prev.sessionId), { force: true });
|
|
17559
17670
|
} catch {
|
|
17560
17671
|
}
|
|
17561
17672
|
if (retry2 && prev.pictures?.length) {
|
|
@@ -17578,8 +17689,8 @@ function forgetRun(sessionId) {
|
|
|
17578
17689
|
if (!gone) return;
|
|
17579
17690
|
clearAsks(sessionId);
|
|
17580
17691
|
try {
|
|
17581
|
-
|
|
17582
|
-
|
|
17692
|
+
fs53.unlinkSync(gone.logPath);
|
|
17693
|
+
fs53.rmSync(eventsPathOf(gone.sessionId), { force: true });
|
|
17583
17694
|
} catch {
|
|
17584
17695
|
}
|
|
17585
17696
|
}
|
|
@@ -17608,14 +17719,14 @@ function noteSpecRefusals(sessionId, refused) {
|
|
|
17608
17719
|
}
|
|
17609
17720
|
function clearAsks(sessionId) {
|
|
17610
17721
|
try {
|
|
17611
|
-
|
|
17722
|
+
fs53.unlinkSync(asksPathOf(sessionId));
|
|
17612
17723
|
} catch {
|
|
17613
17724
|
}
|
|
17614
17725
|
}
|
|
17615
17726
|
function readAsks(sessionId) {
|
|
17616
17727
|
let data;
|
|
17617
17728
|
try {
|
|
17618
|
-
data = JSON.parse(
|
|
17729
|
+
data = JSON.parse(fs53.readFileSync(asksPathOf(sessionId), "utf8"));
|
|
17619
17730
|
} catch {
|
|
17620
17731
|
return { asks: [], refines: [], refused: [] };
|
|
17621
17732
|
}
|
|
@@ -17642,10 +17753,10 @@ function readAsks(sessionId) {
|
|
|
17642
17753
|
return { asks: asks.filter((a) => !discarded.has(a.cardId)), refines: refines.filter((a) => !discarded.has(a.cardId)), refused };
|
|
17643
17754
|
}
|
|
17644
17755
|
function writeAsks(sessionId, file) {
|
|
17645
|
-
|
|
17756
|
+
fs53.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
17646
17757
|
const tmp = `${asksPathOf(sessionId)}.tmp`;
|
|
17647
|
-
|
|
17648
|
-
|
|
17758
|
+
fs53.writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
|
|
17759
|
+
fs53.renameSync(tmp, asksPathOf(sessionId));
|
|
17649
17760
|
}
|
|
17650
17761
|
function markSpawned(sessionId, pid) {
|
|
17651
17762
|
patch(sessionId, (r) => {
|
|
@@ -17776,12 +17887,12 @@ async function resumeDelivery(id) {
|
|
|
17776
17887
|
return { ok: true, deliveryId: delivery.deliveryId, carryOn };
|
|
17777
17888
|
}
|
|
17778
17889
|
function writeSpec(spec) {
|
|
17779
|
-
|
|
17780
|
-
|
|
17890
|
+
fs53.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
17891
|
+
fs53.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
|
|
17781
17892
|
}
|
|
17782
17893
|
function readSpec(sessionId) {
|
|
17783
17894
|
try {
|
|
17784
|
-
const spec = JSON.parse(
|
|
17895
|
+
const spec = JSON.parse(fs53.readFileSync(specPathOf(sessionId), "utf8"));
|
|
17785
17896
|
return spec && Array.isArray(spec.plan?.argv) ? spec : null;
|
|
17786
17897
|
} catch {
|
|
17787
17898
|
return null;
|
|
@@ -17789,28 +17900,28 @@ function readSpec(sessionId) {
|
|
|
17789
17900
|
}
|
|
17790
17901
|
function dropSpec(sessionId) {
|
|
17791
17902
|
try {
|
|
17792
|
-
|
|
17903
|
+
fs53.unlinkSync(specPathOf(sessionId));
|
|
17793
17904
|
} catch {
|
|
17794
17905
|
}
|
|
17795
17906
|
}
|
|
17796
17907
|
async function acquireIndexLock(giveUp) {
|
|
17797
17908
|
const until = Date.now() + INDEX_WAIT_MS;
|
|
17798
|
-
const holder =
|
|
17909
|
+
const holder = path56.join(INDEX_LOCK2, "holder");
|
|
17799
17910
|
for (; ; ) {
|
|
17800
17911
|
if (giveUp()) return null;
|
|
17801
17912
|
try {
|
|
17802
|
-
|
|
17803
|
-
|
|
17804
|
-
return () =>
|
|
17913
|
+
fs53.mkdirSync(INDEX_LOCK2, { recursive: false });
|
|
17914
|
+
fs53.writeFileSync(holder, String(process.pid));
|
|
17915
|
+
return () => fs53.rmSync(INDEX_LOCK2, { recursive: true, force: true });
|
|
17805
17916
|
} catch (err) {
|
|
17806
17917
|
const code = err.code;
|
|
17807
17918
|
if (code === "ENOENT") {
|
|
17808
|
-
|
|
17919
|
+
fs53.mkdirSync(path56.dirname(INDEX_LOCK2), { recursive: true });
|
|
17809
17920
|
continue;
|
|
17810
17921
|
}
|
|
17811
17922
|
if (code !== "EEXIST") throw err;
|
|
17812
17923
|
if (!pidAlive(Number(readHolder(holder)))) {
|
|
17813
|
-
|
|
17924
|
+
fs53.rmSync(INDEX_LOCK2, { recursive: true, force: true });
|
|
17814
17925
|
continue;
|
|
17815
17926
|
}
|
|
17816
17927
|
if (Date.now() > until) return null;
|
|
@@ -17820,7 +17931,7 @@ async function acquireIndexLock(giveUp) {
|
|
|
17820
17931
|
}
|
|
17821
17932
|
function readHolder(file) {
|
|
17822
17933
|
try {
|
|
17823
|
-
return
|
|
17934
|
+
return fs53.readFileSync(file, "utf8").trim();
|
|
17824
17935
|
} catch {
|
|
17825
17936
|
return String(process.pid);
|
|
17826
17937
|
}
|
|
@@ -17905,8 +18016,8 @@ var init_sessions = __esm({
|
|
|
17905
18016
|
implement: "implementing",
|
|
17906
18017
|
hook: "implementing"
|
|
17907
18018
|
};
|
|
17908
|
-
specPathOf = (sessionId) =>
|
|
17909
|
-
asksPathOf = (sessionId) =>
|
|
18019
|
+
specPathOf = (sessionId) => path56.join(SESSIONS_DIR, `${sessionId}.plan.json`);
|
|
18020
|
+
asksPathOf = (sessionId) => path56.join(SESSIONS_DIR, `${sessionId}.asks.json`);
|
|
17910
18021
|
carriesSession = (r) => !!(r.resumedFrom || r.continues && !r.continues.fork);
|
|
17911
18022
|
canPickUp = (r) => r.status === "error" || r.status === "interrupted" || r.status === "stopped";
|
|
17912
18023
|
neverStarted = (r) => r.unspawned === true || !!r.errorWhy?.some((why2) => why2.kind === "notInstalled");
|
|
@@ -17959,8 +18070,8 @@ var init_sources = __esm({
|
|
|
17959
18070
|
});
|
|
17960
18071
|
|
|
17961
18072
|
// src/lib/signals/inbox.ts
|
|
17962
|
-
import
|
|
17963
|
-
import
|
|
18073
|
+
import fs54 from "node:fs";
|
|
18074
|
+
import path57 from "node:path";
|
|
17964
18075
|
function metaPair(key, value) {
|
|
17965
18076
|
const name = typeof key === "string" ? key.trim() : "";
|
|
17966
18077
|
if (!name) return null;
|
|
@@ -17991,7 +18102,7 @@ ${signal2.summary.trim()}
|
|
|
17991
18102
|
function parse(file, lenient = false) {
|
|
17992
18103
|
let text4;
|
|
17993
18104
|
try {
|
|
17994
|
-
text4 =
|
|
18105
|
+
text4 = fs54.readFileSync(file, "utf8");
|
|
17995
18106
|
} catch {
|
|
17996
18107
|
return null;
|
|
17997
18108
|
}
|
|
@@ -18045,20 +18156,20 @@ function parse(file, lenient = false) {
|
|
|
18045
18156
|
};
|
|
18046
18157
|
}
|
|
18047
18158
|
function freeName(dir, wanted) {
|
|
18048
|
-
const ext =
|
|
18159
|
+
const ext = path57.extname(wanted);
|
|
18049
18160
|
const stem = wanted.slice(0, wanted.length - ext.length);
|
|
18050
18161
|
let name = wanted;
|
|
18051
|
-
for (let n = 2;
|
|
18162
|
+
for (let n = 2; fs54.existsSync(path57.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
|
|
18052
18163
|
return name;
|
|
18053
18164
|
}
|
|
18054
18165
|
function readFolder2(dir, lenient = false) {
|
|
18055
18166
|
let entries;
|
|
18056
18167
|
try {
|
|
18057
|
-
entries =
|
|
18168
|
+
entries = fs54.readdirSync(dir, { withFileTypes: true });
|
|
18058
18169
|
} catch {
|
|
18059
18170
|
return [];
|
|
18060
18171
|
}
|
|
18061
|
-
return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(
|
|
18172
|
+
return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(path57.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
|
|
18062
18173
|
}
|
|
18063
18174
|
function readInbox() {
|
|
18064
18175
|
const signals = readFolder2(TRIAGE);
|
|
@@ -18066,7 +18177,7 @@ function readInbox() {
|
|
|
18066
18177
|
return signals;
|
|
18067
18178
|
}
|
|
18068
18179
|
function writeSignal(incoming, importedAt, slug2 = "") {
|
|
18069
|
-
|
|
18180
|
+
fs54.mkdirSync(TRIAGE, { recursive: true });
|
|
18070
18181
|
const signal2 = {
|
|
18071
18182
|
...incoming,
|
|
18072
18183
|
importedAt,
|
|
@@ -18078,12 +18189,12 @@ function writeSignal(incoming, importedAt, slug2 = "") {
|
|
|
18078
18189
|
contentKept: true,
|
|
18079
18190
|
relPath: ""
|
|
18080
18191
|
};
|
|
18081
|
-
const file =
|
|
18082
|
-
|
|
18192
|
+
const file = path57.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug2)));
|
|
18193
|
+
fs54.writeFileSync(file, serialize({ ...signal2, relPath: boardRel(file) }));
|
|
18083
18194
|
return { ...signal2, relPath: boardRel(file) };
|
|
18084
18195
|
}
|
|
18085
18196
|
function stamp3(file, fields) {
|
|
18086
|
-
const text4 =
|
|
18197
|
+
const text4 = fs54.readFileSync(file, "utf8");
|
|
18087
18198
|
const lines = text4.split("\n");
|
|
18088
18199
|
const close = lines.indexOf("---", 1);
|
|
18089
18200
|
if (close < 0) return;
|
|
@@ -18092,13 +18203,13 @@ function stamp3(file, fields) {
|
|
|
18092
18203
|
return !key || fields[key[1]] === void 0;
|
|
18093
18204
|
});
|
|
18094
18205
|
const added = Object.entries(fields).flatMap(([key, value]) => value === null ? [] : [`${key}: ${yamlScalar(value)}`]);
|
|
18095
|
-
|
|
18206
|
+
fs54.writeFileSync(file, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
|
|
18096
18207
|
}
|
|
18097
18208
|
function moveSignal(from, into, fields) {
|
|
18098
|
-
if (!
|
|
18099
|
-
|
|
18100
|
-
const at =
|
|
18101
|
-
|
|
18209
|
+
if (!fs54.existsSync(from)) return "";
|
|
18210
|
+
fs54.mkdirSync(into, { recursive: true });
|
|
18211
|
+
const at = path57.join(into, freeName(into, path57.basename(from)));
|
|
18212
|
+
fs54.renameSync(from, at);
|
|
18102
18213
|
stamp3(at, fields);
|
|
18103
18214
|
return boardRel(at);
|
|
18104
18215
|
}
|
|
@@ -18107,10 +18218,10 @@ function archiveInboxItem(sourceId, cardId2) {
|
|
|
18107
18218
|
if (!found2) {
|
|
18108
18219
|
const ignored = readAllDismissed().find((signal2) => signal2.sourceId === sourceId);
|
|
18109
18220
|
if (!ignored) return { ok: false, error: `nothing waiting in triage is ${sourceId}` };
|
|
18110
|
-
stamp3(
|
|
18221
|
+
stamp3(path57.join(SIGNALS_DISMISSED, path57.basename(ignored.relPath)), { card_id: String(cardId2) });
|
|
18111
18222
|
return { ok: true, relPath: ignored.relPath, where: "dismissed" };
|
|
18112
18223
|
}
|
|
18113
|
-
const at = moveSignal(
|
|
18224
|
+
const at = moveSignal(path57.join(TRIAGE, path57.basename(found2.relPath)), SIGNALS_ARCHIVED, {
|
|
18114
18225
|
card_id: String(cardId2),
|
|
18115
18226
|
archived_at: formatStamp(/* @__PURE__ */ new Date())
|
|
18116
18227
|
});
|
|
@@ -18124,7 +18235,7 @@ var init_inbox = __esm({
|
|
|
18124
18235
|
init_sources();
|
|
18125
18236
|
init_paths();
|
|
18126
18237
|
init_yaml();
|
|
18127
|
-
boardRel = (file) => rel(file).split(
|
|
18238
|
+
boardRel = (file) => rel(file).split(path57.sep).join("/");
|
|
18128
18239
|
FIELDS = ["source_id", "title", "collected_at", "imported_at"];
|
|
18129
18240
|
META_LINE = /^\s+("(?:[^"\\]|\\.)*"|[^:]+):\s*(.*)$/;
|
|
18130
18241
|
slugOf = (said2) => said2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56).replace(/-+$/, "");
|
|
@@ -18233,12 +18344,12 @@ var init_studio_cards = __esm({
|
|
|
18233
18344
|
});
|
|
18234
18345
|
|
|
18235
18346
|
// src/lib/readme.ts
|
|
18236
|
-
import
|
|
18237
|
-
import
|
|
18347
|
+
import fs55 from "node:fs";
|
|
18348
|
+
import path58 from "node:path";
|
|
18238
18349
|
function stripReadmeRefs(target) {
|
|
18239
|
-
if (!
|
|
18350
|
+
if (!fs55.existsSync(README)) return [];
|
|
18240
18351
|
const needle = target.kind === "group" ? `](${target.rel}/` : `](${target.rel})`;
|
|
18241
|
-
const lines =
|
|
18352
|
+
const lines = fs55.readFileSync(README, "utf8").split("\n");
|
|
18242
18353
|
const out = [];
|
|
18243
18354
|
const removed = [];
|
|
18244
18355
|
let i = 0;
|
|
@@ -18260,20 +18371,20 @@ function stripReadmeRefs(target) {
|
|
|
18260
18371
|
out.push(line);
|
|
18261
18372
|
i++;
|
|
18262
18373
|
}
|
|
18263
|
-
if (removed.length)
|
|
18374
|
+
if (removed.length) fs55.writeFileSync(README, out.join("\n"));
|
|
18264
18375
|
return removed;
|
|
18265
18376
|
}
|
|
18266
18377
|
function addReadmeRef(id, title, relPath) {
|
|
18267
|
-
if (!
|
|
18268
|
-
const link2 = relPath.split(
|
|
18378
|
+
if (!fs55.existsSync(README)) return false;
|
|
18379
|
+
const link2 = relPath.split(path58.sep).join("/");
|
|
18269
18380
|
const bullet = `- [#${id} ${title}](${link2})`;
|
|
18270
18381
|
const heading = `## ${TASKS_HEADING}`;
|
|
18271
|
-
let lines =
|
|
18382
|
+
let lines = fs55.readFileSync(README, "utf8").split("\n");
|
|
18272
18383
|
const hi = lines.findIndex((l) => l.trim().toLowerCase() === heading.toLowerCase());
|
|
18273
18384
|
if (hi === -1) {
|
|
18274
18385
|
while (lines.length && lines[lines.length - 1].trim() === "") lines.pop();
|
|
18275
18386
|
lines.push("", heading, "", bullet);
|
|
18276
|
-
|
|
18387
|
+
fs55.writeFileSync(README, lines.join("\n") + "\n");
|
|
18277
18388
|
return true;
|
|
18278
18389
|
}
|
|
18279
18390
|
let end2 = hi + 1;
|
|
@@ -18287,15 +18398,15 @@ function addReadmeRef(id, title, relPath) {
|
|
|
18287
18398
|
const at = lastBullet !== -1 ? lastBullet + 1 : lines[hi + 1] === "" ? hi + 2 : hi + 1;
|
|
18288
18399
|
lines.splice(at, 0, bullet);
|
|
18289
18400
|
}
|
|
18290
|
-
|
|
18401
|
+
fs55.writeFileSync(README, lines.join("\n"));
|
|
18291
18402
|
return true;
|
|
18292
18403
|
}
|
|
18293
18404
|
function repointReadmeLink(id, oldRel, newRel, title) {
|
|
18294
|
-
if (!
|
|
18295
|
-
const oldLink = oldRel.split(
|
|
18296
|
-
const newLink = newRel.split(
|
|
18405
|
+
if (!fs55.existsSync(README)) return false;
|
|
18406
|
+
const oldLink = oldRel.split(path58.sep).join("/");
|
|
18407
|
+
const newLink = newRel.split(path58.sep).join("/");
|
|
18297
18408
|
const linkRe = new RegExp(`\\[#${id}\\b[^\\]]*\\]\\(${escapeRegex(oldLink)}\\)`);
|
|
18298
|
-
const lines =
|
|
18409
|
+
const lines = fs55.readFileSync(README, "utf8").split("\n");
|
|
18299
18410
|
let changed = false;
|
|
18300
18411
|
for (let i = 0; i < lines.length; i++) {
|
|
18301
18412
|
if (!lines[i].includes(`](${oldLink})`)) continue;
|
|
@@ -18305,7 +18416,7 @@ function repointReadmeLink(id, oldRel, newRel, title) {
|
|
|
18305
18416
|
changed = true;
|
|
18306
18417
|
}
|
|
18307
18418
|
}
|
|
18308
|
-
if (changed)
|
|
18419
|
+
if (changed) fs55.writeFileSync(README, lines.join("\n"));
|
|
18309
18420
|
return changed;
|
|
18310
18421
|
}
|
|
18311
18422
|
var isTableRow, isBulletStart, bulletIndent, TASKS_HEADING, escapeRegex;
|
|
@@ -18792,14 +18903,14 @@ function collect(body, card, host2) {
|
|
|
18792
18903
|
const active2 = /* @__PURE__ */ new Set();
|
|
18793
18904
|
const out = [];
|
|
18794
18905
|
const visit = (src, types, owner) => {
|
|
18795
|
-
const
|
|
18906
|
+
const path86 = src.replace(/[?#].*$/, "");
|
|
18796
18907
|
let resolved2;
|
|
18797
18908
|
try {
|
|
18798
|
-
resolved2 = host2.resolve(
|
|
18909
|
+
resolved2 = host2.resolve(path86, owner);
|
|
18799
18910
|
} catch (error) {
|
|
18800
18911
|
if (owner !== card) return { key: null, error: why(error) };
|
|
18801
18912
|
if (!nodes.has(src)) {
|
|
18802
|
-
const node2 = { key: src, file: null, kind: kindAt(
|
|
18913
|
+
const node2 = { key: src, file: null, kind: kindAt(path86, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
|
|
18803
18914
|
nodes.set(src, node2);
|
|
18804
18915
|
out.push(node2);
|
|
18805
18916
|
}
|
|
@@ -18884,16 +18995,16 @@ var init_collect = __esm({
|
|
|
18884
18995
|
});
|
|
18885
18996
|
|
|
18886
18997
|
// src/lib/dress-page.ts
|
|
18887
|
-
import
|
|
18888
|
-
import
|
|
18998
|
+
import fs56 from "node:fs";
|
|
18999
|
+
import path59 from "node:path";
|
|
18889
19000
|
function dressPage(file) {
|
|
18890
|
-
const folder =
|
|
18891
|
-
const html =
|
|
19001
|
+
const folder = path59.dirname(file);
|
|
19002
|
+
const html = fs56.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
|
|
18892
19003
|
const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
|
|
18893
19004
|
if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
|
|
18894
|
-
const at2 =
|
|
18895
|
-
if (!at2.startsWith(folder +
|
|
18896
|
-
const css =
|
|
19005
|
+
const at2 = path59.resolve(folder, href);
|
|
19006
|
+
if (!at2.startsWith(folder + path59.sep) || !fs56.existsSync(at2)) return tag;
|
|
19007
|
+
const css = fs56.readFileSync(at2, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole2, quote, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole2 : `url(${quote}${path59.relative(folder, path59.resolve(path59.dirname(at2), src)).split(path59.sep).join("/")}${quote})`);
|
|
18897
19008
|
return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
|
|
18898
19009
|
});
|
|
18899
19010
|
const at = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
|
|
@@ -18905,25 +19016,25 @@ var init_dress_page = __esm({
|
|
|
18905
19016
|
"use strict";
|
|
18906
19017
|
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'";
|
|
18907
19018
|
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>`;
|
|
18908
|
-
referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) :
|
|
19019
|
+
referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) : fs56.readFileSync(file, "utf8");
|
|
18909
19020
|
}
|
|
18910
19021
|
});
|
|
18911
19022
|
|
|
18912
19023
|
// src/lib/preview-files.ts
|
|
18913
|
-
import
|
|
18914
|
-
import
|
|
19024
|
+
import fs57 from "node:fs";
|
|
19025
|
+
import path60 from "node:path";
|
|
18915
19026
|
function resolver(card, id) {
|
|
18916
|
-
const roots = [KANBAN,
|
|
18917
|
-
const real2 = (p) =>
|
|
18918
|
-
const inside2 = (p) => roots.some((root2) => p.startsWith(real2(root2) +
|
|
19027
|
+
const roots = [KANBAN, path60.join(ASSETS, String(id)), path60.join(MOCKUPS, String(id))];
|
|
19028
|
+
const real2 = (p) => fs57.existsSync(p) ? fs57.realpathSync(p) : p;
|
|
19029
|
+
const inside2 = (p) => roots.some((root2) => p.startsWith(real2(root2) + path60.sep));
|
|
18919
19030
|
return (src, owner) => {
|
|
18920
19031
|
if (/^[a-z][\w+.-]*:/i.test(src) || src.startsWith("#") || src.startsWith("//")) return null;
|
|
18921
|
-
if (
|
|
19032
|
+
if (path60.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
|
|
18922
19033
|
const held4 = /^\.(assets|mockups)\//.exec(src);
|
|
18923
|
-
const file = held4 ?
|
|
18924
|
-
if (!inside2(
|
|
18925
|
-
if (!
|
|
18926
|
-
return { key:
|
|
19034
|
+
const file = held4 ? path60.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path60.resolve(path60.dirname(owner), src);
|
|
19035
|
+
if (!inside2(path60.resolve(file)) || fs57.existsSync(file) && !inside2(fs57.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
|
|
19036
|
+
if (!fs57.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
|
|
19037
|
+
return { key: fs57.realpathSync(file), file };
|
|
18927
19038
|
};
|
|
18928
19039
|
}
|
|
18929
19040
|
function validatePreviewFiles(card, id, text4) {
|
|
@@ -18966,8 +19077,8 @@ var init_preview_files = __esm({
|
|
|
18966
19077
|
});
|
|
18967
19078
|
|
|
18968
19079
|
// src/lib/spec-contract.ts
|
|
18969
|
-
import
|
|
18970
|
-
import
|
|
19080
|
+
import fs58 from "node:fs";
|
|
19081
|
+
import path61 from "node:path";
|
|
18971
19082
|
function scanCardLines(lines, start = 0) {
|
|
18972
19083
|
const visible = lines.map(() => "");
|
|
18973
19084
|
let fence = null;
|
|
@@ -19000,18 +19111,18 @@ function scanCardLines(lines, start = 0) {
|
|
|
19000
19111
|
}
|
|
19001
19112
|
function snapshotSpecs() {
|
|
19002
19113
|
const out = /* @__PURE__ */ new Map();
|
|
19003
|
-
if (!
|
|
19114
|
+
if (!fs58.existsSync(TODO)) return out;
|
|
19004
19115
|
for (const file of walkMd(TODO)) {
|
|
19005
|
-
if (isLegacyRecurring(
|
|
19006
|
-
const id = idPrefix(
|
|
19007
|
-
if (id !== null) out.set(file, { id, text:
|
|
19116
|
+
if (isLegacyRecurring(path61.relative(TODO, file))) continue;
|
|
19117
|
+
const id = idPrefix(path61.basename(file) === "root.md" ? path61.basename(path61.dirname(file)) : path61.basename(file));
|
|
19118
|
+
if (id !== null) out.set(file, { id, text: fs58.readFileSync(file, "utf8") });
|
|
19008
19119
|
}
|
|
19009
19120
|
return out;
|
|
19010
19121
|
}
|
|
19011
19122
|
function enclosingGroups(file) {
|
|
19012
19123
|
const ids = [];
|
|
19013
19124
|
for (let root2 = enclosingGroupRoot(file); root2; root2 = enclosingGroupRoot(root2)) {
|
|
19014
|
-
const id = idPrefix(
|
|
19125
|
+
const id = idPrefix(path61.basename(path61.dirname(root2)));
|
|
19015
19126
|
if (id !== null) ids.push(id);
|
|
19016
19127
|
}
|
|
19017
19128
|
return ids;
|
|
@@ -19186,9 +19297,9 @@ function setEnd(lines, at) {
|
|
|
19186
19297
|
}
|
|
19187
19298
|
function inside(dir, name) {
|
|
19188
19299
|
try {
|
|
19189
|
-
const root2 =
|
|
19190
|
-
const real2 =
|
|
19191
|
-
return real2.startsWith(root2 +
|
|
19300
|
+
const root2 = fs58.realpathSync(dir);
|
|
19301
|
+
const real2 = fs58.realpathSync(path61.join(dir, name));
|
|
19302
|
+
return real2.startsWith(root2 + path61.sep) && fs58.statSync(real2).isFile() ? real2 : null;
|
|
19192
19303
|
} catch {
|
|
19193
19304
|
return null;
|
|
19194
19305
|
}
|
|
@@ -19206,7 +19317,7 @@ function variantsProblem(raw, src, id) {
|
|
|
19206
19317
|
if (files.length < 2 || !files.every((f) => typeof f === "string" && f)) return `variants needs at least two labels, each naming a file. ${shape}`;
|
|
19207
19318
|
if (!files.includes(src)) return `src="${src}" is not one of the variants. Set src to the version shown first.`;
|
|
19208
19319
|
if (id === void 0) return null;
|
|
19209
|
-
const dir =
|
|
19320
|
+
const dir = path61.join(ASSETS, String(id));
|
|
19210
19321
|
for (const f of files) {
|
|
19211
19322
|
const parts = f.split("/");
|
|
19212
19323
|
if (parts.length !== 3 || parts[0] !== ".assets" || parts[1] !== String(id) || !inside(dir, parts[2])) {
|
|
@@ -19216,12 +19327,12 @@ function variantsProblem(raw, src, id) {
|
|
|
19216
19327
|
return null;
|
|
19217
19328
|
}
|
|
19218
19329
|
function compareProblem(attrs, id) {
|
|
19219
|
-
const dir =
|
|
19330
|
+
const dir = path61.join(ASSETS, String(id));
|
|
19220
19331
|
const src = (message) => ({ rule: "compare-src", message });
|
|
19221
19332
|
const shots = (message) => ({ rule: "compare-shots", message });
|
|
19222
19333
|
const json = (file) => {
|
|
19223
19334
|
try {
|
|
19224
|
-
return file.endsWith(".json") ? JSON.parse(
|
|
19335
|
+
return file.endsWith(".json") ? JSON.parse(fs58.readFileSync(file, "utf8")) : null;
|
|
19225
19336
|
} catch {
|
|
19226
19337
|
return null;
|
|
19227
19338
|
}
|
|
@@ -19246,7 +19357,7 @@ function compareProblem(attrs, id) {
|
|
|
19246
19357
|
const file = inside(dir, named2.name);
|
|
19247
19358
|
if (!file) return { message: `Compare shots ${at} names no file in this card's asset folder. Write the JSON there or fix the path.` };
|
|
19248
19359
|
try {
|
|
19249
|
-
return { data: JSON.parse(
|
|
19360
|
+
return { data: JSON.parse(fs58.readFileSync(file, "utf8")) };
|
|
19250
19361
|
} catch {
|
|
19251
19362
|
return { message: `${at} is not valid JSON.` };
|
|
19252
19363
|
}
|
|
@@ -19264,7 +19375,7 @@ function compareProblem(attrs, id) {
|
|
|
19264
19375
|
}
|
|
19265
19376
|
function validateStoryboards(file, id, text4) {
|
|
19266
19377
|
const errors = [];
|
|
19267
|
-
const dir =
|
|
19378
|
+
const dir = path61.join(ASSETS, String(id));
|
|
19268
19379
|
for (const [tag, tagOf, rule, fix] of [
|
|
19269
19380
|
["Storyboard", storyboardTag, "storyboard-src", "Write the JSON there or fix the path."],
|
|
19270
19381
|
["Studio", studioTag, "studio-src", "Write it with `akb raw studio diagram <studio id> <card id>` or fix the path."]
|
|
@@ -19300,14 +19411,14 @@ var init_spec_contract = __esm({
|
|
|
19300
19411
|
});
|
|
19301
19412
|
|
|
19302
19413
|
// src/lib/reconcile.ts
|
|
19303
|
-
import
|
|
19304
|
-
import
|
|
19414
|
+
import fs59 from "node:fs";
|
|
19415
|
+
import path62 from "node:path";
|
|
19305
19416
|
function liveIds() {
|
|
19306
19417
|
const ids = /* @__PURE__ */ new Set();
|
|
19307
19418
|
for (const file of walkMd(TODO)) {
|
|
19308
|
-
const base =
|
|
19419
|
+
const base = path62.basename(file);
|
|
19309
19420
|
if (base === "README.md") continue;
|
|
19310
|
-
const id = base === "root.md" ? idPrefix(
|
|
19421
|
+
const id = base === "root.md" ? idPrefix(path62.basename(path62.dirname(file))) : idPrefix(base);
|
|
19311
19422
|
if (id != null) ids.add(id);
|
|
19312
19423
|
}
|
|
19313
19424
|
return ids;
|
|
@@ -19315,16 +19426,16 @@ function liveIds() {
|
|
|
19315
19426
|
function indexableCards() {
|
|
19316
19427
|
const out = [];
|
|
19317
19428
|
for (const dir of walkDirs(TODO)) {
|
|
19318
|
-
const id = idPrefix(
|
|
19319
|
-
if (id != null &&
|
|
19320
|
-
out.push({ id, rel:
|
|
19429
|
+
const id = idPrefix(path62.basename(dir));
|
|
19430
|
+
if (id != null && fs59.existsSync(path62.join(dir, "root.md"))) {
|
|
19431
|
+
out.push({ id, rel: path62.join(path62.relative(TODO, dir), "root.md").split(path62.sep).join("/") });
|
|
19321
19432
|
}
|
|
19322
19433
|
}
|
|
19323
19434
|
for (const file of walkMd(TODO)) {
|
|
19324
|
-
const base =
|
|
19435
|
+
const base = path62.basename(file);
|
|
19325
19436
|
if (base === "README.md" || base === "root.md") continue;
|
|
19326
|
-
const relTODO =
|
|
19327
|
-
const segs = relTODO.split(
|
|
19437
|
+
const relTODO = path62.relative(TODO, file);
|
|
19438
|
+
const segs = relTODO.split(path62.sep);
|
|
19328
19439
|
if (segs.length !== 1) continue;
|
|
19329
19440
|
const id = idPrefix(base);
|
|
19330
19441
|
if (id != null) out.push({ id, rel: segs.join("/") });
|
|
@@ -19333,7 +19444,7 @@ function indexableCards() {
|
|
|
19333
19444
|
}
|
|
19334
19445
|
function readmeComplaints(fix) {
|
|
19335
19446
|
const said2 = [];
|
|
19336
|
-
const lines =
|
|
19447
|
+
const lines = fs59.readFileSync(README, "utf8").split("\n");
|
|
19337
19448
|
const indexed = /* @__PURE__ */ new Set();
|
|
19338
19449
|
let fixed = 0;
|
|
19339
19450
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -19342,13 +19453,13 @@ function readmeComplaints(fix) {
|
|
|
19342
19453
|
const id = Number(m[1]);
|
|
19343
19454
|
const linkPath = m[2];
|
|
19344
19455
|
indexed.add(id);
|
|
19345
|
-
if (
|
|
19456
|
+
if (fs59.existsSync(path62.join(TODO, linkPath))) continue;
|
|
19346
19457
|
const found2 = locate(id);
|
|
19347
19458
|
if (!found2) {
|
|
19348
19459
|
said2.push(`README links #${id} \u2192 ${linkPath}, but no card with that id exists (removed by hand?). Drop the entry or restore the file.`);
|
|
19349
19460
|
continue;
|
|
19350
19461
|
}
|
|
19351
|
-
const want = (found2.kind === "group" ?
|
|
19462
|
+
const want = (found2.kind === "group" ? path62.join(found2.rel, "root.md") : found2.rel).split(path62.sep).join("/");
|
|
19352
19463
|
if (want === linkPath) continue;
|
|
19353
19464
|
if (!fix) {
|
|
19354
19465
|
said2.push(`README links #${id} \u2192 ${linkPath}, which isn't there any more; the card is at ${want}.`);
|
|
@@ -19358,7 +19469,7 @@ function readmeComplaints(fix) {
|
|
|
19358
19469
|
said2.push(`README link #${id} pointed at missing ${linkPath} \u2192 repointed to ${want}.`);
|
|
19359
19470
|
fixed++;
|
|
19360
19471
|
}
|
|
19361
|
-
if (fixed)
|
|
19472
|
+
if (fixed) fs59.writeFileSync(README, lines.join("\n"));
|
|
19362
19473
|
for (const c of indexableCards()) {
|
|
19363
19474
|
if (!indexed.has(c.id)) {
|
|
19364
19475
|
said2.push(`card ${c.rel} (#${c.id}) is not in the README index. Add it under "## ${TASKS_HEADING}".`);
|
|
@@ -19370,11 +19481,11 @@ function crossRefComplaints() {
|
|
|
19370
19481
|
const said2 = [];
|
|
19371
19482
|
const live = liveIds();
|
|
19372
19483
|
for (const file of walkMd(TODO)) {
|
|
19373
|
-
const base =
|
|
19484
|
+
const base = path62.basename(file);
|
|
19374
19485
|
if (base === "README.md") continue;
|
|
19375
|
-
const ownerId = base === "root.md" ? idPrefix(
|
|
19486
|
+
const ownerId = base === "root.md" ? idPrefix(path62.basename(path62.dirname(file))) : idPrefix(base);
|
|
19376
19487
|
if (ownerId == null) continue;
|
|
19377
|
-
const { meta } = parseFrontmatter(
|
|
19488
|
+
const { meta } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
|
|
19378
19489
|
if (!meta) continue;
|
|
19379
19490
|
for (const field2 of ["blocked_by", "related"]) {
|
|
19380
19491
|
for (const ref of meta[field2] || []) {
|
|
@@ -19387,11 +19498,11 @@ function crossRefComplaints() {
|
|
|
19387
19498
|
return said2;
|
|
19388
19499
|
}
|
|
19389
19500
|
function reconcileBoard() {
|
|
19390
|
-
if (!
|
|
19501
|
+
if (!fs59.existsSync(README)) return;
|
|
19391
19502
|
for (const line of [...readmeComplaints(true), ...crossRefComplaints()]) warn2(line);
|
|
19392
19503
|
}
|
|
19393
19504
|
function boardComplaints() {
|
|
19394
|
-
if (!
|
|
19505
|
+
if (!fs59.existsSync(README)) return [];
|
|
19395
19506
|
try {
|
|
19396
19507
|
return [...readmeComplaints(false), ...crossRefComplaints()];
|
|
19397
19508
|
} catch {
|
|
@@ -19411,8 +19522,8 @@ var init_reconcile = __esm({
|
|
|
19411
19522
|
});
|
|
19412
19523
|
|
|
19413
19524
|
// src/commands/card.ts
|
|
19414
|
-
import
|
|
19415
|
-
import
|
|
19525
|
+
import fs60 from "node:fs";
|
|
19526
|
+
import path63 from "node:path";
|
|
19416
19527
|
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>") {
|
|
19417
19528
|
return [
|
|
19418
19529
|
summary,
|
|
@@ -19438,7 +19549,7 @@ function bodyFromFile(opts) {
|
|
|
19438
19549
|
if (opts.body === false) die("pass --body-file or --no-body, not both");
|
|
19439
19550
|
let text4;
|
|
19440
19551
|
try {
|
|
19441
|
-
text4 =
|
|
19552
|
+
text4 = fs60.readFileSync(opts.bodyFile, "utf8");
|
|
19442
19553
|
} catch {
|
|
19443
19554
|
die(`can't read ${opts.bodyFile} \u2014 write the body to a file, then pass its path`, { kind: "needs-input" });
|
|
19444
19555
|
}
|
|
@@ -19503,20 +19614,20 @@ function cmdCreate(opts) {
|
|
|
19503
19614
|
const start = opts.id;
|
|
19504
19615
|
const slug2 = slugify(opts.slug !== void 0 ? opts.slug : title);
|
|
19505
19616
|
const fileRel = `${start}-${slug2}.md`;
|
|
19506
|
-
const file =
|
|
19617
|
+
const file = path63.join(TODO, fileRel);
|
|
19507
19618
|
const held4 = locate(start) ?? locateArchived(start);
|
|
19508
|
-
if (held4 &&
|
|
19619
|
+
if (held4 && path63.basename(held4.target) === `${start}-${slug2}.md`) {
|
|
19509
19620
|
say(start);
|
|
19510
19621
|
say(` ${rel(held4.target)} was already written`);
|
|
19511
19622
|
return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
|
|
19512
19623
|
}
|
|
19513
19624
|
if (held4) die(`#${start} is already a card here (${rel(held4.target)})`, { kind: "id-taken", id: start });
|
|
19514
|
-
if (
|
|
19625
|
+
if (fs60.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
|
|
19515
19626
|
countBoardEvent(triage ? "cards_created_proposed" : "cards_created_asked");
|
|
19516
19627
|
const meta = { title, priority, status: "todo", blocked_by, related, modules, studio, previews, stages, triage, source, questions };
|
|
19517
19628
|
const scaffolded = !written && opts.body !== false;
|
|
19518
19629
|
const body = written ?? (scaffolded ? defaultBody() : "");
|
|
19519
|
-
|
|
19630
|
+
fs60.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
|
|
19520
19631
|
const indexed = addReadmeRef(start, title, fileRel);
|
|
19521
19632
|
say(start);
|
|
19522
19633
|
say(
|
|
@@ -19568,8 +19679,8 @@ function cmdUpdate(id, flags) {
|
|
|
19568
19679
|
if (creating) die(creating, { kind: "card-being-created", id });
|
|
19569
19680
|
const found2 = locate(id);
|
|
19570
19681
|
if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
|
|
19571
|
-
const file = found2.kind === "group" ?
|
|
19572
|
-
const { meta, body } = parseFrontmatter(
|
|
19682
|
+
const file = found2.kind === "group" ? path63.join(found2.target, "root.md") : found2.target;
|
|
19683
|
+
const { meta, body } = parseFrontmatter(fs60.readFileSync(file, "utf8"));
|
|
19573
19684
|
if (!meta) die(`${rel(file)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
|
|
19574
19685
|
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");
|
|
19575
19686
|
if (flags.related !== void 0 && flags.addRelated !== void 0) die("--related replaces the list and --add-related appends to it \u2014 pass one");
|
|
@@ -19643,26 +19754,26 @@ function cmdUpdate(id, flags) {
|
|
|
19643
19754
|
meta.status = "todo";
|
|
19644
19755
|
changes.push("status\u2192todo (open questions)");
|
|
19645
19756
|
}
|
|
19646
|
-
const curRel =
|
|
19757
|
+
const curRel = path63.relative(TODO, file);
|
|
19647
19758
|
const isSubtask = found2.kind === "file" && enclosingGroupRoot(file) !== null;
|
|
19648
|
-
let base =
|
|
19759
|
+
let base = path63.basename(file);
|
|
19649
19760
|
if (flags.slug !== void 0) {
|
|
19650
19761
|
if (found2.kind === "group") die("renaming a group root by script is not supported");
|
|
19651
19762
|
base = `${id}-${slugify(flags.slug)}.md`;
|
|
19652
19763
|
}
|
|
19653
|
-
const destRel =
|
|
19654
|
-
const dest =
|
|
19764
|
+
const destRel = path63.join(path63.dirname(curRel), base);
|
|
19765
|
+
const dest = path63.join(TODO, destRel);
|
|
19655
19766
|
const moving = dest !== file;
|
|
19656
|
-
if (moving &&
|
|
19657
|
-
|
|
19658
|
-
if (moving)
|
|
19767
|
+
if (moving && fs60.existsSync(dest)) die(`${rel(dest)} already exists`);
|
|
19768
|
+
fs60.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
|
|
19769
|
+
if (moving) fs60.renameSync(file, dest);
|
|
19659
19770
|
if (isSubtask) {
|
|
19660
19771
|
if (moving || changes.includes("title")) repointReadmeLink(id, curRel, destRel, meta.title);
|
|
19661
|
-
if (moving) changes.push(`renamed \u2192 ${destRel.split(
|
|
19772
|
+
if (moving) changes.push(`renamed \u2192 ${destRel.split(path63.sep).join("/")}`);
|
|
19662
19773
|
} else if (moving) {
|
|
19663
19774
|
stripReadmeRefs({ kind: "file", rel: curRel });
|
|
19664
19775
|
addReadmeRef(id, meta.title, destRel);
|
|
19665
|
-
changes.push(`renamed \u2192 ${destRel.split(
|
|
19776
|
+
changes.push(`renamed \u2192 ${destRel.split(path63.sep).join("/")}`);
|
|
19666
19777
|
} else if (changes.includes("title")) {
|
|
19667
19778
|
stripReadmeRefs({ kind: "file", rel: curRel });
|
|
19668
19779
|
addReadmeRef(id, meta.title, curRel);
|
|
@@ -19674,8 +19785,8 @@ function cmdUpdateQuestions(id, input) {
|
|
|
19674
19785
|
const ops = readQuestionOps(input.ops ?? []);
|
|
19675
19786
|
const found2 = locate(id);
|
|
19676
19787
|
if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
|
|
19677
|
-
const file = found2.kind === "group" ?
|
|
19678
|
-
const { meta, body } = parseFrontmatter(
|
|
19788
|
+
const file = found2.kind === "group" ? path63.join(found2.target, "root.md") : found2.target;
|
|
19789
|
+
const { meta, body } = parseFrontmatter(fs60.readFileSync(file, "utf8"));
|
|
19679
19790
|
if (!meta) die(`${rel(file)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
|
|
19680
19791
|
for (const op of ops) {
|
|
19681
19792
|
if (!op.question?.agent) continue;
|
|
@@ -19697,7 +19808,7 @@ function cmdUpdateQuestions(id, input) {
|
|
|
19697
19808
|
meta.status = "todo";
|
|
19698
19809
|
changes.push("status\u2192todo (open questions)");
|
|
19699
19810
|
}
|
|
19700
|
-
|
|
19811
|
+
fs60.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
|
|
19701
19812
|
const closed2 = activeDelivery(id) ? "questions_closed_verify" : "questions_closed_user";
|
|
19702
19813
|
for (const _ of done2.closed) countBoardEvent(closed2);
|
|
19703
19814
|
say(`updated #${id} questions: ${changes.join(", ")} (${open3} open)`);
|
|
@@ -19764,13 +19875,13 @@ var init_config_template = __esm({
|
|
|
19764
19875
|
});
|
|
19765
19876
|
|
|
19766
19877
|
// src/lib/agent/local.ts
|
|
19767
|
-
import
|
|
19768
|
-
import
|
|
19878
|
+
import fs61 from "node:fs";
|
|
19879
|
+
import path64 from "node:path";
|
|
19769
19880
|
function takeLocalModels(board2) {
|
|
19770
|
-
const file =
|
|
19881
|
+
const file = path64.join(board2, ".local.json");
|
|
19771
19882
|
let held4;
|
|
19772
19883
|
try {
|
|
19773
|
-
held4 = configBlock(JSON.parse(
|
|
19884
|
+
held4 = configBlock(JSON.parse(fs61.readFileSync(file, "utf8")));
|
|
19774
19885
|
} catch {
|
|
19775
19886
|
return {};
|
|
19776
19887
|
}
|
|
@@ -19788,7 +19899,7 @@ function takeLocalModels(board2) {
|
|
|
19788
19899
|
}
|
|
19789
19900
|
if (!Object.keys(agents).length) return out;
|
|
19790
19901
|
delete held4.agents;
|
|
19791
|
-
|
|
19902
|
+
fs61.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
|
|
19792
19903
|
return out;
|
|
19793
19904
|
}
|
|
19794
19905
|
var LOCAL_IGNORE_LINE;
|
|
@@ -19849,12 +19960,12 @@ var init_identity2 = __esm({
|
|
|
19849
19960
|
});
|
|
19850
19961
|
|
|
19851
19962
|
// src/lib/signals/migrate.ts
|
|
19852
|
-
import
|
|
19853
|
-
import
|
|
19963
|
+
import fs62 from "node:fs";
|
|
19964
|
+
import path65 from "node:path";
|
|
19854
19965
|
function readHandled() {
|
|
19855
19966
|
let text4;
|
|
19856
19967
|
try {
|
|
19857
|
-
text4 =
|
|
19968
|
+
text4 = fs62.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
|
|
19858
19969
|
} catch {
|
|
19859
19970
|
return [];
|
|
19860
19971
|
}
|
|
@@ -19871,57 +19982,57 @@ function readHandled() {
|
|
|
19871
19982
|
return held4;
|
|
19872
19983
|
}
|
|
19873
19984
|
function lift(from, into) {
|
|
19874
|
-
|
|
19875
|
-
|
|
19985
|
+
fs62.mkdirSync(into, { recursive: true });
|
|
19986
|
+
fs62.renameSync(from, path65.join(into, freeName(into, path65.basename(from))));
|
|
19876
19987
|
}
|
|
19877
19988
|
function repoint(dir, from, into) {
|
|
19878
19989
|
let entries;
|
|
19879
19990
|
try {
|
|
19880
|
-
entries =
|
|
19991
|
+
entries = fs62.readdirSync(dir, { withFileTypes: true });
|
|
19881
19992
|
} catch {
|
|
19882
19993
|
return;
|
|
19883
19994
|
}
|
|
19884
19995
|
for (const entry of entries) {
|
|
19885
19996
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
19886
|
-
const file =
|
|
19887
|
-
const text4 =
|
|
19888
|
-
if (text4.includes(from))
|
|
19997
|
+
const file = path65.join(dir, entry.name);
|
|
19998
|
+
const text4 = fs62.readFileSync(file, "utf8");
|
|
19999
|
+
if (text4.includes(from)) fs62.writeFileSync(file, text4.split(from).join(into));
|
|
19889
20000
|
}
|
|
19890
20001
|
}
|
|
19891
20002
|
function dropIfEmpty2(dir) {
|
|
19892
20003
|
try {
|
|
19893
|
-
|
|
20004
|
+
fs62.rmdirSync(dir);
|
|
19894
20005
|
} catch {
|
|
19895
20006
|
}
|
|
19896
20007
|
}
|
|
19897
20008
|
function liftInbox() {
|
|
19898
|
-
if (!
|
|
19899
|
-
const oldFiles =
|
|
19900
|
-
if (
|
|
19901
|
-
for (const entry of
|
|
19902
|
-
if (entry.isFile()) lift(
|
|
20009
|
+
if (!fs62.existsSync(SIGNALS_OLD_INBOX)) return;
|
|
20010
|
+
const oldFiles = path65.join(SIGNALS_OLD_INBOX, "files");
|
|
20011
|
+
if (fs62.existsSync(oldFiles)) {
|
|
20012
|
+
for (const entry of fs62.readdirSync(oldFiles, { withFileTypes: true })) {
|
|
20013
|
+
if (entry.isFile()) lift(path65.join(oldFiles, entry.name), SIGNALS_FILES);
|
|
19903
20014
|
}
|
|
19904
20015
|
dropIfEmpty2(oldFiles);
|
|
19905
20016
|
}
|
|
19906
20017
|
const held4 = new Set(readFolder2(TRIAGE).map((signal2) => signal2.sourceId));
|
|
19907
|
-
for (const entry of
|
|
20018
|
+
for (const entry of fs62.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
|
|
19908
20019
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
19909
|
-
const from =
|
|
20020
|
+
const from = path65.join(SIGNALS_OLD_INBOX, entry.name);
|
|
19910
20021
|
const item = parse(from);
|
|
19911
20022
|
if (item && held4.has(item.sourceId)) {
|
|
19912
|
-
|
|
20023
|
+
fs62.rmSync(from, { force: true });
|
|
19913
20024
|
continue;
|
|
19914
20025
|
}
|
|
19915
20026
|
if (item) held4.add(item.sourceId);
|
|
19916
20027
|
lift(from, TRIAGE);
|
|
19917
20028
|
}
|
|
19918
|
-
const wasAt = asWritten(
|
|
20029
|
+
const wasAt = asWritten(path65.join(SIGNALS_OLD_INBOX, "files"));
|
|
19919
20030
|
const nowAt = asWritten(SIGNALS_FILES);
|
|
19920
20031
|
for (const dir of [TRIAGE, SIGNALS_ARCHIVED, SIGNALS_DISMISSED]) repoint(dir, wasAt, nowAt);
|
|
19921
20032
|
dropIfEmpty2(SIGNALS_OLD_INBOX);
|
|
19922
20033
|
}
|
|
19923
20034
|
function liftHandled() {
|
|
19924
|
-
if (!
|
|
20035
|
+
if (!fs62.existsSync(SIGNALS_OLD_HANDLED)) return;
|
|
19925
20036
|
const lines = readHandled();
|
|
19926
20037
|
const held4 = /* @__PURE__ */ new Set([
|
|
19927
20038
|
...readFolder2(TRIAGE).map((signal2) => signal2.sourceId),
|
|
@@ -19931,7 +20042,7 @@ function liftHandled() {
|
|
|
19931
20042
|
for (const { sourceId, when } of lines) {
|
|
19932
20043
|
if (held4.has(sourceId)) continue;
|
|
19933
20044
|
held4.add(sourceId);
|
|
19934
|
-
|
|
20045
|
+
fs62.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
|
|
19935
20046
|
const name = freeName(SIGNALS_DISMISSED, fileName("", sourceId));
|
|
19936
20047
|
const front = [
|
|
19937
20048
|
"---",
|
|
@@ -19941,13 +20052,13 @@ function liftHandled() {
|
|
|
19941
20052
|
"---",
|
|
19942
20053
|
""
|
|
19943
20054
|
];
|
|
19944
|
-
|
|
20055
|
+
fs62.writeFileSync(path65.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
|
|
19945
20056
|
`);
|
|
19946
20057
|
}
|
|
19947
|
-
|
|
20058
|
+
fs62.rmSync(SIGNALS_OLD_HANDLED, { force: true });
|
|
19948
20059
|
}
|
|
19949
20060
|
function migrateTriage() {
|
|
19950
|
-
if (!
|
|
20061
|
+
if (!fs62.existsSync(SIGNALS_OLD_INBOX) && !fs62.existsSync(SIGNALS_OLD_HANDLED)) return;
|
|
19951
20062
|
try {
|
|
19952
20063
|
liftInbox();
|
|
19953
20064
|
liftHandled();
|
|
@@ -19962,13 +20073,13 @@ var init_migrate = __esm({
|
|
|
19962
20073
|
init_yaml();
|
|
19963
20074
|
init_inbox();
|
|
19964
20075
|
HANDLED_LINE = /^-\s+(.+?)\s+—\s+(.+)$/;
|
|
19965
|
-
asWritten = (dir) => `${rel(dir).split(
|
|
20076
|
+
asWritten = (dir) => `${rel(dir).split(path65.sep).join("/")}/`;
|
|
19966
20077
|
}
|
|
19967
20078
|
});
|
|
19968
20079
|
|
|
19969
20080
|
// src/lib/signals/add.ts
|
|
19970
|
-
import
|
|
19971
|
-
import
|
|
20081
|
+
import fs63 from "node:fs";
|
|
20082
|
+
import path66 from "node:path";
|
|
19972
20083
|
import { createHash as createHash4 } from "node:crypto";
|
|
19973
20084
|
function linkTitle(url) {
|
|
19974
20085
|
let at;
|
|
@@ -19981,7 +20092,7 @@ function linkTitle(url) {
|
|
|
19981
20092
|
return oneLine(where) || url.slice(0, TITLE_MAX);
|
|
19982
20093
|
}
|
|
19983
20094
|
function asText(file) {
|
|
19984
|
-
const ext =
|
|
20095
|
+
const ext = path66.extname(file.name).toLowerCase();
|
|
19985
20096
|
if (!file.type.startsWith("text/") && file.type !== "application/json" && !TEXT_EXTENSIONS.has(ext)) return null;
|
|
19986
20097
|
try {
|
|
19987
20098
|
const text4 = new TextDecoder("utf-8", { fatal: true }).decode(file.data);
|
|
@@ -19991,9 +20102,9 @@ function asText(file) {
|
|
|
19991
20102
|
}
|
|
19992
20103
|
}
|
|
19993
20104
|
function fileName2(name, data) {
|
|
19994
|
-
const base =
|
|
19995
|
-
const ext =
|
|
19996
|
-
const word =
|
|
20105
|
+
const base = path66.basename(name);
|
|
20106
|
+
const ext = path66.extname(base).toLowerCase().slice(0, 12);
|
|
20107
|
+
const word = path66.basename(base, path66.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
|
|
19997
20108
|
const hash2 = createHash4("sha256").update(data).digest("hex").slice(0, 8);
|
|
19998
20109
|
return `${word}-${hash2}${ext}`;
|
|
19999
20110
|
}
|
|
@@ -20002,9 +20113,9 @@ function addToInbox(drop) {
|
|
|
20002
20113
|
const typed = (drop.text ?? "").trim();
|
|
20003
20114
|
const file = drop.file;
|
|
20004
20115
|
if (!typed && !file) return { ok: false, error: "nothing to add \u2014 paste a link or some text, or drop a file." };
|
|
20005
|
-
if (file && file.data.length === 0) return { ok: false, error: `${
|
|
20116
|
+
if (file && file.data.length === 0) return { ok: false, error: `${path66.basename(file.name)} is empty.` };
|
|
20006
20117
|
if (file && file.data.length > MAX_BYTES2) {
|
|
20007
|
-
return { ok: false, error: `${
|
|
20118
|
+
return { ok: false, error: `${path66.basename(file.name)} is over ${MAX_BYTES2 / 1024 / 1024} MB \u2014 too big for the board.` };
|
|
20008
20119
|
}
|
|
20009
20120
|
const read3 = describe(typed, file);
|
|
20010
20121
|
const keep2 = read3.keep;
|
|
@@ -20026,8 +20137,8 @@ ${incoming.summary}`);
|
|
|
20026
20137
|
if (seen.status === "pending" || seen.status === "archived") return { ok: false, error: `${sayHit(seen)}.` };
|
|
20027
20138
|
try {
|
|
20028
20139
|
if (keep2) {
|
|
20029
|
-
|
|
20030
|
-
|
|
20140
|
+
fs63.mkdirSync(SIGNALS_FILES, { recursive: true });
|
|
20141
|
+
fs63.writeFileSync(keep2.at, keep2.data);
|
|
20031
20142
|
}
|
|
20032
20143
|
return { ok: true, signal: writeSignal({ ...incoming, sourceId }, formatStamp(/* @__PURE__ */ new Date()), drop.slug) };
|
|
20033
20144
|
} catch (e) {
|
|
@@ -20041,7 +20152,7 @@ function describe(typed, file) {
|
|
|
20041
20152
|
return only ? [only] : [];
|
|
20042
20153
|
};
|
|
20043
20154
|
if (file) {
|
|
20044
|
-
const name =
|
|
20155
|
+
const name = path66.basename(file.name);
|
|
20045
20156
|
const text4 = asText(file);
|
|
20046
20157
|
const note = typed ? `
|
|
20047
20158
|
|
|
@@ -20053,7 +20164,7 @@ ${typed}` : "";
|
|
|
20053
20164
|
const at = keepAt(file);
|
|
20054
20165
|
return {
|
|
20055
20166
|
incoming: {
|
|
20056
|
-
title:
|
|
20167
|
+
title: path66.basename(name, path66.extname(name)) || name,
|
|
20057
20168
|
summary: `${name} \u2014 ${boardRel2(at)}${note}`,
|
|
20058
20169
|
...named2
|
|
20059
20170
|
},
|
|
@@ -20091,73 +20202,73 @@ var init_add = __esm({
|
|
|
20091
20202
|
MAX_BYTES2 = 25 * 1024 * 1024;
|
|
20092
20203
|
TITLE_MAX = 120;
|
|
20093
20204
|
TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".text", ".csv", ".json", ".yml", ".yaml", ".log"]);
|
|
20094
|
-
boardRel2 = (file) => rel(file).split(
|
|
20205
|
+
boardRel2 = (file) => rel(file).split(path66.sep).join("/");
|
|
20095
20206
|
oneLine = (text4) => {
|
|
20096
20207
|
const first = text4.split("\n").find((line) => line.trim()) ?? "";
|
|
20097
20208
|
const clean = first.replace(/^#+\s*/, "").trim();
|
|
20098
20209
|
return clean.length > TITLE_MAX ? `${clean.slice(0, TITLE_MAX - 1).trimEnd()}\u2026` : clean;
|
|
20099
20210
|
};
|
|
20100
|
-
keepAt = (file) =>
|
|
20211
|
+
keepAt = (file) => path66.join(SIGNALS_FILES, fileName2(file.name, file.data));
|
|
20101
20212
|
}
|
|
20102
20213
|
});
|
|
20103
20214
|
|
|
20104
20215
|
// src/lib/recurring.ts
|
|
20105
|
-
import
|
|
20106
|
-
import
|
|
20216
|
+
import fs64 from "node:fs";
|
|
20217
|
+
import path67 from "node:path";
|
|
20107
20218
|
function migratePruneMemoryCard() {
|
|
20108
20219
|
const dir = recurringDir();
|
|
20109
20220
|
let names3;
|
|
20110
20221
|
try {
|
|
20111
|
-
names3 =
|
|
20222
|
+
names3 = fs64.readdirSync(dir);
|
|
20112
20223
|
} catch {
|
|
20113
20224
|
return null;
|
|
20114
20225
|
}
|
|
20115
20226
|
const name = names3.find((entry) => entry.endsWith(`-${PRUNE_SLUG}.md`));
|
|
20116
20227
|
if (!name) return null;
|
|
20117
|
-
const file =
|
|
20228
|
+
const file = path67.join(dir, name);
|
|
20118
20229
|
try {
|
|
20119
|
-
const { meta } = parseFrontmatter(
|
|
20230
|
+
const { meta } = parseFrontmatter(fs64.readFileSync(file, "utf8"));
|
|
20120
20231
|
const cadence = meta?.cadence;
|
|
20121
20232
|
if (typeof cadence === "string") adoptMemoryPruneCadence(cadence);
|
|
20122
20233
|
} catch {
|
|
20123
20234
|
}
|
|
20124
|
-
|
|
20235
|
+
fs64.rmSync(file, { force: true });
|
|
20125
20236
|
return rel(file);
|
|
20126
20237
|
}
|
|
20127
20238
|
function legacyCards() {
|
|
20128
20239
|
const dir = recurringDir();
|
|
20129
|
-
if (!
|
|
20240
|
+
if (!fs64.existsSync(dir)) return [];
|
|
20130
20241
|
const cards = [];
|
|
20131
|
-
for (const entry of
|
|
20242
|
+
for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
|
|
20132
20243
|
const id = idPrefix(entry.name);
|
|
20133
20244
|
if (id === null) continue;
|
|
20134
|
-
const full =
|
|
20245
|
+
const full = path67.join(dir, entry.name);
|
|
20135
20246
|
const slug2 = entry.name.replace(/\.md$/, "").replace(/^\d+-?/, "");
|
|
20136
20247
|
if (entry.isFile() && entry.name.endsWith(".md")) cards.push({ id, slug: slug2, file: full });
|
|
20137
|
-
else if (entry.isDirectory() &&
|
|
20138
|
-
cards.push({ id, slug: slug2, file:
|
|
20248
|
+
else if (entry.isDirectory() && fs64.existsSync(path67.join(full, "root.md"))) {
|
|
20249
|
+
cards.push({ id, slug: slug2, file: path67.join(full, "root.md"), folder: full });
|
|
20139
20250
|
}
|
|
20140
20251
|
}
|
|
20141
20252
|
return cards.sort((a, b) => a.id - b.id);
|
|
20142
20253
|
}
|
|
20143
20254
|
function mergeInto2(from, to, skip = []) {
|
|
20144
|
-
|
|
20145
|
-
for (const entry of
|
|
20255
|
+
fs64.mkdirSync(to, { recursive: true });
|
|
20256
|
+
for (const entry of fs64.readdirSync(from, { withFileTypes: true })) {
|
|
20146
20257
|
if (skip.includes(entry.name)) continue;
|
|
20147
|
-
const source =
|
|
20148
|
-
const target =
|
|
20149
|
-
if (!
|
|
20150
|
-
else if (entry.isDirectory() &&
|
|
20258
|
+
const source = path67.join(from, entry.name);
|
|
20259
|
+
const target = path67.join(to, entry.name);
|
|
20260
|
+
if (!fs64.existsSync(target)) fs64.renameSync(source, target);
|
|
20261
|
+
else if (entry.isDirectory() && fs64.statSync(target).isDirectory()) mergeInto2(source, target);
|
|
20151
20262
|
}
|
|
20152
|
-
if (isEmpty(from))
|
|
20263
|
+
if (isEmpty(from)) fs64.rmSync(from, { recursive: true, force: true });
|
|
20153
20264
|
}
|
|
20154
20265
|
function moveSideFolders() {
|
|
20155
20266
|
const dir = recurringDir();
|
|
20156
|
-
for (const entry of
|
|
20267
|
+
for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
|
|
20157
20268
|
if (!entry.isDirectory() || idPrefix(entry.name) !== null) continue;
|
|
20158
|
-
const from =
|
|
20159
|
-
if (isEmpty(from))
|
|
20160
|
-
else mergeInto2(from,
|
|
20269
|
+
const from = path67.join(dir, entry.name);
|
|
20270
|
+
if (isEmpty(from)) fs64.rmSync(from, { recursive: true, force: true });
|
|
20271
|
+
else mergeInto2(from, path67.join(AGENTS, entry.name));
|
|
20161
20272
|
}
|
|
20162
20273
|
}
|
|
20163
20274
|
function sections(body) {
|
|
@@ -20207,8 +20318,8 @@ function agentName(card, text4) {
|
|
|
20207
20318
|
const known2 = /* @__PURE__ */ new Set([...specAgentCatalog().agents.map((a) => a.name), ...ROLE_NAMES]);
|
|
20208
20319
|
for (const name of [slug2, `${slug2}-${card.id}`]) {
|
|
20209
20320
|
if (!AGENT_NAME.test(name)) continue;
|
|
20210
|
-
const file =
|
|
20211
|
-
const written =
|
|
20321
|
+
const file = path67.join(AGENTS, name, AGENT_FILE2);
|
|
20322
|
+
const written = fs64.existsSync(file) ? fs64.readFileSync(file, "utf8") : null;
|
|
20212
20323
|
if (written === text4(name)) return name;
|
|
20213
20324
|
if (written === null && !known2.has(name)) return name;
|
|
20214
20325
|
}
|
|
@@ -20225,11 +20336,11 @@ ${q.options.map((o) => `- ${o}`).join("\n")}` : "";
|
|
|
20225
20336
|
function removeCard(card) {
|
|
20226
20337
|
dropCrossRefs(card.id);
|
|
20227
20338
|
const target = card.folder ?? card.file;
|
|
20228
|
-
stripReadmeRefs({ kind: card.folder ? "group" : "file", rel:
|
|
20229
|
-
|
|
20339
|
+
stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path67.relative(TODO, target).split(path67.sep).join("/") });
|
|
20340
|
+
fs64.rmSync(target, { recursive: true, force: true });
|
|
20230
20341
|
}
|
|
20231
20342
|
function migrateCard(card) {
|
|
20232
|
-
const { meta, body } = parseFrontmatter(
|
|
20343
|
+
const { meta, body } = parseFrontmatter(fs64.readFileSync(card.file, "utf8"));
|
|
20233
20344
|
if (!meta) throw new Error("its frontmatter cannot be read");
|
|
20234
20345
|
const raw = meta;
|
|
20235
20346
|
const said2 = (key) => typeof raw[key] === "string" ? raw[key].trim() : "";
|
|
@@ -20239,19 +20350,19 @@ function migrateCard(card) {
|
|
|
20239
20350
|
if (!flow) throw new Error(noStudioMessage(""));
|
|
20240
20351
|
const text4 = (name2) => agentText(name2, meta.title || card.slug, body);
|
|
20241
20352
|
const name = agentName(card, text4);
|
|
20242
|
-
const dir =
|
|
20243
|
-
const file =
|
|
20244
|
-
const madeDir = !
|
|
20245
|
-
const wrote = !
|
|
20353
|
+
const dir = path67.join(AGENTS, name);
|
|
20354
|
+
const file = path67.join(dir, AGENT_FILE2);
|
|
20355
|
+
const madeDir = !fs64.existsSync(dir);
|
|
20356
|
+
const wrote = !fs64.existsSync(file);
|
|
20246
20357
|
try {
|
|
20247
|
-
|
|
20248
|
-
if (wrote)
|
|
20358
|
+
fs64.mkdirSync(dir, { recursive: true });
|
|
20359
|
+
if (wrote) fs64.writeFileSync(file, text4(name));
|
|
20249
20360
|
const adopted = adoptStudioScheduled(flow.id, name, { cadence, lastRun });
|
|
20250
20361
|
if (!adopted.ok) throw new Error(adopted.error);
|
|
20251
20362
|
questionsToTriage(meta, name);
|
|
20252
20363
|
} catch (e) {
|
|
20253
|
-
if (madeDir)
|
|
20254
|
-
else if (wrote)
|
|
20364
|
+
if (madeDir) fs64.rmSync(dir, { recursive: true, force: true });
|
|
20365
|
+
else if (wrote) fs64.rmSync(file, { force: true });
|
|
20255
20366
|
throw e;
|
|
20256
20367
|
}
|
|
20257
20368
|
if (card.folder) mergeInto2(card.folder, dir, ["root.md"]);
|
|
@@ -20261,7 +20372,7 @@ function migrateCard(card) {
|
|
|
20261
20372
|
function migrateRecurringCards() {
|
|
20262
20373
|
const done2 = { agents: [], removed: [], failed: [] };
|
|
20263
20374
|
const dir = recurringDir();
|
|
20264
|
-
if (!
|
|
20375
|
+
if (!fs64.existsSync(dir)) return done2;
|
|
20265
20376
|
migratePruneMemoryCard();
|
|
20266
20377
|
moveSideFolders();
|
|
20267
20378
|
for (const card of legacyCards()) {
|
|
@@ -20274,7 +20385,7 @@ function migrateRecurringCards() {
|
|
|
20274
20385
|
done2.failed.push({ card: rel(card.file), why: e instanceof Error ? e.message : String(e) });
|
|
20275
20386
|
}
|
|
20276
20387
|
}
|
|
20277
|
-
if (isEmpty(dir))
|
|
20388
|
+
if (isEmpty(dir)) fs64.rmSync(dir, { recursive: true, force: true });
|
|
20278
20389
|
return done2;
|
|
20279
20390
|
}
|
|
20280
20391
|
function recurringMigrationLines(done2) {
|
|
@@ -20307,14 +20418,14 @@ var init_recurring = __esm({
|
|
|
20307
20418
|
PRUNE_SLUG = "prune-the-memory";
|
|
20308
20419
|
FETCH_SLUG = "fetch-triage-items";
|
|
20309
20420
|
AGENT_FILE2 = "AGENT.md";
|
|
20310
|
-
recurringDir = () =>
|
|
20311
|
-
isEmpty = (dir) =>
|
|
20421
|
+
recurringDir = () => path67.join(TODO, LEGACY_RECURRING);
|
|
20422
|
+
isEmpty = (dir) => fs64.readdirSync(dir).every((name) => name === ".DS_Store");
|
|
20312
20423
|
SECTION = /^##\s+(.+?)\s*$/;
|
|
20313
20424
|
}
|
|
20314
20425
|
});
|
|
20315
20426
|
|
|
20316
20427
|
// src/commands/init.ts
|
|
20317
|
-
import
|
|
20428
|
+
import fs65 from "node:fs";
|
|
20318
20429
|
function boardReadme() {
|
|
20319
20430
|
return `# Board
|
|
20320
20431
|
|
|
@@ -20327,20 +20438,20 @@ _(none)_
|
|
|
20327
20438
|
`;
|
|
20328
20439
|
}
|
|
20329
20440
|
function writeConfigIfMissing() {
|
|
20330
|
-
if (
|
|
20331
|
-
|
|
20332
|
-
|
|
20441
|
+
if (fs65.existsSync(CONFIG)) return false;
|
|
20442
|
+
fs65.mkdirSync(KANBAN, { recursive: true });
|
|
20443
|
+
fs65.writeFileSync(CONFIG, CONFIG_TEMPLATE);
|
|
20333
20444
|
return true;
|
|
20334
20445
|
}
|
|
20335
20446
|
function writeModulesIfMissing() {
|
|
20336
|
-
if (
|
|
20337
|
-
|
|
20338
|
-
|
|
20447
|
+
if (fs65.existsSync(MODULES_MD)) return false;
|
|
20448
|
+
fs65.mkdirSync(KANBAN, { recursive: true });
|
|
20449
|
+
fs65.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
|
|
20339
20450
|
return true;
|
|
20340
20451
|
}
|
|
20341
20452
|
function writeGitignoreIfMissing() {
|
|
20342
|
-
|
|
20343
|
-
const text4 =
|
|
20453
|
+
fs65.mkdirSync(KANBAN, { recursive: true });
|
|
20454
|
+
const text4 = fs65.existsSync(KANBAN_GITIGNORE) ? fs65.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
|
|
20344
20455
|
const has = (rule) => text4.split("\n").some((line) => line.trim() === rule.line);
|
|
20345
20456
|
const missing = IGNORE_RULES.filter((rule) => !has(rule));
|
|
20346
20457
|
if (!missing.length) return false;
|
|
@@ -20348,37 +20459,37 @@ function writeGitignoreIfMissing() {
|
|
|
20348
20459
|
${rule.line}
|
|
20349
20460
|
`).join("");
|
|
20350
20461
|
const separator = !text4 || text4.endsWith("\n") ? "" : "\n";
|
|
20351
|
-
|
|
20462
|
+
fs65.writeFileSync(KANBAN_GITIGNORE, `${text4}${separator}${block}`);
|
|
20352
20463
|
return true;
|
|
20353
20464
|
}
|
|
20354
20465
|
function writeSkeletonIfMissing() {
|
|
20355
20466
|
const added = [];
|
|
20356
|
-
if (!
|
|
20357
|
-
|
|
20467
|
+
if (!fs65.existsSync(TODO)) {
|
|
20468
|
+
fs65.mkdirSync(TODO, { recursive: true });
|
|
20358
20469
|
added.push(`${rel(TODO)}/`);
|
|
20359
20470
|
}
|
|
20360
|
-
if (!
|
|
20361
|
-
|
|
20471
|
+
if (!fs65.existsSync(README)) {
|
|
20472
|
+
fs65.writeFileSync(README, boardReadme());
|
|
20362
20473
|
added.push(rel(README));
|
|
20363
20474
|
}
|
|
20364
20475
|
return added;
|
|
20365
20476
|
}
|
|
20366
20477
|
function retireReleases() {
|
|
20367
20478
|
const done2 = [];
|
|
20368
|
-
if (
|
|
20369
|
-
|
|
20479
|
+
if (fs65.existsSync(RELEASES)) {
|
|
20480
|
+
fs65.rmSync(RELEASES);
|
|
20370
20481
|
done2.push(`deleted ${rel(RELEASES)}`);
|
|
20371
20482
|
}
|
|
20372
20483
|
let cards = 0;
|
|
20373
20484
|
for (const dir of [TODO, ARCHIVE]) {
|
|
20374
|
-
if (!
|
|
20485
|
+
if (!fs65.existsSync(dir)) continue;
|
|
20375
20486
|
for (const file of walkMd(dir)) {
|
|
20376
|
-
const text4 =
|
|
20487
|
+
const text4 = fs65.readFileSync(file, "utf8");
|
|
20377
20488
|
const end2 = text4.startsWith("---\n") ? text4.indexOf("\n---", 3) : -1;
|
|
20378
20489
|
if (end2 < 0) continue;
|
|
20379
20490
|
const head2 = text4.slice(0, end2).replace(/\nrelease:[^\n]*/, "");
|
|
20380
20491
|
if (head2.length === end2) continue;
|
|
20381
|
-
|
|
20492
|
+
fs65.writeFileSync(file, head2 + text4.slice(end2));
|
|
20382
20493
|
cards++;
|
|
20383
20494
|
}
|
|
20384
20495
|
}
|
|
@@ -20386,7 +20497,7 @@ function retireReleases() {
|
|
|
20386
20497
|
return done2.join(", ");
|
|
20387
20498
|
}
|
|
20388
20499
|
function cmdInit() {
|
|
20389
|
-
if (
|
|
20500
|
+
if (fs65.existsSync(KANBAN)) {
|
|
20390
20501
|
const added = [
|
|
20391
20502
|
...writeSkeletonIfMissing(),
|
|
20392
20503
|
writeConfigIfMissing() && rel(CONFIG),
|
|
@@ -20421,8 +20532,8 @@ function cmdInit() {
|
|
|
20421
20532
|
}
|
|
20422
20533
|
return { board: rel(KANBAN), created: false, added, memory_paths: scaffolded.map((s) => rel(s.dir)) };
|
|
20423
20534
|
}
|
|
20424
|
-
|
|
20425
|
-
|
|
20535
|
+
fs65.mkdirSync(TODO, { recursive: true });
|
|
20536
|
+
fs65.writeFileSync(README, boardReadme());
|
|
20426
20537
|
writeConfigIfMissing();
|
|
20427
20538
|
scaffoldProjectMemory();
|
|
20428
20539
|
writeModulesIfMissing();
|
|
@@ -20511,25 +20622,25 @@ var init_scheduled = __esm({
|
|
|
20511
20622
|
});
|
|
20512
20623
|
|
|
20513
20624
|
// src/lib/card-age.ts
|
|
20514
|
-
import
|
|
20515
|
-
import
|
|
20625
|
+
import fs66 from "node:fs";
|
|
20626
|
+
import path68 from "node:path";
|
|
20516
20627
|
function staleAfterIn(config) {
|
|
20517
20628
|
const days = Number(LINE.exec(config)?.[1]);
|
|
20518
20629
|
return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
|
|
20519
20630
|
}
|
|
20520
20631
|
function staleAfter() {
|
|
20521
|
-
if (!
|
|
20522
|
-
return staleAfterIn(
|
|
20632
|
+
if (!fs66.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
|
|
20633
|
+
return staleAfterIn(fs66.readFileSync(CONFIG, "utf8"));
|
|
20523
20634
|
}
|
|
20524
20635
|
function todoPathspec(top) {
|
|
20525
|
-
const from =
|
|
20526
|
-
if (!from || from.startsWith("..") ||
|
|
20527
|
-
return from.split(
|
|
20636
|
+
const from = path68.relative(real(top), real(TODO));
|
|
20637
|
+
if (!from || from.startsWith("..") || path68.isAbsolute(from)) return null;
|
|
20638
|
+
return from.split(path68.sep).join("/");
|
|
20528
20639
|
}
|
|
20529
20640
|
function cardFile2(spec, printed) {
|
|
20530
20641
|
const p = unquotePath(printed);
|
|
20531
20642
|
if (!p.startsWith(`${spec}/`)) return null;
|
|
20532
|
-
return
|
|
20643
|
+
return path68.join(TODO, ...p.slice(spec.length + 1).split("/"));
|
|
20533
20644
|
}
|
|
20534
20645
|
function dirtyCards(top, spec) {
|
|
20535
20646
|
const out = git(["status", "--porcelain", "--untracked-files=all", "--", spec], top);
|
|
@@ -20576,9 +20687,9 @@ var init_card_age = __esm({
|
|
|
20576
20687
|
gitTop = () => git(["rev-parse", "--show-toplevel"])?.trim() || null;
|
|
20577
20688
|
real = (p) => {
|
|
20578
20689
|
try {
|
|
20579
|
-
return
|
|
20690
|
+
return fs66.realpathSync(p);
|
|
20580
20691
|
} catch {
|
|
20581
|
-
return
|
|
20692
|
+
return path68.resolve(p);
|
|
20582
20693
|
}
|
|
20583
20694
|
};
|
|
20584
20695
|
unquotePath = (line) => {
|
|
@@ -20612,8 +20723,8 @@ var init_card_holds = __esm({
|
|
|
20612
20723
|
});
|
|
20613
20724
|
|
|
20614
20725
|
// src/commands/list.ts
|
|
20615
|
-
import
|
|
20616
|
-
import
|
|
20726
|
+
import fs67 from "node:fs";
|
|
20727
|
+
import path69 from "node:path";
|
|
20617
20728
|
function summaryLine(body) {
|
|
20618
20729
|
const lines = body.split("\n");
|
|
20619
20730
|
let i = 0;
|
|
@@ -20629,13 +20740,13 @@ function summaryLine(body) {
|
|
|
20629
20740
|
function openRows() {
|
|
20630
20741
|
const rows = [];
|
|
20631
20742
|
for (const file of walkMd(TODO)) {
|
|
20632
|
-
const base =
|
|
20743
|
+
const base = path69.basename(file);
|
|
20633
20744
|
if (base === "README.md") continue;
|
|
20634
20745
|
const isRoot = base === "root.md";
|
|
20635
|
-
const id = isRoot ? idPrefix(
|
|
20746
|
+
const id = isRoot ? idPrefix(path69.basename(path69.dirname(file))) : idPrefix(base);
|
|
20636
20747
|
if (id == null) continue;
|
|
20637
|
-
if (isLegacyRecurring(
|
|
20638
|
-
const { meta, body } = parseFrontmatter(
|
|
20748
|
+
if (isLegacyRecurring(path69.relative(TODO, file))) continue;
|
|
20749
|
+
const { meta, body } = parseFrontmatter(fs67.readFileSync(file, "utf8"));
|
|
20639
20750
|
rows.push({
|
|
20640
20751
|
id,
|
|
20641
20752
|
file,
|
|
@@ -20677,15 +20788,15 @@ function cmdStale(rows, all2, scope, mod) {
|
|
|
20677
20788
|
}
|
|
20678
20789
|
function archivedFiles() {
|
|
20679
20790
|
const files = /* @__PURE__ */ new Map();
|
|
20680
|
-
if (!
|
|
20791
|
+
if (!fs67.existsSync(ARCHIVE)) return files;
|
|
20681
20792
|
for (const file of walkMd(ARCHIVE)) {
|
|
20682
|
-
const id = idPrefix(
|
|
20793
|
+
const id = idPrefix(path69.basename(file));
|
|
20683
20794
|
if (id !== null) files.set(id, file);
|
|
20684
20795
|
}
|
|
20685
20796
|
for (const dir of walkDirs(ARCHIVE)) {
|
|
20686
|
-
const id = idPrefix(
|
|
20687
|
-
const root2 =
|
|
20688
|
-
if (id !== null &&
|
|
20797
|
+
const id = idPrefix(path69.basename(dir));
|
|
20798
|
+
const root2 = path69.join(dir, "root.md");
|
|
20799
|
+
if (id !== null && fs67.existsSync(root2)) files.set(id, root2);
|
|
20689
20800
|
}
|
|
20690
20801
|
return files;
|
|
20691
20802
|
}
|
|
@@ -20795,8 +20906,8 @@ var init_list = __esm({
|
|
|
20795
20906
|
});
|
|
20796
20907
|
|
|
20797
20908
|
// src/lib/card-sources.ts
|
|
20798
|
-
import
|
|
20799
|
-
import
|
|
20909
|
+
import fs68 from "node:fs";
|
|
20910
|
+
import path70 from "node:path";
|
|
20800
20911
|
function planById(id) {
|
|
20801
20912
|
const found2 = readPlan(`plans/${id}-.md`);
|
|
20802
20913
|
return found2?.text.trim() ? found2 : null;
|
|
@@ -20806,8 +20917,8 @@ function cardLink(id) {
|
|
|
20806
20917
|
const found2 = open3 ?? locateArchived(id);
|
|
20807
20918
|
if (!found2) return null;
|
|
20808
20919
|
try {
|
|
20809
|
-
const file = found2.kind === "group" ?
|
|
20810
|
-
const title = parseFrontmatter(
|
|
20920
|
+
const file = found2.kind === "group" ? path70.join(found2.target, "root.md") : found2.target;
|
|
20921
|
+
const title = parseFrontmatter(fs68.readFileSync(file, "utf8")).meta?.title ?? "";
|
|
20811
20922
|
return { kind: "card", ref: String(id), title, ...open3 ? {} : { archived: true } };
|
|
20812
20923
|
} catch {
|
|
20813
20924
|
return null;
|
|
@@ -20832,7 +20943,7 @@ function link(ref, items) {
|
|
|
20832
20943
|
if (ref.kind === "plan") return planLink(ref.id);
|
|
20833
20944
|
if (ref.kind === "card") return cardLink(ref.id);
|
|
20834
20945
|
if (ref.kind === "url") return urlLink(ref.url);
|
|
20835
|
-
const item = items().find((signal2) =>
|
|
20946
|
+
const item = items().find((signal2) => path70.basename(signal2.relPath) === ref.file);
|
|
20836
20947
|
return item ? itemLink(item) : null;
|
|
20837
20948
|
}
|
|
20838
20949
|
function cardSources(meta, body) {
|
|
@@ -20873,12 +20984,12 @@ var init_card_sources = __esm({
|
|
|
20873
20984
|
});
|
|
20874
20985
|
|
|
20875
20986
|
// src/lib/view/read.ts
|
|
20876
|
-
import
|
|
20877
|
-
import
|
|
20987
|
+
import fs69 from "node:fs";
|
|
20988
|
+
import path71 from "node:path";
|
|
20878
20989
|
function readCard(file, relFromTodo) {
|
|
20879
|
-
const id = idPrefix(
|
|
20990
|
+
const id = idPrefix(path71.basename(relFromTodo));
|
|
20880
20991
|
if (id === null) {
|
|
20881
|
-
const parts = relFromTodo.split(
|
|
20992
|
+
const parts = relFromTodo.split(path71.sep);
|
|
20882
20993
|
const folderId = idPrefix(parts[parts.length - 2] || "");
|
|
20883
20994
|
if (folderId === null) return null;
|
|
20884
20995
|
return buildCard(folderId, file, relFromTodo);
|
|
@@ -20886,10 +20997,10 @@ function readCard(file, relFromTodo) {
|
|
|
20886
20997
|
return buildCard(id, file, relFromTodo);
|
|
20887
20998
|
}
|
|
20888
20999
|
function buildCard(id, file, relFromTodo) {
|
|
20889
|
-
const text4 =
|
|
21000
|
+
const text4 = fs69.readFileSync(file, "utf8");
|
|
20890
21001
|
const { meta, body } = parseFrontmatter(text4);
|
|
20891
21002
|
if (!meta) return null;
|
|
20892
|
-
const relPath = relFromTodo.split(
|
|
21003
|
+
const relPath = relFromTodo.split(path71.sep).join("/");
|
|
20893
21004
|
const flow = studioFor(meta.studio);
|
|
20894
21005
|
const plan = !!meta.studio && archivesOnApproval(flow);
|
|
20895
21006
|
const stages = cardStages(meta, flow).length;
|
|
@@ -20898,7 +21009,7 @@ function buildCard(id, file, relFromTodo) {
|
|
|
20898
21009
|
// Derived from the file exactly as it is on disk (lib/board/revision.ts), so a card
|
|
20899
21010
|
// read here and a card read by the contract agree on what version this is.
|
|
20900
21011
|
revision: revisionOf(text4),
|
|
20901
|
-
updatedAt:
|
|
21012
|
+
updatedAt: fs69.statSync(file).mtime.toISOString(),
|
|
20902
21013
|
relPath,
|
|
20903
21014
|
title: meta.title,
|
|
20904
21015
|
priority: meta.priority,
|
|
@@ -20919,22 +21030,22 @@ function buildCard(id, file, relFromTodo) {
|
|
|
20919
21030
|
};
|
|
20920
21031
|
}
|
|
20921
21032
|
function readGroup2(folderName) {
|
|
20922
|
-
const groupDir =
|
|
20923
|
-
const rootFile =
|
|
20924
|
-
if (!
|
|
20925
|
-
const root2 = readCard(rootFile,
|
|
21033
|
+
const groupDir = path71.join(TODO, folderName);
|
|
21034
|
+
const rootFile = path71.join(groupDir, "root.md");
|
|
21035
|
+
if (!fs69.existsSync(rootFile)) return null;
|
|
21036
|
+
const root2 = readCard(rootFile, path71.join(folderName, "root.md"));
|
|
20926
21037
|
if (!root2) return null;
|
|
20927
21038
|
root2.isGroup = true;
|
|
20928
21039
|
const { total, resolved: resolved2 } = subtaskLines(root2.body);
|
|
20929
21040
|
root2.subtaskLines = { total, resolved: resolved2 };
|
|
20930
21041
|
const subCards = [];
|
|
20931
21042
|
const recurse = (dir, relDir) => {
|
|
20932
|
-
for (const entry of
|
|
20933
|
-
const childRel =
|
|
21043
|
+
for (const entry of fs69.readdirSync(dir, { withFileTypes: true })) {
|
|
21044
|
+
const childRel = path71.join(relDir, entry.name);
|
|
20934
21045
|
if (entry.isDirectory()) {
|
|
20935
|
-
recurse(
|
|
21046
|
+
recurse(path71.join(dir, entry.name), childRel);
|
|
20936
21047
|
} else if (entry.name.endsWith(".md") && entry.name !== "README.md" && entry.name !== "root.md") {
|
|
20937
|
-
const c = readCard(
|
|
21048
|
+
const c = readCard(path71.join(dir, entry.name), childRel);
|
|
20938
21049
|
if (c) {
|
|
20939
21050
|
c.parent = { id: root2.id, title: root2.title };
|
|
20940
21051
|
subCards.push(c);
|
|
@@ -20955,12 +21066,12 @@ function readGroup2(folderName) {
|
|
|
20955
21066
|
return { root: root2, subCards };
|
|
20956
21067
|
}
|
|
20957
21068
|
function standaloneCards(dirRel) {
|
|
20958
|
-
const dir = dirRel ?
|
|
20959
|
-
if (!
|
|
21069
|
+
const dir = dirRel ? path71.join(TODO, dirRel) : TODO;
|
|
21070
|
+
if (!fs69.existsSync(dir)) return [];
|
|
20960
21071
|
const cards = [];
|
|
20961
|
-
for (const entry of
|
|
21072
|
+
for (const entry of fs69.readdirSync(dir, { withFileTypes: true })) {
|
|
20962
21073
|
if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
|
|
20963
|
-
const c = readCard(
|
|
21074
|
+
const c = readCard(path71.join(dir, entry.name), path71.join(dirRel, entry.name));
|
|
20964
21075
|
if (c) cards.push(c);
|
|
20965
21076
|
}
|
|
20966
21077
|
}
|
|
@@ -20972,7 +21083,7 @@ function collectCards() {
|
|
|
20972
21083
|
const top = standaloneCards("");
|
|
20973
21084
|
board2.push(...top);
|
|
20974
21085
|
every.push(...top);
|
|
20975
|
-
for (const entry of
|
|
21086
|
+
for (const entry of fs69.readdirSync(TODO, { withFileTypes: true })) {
|
|
20976
21087
|
if (!entry.isDirectory()) continue;
|
|
20977
21088
|
if (isGroupFolder(entry.name)) {
|
|
20978
21089
|
const g = readGroup2(entry.name);
|
|
@@ -21004,7 +21115,7 @@ function findCard(id) {
|
|
|
21004
21115
|
}
|
|
21005
21116
|
function attachSources(card) {
|
|
21006
21117
|
try {
|
|
21007
|
-
const { meta, body } = parseFrontmatter(
|
|
21118
|
+
const { meta, body } = parseFrontmatter(fs69.readFileSync(path71.join(TODO, card.relPath), "utf8"));
|
|
21008
21119
|
const sources2 = meta ? cardSources(meta, body) : [];
|
|
21009
21120
|
if (sources2.length) card.sources = sources2;
|
|
21010
21121
|
} catch {
|
|
@@ -21108,10 +21219,10 @@ var init_read = __esm({
|
|
|
21108
21219
|
});
|
|
21109
21220
|
|
|
21110
21221
|
// src/lib/group-close.ts
|
|
21111
|
-
import
|
|
21222
|
+
import fs70 from "node:fs";
|
|
21112
21223
|
function groupCloses(rootFile) {
|
|
21113
21224
|
try {
|
|
21114
|
-
return groupCloseOf(
|
|
21225
|
+
return groupCloseOf(fs70.readFileSync(rootFile, "utf8"));
|
|
21115
21226
|
} catch {
|
|
21116
21227
|
return false;
|
|
21117
21228
|
}
|
|
@@ -21124,12 +21235,12 @@ var init_group_close = __esm({
|
|
|
21124
21235
|
});
|
|
21125
21236
|
|
|
21126
21237
|
// src/commands/remove.ts
|
|
21127
|
-
import
|
|
21128
|
-
import
|
|
21238
|
+
import fs71 from "node:fs";
|
|
21239
|
+
import path72 from "node:path";
|
|
21129
21240
|
function leavingIds(id, found2) {
|
|
21130
21241
|
const ids = /* @__PURE__ */ new Set([id]);
|
|
21131
21242
|
if (found2.kind === "group") {
|
|
21132
|
-
const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f) =>
|
|
21243
|
+
const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f) => path72.basename(f));
|
|
21133
21244
|
for (const name of names3) {
|
|
21134
21245
|
const n = idPrefix(name);
|
|
21135
21246
|
if (n !== null) ids.add(n);
|
|
@@ -21141,10 +21252,10 @@ function findMentions(ids) {
|
|
|
21141
21252
|
const hits = [];
|
|
21142
21253
|
const re = new RegExp(ids.map((id) => `#${id}(?!\\d)`).join("|"));
|
|
21143
21254
|
for (const dir of [TODO, MEMORY]) {
|
|
21144
|
-
if (!
|
|
21255
|
+
if (!fs71.existsSync(dir)) continue;
|
|
21145
21256
|
for (const file of walkMd(dir)) {
|
|
21146
|
-
if (
|
|
21147
|
-
const lines =
|
|
21257
|
+
if (path72.basename(file) === "README.md") continue;
|
|
21258
|
+
const lines = fs71.readFileSync(file, "utf8").split("\n");
|
|
21148
21259
|
const fmEnd = frontmatterEnd(lines);
|
|
21149
21260
|
lines.forEach((line, i) => {
|
|
21150
21261
|
if (!re.test(line)) return;
|
|
@@ -21160,12 +21271,12 @@ function findMentions(ids) {
|
|
|
21160
21271
|
return hits;
|
|
21161
21272
|
}
|
|
21162
21273
|
function leavingCards(id, found2) {
|
|
21163
|
-
const own = found2.kind === "group" ?
|
|
21274
|
+
const own = found2.kind === "group" ? path72.join(found2.target, "root.md") : found2.target;
|
|
21164
21275
|
const cards = [{ id, file: own }];
|
|
21165
21276
|
if (found2.kind !== "group") return cards;
|
|
21166
21277
|
for (const file of walkMd(found2.target)) {
|
|
21167
21278
|
if (file === own) continue;
|
|
21168
|
-
const n = idPrefix(
|
|
21279
|
+
const n = idPrefix(path72.basename(file));
|
|
21169
21280
|
if (n !== null) cards.push({ id: n, file });
|
|
21170
21281
|
}
|
|
21171
21282
|
return cards;
|
|
@@ -21174,10 +21285,10 @@ function stampLeaving(cards, rejection) {
|
|
|
21174
21285
|
const day = formatDay();
|
|
21175
21286
|
const stamp4 = rejection && !rejection.discard ? { reason: rejection.reason, at: (/* @__PURE__ */ new Date()).toISOString(), by: insideRun() ? "agent" : "user" } : rejection && { reason: rejection.reason };
|
|
21176
21287
|
for (const card of cards) {
|
|
21177
|
-
if (!
|
|
21178
|
-
const text4 =
|
|
21288
|
+
if (!fs71.existsSync(card.file)) continue;
|
|
21289
|
+
const text4 = fs71.readFileSync(card.file, "utf8");
|
|
21179
21290
|
const stamped = stampLeavingIn(text4, day, stamp4);
|
|
21180
|
-
if (stamped !== text4)
|
|
21291
|
+
if (stamped !== text4) fs71.writeFileSync(card.file, stamped);
|
|
21181
21292
|
}
|
|
21182
21293
|
}
|
|
21183
21294
|
function unfinishedDelivery(id) {
|
|
@@ -21193,7 +21304,7 @@ function unfinishedDelivery(id) {
|
|
|
21193
21304
|
}[gap];
|
|
21194
21305
|
return `#${id} is not finished: ${what}.`;
|
|
21195
21306
|
}
|
|
21196
|
-
const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !
|
|
21307
|
+
const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs71.existsSync(path72.join(ASSETS, src.slice(".assets/".length))));
|
|
21197
21308
|
return missing ? `#${id} is not finished: ${missing} is not on this machine.` : null;
|
|
21198
21309
|
}
|
|
21199
21310
|
function agentDecisions(text4) {
|
|
@@ -21224,8 +21335,8 @@ function removeCard2(id, metric, options) {
|
|
|
21224
21335
|
const unfinished = metric === "completed" ? unfinishedDelivery(id) : null;
|
|
21225
21336
|
if (unfinished) die(unfinished, { kind: "plan-delivery-unfinished" });
|
|
21226
21337
|
const dest = options.cleanupDiscarded && locateArchived(id) ? null : archiveDest(found2);
|
|
21227
|
-
const cardFile3 = found2.kind === "group" ?
|
|
21228
|
-
const cardText =
|
|
21338
|
+
const cardFile3 = found2.kind === "group" ? path72.join(found2.target, "root.md") : found2.target;
|
|
21339
|
+
const cardText = fs71.existsSync(cardFile3) ? fs71.readFileSync(cardFile3, "utf8") : "";
|
|
21229
21340
|
const { meta: cardMeta3 } = parseFrontmatter(cardText);
|
|
21230
21341
|
const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f) => f !== cardFile3).map((f) => rel(f)).sort() : [];
|
|
21231
21342
|
const leftIds = leavingIds(id, found2);
|
|
@@ -21256,10 +21367,10 @@ function removeCard2(id, metric, options) {
|
|
|
21256
21367
|
const groupRoot = found2.kind === "file" && !options.closing ? enclosingGroupRoot(found2.target) : null;
|
|
21257
21368
|
if (dest) {
|
|
21258
21369
|
stampLeaving(leaving, metric === "rejected" ? { reason: options.reason?.trim() ?? "", discard: options.discard === true } : null);
|
|
21259
|
-
|
|
21260
|
-
|
|
21370
|
+
fs71.mkdirSync(ARCHIVE, { recursive: true });
|
|
21371
|
+
fs71.renameSync(found2.target, dest);
|
|
21261
21372
|
} else {
|
|
21262
|
-
|
|
21373
|
+
fs71.rmSync(found2.target, { recursive: true, force: true });
|
|
21263
21374
|
}
|
|
21264
21375
|
const removedRefs = stripReadmeRefs(found2);
|
|
21265
21376
|
let marked2 = null;
|
|
@@ -21308,14 +21419,14 @@ function removeCard2(id, metric, options) {
|
|
|
21308
21419
|
};
|
|
21309
21420
|
}
|
|
21310
21421
|
function closeGroup(rootFile) {
|
|
21311
|
-
const rootId = idPrefix(
|
|
21422
|
+
const rootId = idPrefix(path72.basename(path72.dirname(rootFile)));
|
|
21312
21423
|
if (rootId === null) return null;
|
|
21313
21424
|
if (runnerProject(KANBAN)) return null;
|
|
21314
21425
|
if (!groupCloses(rootFile)) return null;
|
|
21315
21426
|
say(`
|
|
21316
21427
|
every subtask line on #${rootId} is resolved \u2014 closing the group:`);
|
|
21317
21428
|
try {
|
|
21318
|
-
const { meta, body } = parseFrontmatter(
|
|
21429
|
+
const { meta, body } = parseFrontmatter(fs71.readFileSync(rootFile, "utf8"));
|
|
21319
21430
|
const res = cmdRemove(rootId, "completed", { closing: true });
|
|
21320
21431
|
return {
|
|
21321
21432
|
id: rootId,
|
|
@@ -21372,7 +21483,7 @@ function cleanupDiscardedCards(sessionId) {
|
|
|
21372
21483
|
if (card.pending) throw new Error(`Discarding #${card.id} did not finish. Retry the discard.`);
|
|
21373
21484
|
while (locate(card.id)) cmdRemove(card.id, "rejected", { discard: true, cleanupDiscarded: true });
|
|
21374
21485
|
dropCrossRefs(card.id);
|
|
21375
|
-
stripReadmeRefs({ kind: "file", rel:
|
|
21486
|
+
stripReadmeRefs({ kind: "file", rel: path72.relative(TODO, path72.resolve(REPO_ROOT, card.path)).split(path72.sep).join("/") });
|
|
21376
21487
|
}
|
|
21377
21488
|
return discarded.map((c) => c.id);
|
|
21378
21489
|
});
|
|
@@ -21380,8 +21491,8 @@ function cleanupDiscardedCards(sessionId) {
|
|
|
21380
21491
|
function recoveredArchiveHandoff(id, source) {
|
|
21381
21492
|
const found2 = locateArchived(id);
|
|
21382
21493
|
if (!found2) throw new Error(`No archived card #${id} was found.`);
|
|
21383
|
-
const file = found2.kind === "group" ?
|
|
21384
|
-
const { meta } = parseFrontmatter(
|
|
21494
|
+
const file = found2.kind === "group" ? path72.join(found2.target, "root.md") : found2.target;
|
|
21495
|
+
const { meta } = parseFrontmatter(fs71.readFileSync(file, "utf8"));
|
|
21385
21496
|
stripReadmeRefs(source ?? found2);
|
|
21386
21497
|
const root2 = source?.kind === "file" ? enclosingGroupRoot(source.target) : null;
|
|
21387
21498
|
if (root2) markSubtask(root2, id, "tick");
|
|
@@ -21457,6 +21568,30 @@ var init_agent_file = __esm({
|
|
|
21457
21568
|
}
|
|
21458
21569
|
});
|
|
21459
21570
|
|
|
21571
|
+
// src/commands/studio-file.ts
|
|
21572
|
+
function cmdStudioFile(askedStudio, askedFile) {
|
|
21573
|
+
const studio = askedStudio.trim();
|
|
21574
|
+
const files = studioFiles(studio);
|
|
21575
|
+
if (!files) die(`no studio ${studio}`, { kind: "no-such-studio", studio });
|
|
21576
|
+
const file = askedFile.trim().replace(/^\.\//, "");
|
|
21577
|
+
const readable = Object.keys(files).filter((f) => f === STUDIO_FILE || f.startsWith("shared/") || f.startsWith("agents/")).sort();
|
|
21578
|
+
if (!readable.includes(file) || isAboutFile(file)) {
|
|
21579
|
+
die(`${studio} has no ${file}. It has: ${readable.join(", ")}.`, { kind: "no-such-studio-file", studio, file });
|
|
21580
|
+
}
|
|
21581
|
+
const text4 = files[file];
|
|
21582
|
+
say(text4);
|
|
21583
|
+
return { studio, file, text: text4 };
|
|
21584
|
+
}
|
|
21585
|
+
var init_studio_file2 = __esm({
|
|
21586
|
+
"src/commands/studio-file.ts"() {
|
|
21587
|
+
"use strict";
|
|
21588
|
+
init_io();
|
|
21589
|
+
init_paths();
|
|
21590
|
+
init_studio_shared();
|
|
21591
|
+
init_studio_files();
|
|
21592
|
+
}
|
|
21593
|
+
});
|
|
21594
|
+
|
|
21460
21595
|
// src/commands/memory-file.ts
|
|
21461
21596
|
function cmdMemoryFile(askedName) {
|
|
21462
21597
|
const name = askedName.trim();
|
|
@@ -21670,6 +21805,7 @@ var init_local2 = __esm({
|
|
|
21670
21805
|
init_list();
|
|
21671
21806
|
init_remove();
|
|
21672
21807
|
init_agent_file();
|
|
21808
|
+
init_studio_file2();
|
|
21673
21809
|
init_memory_file();
|
|
21674
21810
|
init_validate2();
|
|
21675
21811
|
init_io();
|
|
@@ -21688,10 +21824,11 @@ var init_local2 = __esm({
|
|
|
21688
21824
|
archive: ({ args }) => cmdRemove(Number(args[0]), "completed"),
|
|
21689
21825
|
reject: ({ args, opts }) => cmdRemove(Number(args[0]), "rejected", as(opts)),
|
|
21690
21826
|
"agent-file": ({ args }) => cmdAgentFile(args[0] ?? "", args[1] ?? ""),
|
|
21827
|
+
file: ({ args }) => cmdStudioFile(args[0] ?? "", args[1] ?? ""),
|
|
21691
21828
|
"memory-file": ({ args }) => cmdMemoryFile(args[0] ?? "")
|
|
21692
21829
|
};
|
|
21693
21830
|
BOARD_MOVES = new Set(Object.keys(MOVES));
|
|
21694
|
-
READ_ONLY_MOVES = /* @__PURE__ */ new Set(["list", "validate", "agent-file", "memory-file"]);
|
|
21831
|
+
READ_ONLY_MOVES = /* @__PURE__ */ new Set(["list", "validate", "file", "agent-file", "memory-file"]);
|
|
21695
21832
|
leases = /* @__PURE__ */ new Map();
|
|
21696
21833
|
leaseCounter = 0;
|
|
21697
21834
|
}
|
|
@@ -21742,8 +21879,8 @@ var init_created_cards = __esm({
|
|
|
21742
21879
|
|
|
21743
21880
|
// src/lib/agent/creation.ts
|
|
21744
21881
|
import crypto4 from "node:crypto";
|
|
21745
|
-
import
|
|
21746
|
-
import
|
|
21882
|
+
import fs72 from "node:fs";
|
|
21883
|
+
import path73 from "node:path";
|
|
21747
21884
|
function creationError(error, triage) {
|
|
21748
21885
|
const zh = readLanguage() === "zh";
|
|
21749
21886
|
const messages = {
|
|
@@ -21769,12 +21906,12 @@ ${zh ? `\u539F\u6761\u76EE\u4ECD\u5728 triage\uFF1A${triage}\u3002${unreachable
|
|
|
21769
21906
|
function creationReceipt(request2, slot) {
|
|
21770
21907
|
const hash2 = crypto4.createHash("sha256").update(`${request2}
|
|
21771
21908
|
${slot}`).digest("hex");
|
|
21772
|
-
return
|
|
21909
|
+
return path73.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
|
|
21773
21910
|
}
|
|
21774
21911
|
function readCreation(file, said2) {
|
|
21775
21912
|
return withCreationLock(() => {
|
|
21776
21913
|
try {
|
|
21777
|
-
const held4 = JSON.parse(
|
|
21914
|
+
const held4 = JSON.parse(fs72.readFileSync(file, "utf8"));
|
|
21778
21915
|
if (!held4.said || typeof held4.said.title !== "string") throw new Error("Invalid creation journal");
|
|
21779
21916
|
return held4;
|
|
21780
21917
|
} catch (error) {
|
|
@@ -21786,10 +21923,10 @@ function readCreation(file, said2) {
|
|
|
21786
21923
|
});
|
|
21787
21924
|
}
|
|
21788
21925
|
function saveCreation(file, journal) {
|
|
21789
|
-
|
|
21926
|
+
fs72.mkdirSync(path73.dirname(file), { recursive: true });
|
|
21790
21927
|
const temp = `${file}.${crypto4.randomUUID()}.tmp`;
|
|
21791
|
-
|
|
21792
|
-
|
|
21928
|
+
fs72.writeFileSync(temp, JSON.stringify(journal));
|
|
21929
|
+
fs72.renameSync(temp, file);
|
|
21793
21930
|
}
|
|
21794
21931
|
function archiveCreation(source, id) {
|
|
21795
21932
|
if (readArchived().some((s) => s.sourceId === source && s.cardId === id)) return;
|
|
@@ -21803,7 +21940,7 @@ function archiveCreation(source, id) {
|
|
|
21803
21940
|
function triageFile(sourceId) {
|
|
21804
21941
|
const found2 = [...readInbox(), ...readAllDismissed(), ...readArchived()].find((s) => s.sourceId === sourceId.trim());
|
|
21805
21942
|
if (!found2) throw new BoardError(`nothing in triage is ${sourceId}`, { kind: "refused" });
|
|
21806
|
-
return
|
|
21943
|
+
return path73.basename(found2.relPath, ".md");
|
|
21807
21944
|
}
|
|
21808
21945
|
var init_creation = __esm({
|
|
21809
21946
|
"src/lib/agent/creation.ts"() {
|
|
@@ -21971,8 +22108,8 @@ __export(board_exports, {
|
|
|
21971
22108
|
buildBoardProgram: () => buildBoardProgram
|
|
21972
22109
|
});
|
|
21973
22110
|
import crypto5 from "node:crypto";
|
|
21974
|
-
import
|
|
21975
|
-
import
|
|
22111
|
+
import fs73 from "node:fs";
|
|
22112
|
+
import path74 from "node:path";
|
|
21976
22113
|
async function dispatch(move, cmd, args, opts, cli) {
|
|
21977
22114
|
const ctx = ctxOf(cmd, cli.program);
|
|
21978
22115
|
const data = await runAction(ctx, {}, async () => {
|
|
@@ -22012,7 +22149,7 @@ async function cloudCard(task, opts) {
|
|
|
22012
22149
|
let request2;
|
|
22013
22150
|
if (typeof opts.bodyFile === "string") {
|
|
22014
22151
|
try {
|
|
22015
|
-
request2 =
|
|
22152
|
+
request2 = fs73.readFileSync(opts.bodyFile, "utf8");
|
|
22016
22153
|
} catch {
|
|
22017
22154
|
}
|
|
22018
22155
|
}
|
|
@@ -22042,7 +22179,7 @@ async function cloudCard(task, opts) {
|
|
|
22042
22179
|
const file = creationReceipt(`${checked.value}:${requestId}`, slot);
|
|
22043
22180
|
const journal = readCreation(file, said2);
|
|
22044
22181
|
if (!journal.made) {
|
|
22045
|
-
const key = `akb-${
|
|
22182
|
+
const key = `akb-${path74.basename(file, ".json").slice(0, 40)}`;
|
|
22046
22183
|
const made = await createProjectTask(checked.value, journal.said, key);
|
|
22047
22184
|
if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
|
|
22048
22185
|
journal.made = made.value;
|
|
@@ -22092,9 +22229,10 @@ function buildBoardProgram(cli) {
|
|
|
22092
22229
|
move("validate").argument("[id]", ID, cardId).summary("validate card format and report file, line, and repair instructions").description("Check one card, or every open card when no id is given. Reads only; exits non-zero with detailed errors until the format is valid.").action(async function(id) {
|
|
22093
22230
|
await dispatch("validate", this, id === void 0 ? [] : [String(id)], this.opts(), cli);
|
|
22094
22231
|
});
|
|
22095
|
-
move("
|
|
22096
|
-
"
|
|
22097
|
-
)
|
|
22232
|
+
move("file").argument("<studio>", "the studio, e.g. blog-post").argument("<path>", "the file as `akb studio pull` lays it out: shared/\u2026 or agents/<name>/\u2026").summary("print one file of a studio").description("In a task's run, reads the version the task is pinned to; otherwise the current one.").action(async function(studio, file) {
|
|
22233
|
+
await dispatch("file", this, [studio, file], this.opts(), cli);
|
|
22234
|
+
});
|
|
22235
|
+
withShared(program2.command("agent-file", { hidden: true })).argument("<agent>").argument("<path>").action(async function(agent, file) {
|
|
22098
22236
|
await dispatch("agent-file", this, [agent, file], this.opts(), cli);
|
|
22099
22237
|
});
|
|
22100
22238
|
move("memory-file").argument("<name>", "the global memory").summary("print one global memory's rules, its MEMORY.md").description(
|
|
@@ -22170,17 +22308,17 @@ var init_board2 = __esm({
|
|
|
22170
22308
|
});
|
|
22171
22309
|
|
|
22172
22310
|
// src/lib/board-cli.ts
|
|
22173
|
-
import
|
|
22174
|
-
import
|
|
22311
|
+
import fs74 from "node:fs";
|
|
22312
|
+
import path75 from "node:path";
|
|
22175
22313
|
function useBoard(found2, dirNamed) {
|
|
22176
|
-
if (!found2.named && found2.board ===
|
|
22314
|
+
if (!found2.named && found2.board === path75.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
|
|
22177
22315
|
else setBoardDir(found2.board, found2.root);
|
|
22178
22316
|
useProjectState();
|
|
22179
22317
|
backfillCardStudios();
|
|
22180
22318
|
}
|
|
22181
22319
|
function whole(found2, move) {
|
|
22182
22320
|
if (move === MAKES_A_BOARD) return found2;
|
|
22183
|
-
if (!
|
|
22321
|
+
if (!fs74.existsSync(path75.join(found2.board, "todo"))) {
|
|
22184
22322
|
die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
|
|
22185
22323
|
kind: "board-incomplete",
|
|
22186
22324
|
dir: found2.root
|
|
@@ -22189,13 +22327,13 @@ function whole(found2, move) {
|
|
|
22189
22327
|
return found2;
|
|
22190
22328
|
}
|
|
22191
22329
|
function findBoardUpward(from, move) {
|
|
22192
|
-
let dir =
|
|
22330
|
+
let dir = path75.resolve(from);
|
|
22193
22331
|
for (; ; ) {
|
|
22194
|
-
if (hasBoard(dir)) return { root: dir, board:
|
|
22332
|
+
if (hasBoard(dir)) return { root: dir, board: path75.join(dir, "docs", "kanban") };
|
|
22195
22333
|
if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
|
|
22196
|
-
const kept2 =
|
|
22197
|
-
if (move !== MAKES_A_BOARD &&
|
|
22198
|
-
const up =
|
|
22334
|
+
const kept2 = path75.join(dir, ".akb", "kanban");
|
|
22335
|
+
if (move !== MAKES_A_BOARD && fs74.existsSync(path75.join(kept2, "todo"))) return { root: dir, board: kept2 };
|
|
22336
|
+
const up = path75.dirname(dir);
|
|
22199
22337
|
if (up === dir) return null;
|
|
22200
22338
|
dir = up;
|
|
22201
22339
|
}
|
|
@@ -22203,11 +22341,11 @@ function findBoardUpward(from, move) {
|
|
|
22203
22341
|
function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
22204
22342
|
const named2 = board2 ?? boardFromEnv();
|
|
22205
22343
|
if (named2) {
|
|
22206
|
-
const folder =
|
|
22207
|
-
if (!
|
|
22344
|
+
const folder = path75.resolve(cwd, named2);
|
|
22345
|
+
if (!fs74.existsSync(folder) && move !== MAKES_A_BOARD) {
|
|
22208
22346
|
die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
|
|
22209
22347
|
}
|
|
22210
|
-
if (
|
|
22348
|
+
if (fs74.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
|
|
22211
22349
|
die(`${folder} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
|
|
22212
22350
|
kind: "no-board",
|
|
22213
22351
|
dir: folder
|
|
@@ -22216,24 +22354,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
|
22216
22354
|
return { root: projectRootOf(folder), board: folder, named: true };
|
|
22217
22355
|
}
|
|
22218
22356
|
if (dir !== null) {
|
|
22219
|
-
const root2 =
|
|
22220
|
-
if (!
|
|
22221
|
-
const kept2 =
|
|
22222
|
-
if (!hasBoard(root2) && move !== MAKES_A_BOARD &&
|
|
22357
|
+
const root2 = path75.resolve(dir);
|
|
22358
|
+
if (!fs74.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
|
|
22359
|
+
const kept2 = path75.join(root2, ".akb", "kanban");
|
|
22360
|
+
if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs74.existsSync(path75.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
|
|
22223
22361
|
if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
|
|
22224
22362
|
die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
|
|
22225
22363
|
kind: "no-board",
|
|
22226
22364
|
dir: root2
|
|
22227
22365
|
});
|
|
22228
22366
|
}
|
|
22229
|
-
return whole({ root: root2, board:
|
|
22367
|
+
return whole({ root: root2, board: path75.join(root2, "docs", "kanban") }, move);
|
|
22230
22368
|
}
|
|
22231
22369
|
const found2 = findBoardUpward(cwd, move);
|
|
22232
22370
|
if (found2) return whole(found2, move);
|
|
22233
|
-
if (move === MAKES_A_BOARD) return { root:
|
|
22371
|
+
if (move === MAKES_A_BOARD) return { root: path75.resolve(cwd), board: path75.join(path75.resolve(cwd), "docs", "kanban") };
|
|
22234
22372
|
die(
|
|
22235
|
-
`no board here. Looked in ${
|
|
22236
|
-
{ kind: "no-board", dir:
|
|
22373
|
+
`no board here. Looked in ${path75.resolve(cwd)} and every folder above it for docs/kanban/. ${installHint}\uFF0C\u6216\u7528 --board \u6307\u5B9A\u5DF2\u6709\u770B\u677F\u3002`,
|
|
22374
|
+
{ kind: "no-board", dir: path75.resolve(cwd) }
|
|
22237
22375
|
);
|
|
22238
22376
|
}
|
|
22239
22377
|
function editDistance(a, b) {
|
|
@@ -22316,8 +22454,8 @@ var init_board_cli = __esm({
|
|
|
22316
22454
|
init_pointer();
|
|
22317
22455
|
init_card_studio_backfill();
|
|
22318
22456
|
MAKES_A_BOARD = "init";
|
|
22319
|
-
hasBoard = (dir) =>
|
|
22320
|
-
isBoardDir = (dir) =>
|
|
22457
|
+
hasBoard = (dir) => fs74.existsSync(path75.join(dir, "docs", "kanban"));
|
|
22458
|
+
isBoardDir = (dir) => fs74.existsSync(path75.join(dir, "todo")) && fs74.existsSync(path75.join(dir, "config.md"));
|
|
22321
22459
|
boardFromEnv = () => {
|
|
22322
22460
|
const named2 = process.env.AI4KANBAN_BOARD?.trim();
|
|
22323
22461
|
return named2 ? named2 : null;
|
|
@@ -22577,8 +22715,8 @@ var init_agent = __esm({
|
|
|
22577
22715
|
|
|
22578
22716
|
// src/commands/cloud-template.ts
|
|
22579
22717
|
import { createHash as createHash5 } from "node:crypto";
|
|
22580
|
-
import
|
|
22581
|
-
import
|
|
22718
|
+
import fs75 from "node:fs";
|
|
22719
|
+
import path76 from "node:path";
|
|
22582
22720
|
function usage2(problem, line) {
|
|
22583
22721
|
die(`${problem}
|
|
22584
22722
|
usage: ${line}`, { kind: "bad-args", bare: true, exitCode: 2 });
|
|
@@ -22655,10 +22793,10 @@ This template has no preview.`);
|
|
|
22655
22793
|
const written = [];
|
|
22656
22794
|
for (const p of previews) {
|
|
22657
22795
|
const bytes2 = Buffer.from(await (await ask(`/${at}/previews/${route(p.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
22658
|
-
const file =
|
|
22659
|
-
const out =
|
|
22660
|
-
|
|
22661
|
-
|
|
22796
|
+
const file = path76.basename(p.path);
|
|
22797
|
+
const out = path76.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
|
|
22798
|
+
fs75.mkdirSync(opts.to, { recursive: true });
|
|
22799
|
+
fs75.writeFileSync(out, bytes2);
|
|
22662
22800
|
written.push(out);
|
|
22663
22801
|
say(out);
|
|
22664
22802
|
}
|
|
@@ -22671,15 +22809,15 @@ async function templateGet(name, opts, program2) {
|
|
|
22671
22809
|
const { template } = await asJson(await ask(`/${at}`, {}, WITHOUT));
|
|
22672
22810
|
const fetched = [];
|
|
22673
22811
|
for (const f of template.files) {
|
|
22674
|
-
const out =
|
|
22675
|
-
if (!out.startsWith(
|
|
22812
|
+
const out = path76.resolve(to, f.path);
|
|
22813
|
+
if (!out.startsWith(path76.resolve(to) + path76.sep)) refuse3(T.corrupt, WITHOUT);
|
|
22676
22814
|
const bytes2 = Buffer.from(await (await ask(`/${at}/files/${route(f.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
22677
22815
|
if (bytes2.byteLength !== f.size || createHash5("sha256").update(bytes2).digest("hex") !== f.sha256) {
|
|
22678
22816
|
refuse3(T.corrupt, WITHOUT);
|
|
22679
22817
|
}
|
|
22680
22818
|
fetched.push({ out, bytes: bytes2 });
|
|
22681
22819
|
}
|
|
22682
|
-
const taken = fetched.filter((f) =>
|
|
22820
|
+
const taken = fetched.filter((f) => fs75.existsSync(f.out)).map((f) => path76.relative(to, f.out));
|
|
22683
22821
|
if (taken.length > 0) {
|
|
22684
22822
|
refuse3({
|
|
22685
22823
|
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`,
|
|
@@ -22687,8 +22825,8 @@ async function templateGet(name, opts, program2) {
|
|
|
22687
22825
|
});
|
|
22688
22826
|
}
|
|
22689
22827
|
for (const f of fetched) {
|
|
22690
|
-
|
|
22691
|
-
|
|
22828
|
+
fs75.mkdirSync(path76.dirname(f.out), { recursive: true });
|
|
22829
|
+
fs75.writeFileSync(f.out, f.bytes);
|
|
22692
22830
|
}
|
|
22693
22831
|
say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
|
|
22694
22832
|
Fetched ${name}: ${fetched.length} files into ${to}`);
|
|
@@ -22705,25 +22843,25 @@ async function templateSource(name, opts) {
|
|
|
22705
22843
|
say(`evidence: ${e.path}`);
|
|
22706
22844
|
continue;
|
|
22707
22845
|
}
|
|
22708
|
-
const out =
|
|
22709
|
-
|
|
22710
|
-
|
|
22846
|
+
const out = path76.join(opts.to, `${name}-${path76.basename(e.path)}`);
|
|
22847
|
+
fs75.mkdirSync(opts.to, { recursive: true });
|
|
22848
|
+
fs75.writeFileSync(out, Buffer.from(await (await ask(`/${at}/evidence/${route(e.path)}`)).arrayBuffer()));
|
|
22711
22849
|
written.push(out);
|
|
22712
22850
|
say(out);
|
|
22713
22851
|
}
|
|
22714
22852
|
return { name, source, evidence: written.length > 0 ? written : evidence.map((e) => e.path) };
|
|
22715
22853
|
}
|
|
22716
22854
|
async function templatePublish(dir, opts) {
|
|
22717
|
-
const root2 =
|
|
22718
|
-
const manifest =
|
|
22719
|
-
if (!
|
|
22720
|
-
const meta = readTemplateMeta(
|
|
22855
|
+
const root2 = path76.resolve(dir);
|
|
22856
|
+
const manifest = path76.join(root2, "template.md");
|
|
22857
|
+
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.");
|
|
22858
|
+
const meta = readTemplateMeta(fs75.readFileSync(manifest, "utf8"));
|
|
22721
22859
|
const files = walk2(root2);
|
|
22722
|
-
const total = files.reduce((sum, f) => sum +
|
|
22860
|
+
const total = files.reduce((sum, f) => sum + fs75.statSync(path76.join(root2, f)).size, 0);
|
|
22723
22861
|
if (total > MAX_BYTES3) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
|
|
22724
22862
|
for (const extra of [...opts.preview, ...opts.evidence]) {
|
|
22725
|
-
if (!
|
|
22726
|
-
if (
|
|
22863
|
+
if (!fs75.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
|
|
22864
|
+
if (path76.resolve(extra).startsWith(root2 + path76.sep)) {
|
|
22727
22865
|
invalid(
|
|
22728
22866
|
`${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`,
|
|
22729
22867
|
`${extra} is inside the template folder; keep previews and evidence outside it.`
|
|
@@ -22735,10 +22873,10 @@ async function templatePublish(dir, opts) {
|
|
|
22735
22873
|
}
|
|
22736
22874
|
const form = new FormData();
|
|
22737
22875
|
form.set("meta", JSON.stringify({ ...meta, replace: !!opts.replace }));
|
|
22738
|
-
const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([
|
|
22739
|
-
for (const f of files) add("files", f,
|
|
22740
|
-
for (const f of opts.preview) add("previews",
|
|
22741
|
-
for (const f of opts.evidence) add("evidence",
|
|
22876
|
+
const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs75.readFileSync(file)]), path76.basename(name));
|
|
22877
|
+
for (const f of files) add("files", f, path76.join(root2, f));
|
|
22878
|
+
for (const f of opts.preview) add("previews", path76.basename(f), f);
|
|
22879
|
+
for (const f of opts.evidence) add("evidence", path76.basename(f), f);
|
|
22742
22880
|
const done2 = await asJson(await ask("", { method: "POST", body: form }));
|
|
22743
22881
|
say(
|
|
22744
22882
|
done2.replaced ? `\u5DF2\u66FF\u6362 ${done2.name}\uFF1A${files.length} \u4E2A\u6587\u4EF6\u3002
|
|
@@ -22754,11 +22892,11 @@ Deleted ${name} from the catalog.`);
|
|
|
22754
22892
|
return { name, deleted: true };
|
|
22755
22893
|
}
|
|
22756
22894
|
async function templateShowcase(name, dir) {
|
|
22757
|
-
const file =
|
|
22758
|
-
if (!
|
|
22895
|
+
const file = path76.join(dir, "showcase.json");
|
|
22896
|
+
if (!fs75.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
|
|
22759
22897
|
let meta;
|
|
22760
22898
|
try {
|
|
22761
|
-
meta = JSON.parse(
|
|
22899
|
+
meta = JSON.parse(fs75.readFileSync(file, "utf8"));
|
|
22762
22900
|
} catch {
|
|
22763
22901
|
return invalid("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
|
|
22764
22902
|
}
|
|
@@ -22770,9 +22908,9 @@ async function templateShowcase(name, dir) {
|
|
|
22770
22908
|
const form = new FormData();
|
|
22771
22909
|
form.set("meta", JSON.stringify(meta));
|
|
22772
22910
|
for (const p of new Set(named2)) {
|
|
22773
|
-
const at =
|
|
22774
|
-
if (!
|
|
22775
|
-
form.append(`media:${p}`, new Blob([
|
|
22911
|
+
const at = path76.join(dir, p);
|
|
22912
|
+
if (!fs75.existsSync(at)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at}\u3002`, `${at} does not exist.`);
|
|
22913
|
+
form.append(`media:${p}`, new Blob([fs75.readFileSync(at)]), p);
|
|
22776
22914
|
}
|
|
22777
22915
|
const done2 = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
|
|
22778
22916
|
say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done2.files} \u4E2A\u6587\u4EF6\u3002
|
|
@@ -22781,7 +22919,7 @@ Updated ${name}'s showcase: ${done2.files} files.`);
|
|
|
22781
22919
|
}
|
|
22782
22920
|
function walk2(root2, sub = "") {
|
|
22783
22921
|
const out = [];
|
|
22784
|
-
for (const entry of
|
|
22922
|
+
for (const entry of fs75.readdirSync(path76.join(root2, sub), { withFileTypes: true })) {
|
|
22785
22923
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
22786
22924
|
const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
|
|
22787
22925
|
if (entry.isDirectory()) out.push(...walk2(root2, rel2));
|
|
@@ -22982,7 +23120,7 @@ var init_card_chat = __esm({
|
|
|
22982
23120
|
var update_studio_default;
|
|
22983
23121
|
var init_update_studio = __esm({
|
|
22984
23122
|
"src/guide/update-studio.md"() {
|
|
22985
|
-
update_studio_default = "# Update a studio\n\nChange one of this workspace's studios so new tasks run the new version.\n\n## How a studio works\n\nA studio is steerable: agents do the work, and a person reviews and fine-tunes only the parts where precision matters most, so the result stays reliable.\n\n- **Previews**: usually one preview agent shows the work, finished or a draft, where the person can fine-tune it; add another only when a part needs precision and a mistake there is costly, such as a developer tool's screens. Each shows only what the person decides on, without overlapping another. With none, the card the `STUDIO.md` body writes is the only review.\n- **Unreviewable previews**: when the user finds a preview unneeded or cannot judge it, remove it; a land agent checks that part instead, or nobody does.\n- **Stages**: one stage by default. Add `after` only when a draft is too costly to make before another is approved, such as a video's storyboard, which waits for its script.\n- **Minimal**: when the user outlines the studio, keep it that simple or simpler; add no review point or constraint they did not ask for, and let the trial show what else needs review.\n- **Judgment**: leave to an agent what it can judge; never add a hard rule for one case, and keep a rule only once real runs show it holds widely.\n- **Memory**: give an agent memory only where it has wide latitude and tends to err or be corrected to taste, naming those error-prone points as what it records; give a narrow agent none.\n- **Land**: everything else runs unattended after the last approval and follows the approved previews, such as building and merging a change; leave `land` empty when the last approved preview is the deliverable.\n- **Scheduled**: repeating work runs as a scheduled agent without previews; a studio may hold only scheduled agents.\n- **Agents**: write each as `akb guide write-agent` says.\n\n## The folder\n\n`akb studio pull` writes a studio as this folder:\n\n```text\n<folder>/\n\u251C\u2500\u2500 STUDIO.md frontmatter: `description`, what it does in one sentence; `when`, which requests\n\u2502 it is for, exceptions included; its agents under `previews`, `land`, `scheduled
|
|
23123
|
+
update_studio_default = "# Update a studio\n\nChange one of this workspace's studios so new tasks run the new version.\n\n## How a studio works\n\nA studio is steerable: agents do the work, and a person reviews and fine-tunes only the parts where precision matters most, so the result stays reliable.\n\n- **Previews**: usually one preview agent shows the work, finished or a draft, where the person can fine-tune it; add another only when a part needs precision and a mistake there is costly, such as a developer tool's screens. Each shows only what the person decides on, without overlapping another. With none, the card the `STUDIO.md` body writes is the only review.\n- **Unreviewable previews**: when the user finds a preview unneeded or cannot judge it, remove it; a land agent checks that part instead, or nobody does.\n- **Stages**: one stage by default. Add `after` only when a draft is too costly to make before another is approved, such as a video's storyboard, which waits for its script.\n- **Minimal**: when the user outlines the studio, keep it that simple or simpler; add no review point or constraint they did not ask for, and let the trial show what else needs review.\n- **Judgment**: leave to an agent what it can judge; never add a hard rule for one case, and keep a rule only once real runs show it holds widely.\n- **Memory**: give an agent memory only where it has wide latitude and tends to err or be corrected to taste, naming those error-prone points as what it records; give a narrow agent none.\n- **Shared**: what several of the studio's agents follow, run or remember belongs to the studio, never to one agent that the others point to.\n- **Card template**: put what every card of the studio starts from, such as its shared Todo steps, in `CARD.md`, not in the `STUDIO.md` body.\n- **Land**: everything else runs unattended after the last approval and follows the approved previews, such as building and merging a change; leave `land` empty when the last approved preview is the deliverable.\n- **Scheduled**: repeating work runs as a scheduled agent without previews; a studio may hold only scheduled agents.\n- **Agents**: write each as `akb guide write-agent` says.\n\n## The folder\n\n`akb studio pull` writes a studio as this folder:\n\n```text\n<folder>/\n\u251C\u2500\u2500 STUDIO.md frontmatter: `description`, what it does in one sentence; `when`, which requests\n\u2502 it is for, exceptions included; its agents under `previews`, `land`, `scheduled`;\n\u2502 `memoryFiles.workspace`, the studio memory shared by every project\n\u2502 body: how a card of this kind is written; every planning run on its cards reads it\n\u251C\u2500\u2500 CARD.md optional: the card template; the planner fits it to each card, such as its `## Todo`\n\u251C\u2500\u2500 shared/\n\u2502 \u251C\u2500\u2500 RULES.md terms and formats every agent follows; every run of the studio reads it\n\u2502 \u2514\u2500\u2500 \u2026 files any of its agents may read with `akb raw file <studio> shared/<path>`\n\u251C\u2500\u2500 agents/<name>/\n\u2502 \u251C\u2500\u2500 AGENT.md one agent: what its preview shows, or what its land or scheduled run does\n\u2502 \u2514\u2500\u2500 \u2026 files its AGENT.md points to\n\u2514\u2500\u2500 version.json the version pulled; push reads it, never edit it\n```\n\n## Versions\n\n- **Pinned**: a studio and the agents it holds live in Cloud as numbered versions; a task\n keeps the version it started with, and only tasks started after a push take the new one.\n- **Project agents**: agents under the board's `agents/` folder are the project's own; a\n studio may name them, but they are not part of its versions and an edit there applies to\n every card at once.\n- **Own studios only**: only the workspace's own studios take a new version; ask the user to\n copy a built-in or marketplace one on the web first.\n\n## Change it\n\n- **Standing preference**: when the user only wants a lasting rule for a studio or one of its\n agents and the flow itself stays, set it with `akb studio rule <studio>` or\n `akb studio instructions <agent>` instead of pushing; it reaches every task's later runs and\n works on built-in studios too. Either replaces all of them, so run it bare first to read the\n current ones, and keep each unless the user asks to change or drop it.\n- **Direct or task**: push directly a change the user spelled out; start a Studio builder task\n instead when the change adds, removes or restages agents, or when the user wants to review\n it before it applies.\n- **Steps**: `akb studio pull <id> <folder>`, edit the files there and keep what the request\n leaves alone, fix every problem `akb raw studio validate <folder>` reports, then\n `akb studio push <folder>`.\n- **Moved on**: when push says Cloud has a newer version, pull again and redo the change.\n- **Borrowed parts**: when an agent points to another agent's sections, files or memory\n folder, move them into `shared/`, `memoryFiles` and the studio memory folder, then push.\n";
|
|
22986
23124
|
}
|
|
22987
23125
|
});
|
|
22988
23126
|
|
|
@@ -23038,7 +23176,7 @@ var init_prune_memory = __esm({
|
|
|
23038
23176
|
var review_memory_default;
|
|
23039
23177
|
var init_review_memory = __esm({
|
|
23040
23178
|
"src/guide/review-memory.md"() {
|
|
23041
|
-
review_memory_default = "# Review what the conversations settled\n\nRead each conversation given to you right through, then write what it settled into memory.\n\nChats and planning flows write no memory themselves. One turn cannot see where an exchange\nis going, so a \"what if\" thrown out and taken back three turns later used to land as a\ndecision. You read the whole exchange, so you can tell a decision from a passing thought \u2014\nand that judgement is the whole job.\n\n- **Read what you are given**: each card comes in its own `<conversation>` block: its summary,\n its `Worth noting` and `Overruled by the user` lines, then its chat and the comments the user\n left reviewing it, when it had any, the user's words as written and the agent's replies,\n oldest first. The card is archived, so it is complete and reviewed this once; open no card or\n transcript file.\n- **Keep them apart**: judge each block by itself; what one conversation settled never\n becomes a note for another's card or agents.\n- **Hold to the same bar**: \"What earns a note\" in `akb guide board` governs what you write,\n exactly as it governs a flow that writes one. A conversation that settled nothing earns no\n note, and most do not \u2014 writing nothing is a complete result.\n- **Only what the user settled**: a durable preference, constraint, decision or correction\n they stated. Your own proposal is not their decision, and neither is a question, a \"what\n if\", or a direction the conversation then moved off.\n- **Take the last word**: where they said one thing and then another, the later one stands.\n Where a note already in the file says what they have since overturned, rewrite that note in\n place \u2014 never leave both and never add a second.\n- **Honour \"don't record this\"**: told in the conversation not to record something, write no\n note for it. If one is already there from an earlier review, delete it now.\n- **Where it goes**: a durable choice goes in the planner's `decisions.md` as one\n `**<key>**: <call>` line under the topic that fits, without its rationale; a design lesson\n goes in its `redesign.md` under the relevant topic as\n `- \u274C **<mistake>** \u2192 \u2705 <what the design should be instead, one line>.`, written as guidance\n for future tasks, not a history of the fix. Both go in the folder of the module each\n conversation is listed with (`akb guide board`). Each conversation also lists the agents\n whose sections its card holds and the memory files each keeps: where what was settled lands\n on one agent's own work, it goes in that agent's memory
|
|
23179
|
+
review_memory_default = "# Review what the conversations settled\n\nRead each conversation given to you right through, then write what it settled into memory.\n\nChats and planning flows write no memory themselves. One turn cannot see where an exchange\nis going, so a \"what if\" thrown out and taken back three turns later used to land as a\ndecision. You read the whole exchange, so you can tell a decision from a passing thought \u2014\nand that judgement is the whole job.\n\n- **Read what you are given**: each card comes in its own `<conversation>` block: its summary,\n its `Worth noting` and `Overruled by the user` lines, then its chat and the comments the user\n left reviewing it, when it had any, the user's words as written and the agent's replies,\n oldest first. The card is archived, so it is complete and reviewed this once; open no card or\n transcript file.\n- **Keep them apart**: judge each block by itself; what one conversation settled never\n becomes a note for another's card or agents.\n- **Hold to the same bar**: \"What earns a note\" in `akb guide board` governs what you write,\n exactly as it governs a flow that writes one. A conversation that settled nothing earns no\n note, and most do not \u2014 writing nothing is a complete result.\n- **Only what the user settled**: a durable preference, constraint, decision or correction\n they stated. Your own proposal is not their decision, and neither is a question, a \"what\n if\", or a direction the conversation then moved off.\n- **Take the last word**: where they said one thing and then another, the later one stands.\n Where a note already in the file says what they have since overturned, rewrite that note in\n place \u2014 never leave both and never add a second.\n- **Honour \"don't record this\"**: told in the conversation not to record something, write no\n note for it. If one is already there from an earlier review, delete it now.\n- **Where it goes**: a durable choice goes in the planner's `decisions.md` as one\n `**<key>**: <call>` line under the topic that fits, without its rationale; a design lesson\n goes in its `redesign.md` under the relevant topic as\n `- \u274C **<mistake>** \u2192 \u2705 <what the design should be instead, one line>.`, written as guidance\n for future tasks, not a history of the fix. Both go in the folder of the module each\n conversation is listed with (`akb guide board`). Each conversation also lists the agents\n whose sections its card holds and the memory files each keeps: where what was settled lands\n on one agent's own work, it goes in that agent's memory, or the studio's when its `shared/RULES.md`\n keeps it. Read those rules (`akb raw file <studio> agents/<agent>/AGENT.md`, `shared/RULES.md`)\n only then, and keep the memory the way they say.\n Distill settled feedback into reusable preferences (dos) and corrections (don'ts), retaining\n their scope; never copy raw reviews. An agent whose instructions name no memory gets no new file.\n- **What the card settled**: the summary says what the card was about and earns no note. A\n `Worth noting` line is a decision the user approved, by answering it or letting it stand, so\n it can be a choice but never a correction, and it earns a planner note only where the user's\n own words in the conversation back it; a line under\n `Overruled by the user` is a call the user reversed, so it goes in `redesign.md`: that of\n the agent whose section it came from, created there even if its instructions name other\n files, or the planner's when none did or its instructions name no memory.\n- **Change nothing else**: no card, no open question, no code. The memory\n files are the whole of what this run writes.\n- **Say what you wrote**: finish by reporting each conversation you read, and for each the\n notes you added, rewrote, deleted, or that you wrote none.\n";
|
|
23042
23180
|
}
|
|
23043
23181
|
});
|
|
23044
23182
|
|
|
@@ -23086,7 +23224,7 @@ var init_revise = __esm({
|
|
|
23086
23224
|
var preview_agent_default;
|
|
23087
23225
|
var init_preview_agent = __esm({
|
|
23088
23226
|
"src/guide/preview-agent.md"() {
|
|
23089
|
-
preview_agent_default = '# Be a preview agent\n\nYou are one preview agent on a card. Change only your own part: the ``## By `<agent-name>`\nagent`` section your instructions cover, its assets, your memory, and any file your\ninstructions tell you to write.\n\n- **Write**: edit your section in place above `<!-- agent -->`; do not duplicate it. Use\n `###` for subheadings.\n- **Finish your part**: write your planning content on the card now; never defer it to\n implementation.\n- **Components**: use the component documentation supplied with your run for embeds.\n- **Long drafts**: put a draft over about 20 lines in `<board-state>/assets/<card id>/<name>.md`\n and embed it as `<Asset src=".assets/<card id>/<name>.md">`; a shorter one goes in a code block.\n- **Memory**: `docs/kanban/memory/agents/<agent-name>/` is yours; keep only the files your\n instructions name, and edit one directly when you learn something lasting.\n- **User decisions**: follow `akb guide update-questions`; leave at most one open question,\n pointing to your section, appended with `--agent <agent-name>`.\n- **Validate**: run `akb raw validate <task-id>` and fix what it reports.\n';
|
|
23227
|
+
preview_agent_default = '# Be a preview agent\n\nYou are one preview agent on a card. Change only your own part: the ``## By `<agent-name>`\nagent`` section your instructions cover, its assets, your memory, and any file your\ninstructions tell you to write.\n\n- **Write**: edit your section in place above `<!-- agent -->`; do not duplicate it. Use\n `###` for subheadings.\n- **Finish your part**: write your planning content on the card now; never defer it to\n implementation.\n- **Rework**: when your section exists, redo only what the user names or an upstream change\n affects, and keep the rest, including its IDs, as it is.\n- **Components**: use the component documentation supplied with your run for embeds.\n- **Long drafts**: put a draft over about 20 lines in `<board-state>/assets/<card id>/<name>.md`\n and embed it as `<Asset src=".assets/<card id>/<name>.md">`; a shorter one goes in a code block.\n- **Memory**: `docs/kanban/memory/agents/<agent-name>/` is yours; keep only the files your\n instructions name, and edit one directly when you learn something lasting. Edit your\n studio\'s memory only as its rules say.\n- **User decisions**: follow `akb guide update-questions`; leave at most one open question,\n pointing to your section, appended with `--agent <agent-name>`.\n- **Validate**: run `akb raw validate <task-id>` and fix what it reports.\n';
|
|
23090
23228
|
}
|
|
23091
23229
|
});
|
|
23092
23230
|
|
|
@@ -23110,7 +23248,7 @@ var init_troubleshoot = __esm({
|
|
|
23110
23248
|
var write_agent_default;
|
|
23111
23249
|
var init_write_agent = __esm({
|
|
23112
23250
|
"src/guide/write-agent.md"() {
|
|
23113
|
-
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 Studio 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 studio, not the agent, sets its role: `STUDIO.md` lists it under `previews`, `land`\nor `scheduled`.\n\nA scheduled agent can also name the new input it works on; it then runs only when there is some:\n\n```yaml\nakb:\n # archived-cards | chats | dismissals; omit to run on its cadence alone.\n reads: archived-cards\n```\n\nA land agent that merges code into the target branch declares it; completing its step then\nrequires the merged commit and branch:\n\n```yaml\nakb:\n merges: true\n```\n\nAn agent that shares material with others names the global memories it keeps:\n\n```yaml\nakb:\n # Optional; global memories under `docs/kanban/memory/<name>/`, by name.\n memory: [competitors]\n # Optional; its own memory files, or folders ending in `/`, that hold in any of the user's\n # projects. Everything else is this project's.\n memoryFiles:\n workspace: [style.md]\n```\n\nEverything under the frontmatter is the agent's instructions, read fresh on every run \u2014\na file with none is refused.\n\nAn agent declares no options of its own. Two ways of working is two agents, each with its own\n`AGENT.md` \u2014 a switch that changes how one agent works costs more than it buys.\n\n## Translations\n\n```yaml\nakb:\n # Optional; UI text only. Runs use English; omitted text falls back to English.\n i18n:\n # Language tag; every field below is optional.\n en:\n # Display name, shown as the stage name: name the output, not the role; at most\n # 3 English words or 4 Chinese characters. Does not change the agent's name.\n title: UI copy\n zh:\n title: \u754C\u9762\u6587\u6848\n description: \u64B0\u5199\u754C\u9762\u4E0A\u7684\u6587\u5B57\u3002\n when: \u5361\u7247\u65B0\u589E\u6216\u4FEE\u6539\u754C\u9762\u6587\u5B57\u65F6\u3002\n```\n\n## Files\n\nEvery file beside `AGENT.md`, in any subfolder, is named to the run by its path and opened only\nwhen the work calls for it. Put long material there and keep `AGENT.md` short.\n\n- **Scripts**: every agent owns its task scripts in its own folder, including built-in agents.\n Keep business validation there, outside the CLI's board logic. Document the runtime, inputs\n and invocation beside the script; consumers use the owner's script. Built-in files can be\n saved through `akb raw
|
|
23251
|
+
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 Studio 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 studio, not the agent, sets its role: `STUDIO.md` lists it under `previews`, `land`\nor `scheduled`.\n\nA scheduled agent can also name the new input it works on; it then runs only when there is some:\n\n```yaml\nakb:\n # archived-cards | chats | dismissals; omit to run on its cadence alone.\n reads: archived-cards\n```\n\nA land agent that merges code into the target branch declares it; completing its step then\nrequires the merged commit and branch:\n\n```yaml\nakb:\n merges: true\n```\n\nAn agent that shares material with others names the global memories it keeps:\n\n```yaml\nakb:\n # Optional; global memories under `docs/kanban/memory/<name>/`, by name.\n memory: [competitors]\n # Optional; its own memory files, or folders ending in `/`, that hold in any of the user's\n # projects. Everything else is this project's.\n memoryFiles:\n workspace: [style.md]\n```\n\nEverything under the frontmatter is the agent's instructions, read fresh on every run \u2014\na file with none is refused. A preview agent already redoes only what the user names or an\nupstream change affects; state only how its own rework differs, such as what to re-render.\n\nAn agent declares no options of its own. Two ways of working is two agents, each with its own\n`AGENT.md` \u2014 a switch that changes how one agent works costs more than it buys.\n\n## Translations\n\n```yaml\nakb:\n # Optional; UI text only. Runs use English; omitted text falls back to English.\n i18n:\n # Language tag; every field below is optional.\n en:\n # Display name, shown as the stage name: name the output, not the role; at most\n # 3 English words or 4 Chinese characters. Does not change the agent's name.\n title: UI copy\n zh:\n title: \u754C\u9762\u6587\u6848\n description: \u64B0\u5199\u754C\u9762\u4E0A\u7684\u6587\u5B57\u3002\n when: \u5361\u7247\u65B0\u589E\u6216\u4FEE\u6539\u754C\u9762\u6587\u5B57\u65F6\u3002\n```\n\n## Files\n\nEvery file beside `AGENT.md`, in any subfolder, is named to the run by its path and opened only\nwhen the work calls for it. Put long material there and keep `AGENT.md` short.\n\n- **Shared files**: a file several agents of one studio use goes in the studio's `shared/`, never\n in one agent's folder for the others to borrow.\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 file <studio> <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; what several agents of one studio\nremember goes in the studio's `docs/kanban/memory/studios/<studio>/`, described in its\n`shared/RULES.md`. Keep none unless the agent has wide\nlatitude and its mistakes or the user's corrections should change its next output. Otherwise say\nin `AGENT.md`:\n\n- **Files**: each file and what it holds; `## General` for what always holds, and a heading per\n situation (a format, a recipe, a channel) for what holds only there.\n- **When**: which file to apply before which step, and which error-prone points, answers or\n corrections to record.\n- **What goes in**: lasting preferences, decisions and corrections only \u2014 never raw feedback,\n run history, or what the instructions already say.\n- **Shared material**: what other agents also use goes in a global memory under `akb.memory`;\n its rules arrive with every run, so `AGENT.md` never restates them.\n\n## Output\n\nDeclare the preview components the agent uses in `akb.components` (Asset, Compare, Storyboard, Set).\nTheir usage documentation is supplied with the run; omitted declarations default to Asset.\nUse `akb raw components --agent <name> --docs` or `--studio <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. Write the text as `akb guide write-prompt` says.\n\n## Work with the user\n\n- **Ask little**: settle what the request, the skill and the board already answer; ask the rest\n as `akb guide update-questions` does, and never ask again what is answered.\n- **State between runs**: ask how a scheduled agent should keep what its next run needs, and\n write the answer into `AGENT.md`; assume no file or format.\n- **Important choices**: give a recommendation and its tradeoff, and accept a free answer.\n- **Show each edit**: when changing an existing agent, show every changed file as a unified\n diff with context, followed by one sentence of reason.\n\n## Check it\n\n- **Validate before finishing**: after creating or editing an agent, run `akb raw previews`. Read all trigger conditions with `akb raw previews --triggers`.\n Fix every problem reported for its file under \"Problems on this board\", then run it again.\n Do not finish until the agent is accepted with no problems reported for it.\n- **`akb raw previews <name> <id> --print`** on a real card prints the whole prompt the agent will get:\n its instructions, the reference for each chosen setting, its files and its memory. Read it, and cut whatever the run does not need.\n- **Studio**: a new agent belongs to the studio it was created in and starts switched on;\n a preview agent joins the end of that studio's `previews`. `akb raw previews` refuses it while it is off.\n Switch it in that studio's `STUDIO.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 studio's `scheduled`.\n";
|
|
23114
23252
|
}
|
|
23115
23253
|
});
|
|
23116
23254
|
|
|
@@ -23126,7 +23264,7 @@ var init_write_prompt = __esm({
|
|
|
23126
23264
|
var writing_default;
|
|
23127
23265
|
var init_writing = __esm({
|
|
23128
23266
|
"src/guide/writing.md"() {
|
|
23129
|
-
writing_default = "# Write a card\n\nA card has a **human half** for review and a folded **agent half** for implementation.\nUse this order and keep the English section titles and empty scaffold sections:\n\n```text\n<One short paragraph: the problem and the intended result.>\n\n## Worth noting <- user's answers first, then material decisions; empty if none\n- **<decision>**: <chosen behavior and main cost in one sentence>\n\n## Worth noting after implementation\n- **<decision>**: <chosen behavior and main cost in one sentence>\n <- settled by the build; omit when empty; no logs or open questions\n\n## By `<name>` agent <- preview owned by that agent\n\n<!-- agent --> <- folded content starts here\n\n## Scope <- requirements, not rationale\n### Done when <- acceptance checklist, when supplied\n- [ ] <observable result>\n\n## Todo <- implementation only; finish planning before writing steps\n- [ ] <one build step>\n\n## Decided by the agent <- other decisions and non-obvious findings the build needs\n- **<decision>**: <answer and required action>\n### Overruled by the user <- superseded decisions, always last\n```\n\n- **Decisions**: use the material-decision test in `akb guide update-questions` for Worth noting;\n merge entries governed by one policy and keep only the decision and its main cost.\n- **Delivery boundary**: Worth noting after implementation never changes approved scope or\n blocks an ongoing delivery; the build must fix deviations or refer them to the user.\n- **Preview ownership**: produce preview sections only by running their agent; before changing\n owned content, read `akb raw
|
|
23267
|
+
writing_default = "# Write a card\n\nA card has a **human half** for review and a folded **agent half** for implementation.\nUse this order and keep the English section titles and empty scaffold sections:\n\n```text\n<One short paragraph: the problem and the intended result.>\n\n## Worth noting <- user's answers first, then material decisions; empty if none\n- **<decision>**: <chosen behavior and main cost in one sentence>\n\n## Worth noting after implementation\n- **<decision>**: <chosen behavior and main cost in one sentence>\n <- settled by the build; omit when empty; no logs or open questions\n\n## By `<name>` agent <- preview owned by that agent\n\n<!-- agent --> <- folded content starts here\n\n## Scope <- requirements, not rationale\n### Done when <- acceptance checklist, when supplied\n- [ ] <observable result>\n\n## Todo <- implementation only; finish planning before writing steps\n- [ ] <one build step>\n\n## Decided by the agent <- other decisions and non-obvious findings the build needs\n- **<decision>**: <answer and required action>\n### Overruled by the user <- superseded decisions, always last\n```\n\n- **Decisions**: use the material-decision test in `akb guide update-questions` for Worth noting;\n merge entries governed by one policy and keep only the decision and its main cost.\n- **Delivery boundary**: Worth noting after implementation never changes approved scope or\n blocks an ongoing delivery; the build must fix deviations or refer them to the user.\n- **Preview ownership**: produce preview sections only by running their agent; before changing\n owned content, read `akb raw file <studio> agents/<agent>/AGENT.md` and the studio's\n `shared/RULES.md`, then only the files needed for that change with `akb raw file <studio> <path>`;\n report unreadable rules before proceeding.\n- **Preserve work**: leave checked todos and supplied Done when checklists unchanged; append a\n todo to reverse completed work, and move user-overruled decisions to Overruled by the user\n until the card leaves no room to repeat them.\n- **Writing**: write clear behavior and necessary tradeoffs for a fresh reader, keep the human\n half self-contained, and state each fact once.\n- **Frontmatter**: never edit frontmatter by hand; use `akb raw create`, `update`, or\n `update-questions`.\n- **Validate**: run `akb raw validate <id>` after edits and fix every reported file and line.\n";
|
|
23130
23268
|
}
|
|
23131
23269
|
});
|
|
23132
23270
|
|
|
@@ -23243,8 +23381,8 @@ var init_guide2 = __esm({
|
|
|
23243
23381
|
});
|
|
23244
23382
|
|
|
23245
23383
|
// src/commands/studio.ts
|
|
23246
|
-
import
|
|
23247
|
-
import
|
|
23384
|
+
import fs76 from "node:fs";
|
|
23385
|
+
import path77 from "node:path";
|
|
23248
23386
|
function cmdStudioList() {
|
|
23249
23387
|
if (!studiosReachable().ok) die(NEEDS_CLOUD, "needs-cloud");
|
|
23250
23388
|
const offline2 = studiosOffline();
|
|
@@ -23285,17 +23423,17 @@ function cmdStudioDiagram(id, card) {
|
|
|
23285
23423
|
const agent = findSpecAgent(name);
|
|
23286
23424
|
return agent ? { ...agent, after: agentAfter(name) } : null;
|
|
23287
23425
|
});
|
|
23288
|
-
const file =
|
|
23289
|
-
|
|
23290
|
-
|
|
23426
|
+
const file = path77.join(ASSETS, String(cardId2), "studio.json");
|
|
23427
|
+
fs76.mkdirSync(path77.dirname(file), { recursive: true });
|
|
23428
|
+
fs76.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
|
|
23291
23429
|
`);
|
|
23292
23430
|
const tag = `<Studio src=".assets/${cardId2}/studio.json" label="${flow.name.replace(/"/g, "")}" />`;
|
|
23293
23431
|
say(tag);
|
|
23294
23432
|
return { file, tag, diagram };
|
|
23295
23433
|
}
|
|
23296
23434
|
function cmdStudioValidate(folder) {
|
|
23297
|
-
const dir =
|
|
23298
|
-
if (!
|
|
23435
|
+
const dir = path77.resolve(folder);
|
|
23436
|
+
if (!fs76.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder} is not a folder`, "bad-args");
|
|
23299
23437
|
const files = readStudioFolder(dir);
|
|
23300
23438
|
const read3 = parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE);
|
|
23301
23439
|
const def = "def" in read3 ? read3.def : null;
|
|
@@ -23316,26 +23454,26 @@ function cmdStudioValidate(folder) {
|
|
|
23316
23454
|
async function cmdStudioPull(id, folder) {
|
|
23317
23455
|
const cloudId = cloudIdOf(id);
|
|
23318
23456
|
if (!cloudId) found(id);
|
|
23319
|
-
const dir =
|
|
23320
|
-
if (
|
|
23457
|
+
const dir = path77.resolve(folder ?? id);
|
|
23458
|
+
if (fs76.existsSync(dir) && fs76.readdirSync(dir).length) die(`${folder ?? id} is not empty`, "bad-args");
|
|
23321
23459
|
const read3 = await call("GET", `/v1/studios/${encodeURIComponent(cloudId)}`);
|
|
23322
23460
|
if (!read3.ok) die(read3.error, read3.code === "not_found" ? "no-such-studio" : "cloud-refused");
|
|
23323
23461
|
const { version, files } = read3.value;
|
|
23324
23462
|
for (const [file, text4] of Object.entries({ ...files, [VERSION_FILE]: versionText(cloudId, version) })) {
|
|
23325
|
-
const full =
|
|
23326
|
-
|
|
23463
|
+
const full = path77.join(dir, ...file.split("/"));
|
|
23464
|
+
fs76.mkdirSync(path77.dirname(full), { recursive: true });
|
|
23327
23465
|
const data = isAboutFile(file) && !file.endsWith(".md") && /^data:[^;]+;base64,/.exec(text4);
|
|
23328
|
-
|
|
23466
|
+
fs76.writeFileSync(full, data ? Buffer.from(text4.slice(data[0].length), "base64") : text4);
|
|
23329
23467
|
}
|
|
23330
23468
|
const shown = folder ?? `./${id}`;
|
|
23331
23469
|
say(`Pulled ${id} v${version} into ${shown}.`);
|
|
23332
23470
|
return { id, version, folder: dir };
|
|
23333
23471
|
}
|
|
23334
23472
|
async function cmdStudioPush(folder, opts) {
|
|
23335
|
-
const dir =
|
|
23473
|
+
const dir = path77.resolve(folder);
|
|
23336
23474
|
let pulled = null;
|
|
23337
23475
|
try {
|
|
23338
|
-
pulled = JSON.parse(
|
|
23476
|
+
pulled = JSON.parse(fs76.readFileSync(path77.join(dir, VERSION_FILE), "utf8"));
|
|
23339
23477
|
} catch {
|
|
23340
23478
|
}
|
|
23341
23479
|
if (!pulled?.id || !Number.isInteger(pulled.version)) die(`${folder} was not written by \`akb studio pull\``, "bad-args");
|
|
@@ -23365,7 +23503,7 @@ async function cmdStudioPush(folder, opts) {
|
|
|
23365
23503
|
die(res.error, res.code === "bad_request" || res.code === "payload_too_large" ? "bad-studio" : "cloud-refused");
|
|
23366
23504
|
}
|
|
23367
23505
|
const next = res.value.version;
|
|
23368
|
-
|
|
23506
|
+
fs76.writeFileSync(path77.join(dir, VERSION_FILE), versionText(cloudId, next));
|
|
23369
23507
|
say(`Pushed ${id} v${next}. New tasks take it.`);
|
|
23370
23508
|
return { id, version: next, changed: true };
|
|
23371
23509
|
}
|
|
@@ -23373,7 +23511,7 @@ function noteText({ file, text: text4 }) {
|
|
|
23373
23511
|
if (file !== void 0 && text4 !== void 0) die("pass --file or --text, not both", "bad-args");
|
|
23374
23512
|
if (file !== void 0) {
|
|
23375
23513
|
try {
|
|
23376
|
-
return
|
|
23514
|
+
return fs76.readFileSync(file, "utf8").trim();
|
|
23377
23515
|
} catch {
|
|
23378
23516
|
die(`can't read ${file}`, "bad-args");
|
|
23379
23517
|
}
|
|
@@ -23598,8 +23736,8 @@ var init_complete = __esm({
|
|
|
23598
23736
|
});
|
|
23599
23737
|
|
|
23600
23738
|
// src/lib/agent/approve.ts
|
|
23601
|
-
import
|
|
23602
|
-
import
|
|
23739
|
+
import fs77 from "node:fs";
|
|
23740
|
+
import path78 from "node:path";
|
|
23603
23741
|
function approvalRequest(req) {
|
|
23604
23742
|
const id = req.id;
|
|
23605
23743
|
const card = id === void 0 ? null : findCard(id);
|
|
@@ -23617,12 +23755,12 @@ function advancePhase(id) {
|
|
|
23617
23755
|
const card = findCard(id);
|
|
23618
23756
|
const found2 = locate(id);
|
|
23619
23757
|
if (!card || !found2 || !awaitingApproval(card)) return { error: `#${id} is no longer waiting on approval.` };
|
|
23620
|
-
const file = found2.kind === "group" ?
|
|
23621
|
-
const { meta, body } = parseFrontmatter(
|
|
23758
|
+
const file = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
|
|
23759
|
+
const { meta, body } = parseFrontmatter(fs77.readFileSync(file, "utf8"));
|
|
23622
23760
|
if (!meta) return { error: `#${id} has no frontmatter` };
|
|
23623
23761
|
meta.phase = card.stage + 1;
|
|
23624
23762
|
meta.status = "todo";
|
|
23625
|
-
|
|
23763
|
+
fs77.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
|
|
23626
23764
|
return null;
|
|
23627
23765
|
}
|
|
23628
23766
|
var init_approve = __esm({
|
|
@@ -23745,16 +23883,16 @@ var init_start = __esm({
|
|
|
23745
23883
|
});
|
|
23746
23884
|
|
|
23747
23885
|
// src/lib/agent/task-chats.ts
|
|
23748
|
-
import
|
|
23749
|
-
import
|
|
23886
|
+
import fs78 from "node:fs";
|
|
23887
|
+
import path79 from "node:path";
|
|
23750
23888
|
function taskChatFile(task, home3) {
|
|
23751
23889
|
if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
|
|
23752
|
-
return
|
|
23890
|
+
return path79.join(taskChatsDir(home3), `${task}.jsonl`);
|
|
23753
23891
|
}
|
|
23754
23892
|
function readTaskChat(task, home3) {
|
|
23755
23893
|
let text4;
|
|
23756
23894
|
try {
|
|
23757
|
-
text4 =
|
|
23895
|
+
text4 = fs78.readFileSync(taskChatFile(task, home3), "utf8");
|
|
23758
23896
|
} catch {
|
|
23759
23897
|
return [];
|
|
23760
23898
|
}
|
|
@@ -23775,13 +23913,13 @@ var init_task_chats = __esm({
|
|
|
23775
23913
|
"use strict";
|
|
23776
23914
|
init_home();
|
|
23777
23915
|
TASK = /^[\w-]{1,100}$/;
|
|
23778
|
-
taskChatsDir = (home3 = machineHome()) =>
|
|
23916
|
+
taskChatsDir = (home3 = machineHome()) => path79.join(home3, "chats");
|
|
23779
23917
|
}
|
|
23780
23918
|
});
|
|
23781
23919
|
|
|
23782
23920
|
// src/lib/agent/memory-review.ts
|
|
23783
|
-
import
|
|
23784
|
-
import
|
|
23921
|
+
import fs79 from "node:fs";
|
|
23922
|
+
import path80 from "node:path";
|
|
23785
23923
|
function taskChatsToReview(tasks) {
|
|
23786
23924
|
const out = [];
|
|
23787
23925
|
for (const ref of [...new Set(tasks)]) {
|
|
@@ -23803,8 +23941,8 @@ function readArchived2(id) {
|
|
|
23803
23941
|
const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
|
|
23804
23942
|
if (!found2) return null;
|
|
23805
23943
|
try {
|
|
23806
|
-
const file = found2.kind === "group" ?
|
|
23807
|
-
const { meta, body } = parseFrontmatter(
|
|
23944
|
+
const file = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
|
|
23945
|
+
const { meta, body } = parseFrontmatter(fs79.readFileSync(file, "utf8"));
|
|
23808
23946
|
if (!meta) return null;
|
|
23809
23947
|
return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
|
|
23810
23948
|
} catch {
|
|
@@ -23873,17 +24011,17 @@ var init_memory_review = __esm({
|
|
|
23873
24011
|
});
|
|
23874
24012
|
|
|
23875
24013
|
// src/lib/agent/dismissal-review.ts
|
|
23876
|
-
import
|
|
23877
|
-
import
|
|
24014
|
+
import fs80 from "node:fs";
|
|
24015
|
+
import path81 from "node:path";
|
|
23878
24016
|
function rejectionsToReview() {
|
|
23879
|
-
const dir =
|
|
23880
|
-
if (!
|
|
24017
|
+
const dir = path81.join(ARCHIVE, REJECTIONS_TO_REVIEW);
|
|
24018
|
+
if (!fs80.existsSync(dir)) return [];
|
|
23881
24019
|
const found2 = [];
|
|
23882
24020
|
for (const file of walkMd(dir)) {
|
|
23883
24021
|
const id = archivedId(file);
|
|
23884
24022
|
if (id === null) continue;
|
|
23885
24023
|
try {
|
|
23886
|
-
const { meta } = parseFrontmatter(
|
|
24024
|
+
const { meta } = parseFrontmatter(fs80.readFileSync(file, "utf8"));
|
|
23887
24025
|
if (!meta?.rejected || meta.rejected_by !== "user" || !meta.rejected_reason.trim()) continue;
|
|
23888
24026
|
found2.push({ id, title: meta.title, file: rel(file), reason: meta.rejected_reason.trim(), rejectedAt: meta.rejected_at });
|
|
23889
24027
|
} catch {
|
|
@@ -23913,7 +24051,7 @@ function citedSources(text4) {
|
|
|
23913
24051
|
function withdrawnSources() {
|
|
23914
24052
|
const cited = [...new Set(plannerCopies("rejected.md").flatMap((file) => {
|
|
23915
24053
|
try {
|
|
23916
|
-
return citedSources(
|
|
24054
|
+
return citedSources(fs80.readFileSync(file, "utf8"));
|
|
23917
24055
|
} catch {
|
|
23918
24056
|
return [];
|
|
23919
24057
|
}
|
|
@@ -23938,8 +24076,8 @@ var init_dismissal_review = __esm({
|
|
|
23938
24076
|
});
|
|
23939
24077
|
|
|
23940
24078
|
// src/lib/agent/flow.ts
|
|
23941
|
-
import
|
|
23942
|
-
import
|
|
24079
|
+
import fs81 from "node:fs";
|
|
24080
|
+
import path82 from "node:path";
|
|
23943
24081
|
function readCard2(id, home3 = "board") {
|
|
23944
24082
|
const pending = activeDelivery(id)?.completions?.some((c) => !c.finished);
|
|
23945
24083
|
const found2 = home3 === "archive" ? locateArchived(id) : locate(id) ?? (pending ? locateArchived(id) : null);
|
|
@@ -23949,10 +24087,10 @@ function readCard2(id, home3 = "board") {
|
|
|
23949
24087
|
{ kind: "card-not-found", id }
|
|
23950
24088
|
);
|
|
23951
24089
|
}
|
|
23952
|
-
const file = found2.kind === "group" ?
|
|
24090
|
+
const file = found2.kind === "group" ? path82.join(found2.target, "root.md") : found2.target;
|
|
23953
24091
|
let text4;
|
|
23954
24092
|
try {
|
|
23955
|
-
text4 =
|
|
24093
|
+
text4 = fs81.readFileSync(file, "utf8");
|
|
23956
24094
|
} catch {
|
|
23957
24095
|
die(`#${id} is on the board but ${rel(file)} can't be read.`, { kind: "card-unreadable", id });
|
|
23958
24096
|
}
|
|
@@ -24768,7 +24906,7 @@ __export(watch_exports, {
|
|
|
24768
24906
|
watchRun: () => watchRun
|
|
24769
24907
|
});
|
|
24770
24908
|
import { spawn as spawn3 } from "node:child_process";
|
|
24771
|
-
import
|
|
24909
|
+
import fs82 from "node:fs";
|
|
24772
24910
|
async function watchRun(sessionId, resume = startResume) {
|
|
24773
24911
|
const spec = readSpec(sessionId);
|
|
24774
24912
|
const run2 = peekRun(sessionId);
|
|
@@ -24804,11 +24942,11 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
24804
24942
|
const record = claimed ?? run2;
|
|
24805
24943
|
const sub = record.action === "sub";
|
|
24806
24944
|
if (claim) await setCardStatus(claim.cardId, claim.status);
|
|
24807
|
-
|
|
24808
|
-
const logFile =
|
|
24945
|
+
fs82.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
24946
|
+
const logFile = fs82.createWriteStream(record.logPath, { flags: "a" });
|
|
24809
24947
|
logFile.on("error", () => {
|
|
24810
24948
|
});
|
|
24811
|
-
const eventsFile =
|
|
24949
|
+
const eventsFile = fs82.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
|
|
24812
24950
|
eventsFile.on("error", () => {
|
|
24813
24951
|
});
|
|
24814
24952
|
const event2 = (e) => eventsFile.write(`${JSON.stringify(e)}
|
|
@@ -25378,8 +25516,8 @@ var init_watch = __esm({
|
|
|
25378
25516
|
});
|
|
25379
25517
|
|
|
25380
25518
|
// src/commands/run.ts
|
|
25381
|
-
import
|
|
25382
|
-
import
|
|
25519
|
+
import fs83 from "node:fs";
|
|
25520
|
+
import path83 from "node:path";
|
|
25383
25521
|
async function cmdStartRun(action, args, opts, program2 = "akb") {
|
|
25384
25522
|
const { req, follow: follow2, print } = readRequest(action, args, opts);
|
|
25385
25523
|
if (Number.isInteger(req.id)) {
|
|
@@ -25595,7 +25733,7 @@ async function cmdSubStart(words, opts) {
|
|
|
25595
25733
|
let prompt = words.join(" ");
|
|
25596
25734
|
if (opts.file) {
|
|
25597
25735
|
try {
|
|
25598
|
-
prompt =
|
|
25736
|
+
prompt = fs83.readFileSync(path83.resolve(opts.file), "utf8");
|
|
25599
25737
|
} catch {
|
|
25600
25738
|
die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
|
|
25601
25739
|
}
|
|
@@ -25962,7 +26100,7 @@ var init_signals = __esm({
|
|
|
25962
26100
|
});
|
|
25963
26101
|
|
|
25964
26102
|
// src/commands/triage.ts
|
|
25965
|
-
import
|
|
26103
|
+
import fs84 from "node:fs";
|
|
25966
26104
|
async function cmdTriageAdd(opts) {
|
|
25967
26105
|
const title = (opts.title ?? "").trim();
|
|
25968
26106
|
if (!title) die('say what it is: --title "<one line>"', { kind: "needs-input" });
|
|
@@ -25972,7 +26110,7 @@ async function cmdTriageAdd(opts) {
|
|
|
25972
26110
|
let body = opts.text;
|
|
25973
26111
|
if (opts.file !== void 0) {
|
|
25974
26112
|
try {
|
|
25975
|
-
body =
|
|
26113
|
+
body = fs84.readFileSync(opts.file, "utf8");
|
|
25976
26114
|
} catch {
|
|
25977
26115
|
die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
|
|
25978
26116
|
}
|
|
@@ -26643,15 +26781,15 @@ var init_agent2 = __esm({
|
|
|
26643
26781
|
});
|
|
26644
26782
|
|
|
26645
26783
|
// src/kanban.ts
|
|
26646
|
-
import
|
|
26784
|
+
import fs87 from "node:fs";
|
|
26647
26785
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
26648
26786
|
|
|
26649
26787
|
// src/lib/cli/akb.ts
|
|
26650
26788
|
init_agent2();
|
|
26651
26789
|
|
|
26652
26790
|
// src/lib/cli/setup.ts
|
|
26653
|
-
import
|
|
26654
|
-
import
|
|
26791
|
+
import fs86 from "node:fs";
|
|
26792
|
+
import path85 from "node:path";
|
|
26655
26793
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
26656
26794
|
|
|
26657
26795
|
// src/commands/update.ts
|
|
@@ -26665,8 +26803,8 @@ init_paths();
|
|
|
26665
26803
|
init_memory();
|
|
26666
26804
|
init_yaml2();
|
|
26667
26805
|
init_version();
|
|
26668
|
-
import
|
|
26669
|
-
import
|
|
26806
|
+
import fs85 from "node:fs";
|
|
26807
|
+
import path84 from "node:path";
|
|
26670
26808
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
26671
26809
|
var NAME = "wildcrane";
|
|
26672
26810
|
var REPO = "https://github.com/wildcrane-ai/wildcrane";
|
|
@@ -26688,10 +26826,10 @@ var Report = class {
|
|
|
26688
26826
|
for (const line of this.notes) say(` ! ${line}`);
|
|
26689
26827
|
}
|
|
26690
26828
|
};
|
|
26691
|
-
var read2 = (file) =>
|
|
26829
|
+
var read2 = (file) => fs85.existsSync(file) ? fs85.readFileSync(file, "utf8") : null;
|
|
26692
26830
|
function statOf(p) {
|
|
26693
26831
|
try {
|
|
26694
|
-
return
|
|
26832
|
+
return fs85.lstatSync(p);
|
|
26695
26833
|
} catch {
|
|
26696
26834
|
return null;
|
|
26697
26835
|
}
|
|
@@ -26716,10 +26854,10 @@ async function cmdUpdate2(ctx) {
|
|
|
26716
26854
|
return { updated: ctx.dir, from, to: SKILL_VERSION };
|
|
26717
26855
|
}
|
|
26718
26856
|
async function repairBoard(root2, report3, named2) {
|
|
26719
|
-
const legacy2 =
|
|
26720
|
-
const kept2 =
|
|
26721
|
-
const board2 = named2 ?? (
|
|
26722
|
-
if (!
|
|
26857
|
+
const legacy2 = path84.join(root2, "docs", "kanban");
|
|
26858
|
+
const kept2 = path84.join(root2, ".akb", "kanban");
|
|
26859
|
+
const board2 = named2 ?? (fs85.existsSync(legacy2) ? legacy2 : kept2);
|
|
26860
|
+
if (!fs85.existsSync(board2)) {
|
|
26723
26861
|
report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
|
|
26724
26862
|
return false;
|
|
26725
26863
|
}
|
|
@@ -26750,20 +26888,20 @@ function moveRuntimes(root2, board2, report3) {
|
|
|
26750
26888
|
}
|
|
26751
26889
|
}
|
|
26752
26890
|
function moveLegacyMemory(board2, report3) {
|
|
26753
|
-
const memory =
|
|
26891
|
+
const memory = path84.join(board2, "memory");
|
|
26754
26892
|
const moved = [];
|
|
26755
26893
|
for (const name of MEMORY_FILES) {
|
|
26756
|
-
const from =
|
|
26894
|
+
const from = path84.join(board2, name);
|
|
26757
26895
|
const st = statOf(from);
|
|
26758
26896
|
if (!st || !st.isFile()) continue;
|
|
26759
|
-
|
|
26760
|
-
const to =
|
|
26897
|
+
fs85.mkdirSync(memory, { recursive: true });
|
|
26898
|
+
const to = path84.join(memory, name);
|
|
26761
26899
|
const there = read2(to);
|
|
26762
26900
|
if (there === null) {
|
|
26763
|
-
|
|
26901
|
+
fs85.renameSync(from, to);
|
|
26764
26902
|
moved.push(name);
|
|
26765
26903
|
} else if (there === read2(from)) {
|
|
26766
|
-
|
|
26904
|
+
fs85.rmSync(from);
|
|
26767
26905
|
moved.push(name);
|
|
26768
26906
|
} else {
|
|
26769
26907
|
report3.notes.push(`both docs/kanban/${name} and docs/kanban/memory/${name} exist and differ \u2014 merge them by hand`);
|
|
@@ -26772,23 +26910,23 @@ function moveLegacyMemory(board2, report3) {
|
|
|
26772
26910
|
if (moved.length) report3.did.push(`moved the memory set into docs/kanban/memory/: ${moved.join(", ")}`);
|
|
26773
26911
|
}
|
|
26774
26912
|
function dropRecordFile(board2) {
|
|
26775
|
-
const file =
|
|
26776
|
-
if (!
|
|
26777
|
-
|
|
26913
|
+
const file = path84.join(board2, "record.csv");
|
|
26914
|
+
if (!fs85.existsSync(file)) return null;
|
|
26915
|
+
fs85.rmSync(file);
|
|
26778
26916
|
return "removed docs/kanban/record.csv (the planning scores it fed are gone)";
|
|
26779
26917
|
}
|
|
26780
26918
|
function dropModuleGoals(board2, report3) {
|
|
26781
|
-
const memory =
|
|
26782
|
-
if (!
|
|
26783
|
-
const root2 = read2(
|
|
26919
|
+
const memory = path84.join(board2, "memory");
|
|
26920
|
+
if (!fs85.existsSync(memory)) return;
|
|
26921
|
+
const root2 = read2(path84.join(memory, "goal.md"));
|
|
26784
26922
|
let dropped = 0;
|
|
26785
|
-
for (const entry of
|
|
26923
|
+
for (const entry of fs85.readdirSync(memory, { withFileTypes: true })) {
|
|
26786
26924
|
if (!entry.isDirectory()) continue;
|
|
26787
|
-
const file =
|
|
26925
|
+
const file = path84.join(memory, entry.name, "goal.md");
|
|
26788
26926
|
const text4 = read2(file);
|
|
26789
26927
|
if (text4 === null) continue;
|
|
26790
26928
|
if (text4 === root2 || text4.includes(UNFILLED) || !goalWords(text4)) {
|
|
26791
|
-
|
|
26929
|
+
fs85.rmSync(file);
|
|
26792
26930
|
dropped++;
|
|
26793
26931
|
} else {
|
|
26794
26932
|
report3.notes.push(
|
|
@@ -26810,10 +26948,10 @@ var PLAN_LEADS = {
|
|
|
26810
26948
|
var GONE_LEADS = ["software-planner", "planner"];
|
|
26811
26949
|
function planLeads(board2) {
|
|
26812
26950
|
const leads = { ...PLAN_LEADS };
|
|
26813
|
-
const root2 =
|
|
26814
|
-
for (const entry of
|
|
26951
|
+
const root2 = path84.join(board2, "studios");
|
|
26952
|
+
for (const entry of fs85.existsSync(root2) ? fs85.readdirSync(root2, { withFileTypes: true }) : []) {
|
|
26815
26953
|
if (!entry.isDirectory()) continue;
|
|
26816
|
-
const meta = splitFrontmatter(read2(
|
|
26954
|
+
const meta = splitFrontmatter(read2(path84.join(root2, entry.name, "STUDIO.md")) ?? "").meta;
|
|
26817
26955
|
const stages = meta === null ? void 0 : parseYamlBlock(meta).stages;
|
|
26818
26956
|
const plan = stages && typeof stages === "object" && !Array.isArray(stages) ? stages.plan : void 0;
|
|
26819
26957
|
const lead = plan && typeof plan === "object" && !Array.isArray(plan) && typeof plan.lead === "string" ? plan.lead.trim() : "";
|
|
@@ -26822,30 +26960,30 @@ function planLeads(board2) {
|
|
|
26822
26960
|
return leads;
|
|
26823
26961
|
}
|
|
26824
26962
|
function movePlanRules(board2, report3) {
|
|
26825
|
-
const rules =
|
|
26963
|
+
const rules = path84.join(board2, "rules");
|
|
26826
26964
|
const moved = [];
|
|
26827
26965
|
for (const [id, leads] of Object.entries(planLeads(board2))) {
|
|
26828
26966
|
for (const lead of leads) {
|
|
26829
|
-
const from =
|
|
26967
|
+
const from = path84.join(rules, `${lead}.md`);
|
|
26830
26968
|
const rule = read2(from)?.trim();
|
|
26831
26969
|
if (!rule) continue;
|
|
26832
|
-
const to =
|
|
26970
|
+
const to = path84.join(rules, "studios", `${id}.md`);
|
|
26833
26971
|
const there = read2(to)?.trim() ?? "";
|
|
26834
26972
|
if (!there.includes(rule)) {
|
|
26835
|
-
|
|
26836
|
-
|
|
26973
|
+
fs85.mkdirSync(path84.dirname(to), { recursive: true });
|
|
26974
|
+
fs85.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
|
|
26837
26975
|
`);
|
|
26838
26976
|
moved.push(`${lead} \u2192 ${id}`);
|
|
26839
26977
|
}
|
|
26840
26978
|
}
|
|
26841
26979
|
}
|
|
26842
|
-
for (const lead of GONE_LEADS)
|
|
26980
|
+
for (const lead of GONE_LEADS) fs85.rmSync(path84.join(rules, `${lead}.md`), { force: true });
|
|
26843
26981
|
if (moved.length) report3.did.push(`made each plan agent's rule its studio's card rule (docs/kanban/rules/studios/): ${moved.join(", ")}`);
|
|
26844
26982
|
}
|
|
26845
26983
|
function noteOldStudios(board2, report3) {
|
|
26846
26984
|
const old = (dir, file, keys) => {
|
|
26847
|
-
const root2 =
|
|
26848
|
-
return (
|
|
26985
|
+
const root2 = path84.join(board2, dir);
|
|
26986
|
+
return (fs85.existsSync(root2) ? fs85.readdirSync(root2, { withFileTypes: true }) : []).filter((e) => e.isDirectory() && keys.test(splitFrontmatter(read2(path84.join(root2, e.name, file)) ?? "").meta ?? "")).map((e) => `docs/kanban/${dir}/${e.name}/${file}`);
|
|
26849
26987
|
};
|
|
26850
26988
|
const files = [...old("studios", "STUDIO.md", /^(stages|delivers):/m), ...old("agents", "AGENT.md", /^\s+(hook|lead):/m)];
|
|
26851
26989
|
if (files.length) {
|
|
@@ -26855,7 +26993,7 @@ function noteOldStudios(board2, report3) {
|
|
|
26855
26993
|
}
|
|
26856
26994
|
}
|
|
26857
26995
|
function checkConfig(board2, report3) {
|
|
26858
|
-
const current = read2(
|
|
26996
|
+
const current = read2(path84.join(board2, "config.md"));
|
|
26859
26997
|
if (!current) return;
|
|
26860
26998
|
const added = missingConfigKeys(current);
|
|
26861
26999
|
if (added.length) {
|
|
@@ -26865,7 +27003,7 @@ function checkConfig(board2, report3) {
|
|
|
26865
27003
|
}
|
|
26866
27004
|
}
|
|
26867
27005
|
function checkModules(board2, report3) {
|
|
26868
|
-
const map2 = read2(
|
|
27006
|
+
const map2 = read2(path84.join(board2, "modules.md"));
|
|
26869
27007
|
if (map2 && map2.includes(UNFILLED)) {
|
|
26870
27008
|
report3.notes.push(
|
|
26871
27009
|
"docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
|
|
@@ -26919,14 +27057,14 @@ function declareSetup(program2, cli) {
|
|
|
26919
27057
|
program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
|
|
26920
27058
|
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");
|
|
26921
27059
|
const where = (cmd) => {
|
|
26922
|
-
const dir =
|
|
26923
|
-
if (!
|
|
27060
|
+
const dir = path85.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
|
|
27061
|
+
if (!fs86.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
|
|
26924
27062
|
return dir;
|
|
26925
27063
|
};
|
|
26926
27064
|
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() {
|
|
26927
27065
|
const dir = where(this);
|
|
26928
27066
|
const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
|
|
26929
|
-
const board2 = named2 ?
|
|
27067
|
+
const board2 = named2 ? path85.resolve(cli.cwd, named2) : null;
|
|
26930
27068
|
await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
|
|
26931
27069
|
});
|
|
26932
27070
|
program2.command("__rules", { hidden: true }).action(function() {
|
|
@@ -26971,7 +27109,7 @@ function invokedDirectly() {
|
|
|
26971
27109
|
const entry = process.argv[1];
|
|
26972
27110
|
if (!entry) return false;
|
|
26973
27111
|
try {
|
|
26974
|
-
return
|
|
27112
|
+
return fs87.realpathSync(entry) === fs87.realpathSync(SELF2);
|
|
26975
27113
|
} catch {
|
|
26976
27114
|
return false;
|
|
26977
27115
|
}
|