codeam-cli 2.67.2 → 2.67.5
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 +13 -0
- package/dist/index.js +397 -262
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3156,11 +3156,11 @@ function quiet(fn) {
|
|
|
3156
3156
|
log.debug(TAG, "ignored sync error", err);
|
|
3157
3157
|
}
|
|
3158
3158
|
}
|
|
3159
|
-
function rmIfExistsQuiet(
|
|
3159
|
+
function rmIfExistsQuiet(path95) {
|
|
3160
3160
|
try {
|
|
3161
|
-
fs2.rmSync(
|
|
3161
|
+
fs2.rmSync(path95, { force: true });
|
|
3162
3162
|
} catch (err) {
|
|
3163
|
-
log.debug(TAG, `rmIfExists failed for ${
|
|
3163
|
+
log.debug(TAG, `rmIfExists failed for ${path95}`, err);
|
|
3164
3164
|
}
|
|
3165
3165
|
}
|
|
3166
3166
|
function killQuiet(target, signal = "SIGTERM") {
|
|
@@ -3329,9 +3329,9 @@ var _default = makeConfig();
|
|
|
3329
3329
|
var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, setSessionAgent, setSquadAuto, getSquadAuto, clearAll, saveCliConfig, loadCliConfig } = _default;
|
|
3330
3330
|
|
|
3331
3331
|
// src/commands/pair-auto.ts
|
|
3332
|
-
var
|
|
3332
|
+
var fs66 = __toESM(require("fs"));
|
|
3333
3333
|
var os55 = __toESM(require("os"));
|
|
3334
|
-
var
|
|
3334
|
+
var path72 = __toESM(require("path"));
|
|
3335
3335
|
var import_crypto4 = require("crypto");
|
|
3336
3336
|
|
|
3337
3337
|
// src/services/telemetry.service.ts
|
|
@@ -3367,8 +3367,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
3367
3367
|
return decodedFile;
|
|
3368
3368
|
};
|
|
3369
3369
|
}
|
|
3370
|
-
function normalizeWindowsPath(
|
|
3371
|
-
return
|
|
3370
|
+
function normalizeWindowsPath(path95) {
|
|
3371
|
+
return path95.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
3372
3372
|
}
|
|
3373
3373
|
|
|
3374
3374
|
// ../../node_modules/@posthog/core/dist/featureFlagUtils.mjs
|
|
@@ -5848,9 +5848,9 @@ async function addSourceContext(frames) {
|
|
|
5848
5848
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
5849
5849
|
return frames;
|
|
5850
5850
|
}
|
|
5851
|
-
function getContextLinesFromFile(
|
|
5851
|
+
function getContextLinesFromFile(path95, ranges, output) {
|
|
5852
5852
|
return new Promise((resolve10) => {
|
|
5853
|
-
const stream = (0, import_node_fs.createReadStream)(
|
|
5853
|
+
const stream = (0, import_node_fs.createReadStream)(path95);
|
|
5854
5854
|
const lineReaded = (0, import_node_readline.createInterface)({
|
|
5855
5855
|
input: stream
|
|
5856
5856
|
});
|
|
@@ -5865,7 +5865,7 @@ function getContextLinesFromFile(path94, ranges, output) {
|
|
|
5865
5865
|
let rangeStart = range[0];
|
|
5866
5866
|
let rangeEnd = range[1];
|
|
5867
5867
|
function onStreamError() {
|
|
5868
|
-
LRU_FILE_CONTENTS_FS_READ_FAILED.set(
|
|
5868
|
+
LRU_FILE_CONTENTS_FS_READ_FAILED.set(path95, 1);
|
|
5869
5869
|
lineReaded.close();
|
|
5870
5870
|
lineReaded.removeAllListeners();
|
|
5871
5871
|
destroyStreamAndResolve();
|
|
@@ -5926,8 +5926,8 @@ function clearLineContext(frame) {
|
|
|
5926
5926
|
delete frame.context_line;
|
|
5927
5927
|
delete frame.post_context;
|
|
5928
5928
|
}
|
|
5929
|
-
function shouldSkipContextLinesForFile(
|
|
5930
|
-
return
|
|
5929
|
+
function shouldSkipContextLinesForFile(path95) {
|
|
5930
|
+
return path95.startsWith("node:") || path95.endsWith(".min.js") || path95.endsWith(".min.cjs") || path95.endsWith(".min.mjs") || path95.startsWith("data:");
|
|
5931
5931
|
}
|
|
5932
5932
|
function shouldSkipContextLinesForFrame(frame) {
|
|
5933
5933
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
@@ -8081,7 +8081,7 @@ function readAnonId() {
|
|
|
8081
8081
|
}
|
|
8082
8082
|
function superProperties() {
|
|
8083
8083
|
return {
|
|
8084
|
-
cliVersion: true ? "2.67.
|
|
8084
|
+
cliVersion: true ? "2.67.5" : "0.0.0-dev",
|
|
8085
8085
|
nodeVersion: process.version,
|
|
8086
8086
|
platform: process.platform,
|
|
8087
8087
|
arch: process.arch,
|
|
@@ -8323,7 +8323,7 @@ var http = __toESM(require("http"));
|
|
|
8323
8323
|
// package.json
|
|
8324
8324
|
var package_default = {
|
|
8325
8325
|
name: "codeam-cli",
|
|
8326
|
-
version: "2.67.
|
|
8326
|
+
version: "2.67.5",
|
|
8327
8327
|
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.",
|
|
8328
8328
|
type: "commonjs",
|
|
8329
8329
|
main: "dist/index.js",
|
|
@@ -9855,7 +9855,7 @@ var CommandRelayService = class _CommandRelayService {
|
|
|
9855
9855
|
// fresh + clear the "CLI update available" banner after a self-update
|
|
9856
9856
|
// (a codespace that reinstalls @latest reconnects via heartbeat, not
|
|
9857
9857
|
// pair/reconnect). Older backends ignore the extra field.
|
|
9858
|
-
..."2.67.
|
|
9858
|
+
..."2.67.5" ? { ideVersion: "2.67.5" } : {}
|
|
9859
9859
|
}).then(() => log.trace("relay", `heartbeat ok online=${online}`)).catch((err) => log.trace("relay", `heartbeat failed online=${online}`, err));
|
|
9860
9860
|
}
|
|
9861
9861
|
/**
|
|
@@ -11262,9 +11262,9 @@ function closeAllTerminals() {
|
|
|
11262
11262
|
}
|
|
11263
11263
|
|
|
11264
11264
|
// src/commands/start/handlers.ts
|
|
11265
|
-
var
|
|
11265
|
+
var fs65 = __toESM(require("fs"));
|
|
11266
11266
|
var os54 = __toESM(require("os"));
|
|
11267
|
-
var
|
|
11267
|
+
var path71 = __toESM(require("path"));
|
|
11268
11268
|
var import_crypto3 = require("crypto");
|
|
11269
11269
|
var import_child_process27 = require("child_process");
|
|
11270
11270
|
|
|
@@ -17465,8 +17465,8 @@ function pickLine(obj) {
|
|
|
17465
17465
|
function toHunk(raw, groupSeverity) {
|
|
17466
17466
|
if (!raw || typeof raw !== "object") return null;
|
|
17467
17467
|
const o = raw;
|
|
17468
|
-
const
|
|
17469
|
-
if (!
|
|
17468
|
+
const path95 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
|
|
17469
|
+
if (!path95) return null;
|
|
17470
17470
|
const message = asString(
|
|
17471
17471
|
pick(o, [
|
|
17472
17472
|
"comment",
|
|
@@ -17483,7 +17483,7 @@ function toHunk(raw, groupSeverity) {
|
|
|
17483
17483
|
const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
|
|
17484
17484
|
const locObj = pick(o, ["location"]) ?? o;
|
|
17485
17485
|
return {
|
|
17486
|
-
path:
|
|
17486
|
+
path: path95.trim(),
|
|
17487
17487
|
line: pickLine(o) ?? pickLine(locObj),
|
|
17488
17488
|
severity,
|
|
17489
17489
|
message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
|
|
@@ -17566,10 +17566,10 @@ function parsePlain(stdout) {
|
|
|
17566
17566
|
for (const line of stdout.split(/\r?\n/)) {
|
|
17567
17567
|
const m = line.match(HUNK_LINE_RE);
|
|
17568
17568
|
if (!m) continue;
|
|
17569
|
-
const [,
|
|
17570
|
-
if (!
|
|
17569
|
+
const [, path95, lineNo, sevToken, message] = m;
|
|
17570
|
+
if (!path95 || !lineNo || !message) continue;
|
|
17571
17571
|
hunks.push({
|
|
17572
|
-
path:
|
|
17572
|
+
path: path95.trim(),
|
|
17573
17573
|
line: Number(lineNo),
|
|
17574
17574
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
17575
17575
|
message: message.trim().replace(/^[*-]\s+/, "")
|
|
@@ -18287,14 +18287,14 @@ function defaultSdkDir() {
|
|
|
18287
18287
|
return resolveSdkDirViaRequire();
|
|
18288
18288
|
}
|
|
18289
18289
|
function resolveClaudeNativeBinary(deps = {}) {
|
|
18290
|
-
const
|
|
18290
|
+
const existsSync30 = deps.existsSync ?? import_fs.default.existsSync;
|
|
18291
18291
|
const platformKey = deps.platformKey ?? currentPlatformKey();
|
|
18292
18292
|
const sdkDir = deps.sdkDir !== void 0 ? deps.sdkDir : defaultSdkDir();
|
|
18293
18293
|
if (!sdkDir) return null;
|
|
18294
18294
|
const scopeDir = import_path4.default.dirname(sdkDir);
|
|
18295
18295
|
const binName = platformKey.startsWith("win32-") ? "claude.exe" : "claude";
|
|
18296
18296
|
const candidate = import_path4.default.join(scopeDir, `claude-agent-sdk-${platformKey}`, binName);
|
|
18297
|
-
return
|
|
18297
|
+
return existsSync30(candidate) ? candidate : null;
|
|
18298
18298
|
}
|
|
18299
18299
|
var realSleep = (ms) => new Promise((resolve10) => setTimeout(resolve10, ms));
|
|
18300
18300
|
async function waitForClaudeNativeBinary(opts = {}) {
|
|
@@ -18376,18 +18376,18 @@ function augmentUserLocalBinPaths(deps = {}) {
|
|
|
18376
18376
|
env.PATH = [...additions, ...parts].join(p2.delimiter);
|
|
18377
18377
|
}
|
|
18378
18378
|
function resolveCursorAgentBinary(deps = {}) {
|
|
18379
|
-
const
|
|
18379
|
+
const existsSync30 = deps.existsSync ?? import_fs.default.existsSync;
|
|
18380
18380
|
const platform3 = deps.platform ?? process.platform;
|
|
18381
18381
|
const env = deps.env ?? process.env;
|
|
18382
18382
|
if (platform3 === "win32") {
|
|
18383
18383
|
const localAppData = env.LOCALAPPDATA;
|
|
18384
18384
|
if (!localAppData) return null;
|
|
18385
18385
|
const exe = import_path4.default.win32.join(localAppData, "cursor-agent", "cursor-agent.exe");
|
|
18386
|
-
return
|
|
18386
|
+
return existsSync30(exe) ? exe : null;
|
|
18387
18387
|
}
|
|
18388
18388
|
const home = deps.homedir ?? import_os4.default.homedir();
|
|
18389
18389
|
const unix = import_path4.default.posix.join(home, ".local", "bin", "cursor-agent");
|
|
18390
|
-
return
|
|
18390
|
+
return existsSync30(unix) ? unix : null;
|
|
18391
18391
|
}
|
|
18392
18392
|
async function waitForCursorAgent(opts = {}) {
|
|
18393
18393
|
const timeoutMs = opts.timeoutMs ?? 18e4;
|
|
@@ -22082,7 +22082,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
22082
22082
|
if (process.env.NODE_ENV === "test") return;
|
|
22083
22083
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
22084
22084
|
if (process.env.CI) return;
|
|
22085
|
-
const current2 = true ? "2.67.
|
|
22085
|
+
const current2 = true ? "2.67.5" : null;
|
|
22086
22086
|
if (!current2) return;
|
|
22087
22087
|
const cache = readCache();
|
|
22088
22088
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -22099,7 +22099,7 @@ function checkForUpdates() {
|
|
|
22099
22099
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
22100
22100
|
if (process.env.CI) return;
|
|
22101
22101
|
if (!process.stdout.isTTY) return;
|
|
22102
|
-
const current2 = true ? "2.67.
|
|
22102
|
+
const current2 = true ? "2.67.5" : null;
|
|
22103
22103
|
if (!current2) return;
|
|
22104
22104
|
const cache = readCache();
|
|
22105
22105
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -22122,7 +22122,7 @@ var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
|
22122
22122
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
22123
22123
|
var SUDO_PREFLIGHT_TIMEOUT_MS = 5e3;
|
|
22124
22124
|
function currentCliVersion() {
|
|
22125
|
-
return true ? "2.67.
|
|
22125
|
+
return true ? "2.67.5" : null;
|
|
22126
22126
|
}
|
|
22127
22127
|
async function installedVersion(deps) {
|
|
22128
22128
|
const ls = await deps.run(
|
|
@@ -23993,7 +23993,7 @@ async function defaultFetchJson(url2) {
|
|
|
23993
23993
|
async function readUsageReport(deps = {}) {
|
|
23994
23994
|
const port = deps.port ?? HEADROOM_PROXY_PORT;
|
|
23995
23995
|
const base = `http://127.0.0.1:${port}`;
|
|
23996
|
-
const get2 = deps.fetchJson ?? ((
|
|
23996
|
+
const get2 = deps.fetchJson ?? ((path95) => defaultFetchJson(`${base}${path95}`));
|
|
23997
23997
|
let history;
|
|
23998
23998
|
try {
|
|
23999
23999
|
history = await get2("/stats-history");
|
|
@@ -24332,6 +24332,112 @@ async function applyPreviewHostAllow(cwd) {
|
|
|
24332
24332
|
}
|
|
24333
24333
|
}
|
|
24334
24334
|
|
|
24335
|
+
// src/services/preview/build-heal.ts
|
|
24336
|
+
var fs52 = __toESM(require("fs"));
|
|
24337
|
+
var path57 = __toESM(require("path"));
|
|
24338
|
+
var BUILD_MARKER_NAME = "BUILD_ID";
|
|
24339
|
+
var DEFAULT_DEBOUNCE_MS = 1500;
|
|
24340
|
+
var DEFAULT_MAX_RESTARTS = 3;
|
|
24341
|
+
function isBuildHealSupported(framework) {
|
|
24342
|
+
return /next/i.test(framework);
|
|
24343
|
+
}
|
|
24344
|
+
function defaultWatchDir(dir, onEvent) {
|
|
24345
|
+
try {
|
|
24346
|
+
const w3 = fs52.watch(dir, { persistent: false }, (_eventType, filename) => onEvent(filename));
|
|
24347
|
+
return () => w3.close();
|
|
24348
|
+
} catch {
|
|
24349
|
+
return null;
|
|
24350
|
+
}
|
|
24351
|
+
}
|
|
24352
|
+
var healRestartCounts = /* @__PURE__ */ new Map();
|
|
24353
|
+
function resetBuildHealState(sessionId) {
|
|
24354
|
+
healRestartCounts.delete(sessionId);
|
|
24355
|
+
}
|
|
24356
|
+
function readMarker2(markerPath2) {
|
|
24357
|
+
try {
|
|
24358
|
+
return fs52.readFileSync(markerPath2, "utf8").trim();
|
|
24359
|
+
} catch {
|
|
24360
|
+
return null;
|
|
24361
|
+
}
|
|
24362
|
+
}
|
|
24363
|
+
function watchForBuildClobber(deps) {
|
|
24364
|
+
const watchDir = deps.watchDir ?? defaultWatchDir;
|
|
24365
|
+
const debounceMs = deps.debounceMs ?? DEFAULT_DEBOUNCE_MS;
|
|
24366
|
+
const maxRestarts = deps.maxRestarts ?? DEFAULT_MAX_RESTARTS;
|
|
24367
|
+
const nextDir = path57.join(deps.cwd, ".next");
|
|
24368
|
+
const markerPath2 = path57.join(nextDir, BUILD_MARKER_NAME);
|
|
24369
|
+
let stopped = false;
|
|
24370
|
+
let debounceTimer = null;
|
|
24371
|
+
let dirUnwatch = null;
|
|
24372
|
+
let cwdUnwatch = null;
|
|
24373
|
+
let lastKnownMarker = readMarker2(markerPath2);
|
|
24374
|
+
const stop = () => {
|
|
24375
|
+
if (stopped) return;
|
|
24376
|
+
stopped = true;
|
|
24377
|
+
if (debounceTimer) {
|
|
24378
|
+
clearTimeout(debounceTimer);
|
|
24379
|
+
debounceTimer = null;
|
|
24380
|
+
}
|
|
24381
|
+
dirUnwatch?.();
|
|
24382
|
+
dirUnwatch = null;
|
|
24383
|
+
cwdUnwatch?.();
|
|
24384
|
+
cwdUnwatch = null;
|
|
24385
|
+
};
|
|
24386
|
+
const onDebouncedClobber = () => {
|
|
24387
|
+
if (stopped) return;
|
|
24388
|
+
const current2 = readMarker2(markerPath2);
|
|
24389
|
+
if (current2 === lastKnownMarker) return;
|
|
24390
|
+
lastKnownMarker = current2;
|
|
24391
|
+
const count = (healRestartCounts.get(deps.sessionId) ?? 0) + 1;
|
|
24392
|
+
healRestartCounts.set(deps.sessionId, count);
|
|
24393
|
+
if (count > maxRestarts) {
|
|
24394
|
+
log.warn(
|
|
24395
|
+
"preview",
|
|
24396
|
+
`build-heal: restart cap (${maxRestarts}) reached for session=${deps.sessionId} \u2014 no longer self-healing`
|
|
24397
|
+
);
|
|
24398
|
+
deps.notify(
|
|
24399
|
+
"This preview keeps getting rebuilt \u2014 stopped auto-restarting. Restart it manually once the rebuilds settle."
|
|
24400
|
+
);
|
|
24401
|
+
stop();
|
|
24402
|
+
return;
|
|
24403
|
+
}
|
|
24404
|
+
log.info(
|
|
24405
|
+
"preview",
|
|
24406
|
+
`build-heal: ${markerPath2} changed (a build likely ran) \u2014 restarting the dev server (${count}/${maxRestarts})`
|
|
24407
|
+
);
|
|
24408
|
+
deps.notify("Rebuilt \u2014 restarting preview");
|
|
24409
|
+
deps.restart();
|
|
24410
|
+
};
|
|
24411
|
+
const onMarkerTouched = () => {
|
|
24412
|
+
if (stopped) return;
|
|
24413
|
+
if (debounceTimer) clearTimeout(debounceTimer);
|
|
24414
|
+
debounceTimer = setTimeout(() => {
|
|
24415
|
+
debounceTimer = null;
|
|
24416
|
+
onDebouncedClobber();
|
|
24417
|
+
}, debounceMs);
|
|
24418
|
+
};
|
|
24419
|
+
const attachDirWatch = () => {
|
|
24420
|
+
if (dirUnwatch) return;
|
|
24421
|
+
lastKnownMarker = readMarker2(markerPath2);
|
|
24422
|
+
dirUnwatch = watchDir(nextDir, (filename) => {
|
|
24423
|
+
if (filename === null || filename === BUILD_MARKER_NAME) onMarkerTouched();
|
|
24424
|
+
});
|
|
24425
|
+
};
|
|
24426
|
+
if (fs52.existsSync(nextDir)) {
|
|
24427
|
+
attachDirWatch();
|
|
24428
|
+
} else {
|
|
24429
|
+
cwdUnwatch = watchDir(deps.cwd, (filename) => {
|
|
24430
|
+
if (stopped || dirUnwatch) return;
|
|
24431
|
+
if ((filename === ".next" || filename === null) && fs52.existsSync(nextDir)) {
|
|
24432
|
+
cwdUnwatch?.();
|
|
24433
|
+
cwdUnwatch = null;
|
|
24434
|
+
attachDirWatch();
|
|
24435
|
+
}
|
|
24436
|
+
});
|
|
24437
|
+
}
|
|
24438
|
+
return { stop };
|
|
24439
|
+
}
|
|
24440
|
+
|
|
24335
24441
|
// src/services/preview/cloudflared.ts
|
|
24336
24442
|
var import_child_process18 = require("child_process");
|
|
24337
24443
|
var import_fs3 = require("fs");
|
|
@@ -24981,6 +25087,7 @@ function killProcessTree(child, signal = "SIGTERM") {
|
|
|
24981
25087
|
async function killPreview(sessionId) {
|
|
24982
25088
|
const preview = activePreviews.get(sessionId);
|
|
24983
25089
|
if (!preview) return;
|
|
25090
|
+
preview.buildHealStop?.();
|
|
24984
25091
|
forgetPreviewPort(preview.detection.port);
|
|
24985
25092
|
if (preview.tunnel) {
|
|
24986
25093
|
killProcessTree(preview.tunnel, "SIGTERM");
|
|
@@ -25005,19 +25112,19 @@ function activePreviewSessionIds() {
|
|
|
25005
25112
|
|
|
25006
25113
|
// src/services/preview/start-orchestrator.ts
|
|
25007
25114
|
var import_child_process22 = require("child_process");
|
|
25008
|
-
var
|
|
25009
|
-
var
|
|
25115
|
+
var fs59 = __toESM(require("fs"));
|
|
25116
|
+
var path64 = __toESM(require("path"));
|
|
25010
25117
|
var import_which2 = __toESM(require("which"));
|
|
25011
25118
|
|
|
25012
25119
|
// src/services/project-env/index.ts
|
|
25013
25120
|
var import_fs6 = require("fs");
|
|
25014
|
-
var
|
|
25121
|
+
var path63 = __toESM(require("path"));
|
|
25015
25122
|
|
|
25016
25123
|
// src/beads/project-key.ts
|
|
25017
25124
|
var import_child_process21 = require("child_process");
|
|
25018
25125
|
var crypto2 = __toESM(require("crypto"));
|
|
25019
|
-
var
|
|
25020
|
-
var
|
|
25126
|
+
var fs57 = __toESM(require("fs"));
|
|
25127
|
+
var path62 = __toESM(require("path"));
|
|
25021
25128
|
function normalizeOrigin(raw) {
|
|
25022
25129
|
const trimmed = raw.trim();
|
|
25023
25130
|
if (!trimmed) return null;
|
|
@@ -25043,17 +25150,17 @@ function normalizeOrigin(raw) {
|
|
|
25043
25150
|
return `${host2}/${pathPart}`;
|
|
25044
25151
|
}
|
|
25045
25152
|
function findRepoRoot(cwd) {
|
|
25046
|
-
let dir =
|
|
25153
|
+
let dir = path62.resolve(cwd);
|
|
25047
25154
|
const seen = /* @__PURE__ */ new Set();
|
|
25048
25155
|
for (let i = 0; i < 256; i++) {
|
|
25049
25156
|
if (seen.has(dir)) return null;
|
|
25050
25157
|
seen.add(dir);
|
|
25051
25158
|
try {
|
|
25052
|
-
const stat3 =
|
|
25159
|
+
const stat3 = fs57.statSync(path62.join(dir, ".git"), { throwIfNoEntry: false });
|
|
25053
25160
|
if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
|
|
25054
25161
|
} catch {
|
|
25055
25162
|
}
|
|
25056
|
-
const parent =
|
|
25163
|
+
const parent = path62.dirname(dir);
|
|
25057
25164
|
if (parent === dir) return null;
|
|
25058
25165
|
dir = parent;
|
|
25059
25166
|
}
|
|
@@ -25064,7 +25171,7 @@ var _execSeam3 = {
|
|
|
25064
25171
|
const out2 = (0, import_child_process21.execFileSync)(file, args2, opts);
|
|
25065
25172
|
return typeof out2 === "string" ? out2 : out2.toString("utf8");
|
|
25066
25173
|
},
|
|
25067
|
-
realpath: (p2) =>
|
|
25174
|
+
realpath: (p2) => fs57.realpathSync(p2)
|
|
25068
25175
|
};
|
|
25069
25176
|
function readOrigin(cwd) {
|
|
25070
25177
|
try {
|
|
@@ -25093,7 +25200,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
|
|
|
25093
25200
|
} catch {
|
|
25094
25201
|
}
|
|
25095
25202
|
const hash = crypto2.createHash("sha256").update(real).digest("hex");
|
|
25096
|
-
return { projectKey: `path:${hash}`, projectLabel:
|
|
25203
|
+
return { projectKey: `path:${hash}`, projectLabel: path62.basename(real) || "project" };
|
|
25097
25204
|
}
|
|
25098
25205
|
|
|
25099
25206
|
// src/services/project-env/index.ts
|
|
@@ -25106,7 +25213,7 @@ async function readIfExists(p2) {
|
|
|
25106
25213
|
}
|
|
25107
25214
|
async function syncProjectEnvUp(cwd, ctx) {
|
|
25108
25215
|
if (!ctx.pluginAuthToken) return;
|
|
25109
|
-
const content = await readIfExists(
|
|
25216
|
+
const content = await readIfExists(path63.join(cwd, ".env"));
|
|
25110
25217
|
if (content == null) return;
|
|
25111
25218
|
try {
|
|
25112
25219
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -25128,7 +25235,7 @@ async function syncProjectEnvUp(cwd, ctx) {
|
|
|
25128
25235
|
}
|
|
25129
25236
|
async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
25130
25237
|
if (!ctx.pluginAuthToken) return false;
|
|
25131
|
-
const envPath =
|
|
25238
|
+
const envPath = path63.join(cwd, ".env");
|
|
25132
25239
|
if (await readIfExists(envPath) != null) return false;
|
|
25133
25240
|
try {
|
|
25134
25241
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -25139,7 +25246,7 @@ async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
|
25139
25246
|
projectKey
|
|
25140
25247
|
});
|
|
25141
25248
|
if (!stored) return false;
|
|
25142
|
-
const tmp =
|
|
25249
|
+
const tmp = path63.join(cwd, ".env.codeam-restore.tmp");
|
|
25143
25250
|
await import_fs6.promises.writeFile(tmp, stored.content, { encoding: "utf8", mode: 384 });
|
|
25144
25251
|
await import_fs6.promises.rename(tmp, envPath);
|
|
25145
25252
|
log.info("project-env", `restored .env (${stored.keyCount} vars) for ${projectLabel}`);
|
|
@@ -25236,8 +25343,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
|
|
|
25236
25343
|
if (args2.length === 0) return detection;
|
|
25237
25344
|
const binName = args2[0];
|
|
25238
25345
|
if (binName.startsWith("-")) return detection;
|
|
25239
|
-
const binPath =
|
|
25240
|
-
if (!
|
|
25346
|
+
const binPath = path64.join(cwd, "node_modules", ".bin", binName);
|
|
25347
|
+
if (!fs59.existsSync(binPath)) return detection;
|
|
25241
25348
|
return {
|
|
25242
25349
|
...detection,
|
|
25243
25350
|
command: binPath,
|
|
@@ -25618,9 +25725,9 @@ async function establishTunnel(ctx, dev) {
|
|
|
25618
25725
|
|
|
25619
25726
|
// src/beads/bd-adapter.ts
|
|
25620
25727
|
var import_child_process23 = require("child_process");
|
|
25621
|
-
var
|
|
25728
|
+
var fs60 = __toESM(require("fs"));
|
|
25622
25729
|
var os48 = __toESM(require("os"));
|
|
25623
|
-
var
|
|
25730
|
+
var path65 = __toESM(require("path"));
|
|
25624
25731
|
var BD_PACKAGE = "@beads/bd";
|
|
25625
25732
|
function resolveBundledBdBinary() {
|
|
25626
25733
|
return _resolveSeam.resolveBundled();
|
|
@@ -25632,11 +25739,11 @@ function _defaultResolveBundled() {
|
|
|
25632
25739
|
} catch {
|
|
25633
25740
|
return null;
|
|
25634
25741
|
}
|
|
25635
|
-
const binDir =
|
|
25742
|
+
const binDir = path65.join(path65.dirname(pkgJsonPath), "bin");
|
|
25636
25743
|
const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
|
|
25637
|
-
const binaryPath =
|
|
25744
|
+
const binaryPath = path65.join(binDir, binaryName);
|
|
25638
25745
|
try {
|
|
25639
|
-
|
|
25746
|
+
fs60.accessSync(binaryPath, fs60.constants.F_OK);
|
|
25640
25747
|
return binaryPath;
|
|
25641
25748
|
} catch {
|
|
25642
25749
|
return null;
|
|
@@ -25646,13 +25753,13 @@ function resolveBdOnPath() {
|
|
|
25646
25753
|
return _resolveSeam.resolveOnPath();
|
|
25647
25754
|
}
|
|
25648
25755
|
function _defaultResolveOnPath() {
|
|
25649
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
25756
|
+
const dirs = (process.env.PATH ?? "").split(path65.delimiter).filter(Boolean);
|
|
25650
25757
|
const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
|
|
25651
25758
|
for (const dir of dirs) {
|
|
25652
25759
|
for (const candidate of candidates) {
|
|
25653
|
-
const full =
|
|
25760
|
+
const full = path65.join(dir, candidate);
|
|
25654
25761
|
try {
|
|
25655
|
-
|
|
25762
|
+
fs60.accessSync(full, fs60.constants.F_OK);
|
|
25656
25763
|
return full;
|
|
25657
25764
|
} catch {
|
|
25658
25765
|
}
|
|
@@ -25829,9 +25936,9 @@ function coerceIssue(row, projectKey) {
|
|
|
25829
25936
|
|
|
25830
25937
|
// src/beads/provisioner.ts
|
|
25831
25938
|
var import_child_process26 = require("child_process");
|
|
25832
|
-
var
|
|
25939
|
+
var fs62 = __toESM(require("fs"));
|
|
25833
25940
|
var os50 = __toESM(require("os"));
|
|
25834
|
-
var
|
|
25941
|
+
var path67 = __toESM(require("path"));
|
|
25835
25942
|
|
|
25836
25943
|
// src/beads/install-bd.ts
|
|
25837
25944
|
var import_child_process24 = require("child_process");
|
|
@@ -25896,9 +26003,9 @@ async function installBd(platform3 = process.platform) {
|
|
|
25896
26003
|
|
|
25897
26004
|
// src/beads/install-dolt.ts
|
|
25898
26005
|
var import_child_process25 = require("child_process");
|
|
25899
|
-
var
|
|
26006
|
+
var fs61 = __toESM(require("fs"));
|
|
25900
26007
|
var os49 = __toESM(require("os"));
|
|
25901
|
-
var
|
|
26008
|
+
var path66 = __toESM(require("path"));
|
|
25902
26009
|
var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
|
|
25903
26010
|
var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
|
|
25904
26011
|
function resolveDoltInstallStrategy(platform3) {
|
|
@@ -25994,7 +26101,7 @@ var _doltPathSeam = {
|
|
|
25994
26101
|
},
|
|
25995
26102
|
exists: (p2) => {
|
|
25996
26103
|
try {
|
|
25997
|
-
|
|
26104
|
+
fs61.accessSync(p2, fs61.constants.F_OK);
|
|
25998
26105
|
return true;
|
|
25999
26106
|
} catch {
|
|
26000
26107
|
return false;
|
|
@@ -26005,7 +26112,7 @@ function doltBinaryNames(platform3) {
|
|
|
26005
26112
|
return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
|
|
26006
26113
|
}
|
|
26007
26114
|
function knownDoltDirs(platform3) {
|
|
26008
|
-
const P3 = platform3 === "win32" ?
|
|
26115
|
+
const P3 = platform3 === "win32" ? path66.win32 : path66.posix;
|
|
26009
26116
|
const home = _doltPathSeam.homedir();
|
|
26010
26117
|
if (platform3 === "win32") {
|
|
26011
26118
|
return [
|
|
@@ -26021,7 +26128,7 @@ function knownDoltDirs(platform3) {
|
|
|
26021
26128
|
].filter(Boolean);
|
|
26022
26129
|
}
|
|
26023
26130
|
function ensureDoltResolvable(platform3 = process.platform) {
|
|
26024
|
-
const P3 = platform3 === "win32" ?
|
|
26131
|
+
const P3 = platform3 === "win32" ? path66.win32 : path66.posix;
|
|
26025
26132
|
const delim = platform3 === "win32" ? ";" : ":";
|
|
26026
26133
|
const names = doltBinaryNames(platform3);
|
|
26027
26134
|
const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
|
|
@@ -26201,14 +26308,14 @@ var _linkSeam = {
|
|
|
26201
26308
|
homedir: () => os50.homedir(),
|
|
26202
26309
|
isWritableDir: (dir) => {
|
|
26203
26310
|
try {
|
|
26204
|
-
|
|
26311
|
+
fs62.accessSync(dir, fs62.constants.W_OK);
|
|
26205
26312
|
return true;
|
|
26206
26313
|
} catch {
|
|
26207
26314
|
return false;
|
|
26208
26315
|
}
|
|
26209
26316
|
},
|
|
26210
26317
|
ensureDir: (dir) => {
|
|
26211
|
-
|
|
26318
|
+
fs62.mkdirSync(dir, { recursive: true });
|
|
26212
26319
|
},
|
|
26213
26320
|
/**
|
|
26214
26321
|
* A directory to symlink `bd` into so the AGENT's shell + Claude Code's
|
|
@@ -26229,9 +26336,9 @@ var _linkSeam = {
|
|
|
26229
26336
|
* which `linkBdOntoPath` creates if missing.
|
|
26230
26337
|
*/
|
|
26231
26338
|
cliBinDir: () => {
|
|
26232
|
-
const pathDirs = (process.env.PATH ?? "").split(
|
|
26339
|
+
const pathDirs = (process.env.PATH ?? "").split(path67.delimiter).filter(Boolean);
|
|
26233
26340
|
const home = _linkSeam.homedir();
|
|
26234
|
-
const localBin = home ?
|
|
26341
|
+
const localBin = home ? path67.join(home, ".local", "bin") : null;
|
|
26235
26342
|
if (localBin) {
|
|
26236
26343
|
try {
|
|
26237
26344
|
_linkSeam.ensureDir(localBin);
|
|
@@ -26241,16 +26348,16 @@ var _linkSeam = {
|
|
|
26241
26348
|
const candidates = [];
|
|
26242
26349
|
if (localBin) candidates.push(localBin);
|
|
26243
26350
|
try {
|
|
26244
|
-
candidates.push(
|
|
26351
|
+
candidates.push(path67.dirname(process.execPath));
|
|
26245
26352
|
} catch {
|
|
26246
26353
|
}
|
|
26247
26354
|
candidates.push("/usr/local/bin");
|
|
26248
26355
|
const entry = process.argv[1];
|
|
26249
26356
|
if (entry) {
|
|
26250
26357
|
try {
|
|
26251
|
-
candidates.push(
|
|
26358
|
+
candidates.push(path67.dirname(fs62.realpathSync(entry)));
|
|
26252
26359
|
} catch {
|
|
26253
|
-
candidates.push(
|
|
26360
|
+
candidates.push(path67.dirname(entry));
|
|
26254
26361
|
}
|
|
26255
26362
|
}
|
|
26256
26363
|
const onPathWritable = candidates.find(
|
|
@@ -26262,20 +26369,20 @@ var _linkSeam = {
|
|
|
26262
26369
|
/** Current symlink target at `linkPath`, or null when absent / not a link. */
|
|
26263
26370
|
readlink: (linkPath) => {
|
|
26264
26371
|
try {
|
|
26265
|
-
return
|
|
26372
|
+
return fs62.readlinkSync(linkPath);
|
|
26266
26373
|
} catch {
|
|
26267
26374
|
return null;
|
|
26268
26375
|
}
|
|
26269
26376
|
},
|
|
26270
|
-
unlink: (linkPath) =>
|
|
26271
|
-
symlink: (target, linkPath) =>
|
|
26377
|
+
unlink: (linkPath) => fs62.unlinkSync(linkPath),
|
|
26378
|
+
symlink: (target, linkPath) => fs62.symlinkSync(target, linkPath)
|
|
26272
26379
|
};
|
|
26273
26380
|
function linkBdOntoPath(binaryPath) {
|
|
26274
26381
|
if (_linkSeam.platform() === "win32") return;
|
|
26275
26382
|
const binDir = _linkSeam.cliBinDir();
|
|
26276
26383
|
if (!binDir) return;
|
|
26277
26384
|
_linkSeam.ensureDir(binDir);
|
|
26278
|
-
const linkPath =
|
|
26385
|
+
const linkPath = path67.join(binDir, "bd");
|
|
26279
26386
|
if (linkPath === binaryPath) return;
|
|
26280
26387
|
const current2 = _linkSeam.readlink(linkPath);
|
|
26281
26388
|
if (current2 === binaryPath) return;
|
|
@@ -26470,7 +26577,7 @@ function dedupeRecipes(agents) {
|
|
|
26470
26577
|
|
|
26471
26578
|
// src/beads/watcher.ts
|
|
26472
26579
|
var crypto4 = __toESM(require("crypto"));
|
|
26473
|
-
var
|
|
26580
|
+
var path68 = __toESM(require("path"));
|
|
26474
26581
|
var API_BASE6 = resolveApiBaseUrl();
|
|
26475
26582
|
var DEBOUNCE_MS2 = 400;
|
|
26476
26583
|
var ZERO_SUMMARY = {
|
|
@@ -26494,7 +26601,7 @@ var BeadsWatcher = class {
|
|
|
26494
26601
|
constructor(opts) {
|
|
26495
26602
|
this.opts = opts;
|
|
26496
26603
|
this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
|
|
26497
|
-
this.feedPath = opts.feedPath ??
|
|
26604
|
+
this.feedPath = opts.feedPath ?? path68.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
|
|
26498
26605
|
this.apiBase = opts.apiBaseUrl ?? API_BASE6;
|
|
26499
26606
|
}
|
|
26500
26607
|
opts;
|
|
@@ -26993,8 +27100,8 @@ function cleanupAttachmentTempFiles() {
|
|
|
26993
27100
|
function saveFilesTemp(files) {
|
|
26994
27101
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
26995
27102
|
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
26996
|
-
const tmpPath =
|
|
26997
|
-
|
|
27103
|
+
const tmpPath = path71.join(os54.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
|
|
27104
|
+
fs65.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
|
|
26998
27105
|
pendingAttachmentFiles.add(tmpPath);
|
|
26999
27106
|
return tmpPath;
|
|
27000
27107
|
});
|
|
@@ -27212,10 +27319,10 @@ var listFiles = async (ctx, cmd, parsed) => {
|
|
|
27212
27319
|
await ctx.relay.sendResult(cmd.id, "completed", result);
|
|
27213
27320
|
};
|
|
27214
27321
|
var envReadH = async (ctx, cmd) => {
|
|
27215
|
-
const envPath =
|
|
27322
|
+
const envPath = path71.join(process.cwd(), ".env");
|
|
27216
27323
|
await restoreProjectEnvIfMissing(process.cwd(), ctx);
|
|
27217
27324
|
try {
|
|
27218
|
-
const raw = await
|
|
27325
|
+
const raw = await fs65.promises.readFile(envPath, "utf8");
|
|
27219
27326
|
await ctx.relay.sendResult(cmd.id, "completed", {
|
|
27220
27327
|
exists: true,
|
|
27221
27328
|
vars: parseDotenv(raw)
|
|
@@ -27246,15 +27353,15 @@ var envWriteH = async (ctx, cmd, parsed) => {
|
|
|
27246
27353
|
}
|
|
27247
27354
|
seen.add(v.key);
|
|
27248
27355
|
}
|
|
27249
|
-
const envPath =
|
|
27250
|
-
const tmpPath =
|
|
27356
|
+
const envPath = path71.join(process.cwd(), ".env");
|
|
27357
|
+
const tmpPath = path71.join(process.cwd(), ".env.codeam.tmp");
|
|
27251
27358
|
try {
|
|
27252
|
-
await
|
|
27253
|
-
await
|
|
27359
|
+
await fs65.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
|
|
27360
|
+
await fs65.promises.rename(tmpPath, envPath);
|
|
27254
27361
|
await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
|
|
27255
27362
|
void syncProjectEnvUp(process.cwd(), ctx);
|
|
27256
27363
|
} catch (err) {
|
|
27257
|
-
await
|
|
27364
|
+
await fs65.promises.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
27258
27365
|
await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
|
|
27259
27366
|
}
|
|
27260
27367
|
};
|
|
@@ -27303,7 +27410,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
|
|
|
27303
27410
|
let configuredAgent = rawAgentId;
|
|
27304
27411
|
if (!configuredAgent) {
|
|
27305
27412
|
try {
|
|
27306
|
-
const raw = JSON.parse(
|
|
27413
|
+
const raw = JSON.parse(fs65.readFileSync(headroomConfigPath(), "utf8"));
|
|
27307
27414
|
configuredAgent = raw.agent ?? "";
|
|
27308
27415
|
} catch {
|
|
27309
27416
|
}
|
|
@@ -27337,7 +27444,7 @@ var headroomConfigureH = async (ctx, cmd, parsed) => {
|
|
|
27337
27444
|
persist: persistHeadroomConfig,
|
|
27338
27445
|
readEnabled: () => {
|
|
27339
27446
|
try {
|
|
27340
|
-
const raw = JSON.parse(
|
|
27447
|
+
const raw = JSON.parse(fs65.readFileSync(headroomConfigPath(), "utf8"));
|
|
27341
27448
|
return raw.enabled === true;
|
|
27342
27449
|
} catch {
|
|
27343
27450
|
return false;
|
|
@@ -27659,7 +27766,7 @@ var headroomBudgetH = async (ctx, cmd) => {
|
|
|
27659
27766
|
}
|
|
27660
27767
|
let headroomActive = false;
|
|
27661
27768
|
try {
|
|
27662
|
-
const raw = JSON.parse(
|
|
27769
|
+
const raw = JSON.parse(fs65.readFileSync(headroomConfigPath(), "utf8"));
|
|
27663
27770
|
headroomActive = raw.enabled === true;
|
|
27664
27771
|
} catch {
|
|
27665
27772
|
}
|
|
@@ -27669,7 +27776,7 @@ var headroomBudgetH = async (ctx, cmd) => {
|
|
|
27669
27776
|
}
|
|
27670
27777
|
let existingConfig = { enabled: true };
|
|
27671
27778
|
try {
|
|
27672
|
-
existingConfig = JSON.parse(
|
|
27779
|
+
existingConfig = JSON.parse(fs65.readFileSync(headroomConfigPath(), "utf8"));
|
|
27673
27780
|
} catch {
|
|
27674
27781
|
}
|
|
27675
27782
|
if (payload.budgetEnabled && payload.budgetUsd != null) {
|
|
@@ -27782,9 +27889,9 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
|
|
|
27782
27889
|
function buildNpmInstallInvocation(opts) {
|
|
27783
27890
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
27784
27891
|
const execPath = opts?.execPath ?? process.execPath;
|
|
27785
|
-
const exists2 = opts?.existsSync ??
|
|
27892
|
+
const exists2 = opts?.existsSync ?? fs65.existsSync;
|
|
27786
27893
|
const platform3 = opts?.platform ?? process.platform;
|
|
27787
|
-
const p2 = platform3 === "win32" ?
|
|
27894
|
+
const p2 = platform3 === "win32" ? path71.win32 : path71.posix;
|
|
27788
27895
|
const normalized = entryScript.split(/[\\/]/).join("/");
|
|
27789
27896
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
27790
27897
|
const markerIdx = normalized.indexOf(marker);
|
|
@@ -27806,7 +27913,7 @@ function isPermissionError(stderr) {
|
|
|
27806
27913
|
function resolveGlobalNodeModulesDir(opts) {
|
|
27807
27914
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
27808
27915
|
const platform3 = opts?.platform ?? process.platform;
|
|
27809
|
-
const p2 = platform3 === "win32" ?
|
|
27916
|
+
const p2 = platform3 === "win32" ? path71.win32 : path71.posix;
|
|
27810
27917
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
27811
27918
|
const markerIdx = entryScript.split(/[\\/]/).join("/").indexOf(marker);
|
|
27812
27919
|
if (markerIdx <= 0) return null;
|
|
@@ -27816,9 +27923,9 @@ function resolveGlobalNodeModulesDir(opts) {
|
|
|
27816
27923
|
var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
|
|
27817
27924
|
function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
27818
27925
|
if (!nodeModulesDir) return 0;
|
|
27819
|
-
const readdirSync15 = deps?.readdirSync ??
|
|
27820
|
-
const statSync17 = deps?.statSync ??
|
|
27821
|
-
const rmSync9 = deps?.rmSync ??
|
|
27926
|
+
const readdirSync15 = deps?.readdirSync ?? fs65.readdirSync;
|
|
27927
|
+
const statSync17 = deps?.statSync ?? fs65.statSync;
|
|
27928
|
+
const rmSync9 = deps?.rmSync ?? fs65.rmSync;
|
|
27822
27929
|
let removed = 0;
|
|
27823
27930
|
let entries;
|
|
27824
27931
|
try {
|
|
@@ -27828,7 +27935,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
|
27828
27935
|
}
|
|
27829
27936
|
for (const name of entries) {
|
|
27830
27937
|
if (!/^\.codeam-cli-/.test(name)) continue;
|
|
27831
|
-
const full =
|
|
27938
|
+
const full = path71.join(nodeModulesDir, name);
|
|
27832
27939
|
try {
|
|
27833
27940
|
const st3 = statSync17(full);
|
|
27834
27941
|
if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
|
|
@@ -28323,7 +28430,7 @@ function startPreviewFromDetection(ctx, detection, pluginAuthToken) {
|
|
|
28323
28430
|
// this repo picks up its saved `.env` before the dev server spawns. Optional
|
|
28324
28431
|
// — a caller without a token just skips the restore.
|
|
28325
28432
|
projectEnvAuth: { pluginId: ctx.pluginId, pluginAuthToken }
|
|
28326
|
-
}).catch((err) => {
|
|
28433
|
+
}).then(() => maybeAttachBuildHeal(ctx, pluginAuthToken)).catch((err) => {
|
|
28327
28434
|
const message = err instanceof Error ? err.message : String(err);
|
|
28328
28435
|
log.warn("preview", `start crashed before ready: ${message}`);
|
|
28329
28436
|
emit2(USER_EVENTS.PREVIEW_ERROR, {
|
|
@@ -28332,6 +28439,33 @@ function startPreviewFromDetection(ctx, detection, pluginAuthToken) {
|
|
|
28332
28439
|
});
|
|
28333
28440
|
});
|
|
28334
28441
|
}
|
|
28442
|
+
function maybeAttachBuildHeal(ctx, pluginAuthToken) {
|
|
28443
|
+
const preview = activePreviews.get(ctx.sessionId);
|
|
28444
|
+
if (!preview || preview.buildHealStop) return;
|
|
28445
|
+
if (!isBuildHealSupported(preview.framework)) return;
|
|
28446
|
+
const { stop } = watchForBuildClobber({
|
|
28447
|
+
cwd: preview.cwd,
|
|
28448
|
+
sessionId: ctx.sessionId,
|
|
28449
|
+
restart: () => {
|
|
28450
|
+
void (async () => {
|
|
28451
|
+
if (!activePreviews.has(ctx.sessionId)) return;
|
|
28452
|
+
await killPreview(ctx.sessionId);
|
|
28453
|
+
await new Promise((r) => setTimeout(r, 150));
|
|
28454
|
+
startPreviewFromDetection(ctx, preview.detection, pluginAuthToken);
|
|
28455
|
+
})();
|
|
28456
|
+
},
|
|
28457
|
+
notify: (message) => {
|
|
28458
|
+
void postPreviewEvent({
|
|
28459
|
+
sessionId: ctx.sessionId,
|
|
28460
|
+
pluginId: ctx.pluginId,
|
|
28461
|
+
pluginAuthToken,
|
|
28462
|
+
type: USER_EVENTS.PREVIEW_PROGRESS,
|
|
28463
|
+
payload: { step: "BUILD_HEAL", message, timestamp: Date.now() }
|
|
28464
|
+
});
|
|
28465
|
+
}
|
|
28466
|
+
});
|
|
28467
|
+
preview.buildHealStop = stop;
|
|
28468
|
+
}
|
|
28335
28469
|
var previewStopH = (ctx) => {
|
|
28336
28470
|
if (!ctx.pluginAuthToken) {
|
|
28337
28471
|
log.info("preview", "no pluginAuthToken \u2014 skipping stop");
|
|
@@ -28340,6 +28474,7 @@ var previewStopH = (ctx) => {
|
|
|
28340
28474
|
const pluginAuthToken = ctx.pluginAuthToken;
|
|
28341
28475
|
void (async () => {
|
|
28342
28476
|
await killPreview(ctx.sessionId);
|
|
28477
|
+
resetBuildHealState(ctx.sessionId);
|
|
28343
28478
|
log.info("preview", `stopped session=${ctx.sessionId}`);
|
|
28344
28479
|
void postPreviewEvent({
|
|
28345
28480
|
sessionId: ctx.sessionId,
|
|
@@ -28706,11 +28841,11 @@ function resolveTokenValue(args2) {
|
|
|
28706
28841
|
}
|
|
28707
28842
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
28708
28843
|
if (fileFlag) {
|
|
28709
|
-
const
|
|
28844
|
+
const path95 = fileFlag.slice("--token-file=".length);
|
|
28710
28845
|
try {
|
|
28711
|
-
const content =
|
|
28712
|
-
if (content.length === 0) fail(`--token-file ${
|
|
28713
|
-
rmIfExistsQuiet(
|
|
28846
|
+
const content = fs66.readFileSync(path95, "utf8").trim();
|
|
28847
|
+
if (content.length === 0) fail(`--token-file ${path95} is empty`);
|
|
28848
|
+
rmIfExistsQuiet(path95);
|
|
28714
28849
|
return content;
|
|
28715
28850
|
} catch (err) {
|
|
28716
28851
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -28802,7 +28937,7 @@ async function claim(token, pluginId, pluginSecretHash) {
|
|
|
28802
28937
|
}
|
|
28803
28938
|
}
|
|
28804
28939
|
function pairAutoLockPath() {
|
|
28805
|
-
return
|
|
28940
|
+
return path72.join(os55.homedir(), ".codeam", "pair-auto.lock");
|
|
28806
28941
|
}
|
|
28807
28942
|
function isLivePairAuto(pid) {
|
|
28808
28943
|
if (!Number.isInteger(pid) || pid <= 0 || pid === process.pid) return false;
|
|
@@ -28812,7 +28947,7 @@ function isLivePairAuto(pid) {
|
|
|
28812
28947
|
if (e.code !== "EPERM") return false;
|
|
28813
28948
|
}
|
|
28814
28949
|
try {
|
|
28815
|
-
return
|
|
28950
|
+
return fs66.readFileSync(`/proc/${pid}/cmdline`, "utf8").includes("codeam");
|
|
28816
28951
|
} catch {
|
|
28817
28952
|
return true;
|
|
28818
28953
|
}
|
|
@@ -28822,24 +28957,24 @@ function isLiveCodeam(pid) {
|
|
|
28822
28957
|
}
|
|
28823
28958
|
function daemonLockPath(sessionId) {
|
|
28824
28959
|
const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
28825
|
-
return
|
|
28960
|
+
return path72.join(os55.homedir(), ".codeam", `daemon-${safe}.lock`);
|
|
28826
28961
|
}
|
|
28827
28962
|
function acquireDaemonLock(sessionId) {
|
|
28828
28963
|
const lockPath = daemonLockPath(sessionId);
|
|
28829
28964
|
try {
|
|
28830
|
-
|
|
28965
|
+
fs66.mkdirSync(path72.dirname(lockPath), { recursive: true });
|
|
28831
28966
|
try {
|
|
28832
|
-
|
|
28967
|
+
fs66.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
|
|
28833
28968
|
} catch (e) {
|
|
28834
28969
|
if (e.code !== "EEXIST") throw e;
|
|
28835
|
-
const holder = Number(
|
|
28970
|
+
const holder = Number(fs66.readFileSync(lockPath, "utf8").trim());
|
|
28836
28971
|
if (holder && holder !== process.pid && isLiveCodeam(holder)) return false;
|
|
28837
|
-
|
|
28972
|
+
fs66.writeFileSync(lockPath, String(process.pid));
|
|
28838
28973
|
}
|
|
28839
28974
|
const release3 = () => {
|
|
28840
28975
|
try {
|
|
28841
|
-
if (
|
|
28842
|
-
|
|
28976
|
+
if (fs66.existsSync(lockPath) && Number(fs66.readFileSync(lockPath, "utf8").trim()) === process.pid) {
|
|
28977
|
+
fs66.unlinkSync(lockPath);
|
|
28843
28978
|
}
|
|
28844
28979
|
} catch {
|
|
28845
28980
|
}
|
|
@@ -28861,19 +28996,19 @@ function acquireDaemonLock(sessionId) {
|
|
|
28861
28996
|
function acquireSingletonLock() {
|
|
28862
28997
|
const lockPath = pairAutoLockPath();
|
|
28863
28998
|
try {
|
|
28864
|
-
|
|
28999
|
+
fs66.mkdirSync(path72.dirname(lockPath), { recursive: true });
|
|
28865
29000
|
try {
|
|
28866
|
-
|
|
29001
|
+
fs66.writeFileSync(lockPath, String(process.pid), { flag: "wx" });
|
|
28867
29002
|
} catch (e) {
|
|
28868
29003
|
if (e.code !== "EEXIST") throw e;
|
|
28869
|
-
const holder = Number(
|
|
29004
|
+
const holder = Number(fs66.readFileSync(lockPath, "utf8").trim());
|
|
28870
29005
|
if (isLivePairAuto(holder)) return false;
|
|
28871
|
-
|
|
29006
|
+
fs66.writeFileSync(lockPath, String(process.pid));
|
|
28872
29007
|
}
|
|
28873
29008
|
process.once("exit", () => {
|
|
28874
29009
|
try {
|
|
28875
|
-
if (
|
|
28876
|
-
|
|
29010
|
+
if (fs66.existsSync(lockPath) && Number(fs66.readFileSync(lockPath, "utf8").trim()) === process.pid) {
|
|
29011
|
+
fs66.unlinkSync(lockPath);
|
|
28877
29012
|
}
|
|
28878
29013
|
} catch {
|
|
28879
29014
|
}
|
|
@@ -29323,7 +29458,7 @@ var AgentService = class _AgentService {
|
|
|
29323
29458
|
};
|
|
29324
29459
|
|
|
29325
29460
|
// src/agents/acp/adapters.ts
|
|
29326
|
-
var
|
|
29461
|
+
var path73 = __toESM(require("path"));
|
|
29327
29462
|
|
|
29328
29463
|
// src/agents/kimi/installer.ts
|
|
29329
29464
|
var import_node_child_process27 = require("child_process");
|
|
@@ -29443,13 +29578,13 @@ function resolveBin(pkgName, binName) {
|
|
|
29443
29578
|
try {
|
|
29444
29579
|
const manifestPath = require_.resolve(`${pkgName}/package.json`);
|
|
29445
29580
|
const manifest = require_(`${pkgName}/package.json`);
|
|
29446
|
-
const pkgDir =
|
|
29581
|
+
const pkgDir = path73.dirname(manifestPath);
|
|
29447
29582
|
const bin = manifest.bin;
|
|
29448
29583
|
if (!bin) return null;
|
|
29449
|
-
if (typeof bin === "string") return
|
|
29584
|
+
if (typeof bin === "string") return path73.resolve(pkgDir, bin);
|
|
29450
29585
|
const target = binName ?? Object.keys(bin)[0];
|
|
29451
29586
|
if (!target || !bin[target]) return null;
|
|
29452
|
-
return
|
|
29587
|
+
return path73.resolve(pkgDir, bin[target]);
|
|
29453
29588
|
} catch {
|
|
29454
29589
|
return null;
|
|
29455
29590
|
}
|
|
@@ -29630,13 +29765,13 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
29630
29765
|
|
|
29631
29766
|
// src/agents/acp/runner.ts
|
|
29632
29767
|
var import_node_crypto11 = require("crypto");
|
|
29633
|
-
var
|
|
29768
|
+
var fs78 = __toESM(require("fs"));
|
|
29634
29769
|
var os62 = __toESM(require("os"));
|
|
29635
|
-
var
|
|
29770
|
+
var path86 = __toESM(require("path"));
|
|
29636
29771
|
|
|
29637
29772
|
// src/services/history.service.ts
|
|
29638
|
-
var
|
|
29639
|
-
var
|
|
29773
|
+
var fs67 = __toESM(require("fs"));
|
|
29774
|
+
var path74 = __toESM(require("path"));
|
|
29640
29775
|
var os56 = __toESM(require("os"));
|
|
29641
29776
|
var https7 = __toESM(require("https"));
|
|
29642
29777
|
var http6 = __toESM(require("http"));
|
|
@@ -29678,7 +29813,7 @@ function parseJsonl(filePath) {
|
|
|
29678
29813
|
const messages = [];
|
|
29679
29814
|
let raw;
|
|
29680
29815
|
try {
|
|
29681
|
-
raw =
|
|
29816
|
+
raw = fs67.readFileSync(filePath, "utf8");
|
|
29682
29817
|
} catch (err) {
|
|
29683
29818
|
if (err.code !== "ENOENT") {
|
|
29684
29819
|
log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
|
|
@@ -29823,7 +29958,7 @@ var HistoryService = class _HistoryService {
|
|
|
29823
29958
|
return this._quotaPercent === null || Date.now() - this._quotaFetchedAt > ttlMs;
|
|
29824
29959
|
}
|
|
29825
29960
|
get projectDir() {
|
|
29826
|
-
return this.runtime.resolveHistoryDir(this.cwd) ??
|
|
29961
|
+
return this.runtime.resolveHistoryDir(this.cwd) ?? path74.join(os56.homedir(), ".claude", "projects", encodeCwd(this.cwd));
|
|
29827
29962
|
}
|
|
29828
29963
|
/** Set the current Claude conversation ID (extracted from /cost command or session start) */
|
|
29829
29964
|
setCurrentConversationId(id) {
|
|
@@ -29835,7 +29970,7 @@ var HistoryService = class _HistoryService {
|
|
|
29835
29970
|
/** Return the current message count in the active conversation. */
|
|
29836
29971
|
getCurrentMessageCount() {
|
|
29837
29972
|
if (!this.currentConversationId) return 0;
|
|
29838
|
-
const filePath =
|
|
29973
|
+
const filePath = path74.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
29839
29974
|
return parseJsonl(filePath).length;
|
|
29840
29975
|
}
|
|
29841
29976
|
/**
|
|
@@ -29846,7 +29981,7 @@ var HistoryService = class _HistoryService {
|
|
|
29846
29981
|
const deadline = Date.now() + timeoutMs;
|
|
29847
29982
|
while (Date.now() < deadline) {
|
|
29848
29983
|
if (!this.currentConversationId) return null;
|
|
29849
|
-
const filePath =
|
|
29984
|
+
const filePath = path74.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
29850
29985
|
const messages = parseJsonl(filePath);
|
|
29851
29986
|
if (messages.length > previousCount) {
|
|
29852
29987
|
for (let i = messages.length - 1; i >= previousCount; i--) {
|
|
@@ -29872,16 +30007,16 @@ var HistoryService = class _HistoryService {
|
|
|
29872
30007
|
const dir = this.projectDir;
|
|
29873
30008
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
29874
30009
|
try {
|
|
29875
|
-
const files =
|
|
30010
|
+
const files = fs67.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
29876
30011
|
try {
|
|
29877
|
-
const stat3 =
|
|
30012
|
+
const stat3 = fs67.statSync(path74.join(dir, e.name));
|
|
29878
30013
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
29879
30014
|
} catch {
|
|
29880
30015
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
29881
30016
|
}
|
|
29882
30017
|
}).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
29883
30018
|
if (files.length > 0) {
|
|
29884
|
-
this.currentConversationId =
|
|
30019
|
+
this.currentConversationId = path74.basename(files[0].name, ".jsonl");
|
|
29885
30020
|
}
|
|
29886
30021
|
} catch {
|
|
29887
30022
|
}
|
|
@@ -29915,13 +30050,13 @@ var HistoryService = class _HistoryService {
|
|
|
29915
30050
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
29916
30051
|
let entries;
|
|
29917
30052
|
try {
|
|
29918
|
-
entries =
|
|
30053
|
+
entries = fs67.readdirSync(dir, { withFileTypes: true });
|
|
29919
30054
|
} catch {
|
|
29920
30055
|
return null;
|
|
29921
30056
|
}
|
|
29922
30057
|
const files = entries.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
29923
30058
|
try {
|
|
29924
|
-
const stat3 =
|
|
30059
|
+
const stat3 = fs67.statSync(path74.join(dir, e.name));
|
|
29925
30060
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
29926
30061
|
} catch {
|
|
29927
30062
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -29930,12 +30065,12 @@ var HistoryService = class _HistoryService {
|
|
|
29930
30065
|
if (files.length === 0) return null;
|
|
29931
30066
|
const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
|
|
29932
30067
|
if (!files.some((f) => f.name === targetFile)) return null;
|
|
29933
|
-
return this.extractUsageFromFile(
|
|
30068
|
+
return this.extractUsageFromFile(path74.join(dir, targetFile));
|
|
29934
30069
|
}
|
|
29935
30070
|
extractUsageFromFile(filePath) {
|
|
29936
30071
|
let raw;
|
|
29937
30072
|
try {
|
|
29938
|
-
raw =
|
|
30073
|
+
raw = fs67.readFileSync(filePath, "utf8");
|
|
29939
30074
|
} catch {
|
|
29940
30075
|
return null;
|
|
29941
30076
|
}
|
|
@@ -29987,9 +30122,9 @@ var HistoryService = class _HistoryService {
|
|
|
29987
30122
|
let totalCost = 0;
|
|
29988
30123
|
let files;
|
|
29989
30124
|
try {
|
|
29990
|
-
files =
|
|
30125
|
+
files = fs67.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
|
|
29991
30126
|
try {
|
|
29992
|
-
return
|
|
30127
|
+
return fs67.statSync(path74.join(projectDir, f)).mtimeMs >= monthStartMs;
|
|
29993
30128
|
} catch {
|
|
29994
30129
|
return false;
|
|
29995
30130
|
}
|
|
@@ -30000,7 +30135,7 @@ var HistoryService = class _HistoryService {
|
|
|
30000
30135
|
for (const file of files) {
|
|
30001
30136
|
let raw;
|
|
30002
30137
|
try {
|
|
30003
|
-
raw =
|
|
30138
|
+
raw = fs67.readFileSync(path74.join(projectDir, file), "utf8");
|
|
30004
30139
|
} catch {
|
|
30005
30140
|
continue;
|
|
30006
30141
|
}
|
|
@@ -30079,7 +30214,7 @@ var HistoryService = class _HistoryService {
|
|
|
30079
30214
|
if (this.runtime.resolveHistoryFile) {
|
|
30080
30215
|
return this.runtime.resolveHistoryFile(this.cwd, sessionId);
|
|
30081
30216
|
}
|
|
30082
|
-
return
|
|
30217
|
+
return path74.join(this.projectDir, `${sessionId}.jsonl`);
|
|
30083
30218
|
}
|
|
30084
30219
|
/**
|
|
30085
30220
|
* Parse a conversation's messages from disk, agent-aware. Claude uses the
|
|
@@ -30117,7 +30252,7 @@ var HistoryService = class _HistoryService {
|
|
|
30117
30252
|
};
|
|
30118
30253
|
});
|
|
30119
30254
|
}
|
|
30120
|
-
return parseJsonl(
|
|
30255
|
+
return parseJsonl(path74.join(this.projectDir, `${sessionId}.jsonl`));
|
|
30121
30256
|
}
|
|
30122
30257
|
async loadConversation(sessionId) {
|
|
30123
30258
|
const messages = this.readConversation(sessionId);
|
|
@@ -30187,7 +30322,7 @@ var HistoryService = class _HistoryService {
|
|
|
30187
30322
|
if (!filePath) return false;
|
|
30188
30323
|
let mtimeMs;
|
|
30189
30324
|
try {
|
|
30190
|
-
mtimeMs =
|
|
30325
|
+
mtimeMs = fs67.statSync(filePath).mtimeMs;
|
|
30191
30326
|
} catch {
|
|
30192
30327
|
return false;
|
|
30193
30328
|
}
|
|
@@ -30262,10 +30397,10 @@ var HistoryService = class _HistoryService {
|
|
|
30262
30397
|
|
|
30263
30398
|
// src/agents/acp/client.ts
|
|
30264
30399
|
var import_node_child_process29 = require("child_process");
|
|
30265
|
-
var
|
|
30400
|
+
var fs68 = __toESM(require("fs/promises"));
|
|
30266
30401
|
var fsSync = __toESM(require("fs"));
|
|
30267
30402
|
var os58 = __toESM(require("os"));
|
|
30268
|
-
var
|
|
30403
|
+
var path76 = __toESM(require("path"));
|
|
30269
30404
|
var import_node_stream = require("stream");
|
|
30270
30405
|
|
|
30271
30406
|
// ../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
@@ -34291,7 +34426,7 @@ function createIdleTimeout(idleMs, makeError, activeIdleMs = idleMs) {
|
|
|
34291
34426
|
}
|
|
34292
34427
|
|
|
34293
34428
|
// src/agents/acp/internal-paths.ts
|
|
34294
|
-
var
|
|
34429
|
+
var path75 = __toESM(require("path"));
|
|
34295
34430
|
var os57 = __toESM(require("os"));
|
|
34296
34431
|
var INTERNAL_TOKENS = [".codeam", "house-claude"];
|
|
34297
34432
|
var PROSE_ONLY_TOOL_KINDS = /* @__PURE__ */ new Set(["think", "switch_mode"]);
|
|
@@ -34306,11 +34441,11 @@ function textReferencesInternal(text) {
|
|
|
34306
34441
|
}
|
|
34307
34442
|
function pathIsInternal(p2, homeDir2 = os57.homedir()) {
|
|
34308
34443
|
if (!p2) return false;
|
|
34309
|
-
const abs =
|
|
34310
|
-
const home =
|
|
34311
|
-
const within = (root) => abs === root || abs.startsWith(root +
|
|
34312
|
-
if (within(
|
|
34313
|
-
return within(
|
|
34444
|
+
const abs = path75.resolve(p2);
|
|
34445
|
+
const home = path75.resolve(homeDir2);
|
|
34446
|
+
const within = (root) => abs === root || abs.startsWith(root + path75.sep);
|
|
34447
|
+
if (within(path75.join(home, ".codeam", "self-hosted"))) return false;
|
|
34448
|
+
return within(path75.join(home, ".codeam")) || within(path75.join(home, ".beads")) || abs === path75.join(home, ".codeam-host.log") || abs.includes(`${path75.sep}house-claude${path75.sep}`) || abs.endsWith(`${path75.sep}house-claude`);
|
|
34314
34449
|
}
|
|
34315
34450
|
function toolCallReferencesInternal(call, homeDir2) {
|
|
34316
34451
|
if (call.locations?.some((l) => pathIsInternal(l.path, homeDir2))) return true;
|
|
@@ -35285,7 +35420,7 @@ var AcpClient = class {
|
|
|
35285
35420
|
throw new RequestError(-32002, GUARDRAIL_SECRET_READ_BLOCK_REASON, { uri: params.path });
|
|
35286
35421
|
}
|
|
35287
35422
|
try {
|
|
35288
|
-
const content = await
|
|
35423
|
+
const content = await fs68.readFile(params.path, "utf8");
|
|
35289
35424
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
35290
35425
|
} catch (err) {
|
|
35291
35426
|
const code = err.code;
|
|
@@ -35306,7 +35441,7 @@ var AcpClient = class {
|
|
|
35306
35441
|
throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
|
|
35307
35442
|
}
|
|
35308
35443
|
try {
|
|
35309
|
-
await
|
|
35444
|
+
await fs68.writeFile(params.path, params.content, "utf8");
|
|
35310
35445
|
return {};
|
|
35311
35446
|
} catch (err) {
|
|
35312
35447
|
const code = err.code;
|
|
@@ -35399,25 +35534,25 @@ function knownAgentBinaryDirs() {
|
|
|
35399
35534
|
out2.push("/tmp/codeam-node20/bin");
|
|
35400
35535
|
for (const root of [
|
|
35401
35536
|
"/usr/local/share/nvm/versions/node",
|
|
35402
|
-
|
|
35537
|
+
path76.join(home, ".nvm/versions/node")
|
|
35403
35538
|
]) {
|
|
35404
35539
|
try {
|
|
35405
35540
|
for (const child of fsSync.readdirSync(root)) {
|
|
35406
|
-
out2.push(
|
|
35541
|
+
out2.push(path76.join(root, child, "bin"));
|
|
35407
35542
|
}
|
|
35408
35543
|
} catch {
|
|
35409
35544
|
}
|
|
35410
35545
|
}
|
|
35411
|
-
out2.push(
|
|
35546
|
+
out2.push(path76.join(home, ".volta/bin"));
|
|
35412
35547
|
out2.push("/usr/local/bin");
|
|
35413
35548
|
out2.push("/usr/bin");
|
|
35414
|
-
out2.push(
|
|
35415
|
-
out2.push(
|
|
35549
|
+
out2.push(path76.join(home, ".local/bin"));
|
|
35550
|
+
out2.push(path76.join(home, "bin"));
|
|
35416
35551
|
out2.push(...agentInstallBinDirs());
|
|
35417
35552
|
if (process.platform === "win32") {
|
|
35418
35553
|
const { LOCALAPPDATA, APPDATA } = process.env;
|
|
35419
|
-
if (LOCALAPPDATA) out2.push(
|
|
35420
|
-
if (APPDATA) out2.push(
|
|
35554
|
+
if (LOCALAPPDATA) out2.push(path76.join(LOCALAPPDATA, "cursor-agent"));
|
|
35555
|
+
if (APPDATA) out2.push(path76.join(APPDATA, "npm"));
|
|
35421
35556
|
}
|
|
35422
35557
|
return out2.filter((p2) => {
|
|
35423
35558
|
try {
|
|
@@ -35428,7 +35563,7 @@ function knownAgentBinaryDirs() {
|
|
|
35428
35563
|
});
|
|
35429
35564
|
}
|
|
35430
35565
|
function expandPathForAgentBinaries(existingPath) {
|
|
35431
|
-
const existing = new Set(existingPath.split(
|
|
35566
|
+
const existing = new Set(existingPath.split(path76.delimiter).filter((p2) => p2.length > 0));
|
|
35432
35567
|
const additions = [];
|
|
35433
35568
|
for (const dir of knownAgentBinaryDirs()) {
|
|
35434
35569
|
if (!existing.has(dir)) {
|
|
@@ -35437,7 +35572,7 @@ function expandPathForAgentBinaries(existingPath) {
|
|
|
35437
35572
|
}
|
|
35438
35573
|
}
|
|
35439
35574
|
if (additions.length === 0) return existingPath;
|
|
35440
|
-
return [...additions, existingPath].filter((p2) => p2.length > 0).join(
|
|
35575
|
+
return [...additions, existingPath].filter((p2) => p2.length > 0).join(path76.delimiter);
|
|
35441
35576
|
}
|
|
35442
35577
|
|
|
35443
35578
|
// src/agents/acp/headroom-budget-proxy.ts
|
|
@@ -36360,15 +36495,15 @@ function withholdTrailingPartialFenceMarker(text) {
|
|
|
36360
36495
|
|
|
36361
36496
|
// src/agents/acp/onboarding.ts
|
|
36362
36497
|
var import_child_process29 = require("child_process");
|
|
36363
|
-
var
|
|
36498
|
+
var fs69 = __toESM(require("fs"));
|
|
36364
36499
|
var os59 = __toESM(require("os"));
|
|
36365
|
-
var
|
|
36500
|
+
var path77 = __toESM(require("path"));
|
|
36366
36501
|
var _onboardingSeam = {
|
|
36367
|
-
markerPath: (sessionId) =>
|
|
36368
|
-
exists: (p2) =>
|
|
36502
|
+
markerPath: (sessionId) => path77.join(os59.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
36503
|
+
exists: (p2) => fs69.existsSync(p2),
|
|
36369
36504
|
write: (p2) => {
|
|
36370
|
-
|
|
36371
|
-
|
|
36505
|
+
fs69.mkdirSync(path77.dirname(p2), { recursive: true });
|
|
36506
|
+
fs69.writeFileSync(p2, "");
|
|
36372
36507
|
},
|
|
36373
36508
|
disabled: () => {
|
|
36374
36509
|
const v = process.env.CODEAM_ONBOARDING_DISABLED;
|
|
@@ -36405,7 +36540,7 @@ function resolveRepoName(cwd) {
|
|
|
36405
36540
|
if (name) return name;
|
|
36406
36541
|
}
|
|
36407
36542
|
}
|
|
36408
|
-
const base =
|
|
36543
|
+
const base = path77.basename(cwd || "");
|
|
36409
36544
|
if (base && !isUuid(base)) return base;
|
|
36410
36545
|
return "this project";
|
|
36411
36546
|
}
|
|
@@ -36737,13 +36872,13 @@ var import_crypto5 = require("crypto");
|
|
|
36737
36872
|
|
|
36738
36873
|
// src/services/turn-files/git-changeset.ts
|
|
36739
36874
|
var import_child_process30 = require("child_process");
|
|
36740
|
-
var
|
|
36741
|
-
var
|
|
36875
|
+
var fs71 = __toESM(require("fs/promises"));
|
|
36876
|
+
var path79 = __toESM(require("path"));
|
|
36742
36877
|
|
|
36743
36878
|
// src/services/turn-files/review-ignore.ts
|
|
36744
36879
|
var import_ignore2 = __toESM(require("ignore"));
|
|
36745
|
-
var
|
|
36746
|
-
var
|
|
36880
|
+
var fs70 = __toESM(require("fs"));
|
|
36881
|
+
var path78 = __toESM(require("path"));
|
|
36747
36882
|
var CURATED_REVIEW_IGNORE = [
|
|
36748
36883
|
// Google Cloud SDK (the incident) — installs a huge python tree.
|
|
36749
36884
|
"google-cloud-sdk/",
|
|
@@ -36782,7 +36917,7 @@ var CURATED_REVIEW_IGNORE = [
|
|
|
36782
36917
|
function makeReviewIgnore(repoRoot) {
|
|
36783
36918
|
const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
|
|
36784
36919
|
try {
|
|
36785
|
-
const custom =
|
|
36920
|
+
const custom = fs70.readFileSync(path78.join(repoRoot, ".codeam", "reviewignore"), "utf8");
|
|
36786
36921
|
ig.add(custom);
|
|
36787
36922
|
} catch {
|
|
36788
36923
|
}
|
|
@@ -36827,7 +36962,7 @@ async function collectRepoChangeset(opts) {
|
|
|
36827
36962
|
let stats;
|
|
36828
36963
|
if (!truncated && row.fileStatus === "added" && numstatEntry === void 0) {
|
|
36829
36964
|
const lineCount = await readUntrackedLineCount(
|
|
36830
|
-
|
|
36965
|
+
path79.join(opts.repoRoot, row.filePath)
|
|
36831
36966
|
);
|
|
36832
36967
|
stats = { added: lineCount, removed: 0 };
|
|
36833
36968
|
} else {
|
|
@@ -36858,7 +36993,7 @@ function readUntrackedLineCount(absPath) {
|
|
|
36858
36993
|
}
|
|
36859
36994
|
async function defaultReadUntrackedLineCount(absPath) {
|
|
36860
36995
|
try {
|
|
36861
|
-
const content = await
|
|
36996
|
+
const content = await fs71.readFile(absPath, "utf8");
|
|
36862
36997
|
let count = 0;
|
|
36863
36998
|
let pos = -1;
|
|
36864
36999
|
while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
|
|
@@ -36950,7 +37085,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
36950
37085
|
});
|
|
36951
37086
|
}
|
|
36952
37087
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
36953
|
-
const
|
|
37088
|
+
const fs83 = await import("fs/promises");
|
|
36954
37089
|
const out2 = [];
|
|
36955
37090
|
await walk(workingDir, 0);
|
|
36956
37091
|
return out2;
|
|
@@ -36958,7 +37093,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
36958
37093
|
if (depth > maxDepth) return;
|
|
36959
37094
|
let entries = [];
|
|
36960
37095
|
try {
|
|
36961
|
-
const dirents = await
|
|
37096
|
+
const dirents = await fs83.readdir(dir, { withFileTypes: true });
|
|
36962
37097
|
entries = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
36963
37098
|
} catch {
|
|
36964
37099
|
return;
|
|
@@ -36969,8 +37104,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
36969
37104
|
if (hasGit) {
|
|
36970
37105
|
out2.push({
|
|
36971
37106
|
repoRoot: dir,
|
|
36972
|
-
repoPath:
|
|
36973
|
-
repoName:
|
|
37107
|
+
repoPath: path79.relative(workingDir, dir),
|
|
37108
|
+
repoName: path79.basename(dir)
|
|
36974
37109
|
});
|
|
36975
37110
|
return;
|
|
36976
37111
|
}
|
|
@@ -36978,14 +37113,14 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
36978
37113
|
if (!entry.isDirectory) continue;
|
|
36979
37114
|
if (entry.name === "node_modules") continue;
|
|
36980
37115
|
if (entry.name === "dist" || entry.name === "build") continue;
|
|
36981
|
-
await walk(
|
|
37116
|
+
await walk(path79.join(dir, entry.name), depth + 1);
|
|
36982
37117
|
}
|
|
36983
37118
|
}
|
|
36984
37119
|
}
|
|
36985
37120
|
|
|
36986
37121
|
// src/services/turn-files/files-outbox.ts
|
|
36987
|
-
var
|
|
36988
|
-
var
|
|
37122
|
+
var fs72 = __toESM(require("fs/promises"));
|
|
37123
|
+
var path80 = __toESM(require("path"));
|
|
36989
37124
|
var import_os12 = require("os");
|
|
36990
37125
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
36991
37126
|
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -37018,16 +37153,16 @@ var FilesOutbox = class {
|
|
|
37018
37153
|
backoffIndex = 0;
|
|
37019
37154
|
stopped = false;
|
|
37020
37155
|
constructor(opts) {
|
|
37021
|
-
const base = opts.baseDir ??
|
|
37022
|
-
this.filePath =
|
|
37156
|
+
const base = opts.baseDir ?? path80.join(homeDir(), HOME_OUTBOX_DIR);
|
|
37157
|
+
this.filePath = path80.join(base, `${opts.sessionId}.jsonl`);
|
|
37023
37158
|
this.post = opts.post;
|
|
37024
37159
|
this.autoSchedule = opts.autoSchedule !== false;
|
|
37025
37160
|
}
|
|
37026
37161
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
37027
37162
|
* line is durable on disk (not once the POST succeeds). */
|
|
37028
37163
|
async enqueue(entry) {
|
|
37029
|
-
await
|
|
37030
|
-
await
|
|
37164
|
+
await fs72.mkdir(path80.dirname(this.filePath), { recursive: true });
|
|
37165
|
+
await fs72.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
37031
37166
|
this.backoffIndex = 0;
|
|
37032
37167
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
37033
37168
|
}
|
|
@@ -37118,7 +37253,7 @@ var FilesOutbox = class {
|
|
|
37118
37253
|
async readAll() {
|
|
37119
37254
|
let raw = "";
|
|
37120
37255
|
try {
|
|
37121
|
-
raw = await
|
|
37256
|
+
raw = await fs72.readFile(this.filePath, "utf8");
|
|
37122
37257
|
} catch {
|
|
37123
37258
|
return [];
|
|
37124
37259
|
}
|
|
@@ -37142,12 +37277,12 @@ var FilesOutbox = class {
|
|
|
37142
37277
|
async rewrite(entries) {
|
|
37143
37278
|
const tmpPath = `${this.filePath}.${process.pid}.tmp`;
|
|
37144
37279
|
if (entries.length === 0) {
|
|
37145
|
-
await
|
|
37280
|
+
await fs72.unlink(this.filePath).catch(() => void 0);
|
|
37146
37281
|
return;
|
|
37147
37282
|
}
|
|
37148
37283
|
const payload = entries.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
37149
|
-
await
|
|
37150
|
-
await
|
|
37284
|
+
await fs72.writeFile(tmpPath, payload, "utf8");
|
|
37285
|
+
await fs72.rename(tmpPath, this.filePath);
|
|
37151
37286
|
}
|
|
37152
37287
|
};
|
|
37153
37288
|
function applyJitter(ms) {
|
|
@@ -37458,11 +37593,11 @@ function replyIsAuthFailure(finalText) {
|
|
|
37458
37593
|
}
|
|
37459
37594
|
function replyIsHouseAgentLimit(finalText) {
|
|
37460
37595
|
const t2 = finalText.trim();
|
|
37461
|
-
return t2.length > 0 && t2.length <=
|
|
37596
|
+
return t2.length > 0 && t2.length <= 400 && looksLikeHouseAgentLimit(t2);
|
|
37462
37597
|
}
|
|
37463
37598
|
function houseAgentLimitMessage(text) {
|
|
37464
37599
|
if (/temporarily (?:unavailable|disabled)/i.test(text)) {
|
|
37465
|
-
return "\u23F3 **CodeAgent Cloud is temporarily unavailable
|
|
37600
|
+
return "\u23F3 **CodeAgent Cloud is temporarily unavailable \u2014 this one\u2019s on us, not your account.**\n\nThere\u2019s nothing to buy and nothing owed, and it isn\u2019t a problem with your login, so re-authenticating won\u2019t help. Send your message again in a bit, or connect your own agent (Claude Code, Codex, Cursor, Gemini) in **Profile \u203A Agents** to keep going now.";
|
|
37466
37601
|
}
|
|
37467
37602
|
const canUpgrade = /upgrade to pro/i.test(text);
|
|
37468
37603
|
return "\u{1F4CA} **You\u2019ve reached your daily CodeAgent Cloud limit.**\n\nThe free CodeAgent Cloud agent has a daily usage ceiling that resets at midnight UTC. This is a usage limit, not a problem with your login \u2014 re-authenticating won\u2019t change it. " + (canUpgrade ? "To keep going now, upgrade to **Pro** for a higher ceiling, or connect your own agent (Claude, Codex, \u2026) in **Profile \u203A Agents** to run without this limit." : "To keep going now, connect your own agent (Claude, Codex, \u2026) in **Profile \u203A Agents** to run without this limit, or wait for the reset.");
|
|
@@ -37664,8 +37799,8 @@ async function postBudgetReached(opts, fetchImpl = fetch) {
|
|
|
37664
37799
|
|
|
37665
37800
|
// src/packs/gates.ts
|
|
37666
37801
|
var import_node_child_process30 = require("child_process");
|
|
37667
|
-
var
|
|
37668
|
-
var
|
|
37802
|
+
var fs73 = __toESM(require("fs"));
|
|
37803
|
+
var path81 = __toESM(require("path"));
|
|
37669
37804
|
var defaultCommandRunner = (file, args2, cwd, timeoutMs) => new Promise((resolve10) => {
|
|
37670
37805
|
(0, import_node_child_process30.execFile)(
|
|
37671
37806
|
file,
|
|
@@ -37702,14 +37837,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
|
|
|
37702
37837
|
var CHECKS_TIMEOUT_MS = 5 * 6e4;
|
|
37703
37838
|
function detectChecksCommand(cwd) {
|
|
37704
37839
|
try {
|
|
37705
|
-
const cfg = JSON.parse(
|
|
37840
|
+
const cfg = JSON.parse(fs73.readFileSync(path81.join(cwd, ".codeam", "pack.json"), "utf8"));
|
|
37706
37841
|
if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
|
|
37707
37842
|
return cfg.checksCommand.trim();
|
|
37708
37843
|
}
|
|
37709
37844
|
} catch {
|
|
37710
37845
|
}
|
|
37711
37846
|
try {
|
|
37712
|
-
const pkg = JSON.parse(
|
|
37847
|
+
const pkg = JSON.parse(fs73.readFileSync(path81.join(cwd, "package.json"), "utf8"));
|
|
37713
37848
|
const test = pkg.scripts?.test;
|
|
37714
37849
|
if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
|
|
37715
37850
|
return "npm test";
|
|
@@ -37727,39 +37862,39 @@ ${res.stderr}`.trim();
|
|
|
37727
37862
|
}
|
|
37728
37863
|
|
|
37729
37864
|
// src/packs/run-store.ts
|
|
37730
|
-
var
|
|
37731
|
-
var
|
|
37865
|
+
var fs74 = __toESM(require("fs"));
|
|
37866
|
+
var path82 = __toESM(require("path"));
|
|
37732
37867
|
var crypto5 = __toESM(require("crypto"));
|
|
37733
37868
|
function packsDir(cwd) {
|
|
37734
|
-
return
|
|
37869
|
+
return path82.join(cwd, ".codeam", "packs");
|
|
37735
37870
|
}
|
|
37736
37871
|
function runDir(cwd, runId) {
|
|
37737
|
-
return
|
|
37872
|
+
return path82.join(packsDir(cwd), runId);
|
|
37738
37873
|
}
|
|
37739
37874
|
function newRunId() {
|
|
37740
37875
|
return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
|
|
37741
37876
|
}
|
|
37742
37877
|
function writeJsonAtomic(file, value) {
|
|
37743
|
-
|
|
37878
|
+
fs74.mkdirSync(path82.dirname(file), { recursive: true });
|
|
37744
37879
|
const tmp = `${file}.tmp`;
|
|
37745
|
-
|
|
37746
|
-
|
|
37880
|
+
fs74.writeFileSync(tmp, JSON.stringify(value, null, 2));
|
|
37881
|
+
fs74.renameSync(tmp, file);
|
|
37747
37882
|
}
|
|
37748
37883
|
function saveRun(cwd, state) {
|
|
37749
|
-
writeJsonAtomic(
|
|
37884
|
+
writeJsonAtomic(path82.join(runDir(cwd, state.runId), "run.json"), state);
|
|
37750
37885
|
}
|
|
37751
37886
|
function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
|
|
37752
37887
|
const name = `${String(stageIndex + 1).padStart(2, "0")}-${role}.json`;
|
|
37753
|
-
writeJsonAtomic(
|
|
37888
|
+
writeJsonAtomic(path82.join(runDir(cwd, runId), name), handoff);
|
|
37754
37889
|
}
|
|
37755
37890
|
function loadLatestRun(cwd) {
|
|
37756
37891
|
try {
|
|
37757
37892
|
const dir = packsDir(cwd);
|
|
37758
|
-
const entries =
|
|
37893
|
+
const entries = fs74.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
37759
37894
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
37760
|
-
const file =
|
|
37895
|
+
const file = path82.join(dir, entries[i], "run.json");
|
|
37761
37896
|
try {
|
|
37762
|
-
const parsed = JSON.parse(
|
|
37897
|
+
const parsed = JSON.parse(fs74.readFileSync(file, "utf8"));
|
|
37763
37898
|
if (parsed && typeof parsed.runId === "string") return parsed;
|
|
37764
37899
|
} catch {
|
|
37765
37900
|
}
|
|
@@ -37770,17 +37905,17 @@ function loadLatestRun(cwd) {
|
|
|
37770
37905
|
}
|
|
37771
37906
|
function ensureLedgerIgnored(cwd) {
|
|
37772
37907
|
try {
|
|
37773
|
-
const gitDir =
|
|
37774
|
-
if (!
|
|
37775
|
-
const exclude =
|
|
37908
|
+
const gitDir = path82.join(cwd, ".git");
|
|
37909
|
+
if (!fs74.existsSync(gitDir)) return;
|
|
37910
|
+
const exclude = path82.join(gitDir, "info", "exclude");
|
|
37776
37911
|
let existing = "";
|
|
37777
37912
|
try {
|
|
37778
|
-
existing =
|
|
37913
|
+
existing = fs74.readFileSync(exclude, "utf8");
|
|
37779
37914
|
} catch {
|
|
37780
37915
|
}
|
|
37781
37916
|
if (existing.includes(".codeam/packs/")) return;
|
|
37782
|
-
|
|
37783
|
-
|
|
37917
|
+
fs74.mkdirSync(path82.dirname(exclude), { recursive: true });
|
|
37918
|
+
fs74.writeFileSync(exclude, `${existing.trimEnd()}
|
|
37784
37919
|
.codeam/packs/
|
|
37785
37920
|
`.trimStart());
|
|
37786
37921
|
} catch {
|
|
@@ -38533,35 +38668,35 @@ function buildAcpPromptBlocks(payload) {
|
|
|
38533
38668
|
}
|
|
38534
38669
|
|
|
38535
38670
|
// src/agents/agent-standard.ts
|
|
38536
|
-
var
|
|
38537
|
-
var
|
|
38671
|
+
var fs77 = __toESM(require("fs"));
|
|
38672
|
+
var path85 = __toESM(require("path"));
|
|
38538
38673
|
var os61 = __toESM(require("os"));
|
|
38539
38674
|
function ensureAgentStandard(homeDir2 = os61.homedir()) {
|
|
38540
38675
|
try {
|
|
38541
|
-
const file =
|
|
38676
|
+
const file = path85.join(homeDir2, ".claude", "CLAUDE.md");
|
|
38542
38677
|
let existing = "";
|
|
38543
38678
|
try {
|
|
38544
|
-
existing =
|
|
38679
|
+
existing = fs77.readFileSync(file, "utf8");
|
|
38545
38680
|
} catch {
|
|
38546
38681
|
}
|
|
38547
38682
|
if (existing.includes(AGENT_STANDARD_MARKER)) return;
|
|
38548
|
-
|
|
38683
|
+
fs77.mkdirSync(path85.dirname(file), { recursive: true });
|
|
38549
38684
|
const next = existing.trim() ? `${existing.trimEnd()}
|
|
38550
38685
|
|
|
38551
38686
|
${AGENT_STANDARD_BLOCK}
|
|
38552
38687
|
` : `${AGENT_STANDARD_BLOCK}
|
|
38553
38688
|
`;
|
|
38554
|
-
|
|
38689
|
+
fs77.writeFileSync(file, next);
|
|
38555
38690
|
} catch {
|
|
38556
38691
|
}
|
|
38557
38692
|
}
|
|
38558
38693
|
var _agentStandardSeam = {
|
|
38559
38694
|
isLocalSession: () => isLocalSession(),
|
|
38560
|
-
markerPath: (sessionId) =>
|
|
38561
|
-
exists: (p2) =>
|
|
38695
|
+
markerPath: (sessionId) => path85.join(os61.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
|
|
38696
|
+
exists: (p2) => fs77.existsSync(p2),
|
|
38562
38697
|
write: (p2) => {
|
|
38563
|
-
|
|
38564
|
-
|
|
38698
|
+
fs77.mkdirSync(path85.dirname(p2), { recursive: true });
|
|
38699
|
+
fs77.writeFileSync(p2, "");
|
|
38565
38700
|
}
|
|
38566
38701
|
};
|
|
38567
38702
|
function isClaude(agent) {
|
|
@@ -40624,14 +40759,14 @@ async function runAcpSession(opts) {
|
|
|
40624
40759
|
switchCredentialEnv = provisionAgentCredentials(agentId, auth);
|
|
40625
40760
|
},
|
|
40626
40761
|
provisionHouseProxy: ({ baseUrl, token }) => {
|
|
40627
|
-
const claudeConfigDir =
|
|
40762
|
+
const claudeConfigDir = path86.join(
|
|
40628
40763
|
os62.homedir(),
|
|
40629
40764
|
".codeam",
|
|
40630
40765
|
"house-claude",
|
|
40631
40766
|
`switch-${opts.pluginId}`
|
|
40632
40767
|
);
|
|
40633
40768
|
try {
|
|
40634
|
-
|
|
40769
|
+
fs78.mkdirSync(claudeConfigDir, { recursive: true, mode: 448 });
|
|
40635
40770
|
} catch {
|
|
40636
40771
|
}
|
|
40637
40772
|
houseEnv = buildHouseProxyChildEnv({ baseUrl, token, claudeConfigDir });
|
|
@@ -41833,8 +41968,8 @@ function startClaudeCredentialSync(opts) {
|
|
|
41833
41968
|
}
|
|
41834
41969
|
|
|
41835
41970
|
// src/beads/workflow-hint.ts
|
|
41836
|
-
var
|
|
41837
|
-
var
|
|
41971
|
+
var fs79 = __toESM(require("fs"));
|
|
41972
|
+
var path87 = __toESM(require("path"));
|
|
41838
41973
|
var os63 = __toESM(require("os"));
|
|
41839
41974
|
var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
|
|
41840
41975
|
var BEADS_HINT = `${BEADS_HINT_MARKER}
|
|
@@ -41851,20 +41986,20 @@ This environment uses **bd (beads)** for issue/task tracking and persistent memo
|
|
|
41851
41986
|
${BEADS_HINT_MARKER}`;
|
|
41852
41987
|
function ensureBeadsWorkflowHint(homeDir2 = os63.homedir()) {
|
|
41853
41988
|
try {
|
|
41854
|
-
const file =
|
|
41989
|
+
const file = path87.join(homeDir2, ".claude", "CLAUDE.md");
|
|
41855
41990
|
let existing = "";
|
|
41856
41991
|
try {
|
|
41857
|
-
existing =
|
|
41992
|
+
existing = fs79.readFileSync(file, "utf8");
|
|
41858
41993
|
} catch {
|
|
41859
41994
|
}
|
|
41860
41995
|
if (existing.includes(BEADS_HINT_MARKER)) return;
|
|
41861
|
-
|
|
41996
|
+
fs79.mkdirSync(path87.dirname(file), { recursive: true });
|
|
41862
41997
|
const next = existing.trim() ? `${existing.trimEnd()}
|
|
41863
41998
|
|
|
41864
41999
|
${BEADS_HINT}
|
|
41865
42000
|
` : `${BEADS_HINT}
|
|
41866
42001
|
`;
|
|
41867
|
-
|
|
42002
|
+
fs79.writeFileSync(file, next);
|
|
41868
42003
|
} catch {
|
|
41869
42004
|
}
|
|
41870
42005
|
}
|
|
@@ -42162,9 +42297,9 @@ var NativeTuiDriver = class _NativeTuiDriver {
|
|
|
42162
42297
|
armSwitchWatch(currentId) {
|
|
42163
42298
|
this.unwatchSwitch?.();
|
|
42164
42299
|
this.unwatchSwitch = null;
|
|
42165
|
-
const
|
|
42166
|
-
if (!
|
|
42167
|
-
this.unwatchSwitch =
|
|
42300
|
+
const watch4 = this.deps.runtime.watchConversationSwitch;
|
|
42301
|
+
if (!watch4) return;
|
|
42302
|
+
this.unwatchSwitch = watch4(this.deps.opts.cwd, { currentId }, (id) => {
|
|
42168
42303
|
this.historySvc.setCurrentConversationId(id);
|
|
42169
42304
|
this.deps.onConversationSwitch?.(id);
|
|
42170
42305
|
});
|
|
@@ -42375,7 +42510,7 @@ var AcpDriver = class {
|
|
|
42375
42510
|
};
|
|
42376
42511
|
|
|
42377
42512
|
// src/baton/transcript-mirror.ts
|
|
42378
|
-
var
|
|
42513
|
+
var fs80 = __toESM(require("fs"));
|
|
42379
42514
|
var TranscriptMirror = class {
|
|
42380
42515
|
constructor(deps) {
|
|
42381
42516
|
this.deps = deps;
|
|
@@ -42418,8 +42553,8 @@ var TranscriptMirror = class {
|
|
|
42418
42553
|
if (!file) return false;
|
|
42419
42554
|
this.attached = true;
|
|
42420
42555
|
this.emit(file);
|
|
42421
|
-
const
|
|
42422
|
-
this.unwatch =
|
|
42556
|
+
const watch4 = this.deps.watch ?? defaultWatch;
|
|
42557
|
+
this.unwatch = watch4(file, () => this.emit(file));
|
|
42423
42558
|
return true;
|
|
42424
42559
|
}
|
|
42425
42560
|
clearPoll() {
|
|
@@ -42442,7 +42577,7 @@ var TranscriptMirror = class {
|
|
|
42442
42577
|
}
|
|
42443
42578
|
};
|
|
42444
42579
|
function defaultWatch(file, onChange) {
|
|
42445
|
-
const w3 =
|
|
42580
|
+
const w3 = fs80.watch(file, { persistent: false }, () => onChange());
|
|
42446
42581
|
return () => w3.close();
|
|
42447
42582
|
}
|
|
42448
42583
|
|
|
@@ -42772,16 +42907,16 @@ function keepDeviceAwake(deps = {}) {
|
|
|
42772
42907
|
}
|
|
42773
42908
|
|
|
42774
42909
|
// src/agents/claude/onboarding.ts
|
|
42775
|
-
var
|
|
42910
|
+
var fs81 = __toESM(require("fs"));
|
|
42776
42911
|
var os65 = __toESM(require("os"));
|
|
42777
|
-
var
|
|
42912
|
+
var path88 = __toESM(require("path"));
|
|
42778
42913
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
42779
42914
|
function ensureClaudeOnboarded(cwd) {
|
|
42780
42915
|
try {
|
|
42781
|
-
const file =
|
|
42916
|
+
const file = path88.join(os65.homedir(), ".claude.json");
|
|
42782
42917
|
let config = {};
|
|
42783
42918
|
try {
|
|
42784
|
-
config = JSON.parse(
|
|
42919
|
+
config = JSON.parse(fs81.readFileSync(file, "utf8"));
|
|
42785
42920
|
} catch {
|
|
42786
42921
|
}
|
|
42787
42922
|
let changed = false;
|
|
@@ -42806,8 +42941,8 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
42806
42941
|
}
|
|
42807
42942
|
}
|
|
42808
42943
|
if (!changed) return;
|
|
42809
|
-
|
|
42810
|
-
|
|
42944
|
+
fs81.mkdirSync(path88.dirname(file), { recursive: true });
|
|
42945
|
+
fs81.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
42811
42946
|
log.info(
|
|
42812
42947
|
"claude",
|
|
42813
42948
|
`pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
|
|
@@ -43544,7 +43679,7 @@ var import_picocolors11 = __toESM(require("picocolors"));
|
|
|
43544
43679
|
var import_child_process31 = require("child_process");
|
|
43545
43680
|
var import_util4 = require("util");
|
|
43546
43681
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
43547
|
-
var
|
|
43682
|
+
var path89 = __toESM(require("path"));
|
|
43548
43683
|
var execFileP6 = (0, import_util4.promisify)(import_child_process31.execFile);
|
|
43549
43684
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
43550
43685
|
function resetStdinForChild() {
|
|
@@ -44033,7 +44168,7 @@ var GitHubCodespacesProvider = class {
|
|
|
44033
44168
|
});
|
|
44034
44169
|
}
|
|
44035
44170
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
44036
|
-
const remoteDir =
|
|
44171
|
+
const remoteDir = path89.posix.dirname(remotePath);
|
|
44037
44172
|
const parts = [
|
|
44038
44173
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
44039
44174
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -44103,7 +44238,7 @@ function shellQuote(s) {
|
|
|
44103
44238
|
// src/services/providers/gitpod.ts
|
|
44104
44239
|
var import_child_process32 = require("child_process");
|
|
44105
44240
|
var import_util5 = require("util");
|
|
44106
|
-
var
|
|
44241
|
+
var path90 = __toESM(require("path"));
|
|
44107
44242
|
var import_picocolors10 = __toESM(require("picocolors"));
|
|
44108
44243
|
var execFileP7 = (0, import_util5.promisify)(import_child_process32.execFile);
|
|
44109
44244
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
@@ -44343,7 +44478,7 @@ var GitpodProvider = class {
|
|
|
44343
44478
|
});
|
|
44344
44479
|
}
|
|
44345
44480
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
44346
|
-
const remoteDir =
|
|
44481
|
+
const remoteDir = path90.posix.dirname(remotePath);
|
|
44347
44482
|
const parts = [
|
|
44348
44483
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
44349
44484
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -44379,7 +44514,7 @@ function shellQuote2(s) {
|
|
|
44379
44514
|
// src/services/providers/gitlab-workspaces.ts
|
|
44380
44515
|
var import_child_process33 = require("child_process");
|
|
44381
44516
|
var import_util6 = require("util");
|
|
44382
|
-
var
|
|
44517
|
+
var path91 = __toESM(require("path"));
|
|
44383
44518
|
var execFileP8 = (0, import_util6.promisify)(import_child_process33.execFile);
|
|
44384
44519
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
44385
44520
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
@@ -44639,7 +44774,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
44639
44774
|
}
|
|
44640
44775
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
44641
44776
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
44642
|
-
const remoteDir =
|
|
44777
|
+
const remoteDir = path91.posix.dirname(remotePath);
|
|
44643
44778
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
44644
44779
|
if (options.mode != null) {
|
|
44645
44780
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
@@ -44707,7 +44842,7 @@ function shellQuote3(s) {
|
|
|
44707
44842
|
// src/services/providers/railway.ts
|
|
44708
44843
|
var import_child_process34 = require("child_process");
|
|
44709
44844
|
var import_util7 = require("util");
|
|
44710
|
-
var
|
|
44845
|
+
var path92 = __toESM(require("path"));
|
|
44711
44846
|
var execFileP9 = (0, import_util7.promisify)(import_child_process34.execFile);
|
|
44712
44847
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
44713
44848
|
function resetStdinForChild4() {
|
|
@@ -44943,7 +45078,7 @@ var RailwayProvider = class {
|
|
|
44943
45078
|
if (!projectId || !serviceId) {
|
|
44944
45079
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
44945
45080
|
}
|
|
44946
|
-
const remoteDir =
|
|
45081
|
+
const remoteDir = path92.posix.dirname(remotePath);
|
|
44947
45082
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
44948
45083
|
if (options.mode != null) {
|
|
44949
45084
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
@@ -45589,8 +45724,8 @@ async function invite() {
|
|
|
45589
45724
|
var import_node_dns = require("dns");
|
|
45590
45725
|
var import_node_util5 = require("util");
|
|
45591
45726
|
var import_node_crypto13 = require("crypto");
|
|
45592
|
-
var
|
|
45593
|
-
var
|
|
45727
|
+
var fs82 = __toESM(require("fs"));
|
|
45728
|
+
var path93 = __toESM(require("path"));
|
|
45594
45729
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
45595
45730
|
var dnsResolveP = (0, import_node_util5.promisify)(import_node_dns.resolve);
|
|
45596
45731
|
async function checkDns(apiBase2) {
|
|
@@ -45646,13 +45781,13 @@ async function checkHealth(apiBase2) {
|
|
|
45646
45781
|
}
|
|
45647
45782
|
}
|
|
45648
45783
|
function checkConfigDir() {
|
|
45649
|
-
const dir =
|
|
45784
|
+
const dir = path93.join(require("os").homedir(), ".codeam");
|
|
45650
45785
|
try {
|
|
45651
|
-
|
|
45652
|
-
const probe =
|
|
45653
|
-
|
|
45654
|
-
const read2 =
|
|
45655
|
-
|
|
45786
|
+
fs82.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
45787
|
+
const probe = path93.join(dir, ".doctor-probe");
|
|
45788
|
+
fs82.writeFileSync(probe, "ok", { mode: 384 });
|
|
45789
|
+
const read2 = fs82.readFileSync(probe, "utf8");
|
|
45790
|
+
fs82.unlinkSync(probe);
|
|
45656
45791
|
if (read2 !== "ok") throw new Error("write/read round-trip mismatch");
|
|
45657
45792
|
return {
|
|
45658
45793
|
id: "config-dir",
|
|
@@ -45716,7 +45851,7 @@ function checkNodePty() {
|
|
|
45716
45851
|
detail: "not required on this platform"
|
|
45717
45852
|
};
|
|
45718
45853
|
}
|
|
45719
|
-
const vendoredPath =
|
|
45854
|
+
const vendoredPath = path93.join(__dirname, "vendor", "node-pty");
|
|
45720
45855
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
45721
45856
|
try {
|
|
45722
45857
|
require(target);
|
|
@@ -45758,7 +45893,7 @@ function checkChokidar() {
|
|
|
45758
45893
|
}
|
|
45759
45894
|
async function doctor(args2 = []) {
|
|
45760
45895
|
const json = args2.includes("--json");
|
|
45761
|
-
const cliVersion = true ? "2.67.
|
|
45896
|
+
const cliVersion = true ? "2.67.5" : "0.0.0-dev";
|
|
45762
45897
|
const apiBase2 = resolveApiBaseUrl();
|
|
45763
45898
|
const diagnosticId = (0, import_node_crypto13.randomUUID)();
|
|
45764
45899
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -46149,7 +46284,7 @@ async function mcpRun(args2) {
|
|
|
46149
46284
|
// src/commands/version.ts
|
|
46150
46285
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
46151
46286
|
function version2() {
|
|
46152
|
-
const v = true ? "2.67.
|
|
46287
|
+
const v = true ? "2.67.5" : "unknown";
|
|
46153
46288
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
46154
46289
|
}
|
|
46155
46290
|
|