wildcrane-runner 0.6.105 → 0.6.106
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 +822 -524
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/codex-proxy.mjs +37 -11
- package/dist/codex-retained.mjs +36 -10
- package/dist/flow-worker-main.mjs +5150 -4699
- package/dist/launcher.mjs +1880 -1804
- package/dist/plugin.mjs +6501 -6425
- package/dist/runner.mjs +1593 -1144
- package/dist/settings.mjs +2072 -1996
- 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.86 — 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;
|
|
@@ -22372,6 +22372,36 @@ var init_language = __esm({
|
|
|
22372
22372
|
});
|
|
22373
22373
|
|
|
22374
22374
|
// ../cli/src/lib/agent/retry.ts
|
|
22375
|
+
function clipSummary(text5) {
|
|
22376
|
+
const clean = text5.replace(/\s+/g, " ").trim();
|
|
22377
|
+
return clean.length > MAX_SUMMARY_CHARS ? `${clean.slice(0, MAX_SUMMARY_CHARS - 1)}\u2026` : clean;
|
|
22378
|
+
}
|
|
22379
|
+
function clipDetail(text5) {
|
|
22380
|
+
if (!text5) return void 0;
|
|
22381
|
+
const trimmed2 = text5.trim();
|
|
22382
|
+
if (!trimmed2) return void 0;
|
|
22383
|
+
return trimmed2.length > MAX_DETAIL_CHARS ? `${trimmed2.slice(0, MAX_DETAIL_CHARS - 1)}\u2026` : trimmed2;
|
|
22384
|
+
}
|
|
22385
|
+
function makeFailure(source2, rawSummary, options) {
|
|
22386
|
+
const summary2 = clipSummary(rawSummary) || "Execution failed.";
|
|
22387
|
+
const rawDetail = options?.detail?.trim() || (rawSummary.trim().length > summary2.length || rawSummary.includes("\n") ? rawSummary.trim() : void 0);
|
|
22388
|
+
const detail = clipDetail(rawDetail);
|
|
22389
|
+
return {
|
|
22390
|
+
...options?.code ? { code: options.code } : {},
|
|
22391
|
+
source: source2,
|
|
22392
|
+
summary: summary2,
|
|
22393
|
+
...detail && detail !== summary2 ? { detail } : {},
|
|
22394
|
+
...typeof options?.retryAfterMs === "number" && Number.isFinite(options.retryAfterMs) && options.retryAfterMs >= 0 ? { retryAfterMs: options.retryAfterMs } : {}
|
|
22395
|
+
};
|
|
22396
|
+
}
|
|
22397
|
+
function isSessionMissingText(text5) {
|
|
22398
|
+
return !!text5 && SESSION_MISSING_RE.test(text5);
|
|
22399
|
+
}
|
|
22400
|
+
function isSessionMissingFailure(failure2) {
|
|
22401
|
+
if (!failure2) return false;
|
|
22402
|
+
if (failure2.code === "session_not_found" || failure2.code === "session_mismatch") return true;
|
|
22403
|
+
return isSessionMissingText(failure2.summary) || isSessionMissingText(failure2.detail);
|
|
22404
|
+
}
|
|
22375
22405
|
function agentRecovery(evidence) {
|
|
22376
22406
|
if (!evidence.stopped) return "unsafe";
|
|
22377
22407
|
if (evidence.completed) return "report";
|
|
@@ -22379,63 +22409,142 @@ function agentRecovery(evidence) {
|
|
|
22379
22409
|
if (evidence.session) return "resume";
|
|
22380
22410
|
return evidence.replayable ? "replay" : "unsafe";
|
|
22381
22411
|
}
|
|
22412
|
+
function retryContinuePrompt(failure2, attempt2, maxAttempts = MAX_RETRY_ATTEMPTS) {
|
|
22413
|
+
const head2 = attempt2 ? `Previous attempt (${attempt2}/${maxAttempts}) failed [${failure2.source}${failure2.code ? `:${failure2.code}` : ""}]: ${failure2.summary}` : `Previous execution failed [${failure2.source}${failure2.code ? `:${failure2.code}` : ""}]: ${failure2.summary}`;
|
|
22414
|
+
const parts = [head2];
|
|
22415
|
+
if (failure2.detail && failure2.detail !== failure2.summary) parts.push(`Diagnostics:
|
|
22416
|
+
${failure2.detail}`);
|
|
22417
|
+
parts.push(recoveryPrompt);
|
|
22418
|
+
return parts.join("\n\n");
|
|
22419
|
+
}
|
|
22382
22420
|
function backoffMs(attempt2, random = Math.random) {
|
|
22383
22421
|
const step = Math.min(CAP_MS, BASE_MS * 2 ** Math.max(0, attempt2 - 2));
|
|
22384
22422
|
return Math.round(step * (1 - 0.25 * random()));
|
|
22385
22423
|
}
|
|
22386
22424
|
function planRetry(failure2, attempt2, now = Date.now(), backoff = backoffMs, task = false) {
|
|
22387
|
-
if (!Number.isSafeInteger(attempt2) || attempt2 < 1
|
|
22388
|
-
const of =
|
|
22425
|
+
if (!Number.isSafeInteger(attempt2) || attempt2 < 1) return { pause: "unsafe" };
|
|
22426
|
+
const of = MAX_RETRY_ATTEMPTS;
|
|
22389
22427
|
if (attempt2 >= of) return { pause: "limit" };
|
|
22390
22428
|
const delay3 = failure2.retryAfterMs;
|
|
22391
22429
|
const valid = delay3 !== void 0 && !Number.isNaN(delay3) && delay3 >= 0;
|
|
22392
|
-
const
|
|
22430
|
+
const immediate = failure2.source === "validation" || failure2.source === "sync";
|
|
22431
|
+
const wait = valid ? delay3 : immediate ? 0 : backoff(attempt2 + 1);
|
|
22393
22432
|
const cap = task && failure2.code === "rate_limited" && valid ? 24 * 60 * 6e4 : CAP_MS;
|
|
22394
|
-
if (wait > cap) return { pause: "
|
|
22433
|
+
if (wait > cap) return { pause: "wait_too_long" };
|
|
22395
22434
|
return { plan: { at: now + wait, of, failure: failure2 } };
|
|
22396
22435
|
}
|
|
22436
|
+
function normalizeSource(raw) {
|
|
22437
|
+
if (SOURCES.has(raw)) return raw;
|
|
22438
|
+
if (raw === "provider" || raw === "harness") return "runtime";
|
|
22439
|
+
if (raw === "invariant") return "runner";
|
|
22440
|
+
return "runtime";
|
|
22441
|
+
}
|
|
22397
22442
|
function readFailure(raw) {
|
|
22398
22443
|
if (!raw || typeof raw !== "object") return;
|
|
22399
|
-
const
|
|
22400
|
-
|
|
22401
|
-
|
|
22444
|
+
const r = raw;
|
|
22445
|
+
const rawSummary = typeof r.summary === "string" && r.summary.trim() ? r.summary : typeof r.reason === "string" && r.reason.trim() ? r.reason : "";
|
|
22446
|
+
if (!rawSummary) return;
|
|
22447
|
+
const code = typeof r.code === "string" && r.code.trim() ? r.code.trim() : void 0;
|
|
22448
|
+
const detail = typeof r.detail === "string" ? clipDetail(r.detail) : void 0;
|
|
22449
|
+
const retryAfterMs2 = typeof r.retryAfterMs === "number" && Number.isFinite(r.retryAfterMs) && r.retryAfterMs >= 0 ? r.retryAfterMs : void 0;
|
|
22450
|
+
return {
|
|
22451
|
+
...code ? { code } : {},
|
|
22452
|
+
source: normalizeSource(r.source),
|
|
22453
|
+
summary: clipSummary(rawSummary),
|
|
22454
|
+
...detail && detail !== clipSummary(rawSummary) ? { detail } : {},
|
|
22455
|
+
...retryAfterMs2 !== void 0 ? { retryAfterMs: retryAfterMs2 } : {}
|
|
22456
|
+
};
|
|
22457
|
+
}
|
|
22458
|
+
function readRetryRuntime(raw) {
|
|
22459
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
22460
|
+
const r = raw;
|
|
22461
|
+
if (typeof r.connector !== "string" || !r.connector.trim()) return void 0;
|
|
22462
|
+
return {
|
|
22463
|
+
connector: r.connector.trim(),
|
|
22464
|
+
name: typeof r.name === "string" && r.name.trim() ? r.name.trim() : null,
|
|
22465
|
+
model: typeof r.model === "string" && r.model.trim() ? r.model.trim() : null
|
|
22466
|
+
};
|
|
22467
|
+
}
|
|
22468
|
+
function readRetryRecord(raw) {
|
|
22469
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
22470
|
+
const r = raw;
|
|
22471
|
+
const attempt2 = r.attempt;
|
|
22472
|
+
const summary2 = typeof r.summary === "string" ? clipSummary(r.summary) : "";
|
|
22473
|
+
const at = typeof r.at === "string" && r.at.trim() ? r.at.trim() : "";
|
|
22474
|
+
if (typeof attempt2 !== "number" || !Number.isInteger(attempt2) || attempt2 < 1 || !summary2 || !at) return void 0;
|
|
22475
|
+
const runtime = readRetryRuntime(r.runtime);
|
|
22476
|
+
const detail = typeof r.detail === "string" ? clipDetail(r.detail) : void 0;
|
|
22477
|
+
const code = typeof r.code === "string" && r.code.trim() ? r.code.trim() : void 0;
|
|
22478
|
+
const sessionAction = SESSION_ACTIONS.has(r.sessionAction) ? r.sessionAction : void 0;
|
|
22479
|
+
return {
|
|
22480
|
+
attempt: attempt2,
|
|
22481
|
+
source: normalizeSource(r.source),
|
|
22482
|
+
...runtime ? { runtime } : {},
|
|
22483
|
+
summary: summary2,
|
|
22484
|
+
...detail && detail !== summary2 ? { detail } : {},
|
|
22485
|
+
...code ? { code } : {},
|
|
22486
|
+
...sessionAction ? { sessionAction } : {},
|
|
22487
|
+
at
|
|
22488
|
+
};
|
|
22489
|
+
}
|
|
22490
|
+
function readRetryHistory(raw) {
|
|
22491
|
+
if (!Array.isArray(raw)) return void 0;
|
|
22492
|
+
const records = raw.flatMap((entry) => {
|
|
22493
|
+
const parsed = readRetryRecord(entry);
|
|
22494
|
+
return parsed ? [parsed] : [];
|
|
22495
|
+
});
|
|
22496
|
+
return records.length ? records : void 0;
|
|
22497
|
+
}
|
|
22498
|
+
function readRetryPause(raw) {
|
|
22499
|
+
if (raw === "wait-too-long") return "wait_too_long";
|
|
22500
|
+
if (raw === "needs-review") return "limit";
|
|
22501
|
+
if (raw === "limit" || raw === "wait_too_long" || raw === "unsafe" || raw === "authorization" || raw === "stopped") return raw;
|
|
22502
|
+
return void 0;
|
|
22402
22503
|
}
|
|
22403
22504
|
function readRetryPlan(raw, attempt2, task = false) {
|
|
22404
22505
|
if (!raw || typeof raw !== "object") return;
|
|
22405
|
-
const { at, of, failure: rawFailure } = raw;
|
|
22506
|
+
const { at, of, failure: rawFailure, sessionAction } = raw;
|
|
22406
22507
|
const failure2 = readFailure(rawFailure);
|
|
22407
22508
|
if (!failure2 || typeof at !== "number" || !Number.isFinite(at)) return;
|
|
22408
22509
|
const decision = planRetry(failure2, attempt2, Date.now(), backoffMs, task);
|
|
22409
|
-
if ("plan" in decision && of === decision.plan.of)
|
|
22510
|
+
if ("plan" in decision && of === decision.plan.of) {
|
|
22511
|
+
return { at, of, failure: failure2, ...SESSION_ACTIONS.has(sessionAction) ? { sessionAction } : {} };
|
|
22512
|
+
}
|
|
22410
22513
|
}
|
|
22411
22514
|
function pauseLine(pause2, zh = translating()) {
|
|
22412
22515
|
switch (pause2) {
|
|
22413
|
-
case "needs-review":
|
|
22414
|
-
return zh ? "\u5DF2\u6682\u505C\uFF0C\u8BF7\u68C0\u67E5\u5931\u8D25\u539F\u56E0\u540E\u7EED\u8DD1\u3002" : "Paused. Review the failure before resuming.";
|
|
22415
22516
|
case "limit":
|
|
22416
22517
|
return zh ? "\u5DF2\u8FBE\u5230\u81EA\u52A8\u91CD\u8BD5\u6B21\u6570\u4E0A\u9650\u3002" : "The automatic retry limit was reached.";
|
|
22417
|
-
case "
|
|
22518
|
+
case "wait_too_long":
|
|
22418
22519
|
return zh ? "\u6240\u9700\u7B49\u5F85\u65F6\u95F4\u8D85\u8FC7\u4E24\u5206\u949F\uFF0C\u5DF2\u6682\u505C\u3002" : "Paused because the required wait exceeds two minutes.";
|
|
22419
22520
|
case "unsafe":
|
|
22420
22521
|
return zh ? "\u65E0\u6CD5\u786E\u8BA4\u53EF\u4EE5\u5B89\u5168\u7EED\u8DD1\uFF0C\u8BF7\u5148\u6838\u5BF9\u5DF2\u6709\u8FDB\u5EA6\u548C\u64CD\u4F5C\u7ED3\u679C\u3002" : "Check saved progress and operation results before resuming safely.";
|
|
22421
22522
|
case "authorization":
|
|
22422
22523
|
return zh ? "\u65E0\u6CD5\u786E\u8BA4\u7EED\u8DD1\u6388\u6743\uFF0C\u5DF2\u6682\u505C\u3002" : "Paused because authorization to resume could not be confirmed.";
|
|
22524
|
+
case "stopped":
|
|
22525
|
+
return zh ? "\u6267\u884C\u5DF2\u505C\u6B62\u3002" : "Execution stopped.";
|
|
22423
22526
|
}
|
|
22424
22527
|
}
|
|
22425
22528
|
function retryLine(plan, attempt2, now = Date.now()) {
|
|
22426
22529
|
const seconds = Math.max(0, Math.ceil((plan.at - now) / 1e3));
|
|
22427
|
-
return `${plan.failure.
|
|
22530
|
+
return `${plan.failure.summary} \u2014 retrying ${seconds ? `in ${seconds}s` : "now"} (attempt ${attempt2 + 1} of ${plan.of}).`;
|
|
22428
22531
|
}
|
|
22429
22532
|
function syncRepairPrompt(reason) {
|
|
22430
22533
|
return `The Harness could not synchronize the saved result. Correct the diagnostics below, verify the original result and its attachments, then continue from the saved work. Preserve completed work and archive state. Read the task review before changing an approved output and revise its stage first.
|
|
22431
22534
|
|
|
22432
22535
|
${reason}`;
|
|
22433
22536
|
}
|
|
22434
|
-
var recoveryPrompt, BASE_MS, CAP_MS;
|
|
22537
|
+
var MAX_RETRY_ATTEMPTS, MAX_SUMMARY_CHARS, MAX_DETAIL_CHARS, SOURCES, SESSION_ACTIONS, SESSION_MISSING_RE, recoveryPrompt, BASE_MS, CAP_MS;
|
|
22435
22538
|
var init_retry = __esm({
|
|
22436
22539
|
"../cli/src/lib/agent/retry.ts"() {
|
|
22437
22540
|
"use strict";
|
|
22438
22541
|
init_language();
|
|
22542
|
+
MAX_RETRY_ATTEMPTS = 4;
|
|
22543
|
+
MAX_SUMMARY_CHARS = 300;
|
|
22544
|
+
MAX_DETAIL_CHARS = 4e3;
|
|
22545
|
+
SOURCES = /* @__PURE__ */ new Set(["runtime", "runner", "sync", "validation"]);
|
|
22546
|
+
SESSION_ACTIONS = /* @__PURE__ */ new Set(["resume", "reset_replay", "pause_unsafe"]);
|
|
22547
|
+
SESSION_MISSING_RE = /no rollout found for thread id|no conversation found with session id|session[_\s-]*not[_\s-]*found|session[_\s-]*mismatch|(?:session|thread|conversation)\s+\S+\s+not\s+found|unknown\s+(?:session|thread)|did not resume the requested conversation|did not return the requested session/i;
|
|
22439
22548
|
recoveryPrompt = "Continue the interrupted turn in this session. Check the current state and the results of previous operations first. Preserve completed work and user decisions. Do not repeat an operation whose result has already taken effect.";
|
|
22440
22549
|
BASE_MS = 15e3;
|
|
22441
22550
|
CAP_MS = 12e4;
|
|
@@ -22722,8 +22831,8 @@ var init_package = __esm({
|
|
|
22722
22831
|
"../cli/package.json"() {
|
|
22723
22832
|
package_default = {
|
|
22724
22833
|
name: "wildcrane",
|
|
22725
|
-
version: "0.11.
|
|
22726
|
-
akbContract:
|
|
22834
|
+
version: "0.11.86",
|
|
22835
|
+
akbContract: 29,
|
|
22727
22836
|
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.",
|
|
22728
22837
|
keywords: [
|
|
22729
22838
|
"kanban",
|
|
@@ -24341,7 +24450,7 @@ function createAntigravityRenderer(expectedSession, cwd = process.cwd()) {
|
|
|
24341
24450
|
const events = createEventCollector();
|
|
24342
24451
|
const fail = (reason, code = "provider_failed") => {
|
|
24343
24452
|
failure2 = failureHint(reason);
|
|
24344
|
-
classified = { code,
|
|
24453
|
+
classified = makeFailure("runtime", failure2, { code, detail: reason });
|
|
24345
24454
|
events.error(failure2);
|
|
24346
24455
|
};
|
|
24347
24456
|
const reader = createLineReader((line) => {
|
|
@@ -24496,7 +24605,7 @@ ${imageError(target, reason || str2(step.state))}
|
|
|
24496
24605
|
},
|
|
24497
24606
|
failure: () => failure2 || imageFailure,
|
|
24498
24607
|
terminalFailure: () => terminal && !!classified,
|
|
24499
|
-
executionFailure: () => classified ?? (imageFailure ? { code: "image_read_failed",
|
|
24608
|
+
executionFailure: () => classified ?? (imageFailure ? makeFailure("runtime", imageFailure, { code: "image_read_failed", detail: imageFailure }) : void 0),
|
|
24500
24609
|
events: events.events,
|
|
24501
24610
|
activity: events.activity
|
|
24502
24611
|
};
|
|
@@ -24505,6 +24614,7 @@ var CONTEXT_LOOK_EVERY_MS, KINDS, zero, usageOf, add, imagePath;
|
|
|
24505
24614
|
var init_antigravity = __esm({
|
|
24506
24615
|
"../cli/src/lib/agent/wire/antigravity.ts"() {
|
|
24507
24616
|
"use strict";
|
|
24617
|
+
init_retry();
|
|
24508
24618
|
init_prices();
|
|
24509
24619
|
init_language();
|
|
24510
24620
|
init_events();
|
|
@@ -24751,13 +24861,9 @@ var init_check = __esm({
|
|
|
24751
24861
|
function executionFailure(error62) {
|
|
24752
24862
|
if (error62 instanceof ExecutionError) return error62.failure;
|
|
24753
24863
|
const code = str2(obj2(error62).code);
|
|
24754
|
-
const
|
|
24755
|
-
|
|
24756
|
-
|
|
24757
|
-
level: NETWORK.has(code) ? 2 : 3,
|
|
24758
|
-
source: "harness",
|
|
24759
|
-
reason
|
|
24760
|
-
};
|
|
24864
|
+
const raw = error62 instanceof Error ? error62.message : String(error62);
|
|
24865
|
+
const resolvedCode = isSessionMissingText(raw) ? "session_not_found" : NETWORK.has(code) ? "connection_lost" : code === "ENOENT" ? "executable_missing" : "execution_failed";
|
|
24866
|
+
return makeFailure("runner", raw, { code: resolvedCode, detail: raw });
|
|
24761
24867
|
}
|
|
24762
24868
|
function retryAfterMs(value, now = Date.now()) {
|
|
24763
24869
|
if (typeof value !== "string") return;
|
|
@@ -24767,37 +24873,48 @@ function retryAfterMs(value, now = Date.now()) {
|
|
|
24767
24873
|
const date5 = Date.parse(header);
|
|
24768
24874
|
if (Number.isFinite(date5)) return Math.max(0, date5 - now);
|
|
24769
24875
|
}
|
|
24770
|
-
function providerFailure(error62, reason) {
|
|
24876
|
+
function providerFailure(error62, reason, detail) {
|
|
24771
24877
|
const info = obj2(error62);
|
|
24772
24878
|
const status = typeof info.status === "number" ? info.status : void 0;
|
|
24773
24879
|
const headers = obj2(info.headers);
|
|
24774
24880
|
const wait = retryAfterMs(headers["retry-after"] ?? headers["Retry-After"]);
|
|
24775
|
-
const
|
|
24776
|
-
|
|
24777
|
-
if (
|
|
24778
|
-
return
|
|
24881
|
+
const rawCode = info.code ?? info.type;
|
|
24882
|
+
const fullDetail = detail || reason;
|
|
24883
|
+
if (rawCode === "session_not_found" || isSessionMissingText(reason) || isSessionMissingText(fullDetail)) {
|
|
24884
|
+
return makeFailure("runtime", reason, { code: "session_not_found", detail: fullDetail });
|
|
24885
|
+
}
|
|
24886
|
+
if (status === 401 || status === 403 || ["authentication_error", "permission_error", "invalid_request_error"].includes(str2(rawCode))) {
|
|
24887
|
+
return makeFailure("runtime", reason, { code: "provider_refused", detail: fullDetail });
|
|
24888
|
+
}
|
|
24889
|
+
if (status === 429 || rawCode === "rate_limit_error") {
|
|
24890
|
+
return makeFailure("runtime", reason, { code: "rate_limited", detail: fullDetail, retryAfterMs: wait });
|
|
24891
|
+
}
|
|
24892
|
+
if (TEMPORARY_HTTP.has(status ?? 0) || rawCode === "overloaded_error") {
|
|
24893
|
+
return makeFailure("runtime", reason, { code: "service_overloaded", detail: fullDetail, retryAfterMs: wait });
|
|
24894
|
+
}
|
|
24895
|
+
if (NETWORK.has(str2(rawCode))) {
|
|
24896
|
+
return makeFailure("runtime", reason, { code: "connection_lost", detail: fullDetail, retryAfterMs: wait });
|
|
24779
24897
|
}
|
|
24780
|
-
|
|
24781
|
-
if (TEMPORARY_HTTP.has(status ?? 0) || code === "overloaded_error") return { code: "service_overloaded", source: "provider", level: 2, reason, retryAfterMs: wait };
|
|
24782
|
-
if (NETWORK.has(str2(code))) return { code: "connection_lost", source: "provider", level: 2, reason, retryAfterMs: wait };
|
|
24783
|
-
return { code: "provider_failed", source: "provider", level: 3, reason };
|
|
24898
|
+
return makeFailure("runtime", reason, { code: "provider_failed", detail: fullDetail, retryAfterMs: wait });
|
|
24784
24899
|
}
|
|
24785
24900
|
function codexFailure(raw, fallback) {
|
|
24786
24901
|
const error62 = obj2(raw);
|
|
24787
24902
|
const failure2 = readFailure(error62.wildcraneFailure);
|
|
24788
|
-
if (failure2
|
|
24903
|
+
if (failure2) return failure2;
|
|
24789
24904
|
const reason = str2(error62.message) || fallback;
|
|
24905
|
+
const additional = str2(error62.additionalDetails);
|
|
24906
|
+
const detail = [reason, additional].filter(Boolean).join("\n");
|
|
24790
24907
|
const info = error62.codexErrorInfo;
|
|
24791
|
-
if (info === "serverOverloaded") return providerFailure({ ...error62, type: "overloaded_error" }, reason);
|
|
24792
|
-
if (info === "rateLimitExceeded") return providerFailure({ ...error62, type: "rate_limit_error" }, reason);
|
|
24908
|
+
if (info === "serverOverloaded") return providerFailure({ ...error62, type: "overloaded_error" }, reason, detail);
|
|
24909
|
+
if (info === "rateLimitExceeded") return providerFailure({ ...error62, type: "rate_limit_error" }, reason, detail);
|
|
24793
24910
|
const types = obj2(info);
|
|
24794
24911
|
for (const kind of ["httpConnectionFailed", "responseStreamConnectionFailed", "responseStreamDisconnected", "responseTooManyFailedAttempts"]) {
|
|
24795
24912
|
if (!(kind in types)) continue;
|
|
24796
24913
|
const status = obj2(types[kind]).httpStatusCode;
|
|
24797
|
-
if (typeof status === "number") return providerFailure({ ...error62, status }, reason);
|
|
24798
|
-
if (kind !== "responseTooManyFailedAttempts") return providerFailure({ ...error62, code: "ECONNRESET" }, reason);
|
|
24914
|
+
if (typeof status === "number") return providerFailure({ ...error62, status }, reason, detail);
|
|
24915
|
+
if (kind !== "responseTooManyFailedAttempts") return providerFailure({ ...error62, code: "ECONNRESET" }, reason, detail);
|
|
24799
24916
|
}
|
|
24800
|
-
return providerFailure(error62, reason);
|
|
24917
|
+
return providerFailure(error62, reason, detail);
|
|
24801
24918
|
}
|
|
24802
24919
|
var ExecutionError, NETWORK, TEMPORARY_HTTP;
|
|
24803
24920
|
var init_failures = __esm({
|
|
@@ -24807,7 +24924,7 @@ var init_failures = __esm({
|
|
|
24807
24924
|
init_json();
|
|
24808
24925
|
ExecutionError = class extends Error {
|
|
24809
24926
|
constructor(failure2) {
|
|
24810
|
-
super(failure2.
|
|
24927
|
+
super(failure2.summary);
|
|
24811
24928
|
this.failure = failure2;
|
|
24812
24929
|
}
|
|
24813
24930
|
failure;
|
|
@@ -24953,7 +25070,12 @@ function createStreamRenderer() {
|
|
|
24953
25070
|
const turnUsage = usageOf2(ev.usage);
|
|
24954
25071
|
if (turnUsage) usage3 = usage3 ? addUsage(usage3, turnUsage) : turnUsage;
|
|
24955
25072
|
failure2 = ev.is_error === true ? whyItFailed(ev) : void 0;
|
|
24956
|
-
classified = failure2 ? ev.subtype === "error_max_structured_output_retries" ?
|
|
25073
|
+
classified = failure2 ? ev.subtype === "error_max_structured_output_retries" ? makeFailure("validation", failure2, { code: "validation_failed", detail: failure2 }) : (() => {
|
|
25074
|
+
const base = apiFailure ?? providerFailure(ev.error, failure2, failure2);
|
|
25075
|
+
const summary2 = clipSummary(failure2);
|
|
25076
|
+
const detail = clipDetail(failure2);
|
|
25077
|
+
return { ...base, summary: summary2, ...detail && detail !== summary2 ? { detail } : {} };
|
|
25078
|
+
})() : void 0;
|
|
24957
25079
|
apiFailure = void 0;
|
|
24958
25080
|
if (failure2) events.error(failure2);
|
|
24959
25081
|
turns.push({
|
|
@@ -25011,6 +25133,7 @@ var ARG_KEYS, TOOL_KINDS2, SUBAGENT_TOOLS, USER_FIXES, addUsage;
|
|
|
25011
25133
|
var init_claude_stream = __esm({
|
|
25012
25134
|
"../cli/src/lib/agent/wire/claude-stream.ts"() {
|
|
25013
25135
|
"use strict";
|
|
25136
|
+
init_retry();
|
|
25014
25137
|
init_failures();
|
|
25015
25138
|
init_events();
|
|
25016
25139
|
init_json();
|
|
@@ -25439,7 +25562,7 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
25439
25562
|
return "";
|
|
25440
25563
|
// 最终失败保留;连接提示只在没有后续成功完成时才作为失败。
|
|
25441
25564
|
case "turn.failed": {
|
|
25442
|
-
const said2 = str2(obj2(ev.error).message) || failure2?.
|
|
25565
|
+
const said2 = str2(obj2(ev.error).message) || failure2?.summary || "Codex execution failed.";
|
|
25443
25566
|
failure2 = codexFailure(ev.error, said2);
|
|
25444
25567
|
events.error(said2);
|
|
25445
25568
|
return `[error] ${said2}
|
|
@@ -25494,7 +25617,7 @@ function createCodexStreamRenderer(carried = false) {
|
|
|
25494
25617
|
},
|
|
25495
25618
|
costIncomplete: () => childSpend(subagents, since).costIncomplete || childSpend(subagents, since).costUsd !== void 0 && priceUsd(facts?.provider, turn2()?.model ?? facts?.model, own2()) === void 0 || void 0,
|
|
25496
25619
|
resumeId: () => threadId,
|
|
25497
|
-
failure: () => failure2?.
|
|
25620
|
+
failure: () => failure2?.summary ?? background.failure(),
|
|
25498
25621
|
executionFailure: () => failure2,
|
|
25499
25622
|
background: () => subagents.size ? background.count() : void 0,
|
|
25500
25623
|
events: events.events,
|
|
@@ -25883,7 +26006,7 @@ function connect(stdout, stdin, onCall, dialect = {}) {
|
|
|
25883
26006
|
} else pending.ok(obj2(msg.result));
|
|
25884
26007
|
}
|
|
25885
26008
|
});
|
|
25886
|
-
stdout.on("close", () => closed2(new ExecutionError({ code: "connection_lost",
|
|
26009
|
+
stdout.on("close", () => closed2(new ExecutionError({ code: "connection_lost", source: "runtime", summary: "The agent closed the connection." })));
|
|
25887
26010
|
stdout.on("error", (err) => closed2(new ExecutionError(executionFailure(err))));
|
|
25888
26011
|
stdin.on("error", (err) => closed2(new ExecutionError(executionFailure(err))));
|
|
25889
26012
|
return {
|
|
@@ -26160,7 +26283,7 @@ async function oneTurn(io, options) {
|
|
|
26160
26283
|
} catch (e) {
|
|
26161
26284
|
const reason = e instanceof Error ? e.message : String(e);
|
|
26162
26285
|
const failure2 = e instanceof RpcError ? providerFailure(e.data, reason) : executionFailure(e);
|
|
26163
|
-
if (
|
|
26286
|
+
if (!(e instanceof RpcError) || obj2(e.data).code !== "session_not_found") throw e;
|
|
26164
26287
|
if (!io.restartPrompt) throw new ExecutionError(failure2);
|
|
26165
26288
|
const fresh = await bounded(newSession(rpc, io.cwd, mcpServers), preparingUntil - Date.now(), "ACP session/new timed out.");
|
|
26166
26289
|
opened = fresh.opened;
|
|
@@ -26208,7 +26331,7 @@ async function oneTurn(io, options) {
|
|
|
26208
26331
|
`);
|
|
26209
26332
|
events.error(why2);
|
|
26210
26333
|
emit();
|
|
26211
|
-
return { ok: false, result, error: why2, failure: { code: stopReason2
|
|
26334
|
+
return { ok: false, result, error: why2, failure: makeFailure("runtime", why2, { code: stopReason2 }), usage: usage3, context, costUsd };
|
|
26212
26335
|
}
|
|
26213
26336
|
emit();
|
|
26214
26337
|
return { ok: true, result, usage: usage3, context, costUsd };
|
|
@@ -26276,6 +26399,7 @@ var PROTOCOL_VERSION, CLIENT_CAPABILITIES, RESTARTED, TICKS_PER_USD, STOPPED;
|
|
|
26276
26399
|
var init_acp = __esm({
|
|
26277
26400
|
"../cli/src/lib/agent/wire/acp.ts"() {
|
|
26278
26401
|
"use strict";
|
|
26402
|
+
init_retry();
|
|
26279
26403
|
init_failures();
|
|
26280
26404
|
init_acp_cost();
|
|
26281
26405
|
init_conversation();
|
|
@@ -26580,7 +26704,7 @@ function event(envelope2, parts, tail, live, ended) {
|
|
|
26580
26704
|
case "turn.failed": {
|
|
26581
26705
|
const error62 = obj2(payload.error);
|
|
26582
26706
|
const failure2 = providerFailure(error62, str2(error62.message) || "the turn failed");
|
|
26583
|
-
return ended({ ok: false, error: failure2.
|
|
26707
|
+
return ended({ ok: false, error: failure2.summary, failure: failure2 });
|
|
26584
26708
|
}
|
|
26585
26709
|
case "session.closed":
|
|
26586
26710
|
return ended({ ok: false, error: str2(payload.reason) || "the agent closed the session" });
|
|
@@ -26673,6 +26797,18 @@ function createIdleWatchdog(expired, busy = () => false, milliseconds = IDLE_TIM
|
|
|
26673
26797
|
check2();
|
|
26674
26798
|
return;
|
|
26675
26799
|
}
|
|
26800
|
+
if (e.kind === "retry") {
|
|
26801
|
+
if (e.data.state === "waiting" || e.data.state === "retrying") {
|
|
26802
|
+
recoveringAt ??= now();
|
|
26803
|
+
const target = e.data.nextRetryAt ? Date.parse(e.data.nextRetryAt) : NaN;
|
|
26804
|
+
const waitUntil = Number.isFinite(target) ? Math.max(target + 3e4, now() + PROVIDER_RETRY_MS.announcement) : now() + PROVIDER_RETRY_MS.announcement;
|
|
26805
|
+
retryUntil = Math.min(waitUntil, recoveringAt + PROVIDER_RETRY_MS.episode);
|
|
26806
|
+
} else {
|
|
26807
|
+
touch();
|
|
26808
|
+
}
|
|
26809
|
+
check2();
|
|
26810
|
+
return;
|
|
26811
|
+
}
|
|
26676
26812
|
if (e.kind === "log" || e.kind === "context") return;
|
|
26677
26813
|
if (e.kind === "phase" && !e.data.contentAt) return;
|
|
26678
26814
|
const key = e.kind === "tool_call" || e.kind === "tool_call_update" ? `${e.kind}:${e.data.toolCallId}` : e.kind;
|
|
@@ -26700,7 +26836,7 @@ var init_idle = __esm({
|
|
|
26700
26836
|
IDLE_MS = 5 * 6e4;
|
|
26701
26837
|
IDLE_TIMEOUT = { milliseconds: IDLE_MS };
|
|
26702
26838
|
IDLE_ERROR = "No response for 5 minutes (idle timeout).";
|
|
26703
|
-
IDLE_FAILURE = { code: "idle_timeout",
|
|
26839
|
+
IDLE_FAILURE = { code: "idle_timeout", source: "runtime", summary: IDLE_ERROR };
|
|
26704
26840
|
PROVIDER_RETRY_MS = { announcement: 10 * 6e4, episode: 30 * 6e4 };
|
|
26705
26841
|
}
|
|
26706
26842
|
});
|
|
@@ -27061,12 +27197,12 @@ async function run(io, options, count3) {
|
|
|
27061
27197
|
const costUsd = cost === void 0 ? child.costUsd : cost + (child.costUsd ?? 0);
|
|
27062
27198
|
const failure2 = error62 || (cleanup.status === "unconfirmed" ? cleanup.detail : void 0) || work.work().filter((w) => !w.intentionalStop && ["failed", "interrupted"].includes(w.status)).map((w) => w.result || `Background work ${w.id} ${w.status}.`).join("\n") || void 0;
|
|
27063
27199
|
if (failure2) io.event?.({ kind: "error", data: { text: failure2 } });
|
|
27064
|
-
resolve2({ ok: !failure2, error: failure2, failure: failure2 ? classified ?? { code: "execution_failed",
|
|
27200
|
+
resolve2({ ok: !failure2, error: failure2, failure: failure2 ? classified ?? makeFailure("runtime", failure2, { code: "execution_failed", detail: failure2 }) : void 0, cleanup, result: renderer.result(), replyParts: renderer.replyParts?.(), usage: combinedUsage, context, costUsd, costIncomplete: child.costIncomplete || cost === void 0 && child.costUsd !== void 0 || void 0 });
|
|
27065
27201
|
};
|
|
27066
27202
|
const closed2 = () => {
|
|
27067
27203
|
const reason = "Codex connection closed before all work and results finished.";
|
|
27068
27204
|
if (work.work().some((w) => ["running", "unknown"].includes(w.status))) note("Connection lost; managed cleanup is unconfirmed.");
|
|
27069
|
-
end2(reason, { code: "connection_lost",
|
|
27205
|
+
end2(reason, makeFailure("runtime", reason, { code: "connection_lost", detail: reason }));
|
|
27070
27206
|
};
|
|
27071
27207
|
const inputFailed = (e) => {
|
|
27072
27208
|
if (work.work().some((w) => ["running", "unknown"].includes(w.status))) note("Connection input failed; managed cleanup is unconfirmed.");
|
|
@@ -27105,7 +27241,7 @@ async function run(io, options, count3) {
|
|
|
27105
27241
|
} catch (error62) {
|
|
27106
27242
|
if (!ended) note(error62 instanceof Error ? error62.message : String(error62));
|
|
27107
27243
|
}
|
|
27108
|
-
if (!ended) end2(IDLE_FAILURE.
|
|
27244
|
+
if (!ended) end2(IDLE_FAILURE.summary, IDLE_FAILURE);
|
|
27109
27245
|
};
|
|
27110
27246
|
io.idleSignal?.addEventListener("abort", idle, { once: true });
|
|
27111
27247
|
const childUpdates = () => {
|
|
@@ -27365,10 +27501,24 @@ async function run(io, options, count3) {
|
|
|
27365
27501
|
const failure2 = codexFailure(p.error, "Codex failed.");
|
|
27366
27502
|
if (p.willRetry === true && submitted && active3 && !idling) {
|
|
27367
27503
|
status = "retrying";
|
|
27368
|
-
io.log(`[Codex recovery] ${failure2.code}: ${failure2.
|
|
27504
|
+
io.log(`[Codex recovery] ${failure2.code ?? "error"}: ${failure2.summary}
|
|
27369
27505
|
`);
|
|
27370
27506
|
io.event?.({ kind: "status", data: { state: "retrying", source: "codex", code: failure2.code } });
|
|
27371
|
-
|
|
27507
|
+
io.event?.({
|
|
27508
|
+
kind: "retry",
|
|
27509
|
+
data: {
|
|
27510
|
+
state: "retrying",
|
|
27511
|
+
source: "runtime",
|
|
27512
|
+
runtime: { connector: "codex", name: null, model: model ?? null },
|
|
27513
|
+
attempt: 1,
|
|
27514
|
+
maxAttempts: MAX_RETRY_ATTEMPTS,
|
|
27515
|
+
summary: failure2.summary,
|
|
27516
|
+
...failure2.detail ? { detail: failure2.detail } : {},
|
|
27517
|
+
...failure2.code ? { code: failure2.code } : {},
|
|
27518
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
27519
|
+
}
|
|
27520
|
+
});
|
|
27521
|
+
} else if (p.willRetry !== true) end2(failure2.summary, failure2);
|
|
27372
27522
|
}
|
|
27373
27523
|
if (msg.method === "turn/completed") {
|
|
27374
27524
|
const turn2 = obj2(p.turn);
|
|
@@ -27382,7 +27532,7 @@ async function run(io, options, count3) {
|
|
|
27382
27532
|
if (idling) return;
|
|
27383
27533
|
if (turn2.status !== "completed") {
|
|
27384
27534
|
const reason = str2(obj2(turn2.error).message) || `Codex turn ${str2(turn2.status)}.`;
|
|
27385
|
-
const failure2 = turn2.status === "failed" ? codexFailure(turn2.error, reason) : { code: "turn_stopped",
|
|
27535
|
+
const failure2 = turn2.status === "failed" ? codexFailure(turn2.error, reason) : makeFailure("runtime", reason, { code: "turn_stopped", detail: reason });
|
|
27386
27536
|
end2(reason, failure2);
|
|
27387
27537
|
return;
|
|
27388
27538
|
}
|
|
@@ -27419,11 +27569,15 @@ async function run(io, options, count3) {
|
|
|
27419
27569
|
try {
|
|
27420
27570
|
response = await bounded(rpc.call(method, params), preparingUntil - Date.now(), `Codex ${method} timed out.`);
|
|
27421
27571
|
} catch (error62) {
|
|
27572
|
+
if (mode === "fork" && error62 instanceof RpcError && error62.code === -32600 && error62.message === `no rollout found for thread id ${params.threadId}`) {
|
|
27573
|
+
end2(error62.message, { code: "codex_fork_source_missing", source: "runtime", summary: error62.message, detail: error62.message });
|
|
27574
|
+
return done;
|
|
27575
|
+
}
|
|
27422
27576
|
const failure2 = error62 instanceof RpcError ? codexFailure(error62.data, error62.message) : void 0;
|
|
27423
|
-
if (mode !== "fork" || failure2?.
|
|
27577
|
+
if (mode !== "fork" || failure2?.code !== "codex_source_busy") throw error62;
|
|
27424
27578
|
if (!waiting) {
|
|
27425
27579
|
waiting = true;
|
|
27426
|
-
io.event?.({ kind: "log", data: { text: failure2.
|
|
27580
|
+
io.event?.({ kind: "log", data: { text: failure2.summary } });
|
|
27427
27581
|
}
|
|
27428
27582
|
io.activity?.();
|
|
27429
27583
|
await delay(500, void 0, { signal: io.signal });
|
|
@@ -27449,7 +27603,7 @@ async function run(io, options, count3) {
|
|
|
27449
27603
|
await start(io.prompt, options.images);
|
|
27450
27604
|
} catch (e) {
|
|
27451
27605
|
const failure2 = e instanceof RpcError ? codexFailure(e.data, e.message) : executionFailure(e);
|
|
27452
|
-
end2(failure2.
|
|
27606
|
+
end2(failure2.summary, failure2);
|
|
27453
27607
|
}
|
|
27454
27608
|
return done;
|
|
27455
27609
|
}
|
|
@@ -27458,6 +27612,7 @@ var init_codex = __esm({
|
|
|
27458
27612
|
"../cli/src/lib/agent/wire/codex.ts"() {
|
|
27459
27613
|
"use strict";
|
|
27460
27614
|
init_idle();
|
|
27615
|
+
init_retry();
|
|
27461
27616
|
init_failures();
|
|
27462
27617
|
init_conversation();
|
|
27463
27618
|
init_codex_background();
|
|
@@ -29129,6 +29284,22 @@ var init_settings2 = __esm({
|
|
|
29129
29284
|
});
|
|
29130
29285
|
|
|
29131
29286
|
// ../cli/src/lib/agent/runtimes.ts
|
|
29287
|
+
import fs27 from "node:fs";
|
|
29288
|
+
function executionRuntimes() {
|
|
29289
|
+
const encoded = process.env[EXECUTION_RUNTIMES_ENV];
|
|
29290
|
+
return encoded ? JSON.parse(encoded) : void 0;
|
|
29291
|
+
}
|
|
29292
|
+
function readRuntimeCredentials(file2) {
|
|
29293
|
+
try {
|
|
29294
|
+
return configBlock(JSON.parse(fs27.readFileSync(file2, "utf8")));
|
|
29295
|
+
} catch {
|
|
29296
|
+
return {};
|
|
29297
|
+
}
|
|
29298
|
+
}
|
|
29299
|
+
function runRuntimeById(id2) {
|
|
29300
|
+
const scope = executionRuntimes();
|
|
29301
|
+
return scope ? [scope.default, ...Object.values(scope.picks)].find((row) => row.id === id2) : runtimeById(id2);
|
|
29302
|
+
}
|
|
29132
29303
|
function readRuntimes(cfg = safeConfig()) {
|
|
29133
29304
|
const saved = Array.isArray(cfg.runtimes) ? cfg.runtimes.map(parseRuntime).filter(isRuntime) : null;
|
|
29134
29305
|
const list3 = saved?.length ? dedupe(saved) : [];
|
|
@@ -29243,7 +29414,7 @@ function writePicks(cfg, picks, list3 = readRuntimes(cfg)) {
|
|
|
29243
29414
|
if (Object.keys(block).length) cfg.agentRuntime = block;
|
|
29244
29415
|
else delete cfg.agentRuntime;
|
|
29245
29416
|
}
|
|
29246
|
-
var GLOBAL_ID, GLOBAL_NAME, isRuntime, runtimeSecretVar, keepsPick, noRuntime, noHarness;
|
|
29417
|
+
var GLOBAL_ID, GLOBAL_NAME, EXECUTION_RUNTIMES_ENV, isRuntime, runtimeSecretVar, keepsPick, noRuntime, noHarness;
|
|
29247
29418
|
var init_runtimes = __esm({
|
|
29248
29419
|
"../cli/src/lib/agent/runtimes.ts"() {
|
|
29249
29420
|
"use strict";
|
|
@@ -29252,6 +29423,7 @@ var init_runtimes = __esm({
|
|
|
29252
29423
|
init_types3();
|
|
29253
29424
|
GLOBAL_ID = "global";
|
|
29254
29425
|
GLOBAL_NAME = "Global default";
|
|
29426
|
+
EXECUTION_RUNTIMES_ENV = "AI4KANBAN_EXECUTION_RUNTIMES";
|
|
29255
29427
|
isRuntime = (r) => r !== null;
|
|
29256
29428
|
runtimeSecretVar = (env2, runtime) => runtime.secretRefs?.[env2] ?? secretVar(env2, runtime.id);
|
|
29257
29429
|
keepsPick = (id2) => !!id2 && id2 !== GLOBAL_ID;
|
|
@@ -29272,11 +29444,11 @@ var init_slug = __esm({
|
|
|
29272
29444
|
});
|
|
29273
29445
|
|
|
29274
29446
|
// ../cli/src/lib/validate.ts
|
|
29275
|
-
import
|
|
29447
|
+
import fs28 from "node:fs";
|
|
29276
29448
|
import path30 from "node:path";
|
|
29277
29449
|
function moduleNames() {
|
|
29278
|
-
if (!
|
|
29279
|
-
return moduleNamesFrom(
|
|
29450
|
+
if (!fs28.existsSync(MODULES_MD)) return null;
|
|
29451
|
+
return moduleNamesFrom(fs28.readFileSync(MODULES_MD, "utf8"));
|
|
29280
29452
|
}
|
|
29281
29453
|
function validModules(mods) {
|
|
29282
29454
|
const known2 = moduleNames();
|
|
@@ -29311,7 +29483,7 @@ function dependencyCycle(id2, dep) {
|
|
|
29311
29483
|
const found2 = locate(at);
|
|
29312
29484
|
if (!found2) return null;
|
|
29313
29485
|
const file2 = found2.kind === "group" ? path30.join(found2.target, "root.md") : found2.target;
|
|
29314
|
-
const nexts = parseFrontmatter(
|
|
29486
|
+
const nexts = parseFrontmatter(fs28.readFileSync(file2, "utf8")).meta?.blocked_by ?? [];
|
|
29315
29487
|
if (found2.kind === "group") nexts.push(...groupMembers(found2.target));
|
|
29316
29488
|
for (const next of nexts) {
|
|
29317
29489
|
const rest2 = walk3(next);
|
|
@@ -29339,7 +29511,7 @@ var init_validate = __esm({
|
|
|
29339
29511
|
});
|
|
29340
29512
|
|
|
29341
29513
|
// ../cli/src/lib/memory.ts
|
|
29342
|
-
import
|
|
29514
|
+
import fs29 from "node:fs";
|
|
29343
29515
|
import path31 from "node:path";
|
|
29344
29516
|
function scaffoldProjectMemory() {
|
|
29345
29517
|
const board2 = scaffoldMemoryDir(MEMORY, setOf(BOARD_MEMORY_FILES));
|
|
@@ -29347,13 +29519,13 @@ function scaffoldProjectMemory() {
|
|
|
29347
29519
|
return board2 ?? planner;
|
|
29348
29520
|
}
|
|
29349
29521
|
function scaffoldMemoryDir(dir, set2) {
|
|
29350
|
-
const existed =
|
|
29351
|
-
|
|
29522
|
+
const existed = fs29.existsSync(dir);
|
|
29523
|
+
fs29.mkdirSync(dir, { recursive: true });
|
|
29352
29524
|
const made = [];
|
|
29353
29525
|
for (const [name, body] of Object.entries(set2)) {
|
|
29354
29526
|
const file2 = path31.join(dir, name);
|
|
29355
|
-
if (!
|
|
29356
|
-
|
|
29527
|
+
if (!fs29.existsSync(file2)) {
|
|
29528
|
+
fs29.writeFileSync(file2, body);
|
|
29357
29529
|
made.push(name);
|
|
29358
29530
|
}
|
|
29359
29531
|
}
|
|
@@ -29363,7 +29535,7 @@ function scaffoldMemoryDir(dir, set2) {
|
|
|
29363
29535
|
function plannerModules() {
|
|
29364
29536
|
let dirs2;
|
|
29365
29537
|
try {
|
|
29366
|
-
dirs2 =
|
|
29538
|
+
dirs2 = fs29.readdirSync(agentMemoryDir(PLANNER), { withFileTypes: true }).filter((e) => e.isDirectory() && isModule(e.name)).map((e) => e.name);
|
|
29367
29539
|
} catch {
|
|
29368
29540
|
return [];
|
|
29369
29541
|
}
|
|
@@ -29375,7 +29547,7 @@ function memoryDirectories(board2) {
|
|
|
29375
29547
|
const walk3 = (dir, depth3, scoped = true) => {
|
|
29376
29548
|
let entries2;
|
|
29377
29549
|
try {
|
|
29378
|
-
entries2 =
|
|
29550
|
+
entries2 = fs29.readdirSync(dir, { withFileTypes: true });
|
|
29379
29551
|
} catch {
|
|
29380
29552
|
return [];
|
|
29381
29553
|
}
|
|
@@ -29389,7 +29561,7 @@ function memoryDirectories(board2) {
|
|
|
29389
29561
|
...walk3(path31.join(root2, "previews"), 3),
|
|
29390
29562
|
...walk3(path31.join(root2, "studios"), 1, false),
|
|
29391
29563
|
path31.join(root2, "agents", PLANNER)
|
|
29392
|
-
].filter((dir) =>
|
|
29564
|
+
].filter((dir) => fs29.existsSync(dir)).map((dir) => `${dir}/`);
|
|
29393
29565
|
}
|
|
29394
29566
|
var PLANNER, PLANNER_MEMORY_FILES, BOARD_MEMORY_FILES, STARTERS, setOf, RESERVED_MEMORY_DIR, STUDIO_MEMORY_DIR, agentMemoryDir, agentMemoryFile, writtenMemoryNames, memoryNamesOf, agentMemoryFiles, RESERVED_MODULE_NAMES, isModule, moduleMemoryFile, plannerCopies;
|
|
29395
29567
|
var init_memory = __esm({
|
|
@@ -29438,7 +29610,7 @@ edits here do not last.
|
|
|
29438
29610
|
agentMemoryFile = (agent, name) => path31.join(agentMemoryDir(agent), name);
|
|
29439
29611
|
writtenMemoryNames = (agent) => {
|
|
29440
29612
|
try {
|
|
29441
|
-
return
|
|
29613
|
+
return fs29.readdirSync(agentMemoryDir(agent), { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".md")).map((e) => e.name).sort();
|
|
29442
29614
|
} catch {
|
|
29443
29615
|
return [];
|
|
29444
29616
|
}
|
|
@@ -29450,7 +29622,7 @@ edits here do not last.
|
|
|
29450
29622
|
moduleMemoryFile = (module, name) => path31.join(agentMemoryDir(PLANNER), module, name);
|
|
29451
29623
|
plannerCopies = (name) => [
|
|
29452
29624
|
agentMemoryFile(PLANNER, name),
|
|
29453
|
-
...plannerModules().map((m) => moduleMemoryFile(m, name)).filter((file2) =>
|
|
29625
|
+
...plannerModules().map((m) => moduleMemoryFile(m, name)).filter((file2) => fs29.existsSync(file2))
|
|
29454
29626
|
];
|
|
29455
29627
|
}
|
|
29456
29628
|
});
|
|
@@ -43121,14 +43293,14 @@ var require_parser = __commonJS({
|
|
|
43121
43293
|
case "scalar":
|
|
43122
43294
|
case "single-quoted-scalar":
|
|
43123
43295
|
case "double-quoted-scalar": {
|
|
43124
|
-
const
|
|
43296
|
+
const fs91 = this.flowScalar(this.type);
|
|
43125
43297
|
if (atNextItem || it.value) {
|
|
43126
|
-
map3.items.push({ start, key:
|
|
43298
|
+
map3.items.push({ start, key: fs91, sep: [] });
|
|
43127
43299
|
this.onKeyLine = true;
|
|
43128
43300
|
} else if (it.sep) {
|
|
43129
|
-
this.stack.push(
|
|
43301
|
+
this.stack.push(fs91);
|
|
43130
43302
|
} else {
|
|
43131
|
-
Object.assign(it, { key:
|
|
43303
|
+
Object.assign(it, { key: fs91, sep: [] });
|
|
43132
43304
|
this.onKeyLine = true;
|
|
43133
43305
|
}
|
|
43134
43306
|
return;
|
|
@@ -43256,13 +43428,13 @@ var require_parser = __commonJS({
|
|
|
43256
43428
|
case "scalar":
|
|
43257
43429
|
case "single-quoted-scalar":
|
|
43258
43430
|
case "double-quoted-scalar": {
|
|
43259
|
-
const
|
|
43431
|
+
const fs91 = this.flowScalar(this.type);
|
|
43260
43432
|
if (!it || it.value)
|
|
43261
|
-
fc.items.push({ start: [], key:
|
|
43433
|
+
fc.items.push({ start: [], key: fs91, sep: [] });
|
|
43262
43434
|
else if (it.sep)
|
|
43263
|
-
this.stack.push(
|
|
43435
|
+
this.stack.push(fs91);
|
|
43264
43436
|
else
|
|
43265
|
-
Object.assign(it, { key:
|
|
43437
|
+
Object.assign(it, { key: fs91, sep: [] });
|
|
43266
43438
|
return;
|
|
43267
43439
|
}
|
|
43268
43440
|
case "flow-map-end":
|
|
@@ -43948,10 +44120,10 @@ var init_studio_files = __esm({
|
|
|
43948
44120
|
});
|
|
43949
44121
|
|
|
43950
44122
|
// ../cli/src/lib/agent/studio-folder.ts
|
|
43951
|
-
import
|
|
44123
|
+
import fs30 from "node:fs";
|
|
43952
44124
|
import path32 from "node:path";
|
|
43953
44125
|
function filesOf(dir, base = dir) {
|
|
43954
|
-
return
|
|
44126
|
+
return fs30.readdirSync(dir, { withFileTypes: true }).filter((e) => !e.name.startsWith(".")).flatMap((e) => {
|
|
43955
44127
|
const full = path32.join(dir, e.name);
|
|
43956
44128
|
if (e.isSymbolicLink()) throw new Error(`${full}: symbolic links are not allowed`);
|
|
43957
44129
|
return e.isDirectory() ? filesOf(full, base) : [path32.relative(base, full).split(path32.sep).join("/")];
|
|
@@ -43959,7 +44131,7 @@ function filesOf(dir, base = dir) {
|
|
|
43959
44131
|
}
|
|
43960
44132
|
function readStudioFile(dir, file2) {
|
|
43961
44133
|
const full = path32.join(dir, file2);
|
|
43962
|
-
return isAboutFile(file2) && !file2.endsWith(".md") ? `data:${MIME[path32.extname(file2)]};base64,${
|
|
44134
|
+
return isAboutFile(file2) && !file2.endsWith(".md") ? `data:${MIME[path32.extname(file2)]};base64,${fs30.readFileSync(full).toString("base64")}` : fs30.readFileSync(full, "utf8");
|
|
43963
44135
|
}
|
|
43964
44136
|
var MIME, readStudioFolder;
|
|
43965
44137
|
var init_studio_folder = __esm({
|
|
@@ -43973,7 +44145,7 @@ var init_studio_folder = __esm({
|
|
|
43973
44145
|
|
|
43974
44146
|
// ../official/pack.ts
|
|
43975
44147
|
import crypto2 from "node:crypto";
|
|
43976
|
-
import
|
|
44148
|
+
import fs31 from "node:fs";
|
|
43977
44149
|
import path33 from "node:path";
|
|
43978
44150
|
import { fileURLToPath } from "node:url";
|
|
43979
44151
|
function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
@@ -44005,32 +44177,32 @@ var init_pack = __esm({
|
|
|
44005
44177
|
init_studio_folder();
|
|
44006
44178
|
init_studio_files();
|
|
44007
44179
|
OFFICIAL = path33.dirname(fileURLToPath(import.meta.url));
|
|
44008
|
-
dirs = (dir) =>
|
|
44180
|
+
dirs = (dir) => fs31.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
44009
44181
|
hashOf = (files) => crypto2.createHash("sha256").update(hashInput(files)).digest("hex");
|
|
44010
44182
|
}
|
|
44011
44183
|
});
|
|
44012
44184
|
|
|
44013
44185
|
// ../cli/src/lib/agent/cloud-studios.ts
|
|
44014
|
-
import
|
|
44186
|
+
import fs32 from "node:fs";
|
|
44015
44187
|
import path34 from "node:path";
|
|
44016
44188
|
function readJson(file2) {
|
|
44017
44189
|
try {
|
|
44018
|
-
return JSON.parse(
|
|
44190
|
+
return JSON.parse(fs32.readFileSync(file2, "utf8"));
|
|
44019
44191
|
} catch {
|
|
44020
44192
|
return null;
|
|
44021
44193
|
}
|
|
44022
44194
|
}
|
|
44023
44195
|
function writeJson(file2, value) {
|
|
44024
|
-
|
|
44196
|
+
fs32.mkdirSync(path34.dirname(file2), { recursive: true });
|
|
44025
44197
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
44026
|
-
|
|
44198
|
+
fs32.writeFileSync(tmp, `${JSON.stringify(value)}
|
|
44027
44199
|
`);
|
|
44028
|
-
|
|
44200
|
+
fs32.renameSync(tmp, file2);
|
|
44029
44201
|
}
|
|
44030
44202
|
function heldStudioName(name) {
|
|
44031
44203
|
let files;
|
|
44032
44204
|
try {
|
|
44033
|
-
files =
|
|
44205
|
+
files = fs32.readdirSync(path34.join(root(), "versions"));
|
|
44034
44206
|
} catch {
|
|
44035
44207
|
return "";
|
|
44036
44208
|
}
|
|
@@ -44041,7 +44213,7 @@ function heldStudioName(name) {
|
|
|
44041
44213
|
}
|
|
44042
44214
|
function saveVersion(held4) {
|
|
44043
44215
|
const file2 = versionFile(held4.id, held4.version);
|
|
44044
|
-
if (!
|
|
44216
|
+
if (!fs32.existsSync(file2)) writeJson(file2, { id: held4.id, version: held4.version, name: held4.name, names: held4.names, files: held4.files });
|
|
44045
44217
|
}
|
|
44046
44218
|
function savePin(task, held4) {
|
|
44047
44219
|
saveVersion(held4);
|
|
@@ -44246,7 +44418,7 @@ var init_studio_file = __esm({
|
|
|
44246
44418
|
});
|
|
44247
44419
|
|
|
44248
44420
|
// ../cli/src/lib/agent/studios.ts
|
|
44249
|
-
import
|
|
44421
|
+
import fs33 from "node:fs";
|
|
44250
44422
|
import path35 from "node:path";
|
|
44251
44423
|
function noStudioMessage(id2) {
|
|
44252
44424
|
const name = heldStudioName(id2 ?? "") || id2;
|
|
@@ -44259,7 +44431,7 @@ function knownStudio(id2) {
|
|
|
44259
44431
|
}
|
|
44260
44432
|
function userStudioRules(flow) {
|
|
44261
44433
|
try {
|
|
44262
|
-
return
|
|
44434
|
+
return fs33.readFileSync(studioRuleFile(flow.id), "utf8").trim();
|
|
44263
44435
|
} catch {
|
|
44264
44436
|
return "";
|
|
44265
44437
|
}
|
|
@@ -44269,7 +44441,7 @@ function cardMeta(id2) {
|
|
|
44269
44441
|
const found2 = locate(id2) ?? locateArchived(id2);
|
|
44270
44442
|
if (!found2) return null;
|
|
44271
44443
|
const file2 = found2.kind === "group" ? path35.join(found2.target, "root.md") : found2.target;
|
|
44272
|
-
return parseFrontmatter(
|
|
44444
|
+
return parseFrontmatter(fs33.readFileSync(file2, "utf8")).meta;
|
|
44273
44445
|
} catch {
|
|
44274
44446
|
return null;
|
|
44275
44447
|
}
|
|
@@ -44933,7 +45105,7 @@ var init_parse3 = __esm({
|
|
|
44933
45105
|
});
|
|
44934
45106
|
|
|
44935
45107
|
// ../cli/src/lib/agents/catalog.ts
|
|
44936
|
-
import
|
|
45108
|
+
import fs34 from "node:fs";
|
|
44937
45109
|
import path37 from "node:path";
|
|
44938
45110
|
function readCatalog() {
|
|
44939
45111
|
const agents = [];
|
|
@@ -44991,7 +45163,7 @@ function readBundled(folder2) {
|
|
|
44991
45163
|
function projectFolders(root2) {
|
|
44992
45164
|
let entries2;
|
|
44993
45165
|
try {
|
|
44994
|
-
entries2 =
|
|
45166
|
+
entries2 = fs34.readdirSync(root2, { withFileTypes: true });
|
|
44995
45167
|
} catch {
|
|
44996
45168
|
return [];
|
|
44997
45169
|
}
|
|
@@ -45002,9 +45174,9 @@ function agentFileReader(dir) {
|
|
|
45002
45174
|
const target = path37.resolve(dir, relative);
|
|
45003
45175
|
if (target !== dir && !target.startsWith(dir + path37.sep)) return null;
|
|
45004
45176
|
try {
|
|
45005
|
-
const real2 =
|
|
45006
|
-
if (!real2.startsWith(
|
|
45007
|
-
return
|
|
45177
|
+
const real2 = fs34.realpathSync(target);
|
|
45178
|
+
if (!real2.startsWith(fs34.realpathSync(dir) + path37.sep)) return null;
|
|
45179
|
+
return fs34.readFileSync(real2, "utf8");
|
|
45008
45180
|
} catch {
|
|
45009
45181
|
return null;
|
|
45010
45182
|
}
|
|
@@ -45013,7 +45185,7 @@ function agentFileReader(dir) {
|
|
|
45013
45185
|
function walkFolder(dir, prefix) {
|
|
45014
45186
|
let entries2;
|
|
45015
45187
|
try {
|
|
45016
|
-
entries2 =
|
|
45188
|
+
entries2 = fs34.readdirSync(dir, { withFileTypes: true });
|
|
45017
45189
|
} catch {
|
|
45018
45190
|
return [];
|
|
45019
45191
|
}
|
|
@@ -45124,7 +45296,7 @@ var init_candidate = __esm({
|
|
|
45124
45296
|
|
|
45125
45297
|
// ../cli/src/lib/agent/launch.ts
|
|
45126
45298
|
import { spawn as spawn2 } from "node:child_process";
|
|
45127
|
-
import
|
|
45299
|
+
import fs35 from "node:fs";
|
|
45128
45300
|
import path38 from "node:path";
|
|
45129
45301
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
45130
45302
|
function boardArgs() {
|
|
@@ -45137,8 +45309,8 @@ function watcherEnv(env2 = process.env) {
|
|
|
45137
45309
|
}
|
|
45138
45310
|
function spawnWatcher(sessionId) {
|
|
45139
45311
|
if (!BUILT) return void 0;
|
|
45140
|
-
|
|
45141
|
-
const out =
|
|
45312
|
+
fs35.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
45313
|
+
const out = fs35.openSync(path38.join(SESSIONS_DIR, `${sessionId}.watch.log`), "a");
|
|
45142
45314
|
try {
|
|
45143
45315
|
const child = spawn2(process.execPath, [SELF, "__watch", sessionId, ...boardArgs()], {
|
|
45144
45316
|
cwd: REPO_ROOT,
|
|
@@ -45154,7 +45326,7 @@ function spawnWatcher(sessionId) {
|
|
|
45154
45326
|
return void 0;
|
|
45155
45327
|
} finally {
|
|
45156
45328
|
try {
|
|
45157
|
-
|
|
45329
|
+
fs35.closeSync(out);
|
|
45158
45330
|
} catch {
|
|
45159
45331
|
}
|
|
45160
45332
|
}
|
|
@@ -45171,11 +45343,11 @@ var init_launch = __esm({
|
|
|
45171
45343
|
});
|
|
45172
45344
|
|
|
45173
45345
|
// ../cli/src/lib/agent/command.ts
|
|
45174
|
-
import
|
|
45346
|
+
import fs36 from "node:fs";
|
|
45175
45347
|
import path39 from "node:path";
|
|
45176
45348
|
function selfCommand() {
|
|
45177
45349
|
const bin = path39.resolve(path39.dirname(SELF), "..", "bin", "ai4kanban.mjs");
|
|
45178
|
-
const file2 =
|
|
45350
|
+
const file2 = fs36.existsSync(bin) ? bin : SELF;
|
|
45179
45351
|
const inside2 = rel(file2);
|
|
45180
45352
|
const shortHop = !inside2.startsWith("..") && !path39.isAbsolute(inside2) && inside2.split(/[\\/]/).length <= 3;
|
|
45181
45353
|
return `node ${shortHop ? inside2 : file2}`;
|
|
@@ -45189,7 +45361,7 @@ function boardCommandFor(_cardId) {
|
|
|
45189
45361
|
}
|
|
45190
45362
|
function absoluteSelf() {
|
|
45191
45363
|
const bin = path39.resolve(path39.dirname(SELF), "..", "bin", "ai4kanban.mjs");
|
|
45192
|
-
return
|
|
45364
|
+
return fs36.existsSync(bin) ? bin : SELF;
|
|
45193
45365
|
}
|
|
45194
45366
|
function commandNote(command) {
|
|
45195
45367
|
if (command === "akb") return "";
|
|
@@ -45205,13 +45377,13 @@ var init_command = __esm({
|
|
|
45205
45377
|
});
|
|
45206
45378
|
|
|
45207
45379
|
// ../cli/src/lib/agent/outputs.ts
|
|
45208
|
-
import
|
|
45380
|
+
import fs37 from "node:fs";
|
|
45209
45381
|
import path40 from "node:path";
|
|
45210
45382
|
function cardBody(cardId2) {
|
|
45211
45383
|
const found2 = locate(cardId2) ?? locateArchived(cardId2);
|
|
45212
45384
|
if (!found2) return "";
|
|
45213
45385
|
try {
|
|
45214
|
-
return
|
|
45386
|
+
return fs37.readFileSync(found2.kind === "group" ? path40.join(found2.target, "root.md") : found2.target, "utf8");
|
|
45215
45387
|
} catch {
|
|
45216
45388
|
return "";
|
|
45217
45389
|
}
|
|
@@ -45245,20 +45417,20 @@ var init_outputs = __esm({
|
|
|
45245
45417
|
});
|
|
45246
45418
|
|
|
45247
45419
|
// ../cli/src/lib/agent/log.ts
|
|
45248
|
-
import
|
|
45420
|
+
import fs38 from "node:fs";
|
|
45249
45421
|
import path41 from "node:path";
|
|
45250
45422
|
function pruneLogs() {
|
|
45251
45423
|
try {
|
|
45252
|
-
const runs =
|
|
45424
|
+
const runs = fs38.readdirSync(SESSIONS_DIR).filter((f) => f.endsWith(".log") && !f.endsWith(".watch.log")).map((f) => ({ id: f.slice(0, -".log".length), t: fs38.statSync(path41.join(SESSIONS_DIR, f)).mtimeMs })).sort((a, b) => b.t - a.t);
|
|
45253
45425
|
const kept2 = new Set(runs.slice(0, KEEP_LOGS).map((r) => r.id));
|
|
45254
45426
|
const drop = new Set(runs.slice(KEEP_LOGS).map((r) => r.id));
|
|
45255
|
-
for (const f of
|
|
45427
|
+
for (const f of fs38.readdirSync(SESSIONS_DIR)) {
|
|
45256
45428
|
const dot = f.indexOf(".");
|
|
45257
45429
|
const id2 = dot === -1 ? f : f.slice(0, dot);
|
|
45258
45430
|
const stray = f.endsWith(".images") && !kept2.has(id2) && !drop.has(id2) && stale2(f);
|
|
45259
45431
|
if (!stray && !drop.has(id2)) continue;
|
|
45260
45432
|
try {
|
|
45261
|
-
|
|
45433
|
+
fs38.rmSync(path41.join(SESSIONS_DIR, f), { recursive: true, force: true });
|
|
45262
45434
|
} catch {
|
|
45263
45435
|
}
|
|
45264
45436
|
}
|
|
@@ -45267,7 +45439,7 @@ function pruneLogs() {
|
|
|
45267
45439
|
}
|
|
45268
45440
|
function stale2(name) {
|
|
45269
45441
|
try {
|
|
45270
|
-
return Date.now() -
|
|
45442
|
+
return Date.now() - fs38.statSync(path41.join(SESSIONS_DIR, name)).mtimeMs > STRAY_MS;
|
|
45271
45443
|
} catch {
|
|
45272
45444
|
return false;
|
|
45273
45445
|
}
|
|
@@ -45294,13 +45466,13 @@ function asContext(v) {
|
|
|
45294
45466
|
function readLogTail(logPath, maxBytes = TAIL_BYTES) {
|
|
45295
45467
|
let fd;
|
|
45296
45468
|
try {
|
|
45297
|
-
const size =
|
|
45469
|
+
const size = fs38.statSync(logPath).size;
|
|
45298
45470
|
const start = Math.max(0, size - maxBytes);
|
|
45299
45471
|
const len = size - start;
|
|
45300
45472
|
if (len === 0) return "";
|
|
45301
|
-
fd =
|
|
45473
|
+
fd = fs38.openSync(logPath, "r");
|
|
45302
45474
|
const buf = Buffer.alloc(len);
|
|
45303
|
-
|
|
45475
|
+
fs38.readSync(fd, buf, 0, len, start);
|
|
45304
45476
|
let text5 = buf.toString("utf8");
|
|
45305
45477
|
if (start > 0) {
|
|
45306
45478
|
const nl = text5.indexOf("\n");
|
|
@@ -45312,7 +45484,7 @@ function readLogTail(logPath, maxBytes = TAIL_BYTES) {
|
|
|
45312
45484
|
} finally {
|
|
45313
45485
|
if (fd !== void 0) {
|
|
45314
45486
|
try {
|
|
45315
|
-
|
|
45487
|
+
fs38.closeSync(fd);
|
|
45316
45488
|
} catch {
|
|
45317
45489
|
}
|
|
45318
45490
|
}
|
|
@@ -45403,7 +45575,7 @@ ${DURATION_MARKER} ${Math.max(0, ms)}
|
|
|
45403
45575
|
});
|
|
45404
45576
|
|
|
45405
45577
|
// ../cli/src/lib/agent/store.ts
|
|
45406
|
-
import
|
|
45578
|
+
import fs39 from "node:fs";
|
|
45407
45579
|
import path42 from "node:path";
|
|
45408
45580
|
function logPathIn(held4, sessionId) {
|
|
45409
45581
|
return typeof held4 === "string" && held4.startsWith(SESSIONS_DIR + path42.sep) ? held4 : logPathOf(sessionId);
|
|
@@ -45411,7 +45583,7 @@ function logPathIn(held4, sessionId) {
|
|
|
45411
45583
|
function parseStore() {
|
|
45412
45584
|
let data;
|
|
45413
45585
|
try {
|
|
45414
|
-
data = JSON.parse(
|
|
45586
|
+
data = JSON.parse(fs39.readFileSync(SESSIONS, "utf8"));
|
|
45415
45587
|
} catch {
|
|
45416
45588
|
return { runs: [], deliveries: [], marks: {} };
|
|
45417
45589
|
}
|
|
@@ -45445,7 +45617,8 @@ function parseStore() {
|
|
|
45445
45617
|
error: typeof entry.error === "string" ? entry.error : void 0,
|
|
45446
45618
|
failure: readFailure(entry.failure),
|
|
45447
45619
|
validationFailure: readFailure(entry.validationFailure),
|
|
45448
|
-
retryPause: entry.retryPause,
|
|
45620
|
+
retryPause: readRetryPause(entry.retryPause),
|
|
45621
|
+
retryHistory: readRetryHistory(entry.retryHistory),
|
|
45449
45622
|
blocker: readBlocker(entry.blocker),
|
|
45450
45623
|
// A run that never reported a cost shows none, rather than a zero it didn't earn.
|
|
45451
45624
|
costUsd: typeof entry.costUsd === "number" && entry.costUsd >= 0 ? entry.costUsd : void 0,
|
|
@@ -45765,16 +45938,16 @@ function writeStore(store) {
|
|
|
45765
45938
|
marks: store.marks,
|
|
45766
45939
|
...store.refined ? { refined: store.refined } : {}
|
|
45767
45940
|
};
|
|
45768
|
-
|
|
45941
|
+
fs39.mkdirSync(path42.dirname(SESSIONS), { recursive: true });
|
|
45769
45942
|
const tmp = `${SESSIONS}.tmp`;
|
|
45770
|
-
|
|
45771
|
-
|
|
45943
|
+
fs39.writeFileSync(tmp, JSON.stringify(kept2, null, 2) + "\n");
|
|
45944
|
+
fs39.renameSync(tmp, SESSIONS);
|
|
45772
45945
|
forgetFileMemos();
|
|
45773
45946
|
}
|
|
45774
45947
|
function prune(runs, deliveries) {
|
|
45775
45948
|
const held4 = new Set(deliveries.filter(holdsCheckout).map((d) => d.deliveryId));
|
|
45776
45949
|
const live = runs.filter((r) => r.status === "running");
|
|
45777
|
-
const finished = runs.filter((r) => r.status !== "running" && (
|
|
45950
|
+
const finished = runs.filter((r) => r.status !== "running" && (fs39.existsSync(r.logPath) || r.deliveryId && held4.has(r.deliveryId))).sort((a, b) => b.startedAt - a.startedAt).slice(0, KEEP_RUNS);
|
|
45778
45951
|
const spared = runs.filter(
|
|
45779
45952
|
(r) => r.status !== "running" && !finished.includes(r) && (!!r.discardedCards?.length || r.deliveryId && held4.has(r.deliveryId))
|
|
45780
45953
|
);
|
|
@@ -45871,11 +46044,11 @@ var init_store = __esm({
|
|
|
45871
46044
|
});
|
|
45872
46045
|
|
|
45873
46046
|
// ../cli/src/lib/agent/commit-mode.ts
|
|
45874
|
-
import
|
|
46047
|
+
import fs40 from "node:fs";
|
|
45875
46048
|
function recordedIds() {
|
|
45876
46049
|
try {
|
|
45877
46050
|
return new Set(
|
|
45878
|
-
|
|
46051
|
+
fs40.readdirSync(DELIVERIES).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -".json".length))
|
|
45879
46052
|
);
|
|
45880
46053
|
} catch {
|
|
45881
46054
|
return /* @__PURE__ */ new Set();
|
|
@@ -45908,7 +46081,7 @@ var init_commit_mode = __esm({
|
|
|
45908
46081
|
init_worktree();
|
|
45909
46082
|
ID_ALPHABET = "abcdefghjkmnpqrstuvwxyz23456789";
|
|
45910
46083
|
ID_LENGTH = 8;
|
|
45911
|
-
deliveryCwd = (delivery) => delivery.worktree &&
|
|
46084
|
+
deliveryCwd = (delivery) => delivery.worktree && fs40.existsSync(worktreeDir(delivery.worktree)) ? worktreeDir(delivery.worktree) : REPO_ROOT;
|
|
45912
46085
|
}
|
|
45913
46086
|
});
|
|
45914
46087
|
|
|
@@ -46002,12 +46175,12 @@ var init_runner = __esm({
|
|
|
46002
46175
|
});
|
|
46003
46176
|
|
|
46004
46177
|
// ../cli/src/lib/agent/rules.ts
|
|
46005
|
-
import
|
|
46178
|
+
import fs41 from "node:fs";
|
|
46006
46179
|
import path43 from "node:path";
|
|
46007
46180
|
function ruleFile(agent) {
|
|
46008
46181
|
if (!agent || hiddenRole(agent)) return "";
|
|
46009
46182
|
try {
|
|
46010
|
-
return
|
|
46183
|
+
return fs41.readFileSync(rulePath(agent), "utf8").trim();
|
|
46011
46184
|
} catch {
|
|
46012
46185
|
return "";
|
|
46013
46186
|
}
|
|
@@ -46072,7 +46245,7 @@ var init_rules2 = __esm({
|
|
|
46072
46245
|
});
|
|
46073
46246
|
|
|
46074
46247
|
// ../cli/src/lib/agent/deliveries.ts
|
|
46075
|
-
import
|
|
46248
|
+
import fs42 from "node:fs";
|
|
46076
46249
|
import path44 from "node:path";
|
|
46077
46250
|
function writeAudit(delivery, runs) {
|
|
46078
46251
|
const known2 = new Map(readAudit(delivery.deliveryId)?.sessions.map((s) => [s.sessionId, s]) ?? []);
|
|
@@ -46102,10 +46275,10 @@ function writeAudit(delivery, runs) {
|
|
|
46102
46275
|
}
|
|
46103
46276
|
function writeAuditFile(record2) {
|
|
46104
46277
|
try {
|
|
46105
|
-
|
|
46278
|
+
fs42.mkdirSync(DELIVERIES, { recursive: true });
|
|
46106
46279
|
const tmp = `${auditPath(record2.deliveryId)}.tmp`;
|
|
46107
|
-
|
|
46108
|
-
|
|
46280
|
+
fs42.writeFileSync(tmp, JSON.stringify(record2, null, 2) + "\n");
|
|
46281
|
+
fs42.renameSync(tmp, auditPath(record2.deliveryId));
|
|
46109
46282
|
return true;
|
|
46110
46283
|
} catch {
|
|
46111
46284
|
return false;
|
|
@@ -46113,7 +46286,7 @@ function writeAuditFile(record2) {
|
|
|
46113
46286
|
}
|
|
46114
46287
|
function readAudit(deliveryId) {
|
|
46115
46288
|
try {
|
|
46116
|
-
const data = JSON.parse(
|
|
46289
|
+
const data = JSON.parse(fs42.readFileSync(auditPath(deliveryId), "utf8"));
|
|
46117
46290
|
return { sessions: Array.isArray(data?.sessions) ? data.sessions : [] };
|
|
46118
46291
|
} catch {
|
|
46119
46292
|
return null;
|
|
@@ -46128,7 +46301,7 @@ function syncAudit(deliveryId, just) {
|
|
|
46128
46301
|
}
|
|
46129
46302
|
function wholeAudit(file2) {
|
|
46130
46303
|
try {
|
|
46131
|
-
const data = JSON.parse(
|
|
46304
|
+
const data = JSON.parse(fs42.readFileSync(file2, "utf8"));
|
|
46132
46305
|
return typeof data?.deliveryId === "string" && Array.isArray(data.sessions) ? data : null;
|
|
46133
46306
|
} catch {
|
|
46134
46307
|
return null;
|
|
@@ -46141,7 +46314,7 @@ function activeAudit(file2) {
|
|
|
46141
46314
|
function allAudits() {
|
|
46142
46315
|
let names2;
|
|
46143
46316
|
try {
|
|
46144
|
-
names2 =
|
|
46317
|
+
names2 = fs42.readdirSync(DELIVERIES);
|
|
46145
46318
|
} catch {
|
|
46146
46319
|
return [];
|
|
46147
46320
|
}
|
|
@@ -46270,7 +46443,7 @@ function resumeRecord(id2, execution) {
|
|
|
46270
46443
|
const found2 = namedDelivery(id2) ?? endedDelivery(id2);
|
|
46271
46444
|
if (!found2) return { ok: false, ...unknownDelivery(id2) };
|
|
46272
46445
|
const file2 = found2.cardId === null ? null : cardFile(found2.cardId);
|
|
46273
|
-
const restored = file2 && parseFrontmatter(
|
|
46446
|
+
const restored = file2 && parseFrontmatter(fs42.readFileSync(file2, "utf8")).meta?.restored;
|
|
46274
46447
|
if (restored && Date.parse(restored) > found2.startedAt) return { ok: false, ...unknownDelivery(id2) };
|
|
46275
46448
|
if (found2.status === "finished") return { ok: true, delivery: found2 };
|
|
46276
46449
|
const refused = resumeRefusal(found2);
|
|
@@ -46316,7 +46489,7 @@ function approvedRequirements(cardId2) {
|
|
|
46316
46489
|
const file2 = found2.kind === "group" ? path44.join(found2.target, "root.md") : found2.target;
|
|
46317
46490
|
let text5;
|
|
46318
46491
|
try {
|
|
46319
|
-
text5 =
|
|
46492
|
+
text5 = fs42.readFileSync(file2, "utf8");
|
|
46320
46493
|
} catch {
|
|
46321
46494
|
return "";
|
|
46322
46495
|
}
|
|
@@ -46327,7 +46500,7 @@ function cardMeta2(cardId2) {
|
|
|
46327
46500
|
const found2 = locate(cardId2);
|
|
46328
46501
|
if (!found2) return null;
|
|
46329
46502
|
const file2 = found2.kind === "group" ? path44.join(found2.target, "root.md") : found2.target;
|
|
46330
|
-
return parseFrontmatter(
|
|
46503
|
+
return parseFrontmatter(fs42.readFileSync(file2, "utf8")).meta;
|
|
46331
46504
|
} catch {
|
|
46332
46505
|
return null;
|
|
46333
46506
|
}
|
|
@@ -46485,7 +46658,7 @@ var init_deliveries = __esm({
|
|
|
46485
46658
|
activeAudits = () => allAudits().filter((a) => a.status === "active");
|
|
46486
46659
|
auditRow = (audit) => readDeliveryRow({ ...audit, sessions: audit.sessions.map((s) => s.sessionId) });
|
|
46487
46660
|
lastSessionRunning = (audit) => audit.sessions[audit.sessions.length - 1]?.status === "running";
|
|
46488
|
-
localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) => path44.resolve(REPO_ROOT, session.log) === logPathOf(session.sessionId) &&
|
|
46661
|
+
localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) => path44.resolve(REPO_ROOT, session.log) === logPathOf(session.sessionId) && fs42.existsSync(logPathOf(session.sessionId)));
|
|
46489
46662
|
unknownDelivery = (id2) => refusal("deliveryNotFound", `no delivery here answers to "${id2}"`, { id: id2 });
|
|
46490
46663
|
isResumable = (delivery) => !resumeRefusal(delivery);
|
|
46491
46664
|
cardStatus = (cardId2) => cardMeta2(cardId2)?.status || "todo";
|
|
@@ -46816,14 +46989,15 @@ function startableBinary(binary, harness, pinned2 = false) {
|
|
|
46816
46989
|
const note = brokenEntryNote(copy2, own2, harness);
|
|
46817
46990
|
return { binary: spawnName(copy2, own2), ...note ? { note } : {} };
|
|
46818
46991
|
}
|
|
46819
|
-
function readBlock2(harness, block, argv, runtimeId, secretRefs = {}) {
|
|
46992
|
+
function readBlock2(harness, block, argv, runtimeId, secretRefs = {}, executionSecrets) {
|
|
46820
46993
|
const values = {};
|
|
46821
46994
|
const ignored = [];
|
|
46822
46995
|
const secretsSet = [];
|
|
46823
|
-
const env2 = harness.settings.some((s) => s.kind === "secret") ? readEnvFile() : {};
|
|
46996
|
+
const env2 = !executionSecrets && harness.settings.some((s) => s.kind === "secret") ? readEnvFile() : {};
|
|
46824
46997
|
for (const setting of harness.settings) {
|
|
46825
46998
|
if (setting.kind === "secret") {
|
|
46826
|
-
|
|
46999
|
+
const value2 = executionSecrets ? executionSecrets[setting.key] : setting.env && env2[secretRefs[setting.env] ?? secretVar(setting.env, runtimeId)];
|
|
47000
|
+
if (value2) secretsSet.push(setting.key);
|
|
46827
47001
|
continue;
|
|
46828
47002
|
}
|
|
46829
47003
|
const value = block[setting.key]?.trim() ?? "";
|
|
@@ -46840,11 +47014,8 @@ function readBlock2(harness, block, argv, runtimeId, secretRefs = {}) {
|
|
|
46840
47014
|
}
|
|
46841
47015
|
function onOwnEndpoint(runtimeId) {
|
|
46842
47016
|
try {
|
|
46843
|
-
|
|
46844
|
-
|
|
46845
|
-
if (!runtime || !harness) return false;
|
|
46846
|
-
const { values, secretsSet } = readBlock2(harness, runtime.settings, [], runtime.id, runtime.secretRefs);
|
|
46847
|
-
return !!activeProviderOf({ harness, values, secretsSet })?.needs.includes("baseUrl");
|
|
47017
|
+
if (!runtimeId || !runRuntimeById(runtimeId)) return false;
|
|
47018
|
+
return !!activeProviderOf(resolveHarness({ pin: runtimeId }))?.needs.includes("baseUrl");
|
|
46848
47019
|
} catch {
|
|
46849
47020
|
return true;
|
|
46850
47021
|
}
|
|
@@ -46853,12 +47024,15 @@ function resolveHarness(ask2 = {}) {
|
|
|
46853
47024
|
const cfg = safeConfig();
|
|
46854
47025
|
const staleCommand = typeof cfg.command === "string" && cfg.command.trim() ? true : void 0;
|
|
46855
47026
|
const agent = ask2.agent ?? "";
|
|
46856
|
-
const
|
|
46857
|
-
const
|
|
47027
|
+
const execution = executionRuntimes();
|
|
47028
|
+
const scoped = execution && [execution.default, ...Object.values(execution.picks)];
|
|
47029
|
+
const list3 = scoped ?? readRuntimes(cfg);
|
|
46858
47030
|
const owner = agent ? runtimeOwner(agent) : "";
|
|
46859
|
-
const picked = owner ? runtimeOfAgent(owner,
|
|
47031
|
+
const picked = owner ? execution ? execution.picks[owner]?.id : runtimeOfAgent(owner, readAgentRuntime(cfg)) : void 0;
|
|
46860
47032
|
const asked = ask2.pin ?? picked;
|
|
46861
47033
|
const runtime = pickRuntime(list3, asked, ask2.harness);
|
|
47034
|
+
const credentialId = scoped?.find((row) => row === runtime)?.credentialId;
|
|
47035
|
+
const executionSecrets = execution && (credentialId ? readRuntimeCredentials(execution.credentialsFile)[credentialId] ?? {} : {});
|
|
46862
47036
|
const unknownAgentRuntime = picked && !ask2.pin && !list3.some((r) => r.id === picked || r.harness === picked) ? picked : void 0;
|
|
46863
47037
|
const known2 = harnessByName(runtime.harness);
|
|
46864
47038
|
const harness = known2 ?? DEFAULT_HARNESS;
|
|
@@ -46868,7 +47042,8 @@ function resolveHarness(ask2 = {}) {
|
|
|
46868
47042
|
runtime.settings,
|
|
46869
47043
|
splitCommand(command),
|
|
46870
47044
|
runtime.id,
|
|
46871
|
-
runtime.secretRefs
|
|
47045
|
+
runtime.secretRefs,
|
|
47046
|
+
executionSecrets
|
|
46872
47047
|
);
|
|
46873
47048
|
return {
|
|
46874
47049
|
runtime,
|
|
@@ -46879,6 +47054,7 @@ function resolveHarness(ask2 = {}) {
|
|
|
46879
47054
|
unknownAgentRuntime,
|
|
46880
47055
|
values,
|
|
46881
47056
|
secretsSet,
|
|
47057
|
+
executionSecrets,
|
|
46882
47058
|
ignored,
|
|
46883
47059
|
unknownName: known2 ? void 0 : runtime.harness || void 0,
|
|
46884
47060
|
staleCommand
|
|
@@ -46922,6 +47098,7 @@ function settingSaveError(key, value, ask2 = {}) {
|
|
|
46922
47098
|
}
|
|
46923
47099
|
function runEnv2(resolved, cwd = REPO_ROOT) {
|
|
46924
47100
|
const { harness, runtime } = resolved;
|
|
47101
|
+
if (resolved.executionSecrets) return settingEnv(harness, resolved, resolved.executionSecrets, cwd);
|
|
46925
47102
|
const file2 = readEnvFile();
|
|
46926
47103
|
const secrets = {};
|
|
46927
47104
|
for (const setting of harness.settings) {
|
|
@@ -46951,7 +47128,7 @@ function planResume(session, agent, own2 = {}) {
|
|
|
46951
47128
|
if (!harnessByName(harnessName)) return null;
|
|
46952
47129
|
const resolved = resolveHarness({ agent, ...own2, harness: harnessName });
|
|
46953
47130
|
const { harness, command, runtime } = resolved;
|
|
46954
|
-
if (!harness.resumes) return null;
|
|
47131
|
+
if (!harness.resumes || resolved.executionSecrets && !runtime.id) return null;
|
|
46955
47132
|
const argv = splitCommand(command);
|
|
46956
47133
|
return {
|
|
46957
47134
|
harness: harness.name,
|
|
@@ -46970,7 +47147,7 @@ function planFork(session, agent, own2 = {}, sessionId = randomUUID5()) {
|
|
|
46970
47147
|
if (!harnessByName(harnessName)) return null;
|
|
46971
47148
|
const resolved = resolveHarness({ agent, ...own2, harness: harnessName });
|
|
46972
47149
|
const { harness, command, runtime } = resolved;
|
|
46973
|
-
if (!harness.forkArgs || harness.name !== harnessName) return null;
|
|
47150
|
+
if (!harness.forkArgs || harness.name !== harnessName || resolved.executionSecrets && !runtime.id) return null;
|
|
46974
47151
|
const argv = splitCommand(command);
|
|
46975
47152
|
return {
|
|
46976
47153
|
harness: harness.name,
|
|
@@ -47198,31 +47375,31 @@ var init_resolve = __esm({
|
|
|
47198
47375
|
});
|
|
47199
47376
|
|
|
47200
47377
|
// ../cli/src/lib/agent/pictures.ts
|
|
47201
|
-
import
|
|
47378
|
+
import fs43 from "node:fs";
|
|
47202
47379
|
import path46 from "node:path";
|
|
47203
47380
|
function claimRunPictures(box, sessionId, names2 = []) {
|
|
47204
47381
|
if (!box || !freeBox(box) || names2.length === 0) return [];
|
|
47205
47382
|
const from = pictureBox(box);
|
|
47206
47383
|
const to = pictureBox(sessionId);
|
|
47207
47384
|
try {
|
|
47208
|
-
|
|
47209
|
-
|
|
47385
|
+
fs43.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
47386
|
+
fs43.renameSync(from, to);
|
|
47210
47387
|
} catch {
|
|
47211
47388
|
return [];
|
|
47212
47389
|
}
|
|
47213
|
-
return names2.filter(pictureName).map((name) => path46.join(to, name)).filter((file2) =>
|
|
47390
|
+
return names2.filter(pictureName).map((name) => path46.join(to, name)).filter((file2) => fs43.existsSync(file2));
|
|
47214
47391
|
}
|
|
47215
47392
|
function returnRunPictures(sessionId, box) {
|
|
47216
47393
|
if (!box || !boxId(box)) return;
|
|
47217
47394
|
try {
|
|
47218
|
-
|
|
47395
|
+
fs43.renameSync(pictureBox(sessionId), pictureBox(box));
|
|
47219
47396
|
} catch {
|
|
47220
47397
|
}
|
|
47221
47398
|
}
|
|
47222
47399
|
function moveRunPictures(from, to, files = []) {
|
|
47223
47400
|
if (files.length === 0) return [];
|
|
47224
47401
|
try {
|
|
47225
|
-
|
|
47402
|
+
fs43.renameSync(pictureBox(from), pictureBox(to));
|
|
47226
47403
|
} catch {
|
|
47227
47404
|
return files;
|
|
47228
47405
|
}
|
|
@@ -47235,7 +47412,7 @@ var init_pictures = __esm({
|
|
|
47235
47412
|
init_paths();
|
|
47236
47413
|
pictureName = (name) => /^[0-9a-f-]{36}\.[a-z0-9]{2,5}$/.test(name);
|
|
47237
47414
|
boxId = (box) => /^[0-9a-f-]{36}$/.test(box);
|
|
47238
|
-
freeBox = (box) => boxId(box) && !
|
|
47415
|
+
freeBox = (box) => boxId(box) && !fs43.existsSync(path46.join(SESSIONS_DIR, `${box}.log`));
|
|
47239
47416
|
pictureBox = (box) => path46.join(SESSIONS_DIR, `${box}.images`);
|
|
47240
47417
|
}
|
|
47241
47418
|
});
|
|
@@ -47337,7 +47514,7 @@ var init_facts = __esm({
|
|
|
47337
47514
|
});
|
|
47338
47515
|
|
|
47339
47516
|
// ../cli/src/lib/view/archive.ts
|
|
47340
|
-
import
|
|
47517
|
+
import fs44 from "node:fs";
|
|
47341
47518
|
import path47 from "node:path";
|
|
47342
47519
|
function archivedId(file2) {
|
|
47343
47520
|
const own2 = idPrefix(path47.basename(file2));
|
|
@@ -47346,7 +47523,7 @@ function archivedId(file2) {
|
|
|
47346
47523
|
function readFile(file2) {
|
|
47347
47524
|
const id2 = archivedId(file2);
|
|
47348
47525
|
if (id2 === null) return null;
|
|
47349
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
47526
|
+
const { meta: meta3, body } = parseFrontmatter(fs44.readFileSync(file2, "utf8"));
|
|
47350
47527
|
if (!meta3) return null;
|
|
47351
47528
|
return {
|
|
47352
47529
|
row: {
|
|
@@ -47362,7 +47539,7 @@ function readFile(file2) {
|
|
|
47362
47539
|
}
|
|
47363
47540
|
function readArchive() {
|
|
47364
47541
|
const relPath = rel(ARCHIVE).split(path47.sep).join("/");
|
|
47365
|
-
if (!
|
|
47542
|
+
if (!fs44.existsSync(ARCHIVE)) return { relPath, cards: [] };
|
|
47366
47543
|
const cards = walkMd(ARCHIVE).map(readFile).filter((found2) => found2 !== null).map((found2) => found2.row);
|
|
47367
47544
|
cards.sort((a, b) => b.id - a.id);
|
|
47368
47545
|
return { relPath, cards };
|
|
@@ -47717,16 +47894,16 @@ var init_prompts = __esm({
|
|
|
47717
47894
|
|
|
47718
47895
|
// ../cli/src/lib/agent/stop.ts
|
|
47719
47896
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
47720
|
-
import
|
|
47897
|
+
import fs45 from "node:fs";
|
|
47721
47898
|
function markedInProc(entry, strict = false, since) {
|
|
47722
47899
|
const pids = [];
|
|
47723
|
-
for (const name of
|
|
47900
|
+
for (const name of fs45.readdirSync("/proc")) {
|
|
47724
47901
|
if (!/^\d+$/.test(name)) continue;
|
|
47725
47902
|
try {
|
|
47726
|
-
if (
|
|
47903
|
+
if (fs45.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
|
|
47727
47904
|
} catch (error62) {
|
|
47728
47905
|
if (strict && !["ENOENT", "ESRCH"].includes(error62.code ?? "")) {
|
|
47729
|
-
const stat =
|
|
47906
|
+
const stat = fs45.statSync(`/proc/${name}`, { throwIfNoEntry: false });
|
|
47730
47907
|
if (stat?.uid === process.getuid?.() && !startedBefore(Number(name), since)) throw error62;
|
|
47731
47908
|
}
|
|
47732
47909
|
}
|
|
@@ -47936,7 +48113,7 @@ var init_creation_lock = __esm({
|
|
|
47936
48113
|
|
|
47937
48114
|
// ../cli/src/lib/agent/sessions.ts
|
|
47938
48115
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
47939
|
-
import
|
|
48116
|
+
import fs46 from "node:fs";
|
|
47940
48117
|
import path50 from "node:path";
|
|
47941
48118
|
function reap(runs, reaped = [], restore = []) {
|
|
47942
48119
|
let changed = false;
|
|
@@ -47963,7 +48140,7 @@ function reap(runs, reaped = [], restore = []) {
|
|
|
47963
48140
|
}
|
|
47964
48141
|
function stampDuration(run3, endedAt) {
|
|
47965
48142
|
try {
|
|
47966
|
-
|
|
48143
|
+
fs46.appendFileSync(run3.logPath, durationLine(endedAt - run3.startedAt));
|
|
47967
48144
|
} catch {
|
|
47968
48145
|
}
|
|
47969
48146
|
}
|
|
@@ -47977,7 +48154,7 @@ function cardNow(cardId2) {
|
|
|
47977
48154
|
try {
|
|
47978
48155
|
const file2 = cardFile(cardId2);
|
|
47979
48156
|
if (!file2) return null;
|
|
47980
|
-
const { meta: meta3 } = parseFrontmatter(
|
|
48157
|
+
const { meta: meta3 } = parseFrontmatter(fs46.readFileSync(file2, "utf8"));
|
|
47981
48158
|
if (!meta3) return null;
|
|
47982
48159
|
return { status: meta3.status || "todo", questions: meta3.questions.length, title: meta3.title };
|
|
47983
48160
|
} catch {
|
|
@@ -48222,7 +48399,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID6(), said2) {
|
|
|
48222
48399
|
if (retired) return retired;
|
|
48223
48400
|
if (req.deliveryId && findDelivery(req.deliveryId)?.scheduled) return retiredStudioRun("scheduled");
|
|
48224
48401
|
const cardId2 = Number.isInteger(req.id) ? req.id : null;
|
|
48225
|
-
if (req.runtime && !
|
|
48402
|
+
if (req.runtime && !runRuntimeById(req.runtime)) {
|
|
48226
48403
|
const runtimes = readRuntimes().map((r) => r.id).join(", ");
|
|
48227
48404
|
return refusal("runtimeNotFound", `this board has no runtime called "${req.runtime}". It has: ${runtimes}.`, {
|
|
48228
48405
|
id: req.runtime,
|
|
@@ -48245,7 +48422,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID6(), said2) {
|
|
|
48245
48422
|
const parent = req.action === "sub" && req.parentId ? peekRun(req.parentId) : void 0;
|
|
48246
48423
|
const cwd = parent?.cwd ?? deliveryCwd(start ?? joining ?? {});
|
|
48247
48424
|
const plan = said2 ? { ...said2.plan(cwd, sessionId), note: null } : planRun(sessionId, cwd, agentForRun(req), req.runtime ? { pin: req.runtime } : {});
|
|
48248
|
-
const away = plan.runtime ?
|
|
48425
|
+
const away = plan.runtime ? runRuntimeById(plan.runtime)?.away : void 0;
|
|
48249
48426
|
if (away) return refusal("runtimeAway", away, { id: plan.runtime });
|
|
48250
48427
|
if (plan.note) notes = [...notes, plan.note];
|
|
48251
48428
|
const record2 = {
|
|
@@ -48316,7 +48493,16 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID6(), said2) {
|
|
|
48316
48493
|
}
|
|
48317
48494
|
function planningSession(cardId2, cwd = REPO_ROOT) {
|
|
48318
48495
|
const here = (dir) => !dir || path50.resolve(dir) === cwd;
|
|
48319
|
-
const
|
|
48496
|
+
const safeToContinue = (r) => {
|
|
48497
|
+
if (r.status === "done") return true;
|
|
48498
|
+
if (r.status !== "stopped" && r.status !== "error" && r.status !== "interrupted") return false;
|
|
48499
|
+
if (r.pendingWrites || r.cleanup?.status === "unconfirmed") return false;
|
|
48500
|
+
if (isSessionMissingFailure(r.failure)) return false;
|
|
48501
|
+
const root2 = r.agentPid ? { pid: r.agentPid, since: r.agentStartedAt ?? r.startedAt, identity: r.agentIdentity } : void 0;
|
|
48502
|
+
const stopped2 = r.managedProcess ? connectionStopped(root2) : processesStopped(runMark(r.sessionId, r.agentStartedAt ?? r.startedAt), root2);
|
|
48503
|
+
return stopped2;
|
|
48504
|
+
};
|
|
48505
|
+
const planned = readRuns().filter((r) => r.status !== "running" && r.cardId === cardId2 && PLANNING.has(r.action)).sort((a, b) => b.startedAt - a.startedAt).find((r) => safeToContinue(r) && !!resumeSessionId(r));
|
|
48320
48506
|
if (!planned) return { none: "unrecorded" };
|
|
48321
48507
|
if (!here(planned.cwd)) return { none: "elsewhere" };
|
|
48322
48508
|
const resumeId = resumeSessionId(planned);
|
|
@@ -48404,14 +48590,15 @@ async function openResume(id2, options) {
|
|
|
48404
48590
|
const automatic = typeof options === "object" && options.automatic === true;
|
|
48405
48591
|
const pending = !forced && prev.status !== "stopped" ? prev.retry?.pending : void 0;
|
|
48406
48592
|
if (automatic && !pending) return refusal("runContinued", "The automatic retry is no longer pending.");
|
|
48407
|
-
const
|
|
48593
|
+
const resetReplay = pending?.sessionAction === "reset_replay";
|
|
48594
|
+
const session = forced || resetReplay ? void 0 : resumeSessionId(prev);
|
|
48408
48595
|
if (pending || requireSession) {
|
|
48409
48596
|
const root2 = prev.agentPid ? { pid: prev.agentPid, since: prev.agentStartedAt ?? prev.startedAt, identity: prev.agentIdentity } : void 0;
|
|
48410
48597
|
const stopped2 = prev.managedProcess ? connectionStopped(root2) : processesStopped(runMark(prev.sessionId, prev.agentStartedAt), root2);
|
|
48411
48598
|
const recovery = agentRecovery({
|
|
48412
48599
|
stopped: stopped2,
|
|
48413
48600
|
session,
|
|
48414
|
-
replayable: !requireSession && neverStarted(prev),
|
|
48601
|
+
replayable: !requireSession && (neverStarted(prev) || resetReplay),
|
|
48415
48602
|
unconfirmedCleanup: prev.pendingWrites || prev.cleanup?.status === "unconfirmed" || prev.managedProcess && (pending?.failure ?? prev.failure)?.code === "idle_timeout" && !idleStopConfirmed(prev.cleanup, session)
|
|
48416
48603
|
});
|
|
48417
48604
|
if (recovery === "unsafe") {
|
|
@@ -48426,10 +48613,10 @@ async function openResume(id2, options) {
|
|
|
48426
48613
|
const sessionId = randomUUID6();
|
|
48427
48614
|
let plan;
|
|
48428
48615
|
let fresh;
|
|
48429
|
-
if (!forced && prev.harness === "antigravity" && !session && !neverStarted(prev)) {
|
|
48616
|
+
if (!forced && !resetReplay && prev.harness === "antigravity" && !session && !neverStarted(prev)) {
|
|
48430
48617
|
return refusal("runNoSession", "Antigravity did not record a conversation ID before interruption. The original session cannot be resumed.");
|
|
48431
48618
|
}
|
|
48432
|
-
if (!session && !forced && prev.cardId !== null && !neverStarted(prev)) return refusal("runNoSession", "The original session is unavailable. Explicitly take over the saved task in a new session.");
|
|
48619
|
+
if (!session && !forced && !resetReplay && prev.cardId !== null && !neverStarted(prev)) return refusal("runNoSession", "The original session is unavailable. Explicitly take over the saved task in a new session.");
|
|
48433
48620
|
if (session) {
|
|
48434
48621
|
plan = planResume({ harness: prev.harness, resumeId: session, cwd }, prev.agent, prev.runtime ? { pin: prev.runtime } : {});
|
|
48435
48622
|
} else {
|
|
@@ -48450,12 +48637,12 @@ async function openResume(id2, options) {
|
|
|
48450
48637
|
if ("error" in opened) return opened;
|
|
48451
48638
|
if (!opened.spec.prompt && buildResume) opened.spec.prompt = buildResume;
|
|
48452
48639
|
if (build?.notes?.trim()) opened.spec.prompt = [opened.spec.prompt || resumePrompt(prev.deliveryId, prev.action), build.notes.trim()].join("\n\n");
|
|
48453
|
-
if (session &&
|
|
48640
|
+
if (session && requireSession && !pending) opened.spec.prompt = [recoveryPrompt, opened.spec.prompt].filter(Boolean).join("\n\n");
|
|
48454
48641
|
if (build || buildResume || pending || requireSession) writeSpec(opened.spec);
|
|
48455
48642
|
return opened;
|
|
48456
48643
|
}
|
|
48457
48644
|
async function planRetry2(prev, ask2, sessionId, cwd) {
|
|
48458
|
-
const runtime = prev.runtime &&
|
|
48645
|
+
const runtime = prev.runtime && runRuntimeById(prev.runtime) ? prev.runtime : void 0;
|
|
48459
48646
|
const { note, ...plan } = planRun(sessionId, cwd, prev.agent ?? agentForRun(ask2), {
|
|
48460
48647
|
...runtime ? { pin: runtime } : {},
|
|
48461
48648
|
...shipsHarness(prev.harness) ? { harness: prev.harness } : {}
|
|
@@ -48505,6 +48692,7 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh, automatic = fa
|
|
|
48505
48692
|
},
|
|
48506
48693
|
failure: automatic ? prev.retry?.pending?.failure : void 0,
|
|
48507
48694
|
retry: prev.retry ? { ...prev.retry, pending: void 0, launching: automatic ? true : void 0 } : void 0,
|
|
48695
|
+
...prev.retryHistory?.length ? { retryHistory: prev.retryHistory } : {},
|
|
48508
48696
|
logPath: logPathOf(sessionId),
|
|
48509
48697
|
specAgent: prev.specAgent,
|
|
48510
48698
|
cards: prev.cards,
|
|
@@ -48569,14 +48757,14 @@ function askForRefine(sessionId, ask2) {
|
|
|
48569
48757
|
}
|
|
48570
48758
|
function clearAsks(sessionId) {
|
|
48571
48759
|
try {
|
|
48572
|
-
|
|
48760
|
+
fs46.unlinkSync(asksPathOf(sessionId));
|
|
48573
48761
|
} catch {
|
|
48574
48762
|
}
|
|
48575
48763
|
}
|
|
48576
48764
|
function readAsks(sessionId) {
|
|
48577
48765
|
let data;
|
|
48578
48766
|
try {
|
|
48579
|
-
data = JSON.parse(
|
|
48767
|
+
data = JSON.parse(fs46.readFileSync(asksPathOf(sessionId), "utf8"));
|
|
48580
48768
|
} catch {
|
|
48581
48769
|
return { refines: [] };
|
|
48582
48770
|
}
|
|
@@ -48593,10 +48781,10 @@ function readAsks(sessionId) {
|
|
|
48593
48781
|
return { refines: refines.filter((a) => !discarded.has(a.cardId)) };
|
|
48594
48782
|
}
|
|
48595
48783
|
function writeAsks(sessionId, file2) {
|
|
48596
|
-
|
|
48784
|
+
fs46.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
48597
48785
|
const tmp = `${asksPathOf(sessionId)}.tmp`;
|
|
48598
|
-
|
|
48599
|
-
|
|
48786
|
+
fs46.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n");
|
|
48787
|
+
fs46.renameSync(tmp, asksPathOf(sessionId));
|
|
48600
48788
|
}
|
|
48601
48789
|
function markSpawned(sessionId, pid) {
|
|
48602
48790
|
patch(sessionId, (r) => {
|
|
@@ -48623,6 +48811,7 @@ async function closeRun(sessionId, res) {
|
|
|
48623
48811
|
if (res.error) run3.error = res.error;
|
|
48624
48812
|
run3.failure = res.failure;
|
|
48625
48813
|
run3.retryPause = res.retryPause;
|
|
48814
|
+
if (res.retryHistory?.length) run3.retryHistory = res.retryHistory;
|
|
48626
48815
|
if (run3.retry) {
|
|
48627
48816
|
delete run3.retry.launching;
|
|
48628
48817
|
if (res.status === "stopped") delete run3.retry.pending;
|
|
@@ -48751,7 +48940,7 @@ async function reconcileCardDelivery(cardId2) {
|
|
|
48751
48940
|
result = withStore((store) => {
|
|
48752
48941
|
reap(store.runs, reaped, restore);
|
|
48753
48942
|
const file2 = cardFile(cardId2);
|
|
48754
|
-
const restoredRaw = file2 ? parseFrontmatter(
|
|
48943
|
+
const restoredRaw = file2 ? parseFrontmatter(fs46.readFileSync(file2, "utf8")).meta?.restored : void 0;
|
|
48755
48944
|
const restoredAt = restoredRaw ? Date.parse(restoredRaw) : Number.NaN;
|
|
48756
48945
|
const merged = /* @__PURE__ */ new Map();
|
|
48757
48946
|
for (const audit of cardAudits(cardId2)) merged.set(audit.deliveryId, audit);
|
|
@@ -48879,12 +49068,12 @@ async function resumeDelivery(id2) {
|
|
|
48879
49068
|
return { ok: true, deliveryId: delivery.deliveryId, carryOn };
|
|
48880
49069
|
}
|
|
48881
49070
|
function writeSpec(spec) {
|
|
48882
|
-
|
|
48883
|
-
|
|
49071
|
+
fs46.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
49072
|
+
fs46.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
|
|
48884
49073
|
}
|
|
48885
49074
|
function readSpec(sessionId) {
|
|
48886
49075
|
try {
|
|
48887
|
-
const spec = JSON.parse(
|
|
49076
|
+
const spec = JSON.parse(fs46.readFileSync(specPathOf(sessionId), "utf8"));
|
|
48888
49077
|
return spec && Array.isArray(spec.plan?.argv) ? spec : null;
|
|
48889
49078
|
} catch {
|
|
48890
49079
|
return null;
|
|
@@ -48892,7 +49081,7 @@ function readSpec(sessionId) {
|
|
|
48892
49081
|
}
|
|
48893
49082
|
function dropSpec(sessionId) {
|
|
48894
49083
|
try {
|
|
48895
|
-
|
|
49084
|
+
fs46.unlinkSync(specPathOf(sessionId));
|
|
48896
49085
|
} catch {
|
|
48897
49086
|
}
|
|
48898
49087
|
}
|
|
@@ -48902,18 +49091,18 @@ async function acquireIndexLock(giveUp) {
|
|
|
48902
49091
|
for (; ; ) {
|
|
48903
49092
|
if (giveUp()) return null;
|
|
48904
49093
|
try {
|
|
48905
|
-
|
|
48906
|
-
|
|
48907
|
-
return () =>
|
|
49094
|
+
fs46.mkdirSync(INDEX_LOCK2, { recursive: false });
|
|
49095
|
+
fs46.writeFileSync(holder, String(process.pid));
|
|
49096
|
+
return () => fs46.rmSync(INDEX_LOCK2, { recursive: true, force: true });
|
|
48908
49097
|
} catch (err) {
|
|
48909
49098
|
const code = err.code;
|
|
48910
49099
|
if (code === "ENOENT") {
|
|
48911
|
-
|
|
49100
|
+
fs46.mkdirSync(path50.dirname(INDEX_LOCK2), { recursive: true });
|
|
48912
49101
|
continue;
|
|
48913
49102
|
}
|
|
48914
49103
|
if (code !== "EEXIST") throw err;
|
|
48915
49104
|
if (!pidAlive(Number(readHolder(holder)))) {
|
|
48916
|
-
|
|
49105
|
+
fs46.rmSync(INDEX_LOCK2, { recursive: true, force: true });
|
|
48917
49106
|
continue;
|
|
48918
49107
|
}
|
|
48919
49108
|
if (Date.now() > until) return null;
|
|
@@ -48923,7 +49112,7 @@ async function acquireIndexLock(giveUp) {
|
|
|
48923
49112
|
}
|
|
48924
49113
|
function readHolder(file2) {
|
|
48925
49114
|
try {
|
|
48926
|
-
return
|
|
49115
|
+
return fs46.readFileSync(file2, "utf8").trim();
|
|
48927
49116
|
} catch {
|
|
48928
49117
|
return String(process.pid);
|
|
48929
49118
|
}
|
|
@@ -49062,7 +49251,7 @@ var init_sources = __esm({
|
|
|
49062
49251
|
});
|
|
49063
49252
|
|
|
49064
49253
|
// ../cli/src/lib/signals/inbox.ts
|
|
49065
|
-
import
|
|
49254
|
+
import fs47 from "node:fs";
|
|
49066
49255
|
import path51 from "node:path";
|
|
49067
49256
|
function metaPair(key, value) {
|
|
49068
49257
|
const name = typeof key === "string" ? key.trim() : "";
|
|
@@ -49094,7 +49283,7 @@ ${signal2.summary.trim()}
|
|
|
49094
49283
|
function parse3(file2, lenient = false) {
|
|
49095
49284
|
let text5;
|
|
49096
49285
|
try {
|
|
49097
|
-
text5 =
|
|
49286
|
+
text5 = fs47.readFileSync(file2, "utf8");
|
|
49098
49287
|
} catch {
|
|
49099
49288
|
return null;
|
|
49100
49289
|
}
|
|
@@ -49149,13 +49338,13 @@ function freeName(dir, wanted) {
|
|
|
49149
49338
|
const ext = path51.extname(wanted);
|
|
49150
49339
|
const stem = wanted.slice(0, wanted.length - ext.length);
|
|
49151
49340
|
let name = wanted;
|
|
49152
|
-
for (let n = 2;
|
|
49341
|
+
for (let n = 2; fs47.existsSync(path51.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
|
|
49153
49342
|
return name;
|
|
49154
49343
|
}
|
|
49155
49344
|
function readFolder(dir, lenient = false) {
|
|
49156
49345
|
let entries2;
|
|
49157
49346
|
try {
|
|
49158
|
-
entries2 =
|
|
49347
|
+
entries2 = fs47.readdirSync(dir, { withFileTypes: true });
|
|
49159
49348
|
} catch {
|
|
49160
49349
|
return [];
|
|
49161
49350
|
}
|
|
@@ -49167,7 +49356,7 @@ function readInbox() {
|
|
|
49167
49356
|
return signals;
|
|
49168
49357
|
}
|
|
49169
49358
|
function writeSignal(incoming, importedAt, slug = "") {
|
|
49170
|
-
|
|
49359
|
+
fs47.mkdirSync(TRIAGE, { recursive: true });
|
|
49171
49360
|
const signal2 = {
|
|
49172
49361
|
...incoming,
|
|
49173
49362
|
importedAt,
|
|
@@ -49180,11 +49369,11 @@ function writeSignal(incoming, importedAt, slug = "") {
|
|
|
49180
49369
|
relPath: ""
|
|
49181
49370
|
};
|
|
49182
49371
|
const file2 = path51.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug)));
|
|
49183
|
-
|
|
49372
|
+
fs47.writeFileSync(file2, serialize({ ...signal2, relPath: boardRel(file2) }));
|
|
49184
49373
|
return { ...signal2, relPath: boardRel(file2) };
|
|
49185
49374
|
}
|
|
49186
49375
|
function stamp3(file2, fields2) {
|
|
49187
|
-
const text5 =
|
|
49376
|
+
const text5 = fs47.readFileSync(file2, "utf8");
|
|
49188
49377
|
const lines = text5.split("\n");
|
|
49189
49378
|
const close = lines.indexOf("---", 1);
|
|
49190
49379
|
if (close < 0) return;
|
|
@@ -49193,13 +49382,13 @@ function stamp3(file2, fields2) {
|
|
|
49193
49382
|
return !key || fields2[key[1]] === void 0;
|
|
49194
49383
|
});
|
|
49195
49384
|
const added = Object.entries(fields2).flatMap(([key, value]) => value === null ? [] : [`${key}: ${yamlScalar(value)}`]);
|
|
49196
|
-
|
|
49385
|
+
fs47.writeFileSync(file2, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
|
|
49197
49386
|
}
|
|
49198
49387
|
function moveSignal(from, into, fields2) {
|
|
49199
|
-
if (!
|
|
49200
|
-
|
|
49388
|
+
if (!fs47.existsSync(from)) return "";
|
|
49389
|
+
fs47.mkdirSync(into, { recursive: true });
|
|
49201
49390
|
const at = path51.join(into, freeName(into, path51.basename(from)));
|
|
49202
|
-
|
|
49391
|
+
fs47.renameSync(from, at);
|
|
49203
49392
|
stamp3(at, fields2);
|
|
49204
49393
|
return boardRel(at);
|
|
49205
49394
|
}
|
|
@@ -49447,12 +49636,12 @@ var init_studio_cards = __esm({
|
|
|
49447
49636
|
});
|
|
49448
49637
|
|
|
49449
49638
|
// ../cli/src/lib/readme.ts
|
|
49450
|
-
import
|
|
49639
|
+
import fs48 from "node:fs";
|
|
49451
49640
|
import path52 from "node:path";
|
|
49452
49641
|
function stripReadmeRefs(target) {
|
|
49453
|
-
if (!
|
|
49642
|
+
if (!fs48.existsSync(README)) return [];
|
|
49454
49643
|
const needle = target.kind === "group" ? `](${target.rel}/` : `](${target.rel})`;
|
|
49455
|
-
const lines =
|
|
49644
|
+
const lines = fs48.readFileSync(README, "utf8").split("\n");
|
|
49456
49645
|
const out = [];
|
|
49457
49646
|
const removed = [];
|
|
49458
49647
|
let i = 0;
|
|
@@ -49474,20 +49663,20 @@ function stripReadmeRefs(target) {
|
|
|
49474
49663
|
out.push(line);
|
|
49475
49664
|
i++;
|
|
49476
49665
|
}
|
|
49477
|
-
if (removed.length)
|
|
49666
|
+
if (removed.length) fs48.writeFileSync(README, out.join("\n"));
|
|
49478
49667
|
return removed;
|
|
49479
49668
|
}
|
|
49480
49669
|
function addReadmeRef(id2, title, relPath) {
|
|
49481
|
-
if (!
|
|
49670
|
+
if (!fs48.existsSync(README)) return false;
|
|
49482
49671
|
const link2 = relPath.split(path52.sep).join("/");
|
|
49483
49672
|
const bullet = `- [#${id2} ${title}](${link2})`;
|
|
49484
49673
|
const heading = `## ${TASKS_HEADING}`;
|
|
49485
|
-
let lines =
|
|
49674
|
+
let lines = fs48.readFileSync(README, "utf8").split("\n");
|
|
49486
49675
|
const hi = lines.findIndex((l) => l.trim().toLowerCase() === heading.toLowerCase());
|
|
49487
49676
|
if (hi === -1) {
|
|
49488
49677
|
while (lines.length && lines[lines.length - 1].trim() === "") lines.pop();
|
|
49489
49678
|
lines.push("", heading, "", bullet);
|
|
49490
|
-
|
|
49679
|
+
fs48.writeFileSync(README, lines.join("\n") + "\n");
|
|
49491
49680
|
return true;
|
|
49492
49681
|
}
|
|
49493
49682
|
let end2 = hi + 1;
|
|
@@ -49501,15 +49690,15 @@ function addReadmeRef(id2, title, relPath) {
|
|
|
49501
49690
|
const at = lastBullet !== -1 ? lastBullet + 1 : lines[hi + 1] === "" ? hi + 2 : hi + 1;
|
|
49502
49691
|
lines.splice(at, 0, bullet);
|
|
49503
49692
|
}
|
|
49504
|
-
|
|
49693
|
+
fs48.writeFileSync(README, lines.join("\n"));
|
|
49505
49694
|
return true;
|
|
49506
49695
|
}
|
|
49507
49696
|
function repointReadmeLink(id2, oldRel, newRel, title) {
|
|
49508
|
-
if (!
|
|
49697
|
+
if (!fs48.existsSync(README)) return false;
|
|
49509
49698
|
const oldLink = oldRel.split(path52.sep).join("/");
|
|
49510
49699
|
const newLink = newRel.split(path52.sep).join("/");
|
|
49511
49700
|
const linkRe = new RegExp(`\\[#${id2}\\b[^\\]]*\\]\\(${escapeRegex2(oldLink)}\\)`);
|
|
49512
|
-
const lines =
|
|
49701
|
+
const lines = fs48.readFileSync(README, "utf8").split("\n");
|
|
49513
49702
|
let changed = false;
|
|
49514
49703
|
for (let i = 0; i < lines.length; i++) {
|
|
49515
49704
|
if (!lines[i].includes(`](${oldLink})`)) continue;
|
|
@@ -49519,7 +49708,7 @@ function repointReadmeLink(id2, oldRel, newRel, title) {
|
|
|
49519
49708
|
changed = true;
|
|
49520
49709
|
}
|
|
49521
49710
|
}
|
|
49522
|
-
if (changed)
|
|
49711
|
+
if (changed) fs48.writeFileSync(README, lines.join("\n"));
|
|
49523
49712
|
return changed;
|
|
49524
49713
|
}
|
|
49525
49714
|
var isTableRow, isBulletStart, bulletIndent, TASKS_HEADING, escapeRegex2;
|
|
@@ -50195,16 +50384,16 @@ var init_collect = __esm({
|
|
|
50195
50384
|
});
|
|
50196
50385
|
|
|
50197
50386
|
// ../cli/src/lib/dress-page.ts
|
|
50198
|
-
import
|
|
50387
|
+
import fs49 from "node:fs";
|
|
50199
50388
|
import path53 from "node:path";
|
|
50200
50389
|
function dressPage(file2) {
|
|
50201
50390
|
const folder2 = path53.dirname(file2);
|
|
50202
|
-
const html =
|
|
50391
|
+
const html = fs49.readFileSync(file2, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
|
|
50203
50392
|
const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
|
|
50204
50393
|
if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
|
|
50205
50394
|
const at2 = path53.resolve(folder2, href);
|
|
50206
|
-
if (!at2.startsWith(folder2 + path53.sep) || !
|
|
50207
|
-
const css =
|
|
50395
|
+
if (!at2.startsWith(folder2 + path53.sep) || !fs49.existsSync(at2)) return tag;
|
|
50396
|
+
const css = fs49.readFileSync(at2, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole2, quote, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole2 : `url(${quote}${path53.relative(folder2, path53.resolve(path53.dirname(at2), src)).split(path53.sep).join("/")}${quote})`);
|
|
50208
50397
|
return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
|
|
50209
50398
|
});
|
|
50210
50399
|
const at = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
|
|
@@ -50217,25 +50406,25 @@ var init_dress_page = __esm({
|
|
|
50217
50406
|
isHtmlFile = (file2) => /\.html?$/i.test(file2);
|
|
50218
50407
|
CSP = "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; media-src data: blob:; font-src data: blob:; worker-src 'none'; base-uri 'none'; form-action 'none'";
|
|
50219
50408
|
head = `<meta http-equiv="Content-Security-Policy" content="${CSP}"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>html{overflow-x:hidden;overscroll-behavior:contain}</style>`;
|
|
50220
|
-
referenceText = (file2) => isHtmlFile(file2) ? dressPage(file2) :
|
|
50409
|
+
referenceText = (file2) => isHtmlFile(file2) ? dressPage(file2) : fs49.readFileSync(file2, "utf8");
|
|
50221
50410
|
}
|
|
50222
50411
|
});
|
|
50223
50412
|
|
|
50224
50413
|
// ../cli/src/lib/preview-files.ts
|
|
50225
|
-
import
|
|
50414
|
+
import fs50 from "node:fs";
|
|
50226
50415
|
import path54 from "node:path";
|
|
50227
50416
|
function resolver(card, id2) {
|
|
50228
50417
|
const roots = [KANBAN, path54.join(ASSETS, String(id2))];
|
|
50229
|
-
const real2 = (p) =>
|
|
50418
|
+
const real2 = (p) => fs50.existsSync(p) ? fs50.realpathSync(p) : p;
|
|
50230
50419
|
const inside2 = (p) => roots.some((root2) => p.startsWith(real2(root2) + path54.sep));
|
|
50231
50420
|
return (src, owner) => {
|
|
50232
50421
|
if (/^[a-z][\w+.-]*:/i.test(src) || src.startsWith("#") || src.startsWith("//")) return null;
|
|
50233
50422
|
if (path54.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
|
|
50234
50423
|
const held4 = /^\.assets\//.exec(src);
|
|
50235
50424
|
const file2 = held4 ? path54.resolve(ASSETS, src.slice(held4[0].length)) : path54.resolve(path54.dirname(owner), src);
|
|
50236
|
-
if (!inside2(path54.resolve(file2)) ||
|
|
50237
|
-
if (!
|
|
50238
|
-
return { key:
|
|
50425
|
+
if (!inside2(path54.resolve(file2)) || fs50.existsSync(file2) && !inside2(fs50.realpathSync(file2))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id2}/)`);
|
|
50426
|
+
if (!fs50.statSync(file2, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
|
|
50427
|
+
return { key: fs50.realpathSync(file2), file: file2 };
|
|
50239
50428
|
};
|
|
50240
50429
|
}
|
|
50241
50430
|
function validatePreviewFiles(card, id2, text5) {
|
|
@@ -50278,7 +50467,7 @@ var init_preview_files = __esm({
|
|
|
50278
50467
|
});
|
|
50279
50468
|
|
|
50280
50469
|
// ../cli/src/lib/spec-contract.ts
|
|
50281
|
-
import
|
|
50470
|
+
import fs51 from "node:fs";
|
|
50282
50471
|
import path55 from "node:path";
|
|
50283
50472
|
function scanCardLines(lines, start = 0) {
|
|
50284
50473
|
const visible = lines.map(() => "");
|
|
@@ -50312,11 +50501,11 @@ function scanCardLines(lines, start = 0) {
|
|
|
50312
50501
|
}
|
|
50313
50502
|
function snapshotSpecs() {
|
|
50314
50503
|
const out = /* @__PURE__ */ new Map();
|
|
50315
|
-
if (!
|
|
50504
|
+
if (!fs51.existsSync(TODO)) return out;
|
|
50316
50505
|
for (const file2 of walkMd(TODO)) {
|
|
50317
50506
|
if (isLegacyRecurring(path55.relative(TODO, file2))) continue;
|
|
50318
50507
|
const id2 = idPrefix(path55.basename(file2) === "root.md" ? path55.basename(path55.dirname(file2)) : path55.basename(file2));
|
|
50319
|
-
if (id2 !== null) out.set(file2, { id: id2, text:
|
|
50508
|
+
if (id2 !== null) out.set(file2, { id: id2, text: fs51.readFileSync(file2, "utf8") });
|
|
50320
50509
|
}
|
|
50321
50510
|
return out;
|
|
50322
50511
|
}
|
|
@@ -50510,9 +50699,9 @@ function setEnd(lines, at) {
|
|
|
50510
50699
|
}
|
|
50511
50700
|
function inside(dir, name) {
|
|
50512
50701
|
try {
|
|
50513
|
-
const root2 =
|
|
50514
|
-
const real2 =
|
|
50515
|
-
return real2.startsWith(root2 + path55.sep) &&
|
|
50702
|
+
const root2 = fs51.realpathSync(dir);
|
|
50703
|
+
const real2 = fs51.realpathSync(path55.join(dir, name));
|
|
50704
|
+
return real2.startsWith(root2 + path55.sep) && fs51.statSync(real2).isFile() ? real2 : null;
|
|
50516
50705
|
} catch {
|
|
50517
50706
|
return null;
|
|
50518
50707
|
}
|
|
@@ -50545,7 +50734,7 @@ function compareProblem(attrs, id2) {
|
|
|
50545
50734
|
const shots = (message) => ({ rule: "compare-shots", message });
|
|
50546
50735
|
const json2 = (file2) => {
|
|
50547
50736
|
try {
|
|
50548
|
-
return file2.endsWith(".json") ? JSON.parse(
|
|
50737
|
+
return file2.endsWith(".json") ? JSON.parse(fs51.readFileSync(file2, "utf8")) : null;
|
|
50549
50738
|
} catch {
|
|
50550
50739
|
return null;
|
|
50551
50740
|
}
|
|
@@ -50570,7 +50759,7 @@ function compareProblem(attrs, id2) {
|
|
|
50570
50759
|
const file2 = inside(dir, named2.name);
|
|
50571
50760
|
if (!file2) return { message: `Compare shots ${at} names no file in this card's asset folder. Write the JSON there or fix the path.` };
|
|
50572
50761
|
try {
|
|
50573
|
-
return { data: JSON.parse(
|
|
50762
|
+
return { data: JSON.parse(fs51.readFileSync(file2, "utf8")) };
|
|
50574
50763
|
} catch {
|
|
50575
50764
|
return { message: `${at} is not valid JSON.` };
|
|
50576
50765
|
}
|
|
@@ -50625,7 +50814,7 @@ var init_spec_contract = __esm({
|
|
|
50625
50814
|
});
|
|
50626
50815
|
|
|
50627
50816
|
// ../cli/src/lib/reconcile.ts
|
|
50628
|
-
import
|
|
50817
|
+
import fs52 from "node:fs";
|
|
50629
50818
|
import path56 from "node:path";
|
|
50630
50819
|
function liveIds() {
|
|
50631
50820
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -50641,7 +50830,7 @@ function indexableCards() {
|
|
|
50641
50830
|
const out = [];
|
|
50642
50831
|
for (const dir of walkDirs(TODO)) {
|
|
50643
50832
|
const id2 = idPrefix(path56.basename(dir));
|
|
50644
|
-
if (id2 != null &&
|
|
50833
|
+
if (id2 != null && fs52.existsSync(path56.join(dir, "root.md"))) {
|
|
50645
50834
|
out.push({ id: id2, rel: path56.join(path56.relative(TODO, dir), "root.md").split(path56.sep).join("/") });
|
|
50646
50835
|
}
|
|
50647
50836
|
}
|
|
@@ -50658,7 +50847,7 @@ function indexableCards() {
|
|
|
50658
50847
|
}
|
|
50659
50848
|
function readmeComplaints(fix) {
|
|
50660
50849
|
const said2 = [];
|
|
50661
|
-
const lines =
|
|
50850
|
+
const lines = fs52.readFileSync(README, "utf8").split("\n");
|
|
50662
50851
|
const indexed = /* @__PURE__ */ new Set();
|
|
50663
50852
|
let fixed = 0;
|
|
50664
50853
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -50667,7 +50856,7 @@ function readmeComplaints(fix) {
|
|
|
50667
50856
|
const id2 = Number(m[1]);
|
|
50668
50857
|
const linkPath = m[2];
|
|
50669
50858
|
indexed.add(id2);
|
|
50670
|
-
if (
|
|
50859
|
+
if (fs52.existsSync(path56.join(TODO, linkPath))) continue;
|
|
50671
50860
|
const found2 = locate(id2);
|
|
50672
50861
|
if (!found2) {
|
|
50673
50862
|
said2.push(`README links #${id2} \u2192 ${linkPath}, but no card with that id exists (removed by hand?). Drop the entry or restore the file.`);
|
|
@@ -50683,7 +50872,7 @@ function readmeComplaints(fix) {
|
|
|
50683
50872
|
said2.push(`README link #${id2} pointed at missing ${linkPath} \u2192 repointed to ${want}.`);
|
|
50684
50873
|
fixed++;
|
|
50685
50874
|
}
|
|
50686
|
-
if (fixed)
|
|
50875
|
+
if (fixed) fs52.writeFileSync(README, lines.join("\n"));
|
|
50687
50876
|
for (const c of indexableCards()) {
|
|
50688
50877
|
if (!indexed.has(c.id)) {
|
|
50689
50878
|
said2.push(`card ${c.rel} (#${c.id}) is not in the README index. Add it under "## ${TASKS_HEADING}".`);
|
|
@@ -50699,7 +50888,7 @@ function crossRefComplaints() {
|
|
|
50699
50888
|
if (base === "README.md") continue;
|
|
50700
50889
|
const ownerId = base === "root.md" ? idPrefix(path56.basename(path56.dirname(file2))) : idPrefix(base);
|
|
50701
50890
|
if (ownerId == null) continue;
|
|
50702
|
-
const { meta: meta3 } = parseFrontmatter(
|
|
50891
|
+
const { meta: meta3 } = parseFrontmatter(fs52.readFileSync(file2, "utf8"));
|
|
50703
50892
|
if (!meta3) continue;
|
|
50704
50893
|
for (const field2 of ["blocked_by", "related"]) {
|
|
50705
50894
|
for (const ref of meta3[field2] || []) {
|
|
@@ -50712,7 +50901,7 @@ function crossRefComplaints() {
|
|
|
50712
50901
|
return said2;
|
|
50713
50902
|
}
|
|
50714
50903
|
function reconcileBoard() {
|
|
50715
|
-
if (!
|
|
50904
|
+
if (!fs52.existsSync(README)) return;
|
|
50716
50905
|
for (const line of [...readmeComplaints(true), ...crossRefComplaints()]) warn2(line);
|
|
50717
50906
|
}
|
|
50718
50907
|
var README_LINK;
|
|
@@ -50728,7 +50917,7 @@ var init_reconcile = __esm({
|
|
|
50728
50917
|
});
|
|
50729
50918
|
|
|
50730
50919
|
// ../cli/src/commands/card.ts
|
|
50731
|
-
import
|
|
50920
|
+
import fs53 from "node:fs";
|
|
50732
50921
|
import path57 from "node:path";
|
|
50733
50922
|
function defaultBody(summary2 = "<\u7528\u4E00\u5C0F\u6BB5\u8BDD\u5148\u8BB2\u53D1\u751F\u4E86\u4EC0\u4E48\u3001\u7528\u6237\u9047\u5230\u4EC0\u4E48\uFF0C\u518D\u8BB2\u8FD9\u5F20\u5361\u8981\u8FBE\u5230\u7684\u7ED3\u679C\u3002>") {
|
|
50734
50923
|
return [
|
|
@@ -50755,7 +50944,7 @@ function bodyFromFile(opts) {
|
|
|
50755
50944
|
if (opts.body === false) die("pass --body-file or --no-body, not both");
|
|
50756
50945
|
let text5;
|
|
50757
50946
|
try {
|
|
50758
|
-
text5 =
|
|
50947
|
+
text5 = fs53.readFileSync(opts.bodyFile, "utf8");
|
|
50759
50948
|
} catch {
|
|
50760
50949
|
die(`can't read ${opts.bodyFile} \u2014 write the body to a file, then pass its path`, { kind: "needs-input" });
|
|
50761
50950
|
}
|
|
@@ -50827,12 +51016,12 @@ function cmdCreate(opts) {
|
|
|
50827
51016
|
return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
|
|
50828
51017
|
}
|
|
50829
51018
|
if (held4) die(`#${start} is already a card here (${rel(held4.target)})`, { kind: "id-taken", id: start });
|
|
50830
|
-
if (
|
|
51019
|
+
if (fs53.existsSync(file2)) die(`${rel(file2)} already exists \u2014 pick a different --slug`);
|
|
50831
51020
|
countBoardEvent(triage ? "cards_created_proposed" : "cards_created_asked");
|
|
50832
51021
|
const meta3 = { title, priority, status: "todo", blocked_by, related, modules, studio, previews, triage, source: source2, questions };
|
|
50833
51022
|
const scaffolded = !written && opts.body !== false;
|
|
50834
51023
|
const body = written ?? (scaffolded ? defaultBody() : "");
|
|
50835
|
-
|
|
51024
|
+
fs53.writeFileSync(file2, serializeFrontmatter(meta3) + "\n\n" + body);
|
|
50836
51025
|
const indexed = addReadmeRef(start, title, fileRel);
|
|
50837
51026
|
say(start);
|
|
50838
51027
|
say(
|
|
@@ -50885,7 +51074,7 @@ function cmdUpdate(id2, flags) {
|
|
|
50885
51074
|
const found2 = locate(id2);
|
|
50886
51075
|
if (!found2) die(`no task with id ${id2} under ${rel(TODO)}`, { kind: "card-not-found", id: id2 });
|
|
50887
51076
|
const file2 = found2.kind === "group" ? path57.join(found2.target, "root.md") : found2.target;
|
|
50888
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
51077
|
+
const { meta: meta3, body } = parseFrontmatter(fs53.readFileSync(file2, "utf8"));
|
|
50889
51078
|
if (!meta3) die(`${rel(file2)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
|
|
50890
51079
|
if (flags.blockedBy !== void 0 && flags.addBlockedBy !== void 0) die("--blocked-by replaces the list and --add-blocked-by appends to it \u2014 pass one");
|
|
50891
51080
|
if (flags.related !== void 0 && flags.addRelated !== void 0) die("--related replaces the list and --add-related appends to it \u2014 pass one");
|
|
@@ -50961,9 +51150,9 @@ function cmdUpdate(id2, flags) {
|
|
|
50961
51150
|
const destRel = path57.join(path57.dirname(curRel), base);
|
|
50962
51151
|
const dest = path57.join(TODO, destRel);
|
|
50963
51152
|
const moving = dest !== file2;
|
|
50964
|
-
if (moving &&
|
|
50965
|
-
|
|
50966
|
-
if (moving)
|
|
51153
|
+
if (moving && fs53.existsSync(dest)) die(`${rel(dest)} already exists`);
|
|
51154
|
+
fs53.writeFileSync(file2, serializeFrontmatter(meta3) + "\n" + body);
|
|
51155
|
+
if (moving) fs53.renameSync(file2, dest);
|
|
50967
51156
|
if (isSubtask) {
|
|
50968
51157
|
if (moving || changes.includes("title")) repointReadmeLink(id2, curRel, destRel, meta3.title);
|
|
50969
51158
|
if (moving) changes.push(`renamed \u2192 ${destRel.split(path57.sep).join("/")}`);
|
|
@@ -50985,7 +51174,7 @@ function updateCardQuestions(id2, ops, compatibility = false) {
|
|
|
50985
51174
|
const found2 = locate(id2);
|
|
50986
51175
|
if (!found2) die(`no task with id ${id2} under ${rel(TODO)}`, { kind: "card-not-found", id: id2 });
|
|
50987
51176
|
const file2 = found2.kind === "group" ? path57.join(found2.target, "root.md") : found2.target;
|
|
50988
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
51177
|
+
const { meta: meta3, body } = parseFrontmatter(fs53.readFileSync(file2, "utf8"));
|
|
50989
51178
|
if (!meta3) die(`${rel(file2)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
|
|
50990
51179
|
for (const op of ops) {
|
|
50991
51180
|
if (!compatibility || !op.question?.agent) continue;
|
|
@@ -51007,7 +51196,7 @@ function updateCardQuestions(id2, ops, compatibility = false) {
|
|
|
51007
51196
|
meta3.status = "todo";
|
|
51008
51197
|
changes.push("status\u2192todo (open questions)");
|
|
51009
51198
|
}
|
|
51010
|
-
|
|
51199
|
+
fs53.writeFileSync(file2, serializeFrontmatter(meta3) + "\n" + body);
|
|
51011
51200
|
const closed2 = activeDelivery(id2) ? "questions_closed_verify" : "questions_closed_user";
|
|
51012
51201
|
for (const _ of done.closed) countBoardEvent(closed2);
|
|
51013
51202
|
say(`updated #${id2} questions: ${changes.join(", ")} (${open4} open)`);
|
|
@@ -51066,7 +51255,7 @@ var init_config_template = __esm({
|
|
|
51066
51255
|
});
|
|
51067
51256
|
|
|
51068
51257
|
// ../cli/src/commands/init.ts
|
|
51069
|
-
import
|
|
51258
|
+
import fs54 from "node:fs";
|
|
51070
51259
|
function boardReadme() {
|
|
51071
51260
|
return `# Board
|
|
51072
51261
|
|
|
@@ -51079,20 +51268,20 @@ _(none)_
|
|
|
51079
51268
|
`;
|
|
51080
51269
|
}
|
|
51081
51270
|
function writeConfigIfMissing() {
|
|
51082
|
-
if (
|
|
51083
|
-
|
|
51084
|
-
|
|
51271
|
+
if (fs54.existsSync(CONFIG)) return false;
|
|
51272
|
+
fs54.mkdirSync(KANBAN, { recursive: true });
|
|
51273
|
+
fs54.writeFileSync(CONFIG, CONFIG_TEMPLATE);
|
|
51085
51274
|
return true;
|
|
51086
51275
|
}
|
|
51087
51276
|
function writeModulesIfMissing() {
|
|
51088
|
-
if (
|
|
51089
|
-
|
|
51090
|
-
|
|
51277
|
+
if (fs54.existsSync(MODULES_MD)) return false;
|
|
51278
|
+
fs54.mkdirSync(KANBAN, { recursive: true });
|
|
51279
|
+
fs54.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
|
|
51091
51280
|
return true;
|
|
51092
51281
|
}
|
|
51093
51282
|
function writeGitignoreIfMissing() {
|
|
51094
|
-
|
|
51095
|
-
const text5 =
|
|
51283
|
+
fs54.mkdirSync(KANBAN, { recursive: true });
|
|
51284
|
+
const text5 = fs54.existsSync(KANBAN_GITIGNORE) ? fs54.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
|
|
51096
51285
|
const has = (rule) => text5.split("\n").some((line) => line.trim() === rule.line);
|
|
51097
51286
|
const missing = IGNORE_RULES.filter((rule) => !has(rule));
|
|
51098
51287
|
if (!missing.length) return false;
|
|
@@ -51100,23 +51289,23 @@ function writeGitignoreIfMissing() {
|
|
|
51100
51289
|
${rule.line}
|
|
51101
51290
|
`).join("");
|
|
51102
51291
|
const separator = !text5 || text5.endsWith("\n") ? "" : "\n";
|
|
51103
|
-
|
|
51292
|
+
fs54.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${block}`);
|
|
51104
51293
|
return true;
|
|
51105
51294
|
}
|
|
51106
51295
|
function writeSkeletonIfMissing() {
|
|
51107
51296
|
const added = [];
|
|
51108
|
-
if (!
|
|
51109
|
-
|
|
51297
|
+
if (!fs54.existsSync(TODO)) {
|
|
51298
|
+
fs54.mkdirSync(TODO, { recursive: true });
|
|
51110
51299
|
added.push(`${rel(TODO)}/`);
|
|
51111
51300
|
}
|
|
51112
|
-
if (!
|
|
51113
|
-
|
|
51301
|
+
if (!fs54.existsSync(README)) {
|
|
51302
|
+
fs54.writeFileSync(README, boardReadme());
|
|
51114
51303
|
added.push(rel(README));
|
|
51115
51304
|
}
|
|
51116
51305
|
return added;
|
|
51117
51306
|
}
|
|
51118
51307
|
function cmdInit() {
|
|
51119
|
-
if (
|
|
51308
|
+
if (fs54.existsSync(KANBAN)) {
|
|
51120
51309
|
const added = [
|
|
51121
51310
|
...writeSkeletonIfMissing(),
|
|
51122
51311
|
writeConfigIfMissing() && rel(CONFIG),
|
|
@@ -51133,8 +51322,8 @@ function cmdInit() {
|
|
|
51133
51322
|
}
|
|
51134
51323
|
return { board: rel(KANBAN), created: false, added, memory_paths: scaffolded.map((s) => rel(s.dir)) };
|
|
51135
51324
|
}
|
|
51136
|
-
|
|
51137
|
-
|
|
51325
|
+
fs54.mkdirSync(TODO, { recursive: true });
|
|
51326
|
+
fs54.writeFileSync(README, boardReadme());
|
|
51138
51327
|
writeConfigIfMissing();
|
|
51139
51328
|
scaffoldProjectMemory();
|
|
51140
51329
|
writeModulesIfMissing();
|
|
@@ -51169,15 +51358,15 @@ _(not filled in yet \u2014 build the map from the repo before tagging a card.)_
|
|
|
51169
51358
|
});
|
|
51170
51359
|
|
|
51171
51360
|
// ../cli/src/lib/card-age.ts
|
|
51172
|
-
import
|
|
51361
|
+
import fs55 from "node:fs";
|
|
51173
51362
|
import path58 from "node:path";
|
|
51174
51363
|
function staleAfterIn(config2) {
|
|
51175
51364
|
const days = Number(LINE.exec(config2)?.[1]);
|
|
51176
51365
|
return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
|
|
51177
51366
|
}
|
|
51178
51367
|
function staleAfter() {
|
|
51179
|
-
if (!
|
|
51180
|
-
return staleAfterIn(
|
|
51368
|
+
if (!fs55.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
|
|
51369
|
+
return staleAfterIn(fs55.readFileSync(CONFIG, "utf8"));
|
|
51181
51370
|
}
|
|
51182
51371
|
function todoPathspec(top) {
|
|
51183
51372
|
const from = path58.relative(real(top), real(TODO));
|
|
@@ -51234,7 +51423,7 @@ var init_card_age = __esm({
|
|
|
51234
51423
|
gitTop = () => git(["rev-parse", "--show-toplevel"])?.trim() || null;
|
|
51235
51424
|
real = (p) => {
|
|
51236
51425
|
try {
|
|
51237
|
-
return
|
|
51426
|
+
return fs55.realpathSync(p);
|
|
51238
51427
|
} catch {
|
|
51239
51428
|
return path58.resolve(p);
|
|
51240
51429
|
}
|
|
@@ -51270,7 +51459,7 @@ var init_card_holds = __esm({
|
|
|
51270
51459
|
});
|
|
51271
51460
|
|
|
51272
51461
|
// ../cli/src/commands/list.ts
|
|
51273
|
-
import
|
|
51462
|
+
import fs56 from "node:fs";
|
|
51274
51463
|
import path59 from "node:path";
|
|
51275
51464
|
function summaryLine(body) {
|
|
51276
51465
|
const lines = body.split("\n");
|
|
@@ -51293,7 +51482,7 @@ function openRows() {
|
|
|
51293
51482
|
const id2 = isRoot ? idPrefix(path59.basename(path59.dirname(file2))) : idPrefix(base);
|
|
51294
51483
|
if (id2 == null) continue;
|
|
51295
51484
|
if (isLegacyRecurring(path59.relative(TODO, file2))) continue;
|
|
51296
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
51485
|
+
const { meta: meta3, body } = parseFrontmatter(fs56.readFileSync(file2, "utf8"));
|
|
51297
51486
|
rows.push({
|
|
51298
51487
|
id: id2,
|
|
51299
51488
|
file: file2,
|
|
@@ -51335,7 +51524,7 @@ function cmdStale(rows, all2, scope, mod) {
|
|
|
51335
51524
|
}
|
|
51336
51525
|
function archivedFiles() {
|
|
51337
51526
|
const files = /* @__PURE__ */ new Map();
|
|
51338
|
-
if (!
|
|
51527
|
+
if (!fs56.existsSync(ARCHIVE)) return files;
|
|
51339
51528
|
for (const file2 of walkMd(ARCHIVE)) {
|
|
51340
51529
|
const id2 = idPrefix(path59.basename(file2));
|
|
51341
51530
|
if (id2 !== null) files.set(id2, file2);
|
|
@@ -51343,7 +51532,7 @@ function archivedFiles() {
|
|
|
51343
51532
|
for (const dir of walkDirs(ARCHIVE)) {
|
|
51344
51533
|
const id2 = idPrefix(path59.basename(dir));
|
|
51345
51534
|
const root2 = path59.join(dir, "root.md");
|
|
51346
|
-
if (id2 !== null &&
|
|
51535
|
+
if (id2 !== null && fs56.existsSync(root2)) files.set(id2, root2);
|
|
51347
51536
|
}
|
|
51348
51537
|
return files;
|
|
51349
51538
|
}
|
|
@@ -51441,10 +51630,10 @@ var init_list = __esm({
|
|
|
51441
51630
|
});
|
|
51442
51631
|
|
|
51443
51632
|
// ../cli/src/lib/group-close.ts
|
|
51444
|
-
import
|
|
51633
|
+
import fs57 from "node:fs";
|
|
51445
51634
|
function groupCloses(rootFile) {
|
|
51446
51635
|
try {
|
|
51447
|
-
return groupCloseOf(
|
|
51636
|
+
return groupCloseOf(fs57.readFileSync(rootFile, "utf8"));
|
|
51448
51637
|
} catch {
|
|
51449
51638
|
return false;
|
|
51450
51639
|
}
|
|
@@ -51457,7 +51646,7 @@ var init_group_close = __esm({
|
|
|
51457
51646
|
});
|
|
51458
51647
|
|
|
51459
51648
|
// ../cli/src/commands/remove.ts
|
|
51460
|
-
import
|
|
51649
|
+
import fs58 from "node:fs";
|
|
51461
51650
|
import path60 from "node:path";
|
|
51462
51651
|
function leavingIds(id2, found2) {
|
|
51463
51652
|
const ids = /* @__PURE__ */ new Set([id2]);
|
|
@@ -51474,10 +51663,10 @@ function findMentions(ids) {
|
|
|
51474
51663
|
const hits = [];
|
|
51475
51664
|
const re = new RegExp(ids.map((id2) => `#${id2}(?!\\d)`).join("|"));
|
|
51476
51665
|
for (const dir of [TODO, MEMORY]) {
|
|
51477
|
-
if (!
|
|
51666
|
+
if (!fs58.existsSync(dir)) continue;
|
|
51478
51667
|
for (const file2 of walkMd(dir)) {
|
|
51479
51668
|
if (path60.basename(file2) === "README.md") continue;
|
|
51480
|
-
const lines =
|
|
51669
|
+
const lines = fs58.readFileSync(file2, "utf8").split("\n");
|
|
51481
51670
|
const fmEnd = frontmatterEnd(lines);
|
|
51482
51671
|
lines.forEach((line, i) => {
|
|
51483
51672
|
if (!re.test(line)) return;
|
|
@@ -51507,10 +51696,10 @@ function stampLeaving(cards, rejection) {
|
|
|
51507
51696
|
const day = formatDay();
|
|
51508
51697
|
const stamp4 = rejection && !rejection.discard ? { reason: rejection.reason, at: (/* @__PURE__ */ new Date()).toISOString(), by: insideRun() || workspaceTask() ? "agent" : "user" } : rejection && { reason: rejection.reason };
|
|
51509
51698
|
for (const card of cards) {
|
|
51510
|
-
if (!
|
|
51511
|
-
const text5 =
|
|
51699
|
+
if (!fs58.existsSync(card.file)) continue;
|
|
51700
|
+
const text5 = fs58.readFileSync(card.file, "utf8");
|
|
51512
51701
|
const stamped = stampLeavingIn(text5, day, stamp4);
|
|
51513
|
-
if (stamped !== text5)
|
|
51702
|
+
if (stamped !== text5) fs58.writeFileSync(card.file, stamped);
|
|
51514
51703
|
}
|
|
51515
51704
|
}
|
|
51516
51705
|
function agentDecisions(text5) {
|
|
@@ -51540,14 +51729,14 @@ function removeCard(id2, metric, options) {
|
|
|
51540
51729
|
if (!found2) die(`no task with id ${id2} under ${rel(TODO)}`, { kind: "card-not-found", id: id2 });
|
|
51541
51730
|
const dest = options.cleanupDiscarded && locateArchived(id2) ? null : archiveDest(found2);
|
|
51542
51731
|
const cardFile3 = found2.kind === "group" ? path60.join(found2.target, "root.md") : found2.target;
|
|
51543
|
-
const cardText =
|
|
51732
|
+
const cardText = fs58.existsSync(cardFile3) ? fs58.readFileSync(cardFile3, "utf8") : "";
|
|
51544
51733
|
const { meta: cardMeta3 } = parseFrontmatter(cardText);
|
|
51545
51734
|
const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f) => f !== cardFile3).map((f) => rel(f)).sort() : [];
|
|
51546
51735
|
const leftIds = leavingIds(id2, found2);
|
|
51547
51736
|
const leaving = leavingCards(id2, found2);
|
|
51548
51737
|
if (options.archivingTask) {
|
|
51549
51738
|
for (const card of leaving) {
|
|
51550
|
-
const meta3 = parseFrontmatter(
|
|
51739
|
+
const meta3 = parseFrontmatter(fs58.readFileSync(card.file, "utf8")).meta;
|
|
51551
51740
|
if (!meta3 || meta3.rejected) die(`#${card.id} is not eligible for archive.`, { kind: "conflict" });
|
|
51552
51741
|
if (meta3.questions.length) die(`Resolve the open questions on #${card.id} before archiving.`, { kind: "conflict" });
|
|
51553
51742
|
if (card.id !== id2 && (activeDelivery(card.id) || creationRefusal(card.id, cardCreation(card.id), "archive", false))) {
|
|
@@ -51581,10 +51770,10 @@ function removeCard(id2, metric, options) {
|
|
|
51581
51770
|
const groupRoot = found2.kind === "file" && !options.closing ? enclosingGroupRoot(found2.target) : null;
|
|
51582
51771
|
if (dest) {
|
|
51583
51772
|
stampLeaving(leaving, metric === "rejected" ? { reason: options.reason?.trim() ?? "", discard: options.discard === true } : null);
|
|
51584
|
-
|
|
51585
|
-
|
|
51773
|
+
fs58.mkdirSync(ARCHIVE, { recursive: true });
|
|
51774
|
+
fs58.renameSync(found2.target, dest);
|
|
51586
51775
|
} else {
|
|
51587
|
-
|
|
51776
|
+
fs58.rmSync(found2.target, { recursive: true, force: true });
|
|
51588
51777
|
}
|
|
51589
51778
|
const removedRefs = stripReadmeRefs(found2);
|
|
51590
51779
|
let marked2 = null;
|
|
@@ -51640,7 +51829,7 @@ function closeGroup(rootFile) {
|
|
|
51640
51829
|
say(`
|
|
51641
51830
|
every subtask line on #${rootId} is resolved \u2014 closing the group:`);
|
|
51642
51831
|
try {
|
|
51643
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
51832
|
+
const { meta: meta3, body } = parseFrontmatter(fs58.readFileSync(rootFile, "utf8"));
|
|
51644
51833
|
const res = cmdRemove(rootId, "completed", { closing: true });
|
|
51645
51834
|
return {
|
|
51646
51835
|
id: rootId,
|
|
@@ -51704,7 +51893,7 @@ function recoveredArchiveHandoff(id2, source2) {
|
|
|
51704
51893
|
const found2 = locateArchived(id2);
|
|
51705
51894
|
if (!found2) throw new Error(`No archived card #${id2} was found.`);
|
|
51706
51895
|
const file2 = found2.kind === "group" ? path60.join(found2.target, "root.md") : found2.target;
|
|
51707
|
-
const { meta: meta3 } = parseFrontmatter(
|
|
51896
|
+
const { meta: meta3 } = parseFrontmatter(fs58.readFileSync(file2, "utf8"));
|
|
51708
51897
|
stripReadmeRefs(source2 ?? found2);
|
|
51709
51898
|
const root2 = source2?.kind === "file" ? enclosingGroupRoot(source2.target) : null;
|
|
51710
51899
|
if (root2) markSubtask(root2, id2, "tick");
|
|
@@ -51823,7 +52012,7 @@ var init_bundled2 = __esm({
|
|
|
51823
52012
|
});
|
|
51824
52013
|
|
|
51825
52014
|
// ../cli/src/lib/memories.ts
|
|
51826
|
-
import
|
|
52015
|
+
import fs59 from "node:fs";
|
|
51827
52016
|
import path61 from "node:path";
|
|
51828
52017
|
function readMemory(text5, builtIn, folder2) {
|
|
51829
52018
|
const { meta: meta3, body } = splitFrontmatter(text5);
|
|
@@ -51855,14 +52044,14 @@ function globalMemories() {
|
|
|
51855
52044
|
}
|
|
51856
52045
|
let folders2 = [];
|
|
51857
52046
|
try {
|
|
51858
|
-
folders2 =
|
|
52047
|
+
folders2 = fs59.readdirSync(MEMORY, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
51859
52048
|
} catch {
|
|
51860
52049
|
}
|
|
51861
52050
|
for (const name of folders2) {
|
|
51862
52051
|
if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR || name === STUDIO_MEMORY_DIR) continue;
|
|
51863
52052
|
const file2 = path61.join(MEMORY, name, GLOBAL_MEMORY_FILE);
|
|
51864
|
-
if (!
|
|
51865
|
-
const memory = readMemory(
|
|
52053
|
+
if (!fs59.existsSync(file2)) continue;
|
|
52054
|
+
const memory = readMemory(fs59.readFileSync(file2, "utf8"), false, name);
|
|
51866
52055
|
if (memory) out.push(memory);
|
|
51867
52056
|
}
|
|
51868
52057
|
return out;
|
|
@@ -51903,7 +52092,7 @@ var init_memory_file = __esm({
|
|
|
51903
52092
|
});
|
|
51904
52093
|
|
|
51905
52094
|
// ../cli/src/commands/inspect.ts
|
|
51906
|
-
import
|
|
52095
|
+
import fs60 from "node:fs";
|
|
51907
52096
|
import os4 from "node:os";
|
|
51908
52097
|
import path62 from "node:path";
|
|
51909
52098
|
function cmdInspect(id2) {
|
|
@@ -51911,7 +52100,7 @@ function cmdInspect(id2) {
|
|
|
51911
52100
|
const unavailable = [];
|
|
51912
52101
|
function read5(source2, file3, empty) {
|
|
51913
52102
|
try {
|
|
51914
|
-
return JSON.parse(
|
|
52103
|
+
return JSON.parse(fs60.readFileSync(file3, "utf8"));
|
|
51915
52104
|
} catch (error62) {
|
|
51916
52105
|
if (error62.code === "ENOENT") return empty;
|
|
51917
52106
|
findings.push({ source: source2, message: String(error62) });
|
|
@@ -51933,7 +52122,7 @@ function cmdInspect(id2) {
|
|
|
51933
52122
|
const file2 = found2.kind === "group" ? path62.join(found2.target, "root.md") : found2.target;
|
|
51934
52123
|
let card = null;
|
|
51935
52124
|
try {
|
|
51936
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
52125
|
+
const { meta: meta3, body } = parseFrontmatter(fs60.readFileSync(file2, "utf8"));
|
|
51937
52126
|
if (!meta3) throw Error("The card frontmatter could not be parsed.");
|
|
51938
52127
|
card = { path: rel(file2), questions: meta3.questions, todos: [...body.matchAll(/^\s*[-*]\s+\[([ xX])\]\s+(.*)$/gm)].map((m) => ({ text: m[2], done: m[1] !== " " })) };
|
|
51939
52128
|
} catch (error62) {
|
|
@@ -51946,7 +52135,7 @@ function cmdInspect(id2) {
|
|
|
51946
52135
|
const records = [];
|
|
51947
52136
|
const directory = path62.join(KANBAN, "deliveries");
|
|
51948
52137
|
try {
|
|
51949
|
-
for (const name of
|
|
52138
|
+
for (const name of fs60.readdirSync(directory).filter((name2) => name2.endsWith(".json"))) {
|
|
51950
52139
|
const held5 = read5("delivery", path62.join(directory, name), null);
|
|
51951
52140
|
if (held5?.cardId === id2) records.push(held5);
|
|
51952
52141
|
}
|
|
@@ -52000,7 +52189,7 @@ function cmdValidate(id2) {
|
|
|
52000
52189
|
const reason = errors.length ? formatContractErrors(errors) : void 0;
|
|
52001
52190
|
const session = insideRun();
|
|
52002
52191
|
if (session) patch(session, (run3) => {
|
|
52003
|
-
run3.validationFailure = reason ? { code: "validation_failed",
|
|
52192
|
+
run3.validationFailure = reason ? makeFailure("validation", reason, { code: "validation_failed", detail: reason }) : void 0;
|
|
52004
52193
|
});
|
|
52005
52194
|
if (reason) die(reason, { kind: "spec-contract", errors });
|
|
52006
52195
|
say(`Spec format valid (${cards.length} card${cards.length === 1 ? "" : "s"}).`);
|
|
@@ -52009,6 +52198,7 @@ function cmdValidate(id2) {
|
|
|
52009
52198
|
var init_validate2 = __esm({
|
|
52010
52199
|
"../cli/src/commands/validate.ts"() {
|
|
52011
52200
|
"use strict";
|
|
52201
|
+
init_retry();
|
|
52012
52202
|
init_env();
|
|
52013
52203
|
init_sessions();
|
|
52014
52204
|
init_io();
|
|
@@ -52018,7 +52208,7 @@ var init_validate2 = __esm({
|
|
|
52018
52208
|
});
|
|
52019
52209
|
|
|
52020
52210
|
// ../cli/src/lib/card-sources.ts
|
|
52021
|
-
import
|
|
52211
|
+
import fs61 from "node:fs";
|
|
52022
52212
|
import path63 from "node:path";
|
|
52023
52213
|
function planById(id2) {
|
|
52024
52214
|
const found2 = readPlan(`plans/${id2}-.md`);
|
|
@@ -52030,7 +52220,7 @@ function cardLink(id2) {
|
|
|
52030
52220
|
if (!found2) return null;
|
|
52031
52221
|
try {
|
|
52032
52222
|
const file2 = found2.kind === "group" ? path63.join(found2.target, "root.md") : found2.target;
|
|
52033
|
-
const title = parseFrontmatter(
|
|
52223
|
+
const title = parseFrontmatter(fs61.readFileSync(file2, "utf8")).meta?.title ?? "";
|
|
52034
52224
|
return { kind: "card", ref: String(id2), title, ...open4 ? {} : { archived: true } };
|
|
52035
52225
|
} catch {
|
|
52036
52226
|
return null;
|
|
@@ -52093,7 +52283,7 @@ var init_card_sources = __esm({
|
|
|
52093
52283
|
});
|
|
52094
52284
|
|
|
52095
52285
|
// ../cli/src/lib/view/read.ts
|
|
52096
|
-
import
|
|
52286
|
+
import fs62 from "node:fs";
|
|
52097
52287
|
import path64 from "node:path";
|
|
52098
52288
|
function readCard(file2, relFromTodo) {
|
|
52099
52289
|
const id2 = idPrefix(path64.basename(relFromTodo));
|
|
@@ -52106,7 +52296,7 @@ function readCard(file2, relFromTodo) {
|
|
|
52106
52296
|
return buildCard(id2, file2, relFromTodo);
|
|
52107
52297
|
}
|
|
52108
52298
|
function buildCard(id2, file2, relFromTodo) {
|
|
52109
|
-
const text5 =
|
|
52299
|
+
const text5 = fs62.readFileSync(file2, "utf8");
|
|
52110
52300
|
const { meta: meta3, body } = parseFrontmatter(text5);
|
|
52111
52301
|
if (!meta3) return null;
|
|
52112
52302
|
const relPath = relFromTodo.split(path64.sep).join("/");
|
|
@@ -52117,7 +52307,7 @@ function buildCard(id2, file2, relFromTodo) {
|
|
|
52117
52307
|
// Derived from the file exactly as it is on disk (lib/board/revision.ts), so a card
|
|
52118
52308
|
// read here and a card read by the contract agree on what version this is.
|
|
52119
52309
|
revision: revisionOf(text5),
|
|
52120
|
-
updatedAt:
|
|
52310
|
+
updatedAt: fs62.statSync(file2).mtime.toISOString(),
|
|
52121
52311
|
relPath,
|
|
52122
52312
|
title: meta3.title,
|
|
52123
52313
|
priority: meta3.priority,
|
|
@@ -52139,7 +52329,7 @@ function buildCard(id2, file2, relFromTodo) {
|
|
|
52139
52329
|
function readGroup(folderName) {
|
|
52140
52330
|
const groupDir = path64.join(TODO, folderName);
|
|
52141
52331
|
const rootFile = path64.join(groupDir, "root.md");
|
|
52142
|
-
if (!
|
|
52332
|
+
if (!fs62.existsSync(rootFile)) return null;
|
|
52143
52333
|
const root2 = readCard(rootFile, path64.join(folderName, "root.md"));
|
|
52144
52334
|
if (!root2) return null;
|
|
52145
52335
|
root2.isGroup = true;
|
|
@@ -52147,7 +52337,7 @@ function readGroup(folderName) {
|
|
|
52147
52337
|
root2.subtaskLines = { total, resolved };
|
|
52148
52338
|
const subCards = [];
|
|
52149
52339
|
const recurse = (dir, relDir) => {
|
|
52150
|
-
for (const entry of
|
|
52340
|
+
for (const entry of fs62.readdirSync(dir, { withFileTypes: true })) {
|
|
52151
52341
|
const childRel = path64.join(relDir, entry.name);
|
|
52152
52342
|
if (entry.isDirectory()) {
|
|
52153
52343
|
recurse(path64.join(dir, entry.name), childRel);
|
|
@@ -52174,9 +52364,9 @@ function readGroup(folderName) {
|
|
|
52174
52364
|
}
|
|
52175
52365
|
function standaloneCards(dirRel) {
|
|
52176
52366
|
const dir = dirRel ? path64.join(TODO, dirRel) : TODO;
|
|
52177
|
-
if (!
|
|
52367
|
+
if (!fs62.existsSync(dir)) return [];
|
|
52178
52368
|
const cards = [];
|
|
52179
|
-
for (const entry of
|
|
52369
|
+
for (const entry of fs62.readdirSync(dir, { withFileTypes: true })) {
|
|
52180
52370
|
if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
|
|
52181
52371
|
const c = readCard(path64.join(dir, entry.name), path64.join(dirRel, entry.name));
|
|
52182
52372
|
if (c) cards.push(c);
|
|
@@ -52190,7 +52380,7 @@ function collectCards() {
|
|
|
52190
52380
|
const top = standaloneCards("");
|
|
52191
52381
|
board2.push(...top);
|
|
52192
52382
|
every.push(...top);
|
|
52193
|
-
for (const entry of
|
|
52383
|
+
for (const entry of fs62.readdirSync(TODO, { withFileTypes: true })) {
|
|
52194
52384
|
if (!entry.isDirectory()) continue;
|
|
52195
52385
|
if (isGroupFolder(entry.name)) {
|
|
52196
52386
|
const g = readGroup(entry.name);
|
|
@@ -52222,7 +52412,7 @@ function findCard(id2) {
|
|
|
52222
52412
|
}
|
|
52223
52413
|
function attachSources(card) {
|
|
52224
52414
|
try {
|
|
52225
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
52415
|
+
const { meta: meta3, body } = parseFrontmatter(fs62.readFileSync(path64.join(TODO, card.relPath), "utf8"));
|
|
52226
52416
|
const sources2 = meta3 ? cardSources(meta3, body) : [];
|
|
52227
52417
|
if (sources2.length) card.sources = sources2;
|
|
52228
52418
|
} catch {
|
|
@@ -52596,7 +52786,7 @@ var init_project_agent = __esm({
|
|
|
52596
52786
|
|
|
52597
52787
|
// ../cli/src/lib/agent/creation.ts
|
|
52598
52788
|
import crypto3 from "node:crypto";
|
|
52599
|
-
import
|
|
52789
|
+
import fs63 from "node:fs";
|
|
52600
52790
|
import path65 from "node:path";
|
|
52601
52791
|
function creationError(error62, triage) {
|
|
52602
52792
|
const zh = readLanguage() === "zh";
|
|
@@ -52628,7 +52818,7 @@ ${slot}`).digest("hex");
|
|
|
52628
52818
|
function readCreation(file2, said2) {
|
|
52629
52819
|
return withCreationLock(() => {
|
|
52630
52820
|
try {
|
|
52631
|
-
const held4 = JSON.parse(
|
|
52821
|
+
const held4 = JSON.parse(fs63.readFileSync(file2, "utf8"));
|
|
52632
52822
|
if (!held4.said || typeof held4.said.title !== "string") throw new Error("Invalid creation journal");
|
|
52633
52823
|
return held4;
|
|
52634
52824
|
} catch (error62) {
|
|
@@ -52640,10 +52830,10 @@ function readCreation(file2, said2) {
|
|
|
52640
52830
|
});
|
|
52641
52831
|
}
|
|
52642
52832
|
function saveCreation(file2, journal) {
|
|
52643
|
-
|
|
52833
|
+
fs63.mkdirSync(path65.dirname(file2), { recursive: true });
|
|
52644
52834
|
const temp = `${file2}.${crypto3.randomUUID()}.tmp`;
|
|
52645
|
-
|
|
52646
|
-
|
|
52835
|
+
fs63.writeFileSync(temp, JSON.stringify(journal));
|
|
52836
|
+
fs63.renameSync(temp, file2);
|
|
52647
52837
|
}
|
|
52648
52838
|
function archiveCreation(source2, id2) {
|
|
52649
52839
|
if (readArchived().some((s) => s.sourceId === source2 && s.cardId === id2)) return;
|
|
@@ -53789,7 +53979,7 @@ var require_command = __commonJS({
|
|
|
53789
53979
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
53790
53980
|
var childProcess = __require("node:child_process");
|
|
53791
53981
|
var path88 = __require("node:path");
|
|
53792
|
-
var
|
|
53982
|
+
var fs91 = __require("node:fs");
|
|
53793
53983
|
var process2 = __require("node:process");
|
|
53794
53984
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
53795
53985
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -54770,7 +54960,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
54770
54960
|
* @param {string} subcommandName
|
|
54771
54961
|
*/
|
|
54772
54962
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
54773
|
-
if (
|
|
54963
|
+
if (fs91.existsSync(executableFile)) return;
|
|
54774
54964
|
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";
|
|
54775
54965
|
const executableMissing = `'${executableFile}' does not exist
|
|
54776
54966
|
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
@@ -54789,10 +54979,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
54789
54979
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
54790
54980
|
function findFile(baseDir, baseName) {
|
|
54791
54981
|
const localBin = path88.resolve(baseDir, baseName);
|
|
54792
|
-
if (
|
|
54982
|
+
if (fs91.existsSync(localBin)) return localBin;
|
|
54793
54983
|
if (sourceExt.includes(path88.extname(baseName))) return void 0;
|
|
54794
54984
|
const foundExt = sourceExt.find(
|
|
54795
|
-
(ext) =>
|
|
54985
|
+
(ext) => fs91.existsSync(`${localBin}${ext}`)
|
|
54796
54986
|
);
|
|
54797
54987
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
54798
54988
|
return void 0;
|
|
@@ -54804,7 +54994,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
54804
54994
|
if (this._scriptPath) {
|
|
54805
54995
|
let resolvedScriptPath;
|
|
54806
54996
|
try {
|
|
54807
|
-
resolvedScriptPath =
|
|
54997
|
+
resolvedScriptPath = fs91.realpathSync(this._scriptPath);
|
|
54808
54998
|
} catch {
|
|
54809
54999
|
resolvedScriptPath = this._scriptPath;
|
|
54810
55000
|
}
|
|
@@ -56140,7 +56330,7 @@ var init_shared2 = __esm({
|
|
|
56140
56330
|
});
|
|
56141
56331
|
|
|
56142
56332
|
// ../cli/src/lib/agents/shared-memory.ts
|
|
56143
|
-
import
|
|
56333
|
+
import fs64 from "node:fs";
|
|
56144
56334
|
import path66 from "node:path";
|
|
56145
56335
|
function sharedMemory(board2) {
|
|
56146
56336
|
const declared = /* @__PURE__ */ new Map();
|
|
@@ -56149,7 +56339,7 @@ function sharedMemory(board2) {
|
|
|
56149
56339
|
const read5 = parseSpecAgent(text5, folder2, (relative) => {
|
|
56150
56340
|
if (builtIn) return shippedAgentFiles()[`${folder2}/${relative}`] ?? null;
|
|
56151
56341
|
try {
|
|
56152
|
-
return
|
|
56342
|
+
return fs64.readFileSync(path66.join(board2, "agents", folder2, relative), "utf8");
|
|
56153
56343
|
} catch {
|
|
56154
56344
|
return null;
|
|
56155
56345
|
}
|
|
@@ -56163,13 +56353,13 @@ function sharedMemory(board2) {
|
|
|
56163
56353
|
const root2 = path66.join(board2, "agents");
|
|
56164
56354
|
let folders2 = [];
|
|
56165
56355
|
try {
|
|
56166
|
-
folders2 =
|
|
56356
|
+
folders2 = fs64.readdirSync(root2, { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name);
|
|
56167
56357
|
} catch {
|
|
56168
56358
|
}
|
|
56169
56359
|
for (const folder2 of folders2.sort()) {
|
|
56170
56360
|
let text5 = null;
|
|
56171
56361
|
try {
|
|
56172
|
-
text5 =
|
|
56362
|
+
text5 = fs64.readFileSync(path66.join(root2, folder2, "AGENT.md"), "utf8");
|
|
56173
56363
|
} catch {
|
|
56174
56364
|
}
|
|
56175
56365
|
take(folder2, text5, false);
|
|
@@ -56195,30 +56385,30 @@ var init_shared_memory = __esm({
|
|
|
56195
56385
|
|
|
56196
56386
|
// ../cli/src/lib/shared/board-conflicts.ts
|
|
56197
56387
|
import crypto4 from "node:crypto";
|
|
56198
|
-
import
|
|
56388
|
+
import fs65 from "node:fs";
|
|
56199
56389
|
import path67 from "node:path";
|
|
56200
56390
|
function atomicJson(file2, data) {
|
|
56201
|
-
|
|
56391
|
+
fs65.mkdirSync(path67.dirname(file2), { recursive: true });
|
|
56202
56392
|
const temp = `${file2}.${crypto4.randomUUID()}.tmp`;
|
|
56203
|
-
const fd =
|
|
56393
|
+
const fd = fs65.openSync(temp, "wx", 384);
|
|
56204
56394
|
try {
|
|
56205
|
-
|
|
56206
|
-
|
|
56395
|
+
fs65.writeFileSync(fd, JSON.stringify(data));
|
|
56396
|
+
fs65.fsyncSync(fd);
|
|
56207
56397
|
} finally {
|
|
56208
|
-
|
|
56398
|
+
fs65.closeSync(fd);
|
|
56209
56399
|
}
|
|
56210
|
-
|
|
56400
|
+
fs65.renameSync(temp, file2);
|
|
56211
56401
|
}
|
|
56212
56402
|
function boardTextAt(board2, name) {
|
|
56213
56403
|
if (!isBoardPath(name)) throw new BoardError(`Invalid board path: ${name}`, { kind: "invalid-usage" });
|
|
56214
56404
|
const file2 = path67.join(board2, name);
|
|
56215
56405
|
let ancestor = file2;
|
|
56216
|
-
while (!
|
|
56217
|
-
const real2 = path67.resolve(
|
|
56218
|
-
if (!real2.startsWith(
|
|
56219
|
-
if ((
|
|
56406
|
+
while (!fs65.existsSync(ancestor) && path67.dirname(ancestor) !== ancestor) ancestor = path67.dirname(ancestor);
|
|
56407
|
+
const real2 = path67.resolve(fs65.realpathSync(ancestor), path67.relative(ancestor, file2));
|
|
56408
|
+
if (!real2.startsWith(fs65.realpathSync(board2) + path67.sep)) throw new BoardError(`Link outside the board: ${name}`, { kind: "invalid-usage" });
|
|
56409
|
+
if ((fs65.statSync(file2, { throwIfNoEntry: false })?.size ?? 0) > BOARD_FILE_LIMIT) throw new BoardError(`${name} exceeds the board file limit.`, { kind: "cloud-refused" });
|
|
56220
56410
|
try {
|
|
56221
|
-
return
|
|
56411
|
+
return fs65.readFileSync(file2, "utf8");
|
|
56222
56412
|
} catch (e) {
|
|
56223
56413
|
if (e.code === "ENOENT") return null;
|
|
56224
56414
|
throw e;
|
|
@@ -56229,9 +56419,9 @@ function save2(board2, record2) {
|
|
|
56229
56419
|
}
|
|
56230
56420
|
function read2(board2, id2) {
|
|
56231
56421
|
const file2 = fileOf(board2, id2);
|
|
56232
|
-
if (!
|
|
56422
|
+
if (!fs65.existsSync(file2)) throw new BoardError("Unknown board conflict.", { kind: "conflict-not-found", id: id2 });
|
|
56233
56423
|
try {
|
|
56234
|
-
const r = JSON.parse(
|
|
56424
|
+
const r = JSON.parse(fs65.readFileSync(file2, "utf8"));
|
|
56235
56425
|
if (r.id !== id2 || !r.project || !["open", "unconfirmed", "resolved"].includes(r.state) || !Array.isArray(r.files) || !r.files.length) throw Error();
|
|
56236
56426
|
const names2 = /* @__PURE__ */ new Set();
|
|
56237
56427
|
for (const f of r.files) {
|
|
@@ -56253,7 +56443,7 @@ function read2(board2, id2) {
|
|
|
56253
56443
|
function conflictRecords(board2) {
|
|
56254
56444
|
let names2;
|
|
56255
56445
|
try {
|
|
56256
|
-
names2 =
|
|
56446
|
+
names2 = fs65.readdirSync(folder(board2));
|
|
56257
56447
|
} catch (e) {
|
|
56258
56448
|
if (e.code === "ENOENT") return [];
|
|
56259
56449
|
throw e;
|
|
@@ -56342,7 +56532,7 @@ function confirmLocal(board2, r) {
|
|
|
56342
56532
|
const draft = r.draft;
|
|
56343
56533
|
const root2 = stateRootOf(board2);
|
|
56344
56534
|
const file2 = path67.join(root2, ".akb", "base.json");
|
|
56345
|
-
const base = JSON.parse(
|
|
56535
|
+
const base = JSON.parse(fs65.readFileSync(file2, "utf8"));
|
|
56346
56536
|
if (base.project && base.project !== r.project) refuse(r, "The project binding changed.", "cloud-refused");
|
|
56347
56537
|
base.deleted ??= {};
|
|
56348
56538
|
for (const [i, f] of r.files.entries()) {
|
|
@@ -56359,10 +56549,10 @@ function confirmLocal(board2, r) {
|
|
|
56359
56549
|
}
|
|
56360
56550
|
if (boardTextAt(board2, f.path) !== draft.working[i]) continue;
|
|
56361
56551
|
const local = path67.join(board2, f.path);
|
|
56362
|
-
if (sent.content === null)
|
|
56552
|
+
if (sent.content === null) fs65.rmSync(local, { force: true });
|
|
56363
56553
|
else {
|
|
56364
|
-
|
|
56365
|
-
|
|
56554
|
+
fs65.mkdirSync(path67.dirname(local), { recursive: true });
|
|
56555
|
+
fs65.writeFileSync(local, sent.content);
|
|
56366
56556
|
}
|
|
56367
56557
|
}
|
|
56368
56558
|
atomicJson(file2, base);
|
|
@@ -56540,7 +56730,7 @@ __export(board_exports, {
|
|
|
56540
56730
|
buildBoardProgram: () => buildBoardProgram
|
|
56541
56731
|
});
|
|
56542
56732
|
import crypto5 from "node:crypto";
|
|
56543
|
-
import
|
|
56733
|
+
import fs66 from "node:fs";
|
|
56544
56734
|
import path68 from "node:path";
|
|
56545
56735
|
async function dispatch(move, cmd, args2, opts, cli) {
|
|
56546
56736
|
const ctx = ctxOf(cmd, cli.program);
|
|
@@ -56561,7 +56751,7 @@ async function dispatch(move, cmd, args2, opts, cli) {
|
|
|
56561
56751
|
}
|
|
56562
56752
|
let resolution;
|
|
56563
56753
|
try {
|
|
56564
|
-
resolution = JSON.parse(
|
|
56754
|
+
resolution = JSON.parse(fs66.readFileSync(String(opts.file), "utf8"));
|
|
56565
56755
|
} catch {
|
|
56566
56756
|
throw new BoardError("Cannot read the UTF-8 JSON resolution file.", { kind: "invalid-usage" });
|
|
56567
56757
|
}
|
|
@@ -56602,7 +56792,7 @@ async function cloudCard(task, opts) {
|
|
|
56602
56792
|
let request2;
|
|
56603
56793
|
if (typeof opts.bodyFile === "string") {
|
|
56604
56794
|
try {
|
|
56605
|
-
request2 =
|
|
56795
|
+
request2 = fs66.readFileSync(opts.bodyFile, "utf8");
|
|
56606
56796
|
} catch {
|
|
56607
56797
|
}
|
|
56608
56798
|
}
|
|
@@ -56767,7 +56957,7 @@ var init_board2 = __esm({
|
|
|
56767
56957
|
});
|
|
56768
56958
|
|
|
56769
56959
|
// ../cli/src/lib/board-cli.ts
|
|
56770
|
-
import
|
|
56960
|
+
import fs67 from "node:fs";
|
|
56771
56961
|
import path69 from "node:path";
|
|
56772
56962
|
function useBoard(found2, dirNamed, readOnly = false) {
|
|
56773
56963
|
if (!found2.named && found2.board === path69.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
|
|
@@ -56779,7 +56969,7 @@ function useBoard(found2, dirNamed, readOnly = false) {
|
|
|
56779
56969
|
}
|
|
56780
56970
|
function whole(found2, move) {
|
|
56781
56971
|
if (move === MAKES_A_BOARD) return found2;
|
|
56782
|
-
if (!
|
|
56972
|
+
if (!fs67.existsSync(path69.join(found2.board, "todo"))) {
|
|
56783
56973
|
die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
|
|
56784
56974
|
kind: "board-incomplete",
|
|
56785
56975
|
dir: found2.root
|
|
@@ -56793,7 +56983,7 @@ function findBoardUpward(from, move) {
|
|
|
56793
56983
|
if (hasBoard(dir)) return { root: dir, board: path69.join(dir, "docs", "kanban") };
|
|
56794
56984
|
if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
|
|
56795
56985
|
const kept2 = path69.join(dir, ".akb", "kanban");
|
|
56796
|
-
if (move !== MAKES_A_BOARD &&
|
|
56986
|
+
if (move !== MAKES_A_BOARD && fs67.existsSync(path69.join(kept2, "todo"))) return { root: dir, board: kept2 };
|
|
56797
56987
|
const up = path69.dirname(dir);
|
|
56798
56988
|
if (up === dir) return null;
|
|
56799
56989
|
dir = up;
|
|
@@ -56803,10 +56993,10 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
|
56803
56993
|
const named2 = board2 ?? boardFromEnv();
|
|
56804
56994
|
if (named2) {
|
|
56805
56995
|
const folder2 = path69.resolve(cwd, named2);
|
|
56806
|
-
if (!
|
|
56996
|
+
if (!fs67.existsSync(folder2) && move !== MAKES_A_BOARD) {
|
|
56807
56997
|
die(`no such folder: ${folder2}`, { kind: "no-such-folder", dir: folder2 });
|
|
56808
56998
|
}
|
|
56809
|
-
if (
|
|
56999
|
+
if (fs67.existsSync(folder2) && !isBoardDir(folder2) && move !== MAKES_A_BOARD) {
|
|
56810
57000
|
die(`${folder2} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
|
|
56811
57001
|
kind: "no-board",
|
|
56812
57002
|
dir: folder2
|
|
@@ -56816,9 +57006,9 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
|
56816
57006
|
}
|
|
56817
57007
|
if (dir !== null) {
|
|
56818
57008
|
const root2 = path69.resolve(dir);
|
|
56819
|
-
if (!
|
|
57009
|
+
if (!fs67.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
|
|
56820
57010
|
const kept2 = path69.join(root2, ".akb", "kanban");
|
|
56821
|
-
if (!hasBoard(root2) && move !== MAKES_A_BOARD &&
|
|
57011
|
+
if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs67.existsSync(path69.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
|
|
56822
57012
|
if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
|
|
56823
57013
|
die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
|
|
56824
57014
|
kind: "no-board",
|
|
@@ -56909,8 +57099,8 @@ var init_board_cli = __esm({
|
|
|
56909
57099
|
init_io();
|
|
56910
57100
|
init_card_studio_backfill();
|
|
56911
57101
|
MAKES_A_BOARD = "init";
|
|
56912
|
-
hasBoard = (dir) =>
|
|
56913
|
-
isBoardDir = (dir) =>
|
|
57102
|
+
hasBoard = (dir) => fs67.existsSync(path69.join(dir, "docs", "kanban"));
|
|
57103
|
+
isBoardDir = (dir) => fs67.existsSync(path69.join(dir, "todo")) && fs67.existsSync(path69.join(dir, "config.md"));
|
|
56914
57104
|
boardFromEnv = () => {
|
|
56915
57105
|
const named2 = process.env.AI4KANBAN_BOARD?.trim();
|
|
56916
57106
|
return named2 ? named2 : null;
|
|
@@ -56919,11 +57109,11 @@ var init_board_cli = __esm({
|
|
|
56919
57109
|
});
|
|
56920
57110
|
|
|
56921
57111
|
// ../cli/src/lib/cloud/task-operation.ts
|
|
56922
|
-
import
|
|
57112
|
+
import fs68 from "node:fs";
|
|
56923
57113
|
import path70 from "node:path";
|
|
56924
57114
|
function readRemoval(board2, task) {
|
|
56925
57115
|
try {
|
|
56926
|
-
const value = JSON.parse(
|
|
57116
|
+
const value = JSON.parse(fs68.readFileSync(removalFile(board2, task), "utf8"));
|
|
56927
57117
|
if (["pending", "confirmed", "rejected"].includes(value.status) && typeof value.reason === "string" && typeof value.discard === "boolean") return value;
|
|
56928
57118
|
} catch {
|
|
56929
57119
|
}
|
|
@@ -56932,8 +57122,8 @@ function readRemoval(board2, task) {
|
|
|
56932
57122
|
function writeRemoval(board2, task, removal) {
|
|
56933
57123
|
const file2 = removalFile(board2, task);
|
|
56934
57124
|
const temp = `${file2}.${process.pid}.tmp`;
|
|
56935
|
-
|
|
56936
|
-
|
|
57125
|
+
fs68.writeFileSync(temp, JSON.stringify(removal) + "\n");
|
|
57126
|
+
fs68.renameSync(temp, file2);
|
|
56937
57127
|
}
|
|
56938
57128
|
var removalFile;
|
|
56939
57129
|
var init_task_operation = __esm({
|
|
@@ -56989,10 +57179,10 @@ var init_avatar = __esm({
|
|
|
56989
57179
|
});
|
|
56990
57180
|
|
|
56991
57181
|
// ../cli/src/lib/cloud/pro.ts
|
|
56992
|
-
import
|
|
57182
|
+
import fs69 from "node:fs";
|
|
56993
57183
|
import path71 from "node:path";
|
|
56994
57184
|
function forgetPro() {
|
|
56995
|
-
|
|
57185
|
+
fs69.rmSync(heldFile(), { force: true });
|
|
56996
57186
|
}
|
|
56997
57187
|
var FRESH_MS2, GRACE_MS, heldFile;
|
|
56998
57188
|
var init_pro = __esm({
|
|
@@ -57098,7 +57288,7 @@ var init_account = __esm({
|
|
|
57098
57288
|
});
|
|
57099
57289
|
|
|
57100
57290
|
// ../cli/src/commands/cloud.ts
|
|
57101
|
-
import
|
|
57291
|
+
import fs70 from "node:fs";
|
|
57102
57292
|
import path72 from "node:path";
|
|
57103
57293
|
async function cmdCloud(args2, program2) {
|
|
57104
57294
|
const [sub] = args2;
|
|
@@ -57174,7 +57364,7 @@ async function cloudImage(opts, program2) {
|
|
|
57174
57364
|
const type = REF_TYPES[path72.extname(file2).toLowerCase()];
|
|
57175
57365
|
if (!type) usage(`--ref ${file2}: use a PNG, JPEG or WebP file.`, line);
|
|
57176
57366
|
try {
|
|
57177
|
-
return `data:${type};base64,${
|
|
57367
|
+
return `data:${type};base64,${fs70.readFileSync(file2).toString("base64")}`;
|
|
57178
57368
|
} catch (e) {
|
|
57179
57369
|
usage(`--ref ${file2}: ${e instanceof Error ? e.message : String(e)}`, line);
|
|
57180
57370
|
}
|
|
@@ -57298,8 +57488,8 @@ usage: ${g.usage}` }, { bare: true, exitCode: 2 });
|
|
|
57298
57488
|
refuse2(g.failed, g.fallback, { code: error62.kind, message: error62.message, retryable: true });
|
|
57299
57489
|
}
|
|
57300
57490
|
const out = g.outFor?.(res, g.out) ?? g.out;
|
|
57301
|
-
|
|
57302
|
-
|
|
57491
|
+
fs70.mkdirSync(path72.dirname(path72.resolve(out)), { recursive: true });
|
|
57492
|
+
fs70.writeFileSync(out, bytes2);
|
|
57303
57493
|
say(`${out} (${g.label(res)})`);
|
|
57304
57494
|
return { out };
|
|
57305
57495
|
}
|
|
@@ -57361,7 +57551,7 @@ var init_cloud = __esm({
|
|
|
57361
57551
|
});
|
|
57362
57552
|
|
|
57363
57553
|
// ../cli/src/commands/task.ts
|
|
57364
|
-
import
|
|
57554
|
+
import fs71 from "node:fs";
|
|
57365
57555
|
import os5 from "node:os";
|
|
57366
57556
|
import path73 from "node:path";
|
|
57367
57557
|
async function cloud(method, route2, body, signal2) {
|
|
@@ -57420,7 +57610,7 @@ function linked(location) {
|
|
|
57420
57610
|
return link2.ok ? link2.value : null;
|
|
57421
57611
|
}
|
|
57422
57612
|
for (let dir = path73.resolve(cwd, location.dir ?? "."); ; dir = path73.dirname(dir)) {
|
|
57423
|
-
if (
|
|
57613
|
+
if (fs71.existsSync(path73.join(dir, ".akb", "base.json"))) {
|
|
57424
57614
|
const link2 = linkedProject("", dir);
|
|
57425
57615
|
return link2.ok ? link2.value : null;
|
|
57426
57616
|
}
|
|
@@ -57527,7 +57717,7 @@ async function taskReview(id2, opts = {}, location = {}) {
|
|
|
57527
57717
|
if (opts.review !== void 0) {
|
|
57528
57718
|
fields2 = { operation: "plan", review_flow: opts.review };
|
|
57529
57719
|
} else if (opts.file !== void 0) {
|
|
57530
|
-
fields2 = { operation: "plan", review_plan: parseReviewPlan(JSON.parse(
|
|
57720
|
+
fields2 = { operation: "plan", review_plan: parseReviewPlan(JSON.parse(fs71.readFileSync(opts.file, "utf8"))) };
|
|
57531
57721
|
} else if (opts.reviseFrom !== void 0) {
|
|
57532
57722
|
fields2 = { operation: "revise", stage: opts.reviseFrom };
|
|
57533
57723
|
} else if (opts.previewDefinitionsFile !== void 0) {
|
|
@@ -57536,7 +57726,7 @@ async function taskReview(id2, opts = {}, location = {}) {
|
|
|
57536
57726
|
if (!opts.stage || !["running", "done"].includes(opts.status)) die("--stage and --status running|done are required.");
|
|
57537
57727
|
fields2 = { operation: "status", stage: opts.stage, status: opts.status };
|
|
57538
57728
|
}
|
|
57539
|
-
if (opts.previewDefinitionsFile !== void 0) fields2.preview_definitions = previewDefinitionsSchema.parse(JSON.parse(
|
|
57729
|
+
if (opts.previewDefinitionsFile !== void 0) fields2.preview_definitions = previewDefinitionsSchema.parse(JSON.parse(fs71.readFileSync(opts.previewDefinitionsFile, "utf8")));
|
|
57540
57730
|
task = await cloud("POST", `/v1/tasks/${enc(ref)}/review`, { ...fields2, review_revision });
|
|
57541
57731
|
}
|
|
57542
57732
|
say(JSON.stringify(task.review, null, 2));
|
|
@@ -57579,7 +57769,7 @@ async function taskUpdateQuestions(id2, typed, location = {}) {
|
|
|
57579
57769
|
return withBoardLock(() => {
|
|
57580
57770
|
const run3 = insideRun();
|
|
57581
57771
|
const runCard = run3 ? peekRun(run3)?.cardId : null;
|
|
57582
|
-
if (runCard != null && runCard !== mapped.number || !
|
|
57772
|
+
if (runCard != null && runCard !== mapped.number || !fs71.existsSync(path73.join(board2, "todo")) || !locate(mapped.number)) {
|
|
57583
57773
|
return unavailable();
|
|
57584
57774
|
}
|
|
57585
57775
|
return updateCardQuestions(mapped.number, ops);
|
|
@@ -57620,7 +57810,7 @@ function runnerTaskBoard(location) {
|
|
|
57620
57810
|
const cwd = location.cwd ?? process.cwd();
|
|
57621
57811
|
try {
|
|
57622
57812
|
const board2 = path73.resolve(cwd, location.board ?? runnerBoard);
|
|
57623
|
-
return
|
|
57813
|
+
return fs71.realpathSync(board2) === fs71.realpathSync(path73.resolve(cwd, runnerBoard)) && runnerProject(board2) ? board2 : null;
|
|
57624
57814
|
} catch {
|
|
57625
57815
|
return null;
|
|
57626
57816
|
}
|
|
@@ -57628,7 +57818,7 @@ function runnerTaskBoard(location) {
|
|
|
57628
57818
|
function localTaskRecord(board2, task) {
|
|
57629
57819
|
if (!/^task_[\w-]+$/.test(task)) return null;
|
|
57630
57820
|
try {
|
|
57631
|
-
const record2 = JSON.parse(
|
|
57821
|
+
const record2 = JSON.parse(fs71.readFileSync(path73.join(board2, ".sync", task + ".json"), "utf8"));
|
|
57632
57822
|
if (record2.task === task && Number.isSafeInteger(record2.number) && record2.number > 0 && !record2.deleted) {
|
|
57633
57823
|
return { board: board2, task, number: record2.number };
|
|
57634
57824
|
}
|
|
@@ -57661,7 +57851,7 @@ function operationStatus(result) {
|
|
|
57661
57851
|
}
|
|
57662
57852
|
function archiveReceipt(board2, task, file2) {
|
|
57663
57853
|
try {
|
|
57664
|
-
const base = JSON.parse(
|
|
57854
|
+
const base = JSON.parse(fs71.readFileSync(path73.join(board2, "..", "base.json"), "utf8"));
|
|
57665
57855
|
const receipt = base.archiveReceipts?.[task];
|
|
57666
57856
|
const root2 = `projects/${runnerProject(board2)}/`;
|
|
57667
57857
|
const synced = receipt && base.files?.[root2 + receipt.path];
|
|
@@ -57670,7 +57860,7 @@ function archiveReceipt(board2, task, file2) {
|
|
|
57670
57860
|
if (synced && (!file2 || receipt.path === file2) && synced.seq === receipt.seq && (assets?.seq ?? 0) === receipt.assets_seq) {
|
|
57671
57861
|
const local = (name) => {
|
|
57672
57862
|
try {
|
|
57673
|
-
return
|
|
57863
|
+
return fs71.readFileSync(path73.join(board2, name), "utf8");
|
|
57674
57864
|
} catch {
|
|
57675
57865
|
return null;
|
|
57676
57866
|
}
|
|
@@ -57695,7 +57885,7 @@ async function taskArchive(asked, location = {}) {
|
|
|
57695
57885
|
const existing = locateArchived(local.number);
|
|
57696
57886
|
if (!existing) return null;
|
|
57697
57887
|
const file2 = existing.kind === "group" ? path73.join(existing.target, "root.md") : existing.target;
|
|
57698
|
-
const { meta: meta3 } = parseFrontmatter(
|
|
57888
|
+
const { meta: meta3 } = parseFrontmatter(fs71.readFileSync(file2, "utf8"));
|
|
57699
57889
|
if (!meta3?.archived || meta3.rejected) return refuse3("This task is not eligible for archive.", "conflict");
|
|
57700
57890
|
return {
|
|
57701
57891
|
receipt: { archived_to: path73.relative(local.board, existing.target) },
|
|
@@ -57897,20 +58087,20 @@ var init_goal = __esm({
|
|
|
57897
58087
|
});
|
|
57898
58088
|
|
|
57899
58089
|
// ../cli/src/lib/goal-draft.ts
|
|
57900
|
-
import
|
|
58090
|
+
import fs72 from "node:fs";
|
|
57901
58091
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
57902
58092
|
function readGoalDraft(file2) {
|
|
57903
|
-
return decodeGoals(JSON.parse(
|
|
58093
|
+
return decodeGoals(JSON.parse(fs72.readFileSync(file2, "utf8")));
|
|
57904
58094
|
}
|
|
57905
58095
|
function writeGoalDraft(file2, { goals, ...draft }, field2) {
|
|
57906
58096
|
const entries2 = field2 === "goals" ? goals : goals.map(({ task, ...goal }) => ({ ...goal, task: task?.key ? task : task?.id ?? null }));
|
|
57907
58097
|
const temporary = `${file2}.${randomUUID7()}.tmp`;
|
|
57908
58098
|
try {
|
|
57909
|
-
|
|
58099
|
+
fs72.writeFileSync(temporary, `${JSON.stringify({ ...draft, [field2]: entries2 }, null, 2)}
|
|
57910
58100
|
`, { mode: 384, flag: "wx" });
|
|
57911
|
-
|
|
58101
|
+
fs72.renameSync(temporary, file2);
|
|
57912
58102
|
} finally {
|
|
57913
|
-
|
|
58103
|
+
fs72.rmSync(temporary, { force: true });
|
|
57914
58104
|
}
|
|
57915
58105
|
}
|
|
57916
58106
|
var goalDraftPath;
|
|
@@ -57923,7 +58113,7 @@ var init_goal_draft = __esm({
|
|
|
57923
58113
|
});
|
|
57924
58114
|
|
|
57925
58115
|
// ../cli/src/commands/goal.ts
|
|
57926
|
-
import
|
|
58116
|
+
import fs73 from "node:fs";
|
|
57927
58117
|
function loadGoals() {
|
|
57928
58118
|
const file2 = goalDraftPath();
|
|
57929
58119
|
if (!file2) die("Goals exist only inside a WildCrane goal discussion.");
|
|
@@ -57955,7 +58145,7 @@ function splitBody2(text5) {
|
|
|
57955
58145
|
}
|
|
57956
58146
|
function readBody(bodyFile) {
|
|
57957
58147
|
if (!bodyFile) die("--body-file is required; write the goal in a writable temporary file first.");
|
|
57958
|
-
const text5 =
|
|
58148
|
+
const text5 = fs73.readFileSync(bodyFile, "utf8");
|
|
57959
58149
|
if (!text5.trim()) die("The goal must not be empty.");
|
|
57960
58150
|
return splitBody2(text5);
|
|
57961
58151
|
}
|
|
@@ -58021,7 +58211,7 @@ function cmdGoalStudios(held4 = loadGoals().held) {
|
|
|
58021
58211
|
return { studios: held4.studios.map((w) => ({ ...w, id: shortStudioId(w.id) })) };
|
|
58022
58212
|
}
|
|
58023
58213
|
function goalDefinitions(opts, previous = []) {
|
|
58024
|
-
return opts.previewDefinitionsFile === void 0 ? previous : previewDefinitionsSchema.parse(JSON.parse(
|
|
58214
|
+
return opts.previewDefinitionsFile === void 0 ? previous : previewDefinitionsSchema.parse(JSON.parse(fs73.readFileSync(opts.previewDefinitionsFile, "utf8")));
|
|
58025
58215
|
}
|
|
58026
58216
|
function goalCatalog(held4, studio, definitions) {
|
|
58027
58217
|
const builtIn = held4.studios.find((w) => w.id === studio)?.previews;
|
|
@@ -58034,7 +58224,7 @@ function goalReview(held4, studio, opts, previous, definitions) {
|
|
|
58034
58224
|
if (opts.reviewFile !== void 0) die("Use either --review or --review-file.");
|
|
58035
58225
|
return parseReviewFlow(opts.review, catalog);
|
|
58036
58226
|
}
|
|
58037
|
-
const value = opts.reviewFile === void 0 ? readReviewPlan(previous) : JSON.parse(
|
|
58227
|
+
const value = opts.reviewFile === void 0 ? readReviewPlan(previous) : JSON.parse(fs73.readFileSync(opts.reviewFile, "utf8"));
|
|
58038
58228
|
const saved = opts.reviewFile === void 0 && opts.previewDefinitionsFile === void 0 && opts.studio === void 0;
|
|
58039
58229
|
return validateReviewPreviews(parseReviewPlan(value), catalog, { saved });
|
|
58040
58230
|
}
|
|
@@ -58064,7 +58254,7 @@ var init_goal2 = __esm({
|
|
|
58064
58254
|
});
|
|
58065
58255
|
|
|
58066
58256
|
// ../cli/src/commands/goal-cloud.ts
|
|
58067
|
-
import
|
|
58257
|
+
import fs74 from "node:fs";
|
|
58068
58258
|
import os6 from "node:os";
|
|
58069
58259
|
import path74 from "node:path";
|
|
58070
58260
|
import crypto6 from "node:crypto";
|
|
@@ -58098,17 +58288,17 @@ async function discussion() {
|
|
|
58098
58288
|
const machineFile2 = path74.join(home3, "machine.json");
|
|
58099
58289
|
let machine;
|
|
58100
58290
|
try {
|
|
58101
|
-
machine = JSON.parse(
|
|
58291
|
+
machine = JSON.parse(fs74.readFileSync(machineFile2, "utf8")).id;
|
|
58102
58292
|
} catch {
|
|
58103
58293
|
machine = crypto6.randomUUID();
|
|
58104
|
-
|
|
58105
|
-
|
|
58294
|
+
fs74.mkdirSync(home3, { recursive: true });
|
|
58295
|
+
fs74.writeFileSync(machineFile2, JSON.stringify({ id: machine }));
|
|
58106
58296
|
}
|
|
58107
58297
|
const held4 = await request("GET", `/v1/runner/folders?machine=${encodeURIComponent(machine)}`);
|
|
58108
|
-
const cwd =
|
|
58298
|
+
const cwd = fs74.realpathSync(process.cwd());
|
|
58109
58299
|
const folder2 = held4.folders.filter((f) => {
|
|
58110
58300
|
try {
|
|
58111
|
-
const dir =
|
|
58301
|
+
const dir = fs74.realpathSync(f.path);
|
|
58112
58302
|
return cwd === dir || cwd.startsWith(dir + path74.sep);
|
|
58113
58303
|
} catch {
|
|
58114
58304
|
return false;
|
|
@@ -58422,7 +58612,7 @@ var init_agent = __esm({
|
|
|
58422
58612
|
|
|
58423
58613
|
// ../cli/src/commands/cloud-template.ts
|
|
58424
58614
|
import { createHash as createHash5 } from "node:crypto";
|
|
58425
|
-
import
|
|
58615
|
+
import fs75 from "node:fs";
|
|
58426
58616
|
import path75 from "node:path";
|
|
58427
58617
|
function usage2(problem, line) {
|
|
58428
58618
|
die(`${problem}
|
|
@@ -58487,9 +58677,9 @@ async function downloadEntries(name, kind, files, to, fallback) {
|
|
|
58487
58677
|
if (file2.sha256 && createHash5("sha256").update(bytes2).digest("hex") !== file2.sha256) refuse4(T.corrupt, fallback, invalidResponse(expected));
|
|
58488
58678
|
fetched.push({ out, bytes: bytes2 });
|
|
58489
58679
|
}
|
|
58490
|
-
if (fetched.length)
|
|
58680
|
+
if (fetched.length) fs75.mkdirSync(to, { recursive: true });
|
|
58491
58681
|
return fetched.map(({ out, bytes: bytes2 }) => {
|
|
58492
|
-
|
|
58682
|
+
fs75.writeFileSync(out, bytes2);
|
|
58493
58683
|
say(out);
|
|
58494
58684
|
return out;
|
|
58495
58685
|
});
|
|
@@ -58562,7 +58752,7 @@ async function templateGet(name, opts, program2) {
|
|
|
58562
58752
|
}
|
|
58563
58753
|
fetched.push({ out, bytes: bytes2 });
|
|
58564
58754
|
}
|
|
58565
|
-
const taken = fetched.filter((f) =>
|
|
58755
|
+
const taken = fetched.filter((f) => fs75.existsSync(f.out)).map((f) => path75.relative(to, f.out));
|
|
58566
58756
|
if (taken.length > 0) {
|
|
58567
58757
|
refuse4({
|
|
58568
58758
|
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`,
|
|
@@ -58570,8 +58760,8 @@ async function templateGet(name, opts, program2) {
|
|
|
58570
58760
|
});
|
|
58571
58761
|
}
|
|
58572
58762
|
for (const f of fetched) {
|
|
58573
|
-
|
|
58574
|
-
|
|
58763
|
+
fs75.mkdirSync(path75.dirname(f.out), { recursive: true });
|
|
58764
|
+
fs75.writeFileSync(f.out, f.bytes);
|
|
58575
58765
|
}
|
|
58576
58766
|
say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
|
|
58577
58767
|
Fetched ${name}: ${fetched.length} files into ${to}`);
|
|
@@ -58593,13 +58783,13 @@ async function templateSource(name, opts) {
|
|
|
58593
58783
|
async function templatePublish(dir, opts) {
|
|
58594
58784
|
const root2 = path75.resolve(dir);
|
|
58595
58785
|
const manifest = path75.join(root2, "template.md");
|
|
58596
|
-
if (!
|
|
58597
|
-
const meta3 = readTemplateMeta(
|
|
58786
|
+
if (!fs75.existsSync(manifest)) invalid2("\u6587\u4EF6\u5939\u9876\u5C42\u7F3A\u5C11 template.md\u3002", "template.md is missing from the folder\u2019s top level.");
|
|
58787
|
+
const meta3 = readTemplateMeta(fs75.readFileSync(manifest, "utf8"));
|
|
58598
58788
|
const files = walk2(root2);
|
|
58599
|
-
const total = files.reduce((sum, f) => sum +
|
|
58789
|
+
const total = files.reduce((sum, f) => sum + fs75.statSync(path75.join(root2, f)).size, 0);
|
|
58600
58790
|
if (total > MAX_BYTES2) invalid2("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
|
|
58601
58791
|
for (const extra of [...opts.preview, ...opts.evidence]) {
|
|
58602
|
-
if (!
|
|
58792
|
+
if (!fs75.existsSync(extra)) invalid2(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
|
|
58603
58793
|
if (path75.resolve(extra).startsWith(root2 + path75.sep)) {
|
|
58604
58794
|
invalid2(
|
|
58605
58795
|
`${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`,
|
|
@@ -58612,7 +58802,7 @@ async function templatePublish(dir, opts) {
|
|
|
58612
58802
|
}
|
|
58613
58803
|
const form = new FormData();
|
|
58614
58804
|
form.set("meta", JSON.stringify({ ...meta3, replace: !!opts.replace }));
|
|
58615
|
-
const add2 = (kind, name, file2) => form.append(`${kind}:${name}`, new Blob([
|
|
58805
|
+
const add2 = (kind, name, file2) => form.append(`${kind}:${name}`, new Blob([fs75.readFileSync(file2)]), path75.basename(name));
|
|
58616
58806
|
for (const f of files) add2("files", f, path75.join(root2, f));
|
|
58617
58807
|
for (const f of opts.preview) add2("previews", path75.basename(f), f);
|
|
58618
58808
|
for (const f of opts.evidence) add2("evidence", path75.basename(f), f);
|
|
@@ -58640,10 +58830,10 @@ Deleted ${name} from the catalog.`);
|
|
|
58640
58830
|
}
|
|
58641
58831
|
async function templateShowcase(name, dir) {
|
|
58642
58832
|
const file2 = path75.join(dir, "showcase.json");
|
|
58643
|
-
if (!
|
|
58833
|
+
if (!fs75.existsSync(file2)) invalid2(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
|
|
58644
58834
|
let meta3;
|
|
58645
58835
|
try {
|
|
58646
|
-
meta3 = JSON.parse(
|
|
58836
|
+
meta3 = JSON.parse(fs75.readFileSync(file2, "utf8"));
|
|
58647
58837
|
} catch {
|
|
58648
58838
|
return invalid2("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
|
|
58649
58839
|
}
|
|
@@ -58656,8 +58846,8 @@ async function templateShowcase(name, dir) {
|
|
|
58656
58846
|
form.set("meta", JSON.stringify(meta3));
|
|
58657
58847
|
for (const p of new Set(named2)) {
|
|
58658
58848
|
const at = path75.join(dir, p);
|
|
58659
|
-
if (!
|
|
58660
|
-
form.append(`media:${p}`, new Blob([
|
|
58849
|
+
if (!fs75.existsSync(at)) invalid2(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at}\u3002`, `${at} does not exist.`);
|
|
58850
|
+
form.append(`media:${p}`, new Blob([fs75.readFileSync(at)]), p);
|
|
58661
58851
|
}
|
|
58662
58852
|
const done = requireResponse(
|
|
58663
58853
|
await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form })),
|
|
@@ -58670,7 +58860,7 @@ Updated ${name}'s showcase: ${done.files} files.`);
|
|
|
58670
58860
|
}
|
|
58671
58861
|
function walk2(root2, sub = "") {
|
|
58672
58862
|
const out = [];
|
|
58673
|
-
for (const entry of
|
|
58863
|
+
for (const entry of fs75.readdirSync(path75.join(root2, sub), { withFileTypes: true })) {
|
|
58674
58864
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
58675
58865
|
const rel3 = sub ? `${sub}/${entry.name}` : entry.name;
|
|
58676
58866
|
if (entry.isDirectory()) out.push(...walk2(root2, rel3));
|
|
@@ -63161,7 +63351,7 @@ var init_guide2 = __esm({
|
|
|
63161
63351
|
|
|
63162
63352
|
// ../cli/src/commands/studio.ts
|
|
63163
63353
|
import crypto7 from "node:crypto";
|
|
63164
|
-
import
|
|
63354
|
+
import fs76 from "node:fs";
|
|
63165
63355
|
import path76 from "node:path";
|
|
63166
63356
|
function cmdStudioList() {
|
|
63167
63357
|
if (!studiosReachable().ok) die(NEEDS_CLOUD, "needs-cloud");
|
|
@@ -63180,7 +63370,7 @@ function cmdStudioDiagram(_id, _card, _folder) {
|
|
|
63180
63370
|
}
|
|
63181
63371
|
function cmdStudioValidate(folder2) {
|
|
63182
63372
|
const dir = path76.resolve(folder2);
|
|
63183
|
-
if (!
|
|
63373
|
+
if (!fs76.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder2} is not a folder`, "bad-args");
|
|
63184
63374
|
const files = readStudioFolder(dir);
|
|
63185
63375
|
let builtin = false;
|
|
63186
63376
|
try {
|
|
@@ -63202,7 +63392,7 @@ async function cmdStudioPull(id2, folder2) {
|
|
|
63202
63392
|
found(id2);
|
|
63203
63393
|
}
|
|
63204
63394
|
const dir = path76.resolve(folder2 ?? id2);
|
|
63205
|
-
if (
|
|
63395
|
+
if (fs76.existsSync(dir) && fs76.readdirSync(dir).length) die(`${folder2 ?? id2} is not empty`, "bad-args");
|
|
63206
63396
|
const read5 = await call("GET", `/v1/studios/${encodeURIComponent(cloudId)}`);
|
|
63207
63397
|
const { version: version2, files } = requireResponse(
|
|
63208
63398
|
cloudOk(read5, read5.ok || read5.code !== "not_found" ? void 0 : "no-such-studio"),
|
|
@@ -63211,9 +63401,9 @@ async function cmdStudioPull(id2, folder2) {
|
|
|
63211
63401
|
);
|
|
63212
63402
|
for (const [file2, text5] of Object.entries({ ...files, [VERSION_FILE]: versionText(cloudId, version2) })) {
|
|
63213
63403
|
const full = path76.join(dir, ...file2.split("/"));
|
|
63214
|
-
|
|
63404
|
+
fs76.mkdirSync(path76.dirname(full), { recursive: true });
|
|
63215
63405
|
const data = isAboutFile(file2) && !file2.endsWith(".md") && /^data:[^;]+;base64,/.exec(text5);
|
|
63216
|
-
|
|
63406
|
+
fs76.writeFileSync(full, data ? Buffer.from(text5.slice(data[0].length), "base64") : text5);
|
|
63217
63407
|
}
|
|
63218
63408
|
const shown = folder2 ?? `./${id2}`;
|
|
63219
63409
|
say(`Pulled ${id2} v${version2} into ${shown}.`);
|
|
@@ -63229,13 +63419,13 @@ async function publishFolder(dir, route2, body, requestId) {
|
|
|
63229
63419
|
const hash3 = crypto7.createHash("sha256").update(JSON.stringify({ route: route2, files: body.files, workspace: body.workspace })).digest("hex");
|
|
63230
63420
|
let held4;
|
|
63231
63421
|
try {
|
|
63232
|
-
held4 = JSON.parse(
|
|
63422
|
+
held4 = JSON.parse(fs76.readFileSync(pendingFile, "utf8"));
|
|
63233
63423
|
} catch {
|
|
63234
63424
|
}
|
|
63235
63425
|
if (requestId && held4?.requestId === requestId && held4.hash !== hash3) die("This request ID already names different files; use a new request ID.", "bad-args");
|
|
63236
63426
|
const replay = held4?.hash === hash3 && held4.route === route2 && (!requestId || held4.requestId === requestId) && (body.expectedVersion === held4.body.expectedVersion || body.expectedVersion === held4.resultVersion);
|
|
63237
63427
|
const pending = replay ? held4 : { requestId: requestId ?? crypto7.randomUUID(), hash: hash3, body, route: route2 };
|
|
63238
|
-
|
|
63428
|
+
fs76.writeFileSync(pendingFile, JSON.stringify(pending, null, 2) + "\n");
|
|
63239
63429
|
const res = await call(route2 === "/v1/studios" ? "POST" : "PATCH", route2, pending.body, pending.requestId);
|
|
63240
63430
|
const { id: id2, version: version2 } = requireResponse(
|
|
63241
63431
|
cloudOk(res, !res.ok && ["version_conflict", "conflict"].includes(res.code ?? "") ? "studio-moved" : void 0),
|
|
@@ -63243,8 +63433,8 @@ async function publishFolder(dir, route2, body, requestId) {
|
|
|
63243
63433
|
(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)
|
|
63244
63434
|
);
|
|
63245
63435
|
pending.resultVersion = version2;
|
|
63246
|
-
|
|
63247
|
-
|
|
63436
|
+
fs76.writeFileSync(pendingFile, JSON.stringify(pending, null, 2) + "\n");
|
|
63437
|
+
fs76.writeFileSync(path76.join(dir, VERSION_FILE), versionText(id2, version2));
|
|
63248
63438
|
say(`Saved ${studioName(id2)} v${version2}. New tasks take it.`);
|
|
63249
63439
|
return { id: id2, version: version2, changed: true, requestId: pending.requestId };
|
|
63250
63440
|
}
|
|
@@ -63259,14 +63449,14 @@ async function cmdStudioPush(folder2, opts) {
|
|
|
63259
63449
|
const dir = path76.resolve(folder2);
|
|
63260
63450
|
let pulled = null;
|
|
63261
63451
|
try {
|
|
63262
|
-
pulled = JSON.parse(
|
|
63452
|
+
pulled = JSON.parse(fs76.readFileSync(path76.join(dir, VERSION_FILE), "utf8"));
|
|
63263
63453
|
} catch {
|
|
63264
63454
|
}
|
|
63265
63455
|
if (!pulled?.id || !Number.isInteger(pulled.version) || pulled.version < 1) die(`${folder2} has no valid version.json; pull again.`, "bad-args");
|
|
63266
63456
|
const { id: id2, version: version2 } = pulled;
|
|
63267
63457
|
if (id2.startsWith("wf_builtin_")) die("Copy this studio before editing it.", "studio-read-only");
|
|
63268
63458
|
const files = publicationFiles(dir);
|
|
63269
|
-
if (!
|
|
63459
|
+
if (!fs76.existsSync(path76.join(dir, ".publication.json")) && !opts.requestId) {
|
|
63270
63460
|
const now = await call("GET", `/v1/studios/${encodeURIComponent(id2)}`);
|
|
63271
63461
|
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()))) {
|
|
63272
63462
|
say(`${studioName(id2)} is unchanged (v${version2}).`);
|
|
@@ -63289,7 +63479,7 @@ function noteText({ file: file2, text: text5 }) {
|
|
|
63289
63479
|
if (file2 !== void 0 && text5 !== void 0) die("pass --file or --text, not both", "bad-args");
|
|
63290
63480
|
if (file2 !== void 0) {
|
|
63291
63481
|
try {
|
|
63292
|
-
return
|
|
63482
|
+
return fs76.readFileSync(file2, "utf8").trim();
|
|
63293
63483
|
} catch {
|
|
63294
63484
|
die(`can't read ${file2}`, "bad-args");
|
|
63295
63485
|
}
|
|
@@ -63475,7 +63665,7 @@ var init_progress = __esm({
|
|
|
63475
63665
|
});
|
|
63476
63666
|
|
|
63477
63667
|
// ../cli/src/lib/agent/complete.ts
|
|
63478
|
-
import
|
|
63668
|
+
import fs77 from "node:fs";
|
|
63479
63669
|
function checkRecordedResult(receipt, commit, branch) {
|
|
63480
63670
|
if (receipt.commit === commit && receipt.branch === branch) return;
|
|
63481
63671
|
const describe4 = (hash3, target) => hash3 ? `${hash3} on ${target}` : "no Git result";
|
|
@@ -63503,7 +63693,7 @@ function completeDelivery(named2, result = {}) {
|
|
|
63503
63693
|
const run3 = store.runs.find((r) => r.sessionId === sessionId);
|
|
63504
63694
|
const current = store.runs.filter((r) => r.deliveryId === delivery2.deliveryId && ["implement", "scheduled"].includes(r.action)).pop();
|
|
63505
63695
|
const liveCard = delivery2.cardId === null ? null : cardFile(delivery2.cardId);
|
|
63506
|
-
const restored = liveCard && parseFrontmatter(
|
|
63696
|
+
const restored = liveCard && parseFrontmatter(fs77.readFileSync(liveCard, "utf8")).meta?.restored;
|
|
63507
63697
|
if (restored && Date.parse(restored) > (run3?.startedAt ?? 0)) throw new Error("This delivery predates task restoration.");
|
|
63508
63698
|
if (!run3 || run3.deliveryId !== delivery2.deliveryId) throw new Error("This run does not own the delivery.");
|
|
63509
63699
|
const pending = receipts[deliveryStep(delivery2)];
|
|
@@ -63611,7 +63801,7 @@ function startSubRun(parentId, prompt, runtime) {
|
|
|
63611
63801
|
const parent = peekRun(parentId);
|
|
63612
63802
|
if (!parent || parent.status !== "running") return refusal("runNotFound", `run ${parentId.slice(0, 8)} is not running here`, { id: parentId });
|
|
63613
63803
|
if (parent.action === "sub") return refusal("subRunNested", "a sub-run cannot start sub-runs of its own");
|
|
63614
|
-
const inherited = parent.runtime &&
|
|
63804
|
+
const inherited = parent.runtime && runRuntimeById(parent.runtime) ? parent.runtime : void 0;
|
|
63615
63805
|
return open3(
|
|
63616
63806
|
{
|
|
63617
63807
|
action: "sub",
|
|
@@ -63674,7 +63864,7 @@ var init_start = __esm({
|
|
|
63674
63864
|
});
|
|
63675
63865
|
|
|
63676
63866
|
// ../cli/src/lib/agent/task-chats.ts
|
|
63677
|
-
import
|
|
63867
|
+
import fs78 from "node:fs";
|
|
63678
63868
|
import path77 from "node:path";
|
|
63679
63869
|
function taskChatFile(task, home3) {
|
|
63680
63870
|
if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
|
|
@@ -63683,7 +63873,7 @@ function taskChatFile(task, home3) {
|
|
|
63683
63873
|
function readTaskChat(task, home3) {
|
|
63684
63874
|
let text5;
|
|
63685
63875
|
try {
|
|
63686
|
-
text5 =
|
|
63876
|
+
text5 = fs78.readFileSync(taskChatFile(task, home3), "utf8");
|
|
63687
63877
|
} catch {
|
|
63688
63878
|
return [];
|
|
63689
63879
|
}
|
|
@@ -63709,7 +63899,7 @@ var init_task_chats = __esm({
|
|
|
63709
63899
|
});
|
|
63710
63900
|
|
|
63711
63901
|
// ../cli/src/lib/agent/memory-review.ts
|
|
63712
|
-
import
|
|
63902
|
+
import fs79 from "node:fs";
|
|
63713
63903
|
import path78 from "node:path";
|
|
63714
63904
|
function taskChatsToReview(tasks) {
|
|
63715
63905
|
const out = [];
|
|
@@ -63733,7 +63923,7 @@ function readArchived2(id2) {
|
|
|
63733
63923
|
if (!found2) return null;
|
|
63734
63924
|
try {
|
|
63735
63925
|
const file2 = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
|
|
63736
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
63926
|
+
const { meta: meta3, body } = parseFrontmatter(fs79.readFileSync(file2, "utf8"));
|
|
63737
63927
|
if (!meta3) return null;
|
|
63738
63928
|
return { id: id2, title: meta3.title, modules: meta3.modules ?? [], studio: meta3.studio ?? "", previews: meta3.previews ?? [], rejected: meta3.rejected, body };
|
|
63739
63929
|
} catch {
|
|
@@ -63794,18 +63984,18 @@ var init_memory_review = __esm({
|
|
|
63794
63984
|
});
|
|
63795
63985
|
|
|
63796
63986
|
// ../cli/src/lib/agent/dismissal-review.ts
|
|
63797
|
-
import
|
|
63987
|
+
import fs80 from "node:fs";
|
|
63798
63988
|
import path79 from "node:path";
|
|
63799
63989
|
function rejectionsToReview() {
|
|
63800
63990
|
const scratch = process.env.AI4KANBAN_REJECTION_INPUT;
|
|
63801
63991
|
const dir = path79.join(scratch ? path79.join(scratch, ".archive") : ARCHIVE, REJECTIONS_TO_REVIEW);
|
|
63802
|
-
if (!
|
|
63992
|
+
if (!fs80.existsSync(dir)) return [];
|
|
63803
63993
|
const found2 = [];
|
|
63804
63994
|
for (const file2 of walkMd(dir)) {
|
|
63805
63995
|
const id2 = archivedId(file2);
|
|
63806
63996
|
if (id2 === null) continue;
|
|
63807
63997
|
try {
|
|
63808
|
-
const { meta: meta3 } = parseFrontmatter(
|
|
63998
|
+
const { meta: meta3 } = parseFrontmatter(fs80.readFileSync(file2, "utf8"));
|
|
63809
63999
|
if (!meta3?.rejected || meta3.rejected_by !== "user" || !meta3.rejected_reason.trim()) continue;
|
|
63810
64000
|
found2.push({ id: id2, title: meta3.title, file: rel(file2), reason: meta3.rejected_reason.trim(), rejectedAt: meta3.rejected_at });
|
|
63811
64001
|
} catch {
|
|
@@ -63827,7 +64017,7 @@ function citedSources(text5) {
|
|
|
63827
64017
|
const ids = /* @__PURE__ */ new Set();
|
|
63828
64018
|
for (const line of text5.split("\n")) {
|
|
63829
64019
|
if (!/^\s*[-*]\s/.test(line)) continue;
|
|
63830
|
-
const m = line.match(
|
|
64020
|
+
const m = line.match(SOURCES2);
|
|
63831
64021
|
for (const id2 of m?.[1].split(",") ?? []) if (id2.trim()) ids.add(id2.trim());
|
|
63832
64022
|
}
|
|
63833
64023
|
return [...ids];
|
|
@@ -63835,7 +64025,7 @@ function citedSources(text5) {
|
|
|
63835
64025
|
function withdrawnSources() {
|
|
63836
64026
|
const cited = [...new Set(plannerCopies("rejected.md").flatMap((file2) => {
|
|
63837
64027
|
try {
|
|
63838
|
-
return citedSources(
|
|
64028
|
+
return citedSources(fs80.readFileSync(file2, "utf8"));
|
|
63839
64029
|
} catch {
|
|
63840
64030
|
return [];
|
|
63841
64031
|
}
|
|
@@ -63846,7 +64036,7 @@ function withdrawnSources() {
|
|
|
63846
64036
|
const restored = new Set([...readInbox(), ...readArchived(scratch ? path79.join(scratch, "triage", "archived") : void 0)].map((s) => s.sourceId));
|
|
63847
64037
|
return cited.filter((id2) => restored.has(id2) && !dismissed.has(id2));
|
|
63848
64038
|
}
|
|
63849
|
-
var reviewDismissed,
|
|
64039
|
+
var reviewDismissed, SOURCES2;
|
|
63850
64040
|
var init_dismissal_review = __esm({
|
|
63851
64041
|
"../cli/src/lib/agent/dismissal-review.ts"() {
|
|
63852
64042
|
"use strict";
|
|
@@ -63860,12 +64050,12 @@ var init_dismissal_review = __esm({
|
|
|
63860
64050
|
const scratch = process.env.AI4KANBAN_REJECTION_INPUT;
|
|
63861
64051
|
return readAllDismissed(scratch ? path79.join(scratch, "triage", "dismissed") : void 0);
|
|
63862
64052
|
};
|
|
63863
|
-
|
|
64053
|
+
SOURCES2 = /\(([^()]+)\)\s*$/;
|
|
63864
64054
|
}
|
|
63865
64055
|
});
|
|
63866
64056
|
|
|
63867
64057
|
// ../cli/src/lib/agent/flow.ts
|
|
63868
|
-
import
|
|
64058
|
+
import fs81 from "node:fs";
|
|
63869
64059
|
import path80 from "node:path";
|
|
63870
64060
|
function readCard2(id2, home3 = "board") {
|
|
63871
64061
|
const pending = activeDelivery(id2)?.completions?.some((c) => !c.finished);
|
|
@@ -63879,7 +64069,7 @@ function readCard2(id2, home3 = "board") {
|
|
|
63879
64069
|
const file2 = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
|
|
63880
64070
|
let text5;
|
|
63881
64071
|
try {
|
|
63882
|
-
text5 =
|
|
64072
|
+
text5 = fs81.readFileSync(file2, "utf8");
|
|
63883
64073
|
} catch {
|
|
63884
64074
|
die(`#${id2} is on the board but ${rel(file2)} can't be read.`, { kind: "card-unreadable", id: id2 });
|
|
63885
64075
|
}
|
|
@@ -64724,7 +64914,7 @@ __export(watch_exports, {
|
|
|
64724
64914
|
watchRun: () => watchRun
|
|
64725
64915
|
});
|
|
64726
64916
|
import { spawn as spawn3 } from "node:child_process";
|
|
64727
|
-
import
|
|
64917
|
+
import fs82 from "node:fs";
|
|
64728
64918
|
async function watchRun(sessionId, resume = startResume, retryBackoff = backoffMs) {
|
|
64729
64919
|
const spec = readSpec(sessionId);
|
|
64730
64920
|
const run3 = peekRun(sessionId);
|
|
@@ -64760,20 +64950,24 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
64760
64950
|
const record2 = claimed ?? run3;
|
|
64761
64951
|
const sub = record2.action === "sub";
|
|
64762
64952
|
if (claim2) await setCardStatus(claim2.cardId, claim2.status);
|
|
64763
|
-
|
|
64764
|
-
const logFile =
|
|
64953
|
+
fs82.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
64954
|
+
const logFile = fs82.createWriteStream(record2.logPath, { flags: "a" });
|
|
64765
64955
|
logFile.on("error", () => {
|
|
64766
64956
|
});
|
|
64767
|
-
const eventsFile =
|
|
64957
|
+
const eventsFile = fs82.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
|
|
64768
64958
|
eventsFile.on("error", () => {
|
|
64769
64959
|
});
|
|
64770
64960
|
let observeActivity = (_e) => {
|
|
64771
64961
|
};
|
|
64772
64962
|
const pendingOperations = /* @__PURE__ */ new Set();
|
|
64963
|
+
let hadEffects = false;
|
|
64773
64964
|
const event2 = (e) => {
|
|
64774
64965
|
observeActivity(e);
|
|
64775
64966
|
const hadPending = pendingOperations.size > 0;
|
|
64776
|
-
if (e.kind === "tool_call" && !["read", "search", "fetch"].includes(e.data.kind)
|
|
64967
|
+
if (e.kind === "tool_call" && !["read", "search", "fetch"].includes(e.data.kind)) {
|
|
64968
|
+
hadEffects = true;
|
|
64969
|
+
if (!["completed", "failed"].includes(e.data.status)) pendingOperations.add(e.data.toolCallId);
|
|
64970
|
+
}
|
|
64777
64971
|
if ((e.kind === "tool_call" || e.kind === "tool_call_update") && ["completed", "failed"].includes(e.data.status ?? "")) pendingOperations.delete(e.data.toolCallId);
|
|
64778
64972
|
if (record2.cloudExecution && hadPending !== pendingOperations.size > 0) {
|
|
64779
64973
|
patch(sessionId, (run4) => {
|
|
@@ -64783,6 +64977,11 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
64783
64977
|
eventsFile.write(`${JSON.stringify(e)}
|
|
64784
64978
|
`);
|
|
64785
64979
|
};
|
|
64980
|
+
const runtimeInfo = () => ({
|
|
64981
|
+
connector: record2.harness,
|
|
64982
|
+
name: record2.runtime ? runtimeById(record2.runtime)?.name ?? null : null,
|
|
64983
|
+
model: peekRun(sessionId)?.model ?? record2.model ?? null
|
|
64984
|
+
});
|
|
64786
64985
|
const log = {
|
|
64787
64986
|
write(text5) {
|
|
64788
64987
|
logFile.write(text5);
|
|
@@ -64817,7 +65016,8 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
64817
65016
|
`Read the saved task Previews and their pinned files in \`${savedPreviews}\`. Use these saved versions for the requirements they cover and verify the delivery against them.`,
|
|
64818
65017
|
...coding && !approvedUi && review?.plan?.some((node2) => node2.previews.includes("ui-design")) ? [APPROVED_UI_RULE] : []
|
|
64819
65018
|
].join("\n") : "";
|
|
64820
|
-
const
|
|
65019
|
+
const retryDiag = record2.retry ? record2.failure ? retryContinuePrompt(record2.failure, record2.retry.attempt, record2.retry.of) : `Previous execution failed: ${record2.retry.reason}. Check existing results before continuing; do not repeat completed operations.` : "";
|
|
65020
|
+
const prompt = [process.env.AI4KANBAN_SYNC_DIAGNOSTIC ? syncRepairPrompt(process.env.AI4KANBAN_SYNC_DIAGNOSTIC) : "", retryDiag, conflictPrompt(KANBAN), boundary, basePrompt, resumedStudio, savedPrompt, approvedUi, recoveryPrompt2, discardedCardsPrompt(record2.discardedCards)].filter(Boolean).join("\n\n");
|
|
64821
65021
|
const before = markBoard();
|
|
64822
65022
|
const takes = active3.images;
|
|
64823
65023
|
active3.renderer?.setRequiredImages?.(record2.pictures ?? []);
|
|
@@ -64845,11 +65045,29 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
64845
65045
|
letGo();
|
|
64846
65046
|
return 1;
|
|
64847
65047
|
}
|
|
64848
|
-
if (record2.retry?.launching)
|
|
64849
|
-
|
|
64850
|
-
r
|
|
64851
|
-
|
|
64852
|
-
|
|
65048
|
+
if (record2.retry?.launching) {
|
|
65049
|
+
const nextAttempt = record2.retry.attempt + 1;
|
|
65050
|
+
patch(sessionId, (r) => {
|
|
65051
|
+
if (!r.retry?.launching) return;
|
|
65052
|
+
r.retry.attempt++;
|
|
65053
|
+
delete r.retry.launching;
|
|
65054
|
+
});
|
|
65055
|
+
event2({
|
|
65056
|
+
kind: "retry",
|
|
65057
|
+
data: {
|
|
65058
|
+
state: "retrying",
|
|
65059
|
+
source: record2.failure?.source ?? "runtime",
|
|
65060
|
+
runtime: runtimeInfo(),
|
|
65061
|
+
attempt: nextAttempt,
|
|
65062
|
+
maxAttempts: record2.retry.of,
|
|
65063
|
+
summary: record2.failure?.summary ?? record2.retry.reason,
|
|
65064
|
+
...record2.failure?.detail ? { detail: record2.failure.detail } : {},
|
|
65065
|
+
...record2.failure?.code ? { code: record2.failure.code } : {},
|
|
65066
|
+
sessionAction: record2.resumedFrom ? "resume" : "reset_replay",
|
|
65067
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
65068
|
+
}
|
|
65069
|
+
});
|
|
65070
|
+
}
|
|
64853
65071
|
try {
|
|
64854
65072
|
const start = spawnable(cmd, client || stdinPrompt ? args2 : [...args2, prompt], {
|
|
64855
65073
|
// Where this run works: the project, or — inside a delivery with a worktree of its
|
|
@@ -65033,34 +65251,79 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
65033
65251
|
const rendered = renderer?.failure?.() ?? (!taskCompleted && renderer?.background?.() ? "The agent exited with unfinished background tasks." : void 0);
|
|
65034
65252
|
const said2 = spawnError ?? (silent ? silenceSaid(silenceFor) : spoken?.error ?? rendered);
|
|
65035
65253
|
const failed2 = code !== 0 || spoken?.ok === false || !!rendered || silent || !!blocker;
|
|
65036
|
-
const failure2 = failed2 && !asked ? silent ? {
|
|
65254
|
+
const failure2 = failed2 && !asked ? silent ? makeFailure("runtime", said2 ?? IDLE_FAILURE.summary, { code: IDLE_FAILURE.code, detail: said2 ?? IDLE_FAILURE.summary }) : spawnFailure ?? spoken?.failure ?? renderer?.executionFailure?.() ?? (!blocker ? held4.validationFailure : void 0) ?? makeFailure("runtime", said2 ?? blocker?.cause ?? `Agent exited with code ${code}.`, {
|
|
65255
|
+
code: blocker ? "execution_blocked" : "execution_failed",
|
|
65256
|
+
detail: said2 ?? blocker?.cause ?? `Agent exited with code ${code}.`
|
|
65257
|
+
}) : void 0;
|
|
65037
65258
|
const result = spoken ? spoken.result : renderer?.result();
|
|
65038
65259
|
let retryPause;
|
|
65039
65260
|
let retrying = false;
|
|
65261
|
+
let retryHistory = held4.retryHistory ? [...held4.retryHistory] : void 0;
|
|
65262
|
+
let sessionAction;
|
|
65040
65263
|
if (failure2 && !sub && !taskCompleted) {
|
|
65041
65264
|
const attempt2 = held4.retry?.attempt ?? 1;
|
|
65042
|
-
const
|
|
65043
|
-
|
|
65044
|
-
|
|
65045
|
-
|
|
65046
|
-
|
|
65047
|
-
|
|
65048
|
-
|
|
65049
|
-
|
|
65050
|
-
|
|
65051
|
-
|
|
65052
|
-
|
|
65053
|
-
|
|
65054
|
-
|
|
65055
|
-
|
|
65056
|
-
|
|
65057
|
-
|
|
65058
|
-
|
|
65059
|
-
|
|
65265
|
+
const missingSession = isSessionMissingFailure(failure2);
|
|
65266
|
+
const mark = runMark(sessionId, agentStartedAt);
|
|
65267
|
+
const root2 = child.pid ? { pid: child.pid, since: agentStartedAt, identity: held4.agentIdentity } : void 0;
|
|
65268
|
+
const stopped3 = () => client?.managedProcess ? connectionStopped(root2) : processesStopped(mark, root2);
|
|
65269
|
+
const until = Date.now() + STOP_GRACE_MS + STOP_CLOSE_MS;
|
|
65270
|
+
while (!stopped3() && Date.now() < until) await sleep4(100);
|
|
65271
|
+
const isStopped = stopped3();
|
|
65272
|
+
const session = structured && !spawnFailure && !missingSession ? resumeSessionId(held4) : void 0;
|
|
65273
|
+
const unconfirmedCleanup = pendingOperations.size > 0 || !!blocker || spoken?.cleanup?.status === "unconfirmed" || failure2.code === "codex_ownership_unconfirmed" || client?.managedProcess && silent && (uncertainAtIdle || !idleStopConfirmed(spoken?.cleanup, session));
|
|
65274
|
+
const canResetReplay = isStopped && !unconfirmedCleanup && !pendingOperations.size && (held4.unspawned === true || structured && !hadEffects && !record2.resumedFrom);
|
|
65275
|
+
const recovery = missingSession ? canResetReplay ? "replay" : "unsafe" : agentRecovery({
|
|
65276
|
+
stopped: isStopped,
|
|
65277
|
+
session,
|
|
65278
|
+
replayable: canResetReplay,
|
|
65279
|
+
unconfirmedCleanup
|
|
65280
|
+
});
|
|
65281
|
+
sessionAction = recovery === "unsafe" ? "pause_unsafe" : recovery === "replay" ? "reset_replay" : "resume";
|
|
65282
|
+
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
65283
|
+
const retryRecord = {
|
|
65284
|
+
attempt: attempt2,
|
|
65285
|
+
source: failure2.source,
|
|
65286
|
+
runtime: runtimeInfo(),
|
|
65287
|
+
summary: failure2.summary,
|
|
65288
|
+
...failure2.detail ? { detail: failure2.detail } : {},
|
|
65289
|
+
...failure2.code ? { code: failure2.code } : {},
|
|
65290
|
+
sessionAction,
|
|
65291
|
+
at: nowIso
|
|
65292
|
+
};
|
|
65293
|
+
retryHistory = [...retryHistory ?? [], retryRecord];
|
|
65294
|
+
if (recovery === "unsafe") {
|
|
65295
|
+
retryPause = "unsafe";
|
|
65296
|
+
} else {
|
|
65297
|
+
const decision = planRetry(failure2, attempt2, Date.now(), retryBackoff, !!held4.cloudExecution);
|
|
65298
|
+
if ("pause" in decision) {
|
|
65299
|
+
retryPause = decision.pause;
|
|
65300
|
+
} else {
|
|
65301
|
+
const pending = { ...decision.plan, sessionAction };
|
|
65060
65302
|
patch(sessionId, (r) => {
|
|
65061
65303
|
r.failure = failure2;
|
|
65062
|
-
r.error = said2 ?? failure2.
|
|
65063
|
-
r.
|
|
65304
|
+
r.error = said2 ?? failure2.summary;
|
|
65305
|
+
r.retryHistory = retryHistory;
|
|
65306
|
+
if (sessionAction === "reset_replay") {
|
|
65307
|
+
r.resumeId = void 0;
|
|
65308
|
+
r.unspawned = true;
|
|
65309
|
+
}
|
|
65310
|
+
r.retry = { attempt: attempt2, of: pending.of, reason: failure2.summary, at: pending.at, since: held4.retry?.since ?? held4.startedAt, pending };
|
|
65311
|
+
});
|
|
65312
|
+
event2({
|
|
65313
|
+
kind: "retry",
|
|
65314
|
+
data: {
|
|
65315
|
+
state: "waiting",
|
|
65316
|
+
source: failure2.source,
|
|
65317
|
+
runtime: runtimeInfo(),
|
|
65318
|
+
attempt: attempt2 + 1,
|
|
65319
|
+
maxAttempts: pending.of,
|
|
65320
|
+
summary: failure2.summary,
|
|
65321
|
+
...failure2.detail ? { detail: failure2.detail } : {},
|
|
65322
|
+
...failure2.code ? { code: failure2.code } : {},
|
|
65323
|
+
nextRetryAt: new Date(pending.at).toISOString(),
|
|
65324
|
+
sessionAction,
|
|
65325
|
+
at: nowIso
|
|
65326
|
+
}
|
|
65064
65327
|
});
|
|
65065
65328
|
log.write(`
|
|
65066
65329
|
[board] ${retryLine(pending, attempt2)}
|
|
@@ -65069,11 +65332,44 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
65069
65332
|
retrying = true;
|
|
65070
65333
|
}
|
|
65071
65334
|
}
|
|
65335
|
+
if (retryPause && !stoppedByUser()) {
|
|
65336
|
+
event2({
|
|
65337
|
+
kind: "retry",
|
|
65338
|
+
data: {
|
|
65339
|
+
state: "paused",
|
|
65340
|
+
source: failure2.source,
|
|
65341
|
+
runtime: runtimeInfo(),
|
|
65342
|
+
attempt: attempt2,
|
|
65343
|
+
maxAttempts: held4.retry?.of ?? MAX_RETRY_ATTEMPTS,
|
|
65344
|
+
summary: failure2.summary,
|
|
65345
|
+
...failure2.detail ? { detail: failure2.detail } : {},
|
|
65346
|
+
...failure2.code ? { code: failure2.code } : {},
|
|
65347
|
+
sessionAction,
|
|
65348
|
+
at: nowIso
|
|
65349
|
+
}
|
|
65350
|
+
});
|
|
65351
|
+
}
|
|
65072
65352
|
}
|
|
65073
65353
|
asked ||= stoppedByUser();
|
|
65074
65354
|
retrying &&= !asked;
|
|
65075
|
-
const error62 = asked ? void 0 : joinNotes(said2 ?? failure2?.
|
|
65355
|
+
const error62 = asked ? void 0 : joinNotes(said2 ?? failure2?.summary, retryPause ? pauseLine(retryPause) : void 0);
|
|
65076
65356
|
const status = asked ? "stopped" : failed2 || code !== 0 ? "error" : "done";
|
|
65357
|
+
if (status === "done" && !sub && retryHistory?.length) {
|
|
65358
|
+
const lastRetry = retryHistory[retryHistory.length - 1];
|
|
65359
|
+
event2({
|
|
65360
|
+
kind: "retry",
|
|
65361
|
+
data: {
|
|
65362
|
+
state: "recovered",
|
|
65363
|
+
source: lastRetry.source,
|
|
65364
|
+
runtime: runtimeInfo(),
|
|
65365
|
+
attempt: held4.retry?.attempt ?? retryHistory.length + 1,
|
|
65366
|
+
maxAttempts: held4.retry?.of ?? MAX_RETRY_ATTEMPTS,
|
|
65367
|
+
summary: lastRetry.summary,
|
|
65368
|
+
...lastRetry.code ? { code: lastRetry.code } : {},
|
|
65369
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
65370
|
+
}
|
|
65371
|
+
});
|
|
65372
|
+
}
|
|
65077
65373
|
const reported = spoken ? spoken.costUsd : renderer?.costUsd?.();
|
|
65078
65374
|
const totals = reportsSessionTotal(record2.harness);
|
|
65079
65375
|
const sessionTotal = totals ? reported : void 0;
|
|
@@ -65136,6 +65432,7 @@ ${result}
|
|
|
65136
65432
|
error: error62,
|
|
65137
65433
|
failure: failure2,
|
|
65138
65434
|
retryPause,
|
|
65435
|
+
retryHistory,
|
|
65139
65436
|
note,
|
|
65140
65437
|
errorWhy,
|
|
65141
65438
|
noteWhy,
|
|
@@ -65328,6 +65625,7 @@ var init_watch = __esm({
|
|
|
65328
65625
|
init_idle();
|
|
65329
65626
|
init_codex_background_types();
|
|
65330
65627
|
init_retry();
|
|
65628
|
+
init_runtimes();
|
|
65331
65629
|
init_failures();
|
|
65332
65630
|
init_execution();
|
|
65333
65631
|
init_refine2();
|
|
@@ -65342,7 +65640,7 @@ var init_watch = __esm({
|
|
|
65342
65640
|
});
|
|
65343
65641
|
|
|
65344
65642
|
// ../cli/src/commands/run.ts
|
|
65345
|
-
import
|
|
65643
|
+
import fs83 from "node:fs";
|
|
65346
65644
|
import path82 from "node:path";
|
|
65347
65645
|
async function cmdStartRun(action, args2, opts, program2 = "akb") {
|
|
65348
65646
|
const { req, follow: follow2, print } = readRequest(action, args2, opts);
|
|
@@ -65569,7 +65867,7 @@ async function cmdSubStart(words, opts) {
|
|
|
65569
65867
|
let prompt = words.join(" ");
|
|
65570
65868
|
if (opts.file) {
|
|
65571
65869
|
try {
|
|
65572
|
-
prompt =
|
|
65870
|
+
prompt = fs83.readFileSync(path82.resolve(opts.file), "utf8");
|
|
65573
65871
|
} catch {
|
|
65574
65872
|
die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
|
|
65575
65873
|
}
|
|
@@ -65918,12 +66216,12 @@ var init_config3 = __esm({
|
|
|
65918
66216
|
});
|
|
65919
66217
|
|
|
65920
66218
|
// ../cli/src/lib/signals/migrate.ts
|
|
65921
|
-
import
|
|
66219
|
+
import fs84 from "node:fs";
|
|
65922
66220
|
import path83 from "node:path";
|
|
65923
66221
|
function readHandled() {
|
|
65924
66222
|
let text5;
|
|
65925
66223
|
try {
|
|
65926
|
-
text5 =
|
|
66224
|
+
text5 = fs84.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
|
|
65927
66225
|
} catch {
|
|
65928
66226
|
return [];
|
|
65929
66227
|
}
|
|
@@ -65940,45 +66238,45 @@ function readHandled() {
|
|
|
65940
66238
|
return held4;
|
|
65941
66239
|
}
|
|
65942
66240
|
function lift(from, into) {
|
|
65943
|
-
|
|
65944
|
-
|
|
66241
|
+
fs84.mkdirSync(into, { recursive: true });
|
|
66242
|
+
fs84.renameSync(from, path83.join(into, freeName(into, path83.basename(from))));
|
|
65945
66243
|
}
|
|
65946
66244
|
function repoint(dir, from, into) {
|
|
65947
66245
|
let entries2;
|
|
65948
66246
|
try {
|
|
65949
|
-
entries2 =
|
|
66247
|
+
entries2 = fs84.readdirSync(dir, { withFileTypes: true });
|
|
65950
66248
|
} catch {
|
|
65951
66249
|
return;
|
|
65952
66250
|
}
|
|
65953
66251
|
for (const entry of entries2) {
|
|
65954
66252
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
65955
66253
|
const file2 = path83.join(dir, entry.name);
|
|
65956
|
-
const text5 =
|
|
65957
|
-
if (text5.includes(from))
|
|
66254
|
+
const text5 = fs84.readFileSync(file2, "utf8");
|
|
66255
|
+
if (text5.includes(from)) fs84.writeFileSync(file2, text5.split(from).join(into));
|
|
65958
66256
|
}
|
|
65959
66257
|
}
|
|
65960
66258
|
function dropIfEmpty(dir) {
|
|
65961
66259
|
try {
|
|
65962
|
-
|
|
66260
|
+
fs84.rmdirSync(dir);
|
|
65963
66261
|
} catch {
|
|
65964
66262
|
}
|
|
65965
66263
|
}
|
|
65966
66264
|
function liftInbox() {
|
|
65967
|
-
if (!
|
|
66265
|
+
if (!fs84.existsSync(SIGNALS_OLD_INBOX)) return;
|
|
65968
66266
|
const oldFiles = path83.join(SIGNALS_OLD_INBOX, "files");
|
|
65969
|
-
if (
|
|
65970
|
-
for (const entry of
|
|
66267
|
+
if (fs84.existsSync(oldFiles)) {
|
|
66268
|
+
for (const entry of fs84.readdirSync(oldFiles, { withFileTypes: true })) {
|
|
65971
66269
|
if (entry.isFile()) lift(path83.join(oldFiles, entry.name), SIGNALS_FILES);
|
|
65972
66270
|
}
|
|
65973
66271
|
dropIfEmpty(oldFiles);
|
|
65974
66272
|
}
|
|
65975
66273
|
const held4 = new Set(readFolder(TRIAGE).map((signal2) => signal2.sourceId));
|
|
65976
|
-
for (const entry of
|
|
66274
|
+
for (const entry of fs84.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
|
|
65977
66275
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
65978
66276
|
const from = path83.join(SIGNALS_OLD_INBOX, entry.name);
|
|
65979
66277
|
const item = parse3(from);
|
|
65980
66278
|
if (item && held4.has(item.sourceId)) {
|
|
65981
|
-
|
|
66279
|
+
fs84.rmSync(from, { force: true });
|
|
65982
66280
|
continue;
|
|
65983
66281
|
}
|
|
65984
66282
|
if (item) held4.add(item.sourceId);
|
|
@@ -65990,7 +66288,7 @@ function liftInbox() {
|
|
|
65990
66288
|
dropIfEmpty(SIGNALS_OLD_INBOX);
|
|
65991
66289
|
}
|
|
65992
66290
|
function liftHandled() {
|
|
65993
|
-
if (!
|
|
66291
|
+
if (!fs84.existsSync(SIGNALS_OLD_HANDLED)) return;
|
|
65994
66292
|
const lines = readHandled();
|
|
65995
66293
|
const held4 = /* @__PURE__ */ new Set([
|
|
65996
66294
|
...readFolder(TRIAGE).map((signal2) => signal2.sourceId),
|
|
@@ -66000,7 +66298,7 @@ function liftHandled() {
|
|
|
66000
66298
|
for (const { sourceId, when } of lines) {
|
|
66001
66299
|
if (held4.has(sourceId)) continue;
|
|
66002
66300
|
held4.add(sourceId);
|
|
66003
|
-
|
|
66301
|
+
fs84.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
|
|
66004
66302
|
const name = freeName(SIGNALS_DISMISSED, fileName("", sourceId));
|
|
66005
66303
|
const front = [
|
|
66006
66304
|
"---",
|
|
@@ -66010,13 +66308,13 @@ function liftHandled() {
|
|
|
66010
66308
|
"---",
|
|
66011
66309
|
""
|
|
66012
66310
|
];
|
|
66013
|
-
|
|
66311
|
+
fs84.writeFileSync(path83.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
|
|
66014
66312
|
`);
|
|
66015
66313
|
}
|
|
66016
|
-
|
|
66314
|
+
fs84.rmSync(SIGNALS_OLD_HANDLED, { force: true });
|
|
66017
66315
|
}
|
|
66018
66316
|
function migrateTriage() {
|
|
66019
|
-
if (!
|
|
66317
|
+
if (!fs84.existsSync(SIGNALS_OLD_INBOX) && !fs84.existsSync(SIGNALS_OLD_HANDLED)) return;
|
|
66020
66318
|
try {
|
|
66021
66319
|
liftInbox();
|
|
66022
66320
|
liftHandled();
|
|
@@ -66084,7 +66382,7 @@ var init_identity2 = __esm({
|
|
|
66084
66382
|
});
|
|
66085
66383
|
|
|
66086
66384
|
// ../cli/src/lib/signals/add.ts
|
|
66087
|
-
import
|
|
66385
|
+
import fs85 from "node:fs";
|
|
66088
66386
|
import path84 from "node:path";
|
|
66089
66387
|
import { createHash as createHash8 } from "node:crypto";
|
|
66090
66388
|
function linkTitle(url2) {
|
|
@@ -66143,8 +66441,8 @@ ${incoming.summary}`);
|
|
|
66143
66441
|
if (seen.status === "pending" || seen.status === "archived") return { ok: false, error: `${sayHit(seen)}.` };
|
|
66144
66442
|
try {
|
|
66145
66443
|
if (keep2) {
|
|
66146
|
-
|
|
66147
|
-
|
|
66444
|
+
fs85.mkdirSync(SIGNALS_FILES, { recursive: true });
|
|
66445
|
+
fs85.writeFileSync(keep2.at, keep2.data);
|
|
66148
66446
|
}
|
|
66149
66447
|
return { ok: true, signal: writeSignal({ ...incoming, sourceId }, formatStamp(/* @__PURE__ */ new Date()), drop.slug) };
|
|
66150
66448
|
} catch (e) {
|
|
@@ -66255,7 +66553,7 @@ var init_signals = __esm({
|
|
|
66255
66553
|
});
|
|
66256
66554
|
|
|
66257
66555
|
// ../cli/src/commands/triage.ts
|
|
66258
|
-
import
|
|
66556
|
+
import fs86 from "node:fs";
|
|
66259
66557
|
async function cmdTriageAdd(opts) {
|
|
66260
66558
|
const title = (opts.title ?? "").trim();
|
|
66261
66559
|
if (!title) die('say what it is: --title "<one line>"', { kind: "needs-input" });
|
|
@@ -66265,7 +66563,7 @@ async function cmdTriageAdd(opts) {
|
|
|
66265
66563
|
let body = opts.text;
|
|
66266
66564
|
if (opts.file !== void 0) {
|
|
66267
66565
|
try {
|
|
66268
|
-
body =
|
|
66566
|
+
body = fs86.readFileSync(opts.file, "utf8");
|
|
66269
66567
|
} catch {
|
|
66270
66568
|
die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
|
|
66271
66569
|
}
|
|
@@ -66319,21 +66617,21 @@ var init_previews = __esm({
|
|
|
66319
66617
|
});
|
|
66320
66618
|
|
|
66321
66619
|
// ../cli/src/commands/studio-preview.ts
|
|
66322
|
-
import
|
|
66620
|
+
import fs87 from "node:fs";
|
|
66323
66621
|
import path85 from "node:path";
|
|
66324
66622
|
import { createHash as createHash9, randomUUID as randomUUID9 } from "node:crypto";
|
|
66325
66623
|
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
66326
66624
|
function readFolder2(folder2, baseline = false) {
|
|
66327
|
-
const root2 =
|
|
66625
|
+
const root2 = fs87.realpathSync(folder2);
|
|
66328
66626
|
let count3 = 0, total = 0;
|
|
66329
66627
|
const scan = (dir) => {
|
|
66330
|
-
for (const e of
|
|
66628
|
+
for (const e of fs87.readdirSync(dir, { withFileTypes: true })) {
|
|
66331
66629
|
if (e.name.startsWith(".")) continue;
|
|
66332
66630
|
const file2 = path85.join(dir, e.name);
|
|
66333
66631
|
if (e.isSymbolicLink()) throw Error(`${file2}: symbolic links are not allowed`);
|
|
66334
66632
|
if (e.isDirectory()) scan(file2);
|
|
66335
66633
|
else {
|
|
66336
|
-
const size =
|
|
66634
|
+
const size = fs87.statSync(file2).size;
|
|
66337
66635
|
total += size;
|
|
66338
66636
|
if (++count3 > FILE_LIMITS.count || size > FILE_LIMITS.file || total > FILE_LIMITS.total) throw Error(`${file2}: Studio file limit exceeded`);
|
|
66339
66637
|
}
|
|
@@ -66347,8 +66645,8 @@ function readFolder2(folder2, baseline = false) {
|
|
|
66347
66645
|
}
|
|
66348
66646
|
function unified(before, after2, file2, folder2) {
|
|
66349
66647
|
const a = path85.join(folder2, "a"), b = path85.join(folder2, "b");
|
|
66350
|
-
|
|
66351
|
-
|
|
66648
|
+
fs87.writeFileSync(a, before ?? "");
|
|
66649
|
+
fs87.writeFileSync(b, after2 ?? "");
|
|
66352
66650
|
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 });
|
|
66353
66651
|
if (result.error || result.status !== 0 && result.status !== 1) throw Error(`${file2}: ${result.error?.message ?? result.stderr}`);
|
|
66354
66652
|
const lines = result.stdout.split("\n"), start = lines.findIndex((l) => l.startsWith("--- "));
|
|
@@ -66364,12 +66662,12 @@ async function cmdStudioPreview(id2, opts) {
|
|
|
66364
66662
|
const draft = readFolder2(path85.resolve(opts.folder)), base = opts.base === "empty" ? null : readFolder2(path85.resolve(opts.base), true);
|
|
66365
66663
|
const version2 = readVersion2(draft.files), baseVersion = base && readVersion2(base.files);
|
|
66366
66664
|
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");
|
|
66367
|
-
|
|
66665
|
+
fs87.mkdirSync(staging, { recursive: true });
|
|
66368
66666
|
const review = { version: 2, base: base && baseVersion ? { ...baseVersion, fingerprint: base.fingerprint } : null, fingerprint: draft.fingerprint, files: [] };
|
|
66369
66667
|
const save3 = (file2, bytes2) => {
|
|
66370
66668
|
const target = path85.join(staging, file2);
|
|
66371
|
-
|
|
66372
|
-
|
|
66669
|
+
fs87.mkdirSync(path85.dirname(target), { recursive: true });
|
|
66670
|
+
fs87.writeFileSync(target, bytes2);
|
|
66373
66671
|
return file2;
|
|
66374
66672
|
};
|
|
66375
66673
|
const paths = [.../* @__PURE__ */ new Set([...Object.keys(base?.files ?? {}), ...Object.keys(draft.files)])].filter((p) => p !== VERSION_FILE).sort();
|
|
@@ -66377,16 +66675,16 @@ async function cmdStudioPreview(id2, opts) {
|
|
|
66377
66675
|
const before = base?.files[file2] ?? null, after2 = draft.files[file2] ?? null;
|
|
66378
66676
|
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)) } : {} });
|
|
66379
66677
|
}
|
|
66380
|
-
for (const p of ["a", "b"])
|
|
66678
|
+
for (const p of ["a", "b"]) fs87.rmSync(path85.join(staging, p), { force: true });
|
|
66381
66679
|
if (!parseReview(review)) throw Error("generated review is invalid");
|
|
66382
66680
|
save3("review.json", JSON.stringify(review, null, 2) + "\n");
|
|
66383
|
-
|
|
66384
|
-
if (
|
|
66385
|
-
|
|
66681
|
+
fs87.mkdirSync(path85.dirname(destination), { recursive: true });
|
|
66682
|
+
if (fs87.existsSync(destination)) {
|
|
66683
|
+
fs87.renameSync(destination, backup);
|
|
66386
66684
|
moved = true;
|
|
66387
66685
|
}
|
|
66388
|
-
|
|
66389
|
-
|
|
66686
|
+
fs87.renameSync(staging, destination);
|
|
66687
|
+
fs87.rmSync(backup, { recursive: true, force: true });
|
|
66390
66688
|
const tag = `<Studio src=".assets/${id2}/studio-review/review.json" />`;
|
|
66391
66689
|
const prefix = `.assets/${id2}/studio-review/`;
|
|
66392
66690
|
const attachments = review.files.filter((f) => f.path !== "STUDIO.md" && f.diff);
|
|
@@ -66400,11 +66698,11 @@ ${items}
|
|
|
66400
66698
|
say([tag, files].filter(Boolean).join("\n\n"));
|
|
66401
66699
|
return { file: path85.join(destination, "review.json"), tag, files };
|
|
66402
66700
|
} catch (error62) {
|
|
66403
|
-
if (moved && !
|
|
66701
|
+
if (moved && !fs87.existsSync(destination)) fs87.renameSync(backup, destination);
|
|
66404
66702
|
if (error62 && typeof error62 === "object" && "kind" in error62) throw error62;
|
|
66405
66703
|
die(error62 instanceof Error ? error62.message : String(error62), "bad-args");
|
|
66406
66704
|
} finally {
|
|
66407
|
-
|
|
66705
|
+
fs87.rmSync(staging, { recursive: true, force: true });
|
|
66408
66706
|
}
|
|
66409
66707
|
}
|
|
66410
66708
|
var readVersion2;
|
|
@@ -66989,14 +67287,14 @@ Review examples
|
|
|
66989
67287
|
});
|
|
66990
67288
|
|
|
66991
67289
|
// ../cli/src/kanban.ts
|
|
66992
|
-
import
|
|
67290
|
+
import fs90 from "node:fs";
|
|
66993
67291
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
66994
67292
|
|
|
66995
67293
|
// ../cli/src/lib/cli/akb.ts
|
|
66996
67294
|
init_agent2();
|
|
66997
67295
|
|
|
66998
67296
|
// ../cli/src/lib/cli/setup.ts
|
|
66999
|
-
import
|
|
67297
|
+
import fs89 from "node:fs";
|
|
67000
67298
|
import path87 from "node:path";
|
|
67001
67299
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
67002
67300
|
|
|
@@ -67005,7 +67303,7 @@ init_board_cli();
|
|
|
67005
67303
|
init_config_template();
|
|
67006
67304
|
init_io();
|
|
67007
67305
|
init_version();
|
|
67008
|
-
import
|
|
67306
|
+
import fs88 from "node:fs";
|
|
67009
67307
|
import path86 from "node:path";
|
|
67010
67308
|
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
67011
67309
|
var NAME = "wildcrane";
|
|
@@ -67027,7 +67325,7 @@ var Report = class {
|
|
|
67027
67325
|
for (const line of this.notes) say(` ! ${line}`);
|
|
67028
67326
|
}
|
|
67029
67327
|
};
|
|
67030
|
-
var read4 = (file2) =>
|
|
67328
|
+
var read4 = (file2) => fs88.existsSync(file2) ? fs88.readFileSync(file2, "utf8") : null;
|
|
67031
67329
|
async function boardMove(root2, args2, board2) {
|
|
67032
67330
|
const where = board2 ? ["--board", board2] : ["--dir", root2];
|
|
67033
67331
|
const code = await runBoard([...args2, ...where], { program: "akb raw", cwd: root2 });
|
|
@@ -67050,8 +67348,8 @@ async function cmdUpdate2(ctx) {
|
|
|
67050
67348
|
async function repairBoard(root2, report3, named2) {
|
|
67051
67349
|
const legacy = path86.join(root2, "docs", "kanban");
|
|
67052
67350
|
const kept2 = path86.join(root2, ".akb", "kanban");
|
|
67053
|
-
const board2 = named2 ?? (
|
|
67054
|
-
if (!
|
|
67351
|
+
const board2 = named2 ?? (fs88.existsSync(legacy) ? legacy : kept2);
|
|
67352
|
+
if (!fs88.existsSync(board2)) {
|
|
67055
67353
|
report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
|
|
67056
67354
|
return false;
|
|
67057
67355
|
}
|
|
@@ -67127,7 +67425,7 @@ function declareSetup(program2, cli) {
|
|
|
67127
67425
|
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");
|
|
67128
67426
|
const where = (cmd) => {
|
|
67129
67427
|
const dir = path87.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
|
|
67130
|
-
if (!
|
|
67428
|
+
if (!fs89.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
|
|
67131
67429
|
return dir;
|
|
67132
67430
|
};
|
|
67133
67431
|
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() {
|
|
@@ -67178,7 +67476,7 @@ function invokedDirectly() {
|
|
|
67178
67476
|
const entry = process.argv[1];
|
|
67179
67477
|
if (!entry) return false;
|
|
67180
67478
|
try {
|
|
67181
|
-
return
|
|
67479
|
+
return fs90.realpathSync(entry) === fs90.realpathSync(SELF2);
|
|
67182
67480
|
} catch {
|
|
67183
67481
|
return false;
|
|
67184
67482
|
}
|