context-mode 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +87 -91
- package/SHA256SUMS +15 -15
- package/cli.mjs +230 -115
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +87 -85
- package/opencode/plugin.js +378 -231
- package/package.json +1 -1
- package/pi/index.js +429 -282
- package/qwen-extension.json +1 -1
- package/run.mjs +62 -19
- package/search.mjs +62 -19
- package/server.mjs +411 -263
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__")
|
|
@@ -28065,6 +28065,7 @@ var REPORT_CAP = 4096;
|
|
|
28065
28065
|
var POINTER_MIN = 640;
|
|
28066
28066
|
var STATE_CLOSE_TAG = "</context_mode_state>";
|
|
28067
28067
|
var INDEX_WRITE_CHUNK = 1048576;
|
|
28068
|
+
var REPLACE_TRIGGER_BYTES = 4096;
|
|
28068
28069
|
var MAX_CHUNK_BYTES = 4096;
|
|
28069
28070
|
var SEARCH_PAGE_SIZE = 20;
|
|
28070
28071
|
var MEMORY_LABEL_PREFIX = "memory ";
|
|
@@ -28406,7 +28407,7 @@ var DECISION_SOURCE = "decision";
|
|
|
28406
28407
|
var DECISION_USER_LABEL = "decision (user)";
|
|
28407
28408
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
28408
28409
|
var RELEASE_BRANCH = "release";
|
|
28409
|
-
var BUNDLE_SHA = true ? "
|
|
28410
|
+
var BUNDLE_SHA = true ? "d232ce4ddfb581a63a4c0d6ef894b64a0f8464f6" : void 0;
|
|
28410
28411
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
28411
28412
|
var DOCTOR_LABEL = Object.freeze({
|
|
28412
28413
|
D1: "version",
|
|
@@ -28670,6 +28671,7 @@ var REGEX_SPECIAL_CHARS = ".*+?^${}()|[]\\";
|
|
|
28670
28671
|
var REGEX_ESCAPE = "\\";
|
|
28671
28672
|
var CODEX_FEATURES_HOOKS_KEY = Object.freeze(["features", "hooks"]);
|
|
28672
28673
|
var D5_SHAPE_DETAIL = "hook output is not the agent's native shape";
|
|
28674
|
+
var D5_READ_SHAPE_DETAIL = `PostToolUse Read replace is not Read's output shape {type:"text", file:{filePath, content, numLines, startLine, totalLines}}: Claude Code drops it and shows a hook warning`;
|
|
28673
28675
|
function D5_SLOW_DETAIL(ms) {
|
|
28674
28676
|
return `hook round trip took ${ms} ms over bare node, over ${HOOK_P95_MS} ms`;
|
|
28675
28677
|
}
|
|
@@ -28699,8 +28701,8 @@ var UPGRADE_DATA_DELETED = "user data deleted";
|
|
|
28699
28701
|
var UPGRADE_HOST_COMMAND = Object.freeze({
|
|
28700
28702
|
"claude-code": "claude plugin marketplace update context-mode && claude plugin update context-mode@context-mode",
|
|
28701
28703
|
codex: "rewrite config.toml's [mcp_servers.context-mode*] block to the v2 entry, then restart Codex",
|
|
28702
|
-
gemini: "gemini extensions install https://github.com/mksglu/context-mode --
|
|
28703
|
-
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"
|
|
28704
28706
|
});
|
|
28705
28707
|
var PI_GIT_PACKAGE = "git:github.com/mksglu/context-mode@release";
|
|
28706
28708
|
var OPENCODE_GIT_SPEC = "git+https://github.com/mksglu/context-mode.git#release";
|
|
@@ -28764,6 +28766,9 @@ var HOOKS_KEY = "hooks";
|
|
|
28764
28766
|
var STATUS_LINE_KEY = "statusLine";
|
|
28765
28767
|
var PI_PACKAGES_KEY = "packages";
|
|
28766
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}@`;
|
|
28767
28772
|
var V1_DATA_DIR_NAME = "context-mode";
|
|
28768
28773
|
var V1_DATA_ROOT_ENTRIES = Object.freeze(["content", "platform.json"]);
|
|
28769
28774
|
var V1_SESSIONS_DIR_NAME = "sessions";
|
|
@@ -28861,6 +28866,7 @@ var DOCTOR_REPORT_FILE_PREFIX = "doctor-";
|
|
|
28861
28866
|
var DOCTOR_REPORT_LINE = "Report file: ";
|
|
28862
28867
|
var DOCTOR_GH_LINE = "File it: ";
|
|
28863
28868
|
var DOCTOR_URL_LINE = "Or open: ";
|
|
28869
|
+
var DOCTOR_RULES_LINE = "Rules: ";
|
|
28864
28870
|
var DOCTOR_GH_NEXT = " --";
|
|
28865
28871
|
var DOCTOR_NOTE_PREFIXES = Object.freeze([
|
|
28866
28872
|
DOCTOR_ENV_PREFIX,
|
|
@@ -28868,10 +28874,23 @@ var DOCTOR_NOTE_PREFIXES = Object.freeze([
|
|
|
28868
28874
|
DOCTOR_REPORT_LINE,
|
|
28869
28875
|
DOCTOR_GH_LINE,
|
|
28870
28876
|
DOCTOR_GH_NEXT.trim(),
|
|
28871
|
-
DOCTOR_URL_LINE
|
|
28877
|
+
DOCTOR_URL_LINE,
|
|
28878
|
+
DOCTOR_RULES_LINE
|
|
28872
28879
|
]);
|
|
28873
28880
|
var ISSUE_REPO_SLUG = "mksglu/context-mode";
|
|
28874
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
|
+
]);
|
|
28875
28894
|
var ISSUE_URL_MAX = 8e3;
|
|
28876
28895
|
var ISSUE_FORM_HEADINGS = Object.freeze([
|
|
28877
28896
|
"Summary",
|
|
@@ -28902,16 +28921,16 @@ var DOCTOR_PATH_TOOLS = Object.freeze(["node", "git", "sh"]);
|
|
|
28902
28921
|
var DOCTOR_SECRET_WORDS = Object.freeze(["token", "secret", "password", "apikey", "api_key", "authorization", "bearer"]);
|
|
28903
28922
|
var DOCTOR_MASK = "<masked>";
|
|
28904
28923
|
var NATIVE_INSTALL = Object.freeze({
|
|
28905
|
-
"claude-code": ["claude plugin marketplace add mksglu/context-mode
|
|
28906
|
-
codex: ["codex plugin marketplace add mksglu/context-mode
|
|
28907
|
-
gemini: ["gemini extensions install https://github.com/mksglu/context-mode
|
|
28908
|
-
qwen: ["qwen extensions install https://github.com/mksglu/context-mode:context-mode
|
|
28909
|
-
opencode: ["opencode plugin add context-mode
|
|
28910
|
-
pi: ["pi install npm:context-mode
|
|
28911
|
-
"copilot-cli": ["npm i -g context-mode
|
|
28912
|
-
vscode: ["npm i -g context-mode
|
|
28913
|
-
kiro: ["npm i -g context-mode
|
|
28914
|
-
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"]
|
|
28915
28934
|
});
|
|
28916
28935
|
var ISSUE_FORM_URL = `https://github.com/${ISSUE_REPO_SLUG}/issues/new?template=${ISSUE_FORM_FILE}`;
|
|
28917
28936
|
var DOCTOR_GIT_VERSION_TIMEOUT_MS = 5e3;
|
|
@@ -29378,14 +29397,29 @@ function copilotDirOf(env, home) {
|
|
|
29378
29397
|
function kiroDirOf(env, home, platform = process.platform) {
|
|
29379
29398
|
const p = platform === "win32" ? win32 : posix;
|
|
29380
29399
|
const fallback = p.join(home, ...AGENT_HOME_DIR.kiro);
|
|
29381
|
-
const dir = env[KIRO_HOME_ENV];
|
|
29400
|
+
const dir = env[KIRO_HOME_ENV]?.trim();
|
|
29382
29401
|
if (dir === void 0 || dir === "" || !p.isAbsolute(dir)) return fallback;
|
|
29383
29402
|
if (platform === "win32" && p.parse(dir).root.length < 2) return fallback;
|
|
29384
29403
|
const abs = p.resolve(dir);
|
|
29385
|
-
|
|
29386
|
-
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)));
|
|
29387
29408
|
if (!p.isAbsolute(up) && up.split(p.sep)[0] !== "..") return fallback;
|
|
29388
|
-
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
|
+
}
|
|
29389
29423
|
}
|
|
29390
29424
|
function claudeDirOf(env, home) {
|
|
29391
29425
|
const dir = env[CLAUDE_CONFIG_DIR_ENV];
|
|
@@ -43825,7 +43859,7 @@ function cutPoint(src, start, end, scratch) {
|
|
|
43825
43859
|
const r = encoder.encodeInto(src.slice(start, limit), scratch);
|
|
43826
43860
|
return { end: start + r.read, written: r.written };
|
|
43827
43861
|
}
|
|
43828
|
-
function merge4(src, blocks,
|
|
43862
|
+
function merge4(src, blocks, join26, cap, lineCut) {
|
|
43829
43863
|
const out = [];
|
|
43830
43864
|
const scratch = new Uint8Array(cap);
|
|
43831
43865
|
let wide;
|
|
@@ -43835,7 +43869,7 @@ function merge4(src, blocks, join25, cap, lineCut) {
|
|
|
43835
43869
|
out.push({ ord: out.length, text: src.slice(start, end), bytes: bytes5 });
|
|
43836
43870
|
};
|
|
43837
43871
|
for (const b of blocks) {
|
|
43838
|
-
if (cur !== void 0 && !
|
|
43872
|
+
if (cur !== void 0 && !join26) {
|
|
43839
43873
|
emit(cur.start, cur.end, curBytes);
|
|
43840
43874
|
cur = void 0;
|
|
43841
43875
|
}
|
|
@@ -44763,8 +44797,8 @@ var ctxBatch = Object.freeze({
|
|
|
44763
44797
|
});
|
|
44764
44798
|
|
|
44765
44799
|
// src/core/tools/doctor.ts
|
|
44766
|
-
import { readdirSync as readdirSync7, readFileSync as readFileSync10, existsSync as
|
|
44767
|
-
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";
|
|
44768
44802
|
|
|
44769
44803
|
// src/adapters/claude-code.ts
|
|
44770
44804
|
var TOOL_NAME_PREFIX = "mcp__plugin_context-mode_context-mode__";
|
|
@@ -44795,9 +44829,28 @@ function outputOf(resp) {
|
|
|
44795
44829
|
return err === "" ? out : out === "" ? err : out + "\n" + err;
|
|
44796
44830
|
}
|
|
44797
44831
|
}
|
|
44798
|
-
if (typeof resp === "object" && resp !== null &&
|
|
44832
|
+
if (typeof resp === "object" && resp !== null && !Array.isArray(resp)) {
|
|
44833
|
+
const slot = textSlot(resp);
|
|
44834
|
+
if (slot !== null) return slot.text;
|
|
44835
|
+
}
|
|
44799
44836
|
return JSON.stringify(resp);
|
|
44800
44837
|
}
|
|
44838
|
+
function textSlot(r) {
|
|
44839
|
+
const file2 = r.file;
|
|
44840
|
+
if (r.type === "text" && typeof file2 === "object" && file2 !== null && typeof file2.content === "string") {
|
|
44841
|
+
return { text: file2.content, put: (o, output) => ({ ...o, file: { ...o.file, content: output } }) };
|
|
44842
|
+
}
|
|
44843
|
+
if (isGrepContent(r)) return { text: r.content, put: (o, output) => ({ ...o, content: output }) };
|
|
44844
|
+
if (Array.isArray(r.filenames) && r.filenames.every((f) => typeof f === "string")) {
|
|
44845
|
+
return { text: r.filenames.join("\n"), put: (o, output) => ({ ...o, filenames: output.split("\n") }) };
|
|
44846
|
+
}
|
|
44847
|
+
if (typeof r.result === "string") return { text: r.result, put: (o, output) => ({ ...o, result: output }) };
|
|
44848
|
+
return null;
|
|
44849
|
+
}
|
|
44850
|
+
function isShellShape(resp) {
|
|
44851
|
+
const r = resp;
|
|
44852
|
+
return typeof r.stdout === "string" || typeof r.stderr === "string";
|
|
44853
|
+
}
|
|
44801
44854
|
function isGrepContent(resp) {
|
|
44802
44855
|
const r = resp;
|
|
44803
44856
|
return r.mode === "content" && typeof r.content === "string";
|
|
@@ -44816,7 +44869,10 @@ function readResult(resp) {
|
|
|
44816
44869
|
const text = outputOf(resp);
|
|
44817
44870
|
const isError = typeof resp === "object" && resp !== null && resp.is_error === true;
|
|
44818
44871
|
const info = { isError, bytes: Buffer.byteLength(text), text };
|
|
44819
|
-
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) &&
|
|
44872
|
+
if (typeof resp === "object" && resp !== null && !Array.isArray(resp) && !isShellShape(resp)) {
|
|
44873
|
+
if (textSlot(resp) !== null) info.shape = resp;
|
|
44874
|
+
else info.keep = true;
|
|
44875
|
+
}
|
|
44820
44876
|
if (Array.isArray(resp)) {
|
|
44821
44877
|
info.blocks = true;
|
|
44822
44878
|
if (blocksOf(resp).keep) info.keep = true;
|
|
@@ -44853,7 +44909,9 @@ function decodeClaudeShape(raw, agent, ownPrefix, sources) {
|
|
|
44853
44909
|
}
|
|
44854
44910
|
function replaceShape(ev, output) {
|
|
44855
44911
|
if (ev.tool?.canonicalName === "Bash") return { stdout: output, stderr: "", interrupted: false };
|
|
44856
|
-
|
|
44912
|
+
const shape = ev.result?.shape;
|
|
44913
|
+
const slot = shape === void 0 ? null : textSlot(shape);
|
|
44914
|
+
if (shape !== void 0 && slot !== null) return slot.put(shape, output);
|
|
44857
44915
|
if (ev.result?.blocks === true) return [{ type: "text", text: output }];
|
|
44858
44916
|
return output;
|
|
44859
44917
|
}
|
|
@@ -45246,7 +45304,8 @@ function encode8(ev, d, _extra) {
|
|
|
45246
45304
|
}
|
|
45247
45305
|
|
|
45248
45306
|
// src/adapters/kiro.ts
|
|
45249
|
-
var TOOL_NAME_PREFIX7 = "
|
|
45307
|
+
var TOOL_NAME_PREFIX7 = "mcp_context_mode_";
|
|
45308
|
+
var LEGACY_TOOL_NAME_PREFIX = "mcp_context-mode_";
|
|
45250
45309
|
var KIRO_EVENTS = {
|
|
45251
45310
|
SessionStart: "SessionStart",
|
|
45252
45311
|
agentSpawn: "SessionStart",
|
|
@@ -45258,6 +45317,7 @@ var KIRO_EVENTS = {
|
|
|
45258
45317
|
PostToolUse: "PostToolUse",
|
|
45259
45318
|
postToolUse: "PostToolUse"
|
|
45260
45319
|
};
|
|
45320
|
+
var PROMPT_FIELD = "prompt";
|
|
45261
45321
|
var PROMPT_ENV = "USER_PROMPT";
|
|
45262
45322
|
var MCP_PREFIX3 = "mcp_";
|
|
45263
45323
|
var SHELL_TOOL_NAMES4 = Object.freeze(["execute_bash", "execute_pwsh", "shell"]);
|
|
@@ -45266,6 +45326,7 @@ var MCP_SEP3 = "_";
|
|
|
45266
45326
|
var KIRO_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
|
|
45267
45327
|
function canonicalName5(name) {
|
|
45268
45328
|
if (name.startsWith(TOOL_NAME_PREFIX7)) return name.slice(TOOL_NAME_PREFIX7.length);
|
|
45329
|
+
if (name.startsWith(LEGACY_TOOL_NAME_PREFIX)) return name.slice(LEGACY_TOOL_NAME_PREFIX.length);
|
|
45269
45330
|
if (Object.hasOwn(NATIVE_TO_CANONICAL5, name)) return NATIVE_TO_CANONICAL5[name];
|
|
45270
45331
|
if (!name.startsWith(MCP_PREFIX3)) return name;
|
|
45271
45332
|
const rest = name.slice(MCP_PREFIX3.length);
|
|
@@ -45286,7 +45347,8 @@ function decode9(raw) {
|
|
|
45286
45347
|
const ev = { event, agent: "kiro", sessionId: String(p.session_id ?? ""), cwd: String(p.cwd ?? "") };
|
|
45287
45348
|
if (event === "SessionStart" && typeof p.source === "string" && KIRO_SOURCES[p.source] !== void 0) ev.source = KIRO_SOURCES[p.source];
|
|
45288
45349
|
if (event === "UserPromptSubmit") {
|
|
45289
|
-
const
|
|
45350
|
+
const field = p[PROMPT_FIELD];
|
|
45351
|
+
const prompt = typeof field === "string" ? field : process.env[PROMPT_ENV];
|
|
45290
45352
|
if (prompt !== void 0) ev.prompt = prompt;
|
|
45291
45353
|
}
|
|
45292
45354
|
if (event === "PreToolUse" || event === "PostToolUse") {
|
|
@@ -45298,7 +45360,7 @@ function decode9(raw) {
|
|
|
45298
45360
|
return ev;
|
|
45299
45361
|
}
|
|
45300
45362
|
function encode9(ev, d, _extra) {
|
|
45301
|
-
if (ev.event === "UserPromptSubmit") return { stdout: "", exitCode: 0 };
|
|
45363
|
+
if (ev.event === "UserPromptSubmit") return { stdout: d.kind === "hint" ? d.text : "", exitCode: 0 };
|
|
45302
45364
|
switch (d.kind) {
|
|
45303
45365
|
case "allow":
|
|
45304
45366
|
return { stdout: "", exitCode: 0 };
|
|
@@ -45657,18 +45719,40 @@ function getAdapter(id) {
|
|
|
45657
45719
|
return BY_ID.get(id);
|
|
45658
45720
|
}
|
|
45659
45721
|
|
|
45722
|
+
// src/core/ops/bundle-dir.ts
|
|
45723
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
45724
|
+
import { dirname as dirname4, join as join6 } from "node:path";
|
|
45725
|
+
import { fileURLToPath } from "node:url";
|
|
45726
|
+
function bundleDirOf(argv1, moduleFile) {
|
|
45727
|
+
const own4 = dirname4(argv1);
|
|
45728
|
+
if (existsSync4(join6(own4, SERVER_ENTRY_FILE))) return own4;
|
|
45729
|
+
let dir = dirname4(moduleFile);
|
|
45730
|
+
for (; ; ) {
|
|
45731
|
+
if (existsSync4(join6(dir, SERVER_ENTRY_FILE))) return dir;
|
|
45732
|
+
const up = dirname4(dir);
|
|
45733
|
+
if (up === dir) return own4;
|
|
45734
|
+
dir = up;
|
|
45735
|
+
}
|
|
45736
|
+
}
|
|
45737
|
+
var memo4;
|
|
45738
|
+
function ownBundleDir() {
|
|
45739
|
+
const argv1 = process.argv[1] ?? "";
|
|
45740
|
+
if (memo4?.argv1 !== argv1) memo4 = { argv1, dir: bundleDirOf(argv1, fileURLToPath(import.meta.url)) };
|
|
45741
|
+
return memo4.dir;
|
|
45742
|
+
}
|
|
45743
|
+
|
|
45660
45744
|
// src/core/ops/doctor-config.ts
|
|
45661
|
-
import { existsSync as
|
|
45662
|
-
import { join as
|
|
45745
|
+
import { existsSync as existsSync8, readdirSync as readdirSync6 } from "node:fs";
|
|
45746
|
+
import { join as join10 } from "node:path";
|
|
45663
45747
|
|
|
45664
45748
|
// src/core/ops/detect-v1.ts
|
|
45665
|
-
import { existsSync as
|
|
45749
|
+
import { existsSync as existsSync6, opendirSync, readdirSync as readdirSync4, readFileSync as readFileSync5 } from "node:fs";
|
|
45666
45750
|
import { tmpdir } from "node:os";
|
|
45667
|
-
import { join as
|
|
45751
|
+
import { join as join8 } from "node:path";
|
|
45668
45752
|
|
|
45669
45753
|
// src/core/ops/host-config.ts
|
|
45670
|
-
import { existsSync as
|
|
45671
|
-
import { dirname as
|
|
45754
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
|
|
45755
|
+
import { dirname as dirname5, join as join7 } from "node:path";
|
|
45672
45756
|
|
|
45673
45757
|
// node_modules/eslint-visitor-keys/lib/visitor-keys.js
|
|
45674
45758
|
var KEYS2 = {
|
|
@@ -47808,10 +47892,10 @@ function formatOf(path7) {
|
|
|
47808
47892
|
function readHostConfig(agent, path7) {
|
|
47809
47893
|
let file2 = path7;
|
|
47810
47894
|
if (agent === "opencode") {
|
|
47811
|
-
const jsonc =
|
|
47812
|
-
if (
|
|
47895
|
+
const jsonc = join7(dirname5(path7), OPENCODE_CONFIG_FILES[0]);
|
|
47896
|
+
if (existsSync5(jsonc)) file2 = jsonc;
|
|
47813
47897
|
}
|
|
47814
|
-
const raw =
|
|
47898
|
+
const raw = existsSync5(file2) ? readFileSync4(file2, "utf8") : "";
|
|
47815
47899
|
return { agent, text: hostText(raw), format: agent === "opencode" && !file2.endsWith(TOML_EXT) ? "jsonc" : formatOf(file2), path: file2, layout: hostLayout(raw) };
|
|
47816
47900
|
}
|
|
47817
47901
|
function stripJsonComments(text) {
|
|
@@ -48156,7 +48240,7 @@ function setText(agent, path7, text, format, key, value) {
|
|
|
48156
48240
|
}
|
|
48157
48241
|
}
|
|
48158
48242
|
function serverScript() {
|
|
48159
|
-
return
|
|
48243
|
+
return join7(dirname5(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
|
|
48160
48244
|
}
|
|
48161
48245
|
function isNodeCommand(command) {
|
|
48162
48246
|
if (typeof command !== "string") return false;
|
|
@@ -48172,7 +48256,7 @@ function ownMcpValue(agent, node3, server) {
|
|
|
48172
48256
|
return { ...mcp.fields, [MCP_COMMAND_FIELD]: node3, [MCP_ARGS_FIELD]: [server, AGENT_ARG, agent, ...tail] };
|
|
48173
48257
|
}
|
|
48174
48258
|
function opencodePluginFile() {
|
|
48175
|
-
return
|
|
48259
|
+
return ownBundleDir();
|
|
48176
48260
|
}
|
|
48177
48261
|
function listTarget(key, own4, v1, alt = []) {
|
|
48178
48262
|
return {
|
|
@@ -48331,7 +48415,7 @@ function flatCommands(events, prefix) {
|
|
|
48331
48415
|
var isV1Hook = (cmd) => cmd.includes(SERVER_KEY) && (V1_SCRIPT_NAMES.some((name) => cmd.includes(name)) || cmd.includes(V1_HOOK_COMMAND));
|
|
48332
48416
|
var isCodexScript = (cmd) => cmd.includes(V1_SCRIPT_EXT) && V1_PATH_SEPS.some((sep3) => cmd.includes(V1_CODEX_HOOKS_DIR.join(sep3) + sep3));
|
|
48333
48417
|
function dataDir(dir, reason, out) {
|
|
48334
|
-
if (
|
|
48418
|
+
if (existsSync6(dir)) out.push(finding(dir, "", reason));
|
|
48335
48419
|
}
|
|
48336
48420
|
function mcpEntry(file2, doc, out) {
|
|
48337
48421
|
if (isObj(doc) && isObj(doc[MCP_SERVERS_KEY]) && Object.hasOwn(doc[MCP_SERVERS_KEY], SERVER_KEY)) {
|
|
@@ -48339,7 +48423,7 @@ function mcpEntry(file2, doc, out) {
|
|
|
48339
48423
|
}
|
|
48340
48424
|
}
|
|
48341
48425
|
function claudeShapeSettings(agentHome, out) {
|
|
48342
|
-
const file2 =
|
|
48426
|
+
const file2 = join8(agentHome, SETTINGS_FILE);
|
|
48343
48427
|
const doc = readJson(file2);
|
|
48344
48428
|
for (const c of nestedCommands(doc)) {
|
|
48345
48429
|
if (c.command.includes(V1_CACHE_HEAL_NAME)) out.push(finding(file2, c.path, V1_REASON.cacheHealHook));
|
|
@@ -48359,49 +48443,49 @@ function v1HookFile(file2, out) {
|
|
|
48359
48443
|
function scanClaudeCode(home, agentHome, out) {
|
|
48360
48444
|
claudeShapeSettings(agentHome, out);
|
|
48361
48445
|
for (const ext of V1_CACHE_HEAL_EXTS) {
|
|
48362
|
-
const file2 =
|
|
48363
|
-
if (
|
|
48446
|
+
const file2 = join8(agentHome, V1_HOOKS_DIR_NAME, V1_CACHE_HEAL_NAME + ext);
|
|
48447
|
+
if (existsSync6(file2)) out.push(finding(file2, "", V1_REASON.cacheHealFile));
|
|
48364
48448
|
}
|
|
48365
|
-
const userFile =
|
|
48449
|
+
const userFile = join8(home, CLAUDE_USER_CONFIG_FILE);
|
|
48366
48450
|
mcpEntry(userFile, readJson(userFile), out);
|
|
48367
|
-
dataDir(
|
|
48451
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48368
48452
|
}
|
|
48369
48453
|
function scanCodex(agentHome, out) {
|
|
48370
|
-
const hooksFile =
|
|
48454
|
+
const hooksFile = join8(agentHome, HOOKS_JSON_FILE);
|
|
48371
48455
|
for (const c of nestedCommands(readJson(hooksFile))) {
|
|
48372
48456
|
if (c.command.includes(V1_CODEX_HOOK_COMMAND) || isCodexScript(c.command)) {
|
|
48373
48457
|
out.push(finding(hooksFile, c.path, V1_REASON.codexHook));
|
|
48374
48458
|
}
|
|
48375
48459
|
}
|
|
48376
|
-
const tomlFile =
|
|
48460
|
+
const tomlFile = join8(agentHome, CONFIG_TOML_FILE);
|
|
48377
48461
|
const config4 = readTomlValue(tomlFile);
|
|
48378
48462
|
for (const span2 of readTomlTables(tomlFile)) {
|
|
48379
48463
|
if (span2.path[0] !== V1_TOML_SECTION_ROOT || span2.path[1] !== SERVER_KEY) continue;
|
|
48380
48464
|
if (span2.path.length === 2 && isV2McpTable(hostConfigValueAt(config4, span2.path))) continue;
|
|
48381
48465
|
out.push(finding(tomlFile, span2.header.trim(), V1_REASON.codexToml));
|
|
48382
48466
|
}
|
|
48383
|
-
dataDir(
|
|
48467
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48384
48468
|
}
|
|
48385
48469
|
function scanGemini(agentHome, out) {
|
|
48386
|
-
const file2 =
|
|
48470
|
+
const file2 = join8(agentHome, SETTINGS_FILE);
|
|
48387
48471
|
for (const c of nestedCommands(readJson(file2))) {
|
|
48388
48472
|
if (c.command.includes(SERVER_KEY)) out.push(finding(file2, c.path, V1_REASON.hook));
|
|
48389
48473
|
}
|
|
48390
|
-
dataDir(
|
|
48474
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDirShared, out);
|
|
48391
48475
|
}
|
|
48392
48476
|
function scanVscode(agentHome, project, out) {
|
|
48393
48477
|
if (project !== void 0) {
|
|
48394
|
-
v1HookFile(
|
|
48395
|
-
const mcpFile2 =
|
|
48478
|
+
v1HookFile(join8(project, GITHUB_DIR_NAME, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
|
|
48479
|
+
const mcpFile2 = join8(project, VSCODE_DIR_NAME, VSCODE_MCP_FILE);
|
|
48396
48480
|
const doc = readJson(mcpFile2);
|
|
48397
48481
|
const servers = isObj(doc) && isObj(doc[VSCODE_MCP_SERVERS_KEY]) ? doc[VSCODE_MCP_SERVERS_KEY] : {};
|
|
48398
48482
|
const entry = Object.hasOwn(servers, SERVER_KEY) ? servers[SERVER_KEY] : void 0;
|
|
48399
48483
|
if (isObj(entry) && (entry.command === V1_BIN_COMMAND || listOf(entry.args).some((a) => a === V1_BIN_COMMAND))) {
|
|
48400
48484
|
out.push(finding(mcpFile2, keyPath(VSCODE_MCP_SERVERS_KEY, SERVER_KEY), V1_REASON.vscodeMcp));
|
|
48401
48485
|
}
|
|
48402
|
-
dataDir(
|
|
48486
|
+
dataDir(join8(project, GITHUB_DIR_NAME, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
|
|
48403
48487
|
}
|
|
48404
|
-
dataDir(
|
|
48488
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
|
|
48405
48489
|
}
|
|
48406
48490
|
function jsonFiles(dir) {
|
|
48407
48491
|
try {
|
|
@@ -48411,10 +48495,10 @@ function jsonFiles(dir) {
|
|
|
48411
48495
|
}
|
|
48412
48496
|
}
|
|
48413
48497
|
function scanKiro(agentHome, project, out) {
|
|
48414
|
-
const agentsDir =
|
|
48415
|
-
const defaultFile =
|
|
48498
|
+
const agentsDir = join8(agentHome, KIRO_AGENTS_DIR);
|
|
48499
|
+
const defaultFile = join8(agentHome, ...KIRO_AGENT_FILE);
|
|
48416
48500
|
for (const name of jsonFiles(agentsDir)) {
|
|
48417
|
-
const file2 =
|
|
48501
|
+
const file2 = join8(agentsDir, name);
|
|
48418
48502
|
const doc = readJson(file2);
|
|
48419
48503
|
if (isObj(doc) && doc[KIRO_AGENT_NAME_KEY] === SERVER_KEY) {
|
|
48420
48504
|
out.push(finding(file2, "", V1_REASON.kiroAgentFile));
|
|
@@ -48425,25 +48509,25 @@ function scanKiro(agentHome, project, out) {
|
|
|
48425
48509
|
if (isV1Hook(c.command)) out.push(finding(file2, c.path, V1_REASON.kiroHook));
|
|
48426
48510
|
}
|
|
48427
48511
|
}
|
|
48428
|
-
const steeringDocs = [
|
|
48429
|
-
if (project !== void 0) steeringDocs.push(
|
|
48512
|
+
const steeringDocs = [join8(agentHome, ...KIRO_STEERING_FILE)];
|
|
48513
|
+
if (project !== void 0) steeringDocs.push(join8(project, ...AGENT_HOME_DIR.kiro, ...KIRO_STEERING_FILE));
|
|
48430
48514
|
for (const file2 of steeringDocs) {
|
|
48431
|
-
if (
|
|
48515
|
+
if (existsSync6(file2)) out.push(finding(file2, "", V1_REASON.kiroSteering));
|
|
48432
48516
|
}
|
|
48433
|
-
dataDir(
|
|
48517
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48434
48518
|
}
|
|
48435
48519
|
function scanPi(piAgentDir, agentHome, out) {
|
|
48436
|
-
const file2 =
|
|
48520
|
+
const file2 = join8(piAgentDir, SETTINGS_FILE);
|
|
48437
48521
|
const doc = readJson(file2);
|
|
48438
48522
|
listOf(isObj(doc) ? doc[PI_PACKAGES_KEY] : void 0).forEach((pkg, i) => {
|
|
48439
48523
|
const spec = isObj(pkg) ? pkg[PI_PACKAGE_SOURCE_KEY] : pkg;
|
|
48440
48524
|
if (spec === V1_PI_PACKAGE) out.push(finding(file2, keyPath(PI_PACKAGES_KEY, i), V1_REASON.piNpm));
|
|
48441
48525
|
});
|
|
48442
|
-
dataDir(
|
|
48526
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48443
48527
|
}
|
|
48444
48528
|
function scanOpencode(agentHome, out) {
|
|
48445
48529
|
for (const name of OPENCODE_CONFIG_FILES) {
|
|
48446
|
-
const file2 =
|
|
48530
|
+
const file2 = join8(agentHome, name);
|
|
48447
48531
|
const doc = readJson(file2);
|
|
48448
48532
|
if (!isObj(doc) || !Array.isArray(doc[OPENCODE_PLUGIN_KEY])) continue;
|
|
48449
48533
|
doc[OPENCODE_PLUGIN_KEY].forEach((spec, i) => {
|
|
@@ -48453,13 +48537,13 @@ function scanOpencode(agentHome, out) {
|
|
|
48453
48537
|
}
|
|
48454
48538
|
}
|
|
48455
48539
|
function scanZcode(agentHome, out) {
|
|
48456
|
-
const configFile =
|
|
48540
|
+
const configFile = join8(agentHome, ZCODE_CLI_DIR, CONFIG_JSON_FILE);
|
|
48457
48541
|
const config4 = readJson(configFile);
|
|
48458
48542
|
const events = isObj(config4) && isObj(config4[HOOKS_KEY]) ? config4[HOOKS_KEY][ZCODE_EVENTS_KEY] : void 0;
|
|
48459
48543
|
for (const c of flatCommands(events, [HOOKS_KEY, ZCODE_EVENTS_KEY])) {
|
|
48460
48544
|
if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(configFile, c.path, V1_REASON.zcodeHook));
|
|
48461
48545
|
}
|
|
48462
|
-
const hooksFile =
|
|
48546
|
+
const hooksFile = join8(agentHome, ZCODE_CLI_DIR, HOOKS_JSON_FILE);
|
|
48463
48547
|
for (const c of nestedCommands(readJson(hooksFile))) {
|
|
48464
48548
|
if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(hooksFile, c.path, V1_REASON.zcodeHook));
|
|
48465
48549
|
}
|
|
@@ -48483,14 +48567,14 @@ function firstTmpMatch(dir) {
|
|
|
48483
48567
|
}
|
|
48484
48568
|
}
|
|
48485
48569
|
function scanAll(home, tmp, out) {
|
|
48486
|
-
const root =
|
|
48487
|
-
for (const name of V1_DATA_ROOT_ENTRIES) dataDir(
|
|
48570
|
+
const root = join8(home, DATA_ROOT.slice(1));
|
|
48571
|
+
for (const name of V1_DATA_ROOT_ENTRIES) dataDir(join8(root, name), V1_REASON.dataRoot, out);
|
|
48488
48572
|
if (firstTmpMatch(tmp) !== null) out.push(finding(tmp, V1_TMP_PREFIX + "*", V1_REASON.tmpFile));
|
|
48489
48573
|
}
|
|
48490
48574
|
function detectV1(agent, home, scope = {}) {
|
|
48491
48575
|
const out = [];
|
|
48492
48576
|
const project = scope.project;
|
|
48493
|
-
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 :
|
|
48577
|
+
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]);
|
|
48494
48578
|
switch (agent) {
|
|
48495
48579
|
case "claude-code":
|
|
48496
48580
|
scanClaudeCode(home, agentHome, out);
|
|
@@ -48503,11 +48587,11 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48503
48587
|
break;
|
|
48504
48588
|
case "qwen":
|
|
48505
48589
|
claudeShapeSettings(agentHome, out);
|
|
48506
|
-
dataDir(
|
|
48590
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48507
48591
|
break;
|
|
48508
48592
|
case "copilot-cli":
|
|
48509
|
-
v1HookFile(
|
|
48510
|
-
dataDir(
|
|
48593
|
+
v1HookFile(join8(agentHome, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
|
|
48594
|
+
dataDir(join8(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48511
48595
|
break;
|
|
48512
48596
|
case "vscode":
|
|
48513
48597
|
scanVscode(agentHome, project, out);
|
|
@@ -48516,7 +48600,7 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48516
48600
|
scanKiro(agentHome, project, out);
|
|
48517
48601
|
break;
|
|
48518
48602
|
case "pi":
|
|
48519
|
-
scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir :
|
|
48603
|
+
scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir : join8(agentHome, PI_AGENT_DIR), agentHome, out);
|
|
48520
48604
|
break;
|
|
48521
48605
|
// D-WIN-PIDIR-1: empty is unset
|
|
48522
48606
|
case "opencode":
|
|
@@ -48531,9 +48615,9 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48531
48615
|
}
|
|
48532
48616
|
|
|
48533
48617
|
// src/core/ops/plugin-root.ts
|
|
48534
|
-
import { existsSync as
|
|
48535
|
-
import { dirname as
|
|
48536
|
-
import { fileURLToPath } from "node:url";
|
|
48618
|
+
import { existsSync as existsSync7, readdirSync as readdirSync5, readFileSync as readFileSync6, realpathSync as realpathSync4 } from "node:fs";
|
|
48619
|
+
import { dirname as dirname6, isAbsolute, join as join9, sep as sep2 } from "node:path";
|
|
48620
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
48537
48621
|
function missing(agent, path7) {
|
|
48538
48622
|
return new CtxError("PLUGIN_ROOT_MISSING", { agent, path: path7 });
|
|
48539
48623
|
}
|
|
@@ -48580,8 +48664,8 @@ var readOrNull = (file2) => {
|
|
|
48580
48664
|
};
|
|
48581
48665
|
var samePath = (a, b) => a === b || (realOrNull(a) ?? a) === (realOrNull(b) ?? b);
|
|
48582
48666
|
function enabledPlugins(claudeDir, project) {
|
|
48583
|
-
const files = [
|
|
48584
|
-
if (project !== void 0) files.push(
|
|
48667
|
+
const files = [join9(claudeDir, SETTINGS_FILE)];
|
|
48668
|
+
if (project !== void 0) files.push(join9(project, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), join9(project, HOST_CONFIG_DIR_NAME, SETTINGS_LOCAL_FILE));
|
|
48585
48669
|
const out = {};
|
|
48586
48670
|
for (const file2 of files) {
|
|
48587
48671
|
const text = readOrNull(file2);
|
|
@@ -48594,13 +48678,13 @@ function enabledPlugins(claudeDir, project) {
|
|
|
48594
48678
|
function marketplaceChoice(env, worktree) {
|
|
48595
48679
|
const claudeDir = claudeDirOf(env, requireHomeDir(env));
|
|
48596
48680
|
const script = process.argv[1];
|
|
48597
|
-
const ownReal = script === void 0 || script === "" ? null : realOrNull(
|
|
48681
|
+
const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
|
|
48598
48682
|
const hostRoot = env[CLAUDE_PLUGIN_ROOT_ENV];
|
|
48599
48683
|
if (ownReal !== null && hostRoot !== void 0 && hostRoot !== "" && realOrNull(hostRoot) === ownReal) return { root: ownReal };
|
|
48600
|
-
const record6 = readOrNull(
|
|
48684
|
+
const record6 = readOrNull(join9(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE));
|
|
48601
48685
|
const recorded = record6 === null ? [] : recordedInstalls(record6);
|
|
48602
48686
|
if (recorded.length === 0) return { record: false };
|
|
48603
|
-
const live = recorded.filter((r) =>
|
|
48687
|
+
const live = recorded.filter((r) => existsSync7(r.installPath));
|
|
48604
48688
|
const mine = live.find((r) => realOrNull(r.installPath) === ownReal);
|
|
48605
48689
|
if (mine !== void 0) return { root: mine.installPath };
|
|
48606
48690
|
const dirs = live.filter((r, i) => live.findIndex((o) => samePath(o.installPath, r.installPath)) === i);
|
|
@@ -48620,18 +48704,18 @@ function marketplaceChoice(env, worktree) {
|
|
|
48620
48704
|
}
|
|
48621
48705
|
function marketplaceRoot(adapter, env, worktree) {
|
|
48622
48706
|
const claudeDir = claudeDirOf(env, requireHomeDir(env));
|
|
48623
|
-
const plugins =
|
|
48624
|
-
const cache =
|
|
48707
|
+
const plugins = join9(claudeDir, HOST_PLUGINS_DIR_NAME);
|
|
48708
|
+
const cache = join9(plugins, PLUGIN_CACHE_DIR_NAME);
|
|
48625
48709
|
const script = process.argv[1];
|
|
48626
|
-
const ownReal = script === void 0 || script === "" ? null : realOrNull(
|
|
48710
|
+
const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
|
|
48627
48711
|
const choice = marketplaceChoice(env, worktree);
|
|
48628
48712
|
if ("root" in choice) return choice.root;
|
|
48629
48713
|
if ("installs" in choice) throw missing(adapter.id, choice.installs.map((r) => r.installPath).join(", "));
|
|
48630
48714
|
const cacheReal = realOrNull(cache);
|
|
48631
|
-
if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep2) &&
|
|
48632
|
-
const pattern =
|
|
48633
|
-
if (!
|
|
48634
|
-
const found = readdirSync5(cache).sort().map((marketplace) =>
|
|
48715
|
+
if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep2) && existsSync7(join9(ownReal, SERVER_ENTRY_FILE))) return ownReal;
|
|
48716
|
+
const pattern = join9(cache, "*", PLUGIN_NAME);
|
|
48717
|
+
if (!existsSync7(cache)) throw missing(adapter.id, pattern);
|
|
48718
|
+
const found = readdirSync5(cache).sort().map((marketplace) => join9(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync7(dir));
|
|
48635
48719
|
if (found.length !== 1) throw missing(adapter.id, found.length === 0 ? pattern : found.join(", "));
|
|
48636
48720
|
return found[0];
|
|
48637
48721
|
}
|
|
@@ -48639,13 +48723,13 @@ function configEntryRoot(adapter, env) {
|
|
|
48639
48723
|
const spec = OWN_MCP_ENTRY[adapter.id];
|
|
48640
48724
|
if (spec === void 0) throw missing(adapter.id, SERVER_KEY);
|
|
48641
48725
|
const file2 = ownMcpFileOf(adapter.id, spec.file, env, requireHomeDir(env));
|
|
48642
|
-
if (!
|
|
48726
|
+
if (!existsSync7(file2)) throw missing(adapter.id, file2);
|
|
48643
48727
|
const current = readHostConfig(adapter.id, file2);
|
|
48644
48728
|
const value = parseHostConfig(adapter.id, file2, current.text, current.format);
|
|
48645
48729
|
const args = hostConfigValueAt(value, [...spec.key, MCP_ARGS_FIELD]);
|
|
48646
48730
|
const script = Array.isArray(args) ? args[0] : void 0;
|
|
48647
48731
|
if (typeof script !== "string" || !isAbsolute(script)) throw missing(adapter.id, file2);
|
|
48648
|
-
return
|
|
48732
|
+
return dirname6(script);
|
|
48649
48733
|
}
|
|
48650
48734
|
function candidate(adapter, env, worktree) {
|
|
48651
48735
|
switch (adapter.installMode) {
|
|
@@ -48656,11 +48740,11 @@ function candidate(adapter, env, worktree) {
|
|
|
48656
48740
|
case "hooks+mcp":
|
|
48657
48741
|
return configEntryRoot(adapter, env);
|
|
48658
48742
|
case "extension":
|
|
48659
|
-
return
|
|
48743
|
+
return join9(requireHomeDir(env), ...AGENT_HOME_DIR[adapter.id], EXTENSIONS_DIR_NAME, PLUGIN_NAME);
|
|
48660
48744
|
case "plugin":
|
|
48661
|
-
return
|
|
48745
|
+
return join9(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
|
|
48662
48746
|
case "in-process":
|
|
48663
|
-
return
|
|
48747
|
+
return dirname6(fileURLToPath2(import.meta.url));
|
|
48664
48748
|
}
|
|
48665
48749
|
}
|
|
48666
48750
|
function resolvePluginRoot(adapter, env, worktree) {
|
|
@@ -48749,11 +48833,11 @@ function ownHooks(block, shape, timeoutKey, native, agent) {
|
|
|
48749
48833
|
var validTimeout = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
48750
48834
|
function mcpFile(row5, home, env) {
|
|
48751
48835
|
const spec = OWN_MCP_ENTRY[row5.id];
|
|
48752
|
-
if (row5.id === "codex") return
|
|
48836
|
+
if (row5.id === "codex") return join10(codexDirOf(env, home), CONFIG_TOML_FILE);
|
|
48753
48837
|
if (spec !== void 0) return ownMcpFileOf(row5.id, spec.file, env, home);
|
|
48754
|
-
if (row5.id === "opencode") return
|
|
48838
|
+
if (row5.id === "opencode") return join10(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
|
|
48755
48839
|
if (row5.id === "pi") {
|
|
48756
|
-
return
|
|
48840
|
+
return join10(piAgentDirOf(env, home), SETTINGS_FILE);
|
|
48757
48841
|
}
|
|
48758
48842
|
return null;
|
|
48759
48843
|
}
|
|
@@ -48766,27 +48850,27 @@ function codexNativeDir(env, home) {
|
|
|
48766
48850
|
const codexDir = codexDirOf(env, home);
|
|
48767
48851
|
let enabled;
|
|
48768
48852
|
try {
|
|
48769
|
-
enabled = hostConfigValueAt(readParsed("codex",
|
|
48853
|
+
enabled = hostConfigValueAt(readParsed("codex", join10(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
|
|
48770
48854
|
} catch {
|
|
48771
48855
|
return null;
|
|
48772
48856
|
}
|
|
48773
48857
|
if (enabled !== true) return null;
|
|
48774
|
-
const cache =
|
|
48775
|
-
if (!
|
|
48858
|
+
const cache = join10(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
|
|
48859
|
+
if (!existsSync8(cache)) return null;
|
|
48776
48860
|
const found = [];
|
|
48777
48861
|
for (const market of readdirSync6(cache)) {
|
|
48778
|
-
const plugin =
|
|
48779
|
-
if (!
|
|
48862
|
+
const plugin = join10(cache, market, SERVER_KEY);
|
|
48863
|
+
if (!existsSync8(plugin)) continue;
|
|
48780
48864
|
for (const version4 of readdirSync6(plugin).sort()) {
|
|
48781
|
-
const dir =
|
|
48782
|
-
if (
|
|
48865
|
+
const dir = join10(plugin, version4, CODEX_PLUGIN_SUBDIR);
|
|
48866
|
+
if (existsSync8(join10(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
|
|
48783
48867
|
}
|
|
48784
48868
|
}
|
|
48785
48869
|
return found.length === 0 ? null : found[found.length - 1];
|
|
48786
48870
|
}
|
|
48787
48871
|
function nativeMcpWrong(dir, row5) {
|
|
48788
48872
|
try {
|
|
48789
|
-
const entry = hostConfigValueAt(readParsed(row5.id,
|
|
48873
|
+
const entry = hostConfigValueAt(readParsed(row5.id, join10(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
|
|
48790
48874
|
if (!isObject4(entry)) return true;
|
|
48791
48875
|
const args = list(entry[MCP_ARGS_FIELD]);
|
|
48792
48876
|
const script = args[0];
|
|
@@ -48795,6 +48879,17 @@ function nativeMcpWrong(dir, row5) {
|
|
|
48795
48879
|
return true;
|
|
48796
48880
|
}
|
|
48797
48881
|
}
|
|
48882
|
+
function isOwnOpencodeEntry(entry, key, own4) {
|
|
48883
|
+
const spec = isObject4(entry) ? entry[OPENCODE_PACKAGE_FIELD] : entry;
|
|
48884
|
+
if (typeof spec !== "string") return false;
|
|
48885
|
+
if (spec === OPENCODE_GIT_SPEC || spec.startsWith(OPENCODE_NPM_SPEC_PREFIX) || own4.includes(spec)) return true;
|
|
48886
|
+
return key === OPENCODE_PLUGINS_KEY && spec === SERVER_KEY;
|
|
48887
|
+
}
|
|
48888
|
+
function opencodeListed(file2) {
|
|
48889
|
+
const { value } = readParsed("opencode", file2);
|
|
48890
|
+
const own4 = [opencodePluginFile()];
|
|
48891
|
+
return [OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own4)));
|
|
48892
|
+
}
|
|
48798
48893
|
function mcpWrong(row5, home, env, worktree) {
|
|
48799
48894
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
48800
48895
|
if (native !== null) return nativeMcpWrong(native, row5);
|
|
@@ -48804,6 +48899,7 @@ function mcpWrong(row5, home, env, worktree) {
|
|
|
48804
48899
|
resolvePluginRoot(row5, env, worktree);
|
|
48805
48900
|
return false;
|
|
48806
48901
|
}
|
|
48902
|
+
if (row5.id === "opencode") return !opencodeListed(file2);
|
|
48807
48903
|
const cur = readHostConfig(row5.id, file2);
|
|
48808
48904
|
return mergeOwnEntries(row5.id, cur.text, cur.format, row5, { nodePath: true, listEntries: [opencodePluginFile()] }).edits.length > 0;
|
|
48809
48905
|
} catch {
|
|
@@ -48813,7 +48909,7 @@ function mcpWrong(row5, home, env, worktree) {
|
|
|
48813
48909
|
function hookFile(row5, spec, home, env, worktree) {
|
|
48814
48910
|
const root = spec.root === "plugin" ? resolvePluginRoot(row5, env, worktree) : spec.root === "home" ? home : worktree;
|
|
48815
48911
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
48816
|
-
const file2 = native !== null ?
|
|
48912
|
+
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);
|
|
48817
48913
|
return file2;
|
|
48818
48914
|
}
|
|
48819
48915
|
function hookParts(row5, home, env, worktree) {
|
|
@@ -48824,7 +48920,7 @@ function hookParts(row5, home, env, worktree) {
|
|
|
48824
48920
|
const file2 = hookFile(row5, spec, home, env, worktree);
|
|
48825
48921
|
block = hostConfigValueAt(readParsed(row5.id, file2).value, spec.key);
|
|
48826
48922
|
if (row5.id === "codex") {
|
|
48827
|
-
const config4 = readParsed(row5.id,
|
|
48923
|
+
const config4 = readParsed(row5.id, join10(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
|
|
48828
48924
|
if (hostConfigValueAt(config4, CODEX_FEATURES_HOOKS_KEY) === false) return [PART_HOOKS];
|
|
48829
48925
|
}
|
|
48830
48926
|
} catch {
|
|
@@ -48870,7 +48966,7 @@ function checkV1Leftovers(agent, home, scope = {}) {
|
|
|
48870
48966
|
if (findings.length === 0) return pass("D4");
|
|
48871
48967
|
const detail = findings.map((f) => f.reason).join(D4_REASON_JOIN);
|
|
48872
48968
|
if (findings.every((f) => f.reason === V1_REASON.tmpFile)) return { ...pass("D4"), detail };
|
|
48873
|
-
return fail("D4", detail, DOCTOR_FIX_UPGRADE);
|
|
48969
|
+
return { ...fail("D4", detail, DOCTOR_FIX_UPGRADE), status: "WARN" };
|
|
48874
48970
|
}
|
|
48875
48971
|
function parsedOrNull(agent, file2, jsonc) {
|
|
48876
48972
|
try {
|
|
@@ -48882,10 +48978,10 @@ function parsedOrNull(agent, file2, jsonc) {
|
|
|
48882
48978
|
}
|
|
48883
48979
|
function checkDoubleFire(agent, worktree) {
|
|
48884
48980
|
if (agent !== "claude-code" && agent !== "vscode") return pass("D5b");
|
|
48885
|
-
const claude = parsedOrNull(agent,
|
|
48981
|
+
const claude = parsedOrNull(agent, join10(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
|
|
48886
48982
|
const hooks = isObject4(claude) ? claude[HOOKS_KEY] : void 0;
|
|
48887
48983
|
const hooksOn = isObject4(hooks) && Object.keys(hooks).length > 0;
|
|
48888
|
-
const vscode = parsedOrNull(agent,
|
|
48984
|
+
const vscode = parsedOrNull(agent, join10(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
|
|
48889
48985
|
const useClaudeHooks = isObject4(vscode) && vscode[VSCODE_CLAUDE_HOOKS_SETTING] === true;
|
|
48890
48986
|
return hooksOn && useClaudeHooks ? fail("D5b", D5B_DETAIL, D5B_FIX) : pass("D5b");
|
|
48891
48987
|
}
|
|
@@ -48896,7 +48992,7 @@ function configPaths(row5, env, worktree) {
|
|
|
48896
48992
|
const mcp = mcpFile(row5, home, env);
|
|
48897
48993
|
if (mcp !== null) out.push({ label: "MCP entry", path: mcp });
|
|
48898
48994
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
48899
|
-
if (native !== null) out.push({ label: "Codex plugin MCP", path:
|
|
48995
|
+
if (native !== null) out.push({ label: "Codex plugin MCP", path: join10(native, CODEX_PLUGIN_MCP_FILE) });
|
|
48900
48996
|
const spec = HOOK_HOST_FILE[row5.id];
|
|
48901
48997
|
if (spec !== null) {
|
|
48902
48998
|
try {
|
|
@@ -48916,7 +49012,7 @@ function configPaths(row5, env, worktree) {
|
|
|
48916
49012
|
}
|
|
48917
49013
|
|
|
48918
49014
|
// src/core/ops/doctor-db.ts
|
|
48919
|
-
import { existsSync as
|
|
49015
|
+
import { existsSync as existsSync9, statSync as statSync4 } from "node:fs";
|
|
48920
49016
|
var unknown4 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail });
|
|
48921
49017
|
var pass2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "PASS", detail });
|
|
48922
49018
|
var fail2 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
|
|
@@ -48958,15 +49054,15 @@ function orphanFiles(dbPath) {
|
|
|
48958
49054
|
const files = [];
|
|
48959
49055
|
for (const suffix of [DB_WAL_SUFFIX, DB_SHM_SUFFIX]) {
|
|
48960
49056
|
const path7 = dbPath + suffix;
|
|
48961
|
-
if (
|
|
49057
|
+
if (existsSync9(path7)) files.push({ path: path7, bytes: statSync4(path7).size });
|
|
48962
49058
|
}
|
|
48963
|
-
return files.length > 0 && !
|
|
49059
|
+
return files.length > 0 && !existsSync9(dbPath) ? files : [];
|
|
48964
49060
|
}
|
|
48965
49061
|
async function checkDb(project) {
|
|
48966
49062
|
const clean = { schemaStale: false, integrityFailed: false, orphan: [] };
|
|
48967
49063
|
const orphan = orphanFiles(project.dbPath);
|
|
48968
49064
|
if (orphan.length > 0) return { row: fail2(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
|
|
48969
|
-
if (!
|
|
49065
|
+
if (!existsSync9(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
|
|
48970
49066
|
const sqlite = await loadSqlite2();
|
|
48971
49067
|
if (sqlite === null) return { row: unknown4("D8", D2_SQLITE_DETAIL), ...clean };
|
|
48972
49068
|
let raw = null;
|
|
@@ -48992,7 +49088,7 @@ async function checkDb(project) {
|
|
|
48992
49088
|
}
|
|
48993
49089
|
}
|
|
48994
49090
|
async function checkIndex(project) {
|
|
48995
|
-
if (!
|
|
49091
|
+
if (!existsSync9(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
|
|
48996
49092
|
const sqlite = await loadSqlite2();
|
|
48997
49093
|
if (sqlite === null) return unknown4("D9", D2_SQLITE_DETAIL);
|
|
48998
49094
|
let raw = null;
|
|
@@ -49009,8 +49105,8 @@ async function checkIndex(project) {
|
|
|
49009
49105
|
}
|
|
49010
49106
|
|
|
49011
49107
|
// src/core/ops/doctor-env.ts
|
|
49012
|
-
import { existsSync as
|
|
49013
|
-
import { isAbsolute as isAbsolute2, join as
|
|
49108
|
+
import { existsSync as existsSync10, readFileSync as readFileSync7, realpathSync as realpathSync5 } from "node:fs";
|
|
49109
|
+
import { isAbsolute as isAbsolute2, join as join11, relative } from "node:path";
|
|
49014
49110
|
function pass3(id, detail = DOCTOR_PASS_DETAIL) {
|
|
49015
49111
|
return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
|
|
49016
49112
|
}
|
|
@@ -49022,7 +49118,7 @@ function fail3(id, detail, fixCommand) {
|
|
|
49022
49118
|
}
|
|
49023
49119
|
function bundleVersion(bundleDir2) {
|
|
49024
49120
|
try {
|
|
49025
|
-
const v = JSON.parse(readFileSync7(
|
|
49121
|
+
const v = JSON.parse(readFileSync7(join11(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
|
|
49026
49122
|
return typeof v === "string" && v !== "" ? v : void 0;
|
|
49027
49123
|
} catch {
|
|
49028
49124
|
return void 0;
|
|
@@ -49172,7 +49268,7 @@ function checkMcp(ctx) {
|
|
|
49172
49268
|
return named2 || versioned ? pass3("D6") : unknown5("D6", D6_UNKNOWN_DETAIL);
|
|
49173
49269
|
}
|
|
49174
49270
|
function piCwdInside(worktree, piCwd) {
|
|
49175
|
-
if (piCwd === void 0 || !
|
|
49271
|
+
if (piCwd === void 0 || !existsSync10(piCwd)) return false;
|
|
49176
49272
|
const rel = relative(worktree, realpathSync5.native(piCwd));
|
|
49177
49273
|
return rel === "" || !rel.startsWith("..") && !isAbsolute2(rel);
|
|
49178
49274
|
}
|
|
@@ -49193,12 +49289,13 @@ function checkShell(env) {
|
|
|
49193
49289
|
}
|
|
49194
49290
|
|
|
49195
49291
|
// src/core/ops/doctor-hook.ts
|
|
49196
|
-
import { existsSync as
|
|
49292
|
+
import { existsSync as existsSync12, mkdtempSync, readFileSync as readFileSync8, realpathSync as realpathSync7, rmSync as rmSync4 } from "node:fs";
|
|
49293
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
49197
49294
|
import path6 from "node:path";
|
|
49198
49295
|
|
|
49199
49296
|
// src/setup/codex-trust.ts
|
|
49200
49297
|
import { createHash } from "node:crypto";
|
|
49201
|
-
import { existsSync as
|
|
49298
|
+
import { existsSync as existsSync11, realpathSync as realpathSync6 } from "node:fs";
|
|
49202
49299
|
import path5 from "node:path";
|
|
49203
49300
|
import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
|
|
49204
49301
|
|
|
@@ -49296,6 +49393,7 @@ var LIST_TIMEOUT_MS = 15e3;
|
|
|
49296
49393
|
var EXIT_GRACE_MS = 5e3;
|
|
49297
49394
|
var PLUGIN_SOURCE = "plugin";
|
|
49298
49395
|
var TRUSTED = "trusted";
|
|
49396
|
+
var UNTRUSTED = "untrusted";
|
|
49299
49397
|
function pluginHooksFromReply(m, pluginId) {
|
|
49300
49398
|
const out = [];
|
|
49301
49399
|
if (!isObj2(m) || !isObj2(m.result) || !Array.isArray(m.result.data)) return out;
|
|
@@ -49305,7 +49403,8 @@ function pluginHooksFromReply(m, pluginId) {
|
|
|
49305
49403
|
if (!isObj2(h) || h.source !== PLUGIN_SOURCE || h.pluginId !== pluginId) continue;
|
|
49306
49404
|
if (typeof h.key !== "string" || typeof h.currentHash !== "string") continue;
|
|
49307
49405
|
if (out.some((x) => x.key === h.key)) continue;
|
|
49308
|
-
|
|
49406
|
+
const status = typeof h.trustStatus === "string" ? h.trustStatus : UNTRUSTED;
|
|
49407
|
+
out.push({ key: h.key, hash: h.currentHash, trusted: status === TRUSTED, status });
|
|
49309
49408
|
}
|
|
49310
49409
|
}
|
|
49311
49410
|
return out;
|
|
@@ -49398,7 +49497,11 @@ var CODEX_UNTRUSTED_FIX = "run: context-mode setup";
|
|
|
49398
49497
|
function untrustedPluginHooksDetail(hooks) {
|
|
49399
49498
|
const bad = hooks.filter((h) => !h.trusted);
|
|
49400
49499
|
if (!bad.length) return void 0;
|
|
49401
|
-
|
|
49500
|
+
const counts = /* @__PURE__ */ new Map();
|
|
49501
|
+
for (const h of bad) counts.set(h.status, (counts.get(h.status) ?? 0) + 1);
|
|
49502
|
+
const words = [...counts].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1));
|
|
49503
|
+
const state = words.length === 1 ? words[0][0] : `${words.map(([w]) => w).join(" or ")} (${words.map(([w, n]) => `${n} ${w}`).join(", ")})`;
|
|
49504
|
+
return `codex lists ${bad.length} of ${hooks.length} context-mode plugin hooks ${state}, so they do not run; ${CODEX_UNTRUSTED_FIX}`;
|
|
49402
49505
|
}
|
|
49403
49506
|
|
|
49404
49507
|
// src/core/ops/doctor-hook.ts
|
|
@@ -49415,7 +49518,7 @@ function isObject5(v) {
|
|
|
49415
49518
|
}
|
|
49416
49519
|
function loadFixture(bundleDir2, agent) {
|
|
49417
49520
|
const file2 = path6.join(bundleDir2, HOOK_FIXTURE_DIR, HOOK_FIXTURE_FILE);
|
|
49418
|
-
if (!
|
|
49521
|
+
if (!existsSync12(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
|
|
49419
49522
|
let all;
|
|
49420
49523
|
try {
|
|
49421
49524
|
all = JSON.parse(hostText(readFileSync8(file2, "utf8")));
|
|
@@ -49477,6 +49580,50 @@ function isNativeShape(agent, stdout, exitCode, killed, event) {
|
|
|
49477
49580
|
return COPILOT_KEYS.some((k) => Object.hasOwn(out, k));
|
|
49478
49581
|
}
|
|
49479
49582
|
}
|
|
49583
|
+
var READ_PROBE_LINES = 4 * Math.ceil(REPLACE_TRIGGER_BYTES / 40);
|
|
49584
|
+
function readProbePayload(cwd) {
|
|
49585
|
+
const content = Array.from({ length: READ_PROBE_LINES }, (_, n) => "d5 read probe line " + n + " ".padEnd(20, "x")).join("\n");
|
|
49586
|
+
const filePath = path6.join(cwd, "d5-read-probe.txt");
|
|
49587
|
+
return {
|
|
49588
|
+
session_id: "d5-read-probe",
|
|
49589
|
+
transcript_path: "",
|
|
49590
|
+
cwd,
|
|
49591
|
+
hook_event_name: "PostToolUse",
|
|
49592
|
+
tool_name: "Read",
|
|
49593
|
+
tool_use_id: "toolu_d5_read_probe",
|
|
49594
|
+
tool_input: { file_path: filePath },
|
|
49595
|
+
tool_response: { type: "text", file: { filePath, content, numLines: READ_PROBE_LINES, startLine: 1, totalLines: READ_PROBE_LINES } }
|
|
49596
|
+
};
|
|
49597
|
+
}
|
|
49598
|
+
function isReadShape(stdout) {
|
|
49599
|
+
if (stdout.trim() === "") return true;
|
|
49600
|
+
let out;
|
|
49601
|
+
try {
|
|
49602
|
+
out = JSON.parse(stdout);
|
|
49603
|
+
} catch {
|
|
49604
|
+
return false;
|
|
49605
|
+
}
|
|
49606
|
+
if (!isObject5(out) || !isObject5(out.hookSpecificOutput) || !Object.hasOwn(out.hookSpecificOutput, "updatedToolOutput")) return true;
|
|
49607
|
+
const r = out.hookSpecificOutput.updatedToolOutput;
|
|
49608
|
+
if (!isObject5(r) || r.type !== "text" || !isObject5(r.file)) return false;
|
|
49609
|
+
const f = r.file;
|
|
49610
|
+
return typeof f.filePath === "string" && typeof f.content === "string" && ["numLines", "startLine", "totalLines"].every((k) => typeof f[k] === "number");
|
|
49611
|
+
}
|
|
49612
|
+
async function readProbeOk(i, timeoutMs) {
|
|
49613
|
+
const home = mkdtempSync(path6.join(tmpdir2(), "cm-d5-read-"));
|
|
49614
|
+
try {
|
|
49615
|
+
const r = await runProcess([process.execPath, path6.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
49616
|
+
cwd: i.bundleDir,
|
|
49617
|
+
env: { ...i.env, HOME: home, USERPROFILE: home },
|
|
49618
|
+
signal: i.signal,
|
|
49619
|
+
timeoutMs,
|
|
49620
|
+
stdin: JSON.stringify(readProbePayload(i.worktree ?? home))
|
|
49621
|
+
});
|
|
49622
|
+
return isReadShape(r.stdout.toString("utf8"));
|
|
49623
|
+
} finally {
|
|
49624
|
+
rmSync4(home, { recursive: true, force: true });
|
|
49625
|
+
}
|
|
49626
|
+
}
|
|
49480
49627
|
function codexHookJournaled(db) {
|
|
49481
49628
|
if (db === null) return false;
|
|
49482
49629
|
return db.raw.prepare("SELECT 1 FROM events WHERE agent = ? LIMIT 1").get("codex") !== void 0;
|
|
@@ -49510,7 +49657,7 @@ async function checkHookRoundTrip(i) {
|
|
|
49510
49657
|
const trust = await codexPluginTrust(i);
|
|
49511
49658
|
if (trust !== null) return trust;
|
|
49512
49659
|
}
|
|
49513
|
-
if (i.agent === "codex" &&
|
|
49660
|
+
if (i.agent === "codex" && existsSync12(path6.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
|
|
49514
49661
|
return row("UNKNOWN", D5_CODEX_UNTRUSTED_DETAIL);
|
|
49515
49662
|
}
|
|
49516
49663
|
const fixture = loadFixture(i.bundleDir, i.agent);
|
|
@@ -49544,18 +49691,19 @@ async function checkHookRoundTrip(i) {
|
|
|
49544
49691
|
if (n >= minPairs && ms <= HOOK_P95_MS) break;
|
|
49545
49692
|
}
|
|
49546
49693
|
if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
|
|
49694
|
+
if (i.agent === "claude-code" && !await readProbeOk(i, timeoutMs)) return row("FAIL", D5_READ_SHAPE_DETAIL, D5_FIX);
|
|
49547
49695
|
return row("PASS", DOCTOR_PASS_DETAIL);
|
|
49548
49696
|
}
|
|
49549
49697
|
|
|
49550
49698
|
// src/core/hooks/fallback.ts
|
|
49551
|
-
import { join as
|
|
49699
|
+
import { join as join12, resolve as resolve3 } from "node:path";
|
|
49552
49700
|
var fs = process.getBuiltinModule("node:fs");
|
|
49553
49701
|
function homeOf(env) {
|
|
49554
49702
|
return env.HOME ?? env.USERPROFILE ?? "";
|
|
49555
49703
|
}
|
|
49556
49704
|
function hookLogPath(env) {
|
|
49557
49705
|
const home = homeOf(env);
|
|
49558
|
-
return home === "" ? "" :
|
|
49706
|
+
return home === "" ? "" : join12(home, DATA_ROOT.slice(1), HOOK_ERROR_LOG_FILE);
|
|
49559
49707
|
}
|
|
49560
49708
|
function lastHookError(env) {
|
|
49561
49709
|
try {
|
|
@@ -49585,15 +49733,15 @@ function lastHookError(env) {
|
|
|
49585
49733
|
}
|
|
49586
49734
|
|
|
49587
49735
|
// src/core/ops/db-heal.ts
|
|
49588
|
-
import { existsSync as
|
|
49589
|
-
import { basename as basename4, dirname as
|
|
49736
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync5, rmSync as rmSync5 } from "node:fs";
|
|
49737
|
+
import { basename as basename4, dirname as dirname7, join as join13 } from "node:path";
|
|
49590
49738
|
function integrityOk2(rows) {
|
|
49591
49739
|
return rows.length === 1 && rows[0].integrity_check === INTEGRITY_OK;
|
|
49592
49740
|
}
|
|
49593
49741
|
async function healLossless(dbPath) {
|
|
49594
49742
|
const { DatabaseSync } = await import(SQLITE_MODULE);
|
|
49595
49743
|
const tmp = dbPath + HEAL_TMP_SUFFIX;
|
|
49596
|
-
|
|
49744
|
+
rmSync5(tmp, { force: true });
|
|
49597
49745
|
try {
|
|
49598
49746
|
const src = new DatabaseSync(dbPath, { readOnly: true, timeout: DB_TIMEOUT_MS });
|
|
49599
49747
|
try {
|
|
@@ -49609,18 +49757,18 @@ async function healLossless(dbPath) {
|
|
|
49609
49757
|
} finally {
|
|
49610
49758
|
copy.close();
|
|
49611
49759
|
}
|
|
49612
|
-
|
|
49613
|
-
|
|
49760
|
+
rmSync5(dbPath + DB_WAL_SUFFIX, { force: true });
|
|
49761
|
+
rmSync5(dbPath + DB_SHM_SUFFIX, { force: true });
|
|
49614
49762
|
renameWithRetry(tmp, dbPath);
|
|
49615
49763
|
} finally {
|
|
49616
|
-
|
|
49764
|
+
rmSync5(tmp, { force: true });
|
|
49617
49765
|
}
|
|
49618
49766
|
}
|
|
49619
49767
|
function renameAside(dbPath) {
|
|
49620
49768
|
const ts = String(Date.now());
|
|
49621
49769
|
for (const suffix of DB_SIBLING_SUFFIXES) {
|
|
49622
49770
|
const file2 = dbPath + suffix;
|
|
49623
|
-
if (
|
|
49771
|
+
if (existsSync13(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
|
|
49624
49772
|
}
|
|
49625
49773
|
return ts;
|
|
49626
49774
|
}
|
|
@@ -49643,7 +49791,7 @@ function utcStamp(now) {
|
|
|
49643
49791
|
return now.toISOString().slice(0, 19).replaceAll("-", "").replaceAll(":", "") + "Z";
|
|
49644
49792
|
}
|
|
49645
49793
|
function makeOrphanDir(projectDir) {
|
|
49646
|
-
const base =
|
|
49794
|
+
const base = join13(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
|
|
49647
49795
|
for (let n = 1; ; n += 1) {
|
|
49648
49796
|
const dir = n === 1 ? base : base + "-" + String(n);
|
|
49649
49797
|
try {
|
|
@@ -49658,9 +49806,9 @@ async function healOrphan(project, files, row5) {
|
|
|
49658
49806
|
const moved = [];
|
|
49659
49807
|
let dir = "";
|
|
49660
49808
|
try {
|
|
49661
|
-
dir = makeOrphanDir(
|
|
49809
|
+
dir = makeOrphanDir(dirname7(project.dbPath));
|
|
49662
49810
|
for (const f of files) {
|
|
49663
|
-
const to =
|
|
49811
|
+
const to = join13(dir, basename4(f.path));
|
|
49664
49812
|
renameWithRetry(f.path, to);
|
|
49665
49813
|
moved.push({ path: to, bytes: f.bytes });
|
|
49666
49814
|
}
|
|
@@ -49727,8 +49875,8 @@ function buildReportHead(input) {
|
|
|
49727
49875
|
|
|
49728
49876
|
// src/core/ops/doctor-issue.ts
|
|
49729
49877
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
49730
|
-
import { closeSync, existsSync as
|
|
49731
|
-
import { delimiter, join as
|
|
49878
|
+
import { closeSync, existsSync as existsSync14, fstatSync, mkdirSync as mkdirSync6, openSync, readFileSync as readFileSync9, readSync, realpathSync as realpathSync8, writeFileSync as writeFileSync3 } from "node:fs";
|
|
49879
|
+
import { delimiter, join as join14 } from "node:path";
|
|
49732
49880
|
var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
|
|
49733
49881
|
function tildeOf(env) {
|
|
49734
49882
|
const home = homeDirOf(env);
|
|
@@ -49769,8 +49917,8 @@ function onPath(env, tool) {
|
|
|
49769
49917
|
const out = [];
|
|
49770
49918
|
for (const dir of (env.PATH ?? env.Path ?? "").split(delimiter)) {
|
|
49771
49919
|
if (dir === "") continue;
|
|
49772
|
-
for (const n of names) if (
|
|
49773
|
-
out.push(
|
|
49920
|
+
for (const n of names) if (existsSync14(join14(dir, n))) {
|
|
49921
|
+
out.push(join14(dir, n));
|
|
49774
49922
|
break;
|
|
49775
49923
|
}
|
|
49776
49924
|
}
|
|
@@ -49778,7 +49926,7 @@ function onPath(env, tool) {
|
|
|
49778
49926
|
}
|
|
49779
49927
|
function hookLogTail(env) {
|
|
49780
49928
|
const file2 = hookLogPath(env);
|
|
49781
|
-
if (file2 === "" || !
|
|
49929
|
+
if (file2 === "" || !existsSync14(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
|
|
49782
49930
|
try {
|
|
49783
49931
|
const fd = openSync(file2, "r");
|
|
49784
49932
|
try {
|
|
@@ -49798,7 +49946,7 @@ function hookLogTail(env) {
|
|
|
49798
49946
|
}
|
|
49799
49947
|
async function journalRows(ctx) {
|
|
49800
49948
|
const head = ["| kind | tool | bytes | ok | exit_code | created_at |", "|---|---|---|---|---|---|"];
|
|
49801
|
-
if (!
|
|
49949
|
+
if (!existsSync14(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
|
|
49802
49950
|
try {
|
|
49803
49951
|
const db = await openDb(ctx.project, { readOnly: true });
|
|
49804
49952
|
try {
|
|
@@ -49816,15 +49964,15 @@ function agentConfig(adapter, env, worktree) {
|
|
|
49816
49964
|
const home = homeDirOf(env);
|
|
49817
49965
|
const files = configPaths(adapter, env, worktree);
|
|
49818
49966
|
if (home !== null) {
|
|
49819
|
-
if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path:
|
|
49820
|
-
if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path:
|
|
49967
|
+
if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join14(claudeDirOf(env, home), SETTINGS_FILE) });
|
|
49968
|
+
if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join14(codexDirOf(env, home), CONFIG_TOML_FILE) });
|
|
49821
49969
|
}
|
|
49822
49970
|
const out = [];
|
|
49823
49971
|
const seen = /* @__PURE__ */ new Set();
|
|
49824
49972
|
for (const f of files) {
|
|
49825
49973
|
if (seen.has(f.path)) continue;
|
|
49826
49974
|
seen.add(f.path);
|
|
49827
|
-
if (!
|
|
49975
|
+
if (!existsSync14(f.path)) {
|
|
49828
49976
|
out.push(`${f.label}: ${f.path} (absent)`);
|
|
49829
49977
|
continue;
|
|
49830
49978
|
}
|
|
@@ -49900,14 +50048,14 @@ async function buildIssueBody(i) {
|
|
|
49900
50048
|
async function writeIssueReport(i) {
|
|
49901
50049
|
const tilde = tildeOf(i.env);
|
|
49902
50050
|
const body = await buildIssueBody(i);
|
|
49903
|
-
const dir =
|
|
50051
|
+
const dir = join14(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
|
|
49904
50052
|
mkdirSync6(dir, { recursive: true });
|
|
49905
|
-
const file2 =
|
|
50053
|
+
const file2 = join14(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
|
|
49906
50054
|
writeFileSync3(file2, body);
|
|
49907
50055
|
const shown2 = tilde(file2);
|
|
49908
50056
|
const title = issueTitle(i.adapter.id, i.rows);
|
|
49909
50057
|
const gh = [`gh issue create --repo ${ISSUE_REPO_SLUG} --label bug \\`, `${DOCTOR_GH_NEXT}title ${JSON.stringify(title)} \\`, `${DOCTOR_GH_NEXT}body-file ${shown2}`];
|
|
49910
|
-
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))];
|
|
50058
|
+
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];
|
|
49911
50059
|
}
|
|
49912
50060
|
function formUrl(title, summary) {
|
|
49913
50061
|
const base = `${ISSUE_FORM_URL}&title=${encodeURIComponent(title)}`;
|
|
@@ -49948,7 +50096,7 @@ async function guard(id, run) {
|
|
|
49948
50096
|
}
|
|
49949
50097
|
}
|
|
49950
50098
|
async function codexDb(ctx, adapter) {
|
|
49951
|
-
if (adapter.id !== "codex" || !
|
|
50099
|
+
if (adapter.id !== "codex" || !existsSync15(ctx.project.dbPath)) return null;
|
|
49952
50100
|
try {
|
|
49953
50101
|
return await openDb(ctx.project, { readOnly: true });
|
|
49954
50102
|
} catch {
|
|
@@ -49978,11 +50126,11 @@ async function hookRow(ctx, adapter, host) {
|
|
|
49978
50126
|
}
|
|
49979
50127
|
}
|
|
49980
50128
|
function ownServerId(configDir, projectKey) {
|
|
49981
|
-
const dir =
|
|
49982
|
-
if (!
|
|
50129
|
+
const dir = join15(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
50130
|
+
if (!existsSync15(dir)) return "";
|
|
49983
50131
|
for (const name of readdirSync7(dir)) {
|
|
49984
50132
|
if (!name.endsWith(OWNER_PID_EXT)) continue;
|
|
49985
|
-
if (readFileSync10(
|
|
50133
|
+
if (readFileSync10(join15(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
|
|
49986
50134
|
}
|
|
49987
50135
|
return "";
|
|
49988
50136
|
}
|
|
@@ -50065,7 +50213,7 @@ async function doctorReply(ctx, host) {
|
|
|
50065
50213
|
return { text, isError: false, sandboxBytes: bytes5 };
|
|
50066
50214
|
}
|
|
50067
50215
|
async function handler2(_input, ctx) {
|
|
50068
|
-
return doctorReply(ctx, { env: process.env, bundleDir:
|
|
50216
|
+
return doctorReply(ctx, { env: process.env, bundleDir: ownBundleDir(), piCwd: void 0 });
|
|
50069
50217
|
}
|
|
50070
50218
|
var ctxDoctor = Object.freeze({
|
|
50071
50219
|
name: "ctx_doctor",
|
|
@@ -50077,9 +50225,9 @@ var ctxDoctor = Object.freeze({
|
|
|
50077
50225
|
});
|
|
50078
50226
|
|
|
50079
50227
|
// src/core/tools/execute.ts
|
|
50080
|
-
import { existsSync as
|
|
50081
|
-
import { tmpdir as
|
|
50082
|
-
import { dirname as
|
|
50228
|
+
import { existsSync as existsSync16, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync4 } from "node:fs";
|
|
50229
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
50230
|
+
import { dirname as dirname9, join as join16, parse as parse5, resolve as resolve4 } from "node:path";
|
|
50083
50231
|
|
|
50084
50232
|
// src/core/index/select.ts
|
|
50085
50233
|
var READ_CHUNKS = "SELECT ord, body FROM chunks WHERE source_id = ?";
|
|
@@ -50202,7 +50350,7 @@ function schemaLine(issue4) {
|
|
|
50202
50350
|
}
|
|
50203
50351
|
function fileError(given, abs, root) {
|
|
50204
50352
|
let dir = abs;
|
|
50205
|
-
while (!
|
|
50353
|
+
while (!existsSync16(dir) && dirname9(dir) !== dir) dir = dirname9(dir);
|
|
50206
50354
|
if (isInside(root, dir)) return null;
|
|
50207
50355
|
return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
|
|
50208
50356
|
}
|
|
@@ -50283,8 +50431,8 @@ async function handler3(raw, ctx) {
|
|
|
50283
50431
|
if (takesDashC(input.language, runtime)) {
|
|
50284
50432
|
argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
|
|
50285
50433
|
} else {
|
|
50286
|
-
tmpDir =
|
|
50287
|
-
const file2 =
|
|
50434
|
+
tmpDir = mkdtempSync2(join16(tmpdir3(), TMP_PREFIX));
|
|
50435
|
+
const file2 = join16(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
|
|
50288
50436
|
writeFileSync4(file2, scriptText(input.language, input.code), "utf8");
|
|
50289
50437
|
argv = scriptArgv(input.language, runtime, file2);
|
|
50290
50438
|
}
|
|
@@ -50307,7 +50455,7 @@ async function handler3(raw, ctx) {
|
|
|
50307
50455
|
}
|
|
50308
50456
|
throw err;
|
|
50309
50457
|
} finally {
|
|
50310
|
-
if (tmpDir !== null && !handedOff)
|
|
50458
|
+
if (tmpDir !== null && !handedOff) rmSync6(tmpDir, { recursive: true, force: true });
|
|
50311
50459
|
}
|
|
50312
50460
|
}
|
|
50313
50461
|
var ctxExecute = {
|
|
@@ -50319,12 +50467,12 @@ var ctxExecute = {
|
|
|
50319
50467
|
};
|
|
50320
50468
|
|
|
50321
50469
|
// src/core/tools/index.ts
|
|
50322
|
-
import { existsSync as
|
|
50323
|
-
import { dirname as
|
|
50470
|
+
import { existsSync as existsSync17, readFileSync as readFileSync12, statSync as statSync7 } from "node:fs";
|
|
50471
|
+
import { dirname as dirname10, extname, join as join18, relative as relative2, resolve as resolve5 } from "node:path";
|
|
50324
50472
|
|
|
50325
50473
|
// src/core/index/walk.ts
|
|
50326
50474
|
import { readdirSync as readdirSync8, readFileSync as readFileSync11, realpathSync as realpathSync9, statSync as statSync6 } from "node:fs";
|
|
50327
|
-
import { join as
|
|
50475
|
+
import { join as join17 } from "node:path";
|
|
50328
50476
|
var GITIGNORE = ".gitignore";
|
|
50329
50477
|
var GIT_DIR = ".git";
|
|
50330
50478
|
function walkDir(root, containmentRoot) {
|
|
@@ -50333,7 +50481,7 @@ function walkDir(root, containmentRoot) {
|
|
|
50333
50481
|
const found = [];
|
|
50334
50482
|
visit(real2, [], [], containmentRoot, /* @__PURE__ */ new Set([real2]), found);
|
|
50335
50483
|
found.sort(compareFound);
|
|
50336
|
-
return found.map((f) => ({ absPath: f.absPath, relPath:
|
|
50484
|
+
return found.map((f) => ({ absPath: f.absPath, relPath: join17(...f.dir, f.name) }));
|
|
50337
50485
|
}
|
|
50338
50486
|
function visit(abs, rel, parent, contain, seen, found) {
|
|
50339
50487
|
let entries;
|
|
@@ -50342,10 +50490,10 @@ function visit(abs, rel, parent, contain, seen, found) {
|
|
|
50342
50490
|
} catch {
|
|
50343
50491
|
return;
|
|
50344
50492
|
}
|
|
50345
|
-
const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(
|
|
50493
|
+
const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join17(abs, GITIGNORE), rel)) : parent;
|
|
50346
50494
|
for (const e of entries) {
|
|
50347
50495
|
if (e.name === GIT_DIR) continue;
|
|
50348
|
-
const path7 =
|
|
50496
|
+
const path7 = join17(abs, e.name);
|
|
50349
50497
|
let isDir = e.isDirectory();
|
|
50350
50498
|
let isFile = e.isFile();
|
|
50351
50499
|
let target = path7;
|
|
@@ -54475,7 +54623,7 @@ function readUtf8(absPath) {
|
|
|
54475
54623
|
}
|
|
54476
54624
|
function missingOrOutside(given, abs, root) {
|
|
54477
54625
|
let dir = abs;
|
|
54478
|
-
while (!
|
|
54626
|
+
while (!existsSync17(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
|
|
54479
54627
|
if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
|
|
54480
54628
|
return new CtxError("OUTSIDE_ROOT", { p: given, root });
|
|
54481
54629
|
}
|
|
@@ -54486,7 +54634,7 @@ function pathItems(input, project) {
|
|
|
54486
54634
|
if (statSync7(abs).isDirectory()) {
|
|
54487
54635
|
return walkDir(abs, project.containmentRoot).map((f) => ({
|
|
54488
54636
|
sourceKind: "path",
|
|
54489
|
-
label: pathLabel(
|
|
54637
|
+
label: pathLabel(join18(base, f.relPath)),
|
|
54490
54638
|
kind: kindOfPath(f.relPath),
|
|
54491
54639
|
read: () => readUtf8(f.absPath)
|
|
54492
54640
|
}));
|
|
@@ -55291,12 +55439,12 @@ var ctxStats = Object.freeze({
|
|
|
55291
55439
|
});
|
|
55292
55440
|
|
|
55293
55441
|
// src/core/tools/upgrade.ts
|
|
55294
|
-
import { existsSync as
|
|
55295
|
-
import { basename as basename7, dirname as
|
|
55442
|
+
import { existsSync as existsSync23, realpathSync as realpathSync10, rmSync as rmSync11 } from "node:fs";
|
|
55443
|
+
import { basename as basename7, dirname as dirname12, join as join24 } from "node:path";
|
|
55296
55444
|
|
|
55297
55445
|
// src/core/ops/host-write.ts
|
|
55298
|
-
import { copyFileSync, existsSync as
|
|
55299
|
-
import { dirname as
|
|
55446
|
+
import { copyFileSync, existsSync as existsSync18, mkdirSync as mkdirSync7, writeFileSync as writeFileSync5 } from "node:fs";
|
|
55447
|
+
import { dirname as dirname11, join as join19 } from "node:path";
|
|
55300
55448
|
function defaultWrite(file2, text) {
|
|
55301
55449
|
writeFileSync5(file2, text, "utf8");
|
|
55302
55450
|
}
|
|
@@ -55305,14 +55453,14 @@ function hostConfigPath(agent, home, env) {
|
|
|
55305
55453
|
if (own4 !== void 0) return ownMcpFileOf(agent, own4.file, env, home);
|
|
55306
55454
|
switch (agent) {
|
|
55307
55455
|
case "opencode":
|
|
55308
|
-
return
|
|
55456
|
+
return join19(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
|
|
55309
55457
|
// D-WIN-OPENCODE-DIR-1
|
|
55310
55458
|
case "pi":
|
|
55311
|
-
return
|
|
55459
|
+
return join19(piAgentDirOf(env, home), SETTINGS_FILE);
|
|
55312
55460
|
case "copilot-cli":
|
|
55313
55461
|
return null;
|
|
55314
55462
|
default:
|
|
55315
|
-
return
|
|
55463
|
+
return join19(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
|
|
55316
55464
|
}
|
|
55317
55465
|
}
|
|
55318
55466
|
function cell3(value) {
|
|
@@ -55324,8 +55472,8 @@ function toRow(file2, edit) {
|
|
|
55324
55472
|
function writeWithRollback(file2, text, write, atomic) {
|
|
55325
55473
|
const trash = file2 + UPGRADE_TRASH_SUFFIX;
|
|
55326
55474
|
const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
|
|
55327
|
-
const had =
|
|
55328
|
-
mkdirSync7(
|
|
55475
|
+
const had = existsSync18(file2);
|
|
55476
|
+
mkdirSync7(dirname11(file2), { recursive: true });
|
|
55329
55477
|
if (had) copyFileSync(file2, trash);
|
|
55330
55478
|
try {
|
|
55331
55479
|
write(tmp, text);
|
|
@@ -55354,7 +55502,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
55354
55502
|
if (requested === null) return [];
|
|
55355
55503
|
const current = readHostConfig(row5.id, requested);
|
|
55356
55504
|
const result = mergeOwnEntries(row5.id, current.text, current.format, row5);
|
|
55357
|
-
const exists =
|
|
55505
|
+
const exists = existsSync18(current.path);
|
|
55358
55506
|
if (exists && result.text === current.text) return [];
|
|
55359
55507
|
const text = result.text === "" && current.format !== "toml" ? JSON.stringify({}) : result.text;
|
|
55360
55508
|
writeWithRollback(current.path, current.layout === void 0 ? text : withLayout(text, current.layout), opts.write ?? defaultWrite, opts.atomic ?? {});
|
|
@@ -55362,8 +55510,8 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
55362
55510
|
}
|
|
55363
55511
|
|
|
55364
55512
|
// src/core/ops/plugin-swap.ts
|
|
55365
|
-
import { existsSync as
|
|
55366
|
-
import { basename as basename6, join as
|
|
55513
|
+
import { existsSync as existsSync19, lstatSync, readdirSync as readdirSync9, readlinkSync, rmSync as rmSync7, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
|
|
55514
|
+
import { basename as basename6, join as join20, win32 as win322 } from "node:path";
|
|
55367
55515
|
function linkTarget(path7, win) {
|
|
55368
55516
|
if (!isLink(path7)) return null;
|
|
55369
55517
|
const target = readlinkSync(path7);
|
|
@@ -55382,11 +55530,11 @@ function settleLinks(link, tmp, old, opts) {
|
|
|
55382
55530
|
else renameWithRetry(old, link, opts);
|
|
55383
55531
|
}
|
|
55384
55532
|
function swapPluginCurrent(agentDir, sha, opts = {}) {
|
|
55385
|
-
const next =
|
|
55386
|
-
if (!
|
|
55533
|
+
const next = join20(agentDir, sha);
|
|
55534
|
+
if (!existsSync19(next) || !lstatSync(next).isDirectory()) {
|
|
55387
55535
|
throw new CtxError("PLUGIN_ROOT_MISSING", { agent: basename6(agentDir), path: next });
|
|
55388
55536
|
}
|
|
55389
|
-
const link =
|
|
55537
|
+
const link = join20(agentDir, PLUGIN_CURRENT_LINK);
|
|
55390
55538
|
const tmp = link + PLUGIN_LINK_TMP_SUFFIX;
|
|
55391
55539
|
const old = link + PLUGIN_LINK_OLD_SUFFIX;
|
|
55392
55540
|
settleLinks(link, tmp, old, opts);
|
|
@@ -55401,15 +55549,15 @@ function swapPluginCurrent(agentDir, sha, opts = {}) {
|
|
|
55401
55549
|
if (before !== null) unlinkSync2(old);
|
|
55402
55550
|
const keep = /* @__PURE__ */ new Set([sha]);
|
|
55403
55551
|
if (before !== null) keep.add(before);
|
|
55404
|
-
const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) =>
|
|
55405
|
-
for (const dir of removed)
|
|
55406
|
-
const previous = before !== null &&
|
|
55552
|
+
const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join20(agentDir, name));
|
|
55553
|
+
for (const dir of removed) rmSync7(dir, { recursive: true, force: true });
|
|
55554
|
+
const previous = before !== null && existsSync19(join20(agentDir, before)) ? join20(agentDir, before) : null;
|
|
55407
55555
|
return { current: next, previous, removed };
|
|
55408
55556
|
}
|
|
55409
55557
|
|
|
55410
55558
|
// src/core/ops/release-fetch.ts
|
|
55411
|
-
import { existsSync as
|
|
55412
|
-
import { join as
|
|
55559
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync8, rmSync as rmSync8 } from "node:fs";
|
|
55560
|
+
import { join as join21 } from "node:path";
|
|
55413
55561
|
function failed(r) {
|
|
55414
55562
|
if (r.exitCode === null && r.killed === null) return new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
|
|
55415
55563
|
const status = r.killed ?? String(r.exitCode);
|
|
@@ -55421,36 +55569,36 @@ async function git2(bin, args, cwd, env, signal) {
|
|
|
55421
55569
|
return r.stdout.toString().trim();
|
|
55422
55570
|
}
|
|
55423
55571
|
async function fetchRelease(agent, url4, env, signal, opts = {}) {
|
|
55424
|
-
const agentDir =
|
|
55572
|
+
const agentDir = join21(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, agent);
|
|
55425
55573
|
mkdirSync8(agentDir, { recursive: true });
|
|
55426
|
-
const fetchDir =
|
|
55427
|
-
|
|
55574
|
+
const fetchDir = join21(agentDir, UPGRADE_FETCH_DIR_PREFIX + process.pid);
|
|
55575
|
+
rmSync8(fetchDir, { recursive: true, force: true });
|
|
55428
55576
|
const gitBin = findRuntime(GIT_BIN, env);
|
|
55429
55577
|
if (gitBin === null) throw new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
|
|
55430
55578
|
const childEnv = buildChildEnv(env, { ...GIT_NO_PROMPT_ENV, ...GIT_NO_CRLF_ENV });
|
|
55431
55579
|
try {
|
|
55432
55580
|
await git2(gitBin, [...GIT_CLONE_ARGS, RELEASE_BRANCH, url4, fetchDir], agentDir, childEnv, signal);
|
|
55433
55581
|
const sha = await git2(gitBin, GIT_HEAD_SHA_ARGS, fetchDir, childEnv, signal);
|
|
55434
|
-
const dir =
|
|
55435
|
-
if (
|
|
55582
|
+
const dir = join21(agentDir, sha);
|
|
55583
|
+
if (existsSync20(dir)) rmSync8(fetchDir, { recursive: true, force: true });
|
|
55436
55584
|
else renameWithRetry(fetchDir, dir, opts);
|
|
55437
55585
|
return { sha, dir };
|
|
55438
55586
|
} catch (e) {
|
|
55439
|
-
|
|
55587
|
+
rmSync8(fetchDir, { recursive: true, force: true });
|
|
55440
55588
|
throw e;
|
|
55441
55589
|
}
|
|
55442
55590
|
}
|
|
55443
55591
|
|
|
55444
55592
|
// src/core/ops/uninstall.ts
|
|
55445
|
-
import { existsSync as
|
|
55446
|
-
import { join as
|
|
55593
|
+
import { existsSync as existsSync21, readdirSync as readdirSync10, rmSync as rmSync9, writeFileSync as writeFileSync6 } from "node:fs";
|
|
55594
|
+
import { join as join22 } from "node:path";
|
|
55447
55595
|
function row2(area, before, after) {
|
|
55448
55596
|
return { area, before, after };
|
|
55449
55597
|
}
|
|
55450
55598
|
function stopServers(configDir, projectKey) {
|
|
55451
55599
|
const stopped = listLiveOwners(configDir, projectKey);
|
|
55452
|
-
const dir =
|
|
55453
|
-
for (const serverId of stopped) writeFileSync6(
|
|
55600
|
+
const dir = join22(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
55601
|
+
for (const serverId of stopped) writeFileSync6(join22(dir, serverId + OWNER_STOP_EXT), "", "utf8");
|
|
55454
55602
|
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 };
|
|
55455
55603
|
}
|
|
55456
55604
|
function rootOrNull(adapter, env) {
|
|
@@ -55468,16 +55616,16 @@ function removeCache(adapter, env, configDir) {
|
|
|
55468
55616
|
const root = rootOrNull(adapter, env);
|
|
55469
55617
|
if (root === null) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
|
|
55470
55618
|
if (adapter.installMode === "marketplace") {
|
|
55471
|
-
const cache =
|
|
55619
|
+
const cache = join22(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
|
|
55472
55620
|
if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
|
|
55473
55621
|
}
|
|
55474
|
-
|
|
55622
|
+
rmSync9(root, { recursive: true, force: true });
|
|
55475
55623
|
return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
|
|
55476
55624
|
}
|
|
55477
55625
|
case "plugin": {
|
|
55478
|
-
const agentDir =
|
|
55479
|
-
if (!
|
|
55480
|
-
|
|
55626
|
+
const agentDir = join22(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
|
|
55627
|
+
if (!existsSync21(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
|
|
55628
|
+
rmSync9(agentDir, { recursive: true, force: true });
|
|
55481
55629
|
return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
|
|
55482
55630
|
}
|
|
55483
55631
|
case "config-mcp":
|
|
@@ -55521,7 +55669,7 @@ function ownEntries(agent, env) {
|
|
|
55521
55669
|
}
|
|
55522
55670
|
if (agent === "opencode") {
|
|
55523
55671
|
return [{
|
|
55524
|
-
file:
|
|
55672
|
+
file: join22(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
|
|
55525
55673
|
// D-WIN-OPENCODE-DIR-1
|
|
55526
55674
|
key: OPENCODE_PLUGIN_KEY,
|
|
55527
55675
|
shown: OPENCODE_PLUGIN_KEY,
|
|
@@ -55532,7 +55680,7 @@ function ownEntries(agent, env) {
|
|
|
55532
55680
|
if (agent === "pi") {
|
|
55533
55681
|
const agentDir = piAgentDirOf(env, home);
|
|
55534
55682
|
return [{
|
|
55535
|
-
file:
|
|
55683
|
+
file: join22(agentDir, SETTINGS_FILE),
|
|
55536
55684
|
key: PI_PACKAGES_KEY,
|
|
55537
55685
|
shown: PI_PACKAGES_KEY,
|
|
55538
55686
|
has: (v) => Array.isArray(v) && v.some((x) => piSource(x) === PI_GIT_PACKAGE),
|
|
@@ -55554,12 +55702,12 @@ function removeOwnEntries(agent, env) {
|
|
|
55554
55702
|
return rows.length === 0 ? [row2(UPGRADE_CONFIG_AREA, "", UPGRADE_NOT_FOUND)] : rows;
|
|
55555
55703
|
}
|
|
55556
55704
|
function removeProjectData(configDir, projectKey) {
|
|
55557
|
-
const projects =
|
|
55558
|
-
const dir =
|
|
55559
|
-
if (!
|
|
55705
|
+
const projects = join22(configDir, PROJECTS_DIR_NAME);
|
|
55706
|
+
const dir = join22(projects, projectKey);
|
|
55707
|
+
if (!existsSync21(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
|
|
55560
55708
|
if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
|
|
55561
55709
|
for (const name of readdirSync10(dir)) {
|
|
55562
|
-
if (name !== OWNERS_DIR_NAME)
|
|
55710
|
+
if (name !== OWNERS_DIR_NAME) rmSync9(join22(dir, name), { recursive: true, force: true });
|
|
55563
55711
|
}
|
|
55564
55712
|
return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
|
|
55565
55713
|
}
|
|
@@ -55567,25 +55715,25 @@ function runUninstall(input) {
|
|
|
55567
55715
|
const configDir = resolveConfigDir(input.env);
|
|
55568
55716
|
const stop = stopServers(configDir, input.project.projectKey);
|
|
55569
55717
|
const rows = [stop.row, removeCache(input.adapter, input.env, configDir), ...removeOwnEntries(input.adapter.id, input.env)];
|
|
55570
|
-
rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA,
|
|
55718
|
+
rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join22(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
|
|
55571
55719
|
return { rows, stopped: stop.stopped };
|
|
55572
55720
|
}
|
|
55573
55721
|
|
|
55574
55722
|
// src/core/ops/v1-remove.ts
|
|
55575
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
55723
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync22, readFileSync as readFileSync13, rmSync as rmSync10 } from "node:fs";
|
|
55576
55724
|
var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
55577
55725
|
var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
|
|
55578
55726
|
var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
|
|
55579
55727
|
function moveAside(target, undo) {
|
|
55580
55728
|
const trash = target + UPGRADE_TRASH_SUFFIX;
|
|
55581
|
-
|
|
55729
|
+
rmSync10(trash, { recursive: true, force: true });
|
|
55582
55730
|
renameWithRetry(target, trash);
|
|
55583
55731
|
undo.push({ trash, target });
|
|
55584
55732
|
}
|
|
55585
55733
|
function keepOriginal(file2, kept, undo) {
|
|
55586
55734
|
if (kept.has(file2)) return;
|
|
55587
55735
|
const trash = file2 + UPGRADE_TRASH_SUFFIX;
|
|
55588
|
-
|
|
55736
|
+
rmSync10(trash, { recursive: true, force: true });
|
|
55589
55737
|
copyFileSync2(file2, trash);
|
|
55590
55738
|
kept.add(file2);
|
|
55591
55739
|
undo.push({ trash, target: file2 });
|
|
@@ -55653,14 +55801,14 @@ function removeV1(agent, findings) {
|
|
|
55653
55801
|
for (const f of findings) {
|
|
55654
55802
|
if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
|
|
55655
55803
|
else if (f.path === "") {
|
|
55656
|
-
if (
|
|
55804
|
+
if (existsSync22(f.file)) {
|
|
55657
55805
|
moveAside(f.file, undo);
|
|
55658
55806
|
done.set(f, UPGRADE_REMOVED);
|
|
55659
55807
|
} else done.set(f, UPGRADE_NOT_FOUND);
|
|
55660
55808
|
} else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
|
|
55661
55809
|
}
|
|
55662
55810
|
for (const [file2, list3] of entries) {
|
|
55663
|
-
if (!
|
|
55811
|
+
if (!existsSync22(file2)) {
|
|
55664
55812
|
for (const f of list3) done.set(f, UPGRADE_NOT_FOUND);
|
|
55665
55813
|
continue;
|
|
55666
55814
|
}
|
|
@@ -55689,12 +55837,12 @@ function removeV1(agent, findings) {
|
|
|
55689
55837
|
return {
|
|
55690
55838
|
rows: findings.map((f) => row3(f, done.get(f) ?? UPGRADE_NOT_FOUND)),
|
|
55691
55839
|
commit() {
|
|
55692
|
-
for (const u of undo.splice(0))
|
|
55840
|
+
for (const u of undo.splice(0)) rmSync10(u.trash, { recursive: true, force: true });
|
|
55693
55841
|
},
|
|
55694
55842
|
rollback() {
|
|
55695
55843
|
for (const u of undo.splice(0).reverse()) {
|
|
55696
|
-
if (!
|
|
55697
|
-
|
|
55844
|
+
if (!existsSync22(u.trash)) continue;
|
|
55845
|
+
rmSync10(u.target, { recursive: true, force: true });
|
|
55698
55846
|
renameWithRetry(u.trash, u.target);
|
|
55699
55847
|
}
|
|
55700
55848
|
}
|
|
@@ -55704,7 +55852,7 @@ function removeV1(agent, findings) {
|
|
|
55704
55852
|
// src/core/ops/verify-sums.ts
|
|
55705
55853
|
import { createHash as createHash2 } from "node:crypto";
|
|
55706
55854
|
import { lstatSync as lstatSync2, readdirSync as readdirSync11, readFileSync as readFileSync14 } from "node:fs";
|
|
55707
|
-
import { join as
|
|
55855
|
+
import { join as join23 } from "node:path";
|
|
55708
55856
|
function mismatch() {
|
|
55709
55857
|
return new CtxError("BUNDLE_HASH_MISMATCH");
|
|
55710
55858
|
}
|
|
@@ -55725,14 +55873,14 @@ function walk2(dir, prefix, out) {
|
|
|
55725
55873
|
for (const entry of readdirSync11(dir, { withFileTypes: true })) {
|
|
55726
55874
|
const rel = prefix === "" ? entry.name : prefix + "/" + entry.name;
|
|
55727
55875
|
if (prefix === "" && (entry.name === GIT_DIR_NAME || entry.name === RELEASE_SUMS_FILE)) continue;
|
|
55728
|
-
const abs =
|
|
55876
|
+
const abs = join23(dir, entry.name);
|
|
55729
55877
|
if (entry.isDirectory()) walk2(abs, rel, out);
|
|
55730
55878
|
else if (entry.isFile()) out.set(rel, abs);
|
|
55731
55879
|
else throw mismatch();
|
|
55732
55880
|
}
|
|
55733
55881
|
}
|
|
55734
55882
|
function verifySums(dir) {
|
|
55735
|
-
const sumsPath =
|
|
55883
|
+
const sumsPath = join23(dir, RELEASE_SUMS_FILE);
|
|
55736
55884
|
const sumsStat = lstatSync2(sumsPath, { throwIfNoEntry: false });
|
|
55737
55885
|
if (sumsStat === void 0 || !sumsStat.isFile()) throw mismatch();
|
|
55738
55886
|
const sums = parseSums(readFileSync14(sumsPath, "utf8"));
|
|
@@ -55756,7 +55904,7 @@ function row4(area, before, after) {
|
|
|
55756
55904
|
return { area, before, after };
|
|
55757
55905
|
}
|
|
55758
55906
|
function bundleDir() {
|
|
55759
|
-
return
|
|
55907
|
+
return ownBundleDir();
|
|
55760
55908
|
}
|
|
55761
55909
|
function pluginRootRow(adapter, env) {
|
|
55762
55910
|
const own4 = bundleDir();
|
|
@@ -55770,16 +55918,16 @@ function pluginRootRow(adapter, env) {
|
|
|
55770
55918
|
return root === own4 ? [] : [row4(UPGRADE_PLUGIN_ROOT_AREA, root, own4)];
|
|
55771
55919
|
}
|
|
55772
55920
|
function isCurrent(agentDir, dir) {
|
|
55773
|
-
const link =
|
|
55774
|
-
return
|
|
55921
|
+
const link = join24(agentDir, PLUGIN_CURRENT_LINK);
|
|
55922
|
+
return existsSync23(link) && realpathSync10.native(link) === realpathSync10.native(dir);
|
|
55775
55923
|
}
|
|
55776
55924
|
async function checkout(adapter, deps) {
|
|
55777
55925
|
const fetched = await fetchRelease(adapter.id, deps.releaseUrl, deps.env, deps.signal);
|
|
55778
|
-
const agentDir =
|
|
55926
|
+
const agentDir = dirname12(fetched.dir);
|
|
55779
55927
|
try {
|
|
55780
55928
|
verifySums(fetched.dir);
|
|
55781
55929
|
} catch (err) {
|
|
55782
|
-
if (!isCurrent(agentDir, fetched.dir))
|
|
55930
|
+
if (!isCurrent(agentDir, fetched.dir)) rmSync11(fetched.dir, { recursive: true, force: true });
|
|
55783
55931
|
throw err;
|
|
55784
55932
|
}
|
|
55785
55933
|
const swap = swapPluginCurrent(agentDir, fetched.sha);
|
|
@@ -55964,7 +56112,7 @@ function workspaceFromMeta(meta3) {
|
|
|
55964
56112
|
if (typeof cwd !== "string" || cwd === "") return void 0;
|
|
55965
56113
|
if (!cwd.startsWith(FILE_URL_PREFIX)) return cwd;
|
|
55966
56114
|
try {
|
|
55967
|
-
return
|
|
56115
|
+
return fileURLToPath3(cwd);
|
|
55968
56116
|
} catch {
|
|
55969
56117
|
return void 0;
|
|
55970
56118
|
}
|
|
@@ -55980,7 +56128,7 @@ function workspaceCwdOf(meta3, spawnCwd, script) {
|
|
|
55980
56128
|
const fromHost = workspaceFromMeta(meta3);
|
|
55981
56129
|
if (fromHost !== void 0) return fromHost;
|
|
55982
56130
|
if (script === void 0 || script === "") return spawnCwd;
|
|
55983
|
-
return realOrSame(spawnCwd) === realOrSame(
|
|
56131
|
+
return realOrSame(spawnCwd) === realOrSame(dirname13(script)) ? "" : spawnCwd;
|
|
55984
56132
|
}
|
|
55985
56133
|
function errorReply(err) {
|
|
55986
56134
|
if (err instanceof CtxError) return { text: err.toLine(), isError: true, sandboxBytes: 0 };
|
|
@@ -56019,15 +56167,15 @@ async function startServer(argv, env) {
|
|
|
56019
56167
|
opening.catch(() => pending.delete(project.dbPath));
|
|
56020
56168
|
}
|
|
56021
56169
|
const db = await opening;
|
|
56022
|
-
if (!
|
|
56170
|
+
if (!existsSync24(db.path)) throw new CtxError("DB_GONE");
|
|
56023
56171
|
return db;
|
|
56024
56172
|
}
|
|
56025
56173
|
function stopMarker(configDir, projectKey) {
|
|
56026
|
-
return
|
|
56174
|
+
return join25(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
|
|
56027
56175
|
}
|
|
56028
56176
|
function stopRequested() {
|
|
56029
56177
|
const configDir = resolveConfigDir(process.env);
|
|
56030
|
-
return held.some((db) =>
|
|
56178
|
+
return held.some((db) => existsSync24(stopMarker(configDir, db.projectKey)));
|
|
56031
56179
|
}
|
|
56032
56180
|
async function journal(project, ctx, name, reply4) {
|
|
56033
56181
|
const db = await ownDb(project);
|
|
@@ -56120,7 +56268,7 @@ async function startServer(argv, env) {
|
|
|
56120
56268
|
try {
|
|
56121
56269
|
const configDir = resolveConfigDir(process.env);
|
|
56122
56270
|
removeOwnerPid(configDir, db.projectKey, serverId);
|
|
56123
|
-
|
|
56271
|
+
rmSync12(stopMarker(configDir, db.projectKey), { force: true });
|
|
56124
56272
|
} catch (err) {
|
|
56125
56273
|
console.error(err);
|
|
56126
56274
|
}
|
|
@@ -56136,7 +56284,7 @@ async function startServer(argv, env) {
|
|
|
56136
56284
|
handle = serveStdio(createServer);
|
|
56137
56285
|
await new Promise((resolve6) => process.once("exit", () => resolve6()));
|
|
56138
56286
|
}
|
|
56139
|
-
if (isEntry(import.meta.main, process.argv[1],
|
|
56287
|
+
if (isEntry(import.meta.main, process.argv[1], fileURLToPath3(import.meta.url))) {
|
|
56140
56288
|
const [, , ...cliArgs] = process.argv;
|
|
56141
56289
|
await startServer(cliArgs, process.env);
|
|
56142
56290
|
}
|