Add web research and source file reading
This commit is contained in:
@@ -98,6 +98,14 @@ def retrieve(task: str, root: Path, limit: int = 3) -> list[tuple[str, str]]:
|
||||
if relative.casefold() in mentioned_paths:
|
||||
score += 100_000
|
||||
if score:
|
||||
ranked.append((score, relative, text[:1800]))
|
||||
# If the user named a source file explicitly, include a larger bounded
|
||||
# excerpt so the agent can explain the code rather than just locate it.
|
||||
excerpt_limit = 12_000 if relative.casefold() in mentioned_paths else 1_800
|
||||
ranked.append((score, relative, text[:excerpt_limit]))
|
||||
ranked.sort(key=lambda item: (-item[0], item[1]))
|
||||
explicit_matches = [
|
||||
item for item in ranked if item[1].casefold() in mentioned_paths
|
||||
]
|
||||
if explicit_matches:
|
||||
ranked = explicit_matches
|
||||
return [(relative, content) for _, relative, content in ranked[:limit]]
|
||||
|
||||
Reference in New Issue
Block a user