diff --git a/tests/test_aggregate_directives_presets.py b/tests/test_aggregate_directives_presets.py index d2a1ea6c..0d1611a7 100644 --- a/tests/test_aggregate_directives_presets.py +++ b/tests/test_aggregate_directives_presets.py @@ -205,4 +205,52 @@ a - beta: conductor/directives/beta/v1.md """, encoding="utf-8") with pytest.raises(ValueError, match="inheritance loop"): - resolve_inheritance(pdir / "a.md", root=tmp_path) \ No newline at end of file + resolve_inheritance(pdir / "a.md", root=tmp_path) + + +class TestAggregateWithNonDirectiveContext: + """Integration: aggregate_directives returns non-directive files in a separate section.""" + + def test_aggregate_includes_non_directive_section(self, tmp_path: Path): + directives_dir = tmp_path / "conductor" / "directives" / "alpha" + directives_dir.mkdir(parents=True) + (directives_dir / "v1.md").write_text("# Alpha rule\n\nDo the thing.\n", encoding="utf-8") + context_file = tmp_path / "AGENTS.md" + context_file.write_text("# Project Rules\n\nRule 1.\n", encoding="utf-8") + preset = tmp_path / "test_preset.md" + preset.write_text("""# Preset: test + +## Directives to warm +- alpha: conductor/directives/alpha/v1.md + +## Non-directive context +- project rules: AGENTS.md +""", encoding="utf-8") + rendered = aggregate_directives(str(preset), project_root=str(tmp_path)) + assert "alpha" in rendered + assert "Alpha rule" in rendered + assert "NON-DIRECTIVE CONTEXT" in rendered + assert "Project Rules" in rendered + assert rendered.index("alpha") < rendered.index("NON-DIRECTIVE CONTEXT") + + def test_aggregate_non_directive_section_after_directives(self, tmp_path: Path): + directives_dir = tmp_path / "conductor" / "directives" / "beta" + directives_dir.mkdir(parents=True) + (directives_dir / "v1.md").write_text("# Beta rule\n\nDo beta.\n", encoding="utf-8") + context_file = tmp_path / "conductor" / "product.md" + context_file.parent.mkdir(parents=True, exist_ok=True) + context_file.write_text("# Product\n\nVision.\n", encoding="utf-8") + preset = tmp_path / "test_preset.md" + preset.write_text("""# Preset: test + +## Directives to warm +- beta: conductor/directives/beta/v1.md + +## Non-directive context +- product: conductor/product.md +""", encoding="utf-8") + rendered = aggregate_directives(str(preset), project_root=str(tmp_path)) + assert "Beta rule" in rendered + assert "Product" in rendered + assert rendered.index("Beta rule") < rendered.index("NON-DIRECTIVE CONTEXT") + assert "product" in rendered.lower() or "Product" in rendered \ No newline at end of file