refactor(aggregate): remove deprecated build_tier1_context and build_tier2_context

This commit is contained in:
2026-05-09 17:44:15 -04:00
parent 5160287047
commit c4a738c8ba
3 changed files with 3 additions and 88 deletions
-44
View File
@@ -281,50 +281,6 @@ def build_discussion_text(history: list[str]) -> str:
return ""
return "## Discussion History\n\n" + build_discussion_section(history)
def build_tier1_context(file_items: list[dict[str, Any]], screenshot_base_dir: Path, screenshots: list[str], history: list[str]) -> str:
"""
Tier 1 Context: Strategic/Orchestration.
Full content for core conductor files and files with tier=1, summaries for others.
[C: tests/test_aggregate_flags.py:test_auto_aggregate_skip, tests/test_aggregate_flags.py:test_force_full, tests/test_tiered_context.py:test_build_tier1_context_exists, tests/test_tiered_context.py:test_tiered_context_by_tier_field]
"""
core_files = {"product.md", "tech-stack.md", "workflow.md", "tracks.md"}
sections = []
for item in file_items:
if not item.get("auto_aggregate", True):
continue
path = item.get("path")
if not path: continue
entry = item.get("entry")
display_name = entry or str(path)
tier = item.get("tier")
force_full = item.get("force_full")
content = item.get("content", "")
if path.name in core_files or tier == 1 or force_full:
suffix = path.suffix.lstrip(".") if path.suffix else "text"
sections.append(f"### `{display_name}`\n\n```{suffix}\n{content}\n```")
else:
sections.append(f"### `{display_name}`\n\n{summarize.summarise_file(path, content)}")
parts = []
if sections:
parts.append("## Files (Tier 1 - Mixed)\n\n" + "\n\n---\n\n".join(sections))
if screenshots:
parts.append("## Screenshots\n\n" + build_screenshots_section(screenshot_base_dir, screenshots))
if history:
parts.append("## Discussion History\n\n" + build_discussion_section(history))
return "\n\n---\n\n".join(parts)
def build_tier2_context(file_items: list[dict[str, Any]], screenshot_base_dir: Path, screenshots: list[str], history: list[str]) -> str:
"""
Tier 2 Context: Architectural/Tech Lead.
Full content for all files (standard behavior).
[C: tests/test_tiered_context.py:test_build_tier2_context_exists]
"""
return build_markdown_from_items(file_items, screenshot_base_dir, screenshots, history, summary_only=False)
def build_tier3_context(file_items: list[dict[str, Any]], screenshot_base_dir: Path, screenshots: list[str], history: list[str], focus_files: list[str]) -> str:
"""
+1 -15
View File
@@ -21,11 +21,6 @@ def test_auto_aggregate_skip(tmp_path):
assert "file1.txt" in section
assert "file2.txt" not in section
# Test build_tier1_context
t1 = aggregate.build_tier1_context(items, tmp_path, [], [])
assert "file1.txt" in t1
assert "file2.txt" not in t1
# Test build_tier3_context
t3 = aggregate.build_tier3_context(items, tmp_path, [], [], [])
assert "file1.txt" in t3
@@ -49,14 +44,5 @@ def test_force_full(tmp_path):
assert "print('world')" not in t3_2 # Skeletonized
# Tier 1 normally summarizes non-core files
txt_file = tmp_path / "other.txt"
txt_file.write_text("line1\nline2\nline3\nline4\nline5\nline6\nline7\nline8\nline9\nline10")
pass
items3 = aggregate.build_file_items(tmp_path, [{"path": "other.txt", "force_full": True}])
t1 = aggregate.build_tier1_context(items3, tmp_path, [], [])
assert "line10" in t1 # Full content present
items4 = aggregate.build_file_items(tmp_path, [{"path": "other.txt", "force_full": False}])
t1_2 = aggregate.build_tier1_context(items4, tmp_path, [], [])
# Generic summary for .txt shows first 8 lines
assert "line10" not in t1_2
+1 -28
View File
@@ -1,25 +1,6 @@
from typing import Any
from pathlib import Path
from src.aggregate import build_tier1_context, build_tier2_context, build_tier3_context
def test_build_tier1_context_exists() -> None:
file_items = [
{"path": Path("conductor/product.md"), "entry": "conductor/product.md", "content": "Product content", "error": False},
{"path": Path("other.py"), "entry": "other.py", "content": "Other content", "error": False}
]
history = ["User: hello", "AI: hi"]
result = build_tier1_context(file_items, Path("."), [], history)
assert "Product content" in result
# other.py should be summarized, not full content in a code block
assert "Other content" not in result or "Summarized" in result # Assuming summary format
def test_build_tier2_context_exists() -> None:
file_items = [
{"path": Path("other.py"), "entry": "other.py", "content": "Other content", "error": False}
]
history = ["User: hello"]
result = build_tier2_context(file_items, Path("."), [], history)
assert "Other content" in result
from src.aggregate import build_tier3_context
def test_build_tier3_context_ast_skeleton(monkeypatch: Any) -> None:
from unittest.mock import MagicMock
@@ -94,14 +75,6 @@ def test_tiered_context_by_tier_field() -> None:
{"path": Path("tier3_file.txt"), "entry": "tier3_file.txt", "content": "Full Tier 3 Content\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7\nLine 8\nLine 9\nLine 10", "tier": 3},
{"path": Path("other.txt"), "entry": "other.txt", "content": "Other Content\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7\nLine 8\nLine 9\nLine 10", "tier": None}
]
# Test Tier 1 Context
result_t1 = build_tier1_context(file_items, Path("."), [], [])
assert "Full Tier 1 Content" in result_t1
assert "Line 2" in result_t1 # In full
# tier3_file.txt should be summarized
assert "tier3_file.txt" in result_t1
assert "preview:" in result_t1
assert "Line 9" not in result_t1 # Only first 8 lines in preview
# Test Tier 3 Context
result_t3 = build_tier3_context(file_items, Path("."), [], [], focus_files=[])
assert "Full Tier 3 Content" in result_t3