wildcrane 0.11.70 → 0.11.71
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/kanban.mjs +763 -658
- package/package.json +1 -1
package/dist/kanban.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// ai4kanban 0.11.
|
|
2
|
+
// ai4kanban 0.11.71 — built from the CLI's TypeScript sources by cli/scripts/build.mjs.
|
|
3
3
|
// Do not edit: every change belongs in cli/src/, and a build overwrites this file.
|
|
4
4
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
5
5
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
@@ -2118,6 +2118,61 @@ var init_types = __esm({
|
|
|
2118
2118
|
}
|
|
2119
2119
|
});
|
|
2120
2120
|
|
|
2121
|
+
// src/lib/agent/harnesses/transient.ts
|
|
2122
|
+
function reasonLine(text6, rule) {
|
|
2123
|
+
const line = text6.split("\n").find((l2) => rule.test(l2.toLowerCase())) ?? text6;
|
|
2124
|
+
const said2 = line.trim().replace(/\s+/g, " ");
|
|
2125
|
+
return said2.length > REASON_MAX ? `${said2.slice(0, REASON_MAX - 1)}\u2026` : said2;
|
|
2126
|
+
}
|
|
2127
|
+
function manualFailure(text6) {
|
|
2128
|
+
return MANUAL.some((rule) => rule.test(text6.toLowerCase()));
|
|
2129
|
+
}
|
|
2130
|
+
function providerBlip(...said2) {
|
|
2131
|
+
for (const text6 of said2) {
|
|
2132
|
+
if (!text6?.trim()) continue;
|
|
2133
|
+
const lower = text6.toLowerCase();
|
|
2134
|
+
if (manualFailure(text6)) return void 0;
|
|
2135
|
+
const hit = PASSING.find((rule) => rule.test(lower));
|
|
2136
|
+
if (!hit) continue;
|
|
2137
|
+
const asked = RETRY_AFTER.exec(text6);
|
|
2138
|
+
const seconds = asked ? Number(asked[1]) : NaN;
|
|
2139
|
+
return {
|
|
2140
|
+
reason: reasonLine(text6, hit),
|
|
2141
|
+
...Number.isFinite(seconds) && seconds > 0 ? { retryAfterMs: seconds * 1e3 } : {}
|
|
2142
|
+
};
|
|
2143
|
+
}
|
|
2144
|
+
return void 0;
|
|
2145
|
+
}
|
|
2146
|
+
var MANUAL, PASSING, RETRY_AFTER, REASON_MAX;
|
|
2147
|
+
var init_transient = __esm({
|
|
2148
|
+
"src/lib/agent/harnesses/transient.ts"() {
|
|
2149
|
+
"use strict";
|
|
2150
|
+
MANUAL = [
|
|
2151
|
+
/\b(401|403)\b/,
|
|
2152
|
+
/unauthorized|forbidden|permission (?:denied|required|check failed)|permission_denied|soft.denied|auto-denied|权限拒绝/,
|
|
2153
|
+
/authenticat|invalid api key|api[_ ]key|not (?:logged|signed) in|please (?:log|sign) in|\/login|oauth/,
|
|
2154
|
+
/\b429\b/,
|
|
2155
|
+
/rate[ _-]?limit|usage limit|quota|credits?|insufficient|out of tokens|resource[ _-]?exhausted/,
|
|
2156
|
+
/cancell?ed|aborted by|interrupted by the user/,
|
|
2157
|
+
/maximum budget|max(imum)? turns|exceeded the budget/,
|
|
2158
|
+
/model not found|unknown model|invalid model|model (?:is )?unavailable|model[^\n]+ is (?:unavailable|not recognized)|unsupported|invalid[_ ]request/
|
|
2159
|
+
];
|
|
2160
|
+
PASSING = [
|
|
2161
|
+
// 502/503/529 are distinctive enough to read as a status wherever they appear. A bare
|
|
2162
|
+
// 500 is not — a failure line counting something would match it — so it is left to the
|
|
2163
|
+
// words below, which is how that status is actually written out.
|
|
2164
|
+
/\b(502|503|529)\b/,
|
|
2165
|
+
/overloaded|service unavailable|bad gateway|internal server error|server_error/,
|
|
2166
|
+
/connection (lost|dropped|reset|error|closed)|socket hang up|stream (error|disconnected)/,
|
|
2167
|
+
/econnreset|econnrefused|etimedout|enetunreach|enotfound|eai_again/,
|
|
2168
|
+
/fetch failed|request timed out|network error/,
|
|
2169
|
+
/rpc error: code = (?:unavailable|deadlineexceeded)\b|deadline_exceeded|dial tcp[^\n]*(?:timeout|refused|no such host)/
|
|
2170
|
+
];
|
|
2171
|
+
RETRY_AFTER = /retry[-_\s]?after["':=\s]+(\d+)/i;
|
|
2172
|
+
REASON_MAX = 140;
|
|
2173
|
+
}
|
|
2174
|
+
});
|
|
2175
|
+
|
|
2121
2176
|
// src/lib/machine/types.ts
|
|
2122
2177
|
function isLanguage(value) {
|
|
2123
2178
|
return typeof value === "string" && LANGUAGES.includes(value);
|
|
@@ -2202,6 +2257,61 @@ var init_language = __esm({
|
|
|
2202
2257
|
}
|
|
2203
2258
|
});
|
|
2204
2259
|
|
|
2260
|
+
// src/lib/agent/prices.ts
|
|
2261
|
+
function antigravityPrices(at2) {
|
|
2262
|
+
const pro = at2 < Date.parse("2026-12-01T00:00:00Z") ? 2 : 4;
|
|
2263
|
+
const flash = at2 < Date.parse("2027-01-01T00:00:00Z") ? 0.75 : 1.5;
|
|
2264
|
+
return {
|
|
2265
|
+
"gemini-4-carbon": { input: pro, cachedInput: pro / 20, output: pro * 5 },
|
|
2266
|
+
"gemini-4-argon": { input: pro, cachedInput: pro / 20, output: pro * 5 },
|
|
2267
|
+
"gemini-4-hydrogen": { input: 1.5, cachedInput: 0.075, output: 7.5 },
|
|
2268
|
+
"gemini-3.8-flash": { input: flash, cachedInput: flash / 10, output: flash * 5 }
|
|
2269
|
+
};
|
|
2270
|
+
}
|
|
2271
|
+
function lookUp(table, model) {
|
|
2272
|
+
const id = model.trim().toLowerCase().replace(/^[^/]+\//, "");
|
|
2273
|
+
return table[id] ?? table[id.replace(/-\d{4}-\d{2}-\d{2}$/, "")];
|
|
2274
|
+
}
|
|
2275
|
+
function priceUsd(provider, model, usage3, at2 = Date.now()) {
|
|
2276
|
+
if (!provider || !model || !usage3) return void 0;
|
|
2277
|
+
const agy = provider.trim().toLowerCase() === "antigravity";
|
|
2278
|
+
const table = agy ? antigravityPrices(at2) : PRICES[provider.trim().toLowerCase()];
|
|
2279
|
+
const price = table && (agy ? table[model.trim().toLowerCase().replace(/-(?:low|medium|high|xhigh|max)$/, "")] : lookUp(table, model));
|
|
2280
|
+
if (!price) return void 0;
|
|
2281
|
+
const usd = ((usage3.input + usage3.cacheCreation) * price.input + usage3.cacheRead * price.cachedInput + usage3.output * price.output) / 1e6;
|
|
2282
|
+
return Number.isFinite(usd) && usd >= 0 ? usd : void 0;
|
|
2283
|
+
}
|
|
2284
|
+
var OPENAI, PRICES;
|
|
2285
|
+
var init_prices = __esm({
|
|
2286
|
+
"src/lib/agent/prices.ts"() {
|
|
2287
|
+
"use strict";
|
|
2288
|
+
OPENAI = {
|
|
2289
|
+
"gpt-6.1-sol": { input: 2, cachedInput: 0.1, output: 10 },
|
|
2290
|
+
"gpt-6-astra": { input: 10, cachedInput: 1, output: 50 },
|
|
2291
|
+
"gpt-6-sol": { input: 2, cachedInput: 0.2, output: 10 },
|
|
2292
|
+
"gpt-6-luna": { input: 0.1, cachedInput: 0.01, output: 0.5 },
|
|
2293
|
+
"gpt-5.6-sol": { input: 4, cachedInput: 0.4, output: 20 },
|
|
2294
|
+
"gpt-5.6-terra": { input: 2, cachedInput: 0.2, output: 12 },
|
|
2295
|
+
"gpt-5.6-luna": { input: 0.2, cachedInput: 0.02, output: 1.2 },
|
|
2296
|
+
"gpt-5.5": { input: 5, cachedInput: 0.5, output: 30 },
|
|
2297
|
+
"gpt-5.5-pro": { input: 30, cachedInput: 30, output: 180 },
|
|
2298
|
+
"gpt-5.4": { input: 2.5, cachedInput: 0.25, output: 15 },
|
|
2299
|
+
"gpt-5.4-mini": { input: 0.75, cachedInput: 0.075, output: 4.5 },
|
|
2300
|
+
"gpt-5.4-nano": { input: 0.2, cachedInput: 0.02, output: 1.25 },
|
|
2301
|
+
"gpt-5.4-pro": { input: 30, cachedInput: 30, output: 180 },
|
|
2302
|
+
"gpt-5.3-codex": { input: 1.75, cachedInput: 0.175, output: 14 },
|
|
2303
|
+
"gpt-5.2": { input: 1.75, cachedInput: 0.175, output: 14 },
|
|
2304
|
+
"gpt-5.2-pro": { input: 21, cachedInput: 21, output: 168 },
|
|
2305
|
+
"gpt-5.1": { input: 1.25, cachedInput: 0.125, output: 10 },
|
|
2306
|
+
"gpt-5": { input: 1.25, cachedInput: 0.125, output: 10 },
|
|
2307
|
+
"gpt-5-mini": { input: 0.25, cachedInput: 0.025, output: 2 },
|
|
2308
|
+
"gpt-5-nano": { input: 0.05, cachedInput: 5e-3, output: 0.4 },
|
|
2309
|
+
"gpt-5-pro": { input: 15, cachedInput: 15, output: 120 }
|
|
2310
|
+
};
|
|
2311
|
+
PRICES = { openai: OPENAI, "openai-api": OPENAI };
|
|
2312
|
+
}
|
|
2313
|
+
});
|
|
2314
|
+
|
|
2205
2315
|
// src/lib/agent/wire/json.ts
|
|
2206
2316
|
function obj2(value) {
|
|
2207
2317
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
@@ -2448,20 +2558,44 @@ var init_stream = __esm({
|
|
|
2448
2558
|
});
|
|
2449
2559
|
|
|
2450
2560
|
// src/lib/agent/wire/antigravity.ts
|
|
2561
|
+
import path14 from "node:path";
|
|
2451
2562
|
function failureHint(reason) {
|
|
2452
2563
|
const zh = translating();
|
|
2453
2564
|
const hint2 = /authentication (?:required|failed)|not (?:logged|signed) in|unauthenticated|unauthorized|invalid credentials/i.test(reason) ? zh ? "\u8BF7\u5728\u672C\u673A\u8FD0\u884C agy \u767B\u5F55\u540E\u91CD\u8BD5\u3002" : "Run agy on this computer to sign in, then retry." : /invalid model|model.*(?:unavailable|not found|not recognized)/i.test(reason) ? zh ? "\u8BF7\u8FD0\u884C agy models\uFF0C\u9009\u62E9\u53EF\u7528\u6A21\u578B\u540E\u91CD\u8BD5\u3002" : "Run agy models and choose an available model, then retry." : /quota|rate.?limit|resource.exhausted|credits|429/i.test(reason) ? zh ? "\u8BF7\u7B49\u5F85\u989D\u5EA6\u6062\u590D\uFF0C\u6216\u68C0\u67E5 Antigravity \u8D26\u53F7\u989D\u5EA6\u540E\u91CD\u8BD5\u3002" : "Wait for the limit to reset or check your Antigravity credits, then retry." : /network|connection|unavailable|deadline|timeout|timed out|dial tcp|DNS|502|503/i.test(reason) ? zh ? "\u8BF7\u68C0\u67E5\u7F51\u7EDC\u8FDE\u63A5\u540E\u91CD\u8BD5\u3002" : "Check the network connection, then retry." : /permission|denied|soft.den/i.test(reason) ? zh ? "\u8BF7\u68C0\u67E5 Antigravity \u7684\u6743\u9650\u89C4\u5219\u540E\u91CD\u8BD5\u3002" : "Check Antigravity permission rules, then retry." : "";
|
|
2454
2565
|
return hint2 ? `${reason}
|
|
2455
2566
|
${hint2}` : reason;
|
|
2456
2567
|
}
|
|
2457
|
-
function createAntigravityRenderer(expectedSession) {
|
|
2568
|
+
function createAntigravityRenderer(expectedSession, cwd = process.cwd()) {
|
|
2458
2569
|
let session = expectedSession;
|
|
2459
2570
|
let model;
|
|
2571
|
+
let partial = "";
|
|
2460
2572
|
let final;
|
|
2461
2573
|
let failure;
|
|
2574
|
+
let rateLimit;
|
|
2575
|
+
let imageFailure;
|
|
2576
|
+
let requiredImages = [];
|
|
2577
|
+
const readImages = /* @__PURE__ */ new Set();
|
|
2578
|
+
const imageErrors = /* @__PURE__ */ new Map();
|
|
2579
|
+
const imageError = (target, reason) => translating() ? `Antigravity \u65E0\u6CD5\u8BFB\u53D6\u56FE\u7247 ${target}\uFF1A${reason}` : `Antigravity could not read image ${target}: ${reason}`;
|
|
2462
2580
|
let terminal = false;
|
|
2463
2581
|
let offStream;
|
|
2464
2582
|
let stderr = "";
|
|
2583
|
+
let context;
|
|
2584
|
+
let contextStep = -1;
|
|
2585
|
+
const started = Date.now();
|
|
2586
|
+
let cost;
|
|
2587
|
+
let incomplete = false;
|
|
2588
|
+
const priced = /* @__PURE__ */ new Set();
|
|
2589
|
+
const countCost = (step) => {
|
|
2590
|
+
const index = step.step_index;
|
|
2591
|
+
if (typeof index !== "number" || !Number.isSafeInteger(index) || index < 0 || priced.has(index)) return;
|
|
2592
|
+
priced.add(index);
|
|
2593
|
+
const u2 = obj2(step.usage);
|
|
2594
|
+
const valid = [u2.input_tokens, u2.output_tokens, u2.cache_read_tokens].every((n) => typeof n === "number" && Number.isFinite(n) && n >= 0);
|
|
2595
|
+
const usd = valid ? priceUsd("antigravity", model, usageOf(u2), started) : void 0;
|
|
2596
|
+
if (usd === void 0) incomplete = true;
|
|
2597
|
+
else cost = (cost ?? 0) + usd;
|
|
2598
|
+
};
|
|
2465
2599
|
let used;
|
|
2466
2600
|
let turnUsage = zero();
|
|
2467
2601
|
let previous;
|
|
@@ -2470,6 +2604,8 @@ function createAntigravityRenderer(expectedSession) {
|
|
|
2470
2604
|
const closed2 = /* @__PURE__ */ new Set();
|
|
2471
2605
|
const events = createEventCollector();
|
|
2472
2606
|
const fail = (reason) => {
|
|
2607
|
+
if (limited(reason)) rateLimit = failureHint(reason);
|
|
2608
|
+
if (failure && manualFailure(failure) && !(limited(failure) && limited(reason))) return;
|
|
2473
2609
|
failure = failureHint(reason);
|
|
2474
2610
|
events.error(failure);
|
|
2475
2611
|
};
|
|
@@ -2477,6 +2613,7 @@ function createAntigravityRenderer(expectedSession) {
|
|
|
2477
2613
|
const e2 = frame(line);
|
|
2478
2614
|
if (!e2) {
|
|
2479
2615
|
offStream = line.trim() || offStream;
|
|
2616
|
+
if (/^(?:error:|rpc error:)/i.test(line.trim()) && limited(line)) fail(line.trim());
|
|
2480
2617
|
return `${line}
|
|
2481
2618
|
`;
|
|
2482
2619
|
}
|
|
@@ -2495,10 +2632,19 @@ function createAntigravityRenderer(expectedSession) {
|
|
|
2495
2632
|
if (expectedSession && str2(step.conversation_id) !== expectedSession) return "";
|
|
2496
2633
|
session = str2(step.conversation_id) || session;
|
|
2497
2634
|
const id = String(step.step_index ?? "");
|
|
2635
|
+
if (step.state === "DONE" && ["agent_response", "checkpoint"].includes(str2(step.step_type))) countCost(step);
|
|
2498
2636
|
if (step.step_type === "agent_response") {
|
|
2499
2637
|
const text6 = str2(step.text_delta);
|
|
2638
|
+
partial += text6;
|
|
2500
2639
|
if (text6) events.update({ sessionUpdate: "agent_message_chunk", content: { text: text6 } });
|
|
2501
2640
|
const index = num2(step.step_index);
|
|
2641
|
+
if (step.state === "DONE" && Number.isSafeInteger(index) && step.step_index === index && index > contextStep) {
|
|
2642
|
+
contextStep = index;
|
|
2643
|
+
const u2 = obj2(step.usage);
|
|
2644
|
+
const counts = [u2.input_tokens, u2.cache_read_tokens];
|
|
2645
|
+
const prompt = counts.every((n) => typeof n === "number" && Number.isFinite(n) && n >= 0) ? num2(u2.input_tokens) + num2(u2.cache_read_tokens) : 0;
|
|
2646
|
+
context = prompt > 0 && Number.isFinite(prompt) ? { used: prompt } : void 0;
|
|
2647
|
+
}
|
|
2502
2648
|
if (step.state === "DONE" && step.usage && !counted.has(index)) {
|
|
2503
2649
|
counted.add(index);
|
|
2504
2650
|
turnUsage = add(turnUsage, usageOf(step.usage));
|
|
@@ -2524,7 +2670,20 @@ function createAntigravityRenderer(expectedSession) {
|
|
|
2524
2670
|
if (reason && /permission|denied|soft.den/i.test(reason)) fail(reason);
|
|
2525
2671
|
if (["DONE", "ERROR", "CANCELED", "INTERRUPTED"].includes(str2(step.state)) && !closed2.has(id)) {
|
|
2526
2672
|
closed2.add(id);
|
|
2527
|
-
|
|
2673
|
+
const failed2 = !!reason || step.state !== "DONE";
|
|
2674
|
+
if (["read_file", "view_file"].includes(name) && imagePath(target)) {
|
|
2675
|
+
const file2 = path14.resolve(cwd, target);
|
|
2676
|
+
if (failed2) {
|
|
2677
|
+
imageErrors.set(file2, reason || str2(step.state));
|
|
2678
|
+
out += `
|
|
2679
|
+
${imageError(target, reason || str2(step.state))}
|
|
2680
|
+
`;
|
|
2681
|
+
} else {
|
|
2682
|
+
readImages.add(file2);
|
|
2683
|
+
imageErrors.delete(file2);
|
|
2684
|
+
}
|
|
2685
|
+
}
|
|
2686
|
+
events.toolResult(id, failed2 ? "failed" : "completed", str2(tool.output) || reason);
|
|
2528
2687
|
}
|
|
2529
2688
|
return out;
|
|
2530
2689
|
}
|
|
@@ -2544,44 +2703,65 @@ function createAntigravityRenderer(expectedSession) {
|
|
|
2544
2703
|
used = previous ? { input: Math.max(0, total.input - previous.input), output: Math.max(0, total.output - previous.output), cacheRead: Math.max(0, total.cacheRead - previous.cacheRead), cacheCreation: 0 } : num2(result.num_turns) === 1 ? total : turnUsage;
|
|
2545
2704
|
previous = total;
|
|
2546
2705
|
if (!Object.values(used).some((n) => n > 0)) used = void 0;
|
|
2706
|
+
const missing = requiredImages.length ? requiredImages.filter((file2) => !readImages.has(file2)) : [...imageErrors.keys()];
|
|
2707
|
+
imageFailure = missing.length ? missing.map((file2) => imageError(file2, imageErrors.get(file2) || (translating() ? "\u672C\u8F6E\u672A\u6210\u529F\u8BFB\u53D6\u6240\u9700\u56FE\u7247\u3002" : "Required image was not successfully read this turn."))).join("\n") : void 0;
|
|
2708
|
+
if (imageFailure) events.error(imageFailure);
|
|
2709
|
+
readImages.clear();
|
|
2710
|
+
imageErrors.clear();
|
|
2547
2711
|
if (Array.isArray(result.denied_actions) && result.denied_actions.length) fail(translating() ? "Antigravity \u6743\u9650\u62D2\u7EDD\uFF0C\u8BF7\u68C0\u67E5\u6743\u9650\u89C4\u5219\u540E\u91CD\u8BD5\u3002" : "Antigravity permission denied. Check permission rules, then retry.");
|
|
2548
2712
|
if (typeof result.response !== "string" || result.status !== "SUCCESS" || str2(result.error) || result.finished_reason && result.finished_reason !== "completed" && result.finished_reason !== "success") {
|
|
2549
|
-
fail(str2(result.error) || `Antigravity: ${str2(result.status) || "missing status"}`);
|
|
2713
|
+
fail(result.status === "CANCELED" ? `Antigravity: CANCELED${result.error ? `: ${str2(result.error)}` : ""}` : str2(result.error) || `Antigravity: ${str2(result.status) || "missing status"}`);
|
|
2550
2714
|
}
|
|
2551
2715
|
events.end();
|
|
2552
2716
|
turnUsage = zero();
|
|
2553
2717
|
counted.clear();
|
|
2554
|
-
return failure ? `
|
|
2555
|
-
[error] ${failure}
|
|
2718
|
+
return failure || imageFailure ? `
|
|
2719
|
+
[error] ${failure || imageFailure}
|
|
2556
2720
|
` : "";
|
|
2557
2721
|
}
|
|
2558
2722
|
return "";
|
|
2559
2723
|
});
|
|
2560
2724
|
return {
|
|
2561
2725
|
push: reader.push,
|
|
2726
|
+
setRequiredImages(files) {
|
|
2727
|
+
requiredImages = files.filter(imagePath).map((file2) => path14.resolve(cwd, file2));
|
|
2728
|
+
},
|
|
2562
2729
|
flush() {
|
|
2563
2730
|
const text6 = reader.flush();
|
|
2564
|
-
if (!terminal)
|
|
2731
|
+
if (!terminal) {
|
|
2732
|
+
incomplete = true;
|
|
2733
|
+
const diagnostics = [stderr.trim(), offStream?.match(/^(?:error:|rpc error:)/i) ? offStream : void 0];
|
|
2734
|
+
const diagnostic = diagnostics.find((text7) => text7 && manualFailure(text7)) ?? diagnostics.find((text7) => text7 && providerBlip(text7));
|
|
2735
|
+
if (diagnostic) fail(diagnostic);
|
|
2736
|
+
if (!failure) fail(translating() ? "Antigravity \u672A\u8FD4\u56DE\u6700\u7EC8\u7ED3\u679C\uFF0C\u8BF7\u68C0\u67E5\u65E5\u5FD7\u540E\u91CD\u8BD5\u3002" : "Antigravity returned no final result. Check the log, then retry.");
|
|
2737
|
+
}
|
|
2565
2738
|
events.end();
|
|
2566
2739
|
return text6;
|
|
2567
2740
|
},
|
|
2568
2741
|
stderr(chunk) {
|
|
2569
2742
|
stderr = (stderr + chunk).slice(-16e3);
|
|
2743
|
+
if (limited(stderr)) fail(stderr.trim());
|
|
2570
2744
|
if (/soft.denied|auto-denied|permission (?:denied|required)|denied by.*(?:policy|rule)|requires? (?:user )?(?:approval|permission)/i.test(stderr)) fail(stderr.trim());
|
|
2571
2745
|
},
|
|
2572
|
-
result: () => final,
|
|
2746
|
+
result: () => final || (failure ? partial || void 0 : final),
|
|
2573
2747
|
resumeId: () => session,
|
|
2574
2748
|
model: () => model,
|
|
2575
2749
|
usage: () => used,
|
|
2576
|
-
|
|
2750
|
+
costUsd: () => cost,
|
|
2751
|
+
costIncomplete: () => incomplete || void 0,
|
|
2752
|
+
context: () => context,
|
|
2753
|
+
failure: () => failure || imageFailure,
|
|
2754
|
+
rateLimit: () => rateLimit,
|
|
2577
2755
|
offStream: () => offStream,
|
|
2578
2756
|
events: events.events
|
|
2579
2757
|
};
|
|
2580
2758
|
}
|
|
2581
|
-
var KINDS, zero, usageOf, add;
|
|
2759
|
+
var KINDS, zero, usageOf, add, limited, imagePath;
|
|
2582
2760
|
var init_antigravity = __esm({
|
|
2583
2761
|
"src/lib/agent/wire/antigravity.ts"() {
|
|
2584
2762
|
"use strict";
|
|
2763
|
+
init_transient();
|
|
2764
|
+
init_prices();
|
|
2585
2765
|
init_language();
|
|
2586
2766
|
init_events();
|
|
2587
2767
|
init_json();
|
|
@@ -2590,6 +2770,7 @@ var init_antigravity = __esm({
|
|
|
2590
2770
|
run_command: "execute",
|
|
2591
2771
|
command_status: "execute",
|
|
2592
2772
|
send_command_input: "execute",
|
|
2773
|
+
read_file: "read",
|
|
2593
2774
|
view_file: "read",
|
|
2594
2775
|
list_dir: "read",
|
|
2595
2776
|
grep_search: "search",
|
|
@@ -2607,12 +2788,14 @@ var init_antigravity = __esm({
|
|
|
2607
2788
|
return { input: num2(u2.input_tokens), output: num2(u2.output_tokens), cacheRead: num2(u2.cache_read_tokens), cacheCreation: 0 };
|
|
2608
2789
|
};
|
|
2609
2790
|
add = (a2, b2) => ({ input: a2.input + b2.input, output: a2.output + b2.output, cacheRead: a2.cacheRead + b2.cacheRead, cacheCreation: 0 });
|
|
2791
|
+
limited = (reason) => /\b429\b|rate[ _-]?limit|resource[ _-]?exhausted|quota[^\n]*\b(?:exceeded|exhausted|depleted|reached)\b|(?:exceed|exhaust|deplet)[^\n]*quota|(?:insufficient|exhausted|out of|no remaining) (?:credits?|quota)|credits?[^\n]*(?:exhaust|deplet|exceed)/i.test(reason);
|
|
2792
|
+
imagePath = (target) => /\.(?:png|jpe?g|gif|webp|bmp|tiff?|svg)$/i.test(target);
|
|
2610
2793
|
}
|
|
2611
2794
|
});
|
|
2612
2795
|
|
|
2613
2796
|
// src/lib/agent/harnesses/antigravity.ts
|
|
2614
2797
|
import fs13 from "node:fs";
|
|
2615
|
-
import
|
|
2798
|
+
import path15 from "node:path";
|
|
2616
2799
|
import { createHash as createHash3 } from "node:crypto";
|
|
2617
2800
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
2618
2801
|
function antigravityModels(output) {
|
|
@@ -2647,6 +2830,7 @@ var init_antigravity2 = __esm({
|
|
|
2647
2830
|
init_spawnable();
|
|
2648
2831
|
init_models();
|
|
2649
2832
|
init_types();
|
|
2833
|
+
init_transient();
|
|
2650
2834
|
init_language();
|
|
2651
2835
|
init_antigravity();
|
|
2652
2836
|
EFFORT_ID = /-(?:low|medium|high|xhigh|max)$/i;
|
|
@@ -2692,18 +2876,19 @@ var init_antigravity2 = __esm({
|
|
|
2692
2876
|
return result.status === 0 ? antigravityModels(result.stdout ?? "").map((m) => m.id) : [];
|
|
2693
2877
|
},
|
|
2694
2878
|
env: () => ({ ...process.env }),
|
|
2695
|
-
|
|
2879
|
+
images: { as: "message" },
|
|
2880
|
+
renderer: (cwd, _binary, argv = []) => {
|
|
2696
2881
|
const at2 = argv.indexOf("--conversation");
|
|
2697
|
-
return createAntigravityRenderer(at2 >= 0 ? argv[at2 + 1] : argv.find((a2) => a2.startsWith("--conversation="))?.slice(15));
|
|
2882
|
+
return createAntigravityRenderer(at2 >= 0 ? argv[at2 + 1] : argv.find((a2) => a2.startsWith("--conversation="))?.slice(15), cwd);
|
|
2698
2883
|
},
|
|
2699
2884
|
systemPrompt(text6, _argv, env2) {
|
|
2700
2885
|
const rule = `${text6}
|
|
2701
2886
|
|
|
2702
2887
|
The task working directory is ${env2.PWD ?? process.cwd()}. Use it as the base for project files and commands. This additional workspace contains only language rules; do not write task output here.`;
|
|
2703
2888
|
const hash2 = createHash3("sha256").update(rule).digest("hex").slice(0, 16);
|
|
2704
|
-
const root2 =
|
|
2705
|
-
const file2 =
|
|
2706
|
-
fs13.mkdirSync(
|
|
2889
|
+
const root2 = path15.join(machineHome(), "prompts", `antigravity-${hash2}`);
|
|
2890
|
+
const file2 = path15.join(root2, ".agents", "rules", "language.md");
|
|
2891
|
+
fs13.mkdirSync(path15.dirname(file2), { recursive: true });
|
|
2707
2892
|
fs13.writeFileSync(file2, `---
|
|
2708
2893
|
trigger: always_on
|
|
2709
2894
|
---
|
|
@@ -2712,10 +2897,11 @@ ${rule}
|
|
|
2712
2897
|
`);
|
|
2713
2898
|
return { args: ["--add-dir", root2] };
|
|
2714
2899
|
},
|
|
2715
|
-
|
|
2900
|
+
transient: ({ failure }) => providerBlip(failure),
|
|
2901
|
+
reports: ["cost", "tokens", "model", "context"],
|
|
2716
2902
|
adoptsSessionId: false,
|
|
2717
|
-
savesSessionAtOpen:
|
|
2718
|
-
stopsOnRateLimit:
|
|
2903
|
+
savesSessionAtOpen: true,
|
|
2904
|
+
stopsOnRateLimit: true,
|
|
2719
2905
|
// `models` is read-only. Only explicit authentication errors mean signed out.
|
|
2720
2906
|
login: {
|
|
2721
2907
|
args: ["models"],
|
|
@@ -3077,50 +3263,6 @@ var init_background = __esm({
|
|
|
3077
3263
|
}
|
|
3078
3264
|
});
|
|
3079
3265
|
|
|
3080
|
-
// src/lib/agent/prices.ts
|
|
3081
|
-
function lookUp(table, model) {
|
|
3082
|
-
const id = model.trim().toLowerCase().replace(/^[^/]+\//, "");
|
|
3083
|
-
return table[id] ?? table[id.replace(/-\d{4}-\d{2}-\d{2}$/, "")];
|
|
3084
|
-
}
|
|
3085
|
-
function priceUsd(provider, model, usage3) {
|
|
3086
|
-
if (!provider || !model || !usage3) return void 0;
|
|
3087
|
-
const table = PRICES[provider.trim().toLowerCase()];
|
|
3088
|
-
const price = table && lookUp(table, model);
|
|
3089
|
-
if (!price) return void 0;
|
|
3090
|
-
const usd = ((usage3.input + usage3.cacheCreation) * price.input + usage3.cacheRead * price.cachedInput + usage3.output * price.output) / 1e6;
|
|
3091
|
-
return Number.isFinite(usd) && usd >= 0 ? usd : void 0;
|
|
3092
|
-
}
|
|
3093
|
-
var OPENAI, PRICES;
|
|
3094
|
-
var init_prices = __esm({
|
|
3095
|
-
"src/lib/agent/prices.ts"() {
|
|
3096
|
-
"use strict";
|
|
3097
|
-
OPENAI = {
|
|
3098
|
-
"gpt-6.1-sol": { input: 2, cachedInput: 0.1, output: 10 },
|
|
3099
|
-
"gpt-6-astra": { input: 10, cachedInput: 1, output: 50 },
|
|
3100
|
-
"gpt-6-sol": { input: 2, cachedInput: 0.2, output: 10 },
|
|
3101
|
-
"gpt-6-luna": { input: 0.1, cachedInput: 0.01, output: 0.5 },
|
|
3102
|
-
"gpt-5.6-sol": { input: 4, cachedInput: 0.4, output: 20 },
|
|
3103
|
-
"gpt-5.6-terra": { input: 2, cachedInput: 0.2, output: 12 },
|
|
3104
|
-
"gpt-5.6-luna": { input: 0.2, cachedInput: 0.02, output: 1.2 },
|
|
3105
|
-
"gpt-5.5": { input: 5, cachedInput: 0.5, output: 30 },
|
|
3106
|
-
"gpt-5.5-pro": { input: 30, cachedInput: 30, output: 180 },
|
|
3107
|
-
"gpt-5.4": { input: 2.5, cachedInput: 0.25, output: 15 },
|
|
3108
|
-
"gpt-5.4-mini": { input: 0.75, cachedInput: 0.075, output: 4.5 },
|
|
3109
|
-
"gpt-5.4-nano": { input: 0.2, cachedInput: 0.02, output: 1.25 },
|
|
3110
|
-
"gpt-5.4-pro": { input: 30, cachedInput: 30, output: 180 },
|
|
3111
|
-
"gpt-5.3-codex": { input: 1.75, cachedInput: 0.175, output: 14 },
|
|
3112
|
-
"gpt-5.2": { input: 1.75, cachedInput: 0.175, output: 14 },
|
|
3113
|
-
"gpt-5.2-pro": { input: 21, cachedInput: 21, output: 168 },
|
|
3114
|
-
"gpt-5.1": { input: 1.25, cachedInput: 0.125, output: 10 },
|
|
3115
|
-
"gpt-5": { input: 1.25, cachedInput: 0.125, output: 10 },
|
|
3116
|
-
"gpt-5-mini": { input: 0.25, cachedInput: 0.025, output: 2 },
|
|
3117
|
-
"gpt-5-nano": { input: 0.05, cachedInput: 5e-3, output: 0.4 },
|
|
3118
|
-
"gpt-5-pro": { input: 15, cachedInput: 15, output: 120 }
|
|
3119
|
-
};
|
|
3120
|
-
PRICES = { openai: OPENAI, "openai-api": OPENAI };
|
|
3121
|
-
}
|
|
3122
|
-
});
|
|
3123
|
-
|
|
3124
3266
|
// src/lib/agent/wire/codex-session.ts
|
|
3125
3267
|
import { readFileSync as readFileSync2, readdirSync, statSync as statSync2 } from "node:fs";
|
|
3126
3268
|
import { homedir as homedir2 } from "node:os";
|
|
@@ -3176,10 +3318,10 @@ function findRollout(threadId) {
|
|
|
3176
3318
|
}
|
|
3177
3319
|
for (const name of names3) {
|
|
3178
3320
|
if (!name.startsWith("rollout-") || !name.endsWith(tail)) continue;
|
|
3179
|
-
const
|
|
3321
|
+
const path89 = join2(dir, name);
|
|
3180
3322
|
try {
|
|
3181
|
-
const at2 = statSync2(
|
|
3182
|
-
if (!newest2 || at2 > newest2.at) newest2 = { path:
|
|
3323
|
+
const at2 = statSync2(path89).mtimeMs;
|
|
3324
|
+
if (!newest2 || at2 > newest2.at) newest2 = { path: path89, at: at2 };
|
|
3183
3325
|
} catch {
|
|
3184
3326
|
}
|
|
3185
3327
|
}
|
|
@@ -3187,11 +3329,11 @@ function findRollout(threadId) {
|
|
|
3187
3329
|
return newest2?.path;
|
|
3188
3330
|
}
|
|
3189
3331
|
function readCodexRunFacts(threadId) {
|
|
3190
|
-
const
|
|
3191
|
-
if (!
|
|
3332
|
+
const path89 = findRollout(threadId);
|
|
3333
|
+
if (!path89) return void 0;
|
|
3192
3334
|
let raw;
|
|
3193
3335
|
try {
|
|
3194
|
-
raw = readFileSync2(
|
|
3336
|
+
raw = readFileSync2(path89, "utf8");
|
|
3195
3337
|
} catch {
|
|
3196
3338
|
return void 0;
|
|
3197
3339
|
}
|
|
@@ -3317,8 +3459,8 @@ function renderCompleted(item) {
|
|
|
3317
3459
|
const changes = Array.isArray(item.changes) ? item.changes : [];
|
|
3318
3460
|
return changes.map((raw) => {
|
|
3319
3461
|
const change2 = obj2(raw);
|
|
3320
|
-
const
|
|
3321
|
-
return
|
|
3462
|
+
const path89 = str2(change2.path);
|
|
3463
|
+
return path89 ? `\u23FA ${str2(change2.kind) || "change"}(${path89})
|
|
3322
3464
|
` : "";
|
|
3323
3465
|
}).join("");
|
|
3324
3466
|
}
|
|
@@ -3653,10 +3795,10 @@ function readKimiRunFacts(sessionId) {
|
|
|
3653
3795
|
const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
|
|
3654
3796
|
let model;
|
|
3655
3797
|
let holding = 0;
|
|
3656
|
-
for (const { path:
|
|
3798
|
+
for (const { path: path89, main } of wireFiles(entry.sessionDir)) {
|
|
3657
3799
|
let raw;
|
|
3658
3800
|
try {
|
|
3659
|
-
raw = readFileSync3(
|
|
3801
|
+
raw = readFileSync3(path89, "utf8");
|
|
3660
3802
|
} catch {
|
|
3661
3803
|
continue;
|
|
3662
3804
|
}
|
|
@@ -3831,11 +3973,11 @@ var init_kimi_stream = __esm({
|
|
|
3831
3973
|
|
|
3832
3974
|
// src/lib/agent/wire/acp-cost.ts
|
|
3833
3975
|
import fs14 from "node:fs";
|
|
3834
|
-
import
|
|
3976
|
+
import path16 from "node:path";
|
|
3835
3977
|
import { createHash as createHash4 } from "node:crypto";
|
|
3836
3978
|
function acpCostFile(tool, cwd, session) {
|
|
3837
3979
|
const key = createHash4("sha256").update(JSON.stringify([tool, cwd, session])).digest("hex");
|
|
3838
|
-
return
|
|
3980
|
+
return path16.join(machineHome(), "usage", "acp", `${key}.json`);
|
|
3839
3981
|
}
|
|
3840
3982
|
function readAcpCost(file2) {
|
|
3841
3983
|
try {
|
|
@@ -3848,7 +3990,7 @@ function readAcpCost(file2) {
|
|
|
3848
3990
|
function saveAcpCost(file2, cost) {
|
|
3849
3991
|
if (cost === void 0) return;
|
|
3850
3992
|
try {
|
|
3851
|
-
fs14.mkdirSync(
|
|
3993
|
+
fs14.mkdirSync(path16.dirname(file2), { recursive: true, mode: 448 });
|
|
3852
3994
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
3853
3995
|
fs14.writeFileSync(tmp, JSON.stringify(cost), { mode: 384 });
|
|
3854
3996
|
fs14.renameSync(tmp, file2);
|
|
@@ -4030,7 +4172,7 @@ var init_package = __esm({
|
|
|
4030
4172
|
"package.json"() {
|
|
4031
4173
|
package_default = {
|
|
4032
4174
|
name: "wildcrane",
|
|
4033
|
-
version: "0.11.
|
|
4175
|
+
version: "0.11.71",
|
|
4034
4176
|
akbContract: 17,
|
|
4035
4177
|
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.",
|
|
4036
4178
|
keywords: [
|
|
@@ -4109,8 +4251,8 @@ var init_version = __esm({
|
|
|
4109
4251
|
import fs15 from "node:fs";
|
|
4110
4252
|
function whereHint(update2, title) {
|
|
4111
4253
|
const locations = Array.isArray(update2.locations) ? update2.locations : [];
|
|
4112
|
-
const
|
|
4113
|
-
return
|
|
4254
|
+
const path89 = str2(obj2(locations[0]).path);
|
|
4255
|
+
return path89 && !title.includes(path89) ? hint(path89) : "";
|
|
4114
4256
|
}
|
|
4115
4257
|
function saidBy(update2) {
|
|
4116
4258
|
const content = Array.isArray(update2.content) ? update2.content : [];
|
|
@@ -4401,7 +4543,7 @@ var init_acp = __esm({
|
|
|
4401
4543
|
});
|
|
4402
4544
|
|
|
4403
4545
|
// src/lib/agent/wire/zcode.ts
|
|
4404
|
-
import
|
|
4546
|
+
import path17 from "node:path";
|
|
4405
4547
|
function whereHint2(input, title) {
|
|
4406
4548
|
const named2 = obj2(input);
|
|
4407
4549
|
for (const key of ["command", "file_path", "path", "url", "pattern"]) {
|
|
@@ -4552,7 +4694,7 @@ async function oneTurn2(io, options) {
|
|
|
4552
4694
|
{ stringIds: true }
|
|
4553
4695
|
);
|
|
4554
4696
|
try {
|
|
4555
|
-
const workspacePath =
|
|
4697
|
+
const workspacePath = path17.resolve(io.cwd);
|
|
4556
4698
|
const workspace2 = { workspacePath, workspaceKey: workspacePath };
|
|
4557
4699
|
let opened;
|
|
4558
4700
|
if (io.resumeId) {
|
|
@@ -4691,7 +4833,7 @@ var init_zcode = __esm({
|
|
|
4691
4833
|
|
|
4692
4834
|
// src/lib/file-memo.ts
|
|
4693
4835
|
import fs16 from "node:fs";
|
|
4694
|
-
import
|
|
4836
|
+
import path18 from "node:path";
|
|
4695
4837
|
function stamp(paths) {
|
|
4696
4838
|
const parts = [];
|
|
4697
4839
|
const visit = (p2) => {
|
|
@@ -4713,7 +4855,7 @@ function stamp(paths) {
|
|
|
4713
4855
|
} catch {
|
|
4714
4856
|
return;
|
|
4715
4857
|
}
|
|
4716
|
-
for (const name of names3) if (name !== "node_modules" && name !== ".git") visit(
|
|
4858
|
+
for (const name of names3) if (name !== "node_modules" && name !== ".git") visit(path18.join(p2, name));
|
|
4717
4859
|
};
|
|
4718
4860
|
for (const p2 of paths) visit(p2);
|
|
4719
4861
|
return parts.join("\n");
|
|
@@ -4824,7 +4966,7 @@ var init_types3 = __esm({
|
|
|
4824
4966
|
|
|
4825
4967
|
// src/lib/agent/settings.ts
|
|
4826
4968
|
import fs17 from "node:fs";
|
|
4827
|
-
import
|
|
4969
|
+
import path19 from "node:path";
|
|
4828
4970
|
function configBlock(value) {
|
|
4829
4971
|
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
4830
4972
|
return value;
|
|
@@ -4888,7 +5030,7 @@ function writeConfig(change2) {
|
|
|
4888
5030
|
}
|
|
4889
5031
|
change2(cfg);
|
|
4890
5032
|
try {
|
|
4891
|
-
fs17.mkdirSync(
|
|
5033
|
+
fs17.mkdirSync(path19.dirname(UI_CONFIG), { recursive: true });
|
|
4892
5034
|
fs17.writeFileSync(UI_CONFIG, JSON.stringify(cfg, null, 2) + "\n");
|
|
4893
5035
|
forgetFileMemos();
|
|
4894
5036
|
return { ok: true };
|
|
@@ -4930,7 +5072,7 @@ function readEnvFile() {
|
|
|
4930
5072
|
function ensureIgnored() {
|
|
4931
5073
|
try {
|
|
4932
5074
|
if (!fs17.existsSync(KANBAN_GITIGNORE)) {
|
|
4933
|
-
fs17.mkdirSync(
|
|
5075
|
+
fs17.mkdirSync(path19.dirname(KANBAN_GITIGNORE), { recursive: true });
|
|
4934
5076
|
fs17.writeFileSync(KANBAN_GITIGNORE, IGNORE_BLOCK);
|
|
4935
5077
|
return { ok: true };
|
|
4936
5078
|
}
|
|
@@ -5455,7 +5597,7 @@ async function run(io, options, count3) {
|
|
|
5455
5597
|
startupTimer = setTimeout(() => {
|
|
5456
5598
|
if (!started) io.event?.({ kind: "log", data: { text: "[conversation] start_unconfirmed" } });
|
|
5457
5599
|
}, CONVERSATION_MS.start);
|
|
5458
|
-
await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text6 }, ...images.map((
|
|
5600
|
+
await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text6 }, ...images.map((path89) => ({ type: "localImage", path: path89 }))] }), CONVERSATION_MS.start, "Codex turn/start timed out; submission outcome is unknown.").catch((error) => {
|
|
5459
5601
|
if (!started) throw error;
|
|
5460
5602
|
});
|
|
5461
5603
|
};
|
|
@@ -5740,74 +5882,23 @@ var init_wire = __esm({
|
|
|
5740
5882
|
}
|
|
5741
5883
|
});
|
|
5742
5884
|
|
|
5743
|
-
// src/lib/agent/harnesses/transient.ts
|
|
5744
|
-
function reasonLine(text6, rule) {
|
|
5745
|
-
const line = text6.split("\n").find((l2) => rule.test(l2.toLowerCase())) ?? text6;
|
|
5746
|
-
const said2 = line.trim().replace(/\s+/g, " ");
|
|
5747
|
-
return said2.length > REASON_MAX ? `${said2.slice(0, REASON_MAX - 1)}\u2026` : said2;
|
|
5748
|
-
}
|
|
5749
|
-
function providerBlip(...said2) {
|
|
5750
|
-
for (const text6 of said2) {
|
|
5751
|
-
if (!text6?.trim()) continue;
|
|
5752
|
-
const lower = text6.toLowerCase();
|
|
5753
|
-
if (MANUAL.some((rule) => rule.test(lower))) return void 0;
|
|
5754
|
-
const hit = PASSING.find((rule) => rule.test(lower));
|
|
5755
|
-
if (!hit) continue;
|
|
5756
|
-
const asked = RETRY_AFTER.exec(text6);
|
|
5757
|
-
const seconds = asked ? Number(asked[1]) : NaN;
|
|
5758
|
-
return {
|
|
5759
|
-
reason: reasonLine(text6, hit),
|
|
5760
|
-
...Number.isFinite(seconds) && seconds > 0 ? { retryAfterMs: seconds * 1e3 } : {}
|
|
5761
|
-
};
|
|
5762
|
-
}
|
|
5763
|
-
return void 0;
|
|
5764
|
-
}
|
|
5765
|
-
var MANUAL, PASSING, RETRY_AFTER, REASON_MAX;
|
|
5766
|
-
var init_transient = __esm({
|
|
5767
|
-
"src/lib/agent/harnesses/transient.ts"() {
|
|
5768
|
-
"use strict";
|
|
5769
|
-
MANUAL = [
|
|
5770
|
-
/\b(401|403)\b/,
|
|
5771
|
-
/unauthorized|forbidden|permission denied/,
|
|
5772
|
-
/authenticat|invalid api key|api[_ ]key|not logged in|\/login|oauth/,
|
|
5773
|
-
/\b429\b/,
|
|
5774
|
-
/rate[_ ]limit|usage limit|quota|credit balance|insufficient|out of tokens/,
|
|
5775
|
-
/cancell?ed|aborted by|interrupted by the user/,
|
|
5776
|
-
/maximum budget|max(imum)? turns|exceeded the budget/,
|
|
5777
|
-
/model not found|unknown model|unsupported|invalid[_ ]request/
|
|
5778
|
-
];
|
|
5779
|
-
PASSING = [
|
|
5780
|
-
// 502/503/529 are distinctive enough to read as a status wherever they appear. A bare
|
|
5781
|
-
// 500 is not — a failure line counting something would match it — so it is left to the
|
|
5782
|
-
// words below, which is how that status is actually written out.
|
|
5783
|
-
/\b(502|503|529)\b/,
|
|
5784
|
-
/overloaded|service unavailable|bad gateway|internal server error|server_error/,
|
|
5785
|
-
/connection (lost|dropped|reset|error|closed)|socket hang up|stream (error|disconnected)/,
|
|
5786
|
-
/econnreset|econnrefused|etimedout|enetunreach|enotfound|eai_again/,
|
|
5787
|
-
/fetch failed|request timed out|network error/
|
|
5788
|
-
];
|
|
5789
|
-
RETRY_AFTER = /retry[-_\s]?after["':=\s]+(\d+)/i;
|
|
5790
|
-
REASON_MAX = 140;
|
|
5791
|
-
}
|
|
5792
|
-
});
|
|
5793
|
-
|
|
5794
5885
|
// src/lib/agent/harnesses/claude-code.ts
|
|
5795
|
-
import
|
|
5886
|
+
import path20 from "node:path";
|
|
5796
5887
|
function claudeStreamArgs(argv) {
|
|
5797
5888
|
if (argv.includes("--output-format")) return [];
|
|
5798
5889
|
return ["--output-format", "stream-json", "--verbose", ...argv.includes("--input-format") ? [] : ["--input-format", "stream-json"]];
|
|
5799
5890
|
}
|
|
5800
5891
|
function claudeOnWindows() {
|
|
5801
5892
|
const [local, roaming] = [process.env.LOCALAPPDATA?.trim(), process.env.APPDATA?.trim()];
|
|
5802
|
-
const packages = local ?
|
|
5893
|
+
const packages = local ? path20.join(local, "Packages") : "";
|
|
5803
5894
|
const data = [
|
|
5804
|
-
...folders(packages).filter((name) => /^(\w+\.)?Claude_/i.test(name)).sort().map((name) =>
|
|
5805
|
-
...roaming ? [
|
|
5895
|
+
...folders(packages).filter((name) => /^(\w+\.)?Claude_/i.test(name)).sort().map((name) => path20.join(packages, name, "LocalCache", "Roaming", "Claude")),
|
|
5896
|
+
...roaming ? [path20.join(roaming, "Claude")] : []
|
|
5806
5897
|
];
|
|
5807
5898
|
return data.flatMap(
|
|
5808
|
-
(dir) => latestIn(
|
|
5809
|
-
|
|
5810
|
-
...folders(version).map((build) =>
|
|
5899
|
+
(dir) => latestIn(path20.join(dir, "claude-code")).flatMap((version) => [
|
|
5900
|
+
path20.join(version, "claude.exe"),
|
|
5901
|
+
...folders(version).map((build) => path20.join(version, build, "claude.exe"))
|
|
5811
5902
|
])
|
|
5812
5903
|
);
|
|
5813
5904
|
}
|
|
@@ -6077,7 +6168,7 @@ var init_claude_code = __esm({
|
|
|
6077
6168
|
...latestIn(home(".local", "share", "claude", "versions")),
|
|
6078
6169
|
// The copy Claude Desktop carries.
|
|
6079
6170
|
...process.platform === "win32" ? claudeOnWindows() : latestIn(home("Library", "Application Support", "Claude", "claude-code")).flatMap(
|
|
6080
|
-
(version) => folders(version).map((build) =>
|
|
6171
|
+
(version) => folders(version).map((build) => path20.join(version, build, "claude.app", "Contents", "MacOS", "claude"))
|
|
6081
6172
|
)
|
|
6082
6173
|
],
|
|
6083
6174
|
install: "npm install -g @anthropic-ai/claude-code"
|
|
@@ -6088,7 +6179,7 @@ var init_claude_code = __esm({
|
|
|
6088
6179
|
// src/lib/agent/worktree.ts
|
|
6089
6180
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
6090
6181
|
import fs18 from "node:fs";
|
|
6091
|
-
import
|
|
6182
|
+
import path21 from "node:path";
|
|
6092
6183
|
function spawnGit(args2, options) {
|
|
6093
6184
|
const out = spawnSync4("git", args2, {
|
|
6094
6185
|
...options,
|
|
@@ -6123,15 +6214,15 @@ var init_worktree = __esm({
|
|
|
6123
6214
|
gitLimits = { timeoutMs: 3e4 };
|
|
6124
6215
|
GitTimeoutError = class extends Error {
|
|
6125
6216
|
};
|
|
6126
|
-
worktreeDir = (relPath) =>
|
|
6217
|
+
worktreeDir = (relPath) => path21.resolve(REPO_ROOT, relPath);
|
|
6127
6218
|
headCommit = (cwd = REPO_ROOT) => git(["rev-parse", "HEAD"], cwd)?.trim() || null;
|
|
6128
|
-
worktreeExists = (relPath) => !!relPath && fs18.existsSync(
|
|
6219
|
+
worktreeExists = (relPath) => !!relPath && fs18.existsSync(path21.join(worktreeDir(relPath), ".git"));
|
|
6129
6220
|
}
|
|
6130
6221
|
});
|
|
6131
6222
|
|
|
6132
6223
|
// src/lib/agent/harnesses/codex.ts
|
|
6133
6224
|
import fs19 from "node:fs";
|
|
6134
|
-
import
|
|
6225
|
+
import path22 from "node:path";
|
|
6135
6226
|
function codexExtraArgs(argv, cwd = REPO_ROOT) {
|
|
6136
6227
|
const extra = [];
|
|
6137
6228
|
if (!namesFlag(argv, ["--json", "--experimental-json"])) extra.push("--json");
|
|
@@ -6147,10 +6238,10 @@ function codexExtraArgs(argv, cwd = REPO_ROOT) {
|
|
|
6147
6238
|
}
|
|
6148
6239
|
const flags = [...argv, ...extra];
|
|
6149
6240
|
const workspaceWrite = flags.some((arg, i) => arg === "--full-auto" || arg === "--sandbox=workspace-write" || (arg === "--sandbox" || arg === "-s") && flags[i + 1] === "workspace-write");
|
|
6150
|
-
if (workspaceWrite &&
|
|
6241
|
+
if (workspaceWrite && path22.resolve(cwd) !== path22.resolve(REPO_ROOT)) {
|
|
6151
6242
|
for (const dir of [KANBAN, AKB_DIR]) {
|
|
6152
|
-
const relative =
|
|
6153
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
6243
|
+
const relative = path22.relative(cwd, dir);
|
|
6244
|
+
if (relative === ".." || relative.startsWith(`..${path22.sep}`) || path22.isAbsolute(relative)) {
|
|
6154
6245
|
extra.push("--add-dir", dir);
|
|
6155
6246
|
}
|
|
6156
6247
|
}
|
|
@@ -6198,28 +6289,28 @@ function codexOnWindows() {
|
|
|
6198
6289
|
const local = envRoot("LOCALAPPDATA");
|
|
6199
6290
|
const profile = envRoot("USERPROFILE");
|
|
6200
6291
|
const programs = envRoot("ProgramFiles");
|
|
6201
|
-
const cache = local ?
|
|
6202
|
-
const releases = profile ?
|
|
6203
|
-
const packages = programs ?
|
|
6292
|
+
const cache = local ? path22.join(local, "OpenAI", "Codex", "bin") : "";
|
|
6293
|
+
const releases = profile ? path22.join(profile, ".codex", "packages", "standalone", "releases") : "";
|
|
6294
|
+
const packages = programs ? path22.join(programs, "WindowsApps") : "";
|
|
6204
6295
|
return [
|
|
6205
6296
|
// Desktop's relocated CLI cache: a folder per build hash, newest file first.
|
|
6206
|
-
...byNewest(folders(cache).map((name) =>
|
|
6297
|
+
...byNewest(folders(cache).map((name) => path22.join(cache, name, "codex.exe"))),
|
|
6207
6298
|
// The separate standalone launcher, at a path with nothing variable in it.
|
|
6208
|
-
...local ? [
|
|
6299
|
+
...local ? [path22.join(local, "Programs", "OpenAI", "Codex", "bin", "codex.exe")] : [],
|
|
6209
6300
|
// That launcher's release payload: a folder per version and target.
|
|
6210
6301
|
...byVersion(folders(releases).filter(ourArch)).map(
|
|
6211
|
-
(name) =>
|
|
6302
|
+
(name) => path22.join(releases, name, "bin", "codex.exe")
|
|
6212
6303
|
),
|
|
6213
6304
|
// Desktop's own MSIX package.
|
|
6214
6305
|
...byVersion(folders(packages).filter((name) => name.startsWith("OpenAI.Codex_")).filter(ourArch)).map(
|
|
6215
|
-
(name) =>
|
|
6306
|
+
(name) => path22.join(packages, name, "app", "resources", "codex.exe")
|
|
6216
6307
|
)
|
|
6217
6308
|
];
|
|
6218
6309
|
}
|
|
6219
6310
|
function codexInstalls() {
|
|
6220
6311
|
const chosen = process.env.CODEX_INSTALL_DIR?.trim();
|
|
6221
6312
|
return [
|
|
6222
|
-
...chosen ? [
|
|
6313
|
+
...chosen ? [path22.join(chosen, "codex")] : [],
|
|
6223
6314
|
...process.platform === "win32" ? codexOnWindows() : [
|
|
6224
6315
|
// macOS, where Codex now lives in the merged app — `codex-cli/bin/` since 26.928…
|
|
6225
6316
|
"/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex",
|
|
@@ -6278,7 +6369,7 @@ var init_codex2 = __esm({
|
|
|
6278
6369
|
systemPrompt(text6, argv) {
|
|
6279
6370
|
if (namesFlag(argv, ["developer_instructions", "model_instructions_file"])) return {};
|
|
6280
6371
|
try {
|
|
6281
|
-
const config = fs19.readFileSync(
|
|
6372
|
+
const config = fs19.readFileSync(path22.join(process.env.CODEX_HOME || home(".codex"), "config.toml"), "utf8");
|
|
6282
6373
|
if (/^\s*(?:developer_instructions|model_instructions_file)\s*=/m.test(config)) return {};
|
|
6283
6374
|
} catch {
|
|
6284
6375
|
}
|
|
@@ -6532,23 +6623,23 @@ var init_cursor = __esm({
|
|
|
6532
6623
|
|
|
6533
6624
|
// src/lib/agent/harnesses/dsh.ts
|
|
6534
6625
|
import fs20 from "node:fs";
|
|
6535
|
-
import
|
|
6626
|
+
import path23 from "node:path";
|
|
6536
6627
|
function dshHome(argv) {
|
|
6537
6628
|
const binary = argv[0];
|
|
6538
6629
|
if (!binary) return void 0;
|
|
6539
|
-
const names3 = process.platform === "win32" && !
|
|
6540
|
-
const candidates = binary.includes("/") || binary.includes("\\") ? names3 : (process.env.PATH ?? "").split(
|
|
6630
|
+
const names3 = process.platform === "win32" && !path23.extname(binary) ? [".exe", ".cmd"].map((ext) => binary + ext) : [binary];
|
|
6631
|
+
const candidates = binary.includes("/") || binary.includes("\\") ? names3 : (process.env.PATH ?? "").split(path23.delimiter).filter(Boolean).flatMap((dir2) => names3.map((name) => path23.join(dir2, name)));
|
|
6541
6632
|
let dir;
|
|
6542
6633
|
try {
|
|
6543
6634
|
const found2 = candidates.find((candidate) => fs20.existsSync(candidate));
|
|
6544
6635
|
if (!found2) return void 0;
|
|
6545
6636
|
const script = /\.cmd$/i.test(found2) ? shimTarget(fs20.readFileSync(found2, "utf8"), found2)?.script : void 0;
|
|
6546
|
-
dir =
|
|
6637
|
+
dir = path23.dirname(fs20.realpathSync(script ?? found2));
|
|
6547
6638
|
} catch {
|
|
6548
6639
|
return void 0;
|
|
6549
6640
|
}
|
|
6550
|
-
for (let up =
|
|
6551
|
-
if (fs20.existsSync(
|
|
6641
|
+
for (let up = path23.dirname(dir); dir !== up; up = path23.dirname(dir)) {
|
|
6642
|
+
if (fs20.existsSync(path23.join(dir, "package.json"))) return dir;
|
|
6552
6643
|
dir = up;
|
|
6553
6644
|
}
|
|
6554
6645
|
return void 0;
|
|
@@ -6556,7 +6647,7 @@ function dshHome(argv) {
|
|
|
6556
6647
|
function dshFound(binary, onPath2) {
|
|
6557
6648
|
const home3 = dshHome([binary]);
|
|
6558
6649
|
const exts = process.platform === "win32" ? [".cmd", ".exe"] : [""];
|
|
6559
|
-
return !!home3 && exts.some((ext) => fs20.existsSync(
|
|
6650
|
+
return !!home3 && exts.some((ext) => fs20.existsSync(path23.join(home3, "node_modules", ".bin", `dsh${ext}`))) || onPath2("dsh");
|
|
6560
6651
|
}
|
|
6561
6652
|
function dshExtraArgs(argv) {
|
|
6562
6653
|
const args2 = namesFlag(argv, ["--permission-mode"]) ? [] : ["--permission-mode", "workspace-write"];
|
|
@@ -7276,7 +7367,7 @@ var init_providers = __esm({
|
|
|
7276
7367
|
});
|
|
7277
7368
|
|
|
7278
7369
|
// src/lib/agent/run-settings.ts
|
|
7279
|
-
import
|
|
7370
|
+
import path24 from "node:path";
|
|
7280
7371
|
function isFilled(harness, { values, secretsSet }) {
|
|
7281
7372
|
return (key) => {
|
|
7282
7373
|
const setting = harness.settings.find((s) => s.key === key);
|
|
@@ -7356,7 +7447,7 @@ function languageEnv(given) {
|
|
|
7356
7447
|
try {
|
|
7357
7448
|
const config = JSON.parse(env2.OPENCODE_CONFIG_CONTENT ?? "{}");
|
|
7358
7449
|
if (Array.isArray(config.instructions)) {
|
|
7359
|
-
config.instructions = config.instructions.filter((file2) => typeof file2 !== "string" ||
|
|
7450
|
+
config.instructions = config.instructions.filter((file2) => typeof file2 !== "string" || path24.dirname(file2) !== path24.join(machineHome(), "prompts") || !/^opencode-language(?:-[a-f0-9]{16})?\.md$/.test(path24.basename(file2)));
|
|
7360
7451
|
env2.OPENCODE_CONFIG_CONTENT = JSON.stringify(config);
|
|
7361
7452
|
}
|
|
7362
7453
|
} catch {
|
|
@@ -7372,7 +7463,7 @@ function withSystemLanguage(harness, argv, env2, language) {
|
|
|
7372
7463
|
const note = language === "zh" ? "\u8BED\u8A00\u89C4\u5219\u672A\u80FD\u66F4\u65B0\uFF1A\u8FDE\u63A5\u5668\u3001\u5DF2\u6709\u4F1A\u8BDD\u6216\u81EA\u8BBE\u7CFB\u7EDF\u63D0\u793A\u8BCD\u4E0D\u652F\u6301\u6CE8\u5165\u3002\u8BF7\u81EA\u884C\u53E6\u5F00\u652F\u6301\u7684\u4F1A\u8BDD\u4EE5\u91C7\u7528\u65B0\u89C4\u5219\u3002" : "Language rules could not be updated: the connector, existing session, or custom system prompt prevents injection. Open a supported new session to apply them.";
|
|
7373
7464
|
return { argv, env: env2, note };
|
|
7374
7465
|
}
|
|
7375
|
-
const at2 = /^node(?:\.exe)?$/.test(
|
|
7466
|
+
const at2 = /^node(?:\.exe)?$/.test(path24.basename(argv[0])) && argv[1] && !argv[1].startsWith("-") ? 2 : 1;
|
|
7376
7467
|
return { argv: [...argv.slice(0, at2), ...added?.args ?? [], ...argv.slice(at2)], env: { ...env2, ...added?.env } };
|
|
7377
7468
|
}
|
|
7378
7469
|
var init_run_settings = __esm({
|
|
@@ -7427,10 +7518,10 @@ var init_execution = __esm({
|
|
|
7427
7518
|
|
|
7428
7519
|
// src/lib/agent/log.ts
|
|
7429
7520
|
import fs21 from "node:fs";
|
|
7430
|
-
import
|
|
7521
|
+
import path25 from "node:path";
|
|
7431
7522
|
function pruneLogs() {
|
|
7432
7523
|
try {
|
|
7433
|
-
const runs = fs21.readdirSync(SESSIONS_DIR).filter((f2) => f2.endsWith(".log") && !f2.endsWith(".watch.log")).map((f2) => ({ id: f2.slice(0, -".log".length), t: fs21.statSync(
|
|
7524
|
+
const runs = fs21.readdirSync(SESSIONS_DIR).filter((f2) => f2.endsWith(".log") && !f2.endsWith(".watch.log")).map((f2) => ({ id: f2.slice(0, -".log".length), t: fs21.statSync(path25.join(SESSIONS_DIR, f2)).mtimeMs })).sort((a2, b2) => b2.t - a2.t);
|
|
7434
7525
|
const kept2 = new Set(runs.slice(0, KEEP_LOGS).map((r2) => r2.id));
|
|
7435
7526
|
const drop = new Set(runs.slice(KEEP_LOGS).map((r2) => r2.id));
|
|
7436
7527
|
for (const f2 of fs21.readdirSync(SESSIONS_DIR)) {
|
|
@@ -7439,7 +7530,7 @@ function pruneLogs() {
|
|
|
7439
7530
|
const stray = f2.endsWith(".images") && !kept2.has(id) && !drop.has(id) && stale2(f2);
|
|
7440
7531
|
if (!stray && !drop.has(id)) continue;
|
|
7441
7532
|
try {
|
|
7442
|
-
fs21.rmSync(
|
|
7533
|
+
fs21.rmSync(path25.join(SESSIONS_DIR, f2), { recursive: true, force: true });
|
|
7443
7534
|
} catch {
|
|
7444
7535
|
}
|
|
7445
7536
|
}
|
|
@@ -7448,7 +7539,7 @@ function pruneLogs() {
|
|
|
7448
7539
|
}
|
|
7449
7540
|
function stale2(name) {
|
|
7450
7541
|
try {
|
|
7451
|
-
return Date.now() - fs21.statSync(
|
|
7542
|
+
return Date.now() - fs21.statSync(path25.join(SESSIONS_DIR, name)).mtimeMs > STRAY_MS;
|
|
7452
7543
|
} catch {
|
|
7453
7544
|
return false;
|
|
7454
7545
|
}
|
|
@@ -7605,9 +7696,9 @@ __export(store_exports, {
|
|
|
7605
7696
|
withStore: () => withStore
|
|
7606
7697
|
});
|
|
7607
7698
|
import fs22 from "node:fs";
|
|
7608
|
-
import
|
|
7699
|
+
import path26 from "node:path";
|
|
7609
7700
|
function logPathIn(held4, sessionId) {
|
|
7610
|
-
return typeof held4 === "string" && held4.startsWith(SESSIONS_DIR +
|
|
7701
|
+
return typeof held4 === "string" && held4.startsWith(SESSIONS_DIR + path26.sep) ? held4 : logPathOf(sessionId);
|
|
7611
7702
|
}
|
|
7612
7703
|
function parseStore() {
|
|
7613
7704
|
let data;
|
|
@@ -7973,7 +8064,7 @@ function writeStore(store) {
|
|
|
7973
8064
|
marks: store.marks,
|
|
7974
8065
|
...store.refined ? { refined: store.refined } : {}
|
|
7975
8066
|
};
|
|
7976
|
-
fs22.mkdirSync(
|
|
8067
|
+
fs22.mkdirSync(path26.dirname(SESSIONS), { recursive: true });
|
|
7977
8068
|
const tmp = `${SESSIONS}.tmp`;
|
|
7978
8069
|
fs22.writeFileSync(tmp, JSON.stringify(kept2, null, 2) + "\n");
|
|
7979
8070
|
fs22.renameSync(tmp, SESSIONS);
|
|
@@ -8039,8 +8130,8 @@ var init_store = __esm({
|
|
|
8039
8130
|
init_log();
|
|
8040
8131
|
KEEP_RUNS = 100;
|
|
8041
8132
|
KEEP_DELIVERIES = 30;
|
|
8042
|
-
logPathOf = (sessionId) =>
|
|
8043
|
-
eventsPathOf = (sessionId) =>
|
|
8133
|
+
logPathOf = (sessionId) => path26.join(SESSIONS_DIR, `${sessionId}.log`);
|
|
8134
|
+
eventsPathOf = (sessionId) => path26.join(SESSIONS_DIR, `${sessionId}.events.jsonl`);
|
|
8044
8135
|
WAS_CLARIFY = /* @__PURE__ */ new Set(["auto-refine", "refine", "raise-questions"]);
|
|
8045
8136
|
RETIRED_ACTIONS = /* @__PURE__ */ new Set([
|
|
8046
8137
|
"channel",
|
|
@@ -8221,8 +8312,8 @@ var init_file_limits = __esm({
|
|
|
8221
8312
|
});
|
|
8222
8313
|
|
|
8223
8314
|
// src/lib/shared/board-files.ts
|
|
8224
|
-
function studioRenamed(
|
|
8225
|
-
const to =
|
|
8315
|
+
function studioRenamed(path89, content) {
|
|
8316
|
+
const to = path89.replace(/^(rules\/)?workflows\//, "$1studios/").replace(/^(studios\/[^/]+)\/WORKFLOW\.md$/, "$1/STUDIO.md");
|
|
8226
8317
|
if (!to.endsWith(".md")) return { path: to, content };
|
|
8227
8318
|
if (to.startsWith("studios/")) return { path: to, content: content.replace(/^(icon:\s*["']?)workflow(-kit)?(["']?\s*)$/gm, "$1studio$2$3") };
|
|
8228
8319
|
const front = /^(?:todo|triage)\//.test(to) ? /^---\r?\n[\s\S]*?\r?\n---/.exec(content)?.[0] : void 0;
|
|
@@ -8749,7 +8840,7 @@ function diagramFrom(files) {
|
|
|
8749
8840
|
if ("problem" in read4) return null;
|
|
8750
8841
|
return studioDiagram(read4.def, (name) => {
|
|
8751
8842
|
const text6 = files[`agents/${name}/AGENT.md`];
|
|
8752
|
-
const parsed = text6 === void 0 ? null : parseSpecAgent(text6, name, (
|
|
8843
|
+
const parsed = text6 === void 0 ? null : parseSpecAgent(text6, name, (path89) => files[`agents/${name}/${path89}`] ?? null, false);
|
|
8753
8844
|
return parsed && "agent" in parsed ? parsed.agent : null;
|
|
8754
8845
|
});
|
|
8755
8846
|
}
|
|
@@ -8897,16 +8988,16 @@ var init_studio_files = __esm({
|
|
|
8897
8988
|
|
|
8898
8989
|
// src/lib/agent/studio-folder.ts
|
|
8899
8990
|
import fs23 from "node:fs";
|
|
8900
|
-
import
|
|
8991
|
+
import path27 from "node:path";
|
|
8901
8992
|
function filesOf(dir, base = dir) {
|
|
8902
8993
|
return fs23.readdirSync(dir, { withFileTypes: true }).filter((e2) => !e2.name.startsWith(".")).flatMap((e2) => {
|
|
8903
|
-
const full =
|
|
8904
|
-
return e2.isDirectory() ? filesOf(full, base) : [
|
|
8994
|
+
const full = path27.join(dir, e2.name);
|
|
8995
|
+
return e2.isDirectory() ? filesOf(full, base) : [path27.relative(base, full).split(path27.sep).join("/")];
|
|
8905
8996
|
});
|
|
8906
8997
|
}
|
|
8907
8998
|
function readStudioFile(dir, file2) {
|
|
8908
|
-
const full =
|
|
8909
|
-
return isAboutFile(file2) && !file2.endsWith(".md") ? `data:${MIME[
|
|
8999
|
+
const full = path27.join(dir, file2);
|
|
9000
|
+
return isAboutFile(file2) && !file2.endsWith(".md") ? `data:${MIME[path27.extname(file2)]};base64,${fs23.readFileSync(full).toString("base64")}` : fs23.readFileSync(full, "utf8");
|
|
8910
9001
|
}
|
|
8911
9002
|
var MIME, readStudioFolder;
|
|
8912
9003
|
var init_studio_folder = __esm({
|
|
@@ -8921,12 +9012,12 @@ var init_studio_folder = __esm({
|
|
|
8921
9012
|
// ../official/pack.ts
|
|
8922
9013
|
import crypto2 from "node:crypto";
|
|
8923
9014
|
import fs24 from "node:fs";
|
|
8924
|
-
import
|
|
9015
|
+
import path28 from "node:path";
|
|
8925
9016
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8926
9017
|
function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
8927
|
-
const studiosDir =
|
|
9018
|
+
const studiosDir = path28.join(root2, "studios");
|
|
8928
9019
|
return dirs(studiosDir).map((folder) => {
|
|
8929
|
-
const files = readStudioFolder(
|
|
9020
|
+
const files = readStudioFolder(path28.join(studiosDir, folder));
|
|
8930
9021
|
const parsed = parseStudioFile(folder, files[STUDIO_FILE] ?? "", STUDIO_FILE);
|
|
8931
9022
|
if ("problem" in parsed) throw new Error(parsed.problem);
|
|
8932
9023
|
const def = parsed.def;
|
|
@@ -8951,7 +9042,7 @@ var init_pack = __esm({
|
|
|
8951
9042
|
init_studio_def();
|
|
8952
9043
|
init_studio_folder();
|
|
8953
9044
|
init_studio_files();
|
|
8954
|
-
OFFICIAL =
|
|
9045
|
+
OFFICIAL = path28.dirname(fileURLToPath2(import.meta.url));
|
|
8955
9046
|
dirs = (dir) => fs24.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
|
|
8956
9047
|
hashOf = (files) => crypto2.createHash("sha256").update(hashInput(files)).digest("hex");
|
|
8957
9048
|
}
|
|
@@ -8959,7 +9050,7 @@ var init_pack = __esm({
|
|
|
8959
9050
|
|
|
8960
9051
|
// src/lib/agent/cloud-studios.ts
|
|
8961
9052
|
import fs25 from "node:fs";
|
|
8962
|
-
import
|
|
9053
|
+
import path29 from "node:path";
|
|
8963
9054
|
function readJson(file2) {
|
|
8964
9055
|
try {
|
|
8965
9056
|
return JSON.parse(fs25.readFileSync(file2, "utf8"));
|
|
@@ -8968,7 +9059,7 @@ function readJson(file2) {
|
|
|
8968
9059
|
}
|
|
8969
9060
|
}
|
|
8970
9061
|
function writeJson(file2, value) {
|
|
8971
|
-
fs25.mkdirSync(
|
|
9062
|
+
fs25.mkdirSync(path29.dirname(file2), { recursive: true });
|
|
8972
9063
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
8973
9064
|
fs25.writeFileSync(tmp, `${JSON.stringify(value)}
|
|
8974
9065
|
`);
|
|
@@ -8977,14 +9068,14 @@ function writeJson(file2, value) {
|
|
|
8977
9068
|
function heldStudioName(name) {
|
|
8978
9069
|
let files;
|
|
8979
9070
|
try {
|
|
8980
|
-
files = fs25.readdirSync(
|
|
9071
|
+
files = fs25.readdirSync(path29.join(root(), "versions"));
|
|
8981
9072
|
} catch {
|
|
8982
9073
|
return "";
|
|
8983
9074
|
}
|
|
8984
9075
|
const held4 = files.filter((f2) => f2.endsWith(".json")).map((f2) => f2.slice(0, f2.lastIndexOf("@"))).find((id) => studioName(id) === name);
|
|
8985
9076
|
if (!held4) return "";
|
|
8986
9077
|
const file2 = files.filter((f2) => f2.startsWith(`${held4}@`)).sort().pop();
|
|
8987
|
-
return readJson(
|
|
9078
|
+
return readJson(path29.join(root(), "versions", file2))?.name ?? "";
|
|
8988
9079
|
}
|
|
8989
9080
|
function saveVersion(held4) {
|
|
8990
9081
|
const file2 = versionFile(held4.id, held4.version);
|
|
@@ -9120,11 +9211,11 @@ var init_cloud_studios = __esm({
|
|
|
9120
9211
|
init_studio_def();
|
|
9121
9212
|
DEV = "AI4KANBAN_STUDIOS";
|
|
9122
9213
|
FRESH_MS = 6e4;
|
|
9123
|
-
root = () =>
|
|
9214
|
+
root = () => path29.join(machineHome(), "studios");
|
|
9124
9215
|
safe = (name) => name.replace(/[^\w.@-]/g, "_");
|
|
9125
|
-
versionFile = (id, version) =>
|
|
9126
|
-
listFile = (project2) =>
|
|
9127
|
-
pinFile = (task) =>
|
|
9216
|
+
versionFile = (id, version) => path29.join(root(), "versions", `${safe(id)}@${version}.json`);
|
|
9217
|
+
listFile = (project2) => path29.join(root(), "lists", `${safe(project2)}.json`);
|
|
9218
|
+
pinFile = (task) => path29.join(root(), "tasks", `${safe(task)}.json`);
|
|
9128
9219
|
readVersion = (id, version) => readJson(versionFile(id, version));
|
|
9129
9220
|
readPin = (task) => readJson(pinFile(task));
|
|
9130
9221
|
boardProject = () => KANBAN ? runnerProject(KANBAN) : null;
|
|
@@ -9164,7 +9255,7 @@ var init_bundled = __esm({
|
|
|
9164
9255
|
|
|
9165
9256
|
// src/lib/agents/catalog.ts
|
|
9166
9257
|
import fs26 from "node:fs";
|
|
9167
|
-
import
|
|
9258
|
+
import path30 from "node:path";
|
|
9168
9259
|
function readCatalog() {
|
|
9169
9260
|
const agents = [];
|
|
9170
9261
|
const problems = [];
|
|
@@ -9277,11 +9368,11 @@ function projectFolders(root2) {
|
|
|
9277
9368
|
}
|
|
9278
9369
|
function agentFileReader(dir) {
|
|
9279
9370
|
return (relative) => {
|
|
9280
|
-
const target =
|
|
9281
|
-
if (target !== dir && !target.startsWith(dir +
|
|
9371
|
+
const target = path30.resolve(dir, relative);
|
|
9372
|
+
if (target !== dir && !target.startsWith(dir + path30.sep)) return null;
|
|
9282
9373
|
try {
|
|
9283
9374
|
const real2 = fs26.realpathSync(target);
|
|
9284
|
-
if (!real2.startsWith(fs26.realpathSync(dir) +
|
|
9375
|
+
if (!real2.startsWith(fs26.realpathSync(dir) + path30.sep)) return null;
|
|
9285
9376
|
return fs26.readFileSync(real2, "utf8");
|
|
9286
9377
|
} catch {
|
|
9287
9378
|
return null;
|
|
@@ -9297,14 +9388,14 @@ function walkFolder(dir, prefix) {
|
|
|
9297
9388
|
}
|
|
9298
9389
|
return entries.flatMap((e2) => {
|
|
9299
9390
|
const here = prefix ? `${prefix}/${e2.name}` : e2.name;
|
|
9300
|
-
return e2.isDirectory() ? walkFolder(
|
|
9391
|
+
return e2.isDirectory() ? walkFolder(path30.join(dir, e2.name), here) : [here];
|
|
9301
9392
|
});
|
|
9302
9393
|
}
|
|
9303
9394
|
function readProject(root2, folder) {
|
|
9304
|
-
const dir =
|
|
9395
|
+
const dir = path30.join(root2, folder);
|
|
9305
9396
|
const file2 = agentFileReader(dir);
|
|
9306
9397
|
const text6 = file2("AGENT.md");
|
|
9307
|
-
const missing = rel(
|
|
9398
|
+
const missing = rel(path30.join(dir, "AGENT.md"));
|
|
9308
9399
|
if (text6 === null) return { problem: `${missing} is missing`, file: missing, missing: true };
|
|
9309
9400
|
const from = missing;
|
|
9310
9401
|
const read4 = parseSpecAgent(text6, from, file2, false, () => ownFiles(walkFolder(dir, "")));
|
|
@@ -9707,10 +9798,10 @@ var init_assemble = __esm({
|
|
|
9707
9798
|
|
|
9708
9799
|
// src/lib/cards.ts
|
|
9709
9800
|
import fs27 from "node:fs";
|
|
9710
|
-
import
|
|
9801
|
+
import path31 from "node:path";
|
|
9711
9802
|
function walkMd(dir, acc = []) {
|
|
9712
9803
|
for (const entry of fs27.readdirSync(dir, { withFileTypes: true })) {
|
|
9713
|
-
const full =
|
|
9804
|
+
const full = path31.join(dir, entry.name);
|
|
9714
9805
|
if (entry.isDirectory()) walkMd(full, acc);
|
|
9715
9806
|
else if (entry.name.endsWith(".md")) acc.push(full);
|
|
9716
9807
|
}
|
|
@@ -9719,7 +9810,7 @@ function walkMd(dir, acc = []) {
|
|
|
9719
9810
|
function walkDirs(dir, acc = []) {
|
|
9720
9811
|
for (const entry of fs27.readdirSync(dir, { withFileTypes: true })) {
|
|
9721
9812
|
if (!entry.isDirectory()) continue;
|
|
9722
|
-
const full =
|
|
9813
|
+
const full = path31.join(dir, entry.name);
|
|
9723
9814
|
acc.push(full);
|
|
9724
9815
|
walkDirs(full, acc);
|
|
9725
9816
|
}
|
|
@@ -9727,23 +9818,23 @@ function walkDirs(dir, acc = []) {
|
|
|
9727
9818
|
}
|
|
9728
9819
|
function locate2(id) {
|
|
9729
9820
|
const groupDir = walkDirs(TODO).find(
|
|
9730
|
-
(d2) => idPrefix(
|
|
9821
|
+
(d2) => idPrefix(path31.basename(d2)) === id && fs27.existsSync(path31.join(d2, "root.md"))
|
|
9731
9822
|
);
|
|
9732
9823
|
if (groupDir) {
|
|
9733
|
-
return { kind: "group", target: groupDir, rel:
|
|
9824
|
+
return { kind: "group", target: groupDir, rel: path31.relative(TODO, groupDir) };
|
|
9734
9825
|
}
|
|
9735
|
-
const hit = walkMd(TODO).find((f2) => idPrefix(
|
|
9736
|
-
if (hit) return { kind: "file", target: hit, rel:
|
|
9826
|
+
const hit = walkMd(TODO).find((f2) => idPrefix(path31.basename(f2)) === id);
|
|
9827
|
+
if (hit) return { kind: "file", target: hit, rel: path31.relative(TODO, hit) };
|
|
9737
9828
|
return null;
|
|
9738
9829
|
}
|
|
9739
9830
|
function locateArchived(id) {
|
|
9740
9831
|
if (!fs27.existsSync(ARCHIVE)) return null;
|
|
9741
9832
|
const groupDir = walkDirs(ARCHIVE).find(
|
|
9742
|
-
(d2) => idPrefix(
|
|
9833
|
+
(d2) => idPrefix(path31.basename(d2)) === id && fs27.existsSync(path31.join(d2, "root.md"))
|
|
9743
9834
|
);
|
|
9744
|
-
if (groupDir) return { kind: "group", target: groupDir, rel:
|
|
9745
|
-
const hit = walkMd(ARCHIVE).find((f2) => idPrefix(
|
|
9746
|
-
return hit ? { kind: "file", target: hit, rel:
|
|
9835
|
+
if (groupDir) return { kind: "group", target: groupDir, rel: path31.relative(ARCHIVE, groupDir) };
|
|
9836
|
+
const hit = walkMd(ARCHIVE).find((f2) => idPrefix(path31.basename(f2)) === id);
|
|
9837
|
+
return hit ? { kind: "file", target: hit, rel: path31.relative(ARCHIVE, hit) } : null;
|
|
9747
9838
|
}
|
|
9748
9839
|
function boardCardIds() {
|
|
9749
9840
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -9751,16 +9842,16 @@ function boardCardIds() {
|
|
|
9751
9842
|
const id = idPrefix(name);
|
|
9752
9843
|
if (id !== null) ids.add(id);
|
|
9753
9844
|
};
|
|
9754
|
-
for (const dir of walkDirs(TODO)) keep2(
|
|
9755
|
-
for (const file2 of walkMd(TODO)) keep2(
|
|
9845
|
+
for (const dir of walkDirs(TODO)) keep2(path31.basename(dir));
|
|
9846
|
+
for (const file2 of walkMd(TODO)) keep2(path31.basename(file2));
|
|
9756
9847
|
return ids;
|
|
9757
9848
|
}
|
|
9758
9849
|
function enclosingGroupRoot(file2) {
|
|
9759
|
-
let dir =
|
|
9850
|
+
let dir = path31.dirname(file2);
|
|
9760
9851
|
while (dir.startsWith(TODO) && dir !== TODO) {
|
|
9761
|
-
const root2 =
|
|
9852
|
+
const root2 = path31.join(dir, "root.md");
|
|
9762
9853
|
if (fs27.existsSync(root2) && root2 !== file2) return root2;
|
|
9763
|
-
dir =
|
|
9854
|
+
dir = path31.dirname(dir);
|
|
9764
9855
|
}
|
|
9765
9856
|
return null;
|
|
9766
9857
|
}
|
|
@@ -9771,18 +9862,18 @@ function markSubtask(rootFile, id, action) {
|
|
|
9771
9862
|
return true;
|
|
9772
9863
|
}
|
|
9773
9864
|
function archiveDest(found2) {
|
|
9774
|
-
const dest =
|
|
9865
|
+
const dest = path31.join(ARCHIVE, path31.basename(found2.target));
|
|
9775
9866
|
if (fs27.existsSync(dest)) die(`${rel(dest)} already exists \u2014 move it aside first, then archive again`);
|
|
9776
9867
|
return dest;
|
|
9777
9868
|
}
|
|
9778
9869
|
function dropCrossRefs(id) {
|
|
9779
9870
|
const touched = [];
|
|
9780
9871
|
for (const file2 of walkMd(TODO)) {
|
|
9781
|
-
if (
|
|
9872
|
+
if (path31.basename(file2) === "README.md") continue;
|
|
9782
9873
|
const { text: text6, fields } = dropRefsIn(fs27.readFileSync(file2, "utf8"), id);
|
|
9783
9874
|
if (!fields.length) continue;
|
|
9784
9875
|
fs27.writeFileSync(file2, text6);
|
|
9785
|
-
touched.push(`${
|
|
9876
|
+
touched.push(`${path31.relative(TODO, file2).split(path31.sep).join("/")} (${fields.join(", ")})`);
|
|
9786
9877
|
}
|
|
9787
9878
|
return touched;
|
|
9788
9879
|
}
|
|
@@ -9808,7 +9899,7 @@ var init_slug = __esm({
|
|
|
9808
9899
|
|
|
9809
9900
|
// src/lib/validate.ts
|
|
9810
9901
|
import fs28 from "node:fs";
|
|
9811
|
-
import
|
|
9902
|
+
import path32 from "node:path";
|
|
9812
9903
|
function moduleNames() {
|
|
9813
9904
|
if (!fs28.existsSync(MODULES_MD)) return null;
|
|
9814
9905
|
return moduleNamesFrom(fs28.readFileSync(MODULES_MD, "utf8"));
|
|
@@ -9845,7 +9936,7 @@ function dependencyCycle(id, dep) {
|
|
|
9845
9936
|
seen.add(at2);
|
|
9846
9937
|
const found2 = locate2(at2);
|
|
9847
9938
|
if (!found2) return null;
|
|
9848
|
-
const file2 = found2.kind === "group" ?
|
|
9939
|
+
const file2 = found2.kind === "group" ? path32.join(found2.target, "root.md") : found2.target;
|
|
9849
9940
|
const nexts = parseFrontmatter(fs28.readFileSync(file2, "utf8")).meta?.blocked_by ?? [];
|
|
9850
9941
|
if (found2.kind === "group") nexts.push(...groupMembers(found2.target));
|
|
9851
9942
|
for (const next of nexts) {
|
|
@@ -9858,7 +9949,7 @@ function dependencyCycle(id, dep) {
|
|
|
9858
9949
|
return rest && [id, ...rest];
|
|
9859
9950
|
}
|
|
9860
9951
|
function groupMembers(dir) {
|
|
9861
|
-
return walkMd(dir).filter((f2) => f2 !==
|
|
9952
|
+
return walkMd(dir).filter((f2) => f2 !== path32.join(dir, "root.md")).map((f2) => idPrefix(path32.basename(path32.basename(f2) === "root.md" ? path32.dirname(f2) : f2))).filter((n) => n !== null);
|
|
9862
9953
|
}
|
|
9863
9954
|
var LEVELS;
|
|
9864
9955
|
var init_validate = __esm({
|
|
@@ -9875,7 +9966,7 @@ var init_validate = __esm({
|
|
|
9875
9966
|
|
|
9876
9967
|
// src/lib/memory.ts
|
|
9877
9968
|
import fs29 from "node:fs";
|
|
9878
|
-
import
|
|
9969
|
+
import path33 from "node:path";
|
|
9879
9970
|
function scaffoldProjectMemory() {
|
|
9880
9971
|
const board2 = scaffoldMemoryDir(MEMORY, setOf(BOARD_MEMORY_FILES));
|
|
9881
9972
|
const planner = scaffoldMemoryDir(agentMemoryDir(PLANNER), setOf(PLANNER_MEMORY_FILES));
|
|
@@ -9886,7 +9977,7 @@ function scaffoldMemoryDir(dir, set) {
|
|
|
9886
9977
|
fs29.mkdirSync(dir, { recursive: true });
|
|
9887
9978
|
const made = [];
|
|
9888
9979
|
for (const [name, body] of Object.entries(set)) {
|
|
9889
|
-
const file2 =
|
|
9980
|
+
const file2 = path33.join(dir, name);
|
|
9890
9981
|
if (!fs29.existsSync(file2)) {
|
|
9891
9982
|
fs29.writeFileSync(file2, body);
|
|
9892
9983
|
made.push(name);
|
|
@@ -9923,7 +10014,7 @@ function memoryTarget(name, module = "") {
|
|
|
9923
10014
|
}
|
|
9924
10015
|
function scaffoldFile(file2, name) {
|
|
9925
10016
|
if (fs29.existsSync(file2) || !STARTERS[name]) return;
|
|
9926
|
-
fs29.mkdirSync(
|
|
10017
|
+
fs29.mkdirSync(path33.dirname(file2), { recursive: true });
|
|
9927
10018
|
fs29.writeFileSync(file2, STARTERS[name]);
|
|
9928
10019
|
}
|
|
9929
10020
|
function readTopics(file2) {
|
|
@@ -9984,8 +10075,8 @@ edits here do not last.
|
|
|
9984
10075
|
setOf = (names3) => Object.fromEntries(names3.map((name) => [name, STARTERS[name]]));
|
|
9985
10076
|
RESERVED_MEMORY_DIR = "agents";
|
|
9986
10077
|
STUDIO_MEMORY_DIR = "studios";
|
|
9987
|
-
agentMemoryDir = (agent) =>
|
|
9988
|
-
agentMemoryFile = (agent, name) =>
|
|
10078
|
+
agentMemoryDir = (agent) => path33.join(AGENT_MEMORY, agent);
|
|
10079
|
+
agentMemoryFile = (agent, name) => path33.join(agentMemoryDir(agent), name);
|
|
9989
10080
|
writtenMemoryNames = (agent) => {
|
|
9990
10081
|
try {
|
|
9991
10082
|
return fs29.readdirSync(agentMemoryDir(agent), { withFileTypes: true }).filter((e2) => e2.isFile() && e2.name.endsWith(".md")).map((e2) => e2.name).sort();
|
|
@@ -9997,12 +10088,12 @@ edits here do not last.
|
|
|
9997
10088
|
agentMemoryFiles = (agent) => memoryNamesOf(agent).map((name) => agentMemoryFile(agent, name));
|
|
9998
10089
|
RESERVED_MODULE_NAMES = PLANNER_MEMORY_FILES.map((name) => name.replace(/\.md$/, ""));
|
|
9999
10090
|
isModule = (name) => !!name && !RESERVED_MODULE_NAMES.includes(name);
|
|
10000
|
-
moduleMemoryFile = (module, name) =>
|
|
10091
|
+
moduleMemoryFile = (module, name) => path33.join(agentMemoryDir(PLANNER), module, name);
|
|
10001
10092
|
plannerCopies = (name) => [
|
|
10002
10093
|
agentMemoryFile(PLANNER, name),
|
|
10003
10094
|
...plannerModules().map((m) => moduleMemoryFile(m, name)).filter((file2) => fs29.existsSync(file2))
|
|
10004
10095
|
];
|
|
10005
|
-
memoryFile = (name, module = "") => BOARD_MEMORY_FILES.includes(name) ?
|
|
10096
|
+
memoryFile = (name, module = "") => BOARD_MEMORY_FILES.includes(name) ? path33.join(MEMORY, name) : isModule(module) ? moduleMemoryFile(module, name) : agentMemoryFile(PLANNER, name);
|
|
10006
10097
|
}
|
|
10007
10098
|
});
|
|
10008
10099
|
|
|
@@ -10023,7 +10114,7 @@ var init_studio_file = __esm({
|
|
|
10023
10114
|
|
|
10024
10115
|
// src/lib/agent/studios.ts
|
|
10025
10116
|
import fs30 from "node:fs";
|
|
10026
|
-
import
|
|
10117
|
+
import path34 from "node:path";
|
|
10027
10118
|
function studioPurpose(flow) {
|
|
10028
10119
|
if (flow.builtIn) return builtinDescription(flow.id) || flow.name;
|
|
10029
10120
|
return boardStudioDefs().defs.find((d2) => d2.id === flow.id)?.description || flow.name;
|
|
@@ -10185,7 +10276,7 @@ function cardMeta(id) {
|
|
|
10185
10276
|
try {
|
|
10186
10277
|
const found2 = locate2(id) ?? locateArchived(id);
|
|
10187
10278
|
if (!found2) return null;
|
|
10188
|
-
const file2 = found2.kind === "group" ?
|
|
10279
|
+
const file2 = found2.kind === "group" ? path34.join(found2.target, "root.md") : found2.target;
|
|
10189
10280
|
return parseFrontmatter(fs30.readFileSync(file2, "utf8")).meta;
|
|
10190
10281
|
} catch {
|
|
10191
10282
|
return null;
|
|
@@ -10275,7 +10366,7 @@ var init_studios = __esm({
|
|
|
10275
10366
|
previewAgents = (flow) => previewMembers(flow).filter((h3) => !h3.off);
|
|
10276
10367
|
landAgents = (flow) => flow.land.filter((h3) => !h3.off);
|
|
10277
10368
|
archivesOnApproval = (flow) => !!flow && !landAgents(flow).length;
|
|
10278
|
-
studioRuleFile = (id) =>
|
|
10369
|
+
studioRuleFile = (id) => path34.join(RULES, "studios", `${id}.md`);
|
|
10279
10370
|
save = (change2) => writeConfig((cfg) => {
|
|
10280
10371
|
const block = configBlock(cfg.studios);
|
|
10281
10372
|
change2(block);
|
|
@@ -10397,7 +10488,7 @@ var init_stages = __esm({
|
|
|
10397
10488
|
});
|
|
10398
10489
|
|
|
10399
10490
|
// src/lib/agent/roles.ts
|
|
10400
|
-
import
|
|
10491
|
+
import path35 from "node:path";
|
|
10401
10492
|
function landRole(name) {
|
|
10402
10493
|
const agent = specAgentCatalog().agents.find((a2) => a2.name === name);
|
|
10403
10494
|
return agent ? { name, gloss: agent.description, memory: [] } : void 0;
|
|
@@ -10527,8 +10618,8 @@ var init_roles = __esm({
|
|
|
10527
10618
|
hiddenRole = (name) => roleNamed(name)?.hidden === true;
|
|
10528
10619
|
stageContractProblems = () => contractProblems([...agentNames(), ...roles().filter((role) => role.hidden).map((role) => role.name)]);
|
|
10529
10620
|
memoryOf = (role) => role.memory.flatMap((file2) => {
|
|
10530
|
-
const at2 =
|
|
10531
|
-
return
|
|
10621
|
+
const at2 = path35.join(KANBAN, file2);
|
|
10622
|
+
return path35.dirname(at2) === agentMemoryDir(PLANNER) ? plannerCopies(path35.basename(at2)) : [at2];
|
|
10532
10623
|
}).map(rel);
|
|
10533
10624
|
ownMemoryOf = (name, memory) => memoryNamesOf(name).filter((file2) => memory.includes(rel(agentMemoryFile(name, file2))));
|
|
10534
10625
|
agentNames = () => agentRoster().map((entry) => entry.name);
|
|
@@ -11081,7 +11172,7 @@ var init_resolve = __esm({
|
|
|
11081
11172
|
});
|
|
11082
11173
|
|
|
11083
11174
|
// src/lib/agents/index.ts
|
|
11084
|
-
import
|
|
11175
|
+
import path36 from "node:path";
|
|
11085
11176
|
function agentLines(agent, language = readLanguage()) {
|
|
11086
11177
|
const said2 = agent.i18n[language];
|
|
11087
11178
|
return {
|
|
@@ -11128,7 +11219,7 @@ function agentFilesBlock(agent) {
|
|
|
11128
11219
|
"Read one only when the work calls for it:",
|
|
11129
11220
|
"",
|
|
11130
11221
|
...agent.files.map(
|
|
11131
|
-
(f2) => dir ? `- \`${rel(
|
|
11222
|
+
(f2) => dir ? `- \`${rel(path36.join(dir, f2))}\`` : `- \`${f2}\` \u2014 \`${rawMove(studio ? `file ${studio} agents/${agent.name}/${f2}` : `agent-file ${agent.name} ${f2}`)}\``
|
|
11132
11223
|
)
|
|
11133
11224
|
].join("\n");
|
|
11134
11225
|
}
|
|
@@ -11249,12 +11340,12 @@ var init_candidate = __esm({
|
|
|
11249
11340
|
|
|
11250
11341
|
// src/lib/agent/outputs.ts
|
|
11251
11342
|
import fs31 from "node:fs";
|
|
11252
|
-
import
|
|
11343
|
+
import path37 from "node:path";
|
|
11253
11344
|
function cardBody(cardId2) {
|
|
11254
11345
|
const found2 = locate2(cardId2) ?? locateArchived(cardId2);
|
|
11255
11346
|
if (!found2) return "";
|
|
11256
11347
|
try {
|
|
11257
|
-
return fs31.readFileSync(found2.kind === "group" ?
|
|
11348
|
+
return fs31.readFileSync(found2.kind === "group" ? path37.join(found2.target, "root.md") : found2.target, "utf8");
|
|
11258
11349
|
} catch {
|
|
11259
11350
|
return "";
|
|
11260
11351
|
}
|
|
@@ -11507,7 +11598,7 @@ var init_runner = __esm({
|
|
|
11507
11598
|
|
|
11508
11599
|
// src/lib/agent/rules.ts
|
|
11509
11600
|
import fs33 from "node:fs";
|
|
11510
|
-
import
|
|
11601
|
+
import path38 from "node:path";
|
|
11511
11602
|
function ruleFile(agent) {
|
|
11512
11603
|
if (!agent || hiddenRole(agent)) return "";
|
|
11513
11604
|
try {
|
|
@@ -11574,7 +11665,7 @@ var init_rules2 = __esm({
|
|
|
11574
11665
|
init_runner();
|
|
11575
11666
|
init_studios();
|
|
11576
11667
|
init_types3();
|
|
11577
|
-
rulePath = (agent) =>
|
|
11668
|
+
rulePath = (agent) => path38.join(RULES, `${agent}.md`);
|
|
11578
11669
|
flowForRequest = (req) => req.refineRound !== void 0 && REFINE_ACTIONS.has(req.action) ? flowByCommand("refine") : flowByAction(req.action);
|
|
11579
11670
|
ruleOwnerSays = (owner) => `\`${owner.name}\` agent carries one rule of its own${owner.role ? ", on every flow it runs" : ""}`;
|
|
11580
11671
|
said = (owner, rule) => owner && rule ? [
|
|
@@ -11586,7 +11677,7 @@ var init_rules2 = __esm({
|
|
|
11586
11677
|
|
|
11587
11678
|
// src/lib/agent/deliveries.ts
|
|
11588
11679
|
import fs34 from "node:fs";
|
|
11589
|
-
import
|
|
11680
|
+
import path39 from "node:path";
|
|
11590
11681
|
function writeAudit(delivery, runs) {
|
|
11591
11682
|
const known2 = new Map(readAudit(delivery.deliveryId)?.sessions.map((s) => [s.sessionId, s]) ?? []);
|
|
11592
11683
|
const sessions = delivery.sessions.flatMap((id) => {
|
|
@@ -11661,7 +11752,7 @@ function allAudits() {
|
|
|
11661
11752
|
const out = [];
|
|
11662
11753
|
for (const name of names3) {
|
|
11663
11754
|
if (!name.endsWith(".json")) continue;
|
|
11664
|
-
const audit = wholeAudit(
|
|
11755
|
+
const audit = wholeAudit(path39.join(DELIVERIES, name));
|
|
11665
11756
|
if (audit) out.push(audit);
|
|
11666
11757
|
}
|
|
11667
11758
|
return out;
|
|
@@ -11815,7 +11906,7 @@ function carryOnFrom(_deliveryId) {
|
|
|
11815
11906
|
function approvedRequirements(cardId2) {
|
|
11816
11907
|
const found2 = locate2(cardId2);
|
|
11817
11908
|
if (!found2) return "";
|
|
11818
|
-
const file2 = found2.kind === "group" ?
|
|
11909
|
+
const file2 = found2.kind === "group" ? path39.join(found2.target, "root.md") : found2.target;
|
|
11819
11910
|
let text6;
|
|
11820
11911
|
try {
|
|
11821
11912
|
text6 = fs34.readFileSync(file2, "utf8");
|
|
@@ -11848,7 +11939,7 @@ function cardMeta2(cardId2) {
|
|
|
11848
11939
|
try {
|
|
11849
11940
|
const found2 = locate2(cardId2);
|
|
11850
11941
|
if (!found2) return null;
|
|
11851
|
-
const file2 = found2.kind === "group" ?
|
|
11942
|
+
const file2 = found2.kind === "group" ? path39.join(found2.target, "root.md") : found2.target;
|
|
11852
11943
|
return parseFrontmatter(fs34.readFileSync(file2, "utf8")).meta;
|
|
11853
11944
|
} catch {
|
|
11854
11945
|
return null;
|
|
@@ -12020,11 +12111,11 @@ var init_deliveries = __esm({
|
|
|
12020
12111
|
init_types3();
|
|
12021
12112
|
init_worktree();
|
|
12022
12113
|
init_lock();
|
|
12023
|
-
auditPath = (deliveryId) =>
|
|
12114
|
+
auditPath = (deliveryId) => path39.join(DELIVERIES, `${deliveryId}.json`);
|
|
12024
12115
|
activeAudits = () => allAudits().filter((a2) => a2.status === "active");
|
|
12025
12116
|
auditRow = (audit) => readDeliveryRow({ ...audit, sessions: audit.sessions.map((s) => s.sessionId) });
|
|
12026
12117
|
lastSessionRunning = (audit) => audit.sessions[audit.sessions.length - 1]?.status === "running";
|
|
12027
|
-
localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) =>
|
|
12118
|
+
localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) => path39.resolve(REPO_ROOT, session.log) === logPathOf(session.sessionId) && fs34.existsSync(logPathOf(session.sessionId)));
|
|
12028
12119
|
unknownDelivery = (id) => refusal("deliveryNotFound", `no delivery here answers to "${id}"`, { id });
|
|
12029
12120
|
isResumable = (delivery) => !resumeRefusal(delivery);
|
|
12030
12121
|
APPROVED = [
|
|
@@ -12188,9 +12279,9 @@ var init_telemetry_contract = __esm({
|
|
|
12188
12279
|
|
|
12189
12280
|
// src/lib/agent/catalog.ts
|
|
12190
12281
|
import fs35 from "node:fs";
|
|
12191
|
-
import
|
|
12282
|
+
import path40 from "node:path";
|
|
12192
12283
|
function cacheFile() {
|
|
12193
|
-
return
|
|
12284
|
+
return path40.join(machineHome(), "models-dev.json");
|
|
12194
12285
|
}
|
|
12195
12286
|
function readCache() {
|
|
12196
12287
|
const file2 = cacheFile();
|
|
@@ -12241,7 +12332,7 @@ function refreshCatalog() {
|
|
|
12241
12332
|
const limits = limitsIn(await answer2.json());
|
|
12242
12333
|
if (Object.keys(limits).length === 0) return;
|
|
12243
12334
|
const file2 = cacheFile();
|
|
12244
|
-
fs35.mkdirSync(
|
|
12335
|
+
fs35.mkdirSync(path40.dirname(file2), { recursive: true });
|
|
12245
12336
|
fs35.writeFileSync(file2, JSON.stringify({ fetchedAt: Date.now(), limits }));
|
|
12246
12337
|
} catch {
|
|
12247
12338
|
}
|
|
@@ -12255,6 +12346,7 @@ function spellings(model) {
|
|
|
12255
12346
|
return [.../* @__PURE__ */ new Set([id, undated])];
|
|
12256
12347
|
}
|
|
12257
12348
|
function contextLimit(harness, model) {
|
|
12349
|
+
if (harness === "antigravity") return void 0;
|
|
12258
12350
|
if (!model?.trim()) return void 0;
|
|
12259
12351
|
const limits = readCache()?.limits;
|
|
12260
12352
|
if (!limits) return void 0;
|
|
@@ -12306,7 +12398,7 @@ var init_catalog2 = __esm({
|
|
|
12306
12398
|
|
|
12307
12399
|
// src/lib/machine/telemetry.ts
|
|
12308
12400
|
import fs36 from "node:fs";
|
|
12309
|
-
import
|
|
12401
|
+
import path41 from "node:path";
|
|
12310
12402
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
12311
12403
|
function readUsageReporting() {
|
|
12312
12404
|
const { unreadable, values } = heldSettings();
|
|
@@ -12351,14 +12443,14 @@ var init_telemetry = __esm({
|
|
|
12351
12443
|
"use strict";
|
|
12352
12444
|
init_home();
|
|
12353
12445
|
init_settings();
|
|
12354
|
-
usageQueueFile = () =>
|
|
12355
|
-
usageStateFile = () =>
|
|
12446
|
+
usageQueueFile = () => path41.join(machineHome(), "usage-queue.jsonl");
|
|
12447
|
+
usageStateFile = () => path41.join(machineHome(), "usage-state.json");
|
|
12356
12448
|
}
|
|
12357
12449
|
});
|
|
12358
12450
|
|
|
12359
12451
|
// src/lib/machine/usage.ts
|
|
12360
12452
|
import fs37 from "node:fs";
|
|
12361
|
-
import
|
|
12453
|
+
import path42 from "node:path";
|
|
12362
12454
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
12363
12455
|
function usageSurface() {
|
|
12364
12456
|
return process.env.KANBAN_DESKTOP === "1" ? "app" : "command";
|
|
@@ -12637,7 +12729,7 @@ var init_usage2 = __esm({
|
|
|
12637
12729
|
"decisions_stood",
|
|
12638
12730
|
"decisions_overruled"
|
|
12639
12731
|
];
|
|
12640
|
-
boardFile = () =>
|
|
12732
|
+
boardFile = () => path42.join(BOARD_STATE, "usage-board.json");
|
|
12641
12733
|
countOf = (counts, name) => {
|
|
12642
12734
|
const n = counts?.[name];
|
|
12643
12735
|
return typeof n === "number" && Number.isInteger(n) && n > 0 ? n : 0;
|
|
@@ -12674,7 +12766,7 @@ var init_sources = __esm({
|
|
|
12674
12766
|
|
|
12675
12767
|
// src/lib/signals/inbox.ts
|
|
12676
12768
|
import fs38 from "node:fs";
|
|
12677
|
-
import
|
|
12769
|
+
import path43 from "node:path";
|
|
12678
12770
|
function metaPair(key, value) {
|
|
12679
12771
|
const name = typeof key === "string" ? key.trim() : "";
|
|
12680
12772
|
if (!name) return null;
|
|
@@ -12757,10 +12849,10 @@ function parse(file2, lenient = false) {
|
|
|
12757
12849
|
};
|
|
12758
12850
|
}
|
|
12759
12851
|
function freeName(dir, wanted) {
|
|
12760
|
-
const ext =
|
|
12852
|
+
const ext = path43.extname(wanted);
|
|
12761
12853
|
const stem = wanted.slice(0, wanted.length - ext.length);
|
|
12762
12854
|
let name = wanted;
|
|
12763
|
-
for (let n = 2; fs38.existsSync(
|
|
12855
|
+
for (let n = 2; fs38.existsSync(path43.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
|
|
12764
12856
|
return name;
|
|
12765
12857
|
}
|
|
12766
12858
|
function readFolder(dir, lenient = false) {
|
|
@@ -12770,7 +12862,7 @@ function readFolder(dir, lenient = false) {
|
|
|
12770
12862
|
} catch {
|
|
12771
12863
|
return [];
|
|
12772
12864
|
}
|
|
12773
|
-
return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(
|
|
12865
|
+
return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(path43.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
|
|
12774
12866
|
}
|
|
12775
12867
|
function readInbox() {
|
|
12776
12868
|
const signals = readFolder(TRIAGE);
|
|
@@ -12790,7 +12882,7 @@ function writeSignal(incoming, importedAt, slug = "") {
|
|
|
12790
12882
|
contentKept: true,
|
|
12791
12883
|
relPath: ""
|
|
12792
12884
|
};
|
|
12793
|
-
const file2 =
|
|
12885
|
+
const file2 = path43.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug)));
|
|
12794
12886
|
fs38.writeFileSync(file2, serialize({ ...signal2, relPath: boardRel(file2) }));
|
|
12795
12887
|
return { ...signal2, relPath: boardRel(file2) };
|
|
12796
12888
|
}
|
|
@@ -12809,7 +12901,7 @@ function stamp2(file2, fields) {
|
|
|
12809
12901
|
function moveSignal(from, into, fields) {
|
|
12810
12902
|
if (!fs38.existsSync(from)) return "";
|
|
12811
12903
|
fs38.mkdirSync(into, { recursive: true });
|
|
12812
|
-
const at2 =
|
|
12904
|
+
const at2 = path43.join(into, freeName(into, path43.basename(from)));
|
|
12813
12905
|
fs38.renameSync(from, at2);
|
|
12814
12906
|
stamp2(at2, fields);
|
|
12815
12907
|
return boardRel(at2);
|
|
@@ -12819,10 +12911,10 @@ function archiveInboxItem(sourceId, cardId2) {
|
|
|
12819
12911
|
if (!found2) {
|
|
12820
12912
|
const ignored = readAllDismissed().find((signal2) => signal2.sourceId === sourceId);
|
|
12821
12913
|
if (!ignored) return { ok: false, error: `nothing waiting in triage is ${sourceId}` };
|
|
12822
|
-
stamp2(
|
|
12914
|
+
stamp2(path43.join(SIGNALS_DISMISSED, path43.basename(ignored.relPath)), { card_id: String(cardId2) });
|
|
12823
12915
|
return { ok: true, relPath: ignored.relPath, where: "dismissed" };
|
|
12824
12916
|
}
|
|
12825
|
-
const at2 = moveSignal(
|
|
12917
|
+
const at2 = moveSignal(path43.join(TRIAGE, path43.basename(found2.relPath)), SIGNALS_ARCHIVED, {
|
|
12826
12918
|
card_id: String(cardId2),
|
|
12827
12919
|
archived_at: formatStamp(/* @__PURE__ */ new Date())
|
|
12828
12920
|
});
|
|
@@ -12836,7 +12928,7 @@ var init_inbox = __esm({
|
|
|
12836
12928
|
init_sources();
|
|
12837
12929
|
init_paths();
|
|
12838
12930
|
init_yaml();
|
|
12839
|
-
boardRel = (file2) => rel(file2).split(
|
|
12931
|
+
boardRel = (file2) => rel(file2).split(path43.sep).join("/");
|
|
12840
12932
|
FIELDS = ["source_id", "title", "collected_at", "imported_at"];
|
|
12841
12933
|
META_LINE = /^\s+("(?:[^"\\]|\\.)*"|[^:]+):\s*(.*)$/;
|
|
12842
12934
|
slugOf = (said2) => said2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56).replace(/-+$/, "");
|
|
@@ -13044,7 +13136,7 @@ var init_studio_cards = __esm({
|
|
|
13044
13136
|
|
|
13045
13137
|
// src/lib/readme.ts
|
|
13046
13138
|
import fs39 from "node:fs";
|
|
13047
|
-
import
|
|
13139
|
+
import path44 from "node:path";
|
|
13048
13140
|
function stripReadmeRefs(target) {
|
|
13049
13141
|
if (!fs39.existsSync(README)) return [];
|
|
13050
13142
|
const needle = target.kind === "group" ? `](${target.rel}/` : `](${target.rel})`;
|
|
@@ -13075,7 +13167,7 @@ function stripReadmeRefs(target) {
|
|
|
13075
13167
|
}
|
|
13076
13168
|
function addReadmeRef(id, title, relPath) {
|
|
13077
13169
|
if (!fs39.existsSync(README)) return false;
|
|
13078
|
-
const link2 = relPath.split(
|
|
13170
|
+
const link2 = relPath.split(path44.sep).join("/");
|
|
13079
13171
|
const bullet = `- [#${id} ${title}](${link2})`;
|
|
13080
13172
|
const heading = `## ${TASKS_HEADING}`;
|
|
13081
13173
|
let lines = fs39.readFileSync(README, "utf8").split("\n");
|
|
@@ -13102,8 +13194,8 @@ function addReadmeRef(id, title, relPath) {
|
|
|
13102
13194
|
}
|
|
13103
13195
|
function repointReadmeLink(id, oldRel, newRel, title) {
|
|
13104
13196
|
if (!fs39.existsSync(README)) return false;
|
|
13105
|
-
const oldLink = oldRel.split(
|
|
13106
|
-
const newLink = newRel.split(
|
|
13197
|
+
const oldLink = oldRel.split(path44.sep).join("/");
|
|
13198
|
+
const newLink = newRel.split(path44.sep).join("/");
|
|
13107
13199
|
const linkRe = new RegExp(`\\[#${id}\\b[^\\]]*\\]\\(${escapeRegex(oldLink)}\\)`);
|
|
13108
13200
|
const lines = fs39.readFileSync(README, "utf8").split("\n");
|
|
13109
13201
|
let changed = false;
|
|
@@ -13253,14 +13345,14 @@ function collectSources(sources2, card, host2) {
|
|
|
13253
13345
|
const active3 = /* @__PURE__ */ new Set();
|
|
13254
13346
|
const out = [];
|
|
13255
13347
|
const visit = (src, types, owner, partial = false) => {
|
|
13256
|
-
const
|
|
13348
|
+
const path89 = src.replace(/[?#].*$/, "");
|
|
13257
13349
|
let resolved2;
|
|
13258
13350
|
try {
|
|
13259
|
-
resolved2 = host2.resolve(
|
|
13351
|
+
resolved2 = host2.resolve(path89, owner);
|
|
13260
13352
|
} catch (error) {
|
|
13261
13353
|
if (owner !== card) return { key: null, error: why(error) };
|
|
13262
13354
|
if (!nodes.has(src)) {
|
|
13263
|
-
const node2 = { key: src, file: null, kind: kindAt(
|
|
13355
|
+
const node2 = { key: src, file: null, kind: kindAt(path89, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
|
|
13264
13356
|
nodes.set(src, node2);
|
|
13265
13357
|
out.push(node2);
|
|
13266
13358
|
}
|
|
@@ -13350,15 +13442,15 @@ var init_collect = __esm({
|
|
|
13350
13442
|
|
|
13351
13443
|
// src/lib/dress-page.ts
|
|
13352
13444
|
import fs40 from "node:fs";
|
|
13353
|
-
import
|
|
13445
|
+
import path45 from "node:path";
|
|
13354
13446
|
function dressPage(file2) {
|
|
13355
|
-
const folder =
|
|
13447
|
+
const folder = path45.dirname(file2);
|
|
13356
13448
|
const html = fs40.readFileSync(file2, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
|
|
13357
13449
|
const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
|
|
13358
13450
|
if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
|
|
13359
|
-
const at3 =
|
|
13360
|
-
if (!at3.startsWith(folder +
|
|
13361
|
-
const css = fs40.readFileSync(at3, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole2, quote, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole2 : `url(${quote}${
|
|
13451
|
+
const at3 = path45.resolve(folder, href);
|
|
13452
|
+
if (!at3.startsWith(folder + path45.sep) || !fs40.existsSync(at3)) return tag;
|
|
13453
|
+
const css = fs40.readFileSync(at3, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole2, quote, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole2 : `url(${quote}${path45.relative(folder, path45.resolve(path45.dirname(at3), src)).split(path45.sep).join("/")}${quote})`);
|
|
13362
13454
|
return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
|
|
13363
13455
|
});
|
|
13364
13456
|
const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
|
|
@@ -13376,17 +13468,17 @@ var init_dress_page = __esm({
|
|
|
13376
13468
|
|
|
13377
13469
|
// src/lib/preview-files.ts
|
|
13378
13470
|
import fs41 from "node:fs";
|
|
13379
|
-
import
|
|
13471
|
+
import path46 from "node:path";
|
|
13380
13472
|
function resolver(card, id) {
|
|
13381
|
-
const roots = [KANBAN,
|
|
13473
|
+
const roots = [KANBAN, path46.join(ASSETS, String(id))];
|
|
13382
13474
|
const real2 = (p2) => fs41.existsSync(p2) ? fs41.realpathSync(p2) : p2;
|
|
13383
|
-
const inside2 = (p2) => roots.some((root2) => p2.startsWith(real2(root2) +
|
|
13475
|
+
const inside2 = (p2) => roots.some((root2) => p2.startsWith(real2(root2) + path46.sep));
|
|
13384
13476
|
return (src, owner) => {
|
|
13385
13477
|
if (/^[a-z][\w+.-]*:/i.test(src) || src.startsWith("#") || src.startsWith("//")) return null;
|
|
13386
|
-
if (
|
|
13478
|
+
if (path46.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
|
|
13387
13479
|
const held4 = /^\.assets\//.exec(src);
|
|
13388
|
-
const file2 = held4 ?
|
|
13389
|
-
if (!inside2(
|
|
13480
|
+
const file2 = held4 ? path46.resolve(ASSETS, src.slice(held4[0].length)) : path46.resolve(path46.dirname(owner), src);
|
|
13481
|
+
if (!inside2(path46.resolve(file2)) || fs41.existsSync(file2) && !inside2(fs41.realpathSync(file2))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
|
|
13390
13482
|
if (!fs41.statSync(file2, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
|
|
13391
13483
|
return { key: fs41.realpathSync(file2), file: file2 };
|
|
13392
13484
|
};
|
|
@@ -13432,7 +13524,7 @@ var init_preview_files = __esm({
|
|
|
13432
13524
|
|
|
13433
13525
|
// src/lib/spec-contract.ts
|
|
13434
13526
|
import fs42 from "node:fs";
|
|
13435
|
-
import
|
|
13527
|
+
import path47 from "node:path";
|
|
13436
13528
|
function scanCardLines(lines, start = 0) {
|
|
13437
13529
|
const visible = lines.map(() => "");
|
|
13438
13530
|
let fence = null;
|
|
@@ -13467,8 +13559,8 @@ function snapshotSpecs() {
|
|
|
13467
13559
|
const out = /* @__PURE__ */ new Map();
|
|
13468
13560
|
if (!fs42.existsSync(TODO)) return out;
|
|
13469
13561
|
for (const file2 of walkMd(TODO)) {
|
|
13470
|
-
if (isLegacyRecurring(
|
|
13471
|
-
const id = idPrefix(
|
|
13562
|
+
if (isLegacyRecurring(path47.relative(TODO, file2))) continue;
|
|
13563
|
+
const id = idPrefix(path47.basename(file2) === "root.md" ? path47.basename(path47.dirname(file2)) : path47.basename(file2));
|
|
13472
13564
|
if (id !== null) out.set(file2, { id, text: fs42.readFileSync(file2, "utf8") });
|
|
13473
13565
|
}
|
|
13474
13566
|
return out;
|
|
@@ -13476,7 +13568,7 @@ function snapshotSpecs() {
|
|
|
13476
13568
|
function enclosingGroups(file2) {
|
|
13477
13569
|
const ids = [];
|
|
13478
13570
|
for (let root2 = enclosingGroupRoot(file2); root2; root2 = enclosingGroupRoot(root2)) {
|
|
13479
|
-
const id = idPrefix(
|
|
13571
|
+
const id = idPrefix(path47.basename(path47.dirname(root2)));
|
|
13480
13572
|
if (id !== null) ids.push(id);
|
|
13481
13573
|
}
|
|
13482
13574
|
return ids;
|
|
@@ -13652,8 +13744,8 @@ function setEnd(lines, at2) {
|
|
|
13652
13744
|
function inside(dir, name) {
|
|
13653
13745
|
try {
|
|
13654
13746
|
const root2 = fs42.realpathSync(dir);
|
|
13655
|
-
const real2 = fs42.realpathSync(
|
|
13656
|
-
return real2.startsWith(root2 +
|
|
13747
|
+
const real2 = fs42.realpathSync(path47.join(dir, name));
|
|
13748
|
+
return real2.startsWith(root2 + path47.sep) && fs42.statSync(real2).isFile() ? real2 : null;
|
|
13657
13749
|
} catch {
|
|
13658
13750
|
return null;
|
|
13659
13751
|
}
|
|
@@ -13671,7 +13763,7 @@ function variantsProblem(raw, src, id) {
|
|
|
13671
13763
|
if (files.length < 2 || !files.every((f2) => typeof f2 === "string" && f2)) return `variants needs at least two labels, each naming a file. ${shape}`;
|
|
13672
13764
|
if (!files.includes(src)) return `src="${src}" is not one of the variants. Set src to the version shown first.`;
|
|
13673
13765
|
if (id === void 0) return null;
|
|
13674
|
-
const dir =
|
|
13766
|
+
const dir = path47.join(ASSETS, String(id));
|
|
13675
13767
|
for (const f2 of files) {
|
|
13676
13768
|
const parts = f2.split("/");
|
|
13677
13769
|
if (parts.length !== 3 || parts[0] !== ".assets" || parts[1] !== String(id) || !inside(dir, parts[2])) {
|
|
@@ -13681,7 +13773,7 @@ function variantsProblem(raw, src, id) {
|
|
|
13681
13773
|
return null;
|
|
13682
13774
|
}
|
|
13683
13775
|
function compareProblem(attrs, id) {
|
|
13684
|
-
const dir =
|
|
13776
|
+
const dir = path47.join(ASSETS, String(id));
|
|
13685
13777
|
const src = (message) => ({ rule: "compare-src", message });
|
|
13686
13778
|
const shots = (message) => ({ rule: "compare-shots", message });
|
|
13687
13779
|
const json = (file2) => {
|
|
@@ -13729,7 +13821,7 @@ function compareProblem(attrs, id) {
|
|
|
13729
13821
|
}
|
|
13730
13822
|
function validateStoryboards(file2, id, text6) {
|
|
13731
13823
|
const errors = [];
|
|
13732
|
-
const dir =
|
|
13824
|
+
const dir = path47.join(ASSETS, String(id));
|
|
13733
13825
|
for (const [tag, tagOf, rule, fix] of [
|
|
13734
13826
|
["Storyboard", storyboardTag, "storyboard-src", "Write the JSON there or fix the path."],
|
|
13735
13827
|
["Studio", studioTag, "studio-src", "Write it with `akb raw studio diagram <studio id> <card id>` or fix the path."]
|
|
@@ -13764,13 +13856,13 @@ var init_spec_contract = __esm({
|
|
|
13764
13856
|
|
|
13765
13857
|
// src/lib/reconcile.ts
|
|
13766
13858
|
import fs43 from "node:fs";
|
|
13767
|
-
import
|
|
13859
|
+
import path48 from "node:path";
|
|
13768
13860
|
function liveIds() {
|
|
13769
13861
|
const ids = /* @__PURE__ */ new Set();
|
|
13770
13862
|
for (const file2 of walkMd(TODO)) {
|
|
13771
|
-
const base =
|
|
13863
|
+
const base = path48.basename(file2);
|
|
13772
13864
|
if (base === "README.md") continue;
|
|
13773
|
-
const id = base === "root.md" ? idPrefix(
|
|
13865
|
+
const id = base === "root.md" ? idPrefix(path48.basename(path48.dirname(file2))) : idPrefix(base);
|
|
13774
13866
|
if (id != null) ids.add(id);
|
|
13775
13867
|
}
|
|
13776
13868
|
return ids;
|
|
@@ -13778,16 +13870,16 @@ function liveIds() {
|
|
|
13778
13870
|
function indexableCards() {
|
|
13779
13871
|
const out = [];
|
|
13780
13872
|
for (const dir of walkDirs(TODO)) {
|
|
13781
|
-
const id = idPrefix(
|
|
13782
|
-
if (id != null && fs43.existsSync(
|
|
13783
|
-
out.push({ id, rel:
|
|
13873
|
+
const id = idPrefix(path48.basename(dir));
|
|
13874
|
+
if (id != null && fs43.existsSync(path48.join(dir, "root.md"))) {
|
|
13875
|
+
out.push({ id, rel: path48.join(path48.relative(TODO, dir), "root.md").split(path48.sep).join("/") });
|
|
13784
13876
|
}
|
|
13785
13877
|
}
|
|
13786
13878
|
for (const file2 of walkMd(TODO)) {
|
|
13787
|
-
const base =
|
|
13879
|
+
const base = path48.basename(file2);
|
|
13788
13880
|
if (base === "README.md" || base === "root.md") continue;
|
|
13789
|
-
const relTODO =
|
|
13790
|
-
const segs = relTODO.split(
|
|
13881
|
+
const relTODO = path48.relative(TODO, file2);
|
|
13882
|
+
const segs = relTODO.split(path48.sep);
|
|
13791
13883
|
if (segs.length !== 1) continue;
|
|
13792
13884
|
const id = idPrefix(base);
|
|
13793
13885
|
if (id != null) out.push({ id, rel: segs.join("/") });
|
|
@@ -13805,13 +13897,13 @@ function readmeComplaints(fix) {
|
|
|
13805
13897
|
const id = Number(m[1]);
|
|
13806
13898
|
const linkPath = m[2];
|
|
13807
13899
|
indexed.add(id);
|
|
13808
|
-
if (fs43.existsSync(
|
|
13900
|
+
if (fs43.existsSync(path48.join(TODO, linkPath))) continue;
|
|
13809
13901
|
const found2 = locate2(id);
|
|
13810
13902
|
if (!found2) {
|
|
13811
13903
|
said2.push(`README links #${id} \u2192 ${linkPath}, but no card with that id exists (removed by hand?). Drop the entry or restore the file.`);
|
|
13812
13904
|
continue;
|
|
13813
13905
|
}
|
|
13814
|
-
const want = (found2.kind === "group" ?
|
|
13906
|
+
const want = (found2.kind === "group" ? path48.join(found2.rel, "root.md") : found2.rel).split(path48.sep).join("/");
|
|
13815
13907
|
if (want === linkPath) continue;
|
|
13816
13908
|
if (!fix) {
|
|
13817
13909
|
said2.push(`README links #${id} \u2192 ${linkPath}, which isn't there any more; the card is at ${want}.`);
|
|
@@ -13833,9 +13925,9 @@ function crossRefComplaints() {
|
|
|
13833
13925
|
const said2 = [];
|
|
13834
13926
|
const live = liveIds();
|
|
13835
13927
|
for (const file2 of walkMd(TODO)) {
|
|
13836
|
-
const base =
|
|
13928
|
+
const base = path48.basename(file2);
|
|
13837
13929
|
if (base === "README.md") continue;
|
|
13838
|
-
const ownerId = base === "root.md" ? idPrefix(
|
|
13930
|
+
const ownerId = base === "root.md" ? idPrefix(path48.basename(path48.dirname(file2))) : idPrefix(base);
|
|
13839
13931
|
if (ownerId == null) continue;
|
|
13840
13932
|
const { meta } = parseFrontmatter(fs43.readFileSync(file2, "utf8"));
|
|
13841
13933
|
if (!meta) continue;
|
|
@@ -13867,7 +13959,7 @@ var init_reconcile = __esm({
|
|
|
13867
13959
|
|
|
13868
13960
|
// src/commands/card.ts
|
|
13869
13961
|
import fs44 from "node:fs";
|
|
13870
|
-
import
|
|
13962
|
+
import path49 from "node:path";
|
|
13871
13963
|
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>") {
|
|
13872
13964
|
return [
|
|
13873
13965
|
summary2,
|
|
@@ -13958,9 +14050,9 @@ function cmdCreate(opts) {
|
|
|
13958
14050
|
const start = opts.id;
|
|
13959
14051
|
const slug = slugify(opts.slug !== void 0 ? opts.slug : title);
|
|
13960
14052
|
const fileRel = `${start}-${slug}.md`;
|
|
13961
|
-
const file2 =
|
|
14053
|
+
const file2 = path49.join(TODO, fileRel);
|
|
13962
14054
|
const held4 = locate2(start) ?? locateArchived(start);
|
|
13963
|
-
if (held4 &&
|
|
14055
|
+
if (held4 && path49.basename(held4.target) === `${start}-${slug}.md`) {
|
|
13964
14056
|
say(start);
|
|
13965
14057
|
say(` ${rel(held4.target)} was already written`);
|
|
13966
14058
|
return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
|
|
@@ -14023,7 +14115,7 @@ function cmdUpdate(id, flags) {
|
|
|
14023
14115
|
if (creating) die(creating, { kind: "card-being-created", id });
|
|
14024
14116
|
const found2 = locate2(id);
|
|
14025
14117
|
if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
|
|
14026
|
-
const file2 = found2.kind === "group" ?
|
|
14118
|
+
const file2 = found2.kind === "group" ? path49.join(found2.target, "root.md") : found2.target;
|
|
14027
14119
|
const { meta, body } = parseFrontmatter(fs44.readFileSync(file2, "utf8"));
|
|
14028
14120
|
if (!meta) die(`${rel(file2)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
|
|
14029
14121
|
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");
|
|
@@ -14098,26 +14190,26 @@ function cmdUpdate(id, flags) {
|
|
|
14098
14190
|
meta.status = "todo";
|
|
14099
14191
|
changes.push("status\u2192todo (open questions)");
|
|
14100
14192
|
}
|
|
14101
|
-
const curRel =
|
|
14193
|
+
const curRel = path49.relative(TODO, file2);
|
|
14102
14194
|
const isSubtask = found2.kind === "file" && enclosingGroupRoot(file2) !== null;
|
|
14103
|
-
let base =
|
|
14195
|
+
let base = path49.basename(file2);
|
|
14104
14196
|
if (flags.slug !== void 0) {
|
|
14105
14197
|
if (found2.kind === "group") die("renaming a group root by script is not supported");
|
|
14106
14198
|
base = `${id}-${slugify(flags.slug)}.md`;
|
|
14107
14199
|
}
|
|
14108
|
-
const destRel =
|
|
14109
|
-
const dest =
|
|
14200
|
+
const destRel = path49.join(path49.dirname(curRel), base);
|
|
14201
|
+
const dest = path49.join(TODO, destRel);
|
|
14110
14202
|
const moving = dest !== file2;
|
|
14111
14203
|
if (moving && fs44.existsSync(dest)) die(`${rel(dest)} already exists`);
|
|
14112
14204
|
fs44.writeFileSync(file2, serializeFrontmatter(meta) + "\n" + body);
|
|
14113
14205
|
if (moving) fs44.renameSync(file2, dest);
|
|
14114
14206
|
if (isSubtask) {
|
|
14115
14207
|
if (moving || changes.includes("title")) repointReadmeLink(id, curRel, destRel, meta.title);
|
|
14116
|
-
if (moving) changes.push(`renamed \u2192 ${destRel.split(
|
|
14208
|
+
if (moving) changes.push(`renamed \u2192 ${destRel.split(path49.sep).join("/")}`);
|
|
14117
14209
|
} else if (moving) {
|
|
14118
14210
|
stripReadmeRefs({ kind: "file", rel: curRel });
|
|
14119
14211
|
addReadmeRef(id, meta.title, destRel);
|
|
14120
|
-
changes.push(`renamed \u2192 ${destRel.split(
|
|
14212
|
+
changes.push(`renamed \u2192 ${destRel.split(path49.sep).join("/")}`);
|
|
14121
14213
|
} else if (changes.includes("title")) {
|
|
14122
14214
|
stripReadmeRefs({ kind: "file", rel: curRel });
|
|
14123
14215
|
addReadmeRef(id, meta.title, curRel);
|
|
@@ -14129,7 +14221,7 @@ function cmdUpdateQuestions(id, input) {
|
|
|
14129
14221
|
const ops = readQuestionOps(input.ops ?? []);
|
|
14130
14222
|
const found2 = locate2(id);
|
|
14131
14223
|
if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
|
|
14132
|
-
const file2 = found2.kind === "group" ?
|
|
14224
|
+
const file2 = found2.kind === "group" ? path49.join(found2.target, "root.md") : found2.target;
|
|
14133
14225
|
const { meta, body } = parseFrontmatter(fs44.readFileSync(file2, "utf8"));
|
|
14134
14226
|
if (!meta) die(`${rel(file2)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
|
|
14135
14227
|
for (const op of ops) {
|
|
@@ -14372,7 +14464,7 @@ var init_scheduled = __esm({
|
|
|
14372
14464
|
|
|
14373
14465
|
// src/lib/card-age.ts
|
|
14374
14466
|
import fs46 from "node:fs";
|
|
14375
|
-
import
|
|
14467
|
+
import path50 from "node:path";
|
|
14376
14468
|
function staleAfterIn(config) {
|
|
14377
14469
|
const days = Number(LINE.exec(config)?.[1]);
|
|
14378
14470
|
return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
|
|
@@ -14382,14 +14474,14 @@ function staleAfter() {
|
|
|
14382
14474
|
return staleAfterIn(fs46.readFileSync(CONFIG, "utf8"));
|
|
14383
14475
|
}
|
|
14384
14476
|
function todoPathspec(top) {
|
|
14385
|
-
const from =
|
|
14386
|
-
if (!from || from.startsWith("..") ||
|
|
14387
|
-
return from.split(
|
|
14477
|
+
const from = path50.relative(real(top), real(TODO));
|
|
14478
|
+
if (!from || from.startsWith("..") || path50.isAbsolute(from)) return null;
|
|
14479
|
+
return from.split(path50.sep).join("/");
|
|
14388
14480
|
}
|
|
14389
14481
|
function cardFile(spec, printed) {
|
|
14390
14482
|
const p2 = unquotePath(printed);
|
|
14391
14483
|
if (!p2.startsWith(`${spec}/`)) return null;
|
|
14392
|
-
return
|
|
14484
|
+
return path50.join(TODO, ...p2.slice(spec.length + 1).split("/"));
|
|
14393
14485
|
}
|
|
14394
14486
|
function dirtyCards(top, spec) {
|
|
14395
14487
|
const out = git(["status", "--porcelain", "--untracked-files=all", "--", spec], top);
|
|
@@ -14438,7 +14530,7 @@ var init_card_age = __esm({
|
|
|
14438
14530
|
try {
|
|
14439
14531
|
return fs46.realpathSync(p2);
|
|
14440
14532
|
} catch {
|
|
14441
|
-
return
|
|
14533
|
+
return path50.resolve(p2);
|
|
14442
14534
|
}
|
|
14443
14535
|
};
|
|
14444
14536
|
unquotePath = (line) => {
|
|
@@ -14473,7 +14565,7 @@ var init_card_holds = __esm({
|
|
|
14473
14565
|
|
|
14474
14566
|
// src/commands/list.ts
|
|
14475
14567
|
import fs47 from "node:fs";
|
|
14476
|
-
import
|
|
14568
|
+
import path51 from "node:path";
|
|
14477
14569
|
function summaryLine(body) {
|
|
14478
14570
|
const lines = body.split("\n");
|
|
14479
14571
|
let i = 0;
|
|
@@ -14489,12 +14581,12 @@ function summaryLine(body) {
|
|
|
14489
14581
|
function openRows() {
|
|
14490
14582
|
const rows = [];
|
|
14491
14583
|
for (const file2 of walkMd(TODO)) {
|
|
14492
|
-
const base =
|
|
14584
|
+
const base = path51.basename(file2);
|
|
14493
14585
|
if (base === "README.md") continue;
|
|
14494
14586
|
const isRoot = base === "root.md";
|
|
14495
|
-
const id = isRoot ? idPrefix(
|
|
14587
|
+
const id = isRoot ? idPrefix(path51.basename(path51.dirname(file2))) : idPrefix(base);
|
|
14496
14588
|
if (id == null) continue;
|
|
14497
|
-
if (isLegacyRecurring(
|
|
14589
|
+
if (isLegacyRecurring(path51.relative(TODO, file2))) continue;
|
|
14498
14590
|
const { meta, body } = parseFrontmatter(fs47.readFileSync(file2, "utf8"));
|
|
14499
14591
|
rows.push({
|
|
14500
14592
|
id,
|
|
@@ -14539,12 +14631,12 @@ function archivedFiles() {
|
|
|
14539
14631
|
const files = /* @__PURE__ */ new Map();
|
|
14540
14632
|
if (!fs47.existsSync(ARCHIVE)) return files;
|
|
14541
14633
|
for (const file2 of walkMd(ARCHIVE)) {
|
|
14542
|
-
const id = idPrefix(
|
|
14634
|
+
const id = idPrefix(path51.basename(file2));
|
|
14543
14635
|
if (id !== null) files.set(id, file2);
|
|
14544
14636
|
}
|
|
14545
14637
|
for (const dir of walkDirs(ARCHIVE)) {
|
|
14546
|
-
const id = idPrefix(
|
|
14547
|
-
const root2 =
|
|
14638
|
+
const id = idPrefix(path51.basename(dir));
|
|
14639
|
+
const root2 = path51.join(dir, "root.md");
|
|
14548
14640
|
if (id !== null && fs47.existsSync(root2)) files.set(id, root2);
|
|
14549
14641
|
}
|
|
14550
14642
|
return files;
|
|
@@ -14655,10 +14747,10 @@ var init_list = __esm({
|
|
|
14655
14747
|
});
|
|
14656
14748
|
|
|
14657
14749
|
// src/lib/agent/creation-lock.ts
|
|
14658
|
-
import
|
|
14750
|
+
import path52 from "node:path";
|
|
14659
14751
|
function withCreationLock(fn2) {
|
|
14660
14752
|
if (depth2) return fn2();
|
|
14661
|
-
return withLock(
|
|
14753
|
+
return withLock(path52.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
|
|
14662
14754
|
depth2++;
|
|
14663
14755
|
try {
|
|
14664
14756
|
return fn2();
|
|
@@ -14695,11 +14787,11 @@ var init_group_close = __esm({
|
|
|
14695
14787
|
|
|
14696
14788
|
// src/commands/remove.ts
|
|
14697
14789
|
import fs49 from "node:fs";
|
|
14698
|
-
import
|
|
14790
|
+
import path53 from "node:path";
|
|
14699
14791
|
function leavingIds(id, found2) {
|
|
14700
14792
|
const ids = /* @__PURE__ */ new Set([id]);
|
|
14701
14793
|
if (found2.kind === "group") {
|
|
14702
|
-
const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) =>
|
|
14794
|
+
const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) => path53.basename(f2));
|
|
14703
14795
|
for (const name of names3) {
|
|
14704
14796
|
const n = idPrefix(name);
|
|
14705
14797
|
if (n !== null) ids.add(n);
|
|
@@ -14713,7 +14805,7 @@ function findMentions(ids) {
|
|
|
14713
14805
|
for (const dir of [TODO, MEMORY]) {
|
|
14714
14806
|
if (!fs49.existsSync(dir)) continue;
|
|
14715
14807
|
for (const file2 of walkMd(dir)) {
|
|
14716
|
-
if (
|
|
14808
|
+
if (path53.basename(file2) === "README.md") continue;
|
|
14717
14809
|
const lines = fs49.readFileSync(file2, "utf8").split("\n");
|
|
14718
14810
|
const fmEnd = frontmatterEnd(lines);
|
|
14719
14811
|
lines.forEach((line, i) => {
|
|
@@ -14730,12 +14822,12 @@ function findMentions(ids) {
|
|
|
14730
14822
|
return hits;
|
|
14731
14823
|
}
|
|
14732
14824
|
function leavingCards(id, found2) {
|
|
14733
|
-
const own = found2.kind === "group" ?
|
|
14825
|
+
const own = found2.kind === "group" ? path53.join(found2.target, "root.md") : found2.target;
|
|
14734
14826
|
const cards = [{ id, file: own }];
|
|
14735
14827
|
if (found2.kind !== "group") return cards;
|
|
14736
14828
|
for (const file2 of walkMd(found2.target)) {
|
|
14737
14829
|
if (file2 === own) continue;
|
|
14738
|
-
const n = idPrefix(
|
|
14830
|
+
const n = idPrefix(path53.basename(file2));
|
|
14739
14831
|
if (n !== null) cards.push({ id: n, file: file2 });
|
|
14740
14832
|
}
|
|
14741
14833
|
return cards;
|
|
@@ -14776,7 +14868,7 @@ function removeCard(id, metric, options) {
|
|
|
14776
14868
|
const found2 = locate2(id);
|
|
14777
14869
|
if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
|
|
14778
14870
|
const dest = options.cleanupDiscarded && locateArchived(id) ? null : archiveDest(found2);
|
|
14779
|
-
const cardFile3 = found2.kind === "group" ?
|
|
14871
|
+
const cardFile3 = found2.kind === "group" ? path53.join(found2.target, "root.md") : found2.target;
|
|
14780
14872
|
const cardText = fs49.existsSync(cardFile3) ? fs49.readFileSync(cardFile3, "utf8") : "";
|
|
14781
14873
|
const { meta: cardMeta3 } = parseFrontmatter(cardText);
|
|
14782
14874
|
const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f2) => f2 !== cardFile3).map((f2) => rel(f2)).sort() : [];
|
|
@@ -14860,7 +14952,7 @@ function removeCard(id, metric, options) {
|
|
|
14860
14952
|
};
|
|
14861
14953
|
}
|
|
14862
14954
|
function closeGroup(rootFile) {
|
|
14863
|
-
const rootId = idPrefix(
|
|
14955
|
+
const rootId = idPrefix(path53.basename(path53.dirname(rootFile)));
|
|
14864
14956
|
if (rootId === null) return null;
|
|
14865
14957
|
if (runnerProject(KANBAN)) return null;
|
|
14866
14958
|
if (!groupCloses(rootFile)) return null;
|
|
@@ -14924,7 +15016,7 @@ function cleanupDiscardedCards(sessionId) {
|
|
|
14924
15016
|
if (card.pending) throw new Error(`Discarding #${card.id} did not finish. Retry the discard.`);
|
|
14925
15017
|
while (locate2(card.id)) cmdRemove(card.id, "rejected", { discard: true, cleanupDiscarded: true });
|
|
14926
15018
|
dropCrossRefs(card.id);
|
|
14927
|
-
stripReadmeRefs({ kind: "file", rel:
|
|
15019
|
+
stripReadmeRefs({ kind: "file", rel: path53.relative(TODO, path53.resolve(REPO_ROOT, card.path)).split(path53.sep).join("/") });
|
|
14928
15020
|
}
|
|
14929
15021
|
return discarded.map((c2) => c2.id);
|
|
14930
15022
|
});
|
|
@@ -14932,7 +15024,7 @@ function cleanupDiscardedCards(sessionId) {
|
|
|
14932
15024
|
function recoveredArchiveHandoff(id, source2) {
|
|
14933
15025
|
const found2 = locateArchived(id);
|
|
14934
15026
|
if (!found2) throw new Error(`No archived card #${id} was found.`);
|
|
14935
|
-
const file2 = found2.kind === "group" ?
|
|
15027
|
+
const file2 = found2.kind === "group" ? path53.join(found2.target, "root.md") : found2.target;
|
|
14936
15028
|
const { meta } = parseFrontmatter(fs49.readFileSync(file2, "utf8"));
|
|
14937
15029
|
stripReadmeRefs(source2 ?? found2);
|
|
14938
15030
|
const root2 = source2?.kind === "file" ? enclosingGroupRoot(source2.target) : null;
|
|
@@ -15011,7 +15103,7 @@ var init_agent_file = __esm({
|
|
|
15011
15103
|
|
|
15012
15104
|
// src/lib/agent/studio-shared.ts
|
|
15013
15105
|
import fs50 from "node:fs";
|
|
15014
|
-
import
|
|
15106
|
+
import path54 from "node:path";
|
|
15015
15107
|
function studioFiles(studio) {
|
|
15016
15108
|
const flow = cloudFlows().find((f2) => f2.def.id === studio || f2.cloudId === studio);
|
|
15017
15109
|
if (flow) return flow.files;
|
|
@@ -15027,7 +15119,7 @@ function readStudioMemory(studio) {
|
|
|
15027
15119
|
}
|
|
15028
15120
|
return names3.flatMap((name) => {
|
|
15029
15121
|
try {
|
|
15030
|
-
return [{ name, text: fs50.readFileSync(
|
|
15122
|
+
return [{ name, text: fs50.readFileSync(path54.join(dir, name), "utf8").trim() }];
|
|
15031
15123
|
} catch {
|
|
15032
15124
|
return [];
|
|
15033
15125
|
}
|
|
@@ -15068,7 +15160,7 @@ var init_studio_shared = __esm({
|
|
|
15068
15160
|
init_command();
|
|
15069
15161
|
init_cloud_studios();
|
|
15070
15162
|
sharedFiles = (files) => Object.keys(files).filter((f2) => f2.startsWith(SHARED_DIR) && f2 !== RULES_FILE).sort();
|
|
15071
|
-
studioMemoryDir = (studio) =>
|
|
15163
|
+
studioMemoryDir = (studio) => path54.join(MEMORY, STUDIO_MEMORY_DIR, studio);
|
|
15072
15164
|
fileLine = (studio, file2) => `- \`${file2}\` \u2014 \`${rawMove(`file ${studio} ${file2}`)}\``;
|
|
15073
15165
|
studioHoldsAgent = (studio, agent) => !!studio && Object.keys(studioFiles(studio) ?? {}).some((f2) => f2.startsWith(`agents/${agent}/`));
|
|
15074
15166
|
}
|
|
@@ -15122,7 +15214,7 @@ var init_bundled2 = __esm({
|
|
|
15122
15214
|
|
|
15123
15215
|
// src/lib/memories.ts
|
|
15124
15216
|
import fs51 from "node:fs";
|
|
15125
|
-
import
|
|
15217
|
+
import path55 from "node:path";
|
|
15126
15218
|
function readMemory(text6, builtIn, folder) {
|
|
15127
15219
|
const { meta, body } = splitFrontmatter(text6);
|
|
15128
15220
|
if (meta === null) return null;
|
|
@@ -15142,7 +15234,7 @@ function readMemory(text6, builtIn, folder) {
|
|
|
15142
15234
|
rules: body.trim(),
|
|
15143
15235
|
text: text6,
|
|
15144
15236
|
builtIn,
|
|
15145
|
-
dir:
|
|
15237
|
+
dir: path55.join(MEMORY, folder)
|
|
15146
15238
|
};
|
|
15147
15239
|
}
|
|
15148
15240
|
function globalMemories() {
|
|
@@ -15158,7 +15250,7 @@ function globalMemories() {
|
|
|
15158
15250
|
}
|
|
15159
15251
|
for (const name of folders2) {
|
|
15160
15252
|
if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR || name === STUDIO_MEMORY_DIR) continue;
|
|
15161
|
-
const file2 =
|
|
15253
|
+
const file2 = path55.join(MEMORY, name, GLOBAL_MEMORY_FILE);
|
|
15162
15254
|
if (!fs51.existsSync(file2)) continue;
|
|
15163
15255
|
const memory = readMemory(fs51.readFileSync(file2, "utf8"), false, name);
|
|
15164
15256
|
if (memory) out.push(memory);
|
|
@@ -15217,7 +15309,7 @@ var init_memory_file = __esm({
|
|
|
15217
15309
|
// src/commands/inspect.ts
|
|
15218
15310
|
import fs52 from "node:fs";
|
|
15219
15311
|
import os4 from "node:os";
|
|
15220
|
-
import
|
|
15312
|
+
import path56 from "node:path";
|
|
15221
15313
|
function cmdInspect(id) {
|
|
15222
15314
|
const findings = [];
|
|
15223
15315
|
const unavailable = [];
|
|
@@ -15242,7 +15334,7 @@ function cmdInspect(id) {
|
|
|
15242
15334
|
}
|
|
15243
15335
|
const found2 = locate2(id) ?? locateArchived(id);
|
|
15244
15336
|
if (!found2) return die(`no task with id ${id}`, { kind: "card-not-found", id });
|
|
15245
|
-
const file2 = found2.kind === "group" ?
|
|
15337
|
+
const file2 = found2.kind === "group" ? path56.join(found2.target, "root.md") : found2.target;
|
|
15246
15338
|
let card = null;
|
|
15247
15339
|
try {
|
|
15248
15340
|
const { meta, body } = parseFrontmatter(fs52.readFileSync(file2, "utf8"));
|
|
@@ -15252,14 +15344,14 @@ function cmdInspect(id) {
|
|
|
15252
15344
|
findings.push({ source: "card", message: String(error) });
|
|
15253
15345
|
unavailable.push("card");
|
|
15254
15346
|
}
|
|
15255
|
-
const progress = read4("previews",
|
|
15347
|
+
const progress = read4("previews", path56.join(BOARD_STATE, "previews", `${id}.json`), {});
|
|
15256
15348
|
const store = read4("runs", SESSIONS, {});
|
|
15257
15349
|
const runs = fact("runs", () => (store.runs ?? []).filter((run4) => run4.cardId === id).slice(-10).reverse().map((run4) => ({ id: run4.sessionId, status: run4.status, sessionRecorded: run4.harness ? !!(run4.resumeId || run4.continues?.resumeId) : null })), []);
|
|
15258
15350
|
const records = [];
|
|
15259
|
-
const directory =
|
|
15351
|
+
const directory = path56.join(KANBAN, "deliveries");
|
|
15260
15352
|
try {
|
|
15261
15353
|
for (const name of fs52.readdirSync(directory).filter((name2) => name2.endsWith(".json"))) {
|
|
15262
|
-
const held5 = read4("delivery",
|
|
15354
|
+
const held5 = read4("delivery", path56.join(directory, name), null);
|
|
15263
15355
|
if (held5?.cardId === id) records.push(held5);
|
|
15264
15356
|
}
|
|
15265
15357
|
} catch (error) {
|
|
@@ -15271,7 +15363,7 @@ function cmdInspect(id) {
|
|
|
15271
15363
|
records.push(...fact("delivery", () => (store.deliveries ?? []).filter((held5) => held5.cardId === id), []));
|
|
15272
15364
|
const held4 = [...new Map(records.map((held5) => [held5.deliveryId, held5])).values()].sort((a2, b2) => b2.startedAt - a2.startedAt)[0];
|
|
15273
15365
|
const job = executionOf()?.job;
|
|
15274
|
-
const checkpoint = job ? read4("recovery",
|
|
15366
|
+
const checkpoint = job ? read4("recovery", path56.join(process.env.WILDCRANE_HOME || os4.homedir() + "/.wildcrane", "checkpoints", `${encodeURIComponent(job)}.json`), null) : null;
|
|
15275
15367
|
const delivery = fact("delivery", () => held4 ? { id: held4.deliveryId, status: held4.status, directory: held4.worktree ?? REPO_ROOT, completedSteps: (held4.completions ?? []).map((c2) => c2.step) } : null, null);
|
|
15276
15368
|
const recovery = fact("recovery", () => checkpoint ? { pendingOperations: checkpoint.pending ?? [], submitted: checkpoint.submitted ?? null } : null, null);
|
|
15277
15369
|
const result = {
|
|
@@ -15281,7 +15373,7 @@ function cmdInspect(id) {
|
|
|
15281
15373
|
agent,
|
|
15282
15374
|
currentStageId: p2.currentStageId,
|
|
15283
15375
|
stages: p2.stages.map(({ id: id2, status, version }) => ({ id: id2, status, version })),
|
|
15284
|
-
artifact: p2.displayedArtifact ? { stageId: p2.displayedArtifact.stageId, version: p2.displayedArtifact.version, section: `## By \`${agent}\` agent`, files: [.../* @__PURE__ */ new Set([...Object.keys(p2.displayedArtifact.assets).filter((key) => key !== "folder"), ...bodySources(p2.displayedArtifact.body)])].filter((file3) => !
|
|
15376
|
+
artifact: p2.displayedArtifact ? { stageId: p2.displayedArtifact.stageId, version: p2.displayedArtifact.version, section: `## By \`${agent}\` agent`, files: [.../* @__PURE__ */ new Set([...Object.keys(p2.displayedArtifact.assets).filter((key) => key !== "folder"), ...bodySources(p2.displayedArtifact.body)])].filter((file3) => !path56.isAbsolute(file3) && !/^[a-z][\w+.-]*:/i.test(file3)) } : null
|
|
15285
15377
|
})), []),
|
|
15286
15378
|
delivery,
|
|
15287
15379
|
runs,
|
|
@@ -15372,7 +15464,7 @@ var init_ops = __esm({
|
|
|
15372
15464
|
|
|
15373
15465
|
// src/lib/view/stamp.ts
|
|
15374
15466
|
import fs53 from "node:fs";
|
|
15375
|
-
import
|
|
15467
|
+
import path57 from "node:path";
|
|
15376
15468
|
function boardStamp() {
|
|
15377
15469
|
const parts = [];
|
|
15378
15470
|
for (const dir of [TODO, MEMORY, ASSETS]) walk(dir, parts, 0);
|
|
@@ -15390,7 +15482,7 @@ function walk(dir, parts, depth3) {
|
|
|
15390
15482
|
return;
|
|
15391
15483
|
}
|
|
15392
15484
|
for (const entry of entries.sort((a2, b2) => a2.name.localeCompare(b2.name))) {
|
|
15393
|
-
const full =
|
|
15485
|
+
const full = path57.join(dir, entry.name);
|
|
15394
15486
|
if (entry.isDirectory()) walk(full, parts, depth3 + 1);
|
|
15395
15487
|
else stamp3(full, parts);
|
|
15396
15488
|
}
|
|
@@ -15430,7 +15522,7 @@ var init_contract = __esm({
|
|
|
15430
15522
|
|
|
15431
15523
|
// src/lib/board/revision.ts
|
|
15432
15524
|
import fs54 from "node:fs";
|
|
15433
|
-
import
|
|
15525
|
+
import path58 from "node:path";
|
|
15434
15526
|
function revisionOf(text6) {
|
|
15435
15527
|
let h3 = 2166136261;
|
|
15436
15528
|
for (let i = 0; i < text6.length; i++) {
|
|
@@ -15442,7 +15534,7 @@ function revisionOf(text6) {
|
|
|
15442
15534
|
function cardFile2(id) {
|
|
15443
15535
|
const found2 = locate2(id);
|
|
15444
15536
|
if (!found2) return null;
|
|
15445
|
-
return found2.kind === "group" ?
|
|
15537
|
+
return found2.kind === "group" ? path58.join(found2.target, "root.md") : found2.target;
|
|
15446
15538
|
}
|
|
15447
15539
|
function cardRevision(id) {
|
|
15448
15540
|
const file2 = cardFile2(id);
|
|
@@ -15652,13 +15744,13 @@ var init_board = __esm({
|
|
|
15652
15744
|
|
|
15653
15745
|
// src/lib/plans.ts
|
|
15654
15746
|
import fs55 from "node:fs";
|
|
15655
|
-
import
|
|
15747
|
+
import path59 from "node:path";
|
|
15656
15748
|
function planFile(rel2) {
|
|
15657
15749
|
if (!/^plans\/(archive\/)?[^/\\]+\.md$/.test(rel2)) return null;
|
|
15658
15750
|
const dir = isArchivedPlan(rel2) ? PLANS_ARCHIVE : PLANS;
|
|
15659
15751
|
const name = rel2.replace(/^plans\/(archive\/)?/, "");
|
|
15660
15752
|
if (!name || name.includes("/") || !name.endsWith(".md")) return null;
|
|
15661
|
-
return
|
|
15753
|
+
return path59.join(dir, name);
|
|
15662
15754
|
}
|
|
15663
15755
|
function readPlan(rel2) {
|
|
15664
15756
|
const file2 = planFile(rel2);
|
|
@@ -15692,14 +15784,14 @@ function renamedPlan(rel2) {
|
|
|
15692
15784
|
}
|
|
15693
15785
|
for (const n of names3) {
|
|
15694
15786
|
if (!n.startsWith(`${id}-`) || !n.endsWith(".md")) continue;
|
|
15695
|
-
found2.push({ rel: `${prefix}${n}`, at: fs55.statSync(
|
|
15787
|
+
found2.push({ rel: `${prefix}${n}`, at: fs55.statSync(path59.join(dir, n)).mtimeMs });
|
|
15696
15788
|
}
|
|
15697
15789
|
}
|
|
15698
15790
|
if (!found2.length) return null;
|
|
15699
15791
|
return found2.sort((a2, b2) => b2.at - a2.at)[0].rel;
|
|
15700
15792
|
}
|
|
15701
15793
|
function planFromText(text6) {
|
|
15702
|
-
const local = `${
|
|
15794
|
+
const local = `${path59.dirname(PLANS)}/`;
|
|
15703
15795
|
if (text6.startsWith(local)) text6 = text6.slice(local.length);
|
|
15704
15796
|
if (text6.startsWith(`${KANBAN}/`)) text6 = text6.slice(KANBAN.length + 1);
|
|
15705
15797
|
const here = `${boardPath()}/`;
|
|
@@ -15781,7 +15873,7 @@ var init_own_cost = __esm({
|
|
|
15781
15873
|
|
|
15782
15874
|
// src/lib/agent/pictures.ts
|
|
15783
15875
|
import fs56 from "node:fs";
|
|
15784
|
-
import
|
|
15876
|
+
import path60 from "node:path";
|
|
15785
15877
|
function claimRunPictures(box2, sessionId, names3 = []) {
|
|
15786
15878
|
if (!box2 || !freeBox(box2) || names3.length === 0) return [];
|
|
15787
15879
|
const from = pictureBox(box2);
|
|
@@ -15792,7 +15884,7 @@ function claimRunPictures(box2, sessionId, names3 = []) {
|
|
|
15792
15884
|
} catch {
|
|
15793
15885
|
return [];
|
|
15794
15886
|
}
|
|
15795
|
-
return names3.filter(pictureName).map((name) =>
|
|
15887
|
+
return names3.filter(pictureName).map((name) => path60.join(to, name)).filter((file2) => fs56.existsSync(file2));
|
|
15796
15888
|
}
|
|
15797
15889
|
function returnRunPictures(sessionId, box2) {
|
|
15798
15890
|
if (!box2 || !boxId(box2)) return;
|
|
@@ -15808,7 +15900,7 @@ function moveRunPictures(from, to, files = []) {
|
|
|
15808
15900
|
} catch {
|
|
15809
15901
|
return files;
|
|
15810
15902
|
}
|
|
15811
|
-
return files.map((file2) =>
|
|
15903
|
+
return files.map((file2) => path60.join(pictureBox(to), path60.basename(file2)));
|
|
15812
15904
|
}
|
|
15813
15905
|
var pictureName, boxId, freeBox, pictureBox;
|
|
15814
15906
|
var init_pictures = __esm({
|
|
@@ -15817,8 +15909,8 @@ var init_pictures = __esm({
|
|
|
15817
15909
|
init_paths();
|
|
15818
15910
|
pictureName = (name) => /^[0-9a-f-]{36}\.[a-z0-9]{2,5}$/.test(name);
|
|
15819
15911
|
boxId = (box2) => /^[0-9a-f-]{36}$/.test(box2);
|
|
15820
|
-
freeBox = (box2) => boxId(box2) && !fs56.existsSync(
|
|
15821
|
-
pictureBox = (box2) =>
|
|
15912
|
+
freeBox = (box2) => boxId(box2) && !fs56.existsSync(path60.join(SESSIONS_DIR, `${box2}.log`));
|
|
15913
|
+
pictureBox = (box2) => path60.join(SESSIONS_DIR, `${box2}.images`);
|
|
15822
15914
|
}
|
|
15823
15915
|
});
|
|
15824
15916
|
|
|
@@ -15939,10 +16031,10 @@ var init_facts = __esm({
|
|
|
15939
16031
|
|
|
15940
16032
|
// src/lib/view/archive.ts
|
|
15941
16033
|
import fs57 from "node:fs";
|
|
15942
|
-
import
|
|
16034
|
+
import path61 from "node:path";
|
|
15943
16035
|
function archivedId(file2) {
|
|
15944
|
-
const own = idPrefix(
|
|
15945
|
-
return own !== null ? own : idPrefix(
|
|
16036
|
+
const own = idPrefix(path61.basename(file2));
|
|
16037
|
+
return own !== null ? own : idPrefix(path61.basename(path61.dirname(file2)));
|
|
15946
16038
|
}
|
|
15947
16039
|
function readFile(file2) {
|
|
15948
16040
|
const id = archivedId(file2);
|
|
@@ -15955,14 +16047,14 @@ function readFile(file2) {
|
|
|
15955
16047
|
title: meta.title,
|
|
15956
16048
|
archived: meta.archived,
|
|
15957
16049
|
rejected: meta.rejected,
|
|
15958
|
-
relPath: rel(file2).split(
|
|
16050
|
+
relPath: rel(file2).split(path61.sep).join("/")
|
|
15959
16051
|
},
|
|
15960
16052
|
body: body.replace(/^\n+/, "").replace(/\s+$/, ""),
|
|
15961
16053
|
meta
|
|
15962
16054
|
};
|
|
15963
16055
|
}
|
|
15964
16056
|
function readArchive() {
|
|
15965
|
-
const relPath = rel(ARCHIVE).split(
|
|
16057
|
+
const relPath = rel(ARCHIVE).split(path61.sep).join("/");
|
|
15966
16058
|
if (!fs57.existsSync(ARCHIVE)) return { relPath, cards: [] };
|
|
15967
16059
|
const cards = walkMd(ARCHIVE).map(readFile).filter((found2) => found2 !== null).map((found2) => found2.row);
|
|
15968
16060
|
cards.sort((a2, b2) => b2.id - a2.id);
|
|
@@ -15978,7 +16070,7 @@ var init_archive = __esm({
|
|
|
15978
16070
|
});
|
|
15979
16071
|
|
|
15980
16072
|
// src/lib/agent/prompts.ts
|
|
15981
|
-
import
|
|
16073
|
+
import path62 from "node:path";
|
|
15982
16074
|
function stopReason(deliveryId) {
|
|
15983
16075
|
const delivery = findDelivery(deliveryId);
|
|
15984
16076
|
if (!delivery) return void 0;
|
|
@@ -16032,7 +16124,7 @@ ${text6}` : "";
|
|
|
16032
16124
|
}
|
|
16033
16125
|
function cardFileOf(id) {
|
|
16034
16126
|
const found2 = id === void 0 ? null : locate2(id);
|
|
16035
|
-
return found2 ? found2.kind === "group" ?
|
|
16127
|
+
return found2 ? found2.kind === "group" ? path62.join(found2.target, "root.md") : found2.target : "";
|
|
16036
16128
|
}
|
|
16037
16129
|
function realPaths(text6, req) {
|
|
16038
16130
|
if (req.action !== "scheduled" && req.action !== "sub") return text6;
|
|
@@ -16130,7 +16222,7 @@ function frozenRules(req) {
|
|
|
16130
16222
|
function archivedCardFile(id) {
|
|
16131
16223
|
const found2 = locateArchived(id);
|
|
16132
16224
|
if (!found2) return `${rel(ARCHIVE)}/`;
|
|
16133
|
-
return rel(found2.kind === "group" ?
|
|
16225
|
+
return rel(found2.kind === "group" ? path62.join(found2.target, "root.md") : found2.target);
|
|
16134
16226
|
}
|
|
16135
16227
|
function shippedLines(cardId2) {
|
|
16136
16228
|
const delivery = endedDelivery(`${cardId2}`);
|
|
@@ -16270,7 +16362,7 @@ function actionPrompt(req, command, notes) {
|
|
|
16270
16362
|
case "spec": {
|
|
16271
16363
|
const agent = findSpecAgent(req.specAgent ?? "");
|
|
16272
16364
|
const found2 = req.id === void 0 ? null : locate2(req.id);
|
|
16273
|
-
const cardFile3 = found2 ? rel(found2.kind === "group" ?
|
|
16365
|
+
const cardFile3 = found2 ? rel(found2.kind === "group" ? path62.join(found2.target, "root.md") : found2.target) : `task #${req.id}`;
|
|
16274
16366
|
const own = agent ? specAgentInstructions(agent) : null;
|
|
16275
16367
|
const memory = agent ? agentMemoryBlock(agent) : "";
|
|
16276
16368
|
const shared = agent ? globalMemoryBlock(agent) : "";
|
|
@@ -16675,7 +16767,7 @@ __export(sessions_exports, {
|
|
|
16675
16767
|
});
|
|
16676
16768
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
16677
16769
|
import fs59 from "node:fs";
|
|
16678
|
-
import
|
|
16770
|
+
import path63 from "node:path";
|
|
16679
16771
|
function reap(runs, reaped = [], restore = []) {
|
|
16680
16772
|
let changed = false;
|
|
16681
16773
|
const now = Date.now();
|
|
@@ -16689,7 +16781,7 @@ function reap(runs, reaped = [], restore = []) {
|
|
|
16689
16781
|
stampDuration(r2, r2.endedAt);
|
|
16690
16782
|
restore.push({ ...r2 });
|
|
16691
16783
|
if (r2.deliveryId && r2.action !== "sub") reaped.push({ ...r2 });
|
|
16692
|
-
dropSpec(r2.sessionId);
|
|
16784
|
+
if (r2.harness !== "antigravity") dropSpec(r2.sessionId);
|
|
16693
16785
|
changed = true;
|
|
16694
16786
|
}
|
|
16695
16787
|
return changed;
|
|
@@ -16842,7 +16934,7 @@ function leftBoardOnLanding(id) {
|
|
|
16842
16934
|
function archivedRejected(id) {
|
|
16843
16935
|
const filed = locateArchived(id);
|
|
16844
16936
|
if (!filed) return null;
|
|
16845
|
-
const file2 = filed.kind === "group" ?
|
|
16937
|
+
const file2 = filed.kind === "group" ? path63.join(filed.target, "root.md") : filed.target;
|
|
16846
16938
|
try {
|
|
16847
16939
|
return !!parseFrontmatter(fs59.readFileSync(file2, "utf8")).meta?.rejected;
|
|
16848
16940
|
} catch {
|
|
@@ -17094,7 +17186,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID5(), said2) {
|
|
|
17094
17186
|
return { run: record, spec };
|
|
17095
17187
|
}
|
|
17096
17188
|
function planningSession(cardId2, cwd = REPO_ROOT) {
|
|
17097
|
-
const here = (dir) => !dir ||
|
|
17189
|
+
const here = (dir) => !dir || path63.resolve(dir) === cwd;
|
|
17098
17190
|
const planned = readRuns().filter((r2) => r2.status === "done" && r2.cardId === cardId2 && PLANNING.has(r2.action)).sort((a2, b2) => b2.startedAt - a2.startedAt)[0];
|
|
17099
17191
|
if (!planned) return { none: "unrecorded" };
|
|
17100
17192
|
if (!here(planned.cwd)) return { none: "elsewhere" };
|
|
@@ -17183,6 +17275,9 @@ async function openResume(id, options) {
|
|
|
17183
17275
|
let plan;
|
|
17184
17276
|
let fresh;
|
|
17185
17277
|
const session = forced ? void 0 : resumeSessionId(prev);
|
|
17278
|
+
if (!forced && prev.harness === "antigravity" && !session && !neverStarted(prev)) {
|
|
17279
|
+
return refusal("runNoSession", "Antigravity did not record a conversation ID before interruption. The original session cannot be resumed.");
|
|
17280
|
+
}
|
|
17186
17281
|
if (session) {
|
|
17187
17282
|
plan = planResume({ harness: prev.harness, resumeId: session, cwd }, prev.agent, prev.runtime ? { pin: prev.runtime } : {});
|
|
17188
17283
|
} else {
|
|
@@ -17245,7 +17340,8 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
|
|
|
17245
17340
|
sessionCostFrom: reportsSessionTotal(prev.harness) ? prev.sessionCostUsd ?? prev.sessionCostFrom : void 0,
|
|
17246
17341
|
// The retry chain carries on rather than starting over (#525): this run IS the attempt
|
|
17247
17342
|
// the failed one scheduled, so its count and its window come with it.
|
|
17248
|
-
retry: prev.retry
|
|
17343
|
+
retry: prev.retry,
|
|
17344
|
+
...prev.retry && prev.result ? { result: prev.result } : {}
|
|
17249
17345
|
},
|
|
17250
17346
|
logPath: logPathOf(sessionId),
|
|
17251
17347
|
specAgent: prev.specAgent,
|
|
@@ -17291,8 +17387,10 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
|
|
|
17291
17387
|
r2.pictures = record.pictures;
|
|
17292
17388
|
});
|
|
17293
17389
|
}
|
|
17294
|
-
const
|
|
17390
|
+
const prompt = fresh?.prompt ?? (prev.harness === "antigravity" ? readSpec(prev.sessionId)?.prompt : void 0) ?? "";
|
|
17391
|
+
const spec = { sessionId, plan, prompt, ...fresh?.notes.length ? { notes: fresh.notes } : {} };
|
|
17295
17392
|
writeSpec(spec);
|
|
17393
|
+
if (prev.harness === "antigravity") dropSpec(prev.sessionId);
|
|
17296
17394
|
reportRun("started", record.harness, isCustomAgent(record.agent));
|
|
17297
17395
|
reportBoardNumbers(() => customAgentsOn().length);
|
|
17298
17396
|
return { run: record, spec };
|
|
@@ -17420,7 +17518,7 @@ async function closeRun(sessionId, res) {
|
|
|
17420
17518
|
recordReflection(closed2);
|
|
17421
17519
|
recordProjectDescription(closed2);
|
|
17422
17520
|
recordScheduledRun(closed2);
|
|
17423
|
-
dropSpec(sessionId);
|
|
17521
|
+
if (closed2.harness !== "antigravity" || closed2.status === "done") dropSpec(sessionId);
|
|
17424
17522
|
pruneLogs();
|
|
17425
17523
|
}
|
|
17426
17524
|
async function stopRun(id) {
|
|
@@ -17523,7 +17621,7 @@ function dropSpec(sessionId) {
|
|
|
17523
17621
|
}
|
|
17524
17622
|
async function acquireIndexLock(giveUp) {
|
|
17525
17623
|
const until = Date.now() + INDEX_WAIT_MS;
|
|
17526
|
-
const holder =
|
|
17624
|
+
const holder = path63.join(INDEX_LOCK2, "holder");
|
|
17527
17625
|
for (; ; ) {
|
|
17528
17626
|
if (giveUp()) return null;
|
|
17529
17627
|
try {
|
|
@@ -17533,7 +17631,7 @@ async function acquireIndexLock(giveUp) {
|
|
|
17533
17631
|
} catch (err) {
|
|
17534
17632
|
const code = err.code;
|
|
17535
17633
|
if (code === "ENOENT") {
|
|
17536
|
-
fs59.mkdirSync(
|
|
17634
|
+
fs59.mkdirSync(path63.dirname(INDEX_LOCK2), { recursive: true });
|
|
17537
17635
|
continue;
|
|
17538
17636
|
}
|
|
17539
17637
|
if (code !== "EEXIST") throw err;
|
|
@@ -17635,8 +17733,8 @@ var init_sessions = __esm({
|
|
|
17635
17733
|
implement: "implementing",
|
|
17636
17734
|
hook: "implementing"
|
|
17637
17735
|
};
|
|
17638
|
-
specPathOf = (sessionId) =>
|
|
17639
|
-
asksPathOf = (sessionId) =>
|
|
17736
|
+
specPathOf = (sessionId) => path63.join(SESSIONS_DIR, `${sessionId}.plan.json`);
|
|
17737
|
+
asksPathOf = (sessionId) => path63.join(SESSIONS_DIR, `${sessionId}.asks.json`);
|
|
17640
17738
|
carriesSession = (r2) => !!(r2.resumedFrom || r2.continues && !r2.continues.fork);
|
|
17641
17739
|
canPickUp = (r2) => r2.status === "error" || r2.status === "interrupted" || r2.status === "stopped";
|
|
17642
17740
|
neverStarted = (r2) => r2.unspawned === true || !!r2.errorWhy?.some((why2) => why2.kind === "notInstalled");
|
|
@@ -17664,7 +17762,7 @@ var init_sessions = __esm({
|
|
|
17664
17762
|
|
|
17665
17763
|
// src/lib/card-sources.ts
|
|
17666
17764
|
import fs60 from "node:fs";
|
|
17667
|
-
import
|
|
17765
|
+
import path64 from "node:path";
|
|
17668
17766
|
function planById(id) {
|
|
17669
17767
|
const found2 = readPlan(`plans/${id}-.md`);
|
|
17670
17768
|
return found2?.text.trim() ? found2 : null;
|
|
@@ -17674,7 +17772,7 @@ function cardLink(id) {
|
|
|
17674
17772
|
const found2 = open3 ?? locateArchived(id);
|
|
17675
17773
|
if (!found2) return null;
|
|
17676
17774
|
try {
|
|
17677
|
-
const file2 = found2.kind === "group" ?
|
|
17775
|
+
const file2 = found2.kind === "group" ? path64.join(found2.target, "root.md") : found2.target;
|
|
17678
17776
|
const title = parseFrontmatter(fs60.readFileSync(file2, "utf8")).meta?.title ?? "";
|
|
17679
17777
|
return { kind: "card", ref: String(id), title, ...open3 ? {} : { archived: true } };
|
|
17680
17778
|
} catch {
|
|
@@ -17739,11 +17837,11 @@ var init_card_sources = __esm({
|
|
|
17739
17837
|
|
|
17740
17838
|
// src/lib/view/read.ts
|
|
17741
17839
|
import fs61 from "node:fs";
|
|
17742
|
-
import
|
|
17840
|
+
import path65 from "node:path";
|
|
17743
17841
|
function readCard(file2, relFromTodo) {
|
|
17744
|
-
const id = idPrefix(
|
|
17842
|
+
const id = idPrefix(path65.basename(relFromTodo));
|
|
17745
17843
|
if (id === null) {
|
|
17746
|
-
const parts = relFromTodo.split(
|
|
17844
|
+
const parts = relFromTodo.split(path65.sep);
|
|
17747
17845
|
const folderId = idPrefix(parts[parts.length - 2] || "");
|
|
17748
17846
|
if (folderId === null) return null;
|
|
17749
17847
|
return buildCard(folderId, file2, relFromTodo);
|
|
@@ -17754,7 +17852,7 @@ function buildCard(id, file2, relFromTodo) {
|
|
|
17754
17852
|
const text6 = fs61.readFileSync(file2, "utf8");
|
|
17755
17853
|
const { meta, body } = parseFrontmatter(text6);
|
|
17756
17854
|
if (!meta) return null;
|
|
17757
|
-
const relPath = relFromTodo.split(
|
|
17855
|
+
const relPath = relFromTodo.split(path65.sep).join("/");
|
|
17758
17856
|
const flow = studioFor(meta.studio);
|
|
17759
17857
|
const plan = !!meta.studio && archivesOnApproval(flow);
|
|
17760
17858
|
const stages = cardStages(meta, flow).length;
|
|
@@ -17784,10 +17882,10 @@ function buildCard(id, file2, relFromTodo) {
|
|
|
17784
17882
|
};
|
|
17785
17883
|
}
|
|
17786
17884
|
function readGroup2(folderName) {
|
|
17787
|
-
const groupDir =
|
|
17788
|
-
const rootFile =
|
|
17885
|
+
const groupDir = path65.join(TODO, folderName);
|
|
17886
|
+
const rootFile = path65.join(groupDir, "root.md");
|
|
17789
17887
|
if (!fs61.existsSync(rootFile)) return null;
|
|
17790
|
-
const root2 = readCard(rootFile,
|
|
17888
|
+
const root2 = readCard(rootFile, path65.join(folderName, "root.md"));
|
|
17791
17889
|
if (!root2) return null;
|
|
17792
17890
|
root2.isGroup = true;
|
|
17793
17891
|
const { total, resolved: resolved2 } = subtaskLines(root2.body);
|
|
@@ -17795,11 +17893,11 @@ function readGroup2(folderName) {
|
|
|
17795
17893
|
const subCards = [];
|
|
17796
17894
|
const recurse = (dir, relDir) => {
|
|
17797
17895
|
for (const entry of fs61.readdirSync(dir, { withFileTypes: true })) {
|
|
17798
|
-
const childRel =
|
|
17896
|
+
const childRel = path65.join(relDir, entry.name);
|
|
17799
17897
|
if (entry.isDirectory()) {
|
|
17800
|
-
recurse(
|
|
17898
|
+
recurse(path65.join(dir, entry.name), childRel);
|
|
17801
17899
|
} else if (entry.name.endsWith(".md") && entry.name !== "README.md" && entry.name !== "root.md") {
|
|
17802
|
-
const c2 = readCard(
|
|
17900
|
+
const c2 = readCard(path65.join(dir, entry.name), childRel);
|
|
17803
17901
|
if (c2) {
|
|
17804
17902
|
c2.parent = { id: root2.id, title: root2.title };
|
|
17805
17903
|
subCards.push(c2);
|
|
@@ -17820,12 +17918,12 @@ function readGroup2(folderName) {
|
|
|
17820
17918
|
return { root: root2, subCards };
|
|
17821
17919
|
}
|
|
17822
17920
|
function standaloneCards(dirRel) {
|
|
17823
|
-
const dir = dirRel ?
|
|
17921
|
+
const dir = dirRel ? path65.join(TODO, dirRel) : TODO;
|
|
17824
17922
|
if (!fs61.existsSync(dir)) return [];
|
|
17825
17923
|
const cards = [];
|
|
17826
17924
|
for (const entry of fs61.readdirSync(dir, { withFileTypes: true })) {
|
|
17827
17925
|
if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
|
|
17828
|
-
const c2 = readCard(
|
|
17926
|
+
const c2 = readCard(path65.join(dir, entry.name), path65.join(dirRel, entry.name));
|
|
17829
17927
|
if (c2) cards.push(c2);
|
|
17830
17928
|
}
|
|
17831
17929
|
}
|
|
@@ -17869,7 +17967,7 @@ function findCard(id) {
|
|
|
17869
17967
|
}
|
|
17870
17968
|
function attachSources(card) {
|
|
17871
17969
|
try {
|
|
17872
|
-
const { meta, body } = parseFrontmatter(fs61.readFileSync(
|
|
17970
|
+
const { meta, body } = parseFrontmatter(fs61.readFileSync(path65.join(TODO, card.relPath), "utf8"));
|
|
17873
17971
|
const sources2 = meta ? cardSources(meta, body) : [];
|
|
17874
17972
|
if (sources2.length) card.sources = sources2;
|
|
17875
17973
|
} catch {
|
|
@@ -17974,7 +18072,7 @@ var init_read = __esm({
|
|
|
17974
18072
|
|
|
17975
18073
|
// src/lib/agent/preview-progress.ts
|
|
17976
18074
|
import fs62 from "node:fs";
|
|
17977
|
-
import
|
|
18075
|
+
import path66 from "node:path";
|
|
17978
18076
|
import { createHash as createHash5, randomUUID as randomUUID6 } from "node:crypto";
|
|
17979
18077
|
function readPreviewProgress(id) {
|
|
17980
18078
|
try {
|
|
@@ -17996,7 +18094,7 @@ function readPreviewProgress(id) {
|
|
|
17996
18094
|
}
|
|
17997
18095
|
}
|
|
17998
18096
|
function updatePreviewProgress(id, change2) {
|
|
17999
|
-
fs62.mkdirSync(
|
|
18097
|
+
fs62.mkdirSync(path66.dirname(file(id)), { recursive: true });
|
|
18000
18098
|
return withLock(`${file(id)}.lock`, "updating preview progress", () => {
|
|
18001
18099
|
const all2 = readPreviewProgress(id);
|
|
18002
18100
|
const result = change2(all2);
|
|
@@ -18013,7 +18111,7 @@ function freezePreviewProgress(id, name) {
|
|
|
18013
18111
|
const agent = findSpecAgent(name);
|
|
18014
18112
|
if (!agent) return null;
|
|
18015
18113
|
const studio = studioFiles(cardStudioId(id)) ?? {};
|
|
18016
|
-
const protocol = Object.entries(studio).some(([
|
|
18114
|
+
const protocol = Object.entries(studio).some(([path89, text6]) => path89.endsWith("/AGENT.md") && /^[ \t]+stages:/m.test(text6.split(/\r?\n---/)[0]));
|
|
18017
18115
|
if (!agent.stages && !protocol) return null;
|
|
18018
18116
|
const definitions = agent.stages ?? [{ id: "preview", title: { en: "Preview", zh: "\u6210\u679C" }, instructions: "preview.md" }];
|
|
18019
18117
|
const files = Object.fromEntries(agent.files.map((file2) => [file2, agent.file(file2)]).filter((entry) => entry[1] !== null));
|
|
@@ -18046,7 +18144,7 @@ ${stage.artifact?.body ?? ""}`),
|
|
|
18046
18144
|
function previewOwner(id, name, inside2 = insideRun()) {
|
|
18047
18145
|
const found2 = locate2(id);
|
|
18048
18146
|
if (!found2) throw Error("The task is no longer open.");
|
|
18049
|
-
const card = found2.kind === "group" ?
|
|
18147
|
+
const card = found2.kind === "group" ? path66.join(found2.target, "root.md") : found2.target;
|
|
18050
18148
|
const { meta } = parseFrontmatter(fs62.readFileSync(card, "utf8"));
|
|
18051
18149
|
if (!specAgentAssigned(name, meta?.studio) || !meta?.previews?.includes(name)) throw Error("Choose this preview agent on the task first.");
|
|
18052
18150
|
if (inside2) {
|
|
@@ -18067,7 +18165,7 @@ function readContext(file2) {
|
|
|
18067
18165
|
}
|
|
18068
18166
|
}
|
|
18069
18167
|
function writeJson2(file2, value) {
|
|
18070
|
-
fs62.mkdirSync(
|
|
18168
|
+
fs62.mkdirSync(path66.dirname(file2), { recursive: true });
|
|
18071
18169
|
const temp = `${file2}.${process.pid}.tmp`;
|
|
18072
18170
|
fs62.writeFileSync(temp, JSON.stringify(value) + "\n");
|
|
18073
18171
|
fs62.renameSync(temp, file2);
|
|
@@ -18150,21 +18248,21 @@ function reportLocalPreview(id, name, stage, status) {
|
|
|
18150
18248
|
}
|
|
18151
18249
|
function localPreviewAssets(id, body) {
|
|
18152
18250
|
const assets = {};
|
|
18153
|
-
const taskRoot =
|
|
18251
|
+
const taskRoot = path66.join(ASSETS, String(id));
|
|
18154
18252
|
const visit = (src) => {
|
|
18155
18253
|
if (src in assets || /^[a-z][\w+.-]*:/i.test(src)) return;
|
|
18156
|
-
const file2 =
|
|
18157
|
-
if (!file2.startsWith(taskRoot +
|
|
18254
|
+
const file2 = path66.resolve(ASSETS, src.replace(/^\.assets\//, ""));
|
|
18255
|
+
if (!file2.startsWith(taskRoot + path66.sep)) throw Error("Preview assets must stay inside this task\u2019s asset folder.");
|
|
18158
18256
|
if (!fs62.existsSync(file2)) {
|
|
18159
18257
|
assets[src] = null;
|
|
18160
18258
|
return;
|
|
18161
18259
|
}
|
|
18162
18260
|
if (fs62.lstatSync(taskRoot).isSymbolicLink()) throw Error("Preview assets must stay inside this task\u2019s asset folder.");
|
|
18163
18261
|
const real2 = fs62.realpathSync(file2);
|
|
18164
|
-
if (!real2.startsWith(fs62.realpathSync(taskRoot) +
|
|
18262
|
+
if (!real2.startsWith(fs62.realpathSync(taskRoot) + path66.sep)) throw Error("Preview assets must stay inside this task\u2019s asset folder.");
|
|
18165
18263
|
const bytes2 = fs62.readFileSync(real2);
|
|
18166
18264
|
assets[src] = createHash5("sha256").update(bytes2).digest("hex");
|
|
18167
|
-
const manifest = manifestOf(kindOf(
|
|
18265
|
+
const manifest = manifestOf(kindOf(path66.extname(file2)));
|
|
18168
18266
|
let content = bytes2.toString();
|
|
18169
18267
|
if (manifest?.references?.some((ref) => "json" in ref)) {
|
|
18170
18268
|
try {
|
|
@@ -18175,10 +18273,10 @@ function localPreviewAssets(id, body) {
|
|
|
18175
18273
|
}
|
|
18176
18274
|
for (const ref of referencesOf(manifest, content)) {
|
|
18177
18275
|
if (/^[a-z][\w+.-]*:/i.test(ref.src)) continue;
|
|
18178
|
-
visit(
|
|
18276
|
+
visit(path66.posix.normalize(path66.posix.join(path66.posix.dirname(src), ref.src)));
|
|
18179
18277
|
}
|
|
18180
18278
|
};
|
|
18181
|
-
for (const ref of bodyReferences(body)) if (ref.src.startsWith(".assets/") || fs62.existsSync(
|
|
18279
|
+
for (const ref of bodyReferences(body)) if (ref.src.startsWith(".assets/") || fs62.existsSync(path66.join(ASSETS, ref.src))) visit(ref.src);
|
|
18182
18280
|
return assets;
|
|
18183
18281
|
}
|
|
18184
18282
|
function freezeLocalAssets(id, all2) {
|
|
@@ -18188,13 +18286,13 @@ function freezeLocalAssets(id, all2) {
|
|
|
18188
18286
|
const pinned2 = {};
|
|
18189
18287
|
for (const [src, hash2] of Object.entries(artifact.assets)) {
|
|
18190
18288
|
if (typeof hash2 !== "string") continue;
|
|
18191
|
-
const file2 =
|
|
18289
|
+
const file2 = path66.join(ASSETS, src.replace(/^\.assets\//, ""));
|
|
18192
18290
|
if (!fs62.existsSync(file2)) continue;
|
|
18193
|
-
const root2 =
|
|
18194
|
-
if (fs62.lstatSync(root2).isSymbolicLink() || !fs62.realpathSync(file2).startsWith(fs62.realpathSync(root2) +
|
|
18291
|
+
const root2 = path66.join(ASSETS, String(id));
|
|
18292
|
+
if (fs62.lstatSync(root2).isSymbolicLink() || !fs62.realpathSync(file2).startsWith(fs62.realpathSync(root2) + path66.sep)) throw Error("Preview assets must stay inside this task\u2019s asset folder.");
|
|
18195
18293
|
if (createHash5("sha256").update(fs62.readFileSync(file2)).digest("hex") !== hash2) continue;
|
|
18196
|
-
const frozen =
|
|
18197
|
-
fs62.mkdirSync(
|
|
18294
|
+
const frozen = path66.join(BOARD_STATE, "previews", "assets", String(id), stage.id, String(progress.generation), String(artifact.version), hash2, src.replace(/^\.assets\//, ""));
|
|
18295
|
+
fs62.mkdirSync(path66.dirname(frozen), { recursive: true });
|
|
18198
18296
|
if (!fs62.existsSync(frozen)) fs62.copyFileSync(file2, frozen, fs62.constants.COPYFILE_EXCL);
|
|
18199
18297
|
pinned2[src] = frozen;
|
|
18200
18298
|
}
|
|
@@ -18224,17 +18322,17 @@ var init_preview_progress = __esm({
|
|
|
18224
18322
|
init_execution();
|
|
18225
18323
|
init_preview();
|
|
18226
18324
|
init_preview_stages();
|
|
18227
|
-
file = (id) =>
|
|
18228
|
-
contextFile = (id, name, owner) =>
|
|
18325
|
+
file = (id) => path66.join(BOARD_STATE, "previews", `${id}.json`);
|
|
18326
|
+
contextFile = (id, name, owner) => path66.join(BOARD_STATE, "previews", "contexts", String(id), name, `${createHash5("sha256").update(owner).digest("hex")}.json`);
|
|
18229
18327
|
PreviewContextMissing = class extends Error {
|
|
18230
18328
|
};
|
|
18231
|
-
baselineFile = (id, name, run4) =>
|
|
18329
|
+
baselineFile = (id, name, run4) => path66.join(BOARD_STATE, "previews", "runs", String(id), name, `${run4}.json`);
|
|
18232
18330
|
}
|
|
18233
18331
|
});
|
|
18234
18332
|
|
|
18235
18333
|
// src/lib/agent/approve.ts
|
|
18236
18334
|
import fs63 from "node:fs";
|
|
18237
|
-
import
|
|
18335
|
+
import path67 from "node:path";
|
|
18238
18336
|
function approvalRequest(req) {
|
|
18239
18337
|
const id = req.id;
|
|
18240
18338
|
const card = id === void 0 ? null : findCard(id);
|
|
@@ -18252,7 +18350,7 @@ function advancePhase(id) {
|
|
|
18252
18350
|
const card = findCard(id);
|
|
18253
18351
|
const found2 = locate2(id);
|
|
18254
18352
|
if (!card || !found2 || !awaitingApproval(card)) return { error: `#${id} is no longer waiting on approval.` };
|
|
18255
|
-
const file2 = found2.kind === "group" ?
|
|
18353
|
+
const file2 = found2.kind === "group" ? path67.join(found2.target, "root.md") : found2.target;
|
|
18256
18354
|
const { meta, body } = parseFrontmatter(fs63.readFileSync(file2, "utf8"));
|
|
18257
18355
|
if (!meta) return { error: `#${id} has no frontmatter` };
|
|
18258
18356
|
meta.phase = card.stage + 1;
|
|
@@ -18500,7 +18598,7 @@ var init_avatar = __esm({
|
|
|
18500
18598
|
|
|
18501
18599
|
// src/lib/cloud/pro.ts
|
|
18502
18600
|
import fs64 from "node:fs";
|
|
18503
|
-
import
|
|
18601
|
+
import path68 from "node:path";
|
|
18504
18602
|
function forgetPro() {
|
|
18505
18603
|
fs64.rmSync(heldFile(), { force: true });
|
|
18506
18604
|
}
|
|
@@ -18513,7 +18611,7 @@ var init_pro = __esm({
|
|
|
18513
18611
|
init_session();
|
|
18514
18612
|
FRESH_MS2 = 10 * 6e4;
|
|
18515
18613
|
GRACE_MS = 7 * 24 * 60 * 6e4;
|
|
18516
|
-
heldFile = () =>
|
|
18614
|
+
heldFile = () => path68.join(machineHome(), "pro.json");
|
|
18517
18615
|
}
|
|
18518
18616
|
});
|
|
18519
18617
|
|
|
@@ -18605,7 +18703,7 @@ var init_account = __esm({
|
|
|
18605
18703
|
|
|
18606
18704
|
// src/commands/cloud.ts
|
|
18607
18705
|
import fs65 from "node:fs";
|
|
18608
|
-
import
|
|
18706
|
+
import path69 from "node:path";
|
|
18609
18707
|
async function cmdCloud(args2, program2) {
|
|
18610
18708
|
const [sub] = args2;
|
|
18611
18709
|
if (sub === "sign-out") {
|
|
@@ -18667,7 +18765,7 @@ async function cloudImage(opts, program2) {
|
|
|
18667
18765
|
const prompt = opts.prompt.trim();
|
|
18668
18766
|
if (!prompt) usage("Missing the prompt.", line);
|
|
18669
18767
|
const references = opts.refs.map((file2) => {
|
|
18670
|
-
const type = REF_TYPES[
|
|
18768
|
+
const type = REF_TYPES[path69.extname(file2).toLowerCase()];
|
|
18671
18769
|
if (!type) usage(`--ref ${file2}: use a PNG, JPEG or WebP file.`, line);
|
|
18672
18770
|
try {
|
|
18673
18771
|
return `data:${type};base64,${fs65.readFileSync(file2).toString("base64")}`;
|
|
@@ -18778,7 +18876,7 @@ async function generate(g3) {
|
|
|
18778
18876
|
refuse(g3.failed, g3.fallback);
|
|
18779
18877
|
}
|
|
18780
18878
|
const out = g3.outFor?.(res, g3.out) ?? g3.out;
|
|
18781
|
-
fs65.mkdirSync(
|
|
18879
|
+
fs65.mkdirSync(path69.dirname(path69.resolve(out)), { recursive: true });
|
|
18782
18880
|
fs65.writeFileSync(out, Buffer.from(await res.arrayBuffer()));
|
|
18783
18881
|
say(`${out} (${g3.label(res)})`);
|
|
18784
18882
|
return { out };
|
|
@@ -18829,9 +18927,9 @@ var init_cloud = __esm({
|
|
|
18829
18927
|
// src/commands/task.ts
|
|
18830
18928
|
import fs66 from "node:fs";
|
|
18831
18929
|
import os5 from "node:os";
|
|
18832
|
-
import
|
|
18930
|
+
import path70 from "node:path";
|
|
18833
18931
|
async function cloud(method, route2, body, signal2) {
|
|
18834
|
-
process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME ||
|
|
18932
|
+
process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME || path70.join(os5.homedir(), ".wildcrane");
|
|
18835
18933
|
const token2 = await accessToken();
|
|
18836
18934
|
if (!token2.ok) return refuse2(SAID[token2.reason].en, token2.reason.replace("-", "_"));
|
|
18837
18935
|
let response;
|
|
@@ -18874,15 +18972,15 @@ function linked(location) {
|
|
|
18874
18972
|
const cwd = location.cwd ?? process.cwd();
|
|
18875
18973
|
const board2 = location.board ?? (process.env.AI4KANBAN_BOARD?.trim() || null);
|
|
18876
18974
|
if (board2) {
|
|
18877
|
-
const link2 = linkedProject("", projectRootOf(
|
|
18975
|
+
const link2 = linkedProject("", projectRootOf(path70.resolve(cwd, board2)));
|
|
18878
18976
|
return link2.ok ? link2.value : null;
|
|
18879
18977
|
}
|
|
18880
|
-
for (let dir =
|
|
18881
|
-
if (fs66.existsSync(
|
|
18978
|
+
for (let dir = path70.resolve(cwd, location.dir ?? "."); ; dir = path70.dirname(dir)) {
|
|
18979
|
+
if (fs66.existsSync(path70.join(dir, ".akb", "base.json"))) {
|
|
18882
18980
|
const link2 = linkedProject("", dir);
|
|
18883
18981
|
return link2.ok ? link2.value : null;
|
|
18884
18982
|
}
|
|
18885
|
-
if (
|
|
18983
|
+
if (path70.dirname(dir) === dir) return null;
|
|
18886
18984
|
}
|
|
18887
18985
|
}
|
|
18888
18986
|
async function project(asked, location) {
|
|
@@ -19166,7 +19264,7 @@ var init_goal = __esm({
|
|
|
19166
19264
|
// src/commands/goal-cloud.ts
|
|
19167
19265
|
import fs68 from "node:fs";
|
|
19168
19266
|
import os6 from "node:os";
|
|
19169
|
-
import
|
|
19267
|
+
import path71 from "node:path";
|
|
19170
19268
|
import crypto3 from "node:crypto";
|
|
19171
19269
|
function hostSession() {
|
|
19172
19270
|
const { CLAUDE_CODE_SESSION_ID: claude, CODEX_THREAD_ID: codex, CURSOR_CONVERSATION_ID: cursor, KIMI_SESSION_ID: kimi, WILDCRANE_DISCUSSION: discussion2 } = process.env;
|
|
@@ -19195,10 +19293,10 @@ function goalsOf(d2) {
|
|
|
19195
19293
|
async function discussion() {
|
|
19196
19294
|
const session = hostSession();
|
|
19197
19295
|
if (!session) die("Goals exist only inside a WildCrane goal discussion.");
|
|
19198
|
-
const home3 = process.env.WILDCRANE_HOME ||
|
|
19296
|
+
const home3 = process.env.WILDCRANE_HOME || path71.join(os6.homedir(), ".wildcrane");
|
|
19199
19297
|
process.env.AI4KANBAN_HOME ??= home3;
|
|
19200
19298
|
if (session.host === "discussion") return request("GET", `/v1/discussions/${encodeURIComponent(session.id)}`);
|
|
19201
|
-
const machineFile2 =
|
|
19299
|
+
const machineFile2 = path71.join(home3, "machine.json");
|
|
19202
19300
|
let machine;
|
|
19203
19301
|
try {
|
|
19204
19302
|
machine = JSON.parse(fs68.readFileSync(machineFile2, "utf8")).id;
|
|
@@ -19212,7 +19310,7 @@ async function discussion() {
|
|
|
19212
19310
|
const folder = held4.folders.filter((f2) => {
|
|
19213
19311
|
try {
|
|
19214
19312
|
const dir = fs68.realpathSync(f2.path);
|
|
19215
|
-
return cwd === dir || cwd.startsWith(dir +
|
|
19313
|
+
return cwd === dir || cwd.startsWith(dir + path71.sep);
|
|
19216
19314
|
} catch {
|
|
19217
19315
|
return false;
|
|
19218
19316
|
}
|
|
@@ -19221,8 +19319,8 @@ async function discussion() {
|
|
|
19221
19319
|
}
|
|
19222
19320
|
async function withGoalDiscussion(action, save3 = false) {
|
|
19223
19321
|
const d2 = await discussion();
|
|
19224
|
-
const dir = fs68.mkdtempSync(
|
|
19225
|
-
const file2 =
|
|
19322
|
+
const dir = fs68.mkdtempSync(path71.join(os6.tmpdir(), "akb-goals-"));
|
|
19323
|
+
const file2 = path71.join(dir, "goals.json");
|
|
19226
19324
|
const before = process.env.KANBAN_GOALS;
|
|
19227
19325
|
try {
|
|
19228
19326
|
const previous = goalsOf(d2);
|
|
@@ -20398,7 +20496,7 @@ var require_command = __commonJS({
|
|
|
20398
20496
|
"node_modules/commander/lib/command.js"(exports) {
|
|
20399
20497
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
20400
20498
|
var childProcess = __require("node:child_process");
|
|
20401
|
-
var
|
|
20499
|
+
var path89 = __require("node:path");
|
|
20402
20500
|
var fs89 = __require("node:fs");
|
|
20403
20501
|
var process2 = __require("node:process");
|
|
20404
20502
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
@@ -21398,9 +21496,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
21398
21496
|
let launchWithNode = false;
|
|
21399
21497
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
21400
21498
|
function findFile(baseDir, baseName) {
|
|
21401
|
-
const localBin =
|
|
21499
|
+
const localBin = path89.resolve(baseDir, baseName);
|
|
21402
21500
|
if (fs89.existsSync(localBin)) return localBin;
|
|
21403
|
-
if (sourceExt.includes(
|
|
21501
|
+
if (sourceExt.includes(path89.extname(baseName))) return void 0;
|
|
21404
21502
|
const foundExt = sourceExt.find(
|
|
21405
21503
|
(ext) => fs89.existsSync(`${localBin}${ext}`)
|
|
21406
21504
|
);
|
|
@@ -21418,17 +21516,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
21418
21516
|
} catch {
|
|
21419
21517
|
resolvedScriptPath = this._scriptPath;
|
|
21420
21518
|
}
|
|
21421
|
-
executableDir =
|
|
21422
|
-
|
|
21519
|
+
executableDir = path89.resolve(
|
|
21520
|
+
path89.dirname(resolvedScriptPath),
|
|
21423
21521
|
executableDir
|
|
21424
21522
|
);
|
|
21425
21523
|
}
|
|
21426
21524
|
if (executableDir) {
|
|
21427
21525
|
let localFile = findFile(executableDir, executableFile);
|
|
21428
21526
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
21429
|
-
const legacyName =
|
|
21527
|
+
const legacyName = path89.basename(
|
|
21430
21528
|
this._scriptPath,
|
|
21431
|
-
|
|
21529
|
+
path89.extname(this._scriptPath)
|
|
21432
21530
|
);
|
|
21433
21531
|
if (legacyName !== this._name) {
|
|
21434
21532
|
localFile = findFile(
|
|
@@ -21439,7 +21537,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
21439
21537
|
}
|
|
21440
21538
|
executableFile = localFile || executableFile;
|
|
21441
21539
|
}
|
|
21442
|
-
launchWithNode = sourceExt.includes(
|
|
21540
|
+
launchWithNode = sourceExt.includes(path89.extname(executableFile));
|
|
21443
21541
|
let proc;
|
|
21444
21542
|
if (process2.platform !== "win32") {
|
|
21445
21543
|
if (launchWithNode) {
|
|
@@ -22286,7 +22384,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22286
22384
|
* @return {Command}
|
|
22287
22385
|
*/
|
|
22288
22386
|
nameFromFilename(filename) {
|
|
22289
|
-
this._name =
|
|
22387
|
+
this._name = path89.basename(filename, path89.extname(filename));
|
|
22290
22388
|
return this;
|
|
22291
22389
|
}
|
|
22292
22390
|
/**
|
|
@@ -22300,9 +22398,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22300
22398
|
* @param {string} [path]
|
|
22301
22399
|
* @return {(string|null|Command)}
|
|
22302
22400
|
*/
|
|
22303
|
-
executableDir(
|
|
22304
|
-
if (
|
|
22305
|
-
this._executableDir =
|
|
22401
|
+
executableDir(path90) {
|
|
22402
|
+
if (path90 === void 0) return this._executableDir;
|
|
22403
|
+
this._executableDir = path90;
|
|
22306
22404
|
return this;
|
|
22307
22405
|
}
|
|
22308
22406
|
/**
|
|
@@ -22600,21 +22698,21 @@ var init_esm = __esm({
|
|
|
22600
22698
|
|
|
22601
22699
|
// src/lib/card-studio-backfill.ts
|
|
22602
22700
|
import fs69 from "node:fs";
|
|
22603
|
-
import
|
|
22701
|
+
import path72 from "node:path";
|
|
22604
22702
|
function renameToStudio() {
|
|
22605
22703
|
if (!KANBAN || !BOARD_STATE) return;
|
|
22606
|
-
const mark =
|
|
22704
|
+
const mark = path72.join(BOARD_STATE, RENAMED);
|
|
22607
22705
|
try {
|
|
22608
22706
|
if (fs69.existsSync(mark)) return;
|
|
22609
|
-
for (const [from, to] of [[
|
|
22707
|
+
for (const [from, to] of [[path72.join(KANBAN, "workflows"), STUDIOS], [path72.join(RULES, "workflows"), path72.join(RULES, "studios")]]) {
|
|
22610
22708
|
if (fs69.existsSync(from) && !fs69.existsSync(to)) fs69.renameSync(from, to);
|
|
22611
22709
|
}
|
|
22612
22710
|
for (const file2 of [STUDIOS, TODO, TRIAGE].flatMap((dir) => fs69.existsSync(dir) ? walkMd(dir) : [])) {
|
|
22613
|
-
const at2 =
|
|
22711
|
+
const at2 = path72.relative(KANBAN, file2).split(path72.sep).join("/");
|
|
22614
22712
|
const text6 = fs69.readFileSync(file2, "utf8");
|
|
22615
22713
|
const to = studioRenamed(at2, text6);
|
|
22616
22714
|
if (to.path === at2 && to.content === text6) continue;
|
|
22617
|
-
const target =
|
|
22715
|
+
const target = path72.join(KANBAN, to.path);
|
|
22618
22716
|
if (target !== file2 && fs69.existsSync(target)) continue;
|
|
22619
22717
|
fs69.writeFileSync(target, to.content);
|
|
22620
22718
|
if (target !== file2) fs69.rmSync(file2);
|
|
@@ -22627,7 +22725,7 @@ function renameToStudio() {
|
|
|
22627
22725
|
function backfillCardStudios() {
|
|
22628
22726
|
renameToStudio();
|
|
22629
22727
|
if (!TODO || !BOARD_STATE) return;
|
|
22630
|
-
const mark =
|
|
22728
|
+
const mark = path72.join(BOARD_STATE, MARK);
|
|
22631
22729
|
try {
|
|
22632
22730
|
if (fs69.existsSync(mark) || !fs69.existsSync(TODO)) return;
|
|
22633
22731
|
for (const file2 of walkMd(TODO)) {
|
|
@@ -22681,7 +22779,7 @@ var init_created_cards = __esm({
|
|
|
22681
22779
|
// src/lib/agent/creation.ts
|
|
22682
22780
|
import crypto4 from "node:crypto";
|
|
22683
22781
|
import fs70 from "node:fs";
|
|
22684
|
-
import
|
|
22782
|
+
import path73 from "node:path";
|
|
22685
22783
|
function creationError(error, triage) {
|
|
22686
22784
|
const zh = readLanguage() === "zh";
|
|
22687
22785
|
const messages = {
|
|
@@ -22707,7 +22805,7 @@ ${zh ? `\u539F\u6761\u76EE\u4ECD\u5728 triage\uFF1A${triage}\u3002${unreachable
|
|
|
22707
22805
|
function creationReceipt(request2, slot) {
|
|
22708
22806
|
const hash2 = crypto4.createHash("sha256").update(`${request2}
|
|
22709
22807
|
${slot}`).digest("hex");
|
|
22710
|
-
return
|
|
22808
|
+
return path73.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
|
|
22711
22809
|
}
|
|
22712
22810
|
function readCreation(file2, said2) {
|
|
22713
22811
|
return withCreationLock(() => {
|
|
@@ -22724,7 +22822,7 @@ function readCreation(file2, said2) {
|
|
|
22724
22822
|
});
|
|
22725
22823
|
}
|
|
22726
22824
|
function saveCreation(file2, journal) {
|
|
22727
|
-
fs70.mkdirSync(
|
|
22825
|
+
fs70.mkdirSync(path73.dirname(file2), { recursive: true });
|
|
22728
22826
|
const temp = `${file2}.${crypto4.randomUUID()}.tmp`;
|
|
22729
22827
|
fs70.writeFileSync(temp, JSON.stringify(journal));
|
|
22730
22828
|
fs70.renameSync(temp, file2);
|
|
@@ -22741,7 +22839,7 @@ function archiveCreation(source2, id) {
|
|
|
22741
22839
|
function triageFile(sourceId) {
|
|
22742
22840
|
const found2 = [...readInbox(), ...readAllDismissed(), ...readArchived()].find((s) => s.sourceId === sourceId.trim());
|
|
22743
22841
|
if (!found2) throw new BoardError(`nothing in triage is ${sourceId}`, { kind: "refused" });
|
|
22744
|
-
return
|
|
22842
|
+
return path73.basename(found2.relPath, ".md");
|
|
22745
22843
|
}
|
|
22746
22844
|
var init_creation = __esm({
|
|
22747
22845
|
"src/lib/agent/creation.ts"() {
|
|
@@ -22911,7 +23009,7 @@ __export(board_exports, {
|
|
|
22911
23009
|
});
|
|
22912
23010
|
import crypto5 from "node:crypto";
|
|
22913
23011
|
import fs71 from "node:fs";
|
|
22914
|
-
import
|
|
23012
|
+
import path74 from "node:path";
|
|
22915
23013
|
async function dispatch(move, cmd, args2, opts, cli) {
|
|
22916
23014
|
const ctx = ctxOf(cmd, cli.program);
|
|
22917
23015
|
const data = await runAction(ctx, {}, async () => {
|
|
@@ -22980,7 +23078,7 @@ async function cloudCard(task, opts) {
|
|
|
22980
23078
|
const file2 = creationReceipt(`${checked.value}:${requestId}`, slot);
|
|
22981
23079
|
const journal = readCreation(file2, said2);
|
|
22982
23080
|
if (!journal.made) {
|
|
22983
|
-
const key = `akb-${
|
|
23081
|
+
const key = `akb-${path74.basename(file2, ".json").slice(0, 40)}`;
|
|
22984
23082
|
const made = await createProjectTask(checked.value, journal.said, key);
|
|
22985
23083
|
if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
|
|
22986
23084
|
journal.made = made.value;
|
|
@@ -23113,9 +23211,9 @@ var init_board2 = __esm({
|
|
|
23113
23211
|
|
|
23114
23212
|
// src/lib/board-cli.ts
|
|
23115
23213
|
import fs72 from "node:fs";
|
|
23116
|
-
import
|
|
23214
|
+
import path75 from "node:path";
|
|
23117
23215
|
function useBoard(found2, dirNamed, readOnly = false) {
|
|
23118
|
-
if (!found2.named && found2.board ===
|
|
23216
|
+
if (!found2.named && found2.board === path75.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
|
|
23119
23217
|
else setBoardDir(found2.board, found2.root);
|
|
23120
23218
|
if (!readOnly) {
|
|
23121
23219
|
useProjectState();
|
|
@@ -23124,7 +23222,7 @@ function useBoard(found2, dirNamed, readOnly = false) {
|
|
|
23124
23222
|
}
|
|
23125
23223
|
function whole(found2, move) {
|
|
23126
23224
|
if (move === MAKES_A_BOARD) return found2;
|
|
23127
|
-
if (!fs72.existsSync(
|
|
23225
|
+
if (!fs72.existsSync(path75.join(found2.board, "todo"))) {
|
|
23128
23226
|
die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
|
|
23129
23227
|
kind: "board-incomplete",
|
|
23130
23228
|
dir: found2.root
|
|
@@ -23133,13 +23231,13 @@ function whole(found2, move) {
|
|
|
23133
23231
|
return found2;
|
|
23134
23232
|
}
|
|
23135
23233
|
function findBoardUpward(from, move) {
|
|
23136
|
-
let dir =
|
|
23234
|
+
let dir = path75.resolve(from);
|
|
23137
23235
|
for (; ; ) {
|
|
23138
|
-
if (hasBoard(dir)) return { root: dir, board:
|
|
23236
|
+
if (hasBoard(dir)) return { root: dir, board: path75.join(dir, "docs", "kanban") };
|
|
23139
23237
|
if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
|
|
23140
|
-
const kept2 =
|
|
23141
|
-
if (move !== MAKES_A_BOARD && fs72.existsSync(
|
|
23142
|
-
const up =
|
|
23238
|
+
const kept2 = path75.join(dir, ".akb", "kanban");
|
|
23239
|
+
if (move !== MAKES_A_BOARD && fs72.existsSync(path75.join(kept2, "todo"))) return { root: dir, board: kept2 };
|
|
23240
|
+
const up = path75.dirname(dir);
|
|
23143
23241
|
if (up === dir) return null;
|
|
23144
23242
|
dir = up;
|
|
23145
23243
|
}
|
|
@@ -23147,7 +23245,7 @@ function findBoardUpward(from, move) {
|
|
|
23147
23245
|
function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
23148
23246
|
const named2 = board2 ?? boardFromEnv();
|
|
23149
23247
|
if (named2) {
|
|
23150
|
-
const folder =
|
|
23248
|
+
const folder = path75.resolve(cwd, named2);
|
|
23151
23249
|
if (!fs72.existsSync(folder) && move !== MAKES_A_BOARD) {
|
|
23152
23250
|
die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
|
|
23153
23251
|
}
|
|
@@ -23160,24 +23258,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
|
23160
23258
|
return { root: projectRootOf(folder), board: folder, named: true };
|
|
23161
23259
|
}
|
|
23162
23260
|
if (dir !== null) {
|
|
23163
|
-
const root2 =
|
|
23261
|
+
const root2 = path75.resolve(dir);
|
|
23164
23262
|
if (!fs72.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
|
|
23165
|
-
const kept2 =
|
|
23166
|
-
if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs72.existsSync(
|
|
23263
|
+
const kept2 = path75.join(root2, ".akb", "kanban");
|
|
23264
|
+
if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs72.existsSync(path75.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
|
|
23167
23265
|
if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
|
|
23168
23266
|
die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
|
|
23169
23267
|
kind: "no-board",
|
|
23170
23268
|
dir: root2
|
|
23171
23269
|
});
|
|
23172
23270
|
}
|
|
23173
|
-
return whole({ root: root2, board:
|
|
23271
|
+
return whole({ root: root2, board: path75.join(root2, "docs", "kanban") }, move);
|
|
23174
23272
|
}
|
|
23175
23273
|
const found2 = findBoardUpward(cwd, move);
|
|
23176
23274
|
if (found2) return whole(found2, move);
|
|
23177
|
-
if (move === MAKES_A_BOARD) return { root:
|
|
23275
|
+
if (move === MAKES_A_BOARD) return { root: path75.resolve(cwd), board: path75.join(path75.resolve(cwd), "docs", "kanban") };
|
|
23178
23276
|
die(
|
|
23179
|
-
`no board here. Looked in ${
|
|
23180
|
-
{ kind: "no-board", dir:
|
|
23277
|
+
`no board here. Looked in ${path75.resolve(cwd)} and every folder above it for docs/kanban/. ${installHint}\uFF0C\u6216\u7528 --board \u6307\u5B9A\u5DF2\u6709\u770B\u677F\u3002`,
|
|
23278
|
+
{ kind: "no-board", dir: path75.resolve(cwd) }
|
|
23181
23279
|
);
|
|
23182
23280
|
}
|
|
23183
23281
|
function editDistance(a2, b2) {
|
|
@@ -23253,8 +23351,8 @@ var init_board_cli = __esm({
|
|
|
23253
23351
|
init_io();
|
|
23254
23352
|
init_card_studio_backfill();
|
|
23255
23353
|
MAKES_A_BOARD = "init";
|
|
23256
|
-
hasBoard = (dir) => fs72.existsSync(
|
|
23257
|
-
isBoardDir = (dir) => fs72.existsSync(
|
|
23354
|
+
hasBoard = (dir) => fs72.existsSync(path75.join(dir, "docs", "kanban"));
|
|
23355
|
+
isBoardDir = (dir) => fs72.existsSync(path75.join(dir, "todo")) && fs72.existsSync(path75.join(dir, "config.md"));
|
|
23258
23356
|
boardFromEnv = () => {
|
|
23259
23357
|
const named2 = process.env.AI4KANBAN_BOARD?.trim();
|
|
23260
23358
|
return named2 ? named2 : null;
|
|
@@ -23499,7 +23597,7 @@ var init_agent = __esm({
|
|
|
23499
23597
|
// src/commands/cloud-template.ts
|
|
23500
23598
|
import { createHash as createHash6 } from "node:crypto";
|
|
23501
23599
|
import fs73 from "node:fs";
|
|
23502
|
-
import
|
|
23600
|
+
import path76 from "node:path";
|
|
23503
23601
|
function usage2(problem, line) {
|
|
23504
23602
|
die(`${problem}
|
|
23505
23603
|
usage: ${line}`, { kind: "bad-args", bare: true, exitCode: 2 });
|
|
@@ -23576,8 +23674,8 @@ This template has no preview.`);
|
|
|
23576
23674
|
const written = [];
|
|
23577
23675
|
for (const p2 of previews) {
|
|
23578
23676
|
const bytes2 = Buffer.from(await (await ask(`/${at2}/previews/${route(p2.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
23579
|
-
const file2 =
|
|
23580
|
-
const out =
|
|
23677
|
+
const file2 = path76.basename(p2.path);
|
|
23678
|
+
const out = path76.join(opts.to, file2.startsWith(`${name}-`) ? file2 : `${name}-${file2}`);
|
|
23581
23679
|
fs73.mkdirSync(opts.to, { recursive: true });
|
|
23582
23680
|
fs73.writeFileSync(out, bytes2);
|
|
23583
23681
|
written.push(out);
|
|
@@ -23592,15 +23690,15 @@ async function templateGet(name, opts, program2) {
|
|
|
23592
23690
|
const { template } = await asJson(await ask(`/${at2}`, {}, WITHOUT));
|
|
23593
23691
|
const fetched = [];
|
|
23594
23692
|
for (const f2 of template.files) {
|
|
23595
|
-
const out =
|
|
23596
|
-
if (!out.startsWith(
|
|
23693
|
+
const out = path76.resolve(to, f2.path);
|
|
23694
|
+
if (!out.startsWith(path76.resolve(to) + path76.sep)) refuse3(T.corrupt, WITHOUT);
|
|
23597
23695
|
const bytes2 = Buffer.from(await (await ask(`/${at2}/files/${route(f2.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
23598
23696
|
if (bytes2.byteLength !== f2.size || createHash6("sha256").update(bytes2).digest("hex") !== f2.sha256) {
|
|
23599
23697
|
refuse3(T.corrupt, WITHOUT);
|
|
23600
23698
|
}
|
|
23601
23699
|
fetched.push({ out, bytes: bytes2 });
|
|
23602
23700
|
}
|
|
23603
|
-
const taken = fetched.filter((f2) => fs73.existsSync(f2.out)).map((f2) =>
|
|
23701
|
+
const taken = fetched.filter((f2) => fs73.existsSync(f2.out)).map((f2) => path76.relative(to, f2.out));
|
|
23604
23702
|
if (taken.length > 0) {
|
|
23605
23703
|
refuse3({
|
|
23606
23704
|
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`,
|
|
@@ -23608,7 +23706,7 @@ async function templateGet(name, opts, program2) {
|
|
|
23608
23706
|
});
|
|
23609
23707
|
}
|
|
23610
23708
|
for (const f2 of fetched) {
|
|
23611
|
-
fs73.mkdirSync(
|
|
23709
|
+
fs73.mkdirSync(path76.dirname(f2.out), { recursive: true });
|
|
23612
23710
|
fs73.writeFileSync(f2.out, f2.bytes);
|
|
23613
23711
|
}
|
|
23614
23712
|
say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
|
|
@@ -23626,7 +23724,7 @@ async function templateSource(name, opts) {
|
|
|
23626
23724
|
say(`evidence: ${e2.path}`);
|
|
23627
23725
|
continue;
|
|
23628
23726
|
}
|
|
23629
|
-
const out =
|
|
23727
|
+
const out = path76.join(opts.to, `${name}-${path76.basename(e2.path)}`);
|
|
23630
23728
|
fs73.mkdirSync(opts.to, { recursive: true });
|
|
23631
23729
|
fs73.writeFileSync(out, Buffer.from(await (await ask(`/${at2}/evidence/${route(e2.path)}`)).arrayBuffer()));
|
|
23632
23730
|
written.push(out);
|
|
@@ -23635,16 +23733,16 @@ async function templateSource(name, opts) {
|
|
|
23635
23733
|
return { name, source: source2, evidence: written.length > 0 ? written : evidence.map((e2) => e2.path) };
|
|
23636
23734
|
}
|
|
23637
23735
|
async function templatePublish(dir, opts) {
|
|
23638
|
-
const root2 =
|
|
23639
|
-
const manifest =
|
|
23736
|
+
const root2 = path76.resolve(dir);
|
|
23737
|
+
const manifest = path76.join(root2, "template.md");
|
|
23640
23738
|
if (!fs73.existsSync(manifest)) invalid("\u6587\u4EF6\u5939\u9876\u5C42\u7F3A\u5C11 template.md\u3002", "template.md is missing from the folder\u2019s top level.");
|
|
23641
23739
|
const meta = readTemplateMeta(fs73.readFileSync(manifest, "utf8"));
|
|
23642
23740
|
const files = walk2(root2);
|
|
23643
|
-
const total = files.reduce((sum, f2) => sum + fs73.statSync(
|
|
23741
|
+
const total = files.reduce((sum, f2) => sum + fs73.statSync(path76.join(root2, f2)).size, 0);
|
|
23644
23742
|
if (total > MAX_BYTES2) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
|
|
23645
23743
|
for (const extra of [...opts.preview, ...opts.evidence]) {
|
|
23646
23744
|
if (!fs73.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
|
|
23647
|
-
if (
|
|
23745
|
+
if (path76.resolve(extra).startsWith(root2 + path76.sep)) {
|
|
23648
23746
|
invalid(
|
|
23649
23747
|
`${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`,
|
|
23650
23748
|
`${extra} is inside the template folder; keep previews and evidence outside it.`
|
|
@@ -23656,10 +23754,10 @@ async function templatePublish(dir, opts) {
|
|
|
23656
23754
|
}
|
|
23657
23755
|
const form = new FormData();
|
|
23658
23756
|
form.set("meta", JSON.stringify({ ...meta, replace: !!opts.replace }));
|
|
23659
|
-
const add2 = (kind, name, file2) => form.append(`${kind}:${name}`, new Blob([fs73.readFileSync(file2)]),
|
|
23660
|
-
for (const f2 of files) add2("files", f2,
|
|
23661
|
-
for (const f2 of opts.preview) add2("previews",
|
|
23662
|
-
for (const f2 of opts.evidence) add2("evidence",
|
|
23757
|
+
const add2 = (kind, name, file2) => form.append(`${kind}:${name}`, new Blob([fs73.readFileSync(file2)]), path76.basename(name));
|
|
23758
|
+
for (const f2 of files) add2("files", f2, path76.join(root2, f2));
|
|
23759
|
+
for (const f2 of opts.preview) add2("previews", path76.basename(f2), f2);
|
|
23760
|
+
for (const f2 of opts.evidence) add2("evidence", path76.basename(f2), f2);
|
|
23663
23761
|
const done = await asJson(await ask("", { method: "POST", body: form }));
|
|
23664
23762
|
say(
|
|
23665
23763
|
done.replaced ? `\u5DF2\u66FF\u6362 ${done.name}\uFF1A${files.length} \u4E2A\u6587\u4EF6\u3002
|
|
@@ -23675,7 +23773,7 @@ Deleted ${name} from the catalog.`);
|
|
|
23675
23773
|
return { name, deleted: true };
|
|
23676
23774
|
}
|
|
23677
23775
|
async function templateShowcase(name, dir) {
|
|
23678
|
-
const file2 =
|
|
23776
|
+
const file2 = path76.join(dir, "showcase.json");
|
|
23679
23777
|
if (!fs73.existsSync(file2)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
|
|
23680
23778
|
let meta;
|
|
23681
23779
|
try {
|
|
@@ -23691,7 +23789,7 @@ async function templateShowcase(name, dir) {
|
|
|
23691
23789
|
const form = new FormData();
|
|
23692
23790
|
form.set("meta", JSON.stringify(meta));
|
|
23693
23791
|
for (const p2 of new Set(named2)) {
|
|
23694
|
-
const at2 =
|
|
23792
|
+
const at2 = path76.join(dir, p2);
|
|
23695
23793
|
if (!fs73.existsSync(at2)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at2}\u3002`, `${at2} does not exist.`);
|
|
23696
23794
|
form.append(`media:${p2}`, new Blob([fs73.readFileSync(at2)]), p2);
|
|
23697
23795
|
}
|
|
@@ -23702,7 +23800,7 @@ Updated ${name}'s showcase: ${done.files} files.`);
|
|
|
23702
23800
|
}
|
|
23703
23801
|
function walk2(root2, sub = "") {
|
|
23704
23802
|
const out = [];
|
|
23705
|
-
for (const entry of fs73.readdirSync(
|
|
23803
|
+
for (const entry of fs73.readdirSync(path76.join(root2, sub), { withFileTypes: true })) {
|
|
23706
23804
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
23707
23805
|
const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
|
|
23708
23806
|
if (entry.isDirectory()) out.push(...walk2(root2, rel2));
|
|
@@ -28194,7 +28292,7 @@ var init_guide2 = __esm({
|
|
|
28194
28292
|
// src/commands/studio.ts
|
|
28195
28293
|
import crypto6 from "node:crypto";
|
|
28196
28294
|
import fs74 from "node:fs";
|
|
28197
|
-
import
|
|
28295
|
+
import path77 from "node:path";
|
|
28198
28296
|
function cmdStudioList() {
|
|
28199
28297
|
if (!studiosReachable().ok) die(NEEDS_CLOUD, "needs-cloud");
|
|
28200
28298
|
const offline2 = studiosOffline();
|
|
@@ -28223,7 +28321,7 @@ function cmdStudioList() {
|
|
|
28223
28321
|
};
|
|
28224
28322
|
}
|
|
28225
28323
|
function cmdStudioDiagram(id, card, folder) {
|
|
28226
|
-
const files = folder ? readStudioFolder(
|
|
28324
|
+
const files = folder ? readStudioFolder(path77.resolve(folder)) : null;
|
|
28227
28325
|
const local = files ? parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE) : null;
|
|
28228
28326
|
if (local && "problem" in local) die(local.problem, "bad-studio");
|
|
28229
28327
|
const flow = local && "def" in local ? local.def : found(id);
|
|
@@ -28233,8 +28331,8 @@ function cmdStudioDiagram(id, card, folder) {
|
|
|
28233
28331
|
const agent = findSpecAgent(name);
|
|
28234
28332
|
return agent ? { ...agent, after: agentAfter(name) } : null;
|
|
28235
28333
|
});
|
|
28236
|
-
const file2 =
|
|
28237
|
-
fs74.mkdirSync(
|
|
28334
|
+
const file2 = path77.join(ASSETS, String(cardId2), "studio.json");
|
|
28335
|
+
fs74.mkdirSync(path77.dirname(file2), { recursive: true });
|
|
28238
28336
|
fs74.writeFileSync(file2, `${JSON.stringify(diagram, null, 2)}
|
|
28239
28337
|
`);
|
|
28240
28338
|
const tag = `<Studio src=".assets/${cardId2}/studio.json" label="${flow.name.replace(/"/g, "")}" />`;
|
|
@@ -28242,7 +28340,7 @@ function cmdStudioDiagram(id, card, folder) {
|
|
|
28242
28340
|
return { file: file2, tag, diagram };
|
|
28243
28341
|
}
|
|
28244
28342
|
function cmdStudioValidate(folder) {
|
|
28245
|
-
const dir =
|
|
28343
|
+
const dir = path77.resolve(folder);
|
|
28246
28344
|
if (!fs74.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder} is not a folder`, "bad-args");
|
|
28247
28345
|
const files = readStudioFolder(dir);
|
|
28248
28346
|
const read4 = parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE);
|
|
@@ -28271,14 +28369,14 @@ function cmdStudioValidate(folder) {
|
|
|
28271
28369
|
async function cmdStudioPull(id, folder) {
|
|
28272
28370
|
const cloudId = cloudIdOf(id);
|
|
28273
28371
|
if (!cloudId) found(id);
|
|
28274
|
-
const dir =
|
|
28372
|
+
const dir = path77.resolve(folder ?? id);
|
|
28275
28373
|
if (fs74.existsSync(dir) && fs74.readdirSync(dir).length) die(`${folder ?? id} is not empty`, "bad-args");
|
|
28276
28374
|
const read4 = await call("GET", `/v1/studios/${encodeURIComponent(cloudId)}`);
|
|
28277
28375
|
if (!read4.ok) die(read4.error, read4.code === "not_found" ? "no-such-studio" : "cloud-refused");
|
|
28278
28376
|
const { version, files } = read4.value;
|
|
28279
28377
|
for (const [file2, text6] of Object.entries({ ...files, [VERSION_FILE]: versionText(cloudId, version) })) {
|
|
28280
|
-
const full =
|
|
28281
|
-
fs74.mkdirSync(
|
|
28378
|
+
const full = path77.join(dir, ...file2.split("/"));
|
|
28379
|
+
fs74.mkdirSync(path77.dirname(full), { recursive: true });
|
|
28282
28380
|
const data = isAboutFile(file2) && !file2.endsWith(".md") && /^data:[^;]+;base64,/.exec(text6);
|
|
28283
28381
|
fs74.writeFileSync(full, data ? Buffer.from(text6.slice(data[0].length), "base64") : text6);
|
|
28284
28382
|
}
|
|
@@ -28292,7 +28390,7 @@ function publicationFiles(dir) {
|
|
|
28292
28390
|
return checked.files;
|
|
28293
28391
|
}
|
|
28294
28392
|
async function publishFolder(dir, route2, body, requestId) {
|
|
28295
|
-
const pendingFile =
|
|
28393
|
+
const pendingFile = path77.join(dir, ".publication.json");
|
|
28296
28394
|
const hash2 = crypto6.createHash("sha256").update(JSON.stringify({ route: route2, files: body.files, workspace: body.workspace })).digest("hex");
|
|
28297
28395
|
let held4;
|
|
28298
28396
|
try {
|
|
@@ -28308,29 +28406,29 @@ async function publishFolder(dir, route2, body, requestId) {
|
|
|
28308
28406
|
const { id, version } = res.value;
|
|
28309
28407
|
pending.resultVersion = version;
|
|
28310
28408
|
fs74.writeFileSync(pendingFile, JSON.stringify(pending, null, 2) + "\n");
|
|
28311
|
-
fs74.writeFileSync(
|
|
28409
|
+
fs74.writeFileSync(path77.join(dir, VERSION_FILE), versionText(id, version));
|
|
28312
28410
|
say(`Saved ${studioName(id)} v${version}. New tasks take it.`);
|
|
28313
28411
|
return { id, version, changed: true, requestId: pending.requestId };
|
|
28314
28412
|
}
|
|
28315
28413
|
async function cmdStudioCreate(folder, opts) {
|
|
28316
28414
|
if (!opts.requestId) die("--request-id is required", "bad-args");
|
|
28317
|
-
const dir =
|
|
28415
|
+
const dir = path77.resolve(folder);
|
|
28318
28416
|
const files = publicationFiles(dir);
|
|
28319
28417
|
const workspace2 = opts.workspace ?? (await cloudScope()).workspace;
|
|
28320
28418
|
return publishFolder(dir, "/v1/studios", { files, workspace: workspace2 }, opts.requestId);
|
|
28321
28419
|
}
|
|
28322
28420
|
async function cmdStudioPush(folder, opts) {
|
|
28323
|
-
const dir =
|
|
28421
|
+
const dir = path77.resolve(folder);
|
|
28324
28422
|
let pulled = null;
|
|
28325
28423
|
try {
|
|
28326
|
-
pulled = JSON.parse(fs74.readFileSync(
|
|
28424
|
+
pulled = JSON.parse(fs74.readFileSync(path77.join(dir, VERSION_FILE), "utf8"));
|
|
28327
28425
|
} catch {
|
|
28328
28426
|
}
|
|
28329
28427
|
if (!pulled?.id || !Number.isInteger(pulled.version) || pulled.version < 1) die(`${folder} has no valid version.json; pull again.`, "bad-args");
|
|
28330
28428
|
const { id, version } = pulled;
|
|
28331
28429
|
if (id.startsWith("wf_builtin_")) die("Copy this studio before editing it.", "studio-read-only");
|
|
28332
28430
|
const files = publicationFiles(dir);
|
|
28333
|
-
if (!fs74.existsSync(
|
|
28431
|
+
if (!fs74.existsSync(path77.join(dir, ".publication.json")) && !opts.requestId) {
|
|
28334
28432
|
const now = await call("GET", `/v1/studios/${encodeURIComponent(id)}`);
|
|
28335
28433
|
if (now.ok && now.value.version === version && JSON.stringify(files) === JSON.stringify(Object.fromEntries(Object.entries(now.value.files).filter(([f2]) => f2 !== VERSION_FILE).sort()))) {
|
|
28336
28434
|
say(`${studioName(id)} is unchanged (v${version}).`);
|
|
@@ -28556,10 +28654,10 @@ var init_complete = __esm({
|
|
|
28556
28654
|
|
|
28557
28655
|
// src/lib/agent/task-chats.ts
|
|
28558
28656
|
import fs75 from "node:fs";
|
|
28559
|
-
import
|
|
28657
|
+
import path78 from "node:path";
|
|
28560
28658
|
function taskChatFile(task, home3) {
|
|
28561
28659
|
if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
|
|
28562
|
-
return
|
|
28660
|
+
return path78.join(taskChatsDir(home3), `${task}.jsonl`);
|
|
28563
28661
|
}
|
|
28564
28662
|
function readTaskChat(task, home3) {
|
|
28565
28663
|
let text6;
|
|
@@ -28585,13 +28683,13 @@ var init_task_chats = __esm({
|
|
|
28585
28683
|
"use strict";
|
|
28586
28684
|
init_home();
|
|
28587
28685
|
TASK = /^[\w-]{1,100}$/;
|
|
28588
|
-
taskChatsDir = (home3 = machineHome()) =>
|
|
28686
|
+
taskChatsDir = (home3 = machineHome()) => path78.join(home3, "chats");
|
|
28589
28687
|
}
|
|
28590
28688
|
});
|
|
28591
28689
|
|
|
28592
28690
|
// src/lib/agent/memory-review.ts
|
|
28593
28691
|
import fs76 from "node:fs";
|
|
28594
|
-
import
|
|
28692
|
+
import path79 from "node:path";
|
|
28595
28693
|
function taskChatsToReview(tasks) {
|
|
28596
28694
|
const out = [];
|
|
28597
28695
|
for (const ref of [...new Set(tasks)]) {
|
|
@@ -28613,7 +28711,7 @@ function readArchived2(id) {
|
|
|
28613
28711
|
const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
|
|
28614
28712
|
if (!found2) return null;
|
|
28615
28713
|
try {
|
|
28616
|
-
const file2 = found2.kind === "group" ?
|
|
28714
|
+
const file2 = found2.kind === "group" ? path79.join(found2.target, "root.md") : found2.target;
|
|
28617
28715
|
const { meta, body } = parseFrontmatter(fs76.readFileSync(file2, "utf8"));
|
|
28618
28716
|
if (!meta) return null;
|
|
28619
28717
|
return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
|
|
@@ -28683,9 +28781,9 @@ var init_memory_review = __esm({
|
|
|
28683
28781
|
|
|
28684
28782
|
// src/lib/agent/dismissal-review.ts
|
|
28685
28783
|
import fs77 from "node:fs";
|
|
28686
|
-
import
|
|
28784
|
+
import path80 from "node:path";
|
|
28687
28785
|
function rejectionsToReview() {
|
|
28688
|
-
const dir =
|
|
28786
|
+
const dir = path80.join(ARCHIVE, REJECTIONS_TO_REVIEW);
|
|
28689
28787
|
if (!fs77.existsSync(dir)) return [];
|
|
28690
28788
|
const found2 = [];
|
|
28691
28789
|
for (const file2 of walkMd(dir)) {
|
|
@@ -28748,7 +28846,7 @@ var init_dismissal_review = __esm({
|
|
|
28748
28846
|
|
|
28749
28847
|
// src/lib/agent/flow.ts
|
|
28750
28848
|
import fs78 from "node:fs";
|
|
28751
|
-
import
|
|
28849
|
+
import path81 from "node:path";
|
|
28752
28850
|
function readCard2(id, home3 = "board") {
|
|
28753
28851
|
const pending = activeDelivery(id)?.completions?.some((c2) => !c2.finished);
|
|
28754
28852
|
const found2 = home3 === "archive" ? locateArchived(id) : locate2(id) ?? (pending ? locateArchived(id) : null);
|
|
@@ -28758,7 +28856,7 @@ function readCard2(id, home3 = "board") {
|
|
|
28758
28856
|
{ kind: "card-not-found", id }
|
|
28759
28857
|
);
|
|
28760
28858
|
}
|
|
28761
|
-
const file2 = found2.kind === "group" ?
|
|
28859
|
+
const file2 = found2.kind === "group" ? path81.join(found2.target, "root.md") : found2.target;
|
|
28762
28860
|
let text6;
|
|
28763
28861
|
try {
|
|
28764
28862
|
text6 = fs78.readFileSync(file2, "utf8");
|
|
@@ -29632,9 +29730,11 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
29632
29730
|
}
|
|
29633
29731
|
const stagePrompt = record.action === "spec" && record.cardId !== null && record.specAgent ? previewStagePrompt(record.cardId, record.specAgent, boardCommandFor(record.cardId)) : "";
|
|
29634
29732
|
const basePrompt = record.resumedFrom ? spec.prompt || resumePrompt(record.deliveryId, record.action) : spec.prompt;
|
|
29635
|
-
const
|
|
29733
|
+
const recoveryPrompt = record.harness === "antigravity" && record.resumedFrom ? "First verify existing progress and operation results. Preserve user decisions and completed work; do not repeat completed operations. Check actual state before continuing any operation whose result is uncertain." : "";
|
|
29734
|
+
const prompt = [basePrompt, recoveryPrompt, basePrompt.includes(stagePrompt) ? "" : stagePrompt, discardedCardsPrompt(record.discardedCards)].filter(Boolean).join("\n\n");
|
|
29636
29735
|
const before = markBoard();
|
|
29637
29736
|
const takes = active3.images;
|
|
29737
|
+
active3.renderer?.setRequiredImages?.(record.pictures ?? []);
|
|
29638
29738
|
const shots = takes?.as === "args" ? (record.pictures ?? []).flatMap((file2) => takes.args(file2)) : [];
|
|
29639
29739
|
const [cmd, ...args2] = [...active3.argv, ...shots];
|
|
29640
29740
|
const workDir = active3.cwd ?? REPO_ROOT;
|
|
@@ -29739,6 +29839,8 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
29739
29839
|
};
|
|
29740
29840
|
let touch = () => {
|
|
29741
29841
|
};
|
|
29842
|
+
let endLimited = () => {
|
|
29843
|
+
};
|
|
29742
29844
|
child.stdout.on("data", (d2) => {
|
|
29743
29845
|
if (renderer) {
|
|
29744
29846
|
append2(renderer.push(d2.toString()));
|
|
@@ -29747,6 +29849,7 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
29747
29849
|
gotModel(renderer.model?.());
|
|
29748
29850
|
gotContext(renderer.context?.());
|
|
29749
29851
|
afterTurn();
|
|
29852
|
+
if (renderer.rateLimit?.()) endLimited();
|
|
29750
29853
|
}
|
|
29751
29854
|
touch();
|
|
29752
29855
|
});
|
|
@@ -29754,6 +29857,7 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
29754
29857
|
child.stderr.on("data", (d2) => {
|
|
29755
29858
|
touch();
|
|
29756
29859
|
renderer?.stderr?.(d2.toString());
|
|
29860
|
+
if (renderer?.rateLimit?.()) endLimited();
|
|
29757
29861
|
const text6 = errs.push(d2.toString());
|
|
29758
29862
|
if (text6) log.write(text6);
|
|
29759
29863
|
});
|
|
@@ -29968,6 +30072,7 @@ ${result}
|
|
|
29968
30072
|
void finish(null, asked).finally(() => process.exit(0));
|
|
29969
30073
|
});
|
|
29970
30074
|
};
|
|
30075
|
+
endLimited = () => giveUp(false);
|
|
29971
30076
|
const cancellation = new AbortController();
|
|
29972
30077
|
let stopped2 = false;
|
|
29973
30078
|
const askToStop = () => {
|
|
@@ -30154,7 +30259,7 @@ var init_watch = __esm({
|
|
|
30154
30259
|
|
|
30155
30260
|
// src/commands/run.ts
|
|
30156
30261
|
import fs80 from "node:fs";
|
|
30157
|
-
import
|
|
30262
|
+
import path82 from "node:path";
|
|
30158
30263
|
async function cmdStartRun(action, args2, opts, program2 = "akb") {
|
|
30159
30264
|
if (action === "approve" && (opts.preview || opts.previewStage || opts.previewVersion || opts.definitionRevision)) return confirmLocalPreview(Number(args2[0]), opts);
|
|
30160
30265
|
const { req, follow: follow2, print } = readRequest(action, args2, opts);
|
|
@@ -30382,7 +30487,7 @@ async function cmdSubStart(words, opts) {
|
|
|
30382
30487
|
let prompt = words.join(" ");
|
|
30383
30488
|
if (opts.file) {
|
|
30384
30489
|
try {
|
|
30385
|
-
prompt = fs80.readFileSync(
|
|
30490
|
+
prompt = fs80.readFileSync(path82.resolve(opts.file), "utf8");
|
|
30386
30491
|
} catch {
|
|
30387
30492
|
die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
|
|
30388
30493
|
}
|
|
@@ -30716,7 +30821,7 @@ var init_config3 = __esm({
|
|
|
30716
30821
|
|
|
30717
30822
|
// src/lib/signals/migrate.ts
|
|
30718
30823
|
import fs81 from "node:fs";
|
|
30719
|
-
import
|
|
30824
|
+
import path83 from "node:path";
|
|
30720
30825
|
function readHandled() {
|
|
30721
30826
|
let text6;
|
|
30722
30827
|
try {
|
|
@@ -30738,7 +30843,7 @@ function readHandled() {
|
|
|
30738
30843
|
}
|
|
30739
30844
|
function lift(from, into) {
|
|
30740
30845
|
fs81.mkdirSync(into, { recursive: true });
|
|
30741
|
-
fs81.renameSync(from,
|
|
30846
|
+
fs81.renameSync(from, path83.join(into, freeName(into, path83.basename(from))));
|
|
30742
30847
|
}
|
|
30743
30848
|
function repoint(dir, from, into) {
|
|
30744
30849
|
let entries;
|
|
@@ -30749,7 +30854,7 @@ function repoint(dir, from, into) {
|
|
|
30749
30854
|
}
|
|
30750
30855
|
for (const entry of entries) {
|
|
30751
30856
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
30752
|
-
const file2 =
|
|
30857
|
+
const file2 = path83.join(dir, entry.name);
|
|
30753
30858
|
const text6 = fs81.readFileSync(file2, "utf8");
|
|
30754
30859
|
if (text6.includes(from)) fs81.writeFileSync(file2, text6.split(from).join(into));
|
|
30755
30860
|
}
|
|
@@ -30762,17 +30867,17 @@ function dropIfEmpty(dir) {
|
|
|
30762
30867
|
}
|
|
30763
30868
|
function liftInbox() {
|
|
30764
30869
|
if (!fs81.existsSync(SIGNALS_OLD_INBOX)) return;
|
|
30765
|
-
const oldFiles =
|
|
30870
|
+
const oldFiles = path83.join(SIGNALS_OLD_INBOX, "files");
|
|
30766
30871
|
if (fs81.existsSync(oldFiles)) {
|
|
30767
30872
|
for (const entry of fs81.readdirSync(oldFiles, { withFileTypes: true })) {
|
|
30768
|
-
if (entry.isFile()) lift(
|
|
30873
|
+
if (entry.isFile()) lift(path83.join(oldFiles, entry.name), SIGNALS_FILES);
|
|
30769
30874
|
}
|
|
30770
30875
|
dropIfEmpty(oldFiles);
|
|
30771
30876
|
}
|
|
30772
30877
|
const held4 = new Set(readFolder(TRIAGE).map((signal2) => signal2.sourceId));
|
|
30773
30878
|
for (const entry of fs81.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
|
|
30774
30879
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
30775
|
-
const from =
|
|
30880
|
+
const from = path83.join(SIGNALS_OLD_INBOX, entry.name);
|
|
30776
30881
|
const item = parse(from);
|
|
30777
30882
|
if (item && held4.has(item.sourceId)) {
|
|
30778
30883
|
fs81.rmSync(from, { force: true });
|
|
@@ -30781,7 +30886,7 @@ function liftInbox() {
|
|
|
30781
30886
|
if (item) held4.add(item.sourceId);
|
|
30782
30887
|
lift(from, TRIAGE);
|
|
30783
30888
|
}
|
|
30784
|
-
const wasAt = asWritten(
|
|
30889
|
+
const wasAt = asWritten(path83.join(SIGNALS_OLD_INBOX, "files"));
|
|
30785
30890
|
const nowAt = asWritten(SIGNALS_FILES);
|
|
30786
30891
|
for (const dir of [TRIAGE, SIGNALS_ARCHIVED, SIGNALS_DISMISSED]) repoint(dir, wasAt, nowAt);
|
|
30787
30892
|
dropIfEmpty(SIGNALS_OLD_INBOX);
|
|
@@ -30807,7 +30912,7 @@ function liftHandled() {
|
|
|
30807
30912
|
"---",
|
|
30808
30913
|
""
|
|
30809
30914
|
];
|
|
30810
|
-
fs81.writeFileSync(
|
|
30915
|
+
fs81.writeFileSync(path83.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
|
|
30811
30916
|
`);
|
|
30812
30917
|
}
|
|
30813
30918
|
fs81.rmSync(SIGNALS_OLD_HANDLED, { force: true });
|
|
@@ -30828,7 +30933,7 @@ var init_migrate = __esm({
|
|
|
30828
30933
|
init_yaml();
|
|
30829
30934
|
init_inbox();
|
|
30830
30935
|
HANDLED_LINE = /^-\s+(.+?)\s+—\s+(.+)$/;
|
|
30831
|
-
asWritten = (dir) => `${rel(dir).split(
|
|
30936
|
+
asWritten = (dir) => `${rel(dir).split(path83.sep).join("/")}/`;
|
|
30832
30937
|
}
|
|
30833
30938
|
});
|
|
30834
30939
|
|
|
@@ -30882,7 +30987,7 @@ var init_identity2 = __esm({
|
|
|
30882
30987
|
|
|
30883
30988
|
// src/lib/signals/add.ts
|
|
30884
30989
|
import fs82 from "node:fs";
|
|
30885
|
-
import
|
|
30990
|
+
import path84 from "node:path";
|
|
30886
30991
|
import { createHash as createHash9 } from "node:crypto";
|
|
30887
30992
|
function linkTitle(url) {
|
|
30888
30993
|
let at2;
|
|
@@ -30895,7 +31000,7 @@ function linkTitle(url) {
|
|
|
30895
31000
|
return oneLine(where) || url.slice(0, TITLE_MAX);
|
|
30896
31001
|
}
|
|
30897
31002
|
function asText(file2) {
|
|
30898
|
-
const ext =
|
|
31003
|
+
const ext = path84.extname(file2.name).toLowerCase();
|
|
30899
31004
|
if (!file2.type.startsWith("text/") && file2.type !== "application/json" && !TEXT_EXTENSIONS.has(ext)) return null;
|
|
30900
31005
|
try {
|
|
30901
31006
|
const text6 = new TextDecoder("utf-8", { fatal: true }).decode(file2.data);
|
|
@@ -30905,9 +31010,9 @@ function asText(file2) {
|
|
|
30905
31010
|
}
|
|
30906
31011
|
}
|
|
30907
31012
|
function fileName2(name, data) {
|
|
30908
|
-
const base =
|
|
30909
|
-
const ext =
|
|
30910
|
-
const word =
|
|
31013
|
+
const base = path84.basename(name);
|
|
31014
|
+
const ext = path84.extname(base).toLowerCase().slice(0, 12);
|
|
31015
|
+
const word = path84.basename(base, path84.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
|
|
30911
31016
|
const hash2 = createHash9("sha256").update(data).digest("hex").slice(0, 8);
|
|
30912
31017
|
return `${word}-${hash2}${ext}`;
|
|
30913
31018
|
}
|
|
@@ -30916,9 +31021,9 @@ function addToInbox(drop) {
|
|
|
30916
31021
|
const typed = (drop.text ?? "").trim();
|
|
30917
31022
|
const file2 = drop.file;
|
|
30918
31023
|
if (!typed && !file2) return { ok: false, error: "nothing to add \u2014 paste a link or some text, or drop a file." };
|
|
30919
|
-
if (file2 && file2.data.length === 0) return { ok: false, error: `${
|
|
31024
|
+
if (file2 && file2.data.length === 0) return { ok: false, error: `${path84.basename(file2.name)} is empty.` };
|
|
30920
31025
|
if (file2 && file2.data.length > MAX_BYTES3) {
|
|
30921
|
-
return { ok: false, error: `${
|
|
31026
|
+
return { ok: false, error: `${path84.basename(file2.name)} is over ${MAX_BYTES3 / 1024 / 1024} MB \u2014 too big for the board.` };
|
|
30922
31027
|
}
|
|
30923
31028
|
const read4 = describe(typed, file2);
|
|
30924
31029
|
const keep2 = read4.keep;
|
|
@@ -30955,7 +31060,7 @@ function describe(typed, file2) {
|
|
|
30955
31060
|
return only ? [only] : [];
|
|
30956
31061
|
};
|
|
30957
31062
|
if (file2) {
|
|
30958
|
-
const name =
|
|
31063
|
+
const name = path84.basename(file2.name);
|
|
30959
31064
|
const text6 = asText(file2);
|
|
30960
31065
|
const note = typed ? `
|
|
30961
31066
|
|
|
@@ -30967,7 +31072,7 @@ ${typed}` : "";
|
|
|
30967
31072
|
const at2 = keepAt(file2);
|
|
30968
31073
|
return {
|
|
30969
31074
|
incoming: {
|
|
30970
|
-
title:
|
|
31075
|
+
title: path84.basename(name, path84.extname(name)) || name,
|
|
30971
31076
|
summary: `${name} \u2014 ${boardRel2(at2)}${note}`,
|
|
30972
31077
|
...named2
|
|
30973
31078
|
},
|
|
@@ -31005,13 +31110,13 @@ var init_add = __esm({
|
|
|
31005
31110
|
MAX_BYTES3 = 25 * 1024 * 1024;
|
|
31006
31111
|
TITLE_MAX = 120;
|
|
31007
31112
|
TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".text", ".csv", ".json", ".yml", ".yaml", ".log"]);
|
|
31008
|
-
boardRel2 = (file2) => rel(file2).split(
|
|
31113
|
+
boardRel2 = (file2) => rel(file2).split(path84.sep).join("/");
|
|
31009
31114
|
oneLine = (text6) => {
|
|
31010
31115
|
const first = text6.split("\n").find((line) => line.trim()) ?? "";
|
|
31011
31116
|
const clean = first.replace(/^#+\s*/, "").trim();
|
|
31012
31117
|
return clean.length > TITLE_MAX ? `${clean.slice(0, TITLE_MAX - 1).trimEnd()}\u2026` : clean;
|
|
31013
31118
|
};
|
|
31014
|
-
keepAt = (file2) =>
|
|
31119
|
+
keepAt = (file2) => path84.join(SIGNALS_FILES, fileName2(file2.name, file2.data));
|
|
31015
31120
|
}
|
|
31016
31121
|
});
|
|
31017
31122
|
|
|
@@ -72450,8 +72555,8 @@ var require_JSXTransformer = __commonJS({
|
|
|
72450
72555
|
}
|
|
72451
72556
|
if (this.isAutomaticRuntime) {
|
|
72452
72557
|
if (this.importProcessor) {
|
|
72453
|
-
for (const [
|
|
72454
|
-
prefix += `var ${resolvedName} = require("${
|
|
72558
|
+
for (const [path89, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
|
|
72559
|
+
prefix += `var ${resolvedName} = require("${path89}");`;
|
|
72455
72560
|
}
|
|
72456
72561
|
} else {
|
|
72457
72562
|
const { createElement: createElementResolution, ...otherResolutions } = this.esmAutomaticImportNameResolutions;
|
|
@@ -72644,11 +72749,11 @@ var require_JSXTransformer = __commonJS({
|
|
|
72644
72749
|
}
|
|
72645
72750
|
claimAutoImportedName(funcName, importPathSuffix) {
|
|
72646
72751
|
if (this.importProcessor) {
|
|
72647
|
-
const
|
|
72648
|
-
if (!this.cjsAutomaticModuleNameResolutions[
|
|
72649
|
-
this.cjsAutomaticModuleNameResolutions[
|
|
72752
|
+
const path89 = this.jsxImportSource + importPathSuffix;
|
|
72753
|
+
if (!this.cjsAutomaticModuleNameResolutions[path89]) {
|
|
72754
|
+
this.cjsAutomaticModuleNameResolutions[path89] = this.importProcessor.getFreeIdentifierForPath(path89);
|
|
72650
72755
|
}
|
|
72651
|
-
return `${this.cjsAutomaticModuleNameResolutions[
|
|
72756
|
+
return `${this.cjsAutomaticModuleNameResolutions[path89]}.${funcName}`;
|
|
72652
72757
|
} else {
|
|
72653
72758
|
if (!this.esmAutomaticImportNameResolutions[funcName]) {
|
|
72654
72759
|
this.esmAutomaticImportNameResolutions[funcName] = this.nameManager.claimFreeName(
|
|
@@ -73084,7 +73189,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73084
73189
|
*/
|
|
73085
73190
|
pruneTypeOnlyImports() {
|
|
73086
73191
|
this.nonTypeIdentifiers = _getNonTypeIdentifiers.getNonTypeIdentifiers.call(void 0, this.tokens, this.options);
|
|
73087
|
-
for (const [
|
|
73192
|
+
for (const [path89, importInfo] of this.importInfoByPath.entries()) {
|
|
73088
73193
|
if (importInfo.hasBareImport || importInfo.hasStarExport || importInfo.exportStarNames.length > 0 || importInfo.namedExports.length > 0) {
|
|
73089
73194
|
continue;
|
|
73090
73195
|
}
|
|
@@ -73094,7 +73199,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73094
73199
|
...importInfo.namedImports.map(({ localName }) => localName)
|
|
73095
73200
|
];
|
|
73096
73201
|
if (names3.every((name) => this.shouldAutomaticallyElideImportedName(name))) {
|
|
73097
|
-
this.importsToReplace.set(
|
|
73202
|
+
this.importsToReplace.set(path89, "");
|
|
73098
73203
|
}
|
|
73099
73204
|
}
|
|
73100
73205
|
}
|
|
@@ -73102,7 +73207,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73102
73207
|
return this.isTypeScriptTransformEnabled && !this.keepUnusedImports && !this.nonTypeIdentifiers.has(name);
|
|
73103
73208
|
}
|
|
73104
73209
|
generateImportReplacements() {
|
|
73105
|
-
for (const [
|
|
73210
|
+
for (const [path89, importInfo] of this.importInfoByPath.entries()) {
|
|
73106
73211
|
const {
|
|
73107
73212
|
defaultNames,
|
|
73108
73213
|
wildcardNames,
|
|
@@ -73112,17 +73217,17 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73112
73217
|
hasStarExport
|
|
73113
73218
|
} = importInfo;
|
|
73114
73219
|
if (defaultNames.length === 0 && wildcardNames.length === 0 && namedImports.length === 0 && namedExports.length === 0 && exportStarNames.length === 0 && !hasStarExport) {
|
|
73115
|
-
this.importsToReplace.set(
|
|
73220
|
+
this.importsToReplace.set(path89, `require('${path89}');`);
|
|
73116
73221
|
continue;
|
|
73117
73222
|
}
|
|
73118
|
-
const primaryImportName = this.getFreeIdentifierForPath(
|
|
73223
|
+
const primaryImportName = this.getFreeIdentifierForPath(path89);
|
|
73119
73224
|
let secondaryImportName;
|
|
73120
73225
|
if (this.enableLegacyTypeScriptModuleInterop) {
|
|
73121
73226
|
secondaryImportName = primaryImportName;
|
|
73122
73227
|
} else {
|
|
73123
|
-
secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(
|
|
73228
|
+
secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path89);
|
|
73124
73229
|
}
|
|
73125
|
-
let requireCode = `var ${primaryImportName} = require('${
|
|
73230
|
+
let requireCode = `var ${primaryImportName} = require('${path89}');`;
|
|
73126
73231
|
if (wildcardNames.length > 0) {
|
|
73127
73232
|
for (const wildcardName of wildcardNames) {
|
|
73128
73233
|
const moduleExpr = this.enableLegacyTypeScriptModuleInterop ? primaryImportName : `${this.helperManager.getHelperName("interopRequireWildcard")}(${primaryImportName})`;
|
|
@@ -73150,7 +73255,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73150
73255
|
"createStarExport"
|
|
73151
73256
|
)}(${primaryImportName});`;
|
|
73152
73257
|
}
|
|
73153
|
-
this.importsToReplace.set(
|
|
73258
|
+
this.importsToReplace.set(path89, requireCode);
|
|
73154
73259
|
for (const defaultName of defaultNames) {
|
|
73155
73260
|
this.identifierReplacements.set(defaultName, `${secondaryImportName}.default`);
|
|
73156
73261
|
}
|
|
@@ -73159,8 +73264,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73159
73264
|
}
|
|
73160
73265
|
}
|
|
73161
73266
|
}
|
|
73162
|
-
getFreeIdentifierForPath(
|
|
73163
|
-
const components =
|
|
73267
|
+
getFreeIdentifierForPath(path89) {
|
|
73268
|
+
const components = path89.split("/");
|
|
73164
73269
|
const lastComponent = components[components.length - 1];
|
|
73165
73270
|
const baseName = lastComponent.replace(/\W/g, "");
|
|
73166
73271
|
return this.nameManager.claimFreeName(`_${baseName}`);
|
|
@@ -73205,8 +73310,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73205
73310
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
73206
73311
|
throw new Error("Expected string token at the end of import statement.");
|
|
73207
73312
|
}
|
|
73208
|
-
const
|
|
73209
|
-
const importInfo = this.getImportInfo(
|
|
73313
|
+
const path89 = this.tokens.stringValueAtIndex(index);
|
|
73314
|
+
const importInfo = this.getImportInfo(path89);
|
|
73210
73315
|
importInfo.defaultNames.push(...defaultNames);
|
|
73211
73316
|
importInfo.wildcardNames.push(...wildcardNames);
|
|
73212
73317
|
importInfo.namedImports.push(...namedImports);
|
|
@@ -73273,8 +73378,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73273
73378
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
73274
73379
|
throw new Error("Expected string token at the end of import statement.");
|
|
73275
73380
|
}
|
|
73276
|
-
const
|
|
73277
|
-
const importInfo = this.getImportInfo(
|
|
73381
|
+
const path89 = this.tokens.stringValueAtIndex(index);
|
|
73382
|
+
const importInfo = this.getImportInfo(path89);
|
|
73278
73383
|
importInfo.namedExports.push(...namedImports);
|
|
73279
73384
|
}
|
|
73280
73385
|
preprocessExportStarAtIndex(index) {
|
|
@@ -73289,8 +73394,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73289
73394
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
73290
73395
|
throw new Error("Expected string token at the end of star export statement.");
|
|
73291
73396
|
}
|
|
73292
|
-
const
|
|
73293
|
-
const importInfo = this.getImportInfo(
|
|
73397
|
+
const path89 = this.tokens.stringValueAtIndex(index);
|
|
73398
|
+
const importInfo = this.getImportInfo(path89);
|
|
73294
73399
|
if (exportedName !== null) {
|
|
73295
73400
|
importInfo.exportStarNames.push(exportedName);
|
|
73296
73401
|
} else {
|
|
@@ -73330,8 +73435,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73330
73435
|
* Get a mutable import info object for this path, creating one if it doesn't
|
|
73331
73436
|
* exist yet.
|
|
73332
73437
|
*/
|
|
73333
|
-
getImportInfo(
|
|
73334
|
-
const existingInfo = this.importInfoByPath.get(
|
|
73438
|
+
getImportInfo(path89) {
|
|
73439
|
+
const existingInfo = this.importInfoByPath.get(path89);
|
|
73335
73440
|
if (existingInfo) {
|
|
73336
73441
|
return existingInfo;
|
|
73337
73442
|
}
|
|
@@ -73344,7 +73449,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73344
73449
|
exportStarNames: [],
|
|
73345
73450
|
hasStarExport: false
|
|
73346
73451
|
};
|
|
73347
|
-
this.importInfoByPath.set(
|
|
73452
|
+
this.importInfoByPath.set(path89, newInfo);
|
|
73348
73453
|
return newInfo;
|
|
73349
73454
|
}
|
|
73350
73455
|
addExportBinding(localName, exportedName) {
|
|
@@ -73924,16 +74029,16 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
73924
74029
|
}
|
|
73925
74030
|
function parseFileUrl(input) {
|
|
73926
74031
|
const match = fileRegex.exec(input);
|
|
73927
|
-
const
|
|
73928
|
-
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(
|
|
74032
|
+
const path89 = match[2];
|
|
74033
|
+
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path89) ? path89 : "/" + path89, match[3] || "", match[4] || "");
|
|
73929
74034
|
}
|
|
73930
|
-
function makeUrl(scheme, user, host2, port,
|
|
74035
|
+
function makeUrl(scheme, user, host2, port, path89, query, hash2) {
|
|
73931
74036
|
return {
|
|
73932
74037
|
scheme,
|
|
73933
74038
|
user,
|
|
73934
74039
|
host: host2,
|
|
73935
74040
|
port,
|
|
73936
|
-
path:
|
|
74041
|
+
path: path89,
|
|
73937
74042
|
query,
|
|
73938
74043
|
hash: hash2,
|
|
73939
74044
|
type: 7
|
|
@@ -73963,11 +74068,11 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
73963
74068
|
url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
|
|
73964
74069
|
return url;
|
|
73965
74070
|
}
|
|
73966
|
-
function stripPathFilename(
|
|
73967
|
-
if (
|
|
73968
|
-
return
|
|
73969
|
-
const index =
|
|
73970
|
-
return
|
|
74071
|
+
function stripPathFilename(path89) {
|
|
74072
|
+
if (path89.endsWith("/.."))
|
|
74073
|
+
return path89;
|
|
74074
|
+
const index = path89.lastIndexOf("/");
|
|
74075
|
+
return path89.slice(0, index + 1);
|
|
73971
74076
|
}
|
|
73972
74077
|
function mergePaths(url, base) {
|
|
73973
74078
|
normalizePath(base, base.type);
|
|
@@ -74005,14 +74110,14 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
74005
74110
|
pieces[pointer++] = piece;
|
|
74006
74111
|
positive++;
|
|
74007
74112
|
}
|
|
74008
|
-
let
|
|
74113
|
+
let path89 = "";
|
|
74009
74114
|
for (let i = 1; i < pointer; i++) {
|
|
74010
|
-
|
|
74115
|
+
path89 += "/" + pieces[i];
|
|
74011
74116
|
}
|
|
74012
|
-
if (!
|
|
74013
|
-
|
|
74117
|
+
if (!path89 || addTrailingSlash && !path89.endsWith("/..")) {
|
|
74118
|
+
path89 += "/";
|
|
74014
74119
|
}
|
|
74015
|
-
url.path =
|
|
74120
|
+
url.path = path89;
|
|
74016
74121
|
}
|
|
74017
74122
|
function resolve2(input, base) {
|
|
74018
74123
|
if (!input && !base)
|
|
@@ -74053,13 +74158,13 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
74053
74158
|
case 3:
|
|
74054
74159
|
return queryHash;
|
|
74055
74160
|
case 4: {
|
|
74056
|
-
const
|
|
74057
|
-
if (!
|
|
74161
|
+
const path89 = url.path.slice(1);
|
|
74162
|
+
if (!path89)
|
|
74058
74163
|
return queryHash || ".";
|
|
74059
|
-
if (isRelative(base || input) && !isRelative(
|
|
74060
|
-
return "./" +
|
|
74164
|
+
if (isRelative(base || input) && !isRelative(path89)) {
|
|
74165
|
+
return "./" + path89 + queryHash;
|
|
74061
74166
|
}
|
|
74062
|
-
return
|
|
74167
|
+
return path89 + queryHash;
|
|
74063
74168
|
}
|
|
74064
74169
|
case 5:
|
|
74065
74170
|
return url.path + queryHash;
|
|
@@ -74158,10 +74263,10 @@ var require_trace_mapping_umd = __commonJS({
|
|
|
74158
74263
|
module2.exports = __toCommonJS(trace_mapping_exports);
|
|
74159
74264
|
var import_sourcemap_codec = __toESM2(require_sourcemap_codec());
|
|
74160
74265
|
var import_resolve_uri = __toESM2(require_resolve_uri());
|
|
74161
|
-
function stripFilename(
|
|
74162
|
-
if (!
|
|
74163
|
-
const index =
|
|
74164
|
-
return
|
|
74266
|
+
function stripFilename(path89) {
|
|
74267
|
+
if (!path89) return "";
|
|
74268
|
+
const index = path89.lastIndexOf("/");
|
|
74269
|
+
return path89.slice(0, index + 1);
|
|
74165
74270
|
}
|
|
74166
74271
|
function resolver2(mapUrl, sourceRoot) {
|
|
74167
74272
|
const from = stripFilename(mapUrl);
|
|
@@ -75369,9 +75474,9 @@ var require_util2 = __commonJS({
|
|
|
75369
75474
|
/** @class */
|
|
75370
75475
|
(function(_super) {
|
|
75371
75476
|
__extends(VError2, _super);
|
|
75372
|
-
function VError2(
|
|
75477
|
+
function VError2(path89, message) {
|
|
75373
75478
|
var _this = _super.call(this, message) || this;
|
|
75374
|
-
_this.path =
|
|
75479
|
+
_this.path = path89;
|
|
75375
75480
|
Object.setPrototypeOf(_this, VError2.prototype);
|
|
75376
75481
|
return _this;
|
|
75377
75482
|
}
|
|
@@ -75431,26 +75536,26 @@ var require_util2 = __commonJS({
|
|
|
75431
75536
|
(_b = this._messages).push.apply(_b, best._messages);
|
|
75432
75537
|
}
|
|
75433
75538
|
};
|
|
75434
|
-
DetailContext2.prototype.getError = function(
|
|
75539
|
+
DetailContext2.prototype.getError = function(path89) {
|
|
75435
75540
|
var msgParts = [];
|
|
75436
75541
|
for (var i = this._propNames.length - 1; i >= 0; i--) {
|
|
75437
75542
|
var p2 = this._propNames[i];
|
|
75438
|
-
|
|
75543
|
+
path89 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
|
|
75439
75544
|
var m = this._messages[i];
|
|
75440
75545
|
if (m) {
|
|
75441
|
-
msgParts.push(
|
|
75546
|
+
msgParts.push(path89 + " " + m);
|
|
75442
75547
|
}
|
|
75443
75548
|
}
|
|
75444
|
-
return new VError(
|
|
75549
|
+
return new VError(path89, msgParts.join("; "));
|
|
75445
75550
|
};
|
|
75446
|
-
DetailContext2.prototype.getErrorDetail = function(
|
|
75551
|
+
DetailContext2.prototype.getErrorDetail = function(path89) {
|
|
75447
75552
|
var details = [];
|
|
75448
75553
|
for (var i = this._propNames.length - 1; i >= 0; i--) {
|
|
75449
75554
|
var p2 = this._propNames[i];
|
|
75450
|
-
|
|
75555
|
+
path89 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
|
|
75451
75556
|
var message = this._messages[i];
|
|
75452
75557
|
if (message) {
|
|
75453
|
-
details.push({ path:
|
|
75558
|
+
details.push({ path: path89, message });
|
|
75454
75559
|
}
|
|
75455
75560
|
}
|
|
75456
75561
|
var detail = null;
|
|
@@ -76263,8 +76368,8 @@ var require_dist = __commonJS({
|
|
|
76263
76368
|
this.checkerPlain = this.ttype.getChecker(suite, false);
|
|
76264
76369
|
this.checkerStrict = this.ttype.getChecker(suite, true);
|
|
76265
76370
|
}
|
|
76266
|
-
Checker2.prototype.setReportedPath = function(
|
|
76267
|
-
this._path =
|
|
76371
|
+
Checker2.prototype.setReportedPath = function(path89) {
|
|
76372
|
+
this._path = path89;
|
|
76268
76373
|
};
|
|
76269
76374
|
Checker2.prototype.check = function(value) {
|
|
76270
76375
|
return this._doCheck(this.checkerPlain, value);
|
|
@@ -81697,9 +81802,9 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
81697
81802
|
if (shouldElideImport) {
|
|
81698
81803
|
this.tokens.removeToken();
|
|
81699
81804
|
} else {
|
|
81700
|
-
const
|
|
81701
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
81702
|
-
this.tokens.appendCode(this.importProcessor.claimImportCode(
|
|
81805
|
+
const path89 = this.tokens.stringValue();
|
|
81806
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path89));
|
|
81807
|
+
this.tokens.appendCode(this.importProcessor.claimImportCode(path89));
|
|
81703
81808
|
}
|
|
81704
81809
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
81705
81810
|
if (this.tokens.matches1(_types.TokenType.semi)) {
|
|
@@ -82279,8 +82384,8 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
82279
82384
|
}
|
|
82280
82385
|
if (this.tokens.matchesContextual(_keywords.ContextualKeyword._from)) {
|
|
82281
82386
|
this.tokens.removeToken();
|
|
82282
|
-
const
|
|
82283
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
82387
|
+
const path89 = this.tokens.stringValue();
|
|
82388
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path89));
|
|
82284
82389
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
82285
82390
|
} else {
|
|
82286
82391
|
this.tokens.appendCode(exportStatements.join(" "));
|
|
@@ -82294,8 +82399,8 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
82294
82399
|
while (!this.tokens.matches1(_types.TokenType.string)) {
|
|
82295
82400
|
this.tokens.removeToken();
|
|
82296
82401
|
}
|
|
82297
|
-
const
|
|
82298
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
82402
|
+
const path89 = this.tokens.stringValue();
|
|
82403
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path89));
|
|
82299
82404
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
82300
82405
|
if (this.tokens.matches1(_types.TokenType.semi)) {
|
|
82301
82406
|
this.tokens.removeToken();
|
|
@@ -112149,9 +112254,9 @@ var init_bundle_mjs = __esm({
|
|
|
112149
112254
|
processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
|
|
112150
112255
|
}
|
|
112151
112256
|
};
|
|
112152
|
-
getPart = (classPartObject,
|
|
112257
|
+
getPart = (classPartObject, path89) => {
|
|
112153
112258
|
let current = classPartObject;
|
|
112154
|
-
const parts =
|
|
112259
|
+
const parts = path89.split(CLASS_PART_SEPARATOR);
|
|
112155
112260
|
const len = parts.length;
|
|
112156
112261
|
for (let i = 0; i < len; i++) {
|
|
112157
112262
|
const part = parts[i];
|
|
@@ -115402,7 +115507,7 @@ var init_dist = __esm({
|
|
|
115402
115507
|
|
|
115403
115508
|
// src/lib/draw-mockup.ts
|
|
115404
115509
|
import fs84 from "node:fs";
|
|
115405
|
-
import
|
|
115510
|
+
import path85 from "node:path";
|
|
115406
115511
|
import vm from "node:vm";
|
|
115407
115512
|
async function loadPackage(id) {
|
|
115408
115513
|
if (id === "react") return import_react3.default;
|
|
@@ -115415,16 +115520,16 @@ async function loadPackage(id) {
|
|
|
115415
115520
|
return { __esModule: true, ...await load() };
|
|
115416
115521
|
}
|
|
115417
115522
|
function resolveFile(id, from, folder) {
|
|
115418
|
-
const at2 =
|
|
115419
|
-
if (at2 !== folder && !at2.startsWith(folder +
|
|
115420
|
-
const tries =
|
|
115523
|
+
const at2 = path85.resolve(path85.dirname(from), id);
|
|
115524
|
+
if (at2 !== folder && !at2.startsWith(folder + path85.sep)) throw new Error(`${id} is outside the mockup's folder`);
|
|
115525
|
+
const tries = path85.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path85.join(at2, `index${e2}`))];
|
|
115421
115526
|
const file2 = tries.find((f2) => fs84.statSync(f2, { throwIfNoEntry: false })?.isFile());
|
|
115422
115527
|
if (!file2) throw new Error(`no such file: ${id}`);
|
|
115423
|
-
if (!fs84.realpathSync(file2).startsWith(fs84.realpathSync(folder) +
|
|
115528
|
+
if (!fs84.realpathSync(file2).startsWith(fs84.realpathSync(folder) + path85.sep)) throw new Error(`${id} is outside the mockup's folder`);
|
|
115424
115529
|
return file2;
|
|
115425
115530
|
}
|
|
115426
115531
|
async function readGraph(entry) {
|
|
115427
|
-
const folder =
|
|
115532
|
+
const folder = path85.dirname(entry);
|
|
115428
115533
|
const graph = { code: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), sheets: [], packages: /* @__PURE__ */ new Map() };
|
|
115429
115534
|
const walk3 = async (file2) => {
|
|
115430
115535
|
if (graph.code.has(file2)) return;
|
|
@@ -115462,13 +115567,13 @@ function run2(script, context, name, deadline, lineOffset = 0) {
|
|
|
115462
115567
|
async function tailwindFor(markup, sheets, folder) {
|
|
115463
115568
|
const source2 = sheets.length ? sheets.map((s) => s.content).join("\n") : '@import "tailwindcss";';
|
|
115464
115569
|
const compiler = await rc(source2, {
|
|
115465
|
-
base: sheets.length ?
|
|
115570
|
+
base: sheets.length ? path85.dirname(sheets[0].path) : "/",
|
|
115466
115571
|
loadStylesheet: async (id, from) => {
|
|
115467
115572
|
if (id === "tailwindcss" || id.startsWith("tailwindcss/")) return { path: "tailwindcss/index.css", base: "/", content: tailwindcss_default };
|
|
115468
115573
|
if (!id.startsWith(".")) throw new Error(`a mockup cannot import ${id}`);
|
|
115469
|
-
const at2 =
|
|
115470
|
-
if (!fs84.realpathSync(at2).startsWith(fs84.realpathSync(folder) +
|
|
115471
|
-
return { path: at2, base:
|
|
115574
|
+
const at2 = path85.resolve(from, id);
|
|
115575
|
+
if (!fs84.realpathSync(at2).startsWith(fs84.realpathSync(folder) + path85.sep)) throw new Error(`${id} is outside the mockup's folder`);
|
|
115576
|
+
return { path: at2, base: path85.dirname(at2), content: fs84.readFileSync(at2, "utf8") };
|
|
115472
115577
|
}
|
|
115473
115578
|
});
|
|
115474
115579
|
const classes = [...markup.matchAll(/class="([^"]*)"/g)].flatMap((m) => m[1].split(/\s+/));
|
|
@@ -115517,7 +115622,7 @@ ${graph.code.get(file2)}
|
|
|
115517
115622
|
if (typeof Component !== "function") throw new Error("the mockup has no default export to draw");
|
|
115518
115623
|
sandbox.__draw = () => (0, import_server.renderToStaticMarkup)(import_react3.default.createElement(Component));
|
|
115519
115624
|
const markup = run2("__draw()", context, entry, deadline);
|
|
115520
|
-
const css = (await tailwindFor(markup, graph.sheets,
|
|
115625
|
+
const css = (await tailwindFor(markup, graph.sheets, path85.dirname(entry))).replace(/<\/style/gi, "<\\/style");
|
|
115521
115626
|
return `<!doctype html><html><head>${head}<style>${css}</style></head><body>${markup}</body></html>`;
|
|
115522
115627
|
}
|
|
115523
115628
|
var import_react3, JSX, import_server, import_sucrase, DRAW_MS, MAX_FILES, CODE_EXTS, REQUIRES, NOTHING, NEXT_LINK, NEXT_IMAGE, NEXT_NAVIGATION, PACKAGES, MOCKUP_IMPORTS;
|
|
@@ -115579,7 +115684,7 @@ var init_draw_mockup = __esm({
|
|
|
115579
115684
|
|
|
115580
115685
|
// src/commands/studio-preview.ts
|
|
115581
115686
|
import fs85 from "node:fs";
|
|
115582
|
-
import
|
|
115687
|
+
import path86 from "node:path";
|
|
115583
115688
|
import { createHash as createHash10, randomUUID as randomUUID9 } from "node:crypto";
|
|
115584
115689
|
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
115585
115690
|
function readFolder2(folder) {
|
|
@@ -115588,7 +115693,7 @@ function readFolder2(folder) {
|
|
|
115588
115693
|
const scan = (dir) => {
|
|
115589
115694
|
for (const e2 of fs85.readdirSync(dir, { withFileTypes: true })) {
|
|
115590
115695
|
if (e2.name.startsWith(".")) continue;
|
|
115591
|
-
const file2 =
|
|
115696
|
+
const file2 = path86.join(dir, e2.name);
|
|
115592
115697
|
if (e2.isSymbolicLink()) throw Error(`${file2}: symbolic links are not allowed`);
|
|
115593
115698
|
if (e2.isDirectory()) scan(file2);
|
|
115594
115699
|
else {
|
|
@@ -115614,7 +115719,7 @@ function agentsOf2(held4) {
|
|
|
115614
115719
|
});
|
|
115615
115720
|
}
|
|
115616
115721
|
function unified(before, after2, file2, folder) {
|
|
115617
|
-
const a2 =
|
|
115722
|
+
const a2 = path86.join(folder, "a"), b2 = path86.join(folder, "b");
|
|
115618
115723
|
fs85.writeFileSync(a2, before ?? "");
|
|
115619
115724
|
fs85.writeFileSync(b2, after2 ?? "");
|
|
115620
115725
|
const result = spawnSync7("git", ["diff", "--no-index", "--text", "--no-ext-diff", "--no-color", "--unified=3", before === null ? "/dev/null" : a2, after2 === null ? "/dev/null" : b2], { encoding: "utf8", maxBuffer: 16 * 1024 * 1024 });
|
|
@@ -115626,10 +115731,10 @@ ${start < 0 ? "" : lines.slice(start + 2).join("\n")}`;
|
|
|
115626
115731
|
}
|
|
115627
115732
|
async function cmdStudioPreview(id, opts) {
|
|
115628
115733
|
if (!locate2(id)) die(`no card ${id}`, "no-such-card");
|
|
115629
|
-
const destination =
|
|
115734
|
+
const destination = path86.join(ASSETS, String(id), "studio-review"), staging = `${destination}.${randomUUID9()}.tmp`, backup = `${destination}.${randomUUID9()}.previous`;
|
|
115630
115735
|
let moved = false;
|
|
115631
115736
|
try {
|
|
115632
|
-
const draft = readFolder2(
|
|
115737
|
+
const draft = readFolder2(path86.resolve(opts.folder)), base = opts.base === "empty" ? null : readFolder2(path86.resolve(opts.base));
|
|
115633
115738
|
const version = readVersion2(draft.files), baseVersion = base && readVersion2(base.files);
|
|
115634
115739
|
if (base ? !version || !baseVersion || JSON.stringify(version) !== JSON.stringify(baseVersion) : version !== null) throw Error("version.json: existing Studios need matching baseline and draft versions; use --base empty only for a new Studio without version.json");
|
|
115635
115740
|
const agents = [...agentsOf2(draft)];
|
|
@@ -115637,8 +115742,8 @@ async function cmdStudioPreview(id, opts) {
|
|
|
115637
115742
|
fs85.mkdirSync(staging, { recursive: true });
|
|
115638
115743
|
const review = { version: 2, base: base && baseVersion ? { ...baseVersion, fingerprint: base.fingerprint } : null, fingerprint: draft.fingerprint, agents, files: [], results: [] };
|
|
115639
115744
|
const save3 = (file2, bytes2) => {
|
|
115640
|
-
const target =
|
|
115641
|
-
fs85.mkdirSync(
|
|
115745
|
+
const target = path86.join(staging, file2);
|
|
115746
|
+
fs85.mkdirSync(path86.dirname(target), { recursive: true });
|
|
115642
115747
|
fs85.writeFileSync(target, bytes2);
|
|
115643
115748
|
return file2;
|
|
115644
115749
|
};
|
|
@@ -115647,9 +115752,9 @@ async function cmdStudioPreview(id, opts) {
|
|
|
115647
115752
|
const before = base?.files[file2] ?? null, after2 = draft.files[file2] ?? null;
|
|
115648
115753
|
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)) } : {} });
|
|
115649
115754
|
}
|
|
115650
|
-
for (const p2 of ["a", "b"]) fs85.rmSync(
|
|
115755
|
+
for (const p2 of ["a", "b"]) fs85.rmSync(path86.join(staging, p2), { force: true });
|
|
115651
115756
|
if (opts.results) {
|
|
115652
|
-
const manifest = fs85.realpathSync(opts.results), root2 =
|
|
115757
|
+
const manifest = fs85.realpathSync(opts.results), root2 = path86.dirname(manifest);
|
|
115653
115758
|
const results = JSON.parse(fs85.readFileSync(manifest, "utf8")), bad = resultProblem(results, new Set(agents.map((a2) => a2.agent)));
|
|
115654
115759
|
if (bad) throw Error(`${opts.results}: invalid ${bad}`);
|
|
115655
115760
|
const rendered = /* @__PURE__ */ new Map();
|
|
@@ -115658,7 +115763,7 @@ async function cmdStudioPreview(id, opts) {
|
|
|
115658
115763
|
if (/\.(html|tsx)$/i.test(file2)) for (const ref of referencesOf(manifestOf("html"), raw, true)) {
|
|
115659
115764
|
if (/^(?:data:|#)/i.test(ref.src)) continue;
|
|
115660
115765
|
if (/^(?:[a-z][\w+.-]*:|\/)/i.test(ref.src)) throw Error(`${file2}: external result dependency ${ref.src}`);
|
|
115661
|
-
const target =
|
|
115766
|
+
const target = path86.resolve(path86.dirname(file2), ref.src.replace(/[?#].*$/, ""));
|
|
115662
115767
|
if (!within(root2, target) || fs85.existsSync(target) && !within(root2, fs85.realpathSync(target))) throw Error(`${file2}: outside result folder: ${ref.src}`);
|
|
115663
115768
|
}
|
|
115664
115769
|
return rendered.get(file2) ?? referenceText(file2);
|
|
@@ -115666,7 +115771,7 @@ async function cmdStudioPreview(id, opts) {
|
|
|
115666
115771
|
const collectResults = () => collectSources(referencesOf(manifestOf("studio"), { results }), manifest, {
|
|
115667
115772
|
resolve: (src, owner) => {
|
|
115668
115773
|
if (/^(?:[a-z][\w+.-]*:|\/|#)/i.test(src)) throw Error(`${src}: only local result files are allowed`);
|
|
115669
|
-
const target =
|
|
115774
|
+
const target = path86.resolve(path86.dirname(owner), src);
|
|
115670
115775
|
if (!within(root2, target)) throw Error(`${src}: outside result folder`);
|
|
115671
115776
|
const real2 = fs85.realpathSync(target);
|
|
115672
115777
|
if (!within(root2, real2) || !fs85.statSync(real2).isFile()) throw Error(`${src}: outside result folder or not a file`);
|
|
@@ -115686,18 +115791,18 @@ async function cmdStudioPreview(id, opts) {
|
|
|
115686
115791
|
}
|
|
115687
115792
|
if (graph.length > 2e3) throw Error(`${opts.results}: too many result dependencies`);
|
|
115688
115793
|
for (const node of graph) if (node.error || node.problems.length) throw Error(`${node.file}: ${node.error ?? node.problems[0].message}`);
|
|
115689
|
-
const names3 = new Map(graph.map((n, i) => [n.key, `results/${i}${rendered.has(n.file) ? ".html" :
|
|
115690
|
-
const resolve2 = (src, owner) => names3.get(fs85.realpathSync(
|
|
115794
|
+
const names3 = new Map(graph.map((n, i) => [n.key, `results/${i}${rendered.has(n.file) ? ".html" : path86.extname(n.file)}`]));
|
|
115795
|
+
const resolve2 = (src, owner) => names3.get(fs85.realpathSync(path86.resolve(path86.dirname(owner), src.replace(/[?#].*$/, ""))));
|
|
115691
115796
|
for (const node of graph) {
|
|
115692
115797
|
const own = names3.get(node.key);
|
|
115693
|
-
const content = node.data === void 0 ? fs85.readFileSync(node.file) : mapReferences(manifestOf(node.kind), node.data, (src) =>
|
|
115798
|
+
const content = node.data === void 0 ? fs85.readFileSync(node.file) : mapReferences(manifestOf(node.kind), node.data, (src) => path86.posix.relative(path86.posix.dirname(own), resolve2(src, node.file)));
|
|
115694
115799
|
save3(own, typeof content === "string" || Buffer.isBuffer(content) ? content : JSON.stringify(content));
|
|
115695
115800
|
}
|
|
115696
115801
|
review.results = mapReferences(manifestOf("studio"), { results }, (src) => resolve2(src, manifest)).results;
|
|
115697
115802
|
}
|
|
115698
115803
|
if (!parseReview(review)) throw Error("generated review is invalid");
|
|
115699
115804
|
save3("review.json", JSON.stringify(review, null, 2) + "\n");
|
|
115700
|
-
fs85.mkdirSync(
|
|
115805
|
+
fs85.mkdirSync(path86.dirname(destination), { recursive: true });
|
|
115701
115806
|
if (fs85.existsSync(destination)) {
|
|
115702
115807
|
fs85.renameSync(destination, backup);
|
|
115703
115808
|
moved = true;
|
|
@@ -115706,7 +115811,7 @@ async function cmdStudioPreview(id, opts) {
|
|
|
115706
115811
|
fs85.rmSync(backup, { recursive: true, force: true });
|
|
115707
115812
|
const tag = `<Studio src=".assets/${id}/studio-review/review.json" />`;
|
|
115708
115813
|
say(tag);
|
|
115709
|
-
return { file:
|
|
115814
|
+
return { file: path86.join(destination, "review.json"), tag };
|
|
115710
115815
|
} catch (error) {
|
|
115711
115816
|
if (moved && !fs85.existsSync(destination)) fs85.renameSync(backup, destination);
|
|
115712
115817
|
if (error && typeof error === "object" && "kind" in error) throw error;
|
|
@@ -115731,7 +115836,7 @@ var init_studio_preview = __esm({
|
|
|
115731
115836
|
init_cards();
|
|
115732
115837
|
init_paths();
|
|
115733
115838
|
init_io();
|
|
115734
|
-
within = (root2, file2) => file2.startsWith(root2 +
|
|
115839
|
+
within = (root2, file2) => file2.startsWith(root2 + path86.sep);
|
|
115735
115840
|
readVersion2 = (files) => {
|
|
115736
115841
|
if (files[VERSION_FILE] === void 0) return null;
|
|
115737
115842
|
try {
|
|
@@ -116291,7 +116396,7 @@ init_agent2();
|
|
|
116291
116396
|
|
|
116292
116397
|
// src/lib/cli/setup.ts
|
|
116293
116398
|
import fs87 from "node:fs";
|
|
116294
|
-
import
|
|
116399
|
+
import path88 from "node:path";
|
|
116295
116400
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
116296
116401
|
|
|
116297
116402
|
// src/commands/update.ts
|
|
@@ -116300,7 +116405,7 @@ init_config_template();
|
|
|
116300
116405
|
init_io();
|
|
116301
116406
|
init_version();
|
|
116302
116407
|
import fs86 from "node:fs";
|
|
116303
|
-
import
|
|
116408
|
+
import path87 from "node:path";
|
|
116304
116409
|
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
116305
116410
|
var NAME = "wildcrane";
|
|
116306
116411
|
var REPO = "https://github.com/wildcrane-ai/wildcrane";
|
|
@@ -116342,8 +116447,8 @@ async function cmdUpdate2(ctx) {
|
|
|
116342
116447
|
return { updated: ctx.dir, from, to: SKILL_VERSION };
|
|
116343
116448
|
}
|
|
116344
116449
|
async function repairBoard(root2, report3, named2) {
|
|
116345
|
-
const legacy =
|
|
116346
|
-
const kept2 =
|
|
116450
|
+
const legacy = path87.join(root2, "docs", "kanban");
|
|
116451
|
+
const kept2 = path87.join(root2, ".akb", "kanban");
|
|
116347
116452
|
const board2 = named2 ?? (fs86.existsSync(legacy) ? legacy : kept2);
|
|
116348
116453
|
if (!fs86.existsSync(board2)) {
|
|
116349
116454
|
report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
|
|
@@ -116356,7 +116461,7 @@ async function repairBoard(root2, report3, named2) {
|
|
|
116356
116461
|
return true;
|
|
116357
116462
|
}
|
|
116358
116463
|
function checkConfig(board2, report3) {
|
|
116359
|
-
const current = read3(
|
|
116464
|
+
const current = read3(path87.join(board2, "config.md"));
|
|
116360
116465
|
if (!current) return;
|
|
116361
116466
|
const added = missingConfigKeys(current);
|
|
116362
116467
|
if (added.length) {
|
|
@@ -116366,7 +116471,7 @@ function checkConfig(board2, report3) {
|
|
|
116366
116471
|
}
|
|
116367
116472
|
}
|
|
116368
116473
|
function checkModules(board2, report3) {
|
|
116369
|
-
const map2 = read3(
|
|
116474
|
+
const map2 = read3(path87.join(board2, "modules.md"));
|
|
116370
116475
|
if (map2 && map2.includes(UNFILLED)) {
|
|
116371
116476
|
report3.notes.push(
|
|
116372
116477
|
"docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
|
|
@@ -116420,14 +116525,14 @@ function declareSetup(program2, cli) {
|
|
|
116420
116525
|
program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
|
|
116421
116526
|
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");
|
|
116422
116527
|
const where = (cmd) => {
|
|
116423
|
-
const dir =
|
|
116528
|
+
const dir = path88.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
|
|
116424
116529
|
if (!fs87.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
|
|
116425
116530
|
return dir;
|
|
116426
116531
|
};
|
|
116427
116532
|
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() {
|
|
116428
116533
|
const dir = where(this);
|
|
116429
116534
|
const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
|
|
116430
|
-
const board2 = named2 ?
|
|
116535
|
+
const board2 = named2 ? path88.resolve(cli.cwd, named2) : null;
|
|
116431
116536
|
await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
|
|
116432
116537
|
});
|
|
116433
116538
|
program2.command("__rules", { hidden: true }).action(function() {
|