feat(aggregation): Implement sub-agent summarization pass
This commit is contained in:
+22
-4
@@ -153,9 +153,9 @@ _SUMMARISERS: dict[str, Callable[[Path, str], str]] = {
|
||||
|
||||
def summarise_file(path: Path, content: str) -> str:
|
||||
"""
|
||||
Return a compact markdown summary string for a single file.
|
||||
`content` is the already-read file text (or an error string).
|
||||
"""
|
||||
Return a compact markdown summary string for a single file.
|
||||
`content` is the already-read file text (or an error string).
|
||||
"""
|
||||
content_hash = get_file_hash(content)
|
||||
cached = _summary_cache.get_summary(str(path), content_hash)
|
||||
if cached:
|
||||
@@ -164,7 +164,25 @@ def summarise_file(path: Path, content: str) -> str:
|
||||
suffix = path.suffix.lower() if hasattr(path, "suffix") else ""
|
||||
fn = _SUMMARISERS.get(suffix, _summarise_generic)
|
||||
try:
|
||||
summary = fn(path, content)
|
||||
heuristic_outline = fn(path, content)
|
||||
|
||||
# Smart AI Summarization
|
||||
is_code = suffix in [".py", ".ps1", ".js", ".ts", ".cpp", ".c", ".h", ".cs", ".go", ".rs", ".lua"]
|
||||
try:
|
||||
from src import ai_client
|
||||
smart_summary = ai_client.run_subagent_summarization(
|
||||
file_path=str(path),
|
||||
content=content[:10000], # Cap content to 10k chars for summarization
|
||||
is_code=is_code,
|
||||
outline=heuristic_outline
|
||||
)
|
||||
if smart_summary and not smart_summary.startswith("ERROR:"):
|
||||
summary = f"{smart_summary}\n\n**Outline:**\n{heuristic_outline}"
|
||||
else:
|
||||
summary = heuristic_outline
|
||||
except Exception:
|
||||
summary = heuristic_outline # Fallback
|
||||
|
||||
_summary_cache.set_summary(str(path), content_hash, summary)
|
||||
return summary
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user