github mksglu/context-mode v1.0.98

4 hours ago

Bug Fixes

  • Fix PPID mismatch on WSL2/Linux — MCP redirects restored (#347)

    Claude Code spawns hooks via bash -c "node ...". On WSL2/Linux (dash as /bin/sh), the intermediate shell does NOT exec-optimize, so process.ppid in the hook points to a transient bash PID — not Claude Code. The PPID-keyed sentinel file was never found, causing all MCP redirects to be silently bypassed. Context window floods.

    What changed

    • hooks/core/mcp-ready.mjs: Replaced PPID-keyed sentinel lookup with directory-scan + PID liveness probe. Scans /tmp/context-mode-mcp-ready-*, probes each PID with kill(pid, 0). Works regardless of spawn topology.
    • src/server.ts: Sentinel now uses process.pid (not process.ppid) in filename. Hardcoded /tmp on Unix to avoid TMPDIR mismatch.
    • Stale cleanup: Dead sentinels from crashed servers are automatically deleted during scan.
    • 11 test files updated to match new sentinel path pattern.

    Platforms affected

    • WSL2/Linux: Fixed — dash/sh doesn't exec-optimize, PPID always mismatched
    • macOS: Already worked (bash/zsh exec-optimize), now works via scan too
    • Windows: Already worked (cmd.exe), now uses os.tmpdir() for scan

    Related

    • Closes #347
    • Thanks @se7enango for the detailed reproduction and process tree evidence

Don't miss a new context-mode release

NewReleases is sending notifications on new releases.