feat(aggregate): Support custom view mode with annotated slices
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user