|
11 | 11 | """ |
12 | 12 |
|
13 | 13 | import re |
| 14 | +import zipfile |
14 | 15 | import pytest |
15 | 16 | import tempfile |
16 | 17 | import shutil |
@@ -799,6 +800,36 @@ def test_codex_ai_skills_here_mode_preserves_existing_codex_dir(self, tmp_path, |
799 | 800 | assert (target / ".codex").exists() |
800 | 801 | assert (existing_prompts / "custom.md").exists() |
801 | 802 |
|
| 803 | + def test_codex_ai_skills_fresh_dir_does_not_create_codex_dir(self, tmp_path): |
| 804 | + """Fresh-directory Codex skills init should not leave legacy .codex from archive.""" |
| 805 | + target = tmp_path / "fresh-codex-proj" |
| 806 | + archive = tmp_path / "codex-template.zip" |
| 807 | + |
| 808 | + with zipfile.ZipFile(archive, "w") as zf: |
| 809 | + zf.writestr("template-root/.codex/prompts/speckit.specify.md", "legacy") |
| 810 | + zf.writestr("template-root/.specify/templates/constitution-template.md", "constitution") |
| 811 | + |
| 812 | + fake_meta = { |
| 813 | + "filename": archive.name, |
| 814 | + "size": archive.stat().st_size, |
| 815 | + "release": "vtest", |
| 816 | + "asset_url": "https://example.invalid/template.zip", |
| 817 | + } |
| 818 | + |
| 819 | + with patch("specify_cli.download_template_from_github", return_value=(archive, fake_meta)): |
| 820 | + specify_cli.download_and_extract_template( |
| 821 | + target, |
| 822 | + "codex", |
| 823 | + "sh", |
| 824 | + is_current_dir=False, |
| 825 | + skip_legacy_codex_prompts=True, |
| 826 | + verbose=False, |
| 827 | + ) |
| 828 | + |
| 829 | + assert target.exists() |
| 830 | + assert (target / ".specify").exists() |
| 831 | + assert not (target / ".codex").exists() |
| 832 | + |
802 | 833 | def test_commands_preserved_when_skills_fail(self, tmp_path): |
803 | 834 | """If skills fail, commands should NOT be removed (safety net).""" |
804 | 835 | from typer.testing import CliRunner |
|
0 commit comments