context-mode 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.zcode-plugin/hooks.json +50 -0
- package/.zcode-plugin/plugin.json +20 -0
- package/README.md +78 -79
- package/SHA256SUMS +17 -15
- package/cli.mjs +310 -142
- package/copilot/plugin.json +1 -1
- package/gemini-extension.json +1 -1
- package/hook.mjs +99 -97
- package/opencode/plugin.js +637 -509
- package/package.json +2 -1
- package/pi/index.js +726 -577
- package/qwen-extension.json +1 -1
- package/run.mjs +240 -93
- package/search.mjs +240 -93
- package/server.mjs +497 -435
package/server.mjs
CHANGED
|
@@ -7,8 +7,8 @@ var __export = (target, all) => {
|
|
|
7
7
|
|
|
8
8
|
// src/entries/server.ts
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
|
-
import { existsSync as
|
|
11
|
-
import { dirname as
|
|
10
|
+
import { existsSync as existsSync22, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
|
|
11
|
+
import { dirname as dirname12, join as join22 } from "node:path";
|
|
12
12
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
13
13
|
|
|
14
14
|
// node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
|
|
@@ -21994,41 +21994,41 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
21994
21994
|
schemelessOptions.skipEscape = true;
|
|
21995
21995
|
return serialize(resolved, schemelessOptions);
|
|
21996
21996
|
}
|
|
21997
|
-
function resolveComponent(base,
|
|
21997
|
+
function resolveComponent(base, relative4, options, skipNormalization) {
|
|
21998
21998
|
const target = {};
|
|
21999
21999
|
if (!skipNormalization) {
|
|
22000
22000
|
base = parse6(serialize(base, options), options);
|
|
22001
|
-
|
|
22001
|
+
relative4 = parse6(serialize(relative4, options), options);
|
|
22002
22002
|
}
|
|
22003
22003
|
options = options || {};
|
|
22004
|
-
if (!options.tolerant &&
|
|
22005
|
-
target.scheme =
|
|
22006
|
-
target.userinfo =
|
|
22007
|
-
target.host =
|
|
22008
|
-
target.port =
|
|
22009
|
-
target.path = removeDotSegments(
|
|
22010
|
-
target.query =
|
|
22004
|
+
if (!options.tolerant && relative4.scheme) {
|
|
22005
|
+
target.scheme = relative4.scheme;
|
|
22006
|
+
target.userinfo = relative4.userinfo;
|
|
22007
|
+
target.host = relative4.host;
|
|
22008
|
+
target.port = relative4.port;
|
|
22009
|
+
target.path = removeDotSegments(relative4.path || "");
|
|
22010
|
+
target.query = relative4.query;
|
|
22011
22011
|
} else {
|
|
22012
|
-
if (
|
|
22013
|
-
target.userinfo =
|
|
22014
|
-
target.host =
|
|
22015
|
-
target.port =
|
|
22016
|
-
target.path = removeDotSegments(
|
|
22017
|
-
target.query =
|
|
22012
|
+
if (relative4.userinfo !== void 0 || relative4.host !== void 0 || relative4.port !== void 0) {
|
|
22013
|
+
target.userinfo = relative4.userinfo;
|
|
22014
|
+
target.host = relative4.host;
|
|
22015
|
+
target.port = relative4.port;
|
|
22016
|
+
target.path = removeDotSegments(relative4.path || "");
|
|
22017
|
+
target.query = relative4.query;
|
|
22018
22018
|
} else {
|
|
22019
|
-
if (!
|
|
22019
|
+
if (!relative4.path) {
|
|
22020
22020
|
target.path = base.path;
|
|
22021
|
-
if (
|
|
22021
|
+
if (relative4.query !== void 0) target.query = relative4.query;
|
|
22022
22022
|
else target.query = base.query;
|
|
22023
22023
|
} else {
|
|
22024
|
-
if (
|
|
22024
|
+
if (relative4.path[0] === "/") target.path = removeDotSegments(relative4.path);
|
|
22025
22025
|
else {
|
|
22026
|
-
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) target.path = "/" +
|
|
22027
|
-
else if (!base.path) target.path =
|
|
22028
|
-
else target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
22026
|
+
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) target.path = "/" + relative4.path;
|
|
22027
|
+
else if (!base.path) target.path = relative4.path;
|
|
22028
|
+
else target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative4.path;
|
|
22029
22029
|
target.path = removeDotSegments(target.path);
|
|
22030
22030
|
}
|
|
22031
|
-
target.query =
|
|
22031
|
+
target.query = relative4.query;
|
|
22032
22032
|
}
|
|
22033
22033
|
target.userinfo = base.userinfo;
|
|
22034
22034
|
target.host = base.host;
|
|
@@ -22036,7 +22036,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
22036
22036
|
}
|
|
22037
22037
|
target.scheme = base.scheme;
|
|
22038
22038
|
}
|
|
22039
|
-
target.fragment =
|
|
22039
|
+
target.fragment = relative4.fragment;
|
|
22040
22040
|
return target;
|
|
22041
22041
|
}
|
|
22042
22042
|
function equal(uriA, uriB, options) {
|
|
@@ -28244,6 +28244,7 @@ var GIT_COMMONDIR_FILE = "commondir";
|
|
|
28244
28244
|
var GIT_HEAD_FILE = "HEAD";
|
|
28245
28245
|
var WORKSPACE_FOLDER_FLAG = "--workspace-folder";
|
|
28246
28246
|
var EXEC_LANGUAGES = Object.freeze(["shell", "powershell", "javascript", "typescript", "python"]);
|
|
28247
|
+
var SHELL_FAMILY = Object.freeze(["sh", "bash", "zsh", "dash", "ksh", "fish"]);
|
|
28247
28248
|
var PATHEXT_DEFAULT = ".COM;.EXE;.BAT;.CMD";
|
|
28248
28249
|
var FETCH_MAX_HOPS = 5;
|
|
28249
28250
|
var SOURCE_LABEL_MAX_CHARS = 80;
|
|
@@ -28255,6 +28256,7 @@ var RUN_SESSION_PREFIX = "mcp:";
|
|
|
28255
28256
|
var HOST_SESSION_ENV = Object.freeze({ "claude-code": "CLAUDE_CODE_SESSION_ID" });
|
|
28256
28257
|
var NODE_MIN = "24.15.0";
|
|
28257
28258
|
var DATA_ROOT = "~/.context-mode";
|
|
28259
|
+
var DATA_DIR_ENV = "CONTEXT_MODE_DATA_DIR";
|
|
28258
28260
|
var INTERNAL_ERROR_LINE = "Internal error. Fix: run ctx_doctor.";
|
|
28259
28261
|
var HOST_CONFIG_DIR_NAME = ".claude";
|
|
28260
28262
|
var HOST_PLUGINS_DIR_NAME = "plugins";
|
|
@@ -28323,7 +28325,7 @@ var SHELL_DUMP_COMMANDS = Object.freeze(["cat", "head", "tail", "sed", "less", "
|
|
|
28323
28325
|
var DUMP_COUNT_COMMANDS = Object.freeze(["head", "tail"]);
|
|
28324
28326
|
var DUMP_COUNT_FLAGS = Object.freeze(["-n", "-c", "--lines", "--bytes"]);
|
|
28325
28327
|
var SED_QUIET_FLAGS = Object.freeze(["-n", "--quiet", "--silent"]);
|
|
28326
|
-
var READ_PATH_KEYS = Object.freeze(["file_path", "absolute_path", "path"]);
|
|
28328
|
+
var READ_PATH_KEYS = Object.freeze(["file_path", "absolute_path", "path", "filePath"]);
|
|
28327
28329
|
var OWN_TOOL_PREFIX = "ctx_";
|
|
28328
28330
|
var EDIT_TOOLS = Object.freeze(["Write", "Edit"]);
|
|
28329
28331
|
var EDIT_PATH_KEYS = Object.freeze(["file_path", "path"]);
|
|
@@ -28408,8 +28410,7 @@ function PURGE_SUMMARY(rows, scope) {
|
|
|
28408
28410
|
var DECISION_SOURCE = "decision";
|
|
28409
28411
|
var DECISION_USER_LABEL = "decision (user)";
|
|
28410
28412
|
var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
|
|
28411
|
-
var
|
|
28412
|
-
var BUNDLE_SHA = true ? "83f2da691359eaaf61f7baba841dea1942d3ccc1" : void 0;
|
|
28413
|
+
var BUNDLE_SHA = true ? "b496e208f503714cb28500a0b5767799ba882039" : void 0;
|
|
28413
28414
|
var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
|
|
28414
28415
|
var DOCTOR_LABEL = Object.freeze({
|
|
28415
28416
|
D1: "version",
|
|
@@ -28553,7 +28554,6 @@ function D9_INDEX_DETAIL(sources, chunks) {
|
|
|
28553
28554
|
var PLUGIN_CACHE_DIR_NAME = "cache";
|
|
28554
28555
|
var DATA_PLUGINS_DIR_NAME = "plugins";
|
|
28555
28556
|
var PLUGIN_CURRENT_LINK = "current";
|
|
28556
|
-
var RELEASE_SUMS_FILE = "SHA256SUMS";
|
|
28557
28557
|
var EXTENSIONS_DIR_NAME = "extensions";
|
|
28558
28558
|
var AGENT_HOME_DIR = Object.freeze({
|
|
28559
28559
|
"claude-code": [".claude"],
|
|
@@ -28576,7 +28576,6 @@ var UPGRADE_MODES = Object.freeze(["upgrade", "uninstall"]);
|
|
|
28576
28576
|
var UPGRADE_TABLE_HEADER = "| Area | Before | After |";
|
|
28577
28577
|
var UPGRADE_TABLE_RULE = "|---|---|---|";
|
|
28578
28578
|
var UPGRADE_PLUGIN_ROOT_AREA = "plugin root";
|
|
28579
|
-
var UPGRADE_CHECKOUT_AREA = "plugin checkout";
|
|
28580
28579
|
var UPGRADE_SERVER_AREA = "server";
|
|
28581
28580
|
var UPGRADE_SERVER_RUNNING = "running";
|
|
28582
28581
|
var UPGRADE_SERVER_STOPPED = "stopped after this reply";
|
|
@@ -28587,25 +28586,20 @@ var UPGRADE_REPORT_ONLY = "report only: remove it by hand if you no longer use i
|
|
|
28587
28586
|
var UPGRADE_STOP_DELAY_MS = 200;
|
|
28588
28587
|
var UPGRADE_AREA_KEY_SEP = ": ";
|
|
28589
28588
|
var V1_KEY_PATH_SEP = ".";
|
|
28590
|
-
var UPGRADE_GIT_TIMEOUT_MS = 12e4;
|
|
28591
28589
|
var GIT_CLONE_ARGS = Object.freeze(["clone", "--depth", "1", "--branch"]);
|
|
28592
28590
|
var GIT_HEAD_SHA_ARGS = Object.freeze(["rev-parse", "HEAD"]);
|
|
28593
|
-
var UPGRADE_FETCH_DIR_PREFIX = ".fetch-";
|
|
28594
|
-
var SUMS_LINE_SEP = " ";
|
|
28595
|
-
var SUMS_HASH_ALGORITHM = "sha256";
|
|
28596
|
-
var UPGRADE_GIT_CHECKOUT_AGENTS = Object.freeze(["pi", "opencode"]);
|
|
28597
|
-
var UPGRADE_HOST_MANUAL = "update with the host's own install command, then restart";
|
|
28598
28591
|
var UPGRADE_CONFIG_AREA = "host config";
|
|
28599
28592
|
var UPGRADE_OWN_ENTRY = "context-mode entry";
|
|
28600
28593
|
var UPGRADE_CACHE_BY_HAND = "remove the release dir by hand: its place is your choice";
|
|
28601
28594
|
var GIT_NO_PROMPT_ENV = Object.freeze({ GIT_TERMINAL_PROMPT: "0" });
|
|
28602
28595
|
var GIT_NO_CRLF_ENV = Object.freeze({ GIT_CONFIG_COUNT: "1", GIT_CONFIG_KEY_0: "core.autocrlf", GIT_CONFIG_VALUE_0: "false" });
|
|
28603
|
-
var GIT_NOT_STARTED = "git did not start";
|
|
28604
28596
|
var GIT_BIN = "git";
|
|
28605
28597
|
var WIN_SHELL_LANGS = Object.freeze(["shell", "bash", "sh"]);
|
|
28606
28598
|
var GIT_BASH_RELATIVE = Object.freeze([["..", "bin", "bash.exe"], ["..", "..", "bin", "bash.exe"]]);
|
|
28607
|
-
var GIT_EXIT_LABEL = "git exit ";
|
|
28608
28599
|
var UPGRADE_TRASH_SUFFIX = ".ctx-upgrade-removing";
|
|
28600
|
+
var UPGRADE_ASIDE_SUFFIX = ".ctx-v1-old";
|
|
28601
|
+
var UPGRADE_MOVED_ASIDE = "moved aside to ";
|
|
28602
|
+
var PERSISTED_OUTPUT_MAX_BYTES = 16 * 1024 * 1024;
|
|
28609
28603
|
var TABLE_ROW_START = "| ";
|
|
28610
28604
|
var TABLE_CELL_SEP = " | ";
|
|
28611
28605
|
var TABLE_ROW_END = " |";
|
|
@@ -28617,7 +28611,6 @@ var OPS_SPLIT_FILES = Object.freeze([
|
|
|
28617
28611
|
"doctor-hook.ts",
|
|
28618
28612
|
"doctor-db.ts",
|
|
28619
28613
|
"doctor-heal.ts",
|
|
28620
|
-
"release-fetch.ts",
|
|
28621
28614
|
"verify-sums.ts",
|
|
28622
28615
|
"plugin-swap.ts",
|
|
28623
28616
|
"host-write.ts",
|
|
@@ -28693,19 +28686,19 @@ function D11_PASS_DETAIL(shell, win) {
|
|
|
28693
28686
|
var DB_SIBLING_SUFFIXES = Object.freeze(["", DB_WAL_SUFFIX, DB_SHM_SUFFIX]);
|
|
28694
28687
|
var HEAL_TMP_SUFFIX = ".heal";
|
|
28695
28688
|
var HEAL_TS_SEP = ".";
|
|
28696
|
-
var SUMS_LINE_END = "\n";
|
|
28697
|
-
var HASH_ENCODING = "hex";
|
|
28698
|
-
var PLUGIN_LINK_TMP_SUFFIX = ".swap";
|
|
28699
|
-
var PLUGIN_LINK_OLD_SUFFIX = ".old";
|
|
28700
|
-
var PLUGIN_LINK_TYPE = "dir";
|
|
28701
|
-
var PLUGIN_LINK_TYPE_WIN32 = "junction";
|
|
28702
28689
|
var OWNER_STOP_EXT = ".stop";
|
|
28703
28690
|
var UPGRADE_DATA_DELETED = "user data deleted";
|
|
28704
28691
|
var UPGRADE_HOST_COMMAND = Object.freeze({
|
|
28705
28692
|
"claude-code": "claude plugin marketplace update context-mode && claude plugin update context-mode@context-mode",
|
|
28706
|
-
codex: "
|
|
28707
|
-
gemini: "gemini extensions
|
|
28708
|
-
qwen: "qwen extensions
|
|
28693
|
+
codex: "codex plugin marketplace upgrade context-mode",
|
|
28694
|
+
gemini: "gemini extensions update context-mode",
|
|
28695
|
+
qwen: "qwen extensions update context-mode",
|
|
28696
|
+
pi: "pi update --extensions",
|
|
28697
|
+
opencode: "opencode plugin update",
|
|
28698
|
+
"copilot-cli": "npm i -g context-mode && context-mode setup --agents copilot-cli",
|
|
28699
|
+
vscode: "npm i -g context-mode && context-mode setup --agents vscode",
|
|
28700
|
+
kiro: "npm i -g context-mode && context-mode setup --agents kiro",
|
|
28701
|
+
zcode: "npm i -g context-mode && context-mode setup --agents zcode"
|
|
28709
28702
|
});
|
|
28710
28703
|
var PI_GIT_PACKAGE = "git:github.com/mksglu/context-mode@release";
|
|
28711
28704
|
var OPENCODE_GIT_SPEC = "git+https://github.com/mksglu/context-mode.git#release";
|
|
@@ -28747,6 +28740,7 @@ var HOOKS_JSON_FILE = "hooks.json";
|
|
|
28747
28740
|
var CLAUDE_CONFIG_DIR_ENV = "CLAUDE_CONFIG_DIR";
|
|
28748
28741
|
var CODEX_HOME_ENV = "CODEX_HOME";
|
|
28749
28742
|
var COPILOT_HOME_ENV = "COPILOT_HOME";
|
|
28743
|
+
var GEMINI_CLI_HOME_ENV = "GEMINI_CLI_HOME";
|
|
28750
28744
|
var KIRO_HOME_ENV = "KIRO_HOME";
|
|
28751
28745
|
var OPENCODE_CONFIG_DIR_ENV = "OPENCODE_CONFIG_DIR";
|
|
28752
28746
|
var APPDATA_ENV = "APPDATA";
|
|
@@ -28775,8 +28769,12 @@ var STATUS_LINE_KEY = "statusLine";
|
|
|
28775
28769
|
var PI_PACKAGES_KEY = "packages";
|
|
28776
28770
|
var OPENCODE_PLUGIN_KEY = "plugin";
|
|
28777
28771
|
var OPENCODE_PLUGINS_KEY = "plugins";
|
|
28772
|
+
var OPENCODE_MCP_COMMAND_FIELD = "command";
|
|
28778
28773
|
var OPENCODE_PACKAGE_FIELD = "package";
|
|
28779
28774
|
var OPENCODE_NPM_SPEC_PREFIX = `${SERVER_KEY}@`;
|
|
28775
|
+
var NPM_VERSION_SEP = "@";
|
|
28776
|
+
var OPENCODE_NPM_LATEST = `${OPENCODE_NPM_SPEC_PREFIX}latest`;
|
|
28777
|
+
var PI_NPM_LATEST = `${V1_PI_PACKAGE}${NPM_VERSION_SEP}latest`;
|
|
28780
28778
|
var V1_DATA_DIR_NAME = "context-mode";
|
|
28781
28779
|
var V1_DATA_ROOT_ENTRIES = Object.freeze(["content", "platform.json"]);
|
|
28782
28780
|
var V1_SESSIONS_DIR_NAME = "sessions";
|
|
@@ -28805,17 +28803,22 @@ var V1_REASON = Object.freeze({
|
|
|
28805
28803
|
kiroSteering: "old context-mode Kiro steering doc .kiro/steering/KIRO.md: manual review, report only, never removed",
|
|
28806
28804
|
piNpm: "old context-mode Pi package npm:context-mode",
|
|
28807
28805
|
opencodePlugin: "old context-mode OpenCode plugin spec context-mode",
|
|
28806
|
+
piGit: "old context-mode Pi entry git:github.com/mksglu/context-mode@release: ctx_upgrade replaces it with npm:context-mode@latest",
|
|
28807
|
+
opencodeGit: "old context-mode OpenCode entry git+https://github.com/mksglu/context-mode.git#release: ctx_upgrade replaces it with context-mode@latest",
|
|
28808
28808
|
zcodeHook: "old context-mode ZCode hook entry: command contains context-mode hook",
|
|
28809
28809
|
dataDir: "old context-mode data dir <agent home>/context-mode/",
|
|
28810
28810
|
dataDirShared: "old context-mode data dir ~/.gemini/context-mode/: delete only after a prompt (Antigravity shares it)",
|
|
28811
28811
|
dataRoot: "old context-mode content under ~/.context-mode/",
|
|
28812
|
-
tmpFile: "old context-mode temp file context-mode-* under the OS temp dir: report only, safe to keep"
|
|
28812
|
+
tmpFile: "old context-mode temp file context-mode-* under the OS temp dir: report only, safe to keep",
|
|
28813
|
+
projectLink: "context-mode path in the project reached through a link: report only, upgrade keeps it as is and never follows a link"
|
|
28813
28814
|
});
|
|
28814
|
-
var UPGRADE_REPORT_ONLY_REASONS = Object.freeze([V1_REASON.statusLine, V1_REASON.vscodeMcp, V1_REASON.dataDirShared, V1_REASON.tmpFile, V1_REASON.kiroSteering]);
|
|
28815
|
+
var UPGRADE_REPORT_ONLY_REASONS = Object.freeze([V1_REASON.statusLine, V1_REASON.vscodeMcp, V1_REASON.dataDirShared, V1_REASON.tmpFile, V1_REASON.kiroSteering, V1_REASON.piGit, V1_REASON.opencodeGit, V1_REASON.projectLink]);
|
|
28816
|
+
var UPGRADE_KEEP_ASIDE_REASONS = Object.freeze([V1_REASON.dataDir, V1_REASON.dataRoot]);
|
|
28815
28817
|
var PLUGIN_NAME = SERVER_KEY;
|
|
28816
28818
|
var OPENCODE_TOOL_PREFIX = SERVER_KEY + "_";
|
|
28817
28819
|
var SERVER_ENTRY_FILE = "server.mjs";
|
|
28818
28820
|
var VSCODE_WORKSPACE_VAR = "${workspaceFolder}";
|
|
28821
|
+
var ROOTS_TIMEOUT_MS = 2e3;
|
|
28819
28822
|
var OPENCODE_PLUGIN_PATH = Object.freeze(["opencode", "plugin.js"]);
|
|
28820
28823
|
var HOST_NODE_COMMAND = "node";
|
|
28821
28824
|
var EXE_SUFFIX = ".exe";
|
|
@@ -28938,7 +28941,7 @@ var NATIVE_INSTALL = Object.freeze({
|
|
|
28938
28941
|
"copilot-cli": ["npm i -g context-mode", "context-mode setup --agents copilot-cli"],
|
|
28939
28942
|
vscode: ["npm i -g context-mode", "context-mode setup --agents vscode"],
|
|
28940
28943
|
kiro: ["npm i -g context-mode", "context-mode setup --agents kiro"],
|
|
28941
|
-
zcode: ["
|
|
28944
|
+
zcode: ["zcode plugins marketplace add mksglu/context-mode", "zcode plugins install context-mode@context-mode"]
|
|
28942
28945
|
});
|
|
28943
28946
|
var ISSUE_FORM_URL = `https://github.com/${ISSUE_REPO_SLUG}/issues/new?template=${ISSUE_FORM_FILE}`;
|
|
28944
28947
|
var DOCTOR_GIT_VERSION_TIMEOUT_MS = 5e3;
|
|
@@ -29144,6 +29147,15 @@ function applyMigrations(db, fromVersion) {
|
|
|
29144
29147
|
}
|
|
29145
29148
|
}
|
|
29146
29149
|
|
|
29150
|
+
// src/core/store/open-read.ts
|
|
29151
|
+
function openReadOnlyHandle(sqlite, path8, opts = {}) {
|
|
29152
|
+
const bun = "bun" in opts ? opts.bun : process.versions.bun;
|
|
29153
|
+
if (bun === void 0) return new sqlite.DatabaseSync(path8, { timeout: DB_TIMEOUT_MS, readOnly: true });
|
|
29154
|
+
const raw = new sqlite.DatabaseSync(path8, { timeout: DB_TIMEOUT_MS });
|
|
29155
|
+
if (opts.queryOnly !== false) raw.exec("PRAGMA query_only = ON");
|
|
29156
|
+
return raw;
|
|
29157
|
+
}
|
|
29158
|
+
|
|
29147
29159
|
// src/core/store/db.ts
|
|
29148
29160
|
var { existsSync, linkSync, mkdirSync, rmSync } = process.getBuiltinModule("node:fs");
|
|
29149
29161
|
function versionParts(v) {
|
|
@@ -29209,7 +29221,7 @@ function openWritable(sqlite, path8) {
|
|
|
29209
29221
|
}
|
|
29210
29222
|
}
|
|
29211
29223
|
function openReadOnly(sqlite, path8) {
|
|
29212
|
-
const raw =
|
|
29224
|
+
const raw = openReadOnlyHandle(sqlite, path8);
|
|
29213
29225
|
try {
|
|
29214
29226
|
const found = readUserVersion(raw);
|
|
29215
29227
|
if (found !== SCHEMA_VERSION) throw new CtxError("SCHEMA_STALE", { found, want: SCHEMA_VERSION });
|
|
@@ -29402,6 +29414,10 @@ function copilotDirOf(env, home) {
|
|
|
29402
29414
|
const dir = env[COPILOT_HOME_ENV];
|
|
29403
29415
|
return dir !== void 0 && dir !== "" ? dir : join(home, ...AGENT_HOME_DIR["copilot-cli"]);
|
|
29404
29416
|
}
|
|
29417
|
+
function geminiDirOf(env, home) {
|
|
29418
|
+
const dir = env[GEMINI_CLI_HOME_ENV];
|
|
29419
|
+
return join(dir !== void 0 && dir !== "" ? dir : home, ...AGENT_HOME_DIR.gemini);
|
|
29420
|
+
}
|
|
29405
29421
|
function kiroDirOf(env, home, platform = process.platform) {
|
|
29406
29422
|
const p = platform === "win32" ? win32 : posix;
|
|
29407
29423
|
const fallback = p.join(home, ...AGENT_HOME_DIR.kiro);
|
|
@@ -29460,18 +29476,23 @@ function requireHomeDir(env, platform = process.platform) {
|
|
|
29460
29476
|
if (home !== null) return home;
|
|
29461
29477
|
throw new CtxError("NO_HOME", { name: platform === "win32" ? "USERPROFILE" : "HOME" });
|
|
29462
29478
|
}
|
|
29479
|
+
function dataRootOf(env, home) {
|
|
29480
|
+
const dir = env[DATA_DIR_ENV];
|
|
29481
|
+
return dir !== void 0 && dir !== "" ? resolve(dir) : join(home, DATA_ROOT.slice(1));
|
|
29482
|
+
}
|
|
29463
29483
|
function resolveConfigDir(env) {
|
|
29464
|
-
const
|
|
29484
|
+
const set3 = env[DATA_DIR_ENV];
|
|
29485
|
+
const dir = dataRootOf(env, set3 !== void 0 && set3 !== "" ? "" : requireHomeDir(env));
|
|
29465
29486
|
mkdirSync2(dir, { recursive: true });
|
|
29466
29487
|
return realpathSync.native(dir);
|
|
29467
29488
|
}
|
|
29468
29489
|
|
|
29469
29490
|
// src/core/project/resolve.ts
|
|
29470
|
-
import { basename as basename2, dirname as dirname3, join as
|
|
29491
|
+
import { basename as basename2, dirname as dirname3, join as join3, resolve as resolve2 } from "node:path";
|
|
29471
29492
|
|
|
29472
29493
|
// src/core/project/contain.ts
|
|
29473
|
-
import { dirname as dirname2, sep } from "node:path";
|
|
29474
|
-
var { realpathSync: realpathSync2 } = process.getBuiltinModule("node:fs");
|
|
29494
|
+
import { dirname as dirname2, join as join2, relative, sep } from "node:path";
|
|
29495
|
+
var { lstatSync, realpathSync: realpathSync2 } = process.getBuiltinModule("node:fs");
|
|
29475
29496
|
function real(p) {
|
|
29476
29497
|
try {
|
|
29477
29498
|
return realpathSync2.native(p);
|
|
@@ -29510,6 +29531,21 @@ function commonRoot(paths) {
|
|
|
29510
29531
|
while (components(q).length > n && dirname2(q) !== q) q = dirname2(q);
|
|
29511
29532
|
return q;
|
|
29512
29533
|
}
|
|
29534
|
+
function reachedThroughLink(root, p) {
|
|
29535
|
+
const rel = relative(root, p);
|
|
29536
|
+
const steps = components(rel);
|
|
29537
|
+
if (rel === "" || steps[0] === ".." || rel === p) return false;
|
|
29538
|
+
let at = root;
|
|
29539
|
+
for (const step of steps) {
|
|
29540
|
+
at = join2(at, step);
|
|
29541
|
+
try {
|
|
29542
|
+
if (lstatSync(at).isSymbolicLink()) return true;
|
|
29543
|
+
} catch {
|
|
29544
|
+
return false;
|
|
29545
|
+
}
|
|
29546
|
+
}
|
|
29547
|
+
return false;
|
|
29548
|
+
}
|
|
29513
29549
|
|
|
29514
29550
|
// src/core/project/sha256.ts
|
|
29515
29551
|
var K = new Uint32Array([
|
|
@@ -29671,9 +29707,9 @@ function gitDirs(dir) {
|
|
|
29671
29707
|
}
|
|
29672
29708
|
const start = cur;
|
|
29673
29709
|
for (; ; ) {
|
|
29674
|
-
const gitDir = gitDirAt(
|
|
29710
|
+
const gitDir = gitDirAt(join3(cur, GIT_DIR_NAME));
|
|
29675
29711
|
if (gitDir !== null) {
|
|
29676
|
-
const common = firstLine(
|
|
29712
|
+
const common = firstLine(join3(gitDir, GIT_COMMONDIR_FILE));
|
|
29677
29713
|
return { commonDir: realpathSync3.native(common === null ? gitDir : resolve2(gitDir, common)), worktree: cur, start };
|
|
29678
29714
|
}
|
|
29679
29715
|
const up = dirname3(cur);
|
|
@@ -29694,7 +29730,7 @@ function gitDirAt(dotGit) {
|
|
|
29694
29730
|
} catch {
|
|
29695
29731
|
return null;
|
|
29696
29732
|
}
|
|
29697
|
-
return existsSync2(
|
|
29733
|
+
return existsSync2(join3(gitDir, GIT_HEAD_FILE)) ? gitDir : null;
|
|
29698
29734
|
}
|
|
29699
29735
|
function firstLine(file2) {
|
|
29700
29736
|
let text;
|
|
@@ -29735,11 +29771,11 @@ function resolveProject(agent, src) {
|
|
|
29735
29771
|
return key;
|
|
29736
29772
|
},
|
|
29737
29773
|
get projectDir() {
|
|
29738
|
-
pdir ??=
|
|
29774
|
+
pdir ??= join3(resolveConfigDir(process.env), PROJECTS_DIR_NAME, this.projectKey);
|
|
29739
29775
|
return pdir;
|
|
29740
29776
|
},
|
|
29741
29777
|
get dbPath() {
|
|
29742
|
-
return
|
|
29778
|
+
return join3(this.projectDir, DB_FILE_NAME);
|
|
29743
29779
|
},
|
|
29744
29780
|
worktree,
|
|
29745
29781
|
get containmentRoot() {
|
|
@@ -29753,7 +29789,7 @@ function resolveProject(agent, src) {
|
|
|
29753
29789
|
|
|
29754
29790
|
// src/core/store/cleanup.ts
|
|
29755
29791
|
import { existsSync as existsSync3, readdirSync as readdirSync2, rmSync as rmSync3 } from "node:fs";
|
|
29756
|
-
import { join as
|
|
29792
|
+
import { join as join5 } from "node:path";
|
|
29757
29793
|
|
|
29758
29794
|
// src/core/store/snippet.ts
|
|
29759
29795
|
var K1 = 1.2;
|
|
@@ -29787,14 +29823,14 @@ function identParts(w) {
|
|
|
29787
29823
|
if (cur !== "") parts.push(cur);
|
|
29788
29824
|
return parts;
|
|
29789
29825
|
}
|
|
29790
|
-
function snippetTerms(
|
|
29826
|
+
function snippetTerms(words2) {
|
|
29791
29827
|
const out = /* @__PURE__ */ new Map();
|
|
29792
29828
|
const add = (text, weight, symbol2) => {
|
|
29793
29829
|
if (text === "") return;
|
|
29794
29830
|
const prev = out.get(text);
|
|
29795
29831
|
if (!prev || prev.weight < weight) out.set(text, { text, weight, symbol: symbol2 });
|
|
29796
29832
|
};
|
|
29797
|
-
for (const raw of
|
|
29833
|
+
for (const raw of words2) {
|
|
29798
29834
|
let a = 0;
|
|
29799
29835
|
let b = raw.length;
|
|
29800
29836
|
while (a < b && !isAlnum(raw.charCodeAt(a))) a++;
|
|
@@ -31788,18 +31824,18 @@ function deleteChunkRows(raw, scope) {
|
|
|
31788
31824
|
return Number(raw.prepare("DELETE FROM chunks WHERE " + where).run(arg).changes);
|
|
31789
31825
|
}
|
|
31790
31826
|
function toMatch(q) {
|
|
31791
|
-
const
|
|
31827
|
+
const words2 = [];
|
|
31792
31828
|
let cur = "";
|
|
31793
31829
|
for (const ch of q) {
|
|
31794
31830
|
if (ch.trim() === "" || ch === "\0") {
|
|
31795
|
-
if (cur !== "")
|
|
31831
|
+
if (cur !== "") words2.push(cur);
|
|
31796
31832
|
cur = "";
|
|
31797
31833
|
} else {
|
|
31798
31834
|
cur += ch === '"' ? '""' : ch;
|
|
31799
31835
|
}
|
|
31800
31836
|
}
|
|
31801
|
-
if (cur !== "")
|
|
31802
|
-
return
|
|
31837
|
+
if (cur !== "") words2.push(cur);
|
|
31838
|
+
return words2.map((w) => `"${w}"*`).join(" ");
|
|
31803
31839
|
}
|
|
31804
31840
|
function toMatchAny(q) {
|
|
31805
31841
|
const terms = new Set(toMatch(q).split(" ").filter((t) => t !== ""));
|
|
@@ -31896,11 +31932,11 @@ function searchTerms(q) {
|
|
|
31896
31932
|
return kept.length > 0 ? kept : all;
|
|
31897
31933
|
}
|
|
31898
31934
|
function trigramMatch(q) {
|
|
31899
|
-
const
|
|
31900
|
-
const kept =
|
|
31901
|
-
const parts = new Set((kept.length > 0 ? kept :
|
|
31902
|
-
const whole2 =
|
|
31903
|
-
if (
|
|
31935
|
+
const words2 = blankTokens(q);
|
|
31936
|
+
const kept = words2.filter((w) => !STOPWORDS.has(w.toLowerCase()));
|
|
31937
|
+
const parts = new Set((kept.length > 0 ? kept : words2).filter((w) => [...w].length >= 3));
|
|
31938
|
+
const whole2 = words2.join(" ");
|
|
31939
|
+
if (words2.length > 1 && [...whole2].length >= 3) parts.add(whole2);
|
|
31904
31940
|
return [...parts].map((w) => `"${w.replaceAll('"', '""')}"`).join(" OR ");
|
|
31905
31941
|
}
|
|
31906
31942
|
function editDistance(a, b, max) {
|
|
@@ -31947,10 +31983,10 @@ function queryStems(q) {
|
|
|
31947
31983
|
}
|
|
31948
31984
|
var TYPO_MIN_LEN = 5;
|
|
31949
31985
|
var TYPO_MAX_DIST = 2;
|
|
31950
|
-
function typoTerms(db,
|
|
31986
|
+
function typoTerms(db, words2) {
|
|
31951
31987
|
const has = stmt(db.raw, "SELECT 1 AS x FROM chunks_vocab WHERE term = ?");
|
|
31952
31988
|
const near = stmt(db.raw, "SELECT term, doc, length(term) AS n FROM chunks_vocab WHERE length(term) BETWEEN ? AND ?");
|
|
31953
|
-
const stems = queryStems(
|
|
31989
|
+
const stems = queryStems(words2.join(" "));
|
|
31954
31990
|
const miss = stems.map((stem) => has.get(stem) === void 0 && [...stem].length >= TYPO_MIN_LEN);
|
|
31955
31991
|
if (!miss.includes(true)) return null;
|
|
31956
31992
|
const lens = stems.filter((_, i) => miss[i]).map((stem) => stem.length);
|
|
@@ -32053,9 +32089,9 @@ function ftsListSource(db, source, scope, ctx, sessionId, limit, offset) {
|
|
|
32053
32089
|
}));
|
|
32054
32090
|
}
|
|
32055
32091
|
function highlight(row5, terms, maxBytes = SNIPPET_MAX_BYTES) {
|
|
32056
|
-
const
|
|
32057
|
-
const kept =
|
|
32058
|
-
return buildSnippet(row5, snippetTerms(kept.length > 0 ? kept :
|
|
32092
|
+
const words2 = blankTokens(terms);
|
|
32093
|
+
const kept = words2.filter((w) => !STOPWORDS.has(w.toLowerCase()));
|
|
32094
|
+
return buildSnippet(row5, snippetTerms(kept.length > 0 ? kept : words2), maxBytes);
|
|
32059
32095
|
}
|
|
32060
32096
|
var TL_SCOPE = `
|
|
32061
32097
|
AND (:scope <> 'session' OR session_id = :session_id)
|
|
@@ -32293,12 +32329,12 @@ function queryUnits(db, sessionId, q, limit) {
|
|
|
32293
32329
|
|
|
32294
32330
|
// src/core/store/owners.ts
|
|
32295
32331
|
import { mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync2, rmSync as rmSync2, writeFileSync } from "node:fs";
|
|
32296
|
-
import { basename as basename3, join as
|
|
32332
|
+
import { basename as basename3, join as join4 } from "node:path";
|
|
32297
32333
|
function ownersDir(configDir, projectKey) {
|
|
32298
|
-
return
|
|
32334
|
+
return join4(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
32299
32335
|
}
|
|
32300
32336
|
function ownerFile(configDir, projectKey, serverId) {
|
|
32301
|
-
return
|
|
32337
|
+
return join4(ownersDir(configDir, projectKey), serverId + OWNER_PID_EXT);
|
|
32302
32338
|
}
|
|
32303
32339
|
function errCode(err) {
|
|
32304
32340
|
return err.code;
|
|
@@ -32333,7 +32369,7 @@ function listLiveOwners(configDir, projectKey) {
|
|
|
32333
32369
|
const live = [];
|
|
32334
32370
|
for (const name of names) {
|
|
32335
32371
|
if (!name.endsWith(OWNER_PID_EXT)) continue;
|
|
32336
|
-
const file2 =
|
|
32372
|
+
const file2 = join4(dir, name);
|
|
32337
32373
|
let text;
|
|
32338
32374
|
try {
|
|
32339
32375
|
text = readFileSync2(file2, "utf8");
|
|
@@ -32404,8 +32440,8 @@ function lastAccess(raw) {
|
|
|
32404
32440
|
return row5.t;
|
|
32405
32441
|
}
|
|
32406
32442
|
function sweepOne(configDir, projectKey, cutoff) {
|
|
32407
|
-
const dir =
|
|
32408
|
-
const db = openForSweep(
|
|
32443
|
+
const dir = join5(configDir, PROJECTS_DIR_NAME, projectKey);
|
|
32444
|
+
const db = openForSweep(join5(dir, DB_FILE_NAME), projectKey);
|
|
32409
32445
|
let dead;
|
|
32410
32446
|
try {
|
|
32411
32447
|
dead = withWrite(db, (h) => listLiveOwners(configDir, projectKey).length === 0 && lastAccess(h.raw) < cutoff);
|
|
@@ -32418,7 +32454,7 @@ function sweepOne(configDir, projectKey, cutoff) {
|
|
|
32418
32454
|
function sweepDeadProjects(configDir) {
|
|
32419
32455
|
let entries;
|
|
32420
32456
|
try {
|
|
32421
|
-
entries = readdirSync2(
|
|
32457
|
+
entries = readdirSync2(join5(configDir, PROJECTS_DIR_NAME), { withFileTypes: true });
|
|
32422
32458
|
} catch (err) {
|
|
32423
32459
|
if (err.code === "ENOENT") return [];
|
|
32424
32460
|
throw err;
|
|
@@ -43867,7 +43903,7 @@ function cutPoint(src, start, end, scratch) {
|
|
|
43867
43903
|
const r = encoder.encodeInto(src.slice(start, limit), scratch);
|
|
43868
43904
|
return { end: start + r.read, written: r.written };
|
|
43869
43905
|
}
|
|
43870
|
-
function merge4(src, blocks,
|
|
43906
|
+
function merge4(src, blocks, join23, cap, lineCut) {
|
|
43871
43907
|
const out = [];
|
|
43872
43908
|
const scratch = new Uint8Array(cap);
|
|
43873
43909
|
let wide;
|
|
@@ -43877,7 +43913,7 @@ function merge4(src, blocks, join26, cap, lineCut) {
|
|
|
43877
43913
|
out.push({ ord: out.length, text: src.slice(start, end), bytes: bytes5 });
|
|
43878
43914
|
};
|
|
43879
43915
|
for (const b of blocks) {
|
|
43880
|
-
if (cur !== void 0 && !
|
|
43916
|
+
if (cur !== void 0 && !join23) {
|
|
43881
43917
|
emit(cur.start, cur.end, curBytes);
|
|
43882
43918
|
cur = void 0;
|
|
43883
43919
|
}
|
|
@@ -44039,10 +44075,10 @@ function findRuntime(lang, env = process.env) {
|
|
|
44039
44075
|
return shim;
|
|
44040
44076
|
}
|
|
44041
44077
|
function findGitBash(env) {
|
|
44042
|
-
const
|
|
44043
|
-
if (
|
|
44078
|
+
const git2 = findRuntime(GIT_BIN, env);
|
|
44079
|
+
if (git2 === null) return null;
|
|
44044
44080
|
for (const rel of GIT_BASH_RELATIVE) {
|
|
44045
|
-
const full = path.resolve(path.dirname(
|
|
44081
|
+
const full = path.resolve(path.dirname(git2), ...rel);
|
|
44046
44082
|
if (isRunnable(full)) return full;
|
|
44047
44083
|
}
|
|
44048
44084
|
return null;
|
|
@@ -44147,7 +44183,7 @@ function runProcess(argv, o) {
|
|
|
44147
44183
|
|
|
44148
44184
|
// src/core/index/auto-memory.ts
|
|
44149
44185
|
import { readdirSync as readdirSync3, readFileSync as readFileSync3, statSync as statSync3 } from "node:fs";
|
|
44150
|
-
import { join as
|
|
44186
|
+
import { join as join6 } from "node:path";
|
|
44151
44187
|
var MEMORY_FILES = Object.freeze([
|
|
44152
44188
|
Object.freeze(["CLAUDE.md"]),
|
|
44153
44189
|
Object.freeze(["CLAUDE.local.md"]),
|
|
@@ -44161,7 +44197,7 @@ var KIRO_STEERING = Object.freeze([".kiro", "steering"]);
|
|
|
44161
44197
|
var MD = ".md";
|
|
44162
44198
|
function steeringFiles(worktree) {
|
|
44163
44199
|
try {
|
|
44164
|
-
return readdirSync3(
|
|
44200
|
+
return readdirSync3(join6(worktree, ...KIRO_STEERING)).filter((n) => n.endsWith(MD)).sort().map((n) => [...KIRO_STEERING, n]);
|
|
44165
44201
|
} catch {
|
|
44166
44202
|
return [];
|
|
44167
44203
|
}
|
|
@@ -44169,7 +44205,7 @@ function steeringFiles(worktree) {
|
|
|
44169
44205
|
function readAutoMemory(project) {
|
|
44170
44206
|
const rows = [];
|
|
44171
44207
|
for (const segs of [...MEMORY_FILES, ...steeringFiles(project.worktree)]) {
|
|
44172
|
-
const path8 =
|
|
44208
|
+
const path8 = join6(project.worktree, ...segs);
|
|
44173
44209
|
if (!isInside(project.worktree, path8)) continue;
|
|
44174
44210
|
try {
|
|
44175
44211
|
const st = statSync3(path8);
|
|
@@ -44806,7 +44842,7 @@ var ctxBatch = Object.freeze({
|
|
|
44806
44842
|
|
|
44807
44843
|
// src/core/tools/doctor.ts
|
|
44808
44844
|
import { readdirSync as readdirSync7, readFileSync as readFileSync11, existsSync as existsSync16 } from "node:fs";
|
|
44809
|
-
import { basename as basename5, join as
|
|
44845
|
+
import { basename as basename5, join as join16 } from "node:path";
|
|
44810
44846
|
|
|
44811
44847
|
// src/adapters/claude-code.ts
|
|
44812
44848
|
var TOOL_NAME_PREFIX = "mcp__plugin_context-mode_context-mode__";
|
|
@@ -45023,6 +45059,7 @@ var GEMINI_SOURCES = { startup: "startup", resume: "resume", clear: "clear" };
|
|
|
45023
45059
|
var HINT_EVENTS = ["SessionStart", "UserPromptSubmit", "PostToolUse"];
|
|
45024
45060
|
var DENY_EVENTS = ["UserPromptSubmit", "PreToolUse"];
|
|
45025
45061
|
var EMPTY = { stdout: "", exitCode: 0 };
|
|
45062
|
+
var GEMINI_REPLACE_LEAD = "the tool ran and succeeded; context-mode indexed its full output, and this is the part that answers the call:\n";
|
|
45026
45063
|
function own3(p, key) {
|
|
45027
45064
|
return Object.hasOwn(p, key) ? p[key] : void 0;
|
|
45028
45065
|
}
|
|
@@ -45042,13 +45079,67 @@ function canonicalName2(name, mcp) {
|
|
|
45042
45079
|
if (typeof server !== "string" || typeof tool !== "string") return name;
|
|
45043
45080
|
return "mcp:" + server + ":" + tool;
|
|
45044
45081
|
}
|
|
45082
|
+
function partsText(llm) {
|
|
45083
|
+
if (!Array.isArray(llm) || llm.length === 0) return void 0;
|
|
45084
|
+
const out = [];
|
|
45085
|
+
for (const part of llm) {
|
|
45086
|
+
if (typeof part === "string") {
|
|
45087
|
+
out.push(part);
|
|
45088
|
+
continue;
|
|
45089
|
+
}
|
|
45090
|
+
if (typeof part !== "object" || part === null) return void 0;
|
|
45091
|
+
const t = own3(part, "text");
|
|
45092
|
+
if (typeof t !== "string") return void 0;
|
|
45093
|
+
out.push(t);
|
|
45094
|
+
}
|
|
45095
|
+
return out.join("");
|
|
45096
|
+
}
|
|
45045
45097
|
function readResult2(resp) {
|
|
45046
45098
|
const obj = typeof resp === "object" && resp !== null ? resp : void 0;
|
|
45047
45099
|
const llm = obj === void 0 ? void 0 : own3(obj, "llmContent");
|
|
45048
|
-
const text = resp === void 0 ? "" : typeof resp === "string" ? resp : typeof llm === "string" ? llm : JSON.stringify(resp);
|
|
45100
|
+
const text = resp === void 0 ? "" : typeof resp === "string" ? resp : typeof llm === "string" ? llm : partsText(llm) ?? JSON.stringify(resp);
|
|
45049
45101
|
const err = obj === void 0 ? void 0 : own3(obj, "error");
|
|
45050
45102
|
return { isError: err !== void 0 && err !== null, bytes: Buffer.byteLength(text), text };
|
|
45051
45103
|
}
|
|
45104
|
+
var URL_STARTS = ["https://", "http://"];
|
|
45105
|
+
var URL_TRAIL = `.,;:!?)]}>'"`;
|
|
45106
|
+
var SPACE = " \n\r\f\v";
|
|
45107
|
+
function words(text) {
|
|
45108
|
+
const out = [];
|
|
45109
|
+
let cur = "";
|
|
45110
|
+
for (const ch of text) {
|
|
45111
|
+
if (SPACE.includes(ch)) {
|
|
45112
|
+
if (cur !== "") out.push(cur);
|
|
45113
|
+
cur = "";
|
|
45114
|
+
} else cur += ch;
|
|
45115
|
+
}
|
|
45116
|
+
if (cur !== "") out.push(cur);
|
|
45117
|
+
return out;
|
|
45118
|
+
}
|
|
45119
|
+
function firstUrl(prompt) {
|
|
45120
|
+
if (typeof prompt !== "string") return void 0;
|
|
45121
|
+
for (const word of words(prompt)) {
|
|
45122
|
+
const lower = word.toLowerCase();
|
|
45123
|
+
const at = URL_STARTS.map((s) => lower.indexOf(s)).filter((i) => i >= 0).sort((a, b) => a - b)[0];
|
|
45124
|
+
if (at === void 0) continue;
|
|
45125
|
+
let url4 = word.slice(at);
|
|
45126
|
+
while (url4.length > 0 && URL_TRAIL.includes(url4[url4.length - 1])) url4 = url4.slice(0, -1);
|
|
45127
|
+
return url4;
|
|
45128
|
+
}
|
|
45129
|
+
return void 0;
|
|
45130
|
+
}
|
|
45131
|
+
function nativeInput(name, input) {
|
|
45132
|
+
if (name === "web_fetch" && own3(input, "url") === void 0) {
|
|
45133
|
+
const url4 = firstUrl(own3(input, "prompt"));
|
|
45134
|
+
return url4 === void 0 ? input : { ...input, url: url4 };
|
|
45135
|
+
}
|
|
45136
|
+
if (name === "read_many_files" && own3(input, "file_path") === void 0) {
|
|
45137
|
+
const inc = own3(input, "include");
|
|
45138
|
+
const list3 = Array.isArray(inc) ? inc.filter((v) => typeof v === "string") : [];
|
|
45139
|
+
return list3.length === 0 ? input : { ...input, file_path: list3.join(" ") };
|
|
45140
|
+
}
|
|
45141
|
+
return input;
|
|
45142
|
+
}
|
|
45052
45143
|
function decode5(raw) {
|
|
45053
45144
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("gemini: hook payload is not a JSON object");
|
|
45054
45145
|
const p = raw;
|
|
@@ -45066,7 +45157,7 @@ function decode5(raw) {
|
|
|
45066
45157
|
ev.tool = {
|
|
45067
45158
|
name,
|
|
45068
45159
|
canonicalName: canonicalName2(name, own3(p, "mcp_context")),
|
|
45069
|
-
input: typeof input === "object" && input !== null && !Array.isArray(input) ? input : {}
|
|
45160
|
+
input: nativeInput(name, typeof input === "object" && input !== null && !Array.isArray(input) ? input : {})
|
|
45070
45161
|
};
|
|
45071
45162
|
}
|
|
45072
45163
|
if (event === "PostToolUse") ev.result = readResult2(own3(p, "tool_response"));
|
|
@@ -45084,7 +45175,7 @@ function encode5(ev, d, _extra) {
|
|
|
45084
45175
|
return { stdout: JSON.stringify({ decision: "deny", reason: d.rewritten === void 0 ? d.reason : d.rewritten + "\n" + d.reason }), exitCode: 0 };
|
|
45085
45176
|
case "replace":
|
|
45086
45177
|
if (ev.event !== "PostToolUse") return EMPTY;
|
|
45087
|
-
return { stdout: JSON.stringify({ decision: "deny", reason: d.output }), exitCode: 0 };
|
|
45178
|
+
return { stdout: JSON.stringify({ decision: "deny", reason: GEMINI_REPLACE_LEAD + d.output }), exitCode: 0 };
|
|
45088
45179
|
}
|
|
45089
45180
|
}
|
|
45090
45181
|
|
|
@@ -45417,6 +45508,7 @@ function encode9(ev, d, _extra) {
|
|
|
45417
45508
|
|
|
45418
45509
|
// src/adapters/zcode.ts
|
|
45419
45510
|
var TOOL_NAME_PREFIX8 = "mcp__context-mode__";
|
|
45511
|
+
var PLUGIN_TOOL_NAME_PREFIX = "mcp__plugin_context-mode_context-mode__";
|
|
45420
45512
|
var ZCODE_SOURCES = { startup: "startup", resume: "resume", clear: "clear", compact: "compact" };
|
|
45421
45513
|
var TWINS = { hook_event_name: "hookEventName", session_id: "sessionId" };
|
|
45422
45514
|
var FAILURE_EVENT2 = "PostToolUseFailure";
|
|
@@ -45426,7 +45518,9 @@ function decode10(raw) {
|
|
|
45426
45518
|
for (const [snake, camel] of Object.entries(TWINS)) if (p[snake] === void 0) p[snake] = p[camel];
|
|
45427
45519
|
const failure3 = p.hook_event_name === FAILURE_EVENT2;
|
|
45428
45520
|
if (failure3) p.hook_event_name = "PostToolUse";
|
|
45429
|
-
const
|
|
45521
|
+
const toolName2 = typeof p.tool_name === "string" ? p.tool_name : "";
|
|
45522
|
+
const prefix = toolName2.startsWith(PLUGIN_TOOL_NAME_PREFIX) ? PLUGIN_TOOL_NAME_PREFIX : TOOL_NAME_PREFIX8;
|
|
45523
|
+
const ev = decodeClaudeShape(p, "zcode", prefix, ZCODE_SOURCES);
|
|
45430
45524
|
if (failure3) {
|
|
45431
45525
|
const text = typeof p.error === "string" ? p.error : p.error === void 0 ? "" : JSON.stringify(p.error);
|
|
45432
45526
|
ev.result = { isError: true, bytes: Buffer.byteLength(text), text };
|
|
@@ -45507,8 +45601,9 @@ var OPENCODE_EVENTS = {
|
|
|
45507
45601
|
"step-finish": "Usage"
|
|
45508
45602
|
};
|
|
45509
45603
|
var SHELL_TOOL_NAME = "bash";
|
|
45604
|
+
var READ_TOOL_NAME = "read";
|
|
45510
45605
|
var SHELL_TOOL_NAMES5 = Object.freeze([SHELL_TOOL_NAME, "shell"]);
|
|
45511
|
-
var NATIVE_TO_CANONICAL7 = { webfetch: "WebFetch", ...Object.fromEntries(SHELL_TOOL_NAMES5.map((n) => [n, "Bash"])) };
|
|
45606
|
+
var NATIVE_TO_CANONICAL7 = { webfetch: "WebFetch", [READ_TOOL_NAME]: "Read", ...Object.fromEntries(SHELL_TOOL_NAMES5.map((n) => [n, "Bash"])) };
|
|
45512
45607
|
function toCanonicalTool(name) {
|
|
45513
45608
|
if (name.startsWith(OWN_WIRE_PREFIX)) return name.slice(OWN_WIRE_PREFIX.length);
|
|
45514
45609
|
return Object.prototype.hasOwnProperty.call(NATIVE_TO_CANONICAL7, name) ? NATIVE_TO_CANONICAL7[name] : name;
|
|
@@ -45736,9 +45831,9 @@ var ADAPTERS = Object.freeze([
|
|
|
45736
45831
|
installMode: "in-process",
|
|
45737
45832
|
projectSource: "spawn-cwd",
|
|
45738
45833
|
toolNamePrefix: TOOL_NAME_PREFIX10,
|
|
45739
|
-
nativeTools: { shell: [SHELL_TOOL_NAME] },
|
|
45834
|
+
nativeTools: { shell: [SHELL_TOOL_NAME], read: [READ_TOOL_NAME] },
|
|
45740
45835
|
execReadOnlyHint: false,
|
|
45741
|
-
// D-HF-OPENCODE-SHELL-1
|
|
45836
|
+
// D-HF-OPENCODE-SHELL-1, D-R44-OC-READ-1
|
|
45742
45837
|
// Usage: step-finish cost row (DEVIATIONS D-M5-arch-2).
|
|
45743
45838
|
eventMap: { SessionStart: "context", UserPromptSubmit: "prompt", PreToolUse: "execute.before", PostToolUse: "execute.after", PreCompact: "compaction", Usage: "step-finish" },
|
|
45744
45839
|
compactDelivery: "opencode-cache",
|
|
@@ -45764,14 +45859,14 @@ function getAdapter(id) {
|
|
|
45764
45859
|
|
|
45765
45860
|
// src/core/ops/bundle-dir.ts
|
|
45766
45861
|
import { existsSync as existsSync4 } from "node:fs";
|
|
45767
|
-
import { dirname as dirname4, join as
|
|
45862
|
+
import { dirname as dirname4, join as join7 } from "node:path";
|
|
45768
45863
|
import { fileURLToPath } from "node:url";
|
|
45769
45864
|
function bundleDirOf(argv1, moduleFile) {
|
|
45770
45865
|
const own4 = dirname4(argv1);
|
|
45771
|
-
if (existsSync4(
|
|
45866
|
+
if (existsSync4(join7(own4, SERVER_ENTRY_FILE))) return own4;
|
|
45772
45867
|
let dir = dirname4(moduleFile);
|
|
45773
45868
|
for (; ; ) {
|
|
45774
|
-
if (existsSync4(
|
|
45869
|
+
if (existsSync4(join7(dir, SERVER_ENTRY_FILE))) return dir;
|
|
45775
45870
|
const up = dirname4(dir);
|
|
45776
45871
|
if (up === dir) return own4;
|
|
45777
45872
|
dir = up;
|
|
@@ -45786,16 +45881,16 @@ function ownBundleDir() {
|
|
|
45786
45881
|
|
|
45787
45882
|
// src/core/ops/doctor-config.ts
|
|
45788
45883
|
import { existsSync as existsSync9, readdirSync as readdirSync6 } from "node:fs";
|
|
45789
|
-
import { join as
|
|
45884
|
+
import { join as join11 } from "node:path";
|
|
45790
45885
|
|
|
45791
45886
|
// src/core/ops/detect-v1.ts
|
|
45792
45887
|
import { existsSync as existsSync6, opendirSync, readdirSync as readdirSync4, readFileSync as readFileSync5 } from "node:fs";
|
|
45793
45888
|
import { tmpdir } from "node:os";
|
|
45794
|
-
import { join as
|
|
45889
|
+
import { join as join9 } from "node:path";
|
|
45795
45890
|
|
|
45796
45891
|
// src/core/ops/host-config.ts
|
|
45797
45892
|
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
|
|
45798
|
-
import { dirname as dirname5, join as
|
|
45893
|
+
import { dirname as dirname5, join as join8 } from "node:path";
|
|
45799
45894
|
|
|
45800
45895
|
// node_modules/eslint-visitor-keys/lib/visitor-keys.js
|
|
45801
45896
|
var KEYS2 = {
|
|
@@ -47935,7 +48030,7 @@ function formatOf(path8) {
|
|
|
47935
48030
|
function readHostConfig(agent, path8) {
|
|
47936
48031
|
let file2 = path8;
|
|
47937
48032
|
if (agent === "opencode") {
|
|
47938
|
-
const jsonc =
|
|
48033
|
+
const jsonc = join8(dirname5(path8), OPENCODE_CONFIG_FILES[0]);
|
|
47939
48034
|
if (existsSync5(jsonc)) file2 = jsonc;
|
|
47940
48035
|
}
|
|
47941
48036
|
const raw = existsSync5(file2) ? readFileSync4(file2, "utf8") : "";
|
|
@@ -48283,7 +48378,7 @@ function setText(agent, path8, text, format, key, value) {
|
|
|
48283
48378
|
}
|
|
48284
48379
|
}
|
|
48285
48380
|
function serverScript() {
|
|
48286
|
-
return
|
|
48381
|
+
return join8(dirname5(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
|
|
48287
48382
|
}
|
|
48288
48383
|
function isNodeCommand(command) {
|
|
48289
48384
|
if (typeof command !== "string") return false;
|
|
@@ -48295,21 +48390,27 @@ function isNodeCommand(command) {
|
|
|
48295
48390
|
function ownMcpValue(agent, node3, server) {
|
|
48296
48391
|
const mcp = OWN_MCP_ENTRY[agent];
|
|
48297
48392
|
if (mcp === void 0) return void 0;
|
|
48298
|
-
|
|
48299
|
-
return { ...mcp.fields, [MCP_COMMAND_FIELD]: node3, [MCP_ARGS_FIELD]: [server, AGENT_ARG, agent, ...tail] };
|
|
48393
|
+
return { ...mcp.fields, [MCP_COMMAND_FIELD]: node3, [MCP_ARGS_FIELD]: [server, AGENT_ARG, agent] };
|
|
48300
48394
|
}
|
|
48301
48395
|
function opencodePluginFile() {
|
|
48302
48396
|
return ownBundleDir();
|
|
48303
48397
|
}
|
|
48304
|
-
function listTarget(key,
|
|
48398
|
+
function listTarget(key, legacy, swap, isNative) {
|
|
48305
48399
|
return {
|
|
48306
48400
|
key: [key],
|
|
48307
48401
|
next(current) {
|
|
48308
|
-
|
|
48309
|
-
|
|
48402
|
+
if (!Array.isArray(current) || !current.some(legacy)) return current;
|
|
48403
|
+
const keep = current.filter((x) => !legacy(x));
|
|
48404
|
+
if (keep.some(isNative)) return keep;
|
|
48405
|
+
const at = current.findIndex(legacy);
|
|
48406
|
+
return current.flatMap((x, i) => i === at ? [swap(x)] : legacy(x) ? [] : [x]);
|
|
48310
48407
|
}
|
|
48311
48408
|
};
|
|
48312
48409
|
}
|
|
48410
|
+
var piSource = (x) => isPlainObject6(x) ? x[PI_PACKAGE_SOURCE_KEY] : x;
|
|
48411
|
+
var opencodeSpec = (x) => isPlainObject6(x) ? x[OPENCODE_PACKAGE_FIELD] : x;
|
|
48412
|
+
var isNpmOf = (bare2) => (s) => typeof s === "string" && (s === bare2 || s.startsWith(bare2 + NPM_VERSION_SEP));
|
|
48413
|
+
var swapField = (field, spec) => (x) => isPlainObject6(x) ? { ...x, [field]: spec } : spec;
|
|
48313
48414
|
function ownTargets(agent, accept) {
|
|
48314
48415
|
const mcp = OWN_MCP_ENTRY[agent];
|
|
48315
48416
|
if (mcp !== void 0) {
|
|
@@ -48322,8 +48423,18 @@ function ownTargets(agent, accept) {
|
|
|
48322
48423
|
}
|
|
48323
48424
|
}, ...(mcp.also ?? []).map(([key, value]) => ({ key, next: () => value }))];
|
|
48324
48425
|
}
|
|
48325
|
-
if (agent === "opencode")
|
|
48326
|
-
|
|
48426
|
+
if (agent === "opencode") {
|
|
48427
|
+
const alt = accept.listEntries ?? [];
|
|
48428
|
+
const native = (x) => {
|
|
48429
|
+
const s = opencodeSpec(x);
|
|
48430
|
+
return typeof s === "string" && (s.startsWith(OPENCODE_NPM_SPEC_PREFIX) || alt.includes(s));
|
|
48431
|
+
};
|
|
48432
|
+
return [listTarget(OPENCODE_PLUGIN_KEY, (x) => opencodeSpec(x) === OPENCODE_GIT_SPEC, swapField(OPENCODE_PACKAGE_FIELD, OPENCODE_NPM_LATEST), native)];
|
|
48433
|
+
}
|
|
48434
|
+
if (agent === "pi") {
|
|
48435
|
+
const npm = isNpmOf(V1_PI_PACKAGE);
|
|
48436
|
+
return [listTarget(PI_PACKAGES_KEY, (x) => piSource(x) === PI_GIT_PACKAGE, swapField(PI_PACKAGE_SOURCE_KEY, PI_NPM_LATEST), (x) => npm(piSource(x)))];
|
|
48437
|
+
}
|
|
48327
48438
|
return [];
|
|
48328
48439
|
}
|
|
48329
48440
|
function applyEdits(agent, path8, text, format, wanted) {
|
|
@@ -48466,7 +48577,7 @@ function mcpEntry(file2, doc, out) {
|
|
|
48466
48577
|
}
|
|
48467
48578
|
}
|
|
48468
48579
|
function claudeShapeSettings(agentHome, out) {
|
|
48469
|
-
const file2 =
|
|
48580
|
+
const file2 = join9(agentHome, SETTINGS_FILE);
|
|
48470
48581
|
const doc = readJson(file2);
|
|
48471
48582
|
for (const c of nestedCommands(doc)) {
|
|
48472
48583
|
if (c.command.includes(V1_CACHE_HEAL_NAME)) out.push(finding(file2, c.path, V1_REASON.cacheHealHook));
|
|
@@ -48486,49 +48597,50 @@ function v1HookFile(file2, out) {
|
|
|
48486
48597
|
function scanClaudeCode(home, agentHome, out) {
|
|
48487
48598
|
claudeShapeSettings(agentHome, out);
|
|
48488
48599
|
for (const ext of V1_CACHE_HEAL_EXTS) {
|
|
48489
|
-
const file2 =
|
|
48600
|
+
const file2 = join9(agentHome, V1_HOOKS_DIR_NAME, V1_CACHE_HEAL_NAME + ext);
|
|
48490
48601
|
if (existsSync6(file2)) out.push(finding(file2, "", V1_REASON.cacheHealFile));
|
|
48491
48602
|
}
|
|
48492
|
-
const userFile =
|
|
48603
|
+
const userFile = join9(home, CLAUDE_USER_CONFIG_FILE);
|
|
48493
48604
|
mcpEntry(userFile, readJson(userFile), out);
|
|
48494
|
-
dataDir(
|
|
48605
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48495
48606
|
}
|
|
48496
48607
|
function scanCodex(agentHome, out) {
|
|
48497
|
-
const hooksFile =
|
|
48608
|
+
const hooksFile = join9(agentHome, HOOKS_JSON_FILE);
|
|
48498
48609
|
for (const c of nestedCommands(readJson(hooksFile))) {
|
|
48499
48610
|
if (c.command.includes(V1_CODEX_HOOK_COMMAND) || isCodexScript(c.command)) {
|
|
48500
48611
|
out.push(finding(hooksFile, c.path, V1_REASON.codexHook));
|
|
48501
48612
|
}
|
|
48502
48613
|
}
|
|
48503
|
-
const tomlFile =
|
|
48614
|
+
const tomlFile = join9(agentHome, CONFIG_TOML_FILE);
|
|
48504
48615
|
const config4 = readTomlValue(tomlFile);
|
|
48505
48616
|
for (const span2 of readTomlTables(tomlFile)) {
|
|
48506
48617
|
if (span2.path[0] !== V1_TOML_SECTION_ROOT || span2.path[1] !== SERVER_KEY) continue;
|
|
48507
48618
|
if (span2.path.length === 2 && isV2McpTable(hostConfigValueAt(config4, span2.path))) continue;
|
|
48508
48619
|
out.push(finding(tomlFile, span2.header.trim(), V1_REASON.codexToml));
|
|
48509
48620
|
}
|
|
48510
|
-
dataDir(
|
|
48621
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48511
48622
|
}
|
|
48512
48623
|
function scanGemini(agentHome, out) {
|
|
48513
|
-
const file2 =
|
|
48624
|
+
const file2 = join9(agentHome, SETTINGS_FILE);
|
|
48514
48625
|
for (const c of nestedCommands(readJson(file2))) {
|
|
48515
48626
|
if (c.command.includes(SERVER_KEY)) out.push(finding(file2, c.path, V1_REASON.hook));
|
|
48516
48627
|
}
|
|
48517
|
-
dataDir(
|
|
48628
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDirShared, out);
|
|
48518
48629
|
}
|
|
48519
48630
|
function scanVscode(agentHome, project, out) {
|
|
48520
48631
|
if (project !== void 0) {
|
|
48521
|
-
v1HookFile(
|
|
48522
|
-
const mcpFile2 =
|
|
48632
|
+
v1HookFile(join9(project, GITHUB_DIR_NAME, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
|
|
48633
|
+
const mcpFile2 = join9(project, VSCODE_DIR_NAME, VSCODE_MCP_FILE);
|
|
48523
48634
|
const doc = readJson(mcpFile2);
|
|
48524
48635
|
const servers = isObj(doc) && isObj(doc[VSCODE_MCP_SERVERS_KEY]) ? doc[VSCODE_MCP_SERVERS_KEY] : {};
|
|
48525
48636
|
const entry = Object.hasOwn(servers, SERVER_KEY) ? servers[SERVER_KEY] : void 0;
|
|
48526
48637
|
if (isObj(entry) && (entry.command === V1_BIN_COMMAND || listOf(entry.args).some((a) => a === V1_BIN_COMMAND))) {
|
|
48527
48638
|
out.push(finding(mcpFile2, keyPath(VSCODE_MCP_SERVERS_KEY, SERVER_KEY), V1_REASON.vscodeMcp));
|
|
48528
48639
|
}
|
|
48529
|
-
|
|
48640
|
+
const sessions = join9(project, GITHUB_DIR_NAME, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME);
|
|
48641
|
+
dataDir(sessions, reachedThroughLink(project, sessions) ? V1_REASON.projectLink : V1_REASON.dataDir, out);
|
|
48530
48642
|
}
|
|
48531
|
-
dataDir(
|
|
48643
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
|
|
48532
48644
|
}
|
|
48533
48645
|
function jsonFiles(dir) {
|
|
48534
48646
|
try {
|
|
@@ -48538,10 +48650,10 @@ function jsonFiles(dir) {
|
|
|
48538
48650
|
}
|
|
48539
48651
|
}
|
|
48540
48652
|
function scanKiro(agentHome, project, out) {
|
|
48541
|
-
const agentsDir =
|
|
48542
|
-
const defaultFile =
|
|
48653
|
+
const agentsDir = join9(agentHome, KIRO_AGENTS_DIR);
|
|
48654
|
+
const defaultFile = join9(agentHome, ...KIRO_AGENT_FILE);
|
|
48543
48655
|
for (const name of jsonFiles(agentsDir)) {
|
|
48544
|
-
const file2 =
|
|
48656
|
+
const file2 = join9(agentsDir, name);
|
|
48545
48657
|
const doc = readJson(file2);
|
|
48546
48658
|
if (isObj(doc) && doc[KIRO_AGENT_NAME_KEY] === SERVER_KEY) {
|
|
48547
48659
|
out.push(finding(file2, "", V1_REASON.kiroAgentFile));
|
|
@@ -48552,46 +48664,48 @@ function scanKiro(agentHome, project, out) {
|
|
|
48552
48664
|
if (isV1Hook(c.command)) out.push(finding(file2, c.path, V1_REASON.kiroHook));
|
|
48553
48665
|
}
|
|
48554
48666
|
}
|
|
48555
|
-
const steeringDocs = [
|
|
48556
|
-
if (project !== void 0) steeringDocs.push(
|
|
48667
|
+
const steeringDocs = [join9(agentHome, ...KIRO_STEERING_FILE)];
|
|
48668
|
+
if (project !== void 0) steeringDocs.push(join9(project, ...AGENT_HOME_DIR.kiro, ...KIRO_STEERING_FILE));
|
|
48557
48669
|
for (const file2 of steeringDocs) {
|
|
48558
48670
|
if (existsSync6(file2)) out.push(finding(file2, "", V1_REASON.kiroSteering));
|
|
48559
48671
|
}
|
|
48560
|
-
dataDir(
|
|
48672
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48561
48673
|
}
|
|
48562
48674
|
function piNpmIsCurrent(piAgentDir) {
|
|
48563
|
-
const doc = readJson(
|
|
48675
|
+
const doc = readJson(join9(piAgentDir, PI_NPM_DIR, PI_NODE_MODULES_DIR, SERVER_KEY, PI_PACKAGE_JSON_FILE));
|
|
48564
48676
|
const version4 = isObj(doc) && typeof doc.version === "string" ? doc.version : "";
|
|
48565
48677
|
return Number.parseInt(version4, 10) >= PI_CURRENT_MAJOR;
|
|
48566
48678
|
}
|
|
48567
48679
|
function scanPi(piAgentDir, agentHome, out) {
|
|
48568
|
-
const file2 =
|
|
48680
|
+
const file2 = join9(piAgentDir, SETTINGS_FILE);
|
|
48569
48681
|
const doc = readJson(file2);
|
|
48570
48682
|
listOf(isObj(doc) ? doc[PI_PACKAGES_KEY] : void 0).forEach((pkg, i) => {
|
|
48571
48683
|
const spec = isObj(pkg) ? pkg[PI_PACKAGE_SOURCE_KEY] : pkg;
|
|
48572
48684
|
if (spec === V1_PI_PACKAGE && !piNpmIsCurrent(piAgentDir)) out.push(finding(file2, keyPath(PI_PACKAGES_KEY, i), V1_REASON.piNpm));
|
|
48685
|
+
if (spec === PI_GIT_PACKAGE) out.push(finding(file2, keyPath(PI_PACKAGES_KEY, i), V1_REASON.piGit));
|
|
48573
48686
|
});
|
|
48574
|
-
dataDir(
|
|
48687
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48575
48688
|
}
|
|
48576
48689
|
function scanOpencode(agentHome, out) {
|
|
48577
48690
|
for (const name of OPENCODE_CONFIG_FILES) {
|
|
48578
|
-
const file2 =
|
|
48691
|
+
const file2 = join9(agentHome, name);
|
|
48579
48692
|
const doc = readJson(file2);
|
|
48580
48693
|
if (!isObj(doc) || !Array.isArray(doc[OPENCODE_PLUGIN_KEY])) continue;
|
|
48581
48694
|
doc[OPENCODE_PLUGIN_KEY].forEach((spec, i) => {
|
|
48582
48695
|
if (spec === V1_OPENCODE_PLUGIN_SPEC) out.push(finding(file2, keyPath(OPENCODE_PLUGIN_KEY, i), V1_REASON.opencodePlugin));
|
|
48696
|
+
if (spec === OPENCODE_GIT_SPEC) out.push(finding(file2, keyPath(OPENCODE_PLUGIN_KEY, i), V1_REASON.opencodeGit));
|
|
48583
48697
|
});
|
|
48584
48698
|
return;
|
|
48585
48699
|
}
|
|
48586
48700
|
}
|
|
48587
48701
|
function scanZcode(agentHome, out) {
|
|
48588
|
-
const configFile =
|
|
48702
|
+
const configFile = join9(agentHome, ZCODE_CLI_DIR, CONFIG_JSON_FILE);
|
|
48589
48703
|
const config4 = readJson(configFile);
|
|
48590
48704
|
const events = isObj(config4) && isObj(config4[HOOKS_KEY]) ? config4[HOOKS_KEY][ZCODE_EVENTS_KEY] : void 0;
|
|
48591
48705
|
for (const c of flatCommands(events, [HOOKS_KEY, ZCODE_EVENTS_KEY])) {
|
|
48592
48706
|
if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(configFile, c.path, V1_REASON.zcodeHook));
|
|
48593
48707
|
}
|
|
48594
|
-
const hooksFile =
|
|
48708
|
+
const hooksFile = join9(agentHome, ZCODE_CLI_DIR, HOOKS_JSON_FILE);
|
|
48595
48709
|
for (const c of nestedCommands(readJson(hooksFile))) {
|
|
48596
48710
|
if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(hooksFile, c.path, V1_REASON.zcodeHook));
|
|
48597
48711
|
}
|
|
@@ -48615,14 +48729,14 @@ function firstTmpMatch(dir) {
|
|
|
48615
48729
|
}
|
|
48616
48730
|
}
|
|
48617
48731
|
function scanAll(home, tmp, out) {
|
|
48618
|
-
const root =
|
|
48619
|
-
for (const name of V1_DATA_ROOT_ENTRIES) dataDir(
|
|
48732
|
+
const root = join9(home, DATA_ROOT.slice(1));
|
|
48733
|
+
for (const name of V1_DATA_ROOT_ENTRIES) dataDir(join9(root, name), V1_REASON.dataRoot, out);
|
|
48620
48734
|
if (firstTmpMatch(tmp) !== null) out.push(finding(tmp, V1_TMP_PREFIX + "*", V1_REASON.tmpFile));
|
|
48621
48735
|
}
|
|
48622
48736
|
function detectV1(agent, home, scope = {}) {
|
|
48623
48737
|
const out = [];
|
|
48624
48738
|
const project = scope.project;
|
|
48625
|
-
const agentHome = agent === "claude-code" && scope.claudeDir !== void 0 ? scope.claudeDir : agent === "codex" && scope.codexDir !== void 0 ? scope.codexDir : agent === "copilot-cli" && scope.copilotDir !== void 0 ? scope.copilotDir : agent === "kiro" && scope.kiroDir !== void 0 ? scope.kiroDir : agent === "opencode" && scope.opencodeDir !== void 0 ? scope.opencodeDir :
|
|
48739
|
+
const agentHome = agent === "claude-code" && scope.claudeDir !== void 0 ? scope.claudeDir : agent === "codex" && scope.codexDir !== void 0 ? scope.codexDir : agent === "gemini" && scope.geminiDir !== void 0 ? scope.geminiDir : agent === "copilot-cli" && scope.copilotDir !== void 0 ? scope.copilotDir : agent === "kiro" && scope.kiroDir !== void 0 ? scope.kiroDir : agent === "opencode" && scope.opencodeDir !== void 0 ? scope.opencodeDir : join9(home, ...AGENT_HOME_DIR[agent]);
|
|
48626
48740
|
switch (agent) {
|
|
48627
48741
|
case "claude-code":
|
|
48628
48742
|
scanClaudeCode(home, agentHome, out);
|
|
@@ -48635,11 +48749,11 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48635
48749
|
break;
|
|
48636
48750
|
case "qwen":
|
|
48637
48751
|
claudeShapeSettings(agentHome, out);
|
|
48638
|
-
dataDir(
|
|
48752
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48639
48753
|
break;
|
|
48640
48754
|
case "copilot-cli":
|
|
48641
|
-
v1HookFile(
|
|
48642
|
-
dataDir(
|
|
48755
|
+
v1HookFile(join9(agentHome, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
|
|
48756
|
+
dataDir(join9(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
|
|
48643
48757
|
break;
|
|
48644
48758
|
case "vscode":
|
|
48645
48759
|
scanVscode(agentHome, project, out);
|
|
@@ -48648,7 +48762,7 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48648
48762
|
scanKiro(agentHome, project, out);
|
|
48649
48763
|
break;
|
|
48650
48764
|
case "pi":
|
|
48651
|
-
scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir :
|
|
48765
|
+
scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir : join9(agentHome, PI_AGENT_DIR), agentHome, out);
|
|
48652
48766
|
break;
|
|
48653
48767
|
// D-WIN-PIDIR-1: empty is unset
|
|
48654
48768
|
case "opencode":
|
|
@@ -48664,7 +48778,7 @@ function detectV1(agent, home, scope = {}) {
|
|
|
48664
48778
|
|
|
48665
48779
|
// src/core/ops/plugin-root.ts
|
|
48666
48780
|
import { existsSync as existsSync7, readdirSync as readdirSync5, readFileSync as readFileSync6, realpathSync as realpathSync4 } from "node:fs";
|
|
48667
|
-
import { dirname as dirname6, isAbsolute, join as
|
|
48781
|
+
import { dirname as dirname6, isAbsolute, join as join10, sep as sep2 } from "node:path";
|
|
48668
48782
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
48669
48783
|
function missing(agent, path8) {
|
|
48670
48784
|
return new CtxError("PLUGIN_ROOT_MISSING", { agent, path: path8 });
|
|
@@ -48712,8 +48826,8 @@ var readOrNull = (file2) => {
|
|
|
48712
48826
|
};
|
|
48713
48827
|
var samePath = (a, b) => a === b || (realOrNull(a) ?? a) === (realOrNull(b) ?? b);
|
|
48714
48828
|
function enabledPlugins(claudeDir, project) {
|
|
48715
|
-
const files = [
|
|
48716
|
-
if (project !== void 0) files.push(
|
|
48829
|
+
const files = [join10(claudeDir, SETTINGS_FILE)];
|
|
48830
|
+
if (project !== void 0) files.push(join10(project, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), join10(project, HOST_CONFIG_DIR_NAME, SETTINGS_LOCAL_FILE));
|
|
48717
48831
|
const out = {};
|
|
48718
48832
|
for (const file2 of files) {
|
|
48719
48833
|
const text = readOrNull(file2);
|
|
@@ -48729,7 +48843,7 @@ function marketplaceChoice(env, worktree) {
|
|
|
48729
48843
|
const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
|
|
48730
48844
|
const hostRoot = env[CLAUDE_PLUGIN_ROOT_ENV];
|
|
48731
48845
|
if (ownReal !== null && hostRoot !== void 0 && hostRoot !== "" && realOrNull(hostRoot) === ownReal) return { root: ownReal };
|
|
48732
|
-
const record6 = readOrNull(
|
|
48846
|
+
const record6 = readOrNull(join10(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE));
|
|
48733
48847
|
const recorded = record6 === null ? [] : recordedInstalls(record6);
|
|
48734
48848
|
if (recorded.length === 0) return { record: false };
|
|
48735
48849
|
const live = recorded.filter((r) => existsSync7(r.installPath));
|
|
@@ -48752,18 +48866,18 @@ function marketplaceChoice(env, worktree) {
|
|
|
48752
48866
|
}
|
|
48753
48867
|
function marketplaceRoot(adapter, env, worktree) {
|
|
48754
48868
|
const claudeDir = claudeDirOf(env, requireHomeDir(env));
|
|
48755
|
-
const plugins =
|
|
48756
|
-
const cache =
|
|
48869
|
+
const plugins = join10(claudeDir, HOST_PLUGINS_DIR_NAME);
|
|
48870
|
+
const cache = join10(plugins, PLUGIN_CACHE_DIR_NAME);
|
|
48757
48871
|
const script = process.argv[1];
|
|
48758
48872
|
const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname6(script));
|
|
48759
48873
|
const choice = marketplaceChoice(env, worktree);
|
|
48760
48874
|
if ("root" in choice) return choice.root;
|
|
48761
48875
|
if ("installs" in choice) throw missing(adapter.id, choice.installs.map((r) => r.installPath).join(", "));
|
|
48762
48876
|
const cacheReal = realOrNull(cache);
|
|
48763
|
-
if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep2) && existsSync7(
|
|
48764
|
-
const pattern =
|
|
48877
|
+
if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep2) && existsSync7(join10(ownReal, SERVER_ENTRY_FILE))) return ownReal;
|
|
48878
|
+
const pattern = join10(cache, "*", PLUGIN_NAME);
|
|
48765
48879
|
if (!existsSync7(cache)) throw missing(adapter.id, pattern);
|
|
48766
|
-
const found = readdirSync5(cache).sort().map((marketplace) =>
|
|
48880
|
+
const found = readdirSync5(cache).sort().map((marketplace) => join10(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync7(dir));
|
|
48767
48881
|
if (found.length !== 1) throw missing(adapter.id, found.length === 0 ? pattern : found.join(", "));
|
|
48768
48882
|
return found[0];
|
|
48769
48883
|
}
|
|
@@ -48788,9 +48902,9 @@ function candidate(adapter, env, worktree) {
|
|
|
48788
48902
|
case "hooks+mcp":
|
|
48789
48903
|
return configEntryRoot(adapter, env);
|
|
48790
48904
|
case "extension":
|
|
48791
|
-
return
|
|
48905
|
+
return join10(adapter.id === "gemini" ? geminiDirOf(env, requireHomeDir(env)) : join10(requireHomeDir(env), ...AGENT_HOME_DIR[adapter.id]), EXTENSIONS_DIR_NAME, PLUGIN_NAME);
|
|
48792
48906
|
case "plugin":
|
|
48793
|
-
return
|
|
48907
|
+
return join10(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
|
|
48794
48908
|
case "in-process":
|
|
48795
48909
|
return dirname6(fileURLToPath2(import.meta.url));
|
|
48796
48910
|
}
|
|
@@ -48950,11 +49064,11 @@ function ownHooks(block, shape, timeoutKey, native, agent) {
|
|
|
48950
49064
|
var validTimeout = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
48951
49065
|
function mcpFile(row5, home, env) {
|
|
48952
49066
|
const spec = OWN_MCP_ENTRY[row5.id];
|
|
48953
|
-
if (row5.id === "codex") return
|
|
49067
|
+
if (row5.id === "codex") return join11(codexDirOf(env, home), CONFIG_TOML_FILE);
|
|
48954
49068
|
if (spec !== void 0) return ownMcpFileOf(row5.id, spec.file, env, home);
|
|
48955
|
-
if (row5.id === "opencode") return
|
|
49069
|
+
if (row5.id === "opencode") return join11(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
|
|
48956
49070
|
if (row5.id === "pi") {
|
|
48957
|
-
return
|
|
49071
|
+
return join11(piAgentDirOf(env, home), SETTINGS_FILE);
|
|
48958
49072
|
}
|
|
48959
49073
|
return null;
|
|
48960
49074
|
}
|
|
@@ -48967,27 +49081,27 @@ function codexNativeDir(env, home) {
|
|
|
48967
49081
|
const codexDir = codexDirOf(env, home);
|
|
48968
49082
|
let enabled;
|
|
48969
49083
|
try {
|
|
48970
|
-
enabled = hostConfigValueAt(readParsed("codex",
|
|
49084
|
+
enabled = hostConfigValueAt(readParsed("codex", join11(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
|
|
48971
49085
|
} catch {
|
|
48972
49086
|
return null;
|
|
48973
49087
|
}
|
|
48974
49088
|
if (enabled !== true) return null;
|
|
48975
|
-
const cache =
|
|
49089
|
+
const cache = join11(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
|
|
48976
49090
|
if (!existsSync9(cache)) return null;
|
|
48977
49091
|
const found = [];
|
|
48978
49092
|
for (const market of readdirSync6(cache)) {
|
|
48979
|
-
const plugin =
|
|
49093
|
+
const plugin = join11(cache, market, SERVER_KEY);
|
|
48980
49094
|
if (!existsSync9(plugin)) continue;
|
|
48981
49095
|
for (const version4 of readdirSync6(plugin).sort()) {
|
|
48982
|
-
const dir =
|
|
48983
|
-
if (existsSync9(
|
|
49096
|
+
const dir = join11(plugin, version4, CODEX_PLUGIN_SUBDIR);
|
|
49097
|
+
if (existsSync9(join11(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
|
|
48984
49098
|
}
|
|
48985
49099
|
}
|
|
48986
49100
|
return found.length === 0 ? null : found[found.length - 1];
|
|
48987
49101
|
}
|
|
48988
49102
|
function nativeMcpWrong(dir, row5) {
|
|
48989
49103
|
try {
|
|
48990
|
-
const entry = hostConfigValueAt(readParsed(row5.id,
|
|
49104
|
+
const entry = hostConfigValueAt(readParsed(row5.id, join11(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
|
|
48991
49105
|
if (!isObject4(entry)) return true;
|
|
48992
49106
|
const args = list(entry[MCP_ARGS_FIELD]);
|
|
48993
49107
|
const script = args[0];
|
|
@@ -49002,10 +49116,19 @@ function isOwnOpencodeEntry(entry, key, own4) {
|
|
|
49002
49116
|
if (spec === OPENCODE_GIT_SPEC || spec.startsWith(OPENCODE_NPM_SPEC_PREFIX) || own4.includes(spec)) return true;
|
|
49003
49117
|
return key === OPENCODE_PLUGINS_KEY && spec === SERVER_KEY;
|
|
49004
49118
|
}
|
|
49119
|
+
function opencodeMcpOwn(entry) {
|
|
49120
|
+
if (!isObject4(entry)) return false;
|
|
49121
|
+
const cmd = Array.isArray(entry[OPENCODE_MCP_COMMAND_FIELD]) ? entry[OPENCODE_MCP_COMMAND_FIELD] : [entry[MCP_COMMAND_FIELD], ...list(entry[MCP_ARGS_FIELD])];
|
|
49122
|
+
const [node3, script, flag, agent] = cmd;
|
|
49123
|
+
return isNodeCommand(node3) && typeof script === "string" && lastSegment(script) === SERVER_ENTRY_FILE && flag === AGENT_ARG && agent === "opencode";
|
|
49124
|
+
}
|
|
49005
49125
|
function opencodeListed(file2) {
|
|
49006
49126
|
const { value } = readParsed("opencode", file2);
|
|
49007
|
-
const
|
|
49008
|
-
|
|
49127
|
+
const bundle = opencodePluginFile();
|
|
49128
|
+
const own4 = [bundle, join11(bundle, ...OPENCODE_PLUGIN_PATH)];
|
|
49129
|
+
if ([OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own4)))) return true;
|
|
49130
|
+
const mcp = isObject4(value) && isObject4(value.mcp) ? value.mcp : {};
|
|
49131
|
+
return opencodeMcpOwn(mcp[SERVER_KEY]) || isObject4(mcp.servers) && opencodeMcpOwn(mcp.servers[SERVER_KEY]);
|
|
49009
49132
|
}
|
|
49010
49133
|
function mcpWrong(row5, home, env, worktree) {
|
|
49011
49134
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
@@ -49026,7 +49149,7 @@ function mcpWrong(row5, home, env, worktree) {
|
|
|
49026
49149
|
function hookFile(row5, spec, home, env, worktree) {
|
|
49027
49150
|
const root = spec.root === "plugin" ? resolvePluginRoot(row5, env, worktree) : spec.root === "home" ? home : worktree;
|
|
49028
49151
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
49029
|
-
const file2 = native !== null ?
|
|
49152
|
+
const file2 = native !== null ? join11(native, CODEX_PLUGIN_HOOKS_FILE) : row5.id === "codex" ? join11(codexDirOf(env, home), HOOKS_JSON_FILE) : row5.id === "copilot-cli" ? join11(copilotDirOf(env, home), ...spec.file.slice(1)) : row5.id === "kiro" ? join11(kiroDirOf(env, home), ...spec.file.slice(1)) : join11(root, ...spec.file);
|
|
49030
49153
|
return file2;
|
|
49031
49154
|
}
|
|
49032
49155
|
function hookParts(row5, home, env, worktree) {
|
|
@@ -49037,7 +49160,7 @@ function hookParts(row5, home, env, worktree) {
|
|
|
49037
49160
|
const file2 = hookFile(row5, spec, home, env, worktree);
|
|
49038
49161
|
block = hostConfigValueAt(readParsed(row5.id, file2).value, spec.key);
|
|
49039
49162
|
if (row5.id === "codex") {
|
|
49040
|
-
const config4 = readParsed(row5.id,
|
|
49163
|
+
const config4 = readParsed(row5.id, join11(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
|
|
49041
49164
|
if (hostConfigValueAt(config4, CODEX_FEATURES_HOOKS_KEY) === false) return [PART_HOOKS];
|
|
49042
49165
|
}
|
|
49043
49166
|
} catch {
|
|
@@ -49081,7 +49204,7 @@ function checkHostConfig(row5, env, worktree) {
|
|
|
49081
49204
|
function checkPiInstall(env, home, worktree) {
|
|
49082
49205
|
const found = piInstalledIn(env, home, ownBundleDir(), worktree);
|
|
49083
49206
|
if (found !== void 0) return { ...pass("D3"), detail: found };
|
|
49084
|
-
return fail("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN +
|
|
49207
|
+
return fail("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + join11(piAgentDirOf(env, home), SETTINGS_FILE), NATIVE_INSTALL.pi[0]);
|
|
49085
49208
|
}
|
|
49086
49209
|
function checkV1Leftovers(agent, home, scope = {}) {
|
|
49087
49210
|
const findings = detectV1(agent, home, scope);
|
|
@@ -49100,10 +49223,10 @@ function parsedOrNull(agent, file2, jsonc) {
|
|
|
49100
49223
|
}
|
|
49101
49224
|
function checkDoubleFire(agent, worktree) {
|
|
49102
49225
|
if (agent !== "claude-code" && agent !== "vscode") return pass("D5b");
|
|
49103
|
-
const claude = parsedOrNull(agent,
|
|
49226
|
+
const claude = parsedOrNull(agent, join11(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
|
|
49104
49227
|
const hooks = isObject4(claude) ? claude[HOOKS_KEY] : void 0;
|
|
49105
49228
|
const hooksOn = isObject4(hooks) && Object.keys(hooks).length > 0;
|
|
49106
|
-
const vscode = parsedOrNull(agent,
|
|
49229
|
+
const vscode = parsedOrNull(agent, join11(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
|
|
49107
49230
|
const useClaudeHooks = isObject4(vscode) && vscode[VSCODE_CLAUDE_HOOKS_SETTING] === true;
|
|
49108
49231
|
return hooksOn && useClaudeHooks ? fail("D5b", D5B_DETAIL, D5B_FIX) : pass("D5b");
|
|
49109
49232
|
}
|
|
@@ -49114,7 +49237,7 @@ function configPaths(row5, env, worktree) {
|
|
|
49114
49237
|
const mcp = mcpFile(row5, home, env);
|
|
49115
49238
|
if (mcp !== null) out.push({ label: "MCP entry", path: mcp });
|
|
49116
49239
|
const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
|
|
49117
|
-
if (native !== null) out.push({ label: "Codex plugin MCP", path:
|
|
49240
|
+
if (native !== null) out.push({ label: "Codex plugin MCP", path: join11(native, CODEX_PLUGIN_MCP_FILE) });
|
|
49118
49241
|
const spec = HOOK_HOST_FILE[row5.id];
|
|
49119
49242
|
if (spec !== null) {
|
|
49120
49243
|
try {
|
|
@@ -49154,7 +49277,7 @@ async function loadSqlite2() {
|
|
|
49154
49277
|
}
|
|
49155
49278
|
}
|
|
49156
49279
|
function openRead(sqlite, path8) {
|
|
49157
|
-
return
|
|
49280
|
+
return openReadOnlyHandle(sqlite, path8);
|
|
49158
49281
|
}
|
|
49159
49282
|
var cell = (row5) => Object.values(row5)[0];
|
|
49160
49283
|
function readSchema(raw) {
|
|
@@ -49228,7 +49351,7 @@ async function checkIndex(project) {
|
|
|
49228
49351
|
|
|
49229
49352
|
// src/core/ops/doctor-env.ts
|
|
49230
49353
|
import { existsSync as existsSync11, readFileSync as readFileSync8, realpathSync as realpathSync6 } from "node:fs";
|
|
49231
|
-
import { isAbsolute as isAbsolute2, join as
|
|
49354
|
+
import { isAbsolute as isAbsolute2, join as join12, relative as relative2 } from "node:path";
|
|
49232
49355
|
function pass3(id, detail = DOCTOR_PASS_DETAIL) {
|
|
49233
49356
|
return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
|
|
49234
49357
|
}
|
|
@@ -49240,7 +49363,7 @@ function fail3(id, detail, fixCommand) {
|
|
|
49240
49363
|
}
|
|
49241
49364
|
function bundleVersion(bundleDir2) {
|
|
49242
49365
|
try {
|
|
49243
|
-
const v = JSON.parse(readFileSync8(
|
|
49366
|
+
const v = JSON.parse(readFileSync8(join12(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
|
|
49244
49367
|
return typeof v === "string" && v !== "" ? v : void 0;
|
|
49245
49368
|
} catch {
|
|
49246
49369
|
return void 0;
|
|
@@ -49335,12 +49458,12 @@ async function checkVersion(i) {
|
|
|
49335
49458
|
const head = D1_PREFIX(i.version, i.bundleSha) + ": ";
|
|
49336
49459
|
if (i.version === void 0) return unknown5("D1", head + D1_LATEST_UNKNOWN + ", " + D1_NO_VERSION, D1_NPM_CHECK_FIX);
|
|
49337
49460
|
const tag = channelOf(i.version);
|
|
49338
|
-
const
|
|
49461
|
+
const git2 = findRuntime(GIT_BIN, i.env);
|
|
49339
49462
|
const npm = await npmLatest(i.registryUrl, tag, i.signal, i.timeoutMs);
|
|
49340
49463
|
if (npm.ok) return versionRow(head, i.version, tag, D1_SOURCE_NPM, npm.version, "");
|
|
49341
49464
|
let cause = D1_GIT_MISSING;
|
|
49342
|
-
if (
|
|
49343
|
-
const r = await runProcess([
|
|
49465
|
+
if (git2 !== null) {
|
|
49466
|
+
const r = await runProcess([git2, GIT_LS_REMOTE, ...GIT_LS_REMOTE_TAG_ARGS, RELEASE_REPO_URL, RELEASE_TAG_PATTERN], {
|
|
49344
49467
|
cwd: i.cwd,
|
|
49345
49468
|
env: { ...i.env, ...GIT_NO_PROMPT_ENV },
|
|
49346
49469
|
signal: i.signal,
|
|
@@ -49354,7 +49477,7 @@ async function checkVersion(i) {
|
|
|
49354
49477
|
cause = gitCause(r, i.timeoutMs);
|
|
49355
49478
|
}
|
|
49356
49479
|
}
|
|
49357
|
-
return unknown5("D1", head + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause,
|
|
49480
|
+
return unknown5("D1", head + D1_LATEST_UNKNOWN + ", " + npm.cause + D1_CAUSE_JOIN + cause, git2 === null ? D1_NPM_CHECK_FIX : D1_GIT_CHECK_FIX);
|
|
49358
49481
|
}
|
|
49359
49482
|
function numbers(v) {
|
|
49360
49483
|
const bare2 = v.startsWith(NODE_VERSION_PREFIX) ? v.slice(NODE_VERSION_PREFIX.length) : v;
|
|
@@ -49391,7 +49514,7 @@ function checkMcp(ctx) {
|
|
|
49391
49514
|
}
|
|
49392
49515
|
function piCwdInside(worktree, piCwd) {
|
|
49393
49516
|
if (piCwd === void 0 || !existsSync11(piCwd)) return false;
|
|
49394
|
-
const rel =
|
|
49517
|
+
const rel = relative2(worktree, realpathSync6.native(piCwd));
|
|
49395
49518
|
return rel === "" || !rel.startsWith("..") && !isAbsolute2(rel);
|
|
49396
49519
|
}
|
|
49397
49520
|
function checkProject(i) {
|
|
@@ -49415,6 +49538,15 @@ import { existsSync as existsSync13, mkdtempSync, readFileSync as readFileSync9,
|
|
|
49415
49538
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
49416
49539
|
import path7 from "node:path";
|
|
49417
49540
|
|
|
49541
|
+
// src/core/sandbox/host-node.ts
|
|
49542
|
+
var BUN_BE_BUN_ENV = "BUN_BE_BUN";
|
|
49543
|
+
function nodeLaunch(env, host = { bun: process.versions.bun, execPath: process.execPath }, find2 = findRuntime) {
|
|
49544
|
+
if (host.bun === void 0) return { file: host.execPath, env };
|
|
49545
|
+
const node3 = find2("javascript", env);
|
|
49546
|
+
if (node3 !== null) return { file: node3, env };
|
|
49547
|
+
return { file: host.execPath, env: { ...env, [BUN_BE_BUN_ENV]: "1" } };
|
|
49548
|
+
}
|
|
49549
|
+
|
|
49418
49550
|
// src/setup/codex-trust.ts
|
|
49419
49551
|
import { createHash } from "node:crypto";
|
|
49420
49552
|
import { existsSync as existsSync12, realpathSync as realpathSync7 } from "node:fs";
|
|
@@ -49621,8 +49753,8 @@ function untrustedPluginHooksDetail(hooks) {
|
|
|
49621
49753
|
if (!bad.length) return void 0;
|
|
49622
49754
|
const counts = /* @__PURE__ */ new Map();
|
|
49623
49755
|
for (const h of bad) counts.set(h.status, (counts.get(h.status) ?? 0) + 1);
|
|
49624
|
-
const
|
|
49625
|
-
const state =
|
|
49756
|
+
const words2 = [...counts].sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : 1));
|
|
49757
|
+
const state = words2.length === 1 ? words2[0][0] : `${words2.map(([w]) => w).join(" or ")} (${words2.map(([w, n]) => `${n} ${w}`).join(", ")})`;
|
|
49626
49758
|
return `codex lists ${bad.length} of ${hooks.length} context-mode plugin hooks ${state}, so they do not run; ${CODEX_UNTRUSTED_FIX}`;
|
|
49627
49759
|
}
|
|
49628
49760
|
|
|
@@ -49734,9 +49866,10 @@ function isReadShape(stdout) {
|
|
|
49734
49866
|
async function readProbe(i, timeoutMs, ranged) {
|
|
49735
49867
|
const home = mkdtempSync(path7.join(tmpdir2(), "cm-d5-read-"));
|
|
49736
49868
|
try {
|
|
49737
|
-
const
|
|
49869
|
+
const node3 = nodeLaunch({ ...i.env, HOME: home, USERPROFILE: home });
|
|
49870
|
+
const r = await runProcess([node3.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
49738
49871
|
cwd: i.bundleDir,
|
|
49739
|
-
env:
|
|
49872
|
+
env: node3.env,
|
|
49740
49873
|
signal: i.signal,
|
|
49741
49874
|
timeoutMs,
|
|
49742
49875
|
stdin: JSON.stringify(readProbePayload(i.worktree ?? home, ranged))
|
|
@@ -49806,7 +49939,8 @@ async function checkHookRoundTrip(i) {
|
|
|
49806
49939
|
const timeoutMs = i.timeoutMs ?? HOOK_TIMEOUT_MS;
|
|
49807
49940
|
const bareMs = i.bareMs ?? (async () => {
|
|
49808
49941
|
const t = performance.now();
|
|
49809
|
-
|
|
49942
|
+
const node3 = nodeLaunch(i.env);
|
|
49943
|
+
await runProcess([node3.file, "-e", ""], { cwd: i.bundleDir, env: node3.env, signal: i.signal, timeoutMs });
|
|
49810
49944
|
return performance.now() - t;
|
|
49811
49945
|
});
|
|
49812
49946
|
const hookWalls = [];
|
|
@@ -49814,9 +49948,10 @@ async function checkHookRoundTrip(i) {
|
|
|
49814
49948
|
let ms = 0;
|
|
49815
49949
|
for (let n = 1; n <= maxPairs; n++) {
|
|
49816
49950
|
const start = now();
|
|
49817
|
-
const
|
|
49951
|
+
const node3 = nodeLaunch(i.env);
|
|
49952
|
+
const r = await runProcess([node3.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
|
|
49818
49953
|
cwd: i.bundleDir,
|
|
49819
|
-
env:
|
|
49954
|
+
env: node3.env,
|
|
49820
49955
|
signal: i.signal,
|
|
49821
49956
|
timeoutMs,
|
|
49822
49957
|
stdin: JSON.stringify(payloadFor(i.agent, fixture.payload, i.worktree))
|
|
@@ -49834,14 +49969,16 @@ async function checkHookRoundTrip(i) {
|
|
|
49834
49969
|
}
|
|
49835
49970
|
|
|
49836
49971
|
// src/core/hooks/fallback.ts
|
|
49837
|
-
import { join as
|
|
49972
|
+
import { join as join13, resolve as resolve3 } from "node:path";
|
|
49838
49973
|
var fs = process.getBuiltinModule("node:fs");
|
|
49839
49974
|
function homeOf(env) {
|
|
49840
49975
|
return env.HOME ?? env.USERPROFILE ?? "";
|
|
49841
49976
|
}
|
|
49842
49977
|
function hookLogPath(env) {
|
|
49978
|
+
const dir = env[DATA_DIR_ENV];
|
|
49979
|
+
if (dir !== void 0 && dir !== "") return join13(dataRootOf(env, ""), HOOK_ERROR_LOG_FILE);
|
|
49843
49980
|
const home = homeOf(env);
|
|
49844
|
-
return home === "" ? "" :
|
|
49981
|
+
return home === "" ? "" : join13(dataRootOf(env, home), HOOK_ERROR_LOG_FILE);
|
|
49845
49982
|
}
|
|
49846
49983
|
function lastHookError(env) {
|
|
49847
49984
|
try {
|
|
@@ -49872,7 +50009,7 @@ function lastHookError(env) {
|
|
|
49872
50009
|
|
|
49873
50010
|
// src/core/ops/db-heal.ts
|
|
49874
50011
|
import { existsSync as existsSync14, mkdirSync as mkdirSync5, rmSync as rmSync5 } from "node:fs";
|
|
49875
|
-
import { basename as basename4, dirname as dirname7, join as
|
|
50012
|
+
import { basename as basename4, dirname as dirname7, join as join14 } from "node:path";
|
|
49876
50013
|
function integrityOk2(rows) {
|
|
49877
50014
|
return rows.length === 1 && rows[0].integrity_check === INTEGRITY_OK;
|
|
49878
50015
|
}
|
|
@@ -49881,7 +50018,7 @@ async function healLossless(dbPath) {
|
|
|
49881
50018
|
const tmp = dbPath + HEAL_TMP_SUFFIX;
|
|
49882
50019
|
rmSync5(tmp, { force: true });
|
|
49883
50020
|
try {
|
|
49884
|
-
const src =
|
|
50021
|
+
const src = openReadOnlyHandle({ DatabaseSync }, dbPath, { queryOnly: false });
|
|
49885
50022
|
try {
|
|
49886
50023
|
src.prepare("VACUUM INTO ?").run(tmp);
|
|
49887
50024
|
} finally {
|
|
@@ -49929,7 +50066,7 @@ function utcStamp(now) {
|
|
|
49929
50066
|
return now.toISOString().slice(0, 19).replaceAll("-", "").replaceAll(":", "") + "Z";
|
|
49930
50067
|
}
|
|
49931
50068
|
function makeOrphanDir(projectDir) {
|
|
49932
|
-
const base =
|
|
50069
|
+
const base = join14(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
|
|
49933
50070
|
for (let n = 1; ; n += 1) {
|
|
49934
50071
|
const dir = n === 1 ? base : base + "-" + String(n);
|
|
49935
50072
|
try {
|
|
@@ -49946,7 +50083,7 @@ async function healOrphan(project, files, row5) {
|
|
|
49946
50083
|
try {
|
|
49947
50084
|
dir = makeOrphanDir(dirname7(project.dbPath));
|
|
49948
50085
|
for (const f of files) {
|
|
49949
|
-
const to =
|
|
50086
|
+
const to = join14(dir, basename4(f.path));
|
|
49950
50087
|
renameWithRetry(f.path, to);
|
|
49951
50088
|
moved.push({ path: to, bytes: f.bytes });
|
|
49952
50089
|
}
|
|
@@ -50014,7 +50151,7 @@ function buildReportHead(input) {
|
|
|
50014
50151
|
// src/core/ops/doctor-issue.ts
|
|
50015
50152
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
50016
50153
|
import { closeSync, existsSync as existsSync15, fstatSync, mkdirSync as mkdirSync6, openSync, readFileSync as readFileSync10, readSync, realpathSync as realpathSync9, writeFileSync as writeFileSync3 } from "node:fs";
|
|
50017
|
-
import { delimiter, join as
|
|
50154
|
+
import { delimiter, join as join15 } from "node:path";
|
|
50018
50155
|
var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
|
|
50019
50156
|
function tildeOf(env) {
|
|
50020
50157
|
const home = homeDirOf(env);
|
|
@@ -50055,8 +50192,8 @@ function onPath(env, tool) {
|
|
|
50055
50192
|
const out = [];
|
|
50056
50193
|
for (const dir of (env.PATH ?? env.Path ?? "").split(delimiter)) {
|
|
50057
50194
|
if (dir === "") continue;
|
|
50058
|
-
for (const n of names) if (existsSync15(
|
|
50059
|
-
out.push(
|
|
50195
|
+
for (const n of names) if (existsSync15(join15(dir, n))) {
|
|
50196
|
+
out.push(join15(dir, n));
|
|
50060
50197
|
break;
|
|
50061
50198
|
}
|
|
50062
50199
|
}
|
|
@@ -50102,8 +50239,8 @@ function agentConfig(adapter, env, worktree) {
|
|
|
50102
50239
|
const home = homeDirOf(env);
|
|
50103
50240
|
const files = configPaths(adapter, env, worktree);
|
|
50104
50241
|
if (home !== null) {
|
|
50105
|
-
if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path:
|
|
50106
|
-
if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path:
|
|
50242
|
+
if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join15(claudeDirOf(env, home), SETTINGS_FILE) });
|
|
50243
|
+
if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join15(codexDirOf(env, home), CONFIG_TOML_FILE) });
|
|
50107
50244
|
}
|
|
50108
50245
|
const out = [];
|
|
50109
50246
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -50186,9 +50323,9 @@ async function buildIssueBody(i) {
|
|
|
50186
50323
|
async function writeIssueReport(i) {
|
|
50187
50324
|
const tilde = tildeOf(i.env);
|
|
50188
50325
|
const body = await buildIssueBody(i);
|
|
50189
|
-
const dir =
|
|
50326
|
+
const dir = join15(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
|
|
50190
50327
|
mkdirSync6(dir, { recursive: true });
|
|
50191
|
-
const file2 =
|
|
50328
|
+
const file2 = join15(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
|
|
50192
50329
|
writeFileSync3(file2, body);
|
|
50193
50330
|
const shown2 = tilde(file2);
|
|
50194
50331
|
const title = issueTitle(i.adapter.id, i.rows);
|
|
@@ -50264,11 +50401,11 @@ async function hookRow(ctx, adapter, host) {
|
|
|
50264
50401
|
}
|
|
50265
50402
|
}
|
|
50266
50403
|
function ownServerId(configDir, projectKey) {
|
|
50267
|
-
const dir =
|
|
50404
|
+
const dir = join16(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
50268
50405
|
if (!existsSync16(dir)) return "";
|
|
50269
50406
|
for (const name of readdirSync7(dir)) {
|
|
50270
50407
|
if (!name.endsWith(OWNER_PID_EXT)) continue;
|
|
50271
|
-
if (readFileSync11(
|
|
50408
|
+
if (readFileSync11(join16(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
|
|
50272
50409
|
}
|
|
50273
50410
|
return "";
|
|
50274
50411
|
}
|
|
@@ -50282,7 +50419,7 @@ async function runDoctorChecks(ctx, adapter, host0) {
|
|
|
50282
50419
|
D1: () => checkVersion({ bundleSha: BUNDLE_SHA, version: bundleVersion(host.bundleDir), registryUrl: D1_REGISTRY_URL, timeoutMs: DOCTOR_GIT_TIMEOUT_MS, env: buildChildEnv(env), cwd: project.worktree, signal: ctx.signal }),
|
|
50283
50420
|
D2: () => checkNode({ nodeVersion: process.version, bunVersion: process.versions.bun }),
|
|
50284
50421
|
D3: () => checkHostConfig(adapter, env, project.worktree),
|
|
50285
|
-
D4: () => checkV1Leftovers(adapter.id, requireHomeDir(env), { project: project.worktree, piAgentDir: piAgentDirOf(env, requireHomeDir(env)), claudeDir: claudeDirOf(env, requireHomeDir(env)), codexDir: codexDirOf(env, requireHomeDir(env)), copilotDir: copilotDirOf(env, requireHomeDir(env)), kiroDir: kiroDirOf(env, requireHomeDir(env)), opencodeDir: opencodeDirOf(env, requireHomeDir(env)) }),
|
|
50422
|
+
D4: () => checkV1Leftovers(adapter.id, requireHomeDir(env), { project: project.worktree, piAgentDir: piAgentDirOf(env, requireHomeDir(env)), claudeDir: claudeDirOf(env, requireHomeDir(env)), codexDir: codexDirOf(env, requireHomeDir(env)), geminiDir: geminiDirOf(env, requireHomeDir(env)), copilotDir: copilotDirOf(env, requireHomeDir(env)), kiroDir: kiroDirOf(env, requireHomeDir(env)), opencodeDir: opencodeDirOf(env, requireHomeDir(env)) }),
|
|
50286
50423
|
D5: () => hookRow(ctx, adapter, host),
|
|
50287
50424
|
D5b: () => checkDoubleFire(adapter.id, project.worktree),
|
|
50288
50425
|
D6: () => checkMcp(ctx),
|
|
@@ -50323,13 +50460,13 @@ function reportEnv(env) {
|
|
|
50323
50460
|
async function doctorReply(ctx, host) {
|
|
50324
50461
|
const adapter = getAdapter(ctx.project.agent);
|
|
50325
50462
|
const rows = await runDoctorChecks(ctx, adapter, host);
|
|
50326
|
-
const
|
|
50327
|
-
const command = adapter.id === "pi" ?
|
|
50463
|
+
const failed = rows.some((r) => r.status === "FAIL");
|
|
50464
|
+
const command = adapter.id === "pi" ? failed ? NATIVE_INSTALL.pi[0] : PI_LIST_COMMAND : `context-mode ${failed ? "setup" : "doctor"} --agents ${adapter.id}`;
|
|
50328
50465
|
const input = { agent: adapter.id, rows, env: reportEnv(host.env), command };
|
|
50329
50466
|
const envLine2 = environmentLine(ctx, adapter, host.env, bundleVersion(host.bundleDir));
|
|
50330
50467
|
const table3 = buildReport(input);
|
|
50331
50468
|
let notes = [];
|
|
50332
|
-
if (
|
|
50469
|
+
if (failed) {
|
|
50333
50470
|
try {
|
|
50334
50471
|
notes = await writeIssueReport({ ctx, adapter, env: host.env, bundleDir: host.bundleDir, rows, envLine: envLine2, table: table3 });
|
|
50335
50472
|
} catch (err) {
|
|
@@ -50365,7 +50502,7 @@ var ctxDoctor = Object.freeze({
|
|
|
50365
50502
|
// src/core/tools/execute.ts
|
|
50366
50503
|
import { existsSync as existsSync17, mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync4 } from "node:fs";
|
|
50367
50504
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
50368
|
-
import { dirname as dirname9, join as
|
|
50505
|
+
import { dirname as dirname9, join as join17, parse as parse5, resolve as resolve4 } from "node:path";
|
|
50369
50506
|
|
|
50370
50507
|
// src/core/index/select.ts
|
|
50371
50508
|
var READ_CHUNKS = "SELECT ord, body FROM chunks WHERE source_id = ?";
|
|
@@ -50450,7 +50587,6 @@ var ctxExecuteSchema = external_exports.object({
|
|
|
50450
50587
|
background: external_exports.boolean().optional(),
|
|
50451
50588
|
summary: external_exports.boolean().optional()
|
|
50452
50589
|
}, { error: unknownField }).strict();
|
|
50453
|
-
var SHELL_FAMILY = Object.freeze(["sh", "bash", "zsh", "dash", "ksh", "fish"]);
|
|
50454
50590
|
var SCRIPT_EXT = Object.freeze({
|
|
50455
50591
|
javascript: ".js",
|
|
50456
50592
|
typescript: ".ts",
|
|
@@ -50469,7 +50605,7 @@ var LAUNCHER = [
|
|
|
50469
50605
|
'const { rmSync } = require("node:fs");',
|
|
50470
50606
|
"const [mode, dir, ...argv] = process.argv.slice(1);",
|
|
50471
50607
|
'if (mode === "start") {',
|
|
50472
|
-
' const b = spawn(process.execPath, [...process.execArgv, "--", "run", dir, ...argv], { detached: true, stdio: "ignore", windowsHide: true });',
|
|
50608
|
+
' const b = spawn(process.execPath, [...process.execArgv.filter((a) => a !== "--"), "--", "run", dir, ...argv], { detached: true, stdio: "ignore", windowsHide: true });',
|
|
50473
50609
|
" b.unref();",
|
|
50474
50610
|
" process.stdout.write(String(b.pid));",
|
|
50475
50611
|
"} else {",
|
|
@@ -50569,13 +50705,14 @@ async function handler3(raw, ctx) {
|
|
|
50569
50705
|
if (takesDashC(input.language, runtime)) {
|
|
50570
50706
|
argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
|
|
50571
50707
|
} else {
|
|
50572
|
-
tmpDir = mkdtempSync2(
|
|
50573
|
-
const file2 =
|
|
50708
|
+
tmpDir = mkdtempSync2(join17(tmpdir3(), TMP_PREFIX));
|
|
50709
|
+
const file2 = join17(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
|
|
50574
50710
|
writeFileSync4(file2, scriptText(input.language, input.code), "utf8");
|
|
50575
50711
|
argv = scriptArgv(input.language, runtime, file2);
|
|
50576
50712
|
}
|
|
50577
50713
|
if (input.background === true) {
|
|
50578
|
-
const
|
|
50714
|
+
const node3 = nodeLaunch(env);
|
|
50715
|
+
const r2 = await runProcess([node3.file, "-e", LAUNCHER, "--", "start", tmpDir ?? "", ...argv], { cwd, env: node3.env, signal: ctx.signal, timeoutMs });
|
|
50579
50716
|
const pid = r2.stdout.toString("utf8");
|
|
50580
50717
|
if (r2.exitCode !== 0 || pid === "" || !Number.isSafeInteger(Number(pid))) return fail4(spawnFailed(argv[0], cwd), journal);
|
|
50581
50718
|
handedOff = true;
|
|
@@ -50606,11 +50743,11 @@ var ctxExecute = {
|
|
|
50606
50743
|
|
|
50607
50744
|
// src/core/tools/index.ts
|
|
50608
50745
|
import { existsSync as existsSync18, readFileSync as readFileSync13, statSync as statSync7 } from "node:fs";
|
|
50609
|
-
import { dirname as dirname10, extname, join as
|
|
50746
|
+
import { dirname as dirname10, extname, join as join19, relative as relative3, resolve as resolve5 } from "node:path";
|
|
50610
50747
|
|
|
50611
50748
|
// src/core/index/walk.ts
|
|
50612
50749
|
import { readdirSync as readdirSync8, readFileSync as readFileSync12, realpathSync as realpathSync10, statSync as statSync6 } from "node:fs";
|
|
50613
|
-
import { join as
|
|
50750
|
+
import { join as join18 } from "node:path";
|
|
50614
50751
|
var GITIGNORE = ".gitignore";
|
|
50615
50752
|
var GIT_DIR = ".git";
|
|
50616
50753
|
function walkDir(root, containmentRoot) {
|
|
@@ -50619,7 +50756,7 @@ function walkDir(root, containmentRoot) {
|
|
|
50619
50756
|
const found = [];
|
|
50620
50757
|
visit(real3, [], [], containmentRoot, /* @__PURE__ */ new Set([real3]), found);
|
|
50621
50758
|
found.sort(compareFound);
|
|
50622
|
-
return found.map((f) => ({ absPath: f.absPath, relPath:
|
|
50759
|
+
return found.map((f) => ({ absPath: f.absPath, relPath: join18(...f.dir, f.name) }));
|
|
50623
50760
|
}
|
|
50624
50761
|
function visit(abs, rel, parent, contain, seen, found) {
|
|
50625
50762
|
let entries;
|
|
@@ -50628,10 +50765,10 @@ function visit(abs, rel, parent, contain, seen, found) {
|
|
|
50628
50765
|
} catch {
|
|
50629
50766
|
return;
|
|
50630
50767
|
}
|
|
50631
|
-
const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(
|
|
50768
|
+
const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join18(abs, GITIGNORE), rel)) : parent;
|
|
50632
50769
|
for (const e of entries) {
|
|
50633
50770
|
if (e.name === GIT_DIR) continue;
|
|
50634
|
-
const path8 =
|
|
50771
|
+
const path8 = join18(abs, e.name);
|
|
50635
50772
|
let isDir = e.isDirectory();
|
|
50636
50773
|
let isFile = e.isFile();
|
|
50637
50774
|
let target = path8;
|
|
@@ -50765,11 +50902,24 @@ var PRIVATE_RANGES = [
|
|
|
50765
50902
|
["172.16.0.0", 12, "ipv4"],
|
|
50766
50903
|
["192.168.0.0", 16, "ipv4"],
|
|
50767
50904
|
["169.254.0.0", 16, "ipv4"],
|
|
50768
|
-
["0.0.0.0",
|
|
50905
|
+
["0.0.0.0", 8, "ipv4"],
|
|
50906
|
+
// D-SSRF-RANGES-1: "this network", not only 0.0.0.0
|
|
50907
|
+
["100.64.0.0", 10, "ipv4"],
|
|
50908
|
+
// D-SSRF-RANGES-1: shared address space (RFC 6598), cloud metadata lives here
|
|
50909
|
+
["198.18.0.0", 15, "ipv4"],
|
|
50910
|
+
// D-SSRF-RANGES-1: benchmark networks (RFC 2544)
|
|
50911
|
+
["240.0.0.0", 4, "ipv4"],
|
|
50912
|
+
// D-SSRF-RANGES-1: reserved and broadcast
|
|
50769
50913
|
["::1", 128, "ipv6"],
|
|
50770
50914
|
["::", 128, "ipv6"],
|
|
50915
|
+
["::", 96, "ipv6"],
|
|
50916
|
+
// D-SSRF-RANGES-1: IPv4-compatible (::a.b.c.d), deprecated, never a public origin
|
|
50917
|
+
["64:ff9b:1::", 48, "ipv6"],
|
|
50918
|
+
// D-SSRF-RANGES-1: local-use NAT64 (RFC 8215)
|
|
50771
50919
|
["fc00::", 7, "ipv6"],
|
|
50772
|
-
["fe80::", 10, "ipv6"]
|
|
50920
|
+
["fe80::", 10, "ipv6"],
|
|
50921
|
+
["fec0::", 10, "ipv6"]
|
|
50922
|
+
// D-SSRF-RANGES-1: site-local (RFC 3879)
|
|
50773
50923
|
];
|
|
50774
50924
|
var BLOCKED = new BlockList();
|
|
50775
50925
|
for (const [net, prefix, type] of PRIVATE_RANGES) BLOCKED.addSubnet(net, prefix, type);
|
|
@@ -50822,9 +50972,41 @@ function pickProxy(u) {
|
|
|
50822
50972
|
const auth = p.username === "" ? void 0 : "Basic " + Buffer.from(decodeURIComponent(p.username) + ":" + decodeURIComponent(p.password)).toString("base64");
|
|
50823
50973
|
return { url: p, auth };
|
|
50824
50974
|
}
|
|
50975
|
+
function ipv6Words(address) {
|
|
50976
|
+
const zone = address.indexOf("%");
|
|
50977
|
+
const a = zone < 0 ? address : address.slice(0, zone);
|
|
50978
|
+
const words2 = (part) => {
|
|
50979
|
+
if (part === "") return [];
|
|
50980
|
+
const out = [];
|
|
50981
|
+
for (const w of part.split(":")) {
|
|
50982
|
+
if (w.includes(".")) {
|
|
50983
|
+
const q = w.split(".").map(Number);
|
|
50984
|
+
out.push(q[0] * 256 + q[1], q[2] * 256 + q[3]);
|
|
50985
|
+
} else out.push(parseInt(w, 16));
|
|
50986
|
+
}
|
|
50987
|
+
return out;
|
|
50988
|
+
};
|
|
50989
|
+
const gap = a.indexOf("::");
|
|
50990
|
+
if (gap < 0) return words2(a);
|
|
50991
|
+
const head = words2(a.slice(0, gap));
|
|
50992
|
+
const tail = words2(a.slice(gap + 2));
|
|
50993
|
+
return [...head, ...new Array(8 - head.length - tail.length).fill(0), ...tail];
|
|
50994
|
+
}
|
|
50995
|
+
function dotted(hi, lo) {
|
|
50996
|
+
return [hi >> 8, hi & 255, lo >> 8, lo & 255].join(".");
|
|
50997
|
+
}
|
|
50998
|
+
function embeddedIpv4(address) {
|
|
50999
|
+
const w = ipv6Words(address);
|
|
51000
|
+
if (w[0] === 100 && w[1] === 65435 && w[2] === 0 && w[3] === 0 && w[4] === 0 && w[5] === 0) {
|
|
51001
|
+
return dotted(w[6], w[7]);
|
|
51002
|
+
}
|
|
51003
|
+
if (w[0] === 8194) return dotted(w[1], w[2]);
|
|
51004
|
+
return void 0;
|
|
51005
|
+
}
|
|
50825
51006
|
function checkAddress(hostname2, address) {
|
|
50826
51007
|
const family = isIP(address);
|
|
50827
|
-
|
|
51008
|
+
const inner = family === 6 ? embeddedIpv4(address) : void 0;
|
|
51009
|
+
if (family === 0 || BLOCKED.check(address, family === 4 ? "ipv4" : "ipv6") || inner !== void 0 && BLOCKED.check(inner, "ipv4")) {
|
|
50828
51010
|
throw new CtxError("SSRF", { host: hostname2 });
|
|
50829
51011
|
}
|
|
50830
51012
|
}
|
|
@@ -54150,11 +54332,11 @@ function compareDocumentPosition(nodeA, nodeB) {
|
|
|
54150
54332
|
function uniqueSort(nodes) {
|
|
54151
54333
|
nodes = nodes.filter((node3, index, array4) => !array4.includes(node3, index + 1));
|
|
54152
54334
|
nodes.sort((a, b) => {
|
|
54153
|
-
const
|
|
54154
|
-
if (
|
|
54335
|
+
const relative4 = compareDocumentPosition(a, b);
|
|
54336
|
+
if (relative4 & DocumentPosition.PRECEDING) {
|
|
54155
54337
|
return -1;
|
|
54156
54338
|
}
|
|
54157
|
-
if (
|
|
54339
|
+
if (relative4 & DocumentPosition.FOLLOWING) {
|
|
54158
54340
|
return 1;
|
|
54159
54341
|
}
|
|
54160
54342
|
return 0;
|
|
@@ -54723,10 +54905,10 @@ function htmlToReadable(html, baseUrl) {
|
|
|
54723
54905
|
const st = { w: new Writer(), base, sawH1: false };
|
|
54724
54906
|
for (const n of contentRoot(doc.children)) walk(st, n);
|
|
54725
54907
|
const body = st.w.result();
|
|
54726
|
-
const
|
|
54727
|
-
const text = !st.sawH1 && title !== "" &&
|
|
54728
|
-
const sparse =
|
|
54729
|
-
return { text: text === "" ? "" : text + "\n", title, words, sparse };
|
|
54908
|
+
const words2 = wordCount(body);
|
|
54909
|
+
const text = !st.sawH1 && title !== "" && words2 > 0 ? "# " + title + "\n\n" + body : body;
|
|
54910
|
+
const sparse = words2 < SPARSE_MAX_WORDS && html.length > SPARSE_RATIO * Math.max(text.length, 1);
|
|
54911
|
+
return { text: text === "" ? "" : text + "\n", title, words: words2, sparse };
|
|
54730
54912
|
}
|
|
54731
54913
|
|
|
54732
54914
|
// src/core/tools/index.ts
|
|
@@ -54768,11 +54950,11 @@ function missingOrOutside(given, abs, root) {
|
|
|
54768
54950
|
function pathItems(input, project) {
|
|
54769
54951
|
const abs = resolve5(project.worktree, input.path);
|
|
54770
54952
|
if (!isInside(project.containmentRoot, abs)) throw missingOrOutside(input.path, abs, project.containmentRoot);
|
|
54771
|
-
const base =
|
|
54953
|
+
const base = relative3(project.worktree, abs);
|
|
54772
54954
|
if (statSync7(abs).isDirectory()) {
|
|
54773
54955
|
return walkDir(abs, project.containmentRoot).map((f) => ({
|
|
54774
54956
|
sourceKind: "path",
|
|
54775
|
-
label: pathLabel(
|
|
54957
|
+
label: pathLabel(join19(base, f.relPath)),
|
|
54776
54958
|
kind: kindOfPath(f.relPath),
|
|
54777
54959
|
read: () => readUtf8(f.absPath)
|
|
54778
54960
|
}));
|
|
@@ -55061,7 +55243,7 @@ function pickUnits(cands, seen, budget) {
|
|
|
55061
55243
|
const pool = cands.filter((u) => !seen.has(unitKey(u)) && u.score >= RECALL_MIN_SCORE);
|
|
55062
55244
|
if (pool.length === 0) return [];
|
|
55063
55245
|
const top = Math.max(...pool.map((u) => u.score));
|
|
55064
|
-
const
|
|
55246
|
+
const words2 = pool.map((u) => wordsOf(u.body));
|
|
55065
55247
|
const taken = [];
|
|
55066
55248
|
const left = new Set(pool.map((_, i) => i));
|
|
55067
55249
|
let used = 0;
|
|
@@ -55070,7 +55252,7 @@ function pickUnits(cands, seen, budget) {
|
|
|
55070
55252
|
let bestVal = -Infinity;
|
|
55071
55253
|
for (const i of left) {
|
|
55072
55254
|
let sim = 0;
|
|
55073
|
-
for (const j of taken) sim = Math.max(sim, overlap(
|
|
55255
|
+
for (const j of taken) sim = Math.max(sim, overlap(words2[i], words2[j]));
|
|
55074
55256
|
const val = MMR_RELEVANCE_WEIGHT * (pool[i].score / top) - MMR_REDUNDANCY_WEIGHT * sim;
|
|
55075
55257
|
if (val > bestVal) {
|
|
55076
55258
|
bestVal = val;
|
|
@@ -55576,13 +55758,9 @@ var ctxStats = Object.freeze({
|
|
|
55576
55758
|
handler: handler7
|
|
55577
55759
|
});
|
|
55578
55760
|
|
|
55579
|
-
// src/core/tools/upgrade.ts
|
|
55580
|
-
import { existsSync as existsSync24, realpathSync as realpathSync11, rmSync as rmSync11 } from "node:fs";
|
|
55581
|
-
import { basename as basename7, dirname as dirname12, join as join24 } from "node:path";
|
|
55582
|
-
|
|
55583
55761
|
// src/core/ops/host-write.ts
|
|
55584
55762
|
import { copyFileSync, existsSync as existsSync19, mkdirSync as mkdirSync7, writeFileSync as writeFileSync5 } from "node:fs";
|
|
55585
|
-
import { dirname as dirname11, join as
|
|
55763
|
+
import { dirname as dirname11, join as join20 } from "node:path";
|
|
55586
55764
|
function defaultWrite(file2, text) {
|
|
55587
55765
|
writeFileSync5(file2, text, "utf8");
|
|
55588
55766
|
}
|
|
@@ -55591,14 +55769,17 @@ function hostConfigPath(agent, home, env) {
|
|
|
55591
55769
|
if (own4 !== void 0) return ownMcpFileOf(agent, own4.file, env, home);
|
|
55592
55770
|
switch (agent) {
|
|
55593
55771
|
case "opencode":
|
|
55594
|
-
return
|
|
55772
|
+
return join20(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
|
|
55595
55773
|
// D-WIN-OPENCODE-DIR-1
|
|
55596
55774
|
case "pi":
|
|
55597
|
-
return
|
|
55775
|
+
return join20(piAgentDirOf(env, home), SETTINGS_FILE);
|
|
55776
|
+
case "gemini":
|
|
55777
|
+
return join20(geminiDirOf(env, home), SETTINGS_FILE);
|
|
55778
|
+
// D-R38-GEMINI-HOME-1
|
|
55598
55779
|
case "copilot-cli":
|
|
55599
55780
|
return null;
|
|
55600
55781
|
default:
|
|
55601
|
-
return
|
|
55782
|
+
return join20(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
|
|
55602
55783
|
}
|
|
55603
55784
|
}
|
|
55604
55785
|
function cell3(value) {
|
|
@@ -55647,96 +55828,16 @@ function regenerateHostConfig(row5, home, opts = {}) {
|
|
|
55647
55828
|
return result.edits.map((e) => toRow(current.path, e));
|
|
55648
55829
|
}
|
|
55649
55830
|
|
|
55650
|
-
// src/core/ops/plugin-swap.ts
|
|
55651
|
-
import { existsSync as existsSync20, lstatSync, readdirSync as readdirSync9, readlinkSync, rmSync as rmSync7, symlinkSync, unlinkSync as unlinkSync2 } from "node:fs";
|
|
55652
|
-
import { basename as basename6, join as join20, win32 as win322 } from "node:path";
|
|
55653
|
-
function linkTarget(path8, win) {
|
|
55654
|
-
if (!isLink(path8)) return null;
|
|
55655
|
-
const target = readlinkSync(path8);
|
|
55656
|
-
return win ? win322.basename(target) : target;
|
|
55657
|
-
}
|
|
55658
|
-
function isLink(path8) {
|
|
55659
|
-
return lstatSync(path8, { throwIfNoEntry: false })?.isSymbolicLink() === true;
|
|
55660
|
-
}
|
|
55661
|
-
function generations(agentDir) {
|
|
55662
|
-
return readdirSync9(agentDir, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name).filter((name) => !name.startsWith(UPGRADE_FETCH_DIR_PREFIX) && !name.endsWith(UPGRADE_TRASH_SUFFIX)).sort();
|
|
55663
|
-
}
|
|
55664
|
-
function settleLinks(link, tmp, old, opts) {
|
|
55665
|
-
if (isLink(tmp)) unlinkSync2(tmp);
|
|
55666
|
-
if (!isLink(old)) return;
|
|
55667
|
-
if (isLink(link)) unlinkSync2(old);
|
|
55668
|
-
else renameWithRetry(old, link, opts);
|
|
55669
|
-
}
|
|
55670
|
-
function swapPluginCurrent(agentDir, sha, opts = {}) {
|
|
55671
|
-
const next = join20(agentDir, sha);
|
|
55672
|
-
if (!existsSync20(next) || !lstatSync(next).isDirectory()) {
|
|
55673
|
-
throw new CtxError("PLUGIN_ROOT_MISSING", { agent: basename6(agentDir), path: next });
|
|
55674
|
-
}
|
|
55675
|
-
const link = join20(agentDir, PLUGIN_CURRENT_LINK);
|
|
55676
|
-
const tmp = link + PLUGIN_LINK_TMP_SUFFIX;
|
|
55677
|
-
const old = link + PLUGIN_LINK_OLD_SUFFIX;
|
|
55678
|
-
settleLinks(link, tmp, old, opts);
|
|
55679
|
-
const win = (opts.platform ?? process.platform) === "win32";
|
|
55680
|
-
const before = linkTarget(link, win);
|
|
55681
|
-
if (before === sha) return { current: next, previous: null, removed: [] };
|
|
55682
|
-
const symlink = opts.symlink ?? symlinkSync;
|
|
55683
|
-
if (win) symlink(next, tmp, PLUGIN_LINK_TYPE_WIN32);
|
|
55684
|
-
else symlink(sha, tmp, PLUGIN_LINK_TYPE);
|
|
55685
|
-
if (before !== null) renameWithRetry(link, old, opts);
|
|
55686
|
-
renameWithRetry(tmp, link, opts);
|
|
55687
|
-
if (before !== null) unlinkSync2(old);
|
|
55688
|
-
const keep = /* @__PURE__ */ new Set([sha]);
|
|
55689
|
-
if (before !== null) keep.add(before);
|
|
55690
|
-
const removed = generations(agentDir).filter((name) => !keep.has(name)).map((name) => join20(agentDir, name));
|
|
55691
|
-
for (const dir of removed) rmSync7(dir, { recursive: true, force: true });
|
|
55692
|
-
const previous = before !== null && existsSync20(join20(agentDir, before)) ? join20(agentDir, before) : null;
|
|
55693
|
-
return { current: next, previous, removed };
|
|
55694
|
-
}
|
|
55695
|
-
|
|
55696
|
-
// src/core/ops/release-fetch.ts
|
|
55697
|
-
import { existsSync as existsSync21, mkdirSync as mkdirSync8, rmSync as rmSync8 } from "node:fs";
|
|
55698
|
-
import { join as join21 } from "node:path";
|
|
55699
|
-
function failed(r) {
|
|
55700
|
-
if (r.exitCode === null && r.killed === null) return new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
|
|
55701
|
-
const status = r.killed ?? String(r.exitCode);
|
|
55702
|
-
return new CtxError("FETCH_FAILED", { code: GIT_EXIT_LABEL + status + UPGRADE_AREA_KEY_SEP + r.stderr.toString().trim() });
|
|
55703
|
-
}
|
|
55704
|
-
async function git2(bin, args, cwd, env, signal) {
|
|
55705
|
-
const r = await runProcess([bin, ...args], { cwd, env, signal, timeoutMs: UPGRADE_GIT_TIMEOUT_MS });
|
|
55706
|
-
if (r.exitCode !== 0 || r.killed !== null) throw failed(r);
|
|
55707
|
-
return r.stdout.toString().trim();
|
|
55708
|
-
}
|
|
55709
|
-
async function fetchRelease(agent, url4, env, signal, opts = {}) {
|
|
55710
|
-
const agentDir = join21(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, agent);
|
|
55711
|
-
mkdirSync8(agentDir, { recursive: true });
|
|
55712
|
-
const fetchDir = join21(agentDir, UPGRADE_FETCH_DIR_PREFIX + process.pid);
|
|
55713
|
-
rmSync8(fetchDir, { recursive: true, force: true });
|
|
55714
|
-
const gitBin = findRuntime(GIT_BIN, env);
|
|
55715
|
-
if (gitBin === null) throw new CtxError("FETCH_FAILED", { code: GIT_NOT_STARTED });
|
|
55716
|
-
const childEnv = buildChildEnv(env, { ...GIT_NO_PROMPT_ENV, ...GIT_NO_CRLF_ENV });
|
|
55717
|
-
try {
|
|
55718
|
-
await git2(gitBin, [...GIT_CLONE_ARGS, RELEASE_BRANCH, url4, fetchDir], agentDir, childEnv, signal);
|
|
55719
|
-
const sha = await git2(gitBin, GIT_HEAD_SHA_ARGS, fetchDir, childEnv, signal);
|
|
55720
|
-
const dir = join21(agentDir, sha);
|
|
55721
|
-
if (existsSync21(dir)) rmSync8(fetchDir, { recursive: true, force: true });
|
|
55722
|
-
else renameWithRetry(fetchDir, dir, opts);
|
|
55723
|
-
return { sha, dir };
|
|
55724
|
-
} catch (e) {
|
|
55725
|
-
rmSync8(fetchDir, { recursive: true, force: true });
|
|
55726
|
-
throw e;
|
|
55727
|
-
}
|
|
55728
|
-
}
|
|
55729
|
-
|
|
55730
55831
|
// src/core/ops/uninstall.ts
|
|
55731
|
-
import { existsSync as
|
|
55732
|
-
import { join as
|
|
55832
|
+
import { existsSync as existsSync20, readdirSync as readdirSync9, rmSync as rmSync7, writeFileSync as writeFileSync6 } from "node:fs";
|
|
55833
|
+
import { join as join21 } from "node:path";
|
|
55733
55834
|
function row2(area, before, after) {
|
|
55734
55835
|
return { area, before, after };
|
|
55735
55836
|
}
|
|
55736
55837
|
function stopServers(configDir, projectKey) {
|
|
55737
55838
|
const stopped = listLiveOwners(configDir, projectKey);
|
|
55738
|
-
const dir =
|
|
55739
|
-
for (const serverId of stopped) writeFileSync6(
|
|
55839
|
+
const dir = join21(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
|
|
55840
|
+
for (const serverId of stopped) writeFileSync6(join21(dir, serverId + OWNER_STOP_EXT), "", "utf8");
|
|
55740
55841
|
return stopped.length === 0 ? { row: row2(UPGRADE_SERVER_AREA, "", UPGRADE_NOT_FOUND), stopped } : { row: row2(UPGRADE_SERVER_AREA, UPGRADE_SERVER_RUNNING, UPGRADE_SERVER_STOPPED), stopped };
|
|
55741
55842
|
}
|
|
55742
55843
|
function rootOrNull(adapter, env) {
|
|
@@ -55754,16 +55855,16 @@ function removeCache(adapter, env, configDir) {
|
|
|
55754
55855
|
const root = rootOrNull(adapter, env);
|
|
55755
55856
|
if (root === null) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
|
|
55756
55857
|
if (adapter.installMode === "marketplace") {
|
|
55757
|
-
const cache =
|
|
55858
|
+
const cache = join21(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
|
|
55758
55859
|
if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
|
|
55759
55860
|
}
|
|
55760
|
-
|
|
55861
|
+
rmSync7(root, { recursive: true, force: true });
|
|
55761
55862
|
return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
|
|
55762
55863
|
}
|
|
55763
55864
|
case "plugin": {
|
|
55764
|
-
const agentDir =
|
|
55765
|
-
if (!
|
|
55766
|
-
|
|
55865
|
+
const agentDir = join21(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
|
|
55866
|
+
if (!existsSync20(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
|
|
55867
|
+
rmSync7(agentDir, { recursive: true, force: true });
|
|
55767
55868
|
return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
|
|
55768
55869
|
}
|
|
55769
55870
|
case "config-mcp":
|
|
@@ -55778,7 +55879,7 @@ function removeCache(adapter, env, configDir) {
|
|
|
55778
55879
|
function isObj3(v) {
|
|
55779
55880
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
55780
55881
|
}
|
|
55781
|
-
function
|
|
55882
|
+
function piSource2(entry) {
|
|
55782
55883
|
return isObj3(entry) ? entry[PI_PACKAGE_SOURCE_KEY] : entry;
|
|
55783
55884
|
}
|
|
55784
55885
|
function ownEntries2(agent, env) {
|
|
@@ -55807,7 +55908,7 @@ function ownEntries2(agent, env) {
|
|
|
55807
55908
|
}
|
|
55808
55909
|
if (agent === "opencode") {
|
|
55809
55910
|
return [{
|
|
55810
|
-
file:
|
|
55911
|
+
file: join21(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
|
|
55811
55912
|
// D-WIN-OPENCODE-DIR-1
|
|
55812
55913
|
key: OPENCODE_PLUGIN_KEY,
|
|
55813
55914
|
shown: OPENCODE_PLUGIN_KEY,
|
|
@@ -55818,11 +55919,11 @@ function ownEntries2(agent, env) {
|
|
|
55818
55919
|
if (agent === "pi") {
|
|
55819
55920
|
const agentDir = piAgentDirOf(env, home);
|
|
55820
55921
|
return [{
|
|
55821
|
-
file:
|
|
55922
|
+
file: join21(agentDir, SETTINGS_FILE),
|
|
55822
55923
|
key: PI_PACKAGES_KEY,
|
|
55823
55924
|
shown: PI_PACKAGES_KEY,
|
|
55824
|
-
has: (v) => Array.isArray(v) && v.some((x) =>
|
|
55825
|
-
drop: (v) => v.filter((x) =>
|
|
55925
|
+
has: (v) => Array.isArray(v) && v.some((x) => piSource2(x) === PI_GIT_PACKAGE),
|
|
55926
|
+
drop: (v) => v.filter((x) => piSource2(x) !== PI_GIT_PACKAGE)
|
|
55826
55927
|
}];
|
|
55827
55928
|
}
|
|
55828
55929
|
return [];
|
|
@@ -55840,12 +55941,12 @@ function removeOwnEntries(agent, env) {
|
|
|
55840
55941
|
return rows.length === 0 ? [row2(UPGRADE_CONFIG_AREA, "", UPGRADE_NOT_FOUND)] : rows;
|
|
55841
55942
|
}
|
|
55842
55943
|
function removeProjectData(configDir, projectKey) {
|
|
55843
|
-
const projects =
|
|
55844
|
-
const dir =
|
|
55845
|
-
if (!
|
|
55944
|
+
const projects = join21(configDir, PROJECTS_DIR_NAME);
|
|
55945
|
+
const dir = join21(projects, projectKey);
|
|
55946
|
+
if (!existsSync20(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
|
|
55846
55947
|
if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
|
|
55847
|
-
for (const name of
|
|
55848
|
-
if (name !== OWNERS_DIR_NAME)
|
|
55948
|
+
for (const name of readdirSync9(dir)) {
|
|
55949
|
+
if (name !== OWNERS_DIR_NAME) rmSync7(join21(dir, name), { recursive: true, force: true });
|
|
55849
55950
|
}
|
|
55850
55951
|
return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
|
|
55851
55952
|
}
|
|
@@ -55853,25 +55954,32 @@ function runUninstall(input) {
|
|
|
55853
55954
|
const configDir = resolveConfigDir(input.env);
|
|
55854
55955
|
const stop = stopServers(configDir, input.project.projectKey);
|
|
55855
55956
|
const rows = [stop.row, removeCache(input.adapter, input.env, configDir), ...removeOwnEntries(input.adapter.id, input.env)];
|
|
55856
|
-
rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA,
|
|
55957
|
+
rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join21(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
|
|
55857
55958
|
return { rows, stopped: stop.stopped };
|
|
55858
55959
|
}
|
|
55859
55960
|
|
|
55860
55961
|
// src/core/ops/v1-remove.ts
|
|
55861
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
55962
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync21, readFileSync as readFileSync14, rmSync as rmSync8 } from "node:fs";
|
|
55862
55963
|
var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
55863
55964
|
var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
|
|
55864
55965
|
var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
|
|
55865
55966
|
function moveAside(target, undo) {
|
|
55866
55967
|
const trash = target + UPGRADE_TRASH_SUFFIX;
|
|
55867
|
-
|
|
55968
|
+
rmSync8(trash, { recursive: true, force: true });
|
|
55868
55969
|
renameWithRetry(target, trash);
|
|
55869
55970
|
undo.push({ trash, target });
|
|
55870
55971
|
}
|
|
55972
|
+
function keepAside(target, undo) {
|
|
55973
|
+
let aside = target + UPGRADE_ASIDE_SUFFIX;
|
|
55974
|
+
for (let n = 2; existsSync21(aside); n += 1) aside = target + UPGRADE_ASIDE_SUFFIX + "-" + n;
|
|
55975
|
+
renameWithRetry(target, aside);
|
|
55976
|
+
undo.push({ trash: aside, target, keep: true });
|
|
55977
|
+
return aside;
|
|
55978
|
+
}
|
|
55871
55979
|
function keepOriginal(file2, kept, undo) {
|
|
55872
55980
|
if (kept.has(file2)) return;
|
|
55873
55981
|
const trash = file2 + UPGRADE_TRASH_SUFFIX;
|
|
55874
|
-
|
|
55982
|
+
rmSync8(trash, { recursive: true, force: true });
|
|
55875
55983
|
copyFileSync2(file2, trash);
|
|
55876
55984
|
kept.add(file2);
|
|
55877
55985
|
undo.push({ trash, target: file2 });
|
|
@@ -55931,7 +56039,7 @@ function stripJsonEntries(agent, file2, findings, kept, undo) {
|
|
|
55931
56039
|
writeHostConfigEdit(file2, { agent, text, format: "jsonc", path: file2, layout }, patch);
|
|
55932
56040
|
return hit;
|
|
55933
56041
|
}
|
|
55934
|
-
function removeV1(agent, findings) {
|
|
56042
|
+
function removeV1(agent, findings, project) {
|
|
55935
56043
|
const undo = [];
|
|
55936
56044
|
const kept = /* @__PURE__ */ new Set();
|
|
55937
56045
|
const done = /* @__PURE__ */ new Map();
|
|
@@ -55939,14 +56047,16 @@ function removeV1(agent, findings) {
|
|
|
55939
56047
|
for (const f of findings) {
|
|
55940
56048
|
if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
|
|
55941
56049
|
else if (f.path === "") {
|
|
55942
|
-
if (
|
|
56050
|
+
if (project !== void 0 && reachedThroughLink(project, f.file)) done.set(f, UPGRADE_REPORT_ONLY);
|
|
56051
|
+
else if (existsSync21(f.file) && UPGRADE_KEEP_ASIDE_REASONS.includes(f.reason)) done.set(f, UPGRADE_MOVED_ASIDE + keepAside(f.file, undo));
|
|
56052
|
+
else if (existsSync21(f.file)) {
|
|
55943
56053
|
moveAside(f.file, undo);
|
|
55944
56054
|
done.set(f, UPGRADE_REMOVED);
|
|
55945
56055
|
} else done.set(f, UPGRADE_NOT_FOUND);
|
|
55946
56056
|
} else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
|
|
55947
56057
|
}
|
|
55948
56058
|
for (const [file2, list3] of entries) {
|
|
55949
|
-
if (!
|
|
56059
|
+
if (!existsSync21(file2)) {
|
|
55950
56060
|
for (const f of list3) done.set(f, UPGRADE_NOT_FOUND);
|
|
55951
56061
|
continue;
|
|
55952
56062
|
}
|
|
@@ -55975,64 +56085,18 @@ function removeV1(agent, findings) {
|
|
|
55975
56085
|
return {
|
|
55976
56086
|
rows: findings.map((f) => row3(f, done.get(f) ?? UPGRADE_NOT_FOUND)),
|
|
55977
56087
|
commit() {
|
|
55978
|
-
for (const u of undo.splice(0))
|
|
56088
|
+
for (const u of undo.splice(0)) if (u.keep !== true) rmSync8(u.trash, { recursive: true, force: true });
|
|
55979
56089
|
},
|
|
55980
56090
|
rollback() {
|
|
55981
56091
|
for (const u of undo.splice(0).reverse()) {
|
|
55982
|
-
if (!
|
|
55983
|
-
|
|
56092
|
+
if (!existsSync21(u.trash)) continue;
|
|
56093
|
+
rmSync8(u.target, { recursive: true, force: true });
|
|
55984
56094
|
renameWithRetry(u.trash, u.target);
|
|
55985
56095
|
}
|
|
55986
56096
|
}
|
|
55987
56097
|
};
|
|
55988
56098
|
}
|
|
55989
56099
|
|
|
55990
|
-
// src/core/ops/verify-sums.ts
|
|
55991
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
55992
|
-
import { lstatSync as lstatSync2, readdirSync as readdirSync11, readFileSync as readFileSync15 } from "node:fs";
|
|
55993
|
-
import { join as join23 } from "node:path";
|
|
55994
|
-
function mismatch() {
|
|
55995
|
-
return new CtxError("BUNDLE_HASH_MISMATCH");
|
|
55996
|
-
}
|
|
55997
|
-
function parseSums(text) {
|
|
55998
|
-
const lines = text.split(SUMS_LINE_END);
|
|
55999
|
-
if (lines[lines.length - 1] === "") lines.pop();
|
|
56000
|
-
const sums = /* @__PURE__ */ new Map();
|
|
56001
|
-
for (const line of lines) {
|
|
56002
|
-
const at = line.indexOf(SUMS_LINE_SEP);
|
|
56003
|
-
if (at < 0) throw mismatch();
|
|
56004
|
-
const rel = line.slice(at + SUMS_LINE_SEP.length);
|
|
56005
|
-
if (rel === "" || sums.has(rel)) throw mismatch();
|
|
56006
|
-
sums.set(rel, line.slice(0, at));
|
|
56007
|
-
}
|
|
56008
|
-
return sums;
|
|
56009
|
-
}
|
|
56010
|
-
function walk2(dir, prefix, out) {
|
|
56011
|
-
for (const entry of readdirSync11(dir, { withFileTypes: true })) {
|
|
56012
|
-
const rel = prefix === "" ? entry.name : prefix + "/" + entry.name;
|
|
56013
|
-
if (prefix === "" && (entry.name === GIT_DIR_NAME || entry.name === RELEASE_SUMS_FILE)) continue;
|
|
56014
|
-
const abs = join23(dir, entry.name);
|
|
56015
|
-
if (entry.isDirectory()) walk2(abs, rel, out);
|
|
56016
|
-
else if (entry.isFile()) out.set(rel, abs);
|
|
56017
|
-
else throw mismatch();
|
|
56018
|
-
}
|
|
56019
|
-
}
|
|
56020
|
-
function verifySums(dir) {
|
|
56021
|
-
const sumsPath = join23(dir, RELEASE_SUMS_FILE);
|
|
56022
|
-
const sumsStat = lstatSync2(sumsPath, { throwIfNoEntry: false });
|
|
56023
|
-
if (sumsStat === void 0 || !sumsStat.isFile()) throw mismatch();
|
|
56024
|
-
const sums = parseSums(readFileSync15(sumsPath, "utf8"));
|
|
56025
|
-
const files = /* @__PURE__ */ new Map();
|
|
56026
|
-
walk2(dir, "", files);
|
|
56027
|
-
if (files.size !== sums.size) throw mismatch();
|
|
56028
|
-
for (const [rel, abs] of files) {
|
|
56029
|
-
const want = sums.get(rel);
|
|
56030
|
-
if (want === void 0) throw mismatch();
|
|
56031
|
-
const got = createHash2(SUMS_HASH_ALGORITHM).update(readFileSync15(abs)).digest(HASH_ENCODING);
|
|
56032
|
-
if (got !== want) throw mismatch();
|
|
56033
|
-
}
|
|
56034
|
-
}
|
|
56035
|
-
|
|
56036
56100
|
// src/core/tools/upgrade.ts
|
|
56037
56101
|
var ctxUpgradeSchema = external_exports.object({
|
|
56038
56102
|
mode: external_exports.enum(UPGRADE_MODES).optional(),
|
|
@@ -56055,41 +56119,20 @@ function pluginRootRow(adapter, env) {
|
|
|
56055
56119
|
}
|
|
56056
56120
|
return root === own4 ? [] : [row4(UPGRADE_PLUGIN_ROOT_AREA, root, own4)];
|
|
56057
56121
|
}
|
|
56058
|
-
function isCurrent(agentDir, dir) {
|
|
56059
|
-
const link = join24(agentDir, PLUGIN_CURRENT_LINK);
|
|
56060
|
-
return existsSync24(link) && realpathSync11.native(link) === realpathSync11.native(dir);
|
|
56061
|
-
}
|
|
56062
|
-
async function checkout(adapter, deps) {
|
|
56063
|
-
const fetched = await fetchRelease(adapter.id, deps.releaseUrl, deps.env, deps.signal);
|
|
56064
|
-
const agentDir = dirname12(fetched.dir);
|
|
56065
|
-
try {
|
|
56066
|
-
verifySums(fetched.dir);
|
|
56067
|
-
} catch (err) {
|
|
56068
|
-
if (!isCurrent(agentDir, fetched.dir)) rmSync11(fetched.dir, { recursive: true, force: true });
|
|
56069
|
-
throw err;
|
|
56070
|
-
}
|
|
56071
|
-
const swap = swapPluginCurrent(agentDir, fetched.sha);
|
|
56072
|
-
const rows = [row4(UPGRADE_CHECKOUT_AREA, swap.previous ?? "", swap.current)];
|
|
56073
|
-
for (const dir of swap.removed) rows.push(row4(UPGRADE_CACHE_AREA, dir, UPGRADE_REMOVED));
|
|
56074
|
-
return { rows, agentDir, swap };
|
|
56075
|
-
}
|
|
56076
56122
|
function hostRow(adapter) {
|
|
56077
|
-
return row4(UPGRADE_HOST_AREA, "", UPGRADE_HOST_COMMAND[adapter.id]
|
|
56123
|
+
return row4(UPGRADE_HOST_AREA, "", UPGRADE_HOST_COMMAND[adapter.id]);
|
|
56078
56124
|
}
|
|
56079
|
-
|
|
56080
|
-
let done = null;
|
|
56125
|
+
function upgrade(adapter, deps, home) {
|
|
56081
56126
|
let removal = null;
|
|
56082
56127
|
try {
|
|
56083
|
-
const step4 = UPGRADE_GIT_CHECKOUT_AGENTS.includes(adapter.id) ? (done = await checkout(adapter, deps)).rows : [hostRow(adapter)];
|
|
56084
56128
|
const step5 = regenerateHostConfig(adapter, home, { env: deps.env, write: deps.write });
|
|
56085
|
-
const findings = detectV1(adapter.id, home, { project: deps.project.worktree, piAgentDir: piAgentDirOf(deps.env, home), claudeDir: claudeDirOf(deps.env, home), copilotDir: copilotDirOf(deps.env, home), kiroDir: kiroDirOf(deps.env, home), opencodeDir: opencodeDirOf(deps.env, home) });
|
|
56086
|
-
removal = removeV1(adapter.id, findings);
|
|
56087
|
-
const rows = [
|
|
56129
|
+
const findings = detectV1(adapter.id, home, { project: deps.project.worktree, piAgentDir: piAgentDirOf(deps.env, home), claudeDir: claudeDirOf(deps.env, home), geminiDir: geminiDirOf(deps.env, home), copilotDir: copilotDirOf(deps.env, home), kiroDir: kiroDirOf(deps.env, home), opencodeDir: opencodeDirOf(deps.env, home) });
|
|
56130
|
+
removal = removeV1(adapter.id, findings, deps.project.worktree);
|
|
56131
|
+
const rows = [hostRow(adapter), ...step5, ...removal.rows];
|
|
56088
56132
|
removal.commit();
|
|
56089
56133
|
return rows;
|
|
56090
56134
|
} catch (err) {
|
|
56091
56135
|
removal?.rollback();
|
|
56092
|
-
if (done !== null && done.swap.previous !== null) swapPluginCurrent(done.agentDir, basename7(done.swap.previous));
|
|
56093
56136
|
throw err;
|
|
56094
56137
|
}
|
|
56095
56138
|
}
|
|
@@ -56109,12 +56152,12 @@ async function runUpgrade(input, deps) {
|
|
|
56109
56152
|
const result = runUninstall({ adapter, project: deps.project, env: deps.env, confirmDelete: input.confirmDelete === true });
|
|
56110
56153
|
rows.push(...result.rows);
|
|
56111
56154
|
} else {
|
|
56112
|
-
rows.push(...
|
|
56155
|
+
rows.push(...upgrade(adapter, deps, home));
|
|
56113
56156
|
}
|
|
56114
56157
|
return { text: renderTable(rows) + "\n\n" + UPGRADE_RESTART_LINE, isError: false, sandboxBytes: 0 };
|
|
56115
56158
|
}
|
|
56116
56159
|
async function handler8(input, ctx) {
|
|
56117
|
-
return runUpgrade(input, { project: ctx.project, env: process.env, signal: ctx.signal
|
|
56160
|
+
return runUpgrade(input, { project: ctx.project, env: process.env, signal: ctx.signal });
|
|
56118
56161
|
}
|
|
56119
56162
|
var ctxUpgrade = Object.freeze({
|
|
56120
56163
|
name: "ctx_upgrade",
|
|
@@ -56176,12 +56219,12 @@ function checkCall(tool, input) {
|
|
|
56176
56219
|
}
|
|
56177
56220
|
|
|
56178
56221
|
// src/entries/is-entry.ts
|
|
56179
|
-
import { realpathSync as
|
|
56222
|
+
import { realpathSync as realpathSync11 } from "node:fs";
|
|
56180
56223
|
function isEntry(main, argv1, self) {
|
|
56181
56224
|
if (main !== void 0) return main;
|
|
56182
56225
|
if (argv1 === void 0 || argv1 === "") return false;
|
|
56183
56226
|
try {
|
|
56184
|
-
return
|
|
56227
|
+
return realpathSync11(argv1) === realpathSync11(self);
|
|
56185
56228
|
} catch {
|
|
56186
56229
|
return false;
|
|
56187
56230
|
}
|
|
@@ -56257,16 +56300,33 @@ function workspaceFromMeta(meta3) {
|
|
|
56257
56300
|
}
|
|
56258
56301
|
function realOrSame(p) {
|
|
56259
56302
|
try {
|
|
56260
|
-
return
|
|
56303
|
+
return realpathSync12.native(p);
|
|
56261
56304
|
} catch {
|
|
56262
56305
|
return p;
|
|
56263
56306
|
}
|
|
56264
56307
|
}
|
|
56308
|
+
function hasWorkspaceFolder(argv) {
|
|
56309
|
+
const i = argv.indexOf(WORKSPACE_FOLDER_FLAG);
|
|
56310
|
+
const v = i < 0 ? void 0 : argv[i + 1];
|
|
56311
|
+
return v !== void 0 && v !== "" && v !== VSCODE_WORKSPACE_VAR;
|
|
56312
|
+
}
|
|
56313
|
+
async function workspaceFromRoots(server) {
|
|
56314
|
+
if (server.server.getClientCapabilities()?.roots === void 0) return void 0;
|
|
56315
|
+
try {
|
|
56316
|
+
const { roots } = await server.server.listRoots(void 0, { timeout: ROOTS_TIMEOUT_MS });
|
|
56317
|
+
for (const root of roots) {
|
|
56318
|
+
if (root.uri.startsWith(FILE_URL_PREFIX)) return fileURLToPath3(root.uri);
|
|
56319
|
+
}
|
|
56320
|
+
} catch (err) {
|
|
56321
|
+
console.error("context-mode: roots/list: " + (err instanceof Error ? err.message : String(err)));
|
|
56322
|
+
}
|
|
56323
|
+
return void 0;
|
|
56324
|
+
}
|
|
56265
56325
|
function workspaceCwdOf(meta3, spawnCwd, script) {
|
|
56266
56326
|
const fromHost = workspaceFromMeta(meta3);
|
|
56267
56327
|
if (fromHost !== void 0) return fromHost;
|
|
56268
56328
|
if (script === void 0 || script === "") return spawnCwd;
|
|
56269
|
-
return realOrSame(spawnCwd) === realOrSame(
|
|
56329
|
+
return realOrSame(spawnCwd) === realOrSame(dirname12(script)) ? "" : spawnCwd;
|
|
56270
56330
|
}
|
|
56271
56331
|
function errorReply(err) {
|
|
56272
56332
|
if (err instanceof CtxError) return { text: err.toLine(), isError: true, sandboxBytes: 0 };
|
|
@@ -56305,15 +56365,15 @@ async function startServer(argv, env) {
|
|
|
56305
56365
|
opening.catch(() => pending.delete(project.dbPath));
|
|
56306
56366
|
}
|
|
56307
56367
|
const db = await opening;
|
|
56308
|
-
if (!
|
|
56368
|
+
if (!existsSync22(db.path)) throw new CtxError("DB_GONE");
|
|
56309
56369
|
return db;
|
|
56310
56370
|
}
|
|
56311
56371
|
function stopMarker(configDir, projectKey) {
|
|
56312
|
-
return
|
|
56372
|
+
return join22(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
|
|
56313
56373
|
}
|
|
56314
56374
|
function stopRequested() {
|
|
56315
56375
|
const configDir = resolveConfigDir(process.env);
|
|
56316
|
-
return held.some((db) =>
|
|
56376
|
+
return held.some((db) => existsSync22(stopMarker(configDir, db.projectKey)));
|
|
56317
56377
|
}
|
|
56318
56378
|
async function journal(project, ctx, name, reply4) {
|
|
56319
56379
|
const db = await ownDb(project);
|
|
@@ -56323,10 +56383,12 @@ async function startServer(argv, env) {
|
|
|
56323
56383
|
return async (input, req) => {
|
|
56324
56384
|
const meta3 = req.mcpReq._meta;
|
|
56325
56385
|
const agent = resolveAgent(argv, env);
|
|
56386
|
+
const fromRoots = agent === "vscode" && !hasWorkspaceFolder(argv) ? await workspaceFromRoots(server) : void 0;
|
|
56387
|
+
const callArgv = fromRoots === void 0 ? argv : [...argv, WORKSPACE_FOLDER_FLAG, fromRoots];
|
|
56326
56388
|
let project;
|
|
56327
56389
|
const projectOf = () => {
|
|
56328
56390
|
if (agent === void 0) throw new CtxError("NO_PROJECT", { kind: "--agent" });
|
|
56329
|
-
project ??= resolveProject(agent, { env, argv, cwd: workspaceCwdOf(meta3, process.cwd(), process.argv[1]), piCwd: void 0 });
|
|
56391
|
+
project ??= resolveProject(agent, { env, argv: callArgv, cwd: workspaceCwdOf(meta3, process.cwd(), process.argv[1]), piCwd: void 0 });
|
|
56330
56392
|
return project;
|
|
56331
56393
|
};
|
|
56332
56394
|
const ctx = {
|
|
@@ -56406,7 +56468,7 @@ async function startServer(argv, env) {
|
|
|
56406
56468
|
try {
|
|
56407
56469
|
const configDir = resolveConfigDir(process.env);
|
|
56408
56470
|
removeOwnerPid(configDir, db.projectKey, serverId);
|
|
56409
|
-
|
|
56471
|
+
rmSync9(stopMarker(configDir, db.projectKey), { force: true });
|
|
56410
56472
|
} catch (err) {
|
|
56411
56473
|
console.error(err);
|
|
56412
56474
|
}
|