Skip to content

feat: add --exclude to leave paths out of the index - #7

Open
Felgar wants to merge 2 commits into
ThinkyMiner:mainfrom
Felgar:feat/exclude-option
Open

Felgar wants to merge 2 commits into
ThinkyMiner:mainfrom
Felgar:feat/exclude-option

Conversation

@Felgar

@Felgar Felgar commented Nov 15, 2026

Copy link
Copy Markdown

Summary

Supersedes #6, rebased onto git-based discovery (#4) and background indexing (#5).

Git discovery already keeps ignored files and nested worktrees out, but a tracked vendored or generated file is still indexed. A repo committing a 200 KB minified bundle (chart.umd.js) took ~20 s to index it, enough to make the MCP client's connection time out. Two commits:

  1. perf: extract_calls_in_function scanned the whole tree with every definition pattern for each function, so the cost grew with functions x file size. _definitions_by_name() builds the name -> definition-node map once per parsed tree (memoized per thread and bounded, like CachedParser), keeping the old precedence. Cold index, identical graph: 23.1 s -> 1.3 s on the repo with the minified file, 15.6 s -> 5.4 s on a 460-file Python/JSX repo.
  2. feat: --exclude PATH, repeatable, leaves a directory or file out of the index, tracked or not.

Changes

  • --exclude PATH, repeatable, relative to the root (or absolute, below it); discovery drops it whether git tracks it or not
  • a value that can never match (outside the root, empty, or with ..) is rejected: usage error from the CLI, ValueError from create_server() before any indexing thread starts
  • _definitions_by_name() in base.py, used by the JavaScript (and TypeScript/TSX) and Python plugins
  • README: one bullet under the discovery notes; --exclude scopes the index, git_history still reports every tracked file

Test plan

  • Ran pytest — 1222 passed; test_non_utf8_file_names_are_indexed_in_git_mode fails on macOS, on main as well (APFS rejects the non-UTF-8 file name)
  • Added new tests for changed behavior
  • Tested with a real MCP client (if applicable)

Related issues

Supersedes #6.

extract_calls_in_function scanned the whole tree with every definition
pattern for each function it was asked about, and the graph builder asks
about every function of a file in a row: the cost grew with functions x
file size. A vendored 200 KB minified bundle (chart.umd.js) took ~20 s to
index, enough to make the MCP client's connection time out.

_definitions_by_name() builds the name -> definition-node map once per
parsed tree (memoized per thread and bounded, like CachedParser), keeping
the old precedence: patterns in order, first match in document order.
JavaScript (and TypeScript/TSX, which inherit it) and Python use it.

Cold index, unchanged graph (identical edges and symbols):
- repo with a 200 KB minified JS file: 23.1 s -> 1.3 s
- 460-file Python/JSX repo: 15.6 s -> 5.4 s
Ports the --exclude option of ThinkyMiner#6 onto git-based discovery and background
indexing. A repeatable --exclude names a directory or file relative to
the root (or absolute, below it); discovery drops it whether git tracks
it or not, so committed vendored bundles stay out of the index.

A value that can never match (outside the root, empty, or with '..') is
rejected: the CLI exits with a usage error and create_server() raises
ValueError before any indexing thread starts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant