context-mode 2.0.2 → 2.1.1
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 +6 -2
- package/.claude-plugin/plugin.json +5 -2
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +87 -91
- package/SHA256SUMS +18 -21
- package/cli.mjs +244 -118
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +87 -84
- package/opencode/plugin.js +316 -214
- package/package.json +1 -2
- package/pi/index.js +364 -262
- package/qwen-extension.json +1 -1
- package/run.mjs +66 -21
- package/search.mjs +66 -21
- package/server.mjs +349 -247
- package/skills/ctx-doctor/SKILL.md +1 -1
- package/skills/ctx-stats/SKILL.md +1 -1
- package/skills/ctx-upgrade/SKILL.md +1 -1
- package/claude-code/skills/ctx-doctor/SKILL.md +0 -6
- package/claude-code/skills/ctx-stats/SKILL.md +0 -6
- package/claude-code/skills/ctx-upgrade/SKILL.md +0 -6
package/server.mjs
CHANGED
|
@@ -7,9 +7,9 @@ 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
|
|
12
|
-
import { fileURLToPath as
|
|
10
|
+
import { existsSync as existsSync24, realpathSync as realpathSync12, rmSync as rmSync12 } from "node:fs";
|
|
11
|
+
import { dirname as dirname13, join as join25 } from "node:path";
|
|
12
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
13
13
|
|
|
14
14
|
// node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
|
|
15
15
|
var __create = Object.create;
|
|
@@ -2386,8 +2386,8 @@ function handleArrayResult(result, final, index) {
|
|
|
2386
2386
|
}
|
|
2387
2387
|
var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
2388
2388
|
$ZodType.init(inst, def);
|
|
2389
|
-
const
|
|
2390
|
-
|
|
2389
|
+
const memo5 = globalConfig.memoizer;
|
|
2390
|
+
memo5?.attach(inst);
|
|
2391
2391
|
inst._zod.parse = (payload, ctx) => {
|
|
2392
2392
|
const input = payload.value;
|
|
2393
2393
|
if (!Array.isArray(input)) {
|
|
@@ -2399,7 +2399,7 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
2399
2399
|
});
|
|
2400
2400
|
return payload;
|
|
2401
2401
|
}
|
|
2402
|
-
payload.value =
|
|
2402
|
+
payload.value = memo5 ? memo5.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
2403
2403
|
const proms = [];
|
|
2404
2404
|
const abortEarly = ctx?.abortEarly;
|
|
2405
2405
|
for (let i = 0; i < input.length; i++) {
|
|
@@ -2559,8 +2559,8 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
2559
2559
|
const isObject6 = isObject;
|
|
2560
2560
|
const catchall = def.catchall;
|
|
2561
2561
|
let value;
|
|
2562
|
-
const
|
|
2563
|
-
|
|
2562
|
+
const memo5 = globalConfig.memoizer;
|
|
2563
|
+
memo5?.attach(inst);
|
|
2564
2564
|
inst._zod.parse = (payload, ctx) => {
|
|
2565
2565
|
value ?? (value = _normalized.value);
|
|
2566
2566
|
const input = payload.value;
|
|
@@ -2573,7 +2573,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
2573
2573
|
});
|
|
2574
2574
|
return payload;
|
|
2575
2575
|
}
|
|
2576
|
-
payload.value =
|
|
2576
|
+
payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
|
|
2577
2577
|
const proms = [];
|
|
2578
2578
|
const shape = value.shape;
|
|
2579
2579
|
const abortEarly = ctx?.abortEarly;
|
|
@@ -2606,11 +2606,11 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
2606
2606
|
$ZodObject.init(inst, def);
|
|
2607
2607
|
const superParse = inst._zod.parse;
|
|
2608
2608
|
const _normalized = cached(() => normalizeDef(def));
|
|
2609
|
-
const
|
|
2609
|
+
const memo5 = globalConfig.memoizer;
|
|
2610
2610
|
const generateFastpass = (shape) => {
|
|
2611
2611
|
const normalized = _normalized.value;
|
|
2612
2612
|
const syms = normalized.symbolKeys;
|
|
2613
|
-
const doc = new Doc(["payload", "ctx"], { shape, inst, memo:
|
|
2613
|
+
const doc = new Doc(["payload", "ctx"], { shape, inst, memo: memo5, syms });
|
|
2614
2614
|
const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
2615
2615
|
const prefixStr = (id, k) => `
|
|
2616
2616
|
let ${id}_ab = false;
|
|
@@ -2630,7 +2630,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
2630
2630
|
for (const key of normalized.allKeys) {
|
|
2631
2631
|
ids[key] = `key_${counter++}`;
|
|
2632
2632
|
}
|
|
2633
|
-
doc.write(
|
|
2633
|
+
doc.write(memo5 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
|
|
2634
2634
|
for (const key of normalized.allKeys) {
|
|
2635
2635
|
if (key === "__proto__")
|
|
2636
2636
|
continue;
|
|
@@ -2993,8 +2993,8 @@ function handleIntersectionResults(result, left, right2) {
|
|
|
2993
2993
|
}
|
|
2994
2994
|
var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
2995
2995
|
$ZodType.init(inst, def);
|
|
2996
|
-
const
|
|
2997
|
-
|
|
2996
|
+
const memo5 = globalConfig.memoizer;
|
|
2997
|
+
memo5?.attach(inst);
|
|
2998
2998
|
inst._zod.parse = (payload, ctx) => {
|
|
2999
2999
|
const input = payload.value;
|
|
3000
3000
|
if (!isPlainObject(input)) {
|
|
@@ -3009,7 +3009,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
3009
3009
|
const proms = [];
|
|
3010
3010
|
const values = def.keyType._zod.values;
|
|
3011
3011
|
if (values && !def.partial) {
|
|
3012
|
-
payload.value =
|
|
3012
|
+
payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
|
|
3013
3013
|
const recordKeys = /* @__PURE__ */ new Set();
|
|
3014
3014
|
for (const key of values) {
|
|
3015
3015
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
@@ -3073,7 +3073,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
3073
3073
|
});
|
|
3074
3074
|
}
|
|
3075
3075
|
} else {
|
|
3076
|
-
payload.value =
|
|
3076
|
+
payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
|
|
3077
3077
|
let unrecognized;
|
|
3078
3078
|
for (const key of Reflect.ownKeys(input)) {
|
|
3079
3079
|
if (key === "__proto__")
|
|
@@ -9915,8 +9915,8 @@ function handleArrayResult2(result, final, index) {
|
|
|
9915
9915
|
}
|
|
9916
9916
|
var $ZodArray2 = /* @__PURE__ */ $constructor2("$ZodArray", (inst, def) => {
|
|
9917
9917
|
$ZodType2.init(inst, def);
|
|
9918
|
-
const
|
|
9919
|
-
|
|
9918
|
+
const memo5 = globalConfig2.memoizer;
|
|
9919
|
+
memo5?.attach(inst);
|
|
9920
9920
|
inst._zod.parse = (payload, ctx) => {
|
|
9921
9921
|
const input = payload.value;
|
|
9922
9922
|
if (!Array.isArray(input)) {
|
|
@@ -9928,7 +9928,7 @@ var $ZodArray2 = /* @__PURE__ */ $constructor2("$ZodArray", (inst, def) => {
|
|
|
9928
9928
|
});
|
|
9929
9929
|
return payload;
|
|
9930
9930
|
}
|
|
9931
|
-
payload.value =
|
|
9931
|
+
payload.value = memo5 ? memo5.alloc(inst, payload, Array(input.length), ctx) : Array(input.length);
|
|
9932
9932
|
const proms = [];
|
|
9933
9933
|
const abortEarly = ctx?.abortEarly;
|
|
9934
9934
|
for (let i = 0; i < input.length; i++) {
|
|
@@ -10088,8 +10088,8 @@ var $ZodObject2 = /* @__PURE__ */ $constructor2("$ZodObject", (inst, def) => {
|
|
|
10088
10088
|
const isObject6 = isObject2;
|
|
10089
10089
|
const catchall = def.catchall;
|
|
10090
10090
|
let value;
|
|
10091
|
-
const
|
|
10092
|
-
|
|
10091
|
+
const memo5 = globalConfig2.memoizer;
|
|
10092
|
+
memo5?.attach(inst);
|
|
10093
10093
|
inst._zod.parse = (payload, ctx) => {
|
|
10094
10094
|
value ?? (value = _normalized.value);
|
|
10095
10095
|
const input = payload.value;
|
|
@@ -10102,7 +10102,7 @@ var $ZodObject2 = /* @__PURE__ */ $constructor2("$ZodObject", (inst, def) => {
|
|
|
10102
10102
|
});
|
|
10103
10103
|
return payload;
|
|
10104
10104
|
}
|
|
10105
|
-
payload.value =
|
|
10105
|
+
payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
|
|
10106
10106
|
const proms = [];
|
|
10107
10107
|
const shape = value.shape;
|
|
10108
10108
|
const abortEarly = ctx?.abortEarly;
|
|
@@ -10135,11 +10135,11 @@ var $ZodObjectJIT2 = /* @__PURE__ */ $constructor2("$ZodObjectJIT", (inst, def)
|
|
|
10135
10135
|
$ZodObject2.init(inst, def);
|
|
10136
10136
|
const superParse = inst._zod.parse;
|
|
10137
10137
|
const _normalized = cached2(() => normalizeDef2(def));
|
|
10138
|
-
const
|
|
10138
|
+
const memo5 = globalConfig2.memoizer;
|
|
10139
10139
|
const generateFastpass = (shape) => {
|
|
10140
10140
|
const normalized = _normalized.value;
|
|
10141
10141
|
const syms = normalized.symbolKeys;
|
|
10142
|
-
const doc = new Doc2(["payload", "ctx"], { shape, inst, memo:
|
|
10142
|
+
const doc = new Doc2(["payload", "ctx"], { shape, inst, memo: memo5, syms });
|
|
10143
10143
|
const parseStr = (k) => `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
|
|
10144
10144
|
const prefixStr = (id, k) => `
|
|
10145
10145
|
let ${id}_ab = false;
|
|
@@ -10159,7 +10159,7 @@ var $ZodObjectJIT2 = /* @__PURE__ */ $constructor2("$ZodObjectJIT", (inst, def)
|
|
|
10159
10159
|
for (const key of normalized.allKeys) {
|
|
10160
10160
|
ids[key] = `key_${counter++}`;
|
|
10161
10161
|
}
|
|
10162
|
-
doc.write(
|
|
10162
|
+
doc.write(memo5 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
|
|
10163
10163
|
for (const key of normalized.allKeys) {
|
|
10164
10164
|
if (key === "__proto__")
|
|
10165
10165
|
continue;
|
|
@@ -10522,8 +10522,8 @@ function handleIntersectionResults2(result, left, right2) {
|
|
|
10522
10522
|
}
|
|
10523
10523
|
var $ZodRecord2 = /* @__PURE__ */ $constructor2("$ZodRecord", (inst, def) => {
|
|
10524
10524
|
$ZodType2.init(inst, def);
|
|
10525
|
-
const
|
|
10526
|
-
|
|
10525
|
+
const memo5 = globalConfig2.memoizer;
|
|
10526
|
+
memo5?.attach(inst);
|
|
10527
10527
|
inst._zod.parse = (payload, ctx) => {
|
|
10528
10528
|
const input = payload.value;
|
|
10529
10529
|
if (!isPlainObject2(input)) {
|
|
@@ -10538,7 +10538,7 @@ var $ZodRecord2 = /* @__PURE__ */ $constructor2("$ZodRecord", (inst, def) => {
|
|
|
10538
10538
|
const proms = [];
|
|
10539
10539
|
const values = def.keyType._zod.values;
|
|
10540
10540
|
if (values && !def.partial) {
|
|
10541
|
-
payload.value =
|
|
10541
|
+
payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
|
|
10542
10542
|
const recordKeys = /* @__PURE__ */ new Set();
|
|
10543
10543
|
for (const key of values) {
|
|
10544
10544
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
@@ -10602,7 +10602,7 @@ var $ZodRecord2 = /* @__PURE__ */ $constructor2("$ZodRecord", (inst, def) => {
|
|
|
10602
10602
|
});
|
|
10603
10603
|
}
|
|
10604
10604
|
} else {
|
|
10605
|
-
payload.value =
|
|
10605
|
+
payload.value = memo5 ? memo5.alloc(inst, payload, {}, ctx) : {};
|
|
10606
10606
|
let unrecognized;
|
|
10607
10607
|
for (const key of Reflect.ownKeys(input)) {
|
|
10608
10608
|
if (key === "__proto__")
|
|
@@ -28407,7 +28407,7 @@ var DECISION_SOURCE = "decision";
|
|
|
28407
28407
|
var DECISION_USER_LABEL = "decision (user)";
|
|
28408
28408
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
28409
28409
|
var RELEASE_BRANCH = "release";
|
|
28410
|
-
var BUNDLE_SHA = true ? "
|
|
28410
|
+
var BUNDLE_SHA = true ? "2652fe27fc5d4e368fdc38eda49d3011d38e631e" : void 0;
|
|
28411
28411
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
28412
28412
|
var DOCTOR_LABEL = Object.freeze({
|
|
28413
28413
|
D1: "version",
|
|
@@ -28701,8 +28701,8 @@ var UPGRADE_DATA_DELETED = "user data deleted";
|
|
|
28701
28701
|
var UPGRADE_HOST_COMMAND = Object.freeze({
|
|
28702
28702
|
"claude-code": "claude plugin marketplace update context-mode && claude plugin update context-mode@context-mode",
|
|
28703
28703
|
codex: "rewrite config.toml's [mcp_servers.context-mode*] block to the v2 entry, then restart Codex",
|
|
28704
|
-
gemini: "gemini extensions install https://github.com/mksglu/context-mode --
|
|
28705
|
-
qwen: "qwen extensions install https://github.com/mksglu/context-mode --
|
|
28704
|
+
gemini: "gemini extensions install https://github.com/mksglu/context-mode --auto-update",
|
|
28705
|
+
qwen: "qwen extensions install https://github.com/mksglu/context-mode --auto-update"
|
|
28706
28706
|
});
|
|
28707
28707
|
var PI_GIT_PACKAGE = "git:github.com/mksglu/context-mode@release";
|
|
28708
28708
|
var OPENCODE_GIT_SPEC = "git+https://github.com/mksglu/context-mode.git#release";
|
|
@@ -28766,6 +28766,9 @@ var HOOKS_KEY = "hooks";
|
|
|
28766
28766
|
var STATUS_LINE_KEY = "statusLine";
|
|
28767
28767
|
var PI_PACKAGES_KEY = "packages";
|
|
28768
28768
|
var OPENCODE_PLUGIN_KEY = "plugin";
|
|
28769
|
+
var OPENCODE_PLUGINS_KEY = "plugins";
|
|
28770
|
+
var OPENCODE_PACKAGE_FIELD = "package";
|
|
28771
|
+
var OPENCODE_NPM_SPEC_PREFIX = `${SERVER_KEY}@`;
|
|
28769
28772
|
var V1_DATA_DIR_NAME = "context-mode";
|
|
28770
28773
|
var V1_DATA_ROOT_ENTRIES = Object.freeze(["content", "platform.json"]);
|
|
28771
28774
|
var V1_SESSIONS_DIR_NAME = "sessions";
|
|
@@ -28863,6 +28866,7 @@ var DOCTOR_REPORT_FILE_PREFIX = "doctor-";
|
|
|
28863
28866
|
var DOCTOR_REPORT_LINE = "Report file: ";
|
|
28864
28867
|
var DOCTOR_GH_LINE = "File it: ";
|
|
28865
28868
|
var DOCTOR_URL_LINE = "Or open: ";
|
|
28869
|
+
var DOCTOR_RULES_LINE = "Rules: ";
|
|
28866
28870
|
var DOCTOR_GH_NEXT = " --";
|
|
28867
28871
|
var DOCTOR_NOTE_PREFIXES = Object.freeze([
|
|
28868
28872
|
DOCTOR_ENV_PREFIX,
|
|
@@ -28870,10 +28874,23 @@ var DOCTOR_NOTE_PREFIXES = Object.freeze([
|
|
|
28870
28874
|
DOCTOR_REPORT_LINE,
|
|
28871
28875
|
DOCTOR_GH_LINE,
|
|
28872
28876
|
DOCTOR_GH_NEXT.trim(),
|
|
28873
|
-
DOCTOR_URL_LINE
|
|
28877
|
+
DOCTOR_URL_LINE,
|
|
28878
|
+
DOCTOR_RULES_LINE
|
|
28874
28879
|
]);
|
|
28875
28880
|
var ISSUE_REPO_SLUG = "mksglu/context-mode";
|
|
28876
28881
|
var ISSUE_FORM_FILE = "agent-report.yml";
|
|
28882
|
+
var ISSUE_GUIDE_URL = `https://github.com/${ISSUE_REPO_SLUG}/blob/main/.github/AGENT_ISSUE.md`;
|
|
28883
|
+
var ISSUE_AGENT_RULES = Object.freeze([
|
|
28884
|
+
'Search for the same problem first: `gh issue list -R mksglu/context-mode --state all --search "<check id or error>"`. When one matches, add your facts there as a comment.',
|
|
28885
|
+
"File one bug per issue.",
|
|
28886
|
+
"Call the `ctx_doctor` tool and paste its full output unchanged in the `ctx-report` field.",
|
|
28887
|
+
"Give the versions: context-mode, the agent, the OS and arch, and Node.",
|
|
28888
|
+
"Write numbered repro steps that start from a fresh project (`mktemp -d`) and the agent's own install command.",
|
|
28889
|
+
"Give the exact command and its exact output in a fenced code block.",
|
|
28890
|
+
"Say what you expected and what happened instead.",
|
|
28891
|
+
"Name the source file and line when you found the cause.",
|
|
28892
|
+
"Replace every secret with `<masked>` and the home folder with `~` before you send."
|
|
28893
|
+
]);
|
|
28877
28894
|
var ISSUE_URL_MAX = 8e3;
|
|
28878
28895
|
var ISSUE_FORM_HEADINGS = Object.freeze([
|
|
28879
28896
|
"Summary",
|
|
@@ -28904,16 +28921,16 @@ var DOCTOR_PATH_TOOLS = Object.freeze(["node", "git", "sh"]);
|
|
|
28904
28921
|
var DOCTOR_SECRET_WORDS = Object.freeze(["token", "secret", "password", "apikey", "api_key", "authorization", "bearer"]);
|
|
28905
28922
|
var DOCTOR_MASK = "<masked>";
|
|
28906
28923
|
var NATIVE_INSTALL = Object.freeze({
|
|
28907
|
-
"claude-code": ["claude plugin marketplace add mksglu/context-mode
|
|
28908
|
-
codex: ["codex plugin marketplace add mksglu/context-mode
|
|
28909
|
-
gemini: ["gemini extensions install https://github.com/mksglu/context-mode
|
|
28910
|
-
qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode
|
|
28911
|
-
opencode: ["opencode plugin add context-mode
|
|
28912
|
-
pi: ["pi install npm:context-mode
|
|
28913
|
-
"copilot-cli": ["npm i -g context-mode
|
|
28914
|
-
vscode: ["npm i -g context-mode
|
|
28915
|
-
kiro: ["npm i -g context-mode
|
|
28916
|
-
zcode: ["npm i -g context-mode
|
|
28924
|
+
"claude-code": ["claude plugin marketplace add mksglu/context-mode", "claude plugin install context-mode@context-mode"],
|
|
28925
|
+
codex: ["codex plugin marketplace add mksglu/context-mode", "codex plugin add context-mode@context-mode"],
|
|
28926
|
+
gemini: ["gemini extensions install https://github.com/mksglu/context-mode"],
|
|
28927
|
+
qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode"],
|
|
28928
|
+
opencode: ["opencode plugin add context-mode"],
|
|
28929
|
+
pi: ["pi install npm:context-mode"],
|
|
28930
|
+
"copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
|
|
28931
|
+
vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
|
|
28932
|
+
kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
|
|
28933
|
+
zcode: ["npm i -g context-mode", "context-mode setup --agents zcode"]
|
|
28917
28934
|
});
|
|
28918
28935
|
var ISSUE_FORM_URL = `https://github.com/${ISSUE_REPO_SLUG}/issues/new?template=${ISSUE_FORM_FILE}`;
|
|
28919
28936
|
var DOCTOR_GIT_VERSION_TIMEOUT_MS = 5e3;
|
|
@@ -29380,14 +29397,29 @@ function copilotDirOf(env, home) {
|
|
|
29380
29397
|
function kiroDirOf(env, home, platform = process.platform) {
|
|
29381
29398
|
const p = platform === "win32" ? win32 : posix;
|
|
29382
29399
|
const fallback = p.join(home, ...AGENT_HOME_DIR.kiro);
|
|
29383
|
-
const dir = env[KIRO_HOME_ENV];
|
|
29400
|
+
const dir = env[KIRO_HOME_ENV]?.trim();
|
|
29384
29401
|
if (dir === void 0 || dir === "" || !p.isAbsolute(dir)) return fallback;
|
|
29385
29402
|
if (platform === "win32" && p.parse(dir).root.length < 2) return fallback;
|
|
29386
29403
|
const abs = p.resolve(dir);
|
|
29387
|
-
|
|
29388
|
-
const
|
|
29404
|
+
const real2 = platform === process.platform ? realOrSelf : (x) => x;
|
|
29405
|
+
const target = real2(abs);
|
|
29406
|
+
if (p.parse(target).root === target) return fallback;
|
|
29407
|
+
const up = p.relative(target, real2(p.resolve(home)));
|
|
29389
29408
|
if (!p.isAbsolute(up) && up.split(p.sep)[0] !== "..") return fallback;
|
|
29390
|
-
return
|
|
29409
|
+
return abs;
|
|
29410
|
+
}
|
|
29411
|
+
function realOrSelf(path7) {
|
|
29412
|
+
const tail = [];
|
|
29413
|
+
for (let at = path7; ; ) {
|
|
29414
|
+
try {
|
|
29415
|
+
return join(realpathSync.native(at), ...tail.reverse());
|
|
29416
|
+
} catch {
|
|
29417
|
+
const up = dirname(at);
|
|
29418
|
+
if (up === at) return path7;
|
|
29419
|
+
tail.push(basename(at));
|
|
29420
|
+
at = up;
|
|
29421
|
+
}
|
|
29422
|
+
}
|
|
29391
29423
|
}
|
|
29392
29424
|
function claudeDirOf(env, home) {
|
|
29393
29425
|
const dir = env[CLAUDE_CONFIG_DIR_ENV];
|
|
@@ -43827,7 +43859,7 @@ function cutPoint(src, start, end, scratch) {
|
|
|
43827
43859
|
const r = encoder.encodeInto(src.slice(start, limit), scratch);
|
|
43828
43860
|
return { end: start + r.read, written: r.written };
|
|
43829
43861
|
}
|
|
43830
|
-
function merge4(src, blocks,
|
|
43862
|
+
function merge4(src, blocks, join26, cap, lineCut) {
|
|
43831
43863
|
const out = [];
|
|
43832
43864
|
const scratch = new Uint8Array(cap);
|
|
43833
43865
|
let wide;
|
|
@@ -43837,7 +43869,7 @@ function merge4(src, blocks, join25, cap, lineCut) {
|
|
|
43837
43869
|
out.push({ ord: out.length, text: src.slice(start, end), bytes: bytes5 });
|
|
43838
43870
|
};
|
|
43839
43871
|
for (const b of blocks) {
|
|
43840
|
-
if (cur !== void 0 && !
|
|
43872
|
+
if (cur !== void 0 && !join26) {
|
|
43841
43873
|
emit(cur.start, cur.end, curBytes);
|
|
43842
43874
|
cur = void 0;
|
|
43843
43875
|
}
|
|
@@ -44765,8 +44797,8 @@ var ctxBatch = Object.freeze({
|
|
|
44765
44797
|
});
|
|
44766
44798
|
|
|
44767
44799
|
// src/core/tools/doctor.ts
|
|
44768
|
-
import { readdirSync as readdirSync7, readFileSync as readFileSync10, existsSync as
|
|
44769
|
-
import { basename as basename5,
|
|
44800
|
+
import { readdirSync as readdirSync7, readFileSync as readFileSync10, existsSync as existsSync15 } from "node:fs";
|
|
44801
|
+
import { basename as basename5, join as join15 } from "node:path";
|
|
44770
44802
|
|
|
44771
44803
|
// src/adapters/claude-code.ts
|
|
44772
44804
|
var TOOL_NAME_PREFIX = "mcp__plugin_context-mode_context-mode__";
|
|
@@ -44806,7 +44838,7 @@ function outputOf(resp) {
|
|
|
44806
44838
|
function textSlot(r) {
|
|
44807
44839
|
const file2 = r.file;
|
|
44808
44840
|
if (r.type === "text" && typeof file2 === "object" && file2 !== null && typeof file2.content === "string") {
|
|
44809
|
-
return { text: file2.content, put: (o, output) => ({ ...o, file:
|
|
44841
|
+
return { text: file2.content, put: (o, output) => ({ ...o, file: readFile(o.file, output) }) };
|
|
44810
44842
|
}
|
|
44811
44843
|
if (isGrepContent(r)) return { text: r.content, put: (o, output) => ({ ...o, content: output }) };
|
|
44812
44844
|
if (Array.isArray(r.filenames) && r.filenames.every((f) => typeof f === "string")) {
|
|
@@ -44815,13 +44847,35 @@ function textSlot(r) {
|
|
|
44815
44847
|
if (typeof r.result === "string") return { text: r.result, put: (o, output) => ({ ...o, result: output }) };
|
|
44816
44848
|
return null;
|
|
44817
44849
|
}
|
|
44850
|
+
function readFile(file2, output) {
|
|
44851
|
+
const start = typeof file2.startLine === "number" ? file2.startLine : 1;
|
|
44852
|
+
const lines = String(file2.content).split("\n");
|
|
44853
|
+
const read = typeof file2.numLines === "number" ? file2.numLines : lines.length;
|
|
44854
|
+
const out = output.split("\n");
|
|
44855
|
+
const run = firstRun(lines, out);
|
|
44856
|
+
if (run === null) return { ...file2, content: output, startLine: start + read, numLines: out.length };
|
|
44857
|
+
const kept = out.slice(0, run.length);
|
|
44858
|
+
if (run.length < out.length) kept.push(out[out.length - 1]);
|
|
44859
|
+
return { ...file2, content: kept.join("\n"), startLine: start + run.at, numLines: kept.length };
|
|
44860
|
+
}
|
|
44861
|
+
function firstRun(lines, out) {
|
|
44862
|
+
let best = null;
|
|
44863
|
+
for (let i = 0; i < lines.length; i++) {
|
|
44864
|
+
if (lines[i] !== out[0]) continue;
|
|
44865
|
+
let n = 1;
|
|
44866
|
+
while (n < out.length && i + n < lines.length && lines[i + n] === out[n]) n++;
|
|
44867
|
+
if (best === null || n > best.length) best = { at: i, length: n };
|
|
44868
|
+
if (n === out.length) break;
|
|
44869
|
+
}
|
|
44870
|
+
return best;
|
|
44871
|
+
}
|
|
44818
44872
|
function isShellShape(resp) {
|
|
44819
44873
|
const r = resp;
|
|
44820
44874
|
return typeof r.stdout === "string" || typeof r.stderr === "string";
|
|
44821
44875
|
}
|
|
44822
44876
|
function isGrepContent(resp) {
|
|
44823
44877
|
const r = resp;
|
|
44824
|
-
return r.mode === "content" && typeof r.content === "string";
|
|
44878
|
+
return (r.mode === "content" || r.mode === "count") && typeof r.content === "string";
|
|
44825
44879
|
}
|
|
44826
44880
|
function blocksOf(resp) {
|
|
44827
44881
|
const parts = [];
|
|
@@ -44837,6 +44891,7 @@ function readResult(resp) {
|
|
|
44837
44891
|
const text = outputOf(resp);
|
|
44838
44892
|
const isError = typeof resp === "object" && resp !== null && resp.is_error === true;
|
|
44839
44893
|
const info = { isError, bytes: Buffer.byteLength(text), text };
|
|
44894
|
+
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && isShellShape(resp)) info.shape = resp;
|
|
44840
44895
|
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && !isShellShape(resp)) {
|
|
44841
44896
|
if (textSlot(resp) !== null) info.shape = resp;
|
|
44842
44897
|
else info.keep = true;
|
|
@@ -44876,8 +44931,11 @@ function decodeClaudeShape(raw, agent, ownPrefix, sources) {
|
|
|
44876
44931
|
return ev;
|
|
44877
44932
|
}
|
|
44878
44933
|
function replaceShape(ev, output) {
|
|
44879
|
-
if (ev.tool?.canonicalName === "Bash") return { stdout: output, stderr: "", interrupted: false };
|
|
44880
44934
|
const shape = ev.result?.shape;
|
|
44935
|
+
if (ev.tool?.canonicalName === "Bash") {
|
|
44936
|
+
const { persistedOutputPath: _p, persistedOutputSize: _s, ...host } = shape ?? {};
|
|
44937
|
+
return { interrupted: false, ...host, stdout: output, stderr: "" };
|
|
44938
|
+
}
|
|
44881
44939
|
const slot = shape === void 0 ? null : textSlot(shape);
|
|
44882
44940
|
if (shape !== void 0 && slot !== null) return slot.put(shape, output);
|
|
44883
44941
|
if (ev.result?.blocks === true) return [{ type: "text", text: output }];
|
|
@@ -45272,7 +45330,8 @@ function encode8(ev, d, _extra) {
|
|
|
45272
45330
|
}
|
|
45273
45331
|
|
|
45274
45332
|
// src/adapters/kiro.ts
|
|
45275
|
-
var TOOL_NAME_PREFIX7 = "
|
|
45333
|
+
var TOOL_NAME_PREFIX7 = "mcp_context_mode_";
|
|
45334
|
+
var LEGACY_TOOL_NAME_PREFIX = "mcp_context-mode_";
|
|
45276
45335
|
var KIRO_EVENTS = {
|
|
45277
45336
|
SessionStart: "SessionStart",
|
|
45278
45337
|
agentSpawn: "SessionStart",
|
|
@@ -45284,6 +45343,7 @@ var KIRO_EVENTS = {
|
|
|
45284
45343
|
PostToolUse: "PostToolUse",
|
|
45285
45344
|
postToolUse: "PostToolUse"
|
|
45286
45345
|
};
|
|
45346
|
+
var PROMPT_FIELD = "prompt";
|
|
45287
45347
|
var PROMPT_ENV = "USER_PROMPT";
|
|
45288
45348
|
var MCP_PREFIX3 = "mcp_";
|
|
45289
45349
|
var SHELL_TOOL_NAMES4 = Object.freeze(["execute_bash", "execute_pwsh", "shell"]);
|
|
@@ -45292,6 +45352,7 @@ var MCP_SEP3 = "_";
|
|
|
45292
45352
|
var KIRO_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
|
|
45293
45353
|
function canonicalName5(name) {
|
|
45294
45354
|
if (name.startsWith(TOOL_NAME_PREFIX7)) return name.slice(TOOL_NAME_PREFIX7.length);
|
|
45355
|
+
if (name.startsWith(LEGACY_TOOL_NAME_PREFIX)) return name.slice(LEGACY_TOOL_NAME_PREFIX.length);
|
|
45295
45356
|
if (Object.hasOwn(NATIVE_TO_CANONICAL5, name)) return NATIVE_TO_CANONICAL5[name];
|
|
45296
45357
|
if (!name.startsWith(MCP_PREFIX3)) return name;
|
|
45297
45358
|
const rest = name.slice(MCP_PREFIX3.length);
|
|
@@ -45312,7 +45373,8 @@ function decode9(raw) {
|
|
|
45312
45373
|
const ev = { event, agent: "kiro", sessionId: String(p.session_id ?? ""), cwd: String(p.cwd ?? "") };
|
|
45313
45374
|
if (event === "SessionStart" && typeof p.source === "string" && KIRO_SOURCES[p.source] !== void 0) ev.source = KIRO_SOURCES[p.source];
|
|
45314
45375
|
if (event === "UserPromptSubmit") {
|
|
45315
|
-
const
|
|
45376
|
+
const field = p[PROMPT_FIELD];
|
|
45377
|
+
const prompt = typeof field === "string" ? field : process.env[PROMPT_ENV];
|
|
45316
45378
|
if (prompt !== void 0) ev.prompt = prompt;
|
|
45317
45379
|
}
|
|
45318
45380
|
if (event === "PreToolUse" || event === "PostToolUse") {
|
|
@@ -45324,7 +45386,7 @@ function decode9(raw) {
|
|
|
45324
45386
|
return ev;
|
|
45325
45387
|
}
|
|
45326
45388
|
function encode9(ev, d, _extra) {
|
|
45327
|
-
if (ev.event === "UserPromptSubmit") return { stdout: "", exitCode: 0 };
|
|
45389
|
+
if (ev.event === "UserPromptSubmit") return { stdout: d.kind === "hint" ? d.text : "", exitCode: 0 };
|
|
45328
45390
|
switch (d.kind) {
|
|
45329
45391
|
case "allow":
|
|
45330
45392
|
return { stdout: "", exitCode: 0 };
|
|
@@ -45493,8 +45555,8 @@ var ADAPTERS = Object.freeze([
|
|
|
45493
45555
|
hookTimeoutMs: HOOK_TIMEOUT_MS,
|
|
45494
45556
|
denyChannel: "deny-reason",
|
|
45495
45557
|
hookChannel: { kind: "package", path: "hooks/claude-code.json" },
|
|
45496
|
-
skillChannel: { kind: "package", path: "
|
|
45497
|
-
// ADR-0020, D-
|
|
45558
|
+
skillChannel: { kind: "package", path: "skills" },
|
|
45559
|
+
// ADR-0020, D-R33-CC-SKILLS-1: Claude Code always loads <plugin>/skills, shared with gemini and qwen
|
|
45498
45560
|
decode: decode3,
|
|
45499
45561
|
encode: encode3
|
|
45500
45562
|
},
|
|
@@ -45683,18 +45745,40 @@ function getAdapter(id) {
|
|
|
45683
45745
|
return BY_ID.get(id);
|
|
45684
45746
|
}
|
|
45685
45747
|
|
|
45748
|
+
// src/core/ops/bundle-dir.ts
|
|
45749
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
45750
|
+
import { dirname as dirname4, join as join6 } from "node:path";
|
|
45751
|
+
import { fileURLToPath } from "node:url";
|
|
45752
|
+
function bundleDirOf(argv1, moduleFile) {
|
|
45753
|
+
const own4 = dirname4(argv1);
|
|
45754
|
+
if (existsSync4(join6(own4, SERVER_ENTRY_FILE))) return own4;
|
|
45755
|
+
let dir = dirname4(moduleFile);
|
|
45756
|
+
for (; ; ) {
|
|
45757
|
+
if (existsSync4(join6(dir, SERVER_ENTRY_FILE))) return dir;
|
|
45758
|
+
const up = dirname4(dir);
|
|
45759
|
+
if (up === dir) return own4;
|
|
45760
|
+
dir = up;
|
|
45761
|
+
}
|
|
45762
|
+
}
|
|
45763
|
+
var memo4;
|
|
45764
|
+
function ownBundleDir() {
|
|
45765
|
+
const argv1 = process.argv[1] ?? "";
|
|
45766
|
+
if (memo4?.argv1 !== argv1) memo4 = { argv1, dir: bundleDirOf(argv1, fileURLToPath(import.meta.url)) };
|
|
45767
|
+
return memo4.dir;
|
|
45768
|
+
}
|
|
45769
|
+
|
|
45686
45770
|
// src/core/ops/doctor-config.ts
|
|
45687
|
-
import { existsSync as
|
|
45688
|
-
import { join as
|
|
45771
|
+
import { existsSync as existsSync8, readdirSync as readdirSync6 } from "node:fs";
|
|
45772
|
+
import { join as join10 } from "node:path";
|
|
45689
45773
|
|
|
45690
45774
|
// src/core/ops/detect-v1.ts
|
|
45691
|
-
import { existsSync as
|
|
45775
|
+
import { existsSync as existsSync6, opendirSync, readdirSync as readdirSync4, readFileSync as readFileSync5 } from "node:fs";
|
|
45692
45776
|
import { tmpdir } from "node:os";
|
|
45693
|
-
import { join as
|
|
45777
|
+
import { join as join8 } from "node:path";
|
|
45694
45778
|
|
|
45695
45779
|
// src/core/ops/host-config.ts
|
|
45696
|
-
import { existsSync as
|
|
45697
|
-
import { dirname as
|
|
45780
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
|
|
45781
|
+
import { dirname as dirname5, join as join7 } from "node:path";
|
|
45698
45782
|
|
|
45699
45783
|
// node_modules/eslint-visitor-keys/lib/visitor-keys.js
|
|
45700
45784
|
var KEYS2 = {
|
|
@@ -47834,10 +47918,10 @@ function formatOf(path7) {
|
|
|
47834
47918
|
function readHostConfig(agent, path7) {
|
|
47835
47919
|
let file2 = path7;
|
|
47836
47920
|
if (agent === "opencode") {
|
|
47837
|
-
const jsonc =
|
|
47838
|
-
if (
|
|
47921
|
+
const jsonc = join7(dirname5(path7), OPENCODE_CONFIG_FILES[0]);
|
|
47922
|
+
if (existsSync5(jsonc)) file2 = jsonc;
|
|
47839
47923
|
}
|
|
47840
|
-
const raw =
|
|
47924
|
+
const raw = existsSync5(file2) ? readFileSync4(file2, "utf8") : "";
|
|
47841
47925
|
return { agent, text: hostText(raw), format: agent === "opencode" && !file2.endsWith(TOML_EXT) ? "jsonc" : formatOf(file2), path: file2, layout: hostLayout(raw) };
|
|
47842
47926
|
}
|
|
47843
47927
|
function stripJsonComments(text) {
|
|
@@ -48182,7 +48266,7 @@ function setText(agent, path7, text, format, key, value) {
|
|
|
48182
48266
|
}
|
|
48183
48267
|
}
|
|
48184
48268
|
function serverScript() {
|
|
48185
|
-
return
|
|
48269
|
+
return join7(dirname5(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
|
|
48186
48270
|
}
|
|
48187
48271
|
function isNodeCommand(command) {
|
|
48188
48272
|
if (typeof command !== "string") return false;
|
|
@@ -48198,7 +48282,7 @@ function ownMcpValue(agent, node3, server) {
|
|
|
48198
48282
|
return { ...mcp.fields, [MCP_COMMAND_FIELD]: node3, [MCP_ARGS_FIELD]: [server, AGENT_ARG, agent, ...tail] };
|
|
48199
48283
|
}
|
|
48200
48284
|
function opencodePluginFile() {
|
|
48201
|
-
return
|
|
48285
|
+
return ownBundleDir();
|
|
48202
48286
|
}
|
|
48203
48287
|
function listTarget(key, own4, v1, alt = []) {
|
|
48204
48288
|
return {
|
|
@@ -48357,7 +48441,7 @@ function flatCommands(events, prefix) {
|
|
|
48357
48441
|
var isV1Hook = (cmd) => cmd.includes(SERVER_KEY) && (V1_SCRIPT_NAMES.some((name) => cmd.includes(name)) || cmd.includes(V1_HOOK_COMMAND));
|
|
48358
48442
|
var isCodexScript = (cmd) => cmd.includes(V1_SCRIPT_EXT) && V1_PATH_SEPS.some((sep3) => cmd.includes(V1_CODEX_HOOKS_DIR.join(sep3) + sep3));
|
|
48359
48443
|
function dataDir(dir, reason, out) {
|
|
48360
|
-
if (
|
|
48444
|
+
if (existsSync6(dir)) out.push(finding(dir, "", reason));
|
|
48361
48445
|
}
|
|
48362
48446
|
function mcpEntry(file2, doc, out) {
|
|
48363
48447
|
if (isObj(doc) && isObj(doc[MCP_SERVERS_KEY]) && Object.hasOwn(doc[MCP_SERVERS_KEY], SERVER_KEY)) {
|
|
@@ -48365,7 +48449,7 @@ function mcpEntry(file2, doc, out) {
|
|
|
48365
48449
|
}
|
|
48366
48450
|
}
|
|
48367
48451
|
function claudeShapeSettings(agentHome, out) {
|
|
48368
|
-
const file2 =
|
|
48452
|
+
const file2 = join8(agentHome, SETTINGS_FILE);
|
|
48369
48453
|
const doc = readJson(file2);
|
|
48370
48454
|
for (const c of nestedCommands(doc)) {
|
|
48371
48455
|
if (c.command.includes(V1_CACHE_HEAL_NAME)) out.push(finding(file2, c.path, V1_REASON.cacheHealHook));
|
|
@@ -48385,49 +48469,49 @@ function v1HookFile(file2, out) {
|
|
|
48385
48469
|
function scanClaudeCode(home, agentHome, out) {
|
|
48386
48470
|
claudeShapeSettings(agentHome, out);
|
|
48387
48471
|
for (const ext of V1_CACHE_HEAL_EXTS) {
|
|
48388
|
-
const file2 =
|
|
48389
|
-
if (
|
|
48472
|
+
const file2 = join8(agentHome, V1_HOOKS_DIR_NAME, V1_CACHE_HEAL_NAME + ext);
|
|
48473
|
+
if (existsSync6(file2)) out.push(finding(file2, "", V1_REASON.cacheHealFile));
|
|
48390
48474
|
}
|
|
48391
|
-
const userFile =
|
|
48475
|
+
const userFile = join8(home, CLAUDE_USER_CONFIG_FILE);
|
|
48392
48476
|
mcpEntry(userFile, readJson(userFile), out);
|
|
48393
|
-
dataDir(
|
|
48477
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48394
48478
|
}
|
|
48395
48479
|
function scanCodex(agentHome, out) {
|
|
48396
|
-
const hooksFile =
|
|
48480
|
+
const hooksFile = join8(agentHome, HOOKS_JSON_FILE);
|
|
48397
48481
|
for (const c of nestedCommands(readJson(hooksFile))) {
|
|
48398
48482
|
if (c.command.includes(V1_CODEX_HOOK_COMMAND) || isCodexScript(c.command)) {
|
|
48399
48483
|
out.push(finding(hooksFile, c.path, V1_REASON.codexHook));
|
|
48400
48484
|
}
|
|
48401
48485
|
}
|
|
48402
|
-
const tomlFile =
|
|
48486
|
+
const tomlFile = join8(agentHome, CONFIG_TOML_FILE);
|
|
48403
48487
|
const config4 = readTomlValue(tomlFile);
|
|
48404
48488
|
for (const span2 of readTomlTables(tomlFile)) {
|
|
48405
48489
|
if (span2.path[0] !== V1_TOML_SECTION_ROOT || span2.path[1] !== SERVER_KEY) continue;
|
|
48406
48490
|
if (span2.path.length === 2 && isV2McpTable(hostConfigValueAt(config4, span2.path))) continue;
|
|
48407
48491
|
out.push(finding(tomlFile, span2.header.trim(), V1_REASON.codexToml));
|
|
48408
48492
|
}
|
|
48409
|
-
dataDir(
|
|
48493
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48410
48494
|
}
|
|
48411
48495
|
function scanGemini(agentHome, out) {
|
|
48412
|
-
const file2 =
|
|
48496
|
+
const file2 = join8(agentHome, SETTINGS_FILE);
|
|
48413
48497
|
for (const c of nestedCommands(readJson(file2))) {
|
|
48414
48498
|
if (c.command.includes(SERVER_KEY)) out.push(finding(file2, c.path, V1_REASON.hook));
|
|
48415
48499
|
}
|
|
48416
|
-
dataDir(
|
|
48500
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDirShared, out);
|
|
48417
48501
|
}
|
|
48418
48502
|
function scanVscode(agentHome, project, out) {
|
|
48419
48503
|
if (project !== void 0) {
|
|
48420
|
-
v1HookFile(
|
|
48421
|
-
const mcpFile2 =
|
|
48504
|
+
v1HookFile(join8(project, GITHUB_DIR_NAME, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
|
|
48505
|
+
const mcpFile2 = join8(project, VSCODE_DIR_NAME, VSCODE_MCP_FILE);
|
|
48422
48506
|
const doc = readJson(mcpFile2);
|
|
48423
48507
|
const servers = isObj(doc) && isObj(doc[VSCODE_MCP_SERVERS_KEY]) ? doc[VSCODE_MCP_SERVERS_KEY] : {};
|
|
48424
48508
|
const entry = Object.hasOwn(servers, SERVER_KEY) ? servers[SERVER_KEY] : void 0;
|
|
48425
48509
|
if (isObj(entry) && (entry.command === V1_BIN_COMMAND || listOf(entry.args).some((a) => a === V1_BIN_COMMAND))) {
|
|
48426
48510
|
out.push(finding(mcpFile2, keyPath(VSCODE_MCP_SERVERS_KEY, SERVER_KEY), V1_REASON.vscodeMcp));
|
|
48427
48511
|
}
|
|
48428
|
-
dataDir(
|
|
48512
|
+
dataDir(join8(project, GITHUB_DIR_NAME, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
|
|
48429
48513
|
}
|
|
48430
|
-
dataDir(
|
|
48514
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
|
|
48431
48515
|
}
|
|
48432
48516
|
function jsonFiles(dir) {
|
|
48433
48517
|
try {
|
|
@@ -48437,10 +48521,10 @@ function jsonFiles(dir) {
|
|
|
48437
48521
|
}
|
|
48438
48522
|
}
|
|
48439
48523
|
function scanKiro(agentHome, project, out) {
|
|
48440
|
-
const agentsDir =
|
|
48441
|
-
const defaultFile =
|
|
48524
|
+
const agentsDir = join8(agentHome, KIRO_AGENTS_DIR);
|
|
48525
|
+
const defaultFile = join8(agentHome, ...KIRO_AGENT_FILE);
|
|
48442
48526
|
for (const name of jsonFiles(agentsDir)) {
|
|
48443
|
-
const file2 =
|
|
48527
|
+
const file2 = join8(agentsDir, name);
|
|
48444
48528
|
const doc = readJson(file2);
|
|
48445
48529
|
if (isObj(doc) && doc[KIRO_AGENT_NAME_KEY] === SERVER_KEY) {
|
|
48446
48530
|
out.push(finding(file2, "", V1_REASON.kiroAgentFile));
|
|
@@ -48451,25 +48535,25 @@ function scanKiro(agentHome, project, out) {
|
|
|
48451
48535
|
if (isV1Hook(c.command)) out.push(finding(file2, c.path, V1_REASON.kiroHook));
|
|
48452
48536
|
}
|
|
48453
48537
|
}
|
|
48454
|
-
const steeringDocs = [
|
|
48455
|
-
if (project !== void 0) steeringDocs.push(
|
|
48538
|
+
const steeringDocs = [join8(agentHome, ...KIRO_STEERING_FILE)];
|
|
48539
|
+
if (project !== void 0) steeringDocs.push(join8(project, ...AGENT_HOME_DIR.kiro, ...KIRO_STEERING_FILE));
|
|
48456
48540
|
for (const file2 of steeringDocs) {
|
|
48457
|
-
if (
|
|
48541
|
+
if (existsSync6(file2)) out.push(finding(file2, "", V1_REASON.kiroSteering));
|
|
48458
48542
|
}
|
|
48459
|
-
dataDir(
|
|
48543
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48460
48544
|
}
|
|
48461
48545
|
function scanPi(piAgentDir, agentHome, out) {
|
|
48462
|
-
const file2 =
|
|
48546
|
+
const file2 = join8(piAgentDir, SETTINGS_FILE);
|
|
48463
48547
|
const doc = readJson(file2);
|
|
48464
48548
|
listOf(isObj(doc) ? doc[PI_PACKAGES_KEY] : void 0).forEach((pkg, i) => {
|
|
48465
48549
|
const spec = isObj(pkg) ? pkg[PI_PACKAGE_SOURCE_KEY] : pkg;
|
|
48466
48550
|
if (spec === V1_PI_PACKAGE) out.push(finding(file2, keyPath(PI_PACKAGES_KEY, i), V1_REASON.piNpm));
|
|
48467
48551
|
});
|
|
48468
|
-
dataDir(
|
|
48552
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48469
48553
|
}
|
|
48470
48554
|
function scanOpencode(agentHome, out) {
|
|
48471
48555
|
for (const name of OPENCODE_CONFIG_FILES) {
|
|
48472
|
-
const file2 =
|
|
48556
|
+
const file2 = join8(agentHome, name);
|
|
48473
48557
|
const doc = readJson(file2);
|
|
48474
48558
|
if (!isObj(doc) || !Array.isArray(doc[OPENCODE_PLUGIN_KEY])) continue;
|
|
48475
48559
|
doc[OPENCODE_PLUGIN_KEY].forEach((spec, i) => {
|
|
@@ -48479,13 +48563,13 @@ function scanOpencode(agentHome, out) {
|
|
|
48479
48563
|
}
|
|
48480
48564
|
}
|
|
48481
48565
|
function scanZcode(agentHome, out) {
|
|
48482
|
-
const configFile =
|
|
48566
|
+
const configFile = join8(agentHome, ZCODE_CLI_DIR, CONFIG_JSON_FILE);
|
|
48483
48567
|
const config4 = readJson(configFile);
|
|
48484
48568
|
const events = isObj(config4) && isObj(config4[HOOKS_KEY]) ? config4[HOOKS_KEY][ZCODE_EVENTS_KEY] : void 0;
|
|
48485
48569
|
for (const c of flatCommands(events, [HOOKS_KEY, ZCODE_EVENTS_KEY])) {
|
|
48486
48570
|
if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(configFile, c.path, V1_REASON.zcodeHook));
|
|
48487
48571
|
}
|
|
48488
|
-
const hooksFile =
|
|
48572
|
+
const hooksFile = join8(agentHome, ZCODE_CLI_DIR, HOOKS_JSON_FILE);
|
|
48489
48573
|
for (const c of nestedCommands(readJson(hooksFile))) {
|
|
48490
48574
|
if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(hooksFile, c.path, V1_REASON.zcodeHook));
|
|
48491
48575
|
}
|
|
@@ -48509,14 +48593,14 @@ function firstTmpMatch(dir) {
|
|
|
48509
48593
|
}
|
|
48510
48594
|
}
|
|
48511
48595
|
function scanAll(home, tmp, out) {
|
|
48512
|
-
const root =
|
|
48513
|
-
for (const name of V1_DATA_ROOT_ENTRIES) dataDir(
|
|
48596
|
+
const root = join8(home, DATA_ROOT.slice(1));
|
|
48597
|
+
for (const name of V1_DATA_ROOT_ENTRIES) dataDir(join8(root, name), V1_REASON.dataRoot, out);
|
|
48514
48598
|
if (firstTmpMatch(tmp) !== null) out.push(finding(tmp, V1_TMP_PREFIX + "*", V1_REASON.tmpFile));
|
|
48515
48599
|
}
|
|
48516
48600
|
function detectV1(agent, home, scope = {}) {
|
|
48517
48601
|
const out = [];
|
|
48518
48602
|
const project = scope.project;
|
|
48519
|
-
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 :
|
|
48603
|
+
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 : join8(home, ...AGENT_HOME_DIR[agent]);
|
|
48520
48604
|
switch (agent) {
|
|
48521
48605
|
case "claude-code":
|
|
48522
48606
|
scanClaudeCode(home, agentHome, out);
|
|
@@ -48529,11 +48613,11 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48529
48613
|
break;
|
|
48530
48614
|
case "qwen":
|
|
48531
48615
|
claudeShapeSettings(agentHome, out);
|
|
48532
|
-
dataDir(
|
|
48616
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48533
48617
|
break;
|
|
48534
48618
|
case "copilot-cli":
|
|
48535
|
-
v1HookFile(
|
|
48536
|
-
dataDir(
|
|
48619
|
+
v1HookFile(join8(agentHome, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
|
|
48620
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48537
48621
|
break;
|
|
48538
48622
|
case "vscode":
|
|
48539
48623
|
scanVscode(agentHome, project, out);
|
|
@@ -48542,7 +48626,7 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48542
48626
|
scanKiro(agentHome, project, out);
|
|
48543
48627
|
break;
|
|
48544
48628
|
case "pi":
|
|
48545
|
-
scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir :
|
|
48629
|
+
scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir : join8(agentHome, PI_AGENT_DIR), agentHome, out);
|
|
48546
48630
|
break;
|
|
48547
48631
|
// D-WIN-PIDIR-1: empty is unset
|
|
48548
48632
|
case "opencode":
|
|
@@ -48557,9 +48641,9 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48557
48641
|
}
|
|
48558
48642
|
|
|
48559
48643
|
// src/core/ops/plugin-root.ts
|
|
48560
|
-
import { existsSync as
|
|
48561
|
-
import { dirname as
|
|
48562
|
-
import { fileURLToPath } from "node:url";
|
|
48644
|
+
import { existsSync as existsSync7, readdirSync as readdirSync5, readFileSync as readFileSync6, realpathSync as realpathSync4 } from "node:fs";
|
|
48645
|
+
import { dirname as dirname6, isAbsolute, join as join9, sep as sep2 } from "node:path";
|
|
48646
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
48563
48647
|
function missing(agent, path7) {
|
|
48564
48648
|
return new CtxError("PLUGIN_ROOT_MISSING", { agent, path: path7 });
|
|
48565
48649
|
}
|
|
@@ -48606,8 +48690,8 @@ var readOrNull = (file2) => {
|
|
|
48606
48690
|
};
|
|
48607
48691
|
var samePath = (a, b) => a === b || (realOrNull(a) ?? a) === (realOrNull(b) ?? b);
|
|
48608
48692
|
function enabledPlugins(claudeDir, project) {
|
|
48609
|
-
const files = [
|
|
48610
|
-
if (project !== void 0) files.push(
|
|
48693
|
+
const files = [join9(claudeDir, SETTINGS_FILE)];
|
|
48694
|
+
if (project !== void 0) files.push(join9(project, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), join9(project, HOST_CONFIG_DIR_NAME, SETTINGS_LOCAL_FILE));
|
|
48611
48695
|
const out = {};
|
|
48612
48696
|
for (const file2 of files) {
|
|
48613
48697
|
const text = readOrNull(file2);
|
|
@@ -48620,13 +48704,13 @@ function enabledPlugins(claudeDir, project) {
|
|
|
48620
48704
|
function marketplaceChoice(env, worktree) {
|
|
48621
48705
|
const claudeDir = claudeDirOf(env, requireHomeDir(env));
|
|
48622
48706
|
const script = process.argv[1];
|
|
48623
|
-
const ownReal = script === void 0 || script === "" ? null : realOrNull(
|
|
48707
|
+
const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
|
|
48624
48708
|
const hostRoot = env[CLAUDE_PLUGIN_ROOT_ENV];
|
|
48625
48709
|
if (ownReal !== null && hostRoot !== void 0 && hostRoot !== "" && realOrNull(hostRoot) === ownReal) return { root: ownReal };
|
|
48626
|
-
const record6 = readOrNull(
|
|
48710
|
+
const record6 = readOrNull(join9(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE));
|
|
48627
48711
|
const recorded = record6 === null ? [] : recordedInstalls(record6);
|
|
48628
48712
|
if (recorded.length === 0) return { record: false };
|
|
48629
|
-
const live = recorded.filter((r) =>
|
|
48713
|
+
const live = recorded.filter((r) => existsSync7(r.installPath));
|
|
48630
48714
|
const mine = live.find((r) => realOrNull(r.installPath) === ownReal);
|
|
48631
48715
|
if (mine !== void 0) return { root: mine.installPath };
|
|
48632
48716
|
const dirs = live.filter((r, i) => live.findIndex((o) => samePath(o.installPath, r.installPath)) === i);
|
|
@@ -48646,18 +48730,18 @@ function marketplaceChoice(env, worktree) {
|
|
|
48646
48730
|
}
|
|
48647
48731
|
function marketplaceRoot(adapter, env, worktree) {
|
|
48648
48732
|
const claudeDir = claudeDirOf(env, requireHomeDir(env));
|
|
48649
|
-
const plugins =
|
|
48650
|
-
const cache =
|
|
48733
|
+
const plugins = join9(claudeDir, HOST_PLUGINS_DIR_NAME);
|
|
48734
|
+
const cache = join9(plugins, PLUGIN_CACHE_DIR_NAME);
|
|
48651
48735
|
const script = process.argv[1];
|
|
48652
|
-
const ownReal = script === void 0 || script === "" ? null : realOrNull(
|
|
48736
|
+
const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
|
|
48653
48737
|
const choice = marketplaceChoice(env, worktree);
|
|
48654
48738
|
if ("root" in choice) return choice.root;
|
|
48655
48739
|
if ("installs" in choice) throw missing(adapter.id, choice.installs.map((r) => r.installPath).join(", "));
|
|
48656
48740
|
const cacheReal = realOrNull(cache);
|
|
48657
|
-
if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep2) &&
|
|
48658
|
-
const pattern =
|
|
48659
|
-
if (!
|
|
48660
|
-
const found = readdirSync5(cache).sort().map((marketplace) =>
|
|
48741
|
+
if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep2) && existsSync7(join9(ownReal, SERVER_ENTRY_FILE))) return ownReal;
|
|
48742
|
+
const pattern = join9(cache, "*", PLUGIN_NAME);
|
|
48743
|
+
if (!existsSync7(cache)) throw missing(adapter.id, pattern);
|
|
48744
|
+
const found = readdirSync5(cache).sort().map((marketplace) => join9(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync7(dir));
|
|
48661
48745
|
if (found.length !== 1) throw missing(adapter.id, found.length === 0 ? pattern : found.join(", "));
|
|
48662
48746
|
return found[0];
|
|
48663
48747
|
}
|
|
@@ -48665,13 +48749,13 @@ function configEntryRoot(adapter, env) {
|
|
|
48665
48749
|
const spec = OWN_MCP_ENTRY[adapter.id];
|
|
48666
48750
|
if (spec === void 0) throw missing(adapter.id, SERVER_KEY);
|
|
48667
48751
|
const file2 = ownMcpFileOf(adapter.id, spec.file, env, requireHomeDir(env));
|
|
48668
|
-
if (!
|
|
48752
|
+
if (!existsSync7(file2)) throw missing(adapter.id, file2);
|
|
48669
48753
|
const current = readHostConfig(adapter.id, file2);
|
|
48670
48754
|
const value = parseHostConfig(adapter.id, file2, current.text, current.format);
|
|
48671
48755
|
const args = hostConfigValueAt(value, [...spec.key, MCP_ARGS_FIELD]);
|
|
48672
48756
|
const script = Array.isArray(args) ? args[0] : void 0;
|
|
48673
48757
|
if (typeof script !== "string" || !isAbsolute(script)) throw missing(adapter.id, file2);
|
|
48674
|
-
return
|
|
48758
|
+
return dirname6(script);
|
|
48675
48759
|
}
|
|
48676
48760
|
function candidate(adapter, env, worktree) {
|
|
48677
48761
|
switch (adapter.installMode) {
|
|
@@ -48682,11 +48766,11 @@ function candidate(adapter, env, worktree) {
|
|
|
48682
48766
|
case "hooks+mcp":
|
|
48683
48767
|
return configEntryRoot(adapter, env);
|
|
48684
48768
|
case "extension":
|
|
48685
|
-
return
|
|
48769
|
+
return join9(requireHomeDir(env), ...AGENT_HOME_DIR[adapter.id], EXTENSIONS_DIR_NAME, PLUGIN_NAME);
|
|
48686
48770
|
case "plugin":
|
|
48687
|
-
return
|
|
48771
|
+
return join9(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
|
|
48688
48772
|
case "in-process":
|
|
48689
|
-
return
|
|
48773
|
+
return dirname6(fileURLToPath2(import.meta.url));
|
|
48690
48774
|
}
|
|
48691
48775
|
}
|
|
48692
48776
|
function resolvePluginRoot(adapter, env, worktree) {
|
|
@@ -48775,11 +48859,11 @@ function ownHooks(block, shape, timeoutKey, native, agent) {
|
|
|
48775
48859
|
var validTimeout = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
48776
48860
|
function mcpFile(row5, home, env) {
|
|
48777
48861
|
const spec = OWN_MCP_ENTRY[row5.id];
|
|
48778
|
-
if (row5.id === "codex") return
|
|
48862
|
+
if (row5.id === "codex") return join10(codexDirOf(env, home), CONFIG_TOML_FILE);
|
|
48779
48863
|
if (spec !== void 0) return ownMcpFileOf(row5.id, spec.file, env, home);
|
|
48780
|
-
if (row5.id === "opencode") return
|
|
48864
|
+
if (row5.id === "opencode") return join10(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
|
|
48781
48865
|
if (row5.id === "pi") {
|
|
48782
|
-
return
|
|
48866
|
+
return join10(piAgentDirOf(env, home), SETTINGS_FILE);
|
|
48783
48867
|
}
|
|
48784
48868
|
return null;
|
|
48785
48869
|
}
|
|
@@ -48792,27 +48876,27 @@ function codexNativeDir(env, home) {
|
|
|
48792
48876
|
const codexDir = codexDirOf(env, home);
|
|
48793
48877
|
let enabled;
|
|
48794
48878
|
try {
|
|
48795
|
-
enabled = hostConfigValueAt(readParsed("codex",
|
|
48879
|
+
enabled = hostConfigValueAt(readParsed("codex", join10(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
|
|
48796
48880
|
} catch {
|
|
48797
48881
|
return null;
|
|
48798
48882
|
}
|
|
48799
48883
|
if (enabled !== true) return null;
|
|
48800
|
-
const cache =
|
|
48801
|
-
if (!
|
|
48884
|
+
const cache = join10(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
|
|
48885
|
+
if (!existsSync8(cache)) return null;
|
|
48802
48886
|
const found = [];
|
|
48803
48887
|
for (const market of readdirSync6(cache)) {
|
|
48804
|
-
const plugin =
|
|
48805
|
-
if (!
|
|
48888
|
+
const plugin = join10(cache, market, SERVER_KEY);
|
|
48889
|
+
if (!existsSync8(plugin)) continue;
|
|
48806
48890
|
for (const version4 of readdirSync6(plugin).sort()) {
|
|
48807
|
-
const dir =
|
|
48808
|
-
if (
|
|
48891
|
+
const dir = join10(plugin, version4, CODEX_PLUGIN_SUBDIR);
|
|
48892
|
+
if (existsSync8(join10(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
|
|
48809
48893
|
}
|
|
48810
48894
|
}
|
|
48811
48895
|
return found.length === 0 ? null : found[found.length - 1];
|
|
48812
48896
|
}
|
|
48813
48897
|
function nativeMcpWrong(dir, row5) {
|
|
48814
48898
|
try {
|
|
48815
|
-
const entry = hostConfigValueAt(readParsed(row5.id,
|
|
48899
|
+
const entry = hostConfigValueAt(readParsed(row5.id, join10(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
|
|
48816
48900
|
if (!isObject4(entry)) return true;
|
|
48817
48901
|
const args = list(entry[MCP_ARGS_FIELD]);
|
|
48818
48902
|
const script = args[0];
|
|
@@ -48821,6 +48905,17 @@ function nativeMcpWrong(dir, row5) {
|
|
|
48821
48905
|
return true;
|
|
48822
48906
|
}
|
|
48823
48907
|
}
|
|
48908
|
+
function isOwnOpencodeEntry(entry, key, own4) {
|
|
48909
|
+
const spec = isObject4(entry) ? entry[OPENCODE_PACKAGE_FIELD] : entry;
|
|
48910
|
+
if (typeof spec !== "string") return false;
|
|
48911
|
+
if (spec === OPENCODE_GIT_SPEC || spec.startsWith(OPENCODE_NPM_SPEC_PREFIX) || own4.includes(spec)) return true;
|
|
48912
|
+
return key === OPENCODE_PLUGINS_KEY && spec === SERVER_KEY;
|
|
48913
|
+
}
|
|
48914
|
+
function opencodeListed(file2) {
|
|
48915
|
+
const { value } = readParsed("opencode", file2);
|
|
48916
|
+
const own4 = [opencodePluginFile()];
|
|
48917
|
+
return [OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own4)));
|
|
48918
|
+
}
|
|
48824
48919
|
function mcpWrong(row5, home, env, worktree) {
|
|
48825
48920
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
48826
48921
|
if (native !== null) return nativeMcpWrong(native, row5);
|
|
@@ -48830,6 +48925,7 @@ function mcpWrong(row5, home, env, worktree) {
|
|
|
48830
48925
|
resolvePluginRoot(row5, env, worktree);
|
|
48831
48926
|
return false;
|
|
48832
48927
|
}
|
|
48928
|
+
if (row5.id === "opencode") return !opencodeListed(file2);
|
|
48833
48929
|
const cur = readHostConfig(row5.id, file2);
|
|
48834
48930
|
return mergeOwnEntries(row5.id, cur.text, cur.format, row5, { nodePath: true, listEntries: [opencodePluginFile()] }).edits.length > 0;
|
|
48835
48931
|
} catch {
|
|
@@ -48839,7 +48935,7 @@ function mcpWrong(row5, home, env, worktree) {
|
|
|
48839
48935
|
function hookFile(row5, spec, home, env, worktree) {
|
|
48840
48936
|
const root = spec.root === "plugin" ? resolvePluginRoot(row5, env, worktree) : spec.root === "home" ? home : worktree;
|
|
48841
48937
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
48842
|
-
const file2 = native !== null ?
|
|
48938
|
+
const file2 = native !== null ? join10(native, CODEX_PLUGIN_HOOKS_FILE) : row5.id === "codex" ? join10(codexDirOf(env, home), HOOKS_JSON_FILE) : row5.id === "copilot-cli" ? join10(copilotDirOf(env, home), ...spec.file.slice(1)) : row5.id === "kiro" ? join10(kiroDirOf(env, home), ...spec.file.slice(1)) : join10(root, ...spec.file);
|
|
48843
48939
|
return file2;
|
|
48844
48940
|
}
|
|
48845
48941
|
function hookParts(row5, home, env, worktree) {
|
|
@@ -48850,7 +48946,7 @@ function hookParts(row5, home, env, worktree) {
|
|
|
48850
48946
|
const file2 = hookFile(row5, spec, home, env, worktree);
|
|
48851
48947
|
block = hostConfigValueAt(readParsed(row5.id, file2).value, spec.key);
|
|
48852
48948
|
if (row5.id === "codex") {
|
|
48853
|
-
const config4 = readParsed(row5.id,
|
|
48949
|
+
const config4 = readParsed(row5.id, join10(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
|
|
48854
48950
|
if (hostConfigValueAt(config4, CODEX_FEATURES_HOOKS_KEY) === false) return [PART_HOOKS];
|
|
48855
48951
|
}
|
|
48856
48952
|
} catch {
|
|
@@ -48908,10 +49004,10 @@ function parsedOrNull(agent, file2, jsonc) {
|
|
|
48908
49004
|
}
|
|
48909
49005
|
function checkDoubleFire(agent, worktree) {
|
|
48910
49006
|
if (agent !== "claude-code" && agent !== "vscode") return pass("D5b");
|
|
48911
|
-
const claude = parsedOrNull(agent,
|
|
49007
|
+
const claude = parsedOrNull(agent, join10(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
|
|
48912
49008
|
const hooks = isObject4(claude) ? claude[HOOKS_KEY] : void 0;
|
|
48913
49009
|
const hooksOn = isObject4(hooks) && Object.keys(hooks).length > 0;
|
|
48914
|
-
const vscode = parsedOrNull(agent,
|
|
49010
|
+
const vscode = parsedOrNull(agent, join10(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
|
|
48915
49011
|
const useClaudeHooks = isObject4(vscode) && vscode[VSCODE_CLAUDE_HOOKS_SETTING] === true;
|
|
48916
49012
|
return hooksOn && useClaudeHooks ? fail("D5b", D5B_DETAIL, D5B_FIX) : pass("D5b");
|
|
48917
49013
|
}
|
|
@@ -48922,7 +49018,7 @@ function configPaths(row5, env, worktree) {
|
|
|
48922
49018
|
const mcp = mcpFile(row5, home, env);
|
|
48923
49019
|
if (mcp !== null) out.push({ label: "MCP entry", path: mcp });
|
|
48924
49020
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
48925
|
-
if (native !== null) out.push({ label: "Codex plugin MCP", path:
|
|
49021
|
+
if (native !== null) out.push({ label: "Codex plugin MCP", path: join10(native, CODEX_PLUGIN_MCP_FILE) });
|
|
48926
49022
|
const spec = HOOK_HOST_FILE[row5.id];
|
|
48927
49023
|
if (spec !== null) {
|
|
48928
49024
|
try {
|
|
@@ -48942,7 +49038,7 @@ function configPaths(row5, env, worktree) {
|
|
|
48942
49038
|
}
|
|
48943
49039
|
|
|
48944
49040
|
// src/core/ops/doctor-db.ts
|
|
48945
|
-
import { existsSync as
|
|
49041
|
+
import { existsSync as existsSync9, statSync as statSync4 } from "node:fs";
|
|
48946
49042
|
var unknown4 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail });
|
|
48947
49043
|
var pass2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "PASS", detail });
|
|
48948
49044
|
var fail2 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
|
|
@@ -48984,15 +49080,15 @@ function orphanFiles(dbPath) {
|
|
|
48984
49080
|
const files = [];
|
|
48985
49081
|
for (const suffix of [DB_WAL_SUFFIX, DB_SHM_SUFFIX]) {
|
|
48986
49082
|
const path7 = dbPath + suffix;
|
|
48987
|
-
if (
|
|
49083
|
+
if (existsSync9(path7)) files.push({ path: path7, bytes: statSync4(path7).size });
|
|
48988
49084
|
}
|
|
48989
|
-
return files.length > 0 && !
|
|
49085
|
+
return files.length > 0 && !existsSync9(dbPath) ? files : [];
|
|
48990
49086
|
}
|
|
48991
49087
|
async function checkDb(project) {
|
|
48992
49088
|
const clean = { schemaStale: false, integrityFailed: false, orphan: [] };
|
|
48993
49089
|
const orphan = orphanFiles(project.dbPath);
|
|
48994
49090
|
if (orphan.length > 0) return { row: fail2(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
|
|
48995
|
-
if (!
|
|
49091
|
+
if (!existsSync9(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
|
|
48996
49092
|
const sqlite = await loadSqlite2();
|
|
48997
49093
|
if (sqlite === null) return { row: unknown4("D8", D2_SQLITE_DETAIL), ...clean };
|
|
48998
49094
|
let raw = null;
|
|
@@ -49018,7 +49114,7 @@ async function checkDb(project) {
|
|
|
49018
49114
|
}
|
|
49019
49115
|
}
|
|
49020
49116
|
async function checkIndex(project) {
|
|
49021
|
-
if (!
|
|
49117
|
+
if (!existsSync9(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
|
|
49022
49118
|
const sqlite = await loadSqlite2();
|
|
49023
49119
|
if (sqlite === null) return unknown4("D9", D2_SQLITE_DETAIL);
|
|
49024
49120
|
let raw = null;
|
|
@@ -49035,8 +49131,8 @@ async function checkIndex(project) {
|
|
|
49035
49131
|
}
|
|
49036
49132
|
|
|
49037
49133
|
// src/core/ops/doctor-env.ts
|
|
49038
|
-
import { existsSync as
|
|
49039
|
-
import { isAbsolute as isAbsolute2, join as
|
|
49134
|
+
import { existsSync as existsSync10, readFileSync as readFileSync7, realpathSync as realpathSync5 } from "node:fs";
|
|
49135
|
+
import { isAbsolute as isAbsolute2, join as join11, relative } from "node:path";
|
|
49040
49136
|
function pass3(id, detail = DOCTOR_PASS_DETAIL) {
|
|
49041
49137
|
return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
|
|
49042
49138
|
}
|
|
@@ -49048,7 +49144,7 @@ function fail3(id, detail, fixCommand) {
|
|
|
49048
49144
|
}
|
|
49049
49145
|
function bundleVersion(bundleDir2) {
|
|
49050
49146
|
try {
|
|
49051
|
-
const v = JSON.parse(readFileSync7(
|
|
49147
|
+
const v = JSON.parse(readFileSync7(join11(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
|
|
49052
49148
|
return typeof v === "string" && v !== "" ? v : void 0;
|
|
49053
49149
|
} catch {
|
|
49054
49150
|
return void 0;
|
|
@@ -49198,7 +49294,7 @@ function checkMcp(ctx) {
|
|
|
49198
49294
|
return named2 || versioned ? pass3("D6") : unknown5("D6", D6_UNKNOWN_DETAIL);
|
|
49199
49295
|
}
|
|
49200
49296
|
function piCwdInside(worktree, piCwd) {
|
|
49201
|
-
if (piCwd === void 0 || !
|
|
49297
|
+
if (piCwd === void 0 || !existsSync10(piCwd)) return false;
|
|
49202
49298
|
const rel = relative(worktree, realpathSync5.native(piCwd));
|
|
49203
49299
|
return rel === "" || !rel.startsWith("..") && !isAbsolute2(rel);
|
|
49204
49300
|
}
|
|
@@ -49219,13 +49315,13 @@ function checkShell(env) {
|
|
|
49219
49315
|
}
|
|
49220
49316
|
|
|
49221
49317
|
// src/core/ops/doctor-hook.ts
|
|
49222
|
-
import { existsSync as
|
|
49318
|
+
import { existsSync as existsSync12, mkdtempSync, readFileSync as readFileSync8, realpathSync as realpathSync7, rmSync as rmSync4 } from "node:fs";
|
|
49223
49319
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
49224
49320
|
import path6 from "node:path";
|
|
49225
49321
|
|
|
49226
49322
|
// src/setup/codex-trust.ts
|
|
49227
49323
|
import { createHash } from "node:crypto";
|
|
49228
|
-
import { existsSync as
|
|
49324
|
+
import { existsSync as existsSync11, realpathSync as realpathSync6 } from "node:fs";
|
|
49229
49325
|
import path5 from "node:path";
|
|
49230
49326
|
import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
|
|
49231
49327
|
|
|
@@ -49323,6 +49419,7 @@ var LIST_TIMEOUT_MS = 15e3;
|
|
|
49323
49419
|
var EXIT_GRACE_MS = 5e3;
|
|
49324
49420
|
var PLUGIN_SOURCE = "plugin";
|
|
49325
49421
|
var TRUSTED = "trusted";
|
|
49422
|
+
var UNTRUSTED = "untrusted";
|
|
49326
49423
|
function pluginHooksFromReply(m, pluginId) {
|
|
49327
49424
|
const out = [];
|
|
49328
49425
|
if (!isObj2(m) || !isObj2(m.result) || !Array.isArray(m.result.data)) return out;
|
|
@@ -49332,7 +49429,8 @@ function pluginHooksFromReply(m, pluginId) {
|
|
|
49332
49429
|
if (!isObj2(h) || h.source !== PLUGIN_SOURCE || h.pluginId !== pluginId) continue;
|
|
49333
49430
|
if (typeof h.key !== "string" || typeof h.currentHash !== "string") continue;
|
|
49334
49431
|
if (out.some((x) => x.key === h.key)) continue;
|
|
49335
|
-
|
|
49432
|
+
const status = typeof h.trustStatus === "string" ? h.trustStatus : UNTRUSTED;
|
|
49433
|
+
out.push({ key: h.key, hash: h.currentHash, trusted: status === TRUSTED, status });
|
|
49336
49434
|
}
|
|
49337
49435
|
}
|
|
49338
49436
|
return out;
|
|
@@ -49425,7 +49523,11 @@ var CODEX_UNTRUSTED_FIX = "run: context-mode setup";
|
|
|
49425
49523
|
function untrustedPluginHooksDetail(hooks) {
|
|
49426
49524
|
const bad = hooks.filter((h) => !h.trusted);
|
|
49427
49525
|
if (!bad.length) return void 0;
|
|
49428
|
-
|
|
49526
|
+
const counts = /* @__PURE__ */ new Map();
|
|
49527
|
+
for (const h of bad) counts.set(h.status, (counts.get(h.status) ?? 0) + 1);
|
|
49528
|
+
const words = [...counts].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1));
|
|
49529
|
+
const state = words.length === 1 ? words[0][0] : `${words.map(([w]) => w).join(" or ")} (${words.map(([w, n]) => `${n} ${w}`).join(", ")})`;
|
|
49530
|
+
return `codex lists ${bad.length} of ${hooks.length} context-mode plugin hooks ${state}, so they do not run; ${CODEX_UNTRUSTED_FIX}`;
|
|
49429
49531
|
}
|
|
49430
49532
|
|
|
49431
49533
|
// src/core/ops/doctor-hook.ts
|
|
@@ -49442,7 +49544,7 @@ function isObject5(v) {
|
|
|
49442
49544
|
}
|
|
49443
49545
|
function loadFixture(bundleDir2, agent) {
|
|
49444
49546
|
const file2 = path6.join(bundleDir2, HOOK_FIXTURE_DIR, HOOK_FIXTURE_FILE);
|
|
49445
|
-
if (!
|
|
49547
|
+
if (!existsSync12(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
|
|
49446
49548
|
let all;
|
|
49447
49549
|
try {
|
|
49448
49550
|
all = JSON.parse(hostText(readFileSync8(file2, "utf8")));
|
|
@@ -49581,7 +49683,7 @@ async function checkHookRoundTrip(i) {
|
|
|
49581
49683
|
const trust = await codexPluginTrust(i);
|
|
49582
49684
|
if (trust !== null) return trust;
|
|
49583
49685
|
}
|
|
49584
|
-
if (i.agent === "codex" &&
|
|
49686
|
+
if (i.agent === "codex" && existsSync12(path6.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
|
|
49585
49687
|
return row("UNKNOWN", D5_CODEX_UNTRUSTED_DETAIL);
|
|
49586
49688
|
}
|
|
49587
49689
|
const fixture = loadFixture(i.bundleDir, i.agent);
|
|
@@ -49620,14 +49722,14 @@ async function checkHookRoundTrip(i) {
|
|
|
49620
49722
|
}
|
|
49621
49723
|
|
|
49622
49724
|
// src/core/hooks/fallback.ts
|
|
49623
|
-
import { join as
|
|
49725
|
+
import { join as join12, resolve as resolve3 } from "node:path";
|
|
49624
49726
|
var fs = process.getBuiltinModule("node:fs");
|
|
49625
49727
|
function homeOf(env) {
|
|
49626
49728
|
return env.HOME ?? env.USERPROFILE ?? "";
|
|
49627
49729
|
}
|
|
49628
49730
|
function hookLogPath(env) {
|
|
49629
49731
|
const home = homeOf(env);
|
|
49630
|
-
return home === "" ? "" :
|
|
49732
|
+
return home === "" ? "" : join12(home, DATA_ROOT.slice(1), HOOK_ERROR_LOG_FILE);
|
|
49631
49733
|
}
|
|
49632
49734
|
function lastHookError(env) {
|
|
49633
49735
|
try {
|
|
@@ -49657,8 +49759,8 @@ function lastHookError(env) {
|
|
|
49657
49759
|
}
|
|
49658
49760
|
|
|
49659
49761
|
// src/core/ops/db-heal.ts
|
|
49660
|
-
import { existsSync as
|
|
49661
|
-
import { basename as basename4, dirname as
|
|
49762
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync5, rmSync as rmSync5 } from "node:fs";
|
|
49763
|
+
import { basename as basename4, dirname as dirname7, join as join13 } from "node:path";
|
|
49662
49764
|
function integrityOk2(rows) {
|
|
49663
49765
|
return rows.length === 1 && rows[0].integrity_check === INTEGRITY_OK;
|
|
49664
49766
|
}
|
|
@@ -49692,7 +49794,7 @@ function renameAside(dbPath) {
|
|
|
49692
49794
|
const ts = String(Date.now());
|
|
49693
49795
|
for (const suffix of DB_SIBLING_SUFFIXES) {
|
|
49694
49796
|
const file2 = dbPath + suffix;
|
|
49695
|
-
if (
|
|
49797
|
+
if (existsSync13(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
|
|
49696
49798
|
}
|
|
49697
49799
|
return ts;
|
|
49698
49800
|
}
|
|
@@ -49715,7 +49817,7 @@ function utcStamp(now) {
|
|
|
49715
49817
|
return now.toISOString().slice(0, 19).replaceAll("-", "").replaceAll(":", "") + "Z";
|
|
49716
49818
|
}
|
|
49717
49819
|
function makeOrphanDir(projectDir) {
|
|
49718
|
-
const base =
|
|
49820
|
+
const base = join13(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
|
|
49719
49821
|
for (let n = 1; ; n += 1) {
|
|
49720
49822
|
const dir = n === 1 ? base : base + "-" + String(n);
|
|
49721
49823
|
try {
|
|
@@ -49730,9 +49832,9 @@ async function healOrphan(project, files, row5) {
|
|
|
49730
49832
|
const moved = [];
|
|
49731
49833
|
let dir = "";
|
|
49732
49834
|
try {
|
|
49733
|
-
dir = makeOrphanDir(
|
|
49835
|
+
dir = makeOrphanDir(dirname7(project.dbPath));
|
|
49734
49836
|
for (const f of files) {
|
|
49735
|
-
const to =
|
|
49837
|
+
const to = join13(dir, basename4(f.path));
|
|
49736
49838
|
renameWithRetry(f.path, to);
|
|
49737
49839
|
moved.push({ path: to, bytes: f.bytes });
|
|
49738
49840
|
}
|
|
@@ -49799,8 +49901,8 @@ function buildReportHead(input) {
|
|
|
49799
49901
|
|
|
49800
49902
|
// src/core/ops/doctor-issue.ts
|
|
49801
49903
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
49802
|
-
import { closeSync, existsSync as
|
|
49803
|
-
import { delimiter, join as
|
|
49904
|
+
import { closeSync, existsSync as existsSync14, fstatSync, mkdirSync as mkdirSync6, openSync, readFileSync as readFileSync9, readSync, realpathSync as realpathSync8, writeFileSync as writeFileSync3 } from "node:fs";
|
|
49905
|
+
import { delimiter, join as join14 } from "node:path";
|
|
49804
49906
|
var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
|
|
49805
49907
|
function tildeOf(env) {
|
|
49806
49908
|
const home = homeDirOf(env);
|
|
@@ -49841,8 +49943,8 @@ function onPath(env, tool) {
|
|
|
49841
49943
|
const out = [];
|
|
49842
49944
|
for (const dir of (env.PATH ?? env.Path ?? "").split(delimiter)) {
|
|
49843
49945
|
if (dir === "") continue;
|
|
49844
|
-
for (const n of names) if (
|
|
49845
|
-
out.push(
|
|
49946
|
+
for (const n of names) if (existsSync14(join14(dir, n))) {
|
|
49947
|
+
out.push(join14(dir, n));
|
|
49846
49948
|
break;
|
|
49847
49949
|
}
|
|
49848
49950
|
}
|
|
@@ -49850,7 +49952,7 @@ function onPath(env, tool) {
|
|
|
49850
49952
|
}
|
|
49851
49953
|
function hookLogTail(env) {
|
|
49852
49954
|
const file2 = hookLogPath(env);
|
|
49853
|
-
if (file2 === "" || !
|
|
49955
|
+
if (file2 === "" || !existsSync14(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
|
|
49854
49956
|
try {
|
|
49855
49957
|
const fd = openSync(file2, "r");
|
|
49856
49958
|
try {
|
|
@@ -49870,7 +49972,7 @@ function hookLogTail(env) {
|
|
|
49870
49972
|
}
|
|
49871
49973
|
async function journalRows(ctx) {
|
|
49872
49974
|
const head = ["| kind | tool | bytes | ok | exit_code | created_at |", "|---|---|---|---|---|---|"];
|
|
49873
|
-
if (!
|
|
49975
|
+
if (!existsSync14(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
|
|
49874
49976
|
try {
|
|
49875
49977
|
const db = await openDb(ctx.project, { readOnly: true });
|
|
49876
49978
|
try {
|
|
@@ -49888,15 +49990,15 @@ function agentConfig(adapter, env, worktree) {
|
|
|
49888
49990
|
const home = homeDirOf(env);
|
|
49889
49991
|
const files = configPaths(adapter, env, worktree);
|
|
49890
49992
|
if (home !== null) {
|
|
49891
|
-
if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path:
|
|
49892
|
-
if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path:
|
|
49993
|
+
if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join14(claudeDirOf(env, home), SETTINGS_FILE) });
|
|
49994
|
+
if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join14(codexDirOf(env, home), CONFIG_TOML_FILE) });
|
|
49893
49995
|
}
|
|
49894
49996
|
const out = [];
|
|
49895
49997
|
const seen = /* @__PURE__ */ new Set();
|
|
49896
49998
|
for (const f of files) {
|
|
49897
49999
|
if (seen.has(f.path)) continue;
|
|
49898
50000
|
seen.add(f.path);
|
|
49899
|
-
if (!
|
|
50001
|
+
if (!existsSync14(f.path)) {
|
|
49900
50002
|
out.push(`${f.label}: ${f.path} (absent)`);
|
|
49901
50003
|
continue;
|
|
49902
50004
|
}
|
|
@@ -49972,14 +50074,14 @@ async function buildIssueBody(i) {
|
|
|
49972
50074
|
async function writeIssueReport(i) {
|
|
49973
50075
|
const tilde = tildeOf(i.env);
|
|
49974
50076
|
const body = await buildIssueBody(i);
|
|
49975
|
-
const dir =
|
|
50077
|
+
const dir = join14(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
|
|
49976
50078
|
mkdirSync6(dir, { recursive: true });
|
|
49977
|
-
const file2 =
|
|
50079
|
+
const file2 = join14(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
|
|
49978
50080
|
writeFileSync3(file2, body);
|
|
49979
50081
|
const shown2 = tilde(file2);
|
|
49980
50082
|
const title = issueTitle(i.adapter.id, i.rows);
|
|
49981
50083
|
const gh = [`gh issue create --repo ${ISSUE_REPO_SLUG} --label bug \\`, `${DOCTOR_GH_NEXT}title ${JSON.stringify(title)} \\`, `${DOCTOR_GH_NEXT}body-file ${shown2}`];
|
|
49982
|
-
return [DOCTOR_REPORT_LINE + shown2, DOCTOR_GH_LINE + gh[0], gh[1], gh[2], DOCTOR_URL_LINE + formUrl(title, summaryOf(i.adapter.id, i.rows))];
|
|
50084
|
+
return [DOCTOR_REPORT_LINE + shown2, DOCTOR_GH_LINE + gh[0], gh[1], gh[2], DOCTOR_URL_LINE + formUrl(title, summaryOf(i.adapter.id, i.rows)), DOCTOR_RULES_LINE + ISSUE_GUIDE_URL];
|
|
49983
50085
|
}
|
|
49984
50086
|
function formUrl(title, summary) {
|
|
49985
50087
|
const base = `${ISSUE_FORM_URL}&title=${encodeURIComponent(title)}`;
|
|
@@ -50020,7 +50122,7 @@ async function guard(id, run) {
|
|
|
50020
50122
|
}
|
|
50021
50123
|
}
|
|
50022
50124
|
async function codexDb(ctx, adapter) {
|
|
50023
|
-
if (adapter.id !== "codex" || !
|
|
50125
|
+
if (adapter.id !== "codex" || !existsSync15(ctx.project.dbPath)) return null;
|
|
50024
50126
|
try {
|
|
50025
50127
|
return await openDb(ctx.project, { readOnly: true });
|
|
50026
50128
|
} catch {
|
|
@@ -50050,11 +50152,11 @@ async function hookRow(ctx, adapter, host) {
|
|
|
50050
50152
|
}
|
|
50051
50153
|
}
|
|
50052
50154
|
function ownServerId(configDir, projectKey) {
|
|
50053
|
-
const dir =
|
|
50054
|
-
if (!
|
|
50155
|
+
const dir = join15(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
50156
|
+
if (!existsSync15(dir)) return "";
|
|
50055
50157
|
for (const name of readdirSync7(dir)) {
|
|
50056
50158
|
if (!name.endsWith(OWNER_PID_EXT)) continue;
|
|
50057
|
-
if (readFileSync10(
|
|
50159
|
+
if (readFileSync10(join15(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
|
|
50058
50160
|
}
|
|
50059
50161
|
return "";
|
|
50060
50162
|
}
|
|
@@ -50137,7 +50239,7 @@ async function doctorReply(ctx, host) {
|
|
|
50137
50239
|
return { text, isError: false, sandboxBytes: bytes5 };
|
|
50138
50240
|
}
|
|
50139
50241
|
async function handler2(_input, ctx) {
|
|
50140
|
-
return doctorReply(ctx, { env: process.env, bundleDir:
|
|
50242
|
+
return doctorReply(ctx, { env: process.env, bundleDir: ownBundleDir(), piCwd: void 0 });
|
|
50141
50243
|
}
|
|
50142
50244
|
var ctxDoctor = Object.freeze({
|
|
50143
50245
|
name: "ctx_doctor",
|
|
@@ -50149,9 +50251,9 @@ var ctxDoctor = Object.freeze({
|
|
|
50149
50251
|
});
|
|
50150
50252
|
|
|
50151
50253
|
// src/core/tools/execute.ts
|
|
50152
|
-
import { existsSync as
|
|
50254
|
+
import { existsSync as existsSync16, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync4 } from "node:fs";
|
|
50153
50255
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
50154
|
-
import { dirname as
|
|
50256
|
+
import { dirname as dirname9, join as join16, parse as parse5, resolve as resolve4 } from "node:path";
|
|
50155
50257
|
|
|
50156
50258
|
// src/core/index/select.ts
|
|
50157
50259
|
var READ_CHUNKS = "SELECT ord, body FROM chunks WHERE source_id = ?";
|
|
@@ -50274,7 +50376,7 @@ function schemaLine(issue4) {
|
|
|
50274
50376
|
}
|
|
50275
50377
|
function fileError(given, abs, root) {
|
|
50276
50378
|
let dir = abs;
|
|
50277
|
-
while (!
|
|
50379
|
+
while (!existsSync16(dir) && dirname9(dir) !== dir) dir = dirname9(dir);
|
|
50278
50380
|
if (isInside(root, dir)) return null;
|
|
50279
50381
|
return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
|
|
50280
50382
|
}
|
|
@@ -50355,8 +50457,8 @@ async function handler3(raw, ctx) {
|
|
|
50355
50457
|
if (takesDashC(input.language, runtime)) {
|
|
50356
50458
|
argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
|
|
50357
50459
|
} else {
|
|
50358
|
-
tmpDir = mkdtempSync2(
|
|
50359
|
-
const file2 =
|
|
50460
|
+
tmpDir = mkdtempSync2(join16(tmpdir3(), TMP_PREFIX));
|
|
50461
|
+
const file2 = join16(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
|
|
50360
50462
|
writeFileSync4(file2, scriptText(input.language, input.code), "utf8");
|
|
50361
50463
|
argv = scriptArgv(input.language, runtime, file2);
|
|
50362
50464
|
}
|
|
@@ -50391,12 +50493,12 @@ var ctxExecute = {
|
|
|
50391
50493
|
};
|
|
50392
50494
|
|
|
50393
50495
|
// src/core/tools/index.ts
|
|
50394
|
-
import { existsSync as
|
|
50395
|
-
import { dirname as
|
|
50496
|
+
import { existsSync as existsSync17, readFileSync as readFileSync12, statSync as statSync7 } from "node:fs";
|
|
50497
|
+
import { dirname as dirname10, extname, join as join18, relative as relative2, resolve as resolve5 } from "node:path";
|
|
50396
50498
|
|
|
50397
50499
|
// src/core/index/walk.ts
|
|
50398
50500
|
import { readdirSync as readdirSync8, readFileSync as readFileSync11, realpathSync as realpathSync9, statSync as statSync6 } from "node:fs";
|
|
50399
|
-
import { join as
|
|
50501
|
+
import { join as join17 } from "node:path";
|
|
50400
50502
|
var GITIGNORE = ".gitignore";
|
|
50401
50503
|
var GIT_DIR = ".git";
|
|
50402
50504
|
function walkDir(root, containmentRoot) {
|
|
@@ -50405,7 +50507,7 @@ function walkDir(root, containmentRoot) {
|
|
|
50405
50507
|
const found = [];
|
|
50406
50508
|
visit(real2, [], [], containmentRoot, /* @__PURE__ */ new Set([real2]), found);
|
|
50407
50509
|
found.sort(compareFound);
|
|
50408
|
-
return found.map((f) => ({ absPath: f.absPath, relPath:
|
|
50510
|
+
return found.map((f) => ({ absPath: f.absPath, relPath: join17(...f.dir, f.name) }));
|
|
50409
50511
|
}
|
|
50410
50512
|
function visit(abs, rel, parent, contain, seen, found) {
|
|
50411
50513
|
let entries;
|
|
@@ -50414,10 +50516,10 @@ function visit(abs, rel, parent, contain, seen, found) {
|
|
|
50414
50516
|
} catch {
|
|
50415
50517
|
return;
|
|
50416
50518
|
}
|
|
50417
|
-
const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(
|
|
50519
|
+
const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join17(abs, GITIGNORE), rel)) : parent;
|
|
50418
50520
|
for (const e of entries) {
|
|
50419
50521
|
if (e.name === GIT_DIR) continue;
|
|
50420
|
-
const path7 =
|
|
50522
|
+
const path7 = join17(abs, e.name);
|
|
50421
50523
|
let isDir = e.isDirectory();
|
|
50422
50524
|
let isFile = e.isFile();
|
|
50423
50525
|
let target = path7;
|
|
@@ -54547,7 +54649,7 @@ function readUtf8(absPath) {
|
|
|
54547
54649
|
}
|
|
54548
54650
|
function missingOrOutside(given, abs, root) {
|
|
54549
54651
|
let dir = abs;
|
|
54550
|
-
while (!
|
|
54652
|
+
while (!existsSync17(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
|
|
54551
54653
|
if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
|
|
54552
54654
|
return new CtxError("OUTSIDE_ROOT", { p: given, root });
|
|
54553
54655
|
}
|
|
@@ -54558,7 +54660,7 @@ function pathItems(input, project) {
|
|
|
54558
54660
|
if (statSync7(abs).isDirectory()) {
|
|
54559
54661
|
return walkDir(abs, project.containmentRoot).map((f) => ({
|
|
54560
54662
|
sourceKind: "path",
|
|
54561
|
-
label: pathLabel(
|
|
54663
|
+
label: pathLabel(join18(base, f.relPath)),
|
|
54562
54664
|
kind: kindOfPath(f.relPath),
|
|
54563
54665
|
read: () => readUtf8(f.absPath)
|
|
54564
54666
|
}));
|
|
@@ -55363,12 +55465,12 @@ var ctxStats = Object.freeze({
|
|
|
55363
55465
|
});
|
|
55364
55466
|
|
|
55365
55467
|
// src/core/tools/upgrade.ts
|
|
55366
|
-
import { existsSync as
|
|
55367
|
-
import { basename as basename7, dirname as
|
|
55468
|
+
import { existsSync as existsSync23, realpathSync as realpathSync10, rmSync as rmSync11 } from "node:fs";
|
|
55469
|
+
import { basename as basename7, dirname as dirname12, join as join24 } from "node:path";
|
|
55368
55470
|
|
|
55369
55471
|
// src/core/ops/host-write.ts
|
|
55370
|
-
import { copyFileSync, existsSync as
|
|
55371
|
-
import { dirname as
|
|
55472
|
+
import { copyFileSync, existsSync as existsSync18, mkdirSync as mkdirSync7, writeFileSync as writeFileSync5 } from "node:fs";
|
|
55473
|
+
import { dirname as dirname11, join as join19 } from "node:path";
|
|
55372
55474
|
function defaultWrite(file2, text) {
|
|
55373
55475
|
writeFileSync5(file2, text, "utf8");
|
|
55374
55476
|
}
|
|
@@ -55377,14 +55479,14 @@ function hostConfigPath(agent, home, env) {
|
|
|
55377
55479
|
if (own4 !== void 0) return ownMcpFileOf(agent, own4.file, env, home);
|
|
55378
55480
|
switch (agent) {
|
|
55379
55481
|
case "opencode":
|
|
55380
|
-
return
|
|
55482
|
+
return join19(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
|
|
55381
55483
|
// D-WIN-OPENCODE-DIR-1
|
|
55382
55484
|
case "pi":
|
|
55383
|
-
return
|
|
55485
|
+
return join19(piAgentDirOf(env, home), SETTINGS_FILE);
|
|
55384
55486
|
case "copilot-cli":
|
|
55385
55487
|
return null;
|
|
55386
55488
|
default:
|
|
55387
|
-
return
|
|
55489
|
+
return join19(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
|
|
55388
55490
|
}
|
|
55389
55491
|
}
|
|
55390
55492
|
function cell3(value) {
|
|
@@ -55396,8 +55498,8 @@ function toRow(file2, edit) {
|
|
|
55396
55498
|
function writeWithRollback(file2, text, write, atomic) {
|
|
55397
55499
|
const trash = file2 + UPGRADE_TRASH_SUFFIX;
|
|
55398
55500
|
const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
|
|
55399
|
-
const had =
|
|
55400
|
-
mkdirSync7(
|
|
55501
|
+
const had = existsSync18(file2);
|
|
55502
|
+
mkdirSync7(dirname11(file2), { recursive: true });
|
|
55401
55503
|
if (had) copyFileSync(file2, trash);
|
|
55402
55504
|
try {
|
|
55403
55505
|
write(tmp, text);
|
|
@@ -55426,7 +55528,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
55426
55528
|
if (requested === null) return [];
|
|
55427
55529
|
const current = readHostConfig(row5.id, requested);
|
|
55428
55530
|
const result = mergeOwnEntries(row5.id, current.text, current.format, row5);
|
|
55429
|
-
const exists =
|
|
55531
|
+
const exists = existsSync18(current.path);
|
|
55430
55532
|
if (exists && result.text === current.text) return [];
|
|
55431
55533
|
const text = result.text === "" && current.format !== "toml" ? JSON.stringify({}) : result.text;
|
|
55432
55534
|
writeWithRollback(current.path, current.layout === void 0 ? text : withLayout(text, current.layout), opts.write ?? defaultWrite, opts.atomic ?? {});
|
|
@@ -55434,8 +55536,8 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
55434
55536
|
}
|
|
55435
55537
|
|
|
55436
55538
|
// src/core/ops/plugin-swap.ts
|
|
55437
|
-
import { existsSync as
|
|
55438
|
-
import { basename as basename6, join as
|
|
55539
|
+
import { existsSync as existsSync19, lstatSync, readdirSync as readdirSync9, readlinkSync, rmSync as rmSync7, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
|
|
55540
|
+
import { basename as basename6, join as join20, win32 as win322 } from "node:path";
|
|
55439
55541
|
function linkTarget(path7, win) {
|
|
55440
55542
|
if (!isLink(path7)) return null;
|
|
55441
55543
|
const target = readlinkSync(path7);
|
|
@@ -55454,11 +55556,11 @@ function settleLinks(link, tmp, old, opts) {
|
|
|
55454
55556
|
else renameWithRetry(old, link, opts);
|
|
55455
55557
|
}
|
|
55456
55558
|
function swapPluginCurrent(agentDir, sha, opts = {}) {
|
|
55457
|
-
const next =
|
|
55458
|
-
if (!
|
|
55559
|
+
const next = join20(agentDir, sha);
|
|
55560
|
+
if (!existsSync19(next) || !lstatSync(next).isDirectory()) {
|
|
55459
55561
|
throw new CtxError("PLUGIN_ROOT_MISSING", { agent: basename6(agentDir), path: next });
|
|
55460
55562
|
}
|
|
55461
|
-
const link =
|
|
55563
|
+
const link = join20(agentDir, PLUGIN_CURRENT_LINK);
|
|
55462
55564
|
const tmp = link + PLUGIN_LINK_TMP_SUFFIX;
|
|
55463
55565
|
const old = link + PLUGIN_LINK_OLD_SUFFIX;
|
|
55464
55566
|
settleLinks(link, tmp, old, opts);
|
|
@@ -55473,15 +55575,15 @@ function swapPluginCurrent(agentDir, sha, opts = {}) {
|
|
|
55473
55575
|
if (before !== null) unlinkSync2(old);
|
|
55474
55576
|
const keep = /* @__PURE__ */ new Set([sha]);
|
|
55475
55577
|
if (before !== null) keep.add(before);
|
|
55476
|
-
const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) =>
|
|
55578
|
+
const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join20(agentDir, name));
|
|
55477
55579
|
for (const dir of removed) rmSync7(dir, { recursive: true, force: true });
|
|
55478
|
-
const previous = before !== null &&
|
|
55580
|
+
const previous = before !== null && existsSync19(join20(agentDir, before)) ? join20(agentDir, before) : null;
|
|
55479
55581
|
return { current: next, previous, removed };
|
|
55480
55582
|
}
|
|
55481
55583
|
|
|
55482
55584
|
// src/core/ops/release-fetch.ts
|
|
55483
|
-
import { existsSync as
|
|
55484
|
-
import { join as
|
|
55585
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync8, rmSync as rmSync8 } from "node:fs";
|
|
55586
|
+
import { join as join21 } from "node:path";
|
|
55485
55587
|
function failed(r) {
|
|
55486
55588
|
if (r.exitCode === null && r.killed === null) return new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
|
|
55487
55589
|
const status = r.killed ?? String(r.exitCode);
|
|
@@ -55493,9 +55595,9 @@ async function git2(bin, args, cwd, env, signal) {
|
|
|
55493
55595
|
return r.stdout.toString().trim();
|
|
55494
55596
|
}
|
|
55495
55597
|
async function fetchRelease(agent, url4, env, signal, opts = {}) {
|
|
55496
|
-
const agentDir =
|
|
55598
|
+
const agentDir = join21(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, agent);
|
|
55497
55599
|
mkdirSync8(agentDir, { recursive: true });
|
|
55498
|
-
const fetchDir =
|
|
55600
|
+
const fetchDir = join21(agentDir, UPGRADE_FETCH_DIR_PREFIX + process.pid);
|
|
55499
55601
|
rmSync8(fetchDir, { recursive: true, force: true });
|
|
55500
55602
|
const gitBin = findRuntime(GIT_BIN, env);
|
|
55501
55603
|
if (gitBin === null) throw new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
|
|
@@ -55503,8 +55605,8 @@ async function fetchRelease(agent, url4, env, signal, opts = {}) {
|
|
|
55503
55605
|
try {
|
|
55504
55606
|
await git2(gitBin, [...GIT_CLONE_ARGS, RELEASE_BRANCH, url4, fetchDir], agentDir, childEnv, signal);
|
|
55505
55607
|
const sha = await git2(gitBin, GIT_HEAD_SHA_ARGS, fetchDir, childEnv, signal);
|
|
55506
|
-
const dir =
|
|
55507
|
-
if (
|
|
55608
|
+
const dir = join21(agentDir, sha);
|
|
55609
|
+
if (existsSync20(dir)) rmSync8(fetchDir, { recursive: true, force: true });
|
|
55508
55610
|
else renameWithRetry(fetchDir, dir, opts);
|
|
55509
55611
|
return { sha, dir };
|
|
55510
55612
|
} catch (e) {
|
|
@@ -55514,15 +55616,15 @@ async function fetchRelease(agent, url4, env, signal, opts = {}) {
|
|
|
55514
55616
|
}
|
|
55515
55617
|
|
|
55516
55618
|
// src/core/ops/uninstall.ts
|
|
55517
|
-
import { existsSync as
|
|
55518
|
-
import { join as
|
|
55619
|
+
import { existsSync as existsSync21, readdirSync as readdirSync10, rmSync as rmSync9, writeFileSync as writeFileSync6 } from "node:fs";
|
|
55620
|
+
import { join as join22 } from "node:path";
|
|
55519
55621
|
function row2(area, before, after) {
|
|
55520
55622
|
return { area, before, after };
|
|
55521
55623
|
}
|
|
55522
55624
|
function stopServers(configDir, projectKey) {
|
|
55523
55625
|
const stopped = listLiveOwners(configDir, projectKey);
|
|
55524
|
-
const dir =
|
|
55525
|
-
for (const serverId of stopped) writeFileSync6(
|
|
55626
|
+
const dir = join22(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
55627
|
+
for (const serverId of stopped) writeFileSync6(join22(dir, serverId + OWNER_STOP_EXT), "", "utf8");
|
|
55526
55628
|
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 };
|
|
55527
55629
|
}
|
|
55528
55630
|
function rootOrNull(adapter, env) {
|
|
@@ -55540,15 +55642,15 @@ function removeCache(adapter, env, configDir) {
|
|
|
55540
55642
|
const root = rootOrNull(adapter, env);
|
|
55541
55643
|
if (root === null) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
|
|
55542
55644
|
if (adapter.installMode === "marketplace") {
|
|
55543
|
-
const cache =
|
|
55645
|
+
const cache = join22(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
|
|
55544
55646
|
if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
|
|
55545
55647
|
}
|
|
55546
55648
|
rmSync9(root, { recursive: true, force: true });
|
|
55547
55649
|
return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
|
|
55548
55650
|
}
|
|
55549
55651
|
case "plugin": {
|
|
55550
|
-
const agentDir =
|
|
55551
|
-
if (!
|
|
55652
|
+
const agentDir = join22(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
|
|
55653
|
+
if (!existsSync21(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
|
|
55552
55654
|
rmSync9(agentDir, { recursive: true, force: true });
|
|
55553
55655
|
return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
|
|
55554
55656
|
}
|
|
@@ -55593,7 +55695,7 @@ function ownEntries(agent, env) {
|
|
|
55593
55695
|
}
|
|
55594
55696
|
if (agent === "opencode") {
|
|
55595
55697
|
return [{
|
|
55596
|
-
file:
|
|
55698
|
+
file: join22(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
|
|
55597
55699
|
// D-WIN-OPENCODE-DIR-1
|
|
55598
55700
|
key: OPENCODE_PLUGIN_KEY,
|
|
55599
55701
|
shown: OPENCODE_PLUGIN_KEY,
|
|
@@ -55604,7 +55706,7 @@ function ownEntries(agent, env) {
|
|
|
55604
55706
|
if (agent === "pi") {
|
|
55605
55707
|
const agentDir = piAgentDirOf(env, home);
|
|
55606
55708
|
return [{
|
|
55607
|
-
file:
|
|
55709
|
+
file: join22(agentDir, SETTINGS_FILE),
|
|
55608
55710
|
key: PI_PACKAGES_KEY,
|
|
55609
55711
|
shown: PI_PACKAGES_KEY,
|
|
55610
55712
|
has: (v) => Array.isArray(v) && v.some((x) => piSource(x) === PI_GIT_PACKAGE),
|
|
@@ -55626,12 +55728,12 @@ function removeOwnEntries(agent, env) {
|
|
|
55626
55728
|
return rows.length === 0 ? [row2(UPGRADE_CONFIG_AREA, "", UPGRADE_NOT_FOUND)] : rows;
|
|
55627
55729
|
}
|
|
55628
55730
|
function removeProjectData(configDir, projectKey) {
|
|
55629
|
-
const projects =
|
|
55630
|
-
const dir =
|
|
55631
|
-
if (!
|
|
55731
|
+
const projects = join22(configDir, PROJECTS_DIR_NAME);
|
|
55732
|
+
const dir = join22(projects, projectKey);
|
|
55733
|
+
if (!existsSync21(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
|
|
55632
55734
|
if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
|
|
55633
55735
|
for (const name of readdirSync10(dir)) {
|
|
55634
|
-
if (name !== OWNERS_DIR_NAME) rmSync9(
|
|
55736
|
+
if (name !== OWNERS_DIR_NAME) rmSync9(join22(dir, name), { recursive: true, force: true });
|
|
55635
55737
|
}
|
|
55636
55738
|
return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
|
|
55637
55739
|
}
|
|
@@ -55639,12 +55741,12 @@ function runUninstall(input) {
|
|
|
55639
55741
|
const configDir = resolveConfigDir(input.env);
|
|
55640
55742
|
const stop = stopServers(configDir, input.project.projectKey);
|
|
55641
55743
|
const rows = [stop.row, removeCache(input.adapter, input.env, configDir), ...removeOwnEntries(input.adapter.id, input.env)];
|
|
55642
|
-
rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA,
|
|
55744
|
+
rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join22(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
|
|
55643
55745
|
return { rows, stopped: stop.stopped };
|
|
55644
55746
|
}
|
|
55645
55747
|
|
|
55646
55748
|
// src/core/ops/v1-remove.ts
|
|
55647
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
55749
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync22, readFileSync as readFileSync13, rmSync as rmSync10 } from "node:fs";
|
|
55648
55750
|
var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
55649
55751
|
var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
|
|
55650
55752
|
var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
|
|
@@ -55725,14 +55827,14 @@ function removeV1(agent, findings) {
|
|
|
55725
55827
|
for (const f of findings) {
|
|
55726
55828
|
if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
|
|
55727
55829
|
else if (f.path === "") {
|
|
55728
|
-
if (
|
|
55830
|
+
if (existsSync22(f.file)) {
|
|
55729
55831
|
moveAside(f.file, undo);
|
|
55730
55832
|
done.set(f, UPGRADE_REMOVED);
|
|
55731
55833
|
} else done.set(f, UPGRADE_NOT_FOUND);
|
|
55732
55834
|
} else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
|
|
55733
55835
|
}
|
|
55734
55836
|
for (const [file2, list3] of entries) {
|
|
55735
|
-
if (!
|
|
55837
|
+
if (!existsSync22(file2)) {
|
|
55736
55838
|
for (const f of list3) done.set(f, UPGRADE_NOT_FOUND);
|
|
55737
55839
|
continue;
|
|
55738
55840
|
}
|
|
@@ -55765,7 +55867,7 @@ function removeV1(agent, findings) {
|
|
|
55765
55867
|
},
|
|
55766
55868
|
rollback() {
|
|
55767
55869
|
for (const u of undo.splice(0).reverse()) {
|
|
55768
|
-
if (!
|
|
55870
|
+
if (!existsSync22(u.trash)) continue;
|
|
55769
55871
|
rmSync10(u.target, { recursive: true, force: true });
|
|
55770
55872
|
renameWithRetry(u.trash, u.target);
|
|
55771
55873
|
}
|
|
@@ -55776,7 +55878,7 @@ function removeV1(agent, findings) {
|
|
|
55776
55878
|
// src/core/ops/verify-sums.ts
|
|
55777
55879
|
import { createHash as createHash2 } from "node:crypto";
|
|
55778
55880
|
import { lstatSync as lstatSync2, readdirSync as readdirSync11, readFileSync as readFileSync14 } from "node:fs";
|
|
55779
|
-
import { join as
|
|
55881
|
+
import { join as join23 } from "node:path";
|
|
55780
55882
|
function mismatch() {
|
|
55781
55883
|
return new CtxError("BUNDLE_HASH_MISMATCH");
|
|
55782
55884
|
}
|
|
@@ -55797,14 +55899,14 @@ function walk2(dir, prefix, out) {
|
|
|
55797
55899
|
for (const entry of readdirSync11(dir, { withFileTypes: true })) {
|
|
55798
55900
|
const rel = prefix === "" ? entry.name : prefix + "/" + entry.name;
|
|
55799
55901
|
if (prefix === "" && (entry.name === GIT_DIR_NAME || entry.name === RELEASE_SUMS_FILE)) continue;
|
|
55800
|
-
const abs =
|
|
55902
|
+
const abs = join23(dir, entry.name);
|
|
55801
55903
|
if (entry.isDirectory()) walk2(abs, rel, out);
|
|
55802
55904
|
else if (entry.isFile()) out.set(rel, abs);
|
|
55803
55905
|
else throw mismatch();
|
|
55804
55906
|
}
|
|
55805
55907
|
}
|
|
55806
55908
|
function verifySums(dir) {
|
|
55807
|
-
const sumsPath =
|
|
55909
|
+
const sumsPath = join23(dir, RELEASE_SUMS_FILE);
|
|
55808
55910
|
const sumsStat = lstatSync2(sumsPath, { throwIfNoEntry: false });
|
|
55809
55911
|
if (sumsStat === void 0 || !sumsStat.isFile()) throw mismatch();
|
|
55810
55912
|
const sums = parseSums(readFileSync14(sumsPath, "utf8"));
|
|
@@ -55828,7 +55930,7 @@ function row4(area, before, after) {
|
|
|
55828
55930
|
return { area, before, after };
|
|
55829
55931
|
}
|
|
55830
55932
|
function bundleDir() {
|
|
55831
|
-
return
|
|
55933
|
+
return ownBundleDir();
|
|
55832
55934
|
}
|
|
55833
55935
|
function pluginRootRow(adapter, env) {
|
|
55834
55936
|
const own4 = bundleDir();
|
|
@@ -55842,12 +55944,12 @@ function pluginRootRow(adapter, env) {
|
|
|
55842
55944
|
return root === own4 ? [] : [row4(UPGRADE_PLUGIN_ROOT_AREA, root, own4)];
|
|
55843
55945
|
}
|
|
55844
55946
|
function isCurrent(agentDir, dir) {
|
|
55845
|
-
const link =
|
|
55846
|
-
return
|
|
55947
|
+
const link = join24(agentDir, PLUGIN_CURRENT_LINK);
|
|
55948
|
+
return existsSync23(link) && realpathSync10.native(link) === realpathSync10.native(dir);
|
|
55847
55949
|
}
|
|
55848
55950
|
async function checkout(adapter, deps) {
|
|
55849
55951
|
const fetched = await fetchRelease(adapter.id, deps.releaseUrl, deps.env, deps.signal);
|
|
55850
|
-
const agentDir =
|
|
55952
|
+
const agentDir = dirname12(fetched.dir);
|
|
55851
55953
|
try {
|
|
55852
55954
|
verifySums(fetched.dir);
|
|
55853
55955
|
} catch (err) {
|
|
@@ -56036,7 +56138,7 @@ function workspaceFromMeta(meta3) {
|
|
|
56036
56138
|
if (typeof cwd !== "string" || cwd === "") return void 0;
|
|
56037
56139
|
if (!cwd.startsWith(FILE_URL_PREFIX)) return cwd;
|
|
56038
56140
|
try {
|
|
56039
|
-
return
|
|
56141
|
+
return fileURLToPath3(cwd);
|
|
56040
56142
|
} catch {
|
|
56041
56143
|
return void 0;
|
|
56042
56144
|
}
|
|
@@ -56052,7 +56154,7 @@ function workspaceCwdOf(meta3, spawnCwd, script) {
|
|
|
56052
56154
|
const fromHost = workspaceFromMeta(meta3);
|
|
56053
56155
|
if (fromHost !== void 0) return fromHost;
|
|
56054
56156
|
if (script === void 0 || script === "") return spawnCwd;
|
|
56055
|
-
return realOrSame(spawnCwd) === realOrSame(
|
|
56157
|
+
return realOrSame(spawnCwd) === realOrSame(dirname13(script)) ? "" : spawnCwd;
|
|
56056
56158
|
}
|
|
56057
56159
|
function errorReply(err) {
|
|
56058
56160
|
if (err instanceof CtxError) return { text: err.toLine(), isError: true, sandboxBytes: 0 };
|
|
@@ -56091,15 +56193,15 @@ async function startServer(argv, env) {
|
|
|
56091
56193
|
opening.catch(() => pending.delete(project.dbPath));
|
|
56092
56194
|
}
|
|
56093
56195
|
const db = await opening;
|
|
56094
|
-
if (!
|
|
56196
|
+
if (!existsSync24(db.path)) throw new CtxError("DB_GONE");
|
|
56095
56197
|
return db;
|
|
56096
56198
|
}
|
|
56097
56199
|
function stopMarker(configDir, projectKey) {
|
|
56098
|
-
return
|
|
56200
|
+
return join25(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
|
|
56099
56201
|
}
|
|
56100
56202
|
function stopRequested() {
|
|
56101
56203
|
const configDir = resolveConfigDir(process.env);
|
|
56102
|
-
return held.some((db) =>
|
|
56204
|
+
return held.some((db) => existsSync24(stopMarker(configDir, db.projectKey)));
|
|
56103
56205
|
}
|
|
56104
56206
|
async function journal(project, ctx, name, reply4) {
|
|
56105
56207
|
const db = await ownDb(project);
|
|
@@ -56208,7 +56310,7 @@ async function startServer(argv, env) {
|
|
|
56208
56310
|
handle = serveStdio(createServer);
|
|
56209
56311
|
await new Promise((resolve6) => process.once("exit", () => resolve6()));
|
|
56210
56312
|
}
|
|
56211
|
-
if (isEntry(import.meta.main, process.argv[1],
|
|
56313
|
+
if (isEntry(import.meta.main, process.argv[1], fileURLToPath3(import.meta.url))) {
|
|
56212
56314
|
const [, , ...cliArgs] = process.argv;
|
|
56213
56315
|
await startServer(cliArgs, process.env);
|
|
56214
56316
|
}
|