context-mode 2.0.0-next.24 → 2.0.0-next.25

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.
@@ -12,5 +12,5 @@
12
12
  }
13
13
  },
14
14
  "name": "context-mode",
15
- "version": "2.0.0-next.24"
15
+ "version": "2.0.0-next.25"
16
16
  }
package/run.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import{createRequire as __cmRequire}from"node:module";if(typeof process.getBuiltinModule!=="function")process.getBuiltinModule=(id)=>__cmRequire(import.meta.url)(id);
2
2
 
3
3
  // src/entries/run.ts
4
- import { basename as basename2 } from "node:path";
4
+ import { basename as basename3 } from "node:path";
5
5
 
6
6
  // src/core/contracts/constants.ts
7
7
  var SERVER_KEY = "context-mode";
@@ -184,6 +184,8 @@ var HOST_SESSION_ENV = Object.freeze({ "claude-code": "CLAUDE_CODE_SESSION_ID" }
184
184
  var NODE_MIN = "24.15.0";
185
185
  var DATA_ROOT = "~/.context-mode";
186
186
  var REQUIRE_SECURITY_ENV = "CONTEXT_MODE_REQUIRE_SECURITY";
187
+ var PROJECT_PLUGIN_SCOPES = Object.freeze(["local", "project"]);
188
+ var PLUGIN_SCOPE_RANK = Object.freeze({ local: 0, project: 1, user: 2, managed: 2 });
187
189
  var MCP_HINT_EVERY_DEFAULT = 10;
188
190
  function readHintEvery(raw) {
189
191
  if (raw === void 0 || raw.trim() === "") return MCP_HINT_EVERY_DEFAULT;
@@ -405,7 +407,7 @@ var REPORT_ENV_ENUMS = Object.freeze({
405
407
 
406
408
  // src/core/tools/run-wrapper.ts
407
409
  import { randomUUID } from "node:crypto";
408
- import { dirname as dirname3, join as join5 } from "node:path";
410
+ import { dirname as dirname4, join as join5 } from "node:path";
409
411
 
410
412
  // src/adapters/claude-code.ts
411
413
  var TOOL_NAME_PREFIX = "mcp__plugin_context-mode_context-mode__";
@@ -3378,7 +3380,7 @@ function moreLine(intent, label) {
3378
3380
  }
3379
3381
 
3380
3382
  // src/core/policy/decide.ts
3381
- import { resolve as resolve2 } from "node:path";
3383
+ import { resolve as resolve3 } from "node:path";
3382
3384
 
3383
3385
  // src/core/policy/lexer.ts
3384
3386
  var OPS = ["&&", "||", ";;", "|&", ";", "|", "&", "(", ")"];
@@ -4660,7 +4662,7 @@ function psDumpFiles(script, cwd) {
4660
4662
  import { join as join2 } from "node:path";
4661
4663
 
4662
4664
  // src/core/project/config-dir.ts
4663
- import { join, posix, win32 } from "node:path";
4665
+ import { basename, dirname, join, posix, resolve as resolve2, win32 } from "node:path";
4664
4666
  var { mkdirSync: mkdirSync2, realpathSync } = process.getBuiltinModule("node:fs");
4665
4667
  function homeDirOf(env, platform = process.platform) {
4666
4668
  const set = (v) => v !== void 0 && v !== "";
@@ -5003,7 +5005,7 @@ function readPath(input) {
5003
5005
  }
5004
5006
  function userDenyHit(canonical, input, cwd, rules) {
5005
5007
  if (rules.length === 0) return null;
5006
- const readRule = (p) => matchesAnyDenyPattern(resolve2(cwd, p), rules, { tool: READ, projectDir: cwd });
5008
+ const readRule = (p) => matchesAnyDenyPattern(resolve3(cwd, p), rules, { tool: READ, projectDir: cwd });
5007
5009
  if (canonical === BASH) {
5008
5010
  const cmd = str(input.command);
5009
5011
  return cmd === void 0 ? null : matchesAnyDenyPattern(cmd, rules);
@@ -5114,7 +5116,7 @@ function read(ev, row, input) {
5114
5116
  if (!present(input.offset) && !present(input.limit)) {
5115
5117
  const p = readPath(input);
5116
5118
  if (p !== void 0) {
5117
- const abs = resolve2(ev.cwd, p);
5119
+ const abs = resolve3(ev.cwd, p);
5118
5120
  const size = fileSize(abs);
5119
5121
  if (size > OUTPUT_CAP) return deny(READ_DENY_MESSAGE(abs, size, row.toolNamePrefix));
5120
5122
  }
@@ -5127,7 +5129,7 @@ function shellDump(cmds, cwd, row) {
5127
5129
  let verdict = null;
5128
5130
  for (const c of cmds) {
5129
5131
  const name = c.argv0.toLowerCase();
5130
- if (name === CD_COMMAND && c.args.length === 1 && c.insideConstruct === void 0) dir = resolve2(dir, c.args[0]);
5132
+ if (name === CD_COMMAND && c.args.length === 1 && c.insideConstruct === void 0) dir = resolve3(dir, c.args[0]);
5131
5133
  if (c.redirectsToFile || c.endsInBoundedSink || c.pipesOut === true || c.insideConstruct !== void 0) continue;
5132
5134
  if (!has(SHELL_DUMP_COMMANDS, name)) continue;
5133
5135
  const d = dumpTarget(name, c.args);
@@ -5136,7 +5138,7 @@ function shellDump(cmds, cwd, row) {
5136
5138
  verdict = ALLOW;
5137
5139
  continue;
5138
5140
  }
5139
- const abs = resolve2(dir, d.file);
5141
+ const abs = resolve3(dir, d.file);
5140
5142
  const size = fileSize(abs);
5141
5143
  if (size > OUTPUT_CAP) return deny(READ_DENY_MESSAGE(abs, size, row.toolNamePrefix));
5142
5144
  }
@@ -5207,10 +5209,10 @@ function dumpTarget(name, args) {
5207
5209
  }
5208
5210
 
5209
5211
  // src/core/project/resolve.ts
5210
- import { basename, dirname as dirname2, join as join4, resolve as resolve3 } from "node:path";
5212
+ import { basename as basename2, dirname as dirname3, join as join4, resolve as resolve4 } from "node:path";
5211
5213
 
5212
5214
  // src/core/project/contain.ts
5213
- import { dirname, sep as sep2 } from "node:path";
5215
+ import { dirname as dirname2, sep as sep2 } from "node:path";
5214
5216
  var { realpathSync: realpathSync2 } = process.getBuiltinModule("node:fs");
5215
5217
  function real(p) {
5216
5218
  try {
@@ -5235,7 +5237,7 @@ function commonRoot(paths) {
5235
5237
  n = i;
5236
5238
  }
5237
5239
  let q = first;
5238
- while (components(q).length > n && dirname(q) !== q) q = dirname(q);
5240
+ while (components(q).length > n && dirname2(q) !== q) q = dirname2(q);
5239
5241
  return q;
5240
5242
  }
5241
5243
 
@@ -5402,9 +5404,9 @@ function gitDirs(dir) {
5402
5404
  const gitDir = gitDirAt(join4(cur, GIT_DIR_NAME));
5403
5405
  if (gitDir !== null) {
5404
5406
  const common = firstLine(join4(gitDir, GIT_COMMONDIR_FILE));
5405
- return { commonDir: realpathSync3.native(common === null ? gitDir : resolve3(gitDir, common)), worktree: cur, start };
5407
+ return { commonDir: realpathSync3.native(common === null ? gitDir : resolve4(gitDir, common)), worktree: cur, start };
5406
5408
  }
5407
- const up = dirname2(cur);
5409
+ const up = dirname3(cur);
5408
5410
  if (up === cur) return { commonDir: null, start };
5409
5411
  cur = up;
5410
5412
  }
@@ -5417,7 +5419,7 @@ function gitDirAt(dotGit) {
5417
5419
  } else {
5418
5420
  const line = firstLine(dotGit);
5419
5421
  if (line === null || !line.startsWith(GITDIR_FILE_PREFIX)) return null;
5420
- gitDir = resolve3(dirname2(dotGit), line.slice(GITDIR_FILE_PREFIX.length));
5422
+ gitDir = resolve4(dirname3(dotGit), line.slice(GITDIR_FILE_PREFIX.length));
5421
5423
  }
5422
5424
  } catch {
5423
5425
  return null;
@@ -5442,9 +5444,9 @@ function git(dir, args) {
5442
5444
  return r.stdout.split("\n").filter((l) => l !== "");
5443
5445
  }
5444
5446
  function containmentRootOf(dir, commonDir) {
5445
- const repoDir = basename(commonDir) === GIT_DIR_NAME ? dirname2(commonDir) : commonDir;
5447
+ const repoDir = basename2(commonDir) === GIT_DIR_NAME ? dirname3(commonDir) : commonDir;
5446
5448
  const worktrees = git(dir, ["worktree", "list", "--porcelain"]).filter((l) => l.startsWith(GIT_WORKTREE_LINE_PREFIX)).map((l) => l.slice(GIT_WORKTREE_LINE_PREFIX.length));
5447
- return commonRoot([dirname2(repoDir), ...worktrees]);
5449
+ return commonRoot([dirname3(repoDir), ...worktrees]);
5448
5450
  }
5449
5451
  function resolveProject(agent, src) {
5450
5452
  const source = sourceOf(agent);
@@ -5630,10 +5632,10 @@ function startArgv(argv) {
5630
5632
  return sh === null ? null : [sh, ...argv];
5631
5633
  }
5632
5634
  function runProcess(argv, o) {
5633
- return new Promise((resolve4) => {
5635
+ return new Promise((resolve5) => {
5634
5636
  const isWin2 = process.platform === "win32";
5635
5637
  const start = startArgv(argv);
5636
- if (start === null) return resolve4(NOT_STARTED);
5638
+ if (start === null) return resolve5(NOT_STARTED);
5637
5639
  let child;
5638
5640
  try {
5639
5641
  child = spawn(start[0], start.slice(1), {
@@ -5647,7 +5649,7 @@ function runProcess(argv, o) {
5647
5649
  windowsHide: true
5648
5650
  });
5649
5651
  } catch {
5650
- return resolve4(NOT_STARTED);
5652
+ return resolve5(NOT_STARTED);
5651
5653
  }
5652
5654
  const stdoutChunks = [];
5653
5655
  const stderrChunks = [];
@@ -5672,7 +5674,7 @@ function runProcess(argv, o) {
5672
5674
  settled = true;
5673
5675
  clearTimeout(timer);
5674
5676
  o.signal.removeEventListener("abort", onAbort);
5675
- resolve4({
5677
+ resolve5({
5676
5678
  stdout: Buffer.concat(stdoutChunks),
5677
5679
  stderr: Buffer.concat(stderrChunks),
5678
5680
  exitCode,
@@ -6120,7 +6122,7 @@ async function runWrapperMain(argv, env) {
6120
6122
  let text;
6121
6123
  try {
6122
6124
  const { sourceId } = indexText(db, project, sessionId, sourceLabel(command), combined, "text");
6123
- const more = moreLine2(dirname3(argv[1] ?? ""), sourceId, description);
6125
+ const more = moreLine2(dirname4(argv[1] ?? ""), sourceId, description);
6124
6126
  const picked = selectChunks(db, sourceId, description, OUTPUT_CAP - bytes(head) - bytes(more) - 2);
6125
6127
  text = head + "\n" + picked.text + (picked.more === null ? "" : "\n" + more);
6126
6128
  } finally {
@@ -6154,5 +6156,5 @@ async function searchWrapperMain(argv, _env) {
6154
6156
  }
6155
6157
 
6156
6158
  // src/entries/run.ts
6157
- var main = basename2(process.argv[1] ?? "") === SEARCH_WRAPPER_FILE ? searchWrapperMain : runWrapperMain;
6159
+ var main = basename3(process.argv[1] ?? "") === SEARCH_WRAPPER_FILE ? searchWrapperMain : runWrapperMain;
6158
6160
  void main(process.argv, process.env);
package/search.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import{createRequire as __cmRequire}from"node:module";if(typeof process.getBuiltinModule!=="function")process.getBuiltinModule=(id)=>__cmRequire(import.meta.url)(id);
2
2
 
3
3
  // src/entries/run.ts
4
- import { basename as basename2 } from "node:path";
4
+ import { basename as basename3 } from "node:path";
5
5
 
6
6
  // src/core/contracts/constants.ts
7
7
  var SERVER_KEY = "context-mode";
@@ -184,6 +184,8 @@ var HOST_SESSION_ENV = Object.freeze({ "claude-code": "CLAUDE_CODE_SESSION_ID" }
184
184
  var NODE_MIN = "24.15.0";
185
185
  var DATA_ROOT = "~/.context-mode";
186
186
  var REQUIRE_SECURITY_ENV = "CONTEXT_MODE_REQUIRE_SECURITY";
187
+ var PROJECT_PLUGIN_SCOPES = Object.freeze(["local", "project"]);
188
+ var PLUGIN_SCOPE_RANK = Object.freeze({ local: 0, project: 1, user: 2, managed: 2 });
187
189
  var MCP_HINT_EVERY_DEFAULT = 10;
188
190
  function readHintEvery(raw) {
189
191
  if (raw === void 0 || raw.trim() === "") return MCP_HINT_EVERY_DEFAULT;
@@ -405,7 +407,7 @@ var REPORT_ENV_ENUMS = Object.freeze({
405
407
 
406
408
  // src/core/tools/run-wrapper.ts
407
409
  import { randomUUID } from "node:crypto";
408
- import { dirname as dirname3, join as join5 } from "node:path";
410
+ import { dirname as dirname4, join as join5 } from "node:path";
409
411
 
410
412
  // src/adapters/claude-code.ts
411
413
  var TOOL_NAME_PREFIX = "mcp__plugin_context-mode_context-mode__";
@@ -3378,7 +3380,7 @@ function moreLine(intent, label) {
3378
3380
  }
3379
3381
 
3380
3382
  // src/core/policy/decide.ts
3381
- import { resolve as resolve2 } from "node:path";
3383
+ import { resolve as resolve3 } from "node:path";
3382
3384
 
3383
3385
  // src/core/policy/lexer.ts
3384
3386
  var OPS = ["&&", "||", ";;", "|&", ";", "|", "&", "(", ")"];
@@ -4660,7 +4662,7 @@ function psDumpFiles(script, cwd) {
4660
4662
  import { join as join2 } from "node:path";
4661
4663
 
4662
4664
  // src/core/project/config-dir.ts
4663
- import { join, posix, win32 } from "node:path";
4665
+ import { basename, dirname, join, posix, resolve as resolve2, win32 } from "node:path";
4664
4666
  var { mkdirSync: mkdirSync2, realpathSync } = process.getBuiltinModule("node:fs");
4665
4667
  function homeDirOf(env, platform = process.platform) {
4666
4668
  const set = (v) => v !== void 0 && v !== "";
@@ -5003,7 +5005,7 @@ function readPath(input) {
5003
5005
  }
5004
5006
  function userDenyHit(canonical, input, cwd, rules) {
5005
5007
  if (rules.length === 0) return null;
5006
- const readRule = (p) => matchesAnyDenyPattern(resolve2(cwd, p), rules, { tool: READ, projectDir: cwd });
5008
+ const readRule = (p) => matchesAnyDenyPattern(resolve3(cwd, p), rules, { tool: READ, projectDir: cwd });
5007
5009
  if (canonical === BASH) {
5008
5010
  const cmd = str(input.command);
5009
5011
  return cmd === void 0 ? null : matchesAnyDenyPattern(cmd, rules);
@@ -5114,7 +5116,7 @@ function read(ev, row, input) {
5114
5116
  if (!present(input.offset) && !present(input.limit)) {
5115
5117
  const p = readPath(input);
5116
5118
  if (p !== void 0) {
5117
- const abs = resolve2(ev.cwd, p);
5119
+ const abs = resolve3(ev.cwd, p);
5118
5120
  const size = fileSize(abs);
5119
5121
  if (size > OUTPUT_CAP) return deny(READ_DENY_MESSAGE(abs, size, row.toolNamePrefix));
5120
5122
  }
@@ -5127,7 +5129,7 @@ function shellDump(cmds, cwd, row) {
5127
5129
  let verdict = null;
5128
5130
  for (const c of cmds) {
5129
5131
  const name = c.argv0.toLowerCase();
5130
- if (name === CD_COMMAND && c.args.length === 1 && c.insideConstruct === void 0) dir = resolve2(dir, c.args[0]);
5132
+ if (name === CD_COMMAND && c.args.length === 1 && c.insideConstruct === void 0) dir = resolve3(dir, c.args[0]);
5131
5133
  if (c.redirectsToFile || c.endsInBoundedSink || c.pipesOut === true || c.insideConstruct !== void 0) continue;
5132
5134
  if (!has(SHELL_DUMP_COMMANDS, name)) continue;
5133
5135
  const d = dumpTarget(name, c.args);
@@ -5136,7 +5138,7 @@ function shellDump(cmds, cwd, row) {
5136
5138
  verdict = ALLOW;
5137
5139
  continue;
5138
5140
  }
5139
- const abs = resolve2(dir, d.file);
5141
+ const abs = resolve3(dir, d.file);
5140
5142
  const size = fileSize(abs);
5141
5143
  if (size > OUTPUT_CAP) return deny(READ_DENY_MESSAGE(abs, size, row.toolNamePrefix));
5142
5144
  }
@@ -5207,10 +5209,10 @@ function dumpTarget(name, args) {
5207
5209
  }
5208
5210
 
5209
5211
  // src/core/project/resolve.ts
5210
- import { basename, dirname as dirname2, join as join4, resolve as resolve3 } from "node:path";
5212
+ import { basename as basename2, dirname as dirname3, join as join4, resolve as resolve4 } from "node:path";
5211
5213
 
5212
5214
  // src/core/project/contain.ts
5213
- import { dirname, sep as sep2 } from "node:path";
5215
+ import { dirname as dirname2, sep as sep2 } from "node:path";
5214
5216
  var { realpathSync: realpathSync2 } = process.getBuiltinModule("node:fs");
5215
5217
  function real(p) {
5216
5218
  try {
@@ -5235,7 +5237,7 @@ function commonRoot(paths) {
5235
5237
  n = i;
5236
5238
  }
5237
5239
  let q = first;
5238
- while (components(q).length > n && dirname(q) !== q) q = dirname(q);
5240
+ while (components(q).length > n && dirname2(q) !== q) q = dirname2(q);
5239
5241
  return q;
5240
5242
  }
5241
5243
 
@@ -5402,9 +5404,9 @@ function gitDirs(dir) {
5402
5404
  const gitDir = gitDirAt(join4(cur, GIT_DIR_NAME));
5403
5405
  if (gitDir !== null) {
5404
5406
  const common = firstLine(join4(gitDir, GIT_COMMONDIR_FILE));
5405
- return { commonDir: realpathSync3.native(common === null ? gitDir : resolve3(gitDir, common)), worktree: cur, start };
5407
+ return { commonDir: realpathSync3.native(common === null ? gitDir : resolve4(gitDir, common)), worktree: cur, start };
5406
5408
  }
5407
- const up = dirname2(cur);
5409
+ const up = dirname3(cur);
5408
5410
  if (up === cur) return { commonDir: null, start };
5409
5411
  cur = up;
5410
5412
  }
@@ -5417,7 +5419,7 @@ function gitDirAt(dotGit) {
5417
5419
  } else {
5418
5420
  const line = firstLine(dotGit);
5419
5421
  if (line === null || !line.startsWith(GITDIR_FILE_PREFIX)) return null;
5420
- gitDir = resolve3(dirname2(dotGit), line.slice(GITDIR_FILE_PREFIX.length));
5422
+ gitDir = resolve4(dirname3(dotGit), line.slice(GITDIR_FILE_PREFIX.length));
5421
5423
  }
5422
5424
  } catch {
5423
5425
  return null;
@@ -5442,9 +5444,9 @@ function git(dir, args) {
5442
5444
  return r.stdout.split("\n").filter((l) => l !== "");
5443
5445
  }
5444
5446
  function containmentRootOf(dir, commonDir) {
5445
- const repoDir = basename(commonDir) === GIT_DIR_NAME ? dirname2(commonDir) : commonDir;
5447
+ const repoDir = basename2(commonDir) === GIT_DIR_NAME ? dirname3(commonDir) : commonDir;
5446
5448
  const worktrees = git(dir, ["worktree", "list", "--porcelain"]).filter((l) => l.startsWith(GIT_WORKTREE_LINE_PREFIX)).map((l) => l.slice(GIT_WORKTREE_LINE_PREFIX.length));
5447
- return commonRoot([dirname2(repoDir), ...worktrees]);
5449
+ return commonRoot([dirname3(repoDir), ...worktrees]);
5448
5450
  }
5449
5451
  function resolveProject(agent, src) {
5450
5452
  const source = sourceOf(agent);
@@ -5630,10 +5632,10 @@ function startArgv(argv) {
5630
5632
  return sh === null ? null : [sh, ...argv];
5631
5633
  }
5632
5634
  function runProcess(argv, o) {
5633
- return new Promise((resolve4) => {
5635
+ return new Promise((resolve5) => {
5634
5636
  const isWin2 = process.platform === "win32";
5635
5637
  const start = startArgv(argv);
5636
- if (start === null) return resolve4(NOT_STARTED);
5638
+ if (start === null) return resolve5(NOT_STARTED);
5637
5639
  let child;
5638
5640
  try {
5639
5641
  child = spawn(start[0], start.slice(1), {
@@ -5647,7 +5649,7 @@ function runProcess(argv, o) {
5647
5649
  windowsHide: true
5648
5650
  });
5649
5651
  } catch {
5650
- return resolve4(NOT_STARTED);
5652
+ return resolve5(NOT_STARTED);
5651
5653
  }
5652
5654
  const stdoutChunks = [];
5653
5655
  const stderrChunks = [];
@@ -5672,7 +5674,7 @@ function runProcess(argv, o) {
5672
5674
  settled = true;
5673
5675
  clearTimeout(timer);
5674
5676
  o.signal.removeEventListener("abort", onAbort);
5675
- resolve4({
5677
+ resolve5({
5676
5678
  stdout: Buffer.concat(stdoutChunks),
5677
5679
  stderr: Buffer.concat(stderrChunks),
5678
5680
  exitCode,
@@ -6120,7 +6122,7 @@ async function runWrapperMain(argv, env) {
6120
6122
  let text;
6121
6123
  try {
6122
6124
  const { sourceId } = indexText(db, project, sessionId, sourceLabel(command), combined, "text");
6123
- const more = moreLine2(dirname3(argv[1] ?? ""), sourceId, description);
6125
+ const more = moreLine2(dirname4(argv[1] ?? ""), sourceId, description);
6124
6126
  const picked = selectChunks(db, sourceId, description, OUTPUT_CAP - bytes(head) - bytes(more) - 2);
6125
6127
  text = head + "\n" + picked.text + (picked.more === null ? "" : "\n" + more);
6126
6128
  } finally {
@@ -6154,5 +6156,5 @@ async function searchWrapperMain(argv, _env) {
6154
6156
  }
6155
6157
 
6156
6158
  // src/entries/run.ts
6157
- var main = basename2(process.argv[1] ?? "") === SEARCH_WRAPPER_FILE ? searchWrapperMain : runWrapperMain;
6159
+ var main = basename3(process.argv[1] ?? "") === SEARCH_WRAPPER_FILE ? searchWrapperMain : runWrapperMain;
6158
6160
  void main(process.argv, process.env);