context-mode 2.0.0-next.12 → 2.0.0-next.14
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/SHA256SUMS +14 -14
- package/cli.mjs +188 -31
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +9 -9
- package/opencode/plugin.js +50 -16
- package/package.json +1 -1
- package/pi/index.js +50 -16
- package/qwen-extension.json +1 -1
- package/run.mjs +1 -0
- package/search.mjs +1 -0
- package/server.mjs +50 -16
package/SHA256SUMS
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
cecedcc8e4fc962293b653fad7b1d05cb055bc5a51bb6a02e17abc3ae54cbaf4 .claude-plugin/marketplace.json
|
|
2
|
+
224d1f09f2b7a10ae5a93ee58500619b4b901671d81e98c3ca534da29d5d6c47 .claude-plugin/plugin.json
|
|
3
3
|
187503e1455560d4ab5a72e3b8cd2f274abd4ccc5faa60dd66c37e44bb5f10c2 .codex-plugin/hooks.json
|
|
4
4
|
4edea851775bc3f0418f8d9cf6ead74f2767c3a9e3b8c05749eacb78ebb3b896 .codex-plugin/mcp.json
|
|
5
|
-
|
|
5
|
+
47f2769cab1290d2c900edad8509203cd49f0f78245a2106912f9cd52db36b58 .codex-plugin/plugin.json
|
|
6
6
|
1773e40a89384dd1af9023ba533da1908f3e2435dbaaa7cc941edf0514148313 claude-code/skills/ctx-doctor/SKILL.md
|
|
7
7
|
34fffb9c76d69c551f07036230bec0fbaca7a69177a5a47f89ddb9a9990a1fa2 claude-code/skills/ctx-stats/SKILL.md
|
|
8
8
|
d8f835d2f2b3eb70c5902f8707e7c5857977cec9e20ace76c499378a04e178e0 claude-code/skills/ctx-upgrade/SKILL.md
|
|
9
|
-
|
|
9
|
+
ea916221c7625540f30171fb0736706ceca616a3ae46030dfdcb9e2963335cc0 cli.mjs
|
|
10
10
|
83c297020ed0c592fc68c9c482546a6999d41df5d06d8a329498f10edb1bd38e codex/skills/ctx-doctor/SKILL.md
|
|
11
11
|
adc2c374f699d3698110920bb48411965de09fc6e7232ce59c913f6d58c0d738 codex/skills/ctx-stats/SKILL.md
|
|
12
12
|
5c12cdd19a5e3ed7d9ba3a47b24d03864a28d36cf7006876284ee07cd4221ec4 codex/skills/ctx-upgrade/SKILL.md
|
|
13
|
-
|
|
13
|
+
4b26c382c8ac7a6aa5efbda918551ad6d2ddde2267928014b3bc1f49963e7b7d copilot/plugin.json
|
|
14
14
|
832bf0d31c37a448f3904bc41c7df071777aec2f8fce9d667f1fcf5b03a52a91 fixtures/hook-roundtrip.json
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
a84600102a2055df22ac60475d4ce784d7bead1adf8f9ac6c0221e8a45f7f918 gemini-extension.json
|
|
16
|
+
fb7358e764e8f0b9a9d0f3052abce4c7a96f314335f22b02794a1e5494040dae hook.mjs
|
|
17
17
|
1f8d8650d2b38737522cab6b875878e8baf84a74acf98cd924c7af22852d873f hooks/claude-code.json
|
|
18
18
|
2524a0eb52683b65c65943c5097db513e9845ba14e84324b39e9a8ea2bb43193 hooks/codex.json
|
|
19
19
|
b656fed2b754ebcfd4c156bee81d5879c21a8083fc0d6b8e3241462b63a214b6 hooks/copilot-cli.json
|
|
@@ -22,16 +22,16 @@ f336d1db67de49e641687bbd41ba1a9424e31dfe2377b2284bf44358288ebd8b hooks/kiro.jso
|
|
|
22
22
|
017c9cc3997dd53231b8548b1a1609fddc51177af53501565a4f334602039860 hooks/qwen.json
|
|
23
23
|
33f69267645338d0dc392ce551dcd7c69a0b508113469d6ea637d3f34239ef1d hooks/vscode.json
|
|
24
24
|
085630bccf2073ac9a62be24ef91dfc47d106092dc82c822db70890b7d3ae1c0 hooks/zcode.json
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
1d028c0a3a3703470bb6483964bc838b6a24f79d1fc2253ebe585d8bc31bab4c opencode/plugin.js
|
|
26
|
+
4364e391488424f887652886a5138546f76b34b42c3cac83620f601bb650f5c0 package.json
|
|
27
|
+
4cf8123119a09b181a3273f5c766887c50caf9cee4db5088e4e95cc7a0241084 pi/index.js
|
|
28
28
|
8712881622c9905aa4836af50d903042d34a91506264e459bc7839331f6f0192 pi/skills/ctx-doctor/SKILL.md
|
|
29
29
|
8d6e8e2a82eb079bddc60727f52d9f9a6e0bf9e15391357fed82ee76ab5fe76c pi/skills/ctx-stats/SKILL.md
|
|
30
30
|
db6f9c006bc864a7271f1eeffb1e316ebb537a3414f1c22f8b9de0a896e8e3c5 pi/skills/ctx-upgrade/SKILL.md
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
e2cb24da98c5b78cdd76e97a5e4da6d032aaac5781956b1a85157cf4a9f1aa7b qwen-extension.json
|
|
32
|
+
b408612e309a93e3eeade62a23ccc740856da20bfd508a4456d8f44bc4dfa980 run.mjs
|
|
33
|
+
b408612e309a93e3eeade62a23ccc740856da20bfd508a4456d8f44bc4dfa980 search.mjs
|
|
34
|
+
e82dc1c398f9af8dabbcb25f34f4553d54a123aaa96df4a24faaf1d8605cfac9 server.mjs
|
|
35
35
|
e5503a22a6238901484d123efc11d2d933aa9a54c6ac2018812cfa65ec4e53e3 skills/ctx-doctor/SKILL.md
|
|
36
36
|
1044587a1906c69f2467c089a25e19819a290ea5728389bd1f086c6dfc0d0c51 skills/ctx-stats/SKILL.md
|
|
37
37
|
c1cac75b7506ee0d06089ce611ac6dc9314cf12435da318ce88ad50e2c5debbf skills/ctx-upgrade/SKILL.md
|
package/cli.mjs
CHANGED
|
@@ -87,7 +87,7 @@ var require_src = __commonJS({
|
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
// src/entries/cli.ts
|
|
90
|
-
import { spawn as
|
|
90
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
91
91
|
import { readFileSync as readFileSync6, realpathSync as realpathSync6 } from "node:fs";
|
|
92
92
|
import path8 from "node:path";
|
|
93
93
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
@@ -404,12 +404,13 @@ var V1_STATUSLINE_COMMAND = "context-mode statusline";
|
|
|
404
404
|
var V1_PI_PACKAGE = "npm:context-mode";
|
|
405
405
|
var V1_OPENCODE_PLUGIN_SPEC = "context-mode";
|
|
406
406
|
var V1_TMP_PREFIX = "context-mode-";
|
|
407
|
-
var
|
|
407
|
+
var V1_TOML_SECTION_ROOT = "mcp_servers";
|
|
408
408
|
var V1_HOOKS_DIR_NAME = "hooks";
|
|
409
409
|
var SETTINGS_FILE = "settings.json";
|
|
410
410
|
var CLAUDE_USER_CONFIG_FILE = ".claude.json";
|
|
411
411
|
var HOOKS_JSON_FILE = "hooks.json";
|
|
412
412
|
var CLAUDE_CONFIG_DIR_ENV = "CLAUDE_CONFIG_DIR";
|
|
413
|
+
var CODEX_HOME_ENV = "CODEX_HOME";
|
|
413
414
|
var COPILOT_HOME_ENV = "COPILOT_HOME";
|
|
414
415
|
var KIRO_HOME_ENV = "KIRO_HOME";
|
|
415
416
|
var OPENCODE_CONFIG_DIR_ENV = "OPENCODE_CONFIG_DIR";
|
|
@@ -471,12 +472,19 @@ var V1_REASON = Object.freeze({
|
|
|
471
472
|
});
|
|
472
473
|
var UPGRADE_REPORT_ONLY_REASONS = Object.freeze([V1_REASON.statusLine, V1_REASON.vscodeMcp, V1_REASON.dataDirShared, V1_REASON.tmpFile, V1_REASON.kiroSteering]);
|
|
473
474
|
var OPENCODE_TOOL_PREFIX = SERVER_KEY + "_";
|
|
475
|
+
var SERVER_ENTRY_FILE = "server.mjs";
|
|
476
|
+
var VSCODE_WORKSPACE_VAR = "${workspaceFolder}";
|
|
477
|
+
var OPENCODE_PLUGIN_PATH = Object.freeze(["opencode", "plugin.js"]);
|
|
478
|
+
var HOST_NODE_COMMAND = "node";
|
|
479
|
+
var EXE_SUFFIX = ".exe";
|
|
474
480
|
var ATOMIC_RENAME_RETRIES = 5;
|
|
475
481
|
var ATOMIC_RENAME_DELAY_MS = 50;
|
|
476
482
|
var ATOMIC_RENAME_BUSY_CODES = ["EPERM", "EBUSY", "EACCES"];
|
|
477
483
|
var ATOMIC_TMP_PREFIX = ".";
|
|
478
484
|
var ATOMIC_TMP_MARK = ".cm-tmp-";
|
|
479
485
|
var JSON_INDENT_UNIT = " ";
|
|
486
|
+
var MCP_COMMAND_FIELD = "command";
|
|
487
|
+
var MCP_ARGS_FIELD = "args";
|
|
480
488
|
var ZCODE_MCP_FEATURE_KEY = Object.freeze(["features", "mcp"]);
|
|
481
489
|
var CODEX_OMIT_TOOLS_FROM_FIELD = "omit_tools_from";
|
|
482
490
|
var CODEX_OMIT_DEFERRED = Object.freeze(["deferred"]);
|
|
@@ -4490,6 +4498,10 @@ function homeDirOf(env, platform = process.platform) {
|
|
|
4490
4498
|
if (set2(env.HOME)) return env.HOME;
|
|
4491
4499
|
return set2(env.USERPROFILE) ? env.USERPROFILE : null;
|
|
4492
4500
|
}
|
|
4501
|
+
function codexDirOf(env, home) {
|
|
4502
|
+
const dir = env[CODEX_HOME_ENV];
|
|
4503
|
+
return dir !== void 0 && dir !== "" ? dir : join2(home, ...AGENT_HOME_DIR.codex);
|
|
4504
|
+
}
|
|
4493
4505
|
function copilotDirOf(env, home) {
|
|
4494
4506
|
const dir = env[COPILOT_HOME_ENV];
|
|
4495
4507
|
return dir !== void 0 && dir !== "" ? dir : join2(home, ...AGENT_HOME_DIR["copilot-cli"]);
|
|
@@ -4532,14 +4544,6 @@ function ownMcpFileOf(agent, file, env, home) {
|
|
|
4532
4544
|
// src/setup/registry.ts
|
|
4533
4545
|
import path3 from "node:path";
|
|
4534
4546
|
|
|
4535
|
-
// src/core/ops/doctor-config.ts
|
|
4536
|
-
import { join as join6 } from "node:path";
|
|
4537
|
-
|
|
4538
|
-
// src/core/ops/detect-v1.ts
|
|
4539
|
-
import { existsSync as existsSync3, opendirSync, readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
4540
|
-
import { tmpdir } from "node:os";
|
|
4541
|
-
import { join as join4 } from "node:path";
|
|
4542
|
-
|
|
4543
4547
|
// src/core/ops/host-config.ts
|
|
4544
4548
|
import { existsSync as existsSync2, readFileSync } from "node:fs";
|
|
4545
4549
|
import { dirname as dirname2, join as join3 } from "node:path";
|
|
@@ -6850,9 +6854,6 @@ function scanToml(text2) {
|
|
|
6850
6854
|
function tomlTableSpans(text2) {
|
|
6851
6855
|
return scanToml(text2).tables;
|
|
6852
6856
|
}
|
|
6853
|
-
function tomlHeaderText(path9) {
|
|
6854
|
-
return "[" + path9.map(tomlHeaderKey).join(".") + "]";
|
|
6855
|
-
}
|
|
6856
6857
|
function parseHostConfig(agent, path9, text2, format) {
|
|
6857
6858
|
try {
|
|
6858
6859
|
return format === "toml" ? scanToml(text2).value : scanJson(text2, format).value;
|
|
@@ -7018,6 +7019,19 @@ function setText(agent, path9, text2, format, key, value) {
|
|
|
7018
7019
|
throw new CtxError("CONFIG_PARSE_FAILED", { agent, path: path9, format });
|
|
7019
7020
|
}
|
|
7020
7021
|
}
|
|
7022
|
+
function isNodeCommand(command) {
|
|
7023
|
+
if (typeof command !== "string") return false;
|
|
7024
|
+
let at = -1;
|
|
7025
|
+
for (const sep2 of V1_PATH_SEPS) at = Math.max(at, command.lastIndexOf(sep2));
|
|
7026
|
+
const exe = command.slice(at + 1).toLowerCase();
|
|
7027
|
+
return exe === HOST_NODE_COMMAND || exe === HOST_NODE_COMMAND + EXE_SUFFIX;
|
|
7028
|
+
}
|
|
7029
|
+
function ownMcpValue(agent, node, server) {
|
|
7030
|
+
const mcp = OWN_MCP_ENTRY[agent];
|
|
7031
|
+
if (mcp === void 0) return void 0;
|
|
7032
|
+
const tail = agent === "vscode" ? [WORKSPACE_FOLDER_FLAG, VSCODE_WORKSPACE_VAR] : [];
|
|
7033
|
+
return { ...mcp.fields, [MCP_COMMAND_FIELD]: node, [MCP_ARGS_FIELD]: [server, AGENT_ARG, agent, ...tail] };
|
|
7034
|
+
}
|
|
7021
7035
|
function applyEdits(agent, path9, text2, format, wanted) {
|
|
7022
7036
|
const parsed = parseHostConfig(agent, path9, text2, format);
|
|
7023
7037
|
let out2 = text2;
|
|
@@ -7034,7 +7048,13 @@ function editHostConfigText(agent, path9, text2, format, wanted) {
|
|
|
7034
7048
|
return applyEdits(agent, path9, text2, format, wanted);
|
|
7035
7049
|
}
|
|
7036
7050
|
|
|
7051
|
+
// src/core/ops/doctor-config.ts
|
|
7052
|
+
import { join as join6 } from "node:path";
|
|
7053
|
+
|
|
7037
7054
|
// src/core/ops/detect-v1.ts
|
|
7055
|
+
import { existsSync as existsSync3, opendirSync, readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
7056
|
+
import { tmpdir } from "node:os";
|
|
7057
|
+
import { join as join4 } from "node:path";
|
|
7038
7058
|
var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
7039
7059
|
var keyPath = (...parts) => parts.join(".");
|
|
7040
7060
|
var finding = (file, path9, reason) => ({ file, path: path9, reason });
|
|
@@ -7096,6 +7116,21 @@ function readTomlTables(file) {
|
|
|
7096
7116
|
return [];
|
|
7097
7117
|
}
|
|
7098
7118
|
}
|
|
7119
|
+
function readTomlValue(file) {
|
|
7120
|
+
try {
|
|
7121
|
+
return parseHostConfig("codex", file, readText(file), "toml");
|
|
7122
|
+
} catch {
|
|
7123
|
+
return {};
|
|
7124
|
+
}
|
|
7125
|
+
}
|
|
7126
|
+
function isV2McpTable(v) {
|
|
7127
|
+
if (!isObj(v) || !isNodeCommand(v[MCP_COMMAND_FIELD])) return false;
|
|
7128
|
+
const first = Array.isArray(v[MCP_ARGS_FIELD]) ? v[MCP_ARGS_FIELD][0] : void 0;
|
|
7129
|
+
if (typeof first !== "string") return false;
|
|
7130
|
+
let at = -1;
|
|
7131
|
+
for (const sep2 of V1_PATH_SEPS) at = Math.max(at, first.lastIndexOf(sep2));
|
|
7132
|
+
return first.slice(at + 1) === SERVER_ENTRY_FILE;
|
|
7133
|
+
}
|
|
7099
7134
|
var listOf = (v) => Array.isArray(v) ? v : [];
|
|
7100
7135
|
var commandOf = (v) => isObj(v) && typeof v.command === "string" ? v.command : null;
|
|
7101
7136
|
function nestedCommands(doc) {
|
|
@@ -7169,8 +7204,11 @@ function scanCodex(agentHome, out2) {
|
|
|
7169
7204
|
}
|
|
7170
7205
|
}
|
|
7171
7206
|
const tomlFile = join4(agentHome, CONFIG_TOML_FILE);
|
|
7207
|
+
const config = readTomlValue(tomlFile);
|
|
7172
7208
|
for (const span of readTomlTables(tomlFile)) {
|
|
7173
|
-
if (
|
|
7209
|
+
if (span.path[0] !== V1_TOML_SECTION_ROOT || span.path[1] !== SERVER_KEY) continue;
|
|
7210
|
+
if (span.path.length === 2 && isV2McpTable(hostConfigValueAt(config, span.path))) continue;
|
|
7211
|
+
out2.push(finding(tomlFile, span.header.trim(), V1_REASON.codexToml));
|
|
7174
7212
|
}
|
|
7175
7213
|
dataDir(join4(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out2);
|
|
7176
7214
|
}
|
|
@@ -7282,7 +7320,7 @@ function scanAll(home, tmp, out2) {
|
|
|
7282
7320
|
function detectV1(agent, home, scope = {}) {
|
|
7283
7321
|
const out2 = [];
|
|
7284
7322
|
const project = scope.project;
|
|
7285
|
-
const agentHome = agent === "claude-code" && scope.claudeDir !== void 0 ? scope.claudeDir : 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 : join4(home, ...AGENT_HOME_DIR[agent]);
|
|
7323
|
+
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 : join4(home, ...AGENT_HOME_DIR[agent]);
|
|
7286
7324
|
switch (agent) {
|
|
7287
7325
|
case "claude-code":
|
|
7288
7326
|
scanClaudeCode(home, agentHome, out2);
|
|
@@ -7413,7 +7451,6 @@ function configEdits(c3) {
|
|
|
7413
7451
|
}
|
|
7414
7452
|
var COMMAND_SKILLS = Object.freeze(["ctx-doctor", "ctx-stats", "ctx-upgrade"]);
|
|
7415
7453
|
var SKILL_FILE = "SKILL.md";
|
|
7416
|
-
var OPENCODE_PLUGIN = ["opencode", "plugin.js"];
|
|
7417
7454
|
var CODEX_CONFIG_FILE = "config.toml";
|
|
7418
7455
|
var CODEX_HOME_ENV2 = "CODEX_HOME";
|
|
7419
7456
|
var CODEX_DIR = ".codex";
|
|
@@ -7457,7 +7494,7 @@ function extensionPlugin(bin, id) {
|
|
|
7457
7494
|
};
|
|
7458
7495
|
}
|
|
7459
7496
|
var NATIVE_PLUGIN = {
|
|
7460
|
-
codex: { bin: "codex", args: ["plugin", "list"], plugin: PLUGIN_ID, hooksVia: ".codex-plugin", skillsVia: path3.join("codex", SKILLS_DIR_NAME), format: "table" },
|
|
7497
|
+
codex: { bin: "codex", args: ["plugin", "list"], plugin: PLUGIN_ID, hooksVia: ".codex-plugin", skillsVia: path3.join("codex", SKILLS_DIR_NAME), format: "table", hookTrust: true },
|
|
7461
7498
|
qwen: extensionPlugin("qwen", "qwen"),
|
|
7462
7499
|
gemini: extensionPlugin("gemini", "gemini")
|
|
7463
7500
|
};
|
|
@@ -7478,16 +7515,14 @@ function golden(row, home) {
|
|
|
7478
7515
|
tool_input: { command: "true" }
|
|
7479
7516
|
};
|
|
7480
7517
|
}
|
|
7481
|
-
var VSCODE_WORKSPACE_VAR = "${workspaceFolder}";
|
|
7482
7518
|
function configFor(ctx, id) {
|
|
7483
7519
|
const [node, server, flag, agent] = serverCmd(ctx, id);
|
|
7484
7520
|
const own2 = OWN_MCP_ENTRY[id];
|
|
7485
7521
|
if (own2) {
|
|
7486
7522
|
const file = id === "vscode" ? ownMcpFileOf(id, own2.file, ctx.env, ctx.home) : agentPath(ctx, id, own2.file);
|
|
7487
7523
|
const format = file.endsWith(".toml") ? "toml" : id === "vscode" ? "jsonc" : "json";
|
|
7488
|
-
const args = id === "vscode" ? [server, flag, agent, WORKSPACE_FOLDER_FLAG, VSCODE_WORKSPACE_VAR] : [server, flag, agent];
|
|
7489
7524
|
const also = own2.also?.map(([k, v]) => [k, v]);
|
|
7490
|
-
return { file, format, key: own2.key, value:
|
|
7525
|
+
return { file, format, key: own2.key, value: ownMcpValue(id, node, server), ...also ? { also } : {} };
|
|
7491
7526
|
}
|
|
7492
7527
|
if (id === "opencode") {
|
|
7493
7528
|
return {
|
|
@@ -7564,7 +7599,7 @@ function hookInstallFor(ctx, row, command) {
|
|
|
7564
7599
|
kind: "plugin-list",
|
|
7565
7600
|
file: path3.join(opencodeDirOf(ctx.env, ctx.home), OPENCODE_BASE_CONFIG_FILE),
|
|
7566
7601
|
key: ["plugin"],
|
|
7567
|
-
entry: path3.join(ctx.pkgDir, ...
|
|
7602
|
+
entry: path3.join(ctx.pkgDir, ...OPENCODE_PLUGIN_PATH)
|
|
7568
7603
|
};
|
|
7569
7604
|
}
|
|
7570
7605
|
return { kind: "package", via: ch.path };
|
|
@@ -7634,6 +7669,7 @@ function assertWritable(row, file) {
|
|
|
7634
7669
|
import { createHash } from "node:crypto";
|
|
7635
7670
|
import { existsSync as existsSync5, realpathSync as realpathSync3 } from "node:fs";
|
|
7636
7671
|
import path5 from "node:path";
|
|
7672
|
+
import { spawn } from "node:child_process";
|
|
7637
7673
|
|
|
7638
7674
|
// src/setup/spawn-bin.ts
|
|
7639
7675
|
import { spawnSync } from "node:child_process";
|
|
@@ -7804,9 +7840,84 @@ function codexTrustEntries(hooksFile, doc, command, env) {
|
|
|
7804
7840
|
}
|
|
7805
7841
|
return out2;
|
|
7806
7842
|
}
|
|
7843
|
+
var LIST_TIMEOUT_MS = 15e3;
|
|
7844
|
+
var PLUGIN_SOURCE = "plugin";
|
|
7845
|
+
var TRUSTED = "trusted";
|
|
7846
|
+
function pluginHooksFromReply(m3, pluginId) {
|
|
7847
|
+
const out2 = [];
|
|
7848
|
+
if (!isObj2(m3) || !isObj2(m3.result) || !Array.isArray(m3.result.data)) return out2;
|
|
7849
|
+
for (const d of m3.result.data) {
|
|
7850
|
+
if (!isObj2(d) || !Array.isArray(d.hooks)) continue;
|
|
7851
|
+
for (const h2 of d.hooks) {
|
|
7852
|
+
if (!isObj2(h2) || h2.source !== PLUGIN_SOURCE || h2.pluginId !== pluginId) continue;
|
|
7853
|
+
if (typeof h2.key !== "string" || typeof h2.currentHash !== "string") continue;
|
|
7854
|
+
if (out2.some((x2) => x2.key === h2.key)) continue;
|
|
7855
|
+
out2.push({ key: h2.key, hash: h2.currentHash, trusted: h2.trustStatus === TRUSTED });
|
|
7856
|
+
}
|
|
7857
|
+
}
|
|
7858
|
+
return out2;
|
|
7859
|
+
}
|
|
7860
|
+
function listPluginHooks(env, pluginId, cwd) {
|
|
7861
|
+
const bin = whichBin("codex", env);
|
|
7862
|
+
if (!bin) return Promise.resolve(void 0);
|
|
7863
|
+
return new Promise((resolve) => {
|
|
7864
|
+
let f2;
|
|
7865
|
+
try {
|
|
7866
|
+
f2 = spawnForm(bin, ["app-server"], env);
|
|
7867
|
+
} catch {
|
|
7868
|
+
resolve(void 0);
|
|
7869
|
+
return;
|
|
7870
|
+
}
|
|
7871
|
+
const child = spawn(f2.command, f2.args, { env, cwd, stdio: ["pipe", "pipe", "ignore"], windowsVerbatimArguments: f2.windowsVerbatimArguments, windowsHide: true });
|
|
7872
|
+
let buf = "";
|
|
7873
|
+
let done = false;
|
|
7874
|
+
const finish2 = (v) => {
|
|
7875
|
+
if (done) return;
|
|
7876
|
+
done = true;
|
|
7877
|
+
clearTimeout(timer);
|
|
7878
|
+
child.stdin.destroy();
|
|
7879
|
+
child.kill();
|
|
7880
|
+
resolve(v);
|
|
7881
|
+
};
|
|
7882
|
+
const timer = setTimeout(() => finish2(void 0), LIST_TIMEOUT_MS);
|
|
7883
|
+
const send = (o2) => {
|
|
7884
|
+
try {
|
|
7885
|
+
child.stdin.write(JSON.stringify(o2) + "\n");
|
|
7886
|
+
} catch {
|
|
7887
|
+
finish2(void 0);
|
|
7888
|
+
}
|
|
7889
|
+
};
|
|
7890
|
+
child.on("error", () => finish2(void 0));
|
|
7891
|
+
child.on("close", () => finish2(void 0));
|
|
7892
|
+
child.stdin.on("error", () => finish2(void 0));
|
|
7893
|
+
child.stdout.setEncoding("utf8");
|
|
7894
|
+
child.stdout.on("data", (d) => {
|
|
7895
|
+
buf += d;
|
|
7896
|
+
const lines = buf.split("\n");
|
|
7897
|
+
buf = lines.pop() ?? "";
|
|
7898
|
+
for (const line of lines) {
|
|
7899
|
+
let m3;
|
|
7900
|
+
try {
|
|
7901
|
+
m3 = JSON.parse(line);
|
|
7902
|
+
} catch {
|
|
7903
|
+
continue;
|
|
7904
|
+
}
|
|
7905
|
+
if (!isObj2(m3)) continue;
|
|
7906
|
+
if (m3.id === 1) {
|
|
7907
|
+
send({ method: "initialized" });
|
|
7908
|
+
send({ id: 2, method: "hooks/list", params: { cwds: [cwd] } });
|
|
7909
|
+
} else if (m3.id === 2) finish2(pluginHooksFromReply(m3, pluginId));
|
|
7910
|
+
}
|
|
7911
|
+
});
|
|
7912
|
+
send({ id: 1, method: "initialize", params: { clientInfo: { name: "context-mode-setup", version: "2.0.0" } } });
|
|
7913
|
+
});
|
|
7914
|
+
}
|
|
7915
|
+
function pluginTrustEntries(hooks) {
|
|
7916
|
+
return hooks.filter((h2) => !h2.trusted).map((h2) => [[...TRUST_KEY, h2.key], { [HASH_FIELD]: h2.hash }]);
|
|
7917
|
+
}
|
|
7807
7918
|
|
|
7808
7919
|
// src/setup/engine.ts
|
|
7809
|
-
import { spawn, spawnSync as spawnSync2 } from "node:child_process";
|
|
7920
|
+
import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
|
|
7810
7921
|
import { closeSync, existsSync as existsSync6, mkdirSync as mkdirSync3, mkdtempSync, openSync, readFileSync as readFileSync4, readSync, readdirSync as readdirSync4, realpathSync as realpathSync4, rmSync, statSync as statSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
7811
7922
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
7812
7923
|
import path6 from "node:path";
|
|
@@ -8163,7 +8274,7 @@ function copyCheck(row, pkgDir) {
|
|
|
8163
8274
|
}
|
|
8164
8275
|
function mcpCheck(cmd, env) {
|
|
8165
8276
|
return new Promise((resolve) => {
|
|
8166
|
-
const child =
|
|
8277
|
+
const child = spawn2(cmd[0], cmd.slice(1), { env, stdio: ["pipe", "pipe", "ignore"], detached: process.platform !== "win32", windowsHide: true });
|
|
8167
8278
|
const reap = () => {
|
|
8168
8279
|
child.kill();
|
|
8169
8280
|
};
|
|
@@ -8337,6 +8448,7 @@ function skillsCheck(row, pkgDir) {
|
|
|
8337
8448
|
}
|
|
8338
8449
|
var PLUGIN_ENABLED = "enabled";
|
|
8339
8450
|
var WORD_TRIM = ",;";
|
|
8451
|
+
var CODEX_CONFIG_FILE2 = "config.toml";
|
|
8340
8452
|
var EXT_ENABLED_USER = "Enabled (User):";
|
|
8341
8453
|
var EXT_TRUE = "true";
|
|
8342
8454
|
function tableState(n3, text2) {
|
|
@@ -8383,7 +8495,7 @@ function trimChars(w, chars) {
|
|
|
8383
8495
|
while (b3 > a2 && chars.includes(w.charAt(b3 - 1))) b3--;
|
|
8384
8496
|
return w.slice(a2, b3);
|
|
8385
8497
|
}
|
|
8386
|
-
async function nativeResult(row, ctx) {
|
|
8498
|
+
async function nativeResult(row, ctx, apply2) {
|
|
8387
8499
|
const n3 = row.nativePlugin;
|
|
8388
8500
|
const state = nativeState(row, ctx.env);
|
|
8389
8501
|
if (!n3 || state === void 0) return void 0;
|
|
@@ -8400,14 +8512,58 @@ async function nativeResult(row, ctx) {
|
|
|
8400
8512
|
reason: `context-mode is installed but disabled in ${n3.bin}, run ${n3.bin} ${n3.enable.join(" ")}`
|
|
8401
8513
|
};
|
|
8402
8514
|
}
|
|
8403
|
-
const res = { id: row.id, status: "PASS", v1: [], changes: [], checks:
|
|
8515
|
+
const res = { id: row.id, status: "PASS", v1: [], changes: [], checks: [], bin };
|
|
8516
|
+
let hooks = n3.hookTrust ? await listPluginHooks(ctx.env, n3.plugin, ctx.home) : void 0;
|
|
8517
|
+
if (apply2 && hooks?.some((h2) => !h2.trusted)) {
|
|
8518
|
+
try {
|
|
8519
|
+
const done = trustPluginHooks(row, ctx, apply2, hooks);
|
|
8520
|
+
res.changes.push(...done);
|
|
8521
|
+
if (done.length && !apply2.dryRun) hooks = await listPluginHooks(ctx.env, n3.plugin, ctx.home);
|
|
8522
|
+
} catch (e) {
|
|
8523
|
+
apply2.run.rollback(row.id, ctx.env);
|
|
8524
|
+
return { ...res, status: "FAIL", reason: e.message, rolledBack: true };
|
|
8525
|
+
}
|
|
8526
|
+
}
|
|
8527
|
+
res.checks = await verifyRow(nativeRow(row, n3), ctx);
|
|
8528
|
+
if (n3.hookTrust) res.checks = withHookTrust(res.checks, hooks, !!apply2?.dryRun);
|
|
8404
8529
|
const bad = res.checks.filter((c3) => !c3.ok);
|
|
8405
8530
|
if (bad.length) {
|
|
8406
8531
|
res.status = "FAIL";
|
|
8407
8532
|
res.reason = bad.map((c3) => `${c3.name}: ${c3.detail}`).join("; ");
|
|
8533
|
+
if (apply2 && !apply2.dryRun && res.changes.length) {
|
|
8534
|
+
apply2.run.rollback(row.id, ctx.env);
|
|
8535
|
+
res.rolledBack = true;
|
|
8536
|
+
}
|
|
8408
8537
|
}
|
|
8409
8538
|
return res;
|
|
8410
8539
|
}
|
|
8540
|
+
function trustPluginHooks(row, ctx, apply2, hooks) {
|
|
8541
|
+
const file = path6.join(codexDirOf(ctx.env, ctx.home), CODEX_CONFIG_FILE2);
|
|
8542
|
+
const text2 = readOr(file);
|
|
8543
|
+
let edit;
|
|
8544
|
+
try {
|
|
8545
|
+
edit = editHostConfigText(row.id, file, text2 ?? "", "toml", pluginTrustEntries(hooks));
|
|
8546
|
+
} catch (e) {
|
|
8547
|
+
if (e instanceof CtxError) throw new Error(parseFail(row, file));
|
|
8548
|
+
throw e;
|
|
8549
|
+
}
|
|
8550
|
+
if (!edit.edits.length) return [];
|
|
8551
|
+
if (!apply2.dryRun) {
|
|
8552
|
+
assertWritable(row, file);
|
|
8553
|
+
const raw = readRaw(file);
|
|
8554
|
+
apply2.run.record({ agent: row.id, file, existed: raw !== void 0 }, raw);
|
|
8555
|
+
atomicWrite(file, raw === void 0 ? edit.text : withLayout(edit.text, hostLayout(raw)));
|
|
8556
|
+
}
|
|
8557
|
+
return edit.edits.map((e) => ({ file, ...e }));
|
|
8558
|
+
}
|
|
8559
|
+
var UNTRUSTED_FIX = "run: context-mode setup";
|
|
8560
|
+
function withHookTrust(checks, hooks, dryRun) {
|
|
8561
|
+
if (hooks === void 0) return [...checks, { name: "hook-trust", ok: true, warn: true, detail: "codex did not report hook trust (codex app-server hooks/list)" }];
|
|
8562
|
+
const bad = hooks.filter((h2) => !h2.trusted);
|
|
8563
|
+
if (!bad.length || dryRun) return checks;
|
|
8564
|
+
const detail = `codex lists ${bad.length} of ${hooks.length} context-mode plugin hooks untrusted, so they do not run; ${UNTRUSTED_FIX}`;
|
|
8565
|
+
return checks.map((c3) => c3.name === "hook-registered" ? { name: c3.name, ok: false, detail } : c3);
|
|
8566
|
+
}
|
|
8411
8567
|
async function verifyRow(row, ctx) {
|
|
8412
8568
|
const env = ctx.env;
|
|
8413
8569
|
const checks = [parseCheck(row)];
|
|
@@ -8522,7 +8678,7 @@ async function runSetup(opts) {
|
|
|
8522
8678
|
}
|
|
8523
8679
|
current = id;
|
|
8524
8680
|
opts.onAgent?.(id, "start");
|
|
8525
|
-
const res = await nativeResult(row, ctx) ?? await setupRow(row, ctx, run, !!opts.dryRun);
|
|
8681
|
+
const res = await nativeResult(row, ctx, { run, dryRun: !!opts.dryRun }) ?? await setupRow(row, ctx, run, !!opts.dryRun);
|
|
8526
8682
|
current = void 0;
|
|
8527
8683
|
agents.push(res);
|
|
8528
8684
|
opts.onAgent?.(id, "done", res);
|
|
@@ -8551,7 +8707,7 @@ async function setupRow(row, ctx, run, dryRun) {
|
|
|
8551
8707
|
return { ...res, status: "FAIL", reason: e.message };
|
|
8552
8708
|
}
|
|
8553
8709
|
const configEdited = (file) => plan.edits.some((e) => e.file === file && e.changes.some((c3) => !isTrust(row, c3)));
|
|
8554
|
-
res.v1 = detectV1(row.id, ctx.home, { claudeDir: claudeDirOf(ctx.env, ctx.home), copilotDir: copilotDirOf(ctx.env, ctx.home), kiroDir: kiroDirOf(ctx.env, ctx.home), opencodeDir: opencodeDirOf(ctx.env, ctx.home) }).filter((f2) => !(row.config && f2.file === row.config.file && !configEdited(f2.file)));
|
|
8710
|
+
res.v1 = detectV1(row.id, ctx.home, { claudeDir: claudeDirOf(ctx.env, ctx.home), codexDir: codexDirOf(ctx.env, ctx.home), copilotDir: copilotDirOf(ctx.env, ctx.home), kiroDir: kiroDirOf(ctx.env, ctx.home), opencodeDir: opencodeDirOf(ctx.env, ctx.home) }).filter((f2) => !(row.config && f2.file === row.config.file && !configEdited(f2.file)));
|
|
8555
8711
|
res.changes = [...plan.edits.flatMap((e) => e.changes), ...[...plan.cli, ...plan.refresh].map((args) => ({ command: [row.cli.bin, ...args] }))];
|
|
8556
8712
|
if (dryRun) return res;
|
|
8557
8713
|
try {
|
|
@@ -8941,7 +9097,8 @@ function list(ui) {
|
|
|
8941
9097
|
const detected = new Set(detectAgents(reg, ui.ctx));
|
|
8942
9098
|
const rows = ADAPTERS.map((a2) => ({
|
|
8943
9099
|
id: a2.id,
|
|
8944
|
-
|
|
9100
|
+
hooks: a2.hookChannel.kind,
|
|
9101
|
+
// ADR-0020: every agent has a hook channel
|
|
8945
9102
|
installMode: a2.installMode,
|
|
8946
9103
|
detected: detected.has(a2.id)
|
|
8947
9104
|
}));
|
|
@@ -8949,8 +9106,8 @@ function list(ui) {
|
|
|
8949
9106
|
out(JSON.stringify({ agents: rows }));
|
|
8950
9107
|
return EXIT_OK;
|
|
8951
9108
|
}
|
|
8952
|
-
out(`${"AGENT".padEnd(13)} ${"
|
|
8953
|
-
for (const r2 of rows) out(`${r2.id.padEnd(13)} ${r2.
|
|
9109
|
+
out(`${"AGENT".padEnd(13)} ${"HOOKS".padEnd(11)} ${"FOUND".padEnd(9)} INSTALL`);
|
|
9110
|
+
for (const r2 of rows) out(`${r2.id.padEnd(13)} ${r2.hooks.padEnd(11)} ${(r2.detected ? "detected" : "-").padEnd(9)} ${r2.installMode}`);
|
|
8954
9111
|
return EXIT_OK;
|
|
8955
9112
|
}
|
|
8956
9113
|
async function remove(ui) {
|
|
@@ -9232,7 +9389,7 @@ function main() {
|
|
|
9232
9389
|
process.exitCode = r2.code;
|
|
9233
9390
|
return;
|
|
9234
9391
|
}
|
|
9235
|
-
const child =
|
|
9392
|
+
const child = spawn3(process.execPath, [path8.join(dir, r2.file), ...r2.args], { stdio: "inherit", windowsHide: true });
|
|
9236
9393
|
process.on("SIGINT", () => {
|
|
9237
9394
|
});
|
|
9238
9395
|
child.on("error", (err2) => {
|
package/copilot/plugin.json
CHANGED
package/gemini-extension.json
CHANGED