wildcrane 0.11.56 → 0.11.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kanban.mjs +822 -883
- package/package.json +2 -2
package/dist/kanban.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// ai4kanban 0.11.
|
|
2
|
+
// ai4kanban 0.11.58 — built from the CLI's TypeScript sources by cli/scripts/build.mjs.
|
|
3
3
|
// Do not edit: every change belongs in cli/src/, and a build overwrites this file.
|
|
4
4
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
5
5
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
@@ -506,27 +506,30 @@ __export(preview_stages_exports, {
|
|
|
506
506
|
submitPreviewStage: () => submitPreviewStage
|
|
507
507
|
});
|
|
508
508
|
function selectPreviewStages(progress, ids) {
|
|
509
|
-
if (progress.stages.length) throw Error("The stage selection is frozen. Revise the task to change its scope.");
|
|
510
509
|
const wanted = new Set(ids);
|
|
511
510
|
if (!ids.length || wanted.size !== ids.length || ids.some((id) => !progress.definitions.some((stage) => stage.id === id))) throw Error("Choose a nonempty list of unique known stage IDs.");
|
|
512
|
-
const chosen = progress.definitions.
|
|
513
|
-
if (
|
|
514
|
-
|
|
515
|
-
|
|
511
|
+
const chosen = ids.map((id) => progress.definitions.find((stage) => stage.id === id));
|
|
512
|
+
if (progress.stages.length) {
|
|
513
|
+
if (JSON.stringify(progress.stages.map((stage) => stage.id)) === JSON.stringify(ids)) return;
|
|
514
|
+
progress.archivedSelections = [...progress.archivedSelections ?? [], structuredClone(progress.stages)];
|
|
515
|
+
progress.generation++;
|
|
516
|
+
}
|
|
517
|
+
progress.stages = chosen.map((stage, i) => structuredClone(progress.stages.find((held4) => held4.id === stage.id) ?? { ...stage, status: i === 0 ? "running" : "pending", version: null }));
|
|
518
|
+
progress.currentStageId = progress.stages.find((stage) => !["confirmed", "ready"].includes(stage.status))?.id ?? chosen.at(-1).id;
|
|
516
519
|
}
|
|
517
520
|
function previewBaseline(progress, stageId, execution) {
|
|
518
521
|
const stage = progress.stages.find((stage2) => stage2.id === stageId);
|
|
519
|
-
if (progress.currentStageId !== stageId || !stage
|
|
522
|
+
if (progress.currentStageId !== stageId || !stage) throw Error("Unknown current stage.");
|
|
520
523
|
progress.execution = execution;
|
|
521
524
|
delete progress.failure;
|
|
522
|
-
stage.status = "running";
|
|
525
|
+
if (!["awaiting_confirmation", "ready", "confirmed"].includes(stage.status)) stage.status = "running";
|
|
523
526
|
return { definitionRevision: progress.definitionRevision, generation: progress.generation, stageId, execution };
|
|
524
527
|
}
|
|
525
528
|
function submitPreviewStage(progress, baseline, body, assets) {
|
|
526
529
|
const stage = progress.stages.find((stage2) => stage2.id === baseline.stageId);
|
|
527
530
|
if (baseline.definitionRevision !== progress.definitionRevision || baseline.generation !== progress.generation || baseline.execution !== progress.execution || progress.currentStageId !== baseline.stageId || !stage) throw Error("This execution is outdated. Reload the task.");
|
|
528
531
|
if (["awaiting_confirmation", "ready"].includes(stage.status) && stage.artifact) return stage.artifact;
|
|
529
|
-
if (stage.status !== "running"
|
|
532
|
+
if (stage.status !== "running") throw Error("This stage is not the current execution.");
|
|
530
533
|
const artifact = { stageId: stage.id, version: (stage.version ?? 0) + 1, body, assets: structuredClone(assets) };
|
|
531
534
|
stage.history = [...stage.history ?? [], artifact];
|
|
532
535
|
stage.version = artifact.version;
|
|
@@ -577,10 +580,13 @@ function beginPreviewRevision(progress, execution) {
|
|
|
577
580
|
progress.execution = execution;
|
|
578
581
|
}
|
|
579
582
|
function choosePreviewRevision(progress, from, execution) {
|
|
580
|
-
if (
|
|
581
|
-
const
|
|
582
|
-
|
|
583
|
-
|
|
583
|
+
if (progress.execution !== execution) throw Error("This execution is outdated. Reload the task.");
|
|
584
|
+
const saved = progress.revisionBase ?? progress.stages;
|
|
585
|
+
const at2 = saved.findIndex((stage) => stage.id === from);
|
|
586
|
+
if (at2 < 0) throw Error("Unknown stage.");
|
|
587
|
+
progress.archivedSelections = [...progress.archivedSelections ?? [], structuredClone(saved)];
|
|
588
|
+
progress.stages = structuredClone(saved);
|
|
589
|
+
progress.generation++;
|
|
584
590
|
for (const stage of progress.stages.slice(at2)) {
|
|
585
591
|
stage.status = "stale";
|
|
586
592
|
delete stage.confirmation;
|
|
@@ -3352,10 +3358,10 @@ function findRollout(threadId) {
|
|
|
3352
3358
|
}
|
|
3353
3359
|
for (const name of names3) {
|
|
3354
3360
|
if (!name.startsWith("rollout-") || !name.endsWith(tail)) continue;
|
|
3355
|
-
const
|
|
3361
|
+
const path91 = join2(dir, name);
|
|
3356
3362
|
try {
|
|
3357
|
-
const at2 = statSync2(
|
|
3358
|
-
if (!newest2 || at2 > newest2.at) newest2 = { path:
|
|
3363
|
+
const at2 = statSync2(path91).mtimeMs;
|
|
3364
|
+
if (!newest2 || at2 > newest2.at) newest2 = { path: path91, at: at2 };
|
|
3359
3365
|
} catch {
|
|
3360
3366
|
}
|
|
3361
3367
|
}
|
|
@@ -3363,11 +3369,11 @@ function findRollout(threadId) {
|
|
|
3363
3369
|
return newest2?.path;
|
|
3364
3370
|
}
|
|
3365
3371
|
function readCodexRunFacts(threadId) {
|
|
3366
|
-
const
|
|
3367
|
-
if (!
|
|
3372
|
+
const path91 = findRollout(threadId);
|
|
3373
|
+
if (!path91) return void 0;
|
|
3368
3374
|
let raw;
|
|
3369
3375
|
try {
|
|
3370
|
-
raw = readFileSync2(
|
|
3376
|
+
raw = readFileSync2(path91, "utf8");
|
|
3371
3377
|
} catch {
|
|
3372
3378
|
return void 0;
|
|
3373
3379
|
}
|
|
@@ -3493,8 +3499,8 @@ function renderCompleted(item) {
|
|
|
3493
3499
|
const changes = Array.isArray(item.changes) ? item.changes : [];
|
|
3494
3500
|
return changes.map((raw) => {
|
|
3495
3501
|
const change2 = obj2(raw);
|
|
3496
|
-
const
|
|
3497
|
-
return
|
|
3502
|
+
const path91 = str2(change2.path);
|
|
3503
|
+
return path91 ? `\u23FA ${str2(change2.kind) || "change"}(${path91})
|
|
3498
3504
|
` : "";
|
|
3499
3505
|
}).join("");
|
|
3500
3506
|
}
|
|
@@ -3829,10 +3835,10 @@ function readKimiRunFacts(sessionId) {
|
|
|
3829
3835
|
const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
|
|
3830
3836
|
let model;
|
|
3831
3837
|
let holding = 0;
|
|
3832
|
-
for (const { path:
|
|
3838
|
+
for (const { path: path91, main } of wireFiles(entry.sessionDir)) {
|
|
3833
3839
|
let raw;
|
|
3834
3840
|
try {
|
|
3835
|
-
raw = readFileSync3(
|
|
3841
|
+
raw = readFileSync3(path91, "utf8");
|
|
3836
3842
|
} catch {
|
|
3837
3843
|
continue;
|
|
3838
3844
|
}
|
|
@@ -4206,8 +4212,8 @@ var init_package = __esm({
|
|
|
4206
4212
|
"package.json"() {
|
|
4207
4213
|
package_default = {
|
|
4208
4214
|
name: "wildcrane",
|
|
4209
|
-
version: "0.11.
|
|
4210
|
-
akbContract:
|
|
4215
|
+
version: "0.11.58",
|
|
4216
|
+
akbContract: 16,
|
|
4211
4217
|
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.",
|
|
4212
4218
|
keywords: [
|
|
4213
4219
|
"kanban",
|
|
@@ -4283,8 +4289,8 @@ var init_version = __esm({
|
|
|
4283
4289
|
import fs16 from "node:fs";
|
|
4284
4290
|
function whereHint(update2, title) {
|
|
4285
4291
|
const locations = Array.isArray(update2.locations) ? update2.locations : [];
|
|
4286
|
-
const
|
|
4287
|
-
return
|
|
4292
|
+
const path91 = str2(obj2(locations[0]).path);
|
|
4293
|
+
return path91 && !title.includes(path91) ? hint(path91) : "";
|
|
4288
4294
|
}
|
|
4289
4295
|
function saidBy(update2) {
|
|
4290
4296
|
const content = Array.isArray(update2.content) ? update2.content : [];
|
|
@@ -5437,7 +5443,7 @@ async function run(io, options, tasks) {
|
|
|
5437
5443
|
startupTimer = setTimeout(() => {
|
|
5438
5444
|
if (!started) io.event?.({ kind: "log", data: { text: "[conversation] start_unconfirmed" } });
|
|
5439
5445
|
}, CONVERSATION_MS.start);
|
|
5440
|
-
await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text5 }, ...images.map((
|
|
5446
|
+
await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text5 }, ...images.map((path91) => ({ type: "localImage", path: path91 }))] }), CONVERSATION_MS.start, "Codex turn/start timed out; submission outcome is unknown.").catch((error) => {
|
|
5441
5447
|
if (!started) throw error;
|
|
5442
5448
|
});
|
|
5443
5449
|
};
|
|
@@ -8311,7 +8317,7 @@ var init_flows = __esm({
|
|
|
8311
8317
|
group: "card",
|
|
8312
8318
|
action: "refine",
|
|
8313
8319
|
argument: "<id>",
|
|
8314
|
-
gloss: "plan the card
|
|
8320
|
+
gloss: "plan the card",
|
|
8315
8321
|
options: CARRY_OPTIONS
|
|
8316
8322
|
},
|
|
8317
8323
|
{
|
|
@@ -8413,8 +8419,8 @@ var init_file_limits = __esm({
|
|
|
8413
8419
|
});
|
|
8414
8420
|
|
|
8415
8421
|
// src/lib/shared/board-files.ts
|
|
8416
|
-
function studioRenamed(
|
|
8417
|
-
const to =
|
|
8422
|
+
function studioRenamed(path91, content) {
|
|
8423
|
+
const to = path91.replace(/^(rules\/)?workflows\//, "$1studios/").replace(/^(studios\/[^/]+)\/WORKFLOW\.md$/, "$1/STUDIO.md");
|
|
8418
8424
|
if (!to.endsWith(".md")) return { path: to, content };
|
|
8419
8425
|
if (to.startsWith("studios/")) return { path: to, content: content.replace(/^(icon:\s*["']?)workflow(-kit)?(["']?\s*)$/gm, "$1studio$2$3") };
|
|
8420
8426
|
const front = /^(?:todo|triage)\//.test(to) ? /^---\r?\n[\s\S]*?\r?\n---/.exec(content)?.[0] : void 0;
|
|
@@ -8674,7 +8680,7 @@ function parseSpecAgent(text5, from, file2, builtIn = false, list2 = () => []) {
|
|
|
8674
8680
|
const after2 = names(akb.after);
|
|
8675
8681
|
const declaredSession = str3(akb.session);
|
|
8676
8682
|
if (declaredSession && declaredSession !== "new") {
|
|
8677
|
-
return bad(`\`${name}\` declares \`akb.session: ${declaredSession}\` \u2014
|
|
8683
|
+
return bad(`\`${name}\` declares \`akb.session: ${declaredSession}\` \u2014 use \`new\` to recommend a separate session, or omit the preference`);
|
|
8678
8684
|
}
|
|
8679
8685
|
let stages;
|
|
8680
8686
|
if (akb.stages !== void 0) {
|
|
@@ -8915,7 +8921,7 @@ function diagramFrom(files) {
|
|
|
8915
8921
|
if ("problem" in read3) return null;
|
|
8916
8922
|
return studioDiagram(read3.def, (name) => {
|
|
8917
8923
|
const text5 = files[`agents/${name}/AGENT.md`];
|
|
8918
|
-
const parsed = text5 === void 0 ? null : parseSpecAgent(text5, name, (
|
|
8924
|
+
const parsed = text5 === void 0 ? null : parseSpecAgent(text5, name, (path91) => files[`agents/${name}/${path91}`] ?? null, false);
|
|
8919
8925
|
return parsed && "agent" in parsed ? parsed.agent : null;
|
|
8920
8926
|
});
|
|
8921
8927
|
}
|
|
@@ -10946,7 +10952,7 @@ function specAgentSelector(id, studio, meta) {
|
|
|
10946
10952
|
`\`akb raw previews --triggers --studio ${flow.id}\` whose conditions the card meets, always including those marked \`Always\`. Save them with`,
|
|
10947
10953
|
`\`akb raw update ${id} --previews <agents>\` (\`""\` when that leaves none); its stages follow from them.`,
|
|
10948
10954
|
"Then run only the chosen agents whose `After` is empty \u2014 the first stage; the rest run after its approval.",
|
|
10949
|
-
`Command: \`akb raw previews <agent> ${id} <short note>\` \u2014
|
|
10955
|
+
`Command: \`akb raw previews <agent> ${id} <short note>\` \u2014 choose \`--print\` for this session or omit it for a separate session.`,
|
|
10950
10956
|
"</preview-agents>"
|
|
10951
10957
|
].join("\n");
|
|
10952
10958
|
}
|
|
@@ -10958,8 +10964,8 @@ function specAgentSelector(id, studio, meta) {
|
|
|
10958
10964
|
// own job.
|
|
10959
10965
|
"<preview-agents>",
|
|
10960
10966
|
"The preview agents of this card's current stage, each writing one part of the card.",
|
|
10961
|
-
...agents.map((a2) => `- \`${a2.name}\` \u2014 ${a2.description}${a2.session
|
|
10962
|
-
`Command: \`akb raw previews <agent> ${id} <short note>\` \u2014
|
|
10967
|
+
...agents.map((a2) => `- \`${a2.name}\` \u2014 ${a2.description}${a2.session === "new" ? " \xB7 separate session recommended" : ""}`),
|
|
10968
|
+
`Command: \`akb raw previews <agent> ${id} <short note>\` \u2014 choose \`--print\` for this session or omit it for a separate session.`,
|
|
10963
10969
|
"</preview-agents>"
|
|
10964
10970
|
].join("\n");
|
|
10965
10971
|
}
|
|
@@ -11065,7 +11071,6 @@ var init_candidate = __esm({
|
|
|
11065
11071
|
|
|
11066
11072
|
// src/lib/agent/outputs.ts
|
|
11067
11073
|
import fs32 from "node:fs";
|
|
11068
|
-
import os4 from "node:os";
|
|
11069
11074
|
import path36 from "node:path";
|
|
11070
11075
|
function cardBody(cardId2) {
|
|
11071
11076
|
const found2 = locate(cardId2) ?? locateArchived(cardId2);
|
|
@@ -11089,23 +11094,11 @@ function recordedOutputs(delivery) {
|
|
|
11089
11094
|
}
|
|
11090
11095
|
return out;
|
|
11091
11096
|
}
|
|
11092
|
-
|
|
11093
|
-
const outputs = recordedOutputs(delivery);
|
|
11094
|
-
if (!outputs.length) {
|
|
11095
|
-
return { reason: "output", why: "the card records no output file", paths: [] };
|
|
11096
|
-
}
|
|
11097
|
-
const missing = outputs.filter((f2) => !fs32.existsSync(resolveOutput(f2)));
|
|
11098
|
-
if (missing.length) {
|
|
11099
|
-
return { reason: "output", why: `recorded output files are missing: ${missing.join(", ")}`, paths: missing };
|
|
11100
|
-
}
|
|
11101
|
-
return void 0;
|
|
11102
|
-
}
|
|
11103
|
-
var TODO2, todos, plannedTodos, looksLikePath, resolveOutput;
|
|
11097
|
+
var TODO2, todos, plannedTodos, looksLikePath;
|
|
11104
11098
|
var init_outputs = __esm({
|
|
11105
11099
|
"src/lib/agent/outputs.ts"() {
|
|
11106
11100
|
"use strict";
|
|
11107
11101
|
init_cards();
|
|
11108
|
-
init_paths();
|
|
11109
11102
|
TODO2 = /^\s*[-*]\s+\[([ xX])\]\s+(.*)$/;
|
|
11110
11103
|
todos = (cardId2) => cardBody(cardId2).split("\n").flatMap((line) => {
|
|
11111
11104
|
const m = TODO2.exec(line);
|
|
@@ -11113,12 +11106,6 @@ var init_outputs = __esm({
|
|
|
11113
11106
|
});
|
|
11114
11107
|
plannedTodos = (cardId2) => todos(cardId2).map((t) => t.text);
|
|
11115
11108
|
looksLikePath = (token2) => !/\s/.test(token2) && !token2.includes("://") && !token2.startsWith("-") && token2.includes("/");
|
|
11116
|
-
resolveOutput = (file2) => {
|
|
11117
|
-
if (file2.startsWith("~/")) return path36.join(os4.homedir(), file2.slice(2));
|
|
11118
|
-
if (path36.isAbsolute(file2)) return file2;
|
|
11119
|
-
if (file2.startsWith(".assets/")) return path36.join(ASSETS, file2.slice(".assets/".length));
|
|
11120
|
-
return path36.join(REPO_ROOT, file2);
|
|
11121
|
-
};
|
|
11122
11109
|
}
|
|
11123
11110
|
});
|
|
11124
11111
|
|
|
@@ -11264,7 +11251,7 @@ function nextDeliveryRun(deliveryId) {
|
|
|
11264
11251
|
for (const delivery of store.deliveries) {
|
|
11265
11252
|
if (deliveryId && delivery.deliveryId !== deliveryId) continue;
|
|
11266
11253
|
if (delivery.status !== "active" || delivery.cardId === null) continue;
|
|
11267
|
-
if (
|
|
11254
|
+
if (store.runs.some((r2) => r2.deliveryId === delivery.deliveryId && r2.status === "running")) continue;
|
|
11268
11255
|
if (answerOutcome(delivery) === "changed") {
|
|
11269
11256
|
const superseded = withStore((live) => {
|
|
11270
11257
|
const row = live.deliveries.find((d2) => d2.deliveryId === delivery.deliveryId);
|
|
@@ -11640,28 +11627,14 @@ function resumeRefusal(delivery, store) {
|
|
|
11640
11627
|
const id = delivery.deliveryId;
|
|
11641
11628
|
const what = delivery.cardId === null ? "the build" : `#${delivery.cardId}`;
|
|
11642
11629
|
const task = delivery.cardId === null ? "" : String(delivery.cardId);
|
|
11643
|
-
if (delivery.status === "active") {
|
|
11644
|
-
return refusal("deliveryActive", `delivery ${id} has not ended \u2014 it is still in flight on ${what}.`, { id, task });
|
|
11645
|
-
}
|
|
11646
|
-
if (delivery.status === "finished") {
|
|
11647
|
-
return refusal("deliveryFinished", `delivery ${id} finished; resume carries on one that ended abnormally.`, { id });
|
|
11648
|
-
}
|
|
11649
11630
|
if (delivery.status === "cancelled") {
|
|
11650
11631
|
return refusal("deliveryCancelled", `delivery ${id} was cancelled, and its files were preserved. Start ${what} again.`, { id, task });
|
|
11651
11632
|
}
|
|
11652
11633
|
if (delivery.cardId === null) return void 0;
|
|
11653
11634
|
const card = String(delivery.cardId);
|
|
11654
|
-
const pendingArchive = delivery.completions?.some((c2) => !c2.finished && c2.step + 1 >= (delivery.studio?.land?.length ?? 1));
|
|
11655
|
-
if (cardOnBoard(delivery.cardId) === false && !(pendingArchive && locateArchived(delivery.cardId))) {
|
|
11656
|
-
return refusal(
|
|
11657
|
-
"deliveryCardGone",
|
|
11658
|
-
`#${card} is no longer on the board, so delivery ${id} has nothing left to finish.`,
|
|
11659
|
-
{ id, card }
|
|
11660
|
-
);
|
|
11661
|
-
}
|
|
11662
11635
|
const live = store ?? readStore();
|
|
11663
11636
|
const holder = activeIn(live, delivery.cardId);
|
|
11664
|
-
if (holder) {
|
|
11637
|
+
if (holder && holder.deliveryId !== id) {
|
|
11665
11638
|
const command = `${boardCommand()} raw delivery cancel ${holder.deliveryId}`;
|
|
11666
11639
|
return refusal(
|
|
11667
11640
|
"deliveryHeld",
|
|
@@ -11681,16 +11654,10 @@ function resumeRefusal(delivery, store) {
|
|
|
11681
11654
|
}
|
|
11682
11655
|
return void 0;
|
|
11683
11656
|
}
|
|
11684
|
-
function cardOnBoard(cardId2) {
|
|
11685
|
-
try {
|
|
11686
|
-
return !!locate(cardId2);
|
|
11687
|
-
} catch {
|
|
11688
|
-
return void 0;
|
|
11689
|
-
}
|
|
11690
|
-
}
|
|
11691
11657
|
function resumeRecord(id, execution) {
|
|
11692
11658
|
const found2 = namedDelivery(id) ?? endedDelivery(id);
|
|
11693
11659
|
if (!found2) return { ok: false, ...unknownDelivery(id) };
|
|
11660
|
+
if (found2.status === "finished") return { ok: true, delivery: found2 };
|
|
11694
11661
|
const refused = resumeRefusal(found2);
|
|
11695
11662
|
if (refused && found2.status !== "active") return { ok: false, ...refused };
|
|
11696
11663
|
const out = withStore((store) => {
|
|
@@ -11704,6 +11671,7 @@ function resumeRecord(id, execution) {
|
|
|
11704
11671
|
return { ok: false, ...refusal("deliveryRunGoing", "the delivery still has a running agent; stop it before continuing") };
|
|
11705
11672
|
}
|
|
11706
11673
|
} else if (again) return { ok: false, ...again };
|
|
11674
|
+
if (row.status === "finished") return { ok: true, delivery: row };
|
|
11707
11675
|
const at2 = Date.now();
|
|
11708
11676
|
const resumed = {
|
|
11709
11677
|
...row,
|
|
@@ -13410,7 +13378,7 @@ function kindOf2(ext) {
|
|
|
13410
13378
|
if (type.startsWith("image/")) return "image";
|
|
13411
13379
|
return type.startsWith("video/") || type.startsWith("audio/") ? "video" : "asset";
|
|
13412
13380
|
}
|
|
13413
|
-
var STORYBOARD, STUDIO, ARRANGED, ASSET, isObject, TYPES;
|
|
13381
|
+
var STORYBOARD, STUDIO, ARRANGED, ASSET, isObject, bodySources, TYPES;
|
|
13414
13382
|
var init_references = __esm({
|
|
13415
13383
|
"../artifact-sdk/src/internal/references.ts"() {
|
|
13416
13384
|
"use strict";
|
|
@@ -13419,6 +13387,7 @@ var init_references = __esm({
|
|
|
13419
13387
|
ARRANGED = ["storyboard", "compare", "spritesheet", "studio"];
|
|
13420
13388
|
ASSET = ["spritesheet", "asset"];
|
|
13421
13389
|
isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
13390
|
+
bodySources = (body) => [...new Set(bodyReferences(body).map((r2) => r2.src))];
|
|
13422
13391
|
TYPES = {
|
|
13423
13392
|
".png": "image/png",
|
|
13424
13393
|
".jpg": "image/jpeg",
|
|
@@ -13570,14 +13539,14 @@ function collectSources(sources2, card, host2) {
|
|
|
13570
13539
|
const active2 = /* @__PURE__ */ new Set();
|
|
13571
13540
|
const out = [];
|
|
13572
13541
|
const visit = (src, types, owner, partial = false) => {
|
|
13573
|
-
const
|
|
13542
|
+
const path91 = src.replace(/[?#].*$/, "");
|
|
13574
13543
|
let resolved2;
|
|
13575
13544
|
try {
|
|
13576
|
-
resolved2 = host2.resolve(
|
|
13545
|
+
resolved2 = host2.resolve(path91, owner);
|
|
13577
13546
|
} catch (error) {
|
|
13578
13547
|
if (owner !== card) return { key: null, error: why(error) };
|
|
13579
13548
|
if (!nodes.has(src)) {
|
|
13580
|
-
const node2 = { key: src, file: null, kind: kindAt(
|
|
13549
|
+
const node2 = { key: src, file: null, kind: kindAt(path91, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
|
|
13581
13550
|
nodes.set(src, node2);
|
|
13582
13551
|
out.push(node2);
|
|
13583
13552
|
}
|
|
@@ -14063,7 +14032,7 @@ function validateStoryboards(file2, id, text5) {
|
|
|
14063
14032
|
function formatContractErrors(errors) {
|
|
14064
14033
|
return ["Spec format validation failed. Fix these errors without changing the planned behavior:", ...errors.map((e2) => `${e2.file}:${e2.line} [${e2.rule}] ${e2.message}`)].join("\n");
|
|
14065
14034
|
}
|
|
14066
|
-
var ASSET_LINE, BLOCK_LINE
|
|
14035
|
+
var ASSET_LINE, BLOCK_LINE;
|
|
14067
14036
|
var init_spec_contract = __esm({
|
|
14068
14037
|
"src/lib/spec-contract.ts"() {
|
|
14069
14038
|
"use strict";
|
|
@@ -14076,8 +14045,6 @@ var init_spec_contract = __esm({
|
|
|
14076
14045
|
init_validate();
|
|
14077
14046
|
ASSET_LINE = /^\s*<(?:Asset|Mockup)\b[^<>]*\/>\s*$/;
|
|
14078
14047
|
BLOCK_LINE = /^\s*<(?:Asset\b|Mockup\b|Set\b|\/Set>)/;
|
|
14079
|
-
boardCheckErrors = (errors) => ["Board check failed. Fix these errors without changing the planned behavior:", ...errors.map((e2) => `${e2.file}:${e2.line} [${e2.rule}] ${e2.message}`)].join("\n");
|
|
14080
|
-
boardProblems = (errors) => ["Board problems:", ...errors.map((e2) => `- ${e2.message}`)].join("\n");
|
|
14081
14048
|
}
|
|
14082
14049
|
});
|
|
14083
14050
|
|
|
@@ -14172,14 +14139,6 @@ function reconcileBoard() {
|
|
|
14172
14139
|
if (!fs44.existsSync(README)) return;
|
|
14173
14140
|
for (const line of [...readmeComplaints(true), ...crossRefComplaints()]) warn2(line);
|
|
14174
14141
|
}
|
|
14175
|
-
function boardComplaints() {
|
|
14176
|
-
if (!fs44.existsSync(README)) return [];
|
|
14177
|
-
try {
|
|
14178
|
-
return [...readmeComplaints(false), ...crossRefComplaints()];
|
|
14179
|
-
} catch {
|
|
14180
|
-
return [];
|
|
14181
|
-
}
|
|
14182
|
-
}
|
|
14183
14142
|
var README_LINK;
|
|
14184
14143
|
var init_reconcile = __esm({
|
|
14185
14144
|
"src/lib/reconcile.ts"() {
|
|
@@ -15672,22 +15631,6 @@ function stampLeaving(cards, rejection) {
|
|
|
15672
15631
|
if (stamped !== text5) fs54.writeFileSync(card.file, stamped);
|
|
15673
15632
|
}
|
|
15674
15633
|
}
|
|
15675
|
-
function unfinishedDelivery(id) {
|
|
15676
|
-
const card = findCard(id);
|
|
15677
|
-
if (card?.deliversIn !== "plan") return null;
|
|
15678
|
-
const gap = planDeliveryGap(card);
|
|
15679
|
-
if (gap) {
|
|
15680
|
-
const what = {
|
|
15681
|
-
questions: "it still has open questions",
|
|
15682
|
-
deliverable: "no finished deliverable is on the card",
|
|
15683
|
-
command: "no ticked todo records where it was delivered or the command that rebuilds it",
|
|
15684
|
-
todos: "not every todo is ticked"
|
|
15685
|
-
}[gap];
|
|
15686
|
-
return `#${id} is not finished: ${what}.`;
|
|
15687
|
-
}
|
|
15688
|
-
const missing = planDeliverables(card.body).filter((src) => src.startsWith(".assets/")).find((src) => !fs54.existsSync(path56.join(ASSETS, src.slice(".assets/".length))));
|
|
15689
|
-
return missing ? `#${id} is not finished: ${missing} is not on this machine.` : null;
|
|
15690
|
-
}
|
|
15691
15634
|
function agentDecisions(text5) {
|
|
15692
15635
|
let section = null;
|
|
15693
15636
|
const counts = { stood: 0, overruled: 0 };
|
|
@@ -15713,8 +15656,6 @@ function removeCard2(id, metric, options) {
|
|
|
15713
15656
|
if (creating) die(creating, { kind: "card-being-created" });
|
|
15714
15657
|
const found2 = locate(id);
|
|
15715
15658
|
if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
|
|
15716
|
-
const unfinished = metric === "completed" ? unfinishedDelivery(id) : null;
|
|
15717
|
-
if (unfinished) die(unfinished, { kind: "plan-delivery-unfinished" });
|
|
15718
15659
|
const dest = options.cleanupDiscarded && locateArchived(id) ? null : archiveDest(found2);
|
|
15719
15660
|
const cardFile3 = found2.kind === "group" ? path56.join(found2.target, "root.md") : found2.target;
|
|
15720
15661
|
const cardText = fs54.existsSync(cardFile3) ? fs54.readFileSync(cardFile3, "utf8") : "";
|
|
@@ -15900,7 +15841,6 @@ var init_remove = __esm({
|
|
|
15900
15841
|
init_creation_lock();
|
|
15901
15842
|
init_lock();
|
|
15902
15843
|
init_rules();
|
|
15903
|
-
init_read();
|
|
15904
15844
|
init_cadence();
|
|
15905
15845
|
init_paths();
|
|
15906
15846
|
init_io();
|
|
@@ -16135,6 +16075,96 @@ var init_memory_file = __esm({
|
|
|
16135
16075
|
}
|
|
16136
16076
|
});
|
|
16137
16077
|
|
|
16078
|
+
// src/commands/inspect.ts
|
|
16079
|
+
import fs57 from "node:fs";
|
|
16080
|
+
import os4 from "node:os";
|
|
16081
|
+
import path59 from "node:path";
|
|
16082
|
+
function cmdInspect(id) {
|
|
16083
|
+
const findings = [];
|
|
16084
|
+
const unavailable = [];
|
|
16085
|
+
function read3(source2, file3, empty) {
|
|
16086
|
+
try {
|
|
16087
|
+
return JSON.parse(fs57.readFileSync(file3, "utf8"));
|
|
16088
|
+
} catch (error) {
|
|
16089
|
+
if (error.code === "ENOENT") return empty;
|
|
16090
|
+
findings.push({ source: source2, message: String(error) });
|
|
16091
|
+
unavailable.push(source2);
|
|
16092
|
+
return empty;
|
|
16093
|
+
}
|
|
16094
|
+
}
|
|
16095
|
+
function fact(source2, get, empty) {
|
|
16096
|
+
try {
|
|
16097
|
+
return get();
|
|
16098
|
+
} catch (error) {
|
|
16099
|
+
findings.push({ source: source2, message: String(error) });
|
|
16100
|
+
unavailable.push(source2);
|
|
16101
|
+
return empty;
|
|
16102
|
+
}
|
|
16103
|
+
}
|
|
16104
|
+
const found2 = locate(id) ?? locateArchived(id);
|
|
16105
|
+
if (!found2) return die(`no task with id ${id}`, { kind: "card-not-found", id });
|
|
16106
|
+
const file2 = found2.kind === "group" ? path59.join(found2.target, "root.md") : found2.target;
|
|
16107
|
+
let card = null;
|
|
16108
|
+
try {
|
|
16109
|
+
const { meta, body } = parseFrontmatter(fs57.readFileSync(file2, "utf8"));
|
|
16110
|
+
if (!meta) throw Error("The card frontmatter could not be parsed.");
|
|
16111
|
+
card = { path: rel(file2), questions: meta.questions, todos: [...body.matchAll(/^\s*[-*]\s+\[([ xX])\]\s+(.*)$/gm)].map((m) => ({ text: m[2], done: m[1] !== " " })) };
|
|
16112
|
+
} catch (error) {
|
|
16113
|
+
findings.push({ source: "card", message: String(error) });
|
|
16114
|
+
unavailable.push("card");
|
|
16115
|
+
}
|
|
16116
|
+
const progress = read3("previews", path59.join(BOARD_STATE, "previews", `${id}.json`), {});
|
|
16117
|
+
const store = read3("runs", SESSIONS, {});
|
|
16118
|
+
const runs = fact("runs", () => (store.runs ?? []).filter((run4) => run4.cardId === id).slice(-10).reverse().map((run4) => ({ id: run4.sessionId, status: run4.status, sessionRecorded: run4.harness ? !!(run4.resumeId || run4.continues?.resumeId) : null })), []);
|
|
16119
|
+
const records = [];
|
|
16120
|
+
const directory = path59.join(KANBAN, "deliveries");
|
|
16121
|
+
try {
|
|
16122
|
+
for (const name of fs57.readdirSync(directory).filter((name2) => name2.endsWith(".json"))) {
|
|
16123
|
+
const held5 = read3("delivery", path59.join(directory, name), null);
|
|
16124
|
+
if (held5?.cardId === id) records.push(held5);
|
|
16125
|
+
}
|
|
16126
|
+
} catch (error) {
|
|
16127
|
+
if (error.code !== "ENOENT") {
|
|
16128
|
+
findings.push({ source: "delivery", message: String(error) });
|
|
16129
|
+
unavailable.push("delivery");
|
|
16130
|
+
}
|
|
16131
|
+
}
|
|
16132
|
+
records.push(...fact("delivery", () => (store.deliveries ?? []).filter((held5) => held5.cardId === id), []));
|
|
16133
|
+
const held4 = [...new Map(records.map((held5) => [held5.deliveryId, held5])).values()].sort((a2, b2) => b2.startedAt - a2.startedAt)[0];
|
|
16134
|
+
const job = executionOf()?.job;
|
|
16135
|
+
const checkpoint = job ? read3("recovery", path59.join(process.env.WILDCRANE_HOME || os4.homedir() + "/.wildcrane", "checkpoints", `${encodeURIComponent(job)}.json`), null) : null;
|
|
16136
|
+
const delivery = fact("delivery", () => held4 ? { id: held4.deliveryId, status: held4.status, directory: held4.worktree ?? REPO_ROOT, completedSteps: (held4.completions ?? []).map((c2) => c2.step) } : null, null);
|
|
16137
|
+
const recovery = fact("recovery", () => checkpoint ? { pendingOperations: checkpoint.pending ?? [], submitted: checkpoint.submitted ?? null } : null, null);
|
|
16138
|
+
const result = {
|
|
16139
|
+
id,
|
|
16140
|
+
card,
|
|
16141
|
+
previews: fact("previews", () => Object.entries(progress).map(([agent, p2]) => ({
|
|
16142
|
+
agent,
|
|
16143
|
+
currentStageId: p2.currentStageId,
|
|
16144
|
+
stages: p2.stages.map(({ id: id2, status, version }) => ({ id: id2, status, version })),
|
|
16145
|
+
artifact: p2.displayedArtifact ? { stageId: p2.displayedArtifact.stageId, version: p2.displayedArtifact.version, section: `## By \`${agent}\` agent`, files: [.../* @__PURE__ */ new Set([...Object.keys(p2.displayedArtifact.assets).filter((key) => key !== "folder"), ...bodySources(p2.displayedArtifact.body)])].filter((file3) => !path59.isAbsolute(file3) && !/^[a-z][\w+.-]*:/i.test(file3)) } : null
|
|
16146
|
+
})), []),
|
|
16147
|
+
delivery,
|
|
16148
|
+
runs,
|
|
16149
|
+
recovery,
|
|
16150
|
+
findings,
|
|
16151
|
+
unavailable: [...new Set(unavailable)]
|
|
16152
|
+
};
|
|
16153
|
+
say(JSON.stringify(result, null, 2));
|
|
16154
|
+
return result;
|
|
16155
|
+
}
|
|
16156
|
+
var init_inspect = __esm({
|
|
16157
|
+
"src/commands/inspect.ts"() {
|
|
16158
|
+
"use strict";
|
|
16159
|
+
init_cards();
|
|
16160
|
+
init_frontmatter();
|
|
16161
|
+
init_io();
|
|
16162
|
+
init_paths();
|
|
16163
|
+
init_execution();
|
|
16164
|
+
init_references();
|
|
16165
|
+
}
|
|
16166
|
+
});
|
|
16167
|
+
|
|
16138
16168
|
// src/commands/validate.ts
|
|
16139
16169
|
function cmdValidate(id) {
|
|
16140
16170
|
const cards = [...snapshotSpecs()].filter(([, card]) => id === void 0 || card.id === id);
|
|
@@ -16202,11 +16232,11 @@ var init_ops = __esm({
|
|
|
16202
16232
|
});
|
|
16203
16233
|
|
|
16204
16234
|
// src/lib/view/stamp.ts
|
|
16205
|
-
import
|
|
16206
|
-
import
|
|
16235
|
+
import fs58 from "node:fs";
|
|
16236
|
+
import path60 from "node:path";
|
|
16207
16237
|
function boardStamp() {
|
|
16208
16238
|
const parts = [];
|
|
16209
|
-
for (const dir of [TODO, MEMORY, ASSETS, MOCKUPS,
|
|
16239
|
+
for (const dir of [TODO, MEMORY, ASSETS, MOCKUPS, path60.join(KANBAN, ".mockups")]) walk(dir, parts, 0);
|
|
16210
16240
|
for (const file2 of [MODULES_MD, ARCHIVE_MD, CONFIG]) {
|
|
16211
16241
|
stamp3(file2, parts);
|
|
16212
16242
|
}
|
|
@@ -16216,19 +16246,19 @@ function walk(dir, parts, depth3) {
|
|
|
16216
16246
|
if (depth3 > MAX_DEPTH) return;
|
|
16217
16247
|
let entries;
|
|
16218
16248
|
try {
|
|
16219
|
-
entries =
|
|
16249
|
+
entries = fs58.readdirSync(dir, { withFileTypes: true });
|
|
16220
16250
|
} catch {
|
|
16221
16251
|
return;
|
|
16222
16252
|
}
|
|
16223
16253
|
for (const entry of entries.sort((a2, b2) => a2.name.localeCompare(b2.name))) {
|
|
16224
|
-
const full =
|
|
16254
|
+
const full = path60.join(dir, entry.name);
|
|
16225
16255
|
if (entry.isDirectory()) walk(full, parts, depth3 + 1);
|
|
16226
16256
|
else stamp3(full, parts);
|
|
16227
16257
|
}
|
|
16228
16258
|
}
|
|
16229
16259
|
function stamp3(file2, parts) {
|
|
16230
16260
|
try {
|
|
16231
|
-
const s =
|
|
16261
|
+
const s = fs58.statSync(file2);
|
|
16232
16262
|
parts.push(`${file2}:${s.size}:${Math.round(s.mtimeMs)}`);
|
|
16233
16263
|
} catch {
|
|
16234
16264
|
}
|
|
@@ -16260,8 +16290,8 @@ var init_contract = __esm({
|
|
|
16260
16290
|
});
|
|
16261
16291
|
|
|
16262
16292
|
// src/lib/board/revision.ts
|
|
16263
|
-
import
|
|
16264
|
-
import
|
|
16293
|
+
import fs59 from "node:fs";
|
|
16294
|
+
import path61 from "node:path";
|
|
16265
16295
|
function revisionOf(text5) {
|
|
16266
16296
|
let h3 = 2166136261;
|
|
16267
16297
|
for (let i = 0; i < text5.length; i++) {
|
|
@@ -16273,13 +16303,13 @@ function revisionOf(text5) {
|
|
|
16273
16303
|
function cardFile2(id) {
|
|
16274
16304
|
const found2 = locate(id);
|
|
16275
16305
|
if (!found2) return null;
|
|
16276
|
-
return found2.kind === "group" ?
|
|
16306
|
+
return found2.kind === "group" ? path61.join(found2.target, "root.md") : found2.target;
|
|
16277
16307
|
}
|
|
16278
16308
|
function cardRevision(id) {
|
|
16279
16309
|
const file2 = cardFile2(id);
|
|
16280
16310
|
if (!file2) return NO_REVISION;
|
|
16281
16311
|
try {
|
|
16282
|
-
return revisionOf(
|
|
16312
|
+
return revisionOf(fs59.readFileSync(file2, "utf8"));
|
|
16283
16313
|
} catch {
|
|
16284
16314
|
return NO_REVISION;
|
|
16285
16315
|
}
|
|
@@ -16331,7 +16361,7 @@ function localBoard() {
|
|
|
16331
16361
|
}
|
|
16332
16362
|
const provider = {
|
|
16333
16363
|
kind: "local",
|
|
16334
|
-
readCards: () => Promise.resolve(
|
|
16364
|
+
readCards: () => Promise.resolve(allCards()),
|
|
16335
16365
|
// ---- the writer lease ---------------------------------------------------
|
|
16336
16366
|
// Local grants every lease, an unknown card included: a single machine's board is
|
|
16337
16367
|
// already serialized by the writing lock, so there is nothing here to fence off — and
|
|
@@ -16428,6 +16458,7 @@ var init_local2 = __esm({
|
|
|
16428
16458
|
init_agent_file();
|
|
16429
16459
|
init_studio_file2();
|
|
16430
16460
|
init_memory_file();
|
|
16461
|
+
init_inspect();
|
|
16431
16462
|
init_validate2();
|
|
16432
16463
|
init_io();
|
|
16433
16464
|
init_lock();
|
|
@@ -16436,6 +16467,7 @@ var init_local2 = __esm({
|
|
|
16436
16467
|
init_revision();
|
|
16437
16468
|
as = (opts) => opts;
|
|
16438
16469
|
MOVES = {
|
|
16470
|
+
inspect: ({ args: args2 }) => cmdInspect(Number(args2[0])),
|
|
16439
16471
|
validate: ({ args: args2 }) => cmdValidate(args2[0] === void 0 ? void 0 : Number(args2[0])),
|
|
16440
16472
|
init: () => cmdInit(),
|
|
16441
16473
|
create: ({ opts }) => cmdCreate(as(opts)),
|
|
@@ -16449,7 +16481,7 @@ var init_local2 = __esm({
|
|
|
16449
16481
|
"memory-file": ({ args: args2 }) => cmdMemoryFile(args2[0] ?? "")
|
|
16450
16482
|
};
|
|
16451
16483
|
BOARD_MOVES = new Set(Object.keys(MOVES));
|
|
16452
|
-
READ_ONLY_MOVES = /* @__PURE__ */ new Set(["list", "validate", "file", "agent-file", "memory-file"]);
|
|
16484
|
+
READ_ONLY_MOVES = /* @__PURE__ */ new Set(["inspect", "list", "validate", "file", "agent-file", "memory-file"]);
|
|
16453
16485
|
leases = /* @__PURE__ */ new Map();
|
|
16454
16486
|
leaseCounter = 0;
|
|
16455
16487
|
}
|
|
@@ -16480,14 +16512,14 @@ var init_board = __esm({
|
|
|
16480
16512
|
});
|
|
16481
16513
|
|
|
16482
16514
|
// src/lib/plans.ts
|
|
16483
|
-
import
|
|
16484
|
-
import
|
|
16515
|
+
import fs60 from "node:fs";
|
|
16516
|
+
import path62 from "node:path";
|
|
16485
16517
|
function planFile(rel2) {
|
|
16486
16518
|
if (!/^plans\/(archive\/)?[^/\\]+\.md$/.test(rel2)) return null;
|
|
16487
16519
|
const dir = isArchivedPlan(rel2) ? PLANS_ARCHIVE : PLANS;
|
|
16488
16520
|
const name = rel2.replace(/^plans\/(archive\/)?/, "");
|
|
16489
16521
|
if (!name || name.includes("/") || !name.endsWith(".md")) return null;
|
|
16490
|
-
return
|
|
16522
|
+
return path62.join(dir, name);
|
|
16491
16523
|
}
|
|
16492
16524
|
function readPlan(rel2) {
|
|
16493
16525
|
const file2 = planFile(rel2);
|
|
@@ -16495,12 +16527,12 @@ function readPlan(rel2) {
|
|
|
16495
16527
|
let text5 = "";
|
|
16496
16528
|
let found2 = rel2;
|
|
16497
16529
|
try {
|
|
16498
|
-
text5 =
|
|
16530
|
+
text5 = fs60.readFileSync(file2, "utf8");
|
|
16499
16531
|
} catch {
|
|
16500
16532
|
const moved = renamedPlan(rel2);
|
|
16501
16533
|
if (moved) {
|
|
16502
16534
|
found2 = moved;
|
|
16503
|
-
text5 =
|
|
16535
|
+
text5 = fs60.readFileSync(planFile(moved), "utf8");
|
|
16504
16536
|
}
|
|
16505
16537
|
}
|
|
16506
16538
|
return { path: found2, text: text5, lines: text5.trim() ? text5.trimEnd().split("\n").length : 0 };
|
|
@@ -16515,13 +16547,13 @@ function renamedPlan(rel2) {
|
|
|
16515
16547
|
]) {
|
|
16516
16548
|
let names3;
|
|
16517
16549
|
try {
|
|
16518
|
-
names3 =
|
|
16550
|
+
names3 = fs60.readdirSync(dir);
|
|
16519
16551
|
} catch {
|
|
16520
16552
|
continue;
|
|
16521
16553
|
}
|
|
16522
16554
|
for (const n of names3) {
|
|
16523
16555
|
if (!n.startsWith(`${id}-`) || !n.endsWith(".md")) continue;
|
|
16524
|
-
found2.push({ rel: `${prefix}${n}`, at:
|
|
16556
|
+
found2.push({ rel: `${prefix}${n}`, at: fs60.statSync(path62.join(dir, n)).mtimeMs });
|
|
16525
16557
|
}
|
|
16526
16558
|
}
|
|
16527
16559
|
if (!found2.length) return null;
|
|
@@ -16530,7 +16562,7 @@ function renamedPlan(rel2) {
|
|
|
16530
16562
|
function planFromText(text5) {
|
|
16531
16563
|
const legacy2 = `${legacyProjectStateDir(KANBAN)}/`;
|
|
16532
16564
|
if (text5.startsWith(legacy2)) text5 = text5.slice(legacy2.length);
|
|
16533
|
-
const local = `${
|
|
16565
|
+
const local = `${path62.dirname(PLANS)}/`;
|
|
16534
16566
|
if (text5.startsWith(local)) text5 = text5.slice(local.length);
|
|
16535
16567
|
if (text5.startsWith(`${KANBAN}/`)) text5 = text5.slice(KANBAN.length + 1);
|
|
16536
16568
|
const here = `${boardPath()}/`;
|
|
@@ -16589,36 +16621,58 @@ var init_roster = __esm({
|
|
|
16589
16621
|
}
|
|
16590
16622
|
});
|
|
16591
16623
|
|
|
16624
|
+
// src/lib/agent/own-cost.ts
|
|
16625
|
+
function ownCost(total, before) {
|
|
16626
|
+
if (total === void 0 || before === null) return void 0;
|
|
16627
|
+
if (before === void 0 || total < before) return total;
|
|
16628
|
+
return total >= before ? total - before : void 0;
|
|
16629
|
+
}
|
|
16630
|
+
function lastSessionTotal(id, runs) {
|
|
16631
|
+
let best;
|
|
16632
|
+
const take = (at2, usd) => {
|
|
16633
|
+
if (typeof usd === "number" && usd >= 0 && (!best || at2 >= best.at)) best = { at: at2, usd };
|
|
16634
|
+
};
|
|
16635
|
+
for (const r2 of runs) if (r2.resumeId === id || r2.sessionId === id) take(r2.endedAt ?? r2.startedAt, r2.sessionCostUsd);
|
|
16636
|
+
return best?.usd ?? null;
|
|
16637
|
+
}
|
|
16638
|
+
var reportsSessionTotal;
|
|
16639
|
+
var init_own_cost = __esm({
|
|
16640
|
+
"src/lib/agent/own-cost.ts"() {
|
|
16641
|
+
"use strict";
|
|
16642
|
+
reportsSessionTotal = (harness) => harness === "claude-code";
|
|
16643
|
+
}
|
|
16644
|
+
});
|
|
16645
|
+
|
|
16592
16646
|
// src/lib/agent/pictures.ts
|
|
16593
|
-
import
|
|
16594
|
-
import
|
|
16647
|
+
import fs61 from "node:fs";
|
|
16648
|
+
import path63 from "node:path";
|
|
16595
16649
|
function claimRunPictures(box2, sessionId, names3 = []) {
|
|
16596
16650
|
if (!box2 || !freeBox(box2) || names3.length === 0) return [];
|
|
16597
16651
|
const from = pictureBox(box2);
|
|
16598
16652
|
const to = pictureBox(sessionId);
|
|
16599
16653
|
try {
|
|
16600
|
-
|
|
16601
|
-
|
|
16654
|
+
fs61.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
16655
|
+
fs61.renameSync(from, to);
|
|
16602
16656
|
} catch {
|
|
16603
16657
|
return [];
|
|
16604
16658
|
}
|
|
16605
|
-
return names3.filter(pictureName).map((name) =>
|
|
16659
|
+
return names3.filter(pictureName).map((name) => path63.join(to, name)).filter((file2) => fs61.existsSync(file2));
|
|
16606
16660
|
}
|
|
16607
16661
|
function returnRunPictures(sessionId, box2) {
|
|
16608
16662
|
if (!box2 || !boxId(box2)) return;
|
|
16609
16663
|
try {
|
|
16610
|
-
|
|
16664
|
+
fs61.renameSync(pictureBox(sessionId), pictureBox(box2));
|
|
16611
16665
|
} catch {
|
|
16612
16666
|
}
|
|
16613
16667
|
}
|
|
16614
16668
|
function moveRunPictures(from, to, files = []) {
|
|
16615
16669
|
if (files.length === 0) return [];
|
|
16616
16670
|
try {
|
|
16617
|
-
|
|
16671
|
+
fs61.renameSync(pictureBox(from), pictureBox(to));
|
|
16618
16672
|
} catch {
|
|
16619
16673
|
return files;
|
|
16620
16674
|
}
|
|
16621
|
-
return files.map((file2) =>
|
|
16675
|
+
return files.map((file2) => path63.join(pictureBox(to), path63.basename(file2)));
|
|
16622
16676
|
}
|
|
16623
16677
|
var pictureName, boxId, freeBox, pictureBox;
|
|
16624
16678
|
var init_pictures = __esm({
|
|
@@ -16627,8 +16681,8 @@ var init_pictures = __esm({
|
|
|
16627
16681
|
init_paths();
|
|
16628
16682
|
pictureName = (name) => /^[0-9a-f-]{36}\.[a-z0-9]{2,5}$/.test(name);
|
|
16629
16683
|
boxId = (box2) => /^[0-9a-f-]{36}$/.test(box2);
|
|
16630
|
-
freeBox = (box2) => boxId(box2) && !
|
|
16631
|
-
pictureBox = (box2) =>
|
|
16684
|
+
freeBox = (box2) => boxId(box2) && !fs61.existsSync(path63.join(SESSIONS_DIR, `${box2}.log`));
|
|
16685
|
+
pictureBox = (box2) => path63.join(SESSIONS_DIR, `${box2}.images`);
|
|
16632
16686
|
}
|
|
16633
16687
|
});
|
|
16634
16688
|
|
|
@@ -16748,16 +16802,16 @@ var init_facts = __esm({
|
|
|
16748
16802
|
});
|
|
16749
16803
|
|
|
16750
16804
|
// src/lib/view/archive.ts
|
|
16751
|
-
import
|
|
16752
|
-
import
|
|
16805
|
+
import fs62 from "node:fs";
|
|
16806
|
+
import path64 from "node:path";
|
|
16753
16807
|
function archivedId(file2) {
|
|
16754
|
-
const own = idPrefix(
|
|
16755
|
-
return own !== null ? own : idPrefix(
|
|
16808
|
+
const own = idPrefix(path64.basename(file2));
|
|
16809
|
+
return own !== null ? own : idPrefix(path64.basename(path64.dirname(file2)));
|
|
16756
16810
|
}
|
|
16757
16811
|
function readFile(file2) {
|
|
16758
16812
|
const id = archivedId(file2);
|
|
16759
16813
|
if (id === null) return null;
|
|
16760
|
-
const { meta, body } = parseFrontmatter(
|
|
16814
|
+
const { meta, body } = parseFrontmatter(fs62.readFileSync(file2, "utf8"));
|
|
16761
16815
|
if (!meta) return null;
|
|
16762
16816
|
return {
|
|
16763
16817
|
row: {
|
|
@@ -16765,15 +16819,15 @@ function readFile(file2) {
|
|
|
16765
16819
|
title: meta.title,
|
|
16766
16820
|
archived: meta.archived,
|
|
16767
16821
|
rejected: meta.rejected,
|
|
16768
|
-
relPath: rel(file2).split(
|
|
16822
|
+
relPath: rel(file2).split(path64.sep).join("/")
|
|
16769
16823
|
},
|
|
16770
16824
|
body: body.replace(/^\n+/, "").replace(/\s+$/, ""),
|
|
16771
16825
|
meta
|
|
16772
16826
|
};
|
|
16773
16827
|
}
|
|
16774
16828
|
function readArchive() {
|
|
16775
|
-
const relPath = rel(ARCHIVE).split(
|
|
16776
|
-
if (!
|
|
16829
|
+
const relPath = rel(ARCHIVE).split(path64.sep).join("/");
|
|
16830
|
+
if (!fs62.existsSync(ARCHIVE)) return { relPath, cards: [] };
|
|
16777
16831
|
const cards = walkMd(ARCHIVE).map(readFile).filter((found2) => found2 !== null).map((found2) => found2.row);
|
|
16778
16832
|
cards.sort((a2, b2) => b2.id - a2.id);
|
|
16779
16833
|
return { relPath, cards };
|
|
@@ -16788,7 +16842,7 @@ var init_archive = __esm({
|
|
|
16788
16842
|
});
|
|
16789
16843
|
|
|
16790
16844
|
// src/lib/agent/prompts.ts
|
|
16791
|
-
import
|
|
16845
|
+
import path65 from "node:path";
|
|
16792
16846
|
function stopReason(deliveryId) {
|
|
16793
16847
|
const delivery = findDelivery(deliveryId);
|
|
16794
16848
|
if (!delivery) return void 0;
|
|
@@ -16819,13 +16873,6 @@ ${approved}`;
|
|
|
16819
16873
|
}
|
|
16820
16874
|
return `Follow \`akb guide implement\`: create no card and build exactly this approved requirement and nothing more \u2014 "${approved}".`;
|
|
16821
16875
|
}
|
|
16822
|
-
function contractRepairPrompt(req, errors) {
|
|
16823
|
-
return boardText([
|
|
16824
|
-
"The task left the board broken. Fix only the errors below. Preserve planned behavior and completed work; do not repeat the task or request other agents.",
|
|
16825
|
-
errors,
|
|
16826
|
-
ruleBlock(req, frozenRules(req))
|
|
16827
|
-
].filter(Boolean).join("\n\n"));
|
|
16828
|
-
}
|
|
16829
16876
|
function restartPrompt(req, deliveryId) {
|
|
16830
16877
|
if (req.id === void 0 && !req.deliveryId && !deliveryId) return void 0;
|
|
16831
16878
|
if (deliveryId && req.action === "implement") return [RESTART_LEAD, `Continue delivery ${deliveryId}. ${deliveryRequirements(deliveryId, req.id ?? null)}`.trim()].join("\n\n");
|
|
@@ -16849,7 +16896,7 @@ ${text5}` : "";
|
|
|
16849
16896
|
}
|
|
16850
16897
|
function cardFileOf(id) {
|
|
16851
16898
|
const found2 = id === void 0 ? null : locate(id);
|
|
16852
|
-
return found2 ? found2.kind === "group" ?
|
|
16899
|
+
return found2 ? found2.kind === "group" ? path65.join(found2.target, "root.md") : found2.target : "";
|
|
16853
16900
|
}
|
|
16854
16901
|
function realPaths(text5, req) {
|
|
16855
16902
|
if (req.action !== "scheduled" && req.action !== "sub") return text5;
|
|
@@ -16947,7 +16994,7 @@ function frozenRules(req) {
|
|
|
16947
16994
|
function archivedCardFile(id) {
|
|
16948
16995
|
const found2 = locateArchived(id);
|
|
16949
16996
|
if (!found2) return `${rel(ARCHIVE)}/`;
|
|
16950
|
-
return rel(found2.kind === "group" ?
|
|
16997
|
+
return rel(found2.kind === "group" ? path65.join(found2.target, "root.md") : found2.target);
|
|
16951
16998
|
}
|
|
16952
16999
|
function shippedLines(cardId2) {
|
|
16953
17000
|
const delivery = endedDelivery(`${cardId2}`);
|
|
@@ -16981,7 +17028,12 @@ function roster(req) {
|
|
|
16981
17028
|
}
|
|
16982
17029
|
function buildRun(req) {
|
|
16983
17030
|
const notes = [...migrateFlowRules(), ...req.specAgent ? foldedSettingsNotes(req.specAgent) : []];
|
|
16984
|
-
|
|
17031
|
+
let prompt = buildPrompt(req, notes);
|
|
17032
|
+
if (req.action === "spec" && req.id !== void 0 && req.specAgent) {
|
|
17033
|
+
const stage = realPaths(boardText(previewStagePrompt(req.id, req.specAgent, boardCommand())), req);
|
|
17034
|
+
if (stage) prompt = prompt.replace(stage, "");
|
|
17035
|
+
}
|
|
17036
|
+
return { prompt, notes };
|
|
16985
17037
|
}
|
|
16986
17038
|
function answeredNote(cardId2, command) {
|
|
16987
17039
|
const delivery = cardId2 === void 0 ? void 0 : activeDelivery(cardId2);
|
|
@@ -17031,7 +17083,7 @@ function actionPrompt(req, command, notes) {
|
|
|
17031
17083
|
].filter(Boolean).join(" ");
|
|
17032
17084
|
case "clarify": {
|
|
17033
17085
|
return [
|
|
17034
|
-
`Plan task ${req.id} ${named2}
|
|
17086
|
+
`Plan task ${req.id} ${named2} following \`akb guide refine\`. Work the board only through \`akb\`; a command with \`--print\` prints its flow for you to follow here, and without it starts a separate session.`,
|
|
17035
17087
|
carriedNote(req),
|
|
17036
17088
|
// A refine has no note box of its own, but one SCHEDULED on a blocked card
|
|
17037
17089
|
// carries whatever was typed when it was scheduled — often the very reason the user
|
|
@@ -17090,7 +17142,7 @@ function actionPrompt(req, command, notes) {
|
|
|
17090
17142
|
case "spec": {
|
|
17091
17143
|
const agent = findSpecAgent(req.specAgent ?? "");
|
|
17092
17144
|
const found2 = req.id === void 0 ? null : locate(req.id);
|
|
17093
|
-
const cardFile3 = found2 ? rel(found2.kind === "group" ?
|
|
17145
|
+
const cardFile3 = found2 ? rel(found2.kind === "group" ? path65.join(found2.target, "root.md") : found2.target) : `task #${req.id}`;
|
|
17094
17146
|
const own = agent ? specAgentInstructions(agent) : null;
|
|
17095
17147
|
if (own) notes.push(...own.notes);
|
|
17096
17148
|
const memory = agent ? agentMemoryBlock(agent) : "";
|
|
@@ -17236,8 +17288,7 @@ var init_prompts = __esm({
|
|
|
17236
17288
|
init_store();
|
|
17237
17289
|
init_types3();
|
|
17238
17290
|
RESUME_PROMPT = [
|
|
17239
|
-
`Continue
|
|
17240
|
-
`Pick up where you left off and carry it through.`
|
|
17291
|
+
`Continue work.`
|
|
17241
17292
|
].join(" ");
|
|
17242
17293
|
DELIVERY_RESUME = `Continue delivery %s. %r`;
|
|
17243
17294
|
DELIVERY_RESUME_CARD = `Build the card as the delivery holds it, not as the file reads now: \`%c\` prints the approved copy.`;
|
|
@@ -17252,8 +17303,7 @@ var init_prompts = __esm({
|
|
|
17252
17303
|
"scheduled"
|
|
17253
17304
|
]);
|
|
17254
17305
|
RESTART_LEAD = [
|
|
17255
|
-
`
|
|
17256
|
-
`Do the task below from the top, checking each step's precondition before you do it \u2014 work an earlier run already finished is done, so don't repeat it.`
|
|
17306
|
+
`Continue work.`
|
|
17257
17307
|
].join(" ");
|
|
17258
17308
|
restartable = (run4) => (run4.cardId !== null || !!run4.deliveryId) && RESTARTABLE.has(run4.action);
|
|
17259
17309
|
NO_IMPLEMENT = `(Unless the request explicitly asks for implementation, don't implement it; revising the card's drafts is not implementing.)`;
|
|
@@ -17268,16 +17318,16 @@ var init_prompts = __esm({
|
|
|
17268
17318
|
|
|
17269
17319
|
// src/lib/agent/stop.ts
|
|
17270
17320
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
17271
|
-
import
|
|
17321
|
+
import fs63 from "node:fs";
|
|
17272
17322
|
function markedInProc(entry, strict = false, since) {
|
|
17273
17323
|
const pids = [];
|
|
17274
|
-
for (const name of
|
|
17324
|
+
for (const name of fs63.readdirSync("/proc")) {
|
|
17275
17325
|
if (!/^\d+$/.test(name)) continue;
|
|
17276
17326
|
try {
|
|
17277
|
-
if (
|
|
17327
|
+
if (fs63.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
|
|
17278
17328
|
} catch (error) {
|
|
17279
17329
|
if (strict && !["ENOENT", "ESRCH"].includes(error.code ?? "")) {
|
|
17280
|
-
const stat =
|
|
17330
|
+
const stat = fs63.statSync(`/proc/${name}`, { throwIfNoEntry: false });
|
|
17281
17331
|
if (stat?.uid === process.getuid?.() && !startedBefore(Number(name), since)) throw error;
|
|
17282
17332
|
}
|
|
17283
17333
|
}
|
|
@@ -17502,8 +17552,8 @@ __export(sessions_exports, {
|
|
|
17502
17552
|
withRuns: () => withRuns
|
|
17503
17553
|
});
|
|
17504
17554
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
17505
|
-
import
|
|
17506
|
-
import
|
|
17555
|
+
import fs64 from "node:fs";
|
|
17556
|
+
import path66 from "node:path";
|
|
17507
17557
|
function reap(runs, reaped = [], restore = []) {
|
|
17508
17558
|
let changed = false;
|
|
17509
17559
|
const now = Date.now();
|
|
@@ -17523,7 +17573,7 @@ function reap(runs, reaped = [], restore = []) {
|
|
|
17523
17573
|
}
|
|
17524
17574
|
function stampDuration(run4, endedAt) {
|
|
17525
17575
|
try {
|
|
17526
|
-
|
|
17576
|
+
fs64.appendFileSync(run4.logPath, durationLine(endedAt - run4.startedAt));
|
|
17527
17577
|
} catch {
|
|
17528
17578
|
}
|
|
17529
17579
|
}
|
|
@@ -17537,7 +17587,7 @@ function cardNow(cardId2) {
|
|
|
17537
17587
|
try {
|
|
17538
17588
|
const file2 = cardFile2(cardId2);
|
|
17539
17589
|
if (!file2) return null;
|
|
17540
|
-
const { meta } = parseFrontmatter(
|
|
17590
|
+
const { meta } = parseFrontmatter(fs64.readFileSync(file2, "utf8"));
|
|
17541
17591
|
if (!meta) return null;
|
|
17542
17592
|
return { status: meta.status || "todo", questions: meta.questions.length, title: meta.title };
|
|
17543
17593
|
} catch {
|
|
@@ -17608,7 +17658,7 @@ function resumeSessionId(run4) {
|
|
|
17608
17658
|
return resumesUnder(run4.harness) && !neverStarted(run4) ? resumeIdOf(run4) : void 0;
|
|
17609
17659
|
}
|
|
17610
17660
|
function endedDeliveryRefusal(r2, refusals) {
|
|
17611
|
-
if (!r2.deliveryId
|
|
17661
|
+
if (!r2.deliveryId) return void 0;
|
|
17612
17662
|
if (refusals?.has(r2.deliveryId)) return refusals.get(r2.deliveryId);
|
|
17613
17663
|
const delivery = findDelivery(r2.deliveryId);
|
|
17614
17664
|
const ended = delivery && delivery.status !== "active" && (delivery.status !== "failed" || delivery.worktree);
|
|
@@ -17618,8 +17668,7 @@ function endedDeliveryRefusal(r2, refusals) {
|
|
|
17618
17668
|
return why2;
|
|
17619
17669
|
}
|
|
17620
17670
|
function retryAsk(r2) {
|
|
17621
|
-
if (
|
|
17622
|
-
if (r2.formatRepair && !neverStarted(r2)) return void 0;
|
|
17671
|
+
if (isRetired(r2.action)) return void 0;
|
|
17623
17672
|
const id = r2.cardId ?? void 0;
|
|
17624
17673
|
const base = {
|
|
17625
17674
|
action: r2.action,
|
|
@@ -17648,7 +17697,7 @@ function retryAsk(r2) {
|
|
|
17648
17697
|
}
|
|
17649
17698
|
}
|
|
17650
17699
|
function toView(r2, gone, refusals) {
|
|
17651
|
-
const cardOffBoard = r2.cardId !== null && !!gone?.has(r2.cardId);
|
|
17700
|
+
const cardOffBoard = r2.status !== "done" && r2.cardId !== null && !!gone?.has(r2.cardId);
|
|
17652
17701
|
const open3 = r2.action !== "sub" && canPickUp(r2) && !endedDeliveryRefusal(r2, refusals);
|
|
17653
17702
|
const session = !lacksSession(r2);
|
|
17654
17703
|
return {
|
|
@@ -17670,9 +17719,9 @@ function leftBoardOnLanding(id) {
|
|
|
17670
17719
|
function archivedRejected(id) {
|
|
17671
17720
|
const filed = locateArchived(id);
|
|
17672
17721
|
if (!filed) return null;
|
|
17673
|
-
const file2 = filed.kind === "group" ?
|
|
17722
|
+
const file2 = filed.kind === "group" ? path66.join(filed.target, "root.md") : filed.target;
|
|
17674
17723
|
try {
|
|
17675
|
-
return !!parseFrontmatter(
|
|
17724
|
+
return !!parseFrontmatter(fs64.readFileSync(file2, "utf8")).meta?.rejected;
|
|
17676
17725
|
} catch {
|
|
17677
17726
|
return false;
|
|
17678
17727
|
}
|
|
@@ -17922,7 +17971,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID4(), said2) {
|
|
|
17922
17971
|
return { run: record, spec };
|
|
17923
17972
|
}
|
|
17924
17973
|
function planningSession(cardId2, cwd = REPO_ROOT) {
|
|
17925
|
-
const here = (dir) => !dir ||
|
|
17974
|
+
const here = (dir) => !dir || path66.resolve(dir) === cwd;
|
|
17926
17975
|
const planned = readRuns().filter((r2) => r2.status === "done" && r2.cardId === cardId2 && PLANNING.has(r2.action)).sort((a2, b2) => b2.startedAt - a2.startedAt)[0];
|
|
17927
17976
|
if (!planned) return { none: "unrecorded" };
|
|
17928
17977
|
if (!here(planned.cwd)) return { none: "elsewhere" };
|
|
@@ -17975,6 +18024,7 @@ function requestOf(record) {
|
|
|
17975
18024
|
// the CLI actually spawned takes it.
|
|
17976
18025
|
runtime: record.runtime,
|
|
17977
18026
|
specAgent: record.specAgent,
|
|
18027
|
+
notes: record.input,
|
|
17978
18028
|
...record.action === "scheduled" ? { studio: record.studio } : {},
|
|
17979
18029
|
triage: record.triage,
|
|
17980
18030
|
cards: record.cards,
|
|
@@ -17984,8 +18034,8 @@ function requestOf(record) {
|
|
|
17984
18034
|
};
|
|
17985
18035
|
}
|
|
17986
18036
|
async function openResume(id, options) {
|
|
17987
|
-
const build = typeof options === "object" ? options : void 0;
|
|
17988
|
-
const
|
|
18037
|
+
const build = typeof options === "object" && options.deliveryId ? { deliveryId: options.deliveryId, notes: options.notes } : void 0;
|
|
18038
|
+
const forced = typeof options === "object" && options.fresh;
|
|
17989
18039
|
const restore = [];
|
|
17990
18040
|
const runs = withRuns((all2) => {
|
|
17991
18041
|
reap(all2, [], restore);
|
|
@@ -18003,14 +18053,6 @@ async function openResume(id, options) {
|
|
|
18003
18053
|
if (build && (prev.action !== "implement" || prev.deliveryId !== build.deliveryId || delivery?.status !== "active")) {
|
|
18004
18054
|
return refusal("deliveryTakenOver", "\u539F\u6784\u5EFA\u4E0D\u5C5E\u4E8E\u5F53\u524D\u5F85\u7EED\u8DD1\u7684\u4EA4\u4ED8\uFF0C\u4E0D\u4F1A\u542F\u52A8\u65B0\u4F1A\u8BDD\u3002", { id: build.deliveryId });
|
|
18005
18055
|
}
|
|
18006
|
-
const completedBuild = prev.status === "done" && prev.action === "implement" && delivery?.status === "active" && prev.deliveryId === delivery.deliveryId;
|
|
18007
|
-
if (!canPickUp(prev) && !completedBuild) return refusal("runNotResumable", "only a failed, interrupted or stopped run can be continued");
|
|
18008
|
-
const retrying = lacksSession(prev);
|
|
18009
|
-
if (requireSession && (!resumeSessionId(prev) || !resumesUnder(prev.harness))) {
|
|
18010
|
-
return refusal("runNoSession", "\u539F\u6784\u5EFA\u6CA1\u6709\u53EF\u6062\u590D\u7684\u4F1A\u8BDD\u6807\u8BC6\uFF0C\u6216\u539F Agent \u4E0D\u652F\u6301\u7EED\u8DD1\uFF1B\u672C\u6B21\u672A\u542F\u52A8\u65B0\u4F1A\u8BDD\u3002");
|
|
18011
|
-
}
|
|
18012
|
-
const ask2 = retrying && prev.status !== "stopped" ? retryAsk(prev) : void 0;
|
|
18013
|
-
if (retrying && !ask2) return refusal("runNoSession", "that run never reported a session id to continue by");
|
|
18014
18056
|
const ended = endedDeliveryRefusal(prev);
|
|
18015
18057
|
if (ended) return ended;
|
|
18016
18058
|
const resuming = prev.deliveryId ? findDelivery(prev.deliveryId) : void 0;
|
|
@@ -18018,24 +18060,17 @@ async function openResume(id, options) {
|
|
|
18018
18060
|
const sessionId = randomUUID4();
|
|
18019
18061
|
let plan;
|
|
18020
18062
|
let fresh;
|
|
18021
|
-
|
|
18022
|
-
|
|
18023
|
-
|
|
18024
|
-
|
|
18063
|
+
const session = forced ? void 0 : resumeSessionId(prev);
|
|
18064
|
+
if (session) {
|
|
18065
|
+
plan = planResume({ harness: prev.harness, resumeId: session, cwd }, prev.agent, prev.runtime ? { pin: prev.runtime } : {});
|
|
18066
|
+
} else {
|
|
18067
|
+
const ask2 = retryAsk(prev) ?? requestOf(prev);
|
|
18025
18068
|
const started = await planRetry(prev, ask2, sessionId, cwd);
|
|
18026
18069
|
if ("error" in started) return started;
|
|
18027
18070
|
({ plan, fresh } = started);
|
|
18028
|
-
|
|
18029
|
-
|
|
18030
|
-
|
|
18031
|
-
prev.agent,
|
|
18032
|
-
prev.runtime ? { pin: prev.runtime } : {}
|
|
18033
|
-
);
|
|
18034
|
-
} else {
|
|
18035
|
-
const prompt = restartPrompt({ ...requestOf(prev), runtime: void 0 }, prev.deliveryId);
|
|
18036
|
-
const started = prompt ? planRun(sessionId, cwd, prev.agent) : null;
|
|
18037
|
-
plan = started;
|
|
18038
|
-
if (started && prompt) fresh = { prompt, notes: started.note ? [started.note] : [] };
|
|
18071
|
+
const restart = prev.action === "spec" ? void 0 : restartPrompt({ ...requestOf(prev), runtime: plan.runtime }, prev.deliveryId);
|
|
18072
|
+
fresh.prompt = restart ?? ["Continue work.", fresh.prompt].join("\n\n");
|
|
18073
|
+
if (!lacksSession(prev) && !forced) fresh.retry = false;
|
|
18039
18074
|
}
|
|
18040
18075
|
if (!plan) {
|
|
18041
18076
|
const agent = prev.harness || "the agent that started it";
|
|
@@ -18044,7 +18079,6 @@ async function openResume(id, options) {
|
|
|
18044
18079
|
const buildResume = prev.action === "implement" && prev.deliveryId ? resumePrompt(prev.deliveryId, prev.action) : void 0;
|
|
18045
18080
|
const opened = await resumeHeld(prev, plan, sessionId, resuming, fresh);
|
|
18046
18081
|
if ("error" in opened) return opened;
|
|
18047
|
-
if (build) opened.spec.notes = [...opened.spec.notes ?? [], "\u7EE7\u7EED\u539F\u6784\u5EFA\u4F1A\u8BDD\uFF1B\u82E5\u539F\u4F1A\u8BDD\u4E0D\u53EF\u7528\uFF0C\u672C\u6B21\u4E0D\u4F1A\u65B0\u5EFA\u4F1A\u8BDD\u3002"];
|
|
18048
18082
|
if (!opened.spec.prompt && buildResume) opened.spec.prompt = buildResume;
|
|
18049
18083
|
if (build?.notes?.trim()) opened.spec.prompt = [opened.spec.prompt || resumePrompt(prev.deliveryId, prev.action), build.notes.trim()].join("\n\n");
|
|
18050
18084
|
if (build || buildResume) writeSpec(opened.spec);
|
|
@@ -18071,10 +18105,9 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
|
|
|
18071
18105
|
action: prev.action,
|
|
18072
18106
|
status: "running",
|
|
18073
18107
|
startedAt: Date.now(),
|
|
18074
|
-
//
|
|
18075
|
-
|
|
18076
|
-
|
|
18077
|
-
...retry2 ? { input: prev.input, studio: prev.studio } : {},
|
|
18108
|
+
// Keep the original ask available if a later resume loses its session.
|
|
18109
|
+
input: prev.input,
|
|
18110
|
+
studio: prev.studio,
|
|
18078
18111
|
harness: plan.harness,
|
|
18079
18112
|
runtime: plan.runtime,
|
|
18080
18113
|
agent: plan.agent,
|
|
@@ -18087,8 +18120,7 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
|
|
|
18087
18120
|
resumeId: plan.resumeId ?? void 0,
|
|
18088
18121
|
resumedFrom: prev.sessionId,
|
|
18089
18122
|
// Taken now: the run being continued is dropped once this one starts (#1483).
|
|
18090
|
-
sessionCostFrom: prev.sessionCostUsd ?? prev.sessionCostFrom,
|
|
18091
|
-
formatRepair: prev.formatRepair ? { ...prev.formatRepair, attempt: prev.formatRepair.attempt + 1 } : void 0,
|
|
18123
|
+
sessionCostFrom: reportsSessionTotal(prev.harness) ? prev.sessionCostUsd ?? prev.sessionCostFrom : void 0,
|
|
18092
18124
|
// The retry chain carries on rather than starting over (#525): this run IS the attempt
|
|
18093
18125
|
// the failed one scheduled, so its count and its window come with it.
|
|
18094
18126
|
retry: prev.retry
|
|
@@ -18110,22 +18142,12 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
|
|
|
18110
18142
|
return refusal("discardUnfinished", "A card discard did not finish. Retry discarding it before resuming creation.");
|
|
18111
18143
|
}
|
|
18112
18144
|
record.discardedCards = latest.discardedCards;
|
|
18113
|
-
const discarded = new Set(record.discardedCards?.map((c2) => c2.id) ?? []);
|
|
18114
|
-
if (record.formatRepair && discarded.size) {
|
|
18115
|
-
const repair = record.formatRepair;
|
|
18116
|
-
repair.cardIds = repair.cardIds.filter((id) => !discarded.has(id));
|
|
18117
|
-
repair.changedIds = repair.changedIds.filter((id) => !discarded.has(id));
|
|
18118
|
-
repair.existingIds = repair.existingIds.filter((id) => !discarded.has(id));
|
|
18119
|
-
repair.errors = repair.errors.split("\n").filter((line) => !record.discardedCards.some((c2) => line.includes(c2.path) || new RegExp(`Task #${c2.id}(?![0-9])`).test(line))).join("\n");
|
|
18120
|
-
if (!repair.cardIds.length) record.formatRepair = void 0;
|
|
18121
|
-
}
|
|
18122
18145
|
const heldCreation = all2.find((r2) => runIsLive(r2) && (r2.cardId !== null && (latest.createdCardIds ?? []).includes(r2.cardId) || (r2.createdCardIds ?? []).some((id) => (latest.createdCardIds ?? []).includes(id))));
|
|
18123
18146
|
if (heldCreation) return refusal("creationHeld", "A card from this creation is already being worked on. Wait for that run to finish.");
|
|
18124
18147
|
const locked = lockedBy(all2, prev.action, prev.cardId, prev.discard);
|
|
18125
18148
|
if (locked) return locked;
|
|
18126
18149
|
all2.push(record);
|
|
18127
18150
|
const delivery = store.deliveries.find((d2) => d2.deliveryId === prev.deliveryId && d2.status === "active");
|
|
18128
|
-
if (!delivery && record.formatRepair) record.deliveryId = prev.deliveryId;
|
|
18129
18151
|
if (delivery) {
|
|
18130
18152
|
delivery.sessions.push(record.sessionId);
|
|
18131
18153
|
delivery.steps.push({ step: "resume", at: record.startedAt });
|
|
@@ -18141,11 +18163,6 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
|
|
|
18141
18163
|
const inherited = readAsks(prev.sessionId);
|
|
18142
18164
|
if (inherited.asks.length || inherited.refines.length) writeAsks(sessionId, inherited);
|
|
18143
18165
|
clearAsks(prev.sessionId);
|
|
18144
|
-
try {
|
|
18145
|
-
fs63.unlinkSync(prev.logPath);
|
|
18146
|
-
fs63.rmSync(eventsPathOf(prev.sessionId), { force: true });
|
|
18147
|
-
} catch {
|
|
18148
|
-
}
|
|
18149
18166
|
if (retry2 && prev.pictures?.length) {
|
|
18150
18167
|
record.pictures = moveRunPictures(prev.sessionId, sessionId, prev.pictures);
|
|
18151
18168
|
patch(sessionId, (r2) => {
|
|
@@ -18166,8 +18183,8 @@ function forgetRun(sessionId) {
|
|
|
18166
18183
|
if (!gone) return;
|
|
18167
18184
|
clearAsks(sessionId);
|
|
18168
18185
|
try {
|
|
18169
|
-
|
|
18170
|
-
|
|
18186
|
+
fs64.unlinkSync(gone.logPath);
|
|
18187
|
+
fs64.rmSync(eventsPathOf(gone.sessionId), { force: true });
|
|
18171
18188
|
} catch {
|
|
18172
18189
|
}
|
|
18173
18190
|
}
|
|
@@ -18196,14 +18213,14 @@ function noteSpecRefusals(sessionId, refused) {
|
|
|
18196
18213
|
}
|
|
18197
18214
|
function clearAsks(sessionId) {
|
|
18198
18215
|
try {
|
|
18199
|
-
|
|
18216
|
+
fs64.unlinkSync(asksPathOf(sessionId));
|
|
18200
18217
|
} catch {
|
|
18201
18218
|
}
|
|
18202
18219
|
}
|
|
18203
18220
|
function readAsks(sessionId) {
|
|
18204
18221
|
let data;
|
|
18205
18222
|
try {
|
|
18206
|
-
data = JSON.parse(
|
|
18223
|
+
data = JSON.parse(fs64.readFileSync(asksPathOf(sessionId), "utf8"));
|
|
18207
18224
|
} catch {
|
|
18208
18225
|
return { asks: [], refines: [], refused: [] };
|
|
18209
18226
|
}
|
|
@@ -18230,10 +18247,10 @@ function readAsks(sessionId) {
|
|
|
18230
18247
|
return { asks: asks.filter((a2) => !discarded.has(a2.cardId)), refines: refines.filter((a2) => !discarded.has(a2.cardId)), refused };
|
|
18231
18248
|
}
|
|
18232
18249
|
function writeAsks(sessionId, file2) {
|
|
18233
|
-
|
|
18250
|
+
fs64.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
18234
18251
|
const tmp = `${asksPathOf(sessionId)}.tmp`;
|
|
18235
|
-
|
|
18236
|
-
|
|
18252
|
+
fs64.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n");
|
|
18253
|
+
fs64.renameSync(tmp, asksPathOf(sessionId));
|
|
18237
18254
|
}
|
|
18238
18255
|
function markSpawned(sessionId, pid) {
|
|
18239
18256
|
patch(sessionId, (r2) => {
|
|
@@ -18358,18 +18375,19 @@ async function resumeDelivery(id) {
|
|
|
18358
18375
|
const put = resumeRecord(id, execution);
|
|
18359
18376
|
if (!put.ok) return put;
|
|
18360
18377
|
const delivery = put.delivery;
|
|
18378
|
+
if (delivery.status === "finished") return { ok: true, deliveryId: delivery.deliveryId, landed: true };
|
|
18361
18379
|
const carryOn = carryOnFrom(delivery.deliveryId);
|
|
18362
18380
|
if (delivery.cardId !== null) await setCardStatus(delivery.cardId, "implementing");
|
|
18363
18381
|
syncAudit(delivery.deliveryId);
|
|
18364
18382
|
return { ok: true, deliveryId: delivery.deliveryId, carryOn };
|
|
18365
18383
|
}
|
|
18366
18384
|
function writeSpec(spec) {
|
|
18367
|
-
|
|
18368
|
-
|
|
18385
|
+
fs64.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
18386
|
+
fs64.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
|
|
18369
18387
|
}
|
|
18370
18388
|
function readSpec(sessionId) {
|
|
18371
18389
|
try {
|
|
18372
|
-
const spec = JSON.parse(
|
|
18390
|
+
const spec = JSON.parse(fs64.readFileSync(specPathOf(sessionId), "utf8"));
|
|
18373
18391
|
return spec && Array.isArray(spec.plan?.argv) ? spec : null;
|
|
18374
18392
|
} catch {
|
|
18375
18393
|
return null;
|
|
@@ -18377,28 +18395,28 @@ function readSpec(sessionId) {
|
|
|
18377
18395
|
}
|
|
18378
18396
|
function dropSpec(sessionId) {
|
|
18379
18397
|
try {
|
|
18380
|
-
|
|
18398
|
+
fs64.unlinkSync(specPathOf(sessionId));
|
|
18381
18399
|
} catch {
|
|
18382
18400
|
}
|
|
18383
18401
|
}
|
|
18384
18402
|
async function acquireIndexLock(giveUp) {
|
|
18385
18403
|
const until = Date.now() + INDEX_WAIT_MS;
|
|
18386
|
-
const holder =
|
|
18404
|
+
const holder = path66.join(INDEX_LOCK2, "holder");
|
|
18387
18405
|
for (; ; ) {
|
|
18388
18406
|
if (giveUp()) return null;
|
|
18389
18407
|
try {
|
|
18390
|
-
|
|
18391
|
-
|
|
18392
|
-
return () =>
|
|
18408
|
+
fs64.mkdirSync(INDEX_LOCK2, { recursive: false });
|
|
18409
|
+
fs64.writeFileSync(holder, String(process.pid));
|
|
18410
|
+
return () => fs64.rmSync(INDEX_LOCK2, { recursive: true, force: true });
|
|
18393
18411
|
} catch (err) {
|
|
18394
18412
|
const code = err.code;
|
|
18395
18413
|
if (code === "ENOENT") {
|
|
18396
|
-
|
|
18414
|
+
fs64.mkdirSync(path66.dirname(INDEX_LOCK2), { recursive: true });
|
|
18397
18415
|
continue;
|
|
18398
18416
|
}
|
|
18399
18417
|
if (code !== "EEXIST") throw err;
|
|
18400
18418
|
if (!pidAlive(Number(readHolder(holder)))) {
|
|
18401
|
-
|
|
18419
|
+
fs64.rmSync(INDEX_LOCK2, { recursive: true, force: true });
|
|
18402
18420
|
continue;
|
|
18403
18421
|
}
|
|
18404
18422
|
if (Date.now() > until) return null;
|
|
@@ -18408,7 +18426,7 @@ async function acquireIndexLock(giveUp) {
|
|
|
18408
18426
|
}
|
|
18409
18427
|
function readHolder(file2) {
|
|
18410
18428
|
try {
|
|
18411
|
-
return
|
|
18429
|
+
return fs64.readFileSync(file2, "utf8").trim();
|
|
18412
18430
|
} catch {
|
|
18413
18431
|
return String(process.pid);
|
|
18414
18432
|
}
|
|
@@ -18432,6 +18450,7 @@ var init_sessions = __esm({
|
|
|
18432
18450
|
init_deliveries();
|
|
18433
18451
|
init_flows();
|
|
18434
18452
|
init_commit_mode();
|
|
18453
|
+
init_own_cost();
|
|
18435
18454
|
init_log();
|
|
18436
18455
|
init_resolve();
|
|
18437
18456
|
init_pictures();
|
|
@@ -18493,8 +18512,8 @@ var init_sessions = __esm({
|
|
|
18493
18512
|
implement: "implementing",
|
|
18494
18513
|
hook: "implementing"
|
|
18495
18514
|
};
|
|
18496
|
-
specPathOf = (sessionId) =>
|
|
18497
|
-
asksPathOf = (sessionId) =>
|
|
18515
|
+
specPathOf = (sessionId) => path66.join(SESSIONS_DIR, `${sessionId}.plan.json`);
|
|
18516
|
+
asksPathOf = (sessionId) => path66.join(SESSIONS_DIR, `${sessionId}.asks.json`);
|
|
18498
18517
|
carriesSession = (r2) => !!(r2.resumedFrom || r2.continues && !r2.continues.fork);
|
|
18499
18518
|
canPickUp = (r2) => r2.status === "error" || r2.status === "interrupted" || r2.status === "stopped";
|
|
18500
18519
|
neverStarted = (r2) => r2.unspawned === true || !!r2.errorWhy?.some((why2) => why2.kind === "notInstalled");
|
|
@@ -18521,8 +18540,8 @@ var init_sessions = __esm({
|
|
|
18521
18540
|
});
|
|
18522
18541
|
|
|
18523
18542
|
// src/lib/card-sources.ts
|
|
18524
|
-
import
|
|
18525
|
-
import
|
|
18543
|
+
import fs65 from "node:fs";
|
|
18544
|
+
import path67 from "node:path";
|
|
18526
18545
|
function planById(id) {
|
|
18527
18546
|
const found2 = readPlan(`plans/${id}-.md`);
|
|
18528
18547
|
return found2?.text.trim() ? found2 : null;
|
|
@@ -18532,8 +18551,8 @@ function cardLink(id) {
|
|
|
18532
18551
|
const found2 = open3 ?? locateArchived(id);
|
|
18533
18552
|
if (!found2) return null;
|
|
18534
18553
|
try {
|
|
18535
|
-
const file2 = found2.kind === "group" ?
|
|
18536
|
-
const title = parseFrontmatter(
|
|
18554
|
+
const file2 = found2.kind === "group" ? path67.join(found2.target, "root.md") : found2.target;
|
|
18555
|
+
const title = parseFrontmatter(fs65.readFileSync(file2, "utf8")).meta?.title ?? "";
|
|
18537
18556
|
return { kind: "card", ref: String(id), title, ...open3 ? {} : { archived: true } };
|
|
18538
18557
|
} catch {
|
|
18539
18558
|
return null;
|
|
@@ -18558,7 +18577,7 @@ function link(ref, items) {
|
|
|
18558
18577
|
if (ref.kind === "plan") return planLink(ref.id);
|
|
18559
18578
|
if (ref.kind === "card") return cardLink(ref.id);
|
|
18560
18579
|
if (ref.kind === "url") return urlLink(ref.url);
|
|
18561
|
-
const item = items().find((signal2) =>
|
|
18580
|
+
const item = items().find((signal2) => path67.basename(signal2.relPath) === ref.file);
|
|
18562
18581
|
return item ? itemLink(item) : null;
|
|
18563
18582
|
}
|
|
18564
18583
|
function cardSources(meta, body) {
|
|
@@ -18599,12 +18618,12 @@ var init_card_sources = __esm({
|
|
|
18599
18618
|
});
|
|
18600
18619
|
|
|
18601
18620
|
// src/lib/view/read.ts
|
|
18602
|
-
import
|
|
18603
|
-
import
|
|
18621
|
+
import fs66 from "node:fs";
|
|
18622
|
+
import path68 from "node:path";
|
|
18604
18623
|
function readCard(file2, relFromTodo) {
|
|
18605
|
-
const id = idPrefix(
|
|
18624
|
+
const id = idPrefix(path68.basename(relFromTodo));
|
|
18606
18625
|
if (id === null) {
|
|
18607
|
-
const parts = relFromTodo.split(
|
|
18626
|
+
const parts = relFromTodo.split(path68.sep);
|
|
18608
18627
|
const folderId = idPrefix(parts[parts.length - 2] || "");
|
|
18609
18628
|
if (folderId === null) return null;
|
|
18610
18629
|
return buildCard(folderId, file2, relFromTodo);
|
|
@@ -18612,10 +18631,10 @@ function readCard(file2, relFromTodo) {
|
|
|
18612
18631
|
return buildCard(id, file2, relFromTodo);
|
|
18613
18632
|
}
|
|
18614
18633
|
function buildCard(id, file2, relFromTodo) {
|
|
18615
|
-
const text5 =
|
|
18634
|
+
const text5 = fs66.readFileSync(file2, "utf8");
|
|
18616
18635
|
const { meta, body } = parseFrontmatter(text5);
|
|
18617
18636
|
if (!meta) return null;
|
|
18618
|
-
const relPath = relFromTodo.split(
|
|
18637
|
+
const relPath = relFromTodo.split(path68.sep).join("/");
|
|
18619
18638
|
const flow = studioFor(meta.studio);
|
|
18620
18639
|
const plan = !!meta.studio && archivesOnApproval(flow);
|
|
18621
18640
|
const stages = cardStages(meta, flow).length;
|
|
@@ -18624,7 +18643,7 @@ function buildCard(id, file2, relFromTodo) {
|
|
|
18624
18643
|
// Derived from the file exactly as it is on disk (lib/board/revision.ts), so a card
|
|
18625
18644
|
// read here and a card read by the contract agree on what version this is.
|
|
18626
18645
|
revision: revisionOf(text5),
|
|
18627
|
-
updatedAt:
|
|
18646
|
+
updatedAt: fs66.statSync(file2).mtime.toISOString(),
|
|
18628
18647
|
relPath,
|
|
18629
18648
|
title: meta.title,
|
|
18630
18649
|
priority: meta.priority,
|
|
@@ -18645,22 +18664,22 @@ function buildCard(id, file2, relFromTodo) {
|
|
|
18645
18664
|
};
|
|
18646
18665
|
}
|
|
18647
18666
|
function readGroup2(folderName) {
|
|
18648
|
-
const groupDir =
|
|
18649
|
-
const rootFile =
|
|
18650
|
-
if (!
|
|
18651
|
-
const root2 = readCard(rootFile,
|
|
18667
|
+
const groupDir = path68.join(TODO, folderName);
|
|
18668
|
+
const rootFile = path68.join(groupDir, "root.md");
|
|
18669
|
+
if (!fs66.existsSync(rootFile)) return null;
|
|
18670
|
+
const root2 = readCard(rootFile, path68.join(folderName, "root.md"));
|
|
18652
18671
|
if (!root2) return null;
|
|
18653
18672
|
root2.isGroup = true;
|
|
18654
18673
|
const { total, resolved: resolved2 } = subtaskLines(root2.body);
|
|
18655
18674
|
root2.subtaskLines = { total, resolved: resolved2 };
|
|
18656
18675
|
const subCards = [];
|
|
18657
18676
|
const recurse = (dir, relDir) => {
|
|
18658
|
-
for (const entry of
|
|
18659
|
-
const childRel =
|
|
18677
|
+
for (const entry of fs66.readdirSync(dir, { withFileTypes: true })) {
|
|
18678
|
+
const childRel = path68.join(relDir, entry.name);
|
|
18660
18679
|
if (entry.isDirectory()) {
|
|
18661
|
-
recurse(
|
|
18680
|
+
recurse(path68.join(dir, entry.name), childRel);
|
|
18662
18681
|
} else if (entry.name.endsWith(".md") && entry.name !== "README.md" && entry.name !== "root.md") {
|
|
18663
|
-
const c2 = readCard(
|
|
18682
|
+
const c2 = readCard(path68.join(dir, entry.name), childRel);
|
|
18664
18683
|
if (c2) {
|
|
18665
18684
|
c2.parent = { id: root2.id, title: root2.title };
|
|
18666
18685
|
subCards.push(c2);
|
|
@@ -18681,12 +18700,12 @@ function readGroup2(folderName) {
|
|
|
18681
18700
|
return { root: root2, subCards };
|
|
18682
18701
|
}
|
|
18683
18702
|
function standaloneCards(dirRel) {
|
|
18684
|
-
const dir = dirRel ?
|
|
18685
|
-
if (!
|
|
18703
|
+
const dir = dirRel ? path68.join(TODO, dirRel) : TODO;
|
|
18704
|
+
if (!fs66.existsSync(dir)) return [];
|
|
18686
18705
|
const cards = [];
|
|
18687
|
-
for (const entry of
|
|
18706
|
+
for (const entry of fs66.readdirSync(dir, { withFileTypes: true })) {
|
|
18688
18707
|
if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
|
|
18689
|
-
const c2 = readCard(
|
|
18708
|
+
const c2 = readCard(path68.join(dir, entry.name), path68.join(dirRel, entry.name));
|
|
18690
18709
|
if (c2) cards.push(c2);
|
|
18691
18710
|
}
|
|
18692
18711
|
}
|
|
@@ -18698,7 +18717,7 @@ function collectCards() {
|
|
|
18698
18717
|
const top = standaloneCards("");
|
|
18699
18718
|
board2.push(...top);
|
|
18700
18719
|
every.push(...top);
|
|
18701
|
-
for (const entry of
|
|
18720
|
+
for (const entry of fs66.readdirSync(TODO, { withFileTypes: true })) {
|
|
18702
18721
|
if (!entry.isDirectory()) continue;
|
|
18703
18722
|
if (isGroupFolder(entry.name)) {
|
|
18704
18723
|
const g3 = readGroup2(entry.name);
|
|
@@ -18730,7 +18749,7 @@ function findCard(id) {
|
|
|
18730
18749
|
}
|
|
18731
18750
|
function attachSources(card) {
|
|
18732
18751
|
try {
|
|
18733
|
-
const { meta, body } = parseFrontmatter(
|
|
18752
|
+
const { meta, body } = parseFrontmatter(fs66.readFileSync(path68.join(TODO, card.relPath), "utf8"));
|
|
18734
18753
|
const sources2 = meta ? cardSources(meta, body) : [];
|
|
18735
18754
|
if (sources2.length) card.sources = sources2;
|
|
18736
18755
|
} catch {
|
|
@@ -18813,7 +18832,7 @@ function attachDiscard(card, active2) {
|
|
|
18813
18832
|
resumable: holder.status !== "active" && isResumable(holder)
|
|
18814
18833
|
};
|
|
18815
18834
|
}
|
|
18816
|
-
function
|
|
18835
|
+
function allCards() {
|
|
18817
18836
|
return collectCards().every;
|
|
18818
18837
|
}
|
|
18819
18838
|
var init_read = __esm({
|
|
@@ -18834,25 +18853,25 @@ var init_read = __esm({
|
|
|
18834
18853
|
});
|
|
18835
18854
|
|
|
18836
18855
|
// src/lib/agent/preview-progress.ts
|
|
18837
|
-
import
|
|
18838
|
-
import
|
|
18856
|
+
import fs67 from "node:fs";
|
|
18857
|
+
import path69 from "node:path";
|
|
18839
18858
|
import { createHash as createHash7, randomUUID as randomUUID5 } from "node:crypto";
|
|
18840
18859
|
function readPreviewProgress(id) {
|
|
18841
18860
|
try {
|
|
18842
|
-
return JSON.parse(
|
|
18861
|
+
return JSON.parse(fs67.readFileSync(file(id), "utf8"));
|
|
18843
18862
|
} catch (error) {
|
|
18844
18863
|
if (error.code === "ENOENT") return {};
|
|
18845
18864
|
throw error;
|
|
18846
18865
|
}
|
|
18847
18866
|
}
|
|
18848
18867
|
function updatePreviewProgress(id, change2) {
|
|
18849
|
-
|
|
18868
|
+
fs67.mkdirSync(path69.dirname(file(id)), { recursive: true });
|
|
18850
18869
|
return withLock(`${file(id)}.lock`, "updating preview progress", () => {
|
|
18851
18870
|
const all2 = readPreviewProgress(id);
|
|
18852
18871
|
const result = change2(all2);
|
|
18853
18872
|
const temp = `${file(id)}.${process.pid}.tmp`;
|
|
18854
|
-
|
|
18855
|
-
|
|
18873
|
+
fs67.writeFileSync(temp, JSON.stringify(all2) + "\n");
|
|
18874
|
+
fs67.renameSync(temp, file(id));
|
|
18856
18875
|
return result;
|
|
18857
18876
|
});
|
|
18858
18877
|
}
|
|
@@ -18862,7 +18881,7 @@ function freezePreviewProgress(id, name) {
|
|
|
18862
18881
|
const agent = findSpecAgent(name);
|
|
18863
18882
|
if (!agent) return null;
|
|
18864
18883
|
const studio = studioFiles(cardStudioId(id)) ?? {};
|
|
18865
|
-
const protocol = Object.entries(studio).some(([
|
|
18884
|
+
const protocol = Object.entries(studio).some(([path91, text5]) => path91.endsWith("/AGENT.md") && /^[ \t]+stages:/m.test(text5.split(/\r?\n---/)[0]));
|
|
18866
18885
|
if (!agent.stages && !protocol) return null;
|
|
18867
18886
|
const definitions = agent.stages ?? [{ id: "preview", title: { en: "Preview", zh: "\u6210\u679C" }, instructions: "preview.md" }];
|
|
18868
18887
|
const files = Object.fromEntries(agent.files.map((file2) => [file2, agent.file(file2)]).filter((entry) => entry[1] !== null));
|
|
@@ -18876,33 +18895,66 @@ function freezePreviewProgress(id, name) {
|
|
|
18876
18895
|
function previewStagePrompt(id, name, command) {
|
|
18877
18896
|
const progress = freezePreviewProgress(id, name);
|
|
18878
18897
|
if (!progress) return "";
|
|
18879
|
-
if (progress.revisionBase) return `
|
|
18880
|
-
if (!progress.stages.length) return `
|
|
18898
|
+
if (progress.revisionBase) return `Revise from the first affected stage: ${command} raw previews ${name} ${id} --revise-from <stage-id>. Saved stages: ${JSON.stringify(progress.revisionBase.map(({ id: id2, title, status, artifact }) => ({ id: id2, title, status, artifact })))}`;
|
|
18899
|
+
if (!progress.stages.length) return `Stages:
|
|
18881
18900
|
${JSON.stringify(progress.definitions)}
|
|
18882
|
-
|
|
18901
|
+
Select with: ${command} raw previews ${name} ${id} --stages <id,...>.`;
|
|
18883
18902
|
const current = progress.stages.find((stage) => stage.id === progress.currentStageId);
|
|
18884
|
-
if (current
|
|
18903
|
+
if (!current) return `Saved stages: ${JSON.stringify(progress.stages)}
|
|
18904
|
+
Select with: ${command} raw previews ${name} ${id} --stages <id,...>.`;
|
|
18905
|
+
if (current.status === "awaiting_confirmation" || previewReady(progress)) return "The submitted preview is awaiting review.";
|
|
18885
18906
|
return [
|
|
18886
18907
|
`Selected stages: ${progress.stages.map((stage) => stage.id).join(", ")}. Current stage: ${current.id}.`,
|
|
18887
|
-
progress.files[current.instructions],
|
|
18908
|
+
progress.files[current.instructions] === progress.body ? "" : progress.files[current.instructions],
|
|
18888
18909
|
...name === "ui-designer" ? [current.id === "copywriting" ? legacyPreviewMemory("copywriting") : current.id === "illustration" ? legacyPreviewMemory("illustrator") : ""] : [],
|
|
18889
18910
|
...progress.stages.filter((stage) => stage.status === "confirmed").map((stage) => `Confirmed ${stage.id} v${stage.version}:
|
|
18890
18911
|
${stage.artifact?.body ?? ""}`),
|
|
18891
|
-
`
|
|
18912
|
+
`Submit with: ${command} raw previews ${name} ${id} --submit --stage ${current.id}.`
|
|
18892
18913
|
].join("\n\n");
|
|
18893
18914
|
}
|
|
18915
|
+
function previewOwner(id, name, inside2 = insideRun()) {
|
|
18916
|
+
const found2 = locate(id);
|
|
18917
|
+
if (!found2) throw Error("The task is no longer open.");
|
|
18918
|
+
const card = found2.kind === "group" ? path69.join(found2.target, "root.md") : found2.target;
|
|
18919
|
+
const { meta } = parseFrontmatter(fs67.readFileSync(card, "utf8"));
|
|
18920
|
+
if (!specAgentAssigned(name, meta?.studio) || !meta?.previews?.some((agent) => canonicalSpecAgent(agent) === name)) throw Error("Choose this preview agent on the task first.");
|
|
18921
|
+
if (inside2) {
|
|
18922
|
+
const run4 = readRuns().find((run5) => run5.sessionId === inside2);
|
|
18923
|
+
if (!run4 || run4.status !== "running" || run4.cardId !== id) throw Error("Only the active task session can prepare its selected previews.");
|
|
18924
|
+
return `run:${inside2}`;
|
|
18925
|
+
}
|
|
18926
|
+
const execution = executionOf();
|
|
18927
|
+
if (execution) return `job:${execution.job}`;
|
|
18928
|
+
return process.env[STOP_ENV] || Object.values(SESSION_VARS).map((key) => process.env[key]).find(Boolean) || "external";
|
|
18929
|
+
}
|
|
18930
|
+
function readContext(file2) {
|
|
18931
|
+
try {
|
|
18932
|
+
return JSON.parse(fs67.readFileSync(file2, "utf8"));
|
|
18933
|
+
} catch (error) {
|
|
18934
|
+
if (error.code === "ENOENT") return void 0;
|
|
18935
|
+
throw error;
|
|
18936
|
+
}
|
|
18937
|
+
}
|
|
18938
|
+
function writeJson2(file2, value) {
|
|
18939
|
+
fs67.mkdirSync(path69.dirname(file2), { recursive: true });
|
|
18940
|
+
const temp = `${file2}.${process.pid}.tmp`;
|
|
18941
|
+
fs67.writeFileSync(temp, JSON.stringify(value) + "\n");
|
|
18942
|
+
fs67.renameSync(temp, file2);
|
|
18943
|
+
}
|
|
18894
18944
|
function previewRun(id, name) {
|
|
18895
|
-
const
|
|
18896
|
-
if (!
|
|
18897
|
-
|
|
18945
|
+
const context = readContext(contextFile(id, name, previewOwner(id, name)));
|
|
18946
|
+
if (!context?.active) throw new PreviewContextMissing("This preview has no saved execution context.");
|
|
18947
|
+
const progress = readPreviewProgress(id)[name];
|
|
18948
|
+
if (progress?.execution && progress.execution !== context.sessionId && !progress.execution.endsWith(`:${context.sessionId}`)) throw Error("This execution is outdated. Reload the task.");
|
|
18949
|
+
return context;
|
|
18898
18950
|
}
|
|
18899
18951
|
function selectLocalPreview(id, name, ids) {
|
|
18900
18952
|
const run4 = previewRun(id, name);
|
|
18901
|
-
freezePreviewProgress(id, name);
|
|
18902
18953
|
return updatePreviewProgress(id, (all2) => {
|
|
18903
18954
|
const progress = all2[name];
|
|
18904
18955
|
if (!progress) throw Error("This agent has no staged preview.");
|
|
18905
|
-
if (progress.
|
|
18956
|
+
if (progress.execution !== run4.sessionId) throw Error("This execution is outdated. Reload the task.");
|
|
18957
|
+
if (progress.stages.length && JSON.stringify(progress.stages.map((stage) => stage.id)) === JSON.stringify(ids)) return { progress, baseline: readPreviewBaseline(id, name, run4.sessionId) };
|
|
18906
18958
|
selectPreviewStages(progress, ids);
|
|
18907
18959
|
const baseline = previewBaseline(progress, progress.currentStageId, run4.sessionId);
|
|
18908
18960
|
return { progress, baseline };
|
|
@@ -18911,7 +18963,7 @@ function selectLocalPreview(id, name, ids) {
|
|
|
18911
18963
|
function previewSection(body, name) {
|
|
18912
18964
|
const lines = body.split("\n");
|
|
18913
18965
|
const start = lines.findIndex((line) => specHeadingRe(name).test(line));
|
|
18914
|
-
if (start < 0)
|
|
18966
|
+
if (start < 0) return "";
|
|
18915
18967
|
const end2 = lines.findIndex((line, index) => index > start && (/^## /.test(line) || line.trim() === "<!-- agent -->"));
|
|
18916
18968
|
return lines.slice(start + 1, end2 < 0 ? void 0 : end2).join("\n").trim();
|
|
18917
18969
|
}
|
|
@@ -18920,43 +18972,53 @@ function submitLocalPreview(id, name, stage, baseline) {
|
|
|
18920
18972
|
const card = findCard(id);
|
|
18921
18973
|
if (!card) throw Error("The task is no longer open.");
|
|
18922
18974
|
const body = previewSection(card.body, name);
|
|
18923
|
-
const problems = validatePreviewFiles(path68.join(TODO, card.relPath), id, body);
|
|
18924
|
-
if (problems.length) throw Error(problems.map((problem) => problem.message).join("\n"));
|
|
18925
18975
|
const snapshot = randomUUID5();
|
|
18926
|
-
const source2 =
|
|
18927
|
-
const dest =
|
|
18928
|
-
if (
|
|
18976
|
+
const source2 = path69.join(ASSETS, String(id));
|
|
18977
|
+
const dest = path69.join(BOARD_STATE, "previews", "assets", String(id), snapshot);
|
|
18978
|
+
if (fs67.existsSync(source2) && fs67.lstatSync(source2).isSymbolicLink()) throw Error("Preview assets must stay inside this task\u2019s asset folder.");
|
|
18979
|
+
if (fs67.existsSync(source2)) fs67.cpSync(source2, dest, { recursive: true, dereference: true, filter: (file2) => {
|
|
18980
|
+
const real2 = fs67.realpathSync(file2);
|
|
18981
|
+
if (real2 !== fs67.realpathSync(source2) && !real2.startsWith(fs67.realpathSync(source2) + path69.sep)) throw Error("Preview assets must stay inside this task\u2019s asset folder.");
|
|
18982
|
+
return true;
|
|
18983
|
+
} });
|
|
18929
18984
|
return updatePreviewProgress(id, (all2) => {
|
|
18930
18985
|
const progress = all2[name];
|
|
18931
18986
|
if (!progress) throw Error("Select the stages first.");
|
|
18932
|
-
const base = baseline ??
|
|
18987
|
+
const base = baseline ?? readPreviewBaseline(id, name, run4.sessionId);
|
|
18933
18988
|
if (base.stageId !== stage) throw Error("Wrong stage.");
|
|
18934
18989
|
return submitPreviewStage(progress, base, body, { folder: dest });
|
|
18935
18990
|
});
|
|
18936
18991
|
}
|
|
18937
|
-
function savePreviewBaseline(run4, baseline) {
|
|
18938
|
-
|
|
18939
|
-
fs66.writeFileSync(baselineFile(run4), JSON.stringify(baseline) + "\n");
|
|
18992
|
+
function savePreviewBaseline(id, name, run4, baseline) {
|
|
18993
|
+
writeJson2(baselineFile(id, name, run4), baseline);
|
|
18940
18994
|
}
|
|
18941
|
-
function readPreviewBaseline(run4) {
|
|
18942
|
-
return JSON.parse(
|
|
18995
|
+
function readPreviewBaseline(id, name, run4) {
|
|
18996
|
+
return JSON.parse(fs67.readFileSync(baselineFile(id, name, run4), "utf8"));
|
|
18943
18997
|
}
|
|
18944
|
-
async function activatePreviewRun(id, name, run4) {
|
|
18998
|
+
async function activatePreviewRun(id, name, run4, request2 = "") {
|
|
18999
|
+
const owner = previewOwner(id, name, run4 ?? insideRun());
|
|
19000
|
+
const file2 = contextFile(id, name, owner);
|
|
19001
|
+
const held4 = readContext(file2);
|
|
19002
|
+
const context = held4 && held4.request === request2 ? held4 : { sessionId: run4 ?? randomUUID5(), request: request2 };
|
|
19003
|
+
writeJson2(file2, context);
|
|
19004
|
+
run4 = context.sessionId;
|
|
18945
19005
|
const { previewBridge: previewBridge2 } = await Promise.resolve().then(() => (init_preview(), preview_exports));
|
|
18946
|
-
const remote2 = await previewBridge2(name, "start", { run: run4 });
|
|
18947
|
-
if (remote2
|
|
18948
|
-
updatePreviewProgress(id, (all2) => {
|
|
19006
|
+
const remote2 = await previewBridge2(name, "start", { run: run4, cardId: id });
|
|
19007
|
+
if (remote2) {
|
|
19008
|
+
if (remote2.progress) updatePreviewProgress(id, (all2) => {
|
|
18949
19009
|
all2[name] = remote2.progress;
|
|
18950
19010
|
});
|
|
18951
|
-
if (remote2.baseline) savePreviewBaseline(run4, remote2.baseline);
|
|
19011
|
+
if (remote2.baseline) savePreviewBaseline(id, name, run4, remote2.baseline);
|
|
18952
19012
|
} else {
|
|
18953
19013
|
freezePreviewProgress(id, name);
|
|
18954
19014
|
updatePreviewProgress(id, (all2) => {
|
|
18955
19015
|
const progress = all2[name];
|
|
18956
|
-
if (progress
|
|
18957
|
-
if (progress
|
|
19016
|
+
if (!progress) return;
|
|
19017
|
+
if (progress.currentStageId && !progress.revisionBase) savePreviewBaseline(id, name, run4, previewBaseline(progress, progress.currentStageId, run4));
|
|
19018
|
+
else progress.execution = run4;
|
|
18958
19019
|
});
|
|
18959
19020
|
}
|
|
19021
|
+
writeJson2(file2, { ...context, active: true });
|
|
18960
19022
|
}
|
|
18961
19023
|
function frozenPreviewFile(agent, relative) {
|
|
18962
19024
|
const run4 = readRuns().find((run5) => run5.sessionId === insideRun());
|
|
@@ -18966,13 +19028,13 @@ function frozenPreviewFile(agent, relative) {
|
|
|
18966
19028
|
function legacyPreviewMemory(agent) {
|
|
18967
19029
|
const folder = agentMemoryDir(agent);
|
|
18968
19030
|
try {
|
|
18969
|
-
return
|
|
18970
|
-
${
|
|
19031
|
+
return fs67.readdirSync(folder).filter((name) => name.endsWith(".md")).map((name) => `Existing ${agent} preferences (${name}):
|
|
19032
|
+
${fs67.readFileSync(path69.join(folder, name), "utf8")}`).join("\n\n");
|
|
18971
19033
|
} catch {
|
|
18972
19034
|
return "";
|
|
18973
19035
|
}
|
|
18974
19036
|
}
|
|
18975
|
-
var file, baselineFile;
|
|
19037
|
+
var file, contextFile, PreviewContextMissing, baselineFile;
|
|
18976
19038
|
var init_preview_progress = __esm({
|
|
18977
19039
|
"src/lib/agent/preview-progress.ts"() {
|
|
18978
19040
|
"use strict";
|
|
@@ -18980,21 +19042,27 @@ var init_preview_progress = __esm({
|
|
|
18980
19042
|
init_memory();
|
|
18981
19043
|
init_lock();
|
|
18982
19044
|
init_agents();
|
|
19045
|
+
init_spec_agent_names();
|
|
18983
19046
|
init_read();
|
|
18984
19047
|
init_studios();
|
|
18985
19048
|
init_studio_shared();
|
|
18986
19049
|
init_store();
|
|
18987
19050
|
init_env();
|
|
18988
|
-
|
|
19051
|
+
init_cards();
|
|
19052
|
+
init_frontmatter();
|
|
19053
|
+
init_execution();
|
|
18989
19054
|
init_preview_stages();
|
|
18990
|
-
file = (id) =>
|
|
18991
|
-
|
|
19055
|
+
file = (id) => path69.join(BOARD_STATE, "previews", `${id}.json`);
|
|
19056
|
+
contextFile = (id, name, owner) => path69.join(BOARD_STATE, "previews", "contexts", String(id), name, `${createHash7("sha256").update(owner).digest("hex")}.json`);
|
|
19057
|
+
PreviewContextMissing = class extends Error {
|
|
19058
|
+
};
|
|
19059
|
+
baselineFile = (id, name, run4) => path69.join(BOARD_STATE, "previews", "runs", String(id), name, `${run4}.json`);
|
|
18992
19060
|
}
|
|
18993
19061
|
});
|
|
18994
19062
|
|
|
18995
19063
|
// src/lib/agent/approve.ts
|
|
18996
|
-
import
|
|
18997
|
-
import
|
|
19064
|
+
import fs68 from "node:fs";
|
|
19065
|
+
import path70 from "node:path";
|
|
18998
19066
|
function approvalRequest(req) {
|
|
18999
19067
|
const id = req.id;
|
|
19000
19068
|
const card = id === void 0 ? null : findCard(id);
|
|
@@ -19012,12 +19080,12 @@ function advancePhase(id) {
|
|
|
19012
19080
|
const card = findCard(id);
|
|
19013
19081
|
const found2 = locate(id);
|
|
19014
19082
|
if (!card || !found2 || !awaitingApproval(card)) return { error: `#${id} is no longer waiting on approval.` };
|
|
19015
|
-
const file2 = found2.kind === "group" ?
|
|
19016
|
-
const { meta, body } = parseFrontmatter(
|
|
19083
|
+
const file2 = found2.kind === "group" ? path70.join(found2.target, "root.md") : found2.target;
|
|
19084
|
+
const { meta, body } = parseFrontmatter(fs68.readFileSync(file2, "utf8"));
|
|
19017
19085
|
if (!meta) return { error: `#${id} has no frontmatter` };
|
|
19018
19086
|
meta.phase = card.stage + 1;
|
|
19019
19087
|
meta.status = "todo";
|
|
19020
|
-
|
|
19088
|
+
fs68.writeFileSync(file2, serializeFrontmatter(meta) + "\n" + body);
|
|
19021
19089
|
return null;
|
|
19022
19090
|
}
|
|
19023
19091
|
var init_approve = __esm({
|
|
@@ -19060,8 +19128,7 @@ function studioRefusal(req) {
|
|
|
19060
19128
|
if (archivesOnApproval(flow) && req.action === "implement") {
|
|
19061
19129
|
return refusal("planDelivered", `#${req.id} lands nothing, so its last approval archives it rather than building it.`, { card: String(req.id) });
|
|
19062
19130
|
}
|
|
19063
|
-
|
|
19064
|
-
return problem ?? null;
|
|
19131
|
+
return null;
|
|
19065
19132
|
}
|
|
19066
19133
|
async function scheduledRefusal(req) {
|
|
19067
19134
|
if (req.action !== "scheduled" || req.deliveryId || !req.studio || !req.specAgent) return null;
|
|
@@ -19260,10 +19327,10 @@ var init_avatar = __esm({
|
|
|
19260
19327
|
});
|
|
19261
19328
|
|
|
19262
19329
|
// src/lib/cloud/pro.ts
|
|
19263
|
-
import
|
|
19264
|
-
import
|
|
19330
|
+
import fs69 from "node:fs";
|
|
19331
|
+
import path71 from "node:path";
|
|
19265
19332
|
function forgetPro() {
|
|
19266
|
-
|
|
19333
|
+
fs69.rmSync(heldFile(), { force: true });
|
|
19267
19334
|
}
|
|
19268
19335
|
var FRESH_MS2, GRACE_MS, heldFile;
|
|
19269
19336
|
var init_pro = __esm({
|
|
@@ -19274,7 +19341,7 @@ var init_pro = __esm({
|
|
|
19274
19341
|
init_session();
|
|
19275
19342
|
FRESH_MS2 = 10 * 6e4;
|
|
19276
19343
|
GRACE_MS = 7 * 24 * 60 * 6e4;
|
|
19277
|
-
heldFile = () =>
|
|
19344
|
+
heldFile = () => path71.join(machineHome(), "pro.json");
|
|
19278
19345
|
}
|
|
19279
19346
|
});
|
|
19280
19347
|
|
|
@@ -19365,8 +19432,8 @@ var init_account = __esm({
|
|
|
19365
19432
|
});
|
|
19366
19433
|
|
|
19367
19434
|
// src/commands/cloud.ts
|
|
19368
|
-
import
|
|
19369
|
-
import
|
|
19435
|
+
import fs70 from "node:fs";
|
|
19436
|
+
import path72 from "node:path";
|
|
19370
19437
|
async function cmdCloud(args2, program2) {
|
|
19371
19438
|
const [sub] = args2;
|
|
19372
19439
|
if (sub === "sign-out") {
|
|
@@ -19428,10 +19495,10 @@ async function cloudImage(opts, program2) {
|
|
|
19428
19495
|
const prompt = opts.prompt.trim();
|
|
19429
19496
|
if (!prompt) usage("Missing the prompt.", line);
|
|
19430
19497
|
const references = opts.refs.map((file2) => {
|
|
19431
|
-
const type = REF_TYPES[
|
|
19498
|
+
const type = REF_TYPES[path72.extname(file2).toLowerCase()];
|
|
19432
19499
|
if (!type) usage(`--ref ${file2}: use a PNG, JPEG or WebP file.`, line);
|
|
19433
19500
|
try {
|
|
19434
|
-
return `data:${type};base64,${
|
|
19501
|
+
return `data:${type};base64,${fs70.readFileSync(file2).toString("base64")}`;
|
|
19435
19502
|
} catch (e2) {
|
|
19436
19503
|
usage(`--ref ${file2}: ${e2 instanceof Error ? e2.message : String(e2)}`, line);
|
|
19437
19504
|
}
|
|
@@ -19539,8 +19606,8 @@ async function generate(g3) {
|
|
|
19539
19606
|
refuse(g3.failed, g3.fallback);
|
|
19540
19607
|
}
|
|
19541
19608
|
const out = g3.outFor?.(res, g3.out) ?? g3.out;
|
|
19542
|
-
|
|
19543
|
-
|
|
19609
|
+
fs70.mkdirSync(path72.dirname(path72.resolve(out)), { recursive: true });
|
|
19610
|
+
fs70.writeFileSync(out, Buffer.from(await res.arrayBuffer()));
|
|
19544
19611
|
say(`${out} (${g3.label(res)})`);
|
|
19545
19612
|
return { out };
|
|
19546
19613
|
}
|
|
@@ -19588,11 +19655,11 @@ var init_cloud = __esm({
|
|
|
19588
19655
|
});
|
|
19589
19656
|
|
|
19590
19657
|
// src/commands/task.ts
|
|
19591
|
-
import
|
|
19658
|
+
import fs71 from "node:fs";
|
|
19592
19659
|
import os5 from "node:os";
|
|
19593
|
-
import
|
|
19660
|
+
import path73 from "node:path";
|
|
19594
19661
|
async function cloud(method, route2, body) {
|
|
19595
|
-
process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME ||
|
|
19662
|
+
process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME || path73.join(os5.homedir(), ".wildcrane");
|
|
19596
19663
|
const token2 = await accessToken();
|
|
19597
19664
|
if (!token2.ok) return refuse2(SAID[token2.reason].en, token2.reason.replace("-", "_"));
|
|
19598
19665
|
let response;
|
|
@@ -19622,12 +19689,12 @@ async function all(route2) {
|
|
|
19622
19689
|
return rows;
|
|
19623
19690
|
}
|
|
19624
19691
|
function linked() {
|
|
19625
|
-
for (let dir = process.cwd(); ; dir =
|
|
19626
|
-
if (
|
|
19692
|
+
for (let dir = process.cwd(); ; dir = path73.dirname(dir)) {
|
|
19693
|
+
if (fs71.existsSync(path73.join(dir, ".akb", "base.json"))) {
|
|
19627
19694
|
const link2 = linkedProject("", dir);
|
|
19628
19695
|
return link2.ok ? link2.value : null;
|
|
19629
19696
|
}
|
|
19630
|
-
if (
|
|
19697
|
+
if (path73.dirname(dir) === dir) return null;
|
|
19631
19698
|
}
|
|
19632
19699
|
}
|
|
19633
19700
|
async function project(asked) {
|
|
@@ -19771,11 +19838,11 @@ var init_task = __esm({
|
|
|
19771
19838
|
});
|
|
19772
19839
|
|
|
19773
19840
|
// src/commands/goal.ts
|
|
19774
|
-
import
|
|
19841
|
+
import fs72 from "node:fs";
|
|
19775
19842
|
function loadGoals() {
|
|
19776
19843
|
const file2 = goalsFile();
|
|
19777
19844
|
if (!file2) die("Goals exist only inside a WildCrane goal discussion.");
|
|
19778
|
-
const held4 = JSON.parse(
|
|
19845
|
+
const held4 = JSON.parse(fs72.readFileSync(file2, "utf8"));
|
|
19779
19846
|
if (held4.goals !== void 0 && held4.ideas !== void 0 && JSON.stringify(held4.goals) !== JSON.stringify(held4.ideas)) die("goals and ideas do not match.");
|
|
19780
19847
|
const goals = held4.goals ?? held4.ideas;
|
|
19781
19848
|
if (!Array.isArray(goals)) die("The goals array is missing or invalid.");
|
|
@@ -19805,7 +19872,7 @@ function splitBody2(text5) {
|
|
|
19805
19872
|
}
|
|
19806
19873
|
function readBody(bodyFile) {
|
|
19807
19874
|
if (!bodyFile) die("--body-file is required; write the goal in a writable temporary file first.");
|
|
19808
|
-
const text5 =
|
|
19875
|
+
const text5 = fs72.readFileSync(bodyFile, "utf8");
|
|
19809
19876
|
if (!text5.trim()) die("The goal must not be empty.");
|
|
19810
19877
|
return splitBody2(text5);
|
|
19811
19878
|
}
|
|
@@ -19817,7 +19884,7 @@ function named(held4, id) {
|
|
|
19817
19884
|
function cmdGoal(args2, opts) {
|
|
19818
19885
|
const sub = args2[0] ?? "";
|
|
19819
19886
|
const { file: file2, held: held4 } = loadGoals();
|
|
19820
|
-
const write2 = () =>
|
|
19887
|
+
const write2 = () => fs72.writeFileSync(file2, `${JSON.stringify({ ...held4, goals: void 0, ideas: held4.goals }, null, 2)}
|
|
19821
19888
|
`);
|
|
19822
19889
|
if (sub === "new") {
|
|
19823
19890
|
const title = opts.title?.trim();
|
|
@@ -19905,9 +19972,9 @@ var init_goal = __esm({
|
|
|
19905
19972
|
});
|
|
19906
19973
|
|
|
19907
19974
|
// src/commands/goal-cloud.ts
|
|
19908
|
-
import
|
|
19975
|
+
import fs73 from "node:fs";
|
|
19909
19976
|
import os6 from "node:os";
|
|
19910
|
-
import
|
|
19977
|
+
import path74 from "node:path";
|
|
19911
19978
|
import crypto3 from "node:crypto";
|
|
19912
19979
|
function hostSession() {
|
|
19913
19980
|
const { CLAUDE_CODE_SESSION_ID: claude, CODEX_THREAD_ID: codex, CURSOR_CONVERSATION_ID: cursor, KIMI_SESSION_ID: kimi, WILDCRANE_DISCUSSION: discussion2 } = process.env;
|
|
@@ -19936,24 +20003,24 @@ function goalsOf(d2) {
|
|
|
19936
20003
|
async function discussion() {
|
|
19937
20004
|
const session = hostSession();
|
|
19938
20005
|
if (!session) die("Goals exist only inside a WildCrane goal discussion.");
|
|
19939
|
-
const home3 = process.env.WILDCRANE_HOME ||
|
|
20006
|
+
const home3 = process.env.WILDCRANE_HOME || path74.join(os6.homedir(), ".wildcrane");
|
|
19940
20007
|
process.env.AI4KANBAN_HOME ??= home3;
|
|
19941
20008
|
if (session.host === "discussion") return request("GET", `/v1/discussions/${encodeURIComponent(session.id)}`);
|
|
19942
|
-
const machineFile2 =
|
|
20009
|
+
const machineFile2 = path74.join(home3, "machine.json");
|
|
19943
20010
|
let machine;
|
|
19944
20011
|
try {
|
|
19945
|
-
machine = JSON.parse(
|
|
20012
|
+
machine = JSON.parse(fs73.readFileSync(machineFile2, "utf8")).id;
|
|
19946
20013
|
} catch {
|
|
19947
20014
|
machine = crypto3.randomUUID();
|
|
19948
|
-
|
|
19949
|
-
|
|
20015
|
+
fs73.mkdirSync(home3, { recursive: true });
|
|
20016
|
+
fs73.writeFileSync(machineFile2, JSON.stringify({ id: machine }));
|
|
19950
20017
|
}
|
|
19951
20018
|
const held4 = await request("GET", `/v1/runner/folders?machine=${encodeURIComponent(machine)}`);
|
|
19952
|
-
const cwd =
|
|
20019
|
+
const cwd = fs73.realpathSync(process.cwd());
|
|
19953
20020
|
const folder = held4.folders.filter((f2) => {
|
|
19954
20021
|
try {
|
|
19955
|
-
const dir =
|
|
19956
|
-
return cwd === dir || cwd.startsWith(dir +
|
|
20022
|
+
const dir = fs73.realpathSync(f2.path);
|
|
20023
|
+
return cwd === dir || cwd.startsWith(dir + path74.sep);
|
|
19957
20024
|
} catch {
|
|
19958
20025
|
return false;
|
|
19959
20026
|
}
|
|
@@ -19962,16 +20029,16 @@ async function discussion() {
|
|
|
19962
20029
|
}
|
|
19963
20030
|
async function withGoalDiscussion(action, save3 = false) {
|
|
19964
20031
|
const d2 = await discussion();
|
|
19965
|
-
const dir =
|
|
19966
|
-
const file2 =
|
|
20032
|
+
const dir = fs73.mkdtempSync(path74.join(os6.tmpdir(), "akb-goals-"));
|
|
20033
|
+
const file2 = path74.join(dir, "goals.json");
|
|
19967
20034
|
const before = process.env.KANBAN_GOALS;
|
|
19968
20035
|
try {
|
|
19969
20036
|
const previous = goalsOf(d2);
|
|
19970
|
-
|
|
20037
|
+
fs73.writeFileSync(file2, JSON.stringify({ workspace: d2.workspace, studios: await studios2(d2.workspace), ideas: previous.map((g3) => ({ ...g3, task: typeof g3.task === "object" && g3.task ? g3.task.id : g3.task })) }));
|
|
19971
20038
|
process.env.KANBAN_GOALS = file2;
|
|
19972
20039
|
const result = save3 ? await quietlyAsync(async () => action()) : await action();
|
|
19973
20040
|
if (save3) {
|
|
19974
|
-
const goals = JSON.parse(
|
|
20041
|
+
const goals = JSON.parse(fs73.readFileSync(file2, "utf8")).ideas;
|
|
19975
20042
|
const saved = await request("PUT", `/v1/discussions/${d2.id}/draft`, { expectedVersion: d2.version, goals: goals.filter((g3) => !g3.dropped) });
|
|
19976
20043
|
const savedGoals = goalsOf(saved);
|
|
19977
20044
|
const fresh = goals.filter((g3) => !g3.dropped && !previous.some((p2) => p2.id === g3.id));
|
|
@@ -19990,7 +20057,7 @@ async function withGoalDiscussion(action, save3 = false) {
|
|
|
19990
20057
|
} finally {
|
|
19991
20058
|
if (before === void 0) delete process.env.KANBAN_GOALS;
|
|
19992
20059
|
else process.env.KANBAN_GOALS = before;
|
|
19993
|
-
|
|
20060
|
+
fs73.rmSync(dir, { recursive: true, force: true });
|
|
19994
20061
|
}
|
|
19995
20062
|
}
|
|
19996
20063
|
async function queryPreviews(studio, workspace2) {
|
|
@@ -21139,8 +21206,8 @@ var require_command = __commonJS({
|
|
|
21139
21206
|
"node_modules/commander/lib/command.js"(exports) {
|
|
21140
21207
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
21141
21208
|
var childProcess = __require("node:child_process");
|
|
21142
|
-
var
|
|
21143
|
-
var
|
|
21209
|
+
var path91 = __require("node:path");
|
|
21210
|
+
var fs93 = __require("node:fs");
|
|
21144
21211
|
var process2 = __require("node:process");
|
|
21145
21212
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
21146
21213
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -22121,7 +22188,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22121
22188
|
* @param {string} subcommandName
|
|
22122
22189
|
*/
|
|
22123
22190
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
22124
|
-
if (
|
|
22191
|
+
if (fs93.existsSync(executableFile)) return;
|
|
22125
22192
|
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";
|
|
22126
22193
|
const executableMissing = `'${executableFile}' does not exist
|
|
22127
22194
|
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
@@ -22139,11 +22206,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22139
22206
|
let launchWithNode = false;
|
|
22140
22207
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
22141
22208
|
function findFile(baseDir, baseName) {
|
|
22142
|
-
const localBin =
|
|
22143
|
-
if (
|
|
22144
|
-
if (sourceExt.includes(
|
|
22209
|
+
const localBin = path91.resolve(baseDir, baseName);
|
|
22210
|
+
if (fs93.existsSync(localBin)) return localBin;
|
|
22211
|
+
if (sourceExt.includes(path91.extname(baseName))) return void 0;
|
|
22145
22212
|
const foundExt = sourceExt.find(
|
|
22146
|
-
(ext) =>
|
|
22213
|
+
(ext) => fs93.existsSync(`${localBin}${ext}`)
|
|
22147
22214
|
);
|
|
22148
22215
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
22149
22216
|
return void 0;
|
|
@@ -22155,21 +22222,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22155
22222
|
if (this._scriptPath) {
|
|
22156
22223
|
let resolvedScriptPath;
|
|
22157
22224
|
try {
|
|
22158
|
-
resolvedScriptPath =
|
|
22225
|
+
resolvedScriptPath = fs93.realpathSync(this._scriptPath);
|
|
22159
22226
|
} catch {
|
|
22160
22227
|
resolvedScriptPath = this._scriptPath;
|
|
22161
22228
|
}
|
|
22162
|
-
executableDir =
|
|
22163
|
-
|
|
22229
|
+
executableDir = path91.resolve(
|
|
22230
|
+
path91.dirname(resolvedScriptPath),
|
|
22164
22231
|
executableDir
|
|
22165
22232
|
);
|
|
22166
22233
|
}
|
|
22167
22234
|
if (executableDir) {
|
|
22168
22235
|
let localFile = findFile(executableDir, executableFile);
|
|
22169
22236
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
22170
|
-
const legacyName =
|
|
22237
|
+
const legacyName = path91.basename(
|
|
22171
22238
|
this._scriptPath,
|
|
22172
|
-
|
|
22239
|
+
path91.extname(this._scriptPath)
|
|
22173
22240
|
);
|
|
22174
22241
|
if (legacyName !== this._name) {
|
|
22175
22242
|
localFile = findFile(
|
|
@@ -22180,7 +22247,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22180
22247
|
}
|
|
22181
22248
|
executableFile = localFile || executableFile;
|
|
22182
22249
|
}
|
|
22183
|
-
launchWithNode = sourceExt.includes(
|
|
22250
|
+
launchWithNode = sourceExt.includes(path91.extname(executableFile));
|
|
22184
22251
|
let proc;
|
|
22185
22252
|
if (process2.platform !== "win32") {
|
|
22186
22253
|
if (launchWithNode) {
|
|
@@ -23027,7 +23094,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
23027
23094
|
* @return {Command}
|
|
23028
23095
|
*/
|
|
23029
23096
|
nameFromFilename(filename) {
|
|
23030
|
-
this._name =
|
|
23097
|
+
this._name = path91.basename(filename, path91.extname(filename));
|
|
23031
23098
|
return this;
|
|
23032
23099
|
}
|
|
23033
23100
|
/**
|
|
@@ -23041,9 +23108,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
23041
23108
|
* @param {string} [path]
|
|
23042
23109
|
* @return {(string|null|Command)}
|
|
23043
23110
|
*/
|
|
23044
|
-
executableDir(
|
|
23045
|
-
if (
|
|
23046
|
-
this._executableDir =
|
|
23111
|
+
executableDir(path92) {
|
|
23112
|
+
if (path92 === void 0) return this._executableDir;
|
|
23113
|
+
this._executableDir = path92;
|
|
23047
23114
|
return this;
|
|
23048
23115
|
}
|
|
23049
23116
|
/**
|
|
@@ -23340,11 +23407,11 @@ var init_esm = __esm({
|
|
|
23340
23407
|
});
|
|
23341
23408
|
|
|
23342
23409
|
// src/lib/cloud/pointer.ts
|
|
23343
|
-
import
|
|
23344
|
-
import
|
|
23410
|
+
import fs74 from "node:fs";
|
|
23411
|
+
import path75 from "node:path";
|
|
23345
23412
|
function hasRetiredPointer(root2) {
|
|
23346
23413
|
try {
|
|
23347
|
-
const held4 = JSON.parse(
|
|
23414
|
+
const held4 = JSON.parse(fs74.readFileSync(path75.join(root2, POINTER_FILE), "utf8"));
|
|
23348
23415
|
return typeof held4.workspace === "string" && held4.workspace.trim() !== "";
|
|
23349
23416
|
} catch {
|
|
23350
23417
|
return false;
|
|
@@ -23359,39 +23426,39 @@ var init_pointer = __esm({
|
|
|
23359
23426
|
});
|
|
23360
23427
|
|
|
23361
23428
|
// src/lib/card-studio-backfill.ts
|
|
23362
|
-
import
|
|
23363
|
-
import
|
|
23429
|
+
import fs75 from "node:fs";
|
|
23430
|
+
import path76 from "node:path";
|
|
23364
23431
|
function renameToStudio() {
|
|
23365
23432
|
if (!KANBAN || !BOARD_STATE) return;
|
|
23366
|
-
const mark =
|
|
23433
|
+
const mark = path76.join(BOARD_STATE, RENAMED);
|
|
23367
23434
|
try {
|
|
23368
|
-
if (
|
|
23369
|
-
for (const [from, to] of [[
|
|
23370
|
-
if (
|
|
23435
|
+
if (fs75.existsSync(mark)) return;
|
|
23436
|
+
for (const [from, to] of [[path76.join(KANBAN, "workflows"), STUDIOS], [path76.join(RULES, "workflows"), path76.join(RULES, "studios")]]) {
|
|
23437
|
+
if (fs75.existsSync(from) && !fs75.existsSync(to)) fs75.renameSync(from, to);
|
|
23371
23438
|
}
|
|
23372
|
-
for (const file2 of [STUDIOS, TODO, TRIAGE].flatMap((dir) =>
|
|
23373
|
-
const at2 =
|
|
23374
|
-
const text5 =
|
|
23439
|
+
for (const file2 of [STUDIOS, TODO, TRIAGE].flatMap((dir) => fs75.existsSync(dir) ? walkMd(dir) : [])) {
|
|
23440
|
+
const at2 = path76.relative(KANBAN, file2).split(path76.sep).join("/");
|
|
23441
|
+
const text5 = fs75.readFileSync(file2, "utf8");
|
|
23375
23442
|
const to = studioRenamed(at2, text5);
|
|
23376
23443
|
if (to.path === at2 && to.content === text5) continue;
|
|
23377
|
-
const target =
|
|
23378
|
-
if (target !== file2 &&
|
|
23379
|
-
|
|
23380
|
-
if (target !== file2)
|
|
23444
|
+
const target = path76.join(KANBAN, to.path);
|
|
23445
|
+
if (target !== file2 && fs75.existsSync(target)) continue;
|
|
23446
|
+
fs75.writeFileSync(target, to.content);
|
|
23447
|
+
if (target !== file2) fs75.rmSync(file2);
|
|
23381
23448
|
}
|
|
23382
|
-
|
|
23383
|
-
|
|
23449
|
+
fs75.mkdirSync(BOARD_STATE, { recursive: true });
|
|
23450
|
+
fs75.writeFileSync(mark, "");
|
|
23384
23451
|
} catch {
|
|
23385
23452
|
}
|
|
23386
23453
|
}
|
|
23387
23454
|
function backfillCardStudios() {
|
|
23388
23455
|
renameToStudio();
|
|
23389
23456
|
if (!TODO || !BOARD_STATE) return;
|
|
23390
|
-
const mark =
|
|
23457
|
+
const mark = path76.join(BOARD_STATE, MARK);
|
|
23391
23458
|
try {
|
|
23392
|
-
if (
|
|
23459
|
+
if (fs75.existsSync(mark) || !fs75.existsSync(TODO)) return;
|
|
23393
23460
|
for (const file2 of walkMd(TODO)) {
|
|
23394
|
-
const text5 =
|
|
23461
|
+
const text5 = fs75.readFileSync(file2, "utf8");
|
|
23395
23462
|
if (!text5.startsWith("---\n")) continue;
|
|
23396
23463
|
const end2 = text5.indexOf("\n---", 3);
|
|
23397
23464
|
if (end2 < 0) continue;
|
|
@@ -23399,11 +23466,11 @@ function backfillCardStudios() {
|
|
|
23399
23466
|
if (!/\ntitle:/.test(head2) || /\nstudio:/.test(head2)) continue;
|
|
23400
23467
|
const modules = /\nmodules:[^\n]*/.exec(head2);
|
|
23401
23468
|
const at2 = modules ? modules.index + modules[0].length : end2;
|
|
23402
|
-
|
|
23469
|
+
fs75.writeFileSync(file2, `${text5.slice(0, at2)}
|
|
23403
23470
|
studio: coding${text5.slice(at2)}`);
|
|
23404
23471
|
}
|
|
23405
|
-
|
|
23406
|
-
|
|
23472
|
+
fs75.mkdirSync(BOARD_STATE, { recursive: true });
|
|
23473
|
+
fs75.writeFileSync(mark, "");
|
|
23407
23474
|
} catch {
|
|
23408
23475
|
}
|
|
23409
23476
|
}
|
|
@@ -23440,8 +23507,8 @@ var init_created_cards = __esm({
|
|
|
23440
23507
|
|
|
23441
23508
|
// src/lib/agent/creation.ts
|
|
23442
23509
|
import crypto4 from "node:crypto";
|
|
23443
|
-
import
|
|
23444
|
-
import
|
|
23510
|
+
import fs76 from "node:fs";
|
|
23511
|
+
import path77 from "node:path";
|
|
23445
23512
|
function creationError(error, triage) {
|
|
23446
23513
|
const zh = readLanguage() === "zh";
|
|
23447
23514
|
const messages = {
|
|
@@ -23467,12 +23534,12 @@ ${zh ? `\u539F\u6761\u76EE\u4ECD\u5728 triage\uFF1A${triage}\u3002${unreachable
|
|
|
23467
23534
|
function creationReceipt(request2, slot) {
|
|
23468
23535
|
const hash2 = crypto4.createHash("sha256").update(`${request2}
|
|
23469
23536
|
${slot}`).digest("hex");
|
|
23470
|
-
return
|
|
23537
|
+
return path77.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
|
|
23471
23538
|
}
|
|
23472
23539
|
function readCreation(file2, said2) {
|
|
23473
23540
|
return withCreationLock(() => {
|
|
23474
23541
|
try {
|
|
23475
|
-
const held4 = JSON.parse(
|
|
23542
|
+
const held4 = JSON.parse(fs76.readFileSync(file2, "utf8"));
|
|
23476
23543
|
if (!held4.said || typeof held4.said.title !== "string") throw new Error("Invalid creation journal");
|
|
23477
23544
|
return held4;
|
|
23478
23545
|
} catch (error) {
|
|
@@ -23484,10 +23551,10 @@ function readCreation(file2, said2) {
|
|
|
23484
23551
|
});
|
|
23485
23552
|
}
|
|
23486
23553
|
function saveCreation(file2, journal) {
|
|
23487
|
-
|
|
23554
|
+
fs76.mkdirSync(path77.dirname(file2), { recursive: true });
|
|
23488
23555
|
const temp = `${file2}.${crypto4.randomUUID()}.tmp`;
|
|
23489
|
-
|
|
23490
|
-
|
|
23556
|
+
fs76.writeFileSync(temp, JSON.stringify(journal));
|
|
23557
|
+
fs76.renameSync(temp, file2);
|
|
23491
23558
|
}
|
|
23492
23559
|
function archiveCreation(source2, id) {
|
|
23493
23560
|
if (readArchived().some((s) => s.sourceId === source2 && s.cardId === id)) return;
|
|
@@ -23501,7 +23568,7 @@ function archiveCreation(source2, id) {
|
|
|
23501
23568
|
function triageFile(sourceId) {
|
|
23502
23569
|
const found2 = [...readInbox(), ...readAllDismissed(), ...readArchived()].find((s) => s.sourceId === sourceId.trim());
|
|
23503
23570
|
if (!found2) throw new BoardError(`nothing in triage is ${sourceId}`, { kind: "refused" });
|
|
23504
|
-
return
|
|
23571
|
+
return path77.basename(found2.relPath, ".md");
|
|
23505
23572
|
}
|
|
23506
23573
|
var init_creation = __esm({
|
|
23507
23574
|
"src/lib/agent/creation.ts"() {
|
|
@@ -23669,14 +23736,14 @@ __export(board_exports, {
|
|
|
23669
23736
|
buildBoardProgram: () => buildBoardProgram
|
|
23670
23737
|
});
|
|
23671
23738
|
import crypto5 from "node:crypto";
|
|
23672
|
-
import
|
|
23673
|
-
import
|
|
23739
|
+
import fs77 from "node:fs";
|
|
23740
|
+
import path78 from "node:path";
|
|
23674
23741
|
async function dispatch(move, cmd, args2, opts, cli) {
|
|
23675
23742
|
const ctx = ctxOf(cmd, cli.program);
|
|
23676
23743
|
const data = await runAction(ctx, {}, async () => {
|
|
23677
23744
|
const found2 = resolveBoard(move, { board: ctx.board, dir: ctx.dir, cwd: cli.cwd, installHint: cli.installHint });
|
|
23678
|
-
useBoard(found2, ctx.dir !== null);
|
|
23679
|
-
await syncStudios();
|
|
23745
|
+
useBoard(found2, ctx.dir !== null, move === "inspect");
|
|
23746
|
+
if (move !== "inspect") await syncStudios();
|
|
23680
23747
|
const root2 = found2.root;
|
|
23681
23748
|
sayIfRetiredPointer(root2);
|
|
23682
23749
|
const creating = move === "create" && insideRun() ? peekRun(insideRun()) : void 0;
|
|
@@ -23710,7 +23777,7 @@ async function cloudCard(task, opts) {
|
|
|
23710
23777
|
let request2;
|
|
23711
23778
|
if (typeof opts.bodyFile === "string") {
|
|
23712
23779
|
try {
|
|
23713
|
-
request2 =
|
|
23780
|
+
request2 = fs77.readFileSync(opts.bodyFile, "utf8");
|
|
23714
23781
|
} catch {
|
|
23715
23782
|
}
|
|
23716
23783
|
}
|
|
@@ -23740,7 +23807,7 @@ async function cloudCard(task, opts) {
|
|
|
23740
23807
|
const file2 = creationReceipt(`${checked.value}:${requestId}`, slot);
|
|
23741
23808
|
const journal = readCreation(file2, said2);
|
|
23742
23809
|
if (!journal.made) {
|
|
23743
|
-
const key = `akb-${
|
|
23810
|
+
const key = `akb-${path78.basename(file2, ".json").slice(0, 40)}`;
|
|
23744
23811
|
const made = await createProjectTask(checked.value, journal.said, key);
|
|
23745
23812
|
if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
|
|
23746
23813
|
journal.made = made.value;
|
|
@@ -23787,6 +23854,9 @@ function buildBoardProgram(cli) {
|
|
|
23787
23854
|
).option("--append <text>", "add one question to the end", opInOrder("append")).option("--update <n> <text...>", "rewrite question <n> whole", opInOrder("update")).option("--drop <positions>", "remove answered questions, e.g. 1 or 1,3", opInOrder("drop")).option("--clear", "remove every open question", opInOrder("clear")).option("--option <text>", "a choice for the op before it", opInOrder("option")).option("--recommended-option <text>", "a choice for the op before it, ticked to start", opInOrder("recommended-option")).option("--mode <mode>", "how many choices the op before it takes: single | multi", opInOrder("mode")).option("--agent <name>", "the preview agent whose section the op before it is about", opInOrder("agent")).action(async function(id) {
|
|
23788
23855
|
await dispatch("update-questions", this, [String(id)], { ops: questionOps }, cli);
|
|
23789
23856
|
});
|
|
23857
|
+
move("inspect").argument("<id>", ID, cardId).summary("read task facts, saved work and execution references").action(async function(id) {
|
|
23858
|
+
await dispatch("inspect", this, [String(id)], this.opts(), cli);
|
|
23859
|
+
});
|
|
23790
23860
|
move("validate").argument("[id]", ID, cardId).summary("validate card format and report file, line, and repair instructions").description("Check one card, or every open card when no id is given. Reads only; exits non-zero with detailed errors until the format is valid.").action(async function(id) {
|
|
23791
23861
|
await dispatch("validate", this, id === void 0 ? [] : [String(id)], this.opts(), cli);
|
|
23792
23862
|
});
|
|
@@ -23869,17 +23939,19 @@ var init_board2 = __esm({
|
|
|
23869
23939
|
});
|
|
23870
23940
|
|
|
23871
23941
|
// src/lib/board-cli.ts
|
|
23872
|
-
import
|
|
23873
|
-
import
|
|
23874
|
-
function useBoard(found2, dirNamed) {
|
|
23875
|
-
if (!found2.named && found2.board ===
|
|
23942
|
+
import fs78 from "node:fs";
|
|
23943
|
+
import path79 from "node:path";
|
|
23944
|
+
function useBoard(found2, dirNamed, readOnly = false) {
|
|
23945
|
+
if (!found2.named && found2.board === path79.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
|
|
23876
23946
|
else setBoardDir(found2.board, found2.root);
|
|
23877
|
-
|
|
23878
|
-
|
|
23947
|
+
if (!readOnly) {
|
|
23948
|
+
useProjectState();
|
|
23949
|
+
backfillCardStudios();
|
|
23950
|
+
}
|
|
23879
23951
|
}
|
|
23880
23952
|
function whole(found2, move) {
|
|
23881
23953
|
if (move === MAKES_A_BOARD) return found2;
|
|
23882
|
-
if (!
|
|
23954
|
+
if (!fs78.existsSync(path79.join(found2.board, "todo"))) {
|
|
23883
23955
|
die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
|
|
23884
23956
|
kind: "board-incomplete",
|
|
23885
23957
|
dir: found2.root
|
|
@@ -23888,13 +23960,13 @@ function whole(found2, move) {
|
|
|
23888
23960
|
return found2;
|
|
23889
23961
|
}
|
|
23890
23962
|
function findBoardUpward(from, move) {
|
|
23891
|
-
let dir =
|
|
23963
|
+
let dir = path79.resolve(from);
|
|
23892
23964
|
for (; ; ) {
|
|
23893
|
-
if (hasBoard(dir)) return { root: dir, board:
|
|
23965
|
+
if (hasBoard(dir)) return { root: dir, board: path79.join(dir, "docs", "kanban") };
|
|
23894
23966
|
if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
|
|
23895
|
-
const kept2 =
|
|
23896
|
-
if (move !== MAKES_A_BOARD &&
|
|
23897
|
-
const up =
|
|
23967
|
+
const kept2 = path79.join(dir, ".akb", "kanban");
|
|
23968
|
+
if (move !== MAKES_A_BOARD && fs78.existsSync(path79.join(kept2, "todo"))) return { root: dir, board: kept2 };
|
|
23969
|
+
const up = path79.dirname(dir);
|
|
23898
23970
|
if (up === dir) return null;
|
|
23899
23971
|
dir = up;
|
|
23900
23972
|
}
|
|
@@ -23902,11 +23974,11 @@ function findBoardUpward(from, move) {
|
|
|
23902
23974
|
function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
23903
23975
|
const named2 = board2 ?? boardFromEnv();
|
|
23904
23976
|
if (named2) {
|
|
23905
|
-
const folder =
|
|
23906
|
-
if (!
|
|
23977
|
+
const folder = path79.resolve(cwd, named2);
|
|
23978
|
+
if (!fs78.existsSync(folder) && move !== MAKES_A_BOARD) {
|
|
23907
23979
|
die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
|
|
23908
23980
|
}
|
|
23909
|
-
if (
|
|
23981
|
+
if (fs78.existsSync(folder) && !isBoardDir(folder) && move !== MAKES_A_BOARD) {
|
|
23910
23982
|
die(`${folder} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
|
|
23911
23983
|
kind: "no-board",
|
|
23912
23984
|
dir: folder
|
|
@@ -23915,24 +23987,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
|
23915
23987
|
return { root: projectRootOf(folder), board: folder, named: true };
|
|
23916
23988
|
}
|
|
23917
23989
|
if (dir !== null) {
|
|
23918
|
-
const root2 =
|
|
23919
|
-
if (!
|
|
23920
|
-
const kept2 =
|
|
23921
|
-
if (!hasBoard(root2) && move !== MAKES_A_BOARD &&
|
|
23990
|
+
const root2 = path79.resolve(dir);
|
|
23991
|
+
if (!fs78.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
|
|
23992
|
+
const kept2 = path79.join(root2, ".akb", "kanban");
|
|
23993
|
+
if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs78.existsSync(path79.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
|
|
23922
23994
|
if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
|
|
23923
23995
|
die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
|
|
23924
23996
|
kind: "no-board",
|
|
23925
23997
|
dir: root2
|
|
23926
23998
|
});
|
|
23927
23999
|
}
|
|
23928
|
-
return whole({ root: root2, board:
|
|
24000
|
+
return whole({ root: root2, board: path79.join(root2, "docs", "kanban") }, move);
|
|
23929
24001
|
}
|
|
23930
24002
|
const found2 = findBoardUpward(cwd, move);
|
|
23931
24003
|
if (found2) return whole(found2, move);
|
|
23932
|
-
if (move === MAKES_A_BOARD) return { root:
|
|
24004
|
+
if (move === MAKES_A_BOARD) return { root: path79.resolve(cwd), board: path79.join(path79.resolve(cwd), "docs", "kanban") };
|
|
23933
24005
|
die(
|
|
23934
|
-
`no board here. Looked in ${
|
|
23935
|
-
{ kind: "no-board", dir:
|
|
24006
|
+
`no board here. Looked in ${path79.resolve(cwd)} and every folder above it for docs/kanban/. ${installHint}\uFF0C\u6216\u7528 --board \u6307\u5B9A\u5DF2\u6709\u770B\u677F\u3002`,
|
|
24007
|
+
{ kind: "no-board", dir: path79.resolve(cwd) }
|
|
23936
24008
|
);
|
|
23937
24009
|
}
|
|
23938
24010
|
function editDistance(a2, b2) {
|
|
@@ -24015,8 +24087,8 @@ var init_board_cli = __esm({
|
|
|
24015
24087
|
init_pointer();
|
|
24016
24088
|
init_card_studio_backfill();
|
|
24017
24089
|
MAKES_A_BOARD = "init";
|
|
24018
|
-
hasBoard = (dir) =>
|
|
24019
|
-
isBoardDir = (dir) =>
|
|
24090
|
+
hasBoard = (dir) => fs78.existsSync(path79.join(dir, "docs", "kanban"));
|
|
24091
|
+
isBoardDir = (dir) => fs78.existsSync(path79.join(dir, "todo")) && fs78.existsSync(path79.join(dir, "config.md"));
|
|
24020
24092
|
boardFromEnv = () => {
|
|
24021
24093
|
const named2 = process.env.AI4KANBAN_BOARD?.trim();
|
|
24022
24094
|
return named2 ? named2 : null;
|
|
@@ -24033,30 +24105,14 @@ var init_manual = __esm({
|
|
|
24033
24105
|
/** Under every flow: print it, or run it. The one choice each of them has. */
|
|
24034
24106
|
flow: `
|
|
24035
24107
|
Print it, or run it
|
|
24036
|
-
--print
|
|
24108
|
+
--print print the flow to follow in the current session, filled in for this board:
|
|
24037
24109
|
the card's own path, the steps it has left, the memory file its modules point
|
|
24038
24110
|
at, the flows the job is done by in full, and the
|
|
24039
24111
|
command that closes the job \u2014 because nothing is watching you finish.
|
|
24040
|
-
(no flag) start a
|
|
24041
|
-
|
|
24042
|
-
Print when the user is asking you for the action here, in a session. You do the job in the
|
|
24043
|
-
conversation you are already in: it costs no second agent and can't collide with the
|
|
24044
|
-
changes already in the working tree.
|
|
24045
|
-
|
|
24046
|
-
Start a run when the user wants the work to happen on its own \u2014 in the background, while
|
|
24047
|
-
they do something else, on a card they are not watching. That is the explicit ask. It also
|
|
24048
|
-
wins on long read-heavy jobs that need nothing from the conversation.
|
|
24049
|
-
|
|
24050
|
-
Some jobs are better done by the agent that was there. It just built the card, so it knows
|
|
24051
|
-
which steps it really did; a fresh agent sees unticked boxes and works the rest out from
|
|
24052
|
-
the diff.
|
|
24053
|
-
|
|
24054
|
-
When it is not clear which was meant, print. A printed flow costs nothing and can still be
|
|
24055
|
-
followed by starting a run; a started run costs a second agent, a second context, and money
|
|
24056
|
-
nobody asked to spend.
|
|
24112
|
+
(no flag) start a separate session with its own context.
|
|
24057
24113
|
|
|
24058
|
-
|
|
24059
|
-
|
|
24114
|
+
Choose either mode for preview work. Other board actions inside a board run print their
|
|
24115
|
+
flows; preview requests can queue a separate session.
|
|
24060
24116
|
`,
|
|
24061
24117
|
/** Under `delivery`: what one is, which no verb of it says on its own. */
|
|
24062
24118
|
deliveries: (program2) => `
|
|
@@ -24276,8 +24332,8 @@ var init_agent = __esm({
|
|
|
24276
24332
|
|
|
24277
24333
|
// src/commands/cloud-template.ts
|
|
24278
24334
|
import { createHash as createHash8 } from "node:crypto";
|
|
24279
|
-
import
|
|
24280
|
-
import
|
|
24335
|
+
import fs79 from "node:fs";
|
|
24336
|
+
import path80 from "node:path";
|
|
24281
24337
|
function usage2(problem, line) {
|
|
24282
24338
|
die(`${problem}
|
|
24283
24339
|
usage: ${line}`, { kind: "bad-args", bare: true, exitCode: 2 });
|
|
@@ -24354,10 +24410,10 @@ This template has no preview.`);
|
|
|
24354
24410
|
const written = [];
|
|
24355
24411
|
for (const p2 of previews) {
|
|
24356
24412
|
const bytes2 = Buffer.from(await (await ask(`/${at2}/previews/${route(p2.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
24357
|
-
const file2 =
|
|
24358
|
-
const out =
|
|
24359
|
-
|
|
24360
|
-
|
|
24413
|
+
const file2 = path80.basename(p2.path);
|
|
24414
|
+
const out = path80.join(opts.to, file2.startsWith(`${name}-`) ? file2 : `${name}-${file2}`);
|
|
24415
|
+
fs79.mkdirSync(opts.to, { recursive: true });
|
|
24416
|
+
fs79.writeFileSync(out, bytes2);
|
|
24361
24417
|
written.push(out);
|
|
24362
24418
|
say(out);
|
|
24363
24419
|
}
|
|
@@ -24370,15 +24426,15 @@ async function templateGet(name, opts, program2) {
|
|
|
24370
24426
|
const { template } = await asJson(await ask(`/${at2}`, {}, WITHOUT));
|
|
24371
24427
|
const fetched = [];
|
|
24372
24428
|
for (const f2 of template.files) {
|
|
24373
|
-
const out =
|
|
24374
|
-
if (!out.startsWith(
|
|
24429
|
+
const out = path80.resolve(to, f2.path);
|
|
24430
|
+
if (!out.startsWith(path80.resolve(to) + path80.sep)) refuse3(T.corrupt, WITHOUT);
|
|
24375
24431
|
const bytes2 = Buffer.from(await (await ask(`/${at2}/files/${route(f2.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
24376
24432
|
if (bytes2.byteLength !== f2.size || createHash8("sha256").update(bytes2).digest("hex") !== f2.sha256) {
|
|
24377
24433
|
refuse3(T.corrupt, WITHOUT);
|
|
24378
24434
|
}
|
|
24379
24435
|
fetched.push({ out, bytes: bytes2 });
|
|
24380
24436
|
}
|
|
24381
|
-
const taken = fetched.filter((f2) =>
|
|
24437
|
+
const taken = fetched.filter((f2) => fs79.existsSync(f2.out)).map((f2) => path80.relative(to, f2.out));
|
|
24382
24438
|
if (taken.length > 0) {
|
|
24383
24439
|
refuse3({
|
|
24384
24440
|
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`,
|
|
@@ -24386,8 +24442,8 @@ async function templateGet(name, opts, program2) {
|
|
|
24386
24442
|
});
|
|
24387
24443
|
}
|
|
24388
24444
|
for (const f2 of fetched) {
|
|
24389
|
-
|
|
24390
|
-
|
|
24445
|
+
fs79.mkdirSync(path80.dirname(f2.out), { recursive: true });
|
|
24446
|
+
fs79.writeFileSync(f2.out, f2.bytes);
|
|
24391
24447
|
}
|
|
24392
24448
|
say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
|
|
24393
24449
|
Fetched ${name}: ${fetched.length} files into ${to}`);
|
|
@@ -24404,25 +24460,25 @@ async function templateSource(name, opts) {
|
|
|
24404
24460
|
say(`evidence: ${e2.path}`);
|
|
24405
24461
|
continue;
|
|
24406
24462
|
}
|
|
24407
|
-
const out =
|
|
24408
|
-
|
|
24409
|
-
|
|
24463
|
+
const out = path80.join(opts.to, `${name}-${path80.basename(e2.path)}`);
|
|
24464
|
+
fs79.mkdirSync(opts.to, { recursive: true });
|
|
24465
|
+
fs79.writeFileSync(out, Buffer.from(await (await ask(`/${at2}/evidence/${route(e2.path)}`)).arrayBuffer()));
|
|
24410
24466
|
written.push(out);
|
|
24411
24467
|
say(out);
|
|
24412
24468
|
}
|
|
24413
24469
|
return { name, source: source2, evidence: written.length > 0 ? written : evidence.map((e2) => e2.path) };
|
|
24414
24470
|
}
|
|
24415
24471
|
async function templatePublish(dir, opts) {
|
|
24416
|
-
const root2 =
|
|
24417
|
-
const manifest =
|
|
24418
|
-
if (!
|
|
24419
|
-
const meta = readTemplateMeta(
|
|
24472
|
+
const root2 = path80.resolve(dir);
|
|
24473
|
+
const manifest = path80.join(root2, "template.md");
|
|
24474
|
+
if (!fs79.existsSync(manifest)) invalid("\u6587\u4EF6\u5939\u9876\u5C42\u7F3A\u5C11 template.md\u3002", "template.md is missing from the folder\u2019s top level.");
|
|
24475
|
+
const meta = readTemplateMeta(fs79.readFileSync(manifest, "utf8"));
|
|
24420
24476
|
const files = walk2(root2);
|
|
24421
|
-
const total = files.reduce((sum, f2) => sum +
|
|
24477
|
+
const total = files.reduce((sum, f2) => sum + fs79.statSync(path80.join(root2, f2)).size, 0);
|
|
24422
24478
|
if (total > MAX_BYTES3) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
|
|
24423
24479
|
for (const extra of [...opts.preview, ...opts.evidence]) {
|
|
24424
|
-
if (!
|
|
24425
|
-
if (
|
|
24480
|
+
if (!fs79.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
|
|
24481
|
+
if (path80.resolve(extra).startsWith(root2 + path80.sep)) {
|
|
24426
24482
|
invalid(
|
|
24427
24483
|
`${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`,
|
|
24428
24484
|
`${extra} is inside the template folder; keep previews and evidence outside it.`
|
|
@@ -24434,10 +24490,10 @@ async function templatePublish(dir, opts) {
|
|
|
24434
24490
|
}
|
|
24435
24491
|
const form = new FormData();
|
|
24436
24492
|
form.set("meta", JSON.stringify({ ...meta, replace: !!opts.replace }));
|
|
24437
|
-
const add2 = (kind, name, file2) => form.append(`${kind}:${name}`, new Blob([
|
|
24438
|
-
for (const f2 of files) add2("files", f2,
|
|
24439
|
-
for (const f2 of opts.preview) add2("previews",
|
|
24440
|
-
for (const f2 of opts.evidence) add2("evidence",
|
|
24493
|
+
const add2 = (kind, name, file2) => form.append(`${kind}:${name}`, new Blob([fs79.readFileSync(file2)]), path80.basename(name));
|
|
24494
|
+
for (const f2 of files) add2("files", f2, path80.join(root2, f2));
|
|
24495
|
+
for (const f2 of opts.preview) add2("previews", path80.basename(f2), f2);
|
|
24496
|
+
for (const f2 of opts.evidence) add2("evidence", path80.basename(f2), f2);
|
|
24441
24497
|
const done = await asJson(await ask("", { method: "POST", body: form }));
|
|
24442
24498
|
say(
|
|
24443
24499
|
done.replaced ? `\u5DF2\u66FF\u6362 ${done.name}\uFF1A${files.length} \u4E2A\u6587\u4EF6\u3002
|
|
@@ -24453,11 +24509,11 @@ Deleted ${name} from the catalog.`);
|
|
|
24453
24509
|
return { name, deleted: true };
|
|
24454
24510
|
}
|
|
24455
24511
|
async function templateShowcase(name, dir) {
|
|
24456
|
-
const file2 =
|
|
24457
|
-
if (!
|
|
24512
|
+
const file2 = path80.join(dir, "showcase.json");
|
|
24513
|
+
if (!fs79.existsSync(file2)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
|
|
24458
24514
|
let meta;
|
|
24459
24515
|
try {
|
|
24460
|
-
meta = JSON.parse(
|
|
24516
|
+
meta = JSON.parse(fs79.readFileSync(file2, "utf8"));
|
|
24461
24517
|
} catch {
|
|
24462
24518
|
return invalid("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
|
|
24463
24519
|
}
|
|
@@ -24469,9 +24525,9 @@ async function templateShowcase(name, dir) {
|
|
|
24469
24525
|
const form = new FormData();
|
|
24470
24526
|
form.set("meta", JSON.stringify(meta));
|
|
24471
24527
|
for (const p2 of new Set(named2)) {
|
|
24472
|
-
const at2 =
|
|
24473
|
-
if (!
|
|
24474
|
-
form.append(`media:${p2}`, new Blob([
|
|
24528
|
+
const at2 = path80.join(dir, p2);
|
|
24529
|
+
if (!fs79.existsSync(at2)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at2}\u3002`, `${at2} does not exist.`);
|
|
24530
|
+
form.append(`media:${p2}`, new Blob([fs79.readFileSync(at2)]), p2);
|
|
24475
24531
|
}
|
|
24476
24532
|
const done = await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form }));
|
|
24477
24533
|
say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done.files} \u4E2A\u6587\u4EF6\u3002
|
|
@@ -24480,7 +24536,7 @@ Updated ${name}'s showcase: ${done.files} files.`);
|
|
|
24480
24536
|
}
|
|
24481
24537
|
function walk2(root2, sub = "") {
|
|
24482
24538
|
const out = [];
|
|
24483
|
-
for (const entry of
|
|
24539
|
+
for (const entry of fs79.readdirSync(path80.join(root2, sub), { withFileTypes: true })) {
|
|
24484
24540
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
24485
24541
|
const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
|
|
24486
24542
|
if (entry.isDirectory()) out.push(...walk2(root2, rel2));
|
|
@@ -24673,7 +24729,7 @@ var init_board3 = __esm({
|
|
|
24673
24729
|
var card_chat_default;
|
|
24674
24730
|
var init_card_chat = __esm({
|
|
24675
24731
|
"src/guide/card-chat.md"() {
|
|
24676
|
-
card_chat_default = '# Answer a card\'s conversation\n\nWork on the current card and its assets by default. Project implementation requires approval on the review page.\n\n- **Where the task stands**: read it with `akb task show <id>`.\n- **Button labels**: name actions by their labels on the page, in the user\'s language: "Approve" or "Approve, start \u2026" (\u6279\u51C6 / \u6279\u51C6\uFF0C\u5F00\u59CB\u2026), "Resume" (\u7EED\u8DD1), "Start again" (\u91CD\u65B0\u53D1\u8D77).\n\n- **Change requirements or drafts**: when the user changes the scope, expected behavior, or draft, use `akb raw card revise <id> --print "<change>"`.\n- **Record an answer**: when the user answers an open question on the card, use `akb raw card resolve <id> --print`.\n- **Manage open questions**: when a decision needs the user\'s input, follow `akb guide update-questions` and use `akb raw update-questions <id>` to edit the question list.\n- **Change card fields**: when the user changes metadata such as priority, modules, or dependencies, use `akb raw update <id>`.\n- **Choose a preview agent**: when a preview is needed and the agent is unclear, use `akb raw previews --triggers` to match the work to an agent.\n- **Create or revise a preview**: when the user asks to see or change a preview for the current card
|
|
24732
|
+
card_chat_default = '# Answer a card\'s conversation\n\nWork on the current card and its assets by default. Project implementation requires approval on the review page.\n\n- **Where the task stands**: read it with `akb task show <id>`.\n- **Button labels**: name actions by their labels on the page, in the user\'s language: "Approve" or "Approve, start \u2026" (\u6279\u51C6 / \u6279\u51C6\uFF0C\u5F00\u59CB\u2026), "Resume" (\u7EED\u8DD1), "Start again" (\u91CD\u65B0\u53D1\u8D77).\n\n- **Change requirements or drafts**: when the user changes the scope, expected behavior, or draft, use `akb raw card revise <id> --print "<change>"`.\n- **Record an answer**: when the user answers an open question on the card, use `akb raw card resolve <id> --print`.\n- **Manage open questions**: when a decision needs the user\'s input, follow `akb guide update-questions` and use `akb raw update-questions <id>` to edit the question list.\n- **Change card fields**: when the user changes metadata such as priority, modules, or dependencies, use `akb raw update <id>`.\n- **Choose a preview agent**: when a preview is needed and the agent is unclear, use `akb raw previews --triggers` to match the work to an agent.\n- **Create or revise a preview**: when the user asks to see or change a preview for the current card,\n use `akb raw previews <agent> <id>`; choose `--print` for this session or omit it for a separate\n session. The agent carrying out that role writes and maintains its section and Preview Components.\n- **Create a separate task**: when the user asks to capture work unrelated to this card, follow `akb guide add-task`.\n- **Split this card**: when the user asks to break this card\'s outcome into subtasks, follow the group procedure in `akb guide add-task`.\n- **Change a studio**: use `akb guide update-studio` for shared studio or agent changes; a correction to this card\'s draft alone stays on this card.\n- **Check card edits**: after writing a card, run `akb raw validate <id>` and fix what it reports.\n- **Anything else**: for a request this guide does not cover, read `akb help` once, then the matching command\'s `--help`.\n\nReply in plain, natural language. Do not write memory, including through any flow this conversation starts.\n\n- **Start this task**: when the user explicitly asks to start, implement or approve it, use `akb task approve` or `akb raw card approve/implement`. In a task reply these register one approval for after the reply finishes and syncs. Pending means accepted, not started; finish the reply and do not wait or edit the card again. Preview approvals still apply.\n';
|
|
24677
24733
|
}
|
|
24678
24734
|
});
|
|
24679
24735
|
|
|
@@ -24713,7 +24769,7 @@ var init_follow_up = __esm({
|
|
|
24713
24769
|
var implement_default;
|
|
24714
24770
|
var init_implement = __esm({
|
|
24715
24771
|
"src/guide/implement.md"() {
|
|
24716
|
-
implement_default = "# Implement the approved requirements\n\nBuild the approved card or plan directly. Preserve settled decisions and unrelated questions;\ndo not replace or contradict the approved requirements. With no card, build only the given\nrequirement and create no card.\n\n- **
|
|
24772
|
+
implement_default = "# Implement the approved requirements\n\nBuild the approved card or plan directly. Preserve settled decisions and unrelated questions;\ndo not replace or contradict the approved requirements. With no card, build only the given\nrequirement and create no card.\n\n- **Authorization**: approval covers the necessary operations within the agreed scope and\n constraints; carry it across commands, tools and stages without repeated confirmation.\n- **User-action blockers**: resolve routine choices and problems yourself; ask only when\n reasonable investigation leaves a blocker requiring user action or a decision beyond the\n approved scope. On a card, use `akb guide update-questions`, stating what you tried, what\n is blocked and your recommendation; continue independent work.\n- **Defer what can wait**: follow `akb guide follow-up` for work this build does not require;\n never ask about it or let it block this build.\n- **Decisions made while building**: record an answered material decision the user could\n reasonably reverse under `## Worth noting after implementation` on the card.\n";
|
|
24717
24773
|
}
|
|
24718
24774
|
});
|
|
24719
24775
|
|
|
@@ -24753,7 +24809,7 @@ var init_review_rejections = __esm({
|
|
|
24753
24809
|
var refine_default;
|
|
24754
24810
|
var init_refine = __esm({
|
|
24755
24811
|
"src/guide/refine.md"() {
|
|
24756
|
-
refine_default = "# Refine a card\n\nPlan one card
|
|
24812
|
+
refine_default = "# Refine a card\n\nPlan one card until it can be built.\n\n- **Unchecked card**: a card with `triage:` set and an empty `## Scope` was never checked\n against the project. Check it first; when the project already does\n the work, or what it concerns no longer exists, run\n `akb raw reject <id> --reason \"<what shows it>\"` and stop.\n- **Gone or already done**: for any other card, append a question asking the user whether to\n discard it, run no preview agent, and stop.\n- **Existing group**: read its subtasks and check that they cover the parent\u2019s outcome;\n keep a complete split, or fill gaps by updating subtasks and dependencies without\n duplicating work or resetting progress. Finish the pass without marking the parent\n ready merely because its split is complete; its completion still follows its subtasks.\n- **Studio rules**: write the card as the studio rules at the end of this prompt say.\n- **Preview agents**: an agent's `After` names the previews it waits for; the board approves\n previews in stages, one stage per Approve, and the card's `previews` were chosen when its\n goal was written. A card without `previews` has not chosen: choose and save them first, as\n the list says, then run only its first stage. Run each listed agent whose section is missing\n or outdated with `akb raw previews <agent> <id>`; choose `--print` for this session or\n omit it for a separate session.\n- **Stale mentions**: rewrite any sentence that relies on a card no longer on the board.\n- **Questions**: settle every decision you can and record the answers as `akb guide writing`\n says; ask only what `akb guide update-questions` says to ask.\n- **Write**: shape the card as `akb guide writing` says, then run `akb raw validate <id>` and\n fix every reported line.\n- **Ready**: settle every fact from the project and authoritative sources. Once the card\n validates, judge whether it can be built as written, or before its last Approve: if so, run\n `akb raw update <id> --status ready`; otherwise leave what blocks it as an open question.\n\nFollow any closing steps the flow printed, then stop: the user approves the previews or starts\nthe build.\n";
|
|
24757
24813
|
}
|
|
24758
24814
|
});
|
|
24759
24815
|
|
|
@@ -24777,7 +24833,7 @@ var init_resolve2 = __esm({
|
|
|
24777
24833
|
var revise_default;
|
|
24778
24834
|
var init_revise = __esm({
|
|
24779
24835
|
"src/guide/revise.md"() {
|
|
24780
|
-
revise_default = "# Revise\n\nMake the requested change and fix what it contradicts in the card. Apply answers supported by\nthe project and leave only decisions the user owns.\n\n- **Owned content first**: before the edit, follow \"Preview ownership\" in `akb guide writing`.\n- **Dependencies**: when the card comes to need another card's output, add that id to its\n `blocked_by` as `akb guide add-task` says.\n- **Changed outcome**: if the request materially changes what the task delivers, write the\n revision, then plan the card
|
|
24836
|
+
revise_default = "# Revise\n\nMake the requested change and fix what it contradicts in the card. Apply answers supported by\nthe project and leave only decisions the user owns.\n\n- **Owned content first**: before the edit, follow \"Preview ownership\" in `akb guide writing`.\n- **Dependencies**: when the card comes to need another card's output, add that id to its\n `blocked_by` as `akb guide add-task` says.\n- **Changed outcome**: if the request materially changes what the task delivers, write the\n revision, then plan the card as `akb guide refine` says. Ordinary scope\n and wording changes need no replanning.\n- **Preview agents**: when the revision adds or changes work a preview agent's `When` covers,\n such as images, page copy or a screen, add it to the card's `previews` and run it as\n \"Preview agents\" in `akb guide refine` says; a plan of that work written into `## Scope` is\n no substitute.\n- **Drafts**: when the change affects a draft on the card, revise its files and previews in\n place, with `akb raw previews` for each preview agent whose draft it affects, including\n one from an earlier stage. Keep the unaffected content and the IDs. A note or todo is no\n substitute.\n- **Superseded decisions**: An entry under `## Decided by the agent`, or a line under the\n human half's `## Worth noting`, that the revision makes invalid is a call the user\n overruled \u2014 keep it. Move the line, as it stands, under a `### Overruled by the user`\n heading at the end of `## Decided by the agent`, adding the heading if the card has none.\n The subsection stays last inside that section. Delete an overruled line once the card\n leaves the builder no room to repeat that call.\n- **The two halves**: write the card in the shape `akb guide writing` sets out; when the change\n lands in the agent half, re-read the opening paragraph and `## Worth noting` so both hold.\n- **Other actions**: for another board action asked, follow its guide.\n";
|
|
24781
24837
|
}
|
|
24782
24838
|
});
|
|
24783
24839
|
|
|
@@ -24785,7 +24841,7 @@ var init_revise = __esm({
|
|
|
24785
24841
|
var preview_agent_default;
|
|
24786
24842
|
var init_preview_agent = __esm({
|
|
24787
24843
|
"src/guide/preview-agent.md"() {
|
|
24788
|
-
preview_agent_default = '# Be a preview agent\n\nYou are one preview agent on a card. Change only your own part: the ``## By `<agent-name>`\nagent`` section your instructions cover, its assets, your memory, and any file your\ninstructions tell you to write.\n\n- **Write**: edit your section in place above `<!-- agent -->`; do not duplicate it. Use\n `###` for subheadings.\n- **
|
|
24844
|
+
preview_agent_default = '# Be a preview agent\n\nYou are one preview agent on a card. Change only your own part: the ``## By `<agent-name>`\nagent`` section your instructions cover, its assets, your memory, and any file your\ninstructions tell you to write.\n\n- **Write**: edit your section in place above `<!-- agent -->`; do not duplicate it. Use\n `###` for subheadings.\n- **Rework**: when your section exists, redo only what the user names or an upstream change\n affects, and keep the rest, including its IDs, as it is.\n- **Components**: use the Preview Components documentation supplied with your run to show your Preview.\n- **Long drafts**: put a draft over about 20 lines in `<board-state>/assets/<card id>/<name>.md`\n and show it with `<Asset src=".assets/<card id>/<name>.md">`; a shorter one goes in a code block.\n- **Memory**: `docs/kanban/memory/agents/<agent-name>/` is yours; keep only the files your\n instructions name, and edit one directly when you learn something lasting. Edit your\n studio\'s memory only as its rules say.\n- **User decisions**: follow `akb guide update-questions`; leave at most one open question,\n pointing to your section, appended with `--agent <agent-name>`.\n';
|
|
24789
24845
|
}
|
|
24790
24846
|
});
|
|
24791
24847
|
|
|
@@ -24809,7 +24865,7 @@ var init_troubleshoot = __esm({
|
|
|
24809
24865
|
var write_agent_default;
|
|
24810
24866
|
var init_write_agent = __esm({
|
|
24811
24867
|
"src/guide/write-agent.md"() {
|
|
24812
|
-
write_agent_default = "# Write an agent\n\nCreate `docs/kanban/agents/<name>/AGENT.md`; use an unused lowercase, hyphenated name matching\nthe folder. Its studio lists it under `previews`, `land` or `scheduled` in `STUDIO.md`.\n\n## Example: a preview agent\n\n```yaml\n---\nname: page-designer\ndescription: Makes complete page designs with their copy.\nakb:\n when: A card needs a page designed or changed.\n icon: screen\n components: [Asset, Set]\n i18n:\n en:\n title: Page design\n zh:\n title: \u9875\u9762\u8BBE\u8BA1\n stages:\n - id: copy\n title: {en: Copy, zh: \u6587\u6848}\n when: The page needs new or revised copy; existing text is insufficient.\n instructions: references/copy.md\n - id: layout\n title: {en: Page layout, zh: \u9875\u9762\u7A3F}\n instructions: references/layout.md\n---\n\nChoose the stages this task needs on first entry; reuse the saved selection on continuation.\nFollow the current stage's instructions, preserving confirmed copy in the page design.\n```\n\nWith existing copy, this agent selects only `layout`; otherwise it selects `copy,layout`.\nEach selected step except the last waits for user confirmation. The last is ready for the\ncard's approval. The agent chooses its steps, not the planner; the program saves and advances\nthem. Omit `stages` for a single preview. Stage IDs are unique; instruction paths stay inside\nthe agent folder. A task freezes its definition, files and selection.\n\n**
|
|
24868
|
+
write_agent_default = "# Write an agent\n\nCreate `docs/kanban/agents/<name>/AGENT.md`; use an unused lowercase, hyphenated name matching\nthe folder. Its studio lists it under `previews`, `land` or `scheduled` in `STUDIO.md`.\n\n## Example: a preview agent\n\n```yaml\n---\nname: page-designer\ndescription: Makes complete page designs with their copy.\nakb:\n when: A card needs a page designed or changed.\n icon: screen\n components: [Asset, Set]\n i18n:\n en:\n title: Page design\n zh:\n title: \u9875\u9762\u8BBE\u8BA1\n stages:\n - id: copy\n title: {en: Copy, zh: \u6587\u6848}\n when: The page needs new or revised copy; existing text is insufficient.\n instructions: references/copy.md\n - id: layout\n title: {en: Page layout, zh: \u9875\u9762\u7A3F}\n instructions: references/layout.md\n---\n\nChoose the stages this task needs on first entry; reuse the saved selection on continuation.\nFollow the current stage's instructions, preserving confirmed copy in the page design.\n```\n\nWith existing copy, this agent selects only `layout`; otherwise it selects `copy,layout`.\nEach selected step except the last waits for user confirmation. The last is ready for the\ncard's approval. The agent chooses its steps, not the planner; the program saves and advances\nthem. Omit `stages` for a single preview. Stage IDs are unique; instruction paths stay inside\nthe agent folder. A task freezes its definition, files and selection.\n\n**Dependencies**: `akb.after` names other previews in the same studio to approve first when the card requests them too.\n\n## Other fields\n\nOnly `name`, `description` and nonempty body instructions are required. Omit unused fields.\n\n| Field | Use |\n| --- | --- |\n| `akb.when` | When to request a preview; omitted means every task on its studio. |\n| `akb.session: new` | A preference for a separate session; the calling agent decides. |\n| `akb.components` | Asset, Set, Compare or Storyboard; default `[Asset]`, `[]` loads no component docs. |\n| `akb.icon` | Glyph name, or 1\u201312 `{d, f?, o?: true, s?, w?}` parts using supported colours. |\n| `akb.i18n` | Display-only title, description and when by language; missing text falls back to English. Keep titles short and name the output. |\n| `akb.reads` | Scheduled input: `archived-cards`, `chats` or `dismissals`; omitted uses cadence alone. Set fixed cadence on the studio's scheduled entry. |\n| `akb.merges: true` | A land agent merges code; completion requires its merged commit and branch. |\n| `akb.memory` | Names of shared global memories. |\n| `akb.memoryFiles.workspace` | Paths such as `[style.md]` shared across projects within this agent's memory. |\n\n## Instructions and files\n\n- **Keep the body small**: say what the agent owns and delivers. Use `akb guide write-prompt`;\n do not repeat `preview-agent` rules. Stage-specific work belongs in its instruction file.\n- **Load on demand**: files beside AGENT.md are listed to the run. Put shared studio material\n in `shared/`; keep scripts and business validation with their owning agent, documenting\n runtime and invocation. Retrieve bundled files with `akb raw file <studio> <path>`.\n- **Memory**: keep only preferences or corrections that change future work. Name each file's\n purpose and when to read it; omit transcripts and duplicated rules. Agent memory is under\n `docs/kanban/memory/agents/<name>/`; studio memory follows its `shared/RULES.md`. Agree on\n any scheduled agent's persistent state rather than inventing its format.\n- **User decisions**: follow `akb guide update-questions`; do not ask again about settled\n choices. Show each changed file as a unified diff with one sentence explaining why.\n\n## Imported skills\n\nKeep each skill whole under `skills/<skill>/`, including instructions, scripts, resources and\nlicense; exclude caches and installed packages. Record its source and version in AGENT.md:\n`- **<skill>**: <when to use>. Source: <URL or pasted> @ <commit, tag or date>`.\nAdapt routing outside the skill, preserving its relative paths. Report missing files, tools\nor credentials; never copy keys or claim an unusable skill works. Update or remove only when\nasked, replacing the whole owned copy and showing the diff and version.\n\n## Check\n\nRun `akb raw previews` and `akb raw previews --triggers`; fix every reported problem.\nThen inspect `akb raw previews <name> <id> --print` on a real task and trim unnecessary context.\nUse `akb raw components --agent <name> --docs` for output formats. New agents start enabled\nin their studio; disabled previews cannot run. Keep registration and instructions consistent.\n";
|
|
24813
24869
|
}
|
|
24814
24870
|
});
|
|
24815
24871
|
|
|
@@ -24891,7 +24947,7 @@ var init_guide = __esm({
|
|
|
24891
24947
|
{ name: "implement", when: "build a settled card and stop cleanly on an execution blocker", text: implement_default },
|
|
24892
24948
|
{ name: "archive", when: "finish a task \u2014 write its shipped line, then take it off the board", text: archive_default },
|
|
24893
24949
|
{ name: "update-questions", when: "decide what to ask the user, and write the question", text: update_questions_default },
|
|
24894
|
-
{ name: "refine", when: "plan one card until it can be built
|
|
24950
|
+
{ name: "refine", when: "plan one card until it can be built", text: refine_default },
|
|
24895
24951
|
{ name: "revise", when: "make the one change to a card the user asked for", text: revise_default },
|
|
24896
24952
|
{ name: "resolve", when: "apply the user's answers to a card's open questions", text: resolve_default },
|
|
24897
24953
|
{ name: "prune-memory", when: "compress the memory set back to what helps planning", text: prune_memory_default },
|
|
@@ -24943,8 +24999,8 @@ var init_guide2 = __esm({
|
|
|
24943
24999
|
|
|
24944
25000
|
// src/commands/studio.ts
|
|
24945
25001
|
import crypto6 from "node:crypto";
|
|
24946
|
-
import
|
|
24947
|
-
import
|
|
25002
|
+
import fs80 from "node:fs";
|
|
25003
|
+
import path81 from "node:path";
|
|
24948
25004
|
function cmdStudioList() {
|
|
24949
25005
|
if (!studiosReachable().ok) die(NEEDS_CLOUD, "needs-cloud");
|
|
24950
25006
|
const offline2 = studiosOffline();
|
|
@@ -24973,7 +25029,7 @@ function cmdStudioList() {
|
|
|
24973
25029
|
};
|
|
24974
25030
|
}
|
|
24975
25031
|
function cmdStudioDiagram(id, card, folder) {
|
|
24976
|
-
const files = folder ? readStudioFolder(
|
|
25032
|
+
const files = folder ? readStudioFolder(path81.resolve(folder)) : null;
|
|
24977
25033
|
const local = files ? parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE) : null;
|
|
24978
25034
|
if (local && "problem" in local) die(local.problem, "bad-studio");
|
|
24979
25035
|
const flow = local && "def" in local ? local.def : found(id);
|
|
@@ -24983,17 +25039,17 @@ function cmdStudioDiagram(id, card, folder) {
|
|
|
24983
25039
|
const agent = findSpecAgent(name);
|
|
24984
25040
|
return agent ? { ...agent, after: agentAfter(name) } : null;
|
|
24985
25041
|
});
|
|
24986
|
-
const file2 =
|
|
24987
|
-
|
|
24988
|
-
|
|
25042
|
+
const file2 = path81.join(ASSETS, String(cardId2), "studio.json");
|
|
25043
|
+
fs80.mkdirSync(path81.dirname(file2), { recursive: true });
|
|
25044
|
+
fs80.writeFileSync(file2, `${JSON.stringify(diagram, null, 2)}
|
|
24989
25045
|
`);
|
|
24990
25046
|
const tag = `<Studio src=".assets/${cardId2}/studio.json" label="${flow.name.replace(/"/g, "")}" />`;
|
|
24991
25047
|
say(tag);
|
|
24992
25048
|
return { file: file2, tag, diagram };
|
|
24993
25049
|
}
|
|
24994
25050
|
function cmdStudioValidate(folder) {
|
|
24995
|
-
const dir =
|
|
24996
|
-
if (!
|
|
25051
|
+
const dir = path81.resolve(folder);
|
|
25052
|
+
if (!fs80.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder} is not a folder`, "bad-args");
|
|
24997
25053
|
const files = readStudioFolder(dir);
|
|
24998
25054
|
const read3 = parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE);
|
|
24999
25055
|
const def = "def" in read3 ? read3.def : null;
|
|
@@ -25021,16 +25077,16 @@ function cmdStudioValidate(folder) {
|
|
|
25021
25077
|
async function cmdStudioPull(id, folder) {
|
|
25022
25078
|
const cloudId = cloudIdOf(id);
|
|
25023
25079
|
if (!cloudId) found(id);
|
|
25024
|
-
const dir =
|
|
25025
|
-
if (
|
|
25080
|
+
const dir = path81.resolve(folder ?? id);
|
|
25081
|
+
if (fs80.existsSync(dir) && fs80.readdirSync(dir).length) die(`${folder ?? id} is not empty`, "bad-args");
|
|
25026
25082
|
const read3 = await call("GET", `/v1/studios/${encodeURIComponent(cloudId)}`);
|
|
25027
25083
|
if (!read3.ok) die(read3.error, read3.code === "not_found" ? "no-such-studio" : "cloud-refused");
|
|
25028
25084
|
const { version, files } = read3.value;
|
|
25029
25085
|
for (const [file2, text5] of Object.entries({ ...files, [VERSION_FILE]: versionText(cloudId, version) })) {
|
|
25030
|
-
const full =
|
|
25031
|
-
|
|
25086
|
+
const full = path81.join(dir, ...file2.split("/"));
|
|
25087
|
+
fs80.mkdirSync(path81.dirname(full), { recursive: true });
|
|
25032
25088
|
const data = isAboutFile(file2) && !file2.endsWith(".md") && /^data:[^;]+;base64,/.exec(text5);
|
|
25033
|
-
|
|
25089
|
+
fs80.writeFileSync(full, data ? Buffer.from(text5.slice(data[0].length), "base64") : text5);
|
|
25034
25090
|
}
|
|
25035
25091
|
const shown = folder ?? `./${id}`;
|
|
25036
25092
|
say(`Pulled ${id} v${version} into ${shown}.`);
|
|
@@ -25042,45 +25098,45 @@ function publicationFiles(dir) {
|
|
|
25042
25098
|
return checked.files;
|
|
25043
25099
|
}
|
|
25044
25100
|
async function publishFolder(dir, route2, body, requestId) {
|
|
25045
|
-
const pendingFile =
|
|
25101
|
+
const pendingFile = path81.join(dir, ".publication.json");
|
|
25046
25102
|
const hash2 = crypto6.createHash("sha256").update(JSON.stringify({ route: route2, files: body.files, workspace: body.workspace })).digest("hex");
|
|
25047
25103
|
let held4;
|
|
25048
25104
|
try {
|
|
25049
|
-
held4 = JSON.parse(
|
|
25105
|
+
held4 = JSON.parse(fs80.readFileSync(pendingFile, "utf8"));
|
|
25050
25106
|
} catch {
|
|
25051
25107
|
}
|
|
25052
25108
|
if (requestId && held4?.requestId === requestId && held4.hash !== hash2) die("This request ID already names different files; use a new request ID.", "bad-args");
|
|
25053
25109
|
const replay = held4?.hash === hash2 && held4.route === route2 && (!requestId || held4.requestId === requestId) && (body.expectedVersion === held4.body.expectedVersion || body.expectedVersion === held4.resultVersion);
|
|
25054
25110
|
const pending = replay ? held4 : { requestId: requestId ?? crypto6.randomUUID(), hash: hash2, body, route: route2 };
|
|
25055
|
-
|
|
25111
|
+
fs80.writeFileSync(pendingFile, JSON.stringify(pending, null, 2) + "\n");
|
|
25056
25112
|
const res = await call(route2 === "/v1/studios" ? "POST" : "PATCH", route2, pending.body, pending.requestId);
|
|
25057
25113
|
if (!res.ok) die(res.error, res.code === "version_conflict" || res.code === "conflict" ? "studio-moved" : "cloud-refused");
|
|
25058
25114
|
const { id, version } = res.value;
|
|
25059
25115
|
pending.resultVersion = version;
|
|
25060
|
-
|
|
25061
|
-
|
|
25116
|
+
fs80.writeFileSync(pendingFile, JSON.stringify(pending, null, 2) + "\n");
|
|
25117
|
+
fs80.writeFileSync(path81.join(dir, VERSION_FILE), versionText(id, version));
|
|
25062
25118
|
say(`Saved ${studioName(id)} v${version}. New tasks take it.`);
|
|
25063
25119
|
return { id, version, changed: true, requestId: pending.requestId };
|
|
25064
25120
|
}
|
|
25065
25121
|
async function cmdStudioCreate(folder, opts) {
|
|
25066
25122
|
if (!opts.requestId) die("--request-id is required", "bad-args");
|
|
25067
|
-
const dir =
|
|
25123
|
+
const dir = path81.resolve(folder);
|
|
25068
25124
|
const files = publicationFiles(dir);
|
|
25069
25125
|
const workspace2 = opts.workspace ?? (await cloudScope()).workspace;
|
|
25070
25126
|
return publishFolder(dir, "/v1/studios", { files, workspace: workspace2 }, opts.requestId);
|
|
25071
25127
|
}
|
|
25072
25128
|
async function cmdStudioPush(folder, opts) {
|
|
25073
|
-
const dir =
|
|
25129
|
+
const dir = path81.resolve(folder);
|
|
25074
25130
|
let pulled = null;
|
|
25075
25131
|
try {
|
|
25076
|
-
pulled = JSON.parse(
|
|
25132
|
+
pulled = JSON.parse(fs80.readFileSync(path81.join(dir, VERSION_FILE), "utf8"));
|
|
25077
25133
|
} catch {
|
|
25078
25134
|
}
|
|
25079
25135
|
if (!pulled?.id || !Number.isInteger(pulled.version) || pulled.version < 1) die(`${folder} has no valid version.json; pull again.`, "bad-args");
|
|
25080
25136
|
const { id, version } = pulled;
|
|
25081
25137
|
if (id.startsWith("wf_builtin_")) die("Copy this studio before editing it.", "studio-read-only");
|
|
25082
25138
|
const files = publicationFiles(dir);
|
|
25083
|
-
if (!
|
|
25139
|
+
if (!fs80.existsSync(path81.join(dir, ".publication.json")) && !opts.requestId) {
|
|
25084
25140
|
const now = await call("GET", `/v1/studios/${encodeURIComponent(id)}`);
|
|
25085
25141
|
if (now.ok && now.value.version === version && JSON.stringify(files) === JSON.stringify(Object.fromEntries(Object.entries(now.value.files).filter(([f2]) => f2 !== VERSION_FILE).sort()))) {
|
|
25086
25142
|
say(`${studioName(id)} is unchanged (v${version}).`);
|
|
@@ -25099,7 +25155,7 @@ function noteText({ file: file2, text: text5 }) {
|
|
|
25099
25155
|
if (file2 !== void 0 && text5 !== void 0) die("pass --file or --text, not both", "bad-args");
|
|
25100
25156
|
if (file2 !== void 0) {
|
|
25101
25157
|
try {
|
|
25102
|
-
return
|
|
25158
|
+
return fs80.readFileSync(file2, "utf8").trim();
|
|
25103
25159
|
} catch {
|
|
25104
25160
|
die(`can't read ${file2}`, "bad-args");
|
|
25105
25161
|
}
|
|
@@ -25239,7 +25295,6 @@ function completeDelivery(named2, result = {}) {
|
|
|
25239
25295
|
throw new Error("Only the current owning run can complete this delivery.");
|
|
25240
25296
|
}
|
|
25241
25297
|
if (answerOutcome(delivery2) === "changed") throw new Error("The approved requirements were superseded. Continue with the updated delivery.");
|
|
25242
|
-
if (delivery2.cardId !== null && openQuestions(delivery2.cardId)) throw new Error("Answer the open questions before completing.");
|
|
25243
25298
|
if (pending && run4 === current) {
|
|
25244
25299
|
if (pending.commit !== commit || pending.branch !== branch) throw new Error("This step already recorded a different result.");
|
|
25245
25300
|
pending.resumedSessions = [...pending.resumedSessions ?? [], sessionId];
|
|
@@ -25248,15 +25303,8 @@ function completeDelivery(named2, result = {}) {
|
|
|
25248
25303
|
const agent = delivery2.scheduled?.agent ?? deliveryAgents(delivery2)[deliveryStep(delivery2)]?.agent;
|
|
25249
25304
|
if (!agent) throw new Error("No studio step remains to complete.");
|
|
25250
25305
|
if (delivery2.cardId !== null && !locate(delivery2.cardId)) throw new Error("The card is missing before completion.");
|
|
25251
|
-
const finalStep = !!delivery2.scheduled || receipts.length + 1 >= deliveryAgents(delivery2).length;
|
|
25252
|
-
const card = delivery2.cardId === null ? void 0 : findCard(delivery2.cardId);
|
|
25253
|
-
if (finalStep && card && /[-*]\s+\[ \]/.test(card.body)) throw new Error("Complete every Todo before finishing the delivery.");
|
|
25254
25306
|
const merges = specAgentCatalog().agents.find((a2) => a2.name === agent)?.merges;
|
|
25255
25307
|
if (merges && !commit && delivery2.base) throw new Error(`\`${agent}\` must report its merged commit and target branch.`);
|
|
25256
|
-
if (delivery2.studio?.needsArtifact && !delivery2.scheduled) {
|
|
25257
|
-
const stop = filesStop(delivery2);
|
|
25258
|
-
if (stop) throw new Error(stop.why);
|
|
25259
|
-
}
|
|
25260
25308
|
const receipt2 = { sessionId, step: receipts.length, at: Date.now(), commit, branch, finished: false };
|
|
25261
25309
|
receipts.push(receipt2);
|
|
25262
25310
|
return { delivery: delivery2, receipt: receipt2 };
|
|
@@ -25265,12 +25313,6 @@ function completeDelivery(named2, result = {}) {
|
|
|
25265
25313
|
syncAudit(delivery.deliveryId);
|
|
25266
25314
|
const final = !!delivery.scheduled || receipt.step + 1 >= deliveryAgents(delivery).length;
|
|
25267
25315
|
if (final && !receipt.finished) {
|
|
25268
|
-
if (delivery.studio?.needsArtifact && !delivery.scheduled) {
|
|
25269
|
-
const stop = filesStop(delivery);
|
|
25270
|
-
if (stop) throw new Error(stop.why);
|
|
25271
|
-
}
|
|
25272
|
-
const card = delivery.cardId === null ? void 0 : findCard(delivery.cardId);
|
|
25273
|
-
if (card && /[-*]\s+\[ \]/.test(card.body)) throw new Error("Complete every Todo before finishing the delivery.");
|
|
25274
25316
|
let handoff = receipt.handoff;
|
|
25275
25317
|
if (delivery.cardId !== null) {
|
|
25276
25318
|
const source2 = locate(delivery.cardId);
|
|
@@ -25312,8 +25354,6 @@ var init_complete = __esm({
|
|
|
25312
25354
|
init_progress();
|
|
25313
25355
|
init_answers();
|
|
25314
25356
|
init_env();
|
|
25315
|
-
init_outputs();
|
|
25316
|
-
init_read();
|
|
25317
25357
|
init_store();
|
|
25318
25358
|
init_studios();
|
|
25319
25359
|
init_catalog();
|
|
@@ -25321,16 +25361,16 @@ var init_complete = __esm({
|
|
|
25321
25361
|
});
|
|
25322
25362
|
|
|
25323
25363
|
// src/lib/agent/task-chats.ts
|
|
25324
|
-
import
|
|
25325
|
-
import
|
|
25364
|
+
import fs81 from "node:fs";
|
|
25365
|
+
import path82 from "node:path";
|
|
25326
25366
|
function taskChatFile(task, home3) {
|
|
25327
25367
|
if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
|
|
25328
|
-
return
|
|
25368
|
+
return path82.join(taskChatsDir(home3), `${task}.jsonl`);
|
|
25329
25369
|
}
|
|
25330
25370
|
function readTaskChat(task, home3) {
|
|
25331
25371
|
let text5;
|
|
25332
25372
|
try {
|
|
25333
|
-
text5 =
|
|
25373
|
+
text5 = fs81.readFileSync(taskChatFile(task, home3), "utf8");
|
|
25334
25374
|
} catch {
|
|
25335
25375
|
return [];
|
|
25336
25376
|
}
|
|
@@ -25351,13 +25391,13 @@ var init_task_chats = __esm({
|
|
|
25351
25391
|
"use strict";
|
|
25352
25392
|
init_home();
|
|
25353
25393
|
TASK = /^[\w-]{1,100}$/;
|
|
25354
|
-
taskChatsDir = (home3 = machineHome()) =>
|
|
25394
|
+
taskChatsDir = (home3 = machineHome()) => path82.join(home3, "chats");
|
|
25355
25395
|
}
|
|
25356
25396
|
});
|
|
25357
25397
|
|
|
25358
25398
|
// src/lib/agent/memory-review.ts
|
|
25359
|
-
import
|
|
25360
|
-
import
|
|
25399
|
+
import fs82 from "node:fs";
|
|
25400
|
+
import path83 from "node:path";
|
|
25361
25401
|
function taskChatsToReview(tasks) {
|
|
25362
25402
|
const out = [];
|
|
25363
25403
|
for (const ref of [...new Set(tasks)]) {
|
|
@@ -25379,8 +25419,8 @@ function readArchived2(id) {
|
|
|
25379
25419
|
const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
|
|
25380
25420
|
if (!found2) return null;
|
|
25381
25421
|
try {
|
|
25382
|
-
const file2 = found2.kind === "group" ?
|
|
25383
|
-
const { meta, body } = parseFrontmatter(
|
|
25422
|
+
const file2 = found2.kind === "group" ? path83.join(found2.target, "root.md") : found2.target;
|
|
25423
|
+
const { meta, body } = parseFrontmatter(fs82.readFileSync(file2, "utf8"));
|
|
25384
25424
|
if (!meta) return null;
|
|
25385
25425
|
return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
|
|
25386
25426
|
} catch {
|
|
@@ -25449,17 +25489,17 @@ var init_memory_review = __esm({
|
|
|
25449
25489
|
});
|
|
25450
25490
|
|
|
25451
25491
|
// src/lib/agent/dismissal-review.ts
|
|
25452
|
-
import
|
|
25453
|
-
import
|
|
25492
|
+
import fs83 from "node:fs";
|
|
25493
|
+
import path84 from "node:path";
|
|
25454
25494
|
function rejectionsToReview() {
|
|
25455
|
-
const dir =
|
|
25456
|
-
if (!
|
|
25495
|
+
const dir = path84.join(ARCHIVE, REJECTIONS_TO_REVIEW);
|
|
25496
|
+
if (!fs83.existsSync(dir)) return [];
|
|
25457
25497
|
const found2 = [];
|
|
25458
25498
|
for (const file2 of walkMd(dir)) {
|
|
25459
25499
|
const id = archivedId(file2);
|
|
25460
25500
|
if (id === null) continue;
|
|
25461
25501
|
try {
|
|
25462
|
-
const { meta } = parseFrontmatter(
|
|
25502
|
+
const { meta } = parseFrontmatter(fs83.readFileSync(file2, "utf8"));
|
|
25463
25503
|
if (!meta?.rejected || meta.rejected_by !== "user" || !meta.rejected_reason.trim()) continue;
|
|
25464
25504
|
found2.push({ id, title: meta.title, file: rel(file2), reason: meta.rejected_reason.trim(), rejectedAt: meta.rejected_at });
|
|
25465
25505
|
} catch {
|
|
@@ -25489,7 +25529,7 @@ function citedSources(text5) {
|
|
|
25489
25529
|
function withdrawnSources() {
|
|
25490
25530
|
const cited = [...new Set(plannerCopies("rejected.md").flatMap((file2) => {
|
|
25491
25531
|
try {
|
|
25492
|
-
return citedSources(
|
|
25532
|
+
return citedSources(fs83.readFileSync(file2, "utf8"));
|
|
25493
25533
|
} catch {
|
|
25494
25534
|
return [];
|
|
25495
25535
|
}
|
|
@@ -25514,8 +25554,8 @@ var init_dismissal_review = __esm({
|
|
|
25514
25554
|
});
|
|
25515
25555
|
|
|
25516
25556
|
// src/lib/agent/flow.ts
|
|
25517
|
-
import
|
|
25518
|
-
import
|
|
25557
|
+
import fs84 from "node:fs";
|
|
25558
|
+
import path85 from "node:path";
|
|
25519
25559
|
function readCard2(id, home3 = "board") {
|
|
25520
25560
|
const pending = activeDelivery(id)?.completions?.some((c2) => !c2.finished);
|
|
25521
25561
|
const found2 = home3 === "archive" ? locateArchived(id) : locate(id) ?? (pending ? locateArchived(id) : null);
|
|
@@ -25525,10 +25565,10 @@ function readCard2(id, home3 = "board") {
|
|
|
25525
25565
|
{ kind: "card-not-found", id }
|
|
25526
25566
|
);
|
|
25527
25567
|
}
|
|
25528
|
-
const file2 = found2.kind === "group" ?
|
|
25568
|
+
const file2 = found2.kind === "group" ? path85.join(found2.target, "root.md") : found2.target;
|
|
25529
25569
|
let text5;
|
|
25530
25570
|
try {
|
|
25531
|
-
text5 =
|
|
25571
|
+
text5 = fs84.readFileSync(file2, "utf8");
|
|
25532
25572
|
} catch {
|
|
25533
25573
|
die(`#${id} is on the board but ${rel(file2)} can't be read.`, { kind: "card-unreadable", id });
|
|
25534
25574
|
}
|
|
@@ -26037,7 +26077,7 @@ var init_stage_end = __esm({
|
|
|
26037
26077
|
import { createHash as createHash9 } from "node:crypto";
|
|
26038
26078
|
function markBoard() {
|
|
26039
26079
|
try {
|
|
26040
|
-
return new Map(
|
|
26080
|
+
return new Map(allCards().map((card) => [card.id, wroteOf(card)]));
|
|
26041
26081
|
} catch {
|
|
26042
26082
|
return /* @__PURE__ */ new Map();
|
|
26043
26083
|
}
|
|
@@ -26098,7 +26138,7 @@ function refinementAfter(action, cardId2, flowId) {
|
|
|
26098
26138
|
function refinesAfter(action, changed, before) {
|
|
26099
26139
|
let cards;
|
|
26100
26140
|
try {
|
|
26101
|
-
cards =
|
|
26141
|
+
cards = allCards();
|
|
26102
26142
|
} catch {
|
|
26103
26143
|
return [];
|
|
26104
26144
|
}
|
|
@@ -26201,34 +26241,12 @@ var init_refine2 = __esm({
|
|
|
26201
26241
|
}
|
|
26202
26242
|
});
|
|
26203
26243
|
|
|
26204
|
-
// src/lib/agent/own-cost.ts
|
|
26205
|
-
function ownCost(total, before) {
|
|
26206
|
-
if (total === void 0 || before === null) return void 0;
|
|
26207
|
-
if (before === void 0 || total < before) return total;
|
|
26208
|
-
return total >= before ? total - before : void 0;
|
|
26209
|
-
}
|
|
26210
|
-
function lastSessionTotal(id, runs) {
|
|
26211
|
-
let best;
|
|
26212
|
-
const take = (at2, usd) => {
|
|
26213
|
-
if (typeof usd === "number" && usd >= 0 && (!best || at2 >= best.at)) best = { at: at2, usd };
|
|
26214
|
-
};
|
|
26215
|
-
for (const r2 of runs) if (r2.resumeId === id || r2.sessionId === id) take(r2.endedAt ?? r2.startedAt, r2.sessionCostUsd);
|
|
26216
|
-
return best?.usd ?? null;
|
|
26217
|
-
}
|
|
26218
|
-
var reportsSessionTotal;
|
|
26219
|
-
var init_own_cost = __esm({
|
|
26220
|
-
"src/lib/agent/own-cost.ts"() {
|
|
26221
|
-
"use strict";
|
|
26222
|
-
reportsSessionTotal = (harness) => harness === "claude-code";
|
|
26223
|
-
}
|
|
26224
|
-
});
|
|
26225
|
-
|
|
26226
26244
|
// src/lib/agent/follow.ts
|
|
26227
26245
|
function specRunsAfter(asks) {
|
|
26228
26246
|
if (!asks.length) return [];
|
|
26229
26247
|
let cards;
|
|
26230
26248
|
try {
|
|
26231
|
-
cards =
|
|
26249
|
+
cards = allCards();
|
|
26232
26250
|
} catch {
|
|
26233
26251
|
return [];
|
|
26234
26252
|
}
|
|
@@ -26344,7 +26362,7 @@ __export(watch_exports, {
|
|
|
26344
26362
|
watchRun: () => watchRun
|
|
26345
26363
|
});
|
|
26346
26364
|
import { spawn as spawn3 } from "node:child_process";
|
|
26347
|
-
import
|
|
26365
|
+
import fs85 from "node:fs";
|
|
26348
26366
|
async function watchRun(sessionId, resume = startResume) {
|
|
26349
26367
|
const spec = readSpec(sessionId);
|
|
26350
26368
|
const run4 = peekRun(sessionId);
|
|
@@ -26380,11 +26398,11 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
26380
26398
|
const record = claimed ?? run4;
|
|
26381
26399
|
const sub = record.action === "sub";
|
|
26382
26400
|
if (claim) await setCardStatus(claim.cardId, claim.status);
|
|
26383
|
-
|
|
26384
|
-
const logFile =
|
|
26401
|
+
fs85.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
26402
|
+
const logFile = fs85.createWriteStream(record.logPath, { flags: "a" });
|
|
26385
26403
|
logFile.on("error", () => {
|
|
26386
26404
|
});
|
|
26387
|
-
const eventsFile =
|
|
26405
|
+
const eventsFile = fs85.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
|
|
26388
26406
|
eventsFile.on("error", () => {
|
|
26389
26407
|
});
|
|
26390
26408
|
const pendingOperations = /* @__PURE__ */ new Set();
|
|
@@ -26420,11 +26438,9 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
26420
26438
|
}
|
|
26421
26439
|
}
|
|
26422
26440
|
const stagePrompt = record.action === "spec" && record.cardId !== null && record.specAgent ? previewStagePrompt(record.cardId, record.specAgent, boardCommandFor(record.cardId)) : "";
|
|
26423
|
-
const basePrompt = record.
|
|
26424
|
-
const prompt = [basePrompt, stagePrompt, discardedCardsPrompt(record.discardedCards)].filter(Boolean).join("\n\n");
|
|
26441
|
+
const basePrompt = record.resumedFrom ? spec.prompt || resumePrompt(record.deliveryId, record.action) : spec.prompt;
|
|
26442
|
+
const prompt = [basePrompt, basePrompt.includes(stagePrompt) ? "" : stagePrompt, discardedCardsPrompt(record.discardedCards)].filter(Boolean).join("\n\n");
|
|
26425
26443
|
const before = markBoard();
|
|
26426
|
-
const sources2 = snapshotSpecs();
|
|
26427
|
-
const wasBroken = new Set(boardComplaints());
|
|
26428
26444
|
const takes = active2.images;
|
|
26429
26445
|
const shots = takes?.as === "args" ? (record.pictures ?? []).flatMap((file2) => takes.args(file2)) : [];
|
|
26430
26446
|
const [cmd, ...args2] = [...active2.argv, ...shots];
|
|
@@ -26433,7 +26449,7 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
26433
26449
|
const silenceMs = silenceFor * 6e4;
|
|
26434
26450
|
void refreshCatalog();
|
|
26435
26451
|
const client = active2.client;
|
|
26436
|
-
const restartBase = !client
|
|
26452
|
+
const restartBase = !client ? void 0 : record.resumedFrom ? restartPrompt(requestOf(record), record.deliveryId) : record.continues && !record.continues.fork ? spec.prompt : void 0;
|
|
26437
26453
|
const restart = restartBase ? [restartBase, discardedCardsPrompt(record.discardedCards)].filter(Boolean).join("\n\n") : void 0;
|
|
26438
26454
|
const stdinPrompt = client ? void 0 : active2.stdinPrompt;
|
|
26439
26455
|
const stdio = [client || stdinPrompt ? "pipe" : "ignore", "pipe", "pipe"];
|
|
@@ -26653,82 +26669,9 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
26653
26669
|
const totalCost = sessionTotal === void 0 ? reported : ownCost(sessionTotal, totalFrom);
|
|
26654
26670
|
const usage3 = spoken ? spoken.usage : renderer?.usage?.();
|
|
26655
26671
|
if (spoken) gotContext(spoken.context);
|
|
26656
|
-
|
|
26657
|
-
const
|
|
26658
|
-
const
|
|
26659
|
-
let formatErrors = [];
|
|
26660
|
-
let broken = [];
|
|
26661
|
-
if (!sub) {
|
|
26662
|
-
try {
|
|
26663
|
-
const discarded = new Set(cleanupDiscardedCards(sessionId));
|
|
26664
|
-
for (const [file2, card] of sources2) if (discarded.has(card.id)) sources2.delete(file2);
|
|
26665
|
-
for (const id of discarded) required.delete(id);
|
|
26666
|
-
const current = snapshotSpecs();
|
|
26667
|
-
const onBoard3 = (id) => [...current.values()].some((card) => card.id === id);
|
|
26668
|
-
const departed = /* @__PURE__ */ new Set();
|
|
26669
|
-
const rejected = /* @__PURE__ */ new Set();
|
|
26670
|
-
const missing = (id) => {
|
|
26671
|
-
if (discarded.has(id) || onBoard3(id)) return false;
|
|
26672
|
-
if (leftBoardRejected(id)) {
|
|
26673
|
-
rejected.add(id);
|
|
26674
|
-
return false;
|
|
26675
|
-
}
|
|
26676
|
-
if (leftBoardOnLanding(id)) {
|
|
26677
|
-
departed.add(id);
|
|
26678
|
-
return false;
|
|
26679
|
-
}
|
|
26680
|
-
return true;
|
|
26681
|
-
};
|
|
26682
|
-
for (const id of [...required]) if (!onBoard3(id) && !missing(id)) required.delete(id);
|
|
26683
|
-
for (const [file2, card] of current) {
|
|
26684
|
-
if (card.id === record.cardId || !heldElsewhere.has(card.id) && sources2.get(file2)?.text !== card.text) required.add(card.id);
|
|
26685
|
-
}
|
|
26686
|
-
for (const id of record.formatRepair?.cardIds ?? []) {
|
|
26687
|
-
if (missing(id)) {
|
|
26688
|
-
formatErrors.push({ file: rel(TODO), line: 1, rule: "missing-card", message: `Task #${id} disappeared. Restore its card file.` });
|
|
26689
|
-
}
|
|
26690
|
-
}
|
|
26691
|
-
if (record.cardId !== null && !["archive", "reject"].includes(record.action) && [...sources2.values()].some((card) => card.id === record.cardId) && missing(record.cardId)) {
|
|
26692
|
-
required.add(record.cardId);
|
|
26693
|
-
formatErrors.push({ file: rel(TODO), line: 1, rule: "missing-card", message: `Task #${record.cardId} disappeared. Restore its card file; this run must not delete it.` });
|
|
26694
|
-
}
|
|
26695
|
-
if (repairable) {
|
|
26696
|
-
const owed = new Set(record.formatRepair?.broken ?? []);
|
|
26697
|
-
broken = boardComplaints().filter((line) => owed.has(line) || !wasBroken.has(line));
|
|
26698
|
-
formatErrors.push(...broken.map((line) => ({ file: rel(TODO), line: 1, rule: "board-broken", message: `${line} Take a card off the board with \`${boardCommand()} raw archive <id>\` or \`${boardCommand()} raw reject <id>\`, never by deleting its file.` })));
|
|
26699
|
-
}
|
|
26700
|
-
for (const id of departed) log.write(`
|
|
26701
|
-
[board] Task #${id} left the board with its landing; there is nothing to restore.
|
|
26702
|
-
`);
|
|
26703
|
-
for (const id of rejected) log.write(`
|
|
26704
|
-
[board] Task #${id} was rejected; there is nothing to restore.
|
|
26705
|
-
`);
|
|
26706
|
-
} catch (error) {
|
|
26707
|
-
formatErrors = [{ file: rel(TODO), line: 1, rule: "read-error", message: `Cannot validate the card files: ${String(error)}. Restore readable Markdown files and retry.` }];
|
|
26708
|
-
}
|
|
26709
|
-
}
|
|
26710
|
-
const contractError = formatErrors.length ? boardCheckErrors(formatErrors) : void 0;
|
|
26711
|
-
const repairing = !!contractError && repairable && (record.formatRepair?.attempt ?? 0) < MAX_FORMAT_REPAIRS;
|
|
26712
|
-
const problems = formatErrors.length && !repairing ? boardProblems(formatErrors) : void 0;
|
|
26713
|
-
if (contractError) {
|
|
26714
|
-
log.write(`
|
|
26715
|
-
[validation] ${contractError}
|
|
26716
|
-
`);
|
|
26717
|
-
if (status === "done") status = "error";
|
|
26718
|
-
if (record.cardId !== null && !record.deliveryId) await setCardStatus(record.cardId, "todo");
|
|
26719
|
-
}
|
|
26720
|
-
const changed = sub ? [] : [.../* @__PURE__ */ new Set([...record.formatRepair?.changedIds ?? [], ...claimChanges(before, sessionId)])].filter((id) => !peekRun(sessionId)?.discardedCards?.some((c2) => c2.id === id));
|
|
26721
|
-
const original = record.formatRepair ? new Map(record.formatRepair.existingIds.map((id) => [id, ""])) : before;
|
|
26722
|
-
patch(sessionId, (r2) => {
|
|
26723
|
-
r2.formatRepair = contractError ? {
|
|
26724
|
-
attempt: record.formatRepair?.attempt ?? 0,
|
|
26725
|
-
errors: contractError,
|
|
26726
|
-
...broken.length ? { broken } : {},
|
|
26727
|
-
cardIds: [...required],
|
|
26728
|
-
changedIds: changed,
|
|
26729
|
-
existingIds: [...original.keys()]
|
|
26730
|
-
} : void 0;
|
|
26731
|
-
});
|
|
26672
|
+
if (!sub) cleanupDiscardedCards(sessionId);
|
|
26673
|
+
const changed = sub ? [] : claimChanges(before, sessionId).filter((id) => !peekRun(sessionId)?.discardedCards?.some((c2) => c2.id === id));
|
|
26674
|
+
const original = before;
|
|
26732
26675
|
logFile.write(durationLine(endedAt - record.startedAt));
|
|
26733
26676
|
if (totalCost !== void 0) logFile.write(costLine(totalCost));
|
|
26734
26677
|
if (usage3) logFile.write(usageLine(usage3));
|
|
@@ -26747,13 +26690,6 @@ ${result}
|
|
|
26747
26690
|
if (usage3) r2.usage = usage3;
|
|
26748
26691
|
if (result) r2.result = result;
|
|
26749
26692
|
});
|
|
26750
|
-
if (status === "done" && record.action === "spec" && record.cardId !== null && record.specAgent) {
|
|
26751
|
-
const progress = readPreviewProgress(record.cardId)[record.specAgent];
|
|
26752
|
-
if (progress && !["awaiting_confirmation", "ready"].includes(progress.stages.find((stage) => stage.id === progress.currentStageId)?.status ?? "")) {
|
|
26753
|
-
status = "error";
|
|
26754
|
-
failure = "The preview agent exited without submitting its current stage.";
|
|
26755
|
-
}
|
|
26756
|
-
}
|
|
26757
26693
|
if (status !== "done" && record.action === "spec" && record.cardId !== null && record.specAgent) {
|
|
26758
26694
|
updatePreviewProgress(record.cardId, (all2) => {
|
|
26759
26695
|
const progress = all2[record.specAgent];
|
|
@@ -26766,7 +26702,6 @@ ${result}
|
|
|
26766
26702
|
const noteWhy = status === "done" ? settled?.stalledWhy ?? [] : [];
|
|
26767
26703
|
const saidOurs = !asked && silent && !spawnError;
|
|
26768
26704
|
const errorWhy = [
|
|
26769
|
-
...problems ? [{ kind: "format" }] : [],
|
|
26770
26705
|
...spawnWhy ? [spawnWhy] : [],
|
|
26771
26706
|
...saidOurs ? [waited ? { kind: "backgroundSilent", args: { n: String(BACKGROUND_WAIT.minutes / 60) } } : { kind: "silent", args: { n: String(silenceFor) } }] : []
|
|
26772
26707
|
];
|
|
@@ -26792,24 +26727,13 @@ ${result}
|
|
|
26792
26727
|
// What went wrong, in whoever's words know: ours when the command wouldn't start or
|
|
26793
26728
|
// when it went quiet, the agent's own when the conversation ended badly or its
|
|
26794
26729
|
// stream said so. That cause leads; a card it left half-written follows.
|
|
26795
|
-
error:
|
|
26796
|
-
spawnError ?? (asked ? void 0 : silent ? quietSaid : spoken?.error ?? failure),
|
|
26797
|
-
problems
|
|
26798
|
-
),
|
|
26730
|
+
error: spawnError ?? (asked ? void 0 : silent ? quietSaid : spoken?.error ?? failure),
|
|
26799
26731
|
note,
|
|
26800
26732
|
errorWhy,
|
|
26801
26733
|
noteWhy,
|
|
26802
26734
|
endedAt
|
|
26803
26735
|
});
|
|
26804
26736
|
letGo();
|
|
26805
|
-
if (repairing) {
|
|
26806
|
-
const next = await resume(sessionId);
|
|
26807
|
-
if ("error" in next) patch(sessionId, (r2) => {
|
|
26808
|
-
r2.error = `${boardProblems(formatErrors)}
|
|
26809
|
-
Cannot resume board repair: ${next.error}`;
|
|
26810
|
-
r2.errorWhy = [{ kind: "format" }, { kind: "repairUnstarted", refusals: [next] }];
|
|
26811
|
-
});
|
|
26812
|
-
}
|
|
26813
26737
|
if (retrying) {
|
|
26814
26738
|
const next = await resume(sessionId);
|
|
26815
26739
|
if ("error" in next) patch(sessionId, (r2) => {
|
|
@@ -26817,9 +26741,10 @@ Cannot resume board repair: ${next.error}`;
|
|
|
26817
26741
|
r2.errorWhy = [...r2.errorWhy ?? [], { kind: "retryUnstarted", refusals: [next] }];
|
|
26818
26742
|
});
|
|
26819
26743
|
}
|
|
26820
|
-
|
|
26821
|
-
|
|
26822
|
-
|
|
26744
|
+
const missingSession = record.resumedFrom && !/auth|unauthorized|forbidden|login|log.in/i.test(failure ?? spoken?.error ?? "") && /(?:no (?:conversation|session|thread) found|(?:session|conversation|thread)[^\n]*(?:not found|does not exist))/i.test(failure ?? spoken?.error ?? "");
|
|
26745
|
+
if (status === "error" && !asked && (lost || missingSession)) {
|
|
26746
|
+
const next = missingSession ? await startResume(sessionId, { deliveryId: record.deliveryId, fresh: true }) : await startRun(spec.again);
|
|
26747
|
+
if (!missingSession && !("error" in next)) forgetRun(sessionId);
|
|
26823
26748
|
}
|
|
26824
26749
|
if (status === "done") queueCompleted(before.keys());
|
|
26825
26750
|
if (status === "done") await followUp(sessionId, record.flowId, settled?.runs ?? []);
|
|
@@ -26986,7 +26911,7 @@ function catchModel(sessionId, model) {
|
|
|
26986
26911
|
});
|
|
26987
26912
|
return true;
|
|
26988
26913
|
}
|
|
26989
|
-
var STOP_GRACE_MS, STOP_CLOSE_MS, STOP_FINISH_MS, silenceSaid,
|
|
26914
|
+
var STOP_GRACE_MS, STOP_CLOSE_MS, STOP_FINISH_MS, silenceSaid, joinNotes;
|
|
26990
26915
|
var init_watch = __esm({
|
|
26991
26916
|
"src/lib/agent/watch.ts"() {
|
|
26992
26917
|
"use strict";
|
|
@@ -26995,14 +26920,11 @@ var init_watch = __esm({
|
|
|
26995
26920
|
init_progress();
|
|
26996
26921
|
init_deliveries();
|
|
26997
26922
|
init_paths();
|
|
26998
|
-
init_reconcile();
|
|
26999
|
-
init_spec_contract();
|
|
27000
26923
|
init_store();
|
|
27001
26924
|
init_own_cost();
|
|
27002
26925
|
init_remove();
|
|
27003
26926
|
init_prompts();
|
|
27004
26927
|
init_catalog2();
|
|
27005
|
-
init_command();
|
|
27006
26928
|
init_settings2();
|
|
27007
26929
|
init_flow();
|
|
27008
26930
|
init_spawnable();
|
|
@@ -27018,19 +26940,17 @@ var init_watch = __esm({
|
|
|
27018
26940
|
init_refine2();
|
|
27019
26941
|
init_sessions();
|
|
27020
26942
|
init_start();
|
|
27021
|
-
init_types3();
|
|
27022
26943
|
STOP_GRACE_MS = 5e3;
|
|
27023
26944
|
STOP_CLOSE_MS = 2e3;
|
|
27024
26945
|
STOP_FINISH_MS = 1e4;
|
|
27025
26946
|
silenceSaid = (minutes) => `the agent said nothing for ${minutes} minute${minutes === 1 ? "" : "s"}, so the run was ended.`;
|
|
27026
|
-
MAX_FORMAT_REPAIRS = 3;
|
|
27027
26947
|
joinNotes = (...parts) => parts.filter(Boolean).join("\n\n") || void 0;
|
|
27028
26948
|
}
|
|
27029
26949
|
});
|
|
27030
26950
|
|
|
27031
26951
|
// src/commands/run.ts
|
|
27032
|
-
import
|
|
27033
|
-
import
|
|
26952
|
+
import fs86 from "node:fs";
|
|
26953
|
+
import path86 from "node:path";
|
|
27034
26954
|
async function cmdStartRun(action, args2, opts, program2 = "akb") {
|
|
27035
26955
|
if (action === "approve" && (opts.preview || opts.previewStage || opts.previewVersion || opts.definitionRevision)) return confirmLocalPreview(Number(args2[0]), opts);
|
|
27036
26956
|
const { req, follow: follow2, print } = readRequest(action, args2, opts);
|
|
@@ -27189,6 +27109,12 @@ function readRequest(action, args2, opts) {
|
|
|
27189
27109
|
return { req, follow: follow2, print };
|
|
27190
27110
|
}
|
|
27191
27111
|
async function cmdResume(id, opts) {
|
|
27112
|
+
const previous = await getRun(id ?? "last");
|
|
27113
|
+
const completed = previous?.deliveryId ? findDelivery(previous.deliveryId) : void 0;
|
|
27114
|
+
if (completed?.status === "finished" && completed.completions?.some((receipt) => receipt.finished)) {
|
|
27115
|
+
say(`delivery ${completed.deliveryId} is complete.`);
|
|
27116
|
+
return { sessionId: previous.sessionId, resumedFrom: previous.resumedFrom, delivery: deliveryOutcome(completed.deliveryId) };
|
|
27117
|
+
}
|
|
27192
27118
|
const opened = await startResume(id ?? "last", opts.requireSession);
|
|
27193
27119
|
if ("error" in opened) die(opened.error, { kind: "run-refused", ..."reason" in opened ? { reason: opened.reason } : {} });
|
|
27194
27120
|
const { run: run4 } = opened;
|
|
@@ -27210,6 +27136,7 @@ async function cmdResumeDelivery(named2) {
|
|
|
27210
27136
|
kind: "run-refused",
|
|
27211
27137
|
...res.kind === "refused" ? { reason: res.reason, args: res.args } : {}
|
|
27212
27138
|
});
|
|
27139
|
+
if (res.landed) return { deliveryId: res.deliveryId, landed: true };
|
|
27213
27140
|
const delivery = findDelivery(res.deliveryId);
|
|
27214
27141
|
const started = await startRun({
|
|
27215
27142
|
action: "implement",
|
|
@@ -27251,7 +27178,7 @@ async function cmdSubStart(words, opts) {
|
|
|
27251
27178
|
let prompt = words.join(" ");
|
|
27252
27179
|
if (opts.file) {
|
|
27253
27180
|
try {
|
|
27254
|
-
prompt =
|
|
27181
|
+
prompt = fs86.readFileSync(path86.resolve(opts.file), "utf8");
|
|
27255
27182
|
} catch {
|
|
27256
27183
|
die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
|
|
27257
27184
|
}
|
|
@@ -27389,7 +27316,7 @@ async function followRun(sessionId, already = "", program2 = "akb", events = fal
|
|
|
27389
27316
|
const deliveryId = first.deliveryId ?? last.deliveryId;
|
|
27390
27317
|
const delivery = deliveryId ? deliveryOutcome(deliveryId) : void 0;
|
|
27391
27318
|
if (delivery) say(`delivery ${delivery.id}: ${delivery.line}`);
|
|
27392
|
-
const failed = last.status !== "done" ? `run ${short(last.sessionId)} ended ${last.status}${last.error ? `: ${last.error}` : ""}` :
|
|
27319
|
+
const failed = last.status !== "done" ? `run ${short(last.sessionId)} ended ${last.status}${last.error ? `: ${last.error}` : ""}` : void 0;
|
|
27393
27320
|
const held4 = peekRun(last.sessionId);
|
|
27394
27321
|
const agentSession = held4 ? resumeSessionId(held4) : void 0;
|
|
27395
27322
|
return {
|
|
@@ -27620,7 +27547,7 @@ var init_signals = __esm({
|
|
|
27620
27547
|
});
|
|
27621
27548
|
|
|
27622
27549
|
// src/commands/triage.ts
|
|
27623
|
-
import
|
|
27550
|
+
import fs87 from "node:fs";
|
|
27624
27551
|
async function cmdTriageAdd(opts) {
|
|
27625
27552
|
const title = (opts.title ?? "").trim();
|
|
27626
27553
|
if (!title) die('say what it is: --title "<one line>"', { kind: "needs-input" });
|
|
@@ -27630,7 +27557,7 @@ async function cmdTriageAdd(opts) {
|
|
|
27630
27557
|
let body = opts.text;
|
|
27631
27558
|
if (opts.file !== void 0) {
|
|
27632
27559
|
try {
|
|
27633
|
-
body =
|
|
27560
|
+
body = fs87.readFileSync(opts.file, "utf8");
|
|
27634
27561
|
} catch {
|
|
27635
27562
|
die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
|
|
27636
27563
|
}
|
|
@@ -27697,24 +27624,31 @@ async function cmdSpec(opts, program2 = "akb") {
|
|
|
27697
27624
|
if (!locate(id)) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
|
|
27698
27625
|
if (opts.stages !== void 0 || opts.submit || opts.reviseFrom) {
|
|
27699
27626
|
try {
|
|
27700
|
-
|
|
27627
|
+
let run5;
|
|
27628
|
+
try {
|
|
27629
|
+
run5 = previewRun(id, name);
|
|
27630
|
+
} catch (error) {
|
|
27631
|
+
if (!(error instanceof PreviewContextMissing)) throw error;
|
|
27632
|
+
await activatePreviewRun(id, name);
|
|
27633
|
+
run5 = previewRun(id, name);
|
|
27634
|
+
}
|
|
27701
27635
|
const ids = opts.stages?.split(",").map((id2) => id2.trim());
|
|
27702
|
-
const result = await previewBridge(name, ids ? "select" : opts.reviseFrom ? "revise" : "submit", { run: run5.sessionId, ...ids ? { stages: ids } : opts.reviseFrom ? { stageId: opts.reviseFrom } : { baseline: readPreviewBaseline(run5.sessionId), stageId: opts.stage } });
|
|
27636
|
+
const result = await previewBridge(name, ids ? "select" : opts.reviseFrom ? "revise" : "submit", { run: run5.sessionId, cardId: id, ...ids ? { stages: ids } : opts.reviseFrom ? { stageId: opts.reviseFrom } : { baseline: readPreviewBaseline(id, name, run5.sessionId), stageId: opts.stage } });
|
|
27703
27637
|
if (result?.progress) {
|
|
27704
27638
|
updatePreviewProgress(id, (all2) => {
|
|
27705
27639
|
all2[name] = result.progress;
|
|
27706
27640
|
});
|
|
27707
|
-
if (result.baseline) savePreviewBaseline(run5.sessionId, result.baseline);
|
|
27641
|
+
if (result.baseline) savePreviewBaseline(id, name, run5.sessionId, result.baseline);
|
|
27708
27642
|
} else if (opts.reviseFrom) {
|
|
27709
27643
|
updatePreviewProgress(id, (all2) => {
|
|
27710
27644
|
const progress = all2[name];
|
|
27711
27645
|
choosePreviewRevision(progress, opts.reviseFrom, run5.sessionId);
|
|
27712
|
-
savePreviewBaseline(run5.sessionId, previewBaseline(progress, opts.reviseFrom, run5.sessionId));
|
|
27646
|
+
savePreviewBaseline(id, name, run5.sessionId, previewBaseline(progress, opts.reviseFrom, run5.sessionId));
|
|
27713
27647
|
});
|
|
27714
27648
|
} else if (ids) {
|
|
27715
27649
|
const selected = selectLocalPreview(id, name, ids);
|
|
27716
|
-
savePreviewBaseline(run5.sessionId, selected.baseline);
|
|
27717
|
-
} else submitLocalPreview(id, name, opts.stage, readPreviewBaseline(run5.sessionId));
|
|
27650
|
+
savePreviewBaseline(id, name, run5.sessionId, selected.baseline);
|
|
27651
|
+
} else submitLocalPreview(id, name, opts.stage, readPreviewBaseline(id, name, run5.sessionId));
|
|
27718
27652
|
if (ids || opts.reviseFrom) say(previewStagePrompt(id, name, boardCommandFor(id)));
|
|
27719
27653
|
else say("Preview stage submitted. Stop here; the program controls confirmation and continuation.");
|
|
27720
27654
|
return { specAgent: name, cardId: id, submitted: !!opts.submit };
|
|
@@ -27733,13 +27667,20 @@ async function cmdSpec(opts, program2 = "akb") {
|
|
|
27733
27667
|
const req = { action: "spec", id, title: titleOf(id), specAgent: name, notes };
|
|
27734
27668
|
const inside2 = insideRun();
|
|
27735
27669
|
if (!inside2 && process.env[PREVIEW_BRIDGE_ENV]) opts.follow = true;
|
|
27670
|
+
if (opts.print === true) {
|
|
27671
|
+
try {
|
|
27672
|
+
await activatePreviewRun(id, name, void 0, notes);
|
|
27673
|
+
} catch (error) {
|
|
27674
|
+
die(error instanceof Error ? error.message : "Could not prepare the preview.", { kind: "preview-refused" });
|
|
27675
|
+
}
|
|
27676
|
+
return printFlow(req, program2);
|
|
27677
|
+
}
|
|
27736
27678
|
if (inside2 && readRuns().find((r2) => r2.sessionId === inside2)?.action === "spec") {
|
|
27737
27679
|
die(
|
|
27738
27680
|
"a preview agent does not ask for another preview agent \u2014 answer the part you own and leave the rest of the card to the session planning it.",
|
|
27739
27681
|
{ kind: "spec-agent-recursion", specAgent: name }
|
|
27740
27682
|
);
|
|
27741
27683
|
}
|
|
27742
|
-
if (opts.print === true) return printFlow(req, program2);
|
|
27743
27684
|
const live = readRuns().find(
|
|
27744
27685
|
(r2) => r2.status === "running" && r2.action === "spec" && r2.cardId === id && r2.specAgent === name
|
|
27745
27686
|
);
|
|
@@ -44443,7 +44384,7 @@ var require_react_dom_server_legacy_node_development = __commonJS({
|
|
|
44443
44384
|
numberOfReRenders = 0;
|
|
44444
44385
|
workInProgressHook = renderPhaseUpdates = null;
|
|
44445
44386
|
}
|
|
44446
|
-
function
|
|
44387
|
+
function readContext2(context) {
|
|
44447
44388
|
isInHookUserCodeInDev && console.error(
|
|
44448
44389
|
"Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()."
|
|
44449
44390
|
);
|
|
@@ -48796,7 +48737,7 @@ A.finished.finally(function(){document.__reactViewTransition===A&&(document.__re
|
|
|
48796
48737
|
}, emptyTreeContext = { id: 1, overflow: "" }, clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, log = Math.log, LN2 = Math.LN2, currentTaskInDEV = null, SuspenseException = Error(
|
|
48797
48738
|
"Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`."
|
|
48798
48739
|
), suspendedThenable = null, shouldCaptureSuspendedCallSite = false, suspendedCallSiteStack = null, suspendedCallSiteDebugTask = null, objectIs = "function" === typeof Object.is ? Object.is : is, currentlyRenderingComponent = null, currentlyRenderingTask = null, currentlyRenderingRequest = null, currentlyRenderingKeyPath = null, firstWorkInProgressHook = null, workInProgressHook = null, isReRender = false, didScheduleRenderPhaseUpdate = false, localIdCounter = 0, actionStateCounter = 0, actionStateMatchingIndex = -1, thenableIndexCounter = 0, thenableState = null, renderPhaseUpdates = null, numberOfReRenders = 0, isInHookUserCodeInDev = false, currentHookNameInDev, HooksDispatcher = {
|
|
48799
|
-
readContext,
|
|
48740
|
+
readContext: readContext2,
|
|
48800
48741
|
use: function(usable) {
|
|
48801
48742
|
if (null !== usable && "object" === typeof usable) {
|
|
48802
48743
|
if ("function" === typeof usable.then)
|
|
@@ -48804,7 +48745,7 @@ A.finished.finally(function(){document.__reactViewTransition===A&&(document.__re
|
|
|
48804
48745
|
if (usable.$$typeof === REACT_RECOVERABLE_TYPE)
|
|
48805
48746
|
throw createRecoverableError(usable);
|
|
48806
48747
|
if (usable.$$typeof === REACT_CONTEXT_TYPE)
|
|
48807
|
-
return
|
|
48748
|
+
return readContext2(usable);
|
|
48808
48749
|
}
|
|
48809
48750
|
throw Error(
|
|
48810
48751
|
"An unsupported type was passed to use(): " + String(usable)
|
|
@@ -52012,7 +51953,7 @@ var require_react_dom_server_node_development = __commonJS({
|
|
|
52012
51953
|
numberOfReRenders = 0;
|
|
52013
51954
|
workInProgressHook = renderPhaseUpdates = null;
|
|
52014
51955
|
}
|
|
52015
|
-
function
|
|
51956
|
+
function readContext2(context) {
|
|
52016
51957
|
isInHookUserCodeInDev && console.error(
|
|
52017
51958
|
"Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()."
|
|
52018
51959
|
);
|
|
@@ -56745,7 +56686,7 @@ A.finished.finally(function(){document.__reactViewTransition===A&&(document.__re
|
|
|
56745
56686
|
}, emptyTreeContext = { id: 1, overflow: "" }, clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, log = Math.log, LN2 = Math.LN2, currentTaskInDEV = null, SuspenseException = Error(
|
|
56746
56687
|
"Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`."
|
|
56747
56688
|
), suspendedThenable = null, shouldCaptureSuspendedCallSite = false, suspendedCallSiteStack = null, suspendedCallSiteDebugTask = null, objectIs = "function" === typeof Object.is ? Object.is : is, currentlyRenderingComponent = null, currentlyRenderingTask = null, currentlyRenderingRequest = null, currentlyRenderingKeyPath = null, firstWorkInProgressHook = null, workInProgressHook = null, isReRender = false, didScheduleRenderPhaseUpdate = false, localIdCounter = 0, actionStateCounter = 0, actionStateMatchingIndex = -1, thenableIndexCounter = 0, thenableState = null, renderPhaseUpdates = null, numberOfReRenders = 0, isInHookUserCodeInDev = false, currentHookNameInDev, HooksDispatcher = {
|
|
56748
|
-
readContext,
|
|
56689
|
+
readContext: readContext2,
|
|
56749
56690
|
use: function(usable) {
|
|
56750
56691
|
if (null !== usable && "object" === typeof usable) {
|
|
56751
56692
|
if ("function" === typeof usable.then)
|
|
@@ -56753,7 +56694,7 @@ A.finished.finally(function(){document.__reactViewTransition===A&&(document.__re
|
|
|
56753
56694
|
if (usable.$$typeof === REACT_RECOVERABLE_TYPE)
|
|
56754
56695
|
throw createRecoverableError(usable);
|
|
56755
56696
|
if (usable.$$typeof === REACT_CONTEXT_TYPE)
|
|
56756
|
-
return
|
|
56697
|
+
return readContext2(usable);
|
|
56757
56698
|
}
|
|
56758
56699
|
throw Error(
|
|
56759
56700
|
"An unsupported type was passed to use(): " + String(usable)
|
|
@@ -69003,8 +68944,8 @@ var require_JSXTransformer = __commonJS({
|
|
|
69003
68944
|
}
|
|
69004
68945
|
if (this.isAutomaticRuntime) {
|
|
69005
68946
|
if (this.importProcessor) {
|
|
69006
|
-
for (const [
|
|
69007
|
-
prefix += `var ${resolvedName} = require("${
|
|
68947
|
+
for (const [path91, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
|
|
68948
|
+
prefix += `var ${resolvedName} = require("${path91}");`;
|
|
69008
68949
|
}
|
|
69009
68950
|
} else {
|
|
69010
68951
|
const { createElement: createElementResolution, ...otherResolutions } = this.esmAutomaticImportNameResolutions;
|
|
@@ -69197,11 +69138,11 @@ var require_JSXTransformer = __commonJS({
|
|
|
69197
69138
|
}
|
|
69198
69139
|
claimAutoImportedName(funcName, importPathSuffix) {
|
|
69199
69140
|
if (this.importProcessor) {
|
|
69200
|
-
const
|
|
69201
|
-
if (!this.cjsAutomaticModuleNameResolutions[
|
|
69202
|
-
this.cjsAutomaticModuleNameResolutions[
|
|
69141
|
+
const path91 = this.jsxImportSource + importPathSuffix;
|
|
69142
|
+
if (!this.cjsAutomaticModuleNameResolutions[path91]) {
|
|
69143
|
+
this.cjsAutomaticModuleNameResolutions[path91] = this.importProcessor.getFreeIdentifierForPath(path91);
|
|
69203
69144
|
}
|
|
69204
|
-
return `${this.cjsAutomaticModuleNameResolutions[
|
|
69145
|
+
return `${this.cjsAutomaticModuleNameResolutions[path91]}.${funcName}`;
|
|
69205
69146
|
} else {
|
|
69206
69147
|
if (!this.esmAutomaticImportNameResolutions[funcName]) {
|
|
69207
69148
|
this.esmAutomaticImportNameResolutions[funcName] = this.nameManager.claimFreeName(
|
|
@@ -69637,7 +69578,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
69637
69578
|
*/
|
|
69638
69579
|
pruneTypeOnlyImports() {
|
|
69639
69580
|
this.nonTypeIdentifiers = _getNonTypeIdentifiers.getNonTypeIdentifiers.call(void 0, this.tokens, this.options);
|
|
69640
|
-
for (const [
|
|
69581
|
+
for (const [path91, importInfo] of this.importInfoByPath.entries()) {
|
|
69641
69582
|
if (importInfo.hasBareImport || importInfo.hasStarExport || importInfo.exportStarNames.length > 0 || importInfo.namedExports.length > 0) {
|
|
69642
69583
|
continue;
|
|
69643
69584
|
}
|
|
@@ -69647,7 +69588,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
69647
69588
|
...importInfo.namedImports.map(({ localName }) => localName)
|
|
69648
69589
|
];
|
|
69649
69590
|
if (names3.every((name) => this.shouldAutomaticallyElideImportedName(name))) {
|
|
69650
|
-
this.importsToReplace.set(
|
|
69591
|
+
this.importsToReplace.set(path91, "");
|
|
69651
69592
|
}
|
|
69652
69593
|
}
|
|
69653
69594
|
}
|
|
@@ -69655,7 +69596,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
69655
69596
|
return this.isTypeScriptTransformEnabled && !this.keepUnusedImports && !this.nonTypeIdentifiers.has(name);
|
|
69656
69597
|
}
|
|
69657
69598
|
generateImportReplacements() {
|
|
69658
|
-
for (const [
|
|
69599
|
+
for (const [path91, importInfo] of this.importInfoByPath.entries()) {
|
|
69659
69600
|
const {
|
|
69660
69601
|
defaultNames,
|
|
69661
69602
|
wildcardNames,
|
|
@@ -69665,17 +69606,17 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
69665
69606
|
hasStarExport
|
|
69666
69607
|
} = importInfo;
|
|
69667
69608
|
if (defaultNames.length === 0 && wildcardNames.length === 0 && namedImports.length === 0 && namedExports.length === 0 && exportStarNames.length === 0 && !hasStarExport) {
|
|
69668
|
-
this.importsToReplace.set(
|
|
69609
|
+
this.importsToReplace.set(path91, `require('${path91}');`);
|
|
69669
69610
|
continue;
|
|
69670
69611
|
}
|
|
69671
|
-
const primaryImportName = this.getFreeIdentifierForPath(
|
|
69612
|
+
const primaryImportName = this.getFreeIdentifierForPath(path91);
|
|
69672
69613
|
let secondaryImportName;
|
|
69673
69614
|
if (this.enableLegacyTypeScriptModuleInterop) {
|
|
69674
69615
|
secondaryImportName = primaryImportName;
|
|
69675
69616
|
} else {
|
|
69676
|
-
secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(
|
|
69617
|
+
secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path91);
|
|
69677
69618
|
}
|
|
69678
|
-
let requireCode = `var ${primaryImportName} = require('${
|
|
69619
|
+
let requireCode = `var ${primaryImportName} = require('${path91}');`;
|
|
69679
69620
|
if (wildcardNames.length > 0) {
|
|
69680
69621
|
for (const wildcardName of wildcardNames) {
|
|
69681
69622
|
const moduleExpr = this.enableLegacyTypeScriptModuleInterop ? primaryImportName : `${this.helperManager.getHelperName("interopRequireWildcard")}(${primaryImportName})`;
|
|
@@ -69703,7 +69644,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
69703
69644
|
"createStarExport"
|
|
69704
69645
|
)}(${primaryImportName});`;
|
|
69705
69646
|
}
|
|
69706
|
-
this.importsToReplace.set(
|
|
69647
|
+
this.importsToReplace.set(path91, requireCode);
|
|
69707
69648
|
for (const defaultName of defaultNames) {
|
|
69708
69649
|
this.identifierReplacements.set(defaultName, `${secondaryImportName}.default`);
|
|
69709
69650
|
}
|
|
@@ -69712,8 +69653,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
69712
69653
|
}
|
|
69713
69654
|
}
|
|
69714
69655
|
}
|
|
69715
|
-
getFreeIdentifierForPath(
|
|
69716
|
-
const components =
|
|
69656
|
+
getFreeIdentifierForPath(path91) {
|
|
69657
|
+
const components = path91.split("/");
|
|
69717
69658
|
const lastComponent = components[components.length - 1];
|
|
69718
69659
|
const baseName = lastComponent.replace(/\W/g, "");
|
|
69719
69660
|
return this.nameManager.claimFreeName(`_${baseName}`);
|
|
@@ -69758,8 +69699,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
69758
69699
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
69759
69700
|
throw new Error("Expected string token at the end of import statement.");
|
|
69760
69701
|
}
|
|
69761
|
-
const
|
|
69762
|
-
const importInfo = this.getImportInfo(
|
|
69702
|
+
const path91 = this.tokens.stringValueAtIndex(index);
|
|
69703
|
+
const importInfo = this.getImportInfo(path91);
|
|
69763
69704
|
importInfo.defaultNames.push(...defaultNames);
|
|
69764
69705
|
importInfo.wildcardNames.push(...wildcardNames);
|
|
69765
69706
|
importInfo.namedImports.push(...namedImports);
|
|
@@ -69826,8 +69767,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
69826
69767
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
69827
69768
|
throw new Error("Expected string token at the end of import statement.");
|
|
69828
69769
|
}
|
|
69829
|
-
const
|
|
69830
|
-
const importInfo = this.getImportInfo(
|
|
69770
|
+
const path91 = this.tokens.stringValueAtIndex(index);
|
|
69771
|
+
const importInfo = this.getImportInfo(path91);
|
|
69831
69772
|
importInfo.namedExports.push(...namedImports);
|
|
69832
69773
|
}
|
|
69833
69774
|
preprocessExportStarAtIndex(index) {
|
|
@@ -69842,8 +69783,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
69842
69783
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
69843
69784
|
throw new Error("Expected string token at the end of star export statement.");
|
|
69844
69785
|
}
|
|
69845
|
-
const
|
|
69846
|
-
const importInfo = this.getImportInfo(
|
|
69786
|
+
const path91 = this.tokens.stringValueAtIndex(index);
|
|
69787
|
+
const importInfo = this.getImportInfo(path91);
|
|
69847
69788
|
if (exportedName !== null) {
|
|
69848
69789
|
importInfo.exportStarNames.push(exportedName);
|
|
69849
69790
|
} else {
|
|
@@ -69883,8 +69824,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
69883
69824
|
* Get a mutable import info object for this path, creating one if it doesn't
|
|
69884
69825
|
* exist yet.
|
|
69885
69826
|
*/
|
|
69886
|
-
getImportInfo(
|
|
69887
|
-
const existingInfo = this.importInfoByPath.get(
|
|
69827
|
+
getImportInfo(path91) {
|
|
69828
|
+
const existingInfo = this.importInfoByPath.get(path91);
|
|
69888
69829
|
if (existingInfo) {
|
|
69889
69830
|
return existingInfo;
|
|
69890
69831
|
}
|
|
@@ -69897,7 +69838,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
69897
69838
|
exportStarNames: [],
|
|
69898
69839
|
hasStarExport: false
|
|
69899
69840
|
};
|
|
69900
|
-
this.importInfoByPath.set(
|
|
69841
|
+
this.importInfoByPath.set(path91, newInfo);
|
|
69901
69842
|
return newInfo;
|
|
69902
69843
|
}
|
|
69903
69844
|
addExportBinding(localName, exportedName) {
|
|
@@ -70477,16 +70418,16 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
70477
70418
|
}
|
|
70478
70419
|
function parseFileUrl(input) {
|
|
70479
70420
|
const match = fileRegex.exec(input);
|
|
70480
|
-
const
|
|
70481
|
-
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(
|
|
70421
|
+
const path91 = match[2];
|
|
70422
|
+
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path91) ? path91 : "/" + path91, match[3] || "", match[4] || "");
|
|
70482
70423
|
}
|
|
70483
|
-
function makeUrl(scheme, user, host2, port,
|
|
70424
|
+
function makeUrl(scheme, user, host2, port, path91, query, hash2) {
|
|
70484
70425
|
return {
|
|
70485
70426
|
scheme,
|
|
70486
70427
|
user,
|
|
70487
70428
|
host: host2,
|
|
70488
70429
|
port,
|
|
70489
|
-
path:
|
|
70430
|
+
path: path91,
|
|
70490
70431
|
query,
|
|
70491
70432
|
hash: hash2,
|
|
70492
70433
|
type: 7
|
|
@@ -70516,11 +70457,11 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
70516
70457
|
url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
|
|
70517
70458
|
return url;
|
|
70518
70459
|
}
|
|
70519
|
-
function stripPathFilename(
|
|
70520
|
-
if (
|
|
70521
|
-
return
|
|
70522
|
-
const index =
|
|
70523
|
-
return
|
|
70460
|
+
function stripPathFilename(path91) {
|
|
70461
|
+
if (path91.endsWith("/.."))
|
|
70462
|
+
return path91;
|
|
70463
|
+
const index = path91.lastIndexOf("/");
|
|
70464
|
+
return path91.slice(0, index + 1);
|
|
70524
70465
|
}
|
|
70525
70466
|
function mergePaths(url, base) {
|
|
70526
70467
|
normalizePath(base, base.type);
|
|
@@ -70558,14 +70499,14 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
70558
70499
|
pieces[pointer++] = piece;
|
|
70559
70500
|
positive++;
|
|
70560
70501
|
}
|
|
70561
|
-
let
|
|
70502
|
+
let path91 = "";
|
|
70562
70503
|
for (let i = 1; i < pointer; i++) {
|
|
70563
|
-
|
|
70504
|
+
path91 += "/" + pieces[i];
|
|
70564
70505
|
}
|
|
70565
|
-
if (!
|
|
70566
|
-
|
|
70506
|
+
if (!path91 || addTrailingSlash && !path91.endsWith("/..")) {
|
|
70507
|
+
path91 += "/";
|
|
70567
70508
|
}
|
|
70568
|
-
url.path =
|
|
70509
|
+
url.path = path91;
|
|
70569
70510
|
}
|
|
70570
70511
|
function resolve2(input, base) {
|
|
70571
70512
|
if (!input && !base)
|
|
@@ -70606,13 +70547,13 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
70606
70547
|
case 3:
|
|
70607
70548
|
return queryHash;
|
|
70608
70549
|
case 4: {
|
|
70609
|
-
const
|
|
70610
|
-
if (!
|
|
70550
|
+
const path91 = url.path.slice(1);
|
|
70551
|
+
if (!path91)
|
|
70611
70552
|
return queryHash || ".";
|
|
70612
|
-
if (isRelative(base || input) && !isRelative(
|
|
70613
|
-
return "./" +
|
|
70553
|
+
if (isRelative(base || input) && !isRelative(path91)) {
|
|
70554
|
+
return "./" + path91 + queryHash;
|
|
70614
70555
|
}
|
|
70615
|
-
return
|
|
70556
|
+
return path91 + queryHash;
|
|
70616
70557
|
}
|
|
70617
70558
|
case 5:
|
|
70618
70559
|
return url.path + queryHash;
|
|
@@ -70711,10 +70652,10 @@ var require_trace_mapping_umd = __commonJS({
|
|
|
70711
70652
|
module2.exports = __toCommonJS(trace_mapping_exports);
|
|
70712
70653
|
var import_sourcemap_codec = __toESM2(require_sourcemap_codec());
|
|
70713
70654
|
var import_resolve_uri = __toESM2(require_resolve_uri());
|
|
70714
|
-
function stripFilename(
|
|
70715
|
-
if (!
|
|
70716
|
-
const index =
|
|
70717
|
-
return
|
|
70655
|
+
function stripFilename(path91) {
|
|
70656
|
+
if (!path91) return "";
|
|
70657
|
+
const index = path91.lastIndexOf("/");
|
|
70658
|
+
return path91.slice(0, index + 1);
|
|
70718
70659
|
}
|
|
70719
70660
|
function resolver2(mapUrl, sourceRoot) {
|
|
70720
70661
|
const from = stripFilename(mapUrl);
|
|
@@ -71922,9 +71863,9 @@ var require_util2 = __commonJS({
|
|
|
71922
71863
|
/** @class */
|
|
71923
71864
|
(function(_super) {
|
|
71924
71865
|
__extends(VError2, _super);
|
|
71925
|
-
function VError2(
|
|
71866
|
+
function VError2(path91, message) {
|
|
71926
71867
|
var _this = _super.call(this, message) || this;
|
|
71927
|
-
_this.path =
|
|
71868
|
+
_this.path = path91;
|
|
71928
71869
|
Object.setPrototypeOf(_this, VError2.prototype);
|
|
71929
71870
|
return _this;
|
|
71930
71871
|
}
|
|
@@ -71984,26 +71925,26 @@ var require_util2 = __commonJS({
|
|
|
71984
71925
|
(_b = this._messages).push.apply(_b, best._messages);
|
|
71985
71926
|
}
|
|
71986
71927
|
};
|
|
71987
|
-
DetailContext2.prototype.getError = function(
|
|
71928
|
+
DetailContext2.prototype.getError = function(path91) {
|
|
71988
71929
|
var msgParts = [];
|
|
71989
71930
|
for (var i = this._propNames.length - 1; i >= 0; i--) {
|
|
71990
71931
|
var p2 = this._propNames[i];
|
|
71991
|
-
|
|
71932
|
+
path91 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
|
|
71992
71933
|
var m = this._messages[i];
|
|
71993
71934
|
if (m) {
|
|
71994
|
-
msgParts.push(
|
|
71935
|
+
msgParts.push(path91 + " " + m);
|
|
71995
71936
|
}
|
|
71996
71937
|
}
|
|
71997
|
-
return new VError(
|
|
71938
|
+
return new VError(path91, msgParts.join("; "));
|
|
71998
71939
|
};
|
|
71999
|
-
DetailContext2.prototype.getErrorDetail = function(
|
|
71940
|
+
DetailContext2.prototype.getErrorDetail = function(path91) {
|
|
72000
71941
|
var details = [];
|
|
72001
71942
|
for (var i = this._propNames.length - 1; i >= 0; i--) {
|
|
72002
71943
|
var p2 = this._propNames[i];
|
|
72003
|
-
|
|
71944
|
+
path91 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
|
|
72004
71945
|
var message = this._messages[i];
|
|
72005
71946
|
if (message) {
|
|
72006
|
-
details.push({ path:
|
|
71947
|
+
details.push({ path: path91, message });
|
|
72007
71948
|
}
|
|
72008
71949
|
}
|
|
72009
71950
|
var detail = null;
|
|
@@ -72816,8 +72757,8 @@ var require_dist = __commonJS({
|
|
|
72816
72757
|
this.checkerPlain = this.ttype.getChecker(suite, false);
|
|
72817
72758
|
this.checkerStrict = this.ttype.getChecker(suite, true);
|
|
72818
72759
|
}
|
|
72819
|
-
Checker2.prototype.setReportedPath = function(
|
|
72820
|
-
this._path =
|
|
72760
|
+
Checker2.prototype.setReportedPath = function(path91) {
|
|
72761
|
+
this._path = path91;
|
|
72821
72762
|
};
|
|
72822
72763
|
Checker2.prototype.check = function(value) {
|
|
72823
72764
|
return this._doCheck(this.checkerPlain, value);
|
|
@@ -78250,9 +78191,9 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
78250
78191
|
if (shouldElideImport) {
|
|
78251
78192
|
this.tokens.removeToken();
|
|
78252
78193
|
} else {
|
|
78253
|
-
const
|
|
78254
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
78255
|
-
this.tokens.appendCode(this.importProcessor.claimImportCode(
|
|
78194
|
+
const path91 = this.tokens.stringValue();
|
|
78195
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path91));
|
|
78196
|
+
this.tokens.appendCode(this.importProcessor.claimImportCode(path91));
|
|
78256
78197
|
}
|
|
78257
78198
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
78258
78199
|
if (this.tokens.matches1(_types.TokenType.semi)) {
|
|
@@ -78832,8 +78773,8 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
78832
78773
|
}
|
|
78833
78774
|
if (this.tokens.matchesContextual(_keywords.ContextualKeyword._from)) {
|
|
78834
78775
|
this.tokens.removeToken();
|
|
78835
|
-
const
|
|
78836
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
78776
|
+
const path91 = this.tokens.stringValue();
|
|
78777
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path91));
|
|
78837
78778
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
78838
78779
|
} else {
|
|
78839
78780
|
this.tokens.appendCode(exportStatements.join(" "));
|
|
@@ -78847,8 +78788,8 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
78847
78788
|
while (!this.tokens.matches1(_types.TokenType.string)) {
|
|
78848
78789
|
this.tokens.removeToken();
|
|
78849
78790
|
}
|
|
78850
|
-
const
|
|
78851
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
78791
|
+
const path91 = this.tokens.stringValue();
|
|
78792
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path91));
|
|
78852
78793
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
78853
78794
|
if (this.tokens.matches1(_types.TokenType.semi)) {
|
|
78854
78795
|
this.tokens.removeToken();
|
|
@@ -108702,9 +108643,9 @@ var init_bundle_mjs = __esm({
|
|
|
108702
108643
|
processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
|
|
108703
108644
|
}
|
|
108704
108645
|
};
|
|
108705
|
-
getPart = (classPartObject,
|
|
108646
|
+
getPart = (classPartObject, path91) => {
|
|
108706
108647
|
let current = classPartObject;
|
|
108707
|
-
const parts =
|
|
108648
|
+
const parts = path91.split(CLASS_PART_SEPARATOR);
|
|
108708
108649
|
const len = parts.length;
|
|
108709
108650
|
for (let i = 0; i < len; i++) {
|
|
108710
108651
|
const part = parts[i];
|
|
@@ -111954,8 +111895,8 @@ var init_dist = __esm({
|
|
|
111954
111895
|
});
|
|
111955
111896
|
|
|
111956
111897
|
// src/lib/draw-mockup.ts
|
|
111957
|
-
import
|
|
111958
|
-
import
|
|
111898
|
+
import fs88 from "node:fs";
|
|
111899
|
+
import path87 from "node:path";
|
|
111959
111900
|
import vm from "node:vm";
|
|
111960
111901
|
async function loadPackage(id) {
|
|
111961
111902
|
if (id === "react") return import_react3.default;
|
|
@@ -111968,23 +111909,23 @@ async function loadPackage(id) {
|
|
|
111968
111909
|
return { __esModule: true, ...await load() };
|
|
111969
111910
|
}
|
|
111970
111911
|
function resolveFile(id, from, folder) {
|
|
111971
|
-
const at2 =
|
|
111972
|
-
if (at2 !== folder && !at2.startsWith(folder +
|
|
111973
|
-
const tries =
|
|
111974
|
-
const file2 = tries.find((f2) =>
|
|
111912
|
+
const at2 = path87.resolve(path87.dirname(from), id);
|
|
111913
|
+
if (at2 !== folder && !at2.startsWith(folder + path87.sep)) throw new Error(`${id} is outside the mockup's folder`);
|
|
111914
|
+
const tries = path87.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path87.join(at2, `index${e2}`))];
|
|
111915
|
+
const file2 = tries.find((f2) => fs88.statSync(f2, { throwIfNoEntry: false })?.isFile());
|
|
111975
111916
|
if (!file2) throw new Error(`no such file: ${id}`);
|
|
111976
|
-
if (!
|
|
111917
|
+
if (!fs88.realpathSync(file2).startsWith(fs88.realpathSync(folder) + path87.sep)) throw new Error(`${id} is outside the mockup's folder`);
|
|
111977
111918
|
return file2;
|
|
111978
111919
|
}
|
|
111979
111920
|
async function readGraph(entry) {
|
|
111980
|
-
const folder =
|
|
111921
|
+
const folder = path87.dirname(entry);
|
|
111981
111922
|
const graph = { code: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), sheets: [], packages: /* @__PURE__ */ new Map() };
|
|
111982
111923
|
const walk3 = async (file2) => {
|
|
111983
111924
|
if (graph.code.has(file2)) return;
|
|
111984
111925
|
if (graph.code.size >= MAX_FILES) throw new Error(`a mockup imports more than ${MAX_FILES} files`);
|
|
111985
111926
|
let location = file2;
|
|
111986
111927
|
try {
|
|
111987
|
-
const js = (0, import_sucrase.transform)(
|
|
111928
|
+
const js = (0, import_sucrase.transform)(fs88.readFileSync(file2, "utf8"), { transforms: ["typescript", "jsx", "imports"], jsxRuntime: "automatic", production: true, filePath: file2 }).code;
|
|
111988
111929
|
graph.code.set(file2, js);
|
|
111989
111930
|
const link2 = /* @__PURE__ */ new Map();
|
|
111990
111931
|
graph.links.set(file2, link2);
|
|
@@ -111998,7 +111939,7 @@ async function readGraph(entry) {
|
|
|
111998
111939
|
const target = resolveFile(id, file2, folder);
|
|
111999
111940
|
link2.set(id, target);
|
|
112000
111941
|
if (!target.endsWith(".css")) await walk3(target);
|
|
112001
|
-
else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content:
|
|
111942
|
+
else if (!graph.sheets.some((s) => s.path === target)) graph.sheets.push({ path: target, content: fs88.readFileSync(target, "utf8") });
|
|
112002
111943
|
}
|
|
112003
111944
|
} catch (error) {
|
|
112004
111945
|
throw new Error(`${location}: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -112015,13 +111956,13 @@ function run2(script, context, name, deadline, lineOffset = 0) {
|
|
|
112015
111956
|
async function tailwindFor(markup, sheets, folder) {
|
|
112016
111957
|
const source2 = sheets.length ? sheets.map((s) => s.content).join("\n") : '@import "tailwindcss";';
|
|
112017
111958
|
const compiler = await rc(source2, {
|
|
112018
|
-
base: sheets.length ?
|
|
111959
|
+
base: sheets.length ? path87.dirname(sheets[0].path) : "/",
|
|
112019
111960
|
loadStylesheet: async (id, from) => {
|
|
112020
111961
|
if (id === "tailwindcss" || id.startsWith("tailwindcss/")) return { path: "tailwindcss/index.css", base: "/", content: tailwindcss_default };
|
|
112021
111962
|
if (!id.startsWith(".")) throw new Error(`a mockup cannot import ${id}`);
|
|
112022
|
-
const at2 =
|
|
112023
|
-
if (!
|
|
112024
|
-
return { path: at2, base:
|
|
111963
|
+
const at2 = path87.resolve(from, id);
|
|
111964
|
+
if (!fs88.realpathSync(at2).startsWith(fs88.realpathSync(folder) + path87.sep)) throw new Error(`${id} is outside the mockup's folder`);
|
|
111965
|
+
return { path: at2, base: path87.dirname(at2), content: fs88.readFileSync(at2, "utf8") };
|
|
112025
111966
|
}
|
|
112026
111967
|
});
|
|
112027
111968
|
const classes = [...markup.matchAll(/class="([^"]*)"/g)].flatMap((m) => m[1].split(/\s+/));
|
|
@@ -112070,7 +112011,7 @@ ${graph.code.get(file2)}
|
|
|
112070
112011
|
if (typeof Component !== "function") throw new Error("the mockup has no default export to draw");
|
|
112071
112012
|
sandbox.__draw = () => (0, import_server.renderToStaticMarkup)(import_react3.default.createElement(Component));
|
|
112072
112013
|
const markup = run2("__draw()", context, entry, deadline);
|
|
112073
|
-
const css = (await tailwindFor(markup, graph.sheets,
|
|
112014
|
+
const css = (await tailwindFor(markup, graph.sheets, path87.dirname(entry))).replace(/<\/style/gi, "<\\/style");
|
|
112074
112015
|
return `<!doctype html><html><head>${head}<style>${css}</style></head><body>${markup}</body></html>`;
|
|
112075
112016
|
}
|
|
112076
112017
|
var import_react3, JSX, import_server, import_sucrase, DRAW_MS, MAX_FILES, CODE_EXTS, REQUIRES, NOTHING, NEXT_LINK, NEXT_IMAGE, NEXT_NAVIGATION, PACKAGES, MOCKUP_IMPORTS;
|
|
@@ -112131,21 +112072,21 @@ var init_draw_mockup = __esm({
|
|
|
112131
112072
|
});
|
|
112132
112073
|
|
|
112133
112074
|
// src/commands/studio-preview.ts
|
|
112134
|
-
import
|
|
112135
|
-
import
|
|
112075
|
+
import fs89 from "node:fs";
|
|
112076
|
+
import path88 from "node:path";
|
|
112136
112077
|
import { createHash as createHash10, randomUUID as randomUUID8 } from "node:crypto";
|
|
112137
112078
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
112138
112079
|
function readFolder2(folder) {
|
|
112139
|
-
const root2 =
|
|
112080
|
+
const root2 = fs89.realpathSync(folder);
|
|
112140
112081
|
let count3 = 0, total = 0;
|
|
112141
112082
|
const scan = (dir) => {
|
|
112142
|
-
for (const e2 of
|
|
112083
|
+
for (const e2 of fs89.readdirSync(dir, { withFileTypes: true })) {
|
|
112143
112084
|
if (e2.name.startsWith(".")) continue;
|
|
112144
|
-
const file2 =
|
|
112085
|
+
const file2 = path88.join(dir, e2.name);
|
|
112145
112086
|
if (e2.isSymbolicLink()) throw Error(`${file2}: symbolic links are not allowed`);
|
|
112146
112087
|
if (e2.isDirectory()) scan(file2);
|
|
112147
112088
|
else {
|
|
112148
|
-
const size =
|
|
112089
|
+
const size = fs89.statSync(file2).size;
|
|
112149
112090
|
total += size;
|
|
112150
112091
|
if (++count3 > FILE_LIMITS.count || size > FILE_LIMITS.file || total > FILE_LIMITS.total) throw Error(`${file2}: Studio file limit exceeded`);
|
|
112151
112092
|
}
|
|
@@ -112167,9 +112108,9 @@ function agentsOf2(held4) {
|
|
|
112167
112108
|
});
|
|
112168
112109
|
}
|
|
112169
112110
|
function unified(before, after2, file2, folder) {
|
|
112170
|
-
const a2 =
|
|
112171
|
-
|
|
112172
|
-
|
|
112111
|
+
const a2 = path88.join(folder, "a"), b2 = path88.join(folder, "b");
|
|
112112
|
+
fs89.writeFileSync(a2, before ?? "");
|
|
112113
|
+
fs89.writeFileSync(b2, after2 ?? "");
|
|
112173
112114
|
const result = spawnSync6("git", ["diff", "--no-index", "--text", "--no-ext-diff", "--no-color", "--unified=3", before === null ? "/dev/null" : a2, after2 === null ? "/dev/null" : b2], { encoding: "utf8", maxBuffer: 16 * 1024 * 1024 });
|
|
112174
112115
|
if (result.error || result.status !== 0 && result.status !== 1) throw Error(`${file2}: ${result.error?.message ?? result.stderr}`);
|
|
112175
112116
|
const lines = result.stdout.split("\n"), start = lines.findIndex((l2) => l2.startsWith("--- "));
|
|
@@ -112179,20 +112120,20 @@ ${start < 0 ? "" : lines.slice(start + 2).join("\n")}`;
|
|
|
112179
112120
|
}
|
|
112180
112121
|
async function cmdStudioPreview(id, opts) {
|
|
112181
112122
|
if (!locate(id)) die(`no card ${id}`, "no-such-card");
|
|
112182
|
-
const destination =
|
|
112123
|
+
const destination = path88.join(ASSETS, String(id), "studio-review"), staging = `${destination}.${randomUUID8()}.tmp`, backup = `${destination}.${randomUUID8()}.previous`;
|
|
112183
112124
|
let moved = false;
|
|
112184
112125
|
try {
|
|
112185
|
-
const draft = readFolder2(
|
|
112126
|
+
const draft = readFolder2(path88.resolve(opts.folder)), base = opts.base === "empty" ? null : readFolder2(path88.resolve(opts.base));
|
|
112186
112127
|
const version = readVersion2(draft.files), baseVersion = base && readVersion2(base.files);
|
|
112187
112128
|
if (base ? !version || !baseVersion || JSON.stringify(version) !== JSON.stringify(baseVersion) : version !== null) throw Error("version.json: existing Studios need matching baseline and draft versions; use --base empty only for a new Studio without version.json");
|
|
112188
112129
|
const agents = [...agentsOf2(draft)];
|
|
112189
112130
|
for (const a2 of base ? agentsOf2(base) : []) if (!agents.some((b2) => b2.agent === a2.agent)) agents.push(a2);
|
|
112190
|
-
|
|
112131
|
+
fs89.mkdirSync(staging, { recursive: true });
|
|
112191
112132
|
const review = { version: 2, base: base && baseVersion ? { ...baseVersion, fingerprint: base.fingerprint } : null, fingerprint: draft.fingerprint, agents, files: [], results: [] };
|
|
112192
112133
|
const save3 = (file2, bytes2) => {
|
|
112193
|
-
const target =
|
|
112194
|
-
|
|
112195
|
-
|
|
112134
|
+
const target = path88.join(staging, file2);
|
|
112135
|
+
fs89.mkdirSync(path88.dirname(target), { recursive: true });
|
|
112136
|
+
fs89.writeFileSync(target, bytes2);
|
|
112196
112137
|
return file2;
|
|
112197
112138
|
};
|
|
112198
112139
|
const paths = [.../* @__PURE__ */ new Set([...Object.keys(base?.files ?? {}), ...Object.keys(draft.files)])].filter((p2) => p2 !== VERSION_FILE).sort();
|
|
@@ -112200,30 +112141,30 @@ async function cmdStudioPreview(id, opts) {
|
|
|
112200
112141
|
const before = base?.files[file2] ?? null, after2 = draft.files[file2] ?? null;
|
|
112201
112142
|
review.files.push({ path: file2, before: before === null ? null : save3(`files/${i}/before.txt`, before), after: after2 === null ? null : save3(`files/${i}/after.txt`, after2), ...before !== after2 ? { diff: save3(`files/${i}/change.diff`, unified(before, after2, file2, staging)) } : {} });
|
|
112202
112143
|
}
|
|
112203
|
-
for (const p2 of ["a", "b"])
|
|
112144
|
+
for (const p2 of ["a", "b"]) fs89.rmSync(path88.join(staging, p2), { force: true });
|
|
112204
112145
|
if (opts.results) {
|
|
112205
|
-
const manifest =
|
|
112206
|
-
const results = JSON.parse(
|
|
112146
|
+
const manifest = fs89.realpathSync(opts.results), root2 = path88.dirname(manifest);
|
|
112147
|
+
const results = JSON.parse(fs89.readFileSync(manifest, "utf8")), bad = resultProblem(results, new Set(agents.map((a2) => a2.agent)));
|
|
112207
112148
|
if (bad) throw Error(`${opts.results}: invalid ${bad}`);
|
|
112208
112149
|
const rendered = /* @__PURE__ */ new Map();
|
|
112209
112150
|
const textOf = (file2) => {
|
|
112210
|
-
const raw = rendered.get(file2) ??
|
|
112151
|
+
const raw = rendered.get(file2) ?? fs89.readFileSync(file2, "utf8");
|
|
112211
112152
|
if (/\.(html|tsx)$/i.test(file2)) for (const ref of referencesOf(manifestOf("html"), raw, true)) {
|
|
112212
112153
|
if (/^(?:data:|#)/i.test(ref.src)) continue;
|
|
112213
112154
|
if (/^(?:[a-z][\w+.-]*:|\/)/i.test(ref.src)) throw Error(`${file2}: external result dependency ${ref.src}`);
|
|
112214
|
-
const target =
|
|
112215
|
-
if (!within(root2, target) ||
|
|
112155
|
+
const target = path88.resolve(path88.dirname(file2), ref.src.replace(/[?#].*$/, ""));
|
|
112156
|
+
if (!within(root2, target) || fs89.existsSync(target) && !within(root2, fs89.realpathSync(target))) throw Error(`${file2}: outside result folder: ${ref.src}`);
|
|
112216
112157
|
}
|
|
112217
112158
|
return rendered.get(file2) ?? referenceText(file2);
|
|
112218
112159
|
};
|
|
112219
112160
|
const collectResults = () => collectSources(referencesOf(manifestOf("studio"), { results }), manifest, {
|
|
112220
112161
|
resolve: (src, owner) => {
|
|
112221
112162
|
if (/^(?:[a-z][\w+.-]*:|\/|#)/i.test(src)) throw Error(`${src}: only local result files are allowed`);
|
|
112222
|
-
const target =
|
|
112163
|
+
const target = path88.resolve(path88.dirname(owner), src);
|
|
112223
112164
|
if (!within(root2, target)) throw Error(`${src}: outside result folder`);
|
|
112224
|
-
const real2 =
|
|
112225
|
-
if (!within(root2, real2) || !
|
|
112226
|
-
if (
|
|
112165
|
+
const real2 = fs89.realpathSync(target);
|
|
112166
|
+
if (!within(root2, real2) || !fs89.statSync(real2).isFile()) throw Error(`${src}: outside result folder or not a file`);
|
|
112167
|
+
if (fs89.statSync(real2).size > ASSET_FILE_LIMIT) throw Error(`${src}: over 100 MiB`);
|
|
112227
112168
|
return { key: real2, file: real2 };
|
|
112228
112169
|
},
|
|
112229
112170
|
read: textOf,
|
|
@@ -112239,33 +112180,33 @@ async function cmdStudioPreview(id, opts) {
|
|
|
112239
112180
|
}
|
|
112240
112181
|
if (graph.length > 2e3) throw Error(`${opts.results}: too many result dependencies`);
|
|
112241
112182
|
for (const node of graph) if (node.error || node.problems.length) throw Error(`${node.file}: ${node.error ?? node.problems[0].message}`);
|
|
112242
|
-
const names3 = new Map(graph.map((n, i) => [n.key, `results/${i}${rendered.has(n.file) ? ".html" :
|
|
112243
|
-
const resolve2 = (src, owner) => names3.get(
|
|
112183
|
+
const names3 = new Map(graph.map((n, i) => [n.key, `results/${i}${rendered.has(n.file) ? ".html" : path88.extname(n.file)}`]));
|
|
112184
|
+
const resolve2 = (src, owner) => names3.get(fs89.realpathSync(path88.resolve(path88.dirname(owner), src.replace(/[?#].*$/, ""))));
|
|
112244
112185
|
for (const node of graph) {
|
|
112245
112186
|
const own = names3.get(node.key);
|
|
112246
|
-
const content = node.data === void 0 ?
|
|
112187
|
+
const content = node.data === void 0 ? fs89.readFileSync(node.file) : mapReferences(manifestOf(node.kind), node.data, (src) => path88.posix.relative(path88.posix.dirname(own), resolve2(src, node.file)));
|
|
112247
112188
|
save3(own, typeof content === "string" || Buffer.isBuffer(content) ? content : JSON.stringify(content));
|
|
112248
112189
|
}
|
|
112249
112190
|
review.results = mapReferences(manifestOf("studio"), { results }, (src) => resolve2(src, manifest)).results;
|
|
112250
112191
|
}
|
|
112251
112192
|
if (!parseReview(review)) throw Error("generated review is invalid");
|
|
112252
112193
|
save3("review.json", JSON.stringify(review, null, 2) + "\n");
|
|
112253
|
-
|
|
112254
|
-
if (
|
|
112255
|
-
|
|
112194
|
+
fs89.mkdirSync(path88.dirname(destination), { recursive: true });
|
|
112195
|
+
if (fs89.existsSync(destination)) {
|
|
112196
|
+
fs89.renameSync(destination, backup);
|
|
112256
112197
|
moved = true;
|
|
112257
112198
|
}
|
|
112258
|
-
|
|
112259
|
-
|
|
112199
|
+
fs89.renameSync(staging, destination);
|
|
112200
|
+
fs89.rmSync(backup, { recursive: true, force: true });
|
|
112260
112201
|
const tag = `<Studio src=".assets/${id}/studio-review/review.json" />`;
|
|
112261
112202
|
say(tag);
|
|
112262
|
-
return { file:
|
|
112203
|
+
return { file: path88.join(destination, "review.json"), tag };
|
|
112263
112204
|
} catch (error) {
|
|
112264
|
-
if (moved && !
|
|
112205
|
+
if (moved && !fs89.existsSync(destination)) fs89.renameSync(backup, destination);
|
|
112265
112206
|
if (error && typeof error === "object" && "kind" in error) throw error;
|
|
112266
112207
|
die(error instanceof Error ? error.message : String(error), "bad-args");
|
|
112267
112208
|
} finally {
|
|
112268
|
-
|
|
112209
|
+
fs89.rmSync(staging, { recursive: true, force: true });
|
|
112269
112210
|
}
|
|
112270
112211
|
}
|
|
112271
112212
|
var within, readVersion2;
|
|
@@ -112284,7 +112225,7 @@ var init_studio_preview = __esm({
|
|
|
112284
112225
|
init_cards();
|
|
112285
112226
|
init_paths();
|
|
112286
112227
|
init_io();
|
|
112287
|
-
within = (root2, file2) => file2.startsWith(root2 +
|
|
112228
|
+
within = (root2, file2) => file2.startsWith(root2 + path88.sep);
|
|
112288
112229
|
readVersion2 = (files) => {
|
|
112289
112230
|
if (files[VERSION_FILE] === void 0) return null;
|
|
112290
112231
|
try {
|
|
@@ -112686,9 +112627,7 @@ function declareRunning(run4, cli) {
|
|
|
112686
112627
|
const [id] = positional(vals);
|
|
112687
112628
|
await onBoard2(this, cli, () => cmdStop(id));
|
|
112688
112629
|
});
|
|
112689
|
-
verb("resume").argument("[id]", RUN_ID, String).summary("continue a run
|
|
112690
|
-
"The one command that reaches past the board: it picks the coding agent's own session back up \u2014 the conversation it was having, with everything it had already read \u2014 while the board counts the work as a fresh run. Before resuming a creation with no card, check sign-in, project access and connection. A refusal starts no run and leaves triage unchanged. Keep the triage source and request identity; reuse any task already created in Cloud. Repairing an existing card creates no other task. Example: akb raw run resume abc12345"
|
|
112691
|
-
).option("-f, --follow", "watch its log instead of returning").option("--events", "with --follow: print its structured events, one JSON object per line").option("--require-session", "refuse if the original conversation cannot be resumed").action(async function(...vals) {
|
|
112630
|
+
verb("resume").argument("[id]", RUN_ID, String).summary("continue a run from its saved work").description("Reuse its session when available; otherwise continue the original task in the same directory. Preserve task, delivery, triage source and request identities.").option("-f, --follow", "watch its log instead of returning").option("--events", "with --follow: print its structured events, one JSON object per line").option("--require-session", "legacy option; missing sessions still use the saved task context").action(async function(...vals) {
|
|
112692
112631
|
const [id] = positional(vals);
|
|
112693
112632
|
await onBoard2(this, cli, () => cmdResume(id, this.opts()));
|
|
112694
112633
|
});
|
|
@@ -112835,15 +112774,15 @@ var init_agent2 = __esm({
|
|
|
112835
112774
|
});
|
|
112836
112775
|
|
|
112837
112776
|
// src/kanban.ts
|
|
112838
|
-
import
|
|
112777
|
+
import fs92 from "node:fs";
|
|
112839
112778
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
112840
112779
|
|
|
112841
112780
|
// src/lib/cli/akb.ts
|
|
112842
112781
|
init_agent2();
|
|
112843
112782
|
|
|
112844
112783
|
// src/lib/cli/setup.ts
|
|
112845
|
-
import
|
|
112846
|
-
import
|
|
112784
|
+
import fs91 from "node:fs";
|
|
112785
|
+
import path90 from "node:path";
|
|
112847
112786
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
112848
112787
|
|
|
112849
112788
|
// src/commands/update.ts
|
|
@@ -112857,8 +112796,8 @@ init_paths();
|
|
|
112857
112796
|
init_memory();
|
|
112858
112797
|
init_yaml2();
|
|
112859
112798
|
init_version();
|
|
112860
|
-
import
|
|
112861
|
-
import
|
|
112799
|
+
import fs90 from "node:fs";
|
|
112800
|
+
import path89 from "node:path";
|
|
112862
112801
|
import { spawnSync as spawnSync8 } from "node:child_process";
|
|
112863
112802
|
var NAME = "wildcrane";
|
|
112864
112803
|
var REPO = "https://github.com/wildcrane-ai/wildcrane";
|
|
@@ -112880,10 +112819,10 @@ var Report = class {
|
|
|
112880
112819
|
for (const line of this.notes) say(` ! ${line}`);
|
|
112881
112820
|
}
|
|
112882
112821
|
};
|
|
112883
|
-
var read2 = (file2) =>
|
|
112822
|
+
var read2 = (file2) => fs90.existsSync(file2) ? fs90.readFileSync(file2, "utf8") : null;
|
|
112884
112823
|
function statOf(p2) {
|
|
112885
112824
|
try {
|
|
112886
|
-
return
|
|
112825
|
+
return fs90.lstatSync(p2);
|
|
112887
112826
|
} catch {
|
|
112888
112827
|
return null;
|
|
112889
112828
|
}
|
|
@@ -112908,10 +112847,10 @@ async function cmdUpdate2(ctx) {
|
|
|
112908
112847
|
return { updated: ctx.dir, from, to: SKILL_VERSION };
|
|
112909
112848
|
}
|
|
112910
112849
|
async function repairBoard(root2, report3, named2) {
|
|
112911
|
-
const legacy2 =
|
|
112912
|
-
const kept2 =
|
|
112913
|
-
const board2 = named2 ?? (
|
|
112914
|
-
if (!
|
|
112850
|
+
const legacy2 = path89.join(root2, "docs", "kanban");
|
|
112851
|
+
const kept2 = path89.join(root2, ".akb", "kanban");
|
|
112852
|
+
const board2 = named2 ?? (fs90.existsSync(legacy2) ? legacy2 : kept2);
|
|
112853
|
+
if (!fs90.existsSync(board2)) {
|
|
112915
112854
|
report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
|
|
112916
112855
|
return false;
|
|
112917
112856
|
}
|
|
@@ -112942,20 +112881,20 @@ function moveRuntimes(root2, board2, report3) {
|
|
|
112942
112881
|
}
|
|
112943
112882
|
}
|
|
112944
112883
|
function moveLegacyMemory(board2, report3) {
|
|
112945
|
-
const memory =
|
|
112884
|
+
const memory = path89.join(board2, "memory");
|
|
112946
112885
|
const moved = [];
|
|
112947
112886
|
for (const name of MEMORY_FILES) {
|
|
112948
|
-
const from =
|
|
112887
|
+
const from = path89.join(board2, name);
|
|
112949
112888
|
const st2 = statOf(from);
|
|
112950
112889
|
if (!st2 || !st2.isFile()) continue;
|
|
112951
|
-
|
|
112952
|
-
const to =
|
|
112890
|
+
fs90.mkdirSync(memory, { recursive: true });
|
|
112891
|
+
const to = path89.join(memory, name);
|
|
112953
112892
|
const there = read2(to);
|
|
112954
112893
|
if (there === null) {
|
|
112955
|
-
|
|
112894
|
+
fs90.renameSync(from, to);
|
|
112956
112895
|
moved.push(name);
|
|
112957
112896
|
} else if (there === read2(from)) {
|
|
112958
|
-
|
|
112897
|
+
fs90.rmSync(from);
|
|
112959
112898
|
moved.push(name);
|
|
112960
112899
|
} else {
|
|
112961
112900
|
report3.notes.push(`both docs/kanban/${name} and docs/kanban/memory/${name} exist and differ \u2014 merge them by hand`);
|
|
@@ -112964,23 +112903,23 @@ function moveLegacyMemory(board2, report3) {
|
|
|
112964
112903
|
if (moved.length) report3.did.push(`moved the memory set into docs/kanban/memory/: ${moved.join(", ")}`);
|
|
112965
112904
|
}
|
|
112966
112905
|
function dropRecordFile(board2) {
|
|
112967
|
-
const file2 =
|
|
112968
|
-
if (!
|
|
112969
|
-
|
|
112906
|
+
const file2 = path89.join(board2, "record.csv");
|
|
112907
|
+
if (!fs90.existsSync(file2)) return null;
|
|
112908
|
+
fs90.rmSync(file2);
|
|
112970
112909
|
return "removed docs/kanban/record.csv (the planning scores it fed are gone)";
|
|
112971
112910
|
}
|
|
112972
112911
|
function dropModuleGoals(board2, report3) {
|
|
112973
|
-
const memory =
|
|
112974
|
-
if (!
|
|
112975
|
-
const root2 = read2(
|
|
112912
|
+
const memory = path89.join(board2, "memory");
|
|
112913
|
+
if (!fs90.existsSync(memory)) return;
|
|
112914
|
+
const root2 = read2(path89.join(memory, "goal.md"));
|
|
112976
112915
|
let dropped = 0;
|
|
112977
|
-
for (const entry of
|
|
112916
|
+
for (const entry of fs90.readdirSync(memory, { withFileTypes: true })) {
|
|
112978
112917
|
if (!entry.isDirectory()) continue;
|
|
112979
|
-
const file2 =
|
|
112918
|
+
const file2 = path89.join(memory, entry.name, "goal.md");
|
|
112980
112919
|
const text5 = read2(file2);
|
|
112981
112920
|
if (text5 === null) continue;
|
|
112982
112921
|
if (text5 === root2 || text5.includes(UNFILLED) || !goalWords(text5)) {
|
|
112983
|
-
|
|
112922
|
+
fs90.rmSync(file2);
|
|
112984
112923
|
dropped++;
|
|
112985
112924
|
} else {
|
|
112986
112925
|
report3.notes.push(
|
|
@@ -113002,10 +112941,10 @@ var PLAN_LEADS = {
|
|
|
113002
112941
|
var GONE_LEADS = ["software-planner", "planner"];
|
|
113003
112942
|
function planLeads(board2) {
|
|
113004
112943
|
const leads = { ...PLAN_LEADS };
|
|
113005
|
-
const root2 =
|
|
113006
|
-
for (const entry of
|
|
112944
|
+
const root2 = path89.join(board2, "studios");
|
|
112945
|
+
for (const entry of fs90.existsSync(root2) ? fs90.readdirSync(root2, { withFileTypes: true }) : []) {
|
|
113007
112946
|
if (!entry.isDirectory()) continue;
|
|
113008
|
-
const meta = splitFrontmatter(read2(
|
|
112947
|
+
const meta = splitFrontmatter(read2(path89.join(root2, entry.name, "STUDIO.md")) ?? "").meta;
|
|
113009
112948
|
const stages = meta === null ? void 0 : parseYamlBlock(meta).stages;
|
|
113010
112949
|
const plan = stages && typeof stages === "object" && !Array.isArray(stages) ? stages.plan : void 0;
|
|
113011
112950
|
const lead = plan && typeof plan === "object" && !Array.isArray(plan) && typeof plan.lead === "string" ? plan.lead.trim() : "";
|
|
@@ -113014,30 +112953,30 @@ function planLeads(board2) {
|
|
|
113014
112953
|
return leads;
|
|
113015
112954
|
}
|
|
113016
112955
|
function movePlanRules(board2, report3) {
|
|
113017
|
-
const rules =
|
|
112956
|
+
const rules = path89.join(board2, "rules");
|
|
113018
112957
|
const moved = [];
|
|
113019
112958
|
for (const [id, leads] of Object.entries(planLeads(board2))) {
|
|
113020
112959
|
for (const lead of leads) {
|
|
113021
|
-
const from =
|
|
112960
|
+
const from = path89.join(rules, `${lead}.md`);
|
|
113022
112961
|
const rule = read2(from)?.trim();
|
|
113023
112962
|
if (!rule) continue;
|
|
113024
|
-
const to =
|
|
112963
|
+
const to = path89.join(rules, "studios", `${id}.md`);
|
|
113025
112964
|
const there = read2(to)?.trim() ?? "";
|
|
113026
112965
|
if (!there.includes(rule)) {
|
|
113027
|
-
|
|
113028
|
-
|
|
112966
|
+
fs90.mkdirSync(path89.dirname(to), { recursive: true });
|
|
112967
|
+
fs90.writeFileSync(to, `${[there, rule].filter(Boolean).join("\n\n")}
|
|
113029
112968
|
`);
|
|
113030
112969
|
moved.push(`${lead} \u2192 ${id}`);
|
|
113031
112970
|
}
|
|
113032
112971
|
}
|
|
113033
112972
|
}
|
|
113034
|
-
for (const lead of GONE_LEADS)
|
|
112973
|
+
for (const lead of GONE_LEADS) fs90.rmSync(path89.join(rules, `${lead}.md`), { force: true });
|
|
113035
112974
|
if (moved.length) report3.did.push(`made each plan agent's rule its studio's card rule (docs/kanban/rules/studios/): ${moved.join(", ")}`);
|
|
113036
112975
|
}
|
|
113037
112976
|
function noteOldStudios(board2, report3) {
|
|
113038
112977
|
const old = (dir, file2, keys) => {
|
|
113039
|
-
const root2 =
|
|
113040
|
-
return (
|
|
112978
|
+
const root2 = path89.join(board2, dir);
|
|
112979
|
+
return (fs90.existsSync(root2) ? fs90.readdirSync(root2, { withFileTypes: true }) : []).filter((e2) => e2.isDirectory() && keys.test(splitFrontmatter(read2(path89.join(root2, e2.name, file2)) ?? "").meta ?? "")).map((e2) => `docs/kanban/${dir}/${e2.name}/${file2}`);
|
|
113041
112980
|
};
|
|
113042
112981
|
const files = [...old("studios", "STUDIO.md", /^(stages|delivers):/m), ...old("agents", "AGENT.md", /^\s+(hook|lead):/m)];
|
|
113043
112982
|
if (files.length) {
|
|
@@ -113047,7 +112986,7 @@ function noteOldStudios(board2, report3) {
|
|
|
113047
112986
|
}
|
|
113048
112987
|
}
|
|
113049
112988
|
function checkConfig(board2, report3) {
|
|
113050
|
-
const current = read2(
|
|
112989
|
+
const current = read2(path89.join(board2, "config.md"));
|
|
113051
112990
|
if (!current) return;
|
|
113052
112991
|
const added = missingConfigKeys(current);
|
|
113053
112992
|
if (added.length) {
|
|
@@ -113057,7 +112996,7 @@ function checkConfig(board2, report3) {
|
|
|
113057
112996
|
}
|
|
113058
112997
|
}
|
|
113059
112998
|
function checkModules(board2, report3) {
|
|
113060
|
-
const map2 = read2(
|
|
112999
|
+
const map2 = read2(path89.join(board2, "modules.md"));
|
|
113061
113000
|
if (map2 && map2.includes(UNFILLED)) {
|
|
113062
113001
|
report3.notes.push(
|
|
113063
113002
|
"docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
|
|
@@ -113111,14 +113050,14 @@ function declareSetup(program2, cli) {
|
|
|
113111
113050
|
program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
|
|
113112
113051
|
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");
|
|
113113
113052
|
const where = (cmd) => {
|
|
113114
|
-
const dir =
|
|
113115
|
-
if (!
|
|
113053
|
+
const dir = path90.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
|
|
113054
|
+
if (!fs91.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
|
|
113116
113055
|
return dir;
|
|
113117
113056
|
};
|
|
113118
113057
|
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() {
|
|
113119
113058
|
const dir = where(this);
|
|
113120
113059
|
const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
|
|
113121
|
-
const board2 = named2 ?
|
|
113060
|
+
const board2 = named2 ? path90.resolve(cli.cwd, named2) : null;
|
|
113122
113061
|
await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
|
|
113123
113062
|
});
|
|
113124
113063
|
program2.command("__rules", { hidden: true }).action(function() {
|
|
@@ -113163,7 +113102,7 @@ function invokedDirectly() {
|
|
|
113163
113102
|
const entry = process.argv[1];
|
|
113164
113103
|
if (!entry) return false;
|
|
113165
113104
|
try {
|
|
113166
|
-
return
|
|
113105
|
+
return fs92.realpathSync(entry) === fs92.realpathSync(SELF2);
|
|
113167
113106
|
} catch {
|
|
113168
113107
|
return false;
|
|
113169
113108
|
}
|