context-mode 1.0.122 → 1.0.123

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.
@@ -6,14 +6,14 @@
6
6
  },
7
7
  "metadata": {
8
8
  "description": "Claude Code plugins by Mert Koseoğlu",
9
- "version": "1.0.122"
9
+ "version": "1.0.123"
10
10
  },
11
11
  "plugins": [
12
12
  {
13
13
  "name": "context-mode",
14
14
  "source": "./",
15
15
  "description": "Claude Code MCP plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
16
- "version": "1.0.122",
16
+ "version": "1.0.123",
17
17
  "author": {
18
18
  "name": "Mert Koseoğlu"
19
19
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "1.0.122",
3
+ "version": "1.0.123",
4
4
  "description": "MCP server that saves 98% of your context window with session continuity. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and automatic state restore across compactions.",
5
5
  "author": {
6
6
  "name": "Mert Koseoğlu",
@@ -3,7 +3,7 @@
3
3
  "name": "Context Mode",
4
4
  "kind": "tool",
5
5
  "description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
6
- "version": "1.0.122",
6
+ "version": "1.0.123",
7
7
  "sandbox": {
8
8
  "mode": "permissive",
9
9
  "filesystem_access": "full",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "context-mode",
3
- "version": "1.0.122",
3
+ "version": "1.0.123",
4
4
  "description": "OpenClaw plugin that saves 98% of your context window. Sandboxed code execution in 11 languages, FTS5 knowledge base with BM25 ranking, and intent-driven search.",
5
5
  "author": {
6
6
  "name": "Mert Koseoğlu",
@@ -21,6 +21,12 @@ export const CLIENT_NAME_TO_PLATFORM = {
21
21
  "Kiro CLI": "kiro",
22
22
  "Pi CLI": "pi",
23
23
  "Pi Coding Agent": "pi",
24
+ // Issue #542 — Pi rebranded to OMP. Upstream
25
+ // refs/platforms/oh-my-pi/packages/coding-agent/src/mcp/client.ts:46-49
26
+ // ships clientInfo.name = "omp-coding-agent". Resolved to the OMP
27
+ // adapter (~/.omp/, PI_CODING_AGENT_DIR). Legacy "Pi CLI" /
28
+ // "Pi Coding Agent" entries above still resolve to the pi adapter.
29
+ "omp-coding-agent": "omp",
24
30
  "Zed": "zed",
25
31
  "zed": "zed",
26
32
  "qwen-code": "qwen-code",
@@ -33,7 +33,7 @@ export declare function __seedClaudeCodePluginCacheMissForTests(): void;
33
33
  * Single source of truth — consumed by detectPlatform() below and by
34
34
  * tests that need to clear platform-related env vars deterministically.
35
35
  */
36
- export declare const PLATFORM_ENV_VARS: readonly [readonly ["claude-code", readonly ["CLAUDE_CODE_ENTRYPOINT", "CLAUDE_PLUGIN_ROOT", "CLAUDE_PROJECT_DIR", "CLAUDE_SESSION_ID"]], readonly ["antigravity", readonly ["ANTIGRAVITY_CLI_ALIAS"]], readonly ["cursor", readonly ["CURSOR_TRACE_ID", "CURSOR_CLI"]], readonly ["kilo", readonly ["KILO", "KILO_PID"]], readonly ["opencode", readonly ["OPENCODE", "OPENCODE_PID"]], readonly ["zed", readonly ["ZED_SESSION_ID", "ZED_TERM"]], readonly ["codex", readonly ["CODEX_THREAD_ID", "CODEX_CI"]], readonly ["gemini-cli", readonly ["GEMINI_PROJECT_DIR", "GEMINI_CLI"]], readonly ["vscode-copilot", readonly ["VSCODE_PID", "VSCODE_CWD"]], readonly ["jetbrains-copilot", readonly ["IDEA_INITIAL_DIRECTORY"]], readonly ["qwen-code", readonly ["QWEN_PROJECT_DIR"]], readonly ["omp", readonly ["PI_CODING_AGENT_DIR"]], readonly ["pi", readonly ["PI_PROJECT_DIR"]]];
36
+ export declare const PLATFORM_ENV_VARS: readonly [readonly ["claude-code", readonly ["CLAUDE_CODE_ENTRYPOINT", "CLAUDE_PLUGIN_ROOT", "CLAUDE_PROJECT_DIR", "CLAUDE_SESSION_ID"]], readonly ["antigravity", readonly ["ANTIGRAVITY_CLI_ALIAS"]], readonly ["cursor", readonly ["CURSOR_TRACE_ID", "CURSOR_CLI"]], readonly ["kilo", readonly ["KILO", "KILO_PID"]], readonly ["opencode", readonly ["OPENCODE", "OPENCODE_PID"]], readonly ["zed", readonly ["ZED_SESSION_ID", "ZED_TERM"]], readonly ["codex", readonly ["CODEX_THREAD_ID", "CODEX_CI"]], readonly ["gemini-cli", readonly ["GEMINI_PROJECT_DIR", "GEMINI_CLI"]], readonly ["vscode-copilot", readonly ["VSCODE_PID", "VSCODE_CWD"]], readonly ["jetbrains-copilot", readonly ["IDEA_INITIAL_DIRECTORY"]], readonly ["qwen-code", readonly ["QWEN_PROJECT_DIR"]], readonly ["omp", readonly ["PI_CODING_AGENT_DIR"]], readonly ["pi", readonly ["PI_CONFIG_DIR", "PI_SESSION_FILE", "PI_COMPILED"]]];
37
37
  /**
38
38
  * Sync map from platform identifier → home-relative path segments where that
39
39
  * platform stores its config. Mirrors the `super([...])` argument passed by
@@ -118,9 +118,15 @@ export const PLATFORM_ENV_VARS = [
118
118
  // agent-dir override per `packages/utils/src/dirs.ts:193`. Listed
119
119
  // BEFORE pi so OMP is not misclassified as Pi when both are installed.
120
120
  ["omp", ["PI_CODING_AGENT_DIR"]],
121
- // pi — PI_PROJECT_DIR consumed by src/adapters/pi/extension.ts:154 + src/server.ts:153
122
- // implies the Pi runtime sets it before invoking the extension.
123
- ["pi", ["PI_PROJECT_DIR"]],
121
+ // pi — Issue #542 marker correction. PI_PROJECT_DIR is a consumer-set
122
+ // var (read by src/adapters/pi/extension.ts) but is NOT auto-set by
123
+ // the Pi runtime — verified against
124
+ // refs/platforms/oh-my-pi/packages/coding-agent/src/mcp/transports/stdio.ts:55-63
125
+ // (env passthrough only, no synthesis). The Pi runtime DOES set
126
+ // PI_CONFIG_DIR (config dir override), PI_SESSION_FILE (active session
127
+ // path), and PI_COMPILED (binary build marker). PI_CODING_AGENT_DIR is
128
+ // owned by OMP above; keep it there.
129
+ ["pi", ["PI_CONFIG_DIR", "PI_SESSION_FILE", "PI_COMPILED"]],
124
130
  // openclaw — removed (runtime never sets OPENCLAW_HOME or OPENCLAW_CLI;
125
131
  // detection falls through to ~/.openclaw/ config-dir tier below).
126
132
  // kiro — not listed (no auto-set process env vars; ~/.kiro/ config-dir tier).
@@ -245,13 +251,15 @@ export function detectPlatform(clientInfo) {
245
251
  reason: "~/.codex/ directory exists",
246
252
  };
247
253
  }
248
- if (existsSync(resolve(home, ".cursor"))) {
249
- return {
250
- platform: "cursor",
251
- confidence: "medium",
252
- reason: "~/.cursor/ directory exists",
253
- };
254
- }
254
+ // Issue #542 — CLI agents BEFORE host IDEs.
255
+ //
256
+ // Cursor (a VSCode fork) is the most installed editor across our user
257
+ // base. Checking ~/.cursor/ first means every CLI agent co-installed
258
+ // with Cursor (Pi, OMP, Kiro, Qwen) silently routes through
259
+ // CursorAdapter even though the agent owns the session — Cursor merely
260
+ // hosts the terminal. Reorder: agents (.kiro/.omp/.pi/.qwen/.openclaw)
261
+ // win the medium-confidence tier, editors (~/.cursor/, ~/.vscode/,
262
+ // JetBrains) lose. Verified by the detect-config-dir.test.ts matrix.
255
263
  if (existsSync(resolve(home, ".kiro"))) {
256
264
  return {
257
265
  platform: "kiro",
@@ -288,6 +296,14 @@ export function detectPlatform(clientInfo) {
288
296
  reason: "~/.openclaw/ directory exists",
289
297
  };
290
298
  }
299
+ // Cursor / host IDEs — checked AFTER all CLI agents (issue #542).
300
+ if (existsSync(resolve(home, ".cursor"))) {
301
+ return {
302
+ platform: "cursor",
303
+ confidence: "medium",
304
+ reason: "~/.cursor/ directory exists",
305
+ };
306
+ }
291
307
  if (existsSync(resolve(home, ".config", "kilo"))) {
292
308
  return {
293
309
  platform: "kilo",
@@ -233,7 +233,11 @@ export function isPiShortCircuitArgv(argv) {
233
233
  export default function piExtension(pi) {
234
234
  const buildDir = dirname(fileURLToPath(import.meta.url));
235
235
  const pluginRoot = resolve(buildDir, "..", "..", "..");
236
- const projectDir = process.env.PI_PROJECT_DIR || process.cwd();
236
+ // Issue #542 Pi's runtime sets PI_CONFIG_DIR (not PI_PROJECT_DIR).
237
+ // PI_PROJECT_DIR remains supported as a legacy override for callers
238
+ // that historically synthesized it. Cwd is the universal final
239
+ // fallback.
240
+ const projectDir = process.env.PI_CONFIG_DIR || process.env.PI_PROJECT_DIR || process.cwd();
237
241
  const db = getOrCreateDB();
238
242
  // ── 1. session_start — Initialize session ──────────────
239
243
  pi.on("session_start", (_event, ctx) => {
package/build/cli.js CHANGED
@@ -125,7 +125,16 @@ if (args[0] === "doctor") {
125
125
  doctor().then((code) => process.exit(code));
126
126
  }
127
127
  else if (args[0] === "upgrade") {
128
- upgrade().catch((err) => {
128
+ // Issue #542 — accept --platform <id> from the ctx_upgrade MCP handler,
129
+ // which forwards the live MCP clientInfo's resolved PlatformId. The flag
130
+ // wins over upgrade()'s own detectPlatform() heuristic chain so an
131
+ // ambiguous config-dir collision (e.g. ~/.cursor + ~/.pi both present)
132
+ // can never misroute the upgrade.
133
+ const platformFlagIdx = args.indexOf("--platform");
134
+ const platformArg = platformFlagIdx >= 0 && args[platformFlagIdx + 1]
135
+ ? args[platformFlagIdx + 1]
136
+ : undefined;
137
+ upgrade(platformArg ? { platform: platformArg } : undefined).catch((err) => {
129
138
  const message = err instanceof Error ? err.message : String(err);
130
139
  p.log.error(color.red(message));
131
140
  process.exit(1);
@@ -601,11 +610,18 @@ async function insight(port) {
601
610
  /* -------------------------------------------------------
602
611
  * Upgrade — adapter-aware hook configuration
603
612
  * ------------------------------------------------------- */
604
- async function upgrade() {
613
+ async function upgrade(opts) {
605
614
  if (process.stdout.isTTY)
606
615
  console.clear();
607
- // Detect platform
608
- const detection = detectPlatform();
616
+ // Issue #542 — when the MCP ctx_upgrade handler threads through an
617
+ // explicit --platform <id> (resolved from live clientInfo), trust it
618
+ // over the local heuristic chain. detectPlatform() with no args cannot
619
+ // see the MCP handshake and falls through to the config-dir tier,
620
+ // which misdetects Pi/OMP installs as Cursor on systems where both
621
+ // ~/.cursor/ and ~/.pi/ exist.
622
+ const detection = opts?.platform
623
+ ? { platform: opts.platform, confidence: "high", reason: `--platform ${opts.platform} from ctx_upgrade handler` }
624
+ : detectPlatform();
609
625
  const adapter = await getAdapter(detection.platform);
610
626
  p.intro(color.bgCyan(color.black(" context-mode upgrade ")));
611
627
  p.log.info(`Platform: ${color.cyan(adapter.name)}` +
package/build/server.js CHANGED
@@ -2745,12 +2745,27 @@ server.registerTool("ctx_upgrade", {
2745
2745
  }
2746
2746
  }
2747
2747
  catch { /* best effort — don't block upgrade */ }
2748
+ // Issue #542 — thread MCP clientInfo into the spawned upgrade
2749
+ // process. detectPlatform() runs IN-PROCESS here (no spawn boundary)
2750
+ // so clientInfo from the MCP handshake is the highest-confidence
2751
+ // signal available. We forward the resolved PlatformId as a
2752
+ // --platform flag (cross-shell safe on POSIX, Git Bash, PowerShell,
2753
+ // and cmd.exe — unlike env-var prefixes). If detection fails we
2754
+ // skip the flag and let upgrade()'s own detectPlatform() fall back.
2755
+ let platformFlag = "";
2756
+ try {
2757
+ const { detectPlatform } = await import("./adapters/detect.js");
2758
+ const clientInfo = server.server.getClientVersion();
2759
+ const signal = detectPlatform(clientInfo ?? undefined);
2760
+ platformFlag = ` --platform ${signal.platform}`;
2761
+ }
2762
+ catch { /* best effort — fall back to upgrade()'s own detect */ }
2748
2763
  let cmd;
2749
2764
  if (existsSync(bundlePath)) {
2750
- cmd = `${buildNodeCommand(bundlePath)} upgrade`;
2765
+ cmd = `${buildNodeCommand(bundlePath)} upgrade${platformFlag}`;
2751
2766
  }
2752
2767
  else if (existsSync(fallbackPath)) {
2753
- cmd = `${buildNodeCommand(fallbackPath)} upgrade`;
2768
+ cmd = `${buildNodeCommand(fallbackPath)} upgrade${platformFlag}`;
2754
2769
  }
2755
2770
  else {
2756
2771
  // Inline fallback: neither CLI file exists (e.g. marketplace installs).