wildcrane-runner 0.6.31 → 0.6.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/akb/dist/kanban.mjs +940 -875
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/launcher.mjs +3 -3
- package/dist/runner.mjs +558 -533
- package/dist/settings.mjs +3 -3
- package/package.json +1 -1
package/dist/akb/dist/kanban.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// ai4kanban 0.11.
|
|
2
|
+
// ai4kanban 0.11.30 — built by runner/scripts/build.mjs. Do not edit.
|
|
3
3
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
4
4
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
5
5
|
var __create = Object.create;
|
|
@@ -2551,10 +2551,10 @@ function findRollout(threadId) {
|
|
|
2551
2551
|
}
|
|
2552
2552
|
for (const name of names3) {
|
|
2553
2553
|
if (!name.startsWith("rollout-") || !name.endsWith(tail2)) continue;
|
|
2554
|
-
const
|
|
2554
|
+
const path90 = join(dir, name);
|
|
2555
2555
|
try {
|
|
2556
|
-
const at2 = statSync(
|
|
2557
|
-
if (!newest2 || at2 > newest2.at) newest2 = { path:
|
|
2556
|
+
const at2 = statSync(path90).mtimeMs;
|
|
2557
|
+
if (!newest2 || at2 > newest2.at) newest2 = { path: path90, at: at2 };
|
|
2558
2558
|
} catch {
|
|
2559
2559
|
}
|
|
2560
2560
|
}
|
|
@@ -2562,11 +2562,11 @@ function findRollout(threadId) {
|
|
|
2562
2562
|
return newest2?.path;
|
|
2563
2563
|
}
|
|
2564
2564
|
function readCodexRunFacts(threadId) {
|
|
2565
|
-
const
|
|
2566
|
-
if (!
|
|
2565
|
+
const path90 = findRollout(threadId);
|
|
2566
|
+
if (!path90) return void 0;
|
|
2567
2567
|
let raw;
|
|
2568
2568
|
try {
|
|
2569
|
-
raw = readFileSync(
|
|
2569
|
+
raw = readFileSync(path90, "utf8");
|
|
2570
2570
|
} catch {
|
|
2571
2571
|
return void 0;
|
|
2572
2572
|
}
|
|
@@ -2694,8 +2694,8 @@ function renderCompleted(item) {
|
|
|
2694
2694
|
const changes = Array.isArray(item.changes) ? item.changes : [];
|
|
2695
2695
|
return changes.map((raw) => {
|
|
2696
2696
|
const change2 = obj(raw);
|
|
2697
|
-
const
|
|
2698
|
-
return
|
|
2697
|
+
const path90 = str(change2.path);
|
|
2698
|
+
return path90 ? `\u23FA ${str(change2.kind) || "change"}(${path90})
|
|
2699
2699
|
` : "";
|
|
2700
2700
|
}).join("");
|
|
2701
2701
|
}
|
|
@@ -2957,10 +2957,10 @@ function readKimiRunFacts(sessionId) {
|
|
|
2957
2957
|
const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
|
|
2958
2958
|
let model;
|
|
2959
2959
|
let holding = 0;
|
|
2960
|
-
for (const { path:
|
|
2960
|
+
for (const { path: path90, main } of wireFiles(entry.sessionDir)) {
|
|
2961
2961
|
let raw;
|
|
2962
2962
|
try {
|
|
2963
|
-
raw = readFileSync2(
|
|
2963
|
+
raw = readFileSync2(path90, "utf8");
|
|
2964
2964
|
} catch {
|
|
2965
2965
|
continue;
|
|
2966
2966
|
}
|
|
@@ -3243,7 +3243,7 @@ var init_package = __esm({
|
|
|
3243
3243
|
"../cli/package.json"() {
|
|
3244
3244
|
package_default = {
|
|
3245
3245
|
name: "wildcrane",
|
|
3246
|
-
version: "0.11.
|
|
3246
|
+
version: "0.11.30",
|
|
3247
3247
|
akbContract: 7,
|
|
3248
3248
|
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.",
|
|
3249
3249
|
keywords: [
|
|
@@ -3320,8 +3320,8 @@ var init_version = __esm({
|
|
|
3320
3320
|
import fs12 from "node:fs";
|
|
3321
3321
|
function whereHint(update2, title) {
|
|
3322
3322
|
const locations = Array.isArray(update2.locations) ? update2.locations : [];
|
|
3323
|
-
const
|
|
3324
|
-
return
|
|
3323
|
+
const path90 = str(obj(locations[0]).path);
|
|
3324
|
+
return path90 && !title.includes(path90) ? hint(path90) : "";
|
|
3325
3325
|
}
|
|
3326
3326
|
function saidBy(update2) {
|
|
3327
3327
|
const content = Array.isArray(update2.content) ? update2.content : [];
|
|
@@ -8245,15 +8245,15 @@ var init_roles = __esm({
|
|
|
8245
8245
|
});
|
|
8246
8246
|
|
|
8247
8247
|
// ../cli/src/lib/shared/board-files.ts
|
|
8248
|
-
function isBoardPath(
|
|
8249
|
-
if (!
|
|
8250
|
-
if (
|
|
8251
|
-
if (
|
|
8252
|
-
if (
|
|
8253
|
-
if (SETTINGS.includes(
|
|
8254
|
-
if (
|
|
8255
|
-
if (
|
|
8256
|
-
return ROOTS.some((root2) =>
|
|
8248
|
+
function isBoardPath(path90) {
|
|
8249
|
+
if (!path90 || path90.length > 500 || path90.startsWith("/") || path90.includes("\\") || path90.includes("\0")) return false;
|
|
8250
|
+
if (path90.split("/").some((part) => !part || part === "." || part === "..")) return false;
|
|
8251
|
+
if (path90 === "todo/README.md" || path90.split("/").includes(".sync")) return false;
|
|
8252
|
+
if (path90.startsWith("workflows/")) return true;
|
|
8253
|
+
if (SETTINGS.includes(path90)) return true;
|
|
8254
|
+
if (path90.startsWith("rules/")) return isSettingsPath(path90);
|
|
8255
|
+
if (path90.startsWith("assets/")) return path90.endsWith(".json");
|
|
8256
|
+
return ROOTS.some((root2) => path90.startsWith(root2)) && path90.endsWith(".md");
|
|
8257
8257
|
}
|
|
8258
8258
|
var ROOTS, SETTINGS, isSettingsPath, BOARD_FILE_LIMIT, cardSlug, workflowFolder, workflowName, draftFolder;
|
|
8259
8259
|
var init_board_files = __esm({
|
|
@@ -8261,7 +8261,7 @@ var init_board_files = __esm({
|
|
|
8261
8261
|
"use strict";
|
|
8262
8262
|
ROOTS = ["todo/", ".archive/", "memory/", "workflows/", "triage/", "assets/", "rules/"];
|
|
8263
8263
|
SETTINGS = ["modules.md", "config.md"];
|
|
8264
|
-
isSettingsPath = (
|
|
8264
|
+
isSettingsPath = (path90) => SETTINGS.includes(path90) || /^rules\/(?:workflows\/)?[^/]+\.md$/.test(path90);
|
|
8265
8265
|
BOARD_FILE_LIMIT = 256 * 1024;
|
|
8266
8266
|
cardSlug = (task) => task.toLowerCase().replace(/_/g, "-");
|
|
8267
8267
|
workflowFolder = (id) => id.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
@@ -8794,7 +8794,7 @@ function checkWorkflowFiles(value, official = false) {
|
|
|
8794
8794
|
}
|
|
8795
8795
|
return { ok: true, def, files: value };
|
|
8796
8796
|
}
|
|
8797
|
-
var WORKFLOW_FILE, MCP_FILE, KB, FILE_LIMITS, landsOf, SEGMENT, isAboutFile, bytes;
|
|
8797
|
+
var WORKFLOW_FILE, MCP_FILE, KB, FILE_LIMITS, officialId, hashInput, landsOf, SEGMENT, isAboutFile, bytes;
|
|
8798
8798
|
var init_workflow_files = __esm({
|
|
8799
8799
|
"../cli/src/lib/shared/workflow-files.ts"() {
|
|
8800
8800
|
"use strict";
|
|
@@ -8804,7 +8804,9 @@ var init_workflow_files = __esm({
|
|
|
8804
8804
|
WORKFLOW_FILE = "WORKFLOW.md";
|
|
8805
8805
|
MCP_FILE = "mcp.json";
|
|
8806
8806
|
KB = 1024;
|
|
8807
|
-
FILE_LIMITS = { file:
|
|
8807
|
+
FILE_LIMITS = { file: 2 * KB * KB, total: 2 * KB * KB, count: 500, path: 512 };
|
|
8808
|
+
officialId = (folder) => `wf_builtin_${folder.replace(/-/g, "_")}`;
|
|
8809
|
+
hashInput = (files2) => JSON.stringify(Object.entries(files2).sort(([a2], [b2]) => a2 < b2 ? -1 : 1));
|
|
8808
8810
|
landsOf = (def) => ({ lands: def.land.some((h3) => !h3.off) });
|
|
8809
8811
|
SEGMENT = /^[\w.-]+$/;
|
|
8810
8812
|
isAboutFile = (file) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file);
|
|
@@ -8812,34 +8814,50 @@ var init_workflow_files = __esm({
|
|
|
8812
8814
|
}
|
|
8813
8815
|
});
|
|
8814
8816
|
|
|
8815
|
-
// ../
|
|
8816
|
-
import crypto from "node:crypto";
|
|
8817
|
+
// ../cli/src/lib/agent/workflow-folder.ts
|
|
8817
8818
|
import fs23 from "node:fs";
|
|
8818
8819
|
import path27 from "node:path";
|
|
8819
|
-
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8820
8820
|
function filesOf(dir, base = dir) {
|
|
8821
|
-
return fs23.readdirSync(dir, { withFileTypes: true }).flatMap((e2) => {
|
|
8821
|
+
return fs23.readdirSync(dir, { withFileTypes: true }).filter((e2) => !e2.name.startsWith(".")).flatMap((e2) => {
|
|
8822
8822
|
const full = path27.join(dir, e2.name);
|
|
8823
8823
|
return e2.isDirectory() ? filesOf(full, base) : [path27.relative(base, full).split(path27.sep).join("/")];
|
|
8824
8824
|
});
|
|
8825
8825
|
}
|
|
8826
|
+
function readWorkflowFile(dir, file) {
|
|
8827
|
+
const full = path27.join(dir, file);
|
|
8828
|
+
return isAboutFile(file) && !file.endsWith(".md") ? `data:${MIME[path27.extname(file)]};base64,${fs23.readFileSync(full).toString("base64")}` : fs23.readFileSync(full, "utf8");
|
|
8829
|
+
}
|
|
8830
|
+
var MIME, readWorkflowFolder;
|
|
8831
|
+
var init_workflow_folder = __esm({
|
|
8832
|
+
"../cli/src/lib/agent/workflow-folder.ts"() {
|
|
8833
|
+
"use strict";
|
|
8834
|
+
init_workflow_files();
|
|
8835
|
+
MIME = { ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".webp": "image/webp" };
|
|
8836
|
+
readWorkflowFolder = (dir) => Object.fromEntries(filesOf(dir).sort().map((f2) => [f2, readWorkflowFile(dir, f2)]));
|
|
8837
|
+
}
|
|
8838
|
+
});
|
|
8839
|
+
|
|
8840
|
+
// ../official/pack.ts
|
|
8841
|
+
import crypto from "node:crypto";
|
|
8842
|
+
import fs24 from "node:fs";
|
|
8843
|
+
import path28 from "node:path";
|
|
8844
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8826
8845
|
function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
8827
|
-
const agentsDir =
|
|
8846
|
+
const agentsDir = path28.join(root2, "agents");
|
|
8828
8847
|
const agentFiles = Object.fromEntries(dirs(agentsDir).map((name) => {
|
|
8829
|
-
const dir =
|
|
8830
|
-
return [name,
|
|
8848
|
+
const dir = path28.join(agentsDir, name);
|
|
8849
|
+
return [name, readWorkflowFolder(dir)];
|
|
8831
8850
|
}));
|
|
8832
8851
|
for (const [name, own] of Object.entries(loose ? {} : agentFiles)) {
|
|
8833
8852
|
const read5 = parseSpecAgent(own["AGENT.md"] ?? "", `official/agents/${name}/AGENT.md`, (p2) => own[p2] ?? null, true);
|
|
8834
8853
|
if ("problem" in read5) throw new Error(read5.problem);
|
|
8835
8854
|
}
|
|
8836
|
-
const workflowsDir =
|
|
8855
|
+
const workflowsDir = path28.join(root2, "workflows");
|
|
8837
8856
|
return dirs(workflowsDir).map((folder) => {
|
|
8838
|
-
const dir =
|
|
8857
|
+
const dir = path28.join(workflowsDir, folder);
|
|
8839
8858
|
const files2 = {};
|
|
8840
8859
|
for (const f2 of filesOf(dir).sort()) {
|
|
8841
|
-
if (f2 === WORKFLOW_FILE || f2 === MCP_FILE || f2.startsWith("skills/") ||
|
|
8842
|
-
else if (isAboutFile(f2)) files2[f2] = `data:${MIME[path27.extname(f2)]};base64,${fs23.readFileSync(path27.join(dir, f2)).toString("base64")}`;
|
|
8860
|
+
if (f2 === WORKFLOW_FILE || f2 === MCP_FILE || f2.startsWith("skills/") || isAboutFile(f2)) files2[f2] = readWorkflowFile(dir, f2);
|
|
8843
8861
|
}
|
|
8844
8862
|
const read5 = checkWorkflowFiles({ [WORKFLOW_FILE]: files2[WORKFLOW_FILE], ...Object.fromEntries(
|
|
8845
8863
|
Object.entries(agentFiles).flatMap(([name, own]) => Object.entries(own).map(([f2, t]) => [`agents/${name}/${f2}`, t]))
|
|
@@ -8866,24 +8884,23 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
|
8866
8884
|
};
|
|
8867
8885
|
});
|
|
8868
8886
|
}
|
|
8869
|
-
var OFFICIAL,
|
|
8887
|
+
var OFFICIAL, dirs, hashOf;
|
|
8870
8888
|
var init_pack = __esm({
|
|
8871
8889
|
"../official/pack.ts"() {
|
|
8872
8890
|
init_parse();
|
|
8873
8891
|
init_workflow_def();
|
|
8892
|
+
init_workflow_folder();
|
|
8874
8893
|
init_workflow_files();
|
|
8875
|
-
OFFICIAL =
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
officialId = (folder) => `wf_builtin_${folder.replace(/-/g, "_")}`;
|
|
8879
|
-
hashOf = (files2) => crypto.createHash("sha256").update(JSON.stringify(Object.entries(files2).sort(([a2], [b2]) => a2 < b2 ? -1 : 1))).digest("hex");
|
|
8894
|
+
OFFICIAL = path28.dirname(fileURLToPath2(import.meta.url));
|
|
8895
|
+
dirs = (dir) => fs24.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
|
|
8896
|
+
hashOf = (files2) => crypto.createHash("sha256").update(hashInput(files2)).digest("hex");
|
|
8880
8897
|
}
|
|
8881
8898
|
});
|
|
8882
8899
|
|
|
8883
8900
|
// ../cli/src/lib/cloud/tasks.ts
|
|
8884
8901
|
import crypto2 from "node:crypto";
|
|
8885
|
-
import
|
|
8886
|
-
import
|
|
8902
|
+
import fs25 from "node:fs";
|
|
8903
|
+
import path29 from "node:path";
|
|
8887
8904
|
function workspaceTask() {
|
|
8888
8905
|
const id = process.env[TASK_ENV];
|
|
8889
8906
|
return id && id.trim() ? id.trim() : null;
|
|
@@ -8941,15 +8958,15 @@ ${said3.slug?.trim() || said3.title}`).digest("hex").slice(0, 40)}`;
|
|
|
8941
8958
|
return { ok: true, value: { task: made.value, number, from: source.value, replayed: made.replayed === true } };
|
|
8942
8959
|
}
|
|
8943
8960
|
function runnerProject(board2) {
|
|
8944
|
-
if (
|
|
8945
|
-
const linked = linkedProject(board2,
|
|
8961
|
+
if (path29.basename(board2) !== "kanban" || path29.basename(path29.dirname(board2)) !== ".akb") return null;
|
|
8962
|
+
const linked = linkedProject(board2, path29.dirname(path29.dirname(board2)));
|
|
8946
8963
|
return linked.ok ? linked.value : null;
|
|
8947
8964
|
}
|
|
8948
8965
|
function linkedProject(board2, root2) {
|
|
8949
|
-
const file =
|
|
8950
|
-
if (!
|
|
8966
|
+
const file = path29.join(root2, ".akb", "base.json");
|
|
8967
|
+
if (!fs25.existsSync(file)) return { ok: true, value: null };
|
|
8951
8968
|
try {
|
|
8952
|
-
const base = JSON.parse(
|
|
8969
|
+
const base = JSON.parse(fs25.readFileSync(file, "utf8"));
|
|
8953
8970
|
if (!base || typeof base !== "object" || base.project !== void 0 && (typeof base.project !== "string" || !base.project.trim()) || base.files !== void 0 && (!base.files || typeof base.files !== "object" || Array.isArray(base.files))) throw new Error();
|
|
8954
8971
|
const projects = new Set(Object.keys(base.files ?? {}).flatMap((p2) => /^projects\/([^/]+)\//.exec(p2)?.[1] ?? []));
|
|
8955
8972
|
if (typeof base.project === "string") projects.add(base.project);
|
|
@@ -9016,37 +9033,37 @@ var init_tasks = __esm({
|
|
|
9016
9033
|
});
|
|
9017
9034
|
|
|
9018
9035
|
// ../cli/src/lib/agent/cloud-workflows.ts
|
|
9019
|
-
import
|
|
9020
|
-
import
|
|
9036
|
+
import fs26 from "node:fs";
|
|
9037
|
+
import path30 from "node:path";
|
|
9021
9038
|
function readJson(file) {
|
|
9022
9039
|
try {
|
|
9023
|
-
return JSON.parse(
|
|
9040
|
+
return JSON.parse(fs26.readFileSync(file, "utf8"));
|
|
9024
9041
|
} catch {
|
|
9025
9042
|
return null;
|
|
9026
9043
|
}
|
|
9027
9044
|
}
|
|
9028
9045
|
function writeJson(file, value) {
|
|
9029
|
-
|
|
9046
|
+
fs26.mkdirSync(path30.dirname(file), { recursive: true });
|
|
9030
9047
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
9031
|
-
|
|
9048
|
+
fs26.writeFileSync(tmp, `${JSON.stringify(value)}
|
|
9032
9049
|
`);
|
|
9033
|
-
|
|
9050
|
+
fs26.renameSync(tmp, file);
|
|
9034
9051
|
}
|
|
9035
9052
|
function heldWorkflowName(name) {
|
|
9036
9053
|
let files2;
|
|
9037
9054
|
try {
|
|
9038
|
-
files2 =
|
|
9055
|
+
files2 = fs26.readdirSync(path30.join(root(), "versions"));
|
|
9039
9056
|
} catch {
|
|
9040
9057
|
return "";
|
|
9041
9058
|
}
|
|
9042
9059
|
const held4 = files2.filter((f2) => f2.endsWith(".json")).map((f2) => f2.slice(0, f2.lastIndexOf("@"))).find((id) => workflowName(id) === name);
|
|
9043
9060
|
if (!held4) return "";
|
|
9044
9061
|
const file = files2.filter((f2) => f2.startsWith(`${held4}@`)).sort().pop();
|
|
9045
|
-
return readJson(
|
|
9062
|
+
return readJson(path30.join(root(), "versions", file))?.name ?? "";
|
|
9046
9063
|
}
|
|
9047
9064
|
function saveVersion(held4) {
|
|
9048
9065
|
const file = versionFile(held4.id, held4.version);
|
|
9049
|
-
if (!
|
|
9066
|
+
if (!fs26.existsSync(file)) writeJson(file, { id: held4.id, version: held4.version, name: held4.name, names: held4.names, files: held4.files });
|
|
9050
9067
|
}
|
|
9051
9068
|
function savePin(task, held4) {
|
|
9052
9069
|
saveVersion(held4);
|
|
@@ -9178,11 +9195,11 @@ var init_cloud_workflows = __esm({
|
|
|
9178
9195
|
init_workflow_def();
|
|
9179
9196
|
DEV = "AI4KANBAN_WORKFLOWS";
|
|
9180
9197
|
FRESH_MS = 6e4;
|
|
9181
|
-
root = () =>
|
|
9198
|
+
root = () => path30.join(machineHome(), "workflows");
|
|
9182
9199
|
safe = (name) => name.replace(/[^\w.@-]/g, "_");
|
|
9183
|
-
versionFile = (id, version) =>
|
|
9184
|
-
listFile = (project) =>
|
|
9185
|
-
pinFile = (task) =>
|
|
9200
|
+
versionFile = (id, version) => path30.join(root(), "versions", `${safe(id)}@${version}.json`);
|
|
9201
|
+
listFile = (project) => path30.join(root(), "lists", `${safe(project)}.json`);
|
|
9202
|
+
pinFile = (task) => path30.join(root(), "tasks", `${safe(task)}.json`);
|
|
9186
9203
|
readVersion = (id, version) => readJson(versionFile(id, version));
|
|
9187
9204
|
readPin = (task) => readJson(pinFile(task));
|
|
9188
9205
|
boardProject = () => KANBAN ? runnerProject(KANBAN) : null;
|
|
@@ -9221,8 +9238,8 @@ var init_bundled2 = __esm({
|
|
|
9221
9238
|
});
|
|
9222
9239
|
|
|
9223
9240
|
// ../cli/src/lib/agents/catalog.ts
|
|
9224
|
-
import
|
|
9225
|
-
import
|
|
9241
|
+
import fs27 from "node:fs";
|
|
9242
|
+
import path31 from "node:path";
|
|
9226
9243
|
function readCatalog() {
|
|
9227
9244
|
const agents = [];
|
|
9228
9245
|
const problems = [];
|
|
@@ -9272,7 +9289,7 @@ function readCatalog() {
|
|
|
9272
9289
|
}
|
|
9273
9290
|
for (const folder of projectFolders(LEGACY_AGENTS)) {
|
|
9274
9291
|
take(readProject(LEGACY_AGENTS, folder), folder);
|
|
9275
|
-
problems.push(`${rel(
|
|
9292
|
+
problems.push(`${rel(path31.join(LEGACY_AGENTS, folder))}: move it to ${rel(path31.join(AGENTS, folder))}/`);
|
|
9276
9293
|
}
|
|
9277
9294
|
return { agents, problems, refused };
|
|
9278
9295
|
}
|
|
@@ -9336,7 +9353,7 @@ function readBundled(folder) {
|
|
|
9336
9353
|
function projectFolders(root2) {
|
|
9337
9354
|
let entries;
|
|
9338
9355
|
try {
|
|
9339
|
-
entries =
|
|
9356
|
+
entries = fs27.readdirSync(root2, { withFileTypes: true });
|
|
9340
9357
|
} catch {
|
|
9341
9358
|
return [];
|
|
9342
9359
|
}
|
|
@@ -9344,10 +9361,10 @@ function projectFolders(root2) {
|
|
|
9344
9361
|
}
|
|
9345
9362
|
function agentFileReader(dir) {
|
|
9346
9363
|
return (relative) => {
|
|
9347
|
-
const target =
|
|
9348
|
-
if (target !== dir && !target.startsWith(dir +
|
|
9364
|
+
const target = path31.resolve(dir, relative);
|
|
9365
|
+
if (target !== dir && !target.startsWith(dir + path31.sep)) return null;
|
|
9349
9366
|
try {
|
|
9350
|
-
return
|
|
9367
|
+
return fs27.readFileSync(target, "utf8");
|
|
9351
9368
|
} catch {
|
|
9352
9369
|
return null;
|
|
9353
9370
|
}
|
|
@@ -9356,22 +9373,22 @@ function agentFileReader(dir) {
|
|
|
9356
9373
|
function walkFolder(dir, prefix) {
|
|
9357
9374
|
let entries;
|
|
9358
9375
|
try {
|
|
9359
|
-
entries =
|
|
9376
|
+
entries = fs27.readdirSync(dir, { withFileTypes: true });
|
|
9360
9377
|
} catch {
|
|
9361
9378
|
return [];
|
|
9362
9379
|
}
|
|
9363
9380
|
return entries.flatMap((e2) => {
|
|
9364
9381
|
const here = prefix ? `${prefix}/${e2.name}` : e2.name;
|
|
9365
|
-
return e2.isDirectory() ? walkFolder(
|
|
9382
|
+
return e2.isDirectory() ? walkFolder(path31.join(dir, e2.name), here) : [here];
|
|
9366
9383
|
});
|
|
9367
9384
|
}
|
|
9368
9385
|
function readProject(root2, folder) {
|
|
9369
|
-
const dir =
|
|
9386
|
+
const dir = path31.join(root2, folder);
|
|
9370
9387
|
const file = agentFileReader(dir);
|
|
9371
9388
|
const found2 = AGENT_FILES.map((name) => ({ name, text: file(name) })).find((f2) => f2.text !== null);
|
|
9372
|
-
const missing = rel(
|
|
9389
|
+
const missing = rel(path31.join(dir, AGENT_FILE));
|
|
9373
9390
|
if (!found2) return { problem: `${missing} is missing`, file: missing, missing: true };
|
|
9374
|
-
const from = rel(
|
|
9391
|
+
const from = rel(path31.join(dir, found2.name));
|
|
9375
9392
|
const read5 = parseSpecAgent(found2.text, from, file, false, () => ownFiles(walkFolder(dir, "")));
|
|
9376
9393
|
if ("problem" in read5) return { ...read5, file: from };
|
|
9377
9394
|
if ("agent" in read5) Object.assign(read5.agent, { dir, text: found2.text });
|
|
@@ -9397,8 +9414,8 @@ var init_catalog = __esm({
|
|
|
9397
9414
|
});
|
|
9398
9415
|
|
|
9399
9416
|
// ../cli/src/lib/agent/workflow-file.ts
|
|
9400
|
-
import
|
|
9401
|
-
import
|
|
9417
|
+
import fs28 from "node:fs";
|
|
9418
|
+
import path32 from "node:path";
|
|
9402
9419
|
function agentLines2(agents, indent2) {
|
|
9403
9420
|
return agents.flatMap(
|
|
9404
9421
|
(h3) => !h3.extra && !h3.off ? [`${indent2}- ${scalar(h3.agent)}`] : [
|
|
@@ -9434,12 +9451,12 @@ function draftId() {
|
|
|
9434
9451
|
const task = workspaceTask();
|
|
9435
9452
|
if (!task) return null;
|
|
9436
9453
|
const id = draftFolder(task);
|
|
9437
|
-
return
|
|
9454
|
+
return fs28.existsSync(fileOf(id)) ? id : null;
|
|
9438
9455
|
}
|
|
9439
9456
|
function readFolder(id, problems) {
|
|
9440
9457
|
let source;
|
|
9441
9458
|
try {
|
|
9442
|
-
source =
|
|
9459
|
+
source = fs28.readFileSync(fileOf(id), "utf8");
|
|
9443
9460
|
} catch {
|
|
9444
9461
|
problems.push(`${rel(fileOf(id))} is missing`);
|
|
9445
9462
|
return null;
|
|
@@ -9460,8 +9477,8 @@ function boardWorkflowDefs() {
|
|
|
9460
9477
|
}
|
|
9461
9478
|
function writeWorkflowDef(def) {
|
|
9462
9479
|
const file = fileOf(def.id);
|
|
9463
|
-
|
|
9464
|
-
|
|
9480
|
+
fs28.mkdirSync(path32.dirname(file), { recursive: true });
|
|
9481
|
+
fs28.writeFileSync(file, workflowFileText(def));
|
|
9465
9482
|
forgetFileMemos();
|
|
9466
9483
|
}
|
|
9467
9484
|
var WORKFLOW_FILE2, scalar, plain, flowList, builtinDefs, fileOf;
|
|
@@ -9481,13 +9498,13 @@ var init_workflow_file = __esm({
|
|
|
9481
9498
|
plain = (agents) => agents.every((h3) => !h3.extra && !h3.off);
|
|
9482
9499
|
flowList = (agents) => `[${agents.map((h3) => scalar(h3.agent)).join(", ")}]`;
|
|
9483
9500
|
builtinDefs = () => cloudFlows().filter((f2) => f2.builtIn).map((f2) => f2.def);
|
|
9484
|
-
fileOf = (id) =>
|
|
9501
|
+
fileOf = (id) => path32.join(WORKFLOWS, id, WORKFLOW_FILE2);
|
|
9485
9502
|
}
|
|
9486
9503
|
});
|
|
9487
9504
|
|
|
9488
9505
|
// ../cli/src/lib/agent/workflows.ts
|
|
9489
|
-
import
|
|
9490
|
-
import
|
|
9506
|
+
import fs29 from "node:fs";
|
|
9507
|
+
import path33 from "node:path";
|
|
9491
9508
|
function workflowPurpose(flow) {
|
|
9492
9509
|
if (flow.builtIn) return builtinDescription(flow.id) || flow.name;
|
|
9493
9510
|
return boardWorkflowDefs().defs.find((d2) => d2.id === flow.id)?.description || flow.name;
|
|
@@ -9561,7 +9578,7 @@ function previewStages(flow, chosen) {
|
|
|
9561
9578
|
}
|
|
9562
9579
|
function userWorkflowRules(flow) {
|
|
9563
9580
|
try {
|
|
9564
|
-
return
|
|
9581
|
+
return fs29.readFileSync(workflowRuleFile(flow.id), "utf8").trim();
|
|
9565
9582
|
} catch {
|
|
9566
9583
|
return "";
|
|
9567
9584
|
}
|
|
@@ -9696,8 +9713,8 @@ function cardMeta(id) {
|
|
|
9696
9713
|
try {
|
|
9697
9714
|
const found2 = locate(id) ?? locateArchived(id);
|
|
9698
9715
|
if (!found2) return null;
|
|
9699
|
-
const file = found2.kind === "group" ?
|
|
9700
|
-
return parseFrontmatter(
|
|
9716
|
+
const file = found2.kind === "group" ? path33.join(found2.target, "root.md") : found2.target;
|
|
9717
|
+
return parseFrontmatter(fs29.readFileSync(file, "utf8")).meta;
|
|
9701
9718
|
} catch {
|
|
9702
9719
|
return null;
|
|
9703
9720
|
}
|
|
@@ -9787,7 +9804,7 @@ var init_workflows = __esm({
|
|
|
9787
9804
|
previewAgents = (flow) => previewMembers(flow).filter((h3) => !h3.off);
|
|
9788
9805
|
landAgents = (flow) => flow.land.filter((h3) => !h3.off);
|
|
9789
9806
|
archivesOnApproval = (flow) => !!flow && !landAgents(flow).length;
|
|
9790
|
-
workflowRuleFile = (id) =>
|
|
9807
|
+
workflowRuleFile = (id) => path33.join(RULES, "workflows", `${id}.md`);
|
|
9791
9808
|
save2 = (change2) => writeConfig((cfg) => {
|
|
9792
9809
|
const block = configBlock(cfg.workflows);
|
|
9793
9810
|
change2(block);
|
|
@@ -9810,11 +9827,11 @@ var init_workflows = __esm({
|
|
|
9810
9827
|
});
|
|
9811
9828
|
|
|
9812
9829
|
// ../cli/src/commands/goal.ts
|
|
9813
|
-
import
|
|
9830
|
+
import fs30 from "node:fs";
|
|
9814
9831
|
function loadGoals() {
|
|
9815
9832
|
const file = goalsFile();
|
|
9816
9833
|
if (!file) die("Goals exist only inside a WildCrane goal discussion.");
|
|
9817
|
-
const held4 = JSON.parse(
|
|
9834
|
+
const held4 = JSON.parse(fs30.readFileSync(file, "utf8"));
|
|
9818
9835
|
if (held4.goals !== void 0 && held4.ideas !== void 0 && JSON.stringify(held4.goals) !== JSON.stringify(held4.ideas)) die("goals and ideas do not match.");
|
|
9819
9836
|
const goals = held4.goals ?? held4.ideas;
|
|
9820
9837
|
if (!Array.isArray(goals)) die("The goals array is missing or invalid.");
|
|
@@ -9844,7 +9861,7 @@ function splitBody2(text5) {
|
|
|
9844
9861
|
}
|
|
9845
9862
|
function readBody(bodyFile) {
|
|
9846
9863
|
if (!bodyFile) die("--body-file is required; write the goal in a writable temporary file first.");
|
|
9847
|
-
const text5 =
|
|
9864
|
+
const text5 = fs30.readFileSync(bodyFile, "utf8");
|
|
9848
9865
|
if (!text5.trim()) die("The goal must not be empty.");
|
|
9849
9866
|
return splitBody2(text5);
|
|
9850
9867
|
}
|
|
@@ -9856,7 +9873,7 @@ function named(held4, id) {
|
|
|
9856
9873
|
function cmdGoal(args, opts) {
|
|
9857
9874
|
const sub = args[0] ?? "";
|
|
9858
9875
|
const { file, held: held4 } = loadGoals();
|
|
9859
|
-
const write2 = () =>
|
|
9876
|
+
const write2 = () => fs30.writeFileSync(file, `${JSON.stringify({ ...held4, goals: void 0, ideas: held4.goals }, null, 2)}
|
|
9860
9877
|
`);
|
|
9861
9878
|
if (sub === "new") {
|
|
9862
9879
|
const title = opts.title?.trim();
|
|
@@ -9944,12 +9961,12 @@ var init_goal = __esm({
|
|
|
9944
9961
|
});
|
|
9945
9962
|
|
|
9946
9963
|
// ../cli/src/commands/goal-cloud.ts
|
|
9947
|
-
import
|
|
9964
|
+
import fs31 from "node:fs";
|
|
9948
9965
|
import os4 from "node:os";
|
|
9949
|
-
import
|
|
9966
|
+
import path34 from "node:path";
|
|
9950
9967
|
import crypto3 from "node:crypto";
|
|
9951
9968
|
async function request(method, route2, body) {
|
|
9952
|
-
if (externalGoalSession()) process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME ||
|
|
9969
|
+
if (externalGoalSession()) process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME || path34.join(os4.homedir(), ".wildcrane");
|
|
9953
9970
|
const token3 = await accessToken();
|
|
9954
9971
|
if (!token3.ok) die("Sign in through the WildCrane plugin, then try again.");
|
|
9955
9972
|
const response = await fetch(`${cloudEndpoints().api}${route2}`, {
|
|
@@ -9981,23 +9998,23 @@ function goalsOf(d2) {
|
|
|
9981
9998
|
async function discussion() {
|
|
9982
9999
|
const session = process.env.CLAUDE_CODE_SESSION_ID || process.env.CODEX_THREAD_ID;
|
|
9983
10000
|
if (!session) die("Goals exist only inside a WildCrane goal discussion.");
|
|
9984
|
-
const home3 = process.env.WILDCRANE_HOME ||
|
|
10001
|
+
const home3 = process.env.WILDCRANE_HOME || path34.join(os4.homedir(), ".wildcrane");
|
|
9985
10002
|
process.env.AI4KANBAN_HOME ??= home3;
|
|
9986
|
-
const machineFile2 =
|
|
10003
|
+
const machineFile2 = path34.join(home3, "machine.json");
|
|
9987
10004
|
let machine;
|
|
9988
10005
|
try {
|
|
9989
|
-
machine = JSON.parse(
|
|
10006
|
+
machine = JSON.parse(fs31.readFileSync(machineFile2, "utf8")).id;
|
|
9990
10007
|
} catch {
|
|
9991
10008
|
machine = crypto3.randomUUID();
|
|
9992
|
-
|
|
9993
|
-
|
|
10009
|
+
fs31.mkdirSync(home3, { recursive: true });
|
|
10010
|
+
fs31.writeFileSync(machineFile2, JSON.stringify({ id: machine }));
|
|
9994
10011
|
}
|
|
9995
10012
|
const held4 = await request("GET", `/v1/runner/folders?machine=${encodeURIComponent(machine)}`);
|
|
9996
|
-
const cwd =
|
|
10013
|
+
const cwd = fs31.realpathSync(process.cwd());
|
|
9997
10014
|
const folder = held4.folders.filter((f2) => {
|
|
9998
10015
|
try {
|
|
9999
|
-
const dir =
|
|
10000
|
-
return cwd === dir || cwd.startsWith(dir +
|
|
10016
|
+
const dir = fs31.realpathSync(f2.path);
|
|
10017
|
+
return cwd === dir || cwd.startsWith(dir + path34.sep);
|
|
10001
10018
|
} catch {
|
|
10002
10019
|
return false;
|
|
10003
10020
|
}
|
|
@@ -10006,16 +10023,16 @@ async function discussion() {
|
|
|
10006
10023
|
}
|
|
10007
10024
|
async function withGoalDiscussion(action, save3 = false) {
|
|
10008
10025
|
const d2 = await discussion();
|
|
10009
|
-
const dir =
|
|
10010
|
-
const file =
|
|
10026
|
+
const dir = fs31.mkdtempSync(path34.join(os4.tmpdir(), "akb-goals-"));
|
|
10027
|
+
const file = path34.join(dir, "goals.json");
|
|
10011
10028
|
const before = process.env.KANBAN_GOALS;
|
|
10012
10029
|
try {
|
|
10013
10030
|
const previous = goalsOf(d2);
|
|
10014
|
-
|
|
10031
|
+
fs31.writeFileSync(file, JSON.stringify({ workspace: d2.workspace, workflows: await workflows2(d2.workspace), ideas: previous.map((g3) => ({ ...g3, task: typeof g3.task === "object" && g3.task ? g3.task.id : g3.task })) }));
|
|
10015
10032
|
process.env.KANBAN_GOALS = file;
|
|
10016
10033
|
const result = save3 ? await quietlyAsync(async () => action()) : await action();
|
|
10017
10034
|
if (save3) {
|
|
10018
|
-
const goals = JSON.parse(
|
|
10035
|
+
const goals = JSON.parse(fs31.readFileSync(file, "utf8")).ideas;
|
|
10019
10036
|
const saved = await request("PUT", `/v1/discussions/${d2.id}/draft`, { expectedVersion: d2.version, goals: goals.filter((g3) => !g3.dropped) });
|
|
10020
10037
|
const savedGoals = goalsOf(saved);
|
|
10021
10038
|
const fresh = goals.filter((g3) => !g3.dropped && !previous.some((p2) => p2.id === g3.id));
|
|
@@ -10034,7 +10051,7 @@ async function withGoalDiscussion(action, save3 = false) {
|
|
|
10034
10051
|
} finally {
|
|
10035
10052
|
if (before === void 0) delete process.env.KANBAN_GOALS;
|
|
10036
10053
|
else process.env.KANBAN_GOALS = before;
|
|
10037
|
-
|
|
10054
|
+
fs31.rmSync(dir, { recursive: true, force: true });
|
|
10038
10055
|
}
|
|
10039
10056
|
}
|
|
10040
10057
|
async function queryPreviews(workflow, workspace) {
|
|
@@ -11183,8 +11200,8 @@ var require_command = __commonJS({
|
|
|
11183
11200
|
"../cli/node_modules/commander/lib/command.js"(exports) {
|
|
11184
11201
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
11185
11202
|
var childProcess = __require("node:child_process");
|
|
11186
|
-
var
|
|
11187
|
-
var
|
|
11203
|
+
var path90 = __require("node:path");
|
|
11204
|
+
var fs92 = __require("node:fs");
|
|
11188
11205
|
var process2 = __require("node:process");
|
|
11189
11206
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
11190
11207
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -12165,7 +12182,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
12165
12182
|
* @param {string} subcommandName
|
|
12166
12183
|
*/
|
|
12167
12184
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
12168
|
-
if (
|
|
12185
|
+
if (fs92.existsSync(executableFile)) return;
|
|
12169
12186
|
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";
|
|
12170
12187
|
const executableMissing = `'${executableFile}' does not exist
|
|
12171
12188
|
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
@@ -12183,11 +12200,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
12183
12200
|
let launchWithNode = false;
|
|
12184
12201
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
12185
12202
|
function findFile(baseDir, baseName) {
|
|
12186
|
-
const localBin =
|
|
12187
|
-
if (
|
|
12188
|
-
if (sourceExt.includes(
|
|
12203
|
+
const localBin = path90.resolve(baseDir, baseName);
|
|
12204
|
+
if (fs92.existsSync(localBin)) return localBin;
|
|
12205
|
+
if (sourceExt.includes(path90.extname(baseName))) return void 0;
|
|
12189
12206
|
const foundExt = sourceExt.find(
|
|
12190
|
-
(ext) =>
|
|
12207
|
+
(ext) => fs92.existsSync(`${localBin}${ext}`)
|
|
12191
12208
|
);
|
|
12192
12209
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
12193
12210
|
return void 0;
|
|
@@ -12199,21 +12216,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
12199
12216
|
if (this._scriptPath) {
|
|
12200
12217
|
let resolvedScriptPath;
|
|
12201
12218
|
try {
|
|
12202
|
-
resolvedScriptPath =
|
|
12219
|
+
resolvedScriptPath = fs92.realpathSync(this._scriptPath);
|
|
12203
12220
|
} catch {
|
|
12204
12221
|
resolvedScriptPath = this._scriptPath;
|
|
12205
12222
|
}
|
|
12206
|
-
executableDir =
|
|
12207
|
-
|
|
12223
|
+
executableDir = path90.resolve(
|
|
12224
|
+
path90.dirname(resolvedScriptPath),
|
|
12208
12225
|
executableDir
|
|
12209
12226
|
);
|
|
12210
12227
|
}
|
|
12211
12228
|
if (executableDir) {
|
|
12212
12229
|
let localFile = findFile(executableDir, executableFile);
|
|
12213
12230
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
12214
|
-
const legacyName =
|
|
12231
|
+
const legacyName = path90.basename(
|
|
12215
12232
|
this._scriptPath,
|
|
12216
|
-
|
|
12233
|
+
path90.extname(this._scriptPath)
|
|
12217
12234
|
);
|
|
12218
12235
|
if (legacyName !== this._name) {
|
|
12219
12236
|
localFile = findFile(
|
|
@@ -12224,7 +12241,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
12224
12241
|
}
|
|
12225
12242
|
executableFile = localFile || executableFile;
|
|
12226
12243
|
}
|
|
12227
|
-
launchWithNode = sourceExt.includes(
|
|
12244
|
+
launchWithNode = sourceExt.includes(path90.extname(executableFile));
|
|
12228
12245
|
let proc;
|
|
12229
12246
|
if (process2.platform !== "win32") {
|
|
12230
12247
|
if (launchWithNode) {
|
|
@@ -13071,7 +13088,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13071
13088
|
* @return {Command}
|
|
13072
13089
|
*/
|
|
13073
13090
|
nameFromFilename(filename) {
|
|
13074
|
-
this._name =
|
|
13091
|
+
this._name = path90.basename(filename, path90.extname(filename));
|
|
13075
13092
|
return this;
|
|
13076
13093
|
}
|
|
13077
13094
|
/**
|
|
@@ -13085,9 +13102,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
13085
13102
|
* @param {string} [path]
|
|
13086
13103
|
* @return {(string|null|Command)}
|
|
13087
13104
|
*/
|
|
13088
|
-
executableDir(
|
|
13089
|
-
if (
|
|
13090
|
-
this._executableDir =
|
|
13105
|
+
executableDir(path91) {
|
|
13106
|
+
if (path91 === void 0) return this._executableDir;
|
|
13107
|
+
this._executableDir = path91;
|
|
13091
13108
|
return this;
|
|
13092
13109
|
}
|
|
13093
13110
|
/**
|
|
@@ -13384,11 +13401,11 @@ var init_esm = __esm({
|
|
|
13384
13401
|
});
|
|
13385
13402
|
|
|
13386
13403
|
// ../cli/src/lib/cloud/pointer.ts
|
|
13387
|
-
import
|
|
13388
|
-
import
|
|
13404
|
+
import fs32 from "node:fs";
|
|
13405
|
+
import path35 from "node:path";
|
|
13389
13406
|
function hasRetiredPointer(root2) {
|
|
13390
13407
|
try {
|
|
13391
|
-
const held4 = JSON.parse(
|
|
13408
|
+
const held4 = JSON.parse(fs32.readFileSync(path35.join(root2, POINTER_FILE), "utf8"));
|
|
13392
13409
|
return typeof held4.workspace === "string" && held4.workspace.trim() !== "";
|
|
13393
13410
|
} catch {
|
|
13394
13411
|
return false;
|
|
@@ -13403,15 +13420,15 @@ var init_pointer = __esm({
|
|
|
13403
13420
|
});
|
|
13404
13421
|
|
|
13405
13422
|
// ../cli/src/lib/card-workflow-backfill.ts
|
|
13406
|
-
import
|
|
13407
|
-
import
|
|
13423
|
+
import fs33 from "node:fs";
|
|
13424
|
+
import path36 from "node:path";
|
|
13408
13425
|
function backfillCardWorkflows() {
|
|
13409
13426
|
if (!TODO || !BOARD_STATE) return;
|
|
13410
|
-
const mark =
|
|
13427
|
+
const mark = path36.join(BOARD_STATE, MARK);
|
|
13411
13428
|
try {
|
|
13412
|
-
if (
|
|
13429
|
+
if (fs33.existsSync(mark) || !fs33.existsSync(TODO)) return;
|
|
13413
13430
|
for (const file of walkMd(TODO)) {
|
|
13414
|
-
const text5 =
|
|
13431
|
+
const text5 = fs33.readFileSync(file, "utf8");
|
|
13415
13432
|
if (!text5.startsWith("---\n")) continue;
|
|
13416
13433
|
const end2 = text5.indexOf("\n---", 3);
|
|
13417
13434
|
if (end2 < 0) continue;
|
|
@@ -13419,11 +13436,11 @@ function backfillCardWorkflows() {
|
|
|
13419
13436
|
if (!/\ntitle:/.test(head2) || /\nworkflow:/.test(head2)) continue;
|
|
13420
13437
|
const modules = /\nmodules:[^\n]*/.exec(head2);
|
|
13421
13438
|
const at2 = modules ? modules.index + modules[0].length : end2;
|
|
13422
|
-
|
|
13439
|
+
fs33.writeFileSync(file, `${text5.slice(0, at2)}
|
|
13423
13440
|
workflow: coding${text5.slice(at2)}`);
|
|
13424
13441
|
}
|
|
13425
|
-
|
|
13426
|
-
|
|
13442
|
+
fs33.mkdirSync(BOARD_STATE, { recursive: true });
|
|
13443
|
+
fs33.writeFileSync(mark, "");
|
|
13427
13444
|
} catch {
|
|
13428
13445
|
}
|
|
13429
13446
|
}
|
|
@@ -13438,11 +13455,11 @@ var init_card_workflow_backfill = __esm({
|
|
|
13438
13455
|
});
|
|
13439
13456
|
|
|
13440
13457
|
// ../cli/src/lib/view/stamp.ts
|
|
13441
|
-
import
|
|
13442
|
-
import
|
|
13458
|
+
import fs34 from "node:fs";
|
|
13459
|
+
import path37 from "node:path";
|
|
13443
13460
|
function boardStamp() {
|
|
13444
13461
|
const parts = [];
|
|
13445
|
-
for (const dir of [TODO, MEMORY, ASSETS, MOCKUPS,
|
|
13462
|
+
for (const dir of [TODO, MEMORY, ASSETS, MOCKUPS, path37.join(KANBAN, ".mockups")]) walk(dir, parts, 0);
|
|
13446
13463
|
for (const file of [MODULES_MD, ARCHIVE_MD, CONFIG]) {
|
|
13447
13464
|
stamp2(file, parts);
|
|
13448
13465
|
}
|
|
@@ -13452,19 +13469,19 @@ function walk(dir, parts, depth3) {
|
|
|
13452
13469
|
if (depth3 > MAX_DEPTH) return;
|
|
13453
13470
|
let entries;
|
|
13454
13471
|
try {
|
|
13455
|
-
entries =
|
|
13472
|
+
entries = fs34.readdirSync(dir, { withFileTypes: true });
|
|
13456
13473
|
} catch {
|
|
13457
13474
|
return;
|
|
13458
13475
|
}
|
|
13459
13476
|
for (const entry of entries.sort((a2, b2) => a2.name.localeCompare(b2.name))) {
|
|
13460
|
-
const full =
|
|
13477
|
+
const full = path37.join(dir, entry.name);
|
|
13461
13478
|
if (entry.isDirectory()) walk(full, parts, depth3 + 1);
|
|
13462
13479
|
else stamp2(full, parts);
|
|
13463
13480
|
}
|
|
13464
13481
|
}
|
|
13465
13482
|
function stamp2(file, parts) {
|
|
13466
13483
|
try {
|
|
13467
|
-
const s =
|
|
13484
|
+
const s = fs34.statSync(file);
|
|
13468
13485
|
parts.push(`${file}:${s.size}:${Math.round(s.mtimeMs)}`);
|
|
13469
13486
|
} catch {
|
|
13470
13487
|
}
|
|
@@ -13496,8 +13513,8 @@ var init_contract = __esm({
|
|
|
13496
13513
|
});
|
|
13497
13514
|
|
|
13498
13515
|
// ../cli/src/lib/board/revision.ts
|
|
13499
|
-
import
|
|
13500
|
-
import
|
|
13516
|
+
import fs35 from "node:fs";
|
|
13517
|
+
import path38 from "node:path";
|
|
13501
13518
|
function revisionOf(text5) {
|
|
13502
13519
|
let h3 = 2166136261;
|
|
13503
13520
|
for (let i = 0; i < text5.length; i++) {
|
|
@@ -13509,13 +13526,13 @@ function revisionOf(text5) {
|
|
|
13509
13526
|
function cardFile(id) {
|
|
13510
13527
|
const found2 = locate(id);
|
|
13511
13528
|
if (!found2) return null;
|
|
13512
|
-
return found2.kind === "group" ?
|
|
13529
|
+
return found2.kind === "group" ? path38.join(found2.target, "root.md") : found2.target;
|
|
13513
13530
|
}
|
|
13514
13531
|
function cardRevision(id) {
|
|
13515
13532
|
const file = cardFile(id);
|
|
13516
13533
|
if (!file) return NO_REVISION;
|
|
13517
13534
|
try {
|
|
13518
|
-
return revisionOf(
|
|
13535
|
+
return revisionOf(fs35.readFileSync(file, "utf8"));
|
|
13519
13536
|
} catch {
|
|
13520
13537
|
return NO_REVISION;
|
|
13521
13538
|
}
|
|
@@ -13537,14 +13554,14 @@ var init_revision = __esm({
|
|
|
13537
13554
|
});
|
|
13538
13555
|
|
|
13539
13556
|
// ../cli/src/lib/plans.ts
|
|
13540
|
-
import
|
|
13541
|
-
import
|
|
13557
|
+
import fs36 from "node:fs";
|
|
13558
|
+
import path39 from "node:path";
|
|
13542
13559
|
function planFile(rel2) {
|
|
13543
13560
|
if (!/^plans\/(archive\/)?[^/\\]+\.md$/.test(rel2)) return null;
|
|
13544
13561
|
const dir = isArchivedPlan(rel2) ? PLANS_ARCHIVE : PLANS;
|
|
13545
13562
|
const name = rel2.replace(/^plans\/(archive\/)?/, "");
|
|
13546
13563
|
if (!name || name.includes("/") || !name.endsWith(".md")) return null;
|
|
13547
|
-
return
|
|
13564
|
+
return path39.join(dir, name);
|
|
13548
13565
|
}
|
|
13549
13566
|
function readPlan(rel2) {
|
|
13550
13567
|
const file = planFile(rel2);
|
|
@@ -13552,12 +13569,12 @@ function readPlan(rel2) {
|
|
|
13552
13569
|
let text5 = "";
|
|
13553
13570
|
let found2 = rel2;
|
|
13554
13571
|
try {
|
|
13555
|
-
text5 =
|
|
13572
|
+
text5 = fs36.readFileSync(file, "utf8");
|
|
13556
13573
|
} catch {
|
|
13557
13574
|
const moved = renamedPlan(rel2);
|
|
13558
13575
|
if (moved) {
|
|
13559
13576
|
found2 = moved;
|
|
13560
|
-
text5 =
|
|
13577
|
+
text5 = fs36.readFileSync(planFile(moved), "utf8");
|
|
13561
13578
|
}
|
|
13562
13579
|
}
|
|
13563
13580
|
return { path: found2, text: text5, lines: text5.trim() ? text5.trimEnd().split("\n").length : 0 };
|
|
@@ -13572,13 +13589,13 @@ function renamedPlan(rel2) {
|
|
|
13572
13589
|
]) {
|
|
13573
13590
|
let names3;
|
|
13574
13591
|
try {
|
|
13575
|
-
names3 =
|
|
13592
|
+
names3 = fs36.readdirSync(dir);
|
|
13576
13593
|
} catch {
|
|
13577
13594
|
continue;
|
|
13578
13595
|
}
|
|
13579
13596
|
for (const n of names3) {
|
|
13580
13597
|
if (!n.startsWith(`${id}-`) || !n.endsWith(".md")) continue;
|
|
13581
|
-
found2.push({ rel: `${prefix}${n}`, at:
|
|
13598
|
+
found2.push({ rel: `${prefix}${n}`, at: fs36.statSync(path39.join(dir, n)).mtimeMs });
|
|
13582
13599
|
}
|
|
13583
13600
|
}
|
|
13584
13601
|
if (!found2.length) return null;
|
|
@@ -13587,7 +13604,7 @@ function renamedPlan(rel2) {
|
|
|
13587
13604
|
function planFromText(text5) {
|
|
13588
13605
|
const legacy2 = `${legacyProjectStateDir(KANBAN)}/`;
|
|
13589
13606
|
if (text5.startsWith(legacy2)) text5 = text5.slice(legacy2.length);
|
|
13590
|
-
const local = `${
|
|
13607
|
+
const local = `${path39.dirname(PLANS)}/`;
|
|
13591
13608
|
if (text5.startsWith(local)) text5 = text5.slice(local.length);
|
|
13592
13609
|
if (text5.startsWith(`${KANBAN}/`)) text5 = text5.slice(KANBAN.length + 1);
|
|
13593
13610
|
const here = `${boardPath()}/`;
|
|
@@ -13715,23 +13732,23 @@ var init_telemetry_contract = __esm({
|
|
|
13715
13732
|
});
|
|
13716
13733
|
|
|
13717
13734
|
// ../cli/src/lib/agent/catalog.ts
|
|
13718
|
-
import
|
|
13719
|
-
import
|
|
13735
|
+
import fs37 from "node:fs";
|
|
13736
|
+
import path40 from "node:path";
|
|
13720
13737
|
function cacheFile() {
|
|
13721
|
-
return
|
|
13738
|
+
return path40.join(machineHome(), "models-dev.json");
|
|
13722
13739
|
}
|
|
13723
13740
|
function readCache() {
|
|
13724
13741
|
const file = cacheFile();
|
|
13725
13742
|
let stamp4;
|
|
13726
13743
|
try {
|
|
13727
|
-
const stat =
|
|
13744
|
+
const stat = fs37.statSync(file);
|
|
13728
13745
|
stamp4 = `${stat.mtimeMs}:${stat.size}`;
|
|
13729
13746
|
} catch {
|
|
13730
13747
|
return void 0;
|
|
13731
13748
|
}
|
|
13732
13749
|
if (held2?.stamp === stamp4) return held2.cached;
|
|
13733
13750
|
try {
|
|
13734
|
-
const data = JSON.parse(
|
|
13751
|
+
const data = JSON.parse(fs37.readFileSync(file, "utf8"));
|
|
13735
13752
|
if (!data || typeof data.limits !== "object" || !data.limits) return void 0;
|
|
13736
13753
|
const cached2 = {
|
|
13737
13754
|
fetchedAt: typeof data.fetchedAt === "number" ? data.fetchedAt : 0,
|
|
@@ -13769,8 +13786,8 @@ function refreshCatalog() {
|
|
|
13769
13786
|
const limits = limitsIn(await answer2.json());
|
|
13770
13787
|
if (Object.keys(limits).length === 0) return;
|
|
13771
13788
|
const file = cacheFile();
|
|
13772
|
-
|
|
13773
|
-
|
|
13789
|
+
fs37.mkdirSync(path40.dirname(file), { recursive: true });
|
|
13790
|
+
fs37.writeFileSync(file, JSON.stringify({ fetchedAt: Date.now(), limits }));
|
|
13774
13791
|
} catch {
|
|
13775
13792
|
}
|
|
13776
13793
|
})();
|
|
@@ -13833,8 +13850,8 @@ var init_catalog2 = __esm({
|
|
|
13833
13850
|
});
|
|
13834
13851
|
|
|
13835
13852
|
// ../cli/src/lib/machine/telemetry.ts
|
|
13836
|
-
import
|
|
13837
|
-
import
|
|
13853
|
+
import fs38 from "node:fs";
|
|
13854
|
+
import path41 from "node:path";
|
|
13838
13855
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
13839
13856
|
function readUsageReporting() {
|
|
13840
13857
|
const { unreadable, values } = heldSettings();
|
|
@@ -13868,8 +13885,8 @@ function write(on2, disclosed) {
|
|
|
13868
13885
|
if (!on2) patch2.usageInstallId = void 0;
|
|
13869
13886
|
const saved = saveSettings(patch2);
|
|
13870
13887
|
if (saved.ok && !on2) {
|
|
13871
|
-
|
|
13872
|
-
|
|
13888
|
+
fs38.rmSync(usageQueueFile(), { force: true });
|
|
13889
|
+
fs38.rmSync(usageStateFile(), { force: true });
|
|
13873
13890
|
}
|
|
13874
13891
|
return saved;
|
|
13875
13892
|
}
|
|
@@ -13879,14 +13896,14 @@ var init_telemetry = __esm({
|
|
|
13879
13896
|
"use strict";
|
|
13880
13897
|
init_home();
|
|
13881
13898
|
init_settings2();
|
|
13882
|
-
usageQueueFile = () =>
|
|
13883
|
-
usageStateFile = () =>
|
|
13899
|
+
usageQueueFile = () => path41.join(machineHome(), "usage-queue.jsonl");
|
|
13900
|
+
usageStateFile = () => path41.join(machineHome(), "usage-state.json");
|
|
13884
13901
|
}
|
|
13885
13902
|
});
|
|
13886
13903
|
|
|
13887
13904
|
// ../cli/src/lib/machine/usage.ts
|
|
13888
|
-
import
|
|
13889
|
-
import
|
|
13905
|
+
import fs39 from "node:fs";
|
|
13906
|
+
import path42 from "node:path";
|
|
13890
13907
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
13891
13908
|
function usageSurface() {
|
|
13892
13909
|
return process.env.KANBAN_DESKTOP === "1" ? "app" : "command";
|
|
@@ -13963,15 +13980,15 @@ function endFields({ model, costUsd, ownEndpoint }) {
|
|
|
13963
13980
|
}
|
|
13964
13981
|
function readBoard() {
|
|
13965
13982
|
try {
|
|
13966
|
-
const held4 = JSON.parse(
|
|
13983
|
+
const held4 = JSON.parse(fs39.readFileSync(boardFile(), "utf8"));
|
|
13967
13984
|
return held4 && typeof held4 === "object" ? held4 : {};
|
|
13968
13985
|
} catch {
|
|
13969
13986
|
return {};
|
|
13970
13987
|
}
|
|
13971
13988
|
}
|
|
13972
13989
|
function writeBoard(state) {
|
|
13973
|
-
|
|
13974
|
-
|
|
13990
|
+
fs39.mkdirSync(BOARD_STATE, { recursive: true });
|
|
13991
|
+
fs39.writeFileSync(boardFile(), `${JSON.stringify(state)}
|
|
13975
13992
|
`);
|
|
13976
13993
|
}
|
|
13977
13994
|
function countBoardEvent(name, n = 1) {
|
|
@@ -14015,7 +14032,7 @@ function reportBoardNumbers(customAgentsOn2) {
|
|
|
14015
14032
|
function readQueue(day = usageDay()) {
|
|
14016
14033
|
let text5;
|
|
14017
14034
|
try {
|
|
14018
|
-
text5 =
|
|
14035
|
+
text5 = fs39.readFileSync(usageQueueFile(), "utf8");
|
|
14019
14036
|
} catch {
|
|
14020
14037
|
return [];
|
|
14021
14038
|
}
|
|
@@ -14037,8 +14054,8 @@ function readQueue(day = usageDay()) {
|
|
|
14037
14054
|
}
|
|
14038
14055
|
function append(event2) {
|
|
14039
14056
|
const file = usageQueueFile();
|
|
14040
|
-
|
|
14041
|
-
|
|
14057
|
+
fs39.mkdirSync(machineHome(), { recursive: true, mode: 448 });
|
|
14058
|
+
fs39.appendFileSync(file, `${JSON.stringify(event2)}
|
|
14042
14059
|
`);
|
|
14043
14060
|
const queued = readQueue();
|
|
14044
14061
|
if (queued.length > QUEUE_MAX) writeQueue(queued.slice(queued.length - QUEUE_MAX));
|
|
@@ -14046,14 +14063,14 @@ function append(event2) {
|
|
|
14046
14063
|
function writeQueue(events) {
|
|
14047
14064
|
const file = usageQueueFile();
|
|
14048
14065
|
if (!events.length) {
|
|
14049
|
-
|
|
14066
|
+
fs39.rmSync(file, { force: true });
|
|
14050
14067
|
return;
|
|
14051
14068
|
}
|
|
14052
|
-
|
|
14069
|
+
fs39.mkdirSync(machineHome(), { recursive: true, mode: 448 });
|
|
14053
14070
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
14054
|
-
|
|
14071
|
+
fs39.writeFileSync(tmp, `${events.map((e2) => JSON.stringify(e2)).join("\n")}
|
|
14055
14072
|
`);
|
|
14056
|
-
|
|
14073
|
+
fs39.renameSync(tmp, file);
|
|
14057
14074
|
}
|
|
14058
14075
|
function shiftDay(day, days) {
|
|
14059
14076
|
const at2 = Date.parse(`${day}T00:00:00Z`);
|
|
@@ -14061,7 +14078,7 @@ function shiftDay(day, days) {
|
|
|
14061
14078
|
}
|
|
14062
14079
|
function readState() {
|
|
14063
14080
|
try {
|
|
14064
|
-
const parsed = JSON.parse(
|
|
14081
|
+
const parsed = JSON.parse(fs39.readFileSync(usageStateFile(), "utf8"));
|
|
14065
14082
|
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
|
|
14066
14083
|
} catch {
|
|
14067
14084
|
return {};
|
|
@@ -14069,12 +14086,12 @@ function readState() {
|
|
|
14069
14086
|
}
|
|
14070
14087
|
function writeState(state) {
|
|
14071
14088
|
try {
|
|
14072
|
-
|
|
14089
|
+
fs39.mkdirSync(machineHome(), { recursive: true, mode: 448 });
|
|
14073
14090
|
const file = usageStateFile();
|
|
14074
14091
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
14075
|
-
|
|
14092
|
+
fs39.writeFileSync(tmp, `${JSON.stringify(state, null, 2)}
|
|
14076
14093
|
`);
|
|
14077
|
-
|
|
14094
|
+
fs39.renameSync(tmp, file);
|
|
14078
14095
|
} catch {
|
|
14079
14096
|
return;
|
|
14080
14097
|
}
|
|
@@ -14165,7 +14182,7 @@ var init_usage = __esm({
|
|
|
14165
14182
|
"decisions_stood",
|
|
14166
14183
|
"decisions_overruled"
|
|
14167
14184
|
];
|
|
14168
|
-
boardFile = () =>
|
|
14185
|
+
boardFile = () => path42.join(BOARD_STATE, "usage-board.json");
|
|
14169
14186
|
countOf = (counts, name) => {
|
|
14170
14187
|
const n = counts?.[name];
|
|
14171
14188
|
return typeof n === "number" && Number.isInteger(n) && n > 0 ? n : 0;
|
|
@@ -14212,14 +14229,14 @@ var init_candidate = __esm({
|
|
|
14212
14229
|
});
|
|
14213
14230
|
|
|
14214
14231
|
// ../cli/src/lib/agent/outputs.ts
|
|
14215
|
-
import
|
|
14232
|
+
import fs40 from "node:fs";
|
|
14216
14233
|
import os5 from "node:os";
|
|
14217
|
-
import
|
|
14234
|
+
import path43 from "node:path";
|
|
14218
14235
|
function cardBody(cardId2) {
|
|
14219
14236
|
const found2 = locate(cardId2) ?? locateArchived(cardId2);
|
|
14220
14237
|
if (!found2) return "";
|
|
14221
14238
|
try {
|
|
14222
|
-
return
|
|
14239
|
+
return fs40.readFileSync(found2.kind === "group" ? path43.join(found2.target, "root.md") : found2.target, "utf8");
|
|
14223
14240
|
} catch {
|
|
14224
14241
|
return "";
|
|
14225
14242
|
}
|
|
@@ -14242,7 +14259,7 @@ function filesStop(delivery) {
|
|
|
14242
14259
|
if (!outputs.length) {
|
|
14243
14260
|
return { reason: "output", why: "the card records no output file", paths: [] };
|
|
14244
14261
|
}
|
|
14245
|
-
const missing = outputs.filter((f2) => !
|
|
14262
|
+
const missing = outputs.filter((f2) => !fs40.existsSync(resolveOutput(f2)));
|
|
14246
14263
|
if (missing.length) {
|
|
14247
14264
|
return { reason: "output", why: `recorded output files are missing: ${missing.join(", ")}`, paths: missing };
|
|
14248
14265
|
}
|
|
@@ -14262,20 +14279,20 @@ var init_outputs = __esm({
|
|
|
14262
14279
|
plannedTodos = (cardId2) => todos(cardId2).map((t) => t.text);
|
|
14263
14280
|
looksLikePath = (token3) => !/\s/.test(token3) && !token3.includes("://") && !token3.startsWith("-") && token3.includes("/");
|
|
14264
14281
|
resolveOutput = (file) => {
|
|
14265
|
-
if (file.startsWith("~/")) return
|
|
14266
|
-
if (
|
|
14267
|
-
if (file.startsWith(".assets/")) return
|
|
14268
|
-
return
|
|
14282
|
+
if (file.startsWith("~/")) return path43.join(os5.homedir(), file.slice(2));
|
|
14283
|
+
if (path43.isAbsolute(file)) return file;
|
|
14284
|
+
if (file.startsWith(".assets/")) return path43.join(ASSETS, file.slice(".assets/".length));
|
|
14285
|
+
return path43.join(REPO_ROOT, file);
|
|
14269
14286
|
};
|
|
14270
14287
|
}
|
|
14271
14288
|
});
|
|
14272
14289
|
|
|
14273
14290
|
// ../cli/src/lib/agent/commit-mode.ts
|
|
14274
|
-
import
|
|
14291
|
+
import fs41 from "node:fs";
|
|
14275
14292
|
function recordedIds() {
|
|
14276
14293
|
try {
|
|
14277
14294
|
return new Set(
|
|
14278
|
-
|
|
14295
|
+
fs41.readdirSync(DELIVERIES).filter((f2) => f2.endsWith(".json")).map((f2) => f2.slice(0, -".json".length))
|
|
14279
14296
|
);
|
|
14280
14297
|
} catch {
|
|
14281
14298
|
return /* @__PURE__ */ new Set();
|
|
@@ -14308,7 +14325,7 @@ var init_commit_mode = __esm({
|
|
|
14308
14325
|
init_worktree();
|
|
14309
14326
|
ID_ALPHABET = "abcdefghjkmnpqrstuvwxyz23456789";
|
|
14310
14327
|
ID_LENGTH2 = 8;
|
|
14311
|
-
deliveryCwd = (delivery) => delivery.worktree &&
|
|
14328
|
+
deliveryCwd = (delivery) => delivery.worktree && fs41.existsSync(worktreeDir(delivery.worktree)) ? worktreeDir(delivery.worktree) : REPO_ROOT;
|
|
14312
14329
|
}
|
|
14313
14330
|
});
|
|
14314
14331
|
|
|
@@ -14504,12 +14521,12 @@ var init_runner = __esm({
|
|
|
14504
14521
|
});
|
|
14505
14522
|
|
|
14506
14523
|
// ../cli/src/lib/agent/rules.ts
|
|
14507
|
-
import
|
|
14508
|
-
import
|
|
14524
|
+
import fs42 from "node:fs";
|
|
14525
|
+
import path44 from "node:path";
|
|
14509
14526
|
function ruleFile(agent) {
|
|
14510
14527
|
if (!agent || hiddenRole(agent)) return "";
|
|
14511
14528
|
try {
|
|
14512
|
-
return
|
|
14529
|
+
return fs42.readFileSync(rulePath(agent), "utf8").trim();
|
|
14513
14530
|
} catch {
|
|
14514
14531
|
return "";
|
|
14515
14532
|
}
|
|
@@ -14524,11 +14541,11 @@ function setAgentRule(agent, text5) {
|
|
|
14524
14541
|
const rule = String(text5 ?? "").trim();
|
|
14525
14542
|
try {
|
|
14526
14543
|
if (!rule) {
|
|
14527
|
-
|
|
14544
|
+
fs42.rmSync(rulePath(agent), { force: true });
|
|
14528
14545
|
return { ok: true };
|
|
14529
14546
|
}
|
|
14530
|
-
|
|
14531
|
-
|
|
14547
|
+
fs42.mkdirSync(RULES, { recursive: true });
|
|
14548
|
+
fs42.writeFileSync(rulePath(agent), `${rule}
|
|
14532
14549
|
`);
|
|
14533
14550
|
return { ok: true };
|
|
14534
14551
|
} catch (err) {
|
|
@@ -14585,7 +14602,7 @@ function migrateFlowRules() {
|
|
|
14585
14602
|
adoptRenamedRules();
|
|
14586
14603
|
let here;
|
|
14587
14604
|
try {
|
|
14588
|
-
here = new Set(
|
|
14605
|
+
here = new Set(fs42.readdirSync(RULES));
|
|
14589
14606
|
} catch {
|
|
14590
14607
|
return [];
|
|
14591
14608
|
}
|
|
@@ -14599,9 +14616,9 @@ function migrateFlowRules() {
|
|
|
14599
14616
|
if (!from.length) continue;
|
|
14600
14617
|
const parts = [ruleFile(owner.name), ...from.map(ruleFile)].filter(Boolean);
|
|
14601
14618
|
try {
|
|
14602
|
-
if (parts.length)
|
|
14619
|
+
if (parts.length) fs42.writeFileSync(rulePath(owner.name), `${parts.join("\n\n")}
|
|
14603
14620
|
`);
|
|
14604
|
-
for (const flow of from)
|
|
14621
|
+
for (const flow of from) fs42.rmSync(rulePath(flow), { force: true });
|
|
14605
14622
|
} catch (err) {
|
|
14606
14623
|
notes.push(`could not move the ${from.join(", ")} rule(s) onto \`${owner.name}\`: ${String(err)}`);
|
|
14607
14624
|
continue;
|
|
@@ -14615,7 +14632,7 @@ function migrateFlowRules() {
|
|
|
14615
14632
|
function adoptRenamedRules() {
|
|
14616
14633
|
let here;
|
|
14617
14634
|
try {
|
|
14618
|
-
here =
|
|
14635
|
+
here = fs42.readdirSync(RULES);
|
|
14619
14636
|
} catch {
|
|
14620
14637
|
return;
|
|
14621
14638
|
}
|
|
@@ -14625,13 +14642,13 @@ function adoptRenamedRules() {
|
|
|
14625
14642
|
const now = RENAMED_ROLES[was] ?? canonicalSpecAgent(was);
|
|
14626
14643
|
if (now === was) continue;
|
|
14627
14644
|
try {
|
|
14628
|
-
if (!
|
|
14645
|
+
if (!fs42.existsSync(rulePath(now))) fs42.renameSync(rulePath(was), rulePath(now));
|
|
14629
14646
|
else if (FOLDED_SPEC_AGENTS.has(was)) {
|
|
14630
14647
|
const kept2 = ruleFile(now);
|
|
14631
14648
|
const carried = ruleFile(was);
|
|
14632
|
-
if (carried && !kept2.includes(carried))
|
|
14649
|
+
if (carried && !kept2.includes(carried)) fs42.writeFileSync(rulePath(now), `${[kept2, carried].filter(Boolean).join("\n\n")}
|
|
14633
14650
|
`);
|
|
14634
|
-
|
|
14651
|
+
fs42.rmSync(rulePath(was), { force: true });
|
|
14635
14652
|
}
|
|
14636
14653
|
} catch {
|
|
14637
14654
|
}
|
|
@@ -14648,7 +14665,7 @@ var init_rules2 = __esm({
|
|
|
14648
14665
|
init_runner();
|
|
14649
14666
|
init_workflows();
|
|
14650
14667
|
init_types();
|
|
14651
|
-
rulePath = (agent) =>
|
|
14668
|
+
rulePath = (agent) => path44.join(RULES, `${agent}.md`);
|
|
14652
14669
|
notOnTheRoster = (name) => `"${name}" is not an agent on this board. It has: ${agentNames().join(", ")}.`;
|
|
14653
14670
|
flowForRequest = (req) => req.refineRound !== void 0 && REFINE_ACTIONS.has(req.action) ? flowByCommand("refine") : flowByAction(req.action);
|
|
14654
14671
|
ruleOwnerSays = (owner) => `\`${owner.name}\` agent carries one rule of its own${owner.role ? ", on every flow it runs" : ""}`;
|
|
@@ -14661,8 +14678,8 @@ var init_rules2 = __esm({
|
|
|
14661
14678
|
});
|
|
14662
14679
|
|
|
14663
14680
|
// ../cli/src/lib/agent/deliveries.ts
|
|
14664
|
-
import
|
|
14665
|
-
import
|
|
14681
|
+
import fs43 from "node:fs";
|
|
14682
|
+
import path45 from "node:path";
|
|
14666
14683
|
function writeAudit(delivery, runs) {
|
|
14667
14684
|
const known2 = new Map(readAudit(delivery.deliveryId)?.sessions.map((s) => [s.sessionId, s]) ?? []);
|
|
14668
14685
|
const sessions = delivery.sessions.flatMap((id) => {
|
|
@@ -14690,10 +14707,10 @@ function writeAudit(delivery, runs) {
|
|
|
14690
14707
|
}
|
|
14691
14708
|
function writeAuditFile(record) {
|
|
14692
14709
|
try {
|
|
14693
|
-
|
|
14710
|
+
fs43.mkdirSync(DELIVERIES, { recursive: true });
|
|
14694
14711
|
const tmp = `${auditPath(record.deliveryId)}.tmp`;
|
|
14695
|
-
|
|
14696
|
-
|
|
14712
|
+
fs43.writeFileSync(tmp, JSON.stringify(record, null, 2) + "\n");
|
|
14713
|
+
fs43.renameSync(tmp, auditPath(record.deliveryId));
|
|
14697
14714
|
return true;
|
|
14698
14715
|
} catch {
|
|
14699
14716
|
return false;
|
|
@@ -14701,7 +14718,7 @@ function writeAuditFile(record) {
|
|
|
14701
14718
|
}
|
|
14702
14719
|
function readAudit(deliveryId) {
|
|
14703
14720
|
try {
|
|
14704
|
-
const data = JSON.parse(
|
|
14721
|
+
const data = JSON.parse(fs43.readFileSync(auditPath(deliveryId), "utf8"));
|
|
14705
14722
|
return { sessions: Array.isArray(data?.sessions) ? data.sessions : [] };
|
|
14706
14723
|
} catch {
|
|
14707
14724
|
return null;
|
|
@@ -14716,7 +14733,7 @@ function syncAudit(deliveryId, just) {
|
|
|
14716
14733
|
}
|
|
14717
14734
|
function wholeAudit(file) {
|
|
14718
14735
|
try {
|
|
14719
|
-
const data = JSON.parse(
|
|
14736
|
+
const data = JSON.parse(fs43.readFileSync(file, "utf8"));
|
|
14720
14737
|
return typeof data?.deliveryId === "string" && Array.isArray(data.sessions) ? data : null;
|
|
14721
14738
|
} catch {
|
|
14722
14739
|
return null;
|
|
@@ -14729,14 +14746,14 @@ function activeAudit(file) {
|
|
|
14729
14746
|
function allAudits() {
|
|
14730
14747
|
let names3;
|
|
14731
14748
|
try {
|
|
14732
|
-
names3 =
|
|
14749
|
+
names3 = fs43.readdirSync(DELIVERIES);
|
|
14733
14750
|
} catch {
|
|
14734
14751
|
return [];
|
|
14735
14752
|
}
|
|
14736
14753
|
const out = [];
|
|
14737
14754
|
for (const name of names3) {
|
|
14738
14755
|
if (!name.endsWith(".json")) continue;
|
|
14739
|
-
const audit = wholeAudit(
|
|
14756
|
+
const audit = wholeAudit(path45.join(DELIVERIES, name));
|
|
14740
14757
|
if (audit) out.push(audit);
|
|
14741
14758
|
}
|
|
14742
14759
|
return out;
|
|
@@ -14909,10 +14926,10 @@ function carryOnFrom(_deliveryId) {
|
|
|
14909
14926
|
function approvedRequirements(cardId2) {
|
|
14910
14927
|
const found2 = locate(cardId2);
|
|
14911
14928
|
if (!found2) return "";
|
|
14912
|
-
const file = found2.kind === "group" ?
|
|
14929
|
+
const file = found2.kind === "group" ? path45.join(found2.target, "root.md") : found2.target;
|
|
14913
14930
|
let text5;
|
|
14914
14931
|
try {
|
|
14915
|
-
text5 =
|
|
14932
|
+
text5 = fs43.readFileSync(file, "utf8");
|
|
14916
14933
|
} catch {
|
|
14917
14934
|
return "";
|
|
14918
14935
|
}
|
|
@@ -14942,8 +14959,8 @@ function cardMeta2(cardId2) {
|
|
|
14942
14959
|
try {
|
|
14943
14960
|
const found2 = locate(cardId2);
|
|
14944
14961
|
if (!found2) return null;
|
|
14945
|
-
const file = found2.kind === "group" ?
|
|
14946
|
-
return parseFrontmatter(
|
|
14962
|
+
const file = found2.kind === "group" ? path45.join(found2.target, "root.md") : found2.target;
|
|
14963
|
+
return parseFrontmatter(fs43.readFileSync(file, "utf8")).meta;
|
|
14947
14964
|
} catch {
|
|
14948
14965
|
return null;
|
|
14949
14966
|
}
|
|
@@ -15115,11 +15132,11 @@ var init_deliveries = __esm({
|
|
|
15115
15132
|
init_types();
|
|
15116
15133
|
init_worktree();
|
|
15117
15134
|
init_lock();
|
|
15118
|
-
auditPath = (deliveryId) =>
|
|
15135
|
+
auditPath = (deliveryId) => path45.join(DELIVERIES, `${deliveryId}.json`);
|
|
15119
15136
|
activeAudits = () => allAudits().filter((a2) => a2.status === "active");
|
|
15120
15137
|
auditRow = (audit) => readDeliveryRow({ ...audit, sessions: audit.sessions.map((s) => s.sessionId) });
|
|
15121
15138
|
lastSessionRunning = (audit) => audit.sessions[audit.sessions.length - 1]?.status === "running";
|
|
15122
|
-
localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) =>
|
|
15139
|
+
localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) => path45.resolve(REPO_ROOT, session.log) === logPathOf(session.sessionId) && fs43.existsSync(logPathOf(session.sessionId)));
|
|
15123
15140
|
unknownDelivery = (id) => refusal("deliveryNotFound", `no delivery here answers to "${id}"`, { id });
|
|
15124
15141
|
isResumable = (delivery) => !resumeRefusal(delivery);
|
|
15125
15142
|
APPROVED = [
|
|
@@ -15143,35 +15160,35 @@ var init_deliveries = __esm({
|
|
|
15143
15160
|
});
|
|
15144
15161
|
|
|
15145
15162
|
// ../cli/src/lib/agent/pictures.ts
|
|
15146
|
-
import
|
|
15147
|
-
import
|
|
15163
|
+
import fs44 from "node:fs";
|
|
15164
|
+
import path46 from "node:path";
|
|
15148
15165
|
function claimRunPictures(box2, sessionId, names3 = []) {
|
|
15149
15166
|
if (!box2 || !freeBox(box2) || names3.length === 0) return [];
|
|
15150
15167
|
const from = pictureBox(box2);
|
|
15151
15168
|
const to = pictureBox(sessionId);
|
|
15152
15169
|
try {
|
|
15153
|
-
|
|
15154
|
-
|
|
15170
|
+
fs44.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
15171
|
+
fs44.renameSync(from, to);
|
|
15155
15172
|
} catch {
|
|
15156
15173
|
return [];
|
|
15157
15174
|
}
|
|
15158
|
-
return names3.filter(pictureName).map((name) =>
|
|
15175
|
+
return names3.filter(pictureName).map((name) => path46.join(to, name)).filter((file) => fs44.existsSync(file));
|
|
15159
15176
|
}
|
|
15160
15177
|
function returnRunPictures(sessionId, box2) {
|
|
15161
15178
|
if (!box2 || !boxId(box2)) return;
|
|
15162
15179
|
try {
|
|
15163
|
-
|
|
15180
|
+
fs44.renameSync(pictureBox(sessionId), pictureBox(box2));
|
|
15164
15181
|
} catch {
|
|
15165
15182
|
}
|
|
15166
15183
|
}
|
|
15167
15184
|
function moveRunPictures(from, to, files2 = []) {
|
|
15168
15185
|
if (files2.length === 0) return [];
|
|
15169
15186
|
try {
|
|
15170
|
-
|
|
15187
|
+
fs44.renameSync(pictureBox(from), pictureBox(to));
|
|
15171
15188
|
} catch {
|
|
15172
15189
|
return files2;
|
|
15173
15190
|
}
|
|
15174
|
-
return files2.map((file) =>
|
|
15191
|
+
return files2.map((file) => path46.join(pictureBox(to), path46.basename(file)));
|
|
15175
15192
|
}
|
|
15176
15193
|
var pictureName, boxId, freeBox, pictureBox;
|
|
15177
15194
|
var init_pictures = __esm({
|
|
@@ -15180,8 +15197,8 @@ var init_pictures = __esm({
|
|
|
15180
15197
|
init_paths();
|
|
15181
15198
|
pictureName = (name) => /^[0-9a-f-]{36}\.[a-z0-9]{2,5}$/.test(name);
|
|
15182
15199
|
boxId = (box2) => /^[0-9a-f-]{36}$/.test(box2);
|
|
15183
|
-
freeBox = (box2) => boxId(box2) && !
|
|
15184
|
-
pictureBox = (box2) =>
|
|
15200
|
+
freeBox = (box2) => boxId(box2) && !fs44.existsSync(path46.join(SESSIONS_DIR, `${box2}.log`));
|
|
15201
|
+
pictureBox = (box2) => path46.join(SESSIONS_DIR, `${box2}.images`);
|
|
15185
15202
|
}
|
|
15186
15203
|
});
|
|
15187
15204
|
|
|
@@ -15217,6 +15234,14 @@ var init_Workflow = __esm({
|
|
|
15217
15234
|
}
|
|
15218
15235
|
});
|
|
15219
15236
|
|
|
15237
|
+
// ../cli/src/components/shared.md
|
|
15238
|
+
var shared_default;
|
|
15239
|
+
var init_shared = __esm({
|
|
15240
|
+
"../cli/src/components/shared.md"() {
|
|
15241
|
+
shared_default = "Tags draw only in the card body; in any other Markdown file, show pictures as plain Markdown images with paths relative to that file.\n";
|
|
15242
|
+
}
|
|
15243
|
+
});
|
|
15244
|
+
|
|
15220
15245
|
// ../cli/src/lib/components.ts
|
|
15221
15246
|
function agentComponents(names3, documents = DOCUMENTS) {
|
|
15222
15247
|
const docs = /* @__PURE__ */ new Map();
|
|
@@ -15251,18 +15276,19 @@ var init_components = __esm({
|
|
|
15251
15276
|
init_Compare();
|
|
15252
15277
|
init_Storyboard();
|
|
15253
15278
|
init_Workflow();
|
|
15279
|
+
init_shared();
|
|
15254
15280
|
init_agents();
|
|
15255
15281
|
init_io();
|
|
15256
15282
|
init_paths();
|
|
15257
15283
|
init_workflows();
|
|
15258
15284
|
DOCUMENTS = { Asset: Asset_default, Compare: Compare_default, Storyboard: Storyboard_default, Workflow: Workflow_default };
|
|
15259
|
-
componentDocsText = (docs) => docs.map((doc) => doc.text.trim()).join("\n\n");
|
|
15285
|
+
componentDocsText = (docs) => docs.length ? [shared_default, ...docs.map((doc) => doc.text)].map((text5) => text5.trim()).join("\n\n") : "";
|
|
15260
15286
|
}
|
|
15261
15287
|
});
|
|
15262
15288
|
|
|
15263
15289
|
// ../cli/src/lib/memories.ts
|
|
15264
|
-
import
|
|
15265
|
-
import
|
|
15290
|
+
import fs45 from "node:fs";
|
|
15291
|
+
import path47 from "node:path";
|
|
15266
15292
|
function readMemory(text5, builtIn, folder) {
|
|
15267
15293
|
const { meta, body } = splitFrontmatter(text5);
|
|
15268
15294
|
if (meta === null) return null;
|
|
@@ -15282,7 +15308,7 @@ function readMemory(text5, builtIn, folder) {
|
|
|
15282
15308
|
rules: body.trim(),
|
|
15283
15309
|
text: text5,
|
|
15284
15310
|
builtIn,
|
|
15285
|
-
dir:
|
|
15311
|
+
dir: path47.join(MEMORY, folder)
|
|
15286
15312
|
};
|
|
15287
15313
|
}
|
|
15288
15314
|
function globalMemories() {
|
|
@@ -15293,14 +15319,14 @@ function globalMemories() {
|
|
|
15293
15319
|
}
|
|
15294
15320
|
let folders2 = [];
|
|
15295
15321
|
try {
|
|
15296
|
-
folders2 =
|
|
15322
|
+
folders2 = fs45.readdirSync(MEMORY, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
|
|
15297
15323
|
} catch {
|
|
15298
15324
|
}
|
|
15299
15325
|
for (const name of folders2) {
|
|
15300
15326
|
if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR) continue;
|
|
15301
|
-
const file =
|
|
15302
|
-
if (!
|
|
15303
|
-
const memory = readMemory(
|
|
15327
|
+
const file = path47.join(MEMORY, name, GLOBAL_MEMORY_FILE);
|
|
15328
|
+
if (!fs45.existsSync(file)) continue;
|
|
15329
|
+
const memory = readMemory(fs45.readFileSync(file, "utf8"), false, name);
|
|
15304
15330
|
if (memory) out.push(memory);
|
|
15305
15331
|
}
|
|
15306
15332
|
return out;
|
|
@@ -15356,16 +15382,16 @@ var init_facts = __esm({
|
|
|
15356
15382
|
});
|
|
15357
15383
|
|
|
15358
15384
|
// ../cli/src/lib/view/archive.ts
|
|
15359
|
-
import
|
|
15360
|
-
import
|
|
15385
|
+
import fs46 from "node:fs";
|
|
15386
|
+
import path48 from "node:path";
|
|
15361
15387
|
function archivedId(file) {
|
|
15362
|
-
const own = idPrefix(
|
|
15363
|
-
return own !== null ? own : idPrefix(
|
|
15388
|
+
const own = idPrefix(path48.basename(file));
|
|
15389
|
+
return own !== null ? own : idPrefix(path48.basename(path48.dirname(file)));
|
|
15364
15390
|
}
|
|
15365
15391
|
function readFile(file) {
|
|
15366
15392
|
const id = archivedId(file);
|
|
15367
15393
|
if (id === null) return null;
|
|
15368
|
-
const { meta, body } = parseFrontmatter(
|
|
15394
|
+
const { meta, body } = parseFrontmatter(fs46.readFileSync(file, "utf8"));
|
|
15369
15395
|
if (!meta) return null;
|
|
15370
15396
|
return {
|
|
15371
15397
|
row: {
|
|
@@ -15373,15 +15399,15 @@ function readFile(file) {
|
|
|
15373
15399
|
title: meta.title,
|
|
15374
15400
|
archived: meta.archived,
|
|
15375
15401
|
rejected: meta.rejected,
|
|
15376
|
-
relPath: rel(file).split(
|
|
15402
|
+
relPath: rel(file).split(path48.sep).join("/")
|
|
15377
15403
|
},
|
|
15378
15404
|
body: body.replace(/^\n+/, "").replace(/\s+$/, ""),
|
|
15379
15405
|
meta
|
|
15380
15406
|
};
|
|
15381
15407
|
}
|
|
15382
15408
|
function readArchive() {
|
|
15383
|
-
const relPath = rel(ARCHIVE).split(
|
|
15384
|
-
if (!
|
|
15409
|
+
const relPath = rel(ARCHIVE).split(path48.sep).join("/");
|
|
15410
|
+
if (!fs46.existsSync(ARCHIVE)) return { relPath, cards: [] };
|
|
15385
15411
|
const cards = walkMd(ARCHIVE).map(readFile).filter((found2) => found2 !== null).map((found2) => found2.row);
|
|
15386
15412
|
cards.sort((a2, b2) => b2.id - a2.id);
|
|
15387
15413
|
return { relPath, cards };
|
|
@@ -15396,7 +15422,7 @@ var init_archive = __esm({
|
|
|
15396
15422
|
});
|
|
15397
15423
|
|
|
15398
15424
|
// ../cli/src/lib/agent/prompts.ts
|
|
15399
|
-
import
|
|
15425
|
+
import path49 from "node:path";
|
|
15400
15426
|
function stopReason(deliveryId) {
|
|
15401
15427
|
const delivery = findDelivery(deliveryId);
|
|
15402
15428
|
if (!delivery) return void 0;
|
|
@@ -15459,7 +15485,7 @@ ${text5}` : "";
|
|
|
15459
15485
|
}
|
|
15460
15486
|
function cardFileOf(id) {
|
|
15461
15487
|
const found2 = id === void 0 ? null : locate(id);
|
|
15462
|
-
return found2 ? found2.kind === "group" ?
|
|
15488
|
+
return found2 ? found2.kind === "group" ? path49.join(found2.target, "root.md") : found2.target : "";
|
|
15463
15489
|
}
|
|
15464
15490
|
function realPaths(text5, req) {
|
|
15465
15491
|
if (req.action !== "scheduled" && req.action !== "sub") return text5;
|
|
@@ -15546,7 +15572,7 @@ function frozenRules(req) {
|
|
|
15546
15572
|
function archivedCardFile(id) {
|
|
15547
15573
|
const found2 = locateArchived(id);
|
|
15548
15574
|
if (!found2) return `${rel(ARCHIVE)}/`;
|
|
15549
|
-
return rel(found2.kind === "group" ?
|
|
15575
|
+
return rel(found2.kind === "group" ? path49.join(found2.target, "root.md") : found2.target);
|
|
15550
15576
|
}
|
|
15551
15577
|
function shippedLines(cardId2) {
|
|
15552
15578
|
const delivery = endedDelivery(`${cardId2}`);
|
|
@@ -15689,7 +15715,7 @@ function actionPrompt(req, command, notes) {
|
|
|
15689
15715
|
case "spec": {
|
|
15690
15716
|
const agent = findSpecAgent(req.specAgent ?? "");
|
|
15691
15717
|
const found2 = req.id === void 0 ? null : locate(req.id);
|
|
15692
|
-
const cardFile3 = found2 ? rel(found2.kind === "group" ?
|
|
15718
|
+
const cardFile3 = found2 ? rel(found2.kind === "group" ? path49.join(found2.target, "root.md") : found2.target) : `task #${req.id}`;
|
|
15693
15719
|
const own = agent ? specAgentInstructions(agent) : null;
|
|
15694
15720
|
if (own) notes.push(...own.notes);
|
|
15695
15721
|
const memory = agent ? agentMemoryBlock(agent) : "";
|
|
@@ -15870,17 +15896,17 @@ var init_prompts = __esm({
|
|
|
15870
15896
|
// ../cli/src/lib/agent/stop.ts
|
|
15871
15897
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
15872
15898
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
15873
|
-
import
|
|
15899
|
+
import fs47 from "node:fs";
|
|
15874
15900
|
import os6 from "node:os";
|
|
15875
15901
|
function markedInProc(entry, strict = false) {
|
|
15876
15902
|
const pids = [];
|
|
15877
|
-
for (const name of
|
|
15903
|
+
for (const name of fs47.readdirSync("/proc")) {
|
|
15878
15904
|
if (!/^\d+$/.test(name)) continue;
|
|
15879
15905
|
try {
|
|
15880
|
-
if (
|
|
15906
|
+
if (fs47.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
|
|
15881
15907
|
} catch (error) {
|
|
15882
15908
|
if (strict && !["ENOENT", "ESRCH"].includes(error.code ?? "")) {
|
|
15883
|
-
const stat =
|
|
15909
|
+
const stat = fs47.statSync(`/proc/${name}`, { throwIfNoEntry: false });
|
|
15884
15910
|
if (stat?.uid === process.getuid?.()) throw error;
|
|
15885
15911
|
}
|
|
15886
15912
|
}
|
|
@@ -16076,10 +16102,10 @@ var init_stop = __esm({
|
|
|
16076
16102
|
});
|
|
16077
16103
|
|
|
16078
16104
|
// ../cli/src/lib/agent/creation-lock.ts
|
|
16079
|
-
import
|
|
16105
|
+
import path50 from "node:path";
|
|
16080
16106
|
function withCreationLock(fn2) {
|
|
16081
16107
|
if (depth2) return fn2();
|
|
16082
|
-
return withLock(
|
|
16108
|
+
return withLock(path50.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
|
|
16083
16109
|
depth2++;
|
|
16084
16110
|
try {
|
|
16085
16111
|
return fn2();
|
|
@@ -16100,8 +16126,8 @@ var init_creation_lock = __esm({
|
|
|
16100
16126
|
|
|
16101
16127
|
// ../cli/src/lib/agent/sessions.ts
|
|
16102
16128
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
16103
|
-
import
|
|
16104
|
-
import
|
|
16129
|
+
import fs48 from "node:fs";
|
|
16130
|
+
import path51 from "node:path";
|
|
16105
16131
|
function reap(runs, reaped = [], restore = []) {
|
|
16106
16132
|
let changed = false;
|
|
16107
16133
|
const now = Date.now();
|
|
@@ -16121,7 +16147,7 @@ function reap(runs, reaped = [], restore = []) {
|
|
|
16121
16147
|
}
|
|
16122
16148
|
function stampDuration(run3, endedAt) {
|
|
16123
16149
|
try {
|
|
16124
|
-
|
|
16150
|
+
fs48.appendFileSync(run3.logPath, durationLine(endedAt - run3.startedAt));
|
|
16125
16151
|
} catch {
|
|
16126
16152
|
}
|
|
16127
16153
|
}
|
|
@@ -16135,7 +16161,7 @@ function cardNow(cardId2) {
|
|
|
16135
16161
|
try {
|
|
16136
16162
|
const file = cardFile(cardId2);
|
|
16137
16163
|
if (!file) return null;
|
|
16138
|
-
const { meta } = parseFrontmatter(
|
|
16164
|
+
const { meta } = parseFrontmatter(fs48.readFileSync(file, "utf8"));
|
|
16139
16165
|
if (!meta) return null;
|
|
16140
16166
|
return { status: meta.status || "todo", questions: openOf(meta.questions).length, title: meta.title };
|
|
16141
16167
|
} catch {
|
|
@@ -16267,9 +16293,9 @@ function leftBoardOnLanding(id) {
|
|
|
16267
16293
|
function archivedRejected(id) {
|
|
16268
16294
|
const filed = locateArchived(id);
|
|
16269
16295
|
if (!filed) return null;
|
|
16270
|
-
const file = filed.kind === "group" ?
|
|
16296
|
+
const file = filed.kind === "group" ? path51.join(filed.target, "root.md") : filed.target;
|
|
16271
16297
|
try {
|
|
16272
|
-
return !!parseFrontmatter(
|
|
16298
|
+
return !!parseFrontmatter(fs48.readFileSync(file, "utf8")).meta?.rejected;
|
|
16273
16299
|
} catch {
|
|
16274
16300
|
return false;
|
|
16275
16301
|
}
|
|
@@ -16520,7 +16546,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID5(), said3) {
|
|
|
16520
16546
|
return { run: record, spec };
|
|
16521
16547
|
}
|
|
16522
16548
|
function planningSession(cardId2, cwd = REPO_ROOT) {
|
|
16523
|
-
const here = (dir) => !dir ||
|
|
16549
|
+
const here = (dir) => !dir || path51.resolve(dir) === cwd;
|
|
16524
16550
|
const planned = readRuns().filter((r2) => r2.status === "done" && r2.cardId === cardId2 && PLANNING.has(r2.action)).sort((a2, b2) => b2.startedAt - a2.startedAt)[0];
|
|
16525
16551
|
if (!planned) return { none: "unrecorded" };
|
|
16526
16552
|
if (!here(planned.cwd)) return { none: "elsewhere" };
|
|
@@ -16739,8 +16765,8 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
|
|
|
16739
16765
|
if (inherited.asks.length || inherited.refines.length) writeAsks(sessionId, inherited);
|
|
16740
16766
|
clearAsks(prev.sessionId);
|
|
16741
16767
|
try {
|
|
16742
|
-
|
|
16743
|
-
|
|
16768
|
+
fs48.unlinkSync(prev.logPath);
|
|
16769
|
+
fs48.rmSync(eventsPathOf(prev.sessionId), { force: true });
|
|
16744
16770
|
} catch {
|
|
16745
16771
|
}
|
|
16746
16772
|
if (retry2 && prev.pictures?.length) {
|
|
@@ -16763,8 +16789,8 @@ function forgetRun(sessionId) {
|
|
|
16763
16789
|
if (!gone) return;
|
|
16764
16790
|
clearAsks(sessionId);
|
|
16765
16791
|
try {
|
|
16766
|
-
|
|
16767
|
-
|
|
16792
|
+
fs48.unlinkSync(gone.logPath);
|
|
16793
|
+
fs48.rmSync(eventsPathOf(gone.sessionId), { force: true });
|
|
16768
16794
|
} catch {
|
|
16769
16795
|
}
|
|
16770
16796
|
}
|
|
@@ -16793,14 +16819,14 @@ function noteSpecRefusals(sessionId, refused) {
|
|
|
16793
16819
|
}
|
|
16794
16820
|
function clearAsks(sessionId) {
|
|
16795
16821
|
try {
|
|
16796
|
-
|
|
16822
|
+
fs48.unlinkSync(asksPathOf(sessionId));
|
|
16797
16823
|
} catch {
|
|
16798
16824
|
}
|
|
16799
16825
|
}
|
|
16800
16826
|
function readAsks(sessionId) {
|
|
16801
16827
|
let data;
|
|
16802
16828
|
try {
|
|
16803
|
-
data = JSON.parse(
|
|
16829
|
+
data = JSON.parse(fs48.readFileSync(asksPathOf(sessionId), "utf8"));
|
|
16804
16830
|
} catch {
|
|
16805
16831
|
return { asks: [], refines: [], refused: [] };
|
|
16806
16832
|
}
|
|
@@ -16827,10 +16853,10 @@ function readAsks(sessionId) {
|
|
|
16827
16853
|
return { asks: asks.filter((a2) => !discarded.has(a2.cardId)), refines: refines.filter((a2) => !discarded.has(a2.cardId)), refused };
|
|
16828
16854
|
}
|
|
16829
16855
|
function writeAsks(sessionId, file) {
|
|
16830
|
-
|
|
16856
|
+
fs48.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
16831
16857
|
const tmp = `${asksPathOf(sessionId)}.tmp`;
|
|
16832
|
-
|
|
16833
|
-
|
|
16858
|
+
fs48.writeFileSync(tmp, JSON.stringify(file, null, 2) + "\n");
|
|
16859
|
+
fs48.renameSync(tmp, asksPathOf(sessionId));
|
|
16834
16860
|
}
|
|
16835
16861
|
function markSpawned(sessionId, pid) {
|
|
16836
16862
|
patch(sessionId, (r2) => {
|
|
@@ -16961,12 +16987,12 @@ async function resumeDelivery(id) {
|
|
|
16961
16987
|
return { ok: true, deliveryId: delivery.deliveryId, carryOn };
|
|
16962
16988
|
}
|
|
16963
16989
|
function writeSpec(spec) {
|
|
16964
|
-
|
|
16965
|
-
|
|
16990
|
+
fs48.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
16991
|
+
fs48.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
|
|
16966
16992
|
}
|
|
16967
16993
|
function readSpec(sessionId) {
|
|
16968
16994
|
try {
|
|
16969
|
-
const spec = JSON.parse(
|
|
16995
|
+
const spec = JSON.parse(fs48.readFileSync(specPathOf(sessionId), "utf8"));
|
|
16970
16996
|
return spec && Array.isArray(spec.plan?.argv) ? spec : null;
|
|
16971
16997
|
} catch {
|
|
16972
16998
|
return null;
|
|
@@ -16974,28 +17000,28 @@ function readSpec(sessionId) {
|
|
|
16974
17000
|
}
|
|
16975
17001
|
function dropSpec(sessionId) {
|
|
16976
17002
|
try {
|
|
16977
|
-
|
|
17003
|
+
fs48.unlinkSync(specPathOf(sessionId));
|
|
16978
17004
|
} catch {
|
|
16979
17005
|
}
|
|
16980
17006
|
}
|
|
16981
17007
|
async function acquireIndexLock(giveUp) {
|
|
16982
17008
|
const until = Date.now() + INDEX_WAIT_MS;
|
|
16983
|
-
const holder =
|
|
17009
|
+
const holder = path51.join(INDEX_LOCK2, "holder");
|
|
16984
17010
|
for (; ; ) {
|
|
16985
17011
|
if (giveUp()) return null;
|
|
16986
17012
|
try {
|
|
16987
|
-
|
|
16988
|
-
|
|
16989
|
-
return () =>
|
|
17013
|
+
fs48.mkdirSync(INDEX_LOCK2, { recursive: false });
|
|
17014
|
+
fs48.writeFileSync(holder, String(process.pid));
|
|
17015
|
+
return () => fs48.rmSync(INDEX_LOCK2, { recursive: true, force: true });
|
|
16990
17016
|
} catch (err) {
|
|
16991
17017
|
const code = err.code;
|
|
16992
17018
|
if (code === "ENOENT") {
|
|
16993
|
-
|
|
17019
|
+
fs48.mkdirSync(path51.dirname(INDEX_LOCK2), { recursive: true });
|
|
16994
17020
|
continue;
|
|
16995
17021
|
}
|
|
16996
17022
|
if (code !== "EEXIST") throw err;
|
|
16997
17023
|
if (!pidAlive(Number(readHolder(holder)))) {
|
|
16998
|
-
|
|
17024
|
+
fs48.rmSync(INDEX_LOCK2, { recursive: true, force: true });
|
|
16999
17025
|
continue;
|
|
17000
17026
|
}
|
|
17001
17027
|
if (Date.now() > until) return null;
|
|
@@ -17005,7 +17031,7 @@ async function acquireIndexLock(giveUp) {
|
|
|
17005
17031
|
}
|
|
17006
17032
|
function readHolder(file) {
|
|
17007
17033
|
try {
|
|
17008
|
-
return
|
|
17034
|
+
return fs48.readFileSync(file, "utf8").trim();
|
|
17009
17035
|
} catch {
|
|
17010
17036
|
return String(process.pid);
|
|
17011
17037
|
}
|
|
@@ -17091,8 +17117,8 @@ var init_sessions = __esm({
|
|
|
17091
17117
|
implement: "implementing",
|
|
17092
17118
|
hook: "implementing"
|
|
17093
17119
|
};
|
|
17094
|
-
specPathOf = (sessionId) =>
|
|
17095
|
-
asksPathOf = (sessionId) =>
|
|
17120
|
+
specPathOf = (sessionId) => path51.join(SESSIONS_DIR, `${sessionId}.plan.json`);
|
|
17121
|
+
asksPathOf = (sessionId) => path51.join(SESSIONS_DIR, `${sessionId}.asks.json`);
|
|
17096
17122
|
carriesSession = (r2) => !!(r2.resumedFrom || r2.continues && !r2.continues.fork);
|
|
17097
17123
|
canPickUp = (r2) => r2.status === "error" || r2.status === "interrupted" || r2.status === "stopped";
|
|
17098
17124
|
neverStarted = (r2) => r2.unspawned === true || !!r2.errorWhy?.some((why2) => why2.kind === "notInstalled");
|
|
@@ -17145,8 +17171,8 @@ var init_sources = __esm({
|
|
|
17145
17171
|
});
|
|
17146
17172
|
|
|
17147
17173
|
// ../cli/src/lib/signals/inbox.ts
|
|
17148
|
-
import
|
|
17149
|
-
import
|
|
17174
|
+
import fs49 from "node:fs";
|
|
17175
|
+
import path52 from "node:path";
|
|
17150
17176
|
function metaPair(key, value) {
|
|
17151
17177
|
const name = typeof key === "string" ? key.trim() : "";
|
|
17152
17178
|
if (!name) return null;
|
|
@@ -17177,7 +17203,7 @@ ${signal2.summary.trim()}
|
|
|
17177
17203
|
function parse(file, lenient = false) {
|
|
17178
17204
|
let text5;
|
|
17179
17205
|
try {
|
|
17180
|
-
text5 =
|
|
17206
|
+
text5 = fs49.readFileSync(file, "utf8");
|
|
17181
17207
|
} catch {
|
|
17182
17208
|
return null;
|
|
17183
17209
|
}
|
|
@@ -17231,20 +17257,20 @@ function parse(file, lenient = false) {
|
|
|
17231
17257
|
};
|
|
17232
17258
|
}
|
|
17233
17259
|
function freeName(dir, wanted) {
|
|
17234
|
-
const ext =
|
|
17260
|
+
const ext = path52.extname(wanted);
|
|
17235
17261
|
const stem = wanted.slice(0, wanted.length - ext.length);
|
|
17236
17262
|
let name = wanted;
|
|
17237
|
-
for (let n = 2;
|
|
17263
|
+
for (let n = 2; fs49.existsSync(path52.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
|
|
17238
17264
|
return name;
|
|
17239
17265
|
}
|
|
17240
17266
|
function readFolder2(dir, lenient = false) {
|
|
17241
17267
|
let entries;
|
|
17242
17268
|
try {
|
|
17243
|
-
entries =
|
|
17269
|
+
entries = fs49.readdirSync(dir, { withFileTypes: true });
|
|
17244
17270
|
} catch {
|
|
17245
17271
|
return [];
|
|
17246
17272
|
}
|
|
17247
|
-
return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(
|
|
17273
|
+
return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(path52.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
|
|
17248
17274
|
}
|
|
17249
17275
|
function readInbox() {
|
|
17250
17276
|
const signals = readFolder2(TRIAGE);
|
|
@@ -17252,7 +17278,7 @@ function readInbox() {
|
|
|
17252
17278
|
return signals;
|
|
17253
17279
|
}
|
|
17254
17280
|
function writeSignal(incoming, importedAt, slug2 = "") {
|
|
17255
|
-
|
|
17281
|
+
fs49.mkdirSync(TRIAGE, { recursive: true });
|
|
17256
17282
|
const signal2 = {
|
|
17257
17283
|
...incoming,
|
|
17258
17284
|
importedAt,
|
|
@@ -17264,12 +17290,12 @@ function writeSignal(incoming, importedAt, slug2 = "") {
|
|
|
17264
17290
|
contentKept: true,
|
|
17265
17291
|
relPath: ""
|
|
17266
17292
|
};
|
|
17267
|
-
const file =
|
|
17268
|
-
|
|
17293
|
+
const file = path52.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug2)));
|
|
17294
|
+
fs49.writeFileSync(file, serialize({ ...signal2, relPath: boardRel(file) }));
|
|
17269
17295
|
return { ...signal2, relPath: boardRel(file) };
|
|
17270
17296
|
}
|
|
17271
17297
|
function stamp3(file, fields) {
|
|
17272
|
-
const text5 =
|
|
17298
|
+
const text5 = fs49.readFileSync(file, "utf8");
|
|
17273
17299
|
const lines = text5.split("\n");
|
|
17274
17300
|
const close = lines.indexOf("---", 1);
|
|
17275
17301
|
if (close < 0) return;
|
|
@@ -17278,13 +17304,13 @@ function stamp3(file, fields) {
|
|
|
17278
17304
|
return !key || fields[key[1]] === void 0;
|
|
17279
17305
|
});
|
|
17280
17306
|
const added = Object.entries(fields).flatMap(([key, value]) => value === null ? [] : [`${key}: ${yamlScalar(value)}`]);
|
|
17281
|
-
|
|
17307
|
+
fs49.writeFileSync(file, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
|
|
17282
17308
|
}
|
|
17283
17309
|
function moveSignal(from, into, fields) {
|
|
17284
|
-
if (!
|
|
17285
|
-
|
|
17286
|
-
const at2 =
|
|
17287
|
-
|
|
17310
|
+
if (!fs49.existsSync(from)) return "";
|
|
17311
|
+
fs49.mkdirSync(into, { recursive: true });
|
|
17312
|
+
const at2 = path52.join(into, freeName(into, path52.basename(from)));
|
|
17313
|
+
fs49.renameSync(from, at2);
|
|
17288
17314
|
stamp3(at2, fields);
|
|
17289
17315
|
return boardRel(at2);
|
|
17290
17316
|
}
|
|
@@ -17297,8 +17323,8 @@ function dismissInboxItems(sourceIds, by, reason = "") {
|
|
|
17297
17323
|
const found2 = waiting.get(sourceId);
|
|
17298
17324
|
if (!found2) return missing;
|
|
17299
17325
|
const already = ignored.get(sourceId);
|
|
17300
|
-
if (already)
|
|
17301
|
-
const at2 = moveSignal(
|
|
17326
|
+
if (already) fs49.rmSync(path52.join(SIGNALS_DISMISSED, path52.basename(already.relPath)), { force: true });
|
|
17327
|
+
const at2 = moveSignal(path52.join(TRIAGE, path52.basename(found2.relPath)), SIGNALS_DISMISSED, {
|
|
17302
17328
|
dismissed_at: formatStamp(/* @__PURE__ */ new Date()),
|
|
17303
17329
|
dismissed_by: by,
|
|
17304
17330
|
...why2 ? { dismissed_reason: why2 } : {}
|
|
@@ -17314,10 +17340,10 @@ function archiveInboxItem(sourceId, cardId2) {
|
|
|
17314
17340
|
if (!found2) {
|
|
17315
17341
|
const ignored = readAllDismissed().find((signal2) => signal2.sourceId === sourceId);
|
|
17316
17342
|
if (!ignored) return { ok: false, error: `nothing waiting in triage is ${sourceId}` };
|
|
17317
|
-
stamp3(
|
|
17343
|
+
stamp3(path52.join(SIGNALS_DISMISSED, path52.basename(ignored.relPath)), { card_id: String(cardId2) });
|
|
17318
17344
|
return { ok: true, relPath: ignored.relPath, where: "dismissed" };
|
|
17319
17345
|
}
|
|
17320
|
-
const at2 = moveSignal(
|
|
17346
|
+
const at2 = moveSignal(path52.join(TRIAGE, path52.basename(found2.relPath)), SIGNALS_ARCHIVED, {
|
|
17321
17347
|
card_id: String(cardId2),
|
|
17322
17348
|
archived_at: formatStamp(/* @__PURE__ */ new Date())
|
|
17323
17349
|
});
|
|
@@ -17335,7 +17361,7 @@ function restoreInboxItems(sourceIds) {
|
|
|
17335
17361
|
return refuse3(`${sourceId} was kept without its content, so there is nothing to restore`);
|
|
17336
17362
|
}
|
|
17337
17363
|
if (waiting.has(sourceId)) return refuse3(`${sourceId} is already waiting in triage`);
|
|
17338
|
-
const at2 = moveSignal(
|
|
17364
|
+
const at2 = moveSignal(path52.join(SIGNALS_DISMISSED, path52.basename(found2.relPath)), TRIAGE, {
|
|
17339
17365
|
dismissed_at: null,
|
|
17340
17366
|
dismissed_by: null,
|
|
17341
17367
|
dismissed_reason: null
|
|
@@ -17354,7 +17380,7 @@ var init_inbox = __esm({
|
|
|
17354
17380
|
init_sources();
|
|
17355
17381
|
init_paths();
|
|
17356
17382
|
init_yaml();
|
|
17357
|
-
boardRel = (file) => rel(file).split(
|
|
17383
|
+
boardRel = (file) => rel(file).split(path52.sep).join("/");
|
|
17358
17384
|
FIELDS = ["source_id", "title", "collected_at", "imported_at"];
|
|
17359
17385
|
META_LINE = /^\s+("(?:[^"\\]|\\.)*"|[^:]+):\s*(.*)$/;
|
|
17360
17386
|
slugOf = (said3) => said3.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56).replace(/-+$/, "");
|
|
@@ -17571,12 +17597,12 @@ var init_workflow_cards = __esm({
|
|
|
17571
17597
|
});
|
|
17572
17598
|
|
|
17573
17599
|
// ../cli/src/lib/readme.ts
|
|
17574
|
-
import
|
|
17575
|
-
import
|
|
17600
|
+
import fs50 from "node:fs";
|
|
17601
|
+
import path53 from "node:path";
|
|
17576
17602
|
function stripReadmeRefs(target) {
|
|
17577
|
-
if (!
|
|
17603
|
+
if (!fs50.existsSync(README)) return [];
|
|
17578
17604
|
const needle = target.kind === "group" ? `](${target.rel}/` : `](${target.rel})`;
|
|
17579
|
-
const lines =
|
|
17605
|
+
const lines = fs50.readFileSync(README, "utf8").split("\n");
|
|
17580
17606
|
const out = [];
|
|
17581
17607
|
const removed = [];
|
|
17582
17608
|
let i = 0;
|
|
@@ -17598,20 +17624,20 @@ function stripReadmeRefs(target) {
|
|
|
17598
17624
|
out.push(line);
|
|
17599
17625
|
i++;
|
|
17600
17626
|
}
|
|
17601
|
-
if (removed.length)
|
|
17627
|
+
if (removed.length) fs50.writeFileSync(README, out.join("\n"));
|
|
17602
17628
|
return removed;
|
|
17603
17629
|
}
|
|
17604
17630
|
function addReadmeRef(id, title, relPath) {
|
|
17605
|
-
if (!
|
|
17606
|
-
const link2 = relPath.split(
|
|
17631
|
+
if (!fs50.existsSync(README)) return false;
|
|
17632
|
+
const link2 = relPath.split(path53.sep).join("/");
|
|
17607
17633
|
const bullet = `- [#${id} ${title}](${link2})`;
|
|
17608
17634
|
const heading = `## ${TASKS_HEADING}`;
|
|
17609
|
-
let lines =
|
|
17635
|
+
let lines = fs50.readFileSync(README, "utf8").split("\n");
|
|
17610
17636
|
const hi2 = lines.findIndex((l2) => l2.trim().toLowerCase() === heading.toLowerCase());
|
|
17611
17637
|
if (hi2 === -1) {
|
|
17612
17638
|
while (lines.length && lines[lines.length - 1].trim() === "") lines.pop();
|
|
17613
17639
|
lines.push("", heading, "", bullet);
|
|
17614
|
-
|
|
17640
|
+
fs50.writeFileSync(README, lines.join("\n") + "\n");
|
|
17615
17641
|
return true;
|
|
17616
17642
|
}
|
|
17617
17643
|
let end2 = hi2 + 1;
|
|
@@ -17625,15 +17651,15 @@ function addReadmeRef(id, title, relPath) {
|
|
|
17625
17651
|
const at2 = lastBullet !== -1 ? lastBullet + 1 : lines[hi2 + 1] === "" ? hi2 + 2 : hi2 + 1;
|
|
17626
17652
|
lines.splice(at2, 0, bullet);
|
|
17627
17653
|
}
|
|
17628
|
-
|
|
17654
|
+
fs50.writeFileSync(README, lines.join("\n"));
|
|
17629
17655
|
return true;
|
|
17630
17656
|
}
|
|
17631
17657
|
function repointReadmeLink(id, oldRel, newRel, title) {
|
|
17632
|
-
if (!
|
|
17633
|
-
const oldLink = oldRel.split(
|
|
17634
|
-
const newLink = newRel.split(
|
|
17658
|
+
if (!fs50.existsSync(README)) return false;
|
|
17659
|
+
const oldLink = oldRel.split(path53.sep).join("/");
|
|
17660
|
+
const newLink = newRel.split(path53.sep).join("/");
|
|
17635
17661
|
const linkRe = new RegExp(`\\[#${id}\\b[^\\]]*\\]\\(${escapeRegex(oldLink)}\\)`);
|
|
17636
|
-
const lines =
|
|
17662
|
+
const lines = fs50.readFileSync(README, "utf8").split("\n");
|
|
17637
17663
|
let changed = false;
|
|
17638
17664
|
for (let i = 0; i < lines.length; i++) {
|
|
17639
17665
|
if (!lines[i].includes(`](${oldLink})`)) continue;
|
|
@@ -17643,7 +17669,7 @@ function repointReadmeLink(id, oldRel, newRel, title) {
|
|
|
17643
17669
|
changed = true;
|
|
17644
17670
|
}
|
|
17645
17671
|
}
|
|
17646
|
-
if (changed)
|
|
17672
|
+
if (changed) fs50.writeFileSync(README, lines.join("\n"));
|
|
17647
17673
|
return changed;
|
|
17648
17674
|
}
|
|
17649
17675
|
var isTableRow, isBulletStart, bulletIndent, TASKS_HEADING, escapeRegex;
|
|
@@ -18129,14 +18155,14 @@ function collect(body, card, host2) {
|
|
|
18129
18155
|
const active2 = /* @__PURE__ */ new Set();
|
|
18130
18156
|
const out = [];
|
|
18131
18157
|
const visit = (src, types, owner) => {
|
|
18132
|
-
const
|
|
18158
|
+
const path90 = src.replace(/[?#].*$/, "");
|
|
18133
18159
|
let resolved2;
|
|
18134
18160
|
try {
|
|
18135
|
-
resolved2 = host2.resolve(
|
|
18161
|
+
resolved2 = host2.resolve(path90, owner);
|
|
18136
18162
|
} catch (error) {
|
|
18137
18163
|
if (owner !== card) return { key: null, error: why(error) };
|
|
18138
18164
|
if (!nodes.has(src)) {
|
|
18139
|
-
const node2 = { key: src, file: null, kind: kindAt(
|
|
18165
|
+
const node2 = { key: src, file: null, kind: kindAt(path90, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
|
|
18140
18166
|
nodes.set(src, node2);
|
|
18141
18167
|
out.push(node2);
|
|
18142
18168
|
}
|
|
@@ -18221,16 +18247,16 @@ var init_collect = __esm({
|
|
|
18221
18247
|
});
|
|
18222
18248
|
|
|
18223
18249
|
// ../cli/src/lib/dress-page.ts
|
|
18224
|
-
import
|
|
18225
|
-
import
|
|
18250
|
+
import fs51 from "node:fs";
|
|
18251
|
+
import path54 from "node:path";
|
|
18226
18252
|
function dressPage(file) {
|
|
18227
|
-
const folder =
|
|
18228
|
-
const html =
|
|
18253
|
+
const folder = path54.dirname(file);
|
|
18254
|
+
const html = fs51.readFileSync(file, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
|
|
18229
18255
|
const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
|
|
18230
18256
|
if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
|
|
18231
|
-
const at3 =
|
|
18232
|
-
if (!at3.startsWith(folder +
|
|
18233
|
-
const css =
|
|
18257
|
+
const at3 = path54.resolve(folder, href);
|
|
18258
|
+
if (!at3.startsWith(folder + path54.sep) || !fs51.existsSync(at3)) return tag;
|
|
18259
|
+
const css = fs51.readFileSync(at3, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole2, quote, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole2 : `url(${quote}${path54.relative(folder, path54.resolve(path54.dirname(at3), src)).split(path54.sep).join("/")}${quote})`);
|
|
18234
18260
|
return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
|
|
18235
18261
|
});
|
|
18236
18262
|
const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
|
|
@@ -18242,25 +18268,25 @@ var init_dress_page = __esm({
|
|
|
18242
18268
|
"use strict";
|
|
18243
18269
|
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'";
|
|
18244
18270
|
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>`;
|
|
18245
|
-
referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) :
|
|
18271
|
+
referenceText = (file) => /\.html$/i.test(file) ? dressPage(file) : fs51.readFileSync(file, "utf8");
|
|
18246
18272
|
}
|
|
18247
18273
|
});
|
|
18248
18274
|
|
|
18249
18275
|
// ../cli/src/lib/preview-files.ts
|
|
18250
|
-
import
|
|
18251
|
-
import
|
|
18276
|
+
import fs52 from "node:fs";
|
|
18277
|
+
import path55 from "node:path";
|
|
18252
18278
|
function resolver(card, id) {
|
|
18253
|
-
const roots = [KANBAN,
|
|
18254
|
-
const real2 = (p2) =>
|
|
18255
|
-
const inside2 = (p2) => roots.some((root2) => p2.startsWith(real2(root2) +
|
|
18279
|
+
const roots = [KANBAN, path55.join(ASSETS, String(id)), path55.join(MOCKUPS, String(id))];
|
|
18280
|
+
const real2 = (p2) => fs52.existsSync(p2) ? fs52.realpathSync(p2) : p2;
|
|
18281
|
+
const inside2 = (p2) => roots.some((root2) => p2.startsWith(real2(root2) + path55.sep));
|
|
18256
18282
|
return (src, owner) => {
|
|
18257
18283
|
if (/^[a-z][\w+.-]*:/i.test(src) || src.startsWith("#") || src.startsWith("//")) return null;
|
|
18258
|
-
if (
|
|
18284
|
+
if (path55.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
|
|
18259
18285
|
const held4 = /^\.(assets|mockups)\//.exec(src);
|
|
18260
|
-
const file = held4 ?
|
|
18261
|
-
if (!inside2(
|
|
18262
|
-
if (!
|
|
18263
|
-
return { key:
|
|
18286
|
+
const file = held4 ? path55.resolve(held4[1] === "assets" ? ASSETS : MOCKUPS, src.slice(held4[0].length)) : path55.resolve(path55.dirname(owner), src);
|
|
18287
|
+
if (!inside2(path55.resolve(file)) || fs52.existsSync(file) && !inside2(fs52.realpathSync(file))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
|
|
18288
|
+
if (!fs52.statSync(file, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
|
|
18289
|
+
return { key: fs52.realpathSync(file), file };
|
|
18264
18290
|
};
|
|
18265
18291
|
}
|
|
18266
18292
|
function validatePreviewFiles(card, id, text5) {
|
|
@@ -18295,8 +18321,8 @@ var init_preview_files = __esm({
|
|
|
18295
18321
|
});
|
|
18296
18322
|
|
|
18297
18323
|
// ../cli/src/lib/spec-contract.ts
|
|
18298
|
-
import
|
|
18299
|
-
import
|
|
18324
|
+
import fs53 from "node:fs";
|
|
18325
|
+
import path56 from "node:path";
|
|
18300
18326
|
function scanCardLines(lines, start = 0) {
|
|
18301
18327
|
const visible = lines.map(() => "");
|
|
18302
18328
|
let fence = null;
|
|
@@ -18329,18 +18355,18 @@ function scanCardLines(lines, start = 0) {
|
|
|
18329
18355
|
}
|
|
18330
18356
|
function snapshotSpecs() {
|
|
18331
18357
|
const out = /* @__PURE__ */ new Map();
|
|
18332
|
-
if (!
|
|
18358
|
+
if (!fs53.existsSync(TODO)) return out;
|
|
18333
18359
|
for (const file of walkMd(TODO)) {
|
|
18334
|
-
if (isLegacyRecurring(
|
|
18335
|
-
const id = idPrefix(
|
|
18336
|
-
if (id !== null) out.set(file, { id, text:
|
|
18360
|
+
if (isLegacyRecurring(path56.relative(TODO, file))) continue;
|
|
18361
|
+
const id = idPrefix(path56.basename(file) === "root.md" ? path56.basename(path56.dirname(file)) : path56.basename(file));
|
|
18362
|
+
if (id !== null) out.set(file, { id, text: fs53.readFileSync(file, "utf8") });
|
|
18337
18363
|
}
|
|
18338
18364
|
return out;
|
|
18339
18365
|
}
|
|
18340
18366
|
function enclosingGroups(file) {
|
|
18341
18367
|
const ids = [];
|
|
18342
18368
|
for (let root2 = enclosingGroupRoot(file); root2; root2 = enclosingGroupRoot(root2)) {
|
|
18343
|
-
const id = idPrefix(
|
|
18369
|
+
const id = idPrefix(path56.basename(path56.dirname(root2)));
|
|
18344
18370
|
if (id !== null) ids.push(id);
|
|
18345
18371
|
}
|
|
18346
18372
|
return ids;
|
|
@@ -18498,9 +18524,9 @@ function validateSpec(file, text5, id) {
|
|
|
18498
18524
|
}
|
|
18499
18525
|
function inside(dir, name) {
|
|
18500
18526
|
try {
|
|
18501
|
-
const root2 =
|
|
18502
|
-
const real2 =
|
|
18503
|
-
return real2.startsWith(root2 +
|
|
18527
|
+
const root2 = fs53.realpathSync(dir);
|
|
18528
|
+
const real2 = fs53.realpathSync(path56.join(dir, name));
|
|
18529
|
+
return real2.startsWith(root2 + path56.sep) && fs53.statSync(real2).isFile() ? real2 : null;
|
|
18504
18530
|
} catch {
|
|
18505
18531
|
return null;
|
|
18506
18532
|
}
|
|
@@ -18518,7 +18544,7 @@ function variantsProblem(raw, src, id) {
|
|
|
18518
18544
|
if (files2.length < 2 || !files2.every((f2) => typeof f2 === "string" && f2)) return `variants needs at least two labels, each naming a file. ${shape}`;
|
|
18519
18545
|
if (!files2.includes(src)) return `src="${src}" is not one of the variants. Set src to the version shown first.`;
|
|
18520
18546
|
if (id === void 0) return null;
|
|
18521
|
-
const dir =
|
|
18547
|
+
const dir = path56.join(ASSETS, String(id));
|
|
18522
18548
|
for (const f2 of files2) {
|
|
18523
18549
|
const parts = f2.split("/");
|
|
18524
18550
|
if (parts.length !== 3 || parts[0] !== ".assets" || parts[1] !== String(id) || !inside(dir, parts[2])) {
|
|
@@ -18528,7 +18554,7 @@ function variantsProblem(raw, src, id) {
|
|
|
18528
18554
|
return null;
|
|
18529
18555
|
}
|
|
18530
18556
|
function compareProblem(attrs, id) {
|
|
18531
|
-
const dir =
|
|
18557
|
+
const dir = path56.join(ASSETS, String(id));
|
|
18532
18558
|
const src = (message) => ({ rule: "compare-src", message });
|
|
18533
18559
|
const shots = (message) => ({ rule: "compare-shots", message });
|
|
18534
18560
|
for (const side of ["a", "b"]) {
|
|
@@ -18548,7 +18574,7 @@ function compareProblem(attrs, id) {
|
|
|
18548
18574
|
const file = inside(dir, named2.name);
|
|
18549
18575
|
if (!file) return { message: `Compare shots ${at2} names no file in this card's asset folder. Write the JSON there or fix the path.` };
|
|
18550
18576
|
try {
|
|
18551
|
-
return { data: JSON.parse(
|
|
18577
|
+
return { data: JSON.parse(fs53.readFileSync(file, "utf8")) };
|
|
18552
18578
|
} catch {
|
|
18553
18579
|
return { message: `${at2} is not valid JSON.` };
|
|
18554
18580
|
}
|
|
@@ -18568,7 +18594,7 @@ function compareProblem(attrs, id) {
|
|
|
18568
18594
|
}
|
|
18569
18595
|
function validateStoryboards(file, id, text5) {
|
|
18570
18596
|
const errors = [];
|
|
18571
|
-
const dir =
|
|
18597
|
+
const dir = path56.join(ASSETS, String(id));
|
|
18572
18598
|
for (const [tag, tagOf, rule, fix] of [
|
|
18573
18599
|
["Storyboard", storyboardTag, "storyboard-src", "Write the JSON there or fix the path."],
|
|
18574
18600
|
["Workflow", workflowTag, "workflow-src", "Write it with `akb workflow diagram <workflow id> <card id>` or fix the path."]
|
|
@@ -18645,14 +18671,14 @@ var init_spec_contract = __esm({
|
|
|
18645
18671
|
});
|
|
18646
18672
|
|
|
18647
18673
|
// ../cli/src/lib/reconcile.ts
|
|
18648
|
-
import
|
|
18649
|
-
import
|
|
18674
|
+
import fs54 from "node:fs";
|
|
18675
|
+
import path57 from "node:path";
|
|
18650
18676
|
function liveIds() {
|
|
18651
18677
|
const ids = /* @__PURE__ */ new Set();
|
|
18652
18678
|
for (const file of walkMd(TODO)) {
|
|
18653
|
-
const base =
|
|
18679
|
+
const base = path57.basename(file);
|
|
18654
18680
|
if (base === "README.md") continue;
|
|
18655
|
-
const id = base === "root.md" ? idPrefix(
|
|
18681
|
+
const id = base === "root.md" ? idPrefix(path57.basename(path57.dirname(file))) : idPrefix(base);
|
|
18656
18682
|
if (id != null) ids.add(id);
|
|
18657
18683
|
}
|
|
18658
18684
|
return ids;
|
|
@@ -18660,16 +18686,16 @@ function liveIds() {
|
|
|
18660
18686
|
function indexableCards() {
|
|
18661
18687
|
const out = [];
|
|
18662
18688
|
for (const dir of walkDirs(TODO)) {
|
|
18663
|
-
const id = idPrefix(
|
|
18664
|
-
if (id != null &&
|
|
18665
|
-
out.push({ id, rel:
|
|
18689
|
+
const id = idPrefix(path57.basename(dir));
|
|
18690
|
+
if (id != null && fs54.existsSync(path57.join(dir, "root.md"))) {
|
|
18691
|
+
out.push({ id, rel: path57.join(path57.relative(TODO, dir), "root.md").split(path57.sep).join("/") });
|
|
18666
18692
|
}
|
|
18667
18693
|
}
|
|
18668
18694
|
for (const file of walkMd(TODO)) {
|
|
18669
|
-
const base =
|
|
18695
|
+
const base = path57.basename(file);
|
|
18670
18696
|
if (base === "README.md" || base === "root.md") continue;
|
|
18671
|
-
const relTODO =
|
|
18672
|
-
const segs = relTODO.split(
|
|
18697
|
+
const relTODO = path57.relative(TODO, file);
|
|
18698
|
+
const segs = relTODO.split(path57.sep);
|
|
18673
18699
|
if (segs.length !== 1) continue;
|
|
18674
18700
|
const id = idPrefix(base);
|
|
18675
18701
|
if (id != null) out.push({ id, rel: segs.join("/") });
|
|
@@ -18678,7 +18704,7 @@ function indexableCards() {
|
|
|
18678
18704
|
}
|
|
18679
18705
|
function readmeComplaints(fix) {
|
|
18680
18706
|
const said3 = [];
|
|
18681
|
-
const lines =
|
|
18707
|
+
const lines = fs54.readFileSync(README, "utf8").split("\n");
|
|
18682
18708
|
const indexed = /* @__PURE__ */ new Set();
|
|
18683
18709
|
let fixed = 0;
|
|
18684
18710
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -18687,13 +18713,13 @@ function readmeComplaints(fix) {
|
|
|
18687
18713
|
const id = Number(m[1]);
|
|
18688
18714
|
const linkPath = m[2];
|
|
18689
18715
|
indexed.add(id);
|
|
18690
|
-
if (
|
|
18716
|
+
if (fs54.existsSync(path57.join(TODO, linkPath))) continue;
|
|
18691
18717
|
const found2 = locate(id);
|
|
18692
18718
|
if (!found2) {
|
|
18693
18719
|
said3.push(`README links #${id} \u2192 ${linkPath}, but no card with that id exists (removed by hand?). Drop the entry or restore the file.`);
|
|
18694
18720
|
continue;
|
|
18695
18721
|
}
|
|
18696
|
-
const want = (found2.kind === "group" ?
|
|
18722
|
+
const want = (found2.kind === "group" ? path57.join(found2.rel, "root.md") : found2.rel).split(path57.sep).join("/");
|
|
18697
18723
|
if (want === linkPath) continue;
|
|
18698
18724
|
if (!fix) {
|
|
18699
18725
|
said3.push(`README links #${id} \u2192 ${linkPath}, which isn't there any more; the card is at ${want}.`);
|
|
@@ -18703,7 +18729,7 @@ function readmeComplaints(fix) {
|
|
|
18703
18729
|
said3.push(`README link #${id} pointed at missing ${linkPath} \u2192 repointed to ${want}.`);
|
|
18704
18730
|
fixed++;
|
|
18705
18731
|
}
|
|
18706
|
-
if (fixed)
|
|
18732
|
+
if (fixed) fs54.writeFileSync(README, lines.join("\n"));
|
|
18707
18733
|
for (const c2 of indexableCards()) {
|
|
18708
18734
|
if (!indexed.has(c2.id)) {
|
|
18709
18735
|
said3.push(`card ${c2.rel} (#${c2.id}) is not in the README index. Add it under "## ${TASKS_HEADING}".`);
|
|
@@ -18715,11 +18741,11 @@ function crossRefComplaints() {
|
|
|
18715
18741
|
const said3 = [];
|
|
18716
18742
|
const live = liveIds();
|
|
18717
18743
|
for (const file of walkMd(TODO)) {
|
|
18718
|
-
const base =
|
|
18744
|
+
const base = path57.basename(file);
|
|
18719
18745
|
if (base === "README.md") continue;
|
|
18720
|
-
const ownerId = base === "root.md" ? idPrefix(
|
|
18746
|
+
const ownerId = base === "root.md" ? idPrefix(path57.basename(path57.dirname(file))) : idPrefix(base);
|
|
18721
18747
|
if (ownerId == null) continue;
|
|
18722
|
-
const { meta } = parseFrontmatter(
|
|
18748
|
+
const { meta } = parseFrontmatter(fs54.readFileSync(file, "utf8"));
|
|
18723
18749
|
if (!meta) continue;
|
|
18724
18750
|
for (const field2 of ["blocked_by", "related"]) {
|
|
18725
18751
|
for (const ref of meta[field2] || []) {
|
|
@@ -18732,11 +18758,11 @@ function crossRefComplaints() {
|
|
|
18732
18758
|
return said3;
|
|
18733
18759
|
}
|
|
18734
18760
|
function reconcileBoard() {
|
|
18735
|
-
if (!
|
|
18761
|
+
if (!fs54.existsSync(README)) return;
|
|
18736
18762
|
for (const line of [...readmeComplaints(true), ...crossRefComplaints()]) warn2(line);
|
|
18737
18763
|
}
|
|
18738
18764
|
function boardComplaints() {
|
|
18739
|
-
if (!
|
|
18765
|
+
if (!fs54.existsSync(README)) return [];
|
|
18740
18766
|
try {
|
|
18741
18767
|
return [...readmeComplaints(false), ...crossRefComplaints()];
|
|
18742
18768
|
} catch {
|
|
@@ -18756,8 +18782,8 @@ var init_reconcile = __esm({
|
|
|
18756
18782
|
});
|
|
18757
18783
|
|
|
18758
18784
|
// ../cli/src/commands/card.ts
|
|
18759
|
-
import
|
|
18760
|
-
import
|
|
18785
|
+
import fs55 from "node:fs";
|
|
18786
|
+
import path58 from "node:path";
|
|
18761
18787
|
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>") {
|
|
18762
18788
|
return [
|
|
18763
18789
|
summary,
|
|
@@ -18783,7 +18809,7 @@ function bodyFromFile(opts) {
|
|
|
18783
18809
|
if (opts.body === false) die("pass --body-file or --no-body, not both");
|
|
18784
18810
|
let text5;
|
|
18785
18811
|
try {
|
|
18786
|
-
text5 =
|
|
18812
|
+
text5 = fs55.readFileSync(opts.bodyFile, "utf8");
|
|
18787
18813
|
} catch {
|
|
18788
18814
|
die(`can't read ${opts.bodyFile} \u2014 write the body to a file, then pass its path`, { kind: "needs-input" });
|
|
18789
18815
|
}
|
|
@@ -18863,20 +18889,20 @@ function cmdCreate(opts) {
|
|
|
18863
18889
|
const start = opts.id;
|
|
18864
18890
|
const slug2 = slugify(opts.slug !== void 0 ? opts.slug : title);
|
|
18865
18891
|
const fileRel = `${start}-${slug2}.md`;
|
|
18866
|
-
const file =
|
|
18892
|
+
const file = path58.join(TODO, fileRel);
|
|
18867
18893
|
const held4 = locate(start) ?? locateArchived(start);
|
|
18868
|
-
if (held4 &&
|
|
18894
|
+
if (held4 && path58.basename(held4.target) === `${start}-${slug2}.md`) {
|
|
18869
18895
|
say(start);
|
|
18870
18896
|
say(` ${rel(held4.target)} was already written`);
|
|
18871
18897
|
return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
|
|
18872
18898
|
}
|
|
18873
18899
|
if (held4) die(`#${start} is already a card here (${rel(held4.target)})`, { kind: "id-taken", id: start });
|
|
18874
|
-
if (
|
|
18900
|
+
if (fs55.existsSync(file)) die(`${rel(file)} already exists \u2014 pick a different --slug`);
|
|
18875
18901
|
countBoardEvent(triage ? "cards_created_proposed" : "cards_created_asked");
|
|
18876
18902
|
const meta = { title, priority, status: "todo", blocked_by, related, modules, workflow, previews, stages, triage, source, questions };
|
|
18877
18903
|
const scaffolded = !written && opts.body !== false;
|
|
18878
18904
|
const body = written ?? (scaffolded ? defaultBody() : "");
|
|
18879
|
-
|
|
18905
|
+
fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n\n" + body);
|
|
18880
18906
|
const indexed = addReadmeRef(start, title, fileRel);
|
|
18881
18907
|
say(start);
|
|
18882
18908
|
say(
|
|
@@ -18928,8 +18954,8 @@ function cmdUpdate(id, flags) {
|
|
|
18928
18954
|
if (creating) die(creating, { kind: "card-being-created", id });
|
|
18929
18955
|
const found2 = locate(id);
|
|
18930
18956
|
if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
|
|
18931
|
-
const file = found2.kind === "group" ?
|
|
18932
|
-
const { meta, body } = parseFrontmatter(
|
|
18957
|
+
const file = found2.kind === "group" ? path58.join(found2.target, "root.md") : found2.target;
|
|
18958
|
+
const { meta, body } = parseFrontmatter(fs55.readFileSync(file, "utf8"));
|
|
18933
18959
|
if (!meta) die(`${rel(file)} has no frontmatter \u2014 run \`migrate\` first`);
|
|
18934
18960
|
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");
|
|
18935
18961
|
if (flags.related !== void 0 && flags.addRelated !== void 0) die("--related replaces the list and --add-related appends to it \u2014 pass one");
|
|
@@ -19003,26 +19029,26 @@ function cmdUpdate(id, flags) {
|
|
|
19003
19029
|
meta.status = "todo";
|
|
19004
19030
|
changes.push("status\u2192todo (open questions)");
|
|
19005
19031
|
}
|
|
19006
|
-
const curRel =
|
|
19032
|
+
const curRel = path58.relative(TODO, file);
|
|
19007
19033
|
const isSubtask = found2.kind === "file" && enclosingGroupRoot(file) !== null;
|
|
19008
|
-
let base =
|
|
19034
|
+
let base = path58.basename(file);
|
|
19009
19035
|
if (flags.slug !== void 0) {
|
|
19010
19036
|
if (found2.kind === "group") die("renaming a group root by script is not supported");
|
|
19011
19037
|
base = `${id}-${slugify(flags.slug)}.md`;
|
|
19012
19038
|
}
|
|
19013
|
-
const destRel =
|
|
19014
|
-
const dest =
|
|
19039
|
+
const destRel = path58.join(path58.dirname(curRel), base);
|
|
19040
|
+
const dest = path58.join(TODO, destRel);
|
|
19015
19041
|
const moving = dest !== file;
|
|
19016
|
-
if (moving &&
|
|
19017
|
-
|
|
19018
|
-
if (moving)
|
|
19042
|
+
if (moving && fs55.existsSync(dest)) die(`${rel(dest)} already exists`);
|
|
19043
|
+
fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
|
|
19044
|
+
if (moving) fs55.renameSync(file, dest);
|
|
19019
19045
|
if (isSubtask) {
|
|
19020
19046
|
if (moving || changes.includes("title")) repointReadmeLink(id, curRel, destRel, meta.title);
|
|
19021
|
-
if (moving) changes.push(`renamed \u2192 ${destRel.split(
|
|
19047
|
+
if (moving) changes.push(`renamed \u2192 ${destRel.split(path58.sep).join("/")}`);
|
|
19022
19048
|
} else if (moving) {
|
|
19023
19049
|
stripReadmeRefs({ kind: "file", rel: curRel });
|
|
19024
19050
|
addReadmeRef(id, meta.title, destRel);
|
|
19025
|
-
changes.push(`renamed \u2192 ${destRel.split(
|
|
19051
|
+
changes.push(`renamed \u2192 ${destRel.split(path58.sep).join("/")}`);
|
|
19026
19052
|
} else if (changes.includes("title")) {
|
|
19027
19053
|
stripReadmeRefs({ kind: "file", rel: curRel });
|
|
19028
19054
|
addReadmeRef(id, meta.title, curRel);
|
|
@@ -19034,8 +19060,8 @@ function cmdUpdateQuestions(id, input) {
|
|
|
19034
19060
|
const ops = readQuestionOps(input.ops ?? []);
|
|
19035
19061
|
const found2 = locate(id);
|
|
19036
19062
|
if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
|
|
19037
|
-
const file = found2.kind === "group" ?
|
|
19038
|
-
const { meta, body } = parseFrontmatter(
|
|
19063
|
+
const file = found2.kind === "group" ? path58.join(found2.target, "root.md") : found2.target;
|
|
19064
|
+
const { meta, body } = parseFrontmatter(fs55.readFileSync(file, "utf8"));
|
|
19039
19065
|
if (!meta) die(`${rel(file)} has no frontmatter \u2014 run \`migrate\` first`);
|
|
19040
19066
|
if (insideRun() && ops.some((op) => op.kind === "skip" || op.kind === "unskip")) {
|
|
19041
19067
|
die("only the user skips or reopens a question \u2014 a run leaves questions for them to answer");
|
|
@@ -19108,7 +19134,7 @@ function cmdUpdateQuestions(id, input) {
|
|
|
19108
19134
|
meta.status = "todo";
|
|
19109
19135
|
changes.push("status\u2192todo (open questions)");
|
|
19110
19136
|
}
|
|
19111
|
-
|
|
19137
|
+
fs55.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
|
|
19112
19138
|
for (const kind of closed2) countBoardEvent(kind);
|
|
19113
19139
|
settleDelivery2(id, skipped, unskipped);
|
|
19114
19140
|
say(
|
|
@@ -19184,13 +19210,13 @@ var init_config_template = __esm({
|
|
|
19184
19210
|
});
|
|
19185
19211
|
|
|
19186
19212
|
// ../cli/src/lib/agent/local.ts
|
|
19187
|
-
import
|
|
19188
|
-
import
|
|
19213
|
+
import fs56 from "node:fs";
|
|
19214
|
+
import path59 from "node:path";
|
|
19189
19215
|
function takeLocalModels(board2) {
|
|
19190
|
-
const file =
|
|
19216
|
+
const file = path59.join(board2, ".local.json");
|
|
19191
19217
|
let held4;
|
|
19192
19218
|
try {
|
|
19193
|
-
held4 = configBlock(JSON.parse(
|
|
19219
|
+
held4 = configBlock(JSON.parse(fs56.readFileSync(file, "utf8")));
|
|
19194
19220
|
} catch {
|
|
19195
19221
|
return {};
|
|
19196
19222
|
}
|
|
@@ -19208,7 +19234,7 @@ function takeLocalModels(board2) {
|
|
|
19208
19234
|
}
|
|
19209
19235
|
if (!Object.keys(agents).length) return out;
|
|
19210
19236
|
delete held4.agents;
|
|
19211
|
-
|
|
19237
|
+
fs56.writeFileSync(file, JSON.stringify(held4, null, 2) + "\n");
|
|
19212
19238
|
return out;
|
|
19213
19239
|
}
|
|
19214
19240
|
var LOCAL_IGNORE_LINE;
|
|
@@ -19269,12 +19295,12 @@ var init_identity2 = __esm({
|
|
|
19269
19295
|
});
|
|
19270
19296
|
|
|
19271
19297
|
// ../cli/src/lib/signals/migrate.ts
|
|
19272
|
-
import
|
|
19273
|
-
import
|
|
19298
|
+
import fs57 from "node:fs";
|
|
19299
|
+
import path60 from "node:path";
|
|
19274
19300
|
function readHandled() {
|
|
19275
19301
|
let text5;
|
|
19276
19302
|
try {
|
|
19277
|
-
text5 =
|
|
19303
|
+
text5 = fs57.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
|
|
19278
19304
|
} catch {
|
|
19279
19305
|
return [];
|
|
19280
19306
|
}
|
|
@@ -19291,57 +19317,57 @@ function readHandled() {
|
|
|
19291
19317
|
return held4;
|
|
19292
19318
|
}
|
|
19293
19319
|
function lift(from, into) {
|
|
19294
|
-
|
|
19295
|
-
|
|
19320
|
+
fs57.mkdirSync(into, { recursive: true });
|
|
19321
|
+
fs57.renameSync(from, path60.join(into, freeName(into, path60.basename(from))));
|
|
19296
19322
|
}
|
|
19297
19323
|
function repoint(dir, from, into) {
|
|
19298
19324
|
let entries;
|
|
19299
19325
|
try {
|
|
19300
|
-
entries =
|
|
19326
|
+
entries = fs57.readdirSync(dir, { withFileTypes: true });
|
|
19301
19327
|
} catch {
|
|
19302
19328
|
return;
|
|
19303
19329
|
}
|
|
19304
19330
|
for (const entry of entries) {
|
|
19305
19331
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
19306
|
-
const file =
|
|
19307
|
-
const text5 =
|
|
19308
|
-
if (text5.includes(from))
|
|
19332
|
+
const file = path60.join(dir, entry.name);
|
|
19333
|
+
const text5 = fs57.readFileSync(file, "utf8");
|
|
19334
|
+
if (text5.includes(from)) fs57.writeFileSync(file, text5.split(from).join(into));
|
|
19309
19335
|
}
|
|
19310
19336
|
}
|
|
19311
19337
|
function dropIfEmpty2(dir) {
|
|
19312
19338
|
try {
|
|
19313
|
-
|
|
19339
|
+
fs57.rmdirSync(dir);
|
|
19314
19340
|
} catch {
|
|
19315
19341
|
}
|
|
19316
19342
|
}
|
|
19317
19343
|
function liftInbox() {
|
|
19318
|
-
if (!
|
|
19319
|
-
const oldFiles =
|
|
19320
|
-
if (
|
|
19321
|
-
for (const entry of
|
|
19322
|
-
if (entry.isFile()) lift(
|
|
19344
|
+
if (!fs57.existsSync(SIGNALS_OLD_INBOX)) return;
|
|
19345
|
+
const oldFiles = path60.join(SIGNALS_OLD_INBOX, "files");
|
|
19346
|
+
if (fs57.existsSync(oldFiles)) {
|
|
19347
|
+
for (const entry of fs57.readdirSync(oldFiles, { withFileTypes: true })) {
|
|
19348
|
+
if (entry.isFile()) lift(path60.join(oldFiles, entry.name), SIGNALS_FILES);
|
|
19323
19349
|
}
|
|
19324
19350
|
dropIfEmpty2(oldFiles);
|
|
19325
19351
|
}
|
|
19326
19352
|
const held4 = new Set(readFolder2(TRIAGE).map((signal2) => signal2.sourceId));
|
|
19327
|
-
for (const entry of
|
|
19353
|
+
for (const entry of fs57.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
|
|
19328
19354
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
19329
|
-
const from =
|
|
19355
|
+
const from = path60.join(SIGNALS_OLD_INBOX, entry.name);
|
|
19330
19356
|
const item = parse(from);
|
|
19331
19357
|
if (item && held4.has(item.sourceId)) {
|
|
19332
|
-
|
|
19358
|
+
fs57.rmSync(from, { force: true });
|
|
19333
19359
|
continue;
|
|
19334
19360
|
}
|
|
19335
19361
|
if (item) held4.add(item.sourceId);
|
|
19336
19362
|
lift(from, TRIAGE);
|
|
19337
19363
|
}
|
|
19338
|
-
const wasAt = asWritten(
|
|
19364
|
+
const wasAt = asWritten(path60.join(SIGNALS_OLD_INBOX, "files"));
|
|
19339
19365
|
const nowAt = asWritten(SIGNALS_FILES);
|
|
19340
19366
|
for (const dir of [TRIAGE, SIGNALS_ARCHIVED, SIGNALS_DISMISSED]) repoint(dir, wasAt, nowAt);
|
|
19341
19367
|
dropIfEmpty2(SIGNALS_OLD_INBOX);
|
|
19342
19368
|
}
|
|
19343
19369
|
function liftHandled() {
|
|
19344
|
-
if (!
|
|
19370
|
+
if (!fs57.existsSync(SIGNALS_OLD_HANDLED)) return;
|
|
19345
19371
|
const lines = readHandled();
|
|
19346
19372
|
const held4 = /* @__PURE__ */ new Set([
|
|
19347
19373
|
...readFolder2(TRIAGE).map((signal2) => signal2.sourceId),
|
|
@@ -19351,7 +19377,7 @@ function liftHandled() {
|
|
|
19351
19377
|
for (const { sourceId, when } of lines) {
|
|
19352
19378
|
if (held4.has(sourceId)) continue;
|
|
19353
19379
|
held4.add(sourceId);
|
|
19354
|
-
|
|
19380
|
+
fs57.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
|
|
19355
19381
|
const name = freeName(SIGNALS_DISMISSED, fileName("", sourceId));
|
|
19356
19382
|
const front = [
|
|
19357
19383
|
"---",
|
|
@@ -19361,13 +19387,13 @@ function liftHandled() {
|
|
|
19361
19387
|
"---",
|
|
19362
19388
|
""
|
|
19363
19389
|
];
|
|
19364
|
-
|
|
19390
|
+
fs57.writeFileSync(path60.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
|
|
19365
19391
|
`);
|
|
19366
19392
|
}
|
|
19367
|
-
|
|
19393
|
+
fs57.rmSync(SIGNALS_OLD_HANDLED, { force: true });
|
|
19368
19394
|
}
|
|
19369
19395
|
function migrateTriage() {
|
|
19370
|
-
if (!
|
|
19396
|
+
if (!fs57.existsSync(SIGNALS_OLD_INBOX) && !fs57.existsSync(SIGNALS_OLD_HANDLED)) return;
|
|
19371
19397
|
try {
|
|
19372
19398
|
liftInbox();
|
|
19373
19399
|
liftHandled();
|
|
@@ -19382,13 +19408,13 @@ var init_migrate = __esm({
|
|
|
19382
19408
|
init_yaml();
|
|
19383
19409
|
init_inbox();
|
|
19384
19410
|
HANDLED_LINE = /^-\s+(.+?)\s+—\s+(.+)$/;
|
|
19385
|
-
asWritten = (dir) => `${rel(dir).split(
|
|
19411
|
+
asWritten = (dir) => `${rel(dir).split(path60.sep).join("/")}/`;
|
|
19386
19412
|
}
|
|
19387
19413
|
});
|
|
19388
19414
|
|
|
19389
19415
|
// ../cli/src/lib/signals/add.ts
|
|
19390
|
-
import
|
|
19391
|
-
import
|
|
19416
|
+
import fs58 from "node:fs";
|
|
19417
|
+
import path61 from "node:path";
|
|
19392
19418
|
import { createHash as createHash4 } from "node:crypto";
|
|
19393
19419
|
function linkTitle(url) {
|
|
19394
19420
|
let at2;
|
|
@@ -19401,7 +19427,7 @@ function linkTitle(url) {
|
|
|
19401
19427
|
return oneLine(where) || url.slice(0, TITLE_MAX);
|
|
19402
19428
|
}
|
|
19403
19429
|
function asText(file) {
|
|
19404
|
-
const ext =
|
|
19430
|
+
const ext = path61.extname(file.name).toLowerCase();
|
|
19405
19431
|
if (!file.type.startsWith("text/") && file.type !== "application/json" && !TEXT_EXTENSIONS.has(ext)) return null;
|
|
19406
19432
|
try {
|
|
19407
19433
|
const text5 = new TextDecoder("utf-8", { fatal: true }).decode(file.data);
|
|
@@ -19411,9 +19437,9 @@ function asText(file) {
|
|
|
19411
19437
|
}
|
|
19412
19438
|
}
|
|
19413
19439
|
function fileName2(name, data) {
|
|
19414
|
-
const base =
|
|
19415
|
-
const ext =
|
|
19416
|
-
const word =
|
|
19440
|
+
const base = path61.basename(name);
|
|
19441
|
+
const ext = path61.extname(base).toLowerCase().slice(0, 12);
|
|
19442
|
+
const word = path61.basename(base, path61.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
|
|
19417
19443
|
const hash2 = createHash4("sha256").update(data).digest("hex").slice(0, 8);
|
|
19418
19444
|
return `${word}-${hash2}${ext}`;
|
|
19419
19445
|
}
|
|
@@ -19422,9 +19448,9 @@ function addToInbox(drop) {
|
|
|
19422
19448
|
const typed = (drop.text ?? "").trim();
|
|
19423
19449
|
const file = drop.file;
|
|
19424
19450
|
if (!typed && !file) return { ok: false, error: "nothing to add \u2014 paste a link or some text, or drop a file." };
|
|
19425
|
-
if (file && file.data.length === 0) return { ok: false, error: `${
|
|
19451
|
+
if (file && file.data.length === 0) return { ok: false, error: `${path61.basename(file.name)} is empty.` };
|
|
19426
19452
|
if (file && file.data.length > MAX_BYTES) {
|
|
19427
|
-
return { ok: false, error: `${
|
|
19453
|
+
return { ok: false, error: `${path61.basename(file.name)} is over ${MAX_BYTES / 1024 / 1024} MB \u2014 too big for the board.` };
|
|
19428
19454
|
}
|
|
19429
19455
|
const read5 = describe(typed, file);
|
|
19430
19456
|
const keep2 = read5.keep;
|
|
@@ -19446,8 +19472,8 @@ ${incoming.summary}`);
|
|
|
19446
19472
|
if (seen.status === "pending" || seen.status === "archived") return { ok: false, error: `${sayHit(seen)}.` };
|
|
19447
19473
|
try {
|
|
19448
19474
|
if (keep2) {
|
|
19449
|
-
|
|
19450
|
-
|
|
19475
|
+
fs58.mkdirSync(SIGNALS_FILES, { recursive: true });
|
|
19476
|
+
fs58.writeFileSync(keep2.at, keep2.data);
|
|
19451
19477
|
}
|
|
19452
19478
|
return { ok: true, signal: writeSignal({ ...incoming, sourceId }, formatStamp(/* @__PURE__ */ new Date()), drop.slug) };
|
|
19453
19479
|
} catch (e2) {
|
|
@@ -19461,7 +19487,7 @@ function describe(typed, file) {
|
|
|
19461
19487
|
return only ? [only] : [];
|
|
19462
19488
|
};
|
|
19463
19489
|
if (file) {
|
|
19464
|
-
const name =
|
|
19490
|
+
const name = path61.basename(file.name);
|
|
19465
19491
|
const text5 = asText(file);
|
|
19466
19492
|
const note = typed ? `
|
|
19467
19493
|
|
|
@@ -19473,7 +19499,7 @@ ${typed}` : "";
|
|
|
19473
19499
|
const at2 = keepAt(file);
|
|
19474
19500
|
return {
|
|
19475
19501
|
incoming: {
|
|
19476
|
-
title:
|
|
19502
|
+
title: path61.basename(name, path61.extname(name)) || name,
|
|
19477
19503
|
summary: `${name} \u2014 ${boardRel2(at2)}${note}`,
|
|
19478
19504
|
...named2
|
|
19479
19505
|
},
|
|
@@ -19511,73 +19537,73 @@ var init_add = __esm({
|
|
|
19511
19537
|
MAX_BYTES = 25 * 1024 * 1024;
|
|
19512
19538
|
TITLE_MAX = 120;
|
|
19513
19539
|
TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".text", ".csv", ".json", ".yml", ".yaml", ".log"]);
|
|
19514
|
-
boardRel2 = (file) => rel(file).split(
|
|
19540
|
+
boardRel2 = (file) => rel(file).split(path61.sep).join("/");
|
|
19515
19541
|
oneLine = (text5) => {
|
|
19516
19542
|
const first = text5.split("\n").find((line) => line.trim()) ?? "";
|
|
19517
19543
|
const clean = first.replace(/^#+\s*/, "").trim();
|
|
19518
19544
|
return clean.length > TITLE_MAX ? `${clean.slice(0, TITLE_MAX - 1).trimEnd()}\u2026` : clean;
|
|
19519
19545
|
};
|
|
19520
|
-
keepAt = (file) =>
|
|
19546
|
+
keepAt = (file) => path61.join(SIGNALS_FILES, fileName2(file.name, file.data));
|
|
19521
19547
|
}
|
|
19522
19548
|
});
|
|
19523
19549
|
|
|
19524
19550
|
// ../cli/src/lib/recurring.ts
|
|
19525
|
-
import
|
|
19526
|
-
import
|
|
19551
|
+
import fs59 from "node:fs";
|
|
19552
|
+
import path62 from "node:path";
|
|
19527
19553
|
function migratePruneMemoryCard() {
|
|
19528
19554
|
const dir = recurringDir();
|
|
19529
19555
|
let names3;
|
|
19530
19556
|
try {
|
|
19531
|
-
names3 =
|
|
19557
|
+
names3 = fs59.readdirSync(dir);
|
|
19532
19558
|
} catch {
|
|
19533
19559
|
return null;
|
|
19534
19560
|
}
|
|
19535
19561
|
const name = names3.find((entry) => entry.endsWith(`-${PRUNE_SLUG}.md`));
|
|
19536
19562
|
if (!name) return null;
|
|
19537
|
-
const file =
|
|
19563
|
+
const file = path62.join(dir, name);
|
|
19538
19564
|
try {
|
|
19539
|
-
const { meta } = parseFrontmatter(
|
|
19565
|
+
const { meta } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
|
|
19540
19566
|
const cadence = meta?.cadence;
|
|
19541
19567
|
if (typeof cadence === "string") adoptMemoryPruneCadence(cadence);
|
|
19542
19568
|
} catch {
|
|
19543
19569
|
}
|
|
19544
|
-
|
|
19570
|
+
fs59.rmSync(file, { force: true });
|
|
19545
19571
|
return rel(file);
|
|
19546
19572
|
}
|
|
19547
19573
|
function legacyCards() {
|
|
19548
19574
|
const dir = recurringDir();
|
|
19549
|
-
if (!
|
|
19575
|
+
if (!fs59.existsSync(dir)) return [];
|
|
19550
19576
|
const cards = [];
|
|
19551
|
-
for (const entry of
|
|
19577
|
+
for (const entry of fs59.readdirSync(dir, { withFileTypes: true })) {
|
|
19552
19578
|
const id = idPrefix(entry.name);
|
|
19553
19579
|
if (id === null) continue;
|
|
19554
|
-
const full =
|
|
19580
|
+
const full = path62.join(dir, entry.name);
|
|
19555
19581
|
const slug2 = entry.name.replace(/\.md$/, "").replace(/^\d+-?/, "");
|
|
19556
19582
|
if (entry.isFile() && entry.name.endsWith(".md")) cards.push({ id, slug: slug2, file: full });
|
|
19557
|
-
else if (entry.isDirectory() &&
|
|
19558
|
-
cards.push({ id, slug: slug2, file:
|
|
19583
|
+
else if (entry.isDirectory() && fs59.existsSync(path62.join(full, "root.md"))) {
|
|
19584
|
+
cards.push({ id, slug: slug2, file: path62.join(full, "root.md"), folder: full });
|
|
19559
19585
|
}
|
|
19560
19586
|
}
|
|
19561
19587
|
return cards.sort((a2, b2) => a2.id - b2.id);
|
|
19562
19588
|
}
|
|
19563
19589
|
function mergeInto2(from, to, skip = []) {
|
|
19564
|
-
|
|
19565
|
-
for (const entry of
|
|
19590
|
+
fs59.mkdirSync(to, { recursive: true });
|
|
19591
|
+
for (const entry of fs59.readdirSync(from, { withFileTypes: true })) {
|
|
19566
19592
|
if (skip.includes(entry.name)) continue;
|
|
19567
|
-
const source =
|
|
19568
|
-
const target =
|
|
19569
|
-
if (!
|
|
19570
|
-
else if (entry.isDirectory() &&
|
|
19593
|
+
const source = path62.join(from, entry.name);
|
|
19594
|
+
const target = path62.join(to, entry.name);
|
|
19595
|
+
if (!fs59.existsSync(target)) fs59.renameSync(source, target);
|
|
19596
|
+
else if (entry.isDirectory() && fs59.statSync(target).isDirectory()) mergeInto2(source, target);
|
|
19571
19597
|
}
|
|
19572
|
-
if (isEmpty(from))
|
|
19598
|
+
if (isEmpty(from)) fs59.rmSync(from, { recursive: true, force: true });
|
|
19573
19599
|
}
|
|
19574
19600
|
function moveSideFolders() {
|
|
19575
19601
|
const dir = recurringDir();
|
|
19576
|
-
for (const entry of
|
|
19602
|
+
for (const entry of fs59.readdirSync(dir, { withFileTypes: true })) {
|
|
19577
19603
|
if (!entry.isDirectory() || idPrefix(entry.name) !== null) continue;
|
|
19578
|
-
const from =
|
|
19579
|
-
if (isEmpty(from))
|
|
19580
|
-
else mergeInto2(from,
|
|
19604
|
+
const from = path62.join(dir, entry.name);
|
|
19605
|
+
if (isEmpty(from)) fs59.rmSync(from, { recursive: true, force: true });
|
|
19606
|
+
else mergeInto2(from, path62.join(AGENTS, entry.name));
|
|
19581
19607
|
}
|
|
19582
19608
|
}
|
|
19583
19609
|
function sections(body) {
|
|
@@ -19627,8 +19653,8 @@ function agentName(card, text5) {
|
|
|
19627
19653
|
const known2 = /* @__PURE__ */ new Set([...specAgentCatalog().agents.map((a2) => a2.name), ...ROLE_NAMES]);
|
|
19628
19654
|
for (const name of [slug2, `${slug2}-${card.id}`]) {
|
|
19629
19655
|
if (!AGENT_NAME.test(name)) continue;
|
|
19630
|
-
const file =
|
|
19631
|
-
const written =
|
|
19656
|
+
const file = path62.join(AGENTS, name, AGENT_FILE2);
|
|
19657
|
+
const written = fs59.existsSync(file) ? fs59.readFileSync(file, "utf8") : null;
|
|
19632
19658
|
if (written === text5(name)) return name;
|
|
19633
19659
|
if (written === null && !known2.has(name)) return name;
|
|
19634
19660
|
}
|
|
@@ -19645,11 +19671,11 @@ ${q3.options.map((o3) => `- ${o3}`).join("\n")}` : "";
|
|
|
19645
19671
|
function removeCard(card) {
|
|
19646
19672
|
dropCrossRefs(card.id);
|
|
19647
19673
|
const target = card.folder ?? card.file;
|
|
19648
|
-
stripReadmeRefs({ kind: card.folder ? "group" : "file", rel:
|
|
19649
|
-
|
|
19674
|
+
stripReadmeRefs({ kind: card.folder ? "group" : "file", rel: path62.relative(TODO, target).split(path62.sep).join("/") });
|
|
19675
|
+
fs59.rmSync(target, { recursive: true, force: true });
|
|
19650
19676
|
}
|
|
19651
19677
|
function migrateCard(card) {
|
|
19652
|
-
const { meta, body } = parseFrontmatter(
|
|
19678
|
+
const { meta, body } = parseFrontmatter(fs59.readFileSync(card.file, "utf8"));
|
|
19653
19679
|
if (!meta) throw new Error("its frontmatter cannot be read");
|
|
19654
19680
|
const raw = meta;
|
|
19655
19681
|
const said3 = (key) => typeof raw[key] === "string" ? raw[key].trim() : "";
|
|
@@ -19659,19 +19685,19 @@ function migrateCard(card) {
|
|
|
19659
19685
|
if (!flow) throw new Error(noWorkflowMessage(""));
|
|
19660
19686
|
const text5 = (name2) => agentText(name2, meta.title || card.slug, body);
|
|
19661
19687
|
const name = agentName(card, text5);
|
|
19662
|
-
const dir =
|
|
19663
|
-
const file =
|
|
19664
|
-
const madeDir = !
|
|
19665
|
-
const wrote = !
|
|
19688
|
+
const dir = path62.join(AGENTS, name);
|
|
19689
|
+
const file = path62.join(dir, AGENT_FILE2);
|
|
19690
|
+
const madeDir = !fs59.existsSync(dir);
|
|
19691
|
+
const wrote = !fs59.existsSync(file);
|
|
19666
19692
|
try {
|
|
19667
|
-
|
|
19668
|
-
if (wrote)
|
|
19693
|
+
fs59.mkdirSync(dir, { recursive: true });
|
|
19694
|
+
if (wrote) fs59.writeFileSync(file, text5(name));
|
|
19669
19695
|
const adopted = adoptWorkflowScheduled(flow.id, name, { cadence, lastRun });
|
|
19670
19696
|
if (!adopted.ok) throw new Error(adopted.error);
|
|
19671
19697
|
questionsToTriage(meta, name);
|
|
19672
19698
|
} catch (e2) {
|
|
19673
|
-
if (madeDir)
|
|
19674
|
-
else if (wrote)
|
|
19699
|
+
if (madeDir) fs59.rmSync(dir, { recursive: true, force: true });
|
|
19700
|
+
else if (wrote) fs59.rmSync(file, { force: true });
|
|
19675
19701
|
throw e2;
|
|
19676
19702
|
}
|
|
19677
19703
|
if (card.folder) mergeInto2(card.folder, dir, ["root.md"]);
|
|
@@ -19681,7 +19707,7 @@ function migrateCard(card) {
|
|
|
19681
19707
|
function migrateRecurringCards() {
|
|
19682
19708
|
const done2 = { agents: [], removed: [], failed: [] };
|
|
19683
19709
|
const dir = recurringDir();
|
|
19684
|
-
if (!
|
|
19710
|
+
if (!fs59.existsSync(dir)) return done2;
|
|
19685
19711
|
migratePruneMemoryCard();
|
|
19686
19712
|
moveSideFolders();
|
|
19687
19713
|
for (const card of legacyCards()) {
|
|
@@ -19694,7 +19720,7 @@ function migrateRecurringCards() {
|
|
|
19694
19720
|
done2.failed.push({ card: rel(card.file), why: e2 instanceof Error ? e2.message : String(e2) });
|
|
19695
19721
|
}
|
|
19696
19722
|
}
|
|
19697
|
-
if (isEmpty(dir))
|
|
19723
|
+
if (isEmpty(dir)) fs59.rmSync(dir, { recursive: true, force: true });
|
|
19698
19724
|
return done2;
|
|
19699
19725
|
}
|
|
19700
19726
|
function recurringMigrationLines(done2) {
|
|
@@ -19727,14 +19753,14 @@ var init_recurring = __esm({
|
|
|
19727
19753
|
PRUNE_SLUG = "prune-the-memory";
|
|
19728
19754
|
FETCH_SLUG = "fetch-triage-items";
|
|
19729
19755
|
AGENT_FILE2 = "AGENT.md";
|
|
19730
|
-
recurringDir = () =>
|
|
19731
|
-
isEmpty = (dir) =>
|
|
19756
|
+
recurringDir = () => path62.join(TODO, LEGACY_RECURRING);
|
|
19757
|
+
isEmpty = (dir) => fs59.readdirSync(dir).every((name) => name === ".DS_Store");
|
|
19732
19758
|
SECTION = /^##\s+(.+?)\s*$/;
|
|
19733
19759
|
}
|
|
19734
19760
|
});
|
|
19735
19761
|
|
|
19736
19762
|
// ../cli/src/commands/init.ts
|
|
19737
|
-
import
|
|
19763
|
+
import fs60 from "node:fs";
|
|
19738
19764
|
function boardReadme() {
|
|
19739
19765
|
return `# Board
|
|
19740
19766
|
|
|
@@ -19747,20 +19773,20 @@ _(none)_
|
|
|
19747
19773
|
`;
|
|
19748
19774
|
}
|
|
19749
19775
|
function writeConfigIfMissing() {
|
|
19750
|
-
if (
|
|
19751
|
-
|
|
19752
|
-
|
|
19776
|
+
if (fs60.existsSync(CONFIG)) return false;
|
|
19777
|
+
fs60.mkdirSync(KANBAN, { recursive: true });
|
|
19778
|
+
fs60.writeFileSync(CONFIG, CONFIG_TEMPLATE);
|
|
19753
19779
|
return true;
|
|
19754
19780
|
}
|
|
19755
19781
|
function writeModulesIfMissing() {
|
|
19756
|
-
if (
|
|
19757
|
-
|
|
19758
|
-
|
|
19782
|
+
if (fs60.existsSync(MODULES_MD)) return false;
|
|
19783
|
+
fs60.mkdirSync(KANBAN, { recursive: true });
|
|
19784
|
+
fs60.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
|
|
19759
19785
|
return true;
|
|
19760
19786
|
}
|
|
19761
19787
|
function writeGitignoreIfMissing() {
|
|
19762
|
-
|
|
19763
|
-
const text5 =
|
|
19788
|
+
fs60.mkdirSync(KANBAN, { recursive: true });
|
|
19789
|
+
const text5 = fs60.existsSync(KANBAN_GITIGNORE) ? fs60.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
|
|
19764
19790
|
const has = (rule) => text5.split("\n").some((line) => line.trim() === rule.line);
|
|
19765
19791
|
const missing = IGNORE_RULES.filter((rule) => !has(rule));
|
|
19766
19792
|
if (!missing.length) return false;
|
|
@@ -19768,37 +19794,37 @@ function writeGitignoreIfMissing() {
|
|
|
19768
19794
|
${rule.line}
|
|
19769
19795
|
`).join("");
|
|
19770
19796
|
const separator = !text5 || text5.endsWith("\n") ? "" : "\n";
|
|
19771
|
-
|
|
19797
|
+
fs60.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${block}`);
|
|
19772
19798
|
return true;
|
|
19773
19799
|
}
|
|
19774
19800
|
function writeSkeletonIfMissing() {
|
|
19775
19801
|
const added = [];
|
|
19776
|
-
if (!
|
|
19777
|
-
|
|
19802
|
+
if (!fs60.existsSync(TODO)) {
|
|
19803
|
+
fs60.mkdirSync(TODO, { recursive: true });
|
|
19778
19804
|
added.push(`${rel(TODO)}/`);
|
|
19779
19805
|
}
|
|
19780
|
-
if (!
|
|
19781
|
-
|
|
19806
|
+
if (!fs60.existsSync(README)) {
|
|
19807
|
+
fs60.writeFileSync(README, boardReadme());
|
|
19782
19808
|
added.push(rel(README));
|
|
19783
19809
|
}
|
|
19784
19810
|
return added;
|
|
19785
19811
|
}
|
|
19786
19812
|
function retireReleases() {
|
|
19787
19813
|
const done2 = [];
|
|
19788
|
-
if (
|
|
19789
|
-
|
|
19814
|
+
if (fs60.existsSync(RELEASES)) {
|
|
19815
|
+
fs60.rmSync(RELEASES);
|
|
19790
19816
|
done2.push(`deleted ${rel(RELEASES)}`);
|
|
19791
19817
|
}
|
|
19792
19818
|
let cards = 0;
|
|
19793
19819
|
for (const dir of [TODO, ARCHIVE]) {
|
|
19794
|
-
if (!
|
|
19820
|
+
if (!fs60.existsSync(dir)) continue;
|
|
19795
19821
|
for (const file of walkMd(dir)) {
|
|
19796
|
-
const text5 =
|
|
19822
|
+
const text5 = fs60.readFileSync(file, "utf8");
|
|
19797
19823
|
const end2 = text5.startsWith("---\n") ? text5.indexOf("\n---", 3) : -1;
|
|
19798
19824
|
if (end2 < 0) continue;
|
|
19799
19825
|
const head2 = text5.slice(0, end2).replace(/\nrelease:[^\n]*/, "");
|
|
19800
19826
|
if (head2.length === end2) continue;
|
|
19801
|
-
|
|
19827
|
+
fs60.writeFileSync(file, head2 + text5.slice(end2));
|
|
19802
19828
|
cards++;
|
|
19803
19829
|
}
|
|
19804
19830
|
}
|
|
@@ -19806,7 +19832,7 @@ function retireReleases() {
|
|
|
19806
19832
|
return done2.join(", ");
|
|
19807
19833
|
}
|
|
19808
19834
|
function cmdInit() {
|
|
19809
|
-
if (
|
|
19835
|
+
if (fs60.existsSync(KANBAN)) {
|
|
19810
19836
|
const added = [
|
|
19811
19837
|
...writeSkeletonIfMissing(),
|
|
19812
19838
|
writeConfigIfMissing() && rel(CONFIG),
|
|
@@ -19841,8 +19867,8 @@ function cmdInit() {
|
|
|
19841
19867
|
}
|
|
19842
19868
|
return { board: rel(KANBAN), created: false, added, memory_paths: scaffolded.map((s) => rel(s.dir)) };
|
|
19843
19869
|
}
|
|
19844
|
-
|
|
19845
|
-
|
|
19870
|
+
fs60.mkdirSync(TODO, { recursive: true });
|
|
19871
|
+
fs60.writeFileSync(README, boardReadme());
|
|
19846
19872
|
writeConfigIfMissing();
|
|
19847
19873
|
scaffoldProjectMemory();
|
|
19848
19874
|
writeModulesIfMissing();
|
|
@@ -19931,25 +19957,25 @@ var init_scheduled = __esm({
|
|
|
19931
19957
|
});
|
|
19932
19958
|
|
|
19933
19959
|
// ../cli/src/lib/card-age.ts
|
|
19934
|
-
import
|
|
19935
|
-
import
|
|
19960
|
+
import fs61 from "node:fs";
|
|
19961
|
+
import path63 from "node:path";
|
|
19936
19962
|
function staleAfterIn(config) {
|
|
19937
19963
|
const days = Number(LINE.exec(config)?.[1]);
|
|
19938
19964
|
return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
|
|
19939
19965
|
}
|
|
19940
19966
|
function staleAfter() {
|
|
19941
|
-
if (!
|
|
19942
|
-
return staleAfterIn(
|
|
19967
|
+
if (!fs61.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
|
|
19968
|
+
return staleAfterIn(fs61.readFileSync(CONFIG, "utf8"));
|
|
19943
19969
|
}
|
|
19944
19970
|
function todoPathspec(top) {
|
|
19945
|
-
const from =
|
|
19946
|
-
if (!from || from.startsWith("..") ||
|
|
19947
|
-
return from.split(
|
|
19971
|
+
const from = path63.relative(real(top), real(TODO));
|
|
19972
|
+
if (!from || from.startsWith("..") || path63.isAbsolute(from)) return null;
|
|
19973
|
+
return from.split(path63.sep).join("/");
|
|
19948
19974
|
}
|
|
19949
19975
|
function cardFile2(spec, printed) {
|
|
19950
19976
|
const p2 = unquotePath(printed);
|
|
19951
19977
|
if (!p2.startsWith(`${spec}/`)) return null;
|
|
19952
|
-
return
|
|
19978
|
+
return path63.join(TODO, ...p2.slice(spec.length + 1).split("/"));
|
|
19953
19979
|
}
|
|
19954
19980
|
function dirtyCards(top, spec) {
|
|
19955
19981
|
const out = git(["status", "--porcelain", "--untracked-files=all", "--", spec], top);
|
|
@@ -19996,9 +20022,9 @@ var init_card_age = __esm({
|
|
|
19996
20022
|
gitTop = () => git(["rev-parse", "--show-toplevel"])?.trim() || null;
|
|
19997
20023
|
real = (p2) => {
|
|
19998
20024
|
try {
|
|
19999
|
-
return
|
|
20025
|
+
return fs61.realpathSync(p2);
|
|
20000
20026
|
} catch {
|
|
20001
|
-
return
|
|
20027
|
+
return path63.resolve(p2);
|
|
20002
20028
|
}
|
|
20003
20029
|
};
|
|
20004
20030
|
unquotePath = (line) => {
|
|
@@ -20033,8 +20059,8 @@ var init_card_holds = __esm({
|
|
|
20033
20059
|
});
|
|
20034
20060
|
|
|
20035
20061
|
// ../cli/src/commands/list.ts
|
|
20036
|
-
import
|
|
20037
|
-
import
|
|
20062
|
+
import fs62 from "node:fs";
|
|
20063
|
+
import path64 from "node:path";
|
|
20038
20064
|
function summaryLine(body) {
|
|
20039
20065
|
const lines = body.split("\n");
|
|
20040
20066
|
let i = 0;
|
|
@@ -20050,13 +20076,13 @@ function summaryLine(body) {
|
|
|
20050
20076
|
function openRows() {
|
|
20051
20077
|
const rows = [];
|
|
20052
20078
|
for (const file of walkMd(TODO)) {
|
|
20053
|
-
const base =
|
|
20079
|
+
const base = path64.basename(file);
|
|
20054
20080
|
if (base === "README.md") continue;
|
|
20055
20081
|
const isRoot = base === "root.md";
|
|
20056
|
-
const id = isRoot ? idPrefix(
|
|
20082
|
+
const id = isRoot ? idPrefix(path64.basename(path64.dirname(file))) : idPrefix(base);
|
|
20057
20083
|
if (id == null) continue;
|
|
20058
|
-
if (isLegacyRecurring(
|
|
20059
|
-
const { meta, body } = parseFrontmatter(
|
|
20084
|
+
if (isLegacyRecurring(path64.relative(TODO, file))) continue;
|
|
20085
|
+
const { meta, body } = parseFrontmatter(fs62.readFileSync(file, "utf8"));
|
|
20060
20086
|
rows.push({
|
|
20061
20087
|
id,
|
|
20062
20088
|
file,
|
|
@@ -20098,15 +20124,15 @@ function cmdStale(rows, all2, scope, mod) {
|
|
|
20098
20124
|
}
|
|
20099
20125
|
function archivedFiles() {
|
|
20100
20126
|
const files2 = /* @__PURE__ */ new Map();
|
|
20101
|
-
if (!
|
|
20127
|
+
if (!fs62.existsSync(ARCHIVE)) return files2;
|
|
20102
20128
|
for (const file of walkMd(ARCHIVE)) {
|
|
20103
|
-
const id = idPrefix(
|
|
20129
|
+
const id = idPrefix(path64.basename(file));
|
|
20104
20130
|
if (id !== null) files2.set(id, file);
|
|
20105
20131
|
}
|
|
20106
20132
|
for (const dir of walkDirs(ARCHIVE)) {
|
|
20107
|
-
const id = idPrefix(
|
|
20108
|
-
const root2 =
|
|
20109
|
-
if (id !== null &&
|
|
20133
|
+
const id = idPrefix(path64.basename(dir));
|
|
20134
|
+
const root2 = path64.join(dir, "root.md");
|
|
20135
|
+
if (id !== null && fs62.existsSync(root2)) files2.set(id, root2);
|
|
20110
20136
|
}
|
|
20111
20137
|
return files2;
|
|
20112
20138
|
}
|
|
@@ -20217,14 +20243,14 @@ var init_list = __esm({
|
|
|
20217
20243
|
});
|
|
20218
20244
|
|
|
20219
20245
|
// ../cli/src/commands/misc.ts
|
|
20220
|
-
import
|
|
20221
|
-
import
|
|
20246
|
+
import fs63 from "node:fs";
|
|
20247
|
+
import path65 from "node:path";
|
|
20222
20248
|
function extractOldMeta(text5, file) {
|
|
20223
20249
|
const grab = (re3) => {
|
|
20224
20250
|
const m = text5.match(re3);
|
|
20225
20251
|
return m ? m[1].trim() : null;
|
|
20226
20252
|
};
|
|
20227
|
-
const title = grab(/^#\s+(.+)$/m) || slugify(
|
|
20253
|
+
const title = grab(/^#\s+(.+)$/m) || slugify(path65.basename(file, ".md").replace(/^\d+-/, "")).replace(/-/g, " ");
|
|
20228
20254
|
const norm = (raw) => {
|
|
20229
20255
|
const v = (raw || "").toLowerCase();
|
|
20230
20256
|
return LEVELS.includes(v) ? v : "med";
|
|
@@ -20251,11 +20277,11 @@ function stripOldHeader(text5) {
|
|
|
20251
20277
|
}
|
|
20252
20278
|
function cmdMigrate(opts) {
|
|
20253
20279
|
const dry = opts.dryRun === true;
|
|
20254
|
-
const files2 = walkMd(TODO).filter((f2) =>
|
|
20280
|
+
const files2 = walkMd(TODO).filter((f2) => path65.basename(f2) !== "README.md");
|
|
20255
20281
|
let changed = 0;
|
|
20256
20282
|
let skipped = 0;
|
|
20257
20283
|
for (const file of files2) {
|
|
20258
|
-
const text5 =
|
|
20284
|
+
const text5 = fs63.readFileSync(file, "utf8");
|
|
20259
20285
|
if (text5.trimStart().startsWith("---")) {
|
|
20260
20286
|
skipped++;
|
|
20261
20287
|
continue;
|
|
@@ -20264,7 +20290,7 @@ function cmdMigrate(opts) {
|
|
|
20264
20290
|
const out = serializeFrontmatter(meta) + "\n\n" + stripOldHeader(text5).replace(/^\n+/, "");
|
|
20265
20291
|
if (dry) say(`would migrate ${rel(file)} (priority=${meta.priority})`);
|
|
20266
20292
|
else {
|
|
20267
|
-
|
|
20293
|
+
fs63.writeFileSync(file, out.endsWith("\n") ? out : out + "\n");
|
|
20268
20294
|
say(`migrated ${rel(file)}`);
|
|
20269
20295
|
}
|
|
20270
20296
|
changed++;
|
|
@@ -20285,8 +20311,8 @@ var init_misc = __esm({
|
|
|
20285
20311
|
});
|
|
20286
20312
|
|
|
20287
20313
|
// ../cli/src/lib/card-sources.ts
|
|
20288
|
-
import
|
|
20289
|
-
import
|
|
20314
|
+
import fs64 from "node:fs";
|
|
20315
|
+
import path66 from "node:path";
|
|
20290
20316
|
function planById(id) {
|
|
20291
20317
|
const found2 = readPlan(`plans/${id}-.md`);
|
|
20292
20318
|
return found2?.text.trim() ? found2 : null;
|
|
@@ -20296,8 +20322,8 @@ function cardLink(id) {
|
|
|
20296
20322
|
const found2 = open3 ?? locateArchived(id);
|
|
20297
20323
|
if (!found2) return null;
|
|
20298
20324
|
try {
|
|
20299
|
-
const file = found2.kind === "group" ?
|
|
20300
|
-
const title = parseFrontmatter(
|
|
20325
|
+
const file = found2.kind === "group" ? path66.join(found2.target, "root.md") : found2.target;
|
|
20326
|
+
const title = parseFrontmatter(fs64.readFileSync(file, "utf8")).meta?.title ?? "";
|
|
20301
20327
|
return { kind: "card", ref: String(id), title, ...open3 ? {} : { archived: true } };
|
|
20302
20328
|
} catch {
|
|
20303
20329
|
return null;
|
|
@@ -20322,7 +20348,7 @@ function link(ref, items) {
|
|
|
20322
20348
|
if (ref.kind === "plan") return planLink(ref.id);
|
|
20323
20349
|
if (ref.kind === "card") return cardLink(ref.id);
|
|
20324
20350
|
if (ref.kind === "url") return urlLink(ref.url);
|
|
20325
|
-
const item = items().find((signal2) =>
|
|
20351
|
+
const item = items().find((signal2) => path66.basename(signal2.relPath) === ref.file);
|
|
20326
20352
|
return item ? itemLink(item) : null;
|
|
20327
20353
|
}
|
|
20328
20354
|
function cardSources(meta, body) {
|
|
@@ -20363,12 +20389,12 @@ var init_card_sources = __esm({
|
|
|
20363
20389
|
});
|
|
20364
20390
|
|
|
20365
20391
|
// ../cli/src/lib/view/read.ts
|
|
20366
|
-
import
|
|
20367
|
-
import
|
|
20392
|
+
import fs65 from "node:fs";
|
|
20393
|
+
import path67 from "node:path";
|
|
20368
20394
|
function readCard(file, relFromTodo) {
|
|
20369
|
-
const id = idPrefix(
|
|
20395
|
+
const id = idPrefix(path67.basename(relFromTodo));
|
|
20370
20396
|
if (id === null) {
|
|
20371
|
-
const parts = relFromTodo.split(
|
|
20397
|
+
const parts = relFromTodo.split(path67.sep);
|
|
20372
20398
|
const folderId = idPrefix(parts[parts.length - 2] || "");
|
|
20373
20399
|
if (folderId === null) return null;
|
|
20374
20400
|
return buildCard(folderId, file, relFromTodo);
|
|
@@ -20376,10 +20402,10 @@ function readCard(file, relFromTodo) {
|
|
|
20376
20402
|
return buildCard(id, file, relFromTodo);
|
|
20377
20403
|
}
|
|
20378
20404
|
function buildCard(id, file, relFromTodo) {
|
|
20379
|
-
const text5 =
|
|
20405
|
+
const text5 = fs65.readFileSync(file, "utf8");
|
|
20380
20406
|
const { meta, body } = parseFrontmatter(text5);
|
|
20381
20407
|
if (!meta) return null;
|
|
20382
|
-
const relPath = relFromTodo.split(
|
|
20408
|
+
const relPath = relFromTodo.split(path67.sep).join("/");
|
|
20383
20409
|
const flow = workflowFor(meta.workflow);
|
|
20384
20410
|
const plan = !!meta.workflow && archivesOnApproval(flow);
|
|
20385
20411
|
const stages = cardStages(meta, flow).length;
|
|
@@ -20388,7 +20414,7 @@ function buildCard(id, file, relFromTodo) {
|
|
|
20388
20414
|
// Derived from the file exactly as it is on disk (lib/board/revision.ts), so a card
|
|
20389
20415
|
// read here and a card read by the contract agree on what version this is.
|
|
20390
20416
|
revision: revisionOf(text5),
|
|
20391
|
-
updatedAt:
|
|
20417
|
+
updatedAt: fs65.statSync(file).mtime.toISOString(),
|
|
20392
20418
|
relPath,
|
|
20393
20419
|
title: meta.title,
|
|
20394
20420
|
priority: meta.priority,
|
|
@@ -20409,22 +20435,22 @@ function buildCard(id, file, relFromTodo) {
|
|
|
20409
20435
|
};
|
|
20410
20436
|
}
|
|
20411
20437
|
function readGroup2(folderName) {
|
|
20412
|
-
const groupDir =
|
|
20413
|
-
const rootFile =
|
|
20414
|
-
if (!
|
|
20415
|
-
const root2 = readCard(rootFile,
|
|
20438
|
+
const groupDir = path67.join(TODO, folderName);
|
|
20439
|
+
const rootFile = path67.join(groupDir, "root.md");
|
|
20440
|
+
if (!fs65.existsSync(rootFile)) return null;
|
|
20441
|
+
const root2 = readCard(rootFile, path67.join(folderName, "root.md"));
|
|
20416
20442
|
if (!root2) return null;
|
|
20417
20443
|
root2.isGroup = true;
|
|
20418
20444
|
const { total, resolved: resolved2 } = subtaskLines(root2.body);
|
|
20419
20445
|
root2.subtaskLines = { total, resolved: resolved2 };
|
|
20420
20446
|
const subCards = [];
|
|
20421
20447
|
const recurse = (dir, relDir) => {
|
|
20422
|
-
for (const entry of
|
|
20423
|
-
const childRel =
|
|
20448
|
+
for (const entry of fs65.readdirSync(dir, { withFileTypes: true })) {
|
|
20449
|
+
const childRel = path67.join(relDir, entry.name);
|
|
20424
20450
|
if (entry.isDirectory()) {
|
|
20425
|
-
recurse(
|
|
20451
|
+
recurse(path67.join(dir, entry.name), childRel);
|
|
20426
20452
|
} else if (entry.name.endsWith(".md") && entry.name !== "README.md" && entry.name !== "root.md") {
|
|
20427
|
-
const c2 = readCard(
|
|
20453
|
+
const c2 = readCard(path67.join(dir, entry.name), childRel);
|
|
20428
20454
|
if (c2) {
|
|
20429
20455
|
c2.parent = { id: root2.id, title: root2.title };
|
|
20430
20456
|
subCards.push(c2);
|
|
@@ -20445,12 +20471,12 @@ function readGroup2(folderName) {
|
|
|
20445
20471
|
return { root: root2, subCards };
|
|
20446
20472
|
}
|
|
20447
20473
|
function standaloneCards(dirRel) {
|
|
20448
|
-
const dir = dirRel ?
|
|
20449
|
-
if (!
|
|
20474
|
+
const dir = dirRel ? path67.join(TODO, dirRel) : TODO;
|
|
20475
|
+
if (!fs65.existsSync(dir)) return [];
|
|
20450
20476
|
const cards = [];
|
|
20451
|
-
for (const entry of
|
|
20477
|
+
for (const entry of fs65.readdirSync(dir, { withFileTypes: true })) {
|
|
20452
20478
|
if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
|
|
20453
|
-
const c2 = readCard(
|
|
20479
|
+
const c2 = readCard(path67.join(dir, entry.name), path67.join(dirRel, entry.name));
|
|
20454
20480
|
if (c2) cards.push(c2);
|
|
20455
20481
|
}
|
|
20456
20482
|
}
|
|
@@ -20462,7 +20488,7 @@ function collectCards() {
|
|
|
20462
20488
|
const top = standaloneCards("");
|
|
20463
20489
|
board2.push(...top);
|
|
20464
20490
|
every.push(...top);
|
|
20465
|
-
for (const entry of
|
|
20491
|
+
for (const entry of fs65.readdirSync(TODO, { withFileTypes: true })) {
|
|
20466
20492
|
if (!entry.isDirectory()) continue;
|
|
20467
20493
|
if (isGroupFolder(entry.name)) {
|
|
20468
20494
|
const g3 = readGroup2(entry.name);
|
|
@@ -20494,7 +20520,7 @@ function findCard(id) {
|
|
|
20494
20520
|
}
|
|
20495
20521
|
function attachSources(card) {
|
|
20496
20522
|
try {
|
|
20497
|
-
const { meta, body } = parseFrontmatter(
|
|
20523
|
+
const { meta, body } = parseFrontmatter(fs65.readFileSync(path67.join(TODO, card.relPath), "utf8"));
|
|
20498
20524
|
const sources2 = meta ? cardSources(meta, body) : [];
|
|
20499
20525
|
if (sources2.length) card.sources = sources2;
|
|
20500
20526
|
} catch {
|
|
@@ -20599,10 +20625,10 @@ var init_read = __esm({
|
|
|
20599
20625
|
});
|
|
20600
20626
|
|
|
20601
20627
|
// ../cli/src/lib/group-close.ts
|
|
20602
|
-
import
|
|
20628
|
+
import fs66 from "node:fs";
|
|
20603
20629
|
function groupCloses(rootFile) {
|
|
20604
20630
|
try {
|
|
20605
|
-
return groupCloseOf(
|
|
20631
|
+
return groupCloseOf(fs66.readFileSync(rootFile, "utf8"));
|
|
20606
20632
|
} catch {
|
|
20607
20633
|
return false;
|
|
20608
20634
|
}
|
|
@@ -20615,12 +20641,12 @@ var init_group_close = __esm({
|
|
|
20615
20641
|
});
|
|
20616
20642
|
|
|
20617
20643
|
// ../cli/src/commands/remove.ts
|
|
20618
|
-
import
|
|
20619
|
-
import
|
|
20644
|
+
import fs67 from "node:fs";
|
|
20645
|
+
import path68 from "node:path";
|
|
20620
20646
|
function leavingIds(id, found2) {
|
|
20621
20647
|
const ids = /* @__PURE__ */ new Set([id]);
|
|
20622
20648
|
if (found2.kind === "group") {
|
|
20623
|
-
const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) =>
|
|
20649
|
+
const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) => path68.basename(f2));
|
|
20624
20650
|
for (const name of names3) {
|
|
20625
20651
|
const n = idPrefix(name);
|
|
20626
20652
|
if (n !== null) ids.add(n);
|
|
@@ -20632,10 +20658,10 @@ function findMentions(ids) {
|
|
|
20632
20658
|
const hits = [];
|
|
20633
20659
|
const re3 = new RegExp(ids.map((id) => `#${id}(?!\\d)`).join("|"));
|
|
20634
20660
|
for (const dir of [TODO, MEMORY]) {
|
|
20635
|
-
if (!
|
|
20661
|
+
if (!fs67.existsSync(dir)) continue;
|
|
20636
20662
|
for (const file of walkMd(dir)) {
|
|
20637
|
-
if (
|
|
20638
|
-
const lines =
|
|
20663
|
+
if (path68.basename(file) === "README.md") continue;
|
|
20664
|
+
const lines = fs67.readFileSync(file, "utf8").split("\n");
|
|
20639
20665
|
const fmEnd = frontmatterEnd(lines);
|
|
20640
20666
|
lines.forEach((line, i) => {
|
|
20641
20667
|
if (!re3.test(line)) return;
|
|
@@ -20651,12 +20677,12 @@ function findMentions(ids) {
|
|
|
20651
20677
|
return hits;
|
|
20652
20678
|
}
|
|
20653
20679
|
function leavingCards(id, found2) {
|
|
20654
|
-
const own = found2.kind === "group" ?
|
|
20680
|
+
const own = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
|
|
20655
20681
|
const cards = [{ id, file: own }];
|
|
20656
20682
|
if (found2.kind !== "group") return cards;
|
|
20657
20683
|
for (const file of walkMd(found2.target)) {
|
|
20658
20684
|
if (file === own) continue;
|
|
20659
|
-
const n = idPrefix(
|
|
20685
|
+
const n = idPrefix(path68.basename(file));
|
|
20660
20686
|
if (n !== null) cards.push({ id: n, file });
|
|
20661
20687
|
}
|
|
20662
20688
|
return cards;
|
|
@@ -20665,10 +20691,10 @@ function stampLeaving(cards, rejection) {
|
|
|
20665
20691
|
const day = formatDay();
|
|
20666
20692
|
const stamp4 = rejection && !rejection.discard ? { reason: rejection.reason, at: (/* @__PURE__ */ new Date()).toISOString(), by: insideRun() ? "agent" : "user" } : rejection && { reason: rejection.reason };
|
|
20667
20693
|
for (const card of cards) {
|
|
20668
|
-
if (!
|
|
20669
|
-
const text5 =
|
|
20694
|
+
if (!fs67.existsSync(card.file)) continue;
|
|
20695
|
+
const text5 = fs67.readFileSync(card.file, "utf8");
|
|
20670
20696
|
const stamped = stampLeavingIn(text5, day, stamp4);
|
|
20671
|
-
if (stamped !== text5)
|
|
20697
|
+
if (stamped !== text5) fs67.writeFileSync(card.file, stamped);
|
|
20672
20698
|
}
|
|
20673
20699
|
}
|
|
20674
20700
|
function unfinishedDelivery(id) {
|
|
@@ -20684,7 +20710,7 @@ function unfinishedDelivery(id) {
|
|
|
20684
20710
|
}[gap];
|
|
20685
20711
|
return `#${id} is not finished: ${what}.`;
|
|
20686
20712
|
}
|
|
20687
|
-
const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !
|
|
20713
|
+
const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs67.existsSync(path68.join(ASSETS, src.slice(".assets/".length))));
|
|
20688
20714
|
return missing ? `#${id} is not finished: ${missing} is not on this machine.` : null;
|
|
20689
20715
|
}
|
|
20690
20716
|
function agentDecisions(text5) {
|
|
@@ -20715,8 +20741,8 @@ function removeCard2(id, metric, options) {
|
|
|
20715
20741
|
const unfinished = metric === "completed" ? unfinishedDelivery(id) : null;
|
|
20716
20742
|
if (unfinished) die(unfinished, { kind: "plan-delivery-unfinished" });
|
|
20717
20743
|
const dest = options.cleanupDiscarded && locateArchived(id) ? null : archiveDest(found2);
|
|
20718
|
-
const cardFile3 = found2.kind === "group" ?
|
|
20719
|
-
const cardText =
|
|
20744
|
+
const cardFile3 = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
|
|
20745
|
+
const cardText = fs67.existsSync(cardFile3) ? fs67.readFileSync(cardFile3, "utf8") : "";
|
|
20720
20746
|
const { meta: cardMeta3 } = parseFrontmatter(cardText);
|
|
20721
20747
|
const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f2) => f2 !== cardFile3).map((f2) => rel(f2)).sort() : [];
|
|
20722
20748
|
const leftIds = leavingIds(id, found2);
|
|
@@ -20747,10 +20773,10 @@ function removeCard2(id, metric, options) {
|
|
|
20747
20773
|
const groupRoot = found2.kind === "file" && !options.closing ? enclosingGroupRoot(found2.target) : null;
|
|
20748
20774
|
if (dest) {
|
|
20749
20775
|
stampLeaving(leaving, metric === "rejected" ? { reason: options.reason?.trim() ?? "", discard: options.discard === true } : null);
|
|
20750
|
-
|
|
20751
|
-
|
|
20776
|
+
fs67.mkdirSync(ARCHIVE, { recursive: true });
|
|
20777
|
+
fs67.renameSync(found2.target, dest);
|
|
20752
20778
|
} else {
|
|
20753
|
-
|
|
20779
|
+
fs67.rmSync(found2.target, { recursive: true, force: true });
|
|
20754
20780
|
}
|
|
20755
20781
|
const removedRefs = stripReadmeRefs(found2);
|
|
20756
20782
|
let marked2 = null;
|
|
@@ -20799,14 +20825,14 @@ function removeCard2(id, metric, options) {
|
|
|
20799
20825
|
};
|
|
20800
20826
|
}
|
|
20801
20827
|
function closeGroup(rootFile) {
|
|
20802
|
-
const rootId = idPrefix(
|
|
20828
|
+
const rootId = idPrefix(path68.basename(path68.dirname(rootFile)));
|
|
20803
20829
|
if (rootId === null) return null;
|
|
20804
20830
|
if (runnerProject(KANBAN)) return null;
|
|
20805
20831
|
if (!groupCloses(rootFile)) return null;
|
|
20806
20832
|
say(`
|
|
20807
20833
|
every subtask line on #${rootId} is resolved \u2014 closing the group:`);
|
|
20808
20834
|
try {
|
|
20809
|
-
const { meta, body } = parseFrontmatter(
|
|
20835
|
+
const { meta, body } = parseFrontmatter(fs67.readFileSync(rootFile, "utf8"));
|
|
20810
20836
|
const res = cmdRemove(rootId, "completed", { closing: true });
|
|
20811
20837
|
return {
|
|
20812
20838
|
id: rootId,
|
|
@@ -20863,7 +20889,7 @@ function cleanupDiscardedCards(sessionId) {
|
|
|
20863
20889
|
if (card.pending) throw new Error(`Discarding #${card.id} did not finish. Retry the discard.`);
|
|
20864
20890
|
while (locate(card.id)) cmdRemove(card.id, "rejected", { discard: true, cleanupDiscarded: true });
|
|
20865
20891
|
dropCrossRefs(card.id);
|
|
20866
|
-
stripReadmeRefs({ kind: "file", rel:
|
|
20892
|
+
stripReadmeRefs({ kind: "file", rel: path68.relative(TODO, path68.resolve(REPO_ROOT, card.path)).split(path68.sep).join("/") });
|
|
20867
20893
|
}
|
|
20868
20894
|
return discarded.map((c2) => c2.id);
|
|
20869
20895
|
});
|
|
@@ -20871,8 +20897,8 @@ function cleanupDiscardedCards(sessionId) {
|
|
|
20871
20897
|
function recoveredArchiveHandoff(id, source) {
|
|
20872
20898
|
const found2 = locateArchived(id);
|
|
20873
20899
|
if (!found2) throw new Error(`No archived card #${id} was found.`);
|
|
20874
|
-
const file = found2.kind === "group" ?
|
|
20875
|
-
const { meta } = parseFrontmatter(
|
|
20900
|
+
const file = found2.kind === "group" ? path68.join(found2.target, "root.md") : found2.target;
|
|
20901
|
+
const { meta } = parseFrontmatter(fs67.readFileSync(file, "utf8"));
|
|
20876
20902
|
stripReadmeRefs(source ?? found2);
|
|
20877
20903
|
const root2 = source?.kind === "file" ? enclosingGroupRoot(source.target) : null;
|
|
20878
20904
|
if (root2) markSubtask(root2, id, "tick");
|
|
@@ -20970,8 +20996,8 @@ var init_memory_file = __esm({
|
|
|
20970
20996
|
});
|
|
20971
20997
|
|
|
20972
20998
|
// ../cli/src/commands/rule.ts
|
|
20973
|
-
import
|
|
20974
|
-
import
|
|
20999
|
+
import fs68 from "node:fs";
|
|
21000
|
+
import path69 from "node:path";
|
|
20975
21001
|
function cmdRule(askedName, flags) {
|
|
20976
21002
|
const agent = askedName.trim();
|
|
20977
21003
|
if (!agentRoster().some((a2) => a2.name === agent)) {
|
|
@@ -20980,7 +21006,7 @@ function cmdRule(askedName, flags) {
|
|
|
20980
21006
|
const rule = readRuleText(flags.file, flags.text);
|
|
20981
21007
|
const res = setAgentRule(agent, rule);
|
|
20982
21008
|
if (!res.ok) die(res.error);
|
|
20983
|
-
const file = rel(
|
|
21009
|
+
const file = rel(path69.join(RULES, `${agent}.md`));
|
|
20984
21010
|
say(rule ? `wrote the \`${agent}\` rule (${file})` : `cleared the \`${agent}\` rule`);
|
|
20985
21011
|
return { agent, file, cleared: !rule };
|
|
20986
21012
|
}
|
|
@@ -20988,7 +21014,7 @@ function readRuleText(file, text5) {
|
|
|
20988
21014
|
if (file !== void 0 && text5 !== void 0) die("pass --file or --text, not both");
|
|
20989
21015
|
if (file !== void 0) {
|
|
20990
21016
|
try {
|
|
20991
|
-
return
|
|
21017
|
+
return fs68.readFileSync(file, "utf8").trim();
|
|
20992
21018
|
} catch {
|
|
20993
21019
|
die(`can't read ${file} \u2014 write the rule to a file, then pass its path`);
|
|
20994
21020
|
}
|
|
@@ -21274,8 +21300,8 @@ var init_created_cards = __esm({
|
|
|
21274
21300
|
|
|
21275
21301
|
// ../cli/src/lib/agent/creation.ts
|
|
21276
21302
|
import crypto4 from "node:crypto";
|
|
21277
|
-
import
|
|
21278
|
-
import
|
|
21303
|
+
import fs69 from "node:fs";
|
|
21304
|
+
import path70 from "node:path";
|
|
21279
21305
|
function creationError(error, triage) {
|
|
21280
21306
|
const zh = readLanguage() === "zh";
|
|
21281
21307
|
const messages = {
|
|
@@ -21301,12 +21327,12 @@ ${zh ? `\u539F\u6761\u76EE\u4ECD\u5728 triage\uFF1A${triage}\u3002${unreachable
|
|
|
21301
21327
|
function creationReceipt(request2, slot) {
|
|
21302
21328
|
const hash2 = crypto4.createHash("sha256").update(`${request2}
|
|
21303
21329
|
${slot}`).digest("hex");
|
|
21304
|
-
return
|
|
21330
|
+
return path70.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
|
|
21305
21331
|
}
|
|
21306
21332
|
function readCreation(file, said3) {
|
|
21307
21333
|
return withCreationLock(() => {
|
|
21308
21334
|
try {
|
|
21309
|
-
const held4 = JSON.parse(
|
|
21335
|
+
const held4 = JSON.parse(fs69.readFileSync(file, "utf8"));
|
|
21310
21336
|
if (!held4.said || typeof held4.said.title !== "string") throw new Error("Invalid creation journal");
|
|
21311
21337
|
return held4;
|
|
21312
21338
|
} catch (error) {
|
|
@@ -21318,10 +21344,10 @@ function readCreation(file, said3) {
|
|
|
21318
21344
|
});
|
|
21319
21345
|
}
|
|
21320
21346
|
function saveCreation(file, journal) {
|
|
21321
|
-
|
|
21347
|
+
fs69.mkdirSync(path70.dirname(file), { recursive: true });
|
|
21322
21348
|
const temp = `${file}.${crypto4.randomUUID()}.tmp`;
|
|
21323
|
-
|
|
21324
|
-
|
|
21349
|
+
fs69.writeFileSync(temp, JSON.stringify(journal));
|
|
21350
|
+
fs69.renameSync(temp, file);
|
|
21325
21351
|
}
|
|
21326
21352
|
function archiveCreation(source, id) {
|
|
21327
21353
|
if (readArchived().some((s) => s.sourceId === source && s.cardId === id)) return;
|
|
@@ -21335,7 +21361,7 @@ function archiveCreation(source, id) {
|
|
|
21335
21361
|
function triageFile(sourceId) {
|
|
21336
21362
|
const found2 = [...readInbox(), ...readAllDismissed(), ...readArchived()].find((s) => s.sourceId === sourceId.trim());
|
|
21337
21363
|
if (!found2) throw new BoardError(`nothing in triage is ${sourceId}`, { kind: "refused" });
|
|
21338
|
-
return
|
|
21364
|
+
return path70.basename(found2.relPath, ".md");
|
|
21339
21365
|
}
|
|
21340
21366
|
var init_creation = __esm({
|
|
21341
21367
|
"../cli/src/lib/agent/creation.ts"() {
|
|
@@ -21481,7 +21507,7 @@ function ordered(into) {
|
|
|
21481
21507
|
};
|
|
21482
21508
|
}
|
|
21483
21509
|
var HELP_WIDTH, collect2;
|
|
21484
|
-
var
|
|
21510
|
+
var init_shared2 = __esm({
|
|
21485
21511
|
"../cli/src/lib/cli/shared.ts"() {
|
|
21486
21512
|
"use strict";
|
|
21487
21513
|
init_esm();
|
|
@@ -21499,8 +21525,8 @@ __export(board_exports, {
|
|
|
21499
21525
|
buildBoardProgram: () => buildBoardProgram
|
|
21500
21526
|
});
|
|
21501
21527
|
import crypto5 from "node:crypto";
|
|
21502
|
-
import
|
|
21503
|
-
import
|
|
21528
|
+
import fs70 from "node:fs";
|
|
21529
|
+
import path71 from "node:path";
|
|
21504
21530
|
async function dispatch(move, cmd, args, opts, cli) {
|
|
21505
21531
|
const ctx = ctxOf(cmd, cli.program);
|
|
21506
21532
|
const data = await runAction(ctx, {}, async () => {
|
|
@@ -21540,7 +21566,7 @@ async function cloudCard(task, opts) {
|
|
|
21540
21566
|
let request2;
|
|
21541
21567
|
if (typeof opts.bodyFile === "string") {
|
|
21542
21568
|
try {
|
|
21543
|
-
request2 =
|
|
21569
|
+
request2 = fs70.readFileSync(opts.bodyFile, "utf8");
|
|
21544
21570
|
} catch {
|
|
21545
21571
|
}
|
|
21546
21572
|
}
|
|
@@ -21570,7 +21596,7 @@ async function cloudCard(task, opts) {
|
|
|
21570
21596
|
const file = creationReceipt(`${checked.value}:${requestId}`, slot);
|
|
21571
21597
|
const journal = readCreation(file, said3);
|
|
21572
21598
|
if (!journal.made) {
|
|
21573
|
-
const key = `akb-${
|
|
21599
|
+
const key = `akb-${path71.basename(file, ".json").slice(0, 40)}`;
|
|
21574
21600
|
const made = await createProjectTask(checked.value, journal.said, key);
|
|
21575
21601
|
if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
|
|
21576
21602
|
journal.made = made.value;
|
|
@@ -21702,7 +21728,7 @@ var init_board2 = __esm({
|
|
|
21702
21728
|
init_board_cli();
|
|
21703
21729
|
init_cloud_workflows();
|
|
21704
21730
|
init_validate();
|
|
21705
|
-
|
|
21731
|
+
init_shared2();
|
|
21706
21732
|
init_esm();
|
|
21707
21733
|
init_tasks();
|
|
21708
21734
|
init_card();
|
|
@@ -21712,17 +21738,17 @@ var init_board2 = __esm({
|
|
|
21712
21738
|
});
|
|
21713
21739
|
|
|
21714
21740
|
// ../cli/src/lib/board-cli.ts
|
|
21715
|
-
import
|
|
21716
|
-
import
|
|
21741
|
+
import fs71 from "node:fs";
|
|
21742
|
+
import path72 from "node:path";
|
|
21717
21743
|
function useBoard(found2, dirNamed) {
|
|
21718
|
-
if (!found2.named && found2.board ===
|
|
21744
|
+
if (!found2.named && found2.board === path72.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
|
|
21719
21745
|
else setBoardDir(found2.board, found2.root);
|
|
21720
21746
|
useProjectState();
|
|
21721
21747
|
backfillCardWorkflows();
|
|
21722
21748
|
}
|
|
21723
21749
|
function whole(found2, move) {
|
|
21724
21750
|
if (move === MAKES_A_BOARD) return found2;
|
|
21725
|
-
if (!
|
|
21751
|
+
if (!fs71.existsSync(path72.join(found2.board, "todo"))) {
|
|
21726
21752
|
die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
|
|
21727
21753
|
kind: "board-incomplete",
|
|
21728
21754
|
dir: found2.root
|
|
@@ -21731,13 +21757,13 @@ function whole(found2, move) {
|
|
|
21731
21757
|
return found2;
|
|
21732
21758
|
}
|
|
21733
21759
|
function findBoardUpward(from, move) {
|
|
21734
|
-
let dir =
|
|
21760
|
+
let dir = path72.resolve(from);
|
|
21735
21761
|
for (; ; ) {
|
|
21736
|
-
if (hasBoard(dir)) return { root: dir, board:
|
|
21762
|
+
if (hasBoard(dir)) return { root: dir, board: path72.join(dir, "docs", "kanban") };
|
|
21737
21763
|
if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
|
|
21738
|
-
const kept2 =
|
|
21739
|
-
if (move !== MAKES_A_BOARD &&
|
|
21740
|
-
const up =
|
|
21764
|
+
const kept2 = path72.join(dir, ".akb", "kanban");
|
|
21765
|
+
if (move !== MAKES_A_BOARD && fs71.existsSync(path72.join(kept2, "todo"))) return { root: dir, board: kept2 };
|
|
21766
|
+
const up = path72.dirname(dir);
|
|
21741
21767
|
if (up === dir) return null;
|
|
21742
21768
|
dir = up;
|
|
21743
21769
|
}
|
|
@@ -21745,11 +21771,11 @@ function findBoardUpward(from, move) {
|
|
|
21745
21771
|
function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
21746
21772
|
const named2 = board2 ?? boardFromEnv();
|
|
21747
21773
|
if (named2) {
|
|
21748
|
-
const folder =
|
|
21749
|
-
if (!
|
|
21774
|
+
const folder = path72.resolve(cwd, named2);
|
|
21775
|
+
if (!fs71.existsSync(folder) && move !== MAKES_A_BOARD) {
|
|
21750
21776
|
die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
|
|
21751
21777
|
}
|
|
21752
|
-
if (
|
|
21778
|
+
if (fs71.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
|
|
21753
21779
|
die(`${folder} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
|
|
21754
21780
|
kind: "no-board",
|
|
21755
21781
|
dir: folder
|
|
@@ -21758,24 +21784,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
|
21758
21784
|
return { root: projectRootOf(folder), board: folder, named: true };
|
|
21759
21785
|
}
|
|
21760
21786
|
if (dir !== null) {
|
|
21761
|
-
const root2 =
|
|
21762
|
-
if (!
|
|
21763
|
-
const kept2 =
|
|
21764
|
-
if (!hasBoard(root2) && move !== MAKES_A_BOARD &&
|
|
21787
|
+
const root2 = path72.resolve(dir);
|
|
21788
|
+
if (!fs71.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
|
|
21789
|
+
const kept2 = path72.join(root2, ".akb", "kanban");
|
|
21790
|
+
if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs71.existsSync(path72.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
|
|
21765
21791
|
if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
|
|
21766
21792
|
die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
|
|
21767
21793
|
kind: "no-board",
|
|
21768
21794
|
dir: root2
|
|
21769
21795
|
});
|
|
21770
21796
|
}
|
|
21771
|
-
return whole({ root: root2, board:
|
|
21797
|
+
return whole({ root: root2, board: path72.join(root2, "docs", "kanban") }, move);
|
|
21772
21798
|
}
|
|
21773
21799
|
const found2 = findBoardUpward(cwd, move);
|
|
21774
21800
|
if (found2) return whole(found2, move);
|
|
21775
|
-
if (move === MAKES_A_BOARD) return { root:
|
|
21801
|
+
if (move === MAKES_A_BOARD) return { root: path72.resolve(cwd), board: path72.join(path72.resolve(cwd), "docs", "kanban") };
|
|
21776
21802
|
die(
|
|
21777
|
-
`no board here. Looked in ${
|
|
21778
|
-
{ kind: "no-board", dir:
|
|
21803
|
+
`no board here. Looked in ${path72.resolve(cwd)} and every folder above it for docs/kanban/. ${installHint}\uFF0C\u6216\u7528 --board \u6307\u5B9A\u5DF2\u6709\u770B\u677F\u3002`,
|
|
21804
|
+
{ kind: "no-board", dir: path72.resolve(cwd) }
|
|
21779
21805
|
);
|
|
21780
21806
|
}
|
|
21781
21807
|
function editDistance(a2, b2) {
|
|
@@ -21804,7 +21830,7 @@ async function runBoard(argv, options = {}) {
|
|
|
21804
21830
|
onAnswer
|
|
21805
21831
|
} = options;
|
|
21806
21832
|
const { buildBoardProgram: buildBoardProgram2 } = await Promise.resolve().then(() => (init_board2(), board_exports));
|
|
21807
|
-
const { runProgram: runProgram2 } = await Promise.resolve().then(() => (
|
|
21833
|
+
const { runProgram: runProgram2 } = await Promise.resolve().then(() => (init_shared2(), shared_exports));
|
|
21808
21834
|
return runProgram2(buildBoardProgram2({ program: program2, cwd, installHint, version, onAnswer }), argv, program2);
|
|
21809
21835
|
}
|
|
21810
21836
|
function rawArgv(argv) {
|
|
@@ -21858,8 +21884,8 @@ var init_board_cli = __esm({
|
|
|
21858
21884
|
init_pointer();
|
|
21859
21885
|
init_card_workflow_backfill();
|
|
21860
21886
|
MAKES_A_BOARD = "init";
|
|
21861
|
-
hasBoard = (dir) =>
|
|
21862
|
-
isBoardDir = (dir) =>
|
|
21887
|
+
hasBoard = (dir) => fs71.existsSync(path72.join(dir, "docs", "kanban"));
|
|
21888
|
+
isBoardDir = (dir) => fs71.existsSync(path72.join(dir, "todo")) && fs71.existsSync(path72.join(dir, "config.md"));
|
|
21863
21889
|
boardFromEnv = () => {
|
|
21864
21890
|
const named2 = process.env.AI4KANBAN_BOARD?.trim();
|
|
21865
21891
|
return named2 ? named2 : null;
|
|
@@ -21919,7 +21945,7 @@ var init_discuss_goal = __esm({
|
|
|
21919
21945
|
var follow_up_default;
|
|
21920
21946
|
var init_follow_up = __esm({
|
|
21921
21947
|
"../cli/src/guide/follow-up.md"() {
|
|
21922
|
-
follow_up_default = '# Handle follow-up work\n\nUse when planning or implementation discovers additional work.\n\n- **Current task**: finish required work on this card; queue independent follow-ups in triage, then resume the original task.\n- **Drop what was turned down**: queue nothing that\n `docs/kanban/memory/agents/planner/rejected.md` or\n `docs/kanban/memory/agents/planner/*/rejected.md` turns down.\n- **Existing card**: when only another open card needs changing, run `akb card revise <id> "<the change and why>"`.\n- **Queue it**: use the command below; skip an item the command reports as already there.\n- **Workflow**: use the source card\'s `workflow:`, or the id from `akb workflow list` that fits the work when it has none.\n\n```text\nakb triage add --title "<one line>" --slug <short-english-slug> --source "#<id>" --workflow <workflow> --text "<body>"\n```\n\n## Write the item\n\
|
|
21948
|
+
follow_up_default = '# Handle follow-up work\n\nUse when planning or implementation discovers additional work.\n\n- **Current task**: finish required work on this card; queue independent follow-ups in triage, then resume the original task.\n- **Drop what was turned down**: queue nothing that\n `docs/kanban/memory/agents/planner/rejected.md` or\n `docs/kanban/memory/agents/planner/*/rejected.md` turns down.\n- **Existing card**: when only another open card needs changing, run `akb card revise <id> "<the change and why>"`.\n- **Queue it**: use the command below; skip an item the command reports as already there.\n- **Workflow**: use the source card\'s `workflow:`, or the id from `akb workflow list` that fits the work when it has none.\n\n```text\nakb triage add --title "<one line>" --slug <short-english-slug> --source "#<id>" --workflow <workflow> --text "<body>"\n```\n\n## Write the item\n\nWrite each item\'s title and body in the **Goal format** of `akb guide discuss-goal`.\n';
|
|
21923
21949
|
}
|
|
21924
21950
|
});
|
|
21925
21951
|
|
|
@@ -21975,7 +22001,7 @@ var init_refine = __esm({
|
|
|
21975
22001
|
var reflect_default;
|
|
21976
22002
|
var init_reflect = __esm({
|
|
21977
22003
|
"../cli/src/guide/reflect.md"() {
|
|
21978
|
-
reflect_default = '# Reflect on completed cards\n\n## Read\n\nRead each given `<card>` in full and check its own `shipped` content; keep cards separate.\nFind needs the work left behind or revealed, and verify them in the project. Proposing nothing is fine.\n\n## Filter\n\n- **Duplicates**: check `akb raw list` and `akb triage check <source-id>`; propose shared work only once.\n- **Exclude**: skip unsupported guesses, work covered by `<scheduled-agents>`, work rejected in `docs/kanban/memory/agents/planner/rejected.md` or its module folders, and calls the user reversed, in any `redesign.md` under `docs/kanban/memory/agents/` or under a card\'s `Overruled by the user`.\n- **Existing cards**: when shipped work invalidates an open card\'s plan, run `akb card revise <id> "<the change and why>"` instead of proposing an item.\n\n## Write\n\
|
|
22004
|
+
reflect_default = '# Reflect on completed cards\n\n## Read\n\nRead each given `<card>` in full and check its own `shipped` content; keep cards separate.\nFind needs the work left behind or revealed, and verify them in the project. Proposing nothing is fine.\n\n## Filter\n\n- **Duplicates**: check `akb raw list` and `akb triage check <source-id>`; propose shared work only once.\n- **Exclude**: skip unsupported guesses, work covered by `<scheduled-agents>`, work rejected in `docs/kanban/memory/agents/planner/rejected.md` or its module folders, and calls the user reversed, in any `redesign.md` under `docs/kanban/memory/agents/` or under a card\'s `Overruled by the user`.\n- **Existing cards**: when shipped work invalidates an open card\'s plan, run `akb card revise <id> "<the change and why>"` instead of proposing an item.\n\n## Write\n\nWrite each item\'s title and body in the **Goal format** of `akb guide discuss-goal`; write the body to a temporary Markdown file and end it with the source card\'s archive path.\nWrite one triage item per proposal. Exploratory ideas are welcome; identify small chores as such.\nUse the source card\'s `workflow:`, or the id from `akb workflow list` that fits the work when it has none.\n\n```text\nakb triage add --title "<one line>" --slug <short-english-slug> --source "#<id>" --workflow <workflow> --file <body.md>\n```\n\nBriefly report what you proposed and what you skipped, with reasons.\n';
|
|
21979
22005
|
}
|
|
21980
22006
|
});
|
|
21981
22007
|
|
|
@@ -22116,8 +22142,8 @@ var init_guide = __esm({
|
|
|
22116
22142
|
});
|
|
22117
22143
|
|
|
22118
22144
|
// ../cli/src/lib/agent/approve.ts
|
|
22119
|
-
import
|
|
22120
|
-
import
|
|
22145
|
+
import fs78 from "node:fs";
|
|
22146
|
+
import path79 from "node:path";
|
|
22121
22147
|
function approvalRequest(req) {
|
|
22122
22148
|
const id = req.id;
|
|
22123
22149
|
const card = id === void 0 ? null : findCard(id);
|
|
@@ -22135,12 +22161,12 @@ function advancePhase(id) {
|
|
|
22135
22161
|
const card = findCard(id);
|
|
22136
22162
|
const found2 = locate(id);
|
|
22137
22163
|
if (!card || !found2 || !awaitingApproval(card)) return { error: `#${id} is no longer waiting on approval.` };
|
|
22138
|
-
const file = found2.kind === "group" ?
|
|
22139
|
-
const { meta, body } = parseFrontmatter(
|
|
22164
|
+
const file = found2.kind === "group" ? path79.join(found2.target, "root.md") : found2.target;
|
|
22165
|
+
const { meta, body } = parseFrontmatter(fs78.readFileSync(file, "utf8"));
|
|
22140
22166
|
if (!meta) return { error: `#${id} has no frontmatter` };
|
|
22141
22167
|
meta.phase = card.stage + 1;
|
|
22142
22168
|
meta.status = "todo";
|
|
22143
|
-
|
|
22169
|
+
fs78.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
|
|
22144
22170
|
return null;
|
|
22145
22171
|
}
|
|
22146
22172
|
var init_approve = __esm({
|
|
@@ -22263,16 +22289,16 @@ var init_start = __esm({
|
|
|
22263
22289
|
});
|
|
22264
22290
|
|
|
22265
22291
|
// ../cli/src/lib/agent/task-chats.ts
|
|
22266
|
-
import
|
|
22267
|
-
import
|
|
22292
|
+
import fs79 from "node:fs";
|
|
22293
|
+
import path80 from "node:path";
|
|
22268
22294
|
function taskChatFile(task, home3) {
|
|
22269
22295
|
if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
|
|
22270
|
-
return
|
|
22296
|
+
return path80.join(taskChatsDir(home3), `${task}.jsonl`);
|
|
22271
22297
|
}
|
|
22272
22298
|
function readTaskChat(task, home3) {
|
|
22273
22299
|
let text5;
|
|
22274
22300
|
try {
|
|
22275
|
-
text5 =
|
|
22301
|
+
text5 = fs79.readFileSync(taskChatFile(task, home3), "utf8");
|
|
22276
22302
|
} catch {
|
|
22277
22303
|
return [];
|
|
22278
22304
|
}
|
|
@@ -22293,13 +22319,13 @@ var init_task_chats = __esm({
|
|
|
22293
22319
|
"use strict";
|
|
22294
22320
|
init_home();
|
|
22295
22321
|
TASK = /^[\w-]{1,100}$/;
|
|
22296
|
-
taskChatsDir = (home3 = machineHome()) =>
|
|
22322
|
+
taskChatsDir = (home3 = machineHome()) => path80.join(home3, "chats");
|
|
22297
22323
|
}
|
|
22298
22324
|
});
|
|
22299
22325
|
|
|
22300
22326
|
// ../cli/src/lib/agent/memory-review.ts
|
|
22301
|
-
import
|
|
22302
|
-
import
|
|
22327
|
+
import fs80 from "node:fs";
|
|
22328
|
+
import path81 from "node:path";
|
|
22303
22329
|
function taskChatsToReview(tasks) {
|
|
22304
22330
|
const out = [];
|
|
22305
22331
|
for (const ref of [...new Set(tasks)]) {
|
|
@@ -22321,8 +22347,8 @@ function readArchived2(id) {
|
|
|
22321
22347
|
const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
|
|
22322
22348
|
if (!found2) return null;
|
|
22323
22349
|
try {
|
|
22324
|
-
const file = found2.kind === "group" ?
|
|
22325
|
-
const { meta, body } = parseFrontmatter(
|
|
22350
|
+
const file = found2.kind === "group" ? path81.join(found2.target, "root.md") : found2.target;
|
|
22351
|
+
const { meta, body } = parseFrontmatter(fs80.readFileSync(file, "utf8"));
|
|
22326
22352
|
if (!meta) return null;
|
|
22327
22353
|
return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
|
|
22328
22354
|
} catch {
|
|
@@ -22391,17 +22417,17 @@ var init_memory_review = __esm({
|
|
|
22391
22417
|
});
|
|
22392
22418
|
|
|
22393
22419
|
// ../cli/src/lib/agent/dismissal-review.ts
|
|
22394
|
-
import
|
|
22395
|
-
import
|
|
22420
|
+
import fs81 from "node:fs";
|
|
22421
|
+
import path82 from "node:path";
|
|
22396
22422
|
function rejectionsToReview() {
|
|
22397
|
-
const dir =
|
|
22398
|
-
if (!
|
|
22423
|
+
const dir = path82.join(ARCHIVE, REJECTIONS_TO_REVIEW);
|
|
22424
|
+
if (!fs81.existsSync(dir)) return [];
|
|
22399
22425
|
const found2 = [];
|
|
22400
22426
|
for (const file of walkMd(dir)) {
|
|
22401
22427
|
const id = archivedId(file);
|
|
22402
22428
|
if (id === null) continue;
|
|
22403
22429
|
try {
|
|
22404
|
-
const { meta } = parseFrontmatter(
|
|
22430
|
+
const { meta } = parseFrontmatter(fs81.readFileSync(file, "utf8"));
|
|
22405
22431
|
if (!meta?.rejected || meta.rejected_by !== "user" || !meta.rejected_reason.trim()) continue;
|
|
22406
22432
|
found2.push({ id, title: meta.title, file: rel(file), reason: meta.rejected_reason.trim(), rejectedAt: meta.rejected_at });
|
|
22407
22433
|
} catch {
|
|
@@ -22431,7 +22457,7 @@ function citedSources(text5) {
|
|
|
22431
22457
|
function withdrawnSources() {
|
|
22432
22458
|
const cited = [...new Set(plannerCopies("rejected.md").flatMap((file) => {
|
|
22433
22459
|
try {
|
|
22434
|
-
return citedSources(
|
|
22460
|
+
return citedSources(fs81.readFileSync(file, "utf8"));
|
|
22435
22461
|
} catch {
|
|
22436
22462
|
return [];
|
|
22437
22463
|
}
|
|
@@ -22456,8 +22482,8 @@ var init_dismissal_review = __esm({
|
|
|
22456
22482
|
});
|
|
22457
22483
|
|
|
22458
22484
|
// ../cli/src/lib/agent/flow.ts
|
|
22459
|
-
import
|
|
22460
|
-
import
|
|
22485
|
+
import fs82 from "node:fs";
|
|
22486
|
+
import path83 from "node:path";
|
|
22461
22487
|
function readCard2(id, home3 = "board") {
|
|
22462
22488
|
const pending = activeDelivery(id)?.completions?.some((c2) => !c2.finished);
|
|
22463
22489
|
const found2 = home3 === "archive" ? locateArchived(id) : locate(id) ?? (pending ? locateArchived(id) : null);
|
|
@@ -22467,10 +22493,10 @@ function readCard2(id, home3 = "board") {
|
|
|
22467
22493
|
{ kind: "card-not-found", id }
|
|
22468
22494
|
);
|
|
22469
22495
|
}
|
|
22470
|
-
const file = found2.kind === "group" ?
|
|
22496
|
+
const file = found2.kind === "group" ? path83.join(found2.target, "root.md") : found2.target;
|
|
22471
22497
|
let text5;
|
|
22472
22498
|
try {
|
|
22473
|
-
text5 =
|
|
22499
|
+
text5 = fs82.readFileSync(file, "utf8");
|
|
22474
22500
|
} catch {
|
|
22475
22501
|
die(`#${id} is on the board but ${rel(file)} can't be read.`, { kind: "card-unreadable", id });
|
|
22476
22502
|
}
|
|
@@ -64352,8 +64378,8 @@ var require_JSXTransformer = __commonJS({
|
|
|
64352
64378
|
}
|
|
64353
64379
|
if (this.isAutomaticRuntime) {
|
|
64354
64380
|
if (this.importProcessor) {
|
|
64355
|
-
for (const [
|
|
64356
|
-
prefix += `var ${resolvedName} = require("${
|
|
64381
|
+
for (const [path90, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
|
|
64382
|
+
prefix += `var ${resolvedName} = require("${path90}");`;
|
|
64357
64383
|
}
|
|
64358
64384
|
} else {
|
|
64359
64385
|
const { createElement: createElementResolution, ...otherResolutions } = this.esmAutomaticImportNameResolutions;
|
|
@@ -64546,11 +64572,11 @@ var require_JSXTransformer = __commonJS({
|
|
|
64546
64572
|
}
|
|
64547
64573
|
claimAutoImportedName(funcName, importPathSuffix) {
|
|
64548
64574
|
if (this.importProcessor) {
|
|
64549
|
-
const
|
|
64550
|
-
if (!this.cjsAutomaticModuleNameResolutions[
|
|
64551
|
-
this.cjsAutomaticModuleNameResolutions[
|
|
64575
|
+
const path90 = this.jsxImportSource + importPathSuffix;
|
|
64576
|
+
if (!this.cjsAutomaticModuleNameResolutions[path90]) {
|
|
64577
|
+
this.cjsAutomaticModuleNameResolutions[path90] = this.importProcessor.getFreeIdentifierForPath(path90);
|
|
64552
64578
|
}
|
|
64553
|
-
return `${this.cjsAutomaticModuleNameResolutions[
|
|
64579
|
+
return `${this.cjsAutomaticModuleNameResolutions[path90]}.${funcName}`;
|
|
64554
64580
|
} else {
|
|
64555
64581
|
if (!this.esmAutomaticImportNameResolutions[funcName]) {
|
|
64556
64582
|
this.esmAutomaticImportNameResolutions[funcName] = this.nameManager.claimFreeName(
|
|
@@ -64986,7 +65012,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
64986
65012
|
*/
|
|
64987
65013
|
pruneTypeOnlyImports() {
|
|
64988
65014
|
this.nonTypeIdentifiers = _getNonTypeIdentifiers.getNonTypeIdentifiers.call(void 0, this.tokens, this.options);
|
|
64989
|
-
for (const [
|
|
65015
|
+
for (const [path90, importInfo] of this.importInfoByPath.entries()) {
|
|
64990
65016
|
if (importInfo.hasBareImport || importInfo.hasStarExport || importInfo.exportStarNames.length > 0 || importInfo.namedExports.length > 0) {
|
|
64991
65017
|
continue;
|
|
64992
65018
|
}
|
|
@@ -64996,7 +65022,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
64996
65022
|
...importInfo.namedImports.map(({ localName }) => localName)
|
|
64997
65023
|
];
|
|
64998
65024
|
if (names3.every((name) => this.shouldAutomaticallyElideImportedName(name))) {
|
|
64999
|
-
this.importsToReplace.set(
|
|
65025
|
+
this.importsToReplace.set(path90, "");
|
|
65000
65026
|
}
|
|
65001
65027
|
}
|
|
65002
65028
|
}
|
|
@@ -65004,7 +65030,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
65004
65030
|
return this.isTypeScriptTransformEnabled && !this.keepUnusedImports && !this.nonTypeIdentifiers.has(name);
|
|
65005
65031
|
}
|
|
65006
65032
|
generateImportReplacements() {
|
|
65007
|
-
for (const [
|
|
65033
|
+
for (const [path90, importInfo] of this.importInfoByPath.entries()) {
|
|
65008
65034
|
const {
|
|
65009
65035
|
defaultNames,
|
|
65010
65036
|
wildcardNames,
|
|
@@ -65014,17 +65040,17 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
65014
65040
|
hasStarExport
|
|
65015
65041
|
} = importInfo;
|
|
65016
65042
|
if (defaultNames.length === 0 && wildcardNames.length === 0 && namedImports.length === 0 && namedExports.length === 0 && exportStarNames.length === 0 && !hasStarExport) {
|
|
65017
|
-
this.importsToReplace.set(
|
|
65043
|
+
this.importsToReplace.set(path90, `require('${path90}');`);
|
|
65018
65044
|
continue;
|
|
65019
65045
|
}
|
|
65020
|
-
const primaryImportName = this.getFreeIdentifierForPath(
|
|
65046
|
+
const primaryImportName = this.getFreeIdentifierForPath(path90);
|
|
65021
65047
|
let secondaryImportName;
|
|
65022
65048
|
if (this.enableLegacyTypeScriptModuleInterop) {
|
|
65023
65049
|
secondaryImportName = primaryImportName;
|
|
65024
65050
|
} else {
|
|
65025
|
-
secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(
|
|
65051
|
+
secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path90);
|
|
65026
65052
|
}
|
|
65027
|
-
let requireCode = `var ${primaryImportName} = require('${
|
|
65053
|
+
let requireCode = `var ${primaryImportName} = require('${path90}');`;
|
|
65028
65054
|
if (wildcardNames.length > 0) {
|
|
65029
65055
|
for (const wildcardName of wildcardNames) {
|
|
65030
65056
|
const moduleExpr = this.enableLegacyTypeScriptModuleInterop ? primaryImportName : `${this.helperManager.getHelperName("interopRequireWildcard")}(${primaryImportName})`;
|
|
@@ -65052,7 +65078,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
65052
65078
|
"createStarExport"
|
|
65053
65079
|
)}(${primaryImportName});`;
|
|
65054
65080
|
}
|
|
65055
|
-
this.importsToReplace.set(
|
|
65081
|
+
this.importsToReplace.set(path90, requireCode);
|
|
65056
65082
|
for (const defaultName of defaultNames) {
|
|
65057
65083
|
this.identifierReplacements.set(defaultName, `${secondaryImportName}.default`);
|
|
65058
65084
|
}
|
|
@@ -65061,8 +65087,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
65061
65087
|
}
|
|
65062
65088
|
}
|
|
65063
65089
|
}
|
|
65064
|
-
getFreeIdentifierForPath(
|
|
65065
|
-
const components =
|
|
65090
|
+
getFreeIdentifierForPath(path90) {
|
|
65091
|
+
const components = path90.split("/");
|
|
65066
65092
|
const lastComponent = components[components.length - 1];
|
|
65067
65093
|
const baseName = lastComponent.replace(/\W/g, "");
|
|
65068
65094
|
return this.nameManager.claimFreeName(`_${baseName}`);
|
|
@@ -65107,8 +65133,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
65107
65133
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
65108
65134
|
throw new Error("Expected string token at the end of import statement.");
|
|
65109
65135
|
}
|
|
65110
|
-
const
|
|
65111
|
-
const importInfo = this.getImportInfo(
|
|
65136
|
+
const path90 = this.tokens.stringValueAtIndex(index);
|
|
65137
|
+
const importInfo = this.getImportInfo(path90);
|
|
65112
65138
|
importInfo.defaultNames.push(...defaultNames);
|
|
65113
65139
|
importInfo.wildcardNames.push(...wildcardNames);
|
|
65114
65140
|
importInfo.namedImports.push(...namedImports);
|
|
@@ -65175,8 +65201,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
65175
65201
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
65176
65202
|
throw new Error("Expected string token at the end of import statement.");
|
|
65177
65203
|
}
|
|
65178
|
-
const
|
|
65179
|
-
const importInfo = this.getImportInfo(
|
|
65204
|
+
const path90 = this.tokens.stringValueAtIndex(index);
|
|
65205
|
+
const importInfo = this.getImportInfo(path90);
|
|
65180
65206
|
importInfo.namedExports.push(...namedImports);
|
|
65181
65207
|
}
|
|
65182
65208
|
preprocessExportStarAtIndex(index) {
|
|
@@ -65191,8 +65217,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
65191
65217
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
65192
65218
|
throw new Error("Expected string token at the end of star export statement.");
|
|
65193
65219
|
}
|
|
65194
|
-
const
|
|
65195
|
-
const importInfo = this.getImportInfo(
|
|
65220
|
+
const path90 = this.tokens.stringValueAtIndex(index);
|
|
65221
|
+
const importInfo = this.getImportInfo(path90);
|
|
65196
65222
|
if (exportedName !== null) {
|
|
65197
65223
|
importInfo.exportStarNames.push(exportedName);
|
|
65198
65224
|
} else {
|
|
@@ -65232,8 +65258,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
65232
65258
|
* Get a mutable import info object for this path, creating one if it doesn't
|
|
65233
65259
|
* exist yet.
|
|
65234
65260
|
*/
|
|
65235
|
-
getImportInfo(
|
|
65236
|
-
const existingInfo = this.importInfoByPath.get(
|
|
65261
|
+
getImportInfo(path90) {
|
|
65262
|
+
const existingInfo = this.importInfoByPath.get(path90);
|
|
65237
65263
|
if (existingInfo) {
|
|
65238
65264
|
return existingInfo;
|
|
65239
65265
|
}
|
|
@@ -65246,7 +65272,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
65246
65272
|
exportStarNames: [],
|
|
65247
65273
|
hasStarExport: false
|
|
65248
65274
|
};
|
|
65249
|
-
this.importInfoByPath.set(
|
|
65275
|
+
this.importInfoByPath.set(path90, newInfo);
|
|
65250
65276
|
return newInfo;
|
|
65251
65277
|
}
|
|
65252
65278
|
addExportBinding(localName, exportedName) {
|
|
@@ -65826,16 +65852,16 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
65826
65852
|
}
|
|
65827
65853
|
function parseFileUrl(input) {
|
|
65828
65854
|
const match = fileRegex.exec(input);
|
|
65829
|
-
const
|
|
65830
|
-
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(
|
|
65855
|
+
const path90 = match[2];
|
|
65856
|
+
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path90) ? path90 : "/" + path90, match[3] || "", match[4] || "");
|
|
65831
65857
|
}
|
|
65832
|
-
function makeUrl(scheme, user, host2, port,
|
|
65858
|
+
function makeUrl(scheme, user, host2, port, path90, query, hash2) {
|
|
65833
65859
|
return {
|
|
65834
65860
|
scheme,
|
|
65835
65861
|
user,
|
|
65836
65862
|
host: host2,
|
|
65837
65863
|
port,
|
|
65838
|
-
path:
|
|
65864
|
+
path: path90,
|
|
65839
65865
|
query,
|
|
65840
65866
|
hash: hash2,
|
|
65841
65867
|
type: 7
|
|
@@ -65865,11 +65891,11 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
65865
65891
|
url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
|
|
65866
65892
|
return url;
|
|
65867
65893
|
}
|
|
65868
|
-
function stripPathFilename(
|
|
65869
|
-
if (
|
|
65870
|
-
return
|
|
65871
|
-
const index =
|
|
65872
|
-
return
|
|
65894
|
+
function stripPathFilename(path90) {
|
|
65895
|
+
if (path90.endsWith("/.."))
|
|
65896
|
+
return path90;
|
|
65897
|
+
const index = path90.lastIndexOf("/");
|
|
65898
|
+
return path90.slice(0, index + 1);
|
|
65873
65899
|
}
|
|
65874
65900
|
function mergePaths(url, base) {
|
|
65875
65901
|
normalizePath(base, base.type);
|
|
@@ -65907,14 +65933,14 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
65907
65933
|
pieces[pointer++] = piece;
|
|
65908
65934
|
positive++;
|
|
65909
65935
|
}
|
|
65910
|
-
let
|
|
65936
|
+
let path90 = "";
|
|
65911
65937
|
for (let i = 1; i < pointer; i++) {
|
|
65912
|
-
|
|
65938
|
+
path90 += "/" + pieces[i];
|
|
65913
65939
|
}
|
|
65914
|
-
if (!
|
|
65915
|
-
|
|
65940
|
+
if (!path90 || addTrailingSlash && !path90.endsWith("/..")) {
|
|
65941
|
+
path90 += "/";
|
|
65916
65942
|
}
|
|
65917
|
-
url.path =
|
|
65943
|
+
url.path = path90;
|
|
65918
65944
|
}
|
|
65919
65945
|
function resolve2(input, base) {
|
|
65920
65946
|
if (!input && !base)
|
|
@@ -65955,13 +65981,13 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
65955
65981
|
case 3:
|
|
65956
65982
|
return queryHash;
|
|
65957
65983
|
case 4: {
|
|
65958
|
-
const
|
|
65959
|
-
if (!
|
|
65984
|
+
const path90 = url.path.slice(1);
|
|
65985
|
+
if (!path90)
|
|
65960
65986
|
return queryHash || ".";
|
|
65961
|
-
if (isRelative(base || input) && !isRelative(
|
|
65962
|
-
return "./" +
|
|
65987
|
+
if (isRelative(base || input) && !isRelative(path90)) {
|
|
65988
|
+
return "./" + path90 + queryHash;
|
|
65963
65989
|
}
|
|
65964
|
-
return
|
|
65990
|
+
return path90 + queryHash;
|
|
65965
65991
|
}
|
|
65966
65992
|
case 5:
|
|
65967
65993
|
return url.path + queryHash;
|
|
@@ -66060,10 +66086,10 @@ var require_trace_mapping_umd = __commonJS({
|
|
|
66060
66086
|
module2.exports = __toCommonJS(trace_mapping_exports);
|
|
66061
66087
|
var import_sourcemap_codec = __toESM2(require_sourcemap_codec());
|
|
66062
66088
|
var import_resolve_uri = __toESM2(require_resolve_uri());
|
|
66063
|
-
function stripFilename(
|
|
66064
|
-
if (!
|
|
66065
|
-
const index =
|
|
66066
|
-
return
|
|
66089
|
+
function stripFilename(path90) {
|
|
66090
|
+
if (!path90) return "";
|
|
66091
|
+
const index = path90.lastIndexOf("/");
|
|
66092
|
+
return path90.slice(0, index + 1);
|
|
66067
66093
|
}
|
|
66068
66094
|
function resolver2(mapUrl, sourceRoot) {
|
|
66069
66095
|
const from = stripFilename(mapUrl);
|
|
@@ -67271,9 +67297,9 @@ var require_util2 = __commonJS({
|
|
|
67271
67297
|
/** @class */
|
|
67272
67298
|
(function(_super) {
|
|
67273
67299
|
__extends(VError2, _super);
|
|
67274
|
-
function VError2(
|
|
67300
|
+
function VError2(path90, message) {
|
|
67275
67301
|
var _this = _super.call(this, message) || this;
|
|
67276
|
-
_this.path =
|
|
67302
|
+
_this.path = path90;
|
|
67277
67303
|
Object.setPrototypeOf(_this, VError2.prototype);
|
|
67278
67304
|
return _this;
|
|
67279
67305
|
}
|
|
@@ -67333,26 +67359,26 @@ var require_util2 = __commonJS({
|
|
|
67333
67359
|
(_b = this._messages).push.apply(_b, best._messages);
|
|
67334
67360
|
}
|
|
67335
67361
|
};
|
|
67336
|
-
DetailContext2.prototype.getError = function(
|
|
67362
|
+
DetailContext2.prototype.getError = function(path90) {
|
|
67337
67363
|
var msgParts = [];
|
|
67338
67364
|
for (var i = this._propNames.length - 1; i >= 0; i--) {
|
|
67339
67365
|
var p2 = this._propNames[i];
|
|
67340
|
-
|
|
67366
|
+
path90 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
|
|
67341
67367
|
var m = this._messages[i];
|
|
67342
67368
|
if (m) {
|
|
67343
|
-
msgParts.push(
|
|
67369
|
+
msgParts.push(path90 + " " + m);
|
|
67344
67370
|
}
|
|
67345
67371
|
}
|
|
67346
|
-
return new VError(
|
|
67372
|
+
return new VError(path90, msgParts.join("; "));
|
|
67347
67373
|
};
|
|
67348
|
-
DetailContext2.prototype.getErrorDetail = function(
|
|
67374
|
+
DetailContext2.prototype.getErrorDetail = function(path90) {
|
|
67349
67375
|
var details = [];
|
|
67350
67376
|
for (var i = this._propNames.length - 1; i >= 0; i--) {
|
|
67351
67377
|
var p2 = this._propNames[i];
|
|
67352
|
-
|
|
67378
|
+
path90 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
|
|
67353
67379
|
var message = this._messages[i];
|
|
67354
67380
|
if (message) {
|
|
67355
|
-
details.push({ path:
|
|
67381
|
+
details.push({ path: path90, message });
|
|
67356
67382
|
}
|
|
67357
67383
|
}
|
|
67358
67384
|
var detail = null;
|
|
@@ -68165,8 +68191,8 @@ var require_dist = __commonJS({
|
|
|
68165
68191
|
this.checkerPlain = this.ttype.getChecker(suite, false);
|
|
68166
68192
|
this.checkerStrict = this.ttype.getChecker(suite, true);
|
|
68167
68193
|
}
|
|
68168
|
-
Checker2.prototype.setReportedPath = function(
|
|
68169
|
-
this._path =
|
|
68194
|
+
Checker2.prototype.setReportedPath = function(path90) {
|
|
68195
|
+
this._path = path90;
|
|
68170
68196
|
};
|
|
68171
68197
|
Checker2.prototype.check = function(value) {
|
|
68172
68198
|
return this._doCheck(this.checkerPlain, value);
|
|
@@ -73599,9 +73625,9 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
73599
73625
|
if (shouldElideImport) {
|
|
73600
73626
|
this.tokens.removeToken();
|
|
73601
73627
|
} else {
|
|
73602
|
-
const
|
|
73603
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
73604
|
-
this.tokens.appendCode(this.importProcessor.claimImportCode(
|
|
73628
|
+
const path90 = this.tokens.stringValue();
|
|
73629
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
|
|
73630
|
+
this.tokens.appendCode(this.importProcessor.claimImportCode(path90));
|
|
73605
73631
|
}
|
|
73606
73632
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
73607
73633
|
if (this.tokens.matches1(_types.TokenType.semi)) {
|
|
@@ -74181,8 +74207,8 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
74181
74207
|
}
|
|
74182
74208
|
if (this.tokens.matchesContextual(_keywords.ContextualKeyword._from)) {
|
|
74183
74209
|
this.tokens.removeToken();
|
|
74184
|
-
const
|
|
74185
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
74210
|
+
const path90 = this.tokens.stringValue();
|
|
74211
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
|
|
74186
74212
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
74187
74213
|
} else {
|
|
74188
74214
|
this.tokens.appendCode(exportStatements.join(" "));
|
|
@@ -74196,8 +74222,8 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
74196
74222
|
while (!this.tokens.matches1(_types.TokenType.string)) {
|
|
74197
74223
|
this.tokens.removeToken();
|
|
74198
74224
|
}
|
|
74199
|
-
const
|
|
74200
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
74225
|
+
const path90 = this.tokens.stringValue();
|
|
74226
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path90));
|
|
74201
74227
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
74202
74228
|
if (this.tokens.matches1(_types.TokenType.semi)) {
|
|
74203
74229
|
this.tokens.removeToken();
|
|
@@ -104051,9 +104077,9 @@ var init_bundle_mjs = __esm({
|
|
|
104051
104077
|
processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
|
|
104052
104078
|
}
|
|
104053
104079
|
};
|
|
104054
|
-
getPart = (classPartObject,
|
|
104080
|
+
getPart = (classPartObject, path90) => {
|
|
104055
104081
|
let current = classPartObject;
|
|
104056
|
-
const parts =
|
|
104082
|
+
const parts = path90.split(CLASS_PART_SEPARATOR);
|
|
104057
104083
|
const len = parts.length;
|
|
104058
104084
|
for (let i = 0; i < len; i++) {
|
|
104059
104085
|
const part = parts[i];
|
|
@@ -107303,8 +107329,8 @@ var init_dist = __esm({
|
|
|
107303
107329
|
});
|
|
107304
107330
|
|
|
107305
107331
|
// ../cli/src/lib/draw-mockup.ts
|
|
107306
|
-
import
|
|
107307
|
-
import
|
|
107332
|
+
import fs83 from "node:fs";
|
|
107333
|
+
import path84 from "node:path";
|
|
107308
107334
|
import vm from "node:vm";
|
|
107309
107335
|
async function loadPackage(id) {
|
|
107310
107336
|
if (id === "react") return import_react3.default;
|
|
@@ -107317,22 +107343,22 @@ async function loadPackage(id) {
|
|
|
107317
107343
|
return { __esModule: true, ...await load() };
|
|
107318
107344
|
}
|
|
107319
107345
|
function resolveFile(id, from, folder) {
|
|
107320
|
-
const at2 =
|
|
107321
|
-
if (at2 !== folder && !at2.startsWith(folder +
|
|
107322
|
-
const tries =
|
|
107323
|
-
const file = tries.find((f2) =>
|
|
107346
|
+
const at2 = path84.resolve(path84.dirname(from), id);
|
|
107347
|
+
if (at2 !== folder && !at2.startsWith(folder + path84.sep)) throw new Error(`${id} is outside the mockup's folder`);
|
|
107348
|
+
const tries = path84.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path84.join(at2, `index${e2}`))];
|
|
107349
|
+
const file = tries.find((f2) => fs83.statSync(f2, { throwIfNoEntry: false })?.isFile());
|
|
107324
107350
|
if (!file) throw new Error(`no such file: ${id}`);
|
|
107325
107351
|
return file;
|
|
107326
107352
|
}
|
|
107327
107353
|
async function readGraph(entry) {
|
|
107328
|
-
const folder =
|
|
107354
|
+
const folder = path84.dirname(entry);
|
|
107329
107355
|
const graph = { code: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), sheets: [], packages: /* @__PURE__ */ new Map() };
|
|
107330
107356
|
const walk3 = async (file) => {
|
|
107331
107357
|
if (graph.code.has(file)) return;
|
|
107332
107358
|
if (graph.code.size >= MAX_FILES) throw new Error(`a mockup imports more than ${MAX_FILES} files`);
|
|
107333
107359
|
let location = file;
|
|
107334
107360
|
try {
|
|
107335
|
-
const js = (0, import_sucrase.transform)(
|
|
107361
|
+
const js = (0, import_sucrase.transform)(fs83.readFileSync(file, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file }).code;
|
|
107336
107362
|
graph.code.set(file, js);
|
|
107337
107363
|
const link2 = /* @__PURE__ */ new Map();
|
|
107338
107364
|
graph.links.set(file, link2);
|
|
@@ -107346,7 +107372,7 @@ async function readGraph(entry) {
|
|
|
107346
107372
|
const target = resolveFile(id, file, folder);
|
|
107347
107373
|
link2.set(id, target);
|
|
107348
107374
|
if (!target.endsWith(".css")) await walk3(target);
|
|
107349
|
-
else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content:
|
|
107375
|
+
else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs83.readFileSync(target, "utf8") });
|
|
107350
107376
|
}
|
|
107351
107377
|
} catch (error) {
|
|
107352
107378
|
throw new Error(`${location}: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -107363,12 +107389,12 @@ function run2(script, context, name, deadline, lineOffset = 0) {
|
|
|
107363
107389
|
async function tailwindFor(markup, sheets) {
|
|
107364
107390
|
const source = sheets.length ? sheets.map((s) => s.content).join("\n") : '@import "tailwindcss";';
|
|
107365
107391
|
const compiler = await rc(source, {
|
|
107366
|
-
base: sheets.length ?
|
|
107392
|
+
base: sheets.length ? path84.dirname(sheets[0].path) : "/",
|
|
107367
107393
|
loadStylesheet: async (id, from) => {
|
|
107368
107394
|
if (id === "tailwindcss" || id.startsWith("tailwindcss/")) return { path: "tailwindcss/index.css", base: "/", content: tailwindcss_default };
|
|
107369
107395
|
if (!id.startsWith(".")) throw new Error(`a mockup cannot import ${id}`);
|
|
107370
|
-
const at2 =
|
|
107371
|
-
return { path: at2, base:
|
|
107396
|
+
const at2 = path84.resolve(from, id);
|
|
107397
|
+
return { path: at2, base: path84.dirname(at2), content: fs83.readFileSync(at2, "utf8") };
|
|
107372
107398
|
}
|
|
107373
107399
|
});
|
|
107374
107400
|
const classes = [...markup.matchAll(/class="([^"]*)"/g)].flatMap((m) => m[1].split(/\s+/));
|
|
@@ -107477,8 +107503,8 @@ var init_draw_mockup = __esm({
|
|
|
107477
107503
|
});
|
|
107478
107504
|
|
|
107479
107505
|
// ../cli/src/lib/preview-validation.ts
|
|
107480
|
-
import
|
|
107481
|
-
import
|
|
107506
|
+
import fs84 from "node:fs";
|
|
107507
|
+
import path85 from "node:path";
|
|
107482
107508
|
function renderError(error) {
|
|
107483
107509
|
if (!error || typeof error !== "object") return String(error);
|
|
107484
107510
|
const { message, stack } = error;
|
|
@@ -107489,7 +107515,7 @@ function renderError(error) {
|
|
|
107489
107515
|
async function validateScreens(files2) {
|
|
107490
107516
|
const errors = [];
|
|
107491
107517
|
const entries = /* @__PURE__ */ new Map();
|
|
107492
|
-
for (const file of files2) entries.set(
|
|
107518
|
+
for (const file of files2) entries.set(fs84.existsSync(file) ? fs84.realpathSync(file) : path85.resolve(file), path85.resolve(file));
|
|
107493
107519
|
for (const file of entries.values()) {
|
|
107494
107520
|
try {
|
|
107495
107521
|
await drawMockup(file);
|
|
@@ -107508,7 +107534,7 @@ async function validatePreview(file, text5) {
|
|
|
107508
107534
|
if (/^ {0,3}<!--\s*agent\s*-->\s*$/.test(line)) own = false;
|
|
107509
107535
|
if (own) section.push(line);
|
|
107510
107536
|
}
|
|
107511
|
-
const files2 = bodySources(section.join("\n")).filter((src) => !/^[a-z][\w+.-]*:|^#|^\/\//i.test(src) && kindOf(
|
|
107537
|
+
const files2 = bodySources(section.join("\n")).filter((src) => !/^[a-z][\w+.-]*:|^#|^\/\//i.test(src) && kindOf(path85.extname(src).toLowerCase()) === "html").map((src) => src.startsWith(".assets/") ? path85.join(ASSETS, src.slice(8)) : src.startsWith(".mockups/") ? path85.join(MOCKUPS, src.slice(9)) : path85.resolve(path85.dirname(file), src));
|
|
107512
107538
|
return validateScreens(files2);
|
|
107513
107539
|
}
|
|
107514
107540
|
var init_preview_validation = __esm({
|
|
@@ -107665,7 +107691,7 @@ __export(watch_exports, {
|
|
|
107665
107691
|
watchRun: () => watchRun
|
|
107666
107692
|
});
|
|
107667
107693
|
import { spawn as spawn4 } from "node:child_process";
|
|
107668
|
-
import
|
|
107694
|
+
import fs85 from "node:fs";
|
|
107669
107695
|
async function watchRun(sessionId, resume = startResume) {
|
|
107670
107696
|
const spec = readSpec(sessionId);
|
|
107671
107697
|
const run3 = peekRun(sessionId);
|
|
@@ -107701,11 +107727,11 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
107701
107727
|
const record = claimed ?? run3;
|
|
107702
107728
|
const sub = record.action === "sub";
|
|
107703
107729
|
if (claim) await setCardStatus(claim.cardId, claim.status);
|
|
107704
|
-
|
|
107705
|
-
const logFile =
|
|
107730
|
+
fs85.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
107731
|
+
const logFile = fs85.createWriteStream(record.logPath, { flags: "a" });
|
|
107706
107732
|
logFile.on("error", () => {
|
|
107707
107733
|
});
|
|
107708
|
-
const eventsFile =
|
|
107734
|
+
const eventsFile = fs85.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
|
|
107709
107735
|
eventsFile.on("error", () => {
|
|
107710
107736
|
});
|
|
107711
107737
|
const event2 = (e2) => eventsFile.write(`${JSON.stringify(e2)}
|
|
@@ -108291,7 +108317,7 @@ var init_watch = __esm({
|
|
|
108291
108317
|
});
|
|
108292
108318
|
|
|
108293
108319
|
// ../cli/src/kanban.ts
|
|
108294
|
-
import
|
|
108320
|
+
import fs91 from "node:fs";
|
|
108295
108321
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
108296
108322
|
|
|
108297
108323
|
// ../cli/src/lib/cli/agent.ts
|
|
@@ -108774,8 +108800,8 @@ async function testAgent(args) {
|
|
|
108774
108800
|
}
|
|
108775
108801
|
|
|
108776
108802
|
// ../cli/src/commands/cloud.ts
|
|
108777
|
-
import
|
|
108778
|
-
import
|
|
108803
|
+
import fs73 from "node:fs";
|
|
108804
|
+
import path74 from "node:path";
|
|
108779
108805
|
|
|
108780
108806
|
// ../cli/src/lib/cloud/avatar.ts
|
|
108781
108807
|
init_session();
|
|
@@ -108823,13 +108849,13 @@ init_config();
|
|
|
108823
108849
|
init_home();
|
|
108824
108850
|
init_config();
|
|
108825
108851
|
init_session();
|
|
108826
|
-
import
|
|
108827
|
-
import
|
|
108852
|
+
import fs72 from "node:fs";
|
|
108853
|
+
import path73 from "node:path";
|
|
108828
108854
|
var FRESH_MS2 = 10 * 6e4;
|
|
108829
108855
|
var GRACE_MS = 7 * 24 * 60 * 6e4;
|
|
108830
|
-
var heldFile = () =>
|
|
108856
|
+
var heldFile = () => path73.join(machineHome(), "pro.json");
|
|
108831
108857
|
function forgetPro() {
|
|
108832
|
-
|
|
108858
|
+
fs72.rmSync(heldFile(), { force: true });
|
|
108833
108859
|
}
|
|
108834
108860
|
|
|
108835
108861
|
// ../cli/src/lib/cloud/account.ts
|
|
@@ -109006,10 +109032,10 @@ async function cloudImage(opts, program2) {
|
|
|
109006
109032
|
const prompt = opts.prompt.trim();
|
|
109007
109033
|
if (!prompt) usage("Missing the prompt.", line);
|
|
109008
109034
|
const references = opts.refs.map((file) => {
|
|
109009
|
-
const type = REF_TYPES[
|
|
109035
|
+
const type = REF_TYPES[path74.extname(file).toLowerCase()];
|
|
109010
109036
|
if (!type) usage(`--ref ${file}: use a PNG, JPEG or WebP file.`, line);
|
|
109011
109037
|
try {
|
|
109012
|
-
return `data:${type};base64,${
|
|
109038
|
+
return `data:${type};base64,${fs73.readFileSync(file).toString("base64")}`;
|
|
109013
109039
|
} catch (e2) {
|
|
109014
109040
|
usage(`--ref ${file}: ${e2 instanceof Error ? e2.message : String(e2)}`, line);
|
|
109015
109041
|
}
|
|
@@ -109115,8 +109141,8 @@ async function generate(g3) {
|
|
|
109115
109141
|
refuse(g3.failed, g3.fallback);
|
|
109116
109142
|
}
|
|
109117
109143
|
const out = g3.outFor?.(res, g3.out) ?? g3.out;
|
|
109118
|
-
|
|
109119
|
-
|
|
109144
|
+
fs73.mkdirSync(path74.dirname(path74.resolve(out)), { recursive: true });
|
|
109145
|
+
fs73.writeFileSync(out, Buffer.from(await res.arrayBuffer()));
|
|
109120
109146
|
say(`${out} (${g3.label(res)})`);
|
|
109121
109147
|
return { out };
|
|
109122
109148
|
}
|
|
@@ -109125,14 +109151,14 @@ async function generate(g3) {
|
|
|
109125
109151
|
init_board_files();
|
|
109126
109152
|
init_workflow_files();
|
|
109127
109153
|
import crypto6 from "node:crypto";
|
|
109128
|
-
import
|
|
109129
|
-
import
|
|
109154
|
+
import fs75 from "node:fs";
|
|
109155
|
+
import path76 from "node:path";
|
|
109130
109156
|
|
|
109131
109157
|
// ../cli/src/lib/agents/shared-memory.ts
|
|
109132
109158
|
init_bundled2();
|
|
109133
109159
|
init_parse();
|
|
109134
|
-
import
|
|
109135
|
-
import
|
|
109160
|
+
import fs74 from "node:fs";
|
|
109161
|
+
import path75 from "node:path";
|
|
109136
109162
|
function sharedMemory(board2) {
|
|
109137
109163
|
const declared = /* @__PURE__ */ new Map();
|
|
109138
109164
|
const take = (folder, text5, builtIn) => {
|
|
@@ -109144,16 +109170,16 @@ function sharedMemory(board2) {
|
|
|
109144
109170
|
const at2 = /^([^/]+)\/AGENT\.md$/.exec(key);
|
|
109145
109171
|
if (at2) take(at2[1], text5, officialAgent(at2[1]));
|
|
109146
109172
|
}
|
|
109147
|
-
const root2 =
|
|
109173
|
+
const root2 = path75.join(board2, "agents");
|
|
109148
109174
|
let folders2 = [];
|
|
109149
109175
|
try {
|
|
109150
|
-
folders2 =
|
|
109176
|
+
folders2 = fs74.readdirSync(root2, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".")).map((e2) => e2.name);
|
|
109151
109177
|
} catch {
|
|
109152
109178
|
}
|
|
109153
109179
|
for (const folder of folders2.sort()) {
|
|
109154
109180
|
let text5 = null;
|
|
109155
109181
|
try {
|
|
109156
|
-
text5 =
|
|
109182
|
+
text5 = fs74.readFileSync(path75.join(root2, folder, "AGENT.md"), "utf8");
|
|
109157
109183
|
} catch {
|
|
109158
109184
|
}
|
|
109159
109185
|
take(folder, text5, false);
|
|
@@ -109242,24 +109268,24 @@ async function findProject(asked) {
|
|
|
109242
109268
|
}
|
|
109243
109269
|
throw new Refused(`No project of yours has the id or prefix "${asked}".`, "not_found");
|
|
109244
109270
|
}
|
|
109245
|
-
var read2 = (file) =>
|
|
109271
|
+
var read2 = (file) => fs75.readFileSync(file, "utf8");
|
|
109246
109272
|
var bytes2 = (text5) => Buffer.byteLength(text5, "utf8");
|
|
109247
109273
|
function files(dir) {
|
|
109248
|
-
if (!
|
|
109274
|
+
if (!fs75.existsSync(dir)) return [];
|
|
109249
109275
|
const out = [];
|
|
109250
|
-
for (const entry of
|
|
109276
|
+
for (const entry of fs75.readdirSync(dir, { withFileTypes: true })) {
|
|
109251
109277
|
if (entry.name.startsWith(".")) continue;
|
|
109252
|
-
const full =
|
|
109278
|
+
const full = path76.join(dir, entry.name);
|
|
109253
109279
|
if (entry.isDirectory()) out.push(...files(full));
|
|
109254
109280
|
else if (entry.isFile()) out.push(full);
|
|
109255
109281
|
}
|
|
109256
109282
|
return out;
|
|
109257
109283
|
}
|
|
109258
|
-
var posix = (p2) => p2.split(
|
|
109284
|
+
var posix = (p2) => p2.split(path76.sep).join("/");
|
|
109259
109285
|
function openCards() {
|
|
109260
109286
|
const out = [];
|
|
109261
109287
|
for (const file of walkMd(TODO)) {
|
|
109262
|
-
const rel2 = posix(
|
|
109288
|
+
const rel2 = posix(path76.relative(TODO, file));
|
|
109263
109289
|
if (rel2 === "README.md") continue;
|
|
109264
109290
|
const parts = rel2.split("/");
|
|
109265
109291
|
const text5 = read2(file);
|
|
@@ -109346,8 +109372,8 @@ function draftsOf(text5) {
|
|
|
109346
109372
|
const at2 = /^\.(assets|mockups)\/(.+)$/.exec(name);
|
|
109347
109373
|
if (!at2) continue;
|
|
109348
109374
|
const base = at2[1] === "assets" ? ASSETS : MOCKUPS;
|
|
109349
|
-
const file =
|
|
109350
|
-
if (file.startsWith(base +
|
|
109375
|
+
const file = path76.resolve(base, at2[2]);
|
|
109376
|
+
if (file.startsWith(base + path76.sep) && fs75.statSync(file, { throwIfNoEntry: false })?.isFile()) out.set(name, file);
|
|
109351
109377
|
}
|
|
109352
109378
|
return [...out].map(([name, file]) => ({ name, file }));
|
|
109353
109379
|
}
|
|
@@ -109381,9 +109407,9 @@ async function uploadDrafts(task, drafts) {
|
|
|
109381
109407
|
const assets = {};
|
|
109382
109408
|
for (const { name, file } of drafts) {
|
|
109383
109409
|
if (!card.body.includes(name)) continue;
|
|
109384
|
-
const ext =
|
|
109410
|
+
const ext = path76.extname(file).toLowerCase();
|
|
109385
109411
|
const type = TYPES2[ext] ?? "application/octet-stream";
|
|
109386
|
-
const data =
|
|
109412
|
+
const data = fs75.readFileSync(file);
|
|
109387
109413
|
const artifact = await api("POST", `/v1/tasks/${task}/artifacts`, { type: kindOf2(ext), name: name.slice(0, 200) });
|
|
109388
109414
|
const upload = await api("POST", `/v1/artifacts/${artifact.id}/uploads`, { content_type: type, size: Math.max(data.length, 1) });
|
|
109389
109415
|
await api("PUT", `/v1/uploads/${upload.id}`, void 0, { bytes: data, type });
|
|
@@ -109426,7 +109452,7 @@ usage: ${program2} cloud import --project <id or prefix> [--dry-run]`, { kind: "
|
|
|
109426
109452
|
function localWorkflowFolders() {
|
|
109427
109453
|
let folders2;
|
|
109428
109454
|
try {
|
|
109429
|
-
folders2 =
|
|
109455
|
+
folders2 = fs75.readdirSync(WORKFLOWS, { withFileTypes: true }).filter((e2) => e2.isDirectory() && !e2.name.startsWith(".") && !e2.name.startsWith("task-")).map((e2) => e2.name).sort((a2, b2) => a2.localeCompare(b2, "en", { numeric: true }));
|
|
109430
109456
|
} catch {
|
|
109431
109457
|
return [];
|
|
109432
109458
|
}
|
|
@@ -109437,19 +109463,19 @@ function localWorkflowFolders() {
|
|
|
109437
109463
|
});
|
|
109438
109464
|
}
|
|
109439
109465
|
function filesUnder(dir, base = dir) {
|
|
109440
|
-
return
|
|
109441
|
-
const full =
|
|
109442
|
-
return e2.isDirectory() ? filesUnder(full, base) : [posix(
|
|
109466
|
+
return fs75.readdirSync(dir, { withFileTypes: true }).flatMap((e2) => {
|
|
109467
|
+
const full = path76.join(dir, e2.name);
|
|
109468
|
+
return e2.isDirectory() ? filesUnder(full, base) : [posix(path76.relative(base, full))];
|
|
109443
109469
|
});
|
|
109444
109470
|
}
|
|
109445
109471
|
function packLocalWorkflow(id, def, shipped) {
|
|
109446
|
-
const dir =
|
|
109447
|
-
const out = Object.fromEntries(filesUnder(dir).map((f2) => [f2,
|
|
109472
|
+
const dir = path76.join(WORKFLOWS, id);
|
|
109473
|
+
const out = Object.fromEntries(filesUnder(dir).map((f2) => [f2, fs75.readFileSync(path76.join(dir, f2), "utf8")]));
|
|
109448
109474
|
const named2 = [...def.previews, ...def.land, ...def.scheduled].map((h3) => h3.agent);
|
|
109449
109475
|
for (const agent of new Set(named2)) {
|
|
109450
|
-
const at2 =
|
|
109451
|
-
if (
|
|
109452
|
-
for (const file of filesUnder(at2)) out[`agents/${agent}/${file}`] =
|
|
109476
|
+
const at2 = path76.join(AGENTS, agent);
|
|
109477
|
+
if (fs75.existsSync(path76.join(at2, "AGENT.md"))) {
|
|
109478
|
+
for (const file of filesUnder(at2)) out[`agents/${agent}/${file}`] = fs75.readFileSync(path76.join(at2, file), "utf8");
|
|
109453
109479
|
continue;
|
|
109454
109480
|
}
|
|
109455
109481
|
for (const [key, text5] of Object.entries(shipped)) if (key.startsWith(`${agent}/`)) out[`agents/${key}`] = text5;
|
|
@@ -109459,10 +109485,10 @@ function packLocalWorkflow(id, def, shipped) {
|
|
|
109459
109485
|
async function run(asked, dryRun) {
|
|
109460
109486
|
const project = await findProject(asked);
|
|
109461
109487
|
const cloudFlows2 = await all(`/v1/workflows?workspace=${encodeURIComponent(project.workspace)}`);
|
|
109462
|
-
const board2 = crypto6.createHash("sha256").update(
|
|
109488
|
+
const board2 = crypto6.createHash("sha256").update(fs75.realpathSync(KANBAN)).digest("hex").slice(0, 16);
|
|
109463
109489
|
const cards = openCards();
|
|
109464
109490
|
const problems = [];
|
|
109465
|
-
const where = (file) => posix(
|
|
109491
|
+
const where = (file) => posix(path76.relative(KANBAN, file));
|
|
109466
109492
|
const own = [];
|
|
109467
109493
|
for (const f2 of localWorkflowFolders()) {
|
|
109468
109494
|
if (f2.def) own.push({ id: f2.id, name: f2.def.name, def: f2.def });
|
|
@@ -109491,7 +109517,7 @@ async function run(asked, dryRun) {
|
|
|
109491
109517
|
const root2 = `projects/${project.id}/`;
|
|
109492
109518
|
const boardFiles = [];
|
|
109493
109519
|
for (const file of [...files(MEMORY), ...files(RULES), CONFIG, MODULES_MD]) {
|
|
109494
|
-
if (!
|
|
109520
|
+
if (!fs75.existsSync(file)) continue;
|
|
109495
109521
|
const rel2 = where(file);
|
|
109496
109522
|
if (!isBoardPath(rel2)) continue;
|
|
109497
109523
|
const content = read2(file);
|
|
@@ -109602,16 +109628,16 @@ async function run(asked, dryRun) {
|
|
|
109602
109628
|
}
|
|
109603
109629
|
function leftLocal(own) {
|
|
109604
109630
|
const out = [];
|
|
109605
|
-
const count4 = (dir) =>
|
|
109631
|
+
const count4 = (dir) => fs75.existsSync(dir) ? walkMd(dir).length : 0;
|
|
109606
109632
|
const archived = count4(ARCHIVE);
|
|
109607
109633
|
if (archived) out.push(`.archive/ (${archived})`);
|
|
109608
109634
|
const triage = count4(TRIAGE);
|
|
109609
109635
|
if (triage) out.push(`triage/ (${triage})`);
|
|
109610
|
-
if (
|
|
109611
|
-
if (
|
|
109636
|
+
if (fs75.existsSync(DELIVERIES)) out.push("deliveries/");
|
|
109637
|
+
if (fs75.existsSync(path76.join(KANBAN, "metrics.csv"))) out.push("metrics.csv");
|
|
109612
109638
|
const named2 = new Set(own.flatMap((w2) => [...w2.def.previews, ...w2.def.land, ...w2.def.scheduled].map((h3) => h3.agent)));
|
|
109613
|
-
if (
|
|
109614
|
-
for (const e2 of
|
|
109639
|
+
if (fs75.existsSync(AGENTS)) {
|
|
109640
|
+
for (const e2 of fs75.readdirSync(AGENTS, { withFileTypes: true })) {
|
|
109615
109641
|
if (e2.isDirectory() && !e2.name.startsWith(".") && !named2.has(e2.name)) out.push(`agents/${e2.name}/`);
|
|
109616
109642
|
}
|
|
109617
109643
|
}
|
|
@@ -109629,8 +109655,8 @@ init_session();
|
|
|
109629
109655
|
init_io();
|
|
109630
109656
|
init_paths();
|
|
109631
109657
|
import { createHash as createHash5 } from "node:crypto";
|
|
109632
|
-
import
|
|
109633
|
-
import
|
|
109658
|
+
import fs76 from "node:fs";
|
|
109659
|
+
import path77 from "node:path";
|
|
109634
109660
|
var SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
109635
109661
|
var CAPTURED = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})$/;
|
|
109636
109662
|
var MAX_BYTES3 = 50 * 1024 * 1024;
|
|
@@ -109729,10 +109755,10 @@ This template has no preview.`);
|
|
|
109729
109755
|
const written = [];
|
|
109730
109756
|
for (const p2 of previews) {
|
|
109731
109757
|
const bytes3 = Buffer.from(await (await ask(`/${at2}/previews/${route(p2.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
109732
|
-
const file =
|
|
109733
|
-
const out =
|
|
109734
|
-
|
|
109735
|
-
|
|
109758
|
+
const file = path77.basename(p2.path);
|
|
109759
|
+
const out = path77.join(opts.to, file.startsWith(`${name}-`) ? file : `${name}-${file}`);
|
|
109760
|
+
fs76.mkdirSync(opts.to, { recursive: true });
|
|
109761
|
+
fs76.writeFileSync(out, bytes3);
|
|
109736
109762
|
written.push(out);
|
|
109737
109763
|
say(out);
|
|
109738
109764
|
}
|
|
@@ -109745,15 +109771,15 @@ async function templateGet(name, opts, program2) {
|
|
|
109745
109771
|
const { template } = await asJson(await ask(`/${at2}`, {}, WITHOUT));
|
|
109746
109772
|
const fetched = [];
|
|
109747
109773
|
for (const f2 of template.files) {
|
|
109748
|
-
const out =
|
|
109749
|
-
if (!out.startsWith(
|
|
109774
|
+
const out = path77.resolve(to, f2.path);
|
|
109775
|
+
if (!out.startsWith(path77.resolve(to) + path77.sep)) refuse2(T.corrupt, WITHOUT);
|
|
109750
109776
|
const bytes3 = Buffer.from(await (await ask(`/${at2}/files/${route(f2.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
109751
109777
|
if (bytes3.byteLength !== f2.size || createHash5("sha256").update(bytes3).digest("hex") !== f2.sha256) {
|
|
109752
109778
|
refuse2(T.corrupt, WITHOUT);
|
|
109753
109779
|
}
|
|
109754
109780
|
fetched.push({ out, bytes: bytes3 });
|
|
109755
109781
|
}
|
|
109756
|
-
const taken = fetched.filter((f2) =>
|
|
109782
|
+
const taken = fetched.filter((f2) => fs76.existsSync(f2.out)).map((f2) => path77.relative(to, f2.out));
|
|
109757
109783
|
if (taken.length > 0) {
|
|
109758
109784
|
refuse2({
|
|
109759
109785
|
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`,
|
|
@@ -109761,8 +109787,8 @@ async function templateGet(name, opts, program2) {
|
|
|
109761
109787
|
});
|
|
109762
109788
|
}
|
|
109763
109789
|
for (const f2 of fetched) {
|
|
109764
|
-
|
|
109765
|
-
|
|
109790
|
+
fs76.mkdirSync(path77.dirname(f2.out), { recursive: true });
|
|
109791
|
+
fs76.writeFileSync(f2.out, f2.bytes);
|
|
109766
109792
|
}
|
|
109767
109793
|
say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
|
|
109768
109794
|
Fetched ${name}: ${fetched.length} files into ${to}`);
|
|
@@ -109780,25 +109806,25 @@ async function templateSource(name, opts) {
|
|
|
109780
109806
|
say(`evidence: ${e2.path}`);
|
|
109781
109807
|
continue;
|
|
109782
109808
|
}
|
|
109783
|
-
const out =
|
|
109784
|
-
|
|
109785
|
-
|
|
109809
|
+
const out = path77.join(opts.to, `${name}-${path77.basename(e2.path)}`);
|
|
109810
|
+
fs76.mkdirSync(opts.to, { recursive: true });
|
|
109811
|
+
fs76.writeFileSync(out, Buffer.from(await (await ask(`/${at2}/evidence/${route(e2.path)}`)).arrayBuffer()));
|
|
109786
109812
|
written.push(out);
|
|
109787
109813
|
say(out);
|
|
109788
109814
|
}
|
|
109789
109815
|
return { name, source, evidence: written.length > 0 ? written : evidence.map((e2) => e2.path) };
|
|
109790
109816
|
}
|
|
109791
109817
|
async function templatePublish(dir, opts) {
|
|
109792
|
-
const root2 =
|
|
109793
|
-
const manifest =
|
|
109794
|
-
if (!
|
|
109795
|
-
const meta = readTemplateMeta(
|
|
109818
|
+
const root2 = path77.resolve(dir);
|
|
109819
|
+
const manifest = path77.join(root2, "template.md");
|
|
109820
|
+
if (!fs76.existsSync(manifest)) invalid("\u6587\u4EF6\u5939\u9876\u5C42\u7F3A\u5C11 template.md\u3002", "template.md is missing from the folder\u2019s top level.");
|
|
109821
|
+
const meta = readTemplateMeta(fs76.readFileSync(manifest, "utf8"));
|
|
109796
109822
|
const files2 = walk2(root2);
|
|
109797
|
-
const total = files2.reduce((sum, f2) => sum +
|
|
109823
|
+
const total = files2.reduce((sum, f2) => sum + fs76.statSync(path77.join(root2, f2)).size, 0);
|
|
109798
109824
|
if (total > MAX_BYTES3) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
|
|
109799
109825
|
for (const extra of [...opts.preview, ...opts.evidence]) {
|
|
109800
|
-
if (!
|
|
109801
|
-
if (
|
|
109826
|
+
if (!fs76.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
|
|
109827
|
+
if (path77.resolve(extra).startsWith(root2 + path77.sep)) {
|
|
109802
109828
|
invalid(
|
|
109803
109829
|
`${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`,
|
|
109804
109830
|
`${extra} is inside the template folder; keep previews and evidence outside it.`
|
|
@@ -109810,10 +109836,10 @@ async function templatePublish(dir, opts) {
|
|
|
109810
109836
|
}
|
|
109811
109837
|
const form = new FormData();
|
|
109812
109838
|
form.set("meta", JSON.stringify({ ...meta, replace: !!opts.replace }));
|
|
109813
|
-
const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([
|
|
109814
|
-
for (const f2 of files2) add("files", f2,
|
|
109815
|
-
for (const f2 of opts.preview) add("previews",
|
|
109816
|
-
for (const f2 of opts.evidence) add("evidence",
|
|
109839
|
+
const add = (kind, name, file) => form.append(`${kind}:${name}`, new Blob([fs76.readFileSync(file)]), path77.basename(name));
|
|
109840
|
+
for (const f2 of files2) add("files", f2, path77.join(root2, f2));
|
|
109841
|
+
for (const f2 of opts.preview) add("previews", path77.basename(f2), f2);
|
|
109842
|
+
for (const f2 of opts.evidence) add("evidence", path77.basename(f2), f2);
|
|
109817
109843
|
const done2 = await asJson(await ask("", { method: "POST", body: form }));
|
|
109818
109844
|
say(
|
|
109819
109845
|
done2.replaced ? `\u5DF2\u66FF\u6362 ${done2.name}\uFF1A${files2.length} \u4E2A\u6587\u4EF6\u3002
|
|
@@ -109829,11 +109855,11 @@ Deleted ${name} from the catalog.`);
|
|
|
109829
109855
|
return { name, deleted: true };
|
|
109830
109856
|
}
|
|
109831
109857
|
async function templateShowcase(name, dir) {
|
|
109832
|
-
const file =
|
|
109833
|
-
if (!
|
|
109858
|
+
const file = path77.join(dir, "showcase.json");
|
|
109859
|
+
if (!fs76.existsSync(file)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
|
|
109834
109860
|
let meta;
|
|
109835
109861
|
try {
|
|
109836
|
-
meta = JSON.parse(
|
|
109862
|
+
meta = JSON.parse(fs76.readFileSync(file, "utf8"));
|
|
109837
109863
|
} catch {
|
|
109838
109864
|
return invalid("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
|
|
109839
109865
|
}
|
|
@@ -109845,9 +109871,9 @@ async function templateShowcase(name, dir) {
|
|
|
109845
109871
|
const form = new FormData();
|
|
109846
109872
|
form.set("meta", JSON.stringify(meta));
|
|
109847
109873
|
for (const p2 of new Set(named2)) {
|
|
109848
|
-
const at2 =
|
|
109849
|
-
if (!
|
|
109850
|
-
form.append(`media:${p2}`, new Blob([
|
|
109874
|
+
const at2 = path77.join(dir, p2);
|
|
109875
|
+
if (!fs76.existsSync(at2)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at2}\u3002`, `${at2} does not exist.`);
|
|
109876
|
+
form.append(`media:${p2}`, new Blob([fs76.readFileSync(at2)]), p2);
|
|
109851
109877
|
}
|
|
109852
109878
|
const done2 = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
|
|
109853
109879
|
say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done2.files} \u4E2A\u6587\u4EF6\u3002
|
|
@@ -109856,7 +109882,7 @@ Updated ${name}'s showcase: ${done2.files} files.`);
|
|
|
109856
109882
|
}
|
|
109857
109883
|
function walk2(root2, sub = "") {
|
|
109858
109884
|
const out = [];
|
|
109859
|
-
for (const entry of
|
|
109885
|
+
for (const entry of fs76.readdirSync(path77.join(root2, sub), { withFileTypes: true })) {
|
|
109860
109886
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
109861
109887
|
const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
|
|
109862
109888
|
if (entry.isDirectory()) out.push(...walk2(root2, rel2));
|
|
@@ -110013,8 +110039,12 @@ init_paths();
|
|
|
110013
110039
|
init_workflow_diagram();
|
|
110014
110040
|
init_cloud_workflows();
|
|
110015
110041
|
init_workflows();
|
|
110016
|
-
|
|
110017
|
-
|
|
110042
|
+
init_workflow_folder();
|
|
110043
|
+
init_workflow_files();
|
|
110044
|
+
init_config();
|
|
110045
|
+
init_session();
|
|
110046
|
+
import fs77 from "node:fs";
|
|
110047
|
+
import path78 from "node:path";
|
|
110018
110048
|
var found = (id) => {
|
|
110019
110049
|
const flow = workflowById(id);
|
|
110020
110050
|
if (!flow) {
|
|
@@ -110070,14 +110100,46 @@ function cmdWorkflowDiagram(id, card) {
|
|
|
110070
110100
|
const agent = findSpecAgent(name);
|
|
110071
110101
|
return agent ? { ...agent, after: agentAfter(name) } : null;
|
|
110072
110102
|
});
|
|
110073
|
-
const file =
|
|
110074
|
-
|
|
110075
|
-
|
|
110103
|
+
const file = path78.join(ASSETS, String(cardId2), "workflow.json");
|
|
110104
|
+
fs77.mkdirSync(path78.dirname(file), { recursive: true });
|
|
110105
|
+
fs77.writeFileSync(file, `${JSON.stringify(diagram, null, 2)}
|
|
110076
110106
|
`);
|
|
110077
110107
|
const tag = `<Workflow src=".assets/${cardId2}/workflow.json" label="${flow.name.replace(/"/g, "")}" />`;
|
|
110078
110108
|
say(tag);
|
|
110079
110109
|
return { file, tag, diagram };
|
|
110080
110110
|
}
|
|
110111
|
+
var PUBLISH_REFUSED = {
|
|
110112
|
+
not_creator: "only accounts WildCrane has made creators can publish to the marketplace",
|
|
110113
|
+
not_yours: "another creator holds this name, or it is a built-in"
|
|
110114
|
+
};
|
|
110115
|
+
async function cmdWorkflowPublish(folder, opts) {
|
|
110116
|
+
const dir = path78.resolve(folder);
|
|
110117
|
+
if (!fs77.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder} is not a folder`, "bad-args");
|
|
110118
|
+
const slug2 = path78.basename(dir);
|
|
110119
|
+
const files2 = readWorkflowFolder(dir);
|
|
110120
|
+
const checked = checkWorkflowFiles(files2, true);
|
|
110121
|
+
if (!checked.ok) die(`${slug2}: ${checked.file} ${checked.reason}`, "bad-workflow");
|
|
110122
|
+
const token3 = await accessToken();
|
|
110123
|
+
if (!token3.ok) die(SAID[token3.reason].en, "cloud-refused");
|
|
110124
|
+
let res;
|
|
110125
|
+
try {
|
|
110126
|
+
res = await fetch(`${cloudEndpoints().api}/v1/marketplace/workflows`, {
|
|
110127
|
+
method: "POST",
|
|
110128
|
+
headers: { authorization: `Bearer ${token3.token}`, "content-type": "application/json" },
|
|
110129
|
+
body: JSON.stringify({ slug: slug2, files: files2, ...opts.dryRun ? { dry_run: true } : {} })
|
|
110130
|
+
});
|
|
110131
|
+
} catch {
|
|
110132
|
+
die(SAID.unreachable.en, "cloud-refused");
|
|
110133
|
+
}
|
|
110134
|
+
const body = await res.json().catch(() => ({}));
|
|
110135
|
+
if (!res.ok) {
|
|
110136
|
+
if (res.status === 401) die(SAID.expired.en, "cloud-refused");
|
|
110137
|
+
const code = body.error?.code ?? "failed";
|
|
110138
|
+
die(`${slug2}: ${PUBLISH_REFUSED[code] ?? body.error?.message ?? `Cloud answered ${res.status}`}`, code);
|
|
110139
|
+
}
|
|
110140
|
+
say(!body.changed ? `${slug2} is unchanged (v${body.version}).` : opts.dryRun ? `${slug2} would publish v${body.version}.` : `Published ${slug2} v${body.version}.`);
|
|
110141
|
+
return { slug: slug2, id: body.id, version: body.version, changed: body.changed, ...opts.dryRun ? { dryRun: true } : {} };
|
|
110142
|
+
}
|
|
110081
110143
|
|
|
110082
110144
|
// ../cli/src/commands/run.ts
|
|
110083
110145
|
init_progress();
|
|
@@ -110239,8 +110301,8 @@ init_tasks();
|
|
|
110239
110301
|
init_read();
|
|
110240
110302
|
init_rules();
|
|
110241
110303
|
init_board();
|
|
110242
|
-
import
|
|
110243
|
-
import
|
|
110304
|
+
import fs86 from "node:fs";
|
|
110305
|
+
import path86 from "node:path";
|
|
110244
110306
|
var FOLLOW_MS = 400;
|
|
110245
110307
|
async function cmdStartRun(action, args, opts, program2 = "akb") {
|
|
110246
110308
|
const { req, follow: follow2, print } = readRequest(action, args, opts);
|
|
@@ -110464,7 +110526,7 @@ async function cmdSubStart(words, opts) {
|
|
|
110464
110526
|
let prompt = words.join(" ");
|
|
110465
110527
|
if (opts.file) {
|
|
110466
110528
|
try {
|
|
110467
|
-
prompt =
|
|
110529
|
+
prompt = fs86.readFileSync(path86.resolve(opts.file), "utf8");
|
|
110468
110530
|
} catch {
|
|
110469
110531
|
die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
|
|
110470
110532
|
}
|
|
@@ -110755,7 +110817,7 @@ function cmdCompleteDelivery(id, options) {
|
|
|
110755
110817
|
// ../cli/src/commands/triage.ts
|
|
110756
110818
|
init_scheduled();
|
|
110757
110819
|
init_workflows();
|
|
110758
|
-
import
|
|
110820
|
+
import fs88 from "node:fs";
|
|
110759
110821
|
|
|
110760
110822
|
// ../cli/src/lib/signals/index.ts
|
|
110761
110823
|
init_cards();
|
|
@@ -110765,16 +110827,16 @@ init_yaml();
|
|
|
110765
110827
|
// ../cli/src/lib/signals/config.ts
|
|
110766
110828
|
init_settings();
|
|
110767
110829
|
init_paths();
|
|
110768
|
-
import
|
|
110769
|
-
import
|
|
110830
|
+
import fs87 from "node:fs";
|
|
110831
|
+
import path87 from "node:path";
|
|
110770
110832
|
var TOKEN_KEY = "TRIAGE_ENDPOINT_TOKEN";
|
|
110771
110833
|
var ENDPOINT_SETTING = "Triage endpoint";
|
|
110772
110834
|
var LINE2 = /^- \*\*Triage endpoint\*\*\s*[—-]\s*(.+)$/m;
|
|
110773
|
-
var boardRel3 = (file) => rel(file).split(
|
|
110835
|
+
var boardRel3 = (file) => rel(file).split(path87.sep).join("/");
|
|
110774
110836
|
function signalEndpoint() {
|
|
110775
110837
|
let text5;
|
|
110776
110838
|
try {
|
|
110777
|
-
text5 =
|
|
110839
|
+
text5 = fs87.readFileSync(CONFIG, "utf8");
|
|
110778
110840
|
} catch {
|
|
110779
110841
|
return "";
|
|
110780
110842
|
}
|
|
@@ -110950,7 +111012,7 @@ async function cmdTriageAdd(opts) {
|
|
|
110950
111012
|
let body = opts.text;
|
|
110951
111013
|
if (opts.file !== void 0) {
|
|
110952
111014
|
try {
|
|
110953
|
-
body =
|
|
111015
|
+
body = fs88.readFileSync(opts.file, "utf8");
|
|
110954
111016
|
} catch {
|
|
110955
111017
|
die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
|
|
110956
111018
|
}
|
|
@@ -111148,7 +111210,7 @@ function cmdTelemetry(args, program2) {
|
|
|
111148
111210
|
}
|
|
111149
111211
|
|
|
111150
111212
|
// ../cli/src/lib/cli/agent.ts
|
|
111151
|
-
|
|
111213
|
+
init_shared2();
|
|
111152
111214
|
async function onBoard2(cmd, cli, work) {
|
|
111153
111215
|
const ctx = ctxOf(cmd, cli.program);
|
|
111154
111216
|
await runAction(ctx, {}, async () => {
|
|
@@ -111344,6 +111406,9 @@ List trigger conditions: ${cli.program} previews --triggers --json`).action(asyn
|
|
|
111344
111406
|
flowWord("diagram").argument("<id>", "the workflow, from `workflow list`").argument("<card>", "the card whose asset folder gets workflow.json").summary("write the workflow's diagram to .assets/<card>/workflow.json and print the <Workflow> tag that shows it").action(async function(id, card) {
|
|
111345
111407
|
await onBoard2(this, cli, () => cmdWorkflowDiagram(id, card));
|
|
111346
111408
|
});
|
|
111409
|
+
flowWord("publish").argument("<folder>", "the workflow folder; its name is the slug").option("--dry-run", "check the folder and print what would happen, publishing nothing").summary("publish a workflow folder to the marketplace as the signed-in account. Prints the version new tasks take, or that nothing changed.").action(async function(folder) {
|
|
111410
|
+
await boardless(this, cli, () => cmdWorkflowPublish(folder, this.opts()));
|
|
111411
|
+
});
|
|
111347
111412
|
withShared(program2.command("components")).summary("list an agent or workflow\u2019s preview components and their usage").option("--agent <name>", "one agent\u2019s components").option("--workflow <id>", "all components used by a workflow").option("--docs", "include component usage documentation").action(async function() {
|
|
111348
111413
|
const ctx = ctxOf(this, cli.program);
|
|
111349
111414
|
useBoard(resolveBoard("components", { board: ctx.board, dir: ctx.dir, cwd: cli.cwd, installHint: cli.installHint }), ctx.dir !== null);
|
|
@@ -111520,8 +111585,8 @@ function declareAgent(program2, cli) {
|
|
|
111520
111585
|
}
|
|
111521
111586
|
|
|
111522
111587
|
// ../cli/src/lib/cli/setup.ts
|
|
111523
|
-
import
|
|
111524
|
-
import
|
|
111588
|
+
import fs90 from "node:fs";
|
|
111589
|
+
import path89 from "node:path";
|
|
111525
111590
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
111526
111591
|
|
|
111527
111592
|
// ../cli/src/commands/update.ts
|
|
@@ -111535,8 +111600,8 @@ init_paths();
|
|
|
111535
111600
|
init_memory();
|
|
111536
111601
|
init_yaml2();
|
|
111537
111602
|
init_version();
|
|
111538
|
-
import
|
|
111539
|
-
import
|
|
111603
|
+
import fs89 from "node:fs";
|
|
111604
|
+
import path88 from "node:path";
|
|
111540
111605
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
111541
111606
|
var NAME = "wildcrane";
|
|
111542
111607
|
var REPO = "https://github.com/wildcrane-ai/wildcrane";
|
|
@@ -111558,10 +111623,10 @@ var Report = class {
|
|
|
111558
111623
|
for (const line of this.notes) say(` ! ${line}`);
|
|
111559
111624
|
}
|
|
111560
111625
|
};
|
|
111561
|
-
var read4 = (file) =>
|
|
111626
|
+
var read4 = (file) => fs89.existsSync(file) ? fs89.readFileSync(file, "utf8") : null;
|
|
111562
111627
|
function statOf(p2) {
|
|
111563
111628
|
try {
|
|
111564
|
-
return
|
|
111629
|
+
return fs89.lstatSync(p2);
|
|
111565
111630
|
} catch {
|
|
111566
111631
|
return null;
|
|
111567
111632
|
}
|
|
@@ -111586,10 +111651,10 @@ async function cmdUpdate2(ctx) {
|
|
|
111586
111651
|
return { updated: ctx.dir, from, to: SKILL_VERSION };
|
|
111587
111652
|
}
|
|
111588
111653
|
async function repairBoard(root2, report3, named2) {
|
|
111589
|
-
const legacy2 =
|
|
111590
|
-
const kept2 =
|
|
111591
|
-
const board2 = named2 ?? (
|
|
111592
|
-
if (!
|
|
111654
|
+
const legacy2 = path88.join(root2, "docs", "kanban");
|
|
111655
|
+
const kept2 = path88.join(root2, ".akb", "kanban");
|
|
111656
|
+
const board2 = named2 ?? (fs89.existsSync(legacy2) ? legacy2 : kept2);
|
|
111657
|
+
if (!fs89.existsSync(board2)) {
|
|
111593
111658
|
report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
|
|
111594
111659
|
return false;
|
|
111595
111660
|
}
|
|
@@ -111620,20 +111685,20 @@ function moveRuntimes(root2, board2, report3) {
|
|
|
111620
111685
|
}
|
|
111621
111686
|
}
|
|
111622
111687
|
function moveLegacyMemory(board2, report3) {
|
|
111623
|
-
const memory =
|
|
111688
|
+
const memory = path88.join(board2, "memory");
|
|
111624
111689
|
const moved = [];
|
|
111625
111690
|
for (const name of MEMORY_FILES) {
|
|
111626
|
-
const from =
|
|
111691
|
+
const from = path88.join(board2, name);
|
|
111627
111692
|
const st2 = statOf(from);
|
|
111628
111693
|
if (!st2 || !st2.isFile()) continue;
|
|
111629
|
-
|
|
111630
|
-
const to =
|
|
111694
|
+
fs89.mkdirSync(memory, { recursive: true });
|
|
111695
|
+
const to = path88.join(memory, name);
|
|
111631
111696
|
const there = read4(to);
|
|
111632
111697
|
if (there === null) {
|
|
111633
|
-
|
|
111698
|
+
fs89.renameSync(from, to);
|
|
111634
111699
|
moved.push(name);
|
|
111635
111700
|
} else if (there === read4(from)) {
|
|
111636
|
-
|
|
111701
|
+
fs89.rmSync(from);
|
|
111637
111702
|
moved.push(name);
|
|
111638
111703
|
} else {
|
|
111639
111704
|
report3.notes.push(`both docs/kanban/${name} and docs/kanban/memory/${name} exist and differ \u2014 merge them by hand`);
|
|
@@ -111642,23 +111707,23 @@ function moveLegacyMemory(board2, report3) {
|
|
|
111642
111707
|
if (moved.length) report3.did.push(`moved the memory set into docs/kanban/memory/: ${moved.join(", ")}`);
|
|
111643
111708
|
}
|
|
111644
111709
|
function dropRecordFile(board2) {
|
|
111645
|
-
const file =
|
|
111646
|
-
if (!
|
|
111647
|
-
|
|
111710
|
+
const file = path88.join(board2, "record.csv");
|
|
111711
|
+
if (!fs89.existsSync(file)) return null;
|
|
111712
|
+
fs89.rmSync(file);
|
|
111648
111713
|
return "removed docs/kanban/record.csv (the planning scores it fed are gone)";
|
|
111649
111714
|
}
|
|
111650
111715
|
function dropModuleGoals(board2, report3) {
|
|
111651
|
-
const memory =
|
|
111652
|
-
if (!
|
|
111653
|
-
const root2 = read4(
|
|
111716
|
+
const memory = path88.join(board2, "memory");
|
|
111717
|
+
if (!fs89.existsSync(memory)) return;
|
|
111718
|
+
const root2 = read4(path88.join(memory, "goal.md"));
|
|
111654
111719
|
let dropped = 0;
|
|
111655
|
-
for (const entry of
|
|
111720
|
+
for (const entry of fs89.readdirSync(memory, { withFileTypes: true })) {
|
|
111656
111721
|
if (!entry.isDirectory()) continue;
|
|
111657
|
-
const file =
|
|
111722
|
+
const file = path88.join(memory, entry.name, "goal.md");
|
|
111658
111723
|
const text5 = read4(file);
|
|
111659
111724
|
if (text5 === null) continue;
|
|
111660
111725
|
if (text5 === root2 || text5.includes(UNFILLED) || !goalWords(text5)) {
|
|
111661
|
-
|
|
111726
|
+
fs89.rmSync(file);
|
|
111662
111727
|
dropped++;
|
|
111663
111728
|
} else {
|
|
111664
111729
|
report3.notes.push(
|
|
@@ -111680,10 +111745,10 @@ var PLAN_LEADS = {
|
|
|
111680
111745
|
var GONE_LEADS = ["software-planner", "planner"];
|
|
111681
111746
|
function planLeads(board2) {
|
|
111682
111747
|
const leads = { ...PLAN_LEADS };
|
|
111683
|
-
const root2 =
|
|
111684
|
-
for (const entry of
|
|
111748
|
+
const root2 = path88.join(board2, "workflows");
|
|
111749
|
+
for (const entry of fs89.existsSync(root2) ? fs89.readdirSync(root2, { withFileTypes: true }) : []) {
|
|
111685
111750
|
if (!entry.isDirectory()) continue;
|
|
111686
|
-
const meta = splitFrontmatter(read4(
|
|
111751
|
+
const meta = splitFrontmatter(read4(path88.join(root2, entry.name, "WORKFLOW.md")) ?? "").meta;
|
|
111687
111752
|
const stages = meta === null ? void 0 : parseYamlBlock(meta).stages;
|
|
111688
111753
|
const plan = stages && typeof stages === "object" && !Array.isArray(stages) ? stages.plan : void 0;
|
|
111689
111754
|
const lead = plan && typeof plan === "object" && !Array.isArray(plan) && typeof plan.lead === "string" ? plan.lead.trim() : "";
|
|
@@ -111692,30 +111757,30 @@ function planLeads(board2) {
|
|
|
111692
111757
|
return leads;
|
|
111693
111758
|
}
|
|
111694
111759
|
function movePlanRules(board2, report3) {
|
|
111695
|
-
const rules =
|
|
111760
|
+
const rules = path88.join(board2, "rules");
|
|
111696
111761
|
const moved = [];
|
|
111697
111762
|
for (const [id, leads] of Object.entries(planLeads(board2))) {
|
|
111698
111763
|
for (const lead of leads) {
|
|
111699
|
-
const from =
|
|
111764
|
+
const from = path88.join(rules, `${lead}.md`);
|
|
111700
111765
|
const rule = read4(from)?.trim();
|
|
111701
111766
|
if (!rule) continue;
|
|
111702
|
-
const to =
|
|
111767
|
+
const to = path88.join(rules, "workflows", `${id}.md`);
|
|
111703
111768
|
const there = read4(to)?.trim() ?? "";
|
|
111704
111769
|
if (!there.includes(rule)) {
|
|
111705
|
-
|
|
111706
|
-
|
|
111770
|
+
fs89.mkdirSync(path88.dirname(to), { recursive: true });
|
|
111771
|
+
fs89.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
|
|
111707
111772
|
`);
|
|
111708
111773
|
moved.push(`${lead} \u2192 ${id}`);
|
|
111709
111774
|
}
|
|
111710
111775
|
}
|
|
111711
111776
|
}
|
|
111712
|
-
for (const lead of GONE_LEADS)
|
|
111777
|
+
for (const lead of GONE_LEADS) fs89.rmSync(path88.join(rules, `${lead}.md`), { force: true });
|
|
111713
111778
|
if (moved.length) report3.did.push(`made each plan agent's rule its workflow's card rule (docs/kanban/rules/workflows/): ${moved.join(", ")}`);
|
|
111714
111779
|
}
|
|
111715
111780
|
function noteOldWorkflows(board2, report3) {
|
|
111716
111781
|
const old = (dir, file, keys) => {
|
|
111717
|
-
const root2 =
|
|
111718
|
-
return (
|
|
111782
|
+
const root2 = path88.join(board2, dir);
|
|
111783
|
+
return (fs89.existsSync(root2) ? fs89.readdirSync(root2, { withFileTypes: true }) : []).filter((e2) => e2.isDirectory() && keys.test(splitFrontmatter(read4(path88.join(root2, e2.name, file)) ?? "").meta ?? "")).map((e2) => `docs/kanban/${dir}/${e2.name}/${file}`);
|
|
111719
111784
|
};
|
|
111720
111785
|
const files2 = [...old("workflows", "WORKFLOW.md", /^(stages|delivers):/m), ...old("agents", "AGENT.md", /^\s+(hook|lead):/m)];
|
|
111721
111786
|
if (files2.length) {
|
|
@@ -111725,7 +111790,7 @@ function noteOldWorkflows(board2, report3) {
|
|
|
111725
111790
|
}
|
|
111726
111791
|
}
|
|
111727
111792
|
function checkConfig(board2, report3) {
|
|
111728
|
-
const current = read4(
|
|
111793
|
+
const current = read4(path88.join(board2, "config.md"));
|
|
111729
111794
|
if (!current) return;
|
|
111730
111795
|
const added = missingConfigKeys(current);
|
|
111731
111796
|
if (added.length) {
|
|
@@ -111735,7 +111800,7 @@ function checkConfig(board2, report3) {
|
|
|
111735
111800
|
}
|
|
111736
111801
|
}
|
|
111737
111802
|
function checkModules(board2, report3) {
|
|
111738
|
-
const map2 = read4(
|
|
111803
|
+
const map2 = read4(path88.join(board2, "modules.md"));
|
|
111739
111804
|
if (map2 && map2.includes(UNFILLED)) {
|
|
111740
111805
|
report3.notes.push(
|
|
111741
111806
|
"docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
|
|
@@ -111781,7 +111846,7 @@ function isOlder(a2, b2) {
|
|
|
111781
111846
|
// ../cli/src/lib/cli/setup.ts
|
|
111782
111847
|
init_io();
|
|
111783
111848
|
init_version();
|
|
111784
|
-
|
|
111849
|
+
init_shared2();
|
|
111785
111850
|
var spelled = (program2) => program2 === "akb" ? "" : `
|
|
111786
111851
|
This copy isn't on your PATH as \`akb\` \u2014 every \`akb\` below is \`${program2}\` here.
|
|
111787
111852
|
`;
|
|
@@ -111789,14 +111854,14 @@ function declareSetup(program2, cli) {
|
|
|
111789
111854
|
program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
|
|
111790
111855
|
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");
|
|
111791
111856
|
const where = (cmd) => {
|
|
111792
|
-
const dir =
|
|
111793
|
-
if (!
|
|
111857
|
+
const dir = path89.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
|
|
111858
|
+
if (!fs90.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
|
|
111794
111859
|
return dir;
|
|
111795
111860
|
};
|
|
111796
111861
|
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() {
|
|
111797
111862
|
const dir = where(this);
|
|
111798
111863
|
const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
|
|
111799
|
-
const board2 = named2 ?
|
|
111864
|
+
const board2 = named2 ? path89.resolve(cli.cwd, named2) : null;
|
|
111800
111865
|
await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
|
|
111801
111866
|
});
|
|
111802
111867
|
program2.command("__rules", { hidden: true }).action(function() {
|
|
@@ -111806,7 +111871,7 @@ function declareSetup(program2, cli) {
|
|
|
111806
111871
|
|
|
111807
111872
|
// ../cli/src/lib/cli/akb.ts
|
|
111808
111873
|
init_io();
|
|
111809
|
-
|
|
111874
|
+
init_shared2();
|
|
111810
111875
|
function buildAkbProgram(cli) {
|
|
111811
111876
|
const program2 = withShared(newCommand(cli.program));
|
|
111812
111877
|
program2.description("set up a board, and put an agent to work on it.").helpCommand("help [command]", "this list, or one command in full");
|
|
@@ -111823,7 +111888,7 @@ function buildAkbProgram(cli) {
|
|
|
111823
111888
|
}
|
|
111824
111889
|
|
|
111825
111890
|
// ../cli/src/lib/agent-cli.ts
|
|
111826
|
-
|
|
111891
|
+
init_shared2();
|
|
111827
111892
|
init_usage();
|
|
111828
111893
|
var WATCH = "__watch";
|
|
111829
111894
|
async function runAgent2(argv, options = {}) {
|
|
@@ -111841,7 +111906,7 @@ function invokedDirectly() {
|
|
|
111841
111906
|
const entry = process.argv[1];
|
|
111842
111907
|
if (!entry) return false;
|
|
111843
111908
|
try {
|
|
111844
|
-
return
|
|
111909
|
+
return fs91.realpathSync(entry) === fs91.realpathSync(SELF2);
|
|
111845
111910
|
} catch {
|
|
111846
111911
|
return false;
|
|
111847
111912
|
}
|