context-mode 2.1.6 → 2.1.8
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 +1005 -634
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +96 -96
- package/opencode/plugin.js +689 -287
- package/package.json +1 -1
- package/pi/index.js +554 -190
- package/qwen-extension.json +1 -1
- package/run.mjs +195 -32
- package/search.mjs +195 -32
- package/server.mjs +479 -162
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
|
|
@@ -3487,7 +3487,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
3487
3487
|
var NONE = 0;
|
|
3488
3488
|
var ASSUMED = 1;
|
|
3489
3489
|
var PROVEN = 2;
|
|
3490
|
-
function isRecursive(inst, stack2,
|
|
3490
|
+
function isRecursive(inst, stack2, resolve10) {
|
|
3491
3491
|
const cached4 = recursive.get(inst);
|
|
3492
3492
|
if (cached4 !== void 0)
|
|
3493
3493
|
return cached4 ? PROVEN : NONE;
|
|
@@ -3497,7 +3497,7 @@ function isRecursive(inst, stack2, resolve7) {
|
|
|
3497
3497
|
let result = NONE;
|
|
3498
3498
|
const check2 = (child) => {
|
|
3499
3499
|
if (result !== PROVEN && child?._zod) {
|
|
3500
|
-
const answer3 = isRecursive(child, stack2,
|
|
3500
|
+
const answer3 = isRecursive(child, stack2, resolve10);
|
|
3501
3501
|
if (answer3 > result)
|
|
3502
3502
|
result = answer3;
|
|
3503
3503
|
}
|
|
@@ -3508,7 +3508,7 @@ function isRecursive(inst, stack2, resolve7) {
|
|
|
3508
3508
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
3509
3509
|
if (spread && !desc.enumerable)
|
|
3510
3510
|
continue;
|
|
3511
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack2,
|
|
3511
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack2, resolve10) : NONE;
|
|
3512
3512
|
if (child > answer3)
|
|
3513
3513
|
answer3 = child;
|
|
3514
3514
|
}
|
|
@@ -3572,7 +3572,7 @@ function isRecursive(inst, stack2, resolve7) {
|
|
|
3572
3572
|
break;
|
|
3573
3573
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
3574
3574
|
case "lazy": {
|
|
3575
|
-
const inner = def._cachedInner ?? (
|
|
3575
|
+
const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
|
|
3576
3576
|
merge5(inner ? isRecursive(inner, stack2, false) : ASSUMED);
|
|
3577
3577
|
break;
|
|
3578
3578
|
}
|
|
@@ -11016,7 +11016,7 @@ var recursive2 = /* @__PURE__ */ new WeakMap();
|
|
|
11016
11016
|
var NONE2 = 0;
|
|
11017
11017
|
var ASSUMED2 = 1;
|
|
11018
11018
|
var PROVEN2 = 2;
|
|
11019
|
-
function isRecursive2(inst, stack2,
|
|
11019
|
+
function isRecursive2(inst, stack2, resolve10) {
|
|
11020
11020
|
const cached4 = recursive2.get(inst);
|
|
11021
11021
|
if (cached4 !== void 0)
|
|
11022
11022
|
return cached4 ? PROVEN2 : NONE2;
|
|
@@ -11026,7 +11026,7 @@ function isRecursive2(inst, stack2, resolve7) {
|
|
|
11026
11026
|
let result = NONE2;
|
|
11027
11027
|
const check2 = (child) => {
|
|
11028
11028
|
if (result !== PROVEN2 && child?._zod) {
|
|
11029
|
-
const answer3 = isRecursive2(child, stack2,
|
|
11029
|
+
const answer3 = isRecursive2(child, stack2, resolve10);
|
|
11030
11030
|
if (answer3 > result)
|
|
11031
11031
|
result = answer3;
|
|
11032
11032
|
}
|
|
@@ -11037,7 +11037,7 @@ function isRecursive2(inst, stack2, resolve7) {
|
|
|
11037
11037
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
11038
11038
|
if (spread && !desc.enumerable)
|
|
11039
11039
|
continue;
|
|
11040
|
-
const child = desc.get ? ASSUMED2 : desc.value?._zod ? isRecursive2(desc.value, stack2,
|
|
11040
|
+
const child = desc.get ? ASSUMED2 : desc.value?._zod ? isRecursive2(desc.value, stack2, resolve10) : NONE2;
|
|
11041
11041
|
if (child > answer3)
|
|
11042
11042
|
answer3 = child;
|
|
11043
11043
|
}
|
|
@@ -11101,7 +11101,7 @@ function isRecursive2(inst, stack2, resolve7) {
|
|
|
11101
11101
|
break;
|
|
11102
11102
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
11103
11103
|
case "lazy": {
|
|
11104
|
-
const inner = def._cachedInner ?? (
|
|
11104
|
+
const inner = def._cachedInner ?? (resolve10 ? inst._zod.innerType : void 0);
|
|
11105
11105
|
merge5(inner ? isRecursive2(inner, stack2, false) : ASSUMED2);
|
|
11106
11106
|
break;
|
|
11107
11107
|
}
|
|
@@ -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) {
|
|
@@ -17705,14 +17705,14 @@ function inputRequiredRoundsExceededMessage(method, maxRounds) {
|
|
|
17705
17705
|
return `Multi-round-trip request '${method}' still required input after ${maxRounds} rounds (inputRequired.maxRounds)`;
|
|
17706
17706
|
}
|
|
17707
17707
|
function sleep(ms, signal) {
|
|
17708
|
-
return new Promise((
|
|
17708
|
+
return new Promise((resolve10, reject) => {
|
|
17709
17709
|
if (signal?.aborted) {
|
|
17710
17710
|
reject(signal.reason instanceof SdkError ? signal.reason : new SdkError(SdkErrorCode.RequestTimeout, String(signal.reason)));
|
|
17711
17711
|
return;
|
|
17712
17712
|
}
|
|
17713
17713
|
const timer = setTimeout(() => {
|
|
17714
17714
|
signal?.removeEventListener("abort", onAbort);
|
|
17715
|
-
|
|
17715
|
+
resolve10();
|
|
17716
17716
|
}, ms);
|
|
17717
17717
|
const onAbort = () => {
|
|
17718
17718
|
clearTimeout(timer);
|
|
@@ -18511,7 +18511,7 @@ var Protocol = class {
|
|
|
18511
18511
|
const flowStartedAt = Date.now();
|
|
18512
18512
|
let onAbort;
|
|
18513
18513
|
let cleanupMessageId;
|
|
18514
|
-
return new Promise((
|
|
18514
|
+
return new Promise((resolve10, reject) => {
|
|
18515
18515
|
const earlyReject = (error42) => {
|
|
18516
18516
|
reject(error42);
|
|
18517
18517
|
};
|
|
@@ -18580,7 +18580,7 @@ var Protocol = class {
|
|
|
18580
18580
|
}
|
|
18581
18581
|
if (decoded.kind === "invalid") return reject(decoded.error);
|
|
18582
18582
|
if (decoded.kind === "input_required") {
|
|
18583
|
-
if (options?.allowInputRequired === true) return
|
|
18583
|
+
if (options?.allowInputRequired === true) return resolve10(manualInputRequiredValue(decoded));
|
|
18584
18584
|
const flow = {
|
|
18585
18585
|
codec,
|
|
18586
18586
|
request: request2,
|
|
@@ -18592,11 +18592,11 @@ var Protocol = class {
|
|
|
18592
18592
|
params
|
|
18593
18593
|
}, resultSchema, legOptions)
|
|
18594
18594
|
};
|
|
18595
|
-
return
|
|
18595
|
+
return resolve10(this._resolveNonCompleteResult(decoded, flow));
|
|
18596
18596
|
}
|
|
18597
18597
|
const result = decoded.result;
|
|
18598
18598
|
validateStandardSchema(resultSchema, result).then((parseResult) => {
|
|
18599
|
-
if (parseResult.success)
|
|
18599
|
+
if (parseResult.success) resolve10(parseResult.data);
|
|
18600
18600
|
else reject(new SdkError(SdkErrorCode.InvalidResult, `Invalid result for ${request2.method}: ${parseResult.error}`));
|
|
18601
18601
|
}, reject);
|
|
18602
18602
|
});
|
|
@@ -21512,7 +21512,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
21512
21512
|
ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
|
|
21513
21513
|
const schOrFunc = root.refs[ref];
|
|
21514
21514
|
if (schOrFunc) return schOrFunc;
|
|
21515
|
-
let _sch =
|
|
21515
|
+
let _sch = resolve10.call(this, root, ref);
|
|
21516
21516
|
if (_sch === void 0) {
|
|
21517
21517
|
const schema = (_a5 = root.localRefs) === null || _a5 === void 0 ? void 0 : _a5[ref];
|
|
21518
21518
|
const { schemaId } = this.opts;
|
|
@@ -21538,7 +21538,7 @@ var require_compile = /* @__PURE__ */ __commonJSMin((exports) => {
|
|
|
21538
21538
|
function sameSchemaEnv(s1, s2) {
|
|
21539
21539
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
21540
21540
|
}
|
|
21541
|
-
function
|
|
21541
|
+
function resolve10(root, ref) {
|
|
21542
21542
|
let sch;
|
|
21543
21543
|
while (typeof (sch = this.refs[ref]) == "string") ref = sch;
|
|
21544
21544
|
return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
|
|
@@ -21988,7 +21988,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
21988
21988
|
else if (typeof uri === "object") uri = parse6(serialize(uri, options), options);
|
|
21989
21989
|
return uri;
|
|
21990
21990
|
}
|
|
21991
|
-
function
|
|
21991
|
+
function resolve10(baseURI, relativeURI, options) {
|
|
21992
21992
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
21993
21993
|
const resolved = resolveComponent(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
21994
21994
|
schemelessOptions.skipEscape = true;
|
|
@@ -22162,7 +22162,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
22162
22162
|
const fastUri = {
|
|
22163
22163
|
SCHEMES,
|
|
22164
22164
|
normalize: normalize2,
|
|
22165
|
-
resolve:
|
|
22165
|
+
resolve: resolve10,
|
|
22166
22166
|
resolveComponent,
|
|
22167
22167
|
equal,
|
|
22168
22168
|
serialize,
|
|
@@ -27627,7 +27627,7 @@ var StdioServerTransport = class {
|
|
|
27627
27627
|
}
|
|
27628
27628
|
send(message2) {
|
|
27629
27629
|
if (this._closed) return Promise.reject(/* @__PURE__ */ new Error("StdioServerTransport is closed"));
|
|
27630
|
-
return new Promise((
|
|
27630
|
+
return new Promise((resolve10, reject) => {
|
|
27631
27631
|
const json2 = serializeMessage(message2);
|
|
27632
27632
|
let settled = false;
|
|
27633
27633
|
const onError = (error42) => {
|
|
@@ -27642,14 +27642,14 @@ var StdioServerTransport = class {
|
|
|
27642
27642
|
settled = true;
|
|
27643
27643
|
this._stdout.off("error", onError);
|
|
27644
27644
|
this._stdout.off("drain", onDrain);
|
|
27645
|
-
|
|
27645
|
+
resolve10();
|
|
27646
27646
|
};
|
|
27647
27647
|
this._stdout.once("error", onError);
|
|
27648
27648
|
if (this._stdout.write(json2)) {
|
|
27649
27649
|
if (settled) return;
|
|
27650
27650
|
settled = true;
|
|
27651
27651
|
this._stdout.off("error", onError);
|
|
27652
|
-
|
|
27652
|
+
resolve10();
|
|
27653
27653
|
} else if (!settled) this._stdout.once("drain", onDrain);
|
|
27654
27654
|
});
|
|
27655
27655
|
}
|
|
@@ -27703,14 +27703,14 @@ var StdioConnectionChannel = class {
|
|
|
27703
27703
|
*/
|
|
27704
27704
|
async whenRequestsAnswered(timeoutMs) {
|
|
27705
27705
|
if (this._closed || this._pendingRequests.size === 0) return true;
|
|
27706
|
-
return await new Promise((
|
|
27706
|
+
return await new Promise((resolve10) => {
|
|
27707
27707
|
const waiter = () => {
|
|
27708
27708
|
clearTimeout(timer);
|
|
27709
|
-
|
|
27709
|
+
resolve10(true);
|
|
27710
27710
|
};
|
|
27711
27711
|
const timer = setTimeout(() => {
|
|
27712
27712
|
this._drainWaiters = this._drainWaiters.filter((pending) => pending !== waiter);
|
|
27713
|
-
|
|
27713
|
+
resolve10(false);
|
|
27714
27714
|
}, timeoutMs);
|
|
27715
27715
|
this._drainWaiters.push(waiter);
|
|
27716
27716
|
});
|
|
@@ -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 ? "92c1ad26d57b45e786a3dc9149549c416badca09" : 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)}`;
|
|
@@ -28762,6 +28850,14 @@ var V1_SCRIPT_NAMES = Object.freeze([
|
|
|
28762
28850
|
var V1_HOOK_COMMAND = "context-mode hook";
|
|
28763
28851
|
var V1_CODEX_HOOK_COMMAND = "context-mode hook codex";
|
|
28764
28852
|
var V1_CODEX_HOOKS_DIR = Object.freeze(["hooks", "codex"]);
|
|
28853
|
+
var V1_CODEX_SCRIPT_NAMES = Object.freeze([
|
|
28854
|
+
"pretooluse.mjs",
|
|
28855
|
+
"posttooluse.mjs",
|
|
28856
|
+
"sessionstart.mjs",
|
|
28857
|
+
"precompact.mjs",
|
|
28858
|
+
"userpromptsubmit.mjs",
|
|
28859
|
+
"stop.mjs"
|
|
28860
|
+
]);
|
|
28765
28861
|
var V1_CACHE_HEAL_NAME = "context-mode-cache-heal";
|
|
28766
28862
|
var V1_CACHE_HEAL_EXTS = Object.freeze([".mjs", ".sh"]);
|
|
28767
28863
|
var V1_STATUSLINE_COMMAND = "context-mode statusline";
|
|
@@ -28821,7 +28917,6 @@ var PI_NPM_LATEST = `${V1_PI_PACKAGE}${NPM_VERSION_SEP}latest`;
|
|
|
28821
28917
|
var V1_DATA_DIR_NAME = "context-mode";
|
|
28822
28918
|
var V1_DATA_ROOT_ENTRIES = Object.freeze(["content", "platform.json"]);
|
|
28823
28919
|
var V1_SESSIONS_DIR_NAME = "sessions";
|
|
28824
|
-
var V1_SCRIPT_EXT = ".mjs";
|
|
28825
28920
|
var V1_BIN_COMMAND = SERVER_KEY;
|
|
28826
28921
|
var VSCODE_MCP_SERVERS_KEY = "servers";
|
|
28827
28922
|
var ZCODE_EVENTS_KEY = "events";
|
|
@@ -28837,7 +28932,7 @@ var V1_REASON = Object.freeze({
|
|
|
28837
28932
|
cacheHealFile: "old context-mode cache-heal script file",
|
|
28838
28933
|
statusLine: "old context-mode statusLine (context-mode statusline): report only, never removed",
|
|
28839
28934
|
mcpEntry: "old context-mode MCP entry mcpServers.context-mode",
|
|
28840
|
-
codexHook: "old context-mode Codex hook entry: context-mode hook codex or hooks/codex
|
|
28935
|
+
codexHook: "old context-mode Codex hook entry: context-mode hook codex or hooks/codex/<event>.mjs",
|
|
28841
28936
|
codexToml: "old context-mode config.toml [mcp_servers.context-mode*] section",
|
|
28842
28937
|
hookFile: "old context-mode hook file context-mode.json (runs context-mode hook)",
|
|
28843
28938
|
vscodeMcp: "old context-mode MCP entry servers.context-mode in .vscode/mcp.json: report only, never removed",
|
|
@@ -28875,7 +28970,6 @@ var HOST_CONFIG_TEXT_PATH = "(given text)";
|
|
|
28875
28970
|
var JSON_INDENT_UNIT = " ";
|
|
28876
28971
|
var MCP_COMMAND_FIELD = "command";
|
|
28877
28972
|
var MCP_ARGS_FIELD = "args";
|
|
28878
|
-
var MCP_ENV_FIELD = "env";
|
|
28879
28973
|
var ZCODE_MCP_FEATURE_KEY = Object.freeze(["features", "mcp"]);
|
|
28880
28974
|
var CODEX_OMIT_TOOLS_FROM_FIELD = "omit_tools_from";
|
|
28881
28975
|
var CODEX_OMIT_DEFERRED = Object.freeze(["deferred"]);
|
|
@@ -29521,6 +29615,17 @@ function claudeDirOf(env, home) {
|
|
|
29521
29615
|
const dir = env[CLAUDE_CONFIG_DIR_ENV];
|
|
29522
29616
|
return dir !== void 0 && dir !== "" ? dir : join(home, ...AGENT_HOME_DIR["claude-code"]);
|
|
29523
29617
|
}
|
|
29618
|
+
function claudeProfileEnv(env, platform = process.platform) {
|
|
29619
|
+
const dir = env[CLAUDE_CONFIG_DIR_ENV];
|
|
29620
|
+
if (dir === void 0 || dir === "" || platform === "win32") return "";
|
|
29621
|
+
return `${CLAUDE_CONFIG_DIR_ENV}='${dir.split("'").join(`'"'"'`)}' `;
|
|
29622
|
+
}
|
|
29623
|
+
function hostUpdateCommand(agent, env, platform = process.platform) {
|
|
29624
|
+
const cmd = UPGRADE_HOST_COMMAND[agent];
|
|
29625
|
+
if (agent !== "claude-code") return cmd;
|
|
29626
|
+
const profile = claudeProfileEnv(env, platform);
|
|
29627
|
+
return profile === "" ? cmd : cmd.split(" && ").map((c) => profile + c).join(" && ");
|
|
29628
|
+
}
|
|
29524
29629
|
function opencodeDirOf(env, home) {
|
|
29525
29630
|
const own4 = env[OPENCODE_CONFIG_DIR_ENV];
|
|
29526
29631
|
if (own4 !== void 0 && own4 !== "") return own4;
|
|
@@ -29560,10 +29665,10 @@ function resolveConfigDir(env) {
|
|
|
29560
29665
|
}
|
|
29561
29666
|
|
|
29562
29667
|
// src/core/project/resolve.ts
|
|
29563
|
-
import { basename as basename2, dirname as dirname3, join as join3, resolve as
|
|
29668
|
+
import { basename as basename2, dirname as dirname3, join as join3, resolve as resolve3 } from "node:path";
|
|
29564
29669
|
|
|
29565
29670
|
// src/core/project/contain.ts
|
|
29566
|
-
import { dirname as dirname2, join as join2, relative, sep } from "node:path";
|
|
29671
|
+
import { dirname as dirname2, isAbsolute, join as join2, relative, resolve as resolve2, sep } from "node:path";
|
|
29567
29672
|
var { lstatSync, realpathSync: realpathSync2 } = process.getBuiltinModule("node:fs");
|
|
29568
29673
|
function real(p) {
|
|
29569
29674
|
try {
|
|
@@ -29782,7 +29887,7 @@ function gitDirs(dir) {
|
|
|
29782
29887
|
const gitDir = gitDirAt(join3(cur, GIT_DIR_NAME));
|
|
29783
29888
|
if (gitDir !== null) {
|
|
29784
29889
|
const common = firstLine(join3(gitDir, GIT_COMMONDIR_FILE));
|
|
29785
|
-
return { commonDir: realpathSync3.native(common === null ? gitDir :
|
|
29890
|
+
return { commonDir: realpathSync3.native(common === null ? gitDir : resolve3(gitDir, common)), worktree: cur, start };
|
|
29786
29891
|
}
|
|
29787
29892
|
const up = dirname3(cur);
|
|
29788
29893
|
if (up === cur) return { commonDir: null, start };
|
|
@@ -29797,7 +29902,7 @@ function gitDirAt(dotGit) {
|
|
|
29797
29902
|
} else {
|
|
29798
29903
|
const line = firstLine(dotGit);
|
|
29799
29904
|
if (line === null || !line.startsWith(GITDIR_FILE_PREFIX)) return null;
|
|
29800
|
-
gitDir =
|
|
29905
|
+
gitDir = resolve3(dirname3(dotGit), line.slice(GITDIR_FILE_PREFIX.length));
|
|
29801
29906
|
}
|
|
29802
29907
|
} catch {
|
|
29803
29908
|
return null;
|
|
@@ -44177,11 +44282,11 @@ function noRuntimeError(lang) {
|
|
|
44177
44282
|
}
|
|
44178
44283
|
|
|
44179
44284
|
// src/core/sandbox/spawn.ts
|
|
44180
|
-
import { spawn } from "node:child_process";
|
|
44285
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
44181
44286
|
import path2 from "node:path";
|
|
44182
44287
|
|
|
44183
44288
|
// src/core/sandbox/kill.ts
|
|
44184
|
-
import {
|
|
44289
|
+
import { spawn } from "node:child_process";
|
|
44185
44290
|
function signalGroup(pid, signal) {
|
|
44186
44291
|
try {
|
|
44187
44292
|
process.kill(-pid, signal);
|
|
@@ -44195,7 +44300,10 @@ function killTree(pid) {
|
|
|
44195
44300
|
return;
|
|
44196
44301
|
}
|
|
44197
44302
|
try {
|
|
44198
|
-
|
|
44303
|
+
const t = spawn("taskkill", ["/F", "/T", "/PID", String(pid)], { stdio: "ignore", windowsHide: true });
|
|
44304
|
+
t.on("error", () => {
|
|
44305
|
+
});
|
|
44306
|
+
t.unref();
|
|
44199
44307
|
} catch {
|
|
44200
44308
|
}
|
|
44201
44309
|
}
|
|
@@ -44208,13 +44316,13 @@ function startArgv(argv) {
|
|
|
44208
44316
|
return sh === null ? null : [sh, ...argv];
|
|
44209
44317
|
}
|
|
44210
44318
|
function runProcess(argv, o) {
|
|
44211
|
-
return new Promise((
|
|
44319
|
+
return new Promise((resolve10) => {
|
|
44212
44320
|
const isWin2 = process.platform === "win32";
|
|
44213
44321
|
const start = startArgv(argv);
|
|
44214
|
-
if (start === null) return
|
|
44322
|
+
if (start === null) return resolve10(NOT_STARTED);
|
|
44215
44323
|
let child;
|
|
44216
44324
|
try {
|
|
44217
|
-
child =
|
|
44325
|
+
child = spawn2(start[0], start.slice(1), {
|
|
44218
44326
|
cwd: o.cwd,
|
|
44219
44327
|
env: o.env,
|
|
44220
44328
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -44225,14 +44333,20 @@ function runProcess(argv, o) {
|
|
|
44225
44333
|
windowsHide: true
|
|
44226
44334
|
});
|
|
44227
44335
|
} catch {
|
|
44228
|
-
return
|
|
44336
|
+
return resolve10(NOT_STARTED);
|
|
44229
44337
|
}
|
|
44230
44338
|
const stdoutChunks = [];
|
|
44231
44339
|
const stderrChunks = [];
|
|
44232
44340
|
let killedBy = null;
|
|
44233
44341
|
let settled = false;
|
|
44342
|
+
let held = false;
|
|
44343
|
+
let exited = false;
|
|
44344
|
+
let graceTimer;
|
|
44345
|
+
let drainTimer;
|
|
44346
|
+
let stopTimer;
|
|
44234
44347
|
const kill = () => {
|
|
44235
44348
|
if (child.pid !== void 0) killTree(child.pid);
|
|
44349
|
+
if (stopTimer === void 0) stopTimer = setTimeout(() => finishHeld(), KILL_GRACE_MS);
|
|
44236
44350
|
};
|
|
44237
44351
|
const onAbort = () => {
|
|
44238
44352
|
if (killedBy !== null || settled) return;
|
|
@@ -44249,17 +44363,46 @@ function runProcess(argv, o) {
|
|
|
44249
44363
|
if (settled) return;
|
|
44250
44364
|
settled = true;
|
|
44251
44365
|
clearTimeout(timer);
|
|
44366
|
+
clearTimeout(graceTimer);
|
|
44367
|
+
clearTimeout(drainTimer);
|
|
44368
|
+
clearTimeout(stopTimer);
|
|
44252
44369
|
o.signal.removeEventListener("abort", onAbort);
|
|
44253
|
-
|
|
44370
|
+
resolve10({
|
|
44254
44371
|
stdout: Buffer.concat(stdoutChunks),
|
|
44255
44372
|
stderr: Buffer.concat(stderrChunks),
|
|
44256
44373
|
exitCode,
|
|
44257
|
-
killed: killedBy
|
|
44374
|
+
killed: killedBy,
|
|
44375
|
+
...held ? { held: true } : {}
|
|
44258
44376
|
});
|
|
44259
44377
|
};
|
|
44260
|
-
|
|
44261
|
-
|
|
44378
|
+
const finishHeld = () => {
|
|
44379
|
+
if (settled) return;
|
|
44380
|
+
held = exited && killedBy === null;
|
|
44381
|
+
child.stdout.destroy();
|
|
44382
|
+
child.stderr.destroy();
|
|
44383
|
+
if (child.pid !== void 0) killTree(child.pid);
|
|
44384
|
+
settle3(child.exitCode);
|
|
44385
|
+
};
|
|
44386
|
+
const bump = () => {
|
|
44387
|
+
if (!exited || settled) return;
|
|
44388
|
+
clearTimeout(graceTimer);
|
|
44389
|
+
graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
|
|
44390
|
+
};
|
|
44391
|
+
child.stdout.on("data", (chunk) => {
|
|
44392
|
+
stdoutChunks.push(chunk);
|
|
44393
|
+
bump();
|
|
44394
|
+
});
|
|
44395
|
+
child.stderr.on("data", (chunk) => {
|
|
44396
|
+
stderrChunks.push(chunk);
|
|
44397
|
+
bump();
|
|
44398
|
+
});
|
|
44262
44399
|
child.on("close", (code) => settle3(code));
|
|
44400
|
+
child.on("exit", () => {
|
|
44401
|
+
if (settled) return;
|
|
44402
|
+
exited = true;
|
|
44403
|
+
graceTimer = setTimeout(finishHeld, PIPE_EOF_GRACE_MS);
|
|
44404
|
+
drainTimer = setTimeout(finishHeld, PIPE_DRAIN_MAX_MS);
|
|
44405
|
+
});
|
|
44263
44406
|
child.on("error", () => settle3(null));
|
|
44264
44407
|
child.stdin.on("error", () => {
|
|
44265
44408
|
});
|
|
@@ -44671,12 +44814,16 @@ function answer(db, input, scope, ctx, nm, ms, indexed, sort, pick4) {
|
|
|
44671
44814
|
}
|
|
44672
44815
|
async function handler(input, ctx) {
|
|
44673
44816
|
const sort = input.sort ?? "relevance";
|
|
44674
|
-
if (sort === "timeline" && input.offset !==
|
|
44817
|
+
if (sort === "timeline" && (input.offset ?? 0) !== 0) {
|
|
44675
44818
|
return invalid("offset", 'drop offset; page a timeline with "after"');
|
|
44676
44819
|
}
|
|
44677
|
-
if (sort === "relevance" && input.after !==
|
|
44820
|
+
if (sort === "relevance" && (input.after ?? 0) !== 0) {
|
|
44678
44821
|
return invalid("after", 'drop after, or pass sort:"timeline"');
|
|
44679
44822
|
}
|
|
44823
|
+
if (input.source !== void 0 && input.source.trim() === "") {
|
|
44824
|
+
const { source: _blank, ...rest } = input;
|
|
44825
|
+
input = rest;
|
|
44826
|
+
}
|
|
44680
44827
|
const scope = input.scope ?? "worktree";
|
|
44681
44828
|
const db = await openDb(ctx.project, { readOnly: true });
|
|
44682
44829
|
try {
|
|
@@ -44930,7 +45077,7 @@ var ctxBatch = Object.freeze({
|
|
|
44930
45077
|
});
|
|
44931
45078
|
|
|
44932
45079
|
// src/core/tools/doctor.ts
|
|
44933
|
-
import { readdirSync as readdirSync8, readFileSync as
|
|
45080
|
+
import { readdirSync as readdirSync8, readFileSync as readFileSync13, existsSync as existsSync17 } from "node:fs";
|
|
44934
45081
|
import { basename as basename5, join as join17 } from "node:path";
|
|
44935
45082
|
|
|
44936
45083
|
// src/adapters/claude-code.ts
|
|
@@ -45650,6 +45797,7 @@ function readResult6(p) {
|
|
|
45650
45797
|
const text = p.content === void 0 ? "" : typeof p.content === "string" ? p.content : JSON.stringify(p.content);
|
|
45651
45798
|
const info = { isError: p.isError === true, bytes: Buffer.byteLength(text), text };
|
|
45652
45799
|
if (typeof p.exitCode === "number") info.exitCode = p.exitCode;
|
|
45800
|
+
if (p.keep === true) info.keep = true;
|
|
45653
45801
|
return info;
|
|
45654
45802
|
}
|
|
45655
45803
|
function decode11(raw) {
|
|
@@ -45726,6 +45874,11 @@ function decode12(raw) {
|
|
|
45726
45874
|
const event = Object.prototype.hasOwnProperty.call(OPENCODE_EVENTS, native) ? OPENCODE_EVENTS[native] : void 0;
|
|
45727
45875
|
if (event === void 0) throw new Error("opencode: unknown hook event " + String(p.type));
|
|
45728
45876
|
const ev = { event, agent: "opencode", sessionId: String(p.sessionID ?? ""), cwd: String(p.directory ?? "") };
|
|
45877
|
+
if (typeof p.agentID === "string" && p.agentID !== "") {
|
|
45878
|
+
ev.agentId = p.agentID;
|
|
45879
|
+
ev.agentType = p.agentID;
|
|
45880
|
+
}
|
|
45881
|
+
if (Array.isArray(p.agentTools)) ev.agentTools = p.agentTools.filter((t) => typeof t === "string");
|
|
45729
45882
|
if (event === "UserPromptSubmit" && typeof p.message === "string") ev.prompt = p.message;
|
|
45730
45883
|
if (event === "PreToolUse" || event === "PostToolUse") {
|
|
45731
45884
|
const name = String(p.tool ?? "");
|
|
@@ -45746,7 +45899,7 @@ function encode12(ev, d, _extra) {
|
|
|
45746
45899
|
if (ev.event !== "PreToolUse") return { stdout: "", exitCode: 0 };
|
|
45747
45900
|
return { stdout: d.rewritten === void 0 ? d.reason : d.rewritten + "\n" + d.reason, exitCode: 2 };
|
|
45748
45901
|
case "replace":
|
|
45749
|
-
return { stdout: "", exitCode: 0 };
|
|
45902
|
+
return { stdout: ev.event === "PostToolUse" ? d.output : "", exitCode: 0 };
|
|
45750
45903
|
}
|
|
45751
45904
|
}
|
|
45752
45905
|
|
|
@@ -45951,7 +46104,7 @@ var ADAPTERS = Object.freeze([
|
|
|
45951
46104
|
}
|
|
45952
46105
|
]);
|
|
45953
46106
|
var BY_ID = new Map(ADAPTERS.map((r) => [r.id, r]));
|
|
45954
|
-
var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi"]);
|
|
46107
|
+
var REPLACE_ROWS = /* @__PURE__ */ new Set(["claude-code", "gemini", "copilot-cli", "pi", "opencode"]);
|
|
45955
46108
|
function hasReplace(row5) {
|
|
45956
46109
|
return REPLACE_ROWS.has(row5.id);
|
|
45957
46110
|
}
|
|
@@ -45982,8 +46135,31 @@ function ownBundleDir() {
|
|
|
45982
46135
|
}
|
|
45983
46136
|
|
|
45984
46137
|
// 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";
|
|
46138
|
+
import { existsSync as existsSync10, readdirSync as readdirSync7, readFileSync as readFileSync9 } from "node:fs";
|
|
46139
|
+
import { dirname as dirname7, isAbsolute as isAbsolute3, join as join11, resolve as resolve4 } from "node:path";
|
|
46140
|
+
|
|
46141
|
+
// src/core/ops/host-text.ts
|
|
46142
|
+
var BOM_CODE = 65279;
|
|
46143
|
+
var CR_CODE = 13;
|
|
46144
|
+
var CRLF = "\r\n";
|
|
46145
|
+
var LF = "\n";
|
|
46146
|
+
function hostLayout(raw) {
|
|
46147
|
+
let crlf = 0;
|
|
46148
|
+
let lf = 0;
|
|
46149
|
+
for (let i = raw.indexOf(LF); i >= 0; i = raw.indexOf(LF, i + 1)) {
|
|
46150
|
+
if (i > 0 && raw.charCodeAt(i - 1) === CR_CODE) crlf += 1;
|
|
46151
|
+
else lf += 1;
|
|
46152
|
+
}
|
|
46153
|
+
return { bom: raw.length > 0 && raw.charCodeAt(0) === BOM_CODE, crlf: crlf > 0 && crlf >= lf };
|
|
46154
|
+
}
|
|
46155
|
+
function hostText(raw) {
|
|
46156
|
+
const bare2 = raw.length > 0 && raw.charCodeAt(0) === BOM_CODE ? raw.slice(1) : raw;
|
|
46157
|
+
return bare2.indexOf(CRLF) < 0 ? bare2 : bare2.split(CRLF).join(LF);
|
|
46158
|
+
}
|
|
46159
|
+
function withLayout(text, layout) {
|
|
46160
|
+
const eol = layout.crlf ? text.split(LF).join(CRLF) : text;
|
|
46161
|
+
return layout.bom ? String.fromCharCode(BOM_CODE) + eol : eol;
|
|
46162
|
+
}
|
|
45987
46163
|
|
|
45988
46164
|
// src/core/ops/detect-v1.ts
|
|
45989
46165
|
import { existsSync as existsSync7, opendirSync, readdirSync as readdirSync5, readFileSync as readFileSync6 } from "node:fs";
|
|
@@ -48100,29 +48276,6 @@ function atomicWriteFile(file2, text, opts = {}) {
|
|
|
48100
48276
|
}
|
|
48101
48277
|
}
|
|
48102
48278
|
|
|
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
48279
|
// src/core/ops/host-config.ts
|
|
48127
48280
|
function formatOf(path8) {
|
|
48128
48281
|
if (path8.endsWith(JSONC_EXT)) return "jsonc";
|
|
@@ -48669,7 +48822,7 @@ function flatCommands(events, prefix) {
|
|
|
48669
48822
|
return out;
|
|
48670
48823
|
}
|
|
48671
48824
|
var isV1Hook = (cmd) => cmd.includes(SERVER_KEY) && (V1_SCRIPT_NAMES.some((name) => cmd.includes(name)) || cmd.includes(V1_HOOK_COMMAND));
|
|
48672
|
-
var isCodexScript = (cmd) =>
|
|
48825
|
+
var isCodexScript = (cmd) => V1_PATH_SEPS.some((sep3) => V1_CODEX_SCRIPT_NAMES.some((name) => cmd.includes(V1_CODEX_HOOKS_DIR.join(sep3) + sep3 + name)));
|
|
48673
48826
|
function dataDir(dir, reason, out) {
|
|
48674
48827
|
if (existsSync7(dir)) out.push(finding(dir, "", reason));
|
|
48675
48828
|
}
|
|
@@ -48717,8 +48870,7 @@ function scanCodex(agentHome, out) {
|
|
|
48717
48870
|
const config4 = readTomlValue(tomlFile);
|
|
48718
48871
|
for (const span2 of readTomlTables(tomlFile)) {
|
|
48719
48872
|
if (span2.path[0] !== V1_TOML_SECTION_ROOT || span2.path[1] !== SERVER_KEY) continue;
|
|
48720
|
-
if (
|
|
48721
|
-
if (span2.path.length === 3 && span2.path[2] === MCP_ENV_FIELD && isV2McpTable(hostConfigValueAt(config4, span2.path.slice(0, 2)))) continue;
|
|
48873
|
+
if (isV2McpTable(hostConfigValueAt(config4, span2.path.slice(0, 2)))) continue;
|
|
48722
48874
|
out.push(finding(tomlFile, span2.header.trim(), V1_REASON.codexToml));
|
|
48723
48875
|
}
|
|
48724
48876
|
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
@@ -48881,7 +49033,7 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48881
49033
|
|
|
48882
49034
|
// src/core/ops/plugin-root.ts
|
|
48883
49035
|
import { existsSync as existsSync8, readdirSync as readdirSync6, readFileSync as readFileSync7, realpathSync as realpathSync4 } from "node:fs";
|
|
48884
|
-
import { dirname as dirname6, isAbsolute, join as join10, sep as sep2 } from "node:path";
|
|
49036
|
+
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join10, sep as sep2 } from "node:path";
|
|
48885
49037
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
48886
49038
|
function missing(agent, path8) {
|
|
48887
49039
|
return new CtxError("PLUGIN_ROOT_MISSING", { agent, path: path8 });
|
|
@@ -48993,7 +49145,7 @@ function configEntryRoot(adapter, env) {
|
|
|
48993
49145
|
const value = parseHostConfig(adapter.id, file2, current.text, current.format);
|
|
48994
49146
|
const args = hostConfigValueAt(value, [...spec.key, MCP_ARGS_FIELD]);
|
|
48995
49147
|
const script = Array.isArray(args) ? args[0] : void 0;
|
|
48996
|
-
if (typeof script !== "string" || !
|
|
49148
|
+
if (typeof script !== "string" || !isAbsolute2(script)) throw missing(adapter.id, file2);
|
|
48997
49149
|
return dirname6(script);
|
|
48998
49150
|
}
|
|
48999
49151
|
function candidate(adapter, env, worktree) {
|
|
@@ -49213,11 +49365,122 @@ function nativeMcpWrong(dir, row5) {
|
|
|
49213
49365
|
return true;
|
|
49214
49366
|
}
|
|
49215
49367
|
}
|
|
49368
|
+
function opencodeEntrySpec(entry) {
|
|
49369
|
+
return isObject4(entry) ? entry[OPENCODE_PACKAGE_FIELD] : Array.isArray(entry) ? entry[0] : entry;
|
|
49370
|
+
}
|
|
49371
|
+
function isNativeOpencodeEntry(entry, key) {
|
|
49372
|
+
const spec = opencodeEntrySpec(entry);
|
|
49373
|
+
if (typeof spec !== "string") return false;
|
|
49374
|
+
return spec.startsWith(OPENCODE_NPM_SPEC_PREFIX) || key === OPENCODE_PLUGINS_KEY && spec === SERVER_KEY;
|
|
49375
|
+
}
|
|
49216
49376
|
function isOwnOpencodeEntry(entry, key, own4) {
|
|
49217
|
-
const spec =
|
|
49377
|
+
const spec = opencodeEntrySpec(entry);
|
|
49218
49378
|
if (typeof spec !== "string") return false;
|
|
49219
|
-
|
|
49220
|
-
|
|
49379
|
+
return spec === OPENCODE_GIT_SPEC || own4.includes(spec) || isNativeOpencodeEntry(entry, key);
|
|
49380
|
+
}
|
|
49381
|
+
function stringLiterals(src) {
|
|
49382
|
+
const out = [];
|
|
49383
|
+
let i = 0;
|
|
49384
|
+
while (i < src.length) {
|
|
49385
|
+
const c = src[i];
|
|
49386
|
+
if (c === "/" && src[i + 1] === "/") {
|
|
49387
|
+
const n = src.indexOf("\n", i);
|
|
49388
|
+
i = n < 0 ? src.length : n;
|
|
49389
|
+
continue;
|
|
49390
|
+
}
|
|
49391
|
+
if (c === "/" && src[i + 1] === "*") {
|
|
49392
|
+
const n = src.indexOf("*/", i + 2);
|
|
49393
|
+
i = n < 0 ? src.length : n + 2;
|
|
49394
|
+
continue;
|
|
49395
|
+
}
|
|
49396
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
49397
|
+
let j = i + 1;
|
|
49398
|
+
let s = "";
|
|
49399
|
+
while (j < src.length && src[j] !== c) {
|
|
49400
|
+
if (src[j] === "\\") {
|
|
49401
|
+
s += src[j + 1] ?? "";
|
|
49402
|
+
j += 2;
|
|
49403
|
+
continue;
|
|
49404
|
+
}
|
|
49405
|
+
s += src[j];
|
|
49406
|
+
j++;
|
|
49407
|
+
}
|
|
49408
|
+
out.push(s);
|
|
49409
|
+
i = j + 1;
|
|
49410
|
+
continue;
|
|
49411
|
+
}
|
|
49412
|
+
i++;
|
|
49413
|
+
}
|
|
49414
|
+
return out;
|
|
49415
|
+
}
|
|
49416
|
+
var OPENCODE_PLUGINS_DIR = "plugins";
|
|
49417
|
+
var OPENCODE_PROJECT_DIR = ".opencode";
|
|
49418
|
+
var OPENCODE_PLUGIN_EXTS = [".js", ".mjs", ".ts"];
|
|
49419
|
+
var OPENCODE_PLUGIN_INDEX = "index";
|
|
49420
|
+
var OPENCODE_DIR_FILE_MAX = 64 * 1024;
|
|
49421
|
+
var OWN_PLUGIN_MODULES = [SERVER_KEY, `${SERVER_KEY}/server`];
|
|
49422
|
+
var FILE_URL_PREFIX = "file://";
|
|
49423
|
+
var NODE_MODULES_DIR = "node_modules";
|
|
49424
|
+
var PACKAGE_JSON_FILE = "package.json";
|
|
49425
|
+
var OPENCODE_PACKAGE_DIR_HINT = `${NODE_MODULES_DIR}/${SERVER_KEY}`;
|
|
49426
|
+
function opencodePluginDirs(configDir, worktree) {
|
|
49427
|
+
return [configDir, opencodeProjectDir(worktree)];
|
|
49428
|
+
}
|
|
49429
|
+
function opencodeProjectDir(worktree) {
|
|
49430
|
+
return join11(worktree, OPENCODE_PROJECT_DIR);
|
|
49431
|
+
}
|
|
49432
|
+
function packageResolves(fromDir) {
|
|
49433
|
+
for (let d = fromDir; ; d = dirname7(d)) {
|
|
49434
|
+
if (existsSync10(join11(d, NODE_MODULES_DIR, SERVER_KEY, PACKAGE_JSON_FILE))) return true;
|
|
49435
|
+
if (dirname7(d) === d) return false;
|
|
49436
|
+
}
|
|
49437
|
+
}
|
|
49438
|
+
function opencodeDirPlugins(dirs) {
|
|
49439
|
+
const bundle = opencodePluginFile();
|
|
49440
|
+
const ownFile = join11(bundle, ...OPENCODE_PLUGIN_PATH).split("\\").join("/");
|
|
49441
|
+
const isModule = (p) => OWN_PLUGIN_MODULES.includes(p);
|
|
49442
|
+
const isPath = (p) => {
|
|
49443
|
+
if (p === ownFile || p === `${FILE_URL_PREFIX}${ownFile}`) return true;
|
|
49444
|
+
const seg = p.split("/");
|
|
49445
|
+
const n = seg.length;
|
|
49446
|
+
return n >= 3 && seg[n - 1] === "plugin.js" && seg[n - 2] === "opencode" && seg[n - 3] === SERVER_KEY;
|
|
49447
|
+
};
|
|
49448
|
+
const out = [];
|
|
49449
|
+
for (const dir of dirs) {
|
|
49450
|
+
const pdir = join11(dir, OPENCODE_PLUGINS_DIR);
|
|
49451
|
+
let names;
|
|
49452
|
+
try {
|
|
49453
|
+
names = readdirSync7(pdir);
|
|
49454
|
+
} catch {
|
|
49455
|
+
continue;
|
|
49456
|
+
}
|
|
49457
|
+
for (const name of names) {
|
|
49458
|
+
const loose = OPENCODE_PLUGIN_EXTS.some((x) => name.endsWith(x)) ? [join11(pdir, name)] : [];
|
|
49459
|
+
const files = [...loose, ...OPENCODE_PLUGIN_EXTS.map((x) => join11(pdir, name, `${OPENCODE_PLUGIN_INDEX}${x}`))];
|
|
49460
|
+
for (const f of files) {
|
|
49461
|
+
let text;
|
|
49462
|
+
try {
|
|
49463
|
+
const b = readFileSync9(f);
|
|
49464
|
+
if (b.length > OPENCODE_DIR_FILE_MAX) continue;
|
|
49465
|
+
text = b.toString("utf8");
|
|
49466
|
+
} catch {
|
|
49467
|
+
continue;
|
|
49468
|
+
}
|
|
49469
|
+
const lits = stringLiterals(text).map((s) => s.split("\\").join("/")).filter((p) => isModule(p) || isPath(p));
|
|
49470
|
+
if (!lits.length) continue;
|
|
49471
|
+
const loads = lits.some((p) => {
|
|
49472
|
+
if (isModule(p)) return packageResolves(dirname7(f));
|
|
49473
|
+
const bare2 = p.startsWith(FILE_URL_PREFIX) ? p.slice(FILE_URL_PREFIX.length) : p;
|
|
49474
|
+
return existsSync10(isAbsolute3(bare2) ? bare2 : resolve4(dirname7(f), bare2));
|
|
49475
|
+
});
|
|
49476
|
+
out.push({ file: f, loads });
|
|
49477
|
+
}
|
|
49478
|
+
}
|
|
49479
|
+
}
|
|
49480
|
+
return out;
|
|
49481
|
+
}
|
|
49482
|
+
function opencodeDirPlugin(dirs) {
|
|
49483
|
+
return opencodeDirPlugins(dirs).find((p) => p.loads)?.file;
|
|
49221
49484
|
}
|
|
49222
49485
|
function opencodeMcpOwn(entry) {
|
|
49223
49486
|
if (!isObject4(entry)) return false;
|
|
@@ -49225,14 +49488,22 @@ function opencodeMcpOwn(entry) {
|
|
|
49225
49488
|
const [node3, script, flag, agent] = cmd;
|
|
49226
49489
|
return isNodeCommand(node3) && typeof script === "string" && lastSegment(script) === SERVER_ENTRY_FILE && flag === AGENT_ARG && agent === "opencode";
|
|
49227
49490
|
}
|
|
49228
|
-
function
|
|
49229
|
-
|
|
49491
|
+
function opencodeFileValue(file2) {
|
|
49492
|
+
if (!existsSync10(file2)) return {};
|
|
49493
|
+
return parseHostConfig("opencode", file2, hostText(readFileSync9(file2, "utf8")), "jsonc");
|
|
49494
|
+
}
|
|
49495
|
+
function opencodeValueListed(value) {
|
|
49230
49496
|
const bundle = opencodePluginFile();
|
|
49231
49497
|
const own4 = [bundle, join11(bundle, ...OPENCODE_PLUGIN_PATH)];
|
|
49232
49498
|
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
49499
|
const mcp = isObject4(value) && isObject4(value.mcp) ? value.mcp : {};
|
|
49234
49500
|
return opencodeMcpOwn(mcp[SERVER_KEY]) || isObject4(mcp.servers) && opencodeMcpOwn(mcp.servers[SERVER_KEY]);
|
|
49235
49501
|
}
|
|
49502
|
+
function opencodeListed(file2, worktree) {
|
|
49503
|
+
const dirs = [dirname7(file2), worktree];
|
|
49504
|
+
if (dirs.some((dir) => OPENCODE_CONFIG_FILES.some((name) => opencodeValueListed(opencodeFileValue(join11(dir, name)))))) return true;
|
|
49505
|
+
return opencodeDirPlugin(opencodePluginDirs(dirname7(file2), worktree)) !== void 0;
|
|
49506
|
+
}
|
|
49236
49507
|
function mcpWrong(row5, home, env, worktree) {
|
|
49237
49508
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
49238
49509
|
if (native !== null) return nativeMcpWrong(native, row5);
|
|
@@ -49242,7 +49513,7 @@ function mcpWrong(row5, home, env, worktree) {
|
|
|
49242
49513
|
resolvePluginRoot(row5, env, worktree);
|
|
49243
49514
|
return false;
|
|
49244
49515
|
}
|
|
49245
|
-
if (row5.id === "opencode") return !opencodeListed(file2);
|
|
49516
|
+
if (row5.id === "opencode") return !opencodeListed(file2, worktree);
|
|
49246
49517
|
const cur = readHostConfig(row5.id, file2);
|
|
49247
49518
|
return mergeOwnEntries(row5.id, cur.text, cur.format, row5, { nodePath: true, listEntries: [opencodePluginFile()] }).edits.length > 0;
|
|
49248
49519
|
} catch {
|
|
@@ -49453,8 +49724,8 @@ async function checkIndex(project) {
|
|
|
49453
49724
|
}
|
|
49454
49725
|
|
|
49455
49726
|
// src/core/ops/doctor-env.ts
|
|
49456
|
-
import { existsSync as existsSync12, readFileSync as
|
|
49457
|
-
import { isAbsolute as
|
|
49727
|
+
import { existsSync as existsSync12, readFileSync as readFileSync10, realpathSync as realpathSync6 } from "node:fs";
|
|
49728
|
+
import { isAbsolute as isAbsolute4, join as join12, relative as relative2 } from "node:path";
|
|
49458
49729
|
function pass3(id, detail = DOCTOR_PASS_DETAIL) {
|
|
49459
49730
|
return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
|
|
49460
49731
|
}
|
|
@@ -49464,9 +49735,12 @@ function unknown5(id, detail, fixCommand) {
|
|
|
49464
49735
|
function fail3(id, detail, fixCommand) {
|
|
49465
49736
|
return { id, label: DOCTOR_LABEL[id], status: "FAIL", detail, fixCommand };
|
|
49466
49737
|
}
|
|
49738
|
+
function warn(id, detail, fixCommand) {
|
|
49739
|
+
return { id, label: DOCTOR_LABEL[id], status: "WARN", detail, fixCommand };
|
|
49740
|
+
}
|
|
49467
49741
|
function bundleVersion(bundleDir2) {
|
|
49468
49742
|
try {
|
|
49469
|
-
const v = JSON.parse(
|
|
49743
|
+
const v = JSON.parse(readFileSync10(join12(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
|
|
49470
49744
|
return typeof v === "string" && v !== "" ? v : void 0;
|
|
49471
49745
|
} catch {
|
|
49472
49746
|
return void 0;
|
|
@@ -49550,20 +49824,21 @@ function highestTag(stdout, tag) {
|
|
|
49550
49824
|
}
|
|
49551
49825
|
return best;
|
|
49552
49826
|
}
|
|
49553
|
-
function versionRow(head, installed, tag, source, latest, tail) {
|
|
49827
|
+
function versionRow(head, installed, tag, source, latest, tail, update) {
|
|
49554
49828
|
const cmp = compareVersions(installed, latest) ?? (installed === latest ? 0 : -1);
|
|
49555
49829
|
if (cmp === 0) return pass3("D1", head + D1_LATEST_PASS(tag, source) + tail);
|
|
49556
49830
|
if (cmp > 0) return pass3("D1", head + D1_LATEST_AHEAD(tag, source, latest) + tail);
|
|
49557
|
-
return
|
|
49831
|
+
return warn("D1", head + D1_LATEST_UPDATE(tag, source, latest) + tail, update);
|
|
49558
49832
|
}
|
|
49559
49833
|
async function checkVersion(i) {
|
|
49560
49834
|
if (i.bundleSha === void 0) return unknown5("D1", D1_DEV_BUILD_DETAIL);
|
|
49561
49835
|
const head = D1_PREFIX(i.version, i.bundleSha) + ": ";
|
|
49562
49836
|
if (i.version === void 0) return unknown5("D1", head + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
|
|
49563
49837
|
const tag = channelOf(i.version);
|
|
49838
|
+
const update = i.updateCommand ?? DOCTOR_FIX_UPGRADE;
|
|
49564
49839
|
const git2 = findRuntime(GIT_BIN, i.env);
|
|
49565
49840
|
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, "");
|
|
49841
|
+
if (npm.ok) return versionRow(head, i.version, tag, D1_SOURCE_NPM, npm.version, "", update);
|
|
49567
49842
|
let cause = D1_GIT_MISSING;
|
|
49568
49843
|
if (git2 !== null) {
|
|
49569
49844
|
const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
|
|
@@ -49574,7 +49849,7 @@ async function checkVersion(i) {
|
|
|
49574
49849
|
});
|
|
49575
49850
|
if (r.exitCode === 0 && r.killed === null) {
|
|
49576
49851
|
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);
|
|
49852
|
+
if (latest !== void 0) return versionRow(head, i.version, tag, D1_SOURCE_TAGS, latest, D1_CAUSE_JOIN + npm.cause, update);
|
|
49578
49853
|
cause = D1_GIT_NO_TAG(tag);
|
|
49579
49854
|
} else {
|
|
49580
49855
|
cause = gitCause(r, i.timeoutMs);
|
|
@@ -49610,15 +49885,16 @@ async function checkNode(i) {
|
|
|
49610
49885
|
if (!await sqliteLoads()) return fail3("D2", withBun(D2_SQLITE_DETAIL), D2_SQLITE_FIX);
|
|
49611
49886
|
return pass3("D2", bun.length === 0 ? DOCTOR_PASS_DETAIL : bun.join(D4_REASON_JOIN));
|
|
49612
49887
|
}
|
|
49613
|
-
function checkMcp(ctx) {
|
|
49888
|
+
function checkMcp(ctx, adapter) {
|
|
49614
49889
|
const named2 = ctx.clientInfo !== void 0 && ctx.clientInfo.name !== "";
|
|
49615
49890
|
const versioned = ctx.protocolVersion !== void 0 && ctx.protocolVersion !== "";
|
|
49616
|
-
|
|
49891
|
+
if (named2 || versioned) return pass3("D6");
|
|
49892
|
+
return adapter?.installMode === "in-process" ? pass3("D6", D6_IN_PROCESS_DETAIL) : unknown5("D6", D6_UNKNOWN_DETAIL);
|
|
49617
49893
|
}
|
|
49618
49894
|
function piCwdInside(worktree, piCwd) {
|
|
49619
49895
|
if (piCwd === void 0 || !existsSync12(piCwd)) return false;
|
|
49620
49896
|
const rel = relative2(worktree, realpathSync6.native(piCwd));
|
|
49621
|
-
return rel === "" || !rel.startsWith("..") && !
|
|
49897
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute4(rel);
|
|
49622
49898
|
}
|
|
49623
49899
|
function checkProject(i) {
|
|
49624
49900
|
const bad = fail3("D7", D7_DETAIL(i.project.source), D7_FIX);
|
|
@@ -49639,7 +49915,7 @@ function checkShell(env) {
|
|
|
49639
49915
|
}
|
|
49640
49916
|
|
|
49641
49917
|
// src/core/ops/doctor-hook.ts
|
|
49642
|
-
import { existsSync as existsSync14, mkdirSync as mkdirSync5, mkdtempSync, readFileSync as
|
|
49918
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync5, mkdtempSync, readFileSync as readFileSync11, realpathSync as realpathSync8, rmSync as rmSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
49643
49919
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
49644
49920
|
import path7 from "node:path";
|
|
49645
49921
|
|
|
@@ -51402,7 +51678,7 @@ function hasType(v, t) {
|
|
|
51402
51678
|
function same(a, b) {
|
|
51403
51679
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
51404
51680
|
}
|
|
51405
|
-
function
|
|
51681
|
+
function resolve5(root, ref) {
|
|
51406
51682
|
const parts = ref.split("/");
|
|
51407
51683
|
if (parts[0] !== "#") throw new Error(`hook-shape: only local $ref is read, got ${ref}`);
|
|
51408
51684
|
let at = root;
|
|
@@ -51415,7 +51691,7 @@ function shapeErrors(schema, value, root = schema, at = "$") {
|
|
|
51415
51691
|
if (!NOTE_KEYS.has(k) && !RULE_KEYS.has(k)) throw new Error(`hook-shape: keyword ${k} at ${at} is not read by the checker`);
|
|
51416
51692
|
}
|
|
51417
51693
|
const errs = [];
|
|
51418
|
-
if (typeof schema.$ref === "string") errs.push(...shapeErrors(
|
|
51694
|
+
if (typeof schema.$ref === "string") errs.push(...shapeErrors(resolve5(root, schema.$ref), value, root, at));
|
|
51419
51695
|
if (Array.isArray(schema.allOf)) for (const s of schema.allOf) errs.push(...shapeErrors(s, value, root, at));
|
|
51420
51696
|
if (schema.type !== void 0) {
|
|
51421
51697
|
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
@@ -51467,7 +51743,7 @@ function nodeLaunch(env, host = { bun: process.versions.bun, execPath: process.e
|
|
|
51467
51743
|
import { createHash } from "node:crypto";
|
|
51468
51744
|
import { existsSync as existsSync13, realpathSync as realpathSync7 } from "node:fs";
|
|
51469
51745
|
import path6 from "node:path";
|
|
51470
|
-
import { spawn as
|
|
51746
|
+
import { spawn as spawn3, spawnSync as spawnSync2 } from "node:child_process";
|
|
51471
51747
|
|
|
51472
51748
|
// src/setup/spawn-bin.ts
|
|
51473
51749
|
import { spawnSync } from "node:child_process";
|
|
@@ -51582,24 +51858,24 @@ function pluginHooksFromReply(m, pluginId) {
|
|
|
51582
51858
|
function askPluginHooks(env, pluginId, cwd) {
|
|
51583
51859
|
const bin = whichBin("codex", env);
|
|
51584
51860
|
if (!bin) return Promise.resolve({ kind: "absent" });
|
|
51585
|
-
return new Promise((
|
|
51861
|
+
return new Promise((resolve10) => {
|
|
51586
51862
|
let asked;
|
|
51587
51863
|
const done_ = (hooks) => hooks === void 0 ? { kind: "silent" } : { kind: "list", hooks, codexHome: asked };
|
|
51588
51864
|
let f;
|
|
51589
51865
|
try {
|
|
51590
51866
|
f = spawnForm(bin, ["app-server"], env);
|
|
51591
51867
|
} catch {
|
|
51592
|
-
|
|
51868
|
+
resolve10({ kind: "silent" });
|
|
51593
51869
|
return;
|
|
51594
51870
|
}
|
|
51595
|
-
const child =
|
|
51871
|
+
const child = spawn3(f.command, f.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f.windowsVerbatimArguments, windowsHide: true });
|
|
51596
51872
|
let buf = "";
|
|
51597
51873
|
let done = false;
|
|
51598
51874
|
let exited = false;
|
|
51599
51875
|
let result;
|
|
51600
51876
|
const settle3 = () => {
|
|
51601
51877
|
clearTimeout(grace);
|
|
51602
|
-
|
|
51878
|
+
resolve10(done_(result));
|
|
51603
51879
|
};
|
|
51604
51880
|
let grace;
|
|
51605
51881
|
const finish2 = (v) => {
|
|
@@ -51691,7 +51967,7 @@ function loadFixture(bundleDir2, agent) {
|
|
|
51691
51967
|
if (!existsSync14(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
|
|
51692
51968
|
let all;
|
|
51693
51969
|
try {
|
|
51694
|
-
all = JSON.parse(hostText(
|
|
51970
|
+
all = JSON.parse(hostText(readFileSync11(file2, "utf8")));
|
|
51695
51971
|
} catch (err) {
|
|
51696
51972
|
return { cause: D5_FIXTURE_PARSE(file2, err instanceof Error ? err.message : String(err)) };
|
|
51697
51973
|
}
|
|
@@ -51958,14 +52234,14 @@ async function checkHookRoundTrip(i) {
|
|
|
51958
52234
|
}
|
|
51959
52235
|
|
|
51960
52236
|
// src/core/hooks/fallback.ts
|
|
51961
|
-
import { join as join14, resolve as
|
|
52237
|
+
import { join as join14, resolve as resolve7 } from "node:path";
|
|
51962
52238
|
|
|
51963
52239
|
// src/core/policy/read-media.ts
|
|
51964
52240
|
import { extname } from "node:path";
|
|
51965
52241
|
var { closeSync, openSync, readSync } = process.getBuiltinModule("node:fs");
|
|
51966
52242
|
|
|
51967
52243
|
// src/core/policy/own-file.ts
|
|
51968
|
-
import { extname as extname2, join as join13 } from "node:path";
|
|
52244
|
+
import { extname as extname2, join as join13, resolve as resolve6 } from "node:path";
|
|
51969
52245
|
|
|
51970
52246
|
// src/core/hooks/fallback.ts
|
|
51971
52247
|
var fs = process.getBuiltinModule("node:fs");
|
|
@@ -52007,7 +52283,7 @@ function lastHookError(env) {
|
|
|
52007
52283
|
|
|
52008
52284
|
// src/core/ops/db-heal.ts
|
|
52009
52285
|
import { existsSync as existsSync15, mkdirSync as mkdirSync6, rmSync as rmSync5 } from "node:fs";
|
|
52010
|
-
import { basename as basename4, dirname as
|
|
52286
|
+
import { basename as basename4, dirname as dirname8, join as join15 } from "node:path";
|
|
52011
52287
|
function integrityOk2(rows) {
|
|
52012
52288
|
return rows.length === 1 && rows[0].integrity_check === INTEGRITY_OK;
|
|
52013
52289
|
}
|
|
@@ -52079,7 +52355,7 @@ async function healOrphan(project, files, row5) {
|
|
|
52079
52355
|
const moved = [];
|
|
52080
52356
|
let dir = "";
|
|
52081
52357
|
try {
|
|
52082
|
-
dir = makeOrphanDir(
|
|
52358
|
+
dir = makeOrphanDir(dirname8(project.dbPath));
|
|
52083
52359
|
for (const f of files) {
|
|
52084
52360
|
const to = join15(dir, basename4(f.path));
|
|
52085
52361
|
renameWithRetry(f.path, to);
|
|
@@ -52146,9 +52422,40 @@ function buildReportHead(input) {
|
|
|
52146
52422
|
return lines.concat(tail).join("\n");
|
|
52147
52423
|
}
|
|
52148
52424
|
|
|
52425
|
+
// src/core/ops/unsupported-host.ts
|
|
52426
|
+
var SUPPORTED_AGENTS_LINE = `Supported agents: ${AGENT_IDS.join(", ")} (${SUPPORTED_AGENTS_DOCS_URL}).`;
|
|
52427
|
+
function UNSUPPORTED_HOST_LINE(name) {
|
|
52428
|
+
return `${name} is not a supported host today. The MCP server runs here; hooks are not checked. ${SUPPORTED_AGENTS_LINE}`;
|
|
52429
|
+
}
|
|
52430
|
+
function segmentsOf(dir) {
|
|
52431
|
+
let parts = [dir];
|
|
52432
|
+
for (const sep3 of V1_PATH_SEPS) parts = parts.flatMap((p) => p.split(sep3));
|
|
52433
|
+
return parts;
|
|
52434
|
+
}
|
|
52435
|
+
function hasRun(parts, run) {
|
|
52436
|
+
for (let i = 0; i + run.length <= parts.length; i++) if (run.every((seg, k) => parts[i + k] === seg)) return true;
|
|
52437
|
+
return false;
|
|
52438
|
+
}
|
|
52439
|
+
function unsupportedHostOf(sig) {
|
|
52440
|
+
if (sig.clientName !== void 0 && sig.clientName !== "") {
|
|
52441
|
+
const n = sig.clientName.toLowerCase();
|
|
52442
|
+
const hit = UNSUPPORTED_HOSTS.find((h) => h.clientNames.includes(n));
|
|
52443
|
+
if (hit !== void 0) return hit;
|
|
52444
|
+
}
|
|
52445
|
+
if (sig.bundleDir !== void 0) {
|
|
52446
|
+
const parts = segmentsOf(sig.bundleDir);
|
|
52447
|
+
const hit = UNSUPPORTED_HOSTS.find((h) => h.pluginPaths.some((p) => hasRun(parts, p)));
|
|
52448
|
+
if (hit !== void 0) return hit;
|
|
52449
|
+
}
|
|
52450
|
+
if (sig.clientName !== void 0 && sig.clientName !== "") return void 0;
|
|
52451
|
+
const env = sig.env;
|
|
52452
|
+
if (env === void 0) return void 0;
|
|
52453
|
+
return UNSUPPORTED_HOSTS.find((h) => h.envVars.some((v) => env[v] !== void 0 && env[v] !== ""));
|
|
52454
|
+
}
|
|
52455
|
+
|
|
52149
52456
|
// src/core/ops/doctor-issue.ts
|
|
52150
52457
|
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
|
|
52458
|
+
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
52459
|
import { delimiter, join as join16 } from "node:path";
|
|
52153
52460
|
var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
|
|
52154
52461
|
function tildeOf(env) {
|
|
@@ -52251,7 +52558,7 @@ function agentConfig(adapter, env, worktree) {
|
|
|
52251
52558
|
}
|
|
52252
52559
|
let text = "";
|
|
52253
52560
|
try {
|
|
52254
|
-
text =
|
|
52561
|
+
text = readFileSync12(f.path, "utf8");
|
|
52255
52562
|
} catch (err) {
|
|
52256
52563
|
out.push(`${f.label}: ${f.path} (read: ${err instanceof Error ? err.message : String(err)})`);
|
|
52257
52564
|
continue;
|
|
@@ -52265,12 +52572,13 @@ function agentConfig(adapter, env, worktree) {
|
|
|
52265
52572
|
function failing(rows) {
|
|
52266
52573
|
return rows.filter((r) => r.status === "FAIL");
|
|
52267
52574
|
}
|
|
52268
|
-
function issueTitle(agent, rows) {
|
|
52269
|
-
return `ctx_doctor ${agent}: ${failing(rows).map((r) => `${r.id} ${r.label}`).join(", ")} FAIL`;
|
|
52575
|
+
function issueTitle(agent, rows, other) {
|
|
52576
|
+
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
52577
|
}
|
|
52271
|
-
function summaryOf(agent, rows) {
|
|
52578
|
+
function summaryOf(agent, rows, other) {
|
|
52272
52579
|
const f = failing(rows)[0];
|
|
52273
|
-
|
|
52580
|
+
const tag = other === void 0 ? "" : `${other.name} is not a supported host today. `;
|
|
52581
|
+
return tag + (f === void 0 ? `ctx_doctor ${agent}` : `${f.id} ${f.label} FAIL on ${agent}: ${f.detail}`);
|
|
52274
52582
|
}
|
|
52275
52583
|
async function buildIssueBody(i) {
|
|
52276
52584
|
const tilde = tildeOf(i.env);
|
|
@@ -52280,7 +52588,7 @@ async function buildIssueBody(i) {
|
|
|
52280
52588
|
const envNames = DOCTOR_ENV_NAMES.map((n) => i.env[n] === void 0 ? `${n} (unset)` : `${n}=${i.env[n]}`);
|
|
52281
52589
|
const pathTools = DOCTOR_PATH_TOOLS.map((t) => `PATH holds ${t}: ${onPath(i.env, t).join(", ") || "(absent)"}`);
|
|
52282
52590
|
const sections = {
|
|
52283
|
-
"Summary": [summaryOf(agent, i.rows)],
|
|
52591
|
+
"Summary": [summaryOf(agent, i.rows, i.unsupported)],
|
|
52284
52592
|
"ctx-report": [i.table],
|
|
52285
52593
|
"What happened": [
|
|
52286
52594
|
"Rows that need a look:",
|
|
@@ -52326,9 +52634,9 @@ async function writeIssueReport(i) {
|
|
|
52326
52634
|
const file2 = join16(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
|
|
52327
52635
|
writeFileSync4(file2, body);
|
|
52328
52636
|
const shown2 = tilde(file2);
|
|
52329
|
-
const title = issueTitle(i.adapter.id, i.rows);
|
|
52637
|
+
const title = issueTitle(i.adapter.id, i.rows, i.unsupported);
|
|
52330
52638
|
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];
|
|
52639
|
+
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
52640
|
}
|
|
52333
52641
|
function formUrl(title, summary) {
|
|
52334
52642
|
const base = `${ISSUE_FORM_URL}&title=${encodeURIComponent(title)}`;
|
|
@@ -52376,6 +52684,12 @@ async function codexDb(ctx, adapter) {
|
|
|
52376
52684
|
return null;
|
|
52377
52685
|
}
|
|
52378
52686
|
}
|
|
52687
|
+
function d1UpdateCommand(agent, env, other) {
|
|
52688
|
+
return other === void 0 ? hostUpdateCommand(agent, env) : UNSUPPORTED_HOST_LINE(other.name);
|
|
52689
|
+
}
|
|
52690
|
+
function unsupportedRow(id, h) {
|
|
52691
|
+
return { id, label: DOCTOR_LABEL[id], status: "WARN", detail: UNSUPPORTED_HOST_LINE(h.name) };
|
|
52692
|
+
}
|
|
52379
52693
|
async function hookRow(ctx, adapter, host) {
|
|
52380
52694
|
const db = await codexDb(ctx, adapter);
|
|
52381
52695
|
const runStart = Date.now();
|
|
@@ -52403,7 +52717,7 @@ function ownServerId(configDir, projectKey) {
|
|
|
52403
52717
|
if (!existsSync17(dir)) return "";
|
|
52404
52718
|
for (const name of readdirSync8(dir)) {
|
|
52405
52719
|
if (!name.endsWith(OWNER_PID_EXT)) continue;
|
|
52406
|
-
if (
|
|
52720
|
+
if (readFileSync13(join17(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
|
|
52407
52721
|
}
|
|
52408
52722
|
return "";
|
|
52409
52723
|
}
|
|
@@ -52411,16 +52725,18 @@ async function runDoctorChecks(ctx, adapter, host0) {
|
|
|
52411
52725
|
const host = adapter.id === "codex" ? { ...host0, env: { ...host0.env, CODEX_HOME: codexRunDirOf(host0.env, homeDirOf(host0.env) ?? "", host0.bundleDir) } } : host0;
|
|
52412
52726
|
const env = host.env;
|
|
52413
52727
|
const project = ctx.project;
|
|
52728
|
+
const other = adapter.installMode === "in-process" ? void 0 : unsupportedHostOf({ clientName: ctx.clientInfo?.name, bundleDir: host.bundleDir, env });
|
|
52414
52729
|
let integrityFailed = false;
|
|
52415
52730
|
let orphan = [];
|
|
52416
52731
|
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 }),
|
|
52732
|
+
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
52733
|
D2: () => checkNode({ nodeVersion: process.version, bunVersion: process.versions.bun }),
|
|
52419
|
-
D3: () => checkHostConfig(adapter, env, project.worktree),
|
|
52734
|
+
D3: () => other !== void 0 ? unsupportedRow("D3", other) : checkHostConfig(adapter, env, project.worktree),
|
|
52735
|
+
// D-UNSUPPORTED-HOSTS-1
|
|
52420
52736
|
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),
|
|
52737
|
+
D5: () => other !== void 0 ? unsupportedRow("D5", other) : hookRow(ctx, adapter, host),
|
|
52422
52738
|
D5b: () => checkDoubleFire(adapter.id, project.worktree),
|
|
52423
|
-
D6: () => checkMcp(ctx),
|
|
52739
|
+
D6: () => checkMcp(ctx, adapter),
|
|
52424
52740
|
D7: () => checkProject({ project, adapter, piCwd: host.piCwd }),
|
|
52425
52741
|
D8: async () => {
|
|
52426
52742
|
const r = await checkDb(project);
|
|
@@ -52467,7 +52783,7 @@ async function doctorReply(ctx, host) {
|
|
|
52467
52783
|
let notes = [];
|
|
52468
52784
|
if (failed) {
|
|
52469
52785
|
try {
|
|
52470
|
-
notes = await writeIssueReport({ ctx, adapter, env: host.env, bundleDir: host.bundleDir, rows, envLine: envLine2, table: table3 });
|
|
52786
|
+
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
52787
|
} catch (err) {
|
|
52472
52788
|
notes = [`Report file: ${lineOf(err)}`];
|
|
52473
52789
|
}
|
|
@@ -52501,7 +52817,7 @@ var ctxDoctor = Object.freeze({
|
|
|
52501
52817
|
// src/core/tools/execute.ts
|
|
52502
52818
|
import { existsSync as existsSync18, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync5 } from "node:fs";
|
|
52503
52819
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
52504
|
-
import { dirname as
|
|
52820
|
+
import { dirname as dirname10, join as join18, parse as parse5, resolve as resolve8 } from "node:path";
|
|
52505
52821
|
|
|
52506
52822
|
// src/core/index/select.ts
|
|
52507
52823
|
var READ_CHUNKS = "SELECT ord, body FROM chunks WHERE source_id = ?";
|
|
@@ -52623,7 +52939,7 @@ function schemaLine(issue4) {
|
|
|
52623
52939
|
}
|
|
52624
52940
|
function fileError(given, abs, root) {
|
|
52625
52941
|
let dir = abs;
|
|
52626
|
-
while (!existsSync18(dir) &&
|
|
52942
|
+
while (!existsSync18(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
|
|
52627
52943
|
if (isInside(root, dir)) return null;
|
|
52628
52944
|
return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
|
|
52629
52945
|
}
|
|
@@ -52657,7 +52973,7 @@ function spawnFailed(argv0, cwd) {
|
|
|
52657
52973
|
}
|
|
52658
52974
|
async function finish(input, ctx, r, exitCode, journal) {
|
|
52659
52975
|
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") : "");
|
|
52976
|
+
const combined = r.stdout.toString("utf8") + (exitCode !== 0 ? r.stderr.toString("utf8") : "") + (r.held === true ? "\n" + BACKGROUND_HOLD_NOTE + "\n" : "");
|
|
52661
52977
|
const fullBytes = Buffer.byteLength(combined, "utf8");
|
|
52662
52978
|
const head = summaryLine(exitCode, fullBytes);
|
|
52663
52979
|
const intent = input.intent ?? "";
|
|
@@ -52687,7 +53003,7 @@ async function handler3(raw, ctx) {
|
|
|
52687
53003
|
const cwd = ctx.project.worktree;
|
|
52688
53004
|
const extra = { ...PLAIN_OUTPUT_ENV2 };
|
|
52689
53005
|
if (input.file !== void 0) {
|
|
52690
|
-
const abs =
|
|
53006
|
+
const abs = resolve8(cwd, input.file);
|
|
52691
53007
|
const bad = fileError(input.file, abs, ctx.project.containmentRoot);
|
|
52692
53008
|
if (bad !== null) return fail4(bad);
|
|
52693
53009
|
extra.CTX_FILE = abs;
|
|
@@ -52741,11 +53057,11 @@ var ctxExecute = {
|
|
|
52741
53057
|
};
|
|
52742
53058
|
|
|
52743
53059
|
// src/core/tools/index.ts
|
|
52744
|
-
import { existsSync as existsSync19, readFileSync as
|
|
52745
|
-
import { dirname as
|
|
53060
|
+
import { existsSync as existsSync19, readFileSync as readFileSync15, statSync as statSync7 } from "node:fs";
|
|
53061
|
+
import { dirname as dirname11, extname as extname3, join as join20, relative as relative3, resolve as resolve9 } from "node:path";
|
|
52746
53062
|
|
|
52747
53063
|
// src/core/index/walk.ts
|
|
52748
|
-
import { readdirSync as readdirSync9, readFileSync as
|
|
53064
|
+
import { readdirSync as readdirSync9, readFileSync as readFileSync14, realpathSync as realpathSync10, statSync as statSync6 } from "node:fs";
|
|
52749
53065
|
import { join as join19 } from "node:path";
|
|
52750
53066
|
var GITIGNORE = ".gitignore";
|
|
52751
53067
|
var GIT_DIR = ".git";
|
|
@@ -52807,7 +53123,7 @@ function compareFound(a, b) {
|
|
|
52807
53123
|
function readRules(file2, base) {
|
|
52808
53124
|
let body;
|
|
52809
53125
|
try {
|
|
52810
|
-
body =
|
|
53126
|
+
body = readFileSync14(file2, "utf8");
|
|
52811
53127
|
} catch {
|
|
52812
53128
|
return [];
|
|
52813
53129
|
}
|
|
@@ -53029,18 +53345,18 @@ function request(u, conn, proxy, signal) {
|
|
|
53029
53345
|
const host = bare(u.hostname);
|
|
53030
53346
|
const port = u.port === "" ? defaultPort(u.protocol) : Number(u.port);
|
|
53031
53347
|
const path8 = u.pathname + u.search;
|
|
53032
|
-
return new Promise((
|
|
53348
|
+
return new Promise((resolve10, reject) => {
|
|
53033
53349
|
const onErr = (err) => reject(fail5(causeCode(err)));
|
|
53034
53350
|
if (proxy === void 0) {
|
|
53035
53351
|
const mod = u.protocol === "https:" ? https : http;
|
|
53036
53352
|
const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { host: u.host } });
|
|
53037
|
-
req.on("response",
|
|
53353
|
+
req.on("response", resolve10).on("error", onErr).end();
|
|
53038
53354
|
return;
|
|
53039
53355
|
}
|
|
53040
53356
|
const proxyHeaders = proxy.auth === void 0 ? {} : { "proxy-authorization": proxy.auth };
|
|
53041
53357
|
if (u.protocol === "http:") {
|
|
53042
53358
|
const req = http.request({ host: conn.address, port: conn.port, path: u.href, signal, headers: { host: u.host, ...proxyHeaders } });
|
|
53043
|
-
req.on("response",
|
|
53359
|
+
req.on("response", resolve10).on("error", onErr).end();
|
|
53044
53360
|
return;
|
|
53045
53361
|
}
|
|
53046
53362
|
const authority = (isIP(host) === 6 ? "[" + host + "]" : host) + ":" + port;
|
|
@@ -53060,16 +53376,16 @@ function request(u, conn, proxy, signal) {
|
|
|
53060
53376
|
headers: { host: u.host },
|
|
53061
53377
|
createConnection: () => tlsConnect({ socket, host, servername: tlsName(host) })
|
|
53062
53378
|
});
|
|
53063
|
-
req.on("response",
|
|
53379
|
+
req.on("response", resolve10).on("error", onErr).end();
|
|
53064
53380
|
});
|
|
53065
53381
|
tunnel.end();
|
|
53066
53382
|
});
|
|
53067
53383
|
}
|
|
53068
53384
|
function readBody(res) {
|
|
53069
|
-
return new Promise((
|
|
53385
|
+
return new Promise((resolve10, reject) => {
|
|
53070
53386
|
const parts = [];
|
|
53071
53387
|
res.on("data", (b) => parts.push(b));
|
|
53072
|
-
res.on("end", () =>
|
|
53388
|
+
res.on("end", () => resolve10(Buffer.concat(parts)));
|
|
53073
53389
|
res.on("error", (err) => reject(fail5(causeCode(err))));
|
|
53074
53390
|
res.on("aborted", () => reject(fail5("ECONNRESET")));
|
|
53075
53391
|
});
|
|
@@ -56935,19 +57251,19 @@ function kindOfType(contentType) {
|
|
|
56935
57251
|
}
|
|
56936
57252
|
function readUtf8(absPath) {
|
|
56937
57253
|
try {
|
|
56938
|
-
return utf8.decode(
|
|
57254
|
+
return utf8.decode(readFileSync15(absPath));
|
|
56939
57255
|
} catch {
|
|
56940
57256
|
return void 0;
|
|
56941
57257
|
}
|
|
56942
57258
|
}
|
|
56943
57259
|
function missingOrOutside(given, abs, root) {
|
|
56944
57260
|
let dir = abs;
|
|
56945
|
-
while (!existsSync19(dir) &&
|
|
57261
|
+
while (!existsSync19(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
|
|
56946
57262
|
if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
|
|
56947
57263
|
return new CtxError("OUTSIDE_ROOT", { p: given, root });
|
|
56948
57264
|
}
|
|
56949
57265
|
function pathItems(input, project) {
|
|
56950
|
-
const abs =
|
|
57266
|
+
const abs = resolve9(project.worktree, input.path);
|
|
56951
57267
|
if (!isInside(project.containmentRoot, abs)) throw missingOrOutside(input.path, abs, project.containmentRoot);
|
|
56952
57268
|
const base = relative3(project.worktree, abs);
|
|
56953
57269
|
if (statSync7(abs).isDirectory()) {
|
|
@@ -57379,7 +57695,8 @@ function reply3(text, isError) {
|
|
|
57379
57695
|
return { text, isError, sandboxBytes: 0 };
|
|
57380
57696
|
}
|
|
57381
57697
|
async function handler6(input, ctx) {
|
|
57382
|
-
const
|
|
57698
|
+
const given = input.session !== void 0 && input.session.trim() !== "" ? input.session : void 0;
|
|
57699
|
+
const sessionId = given ?? ctx.sessionId;
|
|
57383
57700
|
if (sessionId === "") return reply3(RESUME_NO_SESSION_LINE, true);
|
|
57384
57701
|
const db = await openDb(ctx.project, { readOnly: true });
|
|
57385
57702
|
try {
|
|
@@ -57753,7 +58070,7 @@ var ctxStats = Object.freeze({
|
|
|
57753
58070
|
|
|
57754
58071
|
// src/core/ops/host-write.ts
|
|
57755
58072
|
import { copyFileSync, existsSync as existsSync20, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
|
|
57756
|
-
import { dirname as
|
|
58073
|
+
import { dirname as dirname12, join as join21 } from "node:path";
|
|
57757
58074
|
function defaultWrite(file2, text) {
|
|
57758
58075
|
writeFileSync6(file2, text, "utf8");
|
|
57759
58076
|
}
|
|
@@ -57785,7 +58102,7 @@ function writeWithRollback(file2, text, write, atomic) {
|
|
|
57785
58102
|
const trash = file2 + UPGRADE_TRASH_SUFFIX;
|
|
57786
58103
|
const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
|
|
57787
58104
|
const had = existsSync20(file2);
|
|
57788
|
-
mkdirSync8(
|
|
58105
|
+
mkdirSync8(dirname12(file2), { recursive: true });
|
|
57789
58106
|
if (had) copyFileSync(file2, trash);
|
|
57790
58107
|
try {
|
|
57791
58108
|
write(tmp, text);
|
|
@@ -57952,7 +58269,7 @@ function runUninstall(input) {
|
|
|
57952
58269
|
}
|
|
57953
58270
|
|
|
57954
58271
|
// src/core/ops/v1-remove.ts
|
|
57955
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync22, readFileSync as
|
|
58272
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync22, readFileSync as readFileSync16, rmSync as rmSync8 } from "node:fs";
|
|
57956
58273
|
var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
57957
58274
|
var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
|
|
57958
58275
|
var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
|
|
@@ -58003,8 +58320,8 @@ function locate(doc, path8) {
|
|
|
58003
58320
|
return null;
|
|
58004
58321
|
}
|
|
58005
58322
|
function stripJsonEntries(agent, file2, findings, kept, undo) {
|
|
58006
|
-
const layout = hostLayout(
|
|
58007
|
-
const text = hostText(
|
|
58323
|
+
const layout = hostLayout(readFileSync16(file2, "utf8"));
|
|
58324
|
+
const text = hostText(readFileSync16(file2, "utf8"));
|
|
58008
58325
|
const doc = parseHostConfig(agent, file2, text, "jsonc");
|
|
58009
58326
|
const hit = /* @__PURE__ */ new Set();
|
|
58010
58327
|
const byContainer = /* @__PURE__ */ new Map();
|
|
@@ -58054,7 +58371,7 @@ function removeV1(agent, findings, project) {
|
|
|
58054
58371
|
continue;
|
|
58055
58372
|
}
|
|
58056
58373
|
if (file2.endsWith(TOML_EXT)) {
|
|
58057
|
-
const rawToml =
|
|
58374
|
+
const rawToml = readFileSync16(file2, "utf8");
|
|
58058
58375
|
const tomlLayout = hostLayout(rawToml);
|
|
58059
58376
|
let text = hostText(rawToml);
|
|
58060
58377
|
for (const f of list3) {
|
|
@@ -58112,8 +58429,8 @@ function pluginRootRow(adapter, env) {
|
|
|
58112
58429
|
}
|
|
58113
58430
|
return root === own4 ? [] : [row4(UPGRADE_PLUGIN_ROOT_AREA, root, own4)];
|
|
58114
58431
|
}
|
|
58115
|
-
function hostRow(adapter) {
|
|
58116
|
-
return row4(UPGRADE_HOST_AREA, "",
|
|
58432
|
+
function hostRow(adapter, env) {
|
|
58433
|
+
return row4(UPGRADE_HOST_AREA, "", hostUpdateCommand(adapter.id, env));
|
|
58117
58434
|
}
|
|
58118
58435
|
function upgrade(adapter, deps, home) {
|
|
58119
58436
|
let removal = null;
|
|
@@ -58121,7 +58438,7 @@ function upgrade(adapter, deps, home) {
|
|
|
58121
58438
|
const step5 = regenerateHostConfig(adapter, home, { env: deps.env, write: deps.write });
|
|
58122
58439
|
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
58440
|
removal = removeV1(adapter.id, findings, deps.project.worktree);
|
|
58124
|
-
const rows = [hostRow(adapter), ...step5, ...removal.rows];
|
|
58441
|
+
const rows = [hostRow(adapter, deps.env), ...step5, ...removal.rows];
|
|
58125
58442
|
removal.commit();
|
|
58126
58443
|
return rows;
|
|
58127
58444
|
} catch (err) {
|
|
@@ -58279,12 +58596,12 @@ function sessionIdOf(meta3, agent, env, serverId) {
|
|
|
58279
58596
|
return RUN_SESSION_PREFIX + serverId;
|
|
58280
58597
|
}
|
|
58281
58598
|
var CODEX_SANDBOX_STATE_META = "codex/sandbox-state-meta";
|
|
58282
|
-
var
|
|
58599
|
+
var FILE_URL_PREFIX2 = "file:";
|
|
58283
58600
|
function workspaceFromMeta(meta3) {
|
|
58284
58601
|
const state = meta3?.[CODEX_SANDBOX_STATE_META];
|
|
58285
58602
|
const cwd = typeof state === "object" && state !== null ? state.sandboxCwd : void 0;
|
|
58286
58603
|
if (typeof cwd !== "string" || cwd === "") return void 0;
|
|
58287
|
-
if (!cwd.startsWith(
|
|
58604
|
+
if (!cwd.startsWith(FILE_URL_PREFIX2)) return cwd;
|
|
58288
58605
|
try {
|
|
58289
58606
|
return fileURLToPath3(cwd);
|
|
58290
58607
|
} catch {
|
|
@@ -58308,7 +58625,7 @@ async function workspaceFromRoots(server) {
|
|
|
58308
58625
|
try {
|
|
58309
58626
|
const { roots } = await server.server.listRoots(void 0, { timeout: ROOTS_TIMEOUT_MS });
|
|
58310
58627
|
for (const root of roots) {
|
|
58311
|
-
if (root.uri.startsWith(
|
|
58628
|
+
if (root.uri.startsWith(FILE_URL_PREFIX2)) return fileURLToPath3(root.uri);
|
|
58312
58629
|
}
|
|
58313
58630
|
} catch (err) {
|
|
58314
58631
|
console.error("context-mode: roots/list: " + (err instanceof Error ? err.message : String(err)));
|
|
@@ -58319,7 +58636,7 @@ function workspaceCwdOf(meta3, spawnCwd, script) {
|
|
|
58319
58636
|
const fromHost = workspaceFromMeta(meta3);
|
|
58320
58637
|
if (fromHost !== void 0) return fromHost;
|
|
58321
58638
|
if (script === void 0 || script === "") return spawnCwd;
|
|
58322
|
-
return realOrSame(spawnCwd) === realOrSame(
|
|
58639
|
+
return realOrSame(spawnCwd) === realOrSame(dirname13(script)) ? "" : spawnCwd;
|
|
58323
58640
|
}
|
|
58324
58641
|
function errorReply(err) {
|
|
58325
58642
|
if (err instanceof CtxError) return { text: err.toLine(), isError: true, sandboxBytes: 0 };
|
|
@@ -58475,7 +58792,7 @@ async function startServer(argv, env) {
|
|
|
58475
58792
|
}
|
|
58476
58793
|
installExitGuard({ onShutdown: shutdown, isTTY: process.stdin.isTTY === true });
|
|
58477
58794
|
handle = serveStdio(createServer);
|
|
58478
|
-
await new Promise((
|
|
58795
|
+
await new Promise((resolve10) => process.once("exit", () => resolve10()));
|
|
58479
58796
|
}
|
|
58480
58797
|
if (isEntry(import.meta.main, process.argv[1], fileURLToPath3(import.meta.url))) {
|
|
58481
58798
|
const [, , ...cliArgs] = process.argv;
|