refactor: dedup SembleIndex builders and MCP tool preamble#47
Open
sebastianbreguel wants to merge 3 commits intoMinishLab:mainfrom
Open
refactor: dedup SembleIndex builders and MCP tool preamble#47sebastianbreguel wants to merge 3 commits intoMinishLab:mainfrom
sebastianbreguel wants to merge 3 commits intoMinishLab:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SembleIndex.from_pathandfrom_gitshared a 5-line tail (load_model fallback,create_index_from_pathcall, constructor). Extracted into a private_buildclassmethod so each public entrypoint focuses on its own concern:from_pathvalidates filesystem paths,from_githandles cloning.The
searchandfind_relatedMCP tools shared a 7-line preamble for repo resolution and index lookup. Extracted into_get_index_or_errorso 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.encodenow matches theEncoderprotocol). It also adds.serena/to.gitignore.