wildcrane 0.11.69 → 0.11.71

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