Add web research and source file reading

This commit is contained in:
Hamza Ayed
2026-10-01 14:06:36 +03:00
parent 2d3778a92e
commit dc4d5bad0f
9 changed files with 310 additions and 23 deletions
+9 -1
View File
@@ -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]]