github yvgude/lean-ctx v3.9.7

4 hours ago

Added

  • Runtime tools/list_changed notifications (GH #1250).
    When the user changes tool_profile, tools_enabled, or disabled_tools
    via dashboard, CLI, or manual config edit, the MCP server now automatically
    sends a notifications/tools/list_changed to the IDE client on the next
    tool call. No more "restart IDE to pick up profile changes" — Cursor,
    Claude Code, and all MCP clients refresh their tool surface immediately.
    New module: server/tools_config_watch with hash-based change detection.
  • CLI profile-switch messaging updated.
    lean-ctx tools <profile> now prints "Changes take effect on the next
    tool call (auto-detected)" instead of "Restart your AI tool / IDE".

Fixed

  • lean-ctx index build memory explosion capped (GH #790).
    Six fixes that together prevent unbounded RAM growth during index builds:
    1. Memory Guardian activated for CLI buildsstart_guard() now runs
      before ensure_all_background(), so pressure/abort checks in graph and
      BM25 code actually fire (previously only started in daemon mode).
    2. graph_index_max_files default 0 → 15 000 — caps the graph scan;
      override with graph_index_max_files = 0 for unlimited.
    3. Graph content_cache capped at 256 MB — stops caching file contents
      once the budget is hit; the edge builder falls back to disk reads.
    4. Edge build batched (500 files/batch)par_iter(ALL) replaced with
      chunked parallel batches and memory-pressure checks between them.
    5. BM25 chunk content truncated to 10-line snippets during build — full
      text is tokenised for scoring, then the stored body is snipped immediately
      (no more holding every file's full content in the chunk vector).
    6. BM25 save streams through zstdpostcard::to_allocvec replaced with
      postcard::to_iozstd::Encoder → temp file; eliminates the
      intermediate uncompressed Vec<u8> allocation entirely.
  • Cursor Read redirect removed — savings jump from 9.5 % to 73+ % (GH #1250).
    Cursor's StrReplace internally triggers a native Read that the
    redirect hook intercepted, producing verbatim cli_full output with
    ~0.5 % savings. This dominated the token stats (68 % of all input tokens!)
    and dragged the overall savings rate to single digits. The Read matcher
    is now removed from Cursor's preToolUse redirect hook — native Reads
    pass through unmodified (StrReplace works), and the agent uses ctx_read
    (MCP) for compressed reads, matching how Claude Code already works
    (read_redirect = auto). Grep redirect remains for compression.

Upgrade

lean-ctx update                 # recommended (auto-downloads + refreshes shell hooks)
cargo install lean-ctx          # or
npm update -g lean-ctx-bin      # or
brew upgrade lean-ctx

Note: After upgrading via cargo/npm/brew, run lean-ctx setup to refresh shell aliases. lean-ctx update does this automatically.

Full Changelog: v3.9.7...v3.9.7

Don't miss a new lean-ctx release

NewReleases is sending notifications on new releases.