context-mode 1.0.39 → 1.0.41
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/detect.d.ts +1 -1
- package/build/adapters/detect.js +3 -3
- package/build/adapters/openclaw/index.d.ts +1 -1
- package/build/adapters/openclaw/index.js +5 -5
- package/build/adapters/opencode/index.js +6 -6
- package/build/cli.js +2 -2
- package/build/openclaw-plugin.js +1 -1
- package/build/opencode-plugin.d.ts +34 -10
- package/build/opencode-plugin.js +13 -11
- package/build/server.js +111 -36
- package/cli.bundle.mjs +89 -88
- package/hooks/session-loaders.mjs +25 -9
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/scripts/postinstall.mjs +19 -6
- package/server.bundle.mjs +71 -70
- package/skills/ctx-doctor/SKILL.md +4 -14
- package/skills/ctx-upgrade/SKILL.md +10 -11
- package/start.mjs +63 -38
|
@@ -13,20 +13,10 @@ Run diagnostics and display results directly in the conversation.
|
|
|
13
13
|
|
|
14
14
|
## Instructions
|
|
15
15
|
|
|
16
|
-
1.
|
|
17
|
-
2.
|
|
16
|
+
1. Call the `ctx_doctor` MCP tool directly. It runs all checks server-side and returns a markdown checklist.
|
|
17
|
+
2. Display the results verbatim — they are already formatted as a checklist with `[x]` PASS, `[ ]` FAIL, `[-]` WARN.
|
|
18
|
+
3. **Fallback** (only if MCP tool call fails): Derive the **plugin root** from this skill's base directory (go up 2 levels — remove `/skills/ctx-doctor`), then run with Bash:
|
|
18
19
|
```
|
|
19
20
|
CLI="<PLUGIN_ROOT>/cli.bundle.mjs"; [ ! -f "$CLI" ] && CLI="<PLUGIN_ROOT>/build/cli.js"; node "$CLI" doctor
|
|
20
21
|
```
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
## context-mode doctor
|
|
24
|
-
- [x] Runtimes: 6/10 (javascript, typescript, python, shell, ruby, perl)
|
|
25
|
-
- [x] Performance: FAST (Bun)
|
|
26
|
-
- [x] Server test: PASS
|
|
27
|
-
- [x] Hooks: PASS
|
|
28
|
-
- [x] FTS5: PASS
|
|
29
|
-
- [x] npm: v0.7.1
|
|
30
|
-
- [x] Marketplace: v0.7.1
|
|
31
|
-
```
|
|
32
|
-
Use `[x]` for PASS, `[ ]` for FAIL, `[-]` for WARN.
|
|
22
|
+
Re-display results as a markdown checklist.
|
|
@@ -13,20 +13,19 @@ Pull latest from GitHub and reinstall the plugin.
|
|
|
13
13
|
|
|
14
14
|
## Instructions
|
|
15
15
|
|
|
16
|
-
1.
|
|
17
|
-
2. Run
|
|
18
|
-
|
|
19
|
-
CLI="<PLUGIN_ROOT>/cli.bundle.mjs"; [ ! -f "$CLI" ] && CLI="<PLUGIN_ROOT>/build/cli.js"; node "$CLI" upgrade
|
|
20
|
-
```
|
|
21
|
-
3. **IMPORTANT**: After the Bash tool completes, re-display the key results as markdown text directly in the conversation so the user sees them without expanding the tool output. Format as:
|
|
16
|
+
1. Call the `ctx_upgrade` MCP tool directly. It returns a shell command to execute.
|
|
17
|
+
2. Run the returned command using your shell execution tool (Bash, shell_execute, etc.).
|
|
18
|
+
3. Display results as a markdown checklist:
|
|
22
19
|
```
|
|
23
20
|
## context-mode upgrade
|
|
24
21
|
- [x] Pulled latest from GitHub
|
|
25
|
-
- [x] Built and installed
|
|
26
|
-
- [x] npm global updated
|
|
22
|
+
- [x] Built and installed v1.0.39
|
|
27
23
|
- [x] Hooks configured
|
|
28
|
-
- [x] Permissions set
|
|
29
24
|
- [x] Doctor: all checks PASS
|
|
30
25
|
```
|
|
31
|
-
Use `[x]` for success, `[ ]` for failure. Show
|
|
32
|
-
|
|
26
|
+
Use `[x]` for success, `[ ]` for failure. Show actual version numbers.
|
|
27
|
+
4. Tell the user to **restart their session** to pick up the new version.
|
|
28
|
+
5. **Fallback** (only if MCP tool call fails): Derive the **plugin root** from this skill's base directory (go up 2 levels — remove `/skills/ctx-upgrade`), then run with Bash:
|
|
29
|
+
```
|
|
30
|
+
CLI="<PLUGIN_ROOT>/cli.bundle.mjs"; [ ! -f "$CLI" ] && CLI="<PLUGIN_ROOT>/build/cli.js"; node "$CLI" upgrade
|
|
31
|
+
```
|
package/start.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { execSync } from "node:child_process";
|
|
3
|
-
import { existsSync, copyFileSync, readFileSync, writeFileSync, readdirSync } from "node:fs";
|
|
3
|
+
import { existsSync, copyFileSync, chmodSync, readFileSync, writeFileSync, readdirSync } from "node:fs";
|
|
4
4
|
import { dirname, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { homedir } from "node:os";
|
|
@@ -56,47 +56,65 @@ if (!process.env.CLAUDE_PROJECT_DIR) {
|
|
|
56
56
|
process.env.CLAUDE_PROJECT_DIR = originalCwd;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
// Auto-write routing instructions file for
|
|
59
|
+
// Auto-write routing instructions file for NON-hook-capable platforms only.
|
|
60
|
+
// Hook-capable platforms (Claude Code, Gemini CLI, VS Code Copilot, OpenCode, OpenClaw)
|
|
61
|
+
// inject routing via SessionStart hook — writing to disk dirties the git tree (#158).
|
|
62
|
+
// server.ts also guards this with adapter.capabilities.sessionStart.
|
|
60
63
|
try {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
{ env: ["CLAUDE_PROJECT_DIR", "CLAUDE_SESSION_ID"], dir: "claude-code", file: "CLAUDE.md", target: "CLAUDE.md" },
|
|
72
|
-
{ env: ["GEMINI_PROJECT_DIR", "GEMINI_SESSION_ID"], dir: "gemini-cli", file: "GEMINI.md", target: "GEMINI.md" },
|
|
73
|
-
{ env: ["VSCODE_PID", "VSCODE_CWD"], dir: "vscode-copilot", file: "copilot-instructions.md", target: ".github/copilot-instructions.md" },
|
|
74
|
-
{ env: ["OPENCODE_PROJECT_DIR", "OPENCODE_SESSION_ID"], dir: "opencode", file: "AGENTS.md", target: "AGENTS.md" },
|
|
75
|
-
{ env: ["OPENCLAW_HOME", "OPENCLAW_PROJECT_DIR"], dir: "openclaw", file: "AGENTS.md", target: "AGENTS.md" },
|
|
76
|
-
{ env: ["CODEX_HOME"], dir: "codex", file: "AGENTS.md", target: "AGENTS.md" },
|
|
64
|
+
// Hook-capable platforms set these env vars — skip file write for them.
|
|
65
|
+
// Uses verified env vars from src/adapters/detect.ts (not invented session IDs).
|
|
66
|
+
const hookCapableSessionVars = [
|
|
67
|
+
"CLAUDE_SESSION_ID", // Claude Code
|
|
68
|
+
"GEMINI_PROJECT_DIR", // Gemini CLI (GEMINI_CLI also valid)
|
|
69
|
+
"OPENCODE", // OpenCode (OPENCODE_PID also valid)
|
|
70
|
+
"OPENCLAW_HOME", // OpenClaw (user-set home dir)
|
|
71
|
+
"OPENCLAW_CLI", // OpenClaw (set at runtime by openclaw CLI)
|
|
72
|
+
// VS Code Copilot: VSCODE_PID is too broad (set for ALL VS Code extensions).
|
|
73
|
+
// Accept occasional harmless write rather than false-positive suppression.
|
|
77
74
|
];
|
|
75
|
+
const hasHookSupport = hookCapableSessionVars.some((e) => process.env[e]);
|
|
76
|
+
|
|
77
|
+
if (!hasHookSupport) {
|
|
78
|
+
const projectDir =
|
|
79
|
+
process.env.CLAUDE_PROJECT_DIR ||
|
|
80
|
+
process.env.GEMINI_PROJECT_DIR ||
|
|
81
|
+
process.env.VSCODE_CWD ||
|
|
82
|
+
process.cwd();
|
|
83
|
+
|
|
84
|
+
const configsDir = resolve(__dirname, "configs");
|
|
85
|
+
|
|
86
|
+
// Detect platform and determine instruction file
|
|
87
|
+
const platformConfigs = [
|
|
88
|
+
{ env: ["CLAUDE_PROJECT_DIR"], dir: "claude-code", file: "CLAUDE.md", target: "CLAUDE.md" },
|
|
89
|
+
{ env: ["GEMINI_PROJECT_DIR"], dir: "gemini-cli", file: "GEMINI.md", target: "GEMINI.md" },
|
|
90
|
+
{ env: ["VSCODE_CWD"], dir: "vscode-copilot", file: "copilot-instructions.md", target: ".github/copilot-instructions.md" },
|
|
91
|
+
{ env: ["OPENCODE_PROJECT_DIR"], dir: "opencode", file: "AGENTS.md", target: "AGENTS.md" },
|
|
92
|
+
{ env: ["OPENCLAW_HOME"], dir: "openclaw", file: "AGENTS.md", target: "AGENTS.md" },
|
|
93
|
+
{ env: ["CODEX_HOME"], dir: "codex", file: "AGENTS.md", target: "AGENTS.md" },
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
const detected = platformConfigs.find((p) => p.env.some((e) => process.env[e]));
|
|
97
|
+
if (detected) {
|
|
98
|
+
const targetPath = resolve(projectDir, detected.target);
|
|
99
|
+
const sourcePath = resolve(configsDir, detected.dir, detected.file);
|
|
100
|
+
|
|
101
|
+
// Ensure parent dir exists (for .github/copilot-instructions.md)
|
|
102
|
+
const targetDir = resolve(targetPath, "..");
|
|
103
|
+
if (!existsSync(targetDir)) {
|
|
104
|
+
const { mkdirSync } = await import("node:fs");
|
|
105
|
+
mkdirSync(targetDir, { recursive: true });
|
|
106
|
+
}
|
|
78
107
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
mkdirSync(targetDir, { recursive: true });
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (existsSync(sourcePath)) {
|
|
92
|
-
const content = readFileSync(sourcePath, "utf-8");
|
|
93
|
-
if (existsSync(targetPath)) {
|
|
94
|
-
const existing = readFileSync(targetPath, "utf-8");
|
|
95
|
-
if (!existing.includes("context-mode")) {
|
|
96
|
-
writeFileSync(targetPath, existing.trimEnd() + "\n\n" + content, "utf-8");
|
|
108
|
+
if (existsSync(sourcePath)) {
|
|
109
|
+
const content = readFileSync(sourcePath, "utf-8");
|
|
110
|
+
if (existsSync(targetPath)) {
|
|
111
|
+
const existing = readFileSync(targetPath, "utf-8");
|
|
112
|
+
if (!existing.includes("context-mode")) {
|
|
113
|
+
writeFileSync(targetPath, existing.trimEnd() + "\n\n" + content, "utf-8");
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
writeFileSync(targetPath, content, "utf-8");
|
|
97
117
|
}
|
|
98
|
-
} else {
|
|
99
|
-
writeFileSync(targetPath, content, "utf-8");
|
|
100
118
|
}
|
|
101
119
|
}
|
|
102
120
|
}
|
|
@@ -172,6 +190,13 @@ for (const pkg of ["better-sqlite3", "turndown", "turndown-plugin-gfm", "@mixmar
|
|
|
172
190
|
// Each ABI needs its own compiled binary — cache them side-by-side.
|
|
173
191
|
ensureNativeCompat(__dirname);
|
|
174
192
|
|
|
193
|
+
// Self-heal: create CLI shim if cli.bundle.mjs is missing (marketplace installs)
|
|
194
|
+
if (!existsSync(resolve(__dirname, "cli.bundle.mjs")) && existsSync(resolve(__dirname, "build", "cli.js"))) {
|
|
195
|
+
const shimPath = resolve(__dirname, "cli.bundle.mjs");
|
|
196
|
+
writeFileSync(shimPath, '#!/usr/bin/env node\nawait import("./build/cli.js");\n');
|
|
197
|
+
if (process.platform !== "win32") chmodSync(shimPath, 0o755);
|
|
198
|
+
}
|
|
199
|
+
|
|
175
200
|
// Bundle exists (CI-built) — start instantly
|
|
176
201
|
if (existsSync(resolve(__dirname, "server.bundle.mjs"))) {
|
|
177
202
|
await import("./server.bundle.mjs");
|