wildcrane-runner 0.6.105 → 0.6.107
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 +833 -526
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/codex-proxy.mjs +172 -55
- package/dist/codex-retained.mjs +128 -47
- package/dist/flow-worker-main.mjs +5161 -4701
- package/dist/launcher.mjs +1891 -1806
- package/dist/plugin.mjs +6538 -6442
- package/dist/runner.mjs +1711 -1192
- package/dist/settings.mjs +2083 -1998
- 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.87 — 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.87",
|
|
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 });
|
|
24779
24891
|
}
|
|
24780
|
-
if (
|
|
24781
|
-
|
|
24782
|
-
|
|
24783
|
-
|
|
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 });
|
|
24897
|
+
}
|
|
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
|
});
|
|
@@ -27009,6 +27145,7 @@ async function run(io, options, count3) {
|
|
|
27009
27145
|
const execution = randomUUID4();
|
|
27010
27146
|
let host2 = {};
|
|
27011
27147
|
let cleanup = { status: "confirmed", execution, kept: [] };
|
|
27148
|
+
let hostCleanup;
|
|
27012
27149
|
let settlement;
|
|
27013
27150
|
let replySnapshots = /* @__PURE__ */ new Map();
|
|
27014
27151
|
const visible = /* @__PURE__ */ new Set();
|
|
@@ -27061,15 +27198,15 @@ async function run(io, options, count3) {
|
|
|
27061
27198
|
const costUsd = cost === void 0 ? child.costUsd : cost + (child.costUsd ?? 0);
|
|
27062
27199
|
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
27200
|
if (failure2) io.event?.({ kind: "error", data: { text: failure2 } });
|
|
27064
|
-
resolve2({ ok: !failure2, error: failure2, failure: failure2 ? classified ?? { code: "execution_failed",
|
|
27201
|
+
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
27202
|
};
|
|
27066
27203
|
const closed2 = () => {
|
|
27067
27204
|
const reason = "Codex connection closed before all work and results finished.";
|
|
27068
|
-
if (work.work().some((w) => ["running", "unknown"].includes(w.status))) note("Connection lost; managed cleanup is unconfirmed.");
|
|
27069
|
-
end2(reason, { code: "connection_lost",
|
|
27205
|
+
if (hostCleanup !== "confirmed" && work.work().some((w) => ["running", "unknown"].includes(w.status))) note("Connection lost; managed cleanup is unconfirmed.");
|
|
27206
|
+
end2(reason, makeFailure("runtime", reason, { code: "connection_lost", detail: reason }));
|
|
27070
27207
|
};
|
|
27071
27208
|
const inputFailed = (e) => {
|
|
27072
|
-
if (work.work().some((w) => ["running", "unknown"].includes(w.status))) note("Connection input failed; managed cleanup is unconfirmed.");
|
|
27209
|
+
if (hostCleanup !== "confirmed" && work.work().some((w) => ["running", "unknown"].includes(w.status))) note("Connection input failed; managed cleanup is unconfirmed.");
|
|
27073
27210
|
end2(e.message, executionFailure(e));
|
|
27074
27211
|
};
|
|
27075
27212
|
io.stdout.once("close", closed2);
|
|
@@ -27105,7 +27242,7 @@ async function run(io, options, count3) {
|
|
|
27105
27242
|
} catch (error62) {
|
|
27106
27243
|
if (!ended) note(error62 instanceof Error ? error62.message : String(error62));
|
|
27107
27244
|
}
|
|
27108
|
-
if (!ended) end2(IDLE_FAILURE.
|
|
27245
|
+
if (!ended) end2(IDLE_FAILURE.summary, IDLE_FAILURE);
|
|
27109
27246
|
};
|
|
27110
27247
|
io.idleSignal?.addEventListener("abort", idle, { once: true });
|
|
27111
27248
|
const childUpdates = () => {
|
|
@@ -27292,6 +27429,14 @@ async function run(io, options, count3) {
|
|
|
27292
27429
|
return;
|
|
27293
27430
|
}
|
|
27294
27431
|
const p = obj2(msg.params);
|
|
27432
|
+
if (msg.method === "wildcrane/cleanup") {
|
|
27433
|
+
if (p.status === "confirmed") hostCleanup = "confirmed";
|
|
27434
|
+
else if (p.status === "unconfirmed") {
|
|
27435
|
+
hostCleanup = "unconfirmed";
|
|
27436
|
+
note(str2(p.diagnostic) || "Codex cleanup is unconfirmed.");
|
|
27437
|
+
}
|
|
27438
|
+
return;
|
|
27439
|
+
}
|
|
27295
27440
|
const source2 = str2(p.threadId);
|
|
27296
27441
|
if (!work.own(source2)) return;
|
|
27297
27442
|
if (msg.method === "item/commandExecution/terminalInteraction") {
|
|
@@ -27365,10 +27510,24 @@ async function run(io, options, count3) {
|
|
|
27365
27510
|
const failure2 = codexFailure(p.error, "Codex failed.");
|
|
27366
27511
|
if (p.willRetry === true && submitted && active3 && !idling) {
|
|
27367
27512
|
status = "retrying";
|
|
27368
|
-
io.log(`[Codex recovery] ${failure2.code}: ${failure2.
|
|
27513
|
+
io.log(`[Codex recovery] ${failure2.code ?? "error"}: ${failure2.summary}
|
|
27369
27514
|
`);
|
|
27370
27515
|
io.event?.({ kind: "status", data: { state: "retrying", source: "codex", code: failure2.code } });
|
|
27371
|
-
|
|
27516
|
+
io.event?.({
|
|
27517
|
+
kind: "retry",
|
|
27518
|
+
data: {
|
|
27519
|
+
state: "retrying",
|
|
27520
|
+
source: "runtime",
|
|
27521
|
+
runtime: { connector: "codex", name: null, model: model ?? null },
|
|
27522
|
+
attempt: 1,
|
|
27523
|
+
maxAttempts: MAX_RETRY_ATTEMPTS,
|
|
27524
|
+
summary: failure2.summary,
|
|
27525
|
+
...failure2.detail ? { detail: failure2.detail } : {},
|
|
27526
|
+
...failure2.code ? { code: failure2.code } : {},
|
|
27527
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
27528
|
+
}
|
|
27529
|
+
});
|
|
27530
|
+
} else if (p.willRetry !== true) end2(failure2.summary, failure2);
|
|
27372
27531
|
}
|
|
27373
27532
|
if (msg.method === "turn/completed") {
|
|
27374
27533
|
const turn2 = obj2(p.turn);
|
|
@@ -27382,7 +27541,7 @@ async function run(io, options, count3) {
|
|
|
27382
27541
|
if (idling) return;
|
|
27383
27542
|
if (turn2.status !== "completed") {
|
|
27384
27543
|
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",
|
|
27544
|
+
const failure2 = turn2.status === "failed" ? codexFailure(turn2.error, reason) : makeFailure("runtime", reason, { code: "turn_stopped", detail: reason });
|
|
27386
27545
|
end2(reason, failure2);
|
|
27387
27546
|
return;
|
|
27388
27547
|
}
|
|
@@ -27419,11 +27578,15 @@ async function run(io, options, count3) {
|
|
|
27419
27578
|
try {
|
|
27420
27579
|
response = await bounded(rpc.call(method, params), preparingUntil - Date.now(), `Codex ${method} timed out.`);
|
|
27421
27580
|
} catch (error62) {
|
|
27581
|
+
if (mode === "fork" && error62 instanceof RpcError && error62.code === -32600 && error62.message === `no rollout found for thread id ${params.threadId}`) {
|
|
27582
|
+
end2(error62.message, { code: "codex_fork_source_missing", source: "runtime", summary: error62.message, detail: error62.message });
|
|
27583
|
+
return done;
|
|
27584
|
+
}
|
|
27422
27585
|
const failure2 = error62 instanceof RpcError ? codexFailure(error62.data, error62.message) : void 0;
|
|
27423
|
-
if (mode !== "fork" || failure2?.
|
|
27586
|
+
if (mode !== "fork" || failure2?.code !== "codex_source_busy") throw error62;
|
|
27424
27587
|
if (!waiting) {
|
|
27425
27588
|
waiting = true;
|
|
27426
|
-
io.event?.({ kind: "log", data: { text: failure2.
|
|
27589
|
+
io.event?.({ kind: "log", data: { text: failure2.summary } });
|
|
27427
27590
|
}
|
|
27428
27591
|
io.activity?.();
|
|
27429
27592
|
await delay(500, void 0, { signal: io.signal });
|
|
@@ -27449,7 +27612,7 @@ async function run(io, options, count3) {
|
|
|
27449
27612
|
await start(io.prompt, options.images);
|
|
27450
27613
|
} catch (e) {
|
|
27451
27614
|
const failure2 = e instanceof RpcError ? codexFailure(e.data, e.message) : executionFailure(e);
|
|
27452
|
-
end2(failure2.
|
|
27615
|
+
end2(failure2.summary, failure2);
|
|
27453
27616
|
}
|
|
27454
27617
|
return done;
|
|
27455
27618
|
}
|
|
@@ -27458,6 +27621,7 @@ var init_codex = __esm({
|
|
|
27458
27621
|
"../cli/src/lib/agent/wire/codex.ts"() {
|
|
27459
27622
|
"use strict";
|
|
27460
27623
|
init_idle();
|
|
27624
|
+
init_retry();
|
|
27461
27625
|
init_failures();
|
|
27462
27626
|
init_conversation();
|
|
27463
27627
|
init_codex_background();
|
|
@@ -29129,6 +29293,22 @@ var init_settings2 = __esm({
|
|
|
29129
29293
|
});
|
|
29130
29294
|
|
|
29131
29295
|
// ../cli/src/lib/agent/runtimes.ts
|
|
29296
|
+
import fs27 from "node:fs";
|
|
29297
|
+
function executionRuntimes() {
|
|
29298
|
+
const encoded = process.env[EXECUTION_RUNTIMES_ENV];
|
|
29299
|
+
return encoded ? JSON.parse(encoded) : void 0;
|
|
29300
|
+
}
|
|
29301
|
+
function readRuntimeCredentials(file2) {
|
|
29302
|
+
try {
|
|
29303
|
+
return configBlock(JSON.parse(fs27.readFileSync(file2, "utf8")));
|
|
29304
|
+
} catch {
|
|
29305
|
+
return {};
|
|
29306
|
+
}
|
|
29307
|
+
}
|
|
29308
|
+
function runRuntimeById(id2) {
|
|
29309
|
+
const scope = executionRuntimes();
|
|
29310
|
+
return scope ? [scope.default, ...Object.values(scope.picks)].find((row) => row.id === id2) : runtimeById(id2);
|
|
29311
|
+
}
|
|
29132
29312
|
function readRuntimes(cfg = safeConfig()) {
|
|
29133
29313
|
const saved = Array.isArray(cfg.runtimes) ? cfg.runtimes.map(parseRuntime).filter(isRuntime) : null;
|
|
29134
29314
|
const list3 = saved?.length ? dedupe(saved) : [];
|
|
@@ -29243,7 +29423,7 @@ function writePicks(cfg, picks, list3 = readRuntimes(cfg)) {
|
|
|
29243
29423
|
if (Object.keys(block).length) cfg.agentRuntime = block;
|
|
29244
29424
|
else delete cfg.agentRuntime;
|
|
29245
29425
|
}
|
|
29246
|
-
var GLOBAL_ID, GLOBAL_NAME, isRuntime, runtimeSecretVar, keepsPick, noRuntime, noHarness;
|
|
29426
|
+
var GLOBAL_ID, GLOBAL_NAME, EXECUTION_RUNTIMES_ENV, isRuntime, runtimeSecretVar, keepsPick, noRuntime, noHarness;
|
|
29247
29427
|
var init_runtimes = __esm({
|
|
29248
29428
|
"../cli/src/lib/agent/runtimes.ts"() {
|
|
29249
29429
|
"use strict";
|
|
@@ -29252,6 +29432,7 @@ var init_runtimes = __esm({
|
|
|
29252
29432
|
init_types3();
|
|
29253
29433
|
GLOBAL_ID = "global";
|
|
29254
29434
|
GLOBAL_NAME = "Global default";
|
|
29435
|
+
EXECUTION_RUNTIMES_ENV = "AI4KANBAN_EXECUTION_RUNTIMES";
|
|
29255
29436
|
isRuntime = (r) => r !== null;
|
|
29256
29437
|
runtimeSecretVar = (env2, runtime) => runtime.secretRefs?.[env2] ?? secretVar(env2, runtime.id);
|
|
29257
29438
|
keepsPick = (id2) => !!id2 && id2 !== GLOBAL_ID;
|
|
@@ -29272,11 +29453,11 @@ var init_slug = __esm({
|
|
|
29272
29453
|
});
|
|
29273
29454
|
|
|
29274
29455
|
// ../cli/src/lib/validate.ts
|
|
29275
|
-
import
|
|
29456
|
+
import fs28 from "node:fs";
|
|
29276
29457
|
import path30 from "node:path";
|
|
29277
29458
|
function moduleNames() {
|
|
29278
|
-
if (!
|
|
29279
|
-
return moduleNamesFrom(
|
|
29459
|
+
if (!fs28.existsSync(MODULES_MD)) return null;
|
|
29460
|
+
return moduleNamesFrom(fs28.readFileSync(MODULES_MD, "utf8"));
|
|
29280
29461
|
}
|
|
29281
29462
|
function validModules(mods) {
|
|
29282
29463
|
const known2 = moduleNames();
|
|
@@ -29311,7 +29492,7 @@ function dependencyCycle(id2, dep) {
|
|
|
29311
29492
|
const found2 = locate(at);
|
|
29312
29493
|
if (!found2) return null;
|
|
29313
29494
|
const file2 = found2.kind === "group" ? path30.join(found2.target, "root.md") : found2.target;
|
|
29314
|
-
const nexts = parseFrontmatter(
|
|
29495
|
+
const nexts = parseFrontmatter(fs28.readFileSync(file2, "utf8")).meta?.blocked_by ?? [];
|
|
29315
29496
|
if (found2.kind === "group") nexts.push(...groupMembers(found2.target));
|
|
29316
29497
|
for (const next of nexts) {
|
|
29317
29498
|
const rest2 = walk3(next);
|
|
@@ -29339,7 +29520,7 @@ var init_validate = __esm({
|
|
|
29339
29520
|
});
|
|
29340
29521
|
|
|
29341
29522
|
// ../cli/src/lib/memory.ts
|
|
29342
|
-
import
|
|
29523
|
+
import fs29 from "node:fs";
|
|
29343
29524
|
import path31 from "node:path";
|
|
29344
29525
|
function scaffoldProjectMemory() {
|
|
29345
29526
|
const board2 = scaffoldMemoryDir(MEMORY, setOf(BOARD_MEMORY_FILES));
|
|
@@ -29347,13 +29528,13 @@ function scaffoldProjectMemory() {
|
|
|
29347
29528
|
return board2 ?? planner;
|
|
29348
29529
|
}
|
|
29349
29530
|
function scaffoldMemoryDir(dir, set2) {
|
|
29350
|
-
const existed =
|
|
29351
|
-
|
|
29531
|
+
const existed = fs29.existsSync(dir);
|
|
29532
|
+
fs29.mkdirSync(dir, { recursive: true });
|
|
29352
29533
|
const made = [];
|
|
29353
29534
|
for (const [name, body] of Object.entries(set2)) {
|
|
29354
29535
|
const file2 = path31.join(dir, name);
|
|
29355
|
-
if (!
|
|
29356
|
-
|
|
29536
|
+
if (!fs29.existsSync(file2)) {
|
|
29537
|
+
fs29.writeFileSync(file2, body);
|
|
29357
29538
|
made.push(name);
|
|
29358
29539
|
}
|
|
29359
29540
|
}
|
|
@@ -29363,7 +29544,7 @@ function scaffoldMemoryDir(dir, set2) {
|
|
|
29363
29544
|
function plannerModules() {
|
|
29364
29545
|
let dirs2;
|
|
29365
29546
|
try {
|
|
29366
|
-
dirs2 =
|
|
29547
|
+
dirs2 = fs29.readdirSync(agentMemoryDir(PLANNER), { withFileTypes: true }).filter((e) => e.isDirectory() && isModule(e.name)).map((e) => e.name);
|
|
29367
29548
|
} catch {
|
|
29368
29549
|
return [];
|
|
29369
29550
|
}
|
|
@@ -29375,7 +29556,7 @@ function memoryDirectories(board2) {
|
|
|
29375
29556
|
const walk3 = (dir, depth3, scoped = true) => {
|
|
29376
29557
|
let entries2;
|
|
29377
29558
|
try {
|
|
29378
|
-
entries2 =
|
|
29559
|
+
entries2 = fs29.readdirSync(dir, { withFileTypes: true });
|
|
29379
29560
|
} catch {
|
|
29380
29561
|
return [];
|
|
29381
29562
|
}
|
|
@@ -29389,7 +29570,7 @@ function memoryDirectories(board2) {
|
|
|
29389
29570
|
...walk3(path31.join(root2, "previews"), 3),
|
|
29390
29571
|
...walk3(path31.join(root2, "studios"), 1, false),
|
|
29391
29572
|
path31.join(root2, "agents", PLANNER)
|
|
29392
|
-
].filter((dir) =>
|
|
29573
|
+
].filter((dir) => fs29.existsSync(dir)).map((dir) => `${dir}/`);
|
|
29393
29574
|
}
|
|
29394
29575
|
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
29576
|
var init_memory = __esm({
|
|
@@ -29438,7 +29619,7 @@ edits here do not last.
|
|
|
29438
29619
|
agentMemoryFile = (agent, name) => path31.join(agentMemoryDir(agent), name);
|
|
29439
29620
|
writtenMemoryNames = (agent) => {
|
|
29440
29621
|
try {
|
|
29441
|
-
return
|
|
29622
|
+
return fs29.readdirSync(agentMemoryDir(agent), { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".md")).map((e) => e.name).sort();
|
|
29442
29623
|
} catch {
|
|
29443
29624
|
return [];
|
|
29444
29625
|
}
|
|
@@ -29450,7 +29631,7 @@ edits here do not last.
|
|
|
29450
29631
|
moduleMemoryFile = (module, name) => path31.join(agentMemoryDir(PLANNER), module, name);
|
|
29451
29632
|
plannerCopies = (name) => [
|
|
29452
29633
|
agentMemoryFile(PLANNER, name),
|
|
29453
|
-
...plannerModules().map((m) => moduleMemoryFile(m, name)).filter((file2) =>
|
|
29634
|
+
...plannerModules().map((m) => moduleMemoryFile(m, name)).filter((file2) => fs29.existsSync(file2))
|
|
29454
29635
|
];
|
|
29455
29636
|
}
|
|
29456
29637
|
});
|
|
@@ -43121,14 +43302,14 @@ var require_parser = __commonJS({
|
|
|
43121
43302
|
case "scalar":
|
|
43122
43303
|
case "single-quoted-scalar":
|
|
43123
43304
|
case "double-quoted-scalar": {
|
|
43124
|
-
const
|
|
43305
|
+
const fs91 = this.flowScalar(this.type);
|
|
43125
43306
|
if (atNextItem || it.value) {
|
|
43126
|
-
map3.items.push({ start, key:
|
|
43307
|
+
map3.items.push({ start, key: fs91, sep: [] });
|
|
43127
43308
|
this.onKeyLine = true;
|
|
43128
43309
|
} else if (it.sep) {
|
|
43129
|
-
this.stack.push(
|
|
43310
|
+
this.stack.push(fs91);
|
|
43130
43311
|
} else {
|
|
43131
|
-
Object.assign(it, { key:
|
|
43312
|
+
Object.assign(it, { key: fs91, sep: [] });
|
|
43132
43313
|
this.onKeyLine = true;
|
|
43133
43314
|
}
|
|
43134
43315
|
return;
|
|
@@ -43256,13 +43437,13 @@ var require_parser = __commonJS({
|
|
|
43256
43437
|
case "scalar":
|
|
43257
43438
|
case "single-quoted-scalar":
|
|
43258
43439
|
case "double-quoted-scalar": {
|
|
43259
|
-
const
|
|
43440
|
+
const fs91 = this.flowScalar(this.type);
|
|
43260
43441
|
if (!it || it.value)
|
|
43261
|
-
fc.items.push({ start: [], key:
|
|
43442
|
+
fc.items.push({ start: [], key: fs91, sep: [] });
|
|
43262
43443
|
else if (it.sep)
|
|
43263
|
-
this.stack.push(
|
|
43444
|
+
this.stack.push(fs91);
|
|
43264
43445
|
else
|
|
43265
|
-
Object.assign(it, { key:
|
|
43446
|
+
Object.assign(it, { key: fs91, sep: [] });
|
|
43266
43447
|
return;
|
|
43267
43448
|
}
|
|
43268
43449
|
case "flow-map-end":
|
|
@@ -43948,10 +44129,10 @@ var init_studio_files = __esm({
|
|
|
43948
44129
|
});
|
|
43949
44130
|
|
|
43950
44131
|
// ../cli/src/lib/agent/studio-folder.ts
|
|
43951
|
-
import
|
|
44132
|
+
import fs30 from "node:fs";
|
|
43952
44133
|
import path32 from "node:path";
|
|
43953
44134
|
function filesOf(dir, base = dir) {
|
|
43954
|
-
return
|
|
44135
|
+
return fs30.readdirSync(dir, { withFileTypes: true }).filter((e) => !e.name.startsWith(".")).flatMap((e) => {
|
|
43955
44136
|
const full = path32.join(dir, e.name);
|
|
43956
44137
|
if (e.isSymbolicLink()) throw new Error(`${full}: symbolic links are not allowed`);
|
|
43957
44138
|
return e.isDirectory() ? filesOf(full, base) : [path32.relative(base, full).split(path32.sep).join("/")];
|
|
@@ -43959,7 +44140,7 @@ function filesOf(dir, base = dir) {
|
|
|
43959
44140
|
}
|
|
43960
44141
|
function readStudioFile(dir, file2) {
|
|
43961
44142
|
const full = path32.join(dir, file2);
|
|
43962
|
-
return isAboutFile(file2) && !file2.endsWith(".md") ? `data:${MIME[path32.extname(file2)]};base64,${
|
|
44143
|
+
return isAboutFile(file2) && !file2.endsWith(".md") ? `data:${MIME[path32.extname(file2)]};base64,${fs30.readFileSync(full).toString("base64")}` : fs30.readFileSync(full, "utf8");
|
|
43963
44144
|
}
|
|
43964
44145
|
var MIME, readStudioFolder;
|
|
43965
44146
|
var init_studio_folder = __esm({
|
|
@@ -43973,7 +44154,7 @@ var init_studio_folder = __esm({
|
|
|
43973
44154
|
|
|
43974
44155
|
// ../official/pack.ts
|
|
43975
44156
|
import crypto2 from "node:crypto";
|
|
43976
|
-
import
|
|
44157
|
+
import fs31 from "node:fs";
|
|
43977
44158
|
import path33 from "node:path";
|
|
43978
44159
|
import { fileURLToPath } from "node:url";
|
|
43979
44160
|
function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
@@ -44005,32 +44186,32 @@ var init_pack = __esm({
|
|
|
44005
44186
|
init_studio_folder();
|
|
44006
44187
|
init_studio_files();
|
|
44007
44188
|
OFFICIAL = path33.dirname(fileURLToPath(import.meta.url));
|
|
44008
|
-
dirs = (dir) =>
|
|
44189
|
+
dirs = (dir) => fs31.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
44009
44190
|
hashOf = (files) => crypto2.createHash("sha256").update(hashInput(files)).digest("hex");
|
|
44010
44191
|
}
|
|
44011
44192
|
});
|
|
44012
44193
|
|
|
44013
44194
|
// ../cli/src/lib/agent/cloud-studios.ts
|
|
44014
|
-
import
|
|
44195
|
+
import fs32 from "node:fs";
|
|
44015
44196
|
import path34 from "node:path";
|
|
44016
44197
|
function readJson(file2) {
|
|
44017
44198
|
try {
|
|
44018
|
-
return JSON.parse(
|
|
44199
|
+
return JSON.parse(fs32.readFileSync(file2, "utf8"));
|
|
44019
44200
|
} catch {
|
|
44020
44201
|
return null;
|
|
44021
44202
|
}
|
|
44022
44203
|
}
|
|
44023
44204
|
function writeJson(file2, value) {
|
|
44024
|
-
|
|
44205
|
+
fs32.mkdirSync(path34.dirname(file2), { recursive: true });
|
|
44025
44206
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
44026
|
-
|
|
44207
|
+
fs32.writeFileSync(tmp, `${JSON.stringify(value)}
|
|
44027
44208
|
`);
|
|
44028
|
-
|
|
44209
|
+
fs32.renameSync(tmp, file2);
|
|
44029
44210
|
}
|
|
44030
44211
|
function heldStudioName(name) {
|
|
44031
44212
|
let files;
|
|
44032
44213
|
try {
|
|
44033
|
-
files =
|
|
44214
|
+
files = fs32.readdirSync(path34.join(root(), "versions"));
|
|
44034
44215
|
} catch {
|
|
44035
44216
|
return "";
|
|
44036
44217
|
}
|
|
@@ -44041,7 +44222,7 @@ function heldStudioName(name) {
|
|
|
44041
44222
|
}
|
|
44042
44223
|
function saveVersion(held4) {
|
|
44043
44224
|
const file2 = versionFile(held4.id, held4.version);
|
|
44044
|
-
if (!
|
|
44225
|
+
if (!fs32.existsSync(file2)) writeJson(file2, { id: held4.id, version: held4.version, name: held4.name, names: held4.names, files: held4.files });
|
|
44045
44226
|
}
|
|
44046
44227
|
function savePin(task, held4) {
|
|
44047
44228
|
saveVersion(held4);
|
|
@@ -44246,7 +44427,7 @@ var init_studio_file = __esm({
|
|
|
44246
44427
|
});
|
|
44247
44428
|
|
|
44248
44429
|
// ../cli/src/lib/agent/studios.ts
|
|
44249
|
-
import
|
|
44430
|
+
import fs33 from "node:fs";
|
|
44250
44431
|
import path35 from "node:path";
|
|
44251
44432
|
function noStudioMessage(id2) {
|
|
44252
44433
|
const name = heldStudioName(id2 ?? "") || id2;
|
|
@@ -44259,7 +44440,7 @@ function knownStudio(id2) {
|
|
|
44259
44440
|
}
|
|
44260
44441
|
function userStudioRules(flow) {
|
|
44261
44442
|
try {
|
|
44262
|
-
return
|
|
44443
|
+
return fs33.readFileSync(studioRuleFile(flow.id), "utf8").trim();
|
|
44263
44444
|
} catch {
|
|
44264
44445
|
return "";
|
|
44265
44446
|
}
|
|
@@ -44269,7 +44450,7 @@ function cardMeta(id2) {
|
|
|
44269
44450
|
const found2 = locate(id2) ?? locateArchived(id2);
|
|
44270
44451
|
if (!found2) return null;
|
|
44271
44452
|
const file2 = found2.kind === "group" ? path35.join(found2.target, "root.md") : found2.target;
|
|
44272
|
-
return parseFrontmatter(
|
|
44453
|
+
return parseFrontmatter(fs33.readFileSync(file2, "utf8")).meta;
|
|
44273
44454
|
} catch {
|
|
44274
44455
|
return null;
|
|
44275
44456
|
}
|
|
@@ -44933,7 +45114,7 @@ var init_parse3 = __esm({
|
|
|
44933
45114
|
});
|
|
44934
45115
|
|
|
44935
45116
|
// ../cli/src/lib/agents/catalog.ts
|
|
44936
|
-
import
|
|
45117
|
+
import fs34 from "node:fs";
|
|
44937
45118
|
import path37 from "node:path";
|
|
44938
45119
|
function readCatalog() {
|
|
44939
45120
|
const agents = [];
|
|
@@ -44991,7 +45172,7 @@ function readBundled(folder2) {
|
|
|
44991
45172
|
function projectFolders(root2) {
|
|
44992
45173
|
let entries2;
|
|
44993
45174
|
try {
|
|
44994
|
-
entries2 =
|
|
45175
|
+
entries2 = fs34.readdirSync(root2, { withFileTypes: true });
|
|
44995
45176
|
} catch {
|
|
44996
45177
|
return [];
|
|
44997
45178
|
}
|
|
@@ -45002,9 +45183,9 @@ function agentFileReader(dir) {
|
|
|
45002
45183
|
const target = path37.resolve(dir, relative);
|
|
45003
45184
|
if (target !== dir && !target.startsWith(dir + path37.sep)) return null;
|
|
45004
45185
|
try {
|
|
45005
|
-
const real2 =
|
|
45006
|
-
if (!real2.startsWith(
|
|
45007
|
-
return
|
|
45186
|
+
const real2 = fs34.realpathSync(target);
|
|
45187
|
+
if (!real2.startsWith(fs34.realpathSync(dir) + path37.sep)) return null;
|
|
45188
|
+
return fs34.readFileSync(real2, "utf8");
|
|
45008
45189
|
} catch {
|
|
45009
45190
|
return null;
|
|
45010
45191
|
}
|
|
@@ -45013,7 +45194,7 @@ function agentFileReader(dir) {
|
|
|
45013
45194
|
function walkFolder(dir, prefix) {
|
|
45014
45195
|
let entries2;
|
|
45015
45196
|
try {
|
|
45016
|
-
entries2 =
|
|
45197
|
+
entries2 = fs34.readdirSync(dir, { withFileTypes: true });
|
|
45017
45198
|
} catch {
|
|
45018
45199
|
return [];
|
|
45019
45200
|
}
|
|
@@ -45124,7 +45305,7 @@ var init_candidate = __esm({
|
|
|
45124
45305
|
|
|
45125
45306
|
// ../cli/src/lib/agent/launch.ts
|
|
45126
45307
|
import { spawn as spawn2 } from "node:child_process";
|
|
45127
|
-
import
|
|
45308
|
+
import fs35 from "node:fs";
|
|
45128
45309
|
import path38 from "node:path";
|
|
45129
45310
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
45130
45311
|
function boardArgs() {
|
|
@@ -45137,8 +45318,8 @@ function watcherEnv(env2 = process.env) {
|
|
|
45137
45318
|
}
|
|
45138
45319
|
function spawnWatcher(sessionId) {
|
|
45139
45320
|
if (!BUILT) return void 0;
|
|
45140
|
-
|
|
45141
|
-
const out =
|
|
45321
|
+
fs35.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
45322
|
+
const out = fs35.openSync(path38.join(SESSIONS_DIR, `${sessionId}.watch.log`), "a");
|
|
45142
45323
|
try {
|
|
45143
45324
|
const child = spawn2(process.execPath, [SELF, "__watch", sessionId, ...boardArgs()], {
|
|
45144
45325
|
cwd: REPO_ROOT,
|
|
@@ -45154,7 +45335,7 @@ function spawnWatcher(sessionId) {
|
|
|
45154
45335
|
return void 0;
|
|
45155
45336
|
} finally {
|
|
45156
45337
|
try {
|
|
45157
|
-
|
|
45338
|
+
fs35.closeSync(out);
|
|
45158
45339
|
} catch {
|
|
45159
45340
|
}
|
|
45160
45341
|
}
|
|
@@ -45171,11 +45352,11 @@ var init_launch = __esm({
|
|
|
45171
45352
|
});
|
|
45172
45353
|
|
|
45173
45354
|
// ../cli/src/lib/agent/command.ts
|
|
45174
|
-
import
|
|
45355
|
+
import fs36 from "node:fs";
|
|
45175
45356
|
import path39 from "node:path";
|
|
45176
45357
|
function selfCommand() {
|
|
45177
45358
|
const bin = path39.resolve(path39.dirname(SELF), "..", "bin", "ai4kanban.mjs");
|
|
45178
|
-
const file2 =
|
|
45359
|
+
const file2 = fs36.existsSync(bin) ? bin : SELF;
|
|
45179
45360
|
const inside2 = rel(file2);
|
|
45180
45361
|
const shortHop = !inside2.startsWith("..") && !path39.isAbsolute(inside2) && inside2.split(/[\\/]/).length <= 3;
|
|
45181
45362
|
return `node ${shortHop ? inside2 : file2}`;
|
|
@@ -45189,7 +45370,7 @@ function boardCommandFor(_cardId) {
|
|
|
45189
45370
|
}
|
|
45190
45371
|
function absoluteSelf() {
|
|
45191
45372
|
const bin = path39.resolve(path39.dirname(SELF), "..", "bin", "ai4kanban.mjs");
|
|
45192
|
-
return
|
|
45373
|
+
return fs36.existsSync(bin) ? bin : SELF;
|
|
45193
45374
|
}
|
|
45194
45375
|
function commandNote(command) {
|
|
45195
45376
|
if (command === "akb") return "";
|
|
@@ -45205,13 +45386,13 @@ var init_command = __esm({
|
|
|
45205
45386
|
});
|
|
45206
45387
|
|
|
45207
45388
|
// ../cli/src/lib/agent/outputs.ts
|
|
45208
|
-
import
|
|
45389
|
+
import fs37 from "node:fs";
|
|
45209
45390
|
import path40 from "node:path";
|
|
45210
45391
|
function cardBody(cardId2) {
|
|
45211
45392
|
const found2 = locate(cardId2) ?? locateArchived(cardId2);
|
|
45212
45393
|
if (!found2) return "";
|
|
45213
45394
|
try {
|
|
45214
|
-
return
|
|
45395
|
+
return fs37.readFileSync(found2.kind === "group" ? path40.join(found2.target, "root.md") : found2.target, "utf8");
|
|
45215
45396
|
} catch {
|
|
45216
45397
|
return "";
|
|
45217
45398
|
}
|
|
@@ -45245,20 +45426,20 @@ var init_outputs = __esm({
|
|
|
45245
45426
|
});
|
|
45246
45427
|
|
|
45247
45428
|
// ../cli/src/lib/agent/log.ts
|
|
45248
|
-
import
|
|
45429
|
+
import fs38 from "node:fs";
|
|
45249
45430
|
import path41 from "node:path";
|
|
45250
45431
|
function pruneLogs() {
|
|
45251
45432
|
try {
|
|
45252
|
-
const runs =
|
|
45433
|
+
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
45434
|
const kept2 = new Set(runs.slice(0, KEEP_LOGS).map((r) => r.id));
|
|
45254
45435
|
const drop = new Set(runs.slice(KEEP_LOGS).map((r) => r.id));
|
|
45255
|
-
for (const f of
|
|
45436
|
+
for (const f of fs38.readdirSync(SESSIONS_DIR)) {
|
|
45256
45437
|
const dot = f.indexOf(".");
|
|
45257
45438
|
const id2 = dot === -1 ? f : f.slice(0, dot);
|
|
45258
45439
|
const stray = f.endsWith(".images") && !kept2.has(id2) && !drop.has(id2) && stale2(f);
|
|
45259
45440
|
if (!stray && !drop.has(id2)) continue;
|
|
45260
45441
|
try {
|
|
45261
|
-
|
|
45442
|
+
fs38.rmSync(path41.join(SESSIONS_DIR, f), { recursive: true, force: true });
|
|
45262
45443
|
} catch {
|
|
45263
45444
|
}
|
|
45264
45445
|
}
|
|
@@ -45267,7 +45448,7 @@ function pruneLogs() {
|
|
|
45267
45448
|
}
|
|
45268
45449
|
function stale2(name) {
|
|
45269
45450
|
try {
|
|
45270
|
-
return Date.now() -
|
|
45451
|
+
return Date.now() - fs38.statSync(path41.join(SESSIONS_DIR, name)).mtimeMs > STRAY_MS;
|
|
45271
45452
|
} catch {
|
|
45272
45453
|
return false;
|
|
45273
45454
|
}
|
|
@@ -45294,13 +45475,13 @@ function asContext(v) {
|
|
|
45294
45475
|
function readLogTail(logPath, maxBytes = TAIL_BYTES) {
|
|
45295
45476
|
let fd;
|
|
45296
45477
|
try {
|
|
45297
|
-
const size =
|
|
45478
|
+
const size = fs38.statSync(logPath).size;
|
|
45298
45479
|
const start = Math.max(0, size - maxBytes);
|
|
45299
45480
|
const len = size - start;
|
|
45300
45481
|
if (len === 0) return "";
|
|
45301
|
-
fd =
|
|
45482
|
+
fd = fs38.openSync(logPath, "r");
|
|
45302
45483
|
const buf = Buffer.alloc(len);
|
|
45303
|
-
|
|
45484
|
+
fs38.readSync(fd, buf, 0, len, start);
|
|
45304
45485
|
let text5 = buf.toString("utf8");
|
|
45305
45486
|
if (start > 0) {
|
|
45306
45487
|
const nl = text5.indexOf("\n");
|
|
@@ -45312,7 +45493,7 @@ function readLogTail(logPath, maxBytes = TAIL_BYTES) {
|
|
|
45312
45493
|
} finally {
|
|
45313
45494
|
if (fd !== void 0) {
|
|
45314
45495
|
try {
|
|
45315
|
-
|
|
45496
|
+
fs38.closeSync(fd);
|
|
45316
45497
|
} catch {
|
|
45317
45498
|
}
|
|
45318
45499
|
}
|
|
@@ -45403,7 +45584,7 @@ ${DURATION_MARKER} ${Math.max(0, ms)}
|
|
|
45403
45584
|
});
|
|
45404
45585
|
|
|
45405
45586
|
// ../cli/src/lib/agent/store.ts
|
|
45406
|
-
import
|
|
45587
|
+
import fs39 from "node:fs";
|
|
45407
45588
|
import path42 from "node:path";
|
|
45408
45589
|
function logPathIn(held4, sessionId) {
|
|
45409
45590
|
return typeof held4 === "string" && held4.startsWith(SESSIONS_DIR + path42.sep) ? held4 : logPathOf(sessionId);
|
|
@@ -45411,7 +45592,7 @@ function logPathIn(held4, sessionId) {
|
|
|
45411
45592
|
function parseStore() {
|
|
45412
45593
|
let data;
|
|
45413
45594
|
try {
|
|
45414
|
-
data = JSON.parse(
|
|
45595
|
+
data = JSON.parse(fs39.readFileSync(SESSIONS, "utf8"));
|
|
45415
45596
|
} catch {
|
|
45416
45597
|
return { runs: [], deliveries: [], marks: {} };
|
|
45417
45598
|
}
|
|
@@ -45445,7 +45626,8 @@ function parseStore() {
|
|
|
45445
45626
|
error: typeof entry.error === "string" ? entry.error : void 0,
|
|
45446
45627
|
failure: readFailure(entry.failure),
|
|
45447
45628
|
validationFailure: readFailure(entry.validationFailure),
|
|
45448
|
-
retryPause: entry.retryPause,
|
|
45629
|
+
retryPause: readRetryPause(entry.retryPause),
|
|
45630
|
+
retryHistory: readRetryHistory(entry.retryHistory),
|
|
45449
45631
|
blocker: readBlocker(entry.blocker),
|
|
45450
45632
|
// A run that never reported a cost shows none, rather than a zero it didn't earn.
|
|
45451
45633
|
costUsd: typeof entry.costUsd === "number" && entry.costUsd >= 0 ? entry.costUsd : void 0,
|
|
@@ -45765,16 +45947,16 @@ function writeStore(store) {
|
|
|
45765
45947
|
marks: store.marks,
|
|
45766
45948
|
...store.refined ? { refined: store.refined } : {}
|
|
45767
45949
|
};
|
|
45768
|
-
|
|
45950
|
+
fs39.mkdirSync(path42.dirname(SESSIONS), { recursive: true });
|
|
45769
45951
|
const tmp = `${SESSIONS}.tmp`;
|
|
45770
|
-
|
|
45771
|
-
|
|
45952
|
+
fs39.writeFileSync(tmp, JSON.stringify(kept2, null, 2) + "\n");
|
|
45953
|
+
fs39.renameSync(tmp, SESSIONS);
|
|
45772
45954
|
forgetFileMemos();
|
|
45773
45955
|
}
|
|
45774
45956
|
function prune(runs, deliveries) {
|
|
45775
45957
|
const held4 = new Set(deliveries.filter(holdsCheckout).map((d) => d.deliveryId));
|
|
45776
45958
|
const live = runs.filter((r) => r.status === "running");
|
|
45777
|
-
const finished = runs.filter((r) => r.status !== "running" && (
|
|
45959
|
+
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
45960
|
const spared = runs.filter(
|
|
45779
45961
|
(r) => r.status !== "running" && !finished.includes(r) && (!!r.discardedCards?.length || r.deliveryId && held4.has(r.deliveryId))
|
|
45780
45962
|
);
|
|
@@ -45871,11 +46053,11 @@ var init_store = __esm({
|
|
|
45871
46053
|
});
|
|
45872
46054
|
|
|
45873
46055
|
// ../cli/src/lib/agent/commit-mode.ts
|
|
45874
|
-
import
|
|
46056
|
+
import fs40 from "node:fs";
|
|
45875
46057
|
function recordedIds() {
|
|
45876
46058
|
try {
|
|
45877
46059
|
return new Set(
|
|
45878
|
-
|
|
46060
|
+
fs40.readdirSync(DELIVERIES).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -".json".length))
|
|
45879
46061
|
);
|
|
45880
46062
|
} catch {
|
|
45881
46063
|
return /* @__PURE__ */ new Set();
|
|
@@ -45908,7 +46090,7 @@ var init_commit_mode = __esm({
|
|
|
45908
46090
|
init_worktree();
|
|
45909
46091
|
ID_ALPHABET = "abcdefghjkmnpqrstuvwxyz23456789";
|
|
45910
46092
|
ID_LENGTH = 8;
|
|
45911
|
-
deliveryCwd = (delivery) => delivery.worktree &&
|
|
46093
|
+
deliveryCwd = (delivery) => delivery.worktree && fs40.existsSync(worktreeDir(delivery.worktree)) ? worktreeDir(delivery.worktree) : REPO_ROOT;
|
|
45912
46094
|
}
|
|
45913
46095
|
});
|
|
45914
46096
|
|
|
@@ -46002,12 +46184,12 @@ var init_runner = __esm({
|
|
|
46002
46184
|
});
|
|
46003
46185
|
|
|
46004
46186
|
// ../cli/src/lib/agent/rules.ts
|
|
46005
|
-
import
|
|
46187
|
+
import fs41 from "node:fs";
|
|
46006
46188
|
import path43 from "node:path";
|
|
46007
46189
|
function ruleFile(agent) {
|
|
46008
46190
|
if (!agent || hiddenRole(agent)) return "";
|
|
46009
46191
|
try {
|
|
46010
|
-
return
|
|
46192
|
+
return fs41.readFileSync(rulePath(agent), "utf8").trim();
|
|
46011
46193
|
} catch {
|
|
46012
46194
|
return "";
|
|
46013
46195
|
}
|
|
@@ -46072,7 +46254,7 @@ var init_rules2 = __esm({
|
|
|
46072
46254
|
});
|
|
46073
46255
|
|
|
46074
46256
|
// ../cli/src/lib/agent/deliveries.ts
|
|
46075
|
-
import
|
|
46257
|
+
import fs42 from "node:fs";
|
|
46076
46258
|
import path44 from "node:path";
|
|
46077
46259
|
function writeAudit(delivery, runs) {
|
|
46078
46260
|
const known2 = new Map(readAudit(delivery.deliveryId)?.sessions.map((s) => [s.sessionId, s]) ?? []);
|
|
@@ -46102,10 +46284,10 @@ function writeAudit(delivery, runs) {
|
|
|
46102
46284
|
}
|
|
46103
46285
|
function writeAuditFile(record2) {
|
|
46104
46286
|
try {
|
|
46105
|
-
|
|
46287
|
+
fs42.mkdirSync(DELIVERIES, { recursive: true });
|
|
46106
46288
|
const tmp = `${auditPath(record2.deliveryId)}.tmp`;
|
|
46107
|
-
|
|
46108
|
-
|
|
46289
|
+
fs42.writeFileSync(tmp, JSON.stringify(record2, null, 2) + "\n");
|
|
46290
|
+
fs42.renameSync(tmp, auditPath(record2.deliveryId));
|
|
46109
46291
|
return true;
|
|
46110
46292
|
} catch {
|
|
46111
46293
|
return false;
|
|
@@ -46113,7 +46295,7 @@ function writeAuditFile(record2) {
|
|
|
46113
46295
|
}
|
|
46114
46296
|
function readAudit(deliveryId) {
|
|
46115
46297
|
try {
|
|
46116
|
-
const data = JSON.parse(
|
|
46298
|
+
const data = JSON.parse(fs42.readFileSync(auditPath(deliveryId), "utf8"));
|
|
46117
46299
|
return { sessions: Array.isArray(data?.sessions) ? data.sessions : [] };
|
|
46118
46300
|
} catch {
|
|
46119
46301
|
return null;
|
|
@@ -46128,7 +46310,7 @@ function syncAudit(deliveryId, just) {
|
|
|
46128
46310
|
}
|
|
46129
46311
|
function wholeAudit(file2) {
|
|
46130
46312
|
try {
|
|
46131
|
-
const data = JSON.parse(
|
|
46313
|
+
const data = JSON.parse(fs42.readFileSync(file2, "utf8"));
|
|
46132
46314
|
return typeof data?.deliveryId === "string" && Array.isArray(data.sessions) ? data : null;
|
|
46133
46315
|
} catch {
|
|
46134
46316
|
return null;
|
|
@@ -46141,7 +46323,7 @@ function activeAudit(file2) {
|
|
|
46141
46323
|
function allAudits() {
|
|
46142
46324
|
let names2;
|
|
46143
46325
|
try {
|
|
46144
|
-
names2 =
|
|
46326
|
+
names2 = fs42.readdirSync(DELIVERIES);
|
|
46145
46327
|
} catch {
|
|
46146
46328
|
return [];
|
|
46147
46329
|
}
|
|
@@ -46270,7 +46452,7 @@ function resumeRecord(id2, execution) {
|
|
|
46270
46452
|
const found2 = namedDelivery(id2) ?? endedDelivery(id2);
|
|
46271
46453
|
if (!found2) return { ok: false, ...unknownDelivery(id2) };
|
|
46272
46454
|
const file2 = found2.cardId === null ? null : cardFile(found2.cardId);
|
|
46273
|
-
const restored = file2 && parseFrontmatter(
|
|
46455
|
+
const restored = file2 && parseFrontmatter(fs42.readFileSync(file2, "utf8")).meta?.restored;
|
|
46274
46456
|
if (restored && Date.parse(restored) > found2.startedAt) return { ok: false, ...unknownDelivery(id2) };
|
|
46275
46457
|
if (found2.status === "finished") return { ok: true, delivery: found2 };
|
|
46276
46458
|
const refused = resumeRefusal(found2);
|
|
@@ -46316,7 +46498,7 @@ function approvedRequirements(cardId2) {
|
|
|
46316
46498
|
const file2 = found2.kind === "group" ? path44.join(found2.target, "root.md") : found2.target;
|
|
46317
46499
|
let text5;
|
|
46318
46500
|
try {
|
|
46319
|
-
text5 =
|
|
46501
|
+
text5 = fs42.readFileSync(file2, "utf8");
|
|
46320
46502
|
} catch {
|
|
46321
46503
|
return "";
|
|
46322
46504
|
}
|
|
@@ -46327,7 +46509,7 @@ function cardMeta2(cardId2) {
|
|
|
46327
46509
|
const found2 = locate(cardId2);
|
|
46328
46510
|
if (!found2) return null;
|
|
46329
46511
|
const file2 = found2.kind === "group" ? path44.join(found2.target, "root.md") : found2.target;
|
|
46330
|
-
return parseFrontmatter(
|
|
46512
|
+
return parseFrontmatter(fs42.readFileSync(file2, "utf8")).meta;
|
|
46331
46513
|
} catch {
|
|
46332
46514
|
return null;
|
|
46333
46515
|
}
|
|
@@ -46485,7 +46667,7 @@ var init_deliveries = __esm({
|
|
|
46485
46667
|
activeAudits = () => allAudits().filter((a) => a.status === "active");
|
|
46486
46668
|
auditRow = (audit) => readDeliveryRow({ ...audit, sessions: audit.sessions.map((s) => s.sessionId) });
|
|
46487
46669
|
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) &&
|
|
46670
|
+
localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) => path44.resolve(REPO_ROOT, session.log) === logPathOf(session.sessionId) && fs42.existsSync(logPathOf(session.sessionId)));
|
|
46489
46671
|
unknownDelivery = (id2) => refusal("deliveryNotFound", `no delivery here answers to "${id2}"`, { id: id2 });
|
|
46490
46672
|
isResumable = (delivery) => !resumeRefusal(delivery);
|
|
46491
46673
|
cardStatus = (cardId2) => cardMeta2(cardId2)?.status || "todo";
|
|
@@ -46816,14 +46998,15 @@ function startableBinary(binary, harness, pinned2 = false) {
|
|
|
46816
46998
|
const note = brokenEntryNote(copy2, own2, harness);
|
|
46817
46999
|
return { binary: spawnName(copy2, own2), ...note ? { note } : {} };
|
|
46818
47000
|
}
|
|
46819
|
-
function readBlock2(harness, block, argv, runtimeId, secretRefs = {}) {
|
|
47001
|
+
function readBlock2(harness, block, argv, runtimeId, secretRefs = {}, executionSecrets) {
|
|
46820
47002
|
const values = {};
|
|
46821
47003
|
const ignored = [];
|
|
46822
47004
|
const secretsSet = [];
|
|
46823
|
-
const env2 = harness.settings.some((s) => s.kind === "secret") ? readEnvFile() : {};
|
|
47005
|
+
const env2 = !executionSecrets && harness.settings.some((s) => s.kind === "secret") ? readEnvFile() : {};
|
|
46824
47006
|
for (const setting of harness.settings) {
|
|
46825
47007
|
if (setting.kind === "secret") {
|
|
46826
|
-
|
|
47008
|
+
const value2 = executionSecrets ? executionSecrets[setting.key] : setting.env && env2[secretRefs[setting.env] ?? secretVar(setting.env, runtimeId)];
|
|
47009
|
+
if (value2) secretsSet.push(setting.key);
|
|
46827
47010
|
continue;
|
|
46828
47011
|
}
|
|
46829
47012
|
const value = block[setting.key]?.trim() ?? "";
|
|
@@ -46840,11 +47023,8 @@ function readBlock2(harness, block, argv, runtimeId, secretRefs = {}) {
|
|
|
46840
47023
|
}
|
|
46841
47024
|
function onOwnEndpoint(runtimeId) {
|
|
46842
47025
|
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");
|
|
47026
|
+
if (!runtimeId || !runRuntimeById(runtimeId)) return false;
|
|
47027
|
+
return !!activeProviderOf(resolveHarness({ pin: runtimeId }))?.needs.includes("baseUrl");
|
|
46848
47028
|
} catch {
|
|
46849
47029
|
return true;
|
|
46850
47030
|
}
|
|
@@ -46853,12 +47033,15 @@ function resolveHarness(ask2 = {}) {
|
|
|
46853
47033
|
const cfg = safeConfig();
|
|
46854
47034
|
const staleCommand = typeof cfg.command === "string" && cfg.command.trim() ? true : void 0;
|
|
46855
47035
|
const agent = ask2.agent ?? "";
|
|
46856
|
-
const
|
|
46857
|
-
const
|
|
47036
|
+
const execution = executionRuntimes();
|
|
47037
|
+
const scoped = execution && [execution.default, ...Object.values(execution.picks)];
|
|
47038
|
+
const list3 = scoped ?? readRuntimes(cfg);
|
|
46858
47039
|
const owner = agent ? runtimeOwner(agent) : "";
|
|
46859
|
-
const picked = owner ? runtimeOfAgent(owner,
|
|
47040
|
+
const picked = owner ? execution ? execution.picks[owner]?.id : runtimeOfAgent(owner, readAgentRuntime(cfg)) : void 0;
|
|
46860
47041
|
const asked = ask2.pin ?? picked;
|
|
46861
47042
|
const runtime = pickRuntime(list3, asked, ask2.harness);
|
|
47043
|
+
const credentialId = scoped?.find((row) => row === runtime)?.credentialId;
|
|
47044
|
+
const executionSecrets = execution && (credentialId ? readRuntimeCredentials(execution.credentialsFile)[credentialId] ?? {} : {});
|
|
46862
47045
|
const unknownAgentRuntime = picked && !ask2.pin && !list3.some((r) => r.id === picked || r.harness === picked) ? picked : void 0;
|
|
46863
47046
|
const known2 = harnessByName(runtime.harness);
|
|
46864
47047
|
const harness = known2 ?? DEFAULT_HARNESS;
|
|
@@ -46868,7 +47051,8 @@ function resolveHarness(ask2 = {}) {
|
|
|
46868
47051
|
runtime.settings,
|
|
46869
47052
|
splitCommand(command),
|
|
46870
47053
|
runtime.id,
|
|
46871
|
-
runtime.secretRefs
|
|
47054
|
+
runtime.secretRefs,
|
|
47055
|
+
executionSecrets
|
|
46872
47056
|
);
|
|
46873
47057
|
return {
|
|
46874
47058
|
runtime,
|
|
@@ -46879,6 +47063,7 @@ function resolveHarness(ask2 = {}) {
|
|
|
46879
47063
|
unknownAgentRuntime,
|
|
46880
47064
|
values,
|
|
46881
47065
|
secretsSet,
|
|
47066
|
+
executionSecrets,
|
|
46882
47067
|
ignored,
|
|
46883
47068
|
unknownName: known2 ? void 0 : runtime.harness || void 0,
|
|
46884
47069
|
staleCommand
|
|
@@ -46922,6 +47107,7 @@ function settingSaveError(key, value, ask2 = {}) {
|
|
|
46922
47107
|
}
|
|
46923
47108
|
function runEnv2(resolved, cwd = REPO_ROOT) {
|
|
46924
47109
|
const { harness, runtime } = resolved;
|
|
47110
|
+
if (resolved.executionSecrets) return settingEnv(harness, resolved, resolved.executionSecrets, cwd);
|
|
46925
47111
|
const file2 = readEnvFile();
|
|
46926
47112
|
const secrets = {};
|
|
46927
47113
|
for (const setting of harness.settings) {
|
|
@@ -46951,7 +47137,7 @@ function planResume(session, agent, own2 = {}) {
|
|
|
46951
47137
|
if (!harnessByName(harnessName)) return null;
|
|
46952
47138
|
const resolved = resolveHarness({ agent, ...own2, harness: harnessName });
|
|
46953
47139
|
const { harness, command, runtime } = resolved;
|
|
46954
|
-
if (!harness.resumes) return null;
|
|
47140
|
+
if (!harness.resumes || resolved.executionSecrets && !runtime.id) return null;
|
|
46955
47141
|
const argv = splitCommand(command);
|
|
46956
47142
|
return {
|
|
46957
47143
|
harness: harness.name,
|
|
@@ -46970,7 +47156,7 @@ function planFork(session, agent, own2 = {}, sessionId = randomUUID5()) {
|
|
|
46970
47156
|
if (!harnessByName(harnessName)) return null;
|
|
46971
47157
|
const resolved = resolveHarness({ agent, ...own2, harness: harnessName });
|
|
46972
47158
|
const { harness, command, runtime } = resolved;
|
|
46973
|
-
if (!harness.forkArgs || harness.name !== harnessName) return null;
|
|
47159
|
+
if (!harness.forkArgs || harness.name !== harnessName || resolved.executionSecrets && !runtime.id) return null;
|
|
46974
47160
|
const argv = splitCommand(command);
|
|
46975
47161
|
return {
|
|
46976
47162
|
harness: harness.name,
|
|
@@ -47198,31 +47384,31 @@ var init_resolve = __esm({
|
|
|
47198
47384
|
});
|
|
47199
47385
|
|
|
47200
47386
|
// ../cli/src/lib/agent/pictures.ts
|
|
47201
|
-
import
|
|
47387
|
+
import fs43 from "node:fs";
|
|
47202
47388
|
import path46 from "node:path";
|
|
47203
47389
|
function claimRunPictures(box, sessionId, names2 = []) {
|
|
47204
47390
|
if (!box || !freeBox(box) || names2.length === 0) return [];
|
|
47205
47391
|
const from = pictureBox(box);
|
|
47206
47392
|
const to = pictureBox(sessionId);
|
|
47207
47393
|
try {
|
|
47208
|
-
|
|
47209
|
-
|
|
47394
|
+
fs43.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
47395
|
+
fs43.renameSync(from, to);
|
|
47210
47396
|
} catch {
|
|
47211
47397
|
return [];
|
|
47212
47398
|
}
|
|
47213
|
-
return names2.filter(pictureName).map((name) => path46.join(to, name)).filter((file2) =>
|
|
47399
|
+
return names2.filter(pictureName).map((name) => path46.join(to, name)).filter((file2) => fs43.existsSync(file2));
|
|
47214
47400
|
}
|
|
47215
47401
|
function returnRunPictures(sessionId, box) {
|
|
47216
47402
|
if (!box || !boxId(box)) return;
|
|
47217
47403
|
try {
|
|
47218
|
-
|
|
47404
|
+
fs43.renameSync(pictureBox(sessionId), pictureBox(box));
|
|
47219
47405
|
} catch {
|
|
47220
47406
|
}
|
|
47221
47407
|
}
|
|
47222
47408
|
function moveRunPictures(from, to, files = []) {
|
|
47223
47409
|
if (files.length === 0) return [];
|
|
47224
47410
|
try {
|
|
47225
|
-
|
|
47411
|
+
fs43.renameSync(pictureBox(from), pictureBox(to));
|
|
47226
47412
|
} catch {
|
|
47227
47413
|
return files;
|
|
47228
47414
|
}
|
|
@@ -47235,7 +47421,7 @@ var init_pictures = __esm({
|
|
|
47235
47421
|
init_paths();
|
|
47236
47422
|
pictureName = (name) => /^[0-9a-f-]{36}\.[a-z0-9]{2,5}$/.test(name);
|
|
47237
47423
|
boxId = (box) => /^[0-9a-f-]{36}$/.test(box);
|
|
47238
|
-
freeBox = (box) => boxId(box) && !
|
|
47424
|
+
freeBox = (box) => boxId(box) && !fs43.existsSync(path46.join(SESSIONS_DIR, `${box}.log`));
|
|
47239
47425
|
pictureBox = (box) => path46.join(SESSIONS_DIR, `${box}.images`);
|
|
47240
47426
|
}
|
|
47241
47427
|
});
|
|
@@ -47337,7 +47523,7 @@ var init_facts = __esm({
|
|
|
47337
47523
|
});
|
|
47338
47524
|
|
|
47339
47525
|
// ../cli/src/lib/view/archive.ts
|
|
47340
|
-
import
|
|
47526
|
+
import fs44 from "node:fs";
|
|
47341
47527
|
import path47 from "node:path";
|
|
47342
47528
|
function archivedId(file2) {
|
|
47343
47529
|
const own2 = idPrefix(path47.basename(file2));
|
|
@@ -47346,7 +47532,7 @@ function archivedId(file2) {
|
|
|
47346
47532
|
function readFile(file2) {
|
|
47347
47533
|
const id2 = archivedId(file2);
|
|
47348
47534
|
if (id2 === null) return null;
|
|
47349
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
47535
|
+
const { meta: meta3, body } = parseFrontmatter(fs44.readFileSync(file2, "utf8"));
|
|
47350
47536
|
if (!meta3) return null;
|
|
47351
47537
|
return {
|
|
47352
47538
|
row: {
|
|
@@ -47362,7 +47548,7 @@ function readFile(file2) {
|
|
|
47362
47548
|
}
|
|
47363
47549
|
function readArchive() {
|
|
47364
47550
|
const relPath = rel(ARCHIVE).split(path47.sep).join("/");
|
|
47365
|
-
if (!
|
|
47551
|
+
if (!fs44.existsSync(ARCHIVE)) return { relPath, cards: [] };
|
|
47366
47552
|
const cards = walkMd(ARCHIVE).map(readFile).filter((found2) => found2 !== null).map((found2) => found2.row);
|
|
47367
47553
|
cards.sort((a, b) => b.id - a.id);
|
|
47368
47554
|
return { relPath, cards };
|
|
@@ -47717,16 +47903,16 @@ var init_prompts = __esm({
|
|
|
47717
47903
|
|
|
47718
47904
|
// ../cli/src/lib/agent/stop.ts
|
|
47719
47905
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
47720
|
-
import
|
|
47906
|
+
import fs45 from "node:fs";
|
|
47721
47907
|
function markedInProc(entry, strict = false, since) {
|
|
47722
47908
|
const pids = [];
|
|
47723
|
-
for (const name of
|
|
47909
|
+
for (const name of fs45.readdirSync("/proc")) {
|
|
47724
47910
|
if (!/^\d+$/.test(name)) continue;
|
|
47725
47911
|
try {
|
|
47726
|
-
if (
|
|
47912
|
+
if (fs45.readFileSync(`/proc/${name}/environ`, "utf8").split("\0").includes(entry)) pids.push(Number(name));
|
|
47727
47913
|
} catch (error62) {
|
|
47728
47914
|
if (strict && !["ENOENT", "ESRCH"].includes(error62.code ?? "")) {
|
|
47729
|
-
const stat =
|
|
47915
|
+
const stat = fs45.statSync(`/proc/${name}`, { throwIfNoEntry: false });
|
|
47730
47916
|
if (stat?.uid === process.getuid?.() && !startedBefore(Number(name), since)) throw error62;
|
|
47731
47917
|
}
|
|
47732
47918
|
}
|
|
@@ -47936,7 +48122,7 @@ var init_creation_lock = __esm({
|
|
|
47936
48122
|
|
|
47937
48123
|
// ../cli/src/lib/agent/sessions.ts
|
|
47938
48124
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
47939
|
-
import
|
|
48125
|
+
import fs46 from "node:fs";
|
|
47940
48126
|
import path50 from "node:path";
|
|
47941
48127
|
function reap(runs, reaped = [], restore = []) {
|
|
47942
48128
|
let changed = false;
|
|
@@ -47963,7 +48149,7 @@ function reap(runs, reaped = [], restore = []) {
|
|
|
47963
48149
|
}
|
|
47964
48150
|
function stampDuration(run3, endedAt) {
|
|
47965
48151
|
try {
|
|
47966
|
-
|
|
48152
|
+
fs46.appendFileSync(run3.logPath, durationLine(endedAt - run3.startedAt));
|
|
47967
48153
|
} catch {
|
|
47968
48154
|
}
|
|
47969
48155
|
}
|
|
@@ -47977,7 +48163,7 @@ function cardNow(cardId2) {
|
|
|
47977
48163
|
try {
|
|
47978
48164
|
const file2 = cardFile(cardId2);
|
|
47979
48165
|
if (!file2) return null;
|
|
47980
|
-
const { meta: meta3 } = parseFrontmatter(
|
|
48166
|
+
const { meta: meta3 } = parseFrontmatter(fs46.readFileSync(file2, "utf8"));
|
|
47981
48167
|
if (!meta3) return null;
|
|
47982
48168
|
return { status: meta3.status || "todo", questions: meta3.questions.length, title: meta3.title };
|
|
47983
48169
|
} catch {
|
|
@@ -48222,7 +48408,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID6(), said2) {
|
|
|
48222
48408
|
if (retired) return retired;
|
|
48223
48409
|
if (req.deliveryId && findDelivery(req.deliveryId)?.scheduled) return retiredStudioRun("scheduled");
|
|
48224
48410
|
const cardId2 = Number.isInteger(req.id) ? req.id : null;
|
|
48225
|
-
if (req.runtime && !
|
|
48411
|
+
if (req.runtime && !runRuntimeById(req.runtime)) {
|
|
48226
48412
|
const runtimes = readRuntimes().map((r) => r.id).join(", ");
|
|
48227
48413
|
return refusal("runtimeNotFound", `this board has no runtime called "${req.runtime}". It has: ${runtimes}.`, {
|
|
48228
48414
|
id: req.runtime,
|
|
@@ -48245,7 +48431,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID6(), said2) {
|
|
|
48245
48431
|
const parent = req.action === "sub" && req.parentId ? peekRun(req.parentId) : void 0;
|
|
48246
48432
|
const cwd = parent?.cwd ?? deliveryCwd(start ?? joining ?? {});
|
|
48247
48433
|
const plan = said2 ? { ...said2.plan(cwd, sessionId), note: null } : planRun(sessionId, cwd, agentForRun(req), req.runtime ? { pin: req.runtime } : {});
|
|
48248
|
-
const away = plan.runtime ?
|
|
48434
|
+
const away = plan.runtime ? runRuntimeById(plan.runtime)?.away : void 0;
|
|
48249
48435
|
if (away) return refusal("runtimeAway", away, { id: plan.runtime });
|
|
48250
48436
|
if (plan.note) notes = [...notes, plan.note];
|
|
48251
48437
|
const record2 = {
|
|
@@ -48316,7 +48502,16 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID6(), said2) {
|
|
|
48316
48502
|
}
|
|
48317
48503
|
function planningSession(cardId2, cwd = REPO_ROOT) {
|
|
48318
48504
|
const here = (dir) => !dir || path50.resolve(dir) === cwd;
|
|
48319
|
-
const
|
|
48505
|
+
const safeToContinue = (r) => {
|
|
48506
|
+
if (r.status === "done") return true;
|
|
48507
|
+
if (r.status !== "stopped" && r.status !== "error" && r.status !== "interrupted") return false;
|
|
48508
|
+
if (r.pendingWrites || r.cleanup?.status === "unconfirmed") return false;
|
|
48509
|
+
if (isSessionMissingFailure(r.failure)) return false;
|
|
48510
|
+
const root2 = r.agentPid ? { pid: r.agentPid, since: r.agentStartedAt ?? r.startedAt, identity: r.agentIdentity } : void 0;
|
|
48511
|
+
const stopped2 = r.managedProcess ? connectionStopped(root2) : processesStopped(runMark(r.sessionId, r.agentStartedAt ?? r.startedAt), root2);
|
|
48512
|
+
return stopped2;
|
|
48513
|
+
};
|
|
48514
|
+
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
48515
|
if (!planned) return { none: "unrecorded" };
|
|
48321
48516
|
if (!here(planned.cwd)) return { none: "elsewhere" };
|
|
48322
48517
|
const resumeId = resumeSessionId(planned);
|
|
@@ -48404,14 +48599,15 @@ async function openResume(id2, options) {
|
|
|
48404
48599
|
const automatic = typeof options === "object" && options.automatic === true;
|
|
48405
48600
|
const pending = !forced && prev.status !== "stopped" ? prev.retry?.pending : void 0;
|
|
48406
48601
|
if (automatic && !pending) return refusal("runContinued", "The automatic retry is no longer pending.");
|
|
48407
|
-
const
|
|
48602
|
+
const resetReplay = pending?.sessionAction === "reset_replay";
|
|
48603
|
+
const session = forced || resetReplay ? void 0 : resumeSessionId(prev);
|
|
48408
48604
|
if (pending || requireSession) {
|
|
48409
48605
|
const root2 = prev.agentPid ? { pid: prev.agentPid, since: prev.agentStartedAt ?? prev.startedAt, identity: prev.agentIdentity } : void 0;
|
|
48410
48606
|
const stopped2 = prev.managedProcess ? connectionStopped(root2) : processesStopped(runMark(prev.sessionId, prev.agentStartedAt), root2);
|
|
48411
48607
|
const recovery = agentRecovery({
|
|
48412
48608
|
stopped: stopped2,
|
|
48413
48609
|
session,
|
|
48414
|
-
replayable: !requireSession && neverStarted(prev),
|
|
48610
|
+
replayable: !requireSession && (neverStarted(prev) || resetReplay),
|
|
48415
48611
|
unconfirmedCleanup: prev.pendingWrites || prev.cleanup?.status === "unconfirmed" || prev.managedProcess && (pending?.failure ?? prev.failure)?.code === "idle_timeout" && !idleStopConfirmed(prev.cleanup, session)
|
|
48416
48612
|
});
|
|
48417
48613
|
if (recovery === "unsafe") {
|
|
@@ -48426,10 +48622,10 @@ async function openResume(id2, options) {
|
|
|
48426
48622
|
const sessionId = randomUUID6();
|
|
48427
48623
|
let plan;
|
|
48428
48624
|
let fresh;
|
|
48429
|
-
if (!forced && prev.harness === "antigravity" && !session && !neverStarted(prev)) {
|
|
48625
|
+
if (!forced && !resetReplay && prev.harness === "antigravity" && !session && !neverStarted(prev)) {
|
|
48430
48626
|
return refusal("runNoSession", "Antigravity did not record a conversation ID before interruption. The original session cannot be resumed.");
|
|
48431
48627
|
}
|
|
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.");
|
|
48628
|
+
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
48629
|
if (session) {
|
|
48434
48630
|
plan = planResume({ harness: prev.harness, resumeId: session, cwd }, prev.agent, prev.runtime ? { pin: prev.runtime } : {});
|
|
48435
48631
|
} else {
|
|
@@ -48450,12 +48646,12 @@ async function openResume(id2, options) {
|
|
|
48450
48646
|
if ("error" in opened) return opened;
|
|
48451
48647
|
if (!opened.spec.prompt && buildResume) opened.spec.prompt = buildResume;
|
|
48452
48648
|
if (build?.notes?.trim()) opened.spec.prompt = [opened.spec.prompt || resumePrompt(prev.deliveryId, prev.action), build.notes.trim()].join("\n\n");
|
|
48453
|
-
if (session &&
|
|
48649
|
+
if (session && requireSession && !pending) opened.spec.prompt = [recoveryPrompt, opened.spec.prompt].filter(Boolean).join("\n\n");
|
|
48454
48650
|
if (build || buildResume || pending || requireSession) writeSpec(opened.spec);
|
|
48455
48651
|
return opened;
|
|
48456
48652
|
}
|
|
48457
48653
|
async function planRetry2(prev, ask2, sessionId, cwd) {
|
|
48458
|
-
const runtime = prev.runtime &&
|
|
48654
|
+
const runtime = prev.runtime && runRuntimeById(prev.runtime) ? prev.runtime : void 0;
|
|
48459
48655
|
const { note, ...plan } = planRun(sessionId, cwd, prev.agent ?? agentForRun(ask2), {
|
|
48460
48656
|
...runtime ? { pin: runtime } : {},
|
|
48461
48657
|
...shipsHarness(prev.harness) ? { harness: prev.harness } : {}
|
|
@@ -48505,6 +48701,7 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh, automatic = fa
|
|
|
48505
48701
|
},
|
|
48506
48702
|
failure: automatic ? prev.retry?.pending?.failure : void 0,
|
|
48507
48703
|
retry: prev.retry ? { ...prev.retry, pending: void 0, launching: automatic ? true : void 0 } : void 0,
|
|
48704
|
+
...prev.retryHistory?.length ? { retryHistory: prev.retryHistory } : {},
|
|
48508
48705
|
logPath: logPathOf(sessionId),
|
|
48509
48706
|
specAgent: prev.specAgent,
|
|
48510
48707
|
cards: prev.cards,
|
|
@@ -48569,14 +48766,14 @@ function askForRefine(sessionId, ask2) {
|
|
|
48569
48766
|
}
|
|
48570
48767
|
function clearAsks(sessionId) {
|
|
48571
48768
|
try {
|
|
48572
|
-
|
|
48769
|
+
fs46.unlinkSync(asksPathOf(sessionId));
|
|
48573
48770
|
} catch {
|
|
48574
48771
|
}
|
|
48575
48772
|
}
|
|
48576
48773
|
function readAsks(sessionId) {
|
|
48577
48774
|
let data;
|
|
48578
48775
|
try {
|
|
48579
|
-
data = JSON.parse(
|
|
48776
|
+
data = JSON.parse(fs46.readFileSync(asksPathOf(sessionId), "utf8"));
|
|
48580
48777
|
} catch {
|
|
48581
48778
|
return { refines: [] };
|
|
48582
48779
|
}
|
|
@@ -48593,10 +48790,10 @@ function readAsks(sessionId) {
|
|
|
48593
48790
|
return { refines: refines.filter((a) => !discarded.has(a.cardId)) };
|
|
48594
48791
|
}
|
|
48595
48792
|
function writeAsks(sessionId, file2) {
|
|
48596
|
-
|
|
48793
|
+
fs46.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
48597
48794
|
const tmp = `${asksPathOf(sessionId)}.tmp`;
|
|
48598
|
-
|
|
48599
|
-
|
|
48795
|
+
fs46.writeFileSync(tmp, JSON.stringify(file2, null, 2) + "\n");
|
|
48796
|
+
fs46.renameSync(tmp, asksPathOf(sessionId));
|
|
48600
48797
|
}
|
|
48601
48798
|
function markSpawned(sessionId, pid) {
|
|
48602
48799
|
patch(sessionId, (r) => {
|
|
@@ -48623,6 +48820,7 @@ async function closeRun(sessionId, res) {
|
|
|
48623
48820
|
if (res.error) run3.error = res.error;
|
|
48624
48821
|
run3.failure = res.failure;
|
|
48625
48822
|
run3.retryPause = res.retryPause;
|
|
48823
|
+
if (res.retryHistory?.length) run3.retryHistory = res.retryHistory;
|
|
48626
48824
|
if (run3.retry) {
|
|
48627
48825
|
delete run3.retry.launching;
|
|
48628
48826
|
if (res.status === "stopped") delete run3.retry.pending;
|
|
@@ -48751,7 +48949,7 @@ async function reconcileCardDelivery(cardId2) {
|
|
|
48751
48949
|
result = withStore((store) => {
|
|
48752
48950
|
reap(store.runs, reaped, restore);
|
|
48753
48951
|
const file2 = cardFile(cardId2);
|
|
48754
|
-
const restoredRaw = file2 ? parseFrontmatter(
|
|
48952
|
+
const restoredRaw = file2 ? parseFrontmatter(fs46.readFileSync(file2, "utf8")).meta?.restored : void 0;
|
|
48755
48953
|
const restoredAt = restoredRaw ? Date.parse(restoredRaw) : Number.NaN;
|
|
48756
48954
|
const merged = /* @__PURE__ */ new Map();
|
|
48757
48955
|
for (const audit of cardAudits(cardId2)) merged.set(audit.deliveryId, audit);
|
|
@@ -48879,12 +49077,12 @@ async function resumeDelivery(id2) {
|
|
|
48879
49077
|
return { ok: true, deliveryId: delivery.deliveryId, carryOn };
|
|
48880
49078
|
}
|
|
48881
49079
|
function writeSpec(spec) {
|
|
48882
|
-
|
|
48883
|
-
|
|
49080
|
+
fs46.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
49081
|
+
fs46.writeFileSync(specPathOf(spec.sessionId), JSON.stringify(spec, null, 2) + "\n");
|
|
48884
49082
|
}
|
|
48885
49083
|
function readSpec(sessionId) {
|
|
48886
49084
|
try {
|
|
48887
|
-
const spec = JSON.parse(
|
|
49085
|
+
const spec = JSON.parse(fs46.readFileSync(specPathOf(sessionId), "utf8"));
|
|
48888
49086
|
return spec && Array.isArray(spec.plan?.argv) ? spec : null;
|
|
48889
49087
|
} catch {
|
|
48890
49088
|
return null;
|
|
@@ -48892,7 +49090,7 @@ function readSpec(sessionId) {
|
|
|
48892
49090
|
}
|
|
48893
49091
|
function dropSpec(sessionId) {
|
|
48894
49092
|
try {
|
|
48895
|
-
|
|
49093
|
+
fs46.unlinkSync(specPathOf(sessionId));
|
|
48896
49094
|
} catch {
|
|
48897
49095
|
}
|
|
48898
49096
|
}
|
|
@@ -48902,18 +49100,18 @@ async function acquireIndexLock(giveUp) {
|
|
|
48902
49100
|
for (; ; ) {
|
|
48903
49101
|
if (giveUp()) return null;
|
|
48904
49102
|
try {
|
|
48905
|
-
|
|
48906
|
-
|
|
48907
|
-
return () =>
|
|
49103
|
+
fs46.mkdirSync(INDEX_LOCK2, { recursive: false });
|
|
49104
|
+
fs46.writeFileSync(holder, String(process.pid));
|
|
49105
|
+
return () => fs46.rmSync(INDEX_LOCK2, { recursive: true, force: true });
|
|
48908
49106
|
} catch (err) {
|
|
48909
49107
|
const code = err.code;
|
|
48910
49108
|
if (code === "ENOENT") {
|
|
48911
|
-
|
|
49109
|
+
fs46.mkdirSync(path50.dirname(INDEX_LOCK2), { recursive: true });
|
|
48912
49110
|
continue;
|
|
48913
49111
|
}
|
|
48914
49112
|
if (code !== "EEXIST") throw err;
|
|
48915
49113
|
if (!pidAlive(Number(readHolder(holder)))) {
|
|
48916
|
-
|
|
49114
|
+
fs46.rmSync(INDEX_LOCK2, { recursive: true, force: true });
|
|
48917
49115
|
continue;
|
|
48918
49116
|
}
|
|
48919
49117
|
if (Date.now() > until) return null;
|
|
@@ -48923,7 +49121,7 @@ async function acquireIndexLock(giveUp) {
|
|
|
48923
49121
|
}
|
|
48924
49122
|
function readHolder(file2) {
|
|
48925
49123
|
try {
|
|
48926
|
-
return
|
|
49124
|
+
return fs46.readFileSync(file2, "utf8").trim();
|
|
48927
49125
|
} catch {
|
|
48928
49126
|
return String(process.pid);
|
|
48929
49127
|
}
|
|
@@ -49062,7 +49260,7 @@ var init_sources = __esm({
|
|
|
49062
49260
|
});
|
|
49063
49261
|
|
|
49064
49262
|
// ../cli/src/lib/signals/inbox.ts
|
|
49065
|
-
import
|
|
49263
|
+
import fs47 from "node:fs";
|
|
49066
49264
|
import path51 from "node:path";
|
|
49067
49265
|
function metaPair(key, value) {
|
|
49068
49266
|
const name = typeof key === "string" ? key.trim() : "";
|
|
@@ -49094,7 +49292,7 @@ ${signal2.summary.trim()}
|
|
|
49094
49292
|
function parse3(file2, lenient = false) {
|
|
49095
49293
|
let text5;
|
|
49096
49294
|
try {
|
|
49097
|
-
text5 =
|
|
49295
|
+
text5 = fs47.readFileSync(file2, "utf8");
|
|
49098
49296
|
} catch {
|
|
49099
49297
|
return null;
|
|
49100
49298
|
}
|
|
@@ -49149,13 +49347,13 @@ function freeName(dir, wanted) {
|
|
|
49149
49347
|
const ext = path51.extname(wanted);
|
|
49150
49348
|
const stem = wanted.slice(0, wanted.length - ext.length);
|
|
49151
49349
|
let name = wanted;
|
|
49152
|
-
for (let n = 2;
|
|
49350
|
+
for (let n = 2; fs47.existsSync(path51.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
|
|
49153
49351
|
return name;
|
|
49154
49352
|
}
|
|
49155
49353
|
function readFolder(dir, lenient = false) {
|
|
49156
49354
|
let entries2;
|
|
49157
49355
|
try {
|
|
49158
|
-
entries2 =
|
|
49356
|
+
entries2 = fs47.readdirSync(dir, { withFileTypes: true });
|
|
49159
49357
|
} catch {
|
|
49160
49358
|
return [];
|
|
49161
49359
|
}
|
|
@@ -49167,7 +49365,7 @@ function readInbox() {
|
|
|
49167
49365
|
return signals;
|
|
49168
49366
|
}
|
|
49169
49367
|
function writeSignal(incoming, importedAt, slug = "") {
|
|
49170
|
-
|
|
49368
|
+
fs47.mkdirSync(TRIAGE, { recursive: true });
|
|
49171
49369
|
const signal2 = {
|
|
49172
49370
|
...incoming,
|
|
49173
49371
|
importedAt,
|
|
@@ -49180,11 +49378,11 @@ function writeSignal(incoming, importedAt, slug = "") {
|
|
|
49180
49378
|
relPath: ""
|
|
49181
49379
|
};
|
|
49182
49380
|
const file2 = path51.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug)));
|
|
49183
|
-
|
|
49381
|
+
fs47.writeFileSync(file2, serialize({ ...signal2, relPath: boardRel(file2) }));
|
|
49184
49382
|
return { ...signal2, relPath: boardRel(file2) };
|
|
49185
49383
|
}
|
|
49186
49384
|
function stamp3(file2, fields2) {
|
|
49187
|
-
const text5 =
|
|
49385
|
+
const text5 = fs47.readFileSync(file2, "utf8");
|
|
49188
49386
|
const lines = text5.split("\n");
|
|
49189
49387
|
const close = lines.indexOf("---", 1);
|
|
49190
49388
|
if (close < 0) return;
|
|
@@ -49193,13 +49391,13 @@ function stamp3(file2, fields2) {
|
|
|
49193
49391
|
return !key || fields2[key[1]] === void 0;
|
|
49194
49392
|
});
|
|
49195
49393
|
const added = Object.entries(fields2).flatMap(([key, value]) => value === null ? [] : [`${key}: ${yamlScalar(value)}`]);
|
|
49196
|
-
|
|
49394
|
+
fs47.writeFileSync(file2, ["---", ...kept2, ...added, ...lines.slice(close)].join("\n"));
|
|
49197
49395
|
}
|
|
49198
49396
|
function moveSignal(from, into, fields2) {
|
|
49199
|
-
if (!
|
|
49200
|
-
|
|
49397
|
+
if (!fs47.existsSync(from)) return "";
|
|
49398
|
+
fs47.mkdirSync(into, { recursive: true });
|
|
49201
49399
|
const at = path51.join(into, freeName(into, path51.basename(from)));
|
|
49202
|
-
|
|
49400
|
+
fs47.renameSync(from, at);
|
|
49203
49401
|
stamp3(at, fields2);
|
|
49204
49402
|
return boardRel(at);
|
|
49205
49403
|
}
|
|
@@ -49447,12 +49645,12 @@ var init_studio_cards = __esm({
|
|
|
49447
49645
|
});
|
|
49448
49646
|
|
|
49449
49647
|
// ../cli/src/lib/readme.ts
|
|
49450
|
-
import
|
|
49648
|
+
import fs48 from "node:fs";
|
|
49451
49649
|
import path52 from "node:path";
|
|
49452
49650
|
function stripReadmeRefs(target) {
|
|
49453
|
-
if (!
|
|
49651
|
+
if (!fs48.existsSync(README)) return [];
|
|
49454
49652
|
const needle = target.kind === "group" ? `](${target.rel}/` : `](${target.rel})`;
|
|
49455
|
-
const lines =
|
|
49653
|
+
const lines = fs48.readFileSync(README, "utf8").split("\n");
|
|
49456
49654
|
const out = [];
|
|
49457
49655
|
const removed = [];
|
|
49458
49656
|
let i = 0;
|
|
@@ -49474,20 +49672,20 @@ function stripReadmeRefs(target) {
|
|
|
49474
49672
|
out.push(line);
|
|
49475
49673
|
i++;
|
|
49476
49674
|
}
|
|
49477
|
-
if (removed.length)
|
|
49675
|
+
if (removed.length) fs48.writeFileSync(README, out.join("\n"));
|
|
49478
49676
|
return removed;
|
|
49479
49677
|
}
|
|
49480
49678
|
function addReadmeRef(id2, title, relPath) {
|
|
49481
|
-
if (!
|
|
49679
|
+
if (!fs48.existsSync(README)) return false;
|
|
49482
49680
|
const link2 = relPath.split(path52.sep).join("/");
|
|
49483
49681
|
const bullet = `- [#${id2} ${title}](${link2})`;
|
|
49484
49682
|
const heading = `## ${TASKS_HEADING}`;
|
|
49485
|
-
let lines =
|
|
49683
|
+
let lines = fs48.readFileSync(README, "utf8").split("\n");
|
|
49486
49684
|
const hi = lines.findIndex((l) => l.trim().toLowerCase() === heading.toLowerCase());
|
|
49487
49685
|
if (hi === -1) {
|
|
49488
49686
|
while (lines.length && lines[lines.length - 1].trim() === "") lines.pop();
|
|
49489
49687
|
lines.push("", heading, "", bullet);
|
|
49490
|
-
|
|
49688
|
+
fs48.writeFileSync(README, lines.join("\n") + "\n");
|
|
49491
49689
|
return true;
|
|
49492
49690
|
}
|
|
49493
49691
|
let end2 = hi + 1;
|
|
@@ -49501,15 +49699,15 @@ function addReadmeRef(id2, title, relPath) {
|
|
|
49501
49699
|
const at = lastBullet !== -1 ? lastBullet + 1 : lines[hi + 1] === "" ? hi + 2 : hi + 1;
|
|
49502
49700
|
lines.splice(at, 0, bullet);
|
|
49503
49701
|
}
|
|
49504
|
-
|
|
49702
|
+
fs48.writeFileSync(README, lines.join("\n"));
|
|
49505
49703
|
return true;
|
|
49506
49704
|
}
|
|
49507
49705
|
function repointReadmeLink(id2, oldRel, newRel, title) {
|
|
49508
|
-
if (!
|
|
49706
|
+
if (!fs48.existsSync(README)) return false;
|
|
49509
49707
|
const oldLink = oldRel.split(path52.sep).join("/");
|
|
49510
49708
|
const newLink = newRel.split(path52.sep).join("/");
|
|
49511
49709
|
const linkRe = new RegExp(`\\[#${id2}\\b[^\\]]*\\]\\(${escapeRegex2(oldLink)}\\)`);
|
|
49512
|
-
const lines =
|
|
49710
|
+
const lines = fs48.readFileSync(README, "utf8").split("\n");
|
|
49513
49711
|
let changed = false;
|
|
49514
49712
|
for (let i = 0; i < lines.length; i++) {
|
|
49515
49713
|
if (!lines[i].includes(`](${oldLink})`)) continue;
|
|
@@ -49519,7 +49717,7 @@ function repointReadmeLink(id2, oldRel, newRel, title) {
|
|
|
49519
49717
|
changed = true;
|
|
49520
49718
|
}
|
|
49521
49719
|
}
|
|
49522
|
-
if (changed)
|
|
49720
|
+
if (changed) fs48.writeFileSync(README, lines.join("\n"));
|
|
49523
49721
|
return changed;
|
|
49524
49722
|
}
|
|
49525
49723
|
var isTableRow, isBulletStart, bulletIndent, TASKS_HEADING, escapeRegex2;
|
|
@@ -50195,16 +50393,16 @@ var init_collect = __esm({
|
|
|
50195
50393
|
});
|
|
50196
50394
|
|
|
50197
50395
|
// ../cli/src/lib/dress-page.ts
|
|
50198
|
-
import
|
|
50396
|
+
import fs49 from "node:fs";
|
|
50199
50397
|
import path53 from "node:path";
|
|
50200
50398
|
function dressPage(file2) {
|
|
50201
50399
|
const folder2 = path53.dirname(file2);
|
|
50202
|
-
const html =
|
|
50400
|
+
const html = fs49.readFileSync(file2, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
|
|
50203
50401
|
const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
|
|
50204
50402
|
if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
|
|
50205
50403
|
const at2 = path53.resolve(folder2, href);
|
|
50206
|
-
if (!at2.startsWith(folder2 + path53.sep) || !
|
|
50207
|
-
const css =
|
|
50404
|
+
if (!at2.startsWith(folder2 + path53.sep) || !fs49.existsSync(at2)) return tag;
|
|
50405
|
+
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
50406
|
return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
|
|
50209
50407
|
});
|
|
50210
50408
|
const at = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
|
|
@@ -50217,25 +50415,25 @@ var init_dress_page = __esm({
|
|
|
50217
50415
|
isHtmlFile = (file2) => /\.html?$/i.test(file2);
|
|
50218
50416
|
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
50417
|
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) :
|
|
50418
|
+
referenceText = (file2) => isHtmlFile(file2) ? dressPage(file2) : fs49.readFileSync(file2, "utf8");
|
|
50221
50419
|
}
|
|
50222
50420
|
});
|
|
50223
50421
|
|
|
50224
50422
|
// ../cli/src/lib/preview-files.ts
|
|
50225
|
-
import
|
|
50423
|
+
import fs50 from "node:fs";
|
|
50226
50424
|
import path54 from "node:path";
|
|
50227
50425
|
function resolver(card, id2) {
|
|
50228
50426
|
const roots = [KANBAN, path54.join(ASSETS, String(id2))];
|
|
50229
|
-
const real2 = (p) =>
|
|
50427
|
+
const real2 = (p) => fs50.existsSync(p) ? fs50.realpathSync(p) : p;
|
|
50230
50428
|
const inside2 = (p) => roots.some((root2) => p.startsWith(real2(root2) + path54.sep));
|
|
50231
50429
|
return (src, owner) => {
|
|
50232
50430
|
if (/^[a-z][\w+.-]*:/i.test(src) || src.startsWith("#") || src.startsWith("//")) return null;
|
|
50233
50431
|
if (path54.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
|
|
50234
50432
|
const held4 = /^\.assets\//.exec(src);
|
|
50235
50433
|
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:
|
|
50434
|
+
if (!inside2(path54.resolve(file2)) || fs50.existsSync(file2) && !inside2(fs50.realpathSync(file2))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id2}/)`);
|
|
50435
|
+
if (!fs50.statSync(file2, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
|
|
50436
|
+
return { key: fs50.realpathSync(file2), file: file2 };
|
|
50239
50437
|
};
|
|
50240
50438
|
}
|
|
50241
50439
|
function validatePreviewFiles(card, id2, text5) {
|
|
@@ -50278,7 +50476,7 @@ var init_preview_files = __esm({
|
|
|
50278
50476
|
});
|
|
50279
50477
|
|
|
50280
50478
|
// ../cli/src/lib/spec-contract.ts
|
|
50281
|
-
import
|
|
50479
|
+
import fs51 from "node:fs";
|
|
50282
50480
|
import path55 from "node:path";
|
|
50283
50481
|
function scanCardLines(lines, start = 0) {
|
|
50284
50482
|
const visible = lines.map(() => "");
|
|
@@ -50312,11 +50510,11 @@ function scanCardLines(lines, start = 0) {
|
|
|
50312
50510
|
}
|
|
50313
50511
|
function snapshotSpecs() {
|
|
50314
50512
|
const out = /* @__PURE__ */ new Map();
|
|
50315
|
-
if (!
|
|
50513
|
+
if (!fs51.existsSync(TODO)) return out;
|
|
50316
50514
|
for (const file2 of walkMd(TODO)) {
|
|
50317
50515
|
if (isLegacyRecurring(path55.relative(TODO, file2))) continue;
|
|
50318
50516
|
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:
|
|
50517
|
+
if (id2 !== null) out.set(file2, { id: id2, text: fs51.readFileSync(file2, "utf8") });
|
|
50320
50518
|
}
|
|
50321
50519
|
return out;
|
|
50322
50520
|
}
|
|
@@ -50510,9 +50708,9 @@ function setEnd(lines, at) {
|
|
|
50510
50708
|
}
|
|
50511
50709
|
function inside(dir, name) {
|
|
50512
50710
|
try {
|
|
50513
|
-
const root2 =
|
|
50514
|
-
const real2 =
|
|
50515
|
-
return real2.startsWith(root2 + path55.sep) &&
|
|
50711
|
+
const root2 = fs51.realpathSync(dir);
|
|
50712
|
+
const real2 = fs51.realpathSync(path55.join(dir, name));
|
|
50713
|
+
return real2.startsWith(root2 + path55.sep) && fs51.statSync(real2).isFile() ? real2 : null;
|
|
50516
50714
|
} catch {
|
|
50517
50715
|
return null;
|
|
50518
50716
|
}
|
|
@@ -50545,7 +50743,7 @@ function compareProblem(attrs, id2) {
|
|
|
50545
50743
|
const shots = (message) => ({ rule: "compare-shots", message });
|
|
50546
50744
|
const json2 = (file2) => {
|
|
50547
50745
|
try {
|
|
50548
|
-
return file2.endsWith(".json") ? JSON.parse(
|
|
50746
|
+
return file2.endsWith(".json") ? JSON.parse(fs51.readFileSync(file2, "utf8")) : null;
|
|
50549
50747
|
} catch {
|
|
50550
50748
|
return null;
|
|
50551
50749
|
}
|
|
@@ -50570,7 +50768,7 @@ function compareProblem(attrs, id2) {
|
|
|
50570
50768
|
const file2 = inside(dir, named2.name);
|
|
50571
50769
|
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
50770
|
try {
|
|
50573
|
-
return { data: JSON.parse(
|
|
50771
|
+
return { data: JSON.parse(fs51.readFileSync(file2, "utf8")) };
|
|
50574
50772
|
} catch {
|
|
50575
50773
|
return { message: `${at} is not valid JSON.` };
|
|
50576
50774
|
}
|
|
@@ -50625,7 +50823,7 @@ var init_spec_contract = __esm({
|
|
|
50625
50823
|
});
|
|
50626
50824
|
|
|
50627
50825
|
// ../cli/src/lib/reconcile.ts
|
|
50628
|
-
import
|
|
50826
|
+
import fs52 from "node:fs";
|
|
50629
50827
|
import path56 from "node:path";
|
|
50630
50828
|
function liveIds() {
|
|
50631
50829
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -50641,7 +50839,7 @@ function indexableCards() {
|
|
|
50641
50839
|
const out = [];
|
|
50642
50840
|
for (const dir of walkDirs(TODO)) {
|
|
50643
50841
|
const id2 = idPrefix(path56.basename(dir));
|
|
50644
|
-
if (id2 != null &&
|
|
50842
|
+
if (id2 != null && fs52.existsSync(path56.join(dir, "root.md"))) {
|
|
50645
50843
|
out.push({ id: id2, rel: path56.join(path56.relative(TODO, dir), "root.md").split(path56.sep).join("/") });
|
|
50646
50844
|
}
|
|
50647
50845
|
}
|
|
@@ -50658,7 +50856,7 @@ function indexableCards() {
|
|
|
50658
50856
|
}
|
|
50659
50857
|
function readmeComplaints(fix) {
|
|
50660
50858
|
const said2 = [];
|
|
50661
|
-
const lines =
|
|
50859
|
+
const lines = fs52.readFileSync(README, "utf8").split("\n");
|
|
50662
50860
|
const indexed = /* @__PURE__ */ new Set();
|
|
50663
50861
|
let fixed = 0;
|
|
50664
50862
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -50667,7 +50865,7 @@ function readmeComplaints(fix) {
|
|
|
50667
50865
|
const id2 = Number(m[1]);
|
|
50668
50866
|
const linkPath = m[2];
|
|
50669
50867
|
indexed.add(id2);
|
|
50670
|
-
if (
|
|
50868
|
+
if (fs52.existsSync(path56.join(TODO, linkPath))) continue;
|
|
50671
50869
|
const found2 = locate(id2);
|
|
50672
50870
|
if (!found2) {
|
|
50673
50871
|
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 +50881,7 @@ function readmeComplaints(fix) {
|
|
|
50683
50881
|
said2.push(`README link #${id2} pointed at missing ${linkPath} \u2192 repointed to ${want}.`);
|
|
50684
50882
|
fixed++;
|
|
50685
50883
|
}
|
|
50686
|
-
if (fixed)
|
|
50884
|
+
if (fixed) fs52.writeFileSync(README, lines.join("\n"));
|
|
50687
50885
|
for (const c of indexableCards()) {
|
|
50688
50886
|
if (!indexed.has(c.id)) {
|
|
50689
50887
|
said2.push(`card ${c.rel} (#${c.id}) is not in the README index. Add it under "## ${TASKS_HEADING}".`);
|
|
@@ -50699,7 +50897,7 @@ function crossRefComplaints() {
|
|
|
50699
50897
|
if (base === "README.md") continue;
|
|
50700
50898
|
const ownerId = base === "root.md" ? idPrefix(path56.basename(path56.dirname(file2))) : idPrefix(base);
|
|
50701
50899
|
if (ownerId == null) continue;
|
|
50702
|
-
const { meta: meta3 } = parseFrontmatter(
|
|
50900
|
+
const { meta: meta3 } = parseFrontmatter(fs52.readFileSync(file2, "utf8"));
|
|
50703
50901
|
if (!meta3) continue;
|
|
50704
50902
|
for (const field2 of ["blocked_by", "related"]) {
|
|
50705
50903
|
for (const ref of meta3[field2] || []) {
|
|
@@ -50712,7 +50910,7 @@ function crossRefComplaints() {
|
|
|
50712
50910
|
return said2;
|
|
50713
50911
|
}
|
|
50714
50912
|
function reconcileBoard() {
|
|
50715
|
-
if (!
|
|
50913
|
+
if (!fs52.existsSync(README)) return;
|
|
50716
50914
|
for (const line of [...readmeComplaints(true), ...crossRefComplaints()]) warn2(line);
|
|
50717
50915
|
}
|
|
50718
50916
|
var README_LINK;
|
|
@@ -50728,7 +50926,7 @@ var init_reconcile = __esm({
|
|
|
50728
50926
|
});
|
|
50729
50927
|
|
|
50730
50928
|
// ../cli/src/commands/card.ts
|
|
50731
|
-
import
|
|
50929
|
+
import fs53 from "node:fs";
|
|
50732
50930
|
import path57 from "node:path";
|
|
50733
50931
|
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
50932
|
return [
|
|
@@ -50755,7 +50953,7 @@ function bodyFromFile(opts) {
|
|
|
50755
50953
|
if (opts.body === false) die("pass --body-file or --no-body, not both");
|
|
50756
50954
|
let text5;
|
|
50757
50955
|
try {
|
|
50758
|
-
text5 =
|
|
50956
|
+
text5 = fs53.readFileSync(opts.bodyFile, "utf8");
|
|
50759
50957
|
} catch {
|
|
50760
50958
|
die(`can't read ${opts.bodyFile} \u2014 write the body to a file, then pass its path`, { kind: "needs-input" });
|
|
50761
50959
|
}
|
|
@@ -50827,12 +51025,12 @@ function cmdCreate(opts) {
|
|
|
50827
51025
|
return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
|
|
50828
51026
|
}
|
|
50829
51027
|
if (held4) die(`#${start} is already a card here (${rel(held4.target)})`, { kind: "id-taken", id: start });
|
|
50830
|
-
if (
|
|
51028
|
+
if (fs53.existsSync(file2)) die(`${rel(file2)} already exists \u2014 pick a different --slug`);
|
|
50831
51029
|
countBoardEvent(triage ? "cards_created_proposed" : "cards_created_asked");
|
|
50832
51030
|
const meta3 = { title, priority, status: "todo", blocked_by, related, modules, studio, previews, triage, source: source2, questions };
|
|
50833
51031
|
const scaffolded = !written && opts.body !== false;
|
|
50834
51032
|
const body = written ?? (scaffolded ? defaultBody() : "");
|
|
50835
|
-
|
|
51033
|
+
fs53.writeFileSync(file2, serializeFrontmatter(meta3) + "\n\n" + body);
|
|
50836
51034
|
const indexed = addReadmeRef(start, title, fileRel);
|
|
50837
51035
|
say(start);
|
|
50838
51036
|
say(
|
|
@@ -50885,7 +51083,7 @@ function cmdUpdate(id2, flags) {
|
|
|
50885
51083
|
const found2 = locate(id2);
|
|
50886
51084
|
if (!found2) die(`no task with id ${id2} under ${rel(TODO)}`, { kind: "card-not-found", id: id2 });
|
|
50887
51085
|
const file2 = found2.kind === "group" ? path57.join(found2.target, "root.md") : found2.target;
|
|
50888
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
51086
|
+
const { meta: meta3, body } = parseFrontmatter(fs53.readFileSync(file2, "utf8"));
|
|
50889
51087
|
if (!meta3) die(`${rel(file2)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
|
|
50890
51088
|
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
51089
|
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 +51159,9 @@ function cmdUpdate(id2, flags) {
|
|
|
50961
51159
|
const destRel = path57.join(path57.dirname(curRel), base);
|
|
50962
51160
|
const dest = path57.join(TODO, destRel);
|
|
50963
51161
|
const moving = dest !== file2;
|
|
50964
|
-
if (moving &&
|
|
50965
|
-
|
|
50966
|
-
if (moving)
|
|
51162
|
+
if (moving && fs53.existsSync(dest)) die(`${rel(dest)} already exists`);
|
|
51163
|
+
fs53.writeFileSync(file2, serializeFrontmatter(meta3) + "\n" + body);
|
|
51164
|
+
if (moving) fs53.renameSync(file2, dest);
|
|
50967
51165
|
if (isSubtask) {
|
|
50968
51166
|
if (moving || changes.includes("title")) repointReadmeLink(id2, curRel, destRel, meta3.title);
|
|
50969
51167
|
if (moving) changes.push(`renamed \u2192 ${destRel.split(path57.sep).join("/")}`);
|
|
@@ -50985,7 +51183,7 @@ function updateCardQuestions(id2, ops, compatibility = false) {
|
|
|
50985
51183
|
const found2 = locate(id2);
|
|
50986
51184
|
if (!found2) die(`no task with id ${id2} under ${rel(TODO)}`, { kind: "card-not-found", id: id2 });
|
|
50987
51185
|
const file2 = found2.kind === "group" ? path57.join(found2.target, "root.md") : found2.target;
|
|
50988
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
51186
|
+
const { meta: meta3, body } = parseFrontmatter(fs53.readFileSync(file2, "utf8"));
|
|
50989
51187
|
if (!meta3) die(`${rel(file2)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
|
|
50990
51188
|
for (const op of ops) {
|
|
50991
51189
|
if (!compatibility || !op.question?.agent) continue;
|
|
@@ -51007,7 +51205,7 @@ function updateCardQuestions(id2, ops, compatibility = false) {
|
|
|
51007
51205
|
meta3.status = "todo";
|
|
51008
51206
|
changes.push("status\u2192todo (open questions)");
|
|
51009
51207
|
}
|
|
51010
|
-
|
|
51208
|
+
fs53.writeFileSync(file2, serializeFrontmatter(meta3) + "\n" + body);
|
|
51011
51209
|
const closed2 = activeDelivery(id2) ? "questions_closed_verify" : "questions_closed_user";
|
|
51012
51210
|
for (const _ of done.closed) countBoardEvent(closed2);
|
|
51013
51211
|
say(`updated #${id2} questions: ${changes.join(", ")} (${open4} open)`);
|
|
@@ -51066,7 +51264,7 @@ var init_config_template = __esm({
|
|
|
51066
51264
|
});
|
|
51067
51265
|
|
|
51068
51266
|
// ../cli/src/commands/init.ts
|
|
51069
|
-
import
|
|
51267
|
+
import fs54 from "node:fs";
|
|
51070
51268
|
function boardReadme() {
|
|
51071
51269
|
return `# Board
|
|
51072
51270
|
|
|
@@ -51079,20 +51277,20 @@ _(none)_
|
|
|
51079
51277
|
`;
|
|
51080
51278
|
}
|
|
51081
51279
|
function writeConfigIfMissing() {
|
|
51082
|
-
if (
|
|
51083
|
-
|
|
51084
|
-
|
|
51280
|
+
if (fs54.existsSync(CONFIG)) return false;
|
|
51281
|
+
fs54.mkdirSync(KANBAN, { recursive: true });
|
|
51282
|
+
fs54.writeFileSync(CONFIG, CONFIG_TEMPLATE);
|
|
51085
51283
|
return true;
|
|
51086
51284
|
}
|
|
51087
51285
|
function writeModulesIfMissing() {
|
|
51088
|
-
if (
|
|
51089
|
-
|
|
51090
|
-
|
|
51286
|
+
if (fs54.existsSync(MODULES_MD)) return false;
|
|
51287
|
+
fs54.mkdirSync(KANBAN, { recursive: true });
|
|
51288
|
+
fs54.writeFileSync(MODULES_MD, MODULES_TEMPLATE);
|
|
51091
51289
|
return true;
|
|
51092
51290
|
}
|
|
51093
51291
|
function writeGitignoreIfMissing() {
|
|
51094
|
-
|
|
51095
|
-
const text5 =
|
|
51292
|
+
fs54.mkdirSync(KANBAN, { recursive: true });
|
|
51293
|
+
const text5 = fs54.existsSync(KANBAN_GITIGNORE) ? fs54.readFileSync(KANBAN_GITIGNORE, "utf8") : "";
|
|
51096
51294
|
const has = (rule) => text5.split("\n").some((line) => line.trim() === rule.line);
|
|
51097
51295
|
const missing = IGNORE_RULES.filter((rule) => !has(rule));
|
|
51098
51296
|
if (!missing.length) return false;
|
|
@@ -51100,23 +51298,23 @@ function writeGitignoreIfMissing() {
|
|
|
51100
51298
|
${rule.line}
|
|
51101
51299
|
`).join("");
|
|
51102
51300
|
const separator = !text5 || text5.endsWith("\n") ? "" : "\n";
|
|
51103
|
-
|
|
51301
|
+
fs54.writeFileSync(KANBAN_GITIGNORE, `${text5}${separator}${block}`);
|
|
51104
51302
|
return true;
|
|
51105
51303
|
}
|
|
51106
51304
|
function writeSkeletonIfMissing() {
|
|
51107
51305
|
const added = [];
|
|
51108
|
-
if (!
|
|
51109
|
-
|
|
51306
|
+
if (!fs54.existsSync(TODO)) {
|
|
51307
|
+
fs54.mkdirSync(TODO, { recursive: true });
|
|
51110
51308
|
added.push(`${rel(TODO)}/`);
|
|
51111
51309
|
}
|
|
51112
|
-
if (!
|
|
51113
|
-
|
|
51310
|
+
if (!fs54.existsSync(README)) {
|
|
51311
|
+
fs54.writeFileSync(README, boardReadme());
|
|
51114
51312
|
added.push(rel(README));
|
|
51115
51313
|
}
|
|
51116
51314
|
return added;
|
|
51117
51315
|
}
|
|
51118
51316
|
function cmdInit() {
|
|
51119
|
-
if (
|
|
51317
|
+
if (fs54.existsSync(KANBAN)) {
|
|
51120
51318
|
const added = [
|
|
51121
51319
|
...writeSkeletonIfMissing(),
|
|
51122
51320
|
writeConfigIfMissing() && rel(CONFIG),
|
|
@@ -51133,8 +51331,8 @@ function cmdInit() {
|
|
|
51133
51331
|
}
|
|
51134
51332
|
return { board: rel(KANBAN), created: false, added, memory_paths: scaffolded.map((s) => rel(s.dir)) };
|
|
51135
51333
|
}
|
|
51136
|
-
|
|
51137
|
-
|
|
51334
|
+
fs54.mkdirSync(TODO, { recursive: true });
|
|
51335
|
+
fs54.writeFileSync(README, boardReadme());
|
|
51138
51336
|
writeConfigIfMissing();
|
|
51139
51337
|
scaffoldProjectMemory();
|
|
51140
51338
|
writeModulesIfMissing();
|
|
@@ -51169,15 +51367,15 @@ _(not filled in yet \u2014 build the map from the repo before tagging a card.)_
|
|
|
51169
51367
|
});
|
|
51170
51368
|
|
|
51171
51369
|
// ../cli/src/lib/card-age.ts
|
|
51172
|
-
import
|
|
51370
|
+
import fs55 from "node:fs";
|
|
51173
51371
|
import path58 from "node:path";
|
|
51174
51372
|
function staleAfterIn(config2) {
|
|
51175
51373
|
const days = Number(LINE.exec(config2)?.[1]);
|
|
51176
51374
|
return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
|
|
51177
51375
|
}
|
|
51178
51376
|
function staleAfter() {
|
|
51179
|
-
if (!
|
|
51180
|
-
return staleAfterIn(
|
|
51377
|
+
if (!fs55.existsSync(CONFIG)) return STALE_AFTER_DEFAULT;
|
|
51378
|
+
return staleAfterIn(fs55.readFileSync(CONFIG, "utf8"));
|
|
51181
51379
|
}
|
|
51182
51380
|
function todoPathspec(top) {
|
|
51183
51381
|
const from = path58.relative(real(top), real(TODO));
|
|
@@ -51234,7 +51432,7 @@ var init_card_age = __esm({
|
|
|
51234
51432
|
gitTop = () => git(["rev-parse", "--show-toplevel"])?.trim() || null;
|
|
51235
51433
|
real = (p) => {
|
|
51236
51434
|
try {
|
|
51237
|
-
return
|
|
51435
|
+
return fs55.realpathSync(p);
|
|
51238
51436
|
} catch {
|
|
51239
51437
|
return path58.resolve(p);
|
|
51240
51438
|
}
|
|
@@ -51270,7 +51468,7 @@ var init_card_holds = __esm({
|
|
|
51270
51468
|
});
|
|
51271
51469
|
|
|
51272
51470
|
// ../cli/src/commands/list.ts
|
|
51273
|
-
import
|
|
51471
|
+
import fs56 from "node:fs";
|
|
51274
51472
|
import path59 from "node:path";
|
|
51275
51473
|
function summaryLine(body) {
|
|
51276
51474
|
const lines = body.split("\n");
|
|
@@ -51293,7 +51491,7 @@ function openRows() {
|
|
|
51293
51491
|
const id2 = isRoot ? idPrefix(path59.basename(path59.dirname(file2))) : idPrefix(base);
|
|
51294
51492
|
if (id2 == null) continue;
|
|
51295
51493
|
if (isLegacyRecurring(path59.relative(TODO, file2))) continue;
|
|
51296
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
51494
|
+
const { meta: meta3, body } = parseFrontmatter(fs56.readFileSync(file2, "utf8"));
|
|
51297
51495
|
rows.push({
|
|
51298
51496
|
id: id2,
|
|
51299
51497
|
file: file2,
|
|
@@ -51335,7 +51533,7 @@ function cmdStale(rows, all2, scope, mod) {
|
|
|
51335
51533
|
}
|
|
51336
51534
|
function archivedFiles() {
|
|
51337
51535
|
const files = /* @__PURE__ */ new Map();
|
|
51338
|
-
if (!
|
|
51536
|
+
if (!fs56.existsSync(ARCHIVE)) return files;
|
|
51339
51537
|
for (const file2 of walkMd(ARCHIVE)) {
|
|
51340
51538
|
const id2 = idPrefix(path59.basename(file2));
|
|
51341
51539
|
if (id2 !== null) files.set(id2, file2);
|
|
@@ -51343,7 +51541,7 @@ function archivedFiles() {
|
|
|
51343
51541
|
for (const dir of walkDirs(ARCHIVE)) {
|
|
51344
51542
|
const id2 = idPrefix(path59.basename(dir));
|
|
51345
51543
|
const root2 = path59.join(dir, "root.md");
|
|
51346
|
-
if (id2 !== null &&
|
|
51544
|
+
if (id2 !== null && fs56.existsSync(root2)) files.set(id2, root2);
|
|
51347
51545
|
}
|
|
51348
51546
|
return files;
|
|
51349
51547
|
}
|
|
@@ -51441,10 +51639,10 @@ var init_list = __esm({
|
|
|
51441
51639
|
});
|
|
51442
51640
|
|
|
51443
51641
|
// ../cli/src/lib/group-close.ts
|
|
51444
|
-
import
|
|
51642
|
+
import fs57 from "node:fs";
|
|
51445
51643
|
function groupCloses(rootFile) {
|
|
51446
51644
|
try {
|
|
51447
|
-
return groupCloseOf(
|
|
51645
|
+
return groupCloseOf(fs57.readFileSync(rootFile, "utf8"));
|
|
51448
51646
|
} catch {
|
|
51449
51647
|
return false;
|
|
51450
51648
|
}
|
|
@@ -51457,7 +51655,7 @@ var init_group_close = __esm({
|
|
|
51457
51655
|
});
|
|
51458
51656
|
|
|
51459
51657
|
// ../cli/src/commands/remove.ts
|
|
51460
|
-
import
|
|
51658
|
+
import fs58 from "node:fs";
|
|
51461
51659
|
import path60 from "node:path";
|
|
51462
51660
|
function leavingIds(id2, found2) {
|
|
51463
51661
|
const ids = /* @__PURE__ */ new Set([id2]);
|
|
@@ -51474,10 +51672,10 @@ function findMentions(ids) {
|
|
|
51474
51672
|
const hits = [];
|
|
51475
51673
|
const re = new RegExp(ids.map((id2) => `#${id2}(?!\\d)`).join("|"));
|
|
51476
51674
|
for (const dir of [TODO, MEMORY]) {
|
|
51477
|
-
if (!
|
|
51675
|
+
if (!fs58.existsSync(dir)) continue;
|
|
51478
51676
|
for (const file2 of walkMd(dir)) {
|
|
51479
51677
|
if (path60.basename(file2) === "README.md") continue;
|
|
51480
|
-
const lines =
|
|
51678
|
+
const lines = fs58.readFileSync(file2, "utf8").split("\n");
|
|
51481
51679
|
const fmEnd = frontmatterEnd(lines);
|
|
51482
51680
|
lines.forEach((line, i) => {
|
|
51483
51681
|
if (!re.test(line)) return;
|
|
@@ -51507,10 +51705,10 @@ function stampLeaving(cards, rejection) {
|
|
|
51507
51705
|
const day = formatDay();
|
|
51508
51706
|
const stamp4 = rejection && !rejection.discard ? { reason: rejection.reason, at: (/* @__PURE__ */ new Date()).toISOString(), by: insideRun() || workspaceTask() ? "agent" : "user" } : rejection && { reason: rejection.reason };
|
|
51509
51707
|
for (const card of cards) {
|
|
51510
|
-
if (!
|
|
51511
|
-
const text5 =
|
|
51708
|
+
if (!fs58.existsSync(card.file)) continue;
|
|
51709
|
+
const text5 = fs58.readFileSync(card.file, "utf8");
|
|
51512
51710
|
const stamped = stampLeavingIn(text5, day, stamp4);
|
|
51513
|
-
if (stamped !== text5)
|
|
51711
|
+
if (stamped !== text5) fs58.writeFileSync(card.file, stamped);
|
|
51514
51712
|
}
|
|
51515
51713
|
}
|
|
51516
51714
|
function agentDecisions(text5) {
|
|
@@ -51540,14 +51738,14 @@ function removeCard(id2, metric, options) {
|
|
|
51540
51738
|
if (!found2) die(`no task with id ${id2} under ${rel(TODO)}`, { kind: "card-not-found", id: id2 });
|
|
51541
51739
|
const dest = options.cleanupDiscarded && locateArchived(id2) ? null : archiveDest(found2);
|
|
51542
51740
|
const cardFile3 = found2.kind === "group" ? path60.join(found2.target, "root.md") : found2.target;
|
|
51543
|
-
const cardText =
|
|
51741
|
+
const cardText = fs58.existsSync(cardFile3) ? fs58.readFileSync(cardFile3, "utf8") : "";
|
|
51544
51742
|
const { meta: cardMeta3 } = parseFrontmatter(cardText);
|
|
51545
51743
|
const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f) => f !== cardFile3).map((f) => rel(f)).sort() : [];
|
|
51546
51744
|
const leftIds = leavingIds(id2, found2);
|
|
51547
51745
|
const leaving = leavingCards(id2, found2);
|
|
51548
51746
|
if (options.archivingTask) {
|
|
51549
51747
|
for (const card of leaving) {
|
|
51550
|
-
const meta3 = parseFrontmatter(
|
|
51748
|
+
const meta3 = parseFrontmatter(fs58.readFileSync(card.file, "utf8")).meta;
|
|
51551
51749
|
if (!meta3 || meta3.rejected) die(`#${card.id} is not eligible for archive.`, { kind: "conflict" });
|
|
51552
51750
|
if (meta3.questions.length) die(`Resolve the open questions on #${card.id} before archiving.`, { kind: "conflict" });
|
|
51553
51751
|
if (card.id !== id2 && (activeDelivery(card.id) || creationRefusal(card.id, cardCreation(card.id), "archive", false))) {
|
|
@@ -51581,10 +51779,10 @@ function removeCard(id2, metric, options) {
|
|
|
51581
51779
|
const groupRoot = found2.kind === "file" && !options.closing ? enclosingGroupRoot(found2.target) : null;
|
|
51582
51780
|
if (dest) {
|
|
51583
51781
|
stampLeaving(leaving, metric === "rejected" ? { reason: options.reason?.trim() ?? "", discard: options.discard === true } : null);
|
|
51584
|
-
|
|
51585
|
-
|
|
51782
|
+
fs58.mkdirSync(ARCHIVE, { recursive: true });
|
|
51783
|
+
fs58.renameSync(found2.target, dest);
|
|
51586
51784
|
} else {
|
|
51587
|
-
|
|
51785
|
+
fs58.rmSync(found2.target, { recursive: true, force: true });
|
|
51588
51786
|
}
|
|
51589
51787
|
const removedRefs = stripReadmeRefs(found2);
|
|
51590
51788
|
let marked2 = null;
|
|
@@ -51640,7 +51838,7 @@ function closeGroup(rootFile) {
|
|
|
51640
51838
|
say(`
|
|
51641
51839
|
every subtask line on #${rootId} is resolved \u2014 closing the group:`);
|
|
51642
51840
|
try {
|
|
51643
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
51841
|
+
const { meta: meta3, body } = parseFrontmatter(fs58.readFileSync(rootFile, "utf8"));
|
|
51644
51842
|
const res = cmdRemove(rootId, "completed", { closing: true });
|
|
51645
51843
|
return {
|
|
51646
51844
|
id: rootId,
|
|
@@ -51704,7 +51902,7 @@ function recoveredArchiveHandoff(id2, source2) {
|
|
|
51704
51902
|
const found2 = locateArchived(id2);
|
|
51705
51903
|
if (!found2) throw new Error(`No archived card #${id2} was found.`);
|
|
51706
51904
|
const file2 = found2.kind === "group" ? path60.join(found2.target, "root.md") : found2.target;
|
|
51707
|
-
const { meta: meta3 } = parseFrontmatter(
|
|
51905
|
+
const { meta: meta3 } = parseFrontmatter(fs58.readFileSync(file2, "utf8"));
|
|
51708
51906
|
stripReadmeRefs(source2 ?? found2);
|
|
51709
51907
|
const root2 = source2?.kind === "file" ? enclosingGroupRoot(source2.target) : null;
|
|
51710
51908
|
if (root2) markSubtask(root2, id2, "tick");
|
|
@@ -51823,7 +52021,7 @@ var init_bundled2 = __esm({
|
|
|
51823
52021
|
});
|
|
51824
52022
|
|
|
51825
52023
|
// ../cli/src/lib/memories.ts
|
|
51826
|
-
import
|
|
52024
|
+
import fs59 from "node:fs";
|
|
51827
52025
|
import path61 from "node:path";
|
|
51828
52026
|
function readMemory(text5, builtIn, folder2) {
|
|
51829
52027
|
const { meta: meta3, body } = splitFrontmatter(text5);
|
|
@@ -51855,14 +52053,14 @@ function globalMemories() {
|
|
|
51855
52053
|
}
|
|
51856
52054
|
let folders2 = [];
|
|
51857
52055
|
try {
|
|
51858
|
-
folders2 =
|
|
52056
|
+
folders2 = fs59.readdirSync(MEMORY, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
51859
52057
|
} catch {
|
|
51860
52058
|
}
|
|
51861
52059
|
for (const name of folders2) {
|
|
51862
52060
|
if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR || name === STUDIO_MEMORY_DIR) continue;
|
|
51863
52061
|
const file2 = path61.join(MEMORY, name, GLOBAL_MEMORY_FILE);
|
|
51864
|
-
if (!
|
|
51865
|
-
const memory = readMemory(
|
|
52062
|
+
if (!fs59.existsSync(file2)) continue;
|
|
52063
|
+
const memory = readMemory(fs59.readFileSync(file2, "utf8"), false, name);
|
|
51866
52064
|
if (memory) out.push(memory);
|
|
51867
52065
|
}
|
|
51868
52066
|
return out;
|
|
@@ -51903,7 +52101,7 @@ var init_memory_file = __esm({
|
|
|
51903
52101
|
});
|
|
51904
52102
|
|
|
51905
52103
|
// ../cli/src/commands/inspect.ts
|
|
51906
|
-
import
|
|
52104
|
+
import fs60 from "node:fs";
|
|
51907
52105
|
import os4 from "node:os";
|
|
51908
52106
|
import path62 from "node:path";
|
|
51909
52107
|
function cmdInspect(id2) {
|
|
@@ -51911,7 +52109,7 @@ function cmdInspect(id2) {
|
|
|
51911
52109
|
const unavailable = [];
|
|
51912
52110
|
function read5(source2, file3, empty) {
|
|
51913
52111
|
try {
|
|
51914
|
-
return JSON.parse(
|
|
52112
|
+
return JSON.parse(fs60.readFileSync(file3, "utf8"));
|
|
51915
52113
|
} catch (error62) {
|
|
51916
52114
|
if (error62.code === "ENOENT") return empty;
|
|
51917
52115
|
findings.push({ source: source2, message: String(error62) });
|
|
@@ -51933,7 +52131,7 @@ function cmdInspect(id2) {
|
|
|
51933
52131
|
const file2 = found2.kind === "group" ? path62.join(found2.target, "root.md") : found2.target;
|
|
51934
52132
|
let card = null;
|
|
51935
52133
|
try {
|
|
51936
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
52134
|
+
const { meta: meta3, body } = parseFrontmatter(fs60.readFileSync(file2, "utf8"));
|
|
51937
52135
|
if (!meta3) throw Error("The card frontmatter could not be parsed.");
|
|
51938
52136
|
card = { path: rel(file2), questions: meta3.questions, todos: [...body.matchAll(/^\s*[-*]\s+\[([ xX])\]\s+(.*)$/gm)].map((m) => ({ text: m[2], done: m[1] !== " " })) };
|
|
51939
52137
|
} catch (error62) {
|
|
@@ -51946,7 +52144,7 @@ function cmdInspect(id2) {
|
|
|
51946
52144
|
const records = [];
|
|
51947
52145
|
const directory = path62.join(KANBAN, "deliveries");
|
|
51948
52146
|
try {
|
|
51949
|
-
for (const name of
|
|
52147
|
+
for (const name of fs60.readdirSync(directory).filter((name2) => name2.endsWith(".json"))) {
|
|
51950
52148
|
const held5 = read5("delivery", path62.join(directory, name), null);
|
|
51951
52149
|
if (held5?.cardId === id2) records.push(held5);
|
|
51952
52150
|
}
|
|
@@ -52000,7 +52198,7 @@ function cmdValidate(id2) {
|
|
|
52000
52198
|
const reason = errors.length ? formatContractErrors(errors) : void 0;
|
|
52001
52199
|
const session = insideRun();
|
|
52002
52200
|
if (session) patch(session, (run3) => {
|
|
52003
|
-
run3.validationFailure = reason ? { code: "validation_failed",
|
|
52201
|
+
run3.validationFailure = reason ? makeFailure("validation", reason, { code: "validation_failed", detail: reason }) : void 0;
|
|
52004
52202
|
});
|
|
52005
52203
|
if (reason) die(reason, { kind: "spec-contract", errors });
|
|
52006
52204
|
say(`Spec format valid (${cards.length} card${cards.length === 1 ? "" : "s"}).`);
|
|
@@ -52009,6 +52207,7 @@ function cmdValidate(id2) {
|
|
|
52009
52207
|
var init_validate2 = __esm({
|
|
52010
52208
|
"../cli/src/commands/validate.ts"() {
|
|
52011
52209
|
"use strict";
|
|
52210
|
+
init_retry();
|
|
52012
52211
|
init_env();
|
|
52013
52212
|
init_sessions();
|
|
52014
52213
|
init_io();
|
|
@@ -52018,7 +52217,7 @@ var init_validate2 = __esm({
|
|
|
52018
52217
|
});
|
|
52019
52218
|
|
|
52020
52219
|
// ../cli/src/lib/card-sources.ts
|
|
52021
|
-
import
|
|
52220
|
+
import fs61 from "node:fs";
|
|
52022
52221
|
import path63 from "node:path";
|
|
52023
52222
|
function planById(id2) {
|
|
52024
52223
|
const found2 = readPlan(`plans/${id2}-.md`);
|
|
@@ -52030,7 +52229,7 @@ function cardLink(id2) {
|
|
|
52030
52229
|
if (!found2) return null;
|
|
52031
52230
|
try {
|
|
52032
52231
|
const file2 = found2.kind === "group" ? path63.join(found2.target, "root.md") : found2.target;
|
|
52033
|
-
const title = parseFrontmatter(
|
|
52232
|
+
const title = parseFrontmatter(fs61.readFileSync(file2, "utf8")).meta?.title ?? "";
|
|
52034
52233
|
return { kind: "card", ref: String(id2), title, ...open4 ? {} : { archived: true } };
|
|
52035
52234
|
} catch {
|
|
52036
52235
|
return null;
|
|
@@ -52093,7 +52292,7 @@ var init_card_sources = __esm({
|
|
|
52093
52292
|
});
|
|
52094
52293
|
|
|
52095
52294
|
// ../cli/src/lib/view/read.ts
|
|
52096
|
-
import
|
|
52295
|
+
import fs62 from "node:fs";
|
|
52097
52296
|
import path64 from "node:path";
|
|
52098
52297
|
function readCard(file2, relFromTodo) {
|
|
52099
52298
|
const id2 = idPrefix(path64.basename(relFromTodo));
|
|
@@ -52106,7 +52305,7 @@ function readCard(file2, relFromTodo) {
|
|
|
52106
52305
|
return buildCard(id2, file2, relFromTodo);
|
|
52107
52306
|
}
|
|
52108
52307
|
function buildCard(id2, file2, relFromTodo) {
|
|
52109
|
-
const text5 =
|
|
52308
|
+
const text5 = fs62.readFileSync(file2, "utf8");
|
|
52110
52309
|
const { meta: meta3, body } = parseFrontmatter(text5);
|
|
52111
52310
|
if (!meta3) return null;
|
|
52112
52311
|
const relPath = relFromTodo.split(path64.sep).join("/");
|
|
@@ -52117,7 +52316,7 @@ function buildCard(id2, file2, relFromTodo) {
|
|
|
52117
52316
|
// Derived from the file exactly as it is on disk (lib/board/revision.ts), so a card
|
|
52118
52317
|
// read here and a card read by the contract agree on what version this is.
|
|
52119
52318
|
revision: revisionOf(text5),
|
|
52120
|
-
updatedAt:
|
|
52319
|
+
updatedAt: fs62.statSync(file2).mtime.toISOString(),
|
|
52121
52320
|
relPath,
|
|
52122
52321
|
title: meta3.title,
|
|
52123
52322
|
priority: meta3.priority,
|
|
@@ -52139,7 +52338,7 @@ function buildCard(id2, file2, relFromTodo) {
|
|
|
52139
52338
|
function readGroup(folderName) {
|
|
52140
52339
|
const groupDir = path64.join(TODO, folderName);
|
|
52141
52340
|
const rootFile = path64.join(groupDir, "root.md");
|
|
52142
|
-
if (!
|
|
52341
|
+
if (!fs62.existsSync(rootFile)) return null;
|
|
52143
52342
|
const root2 = readCard(rootFile, path64.join(folderName, "root.md"));
|
|
52144
52343
|
if (!root2) return null;
|
|
52145
52344
|
root2.isGroup = true;
|
|
@@ -52147,7 +52346,7 @@ function readGroup(folderName) {
|
|
|
52147
52346
|
root2.subtaskLines = { total, resolved };
|
|
52148
52347
|
const subCards = [];
|
|
52149
52348
|
const recurse = (dir, relDir) => {
|
|
52150
|
-
for (const entry of
|
|
52349
|
+
for (const entry of fs62.readdirSync(dir, { withFileTypes: true })) {
|
|
52151
52350
|
const childRel = path64.join(relDir, entry.name);
|
|
52152
52351
|
if (entry.isDirectory()) {
|
|
52153
52352
|
recurse(path64.join(dir, entry.name), childRel);
|
|
@@ -52174,9 +52373,9 @@ function readGroup(folderName) {
|
|
|
52174
52373
|
}
|
|
52175
52374
|
function standaloneCards(dirRel) {
|
|
52176
52375
|
const dir = dirRel ? path64.join(TODO, dirRel) : TODO;
|
|
52177
|
-
if (!
|
|
52376
|
+
if (!fs62.existsSync(dir)) return [];
|
|
52178
52377
|
const cards = [];
|
|
52179
|
-
for (const entry of
|
|
52378
|
+
for (const entry of fs62.readdirSync(dir, { withFileTypes: true })) {
|
|
52180
52379
|
if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
|
|
52181
52380
|
const c = readCard(path64.join(dir, entry.name), path64.join(dirRel, entry.name));
|
|
52182
52381
|
if (c) cards.push(c);
|
|
@@ -52190,7 +52389,7 @@ function collectCards() {
|
|
|
52190
52389
|
const top = standaloneCards("");
|
|
52191
52390
|
board2.push(...top);
|
|
52192
52391
|
every.push(...top);
|
|
52193
|
-
for (const entry of
|
|
52392
|
+
for (const entry of fs62.readdirSync(TODO, { withFileTypes: true })) {
|
|
52194
52393
|
if (!entry.isDirectory()) continue;
|
|
52195
52394
|
if (isGroupFolder(entry.name)) {
|
|
52196
52395
|
const g = readGroup(entry.name);
|
|
@@ -52222,7 +52421,7 @@ function findCard(id2) {
|
|
|
52222
52421
|
}
|
|
52223
52422
|
function attachSources(card) {
|
|
52224
52423
|
try {
|
|
52225
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
52424
|
+
const { meta: meta3, body } = parseFrontmatter(fs62.readFileSync(path64.join(TODO, card.relPath), "utf8"));
|
|
52226
52425
|
const sources2 = meta3 ? cardSources(meta3, body) : [];
|
|
52227
52426
|
if (sources2.length) card.sources = sources2;
|
|
52228
52427
|
} catch {
|
|
@@ -52596,7 +52795,7 @@ var init_project_agent = __esm({
|
|
|
52596
52795
|
|
|
52597
52796
|
// ../cli/src/lib/agent/creation.ts
|
|
52598
52797
|
import crypto3 from "node:crypto";
|
|
52599
|
-
import
|
|
52798
|
+
import fs63 from "node:fs";
|
|
52600
52799
|
import path65 from "node:path";
|
|
52601
52800
|
function creationError(error62, triage) {
|
|
52602
52801
|
const zh = readLanguage() === "zh";
|
|
@@ -52628,7 +52827,7 @@ ${slot}`).digest("hex");
|
|
|
52628
52827
|
function readCreation(file2, said2) {
|
|
52629
52828
|
return withCreationLock(() => {
|
|
52630
52829
|
try {
|
|
52631
|
-
const held4 = JSON.parse(
|
|
52830
|
+
const held4 = JSON.parse(fs63.readFileSync(file2, "utf8"));
|
|
52632
52831
|
if (!held4.said || typeof held4.said.title !== "string") throw new Error("Invalid creation journal");
|
|
52633
52832
|
return held4;
|
|
52634
52833
|
} catch (error62) {
|
|
@@ -52640,10 +52839,10 @@ function readCreation(file2, said2) {
|
|
|
52640
52839
|
});
|
|
52641
52840
|
}
|
|
52642
52841
|
function saveCreation(file2, journal) {
|
|
52643
|
-
|
|
52842
|
+
fs63.mkdirSync(path65.dirname(file2), { recursive: true });
|
|
52644
52843
|
const temp = `${file2}.${crypto3.randomUUID()}.tmp`;
|
|
52645
|
-
|
|
52646
|
-
|
|
52844
|
+
fs63.writeFileSync(temp, JSON.stringify(journal));
|
|
52845
|
+
fs63.renameSync(temp, file2);
|
|
52647
52846
|
}
|
|
52648
52847
|
function archiveCreation(source2, id2) {
|
|
52649
52848
|
if (readArchived().some((s) => s.sourceId === source2 && s.cardId === id2)) return;
|
|
@@ -53789,7 +53988,7 @@ var require_command = __commonJS({
|
|
|
53789
53988
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
53790
53989
|
var childProcess = __require("node:child_process");
|
|
53791
53990
|
var path88 = __require("node:path");
|
|
53792
|
-
var
|
|
53991
|
+
var fs91 = __require("node:fs");
|
|
53793
53992
|
var process2 = __require("node:process");
|
|
53794
53993
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
53795
53994
|
var { CommanderError: CommanderError2 } = require_error();
|
|
@@ -54770,7 +54969,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
54770
54969
|
* @param {string} subcommandName
|
|
54771
54970
|
*/
|
|
54772
54971
|
_checkForMissingExecutable(executableFile, executableDir, subcommandName) {
|
|
54773
|
-
if (
|
|
54972
|
+
if (fs91.existsSync(executableFile)) return;
|
|
54774
54973
|
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
54974
|
const executableMissing = `'${executableFile}' does not exist
|
|
54776
54975
|
- if '${subcommandName}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
@@ -54789,10 +54988,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
54789
54988
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
54790
54989
|
function findFile(baseDir, baseName) {
|
|
54791
54990
|
const localBin = path88.resolve(baseDir, baseName);
|
|
54792
|
-
if (
|
|
54991
|
+
if (fs91.existsSync(localBin)) return localBin;
|
|
54793
54992
|
if (sourceExt.includes(path88.extname(baseName))) return void 0;
|
|
54794
54993
|
const foundExt = sourceExt.find(
|
|
54795
|
-
(ext) =>
|
|
54994
|
+
(ext) => fs91.existsSync(`${localBin}${ext}`)
|
|
54796
54995
|
);
|
|
54797
54996
|
if (foundExt) return `${localBin}${foundExt}`;
|
|
54798
54997
|
return void 0;
|
|
@@ -54804,7 +55003,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
54804
55003
|
if (this._scriptPath) {
|
|
54805
55004
|
let resolvedScriptPath;
|
|
54806
55005
|
try {
|
|
54807
|
-
resolvedScriptPath =
|
|
55006
|
+
resolvedScriptPath = fs91.realpathSync(this._scriptPath);
|
|
54808
55007
|
} catch {
|
|
54809
55008
|
resolvedScriptPath = this._scriptPath;
|
|
54810
55009
|
}
|
|
@@ -56140,7 +56339,7 @@ var init_shared2 = __esm({
|
|
|
56140
56339
|
});
|
|
56141
56340
|
|
|
56142
56341
|
// ../cli/src/lib/agents/shared-memory.ts
|
|
56143
|
-
import
|
|
56342
|
+
import fs64 from "node:fs";
|
|
56144
56343
|
import path66 from "node:path";
|
|
56145
56344
|
function sharedMemory(board2) {
|
|
56146
56345
|
const declared = /* @__PURE__ */ new Map();
|
|
@@ -56149,7 +56348,7 @@ function sharedMemory(board2) {
|
|
|
56149
56348
|
const read5 = parseSpecAgent(text5, folder2, (relative) => {
|
|
56150
56349
|
if (builtIn) return shippedAgentFiles()[`${folder2}/${relative}`] ?? null;
|
|
56151
56350
|
try {
|
|
56152
|
-
return
|
|
56351
|
+
return fs64.readFileSync(path66.join(board2, "agents", folder2, relative), "utf8");
|
|
56153
56352
|
} catch {
|
|
56154
56353
|
return null;
|
|
56155
56354
|
}
|
|
@@ -56163,13 +56362,13 @@ function sharedMemory(board2) {
|
|
|
56163
56362
|
const root2 = path66.join(board2, "agents");
|
|
56164
56363
|
let folders2 = [];
|
|
56165
56364
|
try {
|
|
56166
|
-
folders2 =
|
|
56365
|
+
folders2 = fs64.readdirSync(root2, { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name);
|
|
56167
56366
|
} catch {
|
|
56168
56367
|
}
|
|
56169
56368
|
for (const folder2 of folders2.sort()) {
|
|
56170
56369
|
let text5 = null;
|
|
56171
56370
|
try {
|
|
56172
|
-
text5 =
|
|
56371
|
+
text5 = fs64.readFileSync(path66.join(root2, folder2, "AGENT.md"), "utf8");
|
|
56173
56372
|
} catch {
|
|
56174
56373
|
}
|
|
56175
56374
|
take(folder2, text5, false);
|
|
@@ -56195,30 +56394,30 @@ var init_shared_memory = __esm({
|
|
|
56195
56394
|
|
|
56196
56395
|
// ../cli/src/lib/shared/board-conflicts.ts
|
|
56197
56396
|
import crypto4 from "node:crypto";
|
|
56198
|
-
import
|
|
56397
|
+
import fs65 from "node:fs";
|
|
56199
56398
|
import path67 from "node:path";
|
|
56200
56399
|
function atomicJson(file2, data) {
|
|
56201
|
-
|
|
56400
|
+
fs65.mkdirSync(path67.dirname(file2), { recursive: true });
|
|
56202
56401
|
const temp = `${file2}.${crypto4.randomUUID()}.tmp`;
|
|
56203
|
-
const fd =
|
|
56402
|
+
const fd = fs65.openSync(temp, "wx", 384);
|
|
56204
56403
|
try {
|
|
56205
|
-
|
|
56206
|
-
|
|
56404
|
+
fs65.writeFileSync(fd, JSON.stringify(data));
|
|
56405
|
+
fs65.fsyncSync(fd);
|
|
56207
56406
|
} finally {
|
|
56208
|
-
|
|
56407
|
+
fs65.closeSync(fd);
|
|
56209
56408
|
}
|
|
56210
|
-
|
|
56409
|
+
fs65.renameSync(temp, file2);
|
|
56211
56410
|
}
|
|
56212
56411
|
function boardTextAt(board2, name) {
|
|
56213
56412
|
if (!isBoardPath(name)) throw new BoardError(`Invalid board path: ${name}`, { kind: "invalid-usage" });
|
|
56214
56413
|
const file2 = path67.join(board2, name);
|
|
56215
56414
|
let ancestor = file2;
|
|
56216
|
-
while (!
|
|
56217
|
-
const real2 = path67.resolve(
|
|
56218
|
-
if (!real2.startsWith(
|
|
56219
|
-
if ((
|
|
56415
|
+
while (!fs65.existsSync(ancestor) && path67.dirname(ancestor) !== ancestor) ancestor = path67.dirname(ancestor);
|
|
56416
|
+
const real2 = path67.resolve(fs65.realpathSync(ancestor), path67.relative(ancestor, file2));
|
|
56417
|
+
if (!real2.startsWith(fs65.realpathSync(board2) + path67.sep)) throw new BoardError(`Link outside the board: ${name}`, { kind: "invalid-usage" });
|
|
56418
|
+
if ((fs65.statSync(file2, { throwIfNoEntry: false })?.size ?? 0) > BOARD_FILE_LIMIT) throw new BoardError(`${name} exceeds the board file limit.`, { kind: "cloud-refused" });
|
|
56220
56419
|
try {
|
|
56221
|
-
return
|
|
56420
|
+
return fs65.readFileSync(file2, "utf8");
|
|
56222
56421
|
} catch (e) {
|
|
56223
56422
|
if (e.code === "ENOENT") return null;
|
|
56224
56423
|
throw e;
|
|
@@ -56229,9 +56428,9 @@ function save2(board2, record2) {
|
|
|
56229
56428
|
}
|
|
56230
56429
|
function read2(board2, id2) {
|
|
56231
56430
|
const file2 = fileOf(board2, id2);
|
|
56232
|
-
if (!
|
|
56431
|
+
if (!fs65.existsSync(file2)) throw new BoardError("Unknown board conflict.", { kind: "conflict-not-found", id: id2 });
|
|
56233
56432
|
try {
|
|
56234
|
-
const r = JSON.parse(
|
|
56433
|
+
const r = JSON.parse(fs65.readFileSync(file2, "utf8"));
|
|
56235
56434
|
if (r.id !== id2 || !r.project || !["open", "unconfirmed", "resolved"].includes(r.state) || !Array.isArray(r.files) || !r.files.length) throw Error();
|
|
56236
56435
|
const names2 = /* @__PURE__ */ new Set();
|
|
56237
56436
|
for (const f of r.files) {
|
|
@@ -56253,7 +56452,7 @@ function read2(board2, id2) {
|
|
|
56253
56452
|
function conflictRecords(board2) {
|
|
56254
56453
|
let names2;
|
|
56255
56454
|
try {
|
|
56256
|
-
names2 =
|
|
56455
|
+
names2 = fs65.readdirSync(folder(board2));
|
|
56257
56456
|
} catch (e) {
|
|
56258
56457
|
if (e.code === "ENOENT") return [];
|
|
56259
56458
|
throw e;
|
|
@@ -56342,7 +56541,7 @@ function confirmLocal(board2, r) {
|
|
|
56342
56541
|
const draft = r.draft;
|
|
56343
56542
|
const root2 = stateRootOf(board2);
|
|
56344
56543
|
const file2 = path67.join(root2, ".akb", "base.json");
|
|
56345
|
-
const base = JSON.parse(
|
|
56544
|
+
const base = JSON.parse(fs65.readFileSync(file2, "utf8"));
|
|
56346
56545
|
if (base.project && base.project !== r.project) refuse(r, "The project binding changed.", "cloud-refused");
|
|
56347
56546
|
base.deleted ??= {};
|
|
56348
56547
|
for (const [i, f] of r.files.entries()) {
|
|
@@ -56359,10 +56558,10 @@ function confirmLocal(board2, r) {
|
|
|
56359
56558
|
}
|
|
56360
56559
|
if (boardTextAt(board2, f.path) !== draft.working[i]) continue;
|
|
56361
56560
|
const local = path67.join(board2, f.path);
|
|
56362
|
-
if (sent.content === null)
|
|
56561
|
+
if (sent.content === null) fs65.rmSync(local, { force: true });
|
|
56363
56562
|
else {
|
|
56364
|
-
|
|
56365
|
-
|
|
56563
|
+
fs65.mkdirSync(path67.dirname(local), { recursive: true });
|
|
56564
|
+
fs65.writeFileSync(local, sent.content);
|
|
56366
56565
|
}
|
|
56367
56566
|
}
|
|
56368
56567
|
atomicJson(file2, base);
|
|
@@ -56540,7 +56739,7 @@ __export(board_exports, {
|
|
|
56540
56739
|
buildBoardProgram: () => buildBoardProgram
|
|
56541
56740
|
});
|
|
56542
56741
|
import crypto5 from "node:crypto";
|
|
56543
|
-
import
|
|
56742
|
+
import fs66 from "node:fs";
|
|
56544
56743
|
import path68 from "node:path";
|
|
56545
56744
|
async function dispatch(move, cmd, args2, opts, cli) {
|
|
56546
56745
|
const ctx = ctxOf(cmd, cli.program);
|
|
@@ -56561,7 +56760,7 @@ async function dispatch(move, cmd, args2, opts, cli) {
|
|
|
56561
56760
|
}
|
|
56562
56761
|
let resolution;
|
|
56563
56762
|
try {
|
|
56564
|
-
resolution = JSON.parse(
|
|
56763
|
+
resolution = JSON.parse(fs66.readFileSync(String(opts.file), "utf8"));
|
|
56565
56764
|
} catch {
|
|
56566
56765
|
throw new BoardError("Cannot read the UTF-8 JSON resolution file.", { kind: "invalid-usage" });
|
|
56567
56766
|
}
|
|
@@ -56602,7 +56801,7 @@ async function cloudCard(task, opts) {
|
|
|
56602
56801
|
let request2;
|
|
56603
56802
|
if (typeof opts.bodyFile === "string") {
|
|
56604
56803
|
try {
|
|
56605
|
-
request2 =
|
|
56804
|
+
request2 = fs66.readFileSync(opts.bodyFile, "utf8");
|
|
56606
56805
|
} catch {
|
|
56607
56806
|
}
|
|
56608
56807
|
}
|
|
@@ -56767,7 +56966,7 @@ var init_board2 = __esm({
|
|
|
56767
56966
|
});
|
|
56768
56967
|
|
|
56769
56968
|
// ../cli/src/lib/board-cli.ts
|
|
56770
|
-
import
|
|
56969
|
+
import fs67 from "node:fs";
|
|
56771
56970
|
import path69 from "node:path";
|
|
56772
56971
|
function useBoard(found2, dirNamed, readOnly = false) {
|
|
56773
56972
|
if (!found2.named && found2.board === path69.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
|
|
@@ -56779,7 +56978,7 @@ function useBoard(found2, dirNamed, readOnly = false) {
|
|
|
56779
56978
|
}
|
|
56780
56979
|
function whole(found2, move) {
|
|
56781
56980
|
if (move === MAKES_A_BOARD) return found2;
|
|
56782
|
-
if (!
|
|
56981
|
+
if (!fs67.existsSync(path69.join(found2.board, "todo"))) {
|
|
56783
56982
|
die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
|
|
56784
56983
|
kind: "board-incomplete",
|
|
56785
56984
|
dir: found2.root
|
|
@@ -56793,7 +56992,7 @@ function findBoardUpward(from, move) {
|
|
|
56793
56992
|
if (hasBoard(dir)) return { root: dir, board: path69.join(dir, "docs", "kanban") };
|
|
56794
56993
|
if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
|
|
56795
56994
|
const kept2 = path69.join(dir, ".akb", "kanban");
|
|
56796
|
-
if (move !== MAKES_A_BOARD &&
|
|
56995
|
+
if (move !== MAKES_A_BOARD && fs67.existsSync(path69.join(kept2, "todo"))) return { root: dir, board: kept2 };
|
|
56797
56996
|
const up = path69.dirname(dir);
|
|
56798
56997
|
if (up === dir) return null;
|
|
56799
56998
|
dir = up;
|
|
@@ -56803,10 +57002,10 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
|
56803
57002
|
const named2 = board2 ?? boardFromEnv();
|
|
56804
57003
|
if (named2) {
|
|
56805
57004
|
const folder2 = path69.resolve(cwd, named2);
|
|
56806
|
-
if (!
|
|
57005
|
+
if (!fs67.existsSync(folder2) && move !== MAKES_A_BOARD) {
|
|
56807
57006
|
die(`no such folder: ${folder2}`, { kind: "no-such-folder", dir: folder2 });
|
|
56808
57007
|
}
|
|
56809
|
-
if (
|
|
57008
|
+
if (fs67.existsSync(folder2) && !isBoardDir(folder2) && move !== MAKES_A_BOARD) {
|
|
56810
57009
|
die(`${folder2} is not a board \u2014 it has no todo/ and config.md. ${installHint}\u3002`, {
|
|
56811
57010
|
kind: "no-board",
|
|
56812
57011
|
dir: folder2
|
|
@@ -56816,9 +57015,9 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
|
56816
57015
|
}
|
|
56817
57016
|
if (dir !== null) {
|
|
56818
57017
|
const root2 = path69.resolve(dir);
|
|
56819
|
-
if (!
|
|
57018
|
+
if (!fs67.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
|
|
56820
57019
|
const kept2 = path69.join(root2, ".akb", "kanban");
|
|
56821
|
-
if (!hasBoard(root2) && move !== MAKES_A_BOARD &&
|
|
57020
|
+
if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs67.existsSync(path69.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
|
|
56822
57021
|
if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
|
|
56823
57022
|
die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
|
|
56824
57023
|
kind: "no-board",
|
|
@@ -56909,8 +57108,8 @@ var init_board_cli = __esm({
|
|
|
56909
57108
|
init_io();
|
|
56910
57109
|
init_card_studio_backfill();
|
|
56911
57110
|
MAKES_A_BOARD = "init";
|
|
56912
|
-
hasBoard = (dir) =>
|
|
56913
|
-
isBoardDir = (dir) =>
|
|
57111
|
+
hasBoard = (dir) => fs67.existsSync(path69.join(dir, "docs", "kanban"));
|
|
57112
|
+
isBoardDir = (dir) => fs67.existsSync(path69.join(dir, "todo")) && fs67.existsSync(path69.join(dir, "config.md"));
|
|
56914
57113
|
boardFromEnv = () => {
|
|
56915
57114
|
const named2 = process.env.AI4KANBAN_BOARD?.trim();
|
|
56916
57115
|
return named2 ? named2 : null;
|
|
@@ -56919,11 +57118,11 @@ var init_board_cli = __esm({
|
|
|
56919
57118
|
});
|
|
56920
57119
|
|
|
56921
57120
|
// ../cli/src/lib/cloud/task-operation.ts
|
|
56922
|
-
import
|
|
57121
|
+
import fs68 from "node:fs";
|
|
56923
57122
|
import path70 from "node:path";
|
|
56924
57123
|
function readRemoval(board2, task) {
|
|
56925
57124
|
try {
|
|
56926
|
-
const value = JSON.parse(
|
|
57125
|
+
const value = JSON.parse(fs68.readFileSync(removalFile(board2, task), "utf8"));
|
|
56927
57126
|
if (["pending", "confirmed", "rejected"].includes(value.status) && typeof value.reason === "string" && typeof value.discard === "boolean") return value;
|
|
56928
57127
|
} catch {
|
|
56929
57128
|
}
|
|
@@ -56932,8 +57131,8 @@ function readRemoval(board2, task) {
|
|
|
56932
57131
|
function writeRemoval(board2, task, removal) {
|
|
56933
57132
|
const file2 = removalFile(board2, task);
|
|
56934
57133
|
const temp = `${file2}.${process.pid}.tmp`;
|
|
56935
|
-
|
|
56936
|
-
|
|
57134
|
+
fs68.writeFileSync(temp, JSON.stringify(removal) + "\n");
|
|
57135
|
+
fs68.renameSync(temp, file2);
|
|
56937
57136
|
}
|
|
56938
57137
|
var removalFile;
|
|
56939
57138
|
var init_task_operation = __esm({
|
|
@@ -56989,10 +57188,10 @@ var init_avatar = __esm({
|
|
|
56989
57188
|
});
|
|
56990
57189
|
|
|
56991
57190
|
// ../cli/src/lib/cloud/pro.ts
|
|
56992
|
-
import
|
|
57191
|
+
import fs69 from "node:fs";
|
|
56993
57192
|
import path71 from "node:path";
|
|
56994
57193
|
function forgetPro() {
|
|
56995
|
-
|
|
57194
|
+
fs69.rmSync(heldFile(), { force: true });
|
|
56996
57195
|
}
|
|
56997
57196
|
var FRESH_MS2, GRACE_MS, heldFile;
|
|
56998
57197
|
var init_pro = __esm({
|
|
@@ -57098,7 +57297,7 @@ var init_account = __esm({
|
|
|
57098
57297
|
});
|
|
57099
57298
|
|
|
57100
57299
|
// ../cli/src/commands/cloud.ts
|
|
57101
|
-
import
|
|
57300
|
+
import fs70 from "node:fs";
|
|
57102
57301
|
import path72 from "node:path";
|
|
57103
57302
|
async function cmdCloud(args2, program2) {
|
|
57104
57303
|
const [sub] = args2;
|
|
@@ -57174,7 +57373,7 @@ async function cloudImage(opts, program2) {
|
|
|
57174
57373
|
const type = REF_TYPES[path72.extname(file2).toLowerCase()];
|
|
57175
57374
|
if (!type) usage(`--ref ${file2}: use a PNG, JPEG or WebP file.`, line);
|
|
57176
57375
|
try {
|
|
57177
|
-
return `data:${type};base64,${
|
|
57376
|
+
return `data:${type};base64,${fs70.readFileSync(file2).toString("base64")}`;
|
|
57178
57377
|
} catch (e) {
|
|
57179
57378
|
usage(`--ref ${file2}: ${e instanceof Error ? e.message : String(e)}`, line);
|
|
57180
57379
|
}
|
|
@@ -57298,8 +57497,8 @@ usage: ${g.usage}` }, { bare: true, exitCode: 2 });
|
|
|
57298
57497
|
refuse2(g.failed, g.fallback, { code: error62.kind, message: error62.message, retryable: true });
|
|
57299
57498
|
}
|
|
57300
57499
|
const out = g.outFor?.(res, g.out) ?? g.out;
|
|
57301
|
-
|
|
57302
|
-
|
|
57500
|
+
fs70.mkdirSync(path72.dirname(path72.resolve(out)), { recursive: true });
|
|
57501
|
+
fs70.writeFileSync(out, bytes2);
|
|
57303
57502
|
say(`${out} (${g.label(res)})`);
|
|
57304
57503
|
return { out };
|
|
57305
57504
|
}
|
|
@@ -57361,7 +57560,7 @@ var init_cloud = __esm({
|
|
|
57361
57560
|
});
|
|
57362
57561
|
|
|
57363
57562
|
// ../cli/src/commands/task.ts
|
|
57364
|
-
import
|
|
57563
|
+
import fs71 from "node:fs";
|
|
57365
57564
|
import os5 from "node:os";
|
|
57366
57565
|
import path73 from "node:path";
|
|
57367
57566
|
async function cloud(method, route2, body, signal2) {
|
|
@@ -57420,7 +57619,7 @@ function linked(location) {
|
|
|
57420
57619
|
return link2.ok ? link2.value : null;
|
|
57421
57620
|
}
|
|
57422
57621
|
for (let dir = path73.resolve(cwd, location.dir ?? "."); ; dir = path73.dirname(dir)) {
|
|
57423
|
-
if (
|
|
57622
|
+
if (fs71.existsSync(path73.join(dir, ".akb", "base.json"))) {
|
|
57424
57623
|
const link2 = linkedProject("", dir);
|
|
57425
57624
|
return link2.ok ? link2.value : null;
|
|
57426
57625
|
}
|
|
@@ -57527,7 +57726,7 @@ async function taskReview(id2, opts = {}, location = {}) {
|
|
|
57527
57726
|
if (opts.review !== void 0) {
|
|
57528
57727
|
fields2 = { operation: "plan", review_flow: opts.review };
|
|
57529
57728
|
} else if (opts.file !== void 0) {
|
|
57530
|
-
fields2 = { operation: "plan", review_plan: parseReviewPlan(JSON.parse(
|
|
57729
|
+
fields2 = { operation: "plan", review_plan: parseReviewPlan(JSON.parse(fs71.readFileSync(opts.file, "utf8"))) };
|
|
57531
57730
|
} else if (opts.reviseFrom !== void 0) {
|
|
57532
57731
|
fields2 = { operation: "revise", stage: opts.reviseFrom };
|
|
57533
57732
|
} else if (opts.previewDefinitionsFile !== void 0) {
|
|
@@ -57536,7 +57735,7 @@ async function taskReview(id2, opts = {}, location = {}) {
|
|
|
57536
57735
|
if (!opts.stage || !["running", "done"].includes(opts.status)) die("--stage and --status running|done are required.");
|
|
57537
57736
|
fields2 = { operation: "status", stage: opts.stage, status: opts.status };
|
|
57538
57737
|
}
|
|
57539
|
-
if (opts.previewDefinitionsFile !== void 0) fields2.preview_definitions = previewDefinitionsSchema.parse(JSON.parse(
|
|
57738
|
+
if (opts.previewDefinitionsFile !== void 0) fields2.preview_definitions = previewDefinitionsSchema.parse(JSON.parse(fs71.readFileSync(opts.previewDefinitionsFile, "utf8")));
|
|
57540
57739
|
task = await cloud("POST", `/v1/tasks/${enc(ref)}/review`, { ...fields2, review_revision });
|
|
57541
57740
|
}
|
|
57542
57741
|
say(JSON.stringify(task.review, null, 2));
|
|
@@ -57579,7 +57778,7 @@ async function taskUpdateQuestions(id2, typed, location = {}) {
|
|
|
57579
57778
|
return withBoardLock(() => {
|
|
57580
57779
|
const run3 = insideRun();
|
|
57581
57780
|
const runCard = run3 ? peekRun(run3)?.cardId : null;
|
|
57582
|
-
if (runCard != null && runCard !== mapped.number || !
|
|
57781
|
+
if (runCard != null && runCard !== mapped.number || !fs71.existsSync(path73.join(board2, "todo")) || !locate(mapped.number)) {
|
|
57583
57782
|
return unavailable();
|
|
57584
57783
|
}
|
|
57585
57784
|
return updateCardQuestions(mapped.number, ops);
|
|
@@ -57620,7 +57819,7 @@ function runnerTaskBoard(location) {
|
|
|
57620
57819
|
const cwd = location.cwd ?? process.cwd();
|
|
57621
57820
|
try {
|
|
57622
57821
|
const board2 = path73.resolve(cwd, location.board ?? runnerBoard);
|
|
57623
|
-
return
|
|
57822
|
+
return fs71.realpathSync(board2) === fs71.realpathSync(path73.resolve(cwd, runnerBoard)) && runnerProject(board2) ? board2 : null;
|
|
57624
57823
|
} catch {
|
|
57625
57824
|
return null;
|
|
57626
57825
|
}
|
|
@@ -57628,7 +57827,7 @@ function runnerTaskBoard(location) {
|
|
|
57628
57827
|
function localTaskRecord(board2, task) {
|
|
57629
57828
|
if (!/^task_[\w-]+$/.test(task)) return null;
|
|
57630
57829
|
try {
|
|
57631
|
-
const record2 = JSON.parse(
|
|
57830
|
+
const record2 = JSON.parse(fs71.readFileSync(path73.join(board2, ".sync", task + ".json"), "utf8"));
|
|
57632
57831
|
if (record2.task === task && Number.isSafeInteger(record2.number) && record2.number > 0 && !record2.deleted) {
|
|
57633
57832
|
return { board: board2, task, number: record2.number };
|
|
57634
57833
|
}
|
|
@@ -57661,7 +57860,7 @@ function operationStatus(result) {
|
|
|
57661
57860
|
}
|
|
57662
57861
|
function archiveReceipt(board2, task, file2) {
|
|
57663
57862
|
try {
|
|
57664
|
-
const base = JSON.parse(
|
|
57863
|
+
const base = JSON.parse(fs71.readFileSync(path73.join(board2, "..", "base.json"), "utf8"));
|
|
57665
57864
|
const receipt = base.archiveReceipts?.[task];
|
|
57666
57865
|
const root2 = `projects/${runnerProject(board2)}/`;
|
|
57667
57866
|
const synced = receipt && base.files?.[root2 + receipt.path];
|
|
@@ -57670,7 +57869,7 @@ function archiveReceipt(board2, task, file2) {
|
|
|
57670
57869
|
if (synced && (!file2 || receipt.path === file2) && synced.seq === receipt.seq && (assets?.seq ?? 0) === receipt.assets_seq) {
|
|
57671
57870
|
const local = (name) => {
|
|
57672
57871
|
try {
|
|
57673
|
-
return
|
|
57872
|
+
return fs71.readFileSync(path73.join(board2, name), "utf8");
|
|
57674
57873
|
} catch {
|
|
57675
57874
|
return null;
|
|
57676
57875
|
}
|
|
@@ -57695,7 +57894,7 @@ async function taskArchive(asked, location = {}) {
|
|
|
57695
57894
|
const existing = locateArchived(local.number);
|
|
57696
57895
|
if (!existing) return null;
|
|
57697
57896
|
const file2 = existing.kind === "group" ? path73.join(existing.target, "root.md") : existing.target;
|
|
57698
|
-
const { meta: meta3 } = parseFrontmatter(
|
|
57897
|
+
const { meta: meta3 } = parseFrontmatter(fs71.readFileSync(file2, "utf8"));
|
|
57699
57898
|
if (!meta3?.archived || meta3.rejected) return refuse3("This task is not eligible for archive.", "conflict");
|
|
57700
57899
|
return {
|
|
57701
57900
|
receipt: { archived_to: path73.relative(local.board, existing.target) },
|
|
@@ -57897,20 +58096,20 @@ var init_goal = __esm({
|
|
|
57897
58096
|
});
|
|
57898
58097
|
|
|
57899
58098
|
// ../cli/src/lib/goal-draft.ts
|
|
57900
|
-
import
|
|
58099
|
+
import fs72 from "node:fs";
|
|
57901
58100
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
57902
58101
|
function readGoalDraft(file2) {
|
|
57903
|
-
return decodeGoals(JSON.parse(
|
|
58102
|
+
return decodeGoals(JSON.parse(fs72.readFileSync(file2, "utf8")));
|
|
57904
58103
|
}
|
|
57905
58104
|
function writeGoalDraft(file2, { goals, ...draft }, field2) {
|
|
57906
58105
|
const entries2 = field2 === "goals" ? goals : goals.map(({ task, ...goal }) => ({ ...goal, task: task?.key ? task : task?.id ?? null }));
|
|
57907
58106
|
const temporary = `${file2}.${randomUUID7()}.tmp`;
|
|
57908
58107
|
try {
|
|
57909
|
-
|
|
58108
|
+
fs72.writeFileSync(temporary, `${JSON.stringify({ ...draft, [field2]: entries2 }, null, 2)}
|
|
57910
58109
|
`, { mode: 384, flag: "wx" });
|
|
57911
|
-
|
|
58110
|
+
fs72.renameSync(temporary, file2);
|
|
57912
58111
|
} finally {
|
|
57913
|
-
|
|
58112
|
+
fs72.rmSync(temporary, { force: true });
|
|
57914
58113
|
}
|
|
57915
58114
|
}
|
|
57916
58115
|
var goalDraftPath;
|
|
@@ -57923,7 +58122,7 @@ var init_goal_draft = __esm({
|
|
|
57923
58122
|
});
|
|
57924
58123
|
|
|
57925
58124
|
// ../cli/src/commands/goal.ts
|
|
57926
|
-
import
|
|
58125
|
+
import fs73 from "node:fs";
|
|
57927
58126
|
function loadGoals() {
|
|
57928
58127
|
const file2 = goalDraftPath();
|
|
57929
58128
|
if (!file2) die("Goals exist only inside a WildCrane goal discussion.");
|
|
@@ -57955,7 +58154,7 @@ function splitBody2(text5) {
|
|
|
57955
58154
|
}
|
|
57956
58155
|
function readBody(bodyFile) {
|
|
57957
58156
|
if (!bodyFile) die("--body-file is required; write the goal in a writable temporary file first.");
|
|
57958
|
-
const text5 =
|
|
58157
|
+
const text5 = fs73.readFileSync(bodyFile, "utf8");
|
|
57959
58158
|
if (!text5.trim()) die("The goal must not be empty.");
|
|
57960
58159
|
return splitBody2(text5);
|
|
57961
58160
|
}
|
|
@@ -58021,7 +58220,7 @@ function cmdGoalStudios(held4 = loadGoals().held) {
|
|
|
58021
58220
|
return { studios: held4.studios.map((w) => ({ ...w, id: shortStudioId(w.id) })) };
|
|
58022
58221
|
}
|
|
58023
58222
|
function goalDefinitions(opts, previous = []) {
|
|
58024
|
-
return opts.previewDefinitionsFile === void 0 ? previous : previewDefinitionsSchema.parse(JSON.parse(
|
|
58223
|
+
return opts.previewDefinitionsFile === void 0 ? previous : previewDefinitionsSchema.parse(JSON.parse(fs73.readFileSync(opts.previewDefinitionsFile, "utf8")));
|
|
58025
58224
|
}
|
|
58026
58225
|
function goalCatalog(held4, studio, definitions) {
|
|
58027
58226
|
const builtIn = held4.studios.find((w) => w.id === studio)?.previews;
|
|
@@ -58034,7 +58233,7 @@ function goalReview(held4, studio, opts, previous, definitions) {
|
|
|
58034
58233
|
if (opts.reviewFile !== void 0) die("Use either --review or --review-file.");
|
|
58035
58234
|
return parseReviewFlow(opts.review, catalog);
|
|
58036
58235
|
}
|
|
58037
|
-
const value = opts.reviewFile === void 0 ? readReviewPlan(previous) : JSON.parse(
|
|
58236
|
+
const value = opts.reviewFile === void 0 ? readReviewPlan(previous) : JSON.parse(fs73.readFileSync(opts.reviewFile, "utf8"));
|
|
58038
58237
|
const saved = opts.reviewFile === void 0 && opts.previewDefinitionsFile === void 0 && opts.studio === void 0;
|
|
58039
58238
|
return validateReviewPreviews(parseReviewPlan(value), catalog, { saved });
|
|
58040
58239
|
}
|
|
@@ -58064,7 +58263,7 @@ var init_goal2 = __esm({
|
|
|
58064
58263
|
});
|
|
58065
58264
|
|
|
58066
58265
|
// ../cli/src/commands/goal-cloud.ts
|
|
58067
|
-
import
|
|
58266
|
+
import fs74 from "node:fs";
|
|
58068
58267
|
import os6 from "node:os";
|
|
58069
58268
|
import path74 from "node:path";
|
|
58070
58269
|
import crypto6 from "node:crypto";
|
|
@@ -58098,17 +58297,17 @@ async function discussion() {
|
|
|
58098
58297
|
const machineFile2 = path74.join(home3, "machine.json");
|
|
58099
58298
|
let machine;
|
|
58100
58299
|
try {
|
|
58101
|
-
machine = JSON.parse(
|
|
58300
|
+
machine = JSON.parse(fs74.readFileSync(machineFile2, "utf8")).id;
|
|
58102
58301
|
} catch {
|
|
58103
58302
|
machine = crypto6.randomUUID();
|
|
58104
|
-
|
|
58105
|
-
|
|
58303
|
+
fs74.mkdirSync(home3, { recursive: true });
|
|
58304
|
+
fs74.writeFileSync(machineFile2, JSON.stringify({ id: machine }));
|
|
58106
58305
|
}
|
|
58107
58306
|
const held4 = await request("GET", `/v1/runner/folders?machine=${encodeURIComponent(machine)}`);
|
|
58108
|
-
const cwd =
|
|
58307
|
+
const cwd = fs74.realpathSync(process.cwd());
|
|
58109
58308
|
const folder2 = held4.folders.filter((f) => {
|
|
58110
58309
|
try {
|
|
58111
|
-
const dir =
|
|
58310
|
+
const dir = fs74.realpathSync(f.path);
|
|
58112
58311
|
return cwd === dir || cwd.startsWith(dir + path74.sep);
|
|
58113
58312
|
} catch {
|
|
58114
58313
|
return false;
|
|
@@ -58422,7 +58621,7 @@ var init_agent = __esm({
|
|
|
58422
58621
|
|
|
58423
58622
|
// ../cli/src/commands/cloud-template.ts
|
|
58424
58623
|
import { createHash as createHash5 } from "node:crypto";
|
|
58425
|
-
import
|
|
58624
|
+
import fs75 from "node:fs";
|
|
58426
58625
|
import path75 from "node:path";
|
|
58427
58626
|
function usage2(problem, line) {
|
|
58428
58627
|
die(`${problem}
|
|
@@ -58487,9 +58686,9 @@ async function downloadEntries(name, kind, files, to, fallback) {
|
|
|
58487
58686
|
if (file2.sha256 && createHash5("sha256").update(bytes2).digest("hex") !== file2.sha256) refuse4(T.corrupt, fallback, invalidResponse(expected));
|
|
58488
58687
|
fetched.push({ out, bytes: bytes2 });
|
|
58489
58688
|
}
|
|
58490
|
-
if (fetched.length)
|
|
58689
|
+
if (fetched.length) fs75.mkdirSync(to, { recursive: true });
|
|
58491
58690
|
return fetched.map(({ out, bytes: bytes2 }) => {
|
|
58492
|
-
|
|
58691
|
+
fs75.writeFileSync(out, bytes2);
|
|
58493
58692
|
say(out);
|
|
58494
58693
|
return out;
|
|
58495
58694
|
});
|
|
@@ -58562,7 +58761,7 @@ async function templateGet(name, opts, program2) {
|
|
|
58562
58761
|
}
|
|
58563
58762
|
fetched.push({ out, bytes: bytes2 });
|
|
58564
58763
|
}
|
|
58565
|
-
const taken = fetched.filter((f) =>
|
|
58764
|
+
const taken = fetched.filter((f) => fs75.existsSync(f.out)).map((f) => path75.relative(to, f.out));
|
|
58566
58765
|
if (taken.length > 0) {
|
|
58567
58766
|
refuse4({
|
|
58568
58767
|
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 +58769,8 @@ async function templateGet(name, opts, program2) {
|
|
|
58570
58769
|
});
|
|
58571
58770
|
}
|
|
58572
58771
|
for (const f of fetched) {
|
|
58573
|
-
|
|
58574
|
-
|
|
58772
|
+
fs75.mkdirSync(path75.dirname(f.out), { recursive: true });
|
|
58773
|
+
fs75.writeFileSync(f.out, f.bytes);
|
|
58575
58774
|
}
|
|
58576
58775
|
say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
|
|
58577
58776
|
Fetched ${name}: ${fetched.length} files into ${to}`);
|
|
@@ -58593,13 +58792,13 @@ async function templateSource(name, opts) {
|
|
|
58593
58792
|
async function templatePublish(dir, opts) {
|
|
58594
58793
|
const root2 = path75.resolve(dir);
|
|
58595
58794
|
const manifest = path75.join(root2, "template.md");
|
|
58596
|
-
if (!
|
|
58597
|
-
const meta3 = readTemplateMeta(
|
|
58795
|
+
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.");
|
|
58796
|
+
const meta3 = readTemplateMeta(fs75.readFileSync(manifest, "utf8"));
|
|
58598
58797
|
const files = walk2(root2);
|
|
58599
|
-
const total = files.reduce((sum, f) => sum +
|
|
58798
|
+
const total = files.reduce((sum, f) => sum + fs75.statSync(path75.join(root2, f)).size, 0);
|
|
58600
58799
|
if (total > MAX_BYTES2) invalid2("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
|
|
58601
58800
|
for (const extra of [...opts.preview, ...opts.evidence]) {
|
|
58602
|
-
if (!
|
|
58801
|
+
if (!fs75.existsSync(extra)) invalid2(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
|
|
58603
58802
|
if (path75.resolve(extra).startsWith(root2 + path75.sep)) {
|
|
58604
58803
|
invalid2(
|
|
58605
58804
|
`${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 +58811,7 @@ async function templatePublish(dir, opts) {
|
|
|
58612
58811
|
}
|
|
58613
58812
|
const form = new FormData();
|
|
58614
58813
|
form.set("meta", JSON.stringify({ ...meta3, replace: !!opts.replace }));
|
|
58615
|
-
const add2 = (kind, name, file2) => form.append(`${kind}:${name}`, new Blob([
|
|
58814
|
+
const add2 = (kind, name, file2) => form.append(`${kind}:${name}`, new Blob([fs75.readFileSync(file2)]), path75.basename(name));
|
|
58616
58815
|
for (const f of files) add2("files", f, path75.join(root2, f));
|
|
58617
58816
|
for (const f of opts.preview) add2("previews", path75.basename(f), f);
|
|
58618
58817
|
for (const f of opts.evidence) add2("evidence", path75.basename(f), f);
|
|
@@ -58640,10 +58839,10 @@ Deleted ${name} from the catalog.`);
|
|
|
58640
58839
|
}
|
|
58641
58840
|
async function templateShowcase(name, dir) {
|
|
58642
58841
|
const file2 = path75.join(dir, "showcase.json");
|
|
58643
|
-
if (!
|
|
58842
|
+
if (!fs75.existsSync(file2)) invalid2(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
|
|
58644
58843
|
let meta3;
|
|
58645
58844
|
try {
|
|
58646
|
-
meta3 = JSON.parse(
|
|
58845
|
+
meta3 = JSON.parse(fs75.readFileSync(file2, "utf8"));
|
|
58647
58846
|
} catch {
|
|
58648
58847
|
return invalid2("showcase.json \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002", "showcase.json is not valid JSON.");
|
|
58649
58848
|
}
|
|
@@ -58656,8 +58855,8 @@ async function templateShowcase(name, dir) {
|
|
|
58656
58855
|
form.set("meta", JSON.stringify(meta3));
|
|
58657
58856
|
for (const p of new Set(named2)) {
|
|
58658
58857
|
const at = path75.join(dir, p);
|
|
58659
|
-
if (!
|
|
58660
|
-
form.append(`media:${p}`, new Blob([
|
|
58858
|
+
if (!fs75.existsSync(at)) invalid2(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at}\u3002`, `${at} does not exist.`);
|
|
58859
|
+
form.append(`media:${p}`, new Blob([fs75.readFileSync(at)]), p);
|
|
58661
58860
|
}
|
|
58662
58861
|
const done = requireResponse(
|
|
58663
58862
|
await asJson(await ask(`/${encodeURIComponent(name)}/showcase`, { method: "PUT", body: form })),
|
|
@@ -58670,7 +58869,7 @@ Updated ${name}'s showcase: ${done.files} files.`);
|
|
|
58670
58869
|
}
|
|
58671
58870
|
function walk2(root2, sub = "") {
|
|
58672
58871
|
const out = [];
|
|
58673
|
-
for (const entry of
|
|
58872
|
+
for (const entry of fs75.readdirSync(path75.join(root2, sub), { withFileTypes: true })) {
|
|
58674
58873
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
58675
58874
|
const rel3 = sub ? `${sub}/${entry.name}` : entry.name;
|
|
58676
58875
|
if (entry.isDirectory()) out.push(...walk2(root2, rel3));
|
|
@@ -63161,7 +63360,7 @@ var init_guide2 = __esm({
|
|
|
63161
63360
|
|
|
63162
63361
|
// ../cli/src/commands/studio.ts
|
|
63163
63362
|
import crypto7 from "node:crypto";
|
|
63164
|
-
import
|
|
63363
|
+
import fs76 from "node:fs";
|
|
63165
63364
|
import path76 from "node:path";
|
|
63166
63365
|
function cmdStudioList() {
|
|
63167
63366
|
if (!studiosReachable().ok) die(NEEDS_CLOUD, "needs-cloud");
|
|
@@ -63180,7 +63379,7 @@ function cmdStudioDiagram(_id, _card, _folder) {
|
|
|
63180
63379
|
}
|
|
63181
63380
|
function cmdStudioValidate(folder2) {
|
|
63182
63381
|
const dir = path76.resolve(folder2);
|
|
63183
|
-
if (!
|
|
63382
|
+
if (!fs76.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder2} is not a folder`, "bad-args");
|
|
63184
63383
|
const files = readStudioFolder(dir);
|
|
63185
63384
|
let builtin = false;
|
|
63186
63385
|
try {
|
|
@@ -63202,7 +63401,7 @@ async function cmdStudioPull(id2, folder2) {
|
|
|
63202
63401
|
found(id2);
|
|
63203
63402
|
}
|
|
63204
63403
|
const dir = path76.resolve(folder2 ?? id2);
|
|
63205
|
-
if (
|
|
63404
|
+
if (fs76.existsSync(dir) && fs76.readdirSync(dir).length) die(`${folder2 ?? id2} is not empty`, "bad-args");
|
|
63206
63405
|
const read5 = await call("GET", `/v1/studios/${encodeURIComponent(cloudId)}`);
|
|
63207
63406
|
const { version: version2, files } = requireResponse(
|
|
63208
63407
|
cloudOk(read5, read5.ok || read5.code !== "not_found" ? void 0 : "no-such-studio"),
|
|
@@ -63211,9 +63410,9 @@ async function cmdStudioPull(id2, folder2) {
|
|
|
63211
63410
|
);
|
|
63212
63411
|
for (const [file2, text5] of Object.entries({ ...files, [VERSION_FILE]: versionText(cloudId, version2) })) {
|
|
63213
63412
|
const full = path76.join(dir, ...file2.split("/"));
|
|
63214
|
-
|
|
63413
|
+
fs76.mkdirSync(path76.dirname(full), { recursive: true });
|
|
63215
63414
|
const data = isAboutFile(file2) && !file2.endsWith(".md") && /^data:[^;]+;base64,/.exec(text5);
|
|
63216
|
-
|
|
63415
|
+
fs76.writeFileSync(full, data ? Buffer.from(text5.slice(data[0].length), "base64") : text5);
|
|
63217
63416
|
}
|
|
63218
63417
|
const shown = folder2 ?? `./${id2}`;
|
|
63219
63418
|
say(`Pulled ${id2} v${version2} into ${shown}.`);
|
|
@@ -63229,13 +63428,13 @@ async function publishFolder(dir, route2, body, requestId) {
|
|
|
63229
63428
|
const hash3 = crypto7.createHash("sha256").update(JSON.stringify({ route: route2, files: body.files, workspace: body.workspace })).digest("hex");
|
|
63230
63429
|
let held4;
|
|
63231
63430
|
try {
|
|
63232
|
-
held4 = JSON.parse(
|
|
63431
|
+
held4 = JSON.parse(fs76.readFileSync(pendingFile, "utf8"));
|
|
63233
63432
|
} catch {
|
|
63234
63433
|
}
|
|
63235
63434
|
if (requestId && held4?.requestId === requestId && held4.hash !== hash3) die("This request ID already names different files; use a new request ID.", "bad-args");
|
|
63236
63435
|
const replay = held4?.hash === hash3 && held4.route === route2 && (!requestId || held4.requestId === requestId) && (body.expectedVersion === held4.body.expectedVersion || body.expectedVersion === held4.resultVersion);
|
|
63237
63436
|
const pending = replay ? held4 : { requestId: requestId ?? crypto7.randomUUID(), hash: hash3, body, route: route2 };
|
|
63238
|
-
|
|
63437
|
+
fs76.writeFileSync(pendingFile, JSON.stringify(pending, null, 2) + "\n");
|
|
63239
63438
|
const res = await call(route2 === "/v1/studios" ? "POST" : "PATCH", route2, pending.body, pending.requestId);
|
|
63240
63439
|
const { id: id2, version: version2 } = requireResponse(
|
|
63241
63440
|
cloudOk(res, !res.ok && ["version_conflict", "conflict"].includes(res.code ?? "") ? "studio-moved" : void 0),
|
|
@@ -63243,8 +63442,8 @@ async function publishFolder(dir, route2, body, requestId) {
|
|
|
63243
63442
|
(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
63443
|
);
|
|
63245
63444
|
pending.resultVersion = version2;
|
|
63246
|
-
|
|
63247
|
-
|
|
63445
|
+
fs76.writeFileSync(pendingFile, JSON.stringify(pending, null, 2) + "\n");
|
|
63446
|
+
fs76.writeFileSync(path76.join(dir, VERSION_FILE), versionText(id2, version2));
|
|
63248
63447
|
say(`Saved ${studioName(id2)} v${version2}. New tasks take it.`);
|
|
63249
63448
|
return { id: id2, version: version2, changed: true, requestId: pending.requestId };
|
|
63250
63449
|
}
|
|
@@ -63259,14 +63458,14 @@ async function cmdStudioPush(folder2, opts) {
|
|
|
63259
63458
|
const dir = path76.resolve(folder2);
|
|
63260
63459
|
let pulled = null;
|
|
63261
63460
|
try {
|
|
63262
|
-
pulled = JSON.parse(
|
|
63461
|
+
pulled = JSON.parse(fs76.readFileSync(path76.join(dir, VERSION_FILE), "utf8"));
|
|
63263
63462
|
} catch {
|
|
63264
63463
|
}
|
|
63265
63464
|
if (!pulled?.id || !Number.isInteger(pulled.version) || pulled.version < 1) die(`${folder2} has no valid version.json; pull again.`, "bad-args");
|
|
63266
63465
|
const { id: id2, version: version2 } = pulled;
|
|
63267
63466
|
if (id2.startsWith("wf_builtin_")) die("Copy this studio before editing it.", "studio-read-only");
|
|
63268
63467
|
const files = publicationFiles(dir);
|
|
63269
|
-
if (!
|
|
63468
|
+
if (!fs76.existsSync(path76.join(dir, ".publication.json")) && !opts.requestId) {
|
|
63270
63469
|
const now = await call("GET", `/v1/studios/${encodeURIComponent(id2)}`);
|
|
63271
63470
|
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
63471
|
say(`${studioName(id2)} is unchanged (v${version2}).`);
|
|
@@ -63289,7 +63488,7 @@ function noteText({ file: file2, text: text5 }) {
|
|
|
63289
63488
|
if (file2 !== void 0 && text5 !== void 0) die("pass --file or --text, not both", "bad-args");
|
|
63290
63489
|
if (file2 !== void 0) {
|
|
63291
63490
|
try {
|
|
63292
|
-
return
|
|
63491
|
+
return fs76.readFileSync(file2, "utf8").trim();
|
|
63293
63492
|
} catch {
|
|
63294
63493
|
die(`can't read ${file2}`, "bad-args");
|
|
63295
63494
|
}
|
|
@@ -63475,7 +63674,7 @@ var init_progress = __esm({
|
|
|
63475
63674
|
});
|
|
63476
63675
|
|
|
63477
63676
|
// ../cli/src/lib/agent/complete.ts
|
|
63478
|
-
import
|
|
63677
|
+
import fs77 from "node:fs";
|
|
63479
63678
|
function checkRecordedResult(receipt, commit, branch) {
|
|
63480
63679
|
if (receipt.commit === commit && receipt.branch === branch) return;
|
|
63481
63680
|
const describe4 = (hash3, target) => hash3 ? `${hash3} on ${target}` : "no Git result";
|
|
@@ -63503,7 +63702,7 @@ function completeDelivery(named2, result = {}) {
|
|
|
63503
63702
|
const run3 = store.runs.find((r) => r.sessionId === sessionId);
|
|
63504
63703
|
const current = store.runs.filter((r) => r.deliveryId === delivery2.deliveryId && ["implement", "scheduled"].includes(r.action)).pop();
|
|
63505
63704
|
const liveCard = delivery2.cardId === null ? null : cardFile(delivery2.cardId);
|
|
63506
|
-
const restored = liveCard && parseFrontmatter(
|
|
63705
|
+
const restored = liveCard && parseFrontmatter(fs77.readFileSync(liveCard, "utf8")).meta?.restored;
|
|
63507
63706
|
if (restored && Date.parse(restored) > (run3?.startedAt ?? 0)) throw new Error("This delivery predates task restoration.");
|
|
63508
63707
|
if (!run3 || run3.deliveryId !== delivery2.deliveryId) throw new Error("This run does not own the delivery.");
|
|
63509
63708
|
const pending = receipts[deliveryStep(delivery2)];
|
|
@@ -63611,7 +63810,7 @@ function startSubRun(parentId, prompt, runtime) {
|
|
|
63611
63810
|
const parent = peekRun(parentId);
|
|
63612
63811
|
if (!parent || parent.status !== "running") return refusal("runNotFound", `run ${parentId.slice(0, 8)} is not running here`, { id: parentId });
|
|
63613
63812
|
if (parent.action === "sub") return refusal("subRunNested", "a sub-run cannot start sub-runs of its own");
|
|
63614
|
-
const inherited = parent.runtime &&
|
|
63813
|
+
const inherited = parent.runtime && runRuntimeById(parent.runtime) ? parent.runtime : void 0;
|
|
63615
63814
|
return open3(
|
|
63616
63815
|
{
|
|
63617
63816
|
action: "sub",
|
|
@@ -63674,7 +63873,7 @@ var init_start = __esm({
|
|
|
63674
63873
|
});
|
|
63675
63874
|
|
|
63676
63875
|
// ../cli/src/lib/agent/task-chats.ts
|
|
63677
|
-
import
|
|
63876
|
+
import fs78 from "node:fs";
|
|
63678
63877
|
import path77 from "node:path";
|
|
63679
63878
|
function taskChatFile(task, home3) {
|
|
63680
63879
|
if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
|
|
@@ -63683,7 +63882,7 @@ function taskChatFile(task, home3) {
|
|
|
63683
63882
|
function readTaskChat(task, home3) {
|
|
63684
63883
|
let text5;
|
|
63685
63884
|
try {
|
|
63686
|
-
text5 =
|
|
63885
|
+
text5 = fs78.readFileSync(taskChatFile(task, home3), "utf8");
|
|
63687
63886
|
} catch {
|
|
63688
63887
|
return [];
|
|
63689
63888
|
}
|
|
@@ -63709,7 +63908,7 @@ var init_task_chats = __esm({
|
|
|
63709
63908
|
});
|
|
63710
63909
|
|
|
63711
63910
|
// ../cli/src/lib/agent/memory-review.ts
|
|
63712
|
-
import
|
|
63911
|
+
import fs79 from "node:fs";
|
|
63713
63912
|
import path78 from "node:path";
|
|
63714
63913
|
function taskChatsToReview(tasks) {
|
|
63715
63914
|
const out = [];
|
|
@@ -63733,7 +63932,7 @@ function readArchived2(id2) {
|
|
|
63733
63932
|
if (!found2) return null;
|
|
63734
63933
|
try {
|
|
63735
63934
|
const file2 = found2.kind === "group" ? path78.join(found2.target, "root.md") : found2.target;
|
|
63736
|
-
const { meta: meta3, body } = parseFrontmatter(
|
|
63935
|
+
const { meta: meta3, body } = parseFrontmatter(fs79.readFileSync(file2, "utf8"));
|
|
63737
63936
|
if (!meta3) return null;
|
|
63738
63937
|
return { id: id2, title: meta3.title, modules: meta3.modules ?? [], studio: meta3.studio ?? "", previews: meta3.previews ?? [], rejected: meta3.rejected, body };
|
|
63739
63938
|
} catch {
|
|
@@ -63794,18 +63993,18 @@ var init_memory_review = __esm({
|
|
|
63794
63993
|
});
|
|
63795
63994
|
|
|
63796
63995
|
// ../cli/src/lib/agent/dismissal-review.ts
|
|
63797
|
-
import
|
|
63996
|
+
import fs80 from "node:fs";
|
|
63798
63997
|
import path79 from "node:path";
|
|
63799
63998
|
function rejectionsToReview() {
|
|
63800
63999
|
const scratch = process.env.AI4KANBAN_REJECTION_INPUT;
|
|
63801
64000
|
const dir = path79.join(scratch ? path79.join(scratch, ".archive") : ARCHIVE, REJECTIONS_TO_REVIEW);
|
|
63802
|
-
if (!
|
|
64001
|
+
if (!fs80.existsSync(dir)) return [];
|
|
63803
64002
|
const found2 = [];
|
|
63804
64003
|
for (const file2 of walkMd(dir)) {
|
|
63805
64004
|
const id2 = archivedId(file2);
|
|
63806
64005
|
if (id2 === null) continue;
|
|
63807
64006
|
try {
|
|
63808
|
-
const { meta: meta3 } = parseFrontmatter(
|
|
64007
|
+
const { meta: meta3 } = parseFrontmatter(fs80.readFileSync(file2, "utf8"));
|
|
63809
64008
|
if (!meta3?.rejected || meta3.rejected_by !== "user" || !meta3.rejected_reason.trim()) continue;
|
|
63810
64009
|
found2.push({ id: id2, title: meta3.title, file: rel(file2), reason: meta3.rejected_reason.trim(), rejectedAt: meta3.rejected_at });
|
|
63811
64010
|
} catch {
|
|
@@ -63827,7 +64026,7 @@ function citedSources(text5) {
|
|
|
63827
64026
|
const ids = /* @__PURE__ */ new Set();
|
|
63828
64027
|
for (const line of text5.split("\n")) {
|
|
63829
64028
|
if (!/^\s*[-*]\s/.test(line)) continue;
|
|
63830
|
-
const m = line.match(
|
|
64029
|
+
const m = line.match(SOURCES2);
|
|
63831
64030
|
for (const id2 of m?.[1].split(",") ?? []) if (id2.trim()) ids.add(id2.trim());
|
|
63832
64031
|
}
|
|
63833
64032
|
return [...ids];
|
|
@@ -63835,7 +64034,7 @@ function citedSources(text5) {
|
|
|
63835
64034
|
function withdrawnSources() {
|
|
63836
64035
|
const cited = [...new Set(plannerCopies("rejected.md").flatMap((file2) => {
|
|
63837
64036
|
try {
|
|
63838
|
-
return citedSources(
|
|
64037
|
+
return citedSources(fs80.readFileSync(file2, "utf8"));
|
|
63839
64038
|
} catch {
|
|
63840
64039
|
return [];
|
|
63841
64040
|
}
|
|
@@ -63846,7 +64045,7 @@ function withdrawnSources() {
|
|
|
63846
64045
|
const restored = new Set([...readInbox(), ...readArchived(scratch ? path79.join(scratch, "triage", "archived") : void 0)].map((s) => s.sourceId));
|
|
63847
64046
|
return cited.filter((id2) => restored.has(id2) && !dismissed.has(id2));
|
|
63848
64047
|
}
|
|
63849
|
-
var reviewDismissed,
|
|
64048
|
+
var reviewDismissed, SOURCES2;
|
|
63850
64049
|
var init_dismissal_review = __esm({
|
|
63851
64050
|
"../cli/src/lib/agent/dismissal-review.ts"() {
|
|
63852
64051
|
"use strict";
|
|
@@ -63860,12 +64059,12 @@ var init_dismissal_review = __esm({
|
|
|
63860
64059
|
const scratch = process.env.AI4KANBAN_REJECTION_INPUT;
|
|
63861
64060
|
return readAllDismissed(scratch ? path79.join(scratch, "triage", "dismissed") : void 0);
|
|
63862
64061
|
};
|
|
63863
|
-
|
|
64062
|
+
SOURCES2 = /\(([^()]+)\)\s*$/;
|
|
63864
64063
|
}
|
|
63865
64064
|
});
|
|
63866
64065
|
|
|
63867
64066
|
// ../cli/src/lib/agent/flow.ts
|
|
63868
|
-
import
|
|
64067
|
+
import fs81 from "node:fs";
|
|
63869
64068
|
import path80 from "node:path";
|
|
63870
64069
|
function readCard2(id2, home3 = "board") {
|
|
63871
64070
|
const pending = activeDelivery(id2)?.completions?.some((c) => !c.finished);
|
|
@@ -63879,7 +64078,7 @@ function readCard2(id2, home3 = "board") {
|
|
|
63879
64078
|
const file2 = found2.kind === "group" ? path80.join(found2.target, "root.md") : found2.target;
|
|
63880
64079
|
let text5;
|
|
63881
64080
|
try {
|
|
63882
|
-
text5 =
|
|
64081
|
+
text5 = fs81.readFileSync(file2, "utf8");
|
|
63883
64082
|
} catch {
|
|
63884
64083
|
die(`#${id2} is on the board but ${rel(file2)} can't be read.`, { kind: "card-unreadable", id: id2 });
|
|
63885
64084
|
}
|
|
@@ -64724,7 +64923,7 @@ __export(watch_exports, {
|
|
|
64724
64923
|
watchRun: () => watchRun
|
|
64725
64924
|
});
|
|
64726
64925
|
import { spawn as spawn3 } from "node:child_process";
|
|
64727
|
-
import
|
|
64926
|
+
import fs82 from "node:fs";
|
|
64728
64927
|
async function watchRun(sessionId, resume = startResume, retryBackoff = backoffMs) {
|
|
64729
64928
|
const spec = readSpec(sessionId);
|
|
64730
64929
|
const run3 = peekRun(sessionId);
|
|
@@ -64760,20 +64959,24 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
64760
64959
|
const record2 = claimed ?? run3;
|
|
64761
64960
|
const sub = record2.action === "sub";
|
|
64762
64961
|
if (claim2) await setCardStatus(claim2.cardId, claim2.status);
|
|
64763
|
-
|
|
64764
|
-
const logFile =
|
|
64962
|
+
fs82.mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
64963
|
+
const logFile = fs82.createWriteStream(record2.logPath, { flags: "a" });
|
|
64765
64964
|
logFile.on("error", () => {
|
|
64766
64965
|
});
|
|
64767
|
-
const eventsFile =
|
|
64966
|
+
const eventsFile = fs82.createWriteStream(eventsPathOf(sessionId), { flags: "a" });
|
|
64768
64967
|
eventsFile.on("error", () => {
|
|
64769
64968
|
});
|
|
64770
64969
|
let observeActivity = (_e) => {
|
|
64771
64970
|
};
|
|
64772
64971
|
const pendingOperations = /* @__PURE__ */ new Set();
|
|
64972
|
+
let hadEffects = false;
|
|
64773
64973
|
const event2 = (e) => {
|
|
64774
64974
|
observeActivity(e);
|
|
64775
64975
|
const hadPending = pendingOperations.size > 0;
|
|
64776
|
-
if (e.kind === "tool_call" && !["read", "search", "fetch"].includes(e.data.kind)
|
|
64976
|
+
if (e.kind === "tool_call" && !["read", "search", "fetch"].includes(e.data.kind)) {
|
|
64977
|
+
hadEffects = true;
|
|
64978
|
+
if (!["completed", "failed"].includes(e.data.status)) pendingOperations.add(e.data.toolCallId);
|
|
64979
|
+
}
|
|
64777
64980
|
if ((e.kind === "tool_call" || e.kind === "tool_call_update") && ["completed", "failed"].includes(e.data.status ?? "")) pendingOperations.delete(e.data.toolCallId);
|
|
64778
64981
|
if (record2.cloudExecution && hadPending !== pendingOperations.size > 0) {
|
|
64779
64982
|
patch(sessionId, (run4) => {
|
|
@@ -64783,6 +64986,11 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
64783
64986
|
eventsFile.write(`${JSON.stringify(e)}
|
|
64784
64987
|
`);
|
|
64785
64988
|
};
|
|
64989
|
+
const runtimeInfo = () => ({
|
|
64990
|
+
connector: record2.harness,
|
|
64991
|
+
name: record2.runtime ? runtimeById(record2.runtime)?.name ?? null : null,
|
|
64992
|
+
model: peekRun(sessionId)?.model ?? record2.model ?? null
|
|
64993
|
+
});
|
|
64786
64994
|
const log = {
|
|
64787
64995
|
write(text5) {
|
|
64788
64996
|
logFile.write(text5);
|
|
@@ -64817,7 +65025,8 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
64817
65025
|
`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
65026
|
...coding && !approvedUi && review?.plan?.some((node2) => node2.previews.includes("ui-design")) ? [APPROVED_UI_RULE] : []
|
|
64819
65027
|
].join("\n") : "";
|
|
64820
|
-
const
|
|
65028
|
+
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.` : "";
|
|
65029
|
+
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
65030
|
const before = markBoard();
|
|
64822
65031
|
const takes = active3.images;
|
|
64823
65032
|
active3.renderer?.setRequiredImages?.(record2.pictures ?? []);
|
|
@@ -64845,11 +65054,29 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
64845
65054
|
letGo();
|
|
64846
65055
|
return 1;
|
|
64847
65056
|
}
|
|
64848
|
-
if (record2.retry?.launching)
|
|
64849
|
-
|
|
64850
|
-
r
|
|
64851
|
-
|
|
64852
|
-
|
|
65057
|
+
if (record2.retry?.launching) {
|
|
65058
|
+
const nextAttempt = record2.retry.attempt + 1;
|
|
65059
|
+
patch(sessionId, (r) => {
|
|
65060
|
+
if (!r.retry?.launching) return;
|
|
65061
|
+
r.retry.attempt++;
|
|
65062
|
+
delete r.retry.launching;
|
|
65063
|
+
});
|
|
65064
|
+
event2({
|
|
65065
|
+
kind: "retry",
|
|
65066
|
+
data: {
|
|
65067
|
+
state: "retrying",
|
|
65068
|
+
source: record2.failure?.source ?? "runtime",
|
|
65069
|
+
runtime: runtimeInfo(),
|
|
65070
|
+
attempt: nextAttempt,
|
|
65071
|
+
maxAttempts: record2.retry.of,
|
|
65072
|
+
summary: record2.failure?.summary ?? record2.retry.reason,
|
|
65073
|
+
...record2.failure?.detail ? { detail: record2.failure.detail } : {},
|
|
65074
|
+
...record2.failure?.code ? { code: record2.failure.code } : {},
|
|
65075
|
+
sessionAction: record2.resumedFrom ? "resume" : "reset_replay",
|
|
65076
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
65077
|
+
}
|
|
65078
|
+
});
|
|
65079
|
+
}
|
|
64853
65080
|
try {
|
|
64854
65081
|
const start = spawnable(cmd, client || stdinPrompt ? args2 : [...args2, prompt], {
|
|
64855
65082
|
// Where this run works: the project, or — inside a delivery with a worktree of its
|
|
@@ -65033,34 +65260,79 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
65033
65260
|
const rendered = renderer?.failure?.() ?? (!taskCompleted && renderer?.background?.() ? "The agent exited with unfinished background tasks." : void 0);
|
|
65034
65261
|
const said2 = spawnError ?? (silent ? silenceSaid(silenceFor) : spoken?.error ?? rendered);
|
|
65035
65262
|
const failed2 = code !== 0 || spoken?.ok === false || !!rendered || silent || !!blocker;
|
|
65036
|
-
const failure2 = failed2 && !asked ? silent ? {
|
|
65263
|
+
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}.`, {
|
|
65264
|
+
code: blocker ? "execution_blocked" : "execution_failed",
|
|
65265
|
+
detail: said2 ?? blocker?.cause ?? `Agent exited with code ${code}.`
|
|
65266
|
+
}) : void 0;
|
|
65037
65267
|
const result = spoken ? spoken.result : renderer?.result();
|
|
65038
65268
|
let retryPause;
|
|
65039
65269
|
let retrying = false;
|
|
65270
|
+
let retryHistory = held4.retryHistory ? [...held4.retryHistory] : void 0;
|
|
65271
|
+
let sessionAction;
|
|
65040
65272
|
if (failure2 && !sub && !taskCompleted) {
|
|
65041
65273
|
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
|
-
|
|
65274
|
+
const missingSession = isSessionMissingFailure(failure2);
|
|
65275
|
+
const mark = runMark(sessionId, agentStartedAt);
|
|
65276
|
+
const root2 = child.pid ? { pid: child.pid, since: agentStartedAt, identity: held4.agentIdentity } : void 0;
|
|
65277
|
+
const stopped3 = () => client?.managedProcess ? connectionStopped(root2) : processesStopped(mark, root2);
|
|
65278
|
+
const until = Date.now() + STOP_GRACE_MS + STOP_CLOSE_MS;
|
|
65279
|
+
while (!stopped3() && Date.now() < until) await sleep4(100);
|
|
65280
|
+
const isStopped = stopped3();
|
|
65281
|
+
const session = structured && !spawnFailure && !missingSession ? resumeSessionId(held4) : void 0;
|
|
65282
|
+
const unconfirmedCleanup = pendingOperations.size > 0 || !!blocker || spoken?.cleanup?.status === "unconfirmed" || failure2.code === "codex_ownership_unconfirmed" || client?.managedProcess && silent && (uncertainAtIdle || !idleStopConfirmed(spoken?.cleanup, session));
|
|
65283
|
+
const canResetReplay = isStopped && !unconfirmedCleanup && !pendingOperations.size && (held4.unspawned === true || structured && !hadEffects && !record2.resumedFrom);
|
|
65284
|
+
const recovery = missingSession ? canResetReplay ? "replay" : "unsafe" : agentRecovery({
|
|
65285
|
+
stopped: isStopped,
|
|
65286
|
+
session,
|
|
65287
|
+
replayable: canResetReplay,
|
|
65288
|
+
unconfirmedCleanup
|
|
65289
|
+
});
|
|
65290
|
+
sessionAction = recovery === "unsafe" ? "pause_unsafe" : recovery === "replay" ? "reset_replay" : "resume";
|
|
65291
|
+
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
65292
|
+
const retryRecord = {
|
|
65293
|
+
attempt: attempt2,
|
|
65294
|
+
source: failure2.source,
|
|
65295
|
+
runtime: runtimeInfo(),
|
|
65296
|
+
summary: failure2.summary,
|
|
65297
|
+
...failure2.detail ? { detail: failure2.detail } : {},
|
|
65298
|
+
...failure2.code ? { code: failure2.code } : {},
|
|
65299
|
+
sessionAction,
|
|
65300
|
+
at: nowIso
|
|
65301
|
+
};
|
|
65302
|
+
retryHistory = [...retryHistory ?? [], retryRecord];
|
|
65303
|
+
if (recovery === "unsafe") {
|
|
65304
|
+
retryPause = "unsafe";
|
|
65305
|
+
} else {
|
|
65306
|
+
const decision = planRetry(failure2, attempt2, Date.now(), retryBackoff, !!held4.cloudExecution);
|
|
65307
|
+
if ("pause" in decision) {
|
|
65308
|
+
retryPause = decision.pause;
|
|
65309
|
+
} else {
|
|
65310
|
+
const pending = { ...decision.plan, sessionAction };
|
|
65060
65311
|
patch(sessionId, (r) => {
|
|
65061
65312
|
r.failure = failure2;
|
|
65062
|
-
r.error = said2 ?? failure2.
|
|
65063
|
-
r.
|
|
65313
|
+
r.error = said2 ?? failure2.summary;
|
|
65314
|
+
r.retryHistory = retryHistory;
|
|
65315
|
+
if (sessionAction === "reset_replay") {
|
|
65316
|
+
r.resumeId = void 0;
|
|
65317
|
+
r.unspawned = true;
|
|
65318
|
+
}
|
|
65319
|
+
r.retry = { attempt: attempt2, of: pending.of, reason: failure2.summary, at: pending.at, since: held4.retry?.since ?? held4.startedAt, pending };
|
|
65320
|
+
});
|
|
65321
|
+
event2({
|
|
65322
|
+
kind: "retry",
|
|
65323
|
+
data: {
|
|
65324
|
+
state: "waiting",
|
|
65325
|
+
source: failure2.source,
|
|
65326
|
+
runtime: runtimeInfo(),
|
|
65327
|
+
attempt: attempt2 + 1,
|
|
65328
|
+
maxAttempts: pending.of,
|
|
65329
|
+
summary: failure2.summary,
|
|
65330
|
+
...failure2.detail ? { detail: failure2.detail } : {},
|
|
65331
|
+
...failure2.code ? { code: failure2.code } : {},
|
|
65332
|
+
nextRetryAt: new Date(pending.at).toISOString(),
|
|
65333
|
+
sessionAction,
|
|
65334
|
+
at: nowIso
|
|
65335
|
+
}
|
|
65064
65336
|
});
|
|
65065
65337
|
log.write(`
|
|
65066
65338
|
[board] ${retryLine(pending, attempt2)}
|
|
@@ -65069,11 +65341,44 @@ async function watchRun(sessionId, resume = startResume, retryBackoff = backoffM
|
|
|
65069
65341
|
retrying = true;
|
|
65070
65342
|
}
|
|
65071
65343
|
}
|
|
65344
|
+
if (retryPause && !stoppedByUser()) {
|
|
65345
|
+
event2({
|
|
65346
|
+
kind: "retry",
|
|
65347
|
+
data: {
|
|
65348
|
+
state: "paused",
|
|
65349
|
+
source: failure2.source,
|
|
65350
|
+
runtime: runtimeInfo(),
|
|
65351
|
+
attempt: attempt2,
|
|
65352
|
+
maxAttempts: held4.retry?.of ?? MAX_RETRY_ATTEMPTS,
|
|
65353
|
+
summary: failure2.summary,
|
|
65354
|
+
...failure2.detail ? { detail: failure2.detail } : {},
|
|
65355
|
+
...failure2.code ? { code: failure2.code } : {},
|
|
65356
|
+
sessionAction,
|
|
65357
|
+
at: nowIso
|
|
65358
|
+
}
|
|
65359
|
+
});
|
|
65360
|
+
}
|
|
65072
65361
|
}
|
|
65073
65362
|
asked ||= stoppedByUser();
|
|
65074
65363
|
retrying &&= !asked;
|
|
65075
|
-
const error62 = asked ? void 0 : joinNotes(said2 ?? failure2?.
|
|
65364
|
+
const error62 = asked ? void 0 : joinNotes(said2 ?? failure2?.summary, retryPause ? pauseLine(retryPause) : void 0);
|
|
65076
65365
|
const status = asked ? "stopped" : failed2 || code !== 0 ? "error" : "done";
|
|
65366
|
+
if (status === "done" && !sub && retryHistory?.length) {
|
|
65367
|
+
const lastRetry = retryHistory[retryHistory.length - 1];
|
|
65368
|
+
event2({
|
|
65369
|
+
kind: "retry",
|
|
65370
|
+
data: {
|
|
65371
|
+
state: "recovered",
|
|
65372
|
+
source: lastRetry.source,
|
|
65373
|
+
runtime: runtimeInfo(),
|
|
65374
|
+
attempt: held4.retry?.attempt ?? retryHistory.length + 1,
|
|
65375
|
+
maxAttempts: held4.retry?.of ?? MAX_RETRY_ATTEMPTS,
|
|
65376
|
+
summary: lastRetry.summary,
|
|
65377
|
+
...lastRetry.code ? { code: lastRetry.code } : {},
|
|
65378
|
+
at: (/* @__PURE__ */ new Date()).toISOString()
|
|
65379
|
+
}
|
|
65380
|
+
});
|
|
65381
|
+
}
|
|
65077
65382
|
const reported = spoken ? spoken.costUsd : renderer?.costUsd?.();
|
|
65078
65383
|
const totals = reportsSessionTotal(record2.harness);
|
|
65079
65384
|
const sessionTotal = totals ? reported : void 0;
|
|
@@ -65136,6 +65441,7 @@ ${result}
|
|
|
65136
65441
|
error: error62,
|
|
65137
65442
|
failure: failure2,
|
|
65138
65443
|
retryPause,
|
|
65444
|
+
retryHistory,
|
|
65139
65445
|
note,
|
|
65140
65446
|
errorWhy,
|
|
65141
65447
|
noteWhy,
|
|
@@ -65328,6 +65634,7 @@ var init_watch = __esm({
|
|
|
65328
65634
|
init_idle();
|
|
65329
65635
|
init_codex_background_types();
|
|
65330
65636
|
init_retry();
|
|
65637
|
+
init_runtimes();
|
|
65331
65638
|
init_failures();
|
|
65332
65639
|
init_execution();
|
|
65333
65640
|
init_refine2();
|
|
@@ -65342,7 +65649,7 @@ var init_watch = __esm({
|
|
|
65342
65649
|
});
|
|
65343
65650
|
|
|
65344
65651
|
// ../cli/src/commands/run.ts
|
|
65345
|
-
import
|
|
65652
|
+
import fs83 from "node:fs";
|
|
65346
65653
|
import path82 from "node:path";
|
|
65347
65654
|
async function cmdStartRun(action, args2, opts, program2 = "akb") {
|
|
65348
65655
|
const { req, follow: follow2, print } = readRequest(action, args2, opts);
|
|
@@ -65569,7 +65876,7 @@ async function cmdSubStart(words, opts) {
|
|
|
65569
65876
|
let prompt = words.join(" ");
|
|
65570
65877
|
if (opts.file) {
|
|
65571
65878
|
try {
|
|
65572
|
-
prompt =
|
|
65879
|
+
prompt = fs83.readFileSync(path82.resolve(opts.file), "utf8");
|
|
65573
65880
|
} catch {
|
|
65574
65881
|
die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
|
|
65575
65882
|
}
|
|
@@ -65918,12 +66225,12 @@ var init_config3 = __esm({
|
|
|
65918
66225
|
});
|
|
65919
66226
|
|
|
65920
66227
|
// ../cli/src/lib/signals/migrate.ts
|
|
65921
|
-
import
|
|
66228
|
+
import fs84 from "node:fs";
|
|
65922
66229
|
import path83 from "node:path";
|
|
65923
66230
|
function readHandled() {
|
|
65924
66231
|
let text5;
|
|
65925
66232
|
try {
|
|
65926
|
-
text5 =
|
|
66233
|
+
text5 = fs84.readFileSync(SIGNALS_OLD_HANDLED, "utf8");
|
|
65927
66234
|
} catch {
|
|
65928
66235
|
return [];
|
|
65929
66236
|
}
|
|
@@ -65940,45 +66247,45 @@ function readHandled() {
|
|
|
65940
66247
|
return held4;
|
|
65941
66248
|
}
|
|
65942
66249
|
function lift(from, into) {
|
|
65943
|
-
|
|
65944
|
-
|
|
66250
|
+
fs84.mkdirSync(into, { recursive: true });
|
|
66251
|
+
fs84.renameSync(from, path83.join(into, freeName(into, path83.basename(from))));
|
|
65945
66252
|
}
|
|
65946
66253
|
function repoint(dir, from, into) {
|
|
65947
66254
|
let entries2;
|
|
65948
66255
|
try {
|
|
65949
|
-
entries2 =
|
|
66256
|
+
entries2 = fs84.readdirSync(dir, { withFileTypes: true });
|
|
65950
66257
|
} catch {
|
|
65951
66258
|
return;
|
|
65952
66259
|
}
|
|
65953
66260
|
for (const entry of entries2) {
|
|
65954
66261
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
65955
66262
|
const file2 = path83.join(dir, entry.name);
|
|
65956
|
-
const text5 =
|
|
65957
|
-
if (text5.includes(from))
|
|
66263
|
+
const text5 = fs84.readFileSync(file2, "utf8");
|
|
66264
|
+
if (text5.includes(from)) fs84.writeFileSync(file2, text5.split(from).join(into));
|
|
65958
66265
|
}
|
|
65959
66266
|
}
|
|
65960
66267
|
function dropIfEmpty(dir) {
|
|
65961
66268
|
try {
|
|
65962
|
-
|
|
66269
|
+
fs84.rmdirSync(dir);
|
|
65963
66270
|
} catch {
|
|
65964
66271
|
}
|
|
65965
66272
|
}
|
|
65966
66273
|
function liftInbox() {
|
|
65967
|
-
if (!
|
|
66274
|
+
if (!fs84.existsSync(SIGNALS_OLD_INBOX)) return;
|
|
65968
66275
|
const oldFiles = path83.join(SIGNALS_OLD_INBOX, "files");
|
|
65969
|
-
if (
|
|
65970
|
-
for (const entry of
|
|
66276
|
+
if (fs84.existsSync(oldFiles)) {
|
|
66277
|
+
for (const entry of fs84.readdirSync(oldFiles, { withFileTypes: true })) {
|
|
65971
66278
|
if (entry.isFile()) lift(path83.join(oldFiles, entry.name), SIGNALS_FILES);
|
|
65972
66279
|
}
|
|
65973
66280
|
dropIfEmpty(oldFiles);
|
|
65974
66281
|
}
|
|
65975
66282
|
const held4 = new Set(readFolder(TRIAGE).map((signal2) => signal2.sourceId));
|
|
65976
|
-
for (const entry of
|
|
66283
|
+
for (const entry of fs84.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
|
|
65977
66284
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
65978
66285
|
const from = path83.join(SIGNALS_OLD_INBOX, entry.name);
|
|
65979
66286
|
const item = parse3(from);
|
|
65980
66287
|
if (item && held4.has(item.sourceId)) {
|
|
65981
|
-
|
|
66288
|
+
fs84.rmSync(from, { force: true });
|
|
65982
66289
|
continue;
|
|
65983
66290
|
}
|
|
65984
66291
|
if (item) held4.add(item.sourceId);
|
|
@@ -65990,7 +66297,7 @@ function liftInbox() {
|
|
|
65990
66297
|
dropIfEmpty(SIGNALS_OLD_INBOX);
|
|
65991
66298
|
}
|
|
65992
66299
|
function liftHandled() {
|
|
65993
|
-
if (!
|
|
66300
|
+
if (!fs84.existsSync(SIGNALS_OLD_HANDLED)) return;
|
|
65994
66301
|
const lines = readHandled();
|
|
65995
66302
|
const held4 = /* @__PURE__ */ new Set([
|
|
65996
66303
|
...readFolder(TRIAGE).map((signal2) => signal2.sourceId),
|
|
@@ -66000,7 +66307,7 @@ function liftHandled() {
|
|
|
66000
66307
|
for (const { sourceId, when } of lines) {
|
|
66001
66308
|
if (held4.has(sourceId)) continue;
|
|
66002
66309
|
held4.add(sourceId);
|
|
66003
|
-
|
|
66310
|
+
fs84.mkdirSync(SIGNALS_DISMISSED, { recursive: true });
|
|
66004
66311
|
const name = freeName(SIGNALS_DISMISSED, fileName("", sourceId));
|
|
66005
66312
|
const front = [
|
|
66006
66313
|
"---",
|
|
@@ -66010,13 +66317,13 @@ function liftHandled() {
|
|
|
66010
66317
|
"---",
|
|
66011
66318
|
""
|
|
66012
66319
|
];
|
|
66013
|
-
|
|
66320
|
+
fs84.writeFileSync(path83.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
|
|
66014
66321
|
`);
|
|
66015
66322
|
}
|
|
66016
|
-
|
|
66323
|
+
fs84.rmSync(SIGNALS_OLD_HANDLED, { force: true });
|
|
66017
66324
|
}
|
|
66018
66325
|
function migrateTriage() {
|
|
66019
|
-
if (!
|
|
66326
|
+
if (!fs84.existsSync(SIGNALS_OLD_INBOX) && !fs84.existsSync(SIGNALS_OLD_HANDLED)) return;
|
|
66020
66327
|
try {
|
|
66021
66328
|
liftInbox();
|
|
66022
66329
|
liftHandled();
|
|
@@ -66084,7 +66391,7 @@ var init_identity2 = __esm({
|
|
|
66084
66391
|
});
|
|
66085
66392
|
|
|
66086
66393
|
// ../cli/src/lib/signals/add.ts
|
|
66087
|
-
import
|
|
66394
|
+
import fs85 from "node:fs";
|
|
66088
66395
|
import path84 from "node:path";
|
|
66089
66396
|
import { createHash as createHash8 } from "node:crypto";
|
|
66090
66397
|
function linkTitle(url2) {
|
|
@@ -66143,8 +66450,8 @@ ${incoming.summary}`);
|
|
|
66143
66450
|
if (seen.status === "pending" || seen.status === "archived") return { ok: false, error: `${sayHit(seen)}.` };
|
|
66144
66451
|
try {
|
|
66145
66452
|
if (keep2) {
|
|
66146
|
-
|
|
66147
|
-
|
|
66453
|
+
fs85.mkdirSync(SIGNALS_FILES, { recursive: true });
|
|
66454
|
+
fs85.writeFileSync(keep2.at, keep2.data);
|
|
66148
66455
|
}
|
|
66149
66456
|
return { ok: true, signal: writeSignal({ ...incoming, sourceId }, formatStamp(/* @__PURE__ */ new Date()), drop.slug) };
|
|
66150
66457
|
} catch (e) {
|
|
@@ -66255,7 +66562,7 @@ var init_signals = __esm({
|
|
|
66255
66562
|
});
|
|
66256
66563
|
|
|
66257
66564
|
// ../cli/src/commands/triage.ts
|
|
66258
|
-
import
|
|
66565
|
+
import fs86 from "node:fs";
|
|
66259
66566
|
async function cmdTriageAdd(opts) {
|
|
66260
66567
|
const title = (opts.title ?? "").trim();
|
|
66261
66568
|
if (!title) die('say what it is: --title "<one line>"', { kind: "needs-input" });
|
|
@@ -66265,7 +66572,7 @@ async function cmdTriageAdd(opts) {
|
|
|
66265
66572
|
let body = opts.text;
|
|
66266
66573
|
if (opts.file !== void 0) {
|
|
66267
66574
|
try {
|
|
66268
|
-
body =
|
|
66575
|
+
body = fs86.readFileSync(opts.file, "utf8");
|
|
66269
66576
|
} catch {
|
|
66270
66577
|
die(`can't read ${opts.file} \u2014 write the item to a file, then pass its path`, { kind: "needs-input" });
|
|
66271
66578
|
}
|
|
@@ -66319,21 +66626,21 @@ var init_previews = __esm({
|
|
|
66319
66626
|
});
|
|
66320
66627
|
|
|
66321
66628
|
// ../cli/src/commands/studio-preview.ts
|
|
66322
|
-
import
|
|
66629
|
+
import fs87 from "node:fs";
|
|
66323
66630
|
import path85 from "node:path";
|
|
66324
66631
|
import { createHash as createHash9, randomUUID as randomUUID9 } from "node:crypto";
|
|
66325
66632
|
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
66326
66633
|
function readFolder2(folder2, baseline = false) {
|
|
66327
|
-
const root2 =
|
|
66634
|
+
const root2 = fs87.realpathSync(folder2);
|
|
66328
66635
|
let count3 = 0, total = 0;
|
|
66329
66636
|
const scan = (dir) => {
|
|
66330
|
-
for (const e of
|
|
66637
|
+
for (const e of fs87.readdirSync(dir, { withFileTypes: true })) {
|
|
66331
66638
|
if (e.name.startsWith(".")) continue;
|
|
66332
66639
|
const file2 = path85.join(dir, e.name);
|
|
66333
66640
|
if (e.isSymbolicLink()) throw Error(`${file2}: symbolic links are not allowed`);
|
|
66334
66641
|
if (e.isDirectory()) scan(file2);
|
|
66335
66642
|
else {
|
|
66336
|
-
const size =
|
|
66643
|
+
const size = fs87.statSync(file2).size;
|
|
66337
66644
|
total += size;
|
|
66338
66645
|
if (++count3 > FILE_LIMITS.count || size > FILE_LIMITS.file || total > FILE_LIMITS.total) throw Error(`${file2}: Studio file limit exceeded`);
|
|
66339
66646
|
}
|
|
@@ -66347,8 +66654,8 @@ function readFolder2(folder2, baseline = false) {
|
|
|
66347
66654
|
}
|
|
66348
66655
|
function unified(before, after2, file2, folder2) {
|
|
66349
66656
|
const a = path85.join(folder2, "a"), b = path85.join(folder2, "b");
|
|
66350
|
-
|
|
66351
|
-
|
|
66657
|
+
fs87.writeFileSync(a, before ?? "");
|
|
66658
|
+
fs87.writeFileSync(b, after2 ?? "");
|
|
66352
66659
|
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
66660
|
if (result.error || result.status !== 0 && result.status !== 1) throw Error(`${file2}: ${result.error?.message ?? result.stderr}`);
|
|
66354
66661
|
const lines = result.stdout.split("\n"), start = lines.findIndex((l) => l.startsWith("--- "));
|
|
@@ -66364,12 +66671,12 @@ async function cmdStudioPreview(id2, opts) {
|
|
|
66364
66671
|
const draft = readFolder2(path85.resolve(opts.folder)), base = opts.base === "empty" ? null : readFolder2(path85.resolve(opts.base), true);
|
|
66365
66672
|
const version2 = readVersion2(draft.files), baseVersion = base && readVersion2(base.files);
|
|
66366
66673
|
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
|
-
|
|
66674
|
+
fs87.mkdirSync(staging, { recursive: true });
|
|
66368
66675
|
const review = { version: 2, base: base && baseVersion ? { ...baseVersion, fingerprint: base.fingerprint } : null, fingerprint: draft.fingerprint, files: [] };
|
|
66369
66676
|
const save3 = (file2, bytes2) => {
|
|
66370
66677
|
const target = path85.join(staging, file2);
|
|
66371
|
-
|
|
66372
|
-
|
|
66678
|
+
fs87.mkdirSync(path85.dirname(target), { recursive: true });
|
|
66679
|
+
fs87.writeFileSync(target, bytes2);
|
|
66373
66680
|
return file2;
|
|
66374
66681
|
};
|
|
66375
66682
|
const paths = [.../* @__PURE__ */ new Set([...Object.keys(base?.files ?? {}), ...Object.keys(draft.files)])].filter((p) => p !== VERSION_FILE).sort();
|
|
@@ -66377,16 +66684,16 @@ async function cmdStudioPreview(id2, opts) {
|
|
|
66377
66684
|
const before = base?.files[file2] ?? null, after2 = draft.files[file2] ?? null;
|
|
66378
66685
|
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
66686
|
}
|
|
66380
|
-
for (const p of ["a", "b"])
|
|
66687
|
+
for (const p of ["a", "b"]) fs87.rmSync(path85.join(staging, p), { force: true });
|
|
66381
66688
|
if (!parseReview(review)) throw Error("generated review is invalid");
|
|
66382
66689
|
save3("review.json", JSON.stringify(review, null, 2) + "\n");
|
|
66383
|
-
|
|
66384
|
-
if (
|
|
66385
|
-
|
|
66690
|
+
fs87.mkdirSync(path85.dirname(destination), { recursive: true });
|
|
66691
|
+
if (fs87.existsSync(destination)) {
|
|
66692
|
+
fs87.renameSync(destination, backup);
|
|
66386
66693
|
moved = true;
|
|
66387
66694
|
}
|
|
66388
|
-
|
|
66389
|
-
|
|
66695
|
+
fs87.renameSync(staging, destination);
|
|
66696
|
+
fs87.rmSync(backup, { recursive: true, force: true });
|
|
66390
66697
|
const tag = `<Studio src=".assets/${id2}/studio-review/review.json" />`;
|
|
66391
66698
|
const prefix = `.assets/${id2}/studio-review/`;
|
|
66392
66699
|
const attachments = review.files.filter((f) => f.path !== "STUDIO.md" && f.diff);
|
|
@@ -66400,11 +66707,11 @@ ${items}
|
|
|
66400
66707
|
say([tag, files].filter(Boolean).join("\n\n"));
|
|
66401
66708
|
return { file: path85.join(destination, "review.json"), tag, files };
|
|
66402
66709
|
} catch (error62) {
|
|
66403
|
-
if (moved && !
|
|
66710
|
+
if (moved && !fs87.existsSync(destination)) fs87.renameSync(backup, destination);
|
|
66404
66711
|
if (error62 && typeof error62 === "object" && "kind" in error62) throw error62;
|
|
66405
66712
|
die(error62 instanceof Error ? error62.message : String(error62), "bad-args");
|
|
66406
66713
|
} finally {
|
|
66407
|
-
|
|
66714
|
+
fs87.rmSync(staging, { recursive: true, force: true });
|
|
66408
66715
|
}
|
|
66409
66716
|
}
|
|
66410
66717
|
var readVersion2;
|
|
@@ -66989,14 +67296,14 @@ Review examples
|
|
|
66989
67296
|
});
|
|
66990
67297
|
|
|
66991
67298
|
// ../cli/src/kanban.ts
|
|
66992
|
-
import
|
|
67299
|
+
import fs90 from "node:fs";
|
|
66993
67300
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
66994
67301
|
|
|
66995
67302
|
// ../cli/src/lib/cli/akb.ts
|
|
66996
67303
|
init_agent2();
|
|
66997
67304
|
|
|
66998
67305
|
// ../cli/src/lib/cli/setup.ts
|
|
66999
|
-
import
|
|
67306
|
+
import fs89 from "node:fs";
|
|
67000
67307
|
import path87 from "node:path";
|
|
67001
67308
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
67002
67309
|
|
|
@@ -67005,7 +67312,7 @@ init_board_cli();
|
|
|
67005
67312
|
init_config_template();
|
|
67006
67313
|
init_io();
|
|
67007
67314
|
init_version();
|
|
67008
|
-
import
|
|
67315
|
+
import fs88 from "node:fs";
|
|
67009
67316
|
import path86 from "node:path";
|
|
67010
67317
|
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
67011
67318
|
var NAME = "wildcrane";
|
|
@@ -67027,7 +67334,7 @@ var Report = class {
|
|
|
67027
67334
|
for (const line of this.notes) say(` ! ${line}`);
|
|
67028
67335
|
}
|
|
67029
67336
|
};
|
|
67030
|
-
var read4 = (file2) =>
|
|
67337
|
+
var read4 = (file2) => fs88.existsSync(file2) ? fs88.readFileSync(file2, "utf8") : null;
|
|
67031
67338
|
async function boardMove(root2, args2, board2) {
|
|
67032
67339
|
const where = board2 ? ["--board", board2] : ["--dir", root2];
|
|
67033
67340
|
const code = await runBoard([...args2, ...where], { program: "akb raw", cwd: root2 });
|
|
@@ -67050,8 +67357,8 @@ async function cmdUpdate2(ctx) {
|
|
|
67050
67357
|
async function repairBoard(root2, report3, named2) {
|
|
67051
67358
|
const legacy = path86.join(root2, "docs", "kanban");
|
|
67052
67359
|
const kept2 = path86.join(root2, ".akb", "kanban");
|
|
67053
|
-
const board2 = named2 ?? (
|
|
67054
|
-
if (!
|
|
67360
|
+
const board2 = named2 ?? (fs88.existsSync(legacy) ? legacy : kept2);
|
|
67361
|
+
if (!fs88.existsSync(board2)) {
|
|
67055
67362
|
report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
|
|
67056
67363
|
return false;
|
|
67057
67364
|
}
|
|
@@ -67127,7 +67434,7 @@ function declareSetup(program2, cli) {
|
|
|
67127
67434
|
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
67435
|
const where = (cmd) => {
|
|
67129
67436
|
const dir = path87.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
|
|
67130
|
-
if (!
|
|
67437
|
+
if (!fs89.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
|
|
67131
67438
|
return dir;
|
|
67132
67439
|
};
|
|
67133
67440
|
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 +67485,7 @@ function invokedDirectly() {
|
|
|
67178
67485
|
const entry = process.argv[1];
|
|
67179
67486
|
if (!entry) return false;
|
|
67180
67487
|
try {
|
|
67181
|
-
return
|
|
67488
|
+
return fs90.realpathSync(entry) === fs90.realpathSync(SELF2);
|
|
67182
67489
|
} catch {
|
|
67183
67490
|
return false;
|
|
67184
67491
|
}
|