wildcrane-runner 0.6.86 → 0.6.88
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/README.md +3 -0
- package/dist/akb/dist/kanban.mjs +796 -687
- package/dist/akb/package.json +1 -1
- package/dist/akb-proxy.mjs +1 -1
- package/dist/codex-proxy.mjs +1 -1
- package/dist/codex-retained.mjs +1 -1
- package/dist/flow-worker-main.mjs +678 -480
- package/dist/launcher.mjs +473 -305
- package/dist/plugin.mjs +535 -367
- package/dist/runner.mjs +1054 -823
- package/dist/settings.mjs +484 -316
- package/package.json +1 -1
package/dist/akb/dist/kanban.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// ai4kanban 0.11.
|
|
2
|
+
// ai4kanban 0.11.71 — built by runner/scripts/build.mjs. Do not edit.
|
|
3
3
|
import { createRequire as __ai4kanbanRequire } from 'node:module'
|
|
4
4
|
const require = __ai4kanbanRequire(import.meta.url)
|
|
5
5
|
var __create = Object.create;
|
|
@@ -2054,8 +2054,7 @@ function modelsIn(file2, pick2, salt = "") {
|
|
|
2054
2054
|
const stat = statSync(file2);
|
|
2055
2055
|
stamp4 = `${stat.mtimeMs}:${stat.size}:${salt}`;
|
|
2056
2056
|
} catch {
|
|
2057
|
-
cached.
|
|
2058
|
-
return [];
|
|
2057
|
+
return cached.get(file2)?.found ?? [];
|
|
2059
2058
|
}
|
|
2060
2059
|
const hit = cached.get(file2);
|
|
2061
2060
|
if (hit?.stamp === stamp4) return hit.found;
|
|
@@ -2065,8 +2064,8 @@ function modelsIn(file2, pick2, salt = "") {
|
|
|
2065
2064
|
} catch {
|
|
2066
2065
|
found2 = [];
|
|
2067
2066
|
}
|
|
2068
|
-
cached.set(file2, { stamp: stamp4, found: found2 });
|
|
2069
|
-
return found2;
|
|
2067
|
+
if (found2.length) cached.set(file2, { stamp: stamp4, found: found2 });
|
|
2068
|
+
return found2.length ? found2 : hit?.found ?? [];
|
|
2070
2069
|
}
|
|
2071
2070
|
var cached;
|
|
2072
2071
|
var init_models = __esm({
|
|
@@ -2118,6 +2117,61 @@ var init_types = __esm({
|
|
|
2118
2117
|
}
|
|
2119
2118
|
});
|
|
2120
2119
|
|
|
2120
|
+
// ../cli/src/lib/agent/harnesses/transient.ts
|
|
2121
|
+
function reasonLine(text6, rule) {
|
|
2122
|
+
const line = text6.split("\n").find((l2) => rule.test(l2.toLowerCase())) ?? text6;
|
|
2123
|
+
const said2 = line.trim().replace(/\s+/g, " ");
|
|
2124
|
+
return said2.length > REASON_MAX ? `${said2.slice(0, REASON_MAX - 1)}\u2026` : said2;
|
|
2125
|
+
}
|
|
2126
|
+
function manualFailure(text6) {
|
|
2127
|
+
return MANUAL.some((rule) => rule.test(text6.toLowerCase()));
|
|
2128
|
+
}
|
|
2129
|
+
function providerBlip(...said2) {
|
|
2130
|
+
for (const text6 of said2) {
|
|
2131
|
+
if (!text6?.trim()) continue;
|
|
2132
|
+
const lower = text6.toLowerCase();
|
|
2133
|
+
if (manualFailure(text6)) return void 0;
|
|
2134
|
+
const hit = PASSING.find((rule) => rule.test(lower));
|
|
2135
|
+
if (!hit) continue;
|
|
2136
|
+
const asked = RETRY_AFTER.exec(text6);
|
|
2137
|
+
const seconds = asked ? Number(asked[1]) : NaN;
|
|
2138
|
+
return {
|
|
2139
|
+
reason: reasonLine(text6, hit),
|
|
2140
|
+
...Number.isFinite(seconds) && seconds > 0 ? { retryAfterMs: seconds * 1e3 } : {}
|
|
2141
|
+
};
|
|
2142
|
+
}
|
|
2143
|
+
return void 0;
|
|
2144
|
+
}
|
|
2145
|
+
var MANUAL, PASSING, RETRY_AFTER, REASON_MAX;
|
|
2146
|
+
var init_transient = __esm({
|
|
2147
|
+
"../cli/src/lib/agent/harnesses/transient.ts"() {
|
|
2148
|
+
"use strict";
|
|
2149
|
+
MANUAL = [
|
|
2150
|
+
/\b(401|403)\b/,
|
|
2151
|
+
/unauthorized|forbidden|permission (?:denied|required|check failed)|permission_denied|soft.denied|auto-denied|权限拒绝/,
|
|
2152
|
+
/authenticat|invalid api key|api[_ ]key|not (?:logged|signed) in|please (?:log|sign) in|\/login|oauth/,
|
|
2153
|
+
/\b429\b/,
|
|
2154
|
+
/rate[ _-]?limit|usage limit|quota|credits?|insufficient|out of tokens|resource[ _-]?exhausted/,
|
|
2155
|
+
/cancell?ed|aborted by|interrupted by the user/,
|
|
2156
|
+
/maximum budget|max(imum)? turns|exceeded the budget/,
|
|
2157
|
+
/model not found|unknown model|invalid model|model (?:is )?unavailable|model[^\n]+ is (?:unavailable|not recognized)|unsupported|invalid[_ ]request/
|
|
2158
|
+
];
|
|
2159
|
+
PASSING = [
|
|
2160
|
+
// 502/503/529 are distinctive enough to read as a status wherever they appear. A bare
|
|
2161
|
+
// 500 is not — a failure line counting something would match it — so it is left to the
|
|
2162
|
+
// words below, which is how that status is actually written out.
|
|
2163
|
+
/\b(502|503|529)\b/,
|
|
2164
|
+
/overloaded|service unavailable|bad gateway|internal server error|server_error/,
|
|
2165
|
+
/connection (lost|dropped|reset|error|closed)|socket hang up|stream (error|disconnected)/,
|
|
2166
|
+
/econnreset|econnrefused|etimedout|enetunreach|enotfound|eai_again/,
|
|
2167
|
+
/fetch failed|request timed out|network error/,
|
|
2168
|
+
/rpc error: code = (?:unavailable|deadlineexceeded)\b|deadline_exceeded|dial tcp[^\n]*(?:timeout|refused|no such host)/
|
|
2169
|
+
];
|
|
2170
|
+
RETRY_AFTER = /retry[-_\s]?after["':=\s]+(\d+)/i;
|
|
2171
|
+
REASON_MAX = 140;
|
|
2172
|
+
}
|
|
2173
|
+
});
|
|
2174
|
+
|
|
2121
2175
|
// ../cli/src/lib/machine/types.ts
|
|
2122
2176
|
function isLanguage(value) {
|
|
2123
2177
|
return typeof value === "string" && LANGUAGES.includes(value);
|
|
@@ -2202,6 +2256,61 @@ var init_language = __esm({
|
|
|
2202
2256
|
}
|
|
2203
2257
|
});
|
|
2204
2258
|
|
|
2259
|
+
// ../cli/src/lib/agent/prices.ts
|
|
2260
|
+
function antigravityPrices(at2) {
|
|
2261
|
+
const pro = at2 < Date.parse("2026-12-01T00:00:00Z") ? 2 : 4;
|
|
2262
|
+
const flash = at2 < Date.parse("2027-01-01T00:00:00Z") ? 0.75 : 1.5;
|
|
2263
|
+
return {
|
|
2264
|
+
"gemini-4-carbon": { input: pro, cachedInput: pro / 20, output: pro * 5 },
|
|
2265
|
+
"gemini-4-argon": { input: pro, cachedInput: pro / 20, output: pro * 5 },
|
|
2266
|
+
"gemini-4-hydrogen": { input: 1.5, cachedInput: 0.075, output: 7.5 },
|
|
2267
|
+
"gemini-3.8-flash": { input: flash, cachedInput: flash / 10, output: flash * 5 }
|
|
2268
|
+
};
|
|
2269
|
+
}
|
|
2270
|
+
function lookUp(table, model) {
|
|
2271
|
+
const id = model.trim().toLowerCase().replace(/^[^/]+\//, "");
|
|
2272
|
+
return table[id] ?? table[id.replace(/-\d{4}-\d{2}-\d{2}$/, "")];
|
|
2273
|
+
}
|
|
2274
|
+
function priceUsd(provider, model, usage3, at2 = Date.now()) {
|
|
2275
|
+
if (!provider || !model || !usage3) return void 0;
|
|
2276
|
+
const agy = provider.trim().toLowerCase() === "antigravity";
|
|
2277
|
+
const table = agy ? antigravityPrices(at2) : PRICES[provider.trim().toLowerCase()];
|
|
2278
|
+
const price = table && (agy ? table[model.trim().toLowerCase().replace(/-(?:low|medium|high|xhigh|max)$/, "")] : lookUp(table, model));
|
|
2279
|
+
if (!price) return void 0;
|
|
2280
|
+
const usd = ((usage3.input + usage3.cacheCreation) * price.input + usage3.cacheRead * price.cachedInput + usage3.output * price.output) / 1e6;
|
|
2281
|
+
return Number.isFinite(usd) && usd >= 0 ? usd : void 0;
|
|
2282
|
+
}
|
|
2283
|
+
var OPENAI, PRICES;
|
|
2284
|
+
var init_prices = __esm({
|
|
2285
|
+
"../cli/src/lib/agent/prices.ts"() {
|
|
2286
|
+
"use strict";
|
|
2287
|
+
OPENAI = {
|
|
2288
|
+
"gpt-6.1-sol": { input: 2, cachedInput: 0.1, output: 10 },
|
|
2289
|
+
"gpt-6-astra": { input: 10, cachedInput: 1, output: 50 },
|
|
2290
|
+
"gpt-6-sol": { input: 2, cachedInput: 0.2, output: 10 },
|
|
2291
|
+
"gpt-6-luna": { input: 0.1, cachedInput: 0.01, output: 0.5 },
|
|
2292
|
+
"gpt-5.6-sol": { input: 4, cachedInput: 0.4, output: 20 },
|
|
2293
|
+
"gpt-5.6-terra": { input: 2, cachedInput: 0.2, output: 12 },
|
|
2294
|
+
"gpt-5.6-luna": { input: 0.2, cachedInput: 0.02, output: 1.2 },
|
|
2295
|
+
"gpt-5.5": { input: 5, cachedInput: 0.5, output: 30 },
|
|
2296
|
+
"gpt-5.5-pro": { input: 30, cachedInput: 30, output: 180 },
|
|
2297
|
+
"gpt-5.4": { input: 2.5, cachedInput: 0.25, output: 15 },
|
|
2298
|
+
"gpt-5.4-mini": { input: 0.75, cachedInput: 0.075, output: 4.5 },
|
|
2299
|
+
"gpt-5.4-nano": { input: 0.2, cachedInput: 0.02, output: 1.25 },
|
|
2300
|
+
"gpt-5.4-pro": { input: 30, cachedInput: 30, output: 180 },
|
|
2301
|
+
"gpt-5.3-codex": { input: 1.75, cachedInput: 0.175, output: 14 },
|
|
2302
|
+
"gpt-5.2": { input: 1.75, cachedInput: 0.175, output: 14 },
|
|
2303
|
+
"gpt-5.2-pro": { input: 21, cachedInput: 21, output: 168 },
|
|
2304
|
+
"gpt-5.1": { input: 1.25, cachedInput: 0.125, output: 10 },
|
|
2305
|
+
"gpt-5": { input: 1.25, cachedInput: 0.125, output: 10 },
|
|
2306
|
+
"gpt-5-mini": { input: 0.25, cachedInput: 0.025, output: 2 },
|
|
2307
|
+
"gpt-5-nano": { input: 0.05, cachedInput: 5e-3, output: 0.4 },
|
|
2308
|
+
"gpt-5-pro": { input: 15, cachedInput: 15, output: 120 }
|
|
2309
|
+
};
|
|
2310
|
+
PRICES = { openai: OPENAI, "openai-api": OPENAI };
|
|
2311
|
+
}
|
|
2312
|
+
});
|
|
2313
|
+
|
|
2205
2314
|
// ../cli/src/lib/agent/wire/json.ts
|
|
2206
2315
|
function obj2(value) {
|
|
2207
2316
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
@@ -2448,20 +2557,44 @@ var init_stream = __esm({
|
|
|
2448
2557
|
});
|
|
2449
2558
|
|
|
2450
2559
|
// ../cli/src/lib/agent/wire/antigravity.ts
|
|
2560
|
+
import path14 from "node:path";
|
|
2451
2561
|
function failureHint(reason) {
|
|
2452
2562
|
const zh = translating();
|
|
2453
2563
|
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
2564
|
return hint2 ? `${reason}
|
|
2455
2565
|
${hint2}` : reason;
|
|
2456
2566
|
}
|
|
2457
|
-
function createAntigravityRenderer(expectedSession) {
|
|
2567
|
+
function createAntigravityRenderer(expectedSession, cwd = process.cwd()) {
|
|
2458
2568
|
let session = expectedSession;
|
|
2459
2569
|
let model;
|
|
2570
|
+
let partial = "";
|
|
2460
2571
|
let final;
|
|
2461
2572
|
let failure;
|
|
2573
|
+
let rateLimit;
|
|
2574
|
+
let imageFailure;
|
|
2575
|
+
let requiredImages = [];
|
|
2576
|
+
const readImages = /* @__PURE__ */ new Set();
|
|
2577
|
+
const imageErrors = /* @__PURE__ */ new Map();
|
|
2578
|
+
const imageError = (target, reason) => translating() ? `Antigravity \u65E0\u6CD5\u8BFB\u53D6\u56FE\u7247 ${target}\uFF1A${reason}` : `Antigravity could not read image ${target}: ${reason}`;
|
|
2462
2579
|
let terminal = false;
|
|
2463
2580
|
let offStream;
|
|
2464
2581
|
let stderr = "";
|
|
2582
|
+
let context;
|
|
2583
|
+
let contextStep = -1;
|
|
2584
|
+
const started = Date.now();
|
|
2585
|
+
let cost;
|
|
2586
|
+
let incomplete = false;
|
|
2587
|
+
const priced = /* @__PURE__ */ new Set();
|
|
2588
|
+
const countCost = (step) => {
|
|
2589
|
+
const index = step.step_index;
|
|
2590
|
+
if (typeof index !== "number" || !Number.isSafeInteger(index) || index < 0 || priced.has(index)) return;
|
|
2591
|
+
priced.add(index);
|
|
2592
|
+
const u2 = obj2(step.usage);
|
|
2593
|
+
const valid = [u2.input_tokens, u2.output_tokens, u2.cache_read_tokens].every((n) => typeof n === "number" && Number.isFinite(n) && n >= 0);
|
|
2594
|
+
const usd = valid ? priceUsd("antigravity", model, usageOf(u2), started) : void 0;
|
|
2595
|
+
if (usd === void 0) incomplete = true;
|
|
2596
|
+
else cost = (cost ?? 0) + usd;
|
|
2597
|
+
};
|
|
2465
2598
|
let used;
|
|
2466
2599
|
let turnUsage = zero();
|
|
2467
2600
|
let previous;
|
|
@@ -2470,6 +2603,8 @@ function createAntigravityRenderer(expectedSession) {
|
|
|
2470
2603
|
const closed2 = /* @__PURE__ */ new Set();
|
|
2471
2604
|
const events = createEventCollector();
|
|
2472
2605
|
const fail = (reason) => {
|
|
2606
|
+
if (limited(reason)) rateLimit = failureHint(reason);
|
|
2607
|
+
if (failure && manualFailure(failure) && !(limited(failure) && limited(reason))) return;
|
|
2473
2608
|
failure = failureHint(reason);
|
|
2474
2609
|
events.error(failure);
|
|
2475
2610
|
};
|
|
@@ -2477,6 +2612,7 @@ function createAntigravityRenderer(expectedSession) {
|
|
|
2477
2612
|
const e2 = frame(line);
|
|
2478
2613
|
if (!e2) {
|
|
2479
2614
|
offStream = line.trim() || offStream;
|
|
2615
|
+
if (/^(?:error:|rpc error:)/i.test(line.trim()) && limited(line)) fail(line.trim());
|
|
2480
2616
|
return `${line}
|
|
2481
2617
|
`;
|
|
2482
2618
|
}
|
|
@@ -2495,10 +2631,19 @@ function createAntigravityRenderer(expectedSession) {
|
|
|
2495
2631
|
if (expectedSession && str2(step.conversation_id) !== expectedSession) return "";
|
|
2496
2632
|
session = str2(step.conversation_id) || session;
|
|
2497
2633
|
const id = String(step.step_index ?? "");
|
|
2634
|
+
if (step.state === "DONE" && ["agent_response", "checkpoint"].includes(str2(step.step_type))) countCost(step);
|
|
2498
2635
|
if (step.step_type === "agent_response") {
|
|
2499
2636
|
const text6 = str2(step.text_delta);
|
|
2637
|
+
partial += text6;
|
|
2500
2638
|
if (text6) events.update({ sessionUpdate: "agent_message_chunk", content: { text: text6 } });
|
|
2501
2639
|
const index = num2(step.step_index);
|
|
2640
|
+
if (step.state === "DONE" && Number.isSafeInteger(index) && step.step_index === index && index > contextStep) {
|
|
2641
|
+
contextStep = index;
|
|
2642
|
+
const u2 = obj2(step.usage);
|
|
2643
|
+
const counts = [u2.input_tokens, u2.cache_read_tokens];
|
|
2644
|
+
const prompt = counts.every((n) => typeof n === "number" && Number.isFinite(n) && n >= 0) ? num2(u2.input_tokens) + num2(u2.cache_read_tokens) : 0;
|
|
2645
|
+
context = prompt > 0 && Number.isFinite(prompt) ? { used: prompt } : void 0;
|
|
2646
|
+
}
|
|
2502
2647
|
if (step.state === "DONE" && step.usage && !counted.has(index)) {
|
|
2503
2648
|
counted.add(index);
|
|
2504
2649
|
turnUsage = add(turnUsage, usageOf(step.usage));
|
|
@@ -2524,7 +2669,20 @@ function createAntigravityRenderer(expectedSession) {
|
|
|
2524
2669
|
if (reason && /permission|denied|soft.den/i.test(reason)) fail(reason);
|
|
2525
2670
|
if (["DONE", "ERROR", "CANCELED", "INTERRUPTED"].includes(str2(step.state)) && !closed2.has(id)) {
|
|
2526
2671
|
closed2.add(id);
|
|
2527
|
-
|
|
2672
|
+
const failed2 = !!reason || step.state !== "DONE";
|
|
2673
|
+
if (["read_file", "view_file"].includes(name) && imagePath(target)) {
|
|
2674
|
+
const file2 = path14.resolve(cwd, target);
|
|
2675
|
+
if (failed2) {
|
|
2676
|
+
imageErrors.set(file2, reason || str2(step.state));
|
|
2677
|
+
out += `
|
|
2678
|
+
${imageError(target, reason || str2(step.state))}
|
|
2679
|
+
`;
|
|
2680
|
+
} else {
|
|
2681
|
+
readImages.add(file2);
|
|
2682
|
+
imageErrors.delete(file2);
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
events.toolResult(id, failed2 ? "failed" : "completed", str2(tool.output) || reason);
|
|
2528
2686
|
}
|
|
2529
2687
|
return out;
|
|
2530
2688
|
}
|
|
@@ -2544,44 +2702,65 @@ function createAntigravityRenderer(expectedSession) {
|
|
|
2544
2702
|
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
2703
|
previous = total;
|
|
2546
2704
|
if (!Object.values(used).some((n) => n > 0)) used = void 0;
|
|
2705
|
+
const missing = requiredImages.length ? requiredImages.filter((file2) => !readImages.has(file2)) : [...imageErrors.keys()];
|
|
2706
|
+
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;
|
|
2707
|
+
if (imageFailure) events.error(imageFailure);
|
|
2708
|
+
readImages.clear();
|
|
2709
|
+
imageErrors.clear();
|
|
2547
2710
|
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
2711
|
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"}`);
|
|
2712
|
+
fail(result.status === "CANCELED" ? `Antigravity: CANCELED${result.error ? `: ${str2(result.error)}` : ""}` : str2(result.error) || `Antigravity: ${str2(result.status) || "missing status"}`);
|
|
2550
2713
|
}
|
|
2551
2714
|
events.end();
|
|
2552
2715
|
turnUsage = zero();
|
|
2553
2716
|
counted.clear();
|
|
2554
|
-
return failure ? `
|
|
2555
|
-
[error] ${failure}
|
|
2717
|
+
return failure || imageFailure ? `
|
|
2718
|
+
[error] ${failure || imageFailure}
|
|
2556
2719
|
` : "";
|
|
2557
2720
|
}
|
|
2558
2721
|
return "";
|
|
2559
2722
|
});
|
|
2560
2723
|
return {
|
|
2561
2724
|
push: reader.push,
|
|
2725
|
+
setRequiredImages(files) {
|
|
2726
|
+
requiredImages = files.filter(imagePath).map((file2) => path14.resolve(cwd, file2));
|
|
2727
|
+
},
|
|
2562
2728
|
flush() {
|
|
2563
2729
|
const text6 = reader.flush();
|
|
2564
|
-
if (!terminal)
|
|
2730
|
+
if (!terminal) {
|
|
2731
|
+
incomplete = true;
|
|
2732
|
+
const diagnostics = [stderr.trim(), offStream?.match(/^(?:error:|rpc error:)/i) ? offStream : void 0];
|
|
2733
|
+
const diagnostic = diagnostics.find((text7) => text7 && manualFailure(text7)) ?? diagnostics.find((text7) => text7 && providerBlip(text7));
|
|
2734
|
+
if (diagnostic) fail(diagnostic);
|
|
2735
|
+
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.");
|
|
2736
|
+
}
|
|
2565
2737
|
events.end();
|
|
2566
2738
|
return text6;
|
|
2567
2739
|
},
|
|
2568
2740
|
stderr(chunk) {
|
|
2569
2741
|
stderr = (stderr + chunk).slice(-16e3);
|
|
2742
|
+
if (limited(stderr)) fail(stderr.trim());
|
|
2570
2743
|
if (/soft.denied|auto-denied|permission (?:denied|required)|denied by.*(?:policy|rule)|requires? (?:user )?(?:approval|permission)/i.test(stderr)) fail(stderr.trim());
|
|
2571
2744
|
},
|
|
2572
|
-
result: () => final,
|
|
2745
|
+
result: () => final || (failure ? partial || void 0 : final),
|
|
2573
2746
|
resumeId: () => session,
|
|
2574
2747
|
model: () => model,
|
|
2575
2748
|
usage: () => used,
|
|
2576
|
-
|
|
2749
|
+
costUsd: () => cost,
|
|
2750
|
+
costIncomplete: () => incomplete || void 0,
|
|
2751
|
+
context: () => context,
|
|
2752
|
+
failure: () => failure || imageFailure,
|
|
2753
|
+
rateLimit: () => rateLimit,
|
|
2577
2754
|
offStream: () => offStream,
|
|
2578
2755
|
events: events.events
|
|
2579
2756
|
};
|
|
2580
2757
|
}
|
|
2581
|
-
var KINDS, zero, usageOf, add;
|
|
2758
|
+
var KINDS, zero, usageOf, add, limited, imagePath;
|
|
2582
2759
|
var init_antigravity = __esm({
|
|
2583
2760
|
"../cli/src/lib/agent/wire/antigravity.ts"() {
|
|
2584
2761
|
"use strict";
|
|
2762
|
+
init_transient();
|
|
2763
|
+
init_prices();
|
|
2585
2764
|
init_language();
|
|
2586
2765
|
init_events();
|
|
2587
2766
|
init_json();
|
|
@@ -2590,6 +2769,7 @@ var init_antigravity = __esm({
|
|
|
2590
2769
|
run_command: "execute",
|
|
2591
2770
|
command_status: "execute",
|
|
2592
2771
|
send_command_input: "execute",
|
|
2772
|
+
read_file: "read",
|
|
2593
2773
|
view_file: "read",
|
|
2594
2774
|
list_dir: "read",
|
|
2595
2775
|
grep_search: "search",
|
|
@@ -2607,19 +2787,29 @@ var init_antigravity = __esm({
|
|
|
2607
2787
|
return { input: num2(u2.input_tokens), output: num2(u2.output_tokens), cacheRead: num2(u2.cache_read_tokens), cacheCreation: 0 };
|
|
2608
2788
|
};
|
|
2609
2789
|
add = (a2, b2) => ({ input: a2.input + b2.input, output: a2.output + b2.output, cacheRead: a2.cacheRead + b2.cacheRead, cacheCreation: 0 });
|
|
2790
|
+
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);
|
|
2791
|
+
imagePath = (target) => /\.(?:png|jpe?g|gif|webp|bmp|tiff?|svg)$/i.test(target);
|
|
2610
2792
|
}
|
|
2611
2793
|
});
|
|
2612
2794
|
|
|
2613
2795
|
// ../cli/src/lib/agent/harnesses/antigravity.ts
|
|
2614
2796
|
import fs13 from "node:fs";
|
|
2615
|
-
import
|
|
2797
|
+
import path15 from "node:path";
|
|
2616
2798
|
import { createHash as createHash3 } from "node:crypto";
|
|
2617
2799
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
2618
2800
|
function antigravityModels(output) {
|
|
2619
|
-
|
|
2801
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2802
|
+
const models = [];
|
|
2803
|
+
for (const line of output.split("\n")) {
|
|
2620
2804
|
const match = /^([^\s]+)\t(.+)$/.exec(line.trim());
|
|
2621
|
-
|
|
2622
|
-
|
|
2805
|
+
if (!match) continue;
|
|
2806
|
+
const id = match[1].replace(EFFORT_ID, "");
|
|
2807
|
+
const name = match[2].replace(EFFORT_NAME, "").trim();
|
|
2808
|
+
if (seen.has(id)) continue;
|
|
2809
|
+
seen.add(id);
|
|
2810
|
+
models.push({ id, name });
|
|
2811
|
+
}
|
|
2812
|
+
return models;
|
|
2623
2813
|
}
|
|
2624
2814
|
function args(argv, resume) {
|
|
2625
2815
|
if (namesFlag(argv, ["--continue", "-c", "--conversation", "--remote-agent"])) throw new Error(translating() ? "\u8BF7\u901A\u8FC7 WildCrane \u9009\u62E9 Antigravity \u4F1A\u8BDD\uFF0C\u4E0D\u8981\u5728\u989D\u5916\u53C2\u6570\u4E2D\u6307\u5B9A\u4F1A\u8BDD\u6216\u8FDC\u7A0B\u6267\u884C\u3002" : "Antigravity: select a session through WildCrane, not extra arguments.");
|
|
@@ -2630,7 +2820,7 @@ function args(argv, resume) {
|
|
|
2630
2820
|
if (!namesFlag(argv, ["--print", "-p", "--prompt"])) extra.push("--print");
|
|
2631
2821
|
return extra;
|
|
2632
2822
|
}
|
|
2633
|
-
var ANTIGRAVITY;
|
|
2823
|
+
var EFFORT_ID, EFFORT_NAME, ANTIGRAVITY;
|
|
2634
2824
|
var init_antigravity2 = __esm({
|
|
2635
2825
|
"../cli/src/lib/agent/harnesses/antigravity.ts"() {
|
|
2636
2826
|
"use strict";
|
|
@@ -2639,8 +2829,11 @@ var init_antigravity2 = __esm({
|
|
|
2639
2829
|
init_spawnable();
|
|
2640
2830
|
init_models();
|
|
2641
2831
|
init_types();
|
|
2832
|
+
init_transient();
|
|
2642
2833
|
init_language();
|
|
2643
2834
|
init_antigravity();
|
|
2835
|
+
EFFORT_ID = /-(?:low|medium|high|xhigh|max)$/i;
|
|
2836
|
+
EFFORT_NAME = /\s*\((?:low|medium|high|xhigh|max)\)$/i;
|
|
2644
2837
|
ANTIGRAVITY = {
|
|
2645
2838
|
name: "antigravity",
|
|
2646
2839
|
label: "Antigravity CLI",
|
|
@@ -2657,6 +2850,22 @@ var init_antigravity2 = __esm({
|
|
|
2657
2850
|
flags: ["--model"],
|
|
2658
2851
|
placeholder: "model-id",
|
|
2659
2852
|
help: "A model from agy models. Empty uses the CLI default; an invalid model fails the run."
|
|
2853
|
+
}, {
|
|
2854
|
+
key: "reasoning",
|
|
2855
|
+
agentOwned: true,
|
|
2856
|
+
label: "Reasoning effort",
|
|
2857
|
+
kind: "select",
|
|
2858
|
+
choices: [
|
|
2859
|
+
{ value: "", label: "Agent's default" },
|
|
2860
|
+
{ value: "low", label: "Low" },
|
|
2861
|
+
{ value: "medium", label: "Medium" },
|
|
2862
|
+
{ value: "high", label: "High" },
|
|
2863
|
+
{ value: "xhigh", label: "Extra high (xhigh)" },
|
|
2864
|
+
{ value: "max", label: "Max" }
|
|
2865
|
+
],
|
|
2866
|
+
flags: ["--effort"],
|
|
2867
|
+
help: "Lower is quicker and cheaper, higher is slower and more careful.",
|
|
2868
|
+
overriddenHelp: `Not in effect: this agent's "command" in your ui.config.json already names an effort level, and that wins.`
|
|
2660
2869
|
}],
|
|
2661
2870
|
models() {
|
|
2662
2871
|
const copy2 = locate(ANTIGRAVITY);
|
|
@@ -2666,18 +2875,19 @@ var init_antigravity2 = __esm({
|
|
|
2666
2875
|
return result.status === 0 ? antigravityModels(result.stdout ?? "").map((m) => m.id) : [];
|
|
2667
2876
|
},
|
|
2668
2877
|
env: () => ({ ...process.env }),
|
|
2669
|
-
|
|
2878
|
+
images: { as: "message" },
|
|
2879
|
+
renderer: (cwd, _binary, argv = []) => {
|
|
2670
2880
|
const at2 = argv.indexOf("--conversation");
|
|
2671
|
-
return createAntigravityRenderer(at2 >= 0 ? argv[at2 + 1] : argv.find((a2) => a2.startsWith("--conversation="))?.slice(15));
|
|
2881
|
+
return createAntigravityRenderer(at2 >= 0 ? argv[at2 + 1] : argv.find((a2) => a2.startsWith("--conversation="))?.slice(15), cwd);
|
|
2672
2882
|
},
|
|
2673
2883
|
systemPrompt(text6, _argv, env2) {
|
|
2674
2884
|
const rule = `${text6}
|
|
2675
2885
|
|
|
2676
2886
|
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.`;
|
|
2677
2887
|
const hash2 = createHash3("sha256").update(rule).digest("hex").slice(0, 16);
|
|
2678
|
-
const root2 =
|
|
2679
|
-
const file2 =
|
|
2680
|
-
fs13.mkdirSync(
|
|
2888
|
+
const root2 = path15.join(machineHome(), "prompts", `antigravity-${hash2}`);
|
|
2889
|
+
const file2 = path15.join(root2, ".agents", "rules", "language.md");
|
|
2890
|
+
fs13.mkdirSync(path15.dirname(file2), { recursive: true });
|
|
2681
2891
|
fs13.writeFileSync(file2, `---
|
|
2682
2892
|
trigger: always_on
|
|
2683
2893
|
---
|
|
@@ -2686,10 +2896,11 @@ ${rule}
|
|
|
2686
2896
|
`);
|
|
2687
2897
|
return { args: ["--add-dir", root2] };
|
|
2688
2898
|
},
|
|
2689
|
-
|
|
2899
|
+
transient: ({ failure }) => providerBlip(failure),
|
|
2900
|
+
reports: ["cost", "tokens", "model", "context"],
|
|
2690
2901
|
adoptsSessionId: false,
|
|
2691
|
-
savesSessionAtOpen:
|
|
2692
|
-
stopsOnRateLimit:
|
|
2902
|
+
savesSessionAtOpen: true,
|
|
2903
|
+
stopsOnRateLimit: true,
|
|
2693
2904
|
// `models` is read-only. Only explicit authentication errors mean signed out.
|
|
2694
2905
|
login: {
|
|
2695
2906
|
args: ["models"],
|
|
@@ -3051,50 +3262,6 @@ var init_background = __esm({
|
|
|
3051
3262
|
}
|
|
3052
3263
|
});
|
|
3053
3264
|
|
|
3054
|
-
// ../cli/src/lib/agent/prices.ts
|
|
3055
|
-
function lookUp(table, model) {
|
|
3056
|
-
const id = model.trim().toLowerCase().replace(/^[^/]+\//, "");
|
|
3057
|
-
return table[id] ?? table[id.replace(/-\d{4}-\d{2}-\d{2}$/, "")];
|
|
3058
|
-
}
|
|
3059
|
-
function priceUsd(provider, model, usage3) {
|
|
3060
|
-
if (!provider || !model || !usage3) return void 0;
|
|
3061
|
-
const table = PRICES[provider.trim().toLowerCase()];
|
|
3062
|
-
const price = table && lookUp(table, model);
|
|
3063
|
-
if (!price) return void 0;
|
|
3064
|
-
const usd = ((usage3.input + usage3.cacheCreation) * price.input + usage3.cacheRead * price.cachedInput + usage3.output * price.output) / 1e6;
|
|
3065
|
-
return Number.isFinite(usd) && usd >= 0 ? usd : void 0;
|
|
3066
|
-
}
|
|
3067
|
-
var OPENAI, PRICES;
|
|
3068
|
-
var init_prices = __esm({
|
|
3069
|
-
"../cli/src/lib/agent/prices.ts"() {
|
|
3070
|
-
"use strict";
|
|
3071
|
-
OPENAI = {
|
|
3072
|
-
"gpt-6.1-sol": { input: 2, cachedInput: 0.1, output: 10 },
|
|
3073
|
-
"gpt-6-astra": { input: 10, cachedInput: 1, output: 50 },
|
|
3074
|
-
"gpt-6-sol": { input: 2, cachedInput: 0.2, output: 10 },
|
|
3075
|
-
"gpt-6-luna": { input: 0.1, cachedInput: 0.01, output: 0.5 },
|
|
3076
|
-
"gpt-5.6-sol": { input: 4, cachedInput: 0.4, output: 20 },
|
|
3077
|
-
"gpt-5.6-terra": { input: 2, cachedInput: 0.2, output: 12 },
|
|
3078
|
-
"gpt-5.6-luna": { input: 0.2, cachedInput: 0.02, output: 1.2 },
|
|
3079
|
-
"gpt-5.5": { input: 5, cachedInput: 0.5, output: 30 },
|
|
3080
|
-
"gpt-5.5-pro": { input: 30, cachedInput: 30, output: 180 },
|
|
3081
|
-
"gpt-5.4": { input: 2.5, cachedInput: 0.25, output: 15 },
|
|
3082
|
-
"gpt-5.4-mini": { input: 0.75, cachedInput: 0.075, output: 4.5 },
|
|
3083
|
-
"gpt-5.4-nano": { input: 0.2, cachedInput: 0.02, output: 1.25 },
|
|
3084
|
-
"gpt-5.4-pro": { input: 30, cachedInput: 30, output: 180 },
|
|
3085
|
-
"gpt-5.3-codex": { input: 1.75, cachedInput: 0.175, output: 14 },
|
|
3086
|
-
"gpt-5.2": { input: 1.75, cachedInput: 0.175, output: 14 },
|
|
3087
|
-
"gpt-5.2-pro": { input: 21, cachedInput: 21, output: 168 },
|
|
3088
|
-
"gpt-5.1": { input: 1.25, cachedInput: 0.125, output: 10 },
|
|
3089
|
-
"gpt-5": { input: 1.25, cachedInput: 0.125, output: 10 },
|
|
3090
|
-
"gpt-5-mini": { input: 0.25, cachedInput: 0.025, output: 2 },
|
|
3091
|
-
"gpt-5-nano": { input: 0.05, cachedInput: 5e-3, output: 0.4 },
|
|
3092
|
-
"gpt-5-pro": { input: 15, cachedInput: 15, output: 120 }
|
|
3093
|
-
};
|
|
3094
|
-
PRICES = { openai: OPENAI, "openai-api": OPENAI };
|
|
3095
|
-
}
|
|
3096
|
-
});
|
|
3097
|
-
|
|
3098
3265
|
// ../cli/src/lib/agent/wire/codex-session.ts
|
|
3099
3266
|
import { readFileSync as readFileSync2, readdirSync, statSync as statSync2 } from "node:fs";
|
|
3100
3267
|
import { homedir as homedir2 } from "node:os";
|
|
@@ -3150,10 +3317,10 @@ function findRollout(threadId) {
|
|
|
3150
3317
|
}
|
|
3151
3318
|
for (const name of names3) {
|
|
3152
3319
|
if (!name.startsWith("rollout-") || !name.endsWith(tail)) continue;
|
|
3153
|
-
const
|
|
3320
|
+
const path89 = join2(dir, name);
|
|
3154
3321
|
try {
|
|
3155
|
-
const at2 = statSync2(
|
|
3156
|
-
if (!newest2 || at2 > newest2.at) newest2 = { path:
|
|
3322
|
+
const at2 = statSync2(path89).mtimeMs;
|
|
3323
|
+
if (!newest2 || at2 > newest2.at) newest2 = { path: path89, at: at2 };
|
|
3157
3324
|
} catch {
|
|
3158
3325
|
}
|
|
3159
3326
|
}
|
|
@@ -3161,11 +3328,11 @@ function findRollout(threadId) {
|
|
|
3161
3328
|
return newest2?.path;
|
|
3162
3329
|
}
|
|
3163
3330
|
function readCodexRunFacts(threadId) {
|
|
3164
|
-
const
|
|
3165
|
-
if (!
|
|
3331
|
+
const path89 = findRollout(threadId);
|
|
3332
|
+
if (!path89) return void 0;
|
|
3166
3333
|
let raw;
|
|
3167
3334
|
try {
|
|
3168
|
-
raw = readFileSync2(
|
|
3335
|
+
raw = readFileSync2(path89, "utf8");
|
|
3169
3336
|
} catch {
|
|
3170
3337
|
return void 0;
|
|
3171
3338
|
}
|
|
@@ -3291,8 +3458,8 @@ function renderCompleted(item) {
|
|
|
3291
3458
|
const changes = Array.isArray(item.changes) ? item.changes : [];
|
|
3292
3459
|
return changes.map((raw) => {
|
|
3293
3460
|
const change2 = obj2(raw);
|
|
3294
|
-
const
|
|
3295
|
-
return
|
|
3461
|
+
const path89 = str2(change2.path);
|
|
3462
|
+
return path89 ? `\u23FA ${str2(change2.kind) || "change"}(${path89})
|
|
3296
3463
|
` : "";
|
|
3297
3464
|
}).join("");
|
|
3298
3465
|
}
|
|
@@ -3627,10 +3794,10 @@ function readKimiRunFacts(sessionId) {
|
|
|
3627
3794
|
const total = { input: 0, cacheCreation: 0, cacheRead: 0, output: 0 };
|
|
3628
3795
|
let model;
|
|
3629
3796
|
let holding = 0;
|
|
3630
|
-
for (const { path:
|
|
3797
|
+
for (const { path: path89, main } of wireFiles(entry.sessionDir)) {
|
|
3631
3798
|
let raw;
|
|
3632
3799
|
try {
|
|
3633
|
-
raw = readFileSync3(
|
|
3800
|
+
raw = readFileSync3(path89, "utf8");
|
|
3634
3801
|
} catch {
|
|
3635
3802
|
continue;
|
|
3636
3803
|
}
|
|
@@ -3805,11 +3972,11 @@ var init_kimi_stream = __esm({
|
|
|
3805
3972
|
|
|
3806
3973
|
// ../cli/src/lib/agent/wire/acp-cost.ts
|
|
3807
3974
|
import fs14 from "node:fs";
|
|
3808
|
-
import
|
|
3975
|
+
import path16 from "node:path";
|
|
3809
3976
|
import { createHash as createHash4 } from "node:crypto";
|
|
3810
3977
|
function acpCostFile(tool, cwd, session) {
|
|
3811
3978
|
const key = createHash4("sha256").update(JSON.stringify([tool, cwd, session])).digest("hex");
|
|
3812
|
-
return
|
|
3979
|
+
return path16.join(machineHome(), "usage", "acp", `${key}.json`);
|
|
3813
3980
|
}
|
|
3814
3981
|
function readAcpCost(file2) {
|
|
3815
3982
|
try {
|
|
@@ -3822,7 +3989,7 @@ function readAcpCost(file2) {
|
|
|
3822
3989
|
function saveAcpCost(file2, cost) {
|
|
3823
3990
|
if (cost === void 0) return;
|
|
3824
3991
|
try {
|
|
3825
|
-
fs14.mkdirSync(
|
|
3992
|
+
fs14.mkdirSync(path16.dirname(file2), { recursive: true, mode: 448 });
|
|
3826
3993
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
3827
3994
|
fs14.writeFileSync(tmp, JSON.stringify(cost), { mode: 384 });
|
|
3828
3995
|
fs14.renameSync(tmp, file2);
|
|
@@ -4004,7 +4171,7 @@ var init_package = __esm({
|
|
|
4004
4171
|
"../cli/package.json"() {
|
|
4005
4172
|
package_default = {
|
|
4006
4173
|
name: "wildcrane",
|
|
4007
|
-
version: "0.11.
|
|
4174
|
+
version: "0.11.71",
|
|
4008
4175
|
akbContract: 17,
|
|
4009
4176
|
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.",
|
|
4010
4177
|
keywords: [
|
|
@@ -4083,8 +4250,8 @@ var init_version = __esm({
|
|
|
4083
4250
|
import fs15 from "node:fs";
|
|
4084
4251
|
function whereHint(update2, title) {
|
|
4085
4252
|
const locations = Array.isArray(update2.locations) ? update2.locations : [];
|
|
4086
|
-
const
|
|
4087
|
-
return
|
|
4253
|
+
const path89 = str2(obj2(locations[0]).path);
|
|
4254
|
+
return path89 && !title.includes(path89) ? hint(path89) : "";
|
|
4088
4255
|
}
|
|
4089
4256
|
function saidBy(update2) {
|
|
4090
4257
|
const content = Array.isArray(update2.content) ? update2.content : [];
|
|
@@ -4375,7 +4542,7 @@ var init_acp = __esm({
|
|
|
4375
4542
|
});
|
|
4376
4543
|
|
|
4377
4544
|
// ../cli/src/lib/agent/wire/zcode.ts
|
|
4378
|
-
import
|
|
4545
|
+
import path17 from "node:path";
|
|
4379
4546
|
function whereHint2(input, title) {
|
|
4380
4547
|
const named2 = obj2(input);
|
|
4381
4548
|
for (const key of ["command", "file_path", "path", "url", "pattern"]) {
|
|
@@ -4526,7 +4693,7 @@ async function oneTurn2(io, options) {
|
|
|
4526
4693
|
{ stringIds: true }
|
|
4527
4694
|
);
|
|
4528
4695
|
try {
|
|
4529
|
-
const workspacePath =
|
|
4696
|
+
const workspacePath = path17.resolve(io.cwd);
|
|
4530
4697
|
const workspace2 = { workspacePath, workspaceKey: workspacePath };
|
|
4531
4698
|
let opened;
|
|
4532
4699
|
if (io.resumeId) {
|
|
@@ -4665,7 +4832,7 @@ var init_zcode = __esm({
|
|
|
4665
4832
|
|
|
4666
4833
|
// ../cli/src/lib/file-memo.ts
|
|
4667
4834
|
import fs16 from "node:fs";
|
|
4668
|
-
import
|
|
4835
|
+
import path18 from "node:path";
|
|
4669
4836
|
function stamp(paths) {
|
|
4670
4837
|
const parts = [];
|
|
4671
4838
|
const visit = (p2) => {
|
|
@@ -4687,7 +4854,7 @@ function stamp(paths) {
|
|
|
4687
4854
|
} catch {
|
|
4688
4855
|
return;
|
|
4689
4856
|
}
|
|
4690
|
-
for (const name of names3) if (name !== "node_modules" && name !== ".git") visit(
|
|
4857
|
+
for (const name of names3) if (name !== "node_modules" && name !== ".git") visit(path18.join(p2, name));
|
|
4691
4858
|
};
|
|
4692
4859
|
for (const p2 of paths) visit(p2);
|
|
4693
4860
|
return parts.join("\n");
|
|
@@ -4798,7 +4965,7 @@ var init_types3 = __esm({
|
|
|
4798
4965
|
|
|
4799
4966
|
// ../cli/src/lib/agent/settings.ts
|
|
4800
4967
|
import fs17 from "node:fs";
|
|
4801
|
-
import
|
|
4968
|
+
import path19 from "node:path";
|
|
4802
4969
|
function configBlock(value) {
|
|
4803
4970
|
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
4804
4971
|
return value;
|
|
@@ -4862,7 +5029,7 @@ function writeConfig(change2) {
|
|
|
4862
5029
|
}
|
|
4863
5030
|
change2(cfg);
|
|
4864
5031
|
try {
|
|
4865
|
-
fs17.mkdirSync(
|
|
5032
|
+
fs17.mkdirSync(path19.dirname(UI_CONFIG), { recursive: true });
|
|
4866
5033
|
fs17.writeFileSync(UI_CONFIG, JSON.stringify(cfg, null, 2) + "\n");
|
|
4867
5034
|
forgetFileMemos();
|
|
4868
5035
|
return { ok: true };
|
|
@@ -4904,7 +5071,7 @@ function readEnvFile() {
|
|
|
4904
5071
|
function ensureIgnored() {
|
|
4905
5072
|
try {
|
|
4906
5073
|
if (!fs17.existsSync(KANBAN_GITIGNORE)) {
|
|
4907
|
-
fs17.mkdirSync(
|
|
5074
|
+
fs17.mkdirSync(path19.dirname(KANBAN_GITIGNORE), { recursive: true });
|
|
4908
5075
|
fs17.writeFileSync(KANBAN_GITIGNORE, IGNORE_BLOCK);
|
|
4909
5076
|
return { ok: true };
|
|
4910
5077
|
}
|
|
@@ -5429,7 +5596,7 @@ async function run(io, options, count3) {
|
|
|
5429
5596
|
startupTimer = setTimeout(() => {
|
|
5430
5597
|
if (!started) io.event?.({ kind: "log", data: { text: "[conversation] start_unconfirmed" } });
|
|
5431
5598
|
}, CONVERSATION_MS.start);
|
|
5432
|
-
await bounded(rpc.call("turn/start", { threadId, input: [{ type: "text", text: text6 }, ...images.map((
|
|
5599
|
+
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) => {
|
|
5433
5600
|
if (!started) throw error;
|
|
5434
5601
|
});
|
|
5435
5602
|
};
|
|
@@ -5714,74 +5881,23 @@ var init_wire = __esm({
|
|
|
5714
5881
|
}
|
|
5715
5882
|
});
|
|
5716
5883
|
|
|
5717
|
-
// ../cli/src/lib/agent/harnesses/transient.ts
|
|
5718
|
-
function reasonLine(text6, rule) {
|
|
5719
|
-
const line = text6.split("\n").find((l2) => rule.test(l2.toLowerCase())) ?? text6;
|
|
5720
|
-
const said2 = line.trim().replace(/\s+/g, " ");
|
|
5721
|
-
return said2.length > REASON_MAX ? `${said2.slice(0, REASON_MAX - 1)}\u2026` : said2;
|
|
5722
|
-
}
|
|
5723
|
-
function providerBlip(...said2) {
|
|
5724
|
-
for (const text6 of said2) {
|
|
5725
|
-
if (!text6?.trim()) continue;
|
|
5726
|
-
const lower = text6.toLowerCase();
|
|
5727
|
-
if (MANUAL.some((rule) => rule.test(lower))) return void 0;
|
|
5728
|
-
const hit = PASSING.find((rule) => rule.test(lower));
|
|
5729
|
-
if (!hit) continue;
|
|
5730
|
-
const asked = RETRY_AFTER.exec(text6);
|
|
5731
|
-
const seconds = asked ? Number(asked[1]) : NaN;
|
|
5732
|
-
return {
|
|
5733
|
-
reason: reasonLine(text6, hit),
|
|
5734
|
-
...Number.isFinite(seconds) && seconds > 0 ? { retryAfterMs: seconds * 1e3 } : {}
|
|
5735
|
-
};
|
|
5736
|
-
}
|
|
5737
|
-
return void 0;
|
|
5738
|
-
}
|
|
5739
|
-
var MANUAL, PASSING, RETRY_AFTER, REASON_MAX;
|
|
5740
|
-
var init_transient = __esm({
|
|
5741
|
-
"../cli/src/lib/agent/harnesses/transient.ts"() {
|
|
5742
|
-
"use strict";
|
|
5743
|
-
MANUAL = [
|
|
5744
|
-
/\b(401|403)\b/,
|
|
5745
|
-
/unauthorized|forbidden|permission denied/,
|
|
5746
|
-
/authenticat|invalid api key|api[_ ]key|not logged in|\/login|oauth/,
|
|
5747
|
-
/\b429\b/,
|
|
5748
|
-
/rate[_ ]limit|usage limit|quota|credit balance|insufficient|out of tokens/,
|
|
5749
|
-
/cancell?ed|aborted by|interrupted by the user/,
|
|
5750
|
-
/maximum budget|max(imum)? turns|exceeded the budget/,
|
|
5751
|
-
/model not found|unknown model|unsupported|invalid[_ ]request/
|
|
5752
|
-
];
|
|
5753
|
-
PASSING = [
|
|
5754
|
-
// 502/503/529 are distinctive enough to read as a status wherever they appear. A bare
|
|
5755
|
-
// 500 is not — a failure line counting something would match it — so it is left to the
|
|
5756
|
-
// words below, which is how that status is actually written out.
|
|
5757
|
-
/\b(502|503|529)\b/,
|
|
5758
|
-
/overloaded|service unavailable|bad gateway|internal server error|server_error/,
|
|
5759
|
-
/connection (lost|dropped|reset|error|closed)|socket hang up|stream (error|disconnected)/,
|
|
5760
|
-
/econnreset|econnrefused|etimedout|enetunreach|enotfound|eai_again/,
|
|
5761
|
-
/fetch failed|request timed out|network error/
|
|
5762
|
-
];
|
|
5763
|
-
RETRY_AFTER = /retry[-_\s]?after["':=\s]+(\d+)/i;
|
|
5764
|
-
REASON_MAX = 140;
|
|
5765
|
-
}
|
|
5766
|
-
});
|
|
5767
|
-
|
|
5768
5884
|
// ../cli/src/lib/agent/harnesses/claude-code.ts
|
|
5769
|
-
import
|
|
5885
|
+
import path20 from "node:path";
|
|
5770
5886
|
function claudeStreamArgs(argv) {
|
|
5771
5887
|
if (argv.includes("--output-format")) return [];
|
|
5772
5888
|
return ["--output-format", "stream-json", "--verbose", ...argv.includes("--input-format") ? [] : ["--input-format", "stream-json"]];
|
|
5773
5889
|
}
|
|
5774
5890
|
function claudeOnWindows() {
|
|
5775
5891
|
const [local, roaming] = [process.env.LOCALAPPDATA?.trim(), process.env.APPDATA?.trim()];
|
|
5776
|
-
const packages = local ?
|
|
5892
|
+
const packages = local ? path20.join(local, "Packages") : "";
|
|
5777
5893
|
const data = [
|
|
5778
|
-
...folders(packages).filter((name) => /^(\w+\.)?Claude_/i.test(name)).sort().map((name) =>
|
|
5779
|
-
...roaming ? [
|
|
5894
|
+
...folders(packages).filter((name) => /^(\w+\.)?Claude_/i.test(name)).sort().map((name) => path20.join(packages, name, "LocalCache", "Roaming", "Claude")),
|
|
5895
|
+
...roaming ? [path20.join(roaming, "Claude")] : []
|
|
5780
5896
|
];
|
|
5781
5897
|
return data.flatMap(
|
|
5782
|
-
(dir) => latestIn(
|
|
5783
|
-
|
|
5784
|
-
...folders(version).map((build) =>
|
|
5898
|
+
(dir) => latestIn(path20.join(dir, "claude-code")).flatMap((version) => [
|
|
5899
|
+
path20.join(version, "claude.exe"),
|
|
5900
|
+
...folders(version).map((build) => path20.join(version, build, "claude.exe"))
|
|
5785
5901
|
])
|
|
5786
5902
|
);
|
|
5787
5903
|
}
|
|
@@ -6051,7 +6167,7 @@ var init_claude_code = __esm({
|
|
|
6051
6167
|
...latestIn(home(".local", "share", "claude", "versions")),
|
|
6052
6168
|
// The copy Claude Desktop carries.
|
|
6053
6169
|
...process.platform === "win32" ? claudeOnWindows() : latestIn(home("Library", "Application Support", "Claude", "claude-code")).flatMap(
|
|
6054
|
-
(version) => folders(version).map((build) =>
|
|
6170
|
+
(version) => folders(version).map((build) => path20.join(version, build, "claude.app", "Contents", "MacOS", "claude"))
|
|
6055
6171
|
)
|
|
6056
6172
|
],
|
|
6057
6173
|
install: "npm install -g @anthropic-ai/claude-code"
|
|
@@ -6062,7 +6178,7 @@ var init_claude_code = __esm({
|
|
|
6062
6178
|
// ../cli/src/lib/agent/worktree.ts
|
|
6063
6179
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
6064
6180
|
import fs18 from "node:fs";
|
|
6065
|
-
import
|
|
6181
|
+
import path21 from "node:path";
|
|
6066
6182
|
function spawnGit(args2, options) {
|
|
6067
6183
|
const out = spawnSync4("git", args2, {
|
|
6068
6184
|
...options,
|
|
@@ -6097,15 +6213,15 @@ var init_worktree = __esm({
|
|
|
6097
6213
|
gitLimits = { timeoutMs: 3e4 };
|
|
6098
6214
|
GitTimeoutError = class extends Error {
|
|
6099
6215
|
};
|
|
6100
|
-
worktreeDir = (relPath) =>
|
|
6216
|
+
worktreeDir = (relPath) => path21.resolve(REPO_ROOT, relPath);
|
|
6101
6217
|
headCommit = (cwd = REPO_ROOT) => git(["rev-parse", "HEAD"], cwd)?.trim() || null;
|
|
6102
|
-
worktreeExists = (relPath) => !!relPath && fs18.existsSync(
|
|
6218
|
+
worktreeExists = (relPath) => !!relPath && fs18.existsSync(path21.join(worktreeDir(relPath), ".git"));
|
|
6103
6219
|
}
|
|
6104
6220
|
});
|
|
6105
6221
|
|
|
6106
6222
|
// ../cli/src/lib/agent/harnesses/codex.ts
|
|
6107
6223
|
import fs19 from "node:fs";
|
|
6108
|
-
import
|
|
6224
|
+
import path22 from "node:path";
|
|
6109
6225
|
function codexExtraArgs(argv, cwd = REPO_ROOT) {
|
|
6110
6226
|
const extra = [];
|
|
6111
6227
|
if (!namesFlag(argv, ["--json", "--experimental-json"])) extra.push("--json");
|
|
@@ -6121,10 +6237,10 @@ function codexExtraArgs(argv, cwd = REPO_ROOT) {
|
|
|
6121
6237
|
}
|
|
6122
6238
|
const flags = [...argv, ...extra];
|
|
6123
6239
|
const workspaceWrite = flags.some((arg, i) => arg === "--full-auto" || arg === "--sandbox=workspace-write" || (arg === "--sandbox" || arg === "-s") && flags[i + 1] === "workspace-write");
|
|
6124
|
-
if (workspaceWrite &&
|
|
6240
|
+
if (workspaceWrite && path22.resolve(cwd) !== path22.resolve(REPO_ROOT)) {
|
|
6125
6241
|
for (const dir of [KANBAN, AKB_DIR]) {
|
|
6126
|
-
const relative =
|
|
6127
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
6242
|
+
const relative = path22.relative(cwd, dir);
|
|
6243
|
+
if (relative === ".." || relative.startsWith(`..${path22.sep}`) || path22.isAbsolute(relative)) {
|
|
6128
6244
|
extra.push("--add-dir", dir);
|
|
6129
6245
|
}
|
|
6130
6246
|
}
|
|
@@ -6172,28 +6288,28 @@ function codexOnWindows() {
|
|
|
6172
6288
|
const local = envRoot("LOCALAPPDATA");
|
|
6173
6289
|
const profile = envRoot("USERPROFILE");
|
|
6174
6290
|
const programs = envRoot("ProgramFiles");
|
|
6175
|
-
const cache = local ?
|
|
6176
|
-
const releases = profile ?
|
|
6177
|
-
const packages = programs ?
|
|
6291
|
+
const cache = local ? path22.join(local, "OpenAI", "Codex", "bin") : "";
|
|
6292
|
+
const releases = profile ? path22.join(profile, ".codex", "packages", "standalone", "releases") : "";
|
|
6293
|
+
const packages = programs ? path22.join(programs, "WindowsApps") : "";
|
|
6178
6294
|
return [
|
|
6179
6295
|
// Desktop's relocated CLI cache: a folder per build hash, newest file first.
|
|
6180
|
-
...byNewest(folders(cache).map((name) =>
|
|
6296
|
+
...byNewest(folders(cache).map((name) => path22.join(cache, name, "codex.exe"))),
|
|
6181
6297
|
// The separate standalone launcher, at a path with nothing variable in it.
|
|
6182
|
-
...local ? [
|
|
6298
|
+
...local ? [path22.join(local, "Programs", "OpenAI", "Codex", "bin", "codex.exe")] : [],
|
|
6183
6299
|
// That launcher's release payload: a folder per version and target.
|
|
6184
6300
|
...byVersion(folders(releases).filter(ourArch)).map(
|
|
6185
|
-
(name) =>
|
|
6301
|
+
(name) => path22.join(releases, name, "bin", "codex.exe")
|
|
6186
6302
|
),
|
|
6187
6303
|
// Desktop's own MSIX package.
|
|
6188
6304
|
...byVersion(folders(packages).filter((name) => name.startsWith("OpenAI.Codex_")).filter(ourArch)).map(
|
|
6189
|
-
(name) =>
|
|
6305
|
+
(name) => path22.join(packages, name, "app", "resources", "codex.exe")
|
|
6190
6306
|
)
|
|
6191
6307
|
];
|
|
6192
6308
|
}
|
|
6193
6309
|
function codexInstalls() {
|
|
6194
6310
|
const chosen = process.env.CODEX_INSTALL_DIR?.trim();
|
|
6195
6311
|
return [
|
|
6196
|
-
...chosen ? [
|
|
6312
|
+
...chosen ? [path22.join(chosen, "codex")] : [],
|
|
6197
6313
|
...process.platform === "win32" ? codexOnWindows() : [
|
|
6198
6314
|
// macOS, where Codex now lives in the merged app — `codex-cli/bin/` since 26.928…
|
|
6199
6315
|
"/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex",
|
|
@@ -6252,7 +6368,7 @@ var init_codex2 = __esm({
|
|
|
6252
6368
|
systemPrompt(text6, argv) {
|
|
6253
6369
|
if (namesFlag(argv, ["developer_instructions", "model_instructions_file"])) return {};
|
|
6254
6370
|
try {
|
|
6255
|
-
const config = fs19.readFileSync(
|
|
6371
|
+
const config = fs19.readFileSync(path22.join(process.env.CODEX_HOME || home(".codex"), "config.toml"), "utf8");
|
|
6256
6372
|
if (/^\s*(?:developer_instructions|model_instructions_file)\s*=/m.test(config)) return {};
|
|
6257
6373
|
} catch {
|
|
6258
6374
|
}
|
|
@@ -6506,23 +6622,23 @@ var init_cursor = __esm({
|
|
|
6506
6622
|
|
|
6507
6623
|
// ../cli/src/lib/agent/harnesses/dsh.ts
|
|
6508
6624
|
import fs20 from "node:fs";
|
|
6509
|
-
import
|
|
6625
|
+
import path23 from "node:path";
|
|
6510
6626
|
function dshHome(argv) {
|
|
6511
6627
|
const binary = argv[0];
|
|
6512
6628
|
if (!binary) return void 0;
|
|
6513
|
-
const names3 = process.platform === "win32" && !
|
|
6514
|
-
const candidates = binary.includes("/") || binary.includes("\\") ? names3 : (process.env.PATH ?? "").split(
|
|
6629
|
+
const names3 = process.platform === "win32" && !path23.extname(binary) ? [".exe", ".cmd"].map((ext) => binary + ext) : [binary];
|
|
6630
|
+
const candidates = binary.includes("/") || binary.includes("\\") ? names3 : (process.env.PATH ?? "").split(path23.delimiter).filter(Boolean).flatMap((dir2) => names3.map((name) => path23.join(dir2, name)));
|
|
6515
6631
|
let dir;
|
|
6516
6632
|
try {
|
|
6517
6633
|
const found2 = candidates.find((candidate) => fs20.existsSync(candidate));
|
|
6518
6634
|
if (!found2) return void 0;
|
|
6519
6635
|
const script = /\.cmd$/i.test(found2) ? shimTarget(fs20.readFileSync(found2, "utf8"), found2)?.script : void 0;
|
|
6520
|
-
dir =
|
|
6636
|
+
dir = path23.dirname(fs20.realpathSync(script ?? found2));
|
|
6521
6637
|
} catch {
|
|
6522
6638
|
return void 0;
|
|
6523
6639
|
}
|
|
6524
|
-
for (let up =
|
|
6525
|
-
if (fs20.existsSync(
|
|
6640
|
+
for (let up = path23.dirname(dir); dir !== up; up = path23.dirname(dir)) {
|
|
6641
|
+
if (fs20.existsSync(path23.join(dir, "package.json"))) return dir;
|
|
6526
6642
|
dir = up;
|
|
6527
6643
|
}
|
|
6528
6644
|
return void 0;
|
|
@@ -6530,7 +6646,7 @@ function dshHome(argv) {
|
|
|
6530
6646
|
function dshFound(binary, onPath2) {
|
|
6531
6647
|
const home3 = dshHome([binary]);
|
|
6532
6648
|
const exts = process.platform === "win32" ? [".cmd", ".exe"] : [""];
|
|
6533
|
-
return !!home3 && exts.some((ext) => fs20.existsSync(
|
|
6649
|
+
return !!home3 && exts.some((ext) => fs20.existsSync(path23.join(home3, "node_modules", ".bin", `dsh${ext}`))) || onPath2("dsh");
|
|
6534
6650
|
}
|
|
6535
6651
|
function dshExtraArgs(argv) {
|
|
6536
6652
|
const args2 = namesFlag(argv, ["--permission-mode"]) ? [] : ["--permission-mode", "workspace-write"];
|
|
@@ -7250,7 +7366,7 @@ var init_providers = __esm({
|
|
|
7250
7366
|
});
|
|
7251
7367
|
|
|
7252
7368
|
// ../cli/src/lib/agent/run-settings.ts
|
|
7253
|
-
import
|
|
7369
|
+
import path24 from "node:path";
|
|
7254
7370
|
function isFilled(harness, { values, secretsSet }) {
|
|
7255
7371
|
return (key) => {
|
|
7256
7372
|
const setting = harness.settings.find((s) => s.key === key);
|
|
@@ -7330,7 +7446,7 @@ function languageEnv(given) {
|
|
|
7330
7446
|
try {
|
|
7331
7447
|
const config = JSON.parse(env2.OPENCODE_CONFIG_CONTENT ?? "{}");
|
|
7332
7448
|
if (Array.isArray(config.instructions)) {
|
|
7333
|
-
config.instructions = config.instructions.filter((file2) => typeof file2 !== "string" ||
|
|
7449
|
+
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)));
|
|
7334
7450
|
env2.OPENCODE_CONFIG_CONTENT = JSON.stringify(config);
|
|
7335
7451
|
}
|
|
7336
7452
|
} catch {
|
|
@@ -7346,7 +7462,7 @@ function withSystemLanguage(harness, argv, env2, language) {
|
|
|
7346
7462
|
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.";
|
|
7347
7463
|
return { argv, env: env2, note };
|
|
7348
7464
|
}
|
|
7349
|
-
const at2 = /^node(?:\.exe)?$/.test(
|
|
7465
|
+
const at2 = /^node(?:\.exe)?$/.test(path24.basename(argv[0])) && argv[1] && !argv[1].startsWith("-") ? 2 : 1;
|
|
7350
7466
|
return { argv: [...argv.slice(0, at2), ...added?.args ?? [], ...argv.slice(at2)], env: { ...env2, ...added?.env } };
|
|
7351
7467
|
}
|
|
7352
7468
|
var init_run_settings = __esm({
|
|
@@ -7401,10 +7517,10 @@ var init_execution = __esm({
|
|
|
7401
7517
|
|
|
7402
7518
|
// ../cli/src/lib/agent/log.ts
|
|
7403
7519
|
import fs21 from "node:fs";
|
|
7404
|
-
import
|
|
7520
|
+
import path25 from "node:path";
|
|
7405
7521
|
function pruneLogs() {
|
|
7406
7522
|
try {
|
|
7407
|
-
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(
|
|
7523
|
+
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);
|
|
7408
7524
|
const kept2 = new Set(runs.slice(0, KEEP_LOGS).map((r2) => r2.id));
|
|
7409
7525
|
const drop = new Set(runs.slice(KEEP_LOGS).map((r2) => r2.id));
|
|
7410
7526
|
for (const f2 of fs21.readdirSync(SESSIONS_DIR)) {
|
|
@@ -7413,7 +7529,7 @@ function pruneLogs() {
|
|
|
7413
7529
|
const stray = f2.endsWith(".images") && !kept2.has(id) && !drop.has(id) && stale2(f2);
|
|
7414
7530
|
if (!stray && !drop.has(id)) continue;
|
|
7415
7531
|
try {
|
|
7416
|
-
fs21.rmSync(
|
|
7532
|
+
fs21.rmSync(path25.join(SESSIONS_DIR, f2), { recursive: true, force: true });
|
|
7417
7533
|
} catch {
|
|
7418
7534
|
}
|
|
7419
7535
|
}
|
|
@@ -7422,7 +7538,7 @@ function pruneLogs() {
|
|
|
7422
7538
|
}
|
|
7423
7539
|
function stale2(name) {
|
|
7424
7540
|
try {
|
|
7425
|
-
return Date.now() - fs21.statSync(
|
|
7541
|
+
return Date.now() - fs21.statSync(path25.join(SESSIONS_DIR, name)).mtimeMs > STRAY_MS;
|
|
7426
7542
|
} catch {
|
|
7427
7543
|
return false;
|
|
7428
7544
|
}
|
|
@@ -7579,9 +7695,9 @@ __export(store_exports, {
|
|
|
7579
7695
|
withStore: () => withStore
|
|
7580
7696
|
});
|
|
7581
7697
|
import fs22 from "node:fs";
|
|
7582
|
-
import
|
|
7698
|
+
import path26 from "node:path";
|
|
7583
7699
|
function logPathIn(held4, sessionId) {
|
|
7584
|
-
return typeof held4 === "string" && held4.startsWith(SESSIONS_DIR +
|
|
7700
|
+
return typeof held4 === "string" && held4.startsWith(SESSIONS_DIR + path26.sep) ? held4 : logPathOf(sessionId);
|
|
7585
7701
|
}
|
|
7586
7702
|
function parseStore() {
|
|
7587
7703
|
let data;
|
|
@@ -7947,7 +8063,7 @@ function writeStore(store) {
|
|
|
7947
8063
|
marks: store.marks,
|
|
7948
8064
|
...store.refined ? { refined: store.refined } : {}
|
|
7949
8065
|
};
|
|
7950
|
-
fs22.mkdirSync(
|
|
8066
|
+
fs22.mkdirSync(path26.dirname(SESSIONS), { recursive: true });
|
|
7951
8067
|
const tmp = `${SESSIONS}.tmp`;
|
|
7952
8068
|
fs22.writeFileSync(tmp, JSON.stringify(kept2, null, 2) + "\n");
|
|
7953
8069
|
fs22.renameSync(tmp, SESSIONS);
|
|
@@ -8013,8 +8129,8 @@ var init_store = __esm({
|
|
|
8013
8129
|
init_log();
|
|
8014
8130
|
KEEP_RUNS = 100;
|
|
8015
8131
|
KEEP_DELIVERIES = 30;
|
|
8016
|
-
logPathOf = (sessionId) =>
|
|
8017
|
-
eventsPathOf = (sessionId) =>
|
|
8132
|
+
logPathOf = (sessionId) => path26.join(SESSIONS_DIR, `${sessionId}.log`);
|
|
8133
|
+
eventsPathOf = (sessionId) => path26.join(SESSIONS_DIR, `${sessionId}.events.jsonl`);
|
|
8018
8134
|
WAS_CLARIFY = /* @__PURE__ */ new Set(["auto-refine", "refine", "raise-questions"]);
|
|
8019
8135
|
RETIRED_ACTIONS = /* @__PURE__ */ new Set([
|
|
8020
8136
|
"channel",
|
|
@@ -8195,8 +8311,8 @@ var init_file_limits = __esm({
|
|
|
8195
8311
|
});
|
|
8196
8312
|
|
|
8197
8313
|
// ../cli/src/lib/shared/board-files.ts
|
|
8198
|
-
function studioRenamed(
|
|
8199
|
-
const to =
|
|
8314
|
+
function studioRenamed(path89, content) {
|
|
8315
|
+
const to = path89.replace(/^(rules\/)?workflows\//, "$1studios/").replace(/^(studios\/[^/]+)\/WORKFLOW\.md$/, "$1/STUDIO.md");
|
|
8200
8316
|
if (!to.endsWith(".md")) return { path: to, content };
|
|
8201
8317
|
if (to.startsWith("studios/")) return { path: to, content: content.replace(/^(icon:\s*["']?)workflow(-kit)?(["']?\s*)$/gm, "$1studio$2$3") };
|
|
8202
8318
|
const front = /^(?:todo|triage)\//.test(to) ? /^---\r?\n[\s\S]*?\r?\n---/.exec(content)?.[0] : void 0;
|
|
@@ -8723,7 +8839,7 @@ function diagramFrom(files) {
|
|
|
8723
8839
|
if ("problem" in read4) return null;
|
|
8724
8840
|
return studioDiagram(read4.def, (name) => {
|
|
8725
8841
|
const text6 = files[`agents/${name}/AGENT.md`];
|
|
8726
|
-
const parsed = text6 === void 0 ? null : parseSpecAgent(text6, name, (
|
|
8842
|
+
const parsed = text6 === void 0 ? null : parseSpecAgent(text6, name, (path89) => files[`agents/${name}/${path89}`] ?? null, false);
|
|
8727
8843
|
return parsed && "agent" in parsed ? parsed.agent : null;
|
|
8728
8844
|
});
|
|
8729
8845
|
}
|
|
@@ -8871,16 +8987,16 @@ var init_studio_files = __esm({
|
|
|
8871
8987
|
|
|
8872
8988
|
// ../cli/src/lib/agent/studio-folder.ts
|
|
8873
8989
|
import fs23 from "node:fs";
|
|
8874
|
-
import
|
|
8990
|
+
import path27 from "node:path";
|
|
8875
8991
|
function filesOf(dir, base = dir) {
|
|
8876
8992
|
return fs23.readdirSync(dir, { withFileTypes: true }).filter((e2) => !e2.name.startsWith(".")).flatMap((e2) => {
|
|
8877
|
-
const full =
|
|
8878
|
-
return e2.isDirectory() ? filesOf(full, base) : [
|
|
8993
|
+
const full = path27.join(dir, e2.name);
|
|
8994
|
+
return e2.isDirectory() ? filesOf(full, base) : [path27.relative(base, full).split(path27.sep).join("/")];
|
|
8879
8995
|
});
|
|
8880
8996
|
}
|
|
8881
8997
|
function readStudioFile(dir, file2) {
|
|
8882
|
-
const full =
|
|
8883
|
-
return isAboutFile(file2) && !file2.endsWith(".md") ? `data:${MIME[
|
|
8998
|
+
const full = path27.join(dir, file2);
|
|
8999
|
+
return isAboutFile(file2) && !file2.endsWith(".md") ? `data:${MIME[path27.extname(file2)]};base64,${fs23.readFileSync(full).toString("base64")}` : fs23.readFileSync(full, "utf8");
|
|
8884
9000
|
}
|
|
8885
9001
|
var MIME, readStudioFolder;
|
|
8886
9002
|
var init_studio_folder = __esm({
|
|
@@ -8895,35 +9011,15 @@ var init_studio_folder = __esm({
|
|
|
8895
9011
|
// ../official/pack.ts
|
|
8896
9012
|
import crypto2 from "node:crypto";
|
|
8897
9013
|
import fs24 from "node:fs";
|
|
8898
|
-
import
|
|
9014
|
+
import path28 from "node:path";
|
|
8899
9015
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
8900
9016
|
function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
8901
|
-
const
|
|
8902
|
-
const agentFiles = Object.fromEntries(dirs(agentsDir).map((name) => {
|
|
8903
|
-
const dir = path27.join(agentsDir, name);
|
|
8904
|
-
return [name, readStudioFolder(dir)];
|
|
8905
|
-
}));
|
|
8906
|
-
for (const [name, own] of Object.entries(loose ? {} : agentFiles)) {
|
|
8907
|
-
const read4 = parseSpecAgent(own["AGENT.md"] ?? "", `official/agents/${name}/AGENT.md`, (p2) => own[p2] ?? null, true);
|
|
8908
|
-
if ("problem" in read4) throw new Error(read4.problem);
|
|
8909
|
-
}
|
|
8910
|
-
const studiosDir = path27.join(root2, "studios");
|
|
9017
|
+
const studiosDir = path28.join(root2, "studios");
|
|
8911
9018
|
return dirs(studiosDir).map((folder) => {
|
|
8912
|
-
const
|
|
8913
|
-
const files = {};
|
|
8914
|
-
for (const f2 of filesOf(dir).sort()) {
|
|
8915
|
-
if (f2 === STUDIO_FILE || f2 === CARD_TEMPLATE_FILE || f2 === MCP_FILE || f2.startsWith("skills/") || f2.startsWith(SHARED_DIR) || isAboutFile(f2)) files[f2] = readStudioFile(dir, f2);
|
|
8916
|
-
}
|
|
8917
|
-
const read4 = checkStudioFiles({ [STUDIO_FILE]: files[STUDIO_FILE], ...Object.fromEntries(
|
|
8918
|
-
Object.entries(agentFiles).flatMap(([name, own]) => Object.entries(own).map(([f2, t]) => [`agents/${name}/${f2}`, t]))
|
|
8919
|
-
) });
|
|
8920
|
-
if (!read4.ok && !loose) throw new Error(`official/studios/${folder}: ${read4.file}: ${read4.reason}`);
|
|
9019
|
+
const files = readStudioFolder(path28.join(studiosDir, folder));
|
|
8921
9020
|
const parsed = parseStudioFile(folder, files[STUDIO_FILE] ?? "", STUDIO_FILE);
|
|
8922
9021
|
if ("problem" in parsed) throw new Error(parsed.problem);
|
|
8923
9022
|
const def = parsed.def;
|
|
8924
|
-
for (const name of [...new Set([...def.previews, ...def.land, ...def.scheduled].map((h3) => h3.agent))].sort()) {
|
|
8925
|
-
for (const [f2, text6] of Object.entries(agentFiles[name] ?? {})) files[`agents/${name}/${f2}`] = text6;
|
|
8926
|
-
}
|
|
8927
9023
|
const checked = loose ? { ok: true } : checkStudioFiles(files, true);
|
|
8928
9024
|
if (!checked.ok) throw new Error(`official/studios/${folder}: ${checked.file}: ${checked.reason}`);
|
|
8929
9025
|
if (!def.names?.zh && !loose) throw new Error(`official/studios/${folder}/${STUDIO_FILE}: add its Chinese name under \`names: zh\``);
|
|
@@ -8942,11 +9038,10 @@ function packOfficial(root2 = OFFICIAL, loose = false) {
|
|
|
8942
9038
|
var OFFICIAL, dirs, hashOf;
|
|
8943
9039
|
var init_pack = __esm({
|
|
8944
9040
|
"../official/pack.ts"() {
|
|
8945
|
-
init_parse();
|
|
8946
9041
|
init_studio_def();
|
|
8947
9042
|
init_studio_folder();
|
|
8948
9043
|
init_studio_files();
|
|
8949
|
-
OFFICIAL =
|
|
9044
|
+
OFFICIAL = path28.dirname(fileURLToPath2(import.meta.url));
|
|
8950
9045
|
dirs = (dir) => fs24.readdirSync(dir, { withFileTypes: true }).filter((e2) => e2.isDirectory()).map((e2) => e2.name).sort();
|
|
8951
9046
|
hashOf = (files) => crypto2.createHash("sha256").update(hashInput(files)).digest("hex");
|
|
8952
9047
|
}
|
|
@@ -8954,7 +9049,7 @@ var init_pack = __esm({
|
|
|
8954
9049
|
|
|
8955
9050
|
// ../cli/src/lib/agent/cloud-studios.ts
|
|
8956
9051
|
import fs25 from "node:fs";
|
|
8957
|
-
import
|
|
9052
|
+
import path29 from "node:path";
|
|
8958
9053
|
function readJson(file2) {
|
|
8959
9054
|
try {
|
|
8960
9055
|
return JSON.parse(fs25.readFileSync(file2, "utf8"));
|
|
@@ -8963,7 +9058,7 @@ function readJson(file2) {
|
|
|
8963
9058
|
}
|
|
8964
9059
|
}
|
|
8965
9060
|
function writeJson(file2, value) {
|
|
8966
|
-
fs25.mkdirSync(
|
|
9061
|
+
fs25.mkdirSync(path29.dirname(file2), { recursive: true });
|
|
8967
9062
|
const tmp = `${file2}.${process.pid}.tmp`;
|
|
8968
9063
|
fs25.writeFileSync(tmp, `${JSON.stringify(value)}
|
|
8969
9064
|
`);
|
|
@@ -8972,14 +9067,14 @@ function writeJson(file2, value) {
|
|
|
8972
9067
|
function heldStudioName(name) {
|
|
8973
9068
|
let files;
|
|
8974
9069
|
try {
|
|
8975
|
-
files = fs25.readdirSync(
|
|
9070
|
+
files = fs25.readdirSync(path29.join(root(), "versions"));
|
|
8976
9071
|
} catch {
|
|
8977
9072
|
return "";
|
|
8978
9073
|
}
|
|
8979
9074
|
const held4 = files.filter((f2) => f2.endsWith(".json")).map((f2) => f2.slice(0, f2.lastIndexOf("@"))).find((id) => studioName(id) === name);
|
|
8980
9075
|
if (!held4) return "";
|
|
8981
9076
|
const file2 = files.filter((f2) => f2.startsWith(`${held4}@`)).sort().pop();
|
|
8982
|
-
return readJson(
|
|
9077
|
+
return readJson(path29.join(root(), "versions", file2))?.name ?? "";
|
|
8983
9078
|
}
|
|
8984
9079
|
function saveVersion(held4) {
|
|
8985
9080
|
const file2 = versionFile(held4.id, held4.version);
|
|
@@ -9115,11 +9210,11 @@ var init_cloud_studios = __esm({
|
|
|
9115
9210
|
init_studio_def();
|
|
9116
9211
|
DEV = "AI4KANBAN_STUDIOS";
|
|
9117
9212
|
FRESH_MS = 6e4;
|
|
9118
|
-
root = () =>
|
|
9213
|
+
root = () => path29.join(machineHome(), "studios");
|
|
9119
9214
|
safe = (name) => name.replace(/[^\w.@-]/g, "_");
|
|
9120
|
-
versionFile = (id, version) =>
|
|
9121
|
-
listFile = (project2) =>
|
|
9122
|
-
pinFile = (task) =>
|
|
9215
|
+
versionFile = (id, version) => path29.join(root(), "versions", `${safe(id)}@${version}.json`);
|
|
9216
|
+
listFile = (project2) => path29.join(root(), "lists", `${safe(project2)}.json`);
|
|
9217
|
+
pinFile = (task) => path29.join(root(), "tasks", `${safe(task)}.json`);
|
|
9123
9218
|
readVersion = (id, version) => readJson(versionFile(id, version));
|
|
9124
9219
|
readPin = (task) => readJson(pinFile(task));
|
|
9125
9220
|
boardProject = () => KANBAN ? runnerProject(KANBAN) : null;
|
|
@@ -9159,7 +9254,7 @@ var init_bundled = __esm({
|
|
|
9159
9254
|
|
|
9160
9255
|
// ../cli/src/lib/agents/catalog.ts
|
|
9161
9256
|
import fs26 from "node:fs";
|
|
9162
|
-
import
|
|
9257
|
+
import path30 from "node:path";
|
|
9163
9258
|
function readCatalog() {
|
|
9164
9259
|
const agents = [];
|
|
9165
9260
|
const problems = [];
|
|
@@ -9272,11 +9367,11 @@ function projectFolders(root2) {
|
|
|
9272
9367
|
}
|
|
9273
9368
|
function agentFileReader(dir) {
|
|
9274
9369
|
return (relative) => {
|
|
9275
|
-
const target =
|
|
9276
|
-
if (target !== dir && !target.startsWith(dir +
|
|
9370
|
+
const target = path30.resolve(dir, relative);
|
|
9371
|
+
if (target !== dir && !target.startsWith(dir + path30.sep)) return null;
|
|
9277
9372
|
try {
|
|
9278
9373
|
const real2 = fs26.realpathSync(target);
|
|
9279
|
-
if (!real2.startsWith(fs26.realpathSync(dir) +
|
|
9374
|
+
if (!real2.startsWith(fs26.realpathSync(dir) + path30.sep)) return null;
|
|
9280
9375
|
return fs26.readFileSync(real2, "utf8");
|
|
9281
9376
|
} catch {
|
|
9282
9377
|
return null;
|
|
@@ -9292,14 +9387,14 @@ function walkFolder(dir, prefix) {
|
|
|
9292
9387
|
}
|
|
9293
9388
|
return entries.flatMap((e2) => {
|
|
9294
9389
|
const here = prefix ? `${prefix}/${e2.name}` : e2.name;
|
|
9295
|
-
return e2.isDirectory() ? walkFolder(
|
|
9390
|
+
return e2.isDirectory() ? walkFolder(path30.join(dir, e2.name), here) : [here];
|
|
9296
9391
|
});
|
|
9297
9392
|
}
|
|
9298
9393
|
function readProject(root2, folder) {
|
|
9299
|
-
const dir =
|
|
9394
|
+
const dir = path30.join(root2, folder);
|
|
9300
9395
|
const file2 = agentFileReader(dir);
|
|
9301
9396
|
const text6 = file2("AGENT.md");
|
|
9302
|
-
const missing = rel(
|
|
9397
|
+
const missing = rel(path30.join(dir, "AGENT.md"));
|
|
9303
9398
|
if (text6 === null) return { problem: `${missing} is missing`, file: missing, missing: true };
|
|
9304
9399
|
const from = missing;
|
|
9305
9400
|
const read4 = parseSpecAgent(text6, from, file2, false, () => ownFiles(walkFolder(dir, "")));
|
|
@@ -9702,10 +9797,10 @@ var init_assemble = __esm({
|
|
|
9702
9797
|
|
|
9703
9798
|
// ../cli/src/lib/cards.ts
|
|
9704
9799
|
import fs27 from "node:fs";
|
|
9705
|
-
import
|
|
9800
|
+
import path31 from "node:path";
|
|
9706
9801
|
function walkMd(dir, acc = []) {
|
|
9707
9802
|
for (const entry of fs27.readdirSync(dir, { withFileTypes: true })) {
|
|
9708
|
-
const full =
|
|
9803
|
+
const full = path31.join(dir, entry.name);
|
|
9709
9804
|
if (entry.isDirectory()) walkMd(full, acc);
|
|
9710
9805
|
else if (entry.name.endsWith(".md")) acc.push(full);
|
|
9711
9806
|
}
|
|
@@ -9714,7 +9809,7 @@ function walkMd(dir, acc = []) {
|
|
|
9714
9809
|
function walkDirs(dir, acc = []) {
|
|
9715
9810
|
for (const entry of fs27.readdirSync(dir, { withFileTypes: true })) {
|
|
9716
9811
|
if (!entry.isDirectory()) continue;
|
|
9717
|
-
const full =
|
|
9812
|
+
const full = path31.join(dir, entry.name);
|
|
9718
9813
|
acc.push(full);
|
|
9719
9814
|
walkDirs(full, acc);
|
|
9720
9815
|
}
|
|
@@ -9722,23 +9817,23 @@ function walkDirs(dir, acc = []) {
|
|
|
9722
9817
|
}
|
|
9723
9818
|
function locate2(id) {
|
|
9724
9819
|
const groupDir = walkDirs(TODO).find(
|
|
9725
|
-
(d2) => idPrefix(
|
|
9820
|
+
(d2) => idPrefix(path31.basename(d2)) === id && fs27.existsSync(path31.join(d2, "root.md"))
|
|
9726
9821
|
);
|
|
9727
9822
|
if (groupDir) {
|
|
9728
|
-
return { kind: "group", target: groupDir, rel:
|
|
9823
|
+
return { kind: "group", target: groupDir, rel: path31.relative(TODO, groupDir) };
|
|
9729
9824
|
}
|
|
9730
|
-
const hit = walkMd(TODO).find((f2) => idPrefix(
|
|
9731
|
-
if (hit) return { kind: "file", target: hit, rel:
|
|
9825
|
+
const hit = walkMd(TODO).find((f2) => idPrefix(path31.basename(f2)) === id);
|
|
9826
|
+
if (hit) return { kind: "file", target: hit, rel: path31.relative(TODO, hit) };
|
|
9732
9827
|
return null;
|
|
9733
9828
|
}
|
|
9734
9829
|
function locateArchived(id) {
|
|
9735
9830
|
if (!fs27.existsSync(ARCHIVE)) return null;
|
|
9736
9831
|
const groupDir = walkDirs(ARCHIVE).find(
|
|
9737
|
-
(d2) => idPrefix(
|
|
9832
|
+
(d2) => idPrefix(path31.basename(d2)) === id && fs27.existsSync(path31.join(d2, "root.md"))
|
|
9738
9833
|
);
|
|
9739
|
-
if (groupDir) return { kind: "group", target: groupDir, rel:
|
|
9740
|
-
const hit = walkMd(ARCHIVE).find((f2) => idPrefix(
|
|
9741
|
-
return hit ? { kind: "file", target: hit, rel:
|
|
9834
|
+
if (groupDir) return { kind: "group", target: groupDir, rel: path31.relative(ARCHIVE, groupDir) };
|
|
9835
|
+
const hit = walkMd(ARCHIVE).find((f2) => idPrefix(path31.basename(f2)) === id);
|
|
9836
|
+
return hit ? { kind: "file", target: hit, rel: path31.relative(ARCHIVE, hit) } : null;
|
|
9742
9837
|
}
|
|
9743
9838
|
function boardCardIds() {
|
|
9744
9839
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -9746,16 +9841,16 @@ function boardCardIds() {
|
|
|
9746
9841
|
const id = idPrefix(name);
|
|
9747
9842
|
if (id !== null) ids.add(id);
|
|
9748
9843
|
};
|
|
9749
|
-
for (const dir of walkDirs(TODO)) keep2(
|
|
9750
|
-
for (const file2 of walkMd(TODO)) keep2(
|
|
9844
|
+
for (const dir of walkDirs(TODO)) keep2(path31.basename(dir));
|
|
9845
|
+
for (const file2 of walkMd(TODO)) keep2(path31.basename(file2));
|
|
9751
9846
|
return ids;
|
|
9752
9847
|
}
|
|
9753
9848
|
function enclosingGroupRoot(file2) {
|
|
9754
|
-
let dir =
|
|
9849
|
+
let dir = path31.dirname(file2);
|
|
9755
9850
|
while (dir.startsWith(TODO) && dir !== TODO) {
|
|
9756
|
-
const root2 =
|
|
9851
|
+
const root2 = path31.join(dir, "root.md");
|
|
9757
9852
|
if (fs27.existsSync(root2) && root2 !== file2) return root2;
|
|
9758
|
-
dir =
|
|
9853
|
+
dir = path31.dirname(dir);
|
|
9759
9854
|
}
|
|
9760
9855
|
return null;
|
|
9761
9856
|
}
|
|
@@ -9766,18 +9861,18 @@ function markSubtask(rootFile, id, action) {
|
|
|
9766
9861
|
return true;
|
|
9767
9862
|
}
|
|
9768
9863
|
function archiveDest(found2) {
|
|
9769
|
-
const dest =
|
|
9864
|
+
const dest = path31.join(ARCHIVE, path31.basename(found2.target));
|
|
9770
9865
|
if (fs27.existsSync(dest)) die(`${rel(dest)} already exists \u2014 move it aside first, then archive again`);
|
|
9771
9866
|
return dest;
|
|
9772
9867
|
}
|
|
9773
9868
|
function dropCrossRefs(id) {
|
|
9774
9869
|
const touched = [];
|
|
9775
9870
|
for (const file2 of walkMd(TODO)) {
|
|
9776
|
-
if (
|
|
9871
|
+
if (path31.basename(file2) === "README.md") continue;
|
|
9777
9872
|
const { text: text6, fields } = dropRefsIn(fs27.readFileSync(file2, "utf8"), id);
|
|
9778
9873
|
if (!fields.length) continue;
|
|
9779
9874
|
fs27.writeFileSync(file2, text6);
|
|
9780
|
-
touched.push(`${
|
|
9875
|
+
touched.push(`${path31.relative(TODO, file2).split(path31.sep).join("/")} (${fields.join(", ")})`);
|
|
9781
9876
|
}
|
|
9782
9877
|
return touched;
|
|
9783
9878
|
}
|
|
@@ -9803,7 +9898,7 @@ var init_slug = __esm({
|
|
|
9803
9898
|
|
|
9804
9899
|
// ../cli/src/lib/validate.ts
|
|
9805
9900
|
import fs28 from "node:fs";
|
|
9806
|
-
import
|
|
9901
|
+
import path32 from "node:path";
|
|
9807
9902
|
function moduleNames() {
|
|
9808
9903
|
if (!fs28.existsSync(MODULES_MD)) return null;
|
|
9809
9904
|
return moduleNamesFrom(fs28.readFileSync(MODULES_MD, "utf8"));
|
|
@@ -9840,7 +9935,7 @@ function dependencyCycle(id, dep) {
|
|
|
9840
9935
|
seen.add(at2);
|
|
9841
9936
|
const found2 = locate2(at2);
|
|
9842
9937
|
if (!found2) return null;
|
|
9843
|
-
const file2 = found2.kind === "group" ?
|
|
9938
|
+
const file2 = found2.kind === "group" ? path32.join(found2.target, "root.md") : found2.target;
|
|
9844
9939
|
const nexts = parseFrontmatter(fs28.readFileSync(file2, "utf8")).meta?.blocked_by ?? [];
|
|
9845
9940
|
if (found2.kind === "group") nexts.push(...groupMembers(found2.target));
|
|
9846
9941
|
for (const next of nexts) {
|
|
@@ -9853,7 +9948,7 @@ function dependencyCycle(id, dep) {
|
|
|
9853
9948
|
return rest && [id, ...rest];
|
|
9854
9949
|
}
|
|
9855
9950
|
function groupMembers(dir) {
|
|
9856
|
-
return walkMd(dir).filter((f2) => f2 !==
|
|
9951
|
+
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);
|
|
9857
9952
|
}
|
|
9858
9953
|
var LEVELS;
|
|
9859
9954
|
var init_validate = __esm({
|
|
@@ -9870,7 +9965,7 @@ var init_validate = __esm({
|
|
|
9870
9965
|
|
|
9871
9966
|
// ../cli/src/lib/memory.ts
|
|
9872
9967
|
import fs29 from "node:fs";
|
|
9873
|
-
import
|
|
9968
|
+
import path33 from "node:path";
|
|
9874
9969
|
function scaffoldProjectMemory() {
|
|
9875
9970
|
const board2 = scaffoldMemoryDir(MEMORY, setOf(BOARD_MEMORY_FILES));
|
|
9876
9971
|
const planner = scaffoldMemoryDir(agentMemoryDir(PLANNER), setOf(PLANNER_MEMORY_FILES));
|
|
@@ -9881,7 +9976,7 @@ function scaffoldMemoryDir(dir, set) {
|
|
|
9881
9976
|
fs29.mkdirSync(dir, { recursive: true });
|
|
9882
9977
|
const made = [];
|
|
9883
9978
|
for (const [name, body] of Object.entries(set)) {
|
|
9884
|
-
const file2 =
|
|
9979
|
+
const file2 = path33.join(dir, name);
|
|
9885
9980
|
if (!fs29.existsSync(file2)) {
|
|
9886
9981
|
fs29.writeFileSync(file2, body);
|
|
9887
9982
|
made.push(name);
|
|
@@ -9918,7 +10013,7 @@ function memoryTarget(name, module = "") {
|
|
|
9918
10013
|
}
|
|
9919
10014
|
function scaffoldFile(file2, name) {
|
|
9920
10015
|
if (fs29.existsSync(file2) || !STARTERS[name]) return;
|
|
9921
|
-
fs29.mkdirSync(
|
|
10016
|
+
fs29.mkdirSync(path33.dirname(file2), { recursive: true });
|
|
9922
10017
|
fs29.writeFileSync(file2, STARTERS[name]);
|
|
9923
10018
|
}
|
|
9924
10019
|
function readTopics(file2) {
|
|
@@ -9979,8 +10074,8 @@ edits here do not last.
|
|
|
9979
10074
|
setOf = (names3) => Object.fromEntries(names3.map((name) => [name, STARTERS[name]]));
|
|
9980
10075
|
RESERVED_MEMORY_DIR = "agents";
|
|
9981
10076
|
STUDIO_MEMORY_DIR = "studios";
|
|
9982
|
-
agentMemoryDir = (agent) =>
|
|
9983
|
-
agentMemoryFile = (agent, name) =>
|
|
10077
|
+
agentMemoryDir = (agent) => path33.join(AGENT_MEMORY, agent);
|
|
10078
|
+
agentMemoryFile = (agent, name) => path33.join(agentMemoryDir(agent), name);
|
|
9984
10079
|
writtenMemoryNames = (agent) => {
|
|
9985
10080
|
try {
|
|
9986
10081
|
return fs29.readdirSync(agentMemoryDir(agent), { withFileTypes: true }).filter((e2) => e2.isFile() && e2.name.endsWith(".md")).map((e2) => e2.name).sort();
|
|
@@ -9992,12 +10087,12 @@ edits here do not last.
|
|
|
9992
10087
|
agentMemoryFiles = (agent) => memoryNamesOf(agent).map((name) => agentMemoryFile(agent, name));
|
|
9993
10088
|
RESERVED_MODULE_NAMES = PLANNER_MEMORY_FILES.map((name) => name.replace(/\.md$/, ""));
|
|
9994
10089
|
isModule = (name) => !!name && !RESERVED_MODULE_NAMES.includes(name);
|
|
9995
|
-
moduleMemoryFile = (module, name) =>
|
|
10090
|
+
moduleMemoryFile = (module, name) => path33.join(agentMemoryDir(PLANNER), module, name);
|
|
9996
10091
|
plannerCopies = (name) => [
|
|
9997
10092
|
agentMemoryFile(PLANNER, name),
|
|
9998
10093
|
...plannerModules().map((m) => moduleMemoryFile(m, name)).filter((file2) => fs29.existsSync(file2))
|
|
9999
10094
|
];
|
|
10000
|
-
memoryFile = (name, module = "") => BOARD_MEMORY_FILES.includes(name) ?
|
|
10095
|
+
memoryFile = (name, module = "") => BOARD_MEMORY_FILES.includes(name) ? path33.join(MEMORY, name) : isModule(module) ? moduleMemoryFile(module, name) : agentMemoryFile(PLANNER, name);
|
|
10001
10096
|
}
|
|
10002
10097
|
});
|
|
10003
10098
|
|
|
@@ -10018,7 +10113,7 @@ var init_studio_file = __esm({
|
|
|
10018
10113
|
|
|
10019
10114
|
// ../cli/src/lib/agent/studios.ts
|
|
10020
10115
|
import fs30 from "node:fs";
|
|
10021
|
-
import
|
|
10116
|
+
import path34 from "node:path";
|
|
10022
10117
|
function studioPurpose(flow) {
|
|
10023
10118
|
if (flow.builtIn) return builtinDescription(flow.id) || flow.name;
|
|
10024
10119
|
return boardStudioDefs().defs.find((d2) => d2.id === flow.id)?.description || flow.name;
|
|
@@ -10180,7 +10275,7 @@ function cardMeta(id) {
|
|
|
10180
10275
|
try {
|
|
10181
10276
|
const found2 = locate2(id) ?? locateArchived(id);
|
|
10182
10277
|
if (!found2) return null;
|
|
10183
|
-
const file2 = found2.kind === "group" ?
|
|
10278
|
+
const file2 = found2.kind === "group" ? path34.join(found2.target, "root.md") : found2.target;
|
|
10184
10279
|
return parseFrontmatter(fs30.readFileSync(file2, "utf8")).meta;
|
|
10185
10280
|
} catch {
|
|
10186
10281
|
return null;
|
|
@@ -10270,7 +10365,7 @@ var init_studios = __esm({
|
|
|
10270
10365
|
previewAgents = (flow) => previewMembers(flow).filter((h3) => !h3.off);
|
|
10271
10366
|
landAgents = (flow) => flow.land.filter((h3) => !h3.off);
|
|
10272
10367
|
archivesOnApproval = (flow) => !!flow && !landAgents(flow).length;
|
|
10273
|
-
studioRuleFile = (id) =>
|
|
10368
|
+
studioRuleFile = (id) => path34.join(RULES, "studios", `${id}.md`);
|
|
10274
10369
|
save = (change2) => writeConfig((cfg) => {
|
|
10275
10370
|
const block = configBlock(cfg.studios);
|
|
10276
10371
|
change2(block);
|
|
@@ -10392,7 +10487,7 @@ var init_stages = __esm({
|
|
|
10392
10487
|
});
|
|
10393
10488
|
|
|
10394
10489
|
// ../cli/src/lib/agent/roles.ts
|
|
10395
|
-
import
|
|
10490
|
+
import path35 from "node:path";
|
|
10396
10491
|
function landRole(name) {
|
|
10397
10492
|
const agent = specAgentCatalog().agents.find((a2) => a2.name === name);
|
|
10398
10493
|
return agent ? { name, gloss: agent.description, memory: [] } : void 0;
|
|
@@ -10522,8 +10617,8 @@ var init_roles = __esm({
|
|
|
10522
10617
|
hiddenRole = (name) => roleNamed(name)?.hidden === true;
|
|
10523
10618
|
stageContractProblems = () => contractProblems([...agentNames(), ...roles().filter((role) => role.hidden).map((role) => role.name)]);
|
|
10524
10619
|
memoryOf = (role) => role.memory.flatMap((file2) => {
|
|
10525
|
-
const at2 =
|
|
10526
|
-
return
|
|
10620
|
+
const at2 = path35.join(KANBAN, file2);
|
|
10621
|
+
return path35.dirname(at2) === agentMemoryDir(PLANNER) ? plannerCopies(path35.basename(at2)) : [at2];
|
|
10527
10622
|
}).map(rel);
|
|
10528
10623
|
ownMemoryOf = (name, memory) => memoryNamesOf(name).filter((file2) => memory.includes(rel(agentMemoryFile(name, file2))));
|
|
10529
10624
|
agentNames = () => agentRoster().map((entry) => entry.name);
|
|
@@ -11076,7 +11171,7 @@ var init_resolve = __esm({
|
|
|
11076
11171
|
});
|
|
11077
11172
|
|
|
11078
11173
|
// ../cli/src/lib/agents/index.ts
|
|
11079
|
-
import
|
|
11174
|
+
import path36 from "node:path";
|
|
11080
11175
|
function agentLines(agent, language = readLanguage()) {
|
|
11081
11176
|
const said2 = agent.i18n[language];
|
|
11082
11177
|
return {
|
|
@@ -11123,7 +11218,7 @@ function agentFilesBlock(agent) {
|
|
|
11123
11218
|
"Read one only when the work calls for it:",
|
|
11124
11219
|
"",
|
|
11125
11220
|
...agent.files.map(
|
|
11126
|
-
(f2) => dir ? `- \`${rel(
|
|
11221
|
+
(f2) => dir ? `- \`${rel(path36.join(dir, f2))}\`` : `- \`${f2}\` \u2014 \`${rawMove(studio ? `file ${studio} agents/${agent.name}/${f2}` : `agent-file ${agent.name} ${f2}`)}\``
|
|
11127
11222
|
)
|
|
11128
11223
|
].join("\n");
|
|
11129
11224
|
}
|
|
@@ -11244,12 +11339,12 @@ var init_candidate = __esm({
|
|
|
11244
11339
|
|
|
11245
11340
|
// ../cli/src/lib/agent/outputs.ts
|
|
11246
11341
|
import fs31 from "node:fs";
|
|
11247
|
-
import
|
|
11342
|
+
import path37 from "node:path";
|
|
11248
11343
|
function cardBody(cardId2) {
|
|
11249
11344
|
const found2 = locate2(cardId2) ?? locateArchived(cardId2);
|
|
11250
11345
|
if (!found2) return "";
|
|
11251
11346
|
try {
|
|
11252
|
-
return fs31.readFileSync(found2.kind === "group" ?
|
|
11347
|
+
return fs31.readFileSync(found2.kind === "group" ? path37.join(found2.target, "root.md") : found2.target, "utf8");
|
|
11253
11348
|
} catch {
|
|
11254
11349
|
return "";
|
|
11255
11350
|
}
|
|
@@ -11502,7 +11597,7 @@ var init_runner = __esm({
|
|
|
11502
11597
|
|
|
11503
11598
|
// ../cli/src/lib/agent/rules.ts
|
|
11504
11599
|
import fs33 from "node:fs";
|
|
11505
|
-
import
|
|
11600
|
+
import path38 from "node:path";
|
|
11506
11601
|
function ruleFile(agent) {
|
|
11507
11602
|
if (!agent || hiddenRole(agent)) return "";
|
|
11508
11603
|
try {
|
|
@@ -11569,7 +11664,7 @@ var init_rules2 = __esm({
|
|
|
11569
11664
|
init_runner();
|
|
11570
11665
|
init_studios();
|
|
11571
11666
|
init_types3();
|
|
11572
|
-
rulePath = (agent) =>
|
|
11667
|
+
rulePath = (agent) => path38.join(RULES, `${agent}.md`);
|
|
11573
11668
|
flowForRequest = (req) => req.refineRound !== void 0 && REFINE_ACTIONS.has(req.action) ? flowByCommand("refine") : flowByAction(req.action);
|
|
11574
11669
|
ruleOwnerSays = (owner) => `\`${owner.name}\` agent carries one rule of its own${owner.role ? ", on every flow it runs" : ""}`;
|
|
11575
11670
|
said = (owner, rule) => owner && rule ? [
|
|
@@ -11581,7 +11676,7 @@ var init_rules2 = __esm({
|
|
|
11581
11676
|
|
|
11582
11677
|
// ../cli/src/lib/agent/deliveries.ts
|
|
11583
11678
|
import fs34 from "node:fs";
|
|
11584
|
-
import
|
|
11679
|
+
import path39 from "node:path";
|
|
11585
11680
|
function writeAudit(delivery, runs) {
|
|
11586
11681
|
const known2 = new Map(readAudit(delivery.deliveryId)?.sessions.map((s) => [s.sessionId, s]) ?? []);
|
|
11587
11682
|
const sessions = delivery.sessions.flatMap((id) => {
|
|
@@ -11656,7 +11751,7 @@ function allAudits() {
|
|
|
11656
11751
|
const out = [];
|
|
11657
11752
|
for (const name of names3) {
|
|
11658
11753
|
if (!name.endsWith(".json")) continue;
|
|
11659
|
-
const audit = wholeAudit(
|
|
11754
|
+
const audit = wholeAudit(path39.join(DELIVERIES, name));
|
|
11660
11755
|
if (audit) out.push(audit);
|
|
11661
11756
|
}
|
|
11662
11757
|
return out;
|
|
@@ -11810,7 +11905,7 @@ function carryOnFrom(_deliveryId) {
|
|
|
11810
11905
|
function approvedRequirements(cardId2) {
|
|
11811
11906
|
const found2 = locate2(cardId2);
|
|
11812
11907
|
if (!found2) return "";
|
|
11813
|
-
const file2 = found2.kind === "group" ?
|
|
11908
|
+
const file2 = found2.kind === "group" ? path39.join(found2.target, "root.md") : found2.target;
|
|
11814
11909
|
let text6;
|
|
11815
11910
|
try {
|
|
11816
11911
|
text6 = fs34.readFileSync(file2, "utf8");
|
|
@@ -11843,7 +11938,7 @@ function cardMeta2(cardId2) {
|
|
|
11843
11938
|
try {
|
|
11844
11939
|
const found2 = locate2(cardId2);
|
|
11845
11940
|
if (!found2) return null;
|
|
11846
|
-
const file2 = found2.kind === "group" ?
|
|
11941
|
+
const file2 = found2.kind === "group" ? path39.join(found2.target, "root.md") : found2.target;
|
|
11847
11942
|
return parseFrontmatter(fs34.readFileSync(file2, "utf8")).meta;
|
|
11848
11943
|
} catch {
|
|
11849
11944
|
return null;
|
|
@@ -12015,11 +12110,11 @@ var init_deliveries = __esm({
|
|
|
12015
12110
|
init_types3();
|
|
12016
12111
|
init_worktree();
|
|
12017
12112
|
init_lock();
|
|
12018
|
-
auditPath = (deliveryId) =>
|
|
12113
|
+
auditPath = (deliveryId) => path39.join(DELIVERIES, `${deliveryId}.json`);
|
|
12019
12114
|
activeAudits = () => allAudits().filter((a2) => a2.status === "active");
|
|
12020
12115
|
auditRow = (audit) => readDeliveryRow({ ...audit, sessions: audit.sessions.map((s) => s.sessionId) });
|
|
12021
12116
|
lastSessionRunning = (audit) => audit.sessions[audit.sessions.length - 1]?.status === "running";
|
|
12022
|
-
localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) =>
|
|
12117
|
+
localAudit = (audit) => worktreeExists(audit.worktree) || audit.sessions.some((session) => path39.resolve(REPO_ROOT, session.log) === logPathOf(session.sessionId) && fs34.existsSync(logPathOf(session.sessionId)));
|
|
12023
12118
|
unknownDelivery = (id) => refusal("deliveryNotFound", `no delivery here answers to "${id}"`, { id });
|
|
12024
12119
|
isResumable = (delivery) => !resumeRefusal(delivery);
|
|
12025
12120
|
APPROVED = [
|
|
@@ -12183,9 +12278,9 @@ var init_telemetry_contract = __esm({
|
|
|
12183
12278
|
|
|
12184
12279
|
// ../cli/src/lib/agent/catalog.ts
|
|
12185
12280
|
import fs35 from "node:fs";
|
|
12186
|
-
import
|
|
12281
|
+
import path40 from "node:path";
|
|
12187
12282
|
function cacheFile() {
|
|
12188
|
-
return
|
|
12283
|
+
return path40.join(machineHome(), "models-dev.json");
|
|
12189
12284
|
}
|
|
12190
12285
|
function readCache() {
|
|
12191
12286
|
const file2 = cacheFile();
|
|
@@ -12236,7 +12331,7 @@ function refreshCatalog() {
|
|
|
12236
12331
|
const limits = limitsIn(await answer2.json());
|
|
12237
12332
|
if (Object.keys(limits).length === 0) return;
|
|
12238
12333
|
const file2 = cacheFile();
|
|
12239
|
-
fs35.mkdirSync(
|
|
12334
|
+
fs35.mkdirSync(path40.dirname(file2), { recursive: true });
|
|
12240
12335
|
fs35.writeFileSync(file2, JSON.stringify({ fetchedAt: Date.now(), limits }));
|
|
12241
12336
|
} catch {
|
|
12242
12337
|
}
|
|
@@ -12250,6 +12345,7 @@ function spellings(model) {
|
|
|
12250
12345
|
return [.../* @__PURE__ */ new Set([id, undated])];
|
|
12251
12346
|
}
|
|
12252
12347
|
function contextLimit(harness, model) {
|
|
12348
|
+
if (harness === "antigravity") return void 0;
|
|
12253
12349
|
if (!model?.trim()) return void 0;
|
|
12254
12350
|
const limits = readCache()?.limits;
|
|
12255
12351
|
if (!limits) return void 0;
|
|
@@ -12301,7 +12397,7 @@ var init_catalog2 = __esm({
|
|
|
12301
12397
|
|
|
12302
12398
|
// ../cli/src/lib/machine/telemetry.ts
|
|
12303
12399
|
import fs36 from "node:fs";
|
|
12304
|
-
import
|
|
12400
|
+
import path41 from "node:path";
|
|
12305
12401
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
12306
12402
|
function readUsageReporting() {
|
|
12307
12403
|
const { unreadable, values } = heldSettings();
|
|
@@ -12346,14 +12442,14 @@ var init_telemetry = __esm({
|
|
|
12346
12442
|
"use strict";
|
|
12347
12443
|
init_home();
|
|
12348
12444
|
init_settings();
|
|
12349
|
-
usageQueueFile = () =>
|
|
12350
|
-
usageStateFile = () =>
|
|
12445
|
+
usageQueueFile = () => path41.join(machineHome(), "usage-queue.jsonl");
|
|
12446
|
+
usageStateFile = () => path41.join(machineHome(), "usage-state.json");
|
|
12351
12447
|
}
|
|
12352
12448
|
});
|
|
12353
12449
|
|
|
12354
12450
|
// ../cli/src/lib/machine/usage.ts
|
|
12355
12451
|
import fs37 from "node:fs";
|
|
12356
|
-
import
|
|
12452
|
+
import path42 from "node:path";
|
|
12357
12453
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
12358
12454
|
function usageSurface() {
|
|
12359
12455
|
return process.env.KANBAN_DESKTOP === "1" ? "app" : "command";
|
|
@@ -12632,7 +12728,7 @@ var init_usage2 = __esm({
|
|
|
12632
12728
|
"decisions_stood",
|
|
12633
12729
|
"decisions_overruled"
|
|
12634
12730
|
];
|
|
12635
|
-
boardFile = () =>
|
|
12731
|
+
boardFile = () => path42.join(BOARD_STATE, "usage-board.json");
|
|
12636
12732
|
countOf = (counts, name) => {
|
|
12637
12733
|
const n = counts?.[name];
|
|
12638
12734
|
return typeof n === "number" && Number.isInteger(n) && n > 0 ? n : 0;
|
|
@@ -12669,7 +12765,7 @@ var init_sources = __esm({
|
|
|
12669
12765
|
|
|
12670
12766
|
// ../cli/src/lib/signals/inbox.ts
|
|
12671
12767
|
import fs38 from "node:fs";
|
|
12672
|
-
import
|
|
12768
|
+
import path43 from "node:path";
|
|
12673
12769
|
function metaPair(key, value) {
|
|
12674
12770
|
const name = typeof key === "string" ? key.trim() : "";
|
|
12675
12771
|
if (!name) return null;
|
|
@@ -12752,10 +12848,10 @@ function parse(file2, lenient = false) {
|
|
|
12752
12848
|
};
|
|
12753
12849
|
}
|
|
12754
12850
|
function freeName(dir, wanted) {
|
|
12755
|
-
const ext =
|
|
12851
|
+
const ext = path43.extname(wanted);
|
|
12756
12852
|
const stem = wanted.slice(0, wanted.length - ext.length);
|
|
12757
12853
|
let name = wanted;
|
|
12758
|
-
for (let n = 2; fs38.existsSync(
|
|
12854
|
+
for (let n = 2; fs38.existsSync(path43.join(dir, name)); n++) name = `${stem}-${n}${ext}`;
|
|
12759
12855
|
return name;
|
|
12760
12856
|
}
|
|
12761
12857
|
function readFolder(dir, lenient = false) {
|
|
@@ -12765,7 +12861,7 @@ function readFolder(dir, lenient = false) {
|
|
|
12765
12861
|
} catch {
|
|
12766
12862
|
return [];
|
|
12767
12863
|
}
|
|
12768
|
-
return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(
|
|
12864
|
+
return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".md")).map((entry) => parse(path43.join(dir, entry.name), lenient)).filter((signal2) => signal2 !== null);
|
|
12769
12865
|
}
|
|
12770
12866
|
function readInbox() {
|
|
12771
12867
|
const signals = readFolder(TRIAGE);
|
|
@@ -12785,7 +12881,7 @@ function writeSignal(incoming, importedAt, slug = "") {
|
|
|
12785
12881
|
contentKept: true,
|
|
12786
12882
|
relPath: ""
|
|
12787
12883
|
};
|
|
12788
|
-
const file2 =
|
|
12884
|
+
const file2 = path43.join(TRIAGE, freeName(TRIAGE, fileName(signal2.title, slug)));
|
|
12789
12885
|
fs38.writeFileSync(file2, serialize({ ...signal2, relPath: boardRel(file2) }));
|
|
12790
12886
|
return { ...signal2, relPath: boardRel(file2) };
|
|
12791
12887
|
}
|
|
@@ -12804,7 +12900,7 @@ function stamp2(file2, fields) {
|
|
|
12804
12900
|
function moveSignal(from, into, fields) {
|
|
12805
12901
|
if (!fs38.existsSync(from)) return "";
|
|
12806
12902
|
fs38.mkdirSync(into, { recursive: true });
|
|
12807
|
-
const at2 =
|
|
12903
|
+
const at2 = path43.join(into, freeName(into, path43.basename(from)));
|
|
12808
12904
|
fs38.renameSync(from, at2);
|
|
12809
12905
|
stamp2(at2, fields);
|
|
12810
12906
|
return boardRel(at2);
|
|
@@ -12814,10 +12910,10 @@ function archiveInboxItem(sourceId, cardId2) {
|
|
|
12814
12910
|
if (!found2) {
|
|
12815
12911
|
const ignored = readAllDismissed().find((signal2) => signal2.sourceId === sourceId);
|
|
12816
12912
|
if (!ignored) return { ok: false, error: `nothing waiting in triage is ${sourceId}` };
|
|
12817
|
-
stamp2(
|
|
12913
|
+
stamp2(path43.join(SIGNALS_DISMISSED, path43.basename(ignored.relPath)), { card_id: String(cardId2) });
|
|
12818
12914
|
return { ok: true, relPath: ignored.relPath, where: "dismissed" };
|
|
12819
12915
|
}
|
|
12820
|
-
const at2 = moveSignal(
|
|
12916
|
+
const at2 = moveSignal(path43.join(TRIAGE, path43.basename(found2.relPath)), SIGNALS_ARCHIVED, {
|
|
12821
12917
|
card_id: String(cardId2),
|
|
12822
12918
|
archived_at: formatStamp(/* @__PURE__ */ new Date())
|
|
12823
12919
|
});
|
|
@@ -12831,7 +12927,7 @@ var init_inbox = __esm({
|
|
|
12831
12927
|
init_sources();
|
|
12832
12928
|
init_paths();
|
|
12833
12929
|
init_yaml();
|
|
12834
|
-
boardRel = (file2) => rel(file2).split(
|
|
12930
|
+
boardRel = (file2) => rel(file2).split(path43.sep).join("/");
|
|
12835
12931
|
FIELDS = ["source_id", "title", "collected_at", "imported_at"];
|
|
12836
12932
|
META_LINE = /^\s+("(?:[^"\\]|\\.)*"|[^:]+):\s*(.*)$/;
|
|
12837
12933
|
slugOf = (said2) => said2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56).replace(/-+$/, "");
|
|
@@ -13039,7 +13135,7 @@ var init_studio_cards = __esm({
|
|
|
13039
13135
|
|
|
13040
13136
|
// ../cli/src/lib/readme.ts
|
|
13041
13137
|
import fs39 from "node:fs";
|
|
13042
|
-
import
|
|
13138
|
+
import path44 from "node:path";
|
|
13043
13139
|
function stripReadmeRefs(target) {
|
|
13044
13140
|
if (!fs39.existsSync(README)) return [];
|
|
13045
13141
|
const needle = target.kind === "group" ? `](${target.rel}/` : `](${target.rel})`;
|
|
@@ -13070,7 +13166,7 @@ function stripReadmeRefs(target) {
|
|
|
13070
13166
|
}
|
|
13071
13167
|
function addReadmeRef(id, title, relPath) {
|
|
13072
13168
|
if (!fs39.existsSync(README)) return false;
|
|
13073
|
-
const link2 = relPath.split(
|
|
13169
|
+
const link2 = relPath.split(path44.sep).join("/");
|
|
13074
13170
|
const bullet = `- [#${id} ${title}](${link2})`;
|
|
13075
13171
|
const heading = `## ${TASKS_HEADING}`;
|
|
13076
13172
|
let lines = fs39.readFileSync(README, "utf8").split("\n");
|
|
@@ -13097,8 +13193,8 @@ function addReadmeRef(id, title, relPath) {
|
|
|
13097
13193
|
}
|
|
13098
13194
|
function repointReadmeLink(id, oldRel, newRel, title) {
|
|
13099
13195
|
if (!fs39.existsSync(README)) return false;
|
|
13100
|
-
const oldLink = oldRel.split(
|
|
13101
|
-
const newLink = newRel.split(
|
|
13196
|
+
const oldLink = oldRel.split(path44.sep).join("/");
|
|
13197
|
+
const newLink = newRel.split(path44.sep).join("/");
|
|
13102
13198
|
const linkRe = new RegExp(`\\[#${id}\\b[^\\]]*\\]\\(${escapeRegex(oldLink)}\\)`);
|
|
13103
13199
|
const lines = fs39.readFileSync(README, "utf8").split("\n");
|
|
13104
13200
|
let changed = false;
|
|
@@ -13248,14 +13344,14 @@ function collectSources(sources2, card, host2) {
|
|
|
13248
13344
|
const active3 = /* @__PURE__ */ new Set();
|
|
13249
13345
|
const out = [];
|
|
13250
13346
|
const visit = (src, types, owner, partial = false) => {
|
|
13251
|
-
const
|
|
13347
|
+
const path89 = src.replace(/[?#].*$/, "");
|
|
13252
13348
|
let resolved2;
|
|
13253
13349
|
try {
|
|
13254
|
-
resolved2 = host2.resolve(
|
|
13350
|
+
resolved2 = host2.resolve(path89, owner);
|
|
13255
13351
|
} catch (error) {
|
|
13256
13352
|
if (owner !== card) return { key: null, error: why(error) };
|
|
13257
13353
|
if (!nodes.has(src)) {
|
|
13258
|
-
const node2 = { key: src, file: null, kind: kindAt(
|
|
13354
|
+
const node2 = { key: src, file: null, kind: kindAt(path89, types), error: why(error), problems: [], dependencies: /* @__PURE__ */ new Map(), aliases: /* @__PURE__ */ new Set([src]) };
|
|
13259
13355
|
nodes.set(src, node2);
|
|
13260
13356
|
out.push(node2);
|
|
13261
13357
|
}
|
|
@@ -13345,15 +13441,15 @@ var init_collect = __esm({
|
|
|
13345
13441
|
|
|
13346
13442
|
// ../cli/src/lib/dress-page.ts
|
|
13347
13443
|
import fs40 from "node:fs";
|
|
13348
|
-
import
|
|
13444
|
+
import path45 from "node:path";
|
|
13349
13445
|
function dressPage(file2) {
|
|
13350
|
-
const folder =
|
|
13446
|
+
const folder = path45.dirname(file2);
|
|
13351
13447
|
const html = fs40.readFileSync(file2, "utf8").replace(/<link\b[^>]*>/gi, (tag) => {
|
|
13352
13448
|
const href = /\bhref\s*=\s*["']?([^"'\s>]+)/i.exec(tag)?.[1];
|
|
13353
13449
|
if (!/\brel\s*=\s*["']?stylesheet/i.test(tag) || !href || /^[a-z][\w+.-]*:|^\/\//i.test(href)) return tag;
|
|
13354
|
-
const at3 =
|
|
13355
|
-
if (!at3.startsWith(folder +
|
|
13356
|
-
const css = fs40.readFileSync(at3, "utf8").replace(/url\(\s*(["']?)([^"')]+?)\1\s*\)/gi, (whole2, quote, src) => /^(?:[a-z][\w+.-]*:|\/|#)/i.test(src) ? whole2 : `url(${quote}${
|
|
13450
|
+
const at3 = path45.resolve(folder, href);
|
|
13451
|
+
if (!at3.startsWith(folder + path45.sep) || !fs40.existsSync(at3)) return tag;
|
|
13452
|
+
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})`);
|
|
13357
13453
|
return `<style>${css.replace(/\r?\n/g, " ").replace(/<\/style/gi, "<\\/style")}</style>`;
|
|
13358
13454
|
});
|
|
13359
13455
|
const at2 = /^\uFEFF?\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype\b[^>]*>)?/i.exec(html)[0].length;
|
|
@@ -13371,17 +13467,17 @@ var init_dress_page = __esm({
|
|
|
13371
13467
|
|
|
13372
13468
|
// ../cli/src/lib/preview-files.ts
|
|
13373
13469
|
import fs41 from "node:fs";
|
|
13374
|
-
import
|
|
13470
|
+
import path46 from "node:path";
|
|
13375
13471
|
function resolver(card, id) {
|
|
13376
|
-
const roots = [KANBAN,
|
|
13472
|
+
const roots = [KANBAN, path46.join(ASSETS, String(id))];
|
|
13377
13473
|
const real2 = (p2) => fs41.existsSync(p2) ? fs41.realpathSync(p2) : p2;
|
|
13378
|
-
const inside2 = (p2) => roots.some((root2) => p2.startsWith(real2(root2) +
|
|
13474
|
+
const inside2 = (p2) => roots.some((root2) => p2.startsWith(real2(root2) + path46.sep));
|
|
13379
13475
|
return (src, owner) => {
|
|
13380
13476
|
if (/^[a-z][\w+.-]*:/i.test(src) || src.startsWith("#") || src.startsWith("//")) return null;
|
|
13381
|
-
if (
|
|
13477
|
+
if (path46.isAbsolute(src)) throw new Error("an absolute path; name it relative to the file");
|
|
13382
13478
|
const held4 = /^\.assets\//.exec(src);
|
|
13383
|
-
const file2 = held4 ?
|
|
13384
|
-
if (!inside2(
|
|
13479
|
+
const file2 = held4 ? path46.resolve(ASSETS, src.slice(held4[0].length)) : path46.resolve(path46.dirname(owner), src);
|
|
13480
|
+
if (!inside2(path46.resolve(file2)) || fs41.existsSync(file2) && !inside2(fs41.realpathSync(file2))) throw new Error(`outside this card's files (${rel(KANBAN)}, .assets/${id}/)`);
|
|
13385
13481
|
if (!fs41.statSync(file2, { throwIfNoEntry: false })?.isFile()) throw new Error("no such file");
|
|
13386
13482
|
return { key: fs41.realpathSync(file2), file: file2 };
|
|
13387
13483
|
};
|
|
@@ -13427,7 +13523,7 @@ var init_preview_files = __esm({
|
|
|
13427
13523
|
|
|
13428
13524
|
// ../cli/src/lib/spec-contract.ts
|
|
13429
13525
|
import fs42 from "node:fs";
|
|
13430
|
-
import
|
|
13526
|
+
import path47 from "node:path";
|
|
13431
13527
|
function scanCardLines(lines, start = 0) {
|
|
13432
13528
|
const visible = lines.map(() => "");
|
|
13433
13529
|
let fence = null;
|
|
@@ -13462,8 +13558,8 @@ function snapshotSpecs() {
|
|
|
13462
13558
|
const out = /* @__PURE__ */ new Map();
|
|
13463
13559
|
if (!fs42.existsSync(TODO)) return out;
|
|
13464
13560
|
for (const file2 of walkMd(TODO)) {
|
|
13465
|
-
if (isLegacyRecurring(
|
|
13466
|
-
const id = idPrefix(
|
|
13561
|
+
if (isLegacyRecurring(path47.relative(TODO, file2))) continue;
|
|
13562
|
+
const id = idPrefix(path47.basename(file2) === "root.md" ? path47.basename(path47.dirname(file2)) : path47.basename(file2));
|
|
13467
13563
|
if (id !== null) out.set(file2, { id, text: fs42.readFileSync(file2, "utf8") });
|
|
13468
13564
|
}
|
|
13469
13565
|
return out;
|
|
@@ -13471,7 +13567,7 @@ function snapshotSpecs() {
|
|
|
13471
13567
|
function enclosingGroups(file2) {
|
|
13472
13568
|
const ids = [];
|
|
13473
13569
|
for (let root2 = enclosingGroupRoot(file2); root2; root2 = enclosingGroupRoot(root2)) {
|
|
13474
|
-
const id = idPrefix(
|
|
13570
|
+
const id = idPrefix(path47.basename(path47.dirname(root2)));
|
|
13475
13571
|
if (id !== null) ids.push(id);
|
|
13476
13572
|
}
|
|
13477
13573
|
return ids;
|
|
@@ -13647,8 +13743,8 @@ function setEnd(lines, at2) {
|
|
|
13647
13743
|
function inside(dir, name) {
|
|
13648
13744
|
try {
|
|
13649
13745
|
const root2 = fs42.realpathSync(dir);
|
|
13650
|
-
const real2 = fs42.realpathSync(
|
|
13651
|
-
return real2.startsWith(root2 +
|
|
13746
|
+
const real2 = fs42.realpathSync(path47.join(dir, name));
|
|
13747
|
+
return real2.startsWith(root2 + path47.sep) && fs42.statSync(real2).isFile() ? real2 : null;
|
|
13652
13748
|
} catch {
|
|
13653
13749
|
return null;
|
|
13654
13750
|
}
|
|
@@ -13666,7 +13762,7 @@ function variantsProblem(raw, src, id) {
|
|
|
13666
13762
|
if (files.length < 2 || !files.every((f2) => typeof f2 === "string" && f2)) return `variants needs at least two labels, each naming a file. ${shape}`;
|
|
13667
13763
|
if (!files.includes(src)) return `src="${src}" is not one of the variants. Set src to the version shown first.`;
|
|
13668
13764
|
if (id === void 0) return null;
|
|
13669
|
-
const dir =
|
|
13765
|
+
const dir = path47.join(ASSETS, String(id));
|
|
13670
13766
|
for (const f2 of files) {
|
|
13671
13767
|
const parts = f2.split("/");
|
|
13672
13768
|
if (parts.length !== 3 || parts[0] !== ".assets" || parts[1] !== String(id) || !inside(dir, parts[2])) {
|
|
@@ -13676,7 +13772,7 @@ function variantsProblem(raw, src, id) {
|
|
|
13676
13772
|
return null;
|
|
13677
13773
|
}
|
|
13678
13774
|
function compareProblem(attrs, id) {
|
|
13679
|
-
const dir =
|
|
13775
|
+
const dir = path47.join(ASSETS, String(id));
|
|
13680
13776
|
const src = (message) => ({ rule: "compare-src", message });
|
|
13681
13777
|
const shots = (message) => ({ rule: "compare-shots", message });
|
|
13682
13778
|
const json = (file2) => {
|
|
@@ -13724,7 +13820,7 @@ function compareProblem(attrs, id) {
|
|
|
13724
13820
|
}
|
|
13725
13821
|
function validateStoryboards(file2, id, text6) {
|
|
13726
13822
|
const errors = [];
|
|
13727
|
-
const dir =
|
|
13823
|
+
const dir = path47.join(ASSETS, String(id));
|
|
13728
13824
|
for (const [tag, tagOf, rule, fix] of [
|
|
13729
13825
|
["Storyboard", storyboardTag, "storyboard-src", "Write the JSON there or fix the path."],
|
|
13730
13826
|
["Studio", studioTag, "studio-src", "Write it with `akb raw studio diagram <studio id> <card id>` or fix the path."]
|
|
@@ -13759,13 +13855,13 @@ var init_spec_contract = __esm({
|
|
|
13759
13855
|
|
|
13760
13856
|
// ../cli/src/lib/reconcile.ts
|
|
13761
13857
|
import fs43 from "node:fs";
|
|
13762
|
-
import
|
|
13858
|
+
import path48 from "node:path";
|
|
13763
13859
|
function liveIds() {
|
|
13764
13860
|
const ids = /* @__PURE__ */ new Set();
|
|
13765
13861
|
for (const file2 of walkMd(TODO)) {
|
|
13766
|
-
const base =
|
|
13862
|
+
const base = path48.basename(file2);
|
|
13767
13863
|
if (base === "README.md") continue;
|
|
13768
|
-
const id = base === "root.md" ? idPrefix(
|
|
13864
|
+
const id = base === "root.md" ? idPrefix(path48.basename(path48.dirname(file2))) : idPrefix(base);
|
|
13769
13865
|
if (id != null) ids.add(id);
|
|
13770
13866
|
}
|
|
13771
13867
|
return ids;
|
|
@@ -13773,16 +13869,16 @@ function liveIds() {
|
|
|
13773
13869
|
function indexableCards() {
|
|
13774
13870
|
const out = [];
|
|
13775
13871
|
for (const dir of walkDirs(TODO)) {
|
|
13776
|
-
const id = idPrefix(
|
|
13777
|
-
if (id != null && fs43.existsSync(
|
|
13778
|
-
out.push({ id, rel:
|
|
13872
|
+
const id = idPrefix(path48.basename(dir));
|
|
13873
|
+
if (id != null && fs43.existsSync(path48.join(dir, "root.md"))) {
|
|
13874
|
+
out.push({ id, rel: path48.join(path48.relative(TODO, dir), "root.md").split(path48.sep).join("/") });
|
|
13779
13875
|
}
|
|
13780
13876
|
}
|
|
13781
13877
|
for (const file2 of walkMd(TODO)) {
|
|
13782
|
-
const base =
|
|
13878
|
+
const base = path48.basename(file2);
|
|
13783
13879
|
if (base === "README.md" || base === "root.md") continue;
|
|
13784
|
-
const relTODO =
|
|
13785
|
-
const segs = relTODO.split(
|
|
13880
|
+
const relTODO = path48.relative(TODO, file2);
|
|
13881
|
+
const segs = relTODO.split(path48.sep);
|
|
13786
13882
|
if (segs.length !== 1) continue;
|
|
13787
13883
|
const id = idPrefix(base);
|
|
13788
13884
|
if (id != null) out.push({ id, rel: segs.join("/") });
|
|
@@ -13800,13 +13896,13 @@ function readmeComplaints(fix) {
|
|
|
13800
13896
|
const id = Number(m[1]);
|
|
13801
13897
|
const linkPath = m[2];
|
|
13802
13898
|
indexed.add(id);
|
|
13803
|
-
if (fs43.existsSync(
|
|
13899
|
+
if (fs43.existsSync(path48.join(TODO, linkPath))) continue;
|
|
13804
13900
|
const found2 = locate2(id);
|
|
13805
13901
|
if (!found2) {
|
|
13806
13902
|
said2.push(`README links #${id} \u2192 ${linkPath}, but no card with that id exists (removed by hand?). Drop the entry or restore the file.`);
|
|
13807
13903
|
continue;
|
|
13808
13904
|
}
|
|
13809
|
-
const want = (found2.kind === "group" ?
|
|
13905
|
+
const want = (found2.kind === "group" ? path48.join(found2.rel, "root.md") : found2.rel).split(path48.sep).join("/");
|
|
13810
13906
|
if (want === linkPath) continue;
|
|
13811
13907
|
if (!fix) {
|
|
13812
13908
|
said2.push(`README links #${id} \u2192 ${linkPath}, which isn't there any more; the card is at ${want}.`);
|
|
@@ -13828,9 +13924,9 @@ function crossRefComplaints() {
|
|
|
13828
13924
|
const said2 = [];
|
|
13829
13925
|
const live = liveIds();
|
|
13830
13926
|
for (const file2 of walkMd(TODO)) {
|
|
13831
|
-
const base =
|
|
13927
|
+
const base = path48.basename(file2);
|
|
13832
13928
|
if (base === "README.md") continue;
|
|
13833
|
-
const ownerId = base === "root.md" ? idPrefix(
|
|
13929
|
+
const ownerId = base === "root.md" ? idPrefix(path48.basename(path48.dirname(file2))) : idPrefix(base);
|
|
13834
13930
|
if (ownerId == null) continue;
|
|
13835
13931
|
const { meta } = parseFrontmatter(fs43.readFileSync(file2, "utf8"));
|
|
13836
13932
|
if (!meta) continue;
|
|
@@ -13862,7 +13958,7 @@ var init_reconcile = __esm({
|
|
|
13862
13958
|
|
|
13863
13959
|
// ../cli/src/commands/card.ts
|
|
13864
13960
|
import fs44 from "node:fs";
|
|
13865
|
-
import
|
|
13961
|
+
import path49 from "node:path";
|
|
13866
13962
|
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>") {
|
|
13867
13963
|
return [
|
|
13868
13964
|
summary2,
|
|
@@ -13953,9 +14049,9 @@ function cmdCreate(opts) {
|
|
|
13953
14049
|
const start = opts.id;
|
|
13954
14050
|
const slug = slugify(opts.slug !== void 0 ? opts.slug : title);
|
|
13955
14051
|
const fileRel = `${start}-${slug}.md`;
|
|
13956
|
-
const file2 =
|
|
14052
|
+
const file2 = path49.join(TODO, fileRel);
|
|
13957
14053
|
const held4 = locate2(start) ?? locateArchived(start);
|
|
13958
|
-
if (held4 &&
|
|
14054
|
+
if (held4 && path49.basename(held4.target) === `${start}-${slug}.md`) {
|
|
13959
14055
|
say(start);
|
|
13960
14056
|
say(` ${rel(held4.target)} was already written`);
|
|
13961
14057
|
return { id: start, ids: [start], title, file: rel(held4.target), indexed: false };
|
|
@@ -14018,7 +14114,7 @@ function cmdUpdate(id, flags) {
|
|
|
14018
14114
|
if (creating) die(creating, { kind: "card-being-created", id });
|
|
14019
14115
|
const found2 = locate2(id);
|
|
14020
14116
|
if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
|
|
14021
|
-
const file2 = found2.kind === "group" ?
|
|
14117
|
+
const file2 = found2.kind === "group" ? path49.join(found2.target, "root.md") : found2.target;
|
|
14022
14118
|
const { meta, body } = parseFrontmatter(fs44.readFileSync(file2, "utf8"));
|
|
14023
14119
|
if (!meta) die(`${rel(file2)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
|
|
14024
14120
|
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");
|
|
@@ -14093,26 +14189,26 @@ function cmdUpdate(id, flags) {
|
|
|
14093
14189
|
meta.status = "todo";
|
|
14094
14190
|
changes.push("status\u2192todo (open questions)");
|
|
14095
14191
|
}
|
|
14096
|
-
const curRel =
|
|
14192
|
+
const curRel = path49.relative(TODO, file2);
|
|
14097
14193
|
const isSubtask = found2.kind === "file" && enclosingGroupRoot(file2) !== null;
|
|
14098
|
-
let base =
|
|
14194
|
+
let base = path49.basename(file2);
|
|
14099
14195
|
if (flags.slug !== void 0) {
|
|
14100
14196
|
if (found2.kind === "group") die("renaming a group root by script is not supported");
|
|
14101
14197
|
base = `${id}-${slugify(flags.slug)}.md`;
|
|
14102
14198
|
}
|
|
14103
|
-
const destRel =
|
|
14104
|
-
const dest =
|
|
14199
|
+
const destRel = path49.join(path49.dirname(curRel), base);
|
|
14200
|
+
const dest = path49.join(TODO, destRel);
|
|
14105
14201
|
const moving = dest !== file2;
|
|
14106
14202
|
if (moving && fs44.existsSync(dest)) die(`${rel(dest)} already exists`);
|
|
14107
14203
|
fs44.writeFileSync(file2, serializeFrontmatter(meta) + "\n" + body);
|
|
14108
14204
|
if (moving) fs44.renameSync(file2, dest);
|
|
14109
14205
|
if (isSubtask) {
|
|
14110
14206
|
if (moving || changes.includes("title")) repointReadmeLink(id, curRel, destRel, meta.title);
|
|
14111
|
-
if (moving) changes.push(`renamed \u2192 ${destRel.split(
|
|
14207
|
+
if (moving) changes.push(`renamed \u2192 ${destRel.split(path49.sep).join("/")}`);
|
|
14112
14208
|
} else if (moving) {
|
|
14113
14209
|
stripReadmeRefs({ kind: "file", rel: curRel });
|
|
14114
14210
|
addReadmeRef(id, meta.title, destRel);
|
|
14115
|
-
changes.push(`renamed \u2192 ${destRel.split(
|
|
14211
|
+
changes.push(`renamed \u2192 ${destRel.split(path49.sep).join("/")}`);
|
|
14116
14212
|
} else if (changes.includes("title")) {
|
|
14117
14213
|
stripReadmeRefs({ kind: "file", rel: curRel });
|
|
14118
14214
|
addReadmeRef(id, meta.title, curRel);
|
|
@@ -14124,7 +14220,7 @@ function cmdUpdateQuestions(id, input) {
|
|
|
14124
14220
|
const ops = readQuestionOps(input.ops ?? []);
|
|
14125
14221
|
const found2 = locate2(id);
|
|
14126
14222
|
if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
|
|
14127
|
-
const file2 = found2.kind === "group" ?
|
|
14223
|
+
const file2 = found2.kind === "group" ? path49.join(found2.target, "root.md") : found2.target;
|
|
14128
14224
|
const { meta, body } = parseFrontmatter(fs44.readFileSync(file2, "utf8"));
|
|
14129
14225
|
if (!meta) die(`${rel(file2)} has no frontmatter \u2014 recreate it with \`akb raw create\``);
|
|
14130
14226
|
for (const op of ops) {
|
|
@@ -14367,7 +14463,7 @@ var init_scheduled = __esm({
|
|
|
14367
14463
|
|
|
14368
14464
|
// ../cli/src/lib/card-age.ts
|
|
14369
14465
|
import fs46 from "node:fs";
|
|
14370
|
-
import
|
|
14466
|
+
import path50 from "node:path";
|
|
14371
14467
|
function staleAfterIn(config) {
|
|
14372
14468
|
const days = Number(LINE.exec(config)?.[1]);
|
|
14373
14469
|
return Number.isInteger(days) && days > 0 ? days : STALE_AFTER_DEFAULT;
|
|
@@ -14377,14 +14473,14 @@ function staleAfter() {
|
|
|
14377
14473
|
return staleAfterIn(fs46.readFileSync(CONFIG, "utf8"));
|
|
14378
14474
|
}
|
|
14379
14475
|
function todoPathspec(top) {
|
|
14380
|
-
const from =
|
|
14381
|
-
if (!from || from.startsWith("..") ||
|
|
14382
|
-
return from.split(
|
|
14476
|
+
const from = path50.relative(real(top), real(TODO));
|
|
14477
|
+
if (!from || from.startsWith("..") || path50.isAbsolute(from)) return null;
|
|
14478
|
+
return from.split(path50.sep).join("/");
|
|
14383
14479
|
}
|
|
14384
14480
|
function cardFile(spec, printed) {
|
|
14385
14481
|
const p2 = unquotePath(printed);
|
|
14386
14482
|
if (!p2.startsWith(`${spec}/`)) return null;
|
|
14387
|
-
return
|
|
14483
|
+
return path50.join(TODO, ...p2.slice(spec.length + 1).split("/"));
|
|
14388
14484
|
}
|
|
14389
14485
|
function dirtyCards(top, spec) {
|
|
14390
14486
|
const out = git(["status", "--porcelain", "--untracked-files=all", "--", spec], top);
|
|
@@ -14433,7 +14529,7 @@ var init_card_age = __esm({
|
|
|
14433
14529
|
try {
|
|
14434
14530
|
return fs46.realpathSync(p2);
|
|
14435
14531
|
} catch {
|
|
14436
|
-
return
|
|
14532
|
+
return path50.resolve(p2);
|
|
14437
14533
|
}
|
|
14438
14534
|
};
|
|
14439
14535
|
unquotePath = (line) => {
|
|
@@ -14468,7 +14564,7 @@ var init_card_holds = __esm({
|
|
|
14468
14564
|
|
|
14469
14565
|
// ../cli/src/commands/list.ts
|
|
14470
14566
|
import fs47 from "node:fs";
|
|
14471
|
-
import
|
|
14567
|
+
import path51 from "node:path";
|
|
14472
14568
|
function summaryLine(body) {
|
|
14473
14569
|
const lines = body.split("\n");
|
|
14474
14570
|
let i = 0;
|
|
@@ -14484,12 +14580,12 @@ function summaryLine(body) {
|
|
|
14484
14580
|
function openRows() {
|
|
14485
14581
|
const rows = [];
|
|
14486
14582
|
for (const file2 of walkMd(TODO)) {
|
|
14487
|
-
const base =
|
|
14583
|
+
const base = path51.basename(file2);
|
|
14488
14584
|
if (base === "README.md") continue;
|
|
14489
14585
|
const isRoot = base === "root.md";
|
|
14490
|
-
const id = isRoot ? idPrefix(
|
|
14586
|
+
const id = isRoot ? idPrefix(path51.basename(path51.dirname(file2))) : idPrefix(base);
|
|
14491
14587
|
if (id == null) continue;
|
|
14492
|
-
if (isLegacyRecurring(
|
|
14588
|
+
if (isLegacyRecurring(path51.relative(TODO, file2))) continue;
|
|
14493
14589
|
const { meta, body } = parseFrontmatter(fs47.readFileSync(file2, "utf8"));
|
|
14494
14590
|
rows.push({
|
|
14495
14591
|
id,
|
|
@@ -14534,12 +14630,12 @@ function archivedFiles() {
|
|
|
14534
14630
|
const files = /* @__PURE__ */ new Map();
|
|
14535
14631
|
if (!fs47.existsSync(ARCHIVE)) return files;
|
|
14536
14632
|
for (const file2 of walkMd(ARCHIVE)) {
|
|
14537
|
-
const id = idPrefix(
|
|
14633
|
+
const id = idPrefix(path51.basename(file2));
|
|
14538
14634
|
if (id !== null) files.set(id, file2);
|
|
14539
14635
|
}
|
|
14540
14636
|
for (const dir of walkDirs(ARCHIVE)) {
|
|
14541
|
-
const id = idPrefix(
|
|
14542
|
-
const root2 =
|
|
14637
|
+
const id = idPrefix(path51.basename(dir));
|
|
14638
|
+
const root2 = path51.join(dir, "root.md");
|
|
14543
14639
|
if (id !== null && fs47.existsSync(root2)) files.set(id, root2);
|
|
14544
14640
|
}
|
|
14545
14641
|
return files;
|
|
@@ -14650,10 +14746,10 @@ var init_list = __esm({
|
|
|
14650
14746
|
});
|
|
14651
14747
|
|
|
14652
14748
|
// ../cli/src/lib/agent/creation-lock.ts
|
|
14653
|
-
import
|
|
14749
|
+
import path52 from "node:path";
|
|
14654
14750
|
function withCreationLock(fn2) {
|
|
14655
14751
|
if (depth2) return fn2();
|
|
14656
|
-
return withLock(
|
|
14752
|
+
return withLock(path52.join(SESSIONS_DIR, "creation.lock"), "changing card creation", () => {
|
|
14657
14753
|
depth2++;
|
|
14658
14754
|
try {
|
|
14659
14755
|
return fn2();
|
|
@@ -14690,11 +14786,11 @@ var init_group_close = __esm({
|
|
|
14690
14786
|
|
|
14691
14787
|
// ../cli/src/commands/remove.ts
|
|
14692
14788
|
import fs49 from "node:fs";
|
|
14693
|
-
import
|
|
14789
|
+
import path53 from "node:path";
|
|
14694
14790
|
function leavingIds(id, found2) {
|
|
14695
14791
|
const ids = /* @__PURE__ */ new Set([id]);
|
|
14696
14792
|
if (found2.kind === "group") {
|
|
14697
|
-
const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) =>
|
|
14793
|
+
const names3 = [...walkMd(found2.target), ...walkDirs(found2.target)].map((f2) => path53.basename(f2));
|
|
14698
14794
|
for (const name of names3) {
|
|
14699
14795
|
const n = idPrefix(name);
|
|
14700
14796
|
if (n !== null) ids.add(n);
|
|
@@ -14708,7 +14804,7 @@ function findMentions(ids) {
|
|
|
14708
14804
|
for (const dir of [TODO, MEMORY]) {
|
|
14709
14805
|
if (!fs49.existsSync(dir)) continue;
|
|
14710
14806
|
for (const file2 of walkMd(dir)) {
|
|
14711
|
-
if (
|
|
14807
|
+
if (path53.basename(file2) === "README.md") continue;
|
|
14712
14808
|
const lines = fs49.readFileSync(file2, "utf8").split("\n");
|
|
14713
14809
|
const fmEnd = frontmatterEnd(lines);
|
|
14714
14810
|
lines.forEach((line, i) => {
|
|
@@ -14725,12 +14821,12 @@ function findMentions(ids) {
|
|
|
14725
14821
|
return hits;
|
|
14726
14822
|
}
|
|
14727
14823
|
function leavingCards(id, found2) {
|
|
14728
|
-
const own = found2.kind === "group" ?
|
|
14824
|
+
const own = found2.kind === "group" ? path53.join(found2.target, "root.md") : found2.target;
|
|
14729
14825
|
const cards = [{ id, file: own }];
|
|
14730
14826
|
if (found2.kind !== "group") return cards;
|
|
14731
14827
|
for (const file2 of walkMd(found2.target)) {
|
|
14732
14828
|
if (file2 === own) continue;
|
|
14733
|
-
const n = idPrefix(
|
|
14829
|
+
const n = idPrefix(path53.basename(file2));
|
|
14734
14830
|
if (n !== null) cards.push({ id: n, file: file2 });
|
|
14735
14831
|
}
|
|
14736
14832
|
return cards;
|
|
@@ -14771,7 +14867,7 @@ function removeCard(id, metric, options) {
|
|
|
14771
14867
|
const found2 = locate2(id);
|
|
14772
14868
|
if (!found2) die(`no task with id ${id} under ${rel(TODO)}`, { kind: "card-not-found", id });
|
|
14773
14869
|
const dest = options.cleanupDiscarded && locateArchived(id) ? null : archiveDest(found2);
|
|
14774
|
-
const cardFile3 = found2.kind === "group" ?
|
|
14870
|
+
const cardFile3 = found2.kind === "group" ? path53.join(found2.target, "root.md") : found2.target;
|
|
14775
14871
|
const cardText = fs49.existsSync(cardFile3) ? fs49.readFileSync(cardFile3, "utf8") : "";
|
|
14776
14872
|
const { meta: cardMeta3 } = parseFrontmatter(cardText);
|
|
14777
14873
|
const alsoRemoved = found2.kind === "group" ? walkMd(found2.target).filter((f2) => f2 !== cardFile3).map((f2) => rel(f2)).sort() : [];
|
|
@@ -14855,7 +14951,7 @@ function removeCard(id, metric, options) {
|
|
|
14855
14951
|
};
|
|
14856
14952
|
}
|
|
14857
14953
|
function closeGroup(rootFile) {
|
|
14858
|
-
const rootId = idPrefix(
|
|
14954
|
+
const rootId = idPrefix(path53.basename(path53.dirname(rootFile)));
|
|
14859
14955
|
if (rootId === null) return null;
|
|
14860
14956
|
if (runnerProject(KANBAN)) return null;
|
|
14861
14957
|
if (!groupCloses(rootFile)) return null;
|
|
@@ -14919,7 +15015,7 @@ function cleanupDiscardedCards(sessionId) {
|
|
|
14919
15015
|
if (card.pending) throw new Error(`Discarding #${card.id} did not finish. Retry the discard.`);
|
|
14920
15016
|
while (locate2(card.id)) cmdRemove(card.id, "rejected", { discard: true, cleanupDiscarded: true });
|
|
14921
15017
|
dropCrossRefs(card.id);
|
|
14922
|
-
stripReadmeRefs({ kind: "file", rel:
|
|
15018
|
+
stripReadmeRefs({ kind: "file", rel: path53.relative(TODO, path53.resolve(REPO_ROOT, card.path)).split(path53.sep).join("/") });
|
|
14923
15019
|
}
|
|
14924
15020
|
return discarded.map((c2) => c2.id);
|
|
14925
15021
|
});
|
|
@@ -14927,7 +15023,7 @@ function cleanupDiscardedCards(sessionId) {
|
|
|
14927
15023
|
function recoveredArchiveHandoff(id, source2) {
|
|
14928
15024
|
const found2 = locateArchived(id);
|
|
14929
15025
|
if (!found2) throw new Error(`No archived card #${id} was found.`);
|
|
14930
|
-
const file2 = found2.kind === "group" ?
|
|
15026
|
+
const file2 = found2.kind === "group" ? path53.join(found2.target, "root.md") : found2.target;
|
|
14931
15027
|
const { meta } = parseFrontmatter(fs49.readFileSync(file2, "utf8"));
|
|
14932
15028
|
stripReadmeRefs(source2 ?? found2);
|
|
14933
15029
|
const root2 = source2?.kind === "file" ? enclosingGroupRoot(source2.target) : null;
|
|
@@ -15006,7 +15102,7 @@ var init_agent_file = __esm({
|
|
|
15006
15102
|
|
|
15007
15103
|
// ../cli/src/lib/agent/studio-shared.ts
|
|
15008
15104
|
import fs50 from "node:fs";
|
|
15009
|
-
import
|
|
15105
|
+
import path54 from "node:path";
|
|
15010
15106
|
function studioFiles(studio) {
|
|
15011
15107
|
const flow = cloudFlows().find((f2) => f2.def.id === studio || f2.cloudId === studio);
|
|
15012
15108
|
if (flow) return flow.files;
|
|
@@ -15022,7 +15118,7 @@ function readStudioMemory(studio) {
|
|
|
15022
15118
|
}
|
|
15023
15119
|
return names3.flatMap((name) => {
|
|
15024
15120
|
try {
|
|
15025
|
-
return [{ name, text: fs50.readFileSync(
|
|
15121
|
+
return [{ name, text: fs50.readFileSync(path54.join(dir, name), "utf8").trim() }];
|
|
15026
15122
|
} catch {
|
|
15027
15123
|
return [];
|
|
15028
15124
|
}
|
|
@@ -15063,7 +15159,7 @@ var init_studio_shared = __esm({
|
|
|
15063
15159
|
init_command();
|
|
15064
15160
|
init_cloud_studios();
|
|
15065
15161
|
sharedFiles = (files) => Object.keys(files).filter((f2) => f2.startsWith(SHARED_DIR) && f2 !== RULES_FILE).sort();
|
|
15066
|
-
studioMemoryDir = (studio) =>
|
|
15162
|
+
studioMemoryDir = (studio) => path54.join(MEMORY, STUDIO_MEMORY_DIR, studio);
|
|
15067
15163
|
fileLine = (studio, file2) => `- \`${file2}\` \u2014 \`${rawMove(`file ${studio} ${file2}`)}\``;
|
|
15068
15164
|
studioHoldsAgent = (studio, agent) => !!studio && Object.keys(studioFiles(studio) ?? {}).some((f2) => f2.startsWith(`agents/${agent}/`));
|
|
15069
15165
|
}
|
|
@@ -15117,7 +15213,7 @@ var init_bundled2 = __esm({
|
|
|
15117
15213
|
|
|
15118
15214
|
// ../cli/src/lib/memories.ts
|
|
15119
15215
|
import fs51 from "node:fs";
|
|
15120
|
-
import
|
|
15216
|
+
import path55 from "node:path";
|
|
15121
15217
|
function readMemory(text6, builtIn, folder) {
|
|
15122
15218
|
const { meta, body } = splitFrontmatter(text6);
|
|
15123
15219
|
if (meta === null) return null;
|
|
@@ -15137,7 +15233,7 @@ function readMemory(text6, builtIn, folder) {
|
|
|
15137
15233
|
rules: body.trim(),
|
|
15138
15234
|
text: text6,
|
|
15139
15235
|
builtIn,
|
|
15140
|
-
dir:
|
|
15236
|
+
dir: path55.join(MEMORY, folder)
|
|
15141
15237
|
};
|
|
15142
15238
|
}
|
|
15143
15239
|
function globalMemories() {
|
|
@@ -15153,7 +15249,7 @@ function globalMemories() {
|
|
|
15153
15249
|
}
|
|
15154
15250
|
for (const name of folders2) {
|
|
15155
15251
|
if (name in BUNDLED_MEMORY_FILES || name === RESERVED_MEMORY_DIR || name === STUDIO_MEMORY_DIR) continue;
|
|
15156
|
-
const file2 =
|
|
15252
|
+
const file2 = path55.join(MEMORY, name, GLOBAL_MEMORY_FILE);
|
|
15157
15253
|
if (!fs51.existsSync(file2)) continue;
|
|
15158
15254
|
const memory = readMemory(fs51.readFileSync(file2, "utf8"), false, name);
|
|
15159
15255
|
if (memory) out.push(memory);
|
|
@@ -15212,7 +15308,7 @@ var init_memory_file = __esm({
|
|
|
15212
15308
|
// ../cli/src/commands/inspect.ts
|
|
15213
15309
|
import fs52 from "node:fs";
|
|
15214
15310
|
import os4 from "node:os";
|
|
15215
|
-
import
|
|
15311
|
+
import path56 from "node:path";
|
|
15216
15312
|
function cmdInspect(id) {
|
|
15217
15313
|
const findings = [];
|
|
15218
15314
|
const unavailable = [];
|
|
@@ -15237,7 +15333,7 @@ function cmdInspect(id) {
|
|
|
15237
15333
|
}
|
|
15238
15334
|
const found2 = locate2(id) ?? locateArchived(id);
|
|
15239
15335
|
if (!found2) return die(`no task with id ${id}`, { kind: "card-not-found", id });
|
|
15240
|
-
const file2 = found2.kind === "group" ?
|
|
15336
|
+
const file2 = found2.kind === "group" ? path56.join(found2.target, "root.md") : found2.target;
|
|
15241
15337
|
let card = null;
|
|
15242
15338
|
try {
|
|
15243
15339
|
const { meta, body } = parseFrontmatter(fs52.readFileSync(file2, "utf8"));
|
|
@@ -15247,14 +15343,14 @@ function cmdInspect(id) {
|
|
|
15247
15343
|
findings.push({ source: "card", message: String(error) });
|
|
15248
15344
|
unavailable.push("card");
|
|
15249
15345
|
}
|
|
15250
|
-
const progress = read4("previews",
|
|
15346
|
+
const progress = read4("previews", path56.join(BOARD_STATE, "previews", `${id}.json`), {});
|
|
15251
15347
|
const store = read4("runs", SESSIONS, {});
|
|
15252
15348
|
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 })), []);
|
|
15253
15349
|
const records = [];
|
|
15254
|
-
const directory =
|
|
15350
|
+
const directory = path56.join(KANBAN, "deliveries");
|
|
15255
15351
|
try {
|
|
15256
15352
|
for (const name of fs52.readdirSync(directory).filter((name2) => name2.endsWith(".json"))) {
|
|
15257
|
-
const held5 = read4("delivery",
|
|
15353
|
+
const held5 = read4("delivery", path56.join(directory, name), null);
|
|
15258
15354
|
if (held5?.cardId === id) records.push(held5);
|
|
15259
15355
|
}
|
|
15260
15356
|
} catch (error) {
|
|
@@ -15266,7 +15362,7 @@ function cmdInspect(id) {
|
|
|
15266
15362
|
records.push(...fact("delivery", () => (store.deliveries ?? []).filter((held5) => held5.cardId === id), []));
|
|
15267
15363
|
const held4 = [...new Map(records.map((held5) => [held5.deliveryId, held5])).values()].sort((a2, b2) => b2.startedAt - a2.startedAt)[0];
|
|
15268
15364
|
const job = executionOf()?.job;
|
|
15269
|
-
const checkpoint = job ? read4("recovery",
|
|
15365
|
+
const checkpoint = job ? read4("recovery", path56.join(process.env.WILDCRANE_HOME || os4.homedir() + "/.wildcrane", "checkpoints", `${encodeURIComponent(job)}.json`), null) : null;
|
|
15270
15366
|
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);
|
|
15271
15367
|
const recovery = fact("recovery", () => checkpoint ? { pendingOperations: checkpoint.pending ?? [], submitted: checkpoint.submitted ?? null } : null, null);
|
|
15272
15368
|
const result = {
|
|
@@ -15276,7 +15372,7 @@ function cmdInspect(id) {
|
|
|
15276
15372
|
agent,
|
|
15277
15373
|
currentStageId: p2.currentStageId,
|
|
15278
15374
|
stages: p2.stages.map(({ id: id2, status, version }) => ({ id: id2, status, version })),
|
|
15279
|
-
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) => !
|
|
15375
|
+
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
|
|
15280
15376
|
})), []),
|
|
15281
15377
|
delivery,
|
|
15282
15378
|
runs,
|
|
@@ -15367,7 +15463,7 @@ var init_ops = __esm({
|
|
|
15367
15463
|
|
|
15368
15464
|
// ../cli/src/lib/view/stamp.ts
|
|
15369
15465
|
import fs53 from "node:fs";
|
|
15370
|
-
import
|
|
15466
|
+
import path57 from "node:path";
|
|
15371
15467
|
function boardStamp() {
|
|
15372
15468
|
const parts = [];
|
|
15373
15469
|
for (const dir of [TODO, MEMORY, ASSETS]) walk(dir, parts, 0);
|
|
@@ -15385,7 +15481,7 @@ function walk(dir, parts, depth3) {
|
|
|
15385
15481
|
return;
|
|
15386
15482
|
}
|
|
15387
15483
|
for (const entry of entries.sort((a2, b2) => a2.name.localeCompare(b2.name))) {
|
|
15388
|
-
const full =
|
|
15484
|
+
const full = path57.join(dir, entry.name);
|
|
15389
15485
|
if (entry.isDirectory()) walk(full, parts, depth3 + 1);
|
|
15390
15486
|
else stamp3(full, parts);
|
|
15391
15487
|
}
|
|
@@ -15425,7 +15521,7 @@ var init_contract = __esm({
|
|
|
15425
15521
|
|
|
15426
15522
|
// ../cli/src/lib/board/revision.ts
|
|
15427
15523
|
import fs54 from "node:fs";
|
|
15428
|
-
import
|
|
15524
|
+
import path58 from "node:path";
|
|
15429
15525
|
function revisionOf(text6) {
|
|
15430
15526
|
let h3 = 2166136261;
|
|
15431
15527
|
for (let i = 0; i < text6.length; i++) {
|
|
@@ -15437,7 +15533,7 @@ function revisionOf(text6) {
|
|
|
15437
15533
|
function cardFile2(id) {
|
|
15438
15534
|
const found2 = locate2(id);
|
|
15439
15535
|
if (!found2) return null;
|
|
15440
|
-
return found2.kind === "group" ?
|
|
15536
|
+
return found2.kind === "group" ? path58.join(found2.target, "root.md") : found2.target;
|
|
15441
15537
|
}
|
|
15442
15538
|
function cardRevision(id) {
|
|
15443
15539
|
const file2 = cardFile2(id);
|
|
@@ -15647,13 +15743,13 @@ var init_board = __esm({
|
|
|
15647
15743
|
|
|
15648
15744
|
// ../cli/src/lib/plans.ts
|
|
15649
15745
|
import fs55 from "node:fs";
|
|
15650
|
-
import
|
|
15746
|
+
import path59 from "node:path";
|
|
15651
15747
|
function planFile(rel2) {
|
|
15652
15748
|
if (!/^plans\/(archive\/)?[^/\\]+\.md$/.test(rel2)) return null;
|
|
15653
15749
|
const dir = isArchivedPlan(rel2) ? PLANS_ARCHIVE : PLANS;
|
|
15654
15750
|
const name = rel2.replace(/^plans\/(archive\/)?/, "");
|
|
15655
15751
|
if (!name || name.includes("/") || !name.endsWith(".md")) return null;
|
|
15656
|
-
return
|
|
15752
|
+
return path59.join(dir, name);
|
|
15657
15753
|
}
|
|
15658
15754
|
function readPlan(rel2) {
|
|
15659
15755
|
const file2 = planFile(rel2);
|
|
@@ -15687,14 +15783,14 @@ function renamedPlan(rel2) {
|
|
|
15687
15783
|
}
|
|
15688
15784
|
for (const n of names3) {
|
|
15689
15785
|
if (!n.startsWith(`${id}-`) || !n.endsWith(".md")) continue;
|
|
15690
|
-
found2.push({ rel: `${prefix}${n}`, at: fs55.statSync(
|
|
15786
|
+
found2.push({ rel: `${prefix}${n}`, at: fs55.statSync(path59.join(dir, n)).mtimeMs });
|
|
15691
15787
|
}
|
|
15692
15788
|
}
|
|
15693
15789
|
if (!found2.length) return null;
|
|
15694
15790
|
return found2.sort((a2, b2) => b2.at - a2.at)[0].rel;
|
|
15695
15791
|
}
|
|
15696
15792
|
function planFromText(text6) {
|
|
15697
|
-
const local = `${
|
|
15793
|
+
const local = `${path59.dirname(PLANS)}/`;
|
|
15698
15794
|
if (text6.startsWith(local)) text6 = text6.slice(local.length);
|
|
15699
15795
|
if (text6.startsWith(`${KANBAN}/`)) text6 = text6.slice(KANBAN.length + 1);
|
|
15700
15796
|
const here = `${boardPath()}/`;
|
|
@@ -15776,7 +15872,7 @@ var init_own_cost = __esm({
|
|
|
15776
15872
|
|
|
15777
15873
|
// ../cli/src/lib/agent/pictures.ts
|
|
15778
15874
|
import fs56 from "node:fs";
|
|
15779
|
-
import
|
|
15875
|
+
import path60 from "node:path";
|
|
15780
15876
|
function claimRunPictures(box2, sessionId, names3 = []) {
|
|
15781
15877
|
if (!box2 || !freeBox(box2) || names3.length === 0) return [];
|
|
15782
15878
|
const from = pictureBox(box2);
|
|
@@ -15787,7 +15883,7 @@ function claimRunPictures(box2, sessionId, names3 = []) {
|
|
|
15787
15883
|
} catch {
|
|
15788
15884
|
return [];
|
|
15789
15885
|
}
|
|
15790
|
-
return names3.filter(pictureName).map((name) =>
|
|
15886
|
+
return names3.filter(pictureName).map((name) => path60.join(to, name)).filter((file2) => fs56.existsSync(file2));
|
|
15791
15887
|
}
|
|
15792
15888
|
function returnRunPictures(sessionId, box2) {
|
|
15793
15889
|
if (!box2 || !boxId(box2)) return;
|
|
@@ -15803,7 +15899,7 @@ function moveRunPictures(from, to, files = []) {
|
|
|
15803
15899
|
} catch {
|
|
15804
15900
|
return files;
|
|
15805
15901
|
}
|
|
15806
|
-
return files.map((file2) =>
|
|
15902
|
+
return files.map((file2) => path60.join(pictureBox(to), path60.basename(file2)));
|
|
15807
15903
|
}
|
|
15808
15904
|
var pictureName, boxId, freeBox, pictureBox;
|
|
15809
15905
|
var init_pictures = __esm({
|
|
@@ -15812,8 +15908,8 @@ var init_pictures = __esm({
|
|
|
15812
15908
|
init_paths();
|
|
15813
15909
|
pictureName = (name) => /^[0-9a-f-]{36}\.[a-z0-9]{2,5}$/.test(name);
|
|
15814
15910
|
boxId = (box2) => /^[0-9a-f-]{36}$/.test(box2);
|
|
15815
|
-
freeBox = (box2) => boxId(box2) && !fs56.existsSync(
|
|
15816
|
-
pictureBox = (box2) =>
|
|
15911
|
+
freeBox = (box2) => boxId(box2) && !fs56.existsSync(path60.join(SESSIONS_DIR, `${box2}.log`));
|
|
15912
|
+
pictureBox = (box2) => path60.join(SESSIONS_DIR, `${box2}.images`);
|
|
15817
15913
|
}
|
|
15818
15914
|
});
|
|
15819
15915
|
|
|
@@ -15934,10 +16030,10 @@ var init_facts = __esm({
|
|
|
15934
16030
|
|
|
15935
16031
|
// ../cli/src/lib/view/archive.ts
|
|
15936
16032
|
import fs57 from "node:fs";
|
|
15937
|
-
import
|
|
16033
|
+
import path61 from "node:path";
|
|
15938
16034
|
function archivedId(file2) {
|
|
15939
|
-
const own = idPrefix(
|
|
15940
|
-
return own !== null ? own : idPrefix(
|
|
16035
|
+
const own = idPrefix(path61.basename(file2));
|
|
16036
|
+
return own !== null ? own : idPrefix(path61.basename(path61.dirname(file2)));
|
|
15941
16037
|
}
|
|
15942
16038
|
function readFile(file2) {
|
|
15943
16039
|
const id = archivedId(file2);
|
|
@@ -15950,14 +16046,14 @@ function readFile(file2) {
|
|
|
15950
16046
|
title: meta.title,
|
|
15951
16047
|
archived: meta.archived,
|
|
15952
16048
|
rejected: meta.rejected,
|
|
15953
|
-
relPath: rel(file2).split(
|
|
16049
|
+
relPath: rel(file2).split(path61.sep).join("/")
|
|
15954
16050
|
},
|
|
15955
16051
|
body: body.replace(/^\n+/, "").replace(/\s+$/, ""),
|
|
15956
16052
|
meta
|
|
15957
16053
|
};
|
|
15958
16054
|
}
|
|
15959
16055
|
function readArchive() {
|
|
15960
|
-
const relPath = rel(ARCHIVE).split(
|
|
16056
|
+
const relPath = rel(ARCHIVE).split(path61.sep).join("/");
|
|
15961
16057
|
if (!fs57.existsSync(ARCHIVE)) return { relPath, cards: [] };
|
|
15962
16058
|
const cards = walkMd(ARCHIVE).map(readFile).filter((found2) => found2 !== null).map((found2) => found2.row);
|
|
15963
16059
|
cards.sort((a2, b2) => b2.id - a2.id);
|
|
@@ -15973,7 +16069,7 @@ var init_archive = __esm({
|
|
|
15973
16069
|
});
|
|
15974
16070
|
|
|
15975
16071
|
// ../cli/src/lib/agent/prompts.ts
|
|
15976
|
-
import
|
|
16072
|
+
import path62 from "node:path";
|
|
15977
16073
|
function stopReason(deliveryId) {
|
|
15978
16074
|
const delivery = findDelivery(deliveryId);
|
|
15979
16075
|
if (!delivery) return void 0;
|
|
@@ -16027,7 +16123,7 @@ ${text6}` : "";
|
|
|
16027
16123
|
}
|
|
16028
16124
|
function cardFileOf(id) {
|
|
16029
16125
|
const found2 = id === void 0 ? null : locate2(id);
|
|
16030
|
-
return found2 ? found2.kind === "group" ?
|
|
16126
|
+
return found2 ? found2.kind === "group" ? path62.join(found2.target, "root.md") : found2.target : "";
|
|
16031
16127
|
}
|
|
16032
16128
|
function realPaths(text6, req) {
|
|
16033
16129
|
if (req.action !== "scheduled" && req.action !== "sub") return text6;
|
|
@@ -16125,7 +16221,7 @@ function frozenRules(req) {
|
|
|
16125
16221
|
function archivedCardFile(id) {
|
|
16126
16222
|
const found2 = locateArchived(id);
|
|
16127
16223
|
if (!found2) return `${rel(ARCHIVE)}/`;
|
|
16128
|
-
return rel(found2.kind === "group" ?
|
|
16224
|
+
return rel(found2.kind === "group" ? path62.join(found2.target, "root.md") : found2.target);
|
|
16129
16225
|
}
|
|
16130
16226
|
function shippedLines(cardId2) {
|
|
16131
16227
|
const delivery = endedDelivery(`${cardId2}`);
|
|
@@ -16265,7 +16361,7 @@ function actionPrompt(req, command, notes) {
|
|
|
16265
16361
|
case "spec": {
|
|
16266
16362
|
const agent = findSpecAgent(req.specAgent ?? "");
|
|
16267
16363
|
const found2 = req.id === void 0 ? null : locate2(req.id);
|
|
16268
|
-
const cardFile3 = found2 ? rel(found2.kind === "group" ?
|
|
16364
|
+
const cardFile3 = found2 ? rel(found2.kind === "group" ? path62.join(found2.target, "root.md") : found2.target) : `task #${req.id}`;
|
|
16269
16365
|
const own = agent ? specAgentInstructions(agent) : null;
|
|
16270
16366
|
const memory = agent ? agentMemoryBlock(agent) : "";
|
|
16271
16367
|
const shared = agent ? globalMemoryBlock(agent) : "";
|
|
@@ -16670,7 +16766,7 @@ __export(sessions_exports, {
|
|
|
16670
16766
|
});
|
|
16671
16767
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
16672
16768
|
import fs59 from "node:fs";
|
|
16673
|
-
import
|
|
16769
|
+
import path63 from "node:path";
|
|
16674
16770
|
function reap(runs, reaped = [], restore = []) {
|
|
16675
16771
|
let changed = false;
|
|
16676
16772
|
const now = Date.now();
|
|
@@ -16684,7 +16780,7 @@ function reap(runs, reaped = [], restore = []) {
|
|
|
16684
16780
|
stampDuration(r2, r2.endedAt);
|
|
16685
16781
|
restore.push({ ...r2 });
|
|
16686
16782
|
if (r2.deliveryId && r2.action !== "sub") reaped.push({ ...r2 });
|
|
16687
|
-
dropSpec(r2.sessionId);
|
|
16783
|
+
if (r2.harness !== "antigravity") dropSpec(r2.sessionId);
|
|
16688
16784
|
changed = true;
|
|
16689
16785
|
}
|
|
16690
16786
|
return changed;
|
|
@@ -16837,7 +16933,7 @@ function leftBoardOnLanding(id) {
|
|
|
16837
16933
|
function archivedRejected(id) {
|
|
16838
16934
|
const filed = locateArchived(id);
|
|
16839
16935
|
if (!filed) return null;
|
|
16840
|
-
const file2 = filed.kind === "group" ?
|
|
16936
|
+
const file2 = filed.kind === "group" ? path63.join(filed.target, "root.md") : filed.target;
|
|
16841
16937
|
try {
|
|
16842
16938
|
return !!parseFrontmatter(fs59.readFileSync(file2, "utf8")).meta?.rejected;
|
|
16843
16939
|
} catch {
|
|
@@ -17089,7 +17185,7 @@ function openRun(req, prompt, notes = [], sessionId = randomUUID5(), said2) {
|
|
|
17089
17185
|
return { run: record, spec };
|
|
17090
17186
|
}
|
|
17091
17187
|
function planningSession(cardId2, cwd = REPO_ROOT) {
|
|
17092
|
-
const here = (dir) => !dir ||
|
|
17188
|
+
const here = (dir) => !dir || path63.resolve(dir) === cwd;
|
|
17093
17189
|
const planned = readRuns().filter((r2) => r2.status === "done" && r2.cardId === cardId2 && PLANNING.has(r2.action)).sort((a2, b2) => b2.startedAt - a2.startedAt)[0];
|
|
17094
17190
|
if (!planned) return { none: "unrecorded" };
|
|
17095
17191
|
if (!here(planned.cwd)) return { none: "elsewhere" };
|
|
@@ -17178,6 +17274,9 @@ async function openResume(id, options) {
|
|
|
17178
17274
|
let plan;
|
|
17179
17275
|
let fresh;
|
|
17180
17276
|
const session = forced ? void 0 : resumeSessionId(prev);
|
|
17277
|
+
if (!forced && prev.harness === "antigravity" && !session && !neverStarted(prev)) {
|
|
17278
|
+
return refusal("runNoSession", "Antigravity did not record a conversation ID before interruption. The original session cannot be resumed.");
|
|
17279
|
+
}
|
|
17181
17280
|
if (session) {
|
|
17182
17281
|
plan = planResume({ harness: prev.harness, resumeId: session, cwd }, prev.agent, prev.runtime ? { pin: prev.runtime } : {});
|
|
17183
17282
|
} else {
|
|
@@ -17240,7 +17339,8 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
|
|
|
17240
17339
|
sessionCostFrom: reportsSessionTotal(prev.harness) ? prev.sessionCostUsd ?? prev.sessionCostFrom : void 0,
|
|
17241
17340
|
// The retry chain carries on rather than starting over (#525): this run IS the attempt
|
|
17242
17341
|
// the failed one scheduled, so its count and its window come with it.
|
|
17243
|
-
retry: prev.retry
|
|
17342
|
+
retry: prev.retry,
|
|
17343
|
+
...prev.retry && prev.result ? { result: prev.result } : {}
|
|
17244
17344
|
},
|
|
17245
17345
|
logPath: logPathOf(sessionId),
|
|
17246
17346
|
specAgent: prev.specAgent,
|
|
@@ -17286,8 +17386,10 @@ async function resumeHeld(prev, plan, sessionId, resuming, fresh) {
|
|
|
17286
17386
|
r2.pictures = record.pictures;
|
|
17287
17387
|
});
|
|
17288
17388
|
}
|
|
17289
|
-
const
|
|
17389
|
+
const prompt = fresh?.prompt ?? (prev.harness === "antigravity" ? readSpec(prev.sessionId)?.prompt : void 0) ?? "";
|
|
17390
|
+
const spec = { sessionId, plan, prompt, ...fresh?.notes.length ? { notes: fresh.notes } : {} };
|
|
17290
17391
|
writeSpec(spec);
|
|
17392
|
+
if (prev.harness === "antigravity") dropSpec(prev.sessionId);
|
|
17291
17393
|
reportRun("started", record.harness, isCustomAgent(record.agent));
|
|
17292
17394
|
reportBoardNumbers(() => customAgentsOn().length);
|
|
17293
17395
|
return { run: record, spec };
|
|
@@ -17415,7 +17517,7 @@ async function closeRun(sessionId, res) {
|
|
|
17415
17517
|
recordReflection(closed2);
|
|
17416
17518
|
recordProjectDescription(closed2);
|
|
17417
17519
|
recordScheduledRun(closed2);
|
|
17418
|
-
dropSpec(sessionId);
|
|
17520
|
+
if (closed2.harness !== "antigravity" || closed2.status === "done") dropSpec(sessionId);
|
|
17419
17521
|
pruneLogs();
|
|
17420
17522
|
}
|
|
17421
17523
|
async function stopRun(id) {
|
|
@@ -17518,7 +17620,7 @@ function dropSpec(sessionId) {
|
|
|
17518
17620
|
}
|
|
17519
17621
|
async function acquireIndexLock(giveUp) {
|
|
17520
17622
|
const until = Date.now() + INDEX_WAIT_MS;
|
|
17521
|
-
const holder =
|
|
17623
|
+
const holder = path63.join(INDEX_LOCK2, "holder");
|
|
17522
17624
|
for (; ; ) {
|
|
17523
17625
|
if (giveUp()) return null;
|
|
17524
17626
|
try {
|
|
@@ -17528,7 +17630,7 @@ async function acquireIndexLock(giveUp) {
|
|
|
17528
17630
|
} catch (err) {
|
|
17529
17631
|
const code = err.code;
|
|
17530
17632
|
if (code === "ENOENT") {
|
|
17531
|
-
fs59.mkdirSync(
|
|
17633
|
+
fs59.mkdirSync(path63.dirname(INDEX_LOCK2), { recursive: true });
|
|
17532
17634
|
continue;
|
|
17533
17635
|
}
|
|
17534
17636
|
if (code !== "EEXIST") throw err;
|
|
@@ -17630,8 +17732,8 @@ var init_sessions = __esm({
|
|
|
17630
17732
|
implement: "implementing",
|
|
17631
17733
|
hook: "implementing"
|
|
17632
17734
|
};
|
|
17633
|
-
specPathOf = (sessionId) =>
|
|
17634
|
-
asksPathOf = (sessionId) =>
|
|
17735
|
+
specPathOf = (sessionId) => path63.join(SESSIONS_DIR, `${sessionId}.plan.json`);
|
|
17736
|
+
asksPathOf = (sessionId) => path63.join(SESSIONS_DIR, `${sessionId}.asks.json`);
|
|
17635
17737
|
carriesSession = (r2) => !!(r2.resumedFrom || r2.continues && !r2.continues.fork);
|
|
17636
17738
|
canPickUp = (r2) => r2.status === "error" || r2.status === "interrupted" || r2.status === "stopped";
|
|
17637
17739
|
neverStarted = (r2) => r2.unspawned === true || !!r2.errorWhy?.some((why2) => why2.kind === "notInstalled");
|
|
@@ -17659,7 +17761,7 @@ var init_sessions = __esm({
|
|
|
17659
17761
|
|
|
17660
17762
|
// ../cli/src/lib/card-sources.ts
|
|
17661
17763
|
import fs60 from "node:fs";
|
|
17662
|
-
import
|
|
17764
|
+
import path64 from "node:path";
|
|
17663
17765
|
function planById(id) {
|
|
17664
17766
|
const found2 = readPlan(`plans/${id}-.md`);
|
|
17665
17767
|
return found2?.text.trim() ? found2 : null;
|
|
@@ -17669,7 +17771,7 @@ function cardLink(id) {
|
|
|
17669
17771
|
const found2 = open3 ?? locateArchived(id);
|
|
17670
17772
|
if (!found2) return null;
|
|
17671
17773
|
try {
|
|
17672
|
-
const file2 = found2.kind === "group" ?
|
|
17774
|
+
const file2 = found2.kind === "group" ? path64.join(found2.target, "root.md") : found2.target;
|
|
17673
17775
|
const title = parseFrontmatter(fs60.readFileSync(file2, "utf8")).meta?.title ?? "";
|
|
17674
17776
|
return { kind: "card", ref: String(id), title, ...open3 ? {} : { archived: true } };
|
|
17675
17777
|
} catch {
|
|
@@ -17734,11 +17836,11 @@ var init_card_sources = __esm({
|
|
|
17734
17836
|
|
|
17735
17837
|
// ../cli/src/lib/view/read.ts
|
|
17736
17838
|
import fs61 from "node:fs";
|
|
17737
|
-
import
|
|
17839
|
+
import path65 from "node:path";
|
|
17738
17840
|
function readCard(file2, relFromTodo) {
|
|
17739
|
-
const id = idPrefix(
|
|
17841
|
+
const id = idPrefix(path65.basename(relFromTodo));
|
|
17740
17842
|
if (id === null) {
|
|
17741
|
-
const parts = relFromTodo.split(
|
|
17843
|
+
const parts = relFromTodo.split(path65.sep);
|
|
17742
17844
|
const folderId = idPrefix(parts[parts.length - 2] || "");
|
|
17743
17845
|
if (folderId === null) return null;
|
|
17744
17846
|
return buildCard(folderId, file2, relFromTodo);
|
|
@@ -17749,7 +17851,7 @@ function buildCard(id, file2, relFromTodo) {
|
|
|
17749
17851
|
const text6 = fs61.readFileSync(file2, "utf8");
|
|
17750
17852
|
const { meta, body } = parseFrontmatter(text6);
|
|
17751
17853
|
if (!meta) return null;
|
|
17752
|
-
const relPath = relFromTodo.split(
|
|
17854
|
+
const relPath = relFromTodo.split(path65.sep).join("/");
|
|
17753
17855
|
const flow = studioFor(meta.studio);
|
|
17754
17856
|
const plan = !!meta.studio && archivesOnApproval(flow);
|
|
17755
17857
|
const stages = cardStages(meta, flow).length;
|
|
@@ -17779,10 +17881,10 @@ function buildCard(id, file2, relFromTodo) {
|
|
|
17779
17881
|
};
|
|
17780
17882
|
}
|
|
17781
17883
|
function readGroup2(folderName) {
|
|
17782
|
-
const groupDir =
|
|
17783
|
-
const rootFile =
|
|
17884
|
+
const groupDir = path65.join(TODO, folderName);
|
|
17885
|
+
const rootFile = path65.join(groupDir, "root.md");
|
|
17784
17886
|
if (!fs61.existsSync(rootFile)) return null;
|
|
17785
|
-
const root2 = readCard(rootFile,
|
|
17887
|
+
const root2 = readCard(rootFile, path65.join(folderName, "root.md"));
|
|
17786
17888
|
if (!root2) return null;
|
|
17787
17889
|
root2.isGroup = true;
|
|
17788
17890
|
const { total, resolved: resolved2 } = subtaskLines(root2.body);
|
|
@@ -17790,11 +17892,11 @@ function readGroup2(folderName) {
|
|
|
17790
17892
|
const subCards = [];
|
|
17791
17893
|
const recurse = (dir, relDir) => {
|
|
17792
17894
|
for (const entry of fs61.readdirSync(dir, { withFileTypes: true })) {
|
|
17793
|
-
const childRel =
|
|
17895
|
+
const childRel = path65.join(relDir, entry.name);
|
|
17794
17896
|
if (entry.isDirectory()) {
|
|
17795
|
-
recurse(
|
|
17897
|
+
recurse(path65.join(dir, entry.name), childRel);
|
|
17796
17898
|
} else if (entry.name.endsWith(".md") && entry.name !== "README.md" && entry.name !== "root.md") {
|
|
17797
|
-
const c2 = readCard(
|
|
17899
|
+
const c2 = readCard(path65.join(dir, entry.name), childRel);
|
|
17798
17900
|
if (c2) {
|
|
17799
17901
|
c2.parent = { id: root2.id, title: root2.title };
|
|
17800
17902
|
subCards.push(c2);
|
|
@@ -17815,12 +17917,12 @@ function readGroup2(folderName) {
|
|
|
17815
17917
|
return { root: root2, subCards };
|
|
17816
17918
|
}
|
|
17817
17919
|
function standaloneCards(dirRel) {
|
|
17818
|
-
const dir = dirRel ?
|
|
17920
|
+
const dir = dirRel ? path65.join(TODO, dirRel) : TODO;
|
|
17819
17921
|
if (!fs61.existsSync(dir)) return [];
|
|
17820
17922
|
const cards = [];
|
|
17821
17923
|
for (const entry of fs61.readdirSync(dir, { withFileTypes: true })) {
|
|
17822
17924
|
if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
|
|
17823
|
-
const c2 = readCard(
|
|
17925
|
+
const c2 = readCard(path65.join(dir, entry.name), path65.join(dirRel, entry.name));
|
|
17824
17926
|
if (c2) cards.push(c2);
|
|
17825
17927
|
}
|
|
17826
17928
|
}
|
|
@@ -17864,7 +17966,7 @@ function findCard(id) {
|
|
|
17864
17966
|
}
|
|
17865
17967
|
function attachSources(card) {
|
|
17866
17968
|
try {
|
|
17867
|
-
const { meta, body } = parseFrontmatter(fs61.readFileSync(
|
|
17969
|
+
const { meta, body } = parseFrontmatter(fs61.readFileSync(path65.join(TODO, card.relPath), "utf8"));
|
|
17868
17970
|
const sources2 = meta ? cardSources(meta, body) : [];
|
|
17869
17971
|
if (sources2.length) card.sources = sources2;
|
|
17870
17972
|
} catch {
|
|
@@ -17969,7 +18071,7 @@ var init_read = __esm({
|
|
|
17969
18071
|
|
|
17970
18072
|
// ../cli/src/lib/agent/preview-progress.ts
|
|
17971
18073
|
import fs62 from "node:fs";
|
|
17972
|
-
import
|
|
18074
|
+
import path66 from "node:path";
|
|
17973
18075
|
import { createHash as createHash5, randomUUID as randomUUID6 } from "node:crypto";
|
|
17974
18076
|
function readPreviewProgress(id) {
|
|
17975
18077
|
try {
|
|
@@ -17991,7 +18093,7 @@ function readPreviewProgress(id) {
|
|
|
17991
18093
|
}
|
|
17992
18094
|
}
|
|
17993
18095
|
function updatePreviewProgress(id, change2) {
|
|
17994
|
-
fs62.mkdirSync(
|
|
18096
|
+
fs62.mkdirSync(path66.dirname(file(id)), { recursive: true });
|
|
17995
18097
|
return withLock(`${file(id)}.lock`, "updating preview progress", () => {
|
|
17996
18098
|
const all2 = readPreviewProgress(id);
|
|
17997
18099
|
const result = change2(all2);
|
|
@@ -18008,7 +18110,7 @@ function freezePreviewProgress(id, name) {
|
|
|
18008
18110
|
const agent = findSpecAgent(name);
|
|
18009
18111
|
if (!agent) return null;
|
|
18010
18112
|
const studio = studioFiles(cardStudioId(id)) ?? {};
|
|
18011
|
-
const protocol = Object.entries(studio).some(([
|
|
18113
|
+
const protocol = Object.entries(studio).some(([path89, text6]) => path89.endsWith("/AGENT.md") && /^[ \t]+stages:/m.test(text6.split(/\r?\n---/)[0]));
|
|
18012
18114
|
if (!agent.stages && !protocol) return null;
|
|
18013
18115
|
const definitions = agent.stages ?? [{ id: "preview", title: { en: "Preview", zh: "\u6210\u679C" }, instructions: "preview.md" }];
|
|
18014
18116
|
const files = Object.fromEntries(agent.files.map((file2) => [file2, agent.file(file2)]).filter((entry) => entry[1] !== null));
|
|
@@ -18041,7 +18143,7 @@ ${stage.artifact?.body ?? ""}`),
|
|
|
18041
18143
|
function previewOwner(id, name, inside2 = insideRun()) {
|
|
18042
18144
|
const found2 = locate2(id);
|
|
18043
18145
|
if (!found2) throw Error("The task is no longer open.");
|
|
18044
|
-
const card = found2.kind === "group" ?
|
|
18146
|
+
const card = found2.kind === "group" ? path66.join(found2.target, "root.md") : found2.target;
|
|
18045
18147
|
const { meta } = parseFrontmatter(fs62.readFileSync(card, "utf8"));
|
|
18046
18148
|
if (!specAgentAssigned(name, meta?.studio) || !meta?.previews?.includes(name)) throw Error("Choose this preview agent on the task first.");
|
|
18047
18149
|
if (inside2) {
|
|
@@ -18062,7 +18164,7 @@ function readContext(file2) {
|
|
|
18062
18164
|
}
|
|
18063
18165
|
}
|
|
18064
18166
|
function writeJson2(file2, value) {
|
|
18065
|
-
fs62.mkdirSync(
|
|
18167
|
+
fs62.mkdirSync(path66.dirname(file2), { recursive: true });
|
|
18066
18168
|
const temp = `${file2}.${process.pid}.tmp`;
|
|
18067
18169
|
fs62.writeFileSync(temp, JSON.stringify(value) + "\n");
|
|
18068
18170
|
fs62.renameSync(temp, file2);
|
|
@@ -18145,21 +18247,21 @@ function reportLocalPreview(id, name, stage, status) {
|
|
|
18145
18247
|
}
|
|
18146
18248
|
function localPreviewAssets(id, body) {
|
|
18147
18249
|
const assets = {};
|
|
18148
|
-
const taskRoot =
|
|
18250
|
+
const taskRoot = path66.join(ASSETS, String(id));
|
|
18149
18251
|
const visit = (src) => {
|
|
18150
18252
|
if (src in assets || /^[a-z][\w+.-]*:/i.test(src)) return;
|
|
18151
|
-
const file2 =
|
|
18152
|
-
if (!file2.startsWith(taskRoot +
|
|
18253
|
+
const file2 = path66.resolve(ASSETS, src.replace(/^\.assets\//, ""));
|
|
18254
|
+
if (!file2.startsWith(taskRoot + path66.sep)) throw Error("Preview assets must stay inside this task\u2019s asset folder.");
|
|
18153
18255
|
if (!fs62.existsSync(file2)) {
|
|
18154
18256
|
assets[src] = null;
|
|
18155
18257
|
return;
|
|
18156
18258
|
}
|
|
18157
18259
|
if (fs62.lstatSync(taskRoot).isSymbolicLink()) throw Error("Preview assets must stay inside this task\u2019s asset folder.");
|
|
18158
18260
|
const real2 = fs62.realpathSync(file2);
|
|
18159
|
-
if (!real2.startsWith(fs62.realpathSync(taskRoot) +
|
|
18261
|
+
if (!real2.startsWith(fs62.realpathSync(taskRoot) + path66.sep)) throw Error("Preview assets must stay inside this task\u2019s asset folder.");
|
|
18160
18262
|
const bytes2 = fs62.readFileSync(real2);
|
|
18161
18263
|
assets[src] = createHash5("sha256").update(bytes2).digest("hex");
|
|
18162
|
-
const manifest = manifestOf(kindOf(
|
|
18264
|
+
const manifest = manifestOf(kindOf(path66.extname(file2)));
|
|
18163
18265
|
let content = bytes2.toString();
|
|
18164
18266
|
if (manifest?.references?.some((ref) => "json" in ref)) {
|
|
18165
18267
|
try {
|
|
@@ -18170,10 +18272,10 @@ function localPreviewAssets(id, body) {
|
|
|
18170
18272
|
}
|
|
18171
18273
|
for (const ref of referencesOf(manifest, content)) {
|
|
18172
18274
|
if (/^[a-z][\w+.-]*:/i.test(ref.src)) continue;
|
|
18173
|
-
visit(
|
|
18275
|
+
visit(path66.posix.normalize(path66.posix.join(path66.posix.dirname(src), ref.src)));
|
|
18174
18276
|
}
|
|
18175
18277
|
};
|
|
18176
|
-
for (const ref of bodyReferences(body)) if (ref.src.startsWith(".assets/") || fs62.existsSync(
|
|
18278
|
+
for (const ref of bodyReferences(body)) if (ref.src.startsWith(".assets/") || fs62.existsSync(path66.join(ASSETS, ref.src))) visit(ref.src);
|
|
18177
18279
|
return assets;
|
|
18178
18280
|
}
|
|
18179
18281
|
function freezeLocalAssets(id, all2) {
|
|
@@ -18183,13 +18285,13 @@ function freezeLocalAssets(id, all2) {
|
|
|
18183
18285
|
const pinned2 = {};
|
|
18184
18286
|
for (const [src, hash2] of Object.entries(artifact.assets)) {
|
|
18185
18287
|
if (typeof hash2 !== "string") continue;
|
|
18186
|
-
const file2 =
|
|
18288
|
+
const file2 = path66.join(ASSETS, src.replace(/^\.assets\//, ""));
|
|
18187
18289
|
if (!fs62.existsSync(file2)) continue;
|
|
18188
|
-
const root2 =
|
|
18189
|
-
if (fs62.lstatSync(root2).isSymbolicLink() || !fs62.realpathSync(file2).startsWith(fs62.realpathSync(root2) +
|
|
18290
|
+
const root2 = path66.join(ASSETS, String(id));
|
|
18291
|
+
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.");
|
|
18190
18292
|
if (createHash5("sha256").update(fs62.readFileSync(file2)).digest("hex") !== hash2) continue;
|
|
18191
|
-
const frozen =
|
|
18192
|
-
fs62.mkdirSync(
|
|
18293
|
+
const frozen = path66.join(BOARD_STATE, "previews", "assets", String(id), stage.id, String(progress.generation), String(artifact.version), hash2, src.replace(/^\.assets\//, ""));
|
|
18294
|
+
fs62.mkdirSync(path66.dirname(frozen), { recursive: true });
|
|
18193
18295
|
if (!fs62.existsSync(frozen)) fs62.copyFileSync(file2, frozen, fs62.constants.COPYFILE_EXCL);
|
|
18194
18296
|
pinned2[src] = frozen;
|
|
18195
18297
|
}
|
|
@@ -18219,17 +18321,17 @@ var init_preview_progress = __esm({
|
|
|
18219
18321
|
init_execution();
|
|
18220
18322
|
init_preview();
|
|
18221
18323
|
init_preview_stages();
|
|
18222
|
-
file = (id) =>
|
|
18223
|
-
contextFile = (id, name, owner) =>
|
|
18324
|
+
file = (id) => path66.join(BOARD_STATE, "previews", `${id}.json`);
|
|
18325
|
+
contextFile = (id, name, owner) => path66.join(BOARD_STATE, "previews", "contexts", String(id), name, `${createHash5("sha256").update(owner).digest("hex")}.json`);
|
|
18224
18326
|
PreviewContextMissing = class extends Error {
|
|
18225
18327
|
};
|
|
18226
|
-
baselineFile = (id, name, run4) =>
|
|
18328
|
+
baselineFile = (id, name, run4) => path66.join(BOARD_STATE, "previews", "runs", String(id), name, `${run4}.json`);
|
|
18227
18329
|
}
|
|
18228
18330
|
});
|
|
18229
18331
|
|
|
18230
18332
|
// ../cli/src/lib/agent/approve.ts
|
|
18231
18333
|
import fs63 from "node:fs";
|
|
18232
|
-
import
|
|
18334
|
+
import path67 from "node:path";
|
|
18233
18335
|
function approvalRequest(req) {
|
|
18234
18336
|
const id = req.id;
|
|
18235
18337
|
const card = id === void 0 ? null : findCard(id);
|
|
@@ -18247,7 +18349,7 @@ function advancePhase(id) {
|
|
|
18247
18349
|
const card = findCard(id);
|
|
18248
18350
|
const found2 = locate2(id);
|
|
18249
18351
|
if (!card || !found2 || !awaitingApproval(card)) return { error: `#${id} is no longer waiting on approval.` };
|
|
18250
|
-
const file2 = found2.kind === "group" ?
|
|
18352
|
+
const file2 = found2.kind === "group" ? path67.join(found2.target, "root.md") : found2.target;
|
|
18251
18353
|
const { meta, body } = parseFrontmatter(fs63.readFileSync(file2, "utf8"));
|
|
18252
18354
|
if (!meta) return { error: `#${id} has no frontmatter` };
|
|
18253
18355
|
meta.phase = card.stage + 1;
|
|
@@ -18495,7 +18597,7 @@ var init_avatar = __esm({
|
|
|
18495
18597
|
|
|
18496
18598
|
// ../cli/src/lib/cloud/pro.ts
|
|
18497
18599
|
import fs64 from "node:fs";
|
|
18498
|
-
import
|
|
18600
|
+
import path68 from "node:path";
|
|
18499
18601
|
function forgetPro() {
|
|
18500
18602
|
fs64.rmSync(heldFile(), { force: true });
|
|
18501
18603
|
}
|
|
@@ -18508,7 +18610,7 @@ var init_pro = __esm({
|
|
|
18508
18610
|
init_session();
|
|
18509
18611
|
FRESH_MS2 = 10 * 6e4;
|
|
18510
18612
|
GRACE_MS = 7 * 24 * 60 * 6e4;
|
|
18511
|
-
heldFile = () =>
|
|
18613
|
+
heldFile = () => path68.join(machineHome(), "pro.json");
|
|
18512
18614
|
}
|
|
18513
18615
|
});
|
|
18514
18616
|
|
|
@@ -18600,7 +18702,7 @@ var init_account = __esm({
|
|
|
18600
18702
|
|
|
18601
18703
|
// ../cli/src/commands/cloud.ts
|
|
18602
18704
|
import fs65 from "node:fs";
|
|
18603
|
-
import
|
|
18705
|
+
import path69 from "node:path";
|
|
18604
18706
|
async function cmdCloud(args2, program2) {
|
|
18605
18707
|
const [sub] = args2;
|
|
18606
18708
|
if (sub === "sign-out") {
|
|
@@ -18662,7 +18764,7 @@ async function cloudImage(opts, program2) {
|
|
|
18662
18764
|
const prompt = opts.prompt.trim();
|
|
18663
18765
|
if (!prompt) usage("Missing the prompt.", line);
|
|
18664
18766
|
const references = opts.refs.map((file2) => {
|
|
18665
|
-
const type = REF_TYPES[
|
|
18767
|
+
const type = REF_TYPES[path69.extname(file2).toLowerCase()];
|
|
18666
18768
|
if (!type) usage(`--ref ${file2}: use a PNG, JPEG or WebP file.`, line);
|
|
18667
18769
|
try {
|
|
18668
18770
|
return `data:${type};base64,${fs65.readFileSync(file2).toString("base64")}`;
|
|
@@ -18773,7 +18875,7 @@ async function generate(g3) {
|
|
|
18773
18875
|
refuse(g3.failed, g3.fallback);
|
|
18774
18876
|
}
|
|
18775
18877
|
const out = g3.outFor?.(res, g3.out) ?? g3.out;
|
|
18776
|
-
fs65.mkdirSync(
|
|
18878
|
+
fs65.mkdirSync(path69.dirname(path69.resolve(out)), { recursive: true });
|
|
18777
18879
|
fs65.writeFileSync(out, Buffer.from(await res.arrayBuffer()));
|
|
18778
18880
|
say(`${out} (${g3.label(res)})`);
|
|
18779
18881
|
return { out };
|
|
@@ -18824,9 +18926,9 @@ var init_cloud = __esm({
|
|
|
18824
18926
|
// ../cli/src/commands/task.ts
|
|
18825
18927
|
import fs66 from "node:fs";
|
|
18826
18928
|
import os5 from "node:os";
|
|
18827
|
-
import
|
|
18929
|
+
import path70 from "node:path";
|
|
18828
18930
|
async function cloud(method, route2, body, signal2) {
|
|
18829
|
-
process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME ||
|
|
18931
|
+
process.env.AI4KANBAN_HOME ??= process.env.WILDCRANE_HOME || path70.join(os5.homedir(), ".wildcrane");
|
|
18830
18932
|
const token2 = await accessToken();
|
|
18831
18933
|
if (!token2.ok) return refuse2(SAID[token2.reason].en, token2.reason.replace("-", "_"));
|
|
18832
18934
|
let response;
|
|
@@ -18869,15 +18971,15 @@ function linked(location) {
|
|
|
18869
18971
|
const cwd = location.cwd ?? process.cwd();
|
|
18870
18972
|
const board2 = location.board ?? (process.env.AI4KANBAN_BOARD?.trim() || null);
|
|
18871
18973
|
if (board2) {
|
|
18872
|
-
const link2 = linkedProject("", projectRootOf(
|
|
18974
|
+
const link2 = linkedProject("", projectRootOf(path70.resolve(cwd, board2)));
|
|
18873
18975
|
return link2.ok ? link2.value : null;
|
|
18874
18976
|
}
|
|
18875
|
-
for (let dir =
|
|
18876
|
-
if (fs66.existsSync(
|
|
18977
|
+
for (let dir = path70.resolve(cwd, location.dir ?? "."); ; dir = path70.dirname(dir)) {
|
|
18978
|
+
if (fs66.existsSync(path70.join(dir, ".akb", "base.json"))) {
|
|
18877
18979
|
const link2 = linkedProject("", dir);
|
|
18878
18980
|
return link2.ok ? link2.value : null;
|
|
18879
18981
|
}
|
|
18880
|
-
if (
|
|
18982
|
+
if (path70.dirname(dir) === dir) return null;
|
|
18881
18983
|
}
|
|
18882
18984
|
}
|
|
18883
18985
|
async function project(asked, location) {
|
|
@@ -19161,7 +19263,7 @@ var init_goal = __esm({
|
|
|
19161
19263
|
// ../cli/src/commands/goal-cloud.ts
|
|
19162
19264
|
import fs68 from "node:fs";
|
|
19163
19265
|
import os6 from "node:os";
|
|
19164
|
-
import
|
|
19266
|
+
import path71 from "node:path";
|
|
19165
19267
|
import crypto3 from "node:crypto";
|
|
19166
19268
|
function hostSession() {
|
|
19167
19269
|
const { CLAUDE_CODE_SESSION_ID: claude, CODEX_THREAD_ID: codex, CURSOR_CONVERSATION_ID: cursor, KIMI_SESSION_ID: kimi, WILDCRANE_DISCUSSION: discussion2 } = process.env;
|
|
@@ -19190,10 +19292,10 @@ function goalsOf(d2) {
|
|
|
19190
19292
|
async function discussion() {
|
|
19191
19293
|
const session = hostSession();
|
|
19192
19294
|
if (!session) die("Goals exist only inside a WildCrane goal discussion.");
|
|
19193
|
-
const home3 = process.env.WILDCRANE_HOME ||
|
|
19295
|
+
const home3 = process.env.WILDCRANE_HOME || path71.join(os6.homedir(), ".wildcrane");
|
|
19194
19296
|
process.env.AI4KANBAN_HOME ??= home3;
|
|
19195
19297
|
if (session.host === "discussion") return request("GET", `/v1/discussions/${encodeURIComponent(session.id)}`);
|
|
19196
|
-
const machineFile2 =
|
|
19298
|
+
const machineFile2 = path71.join(home3, "machine.json");
|
|
19197
19299
|
let machine;
|
|
19198
19300
|
try {
|
|
19199
19301
|
machine = JSON.parse(fs68.readFileSync(machineFile2, "utf8")).id;
|
|
@@ -19207,7 +19309,7 @@ async function discussion() {
|
|
|
19207
19309
|
const folder = held4.folders.filter((f2) => {
|
|
19208
19310
|
try {
|
|
19209
19311
|
const dir = fs68.realpathSync(f2.path);
|
|
19210
|
-
return cwd === dir || cwd.startsWith(dir +
|
|
19312
|
+
return cwd === dir || cwd.startsWith(dir + path71.sep);
|
|
19211
19313
|
} catch {
|
|
19212
19314
|
return false;
|
|
19213
19315
|
}
|
|
@@ -19216,8 +19318,8 @@ async function discussion() {
|
|
|
19216
19318
|
}
|
|
19217
19319
|
async function withGoalDiscussion(action, save3 = false) {
|
|
19218
19320
|
const d2 = await discussion();
|
|
19219
|
-
const dir = fs68.mkdtempSync(
|
|
19220
|
-
const file2 =
|
|
19321
|
+
const dir = fs68.mkdtempSync(path71.join(os6.tmpdir(), "akb-goals-"));
|
|
19322
|
+
const file2 = path71.join(dir, "goals.json");
|
|
19221
19323
|
const before = process.env.KANBAN_GOALS;
|
|
19222
19324
|
try {
|
|
19223
19325
|
const previous = goalsOf(d2);
|
|
@@ -20393,7 +20495,7 @@ var require_command = __commonJS({
|
|
|
20393
20495
|
"../cli/node_modules/commander/lib/command.js"(exports) {
|
|
20394
20496
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
20395
20497
|
var childProcess = __require("node:child_process");
|
|
20396
|
-
var
|
|
20498
|
+
var path89 = __require("node:path");
|
|
20397
20499
|
var fs89 = __require("node:fs");
|
|
20398
20500
|
var process2 = __require("node:process");
|
|
20399
20501
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
@@ -21393,9 +21495,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
21393
21495
|
let launchWithNode = false;
|
|
21394
21496
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
21395
21497
|
function findFile(baseDir, baseName) {
|
|
21396
|
-
const localBin =
|
|
21498
|
+
const localBin = path89.resolve(baseDir, baseName);
|
|
21397
21499
|
if (fs89.existsSync(localBin)) return localBin;
|
|
21398
|
-
if (sourceExt.includes(
|
|
21500
|
+
if (sourceExt.includes(path89.extname(baseName))) return void 0;
|
|
21399
21501
|
const foundExt = sourceExt.find(
|
|
21400
21502
|
(ext) => fs89.existsSync(`${localBin}${ext}`)
|
|
21401
21503
|
);
|
|
@@ -21413,17 +21515,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
21413
21515
|
} catch {
|
|
21414
21516
|
resolvedScriptPath = this._scriptPath;
|
|
21415
21517
|
}
|
|
21416
|
-
executableDir =
|
|
21417
|
-
|
|
21518
|
+
executableDir = path89.resolve(
|
|
21519
|
+
path89.dirname(resolvedScriptPath),
|
|
21418
21520
|
executableDir
|
|
21419
21521
|
);
|
|
21420
21522
|
}
|
|
21421
21523
|
if (executableDir) {
|
|
21422
21524
|
let localFile = findFile(executableDir, executableFile);
|
|
21423
21525
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
21424
|
-
const legacyName =
|
|
21526
|
+
const legacyName = path89.basename(
|
|
21425
21527
|
this._scriptPath,
|
|
21426
|
-
|
|
21528
|
+
path89.extname(this._scriptPath)
|
|
21427
21529
|
);
|
|
21428
21530
|
if (legacyName !== this._name) {
|
|
21429
21531
|
localFile = findFile(
|
|
@@ -21434,7 +21536,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
21434
21536
|
}
|
|
21435
21537
|
executableFile = localFile || executableFile;
|
|
21436
21538
|
}
|
|
21437
|
-
launchWithNode = sourceExt.includes(
|
|
21539
|
+
launchWithNode = sourceExt.includes(path89.extname(executableFile));
|
|
21438
21540
|
let proc;
|
|
21439
21541
|
if (process2.platform !== "win32") {
|
|
21440
21542
|
if (launchWithNode) {
|
|
@@ -22281,7 +22383,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22281
22383
|
* @return {Command}
|
|
22282
22384
|
*/
|
|
22283
22385
|
nameFromFilename(filename) {
|
|
22284
|
-
this._name =
|
|
22386
|
+
this._name = path89.basename(filename, path89.extname(filename));
|
|
22285
22387
|
return this;
|
|
22286
22388
|
}
|
|
22287
22389
|
/**
|
|
@@ -22295,9 +22397,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
22295
22397
|
* @param {string} [path]
|
|
22296
22398
|
* @return {(string|null|Command)}
|
|
22297
22399
|
*/
|
|
22298
|
-
executableDir(
|
|
22299
|
-
if (
|
|
22300
|
-
this._executableDir =
|
|
22400
|
+
executableDir(path90) {
|
|
22401
|
+
if (path90 === void 0) return this._executableDir;
|
|
22402
|
+
this._executableDir = path90;
|
|
22301
22403
|
return this;
|
|
22302
22404
|
}
|
|
22303
22405
|
/**
|
|
@@ -22595,21 +22697,21 @@ var init_esm = __esm({
|
|
|
22595
22697
|
|
|
22596
22698
|
// ../cli/src/lib/card-studio-backfill.ts
|
|
22597
22699
|
import fs69 from "node:fs";
|
|
22598
|
-
import
|
|
22700
|
+
import path72 from "node:path";
|
|
22599
22701
|
function renameToStudio() {
|
|
22600
22702
|
if (!KANBAN || !BOARD_STATE) return;
|
|
22601
|
-
const mark =
|
|
22703
|
+
const mark = path72.join(BOARD_STATE, RENAMED);
|
|
22602
22704
|
try {
|
|
22603
22705
|
if (fs69.existsSync(mark)) return;
|
|
22604
|
-
for (const [from, to] of [[
|
|
22706
|
+
for (const [from, to] of [[path72.join(KANBAN, "workflows"), STUDIOS], [path72.join(RULES, "workflows"), path72.join(RULES, "studios")]]) {
|
|
22605
22707
|
if (fs69.existsSync(from) && !fs69.existsSync(to)) fs69.renameSync(from, to);
|
|
22606
22708
|
}
|
|
22607
22709
|
for (const file2 of [STUDIOS, TODO, TRIAGE].flatMap((dir) => fs69.existsSync(dir) ? walkMd(dir) : [])) {
|
|
22608
|
-
const at2 =
|
|
22710
|
+
const at2 = path72.relative(KANBAN, file2).split(path72.sep).join("/");
|
|
22609
22711
|
const text6 = fs69.readFileSync(file2, "utf8");
|
|
22610
22712
|
const to = studioRenamed(at2, text6);
|
|
22611
22713
|
if (to.path === at2 && to.content === text6) continue;
|
|
22612
|
-
const target =
|
|
22714
|
+
const target = path72.join(KANBAN, to.path);
|
|
22613
22715
|
if (target !== file2 && fs69.existsSync(target)) continue;
|
|
22614
22716
|
fs69.writeFileSync(target, to.content);
|
|
22615
22717
|
if (target !== file2) fs69.rmSync(file2);
|
|
@@ -22622,7 +22724,7 @@ function renameToStudio() {
|
|
|
22622
22724
|
function backfillCardStudios() {
|
|
22623
22725
|
renameToStudio();
|
|
22624
22726
|
if (!TODO || !BOARD_STATE) return;
|
|
22625
|
-
const mark =
|
|
22727
|
+
const mark = path72.join(BOARD_STATE, MARK);
|
|
22626
22728
|
try {
|
|
22627
22729
|
if (fs69.existsSync(mark) || !fs69.existsSync(TODO)) return;
|
|
22628
22730
|
for (const file2 of walkMd(TODO)) {
|
|
@@ -22676,7 +22778,7 @@ var init_created_cards = __esm({
|
|
|
22676
22778
|
// ../cli/src/lib/agent/creation.ts
|
|
22677
22779
|
import crypto4 from "node:crypto";
|
|
22678
22780
|
import fs70 from "node:fs";
|
|
22679
|
-
import
|
|
22781
|
+
import path73 from "node:path";
|
|
22680
22782
|
function creationError(error, triage) {
|
|
22681
22783
|
const zh = readLanguage() === "zh";
|
|
22682
22784
|
const messages = {
|
|
@@ -22702,7 +22804,7 @@ ${zh ? `\u539F\u6761\u76EE\u4ECD\u5728 triage\uFF1A${triage}\u3002${unreachable
|
|
|
22702
22804
|
function creationReceipt(request2, slot) {
|
|
22703
22805
|
const hash2 = crypto4.createHash("sha256").update(`${request2}
|
|
22704
22806
|
${slot}`).digest("hex");
|
|
22705
|
-
return
|
|
22807
|
+
return path73.join(projectStateDir(KANBAN, REPO_ROOT), "creations", `${hash2}.json`);
|
|
22706
22808
|
}
|
|
22707
22809
|
function readCreation(file2, said2) {
|
|
22708
22810
|
return withCreationLock(() => {
|
|
@@ -22719,7 +22821,7 @@ function readCreation(file2, said2) {
|
|
|
22719
22821
|
});
|
|
22720
22822
|
}
|
|
22721
22823
|
function saveCreation(file2, journal) {
|
|
22722
|
-
fs70.mkdirSync(
|
|
22824
|
+
fs70.mkdirSync(path73.dirname(file2), { recursive: true });
|
|
22723
22825
|
const temp = `${file2}.${crypto4.randomUUID()}.tmp`;
|
|
22724
22826
|
fs70.writeFileSync(temp, JSON.stringify(journal));
|
|
22725
22827
|
fs70.renameSync(temp, file2);
|
|
@@ -22736,7 +22838,7 @@ function archiveCreation(source2, id) {
|
|
|
22736
22838
|
function triageFile(sourceId) {
|
|
22737
22839
|
const found2 = [...readInbox(), ...readAllDismissed(), ...readArchived()].find((s) => s.sourceId === sourceId.trim());
|
|
22738
22840
|
if (!found2) throw new BoardError(`nothing in triage is ${sourceId}`, { kind: "refused" });
|
|
22739
|
-
return
|
|
22841
|
+
return path73.basename(found2.relPath, ".md");
|
|
22740
22842
|
}
|
|
22741
22843
|
var init_creation = __esm({
|
|
22742
22844
|
"../cli/src/lib/agent/creation.ts"() {
|
|
@@ -22906,7 +23008,7 @@ __export(board_exports, {
|
|
|
22906
23008
|
});
|
|
22907
23009
|
import crypto5 from "node:crypto";
|
|
22908
23010
|
import fs71 from "node:fs";
|
|
22909
|
-
import
|
|
23011
|
+
import path74 from "node:path";
|
|
22910
23012
|
async function dispatch(move, cmd, args2, opts, cli) {
|
|
22911
23013
|
const ctx = ctxOf(cmd, cli.program);
|
|
22912
23014
|
const data = await runAction(ctx, {}, async () => {
|
|
@@ -22975,7 +23077,7 @@ async function cloudCard(task, opts) {
|
|
|
22975
23077
|
const file2 = creationReceipt(`${checked.value}:${requestId}`, slot);
|
|
22976
23078
|
const journal = readCreation(file2, said2);
|
|
22977
23079
|
if (!journal.made) {
|
|
22978
|
-
const key = `akb-${
|
|
23080
|
+
const key = `akb-${path74.basename(file2, ".json").slice(0, 40)}`;
|
|
22979
23081
|
const made = await createProjectTask(checked.value, journal.said, key);
|
|
22980
23082
|
if (!made.ok) throw new BoardError(creationError(`Cloud did not make the task: ${made.error}`, triage), { kind: "refused" });
|
|
22981
23083
|
journal.made = made.value;
|
|
@@ -23108,9 +23210,9 @@ var init_board2 = __esm({
|
|
|
23108
23210
|
|
|
23109
23211
|
// ../cli/src/lib/board-cli.ts
|
|
23110
23212
|
import fs72 from "node:fs";
|
|
23111
|
-
import
|
|
23213
|
+
import path75 from "node:path";
|
|
23112
23214
|
function useBoard(found2, dirNamed, readOnly = false) {
|
|
23113
|
-
if (!found2.named && found2.board ===
|
|
23215
|
+
if (!found2.named && found2.board === path75.join(found2.root, "docs", "kanban")) setBoardRoot(found2.root, dirNamed);
|
|
23114
23216
|
else setBoardDir(found2.board, found2.root);
|
|
23115
23217
|
if (!readOnly) {
|
|
23116
23218
|
useProjectState();
|
|
@@ -23119,7 +23221,7 @@ function useBoard(found2, dirNamed, readOnly = false) {
|
|
|
23119
23221
|
}
|
|
23120
23222
|
function whole(found2, move) {
|
|
23121
23223
|
if (move === MAKES_A_BOARD) return found2;
|
|
23122
|
-
if (!fs72.existsSync(
|
|
23224
|
+
if (!fs72.existsSync(path75.join(found2.board, "todo"))) {
|
|
23123
23225
|
die(`the board in ${found2.board} has no todo/ \u2014 run \`init\` to add what is missing.`, {
|
|
23124
23226
|
kind: "board-incomplete",
|
|
23125
23227
|
dir: found2.root
|
|
@@ -23128,13 +23230,13 @@ function whole(found2, move) {
|
|
|
23128
23230
|
return found2;
|
|
23129
23231
|
}
|
|
23130
23232
|
function findBoardUpward(from, move) {
|
|
23131
|
-
let dir =
|
|
23233
|
+
let dir = path75.resolve(from);
|
|
23132
23234
|
for (; ; ) {
|
|
23133
|
-
if (hasBoard(dir)) return { root: dir, board:
|
|
23235
|
+
if (hasBoard(dir)) return { root: dir, board: path75.join(dir, "docs", "kanban") };
|
|
23134
23236
|
if (isBoardDir(dir)) return { root: projectRootOf(dir), board: dir };
|
|
23135
|
-
const kept2 =
|
|
23136
|
-
if (move !== MAKES_A_BOARD && fs72.existsSync(
|
|
23137
|
-
const up =
|
|
23237
|
+
const kept2 = path75.join(dir, ".akb", "kanban");
|
|
23238
|
+
if (move !== MAKES_A_BOARD && fs72.existsSync(path75.join(kept2, "todo"))) return { root: dir, board: kept2 };
|
|
23239
|
+
const up = path75.dirname(dir);
|
|
23138
23240
|
if (up === dir) return null;
|
|
23139
23241
|
dir = up;
|
|
23140
23242
|
}
|
|
@@ -23142,7 +23244,7 @@ function findBoardUpward(from, move) {
|
|
|
23142
23244
|
function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
23143
23245
|
const named2 = board2 ?? boardFromEnv();
|
|
23144
23246
|
if (named2) {
|
|
23145
|
-
const folder =
|
|
23247
|
+
const folder = path75.resolve(cwd, named2);
|
|
23146
23248
|
if (!fs72.existsSync(folder) && move !== MAKES_A_BOARD) {
|
|
23147
23249
|
die(`no such folder: ${folder}`, { kind: "no-such-folder", dir: folder });
|
|
23148
23250
|
}
|
|
@@ -23155,24 +23257,24 @@ function resolveBoard(move, { board: board2, dir, cwd, installHint }) {
|
|
|
23155
23257
|
return { root: projectRootOf(folder), board: folder, named: true };
|
|
23156
23258
|
}
|
|
23157
23259
|
if (dir !== null) {
|
|
23158
|
-
const root2 =
|
|
23260
|
+
const root2 = path75.resolve(dir);
|
|
23159
23261
|
if (!fs72.existsSync(root2)) die(`no such folder: ${root2}`, { kind: "no-such-folder", dir: root2 });
|
|
23160
|
-
const kept2 =
|
|
23161
|
-
if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs72.existsSync(
|
|
23262
|
+
const kept2 = path75.join(root2, ".akb", "kanban");
|
|
23263
|
+
if (!hasBoard(root2) && move !== MAKES_A_BOARD && fs72.existsSync(path75.join(kept2, "todo"))) return whole({ root: root2, board: kept2 }, move);
|
|
23162
23264
|
if (!hasBoard(root2) && move !== MAKES_A_BOARD) {
|
|
23163
23265
|
die(`no board in ${root2} \u2014 it has no docs/kanban/. ${installHint}\u3002`, {
|
|
23164
23266
|
kind: "no-board",
|
|
23165
23267
|
dir: root2
|
|
23166
23268
|
});
|
|
23167
23269
|
}
|
|
23168
|
-
return whole({ root: root2, board:
|
|
23270
|
+
return whole({ root: root2, board: path75.join(root2, "docs", "kanban") }, move);
|
|
23169
23271
|
}
|
|
23170
23272
|
const found2 = findBoardUpward(cwd, move);
|
|
23171
23273
|
if (found2) return whole(found2, move);
|
|
23172
|
-
if (move === MAKES_A_BOARD) return { root:
|
|
23274
|
+
if (move === MAKES_A_BOARD) return { root: path75.resolve(cwd), board: path75.join(path75.resolve(cwd), "docs", "kanban") };
|
|
23173
23275
|
die(
|
|
23174
|
-
`no board here. Looked in ${
|
|
23175
|
-
{ kind: "no-board", dir:
|
|
23276
|
+
`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`,
|
|
23277
|
+
{ kind: "no-board", dir: path75.resolve(cwd) }
|
|
23176
23278
|
);
|
|
23177
23279
|
}
|
|
23178
23280
|
function editDistance(a2, b2) {
|
|
@@ -23248,8 +23350,8 @@ var init_board_cli = __esm({
|
|
|
23248
23350
|
init_io();
|
|
23249
23351
|
init_card_studio_backfill();
|
|
23250
23352
|
MAKES_A_BOARD = "init";
|
|
23251
|
-
hasBoard = (dir) => fs72.existsSync(
|
|
23252
|
-
isBoardDir = (dir) => fs72.existsSync(
|
|
23353
|
+
hasBoard = (dir) => fs72.existsSync(path75.join(dir, "docs", "kanban"));
|
|
23354
|
+
isBoardDir = (dir) => fs72.existsSync(path75.join(dir, "todo")) && fs72.existsSync(path75.join(dir, "config.md"));
|
|
23253
23355
|
boardFromEnv = () => {
|
|
23254
23356
|
const named2 = process.env.AI4KANBAN_BOARD?.trim();
|
|
23255
23357
|
return named2 ? named2 : null;
|
|
@@ -23494,7 +23596,7 @@ var init_agent = __esm({
|
|
|
23494
23596
|
// ../cli/src/commands/cloud-template.ts
|
|
23495
23597
|
import { createHash as createHash6 } from "node:crypto";
|
|
23496
23598
|
import fs73 from "node:fs";
|
|
23497
|
-
import
|
|
23599
|
+
import path76 from "node:path";
|
|
23498
23600
|
function usage2(problem, line) {
|
|
23499
23601
|
die(`${problem}
|
|
23500
23602
|
usage: ${line}`, { kind: "bad-args", bare: true, exitCode: 2 });
|
|
@@ -23571,8 +23673,8 @@ This template has no preview.`);
|
|
|
23571
23673
|
const written = [];
|
|
23572
23674
|
for (const p2 of previews) {
|
|
23573
23675
|
const bytes2 = Buffer.from(await (await ask(`/${at2}/previews/${route(p2.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
23574
|
-
const file2 =
|
|
23575
|
-
const out =
|
|
23676
|
+
const file2 = path76.basename(p2.path);
|
|
23677
|
+
const out = path76.join(opts.to, file2.startsWith(`${name}-`) ? file2 : `${name}-${file2}`);
|
|
23576
23678
|
fs73.mkdirSync(opts.to, { recursive: true });
|
|
23577
23679
|
fs73.writeFileSync(out, bytes2);
|
|
23578
23680
|
written.push(out);
|
|
@@ -23587,15 +23689,15 @@ async function templateGet(name, opts, program2) {
|
|
|
23587
23689
|
const { template } = await asJson(await ask(`/${at2}`, {}, WITHOUT));
|
|
23588
23690
|
const fetched = [];
|
|
23589
23691
|
for (const f2 of template.files) {
|
|
23590
|
-
const out =
|
|
23591
|
-
if (!out.startsWith(
|
|
23692
|
+
const out = path76.resolve(to, f2.path);
|
|
23693
|
+
if (!out.startsWith(path76.resolve(to) + path76.sep)) refuse3(T.corrupt, WITHOUT);
|
|
23592
23694
|
const bytes2 = Buffer.from(await (await ask(`/${at2}/files/${route(f2.path)}`, {}, WITHOUT)).arrayBuffer());
|
|
23593
23695
|
if (bytes2.byteLength !== f2.size || createHash6("sha256").update(bytes2).digest("hex") !== f2.sha256) {
|
|
23594
23696
|
refuse3(T.corrupt, WITHOUT);
|
|
23595
23697
|
}
|
|
23596
23698
|
fetched.push({ out, bytes: bytes2 });
|
|
23597
23699
|
}
|
|
23598
|
-
const taken = fetched.filter((f2) => fs73.existsSync(f2.out)).map((f2) =>
|
|
23700
|
+
const taken = fetched.filter((f2) => fs73.existsSync(f2.out)).map((f2) => path76.relative(to, f2.out));
|
|
23599
23701
|
if (taken.length > 0) {
|
|
23600
23702
|
refuse3({
|
|
23601
23703
|
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`,
|
|
@@ -23603,7 +23705,7 @@ async function templateGet(name, opts, program2) {
|
|
|
23603
23705
|
});
|
|
23604
23706
|
}
|
|
23605
23707
|
for (const f2 of fetched) {
|
|
23606
|
-
fs73.mkdirSync(
|
|
23708
|
+
fs73.mkdirSync(path76.dirname(f2.out), { recursive: true });
|
|
23607
23709
|
fs73.writeFileSync(f2.out, f2.bytes);
|
|
23608
23710
|
}
|
|
23609
23711
|
say(`\u5DF2\u53D6\u56DE ${name}\uFF1A${fetched.length} \u4E2A\u6587\u4EF6\uFF0C\u4F4D\u4E8E ${to}
|
|
@@ -23621,7 +23723,7 @@ async function templateSource(name, opts) {
|
|
|
23621
23723
|
say(`evidence: ${e2.path}`);
|
|
23622
23724
|
continue;
|
|
23623
23725
|
}
|
|
23624
|
-
const out =
|
|
23726
|
+
const out = path76.join(opts.to, `${name}-${path76.basename(e2.path)}`);
|
|
23625
23727
|
fs73.mkdirSync(opts.to, { recursive: true });
|
|
23626
23728
|
fs73.writeFileSync(out, Buffer.from(await (await ask(`/${at2}/evidence/${route(e2.path)}`)).arrayBuffer()));
|
|
23627
23729
|
written.push(out);
|
|
@@ -23630,16 +23732,16 @@ async function templateSource(name, opts) {
|
|
|
23630
23732
|
return { name, source: source2, evidence: written.length > 0 ? written : evidence.map((e2) => e2.path) };
|
|
23631
23733
|
}
|
|
23632
23734
|
async function templatePublish(dir, opts) {
|
|
23633
|
-
const root2 =
|
|
23634
|
-
const manifest =
|
|
23735
|
+
const root2 = path76.resolve(dir);
|
|
23736
|
+
const manifest = path76.join(root2, "template.md");
|
|
23635
23737
|
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.");
|
|
23636
23738
|
const meta = readTemplateMeta(fs73.readFileSync(manifest, "utf8"));
|
|
23637
23739
|
const files = walk2(root2);
|
|
23638
|
-
const total = files.reduce((sum, f2) => sum + fs73.statSync(
|
|
23740
|
+
const total = files.reduce((sum, f2) => sum + fs73.statSync(path76.join(root2, f2)).size, 0);
|
|
23639
23741
|
if (total > MAX_BYTES2) invalid("\u6A21\u677F\u6587\u4EF6\u5408\u8BA1\u8D85\u8FC7 50 MB\u3002", "the template\u2019s files exceed 50 MB.");
|
|
23640
23742
|
for (const extra of [...opts.preview, ...opts.evidence]) {
|
|
23641
23743
|
if (!fs73.existsSync(extra)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${extra}\u3002`, `${extra} does not exist.`);
|
|
23642
|
-
if (
|
|
23744
|
+
if (path76.resolve(extra).startsWith(root2 + path76.sep)) {
|
|
23643
23745
|
invalid(
|
|
23644
23746
|
`${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`,
|
|
23645
23747
|
`${extra} is inside the template folder; keep previews and evidence outside it.`
|
|
@@ -23651,10 +23753,10 @@ async function templatePublish(dir, opts) {
|
|
|
23651
23753
|
}
|
|
23652
23754
|
const form = new FormData();
|
|
23653
23755
|
form.set("meta", JSON.stringify({ ...meta, replace: !!opts.replace }));
|
|
23654
|
-
const add2 = (kind, name, file2) => form.append(`${kind}:${name}`, new Blob([fs73.readFileSync(file2)]),
|
|
23655
|
-
for (const f2 of files) add2("files", f2,
|
|
23656
|
-
for (const f2 of opts.preview) add2("previews",
|
|
23657
|
-
for (const f2 of opts.evidence) add2("evidence",
|
|
23756
|
+
const add2 = (kind, name, file2) => form.append(`${kind}:${name}`, new Blob([fs73.readFileSync(file2)]), path76.basename(name));
|
|
23757
|
+
for (const f2 of files) add2("files", f2, path76.join(root2, f2));
|
|
23758
|
+
for (const f2 of opts.preview) add2("previews", path76.basename(f2), f2);
|
|
23759
|
+
for (const f2 of opts.evidence) add2("evidence", path76.basename(f2), f2);
|
|
23658
23760
|
const done = await asJson(await ask("", { method: "POST", body: form }));
|
|
23659
23761
|
say(
|
|
23660
23762
|
done.replaced ? `\u5DF2\u66FF\u6362 ${done.name}\uFF1A${files.length} \u4E2A\u6587\u4EF6\u3002
|
|
@@ -23670,7 +23772,7 @@ Deleted ${name} from the catalog.`);
|
|
|
23670
23772
|
return { name, deleted: true };
|
|
23671
23773
|
}
|
|
23672
23774
|
async function templateShowcase(name, dir) {
|
|
23673
|
-
const file2 =
|
|
23775
|
+
const file2 = path76.join(dir, "showcase.json");
|
|
23674
23776
|
if (!fs73.existsSync(file2)) invalid(`${dir} \u4E2D\u7F3A\u5C11 showcase.json\u3002`, `showcase.json is missing from ${dir}.`);
|
|
23675
23777
|
let meta;
|
|
23676
23778
|
try {
|
|
@@ -23686,7 +23788,7 @@ async function templateShowcase(name, dir) {
|
|
|
23686
23788
|
const form = new FormData();
|
|
23687
23789
|
form.set("meta", JSON.stringify(meta));
|
|
23688
23790
|
for (const p2 of new Set(named2)) {
|
|
23689
|
-
const at2 =
|
|
23791
|
+
const at2 = path76.join(dir, p2);
|
|
23690
23792
|
if (!fs73.existsSync(at2)) invalid(`\u627E\u4E0D\u5230\u6587\u4EF6 ${at2}\u3002`, `${at2} does not exist.`);
|
|
23691
23793
|
form.append(`media:${p2}`, new Blob([fs73.readFileSync(at2)]), p2);
|
|
23692
23794
|
}
|
|
@@ -23697,7 +23799,7 @@ Updated ${name}'s showcase: ${done.files} files.`);
|
|
|
23697
23799
|
}
|
|
23698
23800
|
function walk2(root2, sub = "") {
|
|
23699
23801
|
const out = [];
|
|
23700
|
-
for (const entry of fs73.readdirSync(
|
|
23802
|
+
for (const entry of fs73.readdirSync(path76.join(root2, sub), { withFileTypes: true })) {
|
|
23701
23803
|
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
23702
23804
|
const rel2 = sub ? `${sub}/${entry.name}` : entry.name;
|
|
23703
23805
|
if (entry.isDirectory()) out.push(...walk2(root2, rel2));
|
|
@@ -28189,7 +28291,7 @@ var init_guide2 = __esm({
|
|
|
28189
28291
|
// ../cli/src/commands/studio.ts
|
|
28190
28292
|
import crypto6 from "node:crypto";
|
|
28191
28293
|
import fs74 from "node:fs";
|
|
28192
|
-
import
|
|
28294
|
+
import path77 from "node:path";
|
|
28193
28295
|
function cmdStudioList() {
|
|
28194
28296
|
if (!studiosReachable().ok) die(NEEDS_CLOUD, "needs-cloud");
|
|
28195
28297
|
const offline2 = studiosOffline();
|
|
@@ -28218,7 +28320,7 @@ function cmdStudioList() {
|
|
|
28218
28320
|
};
|
|
28219
28321
|
}
|
|
28220
28322
|
function cmdStudioDiagram(id, card, folder) {
|
|
28221
|
-
const files = folder ? readStudioFolder(
|
|
28323
|
+
const files = folder ? readStudioFolder(path77.resolve(folder)) : null;
|
|
28222
28324
|
const local = files ? parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE) : null;
|
|
28223
28325
|
if (local && "problem" in local) die(local.problem, "bad-studio");
|
|
28224
28326
|
const flow = local && "def" in local ? local.def : found(id);
|
|
@@ -28228,8 +28330,8 @@ function cmdStudioDiagram(id, card, folder) {
|
|
|
28228
28330
|
const agent = findSpecAgent(name);
|
|
28229
28331
|
return agent ? { ...agent, after: agentAfter(name) } : null;
|
|
28230
28332
|
});
|
|
28231
|
-
const file2 =
|
|
28232
|
-
fs74.mkdirSync(
|
|
28333
|
+
const file2 = path77.join(ASSETS, String(cardId2), "studio.json");
|
|
28334
|
+
fs74.mkdirSync(path77.dirname(file2), { recursive: true });
|
|
28233
28335
|
fs74.writeFileSync(file2, `${JSON.stringify(diagram, null, 2)}
|
|
28234
28336
|
`);
|
|
28235
28337
|
const tag = `<Studio src=".assets/${cardId2}/studio.json" label="${flow.name.replace(/"/g, "")}" />`;
|
|
@@ -28237,7 +28339,7 @@ function cmdStudioDiagram(id, card, folder) {
|
|
|
28237
28339
|
return { file: file2, tag, diagram };
|
|
28238
28340
|
}
|
|
28239
28341
|
function cmdStudioValidate(folder) {
|
|
28240
|
-
const dir =
|
|
28342
|
+
const dir = path77.resolve(folder);
|
|
28241
28343
|
if (!fs74.statSync(dir, { throwIfNoEntry: false })?.isDirectory()) die(`${folder} is not a folder`, "bad-args");
|
|
28242
28344
|
const files = readStudioFolder(dir);
|
|
28243
28345
|
const read4 = parseStudioFile("studio", files[STUDIO_FILE] ?? "", STUDIO_FILE);
|
|
@@ -28266,14 +28368,14 @@ function cmdStudioValidate(folder) {
|
|
|
28266
28368
|
async function cmdStudioPull(id, folder) {
|
|
28267
28369
|
const cloudId = cloudIdOf(id);
|
|
28268
28370
|
if (!cloudId) found(id);
|
|
28269
|
-
const dir =
|
|
28371
|
+
const dir = path77.resolve(folder ?? id);
|
|
28270
28372
|
if (fs74.existsSync(dir) && fs74.readdirSync(dir).length) die(`${folder ?? id} is not empty`, "bad-args");
|
|
28271
28373
|
const read4 = await call("GET", `/v1/studios/${encodeURIComponent(cloudId)}`);
|
|
28272
28374
|
if (!read4.ok) die(read4.error, read4.code === "not_found" ? "no-such-studio" : "cloud-refused");
|
|
28273
28375
|
const { version, files } = read4.value;
|
|
28274
28376
|
for (const [file2, text6] of Object.entries({ ...files, [VERSION_FILE]: versionText(cloudId, version) })) {
|
|
28275
|
-
const full =
|
|
28276
|
-
fs74.mkdirSync(
|
|
28377
|
+
const full = path77.join(dir, ...file2.split("/"));
|
|
28378
|
+
fs74.mkdirSync(path77.dirname(full), { recursive: true });
|
|
28277
28379
|
const data = isAboutFile(file2) && !file2.endsWith(".md") && /^data:[^;]+;base64,/.exec(text6);
|
|
28278
28380
|
fs74.writeFileSync(full, data ? Buffer.from(text6.slice(data[0].length), "base64") : text6);
|
|
28279
28381
|
}
|
|
@@ -28287,7 +28389,7 @@ function publicationFiles(dir) {
|
|
|
28287
28389
|
return checked.files;
|
|
28288
28390
|
}
|
|
28289
28391
|
async function publishFolder(dir, route2, body, requestId) {
|
|
28290
|
-
const pendingFile =
|
|
28392
|
+
const pendingFile = path77.join(dir, ".publication.json");
|
|
28291
28393
|
const hash2 = crypto6.createHash("sha256").update(JSON.stringify({ route: route2, files: body.files, workspace: body.workspace })).digest("hex");
|
|
28292
28394
|
let held4;
|
|
28293
28395
|
try {
|
|
@@ -28303,29 +28405,29 @@ async function publishFolder(dir, route2, body, requestId) {
|
|
|
28303
28405
|
const { id, version } = res.value;
|
|
28304
28406
|
pending.resultVersion = version;
|
|
28305
28407
|
fs74.writeFileSync(pendingFile, JSON.stringify(pending, null, 2) + "\n");
|
|
28306
|
-
fs74.writeFileSync(
|
|
28408
|
+
fs74.writeFileSync(path77.join(dir, VERSION_FILE), versionText(id, version));
|
|
28307
28409
|
say(`Saved ${studioName(id)} v${version}. New tasks take it.`);
|
|
28308
28410
|
return { id, version, changed: true, requestId: pending.requestId };
|
|
28309
28411
|
}
|
|
28310
28412
|
async function cmdStudioCreate(folder, opts) {
|
|
28311
28413
|
if (!opts.requestId) die("--request-id is required", "bad-args");
|
|
28312
|
-
const dir =
|
|
28414
|
+
const dir = path77.resolve(folder);
|
|
28313
28415
|
const files = publicationFiles(dir);
|
|
28314
28416
|
const workspace2 = opts.workspace ?? (await cloudScope()).workspace;
|
|
28315
28417
|
return publishFolder(dir, "/v1/studios", { files, workspace: workspace2 }, opts.requestId);
|
|
28316
28418
|
}
|
|
28317
28419
|
async function cmdStudioPush(folder, opts) {
|
|
28318
|
-
const dir =
|
|
28420
|
+
const dir = path77.resolve(folder);
|
|
28319
28421
|
let pulled = null;
|
|
28320
28422
|
try {
|
|
28321
|
-
pulled = JSON.parse(fs74.readFileSync(
|
|
28423
|
+
pulled = JSON.parse(fs74.readFileSync(path77.join(dir, VERSION_FILE), "utf8"));
|
|
28322
28424
|
} catch {
|
|
28323
28425
|
}
|
|
28324
28426
|
if (!pulled?.id || !Number.isInteger(pulled.version) || pulled.version < 1) die(`${folder} has no valid version.json; pull again.`, "bad-args");
|
|
28325
28427
|
const { id, version } = pulled;
|
|
28326
28428
|
if (id.startsWith("wf_builtin_")) die("Copy this studio before editing it.", "studio-read-only");
|
|
28327
28429
|
const files = publicationFiles(dir);
|
|
28328
|
-
if (!fs74.existsSync(
|
|
28430
|
+
if (!fs74.existsSync(path77.join(dir, ".publication.json")) && !opts.requestId) {
|
|
28329
28431
|
const now = await call("GET", `/v1/studios/${encodeURIComponent(id)}`);
|
|
28330
28432
|
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()))) {
|
|
28331
28433
|
say(`${studioName(id)} is unchanged (v${version}).`);
|
|
@@ -28551,10 +28653,10 @@ var init_complete = __esm({
|
|
|
28551
28653
|
|
|
28552
28654
|
// ../cli/src/lib/agent/task-chats.ts
|
|
28553
28655
|
import fs75 from "node:fs";
|
|
28554
|
-
import
|
|
28656
|
+
import path78 from "node:path";
|
|
28555
28657
|
function taskChatFile(task, home3) {
|
|
28556
28658
|
if (!TASK.test(task)) throw new Error(`${task} is not a task id.`);
|
|
28557
|
-
return
|
|
28659
|
+
return path78.join(taskChatsDir(home3), `${task}.jsonl`);
|
|
28558
28660
|
}
|
|
28559
28661
|
function readTaskChat(task, home3) {
|
|
28560
28662
|
let text6;
|
|
@@ -28580,13 +28682,13 @@ var init_task_chats = __esm({
|
|
|
28580
28682
|
"use strict";
|
|
28581
28683
|
init_home();
|
|
28582
28684
|
TASK = /^[\w-]{1,100}$/;
|
|
28583
|
-
taskChatsDir = (home3 = machineHome()) =>
|
|
28685
|
+
taskChatsDir = (home3 = machineHome()) => path78.join(home3, "chats");
|
|
28584
28686
|
}
|
|
28585
28687
|
});
|
|
28586
28688
|
|
|
28587
28689
|
// ../cli/src/lib/agent/memory-review.ts
|
|
28588
28690
|
import fs76 from "node:fs";
|
|
28589
|
-
import
|
|
28691
|
+
import path79 from "node:path";
|
|
28590
28692
|
function taskChatsToReview(tasks) {
|
|
28591
28693
|
const out = [];
|
|
28592
28694
|
for (const ref of [...new Set(tasks)]) {
|
|
@@ -28608,7 +28710,7 @@ function readArchived2(id) {
|
|
|
28608
28710
|
const found2 = Number.isInteger(id) && id > 0 ? locateArchived(id) : null;
|
|
28609
28711
|
if (!found2) return null;
|
|
28610
28712
|
try {
|
|
28611
|
-
const file2 = found2.kind === "group" ?
|
|
28713
|
+
const file2 = found2.kind === "group" ? path79.join(found2.target, "root.md") : found2.target;
|
|
28612
28714
|
const { meta, body } = parseFrontmatter(fs76.readFileSync(file2, "utf8"));
|
|
28613
28715
|
if (!meta) return null;
|
|
28614
28716
|
return { id, title: meta.title, modules: meta.modules ?? [], rejected: meta.rejected, body };
|
|
@@ -28678,9 +28780,9 @@ var init_memory_review = __esm({
|
|
|
28678
28780
|
|
|
28679
28781
|
// ../cli/src/lib/agent/dismissal-review.ts
|
|
28680
28782
|
import fs77 from "node:fs";
|
|
28681
|
-
import
|
|
28783
|
+
import path80 from "node:path";
|
|
28682
28784
|
function rejectionsToReview() {
|
|
28683
|
-
const dir =
|
|
28785
|
+
const dir = path80.join(ARCHIVE, REJECTIONS_TO_REVIEW);
|
|
28684
28786
|
if (!fs77.existsSync(dir)) return [];
|
|
28685
28787
|
const found2 = [];
|
|
28686
28788
|
for (const file2 of walkMd(dir)) {
|
|
@@ -28743,7 +28845,7 @@ var init_dismissal_review = __esm({
|
|
|
28743
28845
|
|
|
28744
28846
|
// ../cli/src/lib/agent/flow.ts
|
|
28745
28847
|
import fs78 from "node:fs";
|
|
28746
|
-
import
|
|
28848
|
+
import path81 from "node:path";
|
|
28747
28849
|
function readCard2(id, home3 = "board") {
|
|
28748
28850
|
const pending = activeDelivery(id)?.completions?.some((c2) => !c2.finished);
|
|
28749
28851
|
const found2 = home3 === "archive" ? locateArchived(id) : locate2(id) ?? (pending ? locateArchived(id) : null);
|
|
@@ -28753,7 +28855,7 @@ function readCard2(id, home3 = "board") {
|
|
|
28753
28855
|
{ kind: "card-not-found", id }
|
|
28754
28856
|
);
|
|
28755
28857
|
}
|
|
28756
|
-
const file2 = found2.kind === "group" ?
|
|
28858
|
+
const file2 = found2.kind === "group" ? path81.join(found2.target, "root.md") : found2.target;
|
|
28757
28859
|
let text6;
|
|
28758
28860
|
try {
|
|
28759
28861
|
text6 = fs78.readFileSync(file2, "utf8");
|
|
@@ -29627,9 +29729,11 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
29627
29729
|
}
|
|
29628
29730
|
const stagePrompt = record.action === "spec" && record.cardId !== null && record.specAgent ? previewStagePrompt(record.cardId, record.specAgent, boardCommandFor(record.cardId)) : "";
|
|
29629
29731
|
const basePrompt = record.resumedFrom ? spec.prompt || resumePrompt(record.deliveryId, record.action) : spec.prompt;
|
|
29630
|
-
const
|
|
29732
|
+
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." : "";
|
|
29733
|
+
const prompt = [basePrompt, recoveryPrompt, basePrompt.includes(stagePrompt) ? "" : stagePrompt, discardedCardsPrompt(record.discardedCards)].filter(Boolean).join("\n\n");
|
|
29631
29734
|
const before = markBoard();
|
|
29632
29735
|
const takes = active3.images;
|
|
29736
|
+
active3.renderer?.setRequiredImages?.(record.pictures ?? []);
|
|
29633
29737
|
const shots = takes?.as === "args" ? (record.pictures ?? []).flatMap((file2) => takes.args(file2)) : [];
|
|
29634
29738
|
const [cmd, ...args2] = [...active3.argv, ...shots];
|
|
29635
29739
|
const workDir = active3.cwd ?? REPO_ROOT;
|
|
@@ -29734,6 +29838,8 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
29734
29838
|
};
|
|
29735
29839
|
let touch = () => {
|
|
29736
29840
|
};
|
|
29841
|
+
let endLimited = () => {
|
|
29842
|
+
};
|
|
29737
29843
|
child.stdout.on("data", (d2) => {
|
|
29738
29844
|
if (renderer) {
|
|
29739
29845
|
append2(renderer.push(d2.toString()));
|
|
@@ -29742,6 +29848,7 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
29742
29848
|
gotModel(renderer.model?.());
|
|
29743
29849
|
gotContext(renderer.context?.());
|
|
29744
29850
|
afterTurn();
|
|
29851
|
+
if (renderer.rateLimit?.()) endLimited();
|
|
29745
29852
|
}
|
|
29746
29853
|
touch();
|
|
29747
29854
|
});
|
|
@@ -29749,6 +29856,7 @@ async function watchRun(sessionId, resume = startResume) {
|
|
|
29749
29856
|
child.stderr.on("data", (d2) => {
|
|
29750
29857
|
touch();
|
|
29751
29858
|
renderer?.stderr?.(d2.toString());
|
|
29859
|
+
if (renderer?.rateLimit?.()) endLimited();
|
|
29752
29860
|
const text6 = errs.push(d2.toString());
|
|
29753
29861
|
if (text6) log.write(text6);
|
|
29754
29862
|
});
|
|
@@ -29963,6 +30071,7 @@ ${result}
|
|
|
29963
30071
|
void finish(null, asked).finally(() => process.exit(0));
|
|
29964
30072
|
});
|
|
29965
30073
|
};
|
|
30074
|
+
endLimited = () => giveUp(false);
|
|
29966
30075
|
const cancellation = new AbortController();
|
|
29967
30076
|
let stopped2 = false;
|
|
29968
30077
|
const askToStop = () => {
|
|
@@ -30149,7 +30258,7 @@ var init_watch = __esm({
|
|
|
30149
30258
|
|
|
30150
30259
|
// ../cli/src/commands/run.ts
|
|
30151
30260
|
import fs80 from "node:fs";
|
|
30152
|
-
import
|
|
30261
|
+
import path82 from "node:path";
|
|
30153
30262
|
async function cmdStartRun(action, args2, opts, program2 = "akb") {
|
|
30154
30263
|
if (action === "approve" && (opts.preview || opts.previewStage || opts.previewVersion || opts.definitionRevision)) return confirmLocalPreview(Number(args2[0]), opts);
|
|
30155
30264
|
const { req, follow: follow2, print } = readRequest(action, args2, opts);
|
|
@@ -30377,7 +30486,7 @@ async function cmdSubStart(words, opts) {
|
|
|
30377
30486
|
let prompt = words.join(" ");
|
|
30378
30487
|
if (opts.file) {
|
|
30379
30488
|
try {
|
|
30380
|
-
prompt = fs80.readFileSync(
|
|
30489
|
+
prompt = fs80.readFileSync(path82.resolve(opts.file), "utf8");
|
|
30381
30490
|
} catch {
|
|
30382
30491
|
die(`--file: cannot read ${opts.file}`, { kind: "run-refused" });
|
|
30383
30492
|
}
|
|
@@ -30711,7 +30820,7 @@ var init_config3 = __esm({
|
|
|
30711
30820
|
|
|
30712
30821
|
// ../cli/src/lib/signals/migrate.ts
|
|
30713
30822
|
import fs81 from "node:fs";
|
|
30714
|
-
import
|
|
30823
|
+
import path83 from "node:path";
|
|
30715
30824
|
function readHandled() {
|
|
30716
30825
|
let text6;
|
|
30717
30826
|
try {
|
|
@@ -30733,7 +30842,7 @@ function readHandled() {
|
|
|
30733
30842
|
}
|
|
30734
30843
|
function lift(from, into) {
|
|
30735
30844
|
fs81.mkdirSync(into, { recursive: true });
|
|
30736
|
-
fs81.renameSync(from,
|
|
30845
|
+
fs81.renameSync(from, path83.join(into, freeName(into, path83.basename(from))));
|
|
30737
30846
|
}
|
|
30738
30847
|
function repoint(dir, from, into) {
|
|
30739
30848
|
let entries;
|
|
@@ -30744,7 +30853,7 @@ function repoint(dir, from, into) {
|
|
|
30744
30853
|
}
|
|
30745
30854
|
for (const entry of entries) {
|
|
30746
30855
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
30747
|
-
const file2 =
|
|
30856
|
+
const file2 = path83.join(dir, entry.name);
|
|
30748
30857
|
const text6 = fs81.readFileSync(file2, "utf8");
|
|
30749
30858
|
if (text6.includes(from)) fs81.writeFileSync(file2, text6.split(from).join(into));
|
|
30750
30859
|
}
|
|
@@ -30757,17 +30866,17 @@ function dropIfEmpty(dir) {
|
|
|
30757
30866
|
}
|
|
30758
30867
|
function liftInbox() {
|
|
30759
30868
|
if (!fs81.existsSync(SIGNALS_OLD_INBOX)) return;
|
|
30760
|
-
const oldFiles =
|
|
30869
|
+
const oldFiles = path83.join(SIGNALS_OLD_INBOX, "files");
|
|
30761
30870
|
if (fs81.existsSync(oldFiles)) {
|
|
30762
30871
|
for (const entry of fs81.readdirSync(oldFiles, { withFileTypes: true })) {
|
|
30763
|
-
if (entry.isFile()) lift(
|
|
30872
|
+
if (entry.isFile()) lift(path83.join(oldFiles, entry.name), SIGNALS_FILES);
|
|
30764
30873
|
}
|
|
30765
30874
|
dropIfEmpty(oldFiles);
|
|
30766
30875
|
}
|
|
30767
30876
|
const held4 = new Set(readFolder(TRIAGE).map((signal2) => signal2.sourceId));
|
|
30768
30877
|
for (const entry of fs81.readdirSync(SIGNALS_OLD_INBOX, { withFileTypes: true })) {
|
|
30769
30878
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
30770
|
-
const from =
|
|
30879
|
+
const from = path83.join(SIGNALS_OLD_INBOX, entry.name);
|
|
30771
30880
|
const item = parse(from);
|
|
30772
30881
|
if (item && held4.has(item.sourceId)) {
|
|
30773
30882
|
fs81.rmSync(from, { force: true });
|
|
@@ -30776,7 +30885,7 @@ function liftInbox() {
|
|
|
30776
30885
|
if (item) held4.add(item.sourceId);
|
|
30777
30886
|
lift(from, TRIAGE);
|
|
30778
30887
|
}
|
|
30779
|
-
const wasAt = asWritten(
|
|
30888
|
+
const wasAt = asWritten(path83.join(SIGNALS_OLD_INBOX, "files"));
|
|
30780
30889
|
const nowAt = asWritten(SIGNALS_FILES);
|
|
30781
30890
|
for (const dir of [TRIAGE, SIGNALS_ARCHIVED, SIGNALS_DISMISSED]) repoint(dir, wasAt, nowAt);
|
|
30782
30891
|
dropIfEmpty(SIGNALS_OLD_INBOX);
|
|
@@ -30802,7 +30911,7 @@ function liftHandled() {
|
|
|
30802
30911
|
"---",
|
|
30803
30912
|
""
|
|
30804
30913
|
];
|
|
30805
|
-
fs81.writeFileSync(
|
|
30914
|
+
fs81.writeFileSync(path83.join(SIGNALS_DISMISSED, name), `${front.join("\n")}
|
|
30806
30915
|
`);
|
|
30807
30916
|
}
|
|
30808
30917
|
fs81.rmSync(SIGNALS_OLD_HANDLED, { force: true });
|
|
@@ -30823,7 +30932,7 @@ var init_migrate = __esm({
|
|
|
30823
30932
|
init_yaml();
|
|
30824
30933
|
init_inbox();
|
|
30825
30934
|
HANDLED_LINE = /^-\s+(.+?)\s+—\s+(.+)$/;
|
|
30826
|
-
asWritten = (dir) => `${rel(dir).split(
|
|
30935
|
+
asWritten = (dir) => `${rel(dir).split(path83.sep).join("/")}/`;
|
|
30827
30936
|
}
|
|
30828
30937
|
});
|
|
30829
30938
|
|
|
@@ -30877,7 +30986,7 @@ var init_identity2 = __esm({
|
|
|
30877
30986
|
|
|
30878
30987
|
// ../cli/src/lib/signals/add.ts
|
|
30879
30988
|
import fs82 from "node:fs";
|
|
30880
|
-
import
|
|
30989
|
+
import path84 from "node:path";
|
|
30881
30990
|
import { createHash as createHash9 } from "node:crypto";
|
|
30882
30991
|
function linkTitle(url) {
|
|
30883
30992
|
let at2;
|
|
@@ -30890,7 +30999,7 @@ function linkTitle(url) {
|
|
|
30890
30999
|
return oneLine(where) || url.slice(0, TITLE_MAX);
|
|
30891
31000
|
}
|
|
30892
31001
|
function asText(file2) {
|
|
30893
|
-
const ext =
|
|
31002
|
+
const ext = path84.extname(file2.name).toLowerCase();
|
|
30894
31003
|
if (!file2.type.startsWith("text/") && file2.type !== "application/json" && !TEXT_EXTENSIONS.has(ext)) return null;
|
|
30895
31004
|
try {
|
|
30896
31005
|
const text6 = new TextDecoder("utf-8", { fatal: true }).decode(file2.data);
|
|
@@ -30900,9 +31009,9 @@ function asText(file2) {
|
|
|
30900
31009
|
}
|
|
30901
31010
|
}
|
|
30902
31011
|
function fileName2(name, data) {
|
|
30903
|
-
const base =
|
|
30904
|
-
const ext =
|
|
30905
|
-
const word =
|
|
31012
|
+
const base = path84.basename(name);
|
|
31013
|
+
const ext = path84.extname(base).toLowerCase().slice(0, 12);
|
|
31014
|
+
const word = path84.basename(base, path84.extname(base)).toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || "file";
|
|
30906
31015
|
const hash2 = createHash9("sha256").update(data).digest("hex").slice(0, 8);
|
|
30907
31016
|
return `${word}-${hash2}${ext}`;
|
|
30908
31017
|
}
|
|
@@ -30911,9 +31020,9 @@ function addToInbox(drop) {
|
|
|
30911
31020
|
const typed = (drop.text ?? "").trim();
|
|
30912
31021
|
const file2 = drop.file;
|
|
30913
31022
|
if (!typed && !file2) return { ok: false, error: "nothing to add \u2014 paste a link or some text, or drop a file." };
|
|
30914
|
-
if (file2 && file2.data.length === 0) return { ok: false, error: `${
|
|
31023
|
+
if (file2 && file2.data.length === 0) return { ok: false, error: `${path84.basename(file2.name)} is empty.` };
|
|
30915
31024
|
if (file2 && file2.data.length > MAX_BYTES3) {
|
|
30916
|
-
return { ok: false, error: `${
|
|
31025
|
+
return { ok: false, error: `${path84.basename(file2.name)} is over ${MAX_BYTES3 / 1024 / 1024} MB \u2014 too big for the board.` };
|
|
30917
31026
|
}
|
|
30918
31027
|
const read4 = describe(typed, file2);
|
|
30919
31028
|
const keep2 = read4.keep;
|
|
@@ -30950,7 +31059,7 @@ function describe(typed, file2) {
|
|
|
30950
31059
|
return only ? [only] : [];
|
|
30951
31060
|
};
|
|
30952
31061
|
if (file2) {
|
|
30953
|
-
const name =
|
|
31062
|
+
const name = path84.basename(file2.name);
|
|
30954
31063
|
const text6 = asText(file2);
|
|
30955
31064
|
const note = typed ? `
|
|
30956
31065
|
|
|
@@ -30962,7 +31071,7 @@ ${typed}` : "";
|
|
|
30962
31071
|
const at2 = keepAt(file2);
|
|
30963
31072
|
return {
|
|
30964
31073
|
incoming: {
|
|
30965
|
-
title:
|
|
31074
|
+
title: path84.basename(name, path84.extname(name)) || name,
|
|
30966
31075
|
summary: `${name} \u2014 ${boardRel2(at2)}${note}`,
|
|
30967
31076
|
...named2
|
|
30968
31077
|
},
|
|
@@ -31000,13 +31109,13 @@ var init_add = __esm({
|
|
|
31000
31109
|
MAX_BYTES3 = 25 * 1024 * 1024;
|
|
31001
31110
|
TITLE_MAX = 120;
|
|
31002
31111
|
TEXT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".text", ".csv", ".json", ".yml", ".yaml", ".log"]);
|
|
31003
|
-
boardRel2 = (file2) => rel(file2).split(
|
|
31112
|
+
boardRel2 = (file2) => rel(file2).split(path84.sep).join("/");
|
|
31004
31113
|
oneLine = (text6) => {
|
|
31005
31114
|
const first = text6.split("\n").find((line) => line.trim()) ?? "";
|
|
31006
31115
|
const clean = first.replace(/^#+\s*/, "").trim();
|
|
31007
31116
|
return clean.length > TITLE_MAX ? `${clean.slice(0, TITLE_MAX - 1).trimEnd()}\u2026` : clean;
|
|
31008
31117
|
};
|
|
31009
|
-
keepAt = (file2) =>
|
|
31118
|
+
keepAt = (file2) => path84.join(SIGNALS_FILES, fileName2(file2.name, file2.data));
|
|
31010
31119
|
}
|
|
31011
31120
|
});
|
|
31012
31121
|
|
|
@@ -72445,8 +72554,8 @@ var require_JSXTransformer = __commonJS({
|
|
|
72445
72554
|
}
|
|
72446
72555
|
if (this.isAutomaticRuntime) {
|
|
72447
72556
|
if (this.importProcessor) {
|
|
72448
|
-
for (const [
|
|
72449
|
-
prefix += `var ${resolvedName} = require("${
|
|
72557
|
+
for (const [path89, resolvedName] of Object.entries(this.cjsAutomaticModuleNameResolutions)) {
|
|
72558
|
+
prefix += `var ${resolvedName} = require("${path89}");`;
|
|
72450
72559
|
}
|
|
72451
72560
|
} else {
|
|
72452
72561
|
const { createElement: createElementResolution, ...otherResolutions } = this.esmAutomaticImportNameResolutions;
|
|
@@ -72639,11 +72748,11 @@ var require_JSXTransformer = __commonJS({
|
|
|
72639
72748
|
}
|
|
72640
72749
|
claimAutoImportedName(funcName, importPathSuffix) {
|
|
72641
72750
|
if (this.importProcessor) {
|
|
72642
|
-
const
|
|
72643
|
-
if (!this.cjsAutomaticModuleNameResolutions[
|
|
72644
|
-
this.cjsAutomaticModuleNameResolutions[
|
|
72751
|
+
const path89 = this.jsxImportSource + importPathSuffix;
|
|
72752
|
+
if (!this.cjsAutomaticModuleNameResolutions[path89]) {
|
|
72753
|
+
this.cjsAutomaticModuleNameResolutions[path89] = this.importProcessor.getFreeIdentifierForPath(path89);
|
|
72645
72754
|
}
|
|
72646
|
-
return `${this.cjsAutomaticModuleNameResolutions[
|
|
72755
|
+
return `${this.cjsAutomaticModuleNameResolutions[path89]}.${funcName}`;
|
|
72647
72756
|
} else {
|
|
72648
72757
|
if (!this.esmAutomaticImportNameResolutions[funcName]) {
|
|
72649
72758
|
this.esmAutomaticImportNameResolutions[funcName] = this.nameManager.claimFreeName(
|
|
@@ -73079,7 +73188,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73079
73188
|
*/
|
|
73080
73189
|
pruneTypeOnlyImports() {
|
|
73081
73190
|
this.nonTypeIdentifiers = _getNonTypeIdentifiers.getNonTypeIdentifiers.call(void 0, this.tokens, this.options);
|
|
73082
|
-
for (const [
|
|
73191
|
+
for (const [path89, importInfo] of this.importInfoByPath.entries()) {
|
|
73083
73192
|
if (importInfo.hasBareImport || importInfo.hasStarExport || importInfo.exportStarNames.length > 0 || importInfo.namedExports.length > 0) {
|
|
73084
73193
|
continue;
|
|
73085
73194
|
}
|
|
@@ -73089,7 +73198,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73089
73198
|
...importInfo.namedImports.map(({ localName }) => localName)
|
|
73090
73199
|
];
|
|
73091
73200
|
if (names3.every((name) => this.shouldAutomaticallyElideImportedName(name))) {
|
|
73092
|
-
this.importsToReplace.set(
|
|
73201
|
+
this.importsToReplace.set(path89, "");
|
|
73093
73202
|
}
|
|
73094
73203
|
}
|
|
73095
73204
|
}
|
|
@@ -73097,7 +73206,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73097
73206
|
return this.isTypeScriptTransformEnabled && !this.keepUnusedImports && !this.nonTypeIdentifiers.has(name);
|
|
73098
73207
|
}
|
|
73099
73208
|
generateImportReplacements() {
|
|
73100
|
-
for (const [
|
|
73209
|
+
for (const [path89, importInfo] of this.importInfoByPath.entries()) {
|
|
73101
73210
|
const {
|
|
73102
73211
|
defaultNames,
|
|
73103
73212
|
wildcardNames,
|
|
@@ -73107,17 +73216,17 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73107
73216
|
hasStarExport
|
|
73108
73217
|
} = importInfo;
|
|
73109
73218
|
if (defaultNames.length === 0 && wildcardNames.length === 0 && namedImports.length === 0 && namedExports.length === 0 && exportStarNames.length === 0 && !hasStarExport) {
|
|
73110
|
-
this.importsToReplace.set(
|
|
73219
|
+
this.importsToReplace.set(path89, `require('${path89}');`);
|
|
73111
73220
|
continue;
|
|
73112
73221
|
}
|
|
73113
|
-
const primaryImportName = this.getFreeIdentifierForPath(
|
|
73222
|
+
const primaryImportName = this.getFreeIdentifierForPath(path89);
|
|
73114
73223
|
let secondaryImportName;
|
|
73115
73224
|
if (this.enableLegacyTypeScriptModuleInterop) {
|
|
73116
73225
|
secondaryImportName = primaryImportName;
|
|
73117
73226
|
} else {
|
|
73118
|
-
secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(
|
|
73227
|
+
secondaryImportName = wildcardNames.length > 0 ? wildcardNames[0] : this.getFreeIdentifierForPath(path89);
|
|
73119
73228
|
}
|
|
73120
|
-
let requireCode = `var ${primaryImportName} = require('${
|
|
73229
|
+
let requireCode = `var ${primaryImportName} = require('${path89}');`;
|
|
73121
73230
|
if (wildcardNames.length > 0) {
|
|
73122
73231
|
for (const wildcardName of wildcardNames) {
|
|
73123
73232
|
const moduleExpr = this.enableLegacyTypeScriptModuleInterop ? primaryImportName : `${this.helperManager.getHelperName("interopRequireWildcard")}(${primaryImportName})`;
|
|
@@ -73145,7 +73254,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73145
73254
|
"createStarExport"
|
|
73146
73255
|
)}(${primaryImportName});`;
|
|
73147
73256
|
}
|
|
73148
|
-
this.importsToReplace.set(
|
|
73257
|
+
this.importsToReplace.set(path89, requireCode);
|
|
73149
73258
|
for (const defaultName of defaultNames) {
|
|
73150
73259
|
this.identifierReplacements.set(defaultName, `${secondaryImportName}.default`);
|
|
73151
73260
|
}
|
|
@@ -73154,8 +73263,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73154
73263
|
}
|
|
73155
73264
|
}
|
|
73156
73265
|
}
|
|
73157
|
-
getFreeIdentifierForPath(
|
|
73158
|
-
const components =
|
|
73266
|
+
getFreeIdentifierForPath(path89) {
|
|
73267
|
+
const components = path89.split("/");
|
|
73159
73268
|
const lastComponent = components[components.length - 1];
|
|
73160
73269
|
const baseName = lastComponent.replace(/\W/g, "");
|
|
73161
73270
|
return this.nameManager.claimFreeName(`_${baseName}`);
|
|
@@ -73200,8 +73309,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73200
73309
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
73201
73310
|
throw new Error("Expected string token at the end of import statement.");
|
|
73202
73311
|
}
|
|
73203
|
-
const
|
|
73204
|
-
const importInfo = this.getImportInfo(
|
|
73312
|
+
const path89 = this.tokens.stringValueAtIndex(index);
|
|
73313
|
+
const importInfo = this.getImportInfo(path89);
|
|
73205
73314
|
importInfo.defaultNames.push(...defaultNames);
|
|
73206
73315
|
importInfo.wildcardNames.push(...wildcardNames);
|
|
73207
73316
|
importInfo.namedImports.push(...namedImports);
|
|
@@ -73268,8 +73377,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73268
73377
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
73269
73378
|
throw new Error("Expected string token at the end of import statement.");
|
|
73270
73379
|
}
|
|
73271
|
-
const
|
|
73272
|
-
const importInfo = this.getImportInfo(
|
|
73380
|
+
const path89 = this.tokens.stringValueAtIndex(index);
|
|
73381
|
+
const importInfo = this.getImportInfo(path89);
|
|
73273
73382
|
importInfo.namedExports.push(...namedImports);
|
|
73274
73383
|
}
|
|
73275
73384
|
preprocessExportStarAtIndex(index) {
|
|
@@ -73284,8 +73393,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73284
73393
|
if (!this.tokens.matches1AtIndex(index, _types.TokenType.string)) {
|
|
73285
73394
|
throw new Error("Expected string token at the end of star export statement.");
|
|
73286
73395
|
}
|
|
73287
|
-
const
|
|
73288
|
-
const importInfo = this.getImportInfo(
|
|
73396
|
+
const path89 = this.tokens.stringValueAtIndex(index);
|
|
73397
|
+
const importInfo = this.getImportInfo(path89);
|
|
73289
73398
|
if (exportedName !== null) {
|
|
73290
73399
|
importInfo.exportStarNames.push(exportedName);
|
|
73291
73400
|
} else {
|
|
@@ -73325,8 +73434,8 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73325
73434
|
* Get a mutable import info object for this path, creating one if it doesn't
|
|
73326
73435
|
* exist yet.
|
|
73327
73436
|
*/
|
|
73328
|
-
getImportInfo(
|
|
73329
|
-
const existingInfo = this.importInfoByPath.get(
|
|
73437
|
+
getImportInfo(path89) {
|
|
73438
|
+
const existingInfo = this.importInfoByPath.get(path89);
|
|
73330
73439
|
if (existingInfo) {
|
|
73331
73440
|
return existingInfo;
|
|
73332
73441
|
}
|
|
@@ -73339,7 +73448,7 @@ var require_CJSImportProcessor = __commonJS({
|
|
|
73339
73448
|
exportStarNames: [],
|
|
73340
73449
|
hasStarExport: false
|
|
73341
73450
|
};
|
|
73342
|
-
this.importInfoByPath.set(
|
|
73451
|
+
this.importInfoByPath.set(path89, newInfo);
|
|
73343
73452
|
return newInfo;
|
|
73344
73453
|
}
|
|
73345
73454
|
addExportBinding(localName, exportedName) {
|
|
@@ -73919,16 +74028,16 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
73919
74028
|
}
|
|
73920
74029
|
function parseFileUrl(input) {
|
|
73921
74030
|
const match = fileRegex.exec(input);
|
|
73922
|
-
const
|
|
73923
|
-
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(
|
|
74031
|
+
const path89 = match[2];
|
|
74032
|
+
return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path89) ? path89 : "/" + path89, match[3] || "", match[4] || "");
|
|
73924
74033
|
}
|
|
73925
|
-
function makeUrl(scheme, user, host2, port,
|
|
74034
|
+
function makeUrl(scheme, user, host2, port, path89, query, hash2) {
|
|
73926
74035
|
return {
|
|
73927
74036
|
scheme,
|
|
73928
74037
|
user,
|
|
73929
74038
|
host: host2,
|
|
73930
74039
|
port,
|
|
73931
|
-
path:
|
|
74040
|
+
path: path89,
|
|
73932
74041
|
query,
|
|
73933
74042
|
hash: hash2,
|
|
73934
74043
|
type: 7
|
|
@@ -73958,11 +74067,11 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
73958
74067
|
url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
|
|
73959
74068
|
return url;
|
|
73960
74069
|
}
|
|
73961
|
-
function stripPathFilename(
|
|
73962
|
-
if (
|
|
73963
|
-
return
|
|
73964
|
-
const index =
|
|
73965
|
-
return
|
|
74070
|
+
function stripPathFilename(path89) {
|
|
74071
|
+
if (path89.endsWith("/.."))
|
|
74072
|
+
return path89;
|
|
74073
|
+
const index = path89.lastIndexOf("/");
|
|
74074
|
+
return path89.slice(0, index + 1);
|
|
73966
74075
|
}
|
|
73967
74076
|
function mergePaths(url, base) {
|
|
73968
74077
|
normalizePath(base, base.type);
|
|
@@ -74000,14 +74109,14 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
74000
74109
|
pieces[pointer++] = piece;
|
|
74001
74110
|
positive++;
|
|
74002
74111
|
}
|
|
74003
|
-
let
|
|
74112
|
+
let path89 = "";
|
|
74004
74113
|
for (let i = 1; i < pointer; i++) {
|
|
74005
|
-
|
|
74114
|
+
path89 += "/" + pieces[i];
|
|
74006
74115
|
}
|
|
74007
|
-
if (!
|
|
74008
|
-
|
|
74116
|
+
if (!path89 || addTrailingSlash && !path89.endsWith("/..")) {
|
|
74117
|
+
path89 += "/";
|
|
74009
74118
|
}
|
|
74010
|
-
url.path =
|
|
74119
|
+
url.path = path89;
|
|
74011
74120
|
}
|
|
74012
74121
|
function resolve2(input, base) {
|
|
74013
74122
|
if (!input && !base)
|
|
@@ -74048,13 +74157,13 @@ var require_resolve_uri_umd = __commonJS({
|
|
|
74048
74157
|
case 3:
|
|
74049
74158
|
return queryHash;
|
|
74050
74159
|
case 4: {
|
|
74051
|
-
const
|
|
74052
|
-
if (!
|
|
74160
|
+
const path89 = url.path.slice(1);
|
|
74161
|
+
if (!path89)
|
|
74053
74162
|
return queryHash || ".";
|
|
74054
|
-
if (isRelative(base || input) && !isRelative(
|
|
74055
|
-
return "./" +
|
|
74163
|
+
if (isRelative(base || input) && !isRelative(path89)) {
|
|
74164
|
+
return "./" + path89 + queryHash;
|
|
74056
74165
|
}
|
|
74057
|
-
return
|
|
74166
|
+
return path89 + queryHash;
|
|
74058
74167
|
}
|
|
74059
74168
|
case 5:
|
|
74060
74169
|
return url.path + queryHash;
|
|
@@ -74153,10 +74262,10 @@ var require_trace_mapping_umd = __commonJS({
|
|
|
74153
74262
|
module2.exports = __toCommonJS(trace_mapping_exports);
|
|
74154
74263
|
var import_sourcemap_codec = __toESM2(require_sourcemap_codec());
|
|
74155
74264
|
var import_resolve_uri = __toESM2(require_resolve_uri());
|
|
74156
|
-
function stripFilename(
|
|
74157
|
-
if (!
|
|
74158
|
-
const index =
|
|
74159
|
-
return
|
|
74265
|
+
function stripFilename(path89) {
|
|
74266
|
+
if (!path89) return "";
|
|
74267
|
+
const index = path89.lastIndexOf("/");
|
|
74268
|
+
return path89.slice(0, index + 1);
|
|
74160
74269
|
}
|
|
74161
74270
|
function resolver2(mapUrl, sourceRoot) {
|
|
74162
74271
|
const from = stripFilename(mapUrl);
|
|
@@ -75364,9 +75473,9 @@ var require_util2 = __commonJS({
|
|
|
75364
75473
|
/** @class */
|
|
75365
75474
|
(function(_super) {
|
|
75366
75475
|
__extends(VError2, _super);
|
|
75367
|
-
function VError2(
|
|
75476
|
+
function VError2(path89, message) {
|
|
75368
75477
|
var _this = _super.call(this, message) || this;
|
|
75369
|
-
_this.path =
|
|
75478
|
+
_this.path = path89;
|
|
75370
75479
|
Object.setPrototypeOf(_this, VError2.prototype);
|
|
75371
75480
|
return _this;
|
|
75372
75481
|
}
|
|
@@ -75426,26 +75535,26 @@ var require_util2 = __commonJS({
|
|
|
75426
75535
|
(_b = this._messages).push.apply(_b, best._messages);
|
|
75427
75536
|
}
|
|
75428
75537
|
};
|
|
75429
|
-
DetailContext2.prototype.getError = function(
|
|
75538
|
+
DetailContext2.prototype.getError = function(path89) {
|
|
75430
75539
|
var msgParts = [];
|
|
75431
75540
|
for (var i = this._propNames.length - 1; i >= 0; i--) {
|
|
75432
75541
|
var p2 = this._propNames[i];
|
|
75433
|
-
|
|
75542
|
+
path89 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
|
|
75434
75543
|
var m = this._messages[i];
|
|
75435
75544
|
if (m) {
|
|
75436
|
-
msgParts.push(
|
|
75545
|
+
msgParts.push(path89 + " " + m);
|
|
75437
75546
|
}
|
|
75438
75547
|
}
|
|
75439
|
-
return new VError(
|
|
75548
|
+
return new VError(path89, msgParts.join("; "));
|
|
75440
75549
|
};
|
|
75441
|
-
DetailContext2.prototype.getErrorDetail = function(
|
|
75550
|
+
DetailContext2.prototype.getErrorDetail = function(path89) {
|
|
75442
75551
|
var details = [];
|
|
75443
75552
|
for (var i = this._propNames.length - 1; i >= 0; i--) {
|
|
75444
75553
|
var p2 = this._propNames[i];
|
|
75445
|
-
|
|
75554
|
+
path89 += typeof p2 === "number" ? "[" + p2 + "]" : p2 ? "." + p2 : "";
|
|
75446
75555
|
var message = this._messages[i];
|
|
75447
75556
|
if (message) {
|
|
75448
|
-
details.push({ path:
|
|
75557
|
+
details.push({ path: path89, message });
|
|
75449
75558
|
}
|
|
75450
75559
|
}
|
|
75451
75560
|
var detail = null;
|
|
@@ -76258,8 +76367,8 @@ var require_dist = __commonJS({
|
|
|
76258
76367
|
this.checkerPlain = this.ttype.getChecker(suite, false);
|
|
76259
76368
|
this.checkerStrict = this.ttype.getChecker(suite, true);
|
|
76260
76369
|
}
|
|
76261
|
-
Checker2.prototype.setReportedPath = function(
|
|
76262
|
-
this._path =
|
|
76370
|
+
Checker2.prototype.setReportedPath = function(path89) {
|
|
76371
|
+
this._path = path89;
|
|
76263
76372
|
};
|
|
76264
76373
|
Checker2.prototype.check = function(value) {
|
|
76265
76374
|
return this._doCheck(this.checkerPlain, value);
|
|
@@ -81692,9 +81801,9 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
81692
81801
|
if (shouldElideImport) {
|
|
81693
81802
|
this.tokens.removeToken();
|
|
81694
81803
|
} else {
|
|
81695
|
-
const
|
|
81696
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
81697
|
-
this.tokens.appendCode(this.importProcessor.claimImportCode(
|
|
81804
|
+
const path89 = this.tokens.stringValue();
|
|
81805
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path89));
|
|
81806
|
+
this.tokens.appendCode(this.importProcessor.claimImportCode(path89));
|
|
81698
81807
|
}
|
|
81699
81808
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
81700
81809
|
if (this.tokens.matches1(_types.TokenType.semi)) {
|
|
@@ -82274,8 +82383,8 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
82274
82383
|
}
|
|
82275
82384
|
if (this.tokens.matchesContextual(_keywords.ContextualKeyword._from)) {
|
|
82276
82385
|
this.tokens.removeToken();
|
|
82277
|
-
const
|
|
82278
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
82386
|
+
const path89 = this.tokens.stringValue();
|
|
82387
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path89));
|
|
82279
82388
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
82280
82389
|
} else {
|
|
82281
82390
|
this.tokens.appendCode(exportStatements.join(" "));
|
|
@@ -82289,8 +82398,8 @@ var require_CJSImportTransformer = __commonJS({
|
|
|
82289
82398
|
while (!this.tokens.matches1(_types.TokenType.string)) {
|
|
82290
82399
|
this.tokens.removeToken();
|
|
82291
82400
|
}
|
|
82292
|
-
const
|
|
82293
|
-
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(
|
|
82401
|
+
const path89 = this.tokens.stringValue();
|
|
82402
|
+
this.tokens.replaceTokenTrimmingLeftWhitespace(this.importProcessor.claimImportCode(path89));
|
|
82294
82403
|
_removeMaybeImportAttributes.removeMaybeImportAttributes.call(void 0, this.tokens);
|
|
82295
82404
|
if (this.tokens.matches1(_types.TokenType.semi)) {
|
|
82296
82405
|
this.tokens.removeToken();
|
|
@@ -112144,9 +112253,9 @@ var init_bundle_mjs = __esm({
|
|
|
112144
112253
|
processClassesRecursively(value, getPart(classPartObject, key), classGroupId, theme);
|
|
112145
112254
|
}
|
|
112146
112255
|
};
|
|
112147
|
-
getPart = (classPartObject,
|
|
112256
|
+
getPart = (classPartObject, path89) => {
|
|
112148
112257
|
let current = classPartObject;
|
|
112149
|
-
const parts =
|
|
112258
|
+
const parts = path89.split(CLASS_PART_SEPARATOR);
|
|
112150
112259
|
const len = parts.length;
|
|
112151
112260
|
for (let i = 0; i < len; i++) {
|
|
112152
112261
|
const part = parts[i];
|
|
@@ -115397,7 +115506,7 @@ var init_dist = __esm({
|
|
|
115397
115506
|
|
|
115398
115507
|
// ../cli/src/lib/draw-mockup.ts
|
|
115399
115508
|
import fs84 from "node:fs";
|
|
115400
|
-
import
|
|
115509
|
+
import path85 from "node:path";
|
|
115401
115510
|
import vm from "node:vm";
|
|
115402
115511
|
async function loadPackage(id) {
|
|
115403
115512
|
if (id === "react") return import_react3.default;
|
|
@@ -115410,16 +115519,16 @@ async function loadPackage(id) {
|
|
|
115410
115519
|
return { __esModule: true, ...await load() };
|
|
115411
115520
|
}
|
|
115412
115521
|
function resolveFile(id, from, folder) {
|
|
115413
|
-
const at2 =
|
|
115414
|
-
if (at2 !== folder && !at2.startsWith(folder +
|
|
115415
|
-
const tries =
|
|
115522
|
+
const at2 = path85.resolve(path85.dirname(from), id);
|
|
115523
|
+
if (at2 !== folder && !at2.startsWith(folder + path85.sep)) throw new Error(`${id} is outside the mockup's folder`);
|
|
115524
|
+
const tries = path85.extname(at2) ? [at2] : [...CODE_EXTS.map((e2) => at2 + e2), ...CODE_EXTS.map((e2) => path85.join(at2, `index${e2}`))];
|
|
115416
115525
|
const file2 = tries.find((f2) => fs84.statSync(f2, { throwIfNoEntry: false })?.isFile());
|
|
115417
115526
|
if (!file2) throw new Error(`no such file: ${id}`);
|
|
115418
|
-
if (!fs84.realpathSync(file2).startsWith(fs84.realpathSync(folder) +
|
|
115527
|
+
if (!fs84.realpathSync(file2).startsWith(fs84.realpathSync(folder) + path85.sep)) throw new Error(`${id} is outside the mockup's folder`);
|
|
115419
115528
|
return file2;
|
|
115420
115529
|
}
|
|
115421
115530
|
async function readGraph(entry) {
|
|
115422
|
-
const folder =
|
|
115531
|
+
const folder = path85.dirname(entry);
|
|
115423
115532
|
const graph = { code: /* @__PURE__ */ new Map(), links: /* @__PURE__ */ new Map(), sheets: [], packages: /* @__PURE__ */ new Map() };
|
|
115424
115533
|
const walk3 = async (file2) => {
|
|
115425
115534
|
if (graph.code.has(file2)) return;
|
|
@@ -115457,13 +115566,13 @@ function run2(script, context, name, deadline, lineOffset = 0) {
|
|
|
115457
115566
|
async function tailwindFor(markup, sheets, folder) {
|
|
115458
115567
|
const source2 = sheets.length ? sheets.map((s) => s.content).join("\n") : '@import "tailwindcss";';
|
|
115459
115568
|
const compiler = await rc(source2, {
|
|
115460
|
-
base: sheets.length ?
|
|
115569
|
+
base: sheets.length ? path85.dirname(sheets[0].path) : "/",
|
|
115461
115570
|
loadStylesheet: async (id, from) => {
|
|
115462
115571
|
if (id === "tailwindcss" || id.startsWith("tailwindcss/")) return { path: "tailwindcss/index.css", base: "/", content: tailwindcss_default };
|
|
115463
115572
|
if (!id.startsWith(".")) throw new Error(`a mockup cannot import ${id}`);
|
|
115464
|
-
const at2 =
|
|
115465
|
-
if (!fs84.realpathSync(at2).startsWith(fs84.realpathSync(folder) +
|
|
115466
|
-
return { path: at2, base:
|
|
115573
|
+
const at2 = path85.resolve(from, id);
|
|
115574
|
+
if (!fs84.realpathSync(at2).startsWith(fs84.realpathSync(folder) + path85.sep)) throw new Error(`${id} is outside the mockup's folder`);
|
|
115575
|
+
return { path: at2, base: path85.dirname(at2), content: fs84.readFileSync(at2, "utf8") };
|
|
115467
115576
|
}
|
|
115468
115577
|
});
|
|
115469
115578
|
const classes = [...markup.matchAll(/class="([^"]*)"/g)].flatMap((m) => m[1].split(/\s+/));
|
|
@@ -115512,7 +115621,7 @@ ${graph.code.get(file2)}
|
|
|
115512
115621
|
if (typeof Component !== "function") throw new Error("the mockup has no default export to draw");
|
|
115513
115622
|
sandbox.__draw = () => (0, import_server.renderToStaticMarkup)(import_react3.default.createElement(Component));
|
|
115514
115623
|
const markup = run2("__draw()", context, entry, deadline);
|
|
115515
|
-
const css = (await tailwindFor(markup, graph.sheets,
|
|
115624
|
+
const css = (await tailwindFor(markup, graph.sheets, path85.dirname(entry))).replace(/<\/style/gi, "<\\/style");
|
|
115516
115625
|
return `<!doctype html><html><head>${head}<style>${css}</style></head><body>${markup}</body></html>`;
|
|
115517
115626
|
}
|
|
115518
115627
|
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;
|
|
@@ -115574,7 +115683,7 @@ var init_draw_mockup = __esm({
|
|
|
115574
115683
|
|
|
115575
115684
|
// ../cli/src/commands/studio-preview.ts
|
|
115576
115685
|
import fs85 from "node:fs";
|
|
115577
|
-
import
|
|
115686
|
+
import path86 from "node:path";
|
|
115578
115687
|
import { createHash as createHash10, randomUUID as randomUUID9 } from "node:crypto";
|
|
115579
115688
|
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
115580
115689
|
function readFolder2(folder) {
|
|
@@ -115583,7 +115692,7 @@ function readFolder2(folder) {
|
|
|
115583
115692
|
const scan = (dir) => {
|
|
115584
115693
|
for (const e2 of fs85.readdirSync(dir, { withFileTypes: true })) {
|
|
115585
115694
|
if (e2.name.startsWith(".")) continue;
|
|
115586
|
-
const file2 =
|
|
115695
|
+
const file2 = path86.join(dir, e2.name);
|
|
115587
115696
|
if (e2.isSymbolicLink()) throw Error(`${file2}: symbolic links are not allowed`);
|
|
115588
115697
|
if (e2.isDirectory()) scan(file2);
|
|
115589
115698
|
else {
|
|
@@ -115609,7 +115718,7 @@ function agentsOf2(held4) {
|
|
|
115609
115718
|
});
|
|
115610
115719
|
}
|
|
115611
115720
|
function unified(before, after2, file2, folder) {
|
|
115612
|
-
const a2 =
|
|
115721
|
+
const a2 = path86.join(folder, "a"), b2 = path86.join(folder, "b");
|
|
115613
115722
|
fs85.writeFileSync(a2, before ?? "");
|
|
115614
115723
|
fs85.writeFileSync(b2, after2 ?? "");
|
|
115615
115724
|
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 });
|
|
@@ -115621,10 +115730,10 @@ ${start < 0 ? "" : lines.slice(start + 2).join("\n")}`;
|
|
|
115621
115730
|
}
|
|
115622
115731
|
async function cmdStudioPreview(id, opts) {
|
|
115623
115732
|
if (!locate2(id)) die(`no card ${id}`, "no-such-card");
|
|
115624
|
-
const destination =
|
|
115733
|
+
const destination = path86.join(ASSETS, String(id), "studio-review"), staging = `${destination}.${randomUUID9()}.tmp`, backup = `${destination}.${randomUUID9()}.previous`;
|
|
115625
115734
|
let moved = false;
|
|
115626
115735
|
try {
|
|
115627
|
-
const draft = readFolder2(
|
|
115736
|
+
const draft = readFolder2(path86.resolve(opts.folder)), base = opts.base === "empty" ? null : readFolder2(path86.resolve(opts.base));
|
|
115628
115737
|
const version = readVersion2(draft.files), baseVersion = base && readVersion2(base.files);
|
|
115629
115738
|
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");
|
|
115630
115739
|
const agents = [...agentsOf2(draft)];
|
|
@@ -115632,8 +115741,8 @@ async function cmdStudioPreview(id, opts) {
|
|
|
115632
115741
|
fs85.mkdirSync(staging, { recursive: true });
|
|
115633
115742
|
const review = { version: 2, base: base && baseVersion ? { ...baseVersion, fingerprint: base.fingerprint } : null, fingerprint: draft.fingerprint, agents, files: [], results: [] };
|
|
115634
115743
|
const save3 = (file2, bytes2) => {
|
|
115635
|
-
const target =
|
|
115636
|
-
fs85.mkdirSync(
|
|
115744
|
+
const target = path86.join(staging, file2);
|
|
115745
|
+
fs85.mkdirSync(path86.dirname(target), { recursive: true });
|
|
115637
115746
|
fs85.writeFileSync(target, bytes2);
|
|
115638
115747
|
return file2;
|
|
115639
115748
|
};
|
|
@@ -115642,9 +115751,9 @@ async function cmdStudioPreview(id, opts) {
|
|
|
115642
115751
|
const before = base?.files[file2] ?? null, after2 = draft.files[file2] ?? null;
|
|
115643
115752
|
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)) } : {} });
|
|
115644
115753
|
}
|
|
115645
|
-
for (const p2 of ["a", "b"]) fs85.rmSync(
|
|
115754
|
+
for (const p2 of ["a", "b"]) fs85.rmSync(path86.join(staging, p2), { force: true });
|
|
115646
115755
|
if (opts.results) {
|
|
115647
|
-
const manifest = fs85.realpathSync(opts.results), root2 =
|
|
115756
|
+
const manifest = fs85.realpathSync(opts.results), root2 = path86.dirname(manifest);
|
|
115648
115757
|
const results = JSON.parse(fs85.readFileSync(manifest, "utf8")), bad = resultProblem(results, new Set(agents.map((a2) => a2.agent)));
|
|
115649
115758
|
if (bad) throw Error(`${opts.results}: invalid ${bad}`);
|
|
115650
115759
|
const rendered = /* @__PURE__ */ new Map();
|
|
@@ -115653,7 +115762,7 @@ async function cmdStudioPreview(id, opts) {
|
|
|
115653
115762
|
if (/\.(html|tsx)$/i.test(file2)) for (const ref of referencesOf(manifestOf("html"), raw, true)) {
|
|
115654
115763
|
if (/^(?:data:|#)/i.test(ref.src)) continue;
|
|
115655
115764
|
if (/^(?:[a-z][\w+.-]*:|\/)/i.test(ref.src)) throw Error(`${file2}: external result dependency ${ref.src}`);
|
|
115656
|
-
const target =
|
|
115765
|
+
const target = path86.resolve(path86.dirname(file2), ref.src.replace(/[?#].*$/, ""));
|
|
115657
115766
|
if (!within(root2, target) || fs85.existsSync(target) && !within(root2, fs85.realpathSync(target))) throw Error(`${file2}: outside result folder: ${ref.src}`);
|
|
115658
115767
|
}
|
|
115659
115768
|
return rendered.get(file2) ?? referenceText(file2);
|
|
@@ -115661,7 +115770,7 @@ async function cmdStudioPreview(id, opts) {
|
|
|
115661
115770
|
const collectResults = () => collectSources(referencesOf(manifestOf("studio"), { results }), manifest, {
|
|
115662
115771
|
resolve: (src, owner) => {
|
|
115663
115772
|
if (/^(?:[a-z][\w+.-]*:|\/|#)/i.test(src)) throw Error(`${src}: only local result files are allowed`);
|
|
115664
|
-
const target =
|
|
115773
|
+
const target = path86.resolve(path86.dirname(owner), src);
|
|
115665
115774
|
if (!within(root2, target)) throw Error(`${src}: outside result folder`);
|
|
115666
115775
|
const real2 = fs85.realpathSync(target);
|
|
115667
115776
|
if (!within(root2, real2) || !fs85.statSync(real2).isFile()) throw Error(`${src}: outside result folder or not a file`);
|
|
@@ -115681,18 +115790,18 @@ async function cmdStudioPreview(id, opts) {
|
|
|
115681
115790
|
}
|
|
115682
115791
|
if (graph.length > 2e3) throw Error(`${opts.results}: too many result dependencies`);
|
|
115683
115792
|
for (const node of graph) if (node.error || node.problems.length) throw Error(`${node.file}: ${node.error ?? node.problems[0].message}`);
|
|
115684
|
-
const names3 = new Map(graph.map((n, i) => [n.key, `results/${i}${rendered.has(n.file) ? ".html" :
|
|
115685
|
-
const resolve2 = (src, owner) => names3.get(fs85.realpathSync(
|
|
115793
|
+
const names3 = new Map(graph.map((n, i) => [n.key, `results/${i}${rendered.has(n.file) ? ".html" : path86.extname(n.file)}`]));
|
|
115794
|
+
const resolve2 = (src, owner) => names3.get(fs85.realpathSync(path86.resolve(path86.dirname(owner), src.replace(/[?#].*$/, ""))));
|
|
115686
115795
|
for (const node of graph) {
|
|
115687
115796
|
const own = names3.get(node.key);
|
|
115688
|
-
const content = node.data === void 0 ? fs85.readFileSync(node.file) : mapReferences(manifestOf(node.kind), node.data, (src) =>
|
|
115797
|
+
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)));
|
|
115689
115798
|
save3(own, typeof content === "string" || Buffer.isBuffer(content) ? content : JSON.stringify(content));
|
|
115690
115799
|
}
|
|
115691
115800
|
review.results = mapReferences(manifestOf("studio"), { results }, (src) => resolve2(src, manifest)).results;
|
|
115692
115801
|
}
|
|
115693
115802
|
if (!parseReview(review)) throw Error("generated review is invalid");
|
|
115694
115803
|
save3("review.json", JSON.stringify(review, null, 2) + "\n");
|
|
115695
|
-
fs85.mkdirSync(
|
|
115804
|
+
fs85.mkdirSync(path86.dirname(destination), { recursive: true });
|
|
115696
115805
|
if (fs85.existsSync(destination)) {
|
|
115697
115806
|
fs85.renameSync(destination, backup);
|
|
115698
115807
|
moved = true;
|
|
@@ -115701,7 +115810,7 @@ async function cmdStudioPreview(id, opts) {
|
|
|
115701
115810
|
fs85.rmSync(backup, { recursive: true, force: true });
|
|
115702
115811
|
const tag = `<Studio src=".assets/${id}/studio-review/review.json" />`;
|
|
115703
115812
|
say(tag);
|
|
115704
|
-
return { file:
|
|
115813
|
+
return { file: path86.join(destination, "review.json"), tag };
|
|
115705
115814
|
} catch (error) {
|
|
115706
115815
|
if (moved && !fs85.existsSync(destination)) fs85.renameSync(backup, destination);
|
|
115707
115816
|
if (error && typeof error === "object" && "kind" in error) throw error;
|
|
@@ -115726,7 +115835,7 @@ var init_studio_preview = __esm({
|
|
|
115726
115835
|
init_cards();
|
|
115727
115836
|
init_paths();
|
|
115728
115837
|
init_io();
|
|
115729
|
-
within = (root2, file2) => file2.startsWith(root2 +
|
|
115838
|
+
within = (root2, file2) => file2.startsWith(root2 + path86.sep);
|
|
115730
115839
|
readVersion2 = (files) => {
|
|
115731
115840
|
if (files[VERSION_FILE] === void 0) return null;
|
|
115732
115841
|
try {
|
|
@@ -116286,7 +116395,7 @@ init_agent2();
|
|
|
116286
116395
|
|
|
116287
116396
|
// ../cli/src/lib/cli/setup.ts
|
|
116288
116397
|
import fs87 from "node:fs";
|
|
116289
|
-
import
|
|
116398
|
+
import path88 from "node:path";
|
|
116290
116399
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
116291
116400
|
|
|
116292
116401
|
// ../cli/src/commands/update.ts
|
|
@@ -116295,7 +116404,7 @@ init_config_template();
|
|
|
116295
116404
|
init_io();
|
|
116296
116405
|
init_version();
|
|
116297
116406
|
import fs86 from "node:fs";
|
|
116298
|
-
import
|
|
116407
|
+
import path87 from "node:path";
|
|
116299
116408
|
import { spawnSync as spawnSync9 } from "node:child_process";
|
|
116300
116409
|
var NAME = "wildcrane";
|
|
116301
116410
|
var REPO = "https://github.com/wildcrane-ai/wildcrane";
|
|
@@ -116337,8 +116446,8 @@ async function cmdUpdate2(ctx) {
|
|
|
116337
116446
|
return { updated: ctx.dir, from, to: SKILL_VERSION };
|
|
116338
116447
|
}
|
|
116339
116448
|
async function repairBoard(root2, report3, named2) {
|
|
116340
|
-
const legacy =
|
|
116341
|
-
const kept2 =
|
|
116449
|
+
const legacy = path87.join(root2, "docs", "kanban");
|
|
116450
|
+
const kept2 = path87.join(root2, ".akb", "kanban");
|
|
116342
116451
|
const board2 = named2 ?? (fs86.existsSync(legacy) ? legacy : kept2);
|
|
116343
116452
|
if (!fs86.existsSync(board2)) {
|
|
116344
116453
|
report3.notes.push("\u672A\u627E\u5230\u770B\u677F\uFF0C\u8BF7\u901A\u8FC7\u63D2\u4EF6\u8FDE\u63A5\u4E91\u7AEF\u9879\u76EE\u3002");
|
|
@@ -116351,7 +116460,7 @@ async function repairBoard(root2, report3, named2) {
|
|
|
116351
116460
|
return true;
|
|
116352
116461
|
}
|
|
116353
116462
|
function checkConfig(board2, report3) {
|
|
116354
|
-
const current = read3(
|
|
116463
|
+
const current = read3(path87.join(board2, "config.md"));
|
|
116355
116464
|
if (!current) return;
|
|
116356
116465
|
const added = missingConfigKeys(current);
|
|
116357
116466
|
if (added.length) {
|
|
@@ -116361,7 +116470,7 @@ function checkConfig(board2, report3) {
|
|
|
116361
116470
|
}
|
|
116362
116471
|
}
|
|
116363
116472
|
function checkModules(board2, report3) {
|
|
116364
|
-
const map2 = read3(
|
|
116473
|
+
const map2 = read3(path87.join(board2, "modules.md"));
|
|
116365
116474
|
if (map2 && map2.includes(UNFILLED)) {
|
|
116366
116475
|
report3.notes.push(
|
|
116367
116476
|
"docs/kanban/modules.md is still blank \u2014 write it from the repo (`akb guide module-map`)"
|
|
@@ -116415,14 +116524,14 @@ function declareSetup(program2, cli) {
|
|
|
116415
116524
|
program2.version(SKILL_VERSION, "-v, --version", "print this version").addHelpText("beforeAll", spelled(cli.program));
|
|
116416
116525
|
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");
|
|
116417
116526
|
const where = (cmd) => {
|
|
116418
|
-
const dir =
|
|
116527
|
+
const dir = path88.resolve(String(cmd.optsWithGlobals().dir ?? cli.cwd));
|
|
116419
116528
|
if (!fs87.existsSync(dir)) throw new BoardError(`no such folder: ${dir}`, { kind: "no-such-folder", dir });
|
|
116420
116529
|
return dir;
|
|
116421
116530
|
};
|
|
116422
116531
|
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() {
|
|
116423
116532
|
const dir = where(this);
|
|
116424
116533
|
const named2 = this.optsWithGlobals().board ?? process.env.AI4KANBAN_BOARD?.trim();
|
|
116425
|
-
const board2 = named2 ?
|
|
116534
|
+
const board2 = named2 ? path88.resolve(cli.cwd, named2) : null;
|
|
116426
116535
|
await runAction(ctxOf(this, cli.program), {}, () => cmdUpdate2({ dir, program: cli.program, board: board2 }));
|
|
116427
116536
|
});
|
|
116428
116537
|
program2.command("__rules", { hidden: true }).action(function() {
|