@sideboard-ai/core 0.1.197 → 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/cursor-runner.cjs +49 -45
- package/dist/agents/cursor-runner.js +5 -3
- package/dist/{agents-IVDCAG7T.js → agents-AVH44CBS.js} +27 -5
- package/dist/{agents-BGT5DUGU.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-NLHFAMC2.js → chunk-CQ5R3VPP.js} +15 -1
- package/dist/{chunk-ZG7RONNQ.js → chunk-CTABTALL.js} +22 -21
- package/dist/{chunk-PQBRCBIE.js → chunk-DU2ICKLA.js} +382 -6
- package/dist/{chunk-S4QCBBXS.js → chunk-DU4ID3DA.js} +1 -1
- package/dist/{chunk-AH6WIBLY.js → chunk-HQKGK4KO.js} +10 -0
- package/dist/{chunk-N5JBG3BF.js → chunk-KI4YI72Y.js} +371 -6
- package/dist/{chunk-SIIDQV2B.js → chunk-PPVN3APP.js} +24 -23
- 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 +688 -262
- package/dist/index.d.cts +78 -1
- package/dist/index.d.ts +78 -1
- package/dist/index.js +33 -9
- package/dist/mcp/run-stdio.cjs +317 -258
- package/dist/mcp/run-stdio.js +8 -8
- package/dist/{orchestrator-SANGGLQV.js → orchestrator-AJGDZEAS.js} +5 -5
- package/dist/{orchestrator-HB4LZ2AA.js → orchestrator-NCGYNVYN.js} +6 -6
- 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/mcp/run-stdio.cjs
CHANGED
|
@@ -1730,11 +1730,20 @@ function looksLikeInvalidAgentSession(text7) {
|
|
|
1730
1730
|
if (!lower) return false;
|
|
1731
1731
|
return /session not found/.test(lower) || /no conversation found/.test(lower) || /conversation .+ not found/.test(lower) || /thread .+ not found/.test(lower) || /unknown session/.test(lower) || /invalid session/.test(lower) || /session .+ (missing|expired|deleted|gone)/.test(lower) || /cannot resume/.test(lower) || /failed to (load|resume|open) session/.test(lower) || /corrupt local agent checkpoint/.test(lower) || /missing root blob/.test(lower) || /\bagent\b.{0,120}\bnot found\b/.test(lower) || /\brun\b.{0,80}\bnot found for agent\b/.test(lower);
|
|
1732
1732
|
}
|
|
1733
|
+
function looksLikeCursorHttp2StreamClose(text7) {
|
|
1734
|
+
return /nghttp2/i.test(text7.trim());
|
|
1735
|
+
}
|
|
1736
|
+
function looksLikeBrightsyEmptyCompletion(text7) {
|
|
1737
|
+
const core = text7.trim().replace(/^exit\s*\d+:\s*/i, "").replace(/^error:\s*/i, "").trim();
|
|
1738
|
+
return /^i did not receive a valid model response\. please try again\.$/i.test(core);
|
|
1739
|
+
}
|
|
1733
1740
|
function looksLikeRetryableRunnerCrash(text7) {
|
|
1734
1741
|
if (looksLikeAgentFailureMessage(text7)) return false;
|
|
1735
1742
|
if (looksLikeInvalidAgentSession(text7)) return false;
|
|
1736
1743
|
if (looksLikeV8Oom(text7)) return false;
|
|
1737
1744
|
if (looksLikeHugeToolResultDump(text7)) return true;
|
|
1745
|
+
if (looksLikeCursorHttp2StreamClose(text7)) return true;
|
|
1746
|
+
if (looksLikeBrightsyEmptyCompletion(text7)) return true;
|
|
1738
1747
|
const lower = text7.trim().toLowerCase();
|
|
1739
1748
|
if (/cannot find (?:package|module)|err_module_not_found/.test(lower)) return false;
|
|
1740
1749
|
if (!lower) return true;
|
|
@@ -1807,9 +1816,12 @@ function humanizeAgentFailDetail(detail) {
|
|
|
1807
1816
|
if (/corrupt local agent checkpoint|missing root blob|truncated crash dump/.test(lower)) {
|
|
1808
1817
|
return `${raw} \u2014 retry the turn (Sideboard will start a fresh Cursor session).`;
|
|
1809
1818
|
}
|
|
1810
|
-
if (/connection stalled/.test(lower)) {
|
|
1819
|
+
if (/connection stalled/.test(lower) || looksLikeCursorHttp2StreamClose(raw)) {
|
|
1811
1820
|
return /retry the turn/i.test(raw) ? raw : `${raw} \u2014 retry the turn (Sideboard will start a fresh Cursor session).`;
|
|
1812
1821
|
}
|
|
1822
|
+
if (looksLikeBrightsyEmptyCompletion(raw)) {
|
|
1823
|
+
return /retry the turn/i.test(raw) ? raw : `${raw} \u2014 retry the turn (Brightsy returned an empty model completion).`;
|
|
1824
|
+
}
|
|
1813
1825
|
if (/network request failed|cursor startup failed:.+\(retryable\)/.test(lower)) {
|
|
1814
1826
|
return /retry the turn/i.test(raw) ? raw : `${raw} \u2014 retry the turn (a transient Cursor SDK network error).`;
|
|
1815
1827
|
}
|
|
@@ -3510,6 +3522,7 @@ __export(app_settings_exports, {
|
|
|
3510
3522
|
childEnvWithAppSettings: () => childEnvWithAppSettings,
|
|
3511
3523
|
claudeChromeEnabled: () => claudeChromeEnabled,
|
|
3512
3524
|
claudeUserSettingsPath: () => claudeUserSettingsPath,
|
|
3525
|
+
confirmClaudeUsageOverLimitEnabled: () => confirmClaudeUsageOverLimitEnabled,
|
|
3513
3526
|
cowboyModeEnabled: () => cowboyModeEnabled,
|
|
3514
3527
|
deleteBranchOnPurgeEnabled: () => deleteBranchOnPurgeEnabled,
|
|
3515
3528
|
disconnectAbleTimeConnection: () => disconnectAbleTimeConnection,
|
|
@@ -3937,6 +3950,9 @@ function normalizeAdvanced(raw) {
|
|
|
3937
3950
|
if (typeof source.showCost === "boolean") {
|
|
3938
3951
|
out.showCost = source.showCost;
|
|
3939
3952
|
}
|
|
3953
|
+
if (typeof source.confirmClaudeUsageOverLimit === "boolean") {
|
|
3954
|
+
out.confirmClaudeUsageOverLimit = source.confirmClaudeUsageOverLimit;
|
|
3955
|
+
}
|
|
3940
3956
|
if (typeof source.autoArchiveOnMerge === "boolean") {
|
|
3941
3957
|
out.autoArchiveOnMerge = source.autoArchiveOnMerge;
|
|
3942
3958
|
}
|
|
@@ -4799,6 +4815,9 @@ function updateAdvancedSettings(patch) {
|
|
|
4799
4815
|
if (typeof patch.showCost === "boolean") {
|
|
4800
4816
|
advanced.showCost = patch.showCost;
|
|
4801
4817
|
}
|
|
4818
|
+
if (typeof patch.confirmClaudeUsageOverLimit === "boolean") {
|
|
4819
|
+
advanced.confirmClaudeUsageOverLimit = patch.confirmClaudeUsageOverLimit;
|
|
4820
|
+
}
|
|
4802
4821
|
if (typeof patch.autoArchiveOnMerge === "boolean") {
|
|
4803
4822
|
advanced.autoArchiveOnMerge = patch.autoArchiveOnMerge;
|
|
4804
4823
|
}
|
|
@@ -4861,6 +4880,9 @@ function cowboyModeEnabled(settings = loadAppSettings()) {
|
|
|
4861
4880
|
function showCostEnabled(settings = loadAppSettings()) {
|
|
4862
4881
|
return Boolean(settings.advanced.showCost);
|
|
4863
4882
|
}
|
|
4883
|
+
function confirmClaudeUsageOverLimitEnabled(settings = loadAppSettings()) {
|
|
4884
|
+
return Boolean(settings.advanced.confirmClaudeUsageOverLimit);
|
|
4885
|
+
}
|
|
4864
4886
|
function autoArchiveOnMergeEnabled(settings = loadAppSettings()) {
|
|
4865
4887
|
return Boolean(settings.advanced.autoArchiveOnMerge);
|
|
4866
4888
|
}
|
|
@@ -8769,6 +8791,12 @@ function parseBrightsyCliLine(line) {
|
|
|
8769
8791
|
try {
|
|
8770
8792
|
const obj = JSON.parse(trimmed);
|
|
8771
8793
|
if (obj.type === "text" && typeof obj.text === "string") {
|
|
8794
|
+
if (looksLikeBrightsyEmptyCompletion(obj.text)) {
|
|
8795
|
+
return [
|
|
8796
|
+
{ type: "stderr", data: obj.text },
|
|
8797
|
+
{ type: "stdout", data: `Error: ${obj.text}` }
|
|
8798
|
+
];
|
|
8799
|
+
}
|
|
8772
8800
|
return { type: "stdout", data: obj.text };
|
|
8773
8801
|
}
|
|
8774
8802
|
if (obj.type === "thinking" && typeof obj.text === "string") {
|
|
@@ -8812,7 +8840,7 @@ function parseBrightsyCliLine(line) {
|
|
|
8812
8840
|
if (trimmed.startsWith("{") && /"type"\s*:\s*"(tool_use|tool_result|tool|text|thinking|usage|done|error)"/.test(trimmed)) {
|
|
8813
8841
|
return null;
|
|
8814
8842
|
}
|
|
8815
|
-
if (/error|failed|unauthorized|quota|limit|not logged in/i.test(trimmed)) {
|
|
8843
|
+
if (looksLikeBrightsyEmptyCompletion(trimmed) || /error|failed|unauthorized|quota|limit|not logged in/i.test(trimmed)) {
|
|
8816
8844
|
return [
|
|
8817
8845
|
{ type: "stderr", data: trimmed },
|
|
8818
8846
|
{ type: "stdout", data: `Error: ${trimmed}` }
|
|
@@ -8821,6 +8849,12 @@ function parseBrightsyCliLine(line) {
|
|
|
8821
8849
|
return { type: "stdout", data: line };
|
|
8822
8850
|
}
|
|
8823
8851
|
}
|
|
8852
|
+
function adjustBrightsyTurnExit(exitCode, assistantText) {
|
|
8853
|
+
if (looksLikeBrightsyEmptyCompletion(assistantText) && (exitCode === 0 || exitCode == null)) {
|
|
8854
|
+
return 2;
|
|
8855
|
+
}
|
|
8856
|
+
return exitCode;
|
|
8857
|
+
}
|
|
8824
8858
|
async function fetchTeamChatTargets(team) {
|
|
8825
8859
|
const endpoint = (team.endpoint || "https://brightsy.ai").replace(/\/$/, "");
|
|
8826
8860
|
let agents = [
|
|
@@ -12165,6 +12199,29 @@ var init_session_quota = __esm({
|
|
|
12165
12199
|
}
|
|
12166
12200
|
});
|
|
12167
12201
|
|
|
12202
|
+
// src/agents/claude-usage.ts
|
|
12203
|
+
var init_claude_usage = __esm({
|
|
12204
|
+
"src/agents/claude-usage.ts"() {
|
|
12205
|
+
"use strict";
|
|
12206
|
+
}
|
|
12207
|
+
});
|
|
12208
|
+
|
|
12209
|
+
// src/agents/claude-usage-client.ts
|
|
12210
|
+
var import_node_fs33, import_node_os13, import_node_path33, CLAUDE_USAGE_ERROR_TTL_MS, CLAUDE_USAGE_STALE_OK_MS;
|
|
12211
|
+
var init_claude_usage_client = __esm({
|
|
12212
|
+
"src/agents/claude-usage-client.ts"() {
|
|
12213
|
+
"use strict";
|
|
12214
|
+
import_node_fs33 = require("fs");
|
|
12215
|
+
import_node_os13 = require("os");
|
|
12216
|
+
import_node_path33 = require("path");
|
|
12217
|
+
init_run();
|
|
12218
|
+
init_app_settings();
|
|
12219
|
+
init_claude_usage();
|
|
12220
|
+
CLAUDE_USAGE_ERROR_TTL_MS = 5 * 6e4;
|
|
12221
|
+
CLAUDE_USAGE_STALE_OK_MS = 30 * 6e4;
|
|
12222
|
+
}
|
|
12223
|
+
});
|
|
12224
|
+
|
|
12168
12225
|
// src/agents/install.ts
|
|
12169
12226
|
var init_install = __esm({
|
|
12170
12227
|
"src/agents/install.ts"() {
|
|
@@ -12199,6 +12256,8 @@ var init_agents = __esm({
|
|
|
12199
12256
|
init_opencode();
|
|
12200
12257
|
init_list_models();
|
|
12201
12258
|
init_session_quota();
|
|
12259
|
+
init_claude_usage();
|
|
12260
|
+
init_claude_usage_client();
|
|
12202
12261
|
init_orchestrator_capable();
|
|
12203
12262
|
init_path();
|
|
12204
12263
|
init_install();
|
|
@@ -12214,15 +12273,15 @@ var init_agents = __esm({
|
|
|
12214
12273
|
|
|
12215
12274
|
// src/hook/worktree-pkg-cache.ts
|
|
12216
12275
|
function worktreePkgCacheRoot(worktreePath) {
|
|
12217
|
-
return (0,
|
|
12276
|
+
return (0, import_node_path34.join)(worktreePath, WORKTREE_PKG_CACHE_REL);
|
|
12218
12277
|
}
|
|
12219
12278
|
function worktreePkgCacheEnv(worktreePath) {
|
|
12220
12279
|
const root = worktreePkgCacheRoot(worktreePath);
|
|
12221
|
-
const store = (0,
|
|
12222
|
-
const pnpmCache = (0,
|
|
12223
|
-
const npmCache = (0,
|
|
12224
|
-
const nodeGyp = (0,
|
|
12225
|
-
const electron = (0,
|
|
12280
|
+
const store = (0, import_node_path34.join)(root, "pnpm-store");
|
|
12281
|
+
const pnpmCache = (0, import_node_path34.join)(root, "pnpm");
|
|
12282
|
+
const npmCache = (0, import_node_path34.join)(root, "npm");
|
|
12283
|
+
const nodeGyp = (0, import_node_path34.join)(root, "node-gyp");
|
|
12284
|
+
const electron = (0, import_node_path34.join)(root, "electron");
|
|
12226
12285
|
return {
|
|
12227
12286
|
npm_config_store_dir: store,
|
|
12228
12287
|
PNPM_STORE_DIR: store,
|
|
@@ -12244,8 +12303,8 @@ function fillGroup(env, keys, values) {
|
|
|
12244
12303
|
}
|
|
12245
12304
|
}
|
|
12246
12305
|
function ensureWorktreePkgCacheDirs(worktreePath) {
|
|
12247
|
-
if (!(0,
|
|
12248
|
-
(0,
|
|
12306
|
+
if (!(0, import_node_fs34.existsSync)(worktreePath)) return;
|
|
12307
|
+
(0, import_node_fs34.mkdirSync)(worktreePkgCacheRoot(worktreePath), { recursive: true });
|
|
12249
12308
|
}
|
|
12250
12309
|
function applyWorktreePkgCacheEnv(env, worktreePath) {
|
|
12251
12310
|
const cwd = worktreePath.trim();
|
|
@@ -12258,12 +12317,12 @@ function applyWorktreePkgCacheEnv(env, worktreePath) {
|
|
|
12258
12317
|
fillGroup(env, ["electron_config_cache"], next);
|
|
12259
12318
|
ensureWorktreePkgCacheDirs(cwd);
|
|
12260
12319
|
}
|
|
12261
|
-
var
|
|
12320
|
+
var import_node_fs34, import_node_path34, WORKTREE_PKG_CACHE_REL;
|
|
12262
12321
|
var init_worktree_pkg_cache = __esm({
|
|
12263
12322
|
"src/hook/worktree-pkg-cache.ts"() {
|
|
12264
12323
|
"use strict";
|
|
12265
|
-
|
|
12266
|
-
|
|
12324
|
+
import_node_fs34 = require("fs");
|
|
12325
|
+
import_node_path34 = require("path");
|
|
12267
12326
|
WORKTREE_PKG_CACHE_REL = ".context/.sideboard/pkg-cache";
|
|
12268
12327
|
}
|
|
12269
12328
|
});
|
|
@@ -12448,11 +12507,11 @@ async function spawnAgentTurn(thread, input, onEvent) {
|
|
|
12448
12507
|
consume(child.stderr, "stderr");
|
|
12449
12508
|
const done = child.then((result) => {
|
|
12450
12509
|
outbound.flush();
|
|
12451
|
-
const exitCode = result.exitCode ?? null;
|
|
12452
|
-
onEvent({ type: "exit", data: exitCode });
|
|
12453
12510
|
const finalized = finalizeParts(parts);
|
|
12454
12511
|
const rawText = assistantText.trim() || partsToAssistantText(finalized);
|
|
12455
12512
|
const text7 = thread.agent === "brightsy" ? stripBrightsyNdjsonNoise(rawText) : rawText;
|
|
12513
|
+
const exitCode = thread.agent === "brightsy" ? adjustBrightsyTurnExit(result.exitCode ?? null, text7) : result.exitCode ?? null;
|
|
12514
|
+
onEvent({ type: "exit", data: exitCode });
|
|
12456
12515
|
return { exitCode, sessionId, assistantText: text7, parts: finalized, usage };
|
|
12457
12516
|
});
|
|
12458
12517
|
return {
|
|
@@ -13379,21 +13438,21 @@ function shouldRefreshReviewRequestTemplate(content) {
|
|
|
13379
13438
|
return LEGACY_REVIEW_TEMPLATE_MARKERS.every((m) => trimmed.includes(m));
|
|
13380
13439
|
}
|
|
13381
13440
|
function readTextIfPresent(abs) {
|
|
13382
|
-
if (!(0,
|
|
13441
|
+
if (!(0, import_node_fs35.existsSync)(abs)) return null;
|
|
13383
13442
|
try {
|
|
13384
|
-
const content = (0,
|
|
13443
|
+
const content = (0, import_node_fs35.readFileSync)(abs, "utf8");
|
|
13385
13444
|
return content.trim() ? content : null;
|
|
13386
13445
|
} catch {
|
|
13387
13446
|
return null;
|
|
13388
13447
|
}
|
|
13389
13448
|
}
|
|
13390
13449
|
function readLocalGuidelines(worktreePath) {
|
|
13391
|
-
const localAbs = (0,
|
|
13450
|
+
const localAbs = (0, import_node_path35.join)(worktreePath, REVIEW_REQUEST_PATH);
|
|
13392
13451
|
const localContent = readTextIfPresent(localAbs);
|
|
13393
13452
|
if (localContent && !shouldRefreshReviewRequestTemplate(localContent)) {
|
|
13394
13453
|
return { path: REVIEW_REQUEST_PATH, content: localContent };
|
|
13395
13454
|
}
|
|
13396
|
-
const legacyAbs = (0,
|
|
13455
|
+
const legacyAbs = (0, import_node_path35.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
|
|
13397
13456
|
const legacyContent = readTextIfPresent(legacyAbs);
|
|
13398
13457
|
if (legacyContent && !shouldRefreshReviewRequestTemplate(legacyContent)) {
|
|
13399
13458
|
return { path: LEGACY_REVIEW_REQUEST_PATH, content: legacyContent };
|
|
@@ -13417,27 +13476,27 @@ function contextGuidelines(content, source) {
|
|
|
13417
13476
|
};
|
|
13418
13477
|
}
|
|
13419
13478
|
function writeContextGuidelines(worktreePath, content) {
|
|
13420
|
-
const abs = (0,
|
|
13421
|
-
(0,
|
|
13479
|
+
const abs = (0, import_node_path35.join)(worktreePath, CONTEXT_REVIEW_PATH);
|
|
13480
|
+
(0, import_node_fs35.mkdirSync)((0, import_node_path35.dirname)(abs), { recursive: true });
|
|
13422
13481
|
const body = content.endsWith("\n") ? content : `${content}
|
|
13423
13482
|
`;
|
|
13424
|
-
(0,
|
|
13483
|
+
(0, import_node_fs35.writeFileSync)(abs, body, "utf8");
|
|
13425
13484
|
return body;
|
|
13426
13485
|
}
|
|
13427
13486
|
function readSideboardReview(worktreePath, repoPath) {
|
|
13428
|
-
const fromWorktree = readTextIfPresent((0,
|
|
13487
|
+
const fromWorktree = readTextIfPresent((0, import_node_path35.join)(worktreePath, REPO_REVIEW_PATH));
|
|
13429
13488
|
if (fromWorktree) return fromWorktree;
|
|
13430
13489
|
const repo = repoPath?.replace(/\/+$/, "");
|
|
13431
13490
|
const wt = worktreePath.replace(/\/+$/, "");
|
|
13432
13491
|
if (!repo || repo === wt) return null;
|
|
13433
|
-
return readTextIfPresent((0,
|
|
13492
|
+
return readTextIfPresent((0, import_node_path35.join)(repo, REPO_REVIEW_PATH));
|
|
13434
13493
|
}
|
|
13435
13494
|
function ensureReviewGuidelinesFile(worktreePath, repoPath) {
|
|
13436
|
-
const skillContent = readTextIfPresent((0,
|
|
13495
|
+
const skillContent = readTextIfPresent((0, import_node_path35.join)(worktreePath, REVIEW_SKILL_PATH));
|
|
13437
13496
|
if (skillContent) {
|
|
13438
13497
|
return { ...skillGuidelines(skillContent, "skill"), wrote: false };
|
|
13439
13498
|
}
|
|
13440
|
-
const contextContent = readTextIfPresent((0,
|
|
13499
|
+
const contextContent = readTextIfPresent((0, import_node_path35.join)(worktreePath, CONTEXT_REVIEW_PATH));
|
|
13441
13500
|
if (contextContent && !shouldRefreshReviewRequestTemplate(contextContent)) {
|
|
13442
13501
|
return { ...contextGuidelines(contextContent, "local"), wrote: false };
|
|
13443
13502
|
}
|
|
@@ -13492,13 +13551,13 @@ async function requestReview(threadRef, send) {
|
|
|
13492
13551
|
const started = await send(tab.id, REVIEW_REQUEST_PREFILL);
|
|
13493
13552
|
return { tab: started, from };
|
|
13494
13553
|
}
|
|
13495
|
-
var import_node_crypto7,
|
|
13554
|
+
var import_node_crypto7, import_node_fs35, import_node_path35, 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;
|
|
13496
13555
|
var init_request_review = __esm({
|
|
13497
13556
|
"src/review/request-review.ts"() {
|
|
13498
13557
|
"use strict";
|
|
13499
13558
|
import_node_crypto7 = require("crypto");
|
|
13500
|
-
|
|
13501
|
-
|
|
13559
|
+
import_node_fs35 = require("fs");
|
|
13560
|
+
import_node_path35 = require("path");
|
|
13502
13561
|
init_global_workspace();
|
|
13503
13562
|
init_chat_tabs();
|
|
13504
13563
|
init_thread_store();
|
|
@@ -13524,9 +13583,9 @@ function matchSimpleGlob(pattern, name) {
|
|
|
13524
13583
|
return new RegExp(`^${escaped}$`).test(name);
|
|
13525
13584
|
}
|
|
13526
13585
|
function readWorktreeInclude(repoPath) {
|
|
13527
|
-
const path = (0,
|
|
13528
|
-
if (!(0,
|
|
13529
|
-
return (0,
|
|
13586
|
+
const path = (0, import_node_path36.join)(repoPath, ".worktreeinclude");
|
|
13587
|
+
if (!(0, import_node_fs36.existsSync)(path)) return [];
|
|
13588
|
+
return (0, import_node_fs36.readFileSync)(path, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
|
|
13530
13589
|
}
|
|
13531
13590
|
function resolveFilesToCopy(repoPath) {
|
|
13532
13591
|
const fromInclude = readWorktreeInclude(repoPath);
|
|
@@ -13536,10 +13595,10 @@ function resolveFilesToCopy(repoPath) {
|
|
|
13536
13595
|
if (settings?.fileIncludeGlobs?.length) {
|
|
13537
13596
|
const matched = [];
|
|
13538
13597
|
try {
|
|
13539
|
-
for (const entry of (0,
|
|
13598
|
+
for (const entry of (0, import_node_fs36.readdirSync)(repoPath, { withFileTypes: true })) {
|
|
13540
13599
|
if (!entry.isFile()) continue;
|
|
13541
13600
|
for (const glob of settings.fileIncludeGlobs) {
|
|
13542
|
-
if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0,
|
|
13601
|
+
if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path36.basename)(glob), entry.name)) {
|
|
13543
13602
|
matched.push(entry.name);
|
|
13544
13603
|
break;
|
|
13545
13604
|
}
|
|
@@ -13551,7 +13610,7 @@ function resolveFilesToCopy(repoPath) {
|
|
|
13551
13610
|
}
|
|
13552
13611
|
const defaults = [];
|
|
13553
13612
|
try {
|
|
13554
|
-
for (const entry of (0,
|
|
13613
|
+
for (const entry of (0, import_node_fs36.readdirSync)(repoPath, { withFileTypes: true })) {
|
|
13555
13614
|
if (entry.isFile() && entry.name.startsWith(".env")) {
|
|
13556
13615
|
defaults.push(entry.name);
|
|
13557
13616
|
}
|
|
@@ -13565,11 +13624,11 @@ function copyConfiguredFiles(repoPath, worktreePath) {
|
|
|
13565
13624
|
const patterns = resolveFilesToCopy(repoPath);
|
|
13566
13625
|
const copied = [];
|
|
13567
13626
|
for (const rel of patterns) {
|
|
13568
|
-
const src = (0,
|
|
13569
|
-
if (!(0,
|
|
13570
|
-
const dest = (0,
|
|
13571
|
-
(0,
|
|
13572
|
-
(0,
|
|
13627
|
+
const src = (0, import_node_path36.join)(repoPath, rel);
|
|
13628
|
+
if (!(0, import_node_fs36.existsSync)(src)) continue;
|
|
13629
|
+
const dest = (0, import_node_path36.join)(worktreePath, rel);
|
|
13630
|
+
(0, import_node_fs36.mkdirSync)((0, import_node_path36.dirname)(dest), { recursive: true });
|
|
13631
|
+
(0, import_node_fs36.copyFileSync)(src, dest);
|
|
13573
13632
|
copied.push(rel);
|
|
13574
13633
|
}
|
|
13575
13634
|
return copied;
|
|
@@ -13604,7 +13663,7 @@ function buildWorkspaceScriptEnv(opts, baseEnv) {
|
|
|
13604
13663
|
const env = stripNestedElectronEnv({
|
|
13605
13664
|
...baseEnv ?? process.env
|
|
13606
13665
|
});
|
|
13607
|
-
const name = opts.workspaceName ?? (0,
|
|
13666
|
+
const name = opts.workspaceName ?? (0, import_node_path36.basename)(opts.worktreePath);
|
|
13608
13667
|
const ports = opts.ports ?? [];
|
|
13609
13668
|
const primary = ports[0];
|
|
13610
13669
|
env.SIDEBOARD_WORKSPACE_NAME = name;
|
|
@@ -13867,13 +13926,13 @@ async function startDevServer(repoPath, worktreePath, onLine, opts) {
|
|
|
13867
13926
|
done: handle.done
|
|
13868
13927
|
};
|
|
13869
13928
|
}
|
|
13870
|
-
var
|
|
13929
|
+
var import_node_fs36, import_node_net, import_node_path36, import_execa4, import_node_readline3, PORT_RANGE_SIZE, cachedLoginEnv;
|
|
13871
13930
|
var init_conductor = __esm({
|
|
13872
13931
|
"src/hook/conductor.ts"() {
|
|
13873
13932
|
"use strict";
|
|
13874
|
-
|
|
13933
|
+
import_node_fs36 = require("fs");
|
|
13875
13934
|
import_node_net = require("net");
|
|
13876
|
-
|
|
13935
|
+
import_node_path36 = require("path");
|
|
13877
13936
|
import_execa4 = require("execa");
|
|
13878
13937
|
import_node_readline3 = require("readline");
|
|
13879
13938
|
init_settings();
|
|
@@ -13900,7 +13959,7 @@ ${line}` : line;
|
|
|
13900
13959
|
return nl >= 0 && nl < cut.length - 1 ? cut.slice(nl + 1) : cut;
|
|
13901
13960
|
}
|
|
13902
13961
|
function setupLogPath(threadId) {
|
|
13903
|
-
return (0,
|
|
13962
|
+
return (0, import_node_path37.join)(threadsDir(), `${threadId}.setup.log.json`);
|
|
13904
13963
|
}
|
|
13905
13964
|
function setupLogKeyForWorktree(worktreePath) {
|
|
13906
13965
|
const norm = normalizeWorktreePath(worktreePath);
|
|
@@ -13921,7 +13980,7 @@ function persistNow(threadId) {
|
|
|
13921
13980
|
const snap = memory.get(threadId);
|
|
13922
13981
|
if (!snap) return;
|
|
13923
13982
|
try {
|
|
13924
|
-
(0,
|
|
13983
|
+
(0, import_node_fs37.writeFileSync)(setupLogPath(threadId), `${JSON.stringify(snap)}
|
|
13925
13984
|
`, "utf8");
|
|
13926
13985
|
} catch {
|
|
13927
13986
|
}
|
|
@@ -13938,9 +13997,9 @@ function schedulePersist(threadId) {
|
|
|
13938
13997
|
}
|
|
13939
13998
|
function loadFromDisk(threadId) {
|
|
13940
13999
|
const path = setupLogPath(threadId);
|
|
13941
|
-
if (!(0,
|
|
14000
|
+
if (!(0, import_node_fs37.existsSync)(path)) return null;
|
|
13942
14001
|
try {
|
|
13943
|
-
const raw = JSON.parse((0,
|
|
14002
|
+
const raw = JSON.parse((0, import_node_fs37.readFileSync)(path, "utf8"));
|
|
13944
14003
|
return {
|
|
13945
14004
|
output: typeof raw.output === "string" ? raw.output : "",
|
|
13946
14005
|
running: Boolean(raw.running),
|
|
@@ -13995,13 +14054,13 @@ function finishSetupLog(threadId, exitCode, source) {
|
|
|
13995
14054
|
persistNow(threadId);
|
|
13996
14055
|
return clone(snap);
|
|
13997
14056
|
}
|
|
13998
|
-
var import_node_crypto8,
|
|
14057
|
+
var import_node_crypto8, import_node_fs37, import_node_path37, EMPTY, MAX_SETUP_LOG_CHARS, memory, persistTimers;
|
|
13999
14058
|
var init_setup_log = __esm({
|
|
14000
14059
|
"src/store/setup-log.ts"() {
|
|
14001
14060
|
"use strict";
|
|
14002
14061
|
import_node_crypto8 = require("crypto");
|
|
14003
|
-
|
|
14004
|
-
|
|
14062
|
+
import_node_fs37 = require("fs");
|
|
14063
|
+
import_node_path37 = require("path");
|
|
14005
14064
|
init_worktree_labels();
|
|
14006
14065
|
init_paths();
|
|
14007
14066
|
EMPTY = {
|
|
@@ -14027,9 +14086,9 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
14027
14086
|
repoPaths?.length ? repoPaths : threads.map((t) => t.repoPath).filter(Boolean)
|
|
14028
14087
|
);
|
|
14029
14088
|
const homeRoot = sideboardWorkspacesDir();
|
|
14030
|
-
if ((0,
|
|
14089
|
+
if ((0, import_node_fs38.existsSync)(homeRoot)) {
|
|
14031
14090
|
try {
|
|
14032
|
-
for (const entry of (0,
|
|
14091
|
+
for (const entry of (0, import_node_fs38.readdirSync)(homeRoot, { withFileTypes: true })) {
|
|
14033
14092
|
if (!entry.isDirectory()) continue;
|
|
14034
14093
|
void entry;
|
|
14035
14094
|
}
|
|
@@ -14039,7 +14098,7 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
14039
14098
|
const orphans = [];
|
|
14040
14099
|
const seen = /* @__PURE__ */ new Set();
|
|
14041
14100
|
for (const repoPath of repos) {
|
|
14042
|
-
if (!repoPath || !(0,
|
|
14101
|
+
if (!repoPath || !(0, import_node_fs38.existsSync)(repoPath)) continue;
|
|
14043
14102
|
try {
|
|
14044
14103
|
const wts = await listWorktrees(repoPath);
|
|
14045
14104
|
for (const wt of wts) {
|
|
@@ -14050,7 +14109,7 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
14050
14109
|
seen.add(path);
|
|
14051
14110
|
let mtimeMs = 0;
|
|
14052
14111
|
try {
|
|
14053
|
-
mtimeMs = (0,
|
|
14112
|
+
mtimeMs = (0, import_node_fs38.statSync)(path).mtimeMs;
|
|
14054
14113
|
} catch {
|
|
14055
14114
|
mtimeMs = 0;
|
|
14056
14115
|
}
|
|
@@ -14060,16 +14119,16 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
14060
14119
|
}
|
|
14061
14120
|
try {
|
|
14062
14121
|
const root = worktreesRoot(repoPath);
|
|
14063
|
-
if ((0,
|
|
14064
|
-
for (const entry of (0,
|
|
14122
|
+
if ((0, import_node_fs38.existsSync)(root)) {
|
|
14123
|
+
for (const entry of (0, import_node_fs38.readdirSync)(root, { withFileTypes: true })) {
|
|
14065
14124
|
if (!entry.isDirectory()) continue;
|
|
14066
|
-
const path = (0,
|
|
14125
|
+
const path = (0, import_node_path38.join)(root, entry.name).replace(/\/$/, "");
|
|
14067
14126
|
if (known.has(path) || seen.has(path)) continue;
|
|
14068
|
-
if (!(0,
|
|
14127
|
+
if (!(0, import_node_fs38.existsSync)((0, import_node_path38.join)(path, ".git"))) continue;
|
|
14069
14128
|
seen.add(path);
|
|
14070
14129
|
let mtimeMs = 0;
|
|
14071
14130
|
try {
|
|
14072
|
-
mtimeMs = (0,
|
|
14131
|
+
mtimeMs = (0, import_node_fs38.statSync)(path).mtimeMs;
|
|
14073
14132
|
} catch {
|
|
14074
14133
|
mtimeMs = Date.now();
|
|
14075
14134
|
}
|
|
@@ -14121,12 +14180,12 @@ function shouldRunWorktreeCleanup(settings = loadAppSettings()) {
|
|
|
14121
14180
|
const elapsed = Date.now() - Date.parse(last);
|
|
14122
14181
|
return elapsed >= intervalHours * 36e5;
|
|
14123
14182
|
}
|
|
14124
|
-
var
|
|
14183
|
+
var import_node_fs38, import_node_path38;
|
|
14125
14184
|
var init_orphan_cleanup = __esm({
|
|
14126
14185
|
"src/git/orphan-cleanup.ts"() {
|
|
14127
14186
|
"use strict";
|
|
14128
|
-
|
|
14129
|
-
|
|
14187
|
+
import_node_fs38 = require("fs");
|
|
14188
|
+
import_node_path38 = require("path");
|
|
14130
14189
|
init_worktree();
|
|
14131
14190
|
init_thread_store();
|
|
14132
14191
|
init_paths();
|
|
@@ -14229,12 +14288,12 @@ async function cloneRepoIntoSideboard(opts) {
|
|
|
14229
14288
|
if (!url) throw new Error("Clone URL is required");
|
|
14230
14289
|
let name = opts.name?.trim();
|
|
14231
14290
|
if (!name) {
|
|
14232
|
-
const leaf = (0,
|
|
14291
|
+
const leaf = (0, import_node_path39.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
|
|
14233
14292
|
name = leaf || "repo";
|
|
14234
14293
|
}
|
|
14235
14294
|
name = name.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "repo";
|
|
14236
|
-
const dest = (0,
|
|
14237
|
-
if ((0,
|
|
14295
|
+
const dest = (0, import_node_path39.join)(sideboardReposDir(), name);
|
|
14296
|
+
if ((0, import_node_fs39.existsSync)(dest)) {
|
|
14238
14297
|
const repoPath2 = await resolveRepoRoot(dest);
|
|
14239
14298
|
const workspace2 = await ensureWorkspace(repoPath2);
|
|
14240
14299
|
return { repoPath: repoPath2, workspace: workspace2 };
|
|
@@ -14249,12 +14308,12 @@ async function cloneRepoIntoSideboard(opts) {
|
|
|
14249
14308
|
const workspace = await ensureWorkspace(repoPath);
|
|
14250
14309
|
return { repoPath, workspace };
|
|
14251
14310
|
}
|
|
14252
|
-
var
|
|
14311
|
+
var import_node_fs39, import_node_path39, import_execa6;
|
|
14253
14312
|
var init_clone_repo = __esm({
|
|
14254
14313
|
"src/git/clone-repo.ts"() {
|
|
14255
14314
|
"use strict";
|
|
14256
|
-
|
|
14257
|
-
|
|
14315
|
+
import_node_fs39 = require("fs");
|
|
14316
|
+
import_node_path39 = require("path");
|
|
14258
14317
|
import_execa6 = require("execa");
|
|
14259
14318
|
init_paths();
|
|
14260
14319
|
init_workspaces2();
|
|
@@ -14264,11 +14323,11 @@ var init_clone_repo = __esm({
|
|
|
14264
14323
|
|
|
14265
14324
|
// src/store/desktop-host.ts
|
|
14266
14325
|
function desktopHostPidPath() {
|
|
14267
|
-
return (0,
|
|
14326
|
+
return (0, import_node_path40.join)(appDataDir(), "desktop-host.pid");
|
|
14268
14327
|
}
|
|
14269
14328
|
function readDesktopHostPid() {
|
|
14270
14329
|
try {
|
|
14271
|
-
const pid = Number.parseInt((0,
|
|
14330
|
+
const pid = Number.parseInt((0, import_node_fs40.readFileSync)(desktopHostPidPath(), "utf8").trim(), 10);
|
|
14272
14331
|
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
14273
14332
|
return pid;
|
|
14274
14333
|
} catch {
|
|
@@ -14294,12 +14353,12 @@ function thisProcessShouldDrainAgentQueues() {
|
|
|
14294
14353
|
if (isThisProcessDesktopHost()) return true;
|
|
14295
14354
|
return !isDesktopHostAlive();
|
|
14296
14355
|
}
|
|
14297
|
-
var
|
|
14356
|
+
var import_node_fs40, import_node_path40;
|
|
14298
14357
|
var init_desktop_host = __esm({
|
|
14299
14358
|
"src/store/desktop-host.ts"() {
|
|
14300
14359
|
"use strict";
|
|
14301
|
-
|
|
14302
|
-
|
|
14360
|
+
import_node_fs40 = require("fs");
|
|
14361
|
+
import_node_path40 = require("path");
|
|
14303
14362
|
init_paths();
|
|
14304
14363
|
}
|
|
14305
14364
|
});
|
|
@@ -14414,24 +14473,24 @@ function jobTreeAlive(pid) {
|
|
|
14414
14473
|
return jobAlive(pid) || processGroupAlive(pid);
|
|
14415
14474
|
}
|
|
14416
14475
|
function readIntFile(file) {
|
|
14417
|
-
if (!(0,
|
|
14418
|
-
const n = Number.parseInt((0,
|
|
14476
|
+
if (!(0, import_node_fs41.existsSync)(file)) return null;
|
|
14477
|
+
const n = Number.parseInt((0, import_node_fs41.readFileSync)(file, "utf8").trim(), 10);
|
|
14419
14478
|
return Number.isInteger(n) ? n : null;
|
|
14420
14479
|
}
|
|
14421
14480
|
function jobDir(root, id, legacy = false) {
|
|
14422
|
-
return (0,
|
|
14481
|
+
return (0, import_node_path41.join)(root, legacy ? LEGACY_DETACHED_JOBS_DIR : DETACHED_JOBS_DIR, id);
|
|
14423
14482
|
}
|
|
14424
14483
|
function resolveJobDir(root, id) {
|
|
14425
14484
|
const modern = jobDir(root, id, false);
|
|
14426
|
-
if ((0,
|
|
14485
|
+
if ((0, import_node_fs41.existsSync)(modern)) return modern;
|
|
14427
14486
|
const legacy = jobDir(root, id, true);
|
|
14428
|
-
if ((0,
|
|
14487
|
+
if ((0, import_node_fs41.existsSync)(legacy)) return legacy;
|
|
14429
14488
|
return modern;
|
|
14430
14489
|
}
|
|
14431
14490
|
function listJobIdsIn(root, rel) {
|
|
14432
|
-
const dir = (0,
|
|
14433
|
-
if (!(0,
|
|
14434
|
-
return (0,
|
|
14491
|
+
const dir = (0, import_node_path41.join)(root, rel);
|
|
14492
|
+
if (!(0, import_node_fs41.existsSync)(dir)) return [];
|
|
14493
|
+
return (0, import_node_fs41.readdirSync)(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && JOB_ID_RE.test(e.name)).map((e) => e.name);
|
|
14435
14494
|
}
|
|
14436
14495
|
function listRunningDetachedJobs(worktreePath) {
|
|
14437
14496
|
const root = worktreePath.trim();
|
|
@@ -14443,7 +14502,7 @@ function listRunningDetachedJobs(worktreePath) {
|
|
|
14443
14502
|
const running = [];
|
|
14444
14503
|
for (const id of ids) {
|
|
14445
14504
|
const dir = resolveJobDir(root, id);
|
|
14446
|
-
const pid = readIntFile((0,
|
|
14505
|
+
const pid = readIntFile((0, import_node_path41.join)(dir, "pid"));
|
|
14447
14506
|
if (jobTreeAlive(pid)) running.push(id);
|
|
14448
14507
|
}
|
|
14449
14508
|
return running.sort();
|
|
@@ -14525,8 +14584,8 @@ function planJobContinue(opts) {
|
|
|
14525
14584
|
return { action: "none" };
|
|
14526
14585
|
}
|
|
14527
14586
|
function tailProgress(logFile, maxLines = 12) {
|
|
14528
|
-
if (!(0,
|
|
14529
|
-
const lines = (0,
|
|
14587
|
+
if (!(0, import_node_fs41.existsSync)(logFile)) return "(no log yet)";
|
|
14588
|
+
const lines = (0, import_node_fs41.readFileSync)(logFile, "utf8").split("\n");
|
|
14530
14589
|
return lines.slice(-maxLines).join("\n");
|
|
14531
14590
|
}
|
|
14532
14591
|
function lastProgressLine(progress) {
|
|
@@ -14534,8 +14593,8 @@ function lastProgressLine(progress) {
|
|
|
14534
14593
|
return last ? last.slice(0, 72) : void 0;
|
|
14535
14594
|
}
|
|
14536
14595
|
function readLogLines(file) {
|
|
14537
|
-
if (!(0,
|
|
14538
|
-
const lines = (0,
|
|
14596
|
+
if (!(0, import_node_fs41.existsSync)(file)) return [];
|
|
14597
|
+
const lines = (0, import_node_fs41.readFileSync)(file, "utf8").split("\n");
|
|
14539
14598
|
if (lines.length && lines[lines.length - 1] === "") lines.pop();
|
|
14540
14599
|
return lines;
|
|
14541
14600
|
}
|
|
@@ -14546,15 +14605,15 @@ function takeDelta(logFile, cursorFile) {
|
|
|
14546
14605
|
return { delta: capJobLogDelta(lines.slice(start).join("\n")), nextCursor: lines.length };
|
|
14547
14606
|
}
|
|
14548
14607
|
function snapshotJob(dir) {
|
|
14549
|
-
const pid = readIntFile((0,
|
|
14608
|
+
const pid = readIntFile((0, import_node_path41.join)(dir, "pid"));
|
|
14550
14609
|
const running = jobTreeAlive(pid);
|
|
14551
14610
|
return {
|
|
14552
14611
|
pid,
|
|
14553
14612
|
running,
|
|
14554
|
-
exitCode: readIntFile((0,
|
|
14555
|
-
log: (0,
|
|
14556
|
-
cursor: (0,
|
|
14557
|
-
progress: tailProgress((0,
|
|
14613
|
+
exitCode: readIntFile((0, import_node_path41.join)(dir, "exit")),
|
|
14614
|
+
log: (0, import_node_path41.join)(dir, "log"),
|
|
14615
|
+
cursor: (0, import_node_path41.join)(dir, "present.cursor"),
|
|
14616
|
+
progress: tailProgress((0, import_node_path41.join)(dir, "log"))
|
|
14558
14617
|
};
|
|
14559
14618
|
}
|
|
14560
14619
|
function toResult(id, snap, extra) {
|
|
@@ -14563,8 +14622,8 @@ function toResult(id, snap, extra) {
|
|
|
14563
14622
|
const stillRunning = snap.running && !ok;
|
|
14564
14623
|
const { delta, nextCursor } = takeDelta(snap.log, snap.cursor);
|
|
14565
14624
|
try {
|
|
14566
|
-
(0,
|
|
14567
|
-
(0,
|
|
14625
|
+
(0, import_node_fs41.mkdirSync)((0, import_node_path41.dirname)(snap.cursor), { recursive: true });
|
|
14626
|
+
(0, import_node_fs41.writeFileSync)(snap.cursor, `${nextCursor}
|
|
14568
14627
|
`);
|
|
14569
14628
|
} catch {
|
|
14570
14629
|
}
|
|
@@ -14593,7 +14652,7 @@ async function waitForDetachedJob(cwd, id, opts) {
|
|
|
14593
14652
|
const dir = resolveJobDir(root, jobId);
|
|
14594
14653
|
const timeoutMs = mcpWaitForJobTimeoutMs(opts?.timeoutMs);
|
|
14595
14654
|
const sleep = opts?.sleep ?? sleepMs;
|
|
14596
|
-
if (!(0,
|
|
14655
|
+
if (!(0, import_node_fs41.existsSync)(dir)) {
|
|
14597
14656
|
return {
|
|
14598
14657
|
stillRunning: false,
|
|
14599
14658
|
ok: false,
|
|
@@ -14639,10 +14698,10 @@ function killProcessTree(pid, signal) {
|
|
|
14639
14698
|
}
|
|
14640
14699
|
function appendJobLog(logFile, line) {
|
|
14641
14700
|
try {
|
|
14642
|
-
(0,
|
|
14701
|
+
(0, import_node_fs41.mkdirSync)((0, import_node_path41.dirname)(logFile), { recursive: true });
|
|
14643
14702
|
const body = line.endsWith("\n") ? line : `${line}
|
|
14644
14703
|
`;
|
|
14645
|
-
(0,
|
|
14704
|
+
(0, import_node_fs41.appendFileSync)(logFile, body);
|
|
14646
14705
|
} catch {
|
|
14647
14706
|
}
|
|
14648
14707
|
}
|
|
@@ -14652,7 +14711,7 @@ async function stopDetachedJob(cwd, id, opts) {
|
|
|
14652
14711
|
const dir = resolveJobDir(root, jobId);
|
|
14653
14712
|
const sleep = opts?.sleep ?? sleepMs;
|
|
14654
14713
|
const why = opts?.reason?.trim() ?? "";
|
|
14655
|
-
if (!(0,
|
|
14714
|
+
if (!(0, import_node_fs41.existsSync)(dir)) {
|
|
14656
14715
|
return {
|
|
14657
14716
|
stillRunning: false,
|
|
14658
14717
|
ok: false,
|
|
@@ -14688,10 +14747,10 @@ async function stopDetachedJob(cwd, id, opts) {
|
|
|
14688
14747
|
killProcessTree(targetPid, "SIGKILL");
|
|
14689
14748
|
await sleep(100);
|
|
14690
14749
|
}
|
|
14691
|
-
const exitFile = (0,
|
|
14692
|
-
if (!(0,
|
|
14750
|
+
const exitFile = (0, import_node_path41.join)(dir, "exit");
|
|
14751
|
+
if (!(0, import_node_fs41.existsSync)(exitFile)) {
|
|
14693
14752
|
try {
|
|
14694
|
-
(0,
|
|
14753
|
+
(0, import_node_fs41.writeFileSync)(exitFile, "1\n");
|
|
14695
14754
|
} catch {
|
|
14696
14755
|
}
|
|
14697
14756
|
}
|
|
@@ -14711,12 +14770,12 @@ async function stopDetachedJob(cwd, id, opts) {
|
|
|
14711
14770
|
hint: stopped ? MCP_STOP_JOB_HINT : MCP_WAIT_JOB_STILL_RUNNING_HINT
|
|
14712
14771
|
};
|
|
14713
14772
|
}
|
|
14714
|
-
var
|
|
14773
|
+
var import_node_fs41, import_node_path41, 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;
|
|
14715
14774
|
var init_wait_for_job = __esm({
|
|
14716
14775
|
"src/mcp/wait-for-job.ts"() {
|
|
14717
14776
|
"use strict";
|
|
14718
|
-
|
|
14719
|
-
|
|
14777
|
+
import_node_fs41 = require("fs");
|
|
14778
|
+
import_node_path41 = require("path");
|
|
14720
14779
|
init_workspace_scratch();
|
|
14721
14780
|
init_wait_for_turn();
|
|
14722
14781
|
MAX_JOB_CONTINUES = 8;
|
|
@@ -15962,7 +16021,7 @@ function reuseLiveThread(input, repoPath, match) {
|
|
|
15962
16021
|
}
|
|
15963
16022
|
async function createThread(input, _onSetupLine) {
|
|
15964
16023
|
const repoPath = await resolveRepoRoot(input.repoPath);
|
|
15965
|
-
if (!(0,
|
|
16024
|
+
if (!(0, import_node_fs42.existsSync)(repoPath)) {
|
|
15966
16025
|
throw new Error(`Repo not found: ${repoPath}`);
|
|
15967
16026
|
}
|
|
15968
16027
|
const reused = reuseLiveThread(input, repoPath, {
|
|
@@ -16138,11 +16197,11 @@ async function createThread(input, _onSetupLine) {
|
|
|
16138
16197
|
await ensureWorkspace(repoPath);
|
|
16139
16198
|
return readThread(thread.id) ?? thread;
|
|
16140
16199
|
}
|
|
16141
|
-
var
|
|
16200
|
+
var import_node_fs42;
|
|
16142
16201
|
var init_create = __esm({
|
|
16143
16202
|
"src/threads/create.ts"() {
|
|
16144
16203
|
"use strict";
|
|
16145
|
-
|
|
16204
|
+
import_node_fs42 = require("fs");
|
|
16146
16205
|
init_detect();
|
|
16147
16206
|
init_worktree();
|
|
16148
16207
|
init_home_board();
|
|
@@ -16262,20 +16321,20 @@ function writeTurnLive(threadId, progress) {
|
|
|
16262
16321
|
const path = threadLivePath(threadId);
|
|
16263
16322
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
16264
16323
|
try {
|
|
16265
|
-
(0,
|
|
16266
|
-
(0,
|
|
16324
|
+
(0, import_node_fs43.writeFileSync)(tmp, JSON.stringify(progress), "utf8");
|
|
16325
|
+
(0, import_node_fs43.renameSync)(tmp, path);
|
|
16267
16326
|
} catch {
|
|
16268
16327
|
try {
|
|
16269
|
-
(0,
|
|
16328
|
+
(0, import_node_fs43.unlinkSync)(tmp);
|
|
16270
16329
|
} catch {
|
|
16271
16330
|
}
|
|
16272
16331
|
}
|
|
16273
16332
|
}
|
|
16274
16333
|
function readTurnLive(threadId) {
|
|
16275
16334
|
const path = threadLivePath(threadId);
|
|
16276
|
-
if (!(0,
|
|
16335
|
+
if (!(0, import_node_fs43.existsSync)(path)) return null;
|
|
16277
16336
|
try {
|
|
16278
|
-
const raw = JSON.parse((0,
|
|
16337
|
+
const raw = JSON.parse((0, import_node_fs43.readFileSync)(path, "utf8"));
|
|
16279
16338
|
if (!raw || typeof raw.summary !== "string") return null;
|
|
16280
16339
|
return raw;
|
|
16281
16340
|
} catch {
|
|
@@ -16287,17 +16346,17 @@ function clearTurnLive(threadId) {
|
|
|
16287
16346
|
if (buf?.timer) clearTimeout(buf.timer);
|
|
16288
16347
|
buffers.delete(threadId);
|
|
16289
16348
|
const path = threadLivePath(threadId);
|
|
16290
|
-
if (!(0,
|
|
16349
|
+
if (!(0, import_node_fs43.existsSync)(path)) return;
|
|
16291
16350
|
try {
|
|
16292
|
-
(0,
|
|
16351
|
+
(0, import_node_fs43.unlinkSync)(path);
|
|
16293
16352
|
} catch {
|
|
16294
16353
|
}
|
|
16295
16354
|
}
|
|
16296
|
-
var
|
|
16355
|
+
var import_node_fs43, buffers, FLUSH_MS, MAX_PARTS;
|
|
16297
16356
|
var init_turn_live = __esm({
|
|
16298
16357
|
"src/store/turn-live.ts"() {
|
|
16299
16358
|
"use strict";
|
|
16300
|
-
|
|
16359
|
+
import_node_fs43 = require("fs");
|
|
16301
16360
|
init_message_parts();
|
|
16302
16361
|
init_paths();
|
|
16303
16362
|
buffers = /* @__PURE__ */ new Map();
|
|
@@ -16514,7 +16573,7 @@ var init_quota_failover = __esm({
|
|
|
16514
16573
|
// src/threads/adopt.ts
|
|
16515
16574
|
function thisModuleFile() {
|
|
16516
16575
|
const cjsFile = typeof __filename !== "undefined" ? __filename : "";
|
|
16517
|
-
return cjsFile || process.argv[1] || (0,
|
|
16576
|
+
return cjsFile || process.argv[1] || (0, import_node_path42.join)(process.cwd(), "package.json");
|
|
16518
16577
|
}
|
|
16519
16578
|
function openReadonlySqlite(file) {
|
|
16520
16579
|
const req = (0, import_node_module4.createRequire)(thisModuleFile());
|
|
@@ -16532,21 +16591,21 @@ function mapAgentType(raw) {
|
|
|
16532
16591
|
return null;
|
|
16533
16592
|
}
|
|
16534
16593
|
function resolveConductorCursorAgentId(workspacePath) {
|
|
16535
|
-
if (!workspacePath || !(0,
|
|
16594
|
+
if (!workspacePath || !(0, import_node_fs44.existsSync)(CURSOR_SDK_STORE)) return null;
|
|
16536
16595
|
const normalized = workspacePath.replace(/\/$/, "");
|
|
16537
16596
|
let best = null;
|
|
16538
16597
|
let hashes;
|
|
16539
16598
|
try {
|
|
16540
|
-
hashes = (0,
|
|
16599
|
+
hashes = (0, import_node_fs44.readdirSync)(CURSOR_SDK_STORE);
|
|
16541
16600
|
} catch {
|
|
16542
16601
|
return null;
|
|
16543
16602
|
}
|
|
16544
16603
|
for (const hash of hashes) {
|
|
16545
|
-
const agentsFile = (0,
|
|
16546
|
-
if (!(0,
|
|
16604
|
+
const agentsFile = (0, import_node_path42.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
|
|
16605
|
+
if (!(0, import_node_fs44.existsSync)(agentsFile)) continue;
|
|
16547
16606
|
let text7;
|
|
16548
16607
|
try {
|
|
16549
|
-
text7 = (0,
|
|
16608
|
+
text7 = (0, import_node_fs44.readFileSync)(agentsFile, "utf8");
|
|
16550
16609
|
} catch {
|
|
16551
16610
|
continue;
|
|
16552
16611
|
}
|
|
@@ -16570,7 +16629,7 @@ function resolveConductorCursorAgentId(workspacePath) {
|
|
|
16570
16629
|
return best?.agentId ?? null;
|
|
16571
16630
|
}
|
|
16572
16631
|
async function adoptThread(input) {
|
|
16573
|
-
if (!(0,
|
|
16632
|
+
if (!(0, import_node_fs44.existsSync)(input.worktreePath)) {
|
|
16574
16633
|
throw new Error(`Worktree not found: ${input.worktreePath}`);
|
|
16575
16634
|
}
|
|
16576
16635
|
const repoPath = await resolveRepoRoot(input.worktreePath);
|
|
@@ -16596,18 +16655,18 @@ async function adoptThread(input) {
|
|
|
16596
16655
|
return thread;
|
|
16597
16656
|
}
|
|
16598
16657
|
function listConductorWorkspaces() {
|
|
16599
|
-
if (!(0,
|
|
16658
|
+
if (!(0, import_node_fs44.existsSync)(CONDUCTOR_DB)) {
|
|
16600
16659
|
throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
|
|
16601
16660
|
}
|
|
16602
|
-
const tmp = (0,
|
|
16603
|
-
const snapshot = (0,
|
|
16661
|
+
const tmp = (0, import_node_fs44.mkdtempSync)((0, import_node_path42.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
|
|
16662
|
+
const snapshot = (0, import_node_path42.join)(tmp, "conductor.db");
|
|
16604
16663
|
try {
|
|
16605
|
-
(0,
|
|
16664
|
+
(0, import_node_fs44.copyFileSync)(CONDUCTOR_DB, snapshot);
|
|
16606
16665
|
for (const suffix of ["-wal", "-shm"]) {
|
|
16607
16666
|
const src = `${CONDUCTOR_DB}${suffix}`;
|
|
16608
|
-
if ((0,
|
|
16667
|
+
if ((0, import_node_fs44.existsSync)(src)) {
|
|
16609
16668
|
try {
|
|
16610
|
-
(0,
|
|
16669
|
+
(0, import_node_fs44.copyFileSync)(src, `${snapshot}${suffix}`);
|
|
16611
16670
|
} catch {
|
|
16612
16671
|
}
|
|
16613
16672
|
}
|
|
@@ -16683,22 +16742,22 @@ function listConductorWorkspaces() {
|
|
|
16683
16742
|
db.close();
|
|
16684
16743
|
}
|
|
16685
16744
|
} finally {
|
|
16686
|
-
(0,
|
|
16745
|
+
(0, import_node_fs44.rmSync)(tmp, { recursive: true, force: true });
|
|
16687
16746
|
}
|
|
16688
16747
|
}
|
|
16689
16748
|
function importConductorWorkspace(workspaceId) {
|
|
16690
|
-
if (!(0,
|
|
16749
|
+
if (!(0, import_node_fs44.existsSync)(CONDUCTOR_DB)) {
|
|
16691
16750
|
throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
|
|
16692
16751
|
}
|
|
16693
|
-
const tmp = (0,
|
|
16694
|
-
const snapshot = (0,
|
|
16752
|
+
const tmp = (0, import_node_fs44.mkdtempSync)((0, import_node_path42.join)((0, import_node_os14.tmpdir)(), "sideboard-conductor-"));
|
|
16753
|
+
const snapshot = (0, import_node_path42.join)(tmp, "conductor.db");
|
|
16695
16754
|
try {
|
|
16696
|
-
(0,
|
|
16755
|
+
(0, import_node_fs44.copyFileSync)(CONDUCTOR_DB, snapshot);
|
|
16697
16756
|
for (const suffix of ["-wal", "-shm"]) {
|
|
16698
16757
|
const src = `${CONDUCTOR_DB}${suffix}`;
|
|
16699
|
-
if ((0,
|
|
16758
|
+
if ((0, import_node_fs44.existsSync)(src)) {
|
|
16700
16759
|
try {
|
|
16701
|
-
(0,
|
|
16760
|
+
(0, import_node_fs44.copyFileSync)(src, `${snapshot}${suffix}`);
|
|
16702
16761
|
} catch {
|
|
16703
16762
|
}
|
|
16704
16763
|
}
|
|
@@ -16716,7 +16775,7 @@ function importConductorWorkspace(workspaceId) {
|
|
|
16716
16775
|
).get(workspaceId);
|
|
16717
16776
|
if (!row) throw new Error(`Conductor workspace not found: ${workspaceId}`);
|
|
16718
16777
|
const worktreePath = String(row.workspacePath);
|
|
16719
|
-
if (!(0,
|
|
16778
|
+
if (!(0, import_node_fs44.existsSync)(worktreePath)) {
|
|
16720
16779
|
throw new Error(`Conductor worktree missing on disk: ${worktreePath}`);
|
|
16721
16780
|
}
|
|
16722
16781
|
let sessionId = null;
|
|
@@ -16779,31 +16838,31 @@ function importConductorWorkspace(workspaceId) {
|
|
|
16779
16838
|
db.close();
|
|
16780
16839
|
}
|
|
16781
16840
|
} finally {
|
|
16782
|
-
(0,
|
|
16841
|
+
(0, import_node_fs44.rmSync)(tmp, { recursive: true, force: true });
|
|
16783
16842
|
}
|
|
16784
16843
|
}
|
|
16785
16844
|
async function importConductorWorkspaceAsync(workspaceId) {
|
|
16786
16845
|
return importConductorWorkspace(workspaceId);
|
|
16787
16846
|
}
|
|
16788
|
-
var import_node_child_process4,
|
|
16847
|
+
var import_node_child_process4, import_node_fs44, import_node_os14, import_node_path42, import_node_module4, CONDUCTOR_APP_SUPPORT, CONDUCTOR_DB, CURSOR_SDK_STORE;
|
|
16789
16848
|
var init_adopt = __esm({
|
|
16790
16849
|
"src/threads/adopt.ts"() {
|
|
16791
16850
|
"use strict";
|
|
16792
16851
|
import_node_child_process4 = require("child_process");
|
|
16793
|
-
|
|
16794
|
-
|
|
16795
|
-
|
|
16852
|
+
import_node_fs44 = require("fs");
|
|
16853
|
+
import_node_os14 = require("os");
|
|
16854
|
+
import_node_path42 = require("path");
|
|
16796
16855
|
import_node_module4 = require("module");
|
|
16797
16856
|
init_worktree();
|
|
16798
16857
|
init_thread_store();
|
|
16799
|
-
CONDUCTOR_APP_SUPPORT = (0,
|
|
16858
|
+
CONDUCTOR_APP_SUPPORT = (0, import_node_path42.join)(
|
|
16800
16859
|
process.env.HOME ?? "",
|
|
16801
16860
|
"Library",
|
|
16802
16861
|
"Application Support",
|
|
16803
16862
|
"com.conductor.app"
|
|
16804
16863
|
);
|
|
16805
|
-
CONDUCTOR_DB = (0,
|
|
16806
|
-
CURSOR_SDK_STORE = (0,
|
|
16864
|
+
CONDUCTOR_DB = (0, import_node_path42.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
|
|
16865
|
+
CURSOR_SDK_STORE = (0, import_node_path42.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
|
|
16807
16866
|
}
|
|
16808
16867
|
});
|
|
16809
16868
|
|
|
@@ -16870,7 +16929,7 @@ async function openStackLayer(input, _onSetupLine) {
|
|
|
16870
16929
|
let createdWorktree = false;
|
|
16871
16930
|
const trees = await listWorktrees(repoPath);
|
|
16872
16931
|
const checkedOut = trees.find((w) => w.branch === branchName);
|
|
16873
|
-
if (checkedOut?.path && (0,
|
|
16932
|
+
if (checkedOut?.path && (0, import_node_fs45.existsSync)(checkedOut.path)) {
|
|
16874
16933
|
if (input.reuseExistingWorktree !== false) {
|
|
16875
16934
|
worktreePath = checkedOut.path;
|
|
16876
16935
|
} else {
|
|
@@ -17012,7 +17071,7 @@ async function initStackFromThread(input, onSetupLine) {
|
|
|
17012
17071
|
async function createPrStack(input, onSetupLine) {
|
|
17013
17072
|
await requireAgent(input.agent);
|
|
17014
17073
|
const repoPath = await resolveRepoRoot(input.repoPath);
|
|
17015
|
-
if (!(0,
|
|
17074
|
+
if (!(0, import_node_fs45.existsSync)(repoPath)) throw new Error(`Repo not found: ${repoPath}`);
|
|
17016
17075
|
if (!input.branches.length) throw new Error("At least one branch name required");
|
|
17017
17076
|
const status = await detectGhStack(repoPath);
|
|
17018
17077
|
if (!status.available) throw new Error(status.reason);
|
|
@@ -17079,7 +17138,7 @@ async function createPrStack(input, onSetupLine) {
|
|
|
17079
17138
|
}
|
|
17080
17139
|
}
|
|
17081
17140
|
const claimed = new Set(threads.map((t) => t.worktreePath));
|
|
17082
|
-
if (!claimed.has(bootstrap.worktreePath) && (0,
|
|
17141
|
+
if (!claimed.has(bootstrap.worktreePath) && (0, import_node_fs45.existsSync)(bootstrap.worktreePath)) {
|
|
17083
17142
|
try {
|
|
17084
17143
|
await removeWorktree(repoPath, bootstrap.worktreePath, {
|
|
17085
17144
|
deleteBranch: bootstrap.branchName
|
|
@@ -17089,11 +17148,11 @@ async function createPrStack(input, onSetupLine) {
|
|
|
17089
17148
|
}
|
|
17090
17149
|
return { stack, threads, createdThreadIds };
|
|
17091
17150
|
}
|
|
17092
|
-
var
|
|
17151
|
+
var import_node_fs45;
|
|
17093
17152
|
var init_stack_layers = __esm({
|
|
17094
17153
|
"src/threads/stack-layers.ts"() {
|
|
17095
17154
|
"use strict";
|
|
17096
|
-
|
|
17155
|
+
import_node_fs45 = require("fs");
|
|
17097
17156
|
init_detect();
|
|
17098
17157
|
init_run();
|
|
17099
17158
|
init_stack();
|
|
@@ -17106,7 +17165,7 @@ var init_stack_layers = __esm({
|
|
|
17106
17165
|
|
|
17107
17166
|
// src/diff/diff.ts
|
|
17108
17167
|
async function inspectGitWorktree(worktreePath) {
|
|
17109
|
-
if (!worktreePath || !(0,
|
|
17168
|
+
if (!worktreePath || !(0, import_node_fs46.existsSync)(worktreePath)) return "missing_worktree";
|
|
17110
17169
|
const check = await git(["rev-parse", "--is-inside-work-tree"], worktreePath, {
|
|
17111
17170
|
reject: false
|
|
17112
17171
|
});
|
|
@@ -17114,7 +17173,7 @@ async function inspectGitWorktree(worktreePath) {
|
|
|
17114
17173
|
return "ok";
|
|
17115
17174
|
}
|
|
17116
17175
|
async function initializeGitRepository(worktreePath) {
|
|
17117
|
-
if (!worktreePath || !(0,
|
|
17176
|
+
if (!worktreePath || !(0, import_node_fs46.existsSync)(worktreePath)) {
|
|
17118
17177
|
throw new Error("Worktree not found");
|
|
17119
17178
|
}
|
|
17120
17179
|
const status = await inspectGitWorktree(worktreePath);
|
|
@@ -17248,11 +17307,11 @@ new file mode 100644
|
|
|
17248
17307
|
};
|
|
17249
17308
|
}
|
|
17250
17309
|
async function untrackedPatch(worktreePath, path, maxHunk) {
|
|
17251
|
-
const abs = (0,
|
|
17310
|
+
const abs = (0, import_node_path43.join)(worktreePath, path);
|
|
17252
17311
|
try {
|
|
17253
|
-
const st = (0,
|
|
17312
|
+
const st = (0, import_node_fs46.statSync)(abs);
|
|
17254
17313
|
if (st.isFile() && st.size > maxHunk) {
|
|
17255
|
-
const buf = (0,
|
|
17314
|
+
const buf = (0, import_node_fs46.readFileSync)(abs).subarray(0, maxHunk);
|
|
17256
17315
|
return syntheticAddPatch(path, buf.toString("utf8"), maxHunk);
|
|
17257
17316
|
}
|
|
17258
17317
|
} catch {
|
|
@@ -17741,8 +17800,8 @@ function isImageRelativePath(relativePath) {
|
|
|
17741
17800
|
function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
17742
17801
|
assertSafeRelativePath(relativePath);
|
|
17743
17802
|
const maxBytes = opts?.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES;
|
|
17744
|
-
const abs = (0,
|
|
17745
|
-
const st = (0,
|
|
17803
|
+
const abs = (0, import_node_path43.join)(worktreePath, relativePath);
|
|
17804
|
+
const st = (0, import_node_fs46.statSync)(abs);
|
|
17746
17805
|
if (!st.isFile()) {
|
|
17747
17806
|
throw new Error(`Not a file: ${relativePath}`);
|
|
17748
17807
|
}
|
|
@@ -17751,7 +17810,7 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
|
17751
17810
|
`File too large to upload (${st.size} bytes; max ${maxBytes})`
|
|
17752
17811
|
);
|
|
17753
17812
|
}
|
|
17754
|
-
const buf = (0,
|
|
17813
|
+
const buf = (0, import_node_fs46.readFileSync)(abs);
|
|
17755
17814
|
return {
|
|
17756
17815
|
path: relativePath,
|
|
17757
17816
|
contentBase64: buf.toString("base64"),
|
|
@@ -17761,12 +17820,12 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
|
17761
17820
|
function readWorktreeFile(worktreePath, relativePath, opts) {
|
|
17762
17821
|
assertSafeRelativePath(relativePath);
|
|
17763
17822
|
const maxBytes = opts?.maxBytes ?? 2e5;
|
|
17764
|
-
const abs = (0,
|
|
17765
|
-
const st = (0,
|
|
17823
|
+
const abs = (0, import_node_path43.join)(worktreePath, relativePath);
|
|
17824
|
+
const st = (0, import_node_fs46.statSync)(abs);
|
|
17766
17825
|
if (!st.isFile()) {
|
|
17767
17826
|
throw new Error(`Not a file: ${relativePath}`);
|
|
17768
17827
|
}
|
|
17769
|
-
const buf = (0,
|
|
17828
|
+
const buf = (0, import_node_fs46.readFileSync)(abs);
|
|
17770
17829
|
if (isImageRelativePath(relativePath)) {
|
|
17771
17830
|
const maxImageBytes = Math.max(maxBytes, 15e6);
|
|
17772
17831
|
const truncated2 = buf.length > maxImageBytes;
|
|
@@ -17809,9 +17868,9 @@ function assertSafeRelativePath(relativePath) {
|
|
|
17809
17868
|
}
|
|
17810
17869
|
function writeWorktreeFile(worktreePath, relativePath, content) {
|
|
17811
17870
|
assertSafeRelativePath(relativePath);
|
|
17812
|
-
const abs = (0,
|
|
17813
|
-
(0,
|
|
17814
|
-
(0,
|
|
17871
|
+
const abs = (0, import_node_path43.join)(worktreePath, relativePath);
|
|
17872
|
+
(0, import_node_fs46.mkdirSync)((0, import_node_path43.dirname)(abs), { recursive: true });
|
|
17873
|
+
(0, import_node_fs46.writeFileSync)(abs, content, "utf8");
|
|
17815
17874
|
return { path: relativePath };
|
|
17816
17875
|
}
|
|
17817
17876
|
async function getDiffSummary(worktreePath, repoPath, opts) {
|
|
@@ -17828,12 +17887,12 @@ async function getDiffSummary(worktreePath, repoPath, opts) {
|
|
|
17828
17887
|
truncated: full.files.length > maxFiles
|
|
17829
17888
|
};
|
|
17830
17889
|
}
|
|
17831
|
-
var
|
|
17890
|
+
var import_node_fs46, import_node_path43, mergeBaseCache, MERGE_BASE_TTL_MS, SHA_RE, IMAGE_EXTENSIONS2, DEFAULT_UPLOAD_MAX_BYTES;
|
|
17832
17891
|
var init_diff = __esm({
|
|
17833
17892
|
"src/diff/diff.ts"() {
|
|
17834
17893
|
"use strict";
|
|
17835
|
-
|
|
17836
|
-
|
|
17894
|
+
import_node_fs46 = require("fs");
|
|
17895
|
+
import_node_path43 = require("path");
|
|
17837
17896
|
init_run();
|
|
17838
17897
|
init_worktree();
|
|
17839
17898
|
mergeBaseCache = /* @__PURE__ */ new Map();
|
|
@@ -18190,7 +18249,7 @@ function parseFrontmatter(content) {
|
|
|
18190
18249
|
}
|
|
18191
18250
|
function readSkill(skillMd, source) {
|
|
18192
18251
|
try {
|
|
18193
|
-
const content = (0,
|
|
18252
|
+
const content = (0, import_node_fs47.readFileSync)(skillMd, "utf8");
|
|
18194
18253
|
const { name: fmName, description } = parseFrontmatter(content);
|
|
18195
18254
|
const dirName = skillMd.split("/").slice(-2, -1)[0] || "skill";
|
|
18196
18255
|
const name = fmName || dirName;
|
|
@@ -18209,19 +18268,19 @@ function readSkill(skillMd, source) {
|
|
|
18209
18268
|
}
|
|
18210
18269
|
}
|
|
18211
18270
|
function scanSkillsDir(dir, source, out) {
|
|
18212
|
-
if (!(0,
|
|
18271
|
+
if (!(0, import_node_fs47.existsSync)(dir)) return;
|
|
18213
18272
|
let entries;
|
|
18214
18273
|
try {
|
|
18215
|
-
entries = (0,
|
|
18274
|
+
entries = (0, import_node_fs47.readdirSync)(dir);
|
|
18216
18275
|
} catch {
|
|
18217
18276
|
return;
|
|
18218
18277
|
}
|
|
18219
18278
|
for (const entry of entries) {
|
|
18220
18279
|
if (entry.startsWith(".")) continue;
|
|
18221
|
-
const skillMd = (0,
|
|
18222
|
-
if (!(0,
|
|
18280
|
+
const skillMd = (0, import_node_path44.join)(dir, entry, "SKILL.md");
|
|
18281
|
+
if (!(0, import_node_fs47.existsSync)(skillMd)) continue;
|
|
18223
18282
|
try {
|
|
18224
|
-
if (!(0,
|
|
18283
|
+
if (!(0, import_node_fs47.statSync)(skillMd).isFile()) continue;
|
|
18225
18284
|
} catch {
|
|
18226
18285
|
continue;
|
|
18227
18286
|
}
|
|
@@ -18230,24 +18289,24 @@ function scanSkillsDir(dir, source, out) {
|
|
|
18230
18289
|
}
|
|
18231
18290
|
}
|
|
18232
18291
|
function scanClaudePluginSkills(pluginsRoot, out) {
|
|
18233
|
-
if (!(0,
|
|
18292
|
+
if (!(0, import_node_fs47.existsSync)(pluginsRoot)) return;
|
|
18234
18293
|
const walk = (dir, depth, lookingForSkillsDir) => {
|
|
18235
18294
|
if (depth > 7) return;
|
|
18236
18295
|
let entries;
|
|
18237
18296
|
try {
|
|
18238
|
-
entries = (0,
|
|
18297
|
+
entries = (0, import_node_fs47.readdirSync)(dir);
|
|
18239
18298
|
} catch {
|
|
18240
18299
|
return;
|
|
18241
18300
|
}
|
|
18242
18301
|
if (lookingForSkillsDir && entries.includes("SKILL.md")) {
|
|
18243
|
-
const skill = readSkill((0,
|
|
18302
|
+
const skill = readSkill((0, import_node_path44.join)(dir, "SKILL.md"), "cli");
|
|
18244
18303
|
if (skill) out.push(skill);
|
|
18245
18304
|
}
|
|
18246
18305
|
for (const entry of entries) {
|
|
18247
18306
|
if (entry === "node_modules" || entry === ".git") continue;
|
|
18248
|
-
const full = (0,
|
|
18307
|
+
const full = (0, import_node_path44.join)(dir, entry);
|
|
18249
18308
|
try {
|
|
18250
|
-
if (!(0,
|
|
18309
|
+
if (!(0, import_node_fs47.statSync)(full).isDirectory()) continue;
|
|
18251
18310
|
} catch {
|
|
18252
18311
|
continue;
|
|
18253
18312
|
}
|
|
@@ -18262,20 +18321,20 @@ function scanClaudePluginSkills(pluginsRoot, out) {
|
|
|
18262
18321
|
walk(pluginsRoot, 0, false);
|
|
18263
18322
|
}
|
|
18264
18323
|
function discoverSkills(worktreePath) {
|
|
18265
|
-
const home = (0,
|
|
18324
|
+
const home = (0, import_node_os15.homedir)();
|
|
18266
18325
|
const collected = [];
|
|
18267
18326
|
for (const rel of [".claude/skills", ".cursor/skills", ".sideboard/skills", ".brightsy/skills", "skills"]) {
|
|
18268
|
-
scanSkillsDir((0,
|
|
18327
|
+
scanSkillsDir((0, import_node_path44.join)(worktreePath, rel), "workspace", collected);
|
|
18269
18328
|
}
|
|
18270
18329
|
for (const abs of [
|
|
18271
|
-
(0,
|
|
18272
|
-
(0,
|
|
18273
|
-
(0,
|
|
18274
|
-
(0,
|
|
18330
|
+
(0, import_node_path44.join)(home, ".claude/skills"),
|
|
18331
|
+
(0, import_node_path44.join)(home, ".cursor/skills"),
|
|
18332
|
+
(0, import_node_path44.join)(home, ".sideboard/skills"),
|
|
18333
|
+
(0, import_node_path44.join)(home, ".brightsy/skills")
|
|
18275
18334
|
]) {
|
|
18276
18335
|
scanSkillsDir(abs, "user", collected);
|
|
18277
18336
|
}
|
|
18278
|
-
scanClaudePluginSkills((0,
|
|
18337
|
+
scanClaudePluginSkills((0, import_node_path44.join)(home, ".claude/plugins"), collected);
|
|
18279
18338
|
collected.push(...bundledSkills());
|
|
18280
18339
|
const rank = {
|
|
18281
18340
|
workspace: 0,
|
|
@@ -18301,7 +18360,7 @@ function readSkillBody(skillPath, maxChars = 12e3) {
|
|
|
18301
18360
|
\u2026(truncated)` : body;
|
|
18302
18361
|
}
|
|
18303
18362
|
}
|
|
18304
|
-
const raw = (0,
|
|
18363
|
+
const raw = (0, import_node_fs47.readFileSync)(skillPath, "utf8");
|
|
18305
18364
|
if (raw.startsWith("---")) {
|
|
18306
18365
|
const end = raw.indexOf("\n---", 3);
|
|
18307
18366
|
if (end >= 0) {
|
|
@@ -18315,13 +18374,13 @@ function readSkillBody(skillPath, maxChars = 12e3) {
|
|
|
18315
18374
|
|
|
18316
18375
|
\u2026(truncated)` : raw;
|
|
18317
18376
|
}
|
|
18318
|
-
var
|
|
18377
|
+
var import_node_fs47, import_node_os15, import_node_path44, BUNDLED_SKILL_PREFIX;
|
|
18319
18378
|
var init_discover = __esm({
|
|
18320
18379
|
"src/skills/discover.ts"() {
|
|
18321
18380
|
"use strict";
|
|
18322
|
-
|
|
18323
|
-
|
|
18324
|
-
|
|
18381
|
+
import_node_fs47 = require("fs");
|
|
18382
|
+
import_node_os15 = require("os");
|
|
18383
|
+
import_node_path44 = require("path");
|
|
18325
18384
|
init_long_running();
|
|
18326
18385
|
BUNDLED_SKILL_PREFIX = "bundled:";
|
|
18327
18386
|
}
|
|
@@ -18415,8 +18474,8 @@ var init_expand = __esm({
|
|
|
18415
18474
|
// src/skills/detached-job-path.ts
|
|
18416
18475
|
function detachedJobScriptIn(dir) {
|
|
18417
18476
|
for (const name of DETACHED_JOB_FILENAMES) {
|
|
18418
|
-
const script = (0,
|
|
18419
|
-
if ((0,
|
|
18477
|
+
const script = (0, import_node_path45.join)(dir, "scripts", name);
|
|
18478
|
+
if ((0, import_node_fs48.existsSync)(script)) return script;
|
|
18420
18479
|
}
|
|
18421
18480
|
return null;
|
|
18422
18481
|
}
|
|
@@ -18428,11 +18487,11 @@ function packagedDetachedJobPath() {
|
|
|
18428
18487
|
function resolveDetachedJobScript() {
|
|
18429
18488
|
const packaged = packagedDetachedJobPath();
|
|
18430
18489
|
if (packaged) return packaged;
|
|
18431
|
-
let dir = (0,
|
|
18490
|
+
let dir = (0, import_node_path45.dirname)((0, import_node_url3.fileURLToPath)(import_meta3.url));
|
|
18432
18491
|
for (let i = 0; i < 8; i++) {
|
|
18433
18492
|
const candidate = detachedJobScriptIn(dir);
|
|
18434
18493
|
if (candidate) return candidate;
|
|
18435
|
-
const parent = (0,
|
|
18494
|
+
const parent = (0, import_node_path45.dirname)(dir);
|
|
18436
18495
|
if (parent === dir) break;
|
|
18437
18496
|
dir = parent;
|
|
18438
18497
|
}
|
|
@@ -18443,12 +18502,12 @@ function formatDetachedJobInvoke(scriptPath) {
|
|
|
18443
18502
|
if (resolved) return `node ${JSON.stringify(resolved)}`;
|
|
18444
18503
|
return "node scripts/detached-job.cjs";
|
|
18445
18504
|
}
|
|
18446
|
-
var
|
|
18505
|
+
var import_node_fs48, import_node_path45, import_node_url3, import_meta3, DETACHED_JOB_FILENAMES;
|
|
18447
18506
|
var init_detached_job_path = __esm({
|
|
18448
18507
|
"src/skills/detached-job-path.ts"() {
|
|
18449
18508
|
"use strict";
|
|
18450
|
-
|
|
18451
|
-
|
|
18509
|
+
import_node_fs48 = require("fs");
|
|
18510
|
+
import_node_path45 = require("path");
|
|
18452
18511
|
import_node_url3 = require("url");
|
|
18453
18512
|
init_packaged_runtime();
|
|
18454
18513
|
import_meta3 = {};
|
|
@@ -18608,9 +18667,9 @@ function formatPrGateDirective() {
|
|
|
18608
18667
|
}
|
|
18609
18668
|
function formatProcessGuideDirective(opts) {
|
|
18610
18669
|
const worktree = opts?.worktreePath?.trim();
|
|
18611
|
-
const hasGraphSkill = !!worktree && (0,
|
|
18612
|
-
const hasReviewSkill = !!worktree && (0,
|
|
18613
|
-
const hasInstallSkill = !!worktree && (0,
|
|
18670
|
+
const hasGraphSkill = !!worktree && (0, import_node_fs49.existsSync)((0, import_node_path46.join)(worktree, ".claude/skills/graph-engineering/SKILL.md"));
|
|
18671
|
+
const hasReviewSkill = !!worktree && (0, import_node_fs49.existsSync)((0, import_node_path46.join)(worktree, ".claude/skills/review/SKILL.md"));
|
|
18672
|
+
const hasInstallSkill = !!worktree && (0, import_node_fs49.existsSync)((0, import_node_path46.join)(worktree, ".claude/skills/worktree-install/SKILL.md"));
|
|
18614
18673
|
return [
|
|
18615
18674
|
"Process guides (recurring work only):",
|
|
18616
18675
|
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,
|
|
@@ -18648,12 +18707,12 @@ function formatArtifactDirective() {
|
|
|
18648
18707
|
function formatUiReminder() {
|
|
18649
18708
|
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.";
|
|
18650
18709
|
}
|
|
18651
|
-
var
|
|
18710
|
+
var import_node_fs49, import_node_path46, PR_GOAL_RE, GITHUB_TICKET_REF, KEYED_TICKET_REF;
|
|
18652
18711
|
var init_instructions = __esm({
|
|
18653
18712
|
"src/agents/instructions.ts"() {
|
|
18654
18713
|
"use strict";
|
|
18655
|
-
|
|
18656
|
-
|
|
18714
|
+
import_node_fs49 = require("fs");
|
|
18715
|
+
import_node_path46 = require("path");
|
|
18657
18716
|
init_git_auth_mode();
|
|
18658
18717
|
init_branch_prefix();
|
|
18659
18718
|
init_worktree_labels();
|
|
@@ -18877,40 +18936,40 @@ __export(plan_file_exports, {
|
|
|
18877
18936
|
writePlanFile: () => writePlanFile
|
|
18878
18937
|
});
|
|
18879
18938
|
function ensureAttachmentsGitignore(worktreePath) {
|
|
18880
|
-
const gitignoreAbs = (0,
|
|
18881
|
-
if ((0,
|
|
18882
|
-
(0,
|
|
18883
|
-
(0,
|
|
18939
|
+
const gitignoreAbs = (0, import_node_path47.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
|
|
18940
|
+
if ((0, import_node_fs50.existsSync)(gitignoreAbs)) return;
|
|
18941
|
+
(0, import_node_fs50.mkdirSync)((0, import_node_path47.dirname)(gitignoreAbs), { recursive: true });
|
|
18942
|
+
(0, import_node_fs50.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
|
|
18884
18943
|
}
|
|
18885
18944
|
function planFileAbs(worktreePath) {
|
|
18886
|
-
return (0,
|
|
18945
|
+
return (0, import_node_path47.join)(worktreePath, PLAN_FILE_REL);
|
|
18887
18946
|
}
|
|
18888
18947
|
function readTextIfPresent2(abs) {
|
|
18889
|
-
if (!(0,
|
|
18948
|
+
if (!(0, import_node_fs50.existsSync)(abs)) return null;
|
|
18890
18949
|
try {
|
|
18891
|
-
const content = (0,
|
|
18950
|
+
const content = (0, import_node_fs50.readFileSync)(abs, "utf8");
|
|
18892
18951
|
return content.trim() ? content : null;
|
|
18893
18952
|
} catch {
|
|
18894
18953
|
return null;
|
|
18895
18954
|
}
|
|
18896
18955
|
}
|
|
18897
18956
|
function readPlanFile(worktreePath) {
|
|
18898
|
-
return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0,
|
|
18957
|
+
return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path47.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path47.join)(worktreePath, LEGACY_PLAN_FILE_REL));
|
|
18899
18958
|
}
|
|
18900
18959
|
function writePlanFile(worktreePath, content) {
|
|
18901
18960
|
ensureAttachmentsGitignore(worktreePath);
|
|
18902
18961
|
const abs = planFileAbs(worktreePath);
|
|
18903
|
-
(0,
|
|
18962
|
+
(0, import_node_fs50.mkdirSync)((0, import_node_path47.dirname)(abs), { recursive: true });
|
|
18904
18963
|
const body = content.trimEnd() + (content.endsWith("\n") ? "" : "\n");
|
|
18905
|
-
(0,
|
|
18964
|
+
(0, import_node_fs50.writeFileSync)(abs, body, "utf8");
|
|
18906
18965
|
return PLAN_FILE_REL;
|
|
18907
18966
|
}
|
|
18908
|
-
var
|
|
18967
|
+
var import_node_fs50, import_node_path47;
|
|
18909
18968
|
var init_plan_file = __esm({
|
|
18910
18969
|
"src/plan/plan-file.ts"() {
|
|
18911
18970
|
"use strict";
|
|
18912
|
-
|
|
18913
|
-
|
|
18971
|
+
import_node_fs50 = require("fs");
|
|
18972
|
+
import_node_path47 = require("path");
|
|
18914
18973
|
init_workspace_scratch();
|
|
18915
18974
|
init_plan_present();
|
|
18916
18975
|
init_plan_present();
|
|
@@ -18970,7 +19029,7 @@ function setCaffeinateHoldHooks(next) {
|
|
|
18970
19029
|
hooks = next;
|
|
18971
19030
|
}
|
|
18972
19031
|
function caffeinateHoldPath() {
|
|
18973
|
-
return (0,
|
|
19032
|
+
return (0, import_node_path48.join)(appDataDir(), "caffeinate-hold.json");
|
|
18974
19033
|
}
|
|
18975
19034
|
function processAlive(pid) {
|
|
18976
19035
|
if (hooks.processAlive) return hooks.processAlive(pid);
|
|
@@ -19004,9 +19063,9 @@ function uniqueIds(ids) {
|
|
|
19004
19063
|
}
|
|
19005
19064
|
function readHold() {
|
|
19006
19065
|
const path = caffeinateHoldPath();
|
|
19007
|
-
if (!(0,
|
|
19066
|
+
if (!(0, import_node_fs51.existsSync)(path)) return null;
|
|
19008
19067
|
try {
|
|
19009
|
-
const parsed = JSON.parse((0,
|
|
19068
|
+
const parsed = JSON.parse((0, import_node_fs51.readFileSync)(path, "utf8"));
|
|
19010
19069
|
if (typeof parsed?.pid === "number" && parsed.pid > 0) {
|
|
19011
19070
|
return {
|
|
19012
19071
|
pid: parsed.pid,
|
|
@@ -19028,7 +19087,7 @@ function writeHold(pid, threadIds) {
|
|
|
19028
19087
|
}
|
|
19029
19088
|
function clearHold() {
|
|
19030
19089
|
try {
|
|
19031
|
-
(0,
|
|
19090
|
+
(0, import_node_fs51.unlinkSync)(caffeinateHoldPath());
|
|
19032
19091
|
} catch {
|
|
19033
19092
|
}
|
|
19034
19093
|
}
|
|
@@ -19113,13 +19172,13 @@ function releaseCaffeinateHoldForThread(threadId) {
|
|
|
19113
19172
|
}
|
|
19114
19173
|
return setCaffeinateHold(false, { threadId: id });
|
|
19115
19174
|
}
|
|
19116
|
-
var import_node_child_process5,
|
|
19175
|
+
var import_node_child_process5, import_node_fs51, import_node_path48, hooks;
|
|
19117
19176
|
var init_caffeinate_hold = __esm({
|
|
19118
19177
|
"src/store/caffeinate-hold.ts"() {
|
|
19119
19178
|
"use strict";
|
|
19120
19179
|
import_node_child_process5 = require("child_process");
|
|
19121
|
-
|
|
19122
|
-
|
|
19180
|
+
import_node_fs51 = require("fs");
|
|
19181
|
+
import_node_path48 = require("path");
|
|
19123
19182
|
init_paths();
|
|
19124
19183
|
init_private_file();
|
|
19125
19184
|
hooks = {};
|
|
@@ -19128,7 +19187,7 @@ var init_caffeinate_hold = __esm({
|
|
|
19128
19187
|
|
|
19129
19188
|
// src/store/schedules.ts
|
|
19130
19189
|
function schedulesPath() {
|
|
19131
|
-
return (0,
|
|
19190
|
+
return (0, import_node_path49.join)(appDataDir(), "schedules.json");
|
|
19132
19191
|
}
|
|
19133
19192
|
function parseDurationMs(every) {
|
|
19134
19193
|
const m = every.trim().match(DURATION_RE);
|
|
@@ -19228,9 +19287,9 @@ function normalizeTask(raw) {
|
|
|
19228
19287
|
}
|
|
19229
19288
|
function readAll2() {
|
|
19230
19289
|
const path = schedulesPath();
|
|
19231
|
-
if (!(0,
|
|
19290
|
+
if (!(0, import_node_fs52.existsSync)(path)) return [];
|
|
19232
19291
|
try {
|
|
19233
|
-
const parsed = JSON.parse((0,
|
|
19292
|
+
const parsed = JSON.parse((0, import_node_fs52.readFileSync)(path, "utf8"));
|
|
19234
19293
|
if (!Array.isArray(parsed)) return [];
|
|
19235
19294
|
return parsed.map((row) => {
|
|
19236
19295
|
try {
|
|
@@ -19342,13 +19401,13 @@ function recordScheduleRun(id, result) {
|
|
|
19342
19401
|
writeAll2(rows);
|
|
19343
19402
|
return next;
|
|
19344
19403
|
}
|
|
19345
|
-
var import_node_crypto10,
|
|
19404
|
+
var import_node_crypto10, import_node_fs52, import_node_path49, import_croner, DURATION_RE, UNIT_MS;
|
|
19346
19405
|
var init_schedules = __esm({
|
|
19347
19406
|
"src/store/schedules.ts"() {
|
|
19348
19407
|
"use strict";
|
|
19349
19408
|
import_node_crypto10 = require("crypto");
|
|
19350
|
-
|
|
19351
|
-
|
|
19409
|
+
import_node_fs52 = require("fs");
|
|
19410
|
+
import_node_path49 = require("path");
|
|
19352
19411
|
import_croner = require("croner");
|
|
19353
19412
|
init_orchestrator_capable();
|
|
19354
19413
|
init_paths();
|
|
@@ -19490,13 +19549,13 @@ var init_schedule_runner = __esm({
|
|
|
19490
19549
|
|
|
19491
19550
|
// src/agents/cursor-store.ts
|
|
19492
19551
|
function cursorSdkStoreDir(threadId) {
|
|
19493
|
-
const root = (0,
|
|
19552
|
+
const root = (0, import_node_path50.join)(appDataDir(), CURSOR_SDK_STORE_DIR);
|
|
19494
19553
|
const id = sanitizeCursorStoreSegment(threadId);
|
|
19495
19554
|
if (!id) return root;
|
|
19496
|
-
return (0,
|
|
19555
|
+
return (0, import_node_path50.join)(root, "threads", id);
|
|
19497
19556
|
}
|
|
19498
19557
|
function cursorSdkRunsNdjsonPath(threadId) {
|
|
19499
|
-
return (0,
|
|
19558
|
+
return (0, import_node_path50.join)(cursorSdkStoreDir(threadId), "runs.ndjson");
|
|
19500
19559
|
}
|
|
19501
19560
|
function cursorSdkRunsNdjsonSearchPaths(threadId) {
|
|
19502
19561
|
const scoped = cursorSdkRunsNdjsonPath(threadId);
|
|
@@ -19509,11 +19568,11 @@ function cursorSdkRunsNdjsonSearchPaths(threadId) {
|
|
|
19509
19568
|
function sanitizeCursorStoreSegment(threadId) {
|
|
19510
19569
|
return (threadId ?? "").trim().replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
19511
19570
|
}
|
|
19512
|
-
var
|
|
19571
|
+
var import_node_path50, CURSOR_SDK_STORE_DIR;
|
|
19513
19572
|
var init_cursor_store = __esm({
|
|
19514
19573
|
"src/agents/cursor-store.ts"() {
|
|
19515
19574
|
"use strict";
|
|
19516
|
-
|
|
19575
|
+
import_node_path50 = require("path");
|
|
19517
19576
|
init_paths();
|
|
19518
19577
|
CURSOR_SDK_STORE_DIR = "cursor-sdk-store";
|
|
19519
19578
|
}
|
|
@@ -19535,9 +19594,9 @@ function recoverFinishedCursorRun(opts) {
|
|
|
19535
19594
|
return best;
|
|
19536
19595
|
}
|
|
19537
19596
|
function scanFinishedCursorRuns(runsPath, agentId, startedAfterMs) {
|
|
19538
|
-
if (!(0,
|
|
19597
|
+
if (!(0, import_node_fs53.existsSync)(runsPath)) return null;
|
|
19539
19598
|
try {
|
|
19540
|
-
const lines = (0,
|
|
19599
|
+
const lines = (0, import_node_fs53.readFileSync)(runsPath, "utf8").split("\n");
|
|
19541
19600
|
let best = null;
|
|
19542
19601
|
for (const line of lines) {
|
|
19543
19602
|
const trimmed = line.trim();
|
|
@@ -19563,11 +19622,11 @@ function scanFinishedCursorRuns(runsPath, agentId, startedAfterMs) {
|
|
|
19563
19622
|
return null;
|
|
19564
19623
|
}
|
|
19565
19624
|
}
|
|
19566
|
-
var
|
|
19625
|
+
var import_node_fs53;
|
|
19567
19626
|
var init_cursor_recover = __esm({
|
|
19568
19627
|
"src/agents/cursor-recover.ts"() {
|
|
19569
19628
|
"use strict";
|
|
19570
|
-
|
|
19629
|
+
import_node_fs53 = require("fs");
|
|
19571
19630
|
init_cursor_store();
|
|
19572
19631
|
}
|
|
19573
19632
|
});
|
|
@@ -19714,13 +19773,13 @@ async function startOrchestration(opts) {
|
|
|
19714
19773
|
}
|
|
19715
19774
|
return updated;
|
|
19716
19775
|
}
|
|
19717
|
-
var import_node_events,
|
|
19776
|
+
var import_node_events, import_node_fs54, LIVE_TURN_SPAWN_GRACE_MS, STALE_AGENT_PID_WAIT_MS, Orchestrator, singleton;
|
|
19718
19777
|
var init_orchestrator = __esm({
|
|
19719
19778
|
"src/orchestrator/orchestrator.ts"() {
|
|
19720
19779
|
"use strict";
|
|
19721
19780
|
import_node_events = require("events");
|
|
19722
19781
|
init_outbound_watch();
|
|
19723
|
-
|
|
19782
|
+
import_node_fs54 = require("fs");
|
|
19724
19783
|
init_error_detail();
|
|
19725
19784
|
init_run();
|
|
19726
19785
|
init_stale_lock();
|
|
@@ -19894,7 +19953,7 @@ var init_orchestrator = __esm({
|
|
|
19894
19953
|
}
|
|
19895
19954
|
continue;
|
|
19896
19955
|
}
|
|
19897
|
-
if (!(0,
|
|
19956
|
+
if (!(0, import_node_fs54.existsSync)(thread.worktreePath)) {
|
|
19898
19957
|
setStatus(thread.id, "broken", "Worktree missing on disk");
|
|
19899
19958
|
this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
|
|
19900
19959
|
continue;
|
|
@@ -21841,7 +21900,7 @@ var init_orchestrator = __esm({
|
|
|
21841
21900
|
this.emit({ type: "status_changed", threadId: restored2.id, status: restored2.status });
|
|
21842
21901
|
return restored2;
|
|
21843
21902
|
}
|
|
21844
|
-
if (!(0,
|
|
21903
|
+
if (!(0, import_node_fs54.existsSync)(thread.worktreePath)) {
|
|
21845
21904
|
if (isCowboyThread(thread) || isPrimaryCheckoutThread(thread)) {
|
|
21846
21905
|
throw new Error(
|
|
21847
21906
|
`Cowboy checkout missing: ${thread.worktreePath}. Re-add the project folder, then restore.`
|
|
@@ -21925,7 +21984,7 @@ var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
|
21925
21984
|
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
21926
21985
|
var import_zod9 = require("zod");
|
|
21927
21986
|
var import_node_crypto13 = require("crypto");
|
|
21928
|
-
var
|
|
21987
|
+
var import_node_path53 = require("path");
|
|
21929
21988
|
init_orchestrator();
|
|
21930
21989
|
init_worktree();
|
|
21931
21990
|
|
|
@@ -25328,27 +25387,27 @@ init_gh_errors();
|
|
|
25328
25387
|
init_git_auth_mode();
|
|
25329
25388
|
|
|
25330
25389
|
// src/board/load-home-board.ts
|
|
25331
|
-
var
|
|
25332
|
-
var
|
|
25390
|
+
var import_node_fs56 = require("fs");
|
|
25391
|
+
var import_node_path52 = require("path");
|
|
25333
25392
|
init_worktree();
|
|
25334
25393
|
init_paths();
|
|
25335
25394
|
|
|
25336
25395
|
// src/board/board-pins.ts
|
|
25337
25396
|
var import_node_crypto12 = require("crypto");
|
|
25338
|
-
var
|
|
25339
|
-
var
|
|
25397
|
+
var import_node_fs55 = require("fs");
|
|
25398
|
+
var import_node_path51 = require("path");
|
|
25340
25399
|
init_paths();
|
|
25341
25400
|
init_home_board();
|
|
25342
25401
|
var FILE = "home-board-pins.json";
|
|
25343
25402
|
var VERSION = 1;
|
|
25344
25403
|
function pinsFile() {
|
|
25345
|
-
return (0,
|
|
25404
|
+
return (0, import_node_path51.join)(appDataDir(), FILE);
|
|
25346
25405
|
}
|
|
25347
25406
|
function readDisk() {
|
|
25348
25407
|
const path = pinsFile();
|
|
25349
|
-
if (!(0,
|
|
25408
|
+
if (!(0, import_node_fs55.existsSync)(path)) return [];
|
|
25350
25409
|
try {
|
|
25351
|
-
const raw = JSON.parse((0,
|
|
25410
|
+
const raw = JSON.parse((0, import_node_fs55.readFileSync)(path, "utf8"));
|
|
25352
25411
|
if (raw?.version !== VERSION || !Array.isArray(raw.items)) return [];
|
|
25353
25412
|
return raw.items.filter((item) => item?.id && item.kind && item.ref);
|
|
25354
25413
|
} catch {
|
|
@@ -25356,8 +25415,8 @@ function readDisk() {
|
|
|
25356
25415
|
}
|
|
25357
25416
|
}
|
|
25358
25417
|
function writeDisk(items) {
|
|
25359
|
-
(0,
|
|
25360
|
-
(0,
|
|
25418
|
+
(0, import_node_fs55.mkdirSync)(appDataDir(), { recursive: true });
|
|
25419
|
+
(0, import_node_fs55.writeFileSync)(pinsFile(), JSON.stringify({ version: VERSION, items }, null, 2), "utf8");
|
|
25361
25420
|
}
|
|
25362
25421
|
function listBoardPins() {
|
|
25363
25422
|
return readDisk();
|
|
@@ -25378,7 +25437,7 @@ function homeBoardWorkspaceKey(workspaces) {
|
|
|
25378
25437
|
return workspaces.map((w) => w.path).filter(Boolean).sort().join("\n");
|
|
25379
25438
|
}
|
|
25380
25439
|
function cacheFile() {
|
|
25381
|
-
return (0,
|
|
25440
|
+
return (0, import_node_path52.join)(appDataDir(), "home-board-cache.json");
|
|
25382
25441
|
}
|
|
25383
25442
|
function emptyInputs() {
|
|
25384
25443
|
return {
|
|
@@ -25404,9 +25463,9 @@ function shouldCacheHomeBoardInputs(inputs) {
|
|
|
25404
25463
|
}
|
|
25405
25464
|
function readDiskCache() {
|
|
25406
25465
|
const path = cacheFile();
|
|
25407
|
-
if (!(0,
|
|
25466
|
+
if (!(0, import_node_fs56.existsSync)(path)) return null;
|
|
25408
25467
|
try {
|
|
25409
|
-
const raw = JSON.parse((0,
|
|
25468
|
+
const raw = JSON.parse((0, import_node_fs56.readFileSync)(path, "utf8"));
|
|
25410
25469
|
if (raw?.version !== CACHE_VERSION || typeof raw.fetchedAt !== "number") {
|
|
25411
25470
|
return null;
|
|
25412
25471
|
}
|
|
@@ -25420,8 +25479,8 @@ function readDiskCache() {
|
|
|
25420
25479
|
}
|
|
25421
25480
|
function writeDiskCache(entry) {
|
|
25422
25481
|
try {
|
|
25423
|
-
(0,
|
|
25424
|
-
(0,
|
|
25482
|
+
(0, import_node_fs56.mkdirSync)(appDataDir(), { recursive: true });
|
|
25483
|
+
(0, import_node_fs56.writeFileSync)(cacheFile(), JSON.stringify(entry), "utf8");
|
|
25425
25484
|
} catch {
|
|
25426
25485
|
}
|
|
25427
25486
|
}
|
|
@@ -25808,7 +25867,7 @@ async function startMcpServer() {
|
|
|
25808
25867
|
async () => {
|
|
25809
25868
|
const threads = orch.getThreads(true);
|
|
25810
25869
|
const lines = threads.map((t) => {
|
|
25811
|
-
const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0,
|
|
25870
|
+
const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0, import_node_path53.basename)(t.repoPath) || t.repoPath;
|
|
25812
25871
|
const live = orch.threadLooksLive(t) ? readTurnLive(t.id) : null;
|
|
25813
25872
|
const parent = t.parentThreadId ? ` parent:${t.parentThreadId.slice(0, 8)}` : "";
|
|
25814
25873
|
const preview = lastMessagePreview(t.messages, 80);
|