Skip to content

refactor: dedup SembleIndex builders and MCP tool preamble#47

Open
sebastianbreguel wants to merge 3 commits intoMinishLab:mainfrom
sebastianbreguel:karpathy/dedup-builders
Open

refactor: dedup SembleIndex builders and MCP tool preamble#47
sebastianbreguel wants to merge 3 commits intoMinishLab:mainfrom
sebastianbreguel:karpathy/dedup-builders

Conversation

@sebastianbreguel
Copy link
Copy Markdown

@sebastianbreguel sebastianbreguel commented Apr 28, 2026

SembleIndex.from_path and from_git shared a 5-line tail (load_model fallback, create_index_from_path call, constructor). Extracted into a private _build classmethod so each public entrypoint focuses on its own concern: from_path validates filesystem paths, from_git handles cloning.

The search and find_related MCP tools shared a 7-line preamble for repo resolution and index lookup. Extracted into _get_index_or_error so each tool body focuses on its own logic.

The first commit applies a repo-wide ruff D213 docstring auto-fix that the pre-commit hook produced, plus a pre-existing mypy fix in the benchmarks (_AsymmetricWrapper.encode now matches the Encoder protocol). It also adds .serena/ to .gitignore.

Pre-commit ruff hook auto-applies D213 (multi-line docstring summary on
second line) repo-wide; landing the resulting cosmetic diff once so
subsequent commits don't drag the whole tree along.

Also fixes a pre-existing mypy error in benchmarks: _AsymmetricWrapper.encode
now matches the Encoder Protocol (Sequence[str], positional-only) instead
of list[str], named.
Both classmethod factories shared a 5-line tail (load_model fallback,
create_index_from_path call, SembleIndex constructor). Extract into
_build so each public entrypoint focuses on its own concern: from_path
validates filesystem paths, from_git handles cloning.
search and find_related shared a 7-line preamble for repo resolution and
index lookup. Extract into _get_index_or_error returning SembleIndex | str
so each tool body focuses on its own logic. Caller narrows via isinstance.
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