context-mode 1.0.106 → 1.0.108
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/README.md +22 -18
- package/build/adapters/claude-code/index.js +26 -9
- package/build/adapters/copilot-base.d.ts +3 -3
- package/build/adapters/cursor/hooks.js +8 -0
- package/build/adapters/cursor/index.js +4 -1
- package/build/adapters/gemini-cli/hooks.d.ts +6 -1
- package/build/adapters/gemini-cli/hooks.js +7 -1
- package/build/adapters/gemini-cli/index.js +12 -0
- package/build/adapters/kiro/hooks.js +4 -0
- package/build/adapters/kiro/index.d.ts +9 -2
- package/build/adapters/kiro/index.js +49 -27
- package/build/adapters/opencode/index.js +11 -5
- package/build/adapters/qwen-code/index.js +18 -0
- package/build/adapters/vscode-copilot/hooks.d.ts +0 -4
- package/build/adapters/vscode-copilot/hooks.js +6 -6
- package/build/cli.js +93 -12
- package/build/openclaw/mcp-tools.d.ts +54 -0
- package/build/openclaw/mcp-tools.js +198 -0
- package/build/openclaw-plugin.d.ts +9 -0
- package/build/openclaw-plugin.js +132 -16
- package/build/opencode-plugin.d.ts +29 -4
- package/build/opencode-plugin.js +154 -7
- package/build/pi-extension.js +123 -29
- package/build/server.d.ts +1 -0
- package/build/server.js +26 -1
- package/build/session/analytics.js +36 -13
- package/build/session/extract.d.ts +1 -1
- package/build/session/extract.js +46 -1
- package/cli.bundle.mjs +133 -132
- package/hooks/core/platform-detect.mjs +49 -0
- package/hooks/core/routing.mjs +13 -1
- package/hooks/cursor/afteragentresponse.mjs +74 -0
- package/hooks/ensure-deps.mjs +28 -12
- package/hooks/gemini-cli/beforeagent.mjs +99 -0
- package/hooks/kiro/agentspawn.mjs +97 -0
- package/hooks/kiro/userpromptsubmit.mjs +88 -0
- package/hooks/posttooluse.mjs +90 -80
- package/hooks/precompact.mjs +56 -46
- package/hooks/pretooluse.mjs +161 -167
- package/hooks/routing-block.mjs +2 -2
- package/hooks/run-hook.mjs +82 -0
- package/hooks/session-extract.bundle.mjs +2 -2
- package/hooks/sessionstart.mjs +187 -153
- package/hooks/userpromptsubmit.mjs +69 -58
- package/hooks/vscode-copilot/sessionstart.mjs +13 -14
- package/openclaw.plugin.json +1 -1
- package/package.json +2 -1
- package/scripts/heal-better-sqlite3.mjs +108 -0
- package/scripts/postinstall.mjs +27 -0
- package/server.bundle.mjs +79 -79
- package/skills/UPSTREAM-CREDITS.md +51 -0
- package/skills/context-mode-ops/SKILL.md +147 -0
- package/skills/diagnose/SKILL.md +122 -0
- package/skills/diagnose/scripts/hitl-loop.template.sh +41 -0
- package/skills/grill-me/SKILL.md +15 -0
- package/skills/grill-with-docs/ADR-FORMAT.md +47 -0
- package/skills/grill-with-docs/CONTEXT-FORMAT.md +77 -0
- package/skills/grill-with-docs/SKILL.md +93 -0
- package/skills/improve-codebase-architecture/DEEPENING.md +37 -0
- package/skills/improve-codebase-architecture/INTERFACE-DESIGN.md +44 -0
- package/skills/improve-codebase-architecture/LANGUAGE.md +53 -0
- package/skills/improve-codebase-architecture/SKILL.md +76 -0
- package/skills/tdd/SKILL.md +114 -0
- package/skills/tdd/deep-modules.md +33 -0
- package/skills/tdd/interface-design.md +31 -0
- package/skills/tdd/mocking.md +59 -0
- package/skills/tdd/refactoring.md +10 -0
- package/skills/tdd/tests.md +61 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-heal a missing better-sqlite3 native binding (#408).
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for the 3-layer heal used by both
|
|
5
|
+
* `scripts/postinstall.mjs` (install-time) and `hooks/ensure-deps.mjs`
|
|
6
|
+
* (runtime). Keeping one implementation avoids the duplicated logic the
|
|
7
|
+
* maintainer flagged on PR #410.
|
|
8
|
+
*
|
|
9
|
+
* Background:
|
|
10
|
+
* On Windows, `npm rebuild better-sqlite3` falls through to `node-gyp`
|
|
11
|
+
* when prebuild-install is not on cmd.exe PATH, then dies for users
|
|
12
|
+
* without Visual Studio C++ tooling. We bypass that by spawning
|
|
13
|
+
* prebuild-install JS directly with `process.execPath`.
|
|
14
|
+
*
|
|
15
|
+
* Layered heal:
|
|
16
|
+
* A. Spawn prebuild-install via process.execPath — bypasses PATH/MSVC.
|
|
17
|
+
* B. `npm install better-sqlite3` (re-resolves tree, NOT `npm rebuild`).
|
|
18
|
+
* C. Write actionable stderr message naming `npm install better-sqlite3`
|
|
19
|
+
* and the Windows / #408 context.
|
|
20
|
+
*
|
|
21
|
+
* Best-effort posture: every layer is wrapped in try/catch and the
|
|
22
|
+
* function never throws. Caller will fail naturally on first DB open if
|
|
23
|
+
* heal could not produce a working binding.
|
|
24
|
+
*
|
|
25
|
+
* @see https://github.com/mksglu/context-mode/issues/408
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import { existsSync } from "node:fs";
|
|
29
|
+
import { execSync, spawnSync } from "node:child_process";
|
|
30
|
+
import { resolve } from "node:path";
|
|
31
|
+
import { createRequire } from "node:module";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Self-heal a missing better_sqlite3.node binding.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} pkgRoot - the directory containing node_modules/better-sqlite3
|
|
37
|
+
* @returns {{ healed: boolean, reason?: string }}
|
|
38
|
+
*/
|
|
39
|
+
export function healBetterSqlite3Binding(pkgRoot) {
|
|
40
|
+
try {
|
|
41
|
+
const bsqRoot = resolve(pkgRoot, "node_modules", "better-sqlite3");
|
|
42
|
+
if (!existsSync(bsqRoot)) {
|
|
43
|
+
// No package at all — caller (ensure-deps install branch) handles this.
|
|
44
|
+
return { healed: false, reason: "package-missing" };
|
|
45
|
+
}
|
|
46
|
+
const bindingPath = resolve(bsqRoot, "build", "Release", "better_sqlite3.node");
|
|
47
|
+
if (existsSync(bindingPath)) {
|
|
48
|
+
return { healed: true, reason: "binding-present" };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const npmBin = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
52
|
+
|
|
53
|
+
// ── Layer A: spawn prebuild-install directly via process.execPath ──
|
|
54
|
+
// Bypasses cmd.exe PATH and MSVC requirement.
|
|
55
|
+
try {
|
|
56
|
+
let prebuildBin = null;
|
|
57
|
+
try {
|
|
58
|
+
const req = createRequire(resolve(bsqRoot, "package.json"));
|
|
59
|
+
prebuildBin = req.resolve("prebuild-install/bin");
|
|
60
|
+
} catch { /* fall through to manual walk */ }
|
|
61
|
+
if (!prebuildBin) {
|
|
62
|
+
const candidates = [
|
|
63
|
+
resolve(bsqRoot, "node_modules", "prebuild-install", "bin.js"),
|
|
64
|
+
resolve(pkgRoot, "node_modules", "prebuild-install", "bin.js"),
|
|
65
|
+
];
|
|
66
|
+
for (const c of candidates) {
|
|
67
|
+
if (existsSync(c)) { prebuildBin = c; break; }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (prebuildBin) {
|
|
71
|
+
const r = spawnSync(
|
|
72
|
+
process.execPath,
|
|
73
|
+
[prebuildBin, "--target", process.versions.node, "--runtime", "node"],
|
|
74
|
+
{ cwd: bsqRoot, stdio: "pipe", timeout: 120000, env: { ...process.env } },
|
|
75
|
+
);
|
|
76
|
+
if (r.status === 0 && existsSync(bindingPath)) {
|
|
77
|
+
return { healed: true, reason: "prebuild-install" };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
} catch { /* best effort — try Layer B */ }
|
|
81
|
+
|
|
82
|
+
// ── Layer B: `npm install better-sqlite3` — NOT `npm rebuild` ──
|
|
83
|
+
// Re-resolves tree and re-runs prebuild-install via the package's
|
|
84
|
+
// own install script. Avoids the rebuild → node-gyp fall-through.
|
|
85
|
+
try {
|
|
86
|
+
execSync(
|
|
87
|
+
`${npmBin} install better-sqlite3 --no-package-lock --no-save --silent`,
|
|
88
|
+
{ cwd: pkgRoot, stdio: "pipe", timeout: 120000, shell: true },
|
|
89
|
+
);
|
|
90
|
+
if (existsSync(bindingPath)) {
|
|
91
|
+
return { healed: true, reason: "npm-install" };
|
|
92
|
+
}
|
|
93
|
+
} catch { /* best effort — fall through to Layer C */ }
|
|
94
|
+
|
|
95
|
+
// ── Layer C: actionable stderr — give the user a real next step ──
|
|
96
|
+
try {
|
|
97
|
+
process.stderr.write(
|
|
98
|
+
"\n[context-mode] better-sqlite3 native binding could not be installed automatically.\n" +
|
|
99
|
+
" This is a known issue on Windows when prebuild-install is not on PATH (#408).\n" +
|
|
100
|
+
" Workaround: run `npm install better-sqlite3` from the plugin directory.\n\n",
|
|
101
|
+
);
|
|
102
|
+
} catch { /* stderr unavailable — give up silently */ }
|
|
103
|
+
return { healed: false, reason: "manual-required" };
|
|
104
|
+
} catch {
|
|
105
|
+
// Outermost guard — never throw, never block the caller.
|
|
106
|
+
return { healed: false, reason: "manual-required" };
|
|
107
|
+
}
|
|
108
|
+
}
|
package/scripts/postinstall.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import { execSync } from "node:child_process";
|
|
|
13
13
|
import { dirname, resolve, join, sep } from "node:path";
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
|
15
15
|
import { homedir } from "node:os";
|
|
16
|
+
import { healBetterSqlite3Binding } from "./heal-better-sqlite3.mjs";
|
|
16
17
|
|
|
17
18
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
18
19
|
const pkgRoot = resolve(__dirname, "..");
|
|
@@ -146,3 +147,29 @@ if (process.platform === "win32" && process.env.npm_config_global === "true") {
|
|
|
146
147
|
// Best effort — don't block install. User can use npx as fallback.
|
|
147
148
|
}
|
|
148
149
|
}
|
|
150
|
+
|
|
151
|
+
// ── 3. Native binding self-heal — better-sqlite3 (#408) ──────────────
|
|
152
|
+
// On Windows, `npm rebuild` falls through to node-gyp without MSVC; bypass
|
|
153
|
+
// that by spawning prebuild-install directly. Cross-platform safety net —
|
|
154
|
+
// the binding can also go missing on macOS/Linux when prebuilds are stale
|
|
155
|
+
// or the install was interrupted.
|
|
156
|
+
//
|
|
157
|
+
// Logic lives in scripts/heal-better-sqlite3.mjs (shared with
|
|
158
|
+
// hooks/ensure-deps.mjs so there's one source of truth).
|
|
159
|
+
try { healBetterSqlite3Binding(pkgRoot); } catch { /* best effort — don't block install */ }
|
|
160
|
+
|
|
161
|
+
// ── 4. Hook normalization at install time (#414) ─────────────────────
|
|
162
|
+
// hooks/hooks.json + .claude-plugin/plugin.json ship with `${CLAUDE_PLUGIN_ROOT}`
|
|
163
|
+
// + bare `node` command. On Windows + Claude Code that combination triggers
|
|
164
|
+
// `cjs/loader:1479 MODULE_NOT_FOUND` (placeholder mangling, MSYS path issues,
|
|
165
|
+
// PATH lookup failure). start.mjs normalizes on every MCP boot, but normalizing
|
|
166
|
+
// here too closes the gap for the very first hook fire after a fresh install
|
|
167
|
+
// (before any MCP server has run).
|
|
168
|
+
try {
|
|
169
|
+
const { normalizeHooksOnStartup } = await import("../hooks/normalize-hooks.mjs");
|
|
170
|
+
normalizeHooksOnStartup({
|
|
171
|
+
pluginRoot: pkgRoot,
|
|
172
|
+
nodePath: process.execPath,
|
|
173
|
+
platform: process.platform,
|
|
174
|
+
});
|
|
175
|
+
} catch { /* best effort — never block install */ }
|