context-mode 1.0.112 → 1.0.113
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/server.js +10 -8
- package/build/util/project-dir.d.ts +49 -0
- package/build/util/project-dir.js +67 -0
- package/cli.bundle.mjs +90 -90
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/server.bundle.mjs +73 -73
- package/start.mjs +16 -4
package/start.mjs
CHANGED
|
@@ -9,15 +9,27 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
|
9
9
|
const originalCwd = process.cwd();
|
|
10
10
|
process.chdir(__dirname);
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
// Plugin-install-path guard (mirror of src/util/project-dir.ts isPluginInstallPath
|
|
13
|
+
// — duplicated here because start.mjs ships as raw JS and cannot import TS).
|
|
14
|
+
// When Claude Code runs `/ctx-upgrade` it kills + respawns the MCP server with
|
|
15
|
+
// `cwd` pointing at the plugin install dir. Setting CLAUDE_PROJECT_DIR from
|
|
16
|
+
// that path then poisons every downstream ctx_stats / SessionDB / hash
|
|
17
|
+
// computation — sessions silently re-root under the plugin install dir. Skip
|
|
18
|
+
// the env auto-set in that case; getProjectDir() defends a second time inside
|
|
19
|
+
// server.ts via resolveProjectDir(). See src/util/project-dir.ts.
|
|
20
|
+
const isPluginInstallPath = (p) =>
|
|
21
|
+
/[/\\]\.claude[/\\]plugins[/\\](cache|marketplaces)[/\\]/.test(p);
|
|
22
|
+
const safeOriginalCwd = isPluginInstallPath(originalCwd) ? null : originalCwd;
|
|
23
|
+
|
|
24
|
+
if (!process.env.CLAUDE_PROJECT_DIR && safeOriginalCwd) {
|
|
25
|
+
process.env.CLAUDE_PROJECT_DIR = safeOriginalCwd;
|
|
14
26
|
}
|
|
15
27
|
|
|
16
28
|
// Platform-agnostic project dir — guaranteed to be set for ALL platforms.
|
|
17
29
|
// Adapters may set their own env var (GEMINI_PROJECT_DIR, etc.) but this
|
|
18
30
|
// is the universal fallback so server.ts getProjectDir() never relies on cwd().
|
|
19
|
-
if (!process.env.CONTEXT_MODE_PROJECT_DIR) {
|
|
20
|
-
process.env.CONTEXT_MODE_PROJECT_DIR =
|
|
31
|
+
if (!process.env.CONTEXT_MODE_PROJECT_DIR && safeOriginalCwd) {
|
|
32
|
+
process.env.CONTEXT_MODE_PROJECT_DIR = safeOriginalCwd;
|
|
21
33
|
}
|
|
22
34
|
|
|
23
35
|
// Routing instructions file auto-write DISABLED for all platforms (#158, #164).
|