feat(aggregate): Support custom view mode with annotated slices

This commit is contained in:
2026-05-11 18:52:22 -04:00
parent d22c98c9ac
commit 1303fc1402
2 changed files with 55 additions and 0 deletions
+16
View File
@@ -214,6 +214,22 @@ def build_file_items(base_dir: Path, files: list[str | dict[str, Any]]) -> list[
content = summarize.summarise_file(path, content)
elif view_mode == "none":
content = "(context excluded)"
elif view_mode == "custom":
if custom_slices:
lines = content.splitlines()
slices_text = []
for s in custom_slices:
start = s.get("start_line", 1)
end = s.get("end_line", len(lines))
tag = s.get("tag", "unnamed")
comment = s.get("comment", "")
s_idx = max(0, start - 1)
e_idx = min(len(lines), end)
chunk = "\n".join(lines[s_idx:e_idx])
slices_text.append(f"---\n[Slice: {tag}] ({comment})\nLines {start}-{end}:\n{chunk}")
content = "\n\n".join(slices_text)
else:
content = summarize.summarise_file(path, content)
except FileNotFoundError:
content = f"ERROR: file not found: {path}"
mtime = 0.0