@sideboard-ai/core 0.1.9
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/LICENSE +190 -0
- package/dist/agents/cursor-runner.cjs +173 -0
- package/dist/agents/cursor-runner.d.cts +1 -0
- package/dist/agents/cursor-runner.d.ts +1 -0
- package/dist/agents/cursor-runner.js +102 -0
- package/dist/agents-OAX7XPKX.js +41 -0
- package/dist/app-settings-BDMLWCWI.js +61 -0
- package/dist/chunk-2M4OHXYX.js +198 -0
- package/dist/chunk-2R5VV4BA.js +143 -0
- package/dist/chunk-3DKGI32Q.js +92 -0
- package/dist/chunk-3WF3X46L.js +373 -0
- package/dist/chunk-AJ6ROGD7.js +74 -0
- package/dist/chunk-E4PWXO2C.js +4534 -0
- package/dist/chunk-HYRHI3QU.js +154 -0
- package/dist/chunk-ILQK4P5R.js +311 -0
- package/dist/chunk-LL7DTZ5B.js +1282 -0
- package/dist/chunk-M37RITA6.js +304 -0
- package/dist/chunk-TLJH3L2C.js +80 -0
- package/dist/chunk-WMCPLDW3.js +1413 -0
- package/dist/connected-teams-GF52Q7LB.js +22 -0
- package/dist/coordinator-prompt-6R2TX4WQ.js +22 -0
- package/dist/global-workspace-R44HGBU6.js +36 -0
- package/dist/index.cjs +9940 -0
- package/dist/index.d.cts +2284 -0
- package/dist/index.d.ts +2284 -0
- package/dist/index.js +929 -0
- package/dist/mcp/run-stdio.cjs +8654 -0
- package/dist/mcp/run-stdio.d.cts +2 -0
- package/dist/mcp/run-stdio.d.ts +2 -0
- package/dist/mcp/run-stdio.js +21 -0
- package/dist/paths-VPH3ITBK.js +26 -0
- package/dist/run-LF6E5IKL.js +10 -0
- package/dist/thread-store-UNPZNIFW.js +27 -0
- package/dist/title-4A2ATYNY.js +24 -0
- package/dist/workspaces-TCJFYI35.js +20 -0
- package/dist/worktree-NGFDN3J4.js +79 -0
- package/package.json +63 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import {
|
|
2
|
+
appDataDir
|
|
3
|
+
} from "./chunk-M37RITA6.js";
|
|
4
|
+
|
|
5
|
+
// src/store/app-settings.ts
|
|
6
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
7
|
+
import { homedir } from "os";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
var HARNESS_ENV_KEYS = {
|
|
10
|
+
claude: "ANTHROPIC_API_KEY",
|
|
11
|
+
codex: "CODEX_API_KEY",
|
|
12
|
+
cursor: "CURSOR_API_KEY",
|
|
13
|
+
opencode: null,
|
|
14
|
+
brightsy: null
|
|
15
|
+
};
|
|
16
|
+
function appSettingsPath() {
|
|
17
|
+
return join(appDataDir(), "settings.json");
|
|
18
|
+
}
|
|
19
|
+
function claudeUserSettingsPath() {
|
|
20
|
+
return join(homedir(), ".claude", "settings.json");
|
|
21
|
+
}
|
|
22
|
+
function normalizeClaude(raw) {
|
|
23
|
+
if (!raw || typeof raw !== "object") return {};
|
|
24
|
+
const source = raw;
|
|
25
|
+
const out = {};
|
|
26
|
+
if (typeof source.executablePath === "string") {
|
|
27
|
+
const path = source.executablePath.trim();
|
|
28
|
+
if (path) out.executablePath = path;
|
|
29
|
+
}
|
|
30
|
+
if (typeof source.chromeEnabled === "boolean") {
|
|
31
|
+
out.chromeEnabled = source.chromeEnabled;
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
var CLOUD_CONNECT_AGENTS = /* @__PURE__ */ new Set([
|
|
36
|
+
"claude",
|
|
37
|
+
"codex",
|
|
38
|
+
"opencode",
|
|
39
|
+
"cursor"
|
|
40
|
+
]);
|
|
41
|
+
function normalizeBrightsy(raw) {
|
|
42
|
+
if (!raw || typeof raw !== "object") return {};
|
|
43
|
+
const source = raw;
|
|
44
|
+
const out = {};
|
|
45
|
+
if (typeof source.cloudConnectEnabled === "boolean") {
|
|
46
|
+
out.cloudConnectEnabled = source.cloudConnectEnabled;
|
|
47
|
+
}
|
|
48
|
+
if (typeof source.cloudConnectAgent === "string" && CLOUD_CONNECT_AGENTS.has(source.cloudConnectAgent)) {
|
|
49
|
+
out.cloudConnectAgent = source.cloudConnectAgent;
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
var ISSUE_SOURCES = /* @__PURE__ */ new Set(["linear", "github"]);
|
|
54
|
+
function normalizeIntegrations(raw) {
|
|
55
|
+
if (!raw || typeof raw !== "object") return {};
|
|
56
|
+
const source = raw;
|
|
57
|
+
const out = {};
|
|
58
|
+
if (typeof source.linearApiKey === "string") {
|
|
59
|
+
const key = source.linearApiKey.trim();
|
|
60
|
+
if (key) out.linearApiKey = key;
|
|
61
|
+
}
|
|
62
|
+
if (typeof source.issueSource === "string" && ISSUE_SOURCES.has(source.issueSource)) {
|
|
63
|
+
out.issueSource = source.issueSource;
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
function normalizeAdvanced(raw) {
|
|
68
|
+
if (!raw || typeof raw !== "object") return {};
|
|
69
|
+
const source = raw;
|
|
70
|
+
const out = {};
|
|
71
|
+
if (typeof source.autoRenameBranch === "boolean") {
|
|
72
|
+
out.autoRenameBranch = source.autoRenameBranch;
|
|
73
|
+
}
|
|
74
|
+
if (typeof source.autoRunAfterSetup === "boolean") {
|
|
75
|
+
out.autoRunAfterSetup = source.autoRunAfterSetup;
|
|
76
|
+
}
|
|
77
|
+
if (typeof source.caffeinateWhileRunning === "boolean") {
|
|
78
|
+
out.caffeinateWhileRunning = source.caffeinateWhileRunning;
|
|
79
|
+
}
|
|
80
|
+
if (typeof source.caffeinateWhileCloudConnect === "boolean") {
|
|
81
|
+
out.caffeinateWhileCloudConnect = source.caffeinateWhileCloudConnect;
|
|
82
|
+
}
|
|
83
|
+
if (typeof source.deleteBranchOnPurge === "boolean") {
|
|
84
|
+
out.deleteBranchOnPurge = source.deleteBranchOnPurge;
|
|
85
|
+
}
|
|
86
|
+
if (typeof source.maxConcurrent === "number" && Number.isFinite(source.maxConcurrent)) {
|
|
87
|
+
out.maxConcurrent = Math.max(1, Math.min(32, Math.floor(source.maxConcurrent)));
|
|
88
|
+
}
|
|
89
|
+
if (typeof source.worktreeMaxCount === "number" && Number.isFinite(source.worktreeMaxCount)) {
|
|
90
|
+
out.worktreeMaxCount = Math.max(1, Math.min(500, Math.floor(source.worktreeMaxCount)));
|
|
91
|
+
}
|
|
92
|
+
if (typeof source.worktreeCleanupIntervalHours === "number" && Number.isFinite(source.worktreeCleanupIntervalHours)) {
|
|
93
|
+
out.worktreeCleanupIntervalHours = Math.max(
|
|
94
|
+
1,
|
|
95
|
+
Math.min(168, Math.floor(source.worktreeCleanupIntervalHours))
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
if (typeof source.worktreeLastCleanupAt === "string" && source.worktreeLastCleanupAt.trim()) {
|
|
99
|
+
out.worktreeLastCleanupAt = source.worktreeLastCleanupAt.trim();
|
|
100
|
+
}
|
|
101
|
+
if (typeof source.autoCleanupOrphans === "boolean") {
|
|
102
|
+
out.autoCleanupOrphans = source.autoCleanupOrphans;
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
function normalizeSettings(raw) {
|
|
107
|
+
const env = {};
|
|
108
|
+
let claude = {};
|
|
109
|
+
let brightsy = {};
|
|
110
|
+
let integrations = {};
|
|
111
|
+
let advanced = {};
|
|
112
|
+
if (raw && typeof raw === "object") {
|
|
113
|
+
if ("environment" in raw) {
|
|
114
|
+
const source = raw.environment;
|
|
115
|
+
if (source && typeof source === "object") {
|
|
116
|
+
for (const [k, v] of Object.entries(source)) {
|
|
117
|
+
const key = k.trim();
|
|
118
|
+
if (!key) continue;
|
|
119
|
+
if (typeof v === "string" && v.length > 0) env[key] = v;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if ("claude" in raw) {
|
|
124
|
+
claude = normalizeClaude(raw.claude);
|
|
125
|
+
}
|
|
126
|
+
if ("brightsy" in raw) {
|
|
127
|
+
brightsy = normalizeBrightsy(raw.brightsy);
|
|
128
|
+
}
|
|
129
|
+
if ("integrations" in raw) {
|
|
130
|
+
integrations = normalizeIntegrations(
|
|
131
|
+
raw.integrations
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
if ("advanced" in raw) {
|
|
135
|
+
advanced = normalizeAdvanced(raw.advanced);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return { environment: env, claude, brightsy, integrations, advanced };
|
|
139
|
+
}
|
|
140
|
+
var EMPTY_SETTINGS = {
|
|
141
|
+
environment: {},
|
|
142
|
+
claude: {},
|
|
143
|
+
brightsy: {},
|
|
144
|
+
integrations: {},
|
|
145
|
+
advanced: {}
|
|
146
|
+
};
|
|
147
|
+
function loadAppSettings() {
|
|
148
|
+
const path = appSettingsPath();
|
|
149
|
+
if (!existsSync(path)) {
|
|
150
|
+
return { ...EMPTY_SETTINGS };
|
|
151
|
+
}
|
|
152
|
+
try {
|
|
153
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
154
|
+
return normalizeSettings(parsed);
|
|
155
|
+
} catch {
|
|
156
|
+
return { ...EMPTY_SETTINGS };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function saveAppSettings(settings) {
|
|
160
|
+
const normalized = normalizeSettings(settings);
|
|
161
|
+
mkdirSync(appDataDir(), { recursive: true });
|
|
162
|
+
writeFileSync(appSettingsPath(), `${JSON.stringify(normalized, null, 2)}
|
|
163
|
+
`, "utf8");
|
|
164
|
+
return normalized;
|
|
165
|
+
}
|
|
166
|
+
function updateAppEnvironment(patch) {
|
|
167
|
+
const current = loadAppSettings();
|
|
168
|
+
const environment = { ...current.environment };
|
|
169
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
170
|
+
const k = key.trim();
|
|
171
|
+
if (!k) continue;
|
|
172
|
+
if (value == null || value === "") {
|
|
173
|
+
delete environment[k];
|
|
174
|
+
} else {
|
|
175
|
+
environment[k] = value;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return saveAppSettings({ ...current, environment });
|
|
179
|
+
}
|
|
180
|
+
function updateClaudeSettings(patch) {
|
|
181
|
+
const current = loadAppSettings();
|
|
182
|
+
const claude = { ...current.claude };
|
|
183
|
+
if ("executablePath" in patch) {
|
|
184
|
+
if (patch.executablePath == null || patch.executablePath.trim() === "") {
|
|
185
|
+
delete claude.executablePath;
|
|
186
|
+
} else {
|
|
187
|
+
claude.executablePath = patch.executablePath.trim();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (typeof patch.chromeEnabled === "boolean") {
|
|
191
|
+
claude.chromeEnabled = patch.chromeEnabled;
|
|
192
|
+
}
|
|
193
|
+
return saveAppSettings({ ...current, claude });
|
|
194
|
+
}
|
|
195
|
+
function updateBrightsySettings(patch) {
|
|
196
|
+
const current = loadAppSettings();
|
|
197
|
+
const brightsy = { ...current.brightsy };
|
|
198
|
+
if (typeof patch.cloudConnectEnabled === "boolean") {
|
|
199
|
+
brightsy.cloudConnectEnabled = patch.cloudConnectEnabled;
|
|
200
|
+
}
|
|
201
|
+
if ("cloudConnectAgent" in patch) {
|
|
202
|
+
if (patch.cloudConnectAgent == null) {
|
|
203
|
+
delete brightsy.cloudConnectAgent;
|
|
204
|
+
} else if (CLOUD_CONNECT_AGENTS.has(patch.cloudConnectAgent)) {
|
|
205
|
+
brightsy.cloudConnectAgent = patch.cloudConnectAgent;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return saveAppSettings({ ...current, brightsy });
|
|
209
|
+
}
|
|
210
|
+
function updateIntegrationsSettings(patch) {
|
|
211
|
+
const current = loadAppSettings();
|
|
212
|
+
const integrations = { ...current.integrations };
|
|
213
|
+
if ("linearApiKey" in patch) {
|
|
214
|
+
if (patch.linearApiKey == null || patch.linearApiKey.trim() === "") {
|
|
215
|
+
delete integrations.linearApiKey;
|
|
216
|
+
} else {
|
|
217
|
+
integrations.linearApiKey = patch.linearApiKey.trim();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if ("issueSource" in patch) {
|
|
221
|
+
if (patch.issueSource == null) {
|
|
222
|
+
delete integrations.issueSource;
|
|
223
|
+
} else if (ISSUE_SOURCES.has(patch.issueSource)) {
|
|
224
|
+
integrations.issueSource = patch.issueSource;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return saveAppSettings({ ...current, integrations });
|
|
228
|
+
}
|
|
229
|
+
function isLinearConnected(settings = loadAppSettings()) {
|
|
230
|
+
return Boolean(settings.integrations.linearApiKey?.trim());
|
|
231
|
+
}
|
|
232
|
+
function getIssueSource(settings = loadAppSettings()) {
|
|
233
|
+
return settings.integrations.issueSource ?? "github";
|
|
234
|
+
}
|
|
235
|
+
function resolveEffectiveIssueSource(settings = loadAppSettings()) {
|
|
236
|
+
const preferred = getIssueSource(settings);
|
|
237
|
+
if (preferred === "linear" && !isLinearConnected(settings)) return "github";
|
|
238
|
+
return preferred;
|
|
239
|
+
}
|
|
240
|
+
function getLinearApiKey(settings = loadAppSettings()) {
|
|
241
|
+
const key = settings.integrations.linearApiKey?.trim();
|
|
242
|
+
return key || null;
|
|
243
|
+
}
|
|
244
|
+
function brightsyCloudConnectEnabled(settings = loadAppSettings()) {
|
|
245
|
+
return Boolean(settings.brightsy.cloudConnectEnabled);
|
|
246
|
+
}
|
|
247
|
+
function brightsyCloudConnectAgent(settings = loadAppSettings()) {
|
|
248
|
+
return settings.brightsy.cloudConnectAgent ?? "claude";
|
|
249
|
+
}
|
|
250
|
+
function updateAdvancedSettings(patch) {
|
|
251
|
+
const current = loadAppSettings();
|
|
252
|
+
const advanced = { ...current.advanced };
|
|
253
|
+
if (typeof patch.autoRenameBranch === "boolean") {
|
|
254
|
+
advanced.autoRenameBranch = patch.autoRenameBranch;
|
|
255
|
+
}
|
|
256
|
+
if (typeof patch.autoRunAfterSetup === "boolean") {
|
|
257
|
+
advanced.autoRunAfterSetup = patch.autoRunAfterSetup;
|
|
258
|
+
}
|
|
259
|
+
if (typeof patch.caffeinateWhileRunning === "boolean") {
|
|
260
|
+
advanced.caffeinateWhileRunning = patch.caffeinateWhileRunning;
|
|
261
|
+
}
|
|
262
|
+
if (typeof patch.caffeinateWhileCloudConnect === "boolean") {
|
|
263
|
+
advanced.caffeinateWhileCloudConnect = patch.caffeinateWhileCloudConnect;
|
|
264
|
+
}
|
|
265
|
+
if (typeof patch.deleteBranchOnPurge === "boolean") {
|
|
266
|
+
advanced.deleteBranchOnPurge = patch.deleteBranchOnPurge;
|
|
267
|
+
}
|
|
268
|
+
if (typeof patch.maxConcurrent === "number" && Number.isFinite(patch.maxConcurrent)) {
|
|
269
|
+
advanced.maxConcurrent = Math.max(1, Math.min(32, Math.floor(patch.maxConcurrent)));
|
|
270
|
+
}
|
|
271
|
+
if (typeof patch.worktreeMaxCount === "number" && Number.isFinite(patch.worktreeMaxCount)) {
|
|
272
|
+
advanced.worktreeMaxCount = Math.max(1, Math.min(500, Math.floor(patch.worktreeMaxCount)));
|
|
273
|
+
}
|
|
274
|
+
if (typeof patch.worktreeCleanupIntervalHours === "number" && Number.isFinite(patch.worktreeCleanupIntervalHours)) {
|
|
275
|
+
advanced.worktreeCleanupIntervalHours = Math.max(
|
|
276
|
+
1,
|
|
277
|
+
Math.min(168, Math.floor(patch.worktreeCleanupIntervalHours))
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
if (typeof patch.worktreeLastCleanupAt === "string") {
|
|
281
|
+
advanced.worktreeLastCleanupAt = patch.worktreeLastCleanupAt;
|
|
282
|
+
}
|
|
283
|
+
if (typeof patch.autoCleanupOrphans === "boolean") {
|
|
284
|
+
advanced.autoCleanupOrphans = patch.autoCleanupOrphans;
|
|
285
|
+
}
|
|
286
|
+
return saveAppSettings({ ...current, advanced });
|
|
287
|
+
}
|
|
288
|
+
function autoRenameBranchEnabled(settings = loadAppSettings()) {
|
|
289
|
+
return settings.advanced.autoRenameBranch !== false;
|
|
290
|
+
}
|
|
291
|
+
function autoRunAfterSetupEnabled(settings = loadAppSettings()) {
|
|
292
|
+
return Boolean(settings.advanced.autoRunAfterSetup);
|
|
293
|
+
}
|
|
294
|
+
function caffeinateWhileRunningEnabled(settings = loadAppSettings()) {
|
|
295
|
+
return Boolean(settings.advanced.caffeinateWhileRunning);
|
|
296
|
+
}
|
|
297
|
+
function caffeinateWhileCloudConnectEnabled(settings = loadAppSettings()) {
|
|
298
|
+
return Boolean(settings.advanced.caffeinateWhileCloudConnect);
|
|
299
|
+
}
|
|
300
|
+
function deleteBranchOnPurgeEnabled(settings = loadAppSettings()) {
|
|
301
|
+
return Boolean(settings.advanced.deleteBranchOnPurge);
|
|
302
|
+
}
|
|
303
|
+
function autoCleanupOrphansEnabled(settings = loadAppSettings()) {
|
|
304
|
+
return Boolean(settings.advanced.autoCleanupOrphans);
|
|
305
|
+
}
|
|
306
|
+
function maxConcurrentAgents(settings = loadAppSettings()) {
|
|
307
|
+
const n = settings.advanced.maxConcurrent;
|
|
308
|
+
if (typeof n === "number" && Number.isFinite(n)) {
|
|
309
|
+
return Math.max(1, Math.min(32, Math.floor(n)));
|
|
310
|
+
}
|
|
311
|
+
return 3;
|
|
312
|
+
}
|
|
313
|
+
function resolveClaudeExecutable(settings = loadAppSettings()) {
|
|
314
|
+
const override = settings.claude.executablePath?.trim();
|
|
315
|
+
return override || "claude";
|
|
316
|
+
}
|
|
317
|
+
function claudeChromeEnabled(settings = loadAppSettings()) {
|
|
318
|
+
return Boolean(settings.claude.chromeEnabled);
|
|
319
|
+
}
|
|
320
|
+
function applyAppEnvironment(target = process.env, settings = loadAppSettings()) {
|
|
321
|
+
for (const [key, value] of Object.entries(settings.environment)) {
|
|
322
|
+
if (!key || value == null || value === "") continue;
|
|
323
|
+
if (target[key] == null || target[key] === "") {
|
|
324
|
+
target[key] = value;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return target;
|
|
328
|
+
}
|
|
329
|
+
function childEnvWithAppSettings(extra) {
|
|
330
|
+
const settings = loadAppSettings();
|
|
331
|
+
const env = { ...process.env };
|
|
332
|
+
applyAppEnvironment(env, settings);
|
|
333
|
+
if (extra) {
|
|
334
|
+
for (const [k, v] of Object.entries(extra)) {
|
|
335
|
+
if (v != null) env[k] = v;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return env;
|
|
339
|
+
}
|
|
340
|
+
function harnessEnvKey(harness) {
|
|
341
|
+
return HARNESS_ENV_KEYS[harness];
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export {
|
|
345
|
+
HARNESS_ENV_KEYS,
|
|
346
|
+
appSettingsPath,
|
|
347
|
+
claudeUserSettingsPath,
|
|
348
|
+
loadAppSettings,
|
|
349
|
+
saveAppSettings,
|
|
350
|
+
updateAppEnvironment,
|
|
351
|
+
updateClaudeSettings,
|
|
352
|
+
updateBrightsySettings,
|
|
353
|
+
updateIntegrationsSettings,
|
|
354
|
+
isLinearConnected,
|
|
355
|
+
getIssueSource,
|
|
356
|
+
resolveEffectiveIssueSource,
|
|
357
|
+
getLinearApiKey,
|
|
358
|
+
brightsyCloudConnectEnabled,
|
|
359
|
+
brightsyCloudConnectAgent,
|
|
360
|
+
updateAdvancedSettings,
|
|
361
|
+
autoRenameBranchEnabled,
|
|
362
|
+
autoRunAfterSetupEnabled,
|
|
363
|
+
caffeinateWhileRunningEnabled,
|
|
364
|
+
caffeinateWhileCloudConnectEnabled,
|
|
365
|
+
deleteBranchOnPurgeEnabled,
|
|
366
|
+
autoCleanupOrphansEnabled,
|
|
367
|
+
maxConcurrentAgents,
|
|
368
|
+
resolveClaudeExecutable,
|
|
369
|
+
claudeChromeEnabled,
|
|
370
|
+
applyAppEnvironment,
|
|
371
|
+
childEnvWithAppSettings,
|
|
372
|
+
harnessEnvKey
|
|
373
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// src/git/run.ts
|
|
2
|
+
import { execa } from "execa";
|
|
3
|
+
|
|
4
|
+
// src/agents/path.ts
|
|
5
|
+
import { homedir } from "os";
|
|
6
|
+
import { delimiter } from "path";
|
|
7
|
+
var EXTRA_BIN_DIRS = [
|
|
8
|
+
".local/bin",
|
|
9
|
+
".cargo/bin",
|
|
10
|
+
".nvm/current/bin",
|
|
11
|
+
".asdf/shims",
|
|
12
|
+
// pnpm / npm global bins (where `@brightsy/cli` typically lands)
|
|
13
|
+
"Library/pnpm",
|
|
14
|
+
".pnpm"
|
|
15
|
+
];
|
|
16
|
+
function ensureAgentPath(env = process.env) {
|
|
17
|
+
const home = env.HOME || env.USERPROFILE || homedir();
|
|
18
|
+
const current = env.PATH ?? "";
|
|
19
|
+
const parts = current.split(delimiter).filter(Boolean);
|
|
20
|
+
const seen = new Set(parts);
|
|
21
|
+
const extras = [
|
|
22
|
+
...EXTRA_BIN_DIRS.map((rel) => `${home}/${rel}`),
|
|
23
|
+
"/opt/homebrew/bin",
|
|
24
|
+
"/usr/local/bin"
|
|
25
|
+
];
|
|
26
|
+
for (const dir of extras.reverse()) {
|
|
27
|
+
if (!dir || seen.has(dir)) continue;
|
|
28
|
+
parts.unshift(dir);
|
|
29
|
+
seen.add(dir);
|
|
30
|
+
}
|
|
31
|
+
const next = parts.join(delimiter);
|
|
32
|
+
env.PATH = next;
|
|
33
|
+
return next;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/git/run.ts
|
|
37
|
+
async function run(file, args, opts) {
|
|
38
|
+
ensureAgentPath();
|
|
39
|
+
try {
|
|
40
|
+
const result = await execa(file, args, {
|
|
41
|
+
cwd: opts?.cwd,
|
|
42
|
+
env: { ...process.env, ...opts?.env },
|
|
43
|
+
reject: opts?.reject ?? true
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
stdout: result.stdout ?? "",
|
|
47
|
+
stderr: result.stderr ?? "",
|
|
48
|
+
exitCode: result.exitCode ?? 0
|
|
49
|
+
};
|
|
50
|
+
} catch (err) {
|
|
51
|
+
const e = err;
|
|
52
|
+
if (opts?.reject === false) {
|
|
53
|
+
return {
|
|
54
|
+
stdout: String(e.stdout ?? ""),
|
|
55
|
+
stderr: String(e.stderr ?? ""),
|
|
56
|
+
exitCode: e.exitCode ?? 1
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
throw err;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async function git(args, cwd, opts) {
|
|
63
|
+
return run("git", args, { cwd, reject: opts?.reject });
|
|
64
|
+
}
|
|
65
|
+
async function gh(args, cwd, opts) {
|
|
66
|
+
return run("gh", args, { cwd, reject: opts?.reject });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
ensureAgentPath,
|
|
71
|
+
run,
|
|
72
|
+
git,
|
|
73
|
+
gh
|
|
74
|
+
};
|