context-mode 2.1.6 → 2.1.7
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 +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.zcode-plugin/plugin.json +1 -1
- package/README.md +72 -72
- package/SHA256SUMS +16 -16
- package/cli.mjs +238 -61
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +98 -98
- package/opencode/plugin.js +253 -64
- package/package.json +1 -1
- package/pi/index.js +262 -73
- package/qwen-extension.json +1 -1
- package/run.mjs +130 -7
- package/search.mjs +130 -7
- package/server.mjs +283 -94
package/server.mjs
CHANGED
|
@@ -8,7 +8,7 @@ var __export = (target, all) => {
|
|
|
8
8
|
// src/entries/server.ts
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
10
|
import { existsSync as existsSync23, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
|
|
11
|
-
import { dirname as
|
|
11
|
+
import { dirname as dirname13, join as join23 } 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
|
|
@@ -17605,7 +17605,7 @@ var PROPERTY_KEYS_BY_TYPE = {
|
|
|
17605
17605
|
array: shapeKeys([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema])
|
|
17606
17606
|
};
|
|
17607
17607
|
var SUPPORTED_STRING_FORMATS = new Set(StringSchemaSchema.shape.format.unwrap().options);
|
|
17608
|
-
function walkProperty(node3, path8, vendor,
|
|
17608
|
+
function walkProperty(node3, path8, vendor, unsupported2) {
|
|
17609
17609
|
if (!isJsonObject(node3)) return node3;
|
|
17610
17610
|
const allowedKeys = typeof node3.type === "string" && Object.hasOwn(PROPERTY_KEYS_BY_TYPE, node3.type) ? PROPERTY_KEYS_BY_TYPE[node3.type] : void 0;
|
|
17611
17611
|
if (allowedKeys === void 0) return node3;
|
|
@@ -17613,17 +17613,17 @@ function walkProperty(node3, path8, vendor, unsupported) {
|
|
|
17613
17613
|
for (const [key, value] of Object.entries(node3)) if (allowedKeys.has(key) || isAnnotationOnlyJsonSchemaKeyword(key)) pruned[key] = value;
|
|
17614
17614
|
else if (key === "pattern" && node3.type === "string" && typeof node3.format === "string") {
|
|
17615
17615
|
if (!SUPPORTED_STRING_FORMATS.has(node3.format)) pruned[key] = value;
|
|
17616
|
-
else if (typeof value !== "string" || !isLibraryFormatPattern(node3.format, value, vendor))
|
|
17617
|
-
} else
|
|
17616
|
+
else if (typeof value !== "string" || !isLibraryFormatPattern(node3.format, value, vendor)) unsupported2.push(`${path8}.${key}`);
|
|
17617
|
+
} else unsupported2.push(`${path8}.${key}`);
|
|
17618
17618
|
return pruned;
|
|
17619
17619
|
}
|
|
17620
17620
|
function walkRequestedSchema(converted, vendor) {
|
|
17621
17621
|
const pruned = {};
|
|
17622
|
-
const
|
|
17623
|
-
for (const [key, value] of Object.entries(converted)) if (key === "properties" && isJsonObject(value)) pruned[key] = Object.fromEntries(Object.entries(value).map(([name, node3]) => [name, walkProperty(node3, `properties.${name}`, vendor,
|
|
17622
|
+
const unsupported2 = [];
|
|
17623
|
+
for (const [key, value] of Object.entries(converted)) if (key === "properties" && isJsonObject(value)) pruned[key] = Object.fromEntries(Object.entries(value).map(([name, node3]) => [name, walkProperty(node3, `properties.${name}`, vendor, unsupported2)]));
|
|
17624
17624
|
else if (ROOT_KEYS.has(key)) pruned[key] = value;
|
|
17625
|
-
else if (!isAnnotationOnlyJsonSchemaKeyword(key))
|
|
17626
|
-
if (
|
|
17625
|
+
else if (!isAnnotationOnlyJsonSchemaKeyword(key)) unsupported2.push(key);
|
|
17626
|
+
if (unsupported2.length > 0) throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${unsupported2.join(", ")}`);
|
|
17627
17627
|
return pruned;
|
|
17628
17628
|
}
|
|
17629
17629
|
function describeUnsupportedProperties(pruned, fallback) {
|
|
@@ -28221,6 +28221,8 @@ var RRF_K = 60;
|
|
|
28221
28221
|
var SOURCE_HANDLE_MAX_DIGITS = 10;
|
|
28222
28222
|
var EXEC_TIMEOUT_MS = 6e5;
|
|
28223
28223
|
var KILL_GRACE_MS = 1e3;
|
|
28224
|
+
var PIPE_EOF_GRACE_MS = 250;
|
|
28225
|
+
var PIPE_DRAIN_MAX_MS = 2e3;
|
|
28224
28226
|
var DB_TIMEOUT_MS = 5e3;
|
|
28225
28227
|
var DB_WAL_SUFFIX = "-wal";
|
|
28226
28228
|
var DB_SHM_SUFFIX = "-shm";
|
|
@@ -28255,6 +28257,7 @@ var SHELL_FAMILY = Object.freeze(["sh", "bash", "zsh", "dash", "ksh", "fish"]);
|
|
|
28255
28257
|
var PATHEXT_DEFAULT = ".COM;.EXE;.BAT;.CMD";
|
|
28256
28258
|
var FETCH_MAX_HOPS = 5;
|
|
28257
28259
|
var SOURCE_LABEL_MAX_CHARS = 80;
|
|
28260
|
+
var BACKGROUND_HOLD_NOTE = "note: the command ended while a background process still held its output; that process was stopped, so output it would write later does not exist.";
|
|
28258
28261
|
var CANCELLED_LINE = "Cancelled.";
|
|
28259
28262
|
var BACKGROUND_REPLY_PREFIX = "started in background, pid ";
|
|
28260
28263
|
var PLAIN_OUTPUT_ENV = Object.freeze({ NO_COLOR: "1", FORCE_COLOR: "0" });
|
|
@@ -28443,7 +28446,7 @@ function PURGE_SUMMARY(rows, scope) {
|
|
|
28443
28446
|
var DECISION_SOURCE = "decision";
|
|
28444
28447
|
var DECISION_USER_LABEL = "decision (user)";
|
|
28445
28448
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
28446
|
-
var BUNDLE_SHA = true ? "
|
|
28449
|
+
var BUNDLE_SHA = true ? "5539b632975049a99de986448417a10bd246e506" : void 0;
|
|
28447
28450
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
28448
28451
|
var DOCTOR_LABEL = Object.freeze({
|
|
28449
28452
|
D1: "version",
|
|
@@ -28549,6 +28552,7 @@ var D5B_FIX = "disable chat.useClaudeHooks or the Claude Code hooks block";
|
|
|
28549
28552
|
var VSCODE_CLAUDE_HOOKS_SETTING = "chat.useClaudeHooks";
|
|
28550
28553
|
var VSCODE_SETTINGS_FILE = "settings.json";
|
|
28551
28554
|
var D6_UNKNOWN_DETAIL = "no clientInfo or protocolVersion on the request";
|
|
28555
|
+
var D6_IN_PROCESS_DETAIL = "in-process plugin: this call ran inside the agent, no MCP session to read";
|
|
28552
28556
|
function D7_DETAIL(got) {
|
|
28553
28557
|
return `resolved project source ${got} does not match the host's actual cwd`;
|
|
28554
28558
|
}
|
|
@@ -28664,6 +28668,90 @@ function D3_DETAIL(parts) {
|
|
|
28664
28668
|
function D3_ROOT_DETAIL(paths) {
|
|
28665
28669
|
return `pick one install for this project: ${paths.join(D3_PART_JOIN)}`;
|
|
28666
28670
|
}
|
|
28671
|
+
var unsupported = (h) => Object.freeze(h);
|
|
28672
|
+
var UNSUPPORTED_HOSTS = Object.freeze([
|
|
28673
|
+
unsupported({
|
|
28674
|
+
id: "antigravity",
|
|
28675
|
+
name: "Antigravity",
|
|
28676
|
+
clientNames: ["antigravity", "antigravity-client", "antigravity-cli", "agy"],
|
|
28677
|
+
envVars: ["ANTIGRAVITY_CLI_ALIAS"],
|
|
28678
|
+
pluginPaths: [[".gemini", "config", "plugins"], [".gemini", "antigravity", "plugins"], [".gemini", "antigravity-cli", "plugins"], [".gemini", "antigravity-ide", "plugins"]],
|
|
28679
|
+
configDirs: [".gemini/antigravity", ".gemini/antigravity-cli", ".gemini/config"],
|
|
28680
|
+
binaries: ["agy"],
|
|
28681
|
+
source: "v1.0.169:src/adapters/client-map.ts:15-17; detect.ts:156,481-483; #1340"
|
|
28682
|
+
}),
|
|
28683
|
+
unsupported({
|
|
28684
|
+
id: "cursor",
|
|
28685
|
+
name: "Cursor",
|
|
28686
|
+
clientNames: ["cursor-vscode"],
|
|
28687
|
+
envVars: ["CURSOR_TRACE_ID", "CURSOR_CLI", "CURSOR_CWD"],
|
|
28688
|
+
pluginPaths: [],
|
|
28689
|
+
configDirs: [".cursor"],
|
|
28690
|
+
binaries: [],
|
|
28691
|
+
source: "v1.0.169:src/adapters/client-map.ts:18; detect.ts:163-165,584"
|
|
28692
|
+
}),
|
|
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
|
+
unsupported({
|
|
28704
|
+
id: "openclaw",
|
|
28705
|
+
name: "OpenClaw",
|
|
28706
|
+
clientNames: [],
|
|
28707
|
+
envVars: [],
|
|
28708
|
+
pluginPaths: [],
|
|
28709
|
+
configDirs: [".openclaw"],
|
|
28710
|
+
binaries: [],
|
|
28711
|
+
source: "v1.0.169:src/adapters/detect.ts:252,575 (the runtime sets no env var)"
|
|
28712
|
+
}),
|
|
28713
|
+
unsupported({
|
|
28714
|
+
id: "kimi",
|
|
28715
|
+
name: "Kimi Code",
|
|
28716
|
+
clientNames: ["kimi-code", "kimi"],
|
|
28717
|
+
envVars: [],
|
|
28718
|
+
pluginPaths: [],
|
|
28719
|
+
configDirs: [".kimi-code"],
|
|
28720
|
+
binaries: ["kimi"],
|
|
28721
|
+
source: "v1.0.169:src/adapters/client-map.ts:42-44; detect.ts:567; adapters/kimi/index.ts:127"
|
|
28722
|
+
}),
|
|
28723
|
+
unsupported({
|
|
28724
|
+
id: "kilo",
|
|
28725
|
+
name: "Kilo Code",
|
|
28726
|
+
clientNames: ["kilo code"],
|
|
28727
|
+
envVars: ["KILO", "KILO_PID"],
|
|
28728
|
+
pluginPaths: [],
|
|
28729
|
+
configDirs: [".config/kilo"],
|
|
28730
|
+
binaries: [],
|
|
28731
|
+
source: "v1.0.169:src/adapters/client-map.ts:28; detect.ts:170-171,592"
|
|
28732
|
+
}),
|
|
28733
|
+
unsupported({
|
|
28734
|
+
id: "zed",
|
|
28735
|
+
name: "Zed",
|
|
28736
|
+
clientNames: ["zed"],
|
|
28737
|
+
envVars: ["ZED_SESSION_ID", "ZED_TERM"],
|
|
28738
|
+
pluginPaths: [],
|
|
28739
|
+
configDirs: [".config/zed"],
|
|
28740
|
+
binaries: [],
|
|
28741
|
+
source: "v1.0.169:src/adapters/client-map.ts:38-39; detect.ts:189-190,616"
|
|
28742
|
+
}),
|
|
28743
|
+
unsupported({
|
|
28744
|
+
id: "jetbrains-copilot",
|
|
28745
|
+
name: "JetBrains Copilot",
|
|
28746
|
+
clientNames: ["jetbrains client", "intellij idea", "pycharm"],
|
|
28747
|
+
envVars: ["IDEA_INITIAL_DIRECTORY"],
|
|
28748
|
+
pluginPaths: [],
|
|
28749
|
+
configDirs: [".config/JetBrains"],
|
|
28750
|
+
binaries: [],
|
|
28751
|
+
source: "v1.0.169:src/adapters/client-map.ts:23-25; detect.ts:213,600"
|
|
28752
|
+
})
|
|
28753
|
+
]);
|
|
28754
|
+
var SUPPORTED_AGENTS_DOCS_URL = "https://github.com/mksglu/context-mode/blob/main/docs/install/README.md";
|
|
28667
28755
|
var D3_ROOT_FIX_JOIN = " or ";
|
|
28668
28756
|
function D3_ROOT_FIX(installs) {
|
|
28669
28757
|
return `remove the extra install: ${installs.map((i) => `claude plugin uninstall ${i.key} --scope ${i.scope}`).join(D3_ROOT_FIX_JOIN)}`;
|
|
@@ -29521,6 +29609,17 @@ function claudeDirOf(env, home) {
|
|
|
29521
29609
|
const dir = env[CLAUDE_CONFIG_DIR_ENV];
|
|
29522
29610
|
return dir !== void 0 && dir !== "" ? dir : join(home, ...AGENT_HOME_DIR["claude-code"]);
|
|
29523
29611
|
}
|
|
29612
|
+
function claudeProfileEnv(env, platform = process.platform) {
|
|
29613
|
+
const dir = env[CLAUDE_CONFIG_DIR_ENV];
|
|
29614
|
+
if (dir === void 0 || dir === "" || platform === "win32") return "";
|
|
29615
|
+
return `${CLAUDE_CONFIG_DIR_ENV}='${dir.split("'").join(`'"'"'`)}' `;
|
|
29616
|
+
}
|
|
29617
|
+
function hostUpdateCommand(agent, env, platform = process.platform) {
|
|
29618
|
+
const cmd = UPGRADE_HOST_COMMAND[agent];
|
|
29619
|
+
if (agent !== "claude-code") return cmd;
|
|
29620
|
+
const profile = claudeProfileEnv(env, platform);
|
|
29621
|
+
return profile === "" ? cmd : cmd.split(" && ").map((c) => profile + c).join(" && ");
|
|
29622
|
+
}
|
|
29524
29623
|
function opencodeDirOf(env, home) {
|
|
29525
29624
|
const own4 = env[OPENCODE_CONFIG_DIR_ENV];
|
|
29526
29625
|
if (own4 !== void 0 && own4 !== "") return own4;
|
|
@@ -44177,11 +44276,11 @@ function noRuntimeError(lang) {
|
|
|
44177
44276
|
}
|
|
44178
44277
|
|
|
44179
44278
|
// src/core/sandbox/spawn.ts
|
|
44180
|
-
import { spawn } from "node:child_process";
|
|
44279
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
44181
44280
|
import path2 from "node:path";
|
|
44182
44281
|
|
|
44183
44282
|
// src/core/sandbox/kill.ts
|
|
44184
|
-
import {
|
|
44283
|
+
import { spawn } from "node:child_process";
|
|
44185
44284
|
function signalGroup(pid, signal) {
|
|
44186
44285
|
try {
|
|
44187
44286
|
process.kill(-pid, signal);
|
|
@@ -44195,7 +44294,10 @@ function killTree(pid) {
|
|
|
44195
44294
|
return;
|
|
44196
44295
|
}
|
|
44197
44296
|
try {
|
|
44198
|
-
|
|
44297
|
+
const t = spawn("taskkill", ["/F", "/T", "/PID", String(pid)], { stdio: "ignore", windowsHide: true });
|
|
44298
|
+
t.on("error", () => {
|
|
44299
|
+
});
|
|
44300
|
+
t.unref();
|
|
44199
44301
|
} catch {
|
|
44200
44302
|
}
|
|
44201
44303
|
}
|
|
@@ -44214,7 +44316,7 @@ function runProcess(argv, o) {
|
|
|
44214
44316
|
if (start === null) return resolve7(NOT_STARTED);
|
|
44215
44317
|
let child;
|
|
44216
44318
|
try {
|
|
44217
|
-
child =
|
|
44319
|
+
child = spawn2(start[0], start.slice(1), {
|
|
44218
44320
|
cwd: o.cwd,
|
|
44219
44321
|
env: o.env,
|
|
44220
44322
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -44231,8 +44333,14 @@ function runProcess(argv, o) {
|
|
|
44231
44333
|
const stderrChunks = [];
|
|
44232
44334
|
let killedBy = null;
|
|
44233
44335
|
let settled = false;
|
|
44336
|
+
let held = false;
|
|
44337
|
+
let exited = false;
|
|
44338
|
+
let graceTimer;
|
|
44339
|
+
let drainTimer;
|
|
44340
|
+
let stopTimer;
|
|
44234
44341
|
const kill = () => {
|
|
44235
44342
|
if (child.pid !== void 0) killTree(child.pid);
|
|
44343
|
+
if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(), KILL_GRACE_MS);
|
|
44236
44344
|
};
|
|
44237
44345
|
const onAbort = () => {
|
|
44238
44346
|
if (killedBy !== null || settled) return;
|
|
@@ -44249,17 +44357,46 @@ function runProcess(argv, o) {
|
|
|
44249
44357
|
if (settled) return;
|
|
44250
44358
|
settled = true;
|
|
44251
44359
|
clearTimeout(timer);
|
|
44360
|
+
clearTimeout(graceTimer);
|
|
44361
|
+
clearTimeout(drainTimer);
|
|
44362
|
+
clearTimeout(stopTimer);
|
|
44252
44363
|
o.signal.removeEventListener("abort", onAbort);
|
|
44253
44364
|
resolve7({
|
|
44254
44365
|
stdout: Buffer.concat(stdoutChunks),
|
|
44255
44366
|
stderr: Buffer.concat(stderrChunks),
|
|
44256
44367
|
exitCode,
|
|
44257
|
-
killed: killedBy
|
|
44368
|
+
killed: killedBy,
|
|
44369
|
+
...held ? { held: true } : {}
|
|
44258
44370
|
});
|
|
44259
44371
|
};
|
|
44260
|
-
|
|
44261
|
-
|
|
44372
|
+
const finishHeld = () => {
|
|
44373
|
+
if (settled) return;
|
|
44374
|
+
held = exited && killedBy === null;
|
|
44375
|
+
child.stdout.destroy();
|
|
44376
|
+
child.stderr.destroy();
|
|
44377
|
+
if (child.pid !== void 0) killTree(child.pid);
|
|
44378
|
+
settle3(child.exitCode);
|
|
44379
|
+
};
|
|
44380
|
+
const bump = () => {
|
|
44381
|
+
if (!exited || settled) return;
|
|
44382
|
+
clearTimeout(graceTimer);
|
|
44383
|
+
graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
|
|
44384
|
+
};
|
|
44385
|
+
child.stdout.on("data", (chunk) => {
|
|
44386
|
+
stdoutChunks.push(chunk);
|
|
44387
|
+
bump();
|
|
44388
|
+
});
|
|
44389
|
+
child.stderr.on("data", (chunk) => {
|
|
44390
|
+
stderrChunks.push(chunk);
|
|
44391
|
+
bump();
|
|
44392
|
+
});
|
|
44262
44393
|
child.on("close", (code) => settle3(code));
|
|
44394
|
+
child.on("exit", () => {
|
|
44395
|
+
if (settled) return;
|
|
44396
|
+
exited = true;
|
|
44397
|
+
graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
|
|
44398
|
+
drainTimer = setTimeout(finishHeld, PIPE_DRAIN_MAX_MS);
|
|
44399
|
+
});
|
|
44263
44400
|
child.on("error", () => settle3(null));
|
|
44264
44401
|
child.stdin.on("error", () => {
|
|
44265
44402
|
});
|
|
@@ -44930,7 +45067,7 @@ var ctxBatch = Object.freeze({
|
|
|
44930
45067
|
});
|
|
44931
45068
|
|
|
44932
45069
|
// src/core/tools/doctor.ts
|
|
44933
|
-
import { readdirSync as readdirSync8, readFileSync as
|
|
45070
|
+
import { readdirSync as readdirSync8, readFileSync as readFileSync13, existsSync as existsSync17 } from "node:fs";
|
|
44934
45071
|
import { basename as basename5, join as join17 } from "node:path";
|
|
44935
45072
|
|
|
44936
45073
|
// src/adapters/claude-code.ts
|
|
@@ -45982,8 +46119,31 @@ function ownBundleDir() {
|
|
|
45982
46119
|
}
|
|
45983
46120
|
|
|
45984
46121
|
// src/core/ops/doctor-config.ts
|
|
45985
|
-
import { existsSync as existsSync10, readdirSync as readdirSync7 } from "node:fs";
|
|
45986
|
-
import { join as join11 } from "node:path";
|
|
46122
|
+
import { existsSync as existsSync10, readdirSync as readdirSync7, readFileSync as readFileSync9 } from "node:fs";
|
|
46123
|
+
import { dirname as dirname7, join as join11 } from "node:path";
|
|
46124
|
+
|
|
46125
|
+
// src/core/ops/host-text.ts
|
|
46126
|
+
var BOM_CODE = 65279;
|
|
46127
|
+
var CR_CODE = 13;
|
|
46128
|
+
var CRLF = "\r\n";
|
|
46129
|
+
var LF = "\n";
|
|
46130
|
+
function hostLayout(raw) {
|
|
46131
|
+
let crlf = 0;
|
|
46132
|
+
let lf = 0;
|
|
46133
|
+
for (let i = raw.indexOf(LF); i >= 0; i = raw.indexOf(LF, i + 1)) {
|
|
46134
|
+
if (i > 0 && raw.charCodeAt(i - 1) === CR_CODE) crlf += 1;
|
|
46135
|
+
else lf += 1;
|
|
46136
|
+
}
|
|
46137
|
+
return { bom: raw.length > 0 && raw.charCodeAt(0) === BOM_CODE, crlf: crlf > 0 && crlf >= lf };
|
|
46138
|
+
}
|
|
46139
|
+
function hostText(raw) {
|
|
46140
|
+
const bare2 = raw.length > 0 && raw.charCodeAt(0) === BOM_CODE ? raw.slice(1) : raw;
|
|
46141
|
+
return bare2.indexOf(CRLF) < 0 ? bare2 : bare2.split(CRLF).join(LF);
|
|
46142
|
+
}
|
|
46143
|
+
function withLayout(text, layout) {
|
|
46144
|
+
const eol = layout.crlf ? text.split(LF).join(CRLF) : text;
|
|
46145
|
+
return layout.bom ? String.fromCharCode(BOM_CODE) + eol : eol;
|
|
46146
|
+
}
|
|
45987
46147
|
|
|
45988
46148
|
// src/core/ops/detect-v1.ts
|
|
45989
46149
|
import { existsSync as existsSync7, opendirSync, readdirSync as readdirSync5, readFileSync as readFileSync6 } from "node:fs";
|
|
@@ -48100,29 +48260,6 @@ function atomicWriteFile(file2, text, opts = {}) {
|
|
|
48100
48260
|
}
|
|
48101
48261
|
}
|
|
48102
48262
|
|
|
48103
|
-
// src/core/ops/host-text.ts
|
|
48104
|
-
var BOM_CODE = 65279;
|
|
48105
|
-
var CR_CODE = 13;
|
|
48106
|
-
var CRLF = "\r\n";
|
|
48107
|
-
var LF = "\n";
|
|
48108
|
-
function hostLayout(raw) {
|
|
48109
|
-
let crlf = 0;
|
|
48110
|
-
let lf = 0;
|
|
48111
|
-
for (let i = raw.indexOf(LF); i >= 0; i = raw.indexOf(LF, i + 1)) {
|
|
48112
|
-
if (i > 0 && raw.charCodeAt(i - 1) === CR_CODE) crlf += 1;
|
|
48113
|
-
else lf += 1;
|
|
48114
|
-
}
|
|
48115
|
-
return { bom: raw.length > 0 && raw.charCodeAt(0) === BOM_CODE, crlf: crlf > 0 && crlf >= lf };
|
|
48116
|
-
}
|
|
48117
|
-
function hostText(raw) {
|
|
48118
|
-
const bare2 = raw.length > 0 && raw.charCodeAt(0) === BOM_CODE ? raw.slice(1) : raw;
|
|
48119
|
-
return bare2.indexOf(CRLF) < 0 ? bare2 : bare2.split(CRLF).join(LF);
|
|
48120
|
-
}
|
|
48121
|
-
function withLayout(text, layout) {
|
|
48122
|
-
const eol = layout.crlf ? text.split(LF).join(CRLF) : text;
|
|
48123
|
-
return layout.bom ? String.fromCharCode(BOM_CODE) + eol : eol;
|
|
48124
|
-
}
|
|
48125
|
-
|
|
48126
48263
|
// src/core/ops/host-config.ts
|
|
48127
48264
|
function formatOf(path8) {
|
|
48128
48265
|
if (path8.endsWith(JSONC_EXT)) return "jsonc";
|
|
@@ -49214,7 +49351,7 @@ function nativeMcpWrong(dir, row5) {
|
|
|
49214
49351
|
}
|
|
49215
49352
|
}
|
|
49216
49353
|
function isOwnOpencodeEntry(entry, key, own4) {
|
|
49217
|
-
const spec = isObject4(entry) ? entry[OPENCODE_PACKAGE_FIELD] : entry;
|
|
49354
|
+
const spec = isObject4(entry) ? entry[OPENCODE_PACKAGE_FIELD] : Array.isArray(entry) ? entry[0] : entry;
|
|
49218
49355
|
if (typeof spec !== "string") return false;
|
|
49219
49356
|
if (spec === OPENCODE_GIT_SPEC || spec.startsWith(OPENCODE_NPM_SPEC_PREFIX) || own4.includes(spec)) return true;
|
|
49220
49357
|
return key === OPENCODE_PLUGINS_KEY && spec === SERVER_KEY;
|
|
@@ -49225,14 +49362,21 @@ function opencodeMcpOwn(entry) {
|
|
|
49225
49362
|
const [node3, script, flag, agent] = cmd;
|
|
49226
49363
|
return isNodeCommand(node3) && typeof script === "string" && lastSegment(script) === SERVER_ENTRY_FILE && flag === AGENT_ARG && agent === "opencode";
|
|
49227
49364
|
}
|
|
49228
|
-
function
|
|
49229
|
-
|
|
49365
|
+
function opencodeFileValue(file2) {
|
|
49366
|
+
if (!existsSync10(file2)) return {};
|
|
49367
|
+
return parseHostConfig("opencode", file2, hostText(readFileSync9(file2, "utf8")), "jsonc");
|
|
49368
|
+
}
|
|
49369
|
+
function opencodeValueListed(value) {
|
|
49230
49370
|
const bundle = opencodePluginFile();
|
|
49231
49371
|
const own4 = [bundle, join11(bundle, ...OPENCODE_PLUGIN_PATH)];
|
|
49232
49372
|
if ([OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own4)))) return true;
|
|
49233
49373
|
const mcp = isObject4(value) && isObject4(value.mcp) ? value.mcp : {};
|
|
49234
49374
|
return opencodeMcpOwn(mcp[SERVER_KEY]) || isObject4(mcp.servers) && opencodeMcpOwn(mcp.servers[SERVER_KEY]);
|
|
49235
49375
|
}
|
|
49376
|
+
function opencodeListed(file2, worktree) {
|
|
49377
|
+
const dirs = [dirname7(file2), worktree];
|
|
49378
|
+
return dirs.some((dir) => OPENCODE_CONFIG_FILES.some((name) => opencodeValueListed(opencodeFileValue(join11(dir, name)))));
|
|
49379
|
+
}
|
|
49236
49380
|
function mcpWrong(row5, home, env, worktree) {
|
|
49237
49381
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
49238
49382
|
if (native !== null) return nativeMcpWrong(native, row5);
|
|
@@ -49242,7 +49386,7 @@ function mcpWrong(row5, home, env, worktree) {
|
|
|
49242
49386
|
resolvePluginRoot(row5, env, worktree);
|
|
49243
49387
|
return false;
|
|
49244
49388
|
}
|
|
49245
|
-
if (row5.id === "opencode") return !opencodeListed(file2);
|
|
49389
|
+
if (row5.id === "opencode") return !opencodeListed(file2, worktree);
|
|
49246
49390
|
const cur = readHostConfig(row5.id, file2);
|
|
49247
49391
|
return mergeOwnEntries(row5.id, cur.text, cur.format, row5, { nodePath: true, listEntries: [opencodePluginFile()] }).edits.length > 0;
|
|
49248
49392
|
} catch {
|
|
@@ -49453,7 +49597,7 @@ async function checkIndex(project) {
|
|
|
49453
49597
|
}
|
|
49454
49598
|
|
|
49455
49599
|
// src/core/ops/doctor-env.ts
|
|
49456
|
-
import { existsSync as existsSync12, readFileSync as
|
|
49600
|
+
import { existsSync as existsSync12, readFileSync as readFileSync10, realpathSync as realpathSync6 } from "node:fs";
|
|
49457
49601
|
import { isAbsolute as isAbsolute2, join as join12, relative as relative2 } from "node:path";
|
|
49458
49602
|
function pass3(id, detail = DOCTOR_PASS_DETAIL) {
|
|
49459
49603
|
return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
|
|
@@ -49464,9 +49608,12 @@ function unknown5(id, detail, fixCommand) {
|
|
|
49464
49608
|
function fail3(id, detail, fixCommand) {
|
|
49465
49609
|
return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
|
|
49466
49610
|
}
|
|
49611
|
+
function warn(id, detail, fixCommand) {
|
|
49612
|
+
return { id, label: DOCTOR_LABEL[id], status: "WARN", detail, fixCommand };
|
|
49613
|
+
}
|
|
49467
49614
|
function bundleVersion(bundleDir2) {
|
|
49468
49615
|
try {
|
|
49469
|
-
const v = JSON.parse(
|
|
49616
|
+
const v = JSON.parse(readFileSync10(join12(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
|
|
49470
49617
|
return typeof v === "string" && v !== "" ? v : void 0;
|
|
49471
49618
|
} catch {
|
|
49472
49619
|
return void 0;
|
|
@@ -49550,20 +49697,21 @@ function highestTag(stdout, tag) {
|
|
|
49550
49697
|
}
|
|
49551
49698
|
return best;
|
|
49552
49699
|
}
|
|
49553
|
-
function versionRow(head, installed, tag, source, latest, tail) {
|
|
49700
|
+
function versionRow(head, installed, tag, source, latest, tail, update) {
|
|
49554
49701
|
const cmp = compareVersions(installed, latest) ?? (installed === latest ? 0 : -1);
|
|
49555
49702
|
if (cmp === 0) return pass3("D1", head + D1_LATEST_PASS(tag, source) + tail);
|
|
49556
49703
|
if (cmp > 0) return pass3("D1", head + D1_LATEST_AHEAD(tag, source, latest) + tail);
|
|
49557
|
-
return
|
|
49704
|
+
return warn("D1", head + D1_LATEST_UPDATE(tag, source, latest) + tail, update);
|
|
49558
49705
|
}
|
|
49559
49706
|
async function checkVersion(i) {
|
|
49560
49707
|
if (i.bundleSha === void 0) return unknown5("D1", D1_DEV_BUILD_DETAIL);
|
|
49561
49708
|
const head = D1_PREFIX(i.version, i.bundleSha) + ": ";
|
|
49562
49709
|
if (i.version === void 0) return unknown5("D1", head + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
|
|
49563
49710
|
const tag = channelOf(i.version);
|
|
49711
|
+
const update = i.updateCommand ?? DOCTOR_FIX_UPGRADE;
|
|
49564
49712
|
const git2 = findRuntime(GIT_BIN, i.env);
|
|
49565
49713
|
const npm = await npmLatest(i.registryUrl, tag, i.signal, i.timeoutMs);
|
|
49566
|
-
if (npm.ok) return versionRow(head, i.version, tag, D1_SOURCE_NPM, npm.version, "");
|
|
49714
|
+
if (npm.ok) return versionRow(head, i.version, tag, D1_SOURCE_NPM, npm.version, "", update);
|
|
49567
49715
|
let cause = D1_GIT_MISSING;
|
|
49568
49716
|
if (git2 !== null) {
|
|
49569
49717
|
const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
|
|
@@ -49574,7 +49722,7 @@ async function checkVersion(i) {
|
|
|
49574
49722
|
});
|
|
49575
49723
|
if (r.exitCode === 0 && r.killed === null) {
|
|
49576
49724
|
const latest = highestTag(r.stdout.toString("utf8"), tag);
|
|
49577
|
-
if (latest !== void 0) return versionRow(head, i.version, tag, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause);
|
|
49725
|
+
if (latest !== void 0) return versionRow(head, i.version, tag, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause, update);
|
|
49578
49726
|
cause = D1_GIT_NO_TAG(tag);
|
|
49579
49727
|
} else {
|
|
49580
49728
|
cause = gitCause(r, i.timeoutMs);
|
|
@@ -49610,10 +49758,11 @@ async function checkNode(i) {
|
|
|
49610
49758
|
if (!await sqliteLoads()) return fail3("D2", withBun(D2_SQLITE_DETAIL), D2_SQLITE_FIX);
|
|
49611
49759
|
return pass3("D2", bun.length === 0 ? DOCTOR_PASS_DETAIL : bun.join(D4_REASON_JOIN));
|
|
49612
49760
|
}
|
|
49613
|
-
function checkMcp(ctx) {
|
|
49761
|
+
function checkMcp(ctx, adapter) {
|
|
49614
49762
|
const named2 = ctx.clientInfo !== void 0 && ctx.clientInfo.name !== "";
|
|
49615
49763
|
const versioned = ctx.protocolVersion !== void 0 && ctx.protocolVersion !== "";
|
|
49616
|
-
|
|
49764
|
+
if (named2 || versioned) return pass3("D6");
|
|
49765
|
+
return adapter?.installMode === "in-process" ? pass3("D6", D6_IN_PROCESS_DETAIL) : unknown5("D6", D6_UNKNOWN_DETAIL);
|
|
49617
49766
|
}
|
|
49618
49767
|
function piCwdInside(worktree, piCwd) {
|
|
49619
49768
|
if (piCwd === void 0 || !existsSync12(piCwd)) return false;
|
|
@@ -49639,7 +49788,7 @@ function checkShell(env) {
|
|
|
49639
49788
|
}
|
|
49640
49789
|
|
|
49641
49790
|
// src/core/ops/doctor-hook.ts
|
|
49642
|
-
import { existsSync as existsSync14, mkdirSync as mkdirSync5, mkdtempSync, readFileSync as
|
|
49791
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync5, mkdtempSync, readFileSync as readFileSync11, realpathSync as realpathSync8, rmSync as rmSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
49643
49792
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
49644
49793
|
import path7 from "node:path";
|
|
49645
49794
|
|
|
@@ -51467,7 +51616,7 @@ function nodeLaunch(env, host = { bun: process.versions.bun, execPath: process.e
|
|
|
51467
51616
|
import { createHash } from "node:crypto";
|
|
51468
51617
|
import { existsSync as existsSync13, realpathSync as realpathSync7 } from "node:fs";
|
|
51469
51618
|
import path6 from "node:path";
|
|
51470
|
-
import { spawn as
|
|
51619
|
+
import { spawn as spawn3, spawnSync as spawnSync2 } from "node:child_process";
|
|
51471
51620
|
|
|
51472
51621
|
// src/setup/spawn-bin.ts
|
|
51473
51622
|
import { spawnSync } from "node:child_process";
|
|
@@ -51592,7 +51741,7 @@ function askPluginHooks(env, pluginId, cwd) {
|
|
|
51592
51741
|
resolve7({ kind: "silent" });
|
|
51593
51742
|
return;
|
|
51594
51743
|
}
|
|
51595
|
-
const child =
|
|
51744
|
+
const child = spawn3(f.command, f.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f.windowsVerbatimArguments, windowsHide: true });
|
|
51596
51745
|
let buf = "";
|
|
51597
51746
|
let done = false;
|
|
51598
51747
|
let exited = false;
|
|
@@ -51691,7 +51840,7 @@ function loadFixture(bundleDir2, agent) {
|
|
|
51691
51840
|
if (!existsSync14(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
|
|
51692
51841
|
let all;
|
|
51693
51842
|
try {
|
|
51694
|
-
all = JSON.parse(hostText(
|
|
51843
|
+
all = JSON.parse(hostText(readFileSync11(file2, "utf8")));
|
|
51695
51844
|
} catch (err) {
|
|
51696
51845
|
return { cause: D5_FIXTURE_PARSE(file2, err instanceof Error ? err.message : String(err)) };
|
|
51697
51846
|
}
|
|
@@ -52007,7 +52156,7 @@ function lastHookError(env) {
|
|
|
52007
52156
|
|
|
52008
52157
|
// src/core/ops/db-heal.ts
|
|
52009
52158
|
import { existsSync as existsSync15, mkdirSync as mkdirSync6, rmSync as rmSync5 } from "node:fs";
|
|
52010
|
-
import { basename as basename4, dirname as
|
|
52159
|
+
import { basename as basename4, dirname as dirname8, join as join15 } from "node:path";
|
|
52011
52160
|
function integrityOk2(rows) {
|
|
52012
52161
|
return rows.length === 1 && rows[0].integrity_check === INTEGRITY_OK;
|
|
52013
52162
|
}
|
|
@@ -52079,7 +52228,7 @@ async function healOrphan(project, files, row5) {
|
|
|
52079
52228
|
const moved = [];
|
|
52080
52229
|
let dir = "";
|
|
52081
52230
|
try {
|
|
52082
|
-
dir = makeOrphanDir(
|
|
52231
|
+
dir = makeOrphanDir(dirname8(project.dbPath));
|
|
52083
52232
|
for (const f of files) {
|
|
52084
52233
|
const to = join15(dir, basename4(f.path));
|
|
52085
52234
|
renameWithRetry(f.path, to);
|
|
@@ -52146,9 +52295,40 @@ function buildReportHead(input) {
|
|
|
52146
52295
|
return lines.concat(tail).join("\n");
|
|
52147
52296
|
}
|
|
52148
52297
|
|
|
52298
|
+
// src/core/ops/unsupported-host.ts
|
|
52299
|
+
var SUPPORTED_AGENTS_LINE = `Supported agents: ${AGENT_IDS.join(", ")} (${SUPPORTED_AGENTS_DOCS_URL}).`;
|
|
52300
|
+
function UNSUPPORTED_HOST_LINE(name) {
|
|
52301
|
+
return `${name} is not a supported host today. The MCP server runs here; hooks are not checked. ${SUPPORTED_AGENTS_LINE}`;
|
|
52302
|
+
}
|
|
52303
|
+
function segmentsOf(dir) {
|
|
52304
|
+
let parts = [dir];
|
|
52305
|
+
for (const sep3 of V1_PATH_SEPS) parts = parts.flatMap((p) => p.split(sep3));
|
|
52306
|
+
return parts;
|
|
52307
|
+
}
|
|
52308
|
+
function hasRun(parts, run) {
|
|
52309
|
+
for (let i = 0; i + run.length <= parts.length; i++) if (run.every((seg, k) => parts[i + k] === seg)) return true;
|
|
52310
|
+
return false;
|
|
52311
|
+
}
|
|
52312
|
+
function unsupportedHostOf(sig) {
|
|
52313
|
+
if (sig.clientName !== void 0 && sig.clientName !== "") {
|
|
52314
|
+
const n = sig.clientName.toLowerCase();
|
|
52315
|
+
const hit = UNSUPPORTED_HOSTS.find((h) => h.clientNames.includes(n));
|
|
52316
|
+
if (hit !== void 0) return hit;
|
|
52317
|
+
}
|
|
52318
|
+
if (sig.bundleDir !== void 0) {
|
|
52319
|
+
const parts = segmentsOf(sig.bundleDir);
|
|
52320
|
+
const hit = UNSUPPORTED_HOSTS.find((h) => h.pluginPaths.some((p) => hasRun(parts, p)));
|
|
52321
|
+
if (hit !== void 0) return hit;
|
|
52322
|
+
}
|
|
52323
|
+
if (sig.clientName !== void 0 && sig.clientName !== "") return void 0;
|
|
52324
|
+
const env = sig.env;
|
|
52325
|
+
if (env === void 0) return void 0;
|
|
52326
|
+
return UNSUPPORTED_HOSTS.find((h) => h.envVars.some((v) => env[v] !== void 0 && env[v] !== ""));
|
|
52327
|
+
}
|
|
52328
|
+
|
|
52149
52329
|
// src/core/ops/doctor-issue.ts
|
|
52150
52330
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
52151
|
-
import { closeSync as closeSync2, existsSync as existsSync16, fstatSync, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as
|
|
52331
|
+
import { closeSync as closeSync2, existsSync as existsSync16, fstatSync, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as readFileSync12, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
|
|
52152
52332
|
import { delimiter, join as join16 } from "node:path";
|
|
52153
52333
|
var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
|
|
52154
52334
|
function tildeOf(env) {
|
|
@@ -52251,7 +52431,7 @@ function agentConfig(adapter, env, worktree) {
|
|
|
52251
52431
|
}
|
|
52252
52432
|
let text = "";
|
|
52253
52433
|
try {
|
|
52254
|
-
text =
|
|
52434
|
+
text = readFileSync12(f.path, "utf8");
|
|
52255
52435
|
} catch (err) {
|
|
52256
52436
|
out.push(`${f.label}: ${f.path} (read: ${err instanceof Error ? err.message : String(err)})`);
|
|
52257
52437
|
continue;
|
|
@@ -52265,12 +52445,13 @@ function agentConfig(adapter, env, worktree) {
|
|
|
52265
52445
|
function failing(rows) {
|
|
52266
52446
|
return rows.filter((r) => r.status === "FAIL");
|
|
52267
52447
|
}
|
|
52268
|
-
function issueTitle(agent, rows) {
|
|
52269
|
-
return `ctx_doctor ${agent}: ${failing(rows).map((r) => `${r.id} ${r.label}`).join(", ")} FAIL`;
|
|
52448
|
+
function issueTitle(agent, rows, other) {
|
|
52449
|
+
return `ctx_doctor ${agent}${other === void 0 ? "" : ` (${other.name} is not a supported host today)`}: ${failing(rows).map((r) => `${r.id} ${r.label}`).join(", ")} FAIL`;
|
|
52270
52450
|
}
|
|
52271
|
-
function summaryOf(agent, rows) {
|
|
52451
|
+
function summaryOf(agent, rows, other) {
|
|
52272
52452
|
const f = failing(rows)[0];
|
|
52273
|
-
|
|
52453
|
+
const tag = other === void 0 ? "" : `${other.name} is not a supported host today. `;
|
|
52454
|
+
return tag + (f === void 0 ? `ctx_doctor ${agent}` : `${f.id} ${f.label} FAIL on ${agent}: ${f.detail}`);
|
|
52274
52455
|
}
|
|
52275
52456
|
async function buildIssueBody(i) {
|
|
52276
52457
|
const tilde = tildeOf(i.env);
|
|
@@ -52280,7 +52461,7 @@ async function buildIssueBody(i) {
|
|
|
52280
52461
|
const envNames = DOCTOR_ENV_NAMES.map((n) => i.env[n] === void 0 ? `${n} (unset)` : `${n}=${i.env[n]}`);
|
|
52281
52462
|
const pathTools = DOCTOR_PATH_TOOLS.map((t) => `PATH holds ${t}: ${onPath(i.env, t).join(", ") || "(absent)"}`);
|
|
52282
52463
|
const sections = {
|
|
52283
|
-
"Summary": [summaryOf(agent, i.rows)],
|
|
52464
|
+
"Summary": [summaryOf(agent, i.rows, i.unsupported)],
|
|
52284
52465
|
"ctx-report": [i.table],
|
|
52285
52466
|
"What happened": [
|
|
52286
52467
|
"Rows that need a look:",
|
|
@@ -52326,9 +52507,9 @@ async function writeIssueReport(i) {
|
|
|
52326
52507
|
const file2 = join16(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
|
|
52327
52508
|
writeFileSync4(file2, body);
|
|
52328
52509
|
const shown2 = tilde(file2);
|
|
52329
|
-
const title = issueTitle(i.adapter.id, i.rows);
|
|
52510
|
+
const title = issueTitle(i.adapter.id, i.rows, i.unsupported);
|
|
52330
52511
|
const gh = [`gh issue create --repo ${ISSUE_REPO_SLUG} --label bug \\`, `${DOCTOR_GH_NEXT}title ${JSON.stringify(title)} \\`, `${DOCTOR_GH_NEXT}body-file ${shown2}`];
|
|
52331
|
-
return [DOCTOR_REPORT_LINE + shown2, DOCTOR_GH_LINE + gh[0], gh[1], gh[2], DOCTOR_URL_LINE + formUrl(title, summaryOf(i.adapter.id, i.rows)), DOCTOR_RULES_LINE + ISSUE_GUIDE_URL];
|
|
52512
|
+
return [DOCTOR_REPORT_LINE + shown2, DOCTOR_GH_LINE + gh[0], gh[1], gh[2], DOCTOR_URL_LINE + formUrl(title, summaryOf(i.adapter.id, i.rows, i.unsupported)), DOCTOR_RULES_LINE + ISSUE_GUIDE_URL];
|
|
52332
52513
|
}
|
|
52333
52514
|
function formUrl(title, summary) {
|
|
52334
52515
|
const base = `${ISSUE_FORM_URL}&title=${encodeURIComponent(title)}`;
|
|
@@ -52376,6 +52557,12 @@ async function codexDb(ctx, adapter) {
|
|
|
52376
52557
|
return null;
|
|
52377
52558
|
}
|
|
52378
52559
|
}
|
|
52560
|
+
function d1UpdateCommand(agent, env, other) {
|
|
52561
|
+
return other === void 0 ? hostUpdateCommand(agent, env) : UNSUPPORTED_HOST_LINE(other.name);
|
|
52562
|
+
}
|
|
52563
|
+
function unsupportedRow(id, h) {
|
|
52564
|
+
return { id, label: DOCTOR_LABEL[id], status: "WARN", detail: UNSUPPORTED_HOST_LINE(h.name) };
|
|
52565
|
+
}
|
|
52379
52566
|
async function hookRow(ctx, adapter, host) {
|
|
52380
52567
|
const db = await codexDb(ctx, adapter);
|
|
52381
52568
|
const runStart = Date.now();
|
|
@@ -52403,7 +52590,7 @@ function ownServerId(configDir, projectKey) {
|
|
|
52403
52590
|
if (!existsSync17(dir)) return "";
|
|
52404
52591
|
for (const name of readdirSync8(dir)) {
|
|
52405
52592
|
if (!name.endsWith(OWNER_PID_EXT)) continue;
|
|
52406
|
-
if (
|
|
52593
|
+
if (readFileSync13(join17(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
|
|
52407
52594
|
}
|
|
52408
52595
|
return "";
|
|
52409
52596
|
}
|
|
@@ -52411,16 +52598,18 @@ async function runDoctorChecks(ctx, adapter, host0) {
|
|
|
52411
52598
|
const host = adapter.id === "codex" ? { ...host0, env: { ...host0.env, CODEX_HOME: codexRunDirOf(host0.env, homeDirOf(host0.env) ?? "", host0.bundleDir) } } : host0;
|
|
52412
52599
|
const env = host.env;
|
|
52413
52600
|
const project = ctx.project;
|
|
52601
|
+
const other = adapter.installMode === "in-process" ? void 0 : unsupportedHostOf({ clientName: ctx.clientInfo?.name, bundleDir: host.bundleDir, env });
|
|
52414
52602
|
let integrityFailed = false;
|
|
52415
52603
|
let orphan = [];
|
|
52416
52604
|
const checks = {
|
|
52417
|
-
D1: () => checkVersion({ bundleSha: BUNDLE_SHA, version: bundleVersion(host.bundleDir), registryUrl: D1_REGISTRY_URL, timeoutMs: DOCTOR_GIT_TIMEOUT_MS, env: buildChildEnv(env), cwd: project.worktree, signal: ctx.signal }),
|
|
52605
|
+
D1: () => checkVersion({ bundleSha: BUNDLE_SHA, version: bundleVersion(host.bundleDir), registryUrl: D1_REGISTRY_URL, timeoutMs: DOCTOR_GIT_TIMEOUT_MS, env: buildChildEnv(env), cwd: project.worktree, signal: ctx.signal, updateCommand: d1UpdateCommand(adapter.id, env, other) }),
|
|
52418
52606
|
D2: () => checkNode({ nodeVersion: process.version, bunVersion: process.versions.bun }),
|
|
52419
|
-
D3: () => checkHostConfig(adapter, env, project.worktree),
|
|
52607
|
+
D3: () => other !== void 0 ? unsupportedRow("D3", other) : checkHostConfig(adapter, env, project.worktree),
|
|
52608
|
+
// D-UNSUPPORTED-HOSTS-1
|
|
52420
52609
|
D4: () => checkV1Leftovers(adapter.id, requireHomeDir(env), { project: project.worktree, piAgentDir: piAgentDirOf(env, requireHomeDir(env)), claudeDir: claudeDirOf(env, requireHomeDir(env)), codexDir: codexDirOf(env, requireHomeDir(env)), geminiDir: geminiDirOf(env, requireHomeDir(env)), copilotDir: copilotDirOf(env, requireHomeDir(env)), kiroDir: kiroDirOf(env, requireHomeDir(env)), opencodeDir: opencodeDirOf(env, requireHomeDir(env)) }),
|
|
52421
|
-
D5: () => hookRow(ctx, adapter, host),
|
|
52610
|
+
D5: () => other !== void 0 ? unsupportedRow("D5", other) : hookRow(ctx, adapter, host),
|
|
52422
52611
|
D5b: () => checkDoubleFire(adapter.id, project.worktree),
|
|
52423
|
-
D6: () => checkMcp(ctx),
|
|
52612
|
+
D6: () => checkMcp(ctx, adapter),
|
|
52424
52613
|
D7: () => checkProject({ project, adapter, piCwd: host.piCwd }),
|
|
52425
52614
|
D8: async () => {
|
|
52426
52615
|
const r = await checkDb(project);
|
|
@@ -52467,7 +52656,7 @@ async function doctorReply(ctx, host) {
|
|
|
52467
52656
|
let notes = [];
|
|
52468
52657
|
if (failed) {
|
|
52469
52658
|
try {
|
|
52470
|
-
notes = await writeIssueReport({ ctx, adapter, env: host.env, bundleDir: host.bundleDir, rows, envLine: envLine2, table: table3 });
|
|
52659
|
+
notes = await writeIssueReport({ unsupported: adapter.installMode === "in-process" ? void 0 : unsupportedHostOf({ clientName: ctx.clientInfo?.name, bundleDir: host.bundleDir, env: host.env }), ctx, adapter, env: host.env, bundleDir: host.bundleDir, rows, envLine: envLine2, table: table3 });
|
|
52471
52660
|
} catch (err) {
|
|
52472
52661
|
notes = [`Report file: ${lineOf(err)}`];
|
|
52473
52662
|
}
|
|
@@ -52501,7 +52690,7 @@ var ctxDoctor = Object.freeze({
|
|
|
52501
52690
|
// src/core/tools/execute.ts
|
|
52502
52691
|
import { existsSync as existsSync18, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync5 } from "node:fs";
|
|
52503
52692
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
52504
|
-
import { dirname as
|
|
52693
|
+
import { dirname as dirname10, join as join18, parse as parse5, resolve as resolve5 } from "node:path";
|
|
52505
52694
|
|
|
52506
52695
|
// src/core/index/select.ts
|
|
52507
52696
|
var READ_CHUNKS = "SELECT ord, body FROM chunks WHERE source_id = ?";
|
|
@@ -52623,7 +52812,7 @@ function schemaLine(issue4) {
|
|
|
52623
52812
|
}
|
|
52624
52813
|
function fileError(given, abs, root) {
|
|
52625
52814
|
let dir = abs;
|
|
52626
|
-
while (!existsSync18(dir) &&
|
|
52815
|
+
while (!existsSync18(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
|
|
52627
52816
|
if (isInside(root, dir)) return null;
|
|
52628
52817
|
return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
|
|
52629
52818
|
}
|
|
@@ -52657,7 +52846,7 @@ function spawnFailed(argv0, cwd) {
|
|
|
52657
52846
|
}
|
|
52658
52847
|
async function finish(input, ctx, r, exitCode, journal) {
|
|
52659
52848
|
const isError = exitCode !== 0 && !(input.language === "shell" && exitCode === SOFT_EXIT && r.stderr.length === 0);
|
|
52660
|
-
const combined = r.stdout.toString("utf8") + (exitCode !== 0 ? r.stderr.toString("utf8") : "");
|
|
52849
|
+
const combined = r.stdout.toString("utf8") + (exitCode !== 0 ? r.stderr.toString("utf8") : "") + (r.held === true ? "\n" + BACKGROUND_HOLD_NOTE + "\n" : "");
|
|
52661
52850
|
const fullBytes = Buffer.byteLength(combined, "utf8");
|
|
52662
52851
|
const head = summaryLine(exitCode, fullBytes);
|
|
52663
52852
|
const intent = input.intent ?? "";
|
|
@@ -52741,11 +52930,11 @@ var ctxExecute = {
|
|
|
52741
52930
|
};
|
|
52742
52931
|
|
|
52743
52932
|
// src/core/tools/index.ts
|
|
52744
|
-
import { existsSync as existsSync19, readFileSync as
|
|
52745
|
-
import { dirname as
|
|
52933
|
+
import { existsSync as existsSync19, readFileSync as readFileSync15, statSync as statSync7 } from "node:fs";
|
|
52934
|
+
import { dirname as dirname11, extname as extname3, join as join20, relative as relative3, resolve as resolve6 } from "node:path";
|
|
52746
52935
|
|
|
52747
52936
|
// src/core/index/walk.ts
|
|
52748
|
-
import { readdirSync as readdirSync9, readFileSync as
|
|
52937
|
+
import { readdirSync as readdirSync9, readFileSync as readFileSync14, realpathSync as realpathSync10, statSync as statSync6 } from "node:fs";
|
|
52749
52938
|
import { join as join19 } from "node:path";
|
|
52750
52939
|
var GITIGNORE = ".gitignore";
|
|
52751
52940
|
var GIT_DIR = ".git";
|
|
@@ -52807,7 +52996,7 @@ function compareFound(a, b) {
|
|
|
52807
52996
|
function readRules(file2, base) {
|
|
52808
52997
|
let body;
|
|
52809
52998
|
try {
|
|
52810
|
-
body =
|
|
52999
|
+
body = readFileSync14(file2, "utf8");
|
|
52811
53000
|
} catch {
|
|
52812
53001
|
return [];
|
|
52813
53002
|
}
|
|
@@ -56935,14 +57124,14 @@ function kindOfType(contentType) {
|
|
|
56935
57124
|
}
|
|
56936
57125
|
function readUtf8(absPath) {
|
|
56937
57126
|
try {
|
|
56938
|
-
return utf8.decode(
|
|
57127
|
+
return utf8.decode(readFileSync15(absPath));
|
|
56939
57128
|
} catch {
|
|
56940
57129
|
return void 0;
|
|
56941
57130
|
}
|
|
56942
57131
|
}
|
|
56943
57132
|
function missingOrOutside(given, abs, root) {
|
|
56944
57133
|
let dir = abs;
|
|
56945
|
-
while (!existsSync19(dir) &&
|
|
57134
|
+
while (!existsSync19(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
|
|
56946
57135
|
if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
|
|
56947
57136
|
return new CtxError("OUTSIDE_ROOT", { p: given, root });
|
|
56948
57137
|
}
|
|
@@ -57753,7 +57942,7 @@ var ctxStats = Object.freeze({
|
|
|
57753
57942
|
|
|
57754
57943
|
// src/core/ops/host-write.ts
|
|
57755
57944
|
import { copyFileSync, existsSync as existsSync20, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
|
|
57756
|
-
import { dirname as
|
|
57945
|
+
import { dirname as dirname12, join as join21 } from "node:path";
|
|
57757
57946
|
function defaultWrite(file2, text) {
|
|
57758
57947
|
writeFileSync6(file2, text, "utf8");
|
|
57759
57948
|
}
|
|
@@ -57785,7 +57974,7 @@ function writeWithRollback(file2, text, write, atomic) {
|
|
|
57785
57974
|
const trash = file2 + UPGRADE_TRASH_SUFFIX;
|
|
57786
57975
|
const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
|
|
57787
57976
|
const had = existsSync20(file2);
|
|
57788
|
-
mkdirSync8(
|
|
57977
|
+
mkdirSync8(dirname12(file2), { recursive: true });
|
|
57789
57978
|
if (had) copyFileSync(file2, trash);
|
|
57790
57979
|
try {
|
|
57791
57980
|
write(tmp, text);
|
|
@@ -57952,7 +58141,7 @@ function runUninstall(input) {
|
|
|
57952
58141
|
}
|
|
57953
58142
|
|
|
57954
58143
|
// src/core/ops/v1-remove.ts
|
|
57955
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync22, readFileSync as
|
|
58144
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync22, readFileSync as readFileSync16, rmSync as rmSync8 } from "node:fs";
|
|
57956
58145
|
var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
57957
58146
|
var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
|
|
57958
58147
|
var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
|
|
@@ -58003,8 +58192,8 @@ function locate(doc, path8) {
|
|
|
58003
58192
|
return null;
|
|
58004
58193
|
}
|
|
58005
58194
|
function stripJsonEntries(agent, file2, findings, kept, undo) {
|
|
58006
|
-
const layout = hostLayout(
|
|
58007
|
-
const text = hostText(
|
|
58195
|
+
const layout = hostLayout(readFileSync16(file2, "utf8"));
|
|
58196
|
+
const text = hostText(readFileSync16(file2, "utf8"));
|
|
58008
58197
|
const doc = parseHostConfig(agent, file2, text, "jsonc");
|
|
58009
58198
|
const hit = /* @__PURE__ */ new Set();
|
|
58010
58199
|
const byContainer = /* @__PURE__ */ new Map();
|
|
@@ -58054,7 +58243,7 @@ function removeV1(agent, findings, project) {
|
|
|
58054
58243
|
continue;
|
|
58055
58244
|
}
|
|
58056
58245
|
if (file2.endsWith(TOML_EXT)) {
|
|
58057
|
-
const rawToml =
|
|
58246
|
+
const rawToml = readFileSync16(file2, "utf8");
|
|
58058
58247
|
const tomlLayout = hostLayout(rawToml);
|
|
58059
58248
|
let text = hostText(rawToml);
|
|
58060
58249
|
for (const f of list3) {
|
|
@@ -58112,8 +58301,8 @@ function pluginRootRow(adapter, env) {
|
|
|
58112
58301
|
}
|
|
58113
58302
|
return root === own4 ? [] : [row4(UPGRADE_PLUGIN_ROOT_AREA, root, own4)];
|
|
58114
58303
|
}
|
|
58115
|
-
function hostRow(adapter) {
|
|
58116
|
-
return row4(UPGRADE_HOST_AREA, "",
|
|
58304
|
+
function hostRow(adapter, env) {
|
|
58305
|
+
return row4(UPGRADE_HOST_AREA, "", hostUpdateCommand(adapter.id, env));
|
|
58117
58306
|
}
|
|
58118
58307
|
function upgrade(adapter, deps, home) {
|
|
58119
58308
|
let removal = null;
|
|
@@ -58121,7 +58310,7 @@ function upgrade(adapter, deps, home) {
|
|
|
58121
58310
|
const step5 = regenerateHostConfig(adapter, home, { env: deps.env, write: deps.write });
|
|
58122
58311
|
const findings = detectV1(adapter.id, home, { project: deps.project.worktree, piAgentDir: piAgentDirOf(deps.env, home), claudeDir: claudeDirOf(deps.env, home), geminiDir: geminiDirOf(deps.env, home), copilotDir: copilotDirOf(deps.env, home), kiroDir: kiroDirOf(deps.env, home), opencodeDir: opencodeDirOf(deps.env, home) });
|
|
58123
58312
|
removal = removeV1(adapter.id, findings, deps.project.worktree);
|
|
58124
|
-
const rows = [hostRow(adapter), ...step5, ...removal.rows];
|
|
58313
|
+
const rows = [hostRow(adapter, deps.env), ...step5, ...removal.rows];
|
|
58125
58314
|
removal.commit();
|
|
58126
58315
|
return rows;
|
|
58127
58316
|
} catch (err) {
|
|
@@ -58319,7 +58508,7 @@ function workspaceCwdOf(meta3, spawnCwd, script) {
|
|
|
58319
58508
|
const fromHost = workspaceFromMeta(meta3);
|
|
58320
58509
|
if (fromHost !== void 0) return fromHost;
|
|
58321
58510
|
if (script === void 0 || script === "") return spawnCwd;
|
|
58322
|
-
return realOrSame(spawnCwd) === realOrSame(
|
|
58511
|
+
return realOrSame(spawnCwd) === realOrSame(dirname13(script)) ? "" : spawnCwd;
|
|
58323
58512
|
}
|
|
58324
58513
|
function errorReply(err) {
|
|
58325
58514
|
if (err instanceof CtxError) return { text: err.toLine(), isError: true, sandboxBytes: 0 };
|