mirror of
https://github.com/mksglu/context-mode.git
synced 2026-10-02 04:14:38 +08:00
Extends normalizeHooksOnStartup / normalizeHooksJsonOnly with an optional jsRuntimePath parameter. When present (and different from nodePath), the static hooks/hooks.json rewrite swaps the bare `node` prefix for the resolved Bun ≥1.0 path so PreToolUse/PostToolUse fires inherit the same cold-start win as the in-place adapter-generated configs. Lifts the prior platform gate (`win32 || linux`) for the hooks.json branch when a bun swap is requested. The original #378 path stays Windows/Linux-only when only #378's placeholder healing is needed, but macOS now also rewrites when jsRuntimePath !== nodePath — the issue was filed from macOS and the historical gate skipped darwin because system node was reliable, not because the rewrite was unsafe. plugin.json normalization is explicitly EXEMPT from the bun swap (MCP server stays on Node, #543 better-sqlite3 ABI). Callers updated: - start.mjs: probe resolveHookRuntime at MCP boot, forward to normalizeHooksOnStartup. Inner probe wrapped in its own try so a missing build/runtime never blocks boot. - src/cli.ts: /ctx-upgrade also probes + forwards so the upgrade-time healing picks bun. - scripts/postinstall.mjs: global install heal also probes. tests/cli/upgrade-plugin-json-assertion.test.ts widens its source slice window 16k→20k chars: the new bun-probe block pushed healPluginJsonMcpServers past the 16k cap and the downstream `Plugin manifest drift` throw fell outside the per-test slice.