context-mode 2.1.3 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.zcode-plugin/hooks.json +50 -0
- package/.zcode-plugin/plugin.json +20 -0
- package/README.md +78 -79
- package/SHA256SUMS +17 -15
- package/cli.mjs +389 -173
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +99 -97
- package/opencode/plugin.js +2774 -727
- package/package.json +2 -1
- package/pi/index.js +2796 -728
- package/qwen-extension.json +1 -1
- package/run.mjs +340 -128
- package/search.mjs +340 -128
- package/server.mjs +2507 -549
package/server.mjs
CHANGED
|
@@ -7,8 +7,8 @@ var __export = (target, all) => {
|
|
|
7
7
|
|
|
8
8
|
// src/entries/server.ts
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
|
-
import { existsSync as
|
|
11
|
-
import { dirname as
|
|
10
|
+
import { existsSync as existsSync22, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
|
|
11
|
+
import { dirname as dirname12, join as join22 } 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
|
|
@@ -2556,7 +2556,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
2556
2556
|
}
|
|
2557
2557
|
return propValues;
|
|
2558
2558
|
});
|
|
2559
|
-
const
|
|
2559
|
+
const isObject7 = isObject;
|
|
2560
2560
|
const catchall = def.catchall;
|
|
2561
2561
|
let value;
|
|
2562
2562
|
const memo5 = globalConfig.memoizer;
|
|
@@ -2564,7 +2564,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
2564
2564
|
inst._zod.parse = (payload, ctx) => {
|
|
2565
2565
|
value ?? (value = _normalized.value);
|
|
2566
2566
|
const input = payload.value;
|
|
2567
|
-
if (!
|
|
2567
|
+
if (!isObject7(input)) {
|
|
2568
2568
|
payload.issues.push({
|
|
2569
2569
|
expected: "object",
|
|
2570
2570
|
code: "invalid_type",
|
|
@@ -2700,7 +2700,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
2700
2700
|
return doc.compile();
|
|
2701
2701
|
};
|
|
2702
2702
|
let fastpass;
|
|
2703
|
-
const
|
|
2703
|
+
const isObject7 = isObject;
|
|
2704
2704
|
const jit = !globalConfig.jitless;
|
|
2705
2705
|
const allowsEval4 = allowsEval;
|
|
2706
2706
|
const fastEnabled = jit && allowsEval4.value;
|
|
@@ -2709,7 +2709,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
2709
2709
|
inst._zod.parse = (payload, ctx) => {
|
|
2710
2710
|
value ?? (value = _normalized.value);
|
|
2711
2711
|
const input = payload.value;
|
|
2712
|
-
if (!
|
|
2712
|
+
if (!isObject7(input)) {
|
|
2713
2713
|
payload.issues.push({
|
|
2714
2714
|
expected: "object",
|
|
2715
2715
|
code: "invalid_type",
|
|
@@ -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, resolve7) {
|
|
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, resolve6) {
|
|
|
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, resolve7);
|
|
3501
3501
|
if (answer3 > result)
|
|
3502
3502
|
result = answer3;
|
|
3503
3503
|
}
|
|
@@ -3508,7 +3508,7 @@ function isRecursive(inst, stack2, resolve6) {
|
|
|
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, resolve7) : NONE;
|
|
3512
3512
|
if (child > answer3)
|
|
3513
3513
|
answer3 = child;
|
|
3514
3514
|
}
|
|
@@ -3572,7 +3572,7 @@ function isRecursive(inst, stack2, resolve6) {
|
|
|
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 ?? (resolve7 ? inst._zod.innerType : void 0);
|
|
3576
3576
|
merge5(inner ? isRecursive(inner, stack2, false) : ASSUMED);
|
|
3577
3577
|
break;
|
|
3578
3578
|
}
|
|
@@ -10085,7 +10085,7 @@ var $ZodObject2 = /* @__PURE__ */ $constructor2("$ZodObject", (inst, def) => {
|
|
|
10085
10085
|
}
|
|
10086
10086
|
return propValues;
|
|
10087
10087
|
});
|
|
10088
|
-
const
|
|
10088
|
+
const isObject7 = isObject2;
|
|
10089
10089
|
const catchall = def.catchall;
|
|
10090
10090
|
let value;
|
|
10091
10091
|
const memo5 = globalConfig2.memoizer;
|
|
@@ -10093,7 +10093,7 @@ var $ZodObject2 = /* @__PURE__ */ $constructor2("$ZodObject", (inst, def) => {
|
|
|
10093
10093
|
inst._zod.parse = (payload, ctx) => {
|
|
10094
10094
|
value ?? (value = _normalized.value);
|
|
10095
10095
|
const input = payload.value;
|
|
10096
|
-
if (!
|
|
10096
|
+
if (!isObject7(input)) {
|
|
10097
10097
|
payload.issues.push({
|
|
10098
10098
|
expected: "object",
|
|
10099
10099
|
code: "invalid_type",
|
|
@@ -10229,7 +10229,7 @@ var $ZodObjectJIT2 = /* @__PURE__ */ $constructor2("$ZodObjectJIT", (inst, def)
|
|
|
10229
10229
|
return doc.compile();
|
|
10230
10230
|
};
|
|
10231
10231
|
let fastpass;
|
|
10232
|
-
const
|
|
10232
|
+
const isObject7 = isObject2;
|
|
10233
10233
|
const jit = !globalConfig2.jitless;
|
|
10234
10234
|
const allowsEval4 = allowsEval2;
|
|
10235
10235
|
const fastEnabled = jit && allowsEval4.value;
|
|
@@ -10238,7 +10238,7 @@ var $ZodObjectJIT2 = /* @__PURE__ */ $constructor2("$ZodObjectJIT", (inst, def)
|
|
|
10238
10238
|
inst._zod.parse = (payload, ctx) => {
|
|
10239
10239
|
value ?? (value = _normalized.value);
|
|
10240
10240
|
const input = payload.value;
|
|
10241
|
-
if (!
|
|
10241
|
+
if (!isObject7(input)) {
|
|
10242
10242
|
payload.issues.push({
|
|
10243
10243
|
expected: "object",
|
|
10244
10244
|
code: "invalid_type",
|
|
@@ -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, resolve7) {
|
|
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, resolve6) {
|
|
|
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, resolve7);
|
|
11030
11030
|
if (answer3 > result)
|
|
11031
11031
|
result = answer3;
|
|
11032
11032
|
}
|
|
@@ -11037,7 +11037,7 @@ function isRecursive2(inst, stack2, resolve6) {
|
|
|
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, resolve7) : NONE2;
|
|
11041
11041
|
if (child > answer3)
|
|
11042
11042
|
answer3 = child;
|
|
11043
11043
|
}
|
|
@@ -11101,7 +11101,7 @@ function isRecursive2(inst, stack2, resolve6) {
|
|
|
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 ?? (resolve7 ? inst._zod.innerType : void 0);
|
|
11105
11105
|
merge5(inner ? isRecursive2(inner, stack2, false) : ASSUMED2);
|
|
11106
11106
|
break;
|
|
11107
11107
|
}
|
|
@@ -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((resolve7, 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
|
+
resolve7();
|
|
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((resolve7, 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 resolve7(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 resolve7(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) resolve7(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 = resolve7.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 resolve7(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,47 +21988,47 @@ 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 resolve7(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;
|
|
21995
21995
|
return serialize(resolved, schemelessOptions);
|
|
21996
21996
|
}
|
|
21997
|
-
function resolveComponent(base,
|
|
21997
|
+
function resolveComponent(base, relative4, options, skipNormalization) {
|
|
21998
21998
|
const target = {};
|
|
21999
21999
|
if (!skipNormalization) {
|
|
22000
22000
|
base = parse6(serialize(base, options), options);
|
|
22001
|
-
|
|
22001
|
+
relative4 = parse6(serialize(relative4, options), options);
|
|
22002
22002
|
}
|
|
22003
22003
|
options = options || {};
|
|
22004
|
-
if (!options.tolerant &&
|
|
22005
|
-
target.scheme =
|
|
22006
|
-
target.userinfo =
|
|
22007
|
-
target.host =
|
|
22008
|
-
target.port =
|
|
22009
|
-
target.path = removeDotSegments(
|
|
22010
|
-
target.query =
|
|
22004
|
+
if (!options.tolerant && relative4.scheme) {
|
|
22005
|
+
target.scheme = relative4.scheme;
|
|
22006
|
+
target.userinfo = relative4.userinfo;
|
|
22007
|
+
target.host = relative4.host;
|
|
22008
|
+
target.port = relative4.port;
|
|
22009
|
+
target.path = removeDotSegments(relative4.path || "");
|
|
22010
|
+
target.query = relative4.query;
|
|
22011
22011
|
} else {
|
|
22012
|
-
if (
|
|
22013
|
-
target.userinfo =
|
|
22014
|
-
target.host =
|
|
22015
|
-
target.port =
|
|
22016
|
-
target.path = removeDotSegments(
|
|
22017
|
-
target.query =
|
|
22012
|
+
if (relative4.userinfo !== void 0 || relative4.host !== void 0 || relative4.port !== void 0) {
|
|
22013
|
+
target.userinfo = relative4.userinfo;
|
|
22014
|
+
target.host = relative4.host;
|
|
22015
|
+
target.port = relative4.port;
|
|
22016
|
+
target.path = removeDotSegments(relative4.path || "");
|
|
22017
|
+
target.query = relative4.query;
|
|
22018
22018
|
} else {
|
|
22019
|
-
if (!
|
|
22019
|
+
if (!relative4.path) {
|
|
22020
22020
|
target.path = base.path;
|
|
22021
|
-
if (
|
|
22021
|
+
if (relative4.query !== void 0) target.query = relative4.query;
|
|
22022
22022
|
else target.query = base.query;
|
|
22023
22023
|
} else {
|
|
22024
|
-
if (
|
|
22024
|
+
if (relative4.path[0] === "/") target.path = removeDotSegments(relative4.path);
|
|
22025
22025
|
else {
|
|
22026
|
-
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) target.path = "/" +
|
|
22027
|
-
else if (!base.path) target.path =
|
|
22028
|
-
else target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
22026
|
+
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) target.path = "/" + relative4.path;
|
|
22027
|
+
else if (!base.path) target.path = relative4.path;
|
|
22028
|
+
else target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative4.path;
|
|
22029
22029
|
target.path = removeDotSegments(target.path);
|
|
22030
22030
|
}
|
|
22031
|
-
target.query =
|
|
22031
|
+
target.query = relative4.query;
|
|
22032
22032
|
}
|
|
22033
22033
|
target.userinfo = base.userinfo;
|
|
22034
22034
|
target.host = base.host;
|
|
@@ -22036,7 +22036,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
22036
22036
|
}
|
|
22037
22037
|
target.scheme = base.scheme;
|
|
22038
22038
|
}
|
|
22039
|
-
target.fragment =
|
|
22039
|
+
target.fragment = relative4.fragment;
|
|
22040
22040
|
return target;
|
|
22041
22041
|
}
|
|
22042
22042
|
function equal(uriA, uriB, options) {
|
|
@@ -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: resolve7,
|
|
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((resolve7, 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
|
+
resolve7();
|
|
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
|
+
resolve7();
|
|
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((resolve7) => {
|
|
27707
27707
|
const waiter = () => {
|
|
27708
27708
|
clearTimeout(timer);
|
|
27709
|
-
|
|
27709
|
+
resolve7(true);
|
|
27710
27710
|
};
|
|
27711
27711
|
const timer = setTimeout(() => {
|
|
27712
27712
|
this._drainWaiters = this._drainWaiters.filter((pending) => pending !== waiter);
|
|
27713
|
-
|
|
27713
|
+
resolve7(false);
|
|
27714
27714
|
}, timeoutMs);
|
|
27715
27715
|
this._drainWaiters.push(waiter);
|
|
27716
27716
|
});
|
|
@@ -28244,6 +28244,7 @@ var GIT_COMMONDIR_FILE = "commondir";
|
|
|
28244
28244
|
var GIT_HEAD_FILE = "HEAD";
|
|
28245
28245
|
var WORKSPACE_FOLDER_FLAG = "--workspace-folder";
|
|
28246
28246
|
var EXEC_LANGUAGES = Object.freeze(["shell", "powershell", "javascript", "typescript", "python"]);
|
|
28247
|
+
var SHELL_FAMILY = Object.freeze(["sh", "bash", "zsh", "dash", "ksh", "fish"]);
|
|
28247
28248
|
var PATHEXT_DEFAULT = ".COM;.EXE;.BAT;.CMD";
|
|
28248
28249
|
var FETCH_MAX_HOPS = 5;
|
|
28249
28250
|
var SOURCE_LABEL_MAX_CHARS = 80;
|
|
@@ -28255,6 +28256,7 @@ var RUN_SESSION_PREFIX = "mcp:";
|
|
|
28255
28256
|
var HOST_SESSION_ENV = Object.freeze({ "claude-code": "CLAUDE_CODE_SESSION_ID" });
|
|
28256
28257
|
var NODE_MIN = "24.15.0";
|
|
28257
28258
|
var DATA_ROOT = "~/.context-mode";
|
|
28259
|
+
var DATA_DIR_ENV = "CONTEXT_MODE_DATA_DIR";
|
|
28258
28260
|
var INTERNAL_ERROR_LINE = "Internal error. Fix: run ctx_doctor.";
|
|
28259
28261
|
var HOST_CONFIG_DIR_NAME = ".claude";
|
|
28260
28262
|
var HOST_PLUGINS_DIR_NAME = "plugins";
|
|
@@ -28323,7 +28325,31 @@ var SHELL_DUMP_COMMANDS = Object.freeze(["cat", "head", "tail", "sed", "less", "
|
|
|
28323
28325
|
var DUMP_COUNT_COMMANDS = Object.freeze(["head", "tail"]);
|
|
28324
28326
|
var DUMP_COUNT_FLAGS = Object.freeze(["-n", "-c", "--lines", "--bytes"]);
|
|
28325
28327
|
var SED_QUIET_FLAGS = Object.freeze(["-n", "--quiet", "--silent"]);
|
|
28326
|
-
var READ_PATH_KEYS = Object.freeze(["file_path", "absolute_path", "path"]);
|
|
28328
|
+
var READ_PATH_KEYS = Object.freeze(["file_path", "absolute_path", "path", "filePath"]);
|
|
28329
|
+
var READ_MEDIA_TYPES = Object.freeze({
|
|
28330
|
+
png: { exts: [".png"], sig: [{ at: 0, bytes: [137, 80, 78, 71, 13, 10, 26, 10] }] },
|
|
28331
|
+
jpeg: { exts: [".jpg", ".jpeg"], sig: [{ at: 0, bytes: [255, 216, 255] }] },
|
|
28332
|
+
gif: { exts: [".gif"], sig: [{ at: 0, bytes: [71, 73, 70, 56] }] },
|
|
28333
|
+
// "GIF8"
|
|
28334
|
+
webp: { exts: [".webp"], sig: [{ at: 0, bytes: [82, 73, 70, 70] }, { at: 8, bytes: [87, 69, 66, 80] }] },
|
|
28335
|
+
// "RIFF" .... "WEBP"
|
|
28336
|
+
pdf: { exts: [".pdf"], sig: [{ at: 0, bytes: [37, 80, 68, 70, 45] }] }
|
|
28337
|
+
// "%PDF-"
|
|
28338
|
+
});
|
|
28339
|
+
var READ_IMAGES = Object.freeze(["png", "jpeg", "gif", "webp"]);
|
|
28340
|
+
var READ_IMAGES_AND_PDF = Object.freeze([...READ_IMAGES, "pdf"]);
|
|
28341
|
+
var READ_MEDIA_BY_AGENT = Object.freeze({
|
|
28342
|
+
"claude-code": READ_IMAGES_AND_PDF,
|
|
28343
|
+
gemini: READ_IMAGES_AND_PDF,
|
|
28344
|
+
qwen: READ_IMAGES_AND_PDF,
|
|
28345
|
+
opencode: READ_IMAGES_AND_PDF,
|
|
28346
|
+
pi: READ_IMAGES,
|
|
28347
|
+
vscode: READ_IMAGES,
|
|
28348
|
+
"copilot-cli": [],
|
|
28349
|
+
codex: [],
|
|
28350
|
+
kiro: [],
|
|
28351
|
+
zcode: []
|
|
28352
|
+
});
|
|
28327
28353
|
var OWN_TOOL_PREFIX = "ctx_";
|
|
28328
28354
|
var EDIT_TOOLS = Object.freeze(["Write", "Edit"]);
|
|
28329
28355
|
var EDIT_PATH_KEYS = Object.freeze(["file_path", "path"]);
|
|
@@ -28408,8 +28434,7 @@ function PURGE_SUMMARY(rows, scope) {
|
|
|
28408
28434
|
var DECISION_SOURCE = "decision";
|
|
28409
28435
|
var DECISION_USER_LABEL = "decision (user)";
|
|
28410
28436
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
28411
|
-
var
|
|
28412
|
-
var BUNDLE_SHA = true ? "83f2da691359eaaf61f7baba841dea1942d3ccc1" : void 0;
|
|
28437
|
+
var BUNDLE_SHA = true ? "f75e51d580374d518a8ceefc1422a009ffe67311" : void 0;
|
|
28413
28438
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
28414
28439
|
var DOCTOR_LABEL = Object.freeze({
|
|
28415
28440
|
D1: "version",
|
|
@@ -28553,7 +28578,6 @@ function D9_INDEX_DETAIL(sources, chunks) {
|
|
|
28553
28578
|
var PLUGIN_CACHE_DIR_NAME = "cache";
|
|
28554
28579
|
var DATA_PLUGINS_DIR_NAME = "plugins";
|
|
28555
28580
|
var PLUGIN_CURRENT_LINK = "current";
|
|
28556
|
-
var RELEASE_SUMS_FILE = "SHA256SUMS";
|
|
28557
28581
|
var EXTENSIONS_DIR_NAME = "extensions";
|
|
28558
28582
|
var AGENT_HOME_DIR = Object.freeze({
|
|
28559
28583
|
"claude-code": [".claude"],
|
|
@@ -28576,7 +28600,6 @@ var UPGRADE_MODES = Object.freeze(["upgrade", "uninstall"]);
|
|
|
28576
28600
|
var UPGRADE_TABLE_HEADER = "| Area | Before | After |";
|
|
28577
28601
|
var UPGRADE_TABLE_RULE = "|---|---|---|";
|
|
28578
28602
|
var UPGRADE_PLUGIN_ROOT_AREA = "plugin root";
|
|
28579
|
-
var UPGRADE_CHECKOUT_AREA = "plugin checkout";
|
|
28580
28603
|
var UPGRADE_SERVER_AREA = "server";
|
|
28581
28604
|
var UPGRADE_SERVER_RUNNING = "running";
|
|
28582
28605
|
var UPGRADE_SERVER_STOPPED = "stopped after this reply";
|
|
@@ -28587,25 +28610,20 @@ var UPGRADE_REPORT_ONLY = "report only: remove it by hand if you no longer use i
|
|
|
28587
28610
|
var UPGRADE_STOP_DELAY_MS = 200;
|
|
28588
28611
|
var UPGRADE_AREA_KEY_SEP = ": ";
|
|
28589
28612
|
var V1_KEY_PATH_SEP = ".";
|
|
28590
|
-
var UPGRADE_GIT_TIMEOUT_MS = 12e4;
|
|
28591
28613
|
var GIT_CLONE_ARGS = Object.freeze(["clone", "--depth", "1", "--branch"]);
|
|
28592
28614
|
var GIT_HEAD_SHA_ARGS = Object.freeze(["rev-parse", "HEAD"]);
|
|
28593
|
-
var UPGRADE_FETCH_DIR_PREFIX = ".fetch-";
|
|
28594
|
-
var SUMS_LINE_SEP = " ";
|
|
28595
|
-
var SUMS_HASH_ALGORITHM = "sha256";
|
|
28596
|
-
var UPGRADE_GIT_CHECKOUT_AGENTS = Object.freeze(["pi", "opencode"]);
|
|
28597
|
-
var UPGRADE_HOST_MANUAL = "update with the host's own install command, then restart";
|
|
28598
28615
|
var UPGRADE_CONFIG_AREA = "host config";
|
|
28599
28616
|
var UPGRADE_OWN_ENTRY = "context-mode entry";
|
|
28600
28617
|
var UPGRADE_CACHE_BY_HAND = "remove the release dir by hand: its place is your choice";
|
|
28601
28618
|
var GIT_NO_PROMPT_ENV = Object.freeze({ GIT_TERMINAL_PROMPT: "0" });
|
|
28602
28619
|
var GIT_NO_CRLF_ENV = Object.freeze({ GIT_CONFIG_COUNT: "1", GIT_CONFIG_KEY_0: "core.autocrlf", GIT_CONFIG_VALUE_0: "false" });
|
|
28603
|
-
var GIT_NOT_STARTED = "git did not start";
|
|
28604
28620
|
var GIT_BIN = "git";
|
|
28605
28621
|
var WIN_SHELL_LANGS = Object.freeze(["shell", "bash", "sh"]);
|
|
28606
28622
|
var GIT_BASH_RELATIVE = Object.freeze([["..", "bin", "bash.exe"], ["..", "..", "bin", "bash.exe"]]);
|
|
28607
|
-
var GIT_EXIT_LABEL = "git exit ";
|
|
28608
28623
|
var UPGRADE_TRASH_SUFFIX = ".ctx-upgrade-removing";
|
|
28624
|
+
var UPGRADE_ASIDE_SUFFIX = ".ctx-v1-old";
|
|
28625
|
+
var UPGRADE_MOVED_ASIDE = "moved aside to ";
|
|
28626
|
+
var PERSISTED_OUTPUT_MAX_BYTES = 16 * 1024 * 1024;
|
|
28609
28627
|
var TABLE_ROW_START = "| ";
|
|
28610
28628
|
var TABLE_CELL_SEP = " | ";
|
|
28611
28629
|
var TABLE_ROW_END = " |";
|
|
@@ -28617,7 +28635,6 @@ var OPS_SPLIT_FILES = Object.freeze([
|
|
|
28617
28635
|
"doctor-hook.ts",
|
|
28618
28636
|
"doctor-db.ts",
|
|
28619
28637
|
"doctor-heal.ts",
|
|
28620
|
-
"release-fetch.ts",
|
|
28621
28638
|
"verify-sums.ts",
|
|
28622
28639
|
"plugin-swap.ts",
|
|
28623
28640
|
"host-write.ts",
|
|
@@ -28674,10 +28691,12 @@ var REGEX_ESCAPE = "\\";
|
|
|
28674
28691
|
var CODEX_FEATURES_HOOKS_KEY = Object.freeze(["features", "hooks"]);
|
|
28675
28692
|
var D5_SHAPE_DETAIL = "hook output is not the agent's native shape";
|
|
28676
28693
|
var D5_READ_RANGE_DETAIL = "PostToolUse Read with offset/limit over the replace trigger came back replaced: a bounded Read must reach the model whole";
|
|
28694
|
+
var D5_READ_MEDIA_DETAIL = "PreToolUse Read of a PNG over the one-read limit came back denied: an image Read must reach the model as an image block (#1321)";
|
|
28677
28695
|
var D5_READ_SHAPE_DETAIL = `PostToolUse Read replace is not Read's output shape {type:"text", file:{filePath, content, numLines, startLine, totalLines}}: Claude Code drops it and shows a hook warning`;
|
|
28678
28696
|
function D5_SLOW_DETAIL(ms) {
|
|
28679
28697
|
return `hook round trip took ${ms} ms over bare node, over ${HOOK_P95_MS} ms`;
|
|
28680
28698
|
}
|
|
28699
|
+
var D5_STOP_DETAIL = "Codex Stop event: the hook did not give an empty or Codex Stop reply, or it logged a hook error";
|
|
28681
28700
|
var D5_FIX = "run ctx_upgrade";
|
|
28682
28701
|
var PRAGMA_INTEGRITY_CHECK = "PRAGMA integrity_check";
|
|
28683
28702
|
function D10_DETAIL(mode) {
|
|
@@ -28693,19 +28712,19 @@ function D11_PASS_DETAIL(shell, win) {
|
|
|
28693
28712
|
var DB_SIBLING_SUFFIXES = Object.freeze(["", DB_WAL_SUFFIX, DB_SHM_SUFFIX]);
|
|
28694
28713
|
var HEAL_TMP_SUFFIX = ".heal";
|
|
28695
28714
|
var HEAL_TS_SEP = ".";
|
|
28696
|
-
var SUMS_LINE_END = "\n";
|
|
28697
|
-
var HASH_ENCODING = "hex";
|
|
28698
|
-
var PLUGIN_LINK_TMP_SUFFIX = ".swap";
|
|
28699
|
-
var PLUGIN_LINK_OLD_SUFFIX = ".old";
|
|
28700
|
-
var PLUGIN_LINK_TYPE = "dir";
|
|
28701
|
-
var PLUGIN_LINK_TYPE_WIN32 = "junction";
|
|
28702
28715
|
var OWNER_STOP_EXT = ".stop";
|
|
28703
28716
|
var UPGRADE_DATA_DELETED = "user data deleted";
|
|
28704
28717
|
var UPGRADE_HOST_COMMAND = Object.freeze({
|
|
28705
28718
|
"claude-code": "claude plugin marketplace update context-mode && claude plugin update context-mode@context-mode",
|
|
28706
|
-
codex: "
|
|
28707
|
-
gemini: "gemini extensions
|
|
28708
|
-
qwen: "qwen extensions
|
|
28719
|
+
codex: "codex plugin marketplace upgrade context-mode",
|
|
28720
|
+
gemini: "gemini extensions update context-mode",
|
|
28721
|
+
qwen: "qwen extensions update context-mode",
|
|
28722
|
+
pi: "pi update --extensions",
|
|
28723
|
+
opencode: "opencode plugin update",
|
|
28724
|
+
"copilot-cli": "npm i -g context-mode && context-mode setup --agents copilot-cli",
|
|
28725
|
+
vscode: "npm i -g context-mode && context-mode setup --agents vscode",
|
|
28726
|
+
kiro: "npm i -g context-mode && context-mode setup --agents kiro",
|
|
28727
|
+
zcode: "npm i -g context-mode && context-mode setup --agents zcode"
|
|
28709
28728
|
});
|
|
28710
28729
|
var PI_GIT_PACKAGE = "git:github.com/mksglu/context-mode@release";
|
|
28711
28730
|
var OPENCODE_GIT_SPEC = "git+https://github.com/mksglu/context-mode.git#release";
|
|
@@ -28747,6 +28766,7 @@ var HOOKS_JSON_FILE = "hooks.json";
|
|
|
28747
28766
|
var CLAUDE_CONFIG_DIR_ENV = "CLAUDE_CONFIG_DIR";
|
|
28748
28767
|
var CODEX_HOME_ENV = "CODEX_HOME";
|
|
28749
28768
|
var COPILOT_HOME_ENV = "COPILOT_HOME";
|
|
28769
|
+
var GEMINI_CLI_HOME_ENV = "GEMINI_CLI_HOME";
|
|
28750
28770
|
var KIRO_HOME_ENV = "KIRO_HOME";
|
|
28751
28771
|
var OPENCODE_CONFIG_DIR_ENV = "OPENCODE_CONFIG_DIR";
|
|
28752
28772
|
var APPDATA_ENV = "APPDATA";
|
|
@@ -28775,8 +28795,12 @@ var STATUS_LINE_KEY = "statusLine";
|
|
|
28775
28795
|
var PI_PACKAGES_KEY = "packages";
|
|
28776
28796
|
var OPENCODE_PLUGIN_KEY = "plugin";
|
|
28777
28797
|
var OPENCODE_PLUGINS_KEY = "plugins";
|
|
28798
|
+
var OPENCODE_MCP_COMMAND_FIELD = "command";
|
|
28778
28799
|
var OPENCODE_PACKAGE_FIELD = "package";
|
|
28779
28800
|
var OPENCODE_NPM_SPEC_PREFIX = `${SERVER_KEY}@`;
|
|
28801
|
+
var NPM_VERSION_SEP = "@";
|
|
28802
|
+
var OPENCODE_NPM_LATEST = `${OPENCODE_NPM_SPEC_PREFIX}latest`;
|
|
28803
|
+
var PI_NPM_LATEST = `${V1_PI_PACKAGE}${NPM_VERSION_SEP}latest`;
|
|
28780
28804
|
var V1_DATA_DIR_NAME = "context-mode";
|
|
28781
28805
|
var V1_DATA_ROOT_ENTRIES = Object.freeze(["content", "platform.json"]);
|
|
28782
28806
|
var V1_SESSIONS_DIR_NAME = "sessions";
|
|
@@ -28805,17 +28829,22 @@ var V1_REASON = Object.freeze({
|
|
|
28805
28829
|
kiroSteering: "old context-mode Kiro steering doc .kiro/steering/KIRO.md: manual review, report only, never removed",
|
|
28806
28830
|
piNpm: "old context-mode Pi package npm:context-mode",
|
|
28807
28831
|
opencodePlugin: "old context-mode OpenCode plugin spec context-mode",
|
|
28832
|
+
piGit: "old context-mode Pi entry git:github.com/mksglu/context-mode@release: ctx_upgrade replaces it with npm:context-mode@latest",
|
|
28833
|
+
opencodeGit: "old context-mode OpenCode entry git+https://github.com/mksglu/context-mode.git#release: ctx_upgrade replaces it with context-mode@latest",
|
|
28808
28834
|
zcodeHook: "old context-mode ZCode hook entry: command contains context-mode hook",
|
|
28809
28835
|
dataDir: "old context-mode data dir <agent home>/context-mode/",
|
|
28810
28836
|
dataDirShared: "old context-mode data dir ~/.gemini/context-mode/: delete only after a prompt (Antigravity shares it)",
|
|
28811
28837
|
dataRoot: "old context-mode content under ~/.context-mode/",
|
|
28812
|
-
tmpFile: "old context-mode temp file context-mode-* under the OS temp dir: report only, safe to keep"
|
|
28838
|
+
tmpFile: "old context-mode temp file context-mode-* under the OS temp dir: report only, safe to keep",
|
|
28839
|
+
projectLink: "context-mode path in the project reached through a link: report only, upgrade keeps it as is and never follows a link"
|
|
28813
28840
|
});
|
|
28814
|
-
var UPGRADE_REPORT_ONLY_REASONS = Object.freeze([V1_REASON.statusLine, V1_REASON.vscodeMcp, V1_REASON.dataDirShared, V1_REASON.tmpFile, V1_REASON.kiroSteering]);
|
|
28841
|
+
var UPGRADE_REPORT_ONLY_REASONS = Object.freeze([V1_REASON.statusLine, V1_REASON.vscodeMcp, V1_REASON.dataDirShared, V1_REASON.tmpFile, V1_REASON.kiroSteering, V1_REASON.piGit, V1_REASON.opencodeGit, V1_REASON.projectLink]);
|
|
28842
|
+
var UPGRADE_KEEP_ASIDE_REASONS = Object.freeze([V1_REASON.dataDir, V1_REASON.dataRoot]);
|
|
28815
28843
|
var PLUGIN_NAME = SERVER_KEY;
|
|
28816
28844
|
var OPENCODE_TOOL_PREFIX = SERVER_KEY + "_";
|
|
28817
28845
|
var SERVER_ENTRY_FILE = "server.mjs";
|
|
28818
28846
|
var VSCODE_WORKSPACE_VAR = "${workspaceFolder}";
|
|
28847
|
+
var ROOTS_TIMEOUT_MS = 2e3;
|
|
28819
28848
|
var OPENCODE_PLUGIN_PATH = Object.freeze(["opencode", "plugin.js"]);
|
|
28820
28849
|
var HOST_NODE_COMMAND = "node";
|
|
28821
28850
|
var EXE_SUFFIX = ".exe";
|
|
@@ -28938,7 +28967,7 @@ var NATIVE_INSTALL = Object.freeze({
|
|
|
28938
28967
|
"copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
|
|
28939
28968
|
vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
|
|
28940
28969
|
kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
|
|
28941
|
-
zcode: ["
|
|
28970
|
+
zcode: ["zcode plugins marketplace add mksglu/context-mode", "zcode plugins install context-mode@context-mode"]
|
|
28942
28971
|
});
|
|
28943
28972
|
var ISSUE_FORM_URL = `https://github.com/${ISSUE_REPO_SLUG}/issues/new?template=${ISSUE_FORM_FILE}`;
|
|
28944
28973
|
var DOCTOR_GIT_VERSION_TIMEOUT_MS = 5e3;
|
|
@@ -29144,6 +29173,15 @@ function applyMigrations(db, fromVersion) {
|
|
|
29144
29173
|
}
|
|
29145
29174
|
}
|
|
29146
29175
|
|
|
29176
|
+
// src/core/store/open-read.ts
|
|
29177
|
+
function openReadOnlyHandle(sqlite, path8, opts = {}) {
|
|
29178
|
+
const bun = "bun" in opts ? opts.bun : process.versions.bun;
|
|
29179
|
+
if (bun === void 0) return new sqlite.DatabaseSync(path8, { timeout: DB_TIMEOUT_MS, readOnly: true });
|
|
29180
|
+
const raw = new sqlite.DatabaseSync(path8, { timeout: DB_TIMEOUT_MS });
|
|
29181
|
+
if (opts.queryOnly !== false) raw.exec("PRAGMA query_only = ON");
|
|
29182
|
+
return raw;
|
|
29183
|
+
}
|
|
29184
|
+
|
|
29147
29185
|
// src/core/store/db.ts
|
|
29148
29186
|
var { existsSync, linkSync, mkdirSync, rmSync } = process.getBuiltinModule("node:fs");
|
|
29149
29187
|
function versionParts(v) {
|
|
@@ -29209,7 +29247,7 @@ function openWritable(sqlite, path8) {
|
|
|
29209
29247
|
}
|
|
29210
29248
|
}
|
|
29211
29249
|
function openReadOnly(sqlite, path8) {
|
|
29212
|
-
const raw =
|
|
29250
|
+
const raw = openReadOnlyHandle(sqlite, path8);
|
|
29213
29251
|
try {
|
|
29214
29252
|
const found = readUserVersion(raw);
|
|
29215
29253
|
if (found !== SCHEMA_VERSION) throw new CtxError("SCHEMA_STALE", { found, want: SCHEMA_VERSION });
|
|
@@ -29402,6 +29440,10 @@ function copilotDirOf(env, home) {
|
|
|
29402
29440
|
const dir = env[COPILOT_HOME_ENV];
|
|
29403
29441
|
return dir !== void 0 && dir !== "" ? dir : join(home, ...AGENT_HOME_DIR["copilot-cli"]);
|
|
29404
29442
|
}
|
|
29443
|
+
function geminiDirOf(env, home) {
|
|
29444
|
+
const dir = env[GEMINI_CLI_HOME_ENV];
|
|
29445
|
+
return join(dir !== void 0 && dir !== "" ? dir : home, ...AGENT_HOME_DIR.gemini);
|
|
29446
|
+
}
|
|
29405
29447
|
function kiroDirOf(env, home, platform = process.platform) {
|
|
29406
29448
|
const p = platform === "win32" ? win32 : posix;
|
|
29407
29449
|
const fallback = p.join(home, ...AGENT_HOME_DIR.kiro);
|
|
@@ -29460,18 +29502,23 @@ function requireHomeDir(env, platform = process.platform) {
|
|
|
29460
29502
|
if (home !== null) return home;
|
|
29461
29503
|
throw new CtxError("NO_HOME", { name: platform === "win32" ? "USERPROFILE" : "HOME" });
|
|
29462
29504
|
}
|
|
29505
|
+
function dataRootOf(env, home) {
|
|
29506
|
+
const dir = env[DATA_DIR_ENV];
|
|
29507
|
+
return dir !== void 0 && dir !== "" ? resolve(dir) : join(home, DATA_ROOT.slice(1));
|
|
29508
|
+
}
|
|
29463
29509
|
function resolveConfigDir(env) {
|
|
29464
|
-
const
|
|
29510
|
+
const set3 = env[DATA_DIR_ENV];
|
|
29511
|
+
const dir = dataRootOf(env, set3 !== void 0 && set3 !== "" ? "" : requireHomeDir(env));
|
|
29465
29512
|
mkdirSync2(dir, { recursive: true });
|
|
29466
29513
|
return realpathSync.native(dir);
|
|
29467
29514
|
}
|
|
29468
29515
|
|
|
29469
29516
|
// src/core/project/resolve.ts
|
|
29470
|
-
import { basename as basename2, dirname as dirname3, join as
|
|
29517
|
+
import { basename as basename2, dirname as dirname3, join as join3, resolve as resolve2 } from "node:path";
|
|
29471
29518
|
|
|
29472
29519
|
// src/core/project/contain.ts
|
|
29473
|
-
import { dirname as dirname2, sep } from "node:path";
|
|
29474
|
-
var { realpathSync: realpathSync2 } = process.getBuiltinModule("node:fs");
|
|
29520
|
+
import { dirname as dirname2, join as join2, relative, sep } from "node:path";
|
|
29521
|
+
var { lstatSync, realpathSync: realpathSync2 } = process.getBuiltinModule("node:fs");
|
|
29475
29522
|
function real(p) {
|
|
29476
29523
|
try {
|
|
29477
29524
|
return realpathSync2.native(p);
|
|
@@ -29510,6 +29557,21 @@ function commonRoot(paths) {
|
|
|
29510
29557
|
while (components(q).length > n && dirname2(q) !== q) q = dirname2(q);
|
|
29511
29558
|
return q;
|
|
29512
29559
|
}
|
|
29560
|
+
function reachedThroughLink(root, p) {
|
|
29561
|
+
const rel = relative(root, p);
|
|
29562
|
+
const steps = components(rel);
|
|
29563
|
+
if (rel === "" || steps[0] === ".." || rel === p) return false;
|
|
29564
|
+
let at = root;
|
|
29565
|
+
for (const step of steps) {
|
|
29566
|
+
at = join2(at, step);
|
|
29567
|
+
try {
|
|
29568
|
+
if (lstatSync(at).isSymbolicLink()) return true;
|
|
29569
|
+
} catch {
|
|
29570
|
+
return false;
|
|
29571
|
+
}
|
|
29572
|
+
}
|
|
29573
|
+
return false;
|
|
29574
|
+
}
|
|
29513
29575
|
|
|
29514
29576
|
// src/core/project/sha256.ts
|
|
29515
29577
|
var K = new Uint32Array([
|
|
@@ -29671,9 +29733,9 @@ function gitDirs(dir) {
|
|
|
29671
29733
|
}
|
|
29672
29734
|
const start = cur;
|
|
29673
29735
|
for (; ; ) {
|
|
29674
|
-
const gitDir = gitDirAt(
|
|
29736
|
+
const gitDir = gitDirAt(join3(cur, GIT_DIR_NAME));
|
|
29675
29737
|
if (gitDir !== null) {
|
|
29676
|
-
const common = firstLine(
|
|
29738
|
+
const common = firstLine(join3(gitDir, GIT_COMMONDIR_FILE));
|
|
29677
29739
|
return { commonDir: realpathSync3.native(common === null ? gitDir : resolve2(gitDir, common)), worktree: cur, start };
|
|
29678
29740
|
}
|
|
29679
29741
|
const up = dirname3(cur);
|
|
@@ -29694,7 +29756,7 @@ function gitDirAt(dotGit) {
|
|
|
29694
29756
|
} catch {
|
|
29695
29757
|
return null;
|
|
29696
29758
|
}
|
|
29697
|
-
return existsSync2(
|
|
29759
|
+
return existsSync2(join3(gitDir, GIT_HEAD_FILE)) ? gitDir : null;
|
|
29698
29760
|
}
|
|
29699
29761
|
function firstLine(file2) {
|
|
29700
29762
|
let text;
|
|
@@ -29735,11 +29797,11 @@ function resolveProject(agent, src) {
|
|
|
29735
29797
|
return key;
|
|
29736
29798
|
},
|
|
29737
29799
|
get projectDir() {
|
|
29738
|
-
pdir ??=
|
|
29800
|
+
pdir ??= join3(resolveConfigDir(process.env), PROJECTS_DIR_NAME, this.projectKey);
|
|
29739
29801
|
return pdir;
|
|
29740
29802
|
},
|
|
29741
29803
|
get dbPath() {
|
|
29742
|
-
return
|
|
29804
|
+
return join3(this.projectDir, DB_FILE_NAME);
|
|
29743
29805
|
},
|
|
29744
29806
|
worktree,
|
|
29745
29807
|
get containmentRoot() {
|
|
@@ -29753,7 +29815,7 @@ function resolveProject(agent, src) {
|
|
|
29753
29815
|
|
|
29754
29816
|
// src/core/store/cleanup.ts
|
|
29755
29817
|
import { existsSync as existsSync3, readdirSync as readdirSync2, rmSync as rmSync3 } from "node:fs";
|
|
29756
|
-
import { join as
|
|
29818
|
+
import { join as join5 } from "node:path";
|
|
29757
29819
|
|
|
29758
29820
|
// src/core/store/snippet.ts
|
|
29759
29821
|
var K1 = 1.2;
|
|
@@ -29787,14 +29849,14 @@ function identParts(w) {
|
|
|
29787
29849
|
if (cur !== "") parts.push(cur);
|
|
29788
29850
|
return parts;
|
|
29789
29851
|
}
|
|
29790
|
-
function snippetTerms(
|
|
29852
|
+
function snippetTerms(words2) {
|
|
29791
29853
|
const out = /* @__PURE__ */ new Map();
|
|
29792
29854
|
const add = (text, weight, symbol2) => {
|
|
29793
29855
|
if (text === "") return;
|
|
29794
29856
|
const prev = out.get(text);
|
|
29795
29857
|
if (!prev || prev.weight < weight) out.set(text, { text, weight, symbol: symbol2 });
|
|
29796
29858
|
};
|
|
29797
|
-
for (const raw of
|
|
29859
|
+
for (const raw of words2) {
|
|
29798
29860
|
let a = 0;
|
|
29799
29861
|
let b = raw.length;
|
|
29800
29862
|
while (a < b && !isAlnum(raw.charCodeAt(a))) a++;
|
|
@@ -31788,18 +31850,18 @@ function deleteChunkRows(raw, scope) {
|
|
|
31788
31850
|
return Number(raw.prepare("DELETE FROM chunks WHERE " + where).run(arg).changes);
|
|
31789
31851
|
}
|
|
31790
31852
|
function toMatch(q) {
|
|
31791
|
-
const
|
|
31853
|
+
const words2 = [];
|
|
31792
31854
|
let cur = "";
|
|
31793
31855
|
for (const ch of q) {
|
|
31794
31856
|
if (ch.trim() === "" || ch === "\0") {
|
|
31795
|
-
if (cur !== "")
|
|
31857
|
+
if (cur !== "") words2.push(cur);
|
|
31796
31858
|
cur = "";
|
|
31797
31859
|
} else {
|
|
31798
31860
|
cur += ch === '"' ? '""' : ch;
|
|
31799
31861
|
}
|
|
31800
31862
|
}
|
|
31801
|
-
if (cur !== "")
|
|
31802
|
-
return
|
|
31863
|
+
if (cur !== "") words2.push(cur);
|
|
31864
|
+
return words2.map((w) => `"${w}"*`).join(" ");
|
|
31803
31865
|
}
|
|
31804
31866
|
function toMatchAny(q) {
|
|
31805
31867
|
const terms = new Set(toMatch(q).split(" ").filter((t) => t !== ""));
|
|
@@ -31896,11 +31958,11 @@ function searchTerms(q) {
|
|
|
31896
31958
|
return kept.length > 0 ? kept : all;
|
|
31897
31959
|
}
|
|
31898
31960
|
function trigramMatch(q) {
|
|
31899
|
-
const
|
|
31900
|
-
const kept =
|
|
31901
|
-
const parts = new Set((kept.length > 0 ? kept :
|
|
31902
|
-
const whole2 =
|
|
31903
|
-
if (
|
|
31961
|
+
const words2 = blankTokens(q);
|
|
31962
|
+
const kept = words2.filter((w) => !STOPWORDS.has(w.toLowerCase()));
|
|
31963
|
+
const parts = new Set((kept.length > 0 ? kept : words2).filter((w) => [...w].length >= 3));
|
|
31964
|
+
const whole2 = words2.join(" ");
|
|
31965
|
+
if (words2.length > 1 && [...whole2].length >= 3) parts.add(whole2);
|
|
31904
31966
|
return [...parts].map((w) => `"${w.replaceAll('"', '""')}"`).join(" OR ");
|
|
31905
31967
|
}
|
|
31906
31968
|
function editDistance(a, b, max) {
|
|
@@ -31947,10 +32009,10 @@ function queryStems(q) {
|
|
|
31947
32009
|
}
|
|
31948
32010
|
var TYPO_MIN_LEN = 5;
|
|
31949
32011
|
var TYPO_MAX_DIST = 2;
|
|
31950
|
-
function typoTerms(db,
|
|
32012
|
+
function typoTerms(db, words2) {
|
|
31951
32013
|
const has = stmt(db.raw, "SELECT 1 AS x FROM chunks_vocab WHERE term = ?");
|
|
31952
32014
|
const near = stmt(db.raw, "SELECT term, doc, length(term) AS n FROM chunks_vocab WHERE length(term) BETWEEN ? AND ?");
|
|
31953
|
-
const stems = queryStems(
|
|
32015
|
+
const stems = queryStems(words2.join(" "));
|
|
31954
32016
|
const miss = stems.map((stem) => has.get(stem) === void 0 && [...stem].length >= TYPO_MIN_LEN);
|
|
31955
32017
|
if (!miss.includes(true)) return null;
|
|
31956
32018
|
const lens = stems.filter((_, i) => miss[i]).map((stem) => stem.length);
|
|
@@ -32053,9 +32115,9 @@ function ftsListSource(db, source, scope, ctx, sessionId, limit, offset) {
|
|
|
32053
32115
|
}));
|
|
32054
32116
|
}
|
|
32055
32117
|
function highlight(row5, terms, maxBytes = SNIPPET_MAX_BYTES) {
|
|
32056
|
-
const
|
|
32057
|
-
const kept =
|
|
32058
|
-
return buildSnippet(row5, snippetTerms(kept.length > 0 ? kept :
|
|
32118
|
+
const words2 = blankTokens(terms);
|
|
32119
|
+
const kept = words2.filter((w) => !STOPWORDS.has(w.toLowerCase()));
|
|
32120
|
+
return buildSnippet(row5, snippetTerms(kept.length > 0 ? kept : words2), maxBytes);
|
|
32059
32121
|
}
|
|
32060
32122
|
var TL_SCOPE = `
|
|
32061
32123
|
AND (:scope <> 'session' OR session_id = :session_id)
|
|
@@ -32293,12 +32355,12 @@ function queryUnits(db, sessionId, q, limit) {
|
|
|
32293
32355
|
|
|
32294
32356
|
// src/core/store/owners.ts
|
|
32295
32357
|
import { mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync2, rmSync as rmSync2, writeFileSync } from "node:fs";
|
|
32296
|
-
import { basename as basename3, join as
|
|
32358
|
+
import { basename as basename3, join as join4 } from "node:path";
|
|
32297
32359
|
function ownersDir(configDir, projectKey) {
|
|
32298
|
-
return
|
|
32360
|
+
return join4(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
32299
32361
|
}
|
|
32300
32362
|
function ownerFile(configDir, projectKey, serverId) {
|
|
32301
|
-
return
|
|
32363
|
+
return join4(ownersDir(configDir, projectKey), serverId + OWNER_PID_EXT);
|
|
32302
32364
|
}
|
|
32303
32365
|
function errCode(err) {
|
|
32304
32366
|
return err.code;
|
|
@@ -32333,7 +32395,7 @@ function listLiveOwners(configDir, projectKey) {
|
|
|
32333
32395
|
const live = [];
|
|
32334
32396
|
for (const name of names) {
|
|
32335
32397
|
if (!name.endsWith(OWNER_PID_EXT)) continue;
|
|
32336
|
-
const file2 =
|
|
32398
|
+
const file2 = join4(dir, name);
|
|
32337
32399
|
let text;
|
|
32338
32400
|
try {
|
|
32339
32401
|
text = readFileSync2(file2, "utf8");
|
|
@@ -32404,8 +32466,8 @@ function lastAccess(raw) {
|
|
|
32404
32466
|
return row5.t;
|
|
32405
32467
|
}
|
|
32406
32468
|
function sweepOne(configDir, projectKey, cutoff) {
|
|
32407
|
-
const dir =
|
|
32408
|
-
const db = openForSweep(
|
|
32469
|
+
const dir = join5(configDir, PROJECTS_DIR_NAME, projectKey);
|
|
32470
|
+
const db = openForSweep(join5(dir, DB_FILE_NAME), projectKey);
|
|
32409
32471
|
let dead;
|
|
32410
32472
|
try {
|
|
32411
32473
|
dead = withWrite(db, (h) => listLiveOwners(configDir, projectKey).length === 0 && lastAccess(h.raw) < cutoff);
|
|
@@ -32418,7 +32480,7 @@ function sweepOne(configDir, projectKey, cutoff) {
|
|
|
32418
32480
|
function sweepDeadProjects(configDir) {
|
|
32419
32481
|
let entries;
|
|
32420
32482
|
try {
|
|
32421
|
-
entries = readdirSync2(
|
|
32483
|
+
entries = readdirSync2(join5(configDir, PROJECTS_DIR_NAME), { withFileTypes: true });
|
|
32422
32484
|
} catch (err) {
|
|
32423
32485
|
if (err.code === "ENOENT") return [];
|
|
32424
32486
|
throw err;
|
|
@@ -35097,7 +35159,7 @@ var $ZodObject3 = /* @__PURE__ */ $constructor3("$ZodObject", (inst, def) => {
|
|
|
35097
35159
|
return (payload, ctx) => fn(shape, payload, ctx);
|
|
35098
35160
|
};
|
|
35099
35161
|
let fastpass;
|
|
35100
|
-
const
|
|
35162
|
+
const isObject7 = isObject3;
|
|
35101
35163
|
const jit = !globalConfig3.jitless;
|
|
35102
35164
|
const allowsEval4 = allowsEval3;
|
|
35103
35165
|
const fastEnabled = jit && allowsEval4.value;
|
|
@@ -35106,7 +35168,7 @@ var $ZodObject3 = /* @__PURE__ */ $constructor3("$ZodObject", (inst, def) => {
|
|
|
35106
35168
|
inst._zod.parse = (payload, ctx) => {
|
|
35107
35169
|
value ?? (value = _normalized.value);
|
|
35108
35170
|
const input = payload.value;
|
|
35109
|
-
if (!
|
|
35171
|
+
if (!isObject7(input)) {
|
|
35110
35172
|
payload.issues.push({
|
|
35111
35173
|
expected: "object",
|
|
35112
35174
|
code: "invalid_type",
|
|
@@ -43867,7 +43929,7 @@ function cutPoint(src, start, end, scratch) {
|
|
|
43867
43929
|
const r = encoder.encodeInto(src.slice(start, limit), scratch);
|
|
43868
43930
|
return { end: start + r.read, written: r.written };
|
|
43869
43931
|
}
|
|
43870
|
-
function merge4(src, blocks,
|
|
43932
|
+
function merge4(src, blocks, join23, cap, lineCut) {
|
|
43871
43933
|
const out = [];
|
|
43872
43934
|
const scratch = new Uint8Array(cap);
|
|
43873
43935
|
let wide;
|
|
@@ -43877,7 +43939,7 @@ function merge4(src, blocks, join26, cap, lineCut) {
|
|
|
43877
43939
|
out.push({ ord: out.length, text: src.slice(start, end), bytes: bytes5 });
|
|
43878
43940
|
};
|
|
43879
43941
|
for (const b of blocks) {
|
|
43880
|
-
if (cur !== void 0 && !
|
|
43942
|
+
if (cur !== void 0 && !join23) {
|
|
43881
43943
|
emit(cur.start, cur.end, curBytes);
|
|
43882
43944
|
cur = void 0;
|
|
43883
43945
|
}
|
|
@@ -44039,10 +44101,10 @@ function findRuntime(lang, env = process.env) {
|
|
|
44039
44101
|
return shim;
|
|
44040
44102
|
}
|
|
44041
44103
|
function findGitBash(env) {
|
|
44042
|
-
const
|
|
44043
|
-
if (
|
|
44104
|
+
const git2 = findRuntime(GIT_BIN, env);
|
|
44105
|
+
if (git2 === null) return null;
|
|
44044
44106
|
for (const rel of GIT_BASH_RELATIVE) {
|
|
44045
|
-
const full = path.resolve(path.dirname(
|
|
44107
|
+
const full = path.resolve(path.dirname(git2), ...rel);
|
|
44046
44108
|
if (isRunnable(full)) return full;
|
|
44047
44109
|
}
|
|
44048
44110
|
return null;
|
|
@@ -44083,10 +44145,10 @@ function startArgv(argv) {
|
|
|
44083
44145
|
return sh === null ? null : [sh, ...argv];
|
|
44084
44146
|
}
|
|
44085
44147
|
function runProcess(argv, o) {
|
|
44086
|
-
return new Promise((
|
|
44148
|
+
return new Promise((resolve7) => {
|
|
44087
44149
|
const isWin2 = process.platform === "win32";
|
|
44088
44150
|
const start = startArgv(argv);
|
|
44089
|
-
if (start === null) return
|
|
44151
|
+
if (start === null) return resolve7(NOT_STARTED);
|
|
44090
44152
|
let child;
|
|
44091
44153
|
try {
|
|
44092
44154
|
child = spawn(start[0], start.slice(1), {
|
|
@@ -44100,7 +44162,7 @@ function runProcess(argv, o) {
|
|
|
44100
44162
|
windowsHide: true
|
|
44101
44163
|
});
|
|
44102
44164
|
} catch {
|
|
44103
|
-
return
|
|
44165
|
+
return resolve7(NOT_STARTED);
|
|
44104
44166
|
}
|
|
44105
44167
|
const stdoutChunks = [];
|
|
44106
44168
|
const stderrChunks = [];
|
|
@@ -44125,7 +44187,7 @@ function runProcess(argv, o) {
|
|
|
44125
44187
|
settled = true;
|
|
44126
44188
|
clearTimeout(timer);
|
|
44127
44189
|
o.signal.removeEventListener("abort", onAbort);
|
|
44128
|
-
|
|
44190
|
+
resolve7({
|
|
44129
44191
|
stdout: Buffer.concat(stdoutChunks),
|
|
44130
44192
|
stderr: Buffer.concat(stderrChunks),
|
|
44131
44193
|
exitCode,
|
|
@@ -44147,7 +44209,7 @@ function runProcess(argv, o) {
|
|
|
44147
44209
|
|
|
44148
44210
|
// src/core/index/auto-memory.ts
|
|
44149
44211
|
import { readdirSync as readdirSync3, readFileSync as readFileSync3, statSync as statSync3 } from "node:fs";
|
|
44150
|
-
import { join as
|
|
44212
|
+
import { join as join6 } from "node:path";
|
|
44151
44213
|
var MEMORY_FILES = Object.freeze([
|
|
44152
44214
|
Object.freeze(["CLAUDE.md"]),
|
|
44153
44215
|
Object.freeze(["CLAUDE.local.md"]),
|
|
@@ -44161,7 +44223,7 @@ var KIRO_STEERING = Object.freeze([".kiro", "steering"]);
|
|
|
44161
44223
|
var MD = ".md";
|
|
44162
44224
|
function steeringFiles(worktree) {
|
|
44163
44225
|
try {
|
|
44164
|
-
return readdirSync3(
|
|
44226
|
+
return readdirSync3(join6(worktree, ...KIRO_STEERING)).filter((n) => n.endsWith(MD)).sort().map((n) => [...KIRO_STEERING, n]);
|
|
44165
44227
|
} catch {
|
|
44166
44228
|
return [];
|
|
44167
44229
|
}
|
|
@@ -44169,7 +44231,7 @@ function steeringFiles(worktree) {
|
|
|
44169
44231
|
function readAutoMemory(project) {
|
|
44170
44232
|
const rows = [];
|
|
44171
44233
|
for (const segs of [...MEMORY_FILES, ...steeringFiles(project.worktree)]) {
|
|
44172
|
-
const path8 =
|
|
44234
|
+
const path8 = join6(project.worktree, ...segs);
|
|
44173
44235
|
if (!isInside(project.worktree, path8)) continue;
|
|
44174
44236
|
try {
|
|
44175
44237
|
const st = statSync3(path8);
|
|
@@ -44806,7 +44868,7 @@ var ctxBatch = Object.freeze({
|
|
|
44806
44868
|
|
|
44807
44869
|
// src/core/tools/doctor.ts
|
|
44808
44870
|
import { readdirSync as readdirSync7, readFileSync as readFileSync11, existsSync as existsSync16 } from "node:fs";
|
|
44809
|
-
import { basename as basename5, join as
|
|
44871
|
+
import { basename as basename5, join as join16 } from "node:path";
|
|
44810
44872
|
|
|
44811
44873
|
// src/adapters/claude-code.ts
|
|
44812
44874
|
var TOOL_NAME_PREFIX = "mcp__plugin_context-mode_context-mode__";
|
|
@@ -45003,10 +45065,17 @@ function encode3(ev, d, _extra) {
|
|
|
45003
45065
|
// src/adapters/codex.ts
|
|
45004
45066
|
var TOOL_NAME_PREFIX2 = "mcp__context_mode__";
|
|
45005
45067
|
var CODEX_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact", fork: "resume" };
|
|
45068
|
+
var STOP_EVENT = "Stop";
|
|
45069
|
+
var EMPTY = { stdout: "", exitCode: 0 };
|
|
45006
45070
|
function decode4(raw) {
|
|
45071
|
+
if (typeof raw === "object" && raw !== null && !Array.isArray(raw) && raw.hook_event_name === STOP_EVENT) {
|
|
45072
|
+
const p = raw;
|
|
45073
|
+
return { event: STOP_EVENT, agent: "codex", sessionId: String(p.session_id ?? ""), cwd: String(p.cwd ?? "") };
|
|
45074
|
+
}
|
|
45007
45075
|
return decodeClaudeShape(raw, "codex", TOOL_NAME_PREFIX2, CODEX_SOURCES);
|
|
45008
45076
|
}
|
|
45009
45077
|
function encode4(ev, d, _extra) {
|
|
45078
|
+
if (ev.event === STOP_EVENT) return EMPTY;
|
|
45010
45079
|
return encodeClaudeShape(ev, d, false);
|
|
45011
45080
|
}
|
|
45012
45081
|
|
|
@@ -45022,7 +45091,8 @@ var GEMINI_EVENTS = {
|
|
|
45022
45091
|
var GEMINI_SOURCES = { startup: "startup", resume: "resume", clear: "clear" };
|
|
45023
45092
|
var HINT_EVENTS = ["SessionStart", "UserPromptSubmit", "PostToolUse"];
|
|
45024
45093
|
var DENY_EVENTS = ["UserPromptSubmit", "PreToolUse"];
|
|
45025
|
-
var
|
|
45094
|
+
var EMPTY2 = { stdout: "", exitCode: 0 };
|
|
45095
|
+
var GEMINI_REPLACE_LEAD = "the tool ran and succeeded; context-mode indexed its full output, and this is the part that answers the call:\n";
|
|
45026
45096
|
function own3(p, key) {
|
|
45027
45097
|
return Object.hasOwn(p, key) ? p[key] : void 0;
|
|
45028
45098
|
}
|
|
@@ -45042,12 +45112,72 @@ function canonicalName2(name, mcp) {
|
|
|
45042
45112
|
if (typeof server !== "string" || typeof tool !== "string") return name;
|
|
45043
45113
|
return "mcp:" + server + ":" + tool;
|
|
45044
45114
|
}
|
|
45115
|
+
function partsText(llm) {
|
|
45116
|
+
if (!Array.isArray(llm) || llm.length === 0) return void 0;
|
|
45117
|
+
const out = [];
|
|
45118
|
+
for (const part of llm) {
|
|
45119
|
+
if (typeof part === "string") {
|
|
45120
|
+
out.push(part);
|
|
45121
|
+
continue;
|
|
45122
|
+
}
|
|
45123
|
+
if (typeof part !== "object" || part === null) return void 0;
|
|
45124
|
+
const t = own3(part, "text");
|
|
45125
|
+
if (typeof t !== "string") return void 0;
|
|
45126
|
+
out.push(t);
|
|
45127
|
+
}
|
|
45128
|
+
return out.join("");
|
|
45129
|
+
}
|
|
45045
45130
|
function readResult2(resp) {
|
|
45046
45131
|
const obj = typeof resp === "object" && resp !== null ? resp : void 0;
|
|
45047
45132
|
const llm = obj === void 0 ? void 0 : own3(obj, "llmContent");
|
|
45048
|
-
const text = resp === void 0 ? "" : typeof resp === "string" ? resp : typeof llm === "string" ? llm : JSON.stringify(resp);
|
|
45133
|
+
const text = resp === void 0 ? "" : typeof resp === "string" ? resp : typeof llm === "string" ? llm : partsText(llm) ?? JSON.stringify(resp);
|
|
45049
45134
|
const err = obj === void 0 ? void 0 : own3(obj, "error");
|
|
45050
|
-
|
|
45135
|
+
const info = { isError: err !== void 0 && err !== null, bytes: Buffer.byteLength(text), text };
|
|
45136
|
+
if (hasMediaPart(llm)) info.keep = true;
|
|
45137
|
+
return info;
|
|
45138
|
+
}
|
|
45139
|
+
function hasMediaPart(llm) {
|
|
45140
|
+
const parts = Array.isArray(llm) ? llm : [llm];
|
|
45141
|
+
return parts.some((p) => typeof p === "object" && p !== null && (Object.hasOwn(p, "inlineData") || Object.hasOwn(p, "fileData")));
|
|
45142
|
+
}
|
|
45143
|
+
var URL_STARTS = ["https://", "http://"];
|
|
45144
|
+
var URL_TRAIL = `.,;:!?)]}>'"`;
|
|
45145
|
+
var SPACE = " \n\r\f\v";
|
|
45146
|
+
function words(text) {
|
|
45147
|
+
const out = [];
|
|
45148
|
+
let cur = "";
|
|
45149
|
+
for (const ch of text) {
|
|
45150
|
+
if (SPACE.includes(ch)) {
|
|
45151
|
+
if (cur !== "") out.push(cur);
|
|
45152
|
+
cur = "";
|
|
45153
|
+
} else cur += ch;
|
|
45154
|
+
}
|
|
45155
|
+
if (cur !== "") out.push(cur);
|
|
45156
|
+
return out;
|
|
45157
|
+
}
|
|
45158
|
+
function firstUrl(prompt) {
|
|
45159
|
+
if (typeof prompt !== "string") return void 0;
|
|
45160
|
+
for (const word of words(prompt)) {
|
|
45161
|
+
const lower = word.toLowerCase();
|
|
45162
|
+
const at = URL_STARTS.map((s) => lower.indexOf(s)).filter((i) => i >= 0).sort((a, b) => a - b)[0];
|
|
45163
|
+
if (at === void 0) continue;
|
|
45164
|
+
let url4 = word.slice(at);
|
|
45165
|
+
while (url4.length > 0 && URL_TRAIL.includes(url4[url4.length - 1])) url4 = url4.slice(0, -1);
|
|
45166
|
+
return url4;
|
|
45167
|
+
}
|
|
45168
|
+
return void 0;
|
|
45169
|
+
}
|
|
45170
|
+
function nativeInput(name, input) {
|
|
45171
|
+
if (name === "web_fetch" && own3(input, "url") === void 0) {
|
|
45172
|
+
const url4 = firstUrl(own3(input, "prompt"));
|
|
45173
|
+
return url4 === void 0 ? input : { ...input, url: url4 };
|
|
45174
|
+
}
|
|
45175
|
+
if (name === "read_many_files" && own3(input, "file_path") === void 0) {
|
|
45176
|
+
const inc = own3(input, "include");
|
|
45177
|
+
const list3 = Array.isArray(inc) ? inc.filter((v) => typeof v === "string") : [];
|
|
45178
|
+
return list3.length === 0 ? input : { ...input, file_path: list3.join(" ") };
|
|
45179
|
+
}
|
|
45180
|
+
return input;
|
|
45051
45181
|
}
|
|
45052
45182
|
function decode5(raw) {
|
|
45053
45183
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("gemini: hook payload is not a JSON object");
|
|
@@ -45066,7 +45196,7 @@ function decode5(raw) {
|
|
|
45066
45196
|
ev.tool = {
|
|
45067
45197
|
name,
|
|
45068
45198
|
canonicalName: canonicalName2(name, own3(p, "mcp_context")),
|
|
45069
|
-
input: typeof input === "object" && input !== null && !Array.isArray(input) ? input : {}
|
|
45199
|
+
input: nativeInput(name, typeof input === "object" && input !== null && !Array.isArray(input) ? input : {})
|
|
45070
45200
|
};
|
|
45071
45201
|
}
|
|
45072
45202
|
if (event === "PostToolUse") ev.result = readResult2(own3(p, "tool_response"));
|
|
@@ -45075,16 +45205,16 @@ function decode5(raw) {
|
|
|
45075
45205
|
function encode5(ev, d, _extra) {
|
|
45076
45206
|
switch (d.kind) {
|
|
45077
45207
|
case "allow":
|
|
45078
|
-
return
|
|
45208
|
+
return EMPTY2;
|
|
45079
45209
|
case "hint":
|
|
45080
|
-
if (!HINT_EVENTS.includes(ev.event)) return
|
|
45210
|
+
if (!HINT_EVENTS.includes(ev.event)) return EMPTY2;
|
|
45081
45211
|
return { stdout: JSON.stringify({ hookSpecificOutput: { additionalContext: d.text } }), exitCode: 0 };
|
|
45082
45212
|
case "deny":
|
|
45083
|
-
if (!DENY_EVENTS.includes(ev.event)) return
|
|
45213
|
+
if (!DENY_EVENTS.includes(ev.event)) return EMPTY2;
|
|
45084
45214
|
return { stdout: JSON.stringify({ decision: "deny", reason: d.rewritten === void 0 ? d.reason : d.rewritten + "\n" + d.reason }), exitCode: 0 };
|
|
45085
45215
|
case "replace":
|
|
45086
|
-
if (ev.event !== "PostToolUse") return
|
|
45087
|
-
return { stdout: JSON.stringify({ decision: "deny", reason: d.output }), exitCode: 0 };
|
|
45216
|
+
if (ev.event !== "PostToolUse") return EMPTY2;
|
|
45217
|
+
return { stdout: JSON.stringify({ decision: "deny", reason: GEMINI_REPLACE_LEAD + d.output }), exitCode: 0 };
|
|
45088
45218
|
}
|
|
45089
45219
|
}
|
|
45090
45220
|
|
|
@@ -45203,21 +45333,21 @@ function decode7(raw) {
|
|
|
45203
45333
|
if (event === "PostToolUse") ev.result = readResult3(raw[k.result], native.casing, native.failure);
|
|
45204
45334
|
return ev;
|
|
45205
45335
|
}
|
|
45206
|
-
var
|
|
45336
|
+
var EMPTY3 = { stdout: "", exitCode: 0 };
|
|
45207
45337
|
function encode7(ev, d, _extra) {
|
|
45208
45338
|
switch (d.kind) {
|
|
45209
45339
|
case "allow":
|
|
45210
|
-
return
|
|
45340
|
+
return EMPTY3;
|
|
45211
45341
|
case "hint":
|
|
45212
|
-
return ev.event === "PostToolUse" ?
|
|
45342
|
+
return ev.event === "PostToolUse" ? EMPTY3 : { stdout: JSON.stringify({ additionalContext: d.text }), exitCode: 0 };
|
|
45213
45343
|
case "deny":
|
|
45214
|
-
if (ev.event !== "PreToolUse") return
|
|
45344
|
+
if (ev.event !== "PreToolUse") return EMPTY3;
|
|
45215
45345
|
return {
|
|
45216
45346
|
stdout: JSON.stringify({ permissionDecision: "deny", permissionDecisionReason: d.rewritten === void 0 ? d.reason : d.rewritten + "\n" + d.reason }),
|
|
45217
45347
|
exitCode: 0
|
|
45218
45348
|
};
|
|
45219
45349
|
case "replace":
|
|
45220
|
-
if (ev.event !== "PostToolUse") return
|
|
45350
|
+
if (ev.event !== "PostToolUse") return EMPTY3;
|
|
45221
45351
|
return { stdout: JSON.stringify({ modifiedResult: { resultType: RESULT_SUCCESS, textResultForLlm: d.output } }), exitCode: 0 };
|
|
45222
45352
|
}
|
|
45223
45353
|
}
|
|
@@ -45417,6 +45547,7 @@ function encode9(ev, d, _extra) {
|
|
|
45417
45547
|
|
|
45418
45548
|
// src/adapters/zcode.ts
|
|
45419
45549
|
var TOOL_NAME_PREFIX8 = "mcp__context-mode__";
|
|
45550
|
+
var PLUGIN_TOOL_NAME_PREFIX = "mcp__plugin_context-mode_context-mode__";
|
|
45420
45551
|
var ZCODE_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
|
|
45421
45552
|
var TWINS = { hook_event_name: "hookEventName", session_id: "sessionId" };
|
|
45422
45553
|
var FAILURE_EVENT2 = "PostToolUseFailure";
|
|
@@ -45426,7 +45557,9 @@ function decode10(raw) {
|
|
|
45426
45557
|
for (const [snake, camel] of Object.entries(TWINS)) if (p[snake] === void 0) p[snake] = p[camel];
|
|
45427
45558
|
const failure3 = p.hook_event_name === FAILURE_EVENT2;
|
|
45428
45559
|
if (failure3) p.hook_event_name = "PostToolUse";
|
|
45429
|
-
const
|
|
45560
|
+
const toolName2 = typeof p.tool_name === "string" ? p.tool_name : "";
|
|
45561
|
+
const prefix = toolName2.startsWith(PLUGIN_TOOL_NAME_PREFIX) ? PLUGIN_TOOL_NAME_PREFIX : TOOL_NAME_PREFIX8;
|
|
45562
|
+
const ev = decodeClaudeShape(p, "zcode", prefix, ZCODE_SOURCES);
|
|
45430
45563
|
if (failure3) {
|
|
45431
45564
|
const text = typeof p.error === "string" ? p.error : p.error === void 0 ? "" : JSON.stringify(p.error);
|
|
45432
45565
|
ev.result = { isError: true, bytes: Buffer.byteLength(text), text };
|
|
@@ -45507,8 +45640,9 @@ var OPENCODE_EVENTS = {
|
|
|
45507
45640
|
"step-finish": "Usage"
|
|
45508
45641
|
};
|
|
45509
45642
|
var SHELL_TOOL_NAME = "bash";
|
|
45643
|
+
var READ_TOOL_NAME = "read";
|
|
45510
45644
|
var SHELL_TOOL_NAMES5 = Object.freeze([SHELL_TOOL_NAME, "shell"]);
|
|
45511
|
-
var NATIVE_TO_CANONICAL7 = { webfetch: "WebFetch", ...Object.fromEntries(SHELL_TOOL_NAMES5.map((n) => [n, "Bash"])) };
|
|
45645
|
+
var NATIVE_TO_CANONICAL7 = { webfetch: "WebFetch", [READ_TOOL_NAME]: "Read", ...Object.fromEntries(SHELL_TOOL_NAMES5.map((n) => [n, "Bash"])) };
|
|
45512
45646
|
function toCanonicalTool(name) {
|
|
45513
45647
|
if (name.startsWith(OWN_WIRE_PREFIX)) return name.slice(OWN_WIRE_PREFIX.length);
|
|
45514
45648
|
return Object.prototype.hasOwnProperty.call(NATIVE_TO_CANONICAL7, name) ? NATIVE_TO_CANONICAL7[name] : name;
|
|
@@ -45736,9 +45870,9 @@ var ADAPTERS = Object.freeze([
|
|
|
45736
45870
|
installMode: "in-process",
|
|
45737
45871
|
projectSource: "spawn-cwd",
|
|
45738
45872
|
toolNamePrefix: TOOL_NAME_PREFIX10,
|
|
45739
|
-
nativeTools: { shell: [SHELL_TOOL_NAME] },
|
|
45873
|
+
nativeTools: { shell: [SHELL_TOOL_NAME], read: [READ_TOOL_NAME] },
|
|
45740
45874
|
execReadOnlyHint: false,
|
|
45741
|
-
// D-HF-OPENCODE-SHELL-1
|
|
45875
|
+
// D-HF-OPENCODE-SHELL-1, D-R44-OC-READ-1
|
|
45742
45876
|
// Usage: step-finish cost row (DEVIATIONS D-M5-arch-2).
|
|
45743
45877
|
eventMap: { SessionStart: "context", UserPromptSubmit: "prompt", PreToolUse: "execute.before", PostToolUse: "execute.after", PreCompact: "compaction", Usage: "step-finish" },
|
|
45744
45878
|
compactDelivery: "opencode-cache",
|
|
@@ -45764,14 +45898,14 @@ function getAdapter(id) {
|
|
|
45764
45898
|
|
|
45765
45899
|
// src/core/ops/bundle-dir.ts
|
|
45766
45900
|
import { existsSync as existsSync4 } from "node:fs";
|
|
45767
|
-
import { dirname as dirname4, join as
|
|
45901
|
+
import { dirname as dirname4, join as join7 } from "node:path";
|
|
45768
45902
|
import { fileURLToPath } from "node:url";
|
|
45769
45903
|
function bundleDirOf(argv1, moduleFile) {
|
|
45770
45904
|
const own4 = dirname4(argv1);
|
|
45771
|
-
if (existsSync4(
|
|
45905
|
+
if (existsSync4(join7(own4, SERVER_ENTRY_FILE))) return own4;
|
|
45772
45906
|
let dir = dirname4(moduleFile);
|
|
45773
45907
|
for (; ; ) {
|
|
45774
|
-
if (existsSync4(
|
|
45908
|
+
if (existsSync4(join7(dir, SERVER_ENTRY_FILE))) return dir;
|
|
45775
45909
|
const up = dirname4(dir);
|
|
45776
45910
|
if (up === dir) return own4;
|
|
45777
45911
|
dir = up;
|
|
@@ -45786,16 +45920,16 @@ function ownBundleDir() {
|
|
|
45786
45920
|
|
|
45787
45921
|
// src/core/ops/doctor-config.ts
|
|
45788
45922
|
import { existsSync as existsSync9, readdirSync as readdirSync6 } from "node:fs";
|
|
45789
|
-
import { join as
|
|
45923
|
+
import { join as join11 } from "node:path";
|
|
45790
45924
|
|
|
45791
45925
|
// src/core/ops/detect-v1.ts
|
|
45792
45926
|
import { existsSync as existsSync6, opendirSync, readdirSync as readdirSync4, readFileSync as readFileSync5 } from "node:fs";
|
|
45793
45927
|
import { tmpdir } from "node:os";
|
|
45794
|
-
import { join as
|
|
45928
|
+
import { join as join9 } from "node:path";
|
|
45795
45929
|
|
|
45796
45930
|
// src/core/ops/host-config.ts
|
|
45797
45931
|
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
|
|
45798
|
-
import { dirname as dirname5, join as
|
|
45932
|
+
import { dirname as dirname5, join as join8 } from "node:path";
|
|
45799
45933
|
|
|
45800
45934
|
// node_modules/eslint-visitor-keys/lib/visitor-keys.js
|
|
45801
45935
|
var KEYS2 = {
|
|
@@ -47935,7 +48069,7 @@ function formatOf(path8) {
|
|
|
47935
48069
|
function readHostConfig(agent, path8) {
|
|
47936
48070
|
let file2 = path8;
|
|
47937
48071
|
if (agent === "opencode") {
|
|
47938
|
-
const jsonc =
|
|
48072
|
+
const jsonc = join8(dirname5(path8), OPENCODE_CONFIG_FILES[0]);
|
|
47939
48073
|
if (existsSync5(jsonc)) file2 = jsonc;
|
|
47940
48074
|
}
|
|
47941
48075
|
const raw = existsSync5(file2) ? readFileSync4(file2, "utf8") : "";
|
|
@@ -48283,7 +48417,7 @@ function setText(agent, path8, text, format, key, value) {
|
|
|
48283
48417
|
}
|
|
48284
48418
|
}
|
|
48285
48419
|
function serverScript() {
|
|
48286
|
-
return
|
|
48420
|
+
return join8(dirname5(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
|
|
48287
48421
|
}
|
|
48288
48422
|
function isNodeCommand(command) {
|
|
48289
48423
|
if (typeof command !== "string") return false;
|
|
@@ -48295,21 +48429,27 @@ function isNodeCommand(command) {
|
|
|
48295
48429
|
function ownMcpValue(agent, node3, server) {
|
|
48296
48430
|
const mcp = OWN_MCP_ENTRY[agent];
|
|
48297
48431
|
if (mcp === void 0) return void 0;
|
|
48298
|
-
|
|
48299
|
-
return { ...mcp.fields, [MCP_COMMAND_FIELD]: node3, [MCP_ARGS_FIELD]: [server, AGENT_ARG, agent, ...tail] };
|
|
48432
|
+
return { ...mcp.fields, [MCP_COMMAND_FIELD]: node3, [MCP_ARGS_FIELD]: [server, AGENT_ARG, agent] };
|
|
48300
48433
|
}
|
|
48301
48434
|
function opencodePluginFile() {
|
|
48302
48435
|
return ownBundleDir();
|
|
48303
48436
|
}
|
|
48304
|
-
function listTarget(key,
|
|
48437
|
+
function listTarget(key, legacy, swap, isNative) {
|
|
48305
48438
|
return {
|
|
48306
48439
|
key: [key],
|
|
48307
48440
|
next(current) {
|
|
48308
|
-
|
|
48309
|
-
|
|
48441
|
+
if (!Array.isArray(current) || !current.some(legacy)) return current;
|
|
48442
|
+
const keep = current.filter((x) => !legacy(x));
|
|
48443
|
+
if (keep.some(isNative)) return keep;
|
|
48444
|
+
const at = current.findIndex(legacy);
|
|
48445
|
+
return current.flatMap((x, i) => i === at ? [swap(x)] : legacy(x) ? [] : [x]);
|
|
48310
48446
|
}
|
|
48311
48447
|
};
|
|
48312
48448
|
}
|
|
48449
|
+
var piSource = (x) => isPlainObject6(x) ? x[PI_PACKAGE_SOURCE_KEY] : x;
|
|
48450
|
+
var opencodeSpec = (x) => isPlainObject6(x) ? x[OPENCODE_PACKAGE_FIELD] : x;
|
|
48451
|
+
var isNpmOf = (bare2) => (s) => typeof s === "string" && (s === bare2 || s.startsWith(bare2 + NPM_VERSION_SEP));
|
|
48452
|
+
var swapField = (field, spec) => (x) => isPlainObject6(x) ? { ...x, [field]: spec } : spec;
|
|
48313
48453
|
function ownTargets(agent, accept) {
|
|
48314
48454
|
const mcp = OWN_MCP_ENTRY[agent];
|
|
48315
48455
|
if (mcp !== void 0) {
|
|
@@ -48322,8 +48462,18 @@ function ownTargets(agent, accept) {
|
|
|
48322
48462
|
}
|
|
48323
48463
|
}, ...(mcp.also ?? []).map(([key, value]) => ({ key, next: () => value }))];
|
|
48324
48464
|
}
|
|
48325
|
-
if (agent === "opencode")
|
|
48326
|
-
|
|
48465
|
+
if (agent === "opencode") {
|
|
48466
|
+
const alt = accept.listEntries ?? [];
|
|
48467
|
+
const native = (x) => {
|
|
48468
|
+
const s = opencodeSpec(x);
|
|
48469
|
+
return typeof s === "string" && (s.startsWith(OPENCODE_NPM_SPEC_PREFIX) || alt.includes(s));
|
|
48470
|
+
};
|
|
48471
|
+
return [listTarget(OPENCODE_PLUGIN_KEY, (x) => opencodeSpec(x) === OPENCODE_GIT_SPEC, swapField(OPENCODE_PACKAGE_FIELD, OPENCODE_NPM_LATEST), native)];
|
|
48472
|
+
}
|
|
48473
|
+
if (agent === "pi") {
|
|
48474
|
+
const npm = isNpmOf(V1_PI_PACKAGE);
|
|
48475
|
+
return [listTarget(PI_PACKAGES_KEY, (x) => piSource(x) === PI_GIT_PACKAGE, swapField(PI_PACKAGE_SOURCE_KEY, PI_NPM_LATEST), (x) => npm(piSource(x)))];
|
|
48476
|
+
}
|
|
48327
48477
|
return [];
|
|
48328
48478
|
}
|
|
48329
48479
|
function applyEdits(agent, path8, text, format, wanted) {
|
|
@@ -48466,7 +48616,7 @@ function mcpEntry(file2, doc, out) {
|
|
|
48466
48616
|
}
|
|
48467
48617
|
}
|
|
48468
48618
|
function claudeShapeSettings(agentHome, out) {
|
|
48469
|
-
const file2 =
|
|
48619
|
+
const file2 = join9(agentHome, SETTINGS_FILE);
|
|
48470
48620
|
const doc = readJson(file2);
|
|
48471
48621
|
for (const c of nestedCommands(doc)) {
|
|
48472
48622
|
if (c.command.includes(V1_CACHE_HEAL_NAME)) out.push(finding(file2, c.path, V1_REASON.cacheHealHook));
|
|
@@ -48486,49 +48636,50 @@ function v1HookFile(file2, out) {
|
|
|
48486
48636
|
function scanClaudeCode(home, agentHome, out) {
|
|
48487
48637
|
claudeShapeSettings(agentHome, out);
|
|
48488
48638
|
for (const ext of V1_CACHE_HEAL_EXTS) {
|
|
48489
|
-
const file2 =
|
|
48639
|
+
const file2 = join9(agentHome, V1_HOOKS_DIR_NAME, V1_CACHE_HEAL_NAME + ext);
|
|
48490
48640
|
if (existsSync6(file2)) out.push(finding(file2, "", V1_REASON.cacheHealFile));
|
|
48491
48641
|
}
|
|
48492
|
-
const userFile =
|
|
48642
|
+
const userFile = join9(home, CLAUDE_USER_CONFIG_FILE);
|
|
48493
48643
|
mcpEntry(userFile, readJson(userFile), out);
|
|
48494
|
-
dataDir(
|
|
48644
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48495
48645
|
}
|
|
48496
48646
|
function scanCodex(agentHome, out) {
|
|
48497
|
-
const hooksFile =
|
|
48647
|
+
const hooksFile = join9(agentHome, HOOKS_JSON_FILE);
|
|
48498
48648
|
for (const c of nestedCommands(readJson(hooksFile))) {
|
|
48499
48649
|
if (c.command.includes(V1_CODEX_HOOK_COMMAND) || isCodexScript(c.command)) {
|
|
48500
48650
|
out.push(finding(hooksFile, c.path, V1_REASON.codexHook));
|
|
48501
48651
|
}
|
|
48502
48652
|
}
|
|
48503
|
-
const tomlFile =
|
|
48653
|
+
const tomlFile = join9(agentHome, CONFIG_TOML_FILE);
|
|
48504
48654
|
const config4 = readTomlValue(tomlFile);
|
|
48505
48655
|
for (const span2 of readTomlTables(tomlFile)) {
|
|
48506
48656
|
if (span2.path[0] !== V1_TOML_SECTION_ROOT || span2.path[1] !== SERVER_KEY) continue;
|
|
48507
48657
|
if (span2.path.length === 2 && isV2McpTable(hostConfigValueAt(config4, span2.path))) continue;
|
|
48508
48658
|
out.push(finding(tomlFile, span2.header.trim(), V1_REASON.codexToml));
|
|
48509
48659
|
}
|
|
48510
|
-
dataDir(
|
|
48660
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48511
48661
|
}
|
|
48512
48662
|
function scanGemini(agentHome, out) {
|
|
48513
|
-
const file2 =
|
|
48663
|
+
const file2 = join9(agentHome, SETTINGS_FILE);
|
|
48514
48664
|
for (const c of nestedCommands(readJson(file2))) {
|
|
48515
48665
|
if (c.command.includes(SERVER_KEY)) out.push(finding(file2, c.path, V1_REASON.hook));
|
|
48516
48666
|
}
|
|
48517
|
-
dataDir(
|
|
48667
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDirShared, out);
|
|
48518
48668
|
}
|
|
48519
48669
|
function scanVscode(agentHome, project, out) {
|
|
48520
48670
|
if (project !== void 0) {
|
|
48521
|
-
v1HookFile(
|
|
48522
|
-
const mcpFile2 =
|
|
48671
|
+
v1HookFile(join9(project, GITHUB_DIR_NAME, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
|
|
48672
|
+
const mcpFile2 = join9(project, VSCODE_DIR_NAME, VSCODE_MCP_FILE);
|
|
48523
48673
|
const doc = readJson(mcpFile2);
|
|
48524
48674
|
const servers = isObj(doc) && isObj(doc[VSCODE_MCP_SERVERS_KEY]) ? doc[VSCODE_MCP_SERVERS_KEY] : {};
|
|
48525
48675
|
const entry = Object.hasOwn(servers, SERVER_KEY) ? servers[SERVER_KEY] : void 0;
|
|
48526
48676
|
if (isObj(entry) && (entry.command === V1_BIN_COMMAND || listOf(entry.args).some((a) => a === V1_BIN_COMMAND))) {
|
|
48527
48677
|
out.push(finding(mcpFile2, keyPath(VSCODE_MCP_SERVERS_KEY, SERVER_KEY), V1_REASON.vscodeMcp));
|
|
48528
48678
|
}
|
|
48529
|
-
|
|
48679
|
+
const sessions = join9(project, GITHUB_DIR_NAME, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME);
|
|
48680
|
+
dataDir(sessions, reachedThroughLink(project, sessions) ? V1_REASON.projectLink : V1_REASON.dataDir, out);
|
|
48530
48681
|
}
|
|
48531
|
-
dataDir(
|
|
48682
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
|
|
48532
48683
|
}
|
|
48533
48684
|
function jsonFiles(dir) {
|
|
48534
48685
|
try {
|
|
@@ -48538,10 +48689,10 @@ function jsonFiles(dir) {
|
|
|
48538
48689
|
}
|
|
48539
48690
|
}
|
|
48540
48691
|
function scanKiro(agentHome, project, out) {
|
|
48541
|
-
const agentsDir =
|
|
48542
|
-
const defaultFile =
|
|
48692
|
+
const agentsDir = join9(agentHome, KIRO_AGENTS_DIR);
|
|
48693
|
+
const defaultFile = join9(agentHome, ...KIRO_AGENT_FILE);
|
|
48543
48694
|
for (const name of jsonFiles(agentsDir)) {
|
|
48544
|
-
const file2 =
|
|
48695
|
+
const file2 = join9(agentsDir, name);
|
|
48545
48696
|
const doc = readJson(file2);
|
|
48546
48697
|
if (isObj(doc) && doc[KIRO_AGENT_NAME_KEY] === SERVER_KEY) {
|
|
48547
48698
|
out.push(finding(file2, "", V1_REASON.kiroAgentFile));
|
|
@@ -48552,46 +48703,48 @@ function scanKiro(agentHome, project, out) {
|
|
|
48552
48703
|
if (isV1Hook(c.command)) out.push(finding(file2, c.path, V1_REASON.kiroHook));
|
|
48553
48704
|
}
|
|
48554
48705
|
}
|
|
48555
|
-
const steeringDocs = [
|
|
48556
|
-
if (project !== void 0) steeringDocs.push(
|
|
48706
|
+
const steeringDocs = [join9(agentHome, ...KIRO_STEERING_FILE)];
|
|
48707
|
+
if (project !== void 0) steeringDocs.push(join9(project, ...AGENT_HOME_DIR.kiro, ...KIRO_STEERING_FILE));
|
|
48557
48708
|
for (const file2 of steeringDocs) {
|
|
48558
48709
|
if (existsSync6(file2)) out.push(finding(file2, "", V1_REASON.kiroSteering));
|
|
48559
48710
|
}
|
|
48560
|
-
dataDir(
|
|
48711
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48561
48712
|
}
|
|
48562
48713
|
function piNpmIsCurrent(piAgentDir) {
|
|
48563
|
-
const doc = readJson(
|
|
48714
|
+
const doc = readJson(join9(piAgentDir, PI_NPM_DIR, PI_NODE_MODULES_DIR, SERVER_KEY, PI_PACKAGE_JSON_FILE));
|
|
48564
48715
|
const version4 = isObj(doc) && typeof doc.version === "string" ? doc.version : "";
|
|
48565
48716
|
return Number.parseInt(version4, 10) >= PI_CURRENT_MAJOR;
|
|
48566
48717
|
}
|
|
48567
48718
|
function scanPi(piAgentDir, agentHome, out) {
|
|
48568
|
-
const file2 =
|
|
48719
|
+
const file2 = join9(piAgentDir, SETTINGS_FILE);
|
|
48569
48720
|
const doc = readJson(file2);
|
|
48570
48721
|
listOf(isObj(doc) ? doc[PI_PACKAGES_KEY] : void 0).forEach((pkg, i) => {
|
|
48571
48722
|
const spec = isObj(pkg) ? pkg[PI_PACKAGE_SOURCE_KEY] : pkg;
|
|
48572
48723
|
if (spec === V1_PI_PACKAGE && !piNpmIsCurrent(piAgentDir)) out.push(finding(file2, keyPath(PI_PACKAGES_KEY, i), V1_REASON.piNpm));
|
|
48724
|
+
if (spec === PI_GIT_PACKAGE) out.push(finding(file2, keyPath(PI_PACKAGES_KEY, i), V1_REASON.piGit));
|
|
48573
48725
|
});
|
|
48574
|
-
dataDir(
|
|
48726
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48575
48727
|
}
|
|
48576
48728
|
function scanOpencode(agentHome, out) {
|
|
48577
48729
|
for (const name of OPENCODE_CONFIG_FILES) {
|
|
48578
|
-
const file2 =
|
|
48730
|
+
const file2 = join9(agentHome, name);
|
|
48579
48731
|
const doc = readJson(file2);
|
|
48580
48732
|
if (!isObj(doc) || !Array.isArray(doc[OPENCODE_PLUGIN_KEY])) continue;
|
|
48581
48733
|
doc[OPENCODE_PLUGIN_KEY].forEach((spec, i) => {
|
|
48582
48734
|
if (spec === V1_OPENCODE_PLUGIN_SPEC) out.push(finding(file2, keyPath(OPENCODE_PLUGIN_KEY, i), V1_REASON.opencodePlugin));
|
|
48735
|
+
if (spec === OPENCODE_GIT_SPEC) out.push(finding(file2, keyPath(OPENCODE_PLUGIN_KEY, i), V1_REASON.opencodeGit));
|
|
48583
48736
|
});
|
|
48584
48737
|
return;
|
|
48585
48738
|
}
|
|
48586
48739
|
}
|
|
48587
48740
|
function scanZcode(agentHome, out) {
|
|
48588
|
-
const configFile =
|
|
48741
|
+
const configFile = join9(agentHome, ZCODE_CLI_DIR, CONFIG_JSON_FILE);
|
|
48589
48742
|
const config4 = readJson(configFile);
|
|
48590
48743
|
const events = isObj(config4) && isObj(config4[HOOKS_KEY]) ? config4[HOOKS_KEY][ZCODE_EVENTS_KEY] : void 0;
|
|
48591
48744
|
for (const c of flatCommands(events, [HOOKS_KEY, ZCODE_EVENTS_KEY])) {
|
|
48592
48745
|
if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(configFile, c.path, V1_REASON.zcodeHook));
|
|
48593
48746
|
}
|
|
48594
|
-
const hooksFile =
|
|
48747
|
+
const hooksFile = join9(agentHome, ZCODE_CLI_DIR, HOOKS_JSON_FILE);
|
|
48595
48748
|
for (const c of nestedCommands(readJson(hooksFile))) {
|
|
48596
48749
|
if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(hooksFile, c.path, V1_REASON.zcodeHook));
|
|
48597
48750
|
}
|
|
@@ -48615,14 +48768,14 @@ function firstTmpMatch(dir) {
|
|
|
48615
48768
|
}
|
|
48616
48769
|
}
|
|
48617
48770
|
function scanAll(home, tmp, out) {
|
|
48618
|
-
const root =
|
|
48619
|
-
for (const name of V1_DATA_ROOT_ENTRIES) dataDir(
|
|
48771
|
+
const root = join9(home, DATA_ROOT.slice(1));
|
|
48772
|
+
for (const name of V1_DATA_ROOT_ENTRIES) dataDir(join9(root, name), V1_REASON.dataRoot, out);
|
|
48620
48773
|
if (firstTmpMatch(tmp) !== null) out.push(finding(tmp, V1_TMP_PREFIX + "*", V1_REASON.tmpFile));
|
|
48621
48774
|
}
|
|
48622
48775
|
function detectV1(agent, home, scope = {}) {
|
|
48623
48776
|
const out = [];
|
|
48624
48777
|
const project = scope.project;
|
|
48625
|
-
const agentHome = agent === "claude-code" && scope.claudeDir !== void 0 ? scope.claudeDir : agent === "codex" && scope.codexDir !== void 0 ? scope.codexDir : agent === "copilot-cli" && scope.copilotDir !== void 0 ? scope.copilotDir : agent === "kiro" && scope.kiroDir !== void 0 ? scope.kiroDir : agent === "opencode" && scope.opencodeDir !== void 0 ? scope.opencodeDir :
|
|
48778
|
+
const agentHome = agent === "claude-code" && scope.claudeDir !== void 0 ? scope.claudeDir : agent === "codex" && scope.codexDir !== void 0 ? scope.codexDir : agent === "gemini" && scope.geminiDir !== void 0 ? scope.geminiDir : agent === "copilot-cli" && scope.copilotDir !== void 0 ? scope.copilotDir : agent === "kiro" && scope.kiroDir !== void 0 ? scope.kiroDir : agent === "opencode" && scope.opencodeDir !== void 0 ? scope.opencodeDir : join9(home, ...AGENT_HOME_DIR[agent]);
|
|
48626
48779
|
switch (agent) {
|
|
48627
48780
|
case "claude-code":
|
|
48628
48781
|
scanClaudeCode(home, agentHome, out);
|
|
@@ -48635,11 +48788,11 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48635
48788
|
break;
|
|
48636
48789
|
case "qwen":
|
|
48637
48790
|
claudeShapeSettings(agentHome, out);
|
|
48638
|
-
dataDir(
|
|
48791
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48639
48792
|
break;
|
|
48640
48793
|
case "copilot-cli":
|
|
48641
|
-
v1HookFile(
|
|
48642
|
-
dataDir(
|
|
48794
|
+
v1HookFile(join9(agentHome, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
|
|
48795
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48643
48796
|
break;
|
|
48644
48797
|
case "vscode":
|
|
48645
48798
|
scanVscode(agentHome, project, out);
|
|
@@ -48648,7 +48801,7 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48648
48801
|
scanKiro(agentHome, project, out);
|
|
48649
48802
|
break;
|
|
48650
48803
|
case "pi":
|
|
48651
|
-
scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir :
|
|
48804
|
+
scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir : join9(agentHome, PI_AGENT_DIR), agentHome, out);
|
|
48652
48805
|
break;
|
|
48653
48806
|
// D-WIN-PIDIR-1: empty is unset
|
|
48654
48807
|
case "opencode":
|
|
@@ -48664,7 +48817,7 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48664
48817
|
|
|
48665
48818
|
// src/core/ops/plugin-root.ts
|
|
48666
48819
|
import { existsSync as existsSync7, readdirSync as readdirSync5, readFileSync as readFileSync6, realpathSync as realpathSync4 } from "node:fs";
|
|
48667
|
-
import { dirname as dirname6, isAbsolute, join as
|
|
48820
|
+
import { dirname as dirname6, isAbsolute, join as join10, sep as sep2 } from "node:path";
|
|
48668
48821
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
48669
48822
|
function missing(agent, path8) {
|
|
48670
48823
|
return new CtxError("PLUGIN_ROOT_MISSING", { agent, path: path8 });
|
|
@@ -48712,8 +48865,8 @@ var readOrNull = (file2) => {
|
|
|
48712
48865
|
};
|
|
48713
48866
|
var samePath = (a, b) => a === b || (realOrNull(a) ?? a) === (realOrNull(b) ?? b);
|
|
48714
48867
|
function enabledPlugins(claudeDir, project) {
|
|
48715
|
-
const files = [
|
|
48716
|
-
if (project !== void 0) files.push(
|
|
48868
|
+
const files = [join10(claudeDir, SETTINGS_FILE)];
|
|
48869
|
+
if (project !== void 0) files.push(join10(project, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), join10(project, HOST_CONFIG_DIR_NAME, SETTINGS_LOCAL_FILE));
|
|
48717
48870
|
const out = {};
|
|
48718
48871
|
for (const file2 of files) {
|
|
48719
48872
|
const text = readOrNull(file2);
|
|
@@ -48729,7 +48882,7 @@ function marketplaceChoice(env, worktree) {
|
|
|
48729
48882
|
const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
|
|
48730
48883
|
const hostRoot = env[CLAUDE_PLUGIN_ROOT_ENV];
|
|
48731
48884
|
if (ownReal !== null && hostRoot !== void 0 && hostRoot !== "" && realOrNull(hostRoot) === ownReal) return { root: ownReal };
|
|
48732
|
-
const record6 = readOrNull(
|
|
48885
|
+
const record6 = readOrNull(join10(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE));
|
|
48733
48886
|
const recorded = record6 === null ? [] : recordedInstalls(record6);
|
|
48734
48887
|
if (recorded.length === 0) return { record: false };
|
|
48735
48888
|
const live = recorded.filter((r) => existsSync7(r.installPath));
|
|
@@ -48752,18 +48905,18 @@ function marketplaceChoice(env, worktree) {
|
|
|
48752
48905
|
}
|
|
48753
48906
|
function marketplaceRoot(adapter, env, worktree) {
|
|
48754
48907
|
const claudeDir = claudeDirOf(env, requireHomeDir(env));
|
|
48755
|
-
const plugins =
|
|
48756
|
-
const cache =
|
|
48908
|
+
const plugins = join10(claudeDir, HOST_PLUGINS_DIR_NAME);
|
|
48909
|
+
const cache = join10(plugins, PLUGIN_CACHE_DIR_NAME);
|
|
48757
48910
|
const script = process.argv[1];
|
|
48758
48911
|
const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
|
|
48759
48912
|
const choice = marketplaceChoice(env, worktree);
|
|
48760
48913
|
if ("root" in choice) return choice.root;
|
|
48761
48914
|
if ("installs" in choice) throw missing(adapter.id, choice.installs.map((r) => r.installPath).join(", "));
|
|
48762
48915
|
const cacheReal = realOrNull(cache);
|
|
48763
|
-
if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep2) && existsSync7(
|
|
48764
|
-
const pattern =
|
|
48916
|
+
if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep2) && existsSync7(join10(ownReal, SERVER_ENTRY_FILE))) return ownReal;
|
|
48917
|
+
const pattern = join10(cache, "*", PLUGIN_NAME);
|
|
48765
48918
|
if (!existsSync7(cache)) throw missing(adapter.id, pattern);
|
|
48766
|
-
const found = readdirSync5(cache).sort().map((marketplace) =>
|
|
48919
|
+
const found = readdirSync5(cache).sort().map((marketplace) => join10(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync7(dir));
|
|
48767
48920
|
if (found.length !== 1) throw missing(adapter.id, found.length === 0 ? pattern : found.join(", "));
|
|
48768
48921
|
return found[0];
|
|
48769
48922
|
}
|
|
@@ -48788,9 +48941,9 @@ function candidate(adapter, env, worktree) {
|
|
|
48788
48941
|
case "hooks+mcp":
|
|
48789
48942
|
return configEntryRoot(adapter, env);
|
|
48790
48943
|
case "extension":
|
|
48791
|
-
return
|
|
48944
|
+
return join10(adapter.id === "gemini" ? geminiDirOf(env, requireHomeDir(env)) : join10(requireHomeDir(env), ...AGENT_HOME_DIR[adapter.id]), EXTENSIONS_DIR_NAME, PLUGIN_NAME);
|
|
48792
48945
|
case "plugin":
|
|
48793
|
-
return
|
|
48946
|
+
return join10(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
|
|
48794
48947
|
case "in-process":
|
|
48795
48948
|
return dirname6(fileURLToPath2(import.meta.url));
|
|
48796
48949
|
}
|
|
@@ -48950,11 +49103,11 @@ function ownHooks(block, shape, timeoutKey, native, agent) {
|
|
|
48950
49103
|
var validTimeout = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
48951
49104
|
function mcpFile(row5, home, env) {
|
|
48952
49105
|
const spec = OWN_MCP_ENTRY[row5.id];
|
|
48953
|
-
if (row5.id === "codex") return
|
|
49106
|
+
if (row5.id === "codex") return join11(codexDirOf(env, home), CONFIG_TOML_FILE);
|
|
48954
49107
|
if (spec !== void 0) return ownMcpFileOf(row5.id, spec.file, env, home);
|
|
48955
|
-
if (row5.id === "opencode") return
|
|
49108
|
+
if (row5.id === "opencode") return join11(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
|
|
48956
49109
|
if (row5.id === "pi") {
|
|
48957
|
-
return
|
|
49110
|
+
return join11(piAgentDirOf(env, home), SETTINGS_FILE);
|
|
48958
49111
|
}
|
|
48959
49112
|
return null;
|
|
48960
49113
|
}
|
|
@@ -48967,27 +49120,27 @@ function codexNativeDir(env, home) {
|
|
|
48967
49120
|
const codexDir = codexDirOf(env, home);
|
|
48968
49121
|
let enabled;
|
|
48969
49122
|
try {
|
|
48970
|
-
enabled = hostConfigValueAt(readParsed("codex",
|
|
49123
|
+
enabled = hostConfigValueAt(readParsed("codex", join11(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
|
|
48971
49124
|
} catch {
|
|
48972
49125
|
return null;
|
|
48973
49126
|
}
|
|
48974
49127
|
if (enabled !== true) return null;
|
|
48975
|
-
const cache =
|
|
49128
|
+
const cache = join11(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
|
|
48976
49129
|
if (!existsSync9(cache)) return null;
|
|
48977
49130
|
const found = [];
|
|
48978
49131
|
for (const market of readdirSync6(cache)) {
|
|
48979
|
-
const plugin =
|
|
49132
|
+
const plugin = join11(cache, market, SERVER_KEY);
|
|
48980
49133
|
if (!existsSync9(plugin)) continue;
|
|
48981
49134
|
for (const version4 of readdirSync6(plugin).sort()) {
|
|
48982
|
-
const dir =
|
|
48983
|
-
if (existsSync9(
|
|
49135
|
+
const dir = join11(plugin, version4, CODEX_PLUGIN_SUBDIR);
|
|
49136
|
+
if (existsSync9(join11(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
|
|
48984
49137
|
}
|
|
48985
49138
|
}
|
|
48986
49139
|
return found.length === 0 ? null : found[found.length - 1];
|
|
48987
49140
|
}
|
|
48988
49141
|
function nativeMcpWrong(dir, row5) {
|
|
48989
49142
|
try {
|
|
48990
|
-
const entry = hostConfigValueAt(readParsed(row5.id,
|
|
49143
|
+
const entry = hostConfigValueAt(readParsed(row5.id, join11(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
|
|
48991
49144
|
if (!isObject4(entry)) return true;
|
|
48992
49145
|
const args = list(entry[MCP_ARGS_FIELD]);
|
|
48993
49146
|
const script = args[0];
|
|
@@ -49002,10 +49155,19 @@ function isOwnOpencodeEntry(entry, key, own4) {
|
|
|
49002
49155
|
if (spec === OPENCODE_GIT_SPEC || spec.startsWith(OPENCODE_NPM_SPEC_PREFIX) || own4.includes(spec)) return true;
|
|
49003
49156
|
return key === OPENCODE_PLUGINS_KEY && spec === SERVER_KEY;
|
|
49004
49157
|
}
|
|
49158
|
+
function opencodeMcpOwn(entry) {
|
|
49159
|
+
if (!isObject4(entry)) return false;
|
|
49160
|
+
const cmd = Array.isArray(entry[OPENCODE_MCP_COMMAND_FIELD]) ? entry[OPENCODE_MCP_COMMAND_FIELD] : [entry[MCP_COMMAND_FIELD], ...list(entry[MCP_ARGS_FIELD])];
|
|
49161
|
+
const [node3, script, flag, agent] = cmd;
|
|
49162
|
+
return isNodeCommand(node3) && typeof script === "string" && lastSegment(script) === SERVER_ENTRY_FILE && flag === AGENT_ARG && agent === "opencode";
|
|
49163
|
+
}
|
|
49005
49164
|
function opencodeListed(file2) {
|
|
49006
49165
|
const { value } = readParsed("opencode", file2);
|
|
49007
|
-
const
|
|
49008
|
-
|
|
49166
|
+
const bundle = opencodePluginFile();
|
|
49167
|
+
const own4 = [bundle, join11(bundle, ...OPENCODE_PLUGIN_PATH)];
|
|
49168
|
+
if ([OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own4)))) return true;
|
|
49169
|
+
const mcp = isObject4(value) && isObject4(value.mcp) ? value.mcp : {};
|
|
49170
|
+
return opencodeMcpOwn(mcp[SERVER_KEY]) || isObject4(mcp.servers) && opencodeMcpOwn(mcp.servers[SERVER_KEY]);
|
|
49009
49171
|
}
|
|
49010
49172
|
function mcpWrong(row5, home, env, worktree) {
|
|
49011
49173
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
@@ -49026,7 +49188,7 @@ function mcpWrong(row5, home, env, worktree) {
|
|
|
49026
49188
|
function hookFile(row5, spec, home, env, worktree) {
|
|
49027
49189
|
const root = spec.root === "plugin" ? resolvePluginRoot(row5, env, worktree) : spec.root === "home" ? home : worktree;
|
|
49028
49190
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
49029
|
-
const file2 = native !== null ?
|
|
49191
|
+
const file2 = native !== null ? join11(native, CODEX_PLUGIN_HOOKS_FILE) : row5.id === "codex" ? join11(codexDirOf(env, home), HOOKS_JSON_FILE) : row5.id === "copilot-cli" ? join11(copilotDirOf(env, home), ...spec.file.slice(1)) : row5.id === "kiro" ? join11(kiroDirOf(env, home), ...spec.file.slice(1)) : join11(root, ...spec.file);
|
|
49030
49192
|
return file2;
|
|
49031
49193
|
}
|
|
49032
49194
|
function hookParts(row5, home, env, worktree) {
|
|
@@ -49037,7 +49199,7 @@ function hookParts(row5, home, env, worktree) {
|
|
|
49037
49199
|
const file2 = hookFile(row5, spec, home, env, worktree);
|
|
49038
49200
|
block = hostConfigValueAt(readParsed(row5.id, file2).value, spec.key);
|
|
49039
49201
|
if (row5.id === "codex") {
|
|
49040
|
-
const config4 = readParsed(row5.id,
|
|
49202
|
+
const config4 = readParsed(row5.id, join11(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
|
|
49041
49203
|
if (hostConfigValueAt(config4, CODEX_FEATURES_HOOKS_KEY) === false) return [PART_HOOKS];
|
|
49042
49204
|
}
|
|
49043
49205
|
} catch {
|
|
@@ -49081,7 +49243,7 @@ function checkHostConfig(row5, env, worktree) {
|
|
|
49081
49243
|
function checkPiInstall(env, home, worktree) {
|
|
49082
49244
|
const found = piInstalledIn(env, home, ownBundleDir(), worktree);
|
|
49083
49245
|
if (found !== void 0) return { ...pass("D3"), detail: found };
|
|
49084
|
-
return fail("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN +
|
|
49246
|
+
return fail("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + join11(piAgentDirOf(env, home), SETTINGS_FILE), NATIVE_INSTALL.pi[0]);
|
|
49085
49247
|
}
|
|
49086
49248
|
function checkV1Leftovers(agent, home, scope = {}) {
|
|
49087
49249
|
const findings = detectV1(agent, home, scope);
|
|
@@ -49100,10 +49262,10 @@ function parsedOrNull(agent, file2, jsonc) {
|
|
|
49100
49262
|
}
|
|
49101
49263
|
function checkDoubleFire(agent, worktree) {
|
|
49102
49264
|
if (agent !== "claude-code" && agent !== "vscode") return pass("D5b");
|
|
49103
|
-
const claude = parsedOrNull(agent,
|
|
49265
|
+
const claude = parsedOrNull(agent, join11(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
|
|
49104
49266
|
const hooks = isObject4(claude) ? claude[HOOKS_KEY] : void 0;
|
|
49105
49267
|
const hooksOn = isObject4(hooks) && Object.keys(hooks).length > 0;
|
|
49106
|
-
const vscode = parsedOrNull(agent,
|
|
49268
|
+
const vscode = parsedOrNull(agent, join11(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
|
|
49107
49269
|
const useClaudeHooks = isObject4(vscode) && vscode[VSCODE_CLAUDE_HOOKS_SETTING] === true;
|
|
49108
49270
|
return hooksOn && useClaudeHooks ? fail("D5b", D5B_DETAIL, D5B_FIX) : pass("D5b");
|
|
49109
49271
|
}
|
|
@@ -49114,7 +49276,7 @@ function configPaths(row5, env, worktree) {
|
|
|
49114
49276
|
const mcp = mcpFile(row5, home, env);
|
|
49115
49277
|
if (mcp !== null) out.push({ label: "MCP entry", path: mcp });
|
|
49116
49278
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
49117
|
-
if (native !== null) out.push({ label: "Codex plugin MCP", path:
|
|
49279
|
+
if (native !== null) out.push({ label: "Codex plugin MCP", path: join11(native, CODEX_PLUGIN_MCP_FILE) });
|
|
49118
49280
|
const spec = HOOK_HOST_FILE[row5.id];
|
|
49119
49281
|
if (spec !== null) {
|
|
49120
49282
|
try {
|
|
@@ -49154,7 +49316,7 @@ async function loadSqlite2() {
|
|
|
49154
49316
|
}
|
|
49155
49317
|
}
|
|
49156
49318
|
function openRead(sqlite, path8) {
|
|
49157
|
-
return
|
|
49319
|
+
return openReadOnlyHandle(sqlite, path8);
|
|
49158
49320
|
}
|
|
49159
49321
|
var cell = (row5) => Object.values(row5)[0];
|
|
49160
49322
|
function readSchema(raw) {
|
|
@@ -49228,7 +49390,7 @@ async function checkIndex(project) {
|
|
|
49228
49390
|
|
|
49229
49391
|
// src/core/ops/doctor-env.ts
|
|
49230
49392
|
import { existsSync as existsSync11, readFileSync as readFileSync8, realpathSync as realpathSync6 } from "node:fs";
|
|
49231
|
-
import { isAbsolute as isAbsolute2, join as
|
|
49393
|
+
import { isAbsolute as isAbsolute2, join as join12, relative as relative2 } from "node:path";
|
|
49232
49394
|
function pass3(id, detail = DOCTOR_PASS_DETAIL) {
|
|
49233
49395
|
return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
|
|
49234
49396
|
}
|
|
@@ -49240,7 +49402,7 @@ function fail3(id, detail, fixCommand) {
|
|
|
49240
49402
|
}
|
|
49241
49403
|
function bundleVersion(bundleDir2) {
|
|
49242
49404
|
try {
|
|
49243
|
-
const v = JSON.parse(readFileSync8(
|
|
49405
|
+
const v = JSON.parse(readFileSync8(join12(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
|
|
49244
49406
|
return typeof v === "string" && v !== "" ? v : void 0;
|
|
49245
49407
|
} catch {
|
|
49246
49408
|
return void 0;
|
|
@@ -49335,12 +49497,12 @@ async function checkVersion(i) {
|
|
|
49335
49497
|
const head = D1_PREFIX(i.version, i.bundleSha) + ": ";
|
|
49336
49498
|
if (i.version === void 0) return unknown5("D1", head + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
|
|
49337
49499
|
const tag = channelOf(i.version);
|
|
49338
|
-
const
|
|
49500
|
+
const git2 = findRuntime(GIT_BIN, i.env);
|
|
49339
49501
|
const npm = await npmLatest(i.registryUrl, tag, i.signal, i.timeoutMs);
|
|
49340
49502
|
if (npm.ok) return versionRow(head, i.version, tag, D1_SOURCE_NPM, npm.version, "");
|
|
49341
49503
|
let cause = D1_GIT_MISSING;
|
|
49342
|
-
if (
|
|
49343
|
-
const r = await runProcess([
|
|
49504
|
+
if (git2 !== null) {
|
|
49505
|
+
const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
|
|
49344
49506
|
cwd: i.cwd,
|
|
49345
49507
|
env: { ...i.env, ...GIT_NO_PROMPT_ENV },
|
|
49346
49508
|
signal: i.signal,
|
|
@@ -49354,7 +49516,7 @@ async function checkVersion(i) {
|
|
|
49354
49516
|
cause = gitCause(r, i.timeoutMs);
|
|
49355
49517
|
}
|
|
49356
49518
|
}
|
|
49357
|
-
return unknown5("D1", head + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause,
|
|
49519
|
+
return unknown5("D1", head + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause, git2 === null ? D1_NPM_CHECK_FIX : D1_GIT_CHECK_FIX);
|
|
49358
49520
|
}
|
|
49359
49521
|
function numbers(v) {
|
|
49360
49522
|
const bare2 = v.startsWith(NODE_VERSION_PREFIX) ? v.slice(NODE_VERSION_PREFIX.length) : v;
|
|
@@ -49391,7 +49553,7 @@ function checkMcp(ctx) {
|
|
|
49391
49553
|
}
|
|
49392
49554
|
function piCwdInside(worktree, piCwd) {
|
|
49393
49555
|
if (piCwd === void 0 || !existsSync11(piCwd)) return false;
|
|
49394
|
-
const rel =
|
|
49556
|
+
const rel = relative2(worktree, realpathSync6.native(piCwd));
|
|
49395
49557
|
return rel === "" || !rel.startsWith("..") && !isAbsolute2(rel);
|
|
49396
49558
|
}
|
|
49397
49559
|
function checkProject(i) {
|
|
@@ -49411,10 +49573,1830 @@ function checkShell(env) {
|
|
|
49411
49573
|
}
|
|
49412
49574
|
|
|
49413
49575
|
// src/core/ops/doctor-hook.ts
|
|
49414
|
-
import { existsSync as existsSync13, mkdtempSync, readFileSync as readFileSync9, realpathSync as realpathSync8, rmSync as rmSync4 } from "node:fs";
|
|
49576
|
+
import { existsSync as existsSync13, mkdtempSync, readFileSync as readFileSync9, realpathSync as realpathSync8, rmSync as rmSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
49415
49577
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
49416
49578
|
import path7 from "node:path";
|
|
49417
49579
|
|
|
49580
|
+
// tests/fixtures/host-schemas/claude-code.json
|
|
49581
|
+
var claude_code_default = {
|
|
49582
|
+
host: "claude-code",
|
|
49583
|
+
source: "Claude Code 2.1.274 native binary, zod hook output schemas: top level eW, hookSpecificOutput union members xF (PreToolUse, permissionDecision enum FK), DF (UserPromptSubmit), UF (SessionStart), the PostToolUse member. zod drops keys it does not read, so each object lists only the keys the host reads.",
|
|
49584
|
+
output: {
|
|
49585
|
+
PreToolUse: {
|
|
49586
|
+
title: "Claude Code 2.1.274 PreToolUse reply",
|
|
49587
|
+
definitions: {
|
|
49588
|
+
Specific: {
|
|
49589
|
+
type: "object",
|
|
49590
|
+
additionalProperties: false,
|
|
49591
|
+
properties: {
|
|
49592
|
+
hookEventName: {
|
|
49593
|
+
type: "string",
|
|
49594
|
+
const: "PreToolUse"
|
|
49595
|
+
},
|
|
49596
|
+
permissionDecision: {
|
|
49597
|
+
type: "string",
|
|
49598
|
+
enum: [
|
|
49599
|
+
"allow",
|
|
49600
|
+
"deny",
|
|
49601
|
+
"ask",
|
|
49602
|
+
"defer"
|
|
49603
|
+
]
|
|
49604
|
+
},
|
|
49605
|
+
permissionDecisionReason: {
|
|
49606
|
+
type: "string"
|
|
49607
|
+
},
|
|
49608
|
+
updatedInput: {
|
|
49609
|
+
type: "object"
|
|
49610
|
+
},
|
|
49611
|
+
additionalContext: {
|
|
49612
|
+
type: "string"
|
|
49613
|
+
},
|
|
49614
|
+
permissionDisplay: {
|
|
49615
|
+
description: "@internal Desktop host only"
|
|
49616
|
+
}
|
|
49617
|
+
},
|
|
49618
|
+
required: [
|
|
49619
|
+
"hookEventName"
|
|
49620
|
+
]
|
|
49621
|
+
}
|
|
49622
|
+
},
|
|
49623
|
+
type: "object",
|
|
49624
|
+
additionalProperties: false,
|
|
49625
|
+
properties: {
|
|
49626
|
+
continue: {
|
|
49627
|
+
type: "boolean"
|
|
49628
|
+
},
|
|
49629
|
+
suppressOutput: {
|
|
49630
|
+
type: "boolean"
|
|
49631
|
+
},
|
|
49632
|
+
stopReason: {
|
|
49633
|
+
type: "string"
|
|
49634
|
+
},
|
|
49635
|
+
decision: {
|
|
49636
|
+
type: "string",
|
|
49637
|
+
enum: [
|
|
49638
|
+
"approve",
|
|
49639
|
+
"block"
|
|
49640
|
+
]
|
|
49641
|
+
},
|
|
49642
|
+
systemMessage: {
|
|
49643
|
+
type: "string"
|
|
49644
|
+
},
|
|
49645
|
+
terminalSequence: {
|
|
49646
|
+
type: "string"
|
|
49647
|
+
},
|
|
49648
|
+
reason: {
|
|
49649
|
+
type: "string"
|
|
49650
|
+
},
|
|
49651
|
+
hookSpecificOutput: {
|
|
49652
|
+
allOf: [
|
|
49653
|
+
{
|
|
49654
|
+
$ref: "#/definitions/Specific"
|
|
49655
|
+
}
|
|
49656
|
+
]
|
|
49657
|
+
}
|
|
49658
|
+
}
|
|
49659
|
+
},
|
|
49660
|
+
PostToolUse: {
|
|
49661
|
+
title: "Claude Code 2.1.274 PostToolUse reply",
|
|
49662
|
+
definitions: {
|
|
49663
|
+
Specific: {
|
|
49664
|
+
type: "object",
|
|
49665
|
+
additionalProperties: false,
|
|
49666
|
+
properties: {
|
|
49667
|
+
hookEventName: {
|
|
49668
|
+
type: "string",
|
|
49669
|
+
const: "PostToolUse"
|
|
49670
|
+
},
|
|
49671
|
+
additionalContext: {
|
|
49672
|
+
type: "string"
|
|
49673
|
+
},
|
|
49674
|
+
classifierContext: {
|
|
49675
|
+
type: "string"
|
|
49676
|
+
},
|
|
49677
|
+
updatedToolOutput: {
|
|
49678
|
+
description: "the tool's own output object"
|
|
49679
|
+
},
|
|
49680
|
+
updatedMCPToolOutput: {
|
|
49681
|
+
description: "an MCP tool's own output"
|
|
49682
|
+
}
|
|
49683
|
+
},
|
|
49684
|
+
required: [
|
|
49685
|
+
"hookEventName"
|
|
49686
|
+
]
|
|
49687
|
+
}
|
|
49688
|
+
},
|
|
49689
|
+
type: "object",
|
|
49690
|
+
additionalProperties: false,
|
|
49691
|
+
properties: {
|
|
49692
|
+
continue: {
|
|
49693
|
+
type: "boolean"
|
|
49694
|
+
},
|
|
49695
|
+
suppressOutput: {
|
|
49696
|
+
type: "boolean"
|
|
49697
|
+
},
|
|
49698
|
+
stopReason: {
|
|
49699
|
+
type: "string"
|
|
49700
|
+
},
|
|
49701
|
+
decision: {
|
|
49702
|
+
type: "string",
|
|
49703
|
+
enum: [
|
|
49704
|
+
"approve",
|
|
49705
|
+
"block"
|
|
49706
|
+
]
|
|
49707
|
+
},
|
|
49708
|
+
systemMessage: {
|
|
49709
|
+
type: "string"
|
|
49710
|
+
},
|
|
49711
|
+
terminalSequence: {
|
|
49712
|
+
type: "string"
|
|
49713
|
+
},
|
|
49714
|
+
reason: {
|
|
49715
|
+
type: "string"
|
|
49716
|
+
},
|
|
49717
|
+
hookSpecificOutput: {
|
|
49718
|
+
allOf: [
|
|
49719
|
+
{
|
|
49720
|
+
$ref: "#/definitions/Specific"
|
|
49721
|
+
}
|
|
49722
|
+
]
|
|
49723
|
+
}
|
|
49724
|
+
}
|
|
49725
|
+
},
|
|
49726
|
+
UserPromptSubmit: {
|
|
49727
|
+
title: "Claude Code 2.1.274 UserPromptSubmit reply",
|
|
49728
|
+
definitions: {
|
|
49729
|
+
Specific: {
|
|
49730
|
+
type: "object",
|
|
49731
|
+
additionalProperties: false,
|
|
49732
|
+
properties: {
|
|
49733
|
+
hookEventName: {
|
|
49734
|
+
type: "string",
|
|
49735
|
+
const: "UserPromptSubmit"
|
|
49736
|
+
},
|
|
49737
|
+
additionalContext: {
|
|
49738
|
+
type: "string"
|
|
49739
|
+
},
|
|
49740
|
+
sessionTitle: {
|
|
49741
|
+
type: "string"
|
|
49742
|
+
},
|
|
49743
|
+
suppressOriginalPrompt: {
|
|
49744
|
+
type: "boolean"
|
|
49745
|
+
}
|
|
49746
|
+
},
|
|
49747
|
+
required: [
|
|
49748
|
+
"hookEventName"
|
|
49749
|
+
]
|
|
49750
|
+
}
|
|
49751
|
+
},
|
|
49752
|
+
type: "object",
|
|
49753
|
+
additionalProperties: false,
|
|
49754
|
+
properties: {
|
|
49755
|
+
continue: {
|
|
49756
|
+
type: "boolean"
|
|
49757
|
+
},
|
|
49758
|
+
suppressOutput: {
|
|
49759
|
+
type: "boolean"
|
|
49760
|
+
},
|
|
49761
|
+
stopReason: {
|
|
49762
|
+
type: "string"
|
|
49763
|
+
},
|
|
49764
|
+
decision: {
|
|
49765
|
+
type: "string",
|
|
49766
|
+
enum: [
|
|
49767
|
+
"approve",
|
|
49768
|
+
"block"
|
|
49769
|
+
]
|
|
49770
|
+
},
|
|
49771
|
+
systemMessage: {
|
|
49772
|
+
type: "string"
|
|
49773
|
+
},
|
|
49774
|
+
terminalSequence: {
|
|
49775
|
+
type: "string"
|
|
49776
|
+
},
|
|
49777
|
+
reason: {
|
|
49778
|
+
type: "string"
|
|
49779
|
+
},
|
|
49780
|
+
hookSpecificOutput: {
|
|
49781
|
+
allOf: [
|
|
49782
|
+
{
|
|
49783
|
+
$ref: "#/definitions/Specific"
|
|
49784
|
+
}
|
|
49785
|
+
]
|
|
49786
|
+
}
|
|
49787
|
+
}
|
|
49788
|
+
},
|
|
49789
|
+
SessionStart: {
|
|
49790
|
+
title: "Claude Code 2.1.274 SessionStart reply",
|
|
49791
|
+
definitions: {
|
|
49792
|
+
Specific: {
|
|
49793
|
+
type: "object",
|
|
49794
|
+
additionalProperties: false,
|
|
49795
|
+
properties: {
|
|
49796
|
+
hookEventName: {
|
|
49797
|
+
type: "string",
|
|
49798
|
+
const: "SessionStart"
|
|
49799
|
+
},
|
|
49800
|
+
additionalContext: {
|
|
49801
|
+
type: "string"
|
|
49802
|
+
},
|
|
49803
|
+
initialUserMessage: {
|
|
49804
|
+
type: "string"
|
|
49805
|
+
},
|
|
49806
|
+
sessionTitle: {
|
|
49807
|
+
type: "string"
|
|
49808
|
+
},
|
|
49809
|
+
watchPaths: {
|
|
49810
|
+
type: "array",
|
|
49811
|
+
items: {
|
|
49812
|
+
type: "string"
|
|
49813
|
+
}
|
|
49814
|
+
},
|
|
49815
|
+
reloadSkills: {
|
|
49816
|
+
type: "boolean"
|
|
49817
|
+
}
|
|
49818
|
+
},
|
|
49819
|
+
required: [
|
|
49820
|
+
"hookEventName"
|
|
49821
|
+
]
|
|
49822
|
+
}
|
|
49823
|
+
},
|
|
49824
|
+
type: "object",
|
|
49825
|
+
additionalProperties: false,
|
|
49826
|
+
properties: {
|
|
49827
|
+
continue: {
|
|
49828
|
+
type: "boolean"
|
|
49829
|
+
},
|
|
49830
|
+
suppressOutput: {
|
|
49831
|
+
type: "boolean"
|
|
49832
|
+
},
|
|
49833
|
+
stopReason: {
|
|
49834
|
+
type: "string"
|
|
49835
|
+
},
|
|
49836
|
+
decision: {
|
|
49837
|
+
type: "string",
|
|
49838
|
+
enum: [
|
|
49839
|
+
"approve",
|
|
49840
|
+
"block"
|
|
49841
|
+
]
|
|
49842
|
+
},
|
|
49843
|
+
systemMessage: {
|
|
49844
|
+
type: "string"
|
|
49845
|
+
},
|
|
49846
|
+
terminalSequence: {
|
|
49847
|
+
type: "string"
|
|
49848
|
+
},
|
|
49849
|
+
reason: {
|
|
49850
|
+
type: "string"
|
|
49851
|
+
},
|
|
49852
|
+
hookSpecificOutput: {
|
|
49853
|
+
allOf: [
|
|
49854
|
+
{
|
|
49855
|
+
$ref: "#/definitions/Specific"
|
|
49856
|
+
}
|
|
49857
|
+
]
|
|
49858
|
+
}
|
|
49859
|
+
}
|
|
49860
|
+
}
|
|
49861
|
+
}
|
|
49862
|
+
};
|
|
49863
|
+
|
|
49864
|
+
// tests/fixtures/host-schemas/codex.json
|
|
49865
|
+
var codex_default = {
|
|
49866
|
+
host: "codex",
|
|
49867
|
+
source: "github.com/openai/codex tag rust-v0.166.0 codex-rs/hooks/schema/generated/*.command.output.schema.json",
|
|
49868
|
+
output: {
|
|
49869
|
+
PreToolUse: {
|
|
49870
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
49871
|
+
additionalProperties: false,
|
|
49872
|
+
definitions: {
|
|
49873
|
+
PreToolUseDecisionWire: {
|
|
49874
|
+
enum: [
|
|
49875
|
+
"approve",
|
|
49876
|
+
"block"
|
|
49877
|
+
],
|
|
49878
|
+
type: "string"
|
|
49879
|
+
},
|
|
49880
|
+
PreToolUseHookSpecificOutputWire: {
|
|
49881
|
+
additionalProperties: false,
|
|
49882
|
+
properties: {
|
|
49883
|
+
additionalContext: {
|
|
49884
|
+
default: null,
|
|
49885
|
+
type: "string"
|
|
49886
|
+
},
|
|
49887
|
+
hookEventName: {
|
|
49888
|
+
const: "PreToolUse",
|
|
49889
|
+
type: "string"
|
|
49890
|
+
},
|
|
49891
|
+
permissionDecision: {
|
|
49892
|
+
allOf: [
|
|
49893
|
+
{
|
|
49894
|
+
$ref: "#/definitions/PreToolUsePermissionDecisionWire"
|
|
49895
|
+
}
|
|
49896
|
+
],
|
|
49897
|
+
default: null
|
|
49898
|
+
},
|
|
49899
|
+
permissionDecisionReason: {
|
|
49900
|
+
default: null,
|
|
49901
|
+
type: "string"
|
|
49902
|
+
},
|
|
49903
|
+
updatedInput: {
|
|
49904
|
+
default: null
|
|
49905
|
+
}
|
|
49906
|
+
},
|
|
49907
|
+
required: [
|
|
49908
|
+
"hookEventName"
|
|
49909
|
+
],
|
|
49910
|
+
type: "object"
|
|
49911
|
+
},
|
|
49912
|
+
PreToolUsePermissionDecisionWire: {
|
|
49913
|
+
enum: [
|
|
49914
|
+
"allow",
|
|
49915
|
+
"deny",
|
|
49916
|
+
"ask"
|
|
49917
|
+
],
|
|
49918
|
+
type: "string"
|
|
49919
|
+
}
|
|
49920
|
+
},
|
|
49921
|
+
properties: {
|
|
49922
|
+
continue: {
|
|
49923
|
+
default: true,
|
|
49924
|
+
type: "boolean"
|
|
49925
|
+
},
|
|
49926
|
+
decision: {
|
|
49927
|
+
allOf: [
|
|
49928
|
+
{
|
|
49929
|
+
$ref: "#/definitions/PreToolUseDecisionWire"
|
|
49930
|
+
}
|
|
49931
|
+
],
|
|
49932
|
+
default: null
|
|
49933
|
+
},
|
|
49934
|
+
hookSpecificOutput: {
|
|
49935
|
+
allOf: [
|
|
49936
|
+
{
|
|
49937
|
+
$ref: "#/definitions/PreToolUseHookSpecificOutputWire"
|
|
49938
|
+
}
|
|
49939
|
+
],
|
|
49940
|
+
default: null
|
|
49941
|
+
},
|
|
49942
|
+
reason: {
|
|
49943
|
+
default: null,
|
|
49944
|
+
type: "string"
|
|
49945
|
+
},
|
|
49946
|
+
stopReason: {
|
|
49947
|
+
default: null,
|
|
49948
|
+
type: "string"
|
|
49949
|
+
},
|
|
49950
|
+
suppressOutput: {
|
|
49951
|
+
default: false,
|
|
49952
|
+
type: "boolean"
|
|
49953
|
+
},
|
|
49954
|
+
systemMessage: {
|
|
49955
|
+
default: null,
|
|
49956
|
+
type: "string"
|
|
49957
|
+
}
|
|
49958
|
+
},
|
|
49959
|
+
title: "pre-tool-use.command.output",
|
|
49960
|
+
type: "object"
|
|
49961
|
+
},
|
|
49962
|
+
PostToolUse: {
|
|
49963
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
49964
|
+
additionalProperties: false,
|
|
49965
|
+
definitions: {
|
|
49966
|
+
BlockDecisionWire: {
|
|
49967
|
+
enum: [
|
|
49968
|
+
"block"
|
|
49969
|
+
],
|
|
49970
|
+
type: "string"
|
|
49971
|
+
},
|
|
49972
|
+
PostToolUseHookSpecificOutputWire: {
|
|
49973
|
+
additionalProperties: false,
|
|
49974
|
+
properties: {
|
|
49975
|
+
additionalContext: {
|
|
49976
|
+
default: null,
|
|
49977
|
+
type: "string"
|
|
49978
|
+
},
|
|
49979
|
+
hookEventName: {
|
|
49980
|
+
const: "PostToolUse",
|
|
49981
|
+
type: "string"
|
|
49982
|
+
},
|
|
49983
|
+
updatedMCPToolOutput: {
|
|
49984
|
+
default: null
|
|
49985
|
+
}
|
|
49986
|
+
},
|
|
49987
|
+
required: [
|
|
49988
|
+
"hookEventName"
|
|
49989
|
+
],
|
|
49990
|
+
type: "object"
|
|
49991
|
+
}
|
|
49992
|
+
},
|
|
49993
|
+
properties: {
|
|
49994
|
+
continue: {
|
|
49995
|
+
default: true,
|
|
49996
|
+
type: "boolean"
|
|
49997
|
+
},
|
|
49998
|
+
decision: {
|
|
49999
|
+
allOf: [
|
|
50000
|
+
{
|
|
50001
|
+
$ref: "#/definitions/BlockDecisionWire"
|
|
50002
|
+
}
|
|
50003
|
+
],
|
|
50004
|
+
default: null
|
|
50005
|
+
},
|
|
50006
|
+
hookSpecificOutput: {
|
|
50007
|
+
allOf: [
|
|
50008
|
+
{
|
|
50009
|
+
$ref: "#/definitions/PostToolUseHookSpecificOutputWire"
|
|
50010
|
+
}
|
|
50011
|
+
],
|
|
50012
|
+
default: null
|
|
50013
|
+
},
|
|
50014
|
+
reason: {
|
|
50015
|
+
default: null,
|
|
50016
|
+
type: "string"
|
|
50017
|
+
},
|
|
50018
|
+
stopReason: {
|
|
50019
|
+
default: null,
|
|
50020
|
+
type: "string"
|
|
50021
|
+
},
|
|
50022
|
+
suppressOutput: {
|
|
50023
|
+
default: false,
|
|
50024
|
+
type: "boolean"
|
|
50025
|
+
},
|
|
50026
|
+
systemMessage: {
|
|
50027
|
+
default: null,
|
|
50028
|
+
type: "string"
|
|
50029
|
+
}
|
|
50030
|
+
},
|
|
50031
|
+
title: "post-tool-use.command.output",
|
|
50032
|
+
type: "object"
|
|
50033
|
+
},
|
|
50034
|
+
SessionStart: {
|
|
50035
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
50036
|
+
additionalProperties: false,
|
|
50037
|
+
definitions: {
|
|
50038
|
+
SessionStartHookSpecificOutputWire: {
|
|
50039
|
+
additionalProperties: false,
|
|
50040
|
+
properties: {
|
|
50041
|
+
additionalContext: {
|
|
50042
|
+
default: null,
|
|
50043
|
+
type: "string"
|
|
50044
|
+
},
|
|
50045
|
+
hookEventName: {
|
|
50046
|
+
const: "SessionStart",
|
|
50047
|
+
type: "string"
|
|
50048
|
+
}
|
|
50049
|
+
},
|
|
50050
|
+
required: [
|
|
50051
|
+
"hookEventName"
|
|
50052
|
+
],
|
|
50053
|
+
type: "object"
|
|
50054
|
+
}
|
|
50055
|
+
},
|
|
50056
|
+
properties: {
|
|
50057
|
+
continue: {
|
|
50058
|
+
default: true,
|
|
50059
|
+
type: "boolean"
|
|
50060
|
+
},
|
|
50061
|
+
hookSpecificOutput: {
|
|
50062
|
+
allOf: [
|
|
50063
|
+
{
|
|
50064
|
+
$ref: "#/definitions/SessionStartHookSpecificOutputWire"
|
|
50065
|
+
}
|
|
50066
|
+
],
|
|
50067
|
+
default: null
|
|
50068
|
+
},
|
|
50069
|
+
stopReason: {
|
|
50070
|
+
default: null,
|
|
50071
|
+
type: "string"
|
|
50072
|
+
},
|
|
50073
|
+
suppressOutput: {
|
|
50074
|
+
default: false,
|
|
50075
|
+
type: "boolean"
|
|
50076
|
+
},
|
|
50077
|
+
systemMessage: {
|
|
50078
|
+
default: null,
|
|
50079
|
+
type: "string"
|
|
50080
|
+
}
|
|
50081
|
+
},
|
|
50082
|
+
title: "session-start.command.output",
|
|
50083
|
+
type: "object"
|
|
50084
|
+
},
|
|
50085
|
+
UserPromptSubmit: {
|
|
50086
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
50087
|
+
additionalProperties: false,
|
|
50088
|
+
definitions: {
|
|
50089
|
+
BlockDecisionWire: {
|
|
50090
|
+
enum: [
|
|
50091
|
+
"block"
|
|
50092
|
+
],
|
|
50093
|
+
type: "string"
|
|
50094
|
+
},
|
|
50095
|
+
UserPromptSubmitHookSpecificOutputWire: {
|
|
50096
|
+
additionalProperties: false,
|
|
50097
|
+
properties: {
|
|
50098
|
+
additionalContext: {
|
|
50099
|
+
default: null,
|
|
50100
|
+
type: "string"
|
|
50101
|
+
},
|
|
50102
|
+
hookEventName: {
|
|
50103
|
+
const: "UserPromptSubmit",
|
|
50104
|
+
type: "string"
|
|
50105
|
+
}
|
|
50106
|
+
},
|
|
50107
|
+
required: [
|
|
50108
|
+
"hookEventName"
|
|
50109
|
+
],
|
|
50110
|
+
type: "object"
|
|
50111
|
+
}
|
|
50112
|
+
},
|
|
50113
|
+
properties: {
|
|
50114
|
+
continue: {
|
|
50115
|
+
default: true,
|
|
50116
|
+
type: "boolean"
|
|
50117
|
+
},
|
|
50118
|
+
decision: {
|
|
50119
|
+
allOf: [
|
|
50120
|
+
{
|
|
50121
|
+
$ref: "#/definitions/BlockDecisionWire"
|
|
50122
|
+
}
|
|
50123
|
+
],
|
|
50124
|
+
default: null
|
|
50125
|
+
},
|
|
50126
|
+
hookSpecificOutput: {
|
|
50127
|
+
allOf: [
|
|
50128
|
+
{
|
|
50129
|
+
$ref: "#/definitions/UserPromptSubmitHookSpecificOutputWire"
|
|
50130
|
+
}
|
|
50131
|
+
],
|
|
50132
|
+
default: null
|
|
50133
|
+
},
|
|
50134
|
+
reason: {
|
|
50135
|
+
default: null,
|
|
50136
|
+
type: "string"
|
|
50137
|
+
},
|
|
50138
|
+
stopReason: {
|
|
50139
|
+
default: null,
|
|
50140
|
+
type: "string"
|
|
50141
|
+
},
|
|
50142
|
+
suppressOutput: {
|
|
50143
|
+
default: false,
|
|
50144
|
+
type: "boolean"
|
|
50145
|
+
},
|
|
50146
|
+
systemMessage: {
|
|
50147
|
+
default: null,
|
|
50148
|
+
type: "string"
|
|
50149
|
+
}
|
|
50150
|
+
},
|
|
50151
|
+
title: "user-prompt-submit.command.output",
|
|
50152
|
+
type: "object"
|
|
50153
|
+
},
|
|
50154
|
+
Stop: {
|
|
50155
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
50156
|
+
additionalProperties: false,
|
|
50157
|
+
definitions: {
|
|
50158
|
+
BlockDecisionWire: {
|
|
50159
|
+
enum: [
|
|
50160
|
+
"block"
|
|
50161
|
+
],
|
|
50162
|
+
type: "string"
|
|
50163
|
+
}
|
|
50164
|
+
},
|
|
50165
|
+
properties: {
|
|
50166
|
+
continue: {
|
|
50167
|
+
default: true,
|
|
50168
|
+
type: "boolean"
|
|
50169
|
+
},
|
|
50170
|
+
decision: {
|
|
50171
|
+
allOf: [
|
|
50172
|
+
{
|
|
50173
|
+
$ref: "#/definitions/BlockDecisionWire"
|
|
50174
|
+
}
|
|
50175
|
+
],
|
|
50176
|
+
default: null
|
|
50177
|
+
},
|
|
50178
|
+
reason: {
|
|
50179
|
+
default: null,
|
|
50180
|
+
description: "Claude requires `reason` when `decision` is `block`; we enforce that semantic rule during output parsing rather than in the JSON schema.",
|
|
50181
|
+
type: "string"
|
|
50182
|
+
},
|
|
50183
|
+
stopReason: {
|
|
50184
|
+
default: null,
|
|
50185
|
+
type: "string"
|
|
50186
|
+
},
|
|
50187
|
+
suppressOutput: {
|
|
50188
|
+
default: false,
|
|
50189
|
+
type: "boolean"
|
|
50190
|
+
},
|
|
50191
|
+
systemMessage: {
|
|
50192
|
+
default: null,
|
|
50193
|
+
type: "string"
|
|
50194
|
+
}
|
|
50195
|
+
},
|
|
50196
|
+
title: "stop.command.output",
|
|
50197
|
+
type: "object"
|
|
50198
|
+
}
|
|
50199
|
+
}
|
|
50200
|
+
};
|
|
50201
|
+
|
|
50202
|
+
// tests/fixtures/host-schemas/gemini.json
|
|
50203
|
+
var gemini_default = {
|
|
50204
|
+
host: "gemini",
|
|
50205
|
+
source: "@google/gemini-cli 0.67.0: bundle/docs/hooks/reference.md (Common output fields; BeforeTool, AfterTool, BeforeAgent, SessionStart output fields) and bundle/chunk-O7MGOE2I.js HookOutput (isBlockingDecision block|deny, isAskDecision ask). Keys are canonical events; each title names the native event.",
|
|
50206
|
+
output: {
|
|
50207
|
+
PreToolUse: {
|
|
50208
|
+
title: "Gemini CLI 0.67.0 BeforeTool reply",
|
|
50209
|
+
definitions: {
|
|
50210
|
+
Specific: {
|
|
50211
|
+
type: "object",
|
|
50212
|
+
additionalProperties: false,
|
|
50213
|
+
properties: {
|
|
50214
|
+
hookEventName: {
|
|
50215
|
+
type: "string"
|
|
50216
|
+
},
|
|
50217
|
+
tool_input: {
|
|
50218
|
+
type: "object"
|
|
50219
|
+
}
|
|
50220
|
+
}
|
|
50221
|
+
}
|
|
50222
|
+
},
|
|
50223
|
+
type: "object",
|
|
50224
|
+
additionalProperties: false,
|
|
50225
|
+
properties: {
|
|
50226
|
+
systemMessage: {
|
|
50227
|
+
type: "string"
|
|
50228
|
+
},
|
|
50229
|
+
suppressOutput: {
|
|
50230
|
+
type: "boolean"
|
|
50231
|
+
},
|
|
50232
|
+
continue: {
|
|
50233
|
+
type: "boolean"
|
|
50234
|
+
},
|
|
50235
|
+
stopReason: {
|
|
50236
|
+
type: "string"
|
|
50237
|
+
},
|
|
50238
|
+
decision: {
|
|
50239
|
+
type: "string",
|
|
50240
|
+
enum: [
|
|
50241
|
+
"allow",
|
|
50242
|
+
"deny",
|
|
50243
|
+
"block",
|
|
50244
|
+
"ask"
|
|
50245
|
+
]
|
|
50246
|
+
},
|
|
50247
|
+
reason: {
|
|
50248
|
+
type: "string"
|
|
50249
|
+
},
|
|
50250
|
+
hookSpecificOutput: {
|
|
50251
|
+
allOf: [
|
|
50252
|
+
{
|
|
50253
|
+
$ref: "#/definitions/Specific"
|
|
50254
|
+
}
|
|
50255
|
+
]
|
|
50256
|
+
}
|
|
50257
|
+
}
|
|
50258
|
+
},
|
|
50259
|
+
PostToolUse: {
|
|
50260
|
+
title: "Gemini CLI 0.67.0 AfterTool reply",
|
|
50261
|
+
definitions: {
|
|
50262
|
+
Specific: {
|
|
50263
|
+
type: "object",
|
|
50264
|
+
additionalProperties: false,
|
|
50265
|
+
properties: {
|
|
50266
|
+
hookEventName: {
|
|
50267
|
+
type: "string"
|
|
50268
|
+
},
|
|
50269
|
+
additionalContext: {
|
|
50270
|
+
type: "string"
|
|
50271
|
+
},
|
|
50272
|
+
tailToolCallRequest: {
|
|
50273
|
+
type: "object",
|
|
50274
|
+
additionalProperties: false,
|
|
50275
|
+
properties: {
|
|
50276
|
+
name: {
|
|
50277
|
+
type: "string"
|
|
50278
|
+
},
|
|
50279
|
+
args: {
|
|
50280
|
+
type: "object"
|
|
50281
|
+
}
|
|
50282
|
+
},
|
|
50283
|
+
required: [
|
|
50284
|
+
"name",
|
|
50285
|
+
"args"
|
|
50286
|
+
]
|
|
50287
|
+
}
|
|
50288
|
+
}
|
|
50289
|
+
}
|
|
50290
|
+
},
|
|
50291
|
+
type: "object",
|
|
50292
|
+
additionalProperties: false,
|
|
50293
|
+
properties: {
|
|
50294
|
+
systemMessage: {
|
|
50295
|
+
type: "string"
|
|
50296
|
+
},
|
|
50297
|
+
suppressOutput: {
|
|
50298
|
+
type: "boolean"
|
|
50299
|
+
},
|
|
50300
|
+
continue: {
|
|
50301
|
+
type: "boolean"
|
|
50302
|
+
},
|
|
50303
|
+
stopReason: {
|
|
50304
|
+
type: "string"
|
|
50305
|
+
},
|
|
50306
|
+
decision: {
|
|
50307
|
+
type: "string",
|
|
50308
|
+
enum: [
|
|
50309
|
+
"allow",
|
|
50310
|
+
"deny",
|
|
50311
|
+
"block",
|
|
50312
|
+
"ask"
|
|
50313
|
+
]
|
|
50314
|
+
},
|
|
50315
|
+
reason: {
|
|
50316
|
+
type: "string"
|
|
50317
|
+
},
|
|
50318
|
+
hookSpecificOutput: {
|
|
50319
|
+
allOf: [
|
|
50320
|
+
{
|
|
50321
|
+
$ref: "#/definitions/Specific"
|
|
50322
|
+
}
|
|
50323
|
+
]
|
|
50324
|
+
}
|
|
50325
|
+
}
|
|
50326
|
+
},
|
|
50327
|
+
UserPromptSubmit: {
|
|
50328
|
+
title: "Gemini CLI 0.67.0 BeforeAgent reply",
|
|
50329
|
+
definitions: {
|
|
50330
|
+
Specific: {
|
|
50331
|
+
type: "object",
|
|
50332
|
+
additionalProperties: false,
|
|
50333
|
+
properties: {
|
|
50334
|
+
hookEventName: {
|
|
50335
|
+
type: "string"
|
|
50336
|
+
},
|
|
50337
|
+
additionalContext: {
|
|
50338
|
+
type: "string"
|
|
50339
|
+
}
|
|
50340
|
+
}
|
|
50341
|
+
}
|
|
50342
|
+
},
|
|
50343
|
+
type: "object",
|
|
50344
|
+
additionalProperties: false,
|
|
50345
|
+
properties: {
|
|
50346
|
+
systemMessage: {
|
|
50347
|
+
type: "string"
|
|
50348
|
+
},
|
|
50349
|
+
suppressOutput: {
|
|
50350
|
+
type: "boolean"
|
|
50351
|
+
},
|
|
50352
|
+
continue: {
|
|
50353
|
+
type: "boolean"
|
|
50354
|
+
},
|
|
50355
|
+
stopReason: {
|
|
50356
|
+
type: "string"
|
|
50357
|
+
},
|
|
50358
|
+
decision: {
|
|
50359
|
+
type: "string",
|
|
50360
|
+
enum: [
|
|
50361
|
+
"allow",
|
|
50362
|
+
"deny",
|
|
50363
|
+
"block",
|
|
50364
|
+
"ask"
|
|
50365
|
+
]
|
|
50366
|
+
},
|
|
50367
|
+
reason: {
|
|
50368
|
+
type: "string"
|
|
50369
|
+
},
|
|
50370
|
+
hookSpecificOutput: {
|
|
50371
|
+
allOf: [
|
|
50372
|
+
{
|
|
50373
|
+
$ref: "#/definitions/Specific"
|
|
50374
|
+
}
|
|
50375
|
+
]
|
|
50376
|
+
}
|
|
50377
|
+
}
|
|
50378
|
+
},
|
|
50379
|
+
SessionStart: {
|
|
50380
|
+
title: "Gemini CLI 0.67.0 SessionStart reply",
|
|
50381
|
+
definitions: {
|
|
50382
|
+
Specific: {
|
|
50383
|
+
type: "object",
|
|
50384
|
+
additionalProperties: false,
|
|
50385
|
+
properties: {
|
|
50386
|
+
hookEventName: {
|
|
50387
|
+
type: "string"
|
|
50388
|
+
},
|
|
50389
|
+
additionalContext: {
|
|
50390
|
+
type: "string"
|
|
50391
|
+
}
|
|
50392
|
+
}
|
|
50393
|
+
}
|
|
50394
|
+
},
|
|
50395
|
+
type: "object",
|
|
50396
|
+
additionalProperties: false,
|
|
50397
|
+
properties: {
|
|
50398
|
+
systemMessage: {
|
|
50399
|
+
type: "string"
|
|
50400
|
+
},
|
|
50401
|
+
suppressOutput: {
|
|
50402
|
+
type: "boolean"
|
|
50403
|
+
},
|
|
50404
|
+
continue: {
|
|
50405
|
+
type: "boolean"
|
|
50406
|
+
},
|
|
50407
|
+
stopReason: {
|
|
50408
|
+
type: "string"
|
|
50409
|
+
},
|
|
50410
|
+
decision: {
|
|
50411
|
+
type: "string",
|
|
50412
|
+
enum: [
|
|
50413
|
+
"allow",
|
|
50414
|
+
"deny",
|
|
50415
|
+
"block",
|
|
50416
|
+
"ask"
|
|
50417
|
+
]
|
|
50418
|
+
},
|
|
50419
|
+
reason: {
|
|
50420
|
+
type: "string"
|
|
50421
|
+
},
|
|
50422
|
+
hookSpecificOutput: {
|
|
50423
|
+
allOf: [
|
|
50424
|
+
{
|
|
50425
|
+
$ref: "#/definitions/Specific"
|
|
50426
|
+
}
|
|
50427
|
+
]
|
|
50428
|
+
}
|
|
50429
|
+
}
|
|
50430
|
+
}
|
|
50431
|
+
}
|
|
50432
|
+
};
|
|
50433
|
+
|
|
50434
|
+
// tests/fixtures/host-schemas/qwen.json
|
|
50435
|
+
var qwen_default = {
|
|
50436
|
+
host: "qwen",
|
|
50437
|
+
source: "@qwen-code/qwen-code 0.26.7: bundled/qc-helper/docs/features/hooks.md (Hook Output Structure, per-event Output Options) and chunks/chunk-6GTPLW7K.js HookOutput (getPermissionDecision reads hookSpecificOutput.permissionDecision allow|deny|ask, then decision allow|approve|deny|block|ask; a missing permissionDecision is no decision).",
|
|
50438
|
+
output: {
|
|
50439
|
+
PreToolUse: {
|
|
50440
|
+
title: "Qwen Code 0.26.7 PreToolUse reply",
|
|
50441
|
+
definitions: {
|
|
50442
|
+
Specific: {
|
|
50443
|
+
type: "object",
|
|
50444
|
+
additionalProperties: false,
|
|
50445
|
+
properties: {
|
|
50446
|
+
hookEventName: {
|
|
50447
|
+
type: "string",
|
|
50448
|
+
const: "PreToolUse"
|
|
50449
|
+
},
|
|
50450
|
+
permissionDecision: {
|
|
50451
|
+
type: "string",
|
|
50452
|
+
enum: [
|
|
50453
|
+
"allow",
|
|
50454
|
+
"deny",
|
|
50455
|
+
"ask"
|
|
50456
|
+
]
|
|
50457
|
+
},
|
|
50458
|
+
permissionDecisionReason: {
|
|
50459
|
+
type: "string"
|
|
50460
|
+
},
|
|
50461
|
+
updatedInput: {
|
|
50462
|
+
type: "object"
|
|
50463
|
+
},
|
|
50464
|
+
additionalContext: {
|
|
50465
|
+
type: "string"
|
|
50466
|
+
}
|
|
50467
|
+
},
|
|
50468
|
+
required: [
|
|
50469
|
+
"hookEventName"
|
|
50470
|
+
]
|
|
50471
|
+
}
|
|
50472
|
+
},
|
|
50473
|
+
type: "object",
|
|
50474
|
+
additionalProperties: false,
|
|
50475
|
+
properties: {
|
|
50476
|
+
continue: {
|
|
50477
|
+
type: "boolean"
|
|
50478
|
+
},
|
|
50479
|
+
stopReason: {
|
|
50480
|
+
type: "string"
|
|
50481
|
+
},
|
|
50482
|
+
suppressOutput: {
|
|
50483
|
+
type: "boolean"
|
|
50484
|
+
},
|
|
50485
|
+
systemMessage: {
|
|
50486
|
+
type: "string"
|
|
50487
|
+
},
|
|
50488
|
+
decision: {
|
|
50489
|
+
type: "string",
|
|
50490
|
+
enum: [
|
|
50491
|
+
"allow",
|
|
50492
|
+
"approve",
|
|
50493
|
+
"deny",
|
|
50494
|
+
"block",
|
|
50495
|
+
"ask"
|
|
50496
|
+
]
|
|
50497
|
+
},
|
|
50498
|
+
reason: {
|
|
50499
|
+
type: "string"
|
|
50500
|
+
},
|
|
50501
|
+
hookSpecificOutput: {
|
|
50502
|
+
allOf: [
|
|
50503
|
+
{
|
|
50504
|
+
$ref: "#/definitions/Specific"
|
|
50505
|
+
}
|
|
50506
|
+
]
|
|
50507
|
+
}
|
|
50508
|
+
}
|
|
50509
|
+
},
|
|
50510
|
+
PostToolUse: {
|
|
50511
|
+
title: "Qwen Code 0.26.7 PostToolUse reply",
|
|
50512
|
+
definitions: {
|
|
50513
|
+
Specific: {
|
|
50514
|
+
type: "object",
|
|
50515
|
+
additionalProperties: false,
|
|
50516
|
+
properties: {
|
|
50517
|
+
hookEventName: {
|
|
50518
|
+
type: "string",
|
|
50519
|
+
const: "PostToolUse"
|
|
50520
|
+
},
|
|
50521
|
+
additionalContext: {
|
|
50522
|
+
type: "string"
|
|
50523
|
+
}
|
|
50524
|
+
},
|
|
50525
|
+
required: [
|
|
50526
|
+
"hookEventName"
|
|
50527
|
+
]
|
|
50528
|
+
}
|
|
50529
|
+
},
|
|
50530
|
+
type: "object",
|
|
50531
|
+
additionalProperties: false,
|
|
50532
|
+
properties: {
|
|
50533
|
+
continue: {
|
|
50534
|
+
type: "boolean"
|
|
50535
|
+
},
|
|
50536
|
+
stopReason: {
|
|
50537
|
+
type: "string"
|
|
50538
|
+
},
|
|
50539
|
+
suppressOutput: {
|
|
50540
|
+
type: "boolean"
|
|
50541
|
+
},
|
|
50542
|
+
systemMessage: {
|
|
50543
|
+
type: "string"
|
|
50544
|
+
},
|
|
50545
|
+
decision: {
|
|
50546
|
+
type: "string",
|
|
50547
|
+
enum: [
|
|
50548
|
+
"allow",
|
|
50549
|
+
"approve",
|
|
50550
|
+
"deny",
|
|
50551
|
+
"block",
|
|
50552
|
+
"ask"
|
|
50553
|
+
]
|
|
50554
|
+
},
|
|
50555
|
+
reason: {
|
|
50556
|
+
type: "string"
|
|
50557
|
+
},
|
|
50558
|
+
hookSpecificOutput: {
|
|
50559
|
+
allOf: [
|
|
50560
|
+
{
|
|
50561
|
+
$ref: "#/definitions/Specific"
|
|
50562
|
+
}
|
|
50563
|
+
]
|
|
50564
|
+
}
|
|
50565
|
+
}
|
|
50566
|
+
},
|
|
50567
|
+
UserPromptSubmit: {
|
|
50568
|
+
title: "Qwen Code 0.26.7 UserPromptSubmit reply",
|
|
50569
|
+
definitions: {
|
|
50570
|
+
Specific: {
|
|
50571
|
+
type: "object",
|
|
50572
|
+
additionalProperties: false,
|
|
50573
|
+
properties: {
|
|
50574
|
+
hookEventName: {
|
|
50575
|
+
type: "string",
|
|
50576
|
+
const: "UserPromptSubmit"
|
|
50577
|
+
},
|
|
50578
|
+
additionalContext: {
|
|
50579
|
+
type: "string"
|
|
50580
|
+
}
|
|
50581
|
+
},
|
|
50582
|
+
required: [
|
|
50583
|
+
"hookEventName"
|
|
50584
|
+
]
|
|
50585
|
+
}
|
|
50586
|
+
},
|
|
50587
|
+
type: "object",
|
|
50588
|
+
additionalProperties: false,
|
|
50589
|
+
properties: {
|
|
50590
|
+
continue: {
|
|
50591
|
+
type: "boolean"
|
|
50592
|
+
},
|
|
50593
|
+
stopReason: {
|
|
50594
|
+
type: "string"
|
|
50595
|
+
},
|
|
50596
|
+
suppressOutput: {
|
|
50597
|
+
type: "boolean"
|
|
50598
|
+
},
|
|
50599
|
+
systemMessage: {
|
|
50600
|
+
type: "string"
|
|
50601
|
+
},
|
|
50602
|
+
decision: {
|
|
50603
|
+
type: "string",
|
|
50604
|
+
enum: [
|
|
50605
|
+
"allow",
|
|
50606
|
+
"approve",
|
|
50607
|
+
"deny",
|
|
50608
|
+
"block",
|
|
50609
|
+
"ask"
|
|
50610
|
+
]
|
|
50611
|
+
},
|
|
50612
|
+
reason: {
|
|
50613
|
+
type: "string"
|
|
50614
|
+
},
|
|
50615
|
+
hookSpecificOutput: {
|
|
50616
|
+
allOf: [
|
|
50617
|
+
{
|
|
50618
|
+
$ref: "#/definitions/Specific"
|
|
50619
|
+
}
|
|
50620
|
+
]
|
|
50621
|
+
}
|
|
50622
|
+
}
|
|
50623
|
+
},
|
|
50624
|
+
SessionStart: {
|
|
50625
|
+
title: "Qwen Code 0.26.7 SessionStart reply",
|
|
50626
|
+
definitions: {
|
|
50627
|
+
Specific: {
|
|
50628
|
+
type: "object",
|
|
50629
|
+
additionalProperties: false,
|
|
50630
|
+
properties: {
|
|
50631
|
+
hookEventName: {
|
|
50632
|
+
type: "string",
|
|
50633
|
+
const: "SessionStart"
|
|
50634
|
+
},
|
|
50635
|
+
additionalContext: {
|
|
50636
|
+
type: "string"
|
|
50637
|
+
}
|
|
50638
|
+
},
|
|
50639
|
+
required: [
|
|
50640
|
+
"hookEventName"
|
|
50641
|
+
]
|
|
50642
|
+
}
|
|
50643
|
+
},
|
|
50644
|
+
type: "object",
|
|
50645
|
+
additionalProperties: false,
|
|
50646
|
+
properties: {
|
|
50647
|
+
continue: {
|
|
50648
|
+
type: "boolean"
|
|
50649
|
+
},
|
|
50650
|
+
stopReason: {
|
|
50651
|
+
type: "string"
|
|
50652
|
+
},
|
|
50653
|
+
suppressOutput: {
|
|
50654
|
+
type: "boolean"
|
|
50655
|
+
},
|
|
50656
|
+
systemMessage: {
|
|
50657
|
+
type: "string"
|
|
50658
|
+
},
|
|
50659
|
+
decision: {
|
|
50660
|
+
type: "string",
|
|
50661
|
+
enum: [
|
|
50662
|
+
"allow",
|
|
50663
|
+
"approve",
|
|
50664
|
+
"deny",
|
|
50665
|
+
"block",
|
|
50666
|
+
"ask"
|
|
50667
|
+
]
|
|
50668
|
+
},
|
|
50669
|
+
reason: {
|
|
50670
|
+
type: "string"
|
|
50671
|
+
},
|
|
50672
|
+
hookSpecificOutput: {
|
|
50673
|
+
allOf: [
|
|
50674
|
+
{
|
|
50675
|
+
$ref: "#/definitions/Specific"
|
|
50676
|
+
}
|
|
50677
|
+
]
|
|
50678
|
+
}
|
|
50679
|
+
}
|
|
50680
|
+
}
|
|
50681
|
+
}
|
|
50682
|
+
};
|
|
50683
|
+
|
|
50684
|
+
// tests/fixtures/host-schemas/copilot-cli.json
|
|
50685
|
+
var copilot_cli_default = {
|
|
50686
|
+
host: "copilot-cli",
|
|
50687
|
+
source: "GitHub Copilot CLI 1.0.105 copilot-sdk/types.d.ts: PreToolUseHookOutput, PostToolUseHookOutput (modifiedResult: ToolResultObject, ToolResultType), UserPromptSubmittedHookOutput, SessionStartHookOutput. Replies are flat objects with no hookSpecificOutput.",
|
|
50688
|
+
output: {
|
|
50689
|
+
PreToolUse: {
|
|
50690
|
+
title: "Copilot CLI 1.0.105 preToolUse reply",
|
|
50691
|
+
type: "object",
|
|
50692
|
+
additionalProperties: false,
|
|
50693
|
+
properties: {
|
|
50694
|
+
permissionDecision: {
|
|
50695
|
+
type: "string",
|
|
50696
|
+
enum: [
|
|
50697
|
+
"allow",
|
|
50698
|
+
"deny",
|
|
50699
|
+
"ask"
|
|
50700
|
+
]
|
|
50701
|
+
},
|
|
50702
|
+
permissionDecisionReason: {
|
|
50703
|
+
type: "string"
|
|
50704
|
+
},
|
|
50705
|
+
modifiedArgs: {
|
|
50706
|
+
description: "unknown"
|
|
50707
|
+
},
|
|
50708
|
+
additionalContext: {
|
|
50709
|
+
type: "string"
|
|
50710
|
+
},
|
|
50711
|
+
suppressOutput: {
|
|
50712
|
+
type: "boolean"
|
|
50713
|
+
}
|
|
50714
|
+
}
|
|
50715
|
+
},
|
|
50716
|
+
PostToolUse: {
|
|
50717
|
+
title: "Copilot CLI 1.0.105 postToolUse reply",
|
|
50718
|
+
definitions: {
|
|
50719
|
+
ToolResultObject: {
|
|
50720
|
+
type: "object",
|
|
50721
|
+
additionalProperties: false,
|
|
50722
|
+
properties: {
|
|
50723
|
+
textResultForLlm: {
|
|
50724
|
+
type: "string"
|
|
50725
|
+
},
|
|
50726
|
+
binaryResultsForLlm: {
|
|
50727
|
+
type: "array",
|
|
50728
|
+
items: {
|
|
50729
|
+
type: "object"
|
|
50730
|
+
}
|
|
50731
|
+
},
|
|
50732
|
+
resultType: {
|
|
50733
|
+
type: "string",
|
|
50734
|
+
enum: [
|
|
50735
|
+
"success",
|
|
50736
|
+
"failure",
|
|
50737
|
+
"rejected",
|
|
50738
|
+
"denied",
|
|
50739
|
+
"timeout"
|
|
50740
|
+
]
|
|
50741
|
+
},
|
|
50742
|
+
error: {
|
|
50743
|
+
type: "string"
|
|
50744
|
+
},
|
|
50745
|
+
sessionLog: {
|
|
50746
|
+
type: "string"
|
|
50747
|
+
},
|
|
50748
|
+
toolTelemetry: {
|
|
50749
|
+
type: "object"
|
|
50750
|
+
},
|
|
50751
|
+
toolReferences: {
|
|
50752
|
+
type: "array",
|
|
50753
|
+
items: {
|
|
50754
|
+
type: "string"
|
|
50755
|
+
}
|
|
50756
|
+
}
|
|
50757
|
+
},
|
|
50758
|
+
required: [
|
|
50759
|
+
"textResultForLlm",
|
|
50760
|
+
"resultType"
|
|
50761
|
+
]
|
|
50762
|
+
}
|
|
50763
|
+
},
|
|
50764
|
+
type: "object",
|
|
50765
|
+
additionalProperties: false,
|
|
50766
|
+
properties: {
|
|
50767
|
+
modifiedResult: {
|
|
50768
|
+
allOf: [
|
|
50769
|
+
{
|
|
50770
|
+
$ref: "#/definitions/ToolResultObject"
|
|
50771
|
+
}
|
|
50772
|
+
]
|
|
50773
|
+
},
|
|
50774
|
+
additionalContext: {
|
|
50775
|
+
type: "string"
|
|
50776
|
+
},
|
|
50777
|
+
suppressOutput: {
|
|
50778
|
+
type: "boolean"
|
|
50779
|
+
}
|
|
50780
|
+
}
|
|
50781
|
+
},
|
|
50782
|
+
UserPromptSubmit: {
|
|
50783
|
+
title: "Copilot CLI 1.0.105 userPromptSubmitted reply",
|
|
50784
|
+
type: "object",
|
|
50785
|
+
additionalProperties: false,
|
|
50786
|
+
properties: {
|
|
50787
|
+
modifiedPrompt: {
|
|
50788
|
+
type: "string"
|
|
50789
|
+
},
|
|
50790
|
+
additionalContext: {
|
|
50791
|
+
type: "string"
|
|
50792
|
+
},
|
|
50793
|
+
suppressOutput: {
|
|
50794
|
+
type: "boolean"
|
|
50795
|
+
},
|
|
50796
|
+
decision: {
|
|
50797
|
+
type: "string",
|
|
50798
|
+
const: "block"
|
|
50799
|
+
},
|
|
50800
|
+
reason: {
|
|
50801
|
+
type: "string"
|
|
50802
|
+
}
|
|
50803
|
+
}
|
|
50804
|
+
},
|
|
50805
|
+
SessionStart: {
|
|
50806
|
+
title: "Copilot CLI 1.0.105 sessionStart reply",
|
|
50807
|
+
type: "object",
|
|
50808
|
+
additionalProperties: false,
|
|
50809
|
+
properties: {
|
|
50810
|
+
additionalContext: {
|
|
50811
|
+
type: "string"
|
|
50812
|
+
},
|
|
50813
|
+
modifiedConfig: {
|
|
50814
|
+
type: "object"
|
|
50815
|
+
}
|
|
50816
|
+
}
|
|
50817
|
+
}
|
|
50818
|
+
}
|
|
50819
|
+
};
|
|
50820
|
+
|
|
50821
|
+
// tests/fixtures/host-schemas/vscode.json
|
|
50822
|
+
var vscode_default = {
|
|
50823
|
+
host: "vscode",
|
|
50824
|
+
source: "VS Code Copilot Chat 0.44.0 (5863f5a) src/platform/chat/common/hookCommandTypes.ts (IPreToolUseHookSpecificCommandOutput, IPostToolUseHookSpecificCommandOutput) and chatHookService.ts (UserPromptSubmitHookOutput, SessionStartHookOutput, IPostToolUseHookResult decision 'block').",
|
|
50825
|
+
output: {
|
|
50826
|
+
PreToolUse: {
|
|
50827
|
+
title: "VS Code Copilot Chat 0.44.0 PreToolUse reply",
|
|
50828
|
+
definitions: {
|
|
50829
|
+
Specific: {
|
|
50830
|
+
type: "object",
|
|
50831
|
+
additionalProperties: false,
|
|
50832
|
+
properties: {
|
|
50833
|
+
hookEventName: {
|
|
50834
|
+
type: "string"
|
|
50835
|
+
},
|
|
50836
|
+
permissionDecision: {
|
|
50837
|
+
type: "string",
|
|
50838
|
+
enum: [
|
|
50839
|
+
"allow",
|
|
50840
|
+
"deny",
|
|
50841
|
+
"ask"
|
|
50842
|
+
]
|
|
50843
|
+
},
|
|
50844
|
+
permissionDecisionReason: {
|
|
50845
|
+
type: "string"
|
|
50846
|
+
},
|
|
50847
|
+
updatedInput: {
|
|
50848
|
+
type: "object"
|
|
50849
|
+
},
|
|
50850
|
+
additionalContext: {
|
|
50851
|
+
type: "string"
|
|
50852
|
+
}
|
|
50853
|
+
}
|
|
50854
|
+
}
|
|
50855
|
+
},
|
|
50856
|
+
type: "object",
|
|
50857
|
+
additionalProperties: false,
|
|
50858
|
+
properties: {
|
|
50859
|
+
hookSpecificOutput: {
|
|
50860
|
+
allOf: [
|
|
50861
|
+
{
|
|
50862
|
+
$ref: "#/definitions/Specific"
|
|
50863
|
+
}
|
|
50864
|
+
]
|
|
50865
|
+
}
|
|
50866
|
+
}
|
|
50867
|
+
},
|
|
50868
|
+
PostToolUse: {
|
|
50869
|
+
title: "VS Code Copilot Chat 0.44.0 PostToolUse reply",
|
|
50870
|
+
definitions: {
|
|
50871
|
+
Specific: {
|
|
50872
|
+
type: "object",
|
|
50873
|
+
additionalProperties: false,
|
|
50874
|
+
properties: {
|
|
50875
|
+
hookEventName: {
|
|
50876
|
+
type: "string"
|
|
50877
|
+
},
|
|
50878
|
+
additionalContext: {
|
|
50879
|
+
type: "string"
|
|
50880
|
+
}
|
|
50881
|
+
}
|
|
50882
|
+
}
|
|
50883
|
+
},
|
|
50884
|
+
type: "object",
|
|
50885
|
+
additionalProperties: false,
|
|
50886
|
+
properties: {
|
|
50887
|
+
decision: {
|
|
50888
|
+
type: "string",
|
|
50889
|
+
const: "block"
|
|
50890
|
+
},
|
|
50891
|
+
reason: {
|
|
50892
|
+
type: "string"
|
|
50893
|
+
},
|
|
50894
|
+
hookSpecificOutput: {
|
|
50895
|
+
allOf: [
|
|
50896
|
+
{
|
|
50897
|
+
$ref: "#/definitions/Specific"
|
|
50898
|
+
}
|
|
50899
|
+
]
|
|
50900
|
+
}
|
|
50901
|
+
}
|
|
50902
|
+
},
|
|
50903
|
+
UserPromptSubmit: {
|
|
50904
|
+
title: "VS Code Copilot Chat 0.44.0 UserPromptSubmit reply",
|
|
50905
|
+
definitions: {
|
|
50906
|
+
Specific: {
|
|
50907
|
+
type: "object",
|
|
50908
|
+
additionalProperties: false,
|
|
50909
|
+
properties: {
|
|
50910
|
+
hookEventName: {
|
|
50911
|
+
type: "string"
|
|
50912
|
+
},
|
|
50913
|
+
additionalContext: {
|
|
50914
|
+
type: "string"
|
|
50915
|
+
}
|
|
50916
|
+
}
|
|
50917
|
+
}
|
|
50918
|
+
},
|
|
50919
|
+
type: "object",
|
|
50920
|
+
additionalProperties: false,
|
|
50921
|
+
properties: {
|
|
50922
|
+
decision: {
|
|
50923
|
+
type: "string",
|
|
50924
|
+
const: "block"
|
|
50925
|
+
},
|
|
50926
|
+
reason: {
|
|
50927
|
+
type: "string"
|
|
50928
|
+
},
|
|
50929
|
+
hookSpecificOutput: {
|
|
50930
|
+
allOf: [
|
|
50931
|
+
{
|
|
50932
|
+
$ref: "#/definitions/Specific"
|
|
50933
|
+
}
|
|
50934
|
+
]
|
|
50935
|
+
}
|
|
50936
|
+
}
|
|
50937
|
+
},
|
|
50938
|
+
SessionStart: {
|
|
50939
|
+
title: "VS Code Copilot Chat 0.44.0 SessionStart reply",
|
|
50940
|
+
definitions: {
|
|
50941
|
+
Specific: {
|
|
50942
|
+
type: "object",
|
|
50943
|
+
additionalProperties: false,
|
|
50944
|
+
properties: {
|
|
50945
|
+
hookEventName: {
|
|
50946
|
+
type: "string"
|
|
50947
|
+
},
|
|
50948
|
+
additionalContext: {
|
|
50949
|
+
type: "string"
|
|
50950
|
+
}
|
|
50951
|
+
}
|
|
50952
|
+
}
|
|
50953
|
+
},
|
|
50954
|
+
type: "object",
|
|
50955
|
+
additionalProperties: false,
|
|
50956
|
+
properties: {
|
|
50957
|
+
hookSpecificOutput: {
|
|
50958
|
+
allOf: [
|
|
50959
|
+
{
|
|
50960
|
+
$ref: "#/definitions/Specific"
|
|
50961
|
+
}
|
|
50962
|
+
]
|
|
50963
|
+
}
|
|
50964
|
+
}
|
|
50965
|
+
}
|
|
50966
|
+
}
|
|
50967
|
+
};
|
|
50968
|
+
|
|
50969
|
+
// tests/fixtures/host-schemas/kiro.json
|
|
50970
|
+
var kiro_default = {
|
|
50971
|
+
host: "kiro",
|
|
50972
|
+
source: "kiro-cli 3.0.0 (BUILD_HASH 21067db0a7cc, 2026-11-02), V3 engine KAS 3.0.0-e315409f JS bundle (acp-server.js, unpacked by `kiro-cli serve`)",
|
|
50973
|
+
mcpToolId: {
|
|
50974
|
+
from: "function uel(server, tool): r = server + '_' + tool; r = r.replace(/[\\s-]/g, '_'); r = r.replace(/[^a-zA-Z0-9_]/g, ''); id = 'mcp_' + r.toLowerCase(); cut to 64 chars",
|
|
50975
|
+
prefix: "mcp_",
|
|
50976
|
+
join: "_",
|
|
50977
|
+
maxLength: 64
|
|
50978
|
+
},
|
|
50979
|
+
hookStdin: {
|
|
50980
|
+
from: "function sJn: {session_id, hook_event_name, cwd} plus per trigger fields",
|
|
50981
|
+
UserPromptSubmit: ["session_id", "hook_event_name", "cwd", "prompt"],
|
|
50982
|
+
PreToolUse: ["session_id", "hook_event_name", "cwd", "tool_name", "tool_input"],
|
|
50983
|
+
PostToolUse: ["session_id", "hook_event_name", "cwd", "tool_name", "tool_input", "tool_response"],
|
|
50984
|
+
SessionStart: ["session_id", "hook_event_name", "cwd"]
|
|
50985
|
+
},
|
|
50986
|
+
hookOutputCapChars: 3e3,
|
|
50987
|
+
windowsHookShell: "child_process.spawn(command, {shell: true}) in the V3 hook process runner (class tje): COMSPEC (cmd.exe /d /s /c) on win32",
|
|
50988
|
+
stdout: "text",
|
|
50989
|
+
output: {
|
|
50990
|
+
PreToolUse: { type: "string", description: "plain stdout added to the agent context (kiro-cli 3.0.0 V3 hook process runner, cut at hookOutputCapChars); exit 2 blocks with stderr as the reason" },
|
|
50991
|
+
PostToolUse: { type: "string", description: "plain stdout added to the agent context (kiro-cli 3.0.0 V3 hook process runner, cut at hookOutputCapChars); exit 2 blocks with stderr as the reason" },
|
|
50992
|
+
UserPromptSubmit: { type: "string", description: "plain stdout added to the agent context (kiro-cli 3.0.0 V3 hook process runner, cut at hookOutputCapChars); exit 2 blocks with stderr as the reason" },
|
|
50993
|
+
SessionStart: { type: "string", description: "plain stdout added to the agent context (kiro-cli 3.0.0 V3 hook process runner, cut at hookOutputCapChars); exit 2 blocks with stderr as the reason" }
|
|
50994
|
+
}
|
|
50995
|
+
};
|
|
50996
|
+
|
|
50997
|
+
// tests/fixtures/host-schemas/zcode.json
|
|
50998
|
+
var zcode_default = {
|
|
50999
|
+
host: "zcode",
|
|
51000
|
+
source: "ZCode 0.17.1 (a9fe401e) apps/zcode-cli/packages/contracts/src/hooks/index.ts: HookJSONOutputSchema and HookSpecificOutputSchema (zod discriminatedUnion on hookEventName). zod drops keys it does not read, so each object lists only the keys the host reads.",
|
|
51001
|
+
output: {
|
|
51002
|
+
PreToolUse: {
|
|
51003
|
+
title: "ZCode 0.17.1 PreToolUse reply",
|
|
51004
|
+
definitions: {
|
|
51005
|
+
Specific: {
|
|
51006
|
+
type: "object",
|
|
51007
|
+
additionalProperties: false,
|
|
51008
|
+
properties: {
|
|
51009
|
+
additionalContext: {
|
|
51010
|
+
type: "string"
|
|
51011
|
+
},
|
|
51012
|
+
hookEventName: {
|
|
51013
|
+
type: "string",
|
|
51014
|
+
const: "PreToolUse"
|
|
51015
|
+
},
|
|
51016
|
+
permissionDecision: {
|
|
51017
|
+
type: "string",
|
|
51018
|
+
enum: [
|
|
51019
|
+
"allow",
|
|
51020
|
+
"ask",
|
|
51021
|
+
"deny"
|
|
51022
|
+
]
|
|
51023
|
+
},
|
|
51024
|
+
permissionDecisionReason: {
|
|
51025
|
+
type: "string"
|
|
51026
|
+
},
|
|
51027
|
+
updatedInput: {
|
|
51028
|
+
description: "z.unknown()"
|
|
51029
|
+
}
|
|
51030
|
+
},
|
|
51031
|
+
required: [
|
|
51032
|
+
"hookEventName"
|
|
51033
|
+
]
|
|
51034
|
+
}
|
|
51035
|
+
},
|
|
51036
|
+
type: "object",
|
|
51037
|
+
additionalProperties: false,
|
|
51038
|
+
properties: {
|
|
51039
|
+
additionalContext: {
|
|
51040
|
+
type: "string"
|
|
51041
|
+
},
|
|
51042
|
+
additional_context: {
|
|
51043
|
+
type: "string"
|
|
51044
|
+
},
|
|
51045
|
+
continue: {
|
|
51046
|
+
type: "boolean"
|
|
51047
|
+
},
|
|
51048
|
+
decision: {
|
|
51049
|
+
type: "string",
|
|
51050
|
+
enum: [
|
|
51051
|
+
"approve",
|
|
51052
|
+
"block"
|
|
51053
|
+
]
|
|
51054
|
+
},
|
|
51055
|
+
reason: {
|
|
51056
|
+
type: "string"
|
|
51057
|
+
},
|
|
51058
|
+
stopReason: {
|
|
51059
|
+
type: "string"
|
|
51060
|
+
},
|
|
51061
|
+
suppressOutput: {
|
|
51062
|
+
type: "boolean"
|
|
51063
|
+
},
|
|
51064
|
+
systemMessage: {
|
|
51065
|
+
type: "string"
|
|
51066
|
+
},
|
|
51067
|
+
hookSpecificOutput: {
|
|
51068
|
+
allOf: [
|
|
51069
|
+
{
|
|
51070
|
+
$ref: "#/definitions/Specific"
|
|
51071
|
+
}
|
|
51072
|
+
]
|
|
51073
|
+
}
|
|
51074
|
+
}
|
|
51075
|
+
},
|
|
51076
|
+
PostToolUse: {
|
|
51077
|
+
title: "ZCode 0.17.1 PostToolUse reply",
|
|
51078
|
+
definitions: {
|
|
51079
|
+
Specific: {
|
|
51080
|
+
type: "object",
|
|
51081
|
+
additionalProperties: false,
|
|
51082
|
+
properties: {
|
|
51083
|
+
additionalContext: {
|
|
51084
|
+
type: "string"
|
|
51085
|
+
},
|
|
51086
|
+
hookEventName: {
|
|
51087
|
+
type: "string",
|
|
51088
|
+
const: "PostToolUse"
|
|
51089
|
+
}
|
|
51090
|
+
},
|
|
51091
|
+
required: [
|
|
51092
|
+
"hookEventName"
|
|
51093
|
+
]
|
|
51094
|
+
}
|
|
51095
|
+
},
|
|
51096
|
+
type: "object",
|
|
51097
|
+
additionalProperties: false,
|
|
51098
|
+
properties: {
|
|
51099
|
+
additionalContext: {
|
|
51100
|
+
type: "string"
|
|
51101
|
+
},
|
|
51102
|
+
additional_context: {
|
|
51103
|
+
type: "string"
|
|
51104
|
+
},
|
|
51105
|
+
continue: {
|
|
51106
|
+
type: "boolean"
|
|
51107
|
+
},
|
|
51108
|
+
decision: {
|
|
51109
|
+
type: "string",
|
|
51110
|
+
enum: [
|
|
51111
|
+
"approve",
|
|
51112
|
+
"block"
|
|
51113
|
+
]
|
|
51114
|
+
},
|
|
51115
|
+
reason: {
|
|
51116
|
+
type: "string"
|
|
51117
|
+
},
|
|
51118
|
+
stopReason: {
|
|
51119
|
+
type: "string"
|
|
51120
|
+
},
|
|
51121
|
+
suppressOutput: {
|
|
51122
|
+
type: "boolean"
|
|
51123
|
+
},
|
|
51124
|
+
systemMessage: {
|
|
51125
|
+
type: "string"
|
|
51126
|
+
},
|
|
51127
|
+
hookSpecificOutput: {
|
|
51128
|
+
allOf: [
|
|
51129
|
+
{
|
|
51130
|
+
$ref: "#/definitions/Specific"
|
|
51131
|
+
}
|
|
51132
|
+
]
|
|
51133
|
+
}
|
|
51134
|
+
}
|
|
51135
|
+
},
|
|
51136
|
+
UserPromptSubmit: {
|
|
51137
|
+
title: "ZCode 0.17.1 UserPromptSubmit reply",
|
|
51138
|
+
definitions: {
|
|
51139
|
+
Specific: {
|
|
51140
|
+
type: "object",
|
|
51141
|
+
additionalProperties: false,
|
|
51142
|
+
properties: {
|
|
51143
|
+
additionalContext: {
|
|
51144
|
+
type: "string"
|
|
51145
|
+
},
|
|
51146
|
+
hookEventName: {
|
|
51147
|
+
type: "string",
|
|
51148
|
+
const: "UserPromptSubmit"
|
|
51149
|
+
}
|
|
51150
|
+
},
|
|
51151
|
+
required: [
|
|
51152
|
+
"hookEventName"
|
|
51153
|
+
]
|
|
51154
|
+
}
|
|
51155
|
+
},
|
|
51156
|
+
type: "object",
|
|
51157
|
+
additionalProperties: false,
|
|
51158
|
+
properties: {
|
|
51159
|
+
additionalContext: {
|
|
51160
|
+
type: "string"
|
|
51161
|
+
},
|
|
51162
|
+
additional_context: {
|
|
51163
|
+
type: "string"
|
|
51164
|
+
},
|
|
51165
|
+
continue: {
|
|
51166
|
+
type: "boolean"
|
|
51167
|
+
},
|
|
51168
|
+
decision: {
|
|
51169
|
+
type: "string",
|
|
51170
|
+
enum: [
|
|
51171
|
+
"approve",
|
|
51172
|
+
"block"
|
|
51173
|
+
]
|
|
51174
|
+
},
|
|
51175
|
+
reason: {
|
|
51176
|
+
type: "string"
|
|
51177
|
+
},
|
|
51178
|
+
stopReason: {
|
|
51179
|
+
type: "string"
|
|
51180
|
+
},
|
|
51181
|
+
suppressOutput: {
|
|
51182
|
+
type: "boolean"
|
|
51183
|
+
},
|
|
51184
|
+
systemMessage: {
|
|
51185
|
+
type: "string"
|
|
51186
|
+
},
|
|
51187
|
+
hookSpecificOutput: {
|
|
51188
|
+
allOf: [
|
|
51189
|
+
{
|
|
51190
|
+
$ref: "#/definitions/Specific"
|
|
51191
|
+
}
|
|
51192
|
+
]
|
|
51193
|
+
}
|
|
51194
|
+
}
|
|
51195
|
+
},
|
|
51196
|
+
SessionStart: {
|
|
51197
|
+
title: "ZCode 0.17.1 SessionStart reply",
|
|
51198
|
+
definitions: {
|
|
51199
|
+
Specific: {
|
|
51200
|
+
type: "object",
|
|
51201
|
+
additionalProperties: false,
|
|
51202
|
+
properties: {
|
|
51203
|
+
additionalContext: {
|
|
51204
|
+
type: "string"
|
|
51205
|
+
},
|
|
51206
|
+
hookEventName: {
|
|
51207
|
+
type: "string",
|
|
51208
|
+
const: "SessionStart"
|
|
51209
|
+
}
|
|
51210
|
+
},
|
|
51211
|
+
required: [
|
|
51212
|
+
"hookEventName"
|
|
51213
|
+
]
|
|
51214
|
+
}
|
|
51215
|
+
},
|
|
51216
|
+
type: "object",
|
|
51217
|
+
additionalProperties: false,
|
|
51218
|
+
properties: {
|
|
51219
|
+
additionalContext: {
|
|
51220
|
+
type: "string"
|
|
51221
|
+
},
|
|
51222
|
+
additional_context: {
|
|
51223
|
+
type: "string"
|
|
51224
|
+
},
|
|
51225
|
+
continue: {
|
|
51226
|
+
type: "boolean"
|
|
51227
|
+
},
|
|
51228
|
+
decision: {
|
|
51229
|
+
type: "string",
|
|
51230
|
+
enum: [
|
|
51231
|
+
"approve",
|
|
51232
|
+
"block"
|
|
51233
|
+
]
|
|
51234
|
+
},
|
|
51235
|
+
reason: {
|
|
51236
|
+
type: "string"
|
|
51237
|
+
},
|
|
51238
|
+
stopReason: {
|
|
51239
|
+
type: "string"
|
|
51240
|
+
},
|
|
51241
|
+
suppressOutput: {
|
|
51242
|
+
type: "boolean"
|
|
51243
|
+
},
|
|
51244
|
+
systemMessage: {
|
|
51245
|
+
type: "string"
|
|
51246
|
+
},
|
|
51247
|
+
hookSpecificOutput: {
|
|
51248
|
+
allOf: [
|
|
51249
|
+
{
|
|
51250
|
+
$ref: "#/definitions/Specific"
|
|
51251
|
+
}
|
|
51252
|
+
]
|
|
51253
|
+
}
|
|
51254
|
+
}
|
|
51255
|
+
}
|
|
51256
|
+
}
|
|
51257
|
+
};
|
|
51258
|
+
|
|
51259
|
+
// tests/fixtures/host-schemas/pi.json
|
|
51260
|
+
var pi_default = {
|
|
51261
|
+
host: "pi",
|
|
51262
|
+
source: "@earendil-works/pi-coding-agent 1.5.0 dist/core/extensions/types.d.ts (ToolCallEventResult {block, reason}, ToolResultEventResult content, BeforeAgentStartEventResult) and runner.js l.895-1010. The hook runs in process (src/entries/pi.ts): plain stdout becomes the reason, the replaced content or the added context; exit 2 blocks the tool call.",
|
|
51263
|
+
stdout: "text",
|
|
51264
|
+
output: {
|
|
51265
|
+
PreToolUse: {
|
|
51266
|
+
type: "string",
|
|
51267
|
+
description: "plain text read by src/entries/pi.ts"
|
|
51268
|
+
},
|
|
51269
|
+
PostToolUse: {
|
|
51270
|
+
type: "string",
|
|
51271
|
+
description: "plain text read by src/entries/pi.ts"
|
|
51272
|
+
},
|
|
51273
|
+
UserPromptSubmit: {
|
|
51274
|
+
type: "string",
|
|
51275
|
+
description: "plain text read by src/entries/pi.ts"
|
|
51276
|
+
},
|
|
51277
|
+
SessionStart: {
|
|
51278
|
+
type: "string",
|
|
51279
|
+
description: "plain text read by src/entries/pi.ts"
|
|
51280
|
+
}
|
|
51281
|
+
}
|
|
51282
|
+
};
|
|
51283
|
+
|
|
51284
|
+
// tests/fixtures/host-schemas/opencode.json
|
|
51285
|
+
var opencode_default = {
|
|
51286
|
+
host: "opencode",
|
|
51287
|
+
source: "@opencode/cli 2.2.5 plugin hooks (tool.execute.before throws to block, session hooks add text). The plugin runs the hook and reads plain stdout; exit 2 blocks the tool call with stdout as the reason.",
|
|
51288
|
+
stdout: "text",
|
|
51289
|
+
output: {
|
|
51290
|
+
PreToolUse: {
|
|
51291
|
+
type: "string",
|
|
51292
|
+
description: "plain text read by the context-mode OpenCode plugin"
|
|
51293
|
+
},
|
|
51294
|
+
PostToolUse: {
|
|
51295
|
+
type: "string",
|
|
51296
|
+
description: "plain text read by the context-mode OpenCode plugin"
|
|
51297
|
+
},
|
|
51298
|
+
UserPromptSubmit: {
|
|
51299
|
+
type: "string",
|
|
51300
|
+
description: "plain text read by the context-mode OpenCode plugin"
|
|
51301
|
+
},
|
|
51302
|
+
SessionStart: {
|
|
51303
|
+
type: "string",
|
|
51304
|
+
description: "plain text read by the context-mode OpenCode plugin"
|
|
51305
|
+
}
|
|
51306
|
+
}
|
|
51307
|
+
};
|
|
51308
|
+
|
|
51309
|
+
// src/core/ops/hook-shape.ts
|
|
51310
|
+
var HOST_SHAPES = {
|
|
51311
|
+
"claude-code": claude_code_default,
|
|
51312
|
+
codex: codex_default,
|
|
51313
|
+
gemini: gemini_default,
|
|
51314
|
+
qwen: qwen_default,
|
|
51315
|
+
"copilot-cli": copilot_cli_default,
|
|
51316
|
+
vscode: vscode_default,
|
|
51317
|
+
kiro: kiro_default,
|
|
51318
|
+
zcode: zcode_default,
|
|
51319
|
+
pi: pi_default,
|
|
51320
|
+
opencode: opencode_default
|
|
51321
|
+
};
|
|
51322
|
+
var NOTE_KEYS = /* @__PURE__ */ new Set(["$schema", "title", "description", "definitions", "default"]);
|
|
51323
|
+
var RULE_KEYS = /* @__PURE__ */ new Set(["type", "enum", "const", "required", "properties", "additionalProperties", "items", "allOf", "$ref"]);
|
|
51324
|
+
function isObject5(v) {
|
|
51325
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
51326
|
+
}
|
|
51327
|
+
function typeOf(v) {
|
|
51328
|
+
if (v === null) return "null";
|
|
51329
|
+
if (Array.isArray(v)) return "array";
|
|
51330
|
+
return typeof v;
|
|
51331
|
+
}
|
|
51332
|
+
function hasType(v, t) {
|
|
51333
|
+
if (t === "integer") return Number.isInteger(v);
|
|
51334
|
+
return typeOf(v) === t;
|
|
51335
|
+
}
|
|
51336
|
+
function same(a, b) {
|
|
51337
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
51338
|
+
}
|
|
51339
|
+
function resolve3(root, ref) {
|
|
51340
|
+
const parts = ref.split("/");
|
|
51341
|
+
if (parts[0] !== "#") throw new Error(`hook-shape: only local $ref is read, got ${ref}`);
|
|
51342
|
+
let at = root;
|
|
51343
|
+
for (const p of parts.slice(1)) at = isObject5(at) ? at[p] : void 0;
|
|
51344
|
+
if (!isObject5(at)) throw new Error(`hook-shape: $ref ${ref} names nothing`);
|
|
51345
|
+
return at;
|
|
51346
|
+
}
|
|
51347
|
+
function shapeErrors(schema, value, root = schema, at = "$") {
|
|
51348
|
+
for (const k of Object.keys(schema)) {
|
|
51349
|
+
if (!NOTE_KEYS.has(k) && !RULE_KEYS.has(k)) throw new Error(`hook-shape: keyword ${k} at ${at} is not read by the checker`);
|
|
51350
|
+
}
|
|
51351
|
+
const errs = [];
|
|
51352
|
+
if (typeof schema.$ref === "string") errs.push(...shapeErrors(resolve3(root, schema.$ref), value, root, at));
|
|
51353
|
+
if (Array.isArray(schema.allOf)) for (const s of schema.allOf) errs.push(...shapeErrors(s, value, root, at));
|
|
51354
|
+
if (schema.type !== void 0) {
|
|
51355
|
+
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
51356
|
+
if (!types.some((t) => hasType(value, String(t)))) return [...errs, `${at}: ${typeOf(value)} is not ${types.join(" or ")}`];
|
|
51357
|
+
}
|
|
51358
|
+
if (Array.isArray(schema.enum) && !schema.enum.some((e) => same(e, value))) errs.push(`${at}: ${JSON.stringify(value)} is not one of ${JSON.stringify(schema.enum)}`);
|
|
51359
|
+
if (Object.hasOwn(schema, "const") && !same(schema.const, value)) errs.push(`${at}: ${JSON.stringify(value)} is not ${JSON.stringify(schema.const)}`);
|
|
51360
|
+
if (isObject5(value)) {
|
|
51361
|
+
const props = isObject5(schema.properties) ? schema.properties : {};
|
|
51362
|
+
if (Array.isArray(schema.required)) {
|
|
51363
|
+
for (const r of schema.required) if (!Object.hasOwn(value, String(r))) errs.push(`${at}: ${String(r)} is required`);
|
|
51364
|
+
}
|
|
51365
|
+
for (const [k, v] of Object.entries(value)) {
|
|
51366
|
+
if (Object.hasOwn(props, k)) errs.push(...shapeErrors(props[k], v, root, `${at}.${k}`));
|
|
51367
|
+
else if (schema.additionalProperties === false) errs.push(`${at}: ${k} is not a known key`);
|
|
51368
|
+
else if (isObject5(schema.additionalProperties)) errs.push(...shapeErrors(schema.additionalProperties, v, root, `${at}.${k}`));
|
|
51369
|
+
}
|
|
51370
|
+
}
|
|
51371
|
+
if (Array.isArray(value) && isObject5(schema.items)) {
|
|
51372
|
+
const items = schema.items;
|
|
51373
|
+
value.forEach((v, n) => errs.push(...shapeErrors(items, v, root, `${at}[${n}]`)));
|
|
51374
|
+
}
|
|
51375
|
+
return errs;
|
|
51376
|
+
}
|
|
51377
|
+
function replyErrors(agent, event, stdout) {
|
|
51378
|
+
const host = HOST_SHAPES[agent];
|
|
51379
|
+
const schema = host.output[event];
|
|
51380
|
+
if (schema === void 0) return [`${agent} has no ${event} reply schema`];
|
|
51381
|
+
if (host.stdout === "text") return shapeErrors(schema, stdout);
|
|
51382
|
+
let value;
|
|
51383
|
+
try {
|
|
51384
|
+
value = JSON.parse(stdout);
|
|
51385
|
+
} catch {
|
|
51386
|
+
return [`${agent} ${event}: stdout is not JSON`];
|
|
51387
|
+
}
|
|
51388
|
+
return shapeErrors(schema, value);
|
|
51389
|
+
}
|
|
51390
|
+
|
|
51391
|
+
// src/core/sandbox/host-node.ts
|
|
51392
|
+
var BUN_BE_BUN_ENV = "BUN_BE_BUN";
|
|
51393
|
+
function nodeLaunch(env, host = { bun: process.versions.bun, execPath: process.execPath }, find2 = findRuntime) {
|
|
51394
|
+
if (host.bun === void 0) return { file: host.execPath, env };
|
|
51395
|
+
const node3 = find2("javascript", env);
|
|
51396
|
+
if (node3 !== null) return { file: node3, env };
|
|
51397
|
+
return { file: host.execPath, env: { ...env, [BUN_BE_BUN_ENV]: "1" } };
|
|
51398
|
+
}
|
|
51399
|
+
|
|
49418
51400
|
// src/setup/codex-trust.ts
|
|
49419
51401
|
import { createHash } from "node:crypto";
|
|
49420
51402
|
import { existsSync as existsSync12, realpathSync as realpathSync7 } from "node:fs";
|
|
@@ -49534,14 +51516,14 @@ function pluginHooksFromReply(m, pluginId) {
|
|
|
49534
51516
|
function askPluginHooks(env, pluginId, cwd) {
|
|
49535
51517
|
const bin = whichBin("codex", env);
|
|
49536
51518
|
if (!bin) return Promise.resolve({ kind: "absent" });
|
|
49537
|
-
return new Promise((
|
|
51519
|
+
return new Promise((resolve7) => {
|
|
49538
51520
|
let asked;
|
|
49539
51521
|
const done_ = (hooks) => hooks === void 0 ? { kind: "silent" } : { kind: "list", hooks, codexHome: asked };
|
|
49540
51522
|
let f;
|
|
49541
51523
|
try {
|
|
49542
51524
|
f = spawnForm(bin, ["app-server"], env);
|
|
49543
51525
|
} catch {
|
|
49544
|
-
|
|
51526
|
+
resolve7({ kind: "silent" });
|
|
49545
51527
|
return;
|
|
49546
51528
|
}
|
|
49547
51529
|
const child = spawn2(f.command, f.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f.windowsVerbatimArguments, windowsHide: true });
|
|
@@ -49551,7 +51533,7 @@ function askPluginHooks(env, pluginId, cwd) {
|
|
|
49551
51533
|
let result;
|
|
49552
51534
|
const settle3 = () => {
|
|
49553
51535
|
clearTimeout(grace);
|
|
49554
|
-
|
|
51536
|
+
resolve7(done_(result));
|
|
49555
51537
|
};
|
|
49556
51538
|
let grace;
|
|
49557
51539
|
const finish2 = (v) => {
|
|
@@ -49621,8 +51603,8 @@ function untrustedPluginHooksDetail(hooks) {
|
|
|
49621
51603
|
if (!bad.length) return void 0;
|
|
49622
51604
|
const counts = /* @__PURE__ */ new Map();
|
|
49623
51605
|
for (const h of bad) counts.set(h.status, (counts.get(h.status) ?? 0) + 1);
|
|
49624
|
-
const
|
|
49625
|
-
const state =
|
|
51606
|
+
const words2 = [...counts].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1));
|
|
51607
|
+
const state = words2.length === 1 ? words2[0][0] : `${words2.map(([w]) => w).join(" or ")} (${words2.map(([w, n]) => `${n} ${w}`).join(", ")})`;
|
|
49626
51608
|
return `codex lists ${bad.length} of ${hooks.length} context-mode plugin hooks ${state}, so they do not run; ${CODEX_UNTRUSTED_FIX}`;
|
|
49627
51609
|
}
|
|
49628
51610
|
|
|
@@ -49635,7 +51617,7 @@ var D5_CODEX_SILENT_DETAIL = (home) => `codex app-server gave no hooks/list answ
|
|
|
49635
51617
|
var D5_CODEX_OTHER_HOME_DETAIL = (asked, home) => `codex answers for ${asked}, but the context-mode plugin runs from ${home}`;
|
|
49636
51618
|
var D5_CODEX_NONE_DETAIL = (home) => `codex lists no context-mode plugin hooks in ${home}, so they do not run`;
|
|
49637
51619
|
var row = (status, detail, fixCommand) => fixCommand === void 0 ? { id: "D5", label: DOCTOR_LABEL.D5, status, detail } : { id: "D5", label: DOCTOR_LABEL.D5, status, detail, fixCommand };
|
|
49638
|
-
function
|
|
51620
|
+
function isObject6(v) {
|
|
49639
51621
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
49640
51622
|
}
|
|
49641
51623
|
function loadFixture(bundleDir2, agent) {
|
|
@@ -49647,10 +51629,10 @@ function loadFixture(bundleDir2, agent) {
|
|
|
49647
51629
|
} catch (err) {
|
|
49648
51630
|
return { cause: D5_FIXTURE_PARSE(file2, err instanceof Error ? err.message : String(err)) };
|
|
49649
51631
|
}
|
|
49650
|
-
if (!
|
|
51632
|
+
if (!isObject6(all)) return { cause: D5_FIXTURE_PARSE(file2, "top level is not an object") };
|
|
49651
51633
|
if (!Object.hasOwn(all, agent)) return { cause: D5_NO_FIXTURE_DETAIL(agent) + ": " + D5_FIXTURE_AGENT_ABSENT(file2, Object.keys(all)) };
|
|
49652
51634
|
const e = all[agent];
|
|
49653
|
-
if (!
|
|
51635
|
+
if (!isObject6(e) || typeof e.event !== "string" || !Object.hasOwn(e, "payload")) {
|
|
49654
51636
|
return { cause: D5_NO_FIXTURE_DETAIL(agent) + ": the entry lacks an event name or a payload" };
|
|
49655
51637
|
}
|
|
49656
51638
|
return { event: e.event, payload: e.payload };
|
|
@@ -49668,39 +51650,11 @@ var CWD_KEY = {
|
|
|
49668
51650
|
opencode: "directory"
|
|
49669
51651
|
};
|
|
49670
51652
|
function payloadFor(agent, payload, worktree) {
|
|
49671
|
-
return worktree !== void 0 &&
|
|
49672
|
-
}
|
|
49673
|
-
var SHAPE = {
|
|
49674
|
-
"claude-code": "claude",
|
|
49675
|
-
codex: "claude",
|
|
49676
|
-
qwen: "claude",
|
|
49677
|
-
vscode: "claude",
|
|
49678
|
-
zcode: "claude",
|
|
49679
|
-
gemini: "gemini",
|
|
49680
|
-
"copilot-cli": "copilot",
|
|
49681
|
-
kiro: "text",
|
|
49682
|
-
pi: "text",
|
|
49683
|
-
opencode: "text"
|
|
49684
|
-
};
|
|
49685
|
-
var COPILOT_KEYS = ["permissionDecision", "additionalContext", "modifiedResult"];
|
|
51653
|
+
return worktree !== void 0 && isObject6(payload) ? { ...payload, [CWD_KEY[agent]]: worktree } : payload;
|
|
51654
|
+
}
|
|
49686
51655
|
function isNativeShape(agent, stdout, exitCode, killed, event) {
|
|
49687
51656
|
if (killed !== null || exitCode !== 0 && exitCode !== 2) return false;
|
|
49688
|
-
|
|
49689
|
-
let out;
|
|
49690
|
-
try {
|
|
49691
|
-
out = JSON.parse(stdout);
|
|
49692
|
-
} catch {
|
|
49693
|
-
return false;
|
|
49694
|
-
}
|
|
49695
|
-
if (!isObject5(out)) return false;
|
|
49696
|
-
switch (SHAPE[agent]) {
|
|
49697
|
-
case "claude":
|
|
49698
|
-
return isObject5(out.hookSpecificOutput) && out.hookSpecificOutput.hookEventName === event;
|
|
49699
|
-
case "gemini":
|
|
49700
|
-
return typeof out.decision === "string" || isObject5(out.hookSpecificOutput);
|
|
49701
|
-
default:
|
|
49702
|
-
return COPILOT_KEYS.some((k) => Object.hasOwn(out, k));
|
|
49703
|
-
}
|
|
51657
|
+
return stdout.length === 0 || replyErrors(agent, event, stdout).length === 0;
|
|
49704
51658
|
}
|
|
49705
51659
|
var READ_PROBE_LINES = 4 * Math.ceil(REPLACE_TRIGGER_BYTES / 40);
|
|
49706
51660
|
function readProbePayload(cwd, ranged) {
|
|
@@ -49725,18 +51679,19 @@ function isReadShape(stdout) {
|
|
|
49725
51679
|
} catch {
|
|
49726
51680
|
return false;
|
|
49727
51681
|
}
|
|
49728
|
-
if (!
|
|
51682
|
+
if (!isObject6(out) || !isObject6(out.hookSpecificOutput) || !Object.hasOwn(out.hookSpecificOutput, "updatedToolOutput")) return true;
|
|
49729
51683
|
const r = out.hookSpecificOutput.updatedToolOutput;
|
|
49730
|
-
if (!
|
|
51684
|
+
if (!isObject6(r) || r.type !== "text" || !isObject6(r.file)) return false;
|
|
49731
51685
|
const f = r.file;
|
|
49732
51686
|
return typeof f.filePath === "string" && typeof f.content === "string" && ["numLines", "startLine", "totalLines"].every((k) => typeof f[k] === "number");
|
|
49733
51687
|
}
|
|
49734
51688
|
async function readProbe(i, timeoutMs, ranged) {
|
|
49735
51689
|
const home = mkdtempSync(path7.join(tmpdir2(), "cm-d5-read-"));
|
|
49736
51690
|
try {
|
|
49737
|
-
const
|
|
51691
|
+
const node3 = nodeLaunch({ ...i.env, HOME: home, USERPROFILE: home });
|
|
51692
|
+
const r = await runProcess([node3.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
49738
51693
|
cwd: i.bundleDir,
|
|
49739
|
-
env:
|
|
51694
|
+
env: node3.env,
|
|
49740
51695
|
signal: i.signal,
|
|
49741
51696
|
timeoutMs,
|
|
49742
51697
|
stdin: JSON.stringify(readProbePayload(i.worktree ?? home, ranged))
|
|
@@ -49754,11 +51709,49 @@ function isPassThrough(stdout) {
|
|
|
49754
51709
|
} catch {
|
|
49755
51710
|
return false;
|
|
49756
51711
|
}
|
|
49757
|
-
return !
|
|
51712
|
+
return !isObject6(out) || !isObject6(out.hookSpecificOutput) || !Object.hasOwn(out.hookSpecificOutput, "updatedToolOutput");
|
|
51713
|
+
}
|
|
51714
|
+
var PNG_SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
|
|
51715
|
+
async function mediaProbe(i, timeoutMs) {
|
|
51716
|
+
const home = mkdtempSync(path7.join(tmpdir2(), "cm-d5-media-"));
|
|
51717
|
+
try {
|
|
51718
|
+
const filePath = path7.join(home, "d5-media-probe.png");
|
|
51719
|
+
writeFileSync3(filePath, Buffer.concat([PNG_SIGNATURE, Buffer.alloc(OUTPUT_CAP + 1)]));
|
|
51720
|
+
const node3 = nodeLaunch({ ...i.env, HOME: home, USERPROFILE: home });
|
|
51721
|
+
const r = await runProcess([node3.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
51722
|
+
cwd: i.bundleDir,
|
|
51723
|
+
env: node3.env,
|
|
51724
|
+
signal: i.signal,
|
|
51725
|
+
timeoutMs,
|
|
51726
|
+
stdin: JSON.stringify({
|
|
51727
|
+
session_id: "d5-media-probe",
|
|
51728
|
+
transcript_path: "",
|
|
51729
|
+
cwd: home,
|
|
51730
|
+
hook_event_name: "PreToolUse",
|
|
51731
|
+
tool_name: "Read",
|
|
51732
|
+
tool_use_id: "toolu_d5_media_probe",
|
|
51733
|
+
tool_input: { file_path: filePath }
|
|
51734
|
+
})
|
|
51735
|
+
});
|
|
51736
|
+
return r.stdout.toString("utf8");
|
|
51737
|
+
} finally {
|
|
51738
|
+
rmSync4(home, { recursive: true, force: true });
|
|
51739
|
+
}
|
|
51740
|
+
}
|
|
51741
|
+
function isDeny(stdout) {
|
|
51742
|
+
if (stdout.trim() === "") return false;
|
|
51743
|
+
let out;
|
|
51744
|
+
try {
|
|
51745
|
+
out = JSON.parse(stdout);
|
|
51746
|
+
} catch {
|
|
51747
|
+
return false;
|
|
51748
|
+
}
|
|
51749
|
+
return isObject6(out) && isObject6(out.hookSpecificOutput) && out.hookSpecificOutput.permissionDecision === "deny";
|
|
49758
51750
|
}
|
|
49759
51751
|
async function readProbeDetail(i, timeoutMs) {
|
|
49760
51752
|
if (!isReadShape(await readProbe(i, timeoutMs, false))) return D5_READ_SHAPE_DETAIL;
|
|
49761
51753
|
if (!isPassThrough(await readProbe(i, timeoutMs, true))) return D5_READ_RANGE_DETAIL;
|
|
51754
|
+
if (isDeny(await mediaProbe(i, timeoutMs))) return D5_READ_MEDIA_DETAIL;
|
|
49762
51755
|
return null;
|
|
49763
51756
|
}
|
|
49764
51757
|
function codexHookJournaled(db) {
|
|
@@ -49789,6 +51782,36 @@ async function codexPluginTrust(i) {
|
|
|
49789
51782
|
if (reply4.hooks.length === 0) return row("FAIL", D5_CODEX_NONE_DETAIL(home), D5_CODEX_TRUST_FIX);
|
|
49790
51783
|
return null;
|
|
49791
51784
|
}
|
|
51785
|
+
function codexStopPayload(cwd) {
|
|
51786
|
+
return {
|
|
51787
|
+
session_id: "d5-stop-probe",
|
|
51788
|
+
turn_id: "d5-stop-turn",
|
|
51789
|
+
transcript_path: null,
|
|
51790
|
+
cwd,
|
|
51791
|
+
hook_event_name: "Stop",
|
|
51792
|
+
model: "d5-probe",
|
|
51793
|
+
permission_mode: "default",
|
|
51794
|
+
stop_hook_active: false,
|
|
51795
|
+
last_assistant_message: "d5 stop probe"
|
|
51796
|
+
};
|
|
51797
|
+
}
|
|
51798
|
+
async function codexStopDetail(i, timeoutMs) {
|
|
51799
|
+
const home = mkdtempSync(path7.join(tmpdir2(), "cm-d5-stop-"));
|
|
51800
|
+
try {
|
|
51801
|
+
const node3 = nodeLaunch({ ...i.env, HOME: home, USERPROFILE: home, [DATA_DIR_ENV]: home });
|
|
51802
|
+
const r = await runProcess([node3.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
51803
|
+
cwd: i.bundleDir,
|
|
51804
|
+
env: node3.env,
|
|
51805
|
+
signal: i.signal,
|
|
51806
|
+
timeoutMs,
|
|
51807
|
+
stdin: JSON.stringify(codexStopPayload(i.worktree ?? home))
|
|
51808
|
+
});
|
|
51809
|
+
const logged = existsSync13(path7.join(home, HOOK_ERROR_LOG_FILE));
|
|
51810
|
+
return !logged && isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, "Stop") ? null : D5_STOP_DETAIL;
|
|
51811
|
+
} finally {
|
|
51812
|
+
rmSync4(home, { recursive: true, force: true });
|
|
51813
|
+
}
|
|
51814
|
+
}
|
|
49792
51815
|
async function checkHookRoundTrip(i) {
|
|
49793
51816
|
if (i.agent === "codex") {
|
|
49794
51817
|
const trust = await codexPluginTrust(i);
|
|
@@ -49806,7 +51829,8 @@ async function checkHookRoundTrip(i) {
|
|
|
49806
51829
|
const timeoutMs = i.timeoutMs ?? HOOK_TIMEOUT_MS;
|
|
49807
51830
|
const bareMs = i.bareMs ?? (async () => {
|
|
49808
51831
|
const t = performance.now();
|
|
49809
|
-
|
|
51832
|
+
const node3 = nodeLaunch(i.env);
|
|
51833
|
+
await runProcess([node3.file, "-e", ""], { cwd: i.bundleDir, env: node3.env, signal: i.signal, timeoutMs });
|
|
49810
51834
|
return performance.now() - t;
|
|
49811
51835
|
});
|
|
49812
51836
|
const hookWalls = [];
|
|
@@ -49814,9 +51838,10 @@ async function checkHookRoundTrip(i) {
|
|
|
49814
51838
|
let ms = 0;
|
|
49815
51839
|
for (let n = 1; n <= maxPairs; n++) {
|
|
49816
51840
|
const start = now();
|
|
49817
|
-
const
|
|
51841
|
+
const node3 = nodeLaunch(i.env);
|
|
51842
|
+
const r = await runProcess([node3.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
49818
51843
|
cwd: i.bundleDir,
|
|
49819
|
-
env:
|
|
51844
|
+
env: node3.env,
|
|
49820
51845
|
signal: i.signal,
|
|
49821
51846
|
timeoutMs,
|
|
49822
51847
|
stdin: JSON.stringify(payloadFor(i.agent, fixture.payload, i.worktree))
|
|
@@ -49828,20 +51853,28 @@ async function checkHookRoundTrip(i) {
|
|
|
49828
51853
|
if (n >= minPairs && ms <= HOOK_P95_MS) break;
|
|
49829
51854
|
}
|
|
49830
51855
|
if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
|
|
49831
|
-
const readDetail = i.agent === "claude-code" ? await readProbeDetail(i, timeoutMs) : null;
|
|
51856
|
+
const readDetail = i.agent === "claude-code" ? await readProbeDetail(i, timeoutMs) : i.agent === "codex" ? await codexStopDetail(i, timeoutMs) : null;
|
|
49832
51857
|
if (readDetail !== null) return row("FAIL", readDetail, D5_FIX);
|
|
49833
51858
|
return row("PASS", DOCTOR_PASS_DETAIL);
|
|
49834
51859
|
}
|
|
49835
51860
|
|
|
49836
51861
|
// src/core/hooks/fallback.ts
|
|
49837
|
-
import { join as
|
|
51862
|
+
import { join as join13, resolve as resolve4 } from "node:path";
|
|
51863
|
+
|
|
51864
|
+
// src/core/policy/read-media.ts
|
|
51865
|
+
import { extname } from "node:path";
|
|
51866
|
+
var { closeSync, openSync, readSync } = process.getBuiltinModule("node:fs");
|
|
51867
|
+
|
|
51868
|
+
// src/core/hooks/fallback.ts
|
|
49838
51869
|
var fs = process.getBuiltinModule("node:fs");
|
|
49839
51870
|
function homeOf(env) {
|
|
49840
51871
|
return env.HOME ?? env.USERPROFILE ?? "";
|
|
49841
51872
|
}
|
|
49842
51873
|
function hookLogPath(env) {
|
|
51874
|
+
const dir = env[DATA_DIR_ENV];
|
|
51875
|
+
if (dir !== void 0 && dir !== "") return join13(dataRootOf(env, ""), HOOK_ERROR_LOG_FILE);
|
|
49843
51876
|
const home = homeOf(env);
|
|
49844
|
-
return home === "" ? "" :
|
|
51877
|
+
return home === "" ? "" : join13(dataRootOf(env, home), HOOK_ERROR_LOG_FILE);
|
|
49845
51878
|
}
|
|
49846
51879
|
function lastHookError(env) {
|
|
49847
51880
|
try {
|
|
@@ -49872,7 +51905,7 @@ function lastHookError(env) {
|
|
|
49872
51905
|
|
|
49873
51906
|
// src/core/ops/db-heal.ts
|
|
49874
51907
|
import { existsSync as existsSync14, mkdirSync as mkdirSync5, rmSync as rmSync5 } from "node:fs";
|
|
49875
|
-
import { basename as basename4, dirname as dirname7, join as
|
|
51908
|
+
import { basename as basename4, dirname as dirname7, join as join14 } from "node:path";
|
|
49876
51909
|
function integrityOk2(rows) {
|
|
49877
51910
|
return rows.length === 1 && rows[0].integrity_check === INTEGRITY_OK;
|
|
49878
51911
|
}
|
|
@@ -49881,7 +51914,7 @@ async function healLossless(dbPath) {
|
|
|
49881
51914
|
const tmp = dbPath + HEAL_TMP_SUFFIX;
|
|
49882
51915
|
rmSync5(tmp, { force: true });
|
|
49883
51916
|
try {
|
|
49884
|
-
const src =
|
|
51917
|
+
const src = openReadOnlyHandle({ DatabaseSync }, dbPath, { queryOnly: false });
|
|
49885
51918
|
try {
|
|
49886
51919
|
src.prepare("VACUUM INTO ?").run(tmp);
|
|
49887
51920
|
} finally {
|
|
@@ -49929,7 +51962,7 @@ function utcStamp(now) {
|
|
|
49929
51962
|
return now.toISOString().slice(0, 19).replaceAll("-", "").replaceAll(":", "") + "Z";
|
|
49930
51963
|
}
|
|
49931
51964
|
function makeOrphanDir(projectDir) {
|
|
49932
|
-
const base =
|
|
51965
|
+
const base = join14(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
|
|
49933
51966
|
for (let n = 1; ; n += 1) {
|
|
49934
51967
|
const dir = n === 1 ? base : base + "-" + String(n);
|
|
49935
51968
|
try {
|
|
@@ -49946,7 +51979,7 @@ async function healOrphan(project, files, row5) {
|
|
|
49946
51979
|
try {
|
|
49947
51980
|
dir = makeOrphanDir(dirname7(project.dbPath));
|
|
49948
51981
|
for (const f of files) {
|
|
49949
|
-
const to =
|
|
51982
|
+
const to = join14(dir, basename4(f.path));
|
|
49950
51983
|
renameWithRetry(f.path, to);
|
|
49951
51984
|
moved.push({ path: to, bytes: f.bytes });
|
|
49952
51985
|
}
|
|
@@ -50013,8 +52046,8 @@ function buildReportHead(input) {
|
|
|
50013
52046
|
|
|
50014
52047
|
// src/core/ops/doctor-issue.ts
|
|
50015
52048
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
50016
|
-
import { closeSync, existsSync as existsSync15, fstatSync, mkdirSync as mkdirSync6, openSync, readFileSync as readFileSync10, readSync, realpathSync as realpathSync9, writeFileSync as
|
|
50017
|
-
import { delimiter, join as
|
|
52049
|
+
import { closeSync as closeSync2, existsSync as existsSync15, fstatSync, mkdirSync as mkdirSync6, openSync as openSync2, readFileSync as readFileSync10, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
|
|
52050
|
+
import { delimiter, join as join15 } from "node:path";
|
|
50018
52051
|
var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
|
|
50019
52052
|
function tildeOf(env) {
|
|
50020
52053
|
const home = homeDirOf(env);
|
|
@@ -50055,8 +52088,8 @@ function onPath(env, tool) {
|
|
|
50055
52088
|
const out = [];
|
|
50056
52089
|
for (const dir of (env.PATH ?? env.Path ?? "").split(delimiter)) {
|
|
50057
52090
|
if (dir === "") continue;
|
|
50058
|
-
for (const n of names) if (existsSync15(
|
|
50059
|
-
out.push(
|
|
52091
|
+
for (const n of names) if (existsSync15(join15(dir, n))) {
|
|
52092
|
+
out.push(join15(dir, n));
|
|
50060
52093
|
break;
|
|
50061
52094
|
}
|
|
50062
52095
|
}
|
|
@@ -50066,17 +52099,17 @@ function hookLogTail(env) {
|
|
|
50066
52099
|
const file2 = hookLogPath(env);
|
|
50067
52100
|
if (file2 === "" || !existsSync15(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
|
|
50068
52101
|
try {
|
|
50069
|
-
const fd =
|
|
52102
|
+
const fd = openSync2(file2, "r");
|
|
50070
52103
|
try {
|
|
50071
52104
|
const size = fstatSync(fd).size;
|
|
50072
52105
|
const start = Math.max(0, size - DOCTOR_LOG_TAIL_BYTES);
|
|
50073
52106
|
const buf = Buffer.alloc(size - start);
|
|
50074
|
-
|
|
52107
|
+
readSync2(fd, buf, 0, buf.length, start);
|
|
50075
52108
|
const lines = buf.toString("utf8").split("\n").filter((l) => l.trim() !== "");
|
|
50076
52109
|
if (start > 0) lines.shift();
|
|
50077
52110
|
return lines.slice(-DOCTOR_HOOK_LOG_LINES).map(maskLine);
|
|
50078
52111
|
} finally {
|
|
50079
|
-
|
|
52112
|
+
closeSync2(fd);
|
|
50080
52113
|
}
|
|
50081
52114
|
} catch (err) {
|
|
50082
52115
|
return [`hook-errors.log read: ${err instanceof Error ? err.message : String(err)}`];
|
|
@@ -50102,8 +52135,8 @@ function agentConfig(adapter, env, worktree) {
|
|
|
50102
52135
|
const home = homeDirOf(env);
|
|
50103
52136
|
const files = configPaths(adapter, env, worktree);
|
|
50104
52137
|
if (home !== null) {
|
|
50105
|
-
if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path:
|
|
50106
|
-
if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path:
|
|
52138
|
+
if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join15(claudeDirOf(env, home), SETTINGS_FILE) });
|
|
52139
|
+
if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join15(codexDirOf(env, home), CONFIG_TOML_FILE) });
|
|
50107
52140
|
}
|
|
50108
52141
|
const out = [];
|
|
50109
52142
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -50186,10 +52219,10 @@ async function buildIssueBody(i) {
|
|
|
50186
52219
|
async function writeIssueReport(i) {
|
|
50187
52220
|
const tilde = tildeOf(i.env);
|
|
50188
52221
|
const body = await buildIssueBody(i);
|
|
50189
|
-
const dir =
|
|
52222
|
+
const dir = join15(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
|
|
50190
52223
|
mkdirSync6(dir, { recursive: true });
|
|
50191
|
-
const file2 =
|
|
50192
|
-
|
|
52224
|
+
const file2 = join15(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
|
|
52225
|
+
writeFileSync4(file2, body);
|
|
50193
52226
|
const shown2 = tilde(file2);
|
|
50194
52227
|
const title = issueTitle(i.adapter.id, i.rows);
|
|
50195
52228
|
const gh = [`gh issue create --repo ${ISSUE_REPO_SLUG} --label bug \\`, `${DOCTOR_GH_NEXT}title ${JSON.stringify(title)} \\`, `${DOCTOR_GH_NEXT}body-file ${shown2}`];
|
|
@@ -50264,11 +52297,11 @@ async function hookRow(ctx, adapter, host) {
|
|
|
50264
52297
|
}
|
|
50265
52298
|
}
|
|
50266
52299
|
function ownServerId(configDir, projectKey) {
|
|
50267
|
-
const dir =
|
|
52300
|
+
const dir = join16(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
50268
52301
|
if (!existsSync16(dir)) return "";
|
|
50269
52302
|
for (const name of readdirSync7(dir)) {
|
|
50270
52303
|
if (!name.endsWith(OWNER_PID_EXT)) continue;
|
|
50271
|
-
if (readFileSync11(
|
|
52304
|
+
if (readFileSync11(join16(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
|
|
50272
52305
|
}
|
|
50273
52306
|
return "";
|
|
50274
52307
|
}
|
|
@@ -50282,7 +52315,7 @@ async function runDoctorChecks(ctx, adapter, host0) {
|
|
|
50282
52315
|
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 }),
|
|
50283
52316
|
D2: () => checkNode({ nodeVersion: process.version, bunVersion: process.versions.bun }),
|
|
50284
52317
|
D3: () => checkHostConfig(adapter, env, project.worktree),
|
|
50285
|
-
D4: () => checkV1Leftovers(adapter.id, requireHomeDir(env), { project: project.worktree, piAgentDir: piAgentDirOf(env, requireHomeDir(env)), claudeDir: claudeDirOf(env, requireHomeDir(env)), codexDir: codexDirOf(env, requireHomeDir(env)), copilotDir: copilotDirOf(env, requireHomeDir(env)), kiroDir: kiroDirOf(env, requireHomeDir(env)), opencodeDir: opencodeDirOf(env, requireHomeDir(env)) }),
|
|
52318
|
+
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)) }),
|
|
50286
52319
|
D5: () => hookRow(ctx, adapter, host),
|
|
50287
52320
|
D5b: () => checkDoubleFire(adapter.id, project.worktree),
|
|
50288
52321
|
D6: () => checkMcp(ctx),
|
|
@@ -50323,13 +52356,13 @@ function reportEnv(env) {
|
|
|
50323
52356
|
async function doctorReply(ctx, host) {
|
|
50324
52357
|
const adapter = getAdapter(ctx.project.agent);
|
|
50325
52358
|
const rows = await runDoctorChecks(ctx, adapter, host);
|
|
50326
|
-
const
|
|
50327
|
-
const command = adapter.id === "pi" ?
|
|
52359
|
+
const failed = rows.some((r) => r.status === "FAIL");
|
|
52360
|
+
const command = adapter.id === "pi" ? failed ? NATIVE_INSTALL.pi[0] : PI_LIST_COMMAND : `context-mode ${failed ? "setup" : "doctor"} --agents ${adapter.id}`;
|
|
50328
52361
|
const input = { agent: adapter.id, rows, env: reportEnv(host.env), command };
|
|
50329
52362
|
const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir));
|
|
50330
52363
|
const table3 = buildReport(input);
|
|
50331
52364
|
let notes = [];
|
|
50332
|
-
if (
|
|
52365
|
+
if (failed) {
|
|
50333
52366
|
try {
|
|
50334
52367
|
notes = await writeIssueReport({ ctx, adapter, env: host.env, bundleDir: host.bundleDir, rows, envLine: envLine2, table: table3 });
|
|
50335
52368
|
} catch (err) {
|
|
@@ -50363,9 +52396,9 @@ var ctxDoctor = Object.freeze({
|
|
|
50363
52396
|
});
|
|
50364
52397
|
|
|
50365
52398
|
// src/core/tools/execute.ts
|
|
50366
|
-
import { existsSync as existsSync17, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as
|
|
52399
|
+
import { existsSync as existsSync17, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync5 } from "node:fs";
|
|
50367
52400
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
50368
|
-
import { dirname as dirname9, join as
|
|
52401
|
+
import { dirname as dirname9, join as join17, parse as parse5, resolve as resolve5 } from "node:path";
|
|
50369
52402
|
|
|
50370
52403
|
// src/core/index/select.ts
|
|
50371
52404
|
var READ_CHUNKS = "SELECT ord, body FROM chunks WHERE source_id = ?";
|
|
@@ -50450,7 +52483,6 @@ var ctxExecuteSchema = external_exports.object({
|
|
|
50450
52483
|
background: external_exports.boolean().optional(),
|
|
50451
52484
|
summary: external_exports.boolean().optional()
|
|
50452
52485
|
}, { error: unknownField }).strict();
|
|
50453
|
-
var SHELL_FAMILY = Object.freeze(["sh", "bash", "zsh", "dash", "ksh", "fish"]);
|
|
50454
52486
|
var SCRIPT_EXT = Object.freeze({
|
|
50455
52487
|
javascript: ".js",
|
|
50456
52488
|
typescript: ".ts",
|
|
@@ -50469,7 +52501,7 @@ var LAUNCHER = [
|
|
|
50469
52501
|
'const { rmSync } = require("node:fs");',
|
|
50470
52502
|
"const [mode, dir, ...argv] = process.argv.slice(1);",
|
|
50471
52503
|
'if (mode === "start") {',
|
|
50472
|
-
' const b = spawn(process.execPath, [...process.execArgv, "--", "run", dir, ...argv], { detached: true, stdio: "ignore", windowsHide: true });',
|
|
52504
|
+
' const b = spawn(process.execPath, [...process.execArgv.filter((a) => a !== "--"), "--", "run", dir, ...argv], { detached: true, stdio: "ignore", windowsHide: true });',
|
|
50473
52505
|
" b.unref();",
|
|
50474
52506
|
" process.stdout.write(String(b.pid));",
|
|
50475
52507
|
"} else {",
|
|
@@ -50552,7 +52584,7 @@ async function handler3(raw, ctx) {
|
|
|
50552
52584
|
const cwd = ctx.project.worktree;
|
|
50553
52585
|
const extra = { ...PLAIN_OUTPUT_ENV2 };
|
|
50554
52586
|
if (input.file !== void 0) {
|
|
50555
|
-
const abs =
|
|
52587
|
+
const abs = resolve5(cwd, input.file);
|
|
50556
52588
|
const bad = fileError(input.file, abs, ctx.project.containmentRoot);
|
|
50557
52589
|
if (bad !== null) return fail4(bad);
|
|
50558
52590
|
extra.CTX_FILE = abs;
|
|
@@ -50569,13 +52601,14 @@ async function handler3(raw, ctx) {
|
|
|
50569
52601
|
if (takesDashC(input.language, runtime)) {
|
|
50570
52602
|
argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
|
|
50571
52603
|
} else {
|
|
50572
|
-
tmpDir = mkdtempSync2(
|
|
50573
|
-
const file2 =
|
|
50574
|
-
|
|
52604
|
+
tmpDir = mkdtempSync2(join17(tmpdir3(), TMP_PREFIX));
|
|
52605
|
+
const file2 = join17(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
|
|
52606
|
+
writeFileSync5(file2, scriptText(input.language, input.code), "utf8");
|
|
50575
52607
|
argv = scriptArgv(input.language, runtime, file2);
|
|
50576
52608
|
}
|
|
50577
52609
|
if (input.background === true) {
|
|
50578
|
-
const
|
|
52610
|
+
const node3 = nodeLaunch(env);
|
|
52611
|
+
const r2 = await runProcess([node3.file, "-e", LAUNCHER, "--", "start", tmpDir ?? "", ...argv], { cwd, env: node3.env, signal: ctx.signal, timeoutMs });
|
|
50579
52612
|
const pid = r2.stdout.toString("utf8");
|
|
50580
52613
|
if (r2.exitCode !== 0 || pid === "" || !Number.isSafeInteger(Number(pid))) return fail4(spawnFailed(argv[0], cwd), journal);
|
|
50581
52614
|
handedOff = true;
|
|
@@ -50606,11 +52639,11 @@ var ctxExecute = {
|
|
|
50606
52639
|
|
|
50607
52640
|
// src/core/tools/index.ts
|
|
50608
52641
|
import { existsSync as existsSync18, readFileSync as readFileSync13, statSync as statSync7 } from "node:fs";
|
|
50609
|
-
import { dirname as dirname10, extname, join as
|
|
52642
|
+
import { dirname as dirname10, extname as extname2, join as join19, relative as relative3, resolve as resolve6 } from "node:path";
|
|
50610
52643
|
|
|
50611
52644
|
// src/core/index/walk.ts
|
|
50612
52645
|
import { readdirSync as readdirSync8, readFileSync as readFileSync12, realpathSync as realpathSync10, statSync as statSync6 } from "node:fs";
|
|
50613
|
-
import { join as
|
|
52646
|
+
import { join as join18 } from "node:path";
|
|
50614
52647
|
var GITIGNORE = ".gitignore";
|
|
50615
52648
|
var GIT_DIR = ".git";
|
|
50616
52649
|
function walkDir(root, containmentRoot) {
|
|
@@ -50619,7 +52652,7 @@ function walkDir(root, containmentRoot) {
|
|
|
50619
52652
|
const found = [];
|
|
50620
52653
|
visit(real3, [], [], containmentRoot, /* @__PURE__ */ new Set([real3]), found);
|
|
50621
52654
|
found.sort(compareFound);
|
|
50622
|
-
return found.map((f) => ({ absPath: f.absPath, relPath:
|
|
52655
|
+
return found.map((f) => ({ absPath: f.absPath, relPath: join18(...f.dir, f.name) }));
|
|
50623
52656
|
}
|
|
50624
52657
|
function visit(abs, rel, parent, contain, seen, found) {
|
|
50625
52658
|
let entries;
|
|
@@ -50628,10 +52661,10 @@ function visit(abs, rel, parent, contain, seen, found) {
|
|
|
50628
52661
|
} catch {
|
|
50629
52662
|
return;
|
|
50630
52663
|
}
|
|
50631
|
-
const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(
|
|
52664
|
+
const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join18(abs, GITIGNORE), rel)) : parent;
|
|
50632
52665
|
for (const e of entries) {
|
|
50633
52666
|
if (e.name === GIT_DIR) continue;
|
|
50634
|
-
const path8 =
|
|
52667
|
+
const path8 = join18(abs, e.name);
|
|
50635
52668
|
let isDir = e.isDirectory();
|
|
50636
52669
|
let isFile = e.isFile();
|
|
50637
52670
|
let target = path8;
|
|
@@ -50765,11 +52798,24 @@ var PRIVATE_RANGES = [
|
|
|
50765
52798
|
["172.16.0.0", 12, "ipv4"],
|
|
50766
52799
|
["192.168.0.0", 16, "ipv4"],
|
|
50767
52800
|
["169.254.0.0", 16, "ipv4"],
|
|
50768
|
-
["0.0.0.0",
|
|
52801
|
+
["0.0.0.0", 8, "ipv4"],
|
|
52802
|
+
// D-SSRF-RANGES-1: "this network", not only 0.0.0.0
|
|
52803
|
+
["100.64.0.0", 10, "ipv4"],
|
|
52804
|
+
// D-SSRF-RANGES-1: shared address space (RFC 6598), cloud metadata lives here
|
|
52805
|
+
["198.18.0.0", 15, "ipv4"],
|
|
52806
|
+
// D-SSRF-RANGES-1: benchmark networks (RFC 2544)
|
|
52807
|
+
["240.0.0.0", 4, "ipv4"],
|
|
52808
|
+
// D-SSRF-RANGES-1: reserved and broadcast
|
|
50769
52809
|
["::1", 128, "ipv6"],
|
|
50770
52810
|
["::", 128, "ipv6"],
|
|
52811
|
+
["::", 96, "ipv6"],
|
|
52812
|
+
// D-SSRF-RANGES-1: IPv4-compatible (::a.b.c.d), deprecated, never a public origin
|
|
52813
|
+
["64:ff9b:1::", 48, "ipv6"],
|
|
52814
|
+
// D-SSRF-RANGES-1: local-use NAT64 (RFC 8215)
|
|
50771
52815
|
["fc00::", 7, "ipv6"],
|
|
50772
|
-
["fe80::", 10, "ipv6"]
|
|
52816
|
+
["fe80::", 10, "ipv6"],
|
|
52817
|
+
["fec0::", 10, "ipv6"]
|
|
52818
|
+
// D-SSRF-RANGES-1: site-local (RFC 3879)
|
|
50773
52819
|
];
|
|
50774
52820
|
var BLOCKED = new BlockList();
|
|
50775
52821
|
for (const [net, prefix, type] of PRIVATE_RANGES) BLOCKED.addSubnet(net, prefix, type);
|
|
@@ -50822,9 +52868,41 @@ function pickProxy(u) {
|
|
|
50822
52868
|
const auth = p.username === "" ? void 0 : "Basic " + Buffer.from(decodeURIComponent(p.username) + ":" + decodeURIComponent(p.password)).toString("base64");
|
|
50823
52869
|
return { url: p, auth };
|
|
50824
52870
|
}
|
|
52871
|
+
function ipv6Words(address) {
|
|
52872
|
+
const zone = address.indexOf("%");
|
|
52873
|
+
const a = zone < 0 ? address : address.slice(0, zone);
|
|
52874
|
+
const words2 = (part) => {
|
|
52875
|
+
if (part === "") return [];
|
|
52876
|
+
const out = [];
|
|
52877
|
+
for (const w of part.split(":")) {
|
|
52878
|
+
if (w.includes(".")) {
|
|
52879
|
+
const q = w.split(".").map(Number);
|
|
52880
|
+
out.push(q[0] * 256 + q[1], q[2] * 256 + q[3]);
|
|
52881
|
+
} else out.push(parseInt(w, 16));
|
|
52882
|
+
}
|
|
52883
|
+
return out;
|
|
52884
|
+
};
|
|
52885
|
+
const gap = a.indexOf("::");
|
|
52886
|
+
if (gap < 0) return words2(a);
|
|
52887
|
+
const head = words2(a.slice(0, gap));
|
|
52888
|
+
const tail = words2(a.slice(gap + 2));
|
|
52889
|
+
return [...head, ...new Array(8 - head.length - tail.length).fill(0), ...tail];
|
|
52890
|
+
}
|
|
52891
|
+
function dotted(hi, lo) {
|
|
52892
|
+
return [hi >> 8, hi & 255, lo >> 8, lo & 255].join(".");
|
|
52893
|
+
}
|
|
52894
|
+
function embeddedIpv4(address) {
|
|
52895
|
+
const w = ipv6Words(address);
|
|
52896
|
+
if (w[0] === 100 && w[1] === 65435 && w[2] === 0 && w[3] === 0 && w[4] === 0 && w[5] === 0) {
|
|
52897
|
+
return dotted(w[6], w[7]);
|
|
52898
|
+
}
|
|
52899
|
+
if (w[0] === 8194) return dotted(w[1], w[2]);
|
|
52900
|
+
return void 0;
|
|
52901
|
+
}
|
|
50825
52902
|
function checkAddress(hostname2, address) {
|
|
50826
52903
|
const family = isIP(address);
|
|
50827
|
-
|
|
52904
|
+
const inner = family === 6 ? embeddedIpv4(address) : void 0;
|
|
52905
|
+
if (family === 0 || BLOCKED.check(address, family === 4 ? "ipv4" : "ipv6") || inner !== void 0 && BLOCKED.check(inner, "ipv4")) {
|
|
50828
52906
|
throw new CtxError("SSRF", { host: hostname2 });
|
|
50829
52907
|
}
|
|
50830
52908
|
}
|
|
@@ -50848,18 +52926,18 @@ function request(u, conn, proxy, signal) {
|
|
|
50848
52926
|
const host = bare(u.hostname);
|
|
50849
52927
|
const port = u.port === "" ? defaultPort(u.protocol) : Number(u.port);
|
|
50850
52928
|
const path8 = u.pathname + u.search;
|
|
50851
|
-
return new Promise((
|
|
52929
|
+
return new Promise((resolve7, reject) => {
|
|
50852
52930
|
const onErr = (err) => reject(fail5(causeCode(err)));
|
|
50853
52931
|
if (proxy === void 0) {
|
|
50854
52932
|
const mod = u.protocol === "https:" ? https : http;
|
|
50855
52933
|
const req = mod.request({ host: conn.address, port, path: path8, signal, servername: tlsName(host), headers: { host: u.host } });
|
|
50856
|
-
req.on("response",
|
|
52934
|
+
req.on("response", resolve7).on("error", onErr).end();
|
|
50857
52935
|
return;
|
|
50858
52936
|
}
|
|
50859
52937
|
const proxyHeaders = proxy.auth === void 0 ? {} : { "proxy-authorization": proxy.auth };
|
|
50860
52938
|
if (u.protocol === "http:") {
|
|
50861
52939
|
const req = http.request({ host: conn.address, port: conn.port, path: u.href, signal, headers: { host: u.host, ...proxyHeaders } });
|
|
50862
|
-
req.on("response",
|
|
52940
|
+
req.on("response", resolve7).on("error", onErr).end();
|
|
50863
52941
|
return;
|
|
50864
52942
|
}
|
|
50865
52943
|
const authority = (isIP(host) === 6 ? "[" + host + "]" : host) + ":" + port;
|
|
@@ -50879,16 +52957,16 @@ function request(u, conn, proxy, signal) {
|
|
|
50879
52957
|
headers: { host: u.host },
|
|
50880
52958
|
createConnection: () => tlsConnect({ socket, host, servername: tlsName(host) })
|
|
50881
52959
|
});
|
|
50882
|
-
req.on("response",
|
|
52960
|
+
req.on("response", resolve7).on("error", onErr).end();
|
|
50883
52961
|
});
|
|
50884
52962
|
tunnel.end();
|
|
50885
52963
|
});
|
|
50886
52964
|
}
|
|
50887
52965
|
function readBody(res) {
|
|
50888
|
-
return new Promise((
|
|
52966
|
+
return new Promise((resolve7, reject) => {
|
|
50889
52967
|
const parts = [];
|
|
50890
52968
|
res.on("data", (b) => parts.push(b));
|
|
50891
|
-
res.on("end", () =>
|
|
52969
|
+
res.on("end", () => resolve7(Buffer.concat(parts)));
|
|
50892
52970
|
res.on("error", (err) => reject(fail5(causeCode(err))));
|
|
50893
52971
|
res.on("aborted", () => reject(fail5("ECONNRESET")));
|
|
50894
52972
|
});
|
|
@@ -54150,11 +56228,11 @@ function compareDocumentPosition(nodeA, nodeB) {
|
|
|
54150
56228
|
function uniqueSort(nodes) {
|
|
54151
56229
|
nodes = nodes.filter((node3, index, array4) => !array4.includes(node3, index + 1));
|
|
54152
56230
|
nodes.sort((a, b) => {
|
|
54153
|
-
const
|
|
54154
|
-
if (
|
|
56231
|
+
const relative4 = compareDocumentPosition(a, b);
|
|
56232
|
+
if (relative4 & DocumentPosition.PRECEDING) {
|
|
54155
56233
|
return -1;
|
|
54156
56234
|
}
|
|
54157
|
-
if (
|
|
56235
|
+
if (relative4 & DocumentPosition.FOLLOWING) {
|
|
54158
56236
|
return 1;
|
|
54159
56237
|
}
|
|
54160
56238
|
return 0;
|
|
@@ -54723,10 +56801,10 @@ function htmlToReadable(html, baseUrl) {
|
|
|
54723
56801
|
const st = { w: new Writer(), base, sawH1: false };
|
|
54724
56802
|
for (const n of contentRoot(doc.children)) walk(st, n);
|
|
54725
56803
|
const body = st.w.result();
|
|
54726
|
-
const
|
|
54727
|
-
const text = !st.sawH1 && title !== "" &&
|
|
54728
|
-
const sparse =
|
|
54729
|
-
return { text: text === "" ? "" : text + "\n", title, words, sparse };
|
|
56804
|
+
const words2 = wordCount(body);
|
|
56805
|
+
const text = !st.sawH1 && title !== "" && words2 > 0 ? "# " + title + "\n\n" + body : body;
|
|
56806
|
+
const sparse = words2 < SPARSE_MAX_WORDS && html.length > SPARSE_RATIO * Math.max(text.length, 1);
|
|
56807
|
+
return { text: text === "" ? "" : text + "\n", title, words: words2, sparse };
|
|
54730
56808
|
}
|
|
54731
56809
|
|
|
54732
56810
|
// src/core/tools/index.ts
|
|
@@ -54745,7 +56823,7 @@ function userLabel(label2) {
|
|
|
54745
56823
|
return label2 === DECISION_SOURCE ? DECISION_USER_LABEL : label2;
|
|
54746
56824
|
}
|
|
54747
56825
|
function kindOfPath(p) {
|
|
54748
|
-
return EXT_KIND[
|
|
56826
|
+
return EXT_KIND[extname2(p).toLowerCase()] ?? "text";
|
|
54749
56827
|
}
|
|
54750
56828
|
function kindOfType(contentType) {
|
|
54751
56829
|
const semi = contentType.indexOf(";");
|
|
@@ -54766,13 +56844,13 @@ function missingOrOutside(given, abs, root) {
|
|
|
54766
56844
|
return new CtxError("OUTSIDE_ROOT", { p: given, root });
|
|
54767
56845
|
}
|
|
54768
56846
|
function pathItems(input, project) {
|
|
54769
|
-
const abs =
|
|
56847
|
+
const abs = resolve6(project.worktree, input.path);
|
|
54770
56848
|
if (!isInside(project.containmentRoot, abs)) throw missingOrOutside(input.path, abs, project.containmentRoot);
|
|
54771
|
-
const base =
|
|
56849
|
+
const base = relative3(project.worktree, abs);
|
|
54772
56850
|
if (statSync7(abs).isDirectory()) {
|
|
54773
56851
|
return walkDir(abs, project.containmentRoot).map((f) => ({
|
|
54774
56852
|
sourceKind: "path",
|
|
54775
|
-
label: pathLabel(
|
|
56853
|
+
label: pathLabel(join19(base, f.relPath)),
|
|
54776
56854
|
kind: kindOfPath(f.relPath),
|
|
54777
56855
|
read: () => readUtf8(f.absPath)
|
|
54778
56856
|
}));
|
|
@@ -55061,7 +57139,7 @@ function pickUnits(cands, seen, budget) {
|
|
|
55061
57139
|
const pool = cands.filter((u) => !seen.has(unitKey(u)) && u.score >= RECALL_MIN_SCORE);
|
|
55062
57140
|
if (pool.length === 0) return [];
|
|
55063
57141
|
const top = Math.max(...pool.map((u) => u.score));
|
|
55064
|
-
const
|
|
57142
|
+
const words2 = pool.map((u) => wordsOf(u.body));
|
|
55065
57143
|
const taken = [];
|
|
55066
57144
|
const left = new Set(pool.map((_, i) => i));
|
|
55067
57145
|
let used = 0;
|
|
@@ -55070,7 +57148,7 @@ function pickUnits(cands, seen, budget) {
|
|
|
55070
57148
|
let bestVal = -Infinity;
|
|
55071
57149
|
for (const i of left) {
|
|
55072
57150
|
let sim = 0;
|
|
55073
|
-
for (const j of taken) sim = Math.max(sim, overlap(
|
|
57151
|
+
for (const j of taken) sim = Math.max(sim, overlap(words2[i], words2[j]));
|
|
55074
57152
|
const val = MMR_RELEVANCE_WEIGHT * (pool[i].score / top) - MMR_REDUNDANCY_WEIGHT * sim;
|
|
55075
57153
|
if (val > bestVal) {
|
|
55076
57154
|
bestVal = val;
|
|
@@ -55282,7 +57360,7 @@ function readWeek(raw, lastMs) {
|
|
|
55282
57360
|
}
|
|
55283
57361
|
return days;
|
|
55284
57362
|
}
|
|
55285
|
-
var
|
|
57363
|
+
var EMPTY4 = Object.freeze({ calls: 0, produced: 0, returned: 0, saved: 0 });
|
|
55286
57364
|
function totals(r) {
|
|
55287
57365
|
const produced = Number(r.produced);
|
|
55288
57366
|
const returned = Number(r.returned);
|
|
@@ -55322,7 +57400,7 @@ function sum(groups) {
|
|
|
55322
57400
|
produced: t.produced + g.produced,
|
|
55323
57401
|
returned: t.returned + g.returned,
|
|
55324
57402
|
saved: t.saved + g.saved
|
|
55325
|
-
}),
|
|
57403
|
+
}), EMPTY4);
|
|
55326
57404
|
}
|
|
55327
57405
|
function reductionPct(t) {
|
|
55328
57406
|
if (t.calls === 0) return 0;
|
|
@@ -55516,8 +57594,8 @@ function report(f, sessionId, agent) {
|
|
|
55516
57594
|
] : []
|
|
55517
57595
|
];
|
|
55518
57596
|
const agents = /* @__PURE__ */ new Map();
|
|
55519
|
-
for (const g of f.groups) agents.set(g.agent, sum([agents.get(g.agent) ??
|
|
55520
|
-
if (!agents.has(agent)) agents.set(agent,
|
|
57597
|
+
for (const g of f.groups) agents.set(g.agent, sum([agents.get(g.agent) ?? EMPTY4, g]));
|
|
57598
|
+
if (!agents.has(agent)) agents.set(agent, EMPTY4);
|
|
55521
57599
|
lines.push("By agent (this project)", ...table2("Agent", [...agents].map(([name, t]) => ({ name, ...t })).sort(bySaved)), "");
|
|
55522
57600
|
const maxKind = Math.max(0, ...[...f.kinds.values()].map((k) => k.project));
|
|
55523
57601
|
lines.push("Kept in the session journal", " " + "Journal".padEnd(LABEL_W) + right("Session", STATS_KIND_W) + right("Project", STATS_KIND_W));
|
|
@@ -55576,29 +57654,28 @@ var ctxStats = Object.freeze({
|
|
|
55576
57654
|
handler: handler7
|
|
55577
57655
|
});
|
|
55578
57656
|
|
|
55579
|
-
// src/core/tools/upgrade.ts
|
|
55580
|
-
import { existsSync as existsSync24, realpathSync as realpathSync11, rmSync as rmSync11 } from "node:fs";
|
|
55581
|
-
import { basename as basename7, dirname as dirname12, join as join24 } from "node:path";
|
|
55582
|
-
|
|
55583
57657
|
// src/core/ops/host-write.ts
|
|
55584
|
-
import { copyFileSync, existsSync as existsSync19, mkdirSync as mkdirSync7, writeFileSync as
|
|
55585
|
-
import { dirname as dirname11, join as
|
|
57658
|
+
import { copyFileSync, existsSync as existsSync19, mkdirSync as mkdirSync7, writeFileSync as writeFileSync6 } from "node:fs";
|
|
57659
|
+
import { dirname as dirname11, join as join20 } from "node:path";
|
|
55586
57660
|
function defaultWrite(file2, text) {
|
|
55587
|
-
|
|
57661
|
+
writeFileSync6(file2, text, "utf8");
|
|
55588
57662
|
}
|
|
55589
57663
|
function hostConfigPath(agent, home, env) {
|
|
55590
57664
|
const own4 = OWN_MCP_ENTRY[agent];
|
|
55591
57665
|
if (own4 !== void 0) return ownMcpFileOf(agent, own4.file, env, home);
|
|
55592
57666
|
switch (agent) {
|
|
55593
57667
|
case "opencode":
|
|
55594
|
-
return
|
|
57668
|
+
return join20(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
|
|
55595
57669
|
// D-WIN-OPENCODE-DIR-1
|
|
55596
57670
|
case "pi":
|
|
55597
|
-
return
|
|
57671
|
+
return join20(piAgentDirOf(env, home), SETTINGS_FILE);
|
|
57672
|
+
case "gemini":
|
|
57673
|
+
return join20(geminiDirOf(env, home), SETTINGS_FILE);
|
|
57674
|
+
// D-R38-GEMINI-HOME-1
|
|
55598
57675
|
case "copilot-cli":
|
|
55599
57676
|
return null;
|
|
55600
57677
|
default:
|
|
55601
|
-
return
|
|
57678
|
+
return join20(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
|
|
55602
57679
|
}
|
|
55603
57680
|
}
|
|
55604
57681
|
function cell3(value) {
|
|
@@ -55647,96 +57724,16 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
55647
57724
|
return result.edits.map((e) => toRow(current.path, e));
|
|
55648
57725
|
}
|
|
55649
57726
|
|
|
55650
|
-
// src/core/ops/plugin-swap.ts
|
|
55651
|
-
import { existsSync as existsSync20, lstatSync, readdirSync as readdirSync9, readlinkSync, rmSync as rmSync7, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
|
|
55652
|
-
import { basename as basename6, join as join20, win32 as win322 } from "node:path";
|
|
55653
|
-
function linkTarget(path8, win) {
|
|
55654
|
-
if (!isLink(path8)) return null;
|
|
55655
|
-
const target = readlinkSync(path8);
|
|
55656
|
-
return win ? win322.basename(target) : target;
|
|
55657
|
-
}
|
|
55658
|
-
function isLink(path8) {
|
|
55659
|
-
return lstatSync(path8, { throwIfNoEntry: false })?.isSymbolicLink() === true;
|
|
55660
|
-
}
|
|
55661
|
-
function generations(agentDir) {
|
|
55662
|
-
return readdirSync9(agentDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).filter((name) => !name.startsWith(UPGRADE_FETCH_DIR_PREFIX) && !name.endsWith(UPGRADE_TRASH_SUFFIX)).sort();
|
|
55663
|
-
}
|
|
55664
|
-
function settleLinks(link, tmp, old, opts) {
|
|
55665
|
-
if (isLink(tmp)) unlinkSync2(tmp);
|
|
55666
|
-
if (!isLink(old)) return;
|
|
55667
|
-
if (isLink(link)) unlinkSync2(old);
|
|
55668
|
-
else renameWithRetry(old, link, opts);
|
|
55669
|
-
}
|
|
55670
|
-
function swapPluginCurrent(agentDir, sha, opts = {}) {
|
|
55671
|
-
const next = join20(agentDir, sha);
|
|
55672
|
-
if (!existsSync20(next) || !lstatSync(next).isDirectory()) {
|
|
55673
|
-
throw new CtxError("PLUGIN_ROOT_MISSING", { agent: basename6(agentDir), path: next });
|
|
55674
|
-
}
|
|
55675
|
-
const link = join20(agentDir, PLUGIN_CURRENT_LINK);
|
|
55676
|
-
const tmp = link + PLUGIN_LINK_TMP_SUFFIX;
|
|
55677
|
-
const old = link + PLUGIN_LINK_OLD_SUFFIX;
|
|
55678
|
-
settleLinks(link, tmp, old, opts);
|
|
55679
|
-
const win = (opts.platform ?? process.platform) === "win32";
|
|
55680
|
-
const before = linkTarget(link, win);
|
|
55681
|
-
if (before === sha) return { current: next, previous: null, removed: [] };
|
|
55682
|
-
const symlink = opts.symlink ?? symlinkSync;
|
|
55683
|
-
if (win) symlink(next, tmp, PLUGIN_LINK_TYPE_WIN32);
|
|
55684
|
-
else symlink(sha, tmp, PLUGIN_LINK_TYPE);
|
|
55685
|
-
if (before !== null) renameWithRetry(link, old, opts);
|
|
55686
|
-
renameWithRetry(tmp, link, opts);
|
|
55687
|
-
if (before !== null) unlinkSync2(old);
|
|
55688
|
-
const keep = /* @__PURE__ */ new Set([sha]);
|
|
55689
|
-
if (before !== null) keep.add(before);
|
|
55690
|
-
const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join20(agentDir, name));
|
|
55691
|
-
for (const dir of removed) rmSync7(dir, { recursive: true, force: true });
|
|
55692
|
-
const previous = before !== null && existsSync20(join20(agentDir, before)) ? join20(agentDir, before) : null;
|
|
55693
|
-
return { current: next, previous, removed };
|
|
55694
|
-
}
|
|
55695
|
-
|
|
55696
|
-
// src/core/ops/release-fetch.ts
|
|
55697
|
-
import { existsSync as existsSync21, mkdirSync as mkdirSync8, rmSync as rmSync8 } from "node:fs";
|
|
55698
|
-
import { join as join21 } from "node:path";
|
|
55699
|
-
function failed(r) {
|
|
55700
|
-
if (r.exitCode === null && r.killed === null) return new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
|
|
55701
|
-
const status = r.killed ?? String(r.exitCode);
|
|
55702
|
-
return new CtxError("FETCH_FAILED", { code: GIT_EXIT_LABEL + status + UPGRADE_AREA_KEY_SEP + r.stderr.toString().trim() });
|
|
55703
|
-
}
|
|
55704
|
-
async function git2(bin, args, cwd, env, signal) {
|
|
55705
|
-
const r = await runProcess([bin, ...args], { cwd, env, signal, timeoutMs: UPGRADE_GIT_TIMEOUT_MS });
|
|
55706
|
-
if (r.exitCode !== 0 || r.killed !== null) throw failed(r);
|
|
55707
|
-
return r.stdout.toString().trim();
|
|
55708
|
-
}
|
|
55709
|
-
async function fetchRelease(agent, url4, env, signal, opts = {}) {
|
|
55710
|
-
const agentDir = join21(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, agent);
|
|
55711
|
-
mkdirSync8(agentDir, { recursive: true });
|
|
55712
|
-
const fetchDir = join21(agentDir, UPGRADE_FETCH_DIR_PREFIX + process.pid);
|
|
55713
|
-
rmSync8(fetchDir, { recursive: true, force: true });
|
|
55714
|
-
const gitBin = findRuntime(GIT_BIN, env);
|
|
55715
|
-
if (gitBin === null) throw new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
|
|
55716
|
-
const childEnv = buildChildEnv(env, { ...GIT_NO_PROMPT_ENV, ...GIT_NO_CRLF_ENV });
|
|
55717
|
-
try {
|
|
55718
|
-
await git2(gitBin, [...GIT_CLONE_ARGS, RELEASE_BRANCH, url4, fetchDir], agentDir, childEnv, signal);
|
|
55719
|
-
const sha = await git2(gitBin, GIT_HEAD_SHA_ARGS, fetchDir, childEnv, signal);
|
|
55720
|
-
const dir = join21(agentDir, sha);
|
|
55721
|
-
if (existsSync21(dir)) rmSync8(fetchDir, { recursive: true, force: true });
|
|
55722
|
-
else renameWithRetry(fetchDir, dir, opts);
|
|
55723
|
-
return { sha, dir };
|
|
55724
|
-
} catch (e) {
|
|
55725
|
-
rmSync8(fetchDir, { recursive: true, force: true });
|
|
55726
|
-
throw e;
|
|
55727
|
-
}
|
|
55728
|
-
}
|
|
55729
|
-
|
|
55730
57727
|
// src/core/ops/uninstall.ts
|
|
55731
|
-
import { existsSync as
|
|
55732
|
-
import { join as
|
|
57728
|
+
import { existsSync as existsSync20, readdirSync as readdirSync9, rmSync as rmSync7, writeFileSync as writeFileSync7 } from "node:fs";
|
|
57729
|
+
import { join as join21 } from "node:path";
|
|
55733
57730
|
function row2(area, before, after) {
|
|
55734
57731
|
return { area, before, after };
|
|
55735
57732
|
}
|
|
55736
57733
|
function stopServers(configDir, projectKey) {
|
|
55737
57734
|
const stopped = listLiveOwners(configDir, projectKey);
|
|
55738
|
-
const dir =
|
|
55739
|
-
for (const serverId of stopped)
|
|
57735
|
+
const dir = join21(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
57736
|
+
for (const serverId of stopped) writeFileSync7(join21(dir, serverId + OWNER_STOP_EXT), "", "utf8");
|
|
55740
57737
|
return stopped.length === 0 ? { row: row2(UPGRADE_SERVER_AREA, "", UPGRADE_NOT_FOUND), stopped } : { row: row2(UPGRADE_SERVER_AREA, UPGRADE_SERVER_RUNNING, UPGRADE_SERVER_STOPPED), stopped };
|
|
55741
57738
|
}
|
|
55742
57739
|
function rootOrNull(adapter, env) {
|
|
@@ -55754,16 +57751,16 @@ function removeCache(adapter, env, configDir) {
|
|
|
55754
57751
|
const root = rootOrNull(adapter, env);
|
|
55755
57752
|
if (root === null) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
|
|
55756
57753
|
if (adapter.installMode === "marketplace") {
|
|
55757
|
-
const cache =
|
|
57754
|
+
const cache = join21(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
|
|
55758
57755
|
if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
|
|
55759
57756
|
}
|
|
55760
|
-
|
|
57757
|
+
rmSync7(root, { recursive: true, force: true });
|
|
55761
57758
|
return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
|
|
55762
57759
|
}
|
|
55763
57760
|
case "plugin": {
|
|
55764
|
-
const agentDir =
|
|
55765
|
-
if (!
|
|
55766
|
-
|
|
57761
|
+
const agentDir = join21(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
|
|
57762
|
+
if (!existsSync20(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
|
|
57763
|
+
rmSync7(agentDir, { recursive: true, force: true });
|
|
55767
57764
|
return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
|
|
55768
57765
|
}
|
|
55769
57766
|
case "config-mcp":
|
|
@@ -55778,7 +57775,7 @@ function removeCache(adapter, env, configDir) {
|
|
|
55778
57775
|
function isObj3(v) {
|
|
55779
57776
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
55780
57777
|
}
|
|
55781
|
-
function
|
|
57778
|
+
function piSource2(entry) {
|
|
55782
57779
|
return isObj3(entry) ? entry[PI_PACKAGE_SOURCE_KEY] : entry;
|
|
55783
57780
|
}
|
|
55784
57781
|
function ownEntries2(agent, env) {
|
|
@@ -55807,7 +57804,7 @@ function ownEntries2(agent, env) {
|
|
|
55807
57804
|
}
|
|
55808
57805
|
if (agent === "opencode") {
|
|
55809
57806
|
return [{
|
|
55810
|
-
file:
|
|
57807
|
+
file: join21(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
|
|
55811
57808
|
// D-WIN-OPENCODE-DIR-1
|
|
55812
57809
|
key: OPENCODE_PLUGIN_KEY,
|
|
55813
57810
|
shown: OPENCODE_PLUGIN_KEY,
|
|
@@ -55818,11 +57815,11 @@ function ownEntries2(agent, env) {
|
|
|
55818
57815
|
if (agent === "pi") {
|
|
55819
57816
|
const agentDir = piAgentDirOf(env, home);
|
|
55820
57817
|
return [{
|
|
55821
|
-
file:
|
|
57818
|
+
file: join21(agentDir, SETTINGS_FILE),
|
|
55822
57819
|
key: PI_PACKAGES_KEY,
|
|
55823
57820
|
shown: PI_PACKAGES_KEY,
|
|
55824
|
-
has: (v) => Array.isArray(v) && v.some((x) =>
|
|
55825
|
-
drop: (v) => v.filter((x) =>
|
|
57821
|
+
has: (v) => Array.isArray(v) && v.some((x) => piSource2(x) === PI_GIT_PACKAGE),
|
|
57822
|
+
drop: (v) => v.filter((x) => piSource2(x) !== PI_GIT_PACKAGE)
|
|
55826
57823
|
}];
|
|
55827
57824
|
}
|
|
55828
57825
|
return [];
|
|
@@ -55840,12 +57837,12 @@ function removeOwnEntries(agent, env) {
|
|
|
55840
57837
|
return rows.length === 0 ? [row2(UPGRADE_CONFIG_AREA, "", UPGRADE_NOT_FOUND)] : rows;
|
|
55841
57838
|
}
|
|
55842
57839
|
function removeProjectData(configDir, projectKey) {
|
|
55843
|
-
const projects =
|
|
55844
|
-
const dir =
|
|
55845
|
-
if (!
|
|
57840
|
+
const projects = join21(configDir, PROJECTS_DIR_NAME);
|
|
57841
|
+
const dir = join21(projects, projectKey);
|
|
57842
|
+
if (!existsSync20(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
|
|
55846
57843
|
if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
|
|
55847
|
-
for (const name of
|
|
55848
|
-
if (name !== OWNERS_DIR_NAME)
|
|
57844
|
+
for (const name of readdirSync9(dir)) {
|
|
57845
|
+
if (name !== OWNERS_DIR_NAME) rmSync7(join21(dir, name), { recursive: true, force: true });
|
|
55849
57846
|
}
|
|
55850
57847
|
return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
|
|
55851
57848
|
}
|
|
@@ -55853,25 +57850,32 @@ function runUninstall(input) {
|
|
|
55853
57850
|
const configDir = resolveConfigDir(input.env);
|
|
55854
57851
|
const stop = stopServers(configDir, input.project.projectKey);
|
|
55855
57852
|
const rows = [stop.row, removeCache(input.adapter, input.env, configDir), ...removeOwnEntries(input.adapter.id, input.env)];
|
|
55856
|
-
rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA,
|
|
57853
|
+
rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join21(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
|
|
55857
57854
|
return { rows, stopped: stop.stopped };
|
|
55858
57855
|
}
|
|
55859
57856
|
|
|
55860
57857
|
// src/core/ops/v1-remove.ts
|
|
55861
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
57858
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync21, readFileSync as readFileSync14, rmSync as rmSync8 } from "node:fs";
|
|
55862
57859
|
var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
55863
57860
|
var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
|
|
55864
57861
|
var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
|
|
55865
57862
|
function moveAside(target, undo) {
|
|
55866
57863
|
const trash = target + UPGRADE_TRASH_SUFFIX;
|
|
55867
|
-
|
|
57864
|
+
rmSync8(trash, { recursive: true, force: true });
|
|
55868
57865
|
renameWithRetry(target, trash);
|
|
55869
57866
|
undo.push({ trash, target });
|
|
55870
57867
|
}
|
|
57868
|
+
function keepAside(target, undo) {
|
|
57869
|
+
let aside = target + UPGRADE_ASIDE_SUFFIX;
|
|
57870
|
+
for (let n = 2; existsSync21(aside); n += 1) aside = target + UPGRADE_ASIDE_SUFFIX + "-" + n;
|
|
57871
|
+
renameWithRetry(target, aside);
|
|
57872
|
+
undo.push({ trash: aside, target, keep: true });
|
|
57873
|
+
return aside;
|
|
57874
|
+
}
|
|
55871
57875
|
function keepOriginal(file2, kept, undo) {
|
|
55872
57876
|
if (kept.has(file2)) return;
|
|
55873
57877
|
const trash = file2 + UPGRADE_TRASH_SUFFIX;
|
|
55874
|
-
|
|
57878
|
+
rmSync8(trash, { recursive: true, force: true });
|
|
55875
57879
|
copyFileSync2(file2, trash);
|
|
55876
57880
|
kept.add(file2);
|
|
55877
57881
|
undo.push({ trash, target: file2 });
|
|
@@ -55931,7 +57935,7 @@ function stripJsonEntries(agent, file2, findings, kept, undo) {
|
|
|
55931
57935
|
writeHostConfigEdit(file2, { agent, text, format: "jsonc", path: file2, layout }, patch);
|
|
55932
57936
|
return hit;
|
|
55933
57937
|
}
|
|
55934
|
-
function removeV1(agent, findings) {
|
|
57938
|
+
function removeV1(agent, findings, project) {
|
|
55935
57939
|
const undo = [];
|
|
55936
57940
|
const kept = /* @__PURE__ */ new Set();
|
|
55937
57941
|
const done = /* @__PURE__ */ new Map();
|
|
@@ -55939,14 +57943,16 @@ function removeV1(agent, findings) {
|
|
|
55939
57943
|
for (const f of findings) {
|
|
55940
57944
|
if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
|
|
55941
57945
|
else if (f.path === "") {
|
|
55942
|
-
if (
|
|
57946
|
+
if (project !== void 0 && reachedThroughLink(project, f.file)) done.set(f, UPGRADE_REPORT_ONLY);
|
|
57947
|
+
else if (existsSync21(f.file) && UPGRADE_KEEP_ASIDE_REASONS.includes(f.reason)) done.set(f, UPGRADE_MOVED_ASIDE + keepAside(f.file, undo));
|
|
57948
|
+
else if (existsSync21(f.file)) {
|
|
55943
57949
|
moveAside(f.file, undo);
|
|
55944
57950
|
done.set(f, UPGRADE_REMOVED);
|
|
55945
57951
|
} else done.set(f, UPGRADE_NOT_FOUND);
|
|
55946
57952
|
} else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
|
|
55947
57953
|
}
|
|
55948
57954
|
for (const [file2, list3] of entries) {
|
|
55949
|
-
if (!
|
|
57955
|
+
if (!existsSync21(file2)) {
|
|
55950
57956
|
for (const f of list3) done.set(f, UPGRADE_NOT_FOUND);
|
|
55951
57957
|
continue;
|
|
55952
57958
|
}
|
|
@@ -55975,64 +57981,18 @@ function removeV1(agent, findings) {
|
|
|
55975
57981
|
return {
|
|
55976
57982
|
rows: findings.map((f) => row3(f, done.get(f) ?? UPGRADE_NOT_FOUND)),
|
|
55977
57983
|
commit() {
|
|
55978
|
-
for (const u of undo.splice(0))
|
|
57984
|
+
for (const u of undo.splice(0)) if (u.keep !== true) rmSync8(u.trash, { recursive: true, force: true });
|
|
55979
57985
|
},
|
|
55980
57986
|
rollback() {
|
|
55981
57987
|
for (const u of undo.splice(0).reverse()) {
|
|
55982
|
-
if (!
|
|
55983
|
-
|
|
57988
|
+
if (!existsSync21(u.trash)) continue;
|
|
57989
|
+
rmSync8(u.target, { recursive: true, force: true });
|
|
55984
57990
|
renameWithRetry(u.trash, u.target);
|
|
55985
57991
|
}
|
|
55986
57992
|
}
|
|
55987
57993
|
};
|
|
55988
57994
|
}
|
|
55989
57995
|
|
|
55990
|
-
// src/core/ops/verify-sums.ts
|
|
55991
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
55992
|
-
import { lstatSync as lstatSync2, readdirSync as readdirSync11, readFileSync as readFileSync15 } from "node:fs";
|
|
55993
|
-
import { join as join23 } from "node:path";
|
|
55994
|
-
function mismatch() {
|
|
55995
|
-
return new CtxError("BUNDLE_HASH_MISMATCH");
|
|
55996
|
-
}
|
|
55997
|
-
function parseSums(text) {
|
|
55998
|
-
const lines = text.split(SUMS_LINE_END);
|
|
55999
|
-
if (lines[lines.length - 1] === "") lines.pop();
|
|
56000
|
-
const sums = /* @__PURE__ */ new Map();
|
|
56001
|
-
for (const line of lines) {
|
|
56002
|
-
const at = line.indexOf(SUMS_LINE_SEP);
|
|
56003
|
-
if (at < 0) throw mismatch();
|
|
56004
|
-
const rel = line.slice(at + SUMS_LINE_SEP.length);
|
|
56005
|
-
if (rel === "" || sums.has(rel)) throw mismatch();
|
|
56006
|
-
sums.set(rel, line.slice(0, at));
|
|
56007
|
-
}
|
|
56008
|
-
return sums;
|
|
56009
|
-
}
|
|
56010
|
-
function walk2(dir, prefix, out) {
|
|
56011
|
-
for (const entry of readdirSync11(dir, { withFileTypes: true })) {
|
|
56012
|
-
const rel = prefix === "" ? entry.name : prefix + "/" + entry.name;
|
|
56013
|
-
if (prefix === "" && (entry.name === GIT_DIR_NAME || entry.name === RELEASE_SUMS_FILE)) continue;
|
|
56014
|
-
const abs = join23(dir, entry.name);
|
|
56015
|
-
if (entry.isDirectory()) walk2(abs, rel, out);
|
|
56016
|
-
else if (entry.isFile()) out.set(rel, abs);
|
|
56017
|
-
else throw mismatch();
|
|
56018
|
-
}
|
|
56019
|
-
}
|
|
56020
|
-
function verifySums(dir) {
|
|
56021
|
-
const sumsPath = join23(dir, RELEASE_SUMS_FILE);
|
|
56022
|
-
const sumsStat = lstatSync2(sumsPath, { throwIfNoEntry: false });
|
|
56023
|
-
if (sumsStat === void 0 || !sumsStat.isFile()) throw mismatch();
|
|
56024
|
-
const sums = parseSums(readFileSync15(sumsPath, "utf8"));
|
|
56025
|
-
const files = /* @__PURE__ */ new Map();
|
|
56026
|
-
walk2(dir, "", files);
|
|
56027
|
-
if (files.size !== sums.size) throw mismatch();
|
|
56028
|
-
for (const [rel, abs] of files) {
|
|
56029
|
-
const want = sums.get(rel);
|
|
56030
|
-
if (want === void 0) throw mismatch();
|
|
56031
|
-
const got = createHash2(SUMS_HASH_ALGORITHM).update(readFileSync15(abs)).digest(HASH_ENCODING);
|
|
56032
|
-
if (got !== want) throw mismatch();
|
|
56033
|
-
}
|
|
56034
|
-
}
|
|
56035
|
-
|
|
56036
57996
|
// src/core/tools/upgrade.ts
|
|
56037
57997
|
var ctxUpgradeSchema = external_exports.object({
|
|
56038
57998
|
mode: external_exports.enum(UPGRADE_MODES).optional(),
|
|
@@ -56055,41 +58015,20 @@ function pluginRootRow(adapter, env) {
|
|
|
56055
58015
|
}
|
|
56056
58016
|
return root === own4 ? [] : [row4(UPGRADE_PLUGIN_ROOT_AREA, root, own4)];
|
|
56057
58017
|
}
|
|
56058
|
-
function isCurrent(agentDir, dir) {
|
|
56059
|
-
const link = join24(agentDir, PLUGIN_CURRENT_LINK);
|
|
56060
|
-
return existsSync24(link) && realpathSync11.native(link) === realpathSync11.native(dir);
|
|
56061
|
-
}
|
|
56062
|
-
async function checkout(adapter, deps) {
|
|
56063
|
-
const fetched = await fetchRelease(adapter.id, deps.releaseUrl, deps.env, deps.signal);
|
|
56064
|
-
const agentDir = dirname12(fetched.dir);
|
|
56065
|
-
try {
|
|
56066
|
-
verifySums(fetched.dir);
|
|
56067
|
-
} catch (err) {
|
|
56068
|
-
if (!isCurrent(agentDir, fetched.dir)) rmSync11(fetched.dir, { recursive: true, force: true });
|
|
56069
|
-
throw err;
|
|
56070
|
-
}
|
|
56071
|
-
const swap = swapPluginCurrent(agentDir, fetched.sha);
|
|
56072
|
-
const rows = [row4(UPGRADE_CHECKOUT_AREA, swap.previous ?? "", swap.current)];
|
|
56073
|
-
for (const dir of swap.removed) rows.push(row4(UPGRADE_CACHE_AREA, dir, UPGRADE_REMOVED));
|
|
56074
|
-
return { rows, agentDir, swap };
|
|
56075
|
-
}
|
|
56076
58018
|
function hostRow(adapter) {
|
|
56077
|
-
return row4(UPGRADE_HOST_AREA, "", UPGRADE_HOST_COMMAND[adapter.id]
|
|
58019
|
+
return row4(UPGRADE_HOST_AREA, "", UPGRADE_HOST_COMMAND[adapter.id]);
|
|
56078
58020
|
}
|
|
56079
|
-
|
|
56080
|
-
let done = null;
|
|
58021
|
+
function upgrade(adapter, deps, home) {
|
|
56081
58022
|
let removal = null;
|
|
56082
58023
|
try {
|
|
56083
|
-
const step4 = UPGRADE_GIT_CHECKOUT_AGENTS.includes(adapter.id) ? (done = await checkout(adapter, deps)).rows : [hostRow(adapter)];
|
|
56084
58024
|
const step5 = regenerateHostConfig(adapter, home, { env: deps.env, write: deps.write });
|
|
56085
|
-
const findings = detectV1(adapter.id, home, { project: deps.project.worktree, piAgentDir: piAgentDirOf(deps.env, home), claudeDir: claudeDirOf(deps.env, home), copilotDir: copilotDirOf(deps.env, home), kiroDir: kiroDirOf(deps.env, home), opencodeDir: opencodeDirOf(deps.env, home) });
|
|
56086
|
-
removal = removeV1(adapter.id, findings);
|
|
56087
|
-
const rows = [
|
|
58025
|
+
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) });
|
|
58026
|
+
removal = removeV1(adapter.id, findings, deps.project.worktree);
|
|
58027
|
+
const rows = [hostRow(adapter), ...step5, ...removal.rows];
|
|
56088
58028
|
removal.commit();
|
|
56089
58029
|
return rows;
|
|
56090
58030
|
} catch (err) {
|
|
56091
58031
|
removal?.rollback();
|
|
56092
|
-
if (done !== null && done.swap.previous !== null) swapPluginCurrent(done.agentDir, basename7(done.swap.previous));
|
|
56093
58032
|
throw err;
|
|
56094
58033
|
}
|
|
56095
58034
|
}
|
|
@@ -56109,12 +58048,12 @@ async function runUpgrade(input, deps) {
|
|
|
56109
58048
|
const result = runUninstall({ adapter, project: deps.project, env: deps.env, confirmDelete: input.confirmDelete === true });
|
|
56110
58049
|
rows.push(...result.rows);
|
|
56111
58050
|
} else {
|
|
56112
|
-
rows.push(...
|
|
58051
|
+
rows.push(...upgrade(adapter, deps, home));
|
|
56113
58052
|
}
|
|
56114
58053
|
return { text: renderTable(rows) + "\n\n" + UPGRADE_RESTART_LINE, isError: false, sandboxBytes: 0 };
|
|
56115
58054
|
}
|
|
56116
58055
|
async function handler8(input, ctx) {
|
|
56117
|
-
return runUpgrade(input, { project: ctx.project, env: process.env, signal: ctx.signal
|
|
58056
|
+
return runUpgrade(input, { project: ctx.project, env: process.env, signal: ctx.signal });
|
|
56118
58057
|
}
|
|
56119
58058
|
var ctxUpgrade = Object.freeze({
|
|
56120
58059
|
name: "ctx_upgrade",
|
|
@@ -56176,12 +58115,12 @@ function checkCall(tool, input) {
|
|
|
56176
58115
|
}
|
|
56177
58116
|
|
|
56178
58117
|
// src/entries/is-entry.ts
|
|
56179
|
-
import { realpathSync as
|
|
58118
|
+
import { realpathSync as realpathSync11 } from "node:fs";
|
|
56180
58119
|
function isEntry(main, argv1, self) {
|
|
56181
58120
|
if (main !== void 0) return main;
|
|
56182
58121
|
if (argv1 === void 0 || argv1 === "") return false;
|
|
56183
58122
|
try {
|
|
56184
|
-
return
|
|
58123
|
+
return realpathSync11(argv1) === realpathSync11(self);
|
|
56185
58124
|
} catch {
|
|
56186
58125
|
return false;
|
|
56187
58126
|
}
|
|
@@ -56257,16 +58196,33 @@ function workspaceFromMeta(meta3) {
|
|
|
56257
58196
|
}
|
|
56258
58197
|
function realOrSame(p) {
|
|
56259
58198
|
try {
|
|
56260
|
-
return
|
|
58199
|
+
return realpathSync12.native(p);
|
|
56261
58200
|
} catch {
|
|
56262
58201
|
return p;
|
|
56263
58202
|
}
|
|
56264
58203
|
}
|
|
58204
|
+
function hasWorkspaceFolder(argv) {
|
|
58205
|
+
const i = argv.indexOf(WORKSPACE_FOLDER_FLAG);
|
|
58206
|
+
const v = i < 0 ? void 0 : argv[i + 1];
|
|
58207
|
+
return v !== void 0 && v !== "" && v !== VSCODE_WORKSPACE_VAR;
|
|
58208
|
+
}
|
|
58209
|
+
async function workspaceFromRoots(server) {
|
|
58210
|
+
if (server.server.getClientCapabilities()?.roots === void 0) return void 0;
|
|
58211
|
+
try {
|
|
58212
|
+
const { roots } = await server.server.listRoots(void 0, { timeout: ROOTS_TIMEOUT_MS });
|
|
58213
|
+
for (const root of roots) {
|
|
58214
|
+
if (root.uri.startsWith(FILE_URL_PREFIX)) return fileURLToPath3(root.uri);
|
|
58215
|
+
}
|
|
58216
|
+
} catch (err) {
|
|
58217
|
+
console.error("context-mode: roots/list: " + (err instanceof Error ? err.message : String(err)));
|
|
58218
|
+
}
|
|
58219
|
+
return void 0;
|
|
58220
|
+
}
|
|
56265
58221
|
function workspaceCwdOf(meta3, spawnCwd, script) {
|
|
56266
58222
|
const fromHost = workspaceFromMeta(meta3);
|
|
56267
58223
|
if (fromHost !== void 0) return fromHost;
|
|
56268
58224
|
if (script === void 0 || script === "") return spawnCwd;
|
|
56269
|
-
return realOrSame(spawnCwd) === realOrSame(
|
|
58225
|
+
return realOrSame(spawnCwd) === realOrSame(dirname12(script)) ? "" : spawnCwd;
|
|
56270
58226
|
}
|
|
56271
58227
|
function errorReply(err) {
|
|
56272
58228
|
if (err instanceof CtxError) return { text: err.toLine(), isError: true, sandboxBytes: 0 };
|
|
@@ -56305,15 +58261,15 @@ async function startServer(argv, env) {
|
|
|
56305
58261
|
opening.catch(() => pending.delete(project.dbPath));
|
|
56306
58262
|
}
|
|
56307
58263
|
const db = await opening;
|
|
56308
|
-
if (!
|
|
58264
|
+
if (!existsSync22(db.path)) throw new CtxError("DB_GONE");
|
|
56309
58265
|
return db;
|
|
56310
58266
|
}
|
|
56311
58267
|
function stopMarker(configDir, projectKey) {
|
|
56312
|
-
return
|
|
58268
|
+
return join22(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
|
|
56313
58269
|
}
|
|
56314
58270
|
function stopRequested() {
|
|
56315
58271
|
const configDir = resolveConfigDir(process.env);
|
|
56316
|
-
return held.some((db) =>
|
|
58272
|
+
return held.some((db) => existsSync22(stopMarker(configDir, db.projectKey)));
|
|
56317
58273
|
}
|
|
56318
58274
|
async function journal(project, ctx, name, reply4) {
|
|
56319
58275
|
const db = await ownDb(project);
|
|
@@ -56323,10 +58279,12 @@ async function startServer(argv, env) {
|
|
|
56323
58279
|
return async (input, req) => {
|
|
56324
58280
|
const meta3 = req.mcpReq._meta;
|
|
56325
58281
|
const agent = resolveAgent(argv, env);
|
|
58282
|
+
const fromRoots = agent === "vscode" && !hasWorkspaceFolder(argv) ? await workspaceFromRoots(server) : void 0;
|
|
58283
|
+
const callArgv = fromRoots === void 0 ? argv : [...argv, WORKSPACE_FOLDER_FLAG, fromRoots];
|
|
56326
58284
|
let project;
|
|
56327
58285
|
const projectOf = () => {
|
|
56328
58286
|
if (agent === void 0) throw new CtxError("NO_PROJECT", { kind: "--agent" });
|
|
56329
|
-
project ??= resolveProject(agent, { env, argv, cwd: workspaceCwdOf(meta3, process.cwd(), process.argv[1]), piCwd: void 0 });
|
|
58287
|
+
project ??= resolveProject(agent, { env, argv: callArgv, cwd: workspaceCwdOf(meta3, process.cwd(), process.argv[1]), piCwd: void 0 });
|
|
56330
58288
|
return project;
|
|
56331
58289
|
};
|
|
56332
58290
|
const ctx = {
|
|
@@ -56406,7 +58364,7 @@ async function startServer(argv, env) {
|
|
|
56406
58364
|
try {
|
|
56407
58365
|
const configDir = resolveConfigDir(process.env);
|
|
56408
58366
|
removeOwnerPid(configDir, db.projectKey, serverId);
|
|
56409
|
-
|
|
58367
|
+
rmSync9(stopMarker(configDir, db.projectKey), { force: true });
|
|
56410
58368
|
} catch (err) {
|
|
56411
58369
|
console.error(err);
|
|
56412
58370
|
}
|
|
@@ -56420,7 +58378,7 @@ async function startServer(argv, env) {
|
|
|
56420
58378
|
}
|
|
56421
58379
|
installExitGuard({ onShutdown: shutdown, isTTY: process.stdin.isTTY === true });
|
|
56422
58380
|
handle = serveStdio(createServer);
|
|
56423
|
-
await new Promise((
|
|
58381
|
+
await new Promise((resolve7) => process.once("exit", () => resolve7()));
|
|
56424
58382
|
}
|
|
56425
58383
|
if (isEntry(import.meta.main, process.argv[1], fileURLToPath3(import.meta.url))) {
|
|
56426
58384
|
const [, , ...cliArgs] = process.argv;
|