Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions tests/extensions/test_extension_agent_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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
Expand Down Expand Up @@ -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 ─────────────────────────────────────────────────────


Expand Down