diff --git a/tests/extensions/test_extension_agent_context.py b/tests/extensions/test_extension_agent_context.py index 61ecab91af..6ea42b69f4 100644 --- a/tests/extensions/test_extension_agent_context.py +++ b/tests/extensions/test_extension_agent_context.py @@ -3,8 +3,11 @@ from __future__ import annotations import json +import os +import subprocess from pathlib import Path +import pytest import yaml from specify_cli import ( @@ -15,6 +18,7 @@ ) from specify_cli.integrations.base import IntegrationBase from specify_cli.integrations.claude import ClaudeIntegration +from tests.conftest import requires_bash PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent @@ -86,6 +90,42 @@ def test_bash_script_reads_extension_config(self): assert "context_markers" in text +# -- Bundled script behavior -------------------------------------------------- + + +@requires_bash +@pytest.mark.skipif(not hasattr(os, "symlink"), reason="symlinks are unavailable") +def test_bash_update_preserves_symlinked_context_file(tmp_path): + """Regression: update-agent-context.sh must not replace context symlinks.""" + target = tmp_path / "AGENTS.md" + link = tmp_path / "CLAUDE.md" + target.write_text("# Agent notes\n", encoding="utf-8") + try: + os.symlink("AGENTS.md", link) + except OSError as exc: + pytest.skip(f"Current platform/user cannot create symlinks: {exc}") + + _write_ext_config(tmp_path, context_file="CLAUDE.md") + + result = subprocess.run( + [ + "bash", + str(EXT_DIR / "scripts" / "bash" / "update-agent-context.sh"), + "specs/001-demo/plan.md", + ], + cwd=tmp_path, + text=True, + capture_output=True, + ) + + assert result.returncode == 0, result.stderr + assert link.is_symlink() + target_text = target.read_text(encoding="utf-8") + assert target_text.startswith("# Agent notes\n") + assert "specs/001-demo/plan.md" in target_text + assert "agent-context: updated CLAUDE.md" in result.stdout + + # ── Catalog registration ─────────────────────────────────────────────────────