context-mode 1.0.122 → 1.0.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/.openclaw-plugin/openclaw.plugin.json +1 -1
- package/.openclaw-plugin/package.json +1 -1
- package/build/adapters/client-map.js +6 -0
- package/build/adapters/detect.d.ts +48 -4
- package/build/adapters/detect.js +140 -33
- package/build/adapters/opencode/plugin.js +1 -1
- package/build/adapters/pi/extension.d.ts +28 -0
- package/build/adapters/pi/extension.js +55 -1
- package/build/adapters/pi/mcp-bridge.js +15 -0
- package/build/cli.js +20 -4
- package/build/server.js +31 -4
- package/build/util/project-dir.d.ts +11 -0
- package/build/util/project-dir.js +38 -20
- package/cli.bundle.mjs +141 -141
- package/hooks/ensure-deps.mjs +23 -7
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/scripts/postinstall.mjs +17 -7
- package/server.bundle.mjs +95 -95
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
+
import { workspaceEnvVarsFor } from "../adapters/detect.js";
|
|
4
|
+
/**
|
|
5
|
+
* Universal escape hatch. NEVER appears in any platform's foreignWorkspaceEnv()
|
|
6
|
+
* (because it isn't registered in PLATFORM_ENV_VARS), so it survives strict
|
|
7
|
+
* mode and bridge env scrubs. Documented as the cross-strict user override
|
|
8
|
+
* for every adapter (set in `~/.<host>/mcp.json` env when nothing else works).
|
|
9
|
+
*/
|
|
10
|
+
const UNIVERSAL_WORKSPACE_ENV = ["CONTEXT_MODE_PROJECT_DIR"];
|
|
11
|
+
/**
|
|
12
|
+
* Frozen legacy candidate list — preserves bit-for-bit behavior of every
|
|
13
|
+
* non-strict caller (`start.mjs` and any caller that doesn't pass
|
|
14
|
+
* `strictPlatform`). Order is locked for semver compatibility.
|
|
15
|
+
*
|
|
16
|
+
* If a new adapter is added, DO NOT add its workspace var here — register it
|
|
17
|
+
* in `PLATFORM_ENV_VARS` and let strict callers pick it up via
|
|
18
|
+
* `workspaceEnvVarsFor(platform)`. Strict mode is the default forward path.
|
|
19
|
+
*/
|
|
20
|
+
const LEGACY_NON_STRICT_CANDIDATES = [
|
|
21
|
+
"CLAUDE_PROJECT_DIR",
|
|
22
|
+
"GEMINI_PROJECT_DIR",
|
|
23
|
+
"VSCODE_CWD",
|
|
24
|
+
"OPENCODE_PROJECT_DIR",
|
|
25
|
+
"PI_PROJECT_DIR",
|
|
26
|
+
"IDEA_INITIAL_DIRECTORY",
|
|
27
|
+
"CURSOR_CWD",
|
|
28
|
+
"CONTEXT_MODE_PROJECT_DIR",
|
|
29
|
+
];
|
|
3
30
|
/**
|
|
4
31
|
* Project-dir resolution helpers — shared between `start.mjs` (the MCP entry
|
|
5
32
|
* point) and `src/server.ts getProjectDir()` (the consumer).
|
|
@@ -145,26 +172,17 @@ export function resolveProjectDirFromTranscript(opts) {
|
|
|
145
172
|
* operation of project-independent tools (sandbox execute, fetch).
|
|
146
173
|
*/
|
|
147
174
|
export function resolveProjectDir(opts) {
|
|
148
|
-
const { env, cwd, pwd, transcriptsRoot } = opts;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
// path on Cursor. Whether Cursor itself sets this on MCP child spawn is
|
|
160
|
-
// unconfirmed — but documenting it as a supported override gives users a
|
|
161
|
-
// documented escape hatch (`~/.cursor/mcp.json` env: { CURSOR_CWD: "..." }).
|
|
162
|
-
env.CURSOR_CWD,
|
|
163
|
-
env.CONTEXT_MODE_PROJECT_DIR,
|
|
164
|
-
];
|
|
165
|
-
for (const c of candidates) {
|
|
166
|
-
if (c && !isPluginInstallPath(c))
|
|
167
|
-
return c;
|
|
175
|
+
const { env, cwd, pwd, transcriptsRoot, strictPlatform } = opts;
|
|
176
|
+
// Build candidate list. Strict path: own workspace vars + universal escape
|
|
177
|
+
// hatch — NO foreign workspace vars, in any order, can win. Non-strict
|
|
178
|
+
// path: frozen legacy literal order for backwards compatibility.
|
|
179
|
+
const candidateVars = strictPlatform
|
|
180
|
+
? [...workspaceEnvVarsFor(strictPlatform), ...UNIVERSAL_WORKSPACE_ENV]
|
|
181
|
+
: LEGACY_NON_STRICT_CANDIDATES;
|
|
182
|
+
for (const name of candidateVars) {
|
|
183
|
+
const v = env[name];
|
|
184
|
+
if (v && !isPluginInstallPath(v))
|
|
185
|
+
return v;
|
|
168
186
|
}
|
|
169
187
|
if (transcriptsRoot) {
|
|
170
188
|
const fromTranscript = resolveProjectDirFromTranscript({ projectsRoot: transcriptsRoot });
|