feat(metadata): NIL_METADATA sentinel + migrate _build_files_section_from_items

This commit is contained in:
ed
2026-06-24 15:22:31 -04:00
parent a18b8ad69c
commit ae81095923
2 changed files with 68 additions and 1 deletions
+6 -1
View File
@@ -47,6 +47,9 @@ from src.type_aliases import (
)
NIL_METADATA: Metadata = {}
def find_next_increment(output_dir: Path, namespace: str) -> int:
pattern = re.compile(rf"^{re.escape(namespace)}_(\d+)\.md$")
max_num = 0
@@ -303,13 +306,15 @@ def _build_files_section_from_items(file_items: list[Metadata]) -> str:
[C: tests/test_aggregate_flags.py:test_auto_aggregate_skip, tests/test_context_composition_phase6.py:test_files_section_rendering, tests/test_tiered_context.py:test_build_files_section_with_dicts, tests/test_ui_summary_only_removal.py:test_aggregate_from_items_respects_auto_aggregate]
"""
sections = []
file_items = file_items or []
for item in file_items:
item = item or NIL_METADATA
if not item.get("auto_aggregate", True): continue
path = item.get("path")
entry = item.get("entry", "unknown")
content = item.get("content", "")
view_mode = item.get("view_mode", "full")
if path is None:
if not path:
if view_mode == "summary":
sections.append(f"### `{entry}`\n\n{content}")
else: