@sideboard-ai/core 0.1.98 → 0.1.99
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/agents/cursor-runner.cjs +47 -2
- package/dist/agents/cursor-runner.js +47 -2
- package/dist/index.cjs +448 -372
- package/dist/index.d.cts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +165 -98
- package/dist/mcp/run-stdio.cjs +193 -142
- package/dist/mcp/run-stdio.js +113 -63
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3072,23 +3072,23 @@ var init_gh_errors = __esm({
|
|
|
3072
3072
|
function githubAgentAuthDir() {
|
|
3073
3073
|
const override = process.env.SIDEBOARD_GIT_AUTH_DIR?.trim();
|
|
3074
3074
|
if (override) return override;
|
|
3075
|
-
return (0,
|
|
3075
|
+
return (0, import_node_path11.join)((0, import_node_os4.homedir)(), ".sideboard-git-auth");
|
|
3076
3076
|
}
|
|
3077
3077
|
function githubCredentialStorePath() {
|
|
3078
|
-
return (0,
|
|
3078
|
+
return (0, import_node_path11.join)(githubAgentAuthDir(), "git-credentials");
|
|
3079
3079
|
}
|
|
3080
3080
|
function githubGhConfigDir() {
|
|
3081
|
-
return (0,
|
|
3081
|
+
return (0, import_node_path11.join)(githubAgentAuthDir(), "gh");
|
|
3082
3082
|
}
|
|
3083
3083
|
function writePrivateFile2(file, body) {
|
|
3084
|
-
(0,
|
|
3084
|
+
(0, import_node_fs11.mkdirSync)((0, import_node_path11.dirname)(file), { recursive: true, mode: 448 });
|
|
3085
3085
|
try {
|
|
3086
|
-
(0,
|
|
3086
|
+
(0, import_node_fs11.chmodSync)((0, import_node_path11.dirname)(file), 448);
|
|
3087
3087
|
} catch {
|
|
3088
3088
|
}
|
|
3089
|
-
(0,
|
|
3089
|
+
(0, import_node_fs11.writeFileSync)(file, body, { encoding: "utf8", mode: 384 });
|
|
3090
3090
|
try {
|
|
3091
|
-
(0,
|
|
3091
|
+
(0, import_node_fs11.chmodSync)(file, 384);
|
|
3092
3092
|
} catch {
|
|
3093
3093
|
}
|
|
3094
3094
|
}
|
|
@@ -3113,19 +3113,19 @@ function materializeGithubAgentAuth(token, user) {
|
|
|
3113
3113
|
const trimmed = token.trim();
|
|
3114
3114
|
if (!trimmed) return;
|
|
3115
3115
|
const root = githubAgentAuthDir();
|
|
3116
|
-
(0,
|
|
3116
|
+
(0, import_node_fs11.mkdirSync)(root, { recursive: true, mode: 448 });
|
|
3117
3117
|
try {
|
|
3118
|
-
(0,
|
|
3118
|
+
(0, import_node_fs11.chmodSync)(root, 448);
|
|
3119
3119
|
} catch {
|
|
3120
3120
|
}
|
|
3121
3121
|
writePrivateFile2(githubCredentialStorePath(), gitCredentialStoreContents(trimmed));
|
|
3122
3122
|
const ghDir = githubGhConfigDir();
|
|
3123
|
-
(0,
|
|
3124
|
-
writePrivateFile2((0,
|
|
3125
|
-
writePrivateFile2((0,
|
|
3123
|
+
(0, import_node_fs11.mkdirSync)(ghDir, { recursive: true, mode: 448 });
|
|
3124
|
+
writePrivateFile2((0, import_node_path11.join)(ghDir, "hosts.yml"), ghHostsYml(trimmed, user));
|
|
3125
|
+
writePrivateFile2((0, import_node_path11.join)(ghDir, "config.yml"), "git_protocol: https\nprompt: disabled\n");
|
|
3126
3126
|
}
|
|
3127
3127
|
function githubAgentAuthReady() {
|
|
3128
|
-
return (0,
|
|
3128
|
+
return (0, import_node_fs11.existsSync)(githubCredentialStorePath()) && (0, import_node_fs11.existsSync)((0, import_node_path11.join)(githubGhConfigDir(), "hosts.yml"));
|
|
3129
3129
|
}
|
|
3130
3130
|
function githubCredentialHelperGitConfig() {
|
|
3131
3131
|
const file = githubCredentialStorePath();
|
|
@@ -3140,29 +3140,29 @@ function githubGhConfigEnv() {
|
|
|
3140
3140
|
GH_PROMPT_DISABLED: "1"
|
|
3141
3141
|
};
|
|
3142
3142
|
}
|
|
3143
|
-
var
|
|
3143
|
+
var import_node_fs11, import_node_os4, import_node_path11;
|
|
3144
3144
|
var init_github_agent_auth = __esm({
|
|
3145
3145
|
"src/git/github-agent-auth.ts"() {
|
|
3146
3146
|
"use strict";
|
|
3147
|
-
|
|
3147
|
+
import_node_fs11 = require("fs");
|
|
3148
3148
|
import_node_os4 = require("os");
|
|
3149
|
-
|
|
3149
|
+
import_node_path11 = require("path");
|
|
3150
3150
|
}
|
|
3151
3151
|
});
|
|
3152
3152
|
|
|
3153
3153
|
// src/agents/path.ts
|
|
3154
3154
|
function prependPathDir(env, dir) {
|
|
3155
|
-
if (!dir || !(0,
|
|
3155
|
+
if (!dir || !(0, import_node_fs12.existsSync)(dir)) return;
|
|
3156
3156
|
const current = env.PATH ?? "";
|
|
3157
|
-
const parts = current.split(
|
|
3157
|
+
const parts = current.split(import_node_path12.delimiter).filter(Boolean);
|
|
3158
3158
|
if (parts.includes(dir)) {
|
|
3159
3159
|
env.PATH = current;
|
|
3160
3160
|
return;
|
|
3161
3161
|
}
|
|
3162
|
-
env.PATH = [dir, ...parts].join(
|
|
3162
|
+
env.PATH = [dir, ...parts].join(import_node_path12.delimiter);
|
|
3163
3163
|
}
|
|
3164
3164
|
function conductorBundledBinDir(home = process.env.HOME || process.env.USERPROFILE || (0, import_node_os5.homedir)()) {
|
|
3165
|
-
return (0,
|
|
3165
|
+
return (0, import_node_path12.join)(home, "Library", "Application Support", "com.conductor.app", "bin");
|
|
3166
3166
|
}
|
|
3167
3167
|
function isConductorBundledCli(filePath) {
|
|
3168
3168
|
const p = (filePath ?? "").replace(/\\/g, "/");
|
|
@@ -3171,21 +3171,21 @@ function isConductorBundledCli(filePath) {
|
|
|
3171
3171
|
function ensureAgentPath(env = process.env) {
|
|
3172
3172
|
const home = env.HOME || env.USERPROFILE || (0, import_node_os5.homedir)();
|
|
3173
3173
|
const current = env.PATH ?? "";
|
|
3174
|
-
const parts = current.split(
|
|
3174
|
+
const parts = current.split(import_node_path12.delimiter).filter(Boolean);
|
|
3175
3175
|
const seen = new Set(parts);
|
|
3176
3176
|
const extras = [
|
|
3177
|
-
...EXTRA_BIN_DIRS.map((rel) => (0,
|
|
3177
|
+
...EXTRA_BIN_DIRS.map((rel) => (0, import_node_path12.join)(home, rel)),
|
|
3178
3178
|
"/opt/homebrew/bin",
|
|
3179
3179
|
"/usr/local/bin",
|
|
3180
3180
|
// Keep after Homebrew/npm so a user-installed CLI still wins.
|
|
3181
3181
|
conductorBundledBinDir(home)
|
|
3182
3182
|
];
|
|
3183
3183
|
for (const dir of extras.reverse()) {
|
|
3184
|
-
if (!dir || seen.has(dir) || !(0,
|
|
3184
|
+
if (!dir || seen.has(dir) || !(0, import_node_fs12.existsSync)(dir)) continue;
|
|
3185
3185
|
parts.unshift(dir);
|
|
3186
3186
|
seen.add(dir);
|
|
3187
3187
|
}
|
|
3188
|
-
const next = parts.join(
|
|
3188
|
+
const next = parts.join(import_node_path12.delimiter);
|
|
3189
3189
|
env.PATH = next;
|
|
3190
3190
|
return next;
|
|
3191
3191
|
}
|
|
@@ -3199,7 +3199,7 @@ function enrichPathWithNpmGlobalBin(env = process.env) {
|
|
|
3199
3199
|
stdio: ["ignore", "pipe", "ignore"]
|
|
3200
3200
|
}).trim().split(/\r?\n/).find(Boolean);
|
|
3201
3201
|
if (prefix) {
|
|
3202
|
-
const binDir = process.platform === "win32" ? prefix : (0,
|
|
3202
|
+
const binDir = process.platform === "win32" ? prefix : (0, import_node_path12.join)(prefix, "bin");
|
|
3203
3203
|
prependPathDir(env, binDir);
|
|
3204
3204
|
}
|
|
3205
3205
|
} catch {
|
|
@@ -3227,14 +3227,14 @@ function withExportedPath(command, pathValue) {
|
|
|
3227
3227
|
if (/^(export\s+PATH=|PATH=)/.test(trimmed)) return trimmed;
|
|
3228
3228
|
return `export PATH=${posixShellSingleQuote(pathValue)} && ${trimmed}`;
|
|
3229
3229
|
}
|
|
3230
|
-
var
|
|
3230
|
+
var import_node_fs12, import_node_child_process3, import_node_os5, import_node_path12, EXTRA_BIN_DIRS;
|
|
3231
3231
|
var init_path = __esm({
|
|
3232
3232
|
"src/agents/path.ts"() {
|
|
3233
3233
|
"use strict";
|
|
3234
|
-
|
|
3234
|
+
import_node_fs12 = require("fs");
|
|
3235
3235
|
import_node_child_process3 = require("child_process");
|
|
3236
3236
|
import_node_os5 = require("os");
|
|
3237
|
-
|
|
3237
|
+
import_node_path12 = require("path");
|
|
3238
3238
|
EXTRA_BIN_DIRS = [
|
|
3239
3239
|
".local/bin",
|
|
3240
3240
|
".cargo/bin",
|
|
@@ -3426,7 +3426,7 @@ async function warmGithubAgentAuth(opts) {
|
|
|
3426
3426
|
}
|
|
3427
3427
|
function normalizeWritableRoot(raw) {
|
|
3428
3428
|
const trimmed = raw.trim().replace(/\/+$/, "");
|
|
3429
|
-
return trimmed && (0,
|
|
3429
|
+
return trimmed && (0, import_node_path13.isAbsolute)(trimmed) ? trimmed : null;
|
|
3430
3430
|
}
|
|
3431
3431
|
async function resolveCodexGitWritableRoots(cwd) {
|
|
3432
3432
|
const roots = /* @__PURE__ */ new Set();
|
|
@@ -3503,11 +3503,11 @@ function formatGitAuthModeDirective(mode) {
|
|
|
3503
3503
|
].join("\n");
|
|
3504
3504
|
}
|
|
3505
3505
|
}
|
|
3506
|
-
var
|
|
3506
|
+
var import_node_path13, HTTPS_REWRITE, TOKEN_TTL_MS, tokenMemo, GITHUB_CHILD_TOKEN_KEYS;
|
|
3507
3507
|
var init_git_auth_mode = __esm({
|
|
3508
3508
|
"src/git/git-auth-mode.ts"() {
|
|
3509
3509
|
"use strict";
|
|
3510
|
-
|
|
3510
|
+
import_node_path13 = require("path");
|
|
3511
3511
|
init_app_settings();
|
|
3512
3512
|
init_github_agent_auth();
|
|
3513
3513
|
init_run();
|
|
@@ -4669,8 +4669,8 @@ function isLocalPrFetchBranch(ref) {
|
|
|
4669
4669
|
}
|
|
4670
4670
|
async function createThreadWorktree(opts) {
|
|
4671
4671
|
let branchName = `thread/${opts.slug}`;
|
|
4672
|
-
const worktreePath = (0,
|
|
4673
|
-
if ((0,
|
|
4672
|
+
const worktreePath = (0, import_node_path14.join)(worktreesRoot(opts.repoPath), opts.slug);
|
|
4673
|
+
if ((0, import_node_fs13.existsSync)(worktreePath)) {
|
|
4674
4674
|
throw new Error(`Worktree already exists at ${worktreePath}`);
|
|
4675
4675
|
}
|
|
4676
4676
|
await ensureGhPreferOrigin(opts.repoPath);
|
|
@@ -4739,8 +4739,8 @@ ${add.stdout}`;
|
|
|
4739
4739
|
async function createExistingBranchWorktree(opts) {
|
|
4740
4740
|
const branchName = opts.branchName.trim();
|
|
4741
4741
|
if (!branchName) throw new Error("branch name required");
|
|
4742
|
-
const worktreePath = (0,
|
|
4743
|
-
if ((0,
|
|
4742
|
+
const worktreePath = (0, import_node_path14.join)(worktreesRoot(opts.repoPath), opts.slug);
|
|
4743
|
+
if ((0, import_node_fs13.existsSync)(worktreePath)) {
|
|
4744
4744
|
throw new Error(`Worktree already exists at ${worktreePath}`);
|
|
4745
4745
|
}
|
|
4746
4746
|
await ensureGhPreferOrigin(opts.repoPath);
|
|
@@ -5028,10 +5028,10 @@ function sameRepoPath(a, b) {
|
|
|
5028
5028
|
return normalizeWorktreePath(a) === normalizeWorktreePath(b);
|
|
5029
5029
|
}
|
|
5030
5030
|
function listLocalThreadBranchSlugs(repoPath) {
|
|
5031
|
-
const refsDir = (0,
|
|
5032
|
-
if (!(0,
|
|
5031
|
+
const refsDir = (0, import_node_path14.join)(repoPath, ".git", "refs", "heads", "thread");
|
|
5032
|
+
if (!(0, import_node_fs13.existsSync)(refsDir)) return [];
|
|
5033
5033
|
try {
|
|
5034
|
-
return (0,
|
|
5034
|
+
return (0, import_node_fs13.readdirSync)(refsDir).filter((name) => !name.startsWith(".")).map((name) => normalizeTakenSlug(name));
|
|
5035
5035
|
} catch {
|
|
5036
5036
|
return [];
|
|
5037
5037
|
}
|
|
@@ -5039,8 +5039,8 @@ function listLocalThreadBranchSlugs(repoPath) {
|
|
|
5039
5039
|
function collectTakenTeamSlugs(repoPath) {
|
|
5040
5040
|
const taken = /* @__PURE__ */ new Set();
|
|
5041
5041
|
const root = worktreesRoot(repoPath);
|
|
5042
|
-
if ((0,
|
|
5043
|
-
for (const entry of (0,
|
|
5042
|
+
if ((0, import_node_fs13.existsSync)(root)) {
|
|
5043
|
+
for (const entry of (0, import_node_fs13.readdirSync)(root, { withFileTypes: true })) {
|
|
5044
5044
|
if (entry.isDirectory() && entry.name !== ".DS_Store") {
|
|
5045
5045
|
taken.add(normalizeTakenSlug(entry.name));
|
|
5046
5046
|
}
|
|
@@ -5061,18 +5061,18 @@ function allocateTeamSlug(repoPath) {
|
|
|
5061
5061
|
const taken = collectTakenTeamSlugs(repoPath);
|
|
5062
5062
|
for (let attempt = 0; attempt < 32; attempt++) {
|
|
5063
5063
|
const team = allocateTeamName(taken);
|
|
5064
|
-
const path2 = (0,
|
|
5065
|
-
if (!(0,
|
|
5064
|
+
const path2 = (0, import_node_path14.join)(worktreesRoot(repoPath), team.slug);
|
|
5065
|
+
if (!(0, import_node_fs13.existsSync)(path2)) return team;
|
|
5066
5066
|
taken.add(team.slug);
|
|
5067
5067
|
}
|
|
5068
5068
|
throw new Error("No available soccer team worktree directories left");
|
|
5069
5069
|
}
|
|
5070
|
-
var
|
|
5070
|
+
var import_node_fs13, import_node_path14;
|
|
5071
5071
|
var init_worktree = __esm({
|
|
5072
5072
|
"src/git/worktree.ts"() {
|
|
5073
5073
|
"use strict";
|
|
5074
|
-
|
|
5075
|
-
|
|
5074
|
+
import_node_fs13 = require("fs");
|
|
5075
|
+
import_node_path14 = require("path");
|
|
5076
5076
|
init_paths();
|
|
5077
5077
|
init_thread_store();
|
|
5078
5078
|
init_teams();
|
|
@@ -5156,7 +5156,7 @@ function coordinatorTurnReminder(opts) {
|
|
|
5156
5156
|
function ensureGlobalCoordinatorCwd(opts) {
|
|
5157
5157
|
const dir = globalAgentCwd();
|
|
5158
5158
|
try {
|
|
5159
|
-
(0,
|
|
5159
|
+
(0, import_node_fs14.mkdirSync)(dir, { recursive: true });
|
|
5160
5160
|
} catch {
|
|
5161
5161
|
return dir;
|
|
5162
5162
|
}
|
|
@@ -5164,7 +5164,7 @@ function ensureGlobalCoordinatorCwd(opts) {
|
|
|
5164
5164
|
let orchId = opts?.orchestratorThreadId?.trim() || "";
|
|
5165
5165
|
if (!orchId) {
|
|
5166
5166
|
try {
|
|
5167
|
-
const existing = (0,
|
|
5167
|
+
const existing = (0, import_node_fs14.readFileSync)((0, import_node_path15.join)(dir, "AGENTS.md"), "utf8");
|
|
5168
5168
|
const m = existing.match(
|
|
5169
5169
|
/YOUR orchestration thread id is `([0-9a-f-]{36})`/i
|
|
5170
5170
|
);
|
|
@@ -5206,9 +5206,9 @@ function ensureGlobalCoordinatorCwd(opts) {
|
|
|
5206
5206
|
"Always ask worktree agents to commit, push, and open draft PRs (`ask_git` / `send_to_thread`). Tell them to merge only when the user explicitly asked. The worktree agent runs git/gh; never merge from this orchestration cwd."
|
|
5207
5207
|
].join("\n");
|
|
5208
5208
|
try {
|
|
5209
|
-
(0,
|
|
5209
|
+
(0, import_node_fs14.writeFileSync)((0, import_node_path15.join)(dir, "CLAUDE.md"), `${body}
|
|
5210
5210
|
`, "utf8");
|
|
5211
|
-
(0,
|
|
5211
|
+
(0, import_node_fs14.writeFileSync)((0, import_node_path15.join)(dir, "AGENTS.md"), `${body}
|
|
5212
5212
|
`, "utf8");
|
|
5213
5213
|
} catch {
|
|
5214
5214
|
}
|
|
@@ -5240,12 +5240,12 @@ function coordinatorSystemPrompt(opts) {
|
|
|
5240
5240
|
formatWorkspaceInventory(opts.workspaces)
|
|
5241
5241
|
].join("\n");
|
|
5242
5242
|
}
|
|
5243
|
-
var
|
|
5243
|
+
var import_node_fs14, import_node_path15, COORDINATOR_TOOL_PLAYBOOK, SLACK_REPLY_FORMATTING;
|
|
5244
5244
|
var init_coordinator_prompt = __esm({
|
|
5245
5245
|
"src/orchestrator/coordinator-prompt.ts"() {
|
|
5246
5246
|
"use strict";
|
|
5247
|
-
|
|
5248
|
-
|
|
5247
|
+
import_node_fs14 = require("fs");
|
|
5248
|
+
import_node_path15 = require("path");
|
|
5249
5249
|
init_worktree();
|
|
5250
5250
|
init_app_settings();
|
|
5251
5251
|
init_paths();
|
|
@@ -5550,38 +5550,38 @@ __export(workspaces_exports, {
|
|
|
5550
5550
|
syncWorkspacesFromThreads: () => syncWorkspacesFromThreads
|
|
5551
5551
|
});
|
|
5552
5552
|
function workspacesFile() {
|
|
5553
|
-
return (0,
|
|
5553
|
+
return (0, import_node_path16.join)(appDataDir(), "workspaces.json");
|
|
5554
5554
|
}
|
|
5555
5555
|
function removedWorkspacesFile() {
|
|
5556
|
-
return (0,
|
|
5556
|
+
return (0, import_node_path16.join)(appDataDir(), "removed-workspaces.json");
|
|
5557
5557
|
}
|
|
5558
5558
|
function readAll() {
|
|
5559
5559
|
const path2 = workspacesFile();
|
|
5560
|
-
if (!(0,
|
|
5560
|
+
if (!(0, import_node_fs15.existsSync)(path2)) return [];
|
|
5561
5561
|
try {
|
|
5562
|
-
const raw = JSON.parse((0,
|
|
5562
|
+
const raw = JSON.parse((0, import_node_fs15.readFileSync)(path2, "utf8"));
|
|
5563
5563
|
return Array.isArray(raw) ? raw : [];
|
|
5564
5564
|
} catch {
|
|
5565
5565
|
return [];
|
|
5566
5566
|
}
|
|
5567
5567
|
}
|
|
5568
5568
|
function writeAll(list) {
|
|
5569
|
-
(0,
|
|
5570
|
-
(0,
|
|
5569
|
+
(0, import_node_fs15.mkdirSync)(appDataDir(), { recursive: true });
|
|
5570
|
+
(0, import_node_fs15.writeFileSync)(workspacesFile(), JSON.stringify(list, null, 2), "utf8");
|
|
5571
5571
|
}
|
|
5572
5572
|
function readRemoved() {
|
|
5573
5573
|
const path2 = removedWorkspacesFile();
|
|
5574
|
-
if (!(0,
|
|
5574
|
+
if (!(0, import_node_fs15.existsSync)(path2)) return /* @__PURE__ */ new Set();
|
|
5575
5575
|
try {
|
|
5576
|
-
const raw = JSON.parse((0,
|
|
5576
|
+
const raw = JSON.parse((0, import_node_fs15.readFileSync)(path2, "utf8"));
|
|
5577
5577
|
return new Set(Array.isArray(raw) ? raw.filter((p) => typeof p === "string") : []);
|
|
5578
5578
|
} catch {
|
|
5579
5579
|
return /* @__PURE__ */ new Set();
|
|
5580
5580
|
}
|
|
5581
5581
|
}
|
|
5582
5582
|
function writeRemoved(paths) {
|
|
5583
|
-
(0,
|
|
5584
|
-
(0,
|
|
5583
|
+
(0, import_node_fs15.mkdirSync)(appDataDir(), { recursive: true });
|
|
5584
|
+
(0, import_node_fs15.writeFileSync)(removedWorkspacesFile(), JSON.stringify([...paths].sort(), null, 2), "utf8");
|
|
5585
5585
|
}
|
|
5586
5586
|
function rememberRemoved(repoPath) {
|
|
5587
5587
|
const next = readRemoved();
|
|
@@ -5604,7 +5604,7 @@ function listWorkspaces() {
|
|
|
5604
5604
|
async function addWorkspace(repoPath) {
|
|
5605
5605
|
const root = await resolveRepoRoot(repoPath);
|
|
5606
5606
|
if (!root || root === "/") throw new Error(`Invalid repo path: ${repoPath}`);
|
|
5607
|
-
if (!(0,
|
|
5607
|
+
if (!(0, import_node_fs15.existsSync)(root)) throw new Error(`Repo not found: ${root}`);
|
|
5608
5608
|
forgetRemoved(root);
|
|
5609
5609
|
await ensureGhPreferOrigin(root);
|
|
5610
5610
|
const current = readAll();
|
|
@@ -5612,7 +5612,7 @@ async function addWorkspace(repoPath) {
|
|
|
5612
5612
|
if (existing) return existing;
|
|
5613
5613
|
const next = {
|
|
5614
5614
|
path: root,
|
|
5615
|
-
name: (0,
|
|
5615
|
+
name: (0, import_node_path16.basename)(root),
|
|
5616
5616
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5617
5617
|
};
|
|
5618
5618
|
writeAll([...current, next]);
|
|
@@ -5634,10 +5634,10 @@ function syncWorkspacesFromThreads(repoPaths) {
|
|
|
5634
5634
|
if (!path2 || path2 === "/" || isGlobalRepoPath(path2) || byPath.has(path2) || removed.has(path2)) {
|
|
5635
5635
|
continue;
|
|
5636
5636
|
}
|
|
5637
|
-
if (!(0,
|
|
5637
|
+
if (!(0, import_node_fs15.existsSync)(path2)) continue;
|
|
5638
5638
|
const ws = {
|
|
5639
5639
|
path: path2,
|
|
5640
|
-
name: (0,
|
|
5640
|
+
name: (0, import_node_path16.basename)(path2),
|
|
5641
5641
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5642
5642
|
};
|
|
5643
5643
|
byPath.set(path2, ws);
|
|
@@ -5647,12 +5647,12 @@ function syncWorkspacesFromThreads(repoPaths) {
|
|
|
5647
5647
|
if (dirty) writeAll(next);
|
|
5648
5648
|
return next.sort((a, b) => a.name.localeCompare(b.name));
|
|
5649
5649
|
}
|
|
5650
|
-
var
|
|
5650
|
+
var import_node_fs15, import_node_path16;
|
|
5651
5651
|
var init_workspaces = __esm({
|
|
5652
5652
|
"src/store/workspaces.ts"() {
|
|
5653
5653
|
"use strict";
|
|
5654
|
-
|
|
5655
|
-
|
|
5654
|
+
import_node_fs15 = require("fs");
|
|
5655
|
+
import_node_path16 = require("path");
|
|
5656
5656
|
init_paths();
|
|
5657
5657
|
init_global_workspace();
|
|
5658
5658
|
init_worktree();
|
|
@@ -5661,32 +5661,32 @@ var init_workspaces = __esm({
|
|
|
5661
5661
|
|
|
5662
5662
|
// src/brightsy/config.ts
|
|
5663
5663
|
function brightsyConfigPath() {
|
|
5664
|
-
return (0,
|
|
5664
|
+
return (0, import_node_path17.join)((0, import_node_os6.homedir)(), ".brightsy", "config.json");
|
|
5665
5665
|
}
|
|
5666
5666
|
function loadBrightsyConfig() {
|
|
5667
5667
|
const path2 = brightsyConfigPath();
|
|
5668
|
-
if (!(0,
|
|
5668
|
+
if (!(0, import_node_fs16.existsSync)(path2)) {
|
|
5669
5669
|
throw new Error("Brightsy not logged in \u2014 run `brightsy login` first");
|
|
5670
5670
|
}
|
|
5671
|
-
const raw = JSON.parse((0,
|
|
5671
|
+
const raw = JSON.parse((0, import_node_fs16.readFileSync)(path2, "utf8"));
|
|
5672
5672
|
if (!raw.access_token || !raw.account_id) {
|
|
5673
5673
|
throw new Error("Brightsy config incomplete \u2014 run `brightsy login`");
|
|
5674
5674
|
}
|
|
5675
5675
|
return raw;
|
|
5676
5676
|
}
|
|
5677
5677
|
function saveBrightsyConfig(cfg) {
|
|
5678
|
-
(0,
|
|
5678
|
+
(0, import_node_fs16.writeFileSync)(brightsyConfigPath(), `${JSON.stringify(cfg, null, 2)}
|
|
5679
5679
|
`, {
|
|
5680
5680
|
mode: 384
|
|
5681
5681
|
});
|
|
5682
5682
|
}
|
|
5683
|
-
var
|
|
5683
|
+
var import_node_fs16, import_node_os6, import_node_path17;
|
|
5684
5684
|
var init_config = __esm({
|
|
5685
5685
|
"src/brightsy/config.ts"() {
|
|
5686
5686
|
"use strict";
|
|
5687
|
-
|
|
5687
|
+
import_node_fs16 = require("fs");
|
|
5688
5688
|
import_node_os6 = require("os");
|
|
5689
|
-
|
|
5689
|
+
import_node_path17 = require("path");
|
|
5690
5690
|
}
|
|
5691
5691
|
});
|
|
5692
5692
|
|
|
@@ -5789,22 +5789,22 @@ __export(connected_teams_exports, {
|
|
|
5789
5789
|
listConnectedBrightsyTeams: () => listConnectedBrightsyTeams
|
|
5790
5790
|
});
|
|
5791
5791
|
function storePath() {
|
|
5792
|
-
return (0,
|
|
5792
|
+
return (0, import_node_path18.join)(appDataDir(), "brightsy-teams.json");
|
|
5793
5793
|
}
|
|
5794
5794
|
function readStore() {
|
|
5795
5795
|
const path2 = storePath();
|
|
5796
|
-
if (!(0,
|
|
5796
|
+
if (!(0, import_node_fs17.existsSync)(path2)) return [];
|
|
5797
5797
|
try {
|
|
5798
|
-
const parsed = JSON.parse((0,
|
|
5798
|
+
const parsed = JSON.parse((0, import_node_fs17.readFileSync)(path2, "utf8"));
|
|
5799
5799
|
return Array.isArray(parsed.teams) ? parsed.teams : [];
|
|
5800
5800
|
} catch {
|
|
5801
5801
|
return [];
|
|
5802
5802
|
}
|
|
5803
5803
|
}
|
|
5804
5804
|
function writeStore(teams) {
|
|
5805
|
-
(0,
|
|
5805
|
+
(0, import_node_fs17.mkdirSync)(appDataDir(), { recursive: true });
|
|
5806
5806
|
const path2 = storePath();
|
|
5807
|
-
(0,
|
|
5807
|
+
(0, import_node_fs17.writeFileSync)(path2, `${JSON.stringify({ teams }, null, 2)}
|
|
5808
5808
|
`, {
|
|
5809
5809
|
mode: 384
|
|
5810
5810
|
});
|
|
@@ -5966,12 +5966,12 @@ function brightsyMcpServerName(slug) {
|
|
|
5966
5966
|
const cleaned = slug.replace(/[^A-Za-z0-9_-]/g, "_").replace(/^_+|_+$/g, "");
|
|
5967
5967
|
return `brightsy_${cleaned || "team"}`;
|
|
5968
5968
|
}
|
|
5969
|
-
var
|
|
5969
|
+
var import_node_fs17, import_node_path18;
|
|
5970
5970
|
var init_connected_teams = __esm({
|
|
5971
5971
|
"src/brightsy/connected-teams.ts"() {
|
|
5972
5972
|
"use strict";
|
|
5973
|
-
|
|
5974
|
-
|
|
5973
|
+
import_node_fs17 = require("fs");
|
|
5974
|
+
import_node_path18 = require("path");
|
|
5975
5975
|
init_paths();
|
|
5976
5976
|
init_accounts();
|
|
5977
5977
|
init_config();
|
|
@@ -6521,11 +6521,11 @@ async function syncCliForTarget(accountId) {
|
|
|
6521
6521
|
}
|
|
6522
6522
|
applyConnectedTeamToCli(team);
|
|
6523
6523
|
}
|
|
6524
|
-
var
|
|
6524
|
+
var import_node_fs18, brightsyAdapter;
|
|
6525
6525
|
var init_brightsy = __esm({
|
|
6526
6526
|
"src/agents/brightsy.ts"() {
|
|
6527
6527
|
"use strict";
|
|
6528
|
-
|
|
6528
|
+
import_node_fs18 = require("fs");
|
|
6529
6529
|
init_run();
|
|
6530
6530
|
init_connected_teams();
|
|
6531
6531
|
init_config();
|
|
@@ -6540,7 +6540,7 @@ var init_brightsy = __esm({
|
|
|
6540
6540
|
async detect() {
|
|
6541
6541
|
const brightsy = resolveAgentExecutable("brightsy");
|
|
6542
6542
|
if (brightsy !== "brightsy") {
|
|
6543
|
-
if (!(0,
|
|
6543
|
+
if (!(0, import_node_fs18.existsSync)(brightsy)) {
|
|
6544
6544
|
return {
|
|
6545
6545
|
agent: "brightsy",
|
|
6546
6546
|
installed: false,
|
|
@@ -6682,7 +6682,7 @@ function unpackedAsarPath(filePath) {
|
|
|
6682
6682
|
if (!isAsarPath(filePath)) return null;
|
|
6683
6683
|
const unpacked = filePath.replace(/\.asar(?=[/\\])/, ".asar.unpacked");
|
|
6684
6684
|
if (unpacked === filePath) return null;
|
|
6685
|
-
return (0,
|
|
6685
|
+
return (0, import_node_fs19.existsSync)(unpacked) ? unpacked : null;
|
|
6686
6686
|
}
|
|
6687
6687
|
function nodeReadableScriptPath(scriptPath) {
|
|
6688
6688
|
return unpackedAsarPath(scriptPath) ?? scriptPath;
|
|
@@ -6693,11 +6693,11 @@ async function findSystemNode() {
|
|
|
6693
6693
|
if (fromWhich && !isElectronLikeCommand(fromWhich)) return fromWhich;
|
|
6694
6694
|
const fallbacks = [
|
|
6695
6695
|
...WELL_KNOWN_NODE_BINS,
|
|
6696
|
-
(0,
|
|
6697
|
-
(0,
|
|
6696
|
+
(0, import_node_path19.join)((0, import_node_os7.homedir)(), ".local/share/fnm/aliases/default/bin/node"),
|
|
6697
|
+
(0, import_node_path19.join)((0, import_node_os7.homedir)(), ".nvm/current/bin/node")
|
|
6698
6698
|
];
|
|
6699
6699
|
for (const bin of fallbacks) {
|
|
6700
|
-
if ((0,
|
|
6700
|
+
if ((0, import_node_fs19.existsSync)(bin) && !isElectronLikeCommand(bin)) return bin;
|
|
6701
6701
|
}
|
|
6702
6702
|
return null;
|
|
6703
6703
|
}
|
|
@@ -6727,13 +6727,13 @@ async function resolveNodeLaunch(scriptPath) {
|
|
|
6727
6727
|
env: { ELECTRON_RUN_AS_NODE: "1" }
|
|
6728
6728
|
};
|
|
6729
6729
|
}
|
|
6730
|
-
var
|
|
6730
|
+
var import_node_fs19, import_node_os7, import_node_path19, WELL_KNOWN_NODE_BINS;
|
|
6731
6731
|
var init_node_launch = __esm({
|
|
6732
6732
|
"src/agents/node-launch.ts"() {
|
|
6733
6733
|
"use strict";
|
|
6734
|
-
|
|
6734
|
+
import_node_fs19 = require("fs");
|
|
6735
6735
|
import_node_os7 = require("os");
|
|
6736
|
-
|
|
6736
|
+
import_node_path19 = require("path");
|
|
6737
6737
|
init_nested_electron_env();
|
|
6738
6738
|
init_run();
|
|
6739
6739
|
WELL_KNOWN_NODE_BINS = [
|
|
@@ -6752,36 +6752,36 @@ function electronResourcesPath() {
|
|
|
6752
6752
|
function packagedCursorRuntimeDir() {
|
|
6753
6753
|
const resources = electronResourcesPath();
|
|
6754
6754
|
if (!resources) return null;
|
|
6755
|
-
const dir = (0,
|
|
6756
|
-
if (!(0,
|
|
6755
|
+
const dir = (0, import_node_path20.join)(resources, "cursor-runtime");
|
|
6756
|
+
if (!(0, import_node_fs20.existsSync)((0, import_node_path20.join)(dir, "core-dist", "agents", "cursor-runner.js"))) return null;
|
|
6757
6757
|
return dir;
|
|
6758
6758
|
}
|
|
6759
6759
|
function packagedCursorRunnerPath() {
|
|
6760
6760
|
const dir = packagedCursorRuntimeDir();
|
|
6761
|
-
return dir ? (0,
|
|
6761
|
+
return dir ? (0, import_node_path20.join)(dir, "core-dist", "agents", "cursor-runner.js") : null;
|
|
6762
6762
|
}
|
|
6763
6763
|
function packagedMcpDir() {
|
|
6764
6764
|
const resources = electronResourcesPath();
|
|
6765
6765
|
if (!resources) return null;
|
|
6766
|
-
const dir = (0,
|
|
6767
|
-
if (!(0,
|
|
6766
|
+
const dir = (0, import_node_path20.join)(resources, "sideboard-mcp");
|
|
6767
|
+
if (!(0, import_node_fs20.existsSync)((0, import_node_path20.join)(dir, "core-dist", "mcp", "run-stdio.js"))) return null;
|
|
6768
6768
|
return dir;
|
|
6769
6769
|
}
|
|
6770
6770
|
function packagedMcpStdioPath() {
|
|
6771
6771
|
const dir = packagedMcpDir();
|
|
6772
|
-
return dir ? (0,
|
|
6772
|
+
return dir ? (0, import_node_path20.join)(dir, "core-dist", "mcp", "run-stdio.js") : null;
|
|
6773
6773
|
}
|
|
6774
6774
|
function packagedCursorRipgrepCandidate(platformPkg, binName) {
|
|
6775
6775
|
const dir = packagedCursorRuntimeDir();
|
|
6776
6776
|
if (!dir) return null;
|
|
6777
|
-
return (0,
|
|
6777
|
+
return (0, import_node_path20.join)(dir, "node_modules", platformPkg, "bin", binName);
|
|
6778
6778
|
}
|
|
6779
|
-
var
|
|
6779
|
+
var import_node_fs20, import_node_path20;
|
|
6780
6780
|
var init_packaged_runtime = __esm({
|
|
6781
6781
|
"src/agents/packaged-runtime.ts"() {
|
|
6782
6782
|
"use strict";
|
|
6783
|
-
|
|
6784
|
-
|
|
6783
|
+
import_node_fs20 = require("fs");
|
|
6784
|
+
import_node_path20 = require("path");
|
|
6785
6785
|
}
|
|
6786
6786
|
});
|
|
6787
6787
|
|
|
@@ -6868,37 +6868,37 @@ function corePackageDir() {
|
|
|
6868
6868
|
try {
|
|
6869
6869
|
const url = import_meta.url;
|
|
6870
6870
|
if (typeof url === "string" && url.length > 0) {
|
|
6871
|
-
return (0,
|
|
6871
|
+
return (0, import_node_path21.dirname)((0, import_node_url.fileURLToPath)(url));
|
|
6872
6872
|
}
|
|
6873
6873
|
} catch {
|
|
6874
6874
|
}
|
|
6875
6875
|
try {
|
|
6876
|
-
const req = (0, import_node_module.createRequire)((0,
|
|
6877
|
-
return (0,
|
|
6876
|
+
const req = (0, import_node_module.createRequire)((0, import_node_path21.join)(process.cwd(), "package.json"));
|
|
6877
|
+
return (0, import_node_path21.dirname)(req.resolve("@sideboard-ai/core"));
|
|
6878
6878
|
} catch {
|
|
6879
6879
|
return process.cwd();
|
|
6880
6880
|
}
|
|
6881
6881
|
}
|
|
6882
6882
|
function findSideboardMcpJsEntry() {
|
|
6883
6883
|
const override = process.env.SIDEBOARD_MCP_ENTRY?.trim() || process.env.SIDEBOARD_CLI?.trim();
|
|
6884
|
-
if (override && (0,
|
|
6884
|
+
if (override && (0, import_node_fs21.existsSync)(override)) return override;
|
|
6885
6885
|
const packaged = packagedMcpStdioPath();
|
|
6886
6886
|
if (packaged) return packaged;
|
|
6887
6887
|
let dir = corePackageDir();
|
|
6888
6888
|
for (let i = 0; i < 10; i++) {
|
|
6889
6889
|
const candidates = [
|
|
6890
|
-
(0,
|
|
6891
|
-
(0,
|
|
6892
|
-
(0,
|
|
6893
|
-
(0,
|
|
6894
|
-
(0,
|
|
6895
|
-
(0,
|
|
6896
|
-
(0,
|
|
6890
|
+
(0, import_node_path21.join)(dir, "mcp/run-stdio.js"),
|
|
6891
|
+
(0, import_node_path21.join)(dir, "mcp/run-stdio.cjs"),
|
|
6892
|
+
(0, import_node_path21.join)(dir, "dist/mcp/run-stdio.js"),
|
|
6893
|
+
(0, import_node_path21.join)(dir, "dist/mcp/run-stdio.cjs"),
|
|
6894
|
+
(0, import_node_path21.join)(dir, "packages/core/dist/mcp/run-stdio.js"),
|
|
6895
|
+
(0, import_node_path21.join)(dir, "packages/cli/dist/index.js"),
|
|
6896
|
+
(0, import_node_path21.join)(dir, "cli/dist/index.js")
|
|
6897
6897
|
];
|
|
6898
6898
|
for (const p of candidates) {
|
|
6899
|
-
if ((0,
|
|
6899
|
+
if ((0, import_node_fs21.existsSync)(p) && !isAsarPath(p)) return p;
|
|
6900
6900
|
}
|
|
6901
|
-
const parent = (0,
|
|
6901
|
+
const parent = (0, import_node_path21.dirname)(dir);
|
|
6902
6902
|
if (parent === dir) break;
|
|
6903
6903
|
dir = parent;
|
|
6904
6904
|
}
|
|
@@ -7039,22 +7039,22 @@ function writeMcpServersConfig(servers) {
|
|
|
7039
7039
|
...env ? { env } : {}
|
|
7040
7040
|
};
|
|
7041
7041
|
}
|
|
7042
|
-
const dir = (0,
|
|
7043
|
-
const cfgPath = (0,
|
|
7044
|
-
(0,
|
|
7042
|
+
const dir = (0, import_node_fs21.mkdtempSync)((0, import_node_path21.join)((0, import_node_os8.tmpdir)(), "sideboard-mcp-"));
|
|
7043
|
+
const cfgPath = (0, import_node_path21.join)(dir, "mcp.json");
|
|
7044
|
+
(0, import_node_fs21.writeFileSync)(cfgPath, JSON.stringify({ mcpServers }, null, 2));
|
|
7045
7045
|
return cfgPath;
|
|
7046
7046
|
}
|
|
7047
7047
|
async function writeInjectedMcpConfig(opts) {
|
|
7048
7048
|
return writeMcpServersConfig(await buildInjectedMcpServers(opts));
|
|
7049
7049
|
}
|
|
7050
|
-
var
|
|
7050
|
+
var import_node_fs21, import_node_module, import_node_os8, import_node_path21, import_node_url, import_meta, SIDEBOARD_MCP_ALLOWED_TOOLS, SIDEBOARD_ARTIFACT_MCP_ALLOWED_TOOLS, BRIGHTSY_MCP_ALLOWED_TOOLS, brightsyMcpCommandCache, BRIGHTSY_WORD;
|
|
7051
7051
|
var init_injected_mcp = __esm({
|
|
7052
7052
|
"src/agents/injected-mcp.ts"() {
|
|
7053
7053
|
"use strict";
|
|
7054
|
-
|
|
7054
|
+
import_node_fs21 = require("fs");
|
|
7055
7055
|
import_node_module = require("module");
|
|
7056
7056
|
import_node_os8 = require("os");
|
|
7057
|
-
|
|
7057
|
+
import_node_path21 = require("path");
|
|
7058
7058
|
import_node_url = require("url");
|
|
7059
7059
|
init_run();
|
|
7060
7060
|
init_config();
|
|
@@ -7247,11 +7247,11 @@ function parseIssuesJson(raw) {
|
|
|
7247
7247
|
}
|
|
7248
7248
|
return [];
|
|
7249
7249
|
}
|
|
7250
|
-
var
|
|
7250
|
+
var import_node_fs22, BASE_ALLOWED_TOOLS, CLAUDE_CHROME_ALLOWED_TOOLS, CLAUDE_PROMPT_ARG_MAX, claudeAdapter;
|
|
7251
7251
|
var init_claude = __esm({
|
|
7252
7252
|
"src/agents/claude.ts"() {
|
|
7253
7253
|
"use strict";
|
|
7254
|
-
|
|
7254
|
+
import_node_fs22 = require("fs");
|
|
7255
7255
|
init_run();
|
|
7256
7256
|
init_app_settings();
|
|
7257
7257
|
init_claude_mcp();
|
|
@@ -7280,7 +7280,7 @@ var init_claude = __esm({
|
|
|
7280
7280
|
async detect() {
|
|
7281
7281
|
const claude = resolveClaudeExecutable();
|
|
7282
7282
|
if (claude !== "claude") {
|
|
7283
|
-
if (!(0,
|
|
7283
|
+
if (!(0, import_node_fs22.existsSync)(claude)) {
|
|
7284
7284
|
return {
|
|
7285
7285
|
agent: "claude",
|
|
7286
7286
|
installed: false,
|
|
@@ -7517,7 +7517,7 @@ async function listCodexModels() {
|
|
|
7517
7517
|
if (codex === "codex") {
|
|
7518
7518
|
const which = await run("which", ["codex"], { reject: false });
|
|
7519
7519
|
if (which.exitCode !== 0) return FALLBACK_CODEX_MODELS;
|
|
7520
|
-
} else if (!(0,
|
|
7520
|
+
} else if (!(0, import_node_fs23.existsSync)(codex)) {
|
|
7521
7521
|
return FALLBACK_CODEX_MODELS;
|
|
7522
7522
|
}
|
|
7523
7523
|
const listed = await run(codex, ["debug", "models"], { reject: false });
|
|
@@ -7552,12 +7552,12 @@ function usageFromCodex(usage) {
|
|
|
7552
7552
|
}
|
|
7553
7553
|
function codexConfigHasNetworkAccess() {
|
|
7554
7554
|
const candidates = [
|
|
7555
|
-
(0,
|
|
7556
|
-
(0,
|
|
7555
|
+
(0, import_node_path22.join)((0, import_node_os9.homedir)(), ".codex", "config.toml"),
|
|
7556
|
+
(0, import_node_path22.join)((0, import_node_os9.homedir)(), ".config", "codex", "config.toml")
|
|
7557
7557
|
];
|
|
7558
7558
|
for (const path2 of candidates) {
|
|
7559
|
-
if (!(0,
|
|
7560
|
-
const text3 = (0,
|
|
7559
|
+
if (!(0, import_node_fs23.existsSync)(path2)) continue;
|
|
7560
|
+
const text3 = (0, import_node_fs23.readFileSync)(path2, "utf8");
|
|
7561
7561
|
if (/network_access\s*=\s*true/.test(text3)) return true;
|
|
7562
7562
|
}
|
|
7563
7563
|
return false;
|
|
@@ -7589,21 +7589,21 @@ function asRecord(value) {
|
|
|
7589
7589
|
return void 0;
|
|
7590
7590
|
}
|
|
7591
7591
|
function codexLooksAuthenticated() {
|
|
7592
|
-
const authPath = (0,
|
|
7593
|
-
if (!(0,
|
|
7592
|
+
const authPath = (0, import_node_path22.join)((0, import_node_os9.homedir)(), ".codex", "auth.json");
|
|
7593
|
+
if (!(0, import_node_fs23.existsSync)(authPath)) return false;
|
|
7594
7594
|
try {
|
|
7595
|
-
return (0,
|
|
7595
|
+
return (0, import_node_fs23.statSync)(authPath).size > 2;
|
|
7596
7596
|
} catch {
|
|
7597
7597
|
return false;
|
|
7598
7598
|
}
|
|
7599
7599
|
}
|
|
7600
|
-
var
|
|
7600
|
+
var import_node_fs23, import_node_os9, import_node_path22, CODEX_PROMPT_ARG_MAX, FALLBACK_CODEX_MODELS, cachedCodexModels, CODEX_MODEL_CACHE_MS, codexAdapter;
|
|
7601
7601
|
var init_codex = __esm({
|
|
7602
7602
|
"src/agents/codex.ts"() {
|
|
7603
7603
|
"use strict";
|
|
7604
|
-
|
|
7604
|
+
import_node_fs23 = require("fs");
|
|
7605
7605
|
import_node_os9 = require("os");
|
|
7606
|
-
|
|
7606
|
+
import_node_path22 = require("path");
|
|
7607
7607
|
init_run();
|
|
7608
7608
|
init_app_settings();
|
|
7609
7609
|
init_global_workspace();
|
|
@@ -7628,7 +7628,7 @@ var init_codex = __esm({
|
|
|
7628
7628
|
async detect() {
|
|
7629
7629
|
const codex = resolveAgentExecutable("codex");
|
|
7630
7630
|
if (codex !== "codex") {
|
|
7631
|
-
if (!(0,
|
|
7631
|
+
if (!(0, import_node_fs23.existsSync)(codex)) {
|
|
7632
7632
|
return {
|
|
7633
7633
|
agent: "codex",
|
|
7634
7634
|
installed: false,
|
|
@@ -8037,21 +8037,21 @@ function platformRipgrepPackage() {
|
|
|
8037
8037
|
}
|
|
8038
8038
|
function usableRipgrepPath(candidate) {
|
|
8039
8039
|
const raw = candidate?.trim();
|
|
8040
|
-
if (!raw || !(0,
|
|
8040
|
+
if (!raw || !(0, import_node_path23.isAbsolute)(raw)) return null;
|
|
8041
8041
|
const readable = nodeReadableScriptPath(raw);
|
|
8042
|
-
if (!(0,
|
|
8042
|
+
if (!(0, import_node_fs24.existsSync)(readable) || isAsarPath(readable)) return null;
|
|
8043
8043
|
return readable;
|
|
8044
8044
|
}
|
|
8045
8045
|
function walkForBundledRipgrep(startFile) {
|
|
8046
8046
|
if (!startFile) return null;
|
|
8047
8047
|
const pkg = platformRipgrepPackage();
|
|
8048
8048
|
const name = rgBinaryName();
|
|
8049
|
-
let dir = (0,
|
|
8050
|
-
const root = (0,
|
|
8049
|
+
let dir = (0, import_node_path23.dirname)((0, import_node_path23.resolve)(startFile));
|
|
8050
|
+
const root = (0, import_node_path23.parse)(dir).root;
|
|
8051
8051
|
while (dir !== root) {
|
|
8052
|
-
const hit = usableRipgrepPath((0,
|
|
8052
|
+
const hit = usableRipgrepPath((0, import_node_path23.join)(dir, "node_modules", pkg, "bin", name));
|
|
8053
8053
|
if (hit) return hit;
|
|
8054
|
-
const next = (0,
|
|
8054
|
+
const next = (0, import_node_path23.dirname)(dir);
|
|
8055
8055
|
if (next === dir) break;
|
|
8056
8056
|
dir = next;
|
|
8057
8057
|
}
|
|
@@ -8061,7 +8061,7 @@ function requireResolveBundledRipgrep(fromFile) {
|
|
|
8061
8061
|
try {
|
|
8062
8062
|
const req = (0, import_node_module2.createRequire)(fromFile);
|
|
8063
8063
|
const pkgJson = req.resolve(`${platformRipgrepPackage()}/package.json`);
|
|
8064
|
-
return usableRipgrepPath((0,
|
|
8064
|
+
return usableRipgrepPath((0, import_node_path23.join)((0, import_node_path23.dirname)(pkgJson), "bin", rgBinaryName()));
|
|
8065
8065
|
} catch {
|
|
8066
8066
|
return null;
|
|
8067
8067
|
}
|
|
@@ -8081,13 +8081,13 @@ function cursorRipgrepEnv(opts) {
|
|
|
8081
8081
|
const path2 = resolveCursorRipgrepPath(opts);
|
|
8082
8082
|
return path2 ? { [RIPGREP_ENV]: path2 } : {};
|
|
8083
8083
|
}
|
|
8084
|
-
var
|
|
8084
|
+
var import_node_fs24, import_node_module2, import_node_path23, import_node_url2, import_meta2, RIPGREP_ENV;
|
|
8085
8085
|
var init_cursor_ripgrep = __esm({
|
|
8086
8086
|
"src/agents/cursor-ripgrep.ts"() {
|
|
8087
8087
|
"use strict";
|
|
8088
|
-
|
|
8088
|
+
import_node_fs24 = require("fs");
|
|
8089
8089
|
import_node_module2 = require("module");
|
|
8090
|
-
|
|
8090
|
+
import_node_path23 = require("path");
|
|
8091
8091
|
import_node_url2 = require("url");
|
|
8092
8092
|
init_node_launch();
|
|
8093
8093
|
init_packaged_runtime();
|
|
@@ -8135,11 +8135,11 @@ function entryDir() {
|
|
|
8135
8135
|
const cjsDir = typeof __dirname !== "undefined" ? __dirname : "";
|
|
8136
8136
|
if (cjsDir) return cjsDir;
|
|
8137
8137
|
try {
|
|
8138
|
-
return (0,
|
|
8138
|
+
return (0, import_node_path24.dirname)((0, import_node_url3.fileURLToPath)(import_meta3.url));
|
|
8139
8139
|
} catch {
|
|
8140
8140
|
try {
|
|
8141
8141
|
const req = (0, import_node_module3.createRequire)(process.cwd() + "/");
|
|
8142
|
-
return (0,
|
|
8142
|
+
return (0, import_node_path24.dirname)(req.resolve("@sideboard-ai/core"));
|
|
8143
8143
|
} catch {
|
|
8144
8144
|
return process.cwd();
|
|
8145
8145
|
}
|
|
@@ -8150,27 +8150,27 @@ function cursorRunnerPath() {
|
|
|
8150
8150
|
if (packaged) return packaged;
|
|
8151
8151
|
const root = entryDir();
|
|
8152
8152
|
const candidates = [
|
|
8153
|
-
(0,
|
|
8154
|
-
(0,
|
|
8153
|
+
(0, import_node_path24.join)(root, "agents", "cursor-runner.js"),
|
|
8154
|
+
(0, import_node_path24.join)(root, "agents", "cursor-runner.cjs"),
|
|
8155
8155
|
// If somehow resolved from package root instead of dist/
|
|
8156
|
-
(0,
|
|
8157
|
-
(0,
|
|
8156
|
+
(0, import_node_path24.join)(root, "dist", "agents", "cursor-runner.js"),
|
|
8157
|
+
(0, import_node_path24.join)(root, "dist", "agents", "cursor-runner.cjs"),
|
|
8158
8158
|
// Source tree (dev): packages/core/src/agents/cursor-runner.ts
|
|
8159
|
-
(0,
|
|
8160
|
-
(0,
|
|
8159
|
+
(0, import_node_path24.join)(root, "cursor-runner.ts"),
|
|
8160
|
+
(0, import_node_path24.join)(root, "src", "agents", "cursor-runner.ts")
|
|
8161
8161
|
];
|
|
8162
8162
|
for (const candidate of candidates) {
|
|
8163
|
-
if ((0,
|
|
8163
|
+
if ((0, import_node_fs25.existsSync)(candidate)) return candidate;
|
|
8164
8164
|
}
|
|
8165
8165
|
return candidates[0];
|
|
8166
8166
|
}
|
|
8167
|
-
var
|
|
8167
|
+
var import_node_fs25, import_node_module3, import_node_path24, import_node_url3, import_sdk, import_meta3, FALLBACK_CURSOR_MODELS, cachedModels, MODEL_CACHE_MS, cursorAdapter;
|
|
8168
8168
|
var init_cursor = __esm({
|
|
8169
8169
|
"src/agents/cursor.ts"() {
|
|
8170
8170
|
"use strict";
|
|
8171
|
-
|
|
8171
|
+
import_node_fs25 = require("fs");
|
|
8172
8172
|
import_node_module3 = require("module");
|
|
8173
|
-
|
|
8173
|
+
import_node_path24 = require("path");
|
|
8174
8174
|
import_node_url3 = require("url");
|
|
8175
8175
|
import_sdk = require("@cursor/sdk");
|
|
8176
8176
|
init_run();
|
|
@@ -8302,7 +8302,7 @@ async function listOpencodeModels() {
|
|
|
8302
8302
|
if (opencode === "opencode") {
|
|
8303
8303
|
const which = await run("which", ["opencode"], { reject: false });
|
|
8304
8304
|
if (which.exitCode !== 0) return FALLBACK_OPENCODE_MODELS;
|
|
8305
|
-
} else if (!(0,
|
|
8305
|
+
} else if (!(0, import_node_fs26.existsSync)(opencode)) {
|
|
8306
8306
|
return FALLBACK_OPENCODE_MODELS;
|
|
8307
8307
|
}
|
|
8308
8308
|
const listed = await run(opencode, ["models"], { reject: false });
|
|
@@ -8332,11 +8332,11 @@ function usageFromOpencode(tokens) {
|
|
|
8332
8332
|
cacheWriteTokens: tokens.cache?.write ? Number(tokens.cache.write) : void 0
|
|
8333
8333
|
};
|
|
8334
8334
|
}
|
|
8335
|
-
var
|
|
8335
|
+
var import_node_fs26, FALLBACK_OPENCODE_MODELS, cachedOpencodeModels, OPENCODE_MODEL_CACHE_MS, opencodeAdapter;
|
|
8336
8336
|
var init_opencode = __esm({
|
|
8337
8337
|
"src/agents/opencode.ts"() {
|
|
8338
8338
|
"use strict";
|
|
8339
|
-
|
|
8339
|
+
import_node_fs26 = require("fs");
|
|
8340
8340
|
init_run();
|
|
8341
8341
|
init_app_settings();
|
|
8342
8342
|
init_global_workspace();
|
|
@@ -8362,7 +8362,7 @@ var init_opencode = __esm({
|
|
|
8362
8362
|
async detect() {
|
|
8363
8363
|
const opencode = resolveAgentExecutable("opencode");
|
|
8364
8364
|
if (opencode !== "opencode") {
|
|
8365
|
-
if (!(0,
|
|
8365
|
+
if (!(0, import_node_fs26.existsSync)(opencode)) {
|
|
8366
8366
|
return {
|
|
8367
8367
|
agent: "opencode",
|
|
8368
8368
|
installed: false,
|
|
@@ -9159,40 +9159,40 @@ __export(plan_file_exports, {
|
|
|
9159
9159
|
writePlanFile: () => writePlanFile
|
|
9160
9160
|
});
|
|
9161
9161
|
function ensureAttachmentsGitignore2(worktreePath) {
|
|
9162
|
-
const gitignoreAbs = (0,
|
|
9163
|
-
if ((0,
|
|
9164
|
-
(0,
|
|
9165
|
-
(0,
|
|
9162
|
+
const gitignoreAbs = (0, import_node_path37.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
|
|
9163
|
+
if ((0, import_node_fs40.existsSync)(gitignoreAbs)) return;
|
|
9164
|
+
(0, import_node_fs40.mkdirSync)((0, import_node_path37.dirname)(gitignoreAbs), { recursive: true });
|
|
9165
|
+
(0, import_node_fs40.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
|
|
9166
9166
|
}
|
|
9167
9167
|
function planFileAbs(worktreePath) {
|
|
9168
|
-
return (0,
|
|
9168
|
+
return (0, import_node_path37.join)(worktreePath, PLAN_FILE_REL);
|
|
9169
9169
|
}
|
|
9170
9170
|
function readTextIfPresent2(abs) {
|
|
9171
|
-
if (!(0,
|
|
9171
|
+
if (!(0, import_node_fs40.existsSync)(abs)) return null;
|
|
9172
9172
|
try {
|
|
9173
|
-
const content = (0,
|
|
9173
|
+
const content = (0, import_node_fs40.readFileSync)(abs, "utf8");
|
|
9174
9174
|
return content.trim() ? content : null;
|
|
9175
9175
|
} catch {
|
|
9176
9176
|
return null;
|
|
9177
9177
|
}
|
|
9178
9178
|
}
|
|
9179
9179
|
function readPlanFile(worktreePath) {
|
|
9180
|
-
return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0,
|
|
9180
|
+
return readTextIfPresent2(planFileAbs(worktreePath)) ?? readTextIfPresent2((0, import_node_path37.join)(worktreePath, `${LEGACY_ATTACHMENTS_DIR}/plan.md`)) ?? readTextIfPresent2((0, import_node_path37.join)(worktreePath, LEGACY_PLAN_FILE_REL));
|
|
9181
9181
|
}
|
|
9182
9182
|
function writePlanFile(worktreePath, content) {
|
|
9183
9183
|
ensureAttachmentsGitignore2(worktreePath);
|
|
9184
9184
|
const abs = planFileAbs(worktreePath);
|
|
9185
|
-
(0,
|
|
9185
|
+
(0, import_node_fs40.mkdirSync)((0, import_node_path37.dirname)(abs), { recursive: true });
|
|
9186
9186
|
const body = content.trimEnd() + (content.endsWith("\n") ? "" : "\n");
|
|
9187
|
-
(0,
|
|
9187
|
+
(0, import_node_fs40.writeFileSync)(abs, body, "utf8");
|
|
9188
9188
|
return PLAN_FILE_REL;
|
|
9189
9189
|
}
|
|
9190
|
-
var
|
|
9190
|
+
var import_node_fs40, import_node_path37;
|
|
9191
9191
|
var init_plan_file = __esm({
|
|
9192
9192
|
"src/plan/plan-file.ts"() {
|
|
9193
9193
|
"use strict";
|
|
9194
|
-
|
|
9195
|
-
|
|
9194
|
+
import_node_fs40 = require("fs");
|
|
9195
|
+
import_node_path37 = require("path");
|
|
9196
9196
|
init_workspace_scratch();
|
|
9197
9197
|
init_plan_present();
|
|
9198
9198
|
init_plan_present();
|
|
@@ -9207,10 +9207,10 @@ __export(cursor_recover_exports, {
|
|
|
9207
9207
|
function recoverFinishedCursorRun(opts) {
|
|
9208
9208
|
const agentId = opts.agentId.trim();
|
|
9209
9209
|
if (!agentId) return null;
|
|
9210
|
-
const runsPath = (0,
|
|
9211
|
-
if (!(0,
|
|
9210
|
+
const runsPath = (0, import_node_path38.join)(appDataDir(), "cursor-sdk-store", "runs.ndjson");
|
|
9211
|
+
if (!(0, import_node_fs41.existsSync)(runsPath)) return null;
|
|
9212
9212
|
try {
|
|
9213
|
-
const lines = (0,
|
|
9213
|
+
const lines = (0, import_node_fs41.readFileSync)(runsPath, "utf8").split("\n");
|
|
9214
9214
|
let best = null;
|
|
9215
9215
|
for (const line of lines) {
|
|
9216
9216
|
const trimmed = line.trim();
|
|
@@ -9236,12 +9236,12 @@ function recoverFinishedCursorRun(opts) {
|
|
|
9236
9236
|
return null;
|
|
9237
9237
|
}
|
|
9238
9238
|
}
|
|
9239
|
-
var
|
|
9239
|
+
var import_node_fs41, import_node_path38;
|
|
9240
9240
|
var init_cursor_recover = __esm({
|
|
9241
9241
|
"src/agents/cursor-recover.ts"() {
|
|
9242
9242
|
"use strict";
|
|
9243
|
-
|
|
9244
|
-
|
|
9243
|
+
import_node_fs41 = require("fs");
|
|
9244
|
+
import_node_path38 = require("path");
|
|
9245
9245
|
init_paths();
|
|
9246
9246
|
}
|
|
9247
9247
|
});
|
|
@@ -9388,6 +9388,7 @@ __export(index_exports, {
|
|
|
9388
9388
|
captureTurnBaseline: () => captureTurnBaseline,
|
|
9389
9389
|
checkoutPrStackLayer: () => checkoutPrStackLayer,
|
|
9390
9390
|
childEnvWithAppSettings: () => childEnvWithAppSettings,
|
|
9391
|
+
claimDesktopHost: () => claimDesktopHost,
|
|
9391
9392
|
claudeAdapter: () => claudeAdapter,
|
|
9392
9393
|
claudeChromeEnabled: () => claudeChromeEnabled,
|
|
9393
9394
|
claudeUserSettingsPath: () => claudeUserSettingsPath,
|
|
@@ -9426,6 +9427,7 @@ __export(index_exports, {
|
|
|
9426
9427
|
decodeBrightsyTarget: () => decodeBrightsyTarget,
|
|
9427
9428
|
deleteBranchOnPurgeEnabled: () => deleteBranchOnPurgeEnabled,
|
|
9428
9429
|
deleteThreadRecord: () => deleteThreadRecord,
|
|
9430
|
+
desktopHostPidPath: () => desktopHostPidPath,
|
|
9429
9431
|
detectAgents: () => detectAgents,
|
|
9430
9432
|
detectGhStack: () => detectGhStack,
|
|
9431
9433
|
detectLocalMergeConflicts: () => detectLocalMergeConflicts,
|
|
@@ -9551,6 +9553,7 @@ __export(index_exports, {
|
|
|
9551
9553
|
isConductorBundledCli: () => isConductorBundledCli,
|
|
9552
9554
|
isCursorAutoModel: () => isCursorAutoModel,
|
|
9553
9555
|
isDefaultishSourceRef: () => isDefaultishSourceRef,
|
|
9556
|
+
isDesktopHostAlive: () => isDesktopHostAlive,
|
|
9554
9557
|
isDirty: () => isDirty,
|
|
9555
9558
|
isGhRateLimitError: () => isGhRateLimitError,
|
|
9556
9559
|
isGlobalRepoPath: () => isGlobalRepoPath,
|
|
@@ -9572,6 +9575,7 @@ __export(index_exports, {
|
|
|
9572
9575
|
isSlackExternalReplyPrompt: () => isSlackExternalReplyPrompt,
|
|
9573
9576
|
isSlackOAuthCancelled: () => isSlackOAuthCancelled,
|
|
9574
9577
|
isThinkingEffort: () => isThinkingEffort,
|
|
9578
|
+
isThisProcessDesktopHost: () => isThisProcessDesktopHost,
|
|
9575
9579
|
isThreadCaffeinated: () => isThreadCaffeinated,
|
|
9576
9580
|
isWorkspaceScratchPath: () => isWorkspaceScratchPath,
|
|
9577
9581
|
linearAuthorizationHeader: () => linearAuthorizationHeader,
|
|
@@ -9673,6 +9677,7 @@ __export(index_exports, {
|
|
|
9673
9677
|
refreshSlackReplyBadges: () => refreshSlackReplyBadges,
|
|
9674
9678
|
registerPackagedUserMcpClients: () => registerPackagedUserMcpClients,
|
|
9675
9679
|
releaseCaffeinateHoldForThread: () => releaseCaffeinateHoldForThread,
|
|
9680
|
+
releaseDesktopHost: () => releaseDesktopHost,
|
|
9676
9681
|
removeWorkspace: () => removeWorkspace,
|
|
9677
9682
|
removeWorktree: () => removeWorktree,
|
|
9678
9683
|
repoSlug: () => repoSlug,
|
|
@@ -9773,6 +9778,7 @@ __export(index_exports, {
|
|
|
9773
9778
|
taskMessageText: () => taskMessageText,
|
|
9774
9779
|
thinkingEffortBars: () => thinkingEffortBars,
|
|
9775
9780
|
thinkingEffortLabel: () => thinkingEffortLabel,
|
|
9781
|
+
thisProcessShouldDrainAgentQueues: () => thisProcessShouldDrainAgentQueues,
|
|
9776
9782
|
threadDisplayLabel: () => threadDisplayLabel,
|
|
9777
9783
|
threadFilePath: () => threadFilePath,
|
|
9778
9784
|
threadLockPath: () => threadLockPath,
|
|
@@ -9820,6 +9826,55 @@ init_app_settings();
|
|
|
9820
9826
|
init_caffeinate_hold();
|
|
9821
9827
|
init_secure_file();
|
|
9822
9828
|
init_thread_store();
|
|
9829
|
+
|
|
9830
|
+
// src/store/desktop-host.ts
|
|
9831
|
+
var import_node_fs10 = require("fs");
|
|
9832
|
+
var import_node_path10 = require("path");
|
|
9833
|
+
init_paths();
|
|
9834
|
+
function desktopHostPidPath() {
|
|
9835
|
+
return (0, import_node_path10.join)(appDataDir(), "desktop-host.pid");
|
|
9836
|
+
}
|
|
9837
|
+
function claimDesktopHost(pid = process.pid) {
|
|
9838
|
+
(0, import_node_fs10.writeFileSync)(desktopHostPidPath(), `${pid}
|
|
9839
|
+
`, "utf8");
|
|
9840
|
+
}
|
|
9841
|
+
function releaseDesktopHost(pid = process.pid) {
|
|
9842
|
+
if (readDesktopHostPid() !== pid) return;
|
|
9843
|
+
try {
|
|
9844
|
+
(0, import_node_fs10.unlinkSync)(desktopHostPidPath());
|
|
9845
|
+
} catch {
|
|
9846
|
+
}
|
|
9847
|
+
}
|
|
9848
|
+
function readDesktopHostPid() {
|
|
9849
|
+
try {
|
|
9850
|
+
const pid = Number.parseInt((0, import_node_fs10.readFileSync)(desktopHostPidPath(), "utf8").trim(), 10);
|
|
9851
|
+
if (!Number.isFinite(pid) || pid <= 0) return null;
|
|
9852
|
+
return pid;
|
|
9853
|
+
} catch {
|
|
9854
|
+
return null;
|
|
9855
|
+
}
|
|
9856
|
+
}
|
|
9857
|
+
function pidAlive(pid) {
|
|
9858
|
+
try {
|
|
9859
|
+
process.kill(pid, 0);
|
|
9860
|
+
return true;
|
|
9861
|
+
} catch {
|
|
9862
|
+
return false;
|
|
9863
|
+
}
|
|
9864
|
+
}
|
|
9865
|
+
function isDesktopHostAlive() {
|
|
9866
|
+
const pid = readDesktopHostPid();
|
|
9867
|
+
return pid != null && pidAlive(pid);
|
|
9868
|
+
}
|
|
9869
|
+
function isThisProcessDesktopHost() {
|
|
9870
|
+
return readDesktopHostPid() === process.pid && pidAlive(process.pid);
|
|
9871
|
+
}
|
|
9872
|
+
function thisProcessShouldDrainAgentQueues() {
|
|
9873
|
+
if (isThisProcessDesktopHost()) return true;
|
|
9874
|
+
return !isDesktopHostAlive();
|
|
9875
|
+
}
|
|
9876
|
+
|
|
9877
|
+
// src/index.ts
|
|
9823
9878
|
init_workspaces();
|
|
9824
9879
|
init_global_workspace();
|
|
9825
9880
|
init_run();
|
|
@@ -10979,8 +11034,8 @@ init_usage();
|
|
|
10979
11034
|
init_claude_mcp();
|
|
10980
11035
|
|
|
10981
11036
|
// src/agents/instructions.ts
|
|
10982
|
-
var
|
|
10983
|
-
var
|
|
11037
|
+
var import_node_fs27 = require("fs");
|
|
11038
|
+
var import_node_path25 = require("path");
|
|
10984
11039
|
init_git_auth_mode();
|
|
10985
11040
|
init_worktree_labels();
|
|
10986
11041
|
function normPath3(p) {
|
|
@@ -11151,11 +11206,11 @@ function loadAgentInstructions(worktreePath, agent) {
|
|
|
11151
11206
|
const out = [];
|
|
11152
11207
|
for (const rel of candidates) {
|
|
11153
11208
|
if (seenPaths.has(rel)) continue;
|
|
11154
|
-
const abs = (0,
|
|
11155
|
-
if (!(0,
|
|
11209
|
+
const abs = (0, import_node_path25.join)(worktreePath, rel);
|
|
11210
|
+
if (!(0, import_node_fs27.existsSync)(abs)) continue;
|
|
11156
11211
|
try {
|
|
11157
|
-
if (!(0,
|
|
11158
|
-
let content = (0,
|
|
11212
|
+
if (!(0, import_node_fs27.statSync)(abs).isFile()) continue;
|
|
11213
|
+
let content = (0, import_node_fs27.readFileSync)(abs, "utf8");
|
|
11159
11214
|
if (!content.trim()) continue;
|
|
11160
11215
|
if (content.length > MAX_CHARS_PER_FILE) {
|
|
11161
11216
|
content = `${content.slice(0, MAX_CHARS_PER_FILE)}
|
|
@@ -11237,9 +11292,9 @@ async function requireAgent(agent, opts) {
|
|
|
11237
11292
|
init_settings();
|
|
11238
11293
|
|
|
11239
11294
|
// src/hook/conductor.ts
|
|
11240
|
-
var
|
|
11295
|
+
var import_node_fs28 = require("fs");
|
|
11241
11296
|
var import_node_net = require("net");
|
|
11242
|
-
var
|
|
11297
|
+
var import_node_path26 = require("path");
|
|
11243
11298
|
var import_execa4 = require("execa");
|
|
11244
11299
|
var import_node_readline3 = require("readline");
|
|
11245
11300
|
init_settings();
|
|
@@ -11254,9 +11309,9 @@ function matchSimpleGlob(pattern, name) {
|
|
|
11254
11309
|
return new RegExp(`^${escaped}$`).test(name);
|
|
11255
11310
|
}
|
|
11256
11311
|
function readWorktreeInclude(repoPath) {
|
|
11257
|
-
const path2 = (0,
|
|
11258
|
-
if (!(0,
|
|
11259
|
-
return (0,
|
|
11312
|
+
const path2 = (0, import_node_path26.join)(repoPath, ".worktreeinclude");
|
|
11313
|
+
if (!(0, import_node_fs28.existsSync)(path2)) return [];
|
|
11314
|
+
return (0, import_node_fs28.readFileSync)(path2, "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
|
|
11260
11315
|
}
|
|
11261
11316
|
function resolveFilesToCopy(repoPath) {
|
|
11262
11317
|
const fromInclude = readWorktreeInclude(repoPath);
|
|
@@ -11266,10 +11321,10 @@ function resolveFilesToCopy(repoPath) {
|
|
|
11266
11321
|
if (settings?.fileIncludeGlobs?.length) {
|
|
11267
11322
|
const matched = [];
|
|
11268
11323
|
try {
|
|
11269
|
-
for (const entry of (0,
|
|
11324
|
+
for (const entry of (0, import_node_fs28.readdirSync)(repoPath, { withFileTypes: true })) {
|
|
11270
11325
|
if (!entry.isFile()) continue;
|
|
11271
11326
|
for (const glob of settings.fileIncludeGlobs) {
|
|
11272
|
-
if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0,
|
|
11327
|
+
if (matchSimpleGlob(glob, entry.name) || matchSimpleGlob((0, import_node_path26.basename)(glob), entry.name)) {
|
|
11273
11328
|
matched.push(entry.name);
|
|
11274
11329
|
break;
|
|
11275
11330
|
}
|
|
@@ -11281,7 +11336,7 @@ function resolveFilesToCopy(repoPath) {
|
|
|
11281
11336
|
}
|
|
11282
11337
|
const defaults = [];
|
|
11283
11338
|
try {
|
|
11284
|
-
for (const entry of (0,
|
|
11339
|
+
for (const entry of (0, import_node_fs28.readdirSync)(repoPath, { withFileTypes: true })) {
|
|
11285
11340
|
if (entry.isFile() && entry.name.startsWith(".env")) {
|
|
11286
11341
|
defaults.push(entry.name);
|
|
11287
11342
|
}
|
|
@@ -11295,11 +11350,11 @@ function copyConfiguredFiles(repoPath, worktreePath) {
|
|
|
11295
11350
|
const patterns = resolveFilesToCopy(repoPath);
|
|
11296
11351
|
const copied = [];
|
|
11297
11352
|
for (const rel of patterns) {
|
|
11298
|
-
const src = (0,
|
|
11299
|
-
if (!(0,
|
|
11300
|
-
const dest = (0,
|
|
11301
|
-
(0,
|
|
11302
|
-
(0,
|
|
11353
|
+
const src = (0, import_node_path26.join)(repoPath, rel);
|
|
11354
|
+
if (!(0, import_node_fs28.existsSync)(src)) continue;
|
|
11355
|
+
const dest = (0, import_node_path26.join)(worktreePath, rel);
|
|
11356
|
+
(0, import_node_fs28.mkdirSync)((0, import_node_path26.dirname)(dest), { recursive: true });
|
|
11357
|
+
(0, import_node_fs28.copyFileSync)(src, dest);
|
|
11303
11358
|
copied.push(rel);
|
|
11304
11359
|
}
|
|
11305
11360
|
return copied;
|
|
@@ -11335,7 +11390,7 @@ function buildWorkspaceScriptEnv(opts, baseEnv) {
|
|
|
11335
11390
|
const env = stripNestedElectronEnv({
|
|
11336
11391
|
...baseEnv ?? process.env
|
|
11337
11392
|
});
|
|
11338
|
-
const name = opts.workspaceName ?? (0,
|
|
11393
|
+
const name = opts.workspaceName ?? (0, import_node_path26.basename)(opts.worktreePath);
|
|
11339
11394
|
const ports = opts.ports ?? [];
|
|
11340
11395
|
const primary = ports[0];
|
|
11341
11396
|
env.SIDEBOARD_WORKSPACE_NAME = name;
|
|
@@ -11596,12 +11651,12 @@ init_convention_setup();
|
|
|
11596
11651
|
init_cursor_worktrees();
|
|
11597
11652
|
|
|
11598
11653
|
// src/diff/diff.ts
|
|
11599
|
-
var
|
|
11600
|
-
var
|
|
11654
|
+
var import_node_fs29 = require("fs");
|
|
11655
|
+
var import_node_path27 = require("path");
|
|
11601
11656
|
init_run();
|
|
11602
11657
|
init_worktree();
|
|
11603
11658
|
async function inspectGitWorktree(worktreePath) {
|
|
11604
|
-
if (!worktreePath || !(0,
|
|
11659
|
+
if (!worktreePath || !(0, import_node_fs29.existsSync)(worktreePath)) return "missing_worktree";
|
|
11605
11660
|
const check = await git(["rev-parse", "--is-inside-work-tree"], worktreePath, {
|
|
11606
11661
|
reject: false
|
|
11607
11662
|
});
|
|
@@ -11609,7 +11664,7 @@ async function inspectGitWorktree(worktreePath) {
|
|
|
11609
11664
|
return "ok";
|
|
11610
11665
|
}
|
|
11611
11666
|
async function initializeGitRepository(worktreePath) {
|
|
11612
|
-
if (!worktreePath || !(0,
|
|
11667
|
+
if (!worktreePath || !(0, import_node_fs29.existsSync)(worktreePath)) {
|
|
11613
11668
|
throw new Error("Worktree not found");
|
|
11614
11669
|
}
|
|
11615
11670
|
const status = await inspectGitWorktree(worktreePath);
|
|
@@ -11745,11 +11800,11 @@ new file mode 100644
|
|
|
11745
11800
|
};
|
|
11746
11801
|
}
|
|
11747
11802
|
async function untrackedPatch(worktreePath, path2, maxHunk) {
|
|
11748
|
-
const abs = (0,
|
|
11803
|
+
const abs = (0, import_node_path27.join)(worktreePath, path2);
|
|
11749
11804
|
try {
|
|
11750
|
-
const st = (0,
|
|
11805
|
+
const st = (0, import_node_fs29.statSync)(abs);
|
|
11751
11806
|
if (st.isFile() && st.size > maxHunk) {
|
|
11752
|
-
const buf = (0,
|
|
11807
|
+
const buf = (0, import_node_fs29.readFileSync)(abs).subarray(0, maxHunk);
|
|
11753
11808
|
return syntheticAddPatch(path2, buf.toString("utf8"), maxHunk);
|
|
11754
11809
|
}
|
|
11755
11810
|
} catch {
|
|
@@ -12250,8 +12305,8 @@ var DEFAULT_UPLOAD_MAX_BYTES = 5e7;
|
|
|
12250
12305
|
function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
12251
12306
|
assertSafeRelativePath(relativePath);
|
|
12252
12307
|
const maxBytes = opts?.maxBytes ?? DEFAULT_UPLOAD_MAX_BYTES;
|
|
12253
|
-
const abs = (0,
|
|
12254
|
-
const st = (0,
|
|
12308
|
+
const abs = (0, import_node_path27.join)(worktreePath, relativePath);
|
|
12309
|
+
const st = (0, import_node_fs29.statSync)(abs);
|
|
12255
12310
|
if (!st.isFile()) {
|
|
12256
12311
|
throw new Error(`Not a file: ${relativePath}`);
|
|
12257
12312
|
}
|
|
@@ -12260,7 +12315,7 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
|
12260
12315
|
`File too large to upload (${st.size} bytes; max ${maxBytes})`
|
|
12261
12316
|
);
|
|
12262
12317
|
}
|
|
12263
|
-
const buf = (0,
|
|
12318
|
+
const buf = (0, import_node_fs29.readFileSync)(abs);
|
|
12264
12319
|
return {
|
|
12265
12320
|
path: relativePath,
|
|
12266
12321
|
contentBase64: buf.toString("base64"),
|
|
@@ -12270,12 +12325,12 @@ function readWorktreeFileForUpload(worktreePath, relativePath, opts) {
|
|
|
12270
12325
|
function readWorktreeFile(worktreePath, relativePath, opts) {
|
|
12271
12326
|
assertSafeRelativePath(relativePath);
|
|
12272
12327
|
const maxBytes = opts?.maxBytes ?? 2e5;
|
|
12273
|
-
const abs = (0,
|
|
12274
|
-
const st = (0,
|
|
12328
|
+
const abs = (0, import_node_path27.join)(worktreePath, relativePath);
|
|
12329
|
+
const st = (0, import_node_fs29.statSync)(abs);
|
|
12275
12330
|
if (!st.isFile()) {
|
|
12276
12331
|
throw new Error(`Not a file: ${relativePath}`);
|
|
12277
12332
|
}
|
|
12278
|
-
const buf = (0,
|
|
12333
|
+
const buf = (0, import_node_fs29.readFileSync)(abs);
|
|
12279
12334
|
if (isImageRelativePath(relativePath)) {
|
|
12280
12335
|
const maxImageBytes = Math.max(maxBytes, 15e6);
|
|
12281
12336
|
const truncated2 = buf.length > maxImageBytes;
|
|
@@ -12318,9 +12373,9 @@ function assertSafeRelativePath(relativePath) {
|
|
|
12318
12373
|
}
|
|
12319
12374
|
function writeWorktreeFile(worktreePath, relativePath, content) {
|
|
12320
12375
|
assertSafeRelativePath(relativePath);
|
|
12321
|
-
const abs = (0,
|
|
12322
|
-
(0,
|
|
12323
|
-
(0,
|
|
12376
|
+
const abs = (0, import_node_path27.join)(worktreePath, relativePath);
|
|
12377
|
+
(0, import_node_fs29.mkdirSync)((0, import_node_path27.dirname)(abs), { recursive: true });
|
|
12378
|
+
(0, import_node_fs29.writeFileSync)(abs, content, "utf8");
|
|
12324
12379
|
return { path: relativePath };
|
|
12325
12380
|
}
|
|
12326
12381
|
async function getDiffSummary(worktreePath, repoPath, opts) {
|
|
@@ -12339,9 +12394,9 @@ async function getDiffSummary(worktreePath, repoPath, opts) {
|
|
|
12339
12394
|
}
|
|
12340
12395
|
|
|
12341
12396
|
// src/skills/discover.ts
|
|
12342
|
-
var
|
|
12397
|
+
var import_node_fs30 = require("fs");
|
|
12343
12398
|
var import_node_os10 = require("os");
|
|
12344
|
-
var
|
|
12399
|
+
var import_node_path28 = require("path");
|
|
12345
12400
|
function toCommand(name) {
|
|
12346
12401
|
return name.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
12347
12402
|
}
|
|
@@ -12373,7 +12428,7 @@ function parseFrontmatter(content) {
|
|
|
12373
12428
|
}
|
|
12374
12429
|
function readSkill(skillMd, source) {
|
|
12375
12430
|
try {
|
|
12376
|
-
const content = (0,
|
|
12431
|
+
const content = (0, import_node_fs30.readFileSync)(skillMd, "utf8");
|
|
12377
12432
|
const { name: fmName, description } = parseFrontmatter(content);
|
|
12378
12433
|
const dirName = skillMd.split("/").slice(-2, -1)[0] || "skill";
|
|
12379
12434
|
const name = fmName || dirName;
|
|
@@ -12392,19 +12447,19 @@ function readSkill(skillMd, source) {
|
|
|
12392
12447
|
}
|
|
12393
12448
|
}
|
|
12394
12449
|
function scanSkillsDir(dir, source, out) {
|
|
12395
|
-
if (!(0,
|
|
12450
|
+
if (!(0, import_node_fs30.existsSync)(dir)) return;
|
|
12396
12451
|
let entries;
|
|
12397
12452
|
try {
|
|
12398
|
-
entries = (0,
|
|
12453
|
+
entries = (0, import_node_fs30.readdirSync)(dir);
|
|
12399
12454
|
} catch {
|
|
12400
12455
|
return;
|
|
12401
12456
|
}
|
|
12402
12457
|
for (const entry of entries) {
|
|
12403
12458
|
if (entry.startsWith(".")) continue;
|
|
12404
|
-
const skillMd = (0,
|
|
12405
|
-
if (!(0,
|
|
12459
|
+
const skillMd = (0, import_node_path28.join)(dir, entry, "SKILL.md");
|
|
12460
|
+
if (!(0, import_node_fs30.existsSync)(skillMd)) continue;
|
|
12406
12461
|
try {
|
|
12407
|
-
if (!(0,
|
|
12462
|
+
if (!(0, import_node_fs30.statSync)(skillMd).isFile()) continue;
|
|
12408
12463
|
} catch {
|
|
12409
12464
|
continue;
|
|
12410
12465
|
}
|
|
@@ -12413,24 +12468,24 @@ function scanSkillsDir(dir, source, out) {
|
|
|
12413
12468
|
}
|
|
12414
12469
|
}
|
|
12415
12470
|
function scanClaudePluginSkills(pluginsRoot, out) {
|
|
12416
|
-
if (!(0,
|
|
12471
|
+
if (!(0, import_node_fs30.existsSync)(pluginsRoot)) return;
|
|
12417
12472
|
const walk = (dir, depth, lookingForSkillsDir) => {
|
|
12418
12473
|
if (depth > 7) return;
|
|
12419
12474
|
let entries;
|
|
12420
12475
|
try {
|
|
12421
|
-
entries = (0,
|
|
12476
|
+
entries = (0, import_node_fs30.readdirSync)(dir);
|
|
12422
12477
|
} catch {
|
|
12423
12478
|
return;
|
|
12424
12479
|
}
|
|
12425
12480
|
if (lookingForSkillsDir && entries.includes("SKILL.md")) {
|
|
12426
|
-
const skill = readSkill((0,
|
|
12481
|
+
const skill = readSkill((0, import_node_path28.join)(dir, "SKILL.md"), "cli");
|
|
12427
12482
|
if (skill) out.push(skill);
|
|
12428
12483
|
}
|
|
12429
12484
|
for (const entry of entries) {
|
|
12430
12485
|
if (entry === "node_modules" || entry === ".git") continue;
|
|
12431
|
-
const full = (0,
|
|
12486
|
+
const full = (0, import_node_path28.join)(dir, entry);
|
|
12432
12487
|
try {
|
|
12433
|
-
if (!(0,
|
|
12488
|
+
if (!(0, import_node_fs30.statSync)(full).isDirectory()) continue;
|
|
12434
12489
|
} catch {
|
|
12435
12490
|
continue;
|
|
12436
12491
|
}
|
|
@@ -12448,17 +12503,17 @@ function discoverSkills(worktreePath) {
|
|
|
12448
12503
|
const home = (0, import_node_os10.homedir)();
|
|
12449
12504
|
const collected = [];
|
|
12450
12505
|
for (const rel of [".claude/skills", ".cursor/skills", ".sideboard/skills", ".brightsy/skills", "skills"]) {
|
|
12451
|
-
scanSkillsDir((0,
|
|
12506
|
+
scanSkillsDir((0, import_node_path28.join)(worktreePath, rel), "workspace", collected);
|
|
12452
12507
|
}
|
|
12453
12508
|
for (const abs of [
|
|
12454
|
-
(0,
|
|
12455
|
-
(0,
|
|
12456
|
-
(0,
|
|
12457
|
-
(0,
|
|
12509
|
+
(0, import_node_path28.join)(home, ".claude/skills"),
|
|
12510
|
+
(0, import_node_path28.join)(home, ".cursor/skills"),
|
|
12511
|
+
(0, import_node_path28.join)(home, ".sideboard/skills"),
|
|
12512
|
+
(0, import_node_path28.join)(home, ".brightsy/skills")
|
|
12458
12513
|
]) {
|
|
12459
12514
|
scanSkillsDir(abs, "user", collected);
|
|
12460
12515
|
}
|
|
12461
|
-
scanClaudePluginSkills((0,
|
|
12516
|
+
scanClaudePluginSkills((0, import_node_path28.join)(home, ".claude/plugins"), collected);
|
|
12462
12517
|
const rank = { workspace: 0, user: 1, cli: 2 };
|
|
12463
12518
|
const byCommand = /* @__PURE__ */ new Map();
|
|
12464
12519
|
for (const skill of collected) {
|
|
@@ -12470,7 +12525,7 @@ function discoverSkills(worktreePath) {
|
|
|
12470
12525
|
return [...byCommand.values()].sort((a, b) => a.command.localeCompare(b.command));
|
|
12471
12526
|
}
|
|
12472
12527
|
function readSkillBody(skillPath, maxChars = 12e3) {
|
|
12473
|
-
const raw = (0,
|
|
12528
|
+
const raw = (0, import_node_fs30.readFileSync)(skillPath, "utf8");
|
|
12474
12529
|
if (raw.startsWith("---")) {
|
|
12475
12530
|
const end = raw.indexOf("\n---", 3);
|
|
12476
12531
|
if (end >= 0) {
|
|
@@ -12611,8 +12666,8 @@ function buildDiffCommentAttachment(input) {
|
|
|
12611
12666
|
}
|
|
12612
12667
|
|
|
12613
12668
|
// src/composer/stage-files.ts
|
|
12614
|
-
var
|
|
12615
|
-
var
|
|
12669
|
+
var import_node_fs31 = require("fs");
|
|
12670
|
+
var import_node_path29 = require("path");
|
|
12616
12671
|
var import_node_crypto5 = require("crypto");
|
|
12617
12672
|
init_workspace_scratch();
|
|
12618
12673
|
var IMAGE_EXTENSIONS2 = /* @__PURE__ */ new Set([
|
|
@@ -12638,7 +12693,7 @@ var IMAGE_MIME_BY_EXT = {
|
|
|
12638
12693
|
var MAX_INLINE_BYTES = 4e5;
|
|
12639
12694
|
var MAX_PREVIEW_BYTES = 5e6;
|
|
12640
12695
|
function fileExtension(filePath) {
|
|
12641
|
-
const base = (0,
|
|
12696
|
+
const base = (0, import_node_path29.basename)(filePath).toLowerCase();
|
|
12642
12697
|
return base.includes(".") ? base.split(".").pop() || "" : "";
|
|
12643
12698
|
}
|
|
12644
12699
|
function isImageFilePath(filePath) {
|
|
@@ -12648,22 +12703,22 @@ function imageMimeType(filePath) {
|
|
|
12648
12703
|
return IMAGE_MIME_BY_EXT[fileExtension(filePath)] || "image/png";
|
|
12649
12704
|
}
|
|
12650
12705
|
function ensureAttachmentsDir(worktreePath) {
|
|
12651
|
-
const dir = (0,
|
|
12652
|
-
(0,
|
|
12653
|
-
const gi = (0,
|
|
12654
|
-
if (!(0,
|
|
12655
|
-
(0,
|
|
12706
|
+
const dir = (0, import_node_path29.join)(worktreePath, ATTACHMENTS_DIR);
|
|
12707
|
+
(0, import_node_fs31.mkdirSync)(dir, { recursive: true });
|
|
12708
|
+
const gi = (0, import_node_path29.join)(dir, ".gitignore");
|
|
12709
|
+
if (!(0, import_node_fs31.existsSync)(gi)) {
|
|
12710
|
+
(0, import_node_fs31.writeFileSync)(gi, attachmentsGitignoreBody(), "utf8");
|
|
12656
12711
|
}
|
|
12657
12712
|
return dir;
|
|
12658
12713
|
}
|
|
12659
12714
|
function uniqueAttachmentName(dir, originalName) {
|
|
12660
12715
|
const safe = originalName.replace(/[/\\]/g, "_") || "file";
|
|
12661
|
-
if (!(0,
|
|
12662
|
-
const ext = (0,
|
|
12716
|
+
if (!(0, import_node_fs31.existsSync)((0, import_node_path29.join)(dir, safe))) return safe;
|
|
12717
|
+
const ext = (0, import_node_path29.extname)(safe);
|
|
12663
12718
|
const stem = ext ? safe.slice(0, -ext.length) : safe;
|
|
12664
12719
|
for (let i = 1; i < 1e4; i++) {
|
|
12665
12720
|
const candidate = `${stem}-${i}${ext}`;
|
|
12666
|
-
if (!(0,
|
|
12721
|
+
if (!(0, import_node_fs31.existsSync)((0, import_node_path29.join)(dir, candidate))) return candidate;
|
|
12667
12722
|
}
|
|
12668
12723
|
return `${stem}-${(0, import_node_crypto5.randomUUID)()}${ext}`;
|
|
12669
12724
|
}
|
|
@@ -12715,9 +12770,9 @@ function attachmentFromBuffer(name, buf, opts) {
|
|
|
12715
12770
|
};
|
|
12716
12771
|
}
|
|
12717
12772
|
function attachmentFromAbsolutePath(absolutePath) {
|
|
12718
|
-
const name = (0,
|
|
12773
|
+
const name = (0, import_node_path29.basename)(absolutePath);
|
|
12719
12774
|
try {
|
|
12720
|
-
const st = (0,
|
|
12775
|
+
const st = (0, import_node_fs31.statSync)(absolutePath);
|
|
12721
12776
|
if (!st.isFile()) {
|
|
12722
12777
|
return {
|
|
12723
12778
|
id: (0, import_node_crypto5.randomUUID)(),
|
|
@@ -12726,7 +12781,7 @@ function attachmentFromAbsolutePath(absolutePath) {
|
|
|
12726
12781
|
content: `(not a file: ${absolutePath})`
|
|
12727
12782
|
};
|
|
12728
12783
|
}
|
|
12729
|
-
const buf = (0,
|
|
12784
|
+
const buf = (0, import_node_fs31.readFileSync)(absolutePath);
|
|
12730
12785
|
return attachmentFromBuffer(name, buf, { sourceLabel: absolutePath });
|
|
12731
12786
|
} catch (err) {
|
|
12732
12787
|
return {
|
|
@@ -12742,15 +12797,15 @@ function stageAbsolutePathsAsAttachments(worktreePath, absolutePaths) {
|
|
|
12742
12797
|
const dir = ensureAttachmentsDir(worktreePath);
|
|
12743
12798
|
const out = [];
|
|
12744
12799
|
for (const abs of absolutePaths) {
|
|
12745
|
-
const originalName = (0,
|
|
12800
|
+
const originalName = (0, import_node_path29.basename)(abs);
|
|
12746
12801
|
try {
|
|
12747
|
-
const st = (0,
|
|
12802
|
+
const st = (0, import_node_fs31.statSync)(abs);
|
|
12748
12803
|
if (!st.isFile()) continue;
|
|
12749
12804
|
const name = uniqueAttachmentName(dir, originalName);
|
|
12750
|
-
const destAbs = (0,
|
|
12751
|
-
(0,
|
|
12805
|
+
const destAbs = (0, import_node_path29.join)(dir, name);
|
|
12806
|
+
(0, import_node_fs31.copyFileSync)(abs, destAbs);
|
|
12752
12807
|
const rel = `${ATTACHMENTS_DIR}/${name}`;
|
|
12753
|
-
const buf = (0,
|
|
12808
|
+
const buf = (0, import_node_fs31.readFileSync)(destAbs);
|
|
12754
12809
|
out.push(attachmentFromBuffer(name, buf, { path: rel, sourceLabel: abs }));
|
|
12755
12810
|
} catch (err) {
|
|
12756
12811
|
out.push({
|
|
@@ -12772,8 +12827,8 @@ function stageBuffersAsAttachments(worktreePath, buffers) {
|
|
|
12772
12827
|
try {
|
|
12773
12828
|
const buf = Buffer.from(item.dataBase64, "base64");
|
|
12774
12829
|
const name = uniqueAttachmentName(dir, originalName);
|
|
12775
|
-
const destAbs = (0,
|
|
12776
|
-
(0,
|
|
12830
|
+
const destAbs = (0, import_node_path29.join)(dir, name);
|
|
12831
|
+
(0, import_node_fs31.writeFileSync)(destAbs, buf);
|
|
12777
12832
|
const rel = `${ATTACHMENTS_DIR}/${name}`;
|
|
12778
12833
|
out.push(attachmentFromBuffer(name, buf, { path: rel }));
|
|
12779
12834
|
} catch (err) {
|
|
@@ -12809,18 +12864,18 @@ function attachmentsFromWorktreePaths(worktreePath, relativePaths) {
|
|
|
12809
12864
|
if (!rel || rel.includes("..") || rel.startsWith("/")) {
|
|
12810
12865
|
out.push({
|
|
12811
12866
|
id: (0, import_node_crypto5.randomUUID)(),
|
|
12812
|
-
name: (0,
|
|
12867
|
+
name: (0, import_node_path29.basename)(rel) || "file",
|
|
12813
12868
|
kind: "file",
|
|
12814
12869
|
content: `(invalid path: ${rel})`
|
|
12815
12870
|
});
|
|
12816
12871
|
continue;
|
|
12817
12872
|
}
|
|
12818
|
-
const name = (0,
|
|
12873
|
+
const name = (0, import_node_path29.basename)(rel);
|
|
12819
12874
|
try {
|
|
12820
|
-
const abs = (0,
|
|
12821
|
-
const st = (0,
|
|
12875
|
+
const abs = (0, import_node_path29.join)(worktreePath, rel);
|
|
12876
|
+
const st = (0, import_node_fs31.statSync)(abs);
|
|
12822
12877
|
if (!st.isFile()) continue;
|
|
12823
|
-
const buf = (0,
|
|
12878
|
+
const buf = (0, import_node_fs31.readFileSync)(abs);
|
|
12824
12879
|
out.push(attachmentFromBuffer(name, buf, { path: rel, sourceLabel: abs }));
|
|
12825
12880
|
} catch (err) {
|
|
12826
12881
|
out.push({
|
|
@@ -13308,7 +13363,7 @@ async function confirmLand(thread, opts) {
|
|
|
13308
13363
|
}
|
|
13309
13364
|
|
|
13310
13365
|
// src/threads/create.ts
|
|
13311
|
-
var
|
|
13366
|
+
var import_node_fs32 = require("fs");
|
|
13312
13367
|
init_worktree();
|
|
13313
13368
|
init_app_settings();
|
|
13314
13369
|
init_thread_store();
|
|
@@ -13322,7 +13377,7 @@ async function createThread(input, _onSetupLine) {
|
|
|
13322
13377
|
});
|
|
13323
13378
|
await requireAgent(resolved.agent);
|
|
13324
13379
|
const repoPath = await resolveRepoRoot(input.repoPath);
|
|
13325
|
-
if (!(0,
|
|
13380
|
+
if (!(0, import_node_fs32.existsSync)(repoPath)) {
|
|
13326
13381
|
throw new Error(`Repo not found: ${repoPath}`);
|
|
13327
13382
|
}
|
|
13328
13383
|
let sourceRef = input.sourceRef;
|
|
@@ -13562,7 +13617,7 @@ async function forkThreadWorktree(input, onSetupLine) {
|
|
|
13562
13617
|
}
|
|
13563
13618
|
|
|
13564
13619
|
// src/threads/stack-layers.ts
|
|
13565
|
-
var
|
|
13620
|
+
var import_node_fs33 = require("fs");
|
|
13566
13621
|
init_run();
|
|
13567
13622
|
init_stack();
|
|
13568
13623
|
init_worktree();
|
|
@@ -13630,7 +13685,7 @@ async function openStackLayer(input, _onSetupLine) {
|
|
|
13630
13685
|
let createdWorktree = false;
|
|
13631
13686
|
const trees = await listWorktrees(repoPath);
|
|
13632
13687
|
const checkedOut = trees.find((w) => w.branch === branchName);
|
|
13633
|
-
if (checkedOut?.path && (0,
|
|
13688
|
+
if (checkedOut?.path && (0, import_node_fs33.existsSync)(checkedOut.path)) {
|
|
13634
13689
|
if (input.reuseExistingWorktree !== false) {
|
|
13635
13690
|
worktreePath = checkedOut.path;
|
|
13636
13691
|
} else {
|
|
@@ -13772,7 +13827,7 @@ async function initStackFromThread(input, onSetupLine) {
|
|
|
13772
13827
|
async function createPrStack(input, onSetupLine) {
|
|
13773
13828
|
await requireAgent(input.agent);
|
|
13774
13829
|
const repoPath = await resolveRepoRoot(input.repoPath);
|
|
13775
|
-
if (!(0,
|
|
13830
|
+
if (!(0, import_node_fs33.existsSync)(repoPath)) throw new Error(`Repo not found: ${repoPath}`);
|
|
13776
13831
|
if (!input.branches.length) throw new Error("At least one branch name required");
|
|
13777
13832
|
const status = await detectGhStack(repoPath);
|
|
13778
13833
|
if (!status.available) throw new Error(status.reason);
|
|
@@ -13839,7 +13894,7 @@ async function createPrStack(input, onSetupLine) {
|
|
|
13839
13894
|
}
|
|
13840
13895
|
}
|
|
13841
13896
|
const claimed = new Set(threads.map((t) => t.worktreePath));
|
|
13842
|
-
if (!claimed.has(bootstrap.worktreePath) && (0,
|
|
13897
|
+
if (!claimed.has(bootstrap.worktreePath) && (0, import_node_fs33.existsSync)(bootstrap.worktreePath)) {
|
|
13843
13898
|
try {
|
|
13844
13899
|
await removeWorktree(repoPath, bootstrap.worktreePath, {
|
|
13845
13900
|
deleteBranch: bootstrap.branchName
|
|
@@ -13862,21 +13917,21 @@ function stackAgentDefaultsFrom(input) {
|
|
|
13862
13917
|
|
|
13863
13918
|
// src/threads/adopt.ts
|
|
13864
13919
|
var import_node_child_process4 = require("child_process");
|
|
13865
|
-
var
|
|
13920
|
+
var import_node_fs34 = require("fs");
|
|
13866
13921
|
var import_node_os11 = require("os");
|
|
13867
|
-
var
|
|
13922
|
+
var import_node_path30 = require("path");
|
|
13868
13923
|
var import_node_module4 = require("module");
|
|
13869
13924
|
init_worktree();
|
|
13870
13925
|
init_thread_store();
|
|
13871
13926
|
var import_meta4 = {};
|
|
13872
|
-
var CONDUCTOR_APP_SUPPORT = (0,
|
|
13927
|
+
var CONDUCTOR_APP_SUPPORT = (0, import_node_path30.join)(
|
|
13873
13928
|
process.env.HOME ?? "",
|
|
13874
13929
|
"Library",
|
|
13875
13930
|
"Application Support",
|
|
13876
13931
|
"com.conductor.app"
|
|
13877
13932
|
);
|
|
13878
|
-
var CONDUCTOR_DB = (0,
|
|
13879
|
-
var CURSOR_SDK_STORE = (0,
|
|
13933
|
+
var CONDUCTOR_DB = (0, import_node_path30.join)(CONDUCTOR_APP_SUPPORT, "conductor.db");
|
|
13934
|
+
var CURSOR_SDK_STORE = (0, import_node_path30.join)(CONDUCTOR_APP_SUPPORT, "cursor-sdk-store");
|
|
13880
13935
|
function openReadonlySqlite(file) {
|
|
13881
13936
|
const req = (0, import_node_module4.createRequire)(import_meta4.url);
|
|
13882
13937
|
const Database = req("better-sqlite3");
|
|
@@ -13893,21 +13948,21 @@ function mapAgentType(raw) {
|
|
|
13893
13948
|
return null;
|
|
13894
13949
|
}
|
|
13895
13950
|
function resolveConductorCursorAgentId(workspacePath) {
|
|
13896
|
-
if (!workspacePath || !(0,
|
|
13951
|
+
if (!workspacePath || !(0, import_node_fs34.existsSync)(CURSOR_SDK_STORE)) return null;
|
|
13897
13952
|
const normalized = workspacePath.replace(/\/$/, "");
|
|
13898
13953
|
let best = null;
|
|
13899
13954
|
let hashes;
|
|
13900
13955
|
try {
|
|
13901
|
-
hashes = (0,
|
|
13956
|
+
hashes = (0, import_node_fs34.readdirSync)(CURSOR_SDK_STORE);
|
|
13902
13957
|
} catch {
|
|
13903
13958
|
return null;
|
|
13904
13959
|
}
|
|
13905
13960
|
for (const hash of hashes) {
|
|
13906
|
-
const agentsFile = (0,
|
|
13907
|
-
if (!(0,
|
|
13961
|
+
const agentsFile = (0, import_node_path30.join)(CURSOR_SDK_STORE, hash, "agents.ndjson");
|
|
13962
|
+
if (!(0, import_node_fs34.existsSync)(agentsFile)) continue;
|
|
13908
13963
|
let text3;
|
|
13909
13964
|
try {
|
|
13910
|
-
text3 = (0,
|
|
13965
|
+
text3 = (0, import_node_fs34.readFileSync)(agentsFile, "utf8");
|
|
13911
13966
|
} catch {
|
|
13912
13967
|
continue;
|
|
13913
13968
|
}
|
|
@@ -13931,7 +13986,7 @@ function resolveConductorCursorAgentId(workspacePath) {
|
|
|
13931
13986
|
return best?.agentId ?? null;
|
|
13932
13987
|
}
|
|
13933
13988
|
async function adoptThread(input) {
|
|
13934
|
-
if (!(0,
|
|
13989
|
+
if (!(0, import_node_fs34.existsSync)(input.worktreePath)) {
|
|
13935
13990
|
throw new Error(`Worktree not found: ${input.worktreePath}`);
|
|
13936
13991
|
}
|
|
13937
13992
|
const repoPath = await resolveRepoRoot(input.worktreePath);
|
|
@@ -13958,18 +14013,18 @@ function conductorDbPath() {
|
|
|
13958
14013
|
return CONDUCTOR_DB;
|
|
13959
14014
|
}
|
|
13960
14015
|
function listConductorWorkspaces() {
|
|
13961
|
-
if (!(0,
|
|
14016
|
+
if (!(0, import_node_fs34.existsSync)(CONDUCTOR_DB)) {
|
|
13962
14017
|
throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
|
|
13963
14018
|
}
|
|
13964
|
-
const tmp = (0,
|
|
13965
|
-
const snapshot = (0,
|
|
14019
|
+
const tmp = (0, import_node_fs34.mkdtempSync)((0, import_node_path30.join)((0, import_node_os11.tmpdir)(), "sideboard-conductor-"));
|
|
14020
|
+
const snapshot = (0, import_node_path30.join)(tmp, "conductor.db");
|
|
13966
14021
|
try {
|
|
13967
|
-
(0,
|
|
14022
|
+
(0, import_node_fs34.copyFileSync)(CONDUCTOR_DB, snapshot);
|
|
13968
14023
|
for (const suffix of ["-wal", "-shm"]) {
|
|
13969
14024
|
const src = `${CONDUCTOR_DB}${suffix}`;
|
|
13970
|
-
if ((0,
|
|
14025
|
+
if ((0, import_node_fs34.existsSync)(src)) {
|
|
13971
14026
|
try {
|
|
13972
|
-
(0,
|
|
14027
|
+
(0, import_node_fs34.copyFileSync)(src, `${snapshot}${suffix}`);
|
|
13973
14028
|
} catch {
|
|
13974
14029
|
}
|
|
13975
14030
|
}
|
|
@@ -14045,22 +14100,22 @@ function listConductorWorkspaces() {
|
|
|
14045
14100
|
db.close();
|
|
14046
14101
|
}
|
|
14047
14102
|
} finally {
|
|
14048
|
-
(0,
|
|
14103
|
+
(0, import_node_fs34.rmSync)(tmp, { recursive: true, force: true });
|
|
14049
14104
|
}
|
|
14050
14105
|
}
|
|
14051
14106
|
function importConductorWorkspace(workspaceId) {
|
|
14052
|
-
if (!(0,
|
|
14107
|
+
if (!(0, import_node_fs34.existsSync)(CONDUCTOR_DB)) {
|
|
14053
14108
|
throw new Error(`Conductor DB not found at ${CONDUCTOR_DB}`);
|
|
14054
14109
|
}
|
|
14055
|
-
const tmp = (0,
|
|
14056
|
-
const snapshot = (0,
|
|
14110
|
+
const tmp = (0, import_node_fs34.mkdtempSync)((0, import_node_path30.join)((0, import_node_os11.tmpdir)(), "sideboard-conductor-"));
|
|
14111
|
+
const snapshot = (0, import_node_path30.join)(tmp, "conductor.db");
|
|
14057
14112
|
try {
|
|
14058
|
-
(0,
|
|
14113
|
+
(0, import_node_fs34.copyFileSync)(CONDUCTOR_DB, snapshot);
|
|
14059
14114
|
for (const suffix of ["-wal", "-shm"]) {
|
|
14060
14115
|
const src = `${CONDUCTOR_DB}${suffix}`;
|
|
14061
|
-
if ((0,
|
|
14116
|
+
if ((0, import_node_fs34.existsSync)(src)) {
|
|
14062
14117
|
try {
|
|
14063
|
-
(0,
|
|
14118
|
+
(0, import_node_fs34.copyFileSync)(src, `${snapshot}${suffix}`);
|
|
14064
14119
|
} catch {
|
|
14065
14120
|
}
|
|
14066
14121
|
}
|
|
@@ -14078,7 +14133,7 @@ function importConductorWorkspace(workspaceId) {
|
|
|
14078
14133
|
).get(workspaceId);
|
|
14079
14134
|
if (!row) throw new Error(`Conductor workspace not found: ${workspaceId}`);
|
|
14080
14135
|
const worktreePath = String(row.workspacePath);
|
|
14081
|
-
if (!(0,
|
|
14136
|
+
if (!(0, import_node_fs34.existsSync)(worktreePath)) {
|
|
14082
14137
|
throw new Error(`Conductor worktree missing on disk: ${worktreePath}`);
|
|
14083
14138
|
}
|
|
14084
14139
|
let sessionId = null;
|
|
@@ -14141,7 +14196,7 @@ function importConductorWorkspace(workspaceId) {
|
|
|
14141
14196
|
db.close();
|
|
14142
14197
|
}
|
|
14143
14198
|
} finally {
|
|
14144
|
-
(0,
|
|
14199
|
+
(0, import_node_fs34.rmSync)(tmp, { recursive: true, force: true });
|
|
14145
14200
|
}
|
|
14146
14201
|
}
|
|
14147
14202
|
async function importConductorWorkspaceAsync(workspaceId) {
|
|
@@ -14152,8 +14207,8 @@ async function importConductorWorkspaceAsync(workspaceId) {
|
|
|
14152
14207
|
var import_node_events = require("events");
|
|
14153
14208
|
|
|
14154
14209
|
// src/slack/outbound-watch.ts
|
|
14155
|
-
var
|
|
14156
|
-
var
|
|
14210
|
+
var import_node_fs36 = require("fs");
|
|
14211
|
+
var import_node_path33 = require("path");
|
|
14157
14212
|
init_paths();
|
|
14158
14213
|
init_private_file();
|
|
14159
14214
|
init_secure_file();
|
|
@@ -14199,19 +14254,19 @@ async function slackAuthTest(token) {
|
|
|
14199
14254
|
}
|
|
14200
14255
|
|
|
14201
14256
|
// src/slack/reply-target.ts
|
|
14202
|
-
var
|
|
14203
|
-
var
|
|
14257
|
+
var import_node_fs35 = require("fs");
|
|
14258
|
+
var import_node_path31 = require("path");
|
|
14204
14259
|
init_paths();
|
|
14205
14260
|
init_private_file();
|
|
14206
14261
|
init_secure_file();
|
|
14207
14262
|
function storePath2() {
|
|
14208
|
-
return (0,
|
|
14263
|
+
return (0, import_node_path31.join)(appDataDir(), "slack-reply-to.json");
|
|
14209
14264
|
}
|
|
14210
14265
|
function readStore2() {
|
|
14211
14266
|
const path2 = storePath2();
|
|
14212
|
-
if (!(0,
|
|
14267
|
+
if (!(0, import_node_fs35.existsSync)(path2)) return {};
|
|
14213
14268
|
try {
|
|
14214
|
-
const parsed = isSecureFileEncrypted(path2) ? readSecureJson(path2) : JSON.parse((0,
|
|
14269
|
+
const parsed = isSecureFileEncrypted(path2) ? readSecureJson(path2) : JSON.parse((0, import_node_fs35.readFileSync)(path2, "utf8"));
|
|
14215
14270
|
return parsed?.targets && typeof parsed.targets === "object" ? parsed.targets : {};
|
|
14216
14271
|
} catch {
|
|
14217
14272
|
return {};
|
|
@@ -14228,11 +14283,11 @@ function getSlackReplyTarget(threadId) {
|
|
|
14228
14283
|
}
|
|
14229
14284
|
|
|
14230
14285
|
// src/slack/workspaces.ts
|
|
14231
|
-
var
|
|
14286
|
+
var import_node_path32 = require("path");
|
|
14232
14287
|
init_paths();
|
|
14233
14288
|
init_secure_file();
|
|
14234
14289
|
function storePath3() {
|
|
14235
|
-
return (0,
|
|
14290
|
+
return (0, import_node_path32.join)(appDataDir(), "slack-workspaces.json");
|
|
14236
14291
|
}
|
|
14237
14292
|
function readStore3() {
|
|
14238
14293
|
try {
|
|
@@ -14348,7 +14403,7 @@ var POLL_INTERVAL_MS = 12e3;
|
|
|
14348
14403
|
var lastPollMs = 0;
|
|
14349
14404
|
var nameCache = /* @__PURE__ */ new Map();
|
|
14350
14405
|
function storePath4() {
|
|
14351
|
-
return (0,
|
|
14406
|
+
return (0, import_node_path33.join)(appDataDir(), "slack-outbound-watch.json");
|
|
14352
14407
|
}
|
|
14353
14408
|
function watchId(teamId, channelId, ts) {
|
|
14354
14409
|
return `${teamId}:${channelId}:${ts}`;
|
|
@@ -14378,9 +14433,9 @@ function tsNewer(a, b) {
|
|
|
14378
14433
|
}
|
|
14379
14434
|
function readStore4() {
|
|
14380
14435
|
const path2 = storePath4();
|
|
14381
|
-
if (!(0,
|
|
14436
|
+
if (!(0, import_node_fs36.existsSync)(path2)) return [];
|
|
14382
14437
|
try {
|
|
14383
|
-
const parsed = isSecureFileEncrypted(path2) ? readSecureJson(path2) : JSON.parse((0,
|
|
14438
|
+
const parsed = isSecureFileEncrypted(path2) ? readSecureJson(path2) : JSON.parse((0, import_node_fs36.readFileSync)(path2, "utf8"));
|
|
14384
14439
|
return Array.isArray(parsed?.watches) ? parsed.watches : [];
|
|
14385
14440
|
} catch {
|
|
14386
14441
|
return [];
|
|
@@ -14725,7 +14780,7 @@ async function refreshSlackReplyBadges(opts) {
|
|
|
14725
14780
|
}
|
|
14726
14781
|
|
|
14727
14782
|
// src/orchestrator/orchestrator.ts
|
|
14728
|
-
var
|
|
14783
|
+
var import_node_fs42 = require("fs");
|
|
14729
14784
|
init_error_detail();
|
|
14730
14785
|
init_agents();
|
|
14731
14786
|
init_worktree();
|
|
@@ -14746,8 +14801,8 @@ function shouldAutoArchiveOnPrMerge(opts) {
|
|
|
14746
14801
|
}
|
|
14747
14802
|
|
|
14748
14803
|
// src/git/orphan-cleanup.ts
|
|
14749
|
-
var
|
|
14750
|
-
var
|
|
14804
|
+
var import_node_fs37 = require("fs");
|
|
14805
|
+
var import_node_path34 = require("path");
|
|
14751
14806
|
init_worktree();
|
|
14752
14807
|
init_thread_store();
|
|
14753
14808
|
init_paths();
|
|
@@ -14762,9 +14817,9 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
14762
14817
|
repoPaths?.length ? repoPaths : threads.map((t) => t.repoPath).filter(Boolean)
|
|
14763
14818
|
);
|
|
14764
14819
|
const homeRoot = sideboardWorkspacesDir();
|
|
14765
|
-
if ((0,
|
|
14820
|
+
if ((0, import_node_fs37.existsSync)(homeRoot)) {
|
|
14766
14821
|
try {
|
|
14767
|
-
for (const entry of (0,
|
|
14822
|
+
for (const entry of (0, import_node_fs37.readdirSync)(homeRoot, { withFileTypes: true })) {
|
|
14768
14823
|
if (!entry.isDirectory()) continue;
|
|
14769
14824
|
void entry;
|
|
14770
14825
|
}
|
|
@@ -14774,7 +14829,7 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
14774
14829
|
const orphans = [];
|
|
14775
14830
|
const seen = /* @__PURE__ */ new Set();
|
|
14776
14831
|
for (const repoPath of repos) {
|
|
14777
|
-
if (!repoPath || !(0,
|
|
14832
|
+
if (!repoPath || !(0, import_node_fs37.existsSync)(repoPath)) continue;
|
|
14778
14833
|
try {
|
|
14779
14834
|
const wts = await listWorktrees(repoPath);
|
|
14780
14835
|
for (const wt of wts) {
|
|
@@ -14785,7 +14840,7 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
14785
14840
|
seen.add(path2);
|
|
14786
14841
|
let mtimeMs = 0;
|
|
14787
14842
|
try {
|
|
14788
|
-
mtimeMs = (0,
|
|
14843
|
+
mtimeMs = (0, import_node_fs37.statSync)(path2).mtimeMs;
|
|
14789
14844
|
} catch {
|
|
14790
14845
|
mtimeMs = 0;
|
|
14791
14846
|
}
|
|
@@ -14795,16 +14850,16 @@ async function findOrphanWorktrees(repoPaths) {
|
|
|
14795
14850
|
}
|
|
14796
14851
|
try {
|
|
14797
14852
|
const root = worktreesRoot(repoPath);
|
|
14798
|
-
if ((0,
|
|
14799
|
-
for (const entry of (0,
|
|
14853
|
+
if ((0, import_node_fs37.existsSync)(root)) {
|
|
14854
|
+
for (const entry of (0, import_node_fs37.readdirSync)(root, { withFileTypes: true })) {
|
|
14800
14855
|
if (!entry.isDirectory()) continue;
|
|
14801
|
-
const path2 = (0,
|
|
14856
|
+
const path2 = (0, import_node_path34.join)(root, entry.name).replace(/\/$/, "");
|
|
14802
14857
|
if (known.has(path2) || seen.has(path2)) continue;
|
|
14803
|
-
if (!(0,
|
|
14858
|
+
if (!(0, import_node_fs37.existsSync)((0, import_node_path34.join)(path2, ".git"))) continue;
|
|
14804
14859
|
seen.add(path2);
|
|
14805
14860
|
let mtimeMs = 0;
|
|
14806
14861
|
try {
|
|
14807
|
-
mtimeMs = (0,
|
|
14862
|
+
mtimeMs = (0, import_node_fs37.statSync)(path2).mtimeMs;
|
|
14808
14863
|
} catch {
|
|
14809
14864
|
mtimeMs = Date.now();
|
|
14810
14865
|
}
|
|
@@ -14950,8 +15005,8 @@ async function applyThreadIntoMain(thread, opts) {
|
|
|
14950
15005
|
}
|
|
14951
15006
|
|
|
14952
15007
|
// src/git/clone-repo.ts
|
|
14953
|
-
var
|
|
14954
|
-
var
|
|
15008
|
+
var import_node_fs38 = require("fs");
|
|
15009
|
+
var import_node_path35 = require("path");
|
|
14955
15010
|
var import_execa6 = require("execa");
|
|
14956
15011
|
init_paths();
|
|
14957
15012
|
init_workspaces();
|
|
@@ -14961,12 +15016,12 @@ async function cloneRepoIntoSideboard(opts) {
|
|
|
14961
15016
|
if (!url) throw new Error("Clone URL is required");
|
|
14962
15017
|
let name = opts.name?.trim();
|
|
14963
15018
|
if (!name) {
|
|
14964
|
-
const leaf = (0,
|
|
15019
|
+
const leaf = (0, import_node_path35.basename)(url.replace(/\/$/, "").replace(/\.git$/, ""));
|
|
14965
15020
|
name = leaf || "repo";
|
|
14966
15021
|
}
|
|
14967
15022
|
name = name.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "repo";
|
|
14968
|
-
const dest = (0,
|
|
14969
|
-
if ((0,
|
|
15023
|
+
const dest = (0, import_node_path35.join)(sideboardReposDir(), name);
|
|
15024
|
+
if ((0, import_node_fs38.existsSync)(dest)) {
|
|
14970
15025
|
const repoPath2 = await resolveRepoRoot(dest);
|
|
14971
15026
|
const workspace2 = await ensureWorkspace(repoPath2);
|
|
14972
15027
|
return { repoPath: repoPath2, workspace: workspace2 };
|
|
@@ -14988,8 +15043,8 @@ init_orchestrator_capable();
|
|
|
14988
15043
|
|
|
14989
15044
|
// src/review/request-review.ts
|
|
14990
15045
|
var import_node_crypto8 = require("crypto");
|
|
14991
|
-
var
|
|
14992
|
-
var
|
|
15046
|
+
var import_node_fs39 = require("fs");
|
|
15047
|
+
var import_node_path36 = require("path");
|
|
14993
15048
|
init_global_workspace();
|
|
14994
15049
|
init_thread_store();
|
|
14995
15050
|
|
|
@@ -15137,22 +15192,22 @@ function shouldRefreshReviewRequestTemplate(content) {
|
|
|
15137
15192
|
return LEGACY_REVIEW_TEMPLATE_MARKERS.every((m) => trimmed.includes(m));
|
|
15138
15193
|
}
|
|
15139
15194
|
function readTextIfPresent(abs) {
|
|
15140
|
-
if (!(0,
|
|
15195
|
+
if (!(0, import_node_fs39.existsSync)(abs)) return null;
|
|
15141
15196
|
try {
|
|
15142
|
-
const content = (0,
|
|
15197
|
+
const content = (0, import_node_fs39.readFileSync)(abs, "utf8");
|
|
15143
15198
|
return content.trim() ? content : null;
|
|
15144
15199
|
} catch {
|
|
15145
15200
|
return null;
|
|
15146
15201
|
}
|
|
15147
15202
|
}
|
|
15148
15203
|
function ensureAttachmentsGitignore(worktreePath) {
|
|
15149
|
-
const gitignoreAbs = (0,
|
|
15150
|
-
if ((0,
|
|
15151
|
-
(0,
|
|
15152
|
-
(0,
|
|
15204
|
+
const gitignoreAbs = (0, import_node_path36.join)(worktreePath, ATTACHMENTS_DIR, ".gitignore");
|
|
15205
|
+
if ((0, import_node_fs39.existsSync)(gitignoreAbs)) return;
|
|
15206
|
+
(0, import_node_fs39.mkdirSync)((0, import_node_path36.dirname)(gitignoreAbs), { recursive: true });
|
|
15207
|
+
(0, import_node_fs39.writeFileSync)(gitignoreAbs, attachmentsGitignoreBody(), "utf8");
|
|
15153
15208
|
}
|
|
15154
15209
|
function resolveReviewGuidelines(worktreePath) {
|
|
15155
|
-
const repoAbs = (0,
|
|
15210
|
+
const repoAbs = (0, import_node_path36.join)(worktreePath, REPO_REVIEW_PATH);
|
|
15156
15211
|
const repoContent = readTextIfPresent(repoAbs);
|
|
15157
15212
|
if (repoContent) {
|
|
15158
15213
|
return {
|
|
@@ -15162,7 +15217,7 @@ function resolveReviewGuidelines(worktreePath) {
|
|
|
15162
15217
|
source: "repo"
|
|
15163
15218
|
};
|
|
15164
15219
|
}
|
|
15165
|
-
const localAbs = (0,
|
|
15220
|
+
const localAbs = (0, import_node_path36.join)(worktreePath, REVIEW_REQUEST_PATH);
|
|
15166
15221
|
const localContent = readTextIfPresent(localAbs);
|
|
15167
15222
|
if (localContent && !shouldRefreshReviewRequestTemplate(localContent)) {
|
|
15168
15223
|
return {
|
|
@@ -15172,7 +15227,7 @@ function resolveReviewGuidelines(worktreePath) {
|
|
|
15172
15227
|
source: "local"
|
|
15173
15228
|
};
|
|
15174
15229
|
}
|
|
15175
|
-
const legacyAbs = (0,
|
|
15230
|
+
const legacyAbs = (0, import_node_path36.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH);
|
|
15176
15231
|
const legacyContent = readTextIfPresent(legacyAbs);
|
|
15177
15232
|
if (legacyContent && !shouldRefreshReviewRequestTemplate(legacyContent)) {
|
|
15178
15233
|
return {
|
|
@@ -15183,8 +15238,8 @@ function resolveReviewGuidelines(worktreePath) {
|
|
|
15183
15238
|
};
|
|
15184
15239
|
}
|
|
15185
15240
|
ensureAttachmentsGitignore(worktreePath);
|
|
15186
|
-
(0,
|
|
15187
|
-
(0,
|
|
15241
|
+
(0, import_node_fs39.mkdirSync)((0, import_node_path36.dirname)(localAbs), { recursive: true });
|
|
15242
|
+
(0, import_node_fs39.writeFileSync)(localAbs, REVIEW_REQUEST_TEMPLATE, "utf8");
|
|
15188
15243
|
return {
|
|
15189
15244
|
path: REVIEW_REQUEST_PATH,
|
|
15190
15245
|
name: REVIEW_REQUEST_NAME,
|
|
@@ -15193,7 +15248,7 @@ function resolveReviewGuidelines(worktreePath) {
|
|
|
15193
15248
|
};
|
|
15194
15249
|
}
|
|
15195
15250
|
function ensureReviewRequestFile(worktreePath) {
|
|
15196
|
-
const repoAbs = (0,
|
|
15251
|
+
const repoAbs = (0, import_node_path36.join)(worktreePath, REPO_REVIEW_PATH);
|
|
15197
15252
|
const repoContent = readTextIfPresent(repoAbs);
|
|
15198
15253
|
if (repoContent) {
|
|
15199
15254
|
return {
|
|
@@ -15203,10 +15258,10 @@ function ensureReviewRequestFile(worktreePath) {
|
|
|
15203
15258
|
source: "repo"
|
|
15204
15259
|
};
|
|
15205
15260
|
}
|
|
15206
|
-
const localAbs = (0,
|
|
15207
|
-
const localContent = readTextIfPresent(localAbs) ?? readTextIfPresent((0,
|
|
15261
|
+
const localAbs = (0, import_node_path36.join)(worktreePath, REVIEW_REQUEST_PATH);
|
|
15262
|
+
const localContent = readTextIfPresent(localAbs) ?? readTextIfPresent((0, import_node_path36.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH));
|
|
15208
15263
|
if (localContent && !shouldRefreshReviewRequestTemplate(localContent)) {
|
|
15209
|
-
const path2 = (0,
|
|
15264
|
+
const path2 = (0, import_node_fs39.existsSync)(localAbs) ? REVIEW_REQUEST_PATH : LEGACY_REVIEW_REQUEST_PATH;
|
|
15210
15265
|
return {
|
|
15211
15266
|
path: path2,
|
|
15212
15267
|
name: REVIEW_REQUEST_NAME,
|
|
@@ -15214,8 +15269,8 @@ function ensureReviewRequestFile(worktreePath) {
|
|
|
15214
15269
|
source: "local"
|
|
15215
15270
|
};
|
|
15216
15271
|
}
|
|
15217
|
-
(0,
|
|
15218
|
-
(0,
|
|
15272
|
+
(0, import_node_fs39.mkdirSync)((0, import_node_path36.dirname)(repoAbs), { recursive: true });
|
|
15273
|
+
(0, import_node_fs39.writeFileSync)(repoAbs, REVIEW_REQUEST_TEMPLATE, "utf8");
|
|
15219
15274
|
return {
|
|
15220
15275
|
path: REPO_REVIEW_PATH,
|
|
15221
15276
|
name: REPO_REVIEW_NAME,
|
|
@@ -15235,7 +15290,7 @@ function buildReviewRequestAttachment(content, opts) {
|
|
|
15235
15290
|
};
|
|
15236
15291
|
}
|
|
15237
15292
|
function readExistingReviewRequestFile(worktreePath) {
|
|
15238
|
-
return readTextIfPresent((0,
|
|
15293
|
+
return readTextIfPresent((0, import_node_path36.join)(worktreePath, REPO_REVIEW_PATH)) ?? readTextIfPresent((0, import_node_path36.join)(worktreePath, REVIEW_REQUEST_PATH)) ?? readTextIfPresent((0, import_node_path36.join)(worktreePath, LEGACY_REVIEW_REQUEST_PATH));
|
|
15239
15294
|
}
|
|
15240
15295
|
async function requestReview(threadRef, send2) {
|
|
15241
15296
|
const from = findThreadByRef(threadRef);
|
|
@@ -15501,7 +15556,7 @@ var Orchestrator = class {
|
|
|
15501
15556
|
}
|
|
15502
15557
|
continue;
|
|
15503
15558
|
}
|
|
15504
|
-
if (!(0,
|
|
15559
|
+
if (!(0, import_node_fs42.existsSync)(thread.worktreePath)) {
|
|
15505
15560
|
setStatus(thread.id, "broken", "Worktree missing on disk");
|
|
15506
15561
|
this.emit({ type: "status_changed", threadId: thread.id, status: "broken" });
|
|
15507
15562
|
continue;
|
|
@@ -15752,7 +15807,9 @@ var Orchestrator = class {
|
|
|
15752
15807
|
updateThread(thread.id, patch);
|
|
15753
15808
|
this.emit({ type: "queue_changed", threadId: thread.id, queue });
|
|
15754
15809
|
this.emit({ type: "status_changed", threadId: thread.id, status: "queued" });
|
|
15755
|
-
|
|
15810
|
+
if (thisProcessShouldDrainAgentQueues()) {
|
|
15811
|
+
void this.drainQueue(thread.id);
|
|
15812
|
+
}
|
|
15756
15813
|
return this.requireThread(thread.id);
|
|
15757
15814
|
});
|
|
15758
15815
|
}
|
|
@@ -15805,10 +15862,10 @@ var Orchestrator = class {
|
|
|
15805
15862
|
async sendQueuedMessageNow(threadRef, index) {
|
|
15806
15863
|
const thread = this.requireThread(threadRef);
|
|
15807
15864
|
const promoted = await withThreadLock(thread.id, async () => {
|
|
15808
|
-
const
|
|
15809
|
-
if (index < 0 || index >=
|
|
15810
|
-
const item =
|
|
15811
|
-
const rest =
|
|
15865
|
+
const current2 = this.requireThread(thread.id);
|
|
15866
|
+
if (index < 0 || index >= current2.queue.length) return false;
|
|
15867
|
+
const item = current2.queue[index];
|
|
15868
|
+
const rest = current2.queue.filter((_, i) => i !== index);
|
|
15812
15869
|
const queue = [item, ...rest];
|
|
15813
15870
|
this.haltDrain.delete(thread.id);
|
|
15814
15871
|
updateThread(thread.id, { queue });
|
|
@@ -15816,10 +15873,16 @@ var Orchestrator = class {
|
|
|
15816
15873
|
return true;
|
|
15817
15874
|
});
|
|
15818
15875
|
if (!promoted) return this.requireThread(thread.id);
|
|
15876
|
+
const current = this.requireThread(thread.id);
|
|
15819
15877
|
const inFlight = this.activeTurns.has(thread.id) || this.startingTurns.has(thread.id);
|
|
15878
|
+
const livePid = current.agentPid;
|
|
15879
|
+
const foreignLive = !inFlight && typeof livePid === "number" && livePid > 0 && isPidAlive(livePid);
|
|
15820
15880
|
if (inFlight) {
|
|
15821
15881
|
this.stop(thread.id, { clearQueue: false, continueQueue: true });
|
|
15822
15882
|
} else {
|
|
15883
|
+
if (foreignLive) {
|
|
15884
|
+
this.stop(thread.id, { clearQueue: false, continueQueue: true });
|
|
15885
|
+
}
|
|
15823
15886
|
void this.drainQueue(thread.id);
|
|
15824
15887
|
}
|
|
15825
15888
|
return this.requireThread(thread.id);
|
|
@@ -16254,6 +16317,13 @@ var Orchestrator = class {
|
|
|
16254
16317
|
if (handle) handle.kill();
|
|
16255
16318
|
const proc = this.processes.get(`${thread.id}:agent`);
|
|
16256
16319
|
if (proc) proc.kill();
|
|
16320
|
+
const pid = thread.agentPid;
|
|
16321
|
+
if (typeof pid === "number" && pid > 0 && isPidAlive(pid)) {
|
|
16322
|
+
try {
|
|
16323
|
+
process.kill(pid, "SIGTERM");
|
|
16324
|
+
} catch {
|
|
16325
|
+
}
|
|
16326
|
+
}
|
|
16257
16327
|
const stopped = writeLiveStatus(thread.id, "stopped") ?? readThread(thread.id) ?? thread;
|
|
16258
16328
|
if (stopped.status === "stopped") {
|
|
16259
16329
|
this.emit({ type: "status_changed", threadId: thread.id, status: "stopped" });
|
|
@@ -17034,7 +17104,7 @@ var Orchestrator = class {
|
|
|
17034
17104
|
this.emit({ type: "status_changed", threadId: restored2.id, status: restored2.status });
|
|
17035
17105
|
return restored2;
|
|
17036
17106
|
}
|
|
17037
|
-
if (!(0,
|
|
17107
|
+
if (!(0, import_node_fs42.existsSync)(thread.worktreePath)) {
|
|
17038
17108
|
const { createThreadWorktree: createThreadWorktree2 } = await Promise.resolve().then(() => (init_worktree(), worktree_exports));
|
|
17039
17109
|
const { execa: execa7 } = await import("execa");
|
|
17040
17110
|
const slug = thread.worktreePath.split("/").pop();
|
|
@@ -17275,7 +17345,7 @@ init_coordinator_prompt();
|
|
|
17275
17345
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
17276
17346
|
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
17277
17347
|
var import_zod3 = require("zod");
|
|
17278
|
-
var
|
|
17348
|
+
var import_node_path39 = require("path");
|
|
17279
17349
|
init_worktree();
|
|
17280
17350
|
init_global_workspace();
|
|
17281
17351
|
init_list_models();
|
|
@@ -17962,7 +18032,7 @@ async function startMcpServer() {
|
|
|
17962
18032
|
async () => {
|
|
17963
18033
|
const threads = orch.getThreads(true);
|
|
17964
18034
|
const lines = threads.map((t) => {
|
|
17965
|
-
const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0,
|
|
18035
|
+
const repo = t.repoPath === GLOBAL_WORKSPACE_ID ? "Orchestration" : (0, import_node_path39.basename)(t.repoPath) || t.repoPath;
|
|
17966
18036
|
return `${t.id.slice(0, 8)} ${t.status.padEnd(9)} ${t.agent.padEnd(8)} ${repo} ${t.sourceType}:${t.sourceRef} ${t.title} sideboard://thread/${t.id}${t.devPort ? ` http://localhost:${t.devPort}` : ""}`;
|
|
17967
18037
|
});
|
|
17968
18038
|
return {
|
|
@@ -19271,16 +19341,16 @@ init_connected_teams();
|
|
|
19271
19341
|
init_injected_mcp();
|
|
19272
19342
|
|
|
19273
19343
|
// src/agents/user-mcp-config.ts
|
|
19274
|
-
var
|
|
19344
|
+
var import_node_fs43 = require("fs");
|
|
19275
19345
|
var import_node_os12 = require("os");
|
|
19276
|
-
var
|
|
19346
|
+
var import_node_path40 = require("path");
|
|
19277
19347
|
init_paths();
|
|
19278
19348
|
init_injected_mcp();
|
|
19279
19349
|
function userCursorMcpConfigPath() {
|
|
19280
|
-
return (0,
|
|
19350
|
+
return (0, import_node_path40.join)((0, import_node_os12.homedir)(), ".cursor", "mcp.json");
|
|
19281
19351
|
}
|
|
19282
19352
|
function userClaudeMcpConfigPath() {
|
|
19283
|
-
return (0,
|
|
19353
|
+
return (0, import_node_path40.join)((0, import_node_os12.homedir)(), ".claude.json");
|
|
19284
19354
|
}
|
|
19285
19355
|
function asObject(value) {
|
|
19286
19356
|
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
@@ -19307,16 +19377,16 @@ function mergeSideboardIntoMcpServersJson(existing, sideboard) {
|
|
|
19307
19377
|
}
|
|
19308
19378
|
function writeMergedMcpServersJson(configPath, sideboard) {
|
|
19309
19379
|
let existing = {};
|
|
19310
|
-
if ((0,
|
|
19380
|
+
if ((0, import_node_fs43.existsSync)(configPath)) {
|
|
19311
19381
|
try {
|
|
19312
|
-
existing = JSON.parse((0,
|
|
19382
|
+
existing = JSON.parse((0, import_node_fs43.readFileSync)(configPath, "utf8"));
|
|
19313
19383
|
} catch {
|
|
19314
19384
|
existing = {};
|
|
19315
19385
|
}
|
|
19316
19386
|
}
|
|
19317
19387
|
const next = mergeSideboardIntoMcpServersJson(existing, sideboard);
|
|
19318
|
-
(0,
|
|
19319
|
-
(0,
|
|
19388
|
+
(0, import_node_fs43.mkdirSync)((0, import_node_path40.dirname)(configPath), { recursive: true });
|
|
19389
|
+
(0, import_node_fs43.writeFileSync)(configPath, `${JSON.stringify(next, null, 2)}
|
|
19320
19390
|
`);
|
|
19321
19391
|
}
|
|
19322
19392
|
function launchFromResolved(server) {
|
|
@@ -19334,7 +19404,7 @@ async function registerPackagedUserMcpClients() {
|
|
|
19334
19404
|
const cursor = userCursorMcpConfigPath();
|
|
19335
19405
|
writeMergedMcpServersJson(cursor, launch);
|
|
19336
19406
|
const claude = userClaudeMcpConfigPath();
|
|
19337
|
-
if ((0,
|
|
19407
|
+
if ((0, import_node_fs43.existsSync)(claude)) {
|
|
19338
19408
|
writeMergedMcpServersJson(claude, launch);
|
|
19339
19409
|
return { cursor, claude };
|
|
19340
19410
|
}
|
|
@@ -20748,9 +20818,9 @@ var import_node_http3 = require("http");
|
|
|
20748
20818
|
var import_ws3 = require("ws");
|
|
20749
20819
|
|
|
20750
20820
|
// src/slack/relay-static.ts
|
|
20751
|
-
var
|
|
20821
|
+
var import_node_fs44 = require("fs");
|
|
20752
20822
|
var import_promises = require("fs/promises");
|
|
20753
|
-
var
|
|
20823
|
+
var import_node_path41 = __toESM(require("path"), 1);
|
|
20754
20824
|
var TYPES = {
|
|
20755
20825
|
".css": "text/css; charset=utf-8",
|
|
20756
20826
|
".html": "text/html; charset=utf-8",
|
|
@@ -20781,9 +20851,9 @@ function resolveStaticPath(root, requestUrl) {
|
|
|
20781
20851
|
return null;
|
|
20782
20852
|
}
|
|
20783
20853
|
if (!pathname.startsWith("/") || pathname.includes("\0")) return null;
|
|
20784
|
-
const rootResolved =
|
|
20785
|
-
const candidate =
|
|
20786
|
-
if (candidate !== rootResolved && !candidate.startsWith(rootResolved +
|
|
20854
|
+
const rootResolved = import_node_path41.default.resolve(root);
|
|
20855
|
+
const candidate = import_node_path41.default.resolve(rootResolved, `.${pathname}`);
|
|
20856
|
+
if (candidate !== rootResolved && !candidate.startsWith(rootResolved + import_node_path41.default.sep)) {
|
|
20787
20857
|
return null;
|
|
20788
20858
|
}
|
|
20789
20859
|
return candidate;
|
|
@@ -20797,7 +20867,7 @@ async function fileSize(file) {
|
|
|
20797
20867
|
}
|
|
20798
20868
|
}
|
|
20799
20869
|
function sendFile(req, res, file, size) {
|
|
20800
|
-
const ext =
|
|
20870
|
+
const ext = import_node_path41.default.extname(file).toLowerCase();
|
|
20801
20871
|
res.writeHead(200, {
|
|
20802
20872
|
"Content-Type": TYPES[ext] ?? "application/octet-stream",
|
|
20803
20873
|
"Content-Length": size,
|
|
@@ -20807,7 +20877,7 @@ function sendFile(req, res, file, size) {
|
|
|
20807
20877
|
res.end();
|
|
20808
20878
|
return true;
|
|
20809
20879
|
}
|
|
20810
|
-
(0,
|
|
20880
|
+
(0, import_node_fs44.createReadStream)(file).pipe(res);
|
|
20811
20881
|
return true;
|
|
20812
20882
|
}
|
|
20813
20883
|
async function tryServeStatic(req, res, root) {
|
|
@@ -20816,7 +20886,7 @@ async function tryServeStatic(req, res, root) {
|
|
|
20816
20886
|
if (!candidate) return false;
|
|
20817
20887
|
const direct = await fileSize(candidate);
|
|
20818
20888
|
if (direct != null) return sendFile(req, res, candidate, direct);
|
|
20819
|
-
const asIndex =
|
|
20889
|
+
const asIndex = import_node_path41.default.join(candidate, "index.html");
|
|
20820
20890
|
const indexSize = await fileSize(asIndex);
|
|
20821
20891
|
if (indexSize != null) return sendFile(req, res, asIndex, indexSize);
|
|
20822
20892
|
return false;
|
|
@@ -21142,6 +21212,7 @@ async function startSlackRelayServer(opts) {
|
|
|
21142
21212
|
captureTurnBaseline,
|
|
21143
21213
|
checkoutPrStackLayer,
|
|
21144
21214
|
childEnvWithAppSettings,
|
|
21215
|
+
claimDesktopHost,
|
|
21145
21216
|
claudeAdapter,
|
|
21146
21217
|
claudeChromeEnabled,
|
|
21147
21218
|
claudeUserSettingsPath,
|
|
@@ -21180,6 +21251,7 @@ async function startSlackRelayServer(opts) {
|
|
|
21180
21251
|
decodeBrightsyTarget,
|
|
21181
21252
|
deleteBranchOnPurgeEnabled,
|
|
21182
21253
|
deleteThreadRecord,
|
|
21254
|
+
desktopHostPidPath,
|
|
21183
21255
|
detectAgents,
|
|
21184
21256
|
detectGhStack,
|
|
21185
21257
|
detectLocalMergeConflicts,
|
|
@@ -21305,6 +21377,7 @@ async function startSlackRelayServer(opts) {
|
|
|
21305
21377
|
isConductorBundledCli,
|
|
21306
21378
|
isCursorAutoModel,
|
|
21307
21379
|
isDefaultishSourceRef,
|
|
21380
|
+
isDesktopHostAlive,
|
|
21308
21381
|
isDirty,
|
|
21309
21382
|
isGhRateLimitError,
|
|
21310
21383
|
isGlobalRepoPath,
|
|
@@ -21326,6 +21399,7 @@ async function startSlackRelayServer(opts) {
|
|
|
21326
21399
|
isSlackExternalReplyPrompt,
|
|
21327
21400
|
isSlackOAuthCancelled,
|
|
21328
21401
|
isThinkingEffort,
|
|
21402
|
+
isThisProcessDesktopHost,
|
|
21329
21403
|
isThreadCaffeinated,
|
|
21330
21404
|
isWorkspaceScratchPath,
|
|
21331
21405
|
linearAuthorizationHeader,
|
|
@@ -21427,6 +21501,7 @@ async function startSlackRelayServer(opts) {
|
|
|
21427
21501
|
refreshSlackReplyBadges,
|
|
21428
21502
|
registerPackagedUserMcpClients,
|
|
21429
21503
|
releaseCaffeinateHoldForThread,
|
|
21504
|
+
releaseDesktopHost,
|
|
21430
21505
|
removeWorkspace,
|
|
21431
21506
|
removeWorktree,
|
|
21432
21507
|
repoSlug,
|
|
@@ -21527,6 +21602,7 @@ async function startSlackRelayServer(opts) {
|
|
|
21527
21602
|
taskMessageText,
|
|
21528
21603
|
thinkingEffortBars,
|
|
21529
21604
|
thinkingEffortLabel,
|
|
21605
|
+
thisProcessShouldDrainAgentQueues,
|
|
21530
21606
|
threadDisplayLabel,
|
|
21531
21607
|
threadFilePath,
|
|
21532
21608
|
threadLockPath,
|