MCPcopy
hub / github.com/MinishLab/semble / resolve_chunk

Function resolve_chunk

src/semble/utils.py:19–32  ·  view source on GitHub ↗

Return the chunk containing *line* in *file_path*, or None. Reconstructs a Chunk from its JSON-primitive MCP tool arguments (file_path + line) before calling into the library.

(chunks: list[Chunk], file_path: str, line: int)

Source from the content-addressed store, hash-verified

17
18
19def resolve_chunk(chunks: list[Chunk], file_path: str, line: int) -> Chunk | None:
20 """Return the chunk containing *line* in *file_path*, or None.
21
22 Reconstructs a Chunk from its JSON-primitive MCP tool arguments (file_path + line)
23 before calling into the library.
24 """
25 fallback = None
26 for chunk in chunks:
27 if chunk.file_path == file_path and chunk.start_line <= line <= chunk.end_line:
28 if line < chunk.end_line:
29 return chunk
30 if fallback is None: # line == end_line: boundary; keep as fallback for end-of-file chunks
31 fallback = chunk
32 return fallback
33
34
35def format_results(query: str, results: list[SearchResult], max_snippet_lines: int | None = None) -> dict[str, Any]:

Callers 3

find_relatedFunction · 0.90
_run_find_relatedFunction · 0.90
test_resolve_chunkFunction · 0.90

Calls

no outgoing calls

Tested by 1

test_resolve_chunkFunction · 0.72