codeam-cli 2.76.2 → 2.76.3
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/CHANGELOG.md +6 -0
- package/dist/index.js +824 -763
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -357,8 +357,8 @@ function defaultSpawn(timeoutMs) {
|
|
|
357
357
|
});
|
|
358
358
|
}
|
|
359
359
|
function resolveConvexBin(cwd) {
|
|
360
|
-
const local =
|
|
361
|
-
if (
|
|
360
|
+
const local = path104.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
|
|
361
|
+
if (fs90.existsSync(local)) return { cmd: local, args: [] };
|
|
362
362
|
return { cmd: "npx", args: ["--yes", "convex"] };
|
|
363
363
|
}
|
|
364
364
|
function redact(text, key) {
|
|
@@ -489,13 +489,13 @@ async function runConvexAdminMcp(client3, id) {
|
|
|
489
489
|
});
|
|
490
490
|
await server.connect(new StdioServerTransport());
|
|
491
491
|
}
|
|
492
|
-
var import_node_child_process37,
|
|
492
|
+
var import_node_child_process37, fs90, path104, TOOLS;
|
|
493
493
|
var init_convex_admin_mcp = __esm({
|
|
494
494
|
"src/integrations/convex-admin-mcp.ts"() {
|
|
495
495
|
"use strict";
|
|
496
496
|
import_node_child_process37 = require("child_process");
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
fs90 = __toESM(require("fs"));
|
|
498
|
+
path104 = __toESM(require("path"));
|
|
499
499
|
TOOLS = [
|
|
500
500
|
{
|
|
501
501
|
name: "tables",
|
|
@@ -3595,11 +3595,11 @@ function quiet(fn) {
|
|
|
3595
3595
|
log.debug(TAG, "ignored sync error", err);
|
|
3596
3596
|
}
|
|
3597
3597
|
}
|
|
3598
|
-
function rmIfExistsQuiet(
|
|
3598
|
+
function rmIfExistsQuiet(path106) {
|
|
3599
3599
|
try {
|
|
3600
|
-
fs2.rmSync(
|
|
3600
|
+
fs2.rmSync(path106, { force: true });
|
|
3601
3601
|
} catch (err) {
|
|
3602
|
-
log.debug(TAG, `rmIfExists failed for ${
|
|
3602
|
+
log.debug(TAG, `rmIfExists failed for ${path106}`, err);
|
|
3603
3603
|
}
|
|
3604
3604
|
}
|
|
3605
3605
|
function killQuiet(target, signal = "SIGTERM") {
|
|
@@ -3765,9 +3765,9 @@ var _default = makeConfig();
|
|
|
3765
3765
|
var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, setSessionAgent, setSquadAuto, getSquadAuto, clearAll, saveCliConfig, loadCliConfig } = _default;
|
|
3766
3766
|
|
|
3767
3767
|
// src/commands/pair-auto.ts
|
|
3768
|
-
var
|
|
3769
|
-
var
|
|
3770
|
-
var
|
|
3768
|
+
var fs62 = __toESM(require("fs"));
|
|
3769
|
+
var os46 = __toESM(require("os"));
|
|
3770
|
+
var path71 = __toESM(require("path"));
|
|
3771
3771
|
var import_crypto4 = require("crypto");
|
|
3772
3772
|
|
|
3773
3773
|
// src/services/telemetry.service.ts
|
|
@@ -3803,8 +3803,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
3803
3803
|
return decodedFile;
|
|
3804
3804
|
};
|
|
3805
3805
|
}
|
|
3806
|
-
function normalizeWindowsPath(
|
|
3807
|
-
return
|
|
3806
|
+
function normalizeWindowsPath(path106) {
|
|
3807
|
+
return path106.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
3808
3808
|
}
|
|
3809
3809
|
|
|
3810
3810
|
// ../../node_modules/@posthog/core/dist/error-tracking/index.mjs
|
|
@@ -6537,13 +6537,13 @@ var PostHogCoreStateless = class {
|
|
|
6537
6537
|
sentFromRoute += batchMessages.length;
|
|
6538
6538
|
}
|
|
6539
6539
|
}
|
|
6540
|
-
async _sendOtlpBatch({ path:
|
|
6540
|
+
async _sendOtlpBatch({ path: path106, payload }) {
|
|
6541
6541
|
if (this.disabled) return {
|
|
6542
6542
|
kind: "fatal",
|
|
6543
6543
|
error: new Error("The client is disabled")
|
|
6544
6544
|
};
|
|
6545
6545
|
const serialized = JSON.stringify(payload);
|
|
6546
|
-
const url2 = `${this.host}/i/v1/${
|
|
6546
|
+
const url2 = `${this.host}/i/v1/${path106}?token=${encodeURIComponent(this.apiKey)}`;
|
|
6547
6547
|
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
6548
6548
|
const fetchOptions = {
|
|
6549
6549
|
method: "POST",
|
|
@@ -7783,14 +7783,14 @@ async function addSourceContext(frames, openSourceFile = import_promises.open, l
|
|
|
7783
7783
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
7784
7784
|
return frames;
|
|
7785
7785
|
}
|
|
7786
|
-
async function openRegularSourceFile(
|
|
7786
|
+
async function openRegularSourceFile(path106, openSourceFile, logger) {
|
|
7787
7787
|
let fileHandle;
|
|
7788
7788
|
let isValid = false;
|
|
7789
7789
|
try {
|
|
7790
|
-
fileHandle = await openSourceFile(
|
|
7790
|
+
fileHandle = await openSourceFile(path106, import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NONBLOCK);
|
|
7791
7791
|
const fileStat = await fileHandle.stat();
|
|
7792
7792
|
if (!fileStat.isFile()) return;
|
|
7793
|
-
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${
|
|
7793
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path106}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
|
|
7794
7794
|
isValid = true;
|
|
7795
7795
|
return fileHandle;
|
|
7796
7796
|
} catch {
|
|
@@ -7800,8 +7800,8 @@ async function openRegularSourceFile(path105, openSourceFile, logger) {
|
|
|
7800
7800
|
});
|
|
7801
7801
|
}
|
|
7802
7802
|
}
|
|
7803
|
-
async function getContextLinesFromFile(
|
|
7804
|
-
const fileHandle = await openRegularSourceFile(
|
|
7803
|
+
async function getContextLinesFromFile(path106, ranges, output, cacheKey, openSourceFile, logger) {
|
|
7804
|
+
const fileHandle = await openRegularSourceFile(path106, openSourceFile, logger);
|
|
7805
7805
|
if (void 0 === fileHandle) return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
7806
7806
|
const openedFileHandle = fileHandle;
|
|
7807
7807
|
return new Promise((resolve12) => {
|
|
@@ -7903,22 +7903,22 @@ function clearLineContext(frame) {
|
|
|
7903
7903
|
delete frame.context_line;
|
|
7904
7904
|
delete frame.post_context;
|
|
7905
7905
|
}
|
|
7906
|
-
function shouldSkipContextLinesForFile(
|
|
7907
|
-
return
|
|
7906
|
+
function shouldSkipContextLinesForFile(path106) {
|
|
7907
|
+
return path106.startsWith("node:") || path106.endsWith(".min.js") || path106.endsWith(".min.cjs") || path106.endsWith(".min.mjs") || path106.startsWith("data:");
|
|
7908
7908
|
}
|
|
7909
7909
|
function shouldSkipContextLinesForFrame(frame) {
|
|
7910
7910
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
7911
7911
|
if (void 0 !== frame.colno && frame.colno > MAX_CONTEXTLINES_COLNO) return true;
|
|
7912
7912
|
return false;
|
|
7913
7913
|
}
|
|
7914
|
-
function makeSourceCacheKey(
|
|
7915
|
-
if ((0, import_node_path.isAbsolute)(
|
|
7914
|
+
function makeSourceCacheKey(path106, basePath) {
|
|
7915
|
+
if ((0, import_node_path.isAbsolute)(path106)) return JSON.stringify([
|
|
7916
7916
|
null,
|
|
7917
|
-
|
|
7917
|
+
path106
|
|
7918
7918
|
]);
|
|
7919
7919
|
return void 0 === basePath ? void 0 : JSON.stringify([
|
|
7920
7920
|
basePath,
|
|
7921
|
-
|
|
7921
|
+
path106
|
|
7922
7922
|
]);
|
|
7923
7923
|
}
|
|
7924
7924
|
function rangeExistsInContentCache(cacheKey, range) {
|
|
@@ -10579,7 +10579,7 @@ function readAnonId() {
|
|
|
10579
10579
|
}
|
|
10580
10580
|
function superProperties() {
|
|
10581
10581
|
return {
|
|
10582
|
-
cliVersion: true ? "2.76.
|
|
10582
|
+
cliVersion: true ? "2.76.3" : "0.0.0-dev",
|
|
10583
10583
|
nodeVersion: process.version,
|
|
10584
10584
|
platform: process.platform,
|
|
10585
10585
|
arch: process.arch,
|
|
@@ -10824,7 +10824,7 @@ var http = __toESM(require("http"));
|
|
|
10824
10824
|
// package.json
|
|
10825
10825
|
var package_default = {
|
|
10826
10826
|
name: "codeam-cli",
|
|
10827
|
-
version: "2.76.
|
|
10827
|
+
version: "2.76.3",
|
|
10828
10828
|
description: "Workflow-continuity bridge for AI coding agents. Wrap Claude Code or Codex in a PTY and supervise, approve, and redirect the session from any device \u2014 async. The terminal companion for CodeAgent Mobile.",
|
|
10829
10829
|
type: "commonjs",
|
|
10830
10830
|
main: "dist/index.js",
|
|
@@ -12160,7 +12160,7 @@ var CommandRelayService = class _CommandRelayService {
|
|
|
12160
12160
|
// fresh + clear the "CLI update available" banner after a self-update
|
|
12161
12161
|
// (a codespace that reinstalls @latest reconnects via heartbeat, not
|
|
12162
12162
|
// pair/reconnect). Older backends ignore the extra field.
|
|
12163
|
-
..."2.76.
|
|
12163
|
+
..."2.76.3" ? { ideVersion: "2.76.3" } : {}
|
|
12164
12164
|
};
|
|
12165
12165
|
try {
|
|
12166
12166
|
const res = await _postJson(`${API_BASE2}/api/plugin/heartbeat`, body);
|
|
@@ -12478,10 +12478,10 @@ var WINDOWS_LEGACY_JUNCTIONS = [
|
|
|
12478
12478
|
/[\\/]Start Menu([\\/]|$)/i,
|
|
12479
12479
|
/[\\/]Templates([\\/]|$)/i
|
|
12480
12480
|
];
|
|
12481
|
-
function isUnsafeWindowsWatchRoot(dir,
|
|
12481
|
+
function isUnsafeWindowsWatchRoot(dir, homedir52) {
|
|
12482
12482
|
const norm = (p2) => p2.replace(/\//g, "\\").replace(/\\+$/, "").toLowerCase();
|
|
12483
12483
|
const cwd = norm(dir);
|
|
12484
|
-
const home = norm(
|
|
12484
|
+
const home = norm(homedir52);
|
|
12485
12485
|
if (cwd === home) return true;
|
|
12486
12486
|
if (/^[a-z]:$/.test(cwd)) return true;
|
|
12487
12487
|
const sysRoots = [
|
|
@@ -13636,9 +13636,9 @@ function closeAllTerminals() {
|
|
|
13636
13636
|
}
|
|
13637
13637
|
|
|
13638
13638
|
// src/commands/start/handlers.ts
|
|
13639
|
-
var
|
|
13640
|
-
var
|
|
13641
|
-
var
|
|
13639
|
+
var fs61 = __toESM(require("fs"));
|
|
13640
|
+
var os45 = __toESM(require("os"));
|
|
13641
|
+
var path70 = __toESM(require("path"));
|
|
13642
13642
|
var import_crypto3 = require("crypto");
|
|
13643
13643
|
var import_child_process25 = require("child_process");
|
|
13644
13644
|
|
|
@@ -14490,7 +14490,7 @@ function findGitRoot2(startDir) {
|
|
|
14490
14490
|
// src/commands/link.ts
|
|
14491
14491
|
var import_node_crypto8 = require("crypto");
|
|
14492
14492
|
var fs30 = __toESM(require("fs"));
|
|
14493
|
-
var
|
|
14493
|
+
var path37 = __toESM(require("path"));
|
|
14494
14494
|
var import_chokidar = __toESM(require("chokidar"));
|
|
14495
14495
|
var import_picocolors2 = __toESM(require("picocolors"));
|
|
14496
14496
|
|
|
@@ -17237,10 +17237,10 @@ function buildForPlatform(platform3) {
|
|
|
17237
17237
|
var import_node_crypto4 = require("crypto");
|
|
17238
17238
|
|
|
17239
17239
|
// src/agents/claude/resolver.ts
|
|
17240
|
-
function buildClaudeLaunch(extraArgs = [],
|
|
17241
|
-
const found =
|
|
17240
|
+
function buildClaudeLaunch(extraArgs = [], os68 = createOsStrategy()) {
|
|
17241
|
+
const found = os68.findInPath("claude") ?? os68.findInPath("claude-code");
|
|
17242
17242
|
if (!found) return null;
|
|
17243
|
-
return
|
|
17243
|
+
return os68.buildLaunch(found, extraArgs);
|
|
17244
17244
|
}
|
|
17245
17245
|
|
|
17246
17246
|
// src/agents/claude/installer.ts
|
|
@@ -17664,14 +17664,27 @@ async function spawnAndCapture(cmd, args2, opts = {}) {
|
|
|
17664
17664
|
|
|
17665
17665
|
// src/agents/claude/history.ts
|
|
17666
17666
|
var fs14 = __toESM(require("fs"));
|
|
17667
|
-
|
|
17667
|
+
|
|
17668
|
+
// src/agents/claude-memory-file.ts
|
|
17668
17669
|
var os12 = __toESM(require("os"));
|
|
17670
|
+
var path18 = __toESM(require("path"));
|
|
17671
|
+
function claudeMemoryFile(homeDir2, env = process.env) {
|
|
17672
|
+
if (homeDir2) return path18.join(homeDir2, ".claude", "CLAUDE.md");
|
|
17673
|
+
return path18.join(claudeConfigDir(env), "CLAUDE.md");
|
|
17674
|
+
}
|
|
17675
|
+
function claudeConfigDir(env = process.env) {
|
|
17676
|
+
const configDir = env.CLAUDE_CONFIG_DIR?.trim();
|
|
17677
|
+
return configDir ? configDir : path18.join(os12.homedir(), ".claude");
|
|
17678
|
+
}
|
|
17679
|
+
|
|
17680
|
+
// src/agents/claude/history.ts
|
|
17681
|
+
var path19 = __toESM(require("path"));
|
|
17669
17682
|
function encodeCwd(cwd) {
|
|
17670
17683
|
return cwd.replace(/[\\/:_]/g, "-");
|
|
17671
17684
|
}
|
|
17672
17685
|
function resolveHistoryDir(cwd, projectsRoot) {
|
|
17673
|
-
const root = projectsRoot ??
|
|
17674
|
-
const primary =
|
|
17686
|
+
const root = projectsRoot ?? path19.join(claudeConfigDir(), "projects");
|
|
17687
|
+
const primary = path19.join(root, encodeCwd(cwd));
|
|
17675
17688
|
if (fs14.existsSync(primary)) return primary;
|
|
17676
17689
|
try {
|
|
17677
17690
|
const entries2 = fs14.readdirSync(root, { withFileTypes: true });
|
|
@@ -17680,7 +17693,7 @@ function resolveHistoryDir(cwd, projectsRoot) {
|
|
|
17680
17693
|
if (!e.isDirectory()) continue;
|
|
17681
17694
|
const candidate = e.name.replace(/-+/g, "-");
|
|
17682
17695
|
if (candidate === wanted.replace(/-+/g, "-")) {
|
|
17683
|
-
return
|
|
17696
|
+
return path19.join(root, e.name);
|
|
17684
17697
|
}
|
|
17685
17698
|
}
|
|
17686
17699
|
} catch {
|
|
@@ -17690,7 +17703,7 @@ function resolveHistoryDir(cwd, projectsRoot) {
|
|
|
17690
17703
|
function resolveHistoryFile(cwd, sessionId, projectsRoot) {
|
|
17691
17704
|
const dir = resolveHistoryDir(cwd, projectsRoot);
|
|
17692
17705
|
if (!dir) return null;
|
|
17693
|
-
const filePath =
|
|
17706
|
+
const filePath = path19.join(dir, `${sessionId}.jsonl`);
|
|
17694
17707
|
return fs14.existsSync(filePath) ? filePath : null;
|
|
17695
17708
|
}
|
|
17696
17709
|
function getCurrentUsage(historyDir, bootTimeMs = 0) {
|
|
@@ -17704,14 +17717,14 @@ function getCurrentUsage(historyDir, bootTimeMs = 0) {
|
|
|
17704
17717
|
}
|
|
17705
17718
|
const files = entries2.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
17706
17719
|
try {
|
|
17707
|
-
const stat3 = fs14.statSync(
|
|
17720
|
+
const stat3 = fs14.statSync(path19.join(historyDir, e.name));
|
|
17708
17721
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
17709
17722
|
} catch {
|
|
17710
17723
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
17711
17724
|
}
|
|
17712
17725
|
}).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
17713
17726
|
if (files.length === 0) return null;
|
|
17714
|
-
const filePath =
|
|
17727
|
+
const filePath = path19.join(historyDir, files[0].name);
|
|
17715
17728
|
let raw;
|
|
17716
17729
|
try {
|
|
17717
17730
|
raw = fs14.readFileSync(filePath, "utf8");
|
|
@@ -17813,7 +17826,7 @@ function listResumableSessions(cwd) {
|
|
|
17813
17826
|
for (const entry of entries2) {
|
|
17814
17827
|
if (!entry.isFile() || !entry.name.endsWith(".jsonl")) continue;
|
|
17815
17828
|
const id = entry.name.slice(0, -".jsonl".length);
|
|
17816
|
-
const filePath =
|
|
17829
|
+
const filePath = path19.join(dir, entry.name);
|
|
17817
17830
|
let timestamp = Date.now();
|
|
17818
17831
|
try {
|
|
17819
17832
|
timestamp = fs14.statSync(filePath).mtimeMs;
|
|
@@ -17918,7 +17931,7 @@ function appendedTailHasResumeMarker(filePath, fromOffset) {
|
|
|
17918
17931
|
}
|
|
17919
17932
|
}
|
|
17920
17933
|
function watchConversationSwitch(cwd, opts, onSwitch, projectsRoot) {
|
|
17921
|
-
const root = projectsRoot ??
|
|
17934
|
+
const root = projectsRoot ?? path19.join(claudeConfigDir(), "projects");
|
|
17922
17935
|
let currentId = opts.currentId;
|
|
17923
17936
|
const baseline = /* @__PURE__ */ new Map();
|
|
17924
17937
|
const unclassified = /* @__PURE__ */ new Map();
|
|
@@ -17933,7 +17946,7 @@ function watchConversationSwitch(cwd, opts, onSwitch, projectsRoot) {
|
|
|
17933
17946
|
}
|
|
17934
17947
|
};
|
|
17935
17948
|
const switchTo = (dir, id, kind) => {
|
|
17936
|
-
const leaving = fileSize(
|
|
17949
|
+
const leaving = fileSize(path19.join(dir, `${currentId}.jsonl`));
|
|
17937
17950
|
if (leaving !== null) baseline.set(currentId, leaving);
|
|
17938
17951
|
baseline.delete(id);
|
|
17939
17952
|
unclassified.delete(id);
|
|
@@ -17952,7 +17965,7 @@ function watchConversationSwitch(cwd, opts, onSwitch, projectsRoot) {
|
|
|
17952
17965
|
if (!name.endsWith(".jsonl")) continue;
|
|
17953
17966
|
const id = name.slice(0, -".jsonl".length);
|
|
17954
17967
|
if (id === currentId) continue;
|
|
17955
|
-
const file =
|
|
17968
|
+
const file = path19.join(dir, name);
|
|
17956
17969
|
const size = fileSize(file);
|
|
17957
17970
|
if (size === null) continue;
|
|
17958
17971
|
const known = baseline.get(id);
|
|
@@ -17982,7 +17995,7 @@ function watchConversationSwitch(cwd, opts, onSwitch, projectsRoot) {
|
|
|
17982
17995
|
if (!name.endsWith(".jsonl")) continue;
|
|
17983
17996
|
const id = name.slice(0, -".jsonl".length);
|
|
17984
17997
|
if (id === currentId) continue;
|
|
17985
|
-
const size = fileSize(
|
|
17998
|
+
const size = fileSize(path19.join(dir, name));
|
|
17986
17999
|
if (size !== null) baseline.set(id, size);
|
|
17987
18000
|
}
|
|
17988
18001
|
} catch {
|
|
@@ -18020,8 +18033,8 @@ var ClaudeRuntimeStrategy = class {
|
|
|
18020
18033
|
meta = getAgent("claude");
|
|
18021
18034
|
mode = "interactive";
|
|
18022
18035
|
os;
|
|
18023
|
-
constructor(
|
|
18024
|
-
this.os =
|
|
18036
|
+
constructor(os68) {
|
|
18037
|
+
this.os = os68;
|
|
18025
18038
|
}
|
|
18026
18039
|
/**
|
|
18027
18040
|
* Claude Code's react-ink TUI enables bracketed-paste mode at
|
|
@@ -18168,18 +18181,18 @@ var ClaudeRuntimeStrategy = class {
|
|
|
18168
18181
|
// src/agents/claude/deploy.ts
|
|
18169
18182
|
var fs16 = __toESM(require("fs"));
|
|
18170
18183
|
var os14 = __toESM(require("os"));
|
|
18171
|
-
var
|
|
18184
|
+
var path21 = __toESM(require("path"));
|
|
18172
18185
|
|
|
18173
18186
|
// src/agents/claude/credentials.ts
|
|
18174
18187
|
var import_child_process12 = require("child_process");
|
|
18175
18188
|
var fs15 = __toESM(require("fs"));
|
|
18176
18189
|
var os13 = __toESM(require("os"));
|
|
18177
|
-
var
|
|
18190
|
+
var path20 = __toESM(require("path"));
|
|
18178
18191
|
var import_util2 = require("util");
|
|
18179
18192
|
var execFileP3 = (0, import_util2.promisify)(import_child_process12.execFile);
|
|
18180
18193
|
async function detectLocalClaudeCredentials() {
|
|
18181
|
-
const localClaudeDir =
|
|
18182
|
-
const flat =
|
|
18194
|
+
const localClaudeDir = path20.join(os13.homedir(), ".claude");
|
|
18195
|
+
const flat = path20.join(localClaudeDir, ".credentials.json");
|
|
18183
18196
|
if (fs15.existsSync(flat)) {
|
|
18184
18197
|
return { source: "flat-file", description: "~/.claude/.credentials.json" };
|
|
18185
18198
|
}
|
|
@@ -18198,8 +18211,8 @@ async function detectLocalClaudeCredentials() {
|
|
|
18198
18211
|
return { source: "none", description: "" };
|
|
18199
18212
|
}
|
|
18200
18213
|
async function bridgeClaudeCredentials(provider, workspaceId) {
|
|
18201
|
-
const localClaudeDir =
|
|
18202
|
-
const fileBased =
|
|
18214
|
+
const localClaudeDir = path20.join(os13.homedir(), ".claude");
|
|
18215
|
+
const fileBased = path20.join(localClaudeDir, ".credentials.json");
|
|
18203
18216
|
if (fs15.existsSync(fileBased)) {
|
|
18204
18217
|
return { source: "flat-file", description: "~/.claude/.credentials.json" };
|
|
18205
18218
|
}
|
|
@@ -18292,7 +18305,7 @@ var ClaudeDeployStrategy = class {
|
|
|
18292
18305
|
process.exit(1);
|
|
18293
18306
|
}
|
|
18294
18307
|
claudeStep.stop("\u2713 Claude CLI installed");
|
|
18295
|
-
const localClaudeDir =
|
|
18308
|
+
const localClaudeDir = path21.join(os14.homedir(), ".claude");
|
|
18296
18309
|
const haveLocalClaude = fs16.existsSync(localClaudeDir) && fs16.statSync(localClaudeDir).isDirectory();
|
|
18297
18310
|
if (haveLocalClaude) {
|
|
18298
18311
|
const copyStep = fe();
|
|
@@ -18347,7 +18360,7 @@ var ClaudeDeployStrategy = class {
|
|
|
18347
18360
|
}
|
|
18348
18361
|
}
|
|
18349
18362
|
if (opts.bridged !== "none") {
|
|
18350
|
-
const localClaudeJson =
|
|
18363
|
+
const localClaudeJson = path21.join(os14.homedir(), ".claude.json");
|
|
18351
18364
|
if (fs16.existsSync(localClaudeJson)) {
|
|
18352
18365
|
try {
|
|
18353
18366
|
const contents = fs16.readFileSync(localClaudeJson);
|
|
@@ -18383,7 +18396,7 @@ var ClaudeDeployStrategy = class {
|
|
|
18383
18396
|
|
|
18384
18397
|
// src/agents/codex/runtime.ts
|
|
18385
18398
|
var import_node_child_process4 = require("child_process");
|
|
18386
|
-
var
|
|
18399
|
+
var path25 = __toESM(require("path"));
|
|
18387
18400
|
|
|
18388
18401
|
// src/agents/codex/history.ts
|
|
18389
18402
|
var import_node_fs3 = __toESM(require("fs"));
|
|
@@ -18393,7 +18406,7 @@ var import_node_os = __toESM(require("os"));
|
|
|
18393
18406
|
// src/agents/acp/squad-roster.ts
|
|
18394
18407
|
var fs17 = __toESM(require("fs"));
|
|
18395
18408
|
var os15 = __toESM(require("os"));
|
|
18396
|
-
var
|
|
18409
|
+
var path22 = __toESM(require("path"));
|
|
18397
18410
|
var PROMPT_MAX = 500;
|
|
18398
18411
|
var REPLY_SUMMARY_MAX = 1e3;
|
|
18399
18412
|
var PREAMBLE_MAX = 2e3;
|
|
@@ -18412,7 +18425,7 @@ function defaultMember() {
|
|
|
18412
18425
|
};
|
|
18413
18426
|
}
|
|
18414
18427
|
function journalPathFor(homeDir2, sessionId) {
|
|
18415
|
-
return
|
|
18428
|
+
return path22.join(homeDir2, ".codeam", `squad-journal-${sessionId}.json`);
|
|
18416
18429
|
}
|
|
18417
18430
|
function loadJournal(journalPath) {
|
|
18418
18431
|
try {
|
|
@@ -18531,7 +18544,7 @@ var SquadState = class {
|
|
|
18531
18544
|
}
|
|
18532
18545
|
persist() {
|
|
18533
18546
|
try {
|
|
18534
|
-
fs17.mkdirSync(
|
|
18547
|
+
fs17.mkdirSync(path22.dirname(this.journalPath), { recursive: true, mode: 448 });
|
|
18535
18548
|
fs17.writeFileSync(this.journalPath, JSON.stringify({ turns: this.turns }), { mode: 384 });
|
|
18536
18549
|
} catch {
|
|
18537
18550
|
}
|
|
@@ -19050,9 +19063,9 @@ var import_node_child_process3 = require("child_process");
|
|
|
19050
19063
|
// src/agents/codex/local-token.ts
|
|
19051
19064
|
var fs19 = __toESM(require("fs"));
|
|
19052
19065
|
var os17 = __toESM(require("os"));
|
|
19053
|
-
var
|
|
19066
|
+
var path24 = __toESM(require("path"));
|
|
19054
19067
|
function codexCredentialsPath() {
|
|
19055
|
-
return
|
|
19068
|
+
return path24.join(os17.homedir(), ".codex", "auth.json");
|
|
19056
19069
|
}
|
|
19057
19070
|
async function extractLocalCodexToken() {
|
|
19058
19071
|
const file = codexCredentialsPath();
|
|
@@ -19116,8 +19129,8 @@ function codexCredentialLocator() {
|
|
|
19116
19129
|
function codexLoginLauncher() {
|
|
19117
19130
|
return {
|
|
19118
19131
|
async ensureInstalled() {
|
|
19119
|
-
const
|
|
19120
|
-
return
|
|
19132
|
+
const os68 = createOsStrategy();
|
|
19133
|
+
return os68.findInPath("codex") !== null;
|
|
19121
19134
|
},
|
|
19122
19135
|
launch() {
|
|
19123
19136
|
return (0, import_node_child_process3.spawn)("codex", ["login"], { stdio: "inherit" });
|
|
@@ -19140,8 +19153,8 @@ var CodexRuntimeStrategy = class {
|
|
|
19140
19153
|
meta = getAgent("codex");
|
|
19141
19154
|
mode = "interactive";
|
|
19142
19155
|
os;
|
|
19143
|
-
constructor(
|
|
19144
|
-
this.os =
|
|
19156
|
+
constructor(os68) {
|
|
19157
|
+
this.os = os68;
|
|
19145
19158
|
}
|
|
19146
19159
|
async prepareLaunch() {
|
|
19147
19160
|
let binary = this.os.findInPath("codex");
|
|
@@ -19252,12 +19265,12 @@ var CodexRuntimeStrategy = class {
|
|
|
19252
19265
|
});
|
|
19253
19266
|
}
|
|
19254
19267
|
};
|
|
19255
|
-
function resolveNpm(
|
|
19256
|
-
return
|
|
19268
|
+
function resolveNpm(os68) {
|
|
19269
|
+
return os68.id === "win32" ? "npm.cmd" : "npm";
|
|
19257
19270
|
}
|
|
19258
|
-
async function installCodexViaNpm(
|
|
19271
|
+
async function installCodexViaNpm(os68) {
|
|
19259
19272
|
return new Promise((resolve12, reject) => {
|
|
19260
|
-
const proc = (0, import_node_child_process4.spawn)(resolveNpm(
|
|
19273
|
+
const proc = (0, import_node_child_process4.spawn)(resolveNpm(os68), ["install", "-g", "@openai/codex"], {
|
|
19261
19274
|
stdio: "inherit"
|
|
19262
19275
|
});
|
|
19263
19276
|
proc.on("close", (code) => {
|
|
@@ -19274,16 +19287,16 @@ async function installCodexViaNpm(os69) {
|
|
|
19274
19287
|
});
|
|
19275
19288
|
});
|
|
19276
19289
|
}
|
|
19277
|
-
function augmentNpmGlobalBin(
|
|
19290
|
+
function augmentNpmGlobalBin(os68) {
|
|
19278
19291
|
try {
|
|
19279
|
-
const result = (0, import_node_child_process4.spawnSync)(resolveNpm(
|
|
19292
|
+
const result = (0, import_node_child_process4.spawnSync)(resolveNpm(os68), ["prefix", "-g"], {
|
|
19280
19293
|
stdio: ["ignore", "pipe", "ignore"]
|
|
19281
19294
|
});
|
|
19282
19295
|
if (result.status !== 0) return;
|
|
19283
19296
|
const prefix = result.stdout.toString().trim();
|
|
19284
19297
|
if (!prefix) return;
|
|
19285
|
-
const binDir =
|
|
19286
|
-
|
|
19298
|
+
const binDir = os68.id === "win32" ? prefix : path25.join(prefix, "bin");
|
|
19299
|
+
os68.augmentPath([binDir]);
|
|
19287
19300
|
} catch {
|
|
19288
19301
|
}
|
|
19289
19302
|
}
|
|
@@ -19367,7 +19380,7 @@ var import_node_child_process8 = require("child_process");
|
|
|
19367
19380
|
// src/agents/coderabbit/installer.ts
|
|
19368
19381
|
var import_node_child_process6 = require("child_process");
|
|
19369
19382
|
var import_node_fs5 = require("fs");
|
|
19370
|
-
var
|
|
19383
|
+
var path27 = __toESM(require("path"));
|
|
19371
19384
|
|
|
19372
19385
|
// src/commands/host/os-packages.ts
|
|
19373
19386
|
var import_node_child_process5 = require("child_process");
|
|
@@ -19477,11 +19490,11 @@ function manualInstallHint(runner, tools) {
|
|
|
19477
19490
|
const argv = osPackageInstallArgv(detectPackageManager(runner), [...tools]);
|
|
19478
19491
|
return argv ? `\`sudo ${argv.join(" ")}\`` : `your package manager (e.g. \`${pkgs}\`)`;
|
|
19479
19492
|
}
|
|
19480
|
-
function writeUnzipShim(
|
|
19493
|
+
function writeUnzipShim(os68, runner) {
|
|
19481
19494
|
const python = ["python3", "python"].find((p2) => runner.which(p2));
|
|
19482
19495
|
if (!python) return null;
|
|
19483
|
-
const dir =
|
|
19484
|
-
const shim =
|
|
19496
|
+
const dir = os68.scratchPath("codeam-cr-prereq");
|
|
19497
|
+
const shim = path27.join(dir, "unzip");
|
|
19485
19498
|
const script = `#!/bin/sh
|
|
19486
19499
|
set -e
|
|
19487
19500
|
archive=""
|
|
@@ -19502,9 +19515,9 @@ exec ${python} -m zipfile -e "$archive" "$dest"
|
|
|
19502
19515
|
(0, import_node_fs5.chmodSync)(shim, 448);
|
|
19503
19516
|
return dir;
|
|
19504
19517
|
}
|
|
19505
|
-
async function ensureInstallPrerequisites(
|
|
19518
|
+
async function ensureInstallPrerequisites(os68, deps = {}) {
|
|
19506
19519
|
const runner = deps.runner ?? defaultOsRunner;
|
|
19507
|
-
const missing = REQUIRED_TOOLS.filter((t2) =>
|
|
19520
|
+
const missing = REQUIRED_TOOLS.filter((t2) => os68.findInPath(t2) === null);
|
|
19508
19521
|
if (missing.length === 0) return { ok: true, extraPath: [] };
|
|
19509
19522
|
log.info(
|
|
19510
19523
|
"coderabbit",
|
|
@@ -19523,10 +19536,10 @@ async function ensureInstallPrerequisites(os69, deps = {}) {
|
|
|
19523
19536
|
);
|
|
19524
19537
|
}
|
|
19525
19538
|
}
|
|
19526
|
-
const stillMissing = REQUIRED_TOOLS.filter((t2) =>
|
|
19539
|
+
const stillMissing = REQUIRED_TOOLS.filter((t2) => os68.findInPath(t2) === null);
|
|
19527
19540
|
if (stillMissing.length === 0) return { ok: true, extraPath: [] };
|
|
19528
19541
|
if (stillMissing.length === 1 && stillMissing[0] === "unzip") {
|
|
19529
|
-
const shimDir = writeUnzipShim(
|
|
19542
|
+
const shimDir = writeUnzipShim(os68, runner);
|
|
19530
19543
|
if (shimDir) {
|
|
19531
19544
|
log.info("coderabbit", "unzip is unavailable \u2014 using a scoped python zipfile shim");
|
|
19532
19545
|
return { ok: true, extraPath: [shimDir] };
|
|
@@ -19589,15 +19602,15 @@ function summarizeInstallFailure(output) {
|
|
|
19589
19602
|
}
|
|
19590
19603
|
return lines.length > 0 ? lines[lines.length - 1] : null;
|
|
19591
19604
|
}
|
|
19592
|
-
async function ensureCoderabbitInstalled(
|
|
19593
|
-
if (
|
|
19594
|
-
if (
|
|
19605
|
+
async function ensureCoderabbitInstalled(os68, deps = {}) {
|
|
19606
|
+
if (os68.findInPath("coderabbit")) return { ok: true };
|
|
19607
|
+
if (os68.id === "win32") {
|
|
19595
19608
|
return {
|
|
19596
19609
|
ok: false,
|
|
19597
19610
|
error: "CodeRabbit on Windows requires WSL. Install the CLI inside your WSL distribution (curl -fsSL https://cli.coderabbit.ai/install.sh | sh), then try again."
|
|
19598
19611
|
};
|
|
19599
19612
|
}
|
|
19600
|
-
const prereq = await ensureInstallPrerequisites(
|
|
19613
|
+
const prereq = await ensureInstallPrerequisites(os68, deps);
|
|
19601
19614
|
if (!prereq.ok) return { ok: false, error: prereq.error };
|
|
19602
19615
|
const env = { ...process.env };
|
|
19603
19616
|
if (prereq.extraPath.length > 0) {
|
|
@@ -19606,8 +19619,8 @@ async function ensureCoderabbitInstalled(os69, deps = {}) {
|
|
|
19606
19619
|
log.info("coderabbit", "CodeRabbit CLI not found \u2014 installing via the official script");
|
|
19607
19620
|
const run3 = deps.runInstallScript ?? defaultRunInstallScript;
|
|
19608
19621
|
const { code, output } = await run3(env);
|
|
19609
|
-
|
|
19610
|
-
const binary =
|
|
19622
|
+
os68.augmentPath([`${os68.homeDir()}/.local/bin`, "/opt/homebrew/bin"]);
|
|
19623
|
+
const binary = os68.findInPath("coderabbit");
|
|
19611
19624
|
const detail = summarizeInstallFailure(output);
|
|
19612
19625
|
if (binary !== null) {
|
|
19613
19626
|
if (code === 0) return { ok: true };
|
|
@@ -19633,7 +19646,7 @@ async function ensureCoderabbitInstalled(os69, deps = {}) {
|
|
|
19633
19646
|
var import_node_child_process7 = require("child_process");
|
|
19634
19647
|
var fs21 = __toESM(require("fs"));
|
|
19635
19648
|
var os19 = __toESM(require("os"));
|
|
19636
|
-
var
|
|
19649
|
+
var path28 = __toESM(require("path"));
|
|
19637
19650
|
|
|
19638
19651
|
// src/agents/strategy.ts
|
|
19639
19652
|
function validateNonEmptyCredential(token) {
|
|
@@ -19642,7 +19655,7 @@ function validateNonEmptyCredential(token) {
|
|
|
19642
19655
|
|
|
19643
19656
|
// src/agents/coderabbit/link.ts
|
|
19644
19657
|
function authPath() {
|
|
19645
|
-
return
|
|
19658
|
+
return path28.join(os19.homedir(), ".coderabbit", "auth.json");
|
|
19646
19659
|
}
|
|
19647
19660
|
async function extractLocalCoderabbitToken() {
|
|
19648
19661
|
const file = authPath();
|
|
@@ -19661,10 +19674,10 @@ function coderabbitCredentialLocator() {
|
|
|
19661
19674
|
validate: validateNonEmptyCredential
|
|
19662
19675
|
};
|
|
19663
19676
|
}
|
|
19664
|
-
function coderabbitLoginLauncher(
|
|
19677
|
+
function coderabbitLoginLauncher(os68) {
|
|
19665
19678
|
return {
|
|
19666
19679
|
async ensureInstalled() {
|
|
19667
|
-
const result = await ensureCoderabbitInstalled(
|
|
19680
|
+
const result = await ensureCoderabbitInstalled(os68);
|
|
19668
19681
|
if (!result.ok && result.error) console.error(`
|
|
19669
19682
|
\u2717 ${result.error}
|
|
19670
19683
|
`);
|
|
@@ -19724,8 +19737,8 @@ function pickLine(obj) {
|
|
|
19724
19737
|
function toHunk(raw, groupSeverity) {
|
|
19725
19738
|
if (!raw || typeof raw !== "object") return null;
|
|
19726
19739
|
const o = raw;
|
|
19727
|
-
const
|
|
19728
|
-
if (!
|
|
19740
|
+
const path106 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
|
|
19741
|
+
if (!path106) return null;
|
|
19729
19742
|
const message = asString(
|
|
19730
19743
|
pick(o, [
|
|
19731
19744
|
"comment",
|
|
@@ -19742,7 +19755,7 @@ function toHunk(raw, groupSeverity) {
|
|
|
19742
19755
|
const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
|
|
19743
19756
|
const locObj = pick(o, ["location"]) ?? o;
|
|
19744
19757
|
return {
|
|
19745
|
-
path:
|
|
19758
|
+
path: path106.trim(),
|
|
19746
19759
|
line: pickLine(o) ?? pickLine(locObj),
|
|
19747
19760
|
severity,
|
|
19748
19761
|
message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
|
|
@@ -19825,10 +19838,10 @@ function parsePlain(stdout) {
|
|
|
19825
19838
|
for (const line of stdout.split(/\r?\n/)) {
|
|
19826
19839
|
const m = line.match(HUNK_LINE_RE);
|
|
19827
19840
|
if (!m) continue;
|
|
19828
|
-
const [,
|
|
19829
|
-
if (!
|
|
19841
|
+
const [, path106, lineNo, sevToken, message] = m;
|
|
19842
|
+
if (!path106 || !lineNo || !message) continue;
|
|
19830
19843
|
hunks.push({
|
|
19831
|
-
path:
|
|
19844
|
+
path: path106.trim(),
|
|
19832
19845
|
line: Number(lineNo),
|
|
19833
19846
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
19834
19847
|
message: message.trim().replace(/^[*-]\s+/, "")
|
|
@@ -19888,8 +19901,8 @@ var CoderabbitRuntimeStrategy = class {
|
|
|
19888
19901
|
meta = getAgent("coderabbit");
|
|
19889
19902
|
mode = "batch";
|
|
19890
19903
|
os;
|
|
19891
|
-
constructor(
|
|
19892
|
-
this.os =
|
|
19904
|
+
constructor(os68) {
|
|
19905
|
+
this.os = os68;
|
|
19893
19906
|
}
|
|
19894
19907
|
getDefaultArgs() {
|
|
19895
19908
|
return ["review", "--agent"];
|
|
@@ -19993,37 +20006,37 @@ CodeRabbit review timed out after ${Math.round(
|
|
|
19993
20006
|
// src/agents/cursor/history.ts
|
|
19994
20007
|
var fs22 = __toESM(require("fs"));
|
|
19995
20008
|
var os20 = __toESM(require("os"));
|
|
19996
|
-
var
|
|
20009
|
+
var path29 = __toESM(require("path"));
|
|
19997
20010
|
var import_node_crypto5 = require("crypto");
|
|
19998
|
-
var HISTORY_ROOT =
|
|
19999
|
-
var CURSOR_HOME =
|
|
20011
|
+
var HISTORY_ROOT = path29.join(os20.homedir(), ".cursor", "projects");
|
|
20012
|
+
var CURSOR_HOME = path29.join(os20.homedir(), ".cursor");
|
|
20000
20013
|
var STORE_FILES = ["store.db", "store.db-wal", "store.db-shm"];
|
|
20001
20014
|
function acpSessionDir(sessionId) {
|
|
20002
|
-
return
|
|
20015
|
+
return path29.join(CURSOR_HOME, "acp-sessions", sessionId);
|
|
20003
20016
|
}
|
|
20004
20017
|
function nativeStoreDir(cwd, sessionId) {
|
|
20005
|
-
const chatsRoot =
|
|
20018
|
+
const chatsRoot = path29.join(CURSOR_HOME, "chats");
|
|
20006
20019
|
let buckets = [];
|
|
20007
20020
|
try {
|
|
20008
20021
|
buckets = fs22.readdirSync(chatsRoot);
|
|
20009
20022
|
} catch {
|
|
20010
20023
|
}
|
|
20011
20024
|
for (const b of buckets) {
|
|
20012
|
-
const candidate =
|
|
20013
|
-
if (fs22.existsSync(
|
|
20025
|
+
const candidate = path29.join(chatsRoot, b, sessionId);
|
|
20026
|
+
if (fs22.existsSync(path29.join(candidate, "store.db"))) return candidate;
|
|
20014
20027
|
}
|
|
20015
|
-
const computed =
|
|
20028
|
+
const computed = path29.join(chatsRoot, (0, import_node_crypto5.createHash)("md5").update(cwd).digest("hex"), sessionId);
|
|
20016
20029
|
return fs22.existsSync(computed) ? computed : null;
|
|
20017
20030
|
}
|
|
20018
20031
|
function copyStoreFiles(srcDir, dstDir) {
|
|
20019
20032
|
fs22.mkdirSync(dstDir, { recursive: true });
|
|
20020
20033
|
for (const f of STORE_FILES) {
|
|
20021
|
-
const dst =
|
|
20034
|
+
const dst = path29.join(dstDir, f);
|
|
20022
20035
|
if (fs22.existsSync(dst)) fs22.rmSync(dst, { force: true });
|
|
20023
20036
|
}
|
|
20024
20037
|
for (const f of STORE_FILES) {
|
|
20025
|
-
const src =
|
|
20026
|
-
if (fs22.existsSync(src)) fs22.copyFileSync(src,
|
|
20038
|
+
const src = path29.join(srcDir, f);
|
|
20039
|
+
if (fs22.existsSync(src)) fs22.copyFileSync(src, path29.join(dstDir, f));
|
|
20027
20040
|
}
|
|
20028
20041
|
}
|
|
20029
20042
|
function bridgeNativeToAcp(cwd, sessionId) {
|
|
@@ -20036,7 +20049,7 @@ function bridgeNativeToAcp(cwd, sessionId) {
|
|
|
20036
20049
|
const dst = acpSessionDir(sessionId);
|
|
20037
20050
|
copyStoreFiles(src, dst);
|
|
20038
20051
|
fs22.writeFileSync(
|
|
20039
|
-
|
|
20052
|
+
path29.join(dst, "meta.json"),
|
|
20040
20053
|
JSON.stringify({ schemaVersion: 1, cwd })
|
|
20041
20054
|
);
|
|
20042
20055
|
log.info("cursor", `baton bridge native\u2192acp ok (${sessionId.slice(0, 8)})`);
|
|
@@ -20047,11 +20060,11 @@ function bridgeNativeToAcp(cwd, sessionId) {
|
|
|
20047
20060
|
function bridgeAcpToNative(cwd, sessionId) {
|
|
20048
20061
|
try {
|
|
20049
20062
|
const src = acpSessionDir(sessionId);
|
|
20050
|
-
if (!fs22.existsSync(
|
|
20063
|
+
if (!fs22.existsSync(path29.join(src, "store.db"))) {
|
|
20051
20064
|
log.warn("cursor", `baton bridge: no acp store for ${sessionId.slice(0, 8)} \u2014 skip`);
|
|
20052
20065
|
return;
|
|
20053
20066
|
}
|
|
20054
|
-
const dst = nativeStoreDir(cwd, sessionId) ??
|
|
20067
|
+
const dst = nativeStoreDir(cwd, sessionId) ?? path29.join(CURSOR_HOME, "chats", (0, import_node_crypto5.createHash)("md5").update(cwd).digest("hex"), sessionId);
|
|
20055
20068
|
copyStoreFiles(src, dst);
|
|
20056
20069
|
log.info("cursor", `baton bridge acp\u2192native ok (${sessionId.slice(0, 8)})`);
|
|
20057
20070
|
} catch (err) {
|
|
@@ -20062,8 +20075,8 @@ function encodeCursorCwd(cwd) {
|
|
|
20062
20075
|
return cwd.replace(/^[/\\]+/, "").replace(/[/\\:]/g, "-");
|
|
20063
20076
|
}
|
|
20064
20077
|
function resolveHistoryFile3(cwd, sessionId, root = HISTORY_ROOT) {
|
|
20065
|
-
const rel =
|
|
20066
|
-
const primary =
|
|
20078
|
+
const rel = path29.join("agent-transcripts", sessionId, `${sessionId}.jsonl`);
|
|
20079
|
+
const primary = path29.join(root, encodeCursorCwd(cwd), rel);
|
|
20067
20080
|
if (fs22.existsSync(primary)) return primary;
|
|
20068
20081
|
let entries2;
|
|
20069
20082
|
try {
|
|
@@ -20073,14 +20086,14 @@ function resolveHistoryFile3(cwd, sessionId, root = HISTORY_ROOT) {
|
|
|
20073
20086
|
}
|
|
20074
20087
|
for (const e of entries2) {
|
|
20075
20088
|
if (!e.isDirectory()) continue;
|
|
20076
|
-
const candidate =
|
|
20089
|
+
const candidate = path29.join(root, e.name, rel);
|
|
20077
20090
|
if (fs22.existsSync(candidate)) return candidate;
|
|
20078
20091
|
}
|
|
20079
20092
|
return null;
|
|
20080
20093
|
}
|
|
20081
20094
|
function resolveHistoryDir3(cwd) {
|
|
20082
20095
|
if (!fs22.existsSync(HISTORY_ROOT)) return null;
|
|
20083
|
-
const dir =
|
|
20096
|
+
const dir = path29.join(HISTORY_ROOT, encodeCursorCwd(cwd));
|
|
20084
20097
|
return fs22.existsSync(dir) ? dir : null;
|
|
20085
20098
|
}
|
|
20086
20099
|
function extractText2(content) {
|
|
@@ -20134,9 +20147,9 @@ var import_node_child_process9 = require("child_process");
|
|
|
20134
20147
|
// src/agents/cursor/local-token.ts
|
|
20135
20148
|
var fs23 = __toESM(require("fs"));
|
|
20136
20149
|
var os21 = __toESM(require("os"));
|
|
20137
|
-
var
|
|
20150
|
+
var path30 = __toESM(require("path"));
|
|
20138
20151
|
function cursorCredentialsPath() {
|
|
20139
|
-
return
|
|
20152
|
+
return path30.join(os21.homedir(), ".cursor", "auth.json");
|
|
20140
20153
|
}
|
|
20141
20154
|
async function extractLocalCursorToken() {
|
|
20142
20155
|
const file = cursorCredentialsPath();
|
|
@@ -20160,10 +20173,10 @@ function cursorCredentialLocator() {
|
|
|
20160
20173
|
validate: validateNonEmptyCredential
|
|
20161
20174
|
};
|
|
20162
20175
|
}
|
|
20163
|
-
function cursorLoginLauncher(
|
|
20176
|
+
function cursorLoginLauncher(os68) {
|
|
20164
20177
|
return {
|
|
20165
20178
|
async ensureInstalled() {
|
|
20166
|
-
if (
|
|
20179
|
+
if (os68.findInPath("cursor-agent")) return true;
|
|
20167
20180
|
console.error(
|
|
20168
20181
|
"\n \u2717 cursor-agent binary not on PATH.\n Install Cursor (https://cursor.com/) and ensure the CLI\n plugin is enabled, then re-run `codeam link cursor`.\n"
|
|
20169
20182
|
);
|
|
@@ -20227,8 +20240,8 @@ var CursorRuntimeStrategy = class {
|
|
|
20227
20240
|
meta = getAgent("cursor");
|
|
20228
20241
|
mode = "interactive";
|
|
20229
20242
|
os;
|
|
20230
|
-
constructor(
|
|
20231
|
-
this.os =
|
|
20243
|
+
constructor(os68) {
|
|
20244
|
+
this.os = os68;
|
|
20232
20245
|
}
|
|
20233
20246
|
async prepareLaunch() {
|
|
20234
20247
|
const binary = this.os.findInPath("cursor-agent");
|
|
@@ -20387,10 +20400,10 @@ var CursorRuntimeStrategy = class {
|
|
|
20387
20400
|
|
|
20388
20401
|
// src/agents/aider/history.ts
|
|
20389
20402
|
var fs24 = __toESM(require("fs"));
|
|
20390
|
-
var
|
|
20403
|
+
var path31 = __toESM(require("path"));
|
|
20391
20404
|
var AIDER_HISTORY_FILE = ".aider.chat.history.md";
|
|
20392
20405
|
function resolveHistoryDir4(cwd) {
|
|
20393
|
-
const candidate =
|
|
20406
|
+
const candidate = path31.join(cwd, AIDER_HISTORY_FILE);
|
|
20394
20407
|
return fs24.existsSync(candidate) ? cwd : null;
|
|
20395
20408
|
}
|
|
20396
20409
|
function parseHistoryFile4(_filePath) {
|
|
@@ -20406,8 +20419,8 @@ var import_node_child_process11 = require("child_process");
|
|
|
20406
20419
|
// src/agents/aider/local-token.ts
|
|
20407
20420
|
var fs25 = __toESM(require("fs"));
|
|
20408
20421
|
var os22 = __toESM(require("os"));
|
|
20409
|
-
var
|
|
20410
|
-
var AIDER_CONF_FILE =
|
|
20422
|
+
var path32 = __toESM(require("path"));
|
|
20423
|
+
var AIDER_CONF_FILE = path32.join(os22.homedir(), ".aider.conf.yml");
|
|
20411
20424
|
var API_KEY_ENV_VARS = [
|
|
20412
20425
|
"ANTHROPIC_API_KEY",
|
|
20413
20426
|
"OPENAI_API_KEY",
|
|
@@ -20446,10 +20459,10 @@ function aiderCredentialLocator() {
|
|
|
20446
20459
|
validate: validateNonEmptyCredential
|
|
20447
20460
|
};
|
|
20448
20461
|
}
|
|
20449
|
-
function aiderLoginLauncher(
|
|
20462
|
+
function aiderLoginLauncher(os68) {
|
|
20450
20463
|
return {
|
|
20451
20464
|
async ensureInstalled() {
|
|
20452
|
-
if (
|
|
20465
|
+
if (os68.findInPath("aider")) return true;
|
|
20453
20466
|
console.error(
|
|
20454
20467
|
"\n \u2717 aider binary not on PATH.\n Install Aider:\n pip install aider-chat\n then re-run `codeam link aider`.\n"
|
|
20455
20468
|
);
|
|
@@ -20459,7 +20472,7 @@ function aiderLoginLauncher(os69) {
|
|
|
20459
20472
|
console.error(
|
|
20460
20473
|
"\n Aider has no interactive login flow.\n Set ANTHROPIC_API_KEY or OPENAI_API_KEY in your shell,\n or re-run `codeam link aider --api-key=<your-key>`.\n"
|
|
20461
20474
|
);
|
|
20462
|
-
return (0, import_node_child_process11.spawn)(
|
|
20475
|
+
return (0, import_node_child_process11.spawn)(os68.id === "win32" ? "cmd.exe" : "sh", os68.id === "win32" ? ["/c", "exit", "0"] : ["-c", "exit 0"], {
|
|
20463
20476
|
stdio: "ignore"
|
|
20464
20477
|
});
|
|
20465
20478
|
}
|
|
@@ -20734,8 +20747,8 @@ var AiderRuntimeStrategy = class {
|
|
|
20734
20747
|
meta = getAgent("aider");
|
|
20735
20748
|
mode = "interactive";
|
|
20736
20749
|
os;
|
|
20737
|
-
constructor(
|
|
20738
|
-
this.os =
|
|
20750
|
+
constructor(os68) {
|
|
20751
|
+
this.os = os68;
|
|
20739
20752
|
}
|
|
20740
20753
|
async prepareLaunch() {
|
|
20741
20754
|
augmentUserLocalBinPaths();
|
|
@@ -20812,9 +20825,9 @@ var import_node_child_process12 = require("child_process");
|
|
|
20812
20825
|
// src/agents/gemini/local-token.ts
|
|
20813
20826
|
var fs27 = __toESM(require("fs"));
|
|
20814
20827
|
var os24 = __toESM(require("os"));
|
|
20815
|
-
var
|
|
20828
|
+
var path34 = __toESM(require("path"));
|
|
20816
20829
|
function geminiCredentialsPath() {
|
|
20817
|
-
return
|
|
20830
|
+
return path34.join(os24.homedir(), ".gemini", "oauth_creds.json");
|
|
20818
20831
|
}
|
|
20819
20832
|
function geminiCredentialsPaths() {
|
|
20820
20833
|
return [geminiCredentialsPath()];
|
|
@@ -20868,8 +20881,8 @@ function geminiCredentialLocator() {
|
|
|
20868
20881
|
function geminiLoginLauncher() {
|
|
20869
20882
|
return {
|
|
20870
20883
|
async ensureInstalled() {
|
|
20871
|
-
const
|
|
20872
|
-
return
|
|
20884
|
+
const os68 = createOsStrategy();
|
|
20885
|
+
return os68.findInPath("gemini") !== null;
|
|
20873
20886
|
},
|
|
20874
20887
|
launch() {
|
|
20875
20888
|
return (0, import_node_child_process12.spawn)("gemini", ["auth", "login"], { stdio: "inherit" });
|
|
@@ -20880,12 +20893,12 @@ function geminiLoginLauncher() {
|
|
|
20880
20893
|
// src/agents/gemini/history.ts
|
|
20881
20894
|
var fs28 = __toESM(require("fs"));
|
|
20882
20895
|
var os25 = __toESM(require("os"));
|
|
20883
|
-
var
|
|
20884
|
-
var GEMINI_ROOT =
|
|
20896
|
+
var path35 = __toESM(require("path"));
|
|
20897
|
+
var GEMINI_ROOT = path35.join(os25.homedir(), ".gemini");
|
|
20885
20898
|
function projectNameForCwd(cwd, root) {
|
|
20886
20899
|
try {
|
|
20887
20900
|
const parsed = JSON.parse(
|
|
20888
|
-
fs28.readFileSync(
|
|
20901
|
+
fs28.readFileSync(path35.join(root, "projects.json"), "utf8")
|
|
20889
20902
|
);
|
|
20890
20903
|
const map = parsed.projects;
|
|
20891
20904
|
if (map && typeof map === "object") {
|
|
@@ -20900,7 +20913,7 @@ function projectNameForCwd(cwd, root) {
|
|
|
20900
20913
|
} catch (err) {
|
|
20901
20914
|
log.debug("gemini", `projects.json unreadable at ${root} \u2014 using basename fallback`, err);
|
|
20902
20915
|
}
|
|
20903
|
-
return
|
|
20916
|
+
return path35.basename(cwd) || null;
|
|
20904
20917
|
}
|
|
20905
20918
|
function resolveHistoryDir5(cwd, root = GEMINI_ROOT) {
|
|
20906
20919
|
const name = projectNameForCwd(cwd, root);
|
|
@@ -20908,7 +20921,7 @@ function resolveHistoryDir5(cwd, root = GEMINI_ROOT) {
|
|
|
20908
20921
|
log.warn("gemini", `resolveHistoryDir \u2014 could not derive a project name for cwd=${cwd}`);
|
|
20909
20922
|
return null;
|
|
20910
20923
|
}
|
|
20911
|
-
const dir =
|
|
20924
|
+
const dir = path35.join(root, "tmp", name, "chats");
|
|
20912
20925
|
if (!fs28.existsSync(dir)) {
|
|
20913
20926
|
log.debug("gemini", `resolveHistoryDir \u2014 chats dir not present yet: ${dir} (project=${name})`);
|
|
20914
20927
|
return null;
|
|
@@ -20933,10 +20946,10 @@ function resolveHistoryFile4(cwd, sessionId, root = GEMINI_ROOT) {
|
|
|
20933
20946
|
const byName = files.find((f) => id8.length > 0 && f.includes(id8));
|
|
20934
20947
|
if (byName) {
|
|
20935
20948
|
log.info("gemini", `resolveHistoryFile \u2014 matched by filename id8=${id8}: ${byName}`);
|
|
20936
|
-
return
|
|
20949
|
+
return path35.join(dir, byName);
|
|
20937
20950
|
}
|
|
20938
20951
|
for (const f of files) {
|
|
20939
|
-
const full =
|
|
20952
|
+
const full = path35.join(dir, f);
|
|
20940
20953
|
try {
|
|
20941
20954
|
const firstLine = fs28.readFileSync(full, "utf8").split("\n", 1)[0] ?? "";
|
|
20942
20955
|
const hdr = JSON.parse(firstLine);
|
|
@@ -20951,7 +20964,7 @@ function resolveHistoryFile4(cwd, sessionId, root = GEMINI_ROOT) {
|
|
|
20951
20964
|
let newest = null;
|
|
20952
20965
|
for (const f of files) {
|
|
20953
20966
|
try {
|
|
20954
|
-
const mtime = fs28.statSync(
|
|
20967
|
+
const mtime = fs28.statSync(path35.join(dir, f)).mtimeMs;
|
|
20955
20968
|
if (!newest || mtime > newest.mtime) newest = { file: f, mtime };
|
|
20956
20969
|
} catch {
|
|
20957
20970
|
}
|
|
@@ -20960,7 +20973,7 @@ function resolveHistoryFile4(cwd, sessionId, root = GEMINI_ROOT) {
|
|
|
20960
20973
|
"gemini",
|
|
20961
20974
|
`resolveHistoryFile \u2014 no id8=${id8} match among ${files.length} file(s) in ${dir}; falling back to newest=${newest?.file ?? "none"}`
|
|
20962
20975
|
);
|
|
20963
|
-
return newest ?
|
|
20976
|
+
return newest ? path35.join(dir, newest.file) : null;
|
|
20964
20977
|
}
|
|
20965
20978
|
function extractGeminiText(content) {
|
|
20966
20979
|
const fromParts = (arr) => Array.isArray(arr) ? arr.map((p2) => {
|
|
@@ -21029,7 +21042,7 @@ function parseHistoryFile5(filePath) {
|
|
|
21029
21042
|
}
|
|
21030
21043
|
log.trace(
|
|
21031
21044
|
"gemini",
|
|
21032
|
-
`parseHistoryFile \u2014 ${out2.length} turn(s) from ${
|
|
21045
|
+
`parseHistoryFile \u2014 ${out2.length} turn(s) from ${path35.basename(filePath)}` + (malformed > 0 ? ` (${malformed} malformed line(s) skipped)` : "")
|
|
21033
21046
|
);
|
|
21034
21047
|
return out2;
|
|
21035
21048
|
}
|
|
@@ -21059,8 +21072,8 @@ var GeminiRuntimeStrategy = class {
|
|
|
21059
21072
|
meta = getAgent("gemini");
|
|
21060
21073
|
mode = "interactive";
|
|
21061
21074
|
os;
|
|
21062
|
-
constructor(
|
|
21063
|
-
this.os =
|
|
21075
|
+
constructor(os68) {
|
|
21076
|
+
this.os = os68;
|
|
21064
21077
|
}
|
|
21065
21078
|
async prepareLaunch() {
|
|
21066
21079
|
const binary = this.os.findInPath("gemini");
|
|
@@ -21177,32 +21190,32 @@ var import_node_path5 = require("path");
|
|
|
21177
21190
|
// src/agents/kimi/history.ts
|
|
21178
21191
|
var fs29 = __toESM(require("fs"));
|
|
21179
21192
|
var os26 = __toESM(require("os"));
|
|
21180
|
-
var
|
|
21193
|
+
var path36 = __toESM(require("path"));
|
|
21181
21194
|
var import_node_crypto7 = require("crypto");
|
|
21182
21195
|
function kimiHome() {
|
|
21183
|
-
return process.env.KIMI_CODE_HOME ||
|
|
21196
|
+
return process.env.KIMI_CODE_HOME || path36.join(os26.homedir(), ".kimi-code");
|
|
21184
21197
|
}
|
|
21185
21198
|
function workDirKey(cwd) {
|
|
21186
21199
|
const hash = (0, import_node_crypto7.createHash)("sha256").update(cwd).digest("hex").slice(0, 12);
|
|
21187
|
-
return `wd_${
|
|
21200
|
+
return `wd_${path36.basename(cwd)}_${hash}`;
|
|
21188
21201
|
}
|
|
21189
21202
|
function resolveHistoryDir6(cwd) {
|
|
21190
|
-
const dir =
|
|
21203
|
+
const dir = path36.join(kimiHome(), "sessions", workDirKey(cwd));
|
|
21191
21204
|
if (!fs29.existsSync(dir)) {
|
|
21192
21205
|
log.debug("kimi", `resolveHistoryDir \u2014 session bucket not present yet: ${dir}`);
|
|
21193
21206
|
return null;
|
|
21194
21207
|
}
|
|
21195
21208
|
return dir;
|
|
21196
21209
|
}
|
|
21197
|
-
var WIRE_REL =
|
|
21210
|
+
var WIRE_REL = path36.join("agents", "main", "wire.jsonl");
|
|
21198
21211
|
function resolveHistoryFile5(cwd, sessionId) {
|
|
21199
21212
|
const fromIndex = sessionDirFromIndex(sessionId);
|
|
21200
21213
|
if (fromIndex) {
|
|
21201
|
-
const p2 =
|
|
21214
|
+
const p2 = path36.join(fromIndex, WIRE_REL);
|
|
21202
21215
|
if (fs29.existsSync(p2)) return p2;
|
|
21203
21216
|
}
|
|
21204
|
-
const bucket =
|
|
21205
|
-
const computed =
|
|
21217
|
+
const bucket = path36.join(kimiHome(), "sessions", workDirKey(cwd));
|
|
21218
|
+
const computed = path36.join(bucket, sessionId, WIRE_REL);
|
|
21206
21219
|
if (fs29.existsSync(computed)) return computed;
|
|
21207
21220
|
const scanned = scanBucketsForSession(sessionId);
|
|
21208
21221
|
if (scanned) return scanned;
|
|
@@ -21210,7 +21223,7 @@ function resolveHistoryFile5(cwd, sessionId) {
|
|
|
21210
21223
|
}
|
|
21211
21224
|
function sessionDirFromIndex(sessionId) {
|
|
21212
21225
|
try {
|
|
21213
|
-
const raw = fs29.readFileSync(
|
|
21226
|
+
const raw = fs29.readFileSync(path36.join(kimiHome(), "session_index.jsonl"), "utf8");
|
|
21214
21227
|
for (const line of raw.split("\n")) {
|
|
21215
21228
|
if (!line.includes(sessionId)) continue;
|
|
21216
21229
|
try {
|
|
@@ -21226,7 +21239,7 @@ function sessionDirFromIndex(sessionId) {
|
|
|
21226
21239
|
return null;
|
|
21227
21240
|
}
|
|
21228
21241
|
function scanBucketsForSession(sessionId) {
|
|
21229
|
-
const sessionsRoot =
|
|
21242
|
+
const sessionsRoot = path36.join(kimiHome(), "sessions");
|
|
21230
21243
|
let buckets;
|
|
21231
21244
|
try {
|
|
21232
21245
|
buckets = fs29.readdirSync(sessionsRoot, { withFileTypes: true });
|
|
@@ -21235,13 +21248,13 @@ function scanBucketsForSession(sessionId) {
|
|
|
21235
21248
|
}
|
|
21236
21249
|
for (const b of buckets) {
|
|
21237
21250
|
if (!b.isDirectory()) continue;
|
|
21238
|
-
const candidate =
|
|
21251
|
+
const candidate = path36.join(sessionsRoot, b.name, sessionId, WIRE_REL);
|
|
21239
21252
|
if (fs29.existsSync(candidate)) return candidate;
|
|
21240
21253
|
}
|
|
21241
21254
|
return null;
|
|
21242
21255
|
}
|
|
21243
21256
|
async function discoverSessionId2(cwd, opts) {
|
|
21244
|
-
const bucket =
|
|
21257
|
+
const bucket = path36.join(kimiHome(), "sessions", workDirKey(cwd));
|
|
21245
21258
|
const floor = opts.sinceMs - 2e3;
|
|
21246
21259
|
const deadline = Date.now() + (opts.timeoutMs ?? 15e3);
|
|
21247
21260
|
for (; ; ) {
|
|
@@ -21264,7 +21277,7 @@ function newestSessionSince(bucket, floorMs) {
|
|
|
21264
21277
|
if (!e.isDirectory() || !e.name.startsWith("session_")) continue;
|
|
21265
21278
|
let mtime;
|
|
21266
21279
|
try {
|
|
21267
|
-
mtime = fs29.statSync(
|
|
21280
|
+
mtime = fs29.statSync(path36.join(bucket, e.name)).mtimeMs;
|
|
21268
21281
|
} catch {
|
|
21269
21282
|
continue;
|
|
21270
21283
|
}
|
|
@@ -21353,8 +21366,8 @@ var KimiRuntimeStrategy = class {
|
|
|
21353
21366
|
meta = getAgent("kimi");
|
|
21354
21367
|
mode = "interactive";
|
|
21355
21368
|
os;
|
|
21356
|
-
constructor(
|
|
21357
|
-
this.os =
|
|
21369
|
+
constructor(os68) {
|
|
21370
|
+
this.os = os68;
|
|
21358
21371
|
}
|
|
21359
21372
|
async prepareLaunch() {
|
|
21360
21373
|
const binary = this.os.findInPath("kimi");
|
|
@@ -21498,8 +21511,8 @@ var OpencodeRuntimeStrategy = class {
|
|
|
21498
21511
|
meta = getAgent("opencode");
|
|
21499
21512
|
mode = "interactive";
|
|
21500
21513
|
os;
|
|
21501
|
-
constructor(
|
|
21502
|
-
this.os =
|
|
21514
|
+
constructor(os68) {
|
|
21515
|
+
this.os = os68;
|
|
21503
21516
|
}
|
|
21504
21517
|
async prepareLaunch() {
|
|
21505
21518
|
const binary = this.os.findInPath("opencode");
|
|
@@ -21585,20 +21598,20 @@ var OpencodeRuntimeStrategy = class {
|
|
|
21585
21598
|
|
|
21586
21599
|
// src/agents/registry.ts
|
|
21587
21600
|
var runtimeBuilders = {
|
|
21588
|
-
claude: (
|
|
21589
|
-
codex: (
|
|
21590
|
-
coderabbit: (
|
|
21591
|
-
cursor: (
|
|
21592
|
-
aider: (
|
|
21593
|
-
gemini: (
|
|
21594
|
-
kimi: (
|
|
21595
|
-
opencode: (
|
|
21601
|
+
claude: (os68) => new ClaudeRuntimeStrategy(os68),
|
|
21602
|
+
codex: (os68) => new CodexRuntimeStrategy(os68),
|
|
21603
|
+
coderabbit: (os68) => new CoderabbitRuntimeStrategy(os68),
|
|
21604
|
+
cursor: (os68) => new CursorRuntimeStrategy(os68),
|
|
21605
|
+
aider: (os68) => new AiderRuntimeStrategy(os68),
|
|
21606
|
+
gemini: (os68) => new GeminiRuntimeStrategy(os68),
|
|
21607
|
+
kimi: (os68) => new KimiRuntimeStrategy(os68),
|
|
21608
|
+
opencode: (os68) => new OpencodeRuntimeStrategy(os68)
|
|
21596
21609
|
};
|
|
21597
21610
|
var deployBuilders = {
|
|
21598
21611
|
claude: () => new ClaudeDeployStrategy(),
|
|
21599
21612
|
codex: () => new CodexDeployStrategy()
|
|
21600
21613
|
};
|
|
21601
|
-
function createAgentStrategy(agent,
|
|
21614
|
+
function createAgentStrategy(agent, os68 = createOsStrategy()) {
|
|
21602
21615
|
if (!AGENT_REGISTRY[agent]?.enabled) {
|
|
21603
21616
|
throw new Error(
|
|
21604
21617
|
`Agent "${agent}" is not supported in this codeam-cli version. Upgrade with 'npm i -g codeam-cli@latest'.`
|
|
@@ -21608,10 +21621,10 @@ function createAgentStrategy(agent, os69 = createOsStrategy()) {
|
|
|
21608
21621
|
if (!build) {
|
|
21609
21622
|
throw new Error(`No runtime strategy registered for agent "${agent}"`);
|
|
21610
21623
|
}
|
|
21611
|
-
return build(
|
|
21624
|
+
return build(os68);
|
|
21612
21625
|
}
|
|
21613
|
-
function createInteractiveAgentStrategy(agent,
|
|
21614
|
-
const s = createAgentStrategy(agent,
|
|
21626
|
+
function createInteractiveAgentStrategy(agent, os68 = createOsStrategy()) {
|
|
21627
|
+
const s = createAgentStrategy(agent, os68);
|
|
21615
21628
|
if (s.mode !== "interactive") {
|
|
21616
21629
|
throw new Error(
|
|
21617
21630
|
`Agent "${agent}" is a batch agent; use createAgentStrategy + .runOneShot for one-shot reviews.`
|
|
@@ -21667,7 +21680,7 @@ function parseLinkArgs(args2) {
|
|
|
21667
21680
|
if (apiKeyFileArg) {
|
|
21668
21681
|
const filePath = apiKeyFileArg.slice("--api-key-file=".length);
|
|
21669
21682
|
try {
|
|
21670
|
-
apiKey = fs30.readFileSync(
|
|
21683
|
+
apiKey = fs30.readFileSync(path37.resolve(filePath), "utf8").trim();
|
|
21671
21684
|
} catch (err) {
|
|
21672
21685
|
throw new Error(`Could not read --api-key-file ${filePath}: ${err.message}`);
|
|
21673
21686
|
}
|
|
@@ -21794,7 +21807,7 @@ async function link(args2 = []) {
|
|
|
21794
21807
|
return;
|
|
21795
21808
|
}
|
|
21796
21809
|
if (parsed.tokenFile) {
|
|
21797
|
-
const credential = fs30.readFileSync(
|
|
21810
|
+
const credential = fs30.readFileSync(path37.resolve(parsed.tokenFile), "utf8").trim();
|
|
21798
21811
|
if (!credential) {
|
|
21799
21812
|
showError(`--token-file ${parsed.tokenFile} is empty.`);
|
|
21800
21813
|
process.exit(1);
|
|
@@ -22049,13 +22062,13 @@ function makePreviewHeartbeatReaffirm(deps) {
|
|
|
22049
22062
|
// src/agents/coderabbit/configure.ts
|
|
22050
22063
|
var import_node_child_process16 = require("child_process");
|
|
22051
22064
|
var import_node_fs6 = require("fs");
|
|
22052
|
-
var
|
|
22065
|
+
var path39 = __toESM(require("path"));
|
|
22053
22066
|
|
|
22054
22067
|
// src/agents/coderabbit/oauth.ts
|
|
22055
22068
|
var import_node_child_process15 = require("child_process");
|
|
22056
22069
|
var fs31 = __toESM(require("fs"));
|
|
22057
22070
|
var os27 = __toESM(require("os"));
|
|
22058
|
-
var
|
|
22071
|
+
var path38 = __toESM(require("path"));
|
|
22059
22072
|
function parseCoderabbitAuthEvent(line) {
|
|
22060
22073
|
const l = line.replace(/\x1b\[[0-9;?]*[A-Za-z]/g, "").trim();
|
|
22061
22074
|
if (!l || l[0] !== "{") return null;
|
|
@@ -22104,7 +22117,7 @@ function resolvePython() {
|
|
|
22104
22117
|
function spawnCoderabbitLoginProc(cmd, args2) {
|
|
22105
22118
|
const python = resolvePython();
|
|
22106
22119
|
if (python) {
|
|
22107
|
-
const helper =
|
|
22120
|
+
const helper = path38.join(os27.tmpdir(), "codeam-cr-pty.py");
|
|
22108
22121
|
fs31.writeFileSync(helper, PYTHON_PTY_HELPER, { mode: 420 });
|
|
22109
22122
|
return (0, import_node_child_process15.spawn)(python, [helper, cmd, ...args2], {
|
|
22110
22123
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -22216,7 +22229,7 @@ function runCoderabbitOAuthLogin(deps) {
|
|
|
22216
22229
|
});
|
|
22217
22230
|
}
|
|
22218
22231
|
function coderabbitDir(home) {
|
|
22219
|
-
return
|
|
22232
|
+
return path38.join(home ?? os27.homedir(), ".coderabbit");
|
|
22220
22233
|
}
|
|
22221
22234
|
var NON_CREDENTIAL = /* @__PURE__ */ new Set(["doctor.json", "machine-id"]);
|
|
22222
22235
|
function snapshotCredentialDir(home) {
|
|
@@ -22231,7 +22244,7 @@ function snapshotCredentialDir(home) {
|
|
|
22231
22244
|
for (const e of entries2) {
|
|
22232
22245
|
if (!e.isFile() || NON_CREDENTIAL.has(e.name)) continue;
|
|
22233
22246
|
try {
|
|
22234
|
-
const st3 = fs31.statSync(
|
|
22247
|
+
const st3 = fs31.statSync(path38.join(dir, e.name));
|
|
22235
22248
|
snap[e.name] = `${st3.mtimeMs}:${st3.size}`;
|
|
22236
22249
|
} catch {
|
|
22237
22250
|
}
|
|
@@ -22249,7 +22262,7 @@ function diffCapturedCredential(before, home) {
|
|
|
22249
22262
|
}
|
|
22250
22263
|
if (!best) return null;
|
|
22251
22264
|
try {
|
|
22252
|
-
return { file: best.file, contents: fs31.readFileSync(
|
|
22265
|
+
return { file: best.file, contents: fs31.readFileSync(path38.join(dir, best.file), "utf8") };
|
|
22253
22266
|
} catch {
|
|
22254
22267
|
return null;
|
|
22255
22268
|
}
|
|
@@ -22325,8 +22338,8 @@ function collectChangedFiles(cwd) {
|
|
|
22325
22338
|
}
|
|
22326
22339
|
return [...byPath.values()];
|
|
22327
22340
|
}
|
|
22328
|
-
function restoreCoderabbitOauthBlob(
|
|
22329
|
-
const dir =
|
|
22341
|
+
function restoreCoderabbitOauthBlob(os68, value) {
|
|
22342
|
+
const dir = path39.join(os68.homeDir(), ".coderabbit");
|
|
22330
22343
|
(0, import_node_fs6.mkdirSync)(dir, { recursive: true });
|
|
22331
22344
|
let file = "auth.json";
|
|
22332
22345
|
let contents = value.trim();
|
|
@@ -22334,38 +22347,38 @@ function restoreCoderabbitOauthBlob(os69, value) {
|
|
|
22334
22347
|
try {
|
|
22335
22348
|
const parsed = JSON.parse(contents);
|
|
22336
22349
|
if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
|
|
22337
|
-
file =
|
|
22350
|
+
file = path39.basename(parsed.file);
|
|
22338
22351
|
contents = parsed.contents;
|
|
22339
22352
|
}
|
|
22340
22353
|
} catch {
|
|
22341
22354
|
}
|
|
22342
22355
|
}
|
|
22343
|
-
(0, import_node_fs6.writeFileSync)(
|
|
22356
|
+
(0, import_node_fs6.writeFileSync)(path39.join(dir, file), contents, { mode: 384 });
|
|
22344
22357
|
}
|
|
22345
22358
|
function installFailureMessage(result) {
|
|
22346
22359
|
return result.error ?? "CodeRabbit CLI could not be installed";
|
|
22347
22360
|
}
|
|
22348
22361
|
async function configureCoderabbit(input, deps = {}) {
|
|
22349
|
-
const
|
|
22362
|
+
const os68 = deps.os ?? createOsStrategy();
|
|
22350
22363
|
const ensureInstalled = deps.ensureInstalled ?? ensureCoderabbitInstalled;
|
|
22351
22364
|
const isLoggedIn = deps.isLoggedIn ?? defaultIsLoggedIn;
|
|
22352
22365
|
const runOAuth = deps.runOAuthLogin ?? runCoderabbitOAuthLogin;
|
|
22353
22366
|
const snapshot = deps.snapshotDir ?? (() => snapshotCredentialDir());
|
|
22354
22367
|
const capture2 = deps.captureCredential ?? ((b) => diffCapturedCredential(b));
|
|
22355
22368
|
const loginWithApiKey = deps.loginWithApiKey ?? defaultLoginWithApiKey;
|
|
22356
|
-
const home =
|
|
22357
|
-
|
|
22358
|
-
|
|
22359
|
-
|
|
22360
|
-
|
|
22361
|
-
|
|
22362
|
-
] : [
|
|
22369
|
+
const home = os68.homeDir();
|
|
22370
|
+
os68.augmentPath(
|
|
22371
|
+
os68.id === "win32" ? [
|
|
22372
|
+
path39.join(home, ".local", "bin"),
|
|
22373
|
+
path39.join(process.env.APPDATA ?? path39.join(home, "AppData", "Roaming"), "npm"),
|
|
22374
|
+
path39.join(home, "scoop", "shims")
|
|
22375
|
+
] : [path39.join(home, ".local", "bin"), "/opt/homebrew/bin", "/usr/local/bin"]
|
|
22363
22376
|
);
|
|
22364
|
-
const installed2 =
|
|
22377
|
+
const installed2 = os68.findInPath("coderabbit") !== null;
|
|
22365
22378
|
const base = () => ({
|
|
22366
22379
|
action: input.action,
|
|
22367
22380
|
supported: true,
|
|
22368
|
-
installed:
|
|
22381
|
+
installed: os68.findInPath("coderabbit") !== null,
|
|
22369
22382
|
loggedIn: false
|
|
22370
22383
|
});
|
|
22371
22384
|
if (input.action === "status") {
|
|
@@ -22379,7 +22392,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22379
22392
|
const key = (input.apiKey ?? "").trim();
|
|
22380
22393
|
if (!key) return { ...res2, error: "No API key provided" };
|
|
22381
22394
|
if (!res2.installed) {
|
|
22382
|
-
const inst = await ensureInstalled(
|
|
22395
|
+
const inst = await ensureInstalled(os68);
|
|
22383
22396
|
res2.installed = inst.ok;
|
|
22384
22397
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
22385
22398
|
}
|
|
@@ -22403,7 +22416,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22403
22416
|
}
|
|
22404
22417
|
if (!res2.installed) {
|
|
22405
22418
|
deps.onEvent?.({ kind: "installing" });
|
|
22406
|
-
const inst = await ensureInstalled(
|
|
22419
|
+
const inst = await ensureInstalled(os68);
|
|
22407
22420
|
res2.installed = inst.ok;
|
|
22408
22421
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
22409
22422
|
}
|
|
@@ -22420,7 +22433,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22420
22433
|
return { ...res2, loggedIn: true, linked: true };
|
|
22421
22434
|
}
|
|
22422
22435
|
try {
|
|
22423
|
-
restoreCoderabbitOauthBlob(
|
|
22436
|
+
restoreCoderabbitOauthBlob(os68, cred.credential);
|
|
22424
22437
|
} catch (err) {
|
|
22425
22438
|
return {
|
|
22426
22439
|
...res2,
|
|
@@ -22444,7 +22457,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22444
22457
|
const res2 = base();
|
|
22445
22458
|
if (!installed2) {
|
|
22446
22459
|
deps.onEvent?.({ kind: "installing" });
|
|
22447
|
-
const inst = await ensureInstalled(
|
|
22460
|
+
const inst = await ensureInstalled(os68);
|
|
22448
22461
|
res2.installed = inst.ok;
|
|
22449
22462
|
if (!inst.ok) return { ...res2, error: installFailureMessage(inst) };
|
|
22450
22463
|
}
|
|
@@ -22484,7 +22497,7 @@ async function configureCoderabbit(input, deps = {}) {
|
|
|
22484
22497
|
}
|
|
22485
22498
|
const res = base();
|
|
22486
22499
|
if (!res.installed) {
|
|
22487
|
-
const inst = await ensureInstalled(
|
|
22500
|
+
const inst = await ensureInstalled(os68);
|
|
22488
22501
|
res.installed = inst.ok;
|
|
22489
22502
|
if (!inst.ok) return { ...res, error: installFailureMessage(inst) };
|
|
22490
22503
|
}
|
|
@@ -22680,7 +22693,7 @@ var import_node_util7 = require("util");
|
|
|
22680
22693
|
// src/commands/host/workspace.ts
|
|
22681
22694
|
var fs33 = __toESM(require("fs"));
|
|
22682
22695
|
var os29 = __toESM(require("os"));
|
|
22683
|
-
var
|
|
22696
|
+
var path40 = __toESM(require("path"));
|
|
22684
22697
|
var import_node_child_process19 = require("child_process");
|
|
22685
22698
|
var import_node_util5 = require("util");
|
|
22686
22699
|
|
|
@@ -22720,18 +22733,18 @@ function restrictToOwner(filePath) {
|
|
|
22720
22733
|
// src/commands/host/workspace.ts
|
|
22721
22734
|
var execFileP4 = (0, import_node_util5.promisify)(import_node_child_process19.execFile);
|
|
22722
22735
|
function isAbsolutePathTarget(target) {
|
|
22723
|
-
return
|
|
22736
|
+
return path40.isAbsolute(target);
|
|
22724
22737
|
}
|
|
22725
22738
|
function selfHostedWorkspaceRoot() {
|
|
22726
|
-
return
|
|
22739
|
+
return path40.join(os29.homedir(), ".codeam", "self-hosted");
|
|
22727
22740
|
}
|
|
22728
22741
|
function deployIdFromWorkspace(cwd) {
|
|
22729
22742
|
if (!cwd) return null;
|
|
22730
22743
|
const root = selfHostedWorkspaceRoot();
|
|
22731
|
-
const resolved =
|
|
22732
|
-
const rel =
|
|
22733
|
-
if (!rel || rel.startsWith("..") ||
|
|
22734
|
-
const parts = rel.split(
|
|
22744
|
+
const resolved = path40.resolve(cwd);
|
|
22745
|
+
const rel = path40.relative(root, resolved);
|
|
22746
|
+
if (!rel || rel.startsWith("..") || path40.isAbsolute(rel)) return null;
|
|
22747
|
+
const parts = rel.split(path40.sep).filter(Boolean);
|
|
22735
22748
|
if (parts.length !== 1) return null;
|
|
22736
22749
|
return parts[0];
|
|
22737
22750
|
}
|
|
@@ -22803,7 +22816,7 @@ async function configureGitCredentials(dest, repoRef, cloneToken, provider = "gi
|
|
|
22803
22816
|
const isGitlab = provider === "gitlab";
|
|
22804
22817
|
if (isGitlab ? !gitlabProjectPath(repoRef.trim()) : !githubOwnerRepo(repoRef.trim())) return;
|
|
22805
22818
|
if (!cloneToken) return;
|
|
22806
|
-
const credFile =
|
|
22819
|
+
const credFile = path40.join(dest, ".git", "codeam-credentials");
|
|
22807
22820
|
const credLine = isGitlab ? `https://oauth2:${cloneToken}@gitlab.com
|
|
22808
22821
|
` : `https://x-access-token:${cloneToken}@github.com
|
|
22809
22822
|
`;
|
|
@@ -22811,7 +22824,7 @@ async function configureGitCredentials(dest, repoRef, cloneToken, provider = "gi
|
|
|
22811
22824
|
restrictToOwner(credFile);
|
|
22812
22825
|
const env = nonInteractiveGitEnv();
|
|
22813
22826
|
const git2 = (args2) => execFileP4("git", ["-C", dest, ...args2], { timeout: 3e4, env });
|
|
22814
|
-
const credFilePosix = credFile.split(
|
|
22827
|
+
const credFilePosix = credFile.split(path40.sep).join("/");
|
|
22815
22828
|
await git2(["config", "--local", "--replace-all", "credential.helper", ""]).catch(() => {
|
|
22816
22829
|
});
|
|
22817
22830
|
await git2([
|
|
@@ -22849,8 +22862,8 @@ async function prepareWorkspace(repoOrPath, deployId, cloneToken, provider = "gi
|
|
|
22849
22862
|
}
|
|
22850
22863
|
return repoOrPath;
|
|
22851
22864
|
}
|
|
22852
|
-
const dest =
|
|
22853
|
-
if (fs33.existsSync(
|
|
22865
|
+
const dest = path40.join(selfHostedWorkspaceRoot(), deployId);
|
|
22866
|
+
if (fs33.existsSync(path40.join(dest, ".git"))) {
|
|
22854
22867
|
if (cloneToken) await configureGitCredentials(dest, repoOrPath, cloneToken, provider);
|
|
22855
22868
|
return dest;
|
|
22856
22869
|
}
|
|
@@ -22998,13 +23011,13 @@ function buildZip(cwd, list, outFile) {
|
|
|
22998
23011
|
var import_crypto2 = require("crypto");
|
|
22999
23012
|
var fs37 = __toESM(require("fs"));
|
|
23000
23013
|
var os30 = __toESM(require("os"));
|
|
23001
|
-
var
|
|
23014
|
+
var path44 = __toESM(require("path"));
|
|
23002
23015
|
var entries = /* @__PURE__ */ new Map();
|
|
23003
23016
|
var EXPORT_TTL_MS = 6e5;
|
|
23004
23017
|
var RETRY_WINDOW_MS = 6e4;
|
|
23005
23018
|
var EXPORT_PATH_PREFIX = "/.codeam/export/";
|
|
23006
|
-
var exportsBaseDir = () =>
|
|
23007
|
-
var exportDir = () =>
|
|
23019
|
+
var exportsBaseDir = () => path44.join(os30.homedir(), ".codeam", "exports");
|
|
23020
|
+
var exportDir = () => path44.join(exportsBaseDir(), String(process.pid));
|
|
23008
23021
|
function drop(token) {
|
|
23009
23022
|
const e = entries.get(token);
|
|
23010
23023
|
if (!e) return;
|
|
@@ -23089,7 +23102,7 @@ function purgeExports() {
|
|
|
23089
23102
|
return;
|
|
23090
23103
|
}
|
|
23091
23104
|
for (const name of names) {
|
|
23092
|
-
const abs =
|
|
23105
|
+
const abs = path44.join(base, name);
|
|
23093
23106
|
try {
|
|
23094
23107
|
const st3 = fs37.lstatSync(abs);
|
|
23095
23108
|
const stale = st3.isDirectory() && /^\d+$/.test(name) ? Number(name) === process.pid || !isPidAlive(Number(name)) : Date.now() - st3.mtimeMs > EXPORT_TTL_MS;
|
|
@@ -23232,10 +23245,10 @@ async function spawnNamedTunnel(bin, token, port) {
|
|
|
23232
23245
|
// src/services/preview/port-registry.ts
|
|
23233
23246
|
var fs39 = __toESM(require("fs"));
|
|
23234
23247
|
var os32 = __toESM(require("os"));
|
|
23235
|
-
var
|
|
23248
|
+
var path46 = __toESM(require("path"));
|
|
23236
23249
|
var import_child_process15 = require("child_process");
|
|
23237
23250
|
function registryPath() {
|
|
23238
|
-
return
|
|
23251
|
+
return path46.join(os32.homedir(), ".codeam", "preview-ports.json");
|
|
23239
23252
|
}
|
|
23240
23253
|
function readRegistry() {
|
|
23241
23254
|
try {
|
|
@@ -23249,7 +23262,7 @@ function readRegistry() {
|
|
|
23249
23262
|
function writeRegistry(reg) {
|
|
23250
23263
|
try {
|
|
23251
23264
|
const file = registryPath();
|
|
23252
|
-
fs39.mkdirSync(
|
|
23265
|
+
fs39.mkdirSync(path46.dirname(file), { recursive: true });
|
|
23253
23266
|
const tmp = `${file}.tmp`;
|
|
23254
23267
|
fs39.writeFileSync(tmp, JSON.stringify(reg), "utf8");
|
|
23255
23268
|
fs39.renameSync(tmp, file);
|
|
@@ -23318,7 +23331,7 @@ function reclaimOwnOrphanPort(port) {
|
|
|
23318
23331
|
|
|
23319
23332
|
// src/services/preview/host-allow.ts
|
|
23320
23333
|
var import_fs3 = require("fs");
|
|
23321
|
-
var
|
|
23334
|
+
var path47 = __toESM(require("path"));
|
|
23322
23335
|
var NEXT_ALLOWED_ORIGINS = [
|
|
23323
23336
|
"*.trycloudflare.com",
|
|
23324
23337
|
"*.preview.codeagent-mobile.com",
|
|
@@ -23338,7 +23351,7 @@ var MARKER_DIR = ".codeam";
|
|
|
23338
23351
|
var MARKER_FILE = "preview-host-allow.json";
|
|
23339
23352
|
var ORIG_INFIX = ".codeam-orig";
|
|
23340
23353
|
function markerPath(cwd) {
|
|
23341
|
-
return
|
|
23354
|
+
return path47.join(cwd, MARKER_DIR, MARKER_FILE);
|
|
23342
23355
|
}
|
|
23343
23356
|
async function fileExists(p2) {
|
|
23344
23357
|
try {
|
|
@@ -23351,13 +23364,13 @@ async function fileExists(p2) {
|
|
|
23351
23364
|
async function findConfigFile(cwd, framework) {
|
|
23352
23365
|
const base = CONFIG_BASENAMES[framework];
|
|
23353
23366
|
for (const ext of CONFIG_EXTS) {
|
|
23354
|
-
if (await fileExists(
|
|
23367
|
+
if (await fileExists(path47.join(cwd, `${base}${ext}`))) return `${base}${ext}`;
|
|
23355
23368
|
}
|
|
23356
23369
|
return null;
|
|
23357
23370
|
}
|
|
23358
23371
|
async function dependsOn(cwd, pkgName) {
|
|
23359
23372
|
try {
|
|
23360
|
-
const raw = await import_fs3.promises.readFile(
|
|
23373
|
+
const raw = await import_fs3.promises.readFile(path47.join(cwd, "package.json"), "utf8");
|
|
23361
23374
|
const pkg = JSON.parse(raw);
|
|
23362
23375
|
return !!(pkg.dependencies?.[pkgName] ?? pkg.devDependencies?.[pkgName]);
|
|
23363
23376
|
} catch {
|
|
@@ -23365,11 +23378,11 @@ async function dependsOn(cwd, pkgName) {
|
|
|
23365
23378
|
}
|
|
23366
23379
|
}
|
|
23367
23380
|
async function isEsmConfig(cwd, configFile) {
|
|
23368
|
-
const ext =
|
|
23381
|
+
const ext = path47.extname(configFile);
|
|
23369
23382
|
if (ext === ".mjs" || ext === ".mts" || ext === ".ts") return true;
|
|
23370
23383
|
if (ext === ".cjs") return false;
|
|
23371
23384
|
try {
|
|
23372
|
-
const raw = await import_fs3.promises.readFile(
|
|
23385
|
+
const raw = await import_fs3.promises.readFile(path47.join(cwd, "package.json"), "utf8");
|
|
23373
23386
|
return JSON.parse(raw).type === "module";
|
|
23374
23387
|
} catch {
|
|
23375
23388
|
return false;
|
|
@@ -23460,7 +23473,7 @@ async function isOurShim(abs) {
|
|
|
23460
23473
|
}
|
|
23461
23474
|
}
|
|
23462
23475
|
async function writeMarker(cwd, marker) {
|
|
23463
|
-
await import_fs3.promises.mkdir(
|
|
23476
|
+
await import_fs3.promises.mkdir(path47.join(cwd, MARKER_DIR), { recursive: true });
|
|
23464
23477
|
await import_fs3.promises.writeFile(markerPath(cwd), JSON.stringify(marker, null, 2), "utf8");
|
|
23465
23478
|
}
|
|
23466
23479
|
async function readMarker(cwd) {
|
|
@@ -23475,9 +23488,9 @@ async function restorePreviewHostAllow(cwd) {
|
|
|
23475
23488
|
const marker = await readMarker(cwd);
|
|
23476
23489
|
if (!marker) return;
|
|
23477
23490
|
try {
|
|
23478
|
-
const configAbs =
|
|
23491
|
+
const configAbs = path47.join(cwd, marker.configFile);
|
|
23479
23492
|
if (marker.backupFile) {
|
|
23480
|
-
const backupAbs =
|
|
23493
|
+
const backupAbs = path47.join(cwd, marker.backupFile);
|
|
23481
23494
|
if (await fileExists(backupAbs)) {
|
|
23482
23495
|
await import_fs3.promises.rm(configAbs, { force: true });
|
|
23483
23496
|
await import_fs3.promises.rename(backupAbs, configAbs);
|
|
@@ -23510,26 +23523,26 @@ async function applyPreviewHostAllow(cwd) {
|
|
|
23510
23523
|
}
|
|
23511
23524
|
if (!framework) return;
|
|
23512
23525
|
if (existing) {
|
|
23513
|
-
const ext =
|
|
23526
|
+
const ext = path47.extname(existing);
|
|
23514
23527
|
const origBasename = `${CONFIG_BASENAMES[framework]}${ORIG_INFIX}${ext}`;
|
|
23515
|
-
if (await isOurShim(
|
|
23516
|
-
const origAbs =
|
|
23528
|
+
if (await isOurShim(path47.join(cwd, existing))) {
|
|
23529
|
+
const origAbs = path47.join(cwd, origBasename);
|
|
23517
23530
|
if (!await fileExists(origAbs) || await isOurShim(origAbs)) {
|
|
23518
23531
|
log.warn("preview", `host-allow: ${existing} is a leftover shim with no original \u2014 skipped`);
|
|
23519
23532
|
return;
|
|
23520
23533
|
}
|
|
23521
|
-
await import_fs3.promises.rm(
|
|
23522
|
-
await import_fs3.promises.rename(origAbs,
|
|
23534
|
+
await import_fs3.promises.rm(path47.join(cwd, existing), { force: true });
|
|
23535
|
+
await import_fs3.promises.rename(origAbs, path47.join(cwd, existing));
|
|
23523
23536
|
log.info("preview", `host-allow: restored ${existing} from a leftover ${origBasename}`);
|
|
23524
23537
|
}
|
|
23525
23538
|
const esm = await isEsmConfig(cwd, existing);
|
|
23526
|
-
await import_fs3.promises.rename(
|
|
23527
|
-
await import_fs3.promises.writeFile(
|
|
23539
|
+
await import_fs3.promises.rename(path47.join(cwd, existing), path47.join(cwd, origBasename));
|
|
23540
|
+
await import_fs3.promises.writeFile(path47.join(cwd, existing), shimFor(framework, origBasename, esm), "utf8");
|
|
23528
23541
|
await writeMarker(cwd, { framework, configFile: existing, backupFile: origBasename });
|
|
23529
23542
|
log.info("preview", `host-allow: wrapped ${existing} (${framework}) for tunnel access`);
|
|
23530
23543
|
} else {
|
|
23531
23544
|
const configFile = `${CONFIG_BASENAMES[framework]}.mjs`;
|
|
23532
|
-
await import_fs3.promises.writeFile(
|
|
23545
|
+
await import_fs3.promises.writeFile(path47.join(cwd, configFile), shimFor(framework, null, true), "utf8");
|
|
23533
23546
|
await writeMarker(cwd, { framework, configFile, backupFile: null });
|
|
23534
23547
|
log.info("preview", `host-allow: created ${configFile} (${framework}) for tunnel access`);
|
|
23535
23548
|
}
|
|
@@ -23540,7 +23553,7 @@ async function applyPreviewHostAllow(cwd) {
|
|
|
23540
23553
|
|
|
23541
23554
|
// src/services/preview/build-heal.ts
|
|
23542
23555
|
var fs41 = __toESM(require("fs"));
|
|
23543
|
-
var
|
|
23556
|
+
var path48 = __toESM(require("path"));
|
|
23544
23557
|
var BUILD_MARKER_NAME = "BUILD_ID";
|
|
23545
23558
|
var DEFAULT_DEBOUNCE_MS = 1500;
|
|
23546
23559
|
var DEFAULT_MAX_RESTARTS = 3;
|
|
@@ -23570,9 +23583,9 @@ var healRestartCounts = /* @__PURE__ */ new Map();
|
|
|
23570
23583
|
function resetBuildHealState(sessionId) {
|
|
23571
23584
|
healRestartCounts.delete(sessionId);
|
|
23572
23585
|
}
|
|
23573
|
-
function readMarker2(
|
|
23586
|
+
function readMarker2(markerPath3) {
|
|
23574
23587
|
try {
|
|
23575
|
-
return fs41.readFileSync(
|
|
23588
|
+
return fs41.readFileSync(markerPath3, "utf8").trim();
|
|
23576
23589
|
} catch {
|
|
23577
23590
|
return null;
|
|
23578
23591
|
}
|
|
@@ -23581,13 +23594,13 @@ function watchForBuildClobber(deps) {
|
|
|
23581
23594
|
const watchDir = deps.watchDir ?? defaultWatchDir;
|
|
23582
23595
|
const debounceMs = deps.debounceMs ?? DEFAULT_DEBOUNCE_MS;
|
|
23583
23596
|
const maxRestarts = deps.maxRestarts ?? DEFAULT_MAX_RESTARTS;
|
|
23584
|
-
const nextDir =
|
|
23585
|
-
const
|
|
23597
|
+
const nextDir = path48.join(deps.cwd, ".next");
|
|
23598
|
+
const markerPath3 = path48.join(nextDir, BUILD_MARKER_NAME);
|
|
23586
23599
|
let stopped = false;
|
|
23587
23600
|
let debounceTimer = null;
|
|
23588
23601
|
let dirUnwatch = null;
|
|
23589
23602
|
let cwdUnwatch = null;
|
|
23590
|
-
let lastKnownMarker = readMarker2(
|
|
23603
|
+
let lastKnownMarker = readMarker2(markerPath3);
|
|
23591
23604
|
const stop = () => {
|
|
23592
23605
|
if (stopped) return;
|
|
23593
23606
|
stopped = true;
|
|
@@ -23602,7 +23615,7 @@ function watchForBuildClobber(deps) {
|
|
|
23602
23615
|
};
|
|
23603
23616
|
const onDebouncedClobber = () => {
|
|
23604
23617
|
if (stopped) return;
|
|
23605
|
-
const current2 = readMarker2(
|
|
23618
|
+
const current2 = readMarker2(markerPath3);
|
|
23606
23619
|
if (current2 === lastKnownMarker) return;
|
|
23607
23620
|
lastKnownMarker = current2;
|
|
23608
23621
|
const count = (healRestartCounts.get(deps.sessionId) ?? 0) + 1;
|
|
@@ -23620,7 +23633,7 @@ function watchForBuildClobber(deps) {
|
|
|
23620
23633
|
}
|
|
23621
23634
|
log.info(
|
|
23622
23635
|
"preview",
|
|
23623
|
-
`build-heal: ${
|
|
23636
|
+
`build-heal: ${markerPath3} changed (a build likely ran) \u2014 restarting the dev server (${count}/${maxRestarts})`
|
|
23624
23637
|
);
|
|
23625
23638
|
deps.notify("Rebuilt \u2014 restarting preview");
|
|
23626
23639
|
deps.restart();
|
|
@@ -23635,7 +23648,7 @@ function watchForBuildClobber(deps) {
|
|
|
23635
23648
|
};
|
|
23636
23649
|
const attachDirWatch = () => {
|
|
23637
23650
|
if (dirUnwatch) return;
|
|
23638
|
-
lastKnownMarker = readMarker2(
|
|
23651
|
+
lastKnownMarker = readMarker2(markerPath3);
|
|
23639
23652
|
dirUnwatch = watchDir(nextDir, (filename) => {
|
|
23640
23653
|
if (filename === null || filename === BUILD_MARKER_NAME) onMarkerTouched();
|
|
23641
23654
|
});
|
|
@@ -23745,7 +23758,7 @@ function quoteIfNeeded(value) {
|
|
|
23745
23758
|
|
|
23746
23759
|
// src/services/preview/expo.ts
|
|
23747
23760
|
var http6 = __toESM(require("http"));
|
|
23748
|
-
var
|
|
23761
|
+
var path50 = __toESM(require("path"));
|
|
23749
23762
|
var EXPO_PACKAGER_PROXY_URL_ENV = "EXPO_PACKAGER_PROXY_URL";
|
|
23750
23763
|
function stripExpoTunnelFlag(args2) {
|
|
23751
23764
|
return args2.filter((a) => a !== "--tunnel" && !a.startsWith("--tunnel="));
|
|
@@ -23754,7 +23767,7 @@ function ensureExpoPortArg(command2, args2, port) {
|
|
|
23754
23767
|
const hasPort = args2.some((a) => a === "--port" || a.startsWith("--port="));
|
|
23755
23768
|
if (hasPort) return [...args2];
|
|
23756
23769
|
const out2 = [...args2];
|
|
23757
|
-
if (
|
|
23770
|
+
if (path50.basename(command2) === "npm" && !out2.includes("--")) out2.push("--");
|
|
23758
23771
|
out2.push("--port", String(port));
|
|
23759
23772
|
return out2;
|
|
23760
23773
|
}
|
|
@@ -24379,7 +24392,7 @@ function isJsInstallCommand(cmd, args2) {
|
|
|
24379
24392
|
|
|
24380
24393
|
// src/services/preview/script-candidates.ts
|
|
24381
24394
|
var fs45 = __toESM(require("fs"));
|
|
24382
|
-
var
|
|
24395
|
+
var path53 = __toESM(require("path"));
|
|
24383
24396
|
var EXCLUDE_RE = /(^|:)(deploy|publish|release|build|test|e2e|lint|format|typecheck|type-check|clean|prebuild|postinstall|preinstall|prepare|install|migrate|seed|db|prisma|codegen|storybook-build)(:|$)/i;
|
|
24384
24397
|
var EXCLUDE_BODY_RE = /\b(run:android|run:ios|gradlew|fastlane|xcodebuild|eas build|eas submit)\b/i;
|
|
24385
24398
|
var MAX_APPS = 40;
|
|
@@ -24407,7 +24420,7 @@ function expandGlob(root, pattern) {
|
|
|
24407
24420
|
if (!clean.endsWith("/*")) return [clean];
|
|
24408
24421
|
const base = clean.slice(0, -2);
|
|
24409
24422
|
try {
|
|
24410
|
-
return fs45.readdirSync(
|
|
24423
|
+
return fs45.readdirSync(path53.join(root, base), { withFileTypes: true }).filter((d3) => d3.isDirectory() && !d3.name.startsWith(".") && d3.name !== "node_modules").map((d3) => path53.join(base, d3.name));
|
|
24411
24424
|
} catch {
|
|
24412
24425
|
return [];
|
|
24413
24426
|
}
|
|
@@ -24416,7 +24429,7 @@ function workspaceDirs(root, rootPkg) {
|
|
|
24416
24429
|
const ws = rootPkg?.workspaces;
|
|
24417
24430
|
const patterns = Array.isArray(ws) ? ws : ws?.packages ?? [];
|
|
24418
24431
|
try {
|
|
24419
|
-
const pnpm = fs45.readFileSync(
|
|
24432
|
+
const pnpm = fs45.readFileSync(path53.join(root, "pnpm-workspace.yaml"), "utf8");
|
|
24420
24433
|
for (const m of pnpm.matchAll(/^\s*-\s*['"]?([^'"\n]+)['"]?\s*$/gm)) patterns.push(m[1]);
|
|
24421
24434
|
} catch {
|
|
24422
24435
|
}
|
|
@@ -24427,14 +24440,14 @@ function workspaceDirs(root, rootPkg) {
|
|
|
24427
24440
|
}
|
|
24428
24441
|
function listScriptCandidates(root) {
|
|
24429
24442
|
const out2 = [];
|
|
24430
|
-
const rootPkg = readPkg(
|
|
24443
|
+
const rootPkg = readPkg(path53.join(root, "package.json"));
|
|
24431
24444
|
const add = (pkg, appDir) => {
|
|
24432
24445
|
for (const [script, body] of Object.entries(pkg.scripts ?? {})) {
|
|
24433
24446
|
if (out2.length >= MAX_CANDIDATES) return;
|
|
24434
24447
|
if (EXCLUDE_RE.test(script) || EXCLUDE_BODY_RE.test(body)) continue;
|
|
24435
24448
|
const fw = frameworkFor(pkg, body);
|
|
24436
24449
|
out2.push({
|
|
24437
|
-
app: pkg.name ?? (appDir === "." ?
|
|
24450
|
+
app: pkg.name ?? (appDir === "." ? path53.basename(root) : appDir),
|
|
24438
24451
|
appDir,
|
|
24439
24452
|
script,
|
|
24440
24453
|
body,
|
|
@@ -24448,8 +24461,8 @@ function listScriptCandidates(root) {
|
|
|
24448
24461
|
};
|
|
24449
24462
|
if (rootPkg) add(rootPkg, ".");
|
|
24450
24463
|
for (const dir of workspaceDirs(root, rootPkg)) {
|
|
24451
|
-
const pkg = readPkg(
|
|
24452
|
-
if (pkg) add(pkg, dir.split(
|
|
24464
|
+
const pkg = readPkg(path53.join(root, dir, "package.json"));
|
|
24465
|
+
if (pkg) add(pkg, dir.split(path53.sep).join("/"));
|
|
24453
24466
|
}
|
|
24454
24467
|
return out2;
|
|
24455
24468
|
}
|
|
@@ -25079,32 +25092,66 @@ async function saveToProviderH(ctx, provider) {
|
|
|
25079
25092
|
}
|
|
25080
25093
|
}
|
|
25081
25094
|
|
|
25095
|
+
// src/services/preview/active-marker.ts
|
|
25096
|
+
var import_node_crypto10 = require("crypto");
|
|
25097
|
+
var import_promises5 = __toESM(require("fs/promises"));
|
|
25098
|
+
var import_node_os6 = __toESM(require("os"));
|
|
25099
|
+
var import_node_path11 = __toESM(require("path"));
|
|
25100
|
+
function markerPath2(cwd, homeDir2 = import_node_os6.default.homedir()) {
|
|
25101
|
+
const key = (0, import_node_crypto10.createHash)("sha256").update(import_node_path11.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
25102
|
+
return import_node_path11.default.join(homeDir2, ".codeam", "preview-active", `${key}.json`);
|
|
25103
|
+
}
|
|
25104
|
+
async function writeActivePreviewMarker(cwd, detection, homeDir2) {
|
|
25105
|
+
try {
|
|
25106
|
+
const file = markerPath2(cwd, homeDir2);
|
|
25107
|
+
await import_promises5.default.mkdir(import_node_path11.default.dirname(file), { recursive: true });
|
|
25108
|
+
await import_promises5.default.writeFile(
|
|
25109
|
+
file,
|
|
25110
|
+
JSON.stringify({ detection, at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2) + "\n",
|
|
25111
|
+
"utf8"
|
|
25112
|
+
);
|
|
25113
|
+
} catch {
|
|
25114
|
+
}
|
|
25115
|
+
}
|
|
25116
|
+
async function clearActivePreviewMarker(cwd, homeDir2) {
|
|
25117
|
+
await import_promises5.default.rm(markerPath2(cwd, homeDir2), { force: true }).catch(() => void 0);
|
|
25118
|
+
}
|
|
25119
|
+
async function readActivePreviewMarker(cwd, homeDir2) {
|
|
25120
|
+
try {
|
|
25121
|
+
const raw = await import_promises5.default.readFile(markerPath2(cwd, homeDir2), "utf8");
|
|
25122
|
+
const parsed = JSON.parse(raw);
|
|
25123
|
+
return parsed.detection && typeof parsed.detection.command === "string" ? parsed.detection : null;
|
|
25124
|
+
} catch {
|
|
25125
|
+
return null;
|
|
25126
|
+
}
|
|
25127
|
+
}
|
|
25128
|
+
|
|
25082
25129
|
// src/agents/acp/guardrail-config.ts
|
|
25083
|
-
var
|
|
25084
|
-
var
|
|
25085
|
-
var
|
|
25130
|
+
var fs49 = __toESM(require("fs"));
|
|
25131
|
+
var path57 = __toESM(require("path"));
|
|
25132
|
+
var os35 = __toESM(require("os"));
|
|
25086
25133
|
var current = null;
|
|
25087
|
-
function guardrailConfigPath(homeDir2 =
|
|
25088
|
-
return
|
|
25134
|
+
function guardrailConfigPath(homeDir2 = os35.homedir()) {
|
|
25135
|
+
return path57.join(homeDir2, ".codeam", "guardrails.json");
|
|
25089
25136
|
}
|
|
25090
|
-
function loadGuardrailPolicy(homeDir2 =
|
|
25137
|
+
function loadGuardrailPolicy(homeDir2 = os35.homedir()) {
|
|
25091
25138
|
try {
|
|
25092
|
-
current = normalizeGuardrailPolicy(JSON.parse(
|
|
25139
|
+
current = normalizeGuardrailPolicy(JSON.parse(fs49.readFileSync(guardrailConfigPath(homeDir2), "utf8")));
|
|
25093
25140
|
} catch {
|
|
25094
25141
|
current = { ...DEFAULT_GUARDRAIL_POLICY };
|
|
25095
25142
|
}
|
|
25096
25143
|
return current;
|
|
25097
25144
|
}
|
|
25098
|
-
function getGuardrailPolicy(homeDir2 =
|
|
25145
|
+
function getGuardrailPolicy(homeDir2 = os35.homedir()) {
|
|
25099
25146
|
return current ?? loadGuardrailPolicy(homeDir2);
|
|
25100
25147
|
}
|
|
25101
|
-
function setGuardrailPolicy(raw, homeDir2 =
|
|
25148
|
+
function setGuardrailPolicy(raw, homeDir2 = os35.homedir()) {
|
|
25102
25149
|
const next = normalizeGuardrailPolicy(raw);
|
|
25103
25150
|
current = next;
|
|
25104
25151
|
try {
|
|
25105
25152
|
const p2 = guardrailConfigPath(homeDir2);
|
|
25106
|
-
|
|
25107
|
-
|
|
25153
|
+
fs49.mkdirSync(path57.dirname(p2), { recursive: true });
|
|
25154
|
+
fs49.writeFileSync(p2, JSON.stringify(next, null, 2));
|
|
25108
25155
|
} catch {
|
|
25109
25156
|
}
|
|
25110
25157
|
return next;
|
|
@@ -25120,22 +25167,22 @@ function shouldOfferOneMRecovery(opts) {
|
|
|
25120
25167
|
}
|
|
25121
25168
|
|
|
25122
25169
|
// src/commands/host/house-proxy-config.ts
|
|
25123
|
-
var
|
|
25124
|
-
var
|
|
25125
|
-
var
|
|
25170
|
+
var fs50 = __toESM(require("fs"));
|
|
25171
|
+
var os36 = __toESM(require("os"));
|
|
25172
|
+
var path58 = __toESM(require("path"));
|
|
25126
25173
|
function houseProxyConfigPath() {
|
|
25127
|
-
return
|
|
25174
|
+
return path58.join(os36.homedir(), ".codeam", "house-proxy.json");
|
|
25128
25175
|
}
|
|
25129
25176
|
var DEPLOY_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
25130
25177
|
function deployHouseProxyConfigPath(deployId) {
|
|
25131
25178
|
if (!DEPLOY_ID_RE.test(deployId) || deployId.includes("..")) return null;
|
|
25132
|
-
return
|
|
25179
|
+
return path58.join(os36.homedir(), ".codeam", "house-proxy", `${deployId}.json`);
|
|
25133
25180
|
}
|
|
25134
25181
|
function writeJson0600(file, value) {
|
|
25135
|
-
|
|
25182
|
+
fs50.mkdirSync(path58.dirname(file), { recursive: true, mode: 448 });
|
|
25136
25183
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
25137
|
-
|
|
25138
|
-
|
|
25184
|
+
fs50.writeFileSync(tmp, JSON.stringify(value, null, 2), { encoding: "utf8", mode: 384 });
|
|
25185
|
+
fs50.renameSync(tmp, file);
|
|
25139
25186
|
restrictToOwner(file);
|
|
25140
25187
|
}
|
|
25141
25188
|
function persistHouseProxyConfig(config, deployId) {
|
|
@@ -25152,7 +25199,7 @@ function persistHouseProxyConfig(config, deployId) {
|
|
|
25152
25199
|
}
|
|
25153
25200
|
function clearHouseProxyConfig(deployId) {
|
|
25154
25201
|
try {
|
|
25155
|
-
|
|
25202
|
+
fs50.rmSync(houseProxyConfigPath(), { force: true });
|
|
25156
25203
|
const perDeploy = deployId ? deployHouseProxyConfigPath(deployId) : null;
|
|
25157
25204
|
if (perDeploy) writeJson0600(perDeploy, { none: true });
|
|
25158
25205
|
} catch {
|
|
@@ -25161,8 +25208,8 @@ function clearHouseProxyConfig(deployId) {
|
|
|
25161
25208
|
function readHouseProxyChildEnv(deployId) {
|
|
25162
25209
|
try {
|
|
25163
25210
|
const perDeploy = deployId ? deployHouseProxyConfigPath(deployId) : null;
|
|
25164
|
-
const file = perDeploy &&
|
|
25165
|
-
const raw =
|
|
25211
|
+
const file = perDeploy && fs50.existsSync(perDeploy) ? perDeploy : houseProxyConfigPath();
|
|
25212
|
+
const raw = fs50.readFileSync(file, "utf8");
|
|
25166
25213
|
const parsed = JSON.parse(raw);
|
|
25167
25214
|
if (typeof parsed !== "object" || parsed === null) return {};
|
|
25168
25215
|
const o = parsed;
|
|
@@ -25268,9 +25315,9 @@ function pickHouseProxyEnv(env) {
|
|
|
25268
25315
|
}
|
|
25269
25316
|
|
|
25270
25317
|
// src/lib/provider-routing.ts
|
|
25271
|
-
var
|
|
25272
|
-
var
|
|
25273
|
-
var
|
|
25318
|
+
var fs51 = __toESM(require("fs"));
|
|
25319
|
+
var os37 = __toESM(require("os"));
|
|
25320
|
+
var path59 = __toESM(require("path"));
|
|
25274
25321
|
var PROVIDER_BASE_URL_ENV_KEYS = [
|
|
25275
25322
|
"ANTHROPIC_BASE_URL",
|
|
25276
25323
|
"OPENAI_BASE_URL",
|
|
@@ -25292,15 +25339,15 @@ function redactUrlToOrigin(raw) {
|
|
|
25292
25339
|
}
|
|
25293
25340
|
}
|
|
25294
25341
|
function readOpencodeProviderOrigins(opts = {}) {
|
|
25295
|
-
const home = opts.homeDir ??
|
|
25296
|
-
const readFile7 = opts.readFile ?? ((f) =>
|
|
25342
|
+
const home = opts.homeDir ?? os37.homedir();
|
|
25343
|
+
const readFile7 = opts.readFile ?? ((f) => fs51.readFileSync(f, "utf8"));
|
|
25297
25344
|
const candidates = [];
|
|
25298
25345
|
if (opts.cwd) {
|
|
25299
|
-
candidates.push(
|
|
25346
|
+
candidates.push(path59.join(opts.cwd, "opencode.json"), path59.join(opts.cwd, "opencode.jsonc"));
|
|
25300
25347
|
}
|
|
25301
25348
|
candidates.push(
|
|
25302
|
-
|
|
25303
|
-
|
|
25349
|
+
path59.join(home, ".config", "opencode", "opencode.json"),
|
|
25350
|
+
path59.join(home, ".config", "opencode", "opencode.jsonc")
|
|
25304
25351
|
);
|
|
25305
25352
|
const out2 = [];
|
|
25306
25353
|
const seen2 = /* @__PURE__ */ new Set();
|
|
@@ -25608,19 +25655,19 @@ function adapterExitMessage(opts) {
|
|
|
25608
25655
|
|
|
25609
25656
|
// src/services/preview/start-orchestrator.ts
|
|
25610
25657
|
var import_child_process20 = require("child_process");
|
|
25611
|
-
var
|
|
25612
|
-
var
|
|
25658
|
+
var fs54 = __toESM(require("fs"));
|
|
25659
|
+
var path62 = __toESM(require("path"));
|
|
25613
25660
|
var import_which3 = __toESM(require("which"));
|
|
25614
25661
|
|
|
25615
25662
|
// src/services/project-env/index.ts
|
|
25616
25663
|
var import_fs6 = require("fs");
|
|
25617
|
-
var
|
|
25664
|
+
var path61 = __toESM(require("path"));
|
|
25618
25665
|
|
|
25619
25666
|
// src/beads/project-key.ts
|
|
25620
25667
|
var import_child_process19 = require("child_process");
|
|
25621
25668
|
var crypto2 = __toESM(require("crypto"));
|
|
25622
|
-
var
|
|
25623
|
-
var
|
|
25669
|
+
var fs52 = __toESM(require("fs"));
|
|
25670
|
+
var path60 = __toESM(require("path"));
|
|
25624
25671
|
function normalizeOrigin(raw) {
|
|
25625
25672
|
const trimmed = raw.trim();
|
|
25626
25673
|
if (!trimmed) return null;
|
|
@@ -25646,17 +25693,17 @@ function normalizeOrigin(raw) {
|
|
|
25646
25693
|
return `${host2}/${pathPart}`;
|
|
25647
25694
|
}
|
|
25648
25695
|
function findRepoRoot(cwd) {
|
|
25649
|
-
let dir =
|
|
25696
|
+
let dir = path60.resolve(cwd);
|
|
25650
25697
|
const seen2 = /* @__PURE__ */ new Set();
|
|
25651
25698
|
for (let i = 0; i < 256; i++) {
|
|
25652
25699
|
if (seen2.has(dir)) return null;
|
|
25653
25700
|
seen2.add(dir);
|
|
25654
25701
|
try {
|
|
25655
|
-
const stat3 =
|
|
25702
|
+
const stat3 = fs52.statSync(path60.join(dir, ".git"), { throwIfNoEntry: false });
|
|
25656
25703
|
if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
|
|
25657
25704
|
} catch {
|
|
25658
25705
|
}
|
|
25659
|
-
const parent =
|
|
25706
|
+
const parent = path60.dirname(dir);
|
|
25660
25707
|
if (parent === dir) return null;
|
|
25661
25708
|
dir = parent;
|
|
25662
25709
|
}
|
|
@@ -25667,7 +25714,7 @@ var _execSeam3 = {
|
|
|
25667
25714
|
const out2 = (0, import_child_process19.execFileSync)(file, args2, opts);
|
|
25668
25715
|
return typeof out2 === "string" ? out2 : out2.toString("utf8");
|
|
25669
25716
|
},
|
|
25670
|
-
realpath: (p2) =>
|
|
25717
|
+
realpath: (p2) => fs52.realpathSync(p2)
|
|
25671
25718
|
};
|
|
25672
25719
|
function readOrigin(cwd) {
|
|
25673
25720
|
try {
|
|
@@ -25696,7 +25743,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
|
|
|
25696
25743
|
} catch {
|
|
25697
25744
|
}
|
|
25698
25745
|
const hash = crypto2.createHash("sha256").update(real).digest("hex");
|
|
25699
|
-
return { projectKey: `path:${hash}`, projectLabel:
|
|
25746
|
+
return { projectKey: `path:${hash}`, projectLabel: path60.basename(real) || "project" };
|
|
25700
25747
|
}
|
|
25701
25748
|
|
|
25702
25749
|
// src/services/project-env/index.ts
|
|
@@ -25709,7 +25756,7 @@ async function readIfExists(p2) {
|
|
|
25709
25756
|
}
|
|
25710
25757
|
async function syncProjectEnvUp(cwd, ctx) {
|
|
25711
25758
|
if (!ctx.pluginAuthToken) return;
|
|
25712
|
-
const content = await readIfExists(
|
|
25759
|
+
const content = await readIfExists(path61.join(cwd, ".env"));
|
|
25713
25760
|
if (content == null) return;
|
|
25714
25761
|
try {
|
|
25715
25762
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -25731,7 +25778,7 @@ async function syncProjectEnvUp(cwd, ctx) {
|
|
|
25731
25778
|
}
|
|
25732
25779
|
async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
25733
25780
|
if (!ctx.pluginAuthToken) return false;
|
|
25734
|
-
const envPath =
|
|
25781
|
+
const envPath = path61.join(cwd, ".env");
|
|
25735
25782
|
if (await readIfExists(envPath) != null) return false;
|
|
25736
25783
|
try {
|
|
25737
25784
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -25742,7 +25789,7 @@ async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
|
25742
25789
|
projectKey
|
|
25743
25790
|
});
|
|
25744
25791
|
if (!stored) return false;
|
|
25745
|
-
const tmp =
|
|
25792
|
+
const tmp = path61.join(cwd, ".env.codeam-restore.tmp");
|
|
25746
25793
|
await import_fs6.promises.writeFile(tmp, stored.content, { encoding: "utf8", mode: 384 });
|
|
25747
25794
|
await import_fs6.promises.rename(tmp, envPath);
|
|
25748
25795
|
log.info("project-env", `restored .env (${stored.keyCount} vars) for ${projectLabel}`);
|
|
@@ -26506,8 +26553,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
|
|
|
26506
26553
|
if (args2.length === 0) return detection;
|
|
26507
26554
|
const binName = args2[0];
|
|
26508
26555
|
if (binName.startsWith("-")) return detection;
|
|
26509
|
-
const binPath =
|
|
26510
|
-
if (!
|
|
26556
|
+
const binPath = path62.join(cwd, "node_modules", ".bin", binName);
|
|
26557
|
+
if (!fs54.existsSync(binPath)) return detection;
|
|
26511
26558
|
return {
|
|
26512
26559
|
...detection,
|
|
26513
26560
|
command: binPath,
|
|
@@ -26587,6 +26634,7 @@ function announceReady(ctx, dev, tun) {
|
|
|
26587
26634
|
recordPreviewPort(detection.port, dev.devServer.pid, sessionId, Date.now());
|
|
26588
26635
|
}
|
|
26589
26636
|
log.info("preview", `ready: ${detection.framework} at ${tun.url}`);
|
|
26637
|
+
void writeActivePreviewMarker(ctx.cwd, detection);
|
|
26590
26638
|
emit2(USER_EVENTS.PREVIEW_READY, {
|
|
26591
26639
|
url: tun.url,
|
|
26592
26640
|
framework: detection.framework,
|
|
@@ -26919,9 +26967,9 @@ async function bringUpPublicUrl(ctx, tunnelPort) {
|
|
|
26919
26967
|
|
|
26920
26968
|
// src/beads/bd-adapter.ts
|
|
26921
26969
|
var import_child_process21 = require("child_process");
|
|
26922
|
-
var
|
|
26923
|
-
var
|
|
26924
|
-
var
|
|
26970
|
+
var fs55 = __toESM(require("fs"));
|
|
26971
|
+
var os38 = __toESM(require("os"));
|
|
26972
|
+
var path63 = __toESM(require("path"));
|
|
26925
26973
|
var BD_PACKAGE = "@beads/bd";
|
|
26926
26974
|
function resolveBundledBdBinary() {
|
|
26927
26975
|
return _resolveSeam.resolveBundled();
|
|
@@ -26933,11 +26981,11 @@ function _defaultResolveBundled() {
|
|
|
26933
26981
|
} catch {
|
|
26934
26982
|
return null;
|
|
26935
26983
|
}
|
|
26936
|
-
const binDir =
|
|
26984
|
+
const binDir = path63.join(path63.dirname(pkgJsonPath), "bin");
|
|
26937
26985
|
const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
|
|
26938
|
-
const binaryPath =
|
|
26986
|
+
const binaryPath = path63.join(binDir, binaryName);
|
|
26939
26987
|
try {
|
|
26940
|
-
|
|
26988
|
+
fs55.accessSync(binaryPath, fs55.constants.F_OK);
|
|
26941
26989
|
return binaryPath;
|
|
26942
26990
|
} catch {
|
|
26943
26991
|
return null;
|
|
@@ -26947,13 +26995,13 @@ function resolveBdOnPath() {
|
|
|
26947
26995
|
return _resolveSeam.resolveOnPath();
|
|
26948
26996
|
}
|
|
26949
26997
|
function _defaultResolveOnPath() {
|
|
26950
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
26998
|
+
const dirs = (process.env.PATH ?? "").split(path63.delimiter).filter(Boolean);
|
|
26951
26999
|
const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
|
|
26952
27000
|
for (const dir of dirs) {
|
|
26953
27001
|
for (const candidate of candidates) {
|
|
26954
|
-
const full =
|
|
27002
|
+
const full = path63.join(dir, candidate);
|
|
26955
27003
|
try {
|
|
26956
|
-
|
|
27004
|
+
fs55.accessSync(full, fs55.constants.F_OK);
|
|
26957
27005
|
return full;
|
|
26958
27006
|
} catch {
|
|
26959
27007
|
}
|
|
@@ -27038,7 +27086,7 @@ var BdAdapter = class {
|
|
|
27038
27086
|
const env = { ...process.env };
|
|
27039
27087
|
if (!env.HOME) {
|
|
27040
27088
|
try {
|
|
27041
|
-
const home =
|
|
27089
|
+
const home = os38.homedir();
|
|
27042
27090
|
if (home) env.HOME = home;
|
|
27043
27091
|
} catch {
|
|
27044
27092
|
}
|
|
@@ -27130,9 +27178,9 @@ function coerceIssue(row, projectKey) {
|
|
|
27130
27178
|
|
|
27131
27179
|
// src/beads/provisioner.ts
|
|
27132
27180
|
var import_child_process24 = require("child_process");
|
|
27133
|
-
var
|
|
27134
|
-
var
|
|
27135
|
-
var
|
|
27181
|
+
var fs57 = __toESM(require("fs"));
|
|
27182
|
+
var os40 = __toESM(require("os"));
|
|
27183
|
+
var path65 = __toESM(require("path"));
|
|
27136
27184
|
|
|
27137
27185
|
// src/beads/install-bd.ts
|
|
27138
27186
|
var import_child_process22 = require("child_process");
|
|
@@ -27197,9 +27245,9 @@ async function installBd(platform3 = process.platform) {
|
|
|
27197
27245
|
|
|
27198
27246
|
// src/beads/install-dolt.ts
|
|
27199
27247
|
var import_child_process23 = require("child_process");
|
|
27200
|
-
var
|
|
27201
|
-
var
|
|
27202
|
-
var
|
|
27248
|
+
var fs56 = __toESM(require("fs"));
|
|
27249
|
+
var os39 = __toESM(require("os"));
|
|
27250
|
+
var path64 = __toESM(require("path"));
|
|
27203
27251
|
var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
|
|
27204
27252
|
var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
|
|
27205
27253
|
function resolveDoltInstallStrategy(platform3) {
|
|
@@ -27239,11 +27287,11 @@ function resolveDoltInstallStrategy(platform3) {
|
|
|
27239
27287
|
}
|
|
27240
27288
|
var DOLT_RELEASE_BASE = "https://github.com/dolthub/dolt/releases/latest/download";
|
|
27241
27289
|
function doltPlatformTuple(platform3, arch2) {
|
|
27242
|
-
const
|
|
27290
|
+
const os68 = platform3 === "win32" ? "windows" : platform3 === "darwin" ? "darwin" : "linux";
|
|
27243
27291
|
const a = arch2 === "x64" ? "amd64" : arch2 === "arm64" ? "arm64" : null;
|
|
27244
27292
|
if (!a) return null;
|
|
27245
|
-
if (
|
|
27246
|
-
return `${
|
|
27293
|
+
if (os68 === "windows" && a !== "amd64") return null;
|
|
27294
|
+
return `${os68}-${a}`;
|
|
27247
27295
|
}
|
|
27248
27296
|
function resolveDoltTarballStrategy(targetDir, platform3, arch2) {
|
|
27249
27297
|
const tuple = doltPlatformTuple(platform3, arch2);
|
|
@@ -27288,14 +27336,14 @@ async function installDoltToDir(targetDir, platform3 = process.platform, arch2 =
|
|
|
27288
27336
|
return result;
|
|
27289
27337
|
}
|
|
27290
27338
|
var _doltPathSeam = {
|
|
27291
|
-
homedir: () =>
|
|
27339
|
+
homedir: () => os39.homedir(),
|
|
27292
27340
|
getPath: () => process.env.PATH ?? "",
|
|
27293
27341
|
setPath: (p2) => {
|
|
27294
27342
|
process.env.PATH = p2;
|
|
27295
27343
|
},
|
|
27296
27344
|
exists: (p2) => {
|
|
27297
27345
|
try {
|
|
27298
|
-
|
|
27346
|
+
fs56.accessSync(p2, fs56.constants.F_OK);
|
|
27299
27347
|
return true;
|
|
27300
27348
|
} catch {
|
|
27301
27349
|
return false;
|
|
@@ -27306,7 +27354,7 @@ function doltBinaryNames(platform3) {
|
|
|
27306
27354
|
return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
|
|
27307
27355
|
}
|
|
27308
27356
|
function knownDoltDirs(platform3) {
|
|
27309
|
-
const P3 = platform3 === "win32" ?
|
|
27357
|
+
const P3 = platform3 === "win32" ? path64.win32 : path64.posix;
|
|
27310
27358
|
const home = _doltPathSeam.homedir();
|
|
27311
27359
|
if (platform3 === "win32") {
|
|
27312
27360
|
return [
|
|
@@ -27322,7 +27370,7 @@ function knownDoltDirs(platform3) {
|
|
|
27322
27370
|
].filter(Boolean);
|
|
27323
27371
|
}
|
|
27324
27372
|
function ensureDoltResolvable(platform3 = process.platform) {
|
|
27325
|
-
const P3 = platform3 === "win32" ?
|
|
27373
|
+
const P3 = platform3 === "win32" ? path64.win32 : path64.posix;
|
|
27326
27374
|
const delim = platform3 === "win32" ? ";" : ":";
|
|
27327
27375
|
const names = doltBinaryNames(platform3);
|
|
27328
27376
|
const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
|
|
@@ -27516,17 +27564,17 @@ function remoteHasDoltData(cwd) {
|
|
|
27516
27564
|
}
|
|
27517
27565
|
var _linkSeam = {
|
|
27518
27566
|
platform: () => process.platform,
|
|
27519
|
-
homedir: () =>
|
|
27567
|
+
homedir: () => os40.homedir(),
|
|
27520
27568
|
isWritableDir: (dir) => {
|
|
27521
27569
|
try {
|
|
27522
|
-
|
|
27570
|
+
fs57.accessSync(dir, fs57.constants.W_OK);
|
|
27523
27571
|
return true;
|
|
27524
27572
|
} catch {
|
|
27525
27573
|
return false;
|
|
27526
27574
|
}
|
|
27527
27575
|
},
|
|
27528
27576
|
ensureDir: (dir) => {
|
|
27529
|
-
|
|
27577
|
+
fs57.mkdirSync(dir, { recursive: true });
|
|
27530
27578
|
},
|
|
27531
27579
|
/**
|
|
27532
27580
|
* A directory to symlink `bd` into so the AGENT's shell + Claude Code's
|
|
@@ -27547,9 +27595,9 @@ var _linkSeam = {
|
|
|
27547
27595
|
* which `linkBdOntoPath` creates if missing.
|
|
27548
27596
|
*/
|
|
27549
27597
|
cliBinDir: () => {
|
|
27550
|
-
const pathDirs = (process.env.PATH ?? "").split(
|
|
27598
|
+
const pathDirs = (process.env.PATH ?? "").split(path65.delimiter).filter(Boolean);
|
|
27551
27599
|
const home = _linkSeam.homedir();
|
|
27552
|
-
const localBin = home ?
|
|
27600
|
+
const localBin = home ? path65.join(home, ".local", "bin") : null;
|
|
27553
27601
|
if (localBin) {
|
|
27554
27602
|
try {
|
|
27555
27603
|
_linkSeam.ensureDir(localBin);
|
|
@@ -27559,16 +27607,16 @@ var _linkSeam = {
|
|
|
27559
27607
|
const candidates = [];
|
|
27560
27608
|
if (localBin) candidates.push(localBin);
|
|
27561
27609
|
try {
|
|
27562
|
-
candidates.push(
|
|
27610
|
+
candidates.push(path65.dirname(process.execPath));
|
|
27563
27611
|
} catch {
|
|
27564
27612
|
}
|
|
27565
27613
|
candidates.push("/usr/local/bin");
|
|
27566
27614
|
const entry = process.argv[1];
|
|
27567
27615
|
if (entry) {
|
|
27568
27616
|
try {
|
|
27569
|
-
candidates.push(
|
|
27617
|
+
candidates.push(path65.dirname(fs57.realpathSync(entry)));
|
|
27570
27618
|
} catch {
|
|
27571
|
-
candidates.push(
|
|
27619
|
+
candidates.push(path65.dirname(entry));
|
|
27572
27620
|
}
|
|
27573
27621
|
}
|
|
27574
27622
|
const onPathWritable = candidates.find(
|
|
@@ -27580,20 +27628,20 @@ var _linkSeam = {
|
|
|
27580
27628
|
/** Current symlink target at `linkPath`, or null when absent / not a link. */
|
|
27581
27629
|
readlink: (linkPath) => {
|
|
27582
27630
|
try {
|
|
27583
|
-
return
|
|
27631
|
+
return fs57.readlinkSync(linkPath);
|
|
27584
27632
|
} catch {
|
|
27585
27633
|
return null;
|
|
27586
27634
|
}
|
|
27587
27635
|
},
|
|
27588
|
-
unlink: (linkPath) =>
|
|
27589
|
-
symlink: (target, linkPath) =>
|
|
27636
|
+
unlink: (linkPath) => fs57.unlinkSync(linkPath),
|
|
27637
|
+
symlink: (target, linkPath) => fs57.symlinkSync(target, linkPath)
|
|
27590
27638
|
};
|
|
27591
27639
|
function linkBdOntoPath(binaryPath) {
|
|
27592
27640
|
if (_linkSeam.platform() === "win32") return;
|
|
27593
27641
|
const binDir = _linkSeam.cliBinDir();
|
|
27594
27642
|
if (!binDir) return;
|
|
27595
27643
|
_linkSeam.ensureDir(binDir);
|
|
27596
|
-
const linkPath =
|
|
27644
|
+
const linkPath = path65.join(binDir, "bd");
|
|
27597
27645
|
if (linkPath === binaryPath) return;
|
|
27598
27646
|
const current2 = _linkSeam.readlink(linkPath);
|
|
27599
27647
|
if (current2 === binaryPath) return;
|
|
@@ -27807,16 +27855,16 @@ function dedupeRecipes(agents) {
|
|
|
27807
27855
|
}
|
|
27808
27856
|
function ensureLocalGitExclude(cwd, patterns) {
|
|
27809
27857
|
try {
|
|
27810
|
-
const gitDir =
|
|
27811
|
-
if (!
|
|
27812
|
-
const file =
|
|
27813
|
-
|
|
27814
|
-
const current2 =
|
|
27858
|
+
const gitDir = path65.join(cwd, ".git");
|
|
27859
|
+
if (!fs57.statSync(gitDir).isDirectory()) return;
|
|
27860
|
+
const file = path65.join(gitDir, "info", "exclude");
|
|
27861
|
+
fs57.mkdirSync(path65.dirname(file), { recursive: true });
|
|
27862
|
+
const current2 = fs57.existsSync(file) ? fs57.readFileSync(file, "utf8") : "";
|
|
27815
27863
|
const have = new Set(current2.split(/\r?\n/).map((l) => l.trim()));
|
|
27816
27864
|
const missing = patterns.filter((p2) => !have.has(p2));
|
|
27817
27865
|
if (missing.length === 0) return;
|
|
27818
27866
|
const prefix = current2.length > 0 && !current2.endsWith("\n") ? "\n" : "";
|
|
27819
|
-
|
|
27867
|
+
fs57.appendFileSync(file, `${prefix}# CodeAgent: beads state stays local
|
|
27820
27868
|
${missing.join("\n")}
|
|
27821
27869
|
`);
|
|
27822
27870
|
} catch {
|
|
@@ -27825,7 +27873,7 @@ ${missing.join("\n")}
|
|
|
27825
27873
|
|
|
27826
27874
|
// src/beads/watcher.ts
|
|
27827
27875
|
var crypto4 = __toESM(require("crypto"));
|
|
27828
|
-
var
|
|
27876
|
+
var path66 = __toESM(require("path"));
|
|
27829
27877
|
var API_BASE5 = resolveApiBaseUrl();
|
|
27830
27878
|
var DEBOUNCE_MS2 = 400;
|
|
27831
27879
|
var ZERO_SUMMARY = {
|
|
@@ -27849,7 +27897,7 @@ var BeadsWatcher = class {
|
|
|
27849
27897
|
constructor(opts) {
|
|
27850
27898
|
this.opts = opts;
|
|
27851
27899
|
this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
|
|
27852
|
-
this.feedPath = opts.feedPath ??
|
|
27900
|
+
this.feedPath = opts.feedPath ?? path66.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
|
|
27853
27901
|
this.apiBase = opts.apiBaseUrl ?? API_BASE5;
|
|
27854
27902
|
}
|
|
27855
27903
|
opts;
|
|
@@ -28101,10 +28149,10 @@ async function handleBeadsActionCommand(action, started) {
|
|
|
28101
28149
|
|
|
28102
28150
|
// src/beads/config-store.ts
|
|
28103
28151
|
var import_node_fs13 = __toESM(require("fs"));
|
|
28104
|
-
var
|
|
28105
|
-
var
|
|
28152
|
+
var import_node_os7 = __toESM(require("os"));
|
|
28153
|
+
var import_node_path12 = __toESM(require("path"));
|
|
28106
28154
|
function beadsConfigPath() {
|
|
28107
|
-
return
|
|
28155
|
+
return import_node_path12.default.join(import_node_os7.default.homedir(), ".codeam", "beads-config.json");
|
|
28108
28156
|
}
|
|
28109
28157
|
function readBeadsEnabled() {
|
|
28110
28158
|
try {
|
|
@@ -28117,7 +28165,7 @@ function readBeadsEnabled() {
|
|
|
28117
28165
|
}
|
|
28118
28166
|
function persistBeadsConfig(cfg) {
|
|
28119
28167
|
const file = beadsConfigPath();
|
|
28120
|
-
import_node_fs13.default.mkdirSync(
|
|
28168
|
+
import_node_fs13.default.mkdirSync(import_node_path12.default.dirname(file), { recursive: true });
|
|
28121
28169
|
const tmp = `${file}.tmp`;
|
|
28122
28170
|
import_node_fs13.default.writeFileSync(tmp, JSON.stringify(cfg), { mode: 384 });
|
|
28123
28171
|
import_node_fs13.default.renameSync(tmp, file);
|
|
@@ -28256,15 +28304,15 @@ async function configureBeads(action, ctx, deps) {
|
|
|
28256
28304
|
}
|
|
28257
28305
|
|
|
28258
28306
|
// src/skills/configure.ts
|
|
28259
|
-
var
|
|
28307
|
+
var import_node_os10 = __toESM(require("os"));
|
|
28260
28308
|
|
|
28261
28309
|
// src/skills/materialize.ts
|
|
28262
28310
|
var import_node_fs14 = __toESM(require("fs"));
|
|
28263
|
-
var
|
|
28264
|
-
var
|
|
28311
|
+
var import_node_os8 = __toESM(require("os"));
|
|
28312
|
+
var import_node_path13 = __toESM(require("path"));
|
|
28265
28313
|
var NS = "codeam-";
|
|
28266
|
-
function skillDirFor(id, home =
|
|
28267
|
-
return
|
|
28314
|
+
function skillDirFor(id, home = import_node_os8.default.homedir()) {
|
|
28315
|
+
return import_node_path13.default.join(home, ".claude", "skills", `${NS}${id}`);
|
|
28268
28316
|
}
|
|
28269
28317
|
function renderSkillMd(id, description, body) {
|
|
28270
28318
|
const desc = description.replace(/\s*\n\s*/g, " ").trim();
|
|
@@ -28276,25 +28324,25 @@ description: ${JSON.stringify(desc)}
|
|
|
28276
28324
|
${body.trim()}
|
|
28277
28325
|
`;
|
|
28278
28326
|
}
|
|
28279
|
-
function materializeSkill(id, home =
|
|
28327
|
+
function materializeSkill(id, home = import_node_os8.default.homedir()) {
|
|
28280
28328
|
const def = getSkillDefinition(id);
|
|
28281
28329
|
if (!def?.delivery.skillFile) return false;
|
|
28282
28330
|
try {
|
|
28283
28331
|
const dir = skillDirFor(id, home);
|
|
28284
28332
|
import_node_fs14.default.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
28285
28333
|
import_node_fs14.default.writeFileSync(
|
|
28286
|
-
|
|
28334
|
+
import_node_path13.default.join(dir, "SKILL.md"),
|
|
28287
28335
|
renderSkillMd(id, def.description, def.delivery.skillFile.body),
|
|
28288
28336
|
{ encoding: "utf8", mode: 384 }
|
|
28289
28337
|
);
|
|
28290
|
-
const baseDir =
|
|
28291
|
-
const baseDirWithSep = baseDir +
|
|
28338
|
+
const baseDir = import_node_path13.default.resolve(dir);
|
|
28339
|
+
const baseDirWithSep = baseDir + import_node_path13.default.sep;
|
|
28292
28340
|
for (const [rel, contents] of Object.entries(def.delivery.skillFile.files ?? {})) {
|
|
28293
|
-
const target =
|
|
28294
|
-
if (!
|
|
28341
|
+
const target = import_node_path13.default.join(dir, rel);
|
|
28342
|
+
if (!import_node_path13.default.resolve(target).startsWith(baseDirWithSep) && import_node_path13.default.resolve(target) !== baseDir) {
|
|
28295
28343
|
continue;
|
|
28296
28344
|
}
|
|
28297
|
-
import_node_fs14.default.mkdirSync(
|
|
28345
|
+
import_node_fs14.default.mkdirSync(import_node_path13.default.dirname(target), { recursive: true, mode: 448 });
|
|
28298
28346
|
import_node_fs14.default.writeFileSync(target, contents, { encoding: "utf8", mode: 384 });
|
|
28299
28347
|
}
|
|
28300
28348
|
return true;
|
|
@@ -28303,7 +28351,7 @@ function materializeSkill(id, home = import_node_os7.default.homedir()) {
|
|
|
28303
28351
|
return false;
|
|
28304
28352
|
}
|
|
28305
28353
|
}
|
|
28306
|
-
function removeSkill(id, home =
|
|
28354
|
+
function removeSkill(id, home = import_node_os8.default.homedir()) {
|
|
28307
28355
|
try {
|
|
28308
28356
|
import_node_fs14.default.rmSync(skillDirFor(id, home), { recursive: true, force: true });
|
|
28309
28357
|
} catch {
|
|
@@ -28312,10 +28360,10 @@ function removeSkill(id, home = import_node_os7.default.homedir()) {
|
|
|
28312
28360
|
|
|
28313
28361
|
// src/skills/manifest.ts
|
|
28314
28362
|
var import_node_fs15 = __toESM(require("fs"));
|
|
28315
|
-
var
|
|
28316
|
-
var
|
|
28363
|
+
var import_node_os9 = __toESM(require("os"));
|
|
28364
|
+
var import_node_path14 = __toESM(require("path"));
|
|
28317
28365
|
function skillsManifestPath() {
|
|
28318
|
-
return
|
|
28366
|
+
return import_node_path14.default.join(import_node_os9.default.homedir(), ".codeam", "skills.json");
|
|
28319
28367
|
}
|
|
28320
28368
|
function readSkillsManifest() {
|
|
28321
28369
|
try {
|
|
@@ -28332,7 +28380,7 @@ function readSkillsManifest() {
|
|
|
28332
28380
|
function persistSkillsManifest(m) {
|
|
28333
28381
|
try {
|
|
28334
28382
|
const file = skillsManifestPath();
|
|
28335
|
-
import_node_fs15.default.mkdirSync(
|
|
28383
|
+
import_node_fs15.default.mkdirSync(import_node_path14.default.dirname(file), { recursive: true, mode: 448 });
|
|
28336
28384
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
28337
28385
|
import_node_fs15.default.writeFileSync(tmp, JSON.stringify(m, null, 2), { encoding: "utf8", mode: 384 });
|
|
28338
28386
|
import_node_fs15.default.renameSync(tmp, file);
|
|
@@ -28356,7 +28404,7 @@ function currentInstalled() {
|
|
|
28356
28404
|
const m = readSkillsManifest();
|
|
28357
28405
|
return (m?.skills ?? []).map((s) => s.id).filter(isSkillId);
|
|
28358
28406
|
}
|
|
28359
|
-
function configureSkill(action, skillId, home =
|
|
28407
|
+
function configureSkill(action, skillId, home = import_node_os10.default.homedir()) {
|
|
28360
28408
|
if (action === "list") return { ok: true, installed: currentInstalled() };
|
|
28361
28409
|
if (!skillId || !isSkillId(skillId)) {
|
|
28362
28410
|
return { ok: false, installed: currentInstalled(), error: `unknown skill: ${skillId ?? "(none)"}` };
|
|
@@ -28389,8 +28437,8 @@ function cleanupAttachmentTempFiles() {
|
|
|
28389
28437
|
function saveFilesTemp(files) {
|
|
28390
28438
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
28391
28439
|
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
28392
|
-
const tmpPath =
|
|
28393
|
-
|
|
28440
|
+
const tmpPath = path70.join(os45.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
|
|
28441
|
+
fs61.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
|
|
28394
28442
|
pendingAttachmentFiles.add(tmpPath);
|
|
28395
28443
|
return tmpPath;
|
|
28396
28444
|
});
|
|
@@ -28635,10 +28683,10 @@ var listFiles = async (ctx, cmd, parsed) => {
|
|
|
28635
28683
|
await ctx.relay.sendResult(cmd.id, "completed", result);
|
|
28636
28684
|
};
|
|
28637
28685
|
var envReadH = async (ctx, cmd) => {
|
|
28638
|
-
const envPath =
|
|
28686
|
+
const envPath = path70.join(process.cwd(), ".env");
|
|
28639
28687
|
await restoreProjectEnvIfMissing(process.cwd(), ctx);
|
|
28640
28688
|
try {
|
|
28641
|
-
const raw = await
|
|
28689
|
+
const raw = await fs61.promises.readFile(envPath, "utf8");
|
|
28642
28690
|
await ctx.relay.sendResult(cmd.id, "completed", {
|
|
28643
28691
|
exists: true,
|
|
28644
28692
|
vars: parseDotenv(raw)
|
|
@@ -28667,7 +28715,7 @@ var envParseH = async (ctx, cmd, parsed) => {
|
|
|
28667
28715
|
const existing = /* @__PURE__ */ new Map();
|
|
28668
28716
|
if (!replace) {
|
|
28669
28717
|
try {
|
|
28670
|
-
const raw = await
|
|
28718
|
+
const raw = await fs61.promises.readFile(path70.join(process.cwd(), ".env"), "utf8");
|
|
28671
28719
|
for (const v of parseDotenv(raw)) existing.set(v.key, v.value);
|
|
28672
28720
|
} catch {
|
|
28673
28721
|
}
|
|
@@ -28707,15 +28755,15 @@ var envWriteH = async (ctx, cmd, parsed) => {
|
|
|
28707
28755
|
}
|
|
28708
28756
|
seen2.add(v.key);
|
|
28709
28757
|
}
|
|
28710
|
-
const envPath =
|
|
28711
|
-
const tmpPath =
|
|
28758
|
+
const envPath = path70.join(process.cwd(), ".env");
|
|
28759
|
+
const tmpPath = path70.join(process.cwd(), ".env.codeam.tmp");
|
|
28712
28760
|
try {
|
|
28713
|
-
await
|
|
28714
|
-
await
|
|
28761
|
+
await fs61.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
|
|
28762
|
+
await fs61.promises.rename(tmpPath, envPath);
|
|
28715
28763
|
await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
|
|
28716
28764
|
void syncProjectEnvUp(process.cwd(), ctx);
|
|
28717
28765
|
} catch (err) {
|
|
28718
|
-
await
|
|
28766
|
+
await fs61.promises.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
28719
28767
|
await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
|
|
28720
28768
|
}
|
|
28721
28769
|
};
|
|
@@ -28941,7 +28989,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
28941
28989
|
});
|
|
28942
28990
|
const token = ctx.pluginAuthToken;
|
|
28943
28991
|
void (async () => {
|
|
28944
|
-
const
|
|
28992
|
+
const os68 = createOsStrategy();
|
|
28945
28993
|
try {
|
|
28946
28994
|
const report = await reviewPullRequest(
|
|
28947
28995
|
{
|
|
@@ -28950,7 +28998,7 @@ var vcsAgentReviewH = async (ctx, cmd, parsed) => {
|
|
|
28950
28998
|
baseBranch: parsed.baseBranch
|
|
28951
28999
|
},
|
|
28952
29000
|
{
|
|
28953
|
-
runReview: (input) => new CoderabbitRuntimeStrategy(
|
|
29001
|
+
runReview: (input) => new CoderabbitRuntimeStrategy(os68).runOneShot(input),
|
|
28954
29002
|
runGh: (args2) => defaultRunGh(args2),
|
|
28955
29003
|
postReport: async (r) => {
|
|
28956
29004
|
if (!token) return;
|
|
@@ -29064,9 +29112,9 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
|
|
|
29064
29112
|
function buildNpmInstallInvocation(opts) {
|
|
29065
29113
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
29066
29114
|
const execPath = opts?.execPath ?? process.execPath;
|
|
29067
|
-
const exists2 = opts?.existsSync ??
|
|
29115
|
+
const exists2 = opts?.existsSync ?? fs61.existsSync;
|
|
29068
29116
|
const platform3 = opts?.platform ?? process.platform;
|
|
29069
|
-
const p2 = platform3 === "win32" ?
|
|
29117
|
+
const p2 = platform3 === "win32" ? path70.win32 : path70.posix;
|
|
29070
29118
|
const normalized = entryScript.split(/[\\/]/).join("/");
|
|
29071
29119
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
29072
29120
|
const markerIdx = normalized.indexOf(marker);
|
|
@@ -29085,7 +29133,7 @@ function isPermissionError(stderr) {
|
|
|
29085
29133
|
function resolveGlobalNodeModulesDir(opts) {
|
|
29086
29134
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
29087
29135
|
const platform3 = opts?.platform ?? process.platform;
|
|
29088
|
-
const p2 = platform3 === "win32" ?
|
|
29136
|
+
const p2 = platform3 === "win32" ? path70.win32 : path70.posix;
|
|
29089
29137
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
29090
29138
|
const markerIdx = entryScript.split(/[\\/]/).join("/").indexOf(marker);
|
|
29091
29139
|
if (markerIdx <= 0) return null;
|
|
@@ -29095,9 +29143,9 @@ function resolveGlobalNodeModulesDir(opts) {
|
|
|
29095
29143
|
var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
|
|
29096
29144
|
function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
29097
29145
|
if (!nodeModulesDir) return 0;
|
|
29098
|
-
const readdirSync17 = deps?.readdirSync ??
|
|
29099
|
-
const statSync16 = deps?.statSync ??
|
|
29100
|
-
const rmSync11 = deps?.rmSync ??
|
|
29146
|
+
const readdirSync17 = deps?.readdirSync ?? fs61.readdirSync;
|
|
29147
|
+
const statSync16 = deps?.statSync ?? fs61.statSync;
|
|
29148
|
+
const rmSync11 = deps?.rmSync ?? fs61.rmSync;
|
|
29101
29149
|
let removed = 0;
|
|
29102
29150
|
let entries2;
|
|
29103
29151
|
try {
|
|
@@ -29107,7 +29155,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
|
29107
29155
|
}
|
|
29108
29156
|
for (const name of entries2) {
|
|
29109
29157
|
if (!/^\.codeam-cli-/.test(name)) continue;
|
|
29110
|
-
const full =
|
|
29158
|
+
const full = path70.join(nodeModulesDir, name);
|
|
29111
29159
|
try {
|
|
29112
29160
|
const st3 = statSync16(full);
|
|
29113
29161
|
if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
|
|
@@ -29698,6 +29746,18 @@ var previewStartH = (ctx, _cmd, parsed) => {
|
|
|
29698
29746
|
}
|
|
29699
29747
|
void startPreviewFromDetection(ctx, rawDetection, ctx.pluginAuthToken);
|
|
29700
29748
|
};
|
|
29749
|
+
async function restorePreviewAfterRestart(ctx, pluginAuthToken, deps = {}) {
|
|
29750
|
+
const detection = await (deps.read ?? readActivePreviewMarker)(process.cwd());
|
|
29751
|
+
if (!detection) return false;
|
|
29752
|
+
log.info(
|
|
29753
|
+
"preview",
|
|
29754
|
+
`restoring the preview that was serving before the restart (${detection.framework})`
|
|
29755
|
+
);
|
|
29756
|
+
void (deps.start ?? startPreviewFromDetection)(ctx, detection, pluginAuthToken, {
|
|
29757
|
+
origin: "user"
|
|
29758
|
+
});
|
|
29759
|
+
return true;
|
|
29760
|
+
}
|
|
29701
29761
|
var scratchOfferedSessions = /* @__PURE__ */ new Set();
|
|
29702
29762
|
async function offerScratchSaveOnce(ctx, pluginAuthToken) {
|
|
29703
29763
|
if (!isScratchWorkspace(process.cwd()) || scratchOfferedSessions.has(ctx.sessionId)) return;
|
|
@@ -29779,6 +29839,7 @@ var previewStopH = (ctx) => {
|
|
|
29779
29839
|
const pluginAuthToken = ctx.pluginAuthToken;
|
|
29780
29840
|
void (async () => {
|
|
29781
29841
|
await killPreview(ctx.sessionId);
|
|
29842
|
+
await clearActivePreviewMarker(process.cwd());
|
|
29782
29843
|
resetBuildHealState(ctx.sessionId);
|
|
29783
29844
|
log.info("preview", `stopped session=${ctx.sessionId}`);
|
|
29784
29845
|
emitPreviewEvent({
|
|
@@ -30208,11 +30269,11 @@ function resolveTokenValue(args2) {
|
|
|
30208
30269
|
}
|
|
30209
30270
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
30210
30271
|
if (fileFlag) {
|
|
30211
|
-
const
|
|
30272
|
+
const path106 = fileFlag.slice("--token-file=".length);
|
|
30212
30273
|
try {
|
|
30213
|
-
const content =
|
|
30214
|
-
if (content.length === 0) fail(`--token-file ${
|
|
30215
|
-
rmIfExistsQuiet(
|
|
30274
|
+
const content = fs62.readFileSync(path106, "utf8").trim();
|
|
30275
|
+
if (content.length === 0) fail(`--token-file ${path106} is empty`);
|
|
30276
|
+
rmIfExistsQuiet(path106);
|
|
30216
30277
|
return content;
|
|
30217
30278
|
} catch (err) {
|
|
30218
30279
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -30304,12 +30365,12 @@ async function claim(token, pluginId, pluginSecretHash) {
|
|
|
30304
30365
|
}
|
|
30305
30366
|
}
|
|
30306
30367
|
function pairAutoLockPath() {
|
|
30307
|
-
return
|
|
30368
|
+
return path71.join(os46.homedir(), ".codeam", "pair-auto.lock");
|
|
30308
30369
|
}
|
|
30309
30370
|
var procRoot = "/proc";
|
|
30310
30371
|
function readProcFile(rel) {
|
|
30311
30372
|
try {
|
|
30312
|
-
return
|
|
30373
|
+
return fs62.readFileSync(path71.join(procRoot, rel), "utf8");
|
|
30313
30374
|
} catch {
|
|
30314
30375
|
return void 0;
|
|
30315
30376
|
}
|
|
@@ -30330,7 +30391,7 @@ function currentBootId() {
|
|
|
30330
30391
|
function readLockRecord(lockPath) {
|
|
30331
30392
|
let raw;
|
|
30332
30393
|
try {
|
|
30333
|
-
raw =
|
|
30394
|
+
raw = fs62.readFileSync(lockPath, "utf8");
|
|
30334
30395
|
} catch {
|
|
30335
30396
|
return void 0;
|
|
30336
30397
|
}
|
|
@@ -30379,7 +30440,7 @@ function isLiveLockHolder(rec) {
|
|
|
30379
30440
|
}
|
|
30380
30441
|
function releaseOwnLock(lockPath) {
|
|
30381
30442
|
try {
|
|
30382
|
-
if (readLockRecord(lockPath)?.pid === process.pid)
|
|
30443
|
+
if (readLockRecord(lockPath)?.pid === process.pid) fs62.unlinkSync(lockPath);
|
|
30383
30444
|
} catch {
|
|
30384
30445
|
}
|
|
30385
30446
|
}
|
|
@@ -30403,7 +30464,7 @@ function snapshotProcessTree(root) {
|
|
|
30403
30464
|
const children = /* @__PURE__ */ new Map();
|
|
30404
30465
|
let entries2 = [];
|
|
30405
30466
|
try {
|
|
30406
|
-
entries2 =
|
|
30467
|
+
entries2 = fs62.readdirSync(procRoot).filter((e) => /^\d+$/.test(e));
|
|
30407
30468
|
} catch {
|
|
30408
30469
|
}
|
|
30409
30470
|
for (const e of entries2) {
|
|
@@ -30438,18 +30499,18 @@ function signalProcessTree(refs, signal) {
|
|
|
30438
30499
|
}
|
|
30439
30500
|
function daemonLockPath(sessionId) {
|
|
30440
30501
|
const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
30441
|
-
return
|
|
30502
|
+
return path71.join(os46.homedir(), ".codeam", `daemon-${safe}.lock`);
|
|
30442
30503
|
}
|
|
30443
30504
|
function acquireDaemonLock(sessionId) {
|
|
30444
30505
|
const lockPath = daemonLockPath(sessionId);
|
|
30445
30506
|
try {
|
|
30446
|
-
|
|
30507
|
+
fs62.mkdirSync(path71.dirname(lockPath), { recursive: true });
|
|
30447
30508
|
try {
|
|
30448
|
-
|
|
30509
|
+
fs62.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
30449
30510
|
} catch (e) {
|
|
30450
30511
|
if (e.code !== "EEXIST") throw e;
|
|
30451
30512
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
30452
|
-
|
|
30513
|
+
fs62.writeFileSync(lockPath, ownLockBody());
|
|
30453
30514
|
}
|
|
30454
30515
|
const release3 = () => releaseOwnLock(lockPath);
|
|
30455
30516
|
process.once("exit", release3);
|
|
@@ -30469,13 +30530,13 @@ function acquireDaemonLock(sessionId) {
|
|
|
30469
30530
|
function acquireSingletonLock() {
|
|
30470
30531
|
const lockPath = pairAutoLockPath();
|
|
30471
30532
|
try {
|
|
30472
|
-
|
|
30533
|
+
fs62.mkdirSync(path71.dirname(lockPath), { recursive: true });
|
|
30473
30534
|
try {
|
|
30474
|
-
|
|
30535
|
+
fs62.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
30475
30536
|
} catch (e) {
|
|
30476
30537
|
if (e.code !== "EEXIST") throw e;
|
|
30477
30538
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
30478
|
-
|
|
30539
|
+
fs62.writeFileSync(lockPath, ownLockBody());
|
|
30479
30540
|
}
|
|
30480
30541
|
process.once("exit", () => releaseOwnLock(lockPath));
|
|
30481
30542
|
return true;
|
|
@@ -30892,15 +30953,15 @@ var AgentService = class _AgentService {
|
|
|
30892
30953
|
};
|
|
30893
30954
|
|
|
30894
30955
|
// src/agents/acp/adapters.ts
|
|
30895
|
-
var
|
|
30956
|
+
var path72 = __toESM(require("path"));
|
|
30896
30957
|
|
|
30897
30958
|
// src/agents/kimi/installer.ts
|
|
30898
30959
|
var import_node_child_process25 = require("child_process");
|
|
30899
|
-
var
|
|
30900
|
-
var
|
|
30960
|
+
var import_node_os11 = require("os");
|
|
30961
|
+
var import_node_path15 = require("path");
|
|
30901
30962
|
var INSTALL_URL2 = "https://code.kimi.com/kimi-code/install.sh";
|
|
30902
30963
|
function kimiBinDir() {
|
|
30903
|
-
return (0,
|
|
30964
|
+
return (0, import_node_path15.join)(process.env.KIMI_CODE_HOME || (0, import_node_path15.join)((0, import_node_os11.homedir)(), ".kimi-code"), "bin");
|
|
30904
30965
|
}
|
|
30905
30966
|
function kimiRuns() {
|
|
30906
30967
|
const r = (0, import_node_child_process25.spawnSync)("kimi", ["--version"], { stdio: "ignore", timeout: 15e3 });
|
|
@@ -30949,11 +31010,11 @@ async function ensureKimiInstalled() {
|
|
|
30949
31010
|
|
|
30950
31011
|
// src/agents/opencode/installer.ts
|
|
30951
31012
|
var import_node_child_process26 = require("child_process");
|
|
30952
|
-
var
|
|
30953
|
-
var
|
|
31013
|
+
var import_node_os12 = require("os");
|
|
31014
|
+
var import_node_path16 = require("path");
|
|
30954
31015
|
var INSTALL_URL3 = "https://opencode.ai/install";
|
|
30955
31016
|
function opencodeBinDir() {
|
|
30956
|
-
return (0,
|
|
31017
|
+
return (0, import_node_path16.join)(process.env.OPENCODE_HOME || (0, import_node_path16.join)((0, import_node_os12.homedir)(), ".opencode"), "bin");
|
|
30957
31018
|
}
|
|
30958
31019
|
function opencodeRuns() {
|
|
30959
31020
|
const r = (0, import_node_child_process26.spawnSync)("opencode", ["--version"], { stdio: "ignore", timeout: 15e3 });
|
|
@@ -31012,13 +31073,13 @@ function resolveBin(pkgName, binName) {
|
|
|
31012
31073
|
try {
|
|
31013
31074
|
const manifestPath = require_.resolve(`${pkgName}/package.json`);
|
|
31014
31075
|
const manifest = require_(`${pkgName}/package.json`);
|
|
31015
|
-
const pkgDir =
|
|
31076
|
+
const pkgDir = path72.dirname(manifestPath);
|
|
31016
31077
|
const bin = manifest.bin;
|
|
31017
31078
|
if (!bin) return null;
|
|
31018
|
-
if (typeof bin === "string") return
|
|
31079
|
+
if (typeof bin === "string") return path72.resolve(pkgDir, bin);
|
|
31019
31080
|
const target = binName ?? Object.keys(bin)[0];
|
|
31020
31081
|
if (!target || !bin[target]) return null;
|
|
31021
|
-
return
|
|
31082
|
+
return path72.resolve(pkgDir, bin[target]);
|
|
31022
31083
|
} catch {
|
|
31023
31084
|
return null;
|
|
31024
31085
|
}
|
|
@@ -31198,10 +31259,10 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
31198
31259
|
}
|
|
31199
31260
|
|
|
31200
31261
|
// src/agents/acp/runner.ts
|
|
31201
|
-
var
|
|
31202
|
-
var
|
|
31203
|
-
var
|
|
31204
|
-
var
|
|
31262
|
+
var import_node_crypto13 = require("crypto");
|
|
31263
|
+
var fs79 = __toESM(require("fs"));
|
|
31264
|
+
var os57 = __toESM(require("os"));
|
|
31265
|
+
var path90 = __toESM(require("path"));
|
|
31205
31266
|
|
|
31206
31267
|
// src/agents/acp/provider-billing-signal.ts
|
|
31207
31268
|
var seen = /* @__PURE__ */ new Set();
|
|
@@ -31233,9 +31294,8 @@ function noteProviderBillingSignal(opts) {
|
|
|
31233
31294
|
}
|
|
31234
31295
|
|
|
31235
31296
|
// src/services/history.service.ts
|
|
31236
|
-
var
|
|
31237
|
-
var
|
|
31238
|
-
var os46 = __toESM(require("os"));
|
|
31297
|
+
var fs63 = __toESM(require("fs"));
|
|
31298
|
+
var path73 = __toESM(require("path"));
|
|
31239
31299
|
var https6 = __toESM(require("https"));
|
|
31240
31300
|
var http10 = __toESM(require("http"));
|
|
31241
31301
|
var import_zod2 = require("zod");
|
|
@@ -31296,7 +31356,7 @@ function parseJsonl(filePath) {
|
|
|
31296
31356
|
const messages = [];
|
|
31297
31357
|
let raw;
|
|
31298
31358
|
try {
|
|
31299
|
-
raw =
|
|
31359
|
+
raw = fs63.readFileSync(filePath, "utf8");
|
|
31300
31360
|
} catch (err) {
|
|
31301
31361
|
if (err.code !== "ENOENT") {
|
|
31302
31362
|
log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
|
|
@@ -31450,7 +31510,13 @@ var HistoryService = class _HistoryService {
|
|
|
31450
31510
|
return this._quotaPercent === null || Date.now() - this._quotaFetchedAt > ttlMs;
|
|
31451
31511
|
}
|
|
31452
31512
|
get projectDir() {
|
|
31453
|
-
return this.runtime.resolveHistoryDir(this.cwd) ??
|
|
31513
|
+
return this.runtime.resolveHistoryDir(this.cwd) ?? // ⚠️ `CLAUDE_CONFIG_DIR`, not `~/.claude`: a managed / house session runs
|
|
31514
|
+
// Claude with its own config dir (`~/.codeam/house-claude/<deploy>`), so a
|
|
31515
|
+
// `~/.claude/projects` lookup found NO transcript for those sessions — the
|
|
31516
|
+
// session-start upload answered false, the active-conversation pointer was
|
|
31517
|
+
// never re-pointed after a Box wake, and the app opened an empty "New
|
|
31518
|
+
// conversation" over the resumed one (QA box, 2026-09-29).
|
|
31519
|
+
path73.join(claudeConfigDir(), "projects", encodeCwd(this.cwd));
|
|
31454
31520
|
}
|
|
31455
31521
|
/** Set the current Claude conversation ID (extracted from /cost command or session start) */
|
|
31456
31522
|
setCurrentConversationId(id) {
|
|
@@ -31462,7 +31528,7 @@ var HistoryService = class _HistoryService {
|
|
|
31462
31528
|
/** Return the current message count in the active conversation. */
|
|
31463
31529
|
getCurrentMessageCount() {
|
|
31464
31530
|
if (!this.currentConversationId) return 0;
|
|
31465
|
-
const filePath =
|
|
31531
|
+
const filePath = path73.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
31466
31532
|
return parseJsonl(filePath).length;
|
|
31467
31533
|
}
|
|
31468
31534
|
/**
|
|
@@ -31473,7 +31539,7 @@ var HistoryService = class _HistoryService {
|
|
|
31473
31539
|
const deadline = Date.now() + timeoutMs;
|
|
31474
31540
|
while (Date.now() < deadline) {
|
|
31475
31541
|
if (!this.currentConversationId) return null;
|
|
31476
|
-
const filePath =
|
|
31542
|
+
const filePath = path73.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
31477
31543
|
const messages = parseJsonl(filePath);
|
|
31478
31544
|
if (messages.length > previousCount) {
|
|
31479
31545
|
for (let i = messages.length - 1; i >= previousCount; i--) {
|
|
@@ -31499,16 +31565,16 @@ var HistoryService = class _HistoryService {
|
|
|
31499
31565
|
const dir = this.projectDir;
|
|
31500
31566
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
31501
31567
|
try {
|
|
31502
|
-
const files =
|
|
31568
|
+
const files = fs63.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
31503
31569
|
try {
|
|
31504
|
-
const stat3 =
|
|
31570
|
+
const stat3 = fs63.statSync(path73.join(dir, e.name));
|
|
31505
31571
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
31506
31572
|
} catch {
|
|
31507
31573
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
31508
31574
|
}
|
|
31509
31575
|
}).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
31510
31576
|
if (files.length > 0) {
|
|
31511
|
-
this.currentConversationId =
|
|
31577
|
+
this.currentConversationId = path73.basename(files[0].name, ".jsonl");
|
|
31512
31578
|
}
|
|
31513
31579
|
} catch {
|
|
31514
31580
|
}
|
|
@@ -31542,13 +31608,13 @@ var HistoryService = class _HistoryService {
|
|
|
31542
31608
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
31543
31609
|
let entries2;
|
|
31544
31610
|
try {
|
|
31545
|
-
entries2 =
|
|
31611
|
+
entries2 = fs63.readdirSync(dir, { withFileTypes: true });
|
|
31546
31612
|
} catch {
|
|
31547
31613
|
return null;
|
|
31548
31614
|
}
|
|
31549
31615
|
const files = entries2.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
31550
31616
|
try {
|
|
31551
|
-
const stat3 =
|
|
31617
|
+
const stat3 = fs63.statSync(path73.join(dir, e.name));
|
|
31552
31618
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
31553
31619
|
} catch {
|
|
31554
31620
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -31557,12 +31623,12 @@ var HistoryService = class _HistoryService {
|
|
|
31557
31623
|
if (files.length === 0) return null;
|
|
31558
31624
|
const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
|
|
31559
31625
|
if (!files.some((f) => f.name === targetFile)) return null;
|
|
31560
|
-
return this.extractUsageFromFile(
|
|
31626
|
+
return this.extractUsageFromFile(path73.join(dir, targetFile));
|
|
31561
31627
|
}
|
|
31562
31628
|
extractUsageFromFile(filePath) {
|
|
31563
31629
|
let raw;
|
|
31564
31630
|
try {
|
|
31565
|
-
raw =
|
|
31631
|
+
raw = fs63.readFileSync(filePath, "utf8");
|
|
31566
31632
|
} catch {
|
|
31567
31633
|
return null;
|
|
31568
31634
|
}
|
|
@@ -31614,9 +31680,9 @@ var HistoryService = class _HistoryService {
|
|
|
31614
31680
|
let totalCost = 0;
|
|
31615
31681
|
let files;
|
|
31616
31682
|
try {
|
|
31617
|
-
files =
|
|
31683
|
+
files = fs63.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
|
|
31618
31684
|
try {
|
|
31619
|
-
return
|
|
31685
|
+
return fs63.statSync(path73.join(projectDir, f)).mtimeMs >= monthStartMs;
|
|
31620
31686
|
} catch {
|
|
31621
31687
|
return false;
|
|
31622
31688
|
}
|
|
@@ -31627,7 +31693,7 @@ var HistoryService = class _HistoryService {
|
|
|
31627
31693
|
for (const file of files) {
|
|
31628
31694
|
let raw;
|
|
31629
31695
|
try {
|
|
31630
|
-
raw =
|
|
31696
|
+
raw = fs63.readFileSync(path73.join(projectDir, file), "utf8");
|
|
31631
31697
|
} catch {
|
|
31632
31698
|
continue;
|
|
31633
31699
|
}
|
|
@@ -31706,7 +31772,7 @@ var HistoryService = class _HistoryService {
|
|
|
31706
31772
|
if (this.runtime.resolveHistoryFile) {
|
|
31707
31773
|
return this.runtime.resolveHistoryFile(this.cwd, sessionId);
|
|
31708
31774
|
}
|
|
31709
|
-
return
|
|
31775
|
+
return path73.join(this.projectDir, `${sessionId}.jsonl`);
|
|
31710
31776
|
}
|
|
31711
31777
|
/**
|
|
31712
31778
|
* Parse a conversation's messages from disk, agent-aware. Claude uses the
|
|
@@ -31744,7 +31810,7 @@ var HistoryService = class _HistoryService {
|
|
|
31744
31810
|
};
|
|
31745
31811
|
});
|
|
31746
31812
|
}
|
|
31747
|
-
return parseJsonl(
|
|
31813
|
+
return parseJsonl(path73.join(this.projectDir, `${sessionId}.jsonl`));
|
|
31748
31814
|
}
|
|
31749
31815
|
/** One in-flight full upload per conversation — the baton mirror and a
|
|
31750
31816
|
* `get_conversation` used to upload the same transcript concurrently. */
|
|
@@ -31826,7 +31892,7 @@ var HistoryService = class _HistoryService {
|
|
|
31826
31892
|
if (!filePath) return false;
|
|
31827
31893
|
let mtimeMs;
|
|
31828
31894
|
try {
|
|
31829
|
-
mtimeMs =
|
|
31895
|
+
mtimeMs = fs63.statSync(filePath).mtimeMs;
|
|
31830
31896
|
} catch {
|
|
31831
31897
|
return false;
|
|
31832
31898
|
}
|
|
@@ -31901,10 +31967,10 @@ var HistoryService = class _HistoryService {
|
|
|
31901
31967
|
|
|
31902
31968
|
// src/agents/acp/client.ts
|
|
31903
31969
|
var import_node_child_process27 = require("child_process");
|
|
31904
|
-
var
|
|
31970
|
+
var fs64 = __toESM(require("fs/promises"));
|
|
31905
31971
|
var fsSync = __toESM(require("fs"));
|
|
31906
31972
|
var os48 = __toESM(require("os"));
|
|
31907
|
-
var
|
|
31973
|
+
var path75 = __toESM(require("path"));
|
|
31908
31974
|
var import_node_stream = require("stream");
|
|
31909
31975
|
|
|
31910
31976
|
// ../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
@@ -35930,7 +35996,7 @@ function createIdleTimeout(idleMs, makeError, activeIdleMs = idleMs) {
|
|
|
35930
35996
|
}
|
|
35931
35997
|
|
|
35932
35998
|
// src/agents/acp/internal-paths.ts
|
|
35933
|
-
var
|
|
35999
|
+
var path74 = __toESM(require("path"));
|
|
35934
36000
|
var os47 = __toESM(require("os"));
|
|
35935
36001
|
var INTERNAL_TOKENS = [".codeam", "house-claude"];
|
|
35936
36002
|
var PROSE_ONLY_TOOL_KINDS = /* @__PURE__ */ new Set(["think", "switch_mode"]);
|
|
@@ -35945,11 +36011,11 @@ function textReferencesInternal(text) {
|
|
|
35945
36011
|
}
|
|
35946
36012
|
function pathIsInternal(p2, homeDir2 = os47.homedir()) {
|
|
35947
36013
|
if (!p2) return false;
|
|
35948
|
-
const abs =
|
|
35949
|
-
const home =
|
|
35950
|
-
const within = (root) => abs === root || abs.startsWith(root +
|
|
35951
|
-
if (within(
|
|
35952
|
-
return within(
|
|
36014
|
+
const abs = path74.resolve(p2);
|
|
36015
|
+
const home = path74.resolve(homeDir2);
|
|
36016
|
+
const within = (root) => abs === root || abs.startsWith(root + path74.sep);
|
|
36017
|
+
if (within(path74.join(home, ".codeam", "self-hosted"))) return false;
|
|
36018
|
+
return within(path74.join(home, ".codeam")) || within(path74.join(home, ".beads")) || abs === path74.join(home, ".codeam-host.log") || abs.includes(`${path74.sep}house-claude${path74.sep}`) || abs.endsWith(`${path74.sep}house-claude`);
|
|
35953
36019
|
}
|
|
35954
36020
|
function toolCallReferencesInternal(call, homeDir2) {
|
|
35955
36021
|
if (call.locations?.some((l) => pathIsInternal(l.path, homeDir2))) return true;
|
|
@@ -37044,7 +37110,7 @@ var AcpClient = class {
|
|
|
37044
37110
|
throw new RequestError(-32002, GUARDRAIL_SECRET_READ_BLOCK_REASON, { uri: params.path });
|
|
37045
37111
|
}
|
|
37046
37112
|
try {
|
|
37047
|
-
const content = await
|
|
37113
|
+
const content = await fs64.readFile(params.path, "utf8");
|
|
37048
37114
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
37049
37115
|
} catch (err) {
|
|
37050
37116
|
const code = err.code;
|
|
@@ -37065,7 +37131,7 @@ var AcpClient = class {
|
|
|
37065
37131
|
throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
|
|
37066
37132
|
}
|
|
37067
37133
|
try {
|
|
37068
|
-
await
|
|
37134
|
+
await fs64.writeFile(params.path, params.content, "utf8");
|
|
37069
37135
|
return {};
|
|
37070
37136
|
} catch (err) {
|
|
37071
37137
|
const code = err.code;
|
|
@@ -37158,25 +37224,25 @@ function knownAgentBinaryDirs() {
|
|
|
37158
37224
|
out2.push("/tmp/codeam-node20/bin");
|
|
37159
37225
|
for (const root of [
|
|
37160
37226
|
"/usr/local/share/nvm/versions/node",
|
|
37161
|
-
|
|
37227
|
+
path75.join(home, ".nvm/versions/node")
|
|
37162
37228
|
]) {
|
|
37163
37229
|
try {
|
|
37164
37230
|
for (const child of fsSync.readdirSync(root)) {
|
|
37165
|
-
out2.push(
|
|
37231
|
+
out2.push(path75.join(root, child, "bin"));
|
|
37166
37232
|
}
|
|
37167
37233
|
} catch {
|
|
37168
37234
|
}
|
|
37169
37235
|
}
|
|
37170
|
-
out2.push(
|
|
37236
|
+
out2.push(path75.join(home, ".volta/bin"));
|
|
37171
37237
|
out2.push("/usr/local/bin");
|
|
37172
37238
|
out2.push("/usr/bin");
|
|
37173
|
-
out2.push(
|
|
37174
|
-
out2.push(
|
|
37239
|
+
out2.push(path75.join(home, ".local/bin"));
|
|
37240
|
+
out2.push(path75.join(home, "bin"));
|
|
37175
37241
|
out2.push(...agentInstallBinDirs());
|
|
37176
37242
|
if (process.platform === "win32") {
|
|
37177
37243
|
const { LOCALAPPDATA, APPDATA } = process.env;
|
|
37178
|
-
if (LOCALAPPDATA) out2.push(
|
|
37179
|
-
if (APPDATA) out2.push(
|
|
37244
|
+
if (LOCALAPPDATA) out2.push(path75.join(LOCALAPPDATA, "cursor-agent"));
|
|
37245
|
+
if (APPDATA) out2.push(path75.join(APPDATA, "npm"));
|
|
37180
37246
|
}
|
|
37181
37247
|
return out2.filter((p2) => {
|
|
37182
37248
|
try {
|
|
@@ -37187,7 +37253,7 @@ function knownAgentBinaryDirs() {
|
|
|
37187
37253
|
});
|
|
37188
37254
|
}
|
|
37189
37255
|
function expandPathForAgentBinaries(existingPath) {
|
|
37190
|
-
const existing = new Set(existingPath.split(
|
|
37256
|
+
const existing = new Set(existingPath.split(path75.delimiter).filter((p2) => p2.length > 0));
|
|
37191
37257
|
const additions = [];
|
|
37192
37258
|
for (const dir of knownAgentBinaryDirs()) {
|
|
37193
37259
|
if (!existing.has(dir)) {
|
|
@@ -37196,7 +37262,7 @@ function expandPathForAgentBinaries(existingPath) {
|
|
|
37196
37262
|
}
|
|
37197
37263
|
}
|
|
37198
37264
|
if (additions.length === 0) return existingPath;
|
|
37199
|
-
return [...additions, existingPath].filter((p2) => p2.length > 0).join(
|
|
37265
|
+
return [...additions, existingPath].filter((p2) => p2.length > 0).join(path75.delimiter);
|
|
37200
37266
|
}
|
|
37201
37267
|
|
|
37202
37268
|
// src/commands/host/agent-install.ts
|
|
@@ -37468,9 +37534,9 @@ async function performAgentSwitch(deps, rawAgentId, fastPath = {}) {
|
|
|
37468
37534
|
}
|
|
37469
37535
|
|
|
37470
37536
|
// src/commands/host/agent-provisioning.ts
|
|
37471
|
-
var
|
|
37537
|
+
var fs65 = __toESM(require("fs"));
|
|
37472
37538
|
var os50 = __toESM(require("os"));
|
|
37473
|
-
var
|
|
37539
|
+
var path76 = __toESM(require("path"));
|
|
37474
37540
|
var PUBLIC_TO_INTERNAL_AGENT = {
|
|
37475
37541
|
claude_code: "claude",
|
|
37476
37542
|
claude: "claude",
|
|
@@ -37487,22 +37553,22 @@ function toInternalAgentId(publicAgentId) {
|
|
|
37487
37553
|
return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
|
|
37488
37554
|
}
|
|
37489
37555
|
function ensureDir(dir) {
|
|
37490
|
-
|
|
37556
|
+
fs65.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
37491
37557
|
}
|
|
37492
37558
|
function writeFile0600(filePath, contents) {
|
|
37493
|
-
ensureDir(
|
|
37494
|
-
|
|
37559
|
+
ensureDir(path76.dirname(filePath));
|
|
37560
|
+
fs65.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
|
|
37495
37561
|
restrictToOwner(filePath);
|
|
37496
37562
|
}
|
|
37497
37563
|
function rmIfExists(filePath) {
|
|
37498
37564
|
try {
|
|
37499
|
-
|
|
37565
|
+
fs65.rmSync(filePath, { force: true });
|
|
37500
37566
|
} catch {
|
|
37501
37567
|
}
|
|
37502
37568
|
}
|
|
37503
37569
|
var claudeProvisioner = {
|
|
37504
37570
|
write(auth, home) {
|
|
37505
|
-
const credentialsJson =
|
|
37571
|
+
const credentialsJson = path76.join(home, ".claude", ".credentials.json");
|
|
37506
37572
|
if (auth.kind === "api_key") {
|
|
37507
37573
|
rmIfExists(credentialsJson);
|
|
37508
37574
|
return { ANTHROPIC_API_KEY: auth.value };
|
|
@@ -37514,8 +37580,8 @@ var claudeProvisioner = {
|
|
|
37514
37580
|
} else {
|
|
37515
37581
|
rmIfExists(credentialsJson);
|
|
37516
37582
|
}
|
|
37517
|
-
const claudeJson =
|
|
37518
|
-
if (!
|
|
37583
|
+
const claudeJson = path76.join(home, ".claude.json");
|
|
37584
|
+
if (!fs65.existsSync(claudeJson)) {
|
|
37519
37585
|
writeFile0600(
|
|
37520
37586
|
claudeJson,
|
|
37521
37587
|
JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
|
|
@@ -37526,7 +37592,7 @@ var claudeProvisioner = {
|
|
|
37526
37592
|
};
|
|
37527
37593
|
var codexProvisioner = {
|
|
37528
37594
|
write(auth, home) {
|
|
37529
|
-
const authJson =
|
|
37595
|
+
const authJson = path76.join(home, ".codex", "auth.json");
|
|
37530
37596
|
if (auth.kind === "api_key") {
|
|
37531
37597
|
writeFile0600(authJson, JSON.stringify({ auth_mode: "apikey", OPENAI_API_KEY: auth.value }));
|
|
37532
37598
|
return { OPENAI_API_KEY: auth.value };
|
|
@@ -37549,7 +37615,7 @@ function codexLoginStamp(raw) {
|
|
|
37549
37615
|
function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
37550
37616
|
let onDisk;
|
|
37551
37617
|
try {
|
|
37552
|
-
onDisk =
|
|
37618
|
+
onDisk = fs65.readFileSync(authJsonPath, "utf8");
|
|
37553
37619
|
} catch {
|
|
37554
37620
|
return false;
|
|
37555
37621
|
}
|
|
@@ -37560,8 +37626,8 @@ function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
|
37560
37626
|
}
|
|
37561
37627
|
var geminiProvisioner = {
|
|
37562
37628
|
write(auth, home) {
|
|
37563
|
-
const settingsJson =
|
|
37564
|
-
const oauthCreds =
|
|
37629
|
+
const settingsJson = path76.join(home, ".gemini", "settings.json");
|
|
37630
|
+
const oauthCreds = path76.join(home, ".gemini", "oauth_creds.json");
|
|
37565
37631
|
if (auth.kind === "api_key") {
|
|
37566
37632
|
rmIfExists(oauthCreds);
|
|
37567
37633
|
writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
|
|
@@ -37574,7 +37640,7 @@ var geminiProvisioner = {
|
|
|
37574
37640
|
};
|
|
37575
37641
|
var cursorProvisioner = {
|
|
37576
37642
|
write(auth, home) {
|
|
37577
|
-
const authJson =
|
|
37643
|
+
const authJson = path76.join(home, ".config", "cursor", "auth.json");
|
|
37578
37644
|
if (auth.kind === "api_key") {
|
|
37579
37645
|
rmIfExists(authJson);
|
|
37580
37646
|
return { CURSOR_API_KEY: auth.value };
|
|
@@ -37616,22 +37682,22 @@ max_context_size = 262144
|
|
|
37616
37682
|
var kimiProvisioner = {
|
|
37617
37683
|
write(auth, home) {
|
|
37618
37684
|
const credentialsFiles = [
|
|
37619
|
-
|
|
37620
|
-
|
|
37685
|
+
path76.join(home, ".kimi", "credentials", "kimi-code.json"),
|
|
37686
|
+
path76.join(home, ".kimi-code", "credentials", "kimi-code.json")
|
|
37621
37687
|
];
|
|
37622
37688
|
if (auth.kind === "api_key") {
|
|
37623
37689
|
credentialsFiles.forEach(rmIfExists);
|
|
37624
37690
|
return { KIMI_API_KEY: auth.value };
|
|
37625
37691
|
}
|
|
37626
37692
|
credentialsFiles.forEach((f) => writeFile0600(f, auth.value));
|
|
37627
|
-
writeFile0600(
|
|
37693
|
+
writeFile0600(path76.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
|
|
37628
37694
|
return {};
|
|
37629
37695
|
}
|
|
37630
37696
|
};
|
|
37631
37697
|
var coderabbitProvisioner = {
|
|
37632
37698
|
write(auth, home) {
|
|
37633
|
-
const dir =
|
|
37634
|
-
const authJson =
|
|
37699
|
+
const dir = path76.join(home, ".coderabbit");
|
|
37700
|
+
const authJson = path76.join(dir, "auth.json");
|
|
37635
37701
|
if (auth.kind === "api_key") {
|
|
37636
37702
|
rmIfExists(authJson);
|
|
37637
37703
|
return { CODERABBIT_API_KEY: auth.value };
|
|
@@ -37643,13 +37709,13 @@ var coderabbitProvisioner = {
|
|
|
37643
37709
|
try {
|
|
37644
37710
|
const parsed = JSON.parse(value);
|
|
37645
37711
|
if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
|
|
37646
|
-
file =
|
|
37712
|
+
file = path76.basename(parsed.file);
|
|
37647
37713
|
contents = parsed.contents;
|
|
37648
37714
|
}
|
|
37649
37715
|
} catch {
|
|
37650
37716
|
}
|
|
37651
37717
|
}
|
|
37652
|
-
writeFile0600(
|
|
37718
|
+
writeFile0600(path76.join(dir, file), contents);
|
|
37653
37719
|
return {};
|
|
37654
37720
|
}
|
|
37655
37721
|
};
|
|
@@ -37686,19 +37752,8 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os50.homedir(
|
|
|
37686
37752
|
}
|
|
37687
37753
|
|
|
37688
37754
|
// src/beads/workflow-hint.ts
|
|
37689
|
-
var
|
|
37690
|
-
var
|
|
37691
|
-
|
|
37692
|
-
// src/agents/claude-memory-file.ts
|
|
37693
|
-
var os51 = __toESM(require("os"));
|
|
37694
|
-
var path75 = __toESM(require("path"));
|
|
37695
|
-
function claudeMemoryFile(homeDir2, env = process.env) {
|
|
37696
|
-
if (homeDir2) return path75.join(homeDir2, ".claude", "CLAUDE.md");
|
|
37697
|
-
const configDir = env.CLAUDE_CONFIG_DIR?.trim();
|
|
37698
|
-
return configDir ? path75.join(configDir, "CLAUDE.md") : path75.join(os51.homedir(), ".claude", "CLAUDE.md");
|
|
37699
|
-
}
|
|
37700
|
-
|
|
37701
|
-
// src/beads/workflow-hint.ts
|
|
37755
|
+
var fs66 = __toESM(require("fs"));
|
|
37756
|
+
var path77 = __toESM(require("path"));
|
|
37702
37757
|
var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
|
|
37703
37758
|
var BEADS_HINT = `${BEADS_HINT_MARKER}
|
|
37704
37759
|
# Beads (bd) \u2014 task tracking + persistent memory (ALWAYS use it)
|
|
@@ -37725,11 +37780,11 @@ function ensureBeadsWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
|
37725
37780
|
try {
|
|
37726
37781
|
let existing = "";
|
|
37727
37782
|
try {
|
|
37728
|
-
existing =
|
|
37783
|
+
existing = fs66.readFileSync(file, "utf8");
|
|
37729
37784
|
} catch {
|
|
37730
37785
|
}
|
|
37731
37786
|
if (existing.includes(BEADS_HINT)) return;
|
|
37732
|
-
|
|
37787
|
+
fs66.mkdirSync(path77.dirname(file), { recursive: true });
|
|
37733
37788
|
let next;
|
|
37734
37789
|
const open = existing.indexOf(BEADS_HINT_MARKER);
|
|
37735
37790
|
const close = open === -1 ? -1 : existing.indexOf(BEADS_HINT_MARKER, open + BEADS_HINT_MARKER.length);
|
|
@@ -37742,40 +37797,40 @@ ${BEADS_HINT}
|
|
|
37742
37797
|
` : `${BEADS_HINT}
|
|
37743
37798
|
`;
|
|
37744
37799
|
}
|
|
37745
|
-
|
|
37800
|
+
fs66.writeFileSync(file, next);
|
|
37746
37801
|
} catch {
|
|
37747
37802
|
}
|
|
37748
37803
|
}
|
|
37749
37804
|
|
|
37750
37805
|
// src/agents/agent-standard.ts
|
|
37751
|
-
var
|
|
37752
|
-
var
|
|
37753
|
-
var
|
|
37806
|
+
var fs67 = __toESM(require("fs"));
|
|
37807
|
+
var path78 = __toESM(require("path"));
|
|
37808
|
+
var os51 = __toESM(require("os"));
|
|
37754
37809
|
function ensureAgentStandard(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
37755
37810
|
try {
|
|
37756
37811
|
let existing = "";
|
|
37757
37812
|
try {
|
|
37758
|
-
existing =
|
|
37813
|
+
existing = fs67.readFileSync(file, "utf8");
|
|
37759
37814
|
} catch {
|
|
37760
37815
|
}
|
|
37761
37816
|
if (existing.includes(AGENT_STANDARD_MARKER)) return;
|
|
37762
|
-
|
|
37817
|
+
fs67.mkdirSync(path78.dirname(file), { recursive: true });
|
|
37763
37818
|
const next = existing.trim() ? `${existing.trimEnd()}
|
|
37764
37819
|
|
|
37765
37820
|
${AGENT_STANDARD_BLOCK}
|
|
37766
37821
|
` : `${AGENT_STANDARD_BLOCK}
|
|
37767
37822
|
`;
|
|
37768
|
-
|
|
37823
|
+
fs67.writeFileSync(file, next);
|
|
37769
37824
|
} catch {
|
|
37770
37825
|
}
|
|
37771
37826
|
}
|
|
37772
37827
|
var _agentStandardSeam = {
|
|
37773
37828
|
isLocalSession: () => isLocalSession(),
|
|
37774
|
-
markerPath: (sessionId) =>
|
|
37775
|
-
exists: (p2) =>
|
|
37829
|
+
markerPath: (sessionId) => path78.join(os51.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
|
|
37830
|
+
exists: (p2) => fs67.existsSync(p2),
|
|
37776
37831
|
write: (p2) => {
|
|
37777
|
-
|
|
37778
|
-
|
|
37832
|
+
fs67.mkdirSync(path78.dirname(p2), { recursive: true });
|
|
37833
|
+
fs67.writeFileSync(p2, "");
|
|
37779
37834
|
}
|
|
37780
37835
|
};
|
|
37781
37836
|
function isClaude(agent) {
|
|
@@ -38468,15 +38523,15 @@ function withholdTrailingPartialFenceMarker(text) {
|
|
|
38468
38523
|
|
|
38469
38524
|
// src/agents/acp/onboarding.ts
|
|
38470
38525
|
var import_child_process28 = require("child_process");
|
|
38471
|
-
var
|
|
38472
|
-
var
|
|
38473
|
-
var
|
|
38526
|
+
var fs68 = __toESM(require("fs"));
|
|
38527
|
+
var os52 = __toESM(require("os"));
|
|
38528
|
+
var path79 = __toESM(require("path"));
|
|
38474
38529
|
var _onboardingSeam = {
|
|
38475
|
-
markerPath: (sessionId) =>
|
|
38476
|
-
exists: (p2) =>
|
|
38530
|
+
markerPath: (sessionId) => path79.join(os52.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
38531
|
+
exists: (p2) => fs68.existsSync(p2),
|
|
38477
38532
|
write: (p2) => {
|
|
38478
|
-
|
|
38479
|
-
|
|
38533
|
+
fs68.mkdirSync(path79.dirname(p2), { recursive: true });
|
|
38534
|
+
fs68.writeFileSync(p2, "");
|
|
38480
38535
|
},
|
|
38481
38536
|
disabled: () => {
|
|
38482
38537
|
const v = process.env.CODEAM_ONBOARDING_DISABLED;
|
|
@@ -38513,7 +38568,7 @@ function resolveRepoName(cwd) {
|
|
|
38513
38568
|
if (name) return name;
|
|
38514
38569
|
}
|
|
38515
38570
|
}
|
|
38516
|
-
const base =
|
|
38571
|
+
const base = path79.basename(cwd || "");
|
|
38517
38572
|
if (base && !isUuid(base)) return base;
|
|
38518
38573
|
return "this project";
|
|
38519
38574
|
}
|
|
@@ -38589,7 +38644,7 @@ async function runOnboardingTurn(opts) {
|
|
|
38589
38644
|
}
|
|
38590
38645
|
|
|
38591
38646
|
// src/agents/acp/mappers.ts
|
|
38592
|
-
var
|
|
38647
|
+
var import_node_crypto11 = require("crypto");
|
|
38593
38648
|
var BD_PRIME_COMMAND_RE = /(?:^|[;&|]\s*)bd\s+prime\b/;
|
|
38594
38649
|
var ToolCallTracker = class {
|
|
38595
38650
|
bdPrimeIds = /* @__PURE__ */ new Set();
|
|
@@ -38695,7 +38750,7 @@ function mapPermissionRequest(request2) {
|
|
|
38695
38750
|
}));
|
|
38696
38751
|
return {
|
|
38697
38752
|
event: {
|
|
38698
|
-
questionId: (0,
|
|
38753
|
+
questionId: (0, import_node_crypto11.randomUUID)(),
|
|
38699
38754
|
prompt,
|
|
38700
38755
|
options: options.length > 0 ? options.map((o) => ({ label: o.label, value: o.optionId })) : void 0
|
|
38701
38756
|
},
|
|
@@ -38704,7 +38759,7 @@ function mapPermissionRequest(request2) {
|
|
|
38704
38759
|
}
|
|
38705
38760
|
function messageChunkId(messageId) {
|
|
38706
38761
|
if (typeof messageId === "string" && messageId.length > 0) return messageId;
|
|
38707
|
-
return (0,
|
|
38762
|
+
return (0, import_node_crypto11.randomUUID)();
|
|
38708
38763
|
}
|
|
38709
38764
|
function extractText4(content) {
|
|
38710
38765
|
if (!content || typeof content !== "object") return null;
|
|
@@ -38905,14 +38960,14 @@ var import_crypto5 = require("crypto");
|
|
|
38905
38960
|
|
|
38906
38961
|
// src/services/turn-files/git-changeset.ts
|
|
38907
38962
|
var import_child_process29 = require("child_process");
|
|
38908
|
-
var
|
|
38963
|
+
var fs70 = __toESM(require("fs/promises"));
|
|
38909
38964
|
var import_fs7 = require("fs");
|
|
38910
|
-
var
|
|
38965
|
+
var path81 = __toESM(require("path"));
|
|
38911
38966
|
|
|
38912
38967
|
// src/services/turn-files/review-ignore.ts
|
|
38913
38968
|
var import_ignore2 = __toESM(require("ignore"));
|
|
38914
|
-
var
|
|
38915
|
-
var
|
|
38969
|
+
var fs69 = __toESM(require("fs"));
|
|
38970
|
+
var path80 = __toESM(require("path"));
|
|
38916
38971
|
var CURATED_REVIEW_IGNORE = [
|
|
38917
38972
|
// Google Cloud SDK (the incident) — installs a huge python tree.
|
|
38918
38973
|
"google-cloud-sdk/",
|
|
@@ -38956,7 +39011,7 @@ var CURATED_REVIEW_IGNORE = [
|
|
|
38956
39011
|
function makeReviewIgnore(repoRoot) {
|
|
38957
39012
|
const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
|
|
38958
39013
|
try {
|
|
38959
|
-
const custom =
|
|
39014
|
+
const custom = fs69.readFileSync(path80.join(repoRoot, ".codeam", "reviewignore"), "utf8");
|
|
38960
39015
|
ig.add(custom);
|
|
38961
39016
|
} catch {
|
|
38962
39017
|
}
|
|
@@ -38991,7 +39046,7 @@ async function collectRepoChangeset(opts) {
|
|
|
38991
39046
|
const rows = parseStatus(status2).filter(
|
|
38992
39047
|
(row) => !isIgnoredFilePath(row.filePath) && !reviewIgnore(row.filePath) && // A socket, FIFO or device node is never a change to review (a
|
|
38993
39048
|
// `cc-socks/1522.sock` reached the Files tab).
|
|
38994
|
-
isReviewablePath(
|
|
39049
|
+
isReviewablePath(path81.join(opts.repoRoot, row.filePath))
|
|
38995
39050
|
);
|
|
38996
39051
|
const MAX_CHANGESET_FILES = Math.max(1, Number(process.env.CODEAM_MAX_CHANGESET_FILES ?? 500));
|
|
38997
39052
|
const truncated = rows.length > MAX_CHANGESET_FILES;
|
|
@@ -39008,7 +39063,7 @@ async function collectRepoChangeset(opts) {
|
|
|
39008
39063
|
let stats;
|
|
39009
39064
|
if (!truncated && row.fileStatus === "added" && numstatEntry === void 0) {
|
|
39010
39065
|
const lineCount = await readUntrackedLineCount(
|
|
39011
|
-
|
|
39066
|
+
path81.join(opts.repoRoot, row.filePath)
|
|
39012
39067
|
);
|
|
39013
39068
|
stats = { added: lineCount, removed: 0 };
|
|
39014
39069
|
} else {
|
|
@@ -39039,7 +39094,7 @@ function readUntrackedLineCount(absPath) {
|
|
|
39039
39094
|
}
|
|
39040
39095
|
async function defaultReadUntrackedLineCount(absPath) {
|
|
39041
39096
|
try {
|
|
39042
|
-
const content = await
|
|
39097
|
+
const content = await fs70.readFile(absPath, "utf8");
|
|
39043
39098
|
let count = 0;
|
|
39044
39099
|
let pos = -1;
|
|
39045
39100
|
while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
|
|
@@ -39131,7 +39186,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
39131
39186
|
});
|
|
39132
39187
|
}
|
|
39133
39188
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
39134
|
-
const
|
|
39189
|
+
const fs91 = await import("fs/promises");
|
|
39135
39190
|
const out2 = [];
|
|
39136
39191
|
await walk2(workingDir, 0);
|
|
39137
39192
|
return out2;
|
|
@@ -39139,7 +39194,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39139
39194
|
if (depth2 > maxDepth) return;
|
|
39140
39195
|
let entries2 = [];
|
|
39141
39196
|
try {
|
|
39142
|
-
const dirents = await
|
|
39197
|
+
const dirents = await fs91.readdir(dir, { withFileTypes: true });
|
|
39143
39198
|
entries2 = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
39144
39199
|
} catch {
|
|
39145
39200
|
return;
|
|
@@ -39150,8 +39205,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39150
39205
|
if (hasGit) {
|
|
39151
39206
|
out2.push({
|
|
39152
39207
|
repoRoot: dir,
|
|
39153
|
-
repoPath:
|
|
39154
|
-
repoName:
|
|
39208
|
+
repoPath: path81.relative(workingDir, dir),
|
|
39209
|
+
repoName: path81.basename(dir)
|
|
39155
39210
|
});
|
|
39156
39211
|
return;
|
|
39157
39212
|
}
|
|
@@ -39159,7 +39214,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
39159
39214
|
if (!entry.isDirectory) continue;
|
|
39160
39215
|
if (entry.name === "node_modules") continue;
|
|
39161
39216
|
if (entry.name === "dist" || entry.name === "build") continue;
|
|
39162
|
-
await walk2(
|
|
39217
|
+
await walk2(path81.join(dir, entry.name), depth2 + 1);
|
|
39163
39218
|
}
|
|
39164
39219
|
}
|
|
39165
39220
|
}
|
|
@@ -39173,8 +39228,8 @@ function isReviewablePath(absPath) {
|
|
|
39173
39228
|
}
|
|
39174
39229
|
|
|
39175
39230
|
// src/services/turn-files/files-outbox.ts
|
|
39176
|
-
var
|
|
39177
|
-
var
|
|
39231
|
+
var fs71 = __toESM(require("fs/promises"));
|
|
39232
|
+
var path82 = __toESM(require("path"));
|
|
39178
39233
|
var import_os12 = require("os");
|
|
39179
39234
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
39180
39235
|
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -39207,16 +39262,16 @@ var FilesOutbox = class {
|
|
|
39207
39262
|
backoffIndex = 0;
|
|
39208
39263
|
stopped = false;
|
|
39209
39264
|
constructor(opts) {
|
|
39210
|
-
const base = opts.baseDir ??
|
|
39211
|
-
this.filePath =
|
|
39265
|
+
const base = opts.baseDir ?? path82.join(homeDir(), HOME_OUTBOX_DIR);
|
|
39266
|
+
this.filePath = path82.join(base, `${opts.sessionId}.jsonl`);
|
|
39212
39267
|
this.post = opts.post;
|
|
39213
39268
|
this.autoSchedule = opts.autoSchedule !== false;
|
|
39214
39269
|
}
|
|
39215
39270
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
39216
39271
|
* line is durable on disk (not once the POST succeeds). */
|
|
39217
39272
|
async enqueue(entry) {
|
|
39218
|
-
await
|
|
39219
|
-
await
|
|
39273
|
+
await fs71.mkdir(path82.dirname(this.filePath), { recursive: true });
|
|
39274
|
+
await fs71.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
39220
39275
|
this.backoffIndex = 0;
|
|
39221
39276
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
39222
39277
|
}
|
|
@@ -39307,7 +39362,7 @@ var FilesOutbox = class {
|
|
|
39307
39362
|
async readAll() {
|
|
39308
39363
|
let raw = "";
|
|
39309
39364
|
try {
|
|
39310
|
-
raw = await
|
|
39365
|
+
raw = await fs71.readFile(this.filePath, "utf8");
|
|
39311
39366
|
} catch {
|
|
39312
39367
|
return [];
|
|
39313
39368
|
}
|
|
@@ -39331,12 +39386,12 @@ var FilesOutbox = class {
|
|
|
39331
39386
|
async rewrite(entries2) {
|
|
39332
39387
|
const tmpPath = `${this.filePath}.${process.pid}.tmp`;
|
|
39333
39388
|
if (entries2.length === 0) {
|
|
39334
|
-
await
|
|
39389
|
+
await fs71.unlink(this.filePath).catch(() => void 0);
|
|
39335
39390
|
return;
|
|
39336
39391
|
}
|
|
39337
39392
|
const payload = entries2.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
39338
|
-
await
|
|
39339
|
-
await
|
|
39393
|
+
await fs71.writeFile(tmpPath, payload, "utf8");
|
|
39394
|
+
await fs71.rename(tmpPath, this.filePath);
|
|
39340
39395
|
}
|
|
39341
39396
|
};
|
|
39342
39397
|
function applyJitter(ms) {
|
|
@@ -39653,27 +39708,27 @@ async function postCredentialSync(opts, fetchImpl = fetch) {
|
|
|
39653
39708
|
}
|
|
39654
39709
|
|
|
39655
39710
|
// src/services/turn-marker.ts
|
|
39656
|
-
var
|
|
39657
|
-
var
|
|
39658
|
-
var
|
|
39711
|
+
var fs72 = __toESM(require("fs"));
|
|
39712
|
+
var os53 = __toESM(require("os"));
|
|
39713
|
+
var path83 = __toESM(require("path"));
|
|
39659
39714
|
var depth = 0;
|
|
39660
39715
|
function codeamHome() {
|
|
39661
|
-
return
|
|
39716
|
+
return path83.join(os53.homedir(), ".codeam");
|
|
39662
39717
|
}
|
|
39663
39718
|
function turnMarkerPath(pid = process.pid, home = codeamHome()) {
|
|
39664
|
-
return
|
|
39719
|
+
return path83.join(home, "turns", String(pid));
|
|
39665
39720
|
}
|
|
39666
39721
|
function mark() {
|
|
39667
39722
|
try {
|
|
39668
39723
|
const file = turnMarkerPath();
|
|
39669
|
-
|
|
39670
|
-
|
|
39724
|
+
fs72.mkdirSync(path83.dirname(file), { recursive: true });
|
|
39725
|
+
fs72.writeFileSync(file, String(Date.now()));
|
|
39671
39726
|
} catch {
|
|
39672
39727
|
}
|
|
39673
39728
|
}
|
|
39674
39729
|
function clear() {
|
|
39675
39730
|
try {
|
|
39676
|
-
|
|
39731
|
+
fs72.rmSync(turnMarkerPath(), { force: true });
|
|
39677
39732
|
} catch {
|
|
39678
39733
|
}
|
|
39679
39734
|
}
|
|
@@ -39688,7 +39743,7 @@ async function withTurnMarker(fn) {
|
|
|
39688
39743
|
function isProcessMidTurn(pid, home) {
|
|
39689
39744
|
if (!pid) return false;
|
|
39690
39745
|
try {
|
|
39691
|
-
return
|
|
39746
|
+
return fs72.existsSync(turnMarkerPath(pid, home));
|
|
39692
39747
|
} catch {
|
|
39693
39748
|
return false;
|
|
39694
39749
|
}
|
|
@@ -39696,8 +39751,8 @@ function isProcessMidTurn(pid, home) {
|
|
|
39696
39751
|
|
|
39697
39752
|
// src/packs/gates.ts
|
|
39698
39753
|
var import_node_child_process28 = require("child_process");
|
|
39699
|
-
var
|
|
39700
|
-
var
|
|
39754
|
+
var fs73 = __toESM(require("fs"));
|
|
39755
|
+
var path84 = __toESM(require("path"));
|
|
39701
39756
|
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve12) => {
|
|
39702
39757
|
(0, import_node_child_process28.execFile)(
|
|
39703
39758
|
file,
|
|
@@ -39747,7 +39802,7 @@ async function changedFiles(run3, cwd, from, to) {
|
|
|
39747
39802
|
}
|
|
39748
39803
|
function readWorkspaceFile(cwd, relPath) {
|
|
39749
39804
|
try {
|
|
39750
|
-
return
|
|
39805
|
+
return fs73.readFileSync(path84.join(cwd, relPath), "utf8");
|
|
39751
39806
|
} catch {
|
|
39752
39807
|
return null;
|
|
39753
39808
|
}
|
|
@@ -39756,14 +39811,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
|
|
|
39756
39811
|
var CHECKS_TIMEOUT_MS = 5 * 6e4;
|
|
39757
39812
|
function detectChecksCommand(cwd) {
|
|
39758
39813
|
try {
|
|
39759
|
-
const cfg = JSON.parse(
|
|
39814
|
+
const cfg = JSON.parse(fs73.readFileSync(path84.join(cwd, ".codeam", "pack.json"), "utf8"));
|
|
39760
39815
|
if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
|
|
39761
39816
|
return cfg.checksCommand.trim();
|
|
39762
39817
|
}
|
|
39763
39818
|
} catch {
|
|
39764
39819
|
}
|
|
39765
39820
|
try {
|
|
39766
|
-
const pkg = JSON.parse(
|
|
39821
|
+
const pkg = JSON.parse(fs73.readFileSync(path84.join(cwd, "package.json"), "utf8"));
|
|
39767
39822
|
const test = pkg.scripts?.test;
|
|
39768
39823
|
if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
|
|
39769
39824
|
return "npm test";
|
|
@@ -39781,39 +39836,39 @@ ${res.stderr}`.trim();
|
|
|
39781
39836
|
}
|
|
39782
39837
|
|
|
39783
39838
|
// src/packs/run-store.ts
|
|
39784
|
-
var
|
|
39785
|
-
var
|
|
39839
|
+
var fs74 = __toESM(require("fs"));
|
|
39840
|
+
var path85 = __toESM(require("path"));
|
|
39786
39841
|
var crypto5 = __toESM(require("crypto"));
|
|
39787
39842
|
function packsDir(cwd) {
|
|
39788
|
-
return
|
|
39843
|
+
return path85.join(cwd, ".codeam", "packs");
|
|
39789
39844
|
}
|
|
39790
39845
|
function runDir(cwd, runId) {
|
|
39791
|
-
return
|
|
39846
|
+
return path85.join(packsDir(cwd), runId);
|
|
39792
39847
|
}
|
|
39793
39848
|
function newRunId() {
|
|
39794
39849
|
return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
|
|
39795
39850
|
}
|
|
39796
39851
|
function writeJsonAtomic(file, value) {
|
|
39797
|
-
|
|
39852
|
+
fs74.mkdirSync(path85.dirname(file), { recursive: true });
|
|
39798
39853
|
const tmp = `${file}.tmp`;
|
|
39799
|
-
|
|
39800
|
-
|
|
39854
|
+
fs74.writeFileSync(tmp, JSON.stringify(value, null, 2));
|
|
39855
|
+
fs74.renameSync(tmp, file);
|
|
39801
39856
|
}
|
|
39802
39857
|
function saveRun(cwd, state) {
|
|
39803
|
-
writeJsonAtomic(
|
|
39858
|
+
writeJsonAtomic(path85.join(runDir(cwd, state.runId), "run.json"), state);
|
|
39804
39859
|
}
|
|
39805
39860
|
function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
|
|
39806
39861
|
const name = `${String(stageIndex + 1).padStart(2, "0")}-${role}.json`;
|
|
39807
|
-
writeJsonAtomic(
|
|
39862
|
+
writeJsonAtomic(path85.join(runDir(cwd, runId), name), handoff);
|
|
39808
39863
|
}
|
|
39809
39864
|
function loadLatestRun(cwd) {
|
|
39810
39865
|
try {
|
|
39811
39866
|
const dir = packsDir(cwd);
|
|
39812
|
-
const entries2 =
|
|
39867
|
+
const entries2 = fs74.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
39813
39868
|
for (let i = entries2.length - 1; i >= 0; i--) {
|
|
39814
|
-
const file =
|
|
39869
|
+
const file = path85.join(dir, entries2[i], "run.json");
|
|
39815
39870
|
try {
|
|
39816
|
-
const parsed = JSON.parse(
|
|
39871
|
+
const parsed = JSON.parse(fs74.readFileSync(file, "utf8"));
|
|
39817
39872
|
if (parsed && typeof parsed.runId === "string") return parsed;
|
|
39818
39873
|
} catch {
|
|
39819
39874
|
}
|
|
@@ -39824,17 +39879,17 @@ function loadLatestRun(cwd) {
|
|
|
39824
39879
|
}
|
|
39825
39880
|
function ensureLedgerIgnored(cwd) {
|
|
39826
39881
|
try {
|
|
39827
|
-
const gitDir =
|
|
39828
|
-
if (!
|
|
39829
|
-
const exclude =
|
|
39882
|
+
const gitDir = path85.join(cwd, ".git");
|
|
39883
|
+
if (!fs74.existsSync(gitDir)) return;
|
|
39884
|
+
const exclude = path85.join(gitDir, "info", "exclude");
|
|
39830
39885
|
let existing = "";
|
|
39831
39886
|
try {
|
|
39832
|
-
existing =
|
|
39887
|
+
existing = fs74.readFileSync(exclude, "utf8");
|
|
39833
39888
|
} catch {
|
|
39834
39889
|
}
|
|
39835
39890
|
if (existing.includes(".codeam/packs/")) return;
|
|
39836
|
-
|
|
39837
|
-
|
|
39891
|
+
fs74.mkdirSync(path85.dirname(exclude), { recursive: true });
|
|
39892
|
+
fs74.writeFileSync(exclude, `${existing.trimEnd()}
|
|
39838
39893
|
.codeam/packs/
|
|
39839
39894
|
`.trimStart());
|
|
39840
39895
|
} catch {
|
|
@@ -40612,10 +40667,10 @@ var packStatusH = async (ctx) => {
|
|
|
40612
40667
|
|
|
40613
40668
|
// src/integrations/manifest.ts
|
|
40614
40669
|
var import_node_fs16 = __toESM(require("fs"));
|
|
40615
|
-
var
|
|
40616
|
-
var
|
|
40670
|
+
var import_node_os13 = __toESM(require("os"));
|
|
40671
|
+
var import_node_path17 = __toESM(require("path"));
|
|
40617
40672
|
function integrationsManifestPath() {
|
|
40618
|
-
return
|
|
40673
|
+
return import_node_path17.default.join(import_node_os13.default.homedir(), ".codeam", "integrations.json");
|
|
40619
40674
|
}
|
|
40620
40675
|
function readIntegrationsManifest() {
|
|
40621
40676
|
try {
|
|
@@ -40629,7 +40684,7 @@ function readIntegrationsManifest() {
|
|
|
40629
40684
|
function persistIntegrationsManifest(m) {
|
|
40630
40685
|
try {
|
|
40631
40686
|
const file = integrationsManifestPath();
|
|
40632
|
-
import_node_fs16.default.mkdirSync(
|
|
40687
|
+
import_node_fs16.default.mkdirSync(import_node_path17.default.dirname(file), { recursive: true, mode: 448 });
|
|
40633
40688
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
40634
40689
|
import_node_fs16.default.writeFileSync(tmp, JSON.stringify(m, null, 2), { encoding: "utf8", mode: 384 });
|
|
40635
40690
|
import_node_fs16.default.renameSync(tmp, file);
|
|
@@ -40815,20 +40870,20 @@ async function mcpRouter() {
|
|
|
40815
40870
|
}
|
|
40816
40871
|
|
|
40817
40872
|
// src/integrations/mcp-secrets.ts
|
|
40818
|
-
var
|
|
40819
|
-
var
|
|
40820
|
-
var
|
|
40873
|
+
var fs76 = __toESM(require("fs"));
|
|
40874
|
+
var os55 = __toESM(require("os"));
|
|
40875
|
+
var path87 = __toESM(require("path"));
|
|
40821
40876
|
var MCP_SECRETS_FILE_ENV = "CODEAM_MCP_SECRETS_FILE";
|
|
40822
40877
|
function mcpSecretsDir() {
|
|
40823
|
-
return
|
|
40878
|
+
return path87.join(os55.homedir(), ".codeam", "mcp-secrets");
|
|
40824
40879
|
}
|
|
40825
40880
|
function mcpSecretsPath(scope, pid = process.pid) {
|
|
40826
|
-
return
|
|
40881
|
+
return path87.join(mcpSecretsDir(), `${pid}-${scope}.json`);
|
|
40827
40882
|
}
|
|
40828
40883
|
var registeredForCleanup = /* @__PURE__ */ new Set();
|
|
40829
40884
|
function readFileVars(file) {
|
|
40830
40885
|
try {
|
|
40831
|
-
const parsed = JSON.parse(
|
|
40886
|
+
const parsed = JSON.parse(fs76.readFileSync(file, "utf8"));
|
|
40832
40887
|
if (!parsed || typeof parsed !== "object") return {};
|
|
40833
40888
|
const out2 = {};
|
|
40834
40889
|
for (const [k2, v] of Object.entries(parsed)) {
|
|
@@ -40850,7 +40905,7 @@ function pidAlive2(pid) {
|
|
|
40850
40905
|
function pruneStale(dir) {
|
|
40851
40906
|
let names = [];
|
|
40852
40907
|
try {
|
|
40853
|
-
names =
|
|
40908
|
+
names = fs76.readdirSync(dir);
|
|
40854
40909
|
} catch {
|
|
40855
40910
|
return;
|
|
40856
40911
|
}
|
|
@@ -40860,25 +40915,25 @@ function pruneStale(dir) {
|
|
|
40860
40915
|
const pid = Number(m[1]);
|
|
40861
40916
|
if (pid === process.pid || pidAlive2(pid)) continue;
|
|
40862
40917
|
try {
|
|
40863
|
-
|
|
40918
|
+
fs76.unlinkSync(path87.join(dir, name));
|
|
40864
40919
|
} catch {
|
|
40865
40920
|
}
|
|
40866
40921
|
}
|
|
40867
40922
|
}
|
|
40868
40923
|
function writeMcpSecrets(vars, file) {
|
|
40869
40924
|
try {
|
|
40870
|
-
const dir =
|
|
40871
|
-
|
|
40925
|
+
const dir = path87.dirname(file);
|
|
40926
|
+
fs76.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
40872
40927
|
pruneStale(dir);
|
|
40873
40928
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
40874
|
-
|
|
40875
|
-
|
|
40876
|
-
|
|
40929
|
+
fs76.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
|
|
40930
|
+
fs76.renameSync(tmp, file);
|
|
40931
|
+
fs76.chmodSync(file, 384);
|
|
40877
40932
|
if (!registeredForCleanup.has(file)) {
|
|
40878
40933
|
registeredForCleanup.add(file);
|
|
40879
40934
|
process.once("exit", () => {
|
|
40880
40935
|
try {
|
|
40881
|
-
|
|
40936
|
+
fs76.unlinkSync(file);
|
|
40882
40937
|
} catch {
|
|
40883
40938
|
}
|
|
40884
40939
|
});
|
|
@@ -40964,11 +41019,11 @@ function previewMcpServer(bridge) {
|
|
|
40964
41019
|
};
|
|
40965
41020
|
}
|
|
40966
41021
|
function httpCall(baseUrl, token) {
|
|
40967
|
-
return async (
|
|
41022
|
+
return async (path106, method, body, timeoutMs) => {
|
|
40968
41023
|
const ac = new AbortController();
|
|
40969
41024
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
40970
41025
|
try {
|
|
40971
|
-
const res = await fetch(`${baseUrl}${
|
|
41026
|
+
const res = await fetch(`${baseUrl}${path106}`, {
|
|
40972
41027
|
method,
|
|
40973
41028
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
40974
41029
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -41095,11 +41150,11 @@ function scratchMcpServer(bridge) {
|
|
|
41095
41150
|
};
|
|
41096
41151
|
}
|
|
41097
41152
|
function httpCall2(baseUrl, token) {
|
|
41098
|
-
return async (
|
|
41153
|
+
return async (path106, method, body, timeoutMs) => {
|
|
41099
41154
|
const ac = new AbortController();
|
|
41100
41155
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
41101
41156
|
try {
|
|
41102
|
-
const res = await fetch(`${baseUrl}${
|
|
41157
|
+
const res = await fetch(`${baseUrl}${path106}`, {
|
|
41103
41158
|
method,
|
|
41104
41159
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
41105
41160
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -41226,11 +41281,11 @@ function buildIntegrationMcpServers(ctx) {
|
|
|
41226
41281
|
|
|
41227
41282
|
// src/services/local-mcp-servers.ts
|
|
41228
41283
|
var import_node_fs17 = __toESM(require("fs"));
|
|
41229
|
-
var
|
|
41230
|
-
var
|
|
41284
|
+
var import_node_os14 = __toESM(require("os"));
|
|
41285
|
+
var import_node_path18 = __toESM(require("path"));
|
|
41231
41286
|
var MAX_LOCAL_MCP_SERVERS = 10;
|
|
41232
41287
|
function localMcpServersPath() {
|
|
41233
|
-
return
|
|
41288
|
+
return import_node_path18.default.join(import_node_os14.default.homedir(), ".codeam", "mcp-servers.json");
|
|
41234
41289
|
}
|
|
41235
41290
|
function isStringArray(v) {
|
|
41236
41291
|
return Array.isArray(v) && v.every((item) => typeof item === "string");
|
|
@@ -41338,14 +41393,14 @@ function mergeWithLocalMcpServers(integrationServers) {
|
|
|
41338
41393
|
|
|
41339
41394
|
// src/commands/start/agent-preview-bridge.ts
|
|
41340
41395
|
var http12 = __toESM(require("http"));
|
|
41341
|
-
var
|
|
41396
|
+
var import_node_crypto12 = require("crypto");
|
|
41342
41397
|
var START_WAIT_MS = 24e4;
|
|
41343
41398
|
var MAX_SELECTOR = 500;
|
|
41344
41399
|
var MAX_LABEL = 80;
|
|
41345
41400
|
var AgentPreviewBridge = class {
|
|
41346
41401
|
server = null;
|
|
41347
41402
|
listening = null;
|
|
41348
|
-
token = (0,
|
|
41403
|
+
token = (0, import_node_crypto12.randomBytes)(24).toString("hex");
|
|
41349
41404
|
ctx = null;
|
|
41350
41405
|
/** The bring-up in flight, so two tool calls never start two dev servers. */
|
|
41351
41406
|
inflight = null;
|
|
@@ -41611,7 +41666,7 @@ function overrideFrom(body) {
|
|
|
41611
41666
|
function authorized(header, token) {
|
|
41612
41667
|
const presented = Buffer.from((header ?? "").replace(/^Bearer\s+/i, ""));
|
|
41613
41668
|
const expected = Buffer.from(token);
|
|
41614
|
-
return presented.length === expected.length && (0,
|
|
41669
|
+
return presented.length === expected.length && (0, import_node_crypto12.timingSafeEqual)(presented, expected);
|
|
41615
41670
|
}
|
|
41616
41671
|
function readJson(req) {
|
|
41617
41672
|
return new Promise((resolve12, reject) => {
|
|
@@ -41640,10 +41695,10 @@ var agentPreviewBridge = new AgentPreviewBridge();
|
|
|
41640
41695
|
|
|
41641
41696
|
// src/integrations/detect-stack.ts
|
|
41642
41697
|
var import_node_fs18 = __toESM(require("fs"));
|
|
41643
|
-
var
|
|
41698
|
+
var import_node_path19 = __toESM(require("path"));
|
|
41644
41699
|
function readSafe(cwd, rel) {
|
|
41645
41700
|
try {
|
|
41646
|
-
return import_node_fs18.default.readFileSync(
|
|
41701
|
+
return import_node_fs18.default.readFileSync(import_node_path19.default.join(cwd, rel), "utf8");
|
|
41647
41702
|
} catch {
|
|
41648
41703
|
return "";
|
|
41649
41704
|
}
|
|
@@ -43423,7 +43478,7 @@ var AcpHistory = class {
|
|
|
43423
43478
|
this.summary = trimmed.length > 120 ? trimmed.slice(0, 117) + "\u2026" : trimmed;
|
|
43424
43479
|
}
|
|
43425
43480
|
this.messages.push({
|
|
43426
|
-
id: (0,
|
|
43481
|
+
id: (0, import_node_crypto13.randomUUID)(),
|
|
43427
43482
|
role: "user",
|
|
43428
43483
|
text,
|
|
43429
43484
|
timestamp: Date.now(),
|
|
@@ -43439,7 +43494,7 @@ var AcpHistory = class {
|
|
|
43439
43494
|
appendAgentReply(text, agentId = this.opts.agent) {
|
|
43440
43495
|
if (text.length === 0) return;
|
|
43441
43496
|
this.messages.push({
|
|
43442
|
-
id: (0,
|
|
43497
|
+
id: (0, import_node_crypto13.randomUUID)(),
|
|
43443
43498
|
role: "agent",
|
|
43444
43499
|
text,
|
|
43445
43500
|
timestamp: Date.now(),
|
|
@@ -43971,23 +44026,23 @@ async function runAcpSession(opts) {
|
|
|
43971
44026
|
switchCredentialEnv = provisionAgentCredentials(agentId, auth);
|
|
43972
44027
|
},
|
|
43973
44028
|
provisionHouseProxy: ({ baseUrl, token, model, managedAgentId }) => {
|
|
43974
|
-
const
|
|
43975
|
-
|
|
44029
|
+
const claudeConfigDir2 = path90.join(
|
|
44030
|
+
os57.homedir(),
|
|
43976
44031
|
".codeam",
|
|
43977
44032
|
"house-claude",
|
|
43978
44033
|
`switch-${opts.pluginId}`
|
|
43979
44034
|
);
|
|
43980
44035
|
try {
|
|
43981
|
-
|
|
44036
|
+
fs79.mkdirSync(claudeConfigDir2, { recursive: true, mode: 448 });
|
|
43982
44037
|
} catch {
|
|
43983
44038
|
}
|
|
43984
|
-
const memoryFile =
|
|
44039
|
+
const memoryFile = path90.join(claudeConfigDir2, "CLAUDE.md");
|
|
43985
44040
|
ensureBeadsWorkflowHint(void 0, memoryFile);
|
|
43986
44041
|
ensureAgentStandard(void 0, memoryFile);
|
|
43987
44042
|
const cfg = {
|
|
43988
44043
|
baseUrl,
|
|
43989
44044
|
token,
|
|
43990
|
-
claudeConfigDir,
|
|
44045
|
+
claudeConfigDir: claudeConfigDir2,
|
|
43991
44046
|
...model ? { model } : {},
|
|
43992
44047
|
...managedAgentId ? { managedAgentId } : {}
|
|
43993
44048
|
};
|
|
@@ -45197,7 +45252,7 @@ function startClaudeCredentialSync(opts) {
|
|
|
45197
45252
|
|
|
45198
45253
|
// src/scratch/workflow-hint.ts
|
|
45199
45254
|
var import_node_fs19 = __toESM(require("fs"));
|
|
45200
|
-
var
|
|
45255
|
+
var import_node_path20 = __toESM(require("path"));
|
|
45201
45256
|
var SCRATCH_HINT_MARKER = "<!-- codeam:scratch-workflow -->";
|
|
45202
45257
|
var SCRATCH_HINT = `${SCRATCH_HINT_MARKER}
|
|
45203
45258
|
# From-scratch projects (CodeAgent Box)
|
|
@@ -45221,7 +45276,7 @@ function ensureScratchWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2))
|
|
|
45221
45276
|
} catch {
|
|
45222
45277
|
}
|
|
45223
45278
|
if (existing.includes(SCRATCH_HINT)) return;
|
|
45224
|
-
import_node_fs19.default.mkdirSync(
|
|
45279
|
+
import_node_fs19.default.mkdirSync(import_node_path20.default.dirname(file), { recursive: true });
|
|
45225
45280
|
const open = existing.indexOf(SCRATCH_HINT_MARKER);
|
|
45226
45281
|
const close = open === -1 ? -1 : existing.indexOf(SCRATCH_HINT_MARKER, open + SCRATCH_HINT_MARKER.length);
|
|
45227
45282
|
const next = open !== -1 && close !== -1 ? existing.slice(0, open) + SCRATCH_HINT + existing.slice(close + SCRATCH_HINT_MARKER.length) : existing.trim() ? `${existing.trimEnd()}
|
|
@@ -45249,9 +45304,9 @@ function pickPinnedSession(pinnedId, listSessions2) {
|
|
|
45249
45304
|
}
|
|
45250
45305
|
|
|
45251
45306
|
// src/agents/retired-proxy-cleanup.ts
|
|
45252
|
-
var
|
|
45253
|
-
var
|
|
45254
|
-
var
|
|
45307
|
+
var fs81 = __toESM(require("fs"));
|
|
45308
|
+
var path92 = __toESM(require("path"));
|
|
45309
|
+
var os58 = __toESM(require("os"));
|
|
45255
45310
|
var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
|
|
45256
45311
|
var HEADROOM_CMD_RE = /(^|[\s/"'])headroom(\s|$)/i;
|
|
45257
45312
|
var MARKETPLACE_KEY = "headroom-marketplace";
|
|
@@ -45260,12 +45315,12 @@ function isHeadroomHook(group) {
|
|
|
45260
45315
|
(h) => typeof h?.command === "string" && HEADROOM_CMD_RE.test(h.command)
|
|
45261
45316
|
);
|
|
45262
45317
|
}
|
|
45263
|
-
function sanitizeRetiredProxyConfig(homeDir2 =
|
|
45318
|
+
function sanitizeRetiredProxyConfig(homeDir2 = os58.homedir()) {
|
|
45264
45319
|
const out2 = { inspected: false, changed: false, removed: [] };
|
|
45265
|
-
const file =
|
|
45320
|
+
const file = path92.join(homeDir2, ".claude", "settings.json");
|
|
45266
45321
|
let parsed;
|
|
45267
45322
|
try {
|
|
45268
|
-
parsed = JSON.parse(
|
|
45323
|
+
parsed = JSON.parse(fs81.readFileSync(file, "utf8"));
|
|
45269
45324
|
} catch {
|
|
45270
45325
|
return out2;
|
|
45271
45326
|
}
|
|
@@ -45307,9 +45362,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os59.homedir()) {
|
|
|
45307
45362
|
if (!out2.changed) return out2;
|
|
45308
45363
|
try {
|
|
45309
45364
|
const tmp = `${file}.codeam.tmp`;
|
|
45310
|
-
|
|
45365
|
+
fs81.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
|
|
45311
45366
|
`, { mode: 384 });
|
|
45312
|
-
|
|
45367
|
+
fs81.renameSync(tmp, file);
|
|
45313
45368
|
} catch {
|
|
45314
45369
|
out2.changed = false;
|
|
45315
45370
|
}
|
|
@@ -45365,8 +45420,8 @@ async function refreshIntegrationsManifest(ctx, fetchImpl = fetch, timeoutMs = 8
|
|
|
45365
45420
|
}
|
|
45366
45421
|
|
|
45367
45422
|
// src/skills/provision.ts
|
|
45368
|
-
var
|
|
45369
|
-
function provisionSkillsForStart(home =
|
|
45423
|
+
var import_node_os15 = __toESM(require("os"));
|
|
45424
|
+
function provisionSkillsForStart(home = import_node_os15.default.homedir()) {
|
|
45370
45425
|
const materialized = [];
|
|
45371
45426
|
try {
|
|
45372
45427
|
const manifest = readSkillsManifest();
|
|
@@ -45841,7 +45896,7 @@ var AcpDriver = class {
|
|
|
45841
45896
|
};
|
|
45842
45897
|
|
|
45843
45898
|
// src/baton/transcript-mirror.ts
|
|
45844
|
-
var
|
|
45899
|
+
var fs82 = __toESM(require("fs"));
|
|
45845
45900
|
var TranscriptMirror = class {
|
|
45846
45901
|
constructor(deps) {
|
|
45847
45902
|
this.deps = deps;
|
|
@@ -45935,7 +45990,7 @@ var TranscriptMirror = class {
|
|
|
45935
45990
|
}
|
|
45936
45991
|
};
|
|
45937
45992
|
function defaultWatch(file, onChange) {
|
|
45938
|
-
const w3 =
|
|
45993
|
+
const w3 = fs82.watch(file, { persistent: false }, () => onChange());
|
|
45939
45994
|
return () => w3.close();
|
|
45940
45995
|
}
|
|
45941
45996
|
|
|
@@ -46281,16 +46336,16 @@ function keepDeviceAwake(deps = {}) {
|
|
|
46281
46336
|
}
|
|
46282
46337
|
|
|
46283
46338
|
// src/agents/claude/onboarding.ts
|
|
46284
|
-
var
|
|
46285
|
-
var
|
|
46286
|
-
var
|
|
46339
|
+
var fs83 = __toESM(require("fs"));
|
|
46340
|
+
var os60 = __toESM(require("os"));
|
|
46341
|
+
var path93 = __toESM(require("path"));
|
|
46287
46342
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
46288
46343
|
function ensureClaudeOnboarded(cwd) {
|
|
46289
46344
|
try {
|
|
46290
|
-
const file =
|
|
46345
|
+
const file = path93.join(os60.homedir(), ".claude.json");
|
|
46291
46346
|
let config = {};
|
|
46292
46347
|
try {
|
|
46293
|
-
config = JSON.parse(
|
|
46348
|
+
config = JSON.parse(fs83.readFileSync(file, "utf8"));
|
|
46294
46349
|
} catch {
|
|
46295
46350
|
}
|
|
46296
46351
|
let changed = false;
|
|
@@ -46315,8 +46370,8 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
46315
46370
|
}
|
|
46316
46371
|
}
|
|
46317
46372
|
if (!changed) return;
|
|
46318
|
-
|
|
46319
|
-
|
|
46373
|
+
fs83.mkdirSync(path93.dirname(file), { recursive: true });
|
|
46374
|
+
fs83.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
46320
46375
|
log.info(
|
|
46321
46376
|
"claude",
|
|
46322
46377
|
`pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
|
|
@@ -46451,6 +46506,12 @@ async function start(requestedAgent, presetSession) {
|
|
|
46451
46506
|
pluginAuthToken: session.pluginAuthToken ?? void 0,
|
|
46452
46507
|
getRuntime: () => createInteractiveAgentStrategy(session.agent, createOsStrategy())
|
|
46453
46508
|
});
|
|
46509
|
+
if (session.pluginAuthToken) {
|
|
46510
|
+
const token = session.pluginAuthToken;
|
|
46511
|
+
setTimeout(() => {
|
|
46512
|
+
void restorePreviewAfterRestart({ sessionId: session.id, pluginId }, token);
|
|
46513
|
+
}, 5e3).unref();
|
|
46514
|
+
}
|
|
46454
46515
|
const mcpServers = mergeWithLocalMcpServers(
|
|
46455
46516
|
buildMcpServersForStart({
|
|
46456
46517
|
sessionId: session.id,
|
|
@@ -47102,7 +47163,7 @@ var import_picocolors10 = __toESM(require("picocolors"));
|
|
|
47102
47163
|
var import_child_process30 = require("child_process");
|
|
47103
47164
|
var import_util4 = require("util");
|
|
47104
47165
|
var import_picocolors8 = __toESM(require("picocolors"));
|
|
47105
|
-
var
|
|
47166
|
+
var path94 = __toESM(require("path"));
|
|
47106
47167
|
var execFileP6 = (0, import_util4.promisify)(import_child_process30.execFile);
|
|
47107
47168
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
47108
47169
|
function resetStdinForChild() {
|
|
@@ -47591,7 +47652,7 @@ var GitHubCodespacesProvider = class {
|
|
|
47591
47652
|
});
|
|
47592
47653
|
}
|
|
47593
47654
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
47594
|
-
const remoteDir =
|
|
47655
|
+
const remoteDir = path94.posix.dirname(remotePath);
|
|
47595
47656
|
const parts = [
|
|
47596
47657
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
47597
47658
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -47661,7 +47722,7 @@ function shellQuote(s) {
|
|
|
47661
47722
|
// src/services/providers/gitpod.ts
|
|
47662
47723
|
var import_child_process31 = require("child_process");
|
|
47663
47724
|
var import_util5 = require("util");
|
|
47664
|
-
var
|
|
47725
|
+
var path95 = __toESM(require("path"));
|
|
47665
47726
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
47666
47727
|
var execFileP7 = (0, import_util5.promisify)(import_child_process31.execFile);
|
|
47667
47728
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
@@ -47901,7 +47962,7 @@ var GitpodProvider = class {
|
|
|
47901
47962
|
});
|
|
47902
47963
|
}
|
|
47903
47964
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
47904
|
-
const remoteDir =
|
|
47965
|
+
const remoteDir = path95.posix.dirname(remotePath);
|
|
47905
47966
|
const parts = [
|
|
47906
47967
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
47907
47968
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -47937,7 +47998,7 @@ function shellQuote2(s) {
|
|
|
47937
47998
|
// src/services/providers/gitlab-workspaces.ts
|
|
47938
47999
|
var import_child_process32 = require("child_process");
|
|
47939
48000
|
var import_util6 = require("util");
|
|
47940
|
-
var
|
|
48001
|
+
var path96 = __toESM(require("path"));
|
|
47941
48002
|
var execFileP8 = (0, import_util6.promisify)(import_child_process32.execFile);
|
|
47942
48003
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
47943
48004
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
@@ -48197,7 +48258,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
48197
48258
|
}
|
|
48198
48259
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
48199
48260
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
48200
|
-
const remoteDir =
|
|
48261
|
+
const remoteDir = path96.posix.dirname(remotePath);
|
|
48201
48262
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
48202
48263
|
if (options.mode != null) {
|
|
48203
48264
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
@@ -48265,7 +48326,7 @@ function shellQuote3(s) {
|
|
|
48265
48326
|
// src/services/providers/railway.ts
|
|
48266
48327
|
var import_child_process33 = require("child_process");
|
|
48267
48328
|
var import_util7 = require("util");
|
|
48268
|
-
var
|
|
48329
|
+
var path97 = __toESM(require("path"));
|
|
48269
48330
|
var execFileP9 = (0, import_util7.promisify)(import_child_process33.execFile);
|
|
48270
48331
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
48271
48332
|
function resetStdinForChild4() {
|
|
@@ -48501,7 +48562,7 @@ var RailwayProvider = class {
|
|
|
48501
48562
|
if (!projectId || !serviceId) {
|
|
48502
48563
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
48503
48564
|
}
|
|
48504
|
-
const remoteDir =
|
|
48565
|
+
const remoteDir = path97.posix.dirname(remotePath);
|
|
48505
48566
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
48506
48567
|
if (options.mode != null) {
|
|
48507
48568
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
@@ -49041,14 +49102,14 @@ async function stopWorkspaceFromLocal(target) {
|
|
|
49041
49102
|
}
|
|
49042
49103
|
|
|
49043
49104
|
// src/commands/host/host-client.ts
|
|
49044
|
-
var
|
|
49045
|
-
var
|
|
49046
|
-
var
|
|
49047
|
-
var
|
|
49105
|
+
var fs84 = __toESM(require("fs"));
|
|
49106
|
+
var os61 = __toESM(require("os"));
|
|
49107
|
+
var path98 = __toESM(require("path"));
|
|
49108
|
+
var import_node_crypto14 = require("crypto");
|
|
49048
49109
|
function sampleCpuTimes() {
|
|
49049
49110
|
let idle = 0;
|
|
49050
49111
|
let total = 0;
|
|
49051
|
-
for (const cpu of
|
|
49112
|
+
for (const cpu of os61.cpus()) {
|
|
49052
49113
|
const t2 = cpu.times;
|
|
49053
49114
|
idle += t2.idle;
|
|
49054
49115
|
total += t2.user + t2.nice + t2.sys + t2.idle + t2.irq;
|
|
@@ -49068,8 +49129,8 @@ var MetricsCollector = class {
|
|
|
49068
49129
|
const prev = this.prevCpu;
|
|
49069
49130
|
this.prevCpu = current2;
|
|
49070
49131
|
if (!prev) {
|
|
49071
|
-
const cores =
|
|
49072
|
-
const proxy =
|
|
49132
|
+
const cores = os61.cpus().length || 1;
|
|
49133
|
+
const proxy = os61.loadavg()[0] / cores * 100;
|
|
49073
49134
|
return Math.min(100, Math.max(0, Math.round(proxy)));
|
|
49074
49135
|
}
|
|
49075
49136
|
const idleDelta = current2.idle - prev.idle;
|
|
@@ -49082,8 +49143,8 @@ var MetricsCollector = class {
|
|
|
49082
49143
|
collect() {
|
|
49083
49144
|
return {
|
|
49084
49145
|
cpuPct: this.cpuPct(),
|
|
49085
|
-
ramUsedMb: Math.round((
|
|
49086
|
-
ramTotalMb: Math.round(
|
|
49146
|
+
ramUsedMb: Math.round((os61.totalmem() - os61.freemem()) / 1048576),
|
|
49147
|
+
ramTotalMb: Math.round(os61.totalmem() / 1048576),
|
|
49087
49148
|
latencyMs: this.lastLatencyMs
|
|
49088
49149
|
};
|
|
49089
49150
|
}
|
|
@@ -49092,19 +49153,19 @@ function apiBase() {
|
|
|
49092
49153
|
return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
|
|
49093
49154
|
}
|
|
49094
49155
|
function hostIdentityPath() {
|
|
49095
|
-
return
|
|
49156
|
+
return path98.join(os61.homedir(), ".codeam", "host-agent.json");
|
|
49096
49157
|
}
|
|
49097
49158
|
function collectOsInfo() {
|
|
49098
49159
|
return {
|
|
49099
|
-
distro:
|
|
49100
|
-
arch:
|
|
49101
|
-
kernel:
|
|
49160
|
+
distro: os61.platform(),
|
|
49161
|
+
arch: os61.arch(),
|
|
49162
|
+
kernel: os61.release(),
|
|
49102
49163
|
nodeVersion: process.versions.node
|
|
49103
49164
|
};
|
|
49104
49165
|
}
|
|
49105
49166
|
function loadHostIdentity() {
|
|
49106
49167
|
try {
|
|
49107
|
-
const raw =
|
|
49168
|
+
const raw = fs84.readFileSync(hostIdentityPath(), "utf8");
|
|
49108
49169
|
const parsed = JSON.parse(raw);
|
|
49109
49170
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
49110
49171
|
const p2 = parsed;
|
|
@@ -49122,18 +49183,18 @@ function loadHostIdentity() {
|
|
|
49122
49183
|
}
|
|
49123
49184
|
}
|
|
49124
49185
|
function pollSecretHash(secret) {
|
|
49125
|
-
return (0,
|
|
49186
|
+
return (0, import_node_crypto14.createHash)("sha256").update(secret).digest("hex");
|
|
49126
49187
|
}
|
|
49127
49188
|
function ensureControlPollSecret(identity, save = saveHostIdentity) {
|
|
49128
49189
|
if (!identity || identity.controlPollSecret) return identity;
|
|
49129
|
-
const upgraded = { ...identity, controlPollSecret: (0,
|
|
49190
|
+
const upgraded = { ...identity, controlPollSecret: (0, import_node_crypto14.randomBytes)(32).toString("base64url") };
|
|
49130
49191
|
save(upgraded);
|
|
49131
49192
|
return upgraded;
|
|
49132
49193
|
}
|
|
49133
49194
|
function saveHostIdentity(identity) {
|
|
49134
49195
|
const file = hostIdentityPath();
|
|
49135
|
-
|
|
49136
|
-
|
|
49196
|
+
fs84.mkdirSync(path98.dirname(file), { recursive: true, mode: 448 });
|
|
49197
|
+
fs84.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
49137
49198
|
encoding: "utf8",
|
|
49138
49199
|
mode: 384
|
|
49139
49200
|
});
|
|
@@ -49178,7 +49239,7 @@ function isTerminalEnrollError(err) {
|
|
|
49178
49239
|
}
|
|
49179
49240
|
function deleteHostIdentity() {
|
|
49180
49241
|
try {
|
|
49181
|
-
|
|
49242
|
+
fs84.rmSync(hostIdentityPath(), { force: true });
|
|
49182
49243
|
} catch {
|
|
49183
49244
|
}
|
|
49184
49245
|
}
|
|
@@ -49202,12 +49263,12 @@ async function postJson(pathname, body) {
|
|
|
49202
49263
|
function resolveHostLabel(label) {
|
|
49203
49264
|
const explicit = label?.trim();
|
|
49204
49265
|
const envLabel = process.env.CODEAM_HOST_LABEL?.trim();
|
|
49205
|
-
const resolved = explicit || envLabel ||
|
|
49266
|
+
const resolved = explicit || envLabel || os61.hostname();
|
|
49206
49267
|
return resolved.slice(0, 80);
|
|
49207
49268
|
}
|
|
49208
49269
|
async function redeemEnrollToken(token, label) {
|
|
49209
|
-
const controlPollSecret = (0,
|
|
49210
|
-
const pluginSecretHash = (0,
|
|
49270
|
+
const controlPollSecret = (0, import_node_crypto14.randomBytes)(32).toString("base64url");
|
|
49271
|
+
const pluginSecretHash = (0, import_node_crypto14.createHash)("sha256").update(controlPollSecret).digest("hex");
|
|
49211
49272
|
const data = await postJson("/api/self-hosted/redeem", {
|
|
49212
49273
|
token,
|
|
49213
49274
|
label: resolveHostLabel(label),
|
|
@@ -49395,9 +49456,9 @@ async function host(args2) {
|
|
|
49395
49456
|
|
|
49396
49457
|
// src/commands/host-agent.ts
|
|
49397
49458
|
var import_node_child_process35 = require("child_process");
|
|
49398
|
-
var
|
|
49399
|
-
var
|
|
49400
|
-
var
|
|
49459
|
+
var os65 = __toESM(require("os"));
|
|
49460
|
+
var fs88 = __toESM(require("fs"));
|
|
49461
|
+
var path102 = __toESM(require("path"));
|
|
49401
49462
|
|
|
49402
49463
|
// src/skills/persist-from-payload.ts
|
|
49403
49464
|
function persistOrClearSkillsFromPayload(skills) {
|
|
@@ -49406,13 +49467,13 @@ function persistOrClearSkillsFromPayload(skills) {
|
|
|
49406
49467
|
}
|
|
49407
49468
|
|
|
49408
49469
|
// src/commands/host/session-state.ts
|
|
49409
|
-
var
|
|
49410
|
-
var
|
|
49411
|
-
var
|
|
49470
|
+
var fs85 = __toESM(require("fs"));
|
|
49471
|
+
var os62 = __toESM(require("os"));
|
|
49472
|
+
var path99 = __toESM(require("path"));
|
|
49412
49473
|
function hostSessionStatePath(env = process.env) {
|
|
49413
49474
|
const override = env.CODEAM_HOST_SESSION_STATE_FILE;
|
|
49414
49475
|
if (override && override.trim()) return override.trim();
|
|
49415
|
-
return
|
|
49476
|
+
return path99.join(os62.homedir(), ".codeam", "host-agent-sessions.json");
|
|
49416
49477
|
}
|
|
49417
49478
|
function isRecord5(v) {
|
|
49418
49479
|
if (typeof v !== "object" || v === null) return false;
|
|
@@ -49423,7 +49484,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
49423
49484
|
return {
|
|
49424
49485
|
load() {
|
|
49425
49486
|
try {
|
|
49426
|
-
const raw = JSON.parse(
|
|
49487
|
+
const raw = JSON.parse(fs85.readFileSync(file, "utf8"));
|
|
49427
49488
|
return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord5) : null;
|
|
49428
49489
|
} catch {
|
|
49429
49490
|
return null;
|
|
@@ -49431,18 +49492,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
49431
49492
|
},
|
|
49432
49493
|
save(list) {
|
|
49433
49494
|
try {
|
|
49434
|
-
|
|
49495
|
+
fs85.mkdirSync(path99.dirname(file), { recursive: true, mode: 448 });
|
|
49435
49496
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
49436
|
-
|
|
49497
|
+
fs85.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
|
|
49437
49498
|
mode: 384
|
|
49438
49499
|
});
|
|
49439
|
-
|
|
49500
|
+
fs85.renameSync(tmp, file);
|
|
49440
49501
|
} catch {
|
|
49441
49502
|
}
|
|
49442
49503
|
},
|
|
49443
49504
|
clear() {
|
|
49444
49505
|
try {
|
|
49445
|
-
|
|
49506
|
+
fs85.rmSync(file, { force: true });
|
|
49446
49507
|
} catch {
|
|
49447
49508
|
}
|
|
49448
49509
|
}
|
|
@@ -49465,10 +49526,10 @@ function planSessionResume(records, max) {
|
|
|
49465
49526
|
return { resume: ordered.slice(0, bound), dropped: ordered.slice(bound) };
|
|
49466
49527
|
}
|
|
49467
49528
|
function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
49468
|
-
const target =
|
|
49529
|
+
const target = path99.resolve(cwd);
|
|
49469
49530
|
const reconnectable = (s) => !!s.pluginId && !!s.pollSecret && !!s.agent;
|
|
49470
49531
|
const matches = sessions3.filter(
|
|
49471
|
-
(s) => !!s.cwd &&
|
|
49532
|
+
(s) => !!s.cwd && path99.resolve(s.cwd) === target && reconnectable(s)
|
|
49472
49533
|
);
|
|
49473
49534
|
if (matches.length > 0) {
|
|
49474
49535
|
matches.sort((a, b) => b.pairedAt - a.pairedAt);
|
|
@@ -49480,11 +49541,11 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
|
49480
49541
|
|
|
49481
49542
|
// src/commands/host/git-tooling.ts
|
|
49482
49543
|
var import_node_child_process31 = require("child_process");
|
|
49483
|
-
var
|
|
49484
|
-
var
|
|
49485
|
-
var
|
|
49544
|
+
var fs86 = __toESM(require("fs"));
|
|
49545
|
+
var os63 = __toESM(require("os"));
|
|
49546
|
+
var path100 = __toESM(require("path"));
|
|
49486
49547
|
function codeamBinDir() {
|
|
49487
|
-
return process.env.CODEAM_BIN_DIR ??
|
|
49548
|
+
return process.env.CODEAM_BIN_DIR ?? path100.join(os63.homedir(), ".codeam", "bin");
|
|
49488
49549
|
}
|
|
49489
49550
|
var FALLBACK_GH_VERSION = "2.62.0";
|
|
49490
49551
|
var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
|
|
@@ -49516,7 +49577,7 @@ async function download(url2, dest) {
|
|
|
49516
49577
|
const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
|
|
49517
49578
|
if (!res.ok || !res.body) return false;
|
|
49518
49579
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
49519
|
-
|
|
49580
|
+
fs86.writeFileSync(dest, buf);
|
|
49520
49581
|
return true;
|
|
49521
49582
|
} catch {
|
|
49522
49583
|
return false;
|
|
@@ -49539,8 +49600,8 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
49539
49600
|
const version3 = await resolveVersionFn(token);
|
|
49540
49601
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
49541
49602
|
const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
49542
|
-
const tmpRoot =
|
|
49543
|
-
const archive =
|
|
49603
|
+
const tmpRoot = fs86.mkdtempSync(path100.join(os63.tmpdir(), "codeam-gh-"));
|
|
49604
|
+
const archive = path100.join(tmpRoot, `${asset}.${ext}`);
|
|
49544
49605
|
if (!await downloadFn(url2, archive)) {
|
|
49545
49606
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
49546
49607
|
return null;
|
|
@@ -49550,16 +49611,16 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
49550
49611
|
log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
|
|
49551
49612
|
return null;
|
|
49552
49613
|
}
|
|
49553
|
-
const extractedBin =
|
|
49554
|
-
if (!
|
|
49614
|
+
const extractedBin = path100.join(tmpRoot, asset, "bin", binaryName);
|
|
49615
|
+
if (!fs86.existsSync(extractedBin)) {
|
|
49555
49616
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
49556
49617
|
return null;
|
|
49557
49618
|
}
|
|
49558
49619
|
const binDir = codeamBinDir();
|
|
49559
|
-
|
|
49560
|
-
const target =
|
|
49561
|
-
|
|
49562
|
-
|
|
49620
|
+
fs86.mkdirSync(binDir, { recursive: true });
|
|
49621
|
+
const target = path100.join(binDir, binaryName);
|
|
49622
|
+
fs86.copyFileSync(extractedBin, target);
|
|
49623
|
+
fs86.chmodSync(target, 493);
|
|
49563
49624
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
49564
49625
|
return target;
|
|
49565
49626
|
} catch (e) {
|
|
@@ -49596,19 +49657,19 @@ async function ensureGhAuth(runner, ghCmd, token) {
|
|
|
49596
49657
|
}
|
|
49597
49658
|
function ghConfigDir() {
|
|
49598
49659
|
if (process.env.GH_CONFIG_DIR) return process.env.GH_CONFIG_DIR;
|
|
49599
|
-
if (process.env.XDG_CONFIG_HOME) return
|
|
49660
|
+
if (process.env.XDG_CONFIG_HOME) return path100.join(process.env.XDG_CONFIG_HOME, "gh");
|
|
49600
49661
|
if (process.platform === "win32" && process.env.APPDATA) {
|
|
49601
|
-
return
|
|
49662
|
+
return path100.join(process.env.APPDATA, "GitHub CLI");
|
|
49602
49663
|
}
|
|
49603
|
-
return
|
|
49664
|
+
return path100.join(os63.homedir(), ".config", "gh");
|
|
49604
49665
|
}
|
|
49605
49666
|
function writeGhHostsToken(token) {
|
|
49606
49667
|
try {
|
|
49607
49668
|
const dir = ghConfigDir();
|
|
49608
|
-
const file =
|
|
49609
|
-
if (
|
|
49610
|
-
|
|
49611
|
-
|
|
49669
|
+
const file = path100.join(dir, "hosts.yml");
|
|
49670
|
+
if (fs86.existsSync(file)) return false;
|
|
49671
|
+
fs86.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
49672
|
+
fs86.writeFileSync(
|
|
49612
49673
|
file,
|
|
49613
49674
|
`github.com:
|
|
49614
49675
|
oauth_token: ${token}
|
|
@@ -49651,8 +49712,8 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
49651
49712
|
const version3 = await resolveLatestGlabVersion();
|
|
49652
49713
|
const asset = `glab_${version3}_${osToken}_${arch2}`;
|
|
49653
49714
|
const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
|
|
49654
|
-
const tmpRoot =
|
|
49655
|
-
const archive =
|
|
49715
|
+
const tmpRoot = fs86.mkdtempSync(path100.join(os63.tmpdir(), "codeam-glab-"));
|
|
49716
|
+
const archive = path100.join(tmpRoot, `${asset}.${ext}`);
|
|
49656
49717
|
if (!await downloadFn(url2, archive)) {
|
|
49657
49718
|
log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
|
|
49658
49719
|
return null;
|
|
@@ -49663,20 +49724,20 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
49663
49724
|
return null;
|
|
49664
49725
|
}
|
|
49665
49726
|
const candidates = [
|
|
49666
|
-
|
|
49667
|
-
|
|
49668
|
-
|
|
49727
|
+
path100.join(tmpRoot, "bin", binaryName),
|
|
49728
|
+
path100.join(tmpRoot, asset, "bin", binaryName),
|
|
49729
|
+
path100.join(tmpRoot, binaryName)
|
|
49669
49730
|
];
|
|
49670
|
-
const extractedBin = candidates.find((c2) =>
|
|
49731
|
+
const extractedBin = candidates.find((c2) => fs86.existsSync(c2));
|
|
49671
49732
|
if (!extractedBin) {
|
|
49672
49733
|
log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
|
|
49673
49734
|
return null;
|
|
49674
49735
|
}
|
|
49675
49736
|
const binDir = codeamBinDir();
|
|
49676
|
-
|
|
49677
|
-
const target =
|
|
49678
|
-
|
|
49679
|
-
|
|
49737
|
+
fs86.mkdirSync(binDir, { recursive: true });
|
|
49738
|
+
const target = path100.join(binDir, binaryName);
|
|
49739
|
+
fs86.copyFileSync(extractedBin, target);
|
|
49740
|
+
fs86.chmodSync(target, 493);
|
|
49680
49741
|
log.info("host-agent", `glab installed to ${target} (v${version3})`);
|
|
49681
49742
|
return target;
|
|
49682
49743
|
} catch (e) {
|
|
@@ -49758,9 +49819,9 @@ var defaultGitToolingRunner = {
|
|
|
49758
49819
|
var import_node_child_process33 = require("child_process");
|
|
49759
49820
|
|
|
49760
49821
|
// src/lib/updateNotifier.ts
|
|
49761
|
-
var
|
|
49762
|
-
var
|
|
49763
|
-
var
|
|
49822
|
+
var fs87 = __toESM(require("fs"));
|
|
49823
|
+
var os64 = __toESM(require("os"));
|
|
49824
|
+
var path101 = __toESM(require("path"));
|
|
49764
49825
|
var https8 = __toESM(require("https"));
|
|
49765
49826
|
var import_node_child_process32 = require("child_process");
|
|
49766
49827
|
var import_picocolors12 = __toESM(require("picocolors"));
|
|
@@ -49769,12 +49830,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
|
49769
49830
|
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
49770
49831
|
var REQUEST_TIMEOUT_MS = 1500;
|
|
49771
49832
|
function cachePath() {
|
|
49772
|
-
const dir =
|
|
49773
|
-
return
|
|
49833
|
+
const dir = path101.join(os64.homedir(), ".codeam");
|
|
49834
|
+
return path101.join(dir, "update-check.json");
|
|
49774
49835
|
}
|
|
49775
49836
|
function readCache() {
|
|
49776
49837
|
try {
|
|
49777
|
-
const raw =
|
|
49838
|
+
const raw = fs87.readFileSync(cachePath(), "utf8");
|
|
49778
49839
|
const parsed = JSON.parse(raw);
|
|
49779
49840
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
49780
49841
|
return parsed;
|
|
@@ -49785,10 +49846,10 @@ function readCache() {
|
|
|
49785
49846
|
function writeCache(cache) {
|
|
49786
49847
|
try {
|
|
49787
49848
|
const file = cachePath();
|
|
49788
|
-
|
|
49849
|
+
fs87.mkdirSync(path101.dirname(file), { recursive: true });
|
|
49789
49850
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
49790
|
-
|
|
49791
|
-
|
|
49851
|
+
fs87.writeFileSync(tmp, JSON.stringify(cache));
|
|
49852
|
+
fs87.renameSync(tmp, file);
|
|
49792
49853
|
} catch {
|
|
49793
49854
|
}
|
|
49794
49855
|
}
|
|
@@ -49862,8 +49923,8 @@ function isLinkedInstall() {
|
|
|
49862
49923
|
timeout: 2e3
|
|
49863
49924
|
}).trim();
|
|
49864
49925
|
if (!root) return false;
|
|
49865
|
-
const pkgPath =
|
|
49866
|
-
return
|
|
49926
|
+
const pkgPath = path101.join(root, PKG_NAME);
|
|
49927
|
+
return fs87.lstatSync(pkgPath).isSymbolicLink();
|
|
49867
49928
|
} catch {
|
|
49868
49929
|
return false;
|
|
49869
49930
|
}
|
|
@@ -49899,7 +49960,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
49899
49960
|
return;
|
|
49900
49961
|
}
|
|
49901
49962
|
try {
|
|
49902
|
-
|
|
49963
|
+
fs87.unlinkSync(cachePath());
|
|
49903
49964
|
} catch {
|
|
49904
49965
|
}
|
|
49905
49966
|
process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -49915,7 +49976,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
49915
49976
|
if (process.env.NODE_ENV === "test") return;
|
|
49916
49977
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
49917
49978
|
if (process.env.CI) return;
|
|
49918
|
-
const current2 = true ? "2.76.
|
|
49979
|
+
const current2 = true ? "2.76.3" : null;
|
|
49919
49980
|
if (!current2) return;
|
|
49920
49981
|
const cache = readCache();
|
|
49921
49982
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -49932,7 +49993,7 @@ function checkForUpdates() {
|
|
|
49932
49993
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
49933
49994
|
if (process.env.CI) return;
|
|
49934
49995
|
if (!process.stdout.isTTY) return;
|
|
49935
|
-
const current2 = true ? "2.76.
|
|
49996
|
+
const current2 = true ? "2.76.3" : null;
|
|
49936
49997
|
if (!current2) return;
|
|
49937
49998
|
const cache = readCache();
|
|
49938
49999
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -49955,7 +50016,7 @@ var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
|
49955
50016
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
49956
50017
|
var SUDO_PREFLIGHT_TIMEOUT_MS = 5e3;
|
|
49957
50018
|
function currentCliVersion() {
|
|
49958
|
-
return true ? "2.76.
|
|
50019
|
+
return true ? "2.76.3" : null;
|
|
49959
50020
|
}
|
|
49960
50021
|
async function installedVersion(deps) {
|
|
49961
50022
|
const ls = await deps.run(
|
|
@@ -50308,7 +50369,7 @@ var ORPHAN_KILL_SETTLE_MS = 500;
|
|
|
50308
50369
|
function needsSelfRelaunch(env = process.env, pid = process.pid) {
|
|
50309
50370
|
return !env.INVOCATION_ID && pid !== 1;
|
|
50310
50371
|
}
|
|
50311
|
-
function isContainerEnvironment(existsSyncFn =
|
|
50372
|
+
function isContainerEnvironment(existsSyncFn = fs88.existsSync, readFileSyncFn = (p2) => fs88.readFileSync(p2, "utf8")) {
|
|
50312
50373
|
try {
|
|
50313
50374
|
if (existsSyncFn("/.dockerenv")) return true;
|
|
50314
50375
|
} catch {
|
|
@@ -50773,13 +50834,13 @@ var HostAgentSupervisor = class {
|
|
|
50773
50834
|
const relay = this.relay;
|
|
50774
50835
|
if (!relay) return;
|
|
50775
50836
|
const raw = cmd.payload?.path;
|
|
50776
|
-
const target = typeof raw === "string" && raw.trim() ?
|
|
50837
|
+
const target = typeof raw === "string" && raw.trim() ? path102.resolve(raw.trim()) : os65.homedir();
|
|
50777
50838
|
try {
|
|
50778
|
-
const dirents = await
|
|
50839
|
+
const dirents = await fs88.promises.readdir(target, { withFileTypes: true });
|
|
50779
50840
|
const entries2 = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
50780
50841
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
50781
50842
|
);
|
|
50782
|
-
const parent =
|
|
50843
|
+
const parent = path102.dirname(target);
|
|
50783
50844
|
await relay.sendResult(cmd.id, "completed", {
|
|
50784
50845
|
path: target,
|
|
50785
50846
|
// null at the filesystem root so the UI can hide the ".." affordance.
|
|
@@ -51127,14 +51188,14 @@ var HostAgentSupervisor = class {
|
|
|
51127
51188
|
...buildHouseProxyChildEnv({ baseUrl, token, openRouter: openRouter === true }),
|
|
51128
51189
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
51129
51190
|
};
|
|
51130
|
-
const houseConfigDir =
|
|
51131
|
-
|
|
51191
|
+
const houseConfigDir = path102.join(
|
|
51192
|
+
os65.homedir(),
|
|
51132
51193
|
".codeam",
|
|
51133
51194
|
"house-claude",
|
|
51134
51195
|
payload.deployId
|
|
51135
51196
|
);
|
|
51136
51197
|
try {
|
|
51137
|
-
|
|
51198
|
+
fs88.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
51138
51199
|
} catch {
|
|
51139
51200
|
}
|
|
51140
51201
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -51160,7 +51221,7 @@ var HostAgentSupervisor = class {
|
|
|
51160
51221
|
report("installing", "installing agent CLI");
|
|
51161
51222
|
await this.runAgentInstall(payload.agentInstallScript);
|
|
51162
51223
|
}
|
|
51163
|
-
const home = process.env.HOME ||
|
|
51224
|
+
const home = process.env.HOME || os65.homedir();
|
|
51164
51225
|
childEnv.PATH = `${home}/.local/bin:${process.env.PATH ?? ""}`;
|
|
51165
51226
|
if (payload.cloneToken) {
|
|
51166
51227
|
try {
|
|
@@ -51168,13 +51229,13 @@ var HostAgentSupervisor = class {
|
|
|
51168
51229
|
if ((payload.repoProvider ?? "github") === "gitlab") {
|
|
51169
51230
|
const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
|
|
51170
51231
|
if (glabCmd) {
|
|
51171
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
51232
|
+
childEnv.PATH = `${codeamBinDir()}${path102.delimiter}${childEnv.PATH}`;
|
|
51172
51233
|
await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
|
|
51173
51234
|
}
|
|
51174
51235
|
} else {
|
|
51175
51236
|
const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
|
|
51176
51237
|
if (ghCmd) {
|
|
51177
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
51238
|
+
childEnv.PATH = `${codeamBinDir()}${path102.delimiter}${childEnv.PATH}`;
|
|
51178
51239
|
await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
|
|
51179
51240
|
}
|
|
51180
51241
|
}
|
|
@@ -51202,9 +51263,9 @@ var HostAgentSupervisor = class {
|
|
|
51202
51263
|
);
|
|
51203
51264
|
if (!payload.suppressOnboardingWelcome) {
|
|
51204
51265
|
try {
|
|
51205
|
-
const cfgDir = childEnv.CLAUDE_CONFIG_DIR ||
|
|
51206
|
-
const projectDir =
|
|
51207
|
-
const hasPriorConversation =
|
|
51266
|
+
const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path102.join(os65.homedir(), ".claude");
|
|
51267
|
+
const projectDir = path102.join(cfgDir, "projects", encodeCwd(cwd));
|
|
51268
|
+
const hasPriorConversation = fs88.existsSync(projectDir) && fs88.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
|
|
51208
51269
|
if (hasPriorConversation) {
|
|
51209
51270
|
childEnv.CODEAM_RESUME_LATEST = "1";
|
|
51210
51271
|
log.info(
|
|
@@ -51358,7 +51419,7 @@ var HostAgentSupervisor = class {
|
|
|
51358
51419
|
fallbackResumeTarget() {
|
|
51359
51420
|
const session = getActiveSession();
|
|
51360
51421
|
if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
|
|
51361
|
-
const cwd = session.cwd &&
|
|
51422
|
+
const cwd = session.cwd && fs88.existsSync(session.cwd) ? session.cwd : process.cwd();
|
|
51362
51423
|
if (isFilesystemRoot(cwd)) {
|
|
51363
51424
|
log.warn(
|
|
51364
51425
|
"host-agent",
|
|
@@ -51398,7 +51459,7 @@ var HostAgentSupervisor = class {
|
|
|
51398
51459
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
|
|
51399
51460
|
return;
|
|
51400
51461
|
}
|
|
51401
|
-
if (!session.cwd || !
|
|
51462
|
+
if (!session.cwd || !fs88.existsSync(session.cwd)) {
|
|
51402
51463
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
|
|
51403
51464
|
return;
|
|
51404
51465
|
}
|
|
@@ -51440,7 +51501,7 @@ var HostAgentSupervisor = class {
|
|
|
51440
51501
|
const persisted = new Map((this.sessionStore.load() ?? []).map((r) => [r.deployId, r.agent]));
|
|
51441
51502
|
for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
|
|
51442
51503
|
return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
|
|
51443
|
-
(x) => x.deployId !== null && !!x.s.cwd &&
|
|
51504
|
+
(x) => x.deployId !== null && !!x.s.cwd && fs88.existsSync(x.s.cwd)
|
|
51444
51505
|
).map(({ s, deployId }) => {
|
|
51445
51506
|
const agent = persisted.get(deployId);
|
|
51446
51507
|
return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
|
|
@@ -51492,7 +51553,7 @@ var HostAgentSupervisor = class {
|
|
|
51492
51553
|
if (this.children.has(deployId)) return;
|
|
51493
51554
|
const st3 = this.resumeStateFor(target);
|
|
51494
51555
|
try {
|
|
51495
|
-
const cwd =
|
|
51556
|
+
const cwd = fs88.existsSync(target.cwd) ? target.cwd : process.cwd();
|
|
51496
51557
|
const proc = this.resumeSpawner(
|
|
51497
51558
|
{ ...readHouseProxyChildEnv(deployId), CODEAM_RESUME_SESSION_ID: session.id },
|
|
51498
51559
|
cwd
|
|
@@ -51519,7 +51580,7 @@ var HostAgentSupervisor = class {
|
|
|
51519
51580
|
return;
|
|
51520
51581
|
}
|
|
51521
51582
|
if (tracked && signal) {
|
|
51522
|
-
this.onResumeChildExit(target, 128 + (
|
|
51583
|
+
this.onResumeChildExit(target, 128 + (os65.constants.signals[signal] ?? 9), `signal ${signal}`);
|
|
51523
51584
|
return;
|
|
51524
51585
|
}
|
|
51525
51586
|
log.warn(
|
|
@@ -51562,7 +51623,7 @@ var HostAgentSupervisor = class {
|
|
|
51562
51623
|
if (Date.now() - child.startedAt < CRASH_RESPAWN_MIN_UPTIME_MS) return false;
|
|
51563
51624
|
const session = pickSavedSessionForWorkspace(this.listSavedSessions(), child.cwd);
|
|
51564
51625
|
if (!session) return false;
|
|
51565
|
-
const exitCode = typeof code === "number" ? code : 128 + (signal ?
|
|
51626
|
+
const exitCode = typeof code === "number" ? code : 128 + (signal ? os65.constants.signals[signal] ?? 9 : 9);
|
|
51566
51627
|
log.warn(
|
|
51567
51628
|
"host-agent",
|
|
51568
51629
|
`session deploy=${child.deployId.slice(0, 8)} died (${signal ?? code}) after ${Math.round((Date.now() - child.startedAt) / 1e3)}s \u2014 respawning it (resume)`
|
|
@@ -51711,12 +51772,12 @@ var HostAgentSupervisor = class {
|
|
|
51711
51772
|
this.untrackChild(deployId);
|
|
51712
51773
|
}
|
|
51713
51774
|
const dirs = [
|
|
51714
|
-
|
|
51715
|
-
|
|
51775
|
+
path102.join(selfHostedWorkspaceRoot(), deployId),
|
|
51776
|
+
path102.join(os65.homedir(), ".codeam", "house-claude", deployId)
|
|
51716
51777
|
];
|
|
51717
51778
|
for (const dir of dirs) {
|
|
51718
51779
|
try {
|
|
51719
|
-
|
|
51780
|
+
fs88.rmSync(dir, { recursive: true, force: true });
|
|
51720
51781
|
} catch (err) {
|
|
51721
51782
|
log.warn(
|
|
51722
51783
|
"host-agent",
|
|
@@ -51875,9 +51936,9 @@ async function invite() {
|
|
|
51875
51936
|
// src/commands/doctor.ts
|
|
51876
51937
|
var import_node_dns = require("dns");
|
|
51877
51938
|
var import_node_util11 = require("util");
|
|
51878
|
-
var
|
|
51879
|
-
var
|
|
51880
|
-
var
|
|
51939
|
+
var import_node_crypto15 = require("crypto");
|
|
51940
|
+
var fs89 = __toESM(require("fs"));
|
|
51941
|
+
var path103 = __toESM(require("path"));
|
|
51881
51942
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
51882
51943
|
var dnsResolveP = (0, import_node_util11.promisify)(import_node_dns.resolve);
|
|
51883
51944
|
async function checkDns(apiBase2) {
|
|
@@ -51933,13 +51994,13 @@ async function checkHealth(apiBase2) {
|
|
|
51933
51994
|
}
|
|
51934
51995
|
}
|
|
51935
51996
|
function checkConfigDir() {
|
|
51936
|
-
const dir =
|
|
51997
|
+
const dir = path103.join(require("os").homedir(), ".codeam");
|
|
51937
51998
|
try {
|
|
51938
|
-
|
|
51939
|
-
const probe =
|
|
51940
|
-
|
|
51941
|
-
const read =
|
|
51942
|
-
|
|
51999
|
+
fs89.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
52000
|
+
const probe = path103.join(dir, ".doctor-probe");
|
|
52001
|
+
fs89.writeFileSync(probe, "ok", { mode: 384 });
|
|
52002
|
+
const read = fs89.readFileSync(probe, "utf8");
|
|
52003
|
+
fs89.unlinkSync(probe);
|
|
51943
52004
|
if (read !== "ok") throw new Error("write/read round-trip mismatch");
|
|
51944
52005
|
return {
|
|
51945
52006
|
id: "config-dir",
|
|
@@ -51979,9 +52040,9 @@ function checkSessions() {
|
|
|
51979
52040
|
}
|
|
51980
52041
|
}
|
|
51981
52042
|
function checkAgentBinaries() {
|
|
51982
|
-
const
|
|
52043
|
+
const os68 = createOsStrategy();
|
|
51983
52044
|
return getEnabledAgents().map((meta) => {
|
|
51984
|
-
const found =
|
|
52045
|
+
const found = os68.findInPath(meta.binaryName);
|
|
51985
52046
|
return {
|
|
51986
52047
|
id: `agent-${meta.id}`,
|
|
51987
52048
|
label: `Agent binary: ${meta.displayName} (${meta.binaryName})`,
|
|
@@ -52003,7 +52064,7 @@ function checkNodePty() {
|
|
|
52003
52064
|
detail: "not required on this platform"
|
|
52004
52065
|
};
|
|
52005
52066
|
}
|
|
52006
|
-
const vendoredPath =
|
|
52067
|
+
const vendoredPath = path103.join(__dirname, "vendor", "node-pty");
|
|
52007
52068
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
52008
52069
|
try {
|
|
52009
52070
|
require(target);
|
|
@@ -52045,9 +52106,9 @@ function checkChokidar() {
|
|
|
52045
52106
|
}
|
|
52046
52107
|
async function doctor(args2 = []) {
|
|
52047
52108
|
const json = args2.includes("--json");
|
|
52048
|
-
const cliVersion = true ? "2.76.
|
|
52109
|
+
const cliVersion = true ? "2.76.3" : "0.0.0-dev";
|
|
52049
52110
|
const apiBase2 = resolveApiBaseUrl();
|
|
52050
|
-
const diagnosticId = (0,
|
|
52111
|
+
const diagnosticId = (0, import_node_crypto15.randomUUID)();
|
|
52051
52112
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
52052
52113
|
const [dns, health] = await Promise.all([
|
|
52053
52114
|
checkDns(apiBase2),
|
|
@@ -52253,8 +52314,8 @@ var LAUNCHER_ENV = Object.freeze({
|
|
|
52253
52314
|
|
|
52254
52315
|
// src/integrations/mcp-run.ts
|
|
52255
52316
|
var import_node_fs20 = require("fs");
|
|
52256
|
-
var
|
|
52257
|
-
var
|
|
52317
|
+
var import_node_os16 = __toESM(require("os"));
|
|
52318
|
+
var import_node_path21 = __toESM(require("path"));
|
|
52258
52319
|
|
|
52259
52320
|
// src/integrations/token-client.ts
|
|
52260
52321
|
var REFRESH_AHEAD_MS = 5 * 60 * 1e3;
|
|
@@ -52334,8 +52395,8 @@ function commandExists(command2) {
|
|
|
52334
52395
|
}
|
|
52335
52396
|
function localBinCandidates(command2) {
|
|
52336
52397
|
return [
|
|
52337
|
-
|
|
52338
|
-
|
|
52398
|
+
import_node_path21.default.join(import_node_os16.default.homedir(), ".local", "bin", command2),
|
|
52399
|
+
import_node_path21.default.join(import_node_os16.default.homedir(), ".cargo", "bin", command2)
|
|
52339
52400
|
];
|
|
52340
52401
|
}
|
|
52341
52402
|
function resolveLauncherPath(command2, deps = {
|
|
@@ -52569,7 +52630,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
52569
52630
|
// src/commands/version.ts
|
|
52570
52631
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
52571
52632
|
function version2() {
|
|
52572
|
-
const v = true ? "2.76.
|
|
52633
|
+
const v = true ? "2.76.3" : "unknown";
|
|
52573
52634
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
52574
52635
|
}
|
|
52575
52636
|
|
|
@@ -52718,10 +52779,10 @@ var EXIT_CODE_NAMES = {
|
|
|
52718
52779
|
};
|
|
52719
52780
|
|
|
52720
52781
|
// src/index.ts
|
|
52721
|
-
var
|
|
52782
|
+
var os67 = __toESM(require("os"));
|
|
52722
52783
|
if (!process.env.HOME) {
|
|
52723
52784
|
try {
|
|
52724
|
-
const home =
|
|
52785
|
+
const home = os67.homedir();
|
|
52725
52786
|
if (home) process.env.HOME = home;
|
|
52726
52787
|
} catch {
|
|
52727
52788
|
}
|