wildcrane-runner 0.6.33 → 0.6.35
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/LICENSE +201 -104
- package/README.md +3 -3
- package/dist/akb/dist/kanban.mjs +159 -89
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/launcher.mjs +310 -237
- package/dist/plugin.mjs +79488 -0
- package/dist/runner.mjs +211 -198
- package/dist/settings.mjs +338 -264
- package/package.json +2 -2
package/dist/akb/dist/kanban.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// ai4kanban 0.11.
|
|
2
|
+
// ai4kanban 0.11.31 — built by runner/scripts/build.mjs. Do not edit.
|
|
3
3
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
4
4
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
5
5
|
var __create = Object.create;
|
|
@@ -2327,6 +2327,12 @@ function eventModel(ev) {
|
|
|
2327
2327
|
return void 0;
|
|
2328
2328
|
}
|
|
2329
2329
|
function whyItFailed(ev) {
|
|
2330
|
+
const why2 = failedWith(ev);
|
|
2331
|
+
const fix = USER_FIXES.find(([pattern]) => pattern.test(why2))?.[1];
|
|
2332
|
+
return fix ? `${why2}
|
|
2333
|
+
${fix}` : why2;
|
|
2334
|
+
}
|
|
2335
|
+
function failedWith(ev) {
|
|
2330
2336
|
const errors = Array.isArray(ev.errors) ? ev.errors.map(str).filter(Boolean) : [];
|
|
2331
2337
|
if (errors.length) return errors.join("; ");
|
|
2332
2338
|
const named2 = str(ev.subtype) || str(ev.terminal_reason);
|
|
@@ -2467,7 +2473,7 @@ function usageOf(raw) {
|
|
|
2467
2473
|
};
|
|
2468
2474
|
return parsed.input + parsed.cacheCreation + parsed.cacheRead + parsed.output > 0 ? parsed : void 0;
|
|
2469
2475
|
}
|
|
2470
|
-
var ARG_KEYS, TOOL_KINDS2, addUsage;
|
|
2476
|
+
var ARG_KEYS, TOOL_KINDS2, USER_FIXES, addUsage;
|
|
2471
2477
|
var init_claude_stream = __esm({
|
|
2472
2478
|
"../cli/src/lib/agent/wire/claude-stream.ts"() {
|
|
2473
2479
|
"use strict";
|
|
@@ -2487,6 +2493,10 @@ var init_claude_stream = __esm({
|
|
|
2487
2493
|
WebFetch: "fetch",
|
|
2488
2494
|
WebSearch: "fetch"
|
|
2489
2495
|
};
|
|
2496
|
+
USER_FIXES = [
|
|
2497
|
+
[/failed to authenticate|invalid api key|oauth token|please run \/login|not logged in/i, "Sign in to Claude Code again: run `claude` and enter /login."],
|
|
2498
|
+
[/usage limit|credit balance is too low|quota/i, "Wait for the usage limit to reset, or add credit, then press Resume."]
|
|
2499
|
+
];
|
|
2490
2500
|
addUsage = (a2, b2) => ({
|
|
2491
2501
|
input: a2.input + b2.input,
|
|
2492
2502
|
cacheCreation: a2.cacheCreation + b2.cacheCreation,
|
|
@@ -3243,7 +3253,7 @@ var init_package = __esm({
|
|
|
3243
3253
|
"../cli/package.json"() {
|
|
3244
3254
|
package_default = {
|
|
3245
3255
|
name: "wildcrane",
|
|
3246
|
-
version: "0.11.
|
|
3256
|
+
version: "0.11.31",
|
|
3247
3257
|
akbContract: 7,
|
|
3248
3258
|
description: "WildCrane's `akb` command \u2014 scaffold the Markdown board under docs/kanban/, put an agent on a card, and carry the flows the agent works by.",
|
|
3249
3259
|
keywords: [
|
|
@@ -3256,7 +3266,7 @@ var init_package = __esm({
|
|
|
3256
3266
|
"markdown",
|
|
3257
3267
|
"board"
|
|
3258
3268
|
],
|
|
3259
|
-
license: "
|
|
3269
|
+
license: "Apache-2.0",
|
|
3260
3270
|
homepage: "https://wildcrane.ai/",
|
|
3261
3271
|
repository: {
|
|
3262
3272
|
type: "git",
|
|
@@ -9642,7 +9652,7 @@ function writeDraft(def, settings) {
|
|
|
9642
9652
|
function renameWorkflow(id, name) {
|
|
9643
9653
|
const draft = draftId();
|
|
9644
9654
|
if (!draft) return readOnly();
|
|
9645
|
-
if (id !== draft) return { ok: false, ...refusal("workflowReadOnly", `only the draft, \`${draft}\`, is
|
|
9655
|
+
if (id !== draft) return { ok: false, ...refusal("workflowReadOnly", `only the draft, \`${draft}\`, is renamed here`, { id }) };
|
|
9646
9656
|
const wanted = trimmedName(name);
|
|
9647
9657
|
if (!wanted) return { ok: false, ...refusal("workflowUnnamed", "a workflow needs a name") };
|
|
9648
9658
|
if (nameTaken(wanted, id)) return { ok: false, ...refusal("workflowTaken", `this workspace already has a workflow called "${wanted}"`, { name: wanted }) };
|
|
@@ -9813,7 +9823,7 @@ var init_workflows = __esm({
|
|
|
9813
9823
|
});
|
|
9814
9824
|
draftDef = (id) => boardWorkflowDefs().defs.find((d2) => d2.id === id);
|
|
9815
9825
|
notFound = (id) => ({ ok: false, ...refusal("workflowNotFound", `this board has no \`${id}\` workflow`, { id }) });
|
|
9816
|
-
readOnly = () => ({ ok: false, ...refusal("workflowReadOnly", "
|
|
9826
|
+
readOnly = () => ({ ok: false, ...refusal("workflowReadOnly", "Only a Workflow builder draft is renamed here; change a workflow with `akb workflow pull` and `push`.") });
|
|
9817
9827
|
trimmedName = (name) => name.replace(/\s+/g, " ").trim();
|
|
9818
9828
|
nameTaken = (name, except = "") => workflows().some((w2) => w2.id !== except && trimmedName(w2.name).toLowerCase() === trimmedName(name).toLowerCase());
|
|
9819
9829
|
scheduledAgent = (id, agent) => {
|
|
@@ -9965,6 +9975,14 @@ import fs31 from "node:fs";
|
|
|
9965
9975
|
import os4 from "node:os";
|
|
9966
9976
|
import path34 from "node:path";
|
|
9967
9977
|
import crypto3 from "node:crypto";
|
|
9978
|
+
function hostSession() {
|
|
9979
|
+
const { CLAUDE_CODE_SESSION_ID: claude, CODEX_THREAD_ID: codex, CURSOR_CONVERSATION_ID: cursor, KIMI_SESSION_ID: kimi, WILDCRANE_DISCUSSION: discussion2 } = process.env;
|
|
9980
|
+
if (discussion2) return { id: discussion2, host: "discussion" };
|
|
9981
|
+
if (claude) return { id: claude, host: "claude-code" };
|
|
9982
|
+
if (codex) return { id: codex, host: "codex" };
|
|
9983
|
+
if (cursor) return { id: cursor, host: "cursor" };
|
|
9984
|
+
return kimi ? { id: kimi, host: "kimi" } : null;
|
|
9985
|
+
}
|
|
9968
9986
|
async function request(method, route2, body) {
|
|
9969
9987
|
if (externalGoalSession()) process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME || path34.join(os4.homedir(), ".wildcrane");
|
|
9970
9988
|
const token3 = await accessToken();
|
|
@@ -9996,10 +10014,11 @@ function goalsOf(d2) {
|
|
|
9996
10014
|
return goals;
|
|
9997
10015
|
}
|
|
9998
10016
|
async function discussion() {
|
|
9999
|
-
const session =
|
|
10017
|
+
const session = hostSession();
|
|
10000
10018
|
if (!session) die("Goals exist only inside a WildCrane goal discussion.");
|
|
10001
10019
|
const home3 = process.env.WILDCRANE_HOME || path34.join(os4.homedir(), ".wildcrane");
|
|
10002
10020
|
process.env.AI4KANBAN_HOME ??= home3;
|
|
10021
|
+
if (session.host === "discussion") return request("GET", `/v1/discussions/${encodeURIComponent(session.id)}`);
|
|
10003
10022
|
const machineFile2 = path34.join(home3, "machine.json");
|
|
10004
10023
|
let machine;
|
|
10005
10024
|
try {
|
|
@@ -10019,7 +10038,7 @@ async function discussion() {
|
|
|
10019
10038
|
return false;
|
|
10020
10039
|
}
|
|
10021
10040
|
}).sort((a2, b2) => b2.path.length - a2.path.length)[0];
|
|
10022
|
-
return request("POST", "/v1/discussions/external", { requestId: session, host:
|
|
10041
|
+
return request("POST", "/v1/discussions/external", { requestId: session.id, host: session.host, ...folder ? { project: folder.project } : {} });
|
|
10023
10042
|
}
|
|
10024
10043
|
async function withGoalDiscussion(action, save3 = false) {
|
|
10025
10044
|
const d2 = await discussion();
|
|
@@ -10077,7 +10096,7 @@ var init_goal_cloud = __esm({
|
|
|
10077
10096
|
init_paths();
|
|
10078
10097
|
init_io();
|
|
10079
10098
|
init_goal();
|
|
10080
|
-
externalGoalSession = () => !goalsFile() && !process.env.KANBAN_RUN && !process.env.WILDCRANE_JOB && !process.env.AI4KANBAN_BOARD && Boolean(
|
|
10099
|
+
externalGoalSession = () => !goalsFile() && !process.env.KANBAN_RUN && !process.env.WILDCRANE_JOB && !process.env.AI4KANBAN_BOARD && Boolean(hostSession());
|
|
10081
10100
|
cloudGoal = (args, opts) => withGoalDiscussion(() => cmdGoal(args, opts), true);
|
|
10082
10101
|
cloudGoalWorkflows = () => withGoalDiscussion(cmdGoalWorkflows);
|
|
10083
10102
|
}
|
|
@@ -15214,7 +15233,7 @@ var init_Asset = __esm({
|
|
|
15214
15233
|
var Compare_default;
|
|
15215
15234
|
var init_Compare = __esm({
|
|
15216
15235
|
"../cli/src/components/Compare.md"() {
|
|
15217
|
-
Compare_default = '# Compare\n\nShow two
|
|
15236
|
+
Compare_default = '# Compare\n\nShow two files with `<Compare a="<src>" b="<src>" label="..." a-label="..." b-label="..." />` alone in a paragraph; never render a side-by-side file for it. Inline and fenced examples remain text.\n\n- **Sides**: either side may be anything an Asset shows, of different kinds, but not another compare; two images or two videos share one viewer, any other pair shows as two Assets.\n- **Video shots**: add `shots="<src>"`, a JSON list of `{ "id": "S1", "start": 0, "end": 2.25, "name": "..." }` covering video A in order, or a storyboard of A.\n- **Storyboard pairing**: beside video A, B may be a storyboard of it; it shows the shot with the id A is on, beside that shot of a storyboard `shots`.\n- **Data contract**: follow the producing agent\'s file contract and validator for storyboards.\n';
|
|
15218
15237
|
}
|
|
15219
15238
|
});
|
|
15220
15239
|
|
|
@@ -15222,7 +15241,7 @@ var init_Compare = __esm({
|
|
|
15222
15241
|
var Storyboard_default;
|
|
15223
15242
|
var init_Storyboard = __esm({
|
|
15224
15243
|
"../cli/src/components/Storyboard.md"() {
|
|
15225
|
-
Storyboard_default = '# Storyboard\n\nShow a sequence with `<Storyboard src=".assets/<card id>/<storyboard>.json" label="..." />` alone in a paragraph; `label` is optional. Inline and fenced examples remain text.\n\n- **Data contract**: follow the producing agent\'s storyboard contract and validator for its shots or slides, keeping stable IDs and reachable preview files.\n';
|
|
15244
|
+
Storyboard_default = '# Storyboard\n\nShow a sequence with `<Storyboard src=".assets/<card id>/<storyboard>.json" label="..." />` alone in a paragraph; `label` is optional. Inline and fenced examples remain text.\n\n- **Frames**: a shot frame or slide preview may be anything an Asset shows, but not a storyboard or compare.\n- **Data contract**: follow the producing agent\'s storyboard contract and validator for its shots or slides, keeping stable IDs and reachable preview files.\n';
|
|
15226
15245
|
}
|
|
15227
15246
|
});
|
|
15228
15247
|
|
|
@@ -16236,7 +16255,8 @@ function endedDeliveryRefusal(r2, refusals) {
|
|
|
16236
16255
|
if (refusals?.has(r2.deliveryId)) return refusals.get(r2.deliveryId);
|
|
16237
16256
|
const delivery = findDelivery(r2.deliveryId);
|
|
16238
16257
|
const ended = delivery && delivery.status !== "active" && (delivery.status !== "failed" || delivery.worktree);
|
|
16239
|
-
const
|
|
16258
|
+
const repairsShipped = !!r2.formatRepair && delivery?.status === "finished";
|
|
16259
|
+
const why2 = ended && !repairsShipped ? resumeRefusal(delivery) : void 0;
|
|
16240
16260
|
refusals?.set(r2.deliveryId, why2);
|
|
16241
16261
|
return why2;
|
|
16242
16262
|
}
|
|
@@ -16749,6 +16769,7 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
|
|
|
16749
16769
|
if (locked) return locked;
|
|
16750
16770
|
all2.push(record);
|
|
16751
16771
|
const delivery = store.deliveries.find((d2) => d2.deliveryId === prev.deliveryId && d2.status === "active");
|
|
16772
|
+
if (!delivery && record.formatRepair) record.deliveryId = prev.deliveryId;
|
|
16752
16773
|
if (delivery) {
|
|
16753
16774
|
delivery.sessions.push(record.sessionId);
|
|
16754
16775
|
delivery.steps.push({ step: "resume", at: record.startedAt });
|
|
@@ -17769,7 +17790,7 @@ function storyboardMarkers(body, tagOf = storyboardTag) {
|
|
|
17769
17790
|
return found2;
|
|
17770
17791
|
}
|
|
17771
17792
|
function assetName(src, cardId2, exts, nested = false) {
|
|
17772
|
-
const expected = `.assets/${cardId2}/<file
|
|
17793
|
+
const expected = `.assets/${cardId2}/<file>${!exts.length ? "" : `.${exts.length === 1 ? exts[0] : `{${exts.join(",")}}`}`} in this card's asset folder`;
|
|
17773
17794
|
if (/^[a-z][a-z0-9+.-]*:/i.test(src)) return { expected, actual: `an external address ${JSON.stringify(src)}` };
|
|
17774
17795
|
const parts = src.split("/");
|
|
17775
17796
|
if (parts[0] !== ".assets" || parts.length < 3 || !nested && parts.length !== 3) return { expected, actual: JSON.stringify(src) };
|
|
@@ -17777,7 +17798,7 @@ function assetName(src, cardId2, exts, nested = false) {
|
|
|
17777
17798
|
if (!parts.slice(2).every((part) => SEGMENT2.test(part))) return { expected, actual: JSON.stringify(src) };
|
|
17778
17799
|
const name = parts.slice(2).join("/");
|
|
17779
17800
|
const ext = name.split(".").pop().toLowerCase();
|
|
17780
|
-
if (!name.includes(".") || !exts.includes(ext)) return { expected, actual: `file type ${JSON.stringify(name.includes(".") ? ext : "")}` };
|
|
17801
|
+
if (exts.length && (!name.includes(".") || !exts.includes(ext))) return { expected, actual: `file type ${JSON.stringify(name.includes(".") ? ext : "")}` };
|
|
17781
17802
|
return { name };
|
|
17782
17803
|
}
|
|
17783
17804
|
var TAG2, attr, SRC_ATTR, LABEL_ATTR, SEGMENT2, storyboardTag, workflowTag;
|
|
@@ -17802,7 +17823,7 @@ var init_storyboard = __esm({
|
|
|
17802
17823
|
var compare_default;
|
|
17803
17824
|
var init_compare2 = __esm({
|
|
17804
17825
|
"../artifact-sdk/src/builtin/compare.json"() {
|
|
17805
|
-
compare_default = '{\n "name": "compare",\n "title": { "en": "Compare", "zh": "\u5BF9\u6BD4" },\n "types": ["compare"],\n "schema": {\n "type": "object",\n "required": ["a", "b"],\n "properties": { "a": { "type": "string" }, "b": { "type": "string" } }\n },\n "references": [\n { "json": "/a", "types": ["storyboard", "compare"] },\n { "json": "/b", "types": ["storyboard", "compare"] },\n { "json": "/shots", "types": ["storyboard", "compare"] }\n ]\n}\n';
|
|
17826
|
+
compare_default = '{\n "name": "compare",\n "title": { "en": "Compare", "zh": "\u5BF9\u6BD4" },\n "types": ["compare"],\n "schema": {\n "type": "object",\n "required": ["a", "b"],\n "properties": { "a": { "type": "string" }, "b": { "type": "string" } }\n },\n "references": [\n { "json": "/a", "types": ["storyboard", "compare", "spritesheet", "workflow"] },\n { "json": "/b", "types": ["storyboard", "compare", "spritesheet", "workflow"] },\n { "json": "/shots", "types": ["storyboard", "compare", "spritesheet", "workflow"] }\n ]\n}\n';
|
|
17806
17827
|
}
|
|
17807
17828
|
});
|
|
17808
17829
|
|
|
@@ -17863,7 +17884,7 @@ var init_spritesheet = __esm({
|
|
|
17863
17884
|
var storyboard_default;
|
|
17864
17885
|
var init_storyboard2 = __esm({
|
|
17865
17886
|
"../artifact-sdk/src/builtin/storyboard.json"() {
|
|
17866
|
-
storyboard_default = '{\n "name": "storyboard",\n "title": { "en": "Storyboard", "zh": "\u5206\u955C" },\n "types": ["storyboard"],\n "schema": {\n "type": "object",\n "anyOf": [{ "required": ["shots"] }, { "required": ["slides"] }],\n "properties": {\n "shots": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": { "frames": { "type": "array", "items": { "type": "object", "properties": { "src": { "type": "string" } } } } }\n }\n },\n "slides": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": {\n "preview": { "type": "object", "properties": { "src": { "type": "string" } } },\n "assets": { "type": "array", "items": { "type": "string" } }\n }\n }\n }\n }\n },\n "references": [\n { "json": "/shots/*/frames/*/src" },\n { "json": "/slides/*/preview/src" },\n { "json": "/slides/*/assets/*" }\n ]\n}\n';
|
|
17887
|
+
storyboard_default = '{\n "name": "storyboard",\n "title": { "en": "Storyboard", "zh": "\u5206\u955C" },\n "types": ["storyboard"],\n "schema": {\n "type": "object",\n "anyOf": [{ "required": ["shots"] }, { "required": ["slides"] }],\n "properties": {\n "shots": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": { "frames": { "type": "array", "items": { "type": "object", "properties": { "src": { "type": "string" } } } } }\n }\n },\n "slides": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": {\n "preview": { "type": "object", "properties": { "src": { "type": "string" } } },\n "assets": { "type": "array", "items": { "type": "string" } }\n }\n }\n }\n }\n },\n "references": [\n { "json": "/shots/*/frames/*/src", "types": ["storyboard", "compare", "spritesheet", "workflow"] },\n { "json": "/slides/*/preview/src", "types": ["storyboard", "compare", "spritesheet", "workflow"] },\n { "json": "/slides/*/assets/*" }\n ]\n}\n';
|
|
17867
17888
|
}
|
|
17868
17889
|
});
|
|
17869
17890
|
|
|
@@ -18082,7 +18103,7 @@ function bodyReferences(body) {
|
|
|
18082
18103
|
for (const p2 of m[2].matchAll(/([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) a2[p2[1]] = p2[2] ?? p2[3];
|
|
18083
18104
|
if (m[1] === "Compare") {
|
|
18084
18105
|
if (!a2.a || !a2.b) continue;
|
|
18085
|
-
for (const k2 of ["a", "b", "shots"]) if (a2[k2]) out.push({ src: a2[k2], types:
|
|
18106
|
+
for (const k2 of ["a", "b", "shots"]) if (a2[k2]) out.push({ src: a2[k2], types: ARRANGED });
|
|
18086
18107
|
} else if (a2.src) {
|
|
18087
18108
|
out.push({ src: a2.src, types: m[1] === "Storyboard" ? STORYBOARD : m[1] === "Workflow" ? WORKFLOW : m[1] === "Asset" ? ASSET : [] });
|
|
18088
18109
|
if (a2.variants) {
|
|
@@ -18108,13 +18129,13 @@ function kindOf(ext) {
|
|
|
18108
18129
|
if (type.startsWith("image/")) return "image";
|
|
18109
18130
|
return type.startsWith("video/") || type.startsWith("audio/") ? "video" : "asset";
|
|
18110
18131
|
}
|
|
18111
|
-
var STORYBOARD, WORKFLOW,
|
|
18132
|
+
var STORYBOARD, WORKFLOW, ARRANGED, ASSET, isObject2, bodySources, TYPES;
|
|
18112
18133
|
var init_references = __esm({
|
|
18113
18134
|
"../artifact-sdk/src/internal/references.ts"() {
|
|
18114
18135
|
"use strict";
|
|
18115
18136
|
STORYBOARD = ["storyboard"];
|
|
18116
18137
|
WORKFLOW = ["workflow"];
|
|
18117
|
-
|
|
18138
|
+
ARRANGED = ["storyboard", "compare", "spritesheet", "workflow"];
|
|
18118
18139
|
ASSET = ["spritesheet", "asset"];
|
|
18119
18140
|
isObject2 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
18120
18141
|
bodySources = (body) => [...new Set(bodyReferences(body).map((r2) => r2.src))];
|
|
@@ -18304,10 +18325,18 @@ function validatePreviewFiles(card, id, text5) {
|
|
|
18304
18325
|
read: referenceText,
|
|
18305
18326
|
retained: () => []
|
|
18306
18327
|
});
|
|
18328
|
+
const kinds = new Map(graph.map((n) => [n.key, n.kind]));
|
|
18307
18329
|
for (const node of graph) {
|
|
18308
18330
|
for (const p2 of node.problems) {
|
|
18309
18331
|
errors.push({ file: rel(node.file ?? card), line: p2.line ?? 1, rule: "preview-file", message: `${p2.at ? `${p2.at}: ` : ""}${p2.src}: ${p2.message}. Fix the reference or add the file.` });
|
|
18310
18332
|
}
|
|
18333
|
+
if (node.kind !== "storyboard" && node.kind !== "compare") continue;
|
|
18334
|
+
for (const [src, key] of node.dependencies) {
|
|
18335
|
+
const kind = kinds.get(key);
|
|
18336
|
+
if (kind === "compare" || node.kind === "storyboard" && kind === "storyboard") {
|
|
18337
|
+
errors.push({ file: rel(node.file ?? card), line: 1, rule: "preview-nesting", message: `${src} is a ${kind}, which cannot go inside a ${node.kind}. Name its files directly.` });
|
|
18338
|
+
}
|
|
18339
|
+
}
|
|
18311
18340
|
}
|
|
18312
18341
|
return errors;
|
|
18313
18342
|
}
|
|
@@ -18557,17 +18586,27 @@ function compareProblem(attrs, id) {
|
|
|
18557
18586
|
const dir = path56.join(ASSETS, String(id));
|
|
18558
18587
|
const src = (message) => ({ rule: "compare-src", message });
|
|
18559
18588
|
const shots = (message) => ({ rule: "compare-shots", message });
|
|
18589
|
+
const json = (file) => {
|
|
18590
|
+
try {
|
|
18591
|
+
return file.endsWith(".json") ? JSON.parse(fs53.readFileSync(file, "utf8")) : null;
|
|
18592
|
+
} catch {
|
|
18593
|
+
return null;
|
|
18594
|
+
}
|
|
18595
|
+
};
|
|
18596
|
+
const files2 = {};
|
|
18560
18597
|
for (const side of ["a", "b"]) {
|
|
18561
|
-
const named2 = assetName(attrs[side], id, [
|
|
18598
|
+
const named2 = assetName(attrs[side], id, []);
|
|
18562
18599
|
if (!("name" in named2)) return src(`Compare ${side} is ${named2.actual}; expected ${named2.expected}.`);
|
|
18563
|
-
|
|
18600
|
+
const file = inside(dir, named2.name);
|
|
18601
|
+
if (!file) return src(`Compare ${side} ${attrs[side]} names no file in this card's asset folder. Write the file there or fix the path.`);
|
|
18602
|
+
const data = files2[side] = json(file);
|
|
18603
|
+
if (typeof data?.a === "string" && typeof data.b === "string") return src(`Compare ${side} ${attrs[side]} is another compare. Compare its two files directly.`);
|
|
18564
18604
|
}
|
|
18565
|
-
const
|
|
18566
|
-
const
|
|
18567
|
-
|
|
18568
|
-
if (!script && kind !== compareKind(attrs.b)) return src("Compare a and b must both be images or both be videos.");
|
|
18605
|
+
const video = compareKind(attrs.a) === "video";
|
|
18606
|
+
const board2 = files2.b;
|
|
18607
|
+
const script = video && Array.isArray(board2?.shots);
|
|
18569
18608
|
if (attrs.shots === void 0) return script ? shots('shots is required when b is a storyboard. Add shots="..." naming a storyboard or shots list of video a.') : null;
|
|
18570
|
-
if (
|
|
18609
|
+
if (!video || !(script || compareKind(attrs.b) === "video")) return shots("shots is for a video beside another video or its storyboard. Remove it from this Compare tag.");
|
|
18571
18610
|
const read5 = (at2) => {
|
|
18572
18611
|
const named2 = assetName(at2, id, ["json"]);
|
|
18573
18612
|
if (!("name" in named2)) return { message: `Compare shots is ${named2.actual}; expected ${named2.expected}.` };
|
|
@@ -18584,12 +18623,10 @@ function compareProblem(attrs, id) {
|
|
|
18584
18623
|
const why2 = Array.isArray(list.data) ? shotsProblem(list.data) : storyboardProblem(list.data);
|
|
18585
18624
|
if (why2) return shots(`${attrs.shots}: ${why2}`);
|
|
18586
18625
|
if (!script) return null;
|
|
18587
|
-
const
|
|
18588
|
-
if ("message" in b2) return src(b2.message);
|
|
18589
|
-
const bad = storyboardProblem(b2.data);
|
|
18626
|
+
const bad = storyboardProblem(board2);
|
|
18590
18627
|
if (bad) return src(`${attrs.b}: ${bad}`);
|
|
18591
18628
|
const known2 = new Set((Array.isArray(list.data) ? list.data : list.data.shots).map((s) => s.id));
|
|
18592
|
-
const extra =
|
|
18629
|
+
const extra = board2.shots.find((s) => !known2.has(s.id));
|
|
18593
18630
|
return extra ? shots(`${attrs.b} has shot ${extra.id}, which ${attrs.shots} lacks. Add ${extra.id} to ${attrs.shots}, or drop it from ${attrs.b}.`) : null;
|
|
18594
18631
|
}
|
|
18595
18632
|
function validateStoryboards(file, id, text5) {
|
|
@@ -18657,6 +18694,7 @@ function validateHumanSection(file, text5, { agent }) {
|
|
|
18657
18694
|
if (heading > markers[0]) return [{ ...where, line: heading, message: `Move ## ${title} above <!-- agent -->: the \`${agent}\` agent's output is for the user to review.` }];
|
|
18658
18695
|
return [];
|
|
18659
18696
|
}
|
|
18697
|
+
var formatProblems;
|
|
18660
18698
|
var init_spec_contract = __esm({
|
|
18661
18699
|
"../cli/src/lib/spec-contract.ts"() {
|
|
18662
18700
|
"use strict";
|
|
@@ -18667,6 +18705,7 @@ var init_spec_contract = __esm({
|
|
|
18667
18705
|
init_storyboard();
|
|
18668
18706
|
init_preview_files();
|
|
18669
18707
|
init_validate();
|
|
18708
|
+
formatProblems = (errors) => ["Task format problems:", ...errors.map((e2) => `- ${e2.message}`)].join("\n");
|
|
18670
18709
|
}
|
|
18671
18710
|
});
|
|
18672
18711
|
|
|
@@ -21921,7 +21960,15 @@ var init_board3 = __esm({
|
|
|
21921
21960
|
var card_chat_default;
|
|
21922
21961
|
var init_card_chat = __esm({
|
|
21923
21962
|
"../cli/src/guide/card-chat.md"() {
|
|
21924
|
-
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- **Change requirements or drafts**: when the user changes the scope, expected behavior, or draft, use `akb card revise <id> --print \"<change>\"`.\n- **Record an answer**: when the user answers an open question on the card, use `akb 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 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, use `akb previews <agent> <id> --print`.\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- **Check card edits**: after writing a card, run `akb raw validate <id>` and fix what it reports.\n- **Look up syntax**: when you need flags or argument details, use the command's `--help` or `akb help`.\n\nReply in plain, natural language. Do not write memory, including through any flow this conversation starts.\n";
|
|
21963
|
+
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- **Change requirements or drafts**: when the user changes the scope, expected behavior, or draft, use `akb card revise <id> --print \"<change>\"`.\n- **Record an answer**: when the user answers an open question on the card, use `akb 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 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, use `akb previews <agent> <id> --print`.\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 workflow**: when the user asks to change a workflow or one of its agents, follow `akb guide update-workflow`.\n- **Check card edits**: after writing a card, run `akb raw validate <id>` and fix what it reports.\n- **Look up syntax**: when you need flags or argument details, use the command's `--help` or `akb help`.\n\nReply in plain, natural language. Do not write memory, including through any flow this conversation starts.\n";
|
|
21964
|
+
}
|
|
21965
|
+
});
|
|
21966
|
+
|
|
21967
|
+
// ../cli/src/guide/update-workflow.md
|
|
21968
|
+
var update_workflow_default;
|
|
21969
|
+
var init_update_workflow = __esm({
|
|
21970
|
+
"../cli/src/guide/update-workflow.md"() {
|
|
21971
|
+
update_workflow_default = "# Update a workflow\n\nChange one of this workspace's workflows so new tasks run the new version.\n\n## How a workflow works\n\nA workflow is steerable: agents do the work, and a person reviews and fine-tunes only the parts where precision matters most, so the result stays reliable.\n\n- **Previews**: give a part its own preview agent only when it needs precision and a mistake there is costly, such as a developer tool's screens, whose experience drives retention. Each shows only what the person decides on, without overlapping another.\n- **Stages**: previews are approved together in one stage by default. Add `after` only when a draft is too costly to make before another is approved, such as a video's storyboard, which waits for its script.\n- **Land**: everything else runs unattended after the last approval and follows the approved drafts, such as building and merging a change; leave `land` empty when the last approved preview is the deliverable.\n- **Scheduled**: repeating work runs as a scheduled agent without previews; a workflow may hold only scheduled agents.\n- **`WORKFLOW.md`**: list its agents under `previews`, `land` and `scheduled`; `description` says in one sentence what it does; `when` tells an agent which requests it is for, exceptions included; the body is how a card of this kind is written.\n- **Agents**: write each as `akb guide write-agent` says.\n\n## Versions\n\n- **Pinned**: a workflow and the agents it holds live in Cloud as numbered versions; a task\n keeps the version it started with, and only tasks started after a push take the new one.\n- **Project agents**: agents under the board's `agents/` folder are the project's own; a\n workflow may name them, but they are not part of its versions and an edit there applies to\n every card at once.\n- **Own workflows only**: built-in and marketplace workflows are read-only; ask the user to copy\n one on the web first.\n\n## Change it\n\n- **Direct or task**: push directly a change the user spelled out; start a Workflow builder task\n instead when the change adds, removes or restages agents, or when the user wants to see it\n work before it applies.\n- **Steps**: `akb workflow pull <id> <folder>`, edit the files there and keep what the request\n leaves alone, fix every problem `akb workflow list` reports, then `akb workflow push <folder>`.\n- **Moved on**: when push says Cloud has a newer version, pull again and redo the change.\n";
|
|
21925
21972
|
}
|
|
21926
21973
|
});
|
|
21927
21974
|
|
|
@@ -22091,6 +22138,7 @@ var init_guide = __esm({
|
|
|
22091
22138
|
init_archive2();
|
|
22092
22139
|
init_board3();
|
|
22093
22140
|
init_card_chat();
|
|
22141
|
+
init_update_workflow();
|
|
22094
22142
|
init_describe_project();
|
|
22095
22143
|
init_discuss_goal();
|
|
22096
22144
|
init_follow_up();
|
|
@@ -22117,6 +22165,7 @@ var init_guide = __esm({
|
|
|
22117
22165
|
{ name: "discuss-goal", when: "help decide what is worth building, and shape it into goals to start as tasks", text: discuss_goal_default },
|
|
22118
22166
|
{ name: "troubleshoot", when: "\u5B9A\u4F4D\u8F6F\u4EF6\u6545\u969C\u7684\u6839\u56E0\u4E0E\u4FEE\u590D\u65B9\u5411", text: troubleshoot_default },
|
|
22119
22167
|
{ name: "card-chat", when: "answer a card's conversation, and act on what each turn settles", text: card_chat_default },
|
|
22168
|
+
{ name: "update-workflow", when: "change one of this workspace's workflows so new tasks run the new version", text: update_workflow_default },
|
|
22120
22169
|
{ name: "implement", when: "build a settled card and stop cleanly on an execution blocker", text: implement_default },
|
|
22121
22170
|
{ name: "archive", when: "finish a task \u2014 write its shipped line, then take it off the board", text: archive_default },
|
|
22122
22171
|
{ name: "update-questions", when: "decide what to ask the user, and write the question", text: update_questions_default },
|
|
@@ -107660,18 +107709,18 @@ function backoffMs(attempt2, random = Math.random) {
|
|
|
107660
107709
|
const step = Math.min(CAP_MS, BASE_MS * 2 ** Math.max(0, attempt2 - 2));
|
|
107661
107710
|
return Math.round(step * (1 - JITTER * random()));
|
|
107662
107711
|
}
|
|
107663
|
-
function planRetry2(prev, failure, startedAt, now = Date.now(), random = Math.random) {
|
|
107712
|
+
function planRetry2(prev, failure, startedAt, now = Date.now(), random = Math.random, windowed = true) {
|
|
107664
107713
|
const attempt2 = (prev?.attempt ?? 1) + 1;
|
|
107665
107714
|
if (attempt2 > RETRY_ATTEMPTS) return null;
|
|
107666
107715
|
const since = prev?.since ?? startedAt;
|
|
107667
107716
|
const wait = failure.retryAfterMs ?? backoffMs(attempt2, random);
|
|
107668
107717
|
const at2 = now + wait;
|
|
107669
|
-
if (at2 > since + RETRY_WINDOW_MS) return null;
|
|
107718
|
+
if (windowed && at2 > since + RETRY_WINDOW_MS) return null;
|
|
107670
107719
|
return { attempt: attempt2, of: RETRY_ATTEMPTS, reason: failure.reason, at: at2, since };
|
|
107671
107720
|
}
|
|
107672
107721
|
function retryLine(retry2, now = Date.now()) {
|
|
107673
107722
|
const seconds = Math.max(1, Math.round((retry2.at - now) / 1e3));
|
|
107674
|
-
return `${retry2.reason} \u2014
|
|
107723
|
+
return `${retry2.reason} \u2014 this run tries again in ${seconds}s (attempt ${retry2.attempt} of ${retry2.of}).`;
|
|
107675
107724
|
}
|
|
107676
107725
|
var RETRY_ATTEMPTS, RETRY_WINDOW_MS, BASE_MS, CAP_MS, JITTER;
|
|
107677
107726
|
var init_retry = __esm({
|
|
@@ -107926,8 +107975,9 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
107926
107975
|
const ours = asked || silent || !!blocker;
|
|
107927
107976
|
const said3 = failure ?? spoken?.error;
|
|
107928
107977
|
const offStream = renderer?.offStream?.();
|
|
107929
|
-
const
|
|
107930
|
-
const
|
|
107978
|
+
const quiet = silent && !asked && !blocker && !sub && !!resumeSessionId(held4);
|
|
107979
|
+
const blip = quiet ? { reason: waited ? backgroundSaid(BACKGROUND_WAIT.minutes) : silenceSaid(silenceFor) } : ours || sub || code === 0 && !said3 || !resumeSessionId(held4) ? void 0 : active2.transient?.({ failure: said3, result, offStream });
|
|
107980
|
+
const again = blip ? planRetry2(held4.retry, blip, held4.startedAt, Date.now(), Math.random, !quiet) : null;
|
|
107931
107981
|
if (again) {
|
|
107932
107982
|
log.write(`
|
|
107933
107983
|
[board] ${retryLine(again)}
|
|
@@ -107954,6 +108004,7 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
107954
108004
|
const required = new Set(record.formatRepair?.cardIds ?? []);
|
|
107955
108005
|
const heldElsewhere = withStore((store) => new Set(store.runs.filter((r2) => r2.sessionId !== sessionId && r2.status === "running" && holdsCard(r2.action)).flatMap((r2) => [r2.cardId, ...r2.createdCardIds ?? []]).filter((id) => id !== null)));
|
|
107956
108006
|
let formatErrors = [];
|
|
108007
|
+
let broken = [];
|
|
107957
108008
|
if (!sub) {
|
|
107958
108009
|
try {
|
|
107959
108010
|
const discarded = new Set(cleanupDiscardedCards(sessionId));
|
|
@@ -107996,6 +108047,11 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
107996
108047
|
required.add(record.cardId);
|
|
107997
108048
|
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.` });
|
|
107998
108049
|
}
|
|
108050
|
+
if (repairable) {
|
|
108051
|
+
const owed = new Set(record.formatRepair?.broken ?? []);
|
|
108052
|
+
broken = boardComplaints().filter((line) => owed.has(line) || !wasBroken.has(line));
|
|
108053
|
+
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.` })));
|
|
108054
|
+
}
|
|
107999
108055
|
for (const id of departed) log.write(`
|
|
108000
108056
|
[board] Task #${id} left the board with its landing; there is nothing to restore.
|
|
108001
108057
|
`);
|
|
@@ -108007,6 +108063,7 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
108007
108063
|
}
|
|
108008
108064
|
}
|
|
108009
108065
|
const contractError = formatErrors.length ? formatContractErrors(formatErrors) : void 0;
|
|
108066
|
+
const problems = formatErrors.length ? formatProblems(formatErrors) : void 0;
|
|
108010
108067
|
if (contractError) {
|
|
108011
108068
|
log.write(`
|
|
108012
108069
|
[validation] ${contractError}
|
|
@@ -108020,6 +108077,7 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
108020
108077
|
r2.formatRepair = contractError ? {
|
|
108021
108078
|
attempt: record.formatRepair?.attempt ?? 0,
|
|
108022
108079
|
errors: contractError,
|
|
108080
|
+
...broken.length ? { broken } : {},
|
|
108023
108081
|
cardIds: [...required],
|
|
108024
108082
|
changedIds: changed,
|
|
108025
108083
|
existingIds: [...original.keys()]
|
|
@@ -108043,12 +108101,8 @@ ${result}
|
|
|
108043
108101
|
if (result) r2.result = result;
|
|
108044
108102
|
});
|
|
108045
108103
|
const settled = status === "done" && !sub ? settleBoard(record, changed, original) : null;
|
|
108046
|
-
const
|
|
108047
|
-
const
|
|
108048
|
-
const noteWhy = [
|
|
108049
|
-
...status === "done" ? settled?.stalledWhy ?? [] : [],
|
|
108050
|
-
...broke ? [broke.why] : []
|
|
108051
|
-
];
|
|
108104
|
+
const note = status === "done" ? settled?.stalled : void 0;
|
|
108105
|
+
const noteWhy = status === "done" ? settled?.stalledWhy ?? [] : [];
|
|
108052
108106
|
const saidOurs = !asked && silent && !spawnError;
|
|
108053
108107
|
const errorWhy = [
|
|
108054
108108
|
...contractError ? [{ kind: "format" }] : [],
|
|
@@ -108079,7 +108133,7 @@ ${result}
|
|
|
108079
108133
|
// stream said so. That cause leads; a card it left half-written follows.
|
|
108080
108134
|
error: joinNotes(
|
|
108081
108135
|
spawnError ?? (asked ? void 0 : silent ? quietSaid : spoken?.error ?? failure),
|
|
108082
|
-
|
|
108136
|
+
problems
|
|
108083
108137
|
),
|
|
108084
108138
|
note,
|
|
108085
108139
|
errorWhy,
|
|
@@ -108090,7 +108144,7 @@ ${result}
|
|
|
108090
108144
|
if (contractError && repairable && (record.formatRepair?.attempt ?? 0) < MAX_FORMAT_REPAIRS) {
|
|
108091
108145
|
const next = await resume(sessionId);
|
|
108092
108146
|
if ("error" in next) patch(sessionId, (r2) => {
|
|
108093
|
-
r2.error = `${
|
|
108147
|
+
r2.error = `${problems}
|
|
108094
108148
|
Cannot resume format repair: ${next.error}`;
|
|
108095
108149
|
r2.errorWhy = [{ kind: "format" }, { kind: "repairUnstarted", refusals: [next] }];
|
|
108096
108150
|
});
|
|
@@ -108198,19 +108252,6 @@ Cannot resume format repair: ${next.error}`;
|
|
|
108198
108252
|
child.on("close", (code) => void finish(code, peekRun(sessionId)?.stopping === true || stopped2));
|
|
108199
108253
|
});
|
|
108200
108254
|
}
|
|
108201
|
-
function brokeBoard(wasBroken) {
|
|
108202
|
-
const broke = boardComplaints().filter((line) => !wasBroken.has(line));
|
|
108203
|
-
if (!broke.length) return null;
|
|
108204
|
-
const shown = broke.slice(0, MAX_BROKEN);
|
|
108205
|
-
const rest = broke.length - shown.length;
|
|
108206
|
-
const why2 = { kind: "broken", args: { n: String(broke.length), more: String(rest) }, lines: shown };
|
|
108207
|
-
return { why: why2, note: [
|
|
108208
|
-
`the work is done, but the board came out of this run inconsistent \u2014 ${broke.length} thing${broke.length === 1 ? "" : "s"} to put right:`,
|
|
108209
|
-
...shown.map((line) => ` ${line}`),
|
|
108210
|
-
...rest ? [` \u2026 and ${rest} more`] : [],
|
|
108211
|
-
`a card is taken off the board with \`${boardCommand()} raw archive <id>\` or \`${boardCommand()} raw reject <id>\`, never by deleting its file.`
|
|
108212
|
-
].join("\n") };
|
|
108213
|
-
}
|
|
108214
108255
|
function settleBoard(run3, changed, before) {
|
|
108215
108256
|
try {
|
|
108216
108257
|
const helpers = specRunsAfter(readSpecAsks(run3.sessionId));
|
|
@@ -108275,7 +108316,7 @@ function catchModel(sessionId, model) {
|
|
|
108275
108316
|
});
|
|
108276
108317
|
return true;
|
|
108277
108318
|
}
|
|
108278
|
-
var STOP_GRACE_MS, STOP_CLOSE_MS, STOP_FINISH_MS, silenceSaid, backgroundSaid, MAX_FORMAT_REPAIRS,
|
|
108319
|
+
var STOP_GRACE_MS, STOP_CLOSE_MS, STOP_FINISH_MS, silenceSaid, backgroundSaid, MAX_FORMAT_REPAIRS, joinNotes;
|
|
108279
108320
|
var init_watch = __esm({
|
|
108280
108321
|
"../cli/src/lib/agent/watch.ts"() {
|
|
108281
108322
|
"use strict";
|
|
@@ -108311,7 +108352,6 @@ var init_watch = __esm({
|
|
|
108311
108352
|
silenceSaid = (minutes) => `the agent said nothing for ${minutes} minute${minutes === 1 ? "" : "s"}, so the run was ended.`;
|
|
108312
108353
|
backgroundSaid = (minutes) => `the agent's background tasks did not finish within ${minutes / 60} hours, so the run was ended.`;
|
|
108313
108354
|
MAX_FORMAT_REPAIRS = 3;
|
|
108314
|
-
MAX_BROKEN = 5;
|
|
108315
108355
|
joinNotes = (...parts) => parts.filter(Boolean).join("\n\n") || void 0;
|
|
108316
108356
|
}
|
|
108317
108357
|
});
|
|
@@ -110041,8 +110081,8 @@ init_cloud_workflows();
|
|
|
110041
110081
|
init_workflows();
|
|
110042
110082
|
init_workflow_folder();
|
|
110043
110083
|
init_workflow_files();
|
|
110044
|
-
|
|
110045
|
-
|
|
110084
|
+
init_board_files();
|
|
110085
|
+
init_tasks();
|
|
110046
110086
|
import fs77 from "node:fs";
|
|
110047
110087
|
import path78 from "node:path";
|
|
110048
110088
|
var found = (id) => {
|
|
@@ -110108,37 +110148,64 @@ function cmdWorkflowDiagram(id, card) {
|
|
|
110108
110148
|
say(tag);
|
|
110109
110149
|
return { file, tag, diagram };
|
|
110110
110150
|
}
|
|
110111
|
-
var
|
|
110112
|
-
|
|
110113
|
-
|
|
110114
|
-
|
|
110115
|
-
|
|
110151
|
+
var PULLED = ".akb-workflow.json";
|
|
110152
|
+
var cloudIdOf = (id) => cloudFlows().find((f2) => workflowName(f2.cloudId) === id)?.cloudId;
|
|
110153
|
+
async function cmdWorkflowPull(id, folder) {
|
|
110154
|
+
const cloudId = cloudIdOf(id);
|
|
110155
|
+
if (!cloudId) found(id);
|
|
110156
|
+
const dir = path78.resolve(folder ?? id);
|
|
110157
|
+
if (fs77.existsSync(dir) && fs77.readdirSync(dir).length) die(`${folder ?? id} is not empty`, "bad-args");
|
|
110158
|
+
const read5 = await call("GET", `/v1/workflows/${encodeURIComponent(cloudId)}`);
|
|
110159
|
+
if (!read5.ok) die(read5.error, read5.code === "not_found" ? "no-such-workflow" : "cloud-refused");
|
|
110160
|
+
const { version, files: files2 } = read5.value;
|
|
110161
|
+
for (const [file, text5] of Object.entries(files2)) {
|
|
110162
|
+
const full = path78.join(dir, ...file.split("/"));
|
|
110163
|
+
fs77.mkdirSync(path78.dirname(full), { recursive: true });
|
|
110164
|
+
const data = isAboutFile(file) && !file.endsWith(".md") && /^data:[^;]+;base64,/.exec(text5);
|
|
110165
|
+
fs77.writeFileSync(full, data ? Buffer.from(text5.slice(data[0].length), "base64") : text5);
|
|
110166
|
+
}
|
|
110167
|
+
fs77.writeFileSync(path78.join(dir, PULLED), `${JSON.stringify({ id: cloudId, version })}
|
|
110168
|
+
`);
|
|
110169
|
+
const shown = folder ?? `./${id}`;
|
|
110170
|
+
say(`Pulled ${id} v${version} into ${shown}.`);
|
|
110171
|
+
return { id, version, folder: dir };
|
|
110172
|
+
}
|
|
110173
|
+
async function cmdWorkflowPush(folder, opts) {
|
|
110116
110174
|
const dir = path78.resolve(folder);
|
|
110117
|
-
|
|
110118
|
-
const slug2 = path78.basename(dir);
|
|
110119
|
-
const files2 = readWorkflowFolder(dir);
|
|
110120
|
-
const checked = checkWorkflowFiles(files2, true);
|
|
110121
|
-
if (!checked.ok) die(`${slug2}: ${checked.file} ${checked.reason}`, "bad-workflow");
|
|
110122
|
-
const token3 = await accessToken();
|
|
110123
|
-
if (!token3.ok) die(SAID[token3.reason].en, "cloud-refused");
|
|
110124
|
-
let res;
|
|
110175
|
+
let pulled = null;
|
|
110125
110176
|
try {
|
|
110126
|
-
|
|
110127
|
-
method: "POST",
|
|
110128
|
-
headers: { authorization: `Bearer ${token3.token}`, "content-type": "application/json" },
|
|
110129
|
-
body: JSON.stringify({ slug: slug2, files: files2, ...opts.dryRun ? { dry_run: true } : {} })
|
|
110130
|
-
});
|
|
110177
|
+
pulled = JSON.parse(fs77.readFileSync(path78.join(dir, PULLED), "utf8"));
|
|
110131
110178
|
} catch {
|
|
110132
|
-
die(SAID.unreachable.en, "cloud-refused");
|
|
110133
110179
|
}
|
|
110134
|
-
|
|
110180
|
+
if (!pulled?.id || !Number.isInteger(pulled.version)) die(`${folder} was not written by \`akb workflow pull\``, "bad-args");
|
|
110181
|
+
const { id: cloudId, version } = pulled;
|
|
110182
|
+
const id = workflowName(cloudId);
|
|
110183
|
+
const readOnly2 = () => die(`${id} is not this workspace's own; copy it on the web first.`, "workflow-read-only");
|
|
110184
|
+
if (cloudId.startsWith("wf_builtin_")) readOnly2();
|
|
110185
|
+
const files2 = readWorkflowFolder(dir);
|
|
110186
|
+
const checked = checkWorkflowFiles(files2);
|
|
110187
|
+
if (!checked.ok) die(`${checked.file} ${checked.reason}`, "bad-workflow");
|
|
110188
|
+
const now = await call("GET", `/v1/workflows/${encodeURIComponent(cloudId)}`);
|
|
110189
|
+
if (!now.ok) die(now.error, now.code === "not_found" ? "no-such-workflow" : "cloud-refused");
|
|
110190
|
+
if (now.value.version !== version) die(`${id} is at v${now.value.version} now; pull again and redo the change.`, "workflow-moved");
|
|
110191
|
+
if (JSON.stringify(files2) === JSON.stringify(Object.fromEntries(Object.entries(now.value.files).sort()))) {
|
|
110192
|
+
say(`${id} is unchanged (v${version}).`);
|
|
110193
|
+
return { id, version, changed: false, ...opts.dryRun ? { dryRun: true } : {} };
|
|
110194
|
+
}
|
|
110195
|
+
if (opts.dryRun) {
|
|
110196
|
+
say(`${id} would push v${version + 1}.`);
|
|
110197
|
+
return { id, version: version + 1, changed: true, dryRun: true };
|
|
110198
|
+
}
|
|
110199
|
+
const res = await call("PATCH", `/v1/workflows/${encodeURIComponent(cloudId)}`, { files: files2 });
|
|
110135
110200
|
if (!res.ok) {
|
|
110136
|
-
if (res.
|
|
110137
|
-
|
|
110138
|
-
die(`${slug2}: ${PUBLISH_REFUSED[code] ?? body.error?.message ?? `Cloud answered ${res.status}`}`, code);
|
|
110201
|
+
if (res.code === "read_only" || res.code === "not_found") readOnly2();
|
|
110202
|
+
die(res.error, res.code === "bad_request" || res.code === "payload_too_large" ? "bad-workflow" : "cloud-refused");
|
|
110139
110203
|
}
|
|
110140
|
-
|
|
110141
|
-
|
|
110204
|
+
const next = res.value.version;
|
|
110205
|
+
fs77.writeFileSync(path78.join(dir, PULLED), `${JSON.stringify({ id: cloudId, version: next })}
|
|
110206
|
+
`);
|
|
110207
|
+
say(`Pushed ${id} v${next}. New tasks take it.`);
|
|
110208
|
+
return { id, version: next, changed: true };
|
|
110142
110209
|
}
|
|
110143
110210
|
|
|
110144
110211
|
// ../cli/src/commands/run.ts
|
|
@@ -111391,7 +111458,7 @@ List trigger conditions: ${cli.program} previews --triggers --json`).action(asyn
|
|
|
111391
111458
|
});
|
|
111392
111459
|
}
|
|
111393
111460
|
const workflow = withShared(program2.command("workflow")).summary("the workflows this board runs, and the agents each one lists").description(
|
|
111394
|
-
"Every card runs through one workflow, kept in Cloud: the built-ins and the workflows this workspace installed or made.
|
|
111461
|
+
"Every card runs through one workflow, kept in Cloud: the built-ins and the workflows this workspace installed or made. To change one of this workspace's own: `pull` it into a folder, edit, `push`. New tasks take the new version; a task already started keeps its own. `akb guide update-workflow` has the whole flow."
|
|
111395
111462
|
).allowExcessArguments().allowUnknownOption().action(async function() {
|
|
111396
111463
|
if (this.args.length) this.error(`unknown command '${this.args[0]}'`, { code: "commander.unknownCommand" });
|
|
111397
111464
|
await workflowList(this, cli);
|
|
@@ -111406,8 +111473,11 @@ List trigger conditions: ${cli.program} previews --triggers --json`).action(asyn
|
|
|
111406
111473
|
flowWord("diagram").argument("<id>", "the workflow, from `workflow list`").argument("<card>", "the card whose asset folder gets workflow.json").summary("write the workflow's diagram to .assets/<card>/workflow.json and print the <Workflow> tag that shows it").action(async function(id, card) {
|
|
111407
111474
|
await onBoard2(this, cli, () => cmdWorkflowDiagram(id, card));
|
|
111408
111475
|
});
|
|
111409
|
-
flowWord("
|
|
111410
|
-
await
|
|
111476
|
+
flowWord("pull").argument("<id>", "the workflow, from `workflow list`").argument("[folder]", "where to write it, empty or new; default ./<id>").summary("write the workflow's current version into a folder to edit").action(async function(id, folder) {
|
|
111477
|
+
await onBoard2(this, cli, () => cmdWorkflowPull(id, folder));
|
|
111478
|
+
});
|
|
111479
|
+
flowWord("push").argument("<folder>", "a folder `workflow pull` wrote").option("--dry-run", "check the folder and print what would happen, saving nothing").summary("save the edited folder as the workflow's next version, which new tasks take").action(async function(folder) {
|
|
111480
|
+
await boardless(this, cli, () => cmdWorkflowPush(folder, this.opts()));
|
|
111411
111481
|
});
|
|
111412
111482
|
withShared(program2.command("components")).summary("list an agent or workflow\u2019s preview components and their usage").option("--agent <name>", "one agent\u2019s components").option("--workflow <id>", "all components used by a workflow").option("--docs", "include component usage documentation").action(async function() {
|
|
111413
111483
|
const ctx = ctxOf(this, cli.program);
|
package/dist/akb/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"wildcrane","version":"0.11.
|
|
1
|
+
{"name":"wildcrane","version":"0.11.31","akbContract":7,"type":"module","private":true}
|
package/dist/akb-proxy.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// wildcrane-runner 0.6.
|
|
1
|
+
// wildcrane-runner 0.6.35 — built by runner/scripts/build.mjs. Do not edit.
|
|
2
2
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
3
3
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
4
4
|
var __create = Object.create;
|