wildcrane-runner 0.6.103 → 0.6.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/akb/dist/kanban.mjs +1026 -644
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/codex-proxy.mjs +1 -1
- package/dist/codex-retained.mjs +1 -1
- package/dist/flow-worker-main.mjs +855 -744
- package/dist/launcher.mjs +84 -53
- package/dist/plugin.mjs +84 -53
- package/dist/runner.mjs +920 -807
- package/dist/settings.mjs +84 -53
- package/package.json +1 -1
package/dist/akb/dist/kanban.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// ai4kanban 0.11.
|
|
2
|
+
// ai4kanban 0.11.84 — 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;
|
|
@@ -139,6 +139,57 @@ var init_io = __esm({
|
|
|
139
139
|
}
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
+
// ../cli/src/lib/cloud/response.ts
|
|
143
|
+
function temporaryCloudFailure({ code, status }) {
|
|
144
|
+
if (code && ["unauthenticated", "machine_offline", "quota_exceeded", "daily_write_budget_reached", "storage_limit_reached"].includes(code)) return false;
|
|
145
|
+
return ["unreachable", "invalid_response", "idempotency_in_progress", "service_unavailable", "artifacts_unavailable"].includes(code ?? "") || status === 408 || (status !== void 0 ? status >= 500 : !code);
|
|
146
|
+
}
|
|
147
|
+
async function readCloudJson(response) {
|
|
148
|
+
return response.json().catch(() => void 0);
|
|
149
|
+
}
|
|
150
|
+
function cloudProblem(response, body) {
|
|
151
|
+
const error62 = isRecord(body) && isRecord(body.error) ? body.error : null;
|
|
152
|
+
if (response.ok && !error62) return null;
|
|
153
|
+
const status = response.status;
|
|
154
|
+
const code = hasText(error62?.code) ? error62.code : status === 401 ? "unauthenticated" : status >= 500 ? "service_unavailable" : "refused";
|
|
155
|
+
const message = hasText(error62?.message) ? error62.message : `Cloud answered ${status}.`;
|
|
156
|
+
return { code, message, status, retryable: temporaryCloudFailure({ code, status }) };
|
|
157
|
+
}
|
|
158
|
+
function cloudError(problem, options = {}) {
|
|
159
|
+
return new BoardError(problem.message, {
|
|
160
|
+
bare: options.bare,
|
|
161
|
+
exitCode: options.exitCode,
|
|
162
|
+
...options.details,
|
|
163
|
+
kind: options.kind ?? problem.code,
|
|
164
|
+
code: problem.code,
|
|
165
|
+
status: problem.status,
|
|
166
|
+
retryable: problem.retryable
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function requireResponse(value, expected, check2) {
|
|
170
|
+
if (!isRecord(value) || !check2(value)) throw cloudError(invalidResponse(expected));
|
|
171
|
+
return value;
|
|
172
|
+
}
|
|
173
|
+
async function cloudBytes(response, expected, options = {}) {
|
|
174
|
+
const bytes2 = await response.arrayBuffer().then((data) => Buffer.from(data), () => null);
|
|
175
|
+
const length = response.headers.get("content-length");
|
|
176
|
+
const compressed = response.headers.has("content-encoding");
|
|
177
|
+
if (response.status !== 200 || response.headers.has("content-range") || !bytes2 || options.size === void 0 && !bytes2.length || length !== null && !compressed && (!/^\d+$/.test(length) || bytes2.length !== Number(length)) || options.size !== void 0 && bytes2.length !== options.size) {
|
|
178
|
+
throw cloudError(invalidResponse(expected));
|
|
179
|
+
}
|
|
180
|
+
return bytes2;
|
|
181
|
+
}
|
|
182
|
+
var isRecord, hasText, invalidResponse;
|
|
183
|
+
var init_response = __esm({
|
|
184
|
+
"../cli/src/lib/cloud/response.ts"() {
|
|
185
|
+
"use strict";
|
|
186
|
+
init_io();
|
|
187
|
+
isRecord = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
188
|
+
hasText = (value) => typeof value === "string" && !!value.trim();
|
|
189
|
+
invalidResponse = (expected) => ({ code: "invalid_response", message: `Cloud did not return ${expected}.`, retryable: true });
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
|
|
142
193
|
// ../cli/src/lib/machine/project.ts
|
|
143
194
|
import fs from "node:fs";
|
|
144
195
|
import path from "node:path";
|
|
@@ -389,12 +440,17 @@ async function approveAfterReply(task, comment, target) {
|
|
|
389
440
|
signal: AbortSignal.timeout(12e4)
|
|
390
441
|
});
|
|
391
442
|
const result = await response.json();
|
|
392
|
-
if (!
|
|
393
|
-
const held4 =
|
|
443
|
+
if (!response.ok || result?.ok === false) throw cloudError({ code: "refused", message: result?.error ?? "The request was not accepted.", retryable: false });
|
|
444
|
+
const held4 = requireResponse(
|
|
445
|
+
result?.value,
|
|
446
|
+
"a reply approval receipt",
|
|
447
|
+
(value) => !!value && hasText(value.id) && hasText(value.task) && ["pending", "committed", "cancelled"].includes(value.status)
|
|
448
|
+
);
|
|
394
449
|
if (held4.status === "cancelled") throw Error(held4.reason ?? "The request was cancelled. Ask again in a new reply.");
|
|
395
450
|
say(held4.status === "pending" ? `Approval pending for ${task}; it will be checked after this reply finishes.` : `Approval already committed for ${task}.`);
|
|
396
451
|
return { ...held4, pending: held4.status === "pending" };
|
|
397
452
|
} catch (e) {
|
|
453
|
+
if (e instanceof BoardError) throw e;
|
|
398
454
|
return die(e instanceof Error ? e.message : "Reply approval failed.", { kind: "refused" });
|
|
399
455
|
}
|
|
400
456
|
}
|
|
@@ -403,6 +459,7 @@ var init_reply_approval = __esm({
|
|
|
403
459
|
"../cli/src/lib/cloud/reply-approval.ts"() {
|
|
404
460
|
"use strict";
|
|
405
461
|
init_io();
|
|
462
|
+
init_response();
|
|
406
463
|
init_paths();
|
|
407
464
|
REPLY_APPROVAL_ENV = "AI4KANBAN_REPLY_APPROVAL";
|
|
408
465
|
}
|
|
@@ -504,9 +561,9 @@ function assertNever(_x) {
|
|
|
504
561
|
}
|
|
505
562
|
function assert(_) {
|
|
506
563
|
}
|
|
507
|
-
function getEnumValues(
|
|
508
|
-
const numericValues = Object.values(
|
|
509
|
-
const values = Object.entries(
|
|
564
|
+
function getEnumValues(entries2) {
|
|
565
|
+
const numericValues = Object.values(entries2).filter((v) => typeof v === "number");
|
|
566
|
+
const values = Object.entries(entries2).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
510
567
|
return values;
|
|
511
568
|
}
|
|
512
569
|
function joinValues(array2, separator = "|") {
|
|
@@ -630,10 +687,10 @@ function mergeDefs(...defs) {
|
|
|
630
687
|
function cloneDef(schema) {
|
|
631
688
|
return mergeDefs(schema._zod.def);
|
|
632
689
|
}
|
|
633
|
-
function getElementAtPath(obj3,
|
|
634
|
-
if (!
|
|
690
|
+
function getElementAtPath(obj3, path88) {
|
|
691
|
+
if (!path88)
|
|
635
692
|
return obj3;
|
|
636
|
-
return
|
|
693
|
+
return path88.reduce((acc, key) => acc?.[key], obj3);
|
|
637
694
|
}
|
|
638
695
|
function promiseAllObject(promisesObj) {
|
|
639
696
|
const keys = Object.keys(promisesObj);
|
|
@@ -892,11 +949,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
892
949
|
}
|
|
893
950
|
return false;
|
|
894
951
|
}
|
|
895
|
-
function prefixIssues(
|
|
952
|
+
function prefixIssues(path88, issues) {
|
|
896
953
|
return issues.map((iss) => {
|
|
897
954
|
var _a3;
|
|
898
955
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
899
|
-
iss.path.unshift(
|
|
956
|
+
iss.path.unshift(path88);
|
|
900
957
|
return iss;
|
|
901
958
|
});
|
|
902
959
|
}
|
|
@@ -1429,16 +1486,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
|
|
|
1429
1486
|
}
|
|
1430
1487
|
function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
1431
1488
|
const fieldErrors = { _errors: [] };
|
|
1432
|
-
const processError = (error63,
|
|
1489
|
+
const processError = (error63, path88 = []) => {
|
|
1433
1490
|
for (const issue2 of error63.issues) {
|
|
1434
1491
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1435
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1492
|
+
issue2.errors.map((issues) => processError({ issues }, [...path88, ...issue2.path]));
|
|
1436
1493
|
} else if (issue2.code === "invalid_key") {
|
|
1437
|
-
processError({ issues: issue2.issues }, [...
|
|
1494
|
+
processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
|
|
1438
1495
|
} else if (issue2.code === "invalid_element") {
|
|
1439
|
-
processError({ issues: issue2.issues }, [...
|
|
1496
|
+
processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
|
|
1440
1497
|
} else {
|
|
1441
|
-
const fullpath = [...
|
|
1498
|
+
const fullpath = [...path88, ...issue2.path];
|
|
1442
1499
|
if (fullpath.length === 0) {
|
|
1443
1500
|
fieldErrors._errors.push(mapper(issue2));
|
|
1444
1501
|
} else {
|
|
@@ -1477,17 +1534,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
|
1477
1534
|
}
|
|
1478
1535
|
function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
1479
1536
|
const result = { errors: [] };
|
|
1480
|
-
const processError = (error63,
|
|
1537
|
+
const processError = (error63, path88 = []) => {
|
|
1481
1538
|
var _a3;
|
|
1482
1539
|
for (const issue2 of error63.issues) {
|
|
1483
1540
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1484
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1541
|
+
issue2.errors.map((issues) => processError({ issues }, [...path88, ...issue2.path]));
|
|
1485
1542
|
} else if (issue2.code === "invalid_key") {
|
|
1486
|
-
processError({ issues: issue2.issues }, [...
|
|
1543
|
+
processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
|
|
1487
1544
|
} else if (issue2.code === "invalid_element") {
|
|
1488
|
-
processError({ issues: issue2.issues }, [...
|
|
1545
|
+
processError({ issues: issue2.issues }, [...path88, ...issue2.path]);
|
|
1489
1546
|
} else {
|
|
1490
|
-
const fullpath = [...
|
|
1547
|
+
const fullpath = [...path88, ...issue2.path];
|
|
1491
1548
|
if (fullpath.length === 0) {
|
|
1492
1549
|
result.errors.push(mapper(issue2));
|
|
1493
1550
|
continue;
|
|
@@ -1526,8 +1583,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
|
1526
1583
|
}
|
|
1527
1584
|
function toDotPath(_path) {
|
|
1528
1585
|
const segs = [];
|
|
1529
|
-
const
|
|
1530
|
-
for (const seg of
|
|
1586
|
+
const path88 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1587
|
+
for (const seg of path88) {
|
|
1531
1588
|
if (typeof seg === "number")
|
|
1532
1589
|
segs.push(`[${seg}]`);
|
|
1533
1590
|
else if (typeof seg === "symbol")
|
|
@@ -2378,16 +2435,16 @@ var init_checks = __esm({
|
|
|
2378
2435
|
hide(inst, Symbol.iterator, function* () {
|
|
2379
2436
|
yield inst;
|
|
2380
2437
|
});
|
|
2381
|
-
let
|
|
2438
|
+
let entries2;
|
|
2382
2439
|
inst._zod.check = (payload) => {
|
|
2383
2440
|
if (payload.value == null) {
|
|
2384
2441
|
payload.issues.push({ expected: "object", code: "invalid_type", input: payload.value, inst });
|
|
2385
2442
|
return void 0;
|
|
2386
2443
|
}
|
|
2387
|
-
|
|
2444
|
+
entries2 ?? (entries2 = Reflect.ownKeys(def.shape).map((key) => [key, def.shape[key]]));
|
|
2388
2445
|
const input2 = payload.value;
|
|
2389
2446
|
let proms;
|
|
2390
|
-
for (const [key, schema] of
|
|
2447
|
+
for (const [key, schema] of entries2) {
|
|
2391
2448
|
const result = schema._zod.run({ value: input2[key], issues: [] }, {});
|
|
2392
2449
|
if (result instanceof Promise) {
|
|
2393
2450
|
proms ?? (proms = []);
|
|
@@ -15686,18 +15743,18 @@ function _set(Class2, valueType, params) {
|
|
|
15686
15743
|
}
|
|
15687
15744
|
// @__NO_SIDE_EFFECTS__
|
|
15688
15745
|
function _enum(Class2, values, params) {
|
|
15689
|
-
const
|
|
15746
|
+
const entries2 = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
15690
15747
|
return new Class2({
|
|
15691
15748
|
type: "enum",
|
|
15692
|
-
entries,
|
|
15749
|
+
entries: entries2,
|
|
15693
15750
|
...normalizeParams(params)
|
|
15694
15751
|
});
|
|
15695
15752
|
}
|
|
15696
15753
|
// @__NO_SIDE_EFFECTS__
|
|
15697
|
-
function _nativeEnum(Class2,
|
|
15754
|
+
function _nativeEnum(Class2, entries2, params) {
|
|
15698
15755
|
return new Class2({
|
|
15699
15756
|
type: "enum",
|
|
15700
|
-
entries,
|
|
15757
|
+
entries: entries2,
|
|
15701
15758
|
...normalizeParams(params)
|
|
15702
15759
|
});
|
|
15703
15760
|
}
|
|
@@ -18284,17 +18341,17 @@ function set(valueType, params) {
|
|
|
18284
18341
|
});
|
|
18285
18342
|
}
|
|
18286
18343
|
function _enum2(values, params) {
|
|
18287
|
-
const
|
|
18344
|
+
const entries2 = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
18288
18345
|
return new ZodEnum({
|
|
18289
18346
|
type: "enum",
|
|
18290
|
-
entries,
|
|
18347
|
+
entries: entries2,
|
|
18291
18348
|
...util_exports.normalizeParams(params)
|
|
18292
18349
|
});
|
|
18293
18350
|
}
|
|
18294
|
-
function nativeEnum(
|
|
18351
|
+
function nativeEnum(entries2, params) {
|
|
18295
18352
|
return new ZodEnum({
|
|
18296
18353
|
type: "enum",
|
|
18297
|
-
entries,
|
|
18354
|
+
entries: entries2,
|
|
18298
18355
|
...util_exports.normalizeParams(params)
|
|
18299
18356
|
});
|
|
18300
18357
|
}
|
|
@@ -19559,13 +19616,13 @@ function resolveRef(ref, ctx) {
|
|
|
19559
19616
|
if (!ref.startsWith("#")) {
|
|
19560
19617
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
19561
19618
|
}
|
|
19562
|
-
const
|
|
19563
|
-
if (
|
|
19619
|
+
const path88 = ref.slice(1).split("/").filter(Boolean);
|
|
19620
|
+
if (path88.length === 0) {
|
|
19564
19621
|
return ctx.rootSchema;
|
|
19565
19622
|
}
|
|
19566
19623
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
19567
|
-
if (
|
|
19568
|
-
const key =
|
|
19624
|
+
if (path88[0] === defsKey) {
|
|
19625
|
+
const key = path88[1] === void 0 ? void 0 : decodeJSONPointerSegment(path88[1]);
|
|
19569
19626
|
if (!key || !ctx.defs[key]) {
|
|
19570
19627
|
throw new Error(`Reference not found: ${ref}`);
|
|
19571
19628
|
}
|
|
@@ -21003,7 +21060,6 @@ function readReviewPlan(plan) {
|
|
|
21003
21060
|
return plan?.map(({ id: id2, after: after2, previews, kind }) => ({ id: id2, after: after2, previews, ...kind && { kind } })) ?? null;
|
|
21004
21061
|
}
|
|
21005
21062
|
function reviewAuthorization(review, assigned, dispatchRevision) {
|
|
21006
|
-
if (review.pending_plan) return { kind: "waiting" };
|
|
21007
21063
|
const states2 = new Map(review.stages.map((stage) => [stage.id, stage]));
|
|
21008
21064
|
const nodes = (review.plan ?? []).filter((node2) => {
|
|
21009
21065
|
const stage = states2.get(node2.id);
|
|
@@ -21125,21 +21181,30 @@ import path4 from "node:path";
|
|
|
21125
21181
|
function readRetry(session) {
|
|
21126
21182
|
try {
|
|
21127
21183
|
const retry2 = JSON.parse(fs3.readFileSync(retryFile(), "utf8"));
|
|
21184
|
+
if (!retry2.source && ["fetch failed", "The operation was aborted due to timeout"].includes(retry2.error)) return;
|
|
21128
21185
|
if (retry2.key === refreshKey(session) && Number.isFinite(retry2.until) && Number.isInteger(retry2.attempt) && retry2.attempt > 0 && typeof retry2.error === "string") return retry2;
|
|
21129
21186
|
} catch {
|
|
21130
21187
|
}
|
|
21131
21188
|
}
|
|
21132
|
-
function
|
|
21189
|
+
function readTransportRetry(session) {
|
|
21190
|
+
if (transportRetry?.file === retryFile() && transportRetry.key === refreshKey(session)) return transportRetry;
|
|
21191
|
+
}
|
|
21192
|
+
function deferRefresh(session, error62, { after: after2, transport = false } = {}) {
|
|
21133
21193
|
const current = readSession();
|
|
21134
21194
|
if (current?.subject === session.subject && current.refreshToken === session.refreshToken) {
|
|
21135
|
-
const
|
|
21195
|
+
const previous = transport ? readTransportRetry(session) : readRetry(session);
|
|
21196
|
+
const attempt2 = Math.min((previous?.attempt ?? 0) + 1, 4);
|
|
21136
21197
|
const seconds = after2?.trim() ? Number(after2) : NaN;
|
|
21137
21198
|
const serverDelay = Number.isFinite(seconds) ? seconds * 1e3 : Date.parse(after2 ?? "") - Date.now();
|
|
21138
|
-
const
|
|
21199
|
+
const backoff = (transport ? 5e3 : REFRESH_BACKOFF_MS) * 2 ** (attempt2 - 1);
|
|
21200
|
+
const delay3 = Math.max(Math.min(backoff, transport ? 3e4 : 3e5), Number.isFinite(serverDelay) ? serverDelay : 0);
|
|
21139
21201
|
const retry2 = { key: refreshKey(session), until: Date.now() + delay3, attempt: attempt2, error: error62 };
|
|
21140
|
-
|
|
21141
|
-
|
|
21142
|
-
|
|
21202
|
+
if (transport) transportRetry = { ...retry2, file: retryFile() };
|
|
21203
|
+
else {
|
|
21204
|
+
const temporary = `${retryFile()}.${process.pid}.tmp`;
|
|
21205
|
+
fs3.writeFileSync(temporary, JSON.stringify({ ...retry2, source: "cloud" }), { mode: 384 });
|
|
21206
|
+
fs3.renameSync(temporary, retryFile());
|
|
21207
|
+
}
|
|
21143
21208
|
}
|
|
21144
21209
|
return { ok: false, reason: "unreachable", error: error62 };
|
|
21145
21210
|
}
|
|
@@ -21166,21 +21231,23 @@ function writeSession(session) {
|
|
|
21166
21231
|
`, { mode: 384 });
|
|
21167
21232
|
fs3.renameSync(tmp, sessionFile());
|
|
21168
21233
|
if (!expiringSoon(session) || !readRetry(session)) fs3.rmSync(retryFile(), { force: true });
|
|
21234
|
+
if (transportRetry?.file === retryFile() && (!expiringSoon(session) || !readTransportRetry(session))) transportRetry = void 0;
|
|
21169
21235
|
}
|
|
21170
21236
|
function clearSession() {
|
|
21237
|
+
if (transportRetry?.file === retryFile()) transportRetry = void 0;
|
|
21171
21238
|
try {
|
|
21172
21239
|
fs3.rmSync(sessionFile());
|
|
21173
21240
|
fs3.rmSync(retryFile(), { force: true });
|
|
21174
21241
|
} catch {
|
|
21175
21242
|
}
|
|
21176
21243
|
}
|
|
21177
|
-
async function accessToken() {
|
|
21244
|
+
async function accessToken({ retryTransport = false } = {}) {
|
|
21178
21245
|
const held4 = readSession();
|
|
21179
21246
|
if (!held4) return { ok: false, reason: "signed-out" };
|
|
21180
21247
|
if (!expiringSoon(held4)) return { ok: true, token: held4.accessToken, session: held4 };
|
|
21181
|
-
return refresh();
|
|
21248
|
+
return refresh(retryTransport);
|
|
21182
21249
|
}
|
|
21183
|
-
async function refresh() {
|
|
21250
|
+
async function refresh(retryTransport) {
|
|
21184
21251
|
const lock = await takeLock();
|
|
21185
21252
|
if (!lock) return { ok: false, reason: "unreachable", error: "Cloud sign-in refresh is busy. Try again shortly." };
|
|
21186
21253
|
try {
|
|
@@ -21189,6 +21256,8 @@ async function refresh() {
|
|
|
21189
21256
|
if (!expiringSoon(now)) return { ok: true, token: now.accessToken, session: now };
|
|
21190
21257
|
const retry2 = readRetry(now);
|
|
21191
21258
|
if (retry2 && retry2.until > Date.now()) return { ok: false, reason: "unreachable", error: retry2.error };
|
|
21259
|
+
const localRetry = retryTransport ? void 0 : readTransportRetry(now);
|
|
21260
|
+
if (localRetry && localRetry.until > Date.now()) return { ok: false, reason: "unreachable", error: localRetry.error };
|
|
21192
21261
|
const { api, anonKey } = cloudEndpoints();
|
|
21193
21262
|
let response;
|
|
21194
21263
|
try {
|
|
@@ -21199,12 +21268,12 @@ async function refresh() {
|
|
|
21199
21268
|
signal: AbortSignal.timeout(REFRESH_TIMEOUT_MS)
|
|
21200
21269
|
});
|
|
21201
21270
|
} catch (e) {
|
|
21202
|
-
return deferRefresh(now, e instanceof Error ? e.message : String(e));
|
|
21271
|
+
return deferRefresh(now, e instanceof Error ? e.message : String(e), { transport: true });
|
|
21203
21272
|
}
|
|
21204
21273
|
if (!response.ok) {
|
|
21205
21274
|
const body = await response.json().catch(() => null);
|
|
21206
21275
|
const error62 = body?.error_description ?? body?.msg ?? body?.message;
|
|
21207
|
-
if (![400, 401, 403].includes(response.status)) return deferRefresh(now, error62 ?? `Cloud answered ${response.status}`, response.headers.get("retry-after"));
|
|
21276
|
+
if (![400, 401, 403].includes(response.status)) return deferRefresh(now, error62 ?? `Cloud answered ${response.status}`, { after: response.headers.get("retry-after") });
|
|
21208
21277
|
return { ok: false, reason: "expired", error: error62 };
|
|
21209
21278
|
}
|
|
21210
21279
|
const fresh = sessionFrom(await response.json().catch(() => null), now);
|
|
@@ -21289,7 +21358,7 @@ function alive(pid) {
|
|
|
21289
21358
|
return e.code === "EPERM";
|
|
21290
21359
|
}
|
|
21291
21360
|
}
|
|
21292
|
-
var REFRESH_MARGIN_MS, LOCK_STALE_MS, LOCK_WAIT_MS, LOCK_RETRY_MS, REFRESH_TIMEOUT_MS, REFRESH_BACKOFF_MS, sessionFile, lockDir, lockOwner, retryFile, refreshKey, expiringSoon, sleep;
|
|
21361
|
+
var REFRESH_MARGIN_MS, LOCK_STALE_MS, LOCK_WAIT_MS, LOCK_RETRY_MS, REFRESH_TIMEOUT_MS, REFRESH_BACKOFF_MS, sessionFile, lockDir, lockOwner, retryFile, transportRetry, refreshKey, expiringSoon, sleep;
|
|
21293
21362
|
var init_session = __esm({
|
|
21294
21363
|
"../cli/src/lib/cloud/session.ts"() {
|
|
21295
21364
|
"use strict";
|
|
@@ -21327,7 +21396,7 @@ async function call(method, route2, body, key) {
|
|
|
21327
21396
|
if (!cloudConfigured()) return { ok: false, error: NOT_CONFIGURED, code: "bad_request" };
|
|
21328
21397
|
const token2 = await accessToken();
|
|
21329
21398
|
if (!token2.ok) {
|
|
21330
|
-
return token2.reason === "unreachable" ? { ok: false, error: `Cloud could not be reached: ${token2.error}
|
|
21399
|
+
return token2.reason === "unreachable" ? { ok: false, error: `Cloud could not be reached: ${token2.error}`, code: "unreachable", retryable: true } : { ok: false, error: token2.reason === "expired" ? "Cloud sign-in has expired. Sign in again." : "This machine is not signed in to Cloud.", code: "unauthenticated" };
|
|
21331
21400
|
}
|
|
21332
21401
|
let response;
|
|
21333
21402
|
try {
|
|
@@ -21342,10 +21411,11 @@ async function call(method, route2, body, key) {
|
|
|
21342
21411
|
signal: AbortSignal.timeout(2e4)
|
|
21343
21412
|
});
|
|
21344
21413
|
} catch (e) {
|
|
21345
|
-
return { ok: false, error: `Cloud could not be reached: ${e instanceof Error ? e.message : String(e)}
|
|
21414
|
+
return { ok: false, error: `Cloud could not be reached: ${e instanceof Error ? e.message : String(e)}`, code: "unreachable", retryable: true };
|
|
21346
21415
|
}
|
|
21347
|
-
const parsed = await response
|
|
21348
|
-
|
|
21416
|
+
const parsed = await readCloudJson(response);
|
|
21417
|
+
const problem = cloudProblem(response, parsed) ?? (isRecord(parsed) ? null : invalidResponse("a valid JSON response"));
|
|
21418
|
+
if (problem) return { ok: false, ...problem, error: problem.message };
|
|
21349
21419
|
return { ok: true, value: parsed, replayed: response.headers.get("idempotent-replayed") === "true" };
|
|
21350
21420
|
}
|
|
21351
21421
|
async function createTask(from, said2) {
|
|
@@ -21431,6 +21501,7 @@ var init_tasks = __esm({
|
|
|
21431
21501
|
"use strict";
|
|
21432
21502
|
init_config();
|
|
21433
21503
|
init_session();
|
|
21504
|
+
init_response();
|
|
21434
21505
|
TASK_ENV = "AI4KANBAN_TASK";
|
|
21435
21506
|
numberOf = (key) => Number(/-(\d+)$/.exec(key)?.[1] ?? NaN);
|
|
21436
21507
|
}
|
|
@@ -22080,19 +22151,19 @@ function tryLock(dir) {
|
|
|
22080
22151
|
const code = err.code;
|
|
22081
22152
|
if (code !== "ENOTEMPTY" && code !== "EEXIST") throw err;
|
|
22082
22153
|
}
|
|
22083
|
-
let
|
|
22154
|
+
let entries2;
|
|
22084
22155
|
try {
|
|
22085
|
-
|
|
22156
|
+
entries2 = fs7.readdirSync(dir);
|
|
22086
22157
|
} catch (err) {
|
|
22087
22158
|
if (err.code === "ENOENT") continue;
|
|
22088
22159
|
throw err;
|
|
22089
22160
|
}
|
|
22090
|
-
if (
|
|
22091
|
-
if (
|
|
22092
|
-
const owner = Number(
|
|
22161
|
+
if (entries2.length) {
|
|
22162
|
+
if (entries2.length !== 1 || !/^\d+-[a-f0-9-]{36}$/.test(entries2[0])) return void 0;
|
|
22163
|
+
const owner = Number(entries2[0].split("-")[0]);
|
|
22093
22164
|
if (pidAlive(owner)) return void 0;
|
|
22094
22165
|
}
|
|
22095
|
-
if (!removeClaim(dir,
|
|
22166
|
+
if (!removeClaim(dir, entries2[0])) return void 0;
|
|
22096
22167
|
}
|
|
22097
22168
|
} finally {
|
|
22098
22169
|
fs7.rmSync(candidate, { recursive: true, force: true });
|
|
@@ -22384,13 +22455,13 @@ function boardStamp() {
|
|
|
22384
22455
|
}
|
|
22385
22456
|
function walk(dir, parts, depth3) {
|
|
22386
22457
|
if (depth3 > MAX_DEPTH) return;
|
|
22387
|
-
let
|
|
22458
|
+
let entries2;
|
|
22388
22459
|
try {
|
|
22389
|
-
|
|
22460
|
+
entries2 = fs9.readdirSync(dir, { withFileTypes: true });
|
|
22390
22461
|
} catch {
|
|
22391
22462
|
return;
|
|
22392
22463
|
}
|
|
22393
|
-
for (const entry of
|
|
22464
|
+
for (const entry of entries2.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
22394
22465
|
const full = path10.join(dir, entry.name);
|
|
22395
22466
|
if (entry.isDirectory()) walk(full, parts, depth3 + 1);
|
|
22396
22467
|
else stamp(full, parts);
|
|
@@ -22651,8 +22722,8 @@ var init_package = __esm({
|
|
|
22651
22722
|
"../cli/package.json"() {
|
|
22652
22723
|
package_default = {
|
|
22653
22724
|
name: "wildcrane",
|
|
22654
|
-
version: "0.11.
|
|
22655
|
-
akbContract:
|
|
22725
|
+
version: "0.11.84",
|
|
22726
|
+
akbContract: 28,
|
|
22656
22727
|
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.",
|
|
22657
22728
|
keywords: [
|
|
22658
22729
|
"kanban",
|
|
@@ -23327,13 +23398,13 @@ function pathLookup() {
|
|
|
23327
23398
|
const names2 = /* @__PURE__ */ new Set();
|
|
23328
23399
|
for (const dir of (process.env.PATH ?? "").split(path17.delimiter)) {
|
|
23329
23400
|
if (!dir) continue;
|
|
23330
|
-
let
|
|
23401
|
+
let entries2;
|
|
23331
23402
|
try {
|
|
23332
|
-
|
|
23403
|
+
entries2 = fs16.readdirSync(dir);
|
|
23333
23404
|
} catch {
|
|
23334
23405
|
continue;
|
|
23335
23406
|
}
|
|
23336
|
-
for (const entry of
|
|
23407
|
+
for (const entry of entries2) names2.add(WINDOWS ? entry.toLowerCase() : entry);
|
|
23337
23408
|
}
|
|
23338
23409
|
const extensions = WINDOWS ? windowsExtensions() : [];
|
|
23339
23410
|
return (command) => {
|
|
@@ -23939,9 +24010,9 @@ function createEventCollector() {
|
|
|
23939
24010
|
close();
|
|
23940
24011
|
queue.push({ kind: "tool_call_update", data: { toolCallId, status, ...result.trim() ? { result: result.trim() } : {} } });
|
|
23941
24012
|
},
|
|
23942
|
-
plan(
|
|
24013
|
+
plan(entries2) {
|
|
23943
24014
|
close();
|
|
23944
|
-
queue.push({ kind: "plan", data: { entries: entriesOf(
|
|
24015
|
+
queue.push({ kind: "plan", data: { entries: entriesOf(entries2) } });
|
|
23945
24016
|
},
|
|
23946
24017
|
/** Cursor's `cursor/update_todos`: the whole list, or under `merge` only what changed, by id. */
|
|
23947
24018
|
todos(raw, merge2) {
|
|
@@ -24792,10 +24863,10 @@ function promptSize(raw) {
|
|
|
24792
24863
|
return size > 0 ? size : void 0;
|
|
24793
24864
|
}
|
|
24794
24865
|
function windowOf(raw, model) {
|
|
24795
|
-
const
|
|
24796
|
-
const names2 = Object.keys(
|
|
24866
|
+
const entries2 = obj2(raw);
|
|
24867
|
+
const names2 = Object.keys(entries2);
|
|
24797
24868
|
const name = model && names2.includes(model) ? model : names2.length === 1 ? names2[0] : void 0;
|
|
24798
|
-
return name ? num2(obj2(
|
|
24869
|
+
return name ? num2(obj2(entries2[name]).contextWindow) || void 0 : void 0;
|
|
24799
24870
|
}
|
|
24800
24871
|
function createStreamRenderer() {
|
|
24801
24872
|
let final;
|
|
@@ -25054,10 +25125,10 @@ function findRollout(threadId) {
|
|
|
25054
25125
|
}
|
|
25055
25126
|
for (const name of names2) {
|
|
25056
25127
|
if (!name.startsWith("rollout-") || !name.endsWith(tail)) continue;
|
|
25057
|
-
const
|
|
25128
|
+
const path88 = join2(dir, name);
|
|
25058
25129
|
try {
|
|
25059
|
-
const at = statSync2(
|
|
25060
|
-
if (!newest2 || at > newest2.at) newest2 = { path:
|
|
25130
|
+
const at = statSync2(path88).mtimeMs;
|
|
25131
|
+
if (!newest2 || at > newest2.at) newest2 = { path: path88, at };
|
|
25061
25132
|
} catch {
|
|
25062
25133
|
}
|
|
25063
25134
|
}
|
|
@@ -25065,11 +25136,11 @@ function findRollout(threadId) {
|
|
|
25065
25136
|
return newest2?.path;
|
|
25066
25137
|
}
|
|
25067
25138
|
function readCodexRunFacts(threadId) {
|
|
25068
|
-
const
|
|
25069
|
-
if (!
|
|
25139
|
+
const path88 = findRollout(threadId);
|
|
25140
|
+
if (!path88) return void 0;
|
|
25070
25141
|
let raw;
|
|
25071
25142
|
try {
|
|
25072
|
-
raw = readFileSync2(
|
|
25143
|
+
raw = readFileSync2(path88, "utf8");
|
|
25073
25144
|
} catch {
|
|
25074
25145
|
return void 0;
|
|
25075
25146
|
}
|
|
@@ -25195,8 +25266,8 @@ function renderCompleted(item) {
|
|
|
25195
25266
|
const changes = Array.isArray(item.changes) ? item.changes : [];
|
|
25196
25267
|
return changes.map((raw) => {
|
|
25197
25268
|
const change2 = obj2(raw);
|
|
25198
|
-
const
|
|
25199
|
-
return
|
|
25269
|
+
const path88 = str2(change2.path);
|
|
25270
|
+
return path88 ? `\u23FA ${str2(change2.kind) || "change"}(${path88})
|
|
25200
25271
|
` : "";
|
|
25201
25272
|
}).join("");
|
|
25202
25273
|
}
|
|
@@ -25472,12 +25543,12 @@ function home2() {
|
|
|
25472
25543
|
return process.env.KIMI_CODE_HOME?.trim() || join3(homedir3(), ".kimi-code");
|
|
25473
25544
|
}
|
|
25474
25545
|
function readIndex() {
|
|
25475
|
-
const
|
|
25546
|
+
const entries2 = /* @__PURE__ */ new Map();
|
|
25476
25547
|
let raw;
|
|
25477
25548
|
try {
|
|
25478
25549
|
raw = readFileSync3(join3(home2(), "session_index.jsonl"), "utf8");
|
|
25479
25550
|
} catch {
|
|
25480
|
-
return
|
|
25551
|
+
return entries2;
|
|
25481
25552
|
}
|
|
25482
25553
|
for (const line of raw.split("\n")) {
|
|
25483
25554
|
if (!line.trim()) continue;
|
|
@@ -25492,14 +25563,14 @@ function readIndex() {
|
|
|
25492
25563
|
const sessionId = str2(record2.sessionId).trim();
|
|
25493
25564
|
if (!sessionId) continue;
|
|
25494
25565
|
if (record2.deleted === true) {
|
|
25495
|
-
|
|
25566
|
+
entries2.delete(sessionId);
|
|
25496
25567
|
continue;
|
|
25497
25568
|
}
|
|
25498
25569
|
const sessionDir = str2(record2.sessionDir).trim();
|
|
25499
25570
|
const workDir = str2(record2.workDir).trim();
|
|
25500
|
-
if (sessionDir && workDir)
|
|
25571
|
+
if (sessionDir && workDir) entries2.set(sessionId, { sessionId, sessionDir, workDir });
|
|
25501
25572
|
}
|
|
25502
|
-
return
|
|
25573
|
+
return entries2;
|
|
25503
25574
|
}
|
|
25504
25575
|
function findKimiSession(cwd, since) {
|
|
25505
25576
|
const want = resolve(cwd);
|
|
@@ -25534,10 +25605,10 @@ function readKimiRunFacts(sessionId) {
|
|
|
25534
25605
|
const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
|
|
25535
25606
|
let model;
|
|
25536
25607
|
let holding = 0;
|
|
25537
|
-
for (const { path:
|
|
25608
|
+
for (const { path: path88, main } of wireFiles(entry.sessionDir)) {
|
|
25538
25609
|
let raw;
|
|
25539
25610
|
try {
|
|
25540
|
-
raw = readFileSync3(
|
|
25611
|
+
raw = readFileSync3(path88, "utf8");
|
|
25541
25612
|
} catch {
|
|
25542
25613
|
continue;
|
|
25543
25614
|
}
|
|
@@ -25914,8 +25985,8 @@ var init_tail = __esm({
|
|
|
25914
25985
|
import fs22 from "node:fs";
|
|
25915
25986
|
function whereHint(update2, title) {
|
|
25916
25987
|
const locations = Array.isArray(update2.locations) ? update2.locations : [];
|
|
25917
|
-
const
|
|
25918
|
-
return
|
|
25988
|
+
const path88 = str2(obj2(locations[0]).path);
|
|
25989
|
+
return path88 && !title.includes(path88) ? hint(path88) : "";
|
|
25919
25990
|
}
|
|
25920
25991
|
function saidBy(update2) {
|
|
25921
25992
|
const content = Array.isArray(update2.content) ? update2.content : [];
|
|
@@ -26679,19 +26750,19 @@ var init_codex_background = __esm({
|
|
|
26679
26750
|
// ../cli/src/lib/agent/wire/codex-work.ts
|
|
26680
26751
|
function codexWork() {
|
|
26681
26752
|
const children = /* @__PURE__ */ new Set();
|
|
26682
|
-
const
|
|
26753
|
+
const entries2 = /* @__PURE__ */ new Map();
|
|
26683
26754
|
const background = /* @__PURE__ */ new Set();
|
|
26684
26755
|
const seenCollab = /* @__PURE__ */ new Set();
|
|
26685
26756
|
let root2 = "";
|
|
26686
26757
|
const own2 = (threadId) => threadId === root2 || children.has(threadId);
|
|
26687
26758
|
const agent = (threadId, raw) => {
|
|
26688
26759
|
const id2 = `agent:${threadId}`;
|
|
26689
|
-
const previous =
|
|
26760
|
+
const previous = entries2.get(id2);
|
|
26690
26761
|
const status = str2(raw.status);
|
|
26691
26762
|
if (["shutdown", "notFound", "not_found"].includes(status) && previous && previous.status !== "running") return;
|
|
26692
26763
|
const state = ["pendingInit", "running", "pending_init"].includes(status) ? "running" : status === "completed" ? "completed" : ["interrupted", "shutdown"].includes(status) ? "interrupted" : ["errored", "notFound", "not_found"].includes(status) ? "failed" : void 0;
|
|
26693
26764
|
if (!state) return;
|
|
26694
|
-
|
|
26765
|
+
entries2.set(id2, { ...previous, id: id2, threadId, kind: "agent", status: state, result: summary(str2(raw.message)) });
|
|
26695
26766
|
};
|
|
26696
26767
|
const observe = (threadId, raw) => {
|
|
26697
26768
|
if (!own2(threadId)) return;
|
|
@@ -26700,7 +26771,7 @@ function codexWork() {
|
|
|
26700
26771
|
if (raw.kind === "started" && child && child !== root2 && !children.has(child)) {
|
|
26701
26772
|
children.add(child);
|
|
26702
26773
|
agent(child, { status: "running" });
|
|
26703
|
-
|
|
26774
|
+
entries2.get(`agent:${child}`).agentPath = str2(raw.agentPath);
|
|
26704
26775
|
}
|
|
26705
26776
|
return;
|
|
26706
26777
|
}
|
|
@@ -26711,18 +26782,18 @@ function codexWork() {
|
|
|
26711
26782
|
if (raw.tool === "spawnAgent") {
|
|
26712
26783
|
for (const id3 of Array.isArray(raw.receiverThreadIds) ? raw.receiverThreadIds : []) if (typeof id3 === "string" && id3 !== root2) {
|
|
26713
26784
|
children.add(id3);
|
|
26714
|
-
if (!
|
|
26785
|
+
if (!entries2.has(`agent:${id3}`)) agent(id3, { status: "running" });
|
|
26715
26786
|
}
|
|
26716
26787
|
}
|
|
26717
26788
|
for (const [id3, state] of Object.entries(obj2(raw.agentsStates))) if (children.has(id3)) agent(id3, obj2(state));
|
|
26718
26789
|
}
|
|
26719
26790
|
if (raw.type !== "commandExecution" || !str2(raw.id)) return;
|
|
26720
26791
|
const id2 = terminalKey(threadId, str2(raw.id));
|
|
26721
|
-
const previous =
|
|
26792
|
+
const previous = entries2.get(id2);
|
|
26722
26793
|
const running = raw.status === "inProgress";
|
|
26723
26794
|
if (running && previous?.exitCode !== void 0) return;
|
|
26724
26795
|
const exitCode = typeof raw.exitCode === "number" ? raw.exitCode : previous?.exitCode;
|
|
26725
|
-
|
|
26796
|
+
entries2.set(id2, {
|
|
26726
26797
|
...previous,
|
|
26727
26798
|
id: id2,
|
|
26728
26799
|
threadId,
|
|
@@ -26764,7 +26835,7 @@ function codexWork() {
|
|
|
26764
26835
|
};
|
|
26765
26836
|
return {
|
|
26766
26837
|
children,
|
|
26767
|
-
entries,
|
|
26838
|
+
entries: entries2,
|
|
26768
26839
|
background,
|
|
26769
26840
|
own: own2,
|
|
26770
26841
|
observe,
|
|
@@ -26774,9 +26845,9 @@ function codexWork() {
|
|
|
26774
26845
|
for (const child of retained) if (child !== id2) children.add(child);
|
|
26775
26846
|
},
|
|
26776
26847
|
freeze() {
|
|
26777
|
-
for (const [id2, entry] of
|
|
26848
|
+
for (const [id2, entry] of entries2) if (entry.status === "running") background.add(id2);
|
|
26778
26849
|
},
|
|
26779
|
-
work: () => [...
|
|
26850
|
+
work: () => [...entries2.values()].filter((e) => background.has(e.id)),
|
|
26780
26851
|
async refresh(rpc, alive2) {
|
|
26781
26852
|
for (const id2 of children) {
|
|
26782
26853
|
if (!alive2()) return;
|
|
@@ -26798,8 +26869,8 @@ function codexWork() {
|
|
|
26798
26869
|
if (!itemId || !processId) throw Error("Codex returned a background terminal without its complete handles.");
|
|
26799
26870
|
const id2 = terminalKey(threadId, itemId);
|
|
26800
26871
|
present.add(id2);
|
|
26801
|
-
const previous =
|
|
26802
|
-
|
|
26872
|
+
const previous = entries2.get(id2);
|
|
26873
|
+
entries2.set(id2, {
|
|
26803
26874
|
...previous,
|
|
26804
26875
|
id: id2,
|
|
26805
26876
|
threadId,
|
|
@@ -26817,13 +26888,13 @@ function codexWork() {
|
|
|
26817
26888
|
} while (cursor);
|
|
26818
26889
|
} catch (e) {
|
|
26819
26890
|
if (!(e instanceof RpcError) || ![-32601, -32600].includes(e.code ?? 0) || !/method|unknown|unsupported/i.test(e.message)) throw e;
|
|
26820
|
-
if ([...
|
|
26891
|
+
if ([...entries2.values()].some((w) => w.threadId === threadId && w.kind === "terminal" && w.status === "running")) throw Error("This Codex version cannot report unfinished background commands; cleanup is unconfirmed.");
|
|
26821
26892
|
continue;
|
|
26822
26893
|
}
|
|
26823
|
-
const missing = [...
|
|
26894
|
+
const missing = [...entries2.values()].filter((e) => background.has(e.id) && e.threadId === threadId && e.kind === "terminal" && e.status === "running" && !present.has(e.id));
|
|
26824
26895
|
if (missing.length) {
|
|
26825
26896
|
await readThread(rpc, threadId);
|
|
26826
|
-
for (const entry of missing) if (
|
|
26897
|
+
for (const entry of missing) if (entries2.get(entry.id)?.status === "running") entries2.get(entry.id).status = "unknown";
|
|
26827
26898
|
}
|
|
26828
26899
|
}
|
|
26829
26900
|
}
|
|
@@ -27096,7 +27167,7 @@ async function run(io, options, count3) {
|
|
|
27096
27167
|
startupTimer = setTimeout(() => {
|
|
27097
27168
|
if (!started) io.event?.({ kind: "log", data: { text: "[conversation] start_unconfirmed" } });
|
|
27098
27169
|
}, CONVERSATION_MS.start);
|
|
27099
|
-
await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text5 }, ...images.map((
|
|
27170
|
+
await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text5 }, ...images.map((path88) => ({ type: "localImage", path: path88 }))] }), CONVERSATION_MS.start, "Codex turn/start timed out; submission outcome is unknown.").catch((error62) => {
|
|
27100
27171
|
if (!started) throw error62;
|
|
27101
27172
|
});
|
|
27102
27173
|
};
|
|
@@ -27190,11 +27261,11 @@ async function run(io, options, count3) {
|
|
|
27190
27261
|
}
|
|
27191
27262
|
const outstanding = work.work().filter((w) => offered.get(w.id) !== snapshot2(w) && presented.get(w.id) !== snapshot2(w) && w.disposition !== "keep" && !(w.intentionalStop && !["running", "unknown"].includes(w.status)));
|
|
27192
27263
|
if (outstanding.length) {
|
|
27193
|
-
const
|
|
27194
|
-
for (const entry of
|
|
27195
|
-
settlement = { work:
|
|
27264
|
+
const entries2 = batch(outstanding).map((w) => ({ ...w }));
|
|
27265
|
+
for (const entry of entries2) offered.set(entry.id, snapshot2(entry));
|
|
27266
|
+
settlement = { work: entries2, polled: /* @__PURE__ */ new Set(), messages: [] };
|
|
27196
27267
|
armCleanup();
|
|
27197
|
-
await start(settlementPrompt(
|
|
27268
|
+
await start(settlementPrompt(entries2, execution, !!host2.instance));
|
|
27198
27269
|
return;
|
|
27199
27270
|
}
|
|
27200
27271
|
const awaited = work.work().filter((w) => w.status === "running" && w.disposition !== "keep");
|
|
@@ -29302,13 +29373,13 @@ function plannerModules() {
|
|
|
29302
29373
|
function memoryDirectories(board2) {
|
|
29303
29374
|
const root2 = board2 ? path31.join(board2, "memory") : MEMORY;
|
|
29304
29375
|
const walk3 = (dir, depth3, scoped = true) => {
|
|
29305
|
-
let
|
|
29376
|
+
let entries2;
|
|
29306
29377
|
try {
|
|
29307
|
-
|
|
29378
|
+
entries2 = fs28.readdirSync(dir, { withFileTypes: true });
|
|
29308
29379
|
} catch {
|
|
29309
29380
|
return [];
|
|
29310
29381
|
}
|
|
29311
|
-
return
|
|
29382
|
+
return entries2.filter((e) => e.isDirectory() && !e.name.startsWith(".")).flatMap((e) => {
|
|
29312
29383
|
const target = path31.join(dir, e.name);
|
|
29313
29384
|
return depth3 === 1 ? !scoped || ["project", "workspace"].includes(e.name) ? [target] : [] : walk3(target, depth3 - 1, scoped);
|
|
29314
29385
|
});
|
|
@@ -29395,31 +29466,32 @@ var init_file_limits = __esm({
|
|
|
29395
29466
|
});
|
|
29396
29467
|
|
|
29397
29468
|
// ../cli/src/lib/shared/board-files.ts
|
|
29398
|
-
function isBoardPath(
|
|
29399
|
-
if (!
|
|
29400
|
-
if (
|
|
29401
|
-
if (
|
|
29402
|
-
if (
|
|
29403
|
-
if (SETTINGS.includes(
|
|
29404
|
-
if (
|
|
29405
|
-
if (
|
|
29406
|
-
return ROOTS.some((root2) =>
|
|
29407
|
-
}
|
|
29408
|
-
function numberOfCard(
|
|
29409
|
-
const n = ROOT.exec(
|
|
29469
|
+
function isBoardPath(path88) {
|
|
29470
|
+
if (!path88 || path88.length > 500 || path88.startsWith("/") || path88.includes("\\") || path88.includes("\0")) return false;
|
|
29471
|
+
if (path88.split("/").some((part) => !part || part === "." || part === "..")) return false;
|
|
29472
|
+
if (path88 === "todo/README.md" || path88.split("/").includes(".sync")) return false;
|
|
29473
|
+
if (path88.startsWith("studios/")) return true;
|
|
29474
|
+
if (SETTINGS.includes(path88)) return true;
|
|
29475
|
+
if (path88.startsWith("rules/")) return isSettingsPath(path88);
|
|
29476
|
+
if (path88.startsWith("assets/")) return taskOfAssets(path88) !== null;
|
|
29477
|
+
return ROOTS.some((root2) => path88.startsWith(root2)) && path88.endsWith(".md");
|
|
29478
|
+
}
|
|
29479
|
+
function numberOfCard(path88) {
|
|
29480
|
+
const n = ROOT.exec(path88)?.[1] ?? CARD.exec(path88)?.[1];
|
|
29410
29481
|
return n ? Number(n) : null;
|
|
29411
29482
|
}
|
|
29412
|
-
var ROOTS, SETTINGS, isSettingsPath, CARD, ROOT, taskOfAssets, studioFolder, studioName;
|
|
29483
|
+
var ROOTS, SETTINGS, isSettingsPath, CARD, ROOT, assetsFile, taskOfAssets, studioFolder, studioName;
|
|
29413
29484
|
var init_board_files = __esm({
|
|
29414
29485
|
"../cli/src/lib/shared/board-files.ts"() {
|
|
29415
29486
|
"use strict";
|
|
29416
29487
|
init_file_limits();
|
|
29417
29488
|
ROOTS = ["todo/", ".archive/", "memory/", "studios/", "triage/", "assets/", "rules/"];
|
|
29418
29489
|
SETTINGS = ["modules.md", "config.md"];
|
|
29419
|
-
isSettingsPath = (
|
|
29490
|
+
isSettingsPath = (path88) => SETTINGS.includes(path88) || /^rules\/(?:studios\/[^/]+|proposer|project-writer|dismissal-reviewer|memory-pruner)\.md$/.test(path88);
|
|
29420
29491
|
CARD = /^(?:todo|\.archive)\/(?:[^/]+\/)*(\d+)-[^/]*\.md$/;
|
|
29421
29492
|
ROOT = /^(?:todo|\.archive)\/(?:[^/]+\/)*(\d+)-[^/]+\/root\.md$/;
|
|
29422
|
-
|
|
29493
|
+
assetsFile = (task) => `assets/${task}.json`;
|
|
29494
|
+
taskOfAssets = (path88) => /^assets\/(task_[0-9a-f]+)\.json$/.exec(path88)?.[1] ?? null;
|
|
29423
29495
|
studioFolder = (id2) => id2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
29424
29496
|
studioName = (id2) => id2.startsWith("wf_builtin_") ? id2.slice("wf_builtin_".length).replace(/_/g, "-") : studioFolder(id2);
|
|
29425
29497
|
}
|
|
@@ -32642,8 +32714,8 @@ var require_utils = __commonJS({
|
|
|
32642
32714
|
}
|
|
32643
32715
|
return ind;
|
|
32644
32716
|
}
|
|
32645
|
-
function removeDotSegments(
|
|
32646
|
-
let input2 =
|
|
32717
|
+
function removeDotSegments(path88) {
|
|
32718
|
+
let input2 = path88;
|
|
32647
32719
|
const output2 = [];
|
|
32648
32720
|
let nextSlash = -1;
|
|
32649
32721
|
let len = 0;
|
|
@@ -32717,11 +32789,11 @@ var require_utils = __commonJS({
|
|
|
32717
32789
|
}
|
|
32718
32790
|
return output2.join("");
|
|
32719
32791
|
}
|
|
32720
|
-
function removeDotSegmentsRelative(
|
|
32721
|
-
if (
|
|
32722
|
-
return removeDotSegments(
|
|
32792
|
+
function removeDotSegmentsRelative(path88) {
|
|
32793
|
+
if (path88 === "" || path88[0] === "/") {
|
|
32794
|
+
return removeDotSegments(path88);
|
|
32723
32795
|
}
|
|
32724
|
-
const segments =
|
|
32796
|
+
const segments = path88.split("/");
|
|
32725
32797
|
const last = segments.length - 1;
|
|
32726
32798
|
const output2 = [];
|
|
32727
32799
|
let trailingDirectory = false;
|
|
@@ -33084,8 +33156,8 @@ var require_schemes = __commonJS({
|
|
|
33084
33156
|
}
|
|
33085
33157
|
if (wsComponent.resourceName) {
|
|
33086
33158
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
33087
|
-
const
|
|
33088
|
-
wsComponent.path =
|
|
33159
|
+
const path88 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
33160
|
+
wsComponent.path = path88 && path88 !== "/" ? path88 : void 0;
|
|
33089
33161
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
33090
33162
|
wsComponent.resourceName = void 0;
|
|
33091
33163
|
}
|
|
@@ -34490,8 +34562,8 @@ var require_multipleOf = __commonJS({
|
|
|
34490
34562
|
const { gen, data, schemaCode, it } = cxt;
|
|
34491
34563
|
const prec = it.opts.multipleOfPrecision;
|
|
34492
34564
|
const res = gen.let("res");
|
|
34493
|
-
const
|
|
34494
|
-
cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${
|
|
34565
|
+
const invalid3 = prec ? (0, codegen_1._)`Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}` : (0, codegen_1._)`${res} !== parseInt(${res})`;
|
|
34566
|
+
cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid3}))`);
|
|
34495
34567
|
}
|
|
34496
34568
|
};
|
|
34497
34569
|
exports.default = def;
|
|
@@ -36245,17 +36317,17 @@ var require_visit = __commonJS({
|
|
|
36245
36317
|
visit2.BREAK = BREAK;
|
|
36246
36318
|
visit2.SKIP = SKIP;
|
|
36247
36319
|
visit2.REMOVE = REMOVE;
|
|
36248
|
-
function visit_(key, node2, visitor,
|
|
36249
|
-
const ctrl = callVisitor(key, node2, visitor,
|
|
36320
|
+
function visit_(key, node2, visitor, path88) {
|
|
36321
|
+
const ctrl = callVisitor(key, node2, visitor, path88);
|
|
36250
36322
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
36251
|
-
replaceNode(key,
|
|
36252
|
-
return visit_(key, ctrl, visitor,
|
|
36323
|
+
replaceNode(key, path88, ctrl);
|
|
36324
|
+
return visit_(key, ctrl, visitor, path88);
|
|
36253
36325
|
}
|
|
36254
36326
|
if (typeof ctrl !== "symbol") {
|
|
36255
36327
|
if (identity.isCollection(node2)) {
|
|
36256
|
-
|
|
36328
|
+
path88 = Object.freeze(path88.concat(node2));
|
|
36257
36329
|
for (let i = 0; i < node2.items.length; ++i) {
|
|
36258
|
-
const ci = visit_(i, node2.items[i], visitor,
|
|
36330
|
+
const ci = visit_(i, node2.items[i], visitor, path88);
|
|
36259
36331
|
if (typeof ci === "number")
|
|
36260
36332
|
i = ci - 1;
|
|
36261
36333
|
else if (ci === BREAK)
|
|
@@ -36266,13 +36338,13 @@ var require_visit = __commonJS({
|
|
|
36266
36338
|
}
|
|
36267
36339
|
}
|
|
36268
36340
|
} else if (identity.isPair(node2)) {
|
|
36269
|
-
|
|
36270
|
-
const ck = visit_("key", node2.key, visitor,
|
|
36341
|
+
path88 = Object.freeze(path88.concat(node2));
|
|
36342
|
+
const ck = visit_("key", node2.key, visitor, path88);
|
|
36271
36343
|
if (ck === BREAK)
|
|
36272
36344
|
return BREAK;
|
|
36273
36345
|
else if (ck === REMOVE)
|
|
36274
36346
|
node2.key = null;
|
|
36275
|
-
const cv = visit_("value", node2.value, visitor,
|
|
36347
|
+
const cv = visit_("value", node2.value, visitor, path88);
|
|
36276
36348
|
if (cv === BREAK)
|
|
36277
36349
|
return BREAK;
|
|
36278
36350
|
else if (cv === REMOVE)
|
|
@@ -36293,17 +36365,17 @@ var require_visit = __commonJS({
|
|
|
36293
36365
|
visitAsync.BREAK = BREAK;
|
|
36294
36366
|
visitAsync.SKIP = SKIP;
|
|
36295
36367
|
visitAsync.REMOVE = REMOVE;
|
|
36296
|
-
async function visitAsync_(key, node2, visitor,
|
|
36297
|
-
const ctrl = await callVisitor(key, node2, visitor,
|
|
36368
|
+
async function visitAsync_(key, node2, visitor, path88) {
|
|
36369
|
+
const ctrl = await callVisitor(key, node2, visitor, path88);
|
|
36298
36370
|
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
|
|
36299
|
-
replaceNode(key,
|
|
36300
|
-
return visitAsync_(key, ctrl, visitor,
|
|
36371
|
+
replaceNode(key, path88, ctrl);
|
|
36372
|
+
return visitAsync_(key, ctrl, visitor, path88);
|
|
36301
36373
|
}
|
|
36302
36374
|
if (typeof ctrl !== "symbol") {
|
|
36303
36375
|
if (identity.isCollection(node2)) {
|
|
36304
|
-
|
|
36376
|
+
path88 = Object.freeze(path88.concat(node2));
|
|
36305
36377
|
for (let i = 0; i < node2.items.length; ++i) {
|
|
36306
|
-
const ci = await visitAsync_(i, node2.items[i], visitor,
|
|
36378
|
+
const ci = await visitAsync_(i, node2.items[i], visitor, path88);
|
|
36307
36379
|
if (typeof ci === "number")
|
|
36308
36380
|
i = ci - 1;
|
|
36309
36381
|
else if (ci === BREAK)
|
|
@@ -36314,13 +36386,13 @@ var require_visit = __commonJS({
|
|
|
36314
36386
|
}
|
|
36315
36387
|
}
|
|
36316
36388
|
} else if (identity.isPair(node2)) {
|
|
36317
|
-
|
|
36318
|
-
const ck = await visitAsync_("key", node2.key, visitor,
|
|
36389
|
+
path88 = Object.freeze(path88.concat(node2));
|
|
36390
|
+
const ck = await visitAsync_("key", node2.key, visitor, path88);
|
|
36319
36391
|
if (ck === BREAK)
|
|
36320
36392
|
return BREAK;
|
|
36321
36393
|
else if (ck === REMOVE)
|
|
36322
36394
|
node2.key = null;
|
|
36323
|
-
const cv = await visitAsync_("value", node2.value, visitor,
|
|
36395
|
+
const cv = await visitAsync_("value", node2.value, visitor, path88);
|
|
36324
36396
|
if (cv === BREAK)
|
|
36325
36397
|
return BREAK;
|
|
36326
36398
|
else if (cv === REMOVE)
|
|
@@ -36347,23 +36419,23 @@ var require_visit = __commonJS({
|
|
|
36347
36419
|
}
|
|
36348
36420
|
return visitor;
|
|
36349
36421
|
}
|
|
36350
|
-
function callVisitor(key, node2, visitor,
|
|
36422
|
+
function callVisitor(key, node2, visitor, path88) {
|
|
36351
36423
|
if (typeof visitor === "function")
|
|
36352
|
-
return visitor(key, node2,
|
|
36424
|
+
return visitor(key, node2, path88);
|
|
36353
36425
|
if (identity.isMap(node2))
|
|
36354
|
-
return visitor.Map?.(key, node2,
|
|
36426
|
+
return visitor.Map?.(key, node2, path88);
|
|
36355
36427
|
if (identity.isSeq(node2))
|
|
36356
|
-
return visitor.Seq?.(key, node2,
|
|
36428
|
+
return visitor.Seq?.(key, node2, path88);
|
|
36357
36429
|
if (identity.isPair(node2))
|
|
36358
|
-
return visitor.Pair?.(key, node2,
|
|
36430
|
+
return visitor.Pair?.(key, node2, path88);
|
|
36359
36431
|
if (identity.isScalar(node2))
|
|
36360
|
-
return visitor.Scalar?.(key, node2,
|
|
36432
|
+
return visitor.Scalar?.(key, node2, path88);
|
|
36361
36433
|
if (identity.isAlias(node2))
|
|
36362
|
-
return visitor.Alias?.(key, node2,
|
|
36434
|
+
return visitor.Alias?.(key, node2, path88);
|
|
36363
36435
|
return void 0;
|
|
36364
36436
|
}
|
|
36365
|
-
function replaceNode(key,
|
|
36366
|
-
const parent =
|
|
36437
|
+
function replaceNode(key, path88, node2) {
|
|
36438
|
+
const parent = path88[path88.length - 1];
|
|
36367
36439
|
if (identity.isCollection(parent)) {
|
|
36368
36440
|
parent.items[key] = node2;
|
|
36369
36441
|
} else if (identity.isPair(parent)) {
|
|
@@ -36975,10 +37047,10 @@ var require_Collection = __commonJS({
|
|
|
36975
37047
|
var createNode = require_createNode();
|
|
36976
37048
|
var identity = require_identity();
|
|
36977
37049
|
var Node = require_Node();
|
|
36978
|
-
function collectionFromPath(schema,
|
|
37050
|
+
function collectionFromPath(schema, path88, value) {
|
|
36979
37051
|
let v = value;
|
|
36980
|
-
for (let i =
|
|
36981
|
-
const k =
|
|
37052
|
+
for (let i = path88.length - 1; i >= 0; --i) {
|
|
37053
|
+
const k = path88[i];
|
|
36982
37054
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
36983
37055
|
const a = [];
|
|
36984
37056
|
a[k] = v;
|
|
@@ -36997,7 +37069,7 @@ var require_Collection = __commonJS({
|
|
|
36997
37069
|
sourceObjects: /* @__PURE__ */ new Map()
|
|
36998
37070
|
});
|
|
36999
37071
|
}
|
|
37000
|
-
var isEmptyPath = (
|
|
37072
|
+
var isEmptyPath = (path88) => path88 == null || typeof path88 === "object" && !!path88[Symbol.iterator]().next().done;
|
|
37001
37073
|
var Collection = class extends Node.NodeBase {
|
|
37002
37074
|
constructor(type, schema) {
|
|
37003
37075
|
super(type);
|
|
@@ -37027,11 +37099,11 @@ var require_Collection = __commonJS({
|
|
|
37027
37099
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
37028
37100
|
* that already exists in the map.
|
|
37029
37101
|
*/
|
|
37030
|
-
addIn(
|
|
37031
|
-
if (isEmptyPath(
|
|
37102
|
+
addIn(path88, value) {
|
|
37103
|
+
if (isEmptyPath(path88))
|
|
37032
37104
|
this.add(value);
|
|
37033
37105
|
else {
|
|
37034
|
-
const [key, ...rest] =
|
|
37106
|
+
const [key, ...rest] = path88;
|
|
37035
37107
|
const node2 = this.get(key, true);
|
|
37036
37108
|
if (identity.isCollection(node2))
|
|
37037
37109
|
node2.addIn(rest, value);
|
|
@@ -37045,8 +37117,8 @@ var require_Collection = __commonJS({
|
|
|
37045
37117
|
* Removes a value from the collection.
|
|
37046
37118
|
* @returns `true` if the item was found and removed.
|
|
37047
37119
|
*/
|
|
37048
|
-
deleteIn(
|
|
37049
|
-
const [key, ...rest] =
|
|
37120
|
+
deleteIn(path88) {
|
|
37121
|
+
const [key, ...rest] = path88;
|
|
37050
37122
|
if (rest.length === 0)
|
|
37051
37123
|
return this.delete(key);
|
|
37052
37124
|
const node2 = this.get(key, true);
|
|
@@ -37060,8 +37132,8 @@ var require_Collection = __commonJS({
|
|
|
37060
37132
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
37061
37133
|
* `true` (collections are always returned intact).
|
|
37062
37134
|
*/
|
|
37063
|
-
getIn(
|
|
37064
|
-
const [key, ...rest] =
|
|
37135
|
+
getIn(path88, keepScalar) {
|
|
37136
|
+
const [key, ...rest] = path88;
|
|
37065
37137
|
const node2 = this.get(key, true);
|
|
37066
37138
|
if (rest.length === 0)
|
|
37067
37139
|
return !keepScalar && identity.isScalar(node2) ? node2.value : node2;
|
|
@@ -37079,8 +37151,8 @@ var require_Collection = __commonJS({
|
|
|
37079
37151
|
/**
|
|
37080
37152
|
* Checks if the collection includes a value with the key `key`.
|
|
37081
37153
|
*/
|
|
37082
|
-
hasIn(
|
|
37083
|
-
const [key, ...rest] =
|
|
37154
|
+
hasIn(path88) {
|
|
37155
|
+
const [key, ...rest] = path88;
|
|
37084
37156
|
if (rest.length === 0)
|
|
37085
37157
|
return this.has(key);
|
|
37086
37158
|
const node2 = this.get(key, true);
|
|
@@ -37090,8 +37162,8 @@ var require_Collection = __commonJS({
|
|
|
37090
37162
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
37091
37163
|
* boolean to add/remove the item from the set.
|
|
37092
37164
|
*/
|
|
37093
|
-
setIn(
|
|
37094
|
-
const [key, ...rest] =
|
|
37165
|
+
setIn(path88, value) {
|
|
37166
|
+
const [key, ...rest] = path88;
|
|
37095
37167
|
if (rest.length === 0) {
|
|
37096
37168
|
this.set(key, value);
|
|
37097
37169
|
} else {
|
|
@@ -39606,9 +39678,9 @@ var require_Document = __commonJS({
|
|
|
39606
39678
|
this.contents.add(value);
|
|
39607
39679
|
}
|
|
39608
39680
|
/** Adds a value to the document. */
|
|
39609
|
-
addIn(
|
|
39681
|
+
addIn(path88, value) {
|
|
39610
39682
|
if (assertCollection(this.contents))
|
|
39611
|
-
this.contents.addIn(
|
|
39683
|
+
this.contents.addIn(path88, value);
|
|
39612
39684
|
}
|
|
39613
39685
|
/**
|
|
39614
39686
|
* Create a new `Alias` node, ensuring that the target `node` has the required anchor.
|
|
@@ -39683,14 +39755,14 @@ var require_Document = __commonJS({
|
|
|
39683
39755
|
* Removes a value from the document.
|
|
39684
39756
|
* @returns `true` if the item was found and removed.
|
|
39685
39757
|
*/
|
|
39686
|
-
deleteIn(
|
|
39687
|
-
if (Collection.isEmptyPath(
|
|
39758
|
+
deleteIn(path88) {
|
|
39759
|
+
if (Collection.isEmptyPath(path88)) {
|
|
39688
39760
|
if (this.contents == null)
|
|
39689
39761
|
return false;
|
|
39690
39762
|
this.contents = null;
|
|
39691
39763
|
return true;
|
|
39692
39764
|
}
|
|
39693
|
-
return assertCollection(this.contents) ? this.contents.deleteIn(
|
|
39765
|
+
return assertCollection(this.contents) ? this.contents.deleteIn(path88) : false;
|
|
39694
39766
|
}
|
|
39695
39767
|
/**
|
|
39696
39768
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
@@ -39705,10 +39777,10 @@ var require_Document = __commonJS({
|
|
|
39705
39777
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
39706
39778
|
* `true` (collections are always returned intact).
|
|
39707
39779
|
*/
|
|
39708
|
-
getIn(
|
|
39709
|
-
if (Collection.isEmptyPath(
|
|
39780
|
+
getIn(path88, keepScalar) {
|
|
39781
|
+
if (Collection.isEmptyPath(path88))
|
|
39710
39782
|
return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
|
|
39711
|
-
return identity.isCollection(this.contents) ? this.contents.getIn(
|
|
39783
|
+
return identity.isCollection(this.contents) ? this.contents.getIn(path88, keepScalar) : void 0;
|
|
39712
39784
|
}
|
|
39713
39785
|
/**
|
|
39714
39786
|
* Checks if the document includes a value with the key `key`.
|
|
@@ -39719,10 +39791,10 @@ var require_Document = __commonJS({
|
|
|
39719
39791
|
/**
|
|
39720
39792
|
* Checks if the document includes a value at `path`.
|
|
39721
39793
|
*/
|
|
39722
|
-
hasIn(
|
|
39723
|
-
if (Collection.isEmptyPath(
|
|
39794
|
+
hasIn(path88) {
|
|
39795
|
+
if (Collection.isEmptyPath(path88))
|
|
39724
39796
|
return this.contents !== void 0;
|
|
39725
|
-
return identity.isCollection(this.contents) ? this.contents.hasIn(
|
|
39797
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path88) : false;
|
|
39726
39798
|
}
|
|
39727
39799
|
/**
|
|
39728
39800
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -39739,13 +39811,13 @@ var require_Document = __commonJS({
|
|
|
39739
39811
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
39740
39812
|
* boolean to add/remove the item from the set.
|
|
39741
39813
|
*/
|
|
39742
|
-
setIn(
|
|
39743
|
-
if (Collection.isEmptyPath(
|
|
39814
|
+
setIn(path88, value) {
|
|
39815
|
+
if (Collection.isEmptyPath(path88)) {
|
|
39744
39816
|
this.contents = value;
|
|
39745
39817
|
} else if (this.contents == null) {
|
|
39746
|
-
this.contents = Collection.collectionFromPath(this.schema, Array.from(
|
|
39818
|
+
this.contents = Collection.collectionFromPath(this.schema, Array.from(path88), value);
|
|
39747
39819
|
} else if (assertCollection(this.contents)) {
|
|
39748
|
-
this.contents.setIn(
|
|
39820
|
+
this.contents.setIn(path88, value);
|
|
39749
39821
|
}
|
|
39750
39822
|
}
|
|
39751
39823
|
/**
|
|
@@ -41706,9 +41778,9 @@ var require_cst_visit = __commonJS({
|
|
|
41706
41778
|
visit2.BREAK = BREAK;
|
|
41707
41779
|
visit2.SKIP = SKIP;
|
|
41708
41780
|
visit2.REMOVE = REMOVE;
|
|
41709
|
-
visit2.itemAtPath = (cst,
|
|
41781
|
+
visit2.itemAtPath = (cst, path88) => {
|
|
41710
41782
|
let item = cst;
|
|
41711
|
-
for (const [field2, index] of
|
|
41783
|
+
for (const [field2, index] of path88) {
|
|
41712
41784
|
const tok = item?.[field2];
|
|
41713
41785
|
if (tok && "items" in tok) {
|
|
41714
41786
|
item = tok.items[index];
|
|
@@ -41717,23 +41789,23 @@ var require_cst_visit = __commonJS({
|
|
|
41717
41789
|
}
|
|
41718
41790
|
return item;
|
|
41719
41791
|
};
|
|
41720
|
-
visit2.parentCollection = (cst,
|
|
41721
|
-
const parent = visit2.itemAtPath(cst,
|
|
41722
|
-
const field2 =
|
|
41792
|
+
visit2.parentCollection = (cst, path88) => {
|
|
41793
|
+
const parent = visit2.itemAtPath(cst, path88.slice(0, -1));
|
|
41794
|
+
const field2 = path88[path88.length - 1][0];
|
|
41723
41795
|
const coll = parent?.[field2];
|
|
41724
41796
|
if (coll && "items" in coll)
|
|
41725
41797
|
return coll;
|
|
41726
41798
|
throw new Error("Parent collection not found");
|
|
41727
41799
|
};
|
|
41728
|
-
function _visit(
|
|
41729
|
-
let ctrl = visitor(item,
|
|
41800
|
+
function _visit(path88, item, visitor) {
|
|
41801
|
+
let ctrl = visitor(item, path88);
|
|
41730
41802
|
if (typeof ctrl === "symbol")
|
|
41731
41803
|
return ctrl;
|
|
41732
41804
|
for (const field2 of ["key", "value"]) {
|
|
41733
41805
|
const token2 = item[field2];
|
|
41734
41806
|
if (token2 && "items" in token2) {
|
|
41735
41807
|
for (let i = 0; i < token2.items.length; ++i) {
|
|
41736
|
-
const ci = _visit(Object.freeze(
|
|
41808
|
+
const ci = _visit(Object.freeze(path88.concat([[field2, i]])), token2.items[i], visitor);
|
|
41737
41809
|
if (typeof ci === "number")
|
|
41738
41810
|
i = ci - 1;
|
|
41739
41811
|
else if (ci === BREAK)
|
|
@@ -41744,10 +41816,10 @@ var require_cst_visit = __commonJS({
|
|
|
41744
41816
|
}
|
|
41745
41817
|
}
|
|
41746
41818
|
if (typeof ctrl === "function" && field2 === "key")
|
|
41747
|
-
ctrl = ctrl(item,
|
|
41819
|
+
ctrl = ctrl(item, path88);
|
|
41748
41820
|
}
|
|
41749
41821
|
}
|
|
41750
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
41822
|
+
return typeof ctrl === "function" ? ctrl(item, path88) : ctrl;
|
|
41751
41823
|
}
|
|
41752
41824
|
exports.visit = visit2;
|
|
41753
41825
|
}
|
|
@@ -43049,14 +43121,14 @@ var require_parser = __commonJS({
|
|
|
43049
43121
|
case "scalar":
|
|
43050
43122
|
case "single-quoted-scalar":
|
|
43051
43123
|
case "double-quoted-scalar": {
|
|
43052
|
-
const
|
|
43124
|
+
const fs90 = this.flowScalar(this.type);
|
|
43053
43125
|
if (atNextItem || it.value) {
|
|
43054
|
-
map3.items.push({ start, key:
|
|
43126
|
+
map3.items.push({ start, key: fs90, sep: [] });
|
|
43055
43127
|
this.onKeyLine = true;
|
|
43056
43128
|
} else if (it.sep) {
|
|
43057
|
-
this.stack.push(
|
|
43129
|
+
this.stack.push(fs90);
|
|
43058
43130
|
} else {
|
|
43059
|
-
Object.assign(it, { key:
|
|
43131
|
+
Object.assign(it, { key: fs90, sep: [] });
|
|
43060
43132
|
this.onKeyLine = true;
|
|
43061
43133
|
}
|
|
43062
43134
|
return;
|
|
@@ -43184,13 +43256,13 @@ var require_parser = __commonJS({
|
|
|
43184
43256
|
case "scalar":
|
|
43185
43257
|
case "single-quoted-scalar":
|
|
43186
43258
|
case "double-quoted-scalar": {
|
|
43187
|
-
const
|
|
43259
|
+
const fs90 = this.flowScalar(this.type);
|
|
43188
43260
|
if (!it || it.value)
|
|
43189
|
-
fc.items.push({ start: [], key:
|
|
43261
|
+
fc.items.push({ start: [], key: fs90, sep: [] });
|
|
43190
43262
|
else if (it.sep)
|
|
43191
|
-
this.stack.push(
|
|
43263
|
+
this.stack.push(fs90);
|
|
43192
43264
|
else
|
|
43193
|
-
Object.assign(it, { key:
|
|
43265
|
+
Object.assign(it, { key: fs90, sep: [] });
|
|
43194
43266
|
return;
|
|
43195
43267
|
}
|
|
43196
43268
|
case "flow-map-end":
|
|
@@ -43609,7 +43681,7 @@ function landSections(body, previews) {
|
|
|
43609
43681
|
}
|
|
43610
43682
|
function parseStudioFile(id2, source2, from, { requirePreviewCopy = false, requireLand = false } = {}) {
|
|
43611
43683
|
const problems = [];
|
|
43612
|
-
const fail = (offset,
|
|
43684
|
+
const fail = (offset, path88, code, message, hint2) => problems.push({ file: from, ...sourcePosition(source2, offset), path: path88, code, message, hint: hint2 });
|
|
43613
43685
|
const result = () => ({ problem: problems.map((p) => `${p.file}:${p.line}:${p.column} ${p.path}: ${p.code} \u2014 ${p.message}. ${p.hint}`).join("\n"), problems });
|
|
43614
43686
|
if (!STUDIO_ID.test(id2)) fail(0, "id", "studio-schema", `Invalid Studio ID ${id2}`, "Use lowercase letters, digits and dashes.");
|
|
43615
43687
|
const front = /^---\r?\n([^]*?)\r?\n---(?:\r?\n|$)/.exec(source2);
|
|
@@ -43778,11 +43850,11 @@ function inspect(value, official, { allowLegacyPreviewCopy, allowLegacyLand } =
|
|
|
43778
43850
|
};
|
|
43779
43851
|
if (!value || typeof value !== "object" || Array.isArray(value)) return fail("files", "must be an object of path \u2192 text");
|
|
43780
43852
|
const files = Object.fromEntries(Object.entries(value).filter(([file2]) => file2 !== VERSION_FILE));
|
|
43781
|
-
const
|
|
43782
|
-
if (
|
|
43853
|
+
const entries2 = Object.entries(files);
|
|
43854
|
+
if (entries2.length > FILE_LIMITS.count) return fail("files", `holds at most ${FILE_LIMITS.count} files`, true);
|
|
43783
43855
|
let total = 0;
|
|
43784
43856
|
const skills = /* @__PURE__ */ new Set();
|
|
43785
|
-
for (const [file2, text5] of
|
|
43857
|
+
for (const [file2, text5] of entries2) {
|
|
43786
43858
|
if (typeof text5 !== "string" || text5.includes("\0")) {
|
|
43787
43859
|
fail(file2, "is not a text file");
|
|
43788
43860
|
continue;
|
|
@@ -43985,11 +44057,19 @@ function pinMissing() {
|
|
|
43985
44057
|
const pin = readPin(task);
|
|
43986
44058
|
return !(pin && readVersion(pin.studio, pin.version));
|
|
43987
44059
|
}
|
|
44060
|
+
function invalid(expected) {
|
|
44061
|
+
const problem = invalidResponse(expected);
|
|
44062
|
+
return { ...problem, ok: false, error: problem.message };
|
|
44063
|
+
}
|
|
44064
|
+
function isStudioFiles(value) {
|
|
44065
|
+
return isRecord(value) && hasText(value["STUDIO.md"]) && Object.entries(value).every(([file2, text5]) => typeof text5 === "string" && !/[\\:\0]/.test(file2) && file2.split("/").every((part) => !!part && part !== "." && part !== ".."));
|
|
44066
|
+
}
|
|
43988
44067
|
async function versionOf(id2, version2) {
|
|
43989
44068
|
const held4 = readVersion(id2, version2);
|
|
43990
44069
|
if (held4) return { ok: true, value: held4 };
|
|
43991
44070
|
const read5 = await call("GET", `/v1/studios/${encodeURIComponent(id2)}`);
|
|
43992
44071
|
if (!read5.ok) return read5;
|
|
44072
|
+
if (read5.value.id !== id2 || !isStudioVersion(read5.value.version) || !isStudioFiles(read5.value.files)) return invalid("a valid Studio version");
|
|
43993
44073
|
saveVersion(read5.value);
|
|
43994
44074
|
return read5;
|
|
43995
44075
|
}
|
|
@@ -43999,55 +44079,68 @@ async function pinTask(task) {
|
|
|
43999
44079
|
if (held4 && "def" in parseStudioFile("studio", held4.files["STUDIO.md"] ?? "", "STUDIO.md")) return { ok: true, value: held4 };
|
|
44000
44080
|
const read5 = await call("GET", `/v1/tasks/${encodeURIComponent(task)}/studio`);
|
|
44001
44081
|
if (!read5.ok) return read5;
|
|
44082
|
+
if (!hasText(read5.value.studio) || !isStudioVersion(read5.value.version) || !isStudioFiles(read5.value.files)) return invalid("the task\u2019s Studio version");
|
|
44002
44083
|
const value = { id: read5.value.studio, version: read5.value.version, name: read5.value.name, files: read5.value.files, historicalPreviews: read5.value.historicalPreviews };
|
|
44003
44084
|
savePin(task, value);
|
|
44004
44085
|
return { ok: true, value };
|
|
44005
44086
|
}
|
|
44006
44087
|
async function syncStudios(force = false) {
|
|
44007
|
-
|
|
44088
|
+
verification = { cached: false };
|
|
44008
44089
|
const project2 = boardProject();
|
|
44009
44090
|
if (devFolder() || !project2 || !cloudConfigured() || !readSession()) return;
|
|
44010
44091
|
const task = workspaceTask();
|
|
44011
44092
|
const held4 = readJson(listFile(project2));
|
|
44012
44093
|
const fresh = held4 && Date.now() - Date.parse(held4.at) < FRESH_MS;
|
|
44094
|
+
const failed2 = (failure2) => {
|
|
44095
|
+
verification = { cached: !!held4, problem: {
|
|
44096
|
+
code: failure2.code ?? "unreachable",
|
|
44097
|
+
message: failure2.error,
|
|
44098
|
+
status: failure2.status,
|
|
44099
|
+
retryable: failure2.retryable ?? temporaryCloudFailure(failure2)
|
|
44100
|
+
} };
|
|
44101
|
+
};
|
|
44013
44102
|
try {
|
|
44014
44103
|
if (task) {
|
|
44015
44104
|
const pinned2 = await pinTask(task);
|
|
44016
|
-
if (!pinned2.ok
|
|
44105
|
+
if (!pinned2.ok) failed2(pinned2);
|
|
44106
|
+
}
|
|
44107
|
+
if (fresh && !force) {
|
|
44108
|
+
verification.cached = true;
|
|
44109
|
+
return;
|
|
44017
44110
|
}
|
|
44018
|
-
if (fresh && !force) return;
|
|
44019
44111
|
let workspace2 = held4?.workspace;
|
|
44020
44112
|
if (!workspace2) {
|
|
44021
44113
|
const read5 = await call("GET", `/v1/projects/${encodeURIComponent(project2)}`);
|
|
44022
|
-
if (!read5.ok)
|
|
44023
|
-
|
|
44024
|
-
return;
|
|
44025
|
-
}
|
|
44114
|
+
if (!read5.ok) return failed2(read5);
|
|
44115
|
+
if (!hasText(read5.value.workspace)) return failed2({ ok: false, error: "Cloud did not return a workspace.", code: "invalid_response" });
|
|
44026
44116
|
workspace2 = read5.value.workspace;
|
|
44027
44117
|
}
|
|
44028
44118
|
const listed = [];
|
|
44119
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
44029
44120
|
let after2 = null;
|
|
44030
44121
|
do {
|
|
44031
44122
|
const page = await call(
|
|
44032
44123
|
"GET",
|
|
44033
44124
|
`/v1/studios?workspace=${encodeURIComponent(workspace2)}&limit=100${after2 ? `&after=${encodeURIComponent(after2)}` : ""}`
|
|
44034
44125
|
);
|
|
44035
|
-
if (!page.ok)
|
|
44036
|
-
|
|
44037
|
-
return;
|
|
44126
|
+
if (!page.ok) return failed2(page);
|
|
44127
|
+
if (!Array.isArray(page.value.data) || page.value.data.some((w) => !isRecord(w) || !hasText(w.id) || !isStudioVersion(w.version)) || page.value.next !== null && (!hasText(page.value.next) || cursors.has(page.value.next))) {
|
|
44128
|
+
return failed2({ ok: false, error: "Cloud did not return a valid Studio list.", code: "invalid_response" });
|
|
44038
44129
|
}
|
|
44039
|
-
listed.push(...page.value.data.map((
|
|
44130
|
+
listed.push(...page.value.data.map(({ id: id2, version: version2 }) => ({ id: id2, version: version2 })));
|
|
44040
44131
|
after2 = page.value.next;
|
|
44132
|
+
if (after2) cursors.add(after2);
|
|
44041
44133
|
} while (after2);
|
|
44042
44134
|
const kept2 = [];
|
|
44043
44135
|
for (const w of listed) {
|
|
44044
44136
|
const read5 = await versionOf(w.id, w.version);
|
|
44045
|
-
if (read5.ok)
|
|
44046
|
-
|
|
44137
|
+
if (!read5.ok) return failed2(read5);
|
|
44138
|
+
kept2.push({ id: read5.value.id, version: read5.value.version });
|
|
44047
44139
|
}
|
|
44048
44140
|
writeJson(listFile(project2), { at: (/* @__PURE__ */ new Date()).toISOString(), workspace: workspace2, studios: kept2 });
|
|
44049
|
-
|
|
44050
|
-
|
|
44141
|
+
verification.cached = false;
|
|
44142
|
+
} catch (error62) {
|
|
44143
|
+
failed2({ ok: false, code: "studio_cache_error", error: error62 instanceof Error ? error62.message : String(error62) });
|
|
44051
44144
|
}
|
|
44052
44145
|
}
|
|
44053
44146
|
function readFlows() {
|
|
@@ -44090,13 +44183,14 @@ function taskHistoricalPreviews() {
|
|
|
44090
44183
|
const task = workspaceTask();
|
|
44091
44184
|
return task ? Object.keys(readPin(task)?.historicalPreviews ?? {}) : [];
|
|
44092
44185
|
}
|
|
44093
|
-
var DEV, FRESH_MS, root, safe, versionFile, listFile, pinFile, readVersion, readPin, boardProject, devFolder, NEEDS_CLOUD, NOT_DOWNLOADED,
|
|
44186
|
+
var DEV, FRESH_MS, root, safe, versionFile, listFile, pinFile, readVersion, readPin, boardProject, devFolder, NEEDS_CLOUD, NOT_DOWNLOADED, verification, studioVerification, isStudioVersion, flowOf, sources, flows, cloudStudioSources, cloudFlows;
|
|
44094
44187
|
var init_cloud_studios = __esm({
|
|
44095
44188
|
"../cli/src/lib/agent/cloud-studios.ts"() {
|
|
44096
44189
|
"use strict";
|
|
44097
44190
|
init_board_files();
|
|
44098
44191
|
init_pack();
|
|
44099
44192
|
init_tasks();
|
|
44193
|
+
init_response();
|
|
44100
44194
|
init_config();
|
|
44101
44195
|
init_session();
|
|
44102
44196
|
init_file_memo();
|
|
@@ -44116,8 +44210,9 @@ var init_cloud_studios = __esm({
|
|
|
44116
44210
|
devFolder = () => process.env[DEV]?.trim() || "";
|
|
44117
44211
|
NEEDS_CLOUD = "Sign in to run studios.";
|
|
44118
44212
|
NOT_DOWNLOADED = "This studio isn't downloaded yet. Connect and try again.";
|
|
44119
|
-
|
|
44120
|
-
|
|
44213
|
+
verification = { cached: false };
|
|
44214
|
+
studioVerification = () => verification;
|
|
44215
|
+
isStudioVersion = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
44121
44216
|
flowOf = (held4) => {
|
|
44122
44217
|
const id2 = studioName(held4.id);
|
|
44123
44218
|
const read5 = parseStudioFile(id2, held4.files["STUDIO.md"] ?? "", `the \`${id2}\` studio`);
|
|
@@ -44212,8 +44307,8 @@ function agentLines(agent, language2 = readLanguage()) {
|
|
|
44212
44307
|
description: said2?.description || agent.description
|
|
44213
44308
|
};
|
|
44214
44309
|
}
|
|
44215
|
-
function settingValues(name, settings,
|
|
44216
|
-
const entry =
|
|
44310
|
+
function settingValues(name, settings, entries2) {
|
|
44311
|
+
const entry = entries2[name];
|
|
44217
44312
|
const values = {};
|
|
44218
44313
|
const notes = [];
|
|
44219
44314
|
for (const setting of settings) {
|
|
@@ -44232,8 +44327,8 @@ function settingValues(name, settings, entries) {
|
|
|
44232
44327
|
}
|
|
44233
44328
|
return { values, notes };
|
|
44234
44329
|
}
|
|
44235
|
-
function roleSettingsBlock(role,
|
|
44236
|
-
const { values } = roleSettings(role,
|
|
44330
|
+
function roleSettingsBlock(role, entries2 = specAgentEntries()) {
|
|
44331
|
+
const { values } = roleSettings(role, entries2);
|
|
44237
44332
|
const lines = (role.settings ?? []).map((setting) => setting.choices.find((c) => c.value === values[setting.key])?.prompt).filter((line) => Boolean(line));
|
|
44238
44333
|
return lines.length ? ["Your settings on this board:", ...lines.map((line) => `- ${line}`)].join("\n") : "";
|
|
44239
44334
|
}
|
|
@@ -44252,7 +44347,7 @@ var init_agents = __esm({
|
|
|
44252
44347
|
findSpecAgent = (name) => {
|
|
44253
44348
|
return specAgents().find((a) => a.name === name) ?? null;
|
|
44254
44349
|
};
|
|
44255
|
-
roleSettings = (role,
|
|
44350
|
+
roleSettings = (role, entries2 = specAgentEntries()) => settingValues(role.name, role.settings ?? [], entries2);
|
|
44256
44351
|
}
|
|
44257
44352
|
});
|
|
44258
44353
|
|
|
@@ -44632,9 +44727,9 @@ function readMap(lines, start, indent2) {
|
|
|
44632
44727
|
}
|
|
44633
44728
|
function readScalar(value) {
|
|
44634
44729
|
if (value.startsWith("{") && value.endsWith("}")) {
|
|
44635
|
-
const
|
|
44730
|
+
const entries2 = value.slice(1, -1).match(/(?:[^,"']|"(?:\\.|[^"\\])*"|'(?:''|[^'])*')+/g) ?? [];
|
|
44636
44731
|
const out = {};
|
|
44637
|
-
for (const entry of
|
|
44732
|
+
for (const entry of entries2) {
|
|
44638
44733
|
const pair = /^\s*([^:]+):\s*(.+)$/.exec(entry);
|
|
44639
44734
|
if (!pair) return value;
|
|
44640
44735
|
out[unquote(pair[1].trim())] = readScalar(pair[2].trim());
|
|
@@ -44894,13 +44989,13 @@ function readBundled(folder2) {
|
|
|
44894
44989
|
return parseSpecAgent(text5, label2, file2, official, list3);
|
|
44895
44990
|
}
|
|
44896
44991
|
function projectFolders(root2) {
|
|
44897
|
-
let
|
|
44992
|
+
let entries2;
|
|
44898
44993
|
try {
|
|
44899
|
-
|
|
44994
|
+
entries2 = fs33.readdirSync(root2, { withFileTypes: true });
|
|
44900
44995
|
} catch {
|
|
44901
44996
|
return [];
|
|
44902
44997
|
}
|
|
44903
|
-
return
|
|
44998
|
+
return entries2.filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name).sort();
|
|
44904
44999
|
}
|
|
44905
45000
|
function agentFileReader(dir) {
|
|
44906
45001
|
return (relative) => {
|
|
@@ -44916,13 +45011,13 @@ function agentFileReader(dir) {
|
|
|
44916
45011
|
};
|
|
44917
45012
|
}
|
|
44918
45013
|
function walkFolder(dir, prefix) {
|
|
44919
|
-
let
|
|
45014
|
+
let entries2;
|
|
44920
45015
|
try {
|
|
44921
|
-
|
|
45016
|
+
entries2 = fs33.readdirSync(dir, { withFileTypes: true });
|
|
44922
45017
|
} catch {
|
|
44923
45018
|
return [];
|
|
44924
45019
|
}
|
|
44925
|
-
return
|
|
45020
|
+
return entries2.flatMap((e) => {
|
|
44926
45021
|
const here = prefix ? `${prefix}/${e.name}` : e.name;
|
|
44927
45022
|
return e.isDirectory() ? walkFolder(path37.join(dir, e.name), here) : [here];
|
|
44928
45023
|
});
|
|
@@ -49058,13 +49153,13 @@ function freeName(dir, wanted) {
|
|
|
49058
49153
|
return name;
|
|
49059
49154
|
}
|
|
49060
49155
|
function readFolder(dir, lenient = false) {
|
|
49061
|
-
let
|
|
49156
|
+
let entries2;
|
|
49062
49157
|
try {
|
|
49063
|
-
|
|
49158
|
+
entries2 = fs46.readdirSync(dir, { withFileTypes: true });
|
|
49064
49159
|
} catch {
|
|
49065
49160
|
return [];
|
|
49066
49161
|
}
|
|
49067
|
-
return
|
|
49162
|
+
return entries2.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse3(path51.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
|
|
49068
49163
|
}
|
|
49069
49164
|
function readInbox() {
|
|
49070
49165
|
const signals = readFolder(TRIAGE);
|
|
@@ -49955,14 +50050,14 @@ function collectSources(sources2, card, host2) {
|
|
|
49955
50050
|
const active3 = /* @__PURE__ */ new Set();
|
|
49956
50051
|
const out = [];
|
|
49957
50052
|
const visit2 = (src, types, owner, partial2 = false) => {
|
|
49958
|
-
const
|
|
50053
|
+
const path88 = src.replace(/[?#].*$/, "");
|
|
49959
50054
|
let resolved;
|
|
49960
50055
|
try {
|
|
49961
|
-
resolved = host2.resolve(
|
|
50056
|
+
resolved = host2.resolve(path88, owner);
|
|
49962
50057
|
} catch (error62) {
|
|
49963
50058
|
if (owner !== card) return { key: null, error: why(error62) };
|
|
49964
50059
|
if (!nodes.has(src)) {
|
|
49965
|
-
const node3 = { key: src, file: null, kind: kindAt(
|
|
50060
|
+
const node3 = { key: src, file: null, kind: kindAt(path88, types), error: why(error62), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
|
|
49966
50061
|
nodes.set(src, node3);
|
|
49967
50062
|
out.push(node3);
|
|
49968
50063
|
}
|
|
@@ -53642,8 +53737,8 @@ var require_command = __commonJS({
|
|
|
53642
53737
|
"../cli/node_modules/commander/lib/command.js"(exports) {
|
|
53643
53738
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
53644
53739
|
var childProcess = __require("node:child_process");
|
|
53645
|
-
var
|
|
53646
|
-
var
|
|
53740
|
+
var path88 = __require("node:path");
|
|
53741
|
+
var fs90 = __require("node:fs");
|
|
53647
53742
|
var process2 = __require("node:process");
|
|
53648
53743
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
53649
53744
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -54624,7 +54719,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
54624
54719
|
* @param {string} subcommandName
|
|
54625
54720
|
*/
|
|
54626
54721
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
54627
|
-
if (
|
|
54722
|
+
if (fs90.existsSync(executableFile)) return;
|
|
54628
54723
|
const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory";
|
|
54629
54724
|
const executableMissing = `'${executableFile}' does not exist
|
|
54630
54725
|
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
@@ -54642,11 +54737,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
54642
54737
|
let launchWithNode = false;
|
|
54643
54738
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
54644
54739
|
function findFile(baseDir, baseName) {
|
|
54645
|
-
const localBin =
|
|
54646
|
-
if (
|
|
54647
|
-
if (sourceExt.includes(
|
|
54740
|
+
const localBin = path88.resolve(baseDir, baseName);
|
|
54741
|
+
if (fs90.existsSync(localBin)) return localBin;
|
|
54742
|
+
if (sourceExt.includes(path88.extname(baseName))) return void 0;
|
|
54648
54743
|
const foundExt = sourceExt.find(
|
|
54649
|
-
(ext) =>
|
|
54744
|
+
(ext) => fs90.existsSync(`${localBin}${ext}`)
|
|
54650
54745
|
);
|
|
54651
54746
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
54652
54747
|
return void 0;
|
|
@@ -54658,21 +54753,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
54658
54753
|
if (this._scriptPath) {
|
|
54659
54754
|
let resolvedScriptPath;
|
|
54660
54755
|
try {
|
|
54661
|
-
resolvedScriptPath =
|
|
54756
|
+
resolvedScriptPath = fs90.realpathSync(this._scriptPath);
|
|
54662
54757
|
} catch {
|
|
54663
54758
|
resolvedScriptPath = this._scriptPath;
|
|
54664
54759
|
}
|
|
54665
|
-
executableDir =
|
|
54666
|
-
|
|
54760
|
+
executableDir = path88.resolve(
|
|
54761
|
+
path88.dirname(resolvedScriptPath),
|
|
54667
54762
|
executableDir
|
|
54668
54763
|
);
|
|
54669
54764
|
}
|
|
54670
54765
|
if (executableDir) {
|
|
54671
54766
|
let localFile = findFile(executableDir, executableFile);
|
|
54672
54767
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
54673
|
-
const legacyName =
|
|
54768
|
+
const legacyName = path88.basename(
|
|
54674
54769
|
this._scriptPath,
|
|
54675
|
-
|
|
54770
|
+
path88.extname(this._scriptPath)
|
|
54676
54771
|
);
|
|
54677
54772
|
if (legacyName !== this._name) {
|
|
54678
54773
|
localFile = findFile(
|
|
@@ -54683,7 +54778,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
54683
54778
|
}
|
|
54684
54779
|
executableFile = localFile || executableFile;
|
|
54685
54780
|
}
|
|
54686
|
-
launchWithNode = sourceExt.includes(
|
|
54781
|
+
launchWithNode = sourceExt.includes(path88.extname(executableFile));
|
|
54687
54782
|
let proc;
|
|
54688
54783
|
if (process2.platform !== "win32") {
|
|
54689
54784
|
if (launchWithNode) {
|
|
@@ -55530,7 +55625,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
55530
55625
|
* @return {Command}
|
|
55531
55626
|
*/
|
|
55532
55627
|
nameFromFilename(filename) {
|
|
55533
|
-
this._name =
|
|
55628
|
+
this._name = path88.basename(filename, path88.extname(filename));
|
|
55534
55629
|
return this;
|
|
55535
55630
|
}
|
|
55536
55631
|
/**
|
|
@@ -55544,9 +55639,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
55544
55639
|
* @param {string} [path]
|
|
55545
55640
|
* @return {(string|null|Command)}
|
|
55546
55641
|
*/
|
|
55547
|
-
executableDir(
|
|
55548
|
-
if (
|
|
55549
|
-
this._executableDir =
|
|
55642
|
+
executableDir(path89) {
|
|
55643
|
+
if (path89 === void 0) return this._executableDir;
|
|
55644
|
+
this._executableDir = path89;
|
|
55550
55645
|
return this;
|
|
55551
55646
|
}
|
|
55552
55647
|
/**
|
|
@@ -56739,7 +56834,8 @@ function report(err, { program: program2, json: json2, box = null }) {
|
|
|
56739
56834
|
if (json2) {
|
|
56740
56835
|
answer({ ok: false, error: { kind: err.kind, message: err.message, ...err.details }, ...prose(box) });
|
|
56741
56836
|
} else {
|
|
56742
|
-
|
|
56837
|
+
const code = typeof err.details.code === "string" ? `[${err.details.code}] ` : "";
|
|
56838
|
+
console.error(err.bare ? `${err.message}${code ? ` [${err.details.code}]` : ""}` : `${program2}: ${code}${err.message}`);
|
|
56743
56839
|
}
|
|
56744
56840
|
return err.exitCode;
|
|
56745
56841
|
}
|
|
@@ -56760,6 +56856,31 @@ var init_board_cli = __esm({
|
|
|
56760
56856
|
}
|
|
56761
56857
|
});
|
|
56762
56858
|
|
|
56859
|
+
// ../cli/src/lib/cloud/task-operation.ts
|
|
56860
|
+
import fs67 from "node:fs";
|
|
56861
|
+
import path70 from "node:path";
|
|
56862
|
+
function readRemoval(board2, task) {
|
|
56863
|
+
try {
|
|
56864
|
+
const value = JSON.parse(fs67.readFileSync(removalFile(board2, task), "utf8"));
|
|
56865
|
+
if (["pending", "confirmed", "rejected"].includes(value.status) && typeof value.reason === "string" && typeof value.discard === "boolean") return value;
|
|
56866
|
+
} catch {
|
|
56867
|
+
}
|
|
56868
|
+
return null;
|
|
56869
|
+
}
|
|
56870
|
+
function writeRemoval(board2, task, removal) {
|
|
56871
|
+
const file2 = removalFile(board2, task);
|
|
56872
|
+
const temp = `${file2}.${process.pid}.tmp`;
|
|
56873
|
+
fs67.writeFileSync(temp, JSON.stringify(removal) + "\n");
|
|
56874
|
+
fs67.renameSync(temp, file2);
|
|
56875
|
+
}
|
|
56876
|
+
var removalFile;
|
|
56877
|
+
var init_task_operation = __esm({
|
|
56878
|
+
"../cli/src/lib/cloud/task-operation.ts"() {
|
|
56879
|
+
"use strict";
|
|
56880
|
+
removalFile = (board2, task) => path70.join(board2, ".sync", `${task}.removal.json`);
|
|
56881
|
+
}
|
|
56882
|
+
});
|
|
56883
|
+
|
|
56763
56884
|
// ../cli/src/lib/cloud/avatar.ts
|
|
56764
56885
|
async function heldAvatar(url2) {
|
|
56765
56886
|
if (!url2) return null;
|
|
@@ -56806,10 +56927,10 @@ var init_avatar = __esm({
|
|
|
56806
56927
|
});
|
|
56807
56928
|
|
|
56808
56929
|
// ../cli/src/lib/cloud/pro.ts
|
|
56809
|
-
import
|
|
56810
|
-
import
|
|
56930
|
+
import fs68 from "node:fs";
|
|
56931
|
+
import path71 from "node:path";
|
|
56811
56932
|
function forgetPro() {
|
|
56812
|
-
|
|
56933
|
+
fs68.rmSync(heldFile(), { force: true });
|
|
56813
56934
|
}
|
|
56814
56935
|
var FRESH_MS2, GRACE_MS, heldFile;
|
|
56815
56936
|
var init_pro = __esm({
|
|
@@ -56820,7 +56941,7 @@ var init_pro = __esm({
|
|
|
56820
56941
|
init_session();
|
|
56821
56942
|
FRESH_MS2 = 10 * 6e4;
|
|
56822
56943
|
GRACE_MS = 7 * 24 * 60 * 6e4;
|
|
56823
|
-
heldFile = () =>
|
|
56944
|
+
heldFile = () => path71.join(machineHome(), "pro.json");
|
|
56824
56945
|
}
|
|
56825
56946
|
});
|
|
56826
56947
|
|
|
@@ -56839,39 +56960,42 @@ async function readCloudAccount() {
|
|
|
56839
56960
|
configured: cloudConfigured()
|
|
56840
56961
|
};
|
|
56841
56962
|
if (!blank.configured) return { ...blank, message: NOT_CONFIGURED };
|
|
56963
|
+
const unverified = (problem2, state = "signed-in") => ({
|
|
56964
|
+
...blank,
|
|
56965
|
+
...held3(),
|
|
56966
|
+
state,
|
|
56967
|
+
...state === "signed-in" ? { error: problem2.message } : { message: problem2.message },
|
|
56968
|
+
verificationFailure: problem2
|
|
56969
|
+
});
|
|
56842
56970
|
const token2 = await accessToken();
|
|
56843
56971
|
if (!token2.ok) {
|
|
56844
56972
|
if (token2.reason === "signed-out") return blank;
|
|
56845
56973
|
if (token2.reason === "unreachable") {
|
|
56846
|
-
return {
|
|
56974
|
+
return unverified({ code: "unreachable", message: token2.error, retryable: true });
|
|
56847
56975
|
}
|
|
56848
|
-
return {
|
|
56976
|
+
return unverified({ code: "expired", message: token2.error ?? "Your Cloud sign-in has expired. Sign in again.", retryable: false }, "expired");
|
|
56849
56977
|
}
|
|
56850
56978
|
let response;
|
|
56851
56979
|
try {
|
|
56852
56980
|
response = await fetch(`${cloudEndpoints().api}/v1/session`, {
|
|
56853
|
-
headers: { authorization: `Bearer ${token2.token}` }
|
|
56981
|
+
headers: { authorization: `Bearer ${token2.token}` },
|
|
56982
|
+
signal: AbortSignal.timeout(2e4)
|
|
56854
56983
|
});
|
|
56855
56984
|
} catch (e) {
|
|
56856
|
-
return {
|
|
56857
|
-
...blank,
|
|
56858
|
-
...held3(),
|
|
56859
|
-
state: "signed-in",
|
|
56860
|
-
error: e instanceof Error ? e.message : String(e)
|
|
56861
|
-
};
|
|
56985
|
+
return unverified({ code: "unreachable", message: e instanceof Error ? e.message : String(e), retryable: true });
|
|
56862
56986
|
}
|
|
56863
|
-
const
|
|
56864
|
-
|
|
56865
|
-
|
|
56866
|
-
if (
|
|
56867
|
-
|
|
56868
|
-
|
|
56869
|
-
if (refusal2?.code === "not_admitted") {
|
|
56870
|
-
return { ...blank, ...held3(), state: "not-admitted", message: refusal2.message ?? null };
|
|
56871
|
-
}
|
|
56872
|
-
return { ...blank, ...held3(), state: "signed-in", error: refusal2?.message };
|
|
56987
|
+
const value = await readCloudJson(response);
|
|
56988
|
+
const problem = cloudProblem(response, value);
|
|
56989
|
+
if (problem) {
|
|
56990
|
+
if (problem.code === "unauthenticated") return unverified(problem, "expired");
|
|
56991
|
+
if (problem.code === "not_admitted") return unverified(problem, "not-admitted");
|
|
56992
|
+
return unverified(problem);
|
|
56873
56993
|
}
|
|
56874
|
-
|
|
56994
|
+
if (!isRecord(value) || !isRecord(value.session) || typeof value.session.admitted !== "boolean") {
|
|
56995
|
+
return unverified(invalidResponse("an account verification receipt"));
|
|
56996
|
+
}
|
|
56997
|
+
const body = value;
|
|
56998
|
+
const session = body.session;
|
|
56875
56999
|
const avatarUrl = session.avatar_url ?? session.avatarUrl ?? null;
|
|
56876
57000
|
const attested = {
|
|
56877
57001
|
handle: session.handle ?? null,
|
|
@@ -56907,12 +57031,13 @@ var init_account = __esm({
|
|
|
56907
57031
|
init_config();
|
|
56908
57032
|
init_pro();
|
|
56909
57033
|
init_session();
|
|
57034
|
+
init_response();
|
|
56910
57035
|
}
|
|
56911
57036
|
});
|
|
56912
57037
|
|
|
56913
57038
|
// ../cli/src/commands/cloud.ts
|
|
56914
|
-
import
|
|
56915
|
-
import
|
|
57039
|
+
import fs69 from "node:fs";
|
|
57040
|
+
import path72 from "node:path";
|
|
56916
57041
|
async function cmdCloud(args2, program2) {
|
|
56917
57042
|
const [sub] = args2;
|
|
56918
57043
|
if (sub === "sign-out") {
|
|
@@ -56927,6 +57052,16 @@ async function cmdCloud(args2, program2) {
|
|
|
56927
57052
|
);
|
|
56928
57053
|
}
|
|
56929
57054
|
const account = await readCloudAccount();
|
|
57055
|
+
if (account.verificationFailure) {
|
|
57056
|
+
if (account.handle || account.email) say(`Cached account: ${account.handle ? "@" + account.handle : account.email}`);
|
|
57057
|
+
throw cloudError(
|
|
57058
|
+
{
|
|
57059
|
+
...account.verificationFailure,
|
|
57060
|
+
message: `Cloud verification failed. Showing cached account details. ${account.verificationFailure.message}`
|
|
57061
|
+
},
|
|
57062
|
+
{ details: { cached: true, cloud: account } }
|
|
57063
|
+
);
|
|
57064
|
+
}
|
|
56930
57065
|
for (const line of report2(account, program2)) say(line);
|
|
56931
57066
|
return { cloud: account };
|
|
56932
57067
|
}
|
|
@@ -56974,10 +57109,10 @@ async function cloudImage(opts, program2) {
|
|
|
56974
57109
|
const prompt = opts.prompt.trim();
|
|
56975
57110
|
if (!prompt) usage("Missing the prompt.", line);
|
|
56976
57111
|
const references = opts.refs.map((file2) => {
|
|
56977
|
-
const type = REF_TYPES[
|
|
57112
|
+
const type = REF_TYPES[path72.extname(file2).toLowerCase()];
|
|
56978
57113
|
if (!type) usage(`--ref ${file2}: use a PNG, JPEG or WebP file.`, line);
|
|
56979
57114
|
try {
|
|
56980
|
-
return `data:${type};base64,${
|
|
57115
|
+
return `data:${type};base64,${fs69.readFileSync(file2).toString("base64")}`;
|
|
56981
57116
|
} catch (e) {
|
|
56982
57117
|
usage(`--ref ${file2}: ${e instanceof Error ? e.message : String(e)}`, line);
|
|
56983
57118
|
}
|
|
@@ -57056,40 +57191,69 @@ async function cloudMusic(opts, program2) {
|
|
|
57056
57191
|
label: () => `${seconds}s`
|
|
57057
57192
|
});
|
|
57058
57193
|
}
|
|
57059
|
-
function refuse2(m, fallback) {
|
|
57060
|
-
|
|
57194
|
+
function refuse2(m, fallback, problem, exitCode = 1) {
|
|
57195
|
+
const message = [m.zh, m.en, problem.message, fallback.zh, fallback.en].filter(Boolean).join("\n");
|
|
57196
|
+
throw cloudError({ ...problem, message }, { bare: true, exitCode });
|
|
57061
57197
|
}
|
|
57062
57198
|
async function generate(g) {
|
|
57063
57199
|
const token2 = await accessToken();
|
|
57064
|
-
if (!token2.ok) refuse2(SAID[token2.reason], g.fallback
|
|
57200
|
+
if (!token2.ok) refuse2(SAID[token2.reason], g.fallback, {
|
|
57201
|
+
code: token2.reason.replace("-", "_"),
|
|
57202
|
+
message: "error" in token2 ? token2.error ?? "" : "",
|
|
57203
|
+
retryable: token2.reason === "unreachable"
|
|
57204
|
+
});
|
|
57065
57205
|
const task = workspaceTask();
|
|
57066
57206
|
let res;
|
|
57067
57207
|
try {
|
|
57068
57208
|
res = await fetch(`${cloudEndpoints().api}${g.endpoint}`, {
|
|
57069
57209
|
method: "POST",
|
|
57070
|
-
// The task this spends credits for, inside a Runner task (#629).
|
|
57071
57210
|
headers: { authorization: `Bearer ${token2.token}`, "content-type": "application/json", ...task ? { "x-wildcrane-task": task } : {} },
|
|
57072
57211
|
body: JSON.stringify(g.body)
|
|
57073
57212
|
});
|
|
57074
57213
|
} catch {
|
|
57075
|
-
refuse2(SAID.unreachable, g.fallback);
|
|
57214
|
+
refuse2(SAID.unreachable, g.fallback, { code: "unreachable", message: "", retryable: true });
|
|
57076
57215
|
}
|
|
57077
|
-
|
|
57078
|
-
|
|
57079
|
-
|
|
57080
|
-
if (
|
|
57081
|
-
if (
|
|
57082
|
-
|
|
57216
|
+
const contentType = res.headers.get("content-type") ?? "";
|
|
57217
|
+
const problem = !res.ok || /^application\/(?:[\w.+-]+\+)?json(?:;|$)/i.test(contentType) ? cloudProblem(res, await readCloudJson(res)) ?? invalidResponse("a complete media file") : null;
|
|
57218
|
+
if (problem) {
|
|
57219
|
+
if (res.status === 401) refuse2(SAID.expired, g.fallback, problem);
|
|
57220
|
+
if (problem.code === "pro_required") refuse2(g.pro_required, g.fallback, problem);
|
|
57221
|
+
if (problem.code === "credits_used_up") {
|
|
57222
|
+
refuse2(res.headers.has("retry-after") ? SAID.credits_used_up : SAID.trial_credits_used_up, g.fallback, problem);
|
|
57083
57223
|
}
|
|
57084
|
-
if (res.status === 400)
|
|
57085
|
-
|
|
57224
|
+
if (res.status === 400) {
|
|
57225
|
+
throw cloudError({ ...problem, message: `${problem.message}
|
|
57226
|
+
usage: ${g.usage}` }, { bare: true, exitCode: 2 });
|
|
57227
|
+
}
|
|
57228
|
+
refuse2(g.failed, g.fallback, problem);
|
|
57229
|
+
}
|
|
57230
|
+
let bytes2;
|
|
57231
|
+
try {
|
|
57232
|
+
bytes2 = await cloudBytes(res, "a complete media file");
|
|
57233
|
+
if (!mediaMatches(contentType, bytes2, g.endpoint.endsWith("image"))) throw cloudError(invalidResponse("a complete media file"));
|
|
57234
|
+
} catch (error62) {
|
|
57235
|
+
if (!(error62 instanceof BoardError)) throw error62;
|
|
57236
|
+
refuse2(g.failed, g.fallback, { code: error62.kind, message: error62.message, retryable: true });
|
|
57086
57237
|
}
|
|
57087
57238
|
const out = g.outFor?.(res, g.out) ?? g.out;
|
|
57088
|
-
|
|
57089
|
-
|
|
57239
|
+
fs69.mkdirSync(path72.dirname(path72.resolve(out)), { recursive: true });
|
|
57240
|
+
fs69.writeFileSync(out, bytes2);
|
|
57090
57241
|
say(`${out} (${g.label(res)})`);
|
|
57091
57242
|
return { out };
|
|
57092
57243
|
}
|
|
57244
|
+
function mediaMatches(contentType, bytes2, image) {
|
|
57245
|
+
const type = contentType.toLowerCase().split(";", 1)[0]?.trim();
|
|
57246
|
+
const starts = (signature, offset = 0) => bytes2.toString("ascii", offset, offset + signature.length) === signature;
|
|
57247
|
+
const riff = (format) => starts("RIFF") && starts(format, 8);
|
|
57248
|
+
if (image) {
|
|
57249
|
+
if (type === "image/png") return bytes2.subarray(0, 8).equals(Buffer.from("89504e470d0a1a0a", "hex"));
|
|
57250
|
+
if (type === "image/jpeg") return bytes2[0] === 255 && bytes2[1] === 216 && bytes2[2] === 255;
|
|
57251
|
+
if (type === "image/webp") return riff("WEBP");
|
|
57252
|
+
return false;
|
|
57253
|
+
}
|
|
57254
|
+
if (type === "audio/wav") return riff("WAVE");
|
|
57255
|
+
return type === "audio/mpeg" && (starts("ID3") || bytes2.length > 2 && bytes2[0] === 255 && (bytes2[1] & 224) === 224);
|
|
57256
|
+
}
|
|
57093
57257
|
var SAID, REF_TYPES, TIERS, SPEECH_TIERS;
|
|
57094
57258
|
var init_cloud = __esm({
|
|
57095
57259
|
"../cli/src/commands/cloud.ts"() {
|
|
@@ -57100,6 +57264,7 @@ var init_cloud = __esm({
|
|
|
57100
57264
|
init_tasks();
|
|
57101
57265
|
init_paths();
|
|
57102
57266
|
init_io();
|
|
57267
|
+
init_response();
|
|
57103
57268
|
SAID = {
|
|
57104
57269
|
"signed-out": {
|
|
57105
57270
|
zh: "\u672A\u767B\u5F55 WildCrane Cloud\u3002\u8BF7\u5728 WildCrane \u5E94\u7528\u7684\u201C\u914D\u7F6E \u2192 Cloud\u201D\u4E2D\u767B\u5F55\u540E\u91CD\u8BD5\u3002",
|
|
@@ -57134,13 +57299,17 @@ var init_cloud = __esm({
|
|
|
57134
57299
|
});
|
|
57135
57300
|
|
|
57136
57301
|
// ../cli/src/commands/task.ts
|
|
57137
|
-
import
|
|
57302
|
+
import fs70 from "node:fs";
|
|
57138
57303
|
import os5 from "node:os";
|
|
57139
|
-
import
|
|
57304
|
+
import path73 from "node:path";
|
|
57140
57305
|
async function cloud(method, route2, body, signal2) {
|
|
57141
|
-
process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME ||
|
|
57306
|
+
process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME || path73.join(os5.homedir(), ".wildcrane");
|
|
57142
57307
|
const token2 = await accessToken();
|
|
57143
|
-
if (!token2.ok)
|
|
57308
|
+
if (!token2.ok) throw cloudError({
|
|
57309
|
+
code: token2.reason.replace("-", "_"),
|
|
57310
|
+
message: ("error" in token2 ? token2.error : void 0) ?? SAID[token2.reason].en,
|
|
57311
|
+
retryable: token2.reason === "unreachable"
|
|
57312
|
+
});
|
|
57144
57313
|
let response;
|
|
57145
57314
|
const request2 = new AbortController();
|
|
57146
57315
|
const abort = () => request2.abort();
|
|
@@ -57156,11 +57325,12 @@ async function cloud(method, route2, body, signal2) {
|
|
|
57156
57325
|
signal: request2.signal
|
|
57157
57326
|
});
|
|
57158
57327
|
} catch {
|
|
57159
|
-
|
|
57328
|
+
throw cloudError({ code: "unreachable", message: SAID.unreachable.en, retryable: true });
|
|
57160
57329
|
}
|
|
57161
|
-
const value = await response
|
|
57162
|
-
|
|
57163
|
-
if (
|
|
57330
|
+
const value = await readCloudJson(response);
|
|
57331
|
+
const problem = cloudProblem(response, value);
|
|
57332
|
+
if (problem) throw cloudError(problem);
|
|
57333
|
+
if (!isRecord(value)) throw cloudError(invalidResponse("a valid JSON response"));
|
|
57164
57334
|
return value;
|
|
57165
57335
|
} finally {
|
|
57166
57336
|
clearTimeout(timeout);
|
|
@@ -57169,11 +57339,14 @@ async function cloud(method, route2, body, signal2) {
|
|
|
57169
57339
|
}
|
|
57170
57340
|
async function all(route2) {
|
|
57171
57341
|
const rows = [];
|
|
57342
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
57172
57343
|
let after2 = null;
|
|
57173
57344
|
do {
|
|
57174
57345
|
const page = await cloud("GET", `${route2}${route2.includes("?") ? "&" : "?"}limit=100${after2 ? `&after=${enc(after2)}` : ""}`);
|
|
57346
|
+
requireResponse(page, "a valid results page", (value) => Array.isArray(value.data) && (value.next === null || hasText(value.next) && !cursors.has(value.next)));
|
|
57175
57347
|
rows.push(...page.data);
|
|
57176
57348
|
after2 = page.next;
|
|
57349
|
+
if (after2) cursors.add(after2);
|
|
57177
57350
|
} while (after2);
|
|
57178
57351
|
return rows;
|
|
57179
57352
|
}
|
|
@@ -57181,15 +57354,15 @@ function linked(location) {
|
|
|
57181
57354
|
const cwd = location.cwd ?? process.cwd();
|
|
57182
57355
|
const board2 = location.board ?? (process.env.AI4KANBAN_BOARD?.trim() || null);
|
|
57183
57356
|
if (board2) {
|
|
57184
|
-
const link2 = linkedProject("", projectRootOf(
|
|
57357
|
+
const link2 = linkedProject("", projectRootOf(path73.resolve(cwd, board2)));
|
|
57185
57358
|
return link2.ok ? link2.value : null;
|
|
57186
57359
|
}
|
|
57187
|
-
for (let dir =
|
|
57188
|
-
if (
|
|
57360
|
+
for (let dir = path73.resolve(cwd, location.dir ?? "."); ; dir = path73.dirname(dir)) {
|
|
57361
|
+
if (fs70.existsSync(path73.join(dir, ".akb", "base.json"))) {
|
|
57189
57362
|
const link2 = linkedProject("", dir);
|
|
57190
57363
|
return link2.ok ? link2.value : null;
|
|
57191
57364
|
}
|
|
57192
|
-
if (
|
|
57365
|
+
if (path73.dirname(dir) === dir) return null;
|
|
57193
57366
|
}
|
|
57194
57367
|
}
|
|
57195
57368
|
async function project(asked, location) {
|
|
@@ -57219,12 +57392,33 @@ async function taskList(opts, location = {}) {
|
|
|
57219
57392
|
}
|
|
57220
57393
|
async function taskShow(id2, location = {}) {
|
|
57221
57394
|
const task = await cloud("GET", `/v1/tasks/${enc(await taskRef(id2, location))}`);
|
|
57222
|
-
|
|
57395
|
+
requireTask(task);
|
|
57396
|
+
if (task.studio != null && (!isRecord(task.studio) || !hasText(task.studio.name))) {
|
|
57397
|
+
throw cloudError(invalidResponse("the task\u2019s Studio"));
|
|
57398
|
+
}
|
|
57399
|
+
let card = null;
|
|
57400
|
+
if (task.studio) {
|
|
57401
|
+
try {
|
|
57402
|
+
card = requireResponse(
|
|
57403
|
+
await cloud("GET", `/v1/tasks/${enc(task.id)}/card`),
|
|
57404
|
+
"the card body",
|
|
57405
|
+
(value) => hasText(value.body)
|
|
57406
|
+
);
|
|
57407
|
+
} catch (error62) {
|
|
57408
|
+
if (!(error62 instanceof BoardError) || error62.details.code !== "not_found" || (task.card_version ?? 0) > 0) throw error62;
|
|
57409
|
+
}
|
|
57410
|
+
}
|
|
57411
|
+
const board2 = linkedBoard(location);
|
|
57412
|
+
const removal = board2 && /^task_[\w-]+$/.test(task.id) ? readRemoval(board2, task.id) : null;
|
|
57413
|
+
const archive = board2 ? archiveReceipt(board2, task.id) : null;
|
|
57414
|
+
const sync = removal && (removal.status !== "confirmed" || task.status === "cancelled") ? { kind: "remove", ...operationStatus(removal) } : archive && archive.status === "confirmed" === (task.status === "done") ? { kind: "archive", ...operationStatus(archive) } : null;
|
|
57223
57415
|
say(`${task.key} ${task.title}`);
|
|
57224
57416
|
say(`${task.status}${task.studio ? ` ${task.studio.name}` : ""} ${taskUrl(task.key)}`);
|
|
57225
|
-
if (card
|
|
57417
|
+
if (card) say(`
|
|
57226
57418
|
${card.body.trim()}`);
|
|
57227
|
-
|
|
57419
|
+
else if (task.studio) say("The card has not been generated yet.");
|
|
57420
|
+
if (sync) say(`${sync.kind === "remove" ? "Removal" : "Archive"}: ${sync.status}${"code" in sync && sync.code ? ` [${sync.code}] ${sync.message ?? ""}` : ""}.`);
|
|
57421
|
+
return { ...task, card, card_read_status: card ? "available" : task.studio ? "not_generated" : "no_studio", ...sync ? { sync } : {} };
|
|
57228
57422
|
}
|
|
57229
57423
|
async function taskCreate(request2, opts, location = {}) {
|
|
57230
57424
|
const text5 = request2.trim();
|
|
@@ -57245,10 +57439,13 @@ async function taskCreate(request2, opts, location = {}) {
|
|
|
57245
57439
|
say(`Status: ${task.status}${task.failure ? ` \u2014 ${task.failure}` : ""}`);
|
|
57246
57440
|
return { ...task };
|
|
57247
57441
|
}
|
|
57248
|
-
|
|
57442
|
+
function requireTask(task) {
|
|
57443
|
+
return requireResponse(task, "a task receipt", (value) => hasText(value.id) && hasText(value.key) && hasText(value.status));
|
|
57444
|
+
}
|
|
57445
|
+
async function act(id2, route2, body, done, location) {
|
|
57249
57446
|
const ref = await taskRef(id2, location);
|
|
57250
57447
|
const value = await cloud("POST", `/v1/tasks/${enc(ref)}/${route2}`, body);
|
|
57251
|
-
say(done(ref));
|
|
57448
|
+
say(done(ref, value));
|
|
57252
57449
|
return value;
|
|
57253
57450
|
}
|
|
57254
57451
|
function reviewRevision(value) {
|
|
@@ -57268,7 +57465,7 @@ async function taskReview(id2, opts = {}, location = {}) {
|
|
|
57268
57465
|
if (opts.review !== void 0) {
|
|
57269
57466
|
fields2 = { operation: "plan", review_flow: opts.review };
|
|
57270
57467
|
} else if (opts.file !== void 0) {
|
|
57271
|
-
fields2 = { operation: "plan", review_plan: parseReviewPlan(JSON.parse(
|
|
57468
|
+
fields2 = { operation: "plan", review_plan: parseReviewPlan(JSON.parse(fs70.readFileSync(opts.file, "utf8"))) };
|
|
57272
57469
|
} else if (opts.reviseFrom !== void 0) {
|
|
57273
57470
|
fields2 = { operation: "revise", stage: opts.reviseFrom };
|
|
57274
57471
|
} else if (opts.previewDefinitionsFile !== void 0) {
|
|
@@ -57277,7 +57474,7 @@ async function taskReview(id2, opts = {}, location = {}) {
|
|
|
57277
57474
|
if (!opts.stage || !["running", "done"].includes(opts.status)) die("--stage and --status running|done are required.");
|
|
57278
57475
|
fields2 = { operation: "status", stage: opts.stage, status: opts.status };
|
|
57279
57476
|
}
|
|
57280
|
-
if (opts.previewDefinitionsFile !== void 0) fields2.preview_definitions = previewDefinitionsSchema.parse(JSON.parse(
|
|
57477
|
+
if (opts.previewDefinitionsFile !== void 0) fields2.preview_definitions = previewDefinitionsSchema.parse(JSON.parse(fs70.readFileSync(opts.previewDefinitionsFile, "utf8")));
|
|
57281
57478
|
task = await cloud("POST", `/v1/tasks/${enc(ref)}/review`, { ...fields2, review_revision });
|
|
57282
57479
|
}
|
|
57283
57480
|
say(JSON.stringify(task.review, null, 2));
|
|
@@ -57294,7 +57491,10 @@ async function taskApprove(id2, comment, opts = {}, location = {}) {
|
|
|
57294
57491
|
review_revision,
|
|
57295
57492
|
...opts.stage ? { stage: opts.stage } : {},
|
|
57296
57493
|
...comment?.trim() ? { comment: comment.trim() } : {}
|
|
57297
|
-
}, (
|
|
57494
|
+
}, (key, value) => {
|
|
57495
|
+
requireResponse(value, "an approval receipt", (receipt) => hasText(receipt.id) && receipt.decision === "approve");
|
|
57496
|
+
return `Approved ${key}.`;
|
|
57497
|
+
}, location);
|
|
57298
57498
|
}
|
|
57299
57499
|
async function taskUpdateQuestions(id2, typed, location = {}) {
|
|
57300
57500
|
const ops = readQuestionOps(typed);
|
|
@@ -57328,10 +57528,10 @@ function localTaskTarget(location) {
|
|
|
57328
57528
|
const runnerBoard = process.env.AI4KANBAN_BOARD?.trim();
|
|
57329
57529
|
if (!task || !/^task_[\w-]+$/.test(task) || !runnerBoard || !executionOf()) return null;
|
|
57330
57530
|
const cwd = location.cwd ?? process.cwd();
|
|
57331
|
-
const board2 =
|
|
57531
|
+
const board2 = path73.resolve(cwd, location.board ?? runnerBoard);
|
|
57332
57532
|
try {
|
|
57333
|
-
if (
|
|
57334
|
-
const record2 = JSON.parse(
|
|
57533
|
+
if (fs70.realpathSync(board2) !== fs70.realpathSync(path73.resolve(cwd, runnerBoard)) || !runnerProject(board2)) return null;
|
|
57534
|
+
const record2 = JSON.parse(fs70.readFileSync(path73.join(board2, ".sync", task + ".json"), "utf8"));
|
|
57335
57535
|
if (record2.task === task && Number.isSafeInteger(record2.number) && record2.number > 0 && !record2.deleted) {
|
|
57336
57536
|
return { board: board2, task, number: record2.number };
|
|
57337
57537
|
}
|
|
@@ -57339,16 +57539,45 @@ function localTaskTarget(location) {
|
|
|
57339
57539
|
}
|
|
57340
57540
|
return null;
|
|
57341
57541
|
}
|
|
57342
|
-
|
|
57542
|
+
function linkedBoard(location) {
|
|
57543
|
+
const cwd = location.cwd ?? process.cwd();
|
|
57544
|
+
const named2 = location.board ?? process.env.AI4KANBAN_BOARD;
|
|
57545
|
+
if (named2) {
|
|
57546
|
+
const board2 = path73.resolve(cwd, named2);
|
|
57547
|
+
return runnerProject(board2) ? board2 : null;
|
|
57548
|
+
}
|
|
57549
|
+
for (let dir = path73.resolve(cwd, location.dir ?? "."); ; dir = path73.dirname(dir)) {
|
|
57550
|
+
const board2 = path73.join(dir, ".akb", "kanban");
|
|
57551
|
+
if (runnerProject(board2)) return board2;
|
|
57552
|
+
if (path73.dirname(dir) === dir) return null;
|
|
57553
|
+
}
|
|
57554
|
+
}
|
|
57555
|
+
function operationStatus(result) {
|
|
57556
|
+
if (result.status === "confirmed") return { status: result.status };
|
|
57557
|
+
return { status: result.status, code: result.code, message: result.message };
|
|
57558
|
+
}
|
|
57559
|
+
function archiveReceipt(board2, task, file2) {
|
|
57343
57560
|
try {
|
|
57344
|
-
const base = JSON.parse(
|
|
57345
|
-
const
|
|
57346
|
-
const
|
|
57347
|
-
|
|
57348
|
-
const
|
|
57349
|
-
|
|
57561
|
+
const base = JSON.parse(fs70.readFileSync(path73.join(board2, "..", "base.json"), "utf8"));
|
|
57562
|
+
const receipt = base.archiveReceipts?.[task];
|
|
57563
|
+
const root2 = `projects/${runnerProject(board2)}/`;
|
|
57564
|
+
const synced = receipt && base.files?.[root2 + receipt.path];
|
|
57565
|
+
const manifest = assetsFile(task);
|
|
57566
|
+
const assets = base.files?.[root2 + manifest];
|
|
57567
|
+
if (synced && (!file2 || receipt.path === file2) && synced.seq === receipt.seq && (assets?.seq ?? 0) === receipt.assets_seq) {
|
|
57568
|
+
const local = (name) => {
|
|
57569
|
+
try {
|
|
57570
|
+
return fs70.readFileSync(path73.join(board2, name), "utf8");
|
|
57571
|
+
} catch {
|
|
57572
|
+
return null;
|
|
57573
|
+
}
|
|
57574
|
+
};
|
|
57575
|
+
if (synced.content === local(receipt.path) && (assets?.content ?? null) === local(manifest)) return operationStatus(receipt);
|
|
57576
|
+
if (file2) return { status: "pending" };
|
|
57577
|
+
}
|
|
57578
|
+
return base.pendingArchives?.[task] ? { status: "pending" } : null;
|
|
57350
57579
|
} catch {
|
|
57351
|
-
return
|
|
57580
|
+
return null;
|
|
57352
57581
|
}
|
|
57353
57582
|
}
|
|
57354
57583
|
async function taskArchive(asked, location = {}) {
|
|
@@ -57362,25 +57591,34 @@ async function taskArchive(asked, location = {}) {
|
|
|
57362
57591
|
if (locate(local.number)) return { receipt: cmdRemove(local.number, "completed", { archivingTask: true }) };
|
|
57363
57592
|
const existing = locateArchived(local.number);
|
|
57364
57593
|
if (!existing) return null;
|
|
57365
|
-
const file2 = existing.kind === "group" ?
|
|
57366
|
-
const { meta: meta3 } = parseFrontmatter(
|
|
57594
|
+
const file2 = existing.kind === "group" ? path73.join(existing.target, "root.md") : existing.target;
|
|
57595
|
+
const { meta: meta3 } = parseFrontmatter(fs70.readFileSync(file2, "utf8"));
|
|
57367
57596
|
if (!meta3?.archived || meta3.rejected) return refuse3("This task is not eligible for archive.", "conflict");
|
|
57368
57597
|
return {
|
|
57369
|
-
receipt: { archived_to:
|
|
57370
|
-
existing:
|
|
57598
|
+
receipt: { archived_to: path73.relative(local.board, existing.target) },
|
|
57599
|
+
existing: path73.relative(local.board, file2)
|
|
57371
57600
|
};
|
|
57372
57601
|
}));
|
|
57373
57602
|
});
|
|
57374
57603
|
if (archive) {
|
|
57375
|
-
|
|
57604
|
+
const receipt = archive.existing && archiveReceipt(local.board, local.task, archive.existing);
|
|
57605
|
+
if (receipt && receipt.status === "confirmed") {
|
|
57376
57606
|
say("Archive confirmed by Cloud.");
|
|
57377
57607
|
return { task: local.task, archive_status: "archived" };
|
|
57378
57608
|
}
|
|
57379
|
-
|
|
57380
|
-
|
|
57609
|
+
if (receipt && receipt.status === "rejected") {
|
|
57610
|
+
if (receipt.code === "version_conflict" || receipt.code === "not_found") {
|
|
57611
|
+
return refuse3(receipt.message ?? "Cloud rejected the archive.", receipt.code);
|
|
57612
|
+
}
|
|
57613
|
+
} else {
|
|
57614
|
+
const pending = receipt && receipt.status === "pending" && receipt.code ? receipt : null;
|
|
57615
|
+
say(`Archived locally. Waiting for Runner synchronization.${pending ? ` [${pending.code}] ${pending.message}` : ""}`);
|
|
57616
|
+
return { ...archive.receipt, task: local.task, archive_status: "pending_sync", ...pending ? { sync: pending } : {} };
|
|
57617
|
+
}
|
|
57381
57618
|
}
|
|
57382
57619
|
}
|
|
57383
|
-
const result = await cloud("POST", `/v1/tasks/${enc(keyMatch ?
|
|
57620
|
+
const result = await cloud("POST", `/v1/tasks/${enc(keyMatch?.id ?? (local && /^\d+$/.test(ref) && Number(ref) === local.number ? local.task : await taskRef(ref, location)))}/archive`);
|
|
57621
|
+
requireResponse(requireTask(result), "confirmation that the task was archived", (task) => task.status === "done");
|
|
57384
57622
|
say(`Archived ${result.key}.`);
|
|
57385
57623
|
return { task: result.id, archive_status: "archived" };
|
|
57386
57624
|
}
|
|
@@ -57394,10 +57632,21 @@ async function taskRemove(asked, reason, location = {}, discard = false) {
|
|
|
57394
57632
|
const keyMatch = local && /^[a-z][a-z0-9]{0,9}-[1-9]\d{0,8}$/i.test(ref) && ref.endsWith(`-${local.number}`) ? await cloud("GET", `/v1/tasks/${enc(ref)}`) : null;
|
|
57395
57633
|
if (local && (ref === local.task || numeric && Number(ref) === local.number || keyMatch?.id === local.task)) {
|
|
57396
57634
|
return withSyncLock(local.board, async () => {
|
|
57397
|
-
|
|
57398
|
-
|
|
57399
|
-
|
|
57400
|
-
|
|
57635
|
+
const held4 = readRemoval(local.board, local.task);
|
|
57636
|
+
if (held4?.status === "confirmed") {
|
|
57637
|
+
const current = requireTask(keyMatch ?? await cloud("GET", `/v1/tasks/${enc(local.task)}`));
|
|
57638
|
+
if (current.status === "cancelled") {
|
|
57639
|
+
say("Removal confirmed by Cloud.");
|
|
57640
|
+
return { task: local.task, remove_status: "removed" };
|
|
57641
|
+
}
|
|
57642
|
+
} else if (held4?.status === "rejected") {
|
|
57643
|
+
const current = requireTask(keyMatch ?? await cloud("GET", `/v1/tasks/${enc(local.task)}`));
|
|
57644
|
+
if (current.status === "done" || current.status === "cancelled") return refuse3(held4.message ?? "Cloud rejected the removal.", held4.code ?? "conflict");
|
|
57645
|
+
}
|
|
57646
|
+
if (held4?.status !== "pending") writeRemoval(local.board, local.task, { status: "pending", reason: text5, discard: true });
|
|
57647
|
+
const pending = held4?.status === "pending" && held4.code ? operationStatus(held4) : null;
|
|
57648
|
+
say(`Removal queued for Runner synchronization.${pending && pending.status !== "confirmed" ? ` [${pending.code}] ${pending.message}` : ""}`);
|
|
57649
|
+
return { task: local.task, board: local.board, remove_status: "pending_sync", ...pending ? { sync: pending } : {} };
|
|
57401
57650
|
});
|
|
57402
57651
|
}
|
|
57403
57652
|
if (!workspaceTask() && run3 && numeric) {
|
|
@@ -57420,15 +57669,35 @@ async function taskRemove(asked, reason, location = {}, discard = false) {
|
|
|
57420
57669
|
keyMatch?.id ?? ref,
|
|
57421
57670
|
"cancel",
|
|
57422
57671
|
Object.keys(body).length ? body : void 0,
|
|
57423
|
-
(key) =>
|
|
57672
|
+
(key, value) => {
|
|
57673
|
+
requireResponse(value, "confirmation that the task was removed", (task) => hasText(task.id) && task.status === "cancelled");
|
|
57674
|
+
return `Removed ${keyMatch ? ref : key} in Cloud. Restore it with akb task restore ${keyMatch ? ref : key}.`;
|
|
57675
|
+
},
|
|
57424
57676
|
location
|
|
57425
57677
|
);
|
|
57426
57678
|
}
|
|
57427
57679
|
async function taskRestore(id2, location = {}) {
|
|
57428
57680
|
const task = await cloud("POST", `/v1/tasks/${enc(await taskRef(id2, location))}/restore`);
|
|
57681
|
+
requireResponse(requireTask(task), "confirmation that the task was restored", (value) => ["stopped", "waiting_review", "failed"].includes(value.status));
|
|
57429
57682
|
say(`Restored ${task.key}. Status: ${task.status}.`);
|
|
57430
57683
|
return { ...task };
|
|
57431
57684
|
}
|
|
57685
|
+
async function taskResume(id2, location = {}) {
|
|
57686
|
+
const task = requireTask(await cloud("POST", `/v1/tasks/${enc(await taskRef(id2, location))}/resume`));
|
|
57687
|
+
if (!["queued", "running"].includes(task.status)) {
|
|
57688
|
+
const reason = task.failure || (task.status === "waiting_review" ? "The task is waiting for review." : ["done", "cancelled"].includes(task.status) ? "This task has finished." : `The task is ${task.status}.`);
|
|
57689
|
+
return refuse3(reason, task.status === "failed" ? "execution_failed" : "conflict");
|
|
57690
|
+
}
|
|
57691
|
+
say(task.status === "queued" ? `Resume queued for ${task.key}.` : `Resumed ${task.key}.`);
|
|
57692
|
+
return { ...task };
|
|
57693
|
+
}
|
|
57694
|
+
async function taskStop(id2, location = {}) {
|
|
57695
|
+
const task = requireTask(await cloud("POST", `/v1/tasks/${enc(await taskRef(id2, location))}/stop`));
|
|
57696
|
+
requireResponse(task, "a stop receipt", (value) => ["running", "queued", "waiting_review", "stopped"].includes(value.status));
|
|
57697
|
+
const stop_status = task.status === "stopped" ? "stopped" : "requested";
|
|
57698
|
+
say(stop_status === "stopped" ? `Stopped ${task.key}.` : `Stop requested for ${task.key}.`);
|
|
57699
|
+
return { ...task, stop_status };
|
|
57700
|
+
}
|
|
57432
57701
|
async function workspaceList() {
|
|
57433
57702
|
const data = await all("/v1/workspaces");
|
|
57434
57703
|
for (const w of data) say(`${w.id} ${w.name}`);
|
|
@@ -57444,7 +57713,7 @@ async function runnerList(opts, location = {}) {
|
|
|
57444
57713
|
for (const r of held4.runners) say(`${r.name} ${r.connected ? "online" : "offline"}`);
|
|
57445
57714
|
return held4;
|
|
57446
57715
|
}
|
|
57447
|
-
var refuse3, enc, WEB, taskUrl, projectLine, taskChat,
|
|
57716
|
+
var refuse3, enc, WEB, taskUrl, projectLine, taskChat, taskComment;
|
|
57448
57717
|
var init_task = __esm({
|
|
57449
57718
|
"../cli/src/commands/task.ts"() {
|
|
57450
57719
|
"use strict";
|
|
@@ -57462,23 +57731,35 @@ var init_task = __esm({
|
|
|
57462
57731
|
init_sessions();
|
|
57463
57732
|
init_creation_lock();
|
|
57464
57733
|
init_lock();
|
|
57734
|
+
init_task_operation();
|
|
57735
|
+
init_board_files();
|
|
57465
57736
|
init_board_conflicts();
|
|
57466
57737
|
init_remove();
|
|
57467
57738
|
init_io();
|
|
57739
|
+
init_response();
|
|
57468
57740
|
init_paths();
|
|
57469
57741
|
init_frontmatter();
|
|
57470
57742
|
init_questions();
|
|
57471
57743
|
init_question_ops();
|
|
57472
57744
|
init_cloud();
|
|
57473
|
-
refuse3 = (message, code) =>
|
|
57745
|
+
refuse3 = (message, code) => {
|
|
57746
|
+
throw cloudError({ code, message, retryable: false });
|
|
57747
|
+
};
|
|
57474
57748
|
enc = encodeURIComponent;
|
|
57475
57749
|
WEB = () => process.env.WILDCRANE_WEB_URL || "https://app.wildcrane.ai";
|
|
57476
57750
|
taskUrl = (key) => `${WEB()}/tasks/${enc(key)}`;
|
|
57477
57751
|
projectLine = (p) => `${p.id} ${p.prefix} ${p.name}`;
|
|
57478
|
-
taskChat = (id2, message, location = {}) => act(id2, "chat", { body: message }, (
|
|
57479
|
-
|
|
57480
|
-
|
|
57481
|
-
|
|
57752
|
+
taskChat = (id2, message, location = {}) => act(id2, "chat", { body: message }, (key, chat) => {
|
|
57753
|
+
requireResponse(chat, "a chat message receipt", (value) => Array.isArray(value.messages) && value.messages.some((msg) => isRecord(msg) && hasText(msg.id) && msg.role === "user" && msg.body === message.trim()));
|
|
57754
|
+
if (hasText(chat.failure) || ["failed", "conflict", "runner_offline", "stopped"].includes(String(chat.status))) {
|
|
57755
|
+
return refuse3(hasText(chat.failure) ? chat.failure : `Chat reply: ${chat.status}.`, "reply_failed");
|
|
57756
|
+
}
|
|
57757
|
+
return ["queued", "replying"].includes(String(chat.status)) ? `Sent to ${key}. Reply pending.` : `Sent to ${key}.`;
|
|
57758
|
+
}, location);
|
|
57759
|
+
taskComment = (id2, text5, location = {}) => act(id2, "comments", { body: text5 }, (key, value) => {
|
|
57760
|
+
requireResponse(value, "a comment receipt", (receipt) => hasText(receipt.id) && receipt.body === text5.trim());
|
|
57761
|
+
return `Commented on ${key}.`;
|
|
57762
|
+
}, location);
|
|
57482
57763
|
}
|
|
57483
57764
|
});
|
|
57484
57765
|
|
|
@@ -57496,10 +57777,10 @@ function decodeGoals({ goals, ideas, ...rest }) {
|
|
|
57496
57777
|
if (goals !== void 0 && ideas !== void 0 && JSON.stringify(goals) !== JSON.stringify(ideas)) {
|
|
57497
57778
|
throw new Error("goals and ideas do not match.");
|
|
57498
57779
|
}
|
|
57499
|
-
const
|
|
57500
|
-
if (!Array.isArray(
|
|
57780
|
+
const entries2 = goals ?? ideas;
|
|
57781
|
+
if (!Array.isArray(entries2)) throw new Error("The goals array is missing or invalid.");
|
|
57501
57782
|
const field2 = goals === void 0 ? "ideas" : "goals";
|
|
57502
|
-
return { field: field2, value: { ...rest, goals:
|
|
57783
|
+
return { field: field2, value: { ...rest, goals: entries2.map(readGoal) } };
|
|
57503
57784
|
}
|
|
57504
57785
|
function goalRoute(discussion2, goal, field2) {
|
|
57505
57786
|
return `/v1/discussions/${encodeURIComponent(discussion2)}/${field2}/${encodeURIComponent(goal)}`;
|
|
@@ -57512,20 +57793,20 @@ var init_goal = __esm({
|
|
|
57512
57793
|
});
|
|
57513
57794
|
|
|
57514
57795
|
// ../cli/src/lib/goal-draft.ts
|
|
57515
|
-
import
|
|
57796
|
+
import fs71 from "node:fs";
|
|
57516
57797
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
57517
57798
|
function readGoalDraft(file2) {
|
|
57518
|
-
return decodeGoals(JSON.parse(
|
|
57799
|
+
return decodeGoals(JSON.parse(fs71.readFileSync(file2, "utf8")));
|
|
57519
57800
|
}
|
|
57520
57801
|
function writeGoalDraft(file2, { goals, ...draft }, field2) {
|
|
57521
|
-
const
|
|
57802
|
+
const entries2 = field2 === "goals" ? goals : goals.map(({ task, ...goal }) => ({ ...goal, task: task?.key ? task : task?.id ?? null }));
|
|
57522
57803
|
const temporary = `${file2}.${randomUUID7()}.tmp`;
|
|
57523
57804
|
try {
|
|
57524
|
-
|
|
57805
|
+
fs71.writeFileSync(temporary, `${JSON.stringify({ ...draft, [field2]: entries2 }, null, 2)}
|
|
57525
57806
|
`, { mode: 384, flag: "wx" });
|
|
57526
|
-
|
|
57807
|
+
fs71.renameSync(temporary, file2);
|
|
57527
57808
|
} finally {
|
|
57528
|
-
|
|
57809
|
+
fs71.rmSync(temporary, { force: true });
|
|
57529
57810
|
}
|
|
57530
57811
|
}
|
|
57531
57812
|
var goalDraftPath;
|
|
@@ -57538,7 +57819,7 @@ var init_goal_draft = __esm({
|
|
|
57538
57819
|
});
|
|
57539
57820
|
|
|
57540
57821
|
// ../cli/src/commands/goal.ts
|
|
57541
|
-
import
|
|
57822
|
+
import fs72 from "node:fs";
|
|
57542
57823
|
function loadGoals() {
|
|
57543
57824
|
const file2 = goalDraftPath();
|
|
57544
57825
|
if (!file2) die("Goals exist only inside a WildCrane goal discussion.");
|
|
@@ -57570,7 +57851,7 @@ function splitBody2(text5) {
|
|
|
57570
57851
|
}
|
|
57571
57852
|
function readBody(bodyFile) {
|
|
57572
57853
|
if (!bodyFile) die("--body-file is required; write the goal in a writable temporary file first.");
|
|
57573
|
-
const text5 =
|
|
57854
|
+
const text5 = fs72.readFileSync(bodyFile, "utf8");
|
|
57574
57855
|
if (!text5.trim()) die("The goal must not be empty.");
|
|
57575
57856
|
return splitBody2(text5);
|
|
57576
57857
|
}
|
|
@@ -57636,7 +57917,7 @@ function cmdGoalStudios(held4 = loadGoals().held) {
|
|
|
57636
57917
|
return { studios: held4.studios.map((w) => ({ ...w, id: shortStudioId(w.id) })) };
|
|
57637
57918
|
}
|
|
57638
57919
|
function goalDefinitions(opts, previous = []) {
|
|
57639
|
-
return opts.previewDefinitionsFile === void 0 ? previous : previewDefinitionsSchema.parse(JSON.parse(
|
|
57920
|
+
return opts.previewDefinitionsFile === void 0 ? previous : previewDefinitionsSchema.parse(JSON.parse(fs72.readFileSync(opts.previewDefinitionsFile, "utf8")));
|
|
57640
57921
|
}
|
|
57641
57922
|
function goalCatalog(held4, studio, definitions) {
|
|
57642
57923
|
const builtIn = held4.studios.find((w) => w.id === studio)?.previews;
|
|
@@ -57649,7 +57930,7 @@ function goalReview(held4, studio, opts, previous, definitions) {
|
|
|
57649
57930
|
if (opts.reviewFile !== void 0) die("Use either --review or --review-file.");
|
|
57650
57931
|
return parseReviewFlow(opts.review, catalog);
|
|
57651
57932
|
}
|
|
57652
|
-
const value = opts.reviewFile === void 0 ? readReviewPlan(previous) : JSON.parse(
|
|
57933
|
+
const value = opts.reviewFile === void 0 ? readReviewPlan(previous) : JSON.parse(fs72.readFileSync(opts.reviewFile, "utf8"));
|
|
57653
57934
|
const saved = opts.reviewFile === void 0 && opts.previewDefinitionsFile === void 0 && opts.studio === void 0;
|
|
57654
57935
|
return validateReviewPreviews(parseReviewPlan(value), catalog, { saved });
|
|
57655
57936
|
}
|
|
@@ -57679,9 +57960,9 @@ var init_goal2 = __esm({
|
|
|
57679
57960
|
});
|
|
57680
57961
|
|
|
57681
57962
|
// ../cli/src/commands/goal-cloud.ts
|
|
57682
|
-
import
|
|
57963
|
+
import fs73 from "node:fs";
|
|
57683
57964
|
import os6 from "node:os";
|
|
57684
|
-
import
|
|
57965
|
+
import path74 from "node:path";
|
|
57685
57966
|
import crypto6 from "node:crypto";
|
|
57686
57967
|
function hostSession() {
|
|
57687
57968
|
const { CLAUDE_CODE_SESSION_ID: claude, CODEX_THREAD_ID: codex, CURSOR_CONVERSATION_ID: cursor, KIMI_SESSION_ID: kimi, WILDCRANE_DISCUSSION: discussion2 } = process.env;
|
|
@@ -57693,43 +57974,54 @@ function hostSession() {
|
|
|
57693
57974
|
}
|
|
57694
57975
|
async function studios2(workspace2) {
|
|
57695
57976
|
const all2 = [];
|
|
57977
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
57696
57978
|
let after2 = null;
|
|
57697
57979
|
do {
|
|
57698
57980
|
const page = await request("GET", `/v1/studios?workspace=${encodeURIComponent(workspace2)}&limit=100${after2 ? `&after=${encodeURIComponent(after2)}` : ""}`);
|
|
57981
|
+
requireResponse(page, "a valid Studio list", (value) => Array.isArray(value.data) && value.data.every((studio) => hasText(studio?.id) && hasText(studio.name)) && (value.next === null || hasText(value.next) && !cursors.has(value.next)));
|
|
57699
57982
|
all2.push(...page.data);
|
|
57700
57983
|
after2 = page.next;
|
|
57984
|
+
if (after2) cursors.add(after2);
|
|
57701
57985
|
} while (after2);
|
|
57702
57986
|
return all2;
|
|
57703
57987
|
}
|
|
57704
57988
|
async function discussion() {
|
|
57705
57989
|
const session = hostSession();
|
|
57706
57990
|
if (!session) die("Goals exist only inside a WildCrane goal discussion.");
|
|
57707
|
-
const home3 = process.env.WILDCRANE_HOME ||
|
|
57991
|
+
const home3 = process.env.WILDCRANE_HOME || path74.join(os6.homedir(), ".wildcrane");
|
|
57708
57992
|
process.env.AI4KANBAN_HOME ??= home3;
|
|
57709
57993
|
if (session.host === "discussion") return request("GET", `/v1/discussions/${encodeURIComponent(session.id)}`);
|
|
57710
|
-
const machineFile2 =
|
|
57994
|
+
const machineFile2 = path74.join(home3, "machine.json");
|
|
57711
57995
|
let machine;
|
|
57712
57996
|
try {
|
|
57713
|
-
machine = JSON.parse(
|
|
57997
|
+
machine = JSON.parse(fs73.readFileSync(machineFile2, "utf8")).id;
|
|
57714
57998
|
} catch {
|
|
57715
57999
|
machine = crypto6.randomUUID();
|
|
57716
|
-
|
|
57717
|
-
|
|
58000
|
+
fs73.mkdirSync(home3, { recursive: true });
|
|
58001
|
+
fs73.writeFileSync(machineFile2, JSON.stringify({ id: machine }));
|
|
57718
58002
|
}
|
|
57719
58003
|
const held4 = await request("GET", `/v1/runner/folders?machine=${encodeURIComponent(machine)}`);
|
|
57720
|
-
const cwd =
|
|
58004
|
+
const cwd = fs73.realpathSync(process.cwd());
|
|
57721
58005
|
const folder2 = held4.folders.filter((f) => {
|
|
57722
58006
|
try {
|
|
57723
|
-
const dir =
|
|
57724
|
-
return cwd === dir || cwd.startsWith(dir +
|
|
58007
|
+
const dir = fs73.realpathSync(f.path);
|
|
58008
|
+
return cwd === dir || cwd.startsWith(dir + path74.sep);
|
|
57725
58009
|
} catch {
|
|
57726
58010
|
return false;
|
|
57727
58011
|
}
|
|
57728
58012
|
}).sort((a, b) => b.path.length - a.path.length)[0];
|
|
57729
58013
|
return request("POST", "/v1/discussions/external", { requestId: session.id, host: session.host, ...folder2 ? { project: folder2.project } : {} });
|
|
57730
58014
|
}
|
|
58015
|
+
function discussionReceipt(value) {
|
|
58016
|
+
try {
|
|
58017
|
+
const decoded = decodeGoals(value);
|
|
58018
|
+
if (hasText(decoded.value.id) && hasText(decoded.value.workspace) && Number.isSafeInteger(decoded.value.version)) return decoded;
|
|
58019
|
+
} catch {
|
|
58020
|
+
}
|
|
58021
|
+
throw cloudError(invalidResponse("a valid discussion draft"));
|
|
58022
|
+
}
|
|
57731
58023
|
async function withGoalDiscussion(action, save3 = false) {
|
|
57732
|
-
const { field: field2, value: d } =
|
|
58024
|
+
const { field: field2, value: d } = discussionReceipt(await discussion());
|
|
57733
58025
|
const held4 = { workspace: d.workspace, studios: await studios2(d.workspace), goals: d.goals.map((goal) => ({ ...goal })) };
|
|
57734
58026
|
const result = action(held4);
|
|
57735
58027
|
if (save3) {
|
|
@@ -57738,15 +58030,21 @@ async function withGoalDiscussion(action, save3 = false) {
|
|
|
57738
58030
|
expectedVersion: d.version,
|
|
57739
58031
|
[field2]: goals
|
|
57740
58032
|
});
|
|
57741
|
-
const { field: savedField, value: latest } =
|
|
58033
|
+
const { field: savedField, value: latest } = discussionReceipt(saved);
|
|
57742
58034
|
const existing = new Set(d.goals.map((g) => g.id));
|
|
57743
58035
|
const fresh = goals.filter((g) => !existing.has(g.id));
|
|
57744
58036
|
const made = latest.goals.filter((g) => !existing.has(g.id));
|
|
57745
58037
|
const actualId = (id2) => made[fresh.findIndex((g) => g.id === id2)]?.id ?? id2;
|
|
57746
58038
|
if (typeof result.id === "string") result.id = actualId(result.id);
|
|
57747
|
-
|
|
57748
|
-
const actual = latest.goals.find((g) => g.id ===
|
|
57749
|
-
if (actual)
|
|
58039
|
+
if (result.start) {
|
|
58040
|
+
const actual = latest.goals.find((g) => g.id === result.id);
|
|
58041
|
+
if (!actual) throw cloudError(invalidResponse("the saved goal"));
|
|
58042
|
+
const task = actual.task ?? requireResponse(await request(
|
|
58043
|
+
"POST",
|
|
58044
|
+
`${goalRoute(d.id, actual.id, savedField)}/start`,
|
|
58045
|
+
{ expectedVersion: latest.version }
|
|
58046
|
+
), "a started task", (value) => hasText(value.id));
|
|
58047
|
+
result.task = task.id;
|
|
57750
58048
|
}
|
|
57751
58049
|
say(`${result.dropped ? "Dropped" : result.start ? "Started" : "Saved"} goal ${result.id}${result.title ? `: ${result.title}` : ""}.`);
|
|
57752
58050
|
}
|
|
@@ -57773,6 +58071,7 @@ var init_goal_cloud = __esm({
|
|
|
57773
58071
|
"../cli/src/commands/goal-cloud.ts"() {
|
|
57774
58072
|
"use strict";
|
|
57775
58073
|
init_task();
|
|
58074
|
+
init_response();
|
|
57776
58075
|
init_paths();
|
|
57777
58076
|
init_io();
|
|
57778
58077
|
init_goal2();
|
|
@@ -58019,21 +58318,27 @@ var init_agent = __esm({
|
|
|
58019
58318
|
|
|
58020
58319
|
// ../cli/src/commands/cloud-template.ts
|
|
58021
58320
|
import { createHash as createHash5 } from "node:crypto";
|
|
58022
|
-
import
|
|
58023
|
-
import
|
|
58321
|
+
import fs74 from "node:fs";
|
|
58322
|
+
import path75 from "node:path";
|
|
58024
58323
|
function usage2(problem, line) {
|
|
58025
58324
|
die(`${problem}
|
|
58026
58325
|
usage: ${line}`, { kind: "bad-args", bare: true, exitCode: 2 });
|
|
58027
58326
|
}
|
|
58028
|
-
function refuse4(m, also) {
|
|
58029
|
-
|
|
58327
|
+
function refuse4(m, also, problem) {
|
|
58328
|
+
const message = [m.zh, m.en, problem?.message, also?.zh, also?.en].filter(Boolean).join("\n");
|
|
58329
|
+
if (problem) throw cloudError({ ...problem, message }, { bare: true });
|
|
58330
|
+
die(message, { kind: "cloud-refused", bare: true });
|
|
58030
58331
|
}
|
|
58031
|
-
function
|
|
58332
|
+
function invalid2(zh, en) {
|
|
58032
58333
|
refuse4({ zh: `\u6A21\u677F\u672A\u901A\u8FC7\u6821\u9A8C\uFF1A${zh}`, en: `The template is not valid: ${en}` });
|
|
58033
58334
|
}
|
|
58034
58335
|
async function ask(route2, init = {}, fallback) {
|
|
58035
58336
|
const token2 = await accessToken();
|
|
58036
|
-
if (!token2.ok) refuse4(SAID[token2.reason], fallback
|
|
58337
|
+
if (!token2.ok) refuse4(SAID[token2.reason], fallback, {
|
|
58338
|
+
code: token2.reason.replace("-", "_"),
|
|
58339
|
+
message: "error" in token2 ? token2.error ?? "" : "",
|
|
58340
|
+
retryable: token2.reason === "unreachable"
|
|
58341
|
+
});
|
|
58037
58342
|
let res;
|
|
58038
58343
|
try {
|
|
58039
58344
|
res = await fetch(`${cloudEndpoints().api}/v1/templates${route2}`, {
|
|
@@ -58041,18 +58346,49 @@ async function ask(route2, init = {}, fallback) {
|
|
|
58041
58346
|
headers: { authorization: `Bearer ${token2.token}` }
|
|
58042
58347
|
});
|
|
58043
58348
|
} catch {
|
|
58044
|
-
refuse4(SAID.unreachable, fallback);
|
|
58349
|
+
refuse4(SAID.unreachable, fallback, { code: "unreachable", message: "", retryable: true });
|
|
58045
58350
|
}
|
|
58046
58351
|
if (res.ok) return res;
|
|
58047
|
-
const
|
|
58048
|
-
if (res.status === 401) refuse4(SAID.expired, fallback);
|
|
58049
|
-
if (
|
|
58352
|
+
const problem = cloudProblem(res, await readCloudJson(res));
|
|
58353
|
+
if (res.status === 401) refuse4(SAID.expired, fallback, problem);
|
|
58354
|
+
if (problem.code === "pro_required") refuse4(T.pro_required, fallback, problem);
|
|
58050
58355
|
const named2 = route2.startsWith("/") && !route2.startsWith("/tags?");
|
|
58051
|
-
if (
|
|
58052
|
-
if (
|
|
58053
|
-
if (
|
|
58054
|
-
if (res.status === 400)
|
|
58055
|
-
refuse4(T.failed, fallback);
|
|
58356
|
+
if (problem.code === "not_found" && named2) refuse4(T.not_found, fallback, problem);
|
|
58357
|
+
if (problem.code === "owner_only") refuse4(T.publisher_only, void 0, problem);
|
|
58358
|
+
if (problem.code === "template_exists") refuse4(T.exists, void 0, problem);
|
|
58359
|
+
if (res.status === 400) refuse4({ zh: "\u6A21\u677F\u8BF7\u6C42\u672A\u901A\u8FC7\u6821\u9A8C\u3002", en: "The template request is not valid." }, fallback, problem);
|
|
58360
|
+
refuse4(T.failed, fallback, problem);
|
|
58361
|
+
}
|
|
58362
|
+
async function asJson(res) {
|
|
58363
|
+
const value = await readCloudJson(res);
|
|
58364
|
+
const problem = cloudProblem(res, value);
|
|
58365
|
+
if (problem) throw cloudError(problem);
|
|
58366
|
+
if (!isRecord(value)) throw cloudError(invalidResponse("a valid template response"));
|
|
58367
|
+
return value;
|
|
58368
|
+
}
|
|
58369
|
+
function entries(value) {
|
|
58370
|
+
return Array.isArray(value) && value.every((entry) => isRecord(entry) && hasText(entry.path) && !/[\\:\0]/.test(entry.path) && entry.path.split("/").every((part) => !!part && part !== "." && part !== "..") && typeof entry.size === "number" && Number.isSafeInteger(entry.size) && entry.size >= 0 && (entry.sha256 === void 0 || typeof entry.sha256 === "string" && /^[a-f0-9]{64}$/.test(entry.sha256)));
|
|
58371
|
+
}
|
|
58372
|
+
async function downloadEntries(name, kind, files, to, fallback) {
|
|
58373
|
+
if (!SLUG.test(name)) throw cloudError(invalidResponse("a valid template name"));
|
|
58374
|
+
const fetched = [];
|
|
58375
|
+
const names2 = /* @__PURE__ */ new Set();
|
|
58376
|
+
const expected = "a matching template download";
|
|
58377
|
+
for (const file2 of files) {
|
|
58378
|
+
const leaf = path75.basename(file2.path);
|
|
58379
|
+
const out = path75.join(to, kind === "previews" && leaf.startsWith(`${name}-`) ? leaf : `${name}-${leaf}`);
|
|
58380
|
+
if (names2.has(out)) refuse4(T.corrupt, fallback, invalidResponse(expected));
|
|
58381
|
+
names2.add(out);
|
|
58382
|
+
const bytes2 = await cloudBytes(await ask(`/${encodeURIComponent(name)}/${kind}/${route(file2.path)}`, {}, fallback), expected, { size: file2.size });
|
|
58383
|
+
if (file2.sha256 && createHash5("sha256").update(bytes2).digest("hex") !== file2.sha256) refuse4(T.corrupt, fallback, invalidResponse(expected));
|
|
58384
|
+
fetched.push({ out, bytes: bytes2 });
|
|
58385
|
+
}
|
|
58386
|
+
if (fetched.length) fs74.mkdirSync(to, { recursive: true });
|
|
58387
|
+
return fetched.map(({ out, bytes: bytes2 }) => {
|
|
58388
|
+
fs74.writeFileSync(out, bytes2);
|
|
58389
|
+
say(out);
|
|
58390
|
+
return out;
|
|
58391
|
+
});
|
|
58056
58392
|
}
|
|
58057
58393
|
function category(value, line) {
|
|
58058
58394
|
if (!value) usage2("Missing --category.", line);
|
|
@@ -58091,37 +58427,38 @@ No template matches. ${WITHOUT.en}`);
|
|
|
58091
58427
|
async function templatePreview(name, opts, program2) {
|
|
58092
58428
|
if (!opts.to) usage2("Missing --to.", `${program2} template preview <name> --to <dir>`);
|
|
58093
58429
|
const at = encodeURIComponent(name);
|
|
58094
|
-
const { previews } =
|
|
58095
|
-
|
|
58096
|
-
|
|
58097
|
-
|
|
58098
|
-
|
|
58099
|
-
|
|
58100
|
-
|
|
58101
|
-
const out = path74.join(opts.to, file2.startsWith(`${name}-`) ? file2 : `${name}-${file2}`);
|
|
58102
|
-
fs73.mkdirSync(opts.to, { recursive: true });
|
|
58103
|
-
fs73.writeFileSync(out, bytes2);
|
|
58104
|
-
written.push(out);
|
|
58105
|
-
say(out);
|
|
58106
|
-
}
|
|
58107
|
-
return { name, previews: written };
|
|
58430
|
+
const { previews } = requireResponse(
|
|
58431
|
+
await asJson(await ask(`/${at}/previews`, {}, WITHOUT)),
|
|
58432
|
+
"the template preview list",
|
|
58433
|
+
(value) => entries(value.previews)
|
|
58434
|
+
);
|
|
58435
|
+
if (previews.length === 0) say("\u8FD9\u4E2A\u6A21\u677F\u6CA1\u6709\u9884\u89C8\u56FE\u3002\nThis template has no preview.");
|
|
58436
|
+
return { name, previews: await downloadEntries(name, "previews", previews, opts.to, WITHOUT) };
|
|
58108
58437
|
}
|
|
58109
58438
|
async function templateGet(name, opts, program2) {
|
|
58110
58439
|
if (!opts.to) usage2("Missing --to.", `${program2} template get <name> --to <dir>`);
|
|
58111
58440
|
const to = opts.to;
|
|
58112
58441
|
const at = encodeURIComponent(name);
|
|
58113
|
-
const { template } =
|
|
58442
|
+
const { template } = requireResponse(
|
|
58443
|
+
await asJson(await ask(`/${at}`, {}, WITHOUT)),
|
|
58444
|
+
"the template file list",
|
|
58445
|
+
(value) => isRecord(value.template) && entries(value.template.files)
|
|
58446
|
+
);
|
|
58114
58447
|
const fetched = [];
|
|
58115
58448
|
for (const f of template.files) {
|
|
58116
|
-
const out =
|
|
58117
|
-
if (!out.startsWith(
|
|
58118
|
-
const
|
|
58449
|
+
const out = path75.resolve(to, f.path);
|
|
58450
|
+
if (!out.startsWith(path75.resolve(to) + path75.sep)) refuse4(T.corrupt, WITHOUT);
|
|
58451
|
+
const response = await ask(`/${at}/files/${route(f.path)}`, {}, WITHOUT);
|
|
58452
|
+
const bytes2 = await cloudBytes(response, "a matching template file", { size: f.size }).catch((error62) => {
|
|
58453
|
+
if (!(error62 instanceof BoardError)) throw error62;
|
|
58454
|
+
return refuse4(T.corrupt, WITHOUT, invalidResponse("a matching template file"));
|
|
58455
|
+
});
|
|
58119
58456
|
if (bytes2.byteLength !== f.size || createHash5("sha256").update(bytes2).digest("hex") !== f.sha256) {
|
|
58120
58457
|
refuse4(T.corrupt, WITHOUT);
|
|
58121
58458
|
}
|
|
58122
58459
|
fetched.push({ out, bytes: bytes2 });
|
|
58123
58460
|
}
|
|
58124
|
-
const taken = fetched.filter((f) =>
|
|
58461
|
+
const taken = fetched.filter((f) => fs74.existsSync(f.out)).map((f) => path75.relative(to, f.out));
|
|
58125
58462
|
if (taken.length > 0) {
|
|
58126
58463
|
refuse4({
|
|
58127
58464
|
zh: `\u76EE\u6807\u6587\u4EF6\u5939\u5DF2\u6709\u540C\u540D\u6587\u4EF6\uFF1A${taken.join("\u3001")}\u3002\u8BF7\u6362\u4E00\u4E2A\u6587\u4EF6\u5939\uFF0C\u6216\u5148\u79FB\u8D70\u8FD9\u4E9B\u6587\u4EF6\u3002`,
|
|
@@ -58129,8 +58466,8 @@ async function templateGet(name, opts, program2) {
|
|
|
58129
58466
|
});
|
|
58130
58467
|
}
|
|
58131
58468
|
for (const f of fetched) {
|
|
58132
|
-
|
|
58133
|
-
|
|
58469
|
+
fs74.mkdirSync(path75.dirname(f.out), { recursive: true });
|
|
58470
|
+
fs74.writeFileSync(f.out, f.bytes);
|
|
58134
58471
|
}
|
|
58135
58472
|
say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
|
|
58136
58473
|
Fetched ${name}: ${fetched.length} files into ${to}`);
|
|
@@ -58138,50 +58475,48 @@ Fetched ${name}: ${fetched.length} files into ${to}`);
|
|
|
58138
58475
|
}
|
|
58139
58476
|
async function templateSource(name, opts) {
|
|
58140
58477
|
const at = encodeURIComponent(name);
|
|
58141
|
-
const { source: source2, evidence } =
|
|
58478
|
+
const { source: source2, evidence } = requireResponse(
|
|
58479
|
+
await asJson(await ask(`/${at}/source`)),
|
|
58480
|
+
"the template source and evidence list",
|
|
58481
|
+
(value) => isRecord(value.source) && entries(value.evidence)
|
|
58482
|
+
);
|
|
58483
|
+
const written = opts.to ? await downloadEntries(name, "evidence", evidence, opts.to) : [];
|
|
58142
58484
|
if (source2.original === true) say("\u539F\u521B\u6A21\u677F\uFF0C\u6CA1\u6709\u5916\u90E8\u53C2\u8003\u3002\nAn original template, with no outside reference.");
|
|
58143
58485
|
for (const [k, v] of Object.entries(source2)) if (k !== "original") say(`${k}: ${Array.isArray(v) ? v.join(", ") : String(v)}`);
|
|
58144
|
-
const
|
|
58145
|
-
|
|
58146
|
-
if (!opts.to) {
|
|
58147
|
-
say(`evidence: ${e.path}`);
|
|
58148
|
-
continue;
|
|
58149
|
-
}
|
|
58150
|
-
const out = path74.join(opts.to, `${name}-${path74.basename(e.path)}`);
|
|
58151
|
-
fs73.mkdirSync(opts.to, { recursive: true });
|
|
58152
|
-
fs73.writeFileSync(out, Buffer.from(await (await ask(`/${at}/evidence/${route(e.path)}`)).arrayBuffer()));
|
|
58153
|
-
written.push(out);
|
|
58154
|
-
say(out);
|
|
58155
|
-
}
|
|
58156
|
-
return { name, source: source2, evidence: written.length > 0 ? written : evidence.map((e) => e.path) };
|
|
58486
|
+
if (!opts.to) for (const file2 of evidence) say(`evidence: ${file2.path}`);
|
|
58487
|
+
return { name, source: source2, evidence: opts.to ? written : evidence.map((e) => e.path) };
|
|
58157
58488
|
}
|
|
58158
58489
|
async function templatePublish(dir, opts) {
|
|
58159
|
-
const root2 =
|
|
58160
|
-
const manifest =
|
|
58161
|
-
if (!
|
|
58162
|
-
const meta3 = readTemplateMeta(
|
|
58490
|
+
const root2 = path75.resolve(dir);
|
|
58491
|
+
const manifest = path75.join(root2, "template.md");
|
|
58492
|
+
if (!fs74.existsSync(manifest)) invalid2("\u6587\u4EF6\u5939\u9876\u5C42\u7F3A\u5C11 template.md\u3002", "template.md is missing from the folder\u2019s top level.");
|
|
58493
|
+
const meta3 = readTemplateMeta(fs74.readFileSync(manifest, "utf8"));
|
|
58163
58494
|
const files = walk2(root2);
|
|
58164
|
-
const total = files.reduce((sum, f) => sum +
|
|
58165
|
-
if (total > MAX_BYTES2)
|
|
58495
|
+
const total = files.reduce((sum, f) => sum + fs74.statSync(path75.join(root2, f)).size, 0);
|
|
58496
|
+
if (total > MAX_BYTES2) invalid2("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
|
|
58166
58497
|
for (const extra of [...opts.preview, ...opts.evidence]) {
|
|
58167
|
-
if (!
|
|
58168
|
-
if (
|
|
58169
|
-
|
|
58498
|
+
if (!fs74.existsSync(extra)) invalid2(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
|
|
58499
|
+
if (path75.resolve(extra).startsWith(root2 + path75.sep)) {
|
|
58500
|
+
invalid2(
|
|
58170
58501
|
`${extra} \u5728\u6A21\u677F\u6587\u4EF6\u5939\u5185\uFF1B\u9884\u89C8\u56FE\u4E0E\u6765\u6E90\u51ED\u8BC1\u9700\u653E\u5728\u6A21\u677F\u6587\u4EF6\u5939\u4E4B\u5916\u3002`,
|
|
58171
58502
|
`${extra} is inside the template folder; keep previews and evidence outside it.`
|
|
58172
58503
|
);
|
|
58173
58504
|
}
|
|
58174
58505
|
}
|
|
58175
58506
|
if (meta3.source.original !== true && opts.evidence.length === 0) {
|
|
58176
|
-
|
|
58507
|
+
invalid2("\u53C2\u8003\u5916\u90E8\u4F5C\u54C1\u7684\u6A21\u677F\u9700\u8981\u7528 --evidence \u9644\u4E0A\u91C7\u96C6\u7684\u6765\u6E90\u51ED\u8BC1\u3002", "a template cloned from a reference needs its captured evidence, via --evidence.");
|
|
58177
58508
|
}
|
|
58178
58509
|
const form = new FormData();
|
|
58179
58510
|
form.set("meta", JSON.stringify({ ...meta3, replace: !!opts.replace }));
|
|
58180
|
-
const add2 = (kind, name, file2) => form.append(`${kind}:${name}`, new Blob([
|
|
58181
|
-
for (const f of files) add2("files", f,
|
|
58182
|
-
for (const f of opts.preview) add2("previews",
|
|
58183
|
-
for (const f of opts.evidence) add2("evidence",
|
|
58184
|
-
const done =
|
|
58511
|
+
const add2 = (kind, name, file2) => form.append(`${kind}:${name}`, new Blob([fs74.readFileSync(file2)]), path75.basename(name));
|
|
58512
|
+
for (const f of files) add2("files", f, path75.join(root2, f));
|
|
58513
|
+
for (const f of opts.preview) add2("previews", path75.basename(f), f);
|
|
58514
|
+
for (const f of opts.evidence) add2("evidence", path75.basename(f), f);
|
|
58515
|
+
const done = requireResponse(
|
|
58516
|
+
await asJson(await ask("", { method: "POST", body: form })),
|
|
58517
|
+
"a template publication receipt",
|
|
58518
|
+
(value) => value.name === meta3.name && typeof value.replaced === "boolean"
|
|
58519
|
+
);
|
|
58185
58520
|
say(
|
|
58186
58521
|
done.replaced ? `\u5DF2\u66FF\u6362 ${done.name}\uFF1A${files.length} \u4E2A\u6587\u4EF6\u3002
|
|
58187
58522
|
Replaced ${done.name}: ${files.length} files.` : `\u5DF2\u53D1\u5E03 ${done.name}\uFF1A${files.length} \u4E2A\u6587\u4EF6\u3002
|
|
@@ -58190,19 +58525,23 @@ Published ${done.name}: ${files.length} files.`
|
|
|
58190
58525
|
return { name: done.name, replaced: done.replaced, files };
|
|
58191
58526
|
}
|
|
58192
58527
|
async function templateDelete(name) {
|
|
58193
|
-
|
|
58528
|
+
requireResponse(
|
|
58529
|
+
await asJson(await ask(`/${encodeURIComponent(name)}`, { method: "DELETE" })),
|
|
58530
|
+
"confirmation that the template was deleted",
|
|
58531
|
+
(value) => value.name === name && value.deleted === true
|
|
58532
|
+
);
|
|
58194
58533
|
say(`\u5DF2\u4ECE\u6A21\u677F\u5E93\u5220\u9664 ${name}\u3002
|
|
58195
58534
|
Deleted ${name} from the catalog.`);
|
|
58196
58535
|
return { name, deleted: true };
|
|
58197
58536
|
}
|
|
58198
58537
|
async function templateShowcase(name, dir) {
|
|
58199
|
-
const file2 =
|
|
58200
|
-
if (!
|
|
58538
|
+
const file2 = path75.join(dir, "showcase.json");
|
|
58539
|
+
if (!fs74.existsSync(file2)) invalid2(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
|
|
58201
58540
|
let meta3;
|
|
58202
58541
|
try {
|
|
58203
|
-
meta3 = JSON.parse(
|
|
58542
|
+
meta3 = JSON.parse(fs74.readFileSync(file2, "utf8"));
|
|
58204
58543
|
} catch {
|
|
58205
|
-
return
|
|
58544
|
+
return invalid2("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
|
|
58206
58545
|
}
|
|
58207
58546
|
const sides = [meta3.original, meta3.recreation].filter((s) => !!s && typeof s === "object");
|
|
58208
58547
|
const pages = (Array.isArray(meta3.pages) ? meta3.pages : []).flatMap(
|
|
@@ -58212,18 +58551,22 @@ async function templateShowcase(name, dir) {
|
|
|
58212
58551
|
const form = new FormData();
|
|
58213
58552
|
form.set("meta", JSON.stringify(meta3));
|
|
58214
58553
|
for (const p of new Set(named2)) {
|
|
58215
|
-
const at =
|
|
58216
|
-
if (!
|
|
58217
|
-
form.append(`media:${p}`, new Blob([
|
|
58218
|
-
}
|
|
58219
|
-
const done =
|
|
58554
|
+
const at = path75.join(dir, p);
|
|
58555
|
+
if (!fs74.existsSync(at)) invalid2(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at}\u3002`, `${at} does not exist.`);
|
|
58556
|
+
form.append(`media:${p}`, new Blob([fs74.readFileSync(at)]), p);
|
|
58557
|
+
}
|
|
58558
|
+
const done = requireResponse(
|
|
58559
|
+
await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form })),
|
|
58560
|
+
"a showcase publication receipt",
|
|
58561
|
+
(value) => value.name === name && value.files === new Set(named2).size
|
|
58562
|
+
);
|
|
58220
58563
|
say(`\u5DF2\u66F4\u65B0 ${name} \u7684\u5C55\u793A\u8D44\u6599\uFF1A${done.files} \u4E2A\u6587\u4EF6\u3002
|
|
58221
58564
|
Updated ${name}'s showcase: ${done.files} files.`);
|
|
58222
58565
|
return { name, files: done.files };
|
|
58223
58566
|
}
|
|
58224
58567
|
function walk2(root2, sub = "") {
|
|
58225
58568
|
const out = [];
|
|
58226
|
-
for (const entry of
|
|
58569
|
+
for (const entry of fs74.readdirSync(path75.join(root2, sub), { withFileTypes: true })) {
|
|
58227
58570
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
58228
58571
|
const rel3 = sub ? `${sub}/${entry.name}` : entry.name;
|
|
58229
58572
|
if (entry.isDirectory()) out.push(...walk2(root2, rel3));
|
|
@@ -58233,40 +58576,40 @@ function walk2(root2, sub = "") {
|
|
|
58233
58576
|
}
|
|
58234
58577
|
function readTemplateMeta(text5) {
|
|
58235
58578
|
const m = /^---\n([\s\S]*?)\n---/.exec(text5.replace(/\r\n/g, "\n"));
|
|
58236
|
-
if (!m)
|
|
58579
|
+
if (!m) invalid2("template.md \u7F3A\u5C11 frontmatter\u3002", "template.md has no frontmatter.");
|
|
58237
58580
|
const fm = parseYamlSubset(m[1] ?? "");
|
|
58238
58581
|
const text_ = (k, oneLine2 = true) => {
|
|
58239
58582
|
const v = typeof fm[k] === "string" ? fm[k].trim() : "";
|
|
58240
|
-
if (!v)
|
|
58241
|
-
if (oneLine2 && v.includes("\n"))
|
|
58583
|
+
if (!v) invalid2(`\u7F3A\u5C11 ${k}\u3002`, `${k} is missing.`);
|
|
58584
|
+
if (oneLine2 && v.includes("\n")) invalid2(`${k} \u53EA\u80FD\u662F\u4E00\u884C\u3002`, `${k} is one line.`);
|
|
58242
58585
|
return v;
|
|
58243
58586
|
};
|
|
58244
58587
|
const name = text_("name");
|
|
58245
|
-
if (!SLUG.test(name))
|
|
58588
|
+
if (!SLUG.test(name)) invalid2(`name \u53EA\u80FD\u7531\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u548C\u8FDE\u5B57\u7B26\u7EC4\u6210\uFF0C\u4F8B\u5982 hero-tilted-screen\u3002`, `name is lowercase words joined by hyphens, like hero-tilted-screen.`);
|
|
58246
58589
|
const cat = text_("category");
|
|
58247
|
-
if (!SLUG.test(cat))
|
|
58590
|
+
if (!SLUG.test(cat)) invalid2("category \u53EA\u80FD\u662F\u5C0F\u5199\u82F1\u6587\u77ED\u8BCD\uFF0C\u4F8B\u5982 ui \u6216 video\u3002", "category is a lowercase word, like ui or video.");
|
|
58248
58591
|
const rawTags = fm.tags === void 0 || fm.tags === "" ? [] : fm.tags;
|
|
58249
|
-
if (!Array.isArray(rawTags)) return
|
|
58592
|
+
if (!Array.isArray(rawTags)) return invalid2("tags \u9700\u8981\u662F\u5217\u8868\uFF0C\u4F8B\u5982 [hero, saas]\u3002", "tags is a list, like [hero, saas].");
|
|
58250
58593
|
const tags = [...new Set(rawTags.map(String))];
|
|
58251
58594
|
const bad = tags.filter((t) => !SLUG.test(t));
|
|
58252
|
-
if (bad.length > 0)
|
|
58595
|
+
if (bad.length > 0) invalid2(`\u6807\u7B7E ${bad.join("\u3001")} \u4E0D\u5408\u89C4\uFF1A\u53EA\u80FD\u7528\u5C0F\u5199\u82F1\u6587\u77ED\u8BCD\u3002`, `tag ${bad.join(", ")}: use lowercase words joined by hyphens.`);
|
|
58253
58596
|
const access = fm.access === void 0 || fm.access === "" ? "pro" : fm.access;
|
|
58254
|
-
if (access !== "free" && access !== "pro") return
|
|
58597
|
+
if (access !== "free" && access !== "pro") return invalid2("access \u53EA\u80FD\u662F free \u6216 pro\u3002", "access is free or pro.");
|
|
58255
58598
|
const source2 = fm.source === void 0 || fm.source === "" ? { original: true } : fm.source;
|
|
58256
58599
|
if (typeof source2 !== "object" || Array.isArray(source2)) {
|
|
58257
|
-
|
|
58600
|
+
invalid2("source \u5199\u6CD5\u4E0D\u5BF9\uFF1B\u539F\u521B\u6A21\u677F\u53EF\u4EE5\u4E0D\u5199\uFF0C\u6216\u5199 source: { original: true }\u3002", "source is malformed; an original can omit it or say original: true.");
|
|
58258
58601
|
}
|
|
58259
58602
|
const s = source2;
|
|
58260
58603
|
if (s.original !== true) {
|
|
58261
|
-
if (typeof s.site !== "string" || !/^https?:\/\//.test(s.site))
|
|
58604
|
+
if (typeof s.site !== "string" || !/^https?:\/\//.test(s.site)) invalid2("source.site \u9700\u8981\u662F\u539F\u7AD9\u7F51\u5740\u3002", "source.site is the referenced site\u2019s URL.");
|
|
58262
58605
|
if (!Array.isArray(s.references) || s.references.length === 0) {
|
|
58263
|
-
|
|
58606
|
+
invalid2("source.references \u9700\u8981\u5217\u51FA\u5B9E\u9645\u53C2\u8003\u8D44\u6599\u7684\u7F51\u5740\u3002", "source.references lists the URLs actually referenced.");
|
|
58264
58607
|
}
|
|
58265
58608
|
if (typeof s.captured !== "string" || !CAPTURED.test(s.captured)) {
|
|
58266
|
-
|
|
58609
|
+
invalid2("source.captured \u9700\u8981\u5E26\u65F6\u533A\u7684\u91C7\u96C6\u65F6\u95F4\uFF0C\u4F8B\u5982 2026-10-16T09:00:00+08:00\u3002", "source.captured is the capture time with its time zone, like 2026-10-16T09:00:00+08:00.");
|
|
58267
58610
|
}
|
|
58268
58611
|
if (typeof s.note !== "string" || !s.note.trim()) {
|
|
58269
|
-
|
|
58612
|
+
invalid2("source.note \u9700\u8981\u8BF4\u660E\u51ED\u8BC1\u662F\u4EC0\u4E48\u3001\u7531\u8C01\u91C7\u96C6\u3002", "source.note says what the evidence is and who captured it.");
|
|
58270
58613
|
}
|
|
58271
58614
|
}
|
|
58272
58615
|
return {
|
|
@@ -58335,13 +58678,14 @@ function unquote3(v) {
|
|
|
58335
58678
|
}
|
|
58336
58679
|
return v;
|
|
58337
58680
|
}
|
|
58338
|
-
var SLUG, CAPTURED, MAX_BYTES2, WITHOUT, T,
|
|
58681
|
+
var SLUG, CAPTURED, MAX_BYTES2, WITHOUT, T, route;
|
|
58339
58682
|
var init_cloud_template = __esm({
|
|
58340
58683
|
"../cli/src/commands/cloud-template.ts"() {
|
|
58341
58684
|
"use strict";
|
|
58342
58685
|
init_config();
|
|
58343
58686
|
init_session();
|
|
58344
58687
|
init_io();
|
|
58688
|
+
init_response();
|
|
58345
58689
|
init_paths();
|
|
58346
58690
|
init_cloud();
|
|
58347
58691
|
SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
@@ -58365,7 +58709,6 @@ var init_cloud_template = __esm({
|
|
|
58365
58709
|
en: "A downloaded file did not match the catalog, so nothing was written. Try again."
|
|
58366
58710
|
}
|
|
58367
58711
|
};
|
|
58368
|
-
asJson = async (res) => await res.json();
|
|
58369
58712
|
route = (p) => p.split("/").map(encodeURIComponent).join("/");
|
|
58370
58713
|
}
|
|
58371
58714
|
});
|
|
@@ -62472,7 +62815,7 @@ var init_describe_project = __esm({
|
|
|
62472
62815
|
var discuss_goal_default;
|
|
62473
62816
|
var init_discuss_goal = __esm({
|
|
62474
62817
|
"../cli/src/guide/discuss-goal.md"() {
|
|
62475
|
-
discuss_goal_default = '# Discuss a goal\n\
|
|
62818
|
+
discuss_goal_default = '# Discuss a goal\n\nResearch how the requested outcome can be achieved before defining a Goal. Explain viable approaches and key tradeoffs in the discussion, then save the requested outcome and acceptance criteria.\n\n- **Investigations**: finish checks and diagnosis here; save a change only when findings establish it. Report unverified work plainly.\n- **Goals**: save independent deliverables separately. Update existing goals rather than duplicate them.\n- **Studio**: choose the fitting installed Studio, preferring the user\'s choice; read its Additional Notes with `akb studio rule <studio>` and honor their scope.\n- **Select Previews**: read the chosen Studio\'s `STUDIO.md` with `akb raw file <studio> STUDIO.md` and linked Studio files as needed with `akb raw file <studio> <path>`. Match deliverables that need review to Studio Previews. Define a Goal Preview for a result that needs review and lacks a Studio Preview.\n- **Review** independent Previews in parallel by default. Use Studio or Goal Preview names, e.g. `--review \'Tech choices + UI design\'`. Add `->` when the next group needs the previous group\'s approvals. Verify the saved plan.\n- **Review state**: pass `--review \'\'` for no extra approval, leave the plan undecided while a decision is missing, and omit the option when keeping a saved plan.\n- **Decisions**: ask only about choices the user must make, and recommend an option.\n- **Save**: in a web discussion, use `akb goal` in the current session, including on retry. Say the goal is ready to save when the reply ends. If the command still fails, say it was not saved.\n- **Start**: the user starts each Goal from the page; its effective review arrangement governs output approval. Confirm changes to task-specific Preview definitions before making the affected output.\n- **Communication**: the remote user sees tasks and previews. Use plain words and button labels, omitting internal paths, commands and tools.\n\n## Goal format\n\nUse exactly these three fields on create and update. Include only what the user requested or confirmed.\n\nPass the one-line title separately with `--title`. Use this template for `--body-file`:\n\n```markdown\n<The requested outcome in at most 150 words.>\n\n## Done when\n\n- <A verifiable condition for the requested outcome.>\n```\n\n\n## Custom Preview definitions\n\nPass a JSON array with `--preview-definitions-file`. Use a stable ID, English and Chinese titles, and concise requirements. Omit the file to keep definitions, or pass `[]` to clear them.\n\n```json\n[{\n "id": "accessibility-report",\n "title": {"en": "Accessibility report", "zh": "\u65E0\u969C\u788D\u68C0\u67E5\u62A5\u544A"},\n "instructions": "Check keyboard navigation, visible focus and contrast. Include steps to reproduce issues."\n}]\n```\n\nUse the title in a Flow such as `--review \'UI design -> Accessibility report\'` when preparation requires an earlier approval.\n';
|
|
62476
62819
|
}
|
|
62477
62820
|
});
|
|
62478
62821
|
|
|
@@ -62714,20 +63057,26 @@ var init_guide2 = __esm({
|
|
|
62714
63057
|
|
|
62715
63058
|
// ../cli/src/commands/studio.ts
|
|
62716
63059
|
import crypto7 from "node:crypto";
|
|
62717
|
-
import
|
|
62718
|
-
import
|
|
63060
|
+
import fs75 from "node:fs";
|
|
63061
|
+
import path76 from "node:path";
|
|
62719
63062
|
function cmdStudioList() {
|
|
62720
63063
|
if (!studiosReachable().ok) die(NEEDS_CLOUD, "needs-cloud");
|
|
62721
63064
|
const rows = studios();
|
|
62722
|
-
|
|
62723
|
-
|
|
63065
|
+
const result = { studios: rows.map(({ id: id2, name, names: names2, icon: icon3, needsArtifact, previews, description, builtIn }) => ({ id: id2, name, names: names2, icon: icon3, needsArtifact, previews, description, builtIn })), problems: studioFileProblems() };
|
|
63066
|
+
const { cached: cached3, problem } = studioVerification();
|
|
63067
|
+
if (!problem || cached3) for (const flow of rows) say(`${flow.id} ${flow.name} ${flow.previews.map((p) => p.id).join(", ")}`);
|
|
63068
|
+
if (problem) throw cloudError(
|
|
63069
|
+
{ ...problem, message: `Cloud Studio verification failed. ${cached3 ? "Showing cached Studios." : "No cached Studio list is available."} ${problem.message}` },
|
|
63070
|
+
{ details: { ...result, cached: cached3, offline: problem.retryable } }
|
|
63071
|
+
);
|
|
63072
|
+
return result;
|
|
62724
63073
|
}
|
|
62725
63074
|
function cmdStudioDiagram(_id, _card, _folder) {
|
|
62726
63075
|
die("Studios have no agent graph. Read STUDIO.md for instructions and Preview outputs.", "bad-args");
|
|
62727
63076
|
}
|
|
62728
63077
|
function cmdStudioValidate(folder2) {
|
|
62729
|
-
const dir =
|
|
62730
|
-
if (!
|
|
63078
|
+
const dir = path76.resolve(folder2);
|
|
63079
|
+
if (!fs75.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder2} is not a folder`, "bad-args");
|
|
62731
63080
|
const files = readStudioFolder(dir);
|
|
62732
63081
|
let builtin = false;
|
|
62733
63082
|
try {
|
|
@@ -62743,17 +63092,24 @@ function cmdStudioValidate(folder2) {
|
|
|
62743
63092
|
}
|
|
62744
63093
|
async function cmdStudioPull(id2, folder2) {
|
|
62745
63094
|
const cloudId = cloudIdOf(id2);
|
|
62746
|
-
if (!cloudId)
|
|
62747
|
-
|
|
62748
|
-
|
|
63095
|
+
if (!cloudId) {
|
|
63096
|
+
const { problem } = studioVerification();
|
|
63097
|
+
if (problem) throw cloudError(problem);
|
|
63098
|
+
found(id2);
|
|
63099
|
+
}
|
|
63100
|
+
const dir = path76.resolve(folder2 ?? id2);
|
|
63101
|
+
if (fs75.existsSync(dir) && fs75.readdirSync(dir).length) die(`${folder2 ?? id2} is not empty`, "bad-args");
|
|
62749
63102
|
const read5 = await call("GET", `/v1/studios/${encodeURIComponent(cloudId)}`);
|
|
62750
|
-
|
|
62751
|
-
|
|
63103
|
+
const { version: version2, files } = requireResponse(
|
|
63104
|
+
cloudOk(read5, read5.ok || read5.code !== "not_found" ? void 0 : "no-such-studio"),
|
|
63105
|
+
"the Studio version and files",
|
|
63106
|
+
(value) => value.id === cloudId && isStudioVersion(value.version) && isStudioFiles(value.files)
|
|
63107
|
+
);
|
|
62752
63108
|
for (const [file2, text5] of Object.entries({ ...files, [VERSION_FILE]: versionText(cloudId, version2) })) {
|
|
62753
|
-
const full =
|
|
62754
|
-
|
|
63109
|
+
const full = path76.join(dir, ...file2.split("/"));
|
|
63110
|
+
fs75.mkdirSync(path76.dirname(full), { recursive: true });
|
|
62755
63111
|
const data = isAboutFile(file2) && !file2.endsWith(".md") && /^data:[^;]+;base64,/.exec(text5);
|
|
62756
|
-
|
|
63112
|
+
fs75.writeFileSync(full, data ? Buffer.from(text5.slice(data[0].length), "base64") : text5);
|
|
62757
63113
|
}
|
|
62758
63114
|
const shown = folder2 ?? `./${id2}`;
|
|
62759
63115
|
say(`Pulled ${id2} v${version2} into ${shown}.`);
|
|
@@ -62765,53 +63121,60 @@ function publicationFiles(dir) {
|
|
|
62765
63121
|
return checked.files;
|
|
62766
63122
|
}
|
|
62767
63123
|
async function publishFolder(dir, route2, body, requestId) {
|
|
62768
|
-
const pendingFile =
|
|
63124
|
+
const pendingFile = path76.join(dir, ".publication.json");
|
|
62769
63125
|
const hash3 = crypto7.createHash("sha256").update(JSON.stringify({ route: route2, files: body.files, workspace: body.workspace })).digest("hex");
|
|
62770
63126
|
let held4;
|
|
62771
63127
|
try {
|
|
62772
|
-
held4 = JSON.parse(
|
|
63128
|
+
held4 = JSON.parse(fs75.readFileSync(pendingFile, "utf8"));
|
|
62773
63129
|
} catch {
|
|
62774
63130
|
}
|
|
62775
63131
|
if (requestId && held4?.requestId === requestId && held4.hash !== hash3) die("This request ID already names different files; use a new request ID.", "bad-args");
|
|
62776
63132
|
const replay = held4?.hash === hash3 && held4.route === route2 && (!requestId || held4.requestId === requestId) && (body.expectedVersion === held4.body.expectedVersion || body.expectedVersion === held4.resultVersion);
|
|
62777
63133
|
const pending = replay ? held4 : { requestId: requestId ?? crypto7.randomUUID(), hash: hash3, body, route: route2 };
|
|
62778
|
-
|
|
63134
|
+
fs75.writeFileSync(pendingFile, JSON.stringify(pending, null, 2) + "\n");
|
|
62779
63135
|
const res = await call(route2 === "/v1/studios" ? "POST" : "PATCH", route2, pending.body, pending.requestId);
|
|
62780
|
-
|
|
62781
|
-
|
|
63136
|
+
const { id: id2, version: version2 } = requireResponse(
|
|
63137
|
+
cloudOk(res, !res.ok && ["version_conflict", "conflict"].includes(res.code ?? "") ? "studio-moved" : void 0),
|
|
63138
|
+
"confirmation of the saved Studio version",
|
|
63139
|
+
(value) => hasText(value.id) && /^wf_[\w-]+$/.test(value.id) && isStudioVersion(value.version) && (pending.body.expectedVersion === void 0 || route2 === `/v1/studios/${encodeURIComponent(value.id)}` && value.version === pending.body.expectedVersion + 1)
|
|
63140
|
+
);
|
|
62782
63141
|
pending.resultVersion = version2;
|
|
62783
|
-
|
|
62784
|
-
|
|
63142
|
+
fs75.writeFileSync(pendingFile, JSON.stringify(pending, null, 2) + "\n");
|
|
63143
|
+
fs75.writeFileSync(path76.join(dir, VERSION_FILE), versionText(id2, version2));
|
|
62785
63144
|
say(`Saved ${studioName(id2)} v${version2}. New tasks take it.`);
|
|
62786
63145
|
return { id: id2, version: version2, changed: true, requestId: pending.requestId };
|
|
62787
63146
|
}
|
|
62788
63147
|
async function cmdStudioCreate(folder2, opts) {
|
|
62789
63148
|
if (!opts.requestId) die("--request-id is required", "bad-args");
|
|
62790
|
-
const dir =
|
|
63149
|
+
const dir = path76.resolve(folder2);
|
|
62791
63150
|
const files = publicationFiles(dir);
|
|
62792
63151
|
const workspace2 = opts.workspace ?? (await cloudScope()).workspace;
|
|
62793
63152
|
return publishFolder(dir, "/v1/studios", { files, workspace: workspace2 }, opts.requestId);
|
|
62794
63153
|
}
|
|
62795
63154
|
async function cmdStudioPush(folder2, opts) {
|
|
62796
|
-
const dir =
|
|
63155
|
+
const dir = path76.resolve(folder2);
|
|
62797
63156
|
let pulled = null;
|
|
62798
63157
|
try {
|
|
62799
|
-
pulled = JSON.parse(
|
|
63158
|
+
pulled = JSON.parse(fs75.readFileSync(path76.join(dir, VERSION_FILE), "utf8"));
|
|
62800
63159
|
} catch {
|
|
62801
63160
|
}
|
|
62802
63161
|
if (!pulled?.id || !Number.isInteger(pulled.version) || pulled.version < 1) die(`${folder2} has no valid version.json; pull again.`, "bad-args");
|
|
62803
63162
|
const { id: id2, version: version2 } = pulled;
|
|
62804
63163
|
if (id2.startsWith("wf_builtin_")) die("Copy this studio before editing it.", "studio-read-only");
|
|
62805
63164
|
const files = publicationFiles(dir);
|
|
62806
|
-
if (!
|
|
63165
|
+
if (!fs75.existsSync(path76.join(dir, ".publication.json")) && !opts.requestId) {
|
|
62807
63166
|
const now = await call("GET", `/v1/studios/${encodeURIComponent(id2)}`);
|
|
62808
|
-
if (now.ok && now.value.version === version2 && JSON.stringify(files) === JSON.stringify(Object.fromEntries(Object.entries(now.value.files).filter(([f]) => f !== VERSION_FILE).sort()))) {
|
|
63167
|
+
if (now.ok && now.value.version === version2 && isStudioFiles(now.value.files) && JSON.stringify(files) === JSON.stringify(Object.fromEntries(Object.entries(now.value.files).filter(([f]) => f !== VERSION_FILE).sort()))) {
|
|
62809
63168
|
say(`${studioName(id2)} is unchanged (v${version2}).`);
|
|
62810
63169
|
return { id: studioName(id2), version: version2, changed: false, ...opts.dryRun ? { dryRun: true } : {} };
|
|
62811
63170
|
}
|
|
62812
63171
|
}
|
|
62813
63172
|
if (opts.dryRun) {
|
|
62814
|
-
const now =
|
|
63173
|
+
const now = requireResponse(
|
|
63174
|
+
cloudOk(await call("GET", `/v1/studios/${encodeURIComponent(id2)}`)),
|
|
63175
|
+
"the current Studio version",
|
|
63176
|
+
(value) => isStudioVersion(value.version)
|
|
63177
|
+
);
|
|
62815
63178
|
if (now.version !== version2) die(`The studio is at v${now.version}; pull again.`, "studio-moved");
|
|
62816
63179
|
say(`${studioName(id2)} would push v${version2 + 1}.`);
|
|
62817
63180
|
return { id: studioName(id2), version: version2 + 1, changed: true, dryRun: true };
|
|
@@ -62822,27 +63185,36 @@ function noteText({ file: file2, text: text5 }) {
|
|
|
62822
63185
|
if (file2 !== void 0 && text5 !== void 0) die("pass --file or --text, not both", "bad-args");
|
|
62823
63186
|
if (file2 !== void 0) {
|
|
62824
63187
|
try {
|
|
62825
|
-
return
|
|
63188
|
+
return fs75.readFileSync(file2, "utf8").trim();
|
|
62826
63189
|
} catch {
|
|
62827
63190
|
die(`can't read ${file2}`, "bad-args");
|
|
62828
63191
|
}
|
|
62829
63192
|
}
|
|
62830
63193
|
return text5?.trim();
|
|
62831
63194
|
}
|
|
62832
|
-
function cloudOk(res) {
|
|
62833
|
-
if (!res.ok)
|
|
63195
|
+
function cloudOk(res, kind) {
|
|
63196
|
+
if (!res.ok) throw cloudError({
|
|
63197
|
+
code: res.code ?? "unreachable",
|
|
63198
|
+
message: res.error,
|
|
63199
|
+
status: res.status,
|
|
63200
|
+
retryable: res.retryable ?? temporaryCloudFailure(res)
|
|
63201
|
+
}, { kind });
|
|
62834
63202
|
return res.value;
|
|
62835
63203
|
}
|
|
62836
63204
|
async function cloudScope() {
|
|
62837
63205
|
const project2 = boardProject();
|
|
62838
63206
|
if (!project2) die("This board is not linked to a Cloud project.", "needs-cloud");
|
|
62839
63207
|
const held4 = cloudOk(await call("GET", `/v1/projects/${enc2(project2)}`));
|
|
62840
|
-
return { project: project2, workspace: held4.workspace };
|
|
63208
|
+
return { project: project2, workspace: requireResponse(held4, "the Studio workspace", (value) => hasText(value.workspace)).workspace };
|
|
62841
63209
|
}
|
|
62842
63210
|
async function cmdStudioRule(name, opts) {
|
|
62843
63211
|
const rule = noteText(opts);
|
|
62844
63212
|
const { workspace: workspace2 } = await cloudScope();
|
|
62845
|
-
const held4 =
|
|
63213
|
+
const held4 = requireResponse(
|
|
63214
|
+
cloudOk(await call("GET", `/v1/workspaces/${enc2(workspace2)}/studio-rules`)),
|
|
63215
|
+
"the workspace\u2019s Studio rules",
|
|
63216
|
+
(value) => Array.isArray(value.studios)
|
|
63217
|
+
);
|
|
62846
63218
|
const flow = held4.studios.find((w) => studioName(w.id) === name);
|
|
62847
63219
|
if (!flow) {
|
|
62848
63220
|
die(`no studio called "${name}" here. There are: ${held4.studios.map((w) => studioName(w.id)).join(", ")}.`, {
|
|
@@ -62855,7 +63227,11 @@ async function cmdStudioRule(name, opts) {
|
|
|
62855
63227
|
say(now || `${name} has no rules`);
|
|
62856
63228
|
return { studio: name, rule: now };
|
|
62857
63229
|
}
|
|
62858
|
-
|
|
63230
|
+
requireResponse(
|
|
63231
|
+
cloudOk(await call("PUT", `/v1/workspaces/${enc2(workspace2)}/studios/${enc2(flow.id)}/rule`, { rule })),
|
|
63232
|
+
"the saved Studio rules",
|
|
63233
|
+
(value) => value.id === flow.id && value.rule === rule
|
|
63234
|
+
);
|
|
62859
63235
|
say(`${rule ? "saved" : "cleared"} the rules of ${name}`);
|
|
62860
63236
|
return { studio: name, rule };
|
|
62861
63237
|
}
|
|
@@ -62863,7 +63239,11 @@ async function cmdStudioInstructions(agent, opts) {
|
|
|
62863
63239
|
const rule = noteText(opts);
|
|
62864
63240
|
const project2 = boardProject();
|
|
62865
63241
|
if (!project2) die("This board is not linked to a Cloud project.", "needs-cloud");
|
|
62866
|
-
const own2 =
|
|
63242
|
+
const own2 = requireResponse(
|
|
63243
|
+
cloudOk(await call("GET", `/v1/projects/${enc2(project2)}/agents`)),
|
|
63244
|
+
"the project\u2019s agent instructions",
|
|
63245
|
+
(value) => Array.isArray(value.board) && Array.isArray(value.data)
|
|
63246
|
+
);
|
|
62867
63247
|
if (!own2.board.includes(agent)) {
|
|
62868
63248
|
die(`no agent called "${agent}" here. There are: ${own2.board.join(", ")}.`, { kind: "no-such-agent", agent });
|
|
62869
63249
|
}
|
|
@@ -62872,7 +63252,11 @@ async function cmdStudioInstructions(agent, opts) {
|
|
|
62872
63252
|
say(now || `${agent} has no instructions`);
|
|
62873
63253
|
return { agent, rule: now, scope: "project" };
|
|
62874
63254
|
}
|
|
62875
|
-
|
|
63255
|
+
requireResponse(
|
|
63256
|
+
cloudOk(await call("PUT", `/v1/projects/${enc2(project2)}/agents/${enc2(agent)}`, { rule })),
|
|
63257
|
+
"the saved instructions",
|
|
63258
|
+
(value) => value.agent === agent && value.rule === rule
|
|
63259
|
+
);
|
|
62876
63260
|
say(rule ? `saved ${agent}'s instructions (this project)` : `cleared ${agent}'s instructions`);
|
|
62877
63261
|
return { agent, rule, scope: "project" };
|
|
62878
63262
|
}
|
|
@@ -62888,6 +63272,7 @@ var init_studio3 = __esm({
|
|
|
62888
63272
|
init_studio_files();
|
|
62889
63273
|
init_board_files();
|
|
62890
63274
|
init_tasks();
|
|
63275
|
+
init_response();
|
|
62891
63276
|
found = (id2) => {
|
|
62892
63277
|
const flow = studioById(id2);
|
|
62893
63278
|
if (!flow) {
|
|
@@ -62986,7 +63371,7 @@ var init_progress = __esm({
|
|
|
62986
63371
|
});
|
|
62987
63372
|
|
|
62988
63373
|
// ../cli/src/lib/agent/complete.ts
|
|
62989
|
-
import
|
|
63374
|
+
import fs76 from "node:fs";
|
|
62990
63375
|
function completeDelivery(named2, result = {}) {
|
|
62991
63376
|
const commit = result.commit?.toLowerCase();
|
|
62992
63377
|
const branch = result.branch;
|
|
@@ -63009,7 +63394,7 @@ function completeDelivery(named2, result = {}) {
|
|
|
63009
63394
|
const run3 = store.runs.find((r) => r.sessionId === sessionId);
|
|
63010
63395
|
const current = store.runs.filter((r) => r.deliveryId === delivery2.deliveryId && ["implement", "scheduled"].includes(r.action)).pop();
|
|
63011
63396
|
const liveCard = delivery2.cardId === null ? null : cardFile(delivery2.cardId);
|
|
63012
|
-
const restored = liveCard && parseFrontmatter(
|
|
63397
|
+
const restored = liveCard && parseFrontmatter(fs76.readFileSync(liveCard, "utf8")).meta?.restored;
|
|
63013
63398
|
if (restored && Date.parse(restored) > (run3?.startedAt ?? 0)) throw new Error("This delivery predates task restoration.");
|
|
63014
63399
|
if (!run3 || run3.deliveryId !== delivery2.deliveryId) throw new Error("This run does not own the delivery.");
|
|
63015
63400
|
const pending = receipts[deliveryStep(delivery2)];
|
|
@@ -63180,16 +63565,16 @@ var init_start = __esm({
|
|
|
63180
63565
|
});
|
|
63181
63566
|
|
|
63182
63567
|
// ../cli/src/lib/agent/task-chats.ts
|
|
63183
|
-
import
|
|
63184
|
-
import
|
|
63568
|
+
import fs77 from "node:fs";
|
|
63569
|
+
import path77 from "node:path";
|
|
63185
63570
|
function taskChatFile(task, home3) {
|
|
63186
63571
|
if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
|
|
63187
|
-
return
|
|
63572
|
+
return path77.join(taskChatsDir(home3), `${task}.jsonl`);
|
|
63188
63573
|
}
|
|
63189
63574
|
function readTaskChat(task, home3) {
|
|
63190
63575
|
let text5;
|
|
63191
63576
|
try {
|
|
63192
|
-
text5 =
|
|
63577
|
+
text5 = fs77.readFileSync(taskChatFile(task, home3), "utf8");
|
|
63193
63578
|
} catch {
|
|
63194
63579
|
return [];
|
|
63195
63580
|
}
|
|
@@ -63210,13 +63595,13 @@ var init_task_chats = __esm({
|
|
|
63210
63595
|
"use strict";
|
|
63211
63596
|
init_home();
|
|
63212
63597
|
TASK = /^[\w-]{1,100}$/;
|
|
63213
|
-
taskChatsDir = (home3 = machineHome()) =>
|
|
63598
|
+
taskChatsDir = (home3 = machineHome()) => path77.join(home3, "chats");
|
|
63214
63599
|
}
|
|
63215
63600
|
});
|
|
63216
63601
|
|
|
63217
63602
|
// ../cli/src/lib/agent/memory-review.ts
|
|
63218
|
-
import
|
|
63219
|
-
import
|
|
63603
|
+
import fs78 from "node:fs";
|
|
63604
|
+
import path78 from "node:path";
|
|
63220
63605
|
function taskChatsToReview(tasks) {
|
|
63221
63606
|
const out = [];
|
|
63222
63607
|
for (const ref of [...new Set(tasks)]) {
|
|
@@ -63238,8 +63623,8 @@ function readArchived2(id2) {
|
|
|
63238
63623
|
const found2 = Number.isInteger(id2) && id2 > 0 ? locateArchived(id2) : null;
|
|
63239
63624
|
if (!found2) return null;
|
|
63240
63625
|
try {
|
|
63241
|
-
const file2 = found2.kind === "group" ?
|
|
63242
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
63626
|
+
const file2 = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
|
|
63627
|
+
const { meta: meta3, body } = parseFrontmatter(fs78.readFileSync(file2, "utf8"));
|
|
63243
63628
|
if (!meta3) return null;
|
|
63244
63629
|
return { id: id2, title: meta3.title, modules: meta3.modules ?? [], studio: meta3.studio ?? "", previews: meta3.previews ?? [], rejected: meta3.rejected, body };
|
|
63245
63630
|
} catch {
|
|
@@ -63300,18 +63685,18 @@ var init_memory_review = __esm({
|
|
|
63300
63685
|
});
|
|
63301
63686
|
|
|
63302
63687
|
// ../cli/src/lib/agent/dismissal-review.ts
|
|
63303
|
-
import
|
|
63304
|
-
import
|
|
63688
|
+
import fs79 from "node:fs";
|
|
63689
|
+
import path79 from "node:path";
|
|
63305
63690
|
function rejectionsToReview() {
|
|
63306
63691
|
const scratch = process.env.AI4KANBAN_REJECTION_INPUT;
|
|
63307
|
-
const dir =
|
|
63308
|
-
if (!
|
|
63692
|
+
const dir = path79.join(scratch ? path79.join(scratch, ".archive") : ARCHIVE, REJECTIONS_TO_REVIEW);
|
|
63693
|
+
if (!fs79.existsSync(dir)) return [];
|
|
63309
63694
|
const found2 = [];
|
|
63310
63695
|
for (const file2 of walkMd(dir)) {
|
|
63311
63696
|
const id2 = archivedId(file2);
|
|
63312
63697
|
if (id2 === null) continue;
|
|
63313
63698
|
try {
|
|
63314
|
-
const { meta: meta3 } = parseFrontmatter(
|
|
63699
|
+
const { meta: meta3 } = parseFrontmatter(fs79.readFileSync(file2, "utf8"));
|
|
63315
63700
|
if (!meta3?.rejected || meta3.rejected_by !== "user" || !meta3.rejected_reason.trim()) continue;
|
|
63316
63701
|
found2.push({ id: id2, title: meta3.title, file: rel(file2), reason: meta3.rejected_reason.trim(), rejectedAt: meta3.rejected_at });
|
|
63317
63702
|
} catch {
|
|
@@ -63341,7 +63726,7 @@ function citedSources(text5) {
|
|
|
63341
63726
|
function withdrawnSources() {
|
|
63342
63727
|
const cited = [...new Set(plannerCopies("rejected.md").flatMap((file2) => {
|
|
63343
63728
|
try {
|
|
63344
|
-
return citedSources(
|
|
63729
|
+
return citedSources(fs79.readFileSync(file2, "utf8"));
|
|
63345
63730
|
} catch {
|
|
63346
63731
|
return [];
|
|
63347
63732
|
}
|
|
@@ -63349,7 +63734,7 @@ function withdrawnSources() {
|
|
|
63349
63734
|
if (cited.length === 0) return [];
|
|
63350
63735
|
const scratch = process.env.AI4KANBAN_REJECTION_INPUT;
|
|
63351
63736
|
const dismissed = new Set(reviewDismissed().map((s) => s.sourceId));
|
|
63352
|
-
const restored = new Set([...readInbox(), ...readArchived(scratch ?
|
|
63737
|
+
const restored = new Set([...readInbox(), ...readArchived(scratch ? path79.join(scratch, "triage", "archived") : void 0)].map((s) => s.sourceId));
|
|
63353
63738
|
return cited.filter((id2) => restored.has(id2) && !dismissed.has(id2));
|
|
63354
63739
|
}
|
|
63355
63740
|
var reviewDismissed, SOURCES;
|
|
@@ -63364,15 +63749,15 @@ var init_dismissal_review = __esm({
|
|
|
63364
63749
|
init_archive();
|
|
63365
63750
|
reviewDismissed = () => {
|
|
63366
63751
|
const scratch = process.env.AI4KANBAN_REJECTION_INPUT;
|
|
63367
|
-
return readAllDismissed(scratch ?
|
|
63752
|
+
return readAllDismissed(scratch ? path79.join(scratch, "triage", "dismissed") : void 0);
|
|
63368
63753
|
};
|
|
63369
63754
|
SOURCES = /\(([^()]+)\)\s*$/;
|
|
63370
63755
|
}
|
|
63371
63756
|
});
|
|
63372
63757
|
|
|
63373
63758
|
// ../cli/src/lib/agent/flow.ts
|
|
63374
|
-
import
|
|
63375
|
-
import
|
|
63759
|
+
import fs80 from "node:fs";
|
|
63760
|
+
import path80 from "node:path";
|
|
63376
63761
|
function readCard2(id2, home3 = "board") {
|
|
63377
63762
|
const pending = activeDelivery(id2)?.completions?.some((c) => !c.finished);
|
|
63378
63763
|
const found2 = home3 === "archive" ? locateArchived(id2) : locate(id2) ?? (pending ? locateArchived(id2) : null);
|
|
@@ -63382,10 +63767,10 @@ function readCard2(id2, home3 = "board") {
|
|
|
63382
63767
|
{ kind: "card-not-found", id: id2 }
|
|
63383
63768
|
);
|
|
63384
63769
|
}
|
|
63385
|
-
const file2 = found2.kind === "group" ?
|
|
63770
|
+
const file2 = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
|
|
63386
63771
|
let text5;
|
|
63387
63772
|
try {
|
|
63388
|
-
text5 =
|
|
63773
|
+
text5 = fs80.readFileSync(file2, "utf8");
|
|
63389
63774
|
} catch {
|
|
63390
63775
|
die(`#${id2} is on the board but ${rel(file2)} can't be read.`, { kind: "card-unreadable", id: id2 });
|
|
63391
63776
|
}
|
|
@@ -64039,7 +64424,7 @@ var init_coding_previews = __esm({
|
|
|
64039
64424
|
});
|
|
64040
64425
|
|
|
64041
64426
|
// ../cli/src/lib/agent/approved-ui.ts
|
|
64042
|
-
import
|
|
64427
|
+
import path81 from "node:path";
|
|
64043
64428
|
function approvedUiPreviews(review) {
|
|
64044
64429
|
if (reviewAuthorization(review).kind !== "delivery") return [];
|
|
64045
64430
|
const result = [];
|
|
@@ -64060,7 +64445,7 @@ function approvedUiPreviews(review) {
|
|
|
64060
64445
|
const pin = object2(pins[src]);
|
|
64061
64446
|
const { artifact, version: version2 } = pin;
|
|
64062
64447
|
if (typeof artifact !== "string" || !/^art_[a-z0-9]+$/i.test(artifact) || typeof version2 !== "number" || !Number.isSafeInteger(version2) || version2 < 1) return;
|
|
64063
|
-
const name = label2.trim() ||
|
|
64448
|
+
const name = label2.trim() || path81.posix.basename(src);
|
|
64064
64449
|
const key = JSON.stringify([src, name]);
|
|
64065
64450
|
let file2 = files.get(key);
|
|
64066
64451
|
if (!file2) {
|
|
@@ -64091,9 +64476,9 @@ function approvedUiPreviews(review) {
|
|
|
64091
64476
|
return result;
|
|
64092
64477
|
}
|
|
64093
64478
|
function approvedUiFile(directory, file2) {
|
|
64094
|
-
const ext =
|
|
64479
|
+
const ext = path81.posix.extname(file2.src).toLowerCase();
|
|
64095
64480
|
const suffix = ext === ".tsx" ? ".html" : /^\.[a-z0-9]+$/.test(ext) ? ext : "";
|
|
64096
|
-
return
|
|
64481
|
+
return path81.join(directory, `${file2.artifact}-${file2.version}${suffix}`);
|
|
64097
64482
|
}
|
|
64098
64483
|
function approvedUiPrompt(review, directory) {
|
|
64099
64484
|
const files = approvedUiPreviews(review);
|
|
@@ -64189,7 +64574,7 @@ __export(watch_exports, {
|
|
|
64189
64574
|
watchRun: () => watchRun
|
|
64190
64575
|
});
|
|
64191
64576
|
import { spawn as spawn3 } from "node:child_process";
|
|
64192
|
-
import
|
|
64577
|
+
import fs81 from "node:fs";
|
|
64193
64578
|
async function watchRun(sessionId, resume = startResume, retryBackoff = backoffMs) {
|
|
64194
64579
|
const spec = readSpec(sessionId);
|
|
64195
64580
|
const run3 = peekRun(sessionId);
|
|
@@ -64225,11 +64610,11 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
64225
64610
|
const record2 = claimed ?? run3;
|
|
64226
64611
|
const sub = record2.action === "sub";
|
|
64227
64612
|
if (claim2) await setCardStatus(claim2.cardId, claim2.status);
|
|
64228
|
-
|
|
64229
|
-
const logFile =
|
|
64613
|
+
fs81.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
64614
|
+
const logFile = fs81.createWriteStream(record2.logPath, { flags: "a" });
|
|
64230
64615
|
logFile.on("error", () => {
|
|
64231
64616
|
});
|
|
64232
|
-
const eventsFile =
|
|
64617
|
+
const eventsFile = fs81.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
|
|
64233
64618
|
eventsFile.on("error", () => {
|
|
64234
64619
|
});
|
|
64235
64620
|
let observeActivity = (_e) => {
|
|
@@ -64805,8 +65190,8 @@ var init_watch = __esm({
|
|
|
64805
65190
|
});
|
|
64806
65191
|
|
|
64807
65192
|
// ../cli/src/commands/run.ts
|
|
64808
|
-
import
|
|
64809
|
-
import
|
|
65193
|
+
import fs82 from "node:fs";
|
|
65194
|
+
import path82 from "node:path";
|
|
64810
65195
|
async function cmdStartRun(action, args2, opts, program2 = "akb") {
|
|
64811
65196
|
const { req, follow: follow2, print } = readRequest(action, args2, opts);
|
|
64812
65197
|
if (!print && (action === "approve" || action === "implement")) {
|
|
@@ -65032,7 +65417,7 @@ async function cmdSubStart(words, opts) {
|
|
|
65032
65417
|
let prompt = words.join(" ");
|
|
65033
65418
|
if (opts.file) {
|
|
65034
65419
|
try {
|
|
65035
|
-
prompt =
|
|
65420
|
+
prompt = fs82.readFileSync(path82.resolve(opts.file), "utf8");
|
|
65036
65421
|
} catch {
|
|
65037
65422
|
die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
|
|
65038
65423
|
}
|
|
@@ -65381,12 +65766,12 @@ var init_config3 = __esm({
|
|
|
65381
65766
|
});
|
|
65382
65767
|
|
|
65383
65768
|
// ../cli/src/lib/signals/migrate.ts
|
|
65384
|
-
import
|
|
65385
|
-
import
|
|
65769
|
+
import fs83 from "node:fs";
|
|
65770
|
+
import path83 from "node:path";
|
|
65386
65771
|
function readHandled() {
|
|
65387
65772
|
let text5;
|
|
65388
65773
|
try {
|
|
65389
|
-
text5 =
|
|
65774
|
+
text5 = fs83.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
|
|
65390
65775
|
} catch {
|
|
65391
65776
|
return [];
|
|
65392
65777
|
}
|
|
@@ -65403,57 +65788,57 @@ function readHandled() {
|
|
|
65403
65788
|
return held4;
|
|
65404
65789
|
}
|
|
65405
65790
|
function lift(from, into) {
|
|
65406
|
-
|
|
65407
|
-
|
|
65791
|
+
fs83.mkdirSync(into, { recursive: true });
|
|
65792
|
+
fs83.renameSync(from, path83.join(into, freeName(into, path83.basename(from))));
|
|
65408
65793
|
}
|
|
65409
65794
|
function repoint(dir, from, into) {
|
|
65410
|
-
let
|
|
65795
|
+
let entries2;
|
|
65411
65796
|
try {
|
|
65412
|
-
|
|
65797
|
+
entries2 = fs83.readdirSync(dir, { withFileTypes: true });
|
|
65413
65798
|
} catch {
|
|
65414
65799
|
return;
|
|
65415
65800
|
}
|
|
65416
|
-
for (const entry of
|
|
65801
|
+
for (const entry of entries2) {
|
|
65417
65802
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
65418
|
-
const file2 =
|
|
65419
|
-
const text5 =
|
|
65420
|
-
if (text5.includes(from))
|
|
65803
|
+
const file2 = path83.join(dir, entry.name);
|
|
65804
|
+
const text5 = fs83.readFileSync(file2, "utf8");
|
|
65805
|
+
if (text5.includes(from)) fs83.writeFileSync(file2, text5.split(from).join(into));
|
|
65421
65806
|
}
|
|
65422
65807
|
}
|
|
65423
65808
|
function dropIfEmpty(dir) {
|
|
65424
65809
|
try {
|
|
65425
|
-
|
|
65810
|
+
fs83.rmdirSync(dir);
|
|
65426
65811
|
} catch {
|
|
65427
65812
|
}
|
|
65428
65813
|
}
|
|
65429
65814
|
function liftInbox() {
|
|
65430
|
-
if (!
|
|
65431
|
-
const oldFiles =
|
|
65432
|
-
if (
|
|
65433
|
-
for (const entry of
|
|
65434
|
-
if (entry.isFile()) lift(
|
|
65815
|
+
if (!fs83.existsSync(SIGNALS_OLD_INBOX)) return;
|
|
65816
|
+
const oldFiles = path83.join(SIGNALS_OLD_INBOX, "files");
|
|
65817
|
+
if (fs83.existsSync(oldFiles)) {
|
|
65818
|
+
for (const entry of fs83.readdirSync(oldFiles, { withFileTypes: true })) {
|
|
65819
|
+
if (entry.isFile()) lift(path83.join(oldFiles, entry.name), SIGNALS_FILES);
|
|
65435
65820
|
}
|
|
65436
65821
|
dropIfEmpty(oldFiles);
|
|
65437
65822
|
}
|
|
65438
65823
|
const held4 = new Set(readFolder(TRIAGE).map((signal2) => signal2.sourceId));
|
|
65439
|
-
for (const entry of
|
|
65824
|
+
for (const entry of fs83.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
|
|
65440
65825
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
65441
|
-
const from =
|
|
65826
|
+
const from = path83.join(SIGNALS_OLD_INBOX, entry.name);
|
|
65442
65827
|
const item = parse3(from);
|
|
65443
65828
|
if (item && held4.has(item.sourceId)) {
|
|
65444
|
-
|
|
65829
|
+
fs83.rmSync(from, { force: true });
|
|
65445
65830
|
continue;
|
|
65446
65831
|
}
|
|
65447
65832
|
if (item) held4.add(item.sourceId);
|
|
65448
65833
|
lift(from, TRIAGE);
|
|
65449
65834
|
}
|
|
65450
|
-
const wasAt = asWritten(
|
|
65835
|
+
const wasAt = asWritten(path83.join(SIGNALS_OLD_INBOX, "files"));
|
|
65451
65836
|
const nowAt = asWritten(SIGNALS_FILES);
|
|
65452
65837
|
for (const dir of [TRIAGE, SIGNALS_ARCHIVED, SIGNALS_DISMISSED]) repoint(dir, wasAt, nowAt);
|
|
65453
65838
|
dropIfEmpty(SIGNALS_OLD_INBOX);
|
|
65454
65839
|
}
|
|
65455
65840
|
function liftHandled() {
|
|
65456
|
-
if (!
|
|
65841
|
+
if (!fs83.existsSync(SIGNALS_OLD_HANDLED)) return;
|
|
65457
65842
|
const lines = readHandled();
|
|
65458
65843
|
const held4 = /* @__PURE__ */ new Set([
|
|
65459
65844
|
...readFolder(TRIAGE).map((signal2) => signal2.sourceId),
|
|
@@ -65463,7 +65848,7 @@ function liftHandled() {
|
|
|
65463
65848
|
for (const { sourceId, when } of lines) {
|
|
65464
65849
|
if (held4.has(sourceId)) continue;
|
|
65465
65850
|
held4.add(sourceId);
|
|
65466
|
-
|
|
65851
|
+
fs83.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
|
|
65467
65852
|
const name = freeName(SIGNALS_DISMISSED, fileName("", sourceId));
|
|
65468
65853
|
const front = [
|
|
65469
65854
|
"---",
|
|
@@ -65473,13 +65858,13 @@ function liftHandled() {
|
|
|
65473
65858
|
"---",
|
|
65474
65859
|
""
|
|
65475
65860
|
];
|
|
65476
|
-
|
|
65861
|
+
fs83.writeFileSync(path83.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
|
|
65477
65862
|
`);
|
|
65478
65863
|
}
|
|
65479
|
-
|
|
65864
|
+
fs83.rmSync(SIGNALS_OLD_HANDLED, { force: true });
|
|
65480
65865
|
}
|
|
65481
65866
|
function migrateTriage() {
|
|
65482
|
-
if (!
|
|
65867
|
+
if (!fs83.existsSync(SIGNALS_OLD_INBOX) && !fs83.existsSync(SIGNALS_OLD_HANDLED)) return;
|
|
65483
65868
|
try {
|
|
65484
65869
|
liftInbox();
|
|
65485
65870
|
liftHandled();
|
|
@@ -65494,7 +65879,7 @@ var init_migrate = __esm({
|
|
|
65494
65879
|
init_yaml();
|
|
65495
65880
|
init_inbox();
|
|
65496
65881
|
HANDLED_LINE = /^-\s+(.+?)\s+—\s+(.+)$/;
|
|
65497
|
-
asWritten = (dir) => `${rel(dir).split(
|
|
65882
|
+
asWritten = (dir) => `${rel(dir).split(path83.sep).join("/")}/`;
|
|
65498
65883
|
}
|
|
65499
65884
|
});
|
|
65500
65885
|
|
|
@@ -65547,8 +65932,8 @@ var init_identity2 = __esm({
|
|
|
65547
65932
|
});
|
|
65548
65933
|
|
|
65549
65934
|
// ../cli/src/lib/signals/add.ts
|
|
65550
|
-
import
|
|
65551
|
-
import
|
|
65935
|
+
import fs84 from "node:fs";
|
|
65936
|
+
import path84 from "node:path";
|
|
65552
65937
|
import { createHash as createHash8 } from "node:crypto";
|
|
65553
65938
|
function linkTitle(url2) {
|
|
65554
65939
|
let at;
|
|
@@ -65561,7 +65946,7 @@ function linkTitle(url2) {
|
|
|
65561
65946
|
return oneLine(where) || url2.slice(0, TITLE_MAX);
|
|
65562
65947
|
}
|
|
65563
65948
|
function asText(file2) {
|
|
65564
|
-
const ext =
|
|
65949
|
+
const ext = path84.extname(file2.name).toLowerCase();
|
|
65565
65950
|
if (!file2.type.startsWith("text/") && file2.type !== "application/json" && !TEXT_EXTENSIONS.has(ext)) return null;
|
|
65566
65951
|
try {
|
|
65567
65952
|
const text5 = new TextDecoder("utf-8", { fatal: true }).decode(file2.data);
|
|
@@ -65571,9 +65956,9 @@ function asText(file2) {
|
|
|
65571
65956
|
}
|
|
65572
65957
|
}
|
|
65573
65958
|
function fileName2(name, data) {
|
|
65574
|
-
const base =
|
|
65575
|
-
const ext =
|
|
65576
|
-
const word =
|
|
65959
|
+
const base = path84.basename(name);
|
|
65960
|
+
const ext = path84.extname(base).toLowerCase().slice(0, 12);
|
|
65961
|
+
const word = path84.basename(base, path84.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
|
|
65577
65962
|
const hash3 = createHash8("sha256").update(data).digest("hex").slice(0, 8);
|
|
65578
65963
|
return `${word}-${hash3}${ext}`;
|
|
65579
65964
|
}
|
|
@@ -65582,9 +65967,9 @@ function addToInbox(drop) {
|
|
|
65582
65967
|
const typed = (drop.text ?? "").trim();
|
|
65583
65968
|
const file2 = drop.file;
|
|
65584
65969
|
if (!typed && !file2) return { ok: false, error: "nothing to add \u2014 paste a link or some text, or drop a file." };
|
|
65585
|
-
if (file2 && file2.data.length === 0) return { ok: false, error: `${
|
|
65970
|
+
if (file2 && file2.data.length === 0) return { ok: false, error: `${path84.basename(file2.name)} is empty.` };
|
|
65586
65971
|
if (file2 && file2.data.length > MAX_BYTES3) {
|
|
65587
|
-
return { ok: false, error: `${
|
|
65972
|
+
return { ok: false, error: `${path84.basename(file2.name)} is over ${MAX_BYTES3 / 1024 / 1024} MB \u2014 too big for the board.` };
|
|
65588
65973
|
}
|
|
65589
65974
|
const read5 = describe3(typed, file2);
|
|
65590
65975
|
const keep2 = read5.keep;
|
|
@@ -65606,8 +65991,8 @@ ${incoming.summary}`);
|
|
|
65606
65991
|
if (seen.status === "pending" || seen.status === "archived") return { ok: false, error: `${sayHit(seen)}.` };
|
|
65607
65992
|
try {
|
|
65608
65993
|
if (keep2) {
|
|
65609
|
-
|
|
65610
|
-
|
|
65994
|
+
fs84.mkdirSync(SIGNALS_FILES, { recursive: true });
|
|
65995
|
+
fs84.writeFileSync(keep2.at, keep2.data);
|
|
65611
65996
|
}
|
|
65612
65997
|
return { ok: true, signal: writeSignal({ ...incoming, sourceId }, formatStamp(/* @__PURE__ */ new Date()), drop.slug) };
|
|
65613
65998
|
} catch (e) {
|
|
@@ -65621,7 +66006,7 @@ function describe3(typed, file2) {
|
|
|
65621
66006
|
return only ? [only] : [];
|
|
65622
66007
|
};
|
|
65623
66008
|
if (file2) {
|
|
65624
|
-
const name =
|
|
66009
|
+
const name = path84.basename(file2.name);
|
|
65625
66010
|
const text5 = asText(file2);
|
|
65626
66011
|
const note = typed ? `
|
|
65627
66012
|
|
|
@@ -65633,7 +66018,7 @@ ${typed}` : "";
|
|
|
65633
66018
|
const at = keepAt(file2);
|
|
65634
66019
|
return {
|
|
65635
66020
|
incoming: {
|
|
65636
|
-
title:
|
|
66021
|
+
title: path84.basename(name, path84.extname(name)) || name,
|
|
65637
66022
|
summary: `${name} \u2014 ${boardRel2(at)}${note}`,
|
|
65638
66023
|
...named2
|
|
65639
66024
|
},
|
|
@@ -65671,13 +66056,13 @@ var init_add = __esm({
|
|
|
65671
66056
|
MAX_BYTES3 = 25 * 1024 * 1024;
|
|
65672
66057
|
TITLE_MAX = 120;
|
|
65673
66058
|
TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".text", ".csv", ".json", ".yml", ".yaml", ".log"]);
|
|
65674
|
-
boardRel2 = (file2) => rel(file2).split(
|
|
66059
|
+
boardRel2 = (file2) => rel(file2).split(path84.sep).join("/");
|
|
65675
66060
|
oneLine = (text5) => {
|
|
65676
66061
|
const first = text5.split("\n").find((line) => line.trim()) ?? "";
|
|
65677
66062
|
const clean = first.replace(/^#+\s*/, "").trim();
|
|
65678
66063
|
return clean.length > TITLE_MAX ? `${clean.slice(0, TITLE_MAX - 1).trimEnd()}\u2026` : clean;
|
|
65679
66064
|
};
|
|
65680
|
-
keepAt = (file2) =>
|
|
66065
|
+
keepAt = (file2) => path84.join(SIGNALS_FILES, fileName2(file2.name, file2.data));
|
|
65681
66066
|
}
|
|
65682
66067
|
});
|
|
65683
66068
|
|
|
@@ -65718,7 +66103,7 @@ var init_signals = __esm({
|
|
|
65718
66103
|
});
|
|
65719
66104
|
|
|
65720
66105
|
// ../cli/src/commands/triage.ts
|
|
65721
|
-
import
|
|
66106
|
+
import fs85 from "node:fs";
|
|
65722
66107
|
async function cmdTriageAdd(opts) {
|
|
65723
66108
|
const title = (opts.title ?? "").trim();
|
|
65724
66109
|
if (!title) die('say what it is: --title "<one line>"', { kind: "needs-input" });
|
|
@@ -65728,7 +66113,7 @@ async function cmdTriageAdd(opts) {
|
|
|
65728
66113
|
let body = opts.text;
|
|
65729
66114
|
if (opts.file !== void 0) {
|
|
65730
66115
|
try {
|
|
65731
|
-
body =
|
|
66116
|
+
body = fs85.readFileSync(opts.file, "utf8");
|
|
65732
66117
|
} catch {
|
|
65733
66118
|
die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
|
|
65734
66119
|
}
|
|
@@ -65782,21 +66167,21 @@ var init_previews = __esm({
|
|
|
65782
66167
|
});
|
|
65783
66168
|
|
|
65784
66169
|
// ../cli/src/commands/studio-preview.ts
|
|
65785
|
-
import
|
|
65786
|
-
import
|
|
66170
|
+
import fs86 from "node:fs";
|
|
66171
|
+
import path85 from "node:path";
|
|
65787
66172
|
import { createHash as createHash9, randomUUID as randomUUID9 } from "node:crypto";
|
|
65788
66173
|
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
65789
66174
|
function readFolder2(folder2, baseline = false) {
|
|
65790
|
-
const root2 =
|
|
66175
|
+
const root2 = fs86.realpathSync(folder2);
|
|
65791
66176
|
let count3 = 0, total = 0;
|
|
65792
66177
|
const scan = (dir) => {
|
|
65793
|
-
for (const e of
|
|
66178
|
+
for (const e of fs86.readdirSync(dir, { withFileTypes: true })) {
|
|
65794
66179
|
if (e.name.startsWith(".")) continue;
|
|
65795
|
-
const file2 =
|
|
66180
|
+
const file2 = path85.join(dir, e.name);
|
|
65796
66181
|
if (e.isSymbolicLink()) throw Error(`${file2}: symbolic links are not allowed`);
|
|
65797
66182
|
if (e.isDirectory()) scan(file2);
|
|
65798
66183
|
else {
|
|
65799
|
-
const size =
|
|
66184
|
+
const size = fs86.statSync(file2).size;
|
|
65800
66185
|
total += size;
|
|
65801
66186
|
if (++count3 > FILE_LIMITS.count || size > FILE_LIMITS.file || total > FILE_LIMITS.total) throw Error(`${file2}: Studio file limit exceeded`);
|
|
65802
66187
|
}
|
|
@@ -65809,9 +66194,9 @@ function readFolder2(folder2, baseline = false) {
|
|
|
65809
66194
|
return { files, def: checked.def, fingerprint };
|
|
65810
66195
|
}
|
|
65811
66196
|
function unified(before, after2, file2, folder2) {
|
|
65812
|
-
const a =
|
|
65813
|
-
|
|
65814
|
-
|
|
66197
|
+
const a = path85.join(folder2, "a"), b = path85.join(folder2, "b");
|
|
66198
|
+
fs86.writeFileSync(a, before ?? "");
|
|
66199
|
+
fs86.writeFileSync(b, after2 ?? "");
|
|
65815
66200
|
const result = spawnSync7("git", ["diff", "--no-index", "--text", "--no-ext-diff", "--no-color", "--unified=3", before === null ? "/dev/null" : a, after2 === null ? "/dev/null" : b], { encoding: "utf8", maxBuffer: 16 * 1024 * 1024 });
|
|
65816
66201
|
if (result.error || result.status !== 0 && result.status !== 1) throw Error(`${file2}: ${result.error?.message ?? result.stderr}`);
|
|
65817
66202
|
const lines = result.stdout.split("\n"), start = lines.findIndex((l) => l.startsWith("--- "));
|
|
@@ -65821,18 +66206,18 @@ ${start < 0 ? "" : lines.slice(start + 2).join("\n")}`;
|
|
|
65821
66206
|
}
|
|
65822
66207
|
async function cmdStudioPreview(id2, opts) {
|
|
65823
66208
|
if (!locate(id2)) die(`no card ${id2}`, "no-such-card");
|
|
65824
|
-
const destination =
|
|
66209
|
+
const destination = path85.join(ASSETS, String(id2), "studio-review"), staging = `${destination}.${randomUUID9()}.tmp`, backup = `${destination}.${randomUUID9()}.previous`;
|
|
65825
66210
|
let moved = false;
|
|
65826
66211
|
try {
|
|
65827
|
-
const draft = readFolder2(
|
|
66212
|
+
const draft = readFolder2(path85.resolve(opts.folder)), base = opts.base === "empty" ? null : readFolder2(path85.resolve(opts.base), true);
|
|
65828
66213
|
const version2 = readVersion2(draft.files), baseVersion = base && readVersion2(base.files);
|
|
65829
66214
|
if (base ? !version2 || !baseVersion || JSON.stringify(version2) !== JSON.stringify(baseVersion) : version2 !== null) throw Error("version.json: existing Studios need matching baseline and draft versions; use --base empty only for a new Studio without version.json");
|
|
65830
|
-
|
|
66215
|
+
fs86.mkdirSync(staging, { recursive: true });
|
|
65831
66216
|
const review = { version: 2, base: base && baseVersion ? { ...baseVersion, fingerprint: base.fingerprint } : null, fingerprint: draft.fingerprint, files: [] };
|
|
65832
66217
|
const save3 = (file2, bytes2) => {
|
|
65833
|
-
const target =
|
|
65834
|
-
|
|
65835
|
-
|
|
66218
|
+
const target = path85.join(staging, file2);
|
|
66219
|
+
fs86.mkdirSync(path85.dirname(target), { recursive: true });
|
|
66220
|
+
fs86.writeFileSync(target, bytes2);
|
|
65836
66221
|
return file2;
|
|
65837
66222
|
};
|
|
65838
66223
|
const paths = [.../* @__PURE__ */ new Set([...Object.keys(base?.files ?? {}), ...Object.keys(draft.files)])].filter((p) => p !== VERSION_FILE).sort();
|
|
@@ -65840,16 +66225,16 @@ async function cmdStudioPreview(id2, opts) {
|
|
|
65840
66225
|
const before = base?.files[file2] ?? null, after2 = draft.files[file2] ?? null;
|
|
65841
66226
|
review.files.push({ path: file2, before: before === null ? null : save3(`files/${i}/before.txt`, before), after: after2 === null ? null : save3(`files/${i}/after.txt`, after2), ...before !== after2 ? { diff: save3(`files/${i}/change.diff`, unified(before, after2, file2, staging)) } : {} });
|
|
65842
66227
|
}
|
|
65843
|
-
for (const p of ["a", "b"])
|
|
66228
|
+
for (const p of ["a", "b"]) fs86.rmSync(path85.join(staging, p), { force: true });
|
|
65844
66229
|
if (!parseReview(review)) throw Error("generated review is invalid");
|
|
65845
66230
|
save3("review.json", JSON.stringify(review, null, 2) + "\n");
|
|
65846
|
-
|
|
65847
|
-
if (
|
|
65848
|
-
|
|
66231
|
+
fs86.mkdirSync(path85.dirname(destination), { recursive: true });
|
|
66232
|
+
if (fs86.existsSync(destination)) {
|
|
66233
|
+
fs86.renameSync(destination, backup);
|
|
65849
66234
|
moved = true;
|
|
65850
66235
|
}
|
|
65851
|
-
|
|
65852
|
-
|
|
66236
|
+
fs86.renameSync(staging, destination);
|
|
66237
|
+
fs86.rmSync(backup, { recursive: true, force: true });
|
|
65853
66238
|
const tag = `<Studio src=".assets/${id2}/studio-review/review.json" />`;
|
|
65854
66239
|
const prefix = `.assets/${id2}/studio-review/`;
|
|
65855
66240
|
const attachments = review.files.filter((f) => f.path !== "STUDIO.md" && f.diff);
|
|
@@ -65861,13 +66246,13 @@ ${items}
|
|
|
65861
66246
|
|
|
65862
66247
|
</Set>` : items;
|
|
65863
66248
|
say([tag, files].filter(Boolean).join("\n\n"));
|
|
65864
|
-
return { file:
|
|
66249
|
+
return { file: path85.join(destination, "review.json"), tag, files };
|
|
65865
66250
|
} catch (error62) {
|
|
65866
|
-
if (moved && !
|
|
66251
|
+
if (moved && !fs86.existsSync(destination)) fs86.renameSync(backup, destination);
|
|
65867
66252
|
if (error62 && typeof error62 === "object" && "kind" in error62) throw error62;
|
|
65868
66253
|
die(error62 instanceof Error ? error62.message : String(error62), "bad-args");
|
|
65869
66254
|
} finally {
|
|
65870
|
-
|
|
66255
|
+
fs86.rmSync(staging, { recursive: true, force: true });
|
|
65871
66256
|
}
|
|
65872
66257
|
}
|
|
65873
66258
|
var readVersion2;
|
|
@@ -65985,12 +66370,12 @@ var init_agent_check = __esm({
|
|
|
65985
66370
|
});
|
|
65986
66371
|
|
|
65987
66372
|
// ../cli/src/lib/cli/agent.ts
|
|
65988
|
-
async function onBoard(cmd, cli, work) {
|
|
66373
|
+
async function onBoard(cmd, cli, work, refreshStudios = false) {
|
|
65989
66374
|
const ctx = ctxOf(cmd, cli.program);
|
|
65990
66375
|
await runAction(ctx, {}, async () => {
|
|
65991
66376
|
const found2 = resolveBoard("runs", { board: ctx.board, dir: ctx.dir, cwd: cli.cwd, installHint: cli.installHint });
|
|
65992
66377
|
useBoard(found2, ctx.dir !== null);
|
|
65993
|
-
await syncStudios();
|
|
66378
|
+
await syncStudios(refreshStudios);
|
|
65994
66379
|
return { board: KANBAN, ...await work(cli.program) ?? {} };
|
|
65995
66380
|
});
|
|
65996
66381
|
}
|
|
@@ -66442,10 +66827,7 @@ Review examples
|
|
|
66442
66827
|
--review 'UI design -> Prompts' Approve in order
|
|
66443
66828
|
--review 'UI design + API docs -> Prompts' Both approvals unlock Prompts
|
|
66444
66829
|
--review '' No extra review`;
|
|
66445
|
-
studioList = (cmd, cli) => !cmd.optsWithGlobals().board && externalGoalSession() ? boardless(cmd, cli, cloudGoalStudios) : goalDraftPath() ? boardless(cmd, cli, () => cmdGoalStudios()) : onBoard(cmd, cli,
|
|
66446
|
-
await syncStudios(true);
|
|
66447
|
-
return cmdStudioList();
|
|
66448
|
-
});
|
|
66830
|
+
studioList = (cmd, cli) => !cmd.optsWithGlobals().board && externalGoalSession() ? boardless(cmd, cli, cloudGoalStudios) : goalDraftPath() ? boardless(cmd, cli, () => cmdGoalStudios()) : onBoard(cmd, cli, cmdStudioList, true);
|
|
66449
66831
|
positional = (vals) => vals.slice(0, -2);
|
|
66450
66832
|
RUN_ID = "a run's id, any prefix of one that names only one run, or `last`. Left out, it means the newest run";
|
|
66451
66833
|
DELIVERY = "the delivery, or the card it is on";
|
|
@@ -66455,15 +66837,15 @@ Review examples
|
|
|
66455
66837
|
});
|
|
66456
66838
|
|
|
66457
66839
|
// ../cli/src/kanban.ts
|
|
66458
|
-
import
|
|
66840
|
+
import fs89 from "node:fs";
|
|
66459
66841
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
66460
66842
|
|
|
66461
66843
|
// ../cli/src/lib/cli/akb.ts
|
|
66462
66844
|
init_agent2();
|
|
66463
66845
|
|
|
66464
66846
|
// ../cli/src/lib/cli/setup.ts
|
|
66465
|
-
import
|
|
66466
|
-
import
|
|
66847
|
+
import fs88 from "node:fs";
|
|
66848
|
+
import path87 from "node:path";
|
|
66467
66849
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
66468
66850
|
|
|
66469
66851
|
// ../cli/src/commands/update.ts
|
|
@@ -66471,8 +66853,8 @@ init_board_cli();
|
|
|
66471
66853
|
init_config_template();
|
|
66472
66854
|
init_io();
|
|
66473
66855
|
init_version();
|
|
66474
|
-
import
|
|
66475
|
-
import
|
|
66856
|
+
import fs87 from "node:fs";
|
|
66857
|
+
import path86 from "node:path";
|
|
66476
66858
|
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
66477
66859
|
var NAME = "wildcrane";
|
|
66478
66860
|
var REPO = "https://github.com/wildcrane-ai/wildcrane";
|
|
@@ -66493,7 +66875,7 @@ var Report = class {
|
|
|
66493
66875
|
for (const line of this.notes) say(` ! ${line}`);
|
|
66494
66876
|
}
|
|
66495
66877
|
};
|
|
66496
|
-
var read4 = (file2) =>
|
|
66878
|
+
var read4 = (file2) => fs87.existsSync(file2) ? fs87.readFileSync(file2, "utf8") : null;
|
|
66497
66879
|
async function boardMove(root2, args2, board2) {
|
|
66498
66880
|
const where = board2 ? ["--board", board2] : ["--dir", root2];
|
|
66499
66881
|
const code = await runBoard([...args2, ...where], { program: "akb raw", cwd: root2 });
|
|
@@ -66514,10 +66896,10 @@ async function cmdUpdate2(ctx) {
|
|
|
66514
66896
|
return { updated: ctx.dir, from, to: SKILL_VERSION };
|
|
66515
66897
|
}
|
|
66516
66898
|
async function repairBoard(root2, report3, named2) {
|
|
66517
|
-
const legacy =
|
|
66518
|
-
const kept2 =
|
|
66519
|
-
const board2 = named2 ?? (
|
|
66520
|
-
if (!
|
|
66899
|
+
const legacy = path86.join(root2, "docs", "kanban");
|
|
66900
|
+
const kept2 = path86.join(root2, ".akb", "kanban");
|
|
66901
|
+
const board2 = named2 ?? (fs87.existsSync(legacy) ? legacy : kept2);
|
|
66902
|
+
if (!fs87.existsSync(board2)) {
|
|
66521
66903
|
report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
|
|
66522
66904
|
return false;
|
|
66523
66905
|
}
|
|
@@ -66528,7 +66910,7 @@ async function repairBoard(root2, report3, named2) {
|
|
|
66528
66910
|
return true;
|
|
66529
66911
|
}
|
|
66530
66912
|
function checkConfig(board2, report3) {
|
|
66531
|
-
const current = read4(
|
|
66913
|
+
const current = read4(path86.join(board2, "config.md"));
|
|
66532
66914
|
if (!current) return;
|
|
66533
66915
|
const added = missingConfigKeys(current);
|
|
66534
66916
|
if (added.length) {
|
|
@@ -66538,7 +66920,7 @@ function checkConfig(board2, report3) {
|
|
|
66538
66920
|
}
|
|
66539
66921
|
}
|
|
66540
66922
|
function checkModules(board2, report3) {
|
|
66541
|
-
const map3 = read4(
|
|
66923
|
+
const map3 = read4(path86.join(board2, "modules.md"));
|
|
66542
66924
|
if (map3 && map3.includes(UNFILLED)) {
|
|
66543
66925
|
report3.notes.push(
|
|
66544
66926
|
"docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
|
|
@@ -66592,14 +66974,14 @@ function declareSetup(program2, cli) {
|
|
|
66592
66974
|
program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
|
|
66593
66975
|
const dirOption = (cmd) => cmd.option("--dir <path>", "the project to work on (default: the current folder)").option("--json", "answer as one JSON object instead of prose");
|
|
66594
66976
|
const where = (cmd) => {
|
|
66595
|
-
const dir =
|
|
66596
|
-
if (!
|
|
66977
|
+
const dir = path87.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
|
|
66978
|
+
if (!fs88.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
|
|
66597
66979
|
return dir;
|
|
66598
66980
|
};
|
|
66599
66981
|
dirOption(program2.command("update")).summary("\u4FEE\u590D\u5DF2\u6709\u770B\u677F\u5E76\u68C0\u67E5 CLI \u65B0\u7248\u672C").description("\u4FEE\u590D\u5DF2\u6709\u770B\u677F\u5E76\u63D0\u793A CLI \u5347\u7EA7\u547D\u4EE4\u3002\u6CA1\u6709\u770B\u677F\u65F6\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002").action(async function() {
|
|
66600
66982
|
const dir = where(this);
|
|
66601
66983
|
const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
|
|
66602
|
-
const board2 = named2 ?
|
|
66984
|
+
const board2 = named2 ? path87.resolve(cli.cwd, named2) : null;
|
|
66603
66985
|
await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
|
|
66604
66986
|
});
|
|
66605
66987
|
program2.command("__rules", { hidden: true }).action(function() {
|
|
@@ -66644,7 +67026,7 @@ function invokedDirectly() {
|
|
|
66644
67026
|
const entry = process.argv[1];
|
|
66645
67027
|
if (!entry) return false;
|
|
66646
67028
|
try {
|
|
66647
|
-
return
|
|
67029
|
+
return fs89.realpathSync(entry) === fs89.realpathSync(SELF2);
|
|
66648
67030
|
} catch {
|
|
66649
67031
|
return false;
|
|
66650
67032
|
}
|