wildcrane 0.11.39 → 0.11.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kanban.mjs +684 -556
- 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.40 — 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.40",
|
|
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
|
}
|
|
@@ -9193,8 +9195,8 @@ var init_roles = __esm({
|
|
|
9193
9195
|
});
|
|
9194
9196
|
|
|
9195
9197
|
// src/lib/shared/board-files.ts
|
|
9196
|
-
function studioRenamed(
|
|
9197
|
-
const to =
|
|
9198
|
+
function studioRenamed(path86, content) {
|
|
9199
|
+
const to = path86.replace(/^(rules\/)?workflows\//, "$1studios/").replace(/^(studios\/[^/]+)\/WORKFLOW\.md$/, "$1/STUDIO.md");
|
|
9198
9200
|
if (!to.endsWith(".md")) return { path: to, content };
|
|
9199
9201
|
if (to.startsWith("studios/")) return { path: to, content: content.replace(/^(icon:\s*["']?)workflow(-kit)?(["']?\s*)$/gm, "$1studio$2$3") };
|
|
9200
9202
|
const front = /^(?:todo|triage)\//.test(to) ? /^---\r?\n[\s\S]*?\r?\n---/.exec(content)?.[0] : void 0;
|
|
@@ -9500,7 +9502,7 @@ function readTranslations(raw) {
|
|
|
9500
9502
|
}
|
|
9501
9503
|
return out;
|
|
9502
9504
|
}
|
|
9503
|
-
function memoryPaths(raw) {
|
|
9505
|
+
function memoryPaths(raw, folder = "memory/agents/<name>/") {
|
|
9504
9506
|
if (raw === void 0) return [];
|
|
9505
9507
|
const block = map(raw);
|
|
9506
9508
|
const extra = block ? Object.keys(block).filter((key) => key !== "workspace") : [];
|
|
@@ -9512,7 +9514,7 @@ function memoryPaths(raw) {
|
|
|
9512
9514
|
}
|
|
9513
9515
|
const paths = [...new Set(list.map((v) => v.trim()))];
|
|
9514
9516
|
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
|
|
9517
|
+
if (outside) return `\`akb.memoryFiles.workspace: ${outside}\`, which is outside its memory folder \u2014 use a path inside \`${folder}\``;
|
|
9516
9518
|
return paths;
|
|
9517
9519
|
}
|
|
9518
9520
|
var OLD_ROLE_KEYS, AGENT_NAME, SCHEDULE_READS, isScheduleReads, names, str3, map;
|
|
@@ -9603,6 +9605,8 @@ function parseStudioFile(id, source, from) {
|
|
|
9603
9605
|
if (!agent || scheduled.some((s) => s.agent === agent)) continue;
|
|
9604
9606
|
scheduled.push({ agent, ...text3(row.cadence) ? { cadence: text3(row.cadence) } : {} });
|
|
9605
9607
|
}
|
|
9608
|
+
const workspace2 = memoryPaths(raw.memoryFiles, `memory/studios/${id}/`);
|
|
9609
|
+
if (typeof workspace2 === "string") return { problem: `${from}: declares ${workspace2}` };
|
|
9606
9610
|
const names3 = Object.fromEntries(Object.entries(box(raw.names)).map(([lang, said2]) => [lang, text3(said2)]).filter(([, said2]) => said2));
|
|
9607
9611
|
return {
|
|
9608
9612
|
def: {
|
|
@@ -9616,6 +9620,7 @@ function parseStudioFile(id, source, from) {
|
|
|
9616
9620
|
previews,
|
|
9617
9621
|
land,
|
|
9618
9622
|
scheduled,
|
|
9623
|
+
...workspace2.length ? { memoryFiles: { workspace: workspace2 } } : {},
|
|
9619
9624
|
rules: body.trim()
|
|
9620
9625
|
}
|
|
9621
9626
|
};
|
|
@@ -9625,6 +9630,7 @@ var init_studio_def = __esm({
|
|
|
9625
9630
|
"src/lib/agent/studio-def.ts"() {
|
|
9626
9631
|
"use strict";
|
|
9627
9632
|
init_icon();
|
|
9633
|
+
init_parse();
|
|
9628
9634
|
init_yaml2();
|
|
9629
9635
|
init_spec_agent_names();
|
|
9630
9636
|
init_yaml();
|
|
@@ -9656,7 +9662,12 @@ function studioDiagram(def, agentOf2) {
|
|
|
9656
9662
|
const after2 = (name) => (agentOf2(name)?.after ?? []).filter((other) => previews.includes(other));
|
|
9657
9663
|
return {
|
|
9658
9664
|
version: 1,
|
|
9659
|
-
rounds: stagesOf(previews, after2).map(
|
|
9665
|
+
rounds: stagesOf(previews, after2).map(
|
|
9666
|
+
(round) => round.map((name) => {
|
|
9667
|
+
const waits = after2(name);
|
|
9668
|
+
return waits.length ? { ...step(name), after: waits } : step(name);
|
|
9669
|
+
})
|
|
9670
|
+
),
|
|
9660
9671
|
land: def.land.filter((h) => !h.off).map((h) => step(h.agent)),
|
|
9661
9672
|
scheduled: def.scheduled.map((s) => ({ ...step(s.agent), ...s.cadence ? { cadence: s.cadence } : {} }))
|
|
9662
9673
|
};
|
|
@@ -9724,7 +9735,7 @@ function inspect(value, official) {
|
|
|
9724
9735
|
if (size > FILE_LIMITS.file) return fail(file, `is larger than ${FILE_LIMITS.file / KB} KB`, true);
|
|
9725
9736
|
total += size;
|
|
9726
9737
|
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;
|
|
9738
|
+
if (file === STUDIO_FILE || file === CARD_TEMPLATE_FILE) continue;
|
|
9728
9739
|
if (official && file === MCP_FILE) {
|
|
9729
9740
|
const problem = mcpProblem(text4);
|
|
9730
9741
|
if (problem) fail(file, problem);
|
|
@@ -9736,9 +9747,10 @@ function inspect(value, official) {
|
|
|
9736
9747
|
else skills.add(file.split("/")[1]);
|
|
9737
9748
|
continue;
|
|
9738
9749
|
}
|
|
9750
|
+
if (isSharedFile(file)) continue;
|
|
9739
9751
|
const at = folderPath(file, "agents");
|
|
9740
9752
|
if (!at) {
|
|
9741
|
-
fail(file, `is neither ${STUDIO_FILE} nor inside agents/<name>/`);
|
|
9753
|
+
fail(file, `is neither ${STUDIO_FILE}, ${CARD_TEMPLATE_FILE}, shared/ nor inside agents/<name>/`);
|
|
9742
9754
|
continue;
|
|
9743
9755
|
}
|
|
9744
9756
|
if (!folders2.has(at[0])) folders2.set(at[0], /* @__PURE__ */ new Map());
|
|
@@ -9776,7 +9788,7 @@ function inspect(value, official) {
|
|
|
9776
9788
|
}
|
|
9777
9789
|
return { problems, def, files };
|
|
9778
9790
|
}
|
|
9779
|
-
var STUDIO_FILE, MCP_FILE, VERSION_FILE, versionText, KB, FILE_LIMITS, officialId, hashInput, landsOf, SEGMENT, isAboutFile, bytes, studioFilesProblems;
|
|
9791
|
+
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
9792
|
var init_studio_files = __esm({
|
|
9781
9793
|
"src/lib/shared/studio-files.ts"() {
|
|
9782
9794
|
"use strict";
|
|
@@ -9785,6 +9797,9 @@ var init_studio_files = __esm({
|
|
|
9785
9797
|
init_studio_diagram();
|
|
9786
9798
|
STUDIO_FILE = "STUDIO.md";
|
|
9787
9799
|
MCP_FILE = "mcp.json";
|
|
9800
|
+
CARD_TEMPLATE_FILE = "CARD.md";
|
|
9801
|
+
SHARED_DIR = "shared/";
|
|
9802
|
+
RULES_FILE = "shared/RULES.md";
|
|
9788
9803
|
VERSION_FILE = "version.json";
|
|
9789
9804
|
versionText = (id, version) => `${JSON.stringify({ id, version })}
|
|
9790
9805
|
`;
|
|
@@ -9796,6 +9811,10 @@ var init_studio_files = __esm({
|
|
|
9796
9811
|
SEGMENT = /^[\w.-]+$/;
|
|
9797
9812
|
isAboutFile = (file) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file);
|
|
9798
9813
|
bytes = (text4) => new TextEncoder().encode(text4).length;
|
|
9814
|
+
isSharedFile = (file) => {
|
|
9815
|
+
const parts = file.split("/");
|
|
9816
|
+
return parts.length > 1 && parts[0] === "shared" && parts.slice(1).every((p) => SEGMENT.test(p) && p !== "." && p !== "..");
|
|
9817
|
+
};
|
|
9799
9818
|
studioFilesProblems = (value, official = false) => inspect(value, official).problems;
|
|
9800
9819
|
}
|
|
9801
9820
|
});
|
|
@@ -9843,7 +9862,7 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
|
9843
9862
|
const dir = path33.join(studiosDir, folder);
|
|
9844
9863
|
const files = {};
|
|
9845
9864
|
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);
|
|
9865
|
+
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
9866
|
}
|
|
9848
9867
|
const read3 = checkStudioFiles({ [STUDIO_FILE]: files[STUDIO_FILE], ...Object.fromEntries(
|
|
9849
9868
|
Object.entries(agentFiles).flatMap(([name, own]) => Object.entries(own).map(([f, t]) => [`agents/${name}/${f}`, t]))
|
|
@@ -10275,6 +10294,7 @@ function studioFileText(def) {
|
|
|
10275
10294
|
if (def.when) lines.push(`when: ${scalar(def.when)}`);
|
|
10276
10295
|
lines.push(`needsArtifact: ${def.needsArtifact}`);
|
|
10277
10296
|
lines.push(...groupLines("previews", def.previews), ...groupLines("land", def.land));
|
|
10297
|
+
if (def.memoryFiles?.workspace.length) lines.push("memoryFiles:", ` workspace: [${def.memoryFiles.workspace.map(scalar).join(", ")}]`);
|
|
10278
10298
|
if (def.scheduled.length) {
|
|
10279
10299
|
lines.push("scheduled:");
|
|
10280
10300
|
for (const s of def.scheduled) {
|
|
@@ -12032,8 +12052,8 @@ var require_command = __commonJS({
|
|
|
12032
12052
|
"node_modules/commander/lib/command.js"(exports) {
|
|
12033
12053
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
12034
12054
|
var childProcess = __require("node:child_process");
|
|
12035
|
-
var
|
|
12036
|
-
var
|
|
12055
|
+
var path86 = __require("node:path");
|
|
12056
|
+
var fs88 = __require("node:fs");
|
|
12037
12057
|
var process2 = __require("node:process");
|
|
12038
12058
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
12039
12059
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -13014,7 +13034,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13014
13034
|
* @param {string} subcommandName
|
|
13015
13035
|
*/
|
|
13016
13036
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
13017
|
-
if (
|
|
13037
|
+
if (fs88.existsSync(executableFile)) return;
|
|
13018
13038
|
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
13039
|
const executableMissing = `'${executableFile}' does not exist
|
|
13020
13040
|
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
@@ -13032,11 +13052,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13032
13052
|
let launchWithNode = false;
|
|
13033
13053
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
13034
13054
|
function findFile(baseDir, baseName) {
|
|
13035
|
-
const localBin =
|
|
13036
|
-
if (
|
|
13037
|
-
if (sourceExt.includes(
|
|
13055
|
+
const localBin = path86.resolve(baseDir, baseName);
|
|
13056
|
+
if (fs88.existsSync(localBin)) return localBin;
|
|
13057
|
+
if (sourceExt.includes(path86.extname(baseName))) return void 0;
|
|
13038
13058
|
const foundExt = sourceExt.find(
|
|
13039
|
-
(ext) =>
|
|
13059
|
+
(ext) => fs88.existsSync(`${localBin}${ext}`)
|
|
13040
13060
|
);
|
|
13041
13061
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
13042
13062
|
return void 0;
|
|
@@ -13048,21 +13068,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13048
13068
|
if (this._scriptPath) {
|
|
13049
13069
|
let resolvedScriptPath;
|
|
13050
13070
|
try {
|
|
13051
|
-
resolvedScriptPath =
|
|
13071
|
+
resolvedScriptPath = fs88.realpathSync(this._scriptPath);
|
|
13052
13072
|
} catch {
|
|
13053
13073
|
resolvedScriptPath = this._scriptPath;
|
|
13054
13074
|
}
|
|
13055
|
-
executableDir =
|
|
13056
|
-
|
|
13075
|
+
executableDir = path86.resolve(
|
|
13076
|
+
path86.dirname(resolvedScriptPath),
|
|
13057
13077
|
executableDir
|
|
13058
13078
|
);
|
|
13059
13079
|
}
|
|
13060
13080
|
if (executableDir) {
|
|
13061
13081
|
let localFile = findFile(executableDir, executableFile);
|
|
13062
13082
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
13063
|
-
const legacyName =
|
|
13083
|
+
const legacyName = path86.basename(
|
|
13064
13084
|
this._scriptPath,
|
|
13065
|
-
|
|
13085
|
+
path86.extname(this._scriptPath)
|
|
13066
13086
|
);
|
|
13067
13087
|
if (legacyName !== this._name) {
|
|
13068
13088
|
localFile = findFile(
|
|
@@ -13073,7 +13093,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13073
13093
|
}
|
|
13074
13094
|
executableFile = localFile || executableFile;
|
|
13075
13095
|
}
|
|
13076
|
-
launchWithNode = sourceExt.includes(
|
|
13096
|
+
launchWithNode = sourceExt.includes(path86.extname(executableFile));
|
|
13077
13097
|
let proc;
|
|
13078
13098
|
if (process2.platform !== "win32") {
|
|
13079
13099
|
if (launchWithNode) {
|
|
@@ -13920,7 +13940,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13920
13940
|
* @return {Command}
|
|
13921
13941
|
*/
|
|
13922
13942
|
nameFromFilename(filename) {
|
|
13923
|
-
this._name =
|
|
13943
|
+
this._name = path86.basename(filename, path86.extname(filename));
|
|
13924
13944
|
return this;
|
|
13925
13945
|
}
|
|
13926
13946
|
/**
|
|
@@ -13934,9 +13954,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13934
13954
|
* @param {string} [path]
|
|
13935
13955
|
* @return {(string|null|Command)}
|
|
13936
13956
|
*/
|
|
13937
|
-
executableDir(
|
|
13938
|
-
if (
|
|
13939
|
-
this._executableDir =
|
|
13957
|
+
executableDir(path87) {
|
|
13958
|
+
if (path87 === void 0) return this._executableDir;
|
|
13959
|
+
this._executableDir = path87;
|
|
13940
13960
|
return this;
|
|
13941
13961
|
}
|
|
13942
13962
|
/**
|
|
@@ -16156,7 +16176,7 @@ function globalMemories() {
|
|
|
16156
16176
|
} catch {
|
|
16157
16177
|
}
|
|
16158
16178
|
for (const name of folders2) {
|
|
16159
|
-
if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR) continue;
|
|
16179
|
+
if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR || name === STUDIO_MEMORY_DIR) continue;
|
|
16160
16180
|
const file = path51.join(MEMORY, name, GLOBAL_MEMORY_FILE);
|
|
16161
16181
|
if (!fs49.existsSync(file)) continue;
|
|
16162
16182
|
const memory = readMemory(fs49.readFileSync(file, "utf8"), false, name);
|
|
@@ -16254,8 +16274,82 @@ var init_archive = __esm({
|
|
|
16254
16274
|
}
|
|
16255
16275
|
});
|
|
16256
16276
|
|
|
16257
|
-
// src/lib/agent/
|
|
16277
|
+
// src/lib/agent/studio-shared.ts
|
|
16278
|
+
import fs51 from "node:fs";
|
|
16258
16279
|
import path53 from "node:path";
|
|
16280
|
+
function studioFiles(studio) {
|
|
16281
|
+
const flow = cloudFlows().find((f) => f.def.id === studio || f.cloudId === studio);
|
|
16282
|
+
if (flow) return flow.files;
|
|
16283
|
+
if (studio && draftId() === studio) {
|
|
16284
|
+
try {
|
|
16285
|
+
return readStudioFolder(path53.join(STUDIOS, studio));
|
|
16286
|
+
} catch {
|
|
16287
|
+
return null;
|
|
16288
|
+
}
|
|
16289
|
+
}
|
|
16290
|
+
return null;
|
|
16291
|
+
}
|
|
16292
|
+
function readStudioMemory(studio) {
|
|
16293
|
+
const dir = studioMemoryDir(studio);
|
|
16294
|
+
let names3 = [];
|
|
16295
|
+
try {
|
|
16296
|
+
names3 = fs51.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".md")).map((e) => e.name).sort();
|
|
16297
|
+
} catch {
|
|
16298
|
+
return [];
|
|
16299
|
+
}
|
|
16300
|
+
return names3.flatMap((name) => {
|
|
16301
|
+
try {
|
|
16302
|
+
return [{ name, text: fs51.readFileSync(path53.join(dir, name), "utf8").trim() }];
|
|
16303
|
+
} catch {
|
|
16304
|
+
return [];
|
|
16305
|
+
}
|
|
16306
|
+
});
|
|
16307
|
+
}
|
|
16308
|
+
function studioSections(studio, opts = {}) {
|
|
16309
|
+
const files = studio ? studioFiles(studio) : null;
|
|
16310
|
+
if (!studio || !files) return [];
|
|
16311
|
+
const rules = files[RULES_FILE]?.trim();
|
|
16312
|
+
const own = opts.agent ? Object.keys(files).filter((f) => f.startsWith(`agents/${opts.agent}/`) && f !== `agents/${opts.agent}/AGENT.md`).sort() : [];
|
|
16313
|
+
const listed = [...sharedFiles(files), ...own];
|
|
16314
|
+
const remembered = opts.memory ? readStudioMemory(studio) : [];
|
|
16315
|
+
return [
|
|
16316
|
+
rules ? `\u2014\u2014\u2014 your studio's rules \u2014\u2014\u2014
|
|
16317
|
+
|
|
16318
|
+
${rules}` : "",
|
|
16319
|
+
listed.length ? `\u2014\u2014\u2014 your studio's files \u2014\u2014\u2014
|
|
16320
|
+
|
|
16321
|
+
Read one only when the work calls for it:
|
|
16322
|
+
|
|
16323
|
+
${listed.map((f) => fileLine(studio, f)).join("\n")}` : "",
|
|
16324
|
+
remembered.length ? `\u2014\u2014\u2014 what your studio remembers \u2014\u2014\u2014
|
|
16325
|
+
|
|
16326
|
+
From \`${rel(studioMemoryDir(studio))}/\`:
|
|
16327
|
+
|
|
16328
|
+
${remembered.map((m) => `### \`${m.name}\`
|
|
16329
|
+
|
|
16330
|
+
${m.text || "_(empty)_"}`).join("\n\n")}` : ""
|
|
16331
|
+
].filter(Boolean);
|
|
16332
|
+
}
|
|
16333
|
+
var sharedFiles, studioMemoryDir, fileLine, studioHoldsAgent;
|
|
16334
|
+
var init_studio_shared = __esm({
|
|
16335
|
+
"src/lib/agent/studio-shared.ts"() {
|
|
16336
|
+
"use strict";
|
|
16337
|
+
init_memory();
|
|
16338
|
+
init_paths();
|
|
16339
|
+
init_studio_files();
|
|
16340
|
+
init_command();
|
|
16341
|
+
init_cloud_studios();
|
|
16342
|
+
init_studio_file();
|
|
16343
|
+
init_studio_folder();
|
|
16344
|
+
sharedFiles = (files) => Object.keys(files).filter((f) => f.startsWith(SHARED_DIR) && f !== RULES_FILE).sort();
|
|
16345
|
+
studioMemoryDir = (studio) => path53.join(MEMORY, STUDIO_MEMORY_DIR, studio);
|
|
16346
|
+
fileLine = (studio, file) => `- \`${file}\` \u2014 \`${rawMove(`file ${studio} ${file}`)}\``;
|
|
16347
|
+
studioHoldsAgent = (studio, agent) => !!studio && Object.keys(studioFiles(studio) ?? {}).some((f) => f.startsWith(`agents/${agent}/`));
|
|
16348
|
+
}
|
|
16349
|
+
});
|
|
16350
|
+
|
|
16351
|
+
// src/lib/agent/prompts.ts
|
|
16352
|
+
import path54 from "node:path";
|
|
16259
16353
|
function stopReason(deliveryId) {
|
|
16260
16354
|
const delivery = findDelivery(deliveryId);
|
|
16261
16355
|
if (!delivery) return void 0;
|
|
@@ -16316,7 +16410,7 @@ ${text4}` : "";
|
|
|
16316
16410
|
}
|
|
16317
16411
|
function cardFileOf(id) {
|
|
16318
16412
|
const found2 = id === void 0 ? null : locate(id);
|
|
16319
|
-
return found2 ? found2.kind === "group" ?
|
|
16413
|
+
return found2 ? found2.kind === "group" ? path54.join(found2.target, "root.md") : found2.target : "";
|
|
16320
16414
|
}
|
|
16321
16415
|
function realPaths(text4, req) {
|
|
16322
16416
|
if (req.action !== "scheduled" && req.action !== "sub") return text4;
|
|
@@ -16343,14 +16437,26 @@ function studioRulesBlock(req) {
|
|
|
16343
16437
|
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
16438
|
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
16439
|
const own = userStudioRules(flow);
|
|
16440
|
+
const template = studioFiles(flow.id)?.[CARD_TEMPLATE_FILE]?.trim();
|
|
16346
16441
|
const body = [where, end2, flow.rules.trim()].filter(Boolean).join("\n\n");
|
|
16347
16442
|
return [
|
|
16348
|
-
|
|
16349
|
-
|
|
16350
|
-
|
|
16351
|
-
|
|
16352
|
-
|
|
16353
|
-
|
|
16443
|
+
[
|
|
16444
|
+
`<studio name="${flow.name}">`,
|
|
16445
|
+
"How a card on this studio is written.",
|
|
16446
|
+
body,
|
|
16447
|
+
"</studio>",
|
|
16448
|
+
...template ? ["", "<card-template>", "Write the card from this template: keep only the parts that fit this card, and fill them in.", template, "</card-template>"] : [],
|
|
16449
|
+
...own ? ["", "<rules>", "The user's own rules for cards on this studio; they win over the studio above.", own, "</rules>"] : []
|
|
16450
|
+
].join("\n"),
|
|
16451
|
+
...studioSections(flow.id)
|
|
16452
|
+
].join("\n\n");
|
|
16453
|
+
}
|
|
16454
|
+
function ownFiles2(studio, agent, files) {
|
|
16455
|
+
const sections2 = studioSections(studio, { agent, memory: true });
|
|
16456
|
+
const listed = !!agent && studioHoldsAgent(studio, agent);
|
|
16457
|
+
return [...sections2, ...files && !listed ? [`\u2014\u2014\u2014 your own files \u2014\u2014\u2014
|
|
16458
|
+
|
|
16459
|
+
${files}`] : []];
|
|
16354
16460
|
}
|
|
16355
16461
|
function landBlock(req) {
|
|
16356
16462
|
if (req.action !== "implement") return "";
|
|
@@ -16358,6 +16464,7 @@ function landBlock(req) {
|
|
|
16358
16464
|
const flow = frozen ? void 0 : studioFor(studioForRun(req));
|
|
16359
16465
|
const rows = frozen ? frozen.land ?? [] : flow ? landAgents(flow) : [];
|
|
16360
16466
|
const delivery = deliveryFor(req);
|
|
16467
|
+
const studio = frozen?.id ?? flow?.id;
|
|
16361
16468
|
const step = delivery ? deliveryStep(delivery) : 0;
|
|
16362
16469
|
const agents = rows.slice(step, step + 1).flatMap((h) => {
|
|
16363
16470
|
const agent = findSpecAgent(h.agent);
|
|
@@ -16369,9 +16476,7 @@ function landBlock(req) {
|
|
|
16369
16476
|
`\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
16477
|
|
|
16371
16478
|
${agent.body}`,
|
|
16372
|
-
agentFilesBlock(agent)
|
|
16373
|
-
|
|
16374
|
-
${agentFilesBlock(agent)}` : "",
|
|
16479
|
+
...ownFiles2(studio, agent.name, agentFilesBlock(agent)),
|
|
16375
16480
|
globalMemoryBlock(agent) ? `\u2014\u2014\u2014 global memories \u2014\u2014\u2014
|
|
16376
16481
|
|
|
16377
16482
|
${globalMemoryBlock(agent)}` : "",
|
|
@@ -16403,7 +16508,7 @@ function frozenRules(req) {
|
|
|
16403
16508
|
function archivedCardFile(id) {
|
|
16404
16509
|
const found2 = locateArchived(id);
|
|
16405
16510
|
if (!found2) return `${rel(ARCHIVE)}/`;
|
|
16406
|
-
return rel(found2.kind === "group" ?
|
|
16511
|
+
return rel(found2.kind === "group" ? path54.join(found2.target, "root.md") : found2.target);
|
|
16407
16512
|
}
|
|
16408
16513
|
function shippedLines(cardId2) {
|
|
16409
16514
|
const delivery = endedDelivery(`${cardId2}`);
|
|
@@ -16502,7 +16607,7 @@ function actionPrompt(req, command, notes) {
|
|
|
16502
16607
|
case "prune-memory":
|
|
16503
16608
|
return [
|
|
16504
16609
|
`${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
|
|
16610
|
+
`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
16611
|
`Change nothing but those files: no card, no question for anyone.`
|
|
16507
16612
|
].join(" ");
|
|
16508
16613
|
// Reading back over the conversations (#748). It names nothing either: which ones have
|
|
@@ -16546,7 +16651,7 @@ function actionPrompt(req, command, notes) {
|
|
|
16546
16651
|
case "spec": {
|
|
16547
16652
|
const agent = findSpecAgent(req.specAgent ?? "");
|
|
16548
16653
|
const found2 = req.id === void 0 ? null : locate(req.id);
|
|
16549
|
-
const cardFile3 = found2 ? rel(found2.kind === "group" ?
|
|
16654
|
+
const cardFile3 = found2 ? rel(found2.kind === "group" ? path54.join(found2.target, "root.md") : found2.target) : `task #${req.id}`;
|
|
16550
16655
|
const own = agent ? specAgentInstructions(agent) : null;
|
|
16551
16656
|
if (own) notes.push(...own.notes);
|
|
16552
16657
|
const memory = agent ? agentMemoryBlock(agent) : "";
|
|
@@ -16564,9 +16669,7 @@ function actionPrompt(req, command, notes) {
|
|
|
16564
16669
|
agent && own ? `\u2014\u2014\u2014 you, the \`${agent.name}\` agent \u2014\u2014\u2014
|
|
16565
16670
|
|
|
16566
16671
|
${own.instructions}` : "",
|
|
16567
|
-
|
|
16568
|
-
|
|
16569
|
-
${own.files}` : "",
|
|
16672
|
+
...ownFiles2(studioForRun(req), agent?.name, own?.files),
|
|
16570
16673
|
memory ? `\u2014\u2014\u2014 what you remember \u2014\u2014\u2014
|
|
16571
16674
|
|
|
16572
16675
|
${memory}` : "",
|
|
@@ -16599,9 +16702,7 @@ ${shared}` : "",
|
|
|
16599
16702
|
agent && own ? `\u2014\u2014\u2014 you, the \`${agent.name}\` agent \u2014\u2014\u2014
|
|
16600
16703
|
|
|
16601
16704
|
${own.instructions}` : "",
|
|
16602
|
-
|
|
16603
|
-
|
|
16604
|
-
${own.files}` : "",
|
|
16705
|
+
...ownFiles2(flow?.id, agent?.name, own?.files),
|
|
16605
16706
|
extra ? `\u2014\u2014\u2014 what this studio asks of you here \u2014\u2014\u2014
|
|
16606
16707
|
|
|
16607
16708
|
${extra}` : "",
|
|
@@ -16635,9 +16736,7 @@ ${req.description ?? ""}`,
|
|
|
16635
16736
|
agent && own ? `\u2014\u2014\u2014 you, the \`${agent.name}\` agent \u2014\u2014\u2014
|
|
16636
16737
|
|
|
16637
16738
|
${own.instructions}` : "",
|
|
16638
|
-
|
|
16639
|
-
|
|
16640
|
-
${own.files}` : "",
|
|
16739
|
+
...ownFiles2(studioForRun(req), agent?.name, own?.files),
|
|
16641
16740
|
memory ? `\u2014\u2014\u2014 what you remember \u2014\u2014\u2014
|
|
16642
16741
|
|
|
16643
16742
|
${memory}` : "",
|
|
@@ -16686,6 +16785,8 @@ var init_prompts = __esm({
|
|
|
16686
16785
|
init_flows();
|
|
16687
16786
|
init_resolve();
|
|
16688
16787
|
init_runner();
|
|
16788
|
+
init_studio_shared();
|
|
16789
|
+
init_studio_files();
|
|
16689
16790
|
init_studios();
|
|
16690
16791
|
init_catalog();
|
|
16691
16792
|
init_roles();
|
|
@@ -16726,16 +16827,16 @@ var init_prompts = __esm({
|
|
|
16726
16827
|
|
|
16727
16828
|
// src/lib/agent/stop.ts
|
|
16728
16829
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
16729
|
-
import
|
|
16830
|
+
import fs52 from "node:fs";
|
|
16730
16831
|
function markedInProc(entry, strict = false) {
|
|
16731
16832
|
const pids = [];
|
|
16732
|
-
for (const name of
|
|
16833
|
+
for (const name of fs52.readdirSync("/proc")) {
|
|
16733
16834
|
if (!/^\d+$/.test(name)) continue;
|
|
16734
16835
|
try {
|
|
16735
|
-
if (
|
|
16836
|
+
if (fs52.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
|
|
16736
16837
|
} catch (error) {
|
|
16737
16838
|
if (strict && !["ENOENT", "ESRCH"].includes(error.code ?? "")) {
|
|
16738
|
-
const stat =
|
|
16839
|
+
const stat = fs52.statSync(`/proc/${name}`, { throwIfNoEntry: false });
|
|
16739
16840
|
if (stat?.uid === process.getuid?.()) throw error;
|
|
16740
16841
|
}
|
|
16741
16842
|
}
|
|
@@ -16890,10 +16991,10 @@ var init_stop = __esm({
|
|
|
16890
16991
|
});
|
|
16891
16992
|
|
|
16892
16993
|
// src/lib/agent/creation-lock.ts
|
|
16893
|
-
import
|
|
16994
|
+
import path55 from "node:path";
|
|
16894
16995
|
function withCreationLock(fn) {
|
|
16895
16996
|
if (depth2) return fn();
|
|
16896
|
-
return withLock(
|
|
16997
|
+
return withLock(path55.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
|
|
16897
16998
|
depth2++;
|
|
16898
16999
|
try {
|
|
16899
17000
|
return fn();
|
|
@@ -16914,8 +17015,8 @@ var init_creation_lock = __esm({
|
|
|
16914
17015
|
|
|
16915
17016
|
// src/lib/agent/sessions.ts
|
|
16916
17017
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
16917
|
-
import
|
|
16918
|
-
import
|
|
17018
|
+
import fs53 from "node:fs";
|
|
17019
|
+
import path56 from "node:path";
|
|
16919
17020
|
function reap(runs, reaped = [], restore = []) {
|
|
16920
17021
|
let changed = false;
|
|
16921
17022
|
const now = Date.now();
|
|
@@ -16935,7 +17036,7 @@ function reap(runs, reaped = [], restore = []) {
|
|
|
16935
17036
|
}
|
|
16936
17037
|
function stampDuration(run2, endedAt) {
|
|
16937
17038
|
try {
|
|
16938
|
-
|
|
17039
|
+
fs53.appendFileSync(run2.logPath, durationLine(endedAt - run2.startedAt));
|
|
16939
17040
|
} catch {
|
|
16940
17041
|
}
|
|
16941
17042
|
}
|
|
@@ -16949,7 +17050,7 @@ function cardNow(cardId2) {
|
|
|
16949
17050
|
try {
|
|
16950
17051
|
const file = cardFile(cardId2);
|
|
16951
17052
|
if (!file) return null;
|
|
16952
|
-
const { meta } = parseFrontmatter(
|
|
17053
|
+
const { meta } = parseFrontmatter(fs53.readFileSync(file, "utf8"));
|
|
16953
17054
|
if (!meta) return null;
|
|
16954
17055
|
return { status: meta.status || "todo", questions: meta.questions.length, title: meta.title };
|
|
16955
17056
|
} catch {
|
|
@@ -17082,9 +17183,9 @@ function leftBoardOnLanding(id) {
|
|
|
17082
17183
|
function archivedRejected(id) {
|
|
17083
17184
|
const filed = locateArchived(id);
|
|
17084
17185
|
if (!filed) return null;
|
|
17085
|
-
const file = filed.kind === "group" ?
|
|
17186
|
+
const file = filed.kind === "group" ? path56.join(filed.target, "root.md") : filed.target;
|
|
17086
17187
|
try {
|
|
17087
|
-
return !!parseFrontmatter(
|
|
17188
|
+
return !!parseFrontmatter(fs53.readFileSync(file, "utf8")).meta?.rejected;
|
|
17088
17189
|
} catch {
|
|
17089
17190
|
return false;
|
|
17090
17191
|
}
|
|
@@ -17334,7 +17435,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID4(), said2) {
|
|
|
17334
17435
|
return { run: record, spec };
|
|
17335
17436
|
}
|
|
17336
17437
|
function planningSession(cardId2, cwd = REPO_ROOT) {
|
|
17337
|
-
const here = (dir) => !dir ||
|
|
17438
|
+
const here = (dir) => !dir || path56.resolve(dir) === cwd;
|
|
17338
17439
|
const planned = readRuns().filter((r) => r.status === "done" && r.cardId === cardId2 && PLANNING.has(r.action)).sort((a, b) => b.startedAt - a.startedAt)[0];
|
|
17339
17440
|
if (!planned) return { none: "unrecorded" };
|
|
17340
17441
|
if (!here(planned.cwd)) return { none: "elsewhere" };
|
|
@@ -17554,8 +17655,8 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
|
|
|
17554
17655
|
if (inherited.asks.length || inherited.refines.length) writeAsks(sessionId, inherited);
|
|
17555
17656
|
clearAsks(prev.sessionId);
|
|
17556
17657
|
try {
|
|
17557
|
-
|
|
17558
|
-
|
|
17658
|
+
fs53.unlinkSync(prev.logPath);
|
|
17659
|
+
fs53.rmSync(eventsPathOf(prev.sessionId), { force: true });
|
|
17559
17660
|
} catch {
|
|
17560
17661
|
}
|
|
17561
17662
|
if (retry2 && prev.pictures?.length) {
|
|
@@ -17578,8 +17679,8 @@ function forgetRun(sessionId) {
|
|
|
17578
17679
|
if (!gone) return;
|
|
17579
17680
|
clearAsks(sessionId);
|
|
17580
17681
|
try {
|
|
17581
|
-
|
|
17582
|
-
|
|
17682
|
+
fs53.unlinkSync(gone.logPath);
|
|
17683
|
+
fs53.rmSync(eventsPathOf(gone.sessionId), { force: true });
|
|
17583
17684
|
} catch {
|
|
17584
17685
|
}
|
|
17585
17686
|
}
|
|
@@ -17608,14 +17709,14 @@ function noteSpecRefusals(sessionId, refused) {
|
|
|
17608
17709
|
}
|
|
17609
17710
|
function clearAsks(sessionId) {
|
|
17610
17711
|
try {
|
|
17611
|
-
|
|
17712
|
+
fs53.unlinkSync(asksPathOf(sessionId));
|
|
17612
17713
|
} catch {
|
|
17613
17714
|
}
|
|
17614
17715
|
}
|
|
17615
17716
|
function readAsks(sessionId) {
|
|
17616
17717
|
let data;
|
|
17617
17718
|
try {
|
|
17618
|
-
data = JSON.parse(
|
|
17719
|
+
data = JSON.parse(fs53.readFileSync(asksPathOf(sessionId), "utf8"));
|
|
17619
17720
|
} catch {
|
|
17620
17721
|
return { asks: [], refines: [], refused: [] };
|
|
17621
17722
|
}
|
|
@@ -17642,10 +17743,10 @@ function readAsks(sessionId) {
|
|
|
17642
17743
|
return { asks: asks.filter((a) => !discarded.has(a.cardId)), refines: refines.filter((a) => !discarded.has(a.cardId)), refused };
|
|
17643
17744
|
}
|
|
17644
17745
|
function writeAsks(sessionId, file) {
|
|
17645
|
-
|
|
17746
|
+
fs53.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
17646
17747
|
const tmp = `${asksPathOf(sessionId)}.tmp`;
|
|
17647
|
-
|
|
17648
|
-
|
|
17748
|
+
fs53.writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
|
|
17749
|
+
fs53.renameSync(tmp, asksPathOf(sessionId));
|
|
17649
17750
|
}
|
|
17650
17751
|
function markSpawned(sessionId, pid) {
|
|
17651
17752
|
patch(sessionId, (r) => {
|
|
@@ -17776,12 +17877,12 @@ async function resumeDelivery(id) {
|
|
|
17776
17877
|
return { ok: true, deliveryId: delivery.deliveryId, carryOn };
|
|
17777
17878
|
}
|
|
17778
17879
|
function writeSpec(spec) {
|
|
17779
|
-
|
|
17780
|
-
|
|
17880
|
+
fs53.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
17881
|
+
fs53.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
|
|
17781
17882
|
}
|
|
17782
17883
|
function readSpec(sessionId) {
|
|
17783
17884
|
try {
|
|
17784
|
-
const spec = JSON.parse(
|
|
17885
|
+
const spec = JSON.parse(fs53.readFileSync(specPathOf(sessionId), "utf8"));
|
|
17785
17886
|
return spec && Array.isArray(spec.plan?.argv) ? spec : null;
|
|
17786
17887
|
} catch {
|
|
17787
17888
|
return null;
|
|
@@ -17789,28 +17890,28 @@ function readSpec(sessionId) {
|
|
|
17789
17890
|
}
|
|
17790
17891
|
function dropSpec(sessionId) {
|
|
17791
17892
|
try {
|
|
17792
|
-
|
|
17893
|
+
fs53.unlinkSync(specPathOf(sessionId));
|
|
17793
17894
|
} catch {
|
|
17794
17895
|
}
|
|
17795
17896
|
}
|
|
17796
17897
|
async function acquireIndexLock(giveUp) {
|
|
17797
17898
|
const until = Date.now() + INDEX_WAIT_MS;
|
|
17798
|
-
const holder =
|
|
17899
|
+
const holder = path56.join(INDEX_LOCK2, "holder");
|
|
17799
17900
|
for (; ; ) {
|
|
17800
17901
|
if (giveUp()) return null;
|
|
17801
17902
|
try {
|
|
17802
|
-
|
|
17803
|
-
|
|
17804
|
-
return () =>
|
|
17903
|
+
fs53.mkdirSync(INDEX_LOCK2, { recursive: false });
|
|
17904
|
+
fs53.writeFileSync(holder, String(process.pid));
|
|
17905
|
+
return () => fs53.rmSync(INDEX_LOCK2, { recursive: true, force: true });
|
|
17805
17906
|
} catch (err) {
|
|
17806
17907
|
const code = err.code;
|
|
17807
17908
|
if (code === "ENOENT") {
|
|
17808
|
-
|
|
17909
|
+
fs53.mkdirSync(path56.dirname(INDEX_LOCK2), { recursive: true });
|
|
17809
17910
|
continue;
|
|
17810
17911
|
}
|
|
17811
17912
|
if (code !== "EEXIST") throw err;
|
|
17812
17913
|
if (!pidAlive(Number(readHolder(holder)))) {
|
|
17813
|
-
|
|
17914
|
+
fs53.rmSync(INDEX_LOCK2, { recursive: true, force: true });
|
|
17814
17915
|
continue;
|
|
17815
17916
|
}
|
|
17816
17917
|
if (Date.now() > until) return null;
|
|
@@ -17820,7 +17921,7 @@ async function acquireIndexLock(giveUp) {
|
|
|
17820
17921
|
}
|
|
17821
17922
|
function readHolder(file) {
|
|
17822
17923
|
try {
|
|
17823
|
-
return
|
|
17924
|
+
return fs53.readFileSync(file, "utf8").trim();
|
|
17824
17925
|
} catch {
|
|
17825
17926
|
return String(process.pid);
|
|
17826
17927
|
}
|
|
@@ -17905,8 +18006,8 @@ var init_sessions = __esm({
|
|
|
17905
18006
|
implement: "implementing",
|
|
17906
18007
|
hook: "implementing"
|
|
17907
18008
|
};
|
|
17908
|
-
specPathOf = (sessionId) =>
|
|
17909
|
-
asksPathOf = (sessionId) =>
|
|
18009
|
+
specPathOf = (sessionId) => path56.join(SESSIONS_DIR, `${sessionId}.plan.json`);
|
|
18010
|
+
asksPathOf = (sessionId) => path56.join(SESSIONS_DIR, `${sessionId}.asks.json`);
|
|
17910
18011
|
carriesSession = (r) => !!(r.resumedFrom || r.continues && !r.continues.fork);
|
|
17911
18012
|
canPickUp = (r) => r.status === "error" || r.status === "interrupted" || r.status === "stopped";
|
|
17912
18013
|
neverStarted = (r) => r.unspawned === true || !!r.errorWhy?.some((why2) => why2.kind === "notInstalled");
|
|
@@ -17959,8 +18060,8 @@ var init_sources = __esm({
|
|
|
17959
18060
|
});
|
|
17960
18061
|
|
|
17961
18062
|
// src/lib/signals/inbox.ts
|
|
17962
|
-
import
|
|
17963
|
-
import
|
|
18063
|
+
import fs54 from "node:fs";
|
|
18064
|
+
import path57 from "node:path";
|
|
17964
18065
|
function metaPair(key, value) {
|
|
17965
18066
|
const name = typeof key === "string" ? key.trim() : "";
|
|
17966
18067
|
if (!name) return null;
|
|
@@ -17991,7 +18092,7 @@ ${signal2.summary.trim()}
|
|
|
17991
18092
|
function parse(file, lenient = false) {
|
|
17992
18093
|
let text4;
|
|
17993
18094
|
try {
|
|
17994
|
-
text4 =
|
|
18095
|
+
text4 = fs54.readFileSync(file, "utf8");
|
|
17995
18096
|
} catch {
|
|
17996
18097
|
return null;
|
|
17997
18098
|
}
|
|
@@ -18045,20 +18146,20 @@ function parse(file, lenient = false) {
|
|
|
18045
18146
|
};
|
|
18046
18147
|
}
|
|
18047
18148
|
function freeName(dir, wanted) {
|
|
18048
|
-
const ext =
|
|
18149
|
+
const ext = path57.extname(wanted);
|
|
18049
18150
|
const stem = wanted.slice(0, wanted.length - ext.length);
|
|
18050
18151
|
let name = wanted;
|
|
18051
|
-
for (let n = 2;
|
|
18152
|
+
for (let n = 2; fs54.existsSync(path57.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
|
|
18052
18153
|
return name;
|
|
18053
18154
|
}
|
|
18054
18155
|
function readFolder2(dir, lenient = false) {
|
|
18055
18156
|
let entries;
|
|
18056
18157
|
try {
|
|
18057
|
-
entries =
|
|
18158
|
+
entries = fs54.readdirSync(dir, { withFileTypes: true });
|
|
18058
18159
|
} catch {
|
|
18059
18160
|
return [];
|
|
18060
18161
|
}
|
|
18061
|
-
return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(
|
|
18162
|
+
return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(path57.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
|
|
18062
18163
|
}
|
|
18063
18164
|
function readInbox() {
|
|
18064
18165
|
const signals = readFolder2(TRIAGE);
|
|
@@ -18066,7 +18167,7 @@ function readInbox() {
|
|
|
18066
18167
|
return signals;
|
|
18067
18168
|
}
|
|
18068
18169
|
function writeSignal(incoming, importedAt, slug2 = "") {
|
|
18069
|
-
|
|
18170
|
+
fs54.mkdirSync(TRIAGE, { recursive: true });
|
|
18070
18171
|
const signal2 = {
|
|
18071
18172
|
...incoming,
|
|
18072
18173
|
importedAt,
|
|
@@ -18078,12 +18179,12 @@ function writeSignal(incoming, importedAt, slug2 = "") {
|
|
|
18078
18179
|
contentKept: true,
|
|
18079
18180
|
relPath: ""
|
|
18080
18181
|
};
|
|
18081
|
-
const file =
|
|
18082
|
-
|
|
18182
|
+
const file = path57.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug2)));
|
|
18183
|
+
fs54.writeFileSync(file, serialize({ ...signal2, relPath: boardRel(file) }));
|
|
18083
18184
|
return { ...signal2, relPath: boardRel(file) };
|
|
18084
18185
|
}
|
|
18085
18186
|
function stamp3(file, fields) {
|
|
18086
|
-
const text4 =
|
|
18187
|
+
const text4 = fs54.readFileSync(file, "utf8");
|
|
18087
18188
|
const lines = text4.split("\n");
|
|
18088
18189
|
const close = lines.indexOf("---", 1);
|
|
18089
18190
|
if (close < 0) return;
|
|
@@ -18092,13 +18193,13 @@ function stamp3(file, fields) {
|
|
|
18092
18193
|
return !key || fields[key[1]] === void 0;
|
|
18093
18194
|
});
|
|
18094
18195
|
const added = Object.entries(fields).flatMap(([key, value]) => value === null ? [] : [`${key}: ${yamlScalar(value)}`]);
|
|
18095
|
-
|
|
18196
|
+
fs54.writeFileSync(file, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
|
|
18096
18197
|
}
|
|
18097
18198
|
function moveSignal(from, into, fields) {
|
|
18098
|
-
if (!
|
|
18099
|
-
|
|
18100
|
-
const at =
|
|
18101
|
-
|
|
18199
|
+
if (!fs54.existsSync(from)) return "";
|
|
18200
|
+
fs54.mkdirSync(into, { recursive: true });
|
|
18201
|
+
const at = path57.join(into, freeName(into, path57.basename(from)));
|
|
18202
|
+
fs54.renameSync(from, at);
|
|
18102
18203
|
stamp3(at, fields);
|
|
18103
18204
|
return boardRel(at);
|
|
18104
18205
|
}
|
|
@@ -18107,10 +18208,10 @@ function archiveInboxItem(sourceId, cardId2) {
|
|
|
18107
18208
|
if (!found2) {
|
|
18108
18209
|
const ignored = readAllDismissed().find((signal2) => signal2.sourceId === sourceId);
|
|
18109
18210
|
if (!ignored) return { ok: false, error: `nothing waiting in triage is ${sourceId}` };
|
|
18110
|
-
stamp3(
|
|
18211
|
+
stamp3(path57.join(SIGNALS_DISMISSED, path57.basename(ignored.relPath)), { card_id: String(cardId2) });
|
|
18111
18212
|
return { ok: true, relPath: ignored.relPath, where: "dismissed" };
|
|
18112
18213
|
}
|
|
18113
|
-
const at = moveSignal(
|
|
18214
|
+
const at = moveSignal(path57.join(TRIAGE, path57.basename(found2.relPath)), SIGNALS_ARCHIVED, {
|
|
18114
18215
|
card_id: String(cardId2),
|
|
18115
18216
|
archived_at: formatStamp(/* @__PURE__ */ new Date())
|
|
18116
18217
|
});
|
|
@@ -18124,7 +18225,7 @@ var init_inbox = __esm({
|
|
|
18124
18225
|
init_sources();
|
|
18125
18226
|
init_paths();
|
|
18126
18227
|
init_yaml();
|
|
18127
|
-
boardRel = (file) => rel(file).split(
|
|
18228
|
+
boardRel = (file) => rel(file).split(path57.sep).join("/");
|
|
18128
18229
|
FIELDS = ["source_id", "title", "collected_at", "imported_at"];
|
|
18129
18230
|
META_LINE = /^\s+("(?:[^"\\]|\\.)*"|[^:]+):\s*(.*)$/;
|
|
18130
18231
|
slugOf = (said2) => said2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56).replace(/-+$/, "");
|
|
@@ -18233,12 +18334,12 @@ var init_studio_cards = __esm({
|
|
|
18233
18334
|
});
|
|
18234
18335
|
|
|
18235
18336
|
// src/lib/readme.ts
|
|
18236
|
-
import
|
|
18237
|
-
import
|
|
18337
|
+
import fs55 from "node:fs";
|
|
18338
|
+
import path58 from "node:path";
|
|
18238
18339
|
function stripReadmeRefs(target) {
|
|
18239
|
-
if (!
|
|
18340
|
+
if (!fs55.existsSync(README)) return [];
|
|
18240
18341
|
const needle = target.kind === "group" ? `](${target.rel}/` : `](${target.rel})`;
|
|
18241
|
-
const lines =
|
|
18342
|
+
const lines = fs55.readFileSync(README, "utf8").split("\n");
|
|
18242
18343
|
const out = [];
|
|
18243
18344
|
const removed = [];
|
|
18244
18345
|
let i = 0;
|
|
@@ -18260,20 +18361,20 @@ function stripReadmeRefs(target) {
|
|
|
18260
18361
|
out.push(line);
|
|
18261
18362
|
i++;
|
|
18262
18363
|
}
|
|
18263
|
-
if (removed.length)
|
|
18364
|
+
if (removed.length) fs55.writeFileSync(README, out.join("\n"));
|
|
18264
18365
|
return removed;
|
|
18265
18366
|
}
|
|
18266
18367
|
function addReadmeRef(id, title, relPath) {
|
|
18267
|
-
if (!
|
|
18268
|
-
const link2 = relPath.split(
|
|
18368
|
+
if (!fs55.existsSync(README)) return false;
|
|
18369
|
+
const link2 = relPath.split(path58.sep).join("/");
|
|
18269
18370
|
const bullet = `- [#${id} ${title}](${link2})`;
|
|
18270
18371
|
const heading = `## ${TASKS_HEADING}`;
|
|
18271
|
-
let lines =
|
|
18372
|
+
let lines = fs55.readFileSync(README, "utf8").split("\n");
|
|
18272
18373
|
const hi = lines.findIndex((l) => l.trim().toLowerCase() === heading.toLowerCase());
|
|
18273
18374
|
if (hi === -1) {
|
|
18274
18375
|
while (lines.length && lines[lines.length - 1].trim() === "") lines.pop();
|
|
18275
18376
|
lines.push("", heading, "", bullet);
|
|
18276
|
-
|
|
18377
|
+
fs55.writeFileSync(README, lines.join("\n") + "\n");
|
|
18277
18378
|
return true;
|
|
18278
18379
|
}
|
|
18279
18380
|
let end2 = hi + 1;
|
|
@@ -18287,15 +18388,15 @@ function addReadmeRef(id, title, relPath) {
|
|
|
18287
18388
|
const at = lastBullet !== -1 ? lastBullet + 1 : lines[hi + 1] === "" ? hi + 2 : hi + 1;
|
|
18288
18389
|
lines.splice(at, 0, bullet);
|
|
18289
18390
|
}
|
|
18290
|
-
|
|
18391
|
+
fs55.writeFileSync(README, lines.join("\n"));
|
|
18291
18392
|
return true;
|
|
18292
18393
|
}
|
|
18293
18394
|
function repointReadmeLink(id, oldRel, newRel, title) {
|
|
18294
|
-
if (!
|
|
18295
|
-
const oldLink = oldRel.split(
|
|
18296
|
-
const newLink = newRel.split(
|
|
18395
|
+
if (!fs55.existsSync(README)) return false;
|
|
18396
|
+
const oldLink = oldRel.split(path58.sep).join("/");
|
|
18397
|
+
const newLink = newRel.split(path58.sep).join("/");
|
|
18297
18398
|
const linkRe = new RegExp(`\\[#${id}\\b[^\\]]*\\]\\(${escapeRegex(oldLink)}\\)`);
|
|
18298
|
-
const lines =
|
|
18399
|
+
const lines = fs55.readFileSync(README, "utf8").split("\n");
|
|
18299
18400
|
let changed = false;
|
|
18300
18401
|
for (let i = 0; i < lines.length; i++) {
|
|
18301
18402
|
if (!lines[i].includes(`](${oldLink})`)) continue;
|
|
@@ -18305,7 +18406,7 @@ function repointReadmeLink(id, oldRel, newRel, title) {
|
|
|
18305
18406
|
changed = true;
|
|
18306
18407
|
}
|
|
18307
18408
|
}
|
|
18308
|
-
if (changed)
|
|
18409
|
+
if (changed) fs55.writeFileSync(README, lines.join("\n"));
|
|
18309
18410
|
return changed;
|
|
18310
18411
|
}
|
|
18311
18412
|
var isTableRow, isBulletStart, bulletIndent, TASKS_HEADING, escapeRegex;
|
|
@@ -18792,14 +18893,14 @@ function collect(body, card, host2) {
|
|
|
18792
18893
|
const active2 = /* @__PURE__ */ new Set();
|
|
18793
18894
|
const out = [];
|
|
18794
18895
|
const visit = (src, types, owner) => {
|
|
18795
|
-
const
|
|
18896
|
+
const path86 = src.replace(/[?#].*$/, "");
|
|
18796
18897
|
let resolved2;
|
|
18797
18898
|
try {
|
|
18798
|
-
resolved2 = host2.resolve(
|
|
18899
|
+
resolved2 = host2.resolve(path86, owner);
|
|
18799
18900
|
} catch (error) {
|
|
18800
18901
|
if (owner !== card) return { key: null, error: why(error) };
|
|
18801
18902
|
if (!nodes.has(src)) {
|
|
18802
|
-
const node2 = { key: src, file: null, kind: kindAt(
|
|
18903
|
+
const node2 = { key: src, file: null, kind: kindAt(path86, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
|
|
18803
18904
|
nodes.set(src, node2);
|
|
18804
18905
|
out.push(node2);
|
|
18805
18906
|
}
|
|
@@ -18884,16 +18985,16 @@ var init_collect = __esm({
|
|
|
18884
18985
|
});
|
|
18885
18986
|
|
|
18886
18987
|
// src/lib/dress-page.ts
|
|
18887
|
-
import
|
|
18888
|
-
import
|
|
18988
|
+
import fs56 from "node:fs";
|
|
18989
|
+
import path59 from "node:path";
|
|
18889
18990
|
function dressPage(file) {
|
|
18890
|
-
const folder =
|
|
18891
|
-
const html =
|
|
18991
|
+
const folder = path59.dirname(file);
|
|
18992
|
+
const html = fs56.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
|
|
18892
18993
|
const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
|
|
18893
18994
|
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 =
|
|
18995
|
+
const at2 = path59.resolve(folder, href);
|
|
18996
|
+
if (!at2.startsWith(folder + path59.sep) || !fs56.existsSync(at2)) return tag;
|
|
18997
|
+
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
18998
|
return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
|
|
18898
18999
|
});
|
|
18899
19000
|
const at = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
|
|
@@ -18905,25 +19006,25 @@ var init_dress_page = __esm({
|
|
|
18905
19006
|
"use strict";
|
|
18906
19007
|
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
19008
|
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) :
|
|
19009
|
+
referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) : fs56.readFileSync(file, "utf8");
|
|
18909
19010
|
}
|
|
18910
19011
|
});
|
|
18911
19012
|
|
|
18912
19013
|
// src/lib/preview-files.ts
|
|
18913
|
-
import
|
|
18914
|
-
import
|
|
19014
|
+
import fs57 from "node:fs";
|
|
19015
|
+
import path60 from "node:path";
|
|
18915
19016
|
function resolver(card, id) {
|
|
18916
|
-
const roots = [KANBAN,
|
|
18917
|
-
const real2 = (p) =>
|
|
18918
|
-
const inside2 = (p) => roots.some((root2) => p.startsWith(real2(root2) +
|
|
19017
|
+
const roots = [KANBAN, path60.join(ASSETS, String(id)), path60.join(MOCKUPS, String(id))];
|
|
19018
|
+
const real2 = (p) => fs57.existsSync(p) ? fs57.realpathSync(p) : p;
|
|
19019
|
+
const inside2 = (p) => roots.some((root2) => p.startsWith(real2(root2) + path60.sep));
|
|
18919
19020
|
return (src, owner) => {
|
|
18920
19021
|
if (/^[a-z][\w+.-]*:/i.test(src) || src.startsWith("#") || src.startsWith("//")) return null;
|
|
18921
|
-
if (
|
|
19022
|
+
if (path60.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
|
|
18922
19023
|
const held4 = /^\.(assets|mockups)\//.exec(src);
|
|
18923
|
-
const file = held4 ?
|
|
18924
|
-
if (!inside2(
|
|
18925
|
-
if (!
|
|
18926
|
-
return { key:
|
|
19024
|
+
const file = held4 ? path60.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path60.resolve(path60.dirname(owner), src);
|
|
19025
|
+
if (!inside2(path60.resolve(file)) || fs57.existsSync(file) && !inside2(fs57.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
|
|
19026
|
+
if (!fs57.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
|
|
19027
|
+
return { key: fs57.realpathSync(file), file };
|
|
18927
19028
|
};
|
|
18928
19029
|
}
|
|
18929
19030
|
function validatePreviewFiles(card, id, text4) {
|
|
@@ -18966,8 +19067,8 @@ var init_preview_files = __esm({
|
|
|
18966
19067
|
});
|
|
18967
19068
|
|
|
18968
19069
|
// src/lib/spec-contract.ts
|
|
18969
|
-
import
|
|
18970
|
-
import
|
|
19070
|
+
import fs58 from "node:fs";
|
|
19071
|
+
import path61 from "node:path";
|
|
18971
19072
|
function scanCardLines(lines, start = 0) {
|
|
18972
19073
|
const visible = lines.map(() => "");
|
|
18973
19074
|
let fence = null;
|
|
@@ -19000,18 +19101,18 @@ function scanCardLines(lines, start = 0) {
|
|
|
19000
19101
|
}
|
|
19001
19102
|
function snapshotSpecs() {
|
|
19002
19103
|
const out = /* @__PURE__ */ new Map();
|
|
19003
|
-
if (!
|
|
19104
|
+
if (!fs58.existsSync(TODO)) return out;
|
|
19004
19105
|
for (const file of walkMd(TODO)) {
|
|
19005
|
-
if (isLegacyRecurring(
|
|
19006
|
-
const id = idPrefix(
|
|
19007
|
-
if (id !== null) out.set(file, { id, text:
|
|
19106
|
+
if (isLegacyRecurring(path61.relative(TODO, file))) continue;
|
|
19107
|
+
const id = idPrefix(path61.basename(file) === "root.md" ? path61.basename(path61.dirname(file)) : path61.basename(file));
|
|
19108
|
+
if (id !== null) out.set(file, { id, text: fs58.readFileSync(file, "utf8") });
|
|
19008
19109
|
}
|
|
19009
19110
|
return out;
|
|
19010
19111
|
}
|
|
19011
19112
|
function enclosingGroups(file) {
|
|
19012
19113
|
const ids = [];
|
|
19013
19114
|
for (let root2 = enclosingGroupRoot(file); root2; root2 = enclosingGroupRoot(root2)) {
|
|
19014
|
-
const id = idPrefix(
|
|
19115
|
+
const id = idPrefix(path61.basename(path61.dirname(root2)));
|
|
19015
19116
|
if (id !== null) ids.push(id);
|
|
19016
19117
|
}
|
|
19017
19118
|
return ids;
|
|
@@ -19186,9 +19287,9 @@ function setEnd(lines, at) {
|
|
|
19186
19287
|
}
|
|
19187
19288
|
function inside(dir, name) {
|
|
19188
19289
|
try {
|
|
19189
|
-
const root2 =
|
|
19190
|
-
const real2 =
|
|
19191
|
-
return real2.startsWith(root2 +
|
|
19290
|
+
const root2 = fs58.realpathSync(dir);
|
|
19291
|
+
const real2 = fs58.realpathSync(path61.join(dir, name));
|
|
19292
|
+
return real2.startsWith(root2 + path61.sep) && fs58.statSync(real2).isFile() ? real2 : null;
|
|
19192
19293
|
} catch {
|
|
19193
19294
|
return null;
|
|
19194
19295
|
}
|
|
@@ -19206,7 +19307,7 @@ function variantsProblem(raw, src, id) {
|
|
|
19206
19307
|
if (files.length < 2 || !files.every((f) => typeof f === "string" && f)) return `variants needs at least two labels, each naming a file. ${shape}`;
|
|
19207
19308
|
if (!files.includes(src)) return `src="${src}" is not one of the variants. Set src to the version shown first.`;
|
|
19208
19309
|
if (id === void 0) return null;
|
|
19209
|
-
const dir =
|
|
19310
|
+
const dir = path61.join(ASSETS, String(id));
|
|
19210
19311
|
for (const f of files) {
|
|
19211
19312
|
const parts = f.split("/");
|
|
19212
19313
|
if (parts.length !== 3 || parts[0] !== ".assets" || parts[1] !== String(id) || !inside(dir, parts[2])) {
|
|
@@ -19216,12 +19317,12 @@ function variantsProblem(raw, src, id) {
|
|
|
19216
19317
|
return null;
|
|
19217
19318
|
}
|
|
19218
19319
|
function compareProblem(attrs, id) {
|
|
19219
|
-
const dir =
|
|
19320
|
+
const dir = path61.join(ASSETS, String(id));
|
|
19220
19321
|
const src = (message) => ({ rule: "compare-src", message });
|
|
19221
19322
|
const shots = (message) => ({ rule: "compare-shots", message });
|
|
19222
19323
|
const json = (file) => {
|
|
19223
19324
|
try {
|
|
19224
|
-
return file.endsWith(".json") ? JSON.parse(
|
|
19325
|
+
return file.endsWith(".json") ? JSON.parse(fs58.readFileSync(file, "utf8")) : null;
|
|
19225
19326
|
} catch {
|
|
19226
19327
|
return null;
|
|
19227
19328
|
}
|
|
@@ -19246,7 +19347,7 @@ function compareProblem(attrs, id) {
|
|
|
19246
19347
|
const file = inside(dir, named2.name);
|
|
19247
19348
|
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
19349
|
try {
|
|
19249
|
-
return { data: JSON.parse(
|
|
19350
|
+
return { data: JSON.parse(fs58.readFileSync(file, "utf8")) };
|
|
19250
19351
|
} catch {
|
|
19251
19352
|
return { message: `${at} is not valid JSON.` };
|
|
19252
19353
|
}
|
|
@@ -19264,7 +19365,7 @@ function compareProblem(attrs, id) {
|
|
|
19264
19365
|
}
|
|
19265
19366
|
function validateStoryboards(file, id, text4) {
|
|
19266
19367
|
const errors = [];
|
|
19267
|
-
const dir =
|
|
19368
|
+
const dir = path61.join(ASSETS, String(id));
|
|
19268
19369
|
for (const [tag, tagOf, rule, fix] of [
|
|
19269
19370
|
["Storyboard", storyboardTag, "storyboard-src", "Write the JSON there or fix the path."],
|
|
19270
19371
|
["Studio", studioTag, "studio-src", "Write it with `akb raw studio diagram <studio id> <card id>` or fix the path."]
|
|
@@ -19300,14 +19401,14 @@ var init_spec_contract = __esm({
|
|
|
19300
19401
|
});
|
|
19301
19402
|
|
|
19302
19403
|
// src/lib/reconcile.ts
|
|
19303
|
-
import
|
|
19304
|
-
import
|
|
19404
|
+
import fs59 from "node:fs";
|
|
19405
|
+
import path62 from "node:path";
|
|
19305
19406
|
function liveIds() {
|
|
19306
19407
|
const ids = /* @__PURE__ */ new Set();
|
|
19307
19408
|
for (const file of walkMd(TODO)) {
|
|
19308
|
-
const base =
|
|
19409
|
+
const base = path62.basename(file);
|
|
19309
19410
|
if (base === "README.md") continue;
|
|
19310
|
-
const id = base === "root.md" ? idPrefix(
|
|
19411
|
+
const id = base === "root.md" ? idPrefix(path62.basename(path62.dirname(file))) : idPrefix(base);
|
|
19311
19412
|
if (id != null) ids.add(id);
|
|
19312
19413
|
}
|
|
19313
19414
|
return ids;
|
|
@@ -19315,16 +19416,16 @@ function liveIds() {
|
|
|
19315
19416
|
function indexableCards() {
|
|
19316
19417
|
const out = [];
|
|
19317
19418
|
for (const dir of walkDirs(TODO)) {
|
|
19318
|
-
const id = idPrefix(
|
|
19319
|
-
if (id != null &&
|
|
19320
|
-
out.push({ id, rel:
|
|
19419
|
+
const id = idPrefix(path62.basename(dir));
|
|
19420
|
+
if (id != null && fs59.existsSync(path62.join(dir, "root.md"))) {
|
|
19421
|
+
out.push({ id, rel: path62.join(path62.relative(TODO, dir), "root.md").split(path62.sep).join("/") });
|
|
19321
19422
|
}
|
|
19322
19423
|
}
|
|
19323
19424
|
for (const file of walkMd(TODO)) {
|
|
19324
|
-
const base =
|
|
19425
|
+
const base = path62.basename(file);
|
|
19325
19426
|
if (base === "README.md" || base === "root.md") continue;
|
|
19326
|
-
const relTODO =
|
|
19327
|
-
const segs = relTODO.split(
|
|
19427
|
+
const relTODO = path62.relative(TODO, file);
|
|
19428
|
+
const segs = relTODO.split(path62.sep);
|
|
19328
19429
|
if (segs.length !== 1) continue;
|
|
19329
19430
|
const id = idPrefix(base);
|
|
19330
19431
|
if (id != null) out.push({ id, rel: segs.join("/") });
|
|
@@ -19333,7 +19434,7 @@ function indexableCards() {
|
|
|
19333
19434
|
}
|
|
19334
19435
|
function readmeComplaints(fix) {
|
|
19335
19436
|
const said2 = [];
|
|
19336
|
-
const lines =
|
|
19437
|
+
const lines = fs59.readFileSync(README, "utf8").split("\n");
|
|
19337
19438
|
const indexed = /* @__PURE__ */ new Set();
|
|
19338
19439
|
let fixed = 0;
|
|
19339
19440
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -19342,13 +19443,13 @@ function readmeComplaints(fix) {
|
|
|
19342
19443
|
const id = Number(m[1]);
|
|
19343
19444
|
const linkPath = m[2];
|
|
19344
19445
|
indexed.add(id);
|
|
19345
|
-
if (
|
|
19446
|
+
if (fs59.existsSync(path62.join(TODO, linkPath))) continue;
|
|
19346
19447
|
const found2 = locate(id);
|
|
19347
19448
|
if (!found2) {
|
|
19348
19449
|
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
19450
|
continue;
|
|
19350
19451
|
}
|
|
19351
|
-
const want = (found2.kind === "group" ?
|
|
19452
|
+
const want = (found2.kind === "group" ? path62.join(found2.rel, "root.md") : found2.rel).split(path62.sep).join("/");
|
|
19352
19453
|
if (want === linkPath) continue;
|
|
19353
19454
|
if (!fix) {
|
|
19354
19455
|
said2.push(`README links #${id} \u2192 ${linkPath}, which isn't there any more; the card is at ${want}.`);
|
|
@@ -19358,7 +19459,7 @@ function readmeComplaints(fix) {
|
|
|
19358
19459
|
said2.push(`README link #${id} pointed at missing ${linkPath} \u2192 repointed to ${want}.`);
|
|
19359
19460
|
fixed++;
|
|
19360
19461
|
}
|
|
19361
|
-
if (fixed)
|
|
19462
|
+
if (fixed) fs59.writeFileSync(README, lines.join("\n"));
|
|
19362
19463
|
for (const c of indexableCards()) {
|
|
19363
19464
|
if (!indexed.has(c.id)) {
|
|
19364
19465
|
said2.push(`card ${c.rel} (#${c.id}) is not in the README index. Add it under "## ${TASKS_HEADING}".`);
|
|
@@ -19370,11 +19471,11 @@ function crossRefComplaints() {
|
|
|
19370
19471
|
const said2 = [];
|
|
19371
19472
|
const live = liveIds();
|
|
19372
19473
|
for (const file of walkMd(TODO)) {
|
|
19373
|
-
const base =
|
|
19474
|
+
const base = path62.basename(file);
|
|
19374
19475
|
if (base === "README.md") continue;
|
|
19375
|
-
const ownerId = base === "root.md" ? idPrefix(
|
|
19476
|
+
const ownerId = base === "root.md" ? idPrefix(path62.basename(path62.dirname(file))) : idPrefix(base);
|
|
19376
19477
|
if (ownerId == null) continue;
|
|
19377
|
-
const { meta } = parseFrontmatter(
|
|
19478
|
+
const { meta } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
|
|
19378
19479
|
if (!meta) continue;
|
|
19379
19480
|
for (const field2 of ["blocked_by", "related"]) {
|
|
19380
19481
|
for (const ref of meta[field2] || []) {
|
|
@@ -19387,11 +19488,11 @@ function crossRefComplaints() {
|
|
|
19387
19488
|
return said2;
|
|
19388
19489
|
}
|
|
19389
19490
|
function reconcileBoard() {
|
|
19390
|
-
if (!
|
|
19491
|
+
if (!fs59.existsSync(README)) return;
|
|
19391
19492
|
for (const line of [...readmeComplaints(true), ...crossRefComplaints()]) warn2(line);
|
|
19392
19493
|
}
|
|
19393
19494
|
function boardComplaints() {
|
|
19394
|
-
if (!
|
|
19495
|
+
if (!fs59.existsSync(README)) return [];
|
|
19395
19496
|
try {
|
|
19396
19497
|
return [...readmeComplaints(false), ...crossRefComplaints()];
|
|
19397
19498
|
} catch {
|
|
@@ -19411,8 +19512,8 @@ var init_reconcile = __esm({
|
|
|
19411
19512
|
});
|
|
19412
19513
|
|
|
19413
19514
|
// src/commands/card.ts
|
|
19414
|
-
import
|
|
19415
|
-
import
|
|
19515
|
+
import fs60 from "node:fs";
|
|
19516
|
+
import path63 from "node:path";
|
|
19416
19517
|
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
19518
|
return [
|
|
19418
19519
|
summary,
|
|
@@ -19438,7 +19539,7 @@ function bodyFromFile(opts) {
|
|
|
19438
19539
|
if (opts.body === false) die("pass --body-file or --no-body, not both");
|
|
19439
19540
|
let text4;
|
|
19440
19541
|
try {
|
|
19441
|
-
text4 =
|
|
19542
|
+
text4 = fs60.readFileSync(opts.bodyFile, "utf8");
|
|
19442
19543
|
} catch {
|
|
19443
19544
|
die(`can't read ${opts.bodyFile} \u2014 write the body to a file, then pass its path`, { kind: "needs-input" });
|
|
19444
19545
|
}
|
|
@@ -19503,20 +19604,20 @@ function cmdCreate(opts) {
|
|
|
19503
19604
|
const start = opts.id;
|
|
19504
19605
|
const slug2 = slugify(opts.slug !== void 0 ? opts.slug : title);
|
|
19505
19606
|
const fileRel = `${start}-${slug2}.md`;
|
|
19506
|
-
const file =
|
|
19607
|
+
const file = path63.join(TODO, fileRel);
|
|
19507
19608
|
const held4 = locate(start) ?? locateArchived(start);
|
|
19508
|
-
if (held4 &&
|
|
19609
|
+
if (held4 && path63.basename(held4.target) === `${start}-${slug2}.md`) {
|
|
19509
19610
|
say(start);
|
|
19510
19611
|
say(` ${rel(held4.target)} was already written`);
|
|
19511
19612
|
return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
|
|
19512
19613
|
}
|
|
19513
19614
|
if (held4) die(`#${start} is already a card here (${rel(held4.target)})`, { kind: "id-taken", id: start });
|
|
19514
|
-
if (
|
|
19615
|
+
if (fs60.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
|
|
19515
19616
|
countBoardEvent(triage ? "cards_created_proposed" : "cards_created_asked");
|
|
19516
19617
|
const meta = { title, priority, status: "todo", blocked_by, related, modules, studio, previews, stages, triage, source, questions };
|
|
19517
19618
|
const scaffolded = !written && opts.body !== false;
|
|
19518
19619
|
const body = written ?? (scaffolded ? defaultBody() : "");
|
|
19519
|
-
|
|
19620
|
+
fs60.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
|
|
19520
19621
|
const indexed = addReadmeRef(start, title, fileRel);
|
|
19521
19622
|
say(start);
|
|
19522
19623
|
say(
|
|
@@ -19568,8 +19669,8 @@ function cmdUpdate(id, flags) {
|
|
|
19568
19669
|
if (creating) die(creating, { kind: "card-being-created", id });
|
|
19569
19670
|
const found2 = locate(id);
|
|
19570
19671
|
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(
|
|
19672
|
+
const file = found2.kind === "group" ? path63.join(found2.target, "root.md") : found2.target;
|
|
19673
|
+
const { meta, body } = parseFrontmatter(fs60.readFileSync(file, "utf8"));
|
|
19573
19674
|
if (!meta) die(`${rel(file)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
|
|
19574
19675
|
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
19676
|
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 +19744,26 @@ function cmdUpdate(id, flags) {
|
|
|
19643
19744
|
meta.status = "todo";
|
|
19644
19745
|
changes.push("status\u2192todo (open questions)");
|
|
19645
19746
|
}
|
|
19646
|
-
const curRel =
|
|
19747
|
+
const curRel = path63.relative(TODO, file);
|
|
19647
19748
|
const isSubtask = found2.kind === "file" && enclosingGroupRoot(file) !== null;
|
|
19648
|
-
let base =
|
|
19749
|
+
let base = path63.basename(file);
|
|
19649
19750
|
if (flags.slug !== void 0) {
|
|
19650
19751
|
if (found2.kind === "group") die("renaming a group root by script is not supported");
|
|
19651
19752
|
base = `${id}-${slugify(flags.slug)}.md`;
|
|
19652
19753
|
}
|
|
19653
|
-
const destRel =
|
|
19654
|
-
const dest =
|
|
19754
|
+
const destRel = path63.join(path63.dirname(curRel), base);
|
|
19755
|
+
const dest = path63.join(TODO, destRel);
|
|
19655
19756
|
const moving = dest !== file;
|
|
19656
|
-
if (moving &&
|
|
19657
|
-
|
|
19658
|
-
if (moving)
|
|
19757
|
+
if (moving && fs60.existsSync(dest)) die(`${rel(dest)} already exists`);
|
|
19758
|
+
fs60.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
|
|
19759
|
+
if (moving) fs60.renameSync(file, dest);
|
|
19659
19760
|
if (isSubtask) {
|
|
19660
19761
|
if (moving || changes.includes("title")) repointReadmeLink(id, curRel, destRel, meta.title);
|
|
19661
|
-
if (moving) changes.push(`renamed \u2192 ${destRel.split(
|
|
19762
|
+
if (moving) changes.push(`renamed \u2192 ${destRel.split(path63.sep).join("/")}`);
|
|
19662
19763
|
} else if (moving) {
|
|
19663
19764
|
stripReadmeRefs({ kind: "file", rel: curRel });
|
|
19664
19765
|
addReadmeRef(id, meta.title, destRel);
|
|
19665
|
-
changes.push(`renamed \u2192 ${destRel.split(
|
|
19766
|
+
changes.push(`renamed \u2192 ${destRel.split(path63.sep).join("/")}`);
|
|
19666
19767
|
} else if (changes.includes("title")) {
|
|
19667
19768
|
stripReadmeRefs({ kind: "file", rel: curRel });
|
|
19668
19769
|
addReadmeRef(id, meta.title, curRel);
|
|
@@ -19674,8 +19775,8 @@ function cmdUpdateQuestions(id, input) {
|
|
|
19674
19775
|
const ops = readQuestionOps(input.ops ?? []);
|
|
19675
19776
|
const found2 = locate(id);
|
|
19676
19777
|
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(
|
|
19778
|
+
const file = found2.kind === "group" ? path63.join(found2.target, "root.md") : found2.target;
|
|
19779
|
+
const { meta, body } = parseFrontmatter(fs60.readFileSync(file, "utf8"));
|
|
19679
19780
|
if (!meta) die(`${rel(file)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
|
|
19680
19781
|
for (const op of ops) {
|
|
19681
19782
|
if (!op.question?.agent) continue;
|
|
@@ -19697,7 +19798,7 @@ function cmdUpdateQuestions(id, input) {
|
|
|
19697
19798
|
meta.status = "todo";
|
|
19698
19799
|
changes.push("status\u2192todo (open questions)");
|
|
19699
19800
|
}
|
|
19700
|
-
|
|
19801
|
+
fs60.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
|
|
19701
19802
|
const closed2 = activeDelivery(id) ? "questions_closed_verify" : "questions_closed_user";
|
|
19702
19803
|
for (const _ of done2.closed) countBoardEvent(closed2);
|
|
19703
19804
|
say(`updated #${id} questions: ${changes.join(", ")} (${open3} open)`);
|
|
@@ -19764,13 +19865,13 @@ var init_config_template = __esm({
|
|
|
19764
19865
|
});
|
|
19765
19866
|
|
|
19766
19867
|
// src/lib/agent/local.ts
|
|
19767
|
-
import
|
|
19768
|
-
import
|
|
19868
|
+
import fs61 from "node:fs";
|
|
19869
|
+
import path64 from "node:path";
|
|
19769
19870
|
function takeLocalModels(board2) {
|
|
19770
|
-
const file =
|
|
19871
|
+
const file = path64.join(board2, ".local.json");
|
|
19771
19872
|
let held4;
|
|
19772
19873
|
try {
|
|
19773
|
-
held4 = configBlock(JSON.parse(
|
|
19874
|
+
held4 = configBlock(JSON.parse(fs61.readFileSync(file, "utf8")));
|
|
19774
19875
|
} catch {
|
|
19775
19876
|
return {};
|
|
19776
19877
|
}
|
|
@@ -19788,7 +19889,7 @@ function takeLocalModels(board2) {
|
|
|
19788
19889
|
}
|
|
19789
19890
|
if (!Object.keys(agents).length) return out;
|
|
19790
19891
|
delete held4.agents;
|
|
19791
|
-
|
|
19892
|
+
fs61.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
|
|
19792
19893
|
return out;
|
|
19793
19894
|
}
|
|
19794
19895
|
var LOCAL_IGNORE_LINE;
|
|
@@ -19849,12 +19950,12 @@ var init_identity2 = __esm({
|
|
|
19849
19950
|
});
|
|
19850
19951
|
|
|
19851
19952
|
// src/lib/signals/migrate.ts
|
|
19852
|
-
import
|
|
19853
|
-
import
|
|
19953
|
+
import fs62 from "node:fs";
|
|
19954
|
+
import path65 from "node:path";
|
|
19854
19955
|
function readHandled() {
|
|
19855
19956
|
let text4;
|
|
19856
19957
|
try {
|
|
19857
|
-
text4 =
|
|
19958
|
+
text4 = fs62.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
|
|
19858
19959
|
} catch {
|
|
19859
19960
|
return [];
|
|
19860
19961
|
}
|
|
@@ -19871,57 +19972,57 @@ function readHandled() {
|
|
|
19871
19972
|
return held4;
|
|
19872
19973
|
}
|
|
19873
19974
|
function lift(from, into) {
|
|
19874
|
-
|
|
19875
|
-
|
|
19975
|
+
fs62.mkdirSync(into, { recursive: true });
|
|
19976
|
+
fs62.renameSync(from, path65.join(into, freeName(into, path65.basename(from))));
|
|
19876
19977
|
}
|
|
19877
19978
|
function repoint(dir, from, into) {
|
|
19878
19979
|
let entries;
|
|
19879
19980
|
try {
|
|
19880
|
-
entries =
|
|
19981
|
+
entries = fs62.readdirSync(dir, { withFileTypes: true });
|
|
19881
19982
|
} catch {
|
|
19882
19983
|
return;
|
|
19883
19984
|
}
|
|
19884
19985
|
for (const entry of entries) {
|
|
19885
19986
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
19886
|
-
const file =
|
|
19887
|
-
const text4 =
|
|
19888
|
-
if (text4.includes(from))
|
|
19987
|
+
const file = path65.join(dir, entry.name);
|
|
19988
|
+
const text4 = fs62.readFileSync(file, "utf8");
|
|
19989
|
+
if (text4.includes(from)) fs62.writeFileSync(file, text4.split(from).join(into));
|
|
19889
19990
|
}
|
|
19890
19991
|
}
|
|
19891
19992
|
function dropIfEmpty2(dir) {
|
|
19892
19993
|
try {
|
|
19893
|
-
|
|
19994
|
+
fs62.rmdirSync(dir);
|
|
19894
19995
|
} catch {
|
|
19895
19996
|
}
|
|
19896
19997
|
}
|
|
19897
19998
|
function liftInbox() {
|
|
19898
|
-
if (!
|
|
19899
|
-
const oldFiles =
|
|
19900
|
-
if (
|
|
19901
|
-
for (const entry of
|
|
19902
|
-
if (entry.isFile()) lift(
|
|
19999
|
+
if (!fs62.existsSync(SIGNALS_OLD_INBOX)) return;
|
|
20000
|
+
const oldFiles = path65.join(SIGNALS_OLD_INBOX, "files");
|
|
20001
|
+
if (fs62.existsSync(oldFiles)) {
|
|
20002
|
+
for (const entry of fs62.readdirSync(oldFiles, { withFileTypes: true })) {
|
|
20003
|
+
if (entry.isFile()) lift(path65.join(oldFiles, entry.name), SIGNALS_FILES);
|
|
19903
20004
|
}
|
|
19904
20005
|
dropIfEmpty2(oldFiles);
|
|
19905
20006
|
}
|
|
19906
20007
|
const held4 = new Set(readFolder2(TRIAGE).map((signal2) => signal2.sourceId));
|
|
19907
|
-
for (const entry of
|
|
20008
|
+
for (const entry of fs62.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
|
|
19908
20009
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
19909
|
-
const from =
|
|
20010
|
+
const from = path65.join(SIGNALS_OLD_INBOX, entry.name);
|
|
19910
20011
|
const item = parse(from);
|
|
19911
20012
|
if (item && held4.has(item.sourceId)) {
|
|
19912
|
-
|
|
20013
|
+
fs62.rmSync(from, { force: true });
|
|
19913
20014
|
continue;
|
|
19914
20015
|
}
|
|
19915
20016
|
if (item) held4.add(item.sourceId);
|
|
19916
20017
|
lift(from, TRIAGE);
|
|
19917
20018
|
}
|
|
19918
|
-
const wasAt = asWritten(
|
|
20019
|
+
const wasAt = asWritten(path65.join(SIGNALS_OLD_INBOX, "files"));
|
|
19919
20020
|
const nowAt = asWritten(SIGNALS_FILES);
|
|
19920
20021
|
for (const dir of [TRIAGE, SIGNALS_ARCHIVED, SIGNALS_DISMISSED]) repoint(dir, wasAt, nowAt);
|
|
19921
20022
|
dropIfEmpty2(SIGNALS_OLD_INBOX);
|
|
19922
20023
|
}
|
|
19923
20024
|
function liftHandled() {
|
|
19924
|
-
if (!
|
|
20025
|
+
if (!fs62.existsSync(SIGNALS_OLD_HANDLED)) return;
|
|
19925
20026
|
const lines = readHandled();
|
|
19926
20027
|
const held4 = /* @__PURE__ */ new Set([
|
|
19927
20028
|
...readFolder2(TRIAGE).map((signal2) => signal2.sourceId),
|
|
@@ -19931,7 +20032,7 @@ function liftHandled() {
|
|
|
19931
20032
|
for (const { sourceId, when } of lines) {
|
|
19932
20033
|
if (held4.has(sourceId)) continue;
|
|
19933
20034
|
held4.add(sourceId);
|
|
19934
|
-
|
|
20035
|
+
fs62.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
|
|
19935
20036
|
const name = freeName(SIGNALS_DISMISSED, fileName("", sourceId));
|
|
19936
20037
|
const front = [
|
|
19937
20038
|
"---",
|
|
@@ -19941,13 +20042,13 @@ function liftHandled() {
|
|
|
19941
20042
|
"---",
|
|
19942
20043
|
""
|
|
19943
20044
|
];
|
|
19944
|
-
|
|
20045
|
+
fs62.writeFileSync(path65.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
|
|
19945
20046
|
`);
|
|
19946
20047
|
}
|
|
19947
|
-
|
|
20048
|
+
fs62.rmSync(SIGNALS_OLD_HANDLED, { force: true });
|
|
19948
20049
|
}
|
|
19949
20050
|
function migrateTriage() {
|
|
19950
|
-
if (!
|
|
20051
|
+
if (!fs62.existsSync(SIGNALS_OLD_INBOX) && !fs62.existsSync(SIGNALS_OLD_HANDLED)) return;
|
|
19951
20052
|
try {
|
|
19952
20053
|
liftInbox();
|
|
19953
20054
|
liftHandled();
|
|
@@ -19962,13 +20063,13 @@ var init_migrate = __esm({
|
|
|
19962
20063
|
init_yaml();
|
|
19963
20064
|
init_inbox();
|
|
19964
20065
|
HANDLED_LINE = /^-\s+(.+?)\s+—\s+(.+)$/;
|
|
19965
|
-
asWritten = (dir) => `${rel(dir).split(
|
|
20066
|
+
asWritten = (dir) => `${rel(dir).split(path65.sep).join("/")}/`;
|
|
19966
20067
|
}
|
|
19967
20068
|
});
|
|
19968
20069
|
|
|
19969
20070
|
// src/lib/signals/add.ts
|
|
19970
|
-
import
|
|
19971
|
-
import
|
|
20071
|
+
import fs63 from "node:fs";
|
|
20072
|
+
import path66 from "node:path";
|
|
19972
20073
|
import { createHash as createHash4 } from "node:crypto";
|
|
19973
20074
|
function linkTitle(url) {
|
|
19974
20075
|
let at;
|
|
@@ -19981,7 +20082,7 @@ function linkTitle(url) {
|
|
|
19981
20082
|
return oneLine(where) || url.slice(0, TITLE_MAX);
|
|
19982
20083
|
}
|
|
19983
20084
|
function asText(file) {
|
|
19984
|
-
const ext =
|
|
20085
|
+
const ext = path66.extname(file.name).toLowerCase();
|
|
19985
20086
|
if (!file.type.startsWith("text/") && file.type !== "application/json" && !TEXT_EXTENSIONS.has(ext)) return null;
|
|
19986
20087
|
try {
|
|
19987
20088
|
const text4 = new TextDecoder("utf-8", { fatal: true }).decode(file.data);
|
|
@@ -19991,9 +20092,9 @@ function asText(file) {
|
|
|
19991
20092
|
}
|
|
19992
20093
|
}
|
|
19993
20094
|
function fileName2(name, data) {
|
|
19994
|
-
const base =
|
|
19995
|
-
const ext =
|
|
19996
|
-
const word =
|
|
20095
|
+
const base = path66.basename(name);
|
|
20096
|
+
const ext = path66.extname(base).toLowerCase().slice(0, 12);
|
|
20097
|
+
const word = path66.basename(base, path66.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
|
|
19997
20098
|
const hash2 = createHash4("sha256").update(data).digest("hex").slice(0, 8);
|
|
19998
20099
|
return `${word}-${hash2}${ext}`;
|
|
19999
20100
|
}
|
|
@@ -20002,9 +20103,9 @@ function addToInbox(drop) {
|
|
|
20002
20103
|
const typed = (drop.text ?? "").trim();
|
|
20003
20104
|
const file = drop.file;
|
|
20004
20105
|
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: `${
|
|
20106
|
+
if (file && file.data.length === 0) return { ok: false, error: `${path66.basename(file.name)} is empty.` };
|
|
20006
20107
|
if (file && file.data.length > MAX_BYTES2) {
|
|
20007
|
-
return { ok: false, error: `${
|
|
20108
|
+
return { ok: false, error: `${path66.basename(file.name)} is over ${MAX_BYTES2 / 1024 / 1024} MB \u2014 too big for the board.` };
|
|
20008
20109
|
}
|
|
20009
20110
|
const read3 = describe(typed, file);
|
|
20010
20111
|
const keep2 = read3.keep;
|
|
@@ -20026,8 +20127,8 @@ ${incoming.summary}`);
|
|
|
20026
20127
|
if (seen.status === "pending" || seen.status === "archived") return { ok: false, error: `${sayHit(seen)}.` };
|
|
20027
20128
|
try {
|
|
20028
20129
|
if (keep2) {
|
|
20029
|
-
|
|
20030
|
-
|
|
20130
|
+
fs63.mkdirSync(SIGNALS_FILES, { recursive: true });
|
|
20131
|
+
fs63.writeFileSync(keep2.at, keep2.data);
|
|
20031
20132
|
}
|
|
20032
20133
|
return { ok: true, signal: writeSignal({ ...incoming, sourceId }, formatStamp(/* @__PURE__ */ new Date()), drop.slug) };
|
|
20033
20134
|
} catch (e) {
|
|
@@ -20041,7 +20142,7 @@ function describe(typed, file) {
|
|
|
20041
20142
|
return only ? [only] : [];
|
|
20042
20143
|
};
|
|
20043
20144
|
if (file) {
|
|
20044
|
-
const name =
|
|
20145
|
+
const name = path66.basename(file.name);
|
|
20045
20146
|
const text4 = asText(file);
|
|
20046
20147
|
const note = typed ? `
|
|
20047
20148
|
|
|
@@ -20053,7 +20154,7 @@ ${typed}` : "";
|
|
|
20053
20154
|
const at = keepAt(file);
|
|
20054
20155
|
return {
|
|
20055
20156
|
incoming: {
|
|
20056
|
-
title:
|
|
20157
|
+
title: path66.basename(name, path66.extname(name)) || name,
|
|
20057
20158
|
summary: `${name} \u2014 ${boardRel2(at)}${note}`,
|
|
20058
20159
|
...named2
|
|
20059
20160
|
},
|
|
@@ -20091,73 +20192,73 @@ var init_add = __esm({
|
|
|
20091
20192
|
MAX_BYTES2 = 25 * 1024 * 1024;
|
|
20092
20193
|
TITLE_MAX = 120;
|
|
20093
20194
|
TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".text", ".csv", ".json", ".yml", ".yaml", ".log"]);
|
|
20094
|
-
boardRel2 = (file) => rel(file).split(
|
|
20195
|
+
boardRel2 = (file) => rel(file).split(path66.sep).join("/");
|
|
20095
20196
|
oneLine = (text4) => {
|
|
20096
20197
|
const first = text4.split("\n").find((line) => line.trim()) ?? "";
|
|
20097
20198
|
const clean = first.replace(/^#+\s*/, "").trim();
|
|
20098
20199
|
return clean.length > TITLE_MAX ? `${clean.slice(0, TITLE_MAX - 1).trimEnd()}\u2026` : clean;
|
|
20099
20200
|
};
|
|
20100
|
-
keepAt = (file) =>
|
|
20201
|
+
keepAt = (file) => path66.join(SIGNALS_FILES, fileName2(file.name, file.data));
|
|
20101
20202
|
}
|
|
20102
20203
|
});
|
|
20103
20204
|
|
|
20104
20205
|
// src/lib/recurring.ts
|
|
20105
|
-
import
|
|
20106
|
-
import
|
|
20206
|
+
import fs64 from "node:fs";
|
|
20207
|
+
import path67 from "node:path";
|
|
20107
20208
|
function migratePruneMemoryCard() {
|
|
20108
20209
|
const dir = recurringDir();
|
|
20109
20210
|
let names3;
|
|
20110
20211
|
try {
|
|
20111
|
-
names3 =
|
|
20212
|
+
names3 = fs64.readdirSync(dir);
|
|
20112
20213
|
} catch {
|
|
20113
20214
|
return null;
|
|
20114
20215
|
}
|
|
20115
20216
|
const name = names3.find((entry) => entry.endsWith(`-${PRUNE_SLUG}.md`));
|
|
20116
20217
|
if (!name) return null;
|
|
20117
|
-
const file =
|
|
20218
|
+
const file = path67.join(dir, name);
|
|
20118
20219
|
try {
|
|
20119
|
-
const { meta } = parseFrontmatter(
|
|
20220
|
+
const { meta } = parseFrontmatter(fs64.readFileSync(file, "utf8"));
|
|
20120
20221
|
const cadence = meta?.cadence;
|
|
20121
20222
|
if (typeof cadence === "string") adoptMemoryPruneCadence(cadence);
|
|
20122
20223
|
} catch {
|
|
20123
20224
|
}
|
|
20124
|
-
|
|
20225
|
+
fs64.rmSync(file, { force: true });
|
|
20125
20226
|
return rel(file);
|
|
20126
20227
|
}
|
|
20127
20228
|
function legacyCards() {
|
|
20128
20229
|
const dir = recurringDir();
|
|
20129
|
-
if (!
|
|
20230
|
+
if (!fs64.existsSync(dir)) return [];
|
|
20130
20231
|
const cards = [];
|
|
20131
|
-
for (const entry of
|
|
20232
|
+
for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
|
|
20132
20233
|
const id = idPrefix(entry.name);
|
|
20133
20234
|
if (id === null) continue;
|
|
20134
|
-
const full =
|
|
20235
|
+
const full = path67.join(dir, entry.name);
|
|
20135
20236
|
const slug2 = entry.name.replace(/\.md$/, "").replace(/^\d+-?/, "");
|
|
20136
20237
|
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:
|
|
20238
|
+
else if (entry.isDirectory() && fs64.existsSync(path67.join(full, "root.md"))) {
|
|
20239
|
+
cards.push({ id, slug: slug2, file: path67.join(full, "root.md"), folder: full });
|
|
20139
20240
|
}
|
|
20140
20241
|
}
|
|
20141
20242
|
return cards.sort((a, b) => a.id - b.id);
|
|
20142
20243
|
}
|
|
20143
20244
|
function mergeInto2(from, to, skip = []) {
|
|
20144
|
-
|
|
20145
|
-
for (const entry of
|
|
20245
|
+
fs64.mkdirSync(to, { recursive: true });
|
|
20246
|
+
for (const entry of fs64.readdirSync(from, { withFileTypes: true })) {
|
|
20146
20247
|
if (skip.includes(entry.name)) continue;
|
|
20147
|
-
const source =
|
|
20148
|
-
const target =
|
|
20149
|
-
if (!
|
|
20150
|
-
else if (entry.isDirectory() &&
|
|
20248
|
+
const source = path67.join(from, entry.name);
|
|
20249
|
+
const target = path67.join(to, entry.name);
|
|
20250
|
+
if (!fs64.existsSync(target)) fs64.renameSync(source, target);
|
|
20251
|
+
else if (entry.isDirectory() && fs64.statSync(target).isDirectory()) mergeInto2(source, target);
|
|
20151
20252
|
}
|
|
20152
|
-
if (isEmpty(from))
|
|
20253
|
+
if (isEmpty(from)) fs64.rmSync(from, { recursive: true, force: true });
|
|
20153
20254
|
}
|
|
20154
20255
|
function moveSideFolders() {
|
|
20155
20256
|
const dir = recurringDir();
|
|
20156
|
-
for (const entry of
|
|
20257
|
+
for (const entry of fs64.readdirSync(dir, { withFileTypes: true })) {
|
|
20157
20258
|
if (!entry.isDirectory() || idPrefix(entry.name) !== null) continue;
|
|
20158
|
-
const from =
|
|
20159
|
-
if (isEmpty(from))
|
|
20160
|
-
else mergeInto2(from,
|
|
20259
|
+
const from = path67.join(dir, entry.name);
|
|
20260
|
+
if (isEmpty(from)) fs64.rmSync(from, { recursive: true, force: true });
|
|
20261
|
+
else mergeInto2(from, path67.join(AGENTS, entry.name));
|
|
20161
20262
|
}
|
|
20162
20263
|
}
|
|
20163
20264
|
function sections(body) {
|
|
@@ -20207,8 +20308,8 @@ function agentName(card, text4) {
|
|
|
20207
20308
|
const known2 = /* @__PURE__ */ new Set([...specAgentCatalog().agents.map((a) => a.name), ...ROLE_NAMES]);
|
|
20208
20309
|
for (const name of [slug2, `${slug2}-${card.id}`]) {
|
|
20209
20310
|
if (!AGENT_NAME.test(name)) continue;
|
|
20210
|
-
const file =
|
|
20211
|
-
const written =
|
|
20311
|
+
const file = path67.join(AGENTS, name, AGENT_FILE2);
|
|
20312
|
+
const written = fs64.existsSync(file) ? fs64.readFileSync(file, "utf8") : null;
|
|
20212
20313
|
if (written === text4(name)) return name;
|
|
20213
20314
|
if (written === null && !known2.has(name)) return name;
|
|
20214
20315
|
}
|
|
@@ -20225,11 +20326,11 @@ ${q.options.map((o) => `- ${o}`).join("\n")}` : "";
|
|
|
20225
20326
|
function removeCard(card) {
|
|
20226
20327
|
dropCrossRefs(card.id);
|
|
20227
20328
|
const target = card.folder ?? card.file;
|
|
20228
|
-
stripReadmeRefs({ kind: card.folder ? "group" : "file", rel:
|
|
20229
|
-
|
|
20329
|
+
stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path67.relative(TODO, target).split(path67.sep).join("/") });
|
|
20330
|
+
fs64.rmSync(target, { recursive: true, force: true });
|
|
20230
20331
|
}
|
|
20231
20332
|
function migrateCard(card) {
|
|
20232
|
-
const { meta, body } = parseFrontmatter(
|
|
20333
|
+
const { meta, body } = parseFrontmatter(fs64.readFileSync(card.file, "utf8"));
|
|
20233
20334
|
if (!meta) throw new Error("its frontmatter cannot be read");
|
|
20234
20335
|
const raw = meta;
|
|
20235
20336
|
const said2 = (key) => typeof raw[key] === "string" ? raw[key].trim() : "";
|
|
@@ -20239,19 +20340,19 @@ function migrateCard(card) {
|
|
|
20239
20340
|
if (!flow) throw new Error(noStudioMessage(""));
|
|
20240
20341
|
const text4 = (name2) => agentText(name2, meta.title || card.slug, body);
|
|
20241
20342
|
const name = agentName(card, text4);
|
|
20242
|
-
const dir =
|
|
20243
|
-
const file =
|
|
20244
|
-
const madeDir = !
|
|
20245
|
-
const wrote = !
|
|
20343
|
+
const dir = path67.join(AGENTS, name);
|
|
20344
|
+
const file = path67.join(dir, AGENT_FILE2);
|
|
20345
|
+
const madeDir = !fs64.existsSync(dir);
|
|
20346
|
+
const wrote = !fs64.existsSync(file);
|
|
20246
20347
|
try {
|
|
20247
|
-
|
|
20248
|
-
if (wrote)
|
|
20348
|
+
fs64.mkdirSync(dir, { recursive: true });
|
|
20349
|
+
if (wrote) fs64.writeFileSync(file, text4(name));
|
|
20249
20350
|
const adopted = adoptStudioScheduled(flow.id, name, { cadence, lastRun });
|
|
20250
20351
|
if (!adopted.ok) throw new Error(adopted.error);
|
|
20251
20352
|
questionsToTriage(meta, name);
|
|
20252
20353
|
} catch (e) {
|
|
20253
|
-
if (madeDir)
|
|
20254
|
-
else if (wrote)
|
|
20354
|
+
if (madeDir) fs64.rmSync(dir, { recursive: true, force: true });
|
|
20355
|
+
else if (wrote) fs64.rmSync(file, { force: true });
|
|
20255
20356
|
throw e;
|
|
20256
20357
|
}
|
|
20257
20358
|
if (card.folder) mergeInto2(card.folder, dir, ["root.md"]);
|
|
@@ -20261,7 +20362,7 @@ function migrateCard(card) {
|
|
|
20261
20362
|
function migrateRecurringCards() {
|
|
20262
20363
|
const done2 = { agents: [], removed: [], failed: [] };
|
|
20263
20364
|
const dir = recurringDir();
|
|
20264
|
-
if (!
|
|
20365
|
+
if (!fs64.existsSync(dir)) return done2;
|
|
20265
20366
|
migratePruneMemoryCard();
|
|
20266
20367
|
moveSideFolders();
|
|
20267
20368
|
for (const card of legacyCards()) {
|
|
@@ -20274,7 +20375,7 @@ function migrateRecurringCards() {
|
|
|
20274
20375
|
done2.failed.push({ card: rel(card.file), why: e instanceof Error ? e.message : String(e) });
|
|
20275
20376
|
}
|
|
20276
20377
|
}
|
|
20277
|
-
if (isEmpty(dir))
|
|
20378
|
+
if (isEmpty(dir)) fs64.rmSync(dir, { recursive: true, force: true });
|
|
20278
20379
|
return done2;
|
|
20279
20380
|
}
|
|
20280
20381
|
function recurringMigrationLines(done2) {
|
|
@@ -20307,14 +20408,14 @@ var init_recurring = __esm({
|
|
|
20307
20408
|
PRUNE_SLUG = "prune-the-memory";
|
|
20308
20409
|
FETCH_SLUG = "fetch-triage-items";
|
|
20309
20410
|
AGENT_FILE2 = "AGENT.md";
|
|
20310
|
-
recurringDir = () =>
|
|
20311
|
-
isEmpty = (dir) =>
|
|
20411
|
+
recurringDir = () => path67.join(TODO, LEGACY_RECURRING);
|
|
20412
|
+
isEmpty = (dir) => fs64.readdirSync(dir).every((name) => name === ".DS_Store");
|
|
20312
20413
|
SECTION = /^##\s+(.+?)\s*$/;
|
|
20313
20414
|
}
|
|
20314
20415
|
});
|
|
20315
20416
|
|
|
20316
20417
|
// src/commands/init.ts
|
|
20317
|
-
import
|
|
20418
|
+
import fs65 from "node:fs";
|
|
20318
20419
|
function boardReadme() {
|
|
20319
20420
|
return `# Board
|
|
20320
20421
|
|
|
@@ -20327,20 +20428,20 @@ _(none)_
|
|
|
20327
20428
|
`;
|
|
20328
20429
|
}
|
|
20329
20430
|
function writeConfigIfMissing() {
|
|
20330
|
-
if (
|
|
20331
|
-
|
|
20332
|
-
|
|
20431
|
+
if (fs65.existsSync(CONFIG)) return false;
|
|
20432
|
+
fs65.mkdirSync(KANBAN, { recursive: true });
|
|
20433
|
+
fs65.writeFileSync(CONFIG, CONFIG_TEMPLATE);
|
|
20333
20434
|
return true;
|
|
20334
20435
|
}
|
|
20335
20436
|
function writeModulesIfMissing() {
|
|
20336
|
-
if (
|
|
20337
|
-
|
|
20338
|
-
|
|
20437
|
+
if (fs65.existsSync(MODULES_MD)) return false;
|
|
20438
|
+
fs65.mkdirSync(KANBAN, { recursive: true });
|
|
20439
|
+
fs65.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
|
|
20339
20440
|
return true;
|
|
20340
20441
|
}
|
|
20341
20442
|
function writeGitignoreIfMissing() {
|
|
20342
|
-
|
|
20343
|
-
const text4 =
|
|
20443
|
+
fs65.mkdirSync(KANBAN, { recursive: true });
|
|
20444
|
+
const text4 = fs65.existsSync(KANBAN_GITIGNORE) ? fs65.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
|
|
20344
20445
|
const has = (rule) => text4.split("\n").some((line) => line.trim() === rule.line);
|
|
20345
20446
|
const missing = IGNORE_RULES.filter((rule) => !has(rule));
|
|
20346
20447
|
if (!missing.length) return false;
|
|
@@ -20348,37 +20449,37 @@ function writeGitignoreIfMissing() {
|
|
|
20348
20449
|
${rule.line}
|
|
20349
20450
|
`).join("");
|
|
20350
20451
|
const separator = !text4 || text4.endsWith("\n") ? "" : "\n";
|
|
20351
|
-
|
|
20452
|
+
fs65.writeFileSync(KANBAN_GITIGNORE, `${text4}${separator}${block}`);
|
|
20352
20453
|
return true;
|
|
20353
20454
|
}
|
|
20354
20455
|
function writeSkeletonIfMissing() {
|
|
20355
20456
|
const added = [];
|
|
20356
|
-
if (!
|
|
20357
|
-
|
|
20457
|
+
if (!fs65.existsSync(TODO)) {
|
|
20458
|
+
fs65.mkdirSync(TODO, { recursive: true });
|
|
20358
20459
|
added.push(`${rel(TODO)}/`);
|
|
20359
20460
|
}
|
|
20360
|
-
if (!
|
|
20361
|
-
|
|
20461
|
+
if (!fs65.existsSync(README)) {
|
|
20462
|
+
fs65.writeFileSync(README, boardReadme());
|
|
20362
20463
|
added.push(rel(README));
|
|
20363
20464
|
}
|
|
20364
20465
|
return added;
|
|
20365
20466
|
}
|
|
20366
20467
|
function retireReleases() {
|
|
20367
20468
|
const done2 = [];
|
|
20368
|
-
if (
|
|
20369
|
-
|
|
20469
|
+
if (fs65.existsSync(RELEASES)) {
|
|
20470
|
+
fs65.rmSync(RELEASES);
|
|
20370
20471
|
done2.push(`deleted ${rel(RELEASES)}`);
|
|
20371
20472
|
}
|
|
20372
20473
|
let cards = 0;
|
|
20373
20474
|
for (const dir of [TODO, ARCHIVE]) {
|
|
20374
|
-
if (!
|
|
20475
|
+
if (!fs65.existsSync(dir)) continue;
|
|
20375
20476
|
for (const file of walkMd(dir)) {
|
|
20376
|
-
const text4 =
|
|
20477
|
+
const text4 = fs65.readFileSync(file, "utf8");
|
|
20377
20478
|
const end2 = text4.startsWith("---\n") ? text4.indexOf("\n---", 3) : -1;
|
|
20378
20479
|
if (end2 < 0) continue;
|
|
20379
20480
|
const head2 = text4.slice(0, end2).replace(/\nrelease:[^\n]*/, "");
|
|
20380
20481
|
if (head2.length === end2) continue;
|
|
20381
|
-
|
|
20482
|
+
fs65.writeFileSync(file, head2 + text4.slice(end2));
|
|
20382
20483
|
cards++;
|
|
20383
20484
|
}
|
|
20384
20485
|
}
|
|
@@ -20386,7 +20487,7 @@ function retireReleases() {
|
|
|
20386
20487
|
return done2.join(", ");
|
|
20387
20488
|
}
|
|
20388
20489
|
function cmdInit() {
|
|
20389
|
-
if (
|
|
20490
|
+
if (fs65.existsSync(KANBAN)) {
|
|
20390
20491
|
const added = [
|
|
20391
20492
|
...writeSkeletonIfMissing(),
|
|
20392
20493
|
writeConfigIfMissing() && rel(CONFIG),
|
|
@@ -20421,8 +20522,8 @@ function cmdInit() {
|
|
|
20421
20522
|
}
|
|
20422
20523
|
return { board: rel(KANBAN), created: false, added, memory_paths: scaffolded.map((s) => rel(s.dir)) };
|
|
20423
20524
|
}
|
|
20424
|
-
|
|
20425
|
-
|
|
20525
|
+
fs65.mkdirSync(TODO, { recursive: true });
|
|
20526
|
+
fs65.writeFileSync(README, boardReadme());
|
|
20426
20527
|
writeConfigIfMissing();
|
|
20427
20528
|
scaffoldProjectMemory();
|
|
20428
20529
|
writeModulesIfMissing();
|
|
@@ -20511,25 +20612,25 @@ var init_scheduled = __esm({
|
|
|
20511
20612
|
});
|
|
20512
20613
|
|
|
20513
20614
|
// src/lib/card-age.ts
|
|
20514
|
-
import
|
|
20515
|
-
import
|
|
20615
|
+
import fs66 from "node:fs";
|
|
20616
|
+
import path68 from "node:path";
|
|
20516
20617
|
function staleAfterIn(config) {
|
|
20517
20618
|
const days = Number(LINE.exec(config)?.[1]);
|
|
20518
20619
|
return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
|
|
20519
20620
|
}
|
|
20520
20621
|
function staleAfter() {
|
|
20521
|
-
if (!
|
|
20522
|
-
return staleAfterIn(
|
|
20622
|
+
if (!fs66.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
|
|
20623
|
+
return staleAfterIn(fs66.readFileSync(CONFIG, "utf8"));
|
|
20523
20624
|
}
|
|
20524
20625
|
function todoPathspec(top) {
|
|
20525
|
-
const from =
|
|
20526
|
-
if (!from || from.startsWith("..") ||
|
|
20527
|
-
return from.split(
|
|
20626
|
+
const from = path68.relative(real(top), real(TODO));
|
|
20627
|
+
if (!from || from.startsWith("..") || path68.isAbsolute(from)) return null;
|
|
20628
|
+
return from.split(path68.sep).join("/");
|
|
20528
20629
|
}
|
|
20529
20630
|
function cardFile2(spec, printed) {
|
|
20530
20631
|
const p = unquotePath(printed);
|
|
20531
20632
|
if (!p.startsWith(`${spec}/`)) return null;
|
|
20532
|
-
return
|
|
20633
|
+
return path68.join(TODO, ...p.slice(spec.length + 1).split("/"));
|
|
20533
20634
|
}
|
|
20534
20635
|
function dirtyCards(top, spec) {
|
|
20535
20636
|
const out = git(["status", "--porcelain", "--untracked-files=all", "--", spec], top);
|
|
@@ -20576,9 +20677,9 @@ var init_card_age = __esm({
|
|
|
20576
20677
|
gitTop = () => git(["rev-parse", "--show-toplevel"])?.trim() || null;
|
|
20577
20678
|
real = (p) => {
|
|
20578
20679
|
try {
|
|
20579
|
-
return
|
|
20680
|
+
return fs66.realpathSync(p);
|
|
20580
20681
|
} catch {
|
|
20581
|
-
return
|
|
20682
|
+
return path68.resolve(p);
|
|
20582
20683
|
}
|
|
20583
20684
|
};
|
|
20584
20685
|
unquotePath = (line) => {
|
|
@@ -20612,8 +20713,8 @@ var init_card_holds = __esm({
|
|
|
20612
20713
|
});
|
|
20613
20714
|
|
|
20614
20715
|
// src/commands/list.ts
|
|
20615
|
-
import
|
|
20616
|
-
import
|
|
20716
|
+
import fs67 from "node:fs";
|
|
20717
|
+
import path69 from "node:path";
|
|
20617
20718
|
function summaryLine(body) {
|
|
20618
20719
|
const lines = body.split("\n");
|
|
20619
20720
|
let i = 0;
|
|
@@ -20629,13 +20730,13 @@ function summaryLine(body) {
|
|
|
20629
20730
|
function openRows() {
|
|
20630
20731
|
const rows = [];
|
|
20631
20732
|
for (const file of walkMd(TODO)) {
|
|
20632
|
-
const base =
|
|
20733
|
+
const base = path69.basename(file);
|
|
20633
20734
|
if (base === "README.md") continue;
|
|
20634
20735
|
const isRoot = base === "root.md";
|
|
20635
|
-
const id = isRoot ? idPrefix(
|
|
20736
|
+
const id = isRoot ? idPrefix(path69.basename(path69.dirname(file))) : idPrefix(base);
|
|
20636
20737
|
if (id == null) continue;
|
|
20637
|
-
if (isLegacyRecurring(
|
|
20638
|
-
const { meta, body } = parseFrontmatter(
|
|
20738
|
+
if (isLegacyRecurring(path69.relative(TODO, file))) continue;
|
|
20739
|
+
const { meta, body } = parseFrontmatter(fs67.readFileSync(file, "utf8"));
|
|
20639
20740
|
rows.push({
|
|
20640
20741
|
id,
|
|
20641
20742
|
file,
|
|
@@ -20677,15 +20778,15 @@ function cmdStale(rows, all2, scope, mod) {
|
|
|
20677
20778
|
}
|
|
20678
20779
|
function archivedFiles() {
|
|
20679
20780
|
const files = /* @__PURE__ */ new Map();
|
|
20680
|
-
if (!
|
|
20781
|
+
if (!fs67.existsSync(ARCHIVE)) return files;
|
|
20681
20782
|
for (const file of walkMd(ARCHIVE)) {
|
|
20682
|
-
const id = idPrefix(
|
|
20783
|
+
const id = idPrefix(path69.basename(file));
|
|
20683
20784
|
if (id !== null) files.set(id, file);
|
|
20684
20785
|
}
|
|
20685
20786
|
for (const dir of walkDirs(ARCHIVE)) {
|
|
20686
|
-
const id = idPrefix(
|
|
20687
|
-
const root2 =
|
|
20688
|
-
if (id !== null &&
|
|
20787
|
+
const id = idPrefix(path69.basename(dir));
|
|
20788
|
+
const root2 = path69.join(dir, "root.md");
|
|
20789
|
+
if (id !== null && fs67.existsSync(root2)) files.set(id, root2);
|
|
20689
20790
|
}
|
|
20690
20791
|
return files;
|
|
20691
20792
|
}
|
|
@@ -20795,8 +20896,8 @@ var init_list = __esm({
|
|
|
20795
20896
|
});
|
|
20796
20897
|
|
|
20797
20898
|
// src/lib/card-sources.ts
|
|
20798
|
-
import
|
|
20799
|
-
import
|
|
20899
|
+
import fs68 from "node:fs";
|
|
20900
|
+
import path70 from "node:path";
|
|
20800
20901
|
function planById(id) {
|
|
20801
20902
|
const found2 = readPlan(`plans/${id}-.md`);
|
|
20802
20903
|
return found2?.text.trim() ? found2 : null;
|
|
@@ -20806,8 +20907,8 @@ function cardLink(id) {
|
|
|
20806
20907
|
const found2 = open3 ?? locateArchived(id);
|
|
20807
20908
|
if (!found2) return null;
|
|
20808
20909
|
try {
|
|
20809
|
-
const file = found2.kind === "group" ?
|
|
20810
|
-
const title = parseFrontmatter(
|
|
20910
|
+
const file = found2.kind === "group" ? path70.join(found2.target, "root.md") : found2.target;
|
|
20911
|
+
const title = parseFrontmatter(fs68.readFileSync(file, "utf8")).meta?.title ?? "";
|
|
20811
20912
|
return { kind: "card", ref: String(id), title, ...open3 ? {} : { archived: true } };
|
|
20812
20913
|
} catch {
|
|
20813
20914
|
return null;
|
|
@@ -20832,7 +20933,7 @@ function link(ref, items) {
|
|
|
20832
20933
|
if (ref.kind === "plan") return planLink(ref.id);
|
|
20833
20934
|
if (ref.kind === "card") return cardLink(ref.id);
|
|
20834
20935
|
if (ref.kind === "url") return urlLink(ref.url);
|
|
20835
|
-
const item = items().find((signal2) =>
|
|
20936
|
+
const item = items().find((signal2) => path70.basename(signal2.relPath) === ref.file);
|
|
20836
20937
|
return item ? itemLink(item) : null;
|
|
20837
20938
|
}
|
|
20838
20939
|
function cardSources(meta, body) {
|
|
@@ -20873,12 +20974,12 @@ var init_card_sources = __esm({
|
|
|
20873
20974
|
});
|
|
20874
20975
|
|
|
20875
20976
|
// src/lib/view/read.ts
|
|
20876
|
-
import
|
|
20877
|
-
import
|
|
20977
|
+
import fs69 from "node:fs";
|
|
20978
|
+
import path71 from "node:path";
|
|
20878
20979
|
function readCard(file, relFromTodo) {
|
|
20879
|
-
const id = idPrefix(
|
|
20980
|
+
const id = idPrefix(path71.basename(relFromTodo));
|
|
20880
20981
|
if (id === null) {
|
|
20881
|
-
const parts = relFromTodo.split(
|
|
20982
|
+
const parts = relFromTodo.split(path71.sep);
|
|
20882
20983
|
const folderId = idPrefix(parts[parts.length - 2] || "");
|
|
20883
20984
|
if (folderId === null) return null;
|
|
20884
20985
|
return buildCard(folderId, file, relFromTodo);
|
|
@@ -20886,10 +20987,10 @@ function readCard(file, relFromTodo) {
|
|
|
20886
20987
|
return buildCard(id, file, relFromTodo);
|
|
20887
20988
|
}
|
|
20888
20989
|
function buildCard(id, file, relFromTodo) {
|
|
20889
|
-
const text4 =
|
|
20990
|
+
const text4 = fs69.readFileSync(file, "utf8");
|
|
20890
20991
|
const { meta, body } = parseFrontmatter(text4);
|
|
20891
20992
|
if (!meta) return null;
|
|
20892
|
-
const relPath = relFromTodo.split(
|
|
20993
|
+
const relPath = relFromTodo.split(path71.sep).join("/");
|
|
20893
20994
|
const flow = studioFor(meta.studio);
|
|
20894
20995
|
const plan = !!meta.studio && archivesOnApproval(flow);
|
|
20895
20996
|
const stages = cardStages(meta, flow).length;
|
|
@@ -20898,7 +20999,7 @@ function buildCard(id, file, relFromTodo) {
|
|
|
20898
20999
|
// Derived from the file exactly as it is on disk (lib/board/revision.ts), so a card
|
|
20899
21000
|
// read here and a card read by the contract agree on what version this is.
|
|
20900
21001
|
revision: revisionOf(text4),
|
|
20901
|
-
updatedAt:
|
|
21002
|
+
updatedAt: fs69.statSync(file).mtime.toISOString(),
|
|
20902
21003
|
relPath,
|
|
20903
21004
|
title: meta.title,
|
|
20904
21005
|
priority: meta.priority,
|
|
@@ -20919,22 +21020,22 @@ function buildCard(id, file, relFromTodo) {
|
|
|
20919
21020
|
};
|
|
20920
21021
|
}
|
|
20921
21022
|
function readGroup2(folderName) {
|
|
20922
|
-
const groupDir =
|
|
20923
|
-
const rootFile =
|
|
20924
|
-
if (!
|
|
20925
|
-
const root2 = readCard(rootFile,
|
|
21023
|
+
const groupDir = path71.join(TODO, folderName);
|
|
21024
|
+
const rootFile = path71.join(groupDir, "root.md");
|
|
21025
|
+
if (!fs69.existsSync(rootFile)) return null;
|
|
21026
|
+
const root2 = readCard(rootFile, path71.join(folderName, "root.md"));
|
|
20926
21027
|
if (!root2) return null;
|
|
20927
21028
|
root2.isGroup = true;
|
|
20928
21029
|
const { total, resolved: resolved2 } = subtaskLines(root2.body);
|
|
20929
21030
|
root2.subtaskLines = { total, resolved: resolved2 };
|
|
20930
21031
|
const subCards = [];
|
|
20931
21032
|
const recurse = (dir, relDir) => {
|
|
20932
|
-
for (const entry of
|
|
20933
|
-
const childRel =
|
|
21033
|
+
for (const entry of fs69.readdirSync(dir, { withFileTypes: true })) {
|
|
21034
|
+
const childRel = path71.join(relDir, entry.name);
|
|
20934
21035
|
if (entry.isDirectory()) {
|
|
20935
|
-
recurse(
|
|
21036
|
+
recurse(path71.join(dir, entry.name), childRel);
|
|
20936
21037
|
} else if (entry.name.endsWith(".md") && entry.name !== "README.md" && entry.name !== "root.md") {
|
|
20937
|
-
const c = readCard(
|
|
21038
|
+
const c = readCard(path71.join(dir, entry.name), childRel);
|
|
20938
21039
|
if (c) {
|
|
20939
21040
|
c.parent = { id: root2.id, title: root2.title };
|
|
20940
21041
|
subCards.push(c);
|
|
@@ -20955,12 +21056,12 @@ function readGroup2(folderName) {
|
|
|
20955
21056
|
return { root: root2, subCards };
|
|
20956
21057
|
}
|
|
20957
21058
|
function standaloneCards(dirRel) {
|
|
20958
|
-
const dir = dirRel ?
|
|
20959
|
-
if (!
|
|
21059
|
+
const dir = dirRel ? path71.join(TODO, dirRel) : TODO;
|
|
21060
|
+
if (!fs69.existsSync(dir)) return [];
|
|
20960
21061
|
const cards = [];
|
|
20961
|
-
for (const entry of
|
|
21062
|
+
for (const entry of fs69.readdirSync(dir, { withFileTypes: true })) {
|
|
20962
21063
|
if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
|
|
20963
|
-
const c = readCard(
|
|
21064
|
+
const c = readCard(path71.join(dir, entry.name), path71.join(dirRel, entry.name));
|
|
20964
21065
|
if (c) cards.push(c);
|
|
20965
21066
|
}
|
|
20966
21067
|
}
|
|
@@ -20972,7 +21073,7 @@ function collectCards() {
|
|
|
20972
21073
|
const top = standaloneCards("");
|
|
20973
21074
|
board2.push(...top);
|
|
20974
21075
|
every.push(...top);
|
|
20975
|
-
for (const entry of
|
|
21076
|
+
for (const entry of fs69.readdirSync(TODO, { withFileTypes: true })) {
|
|
20976
21077
|
if (!entry.isDirectory()) continue;
|
|
20977
21078
|
if (isGroupFolder(entry.name)) {
|
|
20978
21079
|
const g = readGroup2(entry.name);
|
|
@@ -21004,7 +21105,7 @@ function findCard(id) {
|
|
|
21004
21105
|
}
|
|
21005
21106
|
function attachSources(card) {
|
|
21006
21107
|
try {
|
|
21007
|
-
const { meta, body } = parseFrontmatter(
|
|
21108
|
+
const { meta, body } = parseFrontmatter(fs69.readFileSync(path71.join(TODO, card.relPath), "utf8"));
|
|
21008
21109
|
const sources2 = meta ? cardSources(meta, body) : [];
|
|
21009
21110
|
if (sources2.length) card.sources = sources2;
|
|
21010
21111
|
} catch {
|
|
@@ -21108,10 +21209,10 @@ var init_read = __esm({
|
|
|
21108
21209
|
});
|
|
21109
21210
|
|
|
21110
21211
|
// src/lib/group-close.ts
|
|
21111
|
-
import
|
|
21212
|
+
import fs70 from "node:fs";
|
|
21112
21213
|
function groupCloses(rootFile) {
|
|
21113
21214
|
try {
|
|
21114
|
-
return groupCloseOf(
|
|
21215
|
+
return groupCloseOf(fs70.readFileSync(rootFile, "utf8"));
|
|
21115
21216
|
} catch {
|
|
21116
21217
|
return false;
|
|
21117
21218
|
}
|
|
@@ -21124,12 +21225,12 @@ var init_group_close = __esm({
|
|
|
21124
21225
|
});
|
|
21125
21226
|
|
|
21126
21227
|
// src/commands/remove.ts
|
|
21127
|
-
import
|
|
21128
|
-
import
|
|
21228
|
+
import fs71 from "node:fs";
|
|
21229
|
+
import path72 from "node:path";
|
|
21129
21230
|
function leavingIds(id, found2) {
|
|
21130
21231
|
const ids = /* @__PURE__ */ new Set([id]);
|
|
21131
21232
|
if (found2.kind === "group") {
|
|
21132
|
-
const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f) =>
|
|
21233
|
+
const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f) => path72.basename(f));
|
|
21133
21234
|
for (const name of names3) {
|
|
21134
21235
|
const n = idPrefix(name);
|
|
21135
21236
|
if (n !== null) ids.add(n);
|
|
@@ -21141,10 +21242,10 @@ function findMentions(ids) {
|
|
|
21141
21242
|
const hits = [];
|
|
21142
21243
|
const re = new RegExp(ids.map((id) => `#${id}(?!\\d)`).join("|"));
|
|
21143
21244
|
for (const dir of [TODO, MEMORY]) {
|
|
21144
|
-
if (!
|
|
21245
|
+
if (!fs71.existsSync(dir)) continue;
|
|
21145
21246
|
for (const file of walkMd(dir)) {
|
|
21146
|
-
if (
|
|
21147
|
-
const lines =
|
|
21247
|
+
if (path72.basename(file) === "README.md") continue;
|
|
21248
|
+
const lines = fs71.readFileSync(file, "utf8").split("\n");
|
|
21148
21249
|
const fmEnd = frontmatterEnd(lines);
|
|
21149
21250
|
lines.forEach((line, i) => {
|
|
21150
21251
|
if (!re.test(line)) return;
|
|
@@ -21160,12 +21261,12 @@ function findMentions(ids) {
|
|
|
21160
21261
|
return hits;
|
|
21161
21262
|
}
|
|
21162
21263
|
function leavingCards(id, found2) {
|
|
21163
|
-
const own = found2.kind === "group" ?
|
|
21264
|
+
const own = found2.kind === "group" ? path72.join(found2.target, "root.md") : found2.target;
|
|
21164
21265
|
const cards = [{ id, file: own }];
|
|
21165
21266
|
if (found2.kind !== "group") return cards;
|
|
21166
21267
|
for (const file of walkMd(found2.target)) {
|
|
21167
21268
|
if (file === own) continue;
|
|
21168
|
-
const n = idPrefix(
|
|
21269
|
+
const n = idPrefix(path72.basename(file));
|
|
21169
21270
|
if (n !== null) cards.push({ id: n, file });
|
|
21170
21271
|
}
|
|
21171
21272
|
return cards;
|
|
@@ -21174,10 +21275,10 @@ function stampLeaving(cards, rejection) {
|
|
|
21174
21275
|
const day = formatDay();
|
|
21175
21276
|
const stamp4 = rejection && !rejection.discard ? { reason: rejection.reason, at: (/* @__PURE__ */ new Date()).toISOString(), by: insideRun() ? "agent" : "user" } : rejection && { reason: rejection.reason };
|
|
21176
21277
|
for (const card of cards) {
|
|
21177
|
-
if (!
|
|
21178
|
-
const text4 =
|
|
21278
|
+
if (!fs71.existsSync(card.file)) continue;
|
|
21279
|
+
const text4 = fs71.readFileSync(card.file, "utf8");
|
|
21179
21280
|
const stamped = stampLeavingIn(text4, day, stamp4);
|
|
21180
|
-
if (stamped !== text4)
|
|
21281
|
+
if (stamped !== text4) fs71.writeFileSync(card.file, stamped);
|
|
21181
21282
|
}
|
|
21182
21283
|
}
|
|
21183
21284
|
function unfinishedDelivery(id) {
|
|
@@ -21193,7 +21294,7 @@ function unfinishedDelivery(id) {
|
|
|
21193
21294
|
}[gap];
|
|
21194
21295
|
return `#${id} is not finished: ${what}.`;
|
|
21195
21296
|
}
|
|
21196
|
-
const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !
|
|
21297
|
+
const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs71.existsSync(path72.join(ASSETS, src.slice(".assets/".length))));
|
|
21197
21298
|
return missing ? `#${id} is not finished: ${missing} is not on this machine.` : null;
|
|
21198
21299
|
}
|
|
21199
21300
|
function agentDecisions(text4) {
|
|
@@ -21224,8 +21325,8 @@ function removeCard2(id, metric, options) {
|
|
|
21224
21325
|
const unfinished = metric === "completed" ? unfinishedDelivery(id) : null;
|
|
21225
21326
|
if (unfinished) die(unfinished, { kind: "plan-delivery-unfinished" });
|
|
21226
21327
|
const dest = options.cleanupDiscarded && locateArchived(id) ? null : archiveDest(found2);
|
|
21227
|
-
const cardFile3 = found2.kind === "group" ?
|
|
21228
|
-
const cardText =
|
|
21328
|
+
const cardFile3 = found2.kind === "group" ? path72.join(found2.target, "root.md") : found2.target;
|
|
21329
|
+
const cardText = fs71.existsSync(cardFile3) ? fs71.readFileSync(cardFile3, "utf8") : "";
|
|
21229
21330
|
const { meta: cardMeta3 } = parseFrontmatter(cardText);
|
|
21230
21331
|
const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f) => f !== cardFile3).map((f) => rel(f)).sort() : [];
|
|
21231
21332
|
const leftIds = leavingIds(id, found2);
|
|
@@ -21256,10 +21357,10 @@ function removeCard2(id, metric, options) {
|
|
|
21256
21357
|
const groupRoot = found2.kind === "file" && !options.closing ? enclosingGroupRoot(found2.target) : null;
|
|
21257
21358
|
if (dest) {
|
|
21258
21359
|
stampLeaving(leaving, metric === "rejected" ? { reason: options.reason?.trim() ?? "", discard: options.discard === true } : null);
|
|
21259
|
-
|
|
21260
|
-
|
|
21360
|
+
fs71.mkdirSync(ARCHIVE, { recursive: true });
|
|
21361
|
+
fs71.renameSync(found2.target, dest);
|
|
21261
21362
|
} else {
|
|
21262
|
-
|
|
21363
|
+
fs71.rmSync(found2.target, { recursive: true, force: true });
|
|
21263
21364
|
}
|
|
21264
21365
|
const removedRefs = stripReadmeRefs(found2);
|
|
21265
21366
|
let marked2 = null;
|
|
@@ -21308,14 +21409,14 @@ function removeCard2(id, metric, options) {
|
|
|
21308
21409
|
};
|
|
21309
21410
|
}
|
|
21310
21411
|
function closeGroup(rootFile) {
|
|
21311
|
-
const rootId = idPrefix(
|
|
21412
|
+
const rootId = idPrefix(path72.basename(path72.dirname(rootFile)));
|
|
21312
21413
|
if (rootId === null) return null;
|
|
21313
21414
|
if (runnerProject(KANBAN)) return null;
|
|
21314
21415
|
if (!groupCloses(rootFile)) return null;
|
|
21315
21416
|
say(`
|
|
21316
21417
|
every subtask line on #${rootId} is resolved \u2014 closing the group:`);
|
|
21317
21418
|
try {
|
|
21318
|
-
const { meta, body } = parseFrontmatter(
|
|
21419
|
+
const { meta, body } = parseFrontmatter(fs71.readFileSync(rootFile, "utf8"));
|
|
21319
21420
|
const res = cmdRemove(rootId, "completed", { closing: true });
|
|
21320
21421
|
return {
|
|
21321
21422
|
id: rootId,
|
|
@@ -21372,7 +21473,7 @@ function cleanupDiscardedCards(sessionId) {
|
|
|
21372
21473
|
if (card.pending) throw new Error(`Discarding #${card.id} did not finish. Retry the discard.`);
|
|
21373
21474
|
while (locate(card.id)) cmdRemove(card.id, "rejected", { discard: true, cleanupDiscarded: true });
|
|
21374
21475
|
dropCrossRefs(card.id);
|
|
21375
|
-
stripReadmeRefs({ kind: "file", rel:
|
|
21476
|
+
stripReadmeRefs({ kind: "file", rel: path72.relative(TODO, path72.resolve(REPO_ROOT, card.path)).split(path72.sep).join("/") });
|
|
21376
21477
|
}
|
|
21377
21478
|
return discarded.map((c) => c.id);
|
|
21378
21479
|
});
|
|
@@ -21380,8 +21481,8 @@ function cleanupDiscardedCards(sessionId) {
|
|
|
21380
21481
|
function recoveredArchiveHandoff(id, source) {
|
|
21381
21482
|
const found2 = locateArchived(id);
|
|
21382
21483
|
if (!found2) throw new Error(`No archived card #${id} was found.`);
|
|
21383
|
-
const file = found2.kind === "group" ?
|
|
21384
|
-
const { meta } = parseFrontmatter(
|
|
21484
|
+
const file = found2.kind === "group" ? path72.join(found2.target, "root.md") : found2.target;
|
|
21485
|
+
const { meta } = parseFrontmatter(fs71.readFileSync(file, "utf8"));
|
|
21385
21486
|
stripReadmeRefs(source ?? found2);
|
|
21386
21487
|
const root2 = source?.kind === "file" ? enclosingGroupRoot(source.target) : null;
|
|
21387
21488
|
if (root2) markSubtask(root2, id, "tick");
|
|
@@ -21457,6 +21558,30 @@ var init_agent_file = __esm({
|
|
|
21457
21558
|
}
|
|
21458
21559
|
});
|
|
21459
21560
|
|
|
21561
|
+
// src/commands/studio-file.ts
|
|
21562
|
+
function cmdStudioFile(askedStudio, askedFile) {
|
|
21563
|
+
const studio = askedStudio.trim();
|
|
21564
|
+
const files = studioFiles(studio);
|
|
21565
|
+
if (!files) die(`no studio ${studio}`, { kind: "no-such-studio", studio });
|
|
21566
|
+
const file = askedFile.trim().replace(/^\.\//, "");
|
|
21567
|
+
const readable = Object.keys(files).filter((f) => f === STUDIO_FILE || f.startsWith("shared/") || f.startsWith("agents/")).sort();
|
|
21568
|
+
if (!readable.includes(file) || isAboutFile(file)) {
|
|
21569
|
+
die(`${studio} has no ${file}. It has: ${readable.join(", ")}.`, { kind: "no-such-studio-file", studio, file });
|
|
21570
|
+
}
|
|
21571
|
+
const text4 = files[file];
|
|
21572
|
+
say(text4);
|
|
21573
|
+
return { studio, file, text: text4 };
|
|
21574
|
+
}
|
|
21575
|
+
var init_studio_file2 = __esm({
|
|
21576
|
+
"src/commands/studio-file.ts"() {
|
|
21577
|
+
"use strict";
|
|
21578
|
+
init_io();
|
|
21579
|
+
init_paths();
|
|
21580
|
+
init_studio_shared();
|
|
21581
|
+
init_studio_files();
|
|
21582
|
+
}
|
|
21583
|
+
});
|
|
21584
|
+
|
|
21460
21585
|
// src/commands/memory-file.ts
|
|
21461
21586
|
function cmdMemoryFile(askedName) {
|
|
21462
21587
|
const name = askedName.trim();
|
|
@@ -21670,6 +21795,7 @@ var init_local2 = __esm({
|
|
|
21670
21795
|
init_list();
|
|
21671
21796
|
init_remove();
|
|
21672
21797
|
init_agent_file();
|
|
21798
|
+
init_studio_file2();
|
|
21673
21799
|
init_memory_file();
|
|
21674
21800
|
init_validate2();
|
|
21675
21801
|
init_io();
|
|
@@ -21688,10 +21814,11 @@ var init_local2 = __esm({
|
|
|
21688
21814
|
archive: ({ args }) => cmdRemove(Number(args[0]), "completed"),
|
|
21689
21815
|
reject: ({ args, opts }) => cmdRemove(Number(args[0]), "rejected", as(opts)),
|
|
21690
21816
|
"agent-file": ({ args }) => cmdAgentFile(args[0] ?? "", args[1] ?? ""),
|
|
21817
|
+
file: ({ args }) => cmdStudioFile(args[0] ?? "", args[1] ?? ""),
|
|
21691
21818
|
"memory-file": ({ args }) => cmdMemoryFile(args[0] ?? "")
|
|
21692
21819
|
};
|
|
21693
21820
|
BOARD_MOVES = new Set(Object.keys(MOVES));
|
|
21694
|
-
READ_ONLY_MOVES = /* @__PURE__ */ new Set(["list", "validate", "agent-file", "memory-file"]);
|
|
21821
|
+
READ_ONLY_MOVES = /* @__PURE__ */ new Set(["list", "validate", "file", "agent-file", "memory-file"]);
|
|
21695
21822
|
leases = /* @__PURE__ */ new Map();
|
|
21696
21823
|
leaseCounter = 0;
|
|
21697
21824
|
}
|
|
@@ -21742,8 +21869,8 @@ var init_created_cards = __esm({
|
|
|
21742
21869
|
|
|
21743
21870
|
// src/lib/agent/creation.ts
|
|
21744
21871
|
import crypto4 from "node:crypto";
|
|
21745
|
-
import
|
|
21746
|
-
import
|
|
21872
|
+
import fs72 from "node:fs";
|
|
21873
|
+
import path73 from "node:path";
|
|
21747
21874
|
function creationError(error, triage) {
|
|
21748
21875
|
const zh = readLanguage() === "zh";
|
|
21749
21876
|
const messages = {
|
|
@@ -21769,12 +21896,12 @@ ${zh ? `\u539F\u6761\u76EE\u4ECD\u5728 triage\uFF1A${triage}\u3002${unreachable
|
|
|
21769
21896
|
function creationReceipt(request2, slot) {
|
|
21770
21897
|
const hash2 = crypto4.createHash("sha256").update(`${request2}
|
|
21771
21898
|
${slot}`).digest("hex");
|
|
21772
|
-
return
|
|
21899
|
+
return path73.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
|
|
21773
21900
|
}
|
|
21774
21901
|
function readCreation(file, said2) {
|
|
21775
21902
|
return withCreationLock(() => {
|
|
21776
21903
|
try {
|
|
21777
|
-
const held4 = JSON.parse(
|
|
21904
|
+
const held4 = JSON.parse(fs72.readFileSync(file, "utf8"));
|
|
21778
21905
|
if (!held4.said || typeof held4.said.title !== "string") throw new Error("Invalid creation journal");
|
|
21779
21906
|
return held4;
|
|
21780
21907
|
} catch (error) {
|
|
@@ -21786,10 +21913,10 @@ function readCreation(file, said2) {
|
|
|
21786
21913
|
});
|
|
21787
21914
|
}
|
|
21788
21915
|
function saveCreation(file, journal) {
|
|
21789
|
-
|
|
21916
|
+
fs72.mkdirSync(path73.dirname(file), { recursive: true });
|
|
21790
21917
|
const temp = `${file}.${crypto4.randomUUID()}.tmp`;
|
|
21791
|
-
|
|
21792
|
-
|
|
21918
|
+
fs72.writeFileSync(temp, JSON.stringify(journal));
|
|
21919
|
+
fs72.renameSync(temp, file);
|
|
21793
21920
|
}
|
|
21794
21921
|
function archiveCreation(source, id) {
|
|
21795
21922
|
if (readArchived().some((s) => s.sourceId === source && s.cardId === id)) return;
|
|
@@ -21803,7 +21930,7 @@ function archiveCreation(source, id) {
|
|
|
21803
21930
|
function triageFile(sourceId) {
|
|
21804
21931
|
const found2 = [...readInbox(), ...readAllDismissed(), ...readArchived()].find((s) => s.sourceId === sourceId.trim());
|
|
21805
21932
|
if (!found2) throw new BoardError(`nothing in triage is ${sourceId}`, { kind: "refused" });
|
|
21806
|
-
return
|
|
21933
|
+
return path73.basename(found2.relPath, ".md");
|
|
21807
21934
|
}
|
|
21808
21935
|
var init_creation = __esm({
|
|
21809
21936
|
"src/lib/agent/creation.ts"() {
|
|
@@ -21971,8 +22098,8 @@ __export(board_exports, {
|
|
|
21971
22098
|
buildBoardProgram: () => buildBoardProgram
|
|
21972
22099
|
});
|
|
21973
22100
|
import crypto5 from "node:crypto";
|
|
21974
|
-
import
|
|
21975
|
-
import
|
|
22101
|
+
import fs73 from "node:fs";
|
|
22102
|
+
import path74 from "node:path";
|
|
21976
22103
|
async function dispatch(move, cmd, args, opts, cli) {
|
|
21977
22104
|
const ctx = ctxOf(cmd, cli.program);
|
|
21978
22105
|
const data = await runAction(ctx, {}, async () => {
|
|
@@ -22012,7 +22139,7 @@ async function cloudCard(task, opts) {
|
|
|
22012
22139
|
let request2;
|
|
22013
22140
|
if (typeof opts.bodyFile === "string") {
|
|
22014
22141
|
try {
|
|
22015
|
-
request2 =
|
|
22142
|
+
request2 = fs73.readFileSync(opts.bodyFile, "utf8");
|
|
22016
22143
|
} catch {
|
|
22017
22144
|
}
|
|
22018
22145
|
}
|
|
@@ -22042,7 +22169,7 @@ async function cloudCard(task, opts) {
|
|
|
22042
22169
|
const file = creationReceipt(`${checked.value}:${requestId}`, slot);
|
|
22043
22170
|
const journal = readCreation(file, said2);
|
|
22044
22171
|
if (!journal.made) {
|
|
22045
|
-
const key = `akb-${
|
|
22172
|
+
const key = `akb-${path74.basename(file, ".json").slice(0, 40)}`;
|
|
22046
22173
|
const made = await createProjectTask(checked.value, journal.said, key);
|
|
22047
22174
|
if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
|
|
22048
22175
|
journal.made = made.value;
|
|
@@ -22092,9 +22219,10 @@ function buildBoardProgram(cli) {
|
|
|
22092
22219
|
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
22220
|
await dispatch("validate", this, id === void 0 ? [] : [String(id)], this.opts(), cli);
|
|
22094
22221
|
});
|
|
22095
|
-
move("
|
|
22096
|
-
"
|
|
22097
|
-
)
|
|
22222
|
+
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) {
|
|
22223
|
+
await dispatch("file", this, [studio, file], this.opts(), cli);
|
|
22224
|
+
});
|
|
22225
|
+
withShared(program2.command("agent-file", { hidden: true })).argument("<agent>").argument("<path>").action(async function(agent, file) {
|
|
22098
22226
|
await dispatch("agent-file", this, [agent, file], this.opts(), cli);
|
|
22099
22227
|
});
|
|
22100
22228
|
move("memory-file").argument("<name>", "the global memory").summary("print one global memory's rules, its MEMORY.md").description(
|
|
@@ -22170,17 +22298,17 @@ var init_board2 = __esm({
|
|
|
22170
22298
|
});
|
|
22171
22299
|
|
|
22172
22300
|
// src/lib/board-cli.ts
|
|
22173
|
-
import
|
|
22174
|
-
import
|
|
22301
|
+
import fs74 from "node:fs";
|
|
22302
|
+
import path75 from "node:path";
|
|
22175
22303
|
function useBoard(found2, dirNamed) {
|
|
22176
|
-
if (!found2.named && found2.board ===
|
|
22304
|
+
if (!found2.named && found2.board === path75.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
|
|
22177
22305
|
else setBoardDir(found2.board, found2.root);
|
|
22178
22306
|
useProjectState();
|
|
22179
22307
|
backfillCardStudios();
|
|
22180
22308
|
}
|
|
22181
22309
|
function whole(found2, move) {
|
|
22182
22310
|
if (move === MAKES_A_BOARD) return found2;
|
|
22183
|
-
if (!
|
|
22311
|
+
if (!fs74.existsSync(path75.join(found2.board, "todo"))) {
|
|
22184
22312
|
die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
|
|
22185
22313
|
kind: "board-incomplete",
|
|
22186
22314
|
dir: found2.root
|
|
@@ -22189,13 +22317,13 @@ function whole(found2, move) {
|
|
|
22189
22317
|
return found2;
|
|
22190
22318
|
}
|
|
22191
22319
|
function findBoardUpward(from, move) {
|
|
22192
|
-
let dir =
|
|
22320
|
+
let dir = path75.resolve(from);
|
|
22193
22321
|
for (; ; ) {
|
|
22194
|
-
if (hasBoard(dir)) return { root: dir, board:
|
|
22322
|
+
if (hasBoard(dir)) return { root: dir, board: path75.join(dir, "docs", "kanban") };
|
|
22195
22323
|
if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
|
|
22196
|
-
const kept2 =
|
|
22197
|
-
if (move !== MAKES_A_BOARD &&
|
|
22198
|
-
const up =
|
|
22324
|
+
const kept2 = path75.join(dir, ".akb", "kanban");
|
|
22325
|
+
if (move !== MAKES_A_BOARD && fs74.existsSync(path75.join(kept2, "todo"))) return { root: dir, board: kept2 };
|
|
22326
|
+
const up = path75.dirname(dir);
|
|
22199
22327
|
if (up === dir) return null;
|
|
22200
22328
|
dir = up;
|
|
22201
22329
|
}
|
|
@@ -22203,11 +22331,11 @@ function findBoardUpward(from, move) {
|
|
|
22203
22331
|
function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
22204
22332
|
const named2 = board2 ?? boardFromEnv();
|
|
22205
22333
|
if (named2) {
|
|
22206
|
-
const folder =
|
|
22207
|
-
if (!
|
|
22334
|
+
const folder = path75.resolve(cwd, named2);
|
|
22335
|
+
if (!fs74.existsSync(folder) && move !== MAKES_A_BOARD) {
|
|
22208
22336
|
die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
|
|
22209
22337
|
}
|
|
22210
|
-
if (
|
|
22338
|
+
if (fs74.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
|
|
22211
22339
|
die(`${folder} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
|
|
22212
22340
|
kind: "no-board",
|
|
22213
22341
|
dir: folder
|
|
@@ -22216,24 +22344,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
|
22216
22344
|
return { root: projectRootOf(folder), board: folder, named: true };
|
|
22217
22345
|
}
|
|
22218
22346
|
if (dir !== null) {
|
|
22219
|
-
const root2 =
|
|
22220
|
-
if (!
|
|
22221
|
-
const kept2 =
|
|
22222
|
-
if (!hasBoard(root2) && move !== MAKES_A_BOARD &&
|
|
22347
|
+
const root2 = path75.resolve(dir);
|
|
22348
|
+
if (!fs74.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
|
|
22349
|
+
const kept2 = path75.join(root2, ".akb", "kanban");
|
|
22350
|
+
if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs74.existsSync(path75.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
|
|
22223
22351
|
if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
|
|
22224
22352
|
die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
|
|
22225
22353
|
kind: "no-board",
|
|
22226
22354
|
dir: root2
|
|
22227
22355
|
});
|
|
22228
22356
|
}
|
|
22229
|
-
return whole({ root: root2, board:
|
|
22357
|
+
return whole({ root: root2, board: path75.join(root2, "docs", "kanban") }, move);
|
|
22230
22358
|
}
|
|
22231
22359
|
const found2 = findBoardUpward(cwd, move);
|
|
22232
22360
|
if (found2) return whole(found2, move);
|
|
22233
|
-
if (move === MAKES_A_BOARD) return { root:
|
|
22361
|
+
if (move === MAKES_A_BOARD) return { root: path75.resolve(cwd), board: path75.join(path75.resolve(cwd), "docs", "kanban") };
|
|
22234
22362
|
die(
|
|
22235
|
-
`no board here. Looked in ${
|
|
22236
|
-
{ kind: "no-board", dir:
|
|
22363
|
+
`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`,
|
|
22364
|
+
{ kind: "no-board", dir: path75.resolve(cwd) }
|
|
22237
22365
|
);
|
|
22238
22366
|
}
|
|
22239
22367
|
function editDistance(a, b) {
|
|
@@ -22316,8 +22444,8 @@ var init_board_cli = __esm({
|
|
|
22316
22444
|
init_pointer();
|
|
22317
22445
|
init_card_studio_backfill();
|
|
22318
22446
|
MAKES_A_BOARD = "init";
|
|
22319
|
-
hasBoard = (dir) =>
|
|
22320
|
-
isBoardDir = (dir) =>
|
|
22447
|
+
hasBoard = (dir) => fs74.existsSync(path75.join(dir, "docs", "kanban"));
|
|
22448
|
+
isBoardDir = (dir) => fs74.existsSync(path75.join(dir, "todo")) && fs74.existsSync(path75.join(dir, "config.md"));
|
|
22321
22449
|
boardFromEnv = () => {
|
|
22322
22450
|
const named2 = process.env.AI4KANBAN_BOARD?.trim();
|
|
22323
22451
|
return named2 ? named2 : null;
|
|
@@ -22577,8 +22705,8 @@ var init_agent = __esm({
|
|
|
22577
22705
|
|
|
22578
22706
|
// src/commands/cloud-template.ts
|
|
22579
22707
|
import { createHash as createHash5 } from "node:crypto";
|
|
22580
|
-
import
|
|
22581
|
-
import
|
|
22708
|
+
import fs75 from "node:fs";
|
|
22709
|
+
import path76 from "node:path";
|
|
22582
22710
|
function usage2(problem, line) {
|
|
22583
22711
|
die(`${problem}
|
|
22584
22712
|
usage: ${line}`, { kind: "bad-args", bare: true, exitCode: 2 });
|
|
@@ -22655,10 +22783,10 @@ This template has no preview.`);
|
|
|
22655
22783
|
const written = [];
|
|
22656
22784
|
for (const p of previews) {
|
|
22657
22785
|
const bytes2 = Buffer.from(await (await ask(`/${at}/previews/${route(p.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
22658
|
-
const file =
|
|
22659
|
-
const out =
|
|
22660
|
-
|
|
22661
|
-
|
|
22786
|
+
const file = path76.basename(p.path);
|
|
22787
|
+
const out = path76.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
|
|
22788
|
+
fs75.mkdirSync(opts.to, { recursive: true });
|
|
22789
|
+
fs75.writeFileSync(out, bytes2);
|
|
22662
22790
|
written.push(out);
|
|
22663
22791
|
say(out);
|
|
22664
22792
|
}
|
|
@@ -22671,15 +22799,15 @@ async function templateGet(name, opts, program2) {
|
|
|
22671
22799
|
const { template } = await asJson(await ask(`/${at}`, {}, WITHOUT));
|
|
22672
22800
|
const fetched = [];
|
|
22673
22801
|
for (const f of template.files) {
|
|
22674
|
-
const out =
|
|
22675
|
-
if (!out.startsWith(
|
|
22802
|
+
const out = path76.resolve(to, f.path);
|
|
22803
|
+
if (!out.startsWith(path76.resolve(to) + path76.sep)) refuse3(T.corrupt, WITHOUT);
|
|
22676
22804
|
const bytes2 = Buffer.from(await (await ask(`/${at}/files/${route(f.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
22677
22805
|
if (bytes2.byteLength !== f.size || createHash5("sha256").update(bytes2).digest("hex") !== f.sha256) {
|
|
22678
22806
|
refuse3(T.corrupt, WITHOUT);
|
|
22679
22807
|
}
|
|
22680
22808
|
fetched.push({ out, bytes: bytes2 });
|
|
22681
22809
|
}
|
|
22682
|
-
const taken = fetched.filter((f) =>
|
|
22810
|
+
const taken = fetched.filter((f) => fs75.existsSync(f.out)).map((f) => path76.relative(to, f.out));
|
|
22683
22811
|
if (taken.length > 0) {
|
|
22684
22812
|
refuse3({
|
|
22685
22813
|
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 +22815,8 @@ async function templateGet(name, opts, program2) {
|
|
|
22687
22815
|
});
|
|
22688
22816
|
}
|
|
22689
22817
|
for (const f of fetched) {
|
|
22690
|
-
|
|
22691
|
-
|
|
22818
|
+
fs75.mkdirSync(path76.dirname(f.out), { recursive: true });
|
|
22819
|
+
fs75.writeFileSync(f.out, f.bytes);
|
|
22692
22820
|
}
|
|
22693
22821
|
say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
|
|
22694
22822
|
Fetched ${name}: ${fetched.length} files into ${to}`);
|
|
@@ -22705,25 +22833,25 @@ async function templateSource(name, opts) {
|
|
|
22705
22833
|
say(`evidence: ${e.path}`);
|
|
22706
22834
|
continue;
|
|
22707
22835
|
}
|
|
22708
|
-
const out =
|
|
22709
|
-
|
|
22710
|
-
|
|
22836
|
+
const out = path76.join(opts.to, `${name}-${path76.basename(e.path)}`);
|
|
22837
|
+
fs75.mkdirSync(opts.to, { recursive: true });
|
|
22838
|
+
fs75.writeFileSync(out, Buffer.from(await (await ask(`/${at}/evidence/${route(e.path)}`)).arrayBuffer()));
|
|
22711
22839
|
written.push(out);
|
|
22712
22840
|
say(out);
|
|
22713
22841
|
}
|
|
22714
22842
|
return { name, source, evidence: written.length > 0 ? written : evidence.map((e) => e.path) };
|
|
22715
22843
|
}
|
|
22716
22844
|
async function templatePublish(dir, opts) {
|
|
22717
|
-
const root2 =
|
|
22718
|
-
const manifest =
|
|
22719
|
-
if (!
|
|
22720
|
-
const meta = readTemplateMeta(
|
|
22845
|
+
const root2 = path76.resolve(dir);
|
|
22846
|
+
const manifest = path76.join(root2, "template.md");
|
|
22847
|
+
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.");
|
|
22848
|
+
const meta = readTemplateMeta(fs75.readFileSync(manifest, "utf8"));
|
|
22721
22849
|
const files = walk2(root2);
|
|
22722
|
-
const total = files.reduce((sum, f) => sum +
|
|
22850
|
+
const total = files.reduce((sum, f) => sum + fs75.statSync(path76.join(root2, f)).size, 0);
|
|
22723
22851
|
if (total > MAX_BYTES3) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
|
|
22724
22852
|
for (const extra of [...opts.preview, ...opts.evidence]) {
|
|
22725
|
-
if (!
|
|
22726
|
-
if (
|
|
22853
|
+
if (!fs75.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
|
|
22854
|
+
if (path76.resolve(extra).startsWith(root2 + path76.sep)) {
|
|
22727
22855
|
invalid(
|
|
22728
22856
|
`${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
22857
|
`${extra} is inside the template folder; keep previews and evidence outside it.`
|
|
@@ -22735,10 +22863,10 @@ async function templatePublish(dir, opts) {
|
|
|
22735
22863
|
}
|
|
22736
22864
|
const form = new FormData();
|
|
22737
22865
|
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",
|
|
22866
|
+
const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs75.readFileSync(file)]), path76.basename(name));
|
|
22867
|
+
for (const f of files) add("files", f, path76.join(root2, f));
|
|
22868
|
+
for (const f of opts.preview) add("previews", path76.basename(f), f);
|
|
22869
|
+
for (const f of opts.evidence) add("evidence", path76.basename(f), f);
|
|
22742
22870
|
const done2 = await asJson(await ask("", { method: "POST", body: form }));
|
|
22743
22871
|
say(
|
|
22744
22872
|
done2.replaced ? `\u5DF2\u66FF\u6362 ${done2.name}\uFF1A${files.length} \u4E2A\u6587\u4EF6\u3002
|
|
@@ -22754,11 +22882,11 @@ Deleted ${name} from the catalog.`);
|
|
|
22754
22882
|
return { name, deleted: true };
|
|
22755
22883
|
}
|
|
22756
22884
|
async function templateShowcase(name, dir) {
|
|
22757
|
-
const file =
|
|
22758
|
-
if (!
|
|
22885
|
+
const file = path76.join(dir, "showcase.json");
|
|
22886
|
+
if (!fs75.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
|
|
22759
22887
|
let meta;
|
|
22760
22888
|
try {
|
|
22761
|
-
meta = JSON.parse(
|
|
22889
|
+
meta = JSON.parse(fs75.readFileSync(file, "utf8"));
|
|
22762
22890
|
} catch {
|
|
22763
22891
|
return invalid("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
|
|
22764
22892
|
}
|
|
@@ -22770,9 +22898,9 @@ async function templateShowcase(name, dir) {
|
|
|
22770
22898
|
const form = new FormData();
|
|
22771
22899
|
form.set("meta", JSON.stringify(meta));
|
|
22772
22900
|
for (const p of new Set(named2)) {
|
|
22773
|
-
const at =
|
|
22774
|
-
if (!
|
|
22775
|
-
form.append(`media:${p}`, new Blob([
|
|
22901
|
+
const at = path76.join(dir, p);
|
|
22902
|
+
if (!fs75.existsSync(at)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at}\u3002`, `${at} does not exist.`);
|
|
22903
|
+
form.append(`media:${p}`, new Blob([fs75.readFileSync(at)]), p);
|
|
22776
22904
|
}
|
|
22777
22905
|
const done2 = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
|
|
22778
22906
|
say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done2.files} \u4E2A\u6587\u4EF6\u3002
|
|
@@ -22781,7 +22909,7 @@ Updated ${name}'s showcase: ${done2.files} files.`);
|
|
|
22781
22909
|
}
|
|
22782
22910
|
function walk2(root2, sub = "") {
|
|
22783
22911
|
const out = [];
|
|
22784
|
-
for (const entry of
|
|
22912
|
+
for (const entry of fs75.readdirSync(path76.join(root2, sub), { withFileTypes: true })) {
|
|
22785
22913
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
22786
22914
|
const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
|
|
22787
22915
|
if (entry.isDirectory()) out.push(...walk2(root2, rel2));
|
|
@@ -22982,7 +23110,7 @@ var init_card_chat = __esm({
|
|
|
22982
23110
|
var update_studio_default;
|
|
22983
23111
|
var init_update_studio = __esm({
|
|
22984
23112
|
"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
|
|
23113
|
+
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
23114
|
}
|
|
22987
23115
|
});
|
|
22988
23116
|
|
|
@@ -23038,7 +23166,7 @@ var init_prune_memory = __esm({
|
|
|
23038
23166
|
var review_memory_default;
|
|
23039
23167
|
var init_review_memory = __esm({
|
|
23040
23168
|
"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
|
|
23169
|
+
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
23170
|
}
|
|
23043
23171
|
});
|
|
23044
23172
|
|
|
@@ -23086,7 +23214,7 @@ var init_revise = __esm({
|
|
|
23086
23214
|
var preview_agent_default;
|
|
23087
23215
|
var init_preview_agent = __esm({
|
|
23088
23216
|
"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';
|
|
23217
|
+
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
23218
|
}
|
|
23091
23219
|
});
|
|
23092
23220
|
|
|
@@ -23110,7 +23238,7 @@ var init_troubleshoot = __esm({
|
|
|
23110
23238
|
var write_agent_default;
|
|
23111
23239
|
var init_write_agent = __esm({
|
|
23112
23240
|
"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
|
|
23241
|
+
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
23242
|
}
|
|
23115
23243
|
});
|
|
23116
23244
|
|
|
@@ -23126,7 +23254,7 @@ var init_write_prompt = __esm({
|
|
|
23126
23254
|
var writing_default;
|
|
23127
23255
|
var init_writing = __esm({
|
|
23128
23256
|
"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
|
|
23257
|
+
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
23258
|
}
|
|
23131
23259
|
});
|
|
23132
23260
|
|
|
@@ -23243,8 +23371,8 @@ var init_guide2 = __esm({
|
|
|
23243
23371
|
});
|
|
23244
23372
|
|
|
23245
23373
|
// src/commands/studio.ts
|
|
23246
|
-
import
|
|
23247
|
-
import
|
|
23374
|
+
import fs76 from "node:fs";
|
|
23375
|
+
import path77 from "node:path";
|
|
23248
23376
|
function cmdStudioList() {
|
|
23249
23377
|
if (!studiosReachable().ok) die(NEEDS_CLOUD, "needs-cloud");
|
|
23250
23378
|
const offline2 = studiosOffline();
|
|
@@ -23285,17 +23413,17 @@ function cmdStudioDiagram(id, card) {
|
|
|
23285
23413
|
const agent = findSpecAgent(name);
|
|
23286
23414
|
return agent ? { ...agent, after: agentAfter(name) } : null;
|
|
23287
23415
|
});
|
|
23288
|
-
const file =
|
|
23289
|
-
|
|
23290
|
-
|
|
23416
|
+
const file = path77.join(ASSETS, String(cardId2), "studio.json");
|
|
23417
|
+
fs76.mkdirSync(path77.dirname(file), { recursive: true });
|
|
23418
|
+
fs76.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
|
|
23291
23419
|
`);
|
|
23292
23420
|
const tag = `<Studio src=".assets/${cardId2}/studio.json" label="${flow.name.replace(/"/g, "")}" />`;
|
|
23293
23421
|
say(tag);
|
|
23294
23422
|
return { file, tag, diagram };
|
|
23295
23423
|
}
|
|
23296
23424
|
function cmdStudioValidate(folder) {
|
|
23297
|
-
const dir =
|
|
23298
|
-
if (!
|
|
23425
|
+
const dir = path77.resolve(folder);
|
|
23426
|
+
if (!fs76.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder} is not a folder`, "bad-args");
|
|
23299
23427
|
const files = readStudioFolder(dir);
|
|
23300
23428
|
const read3 = parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE);
|
|
23301
23429
|
const def = "def" in read3 ? read3.def : null;
|
|
@@ -23316,26 +23444,26 @@ function cmdStudioValidate(folder) {
|
|
|
23316
23444
|
async function cmdStudioPull(id, folder) {
|
|
23317
23445
|
const cloudId = cloudIdOf(id);
|
|
23318
23446
|
if (!cloudId) found(id);
|
|
23319
|
-
const dir =
|
|
23320
|
-
if (
|
|
23447
|
+
const dir = path77.resolve(folder ?? id);
|
|
23448
|
+
if (fs76.existsSync(dir) && fs76.readdirSync(dir).length) die(`${folder ?? id} is not empty`, "bad-args");
|
|
23321
23449
|
const read3 = await call("GET", `/v1/studios/${encodeURIComponent(cloudId)}`);
|
|
23322
23450
|
if (!read3.ok) die(read3.error, read3.code === "not_found" ? "no-such-studio" : "cloud-refused");
|
|
23323
23451
|
const { version, files } = read3.value;
|
|
23324
23452
|
for (const [file, text4] of Object.entries({ ...files, [VERSION_FILE]: versionText(cloudId, version) })) {
|
|
23325
|
-
const full =
|
|
23326
|
-
|
|
23453
|
+
const full = path77.join(dir, ...file.split("/"));
|
|
23454
|
+
fs76.mkdirSync(path77.dirname(full), { recursive: true });
|
|
23327
23455
|
const data = isAboutFile(file) && !file.endsWith(".md") && /^data:[^;]+;base64,/.exec(text4);
|
|
23328
|
-
|
|
23456
|
+
fs76.writeFileSync(full, data ? Buffer.from(text4.slice(data[0].length), "base64") : text4);
|
|
23329
23457
|
}
|
|
23330
23458
|
const shown = folder ?? `./${id}`;
|
|
23331
23459
|
say(`Pulled ${id} v${version} into ${shown}.`);
|
|
23332
23460
|
return { id, version, folder: dir };
|
|
23333
23461
|
}
|
|
23334
23462
|
async function cmdStudioPush(folder, opts) {
|
|
23335
|
-
const dir =
|
|
23463
|
+
const dir = path77.resolve(folder);
|
|
23336
23464
|
let pulled = null;
|
|
23337
23465
|
try {
|
|
23338
|
-
pulled = JSON.parse(
|
|
23466
|
+
pulled = JSON.parse(fs76.readFileSync(path77.join(dir, VERSION_FILE), "utf8"));
|
|
23339
23467
|
} catch {
|
|
23340
23468
|
}
|
|
23341
23469
|
if (!pulled?.id || !Number.isInteger(pulled.version)) die(`${folder} was not written by \`akb studio pull\``, "bad-args");
|
|
@@ -23365,7 +23493,7 @@ async function cmdStudioPush(folder, opts) {
|
|
|
23365
23493
|
die(res.error, res.code === "bad_request" || res.code === "payload_too_large" ? "bad-studio" : "cloud-refused");
|
|
23366
23494
|
}
|
|
23367
23495
|
const next = res.value.version;
|
|
23368
|
-
|
|
23496
|
+
fs76.writeFileSync(path77.join(dir, VERSION_FILE), versionText(cloudId, next));
|
|
23369
23497
|
say(`Pushed ${id} v${next}. New tasks take it.`);
|
|
23370
23498
|
return { id, version: next, changed: true };
|
|
23371
23499
|
}
|
|
@@ -23373,7 +23501,7 @@ function noteText({ file, text: text4 }) {
|
|
|
23373
23501
|
if (file !== void 0 && text4 !== void 0) die("pass --file or --text, not both", "bad-args");
|
|
23374
23502
|
if (file !== void 0) {
|
|
23375
23503
|
try {
|
|
23376
|
-
return
|
|
23504
|
+
return fs76.readFileSync(file, "utf8").trim();
|
|
23377
23505
|
} catch {
|
|
23378
23506
|
die(`can't read ${file}`, "bad-args");
|
|
23379
23507
|
}
|
|
@@ -23598,8 +23726,8 @@ var init_complete = __esm({
|
|
|
23598
23726
|
});
|
|
23599
23727
|
|
|
23600
23728
|
// src/lib/agent/approve.ts
|
|
23601
|
-
import
|
|
23602
|
-
import
|
|
23729
|
+
import fs77 from "node:fs";
|
|
23730
|
+
import path78 from "node:path";
|
|
23603
23731
|
function approvalRequest(req) {
|
|
23604
23732
|
const id = req.id;
|
|
23605
23733
|
const card = id === void 0 ? null : findCard(id);
|
|
@@ -23617,12 +23745,12 @@ function advancePhase(id) {
|
|
|
23617
23745
|
const card = findCard(id);
|
|
23618
23746
|
const found2 = locate(id);
|
|
23619
23747
|
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(
|
|
23748
|
+
const file = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
|
|
23749
|
+
const { meta, body } = parseFrontmatter(fs77.readFileSync(file, "utf8"));
|
|
23622
23750
|
if (!meta) return { error: `#${id} has no frontmatter` };
|
|
23623
23751
|
meta.phase = card.stage + 1;
|
|
23624
23752
|
meta.status = "todo";
|
|
23625
|
-
|
|
23753
|
+
fs77.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
|
|
23626
23754
|
return null;
|
|
23627
23755
|
}
|
|
23628
23756
|
var init_approve = __esm({
|
|
@@ -23745,16 +23873,16 @@ var init_start = __esm({
|
|
|
23745
23873
|
});
|
|
23746
23874
|
|
|
23747
23875
|
// src/lib/agent/task-chats.ts
|
|
23748
|
-
import
|
|
23749
|
-
import
|
|
23876
|
+
import fs78 from "node:fs";
|
|
23877
|
+
import path79 from "node:path";
|
|
23750
23878
|
function taskChatFile(task, home3) {
|
|
23751
23879
|
if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
|
|
23752
|
-
return
|
|
23880
|
+
return path79.join(taskChatsDir(home3), `${task}.jsonl`);
|
|
23753
23881
|
}
|
|
23754
23882
|
function readTaskChat(task, home3) {
|
|
23755
23883
|
let text4;
|
|
23756
23884
|
try {
|
|
23757
|
-
text4 =
|
|
23885
|
+
text4 = fs78.readFileSync(taskChatFile(task, home3), "utf8");
|
|
23758
23886
|
} catch {
|
|
23759
23887
|
return [];
|
|
23760
23888
|
}
|
|
@@ -23775,13 +23903,13 @@ var init_task_chats = __esm({
|
|
|
23775
23903
|
"use strict";
|
|
23776
23904
|
init_home();
|
|
23777
23905
|
TASK = /^[\w-]{1,100}$/;
|
|
23778
|
-
taskChatsDir = (home3 = machineHome()) =>
|
|
23906
|
+
taskChatsDir = (home3 = machineHome()) => path79.join(home3, "chats");
|
|
23779
23907
|
}
|
|
23780
23908
|
});
|
|
23781
23909
|
|
|
23782
23910
|
// src/lib/agent/memory-review.ts
|
|
23783
|
-
import
|
|
23784
|
-
import
|
|
23911
|
+
import fs79 from "node:fs";
|
|
23912
|
+
import path80 from "node:path";
|
|
23785
23913
|
function taskChatsToReview(tasks) {
|
|
23786
23914
|
const out = [];
|
|
23787
23915
|
for (const ref of [...new Set(tasks)]) {
|
|
@@ -23803,8 +23931,8 @@ function readArchived2(id) {
|
|
|
23803
23931
|
const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
|
|
23804
23932
|
if (!found2) return null;
|
|
23805
23933
|
try {
|
|
23806
|
-
const file = found2.kind === "group" ?
|
|
23807
|
-
const { meta, body } = parseFrontmatter(
|
|
23934
|
+
const file = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
|
|
23935
|
+
const { meta, body } = parseFrontmatter(fs79.readFileSync(file, "utf8"));
|
|
23808
23936
|
if (!meta) return null;
|
|
23809
23937
|
return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
|
|
23810
23938
|
} catch {
|
|
@@ -23873,17 +24001,17 @@ var init_memory_review = __esm({
|
|
|
23873
24001
|
});
|
|
23874
24002
|
|
|
23875
24003
|
// src/lib/agent/dismissal-review.ts
|
|
23876
|
-
import
|
|
23877
|
-
import
|
|
24004
|
+
import fs80 from "node:fs";
|
|
24005
|
+
import path81 from "node:path";
|
|
23878
24006
|
function rejectionsToReview() {
|
|
23879
|
-
const dir =
|
|
23880
|
-
if (!
|
|
24007
|
+
const dir = path81.join(ARCHIVE, REJECTIONS_TO_REVIEW);
|
|
24008
|
+
if (!fs80.existsSync(dir)) return [];
|
|
23881
24009
|
const found2 = [];
|
|
23882
24010
|
for (const file of walkMd(dir)) {
|
|
23883
24011
|
const id = archivedId(file);
|
|
23884
24012
|
if (id === null) continue;
|
|
23885
24013
|
try {
|
|
23886
|
-
const { meta } = parseFrontmatter(
|
|
24014
|
+
const { meta } = parseFrontmatter(fs80.readFileSync(file, "utf8"));
|
|
23887
24015
|
if (!meta?.rejected || meta.rejected_by !== "user" || !meta.rejected_reason.trim()) continue;
|
|
23888
24016
|
found2.push({ id, title: meta.title, file: rel(file), reason: meta.rejected_reason.trim(), rejectedAt: meta.rejected_at });
|
|
23889
24017
|
} catch {
|
|
@@ -23913,7 +24041,7 @@ function citedSources(text4) {
|
|
|
23913
24041
|
function withdrawnSources() {
|
|
23914
24042
|
const cited = [...new Set(plannerCopies("rejected.md").flatMap((file) => {
|
|
23915
24043
|
try {
|
|
23916
|
-
return citedSources(
|
|
24044
|
+
return citedSources(fs80.readFileSync(file, "utf8"));
|
|
23917
24045
|
} catch {
|
|
23918
24046
|
return [];
|
|
23919
24047
|
}
|
|
@@ -23938,8 +24066,8 @@ var init_dismissal_review = __esm({
|
|
|
23938
24066
|
});
|
|
23939
24067
|
|
|
23940
24068
|
// src/lib/agent/flow.ts
|
|
23941
|
-
import
|
|
23942
|
-
import
|
|
24069
|
+
import fs81 from "node:fs";
|
|
24070
|
+
import path82 from "node:path";
|
|
23943
24071
|
function readCard2(id, home3 = "board") {
|
|
23944
24072
|
const pending = activeDelivery(id)?.completions?.some((c) => !c.finished);
|
|
23945
24073
|
const found2 = home3 === "archive" ? locateArchived(id) : locate(id) ?? (pending ? locateArchived(id) : null);
|
|
@@ -23949,10 +24077,10 @@ function readCard2(id, home3 = "board") {
|
|
|
23949
24077
|
{ kind: "card-not-found", id }
|
|
23950
24078
|
);
|
|
23951
24079
|
}
|
|
23952
|
-
const file = found2.kind === "group" ?
|
|
24080
|
+
const file = found2.kind === "group" ? path82.join(found2.target, "root.md") : found2.target;
|
|
23953
24081
|
let text4;
|
|
23954
24082
|
try {
|
|
23955
|
-
text4 =
|
|
24083
|
+
text4 = fs81.readFileSync(file, "utf8");
|
|
23956
24084
|
} catch {
|
|
23957
24085
|
die(`#${id} is on the board but ${rel(file)} can't be read.`, { kind: "card-unreadable", id });
|
|
23958
24086
|
}
|
|
@@ -24768,7 +24896,7 @@ __export(watch_exports, {
|
|
|
24768
24896
|
watchRun: () => watchRun
|
|
24769
24897
|
});
|
|
24770
24898
|
import { spawn as spawn3 } from "node:child_process";
|
|
24771
|
-
import
|
|
24899
|
+
import fs82 from "node:fs";
|
|
24772
24900
|
async function watchRun(sessionId, resume = startResume) {
|
|
24773
24901
|
const spec = readSpec(sessionId);
|
|
24774
24902
|
const run2 = peekRun(sessionId);
|
|
@@ -24804,11 +24932,11 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
24804
24932
|
const record = claimed ?? run2;
|
|
24805
24933
|
const sub = record.action === "sub";
|
|
24806
24934
|
if (claim) await setCardStatus(claim.cardId, claim.status);
|
|
24807
|
-
|
|
24808
|
-
const logFile =
|
|
24935
|
+
fs82.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
24936
|
+
const logFile = fs82.createWriteStream(record.logPath, { flags: "a" });
|
|
24809
24937
|
logFile.on("error", () => {
|
|
24810
24938
|
});
|
|
24811
|
-
const eventsFile =
|
|
24939
|
+
const eventsFile = fs82.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
|
|
24812
24940
|
eventsFile.on("error", () => {
|
|
24813
24941
|
});
|
|
24814
24942
|
const event2 = (e) => eventsFile.write(`${JSON.stringify(e)}
|
|
@@ -25378,8 +25506,8 @@ var init_watch = __esm({
|
|
|
25378
25506
|
});
|
|
25379
25507
|
|
|
25380
25508
|
// src/commands/run.ts
|
|
25381
|
-
import
|
|
25382
|
-
import
|
|
25509
|
+
import fs83 from "node:fs";
|
|
25510
|
+
import path83 from "node:path";
|
|
25383
25511
|
async function cmdStartRun(action, args, opts, program2 = "akb") {
|
|
25384
25512
|
const { req, follow: follow2, print } = readRequest(action, args, opts);
|
|
25385
25513
|
if (Number.isInteger(req.id)) {
|
|
@@ -25595,7 +25723,7 @@ async function cmdSubStart(words, opts) {
|
|
|
25595
25723
|
let prompt = words.join(" ");
|
|
25596
25724
|
if (opts.file) {
|
|
25597
25725
|
try {
|
|
25598
|
-
prompt =
|
|
25726
|
+
prompt = fs83.readFileSync(path83.resolve(opts.file), "utf8");
|
|
25599
25727
|
} catch {
|
|
25600
25728
|
die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
|
|
25601
25729
|
}
|
|
@@ -25962,7 +26090,7 @@ var init_signals = __esm({
|
|
|
25962
26090
|
});
|
|
25963
26091
|
|
|
25964
26092
|
// src/commands/triage.ts
|
|
25965
|
-
import
|
|
26093
|
+
import fs84 from "node:fs";
|
|
25966
26094
|
async function cmdTriageAdd(opts) {
|
|
25967
26095
|
const title = (opts.title ?? "").trim();
|
|
25968
26096
|
if (!title) die('say what it is: --title "<one line>"', { kind: "needs-input" });
|
|
@@ -25972,7 +26100,7 @@ async function cmdTriageAdd(opts) {
|
|
|
25972
26100
|
let body = opts.text;
|
|
25973
26101
|
if (opts.file !== void 0) {
|
|
25974
26102
|
try {
|
|
25975
|
-
body =
|
|
26103
|
+
body = fs84.readFileSync(opts.file, "utf8");
|
|
25976
26104
|
} catch {
|
|
25977
26105
|
die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
|
|
25978
26106
|
}
|
|
@@ -26643,15 +26771,15 @@ var init_agent2 = __esm({
|
|
|
26643
26771
|
});
|
|
26644
26772
|
|
|
26645
26773
|
// src/kanban.ts
|
|
26646
|
-
import
|
|
26774
|
+
import fs87 from "node:fs";
|
|
26647
26775
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
26648
26776
|
|
|
26649
26777
|
// src/lib/cli/akb.ts
|
|
26650
26778
|
init_agent2();
|
|
26651
26779
|
|
|
26652
26780
|
// src/lib/cli/setup.ts
|
|
26653
|
-
import
|
|
26654
|
-
import
|
|
26781
|
+
import fs86 from "node:fs";
|
|
26782
|
+
import path85 from "node:path";
|
|
26655
26783
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
26656
26784
|
|
|
26657
26785
|
// src/commands/update.ts
|
|
@@ -26665,8 +26793,8 @@ init_paths();
|
|
|
26665
26793
|
init_memory();
|
|
26666
26794
|
init_yaml2();
|
|
26667
26795
|
init_version();
|
|
26668
|
-
import
|
|
26669
|
-
import
|
|
26796
|
+
import fs85 from "node:fs";
|
|
26797
|
+
import path84 from "node:path";
|
|
26670
26798
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
26671
26799
|
var NAME = "wildcrane";
|
|
26672
26800
|
var REPO = "https://github.com/wildcrane-ai/wildcrane";
|
|
@@ -26688,10 +26816,10 @@ var Report = class {
|
|
|
26688
26816
|
for (const line of this.notes) say(` ! ${line}`);
|
|
26689
26817
|
}
|
|
26690
26818
|
};
|
|
26691
|
-
var read2 = (file) =>
|
|
26819
|
+
var read2 = (file) => fs85.existsSync(file) ? fs85.readFileSync(file, "utf8") : null;
|
|
26692
26820
|
function statOf(p) {
|
|
26693
26821
|
try {
|
|
26694
|
-
return
|
|
26822
|
+
return fs85.lstatSync(p);
|
|
26695
26823
|
} catch {
|
|
26696
26824
|
return null;
|
|
26697
26825
|
}
|
|
@@ -26716,10 +26844,10 @@ async function cmdUpdate2(ctx) {
|
|
|
26716
26844
|
return { updated: ctx.dir, from, to: SKILL_VERSION };
|
|
26717
26845
|
}
|
|
26718
26846
|
async function repairBoard(root2, report3, named2) {
|
|
26719
|
-
const legacy2 =
|
|
26720
|
-
const kept2 =
|
|
26721
|
-
const board2 = named2 ?? (
|
|
26722
|
-
if (!
|
|
26847
|
+
const legacy2 = path84.join(root2, "docs", "kanban");
|
|
26848
|
+
const kept2 = path84.join(root2, ".akb", "kanban");
|
|
26849
|
+
const board2 = named2 ?? (fs85.existsSync(legacy2) ? legacy2 : kept2);
|
|
26850
|
+
if (!fs85.existsSync(board2)) {
|
|
26723
26851
|
report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
|
|
26724
26852
|
return false;
|
|
26725
26853
|
}
|
|
@@ -26750,20 +26878,20 @@ function moveRuntimes(root2, board2, report3) {
|
|
|
26750
26878
|
}
|
|
26751
26879
|
}
|
|
26752
26880
|
function moveLegacyMemory(board2, report3) {
|
|
26753
|
-
const memory =
|
|
26881
|
+
const memory = path84.join(board2, "memory");
|
|
26754
26882
|
const moved = [];
|
|
26755
26883
|
for (const name of MEMORY_FILES) {
|
|
26756
|
-
const from =
|
|
26884
|
+
const from = path84.join(board2, name);
|
|
26757
26885
|
const st = statOf(from);
|
|
26758
26886
|
if (!st || !st.isFile()) continue;
|
|
26759
|
-
|
|
26760
|
-
const to =
|
|
26887
|
+
fs85.mkdirSync(memory, { recursive: true });
|
|
26888
|
+
const to = path84.join(memory, name);
|
|
26761
26889
|
const there = read2(to);
|
|
26762
26890
|
if (there === null) {
|
|
26763
|
-
|
|
26891
|
+
fs85.renameSync(from, to);
|
|
26764
26892
|
moved.push(name);
|
|
26765
26893
|
} else if (there === read2(from)) {
|
|
26766
|
-
|
|
26894
|
+
fs85.rmSync(from);
|
|
26767
26895
|
moved.push(name);
|
|
26768
26896
|
} else {
|
|
26769
26897
|
report3.notes.push(`both docs/kanban/${name} and docs/kanban/memory/${name} exist and differ \u2014 merge them by hand`);
|
|
@@ -26772,23 +26900,23 @@ function moveLegacyMemory(board2, report3) {
|
|
|
26772
26900
|
if (moved.length) report3.did.push(`moved the memory set into docs/kanban/memory/: ${moved.join(", ")}`);
|
|
26773
26901
|
}
|
|
26774
26902
|
function dropRecordFile(board2) {
|
|
26775
|
-
const file =
|
|
26776
|
-
if (!
|
|
26777
|
-
|
|
26903
|
+
const file = path84.join(board2, "record.csv");
|
|
26904
|
+
if (!fs85.existsSync(file)) return null;
|
|
26905
|
+
fs85.rmSync(file);
|
|
26778
26906
|
return "removed docs/kanban/record.csv (the planning scores it fed are gone)";
|
|
26779
26907
|
}
|
|
26780
26908
|
function dropModuleGoals(board2, report3) {
|
|
26781
|
-
const memory =
|
|
26782
|
-
if (!
|
|
26783
|
-
const root2 = read2(
|
|
26909
|
+
const memory = path84.join(board2, "memory");
|
|
26910
|
+
if (!fs85.existsSync(memory)) return;
|
|
26911
|
+
const root2 = read2(path84.join(memory, "goal.md"));
|
|
26784
26912
|
let dropped = 0;
|
|
26785
|
-
for (const entry of
|
|
26913
|
+
for (const entry of fs85.readdirSync(memory, { withFileTypes: true })) {
|
|
26786
26914
|
if (!entry.isDirectory()) continue;
|
|
26787
|
-
const file =
|
|
26915
|
+
const file = path84.join(memory, entry.name, "goal.md");
|
|
26788
26916
|
const text4 = read2(file);
|
|
26789
26917
|
if (text4 === null) continue;
|
|
26790
26918
|
if (text4 === root2 || text4.includes(UNFILLED) || !goalWords(text4)) {
|
|
26791
|
-
|
|
26919
|
+
fs85.rmSync(file);
|
|
26792
26920
|
dropped++;
|
|
26793
26921
|
} else {
|
|
26794
26922
|
report3.notes.push(
|
|
@@ -26810,10 +26938,10 @@ var PLAN_LEADS = {
|
|
|
26810
26938
|
var GONE_LEADS = ["software-planner", "planner"];
|
|
26811
26939
|
function planLeads(board2) {
|
|
26812
26940
|
const leads = { ...PLAN_LEADS };
|
|
26813
|
-
const root2 =
|
|
26814
|
-
for (const entry of
|
|
26941
|
+
const root2 = path84.join(board2, "studios");
|
|
26942
|
+
for (const entry of fs85.existsSync(root2) ? fs85.readdirSync(root2, { withFileTypes: true }) : []) {
|
|
26815
26943
|
if (!entry.isDirectory()) continue;
|
|
26816
|
-
const meta = splitFrontmatter(read2(
|
|
26944
|
+
const meta = splitFrontmatter(read2(path84.join(root2, entry.name, "STUDIO.md")) ?? "").meta;
|
|
26817
26945
|
const stages = meta === null ? void 0 : parseYamlBlock(meta).stages;
|
|
26818
26946
|
const plan = stages && typeof stages === "object" && !Array.isArray(stages) ? stages.plan : void 0;
|
|
26819
26947
|
const lead = plan && typeof plan === "object" && !Array.isArray(plan) && typeof plan.lead === "string" ? plan.lead.trim() : "";
|
|
@@ -26822,30 +26950,30 @@ function planLeads(board2) {
|
|
|
26822
26950
|
return leads;
|
|
26823
26951
|
}
|
|
26824
26952
|
function movePlanRules(board2, report3) {
|
|
26825
|
-
const rules =
|
|
26953
|
+
const rules = path84.join(board2, "rules");
|
|
26826
26954
|
const moved = [];
|
|
26827
26955
|
for (const [id, leads] of Object.entries(planLeads(board2))) {
|
|
26828
26956
|
for (const lead of leads) {
|
|
26829
|
-
const from =
|
|
26957
|
+
const from = path84.join(rules, `${lead}.md`);
|
|
26830
26958
|
const rule = read2(from)?.trim();
|
|
26831
26959
|
if (!rule) continue;
|
|
26832
|
-
const to =
|
|
26960
|
+
const to = path84.join(rules, "studios", `${id}.md`);
|
|
26833
26961
|
const there = read2(to)?.trim() ?? "";
|
|
26834
26962
|
if (!there.includes(rule)) {
|
|
26835
|
-
|
|
26836
|
-
|
|
26963
|
+
fs85.mkdirSync(path84.dirname(to), { recursive: true });
|
|
26964
|
+
fs85.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
|
|
26837
26965
|
`);
|
|
26838
26966
|
moved.push(`${lead} \u2192 ${id}`);
|
|
26839
26967
|
}
|
|
26840
26968
|
}
|
|
26841
26969
|
}
|
|
26842
|
-
for (const lead of GONE_LEADS)
|
|
26970
|
+
for (const lead of GONE_LEADS) fs85.rmSync(path84.join(rules, `${lead}.md`), { force: true });
|
|
26843
26971
|
if (moved.length) report3.did.push(`made each plan agent's rule its studio's card rule (docs/kanban/rules/studios/): ${moved.join(", ")}`);
|
|
26844
26972
|
}
|
|
26845
26973
|
function noteOldStudios(board2, report3) {
|
|
26846
26974
|
const old = (dir, file, keys) => {
|
|
26847
|
-
const root2 =
|
|
26848
|
-
return (
|
|
26975
|
+
const root2 = path84.join(board2, dir);
|
|
26976
|
+
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
26977
|
};
|
|
26850
26978
|
const files = [...old("studios", "STUDIO.md", /^(stages|delivers):/m), ...old("agents", "AGENT.md", /^\s+(hook|lead):/m)];
|
|
26851
26979
|
if (files.length) {
|
|
@@ -26855,7 +26983,7 @@ function noteOldStudios(board2, report3) {
|
|
|
26855
26983
|
}
|
|
26856
26984
|
}
|
|
26857
26985
|
function checkConfig(board2, report3) {
|
|
26858
|
-
const current = read2(
|
|
26986
|
+
const current = read2(path84.join(board2, "config.md"));
|
|
26859
26987
|
if (!current) return;
|
|
26860
26988
|
const added = missingConfigKeys(current);
|
|
26861
26989
|
if (added.length) {
|
|
@@ -26865,7 +26993,7 @@ function checkConfig(board2, report3) {
|
|
|
26865
26993
|
}
|
|
26866
26994
|
}
|
|
26867
26995
|
function checkModules(board2, report3) {
|
|
26868
|
-
const map2 = read2(
|
|
26996
|
+
const map2 = read2(path84.join(board2, "modules.md"));
|
|
26869
26997
|
if (map2 && map2.includes(UNFILLED)) {
|
|
26870
26998
|
report3.notes.push(
|
|
26871
26999
|
"docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
|
|
@@ -26919,14 +27047,14 @@ function declareSetup(program2, cli) {
|
|
|
26919
27047
|
program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
|
|
26920
27048
|
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
27049
|
const where = (cmd) => {
|
|
26922
|
-
const dir =
|
|
26923
|
-
if (!
|
|
27050
|
+
const dir = path85.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
|
|
27051
|
+
if (!fs86.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
|
|
26924
27052
|
return dir;
|
|
26925
27053
|
};
|
|
26926
27054
|
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
27055
|
const dir = where(this);
|
|
26928
27056
|
const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
|
|
26929
|
-
const board2 = named2 ?
|
|
27057
|
+
const board2 = named2 ? path85.resolve(cli.cwd, named2) : null;
|
|
26930
27058
|
await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
|
|
26931
27059
|
});
|
|
26932
27060
|
program2.command("__rules", { hidden: true }).action(function() {
|
|
@@ -26971,7 +27099,7 @@ function invokedDirectly() {
|
|
|
26971
27099
|
const entry = process.argv[1];
|
|
26972
27100
|
if (!entry) return false;
|
|
26973
27101
|
try {
|
|
26974
|
-
return
|
|
27102
|
+
return fs87.realpathSync(entry) === fs87.realpathSync(SELF2);
|
|
26975
27103
|
} catch {
|
|
26976
27104
|
return false;
|
|
26977
27105
|
}
|