context-mode 2.1.6 → 2.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.zcode-plugin/plugin.json +1 -1
- package/README.md +72 -72
- package/SHA256SUMS +16 -16
- package/cli.mjs +238 -61
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +98 -98
- package/opencode/plugin.js +253 -64
- package/package.json +1 -1
- package/pi/index.js +262 -73
- package/qwen-extension.json +1 -1
- package/run.mjs +130 -7
- package/search.mjs +130 -7
- package/server.mjs +283 -94
package/cli.mjs
CHANGED
|
@@ -88,7 +88,7 @@ var require_src = __commonJS({
|
|
|
88
88
|
|
|
89
89
|
// src/entries/cli.ts
|
|
90
90
|
import { spawn as spawn4 } from "node:child_process";
|
|
91
|
-
import { readFileSync as
|
|
91
|
+
import { readFileSync as readFileSync14, realpathSync as realpathSync11 } from "node:fs";
|
|
92
92
|
import path14 from "node:path";
|
|
93
93
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
94
94
|
|
|
@@ -389,6 +389,7 @@ function D2_NODE_DETAIL(version) {
|
|
|
389
389
|
var D2_SQLITE_DETAIL = "node:sqlite failed to load";
|
|
390
390
|
var D2_SQLITE_FIX = "run ctx_doctor";
|
|
391
391
|
var D3_PARTS = Object.freeze(["MCP entry", "hook entries", "hook timeout"]);
|
|
392
|
+
var PLUGIN_MARKETPLACE_NAME = "context-mode";
|
|
392
393
|
var AGENT_HOME_DIR = Object.freeze({
|
|
393
394
|
"claude-code": [".claude"],
|
|
394
395
|
codex: [".codex"],
|
|
@@ -421,6 +422,90 @@ var OPS_SPLIT_FILES = Object.freeze([
|
|
|
421
422
|
"v1-remove.ts",
|
|
422
423
|
"uninstall.ts"
|
|
423
424
|
]);
|
|
425
|
+
var unsupported = (h2) => Object.freeze(h2);
|
|
426
|
+
var UNSUPPORTED_HOSTS = Object.freeze([
|
|
427
|
+
unsupported({
|
|
428
|
+
id: "antigravity",
|
|
429
|
+
name: "Antigravity",
|
|
430
|
+
clientNames: ["antigravity", "antigravity-client", "antigravity-cli", "agy"],
|
|
431
|
+
envVars: ["ANTIGRAVITY_CLI_ALIAS"],
|
|
432
|
+
pluginPaths: [[".gemini", "config", "plugins"], [".gemini", "antigravity", "plugins"], [".gemini", "antigravity-cli", "plugins"], [".gemini", "antigravity-ide", "plugins"]],
|
|
433
|
+
configDirs: [".gemini/antigravity", ".gemini/antigravity-cli", ".gemini/config"],
|
|
434
|
+
binaries: ["agy"],
|
|
435
|
+
source: "v1.0.169:src/adapters/client-map.ts:15-17; detect.ts:156,481-483; #1340"
|
|
436
|
+
}),
|
|
437
|
+
unsupported({
|
|
438
|
+
id: "cursor",
|
|
439
|
+
name: "Cursor",
|
|
440
|
+
clientNames: ["cursor-vscode"],
|
|
441
|
+
envVars: ["CURSOR_TRACE_ID", "CURSOR_CLI", "CURSOR_CWD"],
|
|
442
|
+
pluginPaths: [],
|
|
443
|
+
configDirs: [".cursor"],
|
|
444
|
+
binaries: [],
|
|
445
|
+
source: "v1.0.169:src/adapters/client-map.ts:18; detect.ts:163-165,584"
|
|
446
|
+
}),
|
|
447
|
+
unsupported({
|
|
448
|
+
id: "omp",
|
|
449
|
+
name: "OMP (oh-my-pi)",
|
|
450
|
+
clientNames: ["omp-coding-agent"],
|
|
451
|
+
envVars: [],
|
|
452
|
+
pluginPaths: [],
|
|
453
|
+
configDirs: [".omp"],
|
|
454
|
+
binaries: ["omp"],
|
|
455
|
+
source: "v1.0.169:src/adapters/client-map.ts:37; detect.ts:543 (PI_CODING_AGENT_DIR is not a signal: supported Pi reads it too)"
|
|
456
|
+
}),
|
|
457
|
+
unsupported({
|
|
458
|
+
id: "openclaw",
|
|
459
|
+
name: "OpenClaw",
|
|
460
|
+
clientNames: [],
|
|
461
|
+
envVars: [],
|
|
462
|
+
pluginPaths: [],
|
|
463
|
+
configDirs: [".openclaw"],
|
|
464
|
+
binaries: [],
|
|
465
|
+
source: "v1.0.169:src/adapters/detect.ts:252,575 (the runtime sets no env var)"
|
|
466
|
+
}),
|
|
467
|
+
unsupported({
|
|
468
|
+
id: "kimi",
|
|
469
|
+
name: "Kimi Code",
|
|
470
|
+
clientNames: ["kimi-code", "kimi"],
|
|
471
|
+
envVars: [],
|
|
472
|
+
pluginPaths: [],
|
|
473
|
+
configDirs: [".kimi-code"],
|
|
474
|
+
binaries: ["kimi"],
|
|
475
|
+
source: "v1.0.169:src/adapters/client-map.ts:42-44; detect.ts:567; adapters/kimi/index.ts:127"
|
|
476
|
+
}),
|
|
477
|
+
unsupported({
|
|
478
|
+
id: "kilo",
|
|
479
|
+
name: "Kilo Code",
|
|
480
|
+
clientNames: ["kilo code"],
|
|
481
|
+
envVars: ["KILO", "KILO_PID"],
|
|
482
|
+
pluginPaths: [],
|
|
483
|
+
configDirs: [".config/kilo"],
|
|
484
|
+
binaries: [],
|
|
485
|
+
source: "v1.0.169:src/adapters/client-map.ts:28; detect.ts:170-171,592"
|
|
486
|
+
}),
|
|
487
|
+
unsupported({
|
|
488
|
+
id: "zed",
|
|
489
|
+
name: "Zed",
|
|
490
|
+
clientNames: ["zed"],
|
|
491
|
+
envVars: ["ZED_SESSION_ID", "ZED_TERM"],
|
|
492
|
+
pluginPaths: [],
|
|
493
|
+
configDirs: [".config/zed"],
|
|
494
|
+
binaries: [],
|
|
495
|
+
source: "v1.0.169:src/adapters/client-map.ts:38-39; detect.ts:189-190,616"
|
|
496
|
+
}),
|
|
497
|
+
unsupported({
|
|
498
|
+
id: "jetbrains-copilot",
|
|
499
|
+
name: "JetBrains Copilot",
|
|
500
|
+
clientNames: ["jetbrains client", "intellij idea", "pycharm"],
|
|
501
|
+
envVars: ["IDEA_INITIAL_DIRECTORY"],
|
|
502
|
+
pluginPaths: [],
|
|
503
|
+
configDirs: [".config/JetBrains"],
|
|
504
|
+
binaries: [],
|
|
505
|
+
source: "v1.0.169:src/adapters/client-map.ts:23-25; detect.ts:213,600"
|
|
506
|
+
})
|
|
507
|
+
]);
|
|
508
|
+
var SUPPORTED_AGENTS_DOCS_URL = "https://github.com/mksglu/context-mode/blob/main/docs/install/README.md";
|
|
424
509
|
var HOOK_HOST_FILE = Object.freeze({
|
|
425
510
|
"claude-code": { root: "plugin", file: ["hooks", "claude-code.json"], key: ["hooks"], shape: "nested", timeoutKey: "timeout", matcher: true },
|
|
426
511
|
codex: { root: "home", file: [".codex", "hooks.json"], key: ["hooks"], shape: "nested", timeoutKey: "timeout", matcher: true },
|
|
@@ -1696,10 +1781,51 @@ function getAdapter(id) {
|
|
|
1696
1781
|
return BY_ID.get(id);
|
|
1697
1782
|
}
|
|
1698
1783
|
|
|
1784
|
+
// src/core/contracts/agents.ts
|
|
1785
|
+
var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode"];
|
|
1786
|
+
|
|
1787
|
+
// src/core/ops/unsupported-host.ts
|
|
1788
|
+
var SUPPORTED_AGENTS_LINE = `Supported agents: ${AGENT_IDS.join(", ")} (${SUPPORTED_AGENTS_DOCS_URL}).`;
|
|
1789
|
+
function UNSUPPORTED_HOST_LINE(name) {
|
|
1790
|
+
return `${name} is not a supported host today. The MCP server runs here; hooks are not checked. ${SUPPORTED_AGENTS_LINE}`;
|
|
1791
|
+
}
|
|
1792
|
+
function UNSUPPORTED_SETUP_LINE(name) {
|
|
1793
|
+
return `${name} is not a supported host today. Setup writes nothing for it. ${SUPPORTED_AGENTS_LINE}`;
|
|
1794
|
+
}
|
|
1795
|
+
function segmentsOf(dir) {
|
|
1796
|
+
let parts = [dir];
|
|
1797
|
+
for (const sep3 of V1_PATH_SEPS) parts = parts.flatMap((p3) => p3.split(sep3));
|
|
1798
|
+
return parts;
|
|
1799
|
+
}
|
|
1800
|
+
function hasRun(parts, run) {
|
|
1801
|
+
for (let i2 = 0; i2 + run.length <= parts.length; i2++) if (run.every((seg, k) => parts[i2 + k] === seg)) return true;
|
|
1802
|
+
return false;
|
|
1803
|
+
}
|
|
1804
|
+
function unsupportedHostOf(sig) {
|
|
1805
|
+
if (sig.clientName !== void 0 && sig.clientName !== "") {
|
|
1806
|
+
const n3 = sig.clientName.toLowerCase();
|
|
1807
|
+
const hit = UNSUPPORTED_HOSTS.find((h2) => h2.clientNames.includes(n3));
|
|
1808
|
+
if (hit !== void 0) return hit;
|
|
1809
|
+
}
|
|
1810
|
+
if (sig.bundleDir !== void 0) {
|
|
1811
|
+
const parts = segmentsOf(sig.bundleDir);
|
|
1812
|
+
const hit = UNSUPPORTED_HOSTS.find((h2) => h2.pluginPaths.some((p3) => hasRun(parts, p3)));
|
|
1813
|
+
if (hit !== void 0) return hit;
|
|
1814
|
+
}
|
|
1815
|
+
if (sig.clientName !== void 0 && sig.clientName !== "") return void 0;
|
|
1816
|
+
const env = sig.env;
|
|
1817
|
+
if (env === void 0) return void 0;
|
|
1818
|
+
return UNSUPPORTED_HOSTS.find((h2) => h2.envVars.some((v) => env[v] !== void 0 && env[v] !== ""));
|
|
1819
|
+
}
|
|
1820
|
+
function unsupportedHostByName(name) {
|
|
1821
|
+
const n3 = name.toLowerCase();
|
|
1822
|
+
return UNSUPPORTED_HOSTS.find((h2) => h2.id === n3 || h2.clientNames.includes(n3) || h2.binaries.includes(n3));
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1699
1825
|
// src/cli/args.ts
|
|
1700
1826
|
var COMMANDS = ["setup", "doctor", "upgrade"];
|
|
1701
1827
|
var ALL_COMMANDS = ["setup", "doctor", "upgrade", "server", "mcp", "hook", "help"];
|
|
1702
|
-
var
|
|
1828
|
+
var AGENT_IDS2 = ADAPTERS.map((a2) => a2.id);
|
|
1703
1829
|
var COMMON = ["--help", "-h", "--json", "--yes", "-y", "--no-input", "--debug", "--quiet", "-q", "--verbose", "--no-color", "--agents"];
|
|
1704
1830
|
var FLAGS = {
|
|
1705
1831
|
setup: [...COMMON, "--dry-run", "--list", "--remove", "--repair", "--print"],
|
|
@@ -1710,6 +1836,11 @@ var VALUE_FLAGS = /* @__PURE__ */ new Set(["--agents", "--tag", "--print"]);
|
|
|
1710
1836
|
var TAG_RE = /^[a-z0-9][a-z0-9.+-]*$/i;
|
|
1711
1837
|
var UsageError = class extends Error {
|
|
1712
1838
|
};
|
|
1839
|
+
function badAgent(name) {
|
|
1840
|
+
const h2 = unsupportedHostByName(name);
|
|
1841
|
+
if (h2 !== void 0) return new UsageError(UNSUPPORTED_SETUP_LINE(h2.name));
|
|
1842
|
+
return new UsageError(`unknown agent "${name}".${suggest(name, AGENT_IDS2)} ${SUPPORTED_AGENTS_LINE} Run context-mode setup --list.`);
|
|
1843
|
+
}
|
|
1713
1844
|
function distance(a2, b3) {
|
|
1714
1845
|
const row = Array.from({ length: b3.length + 1 }, (_2, i2) => i2);
|
|
1715
1846
|
for (let i2 = 1; i2 <= a2.length; i2++) {
|
|
@@ -1794,13 +1925,13 @@ function parseFlags(cmd, argv) {
|
|
|
1794
1925
|
f2.tag = value;
|
|
1795
1926
|
break;
|
|
1796
1927
|
case "--print":
|
|
1797
|
-
if (!
|
|
1928
|
+
if (!AGENT_IDS2.includes(value)) throw badAgent(value);
|
|
1798
1929
|
f2.print = value;
|
|
1799
1930
|
break;
|
|
1800
1931
|
case "--agents": {
|
|
1801
1932
|
const ids = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
1802
1933
|
for (const id of ids) {
|
|
1803
|
-
if (!
|
|
1934
|
+
if (!AGENT_IDS2.includes(id)) throw badAgent(id);
|
|
1804
1935
|
}
|
|
1805
1936
|
f2.agents = [...new Set(ids)];
|
|
1806
1937
|
break;
|
|
@@ -4851,6 +4982,11 @@ function claudeDirOf(env, home) {
|
|
|
4851
4982
|
const dir = env[CLAUDE_CONFIG_DIR_ENV];
|
|
4852
4983
|
return dir !== void 0 && dir !== "" ? dir : join2(home, ...AGENT_HOME_DIR["claude-code"]);
|
|
4853
4984
|
}
|
|
4985
|
+
function claudeProfileEnv(env, platform = process.platform) {
|
|
4986
|
+
const dir = env[CLAUDE_CONFIG_DIR_ENV];
|
|
4987
|
+
if (dir === void 0 || dir === "" || platform === "win32") return "";
|
|
4988
|
+
return `${CLAUDE_CONFIG_DIR_ENV}='${dir.split("'").join(`'"'"'`)}' `;
|
|
4989
|
+
}
|
|
4854
4990
|
function opencodeDirOf(env, home) {
|
|
4855
4991
|
const own2 = env[OPENCODE_CONFIG_DIR_ENV];
|
|
4856
4992
|
if (own2 !== void 0 && own2 !== "") return own2;
|
|
@@ -4880,7 +5016,7 @@ function dataRootOf(env, home) {
|
|
|
4880
5016
|
|
|
4881
5017
|
// src/core/ops/doctor-issue.ts
|
|
4882
5018
|
import { spawnSync } from "node:child_process";
|
|
4883
|
-
import { closeSync as closeSync2, existsSync as existsSync10, fstatSync, mkdirSync as mkdirSync4, openSync as openSync2, readFileSync as
|
|
5019
|
+
import { closeSync as closeSync2, existsSync as existsSync10, fstatSync, mkdirSync as mkdirSync4, openSync as openSync2, readFileSync as readFileSync7, readSync as readSync2, realpathSync as realpathSync5, writeFileSync as writeFileSync2 } from "node:fs";
|
|
4884
5020
|
import { delimiter, join as join11 } from "node:path";
|
|
4885
5021
|
|
|
4886
5022
|
// src/core/hooks/fallback.ts
|
|
@@ -5018,8 +5154,31 @@ CREATE VIRTUAL TABLE line_units USING fts5(
|
|
|
5018
5154
|
var { existsSync: existsSync3, linkSync, mkdirSync: mkdirSync2, rmSync } = process.getBuiltinModule("node:fs");
|
|
5019
5155
|
|
|
5020
5156
|
// src/core/ops/doctor-config.ts
|
|
5021
|
-
import { existsSync as existsSync9, readdirSync as readdirSync5 } from "node:fs";
|
|
5022
|
-
import { join as join10 } from "node:path";
|
|
5157
|
+
import { existsSync as existsSync9, readdirSync as readdirSync5, readFileSync as readFileSync6 } from "node:fs";
|
|
5158
|
+
import { dirname as dirname7, join as join10 } from "node:path";
|
|
5159
|
+
|
|
5160
|
+
// src/core/ops/host-text.ts
|
|
5161
|
+
var BOM_CODE = 65279;
|
|
5162
|
+
var CR_CODE = 13;
|
|
5163
|
+
var CRLF = "\r\n";
|
|
5164
|
+
var LF = "\n";
|
|
5165
|
+
function hostLayout(raw) {
|
|
5166
|
+
let crlf = 0;
|
|
5167
|
+
let lf = 0;
|
|
5168
|
+
for (let i2 = raw.indexOf(LF); i2 >= 0; i2 = raw.indexOf(LF, i2 + 1)) {
|
|
5169
|
+
if (i2 > 0 && raw.charCodeAt(i2 - 1) === CR_CODE) crlf += 1;
|
|
5170
|
+
else lf += 1;
|
|
5171
|
+
}
|
|
5172
|
+
return { bom: raw.length > 0 && raw.charCodeAt(0) === BOM_CODE, crlf: crlf > 0 && crlf >= lf };
|
|
5173
|
+
}
|
|
5174
|
+
function hostText(raw) {
|
|
5175
|
+
const bare = raw.length > 0 && raw.charCodeAt(0) === BOM_CODE ? raw.slice(1) : raw;
|
|
5176
|
+
return bare.indexOf(CRLF) < 0 ? bare : bare.split(CRLF).join(LF);
|
|
5177
|
+
}
|
|
5178
|
+
function withLayout(text2, layout) {
|
|
5179
|
+
const eol = layout.crlf ? text2.split(LF).join(CRLF) : text2;
|
|
5180
|
+
return layout.bom ? String.fromCharCode(BOM_CODE) + eol : eol;
|
|
5181
|
+
}
|
|
5023
5182
|
|
|
5024
5183
|
// src/core/ops/detect-v1.ts
|
|
5025
5184
|
import { existsSync as existsSync6, opendirSync, readdirSync as readdirSync3, readFileSync as readFileSync3 } from "node:fs";
|
|
@@ -7141,29 +7300,6 @@ import { existsSync as existsSync4 } from "node:fs";
|
|
|
7141
7300
|
import { dirname as dirname4, join as join6 } from "node:path";
|
|
7142
7301
|
import { fileURLToPath } from "node:url";
|
|
7143
7302
|
|
|
7144
|
-
// src/core/ops/host-text.ts
|
|
7145
|
-
var BOM_CODE = 65279;
|
|
7146
|
-
var CR_CODE = 13;
|
|
7147
|
-
var CRLF = "\r\n";
|
|
7148
|
-
var LF = "\n";
|
|
7149
|
-
function hostLayout(raw) {
|
|
7150
|
-
let crlf = 0;
|
|
7151
|
-
let lf = 0;
|
|
7152
|
-
for (let i2 = raw.indexOf(LF); i2 >= 0; i2 = raw.indexOf(LF, i2 + 1)) {
|
|
7153
|
-
if (i2 > 0 && raw.charCodeAt(i2 - 1) === CR_CODE) crlf += 1;
|
|
7154
|
-
else lf += 1;
|
|
7155
|
-
}
|
|
7156
|
-
return { bom: raw.length > 0 && raw.charCodeAt(0) === BOM_CODE, crlf: crlf > 0 && crlf >= lf };
|
|
7157
|
-
}
|
|
7158
|
-
function hostText(raw) {
|
|
7159
|
-
const bare = raw.length > 0 && raw.charCodeAt(0) === BOM_CODE ? raw.slice(1) : raw;
|
|
7160
|
-
return bare.indexOf(CRLF) < 0 ? bare : bare.split(CRLF).join(LF);
|
|
7161
|
-
}
|
|
7162
|
-
function withLayout(text2, layout) {
|
|
7163
|
-
const eol = layout.crlf ? text2.split(LF).join(CRLF) : text2;
|
|
7164
|
-
return layout.bom ? String.fromCharCode(BOM_CODE) + eol : eol;
|
|
7165
|
-
}
|
|
7166
|
-
|
|
7167
7303
|
// src/core/ops/host-config.ts
|
|
7168
7304
|
function stripJsonComments(text2) {
|
|
7169
7305
|
let out2 = "";
|
|
@@ -8188,7 +8324,16 @@ function cliFor(ctx, id) {
|
|
|
8188
8324
|
function copyFor(ctx, id) {
|
|
8189
8325
|
if (id !== "claude-code") return void 0;
|
|
8190
8326
|
const file = path4.join(claudeDirOf(ctx.env, ctx.home), HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE);
|
|
8191
|
-
return {
|
|
8327
|
+
return {
|
|
8328
|
+
host: "Claude Code",
|
|
8329
|
+
bin: "claude",
|
|
8330
|
+
plugin: PLUGIN_ID,
|
|
8331
|
+
file,
|
|
8332
|
+
refresh: ["plugin", "update", PLUGIN_ID],
|
|
8333
|
+
enable: ["plugin", "enable", PLUGIN_ID],
|
|
8334
|
+
marketplace: ["plugin", "marketplace", "update", PLUGIN_MARKETPLACE_NAME],
|
|
8335
|
+
profile: claudeProfileEnv(ctx.env, ctx.platform ?? process.platform)
|
|
8336
|
+
};
|
|
8192
8337
|
}
|
|
8193
8338
|
var LIST = {
|
|
8194
8339
|
"claude-code": { bin: "claude", args: ["plugin", "list"] },
|
|
@@ -8304,7 +8449,7 @@ function assertWritable(row, file) {
|
|
|
8304
8449
|
}
|
|
8305
8450
|
|
|
8306
8451
|
// src/setup/gemini-gate.ts
|
|
8307
|
-
import { existsSync as existsSync12, readFileSync as
|
|
8452
|
+
import { existsSync as existsSync12, readFileSync as readFileSync8 } from "node:fs";
|
|
8308
8453
|
import path5 from "node:path";
|
|
8309
8454
|
var GEMINI_DIR = ".gemini";
|
|
8310
8455
|
var SETTINGS_FILE2 = "settings.json";
|
|
@@ -8326,7 +8471,7 @@ function systemDefaultsPath(env) {
|
|
|
8326
8471
|
function load2(file) {
|
|
8327
8472
|
if (!existsSync12(file)) return void 0;
|
|
8328
8473
|
try {
|
|
8329
|
-
return { file, doc: parseHostConfig(OWN_AGENT, file, hostText(
|
|
8474
|
+
return { file, doc: parseHostConfig(OWN_AGENT, file, hostText(readFileSync8(file, "utf8")), "jsonc") };
|
|
8330
8475
|
} catch {
|
|
8331
8476
|
return void 0;
|
|
8332
8477
|
}
|
|
@@ -8358,7 +8503,7 @@ function geminiSettingsGate(env, home, cwd) {
|
|
|
8358
8503
|
}
|
|
8359
8504
|
|
|
8360
8505
|
// src/setup/zcode-gate.ts
|
|
8361
|
-
import { existsSync as existsSync13, readFileSync as
|
|
8506
|
+
import { existsSync as existsSync13, readFileSync as readFileSync9 } from "node:fs";
|
|
8362
8507
|
import path6 from "node:path";
|
|
8363
8508
|
var OWN_AGENT2 = "zcode";
|
|
8364
8509
|
var EVENTS = ["SessionStart", "UserPromptSubmit", "PreToolUse", "PermissionRequest", "PostToolUse", "PostToolUseFailure", "Stop"];
|
|
@@ -8453,7 +8598,7 @@ function zcodeConfigGate(home) {
|
|
|
8453
8598
|
if (!existsSync13(file)) return void 0;
|
|
8454
8599
|
let doc;
|
|
8455
8600
|
try {
|
|
8456
|
-
doc = parseHostConfig(OWN_AGENT2, file, hostText(
|
|
8601
|
+
doc = parseHostConfig(OWN_AGENT2, file, hostText(readFileSync9(file, "utf8")), "json");
|
|
8457
8602
|
} catch {
|
|
8458
8603
|
return void 0;
|
|
8459
8604
|
}
|
|
@@ -8463,7 +8608,7 @@ function zcodeConfigGate(home) {
|
|
|
8463
8608
|
}
|
|
8464
8609
|
|
|
8465
8610
|
// src/setup/vscode-gate.ts
|
|
8466
|
-
import { existsSync as existsSync14, readFileSync as
|
|
8611
|
+
import { existsSync as existsSync14, readFileSync as readFileSync10 } from "node:fs";
|
|
8467
8612
|
import path7 from "node:path";
|
|
8468
8613
|
var SETTINGS_FILE3 = "settings.json";
|
|
8469
8614
|
var WORKSPACE_DIR = ".vscode";
|
|
@@ -8474,7 +8619,7 @@ var MANAGED_KEYS = ["allowManagedHooksOnly", "strictPluginOnlyCustomization"];
|
|
|
8474
8619
|
function load3(file) {
|
|
8475
8620
|
if (!existsSync14(file)) return void 0;
|
|
8476
8621
|
try {
|
|
8477
|
-
return { file, doc: parseHostConfig("vscode", file, hostText(
|
|
8622
|
+
return { file, doc: parseHostConfig("vscode", file, hostText(readFileSync10(file, "utf8")), "jsonc") };
|
|
8478
8623
|
} catch {
|
|
8479
8624
|
return void 0;
|
|
8480
8625
|
}
|
|
@@ -8514,7 +8659,7 @@ function vscodeSettingsGate(env, home, cwd, managedFile = managedSettingsPath(en
|
|
|
8514
8659
|
}
|
|
8515
8660
|
|
|
8516
8661
|
// src/setup/qwen-gate.ts
|
|
8517
|
-
import { existsSync as existsSync15, readFileSync as
|
|
8662
|
+
import { existsSync as existsSync15, readFileSync as readFileSync11 } from "node:fs";
|
|
8518
8663
|
import path8 from "node:path";
|
|
8519
8664
|
var KEY = "disableAllHooks";
|
|
8520
8665
|
var SETTINGS = "settings.json";
|
|
@@ -8533,7 +8678,7 @@ function qwenHooksOff(env, home, cwd = process.cwd(), platform = process.platfor
|
|
|
8533
8678
|
if (!existsSync15(file)) continue;
|
|
8534
8679
|
let value;
|
|
8535
8680
|
try {
|
|
8536
|
-
value = hostConfigValueAt(parseHostConfig("qwen", file, hostText(
|
|
8681
|
+
value = hostConfigValueAt(parseHostConfig("qwen", file, hostText(readFileSync11(file, "utf8")), "jsonc"), [KEY]);
|
|
8537
8682
|
} catch {
|
|
8538
8683
|
continue;
|
|
8539
8684
|
}
|
|
@@ -8953,7 +9098,7 @@ function listCopilotHooks(env, file, cwd) {
|
|
|
8953
9098
|
|
|
8954
9099
|
// src/setup/engine.ts
|
|
8955
9100
|
import { spawn as spawn3, spawnSync as spawnSync4 } from "node:child_process";
|
|
8956
|
-
import { closeSync as closeSync3, existsSync as existsSync17, mkdirSync as mkdirSync5, mkdtempSync, openSync as openSync3, readFileSync as
|
|
9101
|
+
import { closeSync as closeSync3, existsSync as existsSync17, mkdirSync as mkdirSync5, mkdtempSync, openSync as openSync3, readFileSync as readFileSync12, readSync as readSync3, readdirSync as readdirSync6, realpathSync as realpathSync9, rmSync as rmSync2, statSync as statSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
8957
9102
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
8958
9103
|
import path12 from "node:path";
|
|
8959
9104
|
|
|
@@ -9053,7 +9198,7 @@ function owningPackage(dir) {
|
|
|
9053
9198
|
const f2 = path12.join(d, "package.json");
|
|
9054
9199
|
if (existsSync17(f2)) {
|
|
9055
9200
|
try {
|
|
9056
|
-
return String(JSON.parse(hostText(
|
|
9201
|
+
return String(JSON.parse(hostText(readFileSync12(f2, "utf8"))).name);
|
|
9057
9202
|
} catch {
|
|
9058
9203
|
return void 0;
|
|
9059
9204
|
}
|
|
@@ -9086,10 +9231,10 @@ function runBin(bin, args, env, input, timeout = VERIFY_TIMEOUT_MS) {
|
|
|
9086
9231
|
return spawnShim(hostBin(bin, env).file ?? bin, args, env, { encoding: "utf8", input, timeout, maxBuffer: Infinity });
|
|
9087
9232
|
}
|
|
9088
9233
|
function readOr(file) {
|
|
9089
|
-
return existsSync17(file) ? hostText(
|
|
9234
|
+
return existsSync17(file) ? hostText(readFileSync12(file, "utf8")) : void 0;
|
|
9090
9235
|
}
|
|
9091
9236
|
function readRaw(file) {
|
|
9092
|
-
return existsSync17(file) ?
|
|
9237
|
+
return existsSync17(file) ? readFileSync12(file, "utf8") : void 0;
|
|
9093
9238
|
}
|
|
9094
9239
|
var atomicWrite = atomicWriteFile;
|
|
9095
9240
|
function pidAlive(pid) {
|
|
@@ -9299,7 +9444,7 @@ function planSkills(row, edits) {
|
|
|
9299
9444
|
if (s.kind !== "dir") return;
|
|
9300
9445
|
for (const f2 of s.files) {
|
|
9301
9446
|
if (!existsSync17(f2.src)) throw new Error(`preflight: ${f2.src} is missing`);
|
|
9302
|
-
const after = renderSkill(
|
|
9447
|
+
const after = renderSkill(readFileSync12(f2.src, "utf8"), s.prefixes);
|
|
9303
9448
|
const before = readRaw(f2.file);
|
|
9304
9449
|
if (before !== after) edits.push({ plain: true, file: f2.file, before, after, changes: [{ file: f2.file, path: f2.name, before: before === void 0 ? null : "old", after: "SKILL.md" }] });
|
|
9305
9450
|
}
|
|
@@ -9325,7 +9470,7 @@ function planRow(row, listed, stale, env, disabled = false) {
|
|
|
9325
9470
|
planHookInstall(row, edits, env);
|
|
9326
9471
|
planSkills(row, edits);
|
|
9327
9472
|
const cli = row.config || !row.cli || listed ? [] : row.cli.install;
|
|
9328
|
-
const refresh = listed && stale && row.copy ? [row.copy.refresh] : [];
|
|
9473
|
+
const refresh = listed && stale && row.copy ? [row.copy.marketplace, row.copy.refresh] : [];
|
|
9329
9474
|
if (listed && disabled && row.copy) refresh.push(row.copy.enable);
|
|
9330
9475
|
return { edits, cli, refresh };
|
|
9331
9476
|
}
|
|
@@ -9433,13 +9578,16 @@ function hookEnabledCheck(row, status) {
|
|
|
9433
9578
|
}
|
|
9434
9579
|
function packageVersion(pkgDir) {
|
|
9435
9580
|
try {
|
|
9436
|
-
const v = JSON.parse(hostText(
|
|
9581
|
+
const v = JSON.parse(hostText(readFileSync12(path12.join(pkgDir, "package.json"), "utf8"))).version;
|
|
9437
9582
|
return typeof v === "string" ? v : void 0;
|
|
9438
9583
|
} catch {
|
|
9439
9584
|
return void 0;
|
|
9440
9585
|
}
|
|
9441
9586
|
}
|
|
9442
|
-
function
|
|
9587
|
+
function copyFix(c3) {
|
|
9588
|
+
return `${c3.profile}${c3.bin} ${c3.marketplace.join(" ")} && ${c3.profile}${c3.bin} ${c3.refresh.join(" ")}`;
|
|
9589
|
+
}
|
|
9590
|
+
function staleCopy(row, pkgDir) {
|
|
9443
9591
|
const c3 = row.copy;
|
|
9444
9592
|
const pkg = packageVersion(pkgDir);
|
|
9445
9593
|
const text2 = c3 ? readOr(c3.file) : void 0;
|
|
@@ -9449,14 +9597,26 @@ function copyCheck(row, pkgDir) {
|
|
|
9449
9597
|
const doc = JSON.parse(text2);
|
|
9450
9598
|
entries = isObj5(doc) && isObj5(doc.plugins) ? doc.plugins[c3.plugin] : void 0;
|
|
9451
9599
|
} catch {
|
|
9452
|
-
return { name: "copy", ok: false, detail: `${c3.file} is not valid JSON; run ${c3
|
|
9600
|
+
return { name: "copy", ok: false, detail: `${c3.file} is not valid JSON; run ${copyFix(c3)}` };
|
|
9453
9601
|
}
|
|
9454
9602
|
if (!Array.isArray(entries)) return void 0;
|
|
9455
9603
|
const versions = entries.filter(isObj5).map((e) => e.version).filter((v) => typeof v === "string");
|
|
9456
9604
|
if (!versions.length) return void 0;
|
|
9457
9605
|
const old = versions.find((v) => v !== pkg);
|
|
9458
|
-
|
|
9459
|
-
|
|
9606
|
+
return old === void 0 ? { name: "copy", ok: true } : { old, pkg };
|
|
9607
|
+
}
|
|
9608
|
+
function copyCheck(row, pkgDir) {
|
|
9609
|
+
const r2 = staleCopy(row, pkgDir);
|
|
9610
|
+
if (r2 === void 0 || "name" in r2) return r2;
|
|
9611
|
+
const c3 = row.copy;
|
|
9612
|
+
return { name: "copy", ok: false, detail: `${c3.host} runs context-mode ${r2.old}, the installed package is ${r2.pkg}; run ${copyFix(c3)}` };
|
|
9613
|
+
}
|
|
9614
|
+
function copyWarn(row, pkgDir, refreshNotes) {
|
|
9615
|
+
const r2 = staleCopy(row, pkgDir);
|
|
9616
|
+
if (r2 === void 0 || "name" in r2) return void 0;
|
|
9617
|
+
const c3 = row.copy;
|
|
9618
|
+
const why = refreshNotes.length ? ` (${refreshNotes.join("; ")})` : "";
|
|
9619
|
+
return { name: "copy", ok: true, warn: true, detail: `${c3.host} still runs context-mode ${r2.old}, the installed package is ${r2.pkg}${why}; run ${copyFix(c3)}` };
|
|
9460
9620
|
}
|
|
9461
9621
|
function degradedDetail(node, env) {
|
|
9462
9622
|
const r2 = spawnSync4(node, ["-p", "process.version"], { env, encoding: "utf8", timeout: VERIFY_TIMEOUT_MS, windowsHide: true });
|
|
@@ -9659,12 +9819,12 @@ function skillsCheck(row, pkgDir) {
|
|
|
9659
9819
|
const own2 = getAdapter(row.id).toolNamePrefix + SKILL_TOOL_STEM;
|
|
9660
9820
|
const foreign = [...new Set(ADAPTERS.map((r2) => r2.toolNamePrefix + SKILL_TOOL_STEM))].filter((n3) => n3 !== SKILL_TOOL_STEM && n3 !== own2);
|
|
9661
9821
|
const bad2 = files.filter((f2) => {
|
|
9662
|
-
const t2 =
|
|
9822
|
+
const t2 = readFileSync12(f2, "utf8");
|
|
9663
9823
|
return !t2.includes(own2) && foreign.some((n3) => t2.includes(n3));
|
|
9664
9824
|
});
|
|
9665
9825
|
return { name: "skills", ok: bad2.length === 0, detail: bad2.length ? `${bad2.join(", ")} without the ${own2}* tool name` : void 0 };
|
|
9666
9826
|
}
|
|
9667
|
-
const bad = s.files.filter((f2) => readRaw(f2.file) !== (existsSync17(f2.src) ? renderSkill(
|
|
9827
|
+
const bad = s.files.filter((f2) => readRaw(f2.file) !== (existsSync17(f2.src) ? renderSkill(readFileSync12(f2.src, "utf8"), s.prefixes) : void 0));
|
|
9668
9828
|
return { name: "skills", ok: bad.length === 0, detail: bad.length ? `${bad.map((f2) => f2.file).join(", ")} missing or without the ${s.prefixes.join(" / ") || "plain"} tool prefix` : void 0 };
|
|
9669
9829
|
}
|
|
9670
9830
|
var CODEX_CONFIG_FILE2 = "config.toml";
|
|
@@ -9944,7 +10104,7 @@ function undo(dir, entries, env) {
|
|
|
9944
10104
|
continue;
|
|
9945
10105
|
}
|
|
9946
10106
|
if (!e.file) continue;
|
|
9947
|
-
if (e.existed && e.backup) atomicWrite(e.file,
|
|
10107
|
+
if (e.existed && e.backup) atomicWrite(e.file, readFileSync12(path12.join(dir, e.backup), "utf8"));
|
|
9948
10108
|
else unlinkWithRetry(e.file);
|
|
9949
10109
|
}
|
|
9950
10110
|
}
|
|
@@ -9959,7 +10119,7 @@ function takeLock(root, runId) {
|
|
|
9959
10119
|
if (e.code !== "EEXIST") throw e;
|
|
9960
10120
|
let pid = 0;
|
|
9961
10121
|
try {
|
|
9962
|
-
pid = Number(JSON.parse(
|
|
10122
|
+
pid = Number(JSON.parse(readFileSync12(file, "utf8")).pid);
|
|
9963
10123
|
} catch {
|
|
9964
10124
|
}
|
|
9965
10125
|
if (pid && pidAlive(pid)) return `setup lock ${file} is held by pid ${pid}; wait for that run or remove the lock`;
|
|
@@ -10057,13 +10217,23 @@ async function setupRow(row, ctx, run, dryRun) {
|
|
|
10057
10217
|
if (!installExitOk(r2.status, r2.status === WIN_EXIT_CRASH && listCheck(row, ctx.env)?.ok === true)) throw new Error(`${row.cli.bin} ${args.join(" ")} exited ${r2.status}: ${`${r2.stderr}`.trim()}`);
|
|
10058
10218
|
}
|
|
10059
10219
|
if (plan.cli.length) for (const args of row.cli.remove) run.record({ agent: row.id, undo: { bin: row.cli.bin, args } });
|
|
10220
|
+
const refreshNotes = [];
|
|
10060
10221
|
for (const args of plan.refresh) {
|
|
10061
10222
|
const r2 = runBin(row.cli.bin, args, ctx.env, void 0, INSTALL_TIMEOUT_MS);
|
|
10062
|
-
|
|
10223
|
+
const failed = `${row.cli.bin} ${args.join(" ")} exited ${r2.status}: ${`${r2.stderr}`.trim()}`;
|
|
10224
|
+
if (r2.status !== 0 && !isCopyRefresh(row, args)) throw new Error(failed);
|
|
10225
|
+
if (r2.status !== 0) {
|
|
10226
|
+
refreshNotes.push(failed);
|
|
10227
|
+
continue;
|
|
10228
|
+
}
|
|
10063
10229
|
run.record({ agent: row.id, ran: { bin: row.cli.bin, args } });
|
|
10064
10230
|
}
|
|
10065
10231
|
res.changes.push(...await enableCopilotHooks(row, ctx, run));
|
|
10066
10232
|
res.checks = await verifyRow(row, ctx);
|
|
10233
|
+
if (plan.refresh.length) {
|
|
10234
|
+
const w = copyWarn(row, ctx.pkgDir, refreshNotes);
|
|
10235
|
+
if (w) res.checks = res.checks.map((c3) => c3.name === "copy" ? w : c3);
|
|
10236
|
+
}
|
|
10067
10237
|
const bad = res.checks.filter((c3) => !c3.ok);
|
|
10068
10238
|
if (bad.length) throw new Error(bad.map((c3) => `${c3.name}: ${c3.detail}`).join("; "));
|
|
10069
10239
|
} catch (e) {
|
|
@@ -10140,7 +10310,12 @@ function isRefresh(row, c3) {
|
|
|
10140
10310
|
const r2 = row.copy;
|
|
10141
10311
|
if (r2 === void 0 || c3.command === void 0) return false;
|
|
10142
10312
|
const cmd = c3.command.join(" ");
|
|
10143
|
-
return
|
|
10313
|
+
return isCopyRefresh(row, c3.command.slice(1)) || cmd === [r2.bin, ...r2.enable].join(" ");
|
|
10314
|
+
}
|
|
10315
|
+
function isCopyRefresh(row, args) {
|
|
10316
|
+
const r2 = row.copy;
|
|
10317
|
+
const a2 = args.join(" ");
|
|
10318
|
+
return r2 !== void 0 && (a2 === r2.refresh.join(" ") || a2 === r2.marketplace.join(" "));
|
|
10144
10319
|
}
|
|
10145
10320
|
function isTrust(row, c3) {
|
|
10146
10321
|
const h2 = row.hookInstall;
|
|
@@ -10157,7 +10332,7 @@ function runRemove(opts) {
|
|
|
10157
10332
|
try {
|
|
10158
10333
|
const runs = readdirSync6(base).map((r2) => path12.join(base, r2)).filter((d) => existsSync17(path12.join(d, MANIFEST))).sort().reverse();
|
|
10159
10334
|
for (const dir of runs) {
|
|
10160
|
-
const m3 = JSON.parse(
|
|
10335
|
+
const m3 = JSON.parse(readFileSync12(path12.join(dir, MANIFEST), "utf8"));
|
|
10161
10336
|
undo(dir, m3.entries, env);
|
|
10162
10337
|
restored += m3.entries.length;
|
|
10163
10338
|
renameWithRetry(path12.join(dir, MANIFEST), path12.join(dir, MANIFEST_DONE));
|
|
@@ -10169,7 +10344,7 @@ function runRemove(opts) {
|
|
|
10169
10344
|
}
|
|
10170
10345
|
|
|
10171
10346
|
// src/setup/print.ts
|
|
10172
|
-
import { readFileSync as
|
|
10347
|
+
import { readFileSync as readFileSync13 } from "node:fs";
|
|
10173
10348
|
var SHELL_SAFE_PUNCT = "@%+=:,./-_";
|
|
10174
10349
|
function isShellSafe(s) {
|
|
10175
10350
|
if (s === "") return false;
|
|
@@ -10197,7 +10372,7 @@ function printPlan(row, env) {
|
|
|
10197
10372
|
else if (h2.kind === "plugin-list") steps.push({ kind: "hook", file: h2.file, block: JSON.stringify({ [h2.key[0]]: [h2.entry] }, null, 2) + "\n" });
|
|
10198
10373
|
const sk = row.skillInstall;
|
|
10199
10374
|
if (sk.kind === "dir") {
|
|
10200
|
-
for (const f2 of sk.files) steps.push({ kind: "skill", file: f2.file, block: renderSkill(
|
|
10375
|
+
for (const f2 of sk.files) steps.push({ kind: "skill", file: f2.file, block: renderSkill(readFileSync13(f2.src, "utf8"), sk.prefixes) });
|
|
10201
10376
|
}
|
|
10202
10377
|
return { agent: row.id, steps, verify: `context-mode doctor --agents ${row.id}` };
|
|
10203
10378
|
}
|
|
@@ -10568,11 +10743,13 @@ async function doctor(ui) {
|
|
|
10568
10743
|
}
|
|
10569
10744
|
});
|
|
10570
10745
|
spin.stop();
|
|
10746
|
+
const other = res.agents.length === 0 ? unsupportedHostOf({ env: process.env }) : void 0;
|
|
10747
|
+
if (other !== void 0 && !ui.f.json) out(UNSUPPORTED_HOST_LINE(other.name));
|
|
10571
10748
|
if (!res.agents.length && !res.error && !ui.f.json) {
|
|
10572
10749
|
out("No agents found. Run context-mode setup --list.");
|
|
10573
10750
|
return EXIT_OK;
|
|
10574
10751
|
}
|
|
10575
|
-
const code = await finish({ ...ui, clack: void 0 }, "doctor", res, false);
|
|
10752
|
+
const code = await finish({ ...ui, clack: void 0 }, "doctor", other === void 0 ? res : { ...res, unsupportedHost: other.id }, false);
|
|
10576
10753
|
const p3 = ui.clack;
|
|
10577
10754
|
if (!p3 || code === EXIT_OK) return code;
|
|
10578
10755
|
let worst = code;
|
|
@@ -10721,7 +10898,7 @@ function main() {
|
|
|
10721
10898
|
const dir = path14.dirname(realpathSync11(fileURLToPath3(import.meta.url)));
|
|
10722
10899
|
let version = "";
|
|
10723
10900
|
try {
|
|
10724
|
-
version = String(JSON.parse(
|
|
10901
|
+
version = String(JSON.parse(readFileSync14(path14.join(dir, PACKAGE_FILE), "utf8")).version);
|
|
10725
10902
|
} catch (err2) {
|
|
10726
10903
|
process.stderr.write(`${SERVER_KEY}: cannot read ${PACKAGE_FILE}: ${err2.message}
|
|
10727
10904
|
`);
|
package/copilot/plugin.json
CHANGED
package/gemini-extension.json
CHANGED