context-mode 2.1.5 → 2.1.6

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/pi/index.js CHANGED
@@ -11162,7 +11162,14 @@ var POINTER_MIN = 640;
11162
11162
  var STATE_CLOSE_TAG = "</context_mode_state>";
11163
11163
  var INDEX_WRITE_CHUNK = 1048576;
11164
11164
  var SYNC_INDEX_MAX_BYTES = 65536;
11165
- var REPLACE_TRIGGER_BYTES = 4096;
11165
+ var REPLACE_TRIGGER_BYTES_DEFAULT = 4096;
11166
+ var REPLACE_TRIGGER_ENV = "CTX_REPLACE_TRIGGER_BYTES";
11167
+ function readReplaceTrigger(raw) {
11168
+ if (raw === void 0 || raw.trim() === "") return REPLACE_TRIGGER_BYTES_DEFAULT;
11169
+ const n = Number(raw);
11170
+ return Number.isSafeInteger(n) && n > 0 ? n : REPLACE_TRIGGER_BYTES_DEFAULT;
11171
+ }
11172
+ var REPLACE_TRIGGER_BYTES = readReplaceTrigger(process.env[REPLACE_TRIGGER_ENV]);
11166
11173
  var RANGE_READ_TOOLS = Object.freeze(["Read", "view"]);
11167
11174
  var READ_RANGE_KEYS = Object.freeze(["offset", "limit", "view_range"]);
11168
11175
  var REPLACE_RETURN_BYTES = 96;
@@ -11394,6 +11401,7 @@ function readHintEvery(raw) {
11394
11401
  }
11395
11402
  var MCP_HINT_EVERY = readHintEvery(process.env.CTX_MCP_HINT_EVERY);
11396
11403
  var MAX_NEST_DEPTH = 32;
11404
+ var SHARED_SKILLS_DIR = Object.freeze([".agents", "skills"]);
11397
11405
  var DENY_PREFIX = "context-mode: ";
11398
11406
  var DENY_WHAT = Object.freeze({
11399
11407
  curl: "This curl/wget call",
@@ -11487,10 +11495,10 @@ var READ_MEDIA_BY_AGENT = Object.freeze({
11487
11495
  opencode: READ_IMAGES_AND_PDF,
11488
11496
  pi: READ_IMAGES,
11489
11497
  vscode: READ_IMAGES,
11498
+ zcode: READ_IMAGES,
11490
11499
  "copilot-cli": [],
11491
11500
  codex: [],
11492
- kiro: [],
11493
- zcode: []
11501
+ kiro: []
11494
11502
  });
11495
11503
  var OWN_TOOL_PREFIX = "ctx_";
11496
11504
  var SHELL_TOOL = "Bash";
@@ -11508,6 +11516,7 @@ var RECALL_MAX_ROWS = 340;
11508
11516
  var COMPACTED_META_PREFIX = "compacted:";
11509
11517
  var RECALL_UNITS_SEEN_META_PREFIX = "recall_units_seen:";
11510
11518
  var UNITS_ANCESTOR_FACTOR = 8;
11519
+ var RECALL_QUERY_MAX_TERMS = 64;
11511
11520
  var RECALL_UNIT_CANDIDATES = 64;
11512
11521
  var RECALL_SEEN_META_PREFIX = "recall_seen:";
11513
11522
  var RECALL_OPEN_TAG = "<context_mode_recall>";
@@ -11601,7 +11610,7 @@ var DECISION_ANSWERS_KEY = "answers";
11601
11610
  var DECISION_OPTION_KEY = "option";
11602
11611
  var DECISION_LABEL_JOIN = " | ";
11603
11612
  var RELEASE_REPO_URL = "https://github.com/mksglu/context-mode.git";
11604
- var BUNDLE_SHA = true ? "f75e51d580374d518a8ceefc1422a009ffe67311" : void 0;
11613
+ var BUNDLE_SHA = true ? "ee0a1f6058f6abdb5af70b05f825a997bb15615d" : void 0;
11605
11614
  var DOCTOR_CHECK_ORDER = Object.freeze(["D1", "D2", "D3", "D4", "D5", "D5b", "D6", "D7", "D8", "D9", "D10", "D11"]);
11606
11615
  var DOCTOR_LABEL = Object.freeze({
11607
11616
  D1: "version",
@@ -11687,9 +11696,9 @@ var D1_REGISTRY_URL = "https://registry.npmjs.org/-/package/context-mode/dist-ta
11687
11696
  var D1_PRERELEASE_SEP = "-";
11688
11697
  var D1_DEFAULT_TAG = "latest";
11689
11698
  var GIT_LS_REMOTE = "ls-remote";
11690
- var D2_NODE_FIX = `install Node ${NODE_MIN} or later`;
11699
+ var D2_NODE_FIX = `nvm install ${NODE_MIN.split(".")[0]}, or install it from https://nodejs.org`;
11691
11700
  function D2_NODE_DETAIL(version4) {
11692
- return `Node ${version4} is below ${NODE_MIN}`;
11701
+ return `Context Mode needs Node ${NODE_MIN} or newer; you have ${version4}`;
11693
11702
  }
11694
11703
  var D2_SQLITE_DETAIL = "node:sqlite failed to load";
11695
11704
  var D2_SQLITE_FIX = "run ctx_doctor";
@@ -11859,6 +11868,7 @@ var REGEX_ESCAPE = "\\";
11859
11868
  var CODEX_FEATURES_HOOKS_KEY = Object.freeze(["features", "hooks"]);
11860
11869
  var D5_SHAPE_DETAIL = "hook output is not the agent's native shape";
11861
11870
  var D5_READ_RANGE_DETAIL = "PostToolUse Read with offset/limit over the replace trigger came back replaced: a bounded Read must reach the model whole";
11871
+ var D5_READ_OWN_DETAIL = "PreToolUse Read of a skill file over the one-read limit under the agent's own config dir came back denied: skill and rule files must reach the model whole (#1326)";
11862
11872
  var D5_READ_MEDIA_DETAIL = "PreToolUse Read of a PNG over the one-read limit came back denied: an image Read must reach the model as an image block (#1321)";
11863
11873
  var D5_READ_SHAPE_DETAIL = `PostToolUse Read replace is not Read's output shape {type:"text", file:{filePath, content, numLines, startLine, totalLines}}: Claude Code drops it and shows a hook warning`;
11864
11874
  function D5_SLOW_DETAIL(ms) {
@@ -11870,6 +11880,11 @@ var PRAGMA_INTEGRITY_CHECK = "PRAGMA integrity_check";
11870
11880
  function D10_DETAIL(mode) {
11871
11881
  return `enforcement mode: ${mode}`;
11872
11882
  }
11883
+ function D10_PERMISSION_DETAIL(mode) {
11884
+ return `enforcement mode: ${mode}; OpenCode permission rules apply to ctx_* tools`;
11885
+ }
11886
+ var D10_PERMISSION_MISSING_DETAIL = "this OpenCode build gives plugins no permission check (ctx.permission.assert), so ctx_* tools cannot follow OpenCode permission rules";
11887
+ var D10_PERMISSION_FIX = "opencode upgrade";
11873
11888
  var D11_WIN_DETAIL = "Git Bash not found";
11874
11889
  var D11_WIN_FIX = "install Git for Windows";
11875
11890
  var D11_POSIX_DETAIL = "no sh on PATH";
@@ -11932,6 +11947,8 @@ var SETTINGS_FILE = "settings.json";
11932
11947
  var CLAUDE_USER_CONFIG_FILE = ".claude.json";
11933
11948
  var HOOKS_JSON_FILE = "hooks.json";
11934
11949
  var CLAUDE_CONFIG_DIR_ENV = "CLAUDE_CONFIG_DIR";
11950
+ var SETUP_BACKUP_DIR_NAME = "backups";
11951
+ var SETUP_MANIFEST_FILE = "manifest.json";
11935
11952
  var CODEX_HOME_ENV = "CODEX_HOME";
11936
11953
  var COPILOT_HOME_ENV = "COPILOT_HOME";
11937
11954
  var GEMINI_CLI_HOME_ENV = "GEMINI_CLI_HOME";
@@ -12026,6 +12043,7 @@ var HOST_CONFIG_TEXT_PATH = "(given text)";
12026
12043
  var JSON_INDENT_UNIT = " ";
12027
12044
  var MCP_COMMAND_FIELD = "command";
12028
12045
  var MCP_ARGS_FIELD = "args";
12046
+ var MCP_ENV_FIELD = "env";
12029
12047
  var ZCODE_MCP_FEATURE_KEY = Object.freeze(["features", "mcp"]);
12030
12048
  var CODEX_OMIT_TOOLS_FROM_FIELD = "omit_tools_from";
12031
12049
  var CODEX_OMIT_DEFERRED = Object.freeze(["deferred"]);
@@ -12201,7 +12219,8 @@ function checkPermission(out) {
12201
12219
 
12202
12220
  // src/core/contracts/errors.ts
12203
12221
  var ERROR_TEXT = Object.freeze({
12204
- NODE_TOO_OLD: "Node <v> is below 24.15.0. Fix: install Node 24.15.0 or later.",
12222
+ NODE_TOO_OLD: "Context Mode needs Node 24.15.0 or newer; you have <v>. Fix: nvm install 24, or install it from https://nodejs.org.",
12223
+ // #1328 D-NODE-OLD-1
12205
12224
  NO_SQLITE: "node:sqlite failed to load. Fix: run ctx_doctor.",
12206
12225
  DB_GONE: "context.db is gone and its WAL file is still in place. Fix: run ctx_doctor once; it keeps the WAL file in a dated folder and starts a new index.",
12207
12226
  // D-ORPHAN-WAL-1
@@ -12271,7 +12290,7 @@ var CtxError = class extends Error {
12271
12290
  };
12272
12291
 
12273
12292
  // src/core/hooks/dispatch.ts
12274
- import { dirname as dirname4, join as join7, relative as relative3, resolve as resolve6, sep as sep3 } from "node:path";
12293
+ import { dirname as dirname4, join as join8, relative as relative3, resolve as resolve6, sep as sep3 } from "node:path";
12275
12294
 
12276
12295
  // src/core/contracts/agents.ts
12277
12296
  var AGENT_IDS = ["claude-code", "codex", "gemini", "qwen", "copilot-cli", "vscode", "kiro", "zcode", "pi", "opencode"];
@@ -14562,7 +14581,7 @@ function withLayout(text, layout) {
14562
14581
 
14563
14582
  // src/core/project/config-dir.ts
14564
14583
  import { basename, dirname, join, posix, resolve as resolve2, win32 } from "node:path";
14565
- var { mkdirSync, realpathSync } = process.getBuiltinModule("node:fs");
14584
+ var { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync } = process.getBuiltinModule("node:fs");
14566
14585
  function homeDirOf(env, platform = process.platform) {
14567
14586
  const set3 = (v) => v !== void 0 && v !== "";
14568
14587
  if (platform === "win32") {
@@ -14589,7 +14608,34 @@ function codexPluginHomeOf(bundleDir2) {
14589
14608
  function codexRunDirOf(env, home, bundleDir2) {
14590
14609
  const dir = env[CODEX_HOME_ENV];
14591
14610
  if (dir !== void 0 && dir !== "") return dir;
14592
- return codexPluginHomeOf(bundleDir2) ?? codexDirOf(env, home);
14611
+ return codexPluginHomeOf(bundleDir2) ?? codexSetupHomeOf(env, home) ?? codexDirOf(env, home);
14612
+ }
14613
+ function codexSetupHomeOf(env, home) {
14614
+ if (home === "" && !env[DATA_DIR_ENV]) return null;
14615
+ const base = join(dataRootOf(env, home), SETUP_BACKUP_DIR_NAME);
14616
+ let runs;
14617
+ try {
14618
+ runs = readdirSync(base).sort().reverse();
14619
+ } catch {
14620
+ return null;
14621
+ }
14622
+ for (const run of runs) {
14623
+ const file2 = join(base, run, SETUP_MANIFEST_FILE);
14624
+ if (!existsSync(file2)) continue;
14625
+ let entries;
14626
+ try {
14627
+ entries = JSON.parse(readFileSync(file2, "utf8")).entries;
14628
+ } catch {
14629
+ continue;
14630
+ }
14631
+ if (!Array.isArray(entries)) continue;
14632
+ for (const e of entries) {
14633
+ if (e?.agent !== "codex" || typeof e.file !== "string") continue;
14634
+ const p = e.file.includes(win32.sep) ? win32 : posix;
14635
+ if (p.basename(e.file) === CONFIG_TOML_FILE) return p.dirname(e.file);
14636
+ }
14637
+ }
14638
+ return null;
14593
14639
  }
14594
14640
  function copilotDirOf(env, home) {
14595
14641
  const dir = env[COPILOT_HOME_ENV];
@@ -14669,7 +14715,7 @@ function resolveConfigDir(env) {
14669
14715
  }
14670
14716
 
14671
14717
  // src/core/policy/subagent.ts
14672
- var { readFileSync } = process.getBuiltinModule("node:fs");
14718
+ var { readFileSync: readFileSync2 } = process.getBuiltinModule("node:fs");
14673
14719
  function isSubagentCall(ev) {
14674
14720
  return ev.agentId !== void 0 && ev.agentId !== "";
14675
14721
  }
@@ -14730,7 +14776,7 @@ function readPluginAgent(claudeDir, type) {
14730
14776
  if (agent.indexOf(PLUGIN_AGENT_SEPARATOR) >= 0) return null;
14731
14777
  let parsed;
14732
14778
  try {
14733
- parsed = JSON.parse(hostText(readFileSync(join2(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE), "utf8")));
14779
+ parsed = JSON.parse(hostText(readFileSync2(join2(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE), "utf8")));
14734
14780
  } catch {
14735
14781
  return null;
14736
14782
  }
@@ -14753,7 +14799,7 @@ function readPluginAgent(claudeDir, type) {
14753
14799
  function readAgentFile(path8) {
14754
14800
  let text;
14755
14801
  try {
14756
- text = readFileSync(path8, "utf8");
14802
+ text = readFileSync2(path8, "utf8");
14757
14803
  } catch {
14758
14804
  return null;
14759
14805
  }
@@ -14961,7 +15007,7 @@ function unwrap(commands) {
14961
15007
 
14962
15008
  // src/core/policy/user-deny.ts
14963
15009
  import { isAbsolute, join as join3, relative, sep } from "node:path";
14964
- var { readFileSync: readFileSync2 } = process.getBuiltinModule("node:fs");
15010
+ var { readFileSync: readFileSync3 } = process.getBuiltinModule("node:fs");
14965
15011
  var CLAUDE_DIR = ".claude";
14966
15012
  var LOCAL_SETTINGS = "settings.local.json";
14967
15013
  var SETTINGS = "settings.json";
@@ -14988,7 +15034,7 @@ function isObject2(v) {
14988
15034
  function readOne(file2) {
14989
15035
  let text;
14990
15036
  try {
14991
- text = hostText(readFileSync2(file2, "utf8"));
15037
+ text = hostText(readFileSync3(file2, "utf8"));
14992
15038
  } catch (err) {
14993
15039
  return err.code === "ENOENT" ? { kind: "absent" } : { kind: "bad" };
14994
15040
  }
@@ -15151,6 +15197,7 @@ var TOOL_DESCRIPTIONS = Object.freeze({
15151
15197
  ctx_purge: 'Example: `ctx_purge({source:"old-docs"})`. Required: one of session, source, project.\nDeletes stored data: one session, one indexed source, or everything stored for this project. This cannot be undone. Use it only when the user asks to forget or reset data.'
15152
15198
  });
15153
15199
  var READ_DENY_TEMPLATE = 'context-mode: {size}-byte file, over the one-read limit. Run ctx_execute(language, code, file="{path}") and print only the answer.';
15200
+ var READ_DENY_RANGE_TEMPLATE = `context-mode: {size}-byte file, over the one-read limit. Read "{path}" in parts with offset and limit, or sed -n '1,200p'.`;
15154
15201
 
15155
15202
  // src/core/policy/read-deny.ts
15156
15203
  var SIZE = "{size}";
@@ -15158,9 +15205,105 @@ var PATH = "{path}";
15158
15205
  function READ_DENY_MESSAGE(path8, size, prefix = "") {
15159
15206
  return prefixToolNames(READ_DENY_TEMPLATE, prefix).split(SIZE).join(String(size)).split(PATH).join(path8);
15160
15207
  }
15208
+ function READ_DENY_RANGE_MESSAGE(path8, size) {
15209
+ return READ_DENY_RANGE_TEMPLATE.split(SIZE).join(String(size)).split(PATH).join(path8);
15210
+ }
15211
+
15212
+ // src/core/policy/own-file.ts
15213
+ import { extname, join as join5 } from "node:path";
15214
+
15215
+ // src/core/project/contain.ts
15216
+ import { dirname as dirname2, join as join4, relative as relative2, sep as sep2 } from "node:path";
15217
+ var { lstatSync, realpathSync: realpathSync2 } = process.getBuiltinModule("node:fs");
15218
+ function real(p) {
15219
+ try {
15220
+ return realpathSync2.native(p);
15221
+ } catch {
15222
+ return void 0;
15223
+ }
15224
+ }
15225
+ function components(p) {
15226
+ return p.split(sep2).filter((c) => c !== "");
15227
+ }
15228
+ function isInside(root, p) {
15229
+ const r = real(root);
15230
+ const q = real(p);
15231
+ if (r === void 0 || q === void 0) return false;
15232
+ const rc = components(r);
15233
+ const qc = components(q);
15234
+ if (qc.length < rc.length) return false;
15235
+ for (let i = 0; i < rc.length; i += 1) {
15236
+ if (rc[i] !== qc[i]) return false;
15237
+ }
15238
+ return true;
15239
+ }
15240
+ var rootReal = /* @__PURE__ */ new Map();
15241
+ function realRoot(root) {
15242
+ const hit = rootReal.get(root);
15243
+ if (hit !== void 0) return hit;
15244
+ const r = real(root);
15245
+ if (r !== void 0) rootReal.set(root, r);
15246
+ return r;
15247
+ }
15248
+ function isInsideAny(roots, p) {
15249
+ if (roots.length === 0) return false;
15250
+ const q = real(p);
15251
+ if (q === void 0) return false;
15252
+ const qc = components(q);
15253
+ return roots.some((root) => {
15254
+ const r = realRoot(root);
15255
+ if (r === void 0) return false;
15256
+ const rc = components(r);
15257
+ return qc.length >= rc.length && rc.every((c, i) => c === qc[i]);
15258
+ });
15259
+ }
15260
+ function commonRoot(paths) {
15261
+ const reals = paths.map(real).filter((r) => r !== void 0);
15262
+ if (reals.length === 0) throw new RangeError("commonRoot needs at least one existing path");
15263
+ const first = reals[0];
15264
+ let n = components(first).length;
15265
+ for (const r of reals) {
15266
+ const rc = components(r);
15267
+ const fc = components(first);
15268
+ let i = 0;
15269
+ while (i < n && i < rc.length && rc[i] === fc[i]) i += 1;
15270
+ n = i;
15271
+ }
15272
+ let q = first;
15273
+ while (components(q).length > n && dirname2(q) !== q) q = dirname2(q);
15274
+ return q;
15275
+ }
15276
+ function reachedThroughLink(root, p) {
15277
+ const rel = relative2(root, p);
15278
+ const steps = components(rel);
15279
+ if (rel === "" || steps[0] === ".." || rel === p) return false;
15280
+ let at2 = root;
15281
+ for (const step of steps) {
15282
+ at2 = join4(at2, step);
15283
+ try {
15284
+ if (lstatSync(at2).isSymbolicLink()) return true;
15285
+ } catch {
15286
+ return false;
15287
+ }
15288
+ }
15289
+ return false;
15290
+ }
15291
+
15292
+ // src/core/policy/own-file.ts
15293
+ function ownDirsOf(agent, env) {
15294
+ const home = homeDirOf(env);
15295
+ if (home === null) return [];
15296
+ const shared = join5(home, ...SHARED_SKILLS_DIR);
15297
+ const own4 = agent === "claude-code" ? [claudeDirOf(env, home)] : agent === "codex" ? [codexDirOf(env, home)] : agent === "gemini" ? [geminiDirOf(env, home)] : agent === "copilot-cli" ? [copilotDirOf(env, home)] : agent === "kiro" ? [kiroDirOf(env, home)] : agent === "opencode" ? [opencodeDirOf(env, home)] : agent === "pi" ? [piAgentDirOf(env, home)] : agent === "vscode" ? [join5(home, ...AGENT_HOME_DIR.vscode), vscodeUserDirOf(env, home)] : [join5(home, ...AGENT_HOME_DIR[agent])];
15298
+ return [...own4, shared];
15299
+ }
15300
+ function isOwnFile(agent, abs, env = process.env) {
15301
+ if (extname(abs).toLowerCase() !== AGENT_FILE_EXT) return false;
15302
+ return isInsideAny(ownDirsOf(agent, env), abs);
15303
+ }
15161
15304
 
15162
15305
  // src/core/policy/read-media.ts
15163
- import { extname } from "node:path";
15306
+ import { extname as extname2 } from "node:path";
15164
15307
  var { closeSync, openSync, readSync } = process.getBuiltinModule("node:fs");
15165
15308
  function head(abs) {
15166
15309
  let fd = null;
@@ -15178,7 +15321,7 @@ function head(abs) {
15178
15321
  function isMediaRead(agent, abs) {
15179
15322
  const types = READ_MEDIA_BY_AGENT[agent] ?? [];
15180
15323
  if (types.length === 0) return false;
15181
- const ext = extname(abs).toLowerCase();
15324
+ const ext = extname2(abs).toLowerCase();
15182
15325
  const named2 = types.filter((t) => READ_MEDIA_TYPES[t].exts.includes(ext));
15183
15326
  if (named2.length === 0) return false;
15184
15327
  const bytes5 = head(abs);
@@ -15209,7 +15352,7 @@ var deny = (reason) => ({ kind: "deny", reason });
15209
15352
  var str = (v) => typeof v === "string" ? v : void 0;
15210
15353
  var present = (v) => v !== void 0 && v !== null;
15211
15354
  var has = (list4, v) => list4.includes(v);
15212
- function decide(ev, row5, userDeny) {
15355
+ function decide(ev, row5, userDeny, root = ev.cwd) {
15213
15356
  const tool = ev.tool;
15214
15357
  if (tool === void 0) return ALLOW;
15215
15358
  const canonical = tool.canonicalName;
@@ -15223,8 +15366,8 @@ function decide(ev, row5, userDeny) {
15223
15366
  const hit = userDenyHit(canonical, input, ev.cwd, rules);
15224
15367
  if (hit !== null) return deny(USER_DENY_REASON_PREFIX + hit);
15225
15368
  if (canonical === WEBFETCH) return webFetch(input, row5);
15226
- if (canonical === BASH) return bash(ev, row5, input, rules);
15227
- if (canonical === READ) return read(ev, row5, input);
15369
+ if (canonical === BASH) return bash(ev, row5, input, rules, root);
15370
+ if (canonical === READ) return read(ev, row5, input, root);
15228
15371
  return ALLOW;
15229
15372
  }
15230
15373
  function denyMessage(kind, match, row5, intent) {
@@ -15326,10 +15469,10 @@ function webFetch(input, row5) {
15326
15469
  const url4 = str(input.url) ?? "";
15327
15470
  return neverDenied(url4) ? ALLOW : deny(denyMessage("webfetch", url4, row5));
15328
15471
  }
15329
- function bash(ev, row5, input, rules) {
15472
+ function bash(ev, row5, input, rules, root) {
15330
15473
  const cmd = str(input.command) ?? "";
15331
15474
  const parsed = parseShell(cmd);
15332
- if (!parsed.ok) return couldMatch(cmd, rules) ? deny(prefixToolNames(PARSE_ERROR_DENY_LINE, row5.toolNamePrefix)) : psShellDump(cmd, ev.cwd, row5) ?? ALLOW;
15475
+ if (!parsed.ok) return couldMatch(cmd, rules) ? deny(prefixToolNames(PARSE_ERROR_DENY_LINE, row5.toolNamePrefix)) : psShellDump(ev, cmd, row5, root) ?? ALLOW;
15333
15476
  const cmds = unwrap(parsed.commands);
15334
15477
  for (const c of cmds) {
15335
15478
  const h = segmentHit(c, rules);
@@ -15341,7 +15484,7 @@ function bash(ev, row5, input, rules) {
15341
15484
  if (kind !== null) return deny(denyMessage(kind, cmd, row5, str(input.description)));
15342
15485
  }
15343
15486
  }
15344
- return shellDump(cmds, ev.cwd, row5) ?? psShellDump(cmd, ev.cwd, row5) ?? ALLOW;
15487
+ return shellDump(ev, cmds, row5, root) ?? psShellDump(ev, cmd, row5, root) ?? ALLOW;
15345
15488
  }
15346
15489
  function denyKind(c) {
15347
15490
  const name = c.argv0.toLowerCase();
@@ -15384,19 +15527,35 @@ function fileSize(abs) {
15384
15527
  return -1;
15385
15528
  }
15386
15529
  }
15387
- function read(ev, row5, input) {
15530
+ function bigDeny(ev, row5, abs, size, root) {
15531
+ if (size <= OUTPUT_CAP || isOwnFile(ev.agent, abs)) return null;
15532
+ return deny(executeCanOpen(root, abs) ? READ_DENY_MESSAGE(abs, size, row5.toolNamePrefix) : READ_DENY_RANGE_MESSAGE(abs, size));
15533
+ }
15534
+ function executeCanOpen(root, abs) {
15535
+ if (typeof root === "string") return isInsideAny([root], abs);
15536
+ if (isInsideAny([root.worktree], abs)) return true;
15537
+ try {
15538
+ return isInsideAny([root.containmentRoot], abs);
15539
+ } catch {
15540
+ return false;
15541
+ }
15542
+ }
15543
+ function read(ev, row5, input, root) {
15388
15544
  if (!present(input.offset) && !present(input.limit)) {
15389
15545
  for (const p of readPaths(input)) {
15390
15546
  const abs = resolve3(ev.cwd, p);
15391
15547
  const size = fileSize(abs);
15392
- if (size > OUTPUT_CAP && !isMediaRead(ev.agent, abs)) return deny(READ_DENY_MESSAGE(abs, size, row5.toolNamePrefix));
15548
+ if (size > OUTPUT_CAP && !isMediaRead(ev.agent, abs)) {
15549
+ const d = bigDeny(ev, row5, abs, size, root);
15550
+ if (d !== null) return d;
15551
+ }
15393
15552
  }
15394
15553
  }
15395
15554
  return ALLOW;
15396
15555
  }
15397
- function shellDump(cmds, cwd, row5) {
15556
+ function shellDump(ev, cmds, row5, root) {
15398
15557
  if (row5.nativeTools.read !== void 0 && row5.nativeTools.read.length > 0 && dumpRunsThenReplaces(row5)) return null;
15399
- let dir = cwd;
15558
+ let dir = ev.cwd;
15400
15559
  let verdict = null;
15401
15560
  for (const c of cmds) {
15402
15561
  const name = c.argv0.toLowerCase();
@@ -15410,16 +15569,16 @@ function shellDump(cmds, cwd, row5) {
15410
15569
  continue;
15411
15570
  }
15412
15571
  const abs = resolve3(dir, d.file);
15413
- const size = fileSize(abs);
15414
- if (size > OUTPUT_CAP) return deny(READ_DENY_MESSAGE(abs, size, row5.toolNamePrefix));
15572
+ const big = bigDeny(ev, row5, abs, fileSize(abs), root);
15573
+ if (big !== null) return big;
15415
15574
  }
15416
15575
  return verdict;
15417
15576
  }
15418
- function psShellDump(cmd, cwd, row5) {
15577
+ function psShellDump(ev, cmd, row5, root) {
15419
15578
  if (row5.nativeTools.read !== void 0 && row5.nativeTools.read.length > 0 && dumpRunsThenReplaces(row5)) return null;
15420
- for (const abs of psDumpFiles(cmd, cwd)) {
15421
- const size = fileSize(abs);
15422
- if (size > OUTPUT_CAP) return deny(READ_DENY_MESSAGE(abs, size, row5.toolNamePrefix));
15579
+ for (const abs of psDumpFiles(cmd, ev.cwd)) {
15580
+ const d = bigDeny(ev, row5, abs, fileSize(abs), root);
15581
+ if (d !== null) return d;
15423
15582
  }
15424
15583
  return null;
15425
15584
  }
@@ -15480,64 +15639,7 @@ function dumpTarget(name, args) {
15480
15639
  }
15481
15640
 
15482
15641
  // src/core/project/resolve.ts
15483
- import { basename as basename2, dirname as dirname3, join as join5, resolve as resolve4 } from "node:path";
15484
-
15485
- // src/core/project/contain.ts
15486
- import { dirname as dirname2, join as join4, relative as relative2, sep as sep2 } from "node:path";
15487
- var { lstatSync, realpathSync: realpathSync2 } = process.getBuiltinModule("node:fs");
15488
- function real(p) {
15489
- try {
15490
- return realpathSync2.native(p);
15491
- } catch {
15492
- return void 0;
15493
- }
15494
- }
15495
- function components(p) {
15496
- return p.split(sep2).filter((c) => c !== "");
15497
- }
15498
- function isInside(root, p) {
15499
- const r = real(root);
15500
- const q = real(p);
15501
- if (r === void 0 || q === void 0) return false;
15502
- const rc = components(r);
15503
- const qc = components(q);
15504
- if (qc.length < rc.length) return false;
15505
- for (let i = 0; i < rc.length; i += 1) {
15506
- if (rc[i] !== qc[i]) return false;
15507
- }
15508
- return true;
15509
- }
15510
- function commonRoot(paths) {
15511
- const reals = paths.map(real).filter((r) => r !== void 0);
15512
- if (reals.length === 0) throw new RangeError("commonRoot needs at least one existing path");
15513
- const first = reals[0];
15514
- let n = components(first).length;
15515
- for (const r of reals) {
15516
- const rc = components(r);
15517
- const fc = components(first);
15518
- let i = 0;
15519
- while (i < n && i < rc.length && rc[i] === fc[i]) i += 1;
15520
- n = i;
15521
- }
15522
- let q = first;
15523
- while (components(q).length > n && dirname2(q) !== q) q = dirname2(q);
15524
- return q;
15525
- }
15526
- function reachedThroughLink(root, p) {
15527
- const rel = relative2(root, p);
15528
- const steps = components(rel);
15529
- if (rel === "" || steps[0] === ".." || rel === p) return false;
15530
- let at2 = root;
15531
- for (const step of steps) {
15532
- at2 = join4(at2, step);
15533
- try {
15534
- if (lstatSync(at2).isSymbolicLink()) return true;
15535
- } catch {
15536
- return false;
15537
- }
15538
- }
15539
- return false;
15540
- }
15642
+ import { basename as basename2, dirname as dirname3, join as join6, resolve as resolve4 } from "node:path";
15541
15643
 
15542
15644
  // src/core/project/sha256.ts
15543
15645
  var K = new Uint32Array([
@@ -15652,7 +15754,7 @@ function sha256Hex(text) {
15652
15754
  }
15653
15755
 
15654
15756
  // src/core/project/resolve.ts
15655
- var { existsSync, readFileSync: readFileSync3, realpathSync: realpathSync3, statSync: statSync2 } = process.getBuiltinModule("node:fs");
15757
+ var { existsSync: existsSync2, readFileSync: readFileSync4, realpathSync: realpathSync3, statSync: statSync2 } = process.getBuiltinModule("node:fs");
15656
15758
  function sourceOf(agent) {
15657
15759
  switch (agent) {
15658
15760
  case "claude-code":
@@ -15699,9 +15801,9 @@ function gitDirs(dir) {
15699
15801
  }
15700
15802
  const start = cur;
15701
15803
  for (; ; ) {
15702
- const gitDir = gitDirAt(join5(cur, GIT_DIR_NAME));
15804
+ const gitDir = gitDirAt(join6(cur, GIT_DIR_NAME));
15703
15805
  if (gitDir !== null) {
15704
- const common = firstLine(join5(gitDir, GIT_COMMONDIR_FILE));
15806
+ const common = firstLine(join6(gitDir, GIT_COMMONDIR_FILE));
15705
15807
  return { commonDir: realpathSync3.native(common === null ? gitDir : resolve4(gitDir, common)), worktree: cur, start };
15706
15808
  }
15707
15809
  const up = dirname3(cur);
@@ -15722,12 +15824,12 @@ function gitDirAt(dotGit) {
15722
15824
  } catch {
15723
15825
  return null;
15724
15826
  }
15725
- return existsSync(join5(gitDir, GIT_HEAD_FILE)) ? gitDir : null;
15827
+ return existsSync2(join6(gitDir, GIT_HEAD_FILE)) ? gitDir : null;
15726
15828
  }
15727
15829
  function firstLine(file2) {
15728
15830
  let text;
15729
15831
  try {
15730
- text = readFileSync3(file2, "utf8");
15832
+ text = readFileSync4(file2, "utf8");
15731
15833
  } catch {
15732
15834
  return null;
15733
15835
  }
@@ -15763,11 +15865,11 @@ function resolveProject(agent, src) {
15763
15865
  return key;
15764
15866
  },
15765
15867
  get projectDir() {
15766
- pdir ??= join5(resolveConfigDir(process.env), PROJECTS_DIR_NAME, this.projectKey);
15868
+ pdir ??= join6(resolveConfigDir(process.env), PROJECTS_DIR_NAME, this.projectKey);
15767
15869
  return pdir;
15768
15870
  },
15769
15871
  get dbPath() {
15770
- return join5(this.projectDir, DB_FILE_NAME);
15872
+ return join6(this.projectDir, DB_FILE_NAME);
15771
15873
  },
15772
15874
  worktree,
15773
15875
  get containmentRoot() {
@@ -15918,7 +16020,7 @@ function openReadOnlyHandle(sqlite, path8, opts = {}) {
15918
16020
  }
15919
16021
 
15920
16022
  // src/core/store/db.ts
15921
- var { existsSync: existsSync2, linkSync, mkdirSync: mkdirSync2, rmSync } = process.getBuiltinModule("node:fs");
16023
+ var { existsSync: existsSync3, linkSync, mkdirSync: mkdirSync2, rmSync } = process.getBuiltinModule("node:fs");
15922
16024
  function versionParts(v) {
15923
16025
  const bare2 = v.startsWith("v") ? v.slice(1) : v;
15924
16026
  return bare2.split(".").map((p) => Number.parseInt(p, 10));
@@ -15972,7 +16074,7 @@ function createAtomically(sqlite, path8) {
15972
16074
  function openWritable(sqlite, path8) {
15973
16075
  let raw = null;
15974
16076
  try {
15975
- if (!existsSync2(path8)) createAtomically(sqlite, path8);
16077
+ if (!existsSync3(path8)) createAtomically(sqlite, path8);
15976
16078
  raw = new sqlite.DatabaseSync(path8, { timeout: DB_TIMEOUT_MS });
15977
16079
  applyMigrations(raw, readUserVersion(raw));
15978
16080
  return raw;
@@ -15997,14 +16099,14 @@ async function openDb(project, opts) {
15997
16099
  const sqlite = await loadSqlite();
15998
16100
  mkdirSync2(project.projectDir, { recursive: true });
15999
16101
  const path8 = project.dbPath;
16000
- const sibling = existsSync2(path8 + DB_WAL_SUFFIX) || existsSync2(path8 + DB_SHM_SUFFIX);
16001
- if (sibling && !existsSync2(path8)) {
16102
+ const sibling = existsSync3(path8 + DB_WAL_SUFFIX) || existsSync3(path8 + DB_SHM_SUFFIX);
16103
+ if (sibling && !existsSync3(path8)) {
16002
16104
  throw new CtxError("DB_GONE");
16003
16105
  }
16004
16106
  try {
16005
16107
  let raw;
16006
16108
  if (opts?.readOnly === true) {
16007
- if (!existsSync2(path8)) openWritable(sqlite, path8).close();
16109
+ if (!existsSync3(path8)) openWritable(sqlite, path8).close();
16008
16110
  raw = openReadOnly(sqlite, path8);
16009
16111
  } else {
16010
16112
  raw = openWritable(sqlite, path8);
@@ -16154,11 +16256,6 @@ function readLastPrompt(db, sessionId) {
16154
16256
  const row5 = db.raw.prepare("SELECT body FROM events WHERE session_id = ? AND kind = 'prompt' ORDER BY seq DESC LIMIT 1").get(sessionId);
16155
16257
  return row5 === void 0 ? "" : row5.body;
16156
16258
  }
16157
- function readFirstPrompt(db, sessionId) {
16158
- if (sessionId === "") return "";
16159
- const row5 = db.raw.prepare("SELECT body FROM events WHERE session_id = ? AND kind = 'prompt' ORDER BY seq ASC LIMIT 1").get(sessionId);
16160
- return row5 === void 0 ? "" : row5.body;
16161
- }
16162
16259
  function readRecallRows(db, sessionId, worktree, limit) {
16163
16260
  if (sessionId === "") return [];
16164
16261
  return db.raw.prepare("SELECT * FROM events WHERE kind <> 'cost' AND (session_id = ? OR worktree = ?) ORDER BY seq DESC LIMIT ?").all(sessionId, worktree, limit);
@@ -18726,8 +18823,25 @@ function insertUnits(db, sourceId, sessionId, units) {
18726
18823
  start = end;
18727
18824
  }
18728
18825
  }
18729
- function recallQueryText(prompt, goal) {
18730
- return goal === prompt ? prompt : prompt + " " + goal;
18826
+ function recallQueryText(prompt) {
18827
+ const kept = /* @__PURE__ */ new Set();
18828
+ const all = /* @__PURE__ */ new Set();
18829
+ const add = (w) => {
18830
+ if (all.size < RECALL_QUERY_MAX_TERMS) all.add(w);
18831
+ if (!STOPWORDS.has(w.toLowerCase())) kept.add(w);
18832
+ };
18833
+ let cur = "";
18834
+ for (const ch of prompt) {
18835
+ if (kept.size >= RECALL_QUERY_MAX_TERMS) break;
18836
+ if (ch.trim() === "" || ch === "\0") {
18837
+ if (cur !== "") add(cur);
18838
+ cur = "";
18839
+ } else {
18840
+ cur += ch;
18841
+ }
18842
+ }
18843
+ if (cur !== "" && kept.size < RECALL_QUERY_MAX_TERMS) add(cur);
18844
+ return [...kept.size > 0 ? kept : all].join(" ");
18731
18845
  }
18732
18846
  function queryUnits(db, sessionId, q, limit) {
18733
18847
  const match = searchTerms(q).join(" OR ");
@@ -19316,7 +19430,7 @@ function cutPoint(src, start, end, scratch) {
19316
19430
  const r = encoder.encodeInto(src.slice(start, limit), scratch);
19317
19431
  return { end: start + r.read, written: r.written };
19318
19432
  }
19319
- function merge2(src, blocks, join26, cap, lineCut) {
19433
+ function merge2(src, blocks, join27, cap, lineCut) {
19320
19434
  const out = [];
19321
19435
  const scratch = new Uint8Array(cap);
19322
19436
  let wide;
@@ -19326,7 +19440,7 @@ function merge2(src, blocks, join26, cap, lineCut) {
19326
19440
  out.push({ ord: out.length, text: src.slice(start, end), bytes: bytes5 });
19327
19441
  };
19328
19442
  for (const b of blocks) {
19329
- if (cur !== void 0 && !join26) {
19443
+ if (cur !== void 0 && !join27) {
19330
19444
  emit(cur.start, cur.end, curBytes);
19331
19445
  cur = void 0;
19332
19446
  }
@@ -19768,7 +19882,7 @@ function shouldHint(db, sessionId, onceKey, everyN) {
19768
19882
  }
19769
19883
 
19770
19884
  // src/core/hooks/fallback.ts
19771
- import { join as join6, resolve as resolve5 } from "node:path";
19885
+ import { join as join7, resolve as resolve5 } from "node:path";
19772
19886
  var fs = process.getBuiltinModule("node:fs");
19773
19887
  function isRec(v) {
19774
19888
  return typeof v === "object" && v !== null && !Array.isArray(v);
@@ -19796,9 +19910,9 @@ function homeOf(env) {
19796
19910
  }
19797
19911
  function hookLogPath(env) {
19798
19912
  const dir = env[DATA_DIR_ENV];
19799
- if (dir !== void 0 && dir !== "") return join6(dataRootOf(env, ""), HOOK_ERROR_LOG_FILE);
19913
+ if (dir !== void 0 && dir !== "") return join7(dataRootOf(env, ""), HOOK_ERROR_LOG_FILE);
19800
19914
  const home = homeOf(env);
19801
- return home === "" ? "" : join6(dataRootOf(env, home), HOOK_ERROR_LOG_FILE);
19915
+ return home === "" ? "" : join7(dataRootOf(env, home), HOOK_ERROR_LOG_FILE);
19802
19916
  }
19803
19917
  function errorLabel(err) {
19804
19918
  const code = isRec(err) ? err.code : void 0;
@@ -19809,7 +19923,7 @@ function logHookError(env, agent, stage, err) {
19809
19923
  try {
19810
19924
  const file2 = hookLogPath(env);
19811
19925
  if (file2 === "") return;
19812
- fs.mkdirSync(join6(file2, ".."), { recursive: true });
19926
+ fs.mkdirSync(join7(file2, ".."), { recursive: true });
19813
19927
  const line = JSON.stringify({
19814
19928
  ts: (/* @__PURE__ */ new Date()).toISOString(),
19815
19929
  agent,
@@ -19891,7 +20005,7 @@ function bigFile(abs) {
19891
20005
  function bigRead(agent, input, cwd) {
19892
20006
  if ((input.offset ?? null) !== null || (input.limit ?? null) !== null) return false;
19893
20007
  const many = Array.isArray(input[READ_PATH_LIST_KEY]) ? input[READ_PATH_LIST_KEY].filter((x) => typeof x === "string") : [];
19894
- return [firstString(input, READ_PATH_KEYS), ...many].some((p) => p !== "" && bigFile(resolve5(cwd, p)) && !isMediaRead(agent, resolve5(cwd, p)));
20008
+ return [firstString(input, READ_PATH_KEYS), ...many].some((p) => p !== "" && bigFile(resolve5(cwd, p)) && !isMediaRead(agent, resolve5(cwd, p)) && !isOwnFile(agent, resolve5(cwd, p)));
19895
20009
  }
19896
20010
  function failureOutput(agent, raw, err, cwdFallback = "") {
19897
20011
  const row5 = getAdapter(agent);
@@ -19917,7 +20031,7 @@ function failureOutput(agent, raw, err, cwdFallback = "") {
19917
20031
  var { read: read2, writeSync } = process.getBuiltinModule("node:fs");
19918
20032
 
19919
20033
  // src/core/hooks/dispatch.ts
19920
- var { lstatSync: lstatSync2, readFileSync: readFileSync4 } = process.getBuiltinModule("node:fs");
20034
+ var { lstatSync: lstatSync2, readFileSync: readFileSync5 } = process.getBuiltinModule("node:fs");
19921
20035
  var ALLOW2 = { kind: "allow" };
19922
20036
  var EMPTY5 = { stdout: "", exitCode: 0 };
19923
20037
  var DIGIT_0 = 48;
@@ -20080,8 +20194,7 @@ async function recall(ev, row5, project, prompt) {
20080
20194
  const seen = seenSeqs(metaGet(db, seenKey));
20081
20195
  const unitsKey = RECALL_UNITS_SEEN_META_PREFIX + ev.sessionId;
20082
20196
  const seenUnits = seenUnitKeys(metaGet(db, unitsKey));
20083
- const goal = readFirstPrompt(db, ev.sessionId);
20084
- const units = queryUnits(db, ev.sessionId, recallQueryText(prompt, goal), RECALL_UNIT_CANDIDATES);
20197
+ const units = queryUnits(db, ev.sessionId, recallQueryText(prompt), RECALL_UNIT_CANDIDATES);
20085
20198
  const picked = pickRecall(readRecallRows(db, ev.sessionId, project.worktree, RECALL_MAX_ROWS), prompt, new Set(seen), units, new Set(seenUnits));
20086
20199
  if (picked.text === "") return ALLOW2;
20087
20200
  if (picked.seqs.length > 0) metaSet(db, seenKey, JSON.stringify([...seen, ...picked.seqs]));
@@ -20153,7 +20266,7 @@ function askDetached(ev, project, tool, text) {
20153
20266
  }
20154
20267
  async function preToolUse(ev, row5, project, env) {
20155
20268
  const userDeny = readUserDeny(project.worktree, ev.agent);
20156
- const decision0 = decide(ev, row5, userDeny);
20269
+ const decision0 = decide(ev, row5, userDeny, project);
20157
20270
  let decision = decision0;
20158
20271
  if (decision0.kind === "deny" && isSubagentCall(ev) && !isUserPolicyDeny(decision0.reason, row5)) {
20159
20272
  const set3 = toolSetForAgentType(ev, { projectDir: project.worktree, env });
@@ -20179,7 +20292,7 @@ function caseB(ev, row5, d0, userDeny) {
20179
20292
  if (tool === void 0 || !isShell(tool, row5) || isUserPolicyDeny(d0.reason, row5)) return d0;
20180
20293
  const command = tool.input.command;
20181
20294
  if (typeof command !== "string") return d0;
20182
- const wrapper = '"' + join7(dirname4(process.argv[1] ?? ""), RUN_WRAPPER_FILE) + '"';
20295
+ const wrapper = '"' + join8(dirname4(process.argv[1] ?? ""), RUN_WRAPPER_FILE) + '"';
20183
20296
  const rewritten = [RUN_WRAPPER_NODE, wrapper, b64(command), b64(JSON.stringify(userDeny ?? [])), b64(str2(tool.input.description))].join(" ");
20184
20297
  return { kind: "deny", reason: SUBAGENT_RUN_DENY, rewritten };
20185
20298
  }
@@ -20256,9 +20369,15 @@ async function postToolUse(ev, row5, project, env, settle3) {
20256
20369
  settle3.run = (encoded) => journal(encoded && decided.kind === "replace" ? Buffer.byteLength(decided.output) : result.bytes);
20257
20370
  return decision;
20258
20371
  }
20372
+ function ownRead(ev, tool, env) {
20373
+ if (!RANGE_READ_TOOLS.includes(tool.canonicalName)) return false;
20374
+ const p = READ_PATH_KEYS.map((k) => tool.input[k]).find((v) => typeof v === "string" && v !== "");
20375
+ return p !== void 0 && isOwnFile(ev.agent, resolve6(ev.cwd, p), env);
20376
+ }
20259
20377
  async function postReplace(ev, row5, project, env, tool, result, text) {
20260
20378
  if (result.bytes <= REPLACE_TRIGGER_BYTES) return ALLOW2;
20261
20379
  if (boundedRead(tool)) return ALLOW2;
20380
+ if (ownRead(ev, tool, env)) return ALLOW2;
20262
20381
  if (result.keep === true) return ALLOW2;
20263
20382
  if (!hasReplace(row5)) return ALLOW2;
20264
20383
  let label2;
@@ -20301,7 +20420,7 @@ function replaceBudget(handleLine, more) {
20301
20420
  }
20302
20421
  function hostToolResult(file2, sessionId, env) {
20303
20422
  if (sessionId === "" || sessionId.includes(sep3) || sessionId.includes("/")) return false;
20304
- const projects = join7(claudeDirOf(env, homeDirOf(env) ?? ""), PROJECTS_DIR_NAME);
20423
+ const projects = join8(claudeDirOf(env, homeDirOf(env) ?? ""), PROJECTS_DIR_NAME);
20305
20424
  const steps = relative3(projects, resolve6(file2)).split(sep3);
20306
20425
  if (steps.length !== 4 || steps.includes("..") || steps.includes("")) return false;
20307
20426
  if (steps[1] !== sessionId || steps[2] !== CLAUDE_TOOL_RESULTS_DIR_NAME) return false;
@@ -20316,7 +20435,7 @@ function wholeOutput(result, sessionId, env) {
20316
20435
  logHookError(env, "claude-code", "persisted-output", new Error("persisted output path is outside this session's tool-results dir or too large; kept the head"));
20317
20436
  return head2;
20318
20437
  }
20319
- return readFileSync4(result.persistedPath, "utf8");
20438
+ return readFileSync5(result.persistedPath, "utf8");
20320
20439
  } catch {
20321
20440
  return head2;
20322
20441
  }
@@ -20602,8 +20721,8 @@ function runProcess(argv, o) {
20602
20721
  }
20603
20722
 
20604
20723
  // src/core/index/auto-memory.ts
20605
- import { readdirSync, readFileSync as readFileSync5, statSync as statSync4 } from "node:fs";
20606
- import { join as join8 } from "node:path";
20724
+ import { readdirSync as readdirSync2, readFileSync as readFileSync6, statSync as statSync4 } from "node:fs";
20725
+ import { join as join9 } from "node:path";
20607
20726
  var MEMORY_FILES = Object.freeze([
20608
20727
  Object.freeze(["CLAUDE.md"]),
20609
20728
  Object.freeze(["CLAUDE.local.md"]),
@@ -20617,7 +20736,7 @@ var KIRO_STEERING = Object.freeze([".kiro", "steering"]);
20617
20736
  var MD = ".md";
20618
20737
  function steeringFiles(worktree) {
20619
20738
  try {
20620
- return readdirSync(join8(worktree, ...KIRO_STEERING)).filter((n) => n.endsWith(MD)).sort().map((n) => [...KIRO_STEERING, n]);
20739
+ return readdirSync2(join9(worktree, ...KIRO_STEERING)).filter((n) => n.endsWith(MD)).sort().map((n) => [...KIRO_STEERING, n]);
20621
20740
  } catch {
20622
20741
  return [];
20623
20742
  }
@@ -20625,7 +20744,7 @@ function steeringFiles(worktree) {
20625
20744
  function readAutoMemory(project) {
20626
20745
  const rows = [];
20627
20746
  for (const segs of [...MEMORY_FILES, ...steeringFiles(project.worktree)]) {
20628
- const path8 = join8(project.worktree, ...segs);
20747
+ const path8 = join9(project.worktree, ...segs);
20629
20748
  if (!isInside(project.worktree, path8)) continue;
20630
20749
  try {
20631
20750
  const st = statSync4(path8);
@@ -20637,7 +20756,7 @@ function readAutoMemory(project) {
20637
20756
  sourceId: null,
20638
20757
  path: path8,
20639
20758
  label: segs.join("/"),
20640
- text: readFileSync5(path8, "utf8")
20759
+ text: readFileSync6(path8, "utf8")
20641
20760
  });
20642
20761
  } catch {
20643
20762
  }
@@ -21207,19 +21326,19 @@ var ctxBatch = Object.freeze({
21207
21326
  });
21208
21327
 
21209
21328
  // src/core/tools/doctor.ts
21210
- import { readdirSync as readdirSync6, readFileSync as readFileSync14, existsSync as existsSync15 } from "node:fs";
21211
- import { basename as basename5, join as join18 } from "node:path";
21329
+ import { readdirSync as readdirSync7, readFileSync as readFileSync15, existsSync as existsSync16 } from "node:fs";
21330
+ import { basename as basename5, join as join19 } from "node:path";
21212
21331
 
21213
21332
  // src/core/ops/bundle-dir.ts
21214
- import { existsSync as existsSync3 } from "node:fs";
21215
- import { dirname as dirname5, join as join9 } from "node:path";
21333
+ import { existsSync as existsSync4 } from "node:fs";
21334
+ import { dirname as dirname5, join as join10 } from "node:path";
21216
21335
  import { fileURLToPath } from "node:url";
21217
21336
  function bundleDirOf(argv1, moduleFile) {
21218
21337
  const own4 = dirname5(argv1);
21219
- if (existsSync3(join9(own4, SERVER_ENTRY_FILE))) return own4;
21338
+ if (existsSync4(join10(own4, SERVER_ENTRY_FILE))) return own4;
21220
21339
  let dir = dirname5(moduleFile);
21221
21340
  for (; ; ) {
21222
- if (existsSync3(join9(dir, SERVER_ENTRY_FILE))) return dir;
21341
+ if (existsSync4(join10(dir, SERVER_ENTRY_FILE))) return dir;
21223
21342
  const up = dirname5(dir);
21224
21343
  if (up === dir) return own4;
21225
21344
  dir = up;
@@ -21233,17 +21352,17 @@ function ownBundleDir() {
21233
21352
  }
21234
21353
 
21235
21354
  // src/core/ops/doctor-config.ts
21236
- import { existsSync as existsSync8, readdirSync as readdirSync4 } from "node:fs";
21237
- import { join as join13 } from "node:path";
21355
+ import { existsSync as existsSync9, readdirSync as readdirSync5 } from "node:fs";
21356
+ import { join as join14 } from "node:path";
21238
21357
 
21239
21358
  // src/core/ops/detect-v1.ts
21240
- import { existsSync as existsSync5, opendirSync, readdirSync as readdirSync2, readFileSync as readFileSync7 } from "node:fs";
21359
+ import { existsSync as existsSync6, opendirSync, readdirSync as readdirSync3, readFileSync as readFileSync8 } from "node:fs";
21241
21360
  import { tmpdir } from "node:os";
21242
- import { join as join11 } from "node:path";
21361
+ import { join as join12 } from "node:path";
21243
21362
 
21244
21363
  // src/core/ops/host-config.ts
21245
- import { existsSync as existsSync4, readFileSync as readFileSync6 } from "node:fs";
21246
- import { dirname as dirname6, join as join10 } from "node:path";
21364
+ import { existsSync as existsSync5, readFileSync as readFileSync7 } from "node:fs";
21365
+ import { dirname as dirname6, join as join11 } from "node:path";
21247
21366
 
21248
21367
  // node_modules/eslint-visitor-keys/lib/visitor-keys.js
21249
21368
  var KEYS2 = {
@@ -23360,10 +23479,10 @@ function formatOf(path8) {
23360
23479
  function readHostConfig(agent, path8) {
23361
23480
  let file2 = path8;
23362
23481
  if (agent === "opencode") {
23363
- const jsonc = join10(dirname6(path8), OPENCODE_CONFIG_FILES[0]);
23364
- if (existsSync4(jsonc)) file2 = jsonc;
23482
+ const jsonc = join11(dirname6(path8), OPENCODE_CONFIG_FILES[0]);
23483
+ if (existsSync5(jsonc)) file2 = jsonc;
23365
23484
  }
23366
- const raw = existsSync4(file2) ? readFileSync6(file2, "utf8") : "";
23485
+ const raw = existsSync5(file2) ? readFileSync7(file2, "utf8") : "";
23367
23486
  return { agent, text: hostText(raw), format: agent === "opencode" && !file2.endsWith(TOML_EXT) ? "jsonc" : formatOf(file2), path: file2, layout: hostLayout(raw) };
23368
23487
  }
23369
23488
  function stripJsonComments(text) {
@@ -23708,7 +23827,7 @@ function setText(agent, path8, text, format, key, value) {
23708
23827
  }
23709
23828
  }
23710
23829
  function serverScript() {
23711
- return join10(dirname6(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
23830
+ return join11(dirname6(process.argv[1] ?? ""), SERVER_ENTRY_FILE);
23712
23831
  }
23713
23832
  function isNodeCommand(command) {
23714
23833
  if (typeof command !== "string") return false;
@@ -23835,14 +23954,14 @@ function stripJsonc(text) {
23835
23954
  }
23836
23955
  function readJson(file2) {
23837
23956
  try {
23838
- return JSON.parse(stripJsonc(hostText(readFileSync7(file2, "utf8"))));
23957
+ return JSON.parse(stripJsonc(hostText(readFileSync8(file2, "utf8"))));
23839
23958
  } catch {
23840
23959
  return void 0;
23841
23960
  }
23842
23961
  }
23843
23962
  function readText(file2) {
23844
23963
  try {
23845
- return hostText(readFileSync7(file2, "utf8"));
23964
+ return hostText(readFileSync8(file2, "utf8"));
23846
23965
  } catch {
23847
23966
  return "";
23848
23967
  }
@@ -23899,7 +24018,7 @@ function flatCommands(events, prefix) {
23899
24018
  var isV1Hook = (cmd) => cmd.includes(SERVER_KEY) && (V1_SCRIPT_NAMES.some((name) => cmd.includes(name)) || cmd.includes(V1_HOOK_COMMAND));
23900
24019
  var isCodexScript = (cmd) => cmd.includes(V1_SCRIPT_EXT) && V1_PATH_SEPS.some((sep5) => cmd.includes(V1_CODEX_HOOKS_DIR.join(sep5) + sep5));
23901
24020
  function dataDir(dir, reason, out) {
23902
- if (existsSync5(dir)) out.push(finding(dir, "", reason));
24021
+ if (existsSync6(dir)) out.push(finding(dir, "", reason));
23903
24022
  }
23904
24023
  function mcpEntry(file2, doc, out) {
23905
24024
  if (isObj(doc) && isObj(doc[MCP_SERVERS_KEY]) && Object.hasOwn(doc[MCP_SERVERS_KEY], SERVER_KEY)) {
@@ -23907,7 +24026,7 @@ function mcpEntry(file2, doc, out) {
23907
24026
  }
23908
24027
  }
23909
24028
  function claudeShapeSettings(agentHome, out) {
23910
- const file2 = join11(agentHome, SETTINGS_FILE);
24029
+ const file2 = join12(agentHome, SETTINGS_FILE);
23911
24030
  const doc = readJson(file2);
23912
24031
  for (const c of nestedCommands(doc)) {
23913
24032
  if (c.command.includes(V1_CACHE_HEAL_NAME)) out.push(finding(file2, c.path, V1_REASON.cacheHealHook));
@@ -23927,63 +24046,64 @@ function v1HookFile(file2, out) {
23927
24046
  function scanClaudeCode(home, agentHome, out) {
23928
24047
  claudeShapeSettings(agentHome, out);
23929
24048
  for (const ext of V1_CACHE_HEAL_EXTS) {
23930
- const file2 = join11(agentHome, V1_HOOKS_DIR_NAME, V1_CACHE_HEAL_NAME + ext);
23931
- if (existsSync5(file2)) out.push(finding(file2, "", V1_REASON.cacheHealFile));
24049
+ const file2 = join12(agentHome, V1_HOOKS_DIR_NAME, V1_CACHE_HEAL_NAME + ext);
24050
+ if (existsSync6(file2)) out.push(finding(file2, "", V1_REASON.cacheHealFile));
23932
24051
  }
23933
- const userFile = join11(home, CLAUDE_USER_CONFIG_FILE);
24052
+ const userFile = join12(home, CLAUDE_USER_CONFIG_FILE);
23934
24053
  mcpEntry(userFile, readJson(userFile), out);
23935
- dataDir(join11(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
24054
+ dataDir(join12(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23936
24055
  }
23937
24056
  function scanCodex(agentHome, out) {
23938
- const hooksFile = join11(agentHome, HOOKS_JSON_FILE);
24057
+ const hooksFile = join12(agentHome, HOOKS_JSON_FILE);
23939
24058
  for (const c of nestedCommands(readJson(hooksFile))) {
23940
24059
  if (c.command.includes(V1_CODEX_HOOK_COMMAND) || isCodexScript(c.command)) {
23941
24060
  out.push(finding(hooksFile, c.path, V1_REASON.codexHook));
23942
24061
  }
23943
24062
  }
23944
- const tomlFile = join11(agentHome, CONFIG_TOML_FILE);
24063
+ const tomlFile = join12(agentHome, CONFIG_TOML_FILE);
23945
24064
  const config4 = readTomlValue(tomlFile);
23946
24065
  for (const span2 of readTomlTables(tomlFile)) {
23947
24066
  if (span2.path[0] !== V1_TOML_SECTION_ROOT || span2.path[1] !== SERVER_KEY) continue;
23948
24067
  if (span2.path.length === 2 && isV2McpTable(hostConfigValueAt(config4, span2.path))) continue;
24068
+ if (span2.path.length === 3 && span2.path[2] === MCP_ENV_FIELD && isV2McpTable(hostConfigValueAt(config4, span2.path.slice(0, 2)))) continue;
23949
24069
  out.push(finding(tomlFile, span2.header.trim(), V1_REASON.codexToml));
23950
24070
  }
23951
- dataDir(join11(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
24071
+ dataDir(join12(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
23952
24072
  }
23953
24073
  function scanGemini(agentHome, out) {
23954
- const file2 = join11(agentHome, SETTINGS_FILE);
24074
+ const file2 = join12(agentHome, SETTINGS_FILE);
23955
24075
  for (const c of nestedCommands(readJson(file2))) {
23956
24076
  if (c.command.includes(SERVER_KEY)) out.push(finding(file2, c.path, V1_REASON.hook));
23957
24077
  }
23958
- dataDir(join11(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDirShared, out);
24078
+ dataDir(join12(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDirShared, out);
23959
24079
  }
23960
24080
  function scanVscode(agentHome, project, out) {
23961
24081
  if (project !== void 0) {
23962
- v1HookFile(join11(project, GITHUB_DIR_NAME, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
23963
- const mcpFile2 = join11(project, VSCODE_DIR_NAME, VSCODE_MCP_FILE);
24082
+ v1HookFile(join12(project, GITHUB_DIR_NAME, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
24083
+ const mcpFile2 = join12(project, VSCODE_DIR_NAME, VSCODE_MCP_FILE);
23964
24084
  const doc = readJson(mcpFile2);
23965
24085
  const servers = isObj(doc) && isObj(doc[VSCODE_MCP_SERVERS_KEY]) ? doc[VSCODE_MCP_SERVERS_KEY] : {};
23966
24086
  const entry = Object.hasOwn(servers, SERVER_KEY) ? servers[SERVER_KEY] : void 0;
23967
24087
  if (isObj(entry) && (entry.command === V1_BIN_COMMAND || listOf(entry.args).some((a) => a === V1_BIN_COMMAND))) {
23968
24088
  out.push(finding(mcpFile2, keyPath(VSCODE_MCP_SERVERS_KEY, SERVER_KEY), V1_REASON.vscodeMcp));
23969
24089
  }
23970
- const sessions = join11(project, GITHUB_DIR_NAME, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME);
24090
+ const sessions = join12(project, GITHUB_DIR_NAME, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME);
23971
24091
  dataDir(sessions, reachedThroughLink(project, sessions) ? V1_REASON.projectLink : V1_REASON.dataDir, out);
23972
24092
  }
23973
- dataDir(join11(agentHome, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
24093
+ dataDir(join12(agentHome, V1_DATA_DIR_NAME, V1_SESSIONS_DIR_NAME), V1_REASON.dataDir, out);
23974
24094
  }
23975
24095
  function jsonFiles(dir) {
23976
24096
  try {
23977
- return readdirSync2(dir).filter((name) => name.endsWith(KIRO_AGENT_FILE_EXT)).sort();
24097
+ return readdirSync3(dir).filter((name) => name.endsWith(KIRO_AGENT_FILE_EXT)).sort();
23978
24098
  } catch {
23979
24099
  return [];
23980
24100
  }
23981
24101
  }
23982
24102
  function scanKiro(agentHome, project, out) {
23983
- const agentsDir = join11(agentHome, KIRO_AGENTS_DIR);
23984
- const defaultFile = join11(agentHome, ...KIRO_AGENT_FILE);
24103
+ const agentsDir = join12(agentHome, KIRO_AGENTS_DIR);
24104
+ const defaultFile = join12(agentHome, ...KIRO_AGENT_FILE);
23985
24105
  for (const name of jsonFiles(agentsDir)) {
23986
- const file2 = join11(agentsDir, name);
24106
+ const file2 = join12(agentsDir, name);
23987
24107
  const doc = readJson(file2);
23988
24108
  if (isObj(doc) && doc[KIRO_AGENT_NAME_KEY] === SERVER_KEY) {
23989
24109
  out.push(finding(file2, "", V1_REASON.kiroAgentFile));
@@ -23994,31 +24114,31 @@ function scanKiro(agentHome, project, out) {
23994
24114
  if (isV1Hook(c.command)) out.push(finding(file2, c.path, V1_REASON.kiroHook));
23995
24115
  }
23996
24116
  }
23997
- const steeringDocs = [join11(agentHome, ...KIRO_STEERING_FILE)];
23998
- if (project !== void 0) steeringDocs.push(join11(project, ...AGENT_HOME_DIR.kiro, ...KIRO_STEERING_FILE));
24117
+ const steeringDocs = [join12(agentHome, ...KIRO_STEERING_FILE)];
24118
+ if (project !== void 0) steeringDocs.push(join12(project, ...AGENT_HOME_DIR.kiro, ...KIRO_STEERING_FILE));
23999
24119
  for (const file2 of steeringDocs) {
24000
- if (existsSync5(file2)) out.push(finding(file2, "", V1_REASON.kiroSteering));
24120
+ if (existsSync6(file2)) out.push(finding(file2, "", V1_REASON.kiroSteering));
24001
24121
  }
24002
- dataDir(join11(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
24122
+ dataDir(join12(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
24003
24123
  }
24004
24124
  function piNpmIsCurrent(piAgentDir) {
24005
- const doc = readJson(join11(piAgentDir, PI_NPM_DIR, PI_NODE_MODULES_DIR, SERVER_KEY, PI_PACKAGE_JSON_FILE));
24125
+ const doc = readJson(join12(piAgentDir, PI_NPM_DIR, PI_NODE_MODULES_DIR, SERVER_KEY, PI_PACKAGE_JSON_FILE));
24006
24126
  const version4 = isObj(doc) && typeof doc.version === "string" ? doc.version : "";
24007
24127
  return Number.parseInt(version4, 10) >= PI_CURRENT_MAJOR;
24008
24128
  }
24009
24129
  function scanPi(piAgentDir, agentHome, out) {
24010
- const file2 = join11(piAgentDir, SETTINGS_FILE);
24130
+ const file2 = join12(piAgentDir, SETTINGS_FILE);
24011
24131
  const doc = readJson(file2);
24012
24132
  listOf(isObj(doc) ? doc[PI_PACKAGES_KEY] : void 0).forEach((pkg, i) => {
24013
24133
  const spec = isObj(pkg) ? pkg[PI_PACKAGE_SOURCE_KEY] : pkg;
24014
24134
  if (spec === V1_PI_PACKAGE && !piNpmIsCurrent(piAgentDir)) out.push(finding(file2, keyPath(PI_PACKAGES_KEY, i), V1_REASON.piNpm));
24015
24135
  if (spec === PI_GIT_PACKAGE) out.push(finding(file2, keyPath(PI_PACKAGES_KEY, i), V1_REASON.piGit));
24016
24136
  });
24017
- dataDir(join11(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
24137
+ dataDir(join12(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
24018
24138
  }
24019
24139
  function scanOpencode(agentHome, out) {
24020
24140
  for (const name of OPENCODE_CONFIG_FILES) {
24021
- const file2 = join11(agentHome, name);
24141
+ const file2 = join12(agentHome, name);
24022
24142
  const doc = readJson(file2);
24023
24143
  if (!isObj(doc) || !Array.isArray(doc[OPENCODE_PLUGIN_KEY])) continue;
24024
24144
  doc[OPENCODE_PLUGIN_KEY].forEach((spec, i) => {
@@ -24029,13 +24149,13 @@ function scanOpencode(agentHome, out) {
24029
24149
  }
24030
24150
  }
24031
24151
  function scanZcode(agentHome, out) {
24032
- const configFile = join11(agentHome, ZCODE_CLI_DIR, CONFIG_JSON_FILE);
24152
+ const configFile = join12(agentHome, ZCODE_CLI_DIR, CONFIG_JSON_FILE);
24033
24153
  const config4 = readJson(configFile);
24034
24154
  const events = isObj(config4) && isObj(config4[HOOKS_KEY]) ? config4[HOOKS_KEY][ZCODE_EVENTS_KEY] : void 0;
24035
24155
  for (const c of flatCommands(events, [HOOKS_KEY, ZCODE_EVENTS_KEY])) {
24036
24156
  if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(configFile, c.path, V1_REASON.zcodeHook));
24037
24157
  }
24038
- const hooksFile = join11(agentHome, ZCODE_CLI_DIR, HOOKS_JSON_FILE);
24158
+ const hooksFile = join12(agentHome, ZCODE_CLI_DIR, HOOKS_JSON_FILE);
24039
24159
  for (const c of nestedCommands(readJson(hooksFile))) {
24040
24160
  if (c.command.includes(V1_HOOK_COMMAND)) out.push(finding(hooksFile, c.path, V1_REASON.zcodeHook));
24041
24161
  }
@@ -24059,14 +24179,14 @@ function firstTmpMatch(dir) {
24059
24179
  }
24060
24180
  }
24061
24181
  function scanAll(home, tmp, out) {
24062
- const root = join11(home, DATA_ROOT.slice(1));
24063
- for (const name of V1_DATA_ROOT_ENTRIES) dataDir(join11(root, name), V1_REASON.dataRoot, out);
24182
+ const root = join12(home, DATA_ROOT.slice(1));
24183
+ for (const name of V1_DATA_ROOT_ENTRIES) dataDir(join12(root, name), V1_REASON.dataRoot, out);
24064
24184
  if (firstTmpMatch(tmp) !== null) out.push(finding(tmp, V1_TMP_PREFIX + "*", V1_REASON.tmpFile));
24065
24185
  }
24066
24186
  function detectV1(agent, home, scope = {}) {
24067
24187
  const out = [];
24068
24188
  const project = scope.project;
24069
- 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 : join11(home, ...AGENT_HOME_DIR[agent]);
24189
+ 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 : join12(home, ...AGENT_HOME_DIR[agent]);
24070
24190
  switch (agent) {
24071
24191
  case "claude-code":
24072
24192
  scanClaudeCode(home, agentHome, out);
@@ -24079,11 +24199,11 @@ function detectV1(agent, home, scope = {}) {
24079
24199
  break;
24080
24200
  case "qwen":
24081
24201
  claudeShapeSettings(agentHome, out);
24082
- dataDir(join11(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
24202
+ dataDir(join12(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
24083
24203
  break;
24084
24204
  case "copilot-cli":
24085
- v1HookFile(join11(agentHome, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
24086
- dataDir(join11(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
24205
+ v1HookFile(join12(agentHome, V1_HOOKS_DIR_NAME, OWN_HOOK_FILE), out);
24206
+ dataDir(join12(agentHome, V1_DATA_DIR_NAME), V1_REASON.dataDir, out);
24087
24207
  break;
24088
24208
  case "vscode":
24089
24209
  scanVscode(agentHome, project, out);
@@ -24092,7 +24212,7 @@ function detectV1(agent, home, scope = {}) {
24092
24212
  scanKiro(agentHome, project, out);
24093
24213
  break;
24094
24214
  case "pi":
24095
- scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir : join11(agentHome, PI_AGENT_DIR), agentHome, out);
24215
+ scanPi(scope.piAgentDir !== void 0 && scope.piAgentDir !== "" ? scope.piAgentDir : join12(agentHome, PI_AGENT_DIR), agentHome, out);
24096
24216
  break;
24097
24217
  // D-WIN-PIDIR-1: empty is unset
24098
24218
  case "opencode":
@@ -24107,8 +24227,8 @@ function detectV1(agent, home, scope = {}) {
24107
24227
  }
24108
24228
 
24109
24229
  // src/core/ops/plugin-root.ts
24110
- import { existsSync as existsSync6, readdirSync as readdirSync3, readFileSync as readFileSync8, realpathSync as realpathSync4 } from "node:fs";
24111
- import { dirname as dirname7, isAbsolute as isAbsolute2, join as join12, sep as sep4 } from "node:path";
24230
+ import { existsSync as existsSync7, readdirSync as readdirSync4, readFileSync as readFileSync9, realpathSync as realpathSync4 } from "node:fs";
24231
+ import { dirname as dirname7, isAbsolute as isAbsolute2, join as join13, sep as sep4 } from "node:path";
24112
24232
  import { fileURLToPath as fileURLToPath2 } from "node:url";
24113
24233
  function missing(agent, path8) {
24114
24234
  return new CtxError("PLUGIN_ROOT_MISSING", { agent, path: path8 });
@@ -24149,15 +24269,15 @@ var realOrNull = (path8) => {
24149
24269
  };
24150
24270
  var readOrNull = (file2) => {
24151
24271
  try {
24152
- return readFileSync8(file2, "utf8");
24272
+ return readFileSync9(file2, "utf8");
24153
24273
  } catch {
24154
24274
  return null;
24155
24275
  }
24156
24276
  };
24157
24277
  var samePath = (a, b) => a === b || (realOrNull(a) ?? a) === (realOrNull(b) ?? b);
24158
24278
  function enabledPlugins(claudeDir, project) {
24159
- const files = [join12(claudeDir, SETTINGS_FILE)];
24160
- if (project !== void 0) files.push(join12(project, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), join12(project, HOST_CONFIG_DIR_NAME, SETTINGS_LOCAL_FILE));
24279
+ const files = [join13(claudeDir, SETTINGS_FILE)];
24280
+ if (project !== void 0) files.push(join13(project, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), join13(project, HOST_CONFIG_DIR_NAME, SETTINGS_LOCAL_FILE));
24161
24281
  const out = {};
24162
24282
  for (const file2 of files) {
24163
24283
  const text = readOrNull(file2);
@@ -24173,10 +24293,10 @@ function marketplaceChoice(env, worktree) {
24173
24293
  const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname7(script));
24174
24294
  const hostRoot = env[CLAUDE_PLUGIN_ROOT_ENV];
24175
24295
  if (ownReal !== null && hostRoot !== void 0 && hostRoot !== "" && realOrNull(hostRoot) === ownReal) return { root: ownReal };
24176
- const record6 = readOrNull(join12(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE));
24296
+ const record6 = readOrNull(join13(claudeDir, HOST_PLUGINS_DIR_NAME, INSTALLED_PLUGINS_FILE));
24177
24297
  const recorded = record6 === null ? [] : recordedInstalls(record6);
24178
24298
  if (recorded.length === 0) return { record: false };
24179
- const live = recorded.filter((r) => existsSync6(r.installPath));
24299
+ const live = recorded.filter((r) => existsSync7(r.installPath));
24180
24300
  const mine = live.find((r) => realOrNull(r.installPath) === ownReal);
24181
24301
  if (mine !== void 0) return { root: mine.installPath };
24182
24302
  const dirs = live.filter((r, i) => live.findIndex((o) => samePath(o.installPath, r.installPath)) === i);
@@ -24196,18 +24316,18 @@ function marketplaceChoice(env, worktree) {
24196
24316
  }
24197
24317
  function marketplaceRoot(adapter, env, worktree) {
24198
24318
  const claudeDir = claudeDirOf(env, requireHomeDir(env));
24199
- const plugins = join12(claudeDir, HOST_PLUGINS_DIR_NAME);
24200
- const cache = join12(plugins, PLUGIN_CACHE_DIR_NAME);
24319
+ const plugins = join13(claudeDir, HOST_PLUGINS_DIR_NAME);
24320
+ const cache = join13(plugins, PLUGIN_CACHE_DIR_NAME);
24201
24321
  const script = process.argv[1];
24202
24322
  const ownReal = script === void 0 || script === "" ? null : realOrNull(dirname7(script));
24203
24323
  const choice = marketplaceChoice(env, worktree);
24204
24324
  if ("root" in choice) return choice.root;
24205
24325
  if ("installs" in choice) throw missing(adapter.id, choice.installs.map((r) => r.installPath).join(", "));
24206
24326
  const cacheReal = realOrNull(cache);
24207
- if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep4) && existsSync6(join12(ownReal, SERVER_ENTRY_FILE))) return ownReal;
24208
- const pattern = join12(cache, "*", PLUGIN_NAME);
24209
- if (!existsSync6(cache)) throw missing(adapter.id, pattern);
24210
- const found = readdirSync3(cache).sort().map((marketplace) => join12(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync6(dir));
24327
+ if (ownReal !== null && cacheReal !== null && ownReal.startsWith(cacheReal + sep4) && existsSync7(join13(ownReal, SERVER_ENTRY_FILE))) return ownReal;
24328
+ const pattern = join13(cache, "*", PLUGIN_NAME);
24329
+ if (!existsSync7(cache)) throw missing(adapter.id, pattern);
24330
+ const found = readdirSync4(cache).sort().map((marketplace) => join13(cache, marketplace, PLUGIN_NAME)).filter((dir) => existsSync7(dir));
24211
24331
  if (found.length !== 1) throw missing(adapter.id, found.length === 0 ? pattern : found.join(", "));
24212
24332
  return found[0];
24213
24333
  }
@@ -24215,7 +24335,7 @@ function configEntryRoot(adapter, env) {
24215
24335
  const spec = OWN_MCP_ENTRY[adapter.id];
24216
24336
  if (spec === void 0) throw missing(adapter.id, SERVER_KEY);
24217
24337
  const file2 = ownMcpFileOf(adapter.id, spec.file, env, requireHomeDir(env));
24218
- if (!existsSync6(file2)) throw missing(adapter.id, file2);
24338
+ if (!existsSync7(file2)) throw missing(adapter.id, file2);
24219
24339
  const current = readHostConfig(adapter.id, file2);
24220
24340
  const value = parseHostConfig(adapter.id, file2, current.text, current.format);
24221
24341
  const args = hostConfigValueAt(value, [...spec.key, MCP_ARGS_FIELD]);
@@ -24232,9 +24352,9 @@ function candidate(adapter, env, worktree) {
24232
24352
  case "hooks+mcp":
24233
24353
  return configEntryRoot(adapter, env);
24234
24354
  case "extension":
24235
- return join12(adapter.id === "gemini" ? geminiDirOf(env, requireHomeDir(env)) : join12(requireHomeDir(env), ...AGENT_HOME_DIR[adapter.id]), EXTENSIONS_DIR_NAME, PLUGIN_NAME);
24355
+ return join13(adapter.id === "gemini" ? geminiDirOf(env, requireHomeDir(env)) : join13(requireHomeDir(env), ...AGENT_HOME_DIR[adapter.id]), EXTENSIONS_DIR_NAME, PLUGIN_NAME);
24236
24356
  case "plugin":
24237
- return join12(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
24357
+ return join13(resolveConfigDir(env), DATA_PLUGINS_DIR_NAME, adapter.id, PLUGIN_CURRENT_LINK);
24238
24358
  case "in-process":
24239
24359
  return dirname7(fileURLToPath2(import.meta.url));
24240
24360
  }
@@ -24249,7 +24369,7 @@ function resolvePluginRoot(adapter, env, worktree) {
24249
24369
  }
24250
24370
 
24251
24371
  // src/setup/pi-gate.ts
24252
- import { existsSync as existsSync7, readFileSync as readFileSync9, realpathSync as realpathSync5 } from "node:fs";
24372
+ import { existsSync as existsSync8, readFileSync as readFileSync10, realpathSync as realpathSync5 } from "node:fs";
24253
24373
  import path4 from "node:path";
24254
24374
  var EXTENSIONS_KEY = "extensions";
24255
24375
  var PROJECT_DIR = ".pi";
@@ -24257,9 +24377,9 @@ var TRUST_FILE = "trust.json";
24257
24377
  var ALWAYS = "always";
24258
24378
  var SOURCE_PREFIXES = ["npm:", "git:"];
24259
24379
  function load(file2) {
24260
- if (!existsSync7(file2)) return void 0;
24380
+ if (!existsSync8(file2)) return void 0;
24261
24381
  try {
24262
- return { file: file2, doc: parseHostConfig("pi", file2, hostText(readFileSync9(file2, "utf8")), "json") };
24382
+ return { file: file2, doc: parseHostConfig("pi", file2, hostText(readFileSync10(file2, "utf8")), "json") };
24263
24383
  } catch {
24264
24384
  return void 0;
24265
24385
  }
@@ -24394,11 +24514,11 @@ function ownHooks(block, shape, timeoutKey, native, agent) {
24394
24514
  var validTimeout = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
24395
24515
  function mcpFile(row5, home, env) {
24396
24516
  const spec = OWN_MCP_ENTRY[row5.id];
24397
- if (row5.id === "codex") return join13(codexDirOf(env, home), CONFIG_TOML_FILE);
24517
+ if (row5.id === "codex") return join14(codexDirOf(env, home), CONFIG_TOML_FILE);
24398
24518
  if (spec !== void 0) return ownMcpFileOf(row5.id, spec.file, env, home);
24399
- if (row5.id === "opencode") return join13(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
24519
+ if (row5.id === "opencode") return join14(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
24400
24520
  if (row5.id === "pi") {
24401
- return join13(piAgentDirOf(env, home), SETTINGS_FILE);
24521
+ return join14(piAgentDirOf(env, home), SETTINGS_FILE);
24402
24522
  }
24403
24523
  return null;
24404
24524
  }
@@ -24411,27 +24531,27 @@ function codexNativeDir(env, home) {
24411
24531
  const codexDir = codexDirOf(env, home);
24412
24532
  let enabled;
24413
24533
  try {
24414
- enabled = hostConfigValueAt(readParsed("codex", join13(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
24534
+ enabled = hostConfigValueAt(readParsed("codex", join14(codexDir, CONFIG_TOML_FILE)).value, ["plugins", CODEX_PLUGIN_KEY, "enabled"]);
24415
24535
  } catch {
24416
24536
  return null;
24417
24537
  }
24418
24538
  if (enabled !== true) return null;
24419
- const cache = join13(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
24420
- if (!existsSync8(cache)) return null;
24539
+ const cache = join14(codexDir, "plugins", PLUGIN_CACHE_DIR_NAME);
24540
+ if (!existsSync9(cache)) return null;
24421
24541
  const found = [];
24422
- for (const market of readdirSync4(cache)) {
24423
- const plugin = join13(cache, market, SERVER_KEY);
24424
- if (!existsSync8(plugin)) continue;
24425
- for (const version4 of readdirSync4(plugin).sort()) {
24426
- const dir = join13(plugin, version4, CODEX_PLUGIN_SUBDIR);
24427
- if (existsSync8(join13(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
24542
+ for (const market of readdirSync5(cache)) {
24543
+ const plugin = join14(cache, market, SERVER_KEY);
24544
+ if (!existsSync9(plugin)) continue;
24545
+ for (const version4 of readdirSync5(plugin).sort()) {
24546
+ const dir = join14(plugin, version4, CODEX_PLUGIN_SUBDIR);
24547
+ if (existsSync9(join14(dir, CODEX_PLUGIN_MCP_FILE))) found.push(dir);
24428
24548
  }
24429
24549
  }
24430
24550
  return found.length === 0 ? null : found[found.length - 1];
24431
24551
  }
24432
24552
  function nativeMcpWrong(dir, row5) {
24433
24553
  try {
24434
- const entry = hostConfigValueAt(readParsed(row5.id, join13(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
24554
+ const entry = hostConfigValueAt(readParsed(row5.id, join14(dir, CODEX_PLUGIN_MCP_FILE)).value, [MCP_SERVERS_FIELD, SERVER_KEY]);
24435
24555
  if (!isObject4(entry)) return true;
24436
24556
  const args = list2(entry[MCP_ARGS_FIELD]);
24437
24557
  const script = args[0];
@@ -24455,7 +24575,7 @@ function opencodeMcpOwn(entry) {
24455
24575
  function opencodeListed(file2) {
24456
24576
  const { value } = readParsed("opencode", file2);
24457
24577
  const bundle = opencodePluginFile();
24458
- const own4 = [bundle, join13(bundle, ...OPENCODE_PLUGIN_PATH)];
24578
+ const own4 = [bundle, join14(bundle, ...OPENCODE_PLUGIN_PATH)];
24459
24579
  if ([OPENCODE_PLUGIN_KEY, OPENCODE_PLUGINS_KEY].some((key) => list2(isObject4(value) ? value[key] : void 0).some((e) => isOwnOpencodeEntry(e, key, own4)))) return true;
24460
24580
  const mcp = isObject4(value) && isObject4(value.mcp) ? value.mcp : {};
24461
24581
  return opencodeMcpOwn(mcp[SERVER_KEY]) || isObject4(mcp.servers) && opencodeMcpOwn(mcp.servers[SERVER_KEY]);
@@ -24479,7 +24599,7 @@ function mcpWrong(row5, home, env, worktree) {
24479
24599
  function hookFile(row5, spec, home, env, worktree) {
24480
24600
  const root = spec.root === "plugin" ? resolvePluginRoot(row5, env, worktree) : spec.root === "home" ? home : worktree;
24481
24601
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
24482
- const file2 = native !== null ? join13(native, CODEX_PLUGIN_HOOKS_FILE) : row5.id === "codex" ? join13(codexDirOf(env, home), HOOKS_JSON_FILE) : row5.id === "copilot-cli" ? join13(copilotDirOf(env, home), ...spec.file.slice(1)) : row5.id === "kiro" ? join13(kiroDirOf(env, home), ...spec.file.slice(1)) : join13(root, ...spec.file);
24602
+ const file2 = native !== null ? join14(native, CODEX_PLUGIN_HOOKS_FILE) : row5.id === "codex" ? join14(codexDirOf(env, home), HOOKS_JSON_FILE) : row5.id === "copilot-cli" ? join14(copilotDirOf(env, home), ...spec.file.slice(1)) : row5.id === "kiro" ? join14(kiroDirOf(env, home), ...spec.file.slice(1)) : join14(root, ...spec.file);
24483
24603
  return file2;
24484
24604
  }
24485
24605
  function hookParts(row5, home, env, worktree) {
@@ -24490,7 +24610,7 @@ function hookParts(row5, home, env, worktree) {
24490
24610
  const file2 = hookFile(row5, spec, home, env, worktree);
24491
24611
  block = hostConfigValueAt(readParsed(row5.id, file2).value, spec.key);
24492
24612
  if (row5.id === "codex") {
24493
- const config4 = readParsed(row5.id, join13(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
24613
+ const config4 = readParsed(row5.id, join14(codexDirOf(env, home), CONFIG_TOML_FILE)).value;
24494
24614
  if (hostConfigValueAt(config4, CODEX_FEATURES_HOOKS_KEY) === false) return [PART_HOOKS];
24495
24615
  }
24496
24616
  } catch {
@@ -24534,7 +24654,7 @@ function checkHostConfig(row5, env, worktree) {
24534
24654
  function checkPiInstall(env, home, worktree) {
24535
24655
  const found = piInstalledIn(env, home, ownBundleDir(), worktree);
24536
24656
  if (found !== void 0) return { ...pass("D3"), detail: found };
24537
- return fail2("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + join13(piAgentDirOf(env, home), SETTINGS_FILE), NATIVE_INSTALL.pi[0]);
24657
+ return fail2("D3", D3_DETAIL([PART_MCP]) + D4_REASON_JOIN + join14(piAgentDirOf(env, home), SETTINGS_FILE), NATIVE_INSTALL.pi[0]);
24538
24658
  }
24539
24659
  function checkV1Leftovers(agent, home, scope = {}) {
24540
24660
  const findings = detectV1(agent, home, scope);
@@ -24553,10 +24673,10 @@ function parsedOrNull(agent, file2, jsonc) {
24553
24673
  }
24554
24674
  function checkDoubleFire(agent, worktree) {
24555
24675
  if (agent !== "claude-code" && agent !== "vscode") return pass("D5b");
24556
- const claude = parsedOrNull(agent, join13(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
24676
+ const claude = parsedOrNull(agent, join14(worktree, HOST_CONFIG_DIR_NAME, SETTINGS_FILE), false);
24557
24677
  const hooks = isObject4(claude) ? claude[HOOKS_KEY] : void 0;
24558
24678
  const hooksOn = isObject4(hooks) && Object.keys(hooks).length > 0;
24559
- const vscode = parsedOrNull(agent, join13(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
24679
+ const vscode = parsedOrNull(agent, join14(worktree, VSCODE_DIR_NAME, VSCODE_SETTINGS_FILE), true);
24560
24680
  const useClaudeHooks = isObject4(vscode) && vscode[VSCODE_CLAUDE_HOOKS_SETTING] === true;
24561
24681
  return hooksOn && useClaudeHooks ? fail2("D5b", D5B_DETAIL, D5B_FIX) : pass("D5b");
24562
24682
  }
@@ -24567,7 +24687,7 @@ function configPaths(row5, env, worktree) {
24567
24687
  const mcp = mcpFile(row5, home, env);
24568
24688
  if (mcp !== null) out.push({ label: "MCP entry", path: mcp });
24569
24689
  const native = row5.id === "codex" ? codexNativeDir(env, home) : null;
24570
- if (native !== null) out.push({ label: "Codex plugin MCP", path: join13(native, CODEX_PLUGIN_MCP_FILE) });
24690
+ if (native !== null) out.push({ label: "Codex plugin MCP", path: join14(native, CODEX_PLUGIN_MCP_FILE) });
24571
24691
  const spec = HOOK_HOST_FILE[row5.id];
24572
24692
  if (spec !== null) {
24573
24693
  try {
@@ -24587,7 +24707,7 @@ function configPaths(row5, env, worktree) {
24587
24707
  }
24588
24708
 
24589
24709
  // src/core/ops/doctor-db.ts
24590
- import { existsSync as existsSync9, statSync as statSync5 } from "node:fs";
24710
+ import { existsSync as existsSync10, statSync as statSync5 } from "node:fs";
24591
24711
  var unknown2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "UNKNOWN", detail });
24592
24712
  var pass2 = (id, detail) => ({ id, label: DOCTOR_LABEL[id], status: "PASS", detail });
24593
24713
  var fail3 = (detail, fixCommand) => ({ id: "D8", label: DOCTOR_LABEL.D8, status: "FAIL", detail, fixCommand });
@@ -24629,15 +24749,15 @@ function orphanFiles(dbPath) {
24629
24749
  const files = [];
24630
24750
  for (const suffix of [DB_WAL_SUFFIX, DB_SHM_SUFFIX]) {
24631
24751
  const path8 = dbPath + suffix;
24632
- if (existsSync9(path8)) files.push({ path: path8, bytes: statSync5(path8).size });
24752
+ if (existsSync10(path8)) files.push({ path: path8, bytes: statSync5(path8).size });
24633
24753
  }
24634
- return files.length > 0 && !existsSync9(dbPath) ? files : [];
24754
+ return files.length > 0 && !existsSync10(dbPath) ? files : [];
24635
24755
  }
24636
24756
  async function checkDb(project) {
24637
24757
  const clean = { schemaStale: false, integrityFailed: false, orphan: [] };
24638
24758
  const orphan = orphanFiles(project.dbPath);
24639
24759
  if (orphan.length > 0) return { row: fail3(D8_ORPHAN_DETAIL(orphan), D8_ORPHAN_FIX), schemaStale: false, integrityFailed: false, orphan };
24640
- if (!existsSync9(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
24760
+ if (!existsSync10(project.dbPath)) return { row: pass2("D8", DOCTOR_PASS_DETAIL), ...clean };
24641
24761
  const sqlite = await loadSqlite2();
24642
24762
  if (sqlite === null) return { row: unknown2("D8", D2_SQLITE_DETAIL), ...clean };
24643
24763
  let raw = null;
@@ -24663,7 +24783,7 @@ async function checkDb(project) {
24663
24783
  }
24664
24784
  }
24665
24785
  async function checkIndex(project) {
24666
- if (!existsSync9(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
24786
+ if (!existsSync10(project.dbPath)) return pass2("D9", D9_INDEX_DETAIL(0, 0));
24667
24787
  const sqlite = await loadSqlite2();
24668
24788
  if (sqlite === null) return unknown2("D9", D2_SQLITE_DETAIL);
24669
24789
  let raw = null;
@@ -24680,8 +24800,8 @@ async function checkIndex(project) {
24680
24800
  }
24681
24801
 
24682
24802
  // src/core/ops/doctor-env.ts
24683
- import { existsSync as existsSync10, readFileSync as readFileSync10, realpathSync as realpathSync6 } from "node:fs";
24684
- import { isAbsolute as isAbsolute3, join as join14, relative as relative4 } from "node:path";
24803
+ import { existsSync as existsSync11, readFileSync as readFileSync11, realpathSync as realpathSync6 } from "node:fs";
24804
+ import { isAbsolute as isAbsolute3, join as join15, relative as relative4 } from "node:path";
24685
24805
  function pass3(id, detail = DOCTOR_PASS_DETAIL) {
24686
24806
  return { id, label: DOCTOR_LABEL[id], status: "PASS", detail };
24687
24807
  }
@@ -24693,7 +24813,7 @@ function fail4(id, detail, fixCommand) {
24693
24813
  }
24694
24814
  function bundleVersion(bundleDir2) {
24695
24815
  try {
24696
- const v = JSON.parse(readFileSync10(join14(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
24816
+ const v = JSON.parse(readFileSync11(join15(bundleDir2, D1_PACKAGE_FILE), "utf8")).version;
24697
24817
  return typeof v === "string" && v !== "" ? v : void 0;
24698
24818
  } catch {
24699
24819
  return void 0;
@@ -24843,7 +24963,7 @@ function checkMcp(ctx) {
24843
24963
  return named2 || versioned ? pass3("D6") : unknown3("D6", D6_UNKNOWN_DETAIL);
24844
24964
  }
24845
24965
  function piCwdInside(worktree, piCwd) {
24846
- if (piCwd === void 0 || !existsSync10(piCwd)) return false;
24966
+ if (piCwd === void 0 || !existsSync11(piCwd)) return false;
24847
24967
  const rel = relative4(worktree, realpathSync6.native(piCwd));
24848
24968
  return rel === "" || !rel.startsWith("..") && !isAbsolute3(rel);
24849
24969
  }
@@ -24853,7 +24973,9 @@ function checkProject(i) {
24853
24973
  if (i.adapter.projectSource === "pi:ctx.cwd" && !piCwdInside(i.project.worktree, i.piCwd)) return bad;
24854
24974
  return pass3("D7");
24855
24975
  }
24856
- function checkMode(adapter) {
24976
+ function checkMode(adapter, hostPermission) {
24977
+ if (hostPermission === "missing") return fail4("D10", D10_PERMISSION_MISSING_DETAIL, D10_PERMISSION_FIX);
24978
+ if (hostPermission === "wired") return pass3("D10", D10_PERMISSION_DETAIL(adapter.denyChannel));
24857
24979
  return pass3("D10", D10_DETAIL(adapter.denyChannel));
24858
24980
  }
24859
24981
  function checkShell(env) {
@@ -24864,7 +24986,7 @@ function checkShell(env) {
24864
24986
  }
24865
24987
 
24866
24988
  // src/core/ops/doctor-hook.ts
24867
- import { existsSync as existsSync12, mkdtempSync, readFileSync as readFileSync11, realpathSync as realpathSync8, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
24989
+ import { existsSync as existsSync13, mkdirSync as mkdirSync4, mkdtempSync, readFileSync as readFileSync12, realpathSync as realpathSync8, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "node:fs";
24868
24990
  import { tmpdir as tmpdir2 } from "node:os";
24869
24991
  import path7 from "node:path";
24870
24992
 
@@ -26690,7 +26812,7 @@ function nodeLaunch(env, host = { bun: process.versions.bun, execPath: process.e
26690
26812
 
26691
26813
  // src/setup/codex-trust.ts
26692
26814
  import { createHash } from "node:crypto";
26693
- import { existsSync as existsSync11, realpathSync as realpathSync7 } from "node:fs";
26815
+ import { existsSync as existsSync12, realpathSync as realpathSync7 } from "node:fs";
26694
26816
  import path6 from "node:path";
26695
26817
  import { spawn as spawn2, spawnSync as spawnSync2 } from "node:child_process";
26696
26818
 
@@ -26913,10 +27035,10 @@ function isObject6(v) {
26913
27035
  }
26914
27036
  function loadFixture(bundleDir2, agent) {
26915
27037
  const file2 = path7.join(bundleDir2, HOOK_FIXTURE_DIR, HOOK_FIXTURE_FILE);
26916
- if (!existsSync12(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
27038
+ if (!existsSync13(file2)) return { cause: D5_FIXTURE_FILE_ABSENT(file2) };
26917
27039
  let all;
26918
27040
  try {
26919
- all = JSON.parse(hostText(readFileSync11(file2, "utf8")));
27041
+ all = JSON.parse(hostText(readFileSync12(file2, "utf8")));
26920
27042
  } catch (err) {
26921
27043
  return { cause: D5_FIXTURE_PARSE(file2, err instanceof Error ? err.message : String(err)) };
26922
27044
  }
@@ -27029,6 +27151,35 @@ async function mediaProbe(i, timeoutMs) {
27029
27151
  rmSync2(home, { recursive: true, force: true });
27030
27152
  }
27031
27153
  }
27154
+ async function ownProbe(i, timeoutMs) {
27155
+ const home = mkdtempSync(path7.join(tmpdir2(), "cm-d5-own-"));
27156
+ try {
27157
+ const cfg = path7.join(home, ".claude");
27158
+ const refs = path7.join(cfg, "skills", "d5-probe", "references");
27159
+ mkdirSync4(refs, { recursive: true });
27160
+ const filePath = path7.join(refs, "d5-own-probe.md");
27161
+ writeFileSync2(filePath, "# d5 own probe\n".repeat(Math.ceil((OUTPUT_CAP + 1) / 15)));
27162
+ const node3 = nodeLaunch({ ...i.env, HOME: home, USERPROFILE: home, CLAUDE_CONFIG_DIR: cfg });
27163
+ const r = await runProcess([node3.file, path7.join(i.bundleDir, HOOK_ENTRY_FILE), AGENT_ARG, i.agent], {
27164
+ cwd: i.bundleDir,
27165
+ env: node3.env,
27166
+ signal: i.signal,
27167
+ timeoutMs,
27168
+ stdin: JSON.stringify({
27169
+ session_id: "d5-own-probe",
27170
+ transcript_path: "",
27171
+ cwd: home,
27172
+ hook_event_name: "PreToolUse",
27173
+ tool_name: "Read",
27174
+ tool_use_id: "toolu_d5_own_probe",
27175
+ tool_input: { file_path: filePath }
27176
+ })
27177
+ });
27178
+ return r.stdout.toString("utf8");
27179
+ } finally {
27180
+ rmSync2(home, { recursive: true, force: true });
27181
+ }
27182
+ }
27032
27183
  function isDeny(stdout) {
27033
27184
  if (stdout.trim() === "") return false;
27034
27185
  let out;
@@ -27043,8 +27194,12 @@ async function readProbeDetail(i, timeoutMs) {
27043
27194
  if (!isReadShape(await readProbe(i, timeoutMs, false))) return D5_READ_SHAPE_DETAIL;
27044
27195
  if (!isPassThrough(await readProbe(i, timeoutMs, true))) return D5_READ_RANGE_DETAIL;
27045
27196
  if (isDeny(await mediaProbe(i, timeoutMs))) return D5_READ_MEDIA_DETAIL;
27197
+ if (isDeny(await ownProbe(i, timeoutMs))) return D5_READ_OWN_DETAIL;
27046
27198
  return null;
27047
27199
  }
27200
+ async function mediaProbeDetail(i, timeoutMs) {
27201
+ return isDeny(await mediaProbe(i, timeoutMs)) ? D5_READ_MEDIA_DETAIL : null;
27202
+ }
27048
27203
  function codexHookJournaled(db) {
27049
27204
  if (db === null) return false;
27050
27205
  return db.raw.prepare("SELECT 1 FROM events WHERE agent = ? LIMIT 1").get("codex") !== void 0;
@@ -27097,7 +27252,7 @@ async function codexStopDetail(i, timeoutMs) {
27097
27252
  timeoutMs,
27098
27253
  stdin: JSON.stringify(codexStopPayload(i.worktree ?? home))
27099
27254
  });
27100
- const logged = existsSync12(path7.join(home, HOOK_ERROR_LOG_FILE));
27255
+ const logged = existsSync13(path7.join(home, HOOK_ERROR_LOG_FILE));
27101
27256
  return !logged && isNativeShape(i.agent, r.stdout.toString("utf8"), r.exitCode, r.killed, "Stop") ? null : D5_STOP_DETAIL;
27102
27257
  } finally {
27103
27258
  rmSync2(home, { recursive: true, force: true });
@@ -27108,7 +27263,7 @@ async function checkHookRoundTrip(i) {
27108
27263
  const trust = await codexPluginTrust(i);
27109
27264
  if (trust !== null) return trust;
27110
27265
  }
27111
- if (i.agent === "codex" && existsSync12(path7.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
27266
+ if (i.agent === "codex" && existsSync13(path7.join(i.codexConfigDir, HOOKS_JSON_FILE)) && !codexHookJournaled(i.db)) {
27112
27267
  return row("UNKNOWN", D5_CODEX_UNTRUSTED_DETAIL);
27113
27268
  }
27114
27269
  const fixture = loadFixture(i.bundleDir, i.agent);
@@ -27144,29 +27299,29 @@ async function checkHookRoundTrip(i) {
27144
27299
  if (n >= minPairs && ms <= HOOK_P95_MS) break;
27145
27300
  }
27146
27301
  if (ms > HOOK_P95_MS) return row("FAIL", D5_SLOW_DETAIL(ms), D5_FIX);
27147
- const readDetail = i.agent === "claude-code" ? await readProbeDetail(i, timeoutMs) : i.agent === "codex" ? await codexStopDetail(i, timeoutMs) : null;
27302
+ const readDetail = i.agent === "claude-code" ? await readProbeDetail(i, timeoutMs) : i.agent === "zcode" ? await mediaProbeDetail(i, timeoutMs) : i.agent === "codex" ? await codexStopDetail(i, timeoutMs) : null;
27148
27303
  if (readDetail !== null) return row("FAIL", readDetail, D5_FIX);
27149
27304
  return row("PASS", DOCTOR_PASS_DETAIL);
27150
27305
  }
27151
27306
 
27152
27307
  // src/core/ops/db-heal.ts
27153
- import { existsSync as existsSync13, mkdirSync as mkdirSync5, rmSync as rmSync4 } from "node:fs";
27154
- import { basename as basename4, dirname as dirname8, join as join16 } from "node:path";
27308
+ import { existsSync as existsSync14, mkdirSync as mkdirSync6, rmSync as rmSync4 } from "node:fs";
27309
+ import { basename as basename4, dirname as dirname8, join as join17 } from "node:path";
27155
27310
 
27156
27311
  // src/core/store/owners.ts
27157
- import { mkdirSync as mkdirSync4, readdirSync as readdirSync5, readFileSync as readFileSync12, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
27158
- import { basename as basename3, join as join15 } from "node:path";
27312
+ import { mkdirSync as mkdirSync5, readdirSync as readdirSync6, readFileSync as readFileSync13, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
27313
+ import { basename as basename3, join as join16 } from "node:path";
27159
27314
  function ownersDir(configDir, projectKey) {
27160
- return join15(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
27315
+ return join16(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
27161
27316
  }
27162
27317
  function ownerFile(configDir, projectKey, serverId) {
27163
- return join15(ownersDir(configDir, projectKey), serverId + OWNER_PID_EXT);
27318
+ return join16(ownersDir(configDir, projectKey), serverId + OWNER_PID_EXT);
27164
27319
  }
27165
27320
  function errCode2(err) {
27166
27321
  return err.code;
27167
27322
  }
27168
27323
  function writeOwnerPid(configDir, projectKey, serverId) {
27169
- mkdirSync4(ownersDir(configDir, projectKey), { recursive: true });
27324
+ mkdirSync5(ownersDir(configDir, projectKey), { recursive: true });
27170
27325
  writeFileSync3(ownerFile(configDir, projectKey, serverId), String(process.pid), "utf8");
27171
27326
  }
27172
27327
  function removeOwnerPid(configDir, projectKey, serverId) {
@@ -27187,7 +27342,7 @@ function listLiveOwners(configDir, projectKey) {
27187
27342
  const dir = ownersDir(configDir, projectKey);
27188
27343
  let names;
27189
27344
  try {
27190
- names = readdirSync5(dir);
27345
+ names = readdirSync6(dir);
27191
27346
  } catch (err) {
27192
27347
  if (errCode2(err) === "ENOENT") return [];
27193
27348
  throw err;
@@ -27195,10 +27350,10 @@ function listLiveOwners(configDir, projectKey) {
27195
27350
  const live = [];
27196
27351
  for (const name of names) {
27197
27352
  if (!name.endsWith(OWNER_PID_EXT)) continue;
27198
- const file2 = join15(dir, name);
27353
+ const file2 = join16(dir, name);
27199
27354
  let text;
27200
27355
  try {
27201
- text = readFileSync12(file2, "utf8");
27356
+ text = readFileSync13(file2, "utf8");
27202
27357
  } catch (err) {
27203
27358
  if (errCode2(err) === "ENOENT") continue;
27204
27359
  throw err;
@@ -27244,7 +27399,7 @@ function renameAside(dbPath) {
27244
27399
  const ts = String(Date.now());
27245
27400
  for (const suffix of DB_SIBLING_SUFFIXES) {
27246
27401
  const file2 = dbPath + suffix;
27247
- if (existsSync13(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
27402
+ if (existsSync14(file2)) renameWithRetry(file2, file2 + HEAL_TS_SEP + ts + HEAL_BACKUP_SUFFIX);
27248
27403
  }
27249
27404
  return ts;
27250
27405
  }
@@ -27267,11 +27422,11 @@ function utcStamp(now) {
27267
27422
  return now.toISOString().slice(0, 19).replaceAll("-", "").replaceAll(":", "") + "Z";
27268
27423
  }
27269
27424
  function makeOrphanDir(projectDir) {
27270
- const base = join16(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
27425
+ const base = join17(projectDir, ORPHAN_DIR_PREFIX + utcStamp(/* @__PURE__ */ new Date()));
27271
27426
  for (let n = 1; ; n += 1) {
27272
27427
  const dir = n === 1 ? base : base + "-" + String(n);
27273
27428
  try {
27274
- mkdirSync5(dir);
27429
+ mkdirSync6(dir);
27275
27430
  return dir;
27276
27431
  } catch (err) {
27277
27432
  if (err.code !== "EEXIST") throw err;
@@ -27284,7 +27439,7 @@ async function healOrphan(project, files, row5) {
27284
27439
  try {
27285
27440
  dir = makeOrphanDir(dirname8(project.dbPath));
27286
27441
  for (const f of files) {
27287
- const to = join16(dir, basename4(f.path));
27442
+ const to = join17(dir, basename4(f.path));
27288
27443
  renameWithRetry(f.path, to);
27289
27444
  moved.push({ path: to, bytes: f.bytes });
27290
27445
  }
@@ -27351,8 +27506,8 @@ function buildReportHead(input) {
27351
27506
 
27352
27507
  // src/core/ops/doctor-issue.ts
27353
27508
  import { spawnSync as spawnSync3 } from "node:child_process";
27354
- import { closeSync as closeSync2, existsSync as existsSync14, fstatSync, mkdirSync as mkdirSync6, openSync as openSync2, readFileSync as readFileSync13, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
27355
- import { delimiter, join as join17 } from "node:path";
27509
+ import { closeSync as closeSync2, existsSync as existsSync15, fstatSync, mkdirSync as mkdirSync7, openSync as openSync2, readFileSync as readFileSync14, readSync as readSync2, realpathSync as realpathSync9, writeFileSync as writeFileSync4 } from "node:fs";
27510
+ import { delimiter, join as join18 } from "node:path";
27356
27511
  var TOKEN_PREFIXES = ["ghp_", "gho_", "github_pat_", "sk-", "xoxb-", "AKIA"];
27357
27512
  function tildeOf(env) {
27358
27513
  const home = homeDirOf(env);
@@ -27393,8 +27548,8 @@ function onPath(env, tool) {
27393
27548
  const out = [];
27394
27549
  for (const dir of (env.PATH ?? env.Path ?? "").split(delimiter)) {
27395
27550
  if (dir === "") continue;
27396
- for (const n of names) if (existsSync14(join17(dir, n))) {
27397
- out.push(join17(dir, n));
27551
+ for (const n of names) if (existsSync15(join18(dir, n))) {
27552
+ out.push(join18(dir, n));
27398
27553
  break;
27399
27554
  }
27400
27555
  }
@@ -27402,7 +27557,7 @@ function onPath(env, tool) {
27402
27557
  }
27403
27558
  function hookLogTail(env) {
27404
27559
  const file2 = hookLogPath(env);
27405
- if (file2 === "" || !existsSync14(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
27560
+ if (file2 === "" || !existsSync15(file2)) return [`(${file2 || "hook-errors.log"} holds zero lines)`];
27406
27561
  try {
27407
27562
  const fd = openSync2(file2, "r");
27408
27563
  try {
@@ -27422,7 +27577,7 @@ function hookLogTail(env) {
27422
27577
  }
27423
27578
  async function journalRows(ctx) {
27424
27579
  const head2 = ["| kind | tool | bytes | ok | exit_code | created_at |", "|---|---|---|---|---|---|"];
27425
- if (!existsSync14(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
27580
+ if (!existsSync15(ctx.project.dbPath)) return [`(context.db is absent at ${ctx.project.dbPath})`];
27426
27581
  try {
27427
27582
  const db = await openDb(ctx.project, { readOnly: true });
27428
27583
  try {
@@ -27440,21 +27595,21 @@ function agentConfig(adapter, env, worktree) {
27440
27595
  const home = homeDirOf(env);
27441
27596
  const files = configPaths(adapter, env, worktree);
27442
27597
  if (home !== null) {
27443
- if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join17(claudeDirOf(env, home), SETTINGS_FILE) });
27444
- if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join17(codexDirOf(env, home), CONFIG_TOML_FILE) });
27598
+ if (adapter.id === "claude-code") files.push({ label: "agent settings (enabledPlugins)", path: join18(claudeDirOf(env, home), SETTINGS_FILE) });
27599
+ if (adapter.id === "codex") files.push({ label: "agent config (plugins, trust)", path: join18(codexDirOf(env, home), CONFIG_TOML_FILE) });
27445
27600
  }
27446
27601
  const out = [];
27447
27602
  const seen = /* @__PURE__ */ new Set();
27448
27603
  for (const f of files) {
27449
27604
  if (seen.has(f.path)) continue;
27450
27605
  seen.add(f.path);
27451
- if (!existsSync14(f.path)) {
27606
+ if (!existsSync15(f.path)) {
27452
27607
  out.push(`${f.label}: ${f.path} (absent)`);
27453
27608
  continue;
27454
27609
  }
27455
27610
  let text = "";
27456
27611
  try {
27457
- text = readFileSync13(f.path, "utf8");
27612
+ text = readFileSync14(f.path, "utf8");
27458
27613
  } catch (err) {
27459
27614
  out.push(`${f.label}: ${f.path} (read: ${err instanceof Error ? err.message : String(err)})`);
27460
27615
  continue;
@@ -27524,9 +27679,9 @@ async function buildIssueBody(i) {
27524
27679
  async function writeIssueReport(i) {
27525
27680
  const tilde = tildeOf(i.env);
27526
27681
  const body = await buildIssueBody(i);
27527
- const dir = join17(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
27528
- mkdirSync6(dir, { recursive: true });
27529
- const file2 = join17(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
27682
+ const dir = join18(resolveConfigDir(i.env), DOCTOR_REPORTS_DIR);
27683
+ mkdirSync7(dir, { recursive: true });
27684
+ const file2 = join18(dir, `${DOCTOR_REPORT_FILE_PREFIX}${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}.md`);
27530
27685
  writeFileSync4(file2, body);
27531
27686
  const shown2 = tilde(file2);
27532
27687
  const title = issueTitle(i.adapter.id, i.rows);
@@ -27553,7 +27708,7 @@ async function guard(id, run) {
27553
27708
  }
27554
27709
  }
27555
27710
  async function codexDb(ctx, adapter) {
27556
- if (adapter.id !== "codex" || !existsSync15(ctx.project.dbPath)) return null;
27711
+ if (adapter.id !== "codex" || !existsSync16(ctx.project.dbPath)) return null;
27557
27712
  try {
27558
27713
  return await openDb(ctx.project, { readOnly: true });
27559
27714
  } catch {
@@ -27583,11 +27738,11 @@ async function hookRow(ctx, adapter, host) {
27583
27738
  }
27584
27739
  }
27585
27740
  function ownServerId(configDir, projectKey) {
27586
- const dir = join18(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
27587
- if (!existsSync15(dir)) return "";
27588
- for (const name of readdirSync6(dir)) {
27741
+ const dir = join19(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
27742
+ if (!existsSync16(dir)) return "";
27743
+ for (const name of readdirSync7(dir)) {
27589
27744
  if (!name.endsWith(OWNER_PID_EXT)) continue;
27590
- if (readFileSync14(join18(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
27745
+ if (readFileSync15(join19(dir, name), "utf8").trim() === String(process.pid)) return basename5(name, OWNER_PID_EXT);
27591
27746
  }
27592
27747
  return "";
27593
27748
  }
@@ -27613,7 +27768,8 @@ async function runDoctorChecks(ctx, adapter, host0) {
27613
27768
  return r.row;
27614
27769
  },
27615
27770
  D9: () => checkIndex(project),
27616
- D10: () => checkMode(adapter),
27771
+ D10: () => checkMode(adapter, ctx.hostPermission),
27772
+ // D-1331-OC-PERM-1
27617
27773
  D11: () => checkShell(env)
27618
27774
  };
27619
27775
  const rows = [];
@@ -27682,9 +27838,9 @@ var ctxDoctor = Object.freeze({
27682
27838
  });
27683
27839
 
27684
27840
  // src/core/tools/execute.ts
27685
- import { existsSync as existsSync16, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync5 } from "node:fs";
27841
+ import { existsSync as existsSync17, mkdtempSync as mkdtempSync2, rmSync as rmSync5, writeFileSync as writeFileSync5 } from "node:fs";
27686
27842
  import { tmpdir as tmpdir3 } from "node:os";
27687
- import { dirname as dirname10, join as join19, parse as parse3, resolve as resolve8 } from "node:path";
27843
+ import { dirname as dirname10, join as join20, parse as parse3, resolve as resolve8 } from "node:path";
27688
27844
 
27689
27845
  // src/core/sandbox/win-build.ts
27690
27846
  var SEPARATORS2 = ";&|(\n";
@@ -27767,7 +27923,7 @@ function schemaLine(issue4) {
27767
27923
  }
27768
27924
  function fileError(given, abs, root) {
27769
27925
  let dir = abs;
27770
- while (!existsSync16(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
27926
+ while (!existsSync17(dir) && dirname10(dir) !== dir) dir = dirname10(dir);
27771
27927
  if (isInside(root, dir)) return null;
27772
27928
  return new CtxError("OUTSIDE_ROOT", { p: given, root }).toLine();
27773
27929
  }
@@ -27848,8 +28004,8 @@ async function handler3(raw, ctx) {
27848
28004
  if (takesDashC(input.language, runtime)) {
27849
28005
  argv = [runtime, "-c", input.language === "shell" ? rewriteWindowsBuildTools(input.code, process.platform) : input.code];
27850
28006
  } else {
27851
- tmpDir = mkdtempSync2(join19(tmpdir3(), TMP_PREFIX));
27852
- const file2 = join19(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
28007
+ tmpDir = mkdtempSync2(join20(tmpdir3(), TMP_PREFIX));
28008
+ const file2 = join20(tmpDir, SCRIPT_NAME + (SCRIPT_EXT[input.language] ?? ""));
27853
28009
  writeFileSync5(file2, scriptText(input.language, input.code), "utf8");
27854
28010
  argv = scriptArgv(input.language, runtime, file2);
27855
28011
  }
@@ -27885,12 +28041,12 @@ var ctxExecute = {
27885
28041
  };
27886
28042
 
27887
28043
  // src/core/tools/index.ts
27888
- import { existsSync as existsSync17, readFileSync as readFileSync16, statSync as statSync8 } from "node:fs";
27889
- import { dirname as dirname11, extname as extname2, join as join21, relative as relative5, resolve as resolve9 } from "node:path";
28044
+ import { existsSync as existsSync18, readFileSync as readFileSync17, statSync as statSync8 } from "node:fs";
28045
+ import { dirname as dirname11, extname as extname3, join as join22, relative as relative5, resolve as resolve9 } from "node:path";
27890
28046
 
27891
28047
  // src/core/index/walk.ts
27892
- import { readdirSync as readdirSync7, readFileSync as readFileSync15, realpathSync as realpathSync10, statSync as statSync7 } from "node:fs";
27893
- import { join as join20 } from "node:path";
28048
+ import { readdirSync as readdirSync8, readFileSync as readFileSync16, realpathSync as realpathSync10, statSync as statSync7 } from "node:fs";
28049
+ import { join as join21 } from "node:path";
27894
28050
  var GITIGNORE = ".gitignore";
27895
28051
  var GIT_DIR = ".git";
27896
28052
  function walkDir(root, containmentRoot) {
@@ -27899,19 +28055,19 @@ function walkDir(root, containmentRoot) {
27899
28055
  const found = [];
27900
28056
  visit(real3, [], [], containmentRoot, /* @__PURE__ */ new Set([real3]), found);
27901
28057
  found.sort(compareFound);
27902
- return found.map((f) => ({ absPath: f.absPath, relPath: join20(...f.dir, f.name) }));
28058
+ return found.map((f) => ({ absPath: f.absPath, relPath: join21(...f.dir, f.name) }));
27903
28059
  }
27904
28060
  function visit(abs, rel, parent, contain, seen, found) {
27905
28061
  let entries;
27906
28062
  try {
27907
- entries = readdirSync7(abs, { withFileTypes: true });
28063
+ entries = readdirSync8(abs, { withFileTypes: true });
27908
28064
  } catch {
27909
28065
  return;
27910
28066
  }
27911
- const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join20(abs, GITIGNORE), rel)) : parent;
28067
+ const rules = entries.some((e) => e.name === GITIGNORE && e.isFile()) ? parent.concat(readRules(join21(abs, GITIGNORE), rel)) : parent;
27912
28068
  for (const e of entries) {
27913
28069
  if (e.name === GIT_DIR) continue;
27914
- const path8 = join20(abs, e.name);
28070
+ const path8 = join21(abs, e.name);
27915
28071
  let isDir = e.isDirectory();
27916
28072
  let isFile = e.isFile();
27917
28073
  let target = path8;
@@ -27951,7 +28107,7 @@ function compareFound(a, b) {
27951
28107
  function readRules(file2, base) {
27952
28108
  let body;
27953
28109
  try {
27954
- body = readFileSync15(file2, "utf8");
28110
+ body = readFileSync16(file2, "utf8");
27955
28111
  } catch {
27956
28112
  return [];
27957
28113
  }
@@ -32070,7 +32226,7 @@ function userLabel(label2) {
32070
32226
  return label2 === DECISION_SOURCE ? DECISION_USER_LABEL : label2;
32071
32227
  }
32072
32228
  function kindOfPath(p) {
32073
- return EXT_KIND[extname2(p).toLowerCase()] ?? "text";
32229
+ return EXT_KIND[extname3(p).toLowerCase()] ?? "text";
32074
32230
  }
32075
32231
  function kindOfType(contentType) {
32076
32232
  const semi = contentType.indexOf(";");
@@ -32079,14 +32235,14 @@ function kindOfType(contentType) {
32079
32235
  }
32080
32236
  function readUtf8(absPath) {
32081
32237
  try {
32082
- return utf8.decode(readFileSync16(absPath));
32238
+ return utf8.decode(readFileSync17(absPath));
32083
32239
  } catch {
32084
32240
  return void 0;
32085
32241
  }
32086
32242
  }
32087
32243
  function missingOrOutside(given, abs, root) {
32088
32244
  let dir = abs;
32089
- while (!existsSync17(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
32245
+ while (!existsSync18(dir) && dirname11(dir) !== dir) dir = dirname11(dir);
32090
32246
  if (dir !== abs && isInside(root, dir)) return new CtxError("INVALID_ARGS", { field: "path", action: "pass an existing file or folder" });
32091
32247
  return new CtxError("OUTSIDE_ROOT", { p: given, root });
32092
32248
  }
@@ -32097,7 +32253,7 @@ function pathItems(input, project) {
32097
32253
  if (statSync8(abs).isDirectory()) {
32098
32254
  return walkDir(abs, project.containmentRoot).map((f) => ({
32099
32255
  sourceKind: "path",
32100
- label: pathLabel(join21(base, f.relPath)),
32256
+ label: pathLabel(join22(base, f.relPath)),
32101
32257
  kind: kindOfPath(f.relPath),
32102
32258
  read: () => readUtf8(f.absPath)
32103
32259
  }));
@@ -32276,9 +32432,8 @@ async function handler6(input, ctx) {
32276
32432
  const newest = rows.at(-1);
32277
32433
  if (newest === void 0) return reply3(RESUME_EMPTY_LINE, false);
32278
32434
  const sources = listSessionSources(db, sessionId, MAX_CANDIDATES).map((r) => "source " + sourceHandle(r.id) + ": " + r.label + " (" + r.bytes + " B)");
32279
- const goal = readFirstPrompt(db, sessionId);
32280
32435
  const last2 = readLastPrompt(db, sessionId);
32281
- const units = queryUnits(db, sessionId, recallQueryText(last2, goal), RECALL_UNIT_CANDIDATES).map((u) => ({ ...u, label: sourceHandle(u.sourceId) }));
32436
+ const units = queryUnits(db, sessionId, recallQueryText(last2), RECALL_UNIT_CANDIDATES).map((u) => ({ ...u, label: sourceHandle(u.sourceId) }));
32282
32437
  const block = renderState(rows, newest.turn, { sources, units });
32283
32438
  if (Buffer.byteLength(block, "utf8") > RESUME_CAP) throw new Error("ctx_resume: state block over RESUME_CAP (render bug).");
32284
32439
  return reply3(block, false);
@@ -32637,8 +32792,8 @@ var ctxStats = Object.freeze({
32637
32792
  });
32638
32793
 
32639
32794
  // src/core/ops/host-write.ts
32640
- import { copyFileSync, existsSync as existsSync18, mkdirSync as mkdirSync7, writeFileSync as writeFileSync6 } from "node:fs";
32641
- import { dirname as dirname12, join as join22 } from "node:path";
32795
+ import { copyFileSync, existsSync as existsSync19, mkdirSync as mkdirSync8, writeFileSync as writeFileSync6 } from "node:fs";
32796
+ import { dirname as dirname12, join as join23 } from "node:path";
32642
32797
  function defaultWrite(file2, text) {
32643
32798
  writeFileSync6(file2, text, "utf8");
32644
32799
  }
@@ -32647,17 +32802,17 @@ function hostConfigPath(agent, home, env) {
32647
32802
  if (own4 !== void 0) return ownMcpFileOf(agent, own4.file, env, home);
32648
32803
  switch (agent) {
32649
32804
  case "opencode":
32650
- return join22(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
32805
+ return join23(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE);
32651
32806
  // D-WIN-OPENCODE-DIR-1
32652
32807
  case "pi":
32653
- return join22(piAgentDirOf(env, home), SETTINGS_FILE);
32808
+ return join23(piAgentDirOf(env, home), SETTINGS_FILE);
32654
32809
  case "gemini":
32655
- return join22(geminiDirOf(env, home), SETTINGS_FILE);
32810
+ return join23(geminiDirOf(env, home), SETTINGS_FILE);
32656
32811
  // D-R38-GEMINI-HOME-1
32657
32812
  case "copilot-cli":
32658
32813
  return null;
32659
32814
  default:
32660
- return join22(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
32815
+ return join23(home, ...AGENT_HOME_DIR[agent], SETTINGS_FILE);
32661
32816
  }
32662
32817
  }
32663
32818
  function cell3(value) {
@@ -32669,8 +32824,8 @@ function toRow(file2, edit) {
32669
32824
  function writeWithRollback(file2, text, write2, atomic) {
32670
32825
  const trash = file2 + UPGRADE_TRASH_SUFFIX;
32671
32826
  const tmp = `${file2}${HOST_CONFIG_TMP_SUFFIX}.${process.pid}`;
32672
- const had = existsSync18(file2);
32673
- mkdirSync7(dirname12(file2), { recursive: true });
32827
+ const had = existsSync19(file2);
32828
+ mkdirSync8(dirname12(file2), { recursive: true });
32674
32829
  if (had) copyFileSync(file2, trash);
32675
32830
  try {
32676
32831
  write2(tmp, text);
@@ -32699,7 +32854,7 @@ function regenerateHostConfig(row5, home, opts = {}) {
32699
32854
  if (requested === null) return [];
32700
32855
  const current = readHostConfig(row5.id, requested);
32701
32856
  const result = mergeOwnEntries(row5.id, current.text, current.format, row5);
32702
- const exists = existsSync18(current.path);
32857
+ const exists = existsSync19(current.path);
32703
32858
  if (exists && result.text === current.text) return [];
32704
32859
  const text = result.text === "" && current.format !== "toml" ? JSON.stringify({}) : result.text;
32705
32860
  writeWithRollback(current.path, current.layout === void 0 ? text : withLayout(text, current.layout), opts.write ?? defaultWrite, opts.atomic ?? {});
@@ -32707,15 +32862,15 @@ function regenerateHostConfig(row5, home, opts = {}) {
32707
32862
  }
32708
32863
 
32709
32864
  // src/core/ops/uninstall.ts
32710
- import { existsSync as existsSync19, readdirSync as readdirSync8, rmSync as rmSync6, writeFileSync as writeFileSync7 } from "node:fs";
32711
- import { join as join23 } from "node:path";
32865
+ import { existsSync as existsSync20, readdirSync as readdirSync9, rmSync as rmSync6, writeFileSync as writeFileSync7 } from "node:fs";
32866
+ import { join as join24 } from "node:path";
32712
32867
  function row2(area, before, after) {
32713
32868
  return { area, before, after };
32714
32869
  }
32715
32870
  function stopServers(configDir, projectKey) {
32716
32871
  const stopped = listLiveOwners(configDir, projectKey);
32717
- const dir = join23(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
32718
- for (const serverId of stopped) writeFileSync7(join23(dir, serverId + OWNER_STOP_EXT), "", "utf8");
32872
+ const dir = join24(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME);
32873
+ for (const serverId of stopped) writeFileSync7(join24(dir, serverId + OWNER_STOP_EXT), "", "utf8");
32719
32874
  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 };
32720
32875
  }
32721
32876
  function rootOrNull(adapter, env) {
@@ -32733,15 +32888,15 @@ function removeCache(adapter, env, configDir) {
32733
32888
  const root = rootOrNull(adapter, env);
32734
32889
  if (root === null) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
32735
32890
  if (adapter.installMode === "marketplace") {
32736
- const cache = join23(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
32891
+ const cache = join24(claudeDirOf(env, requireHomeDir(env)), HOST_PLUGINS_DIR_NAME, PLUGIN_CACHE_DIR_NAME);
32737
32892
  if (!isInside(cache, root) || isInside(root, cache)) return row2(UPGRADE_CACHE_AREA, root, UPGRADE_CACHE_BY_HAND);
32738
32893
  }
32739
32894
  rmSync6(root, { recursive: true, force: true });
32740
32895
  return row2(UPGRADE_CACHE_AREA, root, UPGRADE_REMOVED);
32741
32896
  }
32742
32897
  case "plugin": {
32743
- const agentDir = join23(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
32744
- if (!existsSync19(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
32898
+ const agentDir = join24(configDir, DATA_PLUGINS_DIR_NAME, adapter.id);
32899
+ if (!existsSync20(agentDir)) return row2(UPGRADE_CACHE_AREA, "", UPGRADE_NOT_FOUND);
32745
32900
  rmSync6(agentDir, { recursive: true, force: true });
32746
32901
  return row2(UPGRADE_CACHE_AREA, agentDir, UPGRADE_REMOVED);
32747
32902
  }
@@ -32786,7 +32941,7 @@ function ownEntries2(agent, env) {
32786
32941
  }
32787
32942
  if (agent === "opencode") {
32788
32943
  return [{
32789
- file: join23(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
32944
+ file: join24(opencodeDirOf(env, home), OPENCODE_BASE_CONFIG_FILE),
32790
32945
  // D-WIN-OPENCODE-DIR-1
32791
32946
  key: OPENCODE_PLUGIN_KEY,
32792
32947
  shown: OPENCODE_PLUGIN_KEY,
@@ -32797,7 +32952,7 @@ function ownEntries2(agent, env) {
32797
32952
  if (agent === "pi") {
32798
32953
  const agentDir = piAgentDirOf(env, home);
32799
32954
  return [{
32800
- file: join23(agentDir, SETTINGS_FILE),
32955
+ file: join24(agentDir, SETTINGS_FILE),
32801
32956
  key: PI_PACKAGES_KEY,
32802
32957
  shown: PI_PACKAGES_KEY,
32803
32958
  has: (v) => Array.isArray(v) && v.some((x) => piSource2(x) === PI_GIT_PACKAGE),
@@ -32819,12 +32974,12 @@ function removeOwnEntries(agent, env) {
32819
32974
  return rows.length === 0 ? [row2(UPGRADE_CONFIG_AREA, "", UPGRADE_NOT_FOUND)] : rows;
32820
32975
  }
32821
32976
  function removeProjectData(configDir, projectKey) {
32822
- const projects = join23(configDir, PROJECTS_DIR_NAME);
32823
- const dir = join23(projects, projectKey);
32824
- if (!existsSync19(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
32977
+ const projects = join24(configDir, PROJECTS_DIR_NAME);
32978
+ const dir = join24(projects, projectKey);
32979
+ if (!existsSync20(dir)) return row2(UPGRADE_DATA_AREA, "", UPGRADE_NOT_FOUND);
32825
32980
  if (dir === projects || !isInside(projects, dir)) throw new CtxError("OUTSIDE_ROOT", { p: dir, root: projects });
32826
- for (const name of readdirSync8(dir)) {
32827
- if (name !== OWNERS_DIR_NAME) rmSync6(join23(dir, name), { recursive: true, force: true });
32981
+ for (const name of readdirSync9(dir)) {
32982
+ if (name !== OWNERS_DIR_NAME) rmSync6(join24(dir, name), { recursive: true, force: true });
32828
32983
  }
32829
32984
  return row2(UPGRADE_DATA_AREA, dir, UPGRADE_DATA_DELETED);
32830
32985
  }
@@ -32832,12 +32987,12 @@ function runUninstall(input) {
32832
32987
  const configDir = resolveConfigDir(input.env);
32833
32988
  const stop = stopServers(configDir, input.project.projectKey);
32834
32989
  const rows = [stop.row, removeCache(input.adapter, input.env, configDir), ...removeOwnEntries(input.adapter.id, input.env)];
32835
- rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join23(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
32990
+ rows.push(input.confirmDelete ? removeProjectData(configDir, input.project.projectKey) : row2(UPGRADE_DATA_AREA, join24(configDir, PROJECTS_DIR_NAME, input.project.projectKey), UPGRADE_DATA_KEPT));
32836
32991
  return { rows, stopped: stop.stopped };
32837
32992
  }
32838
32993
 
32839
32994
  // src/core/ops/v1-remove.ts
32840
- import { copyFileSync as copyFileSync2, existsSync as existsSync20, readFileSync as readFileSync17, rmSync as rmSync7 } from "node:fs";
32995
+ import { copyFileSync as copyFileSync2, existsSync as existsSync21, readFileSync as readFileSync18, rmSync as rmSync7 } from "node:fs";
32841
32996
  var isObj4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
32842
32997
  var areaOf = (f) => f.path === "" ? f.file : f.file + UPGRADE_AREA_KEY_SEP + f.path;
32843
32998
  var row3 = (f, after) => ({ area: areaOf(f), before: f.reason, after });
@@ -32849,7 +33004,7 @@ function moveAside(target, undo) {
32849
33004
  }
32850
33005
  function keepAside(target, undo) {
32851
33006
  let aside = target + UPGRADE_ASIDE_SUFFIX;
32852
- for (let n = 2; existsSync20(aside); n += 1) aside = target + UPGRADE_ASIDE_SUFFIX + "-" + n;
33007
+ for (let n = 2; existsSync21(aside); n += 1) aside = target + UPGRADE_ASIDE_SUFFIX + "-" + n;
32853
33008
  renameWithRetry(target, aside);
32854
33009
  undo.push({ trash: aside, target, keep: true });
32855
33010
  return aside;
@@ -32888,8 +33043,8 @@ function locate(doc, path8) {
32888
33043
  return null;
32889
33044
  }
32890
33045
  function stripJsonEntries(agent, file2, findings, kept, undo) {
32891
- const layout = hostLayout(readFileSync17(file2, "utf8"));
32892
- const text = hostText(readFileSync17(file2, "utf8"));
33046
+ const layout = hostLayout(readFileSync18(file2, "utf8"));
33047
+ const text = hostText(readFileSync18(file2, "utf8"));
32893
33048
  const doc = parseHostConfig(agent, file2, text, "jsonc");
32894
33049
  const hit = /* @__PURE__ */ new Set();
32895
33050
  const byContainer = /* @__PURE__ */ new Map();
@@ -32926,20 +33081,20 @@ function removeV1(agent, findings, project) {
32926
33081
  if (UPGRADE_REPORT_ONLY_REASONS.includes(f.reason)) done.set(f, UPGRADE_REPORT_ONLY);
32927
33082
  else if (f.path === "") {
32928
33083
  if (project !== void 0 && reachedThroughLink(project, f.file)) done.set(f, UPGRADE_REPORT_ONLY);
32929
- else if (existsSync20(f.file) && UPGRADE_KEEP_ASIDE_REASONS.includes(f.reason)) done.set(f, UPGRADE_MOVED_ASIDE + keepAside(f.file, undo));
32930
- else if (existsSync20(f.file)) {
33084
+ else if (existsSync21(f.file) && UPGRADE_KEEP_ASIDE_REASONS.includes(f.reason)) done.set(f, UPGRADE_MOVED_ASIDE + keepAside(f.file, undo));
33085
+ else if (existsSync21(f.file)) {
32931
33086
  moveAside(f.file, undo);
32932
33087
  done.set(f, UPGRADE_REMOVED);
32933
33088
  } else done.set(f, UPGRADE_NOT_FOUND);
32934
33089
  } else entries.set(f.file, [...entries.get(f.file) ?? [], f]);
32935
33090
  }
32936
33091
  for (const [file2, list4] of entries) {
32937
- if (!existsSync20(file2)) {
33092
+ if (!existsSync21(file2)) {
32938
33093
  for (const f of list4) done.set(f, UPGRADE_NOT_FOUND);
32939
33094
  continue;
32940
33095
  }
32941
33096
  if (file2.endsWith(TOML_EXT)) {
32942
- const rawToml = readFileSync17(file2, "utf8");
33097
+ const rawToml = readFileSync18(file2, "utf8");
32943
33098
  const tomlLayout = hostLayout(rawToml);
32944
33099
  let text = hostText(rawToml);
32945
33100
  for (const f of list4) {
@@ -32967,7 +33122,7 @@ function removeV1(agent, findings, project) {
32967
33122
  },
32968
33123
  rollback() {
32969
33124
  for (const u of undo.splice(0).reverse()) {
32970
- if (!existsSync20(u.trash)) continue;
33125
+ if (!existsSync21(u.trash)) continue;
32971
33126
  rmSync7(u.target, { recursive: true, force: true });
32972
33127
  renameWithRetry(u.trash, u.target);
32973
33128
  }
@@ -33098,8 +33253,8 @@ function checkCall(tool, input) {
33098
33253
 
33099
33254
  // src/entries/server.ts
33100
33255
  import { randomUUID } from "node:crypto";
33101
- import { existsSync as existsSync22, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
33102
- import { dirname as dirname13, join as join25 } from "node:path";
33256
+ import { existsSync as existsSync23, realpathSync as realpathSync12, rmSync as rmSync9 } from "node:fs";
33257
+ import { dirname as dirname13, join as join26 } from "node:path";
33103
33258
  import { fileURLToPath as fileURLToPath3 } from "node:url";
33104
33259
 
33105
33260
  // node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
@@ -61164,8 +61319,8 @@ function installExitGuard(opts) {
61164
61319
  }
61165
61320
 
61166
61321
  // src/core/store/cleanup.ts
61167
- import { existsSync as existsSync21, readdirSync as readdirSync9, rmSync as rmSync8 } from "node:fs";
61168
- import { join as join24 } from "node:path";
61322
+ import { existsSync as existsSync22, readdirSync as readdirSync10, rmSync as rmSync8 } from "node:fs";
61323
+ import { join as join25 } from "node:path";
61169
61324
  function deleteSource(raw, id) {
61170
61325
  raw.prepare("DELETE FROM sources WHERE id = ?").run(id);
61171
61326
  deleteChunkRows(raw, { sourceId: id });
@@ -61200,7 +61355,7 @@ function userVersion(raw) {
61200
61355
  return raw.prepare("PRAGMA user_version").get().user_version;
61201
61356
  }
61202
61357
  function openForSweep(dbPath, projectKey) {
61203
- if (!existsSync21(dbPath) && (existsSync21(dbPath + DB_WAL_SUFFIX) || existsSync21(dbPath + DB_SHM_SUFFIX))) {
61358
+ if (!existsSync22(dbPath) && (existsSync22(dbPath + DB_WAL_SUFFIX) || existsSync22(dbPath + DB_SHM_SUFFIX))) {
61204
61359
  throw new CtxError("DB_GONE");
61205
61360
  }
61206
61361
  const sqlite = process.getBuiltinModule("node:sqlite");
@@ -61221,8 +61376,8 @@ function lastAccess(raw) {
61221
61376
  return row5.t;
61222
61377
  }
61223
61378
  function sweepOne(configDir, projectKey, cutoff) {
61224
- const dir = join24(configDir, PROJECTS_DIR_NAME, projectKey);
61225
- const db = openForSweep(join24(dir, DB_FILE_NAME), projectKey);
61379
+ const dir = join25(configDir, PROJECTS_DIR_NAME, projectKey);
61380
+ const db = openForSweep(join25(dir, DB_FILE_NAME), projectKey);
61226
61381
  let dead;
61227
61382
  try {
61228
61383
  dead = withWrite(db, (h) => listLiveOwners(configDir, projectKey).length === 0 && lastAccess(h.raw) < cutoff);
@@ -61235,7 +61390,7 @@ function sweepOne(configDir, projectKey, cutoff) {
61235
61390
  function sweepDeadProjects(configDir) {
61236
61391
  let entries;
61237
61392
  try {
61238
- entries = readdirSync9(join24(configDir, PROJECTS_DIR_NAME), { withFileTypes: true });
61393
+ entries = readdirSync10(join25(configDir, PROJECTS_DIR_NAME), { withFileTypes: true });
61239
61394
  } catch (err) {
61240
61395
  if (err.code === "ENOENT") return [];
61241
61396
  throw err;
@@ -61400,15 +61555,15 @@ async function startServer(argv, env) {
61400
61555
  opening.catch(() => pending.delete(project.dbPath));
61401
61556
  }
61402
61557
  const db = await opening;
61403
- if (!existsSync22(db.path)) throw new CtxError("DB_GONE");
61558
+ if (!existsSync23(db.path)) throw new CtxError("DB_GONE");
61404
61559
  return db;
61405
61560
  }
61406
61561
  function stopMarker(configDir, projectKey) {
61407
- return join25(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
61562
+ return join26(configDir, PROJECTS_DIR_NAME, projectKey, OWNERS_DIR_NAME, serverId + OWNER_STOP_EXT);
61408
61563
  }
61409
61564
  function stopRequested() {
61410
61565
  const configDir = resolveConfigDir(process.env);
61411
- return held.some((db) => existsSync22(stopMarker(configDir, db.projectKey)));
61566
+ return held.some((db) => existsSync23(stopMarker(configDir, db.projectKey)));
61412
61567
  }
61413
61568
  async function journal(project, ctx, name, reply4) {
61414
61569
  const db = await ownDb(project);