v1.0.110 — /ctx-upgrade no longer prints scary "rebuild warning" when the binding is fine
This release removes a cosmetic-but-trust-eroding regression in the upgrade flow: macOS users running /ctx-upgrade would see a yellow Native addon rebuild warning banner naming prebuild-install couldn't resolve rc/index, even though the better-sqlite3 binding from npm install --production was already healthy and ctx-doctor reported FTS5 PASS. The warning was always cosmetic — but on a fresh /ctx-upgrade it was the first thing the user saw, and it looked like the upgrade had broken something.
Fixes
fix(upgrade) — skip npm rebuild when the binding is already present
Root cause: the upgrade flow at src/cli.ts:806 ran npm rebuild better-sqlite3 unconditionally after the prior npm install --production step. npm rebuild's internal prebuild-install spawn raced with the install's tree-prune and intermittently failed to resolve rc/index.js (the rc config-loader package was momentarily unresolvable while npm was finalising the dependency tree). The catch block then printed a yellow warning even though the existing prebuilt binary worked.
Fix:
- Pre-check
existsSync(node_modules/better-sqlite3/build/Release/better_sqlite3.node)before the rebuild step. If present (the 99% case after a successfulnpm install), logNative addons OK — binding presentand skip rebuild entirely. Eliminates the npm-internal race. - When the binding IS missing, delegate to the shared
healBetterSqlite3Bindinghelper (scripts/heal-better-sqlite3.mjs, originally introduced in PR #410) instead of rawnpm rebuild. This consolidates all three call sites (postinstall + ensure-deps + cli upgrade) onto one battle-tested 3-layer heal that bypasses both the PATH/MSVC issue (Layer A spawns prebuild-install viaprocess.execPath) and thercresolution race. - Helper-missing fallback retains the original
npm rebuildhint so older/incomplete installs still get a usable diagnostic.
Reported by Mert on macOS (Darwin 23) during a v1.0.108 → v1.0.109 upgrade. Same code path affects Linux and Windows when the install/rebuild race fires.
feat(plugin) — context injection support for additionalContext (#422)
Plugin now supports injecting context via additionalContext for richer adapter integration.
Tests
Two new structural assertions in tests/core/cli.test.ts > Upgrade rebuild guard:
guards npm rebuild with existsSync check on better_sqlite3.nodedelegates to healBetterSqlite3Binding when binding is missing
Verification: 2324 pass / 9 pre-existing failures (8 OpenCode + 1 unrelated cli.mcp.json), 0 new regressions, typecheck clean.
Upgrade
/ctx-upgrade # in Claude Code
# or
npm install -g context-mode@latestCompatibility
14 adapters, 3 OS (macOS / Linux / Windows), no breaking changes, MCP surface unchanged. The upgrade flow change is OS-agnostic — the existsSync pre-check + heal helper delegation work identically across all three platforms.
Credits
- @ShmidtS for unblocking the upgrade infra reviews leading up to this release
- The
healBetterSqlite3Bindinghelper this fix delegates to was originally contributed by @ousamabenyounes in PR #410 (Windows MSVC bypass)