wildcrane-runner 0.6.41 → 0.6.43

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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // ai4kanban 0.11.35 — built by runner/scripts/build.mjs. Do not edit.
2
+ // ai4kanban 0.11.37 — 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;
@@ -726,167 +726,603 @@ var init_paths = __esm({
726
726
  }
727
727
  });
728
728
 
729
- // ../cli/src/lib/cloud/avatar.ts
730
- async function heldAvatar(url) {
731
- if (!url) return null;
732
- const held4 = readSession();
733
- if (!held4) return null;
734
- if (held4.avatar?.url === url) return held4.avatar.data;
735
- const data = await download(url);
736
- if (!data) return null;
737
- const now = readSession();
738
- if (now) writeSession({ ...now, avatar: { url, data } });
739
- return data;
740
- }
741
- async function download(url) {
742
- try {
743
- const response = await fetch(sized(url), { signal: AbortSignal.timeout(TIMEOUT_MS) });
744
- if (!response.ok) return null;
745
- const type = response.headers.get("content-type")?.split(";")[0]?.trim() ?? "";
746
- if (!type.startsWith("image/")) return null;
747
- const bytes2 = Buffer.from(await response.arrayBuffer());
748
- if (bytes2.byteLength === 0 || bytes2.byteLength > MAX_BYTES) return null;
749
- return `data:${type};base64,${bytes2.toString("base64")}`;
750
- } catch {
751
- return null;
752
- }
753
- }
754
- function sized(url) {
755
- try {
756
- const asked = new URL(url);
757
- asked.searchParams.set("s", String(PIXELS));
758
- return asked.toString();
759
- } catch {
760
- return url;
729
+ // ../cli/src/lib/yaml.ts
730
+ function yamlScalar(s) {
731
+ const text4 = String(s);
732
+ if (text4 === "") return '""';
733
+ if (/^[-?:,[\]{}#&*!|>'"%@`]/.test(text4) || /:\s/.test(text4) || /[\n"]/.test(text4) || /^\s|\s$/.test(text4)) {
734
+ return JSON.stringify(text4);
761
735
  }
736
+ return text4;
762
737
  }
763
- var PIXELS, MAX_BYTES, TIMEOUT_MS;
764
- var init_avatar = __esm({
765
- "../cli/src/lib/cloud/avatar.ts"() {
766
- "use strict";
767
- init_session();
768
- PIXELS = 80;
769
- MAX_BYTES = 256 * 1024;
770
- TIMEOUT_MS = 5e3;
738
+ function unquote(v) {
739
+ const text4 = String(v).trim();
740
+ if (text4.startsWith('"') && text4.endsWith('"')) {
741
+ try {
742
+ return JSON.parse(text4);
743
+ } catch {
744
+ return text4.slice(1, -1);
745
+ }
771
746
  }
772
- });
773
-
774
- // ../cli/src/lib/cloud/pro.ts
775
- import fs5 from "node:fs";
776
- import path6 from "node:path";
777
- function forgetPro() {
778
- fs5.rmSync(heldFile(), { force: true });
747
+ if (text4.startsWith("'") && text4.endsWith("'")) return text4.slice(1, -1);
748
+ return text4;
779
749
  }
780
- var FRESH_MS, GRACE_MS, heldFile;
781
- var init_pro = __esm({
782
- "../cli/src/lib/cloud/pro.ts"() {
750
+ var init_yaml = __esm({
751
+ "../cli/src/lib/yaml.ts"() {
783
752
  "use strict";
784
- init_home();
785
- init_config();
786
- init_session();
787
- FRESH_MS = 10 * 6e4;
788
- GRACE_MS = 7 * 24 * 60 * 6e4;
789
- heldFile = () => path6.join(machineHome(), "pro.json");
790
753
  }
791
754
  });
792
755
 
793
- // ../cli/src/lib/cloud/account.ts
794
- async function readCloudAccount() {
795
- const blank = {
796
- state: "signed-out",
797
- handle: null,
798
- name: null,
799
- avatarUrl: null,
800
- avatarData: null,
801
- email: null,
802
- message: null,
803
- inviteRequestedAt: null,
804
- sessionFile: sessionFile(),
805
- configured: cloudConfigured()
806
- };
807
- if (!blank.configured) return { ...blank, message: NOT_CONFIGURED };
808
- const token2 = await accessToken();
809
- if (!token2.ok) {
810
- if (token2.reason === "signed-out") return blank;
811
- if (token2.reason === "unreachable") {
812
- return { ...blank, ...held(), state: "signed-in", error: token2.error };
813
- }
814
- return { ...blank, ...held(), state: "expired" };
815
- }
816
- let response;
817
- try {
818
- response = await fetch(`${cloudEndpoints().api}/v1/session`, {
819
- headers: { authorization: `Bearer ${token2.token}` }
820
- });
821
- } catch (e) {
822
- return {
823
- ...blank,
824
- ...held(),
825
- state: "signed-in",
826
- error: e instanceof Error ? e.message : String(e)
756
+ // ../cli/src/lib/question-block.ts
757
+ function normalizeQuestion(raw) {
758
+ if (raw && typeof raw === "object" && !Array.isArray(raw)) {
759
+ const source = raw;
760
+ const text4 = withoutTag(String(source.question ?? source.text ?? ""));
761
+ const extra = {
762
+ ...typeof source.agent === "string" && source.agent.trim() ? { agent: source.agent.trim() } : {}
827
763
  };
764
+ const options = (Array.isArray(source.options) ? source.options : []).map((o) => String(o).trim()).filter(Boolean);
765
+ if (options.length === 0) return { text: text4, ...extra };
766
+ const mode = MODES.includes(String(source.mode)) ? String(source.mode) : "single";
767
+ const recommend = (Array.isArray(source.recommend) ? source.recommend : []).map(Number).filter((n) => Number.isInteger(n) && n >= 1 && n <= options.length);
768
+ return { text: text4, mode, options, recommend: mode === "single" ? recommend.slice(0, 1) : recommend, ...extra };
828
769
  }
829
- const body = await response.json().catch(() => ({}));
830
- if (!response.ok) {
831
- const refusal2 = body.error;
832
- if (refusal2?.code === "unauthenticated") {
833
- return { ...blank, ...held(), state: "expired", message: refusal2.message ?? null };
770
+ return { text: withoutTag(String(raw)) };
771
+ }
772
+ function parseQuestionsBlock(lines) {
773
+ const out = [];
774
+ for (let i = 0; i < lines.length; i++) {
775
+ const m = lines[i].match(/^\s*-\s+([\s\S]*)$/);
776
+ if (!m) continue;
777
+ const head2 = m[1];
778
+ const opened = head2.match(/^question:\s*(.*)$/);
779
+ if (!opened) {
780
+ out.push(normalizeQuestion(unquote(head2)));
781
+ continue;
834
782
  }
835
- if (refusal2?.code === "not_admitted") {
836
- return { ...blank, ...held(), state: "not-admitted", message: refusal2.message ?? null };
783
+ let skipped = false;
784
+ const q = {
785
+ question: unquote(opened[1]),
786
+ options: [],
787
+ recommend: []
788
+ };
789
+ while (i + 1 < lines.length && !/^\s*-\s/.test(lines[i + 1])) {
790
+ const field2 = lines[i + 1].match(/^\s*([A-Za-z_]+):\s*(.*)$/);
791
+ i++;
792
+ if (!field2) continue;
793
+ const [, key, val] = field2;
794
+ if (key === "options") {
795
+ while (i + 1 < lines.length && /^\s*-\s+/.test(lines[i + 1])) {
796
+ q.options.push(unquote(lines[i + 1].replace(/^\s*-\s+/, "")));
797
+ i++;
798
+ }
799
+ } else if (key === "recommend") {
800
+ q.recommend = val.replace(/^\[|\]$/g, "").split(",").map((s) => Number(s.trim())).filter((n) => Number.isInteger(n));
801
+ } else if (key === "mode") {
802
+ q.mode = unquote(val);
803
+ } else if (key === "agent") {
804
+ q.agent = unquote(val);
805
+ } else if (key === "skipped") {
806
+ skipped = unquote(val) === "true";
807
+ }
837
808
  }
838
- return { ...blank, ...held(), state: "signed-in", error: refusal2?.message };
809
+ if (!skipped) out.push(normalizeQuestion(q));
839
810
  }
840
- const session = body.session ?? {};
841
- const avatarUrl = session.avatar_url ?? session.avatarUrl ?? null;
842
- const attested = {
843
- handle: session.handle ?? null,
844
- name: session.name ?? null,
845
- avatarUrl,
846
- // Costs a fetch the first time this address is seen and a file read every time after,
847
- // so the picture is on the machine before any screen asks to draw it.
848
- avatarData: await heldAvatar(avatarUrl),
849
- email: session.email ?? null,
850
- inviteRequestedAt: session.inviteRequestedAt ?? null
851
- };
852
- return session.admitted ? { ...blank, ...attested, state: "signed-in" } : { ...blank, ...attested, state: "not-admitted", message: body.refusal?.message ?? null };
811
+ return out;
853
812
  }
854
- function signOutOfCloud() {
855
- clearSession();
856
- forgetPro();
857
- return { ok: true };
813
+ var MODES, withoutTag;
814
+ var init_question_block = __esm({
815
+ "../cli/src/lib/question-block.ts"() {
816
+ "use strict";
817
+ init_yaml();
818
+ MODES = ["single", "multi"];
819
+ withoutTag = (text4) => text4.replace(/^\[user\]\s+/, "");
820
+ }
821
+ });
822
+
823
+ // ../cli/src/lib/view/rules.ts
824
+ function creationRefusal(id, creation, what, discard = false) {
825
+ if (!creation || creation.state === "unfinished" && discard) return null;
826
+ const run2 = creation.runId.slice(0, 8);
827
+ return creation.state === "creating" ? `#${id} is still being created by run ${run2} \u2014 \`${what}\` is refused until that run finishes.` : `#${id} was never finished being created: run ${run2} stopped short. \`${what}\` is refused until that run is picked back up from the board and finishes. Use reject --discard to discard it instead.`;
858
828
  }
859
- function held() {
860
- const session = readSession();
861
- return {
862
- handle: session?.handle ?? null,
863
- name: session?.name ?? null,
864
- avatarUrl: session?.avatarUrl ?? null,
865
- avatarData: session?.avatar?.data ?? null,
866
- email: session?.email ?? null
867
- };
829
+ function hasOptions(q) {
830
+ return Array.isArray(q.options) && q.options.length > 0;
868
831
  }
869
- var init_account = __esm({
870
- "../cli/src/lib/cloud/account.ts"() {
832
+ function planDeliveryGap(card) {
833
+ if (card.questions.length > 0) return "questions";
834
+ if (!planDeliverables(card.body).length) return "deliverable";
835
+ if (!/^[ \t]*[-*]\s+\[[xX]\].*`[^`]+`/m.test(card.body)) return "command";
836
+ const { total, done: done2 } = card.todos;
837
+ return total > 0 && done2 === total ? null : "todos";
838
+ }
839
+ function awaitingApproval(card) {
840
+ const { stages, stage } = card;
841
+ if (!stages || !stage || stage >= stages || card.status !== "ready") return null;
842
+ return card.questions.length ? null : stage;
843
+ }
844
+ function byDispatchOrder(a, b) {
845
+ return rank(LEVEL_RANK, a.priority) - rank(LEVEL_RANK, b.priority) || a.id - b.id;
846
+ }
847
+ function canRefine(card) {
848
+ if (card.isGroup) return false;
849
+ if (awaitingApproval(card)) return false;
850
+ if (card.status !== "todo" && !planUnfinished(card)) return false;
851
+ const { total, done: done2 } = card.todos;
852
+ if (total > 0 && done2 === total && !planUnfinished(card)) return false;
853
+ if (card.questions.length > 0 && card.questions.every(hasOptions)) return false;
854
+ return true;
855
+ }
856
+ var PLAN_DELIVERABLE, PAGES_STORYBOARD, planDeliverables, planUnfinished, LEVEL_RANK, rank;
857
+ var init_rules = __esm({
858
+ "../cli/src/lib/view/rules.ts"() {
871
859
  "use strict";
872
- init_avatar();
873
- init_config();
874
- init_pro();
875
- init_session();
860
+ PLAN_DELIVERABLE = /\.(mp4|webm|mov|m4v|pptx|md|mdx)$/i;
861
+ PAGES_STORYBOARD = /(^|\/)pages-[^/]*\.json$/i;
862
+ planDeliverables = (body) => [
863
+ ...[...body.matchAll(/<Asset\s[^>]*src="([^"]+)"/gi)].map((m) => m[1]).filter((src) => PLAN_DELIVERABLE.test(src)),
864
+ ...[...body.matchAll(/<Storyboard\s[^>]*src="([^"]+)"/gi)].map((m) => m[1]).filter((src) => PAGES_STORYBOARD.test(src))
865
+ ];
866
+ planUnfinished = (card) => card.deliversIn === "plan" && planDeliveryGap(card) !== null;
867
+ LEVEL_RANK = { high: 0, med: 1, low: 2 };
868
+ rank = (table, value) => table[value] ?? Object.keys(table).length;
876
869
  }
877
870
  });
878
871
 
879
- // ../cli/src/commands/cloud.ts
880
- import fs6 from "node:fs";
881
- import path7 from "node:path";
882
- async function cmdCloud(args, program2) {
883
- const [sub] = args;
884
- if (sub === "sign-out") {
885
- signOutOfCloud();
886
- say("Signed out. This machine no longer reaches Cloud; nothing on any board changed.");
887
- return { signedOut: true };
888
- }
889
- if (sub !== void 0) {
872
+ // ../cli/src/lib/frontmatter.ts
873
+ function serializeFrontmatter(m) {
874
+ const out = ["---"];
875
+ out.push(`title: ${yamlScalar(m.title)}`);
876
+ out.push(`priority: ${m.priority}`);
877
+ out.push(`status: ${STATUSES.includes(String(m.status)) ? m.status : "todo"}`);
878
+ out.push(`blocked_by: [${(m.blocked_by || []).join(", ")}]`);
879
+ out.push(`related: [${(m.related || []).join(", ")}]`);
880
+ out.push(`modules: [${(m.modules || []).join(", ")}]`);
881
+ if (m.workflow) out.push(`workflow: ${yamlScalar(m.workflow)}`);
882
+ if (m.triage) out.push(`triage: ${yamlScalar(m.triage)}`);
883
+ if (m.source?.length) {
884
+ out.push("source:");
885
+ for (const ref of m.source) out.push(` - ${yamlScalar(ref)}`);
886
+ }
887
+ if (m.previews) out.push(`previews: [${m.previews.join(", ")}]`);
888
+ if ((m.stages ?? 0) > 0) out.push(`stages: ${m.stages}`);
889
+ if ((m.phase ?? 0) > 1) out.push(`phase: ${m.phase}`);
890
+ if (m.preview_approved) out.push("preview_approved: true");
891
+ if (m.archived) out.push(`archived: ${yamlScalar(m.archived)}`);
892
+ if (m.rejected) out.push("rejected: true");
893
+ if (m.rejected_reason) out.push(`rejected_reason: ${yamlScalar(m.rejected_reason)}`);
894
+ if (m.rejected_at) out.push(`rejected_at: ${yamlScalar(m.rejected_at)}`);
895
+ if (m.rejected_by) out.push(`rejected_by: ${m.rejected_by}`);
896
+ if (!m.questions || m.questions.length === 0) out.push("questions: []");
897
+ else {
898
+ out.push("questions:");
899
+ for (const raw of m.questions) {
900
+ const q = normalizeQuestion(raw);
901
+ if (!hasOptions(q) && !q.agent) {
902
+ out.push(` - ${yamlScalar(q.text)}`);
903
+ continue;
904
+ }
905
+ out.push(` - question: ${yamlScalar(q.text)}`);
906
+ if (hasOptions(q)) {
907
+ out.push(` mode: ${q.mode}`);
908
+ out.push(" options:");
909
+ for (const o of q.options) out.push(` - ${yamlScalar(o)}`);
910
+ out.push(` recommend: [${q.recommend.join(", ")}]`);
911
+ }
912
+ if (q.agent) out.push(` agent: ${yamlScalar(q.agent)}`);
913
+ }
914
+ }
915
+ out.push("---");
916
+ return out.join("\n");
917
+ }
918
+ function parseFrontmatter(text4) {
919
+ const lines = text4.split("\n");
920
+ if (lines[0].trim() !== "---") return { meta: null, body: text4 };
921
+ let i = 1;
922
+ const fm = [];
923
+ while (i < lines.length && lines[i].trim() !== "---") {
924
+ fm.push(lines[i]);
925
+ i++;
926
+ }
927
+ if (i >= lines.length) return { meta: null, body: text4 };
928
+ const meta = {};
929
+ for (let j = 0; j < fm.length; j++) {
930
+ const m = fm[j].match(/^([A-Za-z_]+):\s*(.*)$/);
931
+ if (!m) continue;
932
+ const key = m[1];
933
+ const val = m[2];
934
+ if (key === "questions") {
935
+ if (val === "") {
936
+ const block = [];
937
+ while (j + 1 < fm.length && /^\s/.test(fm[j + 1]) && fm[j + 1].trim() !== "") {
938
+ block.push(fm[j + 1]);
939
+ j++;
940
+ }
941
+ meta.questions = parseQuestionsBlock(block);
942
+ } else {
943
+ meta.questions = val.trim() === "[]" ? [] : [normalizeQuestion(unquote(val))];
944
+ }
945
+ continue;
946
+ }
947
+ if (val === "") {
948
+ const items = [];
949
+ while (j + 1 < fm.length && /^\s*-\s+/.test(fm[j + 1])) {
950
+ items.push(unquote(fm[j + 1].replace(/^\s*-\s+/, "")));
951
+ j++;
952
+ }
953
+ meta[key] = items;
954
+ } else if (val.startsWith("[")) {
955
+ const inner = val.slice(1, val.lastIndexOf("]"));
956
+ meta[key] = inner.split(",").map((s) => s.trim()).filter(Boolean).map(unquote);
957
+ } else {
958
+ meta[key] = unquote(val);
959
+ }
960
+ }
961
+ for (const k of ["blocked_by", "related"]) {
962
+ const value = meta[k];
963
+ if (Array.isArray(value)) {
964
+ meta[k] = value.map((x) => Number(String(x).replace(/^#/, ""))).filter((n) => Number.isInteger(n));
965
+ } else {
966
+ meta[k] = [];
967
+ }
968
+ }
969
+ if (!Array.isArray(meta.questions)) {
970
+ meta.questions = meta.questions ? [normalizeQuestion(meta.questions)] : [];
971
+ }
972
+ meta.priority = typeof meta.priority === "string" ? meta.priority.trim() : "";
973
+ if (!Array.isArray(meta.modules)) meta.modules = [];
974
+ delete meta.channels;
975
+ delete meta.decided;
976
+ delete meta.verify;
977
+ delete meta.release;
978
+ delete meta.schedule;
979
+ delete meta.roi;
980
+ meta.workflow = typeof meta.workflow === "string" && meta.workflow.trim() ? meta.workflow.trim() : "";
981
+ meta.triage = typeof meta.triage === "string" ? meta.triage.trim() : "";
982
+ meta.source = (Array.isArray(meta.source) ? meta.source : typeof meta.source === "string" ? [meta.source] : []).map((ref) => String(ref).trim()).filter(Boolean);
983
+ delete meta.phases;
984
+ if (Array.isArray(meta.previews)) meta.previews = meta.previews.map((name) => String(name).trim()).filter(Boolean);
985
+ else delete meta.previews;
986
+ meta.stages = /^\d+$/.test(String(meta.stages ?? "").trim()) ? Number(meta.stages) : 0;
987
+ meta.phase = /^\d+$/.test(String(meta.phase ?? "").trim()) ? Number(meta.phase) : 0;
988
+ meta.preview_approved = meta.preview_approved === "true";
989
+ meta.archived = typeof meta.archived === "string" && meta.archived.trim() ? meta.archived.trim() : "";
990
+ meta.rejected = meta.rejected === "true";
991
+ meta.rejected_reason = typeof meta.rejected_reason === "string" ? meta.rejected_reason : "";
992
+ meta.rejected_at = typeof meta.rejected_at === "string" ? meta.rejected_at.trim() : "";
993
+ meta.rejected_by = meta.rejected_by === "user" || meta.rejected_by === "agent" ? meta.rejected_by : "";
994
+ return { meta, body: lines.slice(i + 1).join("\n") };
995
+ }
996
+ function frontmatterEnd(lines) {
997
+ if (lines[0]?.trim() !== "---") return 0;
998
+ let i = 1;
999
+ while (i < lines.length && lines[i].trim() !== "---") i++;
1000
+ return i >= lines.length ? 0 : i;
1001
+ }
1002
+ function frontmatterField(lines, i) {
1003
+ for (let j = i; j > 0; j--) {
1004
+ const m = lines[j].match(/^([A-Za-z_]+):/);
1005
+ if (m) return m[1];
1006
+ }
1007
+ return "frontmatter";
1008
+ }
1009
+ var STATUSES;
1010
+ var init_frontmatter = __esm({
1011
+ "../cli/src/lib/frontmatter.ts"() {
1012
+ "use strict";
1013
+ init_yaml();
1014
+ init_question_block();
1015
+ init_rules();
1016
+ STATUSES = ["todo", "ready", "implementing"];
1017
+ }
1018
+ });
1019
+
1020
+ // ../cli/src/lib/questions.ts
1021
+ function newDraft(flag, value) {
1022
+ const text4 = value.trim();
1023
+ if (!text4) die(`--${flag} must not be empty`);
1024
+ if (text4.startsWith("[user]")) die(`"${text4}" starts with [user] \u2014 drop the prefix; every open question is the user's`);
1025
+ return { question: text4, options: [], recommended: [] };
1026
+ }
1027
+ function addToDraft(q, key, value) {
1028
+ if (key === "mode") {
1029
+ const m = value.toLowerCase();
1030
+ if (!MODES.includes(m)) die(`--mode must be single | multi (got "${value}")`);
1031
+ q.mode = m;
1032
+ return;
1033
+ }
1034
+ const text4 = value.trim();
1035
+ if (!text4) die(`--${key} must not be empty`);
1036
+ if (key === "agent") {
1037
+ q.agent = text4;
1038
+ return;
1039
+ }
1040
+ if (q.options.includes(text4)) die(`"${text4}" is listed twice as an option of "${q.question}"`);
1041
+ q.options.push(text4);
1042
+ if (key === "recommended-option") q.recommended.push(text4);
1043
+ }
1044
+ function finalizeDraft(q) {
1045
+ if (q.options.length === 0) missingChoices(q.question);
1046
+ if (q.options.length < 2) {
1047
+ die(`a question with options needs at least 2 \u2014 add another --option ("${q.question}")`);
1048
+ }
1049
+ q.mode = q.mode || "single";
1050
+ if (q.mode === "single" && q.recommended.length > 1) {
1051
+ die(`--mode single takes at most one --recommended-option ("${q.question}")`);
1052
+ }
1053
+ q.recommend = q.recommended.map((text4) => q.options.indexOf(text4) + 1).sort((a, b) => a - b);
1054
+ return normalizeQuestion(q);
1055
+ }
1056
+ function collectQuestions(order) {
1057
+ const out = [];
1058
+ for (const [key, value] of order) {
1059
+ if (key === "question") {
1060
+ out.push(newDraft("question", value));
1061
+ } else if (key === "option" || key === "mode" || key === "recommended-option") {
1062
+ const q = out[out.length - 1];
1063
+ if (!q) die(`--${key} must come after the --question it belongs to`);
1064
+ addToDraft(q, key, value);
1065
+ }
1066
+ }
1067
+ return out.map(finalizeDraft);
1068
+ }
1069
+ function missingChoices(text4) {
1070
+ die(
1071
+ `"${text4}" needs choices to tick \u2014 add 2 or more --option "a \u2014 why". The user always gets a free-text choice too, so never write one yourself.`
1072
+ );
1073
+ }
1074
+ function readQuestionOps(typed) {
1075
+ const ops = [];
1076
+ for (let i = 0; i < typed.length; i++) {
1077
+ const [key, value] = typed[i];
1078
+ if (key === "clear") {
1079
+ ops.push({ kind: "clear" });
1080
+ } else if (key === "drop") {
1081
+ ops.push({ kind: key, ns: value });
1082
+ } else if (key === "append") {
1083
+ ops.push({ kind: "append", draft: newDraft("append", value) });
1084
+ } else if (key === "update") {
1085
+ const n = Number(value);
1086
+ if (!Number.isInteger(n) || n < 1) die('--update takes a 1-based question number, then the new text: --update <n> ".."');
1087
+ const next = typed[i + 1];
1088
+ if (!next || next[0] !== "update") die('--update takes a 1-based question number, then the new text: --update <n> ".."');
1089
+ i++;
1090
+ ops.push({ kind: "update", n, draft: newDraft("update", next[1]) });
1091
+ } else {
1092
+ const last = ops[ops.length - 1];
1093
+ if (!last || !last.draft) die(`--${key} must come after the --append or --update it belongs to`);
1094
+ addToDraft(last.draft, key, value);
1095
+ }
1096
+ }
1097
+ if (!ops.length) {
1098
+ die('update-questions needs at least one op: --append ".." | --update <n> ".." | --drop n[,n...] | --clear');
1099
+ }
1100
+ for (const op of ops) {
1101
+ if (op.draft) {
1102
+ op.question = finalizeDraft(op.draft);
1103
+ delete op.draft;
1104
+ }
1105
+ }
1106
+ return ops;
1107
+ }
1108
+ var init_questions = __esm({
1109
+ "../cli/src/lib/questions.ts"() {
1110
+ "use strict";
1111
+ init_paths();
1112
+ init_question_block();
1113
+ init_question_block();
1114
+ init_rules();
1115
+ }
1116
+ });
1117
+
1118
+ // ../cli/src/lib/question-ops.ts
1119
+ function questionPositions(raw, count3, flag) {
1120
+ const ns = String(raw).split(",").map((s) => s.trim()).filter((s) => s.length > 0).map(Number);
1121
+ if (ns.length === 0 || ns.some((n) => !Number.isInteger(n) || n < 1)) {
1122
+ throw new QuestionOpError(`--${flag} needs one or more 1-based question numbers (e.g. 1 or 1,3)`);
1123
+ }
1124
+ const over = ns.find((n) => n > count3);
1125
+ if (over !== void 0) throw new QuestionOpError(`the card has ${count3} open question(s) \u2014 there's no question ${over}`);
1126
+ return ns;
1127
+ }
1128
+ function applyQuestionOps(start, ops, asker) {
1129
+ let questions = [...start];
1130
+ const changes = [];
1131
+ const closed2 = [];
1132
+ const positions = (op, flag) => questionPositions(op.ns ?? String(op.n), questions.length, flag);
1133
+ for (const op of ops) {
1134
+ if (op.kind === "clear") {
1135
+ closed2.push(...questions);
1136
+ questions = [];
1137
+ changes.push("cleared");
1138
+ } else if (op.kind === "drop") {
1139
+ const ns = positions(op, "drop");
1140
+ closed2.push(...ns.map((n) => questions[n - 1]));
1141
+ questions = questions.filter((_, i) => !ns.includes(i + 1));
1142
+ changes.push(`dropped ${ns.join(",")}`);
1143
+ } else if (op.kind === "append") {
1144
+ const agent = op.question.agent ?? asker;
1145
+ questions.push(agent ? { ...op.question, agent } : op.question);
1146
+ changes.push("appended");
1147
+ } else {
1148
+ const [n] = positions(op, "update");
1149
+ const agent = op.question.agent ?? questions[n - 1].agent;
1150
+ questions[n - 1] = { ...op.question, ...agent ? { agent } : {} };
1151
+ changes.push(`rewrote ${n}`);
1152
+ }
1153
+ }
1154
+ return { questions, changes, closed: closed2 };
1155
+ }
1156
+ var QuestionOpError;
1157
+ var init_question_ops = __esm({
1158
+ "../cli/src/lib/question-ops.ts"() {
1159
+ "use strict";
1160
+ QuestionOpError = class extends Error {
1161
+ };
1162
+ }
1163
+ });
1164
+
1165
+ // ../cli/src/lib/cloud/avatar.ts
1166
+ async function heldAvatar(url) {
1167
+ if (!url) return null;
1168
+ const held4 = readSession();
1169
+ if (!held4) return null;
1170
+ if (held4.avatar?.url === url) return held4.avatar.data;
1171
+ const data = await download(url);
1172
+ if (!data) return null;
1173
+ const now = readSession();
1174
+ if (now) writeSession({ ...now, avatar: { url, data } });
1175
+ return data;
1176
+ }
1177
+ async function download(url) {
1178
+ try {
1179
+ const response = await fetch(sized(url), { signal: AbortSignal.timeout(TIMEOUT_MS) });
1180
+ if (!response.ok) return null;
1181
+ const type = response.headers.get("content-type")?.split(";")[0]?.trim() ?? "";
1182
+ if (!type.startsWith("image/")) return null;
1183
+ const bytes2 = Buffer.from(await response.arrayBuffer());
1184
+ if (bytes2.byteLength === 0 || bytes2.byteLength > MAX_BYTES) return null;
1185
+ return `data:${type};base64,${bytes2.toString("base64")}`;
1186
+ } catch {
1187
+ return null;
1188
+ }
1189
+ }
1190
+ function sized(url) {
1191
+ try {
1192
+ const asked = new URL(url);
1193
+ asked.searchParams.set("s", String(PIXELS));
1194
+ return asked.toString();
1195
+ } catch {
1196
+ return url;
1197
+ }
1198
+ }
1199
+ var PIXELS, MAX_BYTES, TIMEOUT_MS;
1200
+ var init_avatar = __esm({
1201
+ "../cli/src/lib/cloud/avatar.ts"() {
1202
+ "use strict";
1203
+ init_session();
1204
+ PIXELS = 80;
1205
+ MAX_BYTES = 256 * 1024;
1206
+ TIMEOUT_MS = 5e3;
1207
+ }
1208
+ });
1209
+
1210
+ // ../cli/src/lib/cloud/pro.ts
1211
+ import fs5 from "node:fs";
1212
+ import path6 from "node:path";
1213
+ function forgetPro() {
1214
+ fs5.rmSync(heldFile(), { force: true });
1215
+ }
1216
+ var FRESH_MS, GRACE_MS, heldFile;
1217
+ var init_pro = __esm({
1218
+ "../cli/src/lib/cloud/pro.ts"() {
1219
+ "use strict";
1220
+ init_home();
1221
+ init_config();
1222
+ init_session();
1223
+ FRESH_MS = 10 * 6e4;
1224
+ GRACE_MS = 7 * 24 * 60 * 6e4;
1225
+ heldFile = () => path6.join(machineHome(), "pro.json");
1226
+ }
1227
+ });
1228
+
1229
+ // ../cli/src/lib/cloud/account.ts
1230
+ async function readCloudAccount() {
1231
+ const blank = {
1232
+ state: "signed-out",
1233
+ handle: null,
1234
+ name: null,
1235
+ avatarUrl: null,
1236
+ avatarData: null,
1237
+ email: null,
1238
+ message: null,
1239
+ inviteRequestedAt: null,
1240
+ sessionFile: sessionFile(),
1241
+ configured: cloudConfigured()
1242
+ };
1243
+ if (!blank.configured) return { ...blank, message: NOT_CONFIGURED };
1244
+ const token2 = await accessToken();
1245
+ if (!token2.ok) {
1246
+ if (token2.reason === "signed-out") return blank;
1247
+ if (token2.reason === "unreachable") {
1248
+ return { ...blank, ...held(), state: "signed-in", error: token2.error };
1249
+ }
1250
+ return { ...blank, ...held(), state: "expired" };
1251
+ }
1252
+ let response;
1253
+ try {
1254
+ response = await fetch(`${cloudEndpoints().api}/v1/session`, {
1255
+ headers: { authorization: `Bearer ${token2.token}` }
1256
+ });
1257
+ } catch (e) {
1258
+ return {
1259
+ ...blank,
1260
+ ...held(),
1261
+ state: "signed-in",
1262
+ error: e instanceof Error ? e.message : String(e)
1263
+ };
1264
+ }
1265
+ const body = await response.json().catch(() => ({}));
1266
+ if (!response.ok) {
1267
+ const refusal2 = body.error;
1268
+ if (refusal2?.code === "unauthenticated") {
1269
+ return { ...blank, ...held(), state: "expired", message: refusal2.message ?? null };
1270
+ }
1271
+ if (refusal2?.code === "not_admitted") {
1272
+ return { ...blank, ...held(), state: "not-admitted", message: refusal2.message ?? null };
1273
+ }
1274
+ return { ...blank, ...held(), state: "signed-in", error: refusal2?.message };
1275
+ }
1276
+ const session = body.session ?? {};
1277
+ const avatarUrl = session.avatar_url ?? session.avatarUrl ?? null;
1278
+ const attested = {
1279
+ handle: session.handle ?? null,
1280
+ name: session.name ?? null,
1281
+ avatarUrl,
1282
+ // Costs a fetch the first time this address is seen and a file read every time after,
1283
+ // so the picture is on the machine before any screen asks to draw it.
1284
+ avatarData: await heldAvatar(avatarUrl),
1285
+ email: session.email ?? null,
1286
+ inviteRequestedAt: session.inviteRequestedAt ?? null
1287
+ };
1288
+ return session.admitted ? { ...blank, ...attested, state: "signed-in" } : { ...blank, ...attested, state: "not-admitted", message: body.refusal?.message ?? null };
1289
+ }
1290
+ function signOutOfCloud() {
1291
+ clearSession();
1292
+ forgetPro();
1293
+ return { ok: true };
1294
+ }
1295
+ function held() {
1296
+ const session = readSession();
1297
+ return {
1298
+ handle: session?.handle ?? null,
1299
+ name: session?.name ?? null,
1300
+ avatarUrl: session?.avatarUrl ?? null,
1301
+ avatarData: session?.avatar?.data ?? null,
1302
+ email: session?.email ?? null
1303
+ };
1304
+ }
1305
+ var init_account = __esm({
1306
+ "../cli/src/lib/cloud/account.ts"() {
1307
+ "use strict";
1308
+ init_avatar();
1309
+ init_config();
1310
+ init_pro();
1311
+ init_session();
1312
+ }
1313
+ });
1314
+
1315
+ // ../cli/src/commands/cloud.ts
1316
+ import fs6 from "node:fs";
1317
+ import path7 from "node:path";
1318
+ async function cmdCloud(args, program2) {
1319
+ const [sub] = args;
1320
+ if (sub === "sign-out") {
1321
+ signOutOfCloud();
1322
+ say("Signed out. This machine no longer reaches Cloud; nothing on any board changed.");
1323
+ return { signedOut: true };
1324
+ }
1325
+ if (sub !== void 0) {
890
1326
  die(
891
1327
  `unknown \`account\` command "${sub}". Try \`${program2} account\` or \`${program2} account sign-out\`.`,
892
1328
  { kind: "unknown-move" }
@@ -1028,11 +1464,13 @@ function refuse(m, fallback) {
1028
1464
  async function generate(g) {
1029
1465
  const token2 = await accessToken();
1030
1466
  if (!token2.ok) refuse(SAID[token2.reason], g.fallback);
1467
+ const task = workspaceTask();
1031
1468
  let res;
1032
1469
  try {
1033
1470
  res = await fetch(`${cloudEndpoints().api}${g.endpoint}`, {
1034
1471
  method: "POST",
1035
- headers: { authorization: `Bearer ${token2.token}`, "content-type": "application/json" },
1472
+ // The task this spends credits for, inside a Runner task (#629).
1473
+ headers: { authorization: `Bearer ${token2.token}`, "content-type": "application/json", ...task ? { "x-wildcrane-task": task } : {} },
1036
1474
  body: JSON.stringify(g.body)
1037
1475
  });
1038
1476
  } catch {
@@ -1061,6 +1499,7 @@ var init_cloud = __esm({
1061
1499
  init_account();
1062
1500
  init_config();
1063
1501
  init_session();
1502
+ init_tasks();
1064
1503
  init_paths();
1065
1504
  init_io();
1066
1505
  SAID = {
@@ -1134,435 +1573,171 @@ function linked() {
1134
1573
  for (let dir = process.cwd(); ; dir = path8.dirname(dir)) {
1135
1574
  if (fs7.existsSync(path8.join(dir, ".akb", "base.json"))) {
1136
1575
  const link2 = linkedProject("", dir);
1137
- return link2.ok ? link2.value : null;
1138
- }
1139
- if (path8.dirname(dir) === dir) return null;
1140
- }
1141
- }
1142
- async function project(asked) {
1143
- const id = asked ?? linked();
1144
- if (id) return id;
1145
- const rows = await all("/v1/projects");
1146
- return refuse2(`Pick a project with --project: ${rows.map(projectLine).join(", ") || "none yet"}`, "no_project");
1147
- }
1148
- async function workspace(asked) {
1149
- if (asked) return asked;
1150
- const prj = linked();
1151
- if (prj) return (await cloud("GET", `/v1/projects/${enc(prj)}`)).workspace;
1152
- const rows = await all("/v1/workspaces");
1153
- return refuse2(`Pick a workspace with --workspace: ${rows.map((w) => `${w.id} ${w.name}`).join(", ")}`, "no_project");
1154
- }
1155
- async function taskRef(asked) {
1156
- if (!/^\d+$/.test(asked.trim())) return asked.trim();
1157
- const prj = linked();
1158
- if (!prj) refuse2("Write the full task key, like WC-12, or run this in a linked folder.", "no_project");
1159
- return `${(await cloud("GET", `/v1/projects/${enc(prj)}`)).prefix}-${asked.trim()}`;
1160
- }
1161
- async function taskList(opts) {
1162
- const scope = opts.project || !opts.workspace ? `project=${enc(await project(opts.project))}` : `workspace=${enc(opts.workspace)}`;
1163
- const page = await cloud("GET", `/v1/tasks?${scope}&limit=100${opts.status ? `&status=${enc(opts.status)}` : ""}`);
1164
- for (const t of page.data) say(`${t.key} ${t.status} ${t.title}`);
1165
- return { ...page };
1166
- }
1167
- async function taskShow(id) {
1168
- const task = await cloud("GET", `/v1/tasks/${enc(await taskRef(id))}`);
1169
- const card = task.workflow ? await cloud("GET", `/v1/tasks/${enc(task.id)}/card`).catch(() => null) : null;
1170
- say(`${task.key} ${task.title}`);
1171
- say(`${task.status}${task.workflow ? ` ${task.workflow.name}` : ""} ${taskUrl(task.key)}`);
1172
- if (card?.body) say(`
1173
- ${card.body.trim()}`);
1174
- return { ...task, card };
1175
- }
1176
- async function taskCreate(request2, opts) {
1177
- const text4 = request2.trim();
1178
- if (!text4) die("Say what the task is.", { kind: "bad-args", exitCode: 2 });
1179
- const line = text4.split("\n")[0].trim();
1180
- const title = line.length > 80 ? `${line.slice(0, 79)}\u2026` : line;
1181
- const task = await cloud("POST", "/v1/tasks", {
1182
- title,
1183
- request: text4,
1184
- project: await project(opts.project),
1185
- ...opts.workflow ? { workflow: cloudWorkflow(opts.workflow) } : {},
1186
- source: "api"
1187
- });
1188
- say(`Created ${task.key}: ${task.title} ${taskUrl(task.key)}`);
1189
- return { ...task };
1190
- }
1191
- async function act(id, route2, body, done2) {
1192
- const ref = await taskRef(id);
1193
- const value = await cloud("POST", `/v1/tasks/${enc(ref)}/${route2}`, body);
1194
- say(done2(ref));
1195
- return value;
1196
- }
1197
- async function taskApprove(id, comment) {
1198
- const task = await cloud("GET", `/v1/tasks/${enc(await taskRef(id))}`);
1199
- return act(task.key, "decisions", {
1200
- decision: "approve",
1201
- ...comment?.trim() ? { comment: comment.trim() } : {},
1202
- ...task.review ? { review_revision: task.review.revision } : {}
1203
- }, (k) => `Approved ${k}.`);
1204
- }
1205
- async function workspaceList() {
1206
- const data = await all("/v1/workspaces");
1207
- for (const w of data) say(`${w.id} ${w.name}`);
1208
- return { data };
1209
- }
1210
- async function projectList(opts) {
1211
- const data = await all(`/v1/projects${opts.workspace ? `?workspace=${enc(opts.workspace)}` : ""}`);
1212
- for (const p of data) say(projectLine(p));
1213
- return { data };
1214
- }
1215
- async function runnerList(opts) {
1216
- const held4 = await cloud("GET", `/v1/workspaces/${enc(await workspace(opts.workspace))}/runners`);
1217
- for (const r of held4.runners) say(`${r.name} ${r.connected ? "online" : "offline"}`);
1218
- return held4;
1219
- }
1220
- var refuse2, enc, WEB, taskUrl, projectLine, taskChat, taskRemove, taskResume, taskStop, taskComment;
1221
- var init_task = __esm({
1222
- "../cli/src/commands/task.ts"() {
1223
- "use strict";
1224
- init_config();
1225
- init_session();
1226
- init_tasks();
1227
- init_io();
1228
- init_paths();
1229
- init_cloud();
1230
- refuse2 = (message, code) => die(message, { kind: code, code });
1231
- enc = encodeURIComponent;
1232
- WEB = () => process.env.WILDCRANE_WEB_URL || "https://app.wildcrane.ai";
1233
- taskUrl = (key) => `${WEB()}/tasks/${enc(key)}`;
1234
- projectLine = (p) => `${p.id} ${p.prefix} ${p.name}`;
1235
- taskChat = (id, message) => act(id, "chat", { body: message }, (k) => `Sent to ${k}.`);
1236
- taskRemove = (id, reason) => act(id, "cancel", reason.trim() ? { reason: reason.trim() } : void 0, (k) => `Removed ${k}. Restore it on the web.`);
1237
- taskResume = (id) => act(id, "resume", void 0, (k) => `Resumed ${k}.`);
1238
- taskStop = (id) => act(id, "stop", void 0, (k) => `Stopped ${k}.`);
1239
- taskComment = (id, text4) => act(id, "comments", { body: text4 }, (k) => `Commented on ${k}.`);
1240
- }
1241
- });
1242
-
1243
- // ../cli/src/lib/spec-agent-names.ts
1244
- var LEGACY_SPEC_AGENT_NAMES, FOLDED_SPEC_AGENTS, canonicalSpecAgent, specAgentNames;
1245
- var init_spec_agent_names = __esm({
1246
- "../cli/src/lib/spec-agent-names.ts"() {
1247
- "use strict";
1248
- LEGACY_SPEC_AGENT_NAMES = {
1249
- "recommend-tech-stack": "tech-stack-advisor",
1250
- "technology-selection": "tech-stack-advisor",
1251
- "ui-design": "ui-designer",
1252
- // Renamed in #945 and folded into the editor in #1057; its asset memory stays in
1253
- // `memory/agents/video-assets/`.
1254
- "video-assets": "hyperframes-editor",
1255
- // Renamed in #1502: it reads chats, and writes memory as a result.
1256
- "memory-reviewer": "chat-reviewer",
1257
- // Folded into `copywriting` in #1582.
1258
- "user-docs": "copywriting"
1259
- };
1260
- FOLDED_SPEC_AGENTS = /* @__PURE__ */ new Set(["user-docs"]);
1261
- canonicalSpecAgent = (name) => {
1262
- const asked = name.trim();
1263
- return LEGACY_SPEC_AGENT_NAMES[asked] ?? asked;
1264
- };
1265
- specAgentNames = (name) => {
1266
- const canonical = canonicalSpecAgent(name);
1267
- return [
1268
- canonical,
1269
- ...Object.entries(LEGACY_SPEC_AGENT_NAMES).filter(([, current]) => current === canonical).map(([legacy2]) => legacy2)
1270
- ];
1271
- };
1272
- }
1273
- });
1274
-
1275
- // ../cli/src/lib/yaml.ts
1276
- function yamlScalar(s) {
1277
- const text4 = String(s);
1278
- if (text4 === "") return '""';
1279
- if (/^[-?:,[\]{}#&*!|>'"%@`]/.test(text4) || /:\s/.test(text4) || /[\n"]/.test(text4) || /^\s|\s$/.test(text4)) {
1280
- return JSON.stringify(text4);
1281
- }
1282
- return text4;
1283
- }
1284
- function unquote(v) {
1285
- const text4 = String(v).trim();
1286
- if (text4.startsWith('"') && text4.endsWith('"')) {
1287
- try {
1288
- return JSON.parse(text4);
1289
- } catch {
1290
- return text4.slice(1, -1);
1291
- }
1292
- }
1293
- if (text4.startsWith("'") && text4.endsWith("'")) return text4.slice(1, -1);
1294
- return text4;
1295
- }
1296
- var init_yaml = __esm({
1297
- "../cli/src/lib/yaml.ts"() {
1298
- "use strict";
1299
- }
1300
- });
1301
-
1302
- // ../cli/src/lib/question-block.ts
1303
- function normalizeQuestion(raw) {
1304
- if (raw && typeof raw === "object" && !Array.isArray(raw)) {
1305
- const source = raw;
1306
- const text4 = withoutTag(String(source.question ?? source.text ?? ""));
1307
- const extra = {
1308
- ...typeof source.agent === "string" && source.agent.trim() ? { agent: source.agent.trim() } : {},
1309
- ...source.skipped === true || source.skipped === "true" ? { skipped: true } : {}
1310
- };
1311
- const options = (Array.isArray(source.options) ? source.options : []).map((o) => String(o).trim()).filter(Boolean);
1312
- if (options.length === 0) return { text: text4, ...extra };
1313
- const mode = MODES.includes(String(source.mode)) ? String(source.mode) : "single";
1314
- const recommend = (Array.isArray(source.recommend) ? source.recommend : []).map(Number).filter((n) => Number.isInteger(n) && n >= 1 && n <= options.length);
1315
- return { text: text4, mode, options, recommend: mode === "single" ? recommend.slice(0, 1) : recommend, ...extra };
1316
- }
1317
- return { text: withoutTag(String(raw)) };
1318
- }
1319
- function parseQuestionsBlock(lines) {
1320
- const out = [];
1321
- for (let i = 0; i < lines.length; i++) {
1322
- const m = lines[i].match(/^\s*-\s+([\s\S]*)$/);
1323
- if (!m) continue;
1324
- const head2 = m[1];
1325
- const opened = head2.match(/^question:\s*(.*)$/);
1326
- if (!opened) {
1327
- out.push(normalizeQuestion(unquote(head2)));
1328
- continue;
1329
- }
1330
- const q = {
1331
- question: unquote(opened[1]),
1332
- options: [],
1333
- recommend: []
1334
- };
1335
- while (i + 1 < lines.length && !/^\s*-\s/.test(lines[i + 1])) {
1336
- const field2 = lines[i + 1].match(/^\s*([A-Za-z_]+):\s*(.*)$/);
1337
- i++;
1338
- if (!field2) continue;
1339
- const [, key, val] = field2;
1340
- if (key === "options") {
1341
- while (i + 1 < lines.length && /^\s*-\s+/.test(lines[i + 1])) {
1342
- q.options.push(unquote(lines[i + 1].replace(/^\s*-\s+/, "")));
1343
- i++;
1344
- }
1345
- } else if (key === "recommend") {
1346
- q.recommend = val.replace(/^\[|\]$/g, "").split(",").map((s) => Number(s.trim())).filter((n) => Number.isInteger(n));
1347
- } else if (key === "mode") {
1348
- q.mode = unquote(val);
1349
- } else if (key === "agent") {
1350
- q.agent = unquote(val);
1351
- } else if (key === "skipped") {
1352
- q.skipped = unquote(val) === "true";
1353
- }
1576
+ return link2.ok ? link2.value : null;
1354
1577
  }
1355
- out.push(normalizeQuestion(q));
1578
+ if (path8.dirname(dir) === dir) return null;
1356
1579
  }
1357
- return out;
1358
1580
  }
1359
- var MODES, withoutTag;
1360
- var init_question_block = __esm({
1361
- "../cli/src/lib/question-block.ts"() {
1362
- "use strict";
1363
- init_yaml();
1364
- MODES = ["single", "multi"];
1365
- withoutTag = (text4) => text4.replace(/^\[user\]\s+/, "");
1366
- }
1367
- });
1368
-
1369
- // ../cli/src/lib/view/rules.ts
1370
- function creationRefusal(id, creation, what, discard = false) {
1371
- if (!creation || creation.state === "unfinished" && discard) return null;
1372
- const run2 = creation.runId.slice(0, 8);
1373
- return creation.state === "creating" ? `#${id} is still being created by run ${run2} \u2014 \`${what}\` is refused until that run finishes.` : `#${id} was never finished being created: run ${run2} stopped short. \`${what}\` is refused until that run is picked back up from the board and finishes. Use reject --discard to discard it instead.`;
1581
+ async function project(asked) {
1582
+ const id = asked ?? linked();
1583
+ if (id) return id;
1584
+ const rows = await all("/v1/projects");
1585
+ return refuse2(`Pick a project with --project: ${rows.map(projectLine).join(", ") || "none yet"}`, "no_project");
1374
1586
  }
1375
- function hasOptions(q) {
1376
- return Array.isArray(q.options) && q.options.length > 0;
1587
+ async function workspace(asked) {
1588
+ if (asked) return asked;
1589
+ const prj = linked();
1590
+ if (prj) return (await cloud("GET", `/v1/projects/${enc(prj)}`)).workspace;
1591
+ const rows = await all("/v1/workspaces");
1592
+ return refuse2(`Pick a workspace with --workspace: ${rows.map((w) => `${w.id} ${w.name}`).join(", ")}`, "no_project");
1377
1593
  }
1378
- function planDeliveryGap(card) {
1379
- if (openOf(card.questions).length > 0) return "questions";
1380
- if (!planDeliverables(card.body).length) return "deliverable";
1381
- if (!/^[ \t]*[-*]\s+\[[xX]\].*`[^`]+`/m.test(card.body)) return "command";
1382
- const { total, done: done2 } = card.todos;
1383
- return total > 0 && done2 === total ? null : "todos";
1594
+ async function taskRef(asked) {
1595
+ if (!/^\d+$/.test(asked.trim())) return asked.trim();
1596
+ const prj = linked();
1597
+ if (!prj) refuse2("Write the full task key, like WC-12, or run this in a linked folder.", "no_project");
1598
+ return `${(await cloud("GET", `/v1/projects/${enc(prj)}`)).prefix}-${asked.trim()}`;
1384
1599
  }
1385
- function awaitingApproval(card) {
1386
- const { stages, stage } = card;
1387
- if (!stages || !stage || stage >= stages || card.status !== "ready") return null;
1388
- return openOf(card.questions).length ? null : stage;
1600
+ async function taskList(opts) {
1601
+ const scope = opts.project || !opts.workspace ? `project=${enc(await project(opts.project))}` : `workspace=${enc(opts.workspace)}`;
1602
+ const page = await cloud("GET", `/v1/tasks?${scope}&limit=100${opts.status ? `&status=${enc(opts.status)}` : ""}`);
1603
+ for (const t of page.data) say(`${t.key} ${t.status} ${t.title}`);
1604
+ return { ...page };
1389
1605
  }
1390
- function byDispatchOrder(a, b) {
1391
- return rank(LEVEL_RANK, a.priority) - rank(LEVEL_RANK, b.priority) || a.id - b.id;
1606
+ async function taskShow(id) {
1607
+ const task = await cloud("GET", `/v1/tasks/${enc(await taskRef(id))}`);
1608
+ const card = task.workflow ? await cloud("GET", `/v1/tasks/${enc(task.id)}/card`).catch(() => null) : null;
1609
+ say(`${task.key} ${task.title}`);
1610
+ say(`${task.status}${task.workflow ? ` ${task.workflow.name}` : ""} ${taskUrl(task.key)}`);
1611
+ if (card?.body) say(`
1612
+ ${card.body.trim()}`);
1613
+ return { ...task, card };
1392
1614
  }
1393
- function canRefine(card) {
1394
- if (card.isGroup) return false;
1395
- if (awaitingApproval(card)) return false;
1396
- if (card.status !== "todo" && !planUnfinished(card)) return false;
1397
- const { total, done: done2 } = card.todos;
1398
- if (total > 0 && done2 === total && !planUnfinished(card)) return false;
1399
- const open3 = openOf(card.questions);
1400
- if (open3.length > 0 && open3.every(hasOptions)) return false;
1401
- return true;
1615
+ async function taskCreate(request2, opts) {
1616
+ const text4 = request2.trim();
1617
+ if (!text4) die("Say what the task is.", { kind: "bad-args", exitCode: 2 });
1618
+ const line = text4.split("\n")[0].trim();
1619
+ const title = line.length > 80 ? `${line.slice(0, 79)}\u2026` : line;
1620
+ const task = await cloud("POST", "/v1/tasks", {
1621
+ title,
1622
+ request: text4,
1623
+ project: await project(opts.project),
1624
+ ...opts.workflow ? { workflow: cloudWorkflow(opts.workflow) } : {},
1625
+ source: "api"
1626
+ });
1627
+ say(`Created ${task.key}: ${task.title} ${taskUrl(task.key)}`);
1628
+ return { ...task };
1402
1629
  }
1403
- var openOf, PLAN_DELIVERABLE, PAGES_STORYBOARD, planDeliverables, planUnfinished, LEVEL_RANK, rank;
1404
- var init_rules = __esm({
1405
- "../cli/src/lib/view/rules.ts"() {
1406
- "use strict";
1407
- openOf = (questions) => questions.filter((q) => !q.skipped);
1408
- PLAN_DELIVERABLE = /\.(mp4|webm|mov|m4v|pptx|md|mdx)$/i;
1409
- PAGES_STORYBOARD = /(^|\/)pages-[^/]*\.json$/i;
1410
- planDeliverables = (body) => [
1411
- ...[...body.matchAll(/<Asset\s[^>]*src="([^"]+)"/gi)].map((m) => m[1]).filter((src) => PLAN_DELIVERABLE.test(src)),
1412
- ...[...body.matchAll(/<Storyboard\s[^>]*src="([^"]+)"/gi)].map((m) => m[1]).filter((src) => PAGES_STORYBOARD.test(src))
1413
- ];
1414
- planUnfinished = (card) => card.deliversIn === "plan" && planDeliveryGap(card) !== null;
1415
- LEVEL_RANK = { high: 0, med: 1, low: 2 };
1416
- rank = (table, value) => table[value] ?? Object.keys(table).length;
1417
- }
1418
- });
1419
-
1420
- // ../cli/src/lib/frontmatter.ts
1421
- function serializeFrontmatter(m) {
1422
- const out = ["---"];
1423
- out.push(`title: ${yamlScalar(m.title)}`);
1424
- out.push(`priority: ${m.priority}`);
1425
- out.push(`status: ${STATUSES.includes(String(m.status)) ? m.status : "todo"}`);
1426
- out.push(`blocked_by: [${(m.blocked_by || []).join(", ")}]`);
1427
- out.push(`related: [${(m.related || []).join(", ")}]`);
1428
- out.push(`modules: [${(m.modules || []).join(", ")}]`);
1429
- if (m.workflow) out.push(`workflow: ${yamlScalar(m.workflow)}`);
1430
- if (m.triage) out.push(`triage: ${yamlScalar(m.triage)}`);
1431
- if (m.source?.length) {
1432
- out.push("source:");
1433
- for (const ref of m.source) out.push(` - ${yamlScalar(ref)}`);
1434
- }
1435
- if (m.previews) out.push(`previews: [${m.previews.join(", ")}]`);
1436
- if ((m.stages ?? 0) > 0) out.push(`stages: ${m.stages}`);
1437
- if ((m.phase ?? 0) > 1) out.push(`phase: ${m.phase}`);
1438
- if (m.preview_approved) out.push("preview_approved: true");
1439
- if (m.archived) out.push(`archived: ${yamlScalar(m.archived)}`);
1440
- if (m.rejected) out.push("rejected: true");
1441
- if (m.rejected_reason) out.push(`rejected_reason: ${yamlScalar(m.rejected_reason)}`);
1442
- if (m.rejected_at) out.push(`rejected_at: ${yamlScalar(m.rejected_at)}`);
1443
- if (m.rejected_by) out.push(`rejected_by: ${m.rejected_by}`);
1444
- if (!m.questions || m.questions.length === 0) out.push("questions: []");
1445
- else {
1446
- out.push("questions:");
1447
- for (const raw of m.questions) {
1448
- const q = normalizeQuestion(raw);
1449
- if (!hasOptions(q) && !q.agent && !q.skipped) {
1450
- out.push(` - ${yamlScalar(q.text)}`);
1451
- continue;
1452
- }
1453
- out.push(` - question: ${yamlScalar(q.text)}`);
1454
- if (hasOptions(q)) {
1455
- out.push(` mode: ${q.mode}`);
1456
- out.push(" options:");
1457
- for (const o of q.options) out.push(` - ${yamlScalar(o)}`);
1458
- out.push(` recommend: [${q.recommend.join(", ")}]`);
1459
- }
1460
- if (q.agent) out.push(` agent: ${yamlScalar(q.agent)}`);
1461
- if (q.skipped) out.push(" skipped: true");
1462
- }
1463
- }
1464
- out.push("---");
1465
- return out.join("\n");
1630
+ async function act(id, route2, body, done2) {
1631
+ const ref = await taskRef(id);
1632
+ const value = await cloud("POST", `/v1/tasks/${enc(ref)}/${route2}`, body);
1633
+ say(done2(ref));
1634
+ return value;
1466
1635
  }
1467
- function parseFrontmatter(text4) {
1468
- const lines = text4.split("\n");
1469
- if (lines[0].trim() !== "---") return { meta: null, body: text4 };
1470
- let i = 1;
1471
- const fm = [];
1472
- while (i < lines.length && lines[i].trim() !== "---") {
1473
- fm.push(lines[i]);
1474
- i++;
1475
- }
1476
- if (i >= lines.length) return { meta: null, body: text4 };
1477
- const meta = {};
1478
- for (let j = 0; j < fm.length; j++) {
1479
- const m = fm[j].match(/^([A-Za-z_]+):\s*(.*)$/);
1480
- if (!m) continue;
1481
- const key = m[1];
1482
- const val = m[2];
1483
- if (key === "questions") {
1484
- if (val === "") {
1485
- const block = [];
1486
- while (j + 1 < fm.length && /^\s/.test(fm[j + 1]) && fm[j + 1].trim() !== "") {
1487
- block.push(fm[j + 1]);
1488
- j++;
1489
- }
1490
- meta.questions = parseQuestionsBlock(block);
1491
- } else {
1492
- meta.questions = val.trim() === "[]" ? [] : [normalizeQuestion(unquote(val))];
1493
- }
1494
- continue;
1495
- }
1496
- if (val === "") {
1497
- const items = [];
1498
- while (j + 1 < fm.length && /^\s*-\s+/.test(fm[j + 1])) {
1499
- items.push(unquote(fm[j + 1].replace(/^\s*-\s+/, "")));
1500
- j++;
1501
- }
1502
- meta[key] = items;
1503
- } else if (val.startsWith("[")) {
1504
- const inner = val.slice(1, val.lastIndexOf("]"));
1505
- meta[key] = inner.split(",").map((s) => s.trim()).filter(Boolean).map(unquote);
1506
- } else {
1507
- meta[key] = unquote(val);
1508
- }
1509
- }
1510
- for (const k of ["blocked_by", "related"]) {
1511
- const value = meta[k];
1512
- if (Array.isArray(value)) {
1513
- meta[k] = value.map((x) => Number(String(x).replace(/^#/, ""))).filter((n) => Number.isInteger(n));
1514
- } else {
1515
- meta[k] = [];
1516
- }
1517
- }
1518
- if (!Array.isArray(meta.questions)) {
1519
- meta.questions = meta.questions ? [normalizeQuestion(meta.questions)] : [];
1636
+ async function taskApprove(id, comment) {
1637
+ const task = await cloud("GET", `/v1/tasks/${enc(await taskRef(id))}`);
1638
+ return act(task.key, "decisions", {
1639
+ decision: "approve",
1640
+ ...comment?.trim() ? { comment: comment.trim() } : {},
1641
+ ...task.review ? { review_revision: task.review.revision } : {}
1642
+ }, (k) => `Approved ${k}.`);
1643
+ }
1644
+ async function taskUpdateQuestions(id, typed) {
1645
+ const ops = readQuestionOps(typed);
1646
+ const ref = await taskRef(id);
1647
+ const card = await cloud("GET", `/v1/tasks/${enc(ref)}/card`);
1648
+ const questions = parseFrontmatter(card.body).meta?.questions ?? [];
1649
+ let changes;
1650
+ let open3;
1651
+ try {
1652
+ const done2 = applyQuestionOps(questions, ops);
1653
+ changes = done2.changes;
1654
+ open3 = done2.questions.length;
1655
+ } catch (e) {
1656
+ if (e instanceof QuestionOpError) die(`${ref}: ${e.message}`);
1657
+ throw e;
1520
1658
  }
1521
- meta.priority = typeof meta.priority === "string" ? meta.priority.trim() : "";
1522
- if (!Array.isArray(meta.modules)) meta.modules = [];
1523
- delete meta.channels;
1524
- delete meta.decided;
1525
- delete meta.verify;
1526
- delete meta.release;
1527
- delete meta.schedule;
1528
- delete meta.roi;
1529
- meta.workflow = typeof meta.workflow === "string" && meta.workflow.trim() ? meta.workflow.trim() : "";
1530
- meta.triage = typeof meta.triage === "string" ? meta.triage.trim() : "";
1531
- meta.source = (Array.isArray(meta.source) ? meta.source : typeof meta.source === "string" ? [meta.source] : []).map((ref) => String(ref).trim()).filter(Boolean);
1532
- delete meta.phases;
1533
- if (Array.isArray(meta.previews)) meta.previews = meta.previews.map((name) => String(name).trim()).filter(Boolean);
1534
- else delete meta.previews;
1535
- meta.stages = /^\d+$/.test(String(meta.stages ?? "").trim()) ? Number(meta.stages) : 0;
1536
- meta.phase = /^\d+$/.test(String(meta.phase ?? "").trim()) ? Number(meta.phase) : 0;
1537
- meta.preview_approved = meta.preview_approved === "true";
1538
- meta.archived = typeof meta.archived === "string" && meta.archived.trim() ? meta.archived.trim() : "";
1539
- meta.rejected = meta.rejected === "true";
1540
- meta.rejected_reason = typeof meta.rejected_reason === "string" ? meta.rejected_reason : "";
1541
- meta.rejected_at = typeof meta.rejected_at === "string" ? meta.rejected_at.trim() : "";
1542
- meta.rejected_by = meta.rejected_by === "user" || meta.rejected_by === "agent" ? meta.rejected_by : "";
1543
- return { meta, body: lines.slice(i + 1).join("\n") };
1659
+ const body = ops.map((op) => {
1660
+ const q = op.question && { text: op.question.text, options: op.question.options, recommend: op.question.recommend, mode: op.question.mode, agent: op.question.agent };
1661
+ if (op.kind === "append") return { append: q };
1662
+ if (op.kind === "update") return { update: op.n, question: q };
1663
+ if (op.kind === "drop") return { drop: questionPositions(op.ns, Infinity, "drop") };
1664
+ if (op.kind === "clear") return { clear: true };
1665
+ return die(`akb task update-questions has no --${op.kind}; --drop removes a question`);
1666
+ });
1667
+ const task = await cloud("PATCH", `/v1/tasks/${enc(ref)}/questions`, { base_version: card.version, ops: body });
1668
+ say(`updated ${task.key} questions: ${changes.join(", ")} (${open3} open)`);
1669
+ return { ...task, changes, open: open3 };
1544
1670
  }
1545
- function frontmatterEnd(lines) {
1546
- if (lines[0]?.trim() !== "---") return 0;
1547
- let i = 1;
1548
- while (i < lines.length && lines[i].trim() !== "---") i++;
1549
- return i >= lines.length ? 0 : i;
1671
+ async function workspaceList() {
1672
+ const data = await all("/v1/workspaces");
1673
+ for (const w of data) say(`${w.id} ${w.name}`);
1674
+ return { data };
1550
1675
  }
1551
- function frontmatterField(lines, i) {
1552
- for (let j = i; j > 0; j--) {
1553
- const m = lines[j].match(/^([A-Za-z_]+):/);
1554
- if (m) return m[1];
1555
- }
1556
- return "frontmatter";
1676
+ async function projectList(opts) {
1677
+ const data = await all(`/v1/projects${opts.workspace ? `?workspace=${enc(opts.workspace)}` : ""}`);
1678
+ for (const p of data) say(projectLine(p));
1679
+ return { data };
1680
+ }
1681
+ async function runnerList(opts) {
1682
+ const held4 = await cloud("GET", `/v1/workspaces/${enc(await workspace(opts.workspace))}/runners`);
1683
+ for (const r of held4.runners) say(`${r.name} ${r.connected ? "online" : "offline"}`);
1684
+ return held4;
1557
1685
  }
1558
- var STATUSES;
1559
- var init_frontmatter = __esm({
1560
- "../cli/src/lib/frontmatter.ts"() {
1686
+ var refuse2, enc, WEB, taskUrl, projectLine, taskChat, taskRemove, taskResume, taskStop, taskComment;
1687
+ var init_task = __esm({
1688
+ "../cli/src/commands/task.ts"() {
1561
1689
  "use strict";
1562
- init_yaml();
1563
- init_question_block();
1564
- init_rules();
1565
- STATUSES = ["todo", "ready", "implementing"];
1690
+ init_config();
1691
+ init_session();
1692
+ init_tasks();
1693
+ init_io();
1694
+ init_paths();
1695
+ init_frontmatter();
1696
+ init_questions();
1697
+ init_question_ops();
1698
+ init_cloud();
1699
+ refuse2 = (message, code) => die(message, { kind: code, code });
1700
+ enc = encodeURIComponent;
1701
+ WEB = () => process.env.WILDCRANE_WEB_URL || "https://app.wildcrane.ai";
1702
+ taskUrl = (key) => `${WEB()}/tasks/${enc(key)}`;
1703
+ projectLine = (p) => `${p.id} ${p.prefix} ${p.name}`;
1704
+ taskChat = (id, message) => act(id, "chat", { body: message }, (k) => `Sent to ${k}.`);
1705
+ taskRemove = (id, reason) => act(id, "cancel", reason.trim() ? { reason: reason.trim() } : void 0, (k) => `Removed ${k}. Restore it on the web.`);
1706
+ taskResume = (id) => act(id, "resume", void 0, (k) => `Resumed ${k}.`);
1707
+ taskStop = (id) => act(id, "stop", void 0, (k) => `Stopped ${k}.`);
1708
+ taskComment = (id, text4) => act(id, "comments", { body: text4 }, (k) => `Commented on ${k}.`);
1709
+ }
1710
+ });
1711
+
1712
+ // ../cli/src/lib/spec-agent-names.ts
1713
+ var LEGACY_SPEC_AGENT_NAMES, FOLDED_SPEC_AGENTS, canonicalSpecAgent, specAgentNames;
1714
+ var init_spec_agent_names = __esm({
1715
+ "../cli/src/lib/spec-agent-names.ts"() {
1716
+ "use strict";
1717
+ LEGACY_SPEC_AGENT_NAMES = {
1718
+ "recommend-tech-stack": "tech-stack-advisor",
1719
+ "technology-selection": "tech-stack-advisor",
1720
+ "ui-design": "ui-designer",
1721
+ // Renamed in #945 and folded into the editor in #1057; its asset memory stays in
1722
+ // `memory/agents/video-assets/`.
1723
+ "video-assets": "hyperframes-editor",
1724
+ // Renamed in #1502: it reads chats, and writes memory as a result.
1725
+ "memory-reviewer": "chat-reviewer",
1726
+ // Folded into `copywriting` in #1582.
1727
+ "user-docs": "copywriting"
1728
+ };
1729
+ FOLDED_SPEC_AGENTS = /* @__PURE__ */ new Set(["user-docs"]);
1730
+ canonicalSpecAgent = (name) => {
1731
+ const asked = name.trim();
1732
+ return LEGACY_SPEC_AGENT_NAMES[asked] ?? asked;
1733
+ };
1734
+ specAgentNames = (name) => {
1735
+ const canonical = canonicalSpecAgent(name);
1736
+ return [
1737
+ canonical,
1738
+ ...Object.entries(LEGACY_SPEC_AGENT_NAMES).filter(([, current]) => current === canonical).map(([legacy2]) => legacy2)
1739
+ ];
1740
+ };
1566
1741
  }
1567
1742
  });
1568
1743
 
@@ -2255,12 +2430,13 @@ function insideRun() {
2255
2430
  function runEnv(env2, value) {
2256
2431
  return { ...env2, [RUN_ENV]: value };
2257
2432
  }
2258
- var RUN_ENV, SCHEDULED_AGENTS_ENV, STOP_ENV, SESSION_VARS;
2433
+ var RUN_ENV, SCHEDULED_AGENTS_ENV, SESSION_COST_ENV, STOP_ENV, SESSION_VARS;
2259
2434
  var init_env = __esm({
2260
2435
  "../cli/src/lib/agent/env.ts"() {
2261
2436
  "use strict";
2262
2437
  RUN_ENV = "KANBAN_RUN";
2263
2438
  SCHEDULED_AGENTS_ENV = "AI4KANBAN_SCHEDULED_AGENTS";
2439
+ SESSION_COST_ENV = "AI4KANBAN_SESSION_COST";
2264
2440
  STOP_ENV = "KANBAN_STOP_ID";
2265
2441
  SESSION_VARS = {
2266
2442
  "claude-code": "CLAUDE_CODE_SESSION_ID",
@@ -2913,6 +3089,11 @@ function createEventCollector() {
2913
3089
  const t = target ? targetOf(target) : void 0;
2914
3090
  queue.push({ kind: "tool_call", data: { toolCallId, title, kind, status: "in_progress", ...t ? { target: t } : {} } });
2915
3091
  },
3092
+ /** A subagent the agent started, titled by its task; it ends with its call's `toolResult`. */
3093
+ subagent(toolCallId, title) {
3094
+ close();
3095
+ queue.push({ kind: "tool_call", data: { toolCallId, title: targetOf(title) ?? "subagent", kind: "other", status: "in_progress", subagent: true } });
3096
+ },
2916
3097
  toolResult(toolCallId, status, result) {
2917
3098
  close();
2918
3099
  queue.push({ kind: "tool_call_update", data: { toolCallId, status, ...result.trim() ? { result: result.trim() } : {} } });
@@ -3092,6 +3273,13 @@ function createStreamRenderer() {
3092
3273
  const backgrounded = /* @__PURE__ */ new Set();
3093
3274
  const events = createEventCollector();
3094
3275
  const plans = /* @__PURE__ */ new Set();
3276
+ const subagents = /* @__PURE__ */ new Map();
3277
+ const detached = /* @__PURE__ */ new Set();
3278
+ const endSubagent = (id, status) => {
3279
+ if (subagents.get(id) !== false) return;
3280
+ subagents.set(id, true);
3281
+ events.toolResult(id, status, "");
3282
+ };
3095
3283
  const renderLine = (line) => {
3096
3284
  if (!line.trim()) return "";
3097
3285
  const ev = frame(line);
@@ -3101,6 +3289,7 @@ function createStreamRenderer() {
3101
3289
  `;
3102
3290
  }
3103
3291
  if (model === void 0) model = eventModel(ev);
3292
+ if (str(ev.parent_tool_use_id)) return "";
3104
3293
  switch (ev.type) {
3105
3294
  case "assistant": {
3106
3295
  const msg = ev.message;
@@ -3118,7 +3307,12 @@ function createStreamRenderer() {
3118
3307
  } else if (b?.type === "tool_use" && typeof b.name === "string") {
3119
3308
  out.push(`\u23FA ${b.name}${argHint(b.input, ARG_KEYS)}
3120
3309
  `);
3121
- if (b.name === "TodoWrite") {
3310
+ if (SUBAGENT_TOOLS.has(b.name)) {
3311
+ const input = obj(b.input);
3312
+ subagents.set(str(b.id), false);
3313
+ if (input.run_in_background === true) detached.add(str(b.id));
3314
+ events.subagent(str(b.id), str(input.description) || str(input.subagent_type) || b.name);
3315
+ } else if (b.name === "TodoWrite") {
3122
3316
  plans.add(str(b.id));
3123
3317
  events.plan(obj(b.input).todos);
3124
3318
  } else {
@@ -3133,6 +3327,10 @@ function createStreamRenderer() {
3133
3327
  for (const raw of Array.isArray(content) ? content : []) {
3134
3328
  const b = obj(raw);
3135
3329
  if (b.type !== "tool_result" || plans.has(str(b.tool_use_id))) continue;
3330
+ if (subagents.has(str(b.tool_use_id))) {
3331
+ if (!detached.has(str(b.tool_use_id))) endSubagent(str(b.tool_use_id), b.is_error === true ? "failed" : "completed");
3332
+ continue;
3333
+ }
3136
3334
  events.toolResult(str(b.tool_use_id), b.is_error === true ? "failed" : "completed", resultText(b.content));
3137
3335
  }
3138
3336
  return "";
@@ -3160,6 +3358,9 @@ function createStreamRenderer() {
3160
3358
  case "system":
3161
3359
  if (ev.subtype === "background_tasks_changed" && Array.isArray(ev.tasks)) background = ev.tasks.length;
3162
3360
  if (ev.subtype === "task_started" && ev.is_backgrounded === true) backgrounded.add(str(ev.task_id));
3361
+ if (ev.subtype === "task_notification" && subagents.has(str(ev.tool_use_id))) {
3362
+ endSubagent(str(ev.tool_use_id), str(ev.status) === "completed" ? "completed" : "failed");
3363
+ }
3163
3364
  if (ev.subtype === "task_notification" && backgrounded.has(str(ev.task_id)) && str(ev.summary)) {
3164
3365
  return `\u23FA ${str(ev.summary)}
3165
3366
  `;
@@ -3194,7 +3395,7 @@ function usageOf(raw) {
3194
3395
  };
3195
3396
  return parsed.input + parsed.cacheCreation + parsed.cacheRead + parsed.output > 0 ? parsed : void 0;
3196
3397
  }
3197
- var ARG_KEYS, TOOL_KINDS2, USER_FIXES, addUsage;
3398
+ var ARG_KEYS, TOOL_KINDS2, SUBAGENT_TOOLS, USER_FIXES, addUsage;
3198
3399
  var init_claude_stream = __esm({
3199
3400
  "../cli/src/lib/agent/wire/claude-stream.ts"() {
3200
3401
  "use strict";
@@ -3214,6 +3415,7 @@ var init_claude_stream = __esm({
3214
3415
  WebFetch: "fetch",
3215
3416
  WebSearch: "fetch"
3216
3417
  };
3418
+ SUBAGENT_TOOLS = /* @__PURE__ */ new Set(["Agent", "Task"]);
3217
3419
  USER_FIXES = [
3218
3420
  [/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."],
3219
3421
  [/usage limit|credit balance is too low|quota/i, "Wait for the usage limit to reset, or add credit, then press Resume."]
@@ -3765,6 +3967,8 @@ function createKimiStreamRenderer(cwd) {
3765
3967
  let sessionId;
3766
3968
  let facts;
3767
3969
  let lookedAt = 0;
3970
+ const events = createEventCollector();
3971
+ const subagents = /* @__PURE__ */ new Set();
3768
3972
  const look = (now) => {
3769
3973
  const at = Date.now();
3770
3974
  if (!now && at - lookedAt < LOOK_EVERY_MS2) return;
@@ -3781,6 +3985,18 @@ function createKimiStreamRenderer(cwd) {
3781
3985
  case "assistant": {
3782
3986
  const said2 = str(row.content).trim();
3783
3987
  if (said2) final = said2;
3988
+ if (said2) events.message(said2);
3989
+ for (const raw of Array.isArray(row.tool_calls) ? row.tool_calls : []) {
3990
+ const call2 = obj(raw);
3991
+ const name = str(obj(call2.function).name) || "tool";
3992
+ const args = obj(callArgs(obj(call2.function).arguments));
3993
+ if (name === "Agent") {
3994
+ subagents.add(str(call2.id));
3995
+ events.subagent(str(call2.id), str(args.description) || name);
3996
+ } else {
3997
+ events.toolCall(str(call2.id), name, kindOf(name), ARG_KEYS2.map((k) => str(args[k])).find((v) => v.trim()));
3998
+ }
3999
+ }
3784
4000
  return `${said2 ? `${said2}
3785
4001
 
3786
4002
  ` : ""}${toolCalls(row)}`;
@@ -3788,6 +4004,13 @@ function createKimiStreamRenderer(cwd) {
3788
4004
  case "meta":
3789
4005
  if (row.type === "session.resume_hint") sessionId ??= str(row.session_id).trim() || void 0;
3790
4006
  return row.type === "turn.step.retrying" ? retry(row) : "";
4007
+ case "tool": {
4008
+ const id = str(row.tool_call_id);
4009
+ const text4 = str(row.content);
4010
+ if (subagents.delete(id)) events.toolResult(id, /^status: completed$/m.test(text4) ? "completed" : "failed", "");
4011
+ else events.toolResult(id, "completed", text4);
4012
+ return "";
4013
+ }
3791
4014
  default:
3792
4015
  return "";
3793
4016
  }
@@ -3801,6 +4024,7 @@ function createKimiStreamRenderer(cwd) {
3801
4024
  return out;
3802
4025
  },
3803
4026
  result: () => final,
4027
+ events: events.events,
3804
4028
  usage: () => facts?.usage,
3805
4029
  context: () => {
3806
4030
  look(false);
@@ -3819,14 +4043,23 @@ function createKimiStreamRenderer(cwd) {
3819
4043
  }
3820
4044
  };
3821
4045
  }
3822
- var ARG_KEYS2, LOOK_EVERY_MS2;
4046
+ var ARG_KEYS2, TOOL_KINDS3, kindOf, LOOK_EVERY_MS2;
3823
4047
  var init_kimi_stream = __esm({
3824
4048
  "../cli/src/lib/agent/wire/kimi-stream.ts"() {
3825
4049
  "use strict";
4050
+ init_events();
3826
4051
  init_json();
3827
4052
  init_stream();
3828
4053
  init_kimi_session();
3829
4054
  ARG_KEYS2 = ["command", "path", "pattern", "query", "url", "prompt", "prompt_template", "description"];
4055
+ TOOL_KINDS3 = [
4056
+ [/read/i, "read"],
4057
+ [/grep|glob|search/i, "search"],
4058
+ [/fetch|web/i, "fetch"],
4059
+ [/bash|shell/i, "execute"],
4060
+ [/write|edit|replace/i, "edit"]
4061
+ ];
4062
+ kindOf = (name) => TOOL_KINDS3.find(([re]) => re.test(name))?.[1] ?? "other";
3830
4063
  LOOK_EVERY_MS2 = 3e3;
3831
4064
  }
3832
4065
  });
@@ -3974,8 +4207,8 @@ var init_package = __esm({
3974
4207
  "../cli/package.json"() {
3975
4208
  package_default = {
3976
4209
  name: "wildcrane",
3977
- version: "0.11.35",
3978
- akbContract: 8,
4210
+ version: "0.11.37",
4211
+ akbContract: 9,
3979
4212
  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.",
3980
4213
  keywords: [
3981
4214
  "kanban",
@@ -7421,7 +7654,8 @@ function parseRuntime(value) {
7421
7654
  for (const [key, v] of Object.entries(configBlock(raw.settings))) {
7422
7655
  if (typeof v === "string" && v.trim()) settings[key] = v.trim();
7423
7656
  }
7424
- return { id, name: id === GLOBAL_ID ? GLOBAL_NAME : name, harness, settings };
7657
+ const away = typeof raw.away === "string" && raw.away.trim() ? { away: raw.away.trim() } : {};
7658
+ return { id, name: id === GLOBAL_ID ? GLOBAL_NAME : name, harness, settings, ...away };
7425
7659
  }
7426
7660
  function dedupe(list) {
7427
7661
  const seen = /* @__PURE__ */ new Set();
@@ -7487,6 +7721,20 @@ function runtimeOfAgent(names3, table = readAgentRuntime()) {
7487
7721
  }
7488
7722
  return void 0;
7489
7723
  }
7724
+ function replaceAgentRuntimes(picks) {
7725
+ return writeConfig((cfg) => {
7726
+ const global = readRuntimes(cfg)[0];
7727
+ const rows = /* @__PURE__ */ new Map();
7728
+ for (const r of Object.values(picks)) if (r.id !== GLOBAL_ID) rows.set(r.id, r);
7729
+ cfg.runtimes = [global, ...rows.values()];
7730
+ delete cfg.harnessSettings;
7731
+ delete cfg.harness;
7732
+ delete cfg.agentHarness;
7733
+ const block = Object.fromEntries(Object.entries(picks).filter(([, r]) => rows.has(r.id)).map(([agent, r]) => [agent, r.id]));
7734
+ if (Object.keys(block).length) cfg.agentRuntime = block;
7735
+ else delete cfg.agentRuntime;
7736
+ });
7737
+ }
7490
7738
  function setRuntimeHarness(id, harness) {
7491
7739
  const known2 = harnessByName(harness);
7492
7740
  if (!known2) return { ok: false, ...noHarness(harness) };
@@ -8605,7 +8853,7 @@ function specAgentSelector(id, workflow, meta) {
8605
8853
  // own job.
8606
8854
  "<preview-agents>",
8607
8855
  "The preview agents of this card's current stage, each writing one part of the card.",
8608
- ...agents.map((a) => `- \`${a.name}\` \u2014 ${a.description}${a.session ? " \xB7 runs in a session of its own: leave out `--print`" : ""}`),
8856
+ ...agents.map((a) => `- \`${a.name}\` \u2014 ${a.description}${a.session || agentRun(a.name).own ? " \xB7 runs in a session of its own: leave out `--print`" : ""}`),
8609
8857
  `Command: \`akb raw previews <agent> ${id} <short note>\` \u2014 add \`--print\` to run it in this session, as \`akb guide refine\` says.`,
8610
8858
  "</preview-agents>"
8611
8859
  ].join("\n");
@@ -9435,17 +9683,32 @@ function mcpProblem(text4) {
9435
9683
  return null;
9436
9684
  }
9437
9685
  function checkWorkflowFiles(value, official = false) {
9438
- const fail = (file, reason, tooLarge = false) => ({ ok: false, file, reason, ...tooLarge ? { tooLarge } : {} });
9686
+ const read3 = inspect(value, official);
9687
+ const first = read3.problems[0];
9688
+ return first ? { ok: false, ...first } : { ok: true, def: read3.def, files: read3.files };
9689
+ }
9690
+ function inspect(value, official) {
9691
+ const problems = [];
9692
+ const fail = (file, reason, tooLarge = false) => {
9693
+ problems.push({ file, reason, ...tooLarge ? { tooLarge } : {} });
9694
+ return { problems };
9695
+ };
9439
9696
  if (!value || typeof value !== "object" || Array.isArray(value)) return fail("files", "must be an object of path \u2192 text");
9440
- value = Object.fromEntries(Object.entries(value).filter(([file]) => file !== VERSION_FILE));
9441
- const entries = Object.entries(value);
9697
+ const files = Object.fromEntries(Object.entries(value).filter(([file]) => file !== VERSION_FILE));
9698
+ const entries = Object.entries(files);
9442
9699
  if (entries.length > FILE_LIMITS.count) return fail("files", `holds at most ${FILE_LIMITS.count} files`, true);
9443
9700
  let total = 0;
9444
9701
  const folders2 = /* @__PURE__ */ new Map();
9445
9702
  const skills = /* @__PURE__ */ new Set();
9446
9703
  for (const [file, text4] of entries) {
9447
- if (typeof text4 !== "string" || text4.includes("\0")) return fail(file, "is not a text file");
9448
- if (file.length > FILE_LIMITS.path) return fail(file, `the path is longer than ${FILE_LIMITS.path} characters`);
9704
+ if (typeof text4 !== "string" || text4.includes("\0")) {
9705
+ fail(file, "is not a text file");
9706
+ continue;
9707
+ }
9708
+ if (file.length > FILE_LIMITS.path) {
9709
+ fail(file, `the path is longer than ${FILE_LIMITS.path} characters`);
9710
+ continue;
9711
+ }
9449
9712
  const size = bytes(text4);
9450
9713
  if (size > FILE_LIMITS.file) return fail(file, `is larger than ${FILE_LIMITS.file / KB} KB`, true);
9451
9714
  total += size;
@@ -9453,49 +9716,56 @@ function checkWorkflowFiles(value, official = false) {
9453
9716
  if (file === WORKFLOW_FILE) continue;
9454
9717
  if (official && file === MCP_FILE) {
9455
9718
  const problem = mcpProblem(text4);
9456
- if (problem) return fail(file, problem);
9719
+ if (problem) fail(file, problem);
9457
9720
  continue;
9458
9721
  }
9459
9722
  if (official && isAboutFile(file)) continue;
9460
9723
  if (official && file.startsWith("skills/")) {
9461
- if (!folderPath(file, "skills")) return fail(file, "is not inside skills/<name>/");
9462
- skills.add(file.split("/")[1]);
9724
+ if (!folderPath(file, "skills")) fail(file, "is not inside skills/<name>/");
9725
+ else skills.add(file.split("/")[1]);
9463
9726
  continue;
9464
9727
  }
9465
9728
  const at = folderPath(file, "agents");
9466
- if (!at) return fail(file, `is neither ${WORKFLOW_FILE} nor inside agents/<name>/`);
9729
+ if (!at) {
9730
+ fail(file, `is neither ${WORKFLOW_FILE} nor inside agents/<name>/`);
9731
+ continue;
9732
+ }
9467
9733
  if (!folders2.has(at[0])) folders2.set(at[0], /* @__PURE__ */ new Map());
9468
9734
  folders2.get(at[0]).set(at[1], text4);
9469
9735
  }
9470
9736
  for (const name of skills) {
9471
- if (value[`skills/${name}/SKILL.md`] === void 0) return fail(`skills/${name}/SKILL.md`, "is missing");
9737
+ if (files[`skills/${name}/SKILL.md`] === void 0) fail(`skills/${name}/SKILL.md`, "is missing");
9472
9738
  }
9473
- const source = value[WORKFLOW_FILE];
9474
- if (source === void 0) return fail(WORKFLOW_FILE, "is missing");
9475
- const read3 = parseWorkflowFile("workflow", source, WORKFLOW_FILE);
9476
- if ("problem" in read3) return fail(WORKFLOW_FILE, read3.problem.replace(`${WORKFLOW_FILE}: `, ""));
9477
- const def = read3.def;
9739
+ const source = files[WORKFLOW_FILE];
9740
+ const read3 = typeof source === "string" ? parseWorkflowFile("workflow", source, WORKFLOW_FILE) : null;
9741
+ if (!read3) fail(WORKFLOW_FILE, "is missing");
9742
+ else if ("problem" in read3) fail(WORKFLOW_FILE, read3.problem.replace(`${WORKFLOW_FILE}: `, ""));
9478
9743
  const agents = /* @__PURE__ */ new Map();
9479
9744
  for (const [name, own] of folders2) {
9480
9745
  const from = `agents/${name}/AGENT.md`;
9481
9746
  const text4 = own.get("AGENT.md");
9482
- if (text4 === void 0) return fail(from, "is missing");
9747
+ if (text4 === void 0) {
9748
+ fail(from, "is missing");
9749
+ continue;
9750
+ }
9483
9751
  const parsed = parseSpecAgent(text4, from, (p) => own.get(p) ?? null, false, () => [...own.keys()].filter((p) => p !== "AGENT.md"));
9484
- if ("problem" in parsed) return fail(from, parsed.problem.replace(`${from}: `, ""));
9485
- if (parsed.agent.name !== name) return fail(from, `calls itself \`${parsed.agent.name}\`; it must match its folder`);
9486
- agents.set(name, parsed.agent);
9752
+ if ("problem" in parsed) fail(from, parsed.problem.replace(`${from}: `, ""));
9753
+ else if (parsed.agent.name !== name) fail(from, `calls itself \`${parsed.agent.name}\`; it must match its folder`);
9754
+ else agents.set(name, parsed.agent);
9487
9755
  }
9756
+ if (!read3 || "problem" in read3) return { problems };
9757
+ const def = read3.def;
9488
9758
  const named2 = [
9489
9759
  ...def.previews.map((h) => [h.agent, "it previews with"]),
9490
9760
  ...def.land.map((h) => [h.agent, "it lands with"]),
9491
9761
  ...def.scheduled.map((s) => [s.agent, "it schedules"])
9492
9762
  ];
9493
9763
  for (const [name, why2] of named2) {
9494
- if (!agents.has(name)) return fail(WORKFLOW_FILE, `${why2} \`${name}\`, which has no agents/${name}/AGENT.md`);
9764
+ if (!agents.has(name) && !folders2.has(name)) fail(WORKFLOW_FILE, `${why2} \`${name}\`, which has no agents/${name}/AGENT.md`);
9495
9765
  }
9496
- return { ok: true, def, files: value };
9766
+ return { problems, def, files };
9497
9767
  }
9498
- var WORKFLOW_FILE, MCP_FILE, VERSION_FILE, versionText, KB, FILE_LIMITS, officialId, hashInput, landsOf, SEGMENT, isAboutFile, bytes;
9768
+ var WORKFLOW_FILE, MCP_FILE, VERSION_FILE, versionText, KB, FILE_LIMITS, officialId, hashInput, landsOf, SEGMENT, isAboutFile, bytes, workflowFilesProblems;
9499
9769
  var init_workflow_files = __esm({
9500
9770
  "../cli/src/lib/shared/workflow-files.ts"() {
9501
9771
  "use strict";
@@ -9515,6 +9785,7 @@ var init_workflow_files = __esm({
9515
9785
  SEGMENT = /^[\w.-]+$/;
9516
9786
  isAboutFile = (file) => /^ABOUT(\.[a-z]{2})?\.md$/.test(file) || /^screenshots\/[\w.-]+\.(png|jpe?g|webp)$/.test(file);
9517
9787
  bytes = (text4) => new TextEncoder().encode(text4).length;
9788
+ workflowFilesProblems = (value, official = false) => inspect(value, official).problems;
9518
9789
  }
9519
9790
  });
9520
9791
 
@@ -14947,15 +15218,6 @@ var init_pause = __esm({
14947
15218
  function answerOutcome(delivery) {
14948
15219
  return pendingAnswers(delivery).some((a) => a.outcome === "changed") ? "changed" : "unchanged";
14949
15220
  }
14950
- function takeUnchanged(delivery) {
14951
- if (!pendingAnswers(delivery).some((a) => a.outcome === "unchanged")) return;
14952
- withStore((store) => {
14953
- const live = store.deliveries.find((d) => d.deliveryId === delivery.deliveryId);
14954
- if (!live) return;
14955
- const now = Date.now();
14956
- for (const answer2 of live.answers ?? []) if (!answer2.actedAt && answer2.outcome === "unchanged") answer2.actedAt = now;
14957
- });
14958
- }
14959
15221
  function recordAnswer(deliveryId, outcome, why2) {
14960
15222
  const line = why2.trim();
14961
15223
  if (!line) return { ok: false, error: "say in one sentence what the answers did \u2014 an unexplained conclusion is not one." };
@@ -15652,7 +15914,6 @@ var init_deliveries = __esm({
15652
15914
  init_flows();
15653
15915
  init_pause();
15654
15916
  init_rules2();
15655
- init_rules();
15656
15917
  init_workflows();
15657
15918
  init_store();
15658
15919
  init_types();
@@ -15675,7 +15936,7 @@ var init_deliveries = __esm({
15675
15936
  ];
15676
15937
  isApproved = (heading) => APPROVED.some((re) => re.test(heading));
15677
15938
  cardStatus = (cardId2) => cardMeta2(cardId2)?.status || "todo";
15678
- openQuestions = (cardId2) => openOf(cardMeta2(cardId2)?.questions ?? []).length;
15939
+ openQuestions = (cardId2) => cardMeta2(cardId2)?.questions.length ?? 0;
15679
15940
  activeIn = (store, cardId2) => store.deliveries.find((d) => d.status === "active" && d.cardId === cardId2);
15680
15941
  listDeliveries = () => readStore().deliveries;
15681
15942
  withWorkflow = (req) => req.workflow ? req : {
@@ -16653,7 +16914,7 @@ function cardNow(cardId2) {
16653
16914
  if (!file) return null;
16654
16915
  const { meta } = parseFrontmatter(fs52.readFileSync(file, "utf8"));
16655
16916
  if (!meta) return null;
16656
- return { status: meta.status || "todo", questions: openOf(meta.questions).length, title: meta.title };
16917
+ return { status: meta.status || "todo", questions: meta.questions.length, title: meta.title };
16657
16918
  } catch {
16658
16919
  return null;
16659
16920
  }
@@ -16955,6 +17216,8 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID4(), said2) {
16955
17216
  const parent = req.action === "sub" && req.parentId ? peekRun(req.parentId) : void 0;
16956
17217
  const cwd = parent?.cwd ?? deliveryCwd(start ?? joining ?? {});
16957
17218
  const plan = said2 ? { ...said2.plan(cwd, sessionId), note: null } : planRun(sessionId, cwd, agentForRun(req), req.runtime ? { pin: req.runtime } : {});
17219
+ const away = plan.runtime ? runtimeById(plan.runtime)?.away : void 0;
17220
+ if (away) return refusal("runtimeAway", away, { id: plan.runtime });
16958
17221
  if (plan.note) notes = [...notes, plan.note];
16959
17222
  const record = {
16960
17223
  sessionId,
@@ -16982,6 +17245,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID4(), said2) {
16982
17245
  // a fork is a fresh session of its own.
16983
17246
  ...said2 && !said2.fork ? { resumeId: plan.resumeId ?? void 0 } : {},
16984
17247
  ...said2?.continues ? { continues: { resumeId: said2.continues, ...said2.fork ? { fork: true } : {} } } : {},
17248
+ ...said2?.continues && said2.continues === req.carry?.resumeId && req.carry.costFrom ? { sessionCostFrom: req.carry.costFrom } : {},
16985
17249
  logPath: logPathOf(sessionId),
16986
17250
  // Which agent this is, on the action that is one — so the run list can name it, and so
16987
17251
  // a resume starts the same agent rather than a different one.
@@ -17833,113 +18097,6 @@ var init_inbox = __esm({
17833
18097
  }
17834
18098
  });
17835
18099
 
17836
- // ../cli/src/lib/questions.ts
17837
- function newDraft(flag, value) {
17838
- const text4 = value.trim();
17839
- if (!text4) die(`--${flag} must not be empty`);
17840
- if (text4.startsWith("[user]")) die(`"${text4}" starts with [user] \u2014 drop the prefix; every open question is the user's`);
17841
- return { question: text4, options: [], recommended: [] };
17842
- }
17843
- function addToDraft(q, key, value) {
17844
- if (key === "mode") {
17845
- const m = value.toLowerCase();
17846
- if (!MODES.includes(m)) die(`--mode must be single | multi (got "${value}")`);
17847
- q.mode = m;
17848
- return;
17849
- }
17850
- const text4 = value.trim();
17851
- if (!text4) die(`--${key} must not be empty`);
17852
- if (key === "agent") {
17853
- q.agent = text4;
17854
- return;
17855
- }
17856
- if (q.options.includes(text4)) die(`"${text4}" is listed twice as an option of "${q.question}"`);
17857
- q.options.push(text4);
17858
- if (key === "recommended-option") q.recommended.push(text4);
17859
- }
17860
- function finalizeDraft(q) {
17861
- if (q.options.length === 0) missingChoices(q.question);
17862
- if (q.options.length < 2) {
17863
- die(`a question with options needs at least 2 \u2014 add another --option ("${q.question}")`);
17864
- }
17865
- q.mode = q.mode || "single";
17866
- if (q.mode === "single" && q.recommended.length > 1) {
17867
- die(`--mode single takes at most one --recommended-option ("${q.question}")`);
17868
- }
17869
- q.recommend = q.recommended.map((text4) => q.options.indexOf(text4) + 1).sort((a, b) => a - b);
17870
- return normalizeQuestion(q);
17871
- }
17872
- function collectQuestions(order) {
17873
- const out = [];
17874
- for (const [key, value] of order) {
17875
- if (key === "question") {
17876
- out.push(newDraft("question", value));
17877
- } else if (key === "option" || key === "mode" || key === "recommended-option") {
17878
- const q = out[out.length - 1];
17879
- if (!q) die(`--${key} must come after the --question it belongs to`);
17880
- addToDraft(q, key, value);
17881
- }
17882
- }
17883
- return out.map(finalizeDraft);
17884
- }
17885
- function missingChoices(text4) {
17886
- die(
17887
- `"${text4}" needs choices to tick \u2014 add 2 or more --option "a \u2014 why". The user always gets a free-text choice too, so never write one yourself.`
17888
- );
17889
- }
17890
- function readQuestionOps(typed) {
17891
- const ops = [];
17892
- for (let i = 0; i < typed.length; i++) {
17893
- const [key, value] = typed[i];
17894
- if (key === "clear") {
17895
- ops.push({ kind: "clear" });
17896
- } else if (key === "drop" || key === "skip" || key === "unskip") {
17897
- ops.push({ kind: key, ns: value });
17898
- } else if (key === "append") {
17899
- ops.push({ kind: "append", draft: newDraft("append", value) });
17900
- } else if (key === "update") {
17901
- const n = Number(value);
17902
- if (!Number.isInteger(n) || n < 1) die('--update takes a 1-based question number, then the new text: --update <n> ".."');
17903
- const next = typed[i + 1];
17904
- if (!next || next[0] !== "update") die('--update takes a 1-based question number, then the new text: --update <n> ".."');
17905
- i++;
17906
- ops.push({ kind: "update", n, draft: newDraft("update", next[1]) });
17907
- } else {
17908
- const last = ops[ops.length - 1];
17909
- if (!last || !last.draft) die(`--${key} must come after the --append or --update it belongs to`);
17910
- addToDraft(last.draft, key, value);
17911
- }
17912
- }
17913
- if (!ops.length) {
17914
- die('update-questions needs at least one op: --append ".." | --update <n> ".." | --drop n[,n...] | --skip n[,n...] | --unskip n[,n...] | --clear');
17915
- }
17916
- for (const op of ops) {
17917
- if (op.draft) {
17918
- op.question = finalizeDraft(op.draft);
17919
- delete op.draft;
17920
- }
17921
- }
17922
- return ops;
17923
- }
17924
- function parseQuestionPositions(raw, count3, flagName) {
17925
- const ns = String(raw).split(",").map((s) => s.trim()).filter((s) => s.length > 0).map(Number);
17926
- if (ns.length === 0 || ns.some((n) => !Number.isInteger(n) || n < 1)) {
17927
- die(`--${flagName} needs one or more 1-based question numbers (e.g. 1 or 1,3)`);
17928
- }
17929
- const over = ns.find((n) => n > count3);
17930
- if (over !== void 0) die(`the card has ${count3} open question(s) \u2014 there's no question ${over}`);
17931
- return ns;
17932
- }
17933
- var init_questions = __esm({
17934
- "../cli/src/lib/questions.ts"() {
17935
- "use strict";
17936
- init_paths();
17937
- init_question_block();
17938
- init_question_block();
17939
- init_rules();
17940
- }
17941
- });
17942
-
17943
18100
  // ../cli/src/lib/source.ts
17944
18101
  function parseSourceRef(raw) {
17945
18102
  const text4 = raw.trim();
@@ -18544,7 +18701,7 @@ function bodyReferences(body) {
18544
18701
  for (const m of text4.replace(tag, "").matchAll(/\]\(\s*<?([^\s)>]+)>?(?:\s+["'][^]*?["'])?\s*\)/g)) out.push({ src: m[1], types: [] });
18545
18702
  return out;
18546
18703
  }
18547
- function kindOf(ext) {
18704
+ function kindOf2(ext) {
18548
18705
  if (ext === ".tsx" || ext === ".html") return "html";
18549
18706
  if (ext === ".md" || ext === ".mdx") return "markdown";
18550
18707
  if (ext === ".tmx" || ext === ".tmj" || ext === ".tsj") return "tiled";
@@ -18684,7 +18841,7 @@ var init_collect = __esm({
18684
18841
  textKind = (ext, types) => types.find((t) => {
18685
18842
  const m = manifestOf(t);
18686
18843
  return m && !m.schema;
18687
- }) ?? kindOf(ext);
18844
+ }) ?? kindOf2(ext);
18688
18845
  kindAt = (src, types) => extOf(src) === ".json" ? types.includes("asset") ? "asset" : types[0] ?? "asset" : textKind(extOf(src), types);
18689
18846
  }
18690
18847
  });
@@ -19444,7 +19601,7 @@ function cmdUpdate(id, flags) {
19444
19601
  meta.phase = n;
19445
19602
  changes.push("phase");
19446
19603
  }
19447
- if (openOf(meta.questions).length > 0 && meta.status === "ready") {
19604
+ if (meta.questions.length > 0 && meta.status === "ready") {
19448
19605
  meta.status = "todo";
19449
19606
  changes.push("status\u2192todo (open questions)");
19450
19607
  }
@@ -19482,92 +19639,32 @@ function cmdUpdateQuestions(id, input) {
19482
19639
  const file = found2.kind === "group" ? path62.join(found2.target, "root.md") : found2.target;
19483
19640
  const { meta, body } = parseFrontmatter(fs59.readFileSync(file, "utf8"));
19484
19641
  if (!meta) die(`${rel(file)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
19485
- if (insideRun() && ops.some((op) => op.kind === "skip" || op.kind === "unskip")) {
19486
- die("only the user skips or reopens a question \u2014 a run leaves questions for them to answer");
19487
- }
19488
- const changes = [];
19489
- let skipped = 0;
19490
- let unskipped = 0;
19491
- const asker = specRunAgent();
19492
- const closed2 = [];
19493
- const verifying = !!activeDelivery(id);
19494
- const close = (qs) => {
19495
- for (const q of qs) {
19496
- closed2.push(verifying ? "questions_closed_verify" : "questions_closed_user");
19497
- }
19498
- };
19499
- const positions = (op, flag) => {
19500
- const ns = parseQuestionPositions(op.ns ?? String(op.n), meta.questions.length, flag);
19501
- const held4 = ns.find((n) => meta.questions[n - 1].skipped);
19502
- if (held4 !== void 0 && flag !== "unskip" && flag !== "skip") {
19503
- die(`question ${held4} on #${id} was skipped by the user \u2014 \`update-questions ${id} --unskip ${held4}\` reopens it first`);
19504
- }
19505
- return ns;
19506
- };
19507
19642
  for (const op of ops) {
19508
- if (op.question?.agent) {
19509
- const agent = findSpecAgent(op.question.agent);
19510
- if (!agent) die(`--agent "${op.question.agent}" is not an agent on this board`, { kind: "no-such-spec-agent", specAgent: op.question.agent });
19511
- op.question.agent = agent.name;
19512
- }
19513
- if (op.kind === "clear") {
19514
- close(meta.questions.filter((q) => !q.skipped));
19515
- meta.questions = meta.questions.filter((q) => q.skipped);
19516
- changes.push("cleared");
19517
- } else if (op.kind === "drop") {
19518
- const ns = positions(op, "drop");
19519
- close(ns.map((n) => meta.questions[n - 1]));
19520
- meta.questions = meta.questions.filter((_, i) => !ns.includes(i + 1));
19521
- changes.push(`dropped ${ns.join(",")}`);
19522
- } else if (op.kind === "skip") {
19523
- const ns = positions(op, "skip");
19524
- close(ns.map((n) => meta.questions[n - 1]).filter((q) => !q.skipped));
19525
- for (const n of ns) meta.questions[n - 1] = { ...meta.questions[n - 1], skipped: true };
19526
- skipped += ns.length;
19527
- changes.push(`skipped ${ns.join(",")}`);
19528
- } else if (op.kind === "unskip") {
19529
- const ns = positions(op, "unskip");
19530
- const open4 = ns.find((n) => !meta.questions[n - 1].skipped);
19531
- if (open4 !== void 0) die(`question ${open4} on #${id} is not skipped`);
19532
- for (const n of ns) {
19533
- const { skipped: _, ...q } = meta.questions[n - 1];
19534
- meta.questions[n - 1] = q;
19535
- }
19536
- unskipped += ns.length;
19537
- changes.push(`reopened ${ns.join(",")}`);
19538
- } else if (op.kind === "append") {
19539
- const agent = op.question.agent ?? asker;
19540
- const q = agent ? { ...op.question, agent } : op.question;
19541
- meta.questions.push(q);
19542
- changes.push("appended");
19543
- } else {
19544
- const [n] = positions(op, "update");
19545
- const was = meta.questions[n - 1];
19546
- const agent = op.question.agent ?? was.agent;
19547
- meta.questions[n - 1] = { ...op.question, ...agent ? { agent } : {} };
19548
- changes.push(`rewrote ${n}`);
19549
- }
19643
+ if (!op.question?.agent) continue;
19644
+ const agent = findSpecAgent(op.question.agent);
19645
+ if (!agent) die(`--agent "${op.question.agent}" is not an agent on this board`, { kind: "no-such-spec-agent", specAgent: op.question.agent });
19646
+ op.question.agent = agent.name;
19647
+ }
19648
+ let done2;
19649
+ try {
19650
+ done2 = applyQuestionOps(meta.questions, ops, specRunAgent());
19651
+ } catch (e) {
19652
+ if (e instanceof QuestionOpError) die(`#${id}: ${e.message}`);
19653
+ throw e;
19550
19654
  }
19551
- const open3 = openOf(meta.questions).length;
19655
+ const { changes } = done2;
19656
+ meta.questions = done2.questions;
19657
+ const open3 = meta.questions.length;
19552
19658
  if (open3 > 0 && meta.status === "ready") {
19553
19659
  meta.status = "todo";
19554
19660
  changes.push("status\u2192todo (open questions)");
19555
19661
  }
19556
19662
  fs59.writeFileSync(file, serializeFrontmatter(meta) + "\n" + body);
19557
- for (const kind of closed2) countBoardEvent(kind);
19558
- settleDelivery2(id, skipped, unskipped);
19559
- say(
19560
- `updated #${id} questions: ${changes.join(", ")} (${open3} open` + (meta.questions.length > open3 ? `, ${meta.questions.length - open3} skipped` : "") + ")"
19561
- );
19663
+ const closed2 = activeDelivery(id) ? "questions_closed_verify" : "questions_closed_user";
19664
+ for (const _ of done2.closed) countBoardEvent(closed2);
19665
+ say(`updated #${id} questions: ${changes.join(", ")} (${open3} open)`);
19562
19666
  return { id, changes, open: open3, file: rel(file) };
19563
19667
  }
19564
- function settleDelivery2(id, skipped, unskipped) {
19565
- if (!skipped && !unskipped) return;
19566
- const delivery = activeDelivery(id);
19567
- if (!delivery) return;
19568
- if (unskipped) takeUnchanged(delivery);
19569
- else recordAnswer(delivery.deliveryId, "unchanged", `the user skipped ${skipped === 1 ? "a question" : `${skipped} questions`}, keeping the card as it is`);
19570
- }
19571
19668
  function specRunAgent() {
19572
19669
  const id = insideRun();
19573
19670
  if (!id) return void 0;
@@ -19585,6 +19682,7 @@ var init_card = __esm({
19585
19682
  init_workflows();
19586
19683
  init_inbox();
19587
19684
  init_questions();
19685
+ init_question_ops();
19588
19686
  init_frontmatter();
19589
19687
  init_cards();
19590
19688
  init_source();
@@ -19594,7 +19692,6 @@ var init_card = __esm({
19594
19692
  init_env();
19595
19693
  init_tasks();
19596
19694
  init_deliveries();
19597
- init_answers();
19598
19695
  init_agents();
19599
19696
  init_rules();
19600
19697
  init_readme();
@@ -20080,7 +20177,7 @@ function agentName(card, text4) {
20080
20177
  throw new Error(`the agent names \`${slug2}\` and \`${slug2}-${card.id}\` are both taken`);
20081
20178
  }
20082
20179
  function questionsToTriage(meta, agent) {
20083
- for (const q of openOf(meta.questions)) {
20180
+ for (const q of meta.questions) {
20084
20181
  const options = hasOptions(q) ? `
20085
20182
 
20086
20183
  ${q.options.map((o) => `- ${o}`).join("\n")}` : "";
@@ -20464,7 +20561,7 @@ function heldBy(card) {
20464
20561
  if (card.blockers.length) {
20465
20562
  holds.push({ kind: "blocked", text: `blocked by ${card.blockers.map((n) => `#${n}`).join(", ")}` });
20466
20563
  }
20467
- if (openOf(card.questions).length) {
20564
+ if (card.questions.length) {
20468
20565
  holds.push({ kind: "user", text: "waiting on you" });
20469
20566
  }
20470
20567
  if (card.status === "implementing") holds.push({ kind: "building", text: "being built" });
@@ -20473,7 +20570,6 @@ function heldBy(card) {
20473
20570
  var init_card_holds = __esm({
20474
20571
  "../cli/src/lib/card-holds.ts"() {
20475
20572
  "use strict";
20476
- init_rules();
20477
20573
  }
20478
20574
  });
20479
20575
 
@@ -20628,7 +20724,7 @@ function cmdList(opts) {
20628
20724
  const meta = [r.status, `priority ${r.priority}`];
20629
20725
  if (r.isRoot) meta.push("group root");
20630
20726
  if (r.blocked_by.length) meta.push(`blocked by ${r.blocked_by.map((n) => `#${n}`).join(", ")}`);
20631
- const open3 = openOf(r.questions).length;
20727
+ const open3 = r.questions.length;
20632
20728
  if (open3) meta.push(plural(open3, "open question"));
20633
20729
  say("");
20634
20730
  say(`#${r.id} ${r.title} (${rel(r.file)})`);
@@ -20652,7 +20748,6 @@ var init_list = __esm({
20652
20748
  init_scheduled();
20653
20749
  init_card_age();
20654
20750
  init_card_holds();
20655
- init_rules();
20656
20751
  plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
20657
20752
  level = (value) => value || "med";
20658
20753
  holdsOn = (row, open3) => heldBy({ blockers: row.blocked_by.filter((id) => open3.has(id)), questions: row.questions, status: row.status });
@@ -20888,7 +20983,7 @@ function attachDelivery(card) {
20888
20983
  card.delivery = {
20889
20984
  id: live.deliveryId,
20890
20985
  startedAt: live.startedAt,
20891
- state: deliveryState(live, openOf(card.questions).length),
20986
+ state: deliveryState(live, card.questions.length),
20892
20987
  commitMode: live.commitMode === "auto" || live.commitMode === "files" ? live.commitMode : "manual",
20893
20988
  supersedes: supersededBy(card.id, live),
20894
20989
  sessionId: session?.sessionId,
@@ -20962,7 +21057,6 @@ var init_read = __esm({
20962
21057
  "use strict";
20963
21058
  init_deliveries();
20964
21059
  init_pause();
20965
- init_rules();
20966
21060
  init_sessions();
20967
21061
  init_store();
20968
21062
  init_card_sources();
@@ -21954,7 +22048,7 @@ function buildBoardProgram(cli) {
21954
22048
  const opInOrder = ordered(questionOps);
21955
22049
  move("update-questions").argument("<id>", ID, cardId).summary("patch a card's open questions: append, rewrite, drop, skip, or clear").description(
21956
22050
  "Patch the open-question list in place. Ops apply in the order they were typed, and a position is read against the list as it stands when its op runs. Positions are 1-based. A question handed to the user always carries choices to tick \u2014 follow `akb guide update-questions`. --option, --recommended-option, --mode and --agent attach to the --append or --update before them."
21957
- ).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("--skip <positions>", "mark questions skipped: kept as a record, no longer open", opInOrder("skip")).option("--unskip <positions>", "reopen skipped questions", opInOrder("unskip")).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) {
22051
+ ).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) {
21958
22052
  await dispatch("update-questions", this, [String(id)], { ops: questionOps }, cli);
21959
22053
  });
21960
22054
  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) {
@@ -22252,8 +22346,10 @@ function cmdAgent(args) {
22252
22346
  return useAgent(rest);
22253
22347
  case "set":
22254
22348
  return setSetting(rest);
22349
+ case "picks":
22350
+ return setPicks(rest);
22255
22351
  default:
22256
- die(`unknown agent command "${word}" \u2014 try \`akb raw agent\`, or one of use, set`, {
22352
+ die(`unknown agent command "${word}" \u2014 try \`akb raw agent\`, or one of use, set, picks`, {
22257
22353
  kind: "unknown-move",
22258
22354
  move: word
22259
22355
  });
@@ -22325,6 +22421,27 @@ function useAgent(args) {
22325
22421
  say(`Global default runs ${harness.label} \u2014 every agent that named no runtime runs it.`);
22326
22422
  return showAgent();
22327
22423
  }
22424
+ function setPicks(args) {
22425
+ let given;
22426
+ try {
22427
+ given = JSON.parse(args[0] ?? "");
22428
+ } catch {
22429
+ die("give the picks as one JSON argument", { kind: "needs-input" });
22430
+ }
22431
+ const picks = {};
22432
+ for (const [agent, { secrets, ...row }] of Object.entries(given)) {
22433
+ if (!row.id || !harnessByName(row.harness)) die(`"${agent}" names no runtime this version runs`, { kind: "bad-value" });
22434
+ picks[agent] = { ...row, name: row.name || row.id, settings: row.settings ?? {} };
22435
+ for (const setting of harnessByName(row.harness).settings) {
22436
+ if (setting.kind !== "secret" || !setting.env) continue;
22437
+ const res2 = setSecret(secretVar(setting.env, row.id), secrets?.[setting.key] ?? "");
22438
+ if (!res2.ok) die(res2.error ?? "the key could not be saved", { kind: "save-failed" });
22439
+ }
22440
+ }
22441
+ const res = replaceAgentRuntimes(picks);
22442
+ if (!res.ok) die(res.error ?? "the picks could not be saved", { kind: "save-failed" });
22443
+ return { picks: Object.fromEntries(Object.entries(picks).map(([agent, r]) => [agent, r.id])) };
22444
+ }
22328
22445
  function namedRuntime(args) {
22329
22446
  const at = args.indexOf("--runtime");
22330
22447
  if (at < 0) return { rest: args };
@@ -22412,6 +22529,7 @@ var init_agent = __esm({
22412
22529
  init_resolve();
22413
22530
  init_roles();
22414
22531
  init_runtimes();
22532
+ init_settings();
22415
22533
  init_harnesses();
22416
22534
  init_io();
22417
22535
  init_paths();
@@ -22818,7 +22936,7 @@ var init_board3 = __esm({
22818
22936
  var card_chat_default;
22819
22937
  var init_card_chat = __esm({
22820
22938
  "../cli/src/guide/card-chat.md"() {
22821
- 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 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, use `akb raw 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";
22939
+ 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, use `akb raw previews <agent> <id> --print`; never write embed tags by hand.\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- **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';
22822
22940
  }
22823
22941
  });
22824
22942
 
@@ -22826,7 +22944,7 @@ var init_card_chat = __esm({
22826
22944
  var update_workflow_default;
22827
22945
  var init_update_workflow = __esm({
22828
22946
  "../cli/src/guide/update-workflow.md"() {
22829
- 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**: usually one preview agent shows the first draft; add another only when a part needs precision and a mistake there is costly, such as a developer tool's screens. Each shows only what the person decides on, without overlapping another. With none, the card the `WORKFLOW.md` body writes is the only review.\n- **Unreviewable previews**: when the user finds a preview unneeded or cannot judge it, remove it; a land agent checks that part instead, or nobody does.\n- **Stages**: one stage by default. Add `after` only when a draft is too costly to make before another is approved, such as a video's storyboard, which waits for its script.\n- **Minimal**: when the user outlines the workflow, keep it that simple or simpler; add no review point or constraint they did not ask for, and let the trial show what else needs review.\n- **Judgment**: leave to an agent what it can judge; never add a hard rule for one case, and keep a rule only once real runs show it holds widely.\n- **Memory**: give an agent memory only where it has wide latitude and tends to err or be corrected to taste, naming those error-prone points as what it records; give a narrow agent none.\n- **Land**: everything else runs unattended after the last approval and follows the approved 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**: only the workspace's own workflows take a new version; ask the user to\n copy a built-in or marketplace one on the web first.\n\n## Change it\n\n- **Standing preference**: when the user only wants a lasting rule for a workflow or one of its\n agents and the flow itself stays, set it with `akb workflow rule <workflow>` or\n `akb workflow instructions <agent>` instead of pushing; it reaches every task's later runs and\n works on built-in workflows too. Either replaces all of them, so run it bare first to read the\n current ones, and keep each unless the user asks to change or drop it.\n- **Direct or task**: push directly a change the user spelled out; start a 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";
22947
+ 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**: usually one preview agent shows the first draft; add another only when a part needs precision and a mistake there is costly, such as a developer tool's screens. Each shows only what the person decides on, without overlapping another. With none, the card the `WORKFLOW.md` body writes is the only review.\n- **Unreviewable previews**: when the user finds a preview unneeded or cannot judge it, remove it; a land agent checks that part instead, or nobody does.\n- **Stages**: one stage by default. Add `after` only when a draft is too costly to make before another is approved, such as a video's storyboard, which waits for its script.\n- **Minimal**: when the user outlines the workflow, keep it that simple or simpler; add no review point or constraint they did not ask for, and let the trial show what else needs review.\n- **Judgment**: leave to an agent what it can judge; never add a hard rule for one case, and keep a rule only once real runs show it holds widely.\n- **Memory**: give an agent memory only where it has wide latitude and tends to err or be corrected to taste, naming those error-prone points as what it records; give a narrow agent none.\n- **Land**: everything else runs unattended after the last approval and follows the approved 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**: only the workspace's own workflows take a new version; ask the user to\n copy a built-in or marketplace one on the web first.\n\n## Change it\n\n- **Standing preference**: when the user only wants a lasting rule for a workflow or one of its\n agents and the flow itself stays, set it with `akb workflow rule <workflow>` or\n `akb workflow instructions <agent>` instead of pushing; it reaches every task's later runs and\n works on built-in workflows too. Either replaces all of them, so run it bare first to read the\n current ones, and keep each unless the user asks to change or drop it.\n- **Direct or task**: push directly a change the user spelled out; start a 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 raw workflow validate <folder>` reports, then\n `akb workflow push <folder>`.\n- **Moved on**: when push says Cloud has a newer version, pull again and redo the change.\n";
22830
22948
  }
22831
22949
  });
22832
22950
 
@@ -22842,7 +22960,7 @@ var init_describe_project = __esm({
22842
22960
  var discuss_goal_default;
22843
22961
  var init_discuss_goal = __esm({
22844
22962
  "../cli/src/guide/discuss-goal.md"() {
22845
- discuss_goal_default = "# Discuss a goal\n\nThis flow only helps the user settle goals; refining, previewing, and running them come later.\n\n- **Remote user**: the user works remotely and sees only tasks and their previews, never local files.\n- **Software failures**: read `akb guide troubleshoot` when root cause analysis is needed.\n\n## Goals\n\n- **Missing information**: ask the user for information needed to form a goal.\n- **Save**: once a goal is clear, save or update it with `akb goal` (see `akb goal --help`), then stop; an existing build continues in its current session.\n- **Goal format**: each goal has a title, an outcome of at most 150 words, and a `## Done when` list of verifiable acceptance criteria, without technical design.\n- **Independent deliverables**: save separate deliverables as separate goals; remove a replaced goal with `akb goal drop --id <goal>`.\n- **Workflow**: pick the workflow from `akb workflow list` that fits the actual work; prefer the user\u2019s choice.\n- **Review points**: save through `--previews` the agents from `akb raw previews --triggers --workflow <id>` whose conditions the goal meets, always including those marked `Always`, or an empty list.\n- **Use judgment**: settle outcome decisions you can and explain them; ask only for decisions the user must make that change the result, with a recommendation.\n- **Plain words**: answer directly using everyday words.\n- **Hide machinery**: omit plans, files, paths, commands, tools, and connectors from replies; refer to actions by their button labels.\n";
22963
+ discuss_goal_default = '# Discuss a goal\n\nThis flow only helps the user settle goals; refining, previewing, and running them come later.\n\n- **Remote user**: the user works remotely and sees only tasks and their previews, never local files.\n- **Software failures**: read `akb guide troubleshoot` when root cause analysis is needed.\n\n## Goals\n\n- **Missing information**: ask the user for information needed to form a goal.\n- **Save**: once a goal is clear, save or update it with `akb goal` (see `akb goal --help`), then stop; an existing build continues in its current session.\n- **Goal format**: each goal has a title, an outcome of at most 150 words, and a `## Done when` list of verifiable acceptance criteria, without technical design.\n- **Independent deliverables**: save separate deliverables as separate goals; remove a replaced goal with `akb goal drop --id <goal>`.\n- **Workflow**: pick the workflow from `akb workflow list` that fits the actual work; prefer the user\u2019s choice.\n- **Review points**: save through `--previews` the agents from `akb raw previews --triggers --workflow <id>` whose conditions the goal meets, always including those marked `Always`, or an empty list.\n- **Use judgment**: settle outcome decisions you can and explain them; ask only for decisions the user must make that change the result, with a recommendation.\n- **Plain words**: answer directly using everyday words.\n- **Hide machinery**: omit plans, files, paths, commands, tools, and connectors from replies; refer to actions by their button labels.\n- **Starting a goal**: "Start now" (\u7ACB\u5373\u5F00\u59CB) begins the work directly; "Refine goal" (\u7EC6\u5316\u76EE\u6807) appears only when the goal has review points, and shows their previews for approval first.\n- **Anything else**: for a request this guide does not cover, read `akb help` once, then the matching command\'s `--help`.\n';
22846
22964
  }
22847
22965
  });
22848
22966
 
@@ -22938,7 +23056,7 @@ var init_preview_agent = __esm({
22938
23056
  var update_questions_default;
22939
23057
  var init_update_questions = __esm({
22940
23058
  "../cli/src/guide/update-questions.md"() {
22941
- update_questions_default = '# Decide what to ask the user\n\nA decision is a choice the work needs made. A question is a decision handed to the user:\nproject evidence cannot settle it, it materially affects what the user gets, and it has at\nleast two coherent options.\n\n### The material-decision test\n\nAsk when the tradeoff materially changes the delivered result, the accepted scope, the user\'s\nrisk, or a meaningful ongoing cost, and a reasonable reviewer may reject it; a workflow\'s rules\nadd what else counts. Settle everything else yourself. Leave the question open and stop only\nthe work that depends on it. An obstacle only the user can clear is a question too: say what\ncannot proceed and offer ways forward.\n\n- **Write for users**: each option\'s outcome and main cost, your recommendation ticked; no\n card ids, agent names, or board jargon.\n- **Options**: exclusive unless they genuinely combine (`--mode multi`); never write an\n "other" option, the user always gets one.\n- **Not a question**: where a fix goes (`akb guide follow-up`), and one marked\n `skipped: true` \u2014 the user declined to answer it, which grants nothing.\n\n```text\nakb raw update-questions <id> \\\n --append "Which behavior should apply?" \\\n --recommended-option "A \u2014 outcome and cost" \\\n --option "B \u2014 outcome and cost"\n```\n';
23059
+ update_questions_default = '# Decide what to ask the user\n\nA decision is a choice the work needs made. A question is a decision handed to the user:\nproject evidence cannot settle it, it materially affects what the user gets, and it has at\nleast two coherent options.\n\n### The material-decision test\n\nAsk when the tradeoff materially changes the delivered result, the accepted scope, the user\'s\nrisk, or a meaningful ongoing cost, and a reasonable reviewer may reject it; a workflow\'s rules\nadd what else counts. Settle everything else yourself. Leave the question open and stop only\nthe work that depends on it. An obstacle only the user can clear is a question too: say what\ncannot proceed and offer ways forward.\n\n- **Write for users**: each option\'s outcome and main cost, your recommendation ticked; no\n card ids, agent names, or board jargon.\n- **Options**: exclusive unless they genuinely combine (`--mode multi`); never write an\n "other" option, the user always gets one.\n- **Not a question**: where a fix goes (`akb guide follow-up`).\n\n```text\nakb raw update-questions <id> \\\n --append "Which behavior should apply?" \\\n --recommended-option "A \u2014 outcome and cost" \\\n --option "B \u2014 outcome and cost"\n```\n';
22942
23060
  }
22943
23061
  });
22944
23062
 
@@ -23127,6 +23245,26 @@ function cmdWorkflowDiagram(id, card) {
23127
23245
  say(tag);
23128
23246
  return { file, tag, diagram };
23129
23247
  }
23248
+ function cmdWorkflowValidate(folder) {
23249
+ const dir = path76.resolve(folder);
23250
+ if (!fs75.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder} is not a folder`, "bad-args");
23251
+ const files = readWorkflowFolder(dir);
23252
+ const read3 = parseWorkflowFile("workflow", files[WORKFLOW_FILE] ?? "", WORKFLOW_FILE);
23253
+ const def = "def" in read3 ? read3.def : null;
23254
+ const named2 = def ? new Set([...def.previews, ...def.land, ...def.scheduled].map((h) => h.agent)) : [];
23255
+ for (const name of named2) {
23256
+ if (Object.keys(files).some((f) => f.startsWith(`agents/${name}/`))) continue;
23257
+ const agent = findSpecAgent(name);
23258
+ for (const file of agent ? ["AGENT.md", ...agent.files] : []) {
23259
+ const text4 = agent.file(file);
23260
+ if (text4 !== null) files[`agents/${name}/${file}`] = text4;
23261
+ }
23262
+ }
23263
+ const problems = workflowFilesProblems(files).map((p) => `${p.file} ${p.reason}`);
23264
+ if (problems.length) die(problems.map((p) => `! ${p}`).join("\n"), { kind: "workflow-problems", bare: true, problems });
23265
+ say(`${folder}: no problems`);
23266
+ return { folder: dir, problems };
23267
+ }
23130
23268
  async function cmdWorkflowPull(id, folder) {
23131
23269
  const cloudId = cloudIdOf(id);
23132
23270
  if (!cloudId) found(id);
@@ -23157,8 +23295,10 @@ async function cmdWorkflowPush(folder, opts) {
23157
23295
  const id = workflowName(cloudId);
23158
23296
  const readOnly2 = () => die(`${id} is not this workspace's own; copy it on the web first.`, "workflow-read-only");
23159
23297
  if (cloudId.startsWith("wf_builtin_")) readOnly2();
23160
- const checked = checkWorkflowFiles(readWorkflowFolder(dir));
23161
- if (!checked.ok) die(`${checked.file} ${checked.reason}`, "bad-workflow");
23298
+ const read3 = readWorkflowFolder(dir);
23299
+ const problems = workflowFilesProblems(read3).map((p) => `${p.file} ${p.reason}`);
23300
+ if (problems.length) die(problems.map((p) => `! ${p}`).join("\n"), { kind: "bad-workflow", bare: true, problems });
23301
+ const checked = checkWorkflowFiles(read3);
23162
23302
  const { files } = checked;
23163
23303
  const now = await call("GET", `/v1/workflows/${encodeURIComponent(cloudId)}`);
23164
23304
  if (!now.ok) die(now.error, now.code === "not_found" ? "no-such-workflow" : "cloud-refused");
@@ -23263,6 +23403,7 @@ var init_workflow2 = __esm({
23263
23403
  init_workflows();
23264
23404
  init_workflow_folder();
23265
23405
  init_workflow_files();
23406
+ init_workflow_def();
23266
23407
  init_board_files();
23267
23408
  init_tasks();
23268
23409
  found = (id) => {
@@ -23415,7 +23556,7 @@ function approvalRequest(req) {
23415
23556
  const id = req.id;
23416
23557
  const card = id === void 0 ? null : findCard(id);
23417
23558
  if (!card) return { error: `task #${id} does not exist` };
23418
- if (openOf(card.questions).length) return { error: `#${card.id} has open questions \u2014 answer them before approving it.` };
23559
+ if (card.questions.length) return { error: `#${card.id} has open questions \u2014 answer them before approving it.` };
23419
23560
  if (readRuns().some((r) => r.status === "running" && r.cardId === card.id && holdsCard(r.action))) {
23420
23561
  return { error: `#${card.id} has a run in flight \u2014 approve once it ends.` };
23421
23562
  }
@@ -23901,12 +24042,11 @@ function notesField(card) {
23901
24042
  );
23902
24043
  }
23903
24044
  function questionsField(meta) {
23904
- const open3 = openOf(meta.questions).length;
23905
24045
  if (!meta.questions.length) return field("questions", "none open");
23906
24046
  const lines = meta.questions.map(
23907
- (q, i) => `${i + 1}. ${q.skipped ? "(skipped by the user \u2014 leave it) " : ""}${q.text}${q.options?.length ? ` (${q.options.length} options)` : ""}`
24047
+ (q, i) => `${i + 1}. ${q.text}${q.options?.length ? ` (${q.options.length} options)` : ""}`
23908
24048
  );
23909
- return field("questions", [`${open3} open:`, ...lines.map((s) => ` ${s}`)]);
24049
+ return field("questions", [`${meta.questions.length} open:`, ...lines.map((s) => ` ${s}`)]);
23910
24050
  }
23911
24051
  function stageField(meta) {
23912
24052
  const flow = workflowFor(meta.workflow);
@@ -23967,7 +24107,7 @@ function buildFlow(req, program2) {
23967
24107
  `write the shipped line in the memory file above \u2014 \`akb guide archive\``,
23968
24108
  delivery ? `${self} raw delivery complete ${delivery.deliveryId} \u2014 finish your step and follow its handoff; software steps in a git project supply --commit <full-sha> --branch <target>` : `${raw} archive ${req.id} \u2014 once every box is ticked and the card's goal is met`
23969
24109
  );
23970
- if (openOf(card.meta.questions).length) {
24110
+ if (card.meta.questions.length) {
23971
24111
  next.push(
23972
24112
  `${self} raw card resolve ${req.id} --print \u2014 first: the card has open questions, and building on a guess is what they are there to stop`
23973
24113
  );
@@ -24197,7 +24337,6 @@ var init_flow = __esm({
24197
24337
  init_dismissal_review();
24198
24338
  init_prompts();
24199
24339
  init_rules2();
24200
- init_rules();
24201
24340
  init_workflows();
24202
24341
  init_types();
24203
24342
  init_env();
@@ -24313,7 +24452,7 @@ function refinementRequest(req) {
24313
24452
  if (!card) return { error: `task #${req.id} does not exist` };
24314
24453
  const step = refinementStep(card);
24315
24454
  if (step === "done") {
24316
- const waiting = openOf(card.questions).length > 0 && canRefine({ ...card, questions: [] });
24455
+ const waiting = card.questions.length > 0 && canRefine({ ...card, questions: [] });
24317
24456
  return {
24318
24457
  error: waiting ? `#${card.id} is waiting for the user to answer its open questions, so there is nothing to refine yet \u2014 the board refines it on its own once they are answered.` : `a refine would not move #${card.id}`
24319
24458
  };
@@ -24327,7 +24466,7 @@ async function startRefinement(req) {
24327
24466
  function refinementAfter(action, cardId2, flowId) {
24328
24467
  const card = currentCard(cardId2);
24329
24468
  if (!card || card.openBlockers.length > 0) return null;
24330
- if (openOf(card.questions).length > 0 || action === "clarify" || card.deliversIn !== "plan") return null;
24469
+ if (card.questions.length > 0 || action === "clarify" || card.deliversIn !== "plan") return null;
24331
24470
  if (planDeliveryGap(card) === null) return null;
24332
24471
  if (awaitingApproval(card)) return null;
24333
24472
  return { action: "clarify", id: card.id, title: card.title, refineRound: 1, ...flowId ? { flowId } : {} };
@@ -24354,7 +24493,7 @@ function stalledLine(cardId2, next) {
24354
24493
  function planStageEnd(run2) {
24355
24494
  if (run2.cardId === null || stageOfAction(run2.action) !== "plan") return null;
24356
24495
  const card = currentCard(run2.cardId);
24357
- if (!card || card.openBlockers.length > 0 || openOf(card.questions).length > 0) return null;
24496
+ if (!card || card.openBlockers.length > 0 || card.questions.length > 0) return null;
24358
24497
  if (refinementStep(card) !== "done") return null;
24359
24498
  return endOfStage(stageContract("plan"), card);
24360
24499
  }
@@ -24838,7 +24977,7 @@ async function watchRun(sessionId, resume = startResume) {
24838
24977
  const totals = reportsSessionTotal(record.harness);
24839
24978
  const sessionTotal = totals ? reported : void 0;
24840
24979
  const carriedId = record.continues?.resumeId;
24841
- const totalFrom = !totals ? void 0 : record.resumedFrom ? record.sessionCostFrom : carriedId ? lastSessionTotal(carriedId, readRuns()) : void 0;
24980
+ const totalFrom = !totals ? void 0 : record.resumedFrom ? record.sessionCostFrom : carriedId ? record.sessionCostFrom ?? lastSessionTotal(carriedId, readRuns()) : void 0;
24842
24981
  const totalCost = sessionTotal === void 0 ? reported : ownCost(sessionTotal, totalFrom);
24843
24982
  const usage3 = spoken ? spoken.usage : renderer?.usage?.();
24844
24983
  if (spoken) gotContext(spoken.context);
@@ -25303,7 +25442,7 @@ function sayBeforeStart(req, program2) {
25303
25442
  if (blockers.length) {
25304
25443
  say(`#${req.id} is blocked by ${blockers.map((b) => `#${b.id} ${b.title}`).join(", ")} \u2014 starting anyway.`);
25305
25444
  }
25306
- const asked = openOf(card?.questions ?? []).length;
25445
+ const asked = card?.questions.length ?? 0;
25307
25446
  if (req.action === "implement" && asked) {
25308
25447
  say(
25309
25448
  `#${req.id} has ${asked} open question${asked === 1 ? "" : "s"} \u2014 it is built, then holds at landing until ${asked === 1 ? "it is" : "they are"} answered. Answer first with \`${program2} raw card resolve ${req.id}\`.`
@@ -25335,7 +25474,13 @@ function readRequest(action, args, opts) {
25335
25474
  req.notes = words(1);
25336
25475
  if (action === "implement") req.runtime = opts.runtime;
25337
25476
  if (opts.session || opts.transcript) {
25338
- req.carry = { resumeId: opts.session, fork: opts.session ? opts.fork === true : void 0, transcript: opts.transcript };
25477
+ const costFrom = Number(process.env[SESSION_COST_ENV]);
25478
+ req.carry = {
25479
+ resumeId: opts.session,
25480
+ fork: opts.session ? opts.fork === true : void 0,
25481
+ transcript: opts.transcript,
25482
+ ...opts.session && costFrom > 0 ? { costFrom } : {}
25483
+ };
25339
25484
  }
25340
25485
  return { req, follow: follow2, print };
25341
25486
  }
@@ -25689,6 +25834,7 @@ var init_run = __esm({
25689
25834
  init_deliveries();
25690
25835
  init_pause();
25691
25836
  init_flow();
25837
+ init_env();
25692
25838
  init_memory_review();
25693
25839
  init_log();
25694
25840
  init_approve();
@@ -26091,7 +26237,10 @@ List trigger conditions: ${raw} previews --triggers --json`).action(async functi
26091
26237
  useBoard(resolveBoard("components", { board: ctx.board, dir: ctx.dir, cwd: cli.cwd, installHint: cli.installHint }), ctx.dir !== null);
26092
26238
  await boardless(this, cli, () => cmdComponents(this.opts()));
26093
26239
  });
26094
- const workflow = noun("workflow", "rename a workflow draft, or draw a workflow's diagram, inside a run");
26240
+ const workflow = noun("workflow", "check a workflow folder, or rename a draft or draw a diagram inside a run");
26241
+ withShared(workflow.command("validate")).argument("<folder>", "a workflow folder: WORKFLOW.md and agents/").summary("report every problem in a workflow folder; agents it names but lacks are read from the board").action(async function(folder) {
26242
+ await onBoard2(this, cli, () => cmdWorkflowValidate(folder));
26243
+ });
26095
26244
  withShared(workflow.command("rename")).argument("<id>", "the draft, from `workflow list`").argument("<name...>", "what to call it now").summary("rename the Workflow builder draft. Only inside that task's run.").action(async function(id, name) {
26096
26245
  await onBoard2(this, cli, () => cmdWorkflowRename(id, name.join(" ")));
26097
26246
  });
@@ -26101,7 +26250,7 @@ List trigger conditions: ${raw} previews --triggers --json`).action(async functi
26101
26250
  }
26102
26251
  function declareRuns(program2, cli) {
26103
26252
  const ON_WEB = "Reads and writes WildCrane Cloud as the signed-in account; changes show on the web at once.";
26104
- const task = withShared(program2.command("task")).summary("list, create, approve, change and remove WildCrane tasks").description(`${ON_WEB} <task> is WC-12, task_\u2026, or just 12 in a linked folder.`).action(function() {
26253
+ const task = withShared(program2.command("task")).summary("see where WildCrane tasks stand; list, create, approve, stop, resume and remove them").description(`${ON_WEB} <task> is WC-12, task_\u2026, or just 12 in a linked folder.`).action(function() {
26105
26254
  this.help();
26106
26255
  });
26107
26256
  withShared(task.command("list")).summary("list tasks").option("--project <id>", "the project; default: this folder\u2019s linked one").option("--workspace <id>", "every project of a workspace").option("--status <status>", "queued, running, waiting_review, done, failed, cancelled or stopped").action(async function() {
@@ -26116,6 +26265,11 @@ function declareRuns(program2, cli) {
26116
26265
  withShared(task.command("approve")).argument("<task>").summary("approve the current review point").option("--comment <text>", "a note with the approval").action(async function(id) {
26117
26266
  await boardless(this, cli, () => taskApprove(id, this.opts().comment));
26118
26267
  });
26268
+ const questionOps = [];
26269
+ const opInOrder = ordered(questionOps);
26270
+ withShared(task.command("update-questions")).argument("<task>").summary("edit the task's open questions, like `raw update-questions`").description("Positions are 1-based, in the order of the card\u2019s `questions:` (`akb task show`). --option, --recommended-option, --mode and --agent attach to the --append or --update before them.").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 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) {
26271
+ await boardless(this, cli, () => taskUpdateQuestions(id, questionOps));
26272
+ });
26119
26273
  withShared(task.command("chat")).argument("<task>").argument("<message...>").summary("send a message in the task chat, e.g. to change its requirement or draft").action(async function(id, message) {
26120
26274
  await boardless(this, cli, () => taskChat(id, message.join(" ")));
26121
26275
  });
@@ -26391,6 +26545,9 @@ function declareAgent(program2, cli) {
26391
26545
  ])
26392
26546
  );
26393
26547
  });
26548
+ withShared(agent.command("picks", { hidden: true })).argument("<json>", "runtime picks by workflow agent").action(async function(json) {
26549
+ await onBoard2(this, cli, () => cmdAgent(["picks", json]));
26550
+ });
26394
26551
  word("run").argument("<workflow>", "a workflow id, e.g. coding").argument("<agent>", "one of the agents it schedules").summary("run a workflow's scheduled agent once, now").addOption(new Option("-p, --print", "say what to do and start nothing").conflicts("follow")).option("-f, --follow", "watch the log instead of returning").option("--events", "with --follow: print its structured events, one JSON object per line").action(async function(workflow, name) {
26395
26552
  await onBoard2(this, cli, (p) => cmdRunScheduled(workflow, name, this.opts(), p));
26396
26553
  });