codeam-cli 2.76.23 → 2.76.24
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 +601 -534
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -374,8 +374,8 @@ function defaultSpawn(timeoutMs) {
|
|
|
374
374
|
});
|
|
375
375
|
}
|
|
376
376
|
function resolveConvexBin(cwd) {
|
|
377
|
-
const local =
|
|
378
|
-
if (
|
|
377
|
+
const local = path114.join(cwd, "node_modules", ".bin", process.platform === "win32" ? "convex.cmd" : "convex");
|
|
378
|
+
if (fs101.existsSync(local)) return { cmd: local, args: [] };
|
|
379
379
|
return { cmd: "npx", args: ["--yes", "convex"] };
|
|
380
380
|
}
|
|
381
381
|
function redact(text, key) {
|
|
@@ -506,13 +506,13 @@ async function runConvexAdminMcp(client3, id) {
|
|
|
506
506
|
});
|
|
507
507
|
await server.connect(new StdioServerTransport());
|
|
508
508
|
}
|
|
509
|
-
var import_node_child_process40,
|
|
509
|
+
var import_node_child_process40, fs101, path114, TOOLS;
|
|
510
510
|
var init_convex_admin_mcp = __esm({
|
|
511
511
|
"src/integrations/convex-admin-mcp.ts"() {
|
|
512
512
|
"use strict";
|
|
513
513
|
import_node_child_process40 = require("child_process");
|
|
514
|
-
|
|
515
|
-
|
|
514
|
+
fs101 = __toESM(require("fs"));
|
|
515
|
+
path114 = __toESM(require("path"));
|
|
516
516
|
TOOLS = [
|
|
517
517
|
{
|
|
518
518
|
name: "tables",
|
|
@@ -3398,13 +3398,16 @@ Analyze the project in the current working directory and return how to start
|
|
|
3398
3398
|
its development server for in-app preview.
|
|
3399
3399
|
|
|
3400
3400
|
Read package.json, Procfile, Dockerfile, docker-compose.yml, manage.py, app.json,
|
|
3401
|
-
mix.exs, Cargo.toml, go.mod, requirements.txt, Gemfile, and any
|
|
3402
|
-
markers you find at depth <= 2.
|
|
3401
|
+
mix.exs, Cargo.toml, go.mod, requirements.txt, pyproject.toml, Gemfile, and any
|
|
3402
|
+
other framework markers you find at depth <= 2. The app may live in a subfolder
|
|
3403
|
+
(e.g. teleshop/requirements.txt with nothing runnable at the root) \u2014 look there
|
|
3404
|
+
too.
|
|
3403
3405
|
|
|
3404
3406
|
Return ONLY a JSON object on stdout (no prose, no markdown fences):
|
|
3405
3407
|
|
|
3406
3408
|
{
|
|
3407
3409
|
"framework": "<name, or 'unsupported'>",
|
|
3410
|
+
"cwd": "<folder the dev server runs in, relative to the current directory; '.' for the root>",
|
|
3408
3411
|
"command": "<executable>",
|
|
3409
3412
|
"args": ["..."],
|
|
3410
3413
|
"port": <number>,
|
|
@@ -3416,6 +3419,13 @@ Return ONLY a JSON object on stdout (no prose, no markdown fences):
|
|
|
3416
3419
|
|
|
3417
3420
|
Rules:
|
|
3418
3421
|
- Pick the script the developer would run locally to see the app (typically "dev", "start", "serve").
|
|
3422
|
+
- If the app lives in a subfolder, set "cwd" to that folder (e.g. "teleshop"). command,
|
|
3423
|
+
args and setup_commands then run INSIDE it: write paths relative to it
|
|
3424
|
+
(".venv/bin/python", not "teleshop/.venv/bin/python"), and never wrap the command
|
|
3425
|
+
in "cd \u2026 &&" or "sh -c" \u2014 it is executed directly, without a shell.
|
|
3426
|
+
- Python: use the project's virtualenv interpreter when one exists
|
|
3427
|
+
(".venv/bin/python" with args ["-m","uvicorn","main:app","--host","0.0.0.0","--port","8000"]),
|
|
3428
|
+
otherwise "python3".
|
|
3419
3429
|
- Prefer binding to 0.0.0.0 \u2014 most frameworks default to localhost which the tunnel cannot reach.
|
|
3420
3430
|
- For Expo: framework="Expo", command="npx", args=["expo","start","--tunnel"], port=8081, notes="Scan QR with Expo Go".
|
|
3421
3431
|
- If no dev server applies (CLI library, lambda, batch script): {"framework":"unsupported","notes":"<reason>"}.
|
|
@@ -3632,11 +3642,11 @@ function quiet(fn) {
|
|
|
3632
3642
|
log.debug(TAG, "ignored sync error", err);
|
|
3633
3643
|
}
|
|
3634
3644
|
}
|
|
3635
|
-
function rmIfExistsQuiet(
|
|
3645
|
+
function rmIfExistsQuiet(path116) {
|
|
3636
3646
|
try {
|
|
3637
|
-
fs2.rmSync(
|
|
3647
|
+
fs2.rmSync(path116, { force: true });
|
|
3638
3648
|
} catch (err) {
|
|
3639
|
-
log.debug(TAG, `rmIfExists failed for ${
|
|
3649
|
+
log.debug(TAG, `rmIfExists failed for ${path116}`, err);
|
|
3640
3650
|
}
|
|
3641
3651
|
}
|
|
3642
3652
|
function killQuiet(target, signal = "SIGTERM") {
|
|
@@ -3802,9 +3812,9 @@ var _default = makeConfig();
|
|
|
3802
3812
|
var { getConfig, ensurePluginId, addSession, removeSession, setActiveSession, getActiveSession, getActiveSessionForAgent, setDisable1mContext, setSessionAgent, setSquadAuto, getSquadAuto, clearAll, saveCliConfig, loadCliConfig } = _default;
|
|
3803
3813
|
|
|
3804
3814
|
// src/commands/pair-auto.ts
|
|
3805
|
-
var
|
|
3815
|
+
var fs68 = __toESM(require("fs"));
|
|
3806
3816
|
var os49 = __toESM(require("os"));
|
|
3807
|
-
var
|
|
3817
|
+
var path76 = __toESM(require("path"));
|
|
3808
3818
|
var import_crypto4 = require("crypto");
|
|
3809
3819
|
|
|
3810
3820
|
// src/services/telemetry.service.ts
|
|
@@ -3840,8 +3850,8 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? (0, import_pat
|
|
|
3840
3850
|
return decodedFile;
|
|
3841
3851
|
};
|
|
3842
3852
|
}
|
|
3843
|
-
function normalizeWindowsPath(
|
|
3844
|
-
return
|
|
3853
|
+
function normalizeWindowsPath(path116) {
|
|
3854
|
+
return path116.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
|
|
3845
3855
|
}
|
|
3846
3856
|
|
|
3847
3857
|
// ../../node_modules/@posthog/core/dist/error-tracking/index.mjs
|
|
@@ -6574,13 +6584,13 @@ var PostHogCoreStateless = class {
|
|
|
6574
6584
|
sentFromRoute += batchMessages.length;
|
|
6575
6585
|
}
|
|
6576
6586
|
}
|
|
6577
|
-
async _sendOtlpBatch({ path:
|
|
6587
|
+
async _sendOtlpBatch({ path: path116, payload }) {
|
|
6578
6588
|
if (this.disabled) return {
|
|
6579
6589
|
kind: "fatal",
|
|
6580
6590
|
error: new Error("The client is disabled")
|
|
6581
6591
|
};
|
|
6582
6592
|
const serialized = JSON.stringify(payload);
|
|
6583
|
-
const url2 = `${this.host}/i/v1/${
|
|
6593
|
+
const url2 = `${this.host}/i/v1/${path116}?token=${encodeURIComponent(this.apiKey)}`;
|
|
6584
6594
|
const gzippedPayload = this.disableCompression ? null : await this.compressPayload(serialized);
|
|
6585
6595
|
const fetchOptions = {
|
|
6586
6596
|
method: "POST",
|
|
@@ -7820,14 +7830,14 @@ async function addSourceContext(frames, openSourceFile = import_promises.open, l
|
|
|
7820
7830
|
LRU_FILE_CONTENTS_CACHE.reduce();
|
|
7821
7831
|
return frames;
|
|
7822
7832
|
}
|
|
7823
|
-
async function openRegularSourceFile(
|
|
7833
|
+
async function openRegularSourceFile(path116, openSourceFile, logger) {
|
|
7824
7834
|
let fileHandle;
|
|
7825
7835
|
let isValid = false;
|
|
7826
7836
|
try {
|
|
7827
|
-
fileHandle = await openSourceFile(
|
|
7837
|
+
fileHandle = await openSourceFile(path116, import_node_fs.constants.O_RDONLY | import_node_fs.constants.O_NONBLOCK);
|
|
7828
7838
|
const fileStat = await fileHandle.stat();
|
|
7829
7839
|
if (!fileStat.isFile()) return;
|
|
7830
|
-
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${
|
|
7840
|
+
if (fileStat.size > MAX_CONTEXTLINES_FILE_SIZE) return void logger?.debug(`Skipping source context for oversized file ${path116}: ${fileStat.size} bytes exceeds ${MAX_CONTEXTLINES_FILE_SIZE}`);
|
|
7831
7841
|
isValid = true;
|
|
7832
7842
|
return fileHandle;
|
|
7833
7843
|
} catch {
|
|
@@ -7837,8 +7847,8 @@ async function openRegularSourceFile(path115, openSourceFile, logger) {
|
|
|
7837
7847
|
});
|
|
7838
7848
|
}
|
|
7839
7849
|
}
|
|
7840
|
-
async function getContextLinesFromFile(
|
|
7841
|
-
const fileHandle = await openRegularSourceFile(
|
|
7850
|
+
async function getContextLinesFromFile(path116, ranges, output, cacheKey, openSourceFile, logger) {
|
|
7851
|
+
const fileHandle = await openRegularSourceFile(path116, openSourceFile, logger);
|
|
7842
7852
|
if (void 0 === fileHandle) return void LRU_FILE_CONTENTS_FS_READ_FAILED.set(cacheKey, 1);
|
|
7843
7853
|
const openedFileHandle = fileHandle;
|
|
7844
7854
|
return new Promise((resolve13) => {
|
|
@@ -7940,22 +7950,22 @@ function clearLineContext(frame) {
|
|
|
7940
7950
|
delete frame.context_line;
|
|
7941
7951
|
delete frame.post_context;
|
|
7942
7952
|
}
|
|
7943
|
-
function shouldSkipContextLinesForFile(
|
|
7944
|
-
return
|
|
7953
|
+
function shouldSkipContextLinesForFile(path116) {
|
|
7954
|
+
return path116.startsWith("node:") || path116.endsWith(".min.js") || path116.endsWith(".min.cjs") || path116.endsWith(".min.mjs") || path116.startsWith("data:");
|
|
7945
7955
|
}
|
|
7946
7956
|
function shouldSkipContextLinesForFrame(frame) {
|
|
7947
7957
|
if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
|
|
7948
7958
|
if (void 0 !== frame.colno && frame.colno > MAX_CONTEXTLINES_COLNO) return true;
|
|
7949
7959
|
return false;
|
|
7950
7960
|
}
|
|
7951
|
-
function makeSourceCacheKey(
|
|
7952
|
-
if ((0, import_node_path.isAbsolute)(
|
|
7961
|
+
function makeSourceCacheKey(path116, basePath) {
|
|
7962
|
+
if ((0, import_node_path.isAbsolute)(path116)) return JSON.stringify([
|
|
7953
7963
|
null,
|
|
7954
|
-
|
|
7964
|
+
path116
|
|
7955
7965
|
]);
|
|
7956
7966
|
return void 0 === basePath ? void 0 : JSON.stringify([
|
|
7957
7967
|
basePath,
|
|
7958
|
-
|
|
7968
|
+
path116
|
|
7959
7969
|
]);
|
|
7960
7970
|
}
|
|
7961
7971
|
function rangeExistsInContentCache(cacheKey, range) {
|
|
@@ -10617,7 +10627,7 @@ function readAnonId() {
|
|
|
10617
10627
|
}
|
|
10618
10628
|
function superProperties() {
|
|
10619
10629
|
return {
|
|
10620
|
-
cliVersion: true ? "2.76.
|
|
10630
|
+
cliVersion: true ? "2.76.24" : "0.0.0-dev",
|
|
10621
10631
|
nodeVersion: process.version,
|
|
10622
10632
|
platform: process.platform,
|
|
10623
10633
|
arch: process.arch,
|
|
@@ -10866,7 +10876,7 @@ var http = __toESM(require("http"));
|
|
|
10866
10876
|
// package.json
|
|
10867
10877
|
var package_default = {
|
|
10868
10878
|
name: "codeam-cli",
|
|
10869
|
-
version: "2.76.
|
|
10879
|
+
version: "2.76.24",
|
|
10870
10880
|
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.",
|
|
10871
10881
|
type: "commonjs",
|
|
10872
10882
|
main: "dist/index.js",
|
|
@@ -12229,7 +12239,7 @@ var CommandRelayService = class _CommandRelayService {
|
|
|
12229
12239
|
// fresh + clear the "CLI update available" banner after a self-update
|
|
12230
12240
|
// (a codespace that reinstalls @latest reconnects via heartbeat, not
|
|
12231
12241
|
// pair/reconnect). Older backends ignore the extra field.
|
|
12232
|
-
..."2.76.
|
|
12242
|
+
..."2.76.24" ? { ideVersion: "2.76.24" } : {}
|
|
12233
12243
|
};
|
|
12234
12244
|
try {
|
|
12235
12245
|
const res = await _postJson(`${API_BASE2}/api/plugin/heartbeat`, body, this.pollSecretHeader());
|
|
@@ -13710,9 +13720,9 @@ function closeAllTerminals() {
|
|
|
13710
13720
|
}
|
|
13711
13721
|
|
|
13712
13722
|
// src/commands/start/handlers.ts
|
|
13713
|
-
var
|
|
13723
|
+
var fs67 = __toESM(require("fs"));
|
|
13714
13724
|
var os48 = __toESM(require("os"));
|
|
13715
|
-
var
|
|
13725
|
+
var path75 = __toESM(require("path"));
|
|
13716
13726
|
var import_crypto3 = require("crypto");
|
|
13717
13727
|
var import_child_process25 = require("child_process");
|
|
13718
13728
|
|
|
@@ -19968,8 +19978,8 @@ function pickLine(obj) {
|
|
|
19968
19978
|
function toHunk(raw, groupSeverity) {
|
|
19969
19979
|
if (!raw || typeof raw !== "object") return null;
|
|
19970
19980
|
const o = raw;
|
|
19971
|
-
const
|
|
19972
|
-
if (!
|
|
19981
|
+
const path116 = asString(pick(o, ["file_path", "filePath", "file", "path", "filename", "fileName"])) ?? asString(pick(o, ["location"])?.path);
|
|
19982
|
+
if (!path116) return null;
|
|
19973
19983
|
const message = asString(
|
|
19974
19984
|
pick(o, [
|
|
19975
19985
|
"comment",
|
|
@@ -19986,7 +19996,7 @@ function toHunk(raw, groupSeverity) {
|
|
|
19986
19996
|
const severity = normSeverity(pick(o, ["severity", "level", "priority", "impact"])) ?? normSeverity(groupSeverity);
|
|
19987
19997
|
const locObj = pick(o, ["location"]) ?? o;
|
|
19988
19998
|
return {
|
|
19989
|
-
path:
|
|
19999
|
+
path: path116.trim(),
|
|
19990
20000
|
line: pickLine(o) ?? pickLine(locObj),
|
|
19991
20001
|
severity,
|
|
19992
20002
|
message: (title && message ? `${title}: ${message}` : title || message).trim() || "(no message)"
|
|
@@ -20069,10 +20079,10 @@ function parsePlain(stdout) {
|
|
|
20069
20079
|
for (const line of stdout.split(/\r?\n/)) {
|
|
20070
20080
|
const m = line.match(HUNK_LINE_RE);
|
|
20071
20081
|
if (!m) continue;
|
|
20072
|
-
const [,
|
|
20073
|
-
if (!
|
|
20082
|
+
const [, path116, lineNo, sevToken, message] = m;
|
|
20083
|
+
if (!path116 || !lineNo || !message) continue;
|
|
20074
20084
|
hunks.push({
|
|
20075
|
-
path:
|
|
20085
|
+
path: path116.trim(),
|
|
20076
20086
|
line: Number(lineNo),
|
|
20077
20087
|
severity: sevToken ? SEVERITY_MAP[sevToken.toLowerCase()] : void 0,
|
|
20078
20088
|
message: message.trim().replace(/^[*-]\s+/, "")
|
|
@@ -26070,19 +26080,48 @@ function adapterExitMessage(opts) {
|
|
|
26070
26080
|
|
|
26071
26081
|
// src/services/preview/start-orchestrator.ts
|
|
26072
26082
|
var import_child_process20 = require("child_process");
|
|
26073
|
-
var
|
|
26074
|
-
var
|
|
26083
|
+
var fs58 = __toESM(require("fs"));
|
|
26084
|
+
var path66 = __toESM(require("path"));
|
|
26075
26085
|
var import_which3 = __toESM(require("which"));
|
|
26076
26086
|
|
|
26087
|
+
// src/services/preview/detection-cwd.ts
|
|
26088
|
+
var import_node_fs15 = __toESM(require("fs"));
|
|
26089
|
+
var import_node_path14 = __toESM(require("path"));
|
|
26090
|
+
function resolveDetectionCwd(root, cwd) {
|
|
26091
|
+
const rel = typeof cwd === "string" ? cwd.trim() : "";
|
|
26092
|
+
if (!rel || rel === ".") return { ok: true, dir: root };
|
|
26093
|
+
const dir = import_node_path14.default.resolve(root, rel);
|
|
26094
|
+
const inside = import_node_path14.default.relative(root, dir);
|
|
26095
|
+
if (import_node_path14.default.isAbsolute(rel) || inside.startsWith("..") || import_node_path14.default.isAbsolute(inside)) {
|
|
26096
|
+
return {
|
|
26097
|
+
ok: false,
|
|
26098
|
+
message: `The preview's folder "${rel}" is outside this project. Use a folder inside it (e.g. "app"), or "." for the root.`
|
|
26099
|
+
};
|
|
26100
|
+
}
|
|
26101
|
+
let isDir = false;
|
|
26102
|
+
try {
|
|
26103
|
+
isDir = import_node_fs15.default.statSync(dir).isDirectory();
|
|
26104
|
+
} catch {
|
|
26105
|
+
isDir = false;
|
|
26106
|
+
}
|
|
26107
|
+
if (!isDir) {
|
|
26108
|
+
return {
|
|
26109
|
+
ok: false,
|
|
26110
|
+
message: `The preview's folder "${rel}" doesn't exist in this project. Retry detection, or fix "cwd" in .codeam/preview.json.`
|
|
26111
|
+
};
|
|
26112
|
+
}
|
|
26113
|
+
return { ok: true, dir };
|
|
26114
|
+
}
|
|
26115
|
+
|
|
26077
26116
|
// src/services/project-env/index.ts
|
|
26078
26117
|
var import_fs6 = require("fs");
|
|
26079
|
-
var
|
|
26118
|
+
var path65 = __toESM(require("path"));
|
|
26080
26119
|
|
|
26081
26120
|
// src/beads/project-key.ts
|
|
26082
26121
|
var import_child_process19 = require("child_process");
|
|
26083
26122
|
var crypto2 = __toESM(require("crypto"));
|
|
26084
|
-
var
|
|
26085
|
-
var
|
|
26123
|
+
var fs56 = __toESM(require("fs"));
|
|
26124
|
+
var path64 = __toESM(require("path"));
|
|
26086
26125
|
function normalizeOrigin(raw) {
|
|
26087
26126
|
const trimmed = raw.trim();
|
|
26088
26127
|
if (!trimmed) return null;
|
|
@@ -26108,17 +26147,17 @@ function normalizeOrigin(raw) {
|
|
|
26108
26147
|
return `${host2}/${pathPart}`;
|
|
26109
26148
|
}
|
|
26110
26149
|
function findRepoRoot(cwd) {
|
|
26111
|
-
let dir =
|
|
26150
|
+
let dir = path64.resolve(cwd);
|
|
26112
26151
|
const seen2 = /* @__PURE__ */ new Set();
|
|
26113
26152
|
for (let i = 0; i < 256; i++) {
|
|
26114
26153
|
if (seen2.has(dir)) return null;
|
|
26115
26154
|
seen2.add(dir);
|
|
26116
26155
|
try {
|
|
26117
|
-
const stat3 =
|
|
26156
|
+
const stat3 = fs56.statSync(path64.join(dir, ".git"), { throwIfNoEntry: false });
|
|
26118
26157
|
if (stat3 && (stat3.isDirectory() || stat3.isFile())) return dir;
|
|
26119
26158
|
} catch {
|
|
26120
26159
|
}
|
|
26121
|
-
const parent =
|
|
26160
|
+
const parent = path64.dirname(dir);
|
|
26122
26161
|
if (parent === dir) return null;
|
|
26123
26162
|
dir = parent;
|
|
26124
26163
|
}
|
|
@@ -26129,7 +26168,7 @@ var _execSeam3 = {
|
|
|
26129
26168
|
const out2 = (0, import_child_process19.execFileSync)(file, args2, opts);
|
|
26130
26169
|
return typeof out2 === "string" ? out2 : out2.toString("utf8");
|
|
26131
26170
|
},
|
|
26132
|
-
realpath: (p2) =>
|
|
26171
|
+
realpath: (p2) => fs56.realpathSync(p2)
|
|
26133
26172
|
};
|
|
26134
26173
|
function readOrigin(cwd) {
|
|
26135
26174
|
try {
|
|
@@ -26158,7 +26197,7 @@ function deriveProjectIdentity(cwd = process.cwd()) {
|
|
|
26158
26197
|
} catch {
|
|
26159
26198
|
}
|
|
26160
26199
|
const hash = crypto2.createHash("sha256").update(real).digest("hex");
|
|
26161
|
-
return { projectKey: `path:${hash}`, projectLabel:
|
|
26200
|
+
return { projectKey: `path:${hash}`, projectLabel: path64.basename(real) || "project" };
|
|
26162
26201
|
}
|
|
26163
26202
|
|
|
26164
26203
|
// src/services/project-env/index.ts
|
|
@@ -26171,7 +26210,7 @@ async function readIfExists(p2) {
|
|
|
26171
26210
|
}
|
|
26172
26211
|
async function syncProjectEnvUp(cwd, ctx) {
|
|
26173
26212
|
if (!ctx.pluginAuthToken) return;
|
|
26174
|
-
const content = await readIfExists(
|
|
26213
|
+
const content = await readIfExists(path65.join(cwd, ".env"));
|
|
26175
26214
|
if (content == null) return;
|
|
26176
26215
|
try {
|
|
26177
26216
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -26193,7 +26232,7 @@ async function syncProjectEnvUp(cwd, ctx) {
|
|
|
26193
26232
|
}
|
|
26194
26233
|
async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
26195
26234
|
if (!ctx.pluginAuthToken) return false;
|
|
26196
|
-
const envPath =
|
|
26235
|
+
const envPath = path65.join(cwd, ".env");
|
|
26197
26236
|
if (await readIfExists(envPath) != null) return false;
|
|
26198
26237
|
try {
|
|
26199
26238
|
const { projectKey, projectLabel } = deriveProjectIdentity(cwd);
|
|
@@ -26204,7 +26243,7 @@ async function restoreProjectEnvIfMissing(cwd, ctx) {
|
|
|
26204
26243
|
projectKey
|
|
26205
26244
|
});
|
|
26206
26245
|
if (!stored) return false;
|
|
26207
|
-
const tmp =
|
|
26246
|
+
const tmp = path65.join(cwd, ".env.codeam-restore.tmp");
|
|
26208
26247
|
await import_fs6.promises.writeFile(tmp, stored.content, { encoding: "utf8", mode: 384 });
|
|
26209
26248
|
await import_fs6.promises.rename(tmp, envPath);
|
|
26210
26249
|
log.info("project-env", `restored .env (${stored.keyCount} vars) for ${projectLabel}`);
|
|
@@ -26968,8 +27007,8 @@ function normalizeDetectionForSpawn(detection, cwd) {
|
|
|
26968
27007
|
if (args2.length === 0) return detection;
|
|
26969
27008
|
const binName = args2[0];
|
|
26970
27009
|
if (binName.startsWith("-")) return detection;
|
|
26971
|
-
const binPath =
|
|
26972
|
-
if (!
|
|
27010
|
+
const binPath = path66.join(cwd, "node_modules", ".bin", binName);
|
|
27011
|
+
if (!fs58.existsSync(binPath)) return detection;
|
|
26973
27012
|
return {
|
|
26974
27013
|
...detection,
|
|
26975
27014
|
command: binPath,
|
|
@@ -26981,6 +27020,7 @@ async function runPreviewStart(args2) {
|
|
|
26981
27020
|
const { sessionId, detection, emit: emit2 } = args2;
|
|
26982
27021
|
const ctx = {
|
|
26983
27022
|
...args2,
|
|
27023
|
+
rootCwd: args2.cwd,
|
|
26984
27024
|
emitProgress: (step, message) => {
|
|
26985
27025
|
emit2(USER_EVENTS.PREVIEW_PROGRESS, { step, message, timestamp: Date.now() });
|
|
26986
27026
|
}
|
|
@@ -26996,6 +27036,12 @@ async function runPreviewStart(args2) {
|
|
|
26996
27036
|
});
|
|
26997
27037
|
return;
|
|
26998
27038
|
}
|
|
27039
|
+
const appDir = resolveDetectionCwd(args2.cwd, detection.cwd);
|
|
27040
|
+
if (!appDir.ok) {
|
|
27041
|
+
emit2(USER_EVENTS.PREVIEW_ERROR, { stage: "spawn", message: appDir.message });
|
|
27042
|
+
return;
|
|
27043
|
+
}
|
|
27044
|
+
ctx.cwd = appDir.dir;
|
|
26999
27045
|
emit2(USER_EVENTS.PREVIEW_STARTING, {
|
|
27000
27046
|
framework: detection.framework,
|
|
27001
27047
|
port: detection.port
|
|
@@ -27049,7 +27095,7 @@ function announceReady(ctx, dev, tun) {
|
|
|
27049
27095
|
recordPreviewPort(detection.port, dev.devServer.pid, sessionId, Date.now());
|
|
27050
27096
|
}
|
|
27051
27097
|
log.info("preview", `ready: ${detection.framework} at ${tun.url}`);
|
|
27052
|
-
void writeActivePreviewMarker(ctx.
|
|
27098
|
+
void writeActivePreviewMarker(ctx.rootCwd, detection);
|
|
27053
27099
|
emit2(USER_EVENTS.PREVIEW_READY, {
|
|
27054
27100
|
url: tun.url,
|
|
27055
27101
|
framework: detection.framework,
|
|
@@ -27059,7 +27105,7 @@ function announceReady(ctx, dev, tun) {
|
|
|
27059
27105
|
async function provisionDeps(ctx) {
|
|
27060
27106
|
const { detection, cwd, emit: emit2, emitProgress } = ctx;
|
|
27061
27107
|
if (ctx.projectEnvAuth?.pluginAuthToken) {
|
|
27062
|
-
await restoreProjectEnvIfMissing(
|
|
27108
|
+
await restoreProjectEnvIfMissing(ctx.rootCwd, {
|
|
27063
27109
|
sessionId: ctx.sessionId,
|
|
27064
27110
|
pluginId: ctx.projectEnvAuth.pluginId,
|
|
27065
27111
|
pluginAuthToken: ctx.projectEnvAuth.pluginAuthToken
|
|
@@ -27238,6 +27284,10 @@ async function startDevServer(ctx, extraEnv = {}) {
|
|
|
27238
27284
|
// groups — leave detached off there (direct kill is the only option).
|
|
27239
27285
|
detached: process.platform !== "win32"
|
|
27240
27286
|
});
|
|
27287
|
+
let spawnError = null;
|
|
27288
|
+
devServer.on("error", (err) => {
|
|
27289
|
+
spawnError = err;
|
|
27290
|
+
});
|
|
27241
27291
|
emitProgress("BIND_PORT", String(detection.port));
|
|
27242
27292
|
emitProgress("WAITING_FOR_READY", detection.ready_pattern);
|
|
27243
27293
|
let outputTail = "";
|
|
@@ -27258,7 +27308,7 @@ async function startDevServer(ctx, extraEnv = {}) {
|
|
|
27258
27308
|
killProcessTree(devServer, "SIGTERM");
|
|
27259
27309
|
emit2(USER_EVENTS.PREVIEW_ERROR, {
|
|
27260
27310
|
stage: "spawn",
|
|
27261
|
-
message: `The dev server exited (code ${outcome.code}) before it was ready. It may need a database or other services.`,
|
|
27311
|
+
message: describeSpawnFailure(spawnError, spawnable.command, path66.relative(ctx.rootCwd, cwd)) ?? `The dev server exited (code ${outcome.code}) before it was ready. It may need a database or other services.`,
|
|
27262
27312
|
stderrTail: stripAnsi(outputTail).slice(-8e3)
|
|
27263
27313
|
});
|
|
27264
27314
|
return null;
|
|
@@ -27379,12 +27429,23 @@ async function bringUpPublicUrl(ctx, tunnelPort) {
|
|
|
27379
27429
|
}
|
|
27380
27430
|
return { ok: true, url: parsedUrl, tunnel };
|
|
27381
27431
|
}
|
|
27432
|
+
function describeSpawnFailure(err, command2, relDir) {
|
|
27433
|
+
if (!err) return null;
|
|
27434
|
+
const where = relDir ? `the "${relDir}" folder` : "the project root";
|
|
27435
|
+
if (err.code === "ENOENT") {
|
|
27436
|
+
return `Couldn't start the dev server: "${command2}" was not found in ${where}. If the app lives in a subfolder, its "cwd" must point there; otherwise install the tool and try again.`;
|
|
27437
|
+
}
|
|
27438
|
+
if (err.code === "EACCES") {
|
|
27439
|
+
return `Couldn't start the dev server: "${command2}" in ${where} is not executable.`;
|
|
27440
|
+
}
|
|
27441
|
+
return `Couldn't start the dev server "${command2}": ${err.message}`;
|
|
27442
|
+
}
|
|
27382
27443
|
|
|
27383
27444
|
// src/beads/bd-adapter.ts
|
|
27384
27445
|
var import_child_process21 = require("child_process");
|
|
27385
|
-
var
|
|
27446
|
+
var fs59 = __toESM(require("fs"));
|
|
27386
27447
|
var os40 = __toESM(require("os"));
|
|
27387
|
-
var
|
|
27448
|
+
var path67 = __toESM(require("path"));
|
|
27388
27449
|
var BD_PACKAGE = "@beads/bd";
|
|
27389
27450
|
function resolveBundledBdBinary() {
|
|
27390
27451
|
return _resolveSeam.resolveBundled();
|
|
@@ -27396,11 +27457,11 @@ function _defaultResolveBundled() {
|
|
|
27396
27457
|
} catch {
|
|
27397
27458
|
return null;
|
|
27398
27459
|
}
|
|
27399
|
-
const binDir =
|
|
27460
|
+
const binDir = path67.join(path67.dirname(pkgJsonPath), "bin");
|
|
27400
27461
|
const binaryName = process.platform === "win32" ? "bd.exe" : "bd";
|
|
27401
|
-
const binaryPath =
|
|
27462
|
+
const binaryPath = path67.join(binDir, binaryName);
|
|
27402
27463
|
try {
|
|
27403
|
-
|
|
27464
|
+
fs59.accessSync(binaryPath, fs59.constants.F_OK);
|
|
27404
27465
|
return binaryPath;
|
|
27405
27466
|
} catch {
|
|
27406
27467
|
return null;
|
|
@@ -27410,13 +27471,13 @@ function resolveBdOnPath() {
|
|
|
27410
27471
|
return _resolveSeam.resolveOnPath();
|
|
27411
27472
|
}
|
|
27412
27473
|
function _defaultResolveOnPath() {
|
|
27413
|
-
const dirs = (process.env.PATH ?? "").split(
|
|
27474
|
+
const dirs = (process.env.PATH ?? "").split(path67.delimiter).filter(Boolean);
|
|
27414
27475
|
const candidates = process.platform === "win32" ? ["bd.exe", "bd.cmd", "bd"] : ["bd"];
|
|
27415
27476
|
for (const dir of dirs) {
|
|
27416
27477
|
for (const candidate of candidates) {
|
|
27417
|
-
const full =
|
|
27478
|
+
const full = path67.join(dir, candidate);
|
|
27418
27479
|
try {
|
|
27419
|
-
|
|
27480
|
+
fs59.accessSync(full, fs59.constants.F_OK);
|
|
27420
27481
|
return full;
|
|
27421
27482
|
} catch {
|
|
27422
27483
|
}
|
|
@@ -27591,9 +27652,9 @@ function coerceIssue(row, projectKey) {
|
|
|
27591
27652
|
|
|
27592
27653
|
// src/beads/provisioner.ts
|
|
27593
27654
|
var import_child_process24 = require("child_process");
|
|
27594
|
-
var
|
|
27655
|
+
var fs61 = __toESM(require("fs"));
|
|
27595
27656
|
var os42 = __toESM(require("os"));
|
|
27596
|
-
var
|
|
27657
|
+
var path69 = __toESM(require("path"));
|
|
27597
27658
|
|
|
27598
27659
|
// src/beads/install-bd.ts
|
|
27599
27660
|
var import_child_process22 = require("child_process");
|
|
@@ -27658,9 +27719,9 @@ async function installBd(platform3 = process.platform) {
|
|
|
27658
27719
|
|
|
27659
27720
|
// src/beads/install-dolt.ts
|
|
27660
27721
|
var import_child_process23 = require("child_process");
|
|
27661
|
-
var
|
|
27722
|
+
var fs60 = __toESM(require("fs"));
|
|
27662
27723
|
var os41 = __toESM(require("os"));
|
|
27663
|
-
var
|
|
27724
|
+
var path68 = __toESM(require("path"));
|
|
27664
27725
|
var DOLT_INSTALL_SH_URL = "https://github.com/dolthub/dolt/releases/latest/download/install.sh";
|
|
27665
27726
|
var DOLT_MSI_URL = "https://github.com/dolthub/dolt/releases/latest/download/dolt-windows-amd64.msi";
|
|
27666
27727
|
function resolveDoltInstallStrategy(platform3) {
|
|
@@ -27756,7 +27817,7 @@ var _doltPathSeam = {
|
|
|
27756
27817
|
},
|
|
27757
27818
|
exists: (p2) => {
|
|
27758
27819
|
try {
|
|
27759
|
-
|
|
27820
|
+
fs60.accessSync(p2, fs60.constants.F_OK);
|
|
27760
27821
|
return true;
|
|
27761
27822
|
} catch {
|
|
27762
27823
|
return false;
|
|
@@ -27767,7 +27828,7 @@ function doltBinaryNames(platform3) {
|
|
|
27767
27828
|
return platform3 === "win32" ? ["dolt.exe", "dolt.cmd", "dolt"] : ["dolt"];
|
|
27768
27829
|
}
|
|
27769
27830
|
function knownDoltDirs(platform3) {
|
|
27770
|
-
const P3 = platform3 === "win32" ?
|
|
27831
|
+
const P3 = platform3 === "win32" ? path68.win32 : path68.posix;
|
|
27771
27832
|
const home = _doltPathSeam.homedir();
|
|
27772
27833
|
if (platform3 === "win32") {
|
|
27773
27834
|
return [
|
|
@@ -27783,7 +27844,7 @@ function knownDoltDirs(platform3) {
|
|
|
27783
27844
|
].filter(Boolean);
|
|
27784
27845
|
}
|
|
27785
27846
|
function ensureDoltResolvable(platform3 = process.platform) {
|
|
27786
|
-
const P3 = platform3 === "win32" ?
|
|
27847
|
+
const P3 = platform3 === "win32" ? path68.win32 : path68.posix;
|
|
27787
27848
|
const delim = platform3 === "win32" ? ";" : ":";
|
|
27788
27849
|
const names = doltBinaryNames(platform3);
|
|
27789
27850
|
const pathDirs = _doltPathSeam.getPath().split(delim).filter(Boolean);
|
|
@@ -27960,10 +28021,10 @@ var _provisionSeam = {
|
|
|
27960
28021
|
/** Does the project's git remote carry Dolt data (`refs/dolt/data`)? */
|
|
27961
28022
|
remoteHasDoltData,
|
|
27962
28023
|
/** Throwaway cwd for a user-level-only `bd setup` (see GLOBAL_ONLY_RECIPES). */
|
|
27963
|
-
makeSetupCwd: () =>
|
|
28024
|
+
makeSetupCwd: () => fs61.mkdtempSync(path69.join(os42.tmpdir(), "codeam-bd-setup-")),
|
|
27964
28025
|
removeSetupCwd: (dir) => {
|
|
27965
28026
|
try {
|
|
27966
|
-
|
|
28027
|
+
fs61.rmSync(dir, { recursive: true, force: true });
|
|
27967
28028
|
} catch {
|
|
27968
28029
|
}
|
|
27969
28030
|
}
|
|
@@ -27988,14 +28049,14 @@ var _linkSeam = {
|
|
|
27988
28049
|
homedir: () => os42.homedir(),
|
|
27989
28050
|
isWritableDir: (dir) => {
|
|
27990
28051
|
try {
|
|
27991
|
-
|
|
28052
|
+
fs61.accessSync(dir, fs61.constants.W_OK);
|
|
27992
28053
|
return true;
|
|
27993
28054
|
} catch {
|
|
27994
28055
|
return false;
|
|
27995
28056
|
}
|
|
27996
28057
|
},
|
|
27997
28058
|
ensureDir: (dir) => {
|
|
27998
|
-
|
|
28059
|
+
fs61.mkdirSync(dir, { recursive: true });
|
|
27999
28060
|
},
|
|
28000
28061
|
/**
|
|
28001
28062
|
* A directory to symlink `bd` into so the AGENT's shell + Claude Code's
|
|
@@ -28016,9 +28077,9 @@ var _linkSeam = {
|
|
|
28016
28077
|
* which `linkBdOntoPath` creates if missing.
|
|
28017
28078
|
*/
|
|
28018
28079
|
cliBinDir: () => {
|
|
28019
|
-
const pathDirs = (process.env.PATH ?? "").split(
|
|
28080
|
+
const pathDirs = (process.env.PATH ?? "").split(path69.delimiter).filter(Boolean);
|
|
28020
28081
|
const home = _linkSeam.homedir();
|
|
28021
|
-
const localBin = home ?
|
|
28082
|
+
const localBin = home ? path69.join(home, ".local", "bin") : null;
|
|
28022
28083
|
if (localBin) {
|
|
28023
28084
|
try {
|
|
28024
28085
|
_linkSeam.ensureDir(localBin);
|
|
@@ -28028,16 +28089,16 @@ var _linkSeam = {
|
|
|
28028
28089
|
const candidates = [];
|
|
28029
28090
|
if (localBin) candidates.push(localBin);
|
|
28030
28091
|
try {
|
|
28031
|
-
candidates.push(
|
|
28092
|
+
candidates.push(path69.dirname(process.execPath));
|
|
28032
28093
|
} catch {
|
|
28033
28094
|
}
|
|
28034
28095
|
candidates.push("/usr/local/bin");
|
|
28035
28096
|
const entry = process.argv[1];
|
|
28036
28097
|
if (entry) {
|
|
28037
28098
|
try {
|
|
28038
|
-
candidates.push(
|
|
28099
|
+
candidates.push(path69.dirname(fs61.realpathSync(entry)));
|
|
28039
28100
|
} catch {
|
|
28040
|
-
candidates.push(
|
|
28101
|
+
candidates.push(path69.dirname(entry));
|
|
28041
28102
|
}
|
|
28042
28103
|
}
|
|
28043
28104
|
const onPathWritable = candidates.find(
|
|
@@ -28049,20 +28110,20 @@ var _linkSeam = {
|
|
|
28049
28110
|
/** Current symlink target at `linkPath`, or null when absent / not a link. */
|
|
28050
28111
|
readlink: (linkPath) => {
|
|
28051
28112
|
try {
|
|
28052
|
-
return
|
|
28113
|
+
return fs61.readlinkSync(linkPath);
|
|
28053
28114
|
} catch {
|
|
28054
28115
|
return null;
|
|
28055
28116
|
}
|
|
28056
28117
|
},
|
|
28057
|
-
unlink: (linkPath) =>
|
|
28058
|
-
symlink: (target, linkPath) =>
|
|
28118
|
+
unlink: (linkPath) => fs61.unlinkSync(linkPath),
|
|
28119
|
+
symlink: (target, linkPath) => fs61.symlinkSync(target, linkPath)
|
|
28059
28120
|
};
|
|
28060
28121
|
function linkBdOntoPath(binaryPath) {
|
|
28061
28122
|
if (_linkSeam.platform() === "win32") return;
|
|
28062
28123
|
const binDir = _linkSeam.cliBinDir();
|
|
28063
28124
|
if (!binDir) return;
|
|
28064
28125
|
_linkSeam.ensureDir(binDir);
|
|
28065
|
-
const linkPath =
|
|
28126
|
+
const linkPath = path69.join(binDir, "bd");
|
|
28066
28127
|
if (linkPath === binaryPath) return;
|
|
28067
28128
|
const current2 = _linkSeam.readlink(linkPath);
|
|
28068
28129
|
if (current2 === binaryPath) return;
|
|
@@ -28281,16 +28342,16 @@ function dedupeRecipes(agents) {
|
|
|
28281
28342
|
}
|
|
28282
28343
|
function ensureLocalGitExclude(cwd, patterns) {
|
|
28283
28344
|
try {
|
|
28284
|
-
const gitDir =
|
|
28285
|
-
if (!
|
|
28286
|
-
const file =
|
|
28287
|
-
|
|
28288
|
-
const current2 =
|
|
28345
|
+
const gitDir = path69.join(cwd, ".git");
|
|
28346
|
+
if (!fs61.statSync(gitDir).isDirectory()) return;
|
|
28347
|
+
const file = path69.join(gitDir, "info", "exclude");
|
|
28348
|
+
fs61.mkdirSync(path69.dirname(file), { recursive: true });
|
|
28349
|
+
const current2 = fs61.existsSync(file) ? fs61.readFileSync(file, "utf8") : "";
|
|
28289
28350
|
const have = new Set(current2.split(/\r?\n/).map((l) => l.trim()));
|
|
28290
28351
|
const missing = patterns.filter((p2) => !have.has(p2));
|
|
28291
28352
|
if (missing.length === 0) return;
|
|
28292
28353
|
const prefix = current2.length > 0 && !current2.endsWith("\n") ? "\n" : "";
|
|
28293
|
-
|
|
28354
|
+
fs61.appendFileSync(file, `${prefix}# CodeAgent: beads state stays local
|
|
28294
28355
|
${missing.join("\n")}
|
|
28295
28356
|
`);
|
|
28296
28357
|
} catch {
|
|
@@ -28299,7 +28360,7 @@ ${missing.join("\n")}
|
|
|
28299
28360
|
|
|
28300
28361
|
// src/beads/watcher.ts
|
|
28301
28362
|
var crypto4 = __toESM(require("crypto"));
|
|
28302
|
-
var
|
|
28363
|
+
var path70 = __toESM(require("path"));
|
|
28303
28364
|
var API_BASE5 = resolveApiBaseUrl();
|
|
28304
28365
|
var DEBOUNCE_MS2 = 400;
|
|
28305
28366
|
var ZERO_SUMMARY = {
|
|
@@ -28323,7 +28384,7 @@ var BeadsWatcher = class {
|
|
|
28323
28384
|
constructor(opts) {
|
|
28324
28385
|
this.opts = opts;
|
|
28325
28386
|
this.bd = opts.adapter ?? new BdAdapter({ cwd: opts.cwd, beadsDir: opts.beadsDir });
|
|
28326
|
-
this.feedPath = opts.feedPath ??
|
|
28387
|
+
this.feedPath = opts.feedPath ?? path70.join(opts.cwd ?? process.cwd(), ".beads", "last-touched");
|
|
28327
28388
|
this.apiBase = opts.apiBaseUrl ?? API_BASE5;
|
|
28328
28389
|
}
|
|
28329
28390
|
opts;
|
|
@@ -28574,15 +28635,15 @@ async function handleBeadsActionCommand(action, started) {
|
|
|
28574
28635
|
}
|
|
28575
28636
|
|
|
28576
28637
|
// src/beads/config-store.ts
|
|
28577
|
-
var
|
|
28638
|
+
var import_node_fs16 = __toESM(require("fs"));
|
|
28578
28639
|
var import_node_os8 = __toESM(require("os"));
|
|
28579
|
-
var
|
|
28640
|
+
var import_node_path15 = __toESM(require("path"));
|
|
28580
28641
|
function beadsConfigPath() {
|
|
28581
|
-
return
|
|
28642
|
+
return import_node_path15.default.join(import_node_os8.default.homedir(), ".codeam", "beads-config.json");
|
|
28582
28643
|
}
|
|
28583
28644
|
function readBeadsEnabled() {
|
|
28584
28645
|
try {
|
|
28585
|
-
const raw =
|
|
28646
|
+
const raw = import_node_fs16.default.readFileSync(beadsConfigPath(), "utf8");
|
|
28586
28647
|
const cfg = JSON.parse(raw);
|
|
28587
28648
|
return cfg.enabled !== false;
|
|
28588
28649
|
} catch {
|
|
@@ -28591,10 +28652,10 @@ function readBeadsEnabled() {
|
|
|
28591
28652
|
}
|
|
28592
28653
|
function persistBeadsConfig(cfg) {
|
|
28593
28654
|
const file = beadsConfigPath();
|
|
28594
|
-
|
|
28655
|
+
import_node_fs16.default.mkdirSync(import_node_path15.default.dirname(file), { recursive: true });
|
|
28595
28656
|
const tmp = `${file}.tmp`;
|
|
28596
|
-
|
|
28597
|
-
|
|
28657
|
+
import_node_fs16.default.writeFileSync(tmp, JSON.stringify(cfg), { mode: 384 });
|
|
28658
|
+
import_node_fs16.default.renameSync(tmp, file);
|
|
28598
28659
|
restrictToOwner(file);
|
|
28599
28660
|
}
|
|
28600
28661
|
|
|
@@ -28838,12 +28899,12 @@ async function configureBeads(action, ctx, deps) {
|
|
|
28838
28899
|
var import_node_os11 = __toESM(require("os"));
|
|
28839
28900
|
|
|
28840
28901
|
// src/skills/materialize.ts
|
|
28841
|
-
var
|
|
28902
|
+
var import_node_fs17 = __toESM(require("fs"));
|
|
28842
28903
|
var import_node_os9 = __toESM(require("os"));
|
|
28843
|
-
var
|
|
28904
|
+
var import_node_path16 = __toESM(require("path"));
|
|
28844
28905
|
var NS = "codeam-";
|
|
28845
28906
|
function skillDirFor(id, home = import_node_os9.default.homedir()) {
|
|
28846
|
-
return
|
|
28907
|
+
return import_node_path16.default.join(home, ".claude", "skills", `${NS}${id}`);
|
|
28847
28908
|
}
|
|
28848
28909
|
function renderSkillMd(id, description, body) {
|
|
28849
28910
|
const desc = description.replace(/\s*\n\s*/g, " ").trim();
|
|
@@ -28860,21 +28921,21 @@ function materializeSkill(id, home = import_node_os9.default.homedir()) {
|
|
|
28860
28921
|
if (!def?.delivery.skillFile) return false;
|
|
28861
28922
|
try {
|
|
28862
28923
|
const dir = skillDirFor(id, home);
|
|
28863
|
-
|
|
28864
|
-
|
|
28865
|
-
|
|
28924
|
+
import_node_fs17.default.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
28925
|
+
import_node_fs17.default.writeFileSync(
|
|
28926
|
+
import_node_path16.default.join(dir, "SKILL.md"),
|
|
28866
28927
|
renderSkillMd(id, def.description, def.delivery.skillFile.body),
|
|
28867
28928
|
{ encoding: "utf8", mode: 384 }
|
|
28868
28929
|
);
|
|
28869
|
-
const baseDir =
|
|
28870
|
-
const baseDirWithSep = baseDir +
|
|
28930
|
+
const baseDir = import_node_path16.default.resolve(dir);
|
|
28931
|
+
const baseDirWithSep = baseDir + import_node_path16.default.sep;
|
|
28871
28932
|
for (const [rel, contents] of Object.entries(def.delivery.skillFile.files ?? {})) {
|
|
28872
|
-
const target =
|
|
28873
|
-
if (!
|
|
28933
|
+
const target = import_node_path16.default.join(dir, rel);
|
|
28934
|
+
if (!import_node_path16.default.resolve(target).startsWith(baseDirWithSep) && import_node_path16.default.resolve(target) !== baseDir) {
|
|
28874
28935
|
continue;
|
|
28875
28936
|
}
|
|
28876
|
-
|
|
28877
|
-
|
|
28937
|
+
import_node_fs17.default.mkdirSync(import_node_path16.default.dirname(target), { recursive: true, mode: 448 });
|
|
28938
|
+
import_node_fs17.default.writeFileSync(target, contents, { encoding: "utf8", mode: 384 });
|
|
28878
28939
|
}
|
|
28879
28940
|
return true;
|
|
28880
28941
|
} catch (err) {
|
|
@@ -28884,21 +28945,21 @@ function materializeSkill(id, home = import_node_os9.default.homedir()) {
|
|
|
28884
28945
|
}
|
|
28885
28946
|
function removeSkill(id, home = import_node_os9.default.homedir()) {
|
|
28886
28947
|
try {
|
|
28887
|
-
|
|
28948
|
+
import_node_fs17.default.rmSync(skillDirFor(id, home), { recursive: true, force: true });
|
|
28888
28949
|
} catch {
|
|
28889
28950
|
}
|
|
28890
28951
|
}
|
|
28891
28952
|
|
|
28892
28953
|
// src/skills/manifest.ts
|
|
28893
|
-
var
|
|
28954
|
+
var import_node_fs18 = __toESM(require("fs"));
|
|
28894
28955
|
var import_node_os10 = __toESM(require("os"));
|
|
28895
|
-
var
|
|
28956
|
+
var import_node_path17 = __toESM(require("path"));
|
|
28896
28957
|
function skillsManifestPath() {
|
|
28897
|
-
return
|
|
28958
|
+
return import_node_path17.default.join(import_node_os10.default.homedir(), ".codeam", "skills.json");
|
|
28898
28959
|
}
|
|
28899
28960
|
function readSkillsManifest() {
|
|
28900
28961
|
try {
|
|
28901
|
-
const raw = JSON.parse(
|
|
28962
|
+
const raw = JSON.parse(import_node_fs18.default.readFileSync(skillsManifestPath(), "utf8"));
|
|
28902
28963
|
if (!Array.isArray(raw?.skills)) return null;
|
|
28903
28964
|
raw.skills = raw.skills.filter(
|
|
28904
28965
|
(s) => Boolean(s) && typeof s === "object" && typeof s.id === "string"
|
|
@@ -28911,10 +28972,10 @@ function readSkillsManifest() {
|
|
|
28911
28972
|
function persistSkillsManifest(m) {
|
|
28912
28973
|
try {
|
|
28913
28974
|
const file = skillsManifestPath();
|
|
28914
|
-
|
|
28975
|
+
import_node_fs18.default.mkdirSync(import_node_path17.default.dirname(file), { recursive: true, mode: 448 });
|
|
28915
28976
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
28916
|
-
|
|
28917
|
-
|
|
28977
|
+
import_node_fs18.default.writeFileSync(tmp, JSON.stringify(m, null, 2), { encoding: "utf8", mode: 384 });
|
|
28978
|
+
import_node_fs18.default.renameSync(tmp, file);
|
|
28918
28979
|
restrictToOwner(file);
|
|
28919
28980
|
} catch (err) {
|
|
28920
28981
|
log.warn(
|
|
@@ -28925,7 +28986,7 @@ function persistSkillsManifest(m) {
|
|
|
28925
28986
|
}
|
|
28926
28987
|
function clearSkillsManifest() {
|
|
28927
28988
|
try {
|
|
28928
|
-
|
|
28989
|
+
import_node_fs18.default.rmSync(skillsManifestPath(), { force: true });
|
|
28929
28990
|
} catch {
|
|
28930
28991
|
}
|
|
28931
28992
|
}
|
|
@@ -28968,8 +29029,8 @@ function cleanupAttachmentTempFiles() {
|
|
|
28968
29029
|
function saveFilesTemp(files) {
|
|
28969
29030
|
return files.filter(({ base64 }) => base64 && base64.length > 0).map(({ filename, base64 }) => {
|
|
28970
29031
|
const safeName = filename.replace(/[^a-zA-Z0-9._-]/g, "_").slice(0, 80);
|
|
28971
|
-
const tmpPath =
|
|
28972
|
-
|
|
29032
|
+
const tmpPath = path75.join(os48.tmpdir(), `codeam-${(0, import_crypto3.randomUUID)()}-${safeName}`);
|
|
29033
|
+
fs67.writeFileSync(tmpPath, Buffer.from(base64, "base64"));
|
|
28973
29034
|
pendingAttachmentFiles.add(tmpPath);
|
|
28974
29035
|
return tmpPath;
|
|
28975
29036
|
});
|
|
@@ -29215,10 +29276,10 @@ var listFiles = async (ctx, cmd, parsed) => {
|
|
|
29215
29276
|
await ctx.relay.sendResult(cmd.id, "completed", result);
|
|
29216
29277
|
};
|
|
29217
29278
|
var envReadH = async (ctx, cmd) => {
|
|
29218
|
-
const envPath =
|
|
29279
|
+
const envPath = path75.join(process.cwd(), ".env");
|
|
29219
29280
|
await restoreProjectEnvIfMissing(process.cwd(), ctx);
|
|
29220
29281
|
try {
|
|
29221
|
-
const raw = await
|
|
29282
|
+
const raw = await fs67.promises.readFile(envPath, "utf8");
|
|
29222
29283
|
await ctx.relay.sendResult(cmd.id, "completed", {
|
|
29223
29284
|
exists: true,
|
|
29224
29285
|
vars: parseDotenv(raw)
|
|
@@ -29247,7 +29308,7 @@ var envParseH = async (ctx, cmd, parsed) => {
|
|
|
29247
29308
|
const existing = /* @__PURE__ */ new Map();
|
|
29248
29309
|
if (!replace) {
|
|
29249
29310
|
try {
|
|
29250
|
-
const raw = await
|
|
29311
|
+
const raw = await fs67.promises.readFile(path75.join(process.cwd(), ".env"), "utf8");
|
|
29251
29312
|
for (const v of parseDotenv(raw)) existing.set(v.key, v.value);
|
|
29252
29313
|
} catch {
|
|
29253
29314
|
}
|
|
@@ -29287,15 +29348,15 @@ var envWriteH = async (ctx, cmd, parsed) => {
|
|
|
29287
29348
|
}
|
|
29288
29349
|
seen2.add(v.key);
|
|
29289
29350
|
}
|
|
29290
|
-
const envPath =
|
|
29291
|
-
const tmpPath =
|
|
29351
|
+
const envPath = path75.join(process.cwd(), ".env");
|
|
29352
|
+
const tmpPath = path75.join(process.cwd(), ".env.codeam.tmp");
|
|
29292
29353
|
try {
|
|
29293
|
-
await
|
|
29294
|
-
await
|
|
29354
|
+
await fs67.promises.writeFile(tmpPath, serializeDotenv(vars), "utf8");
|
|
29355
|
+
await fs67.promises.rename(tmpPath, envPath);
|
|
29295
29356
|
await ctx.relay.sendResult(cmd.id, "completed", { ok: true, count: vars.length });
|
|
29296
29357
|
void syncProjectEnvUp(process.cwd(), ctx);
|
|
29297
29358
|
} catch (err) {
|
|
29298
|
-
await
|
|
29359
|
+
await fs67.promises.rm(tmpPath, { force: true }).catch(() => void 0);
|
|
29299
29360
|
await ctx.relay.sendResult(cmd.id, "failed", { error: err.message });
|
|
29300
29361
|
}
|
|
29301
29362
|
};
|
|
@@ -29644,9 +29705,9 @@ var CLI_UPDATE_MAX_ATTEMPTS = 3;
|
|
|
29644
29705
|
function buildNpmInstallInvocation(opts) {
|
|
29645
29706
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
29646
29707
|
const execPath = opts?.execPath ?? process.execPath;
|
|
29647
|
-
const exists2 = opts?.existsSync ??
|
|
29708
|
+
const exists2 = opts?.existsSync ?? fs67.existsSync;
|
|
29648
29709
|
const platform3 = opts?.platform ?? process.platform;
|
|
29649
|
-
const p2 = platform3 === "win32" ?
|
|
29710
|
+
const p2 = platform3 === "win32" ? path75.win32 : path75.posix;
|
|
29650
29711
|
const normalized = entryScript.split(/[\\/]/).join("/");
|
|
29651
29712
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
29652
29713
|
const markerIdx = normalized.indexOf(marker);
|
|
@@ -29665,7 +29726,7 @@ function isPermissionError(stderr) {
|
|
|
29665
29726
|
function resolveGlobalNodeModulesDir(opts) {
|
|
29666
29727
|
const entryScript = opts?.entryScript ?? process.argv[1] ?? "";
|
|
29667
29728
|
const platform3 = opts?.platform ?? process.platform;
|
|
29668
|
-
const p2 = platform3 === "win32" ?
|
|
29729
|
+
const p2 = platform3 === "win32" ? path75.win32 : path75.posix;
|
|
29669
29730
|
const marker = "/lib/node_modules/codeam-cli/";
|
|
29670
29731
|
const markerIdx = entryScript.split(/[\\/]/).join("/").indexOf(marker);
|
|
29671
29732
|
if (markerIdx <= 0) return null;
|
|
@@ -29675,9 +29736,9 @@ function resolveGlobalNodeModulesDir(opts) {
|
|
|
29675
29736
|
var STALE_STAGING_AGE_MS = CLI_UPDATE_INSTALL_TIMEOUT_MS;
|
|
29676
29737
|
function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
29677
29738
|
if (!nodeModulesDir) return 0;
|
|
29678
|
-
const readdirSync18 = deps?.readdirSync ??
|
|
29679
|
-
const statSync17 = deps?.statSync ??
|
|
29680
|
-
const rmSync15 = deps?.rmSync ??
|
|
29739
|
+
const readdirSync18 = deps?.readdirSync ?? fs67.readdirSync;
|
|
29740
|
+
const statSync17 = deps?.statSync ?? fs67.statSync;
|
|
29741
|
+
const rmSync15 = deps?.rmSync ?? fs67.rmSync;
|
|
29681
29742
|
let removed = 0;
|
|
29682
29743
|
let entries2;
|
|
29683
29744
|
try {
|
|
@@ -29687,7 +29748,7 @@ function sweepStaleCliStagingDirs(nodeModulesDir, now = Date.now(), deps) {
|
|
|
29687
29748
|
}
|
|
29688
29749
|
for (const name of entries2) {
|
|
29689
29750
|
if (!/^\.codeam-cli-/.test(name)) continue;
|
|
29690
|
-
const full =
|
|
29751
|
+
const full = path75.join(nodeModulesDir, name);
|
|
29691
29752
|
try {
|
|
29692
29753
|
const st3 = statSync17(full);
|
|
29693
29754
|
if (now - st3.mtimeMs < STALE_STAGING_AGE_MS) continue;
|
|
@@ -30834,11 +30895,11 @@ function resolveTokenValue(args2) {
|
|
|
30834
30895
|
}
|
|
30835
30896
|
const fileFlag = args2.find((a) => a.startsWith("--token-file="));
|
|
30836
30897
|
if (fileFlag) {
|
|
30837
|
-
const
|
|
30898
|
+
const path116 = fileFlag.slice("--token-file=".length);
|
|
30838
30899
|
try {
|
|
30839
|
-
const content =
|
|
30840
|
-
if (content.length === 0) fail(`--token-file ${
|
|
30841
|
-
rmIfExistsQuiet(
|
|
30900
|
+
const content = fs68.readFileSync(path116, "utf8").trim();
|
|
30901
|
+
if (content.length === 0) fail(`--token-file ${path116} is empty`);
|
|
30902
|
+
rmIfExistsQuiet(path116);
|
|
30842
30903
|
return content;
|
|
30843
30904
|
} catch (err) {
|
|
30844
30905
|
fail(`Could not read --token-file: ${err.message}`);
|
|
@@ -30930,12 +30991,12 @@ async function claim(token, pluginId, pluginSecretHash) {
|
|
|
30930
30991
|
}
|
|
30931
30992
|
}
|
|
30932
30993
|
function pairAutoLockPath() {
|
|
30933
|
-
return
|
|
30994
|
+
return path76.join(os49.homedir(), ".codeam", "pair-auto.lock");
|
|
30934
30995
|
}
|
|
30935
30996
|
var procRoot = "/proc";
|
|
30936
30997
|
function readProcFile(rel) {
|
|
30937
30998
|
try {
|
|
30938
|
-
return
|
|
30999
|
+
return fs68.readFileSync(path76.join(procRoot, rel), "utf8");
|
|
30939
31000
|
} catch {
|
|
30940
31001
|
return void 0;
|
|
30941
31002
|
}
|
|
@@ -30956,7 +31017,7 @@ function currentBootId() {
|
|
|
30956
31017
|
function readLockRecord(lockPath) {
|
|
30957
31018
|
let raw;
|
|
30958
31019
|
try {
|
|
30959
|
-
raw =
|
|
31020
|
+
raw = fs68.readFileSync(lockPath, "utf8");
|
|
30960
31021
|
} catch {
|
|
30961
31022
|
return void 0;
|
|
30962
31023
|
}
|
|
@@ -31005,7 +31066,7 @@ function isLiveLockHolder(rec) {
|
|
|
31005
31066
|
}
|
|
31006
31067
|
function releaseOwnLock(lockPath) {
|
|
31007
31068
|
try {
|
|
31008
|
-
if (readLockRecord(lockPath)?.pid === process.pid)
|
|
31069
|
+
if (readLockRecord(lockPath)?.pid === process.pid) fs68.unlinkSync(lockPath);
|
|
31009
31070
|
} catch {
|
|
31010
31071
|
}
|
|
31011
31072
|
}
|
|
@@ -31029,7 +31090,7 @@ function snapshotProcessTree(root) {
|
|
|
31029
31090
|
const children = /* @__PURE__ */ new Map();
|
|
31030
31091
|
let entries2 = [];
|
|
31031
31092
|
try {
|
|
31032
|
-
entries2 =
|
|
31093
|
+
entries2 = fs68.readdirSync(procRoot).filter((e) => /^\d+$/.test(e));
|
|
31033
31094
|
} catch {
|
|
31034
31095
|
}
|
|
31035
31096
|
for (const e of entries2) {
|
|
@@ -31064,18 +31125,18 @@ function signalProcessTree(refs, signal) {
|
|
|
31064
31125
|
}
|
|
31065
31126
|
function daemonLockPath(sessionId) {
|
|
31066
31127
|
const safe = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
31067
|
-
return
|
|
31128
|
+
return path76.join(os49.homedir(), ".codeam", `daemon-${safe}.lock`);
|
|
31068
31129
|
}
|
|
31069
31130
|
function acquireDaemonLock(sessionId) {
|
|
31070
31131
|
const lockPath = daemonLockPath(sessionId);
|
|
31071
31132
|
try {
|
|
31072
|
-
|
|
31133
|
+
fs68.mkdirSync(path76.dirname(lockPath), { recursive: true });
|
|
31073
31134
|
try {
|
|
31074
|
-
|
|
31135
|
+
fs68.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
31075
31136
|
} catch (e) {
|
|
31076
31137
|
if (e.code !== "EEXIST") throw e;
|
|
31077
31138
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
31078
|
-
|
|
31139
|
+
fs68.writeFileSync(lockPath, ownLockBody());
|
|
31079
31140
|
}
|
|
31080
31141
|
const release3 = () => releaseOwnLock(lockPath);
|
|
31081
31142
|
process.once("exit", release3);
|
|
@@ -31095,13 +31156,13 @@ function acquireDaemonLock(sessionId) {
|
|
|
31095
31156
|
function acquireSingletonLock() {
|
|
31096
31157
|
const lockPath = pairAutoLockPath();
|
|
31097
31158
|
try {
|
|
31098
|
-
|
|
31159
|
+
fs68.mkdirSync(path76.dirname(lockPath), { recursive: true });
|
|
31099
31160
|
try {
|
|
31100
|
-
|
|
31161
|
+
fs68.writeFileSync(lockPath, ownLockBody(), { flag: "wx" });
|
|
31101
31162
|
} catch (e) {
|
|
31102
31163
|
if (e.code !== "EEXIST") throw e;
|
|
31103
31164
|
if (isLiveLockHolder(readLockRecord(lockPath))) return false;
|
|
31104
|
-
|
|
31165
|
+
fs68.writeFileSync(lockPath, ownLockBody());
|
|
31105
31166
|
}
|
|
31106
31167
|
process.once("exit", () => releaseOwnLock(lockPath));
|
|
31107
31168
|
return true;
|
|
@@ -31527,15 +31588,15 @@ var AgentService = class _AgentService {
|
|
|
31527
31588
|
};
|
|
31528
31589
|
|
|
31529
31590
|
// src/agents/acp/adapters.ts
|
|
31530
|
-
var
|
|
31591
|
+
var path77 = __toESM(require("path"));
|
|
31531
31592
|
|
|
31532
31593
|
// src/agents/kimi/installer.ts
|
|
31533
31594
|
var import_node_child_process26 = require("child_process");
|
|
31534
31595
|
var import_node_os12 = require("os");
|
|
31535
|
-
var
|
|
31596
|
+
var import_node_path18 = require("path");
|
|
31536
31597
|
var INSTALL_URL2 = "https://code.kimi.com/kimi-code/install.sh";
|
|
31537
31598
|
function kimiBinDir() {
|
|
31538
|
-
return (0,
|
|
31599
|
+
return (0, import_node_path18.join)(process.env.KIMI_CODE_HOME || (0, import_node_path18.join)((0, import_node_os12.homedir)(), ".kimi-code"), "bin");
|
|
31539
31600
|
}
|
|
31540
31601
|
function kimiRuns() {
|
|
31541
31602
|
const r = (0, import_node_child_process26.spawnSync)("kimi", ["--version"], { stdio: "ignore", timeout: 15e3 });
|
|
@@ -31585,10 +31646,10 @@ async function ensureKimiInstalled() {
|
|
|
31585
31646
|
// src/agents/opencode/installer.ts
|
|
31586
31647
|
var import_node_child_process27 = require("child_process");
|
|
31587
31648
|
var import_node_os13 = require("os");
|
|
31588
|
-
var
|
|
31649
|
+
var import_node_path19 = require("path");
|
|
31589
31650
|
var INSTALL_URL3 = "https://opencode.ai/install";
|
|
31590
31651
|
function opencodeBinDir() {
|
|
31591
|
-
return (0,
|
|
31652
|
+
return (0, import_node_path19.join)(process.env.OPENCODE_HOME || (0, import_node_path19.join)((0, import_node_os13.homedir)(), ".opencode"), "bin");
|
|
31592
31653
|
}
|
|
31593
31654
|
function opencodeRuns() {
|
|
31594
31655
|
const r = (0, import_node_child_process27.spawnSync)("opencode", ["--version"], { stdio: "ignore", timeout: 15e3 });
|
|
@@ -31647,13 +31708,13 @@ function resolveBin(pkgName, binName) {
|
|
|
31647
31708
|
try {
|
|
31648
31709
|
const manifestPath = require_.resolve(`${pkgName}/package.json`);
|
|
31649
31710
|
const manifest = require_(`${pkgName}/package.json`);
|
|
31650
|
-
const pkgDir =
|
|
31711
|
+
const pkgDir = path77.dirname(manifestPath);
|
|
31651
31712
|
const bin = manifest.bin;
|
|
31652
31713
|
if (!bin) return null;
|
|
31653
|
-
if (typeof bin === "string") return
|
|
31714
|
+
if (typeof bin === "string") return path77.resolve(pkgDir, bin);
|
|
31654
31715
|
const target = binName ?? Object.keys(bin)[0];
|
|
31655
31716
|
if (!target || !bin[target]) return null;
|
|
31656
|
-
return
|
|
31717
|
+
return path77.resolve(pkgDir, bin[target]);
|
|
31657
31718
|
} catch {
|
|
31658
31719
|
return null;
|
|
31659
31720
|
}
|
|
@@ -31668,7 +31729,7 @@ function npmAdapterPackageDir(agent) {
|
|
|
31668
31729
|
const pkg = NPM_ADAPTER_PACKAGES[agent];
|
|
31669
31730
|
if (!pkg) return null;
|
|
31670
31731
|
try {
|
|
31671
|
-
return
|
|
31732
|
+
return path77.dirname(require_.resolve(`${pkg}/package.json`));
|
|
31672
31733
|
} catch {
|
|
31673
31734
|
return null;
|
|
31674
31735
|
}
|
|
@@ -31848,8 +31909,8 @@ async function resolveAcpAdapterWithRetry(agent, opts = {}) {
|
|
|
31848
31909
|
}
|
|
31849
31910
|
|
|
31850
31911
|
// src/agents/acp/prefetch-module-graph.ts
|
|
31851
|
-
var
|
|
31852
|
-
var
|
|
31912
|
+
var fs69 = __toESM(require("fs"));
|
|
31913
|
+
var path78 = __toESM(require("path"));
|
|
31853
31914
|
var LOADABLE_EXT = /* @__PURE__ */ new Set([".js", ".mjs", ".cjs", ".json", ".node"]);
|
|
31854
31915
|
var DEFAULT_MODULE_GRAPH_LIMITS = {
|
|
31855
31916
|
maxFiles: 2e3,
|
|
@@ -31858,23 +31919,23 @@ var DEFAULT_MODULE_GRAPH_LIMITS = {
|
|
|
31858
31919
|
concurrency: 16
|
|
31859
31920
|
};
|
|
31860
31921
|
var realFs = {
|
|
31861
|
-
readdir: (dir) =>
|
|
31862
|
-
readFile: (file) =>
|
|
31863
|
-
stat: (file) =>
|
|
31922
|
+
readdir: (dir) => fs69.promises.readdir(dir, { withFileTypes: true }),
|
|
31923
|
+
readFile: (file) => fs69.promises.readFile(file),
|
|
31924
|
+
stat: (file) => fs69.promises.stat(file)
|
|
31864
31925
|
};
|
|
31865
31926
|
function findPackageDir(dep, fromDir) {
|
|
31866
31927
|
let dir = fromDir;
|
|
31867
31928
|
for (; ; ) {
|
|
31868
|
-
const candidate =
|
|
31869
|
-
if (
|
|
31870
|
-
const parent =
|
|
31929
|
+
const candidate = path78.join(dir, "node_modules", dep);
|
|
31930
|
+
if (fs69.existsSync(path78.join(candidate, "package.json"))) return candidate;
|
|
31931
|
+
const parent = path78.dirname(dir);
|
|
31871
31932
|
if (parent === dir) return null;
|
|
31872
31933
|
dir = parent;
|
|
31873
31934
|
}
|
|
31874
31935
|
}
|
|
31875
31936
|
function runtimeDependencies(pkgDir) {
|
|
31876
31937
|
try {
|
|
31877
|
-
const manifest = JSON.parse(
|
|
31938
|
+
const manifest = JSON.parse(fs69.readFileSync(path78.join(pkgDir, "package.json"), "utf8"));
|
|
31878
31939
|
return Object.keys(manifest.dependencies ?? {});
|
|
31879
31940
|
} catch {
|
|
31880
31941
|
return [];
|
|
@@ -31893,14 +31954,14 @@ async function packageFiles(pkgDir, fsd, out2, maxFiles) {
|
|
|
31893
31954
|
for (const entry of entries2) {
|
|
31894
31955
|
if (out2.length >= maxFiles) return;
|
|
31895
31956
|
if (entry.name.startsWith(".")) continue;
|
|
31896
|
-
const full =
|
|
31957
|
+
const full = path78.join(dir, entry.name);
|
|
31897
31958
|
if (entry.isDirectory()) {
|
|
31898
31959
|
if (entry.name !== "node_modules") stack.push(full);
|
|
31899
31960
|
continue;
|
|
31900
31961
|
}
|
|
31901
31962
|
if (!entry.isFile()) continue;
|
|
31902
31963
|
if (entry.name.endsWith(".d.ts") || entry.name.endsWith(".map")) continue;
|
|
31903
|
-
if (LOADABLE_EXT.has(
|
|
31964
|
+
if (LOADABLE_EXT.has(path78.extname(entry.name))) out2.push(full);
|
|
31904
31965
|
}
|
|
31905
31966
|
}
|
|
31906
31967
|
}
|
|
@@ -31910,7 +31971,7 @@ async function collectModuleGraphFiles(rootPkgDir, limits = DEFAULT_MODULE_GRAPH
|
|
|
31910
31971
|
const queue = [rootPkgDir];
|
|
31911
31972
|
while (queue.length > 0 && files.length < limits.maxFiles) {
|
|
31912
31973
|
const pkgDir = queue.shift();
|
|
31913
|
-
const key =
|
|
31974
|
+
const key = fs69.existsSync(pkgDir) ? fs69.realpathSync(pkgDir) : pkgDir;
|
|
31914
31975
|
if (seen2.has(key)) continue;
|
|
31915
31976
|
seen2.add(key);
|
|
31916
31977
|
await packageFiles(pkgDir, fsd, files, limits.maxFiles);
|
|
@@ -32022,9 +32083,9 @@ async function waitForNoAgentStarting(opts) {
|
|
|
32022
32083
|
|
|
32023
32084
|
// src/agents/acp/runner.ts
|
|
32024
32085
|
var import_node_crypto15 = require("crypto");
|
|
32025
|
-
var
|
|
32086
|
+
var fs88 = __toESM(require("fs"));
|
|
32026
32087
|
var os61 = __toESM(require("os"));
|
|
32027
|
-
var
|
|
32088
|
+
var path98 = __toESM(require("path"));
|
|
32028
32089
|
|
|
32029
32090
|
// src/agents/acp/provider-billing-signal.ts
|
|
32030
32091
|
var seen = /* @__PURE__ */ new Set();
|
|
@@ -32056,8 +32117,8 @@ function noteProviderBillingSignal(opts) {
|
|
|
32056
32117
|
}
|
|
32057
32118
|
|
|
32058
32119
|
// src/services/history.service.ts
|
|
32059
|
-
var
|
|
32060
|
-
var
|
|
32120
|
+
var fs71 = __toESM(require("fs"));
|
|
32121
|
+
var path80 = __toESM(require("path"));
|
|
32061
32122
|
var https6 = __toESM(require("https"));
|
|
32062
32123
|
var http10 = __toESM(require("http"));
|
|
32063
32124
|
var import_zod3 = require("zod");
|
|
@@ -32118,7 +32179,7 @@ function parseJsonl(filePath) {
|
|
|
32118
32179
|
const messages = [];
|
|
32119
32180
|
let raw;
|
|
32120
32181
|
try {
|
|
32121
|
-
raw =
|
|
32182
|
+
raw = fs71.readFileSync(filePath, "utf8");
|
|
32122
32183
|
} catch (err) {
|
|
32123
32184
|
if (err.code !== "ENOENT") {
|
|
32124
32185
|
log.warn("history:parseJsonl", `read failed for ${filePath}`, err);
|
|
@@ -32278,7 +32339,7 @@ var HistoryService = class _HistoryService {
|
|
|
32278
32339
|
// session-start upload answered false, the active-conversation pointer was
|
|
32279
32340
|
// never re-pointed after a Box wake, and the app opened an empty "New
|
|
32280
32341
|
// conversation" over the resumed one (QA box, 2026-09-29).
|
|
32281
|
-
|
|
32342
|
+
path80.join(claudeConfigDir(), "projects", encodeCwd(this.cwd));
|
|
32282
32343
|
}
|
|
32283
32344
|
/** Set the current Claude conversation ID (extracted from /cost command or session start) */
|
|
32284
32345
|
setCurrentConversationId(id) {
|
|
@@ -32290,7 +32351,7 @@ var HistoryService = class _HistoryService {
|
|
|
32290
32351
|
/** Return the current message count in the active conversation. */
|
|
32291
32352
|
getCurrentMessageCount() {
|
|
32292
32353
|
if (!this.currentConversationId) return 0;
|
|
32293
|
-
const filePath =
|
|
32354
|
+
const filePath = path80.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
32294
32355
|
return parseJsonl(filePath).length;
|
|
32295
32356
|
}
|
|
32296
32357
|
/**
|
|
@@ -32301,7 +32362,7 @@ var HistoryService = class _HistoryService {
|
|
|
32301
32362
|
const deadline = Date.now() + timeoutMs;
|
|
32302
32363
|
while (Date.now() < deadline) {
|
|
32303
32364
|
if (!this.currentConversationId) return null;
|
|
32304
|
-
const filePath =
|
|
32365
|
+
const filePath = path80.join(this.projectDir, `${this.currentConversationId}.jsonl`);
|
|
32305
32366
|
const messages = parseJsonl(filePath);
|
|
32306
32367
|
if (messages.length > previousCount) {
|
|
32307
32368
|
for (let i = messages.length - 1; i >= previousCount; i--) {
|
|
@@ -32328,18 +32389,18 @@ var HistoryService = class _HistoryService {
|
|
|
32328
32389
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
32329
32390
|
const oneShots = readOneShotConversations(this.cwd);
|
|
32330
32391
|
try {
|
|
32331
|
-
const files =
|
|
32332
|
-
(e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(
|
|
32392
|
+
const files = fs71.readdirSync(dir, { withFileTypes: true }).filter(
|
|
32393
|
+
(e) => e.isFile() && e.name.endsWith(".jsonl") && !oneShots.has(path80.basename(e.name, ".jsonl"))
|
|
32333
32394
|
).map((e) => {
|
|
32334
32395
|
try {
|
|
32335
|
-
const stat3 =
|
|
32396
|
+
const stat3 = fs71.statSync(path80.join(dir, e.name));
|
|
32336
32397
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
32337
32398
|
} catch {
|
|
32338
32399
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
32339
32400
|
}
|
|
32340
32401
|
}).filter((f) => f.birthtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
|
|
32341
32402
|
if (files.length > 0) {
|
|
32342
|
-
this.currentConversationId =
|
|
32403
|
+
this.currentConversationId = path80.basename(files[0].name, ".jsonl");
|
|
32343
32404
|
}
|
|
32344
32405
|
} catch {
|
|
32345
32406
|
}
|
|
@@ -32373,13 +32434,13 @@ var HistoryService = class _HistoryService {
|
|
|
32373
32434
|
const cutoff = this.bootTimeMs - _HistoryService.BIRTHTIME_GRACE_MS;
|
|
32374
32435
|
let entries2;
|
|
32375
32436
|
try {
|
|
32376
|
-
entries2 =
|
|
32437
|
+
entries2 = fs71.readdirSync(dir, { withFileTypes: true });
|
|
32377
32438
|
} catch {
|
|
32378
32439
|
return null;
|
|
32379
32440
|
}
|
|
32380
32441
|
const files = entries2.filter((e) => e.isFile() && e.name.endsWith(".jsonl")).map((e) => {
|
|
32381
32442
|
try {
|
|
32382
|
-
const stat3 =
|
|
32443
|
+
const stat3 = fs71.statSync(path80.join(dir, e.name));
|
|
32383
32444
|
return { name: e.name, mtime: stat3.mtimeMs, birthtime: stat3.birthtimeMs };
|
|
32384
32445
|
} catch {
|
|
32385
32446
|
return { name: e.name, mtime: 0, birthtime: 0 };
|
|
@@ -32388,12 +32449,12 @@ var HistoryService = class _HistoryService {
|
|
|
32388
32449
|
if (files.length === 0) return null;
|
|
32389
32450
|
const targetFile = this.currentConversationId ? `${this.currentConversationId}.jsonl` : files[0].name;
|
|
32390
32451
|
if (!files.some((f) => f.name === targetFile)) return null;
|
|
32391
|
-
return this.extractUsageFromFile(
|
|
32452
|
+
return this.extractUsageFromFile(path80.join(dir, targetFile));
|
|
32392
32453
|
}
|
|
32393
32454
|
extractUsageFromFile(filePath) {
|
|
32394
32455
|
let raw;
|
|
32395
32456
|
try {
|
|
32396
|
-
raw =
|
|
32457
|
+
raw = fs71.readFileSync(filePath, "utf8");
|
|
32397
32458
|
} catch {
|
|
32398
32459
|
return null;
|
|
32399
32460
|
}
|
|
@@ -32445,9 +32506,9 @@ var HistoryService = class _HistoryService {
|
|
|
32445
32506
|
let totalCost = 0;
|
|
32446
32507
|
let files;
|
|
32447
32508
|
try {
|
|
32448
|
-
files =
|
|
32509
|
+
files = fs71.readdirSync(projectDir).filter((f) => f.endsWith(".jsonl")).filter((f) => {
|
|
32449
32510
|
try {
|
|
32450
|
-
return
|
|
32511
|
+
return fs71.statSync(path80.join(projectDir, f)).mtimeMs >= monthStartMs;
|
|
32451
32512
|
} catch {
|
|
32452
32513
|
return false;
|
|
32453
32514
|
}
|
|
@@ -32458,7 +32519,7 @@ var HistoryService = class _HistoryService {
|
|
|
32458
32519
|
for (const file of files) {
|
|
32459
32520
|
let raw;
|
|
32460
32521
|
try {
|
|
32461
|
-
raw =
|
|
32522
|
+
raw = fs71.readFileSync(path80.join(projectDir, file), "utf8");
|
|
32462
32523
|
} catch {
|
|
32463
32524
|
continue;
|
|
32464
32525
|
}
|
|
@@ -32537,7 +32598,7 @@ var HistoryService = class _HistoryService {
|
|
|
32537
32598
|
if (this.runtime.resolveHistoryFile) {
|
|
32538
32599
|
return this.runtime.resolveHistoryFile(this.cwd, sessionId);
|
|
32539
32600
|
}
|
|
32540
|
-
return
|
|
32601
|
+
return path80.join(this.projectDir, `${sessionId}.jsonl`);
|
|
32541
32602
|
}
|
|
32542
32603
|
/**
|
|
32543
32604
|
* Parse a conversation's messages from disk, agent-aware. Claude uses the
|
|
@@ -32575,7 +32636,7 @@ var HistoryService = class _HistoryService {
|
|
|
32575
32636
|
};
|
|
32576
32637
|
});
|
|
32577
32638
|
}
|
|
32578
|
-
return parseJsonl(
|
|
32639
|
+
return parseJsonl(path80.join(this.projectDir, `${sessionId}.jsonl`));
|
|
32579
32640
|
}
|
|
32580
32641
|
/** One in-flight full upload per conversation — the baton mirror and a
|
|
32581
32642
|
* `get_conversation` used to upload the same transcript concurrently. */
|
|
@@ -32657,7 +32718,7 @@ var HistoryService = class _HistoryService {
|
|
|
32657
32718
|
if (!filePath) return false;
|
|
32658
32719
|
let mtimeMs;
|
|
32659
32720
|
try {
|
|
32660
|
-
mtimeMs =
|
|
32721
|
+
mtimeMs = fs71.statSync(filePath).mtimeMs;
|
|
32661
32722
|
} catch {
|
|
32662
32723
|
return false;
|
|
32663
32724
|
}
|
|
@@ -32732,10 +32793,10 @@ var HistoryService = class _HistoryService {
|
|
|
32732
32793
|
|
|
32733
32794
|
// src/agents/acp/client.ts
|
|
32734
32795
|
var import_node_child_process28 = require("child_process");
|
|
32735
|
-
var
|
|
32796
|
+
var fs72 = __toESM(require("fs/promises"));
|
|
32736
32797
|
var fsSync = __toESM(require("fs"));
|
|
32737
32798
|
var os52 = __toESM(require("os"));
|
|
32738
|
-
var
|
|
32799
|
+
var path82 = __toESM(require("path"));
|
|
32739
32800
|
var import_node_stream = require("stream");
|
|
32740
32801
|
|
|
32741
32802
|
// ../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
|
|
@@ -36761,7 +36822,7 @@ function createIdleTimeout(idleMs, makeError, activeIdleMs = idleMs) {
|
|
|
36761
36822
|
}
|
|
36762
36823
|
|
|
36763
36824
|
// src/agents/acp/internal-paths.ts
|
|
36764
|
-
var
|
|
36825
|
+
var path81 = __toESM(require("path"));
|
|
36765
36826
|
var os51 = __toESM(require("os"));
|
|
36766
36827
|
var INTERNAL_TOKENS = [".codeam", "house-claude"];
|
|
36767
36828
|
var PROSE_ONLY_TOOL_KINDS = /* @__PURE__ */ new Set(["think", "switch_mode"]);
|
|
@@ -36776,11 +36837,11 @@ function textReferencesInternal(text) {
|
|
|
36776
36837
|
}
|
|
36777
36838
|
function pathIsInternal(p2, homeDir2 = os51.homedir()) {
|
|
36778
36839
|
if (!p2) return false;
|
|
36779
|
-
const abs =
|
|
36780
|
-
const home =
|
|
36781
|
-
const within = (root) => abs === root || abs.startsWith(root +
|
|
36782
|
-
if (within(
|
|
36783
|
-
return within(
|
|
36840
|
+
const abs = path81.resolve(p2);
|
|
36841
|
+
const home = path81.resolve(homeDir2);
|
|
36842
|
+
const within = (root) => abs === root || abs.startsWith(root + path81.sep);
|
|
36843
|
+
if (within(path81.join(home, ".codeam", "self-hosted"))) return false;
|
|
36844
|
+
return within(path81.join(home, ".codeam")) || within(path81.join(home, ".beads")) || abs === path81.join(home, ".codeam-host.log") || abs.includes(`${path81.sep}house-claude${path81.sep}`) || abs.endsWith(`${path81.sep}house-claude`);
|
|
36784
36845
|
}
|
|
36785
36846
|
function toolCallReferencesInternal(call, homeDir2) {
|
|
36786
36847
|
if (call.locations?.some((l) => pathIsInternal(l.path, homeDir2))) return true;
|
|
@@ -37914,7 +37975,7 @@ var AcpClient = class {
|
|
|
37914
37975
|
throw new RequestError(-32002, GUARDRAIL_SECRET_READ_BLOCK_REASON, { uri: params.path });
|
|
37915
37976
|
}
|
|
37916
37977
|
try {
|
|
37917
|
-
const content = await
|
|
37978
|
+
const content = await fs72.readFile(params.path, "utf8");
|
|
37918
37979
|
return applyLineRange(content, params.line ?? null, params.limit ?? null);
|
|
37919
37980
|
} catch (err) {
|
|
37920
37981
|
const code = err.code;
|
|
@@ -37935,7 +37996,7 @@ var AcpClient = class {
|
|
|
37935
37996
|
throw new RequestError(-32002, INTERNAL_BLOCK_REASON, { uri: params.path });
|
|
37936
37997
|
}
|
|
37937
37998
|
try {
|
|
37938
|
-
await
|
|
37999
|
+
await fs72.writeFile(params.path, params.content, "utf8");
|
|
37939
38000
|
return {};
|
|
37940
38001
|
} catch (err) {
|
|
37941
38002
|
const code = err.code;
|
|
@@ -38028,25 +38089,25 @@ function knownAgentBinaryDirs() {
|
|
|
38028
38089
|
out2.push("/tmp/codeam-node20/bin");
|
|
38029
38090
|
for (const root of [
|
|
38030
38091
|
"/usr/local/share/nvm/versions/node",
|
|
38031
|
-
|
|
38092
|
+
path82.join(home, ".nvm/versions/node")
|
|
38032
38093
|
]) {
|
|
38033
38094
|
try {
|
|
38034
38095
|
for (const child of fsSync.readdirSync(root)) {
|
|
38035
|
-
out2.push(
|
|
38096
|
+
out2.push(path82.join(root, child, "bin"));
|
|
38036
38097
|
}
|
|
38037
38098
|
} catch {
|
|
38038
38099
|
}
|
|
38039
38100
|
}
|
|
38040
|
-
out2.push(
|
|
38101
|
+
out2.push(path82.join(home, ".volta/bin"));
|
|
38041
38102
|
out2.push("/usr/local/bin");
|
|
38042
38103
|
out2.push("/usr/bin");
|
|
38043
|
-
out2.push(
|
|
38044
|
-
out2.push(
|
|
38104
|
+
out2.push(path82.join(home, ".local/bin"));
|
|
38105
|
+
out2.push(path82.join(home, "bin"));
|
|
38045
38106
|
out2.push(...agentInstallBinDirs());
|
|
38046
38107
|
if (process.platform === "win32") {
|
|
38047
38108
|
const { LOCALAPPDATA, APPDATA } = process.env;
|
|
38048
|
-
if (LOCALAPPDATA) out2.push(
|
|
38049
|
-
if (APPDATA) out2.push(
|
|
38109
|
+
if (LOCALAPPDATA) out2.push(path82.join(LOCALAPPDATA, "cursor-agent"));
|
|
38110
|
+
if (APPDATA) out2.push(path82.join(APPDATA, "npm"));
|
|
38050
38111
|
}
|
|
38051
38112
|
return out2.filter((p2) => {
|
|
38052
38113
|
try {
|
|
@@ -38057,7 +38118,7 @@ function knownAgentBinaryDirs() {
|
|
|
38057
38118
|
});
|
|
38058
38119
|
}
|
|
38059
38120
|
function expandPathForAgentBinaries(existingPath) {
|
|
38060
|
-
const existing = new Set(existingPath.split(
|
|
38121
|
+
const existing = new Set(existingPath.split(path82.delimiter).filter((p2) => p2.length > 0));
|
|
38061
38122
|
const additions = [];
|
|
38062
38123
|
for (const dir of knownAgentBinaryDirs()) {
|
|
38063
38124
|
if (!existing.has(dir)) {
|
|
@@ -38066,7 +38127,7 @@ function expandPathForAgentBinaries(existingPath) {
|
|
|
38066
38127
|
}
|
|
38067
38128
|
}
|
|
38068
38129
|
if (additions.length === 0) return existingPath;
|
|
38069
|
-
return [...additions, existingPath].filter((p2) => p2.length > 0).join(
|
|
38130
|
+
return [...additions, existingPath].filter((p2) => p2.length > 0).join(path82.delimiter);
|
|
38070
38131
|
}
|
|
38071
38132
|
|
|
38072
38133
|
// src/commands/host/agent-install.ts
|
|
@@ -38338,9 +38399,9 @@ async function performAgentSwitch(deps, rawAgentId, fastPath = {}) {
|
|
|
38338
38399
|
}
|
|
38339
38400
|
|
|
38340
38401
|
// src/commands/host/agent-provisioning.ts
|
|
38341
|
-
var
|
|
38402
|
+
var fs73 = __toESM(require("fs"));
|
|
38342
38403
|
var os54 = __toESM(require("os"));
|
|
38343
|
-
var
|
|
38404
|
+
var path83 = __toESM(require("path"));
|
|
38344
38405
|
var PUBLIC_TO_INTERNAL_AGENT = {
|
|
38345
38406
|
claude_code: "claude",
|
|
38346
38407
|
claude: "claude",
|
|
@@ -38357,22 +38418,22 @@ function toInternalAgentId(publicAgentId) {
|
|
|
38357
38418
|
return PUBLIC_TO_INTERNAL_AGENT[publicAgentId] ?? null;
|
|
38358
38419
|
}
|
|
38359
38420
|
function ensureDir(dir) {
|
|
38360
|
-
|
|
38421
|
+
fs73.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
38361
38422
|
}
|
|
38362
38423
|
function writeFile0600(filePath, contents) {
|
|
38363
|
-
ensureDir(
|
|
38364
|
-
|
|
38424
|
+
ensureDir(path83.dirname(filePath));
|
|
38425
|
+
fs73.writeFileSync(filePath, contents, { encoding: "utf8", mode: 384 });
|
|
38365
38426
|
restrictToOwner(filePath);
|
|
38366
38427
|
}
|
|
38367
38428
|
function rmIfExists(filePath) {
|
|
38368
38429
|
try {
|
|
38369
|
-
|
|
38430
|
+
fs73.rmSync(filePath, { force: true });
|
|
38370
38431
|
} catch {
|
|
38371
38432
|
}
|
|
38372
38433
|
}
|
|
38373
38434
|
var claudeProvisioner = {
|
|
38374
38435
|
write(auth, home) {
|
|
38375
|
-
const credentialsJson =
|
|
38436
|
+
const credentialsJson = path83.join(home, ".claude", ".credentials.json");
|
|
38376
38437
|
if (auth.kind === "api_key") {
|
|
38377
38438
|
rmIfExists(credentialsJson);
|
|
38378
38439
|
return { ANTHROPIC_API_KEY: auth.value };
|
|
@@ -38384,8 +38445,8 @@ var claudeProvisioner = {
|
|
|
38384
38445
|
} else {
|
|
38385
38446
|
rmIfExists(credentialsJson);
|
|
38386
38447
|
}
|
|
38387
|
-
const claudeJson =
|
|
38388
|
-
if (!
|
|
38448
|
+
const claudeJson = path83.join(home, ".claude.json");
|
|
38449
|
+
if (!fs73.existsSync(claudeJson)) {
|
|
38389
38450
|
writeFile0600(
|
|
38390
38451
|
claudeJson,
|
|
38391
38452
|
JSON.stringify({ hasCompletedOnboarding: true, customApiKeyResponses: { approved: [] } })
|
|
@@ -38396,7 +38457,7 @@ var claudeProvisioner = {
|
|
|
38396
38457
|
};
|
|
38397
38458
|
var codexProvisioner = {
|
|
38398
38459
|
write(auth, home) {
|
|
38399
|
-
const authJson =
|
|
38460
|
+
const authJson = path83.join(home, ".codex", "auth.json");
|
|
38400
38461
|
if (auth.kind === "api_key") {
|
|
38401
38462
|
writeFile0600(authJson, JSON.stringify({ auth_mode: "apikey", OPENAI_API_KEY: auth.value }));
|
|
38402
38463
|
return { OPENAI_API_KEY: auth.value };
|
|
@@ -38419,7 +38480,7 @@ function codexLoginStamp(raw) {
|
|
|
38419
38480
|
function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
38420
38481
|
let onDisk;
|
|
38421
38482
|
try {
|
|
38422
|
-
onDisk =
|
|
38483
|
+
onDisk = fs73.readFileSync(authJsonPath, "utf8");
|
|
38423
38484
|
} catch {
|
|
38424
38485
|
return false;
|
|
38425
38486
|
}
|
|
@@ -38430,8 +38491,8 @@ function keepsFresherCodexLogin(authJsonPath, incoming) {
|
|
|
38430
38491
|
}
|
|
38431
38492
|
var geminiProvisioner = {
|
|
38432
38493
|
write(auth, home) {
|
|
38433
|
-
const settingsJson =
|
|
38434
|
-
const oauthCreds =
|
|
38494
|
+
const settingsJson = path83.join(home, ".gemini", "settings.json");
|
|
38495
|
+
const oauthCreds = path83.join(home, ".gemini", "oauth_creds.json");
|
|
38435
38496
|
if (auth.kind === "api_key") {
|
|
38436
38497
|
rmIfExists(oauthCreds);
|
|
38437
38498
|
writeFile0600(settingsJson, '{"security":{"auth":{"selectedType":"gemini-api-key"}}}');
|
|
@@ -38444,7 +38505,7 @@ var geminiProvisioner = {
|
|
|
38444
38505
|
};
|
|
38445
38506
|
var cursorProvisioner = {
|
|
38446
38507
|
write(auth, home) {
|
|
38447
|
-
const authJson =
|
|
38508
|
+
const authJson = path83.join(home, ".config", "cursor", "auth.json");
|
|
38448
38509
|
if (auth.kind === "api_key") {
|
|
38449
38510
|
rmIfExists(authJson);
|
|
38450
38511
|
return { CURSOR_API_KEY: auth.value };
|
|
@@ -38486,22 +38547,22 @@ max_context_size = 262144
|
|
|
38486
38547
|
var kimiProvisioner = {
|
|
38487
38548
|
write(auth, home) {
|
|
38488
38549
|
const credentialsFiles = [
|
|
38489
|
-
|
|
38490
|
-
|
|
38550
|
+
path83.join(home, ".kimi", "credentials", "kimi-code.json"),
|
|
38551
|
+
path83.join(home, ".kimi-code", "credentials", "kimi-code.json")
|
|
38491
38552
|
];
|
|
38492
38553
|
if (auth.kind === "api_key") {
|
|
38493
38554
|
credentialsFiles.forEach(rmIfExists);
|
|
38494
38555
|
return { KIMI_API_KEY: auth.value };
|
|
38495
38556
|
}
|
|
38496
38557
|
credentialsFiles.forEach((f) => writeFile0600(f, auth.value));
|
|
38497
|
-
writeFile0600(
|
|
38558
|
+
writeFile0600(path83.join(home, ".kimi-code", "config.toml"), KIMI_MANAGED_CONFIG_TOML);
|
|
38498
38559
|
return {};
|
|
38499
38560
|
}
|
|
38500
38561
|
};
|
|
38501
38562
|
var coderabbitProvisioner = {
|
|
38502
38563
|
write(auth, home) {
|
|
38503
|
-
const dir =
|
|
38504
|
-
const authJson =
|
|
38564
|
+
const dir = path83.join(home, ".coderabbit");
|
|
38565
|
+
const authJson = path83.join(dir, "auth.json");
|
|
38505
38566
|
if (auth.kind === "api_key") {
|
|
38506
38567
|
rmIfExists(authJson);
|
|
38507
38568
|
return { CODERABBIT_API_KEY: auth.value };
|
|
@@ -38513,13 +38574,13 @@ var coderabbitProvisioner = {
|
|
|
38513
38574
|
try {
|
|
38514
38575
|
const parsed = JSON.parse(value);
|
|
38515
38576
|
if (typeof parsed.file === "string" && typeof parsed.contents === "string") {
|
|
38516
|
-
file =
|
|
38577
|
+
file = path83.basename(parsed.file);
|
|
38517
38578
|
contents = parsed.contents;
|
|
38518
38579
|
}
|
|
38519
38580
|
} catch {
|
|
38520
38581
|
}
|
|
38521
38582
|
}
|
|
38522
|
-
writeFile0600(
|
|
38583
|
+
writeFile0600(path83.join(dir, file), contents);
|
|
38523
38584
|
return {};
|
|
38524
38585
|
}
|
|
38525
38586
|
};
|
|
@@ -38560,8 +38621,8 @@ function provisionAgentCredentials(publicAgentId, auth, homeDir2 = os54.homedir(
|
|
|
38560
38621
|
}
|
|
38561
38622
|
|
|
38562
38623
|
// src/beads/workflow-hint.ts
|
|
38563
|
-
var
|
|
38564
|
-
var
|
|
38624
|
+
var fs74 = __toESM(require("fs"));
|
|
38625
|
+
var path84 = __toESM(require("path"));
|
|
38565
38626
|
var BEADS_HINT_MARKER = "<!-- codeam:beads-workflow -->";
|
|
38566
38627
|
var BEADS_HINT = `${BEADS_HINT_MARKER}
|
|
38567
38628
|
# Beads (bd) \u2014 task tracking + persistent memory (ALWAYS use it)
|
|
@@ -38588,11 +38649,11 @@ function ensureBeadsWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
|
38588
38649
|
try {
|
|
38589
38650
|
let existing = "";
|
|
38590
38651
|
try {
|
|
38591
|
-
existing =
|
|
38652
|
+
existing = fs74.readFileSync(file, "utf8");
|
|
38592
38653
|
} catch {
|
|
38593
38654
|
}
|
|
38594
38655
|
if (existing.includes(BEADS_HINT)) return;
|
|
38595
|
-
|
|
38656
|
+
fs74.mkdirSync(path84.dirname(file), { recursive: true });
|
|
38596
38657
|
let next;
|
|
38597
38658
|
const open = existing.indexOf(BEADS_HINT_MARKER);
|
|
38598
38659
|
const close = open === -1 ? -1 : existing.indexOf(BEADS_HINT_MARKER, open + BEADS_HINT_MARKER.length);
|
|
@@ -38605,40 +38666,40 @@ ${BEADS_HINT}
|
|
|
38605
38666
|
` : `${BEADS_HINT}
|
|
38606
38667
|
`;
|
|
38607
38668
|
}
|
|
38608
|
-
|
|
38669
|
+
fs74.writeFileSync(file, next);
|
|
38609
38670
|
} catch {
|
|
38610
38671
|
}
|
|
38611
38672
|
}
|
|
38612
38673
|
|
|
38613
38674
|
// src/agents/agent-standard.ts
|
|
38614
|
-
var
|
|
38615
|
-
var
|
|
38675
|
+
var fs75 = __toESM(require("fs"));
|
|
38676
|
+
var path85 = __toESM(require("path"));
|
|
38616
38677
|
var os55 = __toESM(require("os"));
|
|
38617
38678
|
function ensureAgentStandard(homeDir2, file = claudeMemoryFile(homeDir2)) {
|
|
38618
38679
|
try {
|
|
38619
38680
|
let existing = "";
|
|
38620
38681
|
try {
|
|
38621
|
-
existing =
|
|
38682
|
+
existing = fs75.readFileSync(file, "utf8");
|
|
38622
38683
|
} catch {
|
|
38623
38684
|
}
|
|
38624
38685
|
if (existing.includes(AGENT_STANDARD_MARKER)) return;
|
|
38625
|
-
|
|
38686
|
+
fs75.mkdirSync(path85.dirname(file), { recursive: true });
|
|
38626
38687
|
const next = existing.trim() ? `${existing.trimEnd()}
|
|
38627
38688
|
|
|
38628
38689
|
${AGENT_STANDARD_BLOCK}
|
|
38629
38690
|
` : `${AGENT_STANDARD_BLOCK}
|
|
38630
38691
|
`;
|
|
38631
|
-
|
|
38692
|
+
fs75.writeFileSync(file, next);
|
|
38632
38693
|
} catch {
|
|
38633
38694
|
}
|
|
38634
38695
|
}
|
|
38635
38696
|
var _agentStandardSeam = {
|
|
38636
38697
|
isLocalSession: () => isLocalSession(),
|
|
38637
|
-
markerPath: (sessionId) =>
|
|
38638
|
-
exists: (p2) =>
|
|
38698
|
+
markerPath: (sessionId) => path85.join(os55.homedir(), ".codeam", "agent-standard", `${sessionId}.done`),
|
|
38699
|
+
exists: (p2) => fs75.existsSync(p2),
|
|
38639
38700
|
write: (p2) => {
|
|
38640
|
-
|
|
38641
|
-
|
|
38701
|
+
fs75.mkdirSync(path85.dirname(p2), { recursive: true });
|
|
38702
|
+
fs75.writeFileSync(p2, "");
|
|
38642
38703
|
}
|
|
38643
38704
|
};
|
|
38644
38705
|
function isClaude(agent) {
|
|
@@ -38659,8 +38720,8 @@ function maybePrefaceAgentStandard(blocks, agent, sessionId, seam = _agentStanda
|
|
|
38659
38720
|
}
|
|
38660
38721
|
|
|
38661
38722
|
// src/scratch/workflow-hint.ts
|
|
38662
|
-
var
|
|
38663
|
-
var
|
|
38723
|
+
var import_node_fs19 = __toESM(require("fs"));
|
|
38724
|
+
var import_node_path20 = __toESM(require("path"));
|
|
38664
38725
|
var SCRATCH_HINT_MARKER = "<!-- codeam:scratch-workflow -->";
|
|
38665
38726
|
var SCRATCH_HINT = `${SCRATCH_HINT_MARKER}
|
|
38666
38727
|
# From-scratch projects (CodeAgent Box)
|
|
@@ -38683,11 +38744,11 @@ function ensureScratchWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2))
|
|
|
38683
38744
|
try {
|
|
38684
38745
|
let existing = "";
|
|
38685
38746
|
try {
|
|
38686
|
-
existing =
|
|
38747
|
+
existing = import_node_fs19.default.readFileSync(file, "utf8");
|
|
38687
38748
|
} catch {
|
|
38688
38749
|
}
|
|
38689
38750
|
if (existing.includes(SCRATCH_HINT)) return;
|
|
38690
|
-
|
|
38751
|
+
import_node_fs19.default.mkdirSync(import_node_path20.default.dirname(file), { recursive: true });
|
|
38691
38752
|
const open = existing.indexOf(SCRATCH_HINT_MARKER);
|
|
38692
38753
|
const close = open === -1 ? -1 : existing.indexOf(SCRATCH_HINT_MARKER, open + SCRATCH_HINT_MARKER.length);
|
|
38693
38754
|
const next = open !== -1 && close !== -1 ? existing.slice(0, open) + SCRATCH_HINT + existing.slice(close + SCRATCH_HINT_MARKER.length) : existing.trim() ? `${existing.trimEnd()}
|
|
@@ -38695,7 +38756,7 @@ function ensureScratchWorkflowHint(homeDir2, file = claudeMemoryFile(homeDir2))
|
|
|
38695
38756
|
${SCRATCH_HINT}
|
|
38696
38757
|
` : `${SCRATCH_HINT}
|
|
38697
38758
|
`;
|
|
38698
|
-
|
|
38759
|
+
import_node_fs19.default.writeFileSync(file, next);
|
|
38699
38760
|
} catch {
|
|
38700
38761
|
}
|
|
38701
38762
|
}
|
|
@@ -39373,15 +39434,15 @@ function withholdTrailingPartialFenceMarker(text) {
|
|
|
39373
39434
|
|
|
39374
39435
|
// src/agents/acp/onboarding.ts
|
|
39375
39436
|
var import_child_process28 = require("child_process");
|
|
39376
|
-
var
|
|
39437
|
+
var fs77 = __toESM(require("fs"));
|
|
39377
39438
|
var os56 = __toESM(require("os"));
|
|
39378
|
-
var
|
|
39439
|
+
var path87 = __toESM(require("path"));
|
|
39379
39440
|
var _onboardingSeam = {
|
|
39380
|
-
markerPath: (sessionId) =>
|
|
39381
|
-
exists: (p2) =>
|
|
39441
|
+
markerPath: (sessionId) => path87.join(os56.homedir(), ".codeam", "welcomed", `${sessionId}.done`),
|
|
39442
|
+
exists: (p2) => fs77.existsSync(p2),
|
|
39382
39443
|
write: (p2) => {
|
|
39383
|
-
|
|
39384
|
-
|
|
39444
|
+
fs77.mkdirSync(path87.dirname(p2), { recursive: true });
|
|
39445
|
+
fs77.writeFileSync(p2, "");
|
|
39385
39446
|
},
|
|
39386
39447
|
disabled: () => {
|
|
39387
39448
|
const v = process.env.CODEAM_ONBOARDING_DISABLED;
|
|
@@ -39418,7 +39479,7 @@ function resolveRepoName(cwd) {
|
|
|
39418
39479
|
if (name) return name;
|
|
39419
39480
|
}
|
|
39420
39481
|
}
|
|
39421
|
-
const base =
|
|
39482
|
+
const base = path87.basename(cwd || "");
|
|
39422
39483
|
if (base && !isUuid(base)) return base;
|
|
39423
39484
|
return "this project";
|
|
39424
39485
|
}
|
|
@@ -39818,14 +39879,14 @@ var import_crypto5 = require("crypto");
|
|
|
39818
39879
|
|
|
39819
39880
|
// src/services/turn-files/git-changeset.ts
|
|
39820
39881
|
var import_child_process29 = require("child_process");
|
|
39821
|
-
var
|
|
39882
|
+
var fs79 = __toESM(require("fs/promises"));
|
|
39822
39883
|
var import_fs10 = require("fs");
|
|
39823
|
-
var
|
|
39884
|
+
var path89 = __toESM(require("path"));
|
|
39824
39885
|
|
|
39825
39886
|
// src/services/turn-files/review-ignore.ts
|
|
39826
39887
|
var import_ignore2 = __toESM(require("ignore"));
|
|
39827
|
-
var
|
|
39828
|
-
var
|
|
39888
|
+
var fs78 = __toESM(require("fs"));
|
|
39889
|
+
var path88 = __toESM(require("path"));
|
|
39829
39890
|
var CURATED_REVIEW_IGNORE = [
|
|
39830
39891
|
// Google Cloud SDK (the incident) — installs a huge python tree.
|
|
39831
39892
|
"google-cloud-sdk/",
|
|
@@ -39869,7 +39930,7 @@ var CURATED_REVIEW_IGNORE = [
|
|
|
39869
39930
|
function makeReviewIgnore(repoRoot) {
|
|
39870
39931
|
const ig = (0, import_ignore2.default)().add(CURATED_REVIEW_IGNORE);
|
|
39871
39932
|
try {
|
|
39872
|
-
const custom =
|
|
39933
|
+
const custom = fs78.readFileSync(path88.join(repoRoot, ".codeam", "reviewignore"), "utf8");
|
|
39873
39934
|
ig.add(custom);
|
|
39874
39935
|
} catch {
|
|
39875
39936
|
}
|
|
@@ -39904,7 +39965,7 @@ async function collectRepoChangeset(opts) {
|
|
|
39904
39965
|
const rows = parseStatus(status2).filter(
|
|
39905
39966
|
(row) => !isIgnoredFilePath(row.filePath) && !reviewIgnore(row.filePath) && // A socket, FIFO or device node is never a change to review (a
|
|
39906
39967
|
// `cc-socks/1522.sock` reached the Files tab).
|
|
39907
|
-
isReviewablePath(
|
|
39968
|
+
isReviewablePath(path89.join(opts.repoRoot, row.filePath))
|
|
39908
39969
|
);
|
|
39909
39970
|
const MAX_CHANGESET_FILES = Math.max(1, Number(process.env.CODEAM_MAX_CHANGESET_FILES ?? 500));
|
|
39910
39971
|
const truncated = rows.length > MAX_CHANGESET_FILES;
|
|
@@ -39921,7 +39982,7 @@ async function collectRepoChangeset(opts) {
|
|
|
39921
39982
|
let stats;
|
|
39922
39983
|
if (!truncated && row.fileStatus === "added" && numstatEntry === void 0) {
|
|
39923
39984
|
const lineCount = await readUntrackedLineCount(
|
|
39924
|
-
|
|
39985
|
+
path89.join(opts.repoRoot, row.filePath)
|
|
39925
39986
|
);
|
|
39926
39987
|
stats = { added: lineCount, removed: 0 };
|
|
39927
39988
|
} else {
|
|
@@ -39952,7 +40013,7 @@ function readUntrackedLineCount(absPath) {
|
|
|
39952
40013
|
}
|
|
39953
40014
|
async function defaultReadUntrackedLineCount(absPath) {
|
|
39954
40015
|
try {
|
|
39955
|
-
const content = await
|
|
40016
|
+
const content = await fs79.readFile(absPath, "utf8");
|
|
39956
40017
|
let count = 0;
|
|
39957
40018
|
let pos = -1;
|
|
39958
40019
|
while ((pos = content.indexOf("\n", pos + 1)) !== -1) {
|
|
@@ -40044,7 +40105,7 @@ function defaultRunGit(cwd, args2) {
|
|
|
40044
40105
|
});
|
|
40045
40106
|
}
|
|
40046
40107
|
async function discoverRepos(workingDir, maxDepth = 4) {
|
|
40047
|
-
const
|
|
40108
|
+
const fs102 = await import("fs/promises");
|
|
40048
40109
|
const out2 = [];
|
|
40049
40110
|
await walk2(workingDir, 0);
|
|
40050
40111
|
return out2;
|
|
@@ -40052,7 +40113,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
40052
40113
|
if (depth2 > maxDepth) return;
|
|
40053
40114
|
let entries2 = [];
|
|
40054
40115
|
try {
|
|
40055
|
-
const dirents = await
|
|
40116
|
+
const dirents = await fs102.readdir(dir, { withFileTypes: true });
|
|
40056
40117
|
entries2 = dirents.filter((d3) => !d3.name.startsWith(".") || d3.name === ".git").map((d3) => ({ name: d3.name, isDirectory: d3.isDirectory() }));
|
|
40057
40118
|
} catch {
|
|
40058
40119
|
return;
|
|
@@ -40063,8 +40124,8 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
40063
40124
|
if (hasGit) {
|
|
40064
40125
|
out2.push({
|
|
40065
40126
|
repoRoot: dir,
|
|
40066
|
-
repoPath:
|
|
40067
|
-
repoName:
|
|
40127
|
+
repoPath: path89.relative(workingDir, dir),
|
|
40128
|
+
repoName: path89.basename(dir)
|
|
40068
40129
|
});
|
|
40069
40130
|
return;
|
|
40070
40131
|
}
|
|
@@ -40072,7 +40133,7 @@ async function discoverRepos(workingDir, maxDepth = 4) {
|
|
|
40072
40133
|
if (!entry.isDirectory) continue;
|
|
40073
40134
|
if (entry.name === "node_modules") continue;
|
|
40074
40135
|
if (entry.name === "dist" || entry.name === "build") continue;
|
|
40075
|
-
await walk2(
|
|
40136
|
+
await walk2(path89.join(dir, entry.name), depth2 + 1);
|
|
40076
40137
|
}
|
|
40077
40138
|
}
|
|
40078
40139
|
}
|
|
@@ -40086,8 +40147,8 @@ function isReviewablePath(absPath) {
|
|
|
40086
40147
|
}
|
|
40087
40148
|
|
|
40088
40149
|
// src/services/turn-files/files-outbox.ts
|
|
40089
|
-
var
|
|
40090
|
-
var
|
|
40150
|
+
var fs80 = __toESM(require("fs/promises"));
|
|
40151
|
+
var path90 = __toESM(require("path"));
|
|
40091
40152
|
var import_os14 = require("os");
|
|
40092
40153
|
var HOME_OUTBOX_DIR = ".codeam/outbox";
|
|
40093
40154
|
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -40120,16 +40181,16 @@ var FilesOutbox = class {
|
|
|
40120
40181
|
backoffIndex = 0;
|
|
40121
40182
|
stopped = false;
|
|
40122
40183
|
constructor(opts) {
|
|
40123
|
-
const base = opts.baseDir ??
|
|
40124
|
-
this.filePath =
|
|
40184
|
+
const base = opts.baseDir ?? path90.join(homeDir(), HOME_OUTBOX_DIR);
|
|
40185
|
+
this.filePath = path90.join(base, `${opts.sessionId}.jsonl`);
|
|
40125
40186
|
this.post = opts.post;
|
|
40126
40187
|
this.autoSchedule = opts.autoSchedule !== false;
|
|
40127
40188
|
}
|
|
40128
40189
|
/** Persist the entry to disk and trigger a flush. Returns once the
|
|
40129
40190
|
* line is durable on disk (not once the POST succeeds). */
|
|
40130
40191
|
async enqueue(entry) {
|
|
40131
|
-
await
|
|
40132
|
-
await
|
|
40192
|
+
await fs80.mkdir(path90.dirname(this.filePath), { recursive: true });
|
|
40193
|
+
await fs80.appendFile(this.filePath, JSON.stringify(entry) + "\n", "utf8");
|
|
40133
40194
|
this.backoffIndex = 0;
|
|
40134
40195
|
if (this.autoSchedule) this.scheduleFlush(0);
|
|
40135
40196
|
}
|
|
@@ -40220,7 +40281,7 @@ var FilesOutbox = class {
|
|
|
40220
40281
|
async readAll() {
|
|
40221
40282
|
let raw = "";
|
|
40222
40283
|
try {
|
|
40223
|
-
raw = await
|
|
40284
|
+
raw = await fs80.readFile(this.filePath, "utf8");
|
|
40224
40285
|
} catch {
|
|
40225
40286
|
return [];
|
|
40226
40287
|
}
|
|
@@ -40244,12 +40305,12 @@ var FilesOutbox = class {
|
|
|
40244
40305
|
async rewrite(entries2) {
|
|
40245
40306
|
const tmpPath = `${this.filePath}.${process.pid}.tmp`;
|
|
40246
40307
|
if (entries2.length === 0) {
|
|
40247
|
-
await
|
|
40308
|
+
await fs80.unlink(this.filePath).catch(() => void 0);
|
|
40248
40309
|
return;
|
|
40249
40310
|
}
|
|
40250
40311
|
const payload = entries2.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
40251
|
-
await
|
|
40252
|
-
await
|
|
40312
|
+
await fs80.writeFile(tmpPath, payload, "utf8");
|
|
40313
|
+
await fs80.rename(tmpPath, this.filePath);
|
|
40253
40314
|
}
|
|
40254
40315
|
};
|
|
40255
40316
|
function applyJitter(ms) {
|
|
@@ -40569,15 +40630,15 @@ async function postCredentialSync(opts, fetchImpl = fetch) {
|
|
|
40569
40630
|
var import_node_crypto13 = require("crypto");
|
|
40570
40631
|
var import_promises6 = __toESM(require("fs/promises"));
|
|
40571
40632
|
var import_node_os14 = __toESM(require("os"));
|
|
40572
|
-
var
|
|
40633
|
+
var import_node_path21 = __toESM(require("path"));
|
|
40573
40634
|
function markerPath4(cwd, homeDir2 = import_node_os14.default.homedir()) {
|
|
40574
|
-
const key = (0, import_node_crypto13.createHash)("sha256").update(
|
|
40575
|
-
return
|
|
40635
|
+
const key = (0, import_node_crypto13.createHash)("sha256").update(import_node_path21.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
40636
|
+
return import_node_path21.default.join(homeDir2, ".codeam", "conversation-active", `${key}.json`);
|
|
40576
40637
|
}
|
|
40577
40638
|
async function writeActiveConversationMarker(cwd, conversationId, homeDir2) {
|
|
40578
40639
|
try {
|
|
40579
40640
|
const file = markerPath4(cwd, homeDir2);
|
|
40580
|
-
await import_promises6.default.mkdir(
|
|
40641
|
+
await import_promises6.default.mkdir(import_node_path21.default.dirname(file), { recursive: true });
|
|
40581
40642
|
await import_promises6.default.writeFile(
|
|
40582
40643
|
file,
|
|
40583
40644
|
JSON.stringify({ conversationId, at: (/* @__PURE__ */ new Date()).toISOString() }, null, 2) + "\n",
|
|
@@ -40598,8 +40659,8 @@ async function readActiveConversationMarker(cwd, homeDir2) {
|
|
|
40598
40659
|
|
|
40599
40660
|
// src/packs/gates.ts
|
|
40600
40661
|
var import_node_child_process29 = require("child_process");
|
|
40601
|
-
var
|
|
40602
|
-
var
|
|
40662
|
+
var fs82 = __toESM(require("fs"));
|
|
40663
|
+
var path92 = __toESM(require("path"));
|
|
40603
40664
|
var defaultCommandRunner = (file, args2, cwd, timeoutMs, env) => new Promise((resolve13) => {
|
|
40604
40665
|
(0, import_node_child_process29.execFile)(
|
|
40605
40666
|
file,
|
|
@@ -40649,7 +40710,7 @@ async function changedFiles(run3, cwd, from, to) {
|
|
|
40649
40710
|
}
|
|
40650
40711
|
function readWorkspaceFile(cwd, relPath) {
|
|
40651
40712
|
try {
|
|
40652
|
-
return
|
|
40713
|
+
return fs82.readFileSync(path92.join(cwd, relPath), "utf8");
|
|
40653
40714
|
} catch {
|
|
40654
40715
|
return null;
|
|
40655
40716
|
}
|
|
@@ -40658,14 +40719,14 @@ var NO_TEST_PLACEHOLDER = 'echo "Error: no test specified"';
|
|
|
40658
40719
|
var CHECKS_TIMEOUT_MS = 5 * 6e4;
|
|
40659
40720
|
function detectChecksCommand(cwd) {
|
|
40660
40721
|
try {
|
|
40661
|
-
const cfg = JSON.parse(
|
|
40722
|
+
const cfg = JSON.parse(fs82.readFileSync(path92.join(cwd, ".codeam", "pack.json"), "utf8"));
|
|
40662
40723
|
if (typeof cfg.checksCommand === "string" && cfg.checksCommand.trim().length > 0) {
|
|
40663
40724
|
return cfg.checksCommand.trim();
|
|
40664
40725
|
}
|
|
40665
40726
|
} catch {
|
|
40666
40727
|
}
|
|
40667
40728
|
try {
|
|
40668
|
-
const pkg = JSON.parse(
|
|
40729
|
+
const pkg = JSON.parse(fs82.readFileSync(path92.join(cwd, "package.json"), "utf8"));
|
|
40669
40730
|
const test = pkg.scripts?.test;
|
|
40670
40731
|
if (typeof test === "string" && test.trim().length > 0 && !test.includes(NO_TEST_PLACEHOLDER)) {
|
|
40671
40732
|
return "npm test";
|
|
@@ -40683,39 +40744,39 @@ ${res.stderr}`.trim();
|
|
|
40683
40744
|
}
|
|
40684
40745
|
|
|
40685
40746
|
// src/packs/run-store.ts
|
|
40686
|
-
var
|
|
40687
|
-
var
|
|
40747
|
+
var fs83 = __toESM(require("fs"));
|
|
40748
|
+
var path93 = __toESM(require("path"));
|
|
40688
40749
|
var crypto5 = __toESM(require("crypto"));
|
|
40689
40750
|
function packsDir(cwd) {
|
|
40690
|
-
return
|
|
40751
|
+
return path93.join(cwd, ".codeam", "packs");
|
|
40691
40752
|
}
|
|
40692
40753
|
function runDir(cwd, runId) {
|
|
40693
|
-
return
|
|
40754
|
+
return path93.join(packsDir(cwd), runId);
|
|
40694
40755
|
}
|
|
40695
40756
|
function newRunId() {
|
|
40696
40757
|
return `pk_${Date.now().toString(36)}_${crypto5.randomBytes(4).toString("hex")}`;
|
|
40697
40758
|
}
|
|
40698
40759
|
function writeJsonAtomic(file, value) {
|
|
40699
|
-
|
|
40760
|
+
fs83.mkdirSync(path93.dirname(file), { recursive: true });
|
|
40700
40761
|
const tmp = `${file}.tmp`;
|
|
40701
|
-
|
|
40702
|
-
|
|
40762
|
+
fs83.writeFileSync(tmp, JSON.stringify(value, null, 2));
|
|
40763
|
+
fs83.renameSync(tmp, file);
|
|
40703
40764
|
}
|
|
40704
40765
|
function saveRun(cwd, state) {
|
|
40705
|
-
writeJsonAtomic(
|
|
40766
|
+
writeJsonAtomic(path93.join(runDir(cwd, state.runId), "run.json"), state);
|
|
40706
40767
|
}
|
|
40707
40768
|
function saveStageHandoff(cwd, runId, stageIndex, role, handoff) {
|
|
40708
40769
|
const name = `${String(stageIndex + 1).padStart(2, "0")}-${role}.json`;
|
|
40709
|
-
writeJsonAtomic(
|
|
40770
|
+
writeJsonAtomic(path93.join(runDir(cwd, runId), name), handoff);
|
|
40710
40771
|
}
|
|
40711
40772
|
function loadLatestRun(cwd) {
|
|
40712
40773
|
try {
|
|
40713
40774
|
const dir = packsDir(cwd);
|
|
40714
|
-
const entries2 =
|
|
40775
|
+
const entries2 = fs83.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
40715
40776
|
for (let i = entries2.length - 1; i >= 0; i--) {
|
|
40716
|
-
const file =
|
|
40777
|
+
const file = path93.join(dir, entries2[i], "run.json");
|
|
40717
40778
|
try {
|
|
40718
|
-
const parsed = JSON.parse(
|
|
40779
|
+
const parsed = JSON.parse(fs83.readFileSync(file, "utf8"));
|
|
40719
40780
|
if (parsed && typeof parsed.runId === "string") return parsed;
|
|
40720
40781
|
} catch {
|
|
40721
40782
|
}
|
|
@@ -40726,17 +40787,17 @@ function loadLatestRun(cwd) {
|
|
|
40726
40787
|
}
|
|
40727
40788
|
function ensureLedgerIgnored(cwd) {
|
|
40728
40789
|
try {
|
|
40729
|
-
const gitDir =
|
|
40730
|
-
if (!
|
|
40731
|
-
const exclude =
|
|
40790
|
+
const gitDir = path93.join(cwd, ".git");
|
|
40791
|
+
if (!fs83.existsSync(gitDir)) return;
|
|
40792
|
+
const exclude = path93.join(gitDir, "info", "exclude");
|
|
40732
40793
|
let existing = "";
|
|
40733
40794
|
try {
|
|
40734
|
-
existing =
|
|
40795
|
+
existing = fs83.readFileSync(exclude, "utf8");
|
|
40735
40796
|
} catch {
|
|
40736
40797
|
}
|
|
40737
40798
|
if (existing.includes(".codeam/packs/")) return;
|
|
40738
|
-
|
|
40739
|
-
|
|
40799
|
+
fs83.mkdirSync(path93.dirname(exclude), { recursive: true });
|
|
40800
|
+
fs83.writeFileSync(exclude, `${existing.trimEnd()}
|
|
40740
40801
|
.codeam/packs/
|
|
40741
40802
|
`.trimStart());
|
|
40742
40803
|
} catch {
|
|
@@ -41513,20 +41574,20 @@ var packStatusH = async (ctx) => {
|
|
|
41513
41574
|
};
|
|
41514
41575
|
|
|
41515
41576
|
// src/integrations/manifest.ts
|
|
41516
|
-
var
|
|
41577
|
+
var import_node_fs20 = __toESM(require("fs"));
|
|
41517
41578
|
var import_node_os15 = __toESM(require("os"));
|
|
41518
|
-
var
|
|
41579
|
+
var import_node_path22 = __toESM(require("path"));
|
|
41519
41580
|
var SESSION_ID_RE = /^[A-Za-z0-9_-]{1,128}$/;
|
|
41520
41581
|
function sessionKey(sessionId) {
|
|
41521
41582
|
return sessionId && SESSION_ID_RE.test(sessionId) ? sessionId : null;
|
|
41522
41583
|
}
|
|
41523
41584
|
function integrationsManifestPath(sessionId) {
|
|
41524
41585
|
const key = sessionKey(sessionId);
|
|
41525
|
-
return
|
|
41586
|
+
return import_node_path22.default.join(import_node_os15.default.homedir(), ".codeam", key ? `integrations-${key}.json` : "integrations.json");
|
|
41526
41587
|
}
|
|
41527
41588
|
function readFile7(file) {
|
|
41528
41589
|
try {
|
|
41529
|
-
const raw = JSON.parse(
|
|
41590
|
+
const raw = JSON.parse(import_node_fs20.default.readFileSync(file, "utf8"));
|
|
41530
41591
|
if (!Array.isArray(raw?.integrations)) return null;
|
|
41531
41592
|
return raw;
|
|
41532
41593
|
} catch {
|
|
@@ -41534,7 +41595,7 @@ function readFile7(file) {
|
|
|
41534
41595
|
}
|
|
41535
41596
|
}
|
|
41536
41597
|
function hasSessionIntegrationsManifest(sessionId) {
|
|
41537
|
-
return sessionKey(sessionId) !== null &&
|
|
41598
|
+
return sessionKey(sessionId) !== null && import_node_fs20.default.existsSync(integrationsManifestPath(sessionId));
|
|
41538
41599
|
}
|
|
41539
41600
|
function readIntegrationsManifest(sessionId) {
|
|
41540
41601
|
if (hasSessionIntegrationsManifest(sessionId)) {
|
|
@@ -41545,10 +41606,10 @@ function readIntegrationsManifest(sessionId) {
|
|
|
41545
41606
|
function persistIntegrationsManifest(m, sessionId) {
|
|
41546
41607
|
try {
|
|
41547
41608
|
const file = integrationsManifestPath(sessionId);
|
|
41548
|
-
|
|
41609
|
+
import_node_fs20.default.mkdirSync(import_node_path22.default.dirname(file), { recursive: true, mode: 448 });
|
|
41549
41610
|
const tmp = `${file}.tmp-${process.pid}`;
|
|
41550
|
-
|
|
41551
|
-
|
|
41611
|
+
import_node_fs20.default.writeFileSync(tmp, JSON.stringify(m, null, 2), { encoding: "utf8", mode: 384 });
|
|
41612
|
+
import_node_fs20.default.renameSync(tmp, file);
|
|
41552
41613
|
restrictToOwner(file);
|
|
41553
41614
|
} catch (err) {
|
|
41554
41615
|
log.warn(
|
|
@@ -41559,7 +41620,7 @@ function persistIntegrationsManifest(m, sessionId) {
|
|
|
41559
41620
|
}
|
|
41560
41621
|
function clearIntegrationsManifest(sessionId) {
|
|
41561
41622
|
try {
|
|
41562
|
-
|
|
41623
|
+
import_node_fs20.default.rmSync(integrationsManifestPath(sessionId), { force: true });
|
|
41563
41624
|
} catch {
|
|
41564
41625
|
}
|
|
41565
41626
|
}
|
|
@@ -41731,20 +41792,20 @@ async function mcpRouter() {
|
|
|
41731
41792
|
}
|
|
41732
41793
|
|
|
41733
41794
|
// src/integrations/mcp-secrets.ts
|
|
41734
|
-
var
|
|
41795
|
+
var fs85 = __toESM(require("fs"));
|
|
41735
41796
|
var os59 = __toESM(require("os"));
|
|
41736
|
-
var
|
|
41797
|
+
var path95 = __toESM(require("path"));
|
|
41737
41798
|
var MCP_SECRETS_FILE_ENV = "CODEAM_MCP_SECRETS_FILE";
|
|
41738
41799
|
function mcpSecretsDir() {
|
|
41739
|
-
return
|
|
41800
|
+
return path95.join(os59.homedir(), ".codeam", "mcp-secrets");
|
|
41740
41801
|
}
|
|
41741
41802
|
function mcpSecretsPath(scope, pid = process.pid) {
|
|
41742
|
-
return
|
|
41803
|
+
return path95.join(mcpSecretsDir(), `${pid}-${scope}.json`);
|
|
41743
41804
|
}
|
|
41744
41805
|
var registeredForCleanup = /* @__PURE__ */ new Set();
|
|
41745
41806
|
function readFileVars(file) {
|
|
41746
41807
|
try {
|
|
41747
|
-
const parsed = JSON.parse(
|
|
41808
|
+
const parsed = JSON.parse(fs85.readFileSync(file, "utf8"));
|
|
41748
41809
|
if (!parsed || typeof parsed !== "object") return {};
|
|
41749
41810
|
const out2 = {};
|
|
41750
41811
|
for (const [k2, v] of Object.entries(parsed)) {
|
|
@@ -41766,7 +41827,7 @@ function pidAlive2(pid) {
|
|
|
41766
41827
|
function pruneStale(dir) {
|
|
41767
41828
|
let names = [];
|
|
41768
41829
|
try {
|
|
41769
|
-
names =
|
|
41830
|
+
names = fs85.readdirSync(dir);
|
|
41770
41831
|
} catch {
|
|
41771
41832
|
return;
|
|
41772
41833
|
}
|
|
@@ -41776,25 +41837,25 @@ function pruneStale(dir) {
|
|
|
41776
41837
|
const pid = Number(m[1]);
|
|
41777
41838
|
if (pid === process.pid || pidAlive2(pid)) continue;
|
|
41778
41839
|
try {
|
|
41779
|
-
|
|
41840
|
+
fs85.unlinkSync(path95.join(dir, name));
|
|
41780
41841
|
} catch {
|
|
41781
41842
|
}
|
|
41782
41843
|
}
|
|
41783
41844
|
}
|
|
41784
41845
|
function writeMcpSecrets(vars, file) {
|
|
41785
41846
|
try {
|
|
41786
|
-
const dir =
|
|
41787
|
-
|
|
41847
|
+
const dir = path95.dirname(file);
|
|
41848
|
+
fs85.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
41788
41849
|
pruneStale(dir);
|
|
41789
41850
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
41790
|
-
|
|
41791
|
-
|
|
41792
|
-
|
|
41851
|
+
fs85.writeFileSync(tmp, JSON.stringify(vars), { mode: 384 });
|
|
41852
|
+
fs85.renameSync(tmp, file);
|
|
41853
|
+
fs85.chmodSync(file, 384);
|
|
41793
41854
|
if (!registeredForCleanup.has(file)) {
|
|
41794
41855
|
registeredForCleanup.add(file);
|
|
41795
41856
|
process.once("exit", () => {
|
|
41796
41857
|
try {
|
|
41797
|
-
|
|
41858
|
+
fs85.unlinkSync(file);
|
|
41798
41859
|
} catch {
|
|
41799
41860
|
}
|
|
41800
41861
|
});
|
|
@@ -41826,14 +41887,18 @@ var SHORT_TIMEOUT_MS = 2e4;
|
|
|
41826
41887
|
var PREVIEW_TOOLS = [
|
|
41827
41888
|
{
|
|
41828
41889
|
name: "start_preview",
|
|
41829
|
-
description: `Open this project's live Preview in the user's CodeAgent app \u2014 the same thing as their Preview button: it installs dependencies if needed, starts the dev server, publishes it on a public URL and switches the user's screen to it. Use it after you change anything visual (UI, styles, layout, copy) so you and the user can check the result, or whenever the user asks to see the app. Returns the public URL (you can curl it) or the exact error. Only give the user a preview link when this tool says the preview is live \u2014 after an error or a "still starting" answer there is NO working link. Reuses a preview that is already running (code changes hot-reload; never stop and start it to refresh). Usually leave the arguments out: the project is detected automatically. Pass command/args/port only if you know the exact dev command.`,
|
|
41890
|
+
description: `Open this project's live Preview in the user's CodeAgent app \u2014 the same thing as their Preview button: it installs dependencies if needed, starts the dev server, publishes it on a public URL and switches the user's screen to it. Use it after you change anything visual (UI, styles, layout, copy) so you and the user can check the result, or whenever the user asks to see the app. Returns the public URL (you can curl it) or the exact error. Only give the user a preview link when this tool says the preview is live \u2014 after an error or a "still starting" answer there is NO working link. The user is on their phone: a localhost / 127.0.0.1 address, or a server you started yourself in a shell, never opens for them \u2014 the URL this tool returns is the only link to give. Reuses a preview that is already running (code changes hot-reload; never stop and start it to refresh). Usually leave the arguments out: the project is detected automatically. Pass command/args/port only if you know the exact dev command.`,
|
|
41830
41891
|
inputSchema: {
|
|
41831
41892
|
type: "object",
|
|
41832
41893
|
properties: {
|
|
41833
41894
|
command: { type: "string", description: 'Dev server executable, e.g. "npm". Optional.' },
|
|
41834
41895
|
args: { type: "array", items: { type: "string" }, description: 'e.g. ["run","dev"]. Optional.' },
|
|
41835
41896
|
port: { type: "number", description: "Port the dev server listens on. Required with command." },
|
|
41836
|
-
framework: { type: "string", description: 'Label shown to the user, e.g. "next". Optional.' }
|
|
41897
|
+
framework: { type: "string", description: 'Label shown to the user, e.g. "next". Optional.' },
|
|
41898
|
+
cwd: {
|
|
41899
|
+
type: "string",
|
|
41900
|
+
description: 'Folder the command runs in, relative to the project root, when the app lives in a subfolder (e.g. "teleshop"). command/args are then relative to it (".venv/bin/python"). Never "cd \u2026 &&": the command runs without a shell. Optional.'
|
|
41901
|
+
}
|
|
41837
41902
|
},
|
|
41838
41903
|
additionalProperties: false
|
|
41839
41904
|
}
|
|
@@ -41880,11 +41945,11 @@ function previewMcpServer(bridge) {
|
|
|
41880
41945
|
};
|
|
41881
41946
|
}
|
|
41882
41947
|
function httpCall(baseUrl, token) {
|
|
41883
|
-
return async (
|
|
41948
|
+
return async (path116, method, body, timeoutMs) => {
|
|
41884
41949
|
const ac = new AbortController();
|
|
41885
41950
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
41886
41951
|
try {
|
|
41887
|
-
const res = await fetch(`${baseUrl}${
|
|
41952
|
+
const res = await fetch(`${baseUrl}${path116}`, {
|
|
41888
41953
|
method,
|
|
41889
41954
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
41890
41955
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -42017,11 +42082,11 @@ function scratchMcpServer(bridge) {
|
|
|
42017
42082
|
};
|
|
42018
42083
|
}
|
|
42019
42084
|
function httpCall2(baseUrl, token) {
|
|
42020
|
-
return async (
|
|
42085
|
+
return async (path116, method, body, timeoutMs) => {
|
|
42021
42086
|
const ac = new AbortController();
|
|
42022
42087
|
const timer = setTimeout(() => ac.abort(), timeoutMs);
|
|
42023
42088
|
try {
|
|
42024
|
-
const res = await fetch(`${baseUrl}${
|
|
42089
|
+
const res = await fetch(`${baseUrl}${path116}`, {
|
|
42025
42090
|
method,
|
|
42026
42091
|
headers: { authorization: `Bearer ${token}`, "content-type": "application/json" },
|
|
42027
42092
|
...method === "POST" ? { body: JSON.stringify(body ?? {}) } : {},
|
|
@@ -42147,12 +42212,12 @@ function buildIntegrationMcpServers(ctx) {
|
|
|
42147
42212
|
}
|
|
42148
42213
|
|
|
42149
42214
|
// src/services/local-mcp-servers.ts
|
|
42150
|
-
var
|
|
42215
|
+
var import_node_fs21 = __toESM(require("fs"));
|
|
42151
42216
|
var import_node_os16 = __toESM(require("os"));
|
|
42152
|
-
var
|
|
42217
|
+
var import_node_path23 = __toESM(require("path"));
|
|
42153
42218
|
var MAX_LOCAL_MCP_SERVERS = 10;
|
|
42154
42219
|
function localMcpServersPath() {
|
|
42155
|
-
return
|
|
42220
|
+
return import_node_path23.default.join(import_node_os16.default.homedir(), ".codeam", "mcp-servers.json");
|
|
42156
42221
|
}
|
|
42157
42222
|
function isStringArray(v) {
|
|
42158
42223
|
return Array.isArray(v) && v.every((item) => typeof item === "string");
|
|
@@ -42170,7 +42235,7 @@ function isValidEntry(entry) {
|
|
|
42170
42235
|
function readLocalMcpServers() {
|
|
42171
42236
|
let raw;
|
|
42172
42237
|
try {
|
|
42173
|
-
raw =
|
|
42238
|
+
raw = import_node_fs21.default.readFileSync(localMcpServersPath(), "utf8");
|
|
42174
42239
|
} catch {
|
|
42175
42240
|
return [];
|
|
42176
42241
|
}
|
|
@@ -42543,7 +42608,7 @@ function running(active2, reused) {
|
|
|
42543
42608
|
}
|
|
42544
42609
|
var RESTART_CAPPED_MESSAGE = `The preview was already restarted ${MAX_AGENT_RESTARTS} times in the last ${AGENT_RESTART_WINDOW_MS / 6e4} minutes, so it stays as it is. Dev servers hot-reload: your code changes show up without a restart. If it is genuinely broken, tell the user what you saw.`;
|
|
42545
42610
|
function sameCommand(a, b) {
|
|
42546
|
-
return a.command === b.command && a.port === b.port && JSON.stringify(a.args ?? []) === JSON.stringify(b.args ?? []);
|
|
42611
|
+
return a.command === b.command && a.port === b.port && (a.cwd ?? ".") === (b.cwd ?? ".") && JSON.stringify(a.args ?? []) === JSON.stringify(b.args ?? []);
|
|
42547
42612
|
}
|
|
42548
42613
|
function detectionFromOverride(o) {
|
|
42549
42614
|
if (!o.command || !Number.isInteger(o.port) || o.port <= 0 || o.port > 65535) return null;
|
|
@@ -42553,7 +42618,8 @@ function detectionFromOverride(o) {
|
|
|
42553
42618
|
args: Array.isArray(o.args) ? o.args.map(String) : [],
|
|
42554
42619
|
port: o.port,
|
|
42555
42620
|
// Any Local/ready/listening line; the TCP probe is the real fallback.
|
|
42556
|
-
ready_pattern: o.ready_pattern?.trim() || "(ready|local:|listening|started server|compiled)"
|
|
42621
|
+
ready_pattern: o.ready_pattern?.trim() || "(ready|local:|listening|started server|compiled)",
|
|
42622
|
+
...o.cwd?.trim() ? { cwd: o.cwd.trim() } : {}
|
|
42557
42623
|
};
|
|
42558
42624
|
}
|
|
42559
42625
|
function overrideFrom(body) {
|
|
@@ -42563,7 +42629,8 @@ function overrideFrom(body) {
|
|
|
42563
42629
|
args: Array.isArray(body.args) ? body.args.map(String) : void 0,
|
|
42564
42630
|
port: body.port,
|
|
42565
42631
|
framework: typeof body.framework === "string" ? body.framework : void 0,
|
|
42566
|
-
ready_pattern: typeof body.ready_pattern === "string" ? body.ready_pattern : void 0
|
|
42632
|
+
ready_pattern: typeof body.ready_pattern === "string" ? body.ready_pattern : void 0,
|
|
42633
|
+
cwd: typeof body.cwd === "string" ? body.cwd : void 0
|
|
42567
42634
|
};
|
|
42568
42635
|
}
|
|
42569
42636
|
function authorized(header, token) {
|
|
@@ -42597,11 +42664,11 @@ function readJson(req) {
|
|
|
42597
42664
|
var agentPreviewBridge = new AgentPreviewBridge();
|
|
42598
42665
|
|
|
42599
42666
|
// src/integrations/detect-stack.ts
|
|
42600
|
-
var
|
|
42601
|
-
var
|
|
42667
|
+
var import_node_fs22 = __toESM(require("fs"));
|
|
42668
|
+
var import_node_path24 = __toESM(require("path"));
|
|
42602
42669
|
function readSafe(cwd, rel) {
|
|
42603
42670
|
try {
|
|
42604
|
-
return
|
|
42671
|
+
return import_node_fs22.default.readFileSync(import_node_path24.default.join(cwd, rel), "utf8");
|
|
42605
42672
|
} catch {
|
|
42606
42673
|
return "";
|
|
42607
42674
|
}
|
|
@@ -45116,17 +45183,17 @@ async function runAcpSession(opts) {
|
|
|
45116
45183
|
switchCredentialEnv = provisionAgentCredentials(agentId, auth);
|
|
45117
45184
|
},
|
|
45118
45185
|
provisionHouseProxy: ({ baseUrl, token, model, managedAgentId }) => {
|
|
45119
|
-
const claudeConfigDir2 =
|
|
45186
|
+
const claudeConfigDir2 = path98.join(
|
|
45120
45187
|
os61.homedir(),
|
|
45121
45188
|
".codeam",
|
|
45122
45189
|
"house-claude",
|
|
45123
45190
|
`switch-${opts.pluginId}`
|
|
45124
45191
|
);
|
|
45125
45192
|
try {
|
|
45126
|
-
|
|
45193
|
+
fs88.mkdirSync(claudeConfigDir2, { recursive: true, mode: 448 });
|
|
45127
45194
|
} catch {
|
|
45128
45195
|
}
|
|
45129
|
-
const memoryFile =
|
|
45196
|
+
const memoryFile = path98.join(claudeConfigDir2, "CLAUDE.md");
|
|
45130
45197
|
ensureBeadsWorkflowHint(void 0, memoryFile);
|
|
45131
45198
|
ensureAgentStandard(void 0, memoryFile);
|
|
45132
45199
|
if (isScratchWorkspace(process.cwd())) ensureScratchWorkflowHint(void 0, memoryFile);
|
|
@@ -46357,8 +46424,8 @@ function pickPinnedSession(pinnedId, listSessions2) {
|
|
|
46357
46424
|
}
|
|
46358
46425
|
|
|
46359
46426
|
// src/agents/retired-proxy-cleanup.ts
|
|
46360
|
-
var
|
|
46361
|
-
var
|
|
46427
|
+
var fs89 = __toESM(require("fs"));
|
|
46428
|
+
var path99 = __toESM(require("path"));
|
|
46362
46429
|
var os62 = __toESM(require("os"));
|
|
46363
46430
|
var RETIRED_PROXY_RE = /^https?:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):8787(?:[/?#]|$)/i;
|
|
46364
46431
|
var HEADROOM_CMD_RE = /(^|[\s/"'])headroom(\s|$)/i;
|
|
@@ -46370,10 +46437,10 @@ function isHeadroomHook(group) {
|
|
|
46370
46437
|
}
|
|
46371
46438
|
function sanitizeRetiredProxyConfig(homeDir2 = os62.homedir()) {
|
|
46372
46439
|
const out2 = { inspected: false, changed: false, removed: [] };
|
|
46373
|
-
const file =
|
|
46440
|
+
const file = path99.join(homeDir2, ".claude", "settings.json");
|
|
46374
46441
|
let parsed;
|
|
46375
46442
|
try {
|
|
46376
|
-
parsed = JSON.parse(
|
|
46443
|
+
parsed = JSON.parse(fs89.readFileSync(file, "utf8"));
|
|
46377
46444
|
} catch {
|
|
46378
46445
|
return out2;
|
|
46379
46446
|
}
|
|
@@ -46415,9 +46482,9 @@ function sanitizeRetiredProxyConfig(homeDir2 = os62.homedir()) {
|
|
|
46415
46482
|
if (!out2.changed) return out2;
|
|
46416
46483
|
try {
|
|
46417
46484
|
const tmp = `${file}.codeam.tmp`;
|
|
46418
|
-
|
|
46485
|
+
fs89.writeFileSync(tmp, `${JSON.stringify(parsed, null, 2)}
|
|
46419
46486
|
`, { mode: 384 });
|
|
46420
|
-
|
|
46487
|
+
fs89.renameSync(tmp, file);
|
|
46421
46488
|
} catch {
|
|
46422
46489
|
out2.changed = false;
|
|
46423
46490
|
}
|
|
@@ -46959,7 +47026,7 @@ var AcpDriver = class {
|
|
|
46959
47026
|
};
|
|
46960
47027
|
|
|
46961
47028
|
// src/baton/transcript-mirror.ts
|
|
46962
|
-
var
|
|
47029
|
+
var fs90 = __toESM(require("fs"));
|
|
46963
47030
|
var TranscriptMirror = class {
|
|
46964
47031
|
constructor(deps) {
|
|
46965
47032
|
this.deps = deps;
|
|
@@ -47053,7 +47120,7 @@ var TranscriptMirror = class {
|
|
|
47053
47120
|
}
|
|
47054
47121
|
};
|
|
47055
47122
|
function defaultWatch(file, onChange) {
|
|
47056
|
-
const w3 =
|
|
47123
|
+
const w3 = fs90.watch(file, { persistent: false }, () => onChange());
|
|
47057
47124
|
return () => w3.close();
|
|
47058
47125
|
}
|
|
47059
47126
|
|
|
@@ -47553,16 +47620,16 @@ function keepDeviceAwake(deps = {}) {
|
|
|
47553
47620
|
}
|
|
47554
47621
|
|
|
47555
47622
|
// src/agents/claude/onboarding.ts
|
|
47556
|
-
var
|
|
47623
|
+
var fs91 = __toESM(require("fs"));
|
|
47557
47624
|
var os64 = __toESM(require("os"));
|
|
47558
|
-
var
|
|
47625
|
+
var path100 = __toESM(require("path"));
|
|
47559
47626
|
var ONBOARDING_VERSION_SENTINEL = "9999.0.0";
|
|
47560
47627
|
function ensureClaudeOnboarded(cwd) {
|
|
47561
47628
|
try {
|
|
47562
|
-
const file =
|
|
47629
|
+
const file = path100.join(os64.homedir(), ".claude.json");
|
|
47563
47630
|
let config = {};
|
|
47564
47631
|
try {
|
|
47565
|
-
config = JSON.parse(
|
|
47632
|
+
config = JSON.parse(fs91.readFileSync(file, "utf8"));
|
|
47566
47633
|
} catch {
|
|
47567
47634
|
}
|
|
47568
47635
|
let changed = false;
|
|
@@ -47587,8 +47654,8 @@ function ensureClaudeOnboarded(cwd) {
|
|
|
47587
47654
|
}
|
|
47588
47655
|
}
|
|
47589
47656
|
if (!changed) return;
|
|
47590
|
-
|
|
47591
|
-
|
|
47657
|
+
fs91.mkdirSync(path100.dirname(file), { recursive: true });
|
|
47658
|
+
fs91.writeFileSync(file, JSON.stringify(config, null, 2));
|
|
47592
47659
|
log.info(
|
|
47593
47660
|
"claude",
|
|
47594
47661
|
`pre-completed Claude onboarding${cwd ? ` + trusted workspace ${cwd}` : ""}`
|
|
@@ -48443,7 +48510,7 @@ var import_picocolors10 = __toESM(require("picocolors"));
|
|
|
48443
48510
|
var import_child_process30 = require("child_process");
|
|
48444
48511
|
var import_util4 = require("util");
|
|
48445
48512
|
var import_picocolors8 = __toESM(require("picocolors"));
|
|
48446
|
-
var
|
|
48513
|
+
var path101 = __toESM(require("path"));
|
|
48447
48514
|
var execFileP6 = (0, import_util4.promisify)(import_child_process30.execFile);
|
|
48448
48515
|
var MAX_BUFFER = 8 * 1024 * 1024;
|
|
48449
48516
|
function resetStdinForChild() {
|
|
@@ -48932,7 +48999,7 @@ var GitHubCodespacesProvider = class {
|
|
|
48932
48999
|
});
|
|
48933
49000
|
}
|
|
48934
49001
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
48935
|
-
const remoteDir =
|
|
49002
|
+
const remoteDir = path101.posix.dirname(remotePath);
|
|
48936
49003
|
const parts = [
|
|
48937
49004
|
`mkdir -p ${shellQuote(remoteDir)}`,
|
|
48938
49005
|
`cat > ${shellQuote(remotePath)}`
|
|
@@ -49002,7 +49069,7 @@ function shellQuote(s) {
|
|
|
49002
49069
|
// src/services/providers/gitpod.ts
|
|
49003
49070
|
var import_child_process31 = require("child_process");
|
|
49004
49071
|
var import_util5 = require("util");
|
|
49005
|
-
var
|
|
49072
|
+
var path102 = __toESM(require("path"));
|
|
49006
49073
|
var import_picocolors9 = __toESM(require("picocolors"));
|
|
49007
49074
|
var execFileP7 = (0, import_util5.promisify)(import_child_process31.execFile);
|
|
49008
49075
|
var MAX_BUFFER2 = 8 * 1024 * 1024;
|
|
@@ -49242,7 +49309,7 @@ var GitpodProvider = class {
|
|
|
49242
49309
|
});
|
|
49243
49310
|
}
|
|
49244
49311
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
49245
|
-
const remoteDir =
|
|
49312
|
+
const remoteDir = path102.posix.dirname(remotePath);
|
|
49246
49313
|
const parts = [
|
|
49247
49314
|
`mkdir -p ${shellQuote2(remoteDir)}`,
|
|
49248
49315
|
`cat > ${shellQuote2(remotePath)}`
|
|
@@ -49278,7 +49345,7 @@ function shellQuote2(s) {
|
|
|
49278
49345
|
// src/services/providers/gitlab-workspaces.ts
|
|
49279
49346
|
var import_child_process32 = require("child_process");
|
|
49280
49347
|
var import_util6 = require("util");
|
|
49281
|
-
var
|
|
49348
|
+
var path103 = __toESM(require("path"));
|
|
49282
49349
|
var execFileP8 = (0, import_util6.promisify)(import_child_process32.execFile);
|
|
49283
49350
|
var MAX_BUFFER3 = 8 * 1024 * 1024;
|
|
49284
49351
|
var GITLAB_API_BASE = process.env.CODEAM_GITLAB_API_URL ?? "https://gitlab.com/api/v4";
|
|
@@ -49538,7 +49605,7 @@ Docs: https://docs.gitlab.com/ee/user/workspace/configuration.html`
|
|
|
49538
49605
|
}
|
|
49539
49606
|
async uploadFile(workspaceId, remotePath, contents, options = {}) {
|
|
49540
49607
|
const sshHost = process.env.CODEAM_GITLAB_SSH_HOST ?? "workspaces.gitlab.com";
|
|
49541
|
-
const remoteDir =
|
|
49608
|
+
const remoteDir = path103.posix.dirname(remotePath);
|
|
49542
49609
|
const parts = [`mkdir -p ${shellQuote3(remoteDir)}`, `cat > ${shellQuote3(remotePath)}`];
|
|
49543
49610
|
if (options.mode != null) {
|
|
49544
49611
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote3(remotePath)}`);
|
|
@@ -49606,7 +49673,7 @@ function shellQuote3(s) {
|
|
|
49606
49673
|
// src/services/providers/railway.ts
|
|
49607
49674
|
var import_child_process33 = require("child_process");
|
|
49608
49675
|
var import_util7 = require("util");
|
|
49609
|
-
var
|
|
49676
|
+
var path104 = __toESM(require("path"));
|
|
49610
49677
|
var execFileP9 = (0, import_util7.promisify)(import_child_process33.execFile);
|
|
49611
49678
|
var MAX_BUFFER4 = 8 * 1024 * 1024;
|
|
49612
49679
|
function resetStdinForChild4() {
|
|
@@ -49842,7 +49909,7 @@ var RailwayProvider = class {
|
|
|
49842
49909
|
if (!projectId || !serviceId) {
|
|
49843
49910
|
throw new Error("Invalid Railway workspace id (expected projectId/serviceId).");
|
|
49844
49911
|
}
|
|
49845
|
-
const remoteDir =
|
|
49912
|
+
const remoteDir = path104.posix.dirname(remotePath);
|
|
49846
49913
|
const parts = [`mkdir -p ${shellQuote4(remoteDir)}`, `cat > ${shellQuote4(remotePath)}`];
|
|
49847
49914
|
if (options.mode != null) {
|
|
49848
49915
|
parts.push(`chmod ${options.mode.toString(8)} ${shellQuote4(remotePath)}`);
|
|
@@ -50382,9 +50449,9 @@ async function stopWorkspaceFromLocal(target) {
|
|
|
50382
50449
|
}
|
|
50383
50450
|
|
|
50384
50451
|
// src/commands/host/host-client.ts
|
|
50385
|
-
var
|
|
50452
|
+
var fs92 = __toESM(require("fs"));
|
|
50386
50453
|
var os65 = __toESM(require("os"));
|
|
50387
|
-
var
|
|
50454
|
+
var path105 = __toESM(require("path"));
|
|
50388
50455
|
var import_node_crypto16 = require("crypto");
|
|
50389
50456
|
function sampleCpuTimes() {
|
|
50390
50457
|
let idle = 0;
|
|
@@ -50433,7 +50500,7 @@ function apiBase() {
|
|
|
50433
50500
|
return process.env.CODEAM_API_URL ?? resolveApiBaseUrl();
|
|
50434
50501
|
}
|
|
50435
50502
|
function hostIdentityPath() {
|
|
50436
|
-
return
|
|
50503
|
+
return path105.join(os65.homedir(), ".codeam", "host-agent.json");
|
|
50437
50504
|
}
|
|
50438
50505
|
function collectOsInfo() {
|
|
50439
50506
|
return {
|
|
@@ -50445,7 +50512,7 @@ function collectOsInfo() {
|
|
|
50445
50512
|
}
|
|
50446
50513
|
function loadHostIdentity() {
|
|
50447
50514
|
try {
|
|
50448
|
-
const raw =
|
|
50515
|
+
const raw = fs92.readFileSync(hostIdentityPath(), "utf8");
|
|
50449
50516
|
const parsed = JSON.parse(raw);
|
|
50450
50517
|
if (typeof parsed === "object" && parsed !== null && typeof parsed.hostId === "string" && typeof parsed.hostToken === "string" && typeof parsed.controlPluginId === "string") {
|
|
50451
50518
|
const p2 = parsed;
|
|
@@ -50473,8 +50540,8 @@ function ensureControlPollSecret(identity, save = saveHostIdentity) {
|
|
|
50473
50540
|
}
|
|
50474
50541
|
function saveHostIdentity(identity) {
|
|
50475
50542
|
const file = hostIdentityPath();
|
|
50476
|
-
|
|
50477
|
-
|
|
50543
|
+
fs92.mkdirSync(path105.dirname(file), { recursive: true, mode: 448 });
|
|
50544
|
+
fs92.writeFileSync(file, JSON.stringify(identity, null, 2), {
|
|
50478
50545
|
encoding: "utf8",
|
|
50479
50546
|
mode: 384
|
|
50480
50547
|
});
|
|
@@ -50519,7 +50586,7 @@ function isTerminalEnrollError(err) {
|
|
|
50519
50586
|
}
|
|
50520
50587
|
function deleteHostIdentity() {
|
|
50521
50588
|
try {
|
|
50522
|
-
|
|
50589
|
+
fs92.rmSync(hostIdentityPath(), { force: true });
|
|
50523
50590
|
} catch {
|
|
50524
50591
|
}
|
|
50525
50592
|
}
|
|
@@ -50748,8 +50815,8 @@ async function host(args2) {
|
|
|
50748
50815
|
// src/commands/host-agent.ts
|
|
50749
50816
|
var import_node_child_process38 = require("child_process");
|
|
50750
50817
|
var os71 = __toESM(require("os"));
|
|
50751
|
-
var
|
|
50752
|
-
var
|
|
50818
|
+
var fs99 = __toESM(require("fs"));
|
|
50819
|
+
var path112 = __toESM(require("path"));
|
|
50753
50820
|
|
|
50754
50821
|
// src/skills/persist-from-payload.ts
|
|
50755
50822
|
function persistOrClearSkillsFromPayload(skills) {
|
|
@@ -50758,13 +50825,13 @@ function persistOrClearSkillsFromPayload(skills) {
|
|
|
50758
50825
|
}
|
|
50759
50826
|
|
|
50760
50827
|
// src/commands/host/session-state.ts
|
|
50761
|
-
var
|
|
50828
|
+
var fs93 = __toESM(require("fs"));
|
|
50762
50829
|
var os66 = __toESM(require("os"));
|
|
50763
|
-
var
|
|
50830
|
+
var path106 = __toESM(require("path"));
|
|
50764
50831
|
function hostSessionStatePath(env = process.env) {
|
|
50765
50832
|
const override = env.CODEAM_HOST_SESSION_STATE_FILE;
|
|
50766
50833
|
if (override && override.trim()) return override.trim();
|
|
50767
|
-
return
|
|
50834
|
+
return path106.join(os66.homedir(), ".codeam", "host-agent-sessions.json");
|
|
50768
50835
|
}
|
|
50769
50836
|
function isRecord5(v) {
|
|
50770
50837
|
if (typeof v !== "object" || v === null) return false;
|
|
@@ -50775,7 +50842,7 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
50775
50842
|
return {
|
|
50776
50843
|
load() {
|
|
50777
50844
|
try {
|
|
50778
|
-
const raw = JSON.parse(
|
|
50845
|
+
const raw = JSON.parse(fs93.readFileSync(file, "utf8"));
|
|
50779
50846
|
return Array.isArray(raw?.sessions) ? raw.sessions.filter(isRecord5) : null;
|
|
50780
50847
|
} catch {
|
|
50781
50848
|
return null;
|
|
@@ -50783,18 +50850,18 @@ function fileSessionChildStore(file = hostSessionStatePath()) {
|
|
|
50783
50850
|
},
|
|
50784
50851
|
save(list) {
|
|
50785
50852
|
try {
|
|
50786
|
-
|
|
50853
|
+
fs93.mkdirSync(path106.dirname(file), { recursive: true, mode: 448 });
|
|
50787
50854
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
50788
|
-
|
|
50855
|
+
fs93.writeFileSync(tmp, JSON.stringify({ version: 1, sessions: list }, null, 2), {
|
|
50789
50856
|
mode: 384
|
|
50790
50857
|
});
|
|
50791
|
-
|
|
50858
|
+
fs93.renameSync(tmp, file);
|
|
50792
50859
|
} catch {
|
|
50793
50860
|
}
|
|
50794
50861
|
},
|
|
50795
50862
|
clear() {
|
|
50796
50863
|
try {
|
|
50797
|
-
|
|
50864
|
+
fs93.rmSync(file, { force: true });
|
|
50798
50865
|
} catch {
|
|
50799
50866
|
}
|
|
50800
50867
|
}
|
|
@@ -50817,10 +50884,10 @@ function planSessionResume(records, max) {
|
|
|
50817
50884
|
return { resume: ordered.slice(0, bound), dropped: ordered.slice(bound) };
|
|
50818
50885
|
}
|
|
50819
50886
|
function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
50820
|
-
const target =
|
|
50887
|
+
const target = path106.resolve(cwd);
|
|
50821
50888
|
const reconnectable = (s) => !!s.pluginId && !!s.pollSecret && !!s.agent;
|
|
50822
50889
|
const matches = sessions3.filter(
|
|
50823
|
-
(s) => !!s.cwd &&
|
|
50890
|
+
(s) => !!s.cwd && path106.resolve(s.cwd) === target && reconnectable(s)
|
|
50824
50891
|
);
|
|
50825
50892
|
if (matches.length > 0) {
|
|
50826
50893
|
matches.sort((a, b) => b.pairedAt - a.pairedAt);
|
|
@@ -50832,11 +50899,11 @@ function pickSavedSessionForWorkspace(sessions3, cwd, deployId) {
|
|
|
50832
50899
|
|
|
50833
50900
|
// src/commands/host/git-tooling.ts
|
|
50834
50901
|
var import_node_child_process32 = require("child_process");
|
|
50835
|
-
var
|
|
50902
|
+
var fs94 = __toESM(require("fs"));
|
|
50836
50903
|
var os67 = __toESM(require("os"));
|
|
50837
|
-
var
|
|
50904
|
+
var path107 = __toESM(require("path"));
|
|
50838
50905
|
function codeamBinDir() {
|
|
50839
|
-
return process.env.CODEAM_BIN_DIR ??
|
|
50906
|
+
return process.env.CODEAM_BIN_DIR ?? path107.join(os67.homedir(), ".codeam", "bin");
|
|
50840
50907
|
}
|
|
50841
50908
|
var FALLBACK_GH_VERSION = "2.62.0";
|
|
50842
50909
|
var RELEASE_API = "https://api.github.com/repos/cli/cli/releases/latest";
|
|
@@ -50868,7 +50935,7 @@ async function download(url2, dest) {
|
|
|
50868
50935
|
const res = await fetch(url2, { headers: { "User-Agent": "codeam-cli" } });
|
|
50869
50936
|
if (!res.ok || !res.body) return false;
|
|
50870
50937
|
const buf = Buffer.from(await res.arrayBuffer());
|
|
50871
|
-
|
|
50938
|
+
fs94.writeFileSync(dest, buf);
|
|
50872
50939
|
return true;
|
|
50873
50940
|
} catch {
|
|
50874
50941
|
return false;
|
|
@@ -50891,8 +50958,8 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
50891
50958
|
const version3 = await resolveVersionFn(token);
|
|
50892
50959
|
const asset = `gh_${version3}_${osToken}_${arch2}`;
|
|
50893
50960
|
const url2 = `https://github.com/cli/cli/releases/download/v${version3}/${asset}.${ext}`;
|
|
50894
|
-
const tmpRoot =
|
|
50895
|
-
const archive =
|
|
50961
|
+
const tmpRoot = fs94.mkdtempSync(path107.join(os67.tmpdir(), "codeam-gh-"));
|
|
50962
|
+
const archive = path107.join(tmpRoot, `${asset}.${ext}`);
|
|
50896
50963
|
if (!await downloadFn(url2, archive)) {
|
|
50897
50964
|
log.warn("host-agent", "gh download failed \u2014 skipping (git pull/push still work via the credential helper)");
|
|
50898
50965
|
return null;
|
|
@@ -50902,16 +50969,16 @@ async function ensureGhCli(runner, token, deps = {}) {
|
|
|
50902
50969
|
log.warn("host-agent", `gh archive extraction failed (code=${String(extract.code)}) \u2014 skipping`);
|
|
50903
50970
|
return null;
|
|
50904
50971
|
}
|
|
50905
|
-
const extractedBin =
|
|
50906
|
-
if (!
|
|
50972
|
+
const extractedBin = path107.join(tmpRoot, asset, "bin", binaryName);
|
|
50973
|
+
if (!fs94.existsSync(extractedBin)) {
|
|
50907
50974
|
log.warn("host-agent", "gh binary not found in the extracted archive \u2014 skipping");
|
|
50908
50975
|
return null;
|
|
50909
50976
|
}
|
|
50910
50977
|
const binDir = codeamBinDir();
|
|
50911
|
-
|
|
50912
|
-
const target =
|
|
50913
|
-
|
|
50914
|
-
|
|
50978
|
+
fs94.mkdirSync(binDir, { recursive: true });
|
|
50979
|
+
const target = path107.join(binDir, binaryName);
|
|
50980
|
+
fs94.copyFileSync(extractedBin, target);
|
|
50981
|
+
fs94.chmodSync(target, 493);
|
|
50915
50982
|
log.info("host-agent", `gh installed to ${target} (v${version3})`);
|
|
50916
50983
|
return target;
|
|
50917
50984
|
} catch (e) {
|
|
@@ -50948,19 +51015,19 @@ async function ensureGhAuth(runner, ghCmd, token) {
|
|
|
50948
51015
|
}
|
|
50949
51016
|
function ghConfigDir() {
|
|
50950
51017
|
if (process.env.GH_CONFIG_DIR) return process.env.GH_CONFIG_DIR;
|
|
50951
|
-
if (process.env.XDG_CONFIG_HOME) return
|
|
51018
|
+
if (process.env.XDG_CONFIG_HOME) return path107.join(process.env.XDG_CONFIG_HOME, "gh");
|
|
50952
51019
|
if (process.platform === "win32" && process.env.APPDATA) {
|
|
50953
|
-
return
|
|
51020
|
+
return path107.join(process.env.APPDATA, "GitHub CLI");
|
|
50954
51021
|
}
|
|
50955
|
-
return
|
|
51022
|
+
return path107.join(os67.homedir(), ".config", "gh");
|
|
50956
51023
|
}
|
|
50957
51024
|
function writeGhHostsToken(token) {
|
|
50958
51025
|
try {
|
|
50959
51026
|
const dir = ghConfigDir();
|
|
50960
|
-
const file =
|
|
50961
|
-
if (
|
|
50962
|
-
|
|
50963
|
-
|
|
51027
|
+
const file = path107.join(dir, "hosts.yml");
|
|
51028
|
+
if (fs94.existsSync(file)) return false;
|
|
51029
|
+
fs94.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
51030
|
+
fs94.writeFileSync(
|
|
50964
51031
|
file,
|
|
50965
51032
|
`github.com:
|
|
50966
51033
|
oauth_token: ${token}
|
|
@@ -51003,8 +51070,8 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
51003
51070
|
const version3 = await resolveLatestGlabVersion();
|
|
51004
51071
|
const asset = `glab_${version3}_${osToken}_${arch2}`;
|
|
51005
51072
|
const url2 = `https://gitlab.com/gitlab-org/cli/-/releases/v${version3}/downloads/${asset}.${ext}`;
|
|
51006
|
-
const tmpRoot =
|
|
51007
|
-
const archive =
|
|
51073
|
+
const tmpRoot = fs94.mkdtempSync(path107.join(os67.tmpdir(), "codeam-glab-"));
|
|
51074
|
+
const archive = path107.join(tmpRoot, `${asset}.${ext}`);
|
|
51008
51075
|
if (!await downloadFn(url2, archive)) {
|
|
51009
51076
|
log.warn("host-agent", "glab download failed \u2014 skipping (git push/pull still work)");
|
|
51010
51077
|
return null;
|
|
@@ -51015,20 +51082,20 @@ async function ensureGlabCli(runner, deps = {}) {
|
|
|
51015
51082
|
return null;
|
|
51016
51083
|
}
|
|
51017
51084
|
const candidates = [
|
|
51018
|
-
|
|
51019
|
-
|
|
51020
|
-
|
|
51085
|
+
path107.join(tmpRoot, "bin", binaryName),
|
|
51086
|
+
path107.join(tmpRoot, asset, "bin", binaryName),
|
|
51087
|
+
path107.join(tmpRoot, binaryName)
|
|
51021
51088
|
];
|
|
51022
|
-
const extractedBin = candidates.find((c2) =>
|
|
51089
|
+
const extractedBin = candidates.find((c2) => fs94.existsSync(c2));
|
|
51023
51090
|
if (!extractedBin) {
|
|
51024
51091
|
log.warn("host-agent", "glab binary not found in the extracted archive \u2014 skipping");
|
|
51025
51092
|
return null;
|
|
51026
51093
|
}
|
|
51027
51094
|
const binDir = codeamBinDir();
|
|
51028
|
-
|
|
51029
|
-
const target =
|
|
51030
|
-
|
|
51031
|
-
|
|
51095
|
+
fs94.mkdirSync(binDir, { recursive: true });
|
|
51096
|
+
const target = path107.join(binDir, binaryName);
|
|
51097
|
+
fs94.copyFileSync(extractedBin, target);
|
|
51098
|
+
fs94.chmodSync(target, 493);
|
|
51032
51099
|
log.info("host-agent", `glab installed to ${target} (v${version3})`);
|
|
51033
51100
|
return target;
|
|
51034
51101
|
} catch (e) {
|
|
@@ -51107,14 +51174,14 @@ var defaultGitToolingRunner = {
|
|
|
51107
51174
|
};
|
|
51108
51175
|
|
|
51109
51176
|
// src/lib/cli-versions.ts
|
|
51110
|
-
var
|
|
51177
|
+
var fs96 = __toESM(require("fs"));
|
|
51111
51178
|
var os69 = __toESM(require("os"));
|
|
51112
|
-
var
|
|
51179
|
+
var path109 = __toESM(require("path"));
|
|
51113
51180
|
|
|
51114
51181
|
// src/lib/updateNotifier.ts
|
|
51115
|
-
var
|
|
51182
|
+
var fs95 = __toESM(require("fs"));
|
|
51116
51183
|
var os68 = __toESM(require("os"));
|
|
51117
|
-
var
|
|
51184
|
+
var path108 = __toESM(require("path"));
|
|
51118
51185
|
var https8 = __toESM(require("https"));
|
|
51119
51186
|
var import_node_child_process33 = require("child_process");
|
|
51120
51187
|
var import_picocolors12 = __toESM(require("picocolors"));
|
|
@@ -51123,12 +51190,12 @@ var REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
|
|
|
51123
51190
|
var TTL_MS = 24 * 60 * 60 * 1e3;
|
|
51124
51191
|
var REQUEST_TIMEOUT_MS = 1500;
|
|
51125
51192
|
function cachePath() {
|
|
51126
|
-
const dir =
|
|
51127
|
-
return
|
|
51193
|
+
const dir = path108.join(os68.homedir(), ".codeam");
|
|
51194
|
+
return path108.join(dir, "update-check.json");
|
|
51128
51195
|
}
|
|
51129
51196
|
function readCache() {
|
|
51130
51197
|
try {
|
|
51131
|
-
const raw =
|
|
51198
|
+
const raw = fs95.readFileSync(cachePath(), "utf8");
|
|
51132
51199
|
const parsed = JSON.parse(raw);
|
|
51133
51200
|
if (typeof parsed.fetchedAt !== "number" || typeof parsed.latest !== "string") return null;
|
|
51134
51201
|
return parsed;
|
|
@@ -51139,10 +51206,10 @@ function readCache() {
|
|
|
51139
51206
|
function writeCache(cache) {
|
|
51140
51207
|
try {
|
|
51141
51208
|
const file = cachePath();
|
|
51142
|
-
|
|
51209
|
+
fs95.mkdirSync(path108.dirname(file), { recursive: true });
|
|
51143
51210
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
51144
|
-
|
|
51145
|
-
|
|
51211
|
+
fs95.writeFileSync(tmp, JSON.stringify(cache));
|
|
51212
|
+
fs95.renameSync(tmp, file);
|
|
51146
51213
|
} catch {
|
|
51147
51214
|
}
|
|
51148
51215
|
}
|
|
@@ -51216,8 +51283,8 @@ function isLinkedInstall() {
|
|
|
51216
51283
|
timeout: 2e3
|
|
51217
51284
|
}).trim();
|
|
51218
51285
|
if (!root) return false;
|
|
51219
|
-
const pkgPath =
|
|
51220
|
-
return
|
|
51286
|
+
const pkgPath = path108.join(root, PKG_NAME);
|
|
51287
|
+
return fs95.lstatSync(pkgPath).isSymbolicLink();
|
|
51221
51288
|
} catch {
|
|
51222
51289
|
return false;
|
|
51223
51290
|
}
|
|
@@ -51253,7 +51320,7 @@ function maybeAutoUpdate(currentVersion, latest) {
|
|
|
51253
51320
|
return;
|
|
51254
51321
|
}
|
|
51255
51322
|
try {
|
|
51256
|
-
|
|
51323
|
+
fs95.unlinkSync(cachePath());
|
|
51257
51324
|
} catch {
|
|
51258
51325
|
}
|
|
51259
51326
|
process.stderr.write(` ${import_picocolors12.default.green("\u2713")} Updated. Resuming session...
|
|
@@ -51269,7 +51336,7 @@ async function autoUpgradeBeforeCriticalCommand() {
|
|
|
51269
51336
|
if (process.env.NODE_ENV === "test") return;
|
|
51270
51337
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
51271
51338
|
if (process.env.CI) return;
|
|
51272
|
-
const current2 = true ? "2.76.
|
|
51339
|
+
const current2 = true ? "2.76.24" : null;
|
|
51273
51340
|
if (!current2) return;
|
|
51274
51341
|
const cache = readCache();
|
|
51275
51342
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -51286,7 +51353,7 @@ function checkForUpdates() {
|
|
|
51286
51353
|
if (process.env.CODEAM_DISABLE_UPDATE_CHECK === "1") return;
|
|
51287
51354
|
if (process.env.CI) return;
|
|
51288
51355
|
if (!process.stdout.isTTY) return;
|
|
51289
|
-
const current2 = true ? "2.76.
|
|
51356
|
+
const current2 = true ? "2.76.24" : null;
|
|
51290
51357
|
if (!current2) return;
|
|
51291
51358
|
const cache = readCache();
|
|
51292
51359
|
const fresh = cache && Date.now() - cache.fetchedAt < TTL_MS;
|
|
@@ -51309,10 +51376,10 @@ function versionedModeSupported(platform3 = process.platform) {
|
|
|
51309
51376
|
return platform3 !== "win32";
|
|
51310
51377
|
}
|
|
51311
51378
|
function cliVersionsRoot(env = process.env) {
|
|
51312
|
-
return env.CODEAM_CLI_VERSIONS_DIR ||
|
|
51379
|
+
return env.CODEAM_CLI_VERSIONS_DIR || path109.join(os69.homedir(), ".codeam", "cli");
|
|
51313
51380
|
}
|
|
51314
51381
|
function packageDirOf(versionDir) {
|
|
51315
|
-
return
|
|
51382
|
+
return path109.join(versionDir, "node_modules", CLI_PKG);
|
|
51316
51383
|
}
|
|
51317
51384
|
function isRecord6(v) {
|
|
51318
51385
|
return typeof v === "object" && v !== null;
|
|
@@ -51320,7 +51387,7 @@ function isRecord6(v) {
|
|
|
51320
51387
|
function readPkg2(versionDir) {
|
|
51321
51388
|
try {
|
|
51322
51389
|
const raw = JSON.parse(
|
|
51323
|
-
|
|
51390
|
+
fs96.readFileSync(path109.join(packageDirOf(versionDir), "package.json"), "utf8")
|
|
51324
51391
|
);
|
|
51325
51392
|
return isRecord6(raw) ? raw : null;
|
|
51326
51393
|
} catch {
|
|
@@ -51333,15 +51400,15 @@ function entryOf(versionDir) {
|
|
|
51333
51400
|
const bin = pkg.bin;
|
|
51334
51401
|
const named = isRecord6(bin) ? bin.codeam : void 0;
|
|
51335
51402
|
const rel = typeof bin === "string" ? bin : typeof named === "string" ? named : "dist/index.js";
|
|
51336
|
-
const entry =
|
|
51337
|
-
return
|
|
51403
|
+
const entry = path109.join(packageDirOf(versionDir), rel);
|
|
51404
|
+
return fs96.existsSync(entry) ? entry : null;
|
|
51338
51405
|
}
|
|
51339
51406
|
function launcherOf(versionDir) {
|
|
51340
51407
|
const entry = entryOf(versionDir);
|
|
51341
51408
|
if (!entry) return null;
|
|
51342
|
-
const bin =
|
|
51409
|
+
const bin = path109.join(versionDir, "node_modules", ".bin", "codeam");
|
|
51343
51410
|
try {
|
|
51344
|
-
return
|
|
51411
|
+
return fs96.realpathSync(bin) === fs96.realpathSync(entry) ? bin : entry;
|
|
51345
51412
|
} catch {
|
|
51346
51413
|
return entry;
|
|
51347
51414
|
}
|
|
@@ -51354,16 +51421,16 @@ var BAD_MARKER_TTL_MS = 24 * 60 * 6e4;
|
|
|
51354
51421
|
var PRE_READY_WINDOW_MS = 60 * 6e4;
|
|
51355
51422
|
function isBad(versionDir, now = Date.now()) {
|
|
51356
51423
|
try {
|
|
51357
|
-
return now -
|
|
51424
|
+
return now - fs96.statSync(path109.join(versionDir, ".bad")).mtimeMs < BAD_MARKER_TTL_MS;
|
|
51358
51425
|
} catch {
|
|
51359
51426
|
return false;
|
|
51360
51427
|
}
|
|
51361
51428
|
}
|
|
51362
51429
|
function recordPreReadyFailure(versionDir, now = Date.now()) {
|
|
51363
|
-
const file =
|
|
51430
|
+
const file = path109.join(versionDir, ".prefail");
|
|
51364
51431
|
let count = 0;
|
|
51365
51432
|
try {
|
|
51366
|
-
const [n, at3] =
|
|
51433
|
+
const [n, at3] = fs96.readFileSync(file, "utf8").trim().split(" ").map(Number);
|
|
51367
51434
|
if (Number.isFinite(n) && Number.isFinite(at3) && now - at3 < PRE_READY_WINDOW_MS) {
|
|
51368
51435
|
count = n;
|
|
51369
51436
|
}
|
|
@@ -51371,45 +51438,45 @@ function recordPreReadyFailure(versionDir, now = Date.now()) {
|
|
|
51371
51438
|
}
|
|
51372
51439
|
count += 1;
|
|
51373
51440
|
try {
|
|
51374
|
-
|
|
51441
|
+
fs96.writeFileSync(file, `${count} ${now}`);
|
|
51375
51442
|
} catch {
|
|
51376
51443
|
}
|
|
51377
51444
|
return count;
|
|
51378
51445
|
}
|
|
51379
51446
|
function clearPreReadyFailures(versionDir) {
|
|
51380
|
-
|
|
51447
|
+
fs96.rmSync(path109.join(versionDir, ".prefail"), { force: true });
|
|
51381
51448
|
}
|
|
51382
51449
|
function markBad(versionDir, reason) {
|
|
51383
51450
|
try {
|
|
51384
|
-
|
|
51451
|
+
fs96.writeFileSync(path109.join(versionDir, ".bad"), `${(/* @__PURE__ */ new Date()).toISOString()} ${reason}
|
|
51385
51452
|
`);
|
|
51386
51453
|
} catch {
|
|
51387
51454
|
}
|
|
51388
51455
|
}
|
|
51389
51456
|
function pointerTarget(root, name) {
|
|
51390
51457
|
try {
|
|
51391
|
-
return
|
|
51458
|
+
return fs96.realpathSync(path109.join(root, name));
|
|
51392
51459
|
} catch {
|
|
51393
51460
|
return null;
|
|
51394
51461
|
}
|
|
51395
51462
|
}
|
|
51396
51463
|
function atomicPoint(root, name, targetDir) {
|
|
51397
|
-
const realRoot =
|
|
51398
|
-
const tmp =
|
|
51399
|
-
|
|
51464
|
+
const realRoot = fs96.realpathSync(root);
|
|
51465
|
+
const tmp = path109.join(realRoot, `.${name}.tmp-${process.pid}-${Date.now()}`);
|
|
51466
|
+
fs96.symlinkSync(path109.relative(realRoot, fs96.realpathSync(targetDir)), tmp, "dir");
|
|
51400
51467
|
try {
|
|
51401
|
-
|
|
51468
|
+
fs96.renameSync(tmp, path109.join(realRoot, name));
|
|
51402
51469
|
} catch (err) {
|
|
51403
|
-
|
|
51470
|
+
fs96.rmSync(tmp, { force: true });
|
|
51404
51471
|
throw err;
|
|
51405
51472
|
}
|
|
51406
51473
|
}
|
|
51407
51474
|
function samePath(a, b) {
|
|
51408
51475
|
const canon = (p2) => {
|
|
51409
51476
|
try {
|
|
51410
|
-
return
|
|
51477
|
+
return fs96.realpathSync(p2);
|
|
51411
51478
|
} catch {
|
|
51412
|
-
return
|
|
51479
|
+
return path109.resolve(p2);
|
|
51413
51480
|
}
|
|
51414
51481
|
};
|
|
51415
51482
|
return canon(a) === canon(b);
|
|
@@ -51444,15 +51511,15 @@ function versionDirContaining(root, file) {
|
|
|
51444
51511
|
let real;
|
|
51445
51512
|
let realRoot;
|
|
51446
51513
|
try {
|
|
51447
|
-
real =
|
|
51448
|
-
realRoot =
|
|
51514
|
+
real = fs96.realpathSync(file);
|
|
51515
|
+
realRoot = fs96.realpathSync(root);
|
|
51449
51516
|
} catch {
|
|
51450
51517
|
return null;
|
|
51451
51518
|
}
|
|
51452
|
-
const rel =
|
|
51453
|
-
if (rel.startsWith("..") ||
|
|
51454
|
-
const first = rel.split(
|
|
51455
|
-
return first && SEMVER_DIR.test(first) ?
|
|
51519
|
+
const rel = path109.relative(realRoot, real);
|
|
51520
|
+
if (rel.startsWith("..") || path109.isAbsolute(rel)) return null;
|
|
51521
|
+
const first = rel.split(path109.sep)[0];
|
|
51522
|
+
return first && SEMVER_DIR.test(first) ? path109.join(realRoot, first) : null;
|
|
51456
51523
|
}
|
|
51457
51524
|
function pidAlive3(pid) {
|
|
51458
51525
|
try {
|
|
@@ -51465,7 +51532,7 @@ function pidAlive3(pid) {
|
|
|
51465
51532
|
function livePids(versionDir) {
|
|
51466
51533
|
let names;
|
|
51467
51534
|
try {
|
|
51468
|
-
names =
|
|
51535
|
+
names = fs96.readdirSync(path109.join(versionDir, ".pids"));
|
|
51469
51536
|
} catch {
|
|
51470
51537
|
return [];
|
|
51471
51538
|
}
|
|
@@ -51474,11 +51541,11 @@ function livePids(versionDir) {
|
|
|
51474
51541
|
function registerRunningVersion(root = cliVersionsRoot(), entry = process.argv[1]) {
|
|
51475
51542
|
const dir = versionDirContaining(root, entry);
|
|
51476
51543
|
if (!dir) return;
|
|
51477
|
-
const file =
|
|
51544
|
+
const file = path109.join(dir, ".pids", String(process.pid));
|
|
51478
51545
|
try {
|
|
51479
|
-
|
|
51480
|
-
|
|
51481
|
-
process.once("exit", () =>
|
|
51546
|
+
fs96.mkdirSync(path109.dirname(file), { recursive: true });
|
|
51547
|
+
fs96.writeFileSync(file, "");
|
|
51548
|
+
process.once("exit", () => fs96.rmSync(file, { force: true }));
|
|
51482
51549
|
} catch {
|
|
51483
51550
|
}
|
|
51484
51551
|
}
|
|
@@ -51486,7 +51553,7 @@ function gcVersions(root) {
|
|
|
51486
51553
|
const removed = [];
|
|
51487
51554
|
let names;
|
|
51488
51555
|
try {
|
|
51489
|
-
names =
|
|
51556
|
+
names = fs96.readdirSync(root).filter((n) => SEMVER_DIR.test(n));
|
|
51490
51557
|
} catch {
|
|
51491
51558
|
return removed;
|
|
51492
51559
|
}
|
|
@@ -51494,13 +51561,13 @@ function gcVersions(root) {
|
|
|
51494
51561
|
[...names].sort((a, b) => compareSemver(b, a)).slice(0, GC_KEEP_NEWEST)
|
|
51495
51562
|
);
|
|
51496
51563
|
for (const p2 of [pointerTarget(root, "current"), pointerTarget(root, "previous")]) {
|
|
51497
|
-
if (p2) keep.add(
|
|
51564
|
+
if (p2) keep.add(path109.basename(p2));
|
|
51498
51565
|
}
|
|
51499
51566
|
for (const name of names) {
|
|
51500
|
-
const dir =
|
|
51567
|
+
const dir = path109.join(root, name);
|
|
51501
51568
|
if (keep.has(name) || livePids(dir).length > 0) continue;
|
|
51502
51569
|
try {
|
|
51503
|
-
|
|
51570
|
+
fs96.rmSync(dir, { recursive: true, force: true });
|
|
51504
51571
|
removed.push(name);
|
|
51505
51572
|
} catch {
|
|
51506
51573
|
}
|
|
@@ -51508,25 +51575,25 @@ function gcVersions(root) {
|
|
|
51508
51575
|
return removed;
|
|
51509
51576
|
}
|
|
51510
51577
|
function acquireInstallLock(root) {
|
|
51511
|
-
const lock =
|
|
51578
|
+
const lock = path109.join(root, ".install.lock");
|
|
51512
51579
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
51513
51580
|
try {
|
|
51514
|
-
const fd =
|
|
51515
|
-
|
|
51516
|
-
|
|
51517
|
-
return () =>
|
|
51581
|
+
const fd = fs96.openSync(lock, "wx");
|
|
51582
|
+
fs96.writeSync(fd, String(process.pid));
|
|
51583
|
+
fs96.closeSync(fd);
|
|
51584
|
+
return () => fs96.rmSync(lock, { force: true });
|
|
51518
51585
|
} catch (err) {
|
|
51519
51586
|
if (err.code !== "EEXIST") return null;
|
|
51520
51587
|
let stale = false;
|
|
51521
51588
|
try {
|
|
51522
|
-
const owner = Number(
|
|
51523
|
-
const age = Date.now() -
|
|
51589
|
+
const owner = Number(fs96.readFileSync(lock, "utf8"));
|
|
51590
|
+
const age = Date.now() - fs96.statSync(lock).mtimeMs;
|
|
51524
51591
|
stale = !Number.isInteger(owner) || !pidAlive3(owner) || age > LOCK_STALE_MS;
|
|
51525
51592
|
} catch {
|
|
51526
51593
|
stale = true;
|
|
51527
51594
|
}
|
|
51528
51595
|
if (!stale) return null;
|
|
51529
|
-
|
|
51596
|
+
fs96.rmSync(lock, { force: true });
|
|
51530
51597
|
}
|
|
51531
51598
|
}
|
|
51532
51599
|
return null;
|
|
@@ -51534,9 +51601,9 @@ function acquireInstallLock(root) {
|
|
|
51534
51601
|
|
|
51535
51602
|
// src/commands/host/host-launch.ts
|
|
51536
51603
|
var import_node_child_process35 = require("child_process");
|
|
51537
|
-
var
|
|
51604
|
+
var fs98 = __toESM(require("fs"));
|
|
51538
51605
|
var os70 = __toESM(require("os"));
|
|
51539
|
-
var
|
|
51606
|
+
var path111 = __toESM(require("path"));
|
|
51540
51607
|
|
|
51541
51608
|
// src/exit-codes.ts
|
|
51542
51609
|
var EXIT_OK = 0;
|
|
@@ -51558,8 +51625,8 @@ var EXIT_CODE_NAMES = {
|
|
|
51558
51625
|
|
|
51559
51626
|
// src/commands/host/self-update.ts
|
|
51560
51627
|
var import_node_child_process34 = require("child_process");
|
|
51561
|
-
var
|
|
51562
|
-
var
|
|
51628
|
+
var fs97 = __toESM(require("fs"));
|
|
51629
|
+
var path110 = __toESM(require("path"));
|
|
51563
51630
|
var SELF_UPDATE_PKG = "codeam-cli";
|
|
51564
51631
|
var SELF_UPDATE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
51565
51632
|
var SELF_UPDATE_STARTUP_DELAY_MS = 5e3;
|
|
@@ -51569,7 +51636,7 @@ var SELF_UPDATE_VIEW_TIMEOUT_MS = 3e4;
|
|
|
51569
51636
|
var SELF_UPDATE_INSTALL_TIMEOUT_MS = 18e4;
|
|
51570
51637
|
var SELF_UPDATE_LS_TIMEOUT_MS = 15e3;
|
|
51571
51638
|
function currentCliVersion() {
|
|
51572
|
-
return true ? "2.76.
|
|
51639
|
+
return true ? "2.76.24" : null;
|
|
51573
51640
|
}
|
|
51574
51641
|
async function installedVersion(deps) {
|
|
51575
51642
|
const ls = await deps.run(
|
|
@@ -51673,9 +51740,9 @@ async function runSelfUpdateWith(deps) {
|
|
|
51673
51740
|
var VERIFY_TIMEOUT_MS = 3e4;
|
|
51674
51741
|
async function installVersioned(deps, root, latest, running2) {
|
|
51675
51742
|
const node = deps.nodePath ?? process.execPath;
|
|
51676
|
-
const target =
|
|
51743
|
+
const target = path110.join(root, latest);
|
|
51677
51744
|
try {
|
|
51678
|
-
|
|
51745
|
+
fs97.mkdirSync(root, { recursive: true });
|
|
51679
51746
|
} catch {
|
|
51680
51747
|
return { status: "skipped" };
|
|
51681
51748
|
}
|
|
@@ -51699,7 +51766,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
51699
51766
|
}
|
|
51700
51767
|
const reusable = entryOf(target) && versionOf(target) === latest;
|
|
51701
51768
|
if (!reusable) {
|
|
51702
|
-
|
|
51769
|
+
fs97.rmSync(target, { recursive: true, force: true });
|
|
51703
51770
|
const install = await deps.run(
|
|
51704
51771
|
"npm",
|
|
51705
51772
|
[
|
|
@@ -51714,7 +51781,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
51714
51781
|
SELF_UPDATE_INSTALL_TIMEOUT_MS
|
|
51715
51782
|
);
|
|
51716
51783
|
if (install.code !== 0) {
|
|
51717
|
-
|
|
51784
|
+
fs97.rmSync(target, { recursive: true, force: true });
|
|
51718
51785
|
log.warn(
|
|
51719
51786
|
"host-agent",
|
|
51720
51787
|
`self-update: versioned install exited ${String(install.code)} \u2014 staying on ${running2}: ` + install.stderr.slice(-300)
|
|
@@ -51725,7 +51792,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
51725
51792
|
const entry = entryOf(target);
|
|
51726
51793
|
const check = entry ? await deps.run(node, [entry, "--version"], VERIFY_TIMEOUT_MS) : { code: null, stdout: "", stderr: "no entry point" };
|
|
51727
51794
|
if (check.code !== 0 || !check.stdout.includes(latest)) {
|
|
51728
|
-
|
|
51795
|
+
fs97.rmSync(target, { recursive: true, force: true });
|
|
51729
51796
|
log.warn(
|
|
51730
51797
|
"host-agent",
|
|
51731
51798
|
`self-update: ${latest} failed verification (exit ${String(check.code)}: ${(check.stdout + check.stderr).trim().slice(-200)}) \u2014 staying on ${running2}`
|
|
@@ -51741,7 +51808,7 @@ async function installVersioned(deps, root, latest, running2) {
|
|
|
51741
51808
|
return { status: "updated", version: latest };
|
|
51742
51809
|
} catch (err) {
|
|
51743
51810
|
const cur = pointerTarget(root, "current");
|
|
51744
|
-
if (!cur ||
|
|
51811
|
+
if (!cur || path110.basename(cur) !== latest) fs97.rmSync(target, { recursive: true, force: true });
|
|
51745
51812
|
log.warn(
|
|
51746
51813
|
"host-agent",
|
|
51747
51814
|
`self-update: versioned install failed: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -51780,7 +51847,7 @@ function signalHostReady(send = process.send?.bind(process)) {
|
|
|
51780
51847
|
}
|
|
51781
51848
|
function defaultDeps() {
|
|
51782
51849
|
return {
|
|
51783
|
-
ownVersion: true ? "2.76.
|
|
51850
|
+
ownVersion: true ? "2.76.24" : null,
|
|
51784
51851
|
root: cliVersionsRoot(),
|
|
51785
51852
|
args: process.argv.slice(3),
|
|
51786
51853
|
execPath: process.execPath,
|
|
@@ -51877,13 +51944,13 @@ function needsSelfRelaunch(env = process.env, pid = process.pid, ctx = {}) {
|
|
|
51877
51944
|
}
|
|
51878
51945
|
function readPid1Cmdline() {
|
|
51879
51946
|
try {
|
|
51880
|
-
return
|
|
51947
|
+
return fs98.readFileSync("/proc/1/cmdline", "utf8").split("\0").filter(Boolean);
|
|
51881
51948
|
} catch {
|
|
51882
51949
|
return [];
|
|
51883
51950
|
}
|
|
51884
51951
|
}
|
|
51885
51952
|
function isOurTiniEntrypoint(argv) {
|
|
51886
|
-
return argv.some((a) =>
|
|
51953
|
+
return argv.some((a) => path111.basename(a) === "tini") && argv.includes("host-agent");
|
|
51887
51954
|
}
|
|
51888
51955
|
function relaunchArgv(execPath, argv) {
|
|
51889
51956
|
return ["-c", 'sleep 2; exec "$0" "$@"', execPath, ...argv.slice(1)];
|
|
@@ -51925,7 +51992,7 @@ function defaultRestartForUpdate(version3, supervised, io = {}) {
|
|
|
51925
51992
|
}
|
|
51926
51993
|
exit(0);
|
|
51927
51994
|
}
|
|
51928
|
-
function isContainerEnvironment(existsSyncFn =
|
|
51995
|
+
function isContainerEnvironment(existsSyncFn = fs98.existsSync, readFileSyncFn = (p2) => fs98.readFileSync(p2, "utf8")) {
|
|
51929
51996
|
try {
|
|
51930
51997
|
if (existsSyncFn("/.dockerenv")) return true;
|
|
51931
51998
|
} catch {
|
|
@@ -51938,15 +52005,15 @@ function isContainerEnvironment(existsSyncFn = fs97.existsSync, readFileSyncFn =
|
|
|
51938
52005
|
return false;
|
|
51939
52006
|
}
|
|
51940
52007
|
function hostAgentPidFile(home = os70.homedir()) {
|
|
51941
|
-
return
|
|
52008
|
+
return path111.join(home, ".codeam", "host-agent.pid");
|
|
51942
52009
|
}
|
|
51943
52010
|
function writeHostAgentPidFile(file = hostAgentPidFile(), pid = process.pid) {
|
|
51944
52011
|
try {
|
|
51945
|
-
|
|
51946
|
-
|
|
52012
|
+
fs98.mkdirSync(path111.dirname(file), { recursive: true });
|
|
52013
|
+
fs98.writeFileSync(file, String(pid));
|
|
51947
52014
|
process.once("exit", () => {
|
|
51948
52015
|
try {
|
|
51949
|
-
if (
|
|
52016
|
+
if (fs98.readFileSync(file, "utf8").trim() === String(pid)) fs98.rmSync(file, { force: true });
|
|
51950
52017
|
} catch {
|
|
51951
52018
|
}
|
|
51952
52019
|
});
|
|
@@ -52794,13 +52861,13 @@ var HostAgentSupervisor = class {
|
|
|
52794
52861
|
const relay = this.relay;
|
|
52795
52862
|
if (!relay) return;
|
|
52796
52863
|
const raw = cmd.payload?.path;
|
|
52797
|
-
const target = typeof raw === "string" && raw.trim() ?
|
|
52864
|
+
const target = typeof raw === "string" && raw.trim() ? path112.resolve(raw.trim()) : os71.homedir();
|
|
52798
52865
|
try {
|
|
52799
|
-
const dirents = await
|
|
52866
|
+
const dirents = await fs99.promises.readdir(target, { withFileTypes: true });
|
|
52800
52867
|
const entries2 = dirents.filter((d3) => !d3.name.startsWith(".")).map((d3) => ({ name: d3.name, isDir: d3.isDirectory() })).sort(
|
|
52801
52868
|
(a, b) => a.isDir === b.isDir ? a.name.localeCompare(b.name) : a.isDir ? -1 : 1
|
|
52802
52869
|
);
|
|
52803
|
-
const parent =
|
|
52870
|
+
const parent = path112.dirname(target);
|
|
52804
52871
|
await relay.sendResult(cmd.id, "completed", {
|
|
52805
52872
|
path: target,
|
|
52806
52873
|
// null at the filesystem root so the UI can hide the ".." affordance.
|
|
@@ -53278,14 +53345,14 @@ var HostAgentSupervisor = class {
|
|
|
53278
53345
|
}),
|
|
53279
53346
|
CODEAM_AUTO_TOKEN: payload.autoPairToken
|
|
53280
53347
|
};
|
|
53281
|
-
const houseConfigDir =
|
|
53348
|
+
const houseConfigDir = path112.join(
|
|
53282
53349
|
os71.homedir(),
|
|
53283
53350
|
".codeam",
|
|
53284
53351
|
"house-claude",
|
|
53285
53352
|
payload.deployId
|
|
53286
53353
|
);
|
|
53287
53354
|
try {
|
|
53288
|
-
|
|
53355
|
+
fs99.mkdirSync(houseConfigDir, { recursive: true, mode: 448 });
|
|
53289
53356
|
} catch {
|
|
53290
53357
|
}
|
|
53291
53358
|
childEnv.CLAUDE_CONFIG_DIR = houseConfigDir;
|
|
@@ -53322,13 +53389,13 @@ var HostAgentSupervisor = class {
|
|
|
53322
53389
|
if ((payload.repoProvider ?? "github") === "gitlab") {
|
|
53323
53390
|
const glabCmd = await ensureGlabCli(defaultGitToolingRunner);
|
|
53324
53391
|
if (glabCmd) {
|
|
53325
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
53392
|
+
childEnv.PATH = `${codeamBinDir()}${path112.delimiter}${childEnv.PATH}`;
|
|
53326
53393
|
await ensureGlabAuth(defaultGitToolingRunner, glabCmd, payload.cloneToken);
|
|
53327
53394
|
}
|
|
53328
53395
|
} else {
|
|
53329
53396
|
const ghCmd = await ensureGhCli(defaultGitToolingRunner, payload.cloneToken);
|
|
53330
53397
|
if (ghCmd) {
|
|
53331
|
-
childEnv.PATH = `${codeamBinDir()}${
|
|
53398
|
+
childEnv.PATH = `${codeamBinDir()}${path112.delimiter}${childEnv.PATH}`;
|
|
53332
53399
|
await ensureGhAuth(defaultGitToolingRunner, ghCmd, payload.cloneToken);
|
|
53333
53400
|
}
|
|
53334
53401
|
}
|
|
@@ -53356,9 +53423,9 @@ var HostAgentSupervisor = class {
|
|
|
53356
53423
|
);
|
|
53357
53424
|
if (!payload.suppressOnboardingWelcome) {
|
|
53358
53425
|
try {
|
|
53359
|
-
const cfgDir = childEnv.CLAUDE_CONFIG_DIR ||
|
|
53360
|
-
const projectDir =
|
|
53361
|
-
const hasPriorConversation =
|
|
53426
|
+
const cfgDir = childEnv.CLAUDE_CONFIG_DIR || path112.join(os71.homedir(), ".claude");
|
|
53427
|
+
const projectDir = path112.join(cfgDir, "projects", encodeCwd(cwd));
|
|
53428
|
+
const hasPriorConversation = fs99.existsSync(projectDir) && fs99.readdirSync(projectDir).some((f) => f.endsWith(".jsonl"));
|
|
53362
53429
|
if (hasPriorConversation) {
|
|
53363
53430
|
childEnv.CODEAM_RESUME_LATEST = "1";
|
|
53364
53431
|
log.info(
|
|
@@ -53512,7 +53579,7 @@ var HostAgentSupervisor = class {
|
|
|
53512
53579
|
fallbackResumeTarget() {
|
|
53513
53580
|
const session = getActiveSession();
|
|
53514
53581
|
if (!session || !session.pluginId || !session.pollSecret || !session.agent) return null;
|
|
53515
|
-
const cwd = session.cwd &&
|
|
53582
|
+
const cwd = session.cwd && fs99.existsSync(session.cwd) ? session.cwd : process.cwd();
|
|
53516
53583
|
if (isFilesystemRoot(cwd)) {
|
|
53517
53584
|
log.warn(
|
|
53518
53585
|
"host-agent",
|
|
@@ -53559,7 +53626,7 @@ var HostAgentSupervisor = class {
|
|
|
53559
53626
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: no saved pairing on this box`);
|
|
53560
53627
|
return;
|
|
53561
53628
|
}
|
|
53562
|
-
if (!session.cwd || !
|
|
53629
|
+
if (!session.cwd || !fs99.existsSync(session.cwd)) {
|
|
53563
53630
|
log.warn("host-agent", `self_hosted_resume ${sessionId.slice(0, 8)}: workspace is gone`);
|
|
53564
53631
|
return;
|
|
53565
53632
|
}
|
|
@@ -53601,7 +53668,7 @@ var HostAgentSupervisor = class {
|
|
|
53601
53668
|
const persisted = new Map((this.sessionStore.load() ?? []).map((r) => [r.deployId, r.agent]));
|
|
53602
53669
|
for (const c2 of this.children.values()) persisted.set(c2.deployId, c2.agent);
|
|
53603
53670
|
return this.listSavedSessions().map((s) => ({ s, deployId: deployIdFromWorkspace(s.cwd) })).filter(
|
|
53604
|
-
(x) => x.deployId !== null && !!x.s.cwd &&
|
|
53671
|
+
(x) => x.deployId !== null && !!x.s.cwd && fs99.existsSync(x.s.cwd)
|
|
53605
53672
|
).map(({ s, deployId }) => {
|
|
53606
53673
|
const agent = persisted.get(deployId);
|
|
53607
53674
|
return { deployId, sessionId: s.id, ...agent ? { agent } : {} };
|
|
@@ -53686,7 +53753,7 @@ var HostAgentSupervisor = class {
|
|
|
53686
53753
|
if (this.children.has(deployId)) return;
|
|
53687
53754
|
const st3 = this.resumeStateFor(target);
|
|
53688
53755
|
try {
|
|
53689
|
-
const cwd =
|
|
53756
|
+
const cwd = fs99.existsSync(target.cwd) ? target.cwd : process.cwd();
|
|
53690
53757
|
if (isWrapperCheckout(cwd)) {
|
|
53691
53758
|
log.warn(
|
|
53692
53759
|
"host-agent",
|
|
@@ -53921,12 +53988,12 @@ var HostAgentSupervisor = class {
|
|
|
53921
53988
|
this.untrackChild(deployId);
|
|
53922
53989
|
}
|
|
53923
53990
|
const dirs = [
|
|
53924
|
-
|
|
53925
|
-
|
|
53991
|
+
path112.join(selfHostedWorkspaceRoot(), deployId),
|
|
53992
|
+
path112.join(os71.homedir(), ".codeam", "house-claude", deployId)
|
|
53926
53993
|
];
|
|
53927
53994
|
for (const dir of dirs) {
|
|
53928
53995
|
try {
|
|
53929
|
-
|
|
53996
|
+
fs99.rmSync(dir, { recursive: true, force: true });
|
|
53930
53997
|
} catch (err) {
|
|
53931
53998
|
log.warn(
|
|
53932
53999
|
"host-agent",
|
|
@@ -54138,8 +54205,8 @@ async function invite() {
|
|
|
54138
54205
|
var import_node_dns = require("dns");
|
|
54139
54206
|
var import_node_util11 = require("util");
|
|
54140
54207
|
var import_node_crypto17 = require("crypto");
|
|
54141
|
-
var
|
|
54142
|
-
var
|
|
54208
|
+
var fs100 = __toESM(require("fs"));
|
|
54209
|
+
var path113 = __toESM(require("path"));
|
|
54143
54210
|
var import_picocolors14 = __toESM(require("picocolors"));
|
|
54144
54211
|
var dnsResolveP = (0, import_node_util11.promisify)(import_node_dns.resolve);
|
|
54145
54212
|
async function checkDns(apiBase2) {
|
|
@@ -54195,13 +54262,13 @@ async function checkHealth(apiBase2) {
|
|
|
54195
54262
|
}
|
|
54196
54263
|
}
|
|
54197
54264
|
function checkConfigDir() {
|
|
54198
|
-
const dir =
|
|
54265
|
+
const dir = path113.join(require("os").homedir(), ".codeam");
|
|
54199
54266
|
try {
|
|
54200
|
-
|
|
54201
|
-
const probe =
|
|
54202
|
-
|
|
54203
|
-
const read =
|
|
54204
|
-
|
|
54267
|
+
fs100.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
54268
|
+
const probe = path113.join(dir, ".doctor-probe");
|
|
54269
|
+
fs100.writeFileSync(probe, "ok", { mode: 384 });
|
|
54270
|
+
const read = fs100.readFileSync(probe, "utf8");
|
|
54271
|
+
fs100.unlinkSync(probe);
|
|
54205
54272
|
if (read !== "ok") throw new Error("write/read round-trip mismatch");
|
|
54206
54273
|
return {
|
|
54207
54274
|
id: "config-dir",
|
|
@@ -54265,7 +54332,7 @@ function checkNodePty() {
|
|
|
54265
54332
|
detail: "not required on this platform"
|
|
54266
54333
|
};
|
|
54267
54334
|
}
|
|
54268
|
-
const vendoredPath =
|
|
54335
|
+
const vendoredPath = path113.join(__dirname, "vendor", "node-pty");
|
|
54269
54336
|
for (const target of [vendoredPath, "node-pty"]) {
|
|
54270
54337
|
try {
|
|
54271
54338
|
require(target);
|
|
@@ -54307,7 +54374,7 @@ function checkChokidar() {
|
|
|
54307
54374
|
}
|
|
54308
54375
|
async function doctor(args2 = []) {
|
|
54309
54376
|
const json = args2.includes("--json");
|
|
54310
|
-
const cliVersion = true ? "2.76.
|
|
54377
|
+
const cliVersion = true ? "2.76.24" : "0.0.0-dev";
|
|
54311
54378
|
const apiBase2 = resolveApiBaseUrl();
|
|
54312
54379
|
const diagnosticId = (0, import_node_crypto17.randomUUID)();
|
|
54313
54380
|
log.info("doctor", `run id=${diagnosticId} cli=${cliVersion}`);
|
|
@@ -54514,9 +54581,9 @@ var LAUNCHER_ENV = Object.freeze({
|
|
|
54514
54581
|
});
|
|
54515
54582
|
|
|
54516
54583
|
// src/integrations/mcp-run.ts
|
|
54517
|
-
var
|
|
54584
|
+
var import_node_fs23 = require("fs");
|
|
54518
54585
|
var import_node_os18 = __toESM(require("os"));
|
|
54519
|
-
var
|
|
54586
|
+
var import_node_path25 = __toESM(require("path"));
|
|
54520
54587
|
|
|
54521
54588
|
// src/integrations/token-client.ts
|
|
54522
54589
|
var import_zod4 = require("zod");
|
|
@@ -54608,13 +54675,13 @@ function commandExists(command2) {
|
|
|
54608
54675
|
}
|
|
54609
54676
|
function localBinCandidates(command2) {
|
|
54610
54677
|
return [
|
|
54611
|
-
|
|
54612
|
-
|
|
54678
|
+
import_node_path25.default.join(import_node_os18.default.homedir(), ".local", "bin", command2),
|
|
54679
|
+
import_node_path25.default.join(import_node_os18.default.homedir(), ".cargo", "bin", command2)
|
|
54613
54680
|
];
|
|
54614
54681
|
}
|
|
54615
54682
|
function resolveLauncherPath(command2, deps = {
|
|
54616
54683
|
commandExists,
|
|
54617
|
-
existsSync:
|
|
54684
|
+
existsSync: import_node_fs23.existsSync
|
|
54618
54685
|
}) {
|
|
54619
54686
|
if (deps.commandExists(command2)) return command2;
|
|
54620
54687
|
for (const candidate of localBinCandidates(command2)) {
|
|
@@ -54843,7 +54910,7 @@ async function mcpWarm(argv = [], opts = {}) {
|
|
|
54843
54910
|
// src/commands/version.ts
|
|
54844
54911
|
var import_picocolors15 = __toESM(require("picocolors"));
|
|
54845
54912
|
function version2() {
|
|
54846
|
-
const v = true ? "2.76.
|
|
54913
|
+
const v = true ? "2.76.24" : "unknown";
|
|
54847
54914
|
console.log(`${import_picocolors15.default.bold("codeam-cli")} ${import_picocolors15.default.cyan(v)}`);
|
|
54848
54915
|
}
|
|
54849
54916
|
|