context-mode 2.1.9 → 2.2.0
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/.claude-plugin/marketplace.json +3 -3
- package/.claude-plugin/plugin.json +2 -2
- package/.codex-plugin/plugin.json +2 -2
- package/.zcode-plugin/plugin.json +2 -2
- package/README.md +95 -76
- package/SHA256SUMS +21 -20
- package/cli.mjs +598 -247
- package/copilot/plugin.json +2 -2
- package/fixtures/hook-roundtrip.json +13 -0
- package/gemini-extension.json +2 -2
- package/hook.mjs +95 -95
- package/omp/index.js +5 -0
- package/opencode/plugin.js +654 -394
- package/package.json +9 -2
- package/pi/index.js +707 -421
- package/qwen-extension.json +2 -2
- package/run.mjs +77 -32
- package/search.mjs +77 -32
- package/server.mjs +650 -398
- package/skills/ctx-doctor/SKILL.md +1 -1
- package/skills/ctx-stats/SKILL.md +1 -1
- package/skills/ctx-upgrade/SKILL.md +1 -1
package/server.mjs
CHANGED
|
@@ -7,8 +7,8 @@ var __export = (target, all) => {
|
|
|
7
7
|
|
|
8
8
|
// src/entries/server.ts
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
|
-
import { existsSync as
|
|
11
|
-
import { dirname as
|
|
10
|
+
import { existsSync as existsSync24, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
|
|
11
|
+
import { dirname as dirname14, join as join25 } from "node:path";
|
|
12
12
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
13
13
|
|
|
14
14
|
// node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
|
|
@@ -17979,8 +17979,8 @@ function liftWireOnlyMaterial(message2, kind) {
|
|
|
17979
17979
|
};
|
|
17980
17980
|
}
|
|
17981
17981
|
function codecResultValidator(codec, method) {
|
|
17982
|
-
const
|
|
17983
|
-
if (!
|
|
17982
|
+
const probe2 = codec.validateResult(method, void 0);
|
|
17983
|
+
if (!probe2.ok && probe2.reason === "not-in-era") return void 0;
|
|
17984
17984
|
return { "~standard": {
|
|
17985
17985
|
version: 1,
|
|
17986
17986
|
vendor: "mcp-wire-codec",
|
|
@@ -28052,7 +28052,7 @@ function toError(value) {
|
|
|
28052
28052
|
}
|
|
28053
28053
|
|
|
28054
28054
|
// src/core/contracts/agents.ts
|
|
28055
|
-
var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode"];
|
|
28055
|
+
var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode", "omp"];
|
|
28056
28056
|
|
|
28057
28057
|
// src/core/contracts/constants.ts
|
|
28058
28058
|
var SERVER_KEY = "context-mode";
|
|
@@ -28355,6 +28355,7 @@ var READ_MEDIA_BY_AGENT = Object.freeze({
|
|
|
28355
28355
|
qwen: READ_IMAGES_AND_PDF,
|
|
28356
28356
|
opencode: READ_IMAGES_AND_PDF,
|
|
28357
28357
|
pi: READ_IMAGES,
|
|
28358
|
+
omp: READ_IMAGES,
|
|
28358
28359
|
vscode: READ_IMAGES,
|
|
28359
28360
|
zcode: READ_IMAGES,
|
|
28360
28361
|
"copilot-cli": [],
|
|
@@ -28446,7 +28447,7 @@ function PURGE_SUMMARY(rows, scope) {
|
|
|
28446
28447
|
var DECISION_SOURCE = "decision";
|
|
28447
28448
|
var DECISION_USER_LABEL = "decision (user)";
|
|
28448
28449
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
28449
|
-
var BUNDLE_SHA = true ? "
|
|
28450
|
+
var BUNDLE_SHA = true ? "9cb2aaa5ebb63491960b3f3e9655a5821383eae4" : void 0;
|
|
28450
28451
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
28451
28452
|
var DOCTOR_LABEL = Object.freeze({
|
|
28452
28453
|
D1: "version",
|
|
@@ -28602,7 +28603,9 @@ var AGENT_HOME_DIR = Object.freeze({
|
|
|
28602
28603
|
kiro: [".kiro"],
|
|
28603
28604
|
zcode: [".zcode"],
|
|
28604
28605
|
pi: [".pi"],
|
|
28605
|
-
opencode: [".config", "opencode"]
|
|
28606
|
+
opencode: [".config", "opencode"],
|
|
28607
|
+
omp: [".omp"]
|
|
28608
|
+
// ADR-0026: OMP data and plugins live under ~/.omp
|
|
28606
28609
|
});
|
|
28607
28610
|
var UPGRADE_RESTART_LINE = "restart needed";
|
|
28608
28611
|
var UPGRADE_HOST_AREA = "host update";
|
|
@@ -28690,16 +28693,6 @@ var UNSUPPORTED_HOSTS = Object.freeze([
|
|
|
28690
28693
|
binaries: [],
|
|
28691
28694
|
source: "v1.0.169:src/adapters/client-map.ts:18; detect.ts:163-165,584"
|
|
28692
28695
|
}),
|
|
28693
|
-
unsupported({
|
|
28694
|
-
id: "omp",
|
|
28695
|
-
name: "OMP (oh-my-pi)",
|
|
28696
|
-
clientNames: ["omp-coding-agent"],
|
|
28697
|
-
envVars: [],
|
|
28698
|
-
pluginPaths: [],
|
|
28699
|
-
configDirs: [".omp"],
|
|
28700
|
-
binaries: ["omp"],
|
|
28701
|
-
source: "v1.0.169:src/adapters/client-map.ts:37; detect.ts:543 (PI_CODING_AGENT_DIR is not a signal: supported Pi reads it too)"
|
|
28702
|
-
}),
|
|
28703
28696
|
unsupported({
|
|
28704
28697
|
id: "openclaw",
|
|
28705
28698
|
name: "OpenClaw",
|
|
@@ -28766,7 +28759,9 @@ var HOOK_HOST_FILE = Object.freeze({
|
|
|
28766
28759
|
kiro: { root: "home", file: [".kiro", "hooks", "context-mode.json"], key: ["hooks"], shape: "kiro", timeoutKey: "timeout", matcher: false },
|
|
28767
28760
|
zcode: { root: "home", file: [".zcode", "cli", "config.json"], key: ["hooks", "events"], shape: "zcode", timeoutKey: "timeoutMs", matcher: true },
|
|
28768
28761
|
pi: null,
|
|
28769
|
-
opencode: null
|
|
28762
|
+
opencode: null,
|
|
28763
|
+
omp: null
|
|
28764
|
+
// ADR-0026: in-process, no hook file
|
|
28770
28765
|
});
|
|
28771
28766
|
var TOOL_HOOK_EVENTS = Object.freeze(["PreToolUse", "PostToolUse"]);
|
|
28772
28767
|
var HOOK_MATCHER_FIELD = "matcher";
|
|
@@ -28791,9 +28786,14 @@ var D5_READ_RANGE_DETAIL = "PostToolUse Read with offset/limit over the replace
|
|
|
28791
28786
|
var D5_READ_OWN_DETAIL = "PreToolUse Read of a skill file over the one-read limit under the agent's own config dir came back denied: skill and rule files must reach the model whole (#1326)";
|
|
28792
28787
|
var D5_READ_MEDIA_DETAIL = "PreToolUse Read of a PNG over the one-read limit came back denied: an image Read must reach the model as an image block (#1321)";
|
|
28793
28788
|
var D5_READ_SHAPE_DETAIL = `PostToolUse Read replace is not Read's output shape {type:"text", file:{filePath, content, numLines, startLine, totalLines}}: Claude Code drops it and shows a hook warning`;
|
|
28794
|
-
|
|
28795
|
-
|
|
28789
|
+
var D5_BARE_SHARE = 0.5;
|
|
28790
|
+
function D5_SLOW_DETAIL(ms, bound = HOOK_P95_MS) {
|
|
28791
|
+
return `hook round trip took ${ms} ms over bare node, over ${bound} ms`;
|
|
28792
|
+
}
|
|
28793
|
+
function D5_SLOW_START_DETAIL(ms, bare2, bound) {
|
|
28794
|
+
return `hook adds ${ms} ms to a ${bare2} ms node start, inside ${bound} ms (half a start): node starts slowly on this machine`;
|
|
28796
28795
|
}
|
|
28796
|
+
var D5_IN_PROCESS_DETAIL = "native shape ok; hooks run inside the host process, so a tool call pays no node start";
|
|
28797
28797
|
var D5_STOP_DETAIL = "Codex Stop event: the hook did not give an empty or Codex Stop reply, or it logged a hook error";
|
|
28798
28798
|
var D5_FIX = "run ctx_upgrade";
|
|
28799
28799
|
var PRAGMA_INTEGRITY_CHECK = "PRAGMA integrity_check";
|
|
@@ -28812,6 +28812,12 @@ var D11_POSIX_FIX = "install sh or add it to PATH";
|
|
|
28812
28812
|
function D11_PASS_DETAIL(shell, win) {
|
|
28813
28813
|
return `${win ? "Git Bash" : "sh"}: ${shell}`;
|
|
28814
28814
|
}
|
|
28815
|
+
function D11_RUNTIME_DETAIL(lang, unreadable) {
|
|
28816
|
+
return `${lang} not found, unreadable on PATH: ${unreadable.join(", ")}`;
|
|
28817
|
+
}
|
|
28818
|
+
function D11_RUNTIME_FIX(lang) {
|
|
28819
|
+
return `install ${lang}, or turn off its app alias and PATH entry that cannot be read`;
|
|
28820
|
+
}
|
|
28815
28821
|
var DB_SIBLING_SUFFIXES = Object.freeze(["", DB_WAL_SUFFIX, DB_SHM_SUFFIX]);
|
|
28816
28822
|
var HEAL_TMP_SUFFIX = ".heal";
|
|
28817
28823
|
var HEAL_TS_SEP = ".";
|
|
@@ -28823,6 +28829,8 @@ var UPGRADE_HOST_COMMAND = Object.freeze({
|
|
|
28823
28829
|
gemini: "gemini extensions update context-mode",
|
|
28824
28830
|
qwen: "qwen extensions update context-mode",
|
|
28825
28831
|
pi: "pi update --extensions",
|
|
28832
|
+
omp: "omp plugin upgrade context-mode",
|
|
28833
|
+
// ADR-0026 decision 4: OMP native update
|
|
28826
28834
|
opencode: "opencode plugin update",
|
|
28827
28835
|
"copilot-cli": "npm i -g context-mode && context-mode setup --agents copilot-cli",
|
|
28828
28836
|
vscode: "npm i -g context-mode && context-mode setup --agents vscode",
|
|
@@ -28866,6 +28874,14 @@ var PI_NPM_DIR = "npm";
|
|
|
28866
28874
|
var PI_NODE_MODULES_DIR = "node_modules";
|
|
28867
28875
|
var PI_PACKAGE_JSON_FILE = "package.json";
|
|
28868
28876
|
var PI_LIST_COMMAND = "pi list";
|
|
28877
|
+
var OMP_LIST_COMMAND = "omp plugin list";
|
|
28878
|
+
var OMP_ENABLE_COMMAND = "omp plugin enable context-mode";
|
|
28879
|
+
var OMP_MIN_VERSION = "14.7.0";
|
|
28880
|
+
var OMP_FLOOR_INFO = (v) => `OMP ${v} is older than the tested floor ${OMP_MIN_VERSION}. Update it with: omp update`;
|
|
28881
|
+
var OMP_CONTENT_INFO = "OMP keeps tool output in content; context-mode writes its notes there.";
|
|
28882
|
+
var OMP_PRINT_MODE_INFO = "Print mode sends no prompt event. Use omp or omp --mode rpc to keep prompts.";
|
|
28883
|
+
var OMP_SCRIPTS_INFO = "Add < /dev/null in scripts.";
|
|
28884
|
+
var OMP_IMPORT_INFO = (claude, mcp) => `OMP also imports context-mode from ${claude}. To run it once, add "context-mode" to disabledServers in ${mcp}.`;
|
|
28869
28885
|
var PI_CURRENT_MAJOR = 2;
|
|
28870
28886
|
var V1_OPENCODE_PLUGIN_SPEC = "context-mode";
|
|
28871
28887
|
var V1_TMP_PREFIX = "context-mode-";
|
|
@@ -29076,6 +29092,8 @@ var NATIVE_INSTALL = Object.freeze({
|
|
|
29076
29092
|
qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode"],
|
|
29077
29093
|
opencode: ["opencode plugin add context-mode"],
|
|
29078
29094
|
pi: ["pi install npm:context-mode"],
|
|
29095
|
+
omp: ["omp plugin install context-mode"],
|
|
29096
|
+
// ADR-0026 decision 4: OMP native install
|
|
29079
29097
|
"copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
|
|
29080
29098
|
vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
|
|
29081
29099
|
kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
|
|
@@ -29854,6 +29872,7 @@ function sourceOf(agent) {
|
|
|
29854
29872
|
case "opencode":
|
|
29855
29873
|
return "spawn-cwd";
|
|
29856
29874
|
case "pi":
|
|
29875
|
+
case "omp":
|
|
29857
29876
|
return "pi:ctx.cwd";
|
|
29858
29877
|
}
|
|
29859
29878
|
}
|
|
@@ -44097,7 +44116,7 @@ function cutPoint(src, start, end, scratch) {
|
|
|
44097
44116
|
const r = encoder.encodeInto(src.slice(start, limit), scratch);
|
|
44098
44117
|
return { end: start + r.read, written: r.written };
|
|
44099
44118
|
}
|
|
44100
|
-
function merge4(src, blocks,
|
|
44119
|
+
function merge4(src, blocks, join26, cap, lineCut) {
|
|
44101
44120
|
const out = [];
|
|
44102
44121
|
const scratch = new Uint8Array(cap);
|
|
44103
44122
|
let wide;
|
|
@@ -44107,7 +44126,7 @@ function merge4(src, blocks, join24, cap, lineCut) {
|
|
|
44107
44126
|
out.push({ ord: out.length, text: src.slice(start, end), bytes: bytes5 });
|
|
44108
44127
|
};
|
|
44109
44128
|
for (const b of blocks) {
|
|
44110
|
-
if (cur !== void 0 && !
|
|
44129
|
+
if (cur !== void 0 && !join26) {
|
|
44111
44130
|
emit(cur.start, cur.end, curBytes);
|
|
44112
44131
|
cur = void 0;
|
|
44113
44132
|
}
|
|
@@ -44243,22 +44262,34 @@ function fileNames(name, pathExt) {
|
|
|
44243
44262
|
if (!isWin() || path.extname(name) !== "") return [name];
|
|
44244
44263
|
return [...pathExt.map((ext) => name + ext), name];
|
|
44245
44264
|
}
|
|
44246
|
-
function
|
|
44247
|
-
|
|
44248
|
-
|
|
44265
|
+
function probe(full) {
|
|
44266
|
+
let st;
|
|
44267
|
+
try {
|
|
44268
|
+
st = statSync2(full, { throwIfNoEntry: false });
|
|
44269
|
+
} catch {
|
|
44270
|
+
return "unreadable";
|
|
44271
|
+
}
|
|
44272
|
+
if (st === void 0 || !st.isFile()) return "absent";
|
|
44249
44273
|
if (isWin()) {
|
|
44250
44274
|
const ext = path.extname(full).toLowerCase();
|
|
44251
|
-
return ext === "" || WIN_STARTABLE_EXT.includes(ext);
|
|
44275
|
+
return ext === "" || WIN_STARTABLE_EXT.includes(ext) ? "runnable" : "absent";
|
|
44252
44276
|
}
|
|
44253
44277
|
try {
|
|
44254
44278
|
accessSync(full, fsConstants.X_OK);
|
|
44255
|
-
return
|
|
44279
|
+
return "runnable";
|
|
44256
44280
|
} catch {
|
|
44257
|
-
return
|
|
44281
|
+
return "absent";
|
|
44258
44282
|
}
|
|
44259
44283
|
}
|
|
44284
|
+
function isRunnable(full) {
|
|
44285
|
+
return probe(full) === "runnable";
|
|
44286
|
+
}
|
|
44260
44287
|
function findRuntime(lang, env = process.env) {
|
|
44261
|
-
|
|
44288
|
+
return lookupRuntime(lang, env).found;
|
|
44289
|
+
}
|
|
44290
|
+
function lookupRuntime(lang, env = process.env) {
|
|
44291
|
+
const unreadable = [];
|
|
44292
|
+
if (isWin() && WIN_SHELL_LANGS.includes(lang)) return { found: findGitBash(env), unreadable };
|
|
44262
44293
|
const dirs = pathEntries(envValue(env, "PATH") ?? "", process.platform, path.delimiter);
|
|
44263
44294
|
const pathExt = isWin() ? (envValue(env, "PATHEXT") ?? PATHEXT_DEFAULT).split(PATHEXT_SEPARATOR).filter((e) => e !== "") : [];
|
|
44264
44295
|
const names = candidates(lang);
|
|
@@ -44267,13 +44298,15 @@ function findRuntime(lang, env = process.env) {
|
|
|
44267
44298
|
for (const name of names) {
|
|
44268
44299
|
for (const file2 of fileNames(name, pathExt)) {
|
|
44269
44300
|
const full = path.join(dir, file2);
|
|
44270
|
-
|
|
44271
|
-
if (
|
|
44301
|
+
const state = probe(full);
|
|
44302
|
+
if (state === "unreadable") unreadable.push(full);
|
|
44303
|
+
if (state !== "runnable") continue;
|
|
44304
|
+
if (!isWin() || path.extname(full) !== "") return { found: full, unreadable };
|
|
44272
44305
|
if (shim === null) shim = full;
|
|
44273
44306
|
}
|
|
44274
44307
|
}
|
|
44275
44308
|
}
|
|
44276
|
-
return shim;
|
|
44309
|
+
return { found: shim, unreadable };
|
|
44277
44310
|
}
|
|
44278
44311
|
function findGitBash(env) {
|
|
44279
44312
|
const git2 = findRuntime(GIT_BIN, env);
|
|
@@ -44353,7 +44386,7 @@ function runProcess(argv, o) {
|
|
|
44353
44386
|
let stopTimer;
|
|
44354
44387
|
const kill = () => {
|
|
44355
44388
|
if (child.pid !== void 0) killTree(child.pid);
|
|
44356
|
-
if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(), KILL_GRACE_MS);
|
|
44389
|
+
if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(true), KILL_GRACE_MS);
|
|
44357
44390
|
};
|
|
44358
44391
|
const onAbort = () => {
|
|
44359
44392
|
if (killedBy !== null || settled) return;
|
|
@@ -44382,15 +44415,21 @@ function runProcess(argv, o) {
|
|
|
44382
44415
|
...held ? { held: true } : {}
|
|
44383
44416
|
});
|
|
44384
44417
|
};
|
|
44385
|
-
const finishHeld = () => {
|
|
44418
|
+
const finishHeld = (force = false) => {
|
|
44386
44419
|
if (settled) return;
|
|
44387
|
-
|
|
44388
|
-
|
|
44389
|
-
|
|
44390
|
-
|
|
44391
|
-
|
|
44420
|
+
const seen = chunkCount;
|
|
44421
|
+
setImmediate(() => {
|
|
44422
|
+
if (settled || !force && chunkCount !== seen) return;
|
|
44423
|
+
held = exited && killedBy === null && !(child.stdout.readableEnded && child.stderr.readableEnded);
|
|
44424
|
+
child.stdout.destroy();
|
|
44425
|
+
child.stderr.destroy();
|
|
44426
|
+
if (child.pid !== void 0) killTree(child.pid);
|
|
44427
|
+
settle3(child.exitCode);
|
|
44428
|
+
});
|
|
44392
44429
|
};
|
|
44430
|
+
let chunkCount = 0;
|
|
44393
44431
|
const bump = () => {
|
|
44432
|
+
chunkCount++;
|
|
44394
44433
|
if (!exited || settled) return;
|
|
44395
44434
|
clearTimeout(graceTimer);
|
|
44396
44435
|
graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
|
|
@@ -44408,7 +44447,7 @@ function runProcess(argv, o) {
|
|
|
44408
44447
|
if (settled) return;
|
|
44409
44448
|
exited = true;
|
|
44410
44449
|
graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
|
|
44411
|
-
drainTimer = setTimeout(finishHeld, PIPE_DRAIN_MAX_MS);
|
|
44450
|
+
drainTimer = setTimeout(() => finishHeld(true), PIPE_DRAIN_MAX_MS);
|
|
44412
44451
|
});
|
|
44413
44452
|
child.on("error", () => settle3(null));
|
|
44414
44453
|
child.stdin.on("error", () => {
|
|
@@ -45084,8 +45123,8 @@ var ctxBatch = Object.freeze({
|
|
|
45084
45123
|
});
|
|
45085
45124
|
|
|
45086
45125
|
// src/core/tools/doctor.ts
|
|
45087
|
-
import { readdirSync as readdirSync8, readFileSync as
|
|
45088
|
-
import { basename as basename5, join as
|
|
45126
|
+
import { readdirSync as readdirSync8, readFileSync as readFileSync14, existsSync as existsSync18 } from "node:fs";
|
|
45127
|
+
import { basename as basename5, join as join18 } from "node:path";
|
|
45089
45128
|
|
|
45090
45129
|
// src/adapters/claude-code.ts
|
|
45091
45130
|
var TOOL_NAME_PREFIX = "mcp__plugin_context-mode_context-mode__";
|
|
@@ -45807,6 +45846,9 @@ function readResult6(p) {
|
|
|
45807
45846
|
if (p.keep === true) info.keep = true;
|
|
45808
45847
|
return info;
|
|
45809
45848
|
}
|
|
45849
|
+
function decodeOmp(raw) {
|
|
45850
|
+
return { ...decode11(raw), agent: "omp" };
|
|
45851
|
+
}
|
|
45810
45852
|
function decode11(raw) {
|
|
45811
45853
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("pi: hook payload is not an object");
|
|
45812
45854
|
const p = raw;
|
|
@@ -46108,10 +46150,32 @@ var ADAPTERS = Object.freeze([
|
|
|
46108
46150
|
decode: decode12,
|
|
46109
46151
|
encode: encode12,
|
|
46110
46152
|
toCanonicalTool
|
|
46153
|
+
},
|
|
46154
|
+
{
|
|
46155
|
+
// ADR-0026 (D-OMP-ROW-1): OMP runs the Pi extension API in-process, so the row reuses the Pi decode, encode and
|
|
46156
|
+
// permission check; tool names stay bare. Only the entry path and the skills folder are its own.
|
|
46157
|
+
id: "omp",
|
|
46158
|
+
installMode: "in-process",
|
|
46159
|
+
projectSource: "pi:ctx.cwd",
|
|
46160
|
+
toolNamePrefix: TOOL_NAME_PREFIX9,
|
|
46161
|
+
nativeTools: { shell: ["bash", "powershell"], read: ["read"] },
|
|
46162
|
+
execReadOnlyHint: false,
|
|
46163
|
+
eventMap: { SessionStart: "session_start", UserPromptSubmit: "input", PreToolUse: "tool_call", PostToolUse: "tool_result" },
|
|
46164
|
+
compactDelivery: "pi-flag",
|
|
46165
|
+
compactSummary: "none",
|
|
46166
|
+
hookTimeoutMs: IN_PROCESS_TIMEOUT_MS,
|
|
46167
|
+
denyChannel: "deny-reason",
|
|
46168
|
+
hookChannel: { kind: "in-process", path: "omp/index.js" },
|
|
46169
|
+
skillChannel: { kind: "package", path: "skills" },
|
|
46170
|
+
// D-OMP-SKILLS-1
|
|
46171
|
+
decode: decodeOmp,
|
|
46172
|
+
encode: encode11,
|
|
46173
|
+
checkPermission
|
|
46174
|
+
// D-OMP-FIRE-1: agent omp in rows
|
|
46111
46175
|
}
|
|
46112
46176
|
]);
|
|
46113
46177
|
var BY_ID = new Map(ADAPTERS.map((r) => [r.id, r]));
|
|
46114
|
-
var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode"]);
|
|
46178
|
+
var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode", "omp"]);
|
|
46115
46179
|
function hasReplace(row5) {
|
|
46116
46180
|
return REPLACE_ROWS.has(row5.id);
|
|
46117
46181
|
}
|
|
@@ -46142,8 +46206,8 @@ function ownBundleDir() {
|
|
|
46142
46206
|
}
|
|
46143
46207
|
|
|
46144
46208
|
// src/core/ops/doctor-config.ts
|
|
46145
|
-
import { existsSync as
|
|
46146
|
-
import { dirname as dirname7, isAbsolute as
|
|
46209
|
+
import { existsSync as existsSync12, readdirSync as readdirSync7, readFileSync as readFileSync11 } from "node:fs";
|
|
46210
|
+
import { dirname as dirname7, isAbsolute as isAbsolute4, join as join13, resolve as resolve4 } from "node:path";
|
|
46147
46211
|
|
|
46148
46212
|
// src/core/ops/host-text.ts
|
|
46149
46213
|
var BOM_CODE = 65279;
|
|
@@ -49155,6 +49219,14 @@ function configEntryRoot(adapter, env) {
|
|
|
49155
49219
|
if (typeof script !== "string" || !isAbsolute2(script)) throw missing(adapter.id, file2);
|
|
49156
49220
|
return dirname6(script);
|
|
49157
49221
|
}
|
|
49222
|
+
function packageDirOf(dir) {
|
|
49223
|
+
for (let cur = dir; ; ) {
|
|
49224
|
+
if (existsSync8(join10(cur, D1_PACKAGE_FILE))) return cur;
|
|
49225
|
+
const up = dirname6(cur);
|
|
49226
|
+
if (up === cur) return dir;
|
|
49227
|
+
cur = up;
|
|
49228
|
+
}
|
|
49229
|
+
}
|
|
49158
49230
|
function candidate(adapter, env, worktree) {
|
|
49159
49231
|
switch (adapter.installMode) {
|
|
49160
49232
|
case "marketplace":
|
|
@@ -49168,7 +49240,7 @@ function candidate(adapter, env, worktree) {
|
|
|
49168
49240
|
case "plugin":
|
|
49169
49241
|
return join10(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
|
|
49170
49242
|
case "in-process":
|
|
49171
|
-
return dirname6(fileURLToPath2(import.meta.url));
|
|
49243
|
+
return packageDirOf(dirname6(fileURLToPath2(import.meta.url)));
|
|
49172
49244
|
}
|
|
49173
49245
|
}
|
|
49174
49246
|
function resolvePluginRoot(adapter, env, worktree) {
|
|
@@ -49249,14 +49321,281 @@ function piInstalledIn(env, home, pkgDir, cwd) {
|
|
|
49249
49321
|
return user && ownEntries(user, pkgDir).length > 0 ? user.file : void 0;
|
|
49250
49322
|
}
|
|
49251
49323
|
|
|
49324
|
+
// src/core/ops/doctor-env.ts
|
|
49325
|
+
import { existsSync as existsSync10, readFileSync as readFileSync9, realpathSync as realpathSync6 } from "node:fs";
|
|
49326
|
+
import { isAbsolute as isAbsolute3, join as join11, relative as relative2 } from "node:path";
|
|
49327
|
+
function pass(id, detail = DOCTOR_PASS_DETAIL) {
|
|
49328
|
+
return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
|
|
49329
|
+
}
|
|
49330
|
+
function unknown4(id, detail, fixCommand) {
|
|
49331
|
+
return fixCommand === void 0 ? { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail } : { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail, fixCommand };
|
|
49332
|
+
}
|
|
49333
|
+
function fail(id, detail, fixCommand) {
|
|
49334
|
+
return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
|
|
49335
|
+
}
|
|
49336
|
+
function warn(id, detail, fixCommand) {
|
|
49337
|
+
return { id, label: DOCTOR_LABEL[id], status: "WARN", detail, fixCommand };
|
|
49338
|
+
}
|
|
49339
|
+
function bundleVersion(bundleDir2) {
|
|
49340
|
+
try {
|
|
49341
|
+
const v = JSON.parse(readFileSync9(join11(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
|
|
49342
|
+
return typeof v === "string" && v !== "" ? v : void 0;
|
|
49343
|
+
} catch {
|
|
49344
|
+
return void 0;
|
|
49345
|
+
}
|
|
49346
|
+
}
|
|
49347
|
+
function channelOf(version4) {
|
|
49348
|
+
const at = version4.indexOf(D1_PRERELEASE_SEP);
|
|
49349
|
+
if (at < 0) return D1_DEFAULT_TAG;
|
|
49350
|
+
const pre = version4.slice(at + 1);
|
|
49351
|
+
const dot = pre.indexOf(".");
|
|
49352
|
+
const tag = dot < 0 ? pre : pre.slice(0, dot);
|
|
49353
|
+
return tag === "" ? D1_DEFAULT_TAG : tag;
|
|
49354
|
+
}
|
|
49355
|
+
function firstLine2(b) {
|
|
49356
|
+
const text = b.toString("utf8").trim();
|
|
49357
|
+
const nl = text.indexOf("\n");
|
|
49358
|
+
return (nl < 0 ? text : text.slice(0, nl)).trim();
|
|
49359
|
+
}
|
|
49360
|
+
function gitCause(r, timeoutMs) {
|
|
49361
|
+
if (r.killed === "timeout") return D1_GIT_TIMEOUT(timeoutMs);
|
|
49362
|
+
if (r.killed === "cancel") return D1_GIT_CANCEL;
|
|
49363
|
+
if (r.exitCode === null) return D1_GIT_NO_START;
|
|
49364
|
+
return D1_GIT_EXIT(r.exitCode, firstLine2(r.stderr));
|
|
49365
|
+
}
|
|
49366
|
+
function fetchCause(err, timeoutMs) {
|
|
49367
|
+
const name = err instanceof Error ? err.name : "";
|
|
49368
|
+
if (name === "TimeoutError") return D1_NPM_TIMEOUT(timeoutMs);
|
|
49369
|
+
const cause = err instanceof Error && err.cause instanceof Error ? err.cause : err;
|
|
49370
|
+
const code = typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? cause.code : "";
|
|
49371
|
+
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
49372
|
+
const parts = code !== "" && !msg.includes(code) ? [code, msg] : [msg];
|
|
49373
|
+
return D1_NPM_ERROR(parts.filter((part) => part !== "").join(" "));
|
|
49374
|
+
}
|
|
49375
|
+
async function npmLatest(url4, tag, signal, timeoutMs) {
|
|
49376
|
+
try {
|
|
49377
|
+
const res = await fetch(url4, { signal: AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) });
|
|
49378
|
+
if (!res.ok) return { ok: false, cause: D1_NPM_HTTP(res.status) };
|
|
49379
|
+
const body = await res.json();
|
|
49380
|
+
const v = typeof body === "object" && body !== null ? body[tag] : void 0;
|
|
49381
|
+
return typeof v === "string" && v !== "" ? { ok: true, version: v } : { ok: false, cause: D1_NPM_NO_TAG(tag) };
|
|
49382
|
+
} catch (err) {
|
|
49383
|
+
return { ok: false, cause: fetchCause(err, timeoutMs) };
|
|
49384
|
+
}
|
|
49385
|
+
}
|
|
49386
|
+
function digits(s) {
|
|
49387
|
+
if (s === "") return false;
|
|
49388
|
+
for (const ch of s) if (ch < "0" || ch > "9") return false;
|
|
49389
|
+
return true;
|
|
49390
|
+
}
|
|
49391
|
+
function parseVersion(v) {
|
|
49392
|
+
const at = v.indexOf(D1_PRERELEASE_SEP);
|
|
49393
|
+
const core = (at < 0 ? v : v.slice(0, at)).split(NODE_VERSION_SEP);
|
|
49394
|
+
if (core.length !== 3 || !core.every(digits)) return null;
|
|
49395
|
+
const nums = [Number(core[0]), Number(core[1]), Number(core[2])];
|
|
49396
|
+
if (at < 0) return { core: nums, pre: [] };
|
|
49397
|
+
const pre = v.slice(at + 1).split(NODE_VERSION_SEP);
|
|
49398
|
+
if (pre[0] === "" || digits(pre[0]) || pre.length > 2) return null;
|
|
49399
|
+
if (pre.length === 1) return { core: nums, pre: [pre[0]] };
|
|
49400
|
+
return digits(pre[1]) ? { core: nums, pre: [pre[0], Number(pre[1])] } : null;
|
|
49401
|
+
}
|
|
49402
|
+
function sign(n) {
|
|
49403
|
+
return n < 0 ? -1 : n > 0 ? 1 : 0;
|
|
49404
|
+
}
|
|
49405
|
+
function compareVersions(a, b) {
|
|
49406
|
+
const x = parseVersion(a);
|
|
49407
|
+
const y = parseVersion(b);
|
|
49408
|
+
if (x === null || y === null) return null;
|
|
49409
|
+
for (let k = 0; k < 3; k++) if (x.core[k] !== y.core[k]) return sign(x.core[k] - y.core[k]);
|
|
49410
|
+
if (x.pre.length === 0 || y.pre.length === 0) return sign(y.pre.length - x.pre.length);
|
|
49411
|
+
if (x.pre[0] !== y.pre[0]) return x.pre[0] < y.pre[0] ? -1 : 1;
|
|
49412
|
+
return sign((x.pre[1] ?? -1) - (y.pre[1] ?? -1));
|
|
49413
|
+
}
|
|
49414
|
+
function highestTag(stdout, tag) {
|
|
49415
|
+
let best;
|
|
49416
|
+
for (const line of stdout.split("\n")) {
|
|
49417
|
+
const [sha, ref] = line.trim().split(LS_REMOTE_FIELD_SEP);
|
|
49418
|
+
if (sha === void 0 || sha.length !== GIT_SHA_HEX_LEN || ref === void 0 || !ref.startsWith(RELEASE_TAG_REF_PREFIX)) continue;
|
|
49419
|
+
const v = ref.slice(RELEASE_TAG_REF_PREFIX.length);
|
|
49420
|
+
if (parseVersion(v) === null || channelOf(v) !== tag) continue;
|
|
49421
|
+
if (best === void 0 || compareVersions(v, best) === 1) best = v;
|
|
49422
|
+
}
|
|
49423
|
+
return best;
|
|
49424
|
+
}
|
|
49425
|
+
function versionRow(head, installed, tag, source, latest, tail, update) {
|
|
49426
|
+
const cmp = compareVersions(installed, latest) ?? (installed === latest ? 0 : -1);
|
|
49427
|
+
if (cmp === 0) return pass("D1", head + D1_LATEST_PASS(tag, source) + tail);
|
|
49428
|
+
if (cmp > 0) return pass("D1", head + D1_LATEST_AHEAD(tag, source, latest) + tail);
|
|
49429
|
+
return warn("D1", head + D1_LATEST_UPDATE(tag, source, latest) + tail, update);
|
|
49430
|
+
}
|
|
49431
|
+
async function checkVersion(i) {
|
|
49432
|
+
if (i.bundleSha === void 0) return unknown4("D1", D1_DEV_BUILD_DETAIL);
|
|
49433
|
+
const head = D1_PREFIX(i.version, i.bundleSha) + ": ";
|
|
49434
|
+
if (i.version === void 0) return unknown4("D1", head + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
|
|
49435
|
+
const tag = channelOf(i.version);
|
|
49436
|
+
const update = i.updateCommand ?? DOCTOR_FIX_UPGRADE;
|
|
49437
|
+
const git2 = findRuntime(GIT_BIN, i.env);
|
|
49438
|
+
const npm = await npmLatest(i.registryUrl, tag, i.signal, i.timeoutMs);
|
|
49439
|
+
if (npm.ok) return versionRow(head, i.version, tag, D1_SOURCE_NPM, npm.version, "", update);
|
|
49440
|
+
let cause = D1_GIT_MISSING;
|
|
49441
|
+
if (git2 !== null) {
|
|
49442
|
+
const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
|
|
49443
|
+
cwd: i.cwd,
|
|
49444
|
+
env: { ...i.env, ...GIT_NO_PROMPT_ENV },
|
|
49445
|
+
signal: i.signal,
|
|
49446
|
+
timeoutMs: i.timeoutMs
|
|
49447
|
+
});
|
|
49448
|
+
if (r.exitCode === 0 && r.killed === null) {
|
|
49449
|
+
const latest = highestTag(r.stdout.toString("utf8"), tag);
|
|
49450
|
+
if (latest !== void 0) return versionRow(head, i.version, tag, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause, update);
|
|
49451
|
+
cause = D1_GIT_NO_TAG(tag);
|
|
49452
|
+
} else {
|
|
49453
|
+
cause = gitCause(r, i.timeoutMs);
|
|
49454
|
+
}
|
|
49455
|
+
}
|
|
49456
|
+
return unknown4("D1", head + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause, git2 === null ? D1_NPM_CHECK_FIX : D1_GIT_CHECK_FIX);
|
|
49457
|
+
}
|
|
49458
|
+
function numbers(v) {
|
|
49459
|
+
const bare2 = v.startsWith(NODE_VERSION_PREFIX) ? v.slice(NODE_VERSION_PREFIX.length) : v;
|
|
49460
|
+
return bare2.split(NODE_VERSION_SEP).map(Number);
|
|
49461
|
+
}
|
|
49462
|
+
function belowMin(version4) {
|
|
49463
|
+
const got = numbers(version4);
|
|
49464
|
+
const min = numbers(NODE_MIN);
|
|
49465
|
+
for (let k = 0; k < min.length; k++) {
|
|
49466
|
+
const g = got[k] ?? 0;
|
|
49467
|
+
if (g !== min[k]) return g < min[k];
|
|
49468
|
+
}
|
|
49469
|
+
return false;
|
|
49470
|
+
}
|
|
49471
|
+
async function sqliteLoads() {
|
|
49472
|
+
try {
|
|
49473
|
+
await import(SQLITE_MODULE);
|
|
49474
|
+
return true;
|
|
49475
|
+
} catch {
|
|
49476
|
+
return false;
|
|
49477
|
+
}
|
|
49478
|
+
}
|
|
49479
|
+
async function checkNode(i) {
|
|
49480
|
+
const bun = i.bunVersion === void 0 ? [] : [D2_BUN_DETAIL(i.bunVersion)];
|
|
49481
|
+
const withBun = (detail) => [detail, ...bun].join(D4_REASON_JOIN);
|
|
49482
|
+
if (belowMin(i.nodeVersion)) return fail("D2", withBun(D2_NODE_DETAIL(i.nodeVersion)), D2_NODE_FIX);
|
|
49483
|
+
if (!await sqliteLoads()) return fail("D2", withBun(D2_SQLITE_DETAIL), D2_SQLITE_FIX);
|
|
49484
|
+
return pass("D2", bun.length === 0 ? DOCTOR_PASS_DETAIL : bun.join(D4_REASON_JOIN));
|
|
49485
|
+
}
|
|
49486
|
+
function checkMcp(ctx, adapter) {
|
|
49487
|
+
const named2 = ctx.clientInfo !== void 0 && ctx.clientInfo.name !== "";
|
|
49488
|
+
const versioned = ctx.protocolVersion !== void 0 && ctx.protocolVersion !== "";
|
|
49489
|
+
if (named2 || versioned) return pass("D6");
|
|
49490
|
+
return adapter?.installMode === "in-process" ? pass("D6", D6_IN_PROCESS_DETAIL) : unknown4("D6", D6_UNKNOWN_DETAIL);
|
|
49491
|
+
}
|
|
49492
|
+
function piCwdInside(worktree, piCwd) {
|
|
49493
|
+
if (piCwd === void 0 || !existsSync10(piCwd)) return false;
|
|
49494
|
+
const rel = relative2(worktree, realpathSync6.native(piCwd));
|
|
49495
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
|
|
49496
|
+
}
|
|
49497
|
+
function checkProject(i) {
|
|
49498
|
+
const bad = fail("D7", D7_DETAIL(i.project.source), D7_FIX);
|
|
49499
|
+
if (i.project.source !== i.adapter.projectSource) return bad;
|
|
49500
|
+
if (i.adapter.projectSource === "pi:ctx.cwd" && !piCwdInside(i.project.worktree, i.piCwd)) return bad;
|
|
49501
|
+
return pass("D7");
|
|
49502
|
+
}
|
|
49503
|
+
function checkMode(adapter, hostPermission) {
|
|
49504
|
+
if (hostPermission === "missing") return fail("D10", D10_PERMISSION_MISSING_DETAIL, D10_PERMISSION_FIX);
|
|
49505
|
+
if (hostPermission === "wired") return pass("D10", D10_PERMISSION_DETAIL(adapter.denyChannel));
|
|
49506
|
+
return pass("D10", D10_DETAIL(adapter.denyChannel));
|
|
49507
|
+
}
|
|
49508
|
+
function checkShell(env) {
|
|
49509
|
+
const win = process.platform === "win32";
|
|
49510
|
+
const shell = findRuntime("shell", env);
|
|
49511
|
+
if (shell !== null) return pass("D11", D11_PASS_DETAIL(shell, win));
|
|
49512
|
+
return win ? fail("D11", D11_WIN_DETAIL, D11_WIN_FIX) : fail("D11", D11_POSIX_DETAIL, D11_POSIX_FIX);
|
|
49513
|
+
}
|
|
49514
|
+
function checkRuntimes(env, shellRow) {
|
|
49515
|
+
if (shellRow.status !== "PASS") return shellRow;
|
|
49516
|
+
for (const lang of EXEC_LANGUAGES) {
|
|
49517
|
+
if (lang === "shell") continue;
|
|
49518
|
+
const r = lookupRuntime(lang, env);
|
|
49519
|
+
if (r.found === null && r.unreadable.length > 0) return warn("D11", D11_RUNTIME_DETAIL(lang, r.unreadable), D11_RUNTIME_FIX(lang));
|
|
49520
|
+
}
|
|
49521
|
+
return shellRow;
|
|
49522
|
+
}
|
|
49523
|
+
|
|
49524
|
+
// src/core/ops/omp-import.ts
|
|
49525
|
+
import { join as join12 } from "node:path";
|
|
49526
|
+
var { existsSync: existsSync11, readFileSync: readFileSync10 } = process.getBuiltinModule("node:fs");
|
|
49527
|
+
var OMP_DISABLED_SERVERS_KEY = "disabledServers";
|
|
49528
|
+
var OMP_MCP_FILE = "mcp.json";
|
|
49529
|
+
var OMP_CONFIG_FILE = "config.yml";
|
|
49530
|
+
var ENABLED_PROVIDERS = "enabledProviders";
|
|
49531
|
+
var DISABLED_PROVIDERS = "disabledProviders";
|
|
49532
|
+
var CLAUDE_PROVIDER = "claude";
|
|
49533
|
+
var ALL_PROVIDERS = ["*", "all"];
|
|
49534
|
+
function ompImportFiles(home) {
|
|
49535
|
+
const agentDir = join12(home, ...AGENT_HOME_DIR.omp, PI_AGENT_DIR);
|
|
49536
|
+
return { config: join12(agentDir, OMP_CONFIG_FILE), mcp: join12(agentDir, OMP_MCP_FILE), claude: join12(home, CLAUDE_USER_CONFIG_FILE) };
|
|
49537
|
+
}
|
|
49538
|
+
function readText2(file2) {
|
|
49539
|
+
try {
|
|
49540
|
+
return existsSync11(file2) ? hostText(readFileSync10(file2, "utf8")) : void 0;
|
|
49541
|
+
} catch {
|
|
49542
|
+
return void 0;
|
|
49543
|
+
}
|
|
49544
|
+
}
|
|
49545
|
+
var unquote = (s) => {
|
|
49546
|
+
const t = s.trim();
|
|
49547
|
+
const q = t[0];
|
|
49548
|
+
return (q === '"' || q === "'") && t.endsWith(q) && t.length > 1 ? t.slice(1, -1) : t;
|
|
49549
|
+
};
|
|
49550
|
+
var withoutComment = (s) => {
|
|
49551
|
+
const at = s.indexOf(" #");
|
|
49552
|
+
return at === -1 ? s : s.slice(0, at);
|
|
49553
|
+
};
|
|
49554
|
+
function yamlTopList(text, key) {
|
|
49555
|
+
const lines = text.split("\n").map((l) => l.endsWith("\r") ? l.slice(0, -1) : l);
|
|
49556
|
+
const head = `${key}:`;
|
|
49557
|
+
const at = lines.findIndex((l) => l.startsWith(head));
|
|
49558
|
+
if (at === -1) return [];
|
|
49559
|
+
const rest = withoutComment(lines[at].slice(head.length)).trim();
|
|
49560
|
+
if (rest.startsWith("[")) {
|
|
49561
|
+
const end = rest.indexOf("]");
|
|
49562
|
+
return (end === -1 ? rest.slice(1) : rest.slice(1, end)).split(",").map(unquote).filter((x) => x !== "");
|
|
49563
|
+
}
|
|
49564
|
+
if (rest !== "") return [];
|
|
49565
|
+
const out = [];
|
|
49566
|
+
for (const line of lines.slice(at + 1)) {
|
|
49567
|
+
const t = line.trim();
|
|
49568
|
+
if (t === "" || t.startsWith("#")) continue;
|
|
49569
|
+
if (line === line.trimStart() && !t.startsWith("-")) break;
|
|
49570
|
+
if (!t.startsWith("-")) break;
|
|
49571
|
+
out.push(unquote(withoutComment(t.slice(1))));
|
|
49572
|
+
}
|
|
49573
|
+
return out;
|
|
49574
|
+
}
|
|
49575
|
+
function ompImportsUs(files, env) {
|
|
49576
|
+
const config4 = readText2(files.config) ?? "";
|
|
49577
|
+
if (yamlTopList(config4, DISABLED_PROVIDERS).includes(CLAUDE_PROVIDER)) return false;
|
|
49578
|
+
const enabled = yamlTopList(config4, ENABLED_PROVIDERS);
|
|
49579
|
+
const dirSet = env[CLAUDE_CONFIG_DIR_ENV] !== void 0 && env[CLAUDE_CONFIG_DIR_ENV] !== "";
|
|
49580
|
+
if (!dirSet && !enabled.some((p) => p === CLAUDE_PROVIDER || ALL_PROVIDERS.includes(p))) return false;
|
|
49581
|
+
const claude = readText2(files.claude);
|
|
49582
|
+
if (claude === void 0) return false;
|
|
49583
|
+
try {
|
|
49584
|
+
const servers = JSON.parse(claude)[MCP_SERVERS_KEY];
|
|
49585
|
+
return typeof servers === "object" && servers !== null && Object.hasOwn(servers, SERVER_KEY);
|
|
49586
|
+
} catch {
|
|
49587
|
+
return false;
|
|
49588
|
+
}
|
|
49589
|
+
}
|
|
49590
|
+
|
|
49252
49591
|
// src/core/ops/doctor-config.ts
|
|
49253
49592
|
var [PART_MCP, PART_HOOKS, PART_TIMEOUT] = D3_PARTS;
|
|
49254
49593
|
var isObject4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
49255
49594
|
var list = (v) => Array.isArray(v) ? v : [];
|
|
49256
|
-
function
|
|
49595
|
+
function pass2(id) {
|
|
49257
49596
|
return { id, label: DOCTOR_LABEL[id], status: "PASS", detail: DOCTOR_PASS_DETAIL };
|
|
49258
49597
|
}
|
|
49259
|
-
function
|
|
49598
|
+
function fail2(id, detail, fixCommand) {
|
|
49260
49599
|
return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
|
|
49261
49600
|
}
|
|
49262
49601
|
function readParsed(agent, file2) {
|
|
@@ -49326,11 +49665,11 @@ function ownHooks(block, shape, timeoutKey, native, agent) {
|
|
|
49326
49665
|
var validTimeout = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
49327
49666
|
function mcpFile(row5, home, env) {
|
|
49328
49667
|
const spec = OWN_MCP_ENTRY[row5.id];
|
|
49329
|
-
if (row5.id === "codex") return
|
|
49668
|
+
if (row5.id === "codex") return join13(codexDirOf(env, home), CONFIG_TOML_FILE);
|
|
49330
49669
|
if (spec !== void 0) return ownMcpFileOf(row5.id, spec.file, env, home);
|
|
49331
|
-
if (row5.id === "opencode") return
|
|
49670
|
+
if (row5.id === "opencode") return join13(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
|
|
49332
49671
|
if (row5.id === "pi") {
|
|
49333
|
-
return
|
|
49672
|
+
return join13(piAgentDirOf(env, home), SETTINGS_FILE);
|
|
49334
49673
|
}
|
|
49335
49674
|
return null;
|
|
49336
49675
|
}
|
|
@@ -49343,27 +49682,27 @@ function codexNativeDir(env, home) {
|
|
|
49343
49682
|
const codexDir = codexDirOf(env, home);
|
|
49344
49683
|
let enabled;
|
|
49345
49684
|
try {
|
|
49346
|
-
enabled = hostConfigValueAt(readParsed("codex",
|
|
49685
|
+
enabled = hostConfigValueAt(readParsed("codex", join13(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
|
|
49347
49686
|
} catch {
|
|
49348
49687
|
return null;
|
|
49349
49688
|
}
|
|
49350
49689
|
if (enabled !== true) return null;
|
|
49351
|
-
const cache =
|
|
49352
|
-
if (!
|
|
49690
|
+
const cache = join13(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
|
|
49691
|
+
if (!existsSync12(cache)) return null;
|
|
49353
49692
|
const found = [];
|
|
49354
49693
|
for (const market of readdirSync7(cache)) {
|
|
49355
|
-
const plugin =
|
|
49356
|
-
if (!
|
|
49694
|
+
const plugin = join13(cache, market, SERVER_KEY);
|
|
49695
|
+
if (!existsSync12(plugin)) continue;
|
|
49357
49696
|
for (const version4 of readdirSync7(plugin).sort()) {
|
|
49358
|
-
const dir =
|
|
49359
|
-
if (
|
|
49697
|
+
const dir = join13(plugin, version4, CODEX_PLUGIN_SUBDIR);
|
|
49698
|
+
if (existsSync12(join13(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
|
|
49360
49699
|
}
|
|
49361
49700
|
}
|
|
49362
49701
|
return found.length === 0 ? null : found[found.length - 1];
|
|
49363
49702
|
}
|
|
49364
49703
|
function nativeMcpWrong(dir, row5) {
|
|
49365
49704
|
try {
|
|
49366
|
-
const entry = hostConfigValueAt(readParsed(row5.id,
|
|
49705
|
+
const entry = hostConfigValueAt(readParsed(row5.id, join13(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
|
|
49367
49706
|
if (!isObject4(entry)) return true;
|
|
49368
49707
|
const args = list(entry[MCP_ARGS_FIELD]);
|
|
49369
49708
|
const script = args[0];
|
|
@@ -49434,17 +49773,17 @@ function opencodePluginDirs(configDir, worktree) {
|
|
|
49434
49773
|
return [configDir, opencodeProjectDir(worktree)];
|
|
49435
49774
|
}
|
|
49436
49775
|
function opencodeProjectDir(worktree) {
|
|
49437
|
-
return
|
|
49776
|
+
return join13(worktree, OPENCODE_PROJECT_DIR);
|
|
49438
49777
|
}
|
|
49439
49778
|
function packageResolves(fromDir) {
|
|
49440
49779
|
for (let d = fromDir; ; d = dirname7(d)) {
|
|
49441
|
-
if (
|
|
49780
|
+
if (existsSync12(join13(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
|
|
49442
49781
|
if (dirname7(d) === d) return false;
|
|
49443
49782
|
}
|
|
49444
49783
|
}
|
|
49445
49784
|
function opencodeDirPlugins(dirs) {
|
|
49446
49785
|
const bundle = opencodePluginFile();
|
|
49447
|
-
const ownFile =
|
|
49786
|
+
const ownFile = join13(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
|
|
49448
49787
|
const isModule = (p) => OWN_PLUGIN_MODULES.includes(p);
|
|
49449
49788
|
const isPath = (p) => {
|
|
49450
49789
|
if (p === ownFile || p === `${FILE_URL_PREFIX}${ownFile}`) return true;
|
|
@@ -49454,7 +49793,7 @@ function opencodeDirPlugins(dirs) {
|
|
|
49454
49793
|
};
|
|
49455
49794
|
const out = [];
|
|
49456
49795
|
for (const dir of dirs) {
|
|
49457
|
-
const pdir =
|
|
49796
|
+
const pdir = join13(dir, OPENCODE_PLUGINS_DIR);
|
|
49458
49797
|
let names;
|
|
49459
49798
|
try {
|
|
49460
49799
|
names = readdirSync7(pdir);
|
|
@@ -49462,12 +49801,12 @@ function opencodeDirPlugins(dirs) {
|
|
|
49462
49801
|
continue;
|
|
49463
49802
|
}
|
|
49464
49803
|
for (const name of names) {
|
|
49465
|
-
const loose = OPENCODE_PLUGIN_EXTS.some((x) => name.endsWith(x)) ? [
|
|
49466
|
-
const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x) =>
|
|
49804
|
+
const loose = OPENCODE_PLUGIN_EXTS.some((x) => name.endsWith(x)) ? [join13(pdir, name)] : [];
|
|
49805
|
+
const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x) => join13(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x}`))];
|
|
49467
49806
|
for (const f of files) {
|
|
49468
49807
|
let text;
|
|
49469
49808
|
try {
|
|
49470
|
-
const b =
|
|
49809
|
+
const b = readFileSync11(f);
|
|
49471
49810
|
if (b.length > OPENCODE_DIR_FILE_MAX) continue;
|
|
49472
49811
|
text = b.toString("utf8");
|
|
49473
49812
|
} catch {
|
|
@@ -49478,7 +49817,7 @@ function opencodeDirPlugins(dirs) {
|
|
|
49478
49817
|
const loads = lits.some((p) => {
|
|
49479
49818
|
if (isModule(p)) return packageResolves(dirname7(f));
|
|
49480
49819
|
const bare2 = p.startsWith(FILE_URL_PREFIX) ? p.slice(FILE_URL_PREFIX.length) : p;
|
|
49481
|
-
return
|
|
49820
|
+
return existsSync12(isAbsolute4(bare2) ? bare2 : resolve4(dirname7(f), bare2));
|
|
49482
49821
|
});
|
|
49483
49822
|
out.push({ file: f, loads });
|
|
49484
49823
|
}
|
|
@@ -49496,19 +49835,19 @@ function opencodeMcpOwn(entry) {
|
|
|
49496
49835
|
return isNodeCommand(node3) && typeof script === "string" && lastSegment(script) === SERVER_ENTRY_FILE && flag === AGENT_ARG && agent === "opencode";
|
|
49497
49836
|
}
|
|
49498
49837
|
function opencodeFileValue(file2) {
|
|
49499
|
-
if (!
|
|
49500
|
-
return parseHostConfig("opencode", file2, hostText(
|
|
49838
|
+
if (!existsSync12(file2)) return {};
|
|
49839
|
+
return parseHostConfig("opencode", file2, hostText(readFileSync11(file2, "utf8")), "jsonc");
|
|
49501
49840
|
}
|
|
49502
49841
|
function opencodeValueListed(value) {
|
|
49503
49842
|
const bundle = opencodePluginFile();
|
|
49504
|
-
const own4 = [bundle,
|
|
49843
|
+
const own4 = [bundle, join13(bundle, ...OPENCODE_PLUGIN_PATH)];
|
|
49505
49844
|
if ([OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own4)))) return true;
|
|
49506
49845
|
const mcp = isObject4(value) && isObject4(value.mcp) ? value.mcp : {};
|
|
49507
49846
|
return opencodeMcpOwn(mcp[SERVER_KEY]) || isObject4(mcp.servers) && opencodeMcpOwn(mcp.servers[SERVER_KEY]);
|
|
49508
49847
|
}
|
|
49509
49848
|
function opencodeListed(file2, worktree) {
|
|
49510
49849
|
const dirs = [dirname7(file2), worktree];
|
|
49511
|
-
if (dirs.some((dir) => OPENCODE_CONFIG_FILES.some((name) => opencodeValueListed(opencodeFileValue(
|
|
49850
|
+
if (dirs.some((dir) => OPENCODE_CONFIG_FILES.some((name) => opencodeValueListed(opencodeFileValue(join13(dir, name)))))) return true;
|
|
49512
49851
|
return opencodeDirPlugin(opencodePluginDirs(dirname7(file2), worktree)) !== void 0;
|
|
49513
49852
|
}
|
|
49514
49853
|
function mcpWrong(row5, home, env, worktree) {
|
|
@@ -49530,7 +49869,7 @@ function mcpWrong(row5, home, env, worktree) {
|
|
|
49530
49869
|
function hookFile(row5, spec, home, env, worktree) {
|
|
49531
49870
|
const root = spec.root === "plugin" ? resolvePluginRoot(row5, env, worktree) : spec.root === "home" ? home : worktree;
|
|
49532
49871
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
49533
|
-
const file2 = native !== null ?
|
|
49872
|
+
const file2 = native !== null ? join13(native, CODEX_PLUGIN_HOOKS_FILE) : row5.id === "codex" ? join13(codexDirOf(env, home), HOOKS_JSON_FILE) : row5.id === "copilot-cli" ? join13(copilotDirOf(env, home), ...spec.file.slice(1)) : row5.id === "kiro" ? join13(kiroDirOf(env, home), ...spec.file.slice(1)) : join13(root, ...spec.file);
|
|
49534
49873
|
return file2;
|
|
49535
49874
|
}
|
|
49536
49875
|
function hookParts(row5, home, env, worktree) {
|
|
@@ -49541,7 +49880,7 @@ function hookParts(row5, home, env, worktree) {
|
|
|
49541
49880
|
const file2 = hookFile(row5, spec, home, env, worktree);
|
|
49542
49881
|
block = hostConfigValueAt(readParsed(row5.id, file2).value, spec.key);
|
|
49543
49882
|
if (row5.id === "codex") {
|
|
49544
|
-
const config4 = readParsed(row5.id,
|
|
49883
|
+
const config4 = readParsed(row5.id, join13(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
|
|
49545
49884
|
if (hostConfigValueAt(config4, CODEX_FEATURES_HOOKS_KEY) === false) return [PART_HOOKS];
|
|
49546
49885
|
}
|
|
49547
49886
|
} catch {
|
|
@@ -49570,29 +49909,67 @@ function hookParts(row5, home, env, worktree) {
|
|
|
49570
49909
|
}
|
|
49571
49910
|
function checkHostConfig(row5, env, worktree) {
|
|
49572
49911
|
const home = homeDirOf(env);
|
|
49573
|
-
if (home === null) return
|
|
49912
|
+
if (home === null) return fail2("D3", D3_DETAIL(D3_PARTS), DOCTOR_FIX_UPGRADE);
|
|
49574
49913
|
if (row5.installMode === "marketplace") {
|
|
49575
49914
|
const choice = marketplaceChoice(env, worktree);
|
|
49576
|
-
if ("installs" in choice) return
|
|
49915
|
+
if ("installs" in choice) return fail2("D3", D3_ROOT_DETAIL(choice.installs.map((r) => r.installPath)), D3_ROOT_FIX(choice.installs));
|
|
49577
49916
|
}
|
|
49578
49917
|
if (row5.id === "pi") return checkPiInstall(env, home, worktree);
|
|
49918
|
+
if (row5.id === "omp") return checkOmpInstall(home);
|
|
49579
49919
|
const parts = [...mcpWrong(row5, home, env, worktree) ? [PART_MCP] : [], ...hookParts(row5, home, env, worktree)];
|
|
49580
|
-
if (parts.length === 0) return
|
|
49920
|
+
if (parts.length === 0) return pass2("D3");
|
|
49581
49921
|
const detail = D3_DETAIL(parts);
|
|
49582
49922
|
const fix = parts.includes(PART_MCP) ? D3_NO_SETUP_FIX(row5.id) : DOCTOR_FIX_UPGRADE;
|
|
49583
|
-
return
|
|
49923
|
+
return fail2("D3", detail, fix);
|
|
49584
49924
|
}
|
|
49585
49925
|
function checkPiInstall(env, home, worktree) {
|
|
49586
49926
|
const found = piInstalledIn(env, home, ownBundleDir(), worktree);
|
|
49587
|
-
if (found !== void 0) return { ...
|
|
49588
|
-
return
|
|
49927
|
+
if (found !== void 0) return { ...pass2("D3"), detail: found };
|
|
49928
|
+
return fail2("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + join13(piAgentDirOf(env, home), SETTINGS_FILE), NATIVE_INSTALL.pi[0]);
|
|
49929
|
+
}
|
|
49930
|
+
var OMP_PLUGINS_DIR = "plugins";
|
|
49931
|
+
var OMP_LOCK_FILE = "omp-plugins.lock.json";
|
|
49932
|
+
function readJson2(file2) {
|
|
49933
|
+
try {
|
|
49934
|
+
const doc = JSON.parse(readFileSync11(file2, "utf8"));
|
|
49935
|
+
return typeof doc === "object" && doc !== null ? doc : void 0;
|
|
49936
|
+
} catch {
|
|
49937
|
+
return void 0;
|
|
49938
|
+
}
|
|
49939
|
+
}
|
|
49940
|
+
function ownEntry(doc, key) {
|
|
49941
|
+
const map2 = doc?.[key];
|
|
49942
|
+
return typeof map2 === "object" && map2 !== null ? map2[SERVER_KEY] : void 0;
|
|
49943
|
+
}
|
|
49944
|
+
function checkOmpInstall(home) {
|
|
49945
|
+
const dir = join13(home, ...AGENT_HOME_DIR.omp, OMP_PLUGINS_DIR);
|
|
49946
|
+
const lock = join13(dir, OMP_LOCK_FILE);
|
|
49947
|
+
const pkg = join13(dir, PI_PACKAGE_JSON_FILE);
|
|
49948
|
+
const entry = ownEntry(readJson2(lock), "plugins");
|
|
49949
|
+
const missing2 = (file2) => fail2("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + file2, NATIVE_INSTALL.omp[0]);
|
|
49950
|
+
if (typeof entry !== "object" || entry === null) return missing2(lock);
|
|
49951
|
+
if (ownEntry(readJson2(pkg), "dependencies") === void 0) return missing2(pkg);
|
|
49952
|
+
if (entry.enabled !== true) return fail2("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + lock, OMP_ENABLE_COMMAND);
|
|
49953
|
+
return { ...pass2("D3"), detail: lock };
|
|
49954
|
+
}
|
|
49955
|
+
function ompInfoLines(env, version4) {
|
|
49956
|
+
const out = [];
|
|
49957
|
+
if (version4 !== void 0 && compareVersions(version4, OMP_MIN_VERSION) === -1) out.push(OMP_FLOOR_INFO(version4));
|
|
49958
|
+
out.push(OMP_CONTENT_INFO, OMP_PRINT_MODE_INFO, OMP_SCRIPTS_INFO);
|
|
49959
|
+
const home = homeDirOf(env);
|
|
49960
|
+
if (home === null) return out;
|
|
49961
|
+
const files = ompImportFiles(home);
|
|
49962
|
+
if (!ompImportsUs(files, env)) return out;
|
|
49963
|
+
const listed = readJson2(files.mcp)?.[OMP_DISABLED_SERVERS_KEY];
|
|
49964
|
+
if (!(Array.isArray(listed) && listed.includes(SERVER_KEY))) out.push(OMP_IMPORT_INFO(files.claude, files.mcp));
|
|
49965
|
+
return out;
|
|
49589
49966
|
}
|
|
49590
49967
|
function checkV1Leftovers(agent, home, scope = {}) {
|
|
49591
49968
|
const findings = detectV1(agent, home, scope);
|
|
49592
|
-
if (findings.length === 0) return
|
|
49969
|
+
if (findings.length === 0) return pass2("D4");
|
|
49593
49970
|
const detail = findings.map((f) => f.reason).join(D4_REASON_JOIN);
|
|
49594
|
-
if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...
|
|
49595
|
-
return { ...
|
|
49971
|
+
if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...pass2("D4"), detail };
|
|
49972
|
+
return { ...fail2("D4", detail, DOCTOR_FIX_UPGRADE), status: "WARN" };
|
|
49596
49973
|
}
|
|
49597
49974
|
function parsedOrNull(agent, file2, jsonc) {
|
|
49598
49975
|
try {
|
|
@@ -49603,13 +49980,13 @@ function parsedOrNull(agent, file2, jsonc) {
|
|
|
49603
49980
|
}
|
|
49604
49981
|
}
|
|
49605
49982
|
function checkDoubleFire(agent, worktree) {
|
|
49606
|
-
if (agent !== "claude-code" && agent !== "vscode") return
|
|
49607
|
-
const claude = parsedOrNull(agent,
|
|
49983
|
+
if (agent !== "claude-code" && agent !== "vscode") return pass2("D5b");
|
|
49984
|
+
const claude = parsedOrNull(agent, join13(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
|
|
49608
49985
|
const hooks = isObject4(claude) ? claude[HOOKS_KEY] : void 0;
|
|
49609
49986
|
const hooksOn = isObject4(hooks) && Object.keys(hooks).length > 0;
|
|
49610
|
-
const vscode = parsedOrNull(agent,
|
|
49987
|
+
const vscode = parsedOrNull(agent, join13(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
|
|
49611
49988
|
const useClaudeHooks = isObject4(vscode) && vscode[VSCODE_CLAUDE_HOOKS_SETTING] === true;
|
|
49612
|
-
return hooksOn && useClaudeHooks ?
|
|
49989
|
+
return hooksOn && useClaudeHooks ? fail2("D5b", D5B_DETAIL, D5B_FIX) : pass2("D5b");
|
|
49613
49990
|
}
|
|
49614
49991
|
function configPaths(row5, env, worktree) {
|
|
49615
49992
|
const home = homeDirOf(env);
|
|
@@ -49618,7 +49995,7 @@ function configPaths(row5, env, worktree) {
|
|
|
49618
49995
|
const mcp = mcpFile(row5, home, env);
|
|
49619
49996
|
if (mcp !== null) out.push({ label: "MCP entry", path: mcp });
|
|
49620
49997
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
49621
|
-
if (native !== null) out.push({ label: "Codex plugin MCP", path:
|
|
49998
|
+
if (native !== null) out.push({ label: "Codex plugin MCP", path: join13(native, CODEX_PLUGIN_MCP_FILE) });
|
|
49622
49999
|
const spec = HOOK_HOST_FILE[row5.id];
|
|
49623
50000
|
if (spec !== null) {
|
|
49624
50001
|
try {
|
|
@@ -49638,10 +50015,10 @@ function configPaths(row5, env, worktree) {
|
|
|
49638
50015
|
}
|
|
49639
50016
|
|
|
49640
50017
|
// src/core/ops/doctor-db.ts
|
|
49641
|
-
import { existsSync as
|
|
49642
|
-
var
|
|
49643
|
-
var
|
|
49644
|
-
var
|
|
50018
|
+
import { existsSync as existsSync13, statSync as statSync4 } from "node:fs";
|
|
50019
|
+
var unknown5 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail });
|
|
50020
|
+
var pass3 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "PASS", detail });
|
|
50021
|
+
var fail3 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
|
|
49645
50022
|
function isCorrupt2(err) {
|
|
49646
50023
|
if (typeof err !== "object" || err === null) return false;
|
|
49647
50024
|
const code = err.errcode;
|
|
@@ -49680,17 +50057,17 @@ function orphanFiles(dbPath) {
|
|
|
49680
50057
|
const files = [];
|
|
49681
50058
|
for (const suffix of [DB_WAL_SUFFIX, DB_SHM_SUFFIX]) {
|
|
49682
50059
|
const path8 = dbPath + suffix;
|
|
49683
|
-
if (
|
|
50060
|
+
if (existsSync13(path8)) files.push({ path: path8, bytes: statSync4(path8).size });
|
|
49684
50061
|
}
|
|
49685
|
-
return files.length > 0 && !
|
|
50062
|
+
return files.length > 0 && !existsSync13(dbPath) ? files : [];
|
|
49686
50063
|
}
|
|
49687
50064
|
async function checkDb(project) {
|
|
49688
50065
|
const clean = { schemaStale: false, integrityFailed: false, orphan: [] };
|
|
49689
50066
|
const orphan = orphanFiles(project.dbPath);
|
|
49690
|
-
if (orphan.length > 0) return { row:
|
|
49691
|
-
if (!
|
|
50067
|
+
if (orphan.length > 0) return { row: fail3(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
|
|
50068
|
+
if (!existsSync13(project.dbPath)) return { row: pass3("D8", DOCTOR_PASS_DETAIL), ...clean };
|
|
49692
50069
|
const sqlite = await loadSqlite2();
|
|
49693
|
-
if (sqlite === null) return { row:
|
|
50070
|
+
if (sqlite === null) return { row: unknown5("D8", D2_SQLITE_DETAIL), ...clean };
|
|
49694
50071
|
let raw = null;
|
|
49695
50072
|
try {
|
|
49696
50073
|
raw = openRead(sqlite, project.dbPath);
|
|
@@ -49703,226 +50080,35 @@ async function checkDb(project) {
|
|
|
49703
50080
|
}
|
|
49704
50081
|
const schemaStale = got !== null && got !== SCHEMA_VERSION;
|
|
49705
50082
|
const integrityFailed = failsOnCorrupt(() => !integrityOk(db));
|
|
49706
|
-
if (integrityFailed) return { row:
|
|
49707
|
-
if (schemaStale && got !== null) return { row:
|
|
49708
|
-
return { row:
|
|
50083
|
+
if (integrityFailed) return { row: fail3(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale, integrityFailed, orphan: [] };
|
|
50084
|
+
if (schemaStale && got !== null) return { row: fail3(D8_STALE_SCHEMA_DETAIL(got, SCHEMA_VERSION), DOCTOR_FIX_UPGRADE), schemaStale, integrityFailed, orphan: [] };
|
|
50085
|
+
return { row: pass3("D8", DOCTOR_PASS_DETAIL), ...clean };
|
|
49709
50086
|
} catch (err) {
|
|
49710
|
-
if (isCorrupt2(err)) return { row:
|
|
49711
|
-
return { row:
|
|
50087
|
+
if (isCorrupt2(err)) return { row: fail3(D8_INTEGRITY_DETAIL, D8_INTEGRITY_FIX), schemaStale: false, integrityFailed: true, orphan: [] };
|
|
50088
|
+
return { row: unknown5("D8", message(err)), ...clean };
|
|
49712
50089
|
} finally {
|
|
49713
50090
|
raw?.close();
|
|
49714
50091
|
}
|
|
49715
50092
|
}
|
|
49716
50093
|
async function checkIndex(project) {
|
|
49717
|
-
if (!
|
|
50094
|
+
if (!existsSync13(project.dbPath)) return pass3("D9", D9_INDEX_DETAIL(0, 0));
|
|
49718
50095
|
const sqlite = await loadSqlite2();
|
|
49719
|
-
if (sqlite === null) return
|
|
50096
|
+
if (sqlite === null) return unknown5("D9", D2_SQLITE_DETAIL);
|
|
49720
50097
|
let raw = null;
|
|
49721
50098
|
try {
|
|
49722
50099
|
raw = openRead(sqlite, project.dbPath);
|
|
49723
50100
|
const sources = Number(cell(raw.prepare("SELECT count(*) FROM sources").get()));
|
|
49724
50101
|
const chunks = Number(cell(raw.prepare("SELECT count(*) FROM chunks").get()));
|
|
49725
|
-
return
|
|
50102
|
+
return pass3("D9", D9_INDEX_DETAIL(sources, chunks));
|
|
49726
50103
|
} catch (err) {
|
|
49727
|
-
return
|
|
50104
|
+
return unknown5("D9", message(err));
|
|
49728
50105
|
} finally {
|
|
49729
50106
|
raw?.close();
|
|
49730
50107
|
}
|
|
49731
50108
|
}
|
|
49732
50109
|
|
|
49733
|
-
// src/core/ops/doctor-env.ts
|
|
49734
|
-
import { existsSync as existsSync12, readFileSync as readFileSync10, realpathSync as realpathSync6 } from "node:fs";
|
|
49735
|
-
import { isAbsolute as isAbsolute4, join as join12, relative as relative2 } from "node:path";
|
|
49736
|
-
function pass3(id, detail = DOCTOR_PASS_DETAIL) {
|
|
49737
|
-
return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
|
|
49738
|
-
}
|
|
49739
|
-
function unknown5(id, detail, fixCommand) {
|
|
49740
|
-
return fixCommand === void 0 ? { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail } : { id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail, fixCommand };
|
|
49741
|
-
}
|
|
49742
|
-
function fail3(id, detail, fixCommand) {
|
|
49743
|
-
return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
|
|
49744
|
-
}
|
|
49745
|
-
function warn(id, detail, fixCommand) {
|
|
49746
|
-
return { id, label: DOCTOR_LABEL[id], status: "WARN", detail, fixCommand };
|
|
49747
|
-
}
|
|
49748
|
-
function bundleVersion(bundleDir2) {
|
|
49749
|
-
try {
|
|
49750
|
-
const v = JSON.parse(readFileSync10(join12(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
|
|
49751
|
-
return typeof v === "string" && v !== "" ? v : void 0;
|
|
49752
|
-
} catch {
|
|
49753
|
-
return void 0;
|
|
49754
|
-
}
|
|
49755
|
-
}
|
|
49756
|
-
function channelOf(version4) {
|
|
49757
|
-
const at = version4.indexOf(D1_PRERELEASE_SEP);
|
|
49758
|
-
if (at < 0) return D1_DEFAULT_TAG;
|
|
49759
|
-
const pre = version4.slice(at + 1);
|
|
49760
|
-
const dot = pre.indexOf(".");
|
|
49761
|
-
const tag = dot < 0 ? pre : pre.slice(0, dot);
|
|
49762
|
-
return tag === "" ? D1_DEFAULT_TAG : tag;
|
|
49763
|
-
}
|
|
49764
|
-
function firstLine2(b) {
|
|
49765
|
-
const text = b.toString("utf8").trim();
|
|
49766
|
-
const nl = text.indexOf("\n");
|
|
49767
|
-
return (nl < 0 ? text : text.slice(0, nl)).trim();
|
|
49768
|
-
}
|
|
49769
|
-
function gitCause(r, timeoutMs) {
|
|
49770
|
-
if (r.killed === "timeout") return D1_GIT_TIMEOUT(timeoutMs);
|
|
49771
|
-
if (r.killed === "cancel") return D1_GIT_CANCEL;
|
|
49772
|
-
if (r.exitCode === null) return D1_GIT_NO_START;
|
|
49773
|
-
return D1_GIT_EXIT(r.exitCode, firstLine2(r.stderr));
|
|
49774
|
-
}
|
|
49775
|
-
function fetchCause(err, timeoutMs) {
|
|
49776
|
-
const name = err instanceof Error ? err.name : "";
|
|
49777
|
-
if (name === "TimeoutError") return D1_NPM_TIMEOUT(timeoutMs);
|
|
49778
|
-
const cause = err instanceof Error && err.cause instanceof Error ? err.cause : err;
|
|
49779
|
-
const code = typeof cause === "object" && cause !== null && "code" in cause && typeof cause.code === "string" ? cause.code : "";
|
|
49780
|
-
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
49781
|
-
const parts = code !== "" && !msg.includes(code) ? [code, msg] : [msg];
|
|
49782
|
-
return D1_NPM_ERROR(parts.filter((part) => part !== "").join(" "));
|
|
49783
|
-
}
|
|
49784
|
-
async function npmLatest(url4, tag, signal, timeoutMs) {
|
|
49785
|
-
try {
|
|
49786
|
-
const res = await fetch(url4, { signal: AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) });
|
|
49787
|
-
if (!res.ok) return { ok: false, cause: D1_NPM_HTTP(res.status) };
|
|
49788
|
-
const body = await res.json();
|
|
49789
|
-
const v = typeof body === "object" && body !== null ? body[tag] : void 0;
|
|
49790
|
-
return typeof v === "string" && v !== "" ? { ok: true, version: v } : { ok: false, cause: D1_NPM_NO_TAG(tag) };
|
|
49791
|
-
} catch (err) {
|
|
49792
|
-
return { ok: false, cause: fetchCause(err, timeoutMs) };
|
|
49793
|
-
}
|
|
49794
|
-
}
|
|
49795
|
-
function digits(s) {
|
|
49796
|
-
if (s === "") return false;
|
|
49797
|
-
for (const ch of s) if (ch < "0" || ch > "9") return false;
|
|
49798
|
-
return true;
|
|
49799
|
-
}
|
|
49800
|
-
function parseVersion(v) {
|
|
49801
|
-
const at = v.indexOf(D1_PRERELEASE_SEP);
|
|
49802
|
-
const core = (at < 0 ? v : v.slice(0, at)).split(NODE_VERSION_SEP);
|
|
49803
|
-
if (core.length !== 3 || !core.every(digits)) return null;
|
|
49804
|
-
const nums = [Number(core[0]), Number(core[1]), Number(core[2])];
|
|
49805
|
-
if (at < 0) return { core: nums, pre: [] };
|
|
49806
|
-
const pre = v.slice(at + 1).split(NODE_VERSION_SEP);
|
|
49807
|
-
if (pre[0] === "" || digits(pre[0]) || pre.length > 2) return null;
|
|
49808
|
-
if (pre.length === 1) return { core: nums, pre: [pre[0]] };
|
|
49809
|
-
return digits(pre[1]) ? { core: nums, pre: [pre[0], Number(pre[1])] } : null;
|
|
49810
|
-
}
|
|
49811
|
-
function sign(n) {
|
|
49812
|
-
return n < 0 ? -1 : n > 0 ? 1 : 0;
|
|
49813
|
-
}
|
|
49814
|
-
function compareVersions(a, b) {
|
|
49815
|
-
const x = parseVersion(a);
|
|
49816
|
-
const y = parseVersion(b);
|
|
49817
|
-
if (x === null || y === null) return null;
|
|
49818
|
-
for (let k = 0; k < 3; k++) if (x.core[k] !== y.core[k]) return sign(x.core[k] - y.core[k]);
|
|
49819
|
-
if (x.pre.length === 0 || y.pre.length === 0) return sign(y.pre.length - x.pre.length);
|
|
49820
|
-
if (x.pre[0] !== y.pre[0]) return x.pre[0] < y.pre[0] ? -1 : 1;
|
|
49821
|
-
return sign((x.pre[1] ?? -1) - (y.pre[1] ?? -1));
|
|
49822
|
-
}
|
|
49823
|
-
function highestTag(stdout, tag) {
|
|
49824
|
-
let best;
|
|
49825
|
-
for (const line of stdout.split("\n")) {
|
|
49826
|
-
const [sha, ref] = line.trim().split(LS_REMOTE_FIELD_SEP);
|
|
49827
|
-
if (sha === void 0 || sha.length !== GIT_SHA_HEX_LEN || ref === void 0 || !ref.startsWith(RELEASE_TAG_REF_PREFIX)) continue;
|
|
49828
|
-
const v = ref.slice(RELEASE_TAG_REF_PREFIX.length);
|
|
49829
|
-
if (parseVersion(v) === null || channelOf(v) !== tag) continue;
|
|
49830
|
-
if (best === void 0 || compareVersions(v, best) === 1) best = v;
|
|
49831
|
-
}
|
|
49832
|
-
return best;
|
|
49833
|
-
}
|
|
49834
|
-
function versionRow(head, installed, tag, source, latest, tail, update) {
|
|
49835
|
-
const cmp = compareVersions(installed, latest) ?? (installed === latest ? 0 : -1);
|
|
49836
|
-
if (cmp === 0) return pass3("D1", head + D1_LATEST_PASS(tag, source) + tail);
|
|
49837
|
-
if (cmp > 0) return pass3("D1", head + D1_LATEST_AHEAD(tag, source, latest) + tail);
|
|
49838
|
-
return warn("D1", head + D1_LATEST_UPDATE(tag, source, latest) + tail, update);
|
|
49839
|
-
}
|
|
49840
|
-
async function checkVersion(i) {
|
|
49841
|
-
if (i.bundleSha === void 0) return unknown5("D1", D1_DEV_BUILD_DETAIL);
|
|
49842
|
-
const head = D1_PREFIX(i.version, i.bundleSha) + ": ";
|
|
49843
|
-
if (i.version === void 0) return unknown5("D1", head + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
|
|
49844
|
-
const tag = channelOf(i.version);
|
|
49845
|
-
const update = i.updateCommand ?? DOCTOR_FIX_UPGRADE;
|
|
49846
|
-
const git2 = findRuntime(GIT_BIN, i.env);
|
|
49847
|
-
const npm = await npmLatest(i.registryUrl, tag, i.signal, i.timeoutMs);
|
|
49848
|
-
if (npm.ok) return versionRow(head, i.version, tag, D1_SOURCE_NPM, npm.version, "", update);
|
|
49849
|
-
let cause = D1_GIT_MISSING;
|
|
49850
|
-
if (git2 !== null) {
|
|
49851
|
-
const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
|
|
49852
|
-
cwd: i.cwd,
|
|
49853
|
-
env: { ...i.env, ...GIT_NO_PROMPT_ENV },
|
|
49854
|
-
signal: i.signal,
|
|
49855
|
-
timeoutMs: i.timeoutMs
|
|
49856
|
-
});
|
|
49857
|
-
if (r.exitCode === 0 && r.killed === null) {
|
|
49858
|
-
const latest = highestTag(r.stdout.toString("utf8"), tag);
|
|
49859
|
-
if (latest !== void 0) return versionRow(head, i.version, tag, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause, update);
|
|
49860
|
-
cause = D1_GIT_NO_TAG(tag);
|
|
49861
|
-
} else {
|
|
49862
|
-
cause = gitCause(r, i.timeoutMs);
|
|
49863
|
-
}
|
|
49864
|
-
}
|
|
49865
|
-
return unknown5("D1", head + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause, git2 === null ? D1_NPM_CHECK_FIX : D1_GIT_CHECK_FIX);
|
|
49866
|
-
}
|
|
49867
|
-
function numbers(v) {
|
|
49868
|
-
const bare2 = v.startsWith(NODE_VERSION_PREFIX) ? v.slice(NODE_VERSION_PREFIX.length) : v;
|
|
49869
|
-
return bare2.split(NODE_VERSION_SEP).map(Number);
|
|
49870
|
-
}
|
|
49871
|
-
function belowMin(version4) {
|
|
49872
|
-
const got = numbers(version4);
|
|
49873
|
-
const min = numbers(NODE_MIN);
|
|
49874
|
-
for (let k = 0; k < min.length; k++) {
|
|
49875
|
-
const g = got[k] ?? 0;
|
|
49876
|
-
if (g !== min[k]) return g < min[k];
|
|
49877
|
-
}
|
|
49878
|
-
return false;
|
|
49879
|
-
}
|
|
49880
|
-
async function sqliteLoads() {
|
|
49881
|
-
try {
|
|
49882
|
-
await import(SQLITE_MODULE);
|
|
49883
|
-
return true;
|
|
49884
|
-
} catch {
|
|
49885
|
-
return false;
|
|
49886
|
-
}
|
|
49887
|
-
}
|
|
49888
|
-
async function checkNode(i) {
|
|
49889
|
-
const bun = i.bunVersion === void 0 ? [] : [D2_BUN_DETAIL(i.bunVersion)];
|
|
49890
|
-
const withBun = (detail) => [detail, ...bun].join(D4_REASON_JOIN);
|
|
49891
|
-
if (belowMin(i.nodeVersion)) return fail3("D2", withBun(D2_NODE_DETAIL(i.nodeVersion)), D2_NODE_FIX);
|
|
49892
|
-
if (!await sqliteLoads()) return fail3("D2", withBun(D2_SQLITE_DETAIL), D2_SQLITE_FIX);
|
|
49893
|
-
return pass3("D2", bun.length === 0 ? DOCTOR_PASS_DETAIL : bun.join(D4_REASON_JOIN));
|
|
49894
|
-
}
|
|
49895
|
-
function checkMcp(ctx, adapter) {
|
|
49896
|
-
const named2 = ctx.clientInfo !== void 0 && ctx.clientInfo.name !== "";
|
|
49897
|
-
const versioned = ctx.protocolVersion !== void 0 && ctx.protocolVersion !== "";
|
|
49898
|
-
if (named2 || versioned) return pass3("D6");
|
|
49899
|
-
return adapter?.installMode === "in-process" ? pass3("D6", D6_IN_PROCESS_DETAIL) : unknown5("D6", D6_UNKNOWN_DETAIL);
|
|
49900
|
-
}
|
|
49901
|
-
function piCwdInside(worktree, piCwd) {
|
|
49902
|
-
if (piCwd === void 0 || !existsSync12(piCwd)) return false;
|
|
49903
|
-
const rel = relative2(worktree, realpathSync6.native(piCwd));
|
|
49904
|
-
return rel === "" || !rel.startsWith("..") && !isAbsolute4(rel);
|
|
49905
|
-
}
|
|
49906
|
-
function checkProject(i) {
|
|
49907
|
-
const bad = fail3("D7", D7_DETAIL(i.project.source), D7_FIX);
|
|
49908
|
-
if (i.project.source !== i.adapter.projectSource) return bad;
|
|
49909
|
-
if (i.adapter.projectSource === "pi:ctx.cwd" && !piCwdInside(i.project.worktree, i.piCwd)) return bad;
|
|
49910
|
-
return pass3("D7");
|
|
49911
|
-
}
|
|
49912
|
-
function checkMode(adapter, hostPermission) {
|
|
49913
|
-
if (hostPermission === "missing") return fail3("D10", D10_PERMISSION_MISSING_DETAIL, D10_PERMISSION_FIX);
|
|
49914
|
-
if (hostPermission === "wired") return pass3("D10", D10_PERMISSION_DETAIL(adapter.denyChannel));
|
|
49915
|
-
return pass3("D10", D10_DETAIL(adapter.denyChannel));
|
|
49916
|
-
}
|
|
49917
|
-
function checkShell(env) {
|
|
49918
|
-
const win = process.platform === "win32";
|
|
49919
|
-
const shell = findRuntime("shell", env);
|
|
49920
|
-
if (shell !== null) return pass3("D11", D11_PASS_DETAIL(shell, win));
|
|
49921
|
-
return win ? fail3("D11", D11_WIN_DETAIL, D11_WIN_FIX) : fail3("D11", D11_POSIX_DETAIL, D11_POSIX_FIX);
|
|
49922
|
-
}
|
|
49923
|
-
|
|
49924
50110
|
// src/core/ops/doctor-hook.ts
|
|
49925
|
-
import { existsSync as
|
|
50111
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync5, mkdtempSync, readFileSync as readFileSync12, realpathSync as realpathSync8, rmSync as rmSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
49926
50112
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
49927
50113
|
import path7 from "node:path";
|
|
49928
50114
|
|
|
@@ -51666,7 +51852,9 @@ var HOST_SHAPES = {
|
|
|
51666
51852
|
kiro: kiro_default,
|
|
51667
51853
|
zcode: zcode_default,
|
|
51668
51854
|
pi: pi_default,
|
|
51669
|
-
opencode: opencode_default
|
|
51855
|
+
opencode: opencode_default,
|
|
51856
|
+
omp: pi_default
|
|
51857
|
+
// ADR-0026: OMP reads the Pi extension reply
|
|
51670
51858
|
};
|
|
51671
51859
|
var NOTE_KEYS = /* @__PURE__ */ new Set(["$schema", "title", "description", "definitions", "default"]);
|
|
51672
51860
|
var RULE_KEYS = /* @__PURE__ */ new Set(["type", "enum", "const", "required", "properties", "additionalProperties", "items", "allOf", "$ref"]);
|
|
@@ -51748,7 +51936,7 @@ function nodeLaunch(env, host = { bun: process.versions.bun, execPath: process.e
|
|
|
51748
51936
|
|
|
51749
51937
|
// src/setup/codex-trust.ts
|
|
51750
51938
|
import { createHash } from "node:crypto";
|
|
51751
|
-
import { existsSync as
|
|
51939
|
+
import { existsSync as existsSync14, realpathSync as realpathSync7 } from "node:fs";
|
|
51752
51940
|
import path6 from "node:path";
|
|
51753
51941
|
import { spawn as spawn3, spawnSync as spawnSync2 } from "node:child_process";
|
|
51754
51942
|
|
|
@@ -51971,10 +52159,10 @@ function isObject6(v) {
|
|
|
51971
52159
|
}
|
|
51972
52160
|
function loadFixture(bundleDir2, agent) {
|
|
51973
52161
|
const file2 = path7.join(bundleDir2, HOOK_FIXTURE_DIR, HOOK_FIXTURE_FILE);
|
|
51974
|
-
if (!
|
|
52162
|
+
if (!existsSync15(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
|
|
51975
52163
|
let all;
|
|
51976
52164
|
try {
|
|
51977
|
-
all = JSON.parse(hostText(
|
|
52165
|
+
all = JSON.parse(hostText(readFileSync12(file2, "utf8")));
|
|
51978
52166
|
} catch (err) {
|
|
51979
52167
|
return { cause: D5_FIXTURE_PARSE(file2, err instanceof Error ? err.message : String(err)) };
|
|
51980
52168
|
}
|
|
@@ -51996,7 +52184,8 @@ var CWD_KEY = {
|
|
|
51996
52184
|
kiro: "cwd",
|
|
51997
52185
|
zcode: "cwd",
|
|
51998
52186
|
pi: "cwd",
|
|
51999
|
-
opencode: "directory"
|
|
52187
|
+
opencode: "directory",
|
|
52188
|
+
omp: "cwd"
|
|
52000
52189
|
};
|
|
52001
52190
|
function payloadFor(agent, payload, worktree) {
|
|
52002
52191
|
return worktree !== void 0 && isObject6(payload) ? { ...payload, [CWD_KEY[agent]]: worktree } : payload;
|
|
@@ -52188,7 +52377,7 @@ async function codexStopDetail(i, timeoutMs) {
|
|
|
52188
52377
|
timeoutMs,
|
|
52189
52378
|
stdin: JSON.stringify(codexStopPayload(i.worktree ?? home))
|
|
52190
52379
|
});
|
|
52191
|
-
const logged =
|
|
52380
|
+
const logged = existsSync15(path7.join(home, HOOK_ERROR_LOG_FILE));
|
|
52192
52381
|
return !logged && isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, "Stop") ? null : D5_STOP_DETAIL;
|
|
52193
52382
|
} finally {
|
|
52194
52383
|
rmSync4(home, { recursive: true, force: true });
|
|
@@ -52199,7 +52388,7 @@ async function checkHookRoundTrip(i) {
|
|
|
52199
52388
|
const trust = await codexPluginTrust(i);
|
|
52200
52389
|
if (trust !== null) return trust;
|
|
52201
52390
|
}
|
|
52202
|
-
if (i.agent === "codex" &&
|
|
52391
|
+
if (i.agent === "codex" && existsSync15(path7.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
|
|
52203
52392
|
return row("UNKNOWN", D5_CODEX_UNTRUSTED_DETAIL);
|
|
52204
52393
|
}
|
|
52205
52394
|
const fixture = loadFixture(i.bundleDir, i.agent);
|
|
@@ -52215,10 +52404,13 @@ async function checkHookRoundTrip(i) {
|
|
|
52215
52404
|
await runProcess([node3.file, "-e", ""], { cwd: i.bundleDir, env: node3.env, signal: i.signal, timeoutMs });
|
|
52216
52405
|
return performance.now() - t;
|
|
52217
52406
|
});
|
|
52407
|
+
const inProcess = getAdapter(i.agent).installMode === "in-process";
|
|
52218
52408
|
const hookWalls = [];
|
|
52219
52409
|
const bareWalls = [];
|
|
52220
52410
|
let ms = 0;
|
|
52221
|
-
|
|
52411
|
+
let fastBare = 0;
|
|
52412
|
+
let bound = HOOK_P95_MS;
|
|
52413
|
+
for (let n = 1; n <= (inProcess ? 1 : maxPairs); n++) {
|
|
52222
52414
|
const start = now();
|
|
52223
52415
|
const node3 = nodeLaunch(i.env);
|
|
52224
52416
|
const r = await runProcess([node3.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
@@ -52230,25 +52422,29 @@ async function checkHookRoundTrip(i) {
|
|
|
52230
52422
|
});
|
|
52231
52423
|
hookWalls.push(now() - start);
|
|
52232
52424
|
if (!isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, fixture.event)) return row("FAIL", D5_SHAPE_DETAIL, D5_FIX);
|
|
52425
|
+
if (inProcess) return row("PASS", D5_IN_PROCESS_DETAIL);
|
|
52233
52426
|
bareWalls.push(await bareMs());
|
|
52234
|
-
|
|
52235
|
-
|
|
52427
|
+
fastBare = Math.round(Math.min(...bareWalls));
|
|
52428
|
+
ms = Math.max(0, Math.round(Math.min(...hookWalls)) - fastBare);
|
|
52429
|
+
bound = Math.max(HOOK_P95_MS, Math.round(D5_BARE_SHARE * fastBare));
|
|
52430
|
+
if (n >= minPairs && ms <= bound) break;
|
|
52236
52431
|
}
|
|
52237
|
-
if (ms >
|
|
52432
|
+
if (ms > bound) return row("FAIL", D5_SLOW_DETAIL(ms, bound), D5_FIX);
|
|
52238
52433
|
const readDetail = i.agent === "claude-code" ? await readProbeDetail(i, timeoutMs) : i.agent === "zcode" ? await mediaProbeDetail(i, timeoutMs) : i.agent === "codex" ? await codexStopDetail(i, timeoutMs) : null;
|
|
52239
52434
|
if (readDetail !== null) return row("FAIL", readDetail, D5_FIX);
|
|
52435
|
+
if (ms > HOOK_P95_MS) return row("PASS", D5_SLOW_START_DETAIL(ms, fastBare, bound));
|
|
52240
52436
|
return row("PASS", DOCTOR_PASS_DETAIL);
|
|
52241
52437
|
}
|
|
52242
52438
|
|
|
52243
52439
|
// src/core/hooks/fallback.ts
|
|
52244
|
-
import { join as
|
|
52440
|
+
import { join as join15, resolve as resolve7 } from "node:path";
|
|
52245
52441
|
|
|
52246
52442
|
// src/core/policy/read-media.ts
|
|
52247
52443
|
import { extname } from "node:path";
|
|
52248
52444
|
var { closeSync, openSync, readSync } = process.getBuiltinModule("node:fs");
|
|
52249
52445
|
|
|
52250
52446
|
// src/core/policy/own-file.ts
|
|
52251
|
-
import { extname as extname2, join as
|
|
52447
|
+
import { extname as extname2, join as join14, resolve as resolve6 } from "node:path";
|
|
52252
52448
|
|
|
52253
52449
|
// src/core/hooks/fallback.ts
|
|
52254
52450
|
var fs = process.getBuiltinModule("node:fs");
|
|
@@ -52257,9 +52453,9 @@ function homeOf(env) {
|
|
|
52257
52453
|
}
|
|
52258
52454
|
function hookLogPath(env) {
|
|
52259
52455
|
const dir = env[DATA_DIR_ENV];
|
|
52260
|
-
if (dir !== void 0 && dir !== "") return
|
|
52456
|
+
if (dir !== void 0 && dir !== "") return join15(dataRootOf(env, ""), HOOK_ERROR_LOG_FILE);
|
|
52261
52457
|
const home = homeOf(env);
|
|
52262
|
-
return home === "" ? "" :
|
|
52458
|
+
return home === "" ? "" : join15(dataRootOf(env, home), HOOK_ERROR_LOG_FILE);
|
|
52263
52459
|
}
|
|
52264
52460
|
function lastHookError(env) {
|
|
52265
52461
|
try {
|
|
@@ -52289,8 +52485,8 @@ function lastHookError(env) {
|
|
|
52289
52485
|
}
|
|
52290
52486
|
|
|
52291
52487
|
// src/core/ops/db-heal.ts
|
|
52292
|
-
import { existsSync as
|
|
52293
|
-
import { basename as basename4, dirname as dirname8, join as
|
|
52488
|
+
import { existsSync as existsSync16, mkdirSync as mkdirSync6, rmSync as rmSync5 } from "node:fs";
|
|
52489
|
+
import { basename as basename4, dirname as dirname8, join as join16 } from "node:path";
|
|
52294
52490
|
function integrityOk2(rows) {
|
|
52295
52491
|
return rows.length === 1 && rows[0].integrity_check === INTEGRITY_OK;
|
|
52296
52492
|
}
|
|
@@ -52324,7 +52520,7 @@ function renameAside(dbPath) {
|
|
|
52324
52520
|
const ts = String(Date.now());
|
|
52325
52521
|
for (const suffix of DB_SIBLING_SUFFIXES) {
|
|
52326
52522
|
const file2 = dbPath + suffix;
|
|
52327
|
-
if (
|
|
52523
|
+
if (existsSync16(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
|
|
52328
52524
|
}
|
|
52329
52525
|
return ts;
|
|
52330
52526
|
}
|
|
@@ -52347,7 +52543,7 @@ function utcStamp(now) {
|
|
|
52347
52543
|
return now.toISOString().slice(0, 19).replaceAll("-", "").replaceAll(":", "") + "Z";
|
|
52348
52544
|
}
|
|
52349
52545
|
function makeOrphanDir(projectDir) {
|
|
52350
|
-
const base =
|
|
52546
|
+
const base = join16(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
|
|
52351
52547
|
for (let n = 1; ; n += 1) {
|
|
52352
52548
|
const dir = n === 1 ? base : base + "-" + String(n);
|
|
52353
52549
|
try {
|
|
@@ -52364,7 +52560,7 @@ async function healOrphan(project, files, row5) {
|
|
|
52364
52560
|
try {
|
|
52365
52561
|
dir = makeOrphanDir(dirname8(project.dbPath));
|
|
52366
52562
|
for (const f of files) {
|
|
52367
|
-
const to =
|
|
52563
|
+
const to = join16(dir, basename4(f.path));
|
|
52368
52564
|
renameWithRetry(f.path, to);
|
|
52369
52565
|
moved.push({ path: to, bytes: f.bytes });
|
|
52370
52566
|
}
|
|
@@ -52462,8 +52658,8 @@ function unsupportedHostOf(sig) {
|
|
|
52462
52658
|
|
|
52463
52659
|
// src/core/ops/doctor-issue.ts
|
|
52464
52660
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
52465
|
-
import { closeSync as closeSync2, existsSync as
|
|
52466
|
-
import { delimiter, join as
|
|
52661
|
+
import { closeSync as closeSync2, existsSync as existsSync17, fstatSync, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as readFileSync13, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
|
|
52662
|
+
import { delimiter, dirname as dirname9, join as join17 } from "node:path";
|
|
52467
52663
|
var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
|
|
52468
52664
|
function tildeOf(env) {
|
|
52469
52665
|
const home = homeDirOf(env);
|
|
@@ -52486,13 +52682,28 @@ function maskLine(line) {
|
|
|
52486
52682
|
const at = Math.max(line.indexOf(":"), line.indexOf("="));
|
|
52487
52683
|
return at === -1 ? DOCTOR_MASK : line.slice(0, at + 1) + " " + DOCTOR_MASK;
|
|
52488
52684
|
}
|
|
52489
|
-
function
|
|
52685
|
+
async function runtimeInfo(env, signal, host = { bun: process.versions.bun, node: process.version }) {
|
|
52686
|
+
if (host.bun === void 0) return { node: host.node };
|
|
52687
|
+
const node3 = findRuntime("javascript", env);
|
|
52688
|
+
if (node3 === null) return { node: host.node, bun: host.bun, pathNode: null };
|
|
52689
|
+
const childEnv = {};
|
|
52690
|
+
for (const [k, v] of Object.entries(env)) if (v !== void 0) childEnv[k] = v;
|
|
52691
|
+
const r = await runProcess([node3, "--version"], { cwd: dirname9(node3), env: childEnv, signal, timeoutMs: DOCTOR_GIT_VERSION_TIMEOUT_MS });
|
|
52692
|
+
const out = r.stdout.toString("utf8").trim();
|
|
52693
|
+
return { node: host.node, bun: host.bun, pathNode: r.exitCode === 0 && out !== "" ? out : null };
|
|
52694
|
+
}
|
|
52695
|
+
function environmentLine(ctx, adapter, env, version4, rt) {
|
|
52490
52696
|
const sha = BUNDLE_SHA === void 0 ? "dev build" : BUNDLE_SHA.slice(0, 7);
|
|
52491
52697
|
const client = ctx.clientInfo;
|
|
52492
52698
|
const agent = client === void 0 ? adapter.id : client.name === adapter.id ? `${adapter.id} ${client.version}` : `${adapter.id} ${client.version} (client ${client.name})`;
|
|
52493
52699
|
const shell = env.SHELL ?? env.ComSpec ?? "sh";
|
|
52494
|
-
|
|
52495
|
-
|
|
52700
|
+
const what = `${DOCTOR_ENV_PREFIX}context-mode ${version4 ?? "source checkout"} (${sha}), agent ${agent}
|
|
52701
|
+
`;
|
|
52702
|
+
const os = `${DOCTOR_ENV_PREFIX}${process.platform}-${process.arch}`;
|
|
52703
|
+
if (rt.bun === void 0) return what + `${os}, Node ${rt.node}, shell ${shell}`;
|
|
52704
|
+
const pathNode = rt.pathNode === null || rt.pathNode === void 0 ? "ctx_execute node: none on PATH" : `ctx_execute node ${rt.pathNode} (PATH)`;
|
|
52705
|
+
return what + `${os}, host runtime Bun ${rt.bun} (node-compat ${rt.node})
|
|
52706
|
+
${DOCTOR_ENV_PREFIX}${pathNode}, shell ${shell}`;
|
|
52496
52707
|
}
|
|
52497
52708
|
function gitVersion(env) {
|
|
52498
52709
|
const r = spawnSync3("git", ["--version"], { env, encoding: "utf8", timeout: DOCTOR_GIT_VERSION_TIMEOUT_MS, windowsHide: true });
|
|
@@ -52504,8 +52715,8 @@ function onPath(env, tool) {
|
|
|
52504
52715
|
const out = [];
|
|
52505
52716
|
for (const dir of (envValue(env, "PATH") ?? "").split(delimiter)) {
|
|
52506
52717
|
if (dir === "") continue;
|
|
52507
|
-
for (const n of names) if (
|
|
52508
|
-
out.push(
|
|
52718
|
+
for (const n of names) if (existsSync17(join17(dir, n))) {
|
|
52719
|
+
out.push(join17(dir, n));
|
|
52509
52720
|
break;
|
|
52510
52721
|
}
|
|
52511
52722
|
}
|
|
@@ -52513,7 +52724,7 @@ function onPath(env, tool) {
|
|
|
52513
52724
|
}
|
|
52514
52725
|
function hookLogTail(env) {
|
|
52515
52726
|
const file2 = hookLogPath(env);
|
|
52516
|
-
if (file2 === "" || !
|
|
52727
|
+
if (file2 === "" || !existsSync17(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
|
|
52517
52728
|
try {
|
|
52518
52729
|
const fd = openSync2(file2, "r");
|
|
52519
52730
|
try {
|
|
@@ -52533,7 +52744,7 @@ function hookLogTail(env) {
|
|
|
52533
52744
|
}
|
|
52534
52745
|
async function journalRows(ctx) {
|
|
52535
52746
|
const head = ["| kind | tool | bytes | ok | exit_code | created_at |", "|---|---|---|---|---|---|"];
|
|
52536
|
-
if (!
|
|
52747
|
+
if (!existsSync17(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
|
|
52537
52748
|
try {
|
|
52538
52749
|
const db = await openDb(ctx.project, { readOnly: true });
|
|
52539
52750
|
try {
|
|
@@ -52551,21 +52762,21 @@ function agentConfig(adapter, env, worktree) {
|
|
|
52551
52762
|
const home = homeDirOf(env);
|
|
52552
52763
|
const files = configPaths(adapter, env, worktree);
|
|
52553
52764
|
if (home !== null) {
|
|
52554
|
-
if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path:
|
|
52555
|
-
if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path:
|
|
52765
|
+
if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join17(claudeDirOf(env, home), SETTINGS_FILE) });
|
|
52766
|
+
if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join17(codexDirOf(env, home), CONFIG_TOML_FILE) });
|
|
52556
52767
|
}
|
|
52557
52768
|
const out = [];
|
|
52558
52769
|
const seen = /* @__PURE__ */ new Set();
|
|
52559
52770
|
for (const f of files) {
|
|
52560
52771
|
if (seen.has(f.path)) continue;
|
|
52561
52772
|
seen.add(f.path);
|
|
52562
|
-
if (!
|
|
52773
|
+
if (!existsSync17(f.path)) {
|
|
52563
52774
|
out.push(`${f.label}: ${f.path} (absent)`);
|
|
52564
52775
|
continue;
|
|
52565
52776
|
}
|
|
52566
52777
|
let text = "";
|
|
52567
52778
|
try {
|
|
52568
|
-
text =
|
|
52779
|
+
text = readFileSync13(f.path, "utf8");
|
|
52569
52780
|
} catch (err) {
|
|
52570
52781
|
out.push(`${f.label}: ${f.path} (read: ${err instanceof Error ? err.message : String(err)})`);
|
|
52571
52782
|
continue;
|
|
@@ -52636,9 +52847,9 @@ async function buildIssueBody(i) {
|
|
|
52636
52847
|
async function writeIssueReport(i) {
|
|
52637
52848
|
const tilde = tildeOf(i.env);
|
|
52638
52849
|
const body = await buildIssueBody(i);
|
|
52639
|
-
const dir =
|
|
52850
|
+
const dir = join17(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
|
|
52640
52851
|
mkdirSync7(dir, { recursive: true });
|
|
52641
|
-
const file2 =
|
|
52852
|
+
const file2 = join17(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
|
|
52642
52853
|
writeFileSync4(file2, body);
|
|
52643
52854
|
const shown2 = tilde(file2);
|
|
52644
52855
|
const title = issueTitle(i.adapter.id, i.rows, i.unsupported);
|
|
@@ -52684,7 +52895,7 @@ async function guard(id, run) {
|
|
|
52684
52895
|
}
|
|
52685
52896
|
}
|
|
52686
52897
|
async function codexDb(ctx, adapter) {
|
|
52687
|
-
if (adapter.id !== "codex" || !
|
|
52898
|
+
if (adapter.id !== "codex" || !existsSync18(ctx.project.dbPath)) return null;
|
|
52688
52899
|
try {
|
|
52689
52900
|
return await openDb(ctx.project, { readOnly: true });
|
|
52690
52901
|
} catch {
|
|
@@ -52720,11 +52931,11 @@ async function hookRow(ctx, adapter, host) {
|
|
|
52720
52931
|
}
|
|
52721
52932
|
}
|
|
52722
52933
|
function ownServerId(configDir, projectKey) {
|
|
52723
|
-
const dir =
|
|
52724
|
-
if (!
|
|
52934
|
+
const dir = join18(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
52935
|
+
if (!existsSync18(dir)) return "";
|
|
52725
52936
|
for (const name of readdirSync8(dir)) {
|
|
52726
52937
|
if (!name.endsWith(OWNER_PID_EXT)) continue;
|
|
52727
|
-
if (
|
|
52938
|
+
if (readFileSync14(join18(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
|
|
52728
52939
|
}
|
|
52729
52940
|
return "";
|
|
52730
52941
|
}
|
|
@@ -52754,7 +52965,7 @@ async function runDoctorChecks(ctx, adapter, host0) {
|
|
|
52754
52965
|
D9: () => checkIndex(project),
|
|
52755
52966
|
D10: () => checkMode(adapter, ctx.hostPermission),
|
|
52756
52967
|
// D-1331-OC-PERM-1
|
|
52757
|
-
D11: () => checkShell(env)
|
|
52968
|
+
D11: () => checkRuntimes(env, checkShell(env))
|
|
52758
52969
|
};
|
|
52759
52970
|
const rows = [];
|
|
52760
52971
|
for (const id of DOCTOR_CHECK_ORDER) rows.push(await guard(id, checks[id]));
|
|
@@ -52781,11 +52992,12 @@ function reportEnv(env) {
|
|
|
52781
52992
|
}
|
|
52782
52993
|
async function doctorReply(ctx, host) {
|
|
52783
52994
|
const adapter = getAdapter(ctx.project.agent);
|
|
52995
|
+
const runtime = runtimeInfo(host.env, ctx.signal);
|
|
52784
52996
|
const rows = await runDoctorChecks(ctx, adapter, host);
|
|
52785
52997
|
const failed = rows.some((r) => r.status === "FAIL");
|
|
52786
|
-
const command = adapter.id === "pi" ? failed ? NATIVE_INSTALL.pi[0] : PI_LIST_COMMAND : `context-mode ${failed ? "setup" : "doctor"} --agents ${adapter.id}`;
|
|
52998
|
+
const command = adapter.id === "pi" ? failed ? NATIVE_INSTALL.pi[0] : PI_LIST_COMMAND : adapter.id === "omp" ? ompCommand(rows, failed) : `context-mode ${failed ? "setup" : "doctor"} --agents ${adapter.id}`;
|
|
52787
52999
|
const input = { agent: adapter.id, rows, env: reportEnv(host.env), command };
|
|
52788
|
-
const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir));
|
|
53000
|
+
const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir), await runtime);
|
|
52789
53001
|
const table3 = buildReport(input);
|
|
52790
53002
|
let notes = [];
|
|
52791
53003
|
if (failed) {
|
|
@@ -52797,7 +53009,8 @@ async function doctorReply(ctx, host) {
|
|
|
52797
53009
|
}
|
|
52798
53010
|
const look = rows.find((r) => r.status === "FAIL") ?? rows.find((r) => r.status !== "PASS");
|
|
52799
53011
|
const docs = look === void 0 ? [] : [DOCTOR_DOCS_LABEL + DOCTOR_DOCS_LINK(look.id)];
|
|
52800
|
-
const
|
|
53012
|
+
const info = adapter.id === "omp" ? ompInfoLines(host.env, ctx.clientInfo?.version) : [];
|
|
53013
|
+
const whole2 = [envLine2, table3, ...docs, ...info, ...notes].join("\n");
|
|
52801
53014
|
const bytes5 = Buffer.byteLength(whole2, "utf8");
|
|
52802
53015
|
if (bytes5 <= REPORT_CAP) return { text: whole2, isError: false, sandboxBytes: bytes5 };
|
|
52803
53016
|
const db = await openDb(ctx.project);
|
|
@@ -52806,9 +53019,14 @@ async function doctorReply(ctx, host) {
|
|
|
52806
53019
|
} finally {
|
|
52807
53020
|
closeDb(db);
|
|
52808
53021
|
}
|
|
52809
|
-
const text = [envLine2, buildReportHead(input), ...docs, ...notes].join("\n");
|
|
53022
|
+
const text = [envLine2, buildReportHead(input), ...docs, ...info, ...notes].join("\n");
|
|
52810
53023
|
return { text, isError: false, sandboxBytes: bytes5 };
|
|
52811
53024
|
}
|
|
53025
|
+
function ompCommand(rows, failed) {
|
|
53026
|
+
if (!failed) return OMP_LIST_COMMAND;
|
|
53027
|
+
const d3 = rows.find((r) => r.id === "D3" && r.status === "FAIL");
|
|
53028
|
+
return d3?.fixCommand ?? NATIVE_INSTALL.omp[0];
|
|
53029
|
+
}
|
|
52812
53030
|
async function handler2(_input, ctx) {
|
|
52813
53031
|
return doctorReply(ctx, { env: process.env, bundleDir: ownBundleDir(), piCwd: ctx.piCwd });
|
|
52814
53032
|
}
|
|
@@ -52822,9 +53040,9 @@ var ctxDoctor = Object.freeze({
|
|
|
52822
53040
|
});
|
|
52823
53041
|
|
|
52824
53042
|
// src/core/tools/execute.ts
|
|
52825
|
-
import { existsSync as
|
|
53043
|
+
import { existsSync as existsSync19, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync5 } from "node:fs";
|
|
52826
53044
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
52827
|
-
import { dirname as
|
|
53045
|
+
import { dirname as dirname11, join as join19, parse as parse5, resolve as resolve8 } from "node:path";
|
|
52828
53046
|
|
|
52829
53047
|
// src/core/index/select.ts
|
|
52830
53048
|
var READ_CHUNKS = "SELECT ord, body FROM chunks WHERE source_id = ?";
|
|
@@ -52946,7 +53164,7 @@ function schemaLine(issue4) {
|
|
|
52946
53164
|
}
|
|
52947
53165
|
function fileError(given, abs, root) {
|
|
52948
53166
|
let dir = abs;
|
|
52949
|
-
while (!
|
|
53167
|
+
while (!existsSync19(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
|
|
52950
53168
|
if (isInside(root, dir)) return null;
|
|
52951
53169
|
return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
|
|
52952
53170
|
}
|
|
@@ -53015,7 +53233,12 @@ async function handler3(raw, ctx) {
|
|
|
53015
53233
|
if (bad !== null) return fail4(bad);
|
|
53016
53234
|
extra.CTX_FILE = abs;
|
|
53017
53235
|
}
|
|
53018
|
-
|
|
53236
|
+
let runtime;
|
|
53237
|
+
try {
|
|
53238
|
+
runtime = findRuntime(input.language);
|
|
53239
|
+
} catch {
|
|
53240
|
+
runtime = null;
|
|
53241
|
+
}
|
|
53019
53242
|
if (runtime === null) return fail4(noRuntimeError(input.language).toLine());
|
|
53020
53243
|
const env = buildChildEnv(process.env, extra);
|
|
53021
53244
|
const timeoutMs = input.timeoutMs ?? EXEC_TIMEOUT_MS;
|
|
@@ -53027,8 +53250,8 @@ async function handler3(raw, ctx) {
|
|
|
53027
53250
|
if (takesDashC(input.language, runtime)) {
|
|
53028
53251
|
argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
|
|
53029
53252
|
} else {
|
|
53030
|
-
tmpDir = mkdtempSync2(
|
|
53031
|
-
const file2 =
|
|
53253
|
+
tmpDir = mkdtempSync2(join19(tmpdir3(), TMP_PREFIX));
|
|
53254
|
+
const file2 = join19(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
|
|
53032
53255
|
writeFileSync5(file2, scriptText(input.language, input.code), "utf8");
|
|
53033
53256
|
argv = scriptArgv(input.language, runtime, file2);
|
|
53034
53257
|
}
|
|
@@ -53064,12 +53287,12 @@ var ctxExecute = {
|
|
|
53064
53287
|
};
|
|
53065
53288
|
|
|
53066
53289
|
// src/core/tools/index.ts
|
|
53067
|
-
import { existsSync as
|
|
53068
|
-
import { dirname as
|
|
53290
|
+
import { existsSync as existsSync20, readFileSync as readFileSync17, statSync as statSync7 } from "node:fs";
|
|
53291
|
+
import { dirname as dirname12, extname as extname3, join as join22, relative as relative3, resolve as resolve9 } from "node:path";
|
|
53069
53292
|
|
|
53070
53293
|
// src/core/index/walk.ts
|
|
53071
|
-
import { readdirSync as readdirSync9, readFileSync as
|
|
53072
|
-
import { join as
|
|
53294
|
+
import { readdirSync as readdirSync9, readFileSync as readFileSync15, realpathSync as realpathSync10, statSync as statSync6 } from "node:fs";
|
|
53295
|
+
import { join as join20 } from "node:path";
|
|
53073
53296
|
var GITIGNORE = ".gitignore";
|
|
53074
53297
|
var GIT_DIR = ".git";
|
|
53075
53298
|
function walkDir(root, containmentRoot) {
|
|
@@ -53078,7 +53301,7 @@ function walkDir(root, containmentRoot) {
|
|
|
53078
53301
|
const found = [];
|
|
53079
53302
|
visit(real3, [], [], containmentRoot, /* @__PURE__ */ new Set([real3]), found);
|
|
53080
53303
|
found.sort(compareFound);
|
|
53081
|
-
return found.map((f) => ({ absPath: f.absPath, relPath:
|
|
53304
|
+
return found.map((f) => ({ absPath: f.absPath, relPath: join20(...f.dir, f.name) }));
|
|
53082
53305
|
}
|
|
53083
53306
|
function visit(abs, rel, parent, contain, seen, found) {
|
|
53084
53307
|
let entries;
|
|
@@ -53087,10 +53310,10 @@ function visit(abs, rel, parent, contain, seen, found) {
|
|
|
53087
53310
|
} catch {
|
|
53088
53311
|
return;
|
|
53089
53312
|
}
|
|
53090
|
-
const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(
|
|
53313
|
+
const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join20(abs, GITIGNORE), rel)) : parent;
|
|
53091
53314
|
for (const e of entries) {
|
|
53092
53315
|
if (e.name === GIT_DIR) continue;
|
|
53093
|
-
const path8 =
|
|
53316
|
+
const path8 = join20(abs, e.name);
|
|
53094
53317
|
let isDir = e.isDirectory();
|
|
53095
53318
|
let isFile = e.isFile();
|
|
53096
53319
|
let target = path8;
|
|
@@ -53130,7 +53353,7 @@ function compareFound(a, b) {
|
|
|
53130
53353
|
function readRules(file2, base) {
|
|
53131
53354
|
let body;
|
|
53132
53355
|
try {
|
|
53133
|
-
body =
|
|
53356
|
+
body = readFileSync15(file2, "utf8");
|
|
53134
53357
|
} catch {
|
|
53135
53358
|
return [];
|
|
53136
53359
|
}
|
|
@@ -53213,10 +53436,12 @@ function globSeg(pat, name) {
|
|
|
53213
53436
|
}
|
|
53214
53437
|
|
|
53215
53438
|
// src/core/sandbox/fetch.ts
|
|
53439
|
+
import { readFileSync as readFileSync16 } from "node:fs";
|
|
53216
53440
|
import { lookup } from "node:dns/promises";
|
|
53217
53441
|
import http from "node:http";
|
|
53218
53442
|
import https from "node:https";
|
|
53219
53443
|
import { BlockList, isIP } from "node:net";
|
|
53444
|
+
import { join as join21 } from "node:path";
|
|
53220
53445
|
import { connect as tlsConnect } from "node:tls";
|
|
53221
53446
|
var PRIVATE_RANGES = [
|
|
53222
53447
|
["127.0.0.0", 8, "ipv4"],
|
|
@@ -53248,6 +53473,21 @@ for (const [net, prefix, type] of PRIVATE_RANGES) BLOCKED.addSubnet(net, prefix,
|
|
|
53248
53473
|
var STATUS_OK_FIRST = 200;
|
|
53249
53474
|
var STATUS_OK_END = 300;
|
|
53250
53475
|
var STATUS_REDIRECT = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
53476
|
+
var UA_HOME = "https://github.com/mksglu/context-mode";
|
|
53477
|
+
var UA_DEV_VERSION = "dev";
|
|
53478
|
+
var namedHeaders;
|
|
53479
|
+
function baseHeaders() {
|
|
53480
|
+
if (namedHeaders === void 0) {
|
|
53481
|
+
let version4 = UA_DEV_VERSION;
|
|
53482
|
+
try {
|
|
53483
|
+
const v = JSON.parse(readFileSync16(join21(ownBundleDir(), D1_PACKAGE_FILE), "utf8")).version;
|
|
53484
|
+
if (typeof v === "string" && v !== "") version4 = v;
|
|
53485
|
+
} catch {
|
|
53486
|
+
}
|
|
53487
|
+
namedHeaders = Object.freeze({ "user-agent": "context-mode/" + version4 + " (+" + UA_HOME + ")", accept: "*/*" });
|
|
53488
|
+
}
|
|
53489
|
+
return namedHeaders;
|
|
53490
|
+
}
|
|
53251
53491
|
function fail5(code) {
|
|
53252
53492
|
return new CtxError("FETCH_FAILED", { code });
|
|
53253
53493
|
}
|
|
@@ -53356,11 +53596,11 @@ function request(u, conn, proxy, signal) {
|
|
|
53356
53596
|
const onErr = (err) => reject(fail5(causeCode(err)));
|
|
53357
53597
|
if (proxy === void 0) {
|
|
53358
53598
|
const mod = u.protocol === "https:" ? https : http;
|
|
53359
|
-
const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { host: u.host } });
|
|
53599
|
+
const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { ...baseHeaders(), host: u.host } });
|
|
53360
53600
|
req.on("response", resolve10).on("error", onErr).end();
|
|
53361
53601
|
return;
|
|
53362
53602
|
}
|
|
53363
|
-
const proxyHeaders = proxy.auth === void 0 ? {} : { "proxy-authorization": proxy.auth };
|
|
53603
|
+
const proxyHeaders = proxy.auth === void 0 ? { ...baseHeaders() } : { ...baseHeaders(), "proxy-authorization": proxy.auth };
|
|
53364
53604
|
if (u.protocol === "http:") {
|
|
53365
53605
|
const req = http.request({ host: conn.address, port: conn.port, path: u.href, signal, headers: { host: u.host, ...proxyHeaders } });
|
|
53366
53606
|
req.on("response", resolve10).on("error", onErr).end();
|
|
@@ -53380,7 +53620,7 @@ function request(u, conn, proxy, signal) {
|
|
|
53380
53620
|
port,
|
|
53381
53621
|
path: path8,
|
|
53382
53622
|
signal,
|
|
53383
|
-
headers: { host: u.host },
|
|
53623
|
+
headers: { ...baseHeaders(), host: u.host },
|
|
53384
53624
|
createConnection: () => tlsConnect({ socket, host, servername: tlsName(host) })
|
|
53385
53625
|
});
|
|
53386
53626
|
req.on("response", resolve10).on("error", onErr).end();
|
|
@@ -53422,7 +53662,7 @@ async function safeFetch(url4, signal) {
|
|
|
53422
53662
|
}
|
|
53423
53663
|
if (status < STATUS_OK_FIRST || status >= STATUS_OK_END) {
|
|
53424
53664
|
res.resume();
|
|
53425
|
-
throw fail5(status);
|
|
53665
|
+
throw fail5(status + " from " + bare(current.hostname));
|
|
53426
53666
|
}
|
|
53427
53667
|
const body = await readBody(res);
|
|
53428
53668
|
const shown2 = new URL(current.href);
|
|
@@ -57258,14 +57498,14 @@ function kindOfType(contentType) {
|
|
|
57258
57498
|
}
|
|
57259
57499
|
function readUtf8(absPath) {
|
|
57260
57500
|
try {
|
|
57261
|
-
return utf8.decode(
|
|
57501
|
+
return utf8.decode(readFileSync17(absPath));
|
|
57262
57502
|
} catch {
|
|
57263
57503
|
return void 0;
|
|
57264
57504
|
}
|
|
57265
57505
|
}
|
|
57266
57506
|
function missingOrOutside(given, abs, root) {
|
|
57267
57507
|
let dir = abs;
|
|
57268
|
-
while (!
|
|
57508
|
+
while (!existsSync20(dir) && dirname12(dir) !== dir) dir = dirname12(dir);
|
|
57269
57509
|
if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
|
|
57270
57510
|
return new CtxError("OUTSIDE_ROOT", { p: given, root });
|
|
57271
57511
|
}
|
|
@@ -57276,7 +57516,7 @@ function pathItems(input, project) {
|
|
|
57276
57516
|
if (statSync7(abs).isDirectory()) {
|
|
57277
57517
|
return walkDir(abs, project.containmentRoot).map((f) => ({
|
|
57278
57518
|
sourceKind: "path",
|
|
57279
|
-
label: pathLabel(
|
|
57519
|
+
label: pathLabel(join22(base, f.relPath)),
|
|
57280
57520
|
kind: kindOfPath(f.relPath),
|
|
57281
57521
|
read: () => readUtf8(f.absPath)
|
|
57282
57522
|
}));
|
|
@@ -58076,8 +58316,8 @@ var ctxStats = Object.freeze({
|
|
|
58076
58316
|
});
|
|
58077
58317
|
|
|
58078
58318
|
// src/core/ops/host-write.ts
|
|
58079
|
-
import { copyFileSync, existsSync as
|
|
58080
|
-
import { dirname as
|
|
58319
|
+
import { copyFileSync, existsSync as existsSync21, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
|
|
58320
|
+
import { dirname as dirname13, join as join23 } from "node:path";
|
|
58081
58321
|
function defaultWrite(file2, text) {
|
|
58082
58322
|
writeFileSync6(file2, text, "utf8");
|
|
58083
58323
|
}
|
|
@@ -58086,17 +58326,20 @@ function hostConfigPath(agent, home, env) {
|
|
|
58086
58326
|
if (own4 !== void 0) return ownMcpFileOf(agent, own4.file, env, home);
|
|
58087
58327
|
switch (agent) {
|
|
58088
58328
|
case "opencode":
|
|
58089
|
-
return
|
|
58329
|
+
return join23(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
|
|
58090
58330
|
// D-WIN-OPENCODE-DIR-1
|
|
58091
58331
|
case "pi":
|
|
58092
|
-
return
|
|
58332
|
+
return join23(piAgentDirOf(env, home), SETTINGS_FILE);
|
|
58093
58333
|
case "gemini":
|
|
58094
|
-
return
|
|
58334
|
+
return join23(geminiDirOf(env, home), SETTINGS_FILE);
|
|
58095
58335
|
// D-R38-GEMINI-HOME-1
|
|
58096
58336
|
case "copilot-cli":
|
|
58097
58337
|
return null;
|
|
58338
|
+
case "omp":
|
|
58339
|
+
return null;
|
|
58340
|
+
// ADR-0026 decision 8 (D-OMP-UPGRADE-1): OMP loads the plugin from its own store; no MCP entry, nothing under ~/.pi
|
|
58098
58341
|
default:
|
|
58099
|
-
return
|
|
58342
|
+
return join23(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
|
|
58100
58343
|
}
|
|
58101
58344
|
}
|
|
58102
58345
|
function cell3(value) {
|
|
@@ -58108,8 +58351,8 @@ function toRow(file2, edit) {
|
|
|
58108
58351
|
function writeWithRollback(file2, text, write, atomic) {
|
|
58109
58352
|
const trash = file2 + UPGRADE_TRASH_SUFFIX;
|
|
58110
58353
|
const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
|
|
58111
|
-
const had =
|
|
58112
|
-
mkdirSync8(
|
|
58354
|
+
const had = existsSync21(file2);
|
|
58355
|
+
mkdirSync8(dirname13(file2), { recursive: true });
|
|
58113
58356
|
if (had) copyFileSync(file2, trash);
|
|
58114
58357
|
try {
|
|
58115
58358
|
write(tmp, text);
|
|
@@ -58138,7 +58381,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
58138
58381
|
if (requested === null) return [];
|
|
58139
58382
|
const current = readHostConfig(row5.id, requested);
|
|
58140
58383
|
const result = mergeOwnEntries(row5.id, current.text, current.format, row5);
|
|
58141
|
-
const exists =
|
|
58384
|
+
const exists = existsSync21(current.path);
|
|
58142
58385
|
if (exists && result.text === current.text) return [];
|
|
58143
58386
|
const text = result.text === "" && current.format !== "toml" ? JSON.stringify({}) : result.text;
|
|
58144
58387
|
writeWithRollback(current.path, current.layout === void 0 ? text : withLayout(text, current.layout), opts.write ?? defaultWrite, opts.atomic ?? {});
|
|
@@ -58146,15 +58389,15 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
58146
58389
|
}
|
|
58147
58390
|
|
|
58148
58391
|
// src/core/ops/uninstall.ts
|
|
58149
|
-
import { existsSync as
|
|
58150
|
-
import { join as
|
|
58392
|
+
import { existsSync as existsSync22, readdirSync as readdirSync10, rmSync as rmSync7, writeFileSync as writeFileSync7 } from "node:fs";
|
|
58393
|
+
import { join as join24 } from "node:path";
|
|
58151
58394
|
function row2(area, before, after) {
|
|
58152
58395
|
return { area, before, after };
|
|
58153
58396
|
}
|
|
58154
58397
|
function stopServers(configDir, projectKey) {
|
|
58155
58398
|
const stopped = listLiveOwners(configDir, projectKey);
|
|
58156
|
-
const dir =
|
|
58157
|
-
for (const serverId of stopped) writeFileSync7(
|
|
58399
|
+
const dir = join24(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
58400
|
+
for (const serverId of stopped) writeFileSync7(join24(dir, serverId + OWNER_STOP_EXT), "", "utf8");
|
|
58158
58401
|
return stopped.length === 0 ? { row: row2(UPGRADE_SERVER_AREA, "", UPGRADE_NOT_FOUND), stopped } : { row: row2(UPGRADE_SERVER_AREA, UPGRADE_SERVER_RUNNING, UPGRADE_SERVER_STOPPED), stopped };
|
|
58159
58402
|
}
|
|
58160
58403
|
function rootOrNull(adapter, env) {
|
|
@@ -58172,15 +58415,15 @@ function removeCache(adapter, env, configDir) {
|
|
|
58172
58415
|
const root = rootOrNull(adapter, env);
|
|
58173
58416
|
if (root === null) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
|
|
58174
58417
|
if (adapter.installMode === "marketplace") {
|
|
58175
|
-
const cache =
|
|
58418
|
+
const cache = join24(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
|
|
58176
58419
|
if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
|
|
58177
58420
|
}
|
|
58178
58421
|
rmSync7(root, { recursive: true, force: true });
|
|
58179
58422
|
return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
|
|
58180
58423
|
}
|
|
58181
58424
|
case "plugin": {
|
|
58182
|
-
const agentDir =
|
|
58183
|
-
if (!
|
|
58425
|
+
const agentDir = join24(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
|
|
58426
|
+
if (!existsSync22(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
|
|
58184
58427
|
rmSync7(agentDir, { recursive: true, force: true });
|
|
58185
58428
|
return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
|
|
58186
58429
|
}
|
|
@@ -58225,7 +58468,7 @@ function ownEntries2(agent, env) {
|
|
|
58225
58468
|
}
|
|
58226
58469
|
if (agent === "opencode") {
|
|
58227
58470
|
return [{
|
|
58228
|
-
file:
|
|
58471
|
+
file: join24(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
|
|
58229
58472
|
// D-WIN-OPENCODE-DIR-1
|
|
58230
58473
|
key: OPENCODE_PLUGIN_KEY,
|
|
58231
58474
|
shown: OPENCODE_PLUGIN_KEY,
|
|
@@ -58236,13 +58479,22 @@ function ownEntries2(agent, env) {
|
|
|
58236
58479
|
if (agent === "pi") {
|
|
58237
58480
|
const agentDir = piAgentDirOf(env, home);
|
|
58238
58481
|
return [{
|
|
58239
|
-
file:
|
|
58482
|
+
file: join24(agentDir, SETTINGS_FILE),
|
|
58240
58483
|
key: PI_PACKAGES_KEY,
|
|
58241
58484
|
shown: PI_PACKAGES_KEY,
|
|
58242
58485
|
has: (v) => Array.isArray(v) && v.some((x) => piSource2(x) === PI_GIT_PACKAGE),
|
|
58243
58486
|
drop: (v) => v.filter((x) => piSource2(x) !== PI_GIT_PACKAGE)
|
|
58244
58487
|
}];
|
|
58245
58488
|
}
|
|
58489
|
+
if (agent === "omp") {
|
|
58490
|
+
return [{
|
|
58491
|
+
file: ompImportFiles(home).mcp,
|
|
58492
|
+
key: OMP_DISABLED_SERVERS_KEY,
|
|
58493
|
+
shown: OMP_DISABLED_SERVERS_KEY,
|
|
58494
|
+
has: (v) => Array.isArray(v) && v.includes(SERVER_KEY),
|
|
58495
|
+
drop: (v) => v.filter((x) => x !== SERVER_KEY)
|
|
58496
|
+
}];
|
|
58497
|
+
}
|
|
58246
58498
|
return [];
|
|
58247
58499
|
}
|
|
58248
58500
|
function removeOwnEntries(agent, env) {
|
|
@@ -58258,12 +58510,12 @@ function removeOwnEntries(agent, env) {
|
|
|
58258
58510
|
return rows.length === 0 ? [row2(UPGRADE_CONFIG_AREA, "", UPGRADE_NOT_FOUND)] : rows;
|
|
58259
58511
|
}
|
|
58260
58512
|
function removeProjectData(configDir, projectKey) {
|
|
58261
|
-
const projects =
|
|
58262
|
-
const dir =
|
|
58263
|
-
if (!
|
|
58513
|
+
const projects = join24(configDir, PROJECTS_DIR_NAME);
|
|
58514
|
+
const dir = join24(projects, projectKey);
|
|
58515
|
+
if (!existsSync22(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
|
|
58264
58516
|
if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
|
|
58265
58517
|
for (const name of readdirSync10(dir)) {
|
|
58266
|
-
if (name !== OWNERS_DIR_NAME) rmSync7(
|
|
58518
|
+
if (name !== OWNERS_DIR_NAME) rmSync7(join24(dir, name), { recursive: true, force: true });
|
|
58267
58519
|
}
|
|
58268
58520
|
return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
|
|
58269
58521
|
}
|
|
@@ -58271,12 +58523,12 @@ function runUninstall(input) {
|
|
|
58271
58523
|
const configDir = resolveConfigDir(input.env);
|
|
58272
58524
|
const stop = stopServers(configDir, input.project.projectKey);
|
|
58273
58525
|
const rows = [stop.row, removeCache(input.adapter, input.env, configDir), ...removeOwnEntries(input.adapter.id, input.env)];
|
|
58274
|
-
rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA,
|
|
58526
|
+
rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join24(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
|
|
58275
58527
|
return { rows, stopped: stop.stopped };
|
|
58276
58528
|
}
|
|
58277
58529
|
|
|
58278
58530
|
// src/core/ops/v1-remove.ts
|
|
58279
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
58531
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync23, readFileSync as readFileSync18, rmSync as rmSync8 } from "node:fs";
|
|
58280
58532
|
var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
58281
58533
|
var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
|
|
58282
58534
|
var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
|
|
@@ -58288,7 +58540,7 @@ function moveAside(target, undo) {
|
|
|
58288
58540
|
}
|
|
58289
58541
|
function keepAside(target, undo) {
|
|
58290
58542
|
let aside = target + UPGRADE_ASIDE_SUFFIX;
|
|
58291
|
-
for (let n = 2;
|
|
58543
|
+
for (let n = 2; existsSync23(aside); n += 1) aside = target + UPGRADE_ASIDE_SUFFIX + "-" + n;
|
|
58292
58544
|
renameWithRetry(target, aside);
|
|
58293
58545
|
undo.push({ trash: aside, target, keep: true });
|
|
58294
58546
|
return aside;
|
|
@@ -58327,8 +58579,8 @@ function locate(doc, path8) {
|
|
|
58327
58579
|
return null;
|
|
58328
58580
|
}
|
|
58329
58581
|
function stripJsonEntries(agent, file2, findings, kept, undo) {
|
|
58330
|
-
const layout = hostLayout(
|
|
58331
|
-
const text = hostText(
|
|
58582
|
+
const layout = hostLayout(readFileSync18(file2, "utf8"));
|
|
58583
|
+
const text = hostText(readFileSync18(file2, "utf8"));
|
|
58332
58584
|
const doc = parseHostConfig(agent, file2, text, "jsonc");
|
|
58333
58585
|
const hit = /* @__PURE__ */ new Set();
|
|
58334
58586
|
const byContainer = /* @__PURE__ */ new Map();
|
|
@@ -58365,20 +58617,20 @@ function removeV1(agent, findings, project) {
|
|
|
58365
58617
|
if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
|
|
58366
58618
|
else if (f.path === "") {
|
|
58367
58619
|
if (project !== void 0 && reachedThroughLink(project, f.file)) done.set(f, UPGRADE_REPORT_ONLY);
|
|
58368
|
-
else if (
|
|
58369
|
-
else if (
|
|
58620
|
+
else if (existsSync23(f.file) && UPGRADE_KEEP_ASIDE_REASONS.includes(f.reason)) done.set(f, UPGRADE_MOVED_ASIDE + keepAside(f.file, undo));
|
|
58621
|
+
else if (existsSync23(f.file)) {
|
|
58370
58622
|
moveAside(f.file, undo);
|
|
58371
58623
|
done.set(f, UPGRADE_REMOVED);
|
|
58372
58624
|
} else done.set(f, UPGRADE_NOT_FOUND);
|
|
58373
58625
|
} else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
|
|
58374
58626
|
}
|
|
58375
58627
|
for (const [file2, list3] of entries) {
|
|
58376
|
-
if (!
|
|
58628
|
+
if (!existsSync23(file2)) {
|
|
58377
58629
|
for (const f of list3) done.set(f, UPGRADE_NOT_FOUND);
|
|
58378
58630
|
continue;
|
|
58379
58631
|
}
|
|
58380
58632
|
if (file2.endsWith(TOML_EXT)) {
|
|
58381
|
-
const rawToml =
|
|
58633
|
+
const rawToml = readFileSync18(file2, "utf8");
|
|
58382
58634
|
const tomlLayout = hostLayout(rawToml);
|
|
58383
58635
|
let text = hostText(rawToml);
|
|
58384
58636
|
for (const f of list3) {
|
|
@@ -58406,7 +58658,7 @@ function removeV1(agent, findings, project) {
|
|
|
58406
58658
|
},
|
|
58407
58659
|
rollback() {
|
|
58408
58660
|
for (const u of undo.splice(0).reverse()) {
|
|
58409
|
-
if (!
|
|
58661
|
+
if (!existsSync23(u.trash)) continue;
|
|
58410
58662
|
rmSync8(u.target, { recursive: true, force: true });
|
|
58411
58663
|
renameWithRetry(u.trash, u.target);
|
|
58412
58664
|
}
|
|
@@ -58643,7 +58895,7 @@ function workspaceCwdOf(meta3, spawnCwd, script) {
|
|
|
58643
58895
|
const fromHost = workspaceFromMeta(meta3);
|
|
58644
58896
|
if (fromHost !== void 0) return fromHost;
|
|
58645
58897
|
if (script === void 0 || script === "") return spawnCwd;
|
|
58646
|
-
return realOrSame(spawnCwd) === realOrSame(
|
|
58898
|
+
return realOrSame(spawnCwd) === realOrSame(dirname14(script)) ? "" : spawnCwd;
|
|
58647
58899
|
}
|
|
58648
58900
|
function errorReply(err) {
|
|
58649
58901
|
if (err instanceof CtxError) return { text: err.toLine(), isError: true, sandboxBytes: 0 };
|
|
@@ -58682,15 +58934,15 @@ async function startServer(argv, env) {
|
|
|
58682
58934
|
opening.catch(() => pending.delete(project.dbPath));
|
|
58683
58935
|
}
|
|
58684
58936
|
const db = await opening;
|
|
58685
|
-
if (!
|
|
58937
|
+
if (!existsSync24(db.path)) throw new CtxError("DB_GONE");
|
|
58686
58938
|
return db;
|
|
58687
58939
|
}
|
|
58688
58940
|
function stopMarker(configDir, projectKey) {
|
|
58689
|
-
return
|
|
58941
|
+
return join25(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
|
|
58690
58942
|
}
|
|
58691
58943
|
function stopRequested() {
|
|
58692
58944
|
const configDir = resolveConfigDir(process.env);
|
|
58693
|
-
return held.some((db) =>
|
|
58945
|
+
return held.some((db) => existsSync24(stopMarker(configDir, db.projectKey)));
|
|
58694
58946
|
}
|
|
58695
58947
|
async function journal(project, ctx, name, reply4) {
|
|
58696
58948
|
const db = await ownDb(project);
|