@sideboard-ai/core 0.1.198 → 0.1.199
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{abletime-JINF5KJV.js → abletime-3CSCNAXU.js} +2 -2
- package/dist/{abletime-HR6P4GJH.js → abletime-H74RNIKV.js} +2 -2
- package/dist/{agents-AQQKPD46.js → agents-AVH44CBS.js} +26 -4
- package/dist/{agents-5TZY6LLX.js → agents-BOYOK56K.js} +26 -4
- package/dist/{app-settings-J775CYOO.js → app-settings-FMTDH5RD.js} +3 -1
- package/dist/{app-settings-5KHVKJKO.js → app-settings-MMPLJHWF.js} +3 -1
- package/dist/{chunk-S5GLSRLP.js → chunk-2IQ6W47G.js} +10 -0
- package/dist/{chunk-HZTHWU6A.js → chunk-BLOKJY4U.js} +2 -2
- package/dist/{chunk-E37JHCO3.js → chunk-CA7PWMQ7.js} +1 -1
- package/dist/{chunk-DROELG52.js → chunk-CTABTALL.js} +19 -19
- package/dist/{chunk-SYXSSU7G.js → chunk-DU2ICKLA.js} +355 -4
- package/dist/{chunk-S4QCBBXS.js → chunk-DU4ID3DA.js} +1 -1
- package/dist/{chunk-AH6WIBLY.js → chunk-HQKGK4KO.js} +10 -0
- package/dist/{chunk-EA67VQM2.js → chunk-KI4YI72Y.js} +355 -4
- package/dist/{chunk-6YS5IKD2.js → chunk-PPVN3APP.js} +20 -20
- package/dist/{chunk-KTHRWHA3.js → chunk-PTAMHXBT.js} +1 -1
- package/dist/{chunk-DP4TKAMZ.js → chunk-QFABSE3Q.js} +1 -1
- package/dist/{chunk-6YTI2HBG.js → chunk-S4EEYOSU.js} +2 -2
- package/dist/{coordinator-prompt-IX66YUJ2.js → coordinator-prompt-LB3GA3U4.js} +3 -3
- package/dist/{coordinator-prompt-LYKS3YNG.js → coordinator-prompt-ROWPLVQ3.js} +3 -3
- package/dist/{global-workspace-SNJ2Z6SL.js → global-workspace-C5XKWCRH.js} +3 -3
- package/dist/{global-workspace-4QX6UEOY.js → global-workspace-V2A4YKZ6.js} +3 -3
- package/dist/index.cjs +660 -258
- package/dist/index.d.cts +78 -1
- package/dist/index.d.ts +78 -1
- package/dist/index.js +32 -8
- package/dist/mcp/run-stdio.cjs +289 -254
- package/dist/mcp/run-stdio.js +8 -8
- package/dist/{orchestrator-L2H42HPW.js → orchestrator-AJGDZEAS.js} +5 -5
- package/dist/{orchestrator-6ZNKCPNL.js → orchestrator-NCGYNVYN.js} +5 -5
- package/dist/{workspaces-URMUVGAQ.js → workspaces-GWEKIS3B.js} +3 -3
- package/dist/{workspaces-UTOYGBYB.js → workspaces-WIRJQ6HA.js} +3 -3
- package/dist/{worktree-RM6UWNGZ.js → worktree-QA4J75FI.js} +2 -2
- package/dist/{worktree-R43JOR4V.js → worktree-UI5WJC3A.js} +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1032,6 +1032,7 @@ __export(app_settings_exports, {
|
|
|
1032
1032
|
childEnvWithAppSettings: () => childEnvWithAppSettings,
|
|
1033
1033
|
claudeChromeEnabled: () => claudeChromeEnabled,
|
|
1034
1034
|
claudeUserSettingsPath: () => claudeUserSettingsPath,
|
|
1035
|
+
confirmClaudeUsageOverLimitEnabled: () => confirmClaudeUsageOverLimitEnabled,
|
|
1035
1036
|
cowboyModeEnabled: () => cowboyModeEnabled,
|
|
1036
1037
|
deleteBranchOnPurgeEnabled: () => deleteBranchOnPurgeEnabled,
|
|
1037
1038
|
disconnectAbleTimeConnection: () => disconnectAbleTimeConnection,
|
|
@@ -1459,6 +1460,9 @@ function normalizeAdvanced(raw) {
|
|
|
1459
1460
|
if (typeof source.showCost === "boolean") {
|
|
1460
1461
|
out.showCost = source.showCost;
|
|
1461
1462
|
}
|
|
1463
|
+
if (typeof source.confirmClaudeUsageOverLimit === "boolean") {
|
|
1464
|
+
out.confirmClaudeUsageOverLimit = source.confirmClaudeUsageOverLimit;
|
|
1465
|
+
}
|
|
1462
1466
|
if (typeof source.autoArchiveOnMerge === "boolean") {
|
|
1463
1467
|
out.autoArchiveOnMerge = source.autoArchiveOnMerge;
|
|
1464
1468
|
}
|
|
@@ -2321,6 +2325,9 @@ function updateAdvancedSettings(patch) {
|
|
|
2321
2325
|
if (typeof patch.showCost === "boolean") {
|
|
2322
2326
|
advanced.showCost = patch.showCost;
|
|
2323
2327
|
}
|
|
2328
|
+
if (typeof patch.confirmClaudeUsageOverLimit === "boolean") {
|
|
2329
|
+
advanced.confirmClaudeUsageOverLimit = patch.confirmClaudeUsageOverLimit;
|
|
2330
|
+
}
|
|
2324
2331
|
if (typeof patch.autoArchiveOnMerge === "boolean") {
|
|
2325
2332
|
advanced.autoArchiveOnMerge = patch.autoArchiveOnMerge;
|
|
2326
2333
|
}
|
|
@@ -2383,6 +2390,9 @@ function cowboyModeEnabled(settings = loadAppSettings()) {
|
|
|
2383
2390
|
function showCostEnabled(settings = loadAppSettings()) {
|
|
2384
2391
|
return Boolean(settings.advanced.showCost);
|
|
2385
2392
|
}
|
|
2393
|
+
function confirmClaudeUsageOverLimitEnabled(settings = loadAppSettings()) {
|
|
2394
|
+
return Boolean(settings.advanced.confirmClaudeUsageOverLimit);
|
|
2395
|
+
}
|
|
2386
2396
|
function autoArchiveOnMergeEnabled(settings = loadAppSettings()) {
|
|
2387
2397
|
return Boolean(settings.advanced.autoArchiveOnMerge);
|
|
2388
2398
|
}
|
|
@@ -2845,14 +2855,14 @@ function fileMtimeMs(path2) {
|
|
|
2845
2855
|
}
|
|
2846
2856
|
}
|
|
2847
2857
|
function rememberThread(thread, mtimeMs) {
|
|
2848
|
-
const
|
|
2849
|
-
|
|
2850
|
-
if (mtimeMs != null)
|
|
2858
|
+
const cache2 = cacheForDir();
|
|
2859
|
+
cache2.byId.set(thread.id, thread);
|
|
2860
|
+
if (mtimeMs != null) cache2.mtimeMs.set(thread.id, mtimeMs);
|
|
2851
2861
|
}
|
|
2852
2862
|
function forgetThread(id) {
|
|
2853
|
-
const
|
|
2854
|
-
|
|
2855
|
-
|
|
2863
|
+
const cache2 = cacheForDir();
|
|
2864
|
+
cache2.byId.delete(id);
|
|
2865
|
+
cache2.mtimeMs.delete(id);
|
|
2856
2866
|
}
|
|
2857
2867
|
function invalidateThreadListCache() {
|
|
2858
2868
|
listCache = null;
|
|
@@ -2864,9 +2874,9 @@ function readThread(id) {
|
|
|
2864
2874
|
forgetThread(id);
|
|
2865
2875
|
return null;
|
|
2866
2876
|
}
|
|
2867
|
-
const
|
|
2868
|
-
const cached =
|
|
2869
|
-
if (cached &&
|
|
2877
|
+
const cache2 = cacheForDir();
|
|
2878
|
+
const cached = cache2.byId.get(id);
|
|
2879
|
+
if (cached && cache2.mtimeMs.get(id) === mtimeMs) return cached;
|
|
2870
2880
|
const raw = (0, import_node_fs9.readFileSync)(path2, "utf8");
|
|
2871
2881
|
const thread = normalizeThread(JSON.parse(raw));
|
|
2872
2882
|
rememberThread(thread, mtimeMs);
|
|
@@ -2888,7 +2898,7 @@ function isThreadRecordFile(nameOrPath) {
|
|
|
2888
2898
|
return name.endsWith(".json") && !name.endsWith(".live.json");
|
|
2889
2899
|
}
|
|
2890
2900
|
function listThreads(opts) {
|
|
2891
|
-
const
|
|
2901
|
+
const cache2 = cacheForDir();
|
|
2892
2902
|
const files = (0, import_node_fs9.readdirSync)(threadsDir()).filter(isThreadRecordFile);
|
|
2893
2903
|
const seen = /* @__PURE__ */ new Set();
|
|
2894
2904
|
for (const f of files) {
|
|
@@ -2900,10 +2910,10 @@ function listThreads(opts) {
|
|
|
2900
2910
|
} catch {
|
|
2901
2911
|
}
|
|
2902
2912
|
}
|
|
2903
|
-
for (const id of [...
|
|
2913
|
+
for (const id of [...cache2.byId.keys()]) {
|
|
2904
2914
|
if (!seen.has(id)) forgetThread(id);
|
|
2905
2915
|
}
|
|
2906
|
-
const threads = [...
|
|
2916
|
+
const threads = [...cache2.byId.values()].sort(
|
|
2907
2917
|
(a, b) => b.updatedAt.localeCompare(a.updatedAt)
|
|
2908
2918
|
);
|
|
2909
2919
|
if (opts?.includeArchived) return threads;
|
|
@@ -13674,6 +13684,361 @@ var init_session_quota = __esm({
|
|
|
13674
13684
|
}
|
|
13675
13685
|
});
|
|
13676
13686
|
|
|
13687
|
+
// src/agents/claude-usage.ts
|
|
13688
|
+
function parseClaudeResetsAt(value) {
|
|
13689
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
13690
|
+
const ms = value > 1e12 ? value : value * 1e3;
|
|
13691
|
+
const d = new Date(ms);
|
|
13692
|
+
return Number.isNaN(d.getTime()) ? null : d.toISOString();
|
|
13693
|
+
}
|
|
13694
|
+
if (typeof value === "string") {
|
|
13695
|
+
const trimmed = value.trim();
|
|
13696
|
+
if (!trimmed) return null;
|
|
13697
|
+
if (/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
13698
|
+
return parseClaudeResetsAt(Number(trimmed));
|
|
13699
|
+
}
|
|
13700
|
+
const d = new Date(trimmed);
|
|
13701
|
+
return Number.isNaN(d.getTime()) ? null : d.toISOString();
|
|
13702
|
+
}
|
|
13703
|
+
return null;
|
|
13704
|
+
}
|
|
13705
|
+
function parseClaudeUtilization(value) {
|
|
13706
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return null;
|
|
13707
|
+
return Math.max(0, Math.min(100, value));
|
|
13708
|
+
}
|
|
13709
|
+
function windowFromRaw(id, raw) {
|
|
13710
|
+
if (!raw || typeof raw !== "object") return null;
|
|
13711
|
+
const row = raw;
|
|
13712
|
+
const used = parseClaudeUtilization(row.utilization ?? row.used_percentage);
|
|
13713
|
+
if (used == null) return null;
|
|
13714
|
+
const meta = WINDOW_META[id];
|
|
13715
|
+
return {
|
|
13716
|
+
id,
|
|
13717
|
+
label: meta.label,
|
|
13718
|
+
shortLabel: meta.shortLabel,
|
|
13719
|
+
detail: meta.detail,
|
|
13720
|
+
usedPercent: used,
|
|
13721
|
+
remainingPercent: Math.max(0, Math.min(100, 100 - used)),
|
|
13722
|
+
resetsAt: parseClaudeResetsAt(row.resets_at)
|
|
13723
|
+
};
|
|
13724
|
+
}
|
|
13725
|
+
function extraUsageFromRaw(raw) {
|
|
13726
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
13727
|
+
const row = raw;
|
|
13728
|
+
const enabled = row.is_enabled === true || row.enabled === true;
|
|
13729
|
+
if (!enabled && row.is_enabled !== false && row.enabled !== false) return void 0;
|
|
13730
|
+
const usedCredits = numberOrUndef(row.used_credits ?? row.used);
|
|
13731
|
+
const monthlyLimit = numberOrUndef(row.monthly_limit);
|
|
13732
|
+
const usedPercent = parseClaudeUtilization(row.utilization) ?? void 0;
|
|
13733
|
+
return {
|
|
13734
|
+
enabled,
|
|
13735
|
+
...usedCredits != null ? { usedCredits } : {},
|
|
13736
|
+
...monthlyLimit != null ? { monthlyLimit } : {},
|
|
13737
|
+
...usedPercent != null ? { usedPercent } : {}
|
|
13738
|
+
};
|
|
13739
|
+
}
|
|
13740
|
+
function numberOrUndef(value) {
|
|
13741
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
|
|
13742
|
+
return value;
|
|
13743
|
+
}
|
|
13744
|
+
function parseClaudeUsagePayload(raw, fetchedAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
13745
|
+
if (!raw || typeof raw !== "object") return null;
|
|
13746
|
+
const obj = raw;
|
|
13747
|
+
const source = obj.rate_limits && typeof obj.rate_limits === "object" ? obj.rate_limits : obj;
|
|
13748
|
+
const windows = [];
|
|
13749
|
+
for (const id of WINDOW_ORDER) {
|
|
13750
|
+
const parsed = windowFromRaw(id, source[id]);
|
|
13751
|
+
if (parsed) windows.push(parsed);
|
|
13752
|
+
}
|
|
13753
|
+
if (windows.length === 0) return null;
|
|
13754
|
+
const extra = extraUsageFromRaw(obj.extra_usage ?? source.extra_usage);
|
|
13755
|
+
return {
|
|
13756
|
+
windows,
|
|
13757
|
+
...extra ? { extraUsage: extra } : {},
|
|
13758
|
+
fetchedAt
|
|
13759
|
+
};
|
|
13760
|
+
}
|
|
13761
|
+
function hottestClaudeWindow(usage) {
|
|
13762
|
+
if (usage.windows.length === 0) return null;
|
|
13763
|
+
return usage.windows.reduce((a, b) => b.usedPercent > a.usedPercent ? b : a);
|
|
13764
|
+
}
|
|
13765
|
+
function formatClaudeUsageReset(resetsAt, now = /* @__PURE__ */ new Date()) {
|
|
13766
|
+
if (!resetsAt) return "";
|
|
13767
|
+
const at = new Date(resetsAt);
|
|
13768
|
+
if (Number.isNaN(at.getTime())) return "";
|
|
13769
|
+
const ms = at.getTime() - now.getTime();
|
|
13770
|
+
if (ms <= 0) return "resets soon";
|
|
13771
|
+
const minutes = Math.round(ms / 6e4);
|
|
13772
|
+
if (minutes < 60) return `resets in ${Math.max(1, minutes)}m`;
|
|
13773
|
+
const hours = Math.round(minutes / 60);
|
|
13774
|
+
if (hours < 36) return `resets in ${hours}h`;
|
|
13775
|
+
try {
|
|
13776
|
+
return `resets ${at.toLocaleString(void 0, {
|
|
13777
|
+
weekday: "short",
|
|
13778
|
+
hour: "numeric",
|
|
13779
|
+
minute: "2-digit"
|
|
13780
|
+
})}`;
|
|
13781
|
+
} catch {
|
|
13782
|
+
return `resets ${at.toISOString()}`;
|
|
13783
|
+
}
|
|
13784
|
+
}
|
|
13785
|
+
function formatClaudeUsageResetClock(resetsAt) {
|
|
13786
|
+
if (!resetsAt) return "";
|
|
13787
|
+
const at = new Date(resetsAt);
|
|
13788
|
+
if (Number.isNaN(at.getTime())) return "";
|
|
13789
|
+
try {
|
|
13790
|
+
return at.toLocaleString(void 0, {
|
|
13791
|
+
weekday: "short",
|
|
13792
|
+
month: "short",
|
|
13793
|
+
day: "numeric",
|
|
13794
|
+
hour: "numeric",
|
|
13795
|
+
minute: "2-digit"
|
|
13796
|
+
});
|
|
13797
|
+
} catch {
|
|
13798
|
+
return at.toISOString();
|
|
13799
|
+
}
|
|
13800
|
+
}
|
|
13801
|
+
function formatClaudeUsageFetchedAt(fetchedAt, now = /* @__PURE__ */ new Date()) {
|
|
13802
|
+
const at = new Date(fetchedAt);
|
|
13803
|
+
if (Number.isNaN(at.getTime())) return "";
|
|
13804
|
+
const minutes = Math.max(0, Math.round((now.getTime() - at.getTime()) / 6e4));
|
|
13805
|
+
if (minutes < 1) return "Updated just now";
|
|
13806
|
+
if (minutes < 60) return `Updated ${minutes}m ago`;
|
|
13807
|
+
const hours = Math.round(minutes / 60);
|
|
13808
|
+
if (hours < 36) return `Updated ${hours}h ago`;
|
|
13809
|
+
return `Updated ${formatClaudeUsageResetClock(fetchedAt)}`;
|
|
13810
|
+
}
|
|
13811
|
+
function formatClaudeExtraUsageDetail(extra) {
|
|
13812
|
+
if (!extra.enabled) return "Extra usage off";
|
|
13813
|
+
const bits = ["Extra usage on"];
|
|
13814
|
+
if (extra.usedCredits != null && extra.monthlyLimit != null) {
|
|
13815
|
+
bits.push(`${extra.usedCredits} / ${extra.monthlyLimit} credits this month`);
|
|
13816
|
+
} else if (extra.usedCredits != null) {
|
|
13817
|
+
bits.push(`${extra.usedCredits} credits used`);
|
|
13818
|
+
}
|
|
13819
|
+
if (extra.usedPercent != null) {
|
|
13820
|
+
bits.push(`${Math.round(extra.usedPercent)}% of extra pool`);
|
|
13821
|
+
}
|
|
13822
|
+
return bits.join(" \xB7 ");
|
|
13823
|
+
}
|
|
13824
|
+
function formatClaudeUsageWindowLine(window, now = /* @__PURE__ */ new Date()) {
|
|
13825
|
+
const reset = formatClaudeUsageReset(window.resetsAt, now);
|
|
13826
|
+
const clock = formatClaudeUsageResetClock(window.resetsAt);
|
|
13827
|
+
const left = `${Math.round(window.remainingPercent)}% left`;
|
|
13828
|
+
const used = `${Math.round(window.usedPercent)}% used`;
|
|
13829
|
+
const resetBit = reset ? clock && !reset.includes(clock) ? `${reset} (${clock})` : reset : "";
|
|
13830
|
+
return resetBit ? `${window.label} \u2014 ${window.detail}. ${left} \xB7 ${used} \xB7 ${resetBit}` : `${window.label} \u2014 ${window.detail}. ${left} \xB7 ${used}`;
|
|
13831
|
+
}
|
|
13832
|
+
function formatClaudeUsageTooltip(usage, now = /* @__PURE__ */ new Date()) {
|
|
13833
|
+
const lines = [
|
|
13834
|
+
"Claude Code plan",
|
|
13835
|
+
...usage.windows.map((w) => formatClaudeUsageWindowLine(w, now))
|
|
13836
|
+
];
|
|
13837
|
+
if (usage.extraUsage) {
|
|
13838
|
+
lines.push(formatClaudeExtraUsageDetail(usage.extraUsage));
|
|
13839
|
+
}
|
|
13840
|
+
const fetched = formatClaudeUsageFetchedAt(usage.fetchedAt, now);
|
|
13841
|
+
if (fetched) lines.push(fetched);
|
|
13842
|
+
return lines.join("\n");
|
|
13843
|
+
}
|
|
13844
|
+
function formatClaudeUsageCompact(window) {
|
|
13845
|
+
return `${window.shortLabel} ${Math.round(window.remainingPercent)}%`;
|
|
13846
|
+
}
|
|
13847
|
+
function claudeUsageWindowOverLimit(window) {
|
|
13848
|
+
return window.remainingPercent <= 0 || window.usedPercent >= 100;
|
|
13849
|
+
}
|
|
13850
|
+
function claudeUsageOverLimitWindows(usage) {
|
|
13851
|
+
if (!usage) return [];
|
|
13852
|
+
return usage.windows.filter(claudeUsageWindowOverLimit);
|
|
13853
|
+
}
|
|
13854
|
+
function formatClaudeUsageOverLimitConfirm(windows, now = /* @__PURE__ */ new Date()) {
|
|
13855
|
+
if (windows.length === 0) return "";
|
|
13856
|
+
const parts = windows.map((w) => {
|
|
13857
|
+
const reset = formatClaudeUsageReset(w.resetsAt, now);
|
|
13858
|
+
return reset ? `${w.label} (${reset})` : w.label;
|
|
13859
|
+
});
|
|
13860
|
+
const list = parts.join(", ");
|
|
13861
|
+
const verb = windows.length === 1 ? "is" : "are";
|
|
13862
|
+
return `Claude Code ${list} ${verb} at or over the plan limit. Send this message anyway?`;
|
|
13863
|
+
}
|
|
13864
|
+
var WINDOW_META, WINDOW_ORDER;
|
|
13865
|
+
var init_claude_usage = __esm({
|
|
13866
|
+
"src/agents/claude-usage.ts"() {
|
|
13867
|
+
"use strict";
|
|
13868
|
+
WINDOW_META = {
|
|
13869
|
+
five_hour: {
|
|
13870
|
+
label: "5-hour session",
|
|
13871
|
+
shortLabel: "5h",
|
|
13872
|
+
detail: "Rolling 5-hour limit across all models"
|
|
13873
|
+
},
|
|
13874
|
+
seven_day: {
|
|
13875
|
+
label: "Weekly",
|
|
13876
|
+
shortLabel: "wk",
|
|
13877
|
+
detail: "7-day cap across all models"
|
|
13878
|
+
},
|
|
13879
|
+
seven_day_opus: {
|
|
13880
|
+
label: "Opus",
|
|
13881
|
+
shortLabel: "Opus",
|
|
13882
|
+
detail: "Weekly Opus-only cap"
|
|
13883
|
+
},
|
|
13884
|
+
seven_day_sonnet: {
|
|
13885
|
+
label: "Sonnet",
|
|
13886
|
+
shortLabel: "Sonnet",
|
|
13887
|
+
detail: "Weekly Sonnet-only cap"
|
|
13888
|
+
}
|
|
13889
|
+
};
|
|
13890
|
+
WINDOW_ORDER = [
|
|
13891
|
+
"five_hour",
|
|
13892
|
+
"seven_day",
|
|
13893
|
+
"seven_day_opus",
|
|
13894
|
+
"seven_day_sonnet"
|
|
13895
|
+
];
|
|
13896
|
+
}
|
|
13897
|
+
});
|
|
13898
|
+
|
|
13899
|
+
// src/agents/claude-usage-client.ts
|
|
13900
|
+
function accessTokenFromCredentialsJson(raw) {
|
|
13901
|
+
const trimmed = raw.trim();
|
|
13902
|
+
if (!trimmed) return null;
|
|
13903
|
+
if (trimmed.startsWith("sk-ant-")) {
|
|
13904
|
+
const token = trimmed.split(/\s+/)[0];
|
|
13905
|
+
return token || null;
|
|
13906
|
+
}
|
|
13907
|
+
try {
|
|
13908
|
+
const parsed = JSON.parse(trimmed);
|
|
13909
|
+
const oauth = parsed.claudeAiOauth && typeof parsed.claudeAiOauth === "object" ? parsed.claudeAiOauth : parsed;
|
|
13910
|
+
const token = oauth.accessToken ?? oauth.access_token;
|
|
13911
|
+
return typeof token === "string" && token.trim() ? token.trim() : null;
|
|
13912
|
+
} catch {
|
|
13913
|
+
return null;
|
|
13914
|
+
}
|
|
13915
|
+
}
|
|
13916
|
+
function claudeCredentialsPath() {
|
|
13917
|
+
const root = process.env.CLAUDE_CONFIG_DIR?.trim() || (0, import_node_path37.join)((0, import_node_os13.homedir)(), ".claude");
|
|
13918
|
+
return (0, import_node_path37.join)(root, ".credentials.json");
|
|
13919
|
+
}
|
|
13920
|
+
async function readFileAccessToken() {
|
|
13921
|
+
const path2 = claudeCredentialsPath();
|
|
13922
|
+
if (!(0, import_node_fs37.existsSync)(path2)) return null;
|
|
13923
|
+
try {
|
|
13924
|
+
return accessTokenFromCredentialsJson((0, import_node_fs37.readFileSync)(path2, "utf8"));
|
|
13925
|
+
} catch {
|
|
13926
|
+
return null;
|
|
13927
|
+
}
|
|
13928
|
+
}
|
|
13929
|
+
async function readKeychainAccessToken() {
|
|
13930
|
+
if (process.platform !== "darwin") return null;
|
|
13931
|
+
for (const service of KEYCHAIN_SERVICES) {
|
|
13932
|
+
const result = await run("security", ["find-generic-password", "-s", service, "-w"], {
|
|
13933
|
+
reject: false,
|
|
13934
|
+
timeoutMs: 4e3
|
|
13935
|
+
});
|
|
13936
|
+
if (result.exitCode !== 0 || !result.stdout.trim()) continue;
|
|
13937
|
+
const token = accessTokenFromCredentialsJson(result.stdout);
|
|
13938
|
+
if (token) return token;
|
|
13939
|
+
}
|
|
13940
|
+
return null;
|
|
13941
|
+
}
|
|
13942
|
+
async function readClaudeAccessToken() {
|
|
13943
|
+
const envToken = process.env.CLAUDE_CODE_OAUTH_TOKEN?.trim();
|
|
13944
|
+
if (envToken) return envToken;
|
|
13945
|
+
const fromFile = await readFileAccessToken();
|
|
13946
|
+
if (fromFile) return fromFile;
|
|
13947
|
+
return readKeychainAccessToken();
|
|
13948
|
+
}
|
|
13949
|
+
async function resolveClaudeUserAgent() {
|
|
13950
|
+
if (claudeVersion) return `claude-code/${claudeVersion}`;
|
|
13951
|
+
try {
|
|
13952
|
+
const claude = resolveClaudeExecutable();
|
|
13953
|
+
const result = await run(claude, ["--version"], { reject: false, timeoutMs: 4e3 });
|
|
13954
|
+
const match = `${result.stdout}
|
|
13955
|
+
${result.stderr}`.match(/(\d+\.\d+\.\d+)/);
|
|
13956
|
+
claudeVersion = match?.[1] ?? "2.1.80";
|
|
13957
|
+
} catch {
|
|
13958
|
+
claudeVersion = "2.1.80";
|
|
13959
|
+
}
|
|
13960
|
+
return `claude-code/${claudeVersion}`;
|
|
13961
|
+
}
|
|
13962
|
+
function staleOk(now) {
|
|
13963
|
+
if (!lastGood) return null;
|
|
13964
|
+
if (now - lastGood.at > CLAUDE_USAGE_STALE_OK_MS) return null;
|
|
13965
|
+
return lastGood.value;
|
|
13966
|
+
}
|
|
13967
|
+
async function getClaudePlanUsage(opts = {}) {
|
|
13968
|
+
const now = opts.now ?? Date.now();
|
|
13969
|
+
if (!opts.force) {
|
|
13970
|
+
if (cache && now - cache.at < CLAUDE_USAGE_TTL_MS) return cache.value;
|
|
13971
|
+
if (now < errorUntil) return staleOk(now);
|
|
13972
|
+
}
|
|
13973
|
+
if (inflight) return inflight;
|
|
13974
|
+
inflight = (async () => {
|
|
13975
|
+
try {
|
|
13976
|
+
const token = await (opts.readAccessToken ?? readClaudeAccessToken)();
|
|
13977
|
+
if (!token) {
|
|
13978
|
+
cache = { at: now, value: null };
|
|
13979
|
+
return null;
|
|
13980
|
+
}
|
|
13981
|
+
const fetchFn = opts.fetch ?? globalThis.fetch;
|
|
13982
|
+
const userAgent = opts.userAgent ?? await resolveClaudeUserAgent();
|
|
13983
|
+
const ac = new AbortController();
|
|
13984
|
+
const timer = setTimeout(() => ac.abort(), 8e3);
|
|
13985
|
+
let res;
|
|
13986
|
+
try {
|
|
13987
|
+
res = await fetchFn(CLAUDE_OAUTH_USAGE_URL, {
|
|
13988
|
+
headers: {
|
|
13989
|
+
Authorization: `Bearer ${token}`,
|
|
13990
|
+
"anthropic-beta": "oauth-2025-04-20",
|
|
13991
|
+
"User-Agent": userAgent
|
|
13992
|
+
},
|
|
13993
|
+
signal: ac.signal
|
|
13994
|
+
});
|
|
13995
|
+
} finally {
|
|
13996
|
+
clearTimeout(timer);
|
|
13997
|
+
}
|
|
13998
|
+
if (res.status === 401 || res.status === 403) {
|
|
13999
|
+
cache = { at: now, value: null };
|
|
14000
|
+
return null;
|
|
14001
|
+
}
|
|
14002
|
+
if (!res.ok) {
|
|
14003
|
+
errorUntil = now + CLAUDE_USAGE_ERROR_TTL_MS;
|
|
14004
|
+
return staleOk(now);
|
|
14005
|
+
}
|
|
14006
|
+
const usage = parseClaudeUsagePayload(await res.json(), new Date(now).toISOString());
|
|
14007
|
+
cache = { at: now, value: usage };
|
|
14008
|
+
if (usage) lastGood = { at: now, value: usage };
|
|
14009
|
+
return usage;
|
|
14010
|
+
} catch {
|
|
14011
|
+
errorUntil = now + CLAUDE_USAGE_ERROR_TTL_MS;
|
|
14012
|
+
return staleOk(now);
|
|
14013
|
+
} finally {
|
|
14014
|
+
inflight = null;
|
|
14015
|
+
}
|
|
14016
|
+
})();
|
|
14017
|
+
return inflight;
|
|
14018
|
+
}
|
|
14019
|
+
var import_node_fs37, import_node_os13, import_node_path37, CLAUDE_OAUTH_USAGE_URL, CLAUDE_USAGE_TTL_MS, CLAUDE_USAGE_ERROR_TTL_MS, CLAUDE_USAGE_STALE_OK_MS, KEYCHAIN_SERVICES, cache, errorUntil, inflight, lastGood, claudeVersion;
|
|
14020
|
+
var init_claude_usage_client = __esm({
|
|
14021
|
+
"src/agents/claude-usage-client.ts"() {
|
|
14022
|
+
"use strict";
|
|
14023
|
+
import_node_fs37 = require("fs");
|
|
14024
|
+
import_node_os13 = require("os");
|
|
14025
|
+
import_node_path37 = require("path");
|
|
14026
|
+
init_run();
|
|
14027
|
+
init_app_settings();
|
|
14028
|
+
init_claude_usage();
|
|
14029
|
+
CLAUDE_OAUTH_USAGE_URL = "https://api.anthropic.com/api/oauth/usage";
|
|
14030
|
+
CLAUDE_USAGE_TTL_MS = 9e4;
|
|
14031
|
+
CLAUDE_USAGE_ERROR_TTL_MS = 5 * 6e4;
|
|
14032
|
+
CLAUDE_USAGE_STALE_OK_MS = 30 * 6e4;
|
|
14033
|
+
KEYCHAIN_SERVICES = ["Claude Code-credentials", "Claude Code"];
|
|
14034
|
+
cache = null;
|
|
14035
|
+
errorUntil = 0;
|
|
14036
|
+
inflight = null;
|
|
14037
|
+
lastGood = null;
|
|
14038
|
+
claudeVersion = null;
|
|
14039
|
+
}
|
|
14040
|
+
});
|
|
14041
|
+
|
|
13677
14042
|
// src/agents/install.ts
|
|
13678
14043
|
function getAgentSetupInfo(agent) {
|
|
13679
14044
|
return SETUP[agent];
|
|
@@ -13922,6 +14287,7 @@ __export(agents_exports, {
|
|
|
13922
14287
|
assertOrchestratorCapableAgent: () => assertOrchestratorCapableAgent,
|
|
13923
14288
|
brightsyAdapter: () => brightsyAdapter,
|
|
13924
14289
|
claudeAdapter: () => claudeAdapter,
|
|
14290
|
+
claudeUsageOverLimitWindows: () => claudeUsageOverLimitWindows,
|
|
13925
14291
|
codexAdapter: () => codexAdapter,
|
|
13926
14292
|
coerceOrchestratorAgent: () => coerceOrchestratorAgent,
|
|
13927
14293
|
conductorBundledBinDir: () => conductorBundledBinDir,
|
|
@@ -13931,8 +14297,17 @@ __export(agents_exports, {
|
|
|
13931
14297
|
encodeBrightsyTarget: () => encodeBrightsyTarget,
|
|
13932
14298
|
enrichPathWithNpmGlobalBin: () => enrichPathWithNpmGlobalBin,
|
|
13933
14299
|
ensureAgentPath: () => ensureAgentPath,
|
|
14300
|
+
formatClaudeExtraUsageDetail: () => formatClaudeExtraUsageDetail,
|
|
14301
|
+
formatClaudeUsageCompact: () => formatClaudeUsageCompact,
|
|
14302
|
+
formatClaudeUsageFetchedAt: () => formatClaudeUsageFetchedAt,
|
|
14303
|
+
formatClaudeUsageOverLimitConfirm: () => formatClaudeUsageOverLimitConfirm,
|
|
14304
|
+
formatClaudeUsageReset: () => formatClaudeUsageReset,
|
|
14305
|
+
formatClaudeUsageResetClock: () => formatClaudeUsageResetClock,
|
|
14306
|
+
formatClaudeUsageTooltip: () => formatClaudeUsageTooltip,
|
|
13934
14307
|
getAdapter: () => getAdapter,
|
|
13935
14308
|
getAgentSetupInfo: () => getAgentSetupInfo,
|
|
14309
|
+
getClaudePlanUsage: () => getClaudePlanUsage,
|
|
14310
|
+
hottestClaudeWindow: () => hottestClaudeWindow,
|
|
13936
14311
|
installAgent: () => installAgent,
|
|
13937
14312
|
installNpmGlobalPackage: () => installNpmGlobalPackage,
|
|
13938
14313
|
isConductorBundledCli: () => isConductorBundledCli,
|
|
@@ -13950,6 +14325,7 @@ __export(agents_exports, {
|
|
|
13950
14325
|
mcpStatusThinkingFromClaudeInit: () => mcpStatusThinkingFromClaudeInit,
|
|
13951
14326
|
openInSystemTerminal: () => openInSystemTerminal,
|
|
13952
14327
|
opencodeAdapter: () => opencodeAdapter,
|
|
14328
|
+
parseClaudeUsagePayload: () => parseClaudeUsagePayload,
|
|
13953
14329
|
parseCursorRunnerLine: () => parseCursorRunnerLine,
|
|
13954
14330
|
parseSessionQuotaResetAt: () => parseSessionQuotaResetAt,
|
|
13955
14331
|
permissionMode: () => permissionMode,
|
|
@@ -13990,6 +14366,8 @@ var init_agents = __esm({
|
|
|
13990
14366
|
init_opencode();
|
|
13991
14367
|
init_list_models();
|
|
13992
14368
|
init_session_quota();
|
|
14369
|
+
init_claude_usage();
|
|
14370
|
+
init_claude_usage_client();
|
|
13993
14371
|
init_orchestrator_capable();
|
|
13994
14372
|
init_path();
|
|
13995
14373
|
init_install();
|
|
@@ -14005,15 +14383,15 @@ var init_agents = __esm({
|
|
|
14005
14383
|
|
|
14006
14384
|
// src/hook/worktree-pkg-cache.ts
|
|
14007
14385
|
function worktreePkgCacheRoot(worktreePath) {
|
|
14008
|
-
return (0,
|
|
14386
|
+
return (0, import_node_path38.join)(worktreePath, WORKTREE_PKG_CACHE_REL);
|
|
14009
14387
|
}
|
|
14010
14388
|
function worktreePkgCacheEnv(worktreePath) {
|
|
14011
14389
|
const root = worktreePkgCacheRoot(worktreePath);
|
|
14012
|
-
const store = (0,
|
|
14013
|
-
const pnpmCache = (0,
|
|
14014
|
-
const npmCache = (0,
|
|
14015
|
-
const nodeGyp = (0,
|
|
14016
|
-
const electron = (0,
|
|
14390
|
+
const store = (0, import_node_path38.join)(root, "pnpm-store");
|
|
14391
|
+
const pnpmCache = (0, import_node_path38.join)(root, "pnpm");
|
|
14392
|
+
const npmCache = (0, import_node_path38.join)(root, "npm");
|
|
14393
|
+
const nodeGyp = (0, import_node_path38.join)(root, "node-gyp");
|
|
14394
|
+
const electron = (0, import_node_path38.join)(root, "electron");
|
|
14017
14395
|
return {
|
|
14018
14396
|
npm_config_store_dir: store,
|
|
14019
14397
|
PNPM_STORE_DIR: store,
|
|
@@ -14035,8 +14413,8 @@ function fillGroup(env, keys, values) {
|
|
|
14035
14413
|
}
|
|
14036
14414
|
}
|
|
14037
14415
|
function ensureWorktreePkgCacheDirs(worktreePath) {
|
|
14038
|
-
if (!(0,
|
|
14039
|
-
(0,
|
|
14416
|
+
if (!(0, import_node_fs38.existsSync)(worktreePath)) return;
|
|
14417
|
+
(0, import_node_fs38.mkdirSync)(worktreePkgCacheRoot(worktreePath), { recursive: true });
|
|
14040
14418
|
}
|
|
14041
14419
|
function applyWorktreePkgCacheEnv(env, worktreePath) {
|
|
14042
14420
|
const cwd = worktreePath.trim();
|
|
@@ -14049,12 +14427,12 @@ function applyWorktreePkgCacheEnv(env, worktreePath) {
|
|
|
14049
14427
|
fillGroup(env, ["electron_config_cache"], next);
|
|
14050
14428
|
ensureWorktreePkgCacheDirs(cwd);
|
|
14051
14429
|
}
|
|
14052
|
-
var
|
|
14430
|
+
var import_node_fs38, import_node_path38, WORKTREE_PKG_CACHE_REL;
|
|
14053
14431
|
var init_worktree_pkg_cache = __esm({
|
|
14054
14432
|
"src/hook/worktree-pkg-cache.ts"() {
|
|
14055
14433
|
"use strict";
|
|
14056
|
-
|
|
14057
|
-
|
|
14434
|
+
import_node_fs38 = require("fs");
|
|
14435
|
+
import_node_path38 = require("path");
|
|
14058
14436
|
WORKTREE_PKG_CACHE_REL = ".context/.sideboard/pkg-cache";
|
|
14059
14437
|
}
|
|
14060
14438
|
});
|
|
@@ -15213,21 +15591,21 @@ function shouldRefreshReviewRequestTemplate(content) {
|
|
|
15213
15591
|
return LEGACY_REVIEW_TEMPLATE_MARKERS.every((m) => trimmed.includes(m));
|
|
15214
15592
|
}
|
|
15215
15593
|
function readTextIfPresent(abs) {
|
|
15216
|
-
if (!(0,
|
|
15594
|
+
if (!(0, import_node_fs39.existsSync)(abs)) return null;
|
|
15217
15595
|
try {
|
|
15218
|
-
const content = (0,
|
|
15596
|
+
const content = (0, import_node_fs39.readFileSync)(abs, "utf8");
|
|
15219
15597
|
return content.trim() ? content : null;
|
|
15220
15598
|
} catch {
|
|
15221
15599
|
return null;
|
|
15222
15600
|
}
|
|
15223
15601
|
}
|
|
15224
15602
|
function readLocalGuidelines(worktreePath) {
|
|
15225
|
-
const localAbs = (0,
|
|
15603
|
+
const localAbs = (0, import_node_path39.join)(worktreePath, REVIEW_REQUEST_PATH);
|
|
15226
15604
|
const localContent = readTextIfPresent(localAbs);
|
|
15227
15605
|
if (localContent && !shouldRefreshReviewRequestTemplate(localContent)) {
|
|
15228
15606
|
return { path: REVIEW_REQUEST_PATH, content: localContent };
|
|
15229
15607
|
}
|
|
15230
|
-
const legacyAbs = (0,
|
|
15608
|
+
const legacyAbs = (0, import_node_path39.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
|
|
15231
15609
|
const legacyContent = readTextIfPresent(legacyAbs);
|
|
15232
15610
|
if (legacyContent && !shouldRefreshReviewRequestTemplate(legacyContent)) {
|
|
15233
15611
|
return { path: LEGACY_REVIEW_REQUEST_PATH, content: legacyContent };
|
|
@@ -15251,27 +15629,27 @@ function contextGuidelines(content, source) {
|
|
|
15251
15629
|
};
|
|
15252
15630
|
}
|
|
15253
15631
|
function writeContextGuidelines(worktreePath, content) {
|
|
15254
|
-
const abs = (0,
|
|
15255
|
-
(0,
|
|
15632
|
+
const abs = (0, import_node_path39.join)(worktreePath, CONTEXT_REVIEW_PATH);
|
|
15633
|
+
(0, import_node_fs39.mkdirSync)((0, import_node_path39.dirname)(abs), { recursive: true });
|
|
15256
15634
|
const body = content.endsWith("\n") ? content : `${content}
|
|
15257
15635
|
`;
|
|
15258
|
-
(0,
|
|
15636
|
+
(0, import_node_fs39.writeFileSync)(abs, body, "utf8");
|
|
15259
15637
|
return body;
|
|
15260
15638
|
}
|
|
15261
15639
|
function readSideboardReview(worktreePath, repoPath) {
|
|
15262
|
-
const fromWorktree = readTextIfPresent((0,
|
|
15640
|
+
const fromWorktree = readTextIfPresent((0, import_node_path39.join)(worktreePath, REPO_REVIEW_PATH));
|
|
15263
15641
|
if (fromWorktree) return fromWorktree;
|
|
15264
15642
|
const repo = repoPath?.replace(/\/+$/, "");
|
|
15265
15643
|
const wt = worktreePath.replace(/\/+$/, "");
|
|
15266
15644
|
if (!repo || repo === wt) return null;
|
|
15267
|
-
return readTextIfPresent((0,
|
|
15645
|
+
return readTextIfPresent((0, import_node_path39.join)(repo, REPO_REVIEW_PATH));
|
|
15268
15646
|
}
|
|
15269
15647
|
function ensureReviewGuidelinesFile(worktreePath, repoPath) {
|
|
15270
|
-
const skillContent = readTextIfPresent((0,
|
|
15648
|
+
const skillContent = readTextIfPresent((0, import_node_path39.join)(worktreePath, REVIEW_SKILL_PATH));
|
|
15271
15649
|
if (skillContent) {
|
|
15272
15650
|
return { ...skillGuidelines(skillContent, "skill"), wrote: false };
|
|
15273
15651
|
}
|
|
15274
|
-
const contextContent = readTextIfPresent((0,
|
|
15652
|
+
const contextContent = readTextIfPresent((0, import_node_path39.join)(worktreePath, CONTEXT_REVIEW_PATH));
|
|
15275
15653
|
if (contextContent && !shouldRefreshReviewRequestTemplate(contextContent)) {
|
|
15276
15654
|
return { ...contextGuidelines(contextContent, "local"), wrote: false };
|
|
15277
15655
|
}
|
|
@@ -15309,7 +15687,7 @@ function buildReviewRequestAttachment(content, opts) {
|
|
|
15309
15687
|
};
|
|
15310
15688
|
}
|
|
15311
15689
|
function readExistingReviewRequestFile(worktreePath) {
|
|
15312
|
-
return readTextIfPresent((0,
|
|
15690
|
+
return readTextIfPresent((0, import_node_path39.join)(worktreePath, REVIEW_SKILL_PATH)) ?? readTextIfPresent((0, import_node_path39.join)(worktreePath, CONTEXT_REVIEW_PATH)) ?? readTextIfPresent((0, import_node_path39.join)(worktreePath, REPO_REVIEW_PATH)) ?? readTextIfPresent((0, import_node_path39.join)(worktreePath, REVIEW_REQUEST_PATH)) ?? readTextIfPresent((0, import_node_path39.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH));
|
|
15313
15691
|
}
|
|
15314
15692
|
async function requestReview(threadRef, send2) {
|
|
15315
15693
|
const from = findThreadByRef(threadRef);
|
|
@@ -15336,13 +15714,13 @@ async function requestReview(threadRef, send2) {
|
|
|
15336
15714
|
const started = await send2(tab.id, REVIEW_REQUEST_PREFILL);
|
|
15337
15715
|
return { tab: started, from };
|
|
15338
15716
|
}
|
|
15339
|
-
var import_node_crypto9,
|
|
15717
|
+
var import_node_crypto9, import_node_fs39, import_node_path39, REPO_REVIEW_PATH, REPO_REVIEW_NAME, CONTEXT_REVIEW_PATH, REVIEW_REQUEST_PATH, LEGACY_REVIEW_REQUEST_PATH, REVIEW_REQUEST_NAME, REVIEW_REQUEST_PREFILL, LEGACY_REVIEW_TEMPLATE_MARKERS;
|
|
15340
15718
|
var init_request_review = __esm({
|
|
15341
15719
|
"src/review/request-review.ts"() {
|
|
15342
15720
|
"use strict";
|
|
15343
15721
|
import_node_crypto9 = require("crypto");
|
|
15344
|
-
|
|
15345
|
-
|
|
15722
|
+
import_node_fs39 = require("fs");
|
|
15723
|
+
import_node_path39 = require("path");
|
|
15346
15724
|
init_global_workspace();
|
|
15347
15725
|
init_chat_tabs();
|
|
15348
15726
|
init_thread_store();
|
|
@@ -15368,9 +15746,9 @@ function matchSimpleGlob(pattern, name) {
|
|
|
15368
15746
|
return new RegExp(`^${escaped}$`).test(name);
|
|
15369
15747
|
}
|
|
15370
15748
|
function readWorktreeInclude(repoPath) {
|
|
15371
|
-
const path2 = (0,
|
|
15372
|
-
if (!(0,
|
|
15373
|
-
return (0,
|
|
15749
|
+
const path2 = (0, import_node_path40.join)(repoPath, ".worktreeinclude");
|
|
15750
|
+
if (!(0, import_node_fs40.existsSync)(path2)) return [];
|
|
15751
|
+
return (0, import_node_fs40.readFileSync)(path2, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
|
|
15374
15752
|
}
|
|
15375
15753
|
function resolveFilesToCopy(repoPath) {
|
|
15376
15754
|
const fromInclude = readWorktreeInclude(repoPath);
|
|
@@ -15380,10 +15758,10 @@ function resolveFilesToCopy(repoPath) {
|
|
|
15380
15758
|
if (settings?.fileIncludeGlobs?.length) {
|
|
15381
15759
|
const matched = [];
|
|
15382
15760
|
try {
|
|
15383
|
-
for (const entry of (0,
|
|
15761
|
+
for (const entry of (0, import_node_fs40.readdirSync)(repoPath, { withFileTypes: true })) {
|
|
15384
15762
|
if (!entry.isFile()) continue;
|
|
15385
15763
|
for (const glob of settings.fileIncludeGlobs) {
|
|
15386
|
-
if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0,
|
|
15764
|
+
if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path40.basename)(glob), entry.name)) {
|
|
15387
15765
|
matched.push(entry.name);
|
|
15388
15766
|
break;
|
|
15389
15767
|
}
|
|
@@ -15395,7 +15773,7 @@ function resolveFilesToCopy(repoPath) {
|
|
|
15395
15773
|
}
|
|
15396
15774
|
const defaults = [];
|
|
15397
15775
|
try {
|
|
15398
|
-
for (const entry of (0,
|
|
15776
|
+
for (const entry of (0, import_node_fs40.readdirSync)(repoPath, { withFileTypes: true })) {
|
|
15399
15777
|
if (entry.isFile() && entry.name.startsWith(".env")) {
|
|
15400
15778
|
defaults.push(entry.name);
|
|
15401
15779
|
}
|
|
@@ -15409,11 +15787,11 @@ function copyConfiguredFiles(repoPath, worktreePath) {
|
|
|
15409
15787
|
const patterns = resolveFilesToCopy(repoPath);
|
|
15410
15788
|
const copied = [];
|
|
15411
15789
|
for (const rel of patterns) {
|
|
15412
|
-
const src = (0,
|
|
15413
|
-
if (!(0,
|
|
15414
|
-
const dest = (0,
|
|
15415
|
-
(0,
|
|
15416
|
-
(0,
|
|
15790
|
+
const src = (0, import_node_path40.join)(repoPath, rel);
|
|
15791
|
+
if (!(0, import_node_fs40.existsSync)(src)) continue;
|
|
15792
|
+
const dest = (0, import_node_path40.join)(worktreePath, rel);
|
|
15793
|
+
(0, import_node_fs40.mkdirSync)((0, import_node_path40.dirname)(dest), { recursive: true });
|
|
15794
|
+
(0, import_node_fs40.copyFileSync)(src, dest);
|
|
15417
15795
|
copied.push(rel);
|
|
15418
15796
|
}
|
|
15419
15797
|
return copied;
|
|
@@ -15448,7 +15826,7 @@ function buildWorkspaceScriptEnv(opts, baseEnv) {
|
|
|
15448
15826
|
const env = stripNestedElectronEnv({
|
|
15449
15827
|
...baseEnv ?? process.env
|
|
15450
15828
|
});
|
|
15451
|
-
const name = opts.workspaceName ?? (0,
|
|
15829
|
+
const name = opts.workspaceName ?? (0, import_node_path40.basename)(opts.worktreePath);
|
|
15452
15830
|
const ports = opts.ports ?? [];
|
|
15453
15831
|
const primary = ports[0];
|
|
15454
15832
|
env.SIDEBOARD_WORKSPACE_NAME = name;
|
|
@@ -15711,13 +16089,13 @@ async function startDevServer(repoPath, worktreePath, onLine, opts) {
|
|
|
15711
16089
|
done: handle.done
|
|
15712
16090
|
};
|
|
15713
16091
|
}
|
|
15714
|
-
var
|
|
16092
|
+
var import_node_fs40, import_node_net, import_node_path40, import_execa4, import_node_readline3, PORT_RANGE_SIZE, cachedLoginEnv;
|
|
15715
16093
|
var init_conductor = __esm({
|
|
15716
16094
|
"src/hook/conductor.ts"() {
|
|
15717
16095
|
"use strict";
|
|
15718
|
-
|
|
16096
|
+
import_node_fs40 = require("fs");
|
|
15719
16097
|
import_node_net = require("net");
|
|
15720
|
-
|
|
16098
|
+
import_node_path40 = require("path");
|
|
15721
16099
|
import_execa4 = require("execa");
|
|
15722
16100
|
import_node_readline3 = require("readline");
|
|
15723
16101
|
init_settings();
|
|
@@ -15745,9 +16123,9 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
15745
16123
|
repoPaths?.length ? repoPaths : threads.map((t) => t.repoPath).filter(Boolean)
|
|
15746
16124
|
);
|
|
15747
16125
|
const homeRoot = sideboardWorkspacesDir();
|
|
15748
|
-
if ((0,
|
|
16126
|
+
if ((0, import_node_fs41.existsSync)(homeRoot)) {
|
|
15749
16127
|
try {
|
|
15750
|
-
for (const entry of (0,
|
|
16128
|
+
for (const entry of (0, import_node_fs41.readdirSync)(homeRoot, { withFileTypes: true })) {
|
|
15751
16129
|
if (!entry.isDirectory()) continue;
|
|
15752
16130
|
void entry;
|
|
15753
16131
|
}
|
|
@@ -15757,7 +16135,7 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
15757
16135
|
const orphans = [];
|
|
15758
16136
|
const seen = /* @__PURE__ */ new Set();
|
|
15759
16137
|
for (const repoPath of repos) {
|
|
15760
|
-
if (!repoPath || !(0,
|
|
16138
|
+
if (!repoPath || !(0, import_node_fs41.existsSync)(repoPath)) continue;
|
|
15761
16139
|
try {
|
|
15762
16140
|
const wts = await listWorktrees(repoPath);
|
|
15763
16141
|
for (const wt of wts) {
|
|
@@ -15768,7 +16146,7 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
15768
16146
|
seen.add(path2);
|
|
15769
16147
|
let mtimeMs = 0;
|
|
15770
16148
|
try {
|
|
15771
|
-
mtimeMs = (0,
|
|
16149
|
+
mtimeMs = (0, import_node_fs41.statSync)(path2).mtimeMs;
|
|
15772
16150
|
} catch {
|
|
15773
16151
|
mtimeMs = 0;
|
|
15774
16152
|
}
|
|
@@ -15778,16 +16156,16 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
15778
16156
|
}
|
|
15779
16157
|
try {
|
|
15780
16158
|
const root = worktreesRoot(repoPath);
|
|
15781
|
-
if ((0,
|
|
15782
|
-
for (const entry of (0,
|
|
16159
|
+
if ((0, import_node_fs41.existsSync)(root)) {
|
|
16160
|
+
for (const entry of (0, import_node_fs41.readdirSync)(root, { withFileTypes: true })) {
|
|
15783
16161
|
if (!entry.isDirectory()) continue;
|
|
15784
|
-
const path2 = (0,
|
|
16162
|
+
const path2 = (0, import_node_path41.join)(root, entry.name).replace(/\/$/, "");
|
|
15785
16163
|
if (known.has(path2) || seen.has(path2)) continue;
|
|
15786
|
-
if (!(0,
|
|
16164
|
+
if (!(0, import_node_fs41.existsSync)((0, import_node_path41.join)(path2, ".git"))) continue;
|
|
15787
16165
|
seen.add(path2);
|
|
15788
16166
|
let mtimeMs = 0;
|
|
15789
16167
|
try {
|
|
15790
|
-
mtimeMs = (0,
|
|
16168
|
+
mtimeMs = (0, import_node_fs41.statSync)(path2).mtimeMs;
|
|
15791
16169
|
} catch {
|
|
15792
16170
|
mtimeMs = Date.now();
|
|
15793
16171
|
}
|
|
@@ -15848,12 +16226,12 @@ function worktreeCleanupSettings() {
|
|
|
15848
16226
|
autoCleanupOrphans: a.autoCleanupOrphans
|
|
15849
16227
|
};
|
|
15850
16228
|
}
|
|
15851
|
-
var
|
|
16229
|
+
var import_node_fs41, import_node_path41;
|
|
15852
16230
|
var init_orphan_cleanup = __esm({
|
|
15853
16231
|
"src/git/orphan-cleanup.ts"() {
|
|
15854
16232
|
"use strict";
|
|
15855
|
-
|
|
15856
|
-
|
|
16233
|
+
import_node_fs41 = require("fs");
|
|
16234
|
+
import_node_path41 = require("path");
|
|
15857
16235
|
init_worktree();
|
|
15858
16236
|
init_thread_store();
|
|
15859
16237
|
init_paths();
|
|
@@ -15956,12 +16334,12 @@ async function cloneRepoIntoSideboard(opts) {
|
|
|
15956
16334
|
if (!url) throw new Error("Clone URL is required");
|
|
15957
16335
|
let name = opts.name?.trim();
|
|
15958
16336
|
if (!name) {
|
|
15959
|
-
const leaf = (0,
|
|
16337
|
+
const leaf = (0, import_node_path42.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
|
|
15960
16338
|
name = leaf || "repo";
|
|
15961
16339
|
}
|
|
15962
16340
|
name = name.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "repo";
|
|
15963
|
-
const dest = (0,
|
|
15964
|
-
if ((0,
|
|
16341
|
+
const dest = (0, import_node_path42.join)(sideboardReposDir(), name);
|
|
16342
|
+
if ((0, import_node_fs42.existsSync)(dest)) {
|
|
15965
16343
|
const repoPath2 = await resolveRepoRoot(dest);
|
|
15966
16344
|
const workspace2 = await ensureWorkspace(repoPath2);
|
|
15967
16345
|
return { repoPath: repoPath2, workspace: workspace2 };
|
|
@@ -15976,12 +16354,12 @@ async function cloneRepoIntoSideboard(opts) {
|
|
|
15976
16354
|
const workspace = await ensureWorkspace(repoPath);
|
|
15977
16355
|
return { repoPath, workspace };
|
|
15978
16356
|
}
|
|
15979
|
-
var
|
|
16357
|
+
var import_node_fs42, import_node_path42, import_execa6;
|
|
15980
16358
|
var init_clone_repo = __esm({
|
|
15981
16359
|
"src/git/clone-repo.ts"() {
|
|
15982
16360
|
"use strict";
|
|
15983
|
-
|
|
15984
|
-
|
|
16361
|
+
import_node_fs42 = require("fs");
|
|
16362
|
+
import_node_path42 = require("path");
|
|
15985
16363
|
import_execa6 = require("execa");
|
|
15986
16364
|
init_paths();
|
|
15987
16365
|
init_workspaces();
|
|
@@ -16099,24 +16477,24 @@ function jobTreeAlive(pid) {
|
|
|
16099
16477
|
return jobAlive(pid) || processGroupAlive(pid);
|
|
16100
16478
|
}
|
|
16101
16479
|
function readIntFile(file) {
|
|
16102
|
-
if (!(0,
|
|
16103
|
-
const n = Number.parseInt((0,
|
|
16480
|
+
if (!(0, import_node_fs43.existsSync)(file)) return null;
|
|
16481
|
+
const n = Number.parseInt((0, import_node_fs43.readFileSync)(file, "utf8").trim(), 10);
|
|
16104
16482
|
return Number.isInteger(n) ? n : null;
|
|
16105
16483
|
}
|
|
16106
16484
|
function jobDir(root, id, legacy = false) {
|
|
16107
|
-
return (0,
|
|
16485
|
+
return (0, import_node_path43.join)(root, legacy ? LEGACY_DETACHED_JOBS_DIR : DETACHED_JOBS_DIR, id);
|
|
16108
16486
|
}
|
|
16109
16487
|
function resolveJobDir(root, id) {
|
|
16110
16488
|
const modern = jobDir(root, id, false);
|
|
16111
|
-
if ((0,
|
|
16489
|
+
if ((0, import_node_fs43.existsSync)(modern)) return modern;
|
|
16112
16490
|
const legacy = jobDir(root, id, true);
|
|
16113
|
-
if ((0,
|
|
16491
|
+
if ((0, import_node_fs43.existsSync)(legacy)) return legacy;
|
|
16114
16492
|
return modern;
|
|
16115
16493
|
}
|
|
16116
16494
|
function listJobIdsIn(root, rel) {
|
|
16117
|
-
const dir = (0,
|
|
16118
|
-
if (!(0,
|
|
16119
|
-
return (0,
|
|
16495
|
+
const dir = (0, import_node_path43.join)(root, rel);
|
|
16496
|
+
if (!(0, import_node_fs43.existsSync)(dir)) return [];
|
|
16497
|
+
return (0, import_node_fs43.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && JOB_ID_RE.test(e.name)).map((e) => e.name);
|
|
16120
16498
|
}
|
|
16121
16499
|
function listRunningDetachedJobs(worktreePath) {
|
|
16122
16500
|
const root = worktreePath.trim();
|
|
@@ -16128,7 +16506,7 @@ function listRunningDetachedJobs(worktreePath) {
|
|
|
16128
16506
|
const running = [];
|
|
16129
16507
|
for (const id of ids) {
|
|
16130
16508
|
const dir = resolveJobDir(root, id);
|
|
16131
|
-
const pid = readIntFile((0,
|
|
16509
|
+
const pid = readIntFile((0, import_node_path43.join)(dir, "pid"));
|
|
16132
16510
|
if (jobTreeAlive(pid)) running.push(id);
|
|
16133
16511
|
}
|
|
16134
16512
|
return running.sort();
|
|
@@ -16210,8 +16588,8 @@ function planJobContinue(opts) {
|
|
|
16210
16588
|
return { action: "none" };
|
|
16211
16589
|
}
|
|
16212
16590
|
function tailProgress(logFile, maxLines = 12) {
|
|
16213
|
-
if (!(0,
|
|
16214
|
-
const lines = (0,
|
|
16591
|
+
if (!(0, import_node_fs43.existsSync)(logFile)) return "(no log yet)";
|
|
16592
|
+
const lines = (0, import_node_fs43.readFileSync)(logFile, "utf8").split("\n");
|
|
16215
16593
|
return lines.slice(-maxLines).join("\n");
|
|
16216
16594
|
}
|
|
16217
16595
|
function lastProgressLine(progress) {
|
|
@@ -16219,8 +16597,8 @@ function lastProgressLine(progress) {
|
|
|
16219
16597
|
return last ? last.slice(0, 72) : void 0;
|
|
16220
16598
|
}
|
|
16221
16599
|
function readLogLines(file) {
|
|
16222
|
-
if (!(0,
|
|
16223
|
-
const lines = (0,
|
|
16600
|
+
if (!(0, import_node_fs43.existsSync)(file)) return [];
|
|
16601
|
+
const lines = (0, import_node_fs43.readFileSync)(file, "utf8").split("\n");
|
|
16224
16602
|
if (lines.length && lines[lines.length - 1] === "") lines.pop();
|
|
16225
16603
|
return lines;
|
|
16226
16604
|
}
|
|
@@ -16231,15 +16609,15 @@ function takeDelta(logFile, cursorFile) {
|
|
|
16231
16609
|
return { delta: capJobLogDelta(lines.slice(start).join("\n")), nextCursor: lines.length };
|
|
16232
16610
|
}
|
|
16233
16611
|
function snapshotJob(dir) {
|
|
16234
|
-
const pid = readIntFile((0,
|
|
16612
|
+
const pid = readIntFile((0, import_node_path43.join)(dir, "pid"));
|
|
16235
16613
|
const running = jobTreeAlive(pid);
|
|
16236
16614
|
return {
|
|
16237
16615
|
pid,
|
|
16238
16616
|
running,
|
|
16239
|
-
exitCode: readIntFile((0,
|
|
16240
|
-
log: (0,
|
|
16241
|
-
cursor: (0,
|
|
16242
|
-
progress: tailProgress((0,
|
|
16617
|
+
exitCode: readIntFile((0, import_node_path43.join)(dir, "exit")),
|
|
16618
|
+
log: (0, import_node_path43.join)(dir, "log"),
|
|
16619
|
+
cursor: (0, import_node_path43.join)(dir, "present.cursor"),
|
|
16620
|
+
progress: tailProgress((0, import_node_path43.join)(dir, "log"))
|
|
16243
16621
|
};
|
|
16244
16622
|
}
|
|
16245
16623
|
function toResult(id, snap, extra) {
|
|
@@ -16248,8 +16626,8 @@ function toResult(id, snap, extra) {
|
|
|
16248
16626
|
const stillRunning = snap.running && !ok;
|
|
16249
16627
|
const { delta, nextCursor } = takeDelta(snap.log, snap.cursor);
|
|
16250
16628
|
try {
|
|
16251
|
-
(0,
|
|
16252
|
-
(0,
|
|
16629
|
+
(0, import_node_fs43.mkdirSync)((0, import_node_path43.dirname)(snap.cursor), { recursive: true });
|
|
16630
|
+
(0, import_node_fs43.writeFileSync)(snap.cursor, `${nextCursor}
|
|
16253
16631
|
`);
|
|
16254
16632
|
} catch {
|
|
16255
16633
|
}
|
|
@@ -16278,7 +16656,7 @@ async function waitForDetachedJob(cwd, id, opts) {
|
|
|
16278
16656
|
const dir = resolveJobDir(root, jobId);
|
|
16279
16657
|
const timeoutMs = mcpWaitForJobTimeoutMs(opts?.timeoutMs);
|
|
16280
16658
|
const sleep2 = opts?.sleep ?? sleepMs;
|
|
16281
|
-
if (!(0,
|
|
16659
|
+
if (!(0, import_node_fs43.existsSync)(dir)) {
|
|
16282
16660
|
return {
|
|
16283
16661
|
stillRunning: false,
|
|
16284
16662
|
ok: false,
|
|
@@ -16324,10 +16702,10 @@ function killProcessTree(pid, signal) {
|
|
|
16324
16702
|
}
|
|
16325
16703
|
function appendJobLog(logFile, line) {
|
|
16326
16704
|
try {
|
|
16327
|
-
(0,
|
|
16705
|
+
(0, import_node_fs43.mkdirSync)((0, import_node_path43.dirname)(logFile), { recursive: true });
|
|
16328
16706
|
const body = line.endsWith("\n") ? line : `${line}
|
|
16329
16707
|
`;
|
|
16330
|
-
(0,
|
|
16708
|
+
(0, import_node_fs43.appendFileSync)(logFile, body);
|
|
16331
16709
|
} catch {
|
|
16332
16710
|
}
|
|
16333
16711
|
}
|
|
@@ -16337,7 +16715,7 @@ async function stopDetachedJob(cwd, id, opts) {
|
|
|
16337
16715
|
const dir = resolveJobDir(root, jobId);
|
|
16338
16716
|
const sleep2 = opts?.sleep ?? sleepMs;
|
|
16339
16717
|
const why = opts?.reason?.trim() ?? "";
|
|
16340
|
-
if (!(0,
|
|
16718
|
+
if (!(0, import_node_fs43.existsSync)(dir)) {
|
|
16341
16719
|
return {
|
|
16342
16720
|
stillRunning: false,
|
|
16343
16721
|
ok: false,
|
|
@@ -16373,10 +16751,10 @@ async function stopDetachedJob(cwd, id, opts) {
|
|
|
16373
16751
|
killProcessTree(targetPid, "SIGKILL");
|
|
16374
16752
|
await sleep2(100);
|
|
16375
16753
|
}
|
|
16376
|
-
const exitFile = (0,
|
|
16377
|
-
if (!(0,
|
|
16754
|
+
const exitFile = (0, import_node_path43.join)(dir, "exit");
|
|
16755
|
+
if (!(0, import_node_fs43.existsSync)(exitFile)) {
|
|
16378
16756
|
try {
|
|
16379
|
-
(0,
|
|
16757
|
+
(0, import_node_fs43.writeFileSync)(exitFile, "1\n");
|
|
16380
16758
|
} catch {
|
|
16381
16759
|
}
|
|
16382
16760
|
}
|
|
@@ -16396,12 +16774,12 @@ async function stopDetachedJob(cwd, id, opts) {
|
|
|
16396
16774
|
hint: stopped ? MCP_STOP_JOB_HINT : MCP_WAIT_JOB_STILL_RUNNING_HINT
|
|
16397
16775
|
};
|
|
16398
16776
|
}
|
|
16399
|
-
var
|
|
16777
|
+
var import_node_fs43, import_node_path43, MAX_JOB_CONTINUES, MAX_JOB_DELTA_LINES, MAX_JOB_DELTA_CHARS, DEFERRED_DONE_MAX_CHARS, GH_WATCH_REFRESH, MCP_WAIT_JOB_STILL_RUNNING_HINT, MCP_STOP_JOB_HINT, JOB_ID_RE;
|
|
16400
16778
|
var init_wait_for_job = __esm({
|
|
16401
16779
|
"src/mcp/wait-for-job.ts"() {
|
|
16402
16780
|
"use strict";
|
|
16403
|
-
|
|
16404
|
-
|
|
16781
|
+
import_node_fs43 = require("fs");
|
|
16782
|
+
import_node_path43 = require("path");
|
|
16405
16783
|
init_workspace_scratch();
|
|
16406
16784
|
init_wait_for_turn();
|
|
16407
16785
|
MAX_JOB_CONTINUES = 8;
|
|
@@ -17689,7 +18067,7 @@ function reuseLiveThread(input, repoPath, match) {
|
|
|
17689
18067
|
}
|
|
17690
18068
|
async function createThread(input, _onSetupLine) {
|
|
17691
18069
|
const repoPath = await resolveRepoRoot(input.repoPath);
|
|
17692
|
-
if (!(0,
|
|
18070
|
+
if (!(0, import_node_fs44.existsSync)(repoPath)) {
|
|
17693
18071
|
throw new Error(`Repo not found: ${repoPath}`);
|
|
17694
18072
|
}
|
|
17695
18073
|
const reused = reuseLiveThread(input, repoPath, {
|
|
@@ -17874,11 +18252,11 @@ async function listLinearIssues(agent, repoPath) {
|
|
|
17874
18252
|
}
|
|
17875
18253
|
return adapter.listLinearIssues(repoPath);
|
|
17876
18254
|
}
|
|
17877
|
-
var
|
|
18255
|
+
var import_node_fs44;
|
|
17878
18256
|
var init_create = __esm({
|
|
17879
18257
|
"src/threads/create.ts"() {
|
|
17880
18258
|
"use strict";
|
|
17881
|
-
|
|
18259
|
+
import_node_fs44 = require("fs");
|
|
17882
18260
|
init_detect();
|
|
17883
18261
|
init_worktree();
|
|
17884
18262
|
init_home_board();
|
|
@@ -17998,20 +18376,20 @@ function writeTurnLive(threadId, progress) {
|
|
|
17998
18376
|
const path2 = threadLivePath(threadId);
|
|
17999
18377
|
const tmp = `${path2}.${process.pid}.tmp`;
|
|
18000
18378
|
try {
|
|
18001
|
-
(0,
|
|
18002
|
-
(0,
|
|
18379
|
+
(0, import_node_fs45.writeFileSync)(tmp, JSON.stringify(progress), "utf8");
|
|
18380
|
+
(0, import_node_fs45.renameSync)(tmp, path2);
|
|
18003
18381
|
} catch {
|
|
18004
18382
|
try {
|
|
18005
|
-
(0,
|
|
18383
|
+
(0, import_node_fs45.unlinkSync)(tmp);
|
|
18006
18384
|
} catch {
|
|
18007
18385
|
}
|
|
18008
18386
|
}
|
|
18009
18387
|
}
|
|
18010
18388
|
function readTurnLive(threadId) {
|
|
18011
18389
|
const path2 = threadLivePath(threadId);
|
|
18012
|
-
if (!(0,
|
|
18390
|
+
if (!(0, import_node_fs45.existsSync)(path2)) return null;
|
|
18013
18391
|
try {
|
|
18014
|
-
const raw = JSON.parse((0,
|
|
18392
|
+
const raw = JSON.parse((0, import_node_fs45.readFileSync)(path2, "utf8"));
|
|
18015
18393
|
if (!raw || typeof raw.summary !== "string") return null;
|
|
18016
18394
|
return raw;
|
|
18017
18395
|
} catch {
|
|
@@ -18023,17 +18401,17 @@ function clearTurnLive(threadId) {
|
|
|
18023
18401
|
if (buf?.timer) clearTimeout(buf.timer);
|
|
18024
18402
|
buffers.delete(threadId);
|
|
18025
18403
|
const path2 = threadLivePath(threadId);
|
|
18026
|
-
if (!(0,
|
|
18404
|
+
if (!(0, import_node_fs45.existsSync)(path2)) return;
|
|
18027
18405
|
try {
|
|
18028
|
-
(0,
|
|
18406
|
+
(0, import_node_fs45.unlinkSync)(path2);
|
|
18029
18407
|
} catch {
|
|
18030
18408
|
}
|
|
18031
18409
|
}
|
|
18032
|
-
var
|
|
18410
|
+
var import_node_fs45, buffers, FLUSH_MS, MAX_PARTS;
|
|
18033
18411
|
var init_turn_live = __esm({
|
|
18034
18412
|
"src/store/turn-live.ts"() {
|
|
18035
18413
|
"use strict";
|
|
18036
|
-
|
|
18414
|
+
import_node_fs45 = require("fs");
|
|
18037
18415
|
init_message_parts();
|
|
18038
18416
|
init_paths();
|
|
18039
18417
|
buffers = /* @__PURE__ */ new Map();
|
|
@@ -18253,7 +18631,7 @@ var init_quota_failover = __esm({
|
|
|
18253
18631
|
// src/threads/adopt.ts
|
|
18254
18632
|
function thisModuleFile() {
|
|
18255
18633
|
const cjsFile = typeof __filename !== "undefined" ? __filename : "";
|
|
18256
|
-
return cjsFile || process.argv[1] || (0,
|
|
18634
|
+
return cjsFile || process.argv[1] || (0, import_node_path44.join)(process.cwd(), "package.json");
|
|
18257
18635
|
}
|
|
18258
18636
|
function openReadonlySqlite(file) {
|
|
18259
18637
|
const req = (0, import_node_module4.createRequire)(thisModuleFile());
|
|
@@ -18271,21 +18649,21 @@ function mapAgentType(raw) {
|
|
|
18271
18649
|
return null;
|
|
18272
18650
|
}
|
|
18273
18651
|
function resolveConductorCursorAgentId(workspacePath) {
|
|
18274
|
-
if (!workspacePath || !(0,
|
|
18652
|
+
if (!workspacePath || !(0, import_node_fs46.existsSync)(CURSOR_SDK_STORE)) return null;
|
|
18275
18653
|
const normalized = workspacePath.replace(/\/$/, "");
|
|
18276
18654
|
let best = null;
|
|
18277
18655
|
let hashes;
|
|
18278
18656
|
try {
|
|
18279
|
-
hashes = (0,
|
|
18657
|
+
hashes = (0, import_node_fs46.readdirSync)(CURSOR_SDK_STORE);
|
|
18280
18658
|
} catch {
|
|
18281
18659
|
return null;
|
|
18282
18660
|
}
|
|
18283
18661
|
for (const hash of hashes) {
|
|
18284
|
-
const agentsFile = (0,
|
|
18285
|
-
if (!(0,
|
|
18662
|
+
const agentsFile = (0, import_node_path44.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
|
|
18663
|
+
if (!(0, import_node_fs46.existsSync)(agentsFile)) continue;
|
|
18286
18664
|
let text7;
|
|
18287
18665
|
try {
|
|
18288
|
-
text7 = (0,
|
|
18666
|
+
text7 = (0, import_node_fs46.readFileSync)(agentsFile, "utf8");
|
|
18289
18667
|
} catch {
|
|
18290
18668
|
continue;
|
|
18291
18669
|
}
|
|
@@ -18309,7 +18687,7 @@ function resolveConductorCursorAgentId(workspacePath) {
|
|
|
18309
18687
|
return best?.agentId ?? null;
|
|
18310
18688
|
}
|
|
18311
18689
|
async function adoptThread(input) {
|
|
18312
|
-
if (!(0,
|
|
18690
|
+
if (!(0, import_node_fs46.existsSync)(input.worktreePath)) {
|
|
18313
18691
|
throw new Error(`Worktree not found: ${input.worktreePath}`);
|
|
18314
18692
|
}
|
|
18315
18693
|
const repoPath = await resolveRepoRoot(input.worktreePath);
|
|
@@ -18338,18 +18716,18 @@ function conductorDbPath() {
|
|
|
18338
18716
|
return CONDUCTOR_DB;
|
|
18339
18717
|
}
|
|
18340
18718
|
function listConductorWorkspaces() {
|
|
18341
|
-
if (!(0,
|
|
18719
|
+
if (!(0, import_node_fs46.existsSync)(CONDUCTOR_DB)) {
|
|
18342
18720
|
throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
|
|
18343
18721
|
}
|
|
18344
|
-
const tmp = (0,
|
|
18345
|
-
const snapshot = (0,
|
|
18722
|
+
const tmp = (0, import_node_fs46.mkdtempSync)((0, import_node_path44.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
|
|
18723
|
+
const snapshot = (0, import_node_path44.join)(tmp, "conductor.db");
|
|
18346
18724
|
try {
|
|
18347
|
-
(0,
|
|
18725
|
+
(0, import_node_fs46.copyFileSync)(CONDUCTOR_DB, snapshot);
|
|
18348
18726
|
for (const suffix of ["-wal", "-shm"]) {
|
|
18349
18727
|
const src = `${CONDUCTOR_DB}${suffix}`;
|
|
18350
|
-
if ((0,
|
|
18728
|
+
if ((0, import_node_fs46.existsSync)(src)) {
|
|
18351
18729
|
try {
|
|
18352
|
-
(0,
|
|
18730
|
+
(0, import_node_fs46.copyFileSync)(src, `${snapshot}${suffix}`);
|
|
18353
18731
|
} catch {
|
|
18354
18732
|
}
|
|
18355
18733
|
}
|
|
@@ -18425,22 +18803,22 @@ function listConductorWorkspaces() {
|
|
|
18425
18803
|
db.close();
|
|
18426
18804
|
}
|
|
18427
18805
|
} finally {
|
|
18428
|
-
(0,
|
|
18806
|
+
(0, import_node_fs46.rmSync)(tmp, { recursive: true, force: true });
|
|
18429
18807
|
}
|
|
18430
18808
|
}
|
|
18431
18809
|
function importConductorWorkspace(workspaceId) {
|
|
18432
|
-
if (!(0,
|
|
18810
|
+
if (!(0, import_node_fs46.existsSync)(CONDUCTOR_DB)) {
|
|
18433
18811
|
throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
|
|
18434
18812
|
}
|
|
18435
|
-
const tmp = (0,
|
|
18436
|
-
const snapshot = (0,
|
|
18813
|
+
const tmp = (0, import_node_fs46.mkdtempSync)((0, import_node_path44.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
|
|
18814
|
+
const snapshot = (0, import_node_path44.join)(tmp, "conductor.db");
|
|
18437
18815
|
try {
|
|
18438
|
-
(0,
|
|
18816
|
+
(0, import_node_fs46.copyFileSync)(CONDUCTOR_DB, snapshot);
|
|
18439
18817
|
for (const suffix of ["-wal", "-shm"]) {
|
|
18440
18818
|
const src = `${CONDUCTOR_DB}${suffix}`;
|
|
18441
|
-
if ((0,
|
|
18819
|
+
if ((0, import_node_fs46.existsSync)(src)) {
|
|
18442
18820
|
try {
|
|
18443
|
-
(0,
|
|
18821
|
+
(0, import_node_fs46.copyFileSync)(src, `${snapshot}${suffix}`);
|
|
18444
18822
|
} catch {
|
|
18445
18823
|
}
|
|
18446
18824
|
}
|
|
@@ -18458,7 +18836,7 @@ function importConductorWorkspace(workspaceId) {
|
|
|
18458
18836
|
).get(workspaceId);
|
|
18459
18837
|
if (!row) throw new Error(`Conductor workspace not found: ${workspaceId}`);
|
|
18460
18838
|
const worktreePath = String(row.workspacePath);
|
|
18461
|
-
if (!(0,
|
|
18839
|
+
if (!(0, import_node_fs46.existsSync)(worktreePath)) {
|
|
18462
18840
|
throw new Error(`Conductor worktree missing on disk: ${worktreePath}`);
|
|
18463
18841
|
}
|
|
18464
18842
|
let sessionId = null;
|
|
@@ -18521,31 +18899,31 @@ function importConductorWorkspace(workspaceId) {
|
|
|
18521
18899
|
db.close();
|
|
18522
18900
|
}
|
|
18523
18901
|
} finally {
|
|
18524
|
-
(0,
|
|
18902
|
+
(0, import_node_fs46.rmSync)(tmp, { recursive: true, force: true });
|
|
18525
18903
|
}
|
|
18526
18904
|
}
|
|
18527
18905
|
async function importConductorWorkspaceAsync(workspaceId) {
|
|
18528
18906
|
return importConductorWorkspace(workspaceId);
|
|
18529
18907
|
}
|
|
18530
|
-
var import_node_child_process5,
|
|
18908
|
+
var import_node_child_process5, import_node_fs46, import_node_os14, import_node_path44, import_node_module4, CONDUCTOR_APP_SUPPORT, CONDUCTOR_DB, CURSOR_SDK_STORE;
|
|
18531
18909
|
var init_adopt = __esm({
|
|
18532
18910
|
"src/threads/adopt.ts"() {
|
|
18533
18911
|
"use strict";
|
|
18534
18912
|
import_node_child_process5 = require("child_process");
|
|
18535
|
-
|
|
18536
|
-
|
|
18537
|
-
|
|
18913
|
+
import_node_fs46 = require("fs");
|
|
18914
|
+
import_node_os14 = require("os");
|
|
18915
|
+
import_node_path44 = require("path");
|
|
18538
18916
|
import_node_module4 = require("module");
|
|
18539
18917
|
init_worktree();
|
|
18540
18918
|
init_thread_store();
|
|
18541
|
-
CONDUCTOR_APP_SUPPORT = (0,
|
|
18919
|
+
CONDUCTOR_APP_SUPPORT = (0, import_node_path44.join)(
|
|
18542
18920
|
process.env.HOME ?? "",
|
|
18543
18921
|
"Library",
|
|
18544
18922
|
"Application Support",
|
|
18545
18923
|
"com.conductor.app"
|
|
18546
18924
|
);
|
|
18547
|
-
CONDUCTOR_DB = (0,
|
|
18548
|
-
CURSOR_SDK_STORE = (0,
|
|
18925
|
+
CONDUCTOR_DB = (0, import_node_path44.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
|
|
18926
|
+
CURSOR_SDK_STORE = (0, import_node_path44.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
|
|
18549
18927
|
}
|
|
18550
18928
|
});
|
|
18551
18929
|
|
|
@@ -18612,7 +18990,7 @@ async function openStackLayer(input, _onSetupLine) {
|
|
|
18612
18990
|
let createdWorktree = false;
|
|
18613
18991
|
const trees = await listWorktrees(repoPath);
|
|
18614
18992
|
const checkedOut = trees.find((w) => w.branch === branchName);
|
|
18615
|
-
if (checkedOut?.path && (0,
|
|
18993
|
+
if (checkedOut?.path && (0, import_node_fs47.existsSync)(checkedOut.path)) {
|
|
18616
18994
|
if (input.reuseExistingWorktree !== false) {
|
|
18617
18995
|
worktreePath = checkedOut.path;
|
|
18618
18996
|
} else {
|
|
@@ -18754,7 +19132,7 @@ async function initStackFromThread(input, onSetupLine) {
|
|
|
18754
19132
|
async function createPrStack(input, onSetupLine) {
|
|
18755
19133
|
await requireAgent(input.agent);
|
|
18756
19134
|
const repoPath = await resolveRepoRoot(input.repoPath);
|
|
18757
|
-
if (!(0,
|
|
19135
|
+
if (!(0, import_node_fs47.existsSync)(repoPath)) throw new Error(`Repo not found: ${repoPath}`);
|
|
18758
19136
|
if (!input.branches.length) throw new Error("At least one branch name required");
|
|
18759
19137
|
const status = await detectGhStack(repoPath);
|
|
18760
19138
|
if (!status.available) throw new Error(status.reason);
|
|
@@ -18821,7 +19199,7 @@ async function createPrStack(input, onSetupLine) {
|
|
|
18821
19199
|
}
|
|
18822
19200
|
}
|
|
18823
19201
|
const claimed = new Set(threads.map((t) => t.worktreePath));
|
|
18824
|
-
if (!claimed.has(bootstrap.worktreePath) && (0,
|
|
19202
|
+
if (!claimed.has(bootstrap.worktreePath) && (0, import_node_fs47.existsSync)(bootstrap.worktreePath)) {
|
|
18825
19203
|
try {
|
|
18826
19204
|
await removeWorktree(repoPath, bootstrap.worktreePath, {
|
|
18827
19205
|
deleteBranch: bootstrap.branchName
|
|
@@ -18841,11 +19219,11 @@ function stackAgentDefaultsFrom(input) {
|
|
|
18841
19219
|
planMode: input.planMode
|
|
18842
19220
|
};
|
|
18843
19221
|
}
|
|
18844
|
-
var
|
|
19222
|
+
var import_node_fs47;
|
|
18845
19223
|
var init_stack_layers = __esm({
|
|
18846
19224
|
"src/threads/stack-layers.ts"() {
|
|
18847
19225
|
"use strict";
|
|
18848
|
-
|
|
19226
|
+
import_node_fs47 = require("fs");
|
|
18849
19227
|
init_detect();
|
|
18850
19228
|
init_run();
|
|
18851
19229
|
init_stack();
|
|
@@ -18858,7 +19236,7 @@ var init_stack_layers = __esm({
|
|
|
18858
19236
|
|
|
18859
19237
|
// src/diff/diff.ts
|
|
18860
19238
|
async function inspectGitWorktree(worktreePath) {
|
|
18861
|
-
if (!worktreePath || !(0,
|
|
19239
|
+
if (!worktreePath || !(0, import_node_fs48.existsSync)(worktreePath)) return "missing_worktree";
|
|
18862
19240
|
const check = await git(["rev-parse", "--is-inside-work-tree"], worktreePath, {
|
|
18863
19241
|
reject: false
|
|
18864
19242
|
});
|
|
@@ -18866,7 +19244,7 @@ async function inspectGitWorktree(worktreePath) {
|
|
|
18866
19244
|
return "ok";
|
|
18867
19245
|
}
|
|
18868
19246
|
async function initializeGitRepository(worktreePath) {
|
|
18869
|
-
if (!worktreePath || !(0,
|
|
19247
|
+
if (!worktreePath || !(0, import_node_fs48.existsSync)(worktreePath)) {
|
|
18870
19248
|
throw new Error("Worktree not found");
|
|
18871
19249
|
}
|
|
18872
19250
|
const status = await inspectGitWorktree(worktreePath);
|
|
@@ -19000,11 +19378,11 @@ new file mode 100644
|
|
|
19000
19378
|
};
|
|
19001
19379
|
}
|
|
19002
19380
|
async function untrackedPatch(worktreePath, path2, maxHunk) {
|
|
19003
|
-
const abs = (0,
|
|
19381
|
+
const abs = (0, import_node_path45.join)(worktreePath, path2);
|
|
19004
19382
|
try {
|
|
19005
|
-
const st = (0,
|
|
19383
|
+
const st = (0, import_node_fs48.statSync)(abs);
|
|
19006
19384
|
if (st.isFile() && st.size > maxHunk) {
|
|
19007
|
-
const buf = (0,
|
|
19385
|
+
const buf = (0, import_node_fs48.readFileSync)(abs).subarray(0, maxHunk);
|
|
19008
19386
|
return syntheticAddPatch(path2, buf.toString("utf8"), maxHunk);
|
|
19009
19387
|
}
|
|
19010
19388
|
} catch {
|
|
@@ -19493,8 +19871,8 @@ function isImageRelativePath(relativePath) {
|
|
|
19493
19871
|
function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
19494
19872
|
assertSafeRelativePath(relativePath);
|
|
19495
19873
|
const maxBytes = opts?.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES;
|
|
19496
|
-
const abs = (0,
|
|
19497
|
-
const st = (0,
|
|
19874
|
+
const abs = (0, import_node_path45.join)(worktreePath, relativePath);
|
|
19875
|
+
const st = (0, import_node_fs48.statSync)(abs);
|
|
19498
19876
|
if (!st.isFile()) {
|
|
19499
19877
|
throw new Error(`Not a file: ${relativePath}`);
|
|
19500
19878
|
}
|
|
@@ -19503,7 +19881,7 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
|
19503
19881
|
`File too large to upload (${st.size} bytes; max ${maxBytes})`
|
|
19504
19882
|
);
|
|
19505
19883
|
}
|
|
19506
|
-
const buf = (0,
|
|
19884
|
+
const buf = (0, import_node_fs48.readFileSync)(abs);
|
|
19507
19885
|
return {
|
|
19508
19886
|
path: relativePath,
|
|
19509
19887
|
contentBase64: buf.toString("base64"),
|
|
@@ -19513,12 +19891,12 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
|
19513
19891
|
function readWorktreeFile(worktreePath, relativePath, opts) {
|
|
19514
19892
|
assertSafeRelativePath(relativePath);
|
|
19515
19893
|
const maxBytes = opts?.maxBytes ?? 2e5;
|
|
19516
|
-
const abs = (0,
|
|
19517
|
-
const st = (0,
|
|
19894
|
+
const abs = (0, import_node_path45.join)(worktreePath, relativePath);
|
|
19895
|
+
const st = (0, import_node_fs48.statSync)(abs);
|
|
19518
19896
|
if (!st.isFile()) {
|
|
19519
19897
|
throw new Error(`Not a file: ${relativePath}`);
|
|
19520
19898
|
}
|
|
19521
|
-
const buf = (0,
|
|
19899
|
+
const buf = (0, import_node_fs48.readFileSync)(abs);
|
|
19522
19900
|
if (isImageRelativePath(relativePath)) {
|
|
19523
19901
|
const maxImageBytes = Math.max(maxBytes, 15e6);
|
|
19524
19902
|
const truncated2 = buf.length > maxImageBytes;
|
|
@@ -19561,9 +19939,9 @@ function assertSafeRelativePath(relativePath) {
|
|
|
19561
19939
|
}
|
|
19562
19940
|
function writeWorktreeFile(worktreePath, relativePath, content) {
|
|
19563
19941
|
assertSafeRelativePath(relativePath);
|
|
19564
|
-
const abs = (0,
|
|
19565
|
-
(0,
|
|
19566
|
-
(0,
|
|
19942
|
+
const abs = (0, import_node_path45.join)(worktreePath, relativePath);
|
|
19943
|
+
(0, import_node_fs48.mkdirSync)((0, import_node_path45.dirname)(abs), { recursive: true });
|
|
19944
|
+
(0, import_node_fs48.writeFileSync)(abs, content, "utf8");
|
|
19567
19945
|
return { path: relativePath };
|
|
19568
19946
|
}
|
|
19569
19947
|
async function getDiffSummary(worktreePath, repoPath, opts) {
|
|
@@ -19580,12 +19958,12 @@ async function getDiffSummary(worktreePath, repoPath, opts) {
|
|
|
19580
19958
|
truncated: full.files.length > maxFiles
|
|
19581
19959
|
};
|
|
19582
19960
|
}
|
|
19583
|
-
var
|
|
19961
|
+
var import_node_fs48, import_node_path45, mergeBaseCache, MERGE_BASE_TTL_MS, SHA_RE, IMAGE_EXTENSIONS2, DEFAULT_UPLOAD_MAX_BYTES;
|
|
19584
19962
|
var init_diff = __esm({
|
|
19585
19963
|
"src/diff/diff.ts"() {
|
|
19586
19964
|
"use strict";
|
|
19587
|
-
|
|
19588
|
-
|
|
19965
|
+
import_node_fs48 = require("fs");
|
|
19966
|
+
import_node_path45 = require("path");
|
|
19589
19967
|
init_run();
|
|
19590
19968
|
init_worktree();
|
|
19591
19969
|
mergeBaseCache = /* @__PURE__ */ new Map();
|
|
@@ -19942,7 +20320,7 @@ function parseFrontmatter(content) {
|
|
|
19942
20320
|
}
|
|
19943
20321
|
function readSkill(skillMd, source) {
|
|
19944
20322
|
try {
|
|
19945
|
-
const content = (0,
|
|
20323
|
+
const content = (0, import_node_fs49.readFileSync)(skillMd, "utf8");
|
|
19946
20324
|
const { name: fmName, description } = parseFrontmatter(content);
|
|
19947
20325
|
const dirName = skillMd.split("/").slice(-2, -1)[0] || "skill";
|
|
19948
20326
|
const name = fmName || dirName;
|
|
@@ -19961,19 +20339,19 @@ function readSkill(skillMd, source) {
|
|
|
19961
20339
|
}
|
|
19962
20340
|
}
|
|
19963
20341
|
function scanSkillsDir(dir, source, out) {
|
|
19964
|
-
if (!(0,
|
|
20342
|
+
if (!(0, import_node_fs49.existsSync)(dir)) return;
|
|
19965
20343
|
let entries;
|
|
19966
20344
|
try {
|
|
19967
|
-
entries = (0,
|
|
20345
|
+
entries = (0, import_node_fs49.readdirSync)(dir);
|
|
19968
20346
|
} catch {
|
|
19969
20347
|
return;
|
|
19970
20348
|
}
|
|
19971
20349
|
for (const entry of entries) {
|
|
19972
20350
|
if (entry.startsWith(".")) continue;
|
|
19973
|
-
const skillMd = (0,
|
|
19974
|
-
if (!(0,
|
|
20351
|
+
const skillMd = (0, import_node_path46.join)(dir, entry, "SKILL.md");
|
|
20352
|
+
if (!(0, import_node_fs49.existsSync)(skillMd)) continue;
|
|
19975
20353
|
try {
|
|
19976
|
-
if (!(0,
|
|
20354
|
+
if (!(0, import_node_fs49.statSync)(skillMd).isFile()) continue;
|
|
19977
20355
|
} catch {
|
|
19978
20356
|
continue;
|
|
19979
20357
|
}
|
|
@@ -19982,24 +20360,24 @@ function scanSkillsDir(dir, source, out) {
|
|
|
19982
20360
|
}
|
|
19983
20361
|
}
|
|
19984
20362
|
function scanClaudePluginSkills(pluginsRoot, out) {
|
|
19985
|
-
if (!(0,
|
|
20363
|
+
if (!(0, import_node_fs49.existsSync)(pluginsRoot)) return;
|
|
19986
20364
|
const walk = (dir, depth, lookingForSkillsDir) => {
|
|
19987
20365
|
if (depth > 7) return;
|
|
19988
20366
|
let entries;
|
|
19989
20367
|
try {
|
|
19990
|
-
entries = (0,
|
|
20368
|
+
entries = (0, import_node_fs49.readdirSync)(dir);
|
|
19991
20369
|
} catch {
|
|
19992
20370
|
return;
|
|
19993
20371
|
}
|
|
19994
20372
|
if (lookingForSkillsDir && entries.includes("SKILL.md")) {
|
|
19995
|
-
const skill = readSkill((0,
|
|
20373
|
+
const skill = readSkill((0, import_node_path46.join)(dir, "SKILL.md"), "cli");
|
|
19996
20374
|
if (skill) out.push(skill);
|
|
19997
20375
|
}
|
|
19998
20376
|
for (const entry of entries) {
|
|
19999
20377
|
if (entry === "node_modules" || entry === ".git") continue;
|
|
20000
|
-
const full = (0,
|
|
20378
|
+
const full = (0, import_node_path46.join)(dir, entry);
|
|
20001
20379
|
try {
|
|
20002
|
-
if (!(0,
|
|
20380
|
+
if (!(0, import_node_fs49.statSync)(full).isDirectory()) continue;
|
|
20003
20381
|
} catch {
|
|
20004
20382
|
continue;
|
|
20005
20383
|
}
|
|
@@ -20014,20 +20392,20 @@ function scanClaudePluginSkills(pluginsRoot, out) {
|
|
|
20014
20392
|
walk(pluginsRoot, 0, false);
|
|
20015
20393
|
}
|
|
20016
20394
|
function discoverSkills(worktreePath) {
|
|
20017
|
-
const home = (0,
|
|
20395
|
+
const home = (0, import_node_os15.homedir)();
|
|
20018
20396
|
const collected = [];
|
|
20019
20397
|
for (const rel of [".claude/skills", ".cursor/skills", ".sideboard/skills", ".brightsy/skills", "skills"]) {
|
|
20020
|
-
scanSkillsDir((0,
|
|
20398
|
+
scanSkillsDir((0, import_node_path46.join)(worktreePath, rel), "workspace", collected);
|
|
20021
20399
|
}
|
|
20022
20400
|
for (const abs of [
|
|
20023
|
-
(0,
|
|
20024
|
-
(0,
|
|
20025
|
-
(0,
|
|
20026
|
-
(0,
|
|
20401
|
+
(0, import_node_path46.join)(home, ".claude/skills"),
|
|
20402
|
+
(0, import_node_path46.join)(home, ".cursor/skills"),
|
|
20403
|
+
(0, import_node_path46.join)(home, ".sideboard/skills"),
|
|
20404
|
+
(0, import_node_path46.join)(home, ".brightsy/skills")
|
|
20027
20405
|
]) {
|
|
20028
20406
|
scanSkillsDir(abs, "user", collected);
|
|
20029
20407
|
}
|
|
20030
|
-
scanClaudePluginSkills((0,
|
|
20408
|
+
scanClaudePluginSkills((0, import_node_path46.join)(home, ".claude/plugins"), collected);
|
|
20031
20409
|
collected.push(...bundledSkills());
|
|
20032
20410
|
const rank = {
|
|
20033
20411
|
workspace: 0,
|
|
@@ -20053,7 +20431,7 @@ function readSkillBody(skillPath, maxChars = 12e3) {
|
|
|
20053
20431
|
\u2026(truncated)` : body;
|
|
20054
20432
|
}
|
|
20055
20433
|
}
|
|
20056
|
-
const raw = (0,
|
|
20434
|
+
const raw = (0, import_node_fs49.readFileSync)(skillPath, "utf8");
|
|
20057
20435
|
if (raw.startsWith("---")) {
|
|
20058
20436
|
const end = raw.indexOf("\n---", 3);
|
|
20059
20437
|
if (end >= 0) {
|
|
@@ -20067,13 +20445,13 @@ function readSkillBody(skillPath, maxChars = 12e3) {
|
|
|
20067
20445
|
|
|
20068
20446
|
\u2026(truncated)` : raw;
|
|
20069
20447
|
}
|
|
20070
|
-
var
|
|
20448
|
+
var import_node_fs49, import_node_os15, import_node_path46, BUNDLED_SKILL_PREFIX;
|
|
20071
20449
|
var init_discover = __esm({
|
|
20072
20450
|
"src/skills/discover.ts"() {
|
|
20073
20451
|
"use strict";
|
|
20074
|
-
|
|
20075
|
-
|
|
20076
|
-
|
|
20452
|
+
import_node_fs49 = require("fs");
|
|
20453
|
+
import_node_os15 = require("os");
|
|
20454
|
+
import_node_path46 = require("path");
|
|
20077
20455
|
init_long_running();
|
|
20078
20456
|
BUNDLED_SKILL_PREFIX = "bundled:";
|
|
20079
20457
|
}
|
|
@@ -20167,8 +20545,8 @@ var init_expand = __esm({
|
|
|
20167
20545
|
// src/skills/detached-job-path.ts
|
|
20168
20546
|
function detachedJobScriptIn(dir) {
|
|
20169
20547
|
for (const name of DETACHED_JOB_FILENAMES) {
|
|
20170
|
-
const script = (0,
|
|
20171
|
-
if ((0,
|
|
20548
|
+
const script = (0, import_node_path47.join)(dir, "scripts", name);
|
|
20549
|
+
if ((0, import_node_fs50.existsSync)(script)) return script;
|
|
20172
20550
|
}
|
|
20173
20551
|
return null;
|
|
20174
20552
|
}
|
|
@@ -20180,11 +20558,11 @@ function packagedDetachedJobPath() {
|
|
|
20180
20558
|
function resolveDetachedJobScript() {
|
|
20181
20559
|
const packaged = packagedDetachedJobPath();
|
|
20182
20560
|
if (packaged) return packaged;
|
|
20183
|
-
let dir = (0,
|
|
20561
|
+
let dir = (0, import_node_path47.dirname)((0, import_node_url3.fileURLToPath)(import_meta3.url));
|
|
20184
20562
|
for (let i = 0; i < 8; i++) {
|
|
20185
20563
|
const candidate = detachedJobScriptIn(dir);
|
|
20186
20564
|
if (candidate) return candidate;
|
|
20187
|
-
const parent = (0,
|
|
20565
|
+
const parent = (0, import_node_path47.dirname)(dir);
|
|
20188
20566
|
if (parent === dir) break;
|
|
20189
20567
|
dir = parent;
|
|
20190
20568
|
}
|
|
@@ -20195,12 +20573,12 @@ function formatDetachedJobInvoke(scriptPath) {
|
|
|
20195
20573
|
if (resolved) return `node ${JSON.stringify(resolved)}`;
|
|
20196
20574
|
return "node scripts/detached-job.cjs";
|
|
20197
20575
|
}
|
|
20198
|
-
var
|
|
20576
|
+
var import_node_fs50, import_node_path47, import_node_url3, import_meta3, DETACHED_JOB_FILENAMES;
|
|
20199
20577
|
var init_detached_job_path = __esm({
|
|
20200
20578
|
"src/skills/detached-job-path.ts"() {
|
|
20201
20579
|
"use strict";
|
|
20202
|
-
|
|
20203
|
-
|
|
20580
|
+
import_node_fs50 = require("fs");
|
|
20581
|
+
import_node_path47 = require("path");
|
|
20204
20582
|
import_node_url3 = require("url");
|
|
20205
20583
|
init_packaged_runtime();
|
|
20206
20584
|
import_meta3 = {};
|
|
@@ -20382,9 +20760,9 @@ function formatPrGateDirective() {
|
|
|
20382
20760
|
}
|
|
20383
20761
|
function formatProcessGuideDirective(opts) {
|
|
20384
20762
|
const worktree = opts?.worktreePath?.trim();
|
|
20385
|
-
const hasGraphSkill = !!worktree && (0,
|
|
20386
|
-
const hasReviewSkill = !!worktree && (0,
|
|
20387
|
-
const hasInstallSkill = !!worktree && (0,
|
|
20763
|
+
const hasGraphSkill = !!worktree && (0, import_node_fs51.existsSync)((0, import_node_path48.join)(worktree, ".claude/skills/graph-engineering/SKILL.md"));
|
|
20764
|
+
const hasReviewSkill = !!worktree && (0, import_node_fs51.existsSync)((0, import_node_path48.join)(worktree, ".claude/skills/review/SKILL.md"));
|
|
20765
|
+
const hasInstallSkill = !!worktree && (0, import_node_fs51.existsSync)((0, import_node_path48.join)(worktree, ".claude/skills/worktree-install/SKILL.md"));
|
|
20388
20766
|
return [
|
|
20389
20767
|
"Process guides (recurring work only):",
|
|
20390
20768
|
hasGraphSkill ? "- Migrations, ports, batch fixes, and other fan-out: follow `.claude/skills/graph-engineering/SKILL.md` (`/graph-engineering`). Judge first; state on disk; grow the rulebook; do not patch around it." : null,
|
|
@@ -20422,12 +20800,12 @@ function formatArtifactDirective() {
|
|
|
20422
20800
|
function formatUiReminder() {
|
|
20423
20801
|
return "Sideboard UI: markdown table is enough to read data; present_schema if they ask to edit/filter (even after markdown); present_files for the file manager. html fence or present_artifact, not both for the same document. type=log appends (same artifact_id, new lines only). ask_user only for a real multiple-choice (not hellos, \u201Cwhat next?\u201D, or after a review) \u2014 reply in chat. Do not say artifacts/CMS UI are unavailable.";
|
|
20424
20802
|
}
|
|
20425
|
-
var
|
|
20803
|
+
var import_node_fs51, import_node_path48, PR_GOAL_RE, GITHUB_TICKET_REF, KEYED_TICKET_REF;
|
|
20426
20804
|
var init_instructions = __esm({
|
|
20427
20805
|
"src/agents/instructions.ts"() {
|
|
20428
20806
|
"use strict";
|
|
20429
|
-
|
|
20430
|
-
|
|
20807
|
+
import_node_fs51 = require("fs");
|
|
20808
|
+
import_node_path48 = require("path");
|
|
20431
20809
|
init_git_auth_mode();
|
|
20432
20810
|
init_branch_prefix();
|
|
20433
20811
|
init_worktree_labels();
|
|
@@ -20813,40 +21191,40 @@ __export(plan_file_exports, {
|
|
|
20813
21191
|
writePlanFile: () => writePlanFile
|
|
20814
21192
|
});
|
|
20815
21193
|
function ensureAttachmentsGitignore(worktreePath) {
|
|
20816
|
-
const gitignoreAbs = (0,
|
|
20817
|
-
if ((0,
|
|
20818
|
-
(0,
|
|
20819
|
-
(0,
|
|
21194
|
+
const gitignoreAbs = (0, import_node_path49.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
|
|
21195
|
+
if ((0, import_node_fs52.existsSync)(gitignoreAbs)) return;
|
|
21196
|
+
(0, import_node_fs52.mkdirSync)((0, import_node_path49.dirname)(gitignoreAbs), { recursive: true });
|
|
21197
|
+
(0, import_node_fs52.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
|
|
20820
21198
|
}
|
|
20821
21199
|
function planFileAbs(worktreePath) {
|
|
20822
|
-
return (0,
|
|
21200
|
+
return (0, import_node_path49.join)(worktreePath, PLAN_FILE_REL);
|
|
20823
21201
|
}
|
|
20824
21202
|
function readTextIfPresent2(abs) {
|
|
20825
|
-
if (!(0,
|
|
21203
|
+
if (!(0, import_node_fs52.existsSync)(abs)) return null;
|
|
20826
21204
|
try {
|
|
20827
|
-
const content = (0,
|
|
21205
|
+
const content = (0, import_node_fs52.readFileSync)(abs, "utf8");
|
|
20828
21206
|
return content.trim() ? content : null;
|
|
20829
21207
|
} catch {
|
|
20830
21208
|
return null;
|
|
20831
21209
|
}
|
|
20832
21210
|
}
|
|
20833
21211
|
function readPlanFile(worktreePath) {
|
|
20834
|
-
return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0,
|
|
21212
|
+
return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path49.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path49.join)(worktreePath, LEGACY_PLAN_FILE_REL));
|
|
20835
21213
|
}
|
|
20836
21214
|
function writePlanFile(worktreePath, content) {
|
|
20837
21215
|
ensureAttachmentsGitignore(worktreePath);
|
|
20838
21216
|
const abs = planFileAbs(worktreePath);
|
|
20839
|
-
(0,
|
|
21217
|
+
(0, import_node_fs52.mkdirSync)((0, import_node_path49.dirname)(abs), { recursive: true });
|
|
20840
21218
|
const body = content.trimEnd() + (content.endsWith("\n") ? "" : "\n");
|
|
20841
|
-
(0,
|
|
21219
|
+
(0, import_node_fs52.writeFileSync)(abs, body, "utf8");
|
|
20842
21220
|
return PLAN_FILE_REL;
|
|
20843
21221
|
}
|
|
20844
|
-
var
|
|
21222
|
+
var import_node_fs52, import_node_path49;
|
|
20845
21223
|
var init_plan_file = __esm({
|
|
20846
21224
|
"src/plan/plan-file.ts"() {
|
|
20847
21225
|
"use strict";
|
|
20848
|
-
|
|
20849
|
-
|
|
21226
|
+
import_node_fs52 = require("fs");
|
|
21227
|
+
import_node_path49 = require("path");
|
|
20850
21228
|
init_workspace_scratch();
|
|
20851
21229
|
init_plan_present();
|
|
20852
21230
|
init_plan_present();
|
|
@@ -20894,13 +21272,13 @@ var init_sync_branch = __esm({
|
|
|
20894
21272
|
|
|
20895
21273
|
// src/agents/cursor-store.ts
|
|
20896
21274
|
function cursorSdkStoreDir(threadId) {
|
|
20897
|
-
const root = (0,
|
|
21275
|
+
const root = (0, import_node_path50.join)(appDataDir(), CURSOR_SDK_STORE_DIR);
|
|
20898
21276
|
const id = sanitizeCursorStoreSegment(threadId);
|
|
20899
21277
|
if (!id) return root;
|
|
20900
|
-
return (0,
|
|
21278
|
+
return (0, import_node_path50.join)(root, "threads", id);
|
|
20901
21279
|
}
|
|
20902
21280
|
function cursorSdkRunsNdjsonPath(threadId) {
|
|
20903
|
-
return (0,
|
|
21281
|
+
return (0, import_node_path50.join)(cursorSdkStoreDir(threadId), "runs.ndjson");
|
|
20904
21282
|
}
|
|
20905
21283
|
function cursorSdkRunsNdjsonSearchPaths(threadId) {
|
|
20906
21284
|
const scoped = cursorSdkRunsNdjsonPath(threadId);
|
|
@@ -20913,11 +21291,11 @@ function cursorSdkRunsNdjsonSearchPaths(threadId) {
|
|
|
20913
21291
|
function sanitizeCursorStoreSegment(threadId) {
|
|
20914
21292
|
return (threadId ?? "").trim().replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
20915
21293
|
}
|
|
20916
|
-
var
|
|
21294
|
+
var import_node_path50, CURSOR_SDK_STORE_DIR;
|
|
20917
21295
|
var init_cursor_store = __esm({
|
|
20918
21296
|
"src/agents/cursor-store.ts"() {
|
|
20919
21297
|
"use strict";
|
|
20920
|
-
|
|
21298
|
+
import_node_path50 = require("path");
|
|
20921
21299
|
init_paths();
|
|
20922
21300
|
CURSOR_SDK_STORE_DIR = "cursor-sdk-store";
|
|
20923
21301
|
}
|
|
@@ -20939,9 +21317,9 @@ function recoverFinishedCursorRun(opts) {
|
|
|
20939
21317
|
return best;
|
|
20940
21318
|
}
|
|
20941
21319
|
function scanFinishedCursorRuns(runsPath, agentId, startedAfterMs) {
|
|
20942
|
-
if (!(0,
|
|
21320
|
+
if (!(0, import_node_fs53.existsSync)(runsPath)) return null;
|
|
20943
21321
|
try {
|
|
20944
|
-
const lines = (0,
|
|
21322
|
+
const lines = (0, import_node_fs53.readFileSync)(runsPath, "utf8").split("\n");
|
|
20945
21323
|
let best = null;
|
|
20946
21324
|
for (const line of lines) {
|
|
20947
21325
|
const trimmed = line.trim();
|
|
@@ -20967,11 +21345,11 @@ function scanFinishedCursorRuns(runsPath, agentId, startedAfterMs) {
|
|
|
20967
21345
|
return null;
|
|
20968
21346
|
}
|
|
20969
21347
|
}
|
|
20970
|
-
var
|
|
21348
|
+
var import_node_fs53;
|
|
20971
21349
|
var init_cursor_recover = __esm({
|
|
20972
21350
|
"src/agents/cursor-recover.ts"() {
|
|
20973
21351
|
"use strict";
|
|
20974
|
-
|
|
21352
|
+
import_node_fs53 = require("fs");
|
|
20975
21353
|
init_cursor_store();
|
|
20976
21354
|
}
|
|
20977
21355
|
});
|
|
@@ -21118,13 +21496,13 @@ async function startOrchestration(opts) {
|
|
|
21118
21496
|
}
|
|
21119
21497
|
return updated;
|
|
21120
21498
|
}
|
|
21121
|
-
var import_node_events,
|
|
21499
|
+
var import_node_events, import_node_fs54, LIVE_TURN_SPAWN_GRACE_MS, STALE_AGENT_PID_WAIT_MS, Orchestrator, singleton;
|
|
21122
21500
|
var init_orchestrator = __esm({
|
|
21123
21501
|
"src/orchestrator/orchestrator.ts"() {
|
|
21124
21502
|
"use strict";
|
|
21125
21503
|
import_node_events = require("events");
|
|
21126
21504
|
init_outbound_watch();
|
|
21127
|
-
|
|
21505
|
+
import_node_fs54 = require("fs");
|
|
21128
21506
|
init_error_detail();
|
|
21129
21507
|
init_run();
|
|
21130
21508
|
init_stale_lock();
|
|
@@ -21298,7 +21676,7 @@ var init_orchestrator = __esm({
|
|
|
21298
21676
|
}
|
|
21299
21677
|
continue;
|
|
21300
21678
|
}
|
|
21301
|
-
if (!(0,
|
|
21679
|
+
if (!(0, import_node_fs54.existsSync)(thread.worktreePath)) {
|
|
21302
21680
|
setStatus(thread.id, "broken", "Worktree missing on disk");
|
|
21303
21681
|
this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
|
|
21304
21682
|
continue;
|
|
@@ -23245,7 +23623,7 @@ var init_orchestrator = __esm({
|
|
|
23245
23623
|
this.emit({ type: "status_changed", threadId: restored2.id, status: restored2.status });
|
|
23246
23624
|
return restored2;
|
|
23247
23625
|
}
|
|
23248
|
-
if (!(0,
|
|
23626
|
+
if (!(0, import_node_fs54.existsSync)(thread.worktreePath)) {
|
|
23249
23627
|
if (isCowboyThread(thread) || isPrimaryCheckoutThread(thread)) {
|
|
23250
23628
|
throw new Error(
|
|
23251
23629
|
`Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
|
|
@@ -23618,6 +23996,7 @@ __export(index_exports, {
|
|
|
23618
23996
|
classifyWorktreeColumn: () => classifyWorktreeColumn,
|
|
23619
23997
|
claudeAdapter: () => claudeAdapter,
|
|
23620
23998
|
claudeChromeEnabled: () => claudeChromeEnabled,
|
|
23999
|
+
claudeUsageOverLimitWindows: () => claudeUsageOverLimitWindows,
|
|
23621
24000
|
claudeUserSettingsPath: () => claudeUserSettingsPath,
|
|
23622
24001
|
cleanupOrphanWorktrees: () => cleanupOrphanWorktrees,
|
|
23623
24002
|
clearBoardPins: () => clearBoardPins,
|
|
@@ -23637,6 +24016,7 @@ __export(index_exports, {
|
|
|
23637
24016
|
computeNextRunAt: () => computeNextRunAt,
|
|
23638
24017
|
conductorBundledBinDir: () => conductorBundledBinDir,
|
|
23639
24018
|
conductorDbPath: () => conductorDbPath,
|
|
24019
|
+
confirmClaudeUsageOverLimitEnabled: () => confirmClaudeUsageOverLimitEnabled,
|
|
23640
24020
|
confirmLand: () => confirmLand,
|
|
23641
24021
|
connectBrightsyTeam: () => connectBrightsyTeam,
|
|
23642
24022
|
connectOptionalService: () => connectOptionalService,
|
|
@@ -23736,6 +24116,13 @@ __export(index_exports, {
|
|
|
23736
24116
|
formatAccountProfilePlaybookLine: () => formatAccountProfilePlaybookLine,
|
|
23737
24117
|
formatArtifactDirective: () => formatArtifactDirective,
|
|
23738
24118
|
formatBrightsyFetchError: () => formatBrightsyFetchError,
|
|
24119
|
+
formatClaudeExtraUsageDetail: () => formatClaudeExtraUsageDetail,
|
|
24120
|
+
formatClaudeUsageCompact: () => formatClaudeUsageCompact,
|
|
24121
|
+
formatClaudeUsageFetchedAt: () => formatClaudeUsageFetchedAt,
|
|
24122
|
+
formatClaudeUsageOverLimitConfirm: () => formatClaudeUsageOverLimitConfirm,
|
|
24123
|
+
formatClaudeUsageReset: () => formatClaudeUsageReset,
|
|
24124
|
+
formatClaudeUsageResetClock: () => formatClaudeUsageResetClock,
|
|
24125
|
+
formatClaudeUsageTooltip: () => formatClaudeUsageTooltip,
|
|
23739
24126
|
formatDetachedJobInvoke: () => formatDetachedJobInvoke,
|
|
23740
24127
|
formatFetchError: () => formatFetchError,
|
|
23741
24128
|
formatGhLandError: () => formatGhLandError,
|
|
@@ -23785,6 +24172,7 @@ __export(index_exports, {
|
|
|
23785
24172
|
getAgentSetupInfo: () => getAgentSetupInfo,
|
|
23786
24173
|
getBrightsySession: () => getBrightsySession,
|
|
23787
24174
|
getCaffeinateHold: () => getCaffeinateHold,
|
|
24175
|
+
getClaudePlanUsage: () => getClaudePlanUsage,
|
|
23788
24176
|
getDefaultAgent: () => getDefaultAgent,
|
|
23789
24177
|
getDefaultEffort: () => getDefaultEffort,
|
|
23790
24178
|
getDefaultFast: () => getDefaultFast,
|
|
@@ -23834,6 +24222,7 @@ __export(index_exports, {
|
|
|
23834
24222
|
hasRepoHook: () => hasRepoHook,
|
|
23835
24223
|
hasWorkspaceHook: () => hasWorkspaceHook,
|
|
23836
24224
|
healOrchestrationSoccerTitles: () => healOrchestrationSoccerTitles,
|
|
24225
|
+
hottestClaudeWindow: () => hottestClaudeWindow,
|
|
23837
24226
|
httpFetch: () => httpFetch,
|
|
23838
24227
|
importConductorWorkspace: () => importConductorWorkspace,
|
|
23839
24228
|
importConductorWorkspaceAsync: () => importConductorWorkspaceAsync,
|
|
@@ -23997,6 +24386,7 @@ __export(index_exports, {
|
|
|
23997
24386
|
originFetchBranch: () => originFetchBranch,
|
|
23998
24387
|
originGhRepoEnv: () => originGhRepoEnv,
|
|
23999
24388
|
packagedDetachedJobPath: () => packagedDetachedJobPath,
|
|
24389
|
+
parseClaudeUsagePayload: () => parseClaudeUsagePayload,
|
|
24000
24390
|
parseCursorRunnerLine: () => parseCursorRunnerLine,
|
|
24001
24391
|
parseDurationMs: () => parseDurationMs,
|
|
24002
24392
|
parseForceStopMessage: () => parseForceStopMessage,
|
|
@@ -26579,7 +26969,7 @@ var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
|
26579
26969
|
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
26580
26970
|
var import_zod9 = require("zod");
|
|
26581
26971
|
var import_node_crypto14 = require("crypto");
|
|
26582
|
-
var
|
|
26972
|
+
var import_node_path53 = require("path");
|
|
26583
26973
|
init_orchestrator();
|
|
26584
26974
|
init_worktree();
|
|
26585
26975
|
init_global_workspace();
|
|
@@ -28299,27 +28689,27 @@ init_gh_errors();
|
|
|
28299
28689
|
init_git_auth_mode();
|
|
28300
28690
|
|
|
28301
28691
|
// src/board/load-home-board.ts
|
|
28302
|
-
var
|
|
28303
|
-
var
|
|
28692
|
+
var import_node_fs56 = require("fs");
|
|
28693
|
+
var import_node_path52 = require("path");
|
|
28304
28694
|
init_worktree();
|
|
28305
28695
|
init_paths();
|
|
28306
28696
|
|
|
28307
28697
|
// src/board/board-pins.ts
|
|
28308
28698
|
var import_node_crypto13 = require("crypto");
|
|
28309
|
-
var
|
|
28310
|
-
var
|
|
28699
|
+
var import_node_fs55 = require("fs");
|
|
28700
|
+
var import_node_path51 = require("path");
|
|
28311
28701
|
init_paths();
|
|
28312
28702
|
init_home_board();
|
|
28313
28703
|
var FILE = "home-board-pins.json";
|
|
28314
28704
|
var VERSION = 1;
|
|
28315
28705
|
function pinsFile() {
|
|
28316
|
-
return (0,
|
|
28706
|
+
return (0, import_node_path51.join)(appDataDir(), FILE);
|
|
28317
28707
|
}
|
|
28318
28708
|
function readDisk() {
|
|
28319
28709
|
const path2 = pinsFile();
|
|
28320
|
-
if (!(0,
|
|
28710
|
+
if (!(0, import_node_fs55.existsSync)(path2)) return [];
|
|
28321
28711
|
try {
|
|
28322
|
-
const raw = JSON.parse((0,
|
|
28712
|
+
const raw = JSON.parse((0, import_node_fs55.readFileSync)(path2, "utf8"));
|
|
28323
28713
|
if (raw?.version !== VERSION || !Array.isArray(raw.items)) return [];
|
|
28324
28714
|
return raw.items.filter((item) => item?.id && item.kind && item.ref);
|
|
28325
28715
|
} catch {
|
|
@@ -28327,8 +28717,8 @@ function readDisk() {
|
|
|
28327
28717
|
}
|
|
28328
28718
|
}
|
|
28329
28719
|
function writeDisk(items) {
|
|
28330
|
-
(0,
|
|
28331
|
-
(0,
|
|
28720
|
+
(0, import_node_fs55.mkdirSync)(appDataDir(), { recursive: true });
|
|
28721
|
+
(0, import_node_fs55.writeFileSync)(pinsFile(), JSON.stringify({ version: VERSION, items }, null, 2), "utf8");
|
|
28332
28722
|
}
|
|
28333
28723
|
function listBoardPins() {
|
|
28334
28724
|
return readDisk();
|
|
@@ -28380,7 +28770,7 @@ function replaceBoardPins(items) {
|
|
|
28380
28770
|
}
|
|
28381
28771
|
function clearBoardPins() {
|
|
28382
28772
|
try {
|
|
28383
|
-
(0,
|
|
28773
|
+
(0, import_node_fs55.unlinkSync)(pinsFile());
|
|
28384
28774
|
} catch {
|
|
28385
28775
|
}
|
|
28386
28776
|
}
|
|
@@ -28389,7 +28779,7 @@ function clearBoardPins() {
|
|
|
28389
28779
|
init_home_board();
|
|
28390
28780
|
var CACHE_VERSION = 1;
|
|
28391
28781
|
var memory2 = null;
|
|
28392
|
-
var
|
|
28782
|
+
var inflight2 = null;
|
|
28393
28783
|
function errText(err) {
|
|
28394
28784
|
return err instanceof Error ? err.message : String(err);
|
|
28395
28785
|
}
|
|
@@ -28397,7 +28787,7 @@ function homeBoardWorkspaceKey(workspaces) {
|
|
|
28397
28787
|
return workspaces.map((w) => w.path).filter(Boolean).sort().join("\n");
|
|
28398
28788
|
}
|
|
28399
28789
|
function cacheFile() {
|
|
28400
|
-
return (0,
|
|
28790
|
+
return (0, import_node_path52.join)(appDataDir(), "home-board-cache.json");
|
|
28401
28791
|
}
|
|
28402
28792
|
function emptyInputs() {
|
|
28403
28793
|
return {
|
|
@@ -28423,9 +28813,9 @@ function shouldCacheHomeBoardInputs(inputs) {
|
|
|
28423
28813
|
}
|
|
28424
28814
|
function readDiskCache() {
|
|
28425
28815
|
const path2 = cacheFile();
|
|
28426
|
-
if (!(0,
|
|
28816
|
+
if (!(0, import_node_fs56.existsSync)(path2)) return null;
|
|
28427
28817
|
try {
|
|
28428
|
-
const raw = JSON.parse((0,
|
|
28818
|
+
const raw = JSON.parse((0, import_node_fs56.readFileSync)(path2, "utf8"));
|
|
28429
28819
|
if (raw?.version !== CACHE_VERSION || typeof raw.fetchedAt !== "number") {
|
|
28430
28820
|
return null;
|
|
28431
28821
|
}
|
|
@@ -28439,20 +28829,20 @@ function readDiskCache() {
|
|
|
28439
28829
|
}
|
|
28440
28830
|
function writeDiskCache(entry) {
|
|
28441
28831
|
try {
|
|
28442
|
-
(0,
|
|
28443
|
-
(0,
|
|
28832
|
+
(0, import_node_fs56.mkdirSync)(appDataDir(), { recursive: true });
|
|
28833
|
+
(0, import_node_fs56.writeFileSync)(cacheFile(), JSON.stringify(entry), "utf8");
|
|
28444
28834
|
} catch {
|
|
28445
28835
|
}
|
|
28446
28836
|
}
|
|
28447
28837
|
function deleteDiskCache() {
|
|
28448
28838
|
try {
|
|
28449
|
-
(0,
|
|
28839
|
+
(0, import_node_fs56.unlinkSync)(cacheFile());
|
|
28450
28840
|
} catch {
|
|
28451
28841
|
}
|
|
28452
28842
|
}
|
|
28453
28843
|
function resetHomeBoardMemory() {
|
|
28454
28844
|
memory2 = null;
|
|
28455
|
-
|
|
28845
|
+
inflight2 = null;
|
|
28456
28846
|
}
|
|
28457
28847
|
function clearHomeBoardCache() {
|
|
28458
28848
|
resetHomeBoardMemory();
|
|
@@ -28551,8 +28941,8 @@ async function getHomeBoardInputs(workspaces, opts) {
|
|
|
28551
28941
|
return asLoaded(best, true);
|
|
28552
28942
|
}
|
|
28553
28943
|
}
|
|
28554
|
-
if (
|
|
28555
|
-
return
|
|
28944
|
+
if (inflight2 && inflight2.key === key) {
|
|
28945
|
+
return inflight2.promise;
|
|
28556
28946
|
}
|
|
28557
28947
|
const promise = (async () => {
|
|
28558
28948
|
const inputs = await loadHomeBoardInputs(workspaces);
|
|
@@ -28572,11 +28962,11 @@ async function getHomeBoardInputs(workspaces, opts) {
|
|
|
28572
28962
|
}
|
|
28573
28963
|
return loaded;
|
|
28574
28964
|
})();
|
|
28575
|
-
|
|
28965
|
+
inflight2 = { key, promise };
|
|
28576
28966
|
try {
|
|
28577
28967
|
return await promise;
|
|
28578
28968
|
} finally {
|
|
28579
|
-
if (
|
|
28969
|
+
if (inflight2?.promise === promise) inflight2 = null;
|
|
28580
28970
|
}
|
|
28581
28971
|
}
|
|
28582
28972
|
|
|
@@ -28796,7 +29186,7 @@ async function startMcpServer() {
|
|
|
28796
29186
|
async () => {
|
|
28797
29187
|
const threads = orch.getThreads(true);
|
|
28798
29188
|
const lines = threads.map((t) => {
|
|
28799
|
-
const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0,
|
|
29189
|
+
const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0, import_node_path53.basename)(t.repoPath) || t.repoPath;
|
|
28800
29190
|
const live = orch.threadLooksLive(t) ? readTurnLive(t.id) : null;
|
|
28801
29191
|
const parent = t.parentThreadId ? ` parent:${t.parentThreadId.slice(0, 8)}` : "";
|
|
28802
29192
|
const preview = lastMessagePreview(t.messages, 80);
|
|
@@ -31763,9 +32153,9 @@ var import_node_http3 = require("http");
|
|
|
31763
32153
|
var import_ws3 = require("ws");
|
|
31764
32154
|
|
|
31765
32155
|
// src/slack/relay-static.ts
|
|
31766
|
-
var
|
|
32156
|
+
var import_node_fs57 = require("fs");
|
|
31767
32157
|
var import_promises = require("fs/promises");
|
|
31768
|
-
var
|
|
32158
|
+
var import_node_path54 = __toESM(require("path"), 1);
|
|
31769
32159
|
var TYPES = {
|
|
31770
32160
|
".css": "text/css; charset=utf-8",
|
|
31771
32161
|
".html": "text/html; charset=utf-8",
|
|
@@ -31796,9 +32186,9 @@ function resolveStaticPath(root, requestUrl) {
|
|
|
31796
32186
|
return null;
|
|
31797
32187
|
}
|
|
31798
32188
|
if (!pathname.startsWith("/") || pathname.includes("\0")) return null;
|
|
31799
|
-
const rootResolved =
|
|
31800
|
-
const candidate =
|
|
31801
|
-
if (candidate !== rootResolved && !candidate.startsWith(rootResolved +
|
|
32189
|
+
const rootResolved = import_node_path54.default.resolve(root);
|
|
32190
|
+
const candidate = import_node_path54.default.resolve(rootResolved, `.${pathname}`);
|
|
32191
|
+
if (candidate !== rootResolved && !candidate.startsWith(rootResolved + import_node_path54.default.sep)) {
|
|
31802
32192
|
return null;
|
|
31803
32193
|
}
|
|
31804
32194
|
return candidate;
|
|
@@ -31812,7 +32202,7 @@ async function fileSize(file) {
|
|
|
31812
32202
|
}
|
|
31813
32203
|
}
|
|
31814
32204
|
function sendFile(req, res, file, size) {
|
|
31815
|
-
const ext =
|
|
32205
|
+
const ext = import_node_path54.default.extname(file).toLowerCase();
|
|
31816
32206
|
res.writeHead(200, {
|
|
31817
32207
|
"Content-Type": TYPES[ext] ?? "application/octet-stream",
|
|
31818
32208
|
"Content-Length": size,
|
|
@@ -31822,7 +32212,7 @@ function sendFile(req, res, file, size) {
|
|
|
31822
32212
|
res.end();
|
|
31823
32213
|
return true;
|
|
31824
32214
|
}
|
|
31825
|
-
(0,
|
|
32215
|
+
(0, import_node_fs57.createReadStream)(file).pipe(res);
|
|
31826
32216
|
return true;
|
|
31827
32217
|
}
|
|
31828
32218
|
async function tryServeStatic(req, res, root) {
|
|
@@ -31831,7 +32221,7 @@ async function tryServeStatic(req, res, root) {
|
|
|
31831
32221
|
if (!candidate) return false;
|
|
31832
32222
|
const direct = await fileSize(candidate);
|
|
31833
32223
|
if (direct != null) return sendFile(req, res, candidate, direct);
|
|
31834
|
-
const asIndex =
|
|
32224
|
+
const asIndex = import_node_path54.default.join(candidate, "index.html");
|
|
31835
32225
|
const indexSize = await fileSize(asIndex);
|
|
31836
32226
|
if (indexSize != null) return sendFile(req, res, asIndex, indexSize);
|
|
31837
32227
|
return false;
|
|
@@ -32236,6 +32626,7 @@ init_outbound_watch();
|
|
|
32236
32626
|
classifyWorktreeColumn,
|
|
32237
32627
|
claudeAdapter,
|
|
32238
32628
|
claudeChromeEnabled,
|
|
32629
|
+
claudeUsageOverLimitWindows,
|
|
32239
32630
|
claudeUserSettingsPath,
|
|
32240
32631
|
cleanupOrphanWorktrees,
|
|
32241
32632
|
clearBoardPins,
|
|
@@ -32255,6 +32646,7 @@ init_outbound_watch();
|
|
|
32255
32646
|
computeNextRunAt,
|
|
32256
32647
|
conductorBundledBinDir,
|
|
32257
32648
|
conductorDbPath,
|
|
32649
|
+
confirmClaudeUsageOverLimitEnabled,
|
|
32258
32650
|
confirmLand,
|
|
32259
32651
|
connectBrightsyTeam,
|
|
32260
32652
|
connectOptionalService,
|
|
@@ -32354,6 +32746,13 @@ init_outbound_watch();
|
|
|
32354
32746
|
formatAccountProfilePlaybookLine,
|
|
32355
32747
|
formatArtifactDirective,
|
|
32356
32748
|
formatBrightsyFetchError,
|
|
32749
|
+
formatClaudeExtraUsageDetail,
|
|
32750
|
+
formatClaudeUsageCompact,
|
|
32751
|
+
formatClaudeUsageFetchedAt,
|
|
32752
|
+
formatClaudeUsageOverLimitConfirm,
|
|
32753
|
+
formatClaudeUsageReset,
|
|
32754
|
+
formatClaudeUsageResetClock,
|
|
32755
|
+
formatClaudeUsageTooltip,
|
|
32357
32756
|
formatDetachedJobInvoke,
|
|
32358
32757
|
formatFetchError,
|
|
32359
32758
|
formatGhLandError,
|
|
@@ -32403,6 +32802,7 @@ init_outbound_watch();
|
|
|
32403
32802
|
getAgentSetupInfo,
|
|
32404
32803
|
getBrightsySession,
|
|
32405
32804
|
getCaffeinateHold,
|
|
32805
|
+
getClaudePlanUsage,
|
|
32406
32806
|
getDefaultAgent,
|
|
32407
32807
|
getDefaultEffort,
|
|
32408
32808
|
getDefaultFast,
|
|
@@ -32452,6 +32852,7 @@ init_outbound_watch();
|
|
|
32452
32852
|
hasRepoHook,
|
|
32453
32853
|
hasWorkspaceHook,
|
|
32454
32854
|
healOrchestrationSoccerTitles,
|
|
32855
|
+
hottestClaudeWindow,
|
|
32455
32856
|
httpFetch,
|
|
32456
32857
|
importConductorWorkspace,
|
|
32457
32858
|
importConductorWorkspaceAsync,
|
|
@@ -32615,6 +33016,7 @@ init_outbound_watch();
|
|
|
32615
33016
|
originFetchBranch,
|
|
32616
33017
|
originGhRepoEnv,
|
|
32617
33018
|
packagedDetachedJobPath,
|
|
33019
|
+
parseClaudeUsagePayload,
|
|
32618
33020
|
parseCursorRunnerLine,
|
|
32619
33021
|
parseDurationMs,
|
|
32620
33022
|
parseForceStopMessage,
|