feat(mma): Finalize Phase 1 with AST-based outline and improved tiered selection

This commit is contained in:
2026-02-27 22:23:50 -05:00
parent f59ef247cf
commit 528aaf1957
3 changed files with 73 additions and 78 deletions

View File

@@ -204,7 +204,7 @@ def build_discussion_text(history: list[str]) -> str:
def build_tier1_context(file_items: list[dict], screenshot_base_dir: Path, screenshots: list[str], history: list[str]) -> str:
"""
Tier 1 Context: Strategic/Orchestration.
Full content for core conductor files, summaries for others.
Full content for core conductor files and files with tier=1, summaries for others.
"""
core_files = {"product.md", "tech-stack.md", "workflow.md", "tracks.md"}
@@ -217,13 +217,14 @@ def build_tier1_context(file_items: list[dict], screenshot_base_dir: Path, scree
path = item.get("path")
name = path.name if path else ""
if name in core_files:
if name in core_files or item.get("tier") == 1:
# Include in full
sections.append("### `" + (item.get("entry") or str(path)) + "`\n\n" +
f"```{path.suffix.lstrip('.') if path.suffix else 'text'}\n{item.get('content', '')}\n```")
else:
# Summarize
sections.append(summarize.summarise_file(path, item.get("content", "")))
sections.append("### `" + (item.get("entry") or str(path)) + "`\n\n" +
summarize.summarise_file(path, item.get("content", "")))
parts.append("## Files (Tier 1 - Mixed)\n\n" + "\n\n---\n\n".join(sections))
@@ -247,7 +248,7 @@ def build_tier2_context(file_items: list[dict], screenshot_base_dir: Path, scree
def build_tier3_context(file_items: list[dict], screenshot_base_dir: Path, screenshots: list[str], history: list[str], focus_files: list[str]) -> str:
"""
Tier 3 Context: Execution/Worker.
Full content for focus_files, summaries for others.
Full content for focus_files and files with tier=3, summaries/skeletons for others.
"""
parts = []
@@ -265,7 +266,7 @@ def build_tier3_context(file_items: list[dict], screenshot_base_dir: Path, scree
is_focus = True
break
if is_focus:
if is_focus or item.get("tier") == 3:
sections.append("### `" + (entry or path_str) + "`\n\n" +
f"```{path.suffix.lstrip('.') if path and path.suffix else 'text'}\n{item.get('content', '')}\n```")
else:
@@ -277,9 +278,9 @@ def build_tier3_context(file_items: list[dict], screenshot_base_dir: Path, scree
sections.append(f"### `{entry or path_str}` (AST Skeleton)\n\n```python\n{skeleton}\n```")
except Exception as e:
# Fallback to summary if AST parsing fails
sections.append(summarize.summarise_file(path, content))
sections.append(f"### `{entry or path_str}`\n\n" + summarize.summarise_file(path, content))
else:
sections.append(summarize.summarise_file(path, content))
sections.append(f"### `{entry or path_str}`\n\n" + summarize.summarise_file(path, content))
parts.append("## Files (Tier 3 - Focused)\n\n" + "\n\n---\n\n".join(sections))