Skip to content

Commit ec5471a

Browse files
Copilotmnriem
andauthored
Fix code review issues: safe teardown for shared dirs, less brittle test assertions
- Copilot: only remove .github/agents/ (preserves workflows, templates) - Tabnine: only remove .tabnine/agent/ (preserves other config) - Amp/Codex: only remove respective subdirs (commands/skills) to avoid deleting each other's files in shared .agents/ dir - Tests: use flexible assertions instead of hardcoded >= 25 counts Co-authored-by: mnriem <15701806+mnriem@users.noreply.github.com> Agent-Logs-Url: https://github.com/github/spec-kit/sessions/ef8b4682-7f1a-4b04-a112-df0878236b6b
1 parent 3212309 commit ec5471a

5 files changed

Lines changed: 57 additions & 21 deletions

File tree

src/specify_cli/core_pack/agents/amp/bootstrap.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ def setup(self, project_path: Path, script_type: str, options: Dict[str, Any]) -
1818
commands_dir.mkdir(parents=True, exist_ok=True)
1919

2020
def teardown(self, project_path: Path) -> None:
21-
"""Remove Amp agent files from the project."""
21+
"""Remove Amp agent files from the project.
22+
23+
Only removes the commands/ subdirectory — preserves other .agents/
24+
content (e.g. Codex skills/) which shares the same parent directory.
25+
"""
2226
import shutil
23-
agent_dir = project_path / self.AGENT_DIR
24-
if agent_dir.is_dir():
25-
shutil.rmtree(agent_dir)
27+
commands_dir = project_path / self.AGENT_DIR / self.COMMANDS_SUBDIR
28+
if commands_dir.is_dir():
29+
shutil.rmtree(commands_dir)
30+
# Remove .agents/ only if now empty
31+
agents_dir = project_path / self.AGENT_DIR
32+
if agents_dir.is_dir() and not any(agents_dir.iterdir()):
33+
agents_dir.rmdir()

src/specify_cli/core_pack/agents/codex/bootstrap.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ def setup(self, project_path: Path, script_type: str, options: Dict[str, Any]) -
1818
commands_dir.mkdir(parents=True, exist_ok=True)
1919

2020
def teardown(self, project_path: Path) -> None:
21-
"""Remove Codex CLI agent files from the project."""
21+
"""Remove Codex CLI agent files from the project.
22+
23+
Only removes the skills/ subdirectory — preserves other .agents/
24+
content (e.g. Amp commands/) which shares the same parent directory.
25+
"""
2226
import shutil
23-
agent_dir = project_path / self.AGENT_DIR
24-
if agent_dir.is_dir():
25-
shutil.rmtree(agent_dir)
27+
skills_dir = project_path / self.AGENT_DIR / self.COMMANDS_SUBDIR
28+
if skills_dir.is_dir():
29+
shutil.rmtree(skills_dir)
30+
# Remove .agents/ only if now empty
31+
agents_dir = project_path / self.AGENT_DIR
32+
if agents_dir.is_dir() and not any(agents_dir.iterdir()):
33+
agents_dir.rmdir()

src/specify_cli/core_pack/agents/copilot/bootstrap.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ def setup(self, project_path: Path, script_type: str, options: Dict[str, Any]) -
1818
commands_dir.mkdir(parents=True, exist_ok=True)
1919

2020
def teardown(self, project_path: Path) -> None:
21-
"""Remove GitHub Copilot agent files from the project."""
21+
"""Remove GitHub Copilot agent files from the project.
22+
23+
Only removes the agents/ subdirectory — preserves other .github
24+
content (workflows, issue templates, etc.).
25+
"""
2226
import shutil
23-
agent_dir = project_path / self.AGENT_DIR
24-
if agent_dir.is_dir():
25-
shutil.rmtree(agent_dir)
27+
agents_dir = project_path / self.AGENT_DIR / self.COMMANDS_SUBDIR
28+
if agents_dir.is_dir():
29+
shutil.rmtree(agents_dir)
30+
# Also clean up companion .github/prompts/ if empty
31+
prompts_dir = project_path / self.AGENT_DIR / "prompts"
32+
if prompts_dir.is_dir() and not any(prompts_dir.iterdir()):
33+
prompts_dir.rmdir()

src/specify_cli/core_pack/agents/tabnine/bootstrap.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@ def setup(self, project_path: Path, script_type: str, options: Dict[str, Any]) -
1818
commands_dir.mkdir(parents=True, exist_ok=True)
1919

2020
def teardown(self, project_path: Path) -> None:
21-
"""Remove Tabnine CLI agent files from the project."""
21+
"""Remove Tabnine CLI agent files from the project.
22+
23+
Removes the agent/ subdirectory under .tabnine/ to preserve
24+
any other Tabnine configuration.
25+
"""
2226
import shutil
23-
agent_dir = project_path / self.AGENT_DIR
24-
if agent_dir.is_dir():
25-
shutil.rmtree(agent_dir)
27+
agent_subdir = project_path / self.AGENT_DIR
28+
if agent_subdir.is_dir():
29+
shutil.rmtree(agent_subdir)
30+
# Remove .tabnine/ only if now empty
31+
tabnine_dir = project_path / ".tabnine"
32+
if tabnine_dir.is_dir() and not any(tabnine_dir.iterdir()):
33+
tabnine_dir.rmdir()

tests/test_agent_pack.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,18 +365,22 @@ class TestDiscovery:
365365

366366
def test_list_embedded_agents_nonempty(self):
367367
agents = list_embedded_agents()
368-
assert len(agents) >= 25
368+
assert len(agents) > 0
369369
ids = {a.id for a in agents}
370-
assert "claude" in ids
371-
assert "gemini" in ids
372-
assert "copilot" in ids
370+
# Verify core agents are present
371+
for core_agent in ("claude", "gemini", "copilot"):
372+
assert core_agent in ids
373373

374374
def test_list_all_agents(self):
375375
all_agents = list_all_agents()
376-
assert len(all_agents) >= 25
376+
assert len(all_agents) > 0
377377
# Should be sorted by id
378378
ids = [a.manifest.id for a in all_agents]
379379
assert ids == sorted(ids)
380+
# Verify core agents are present
381+
id_set = set(ids)
382+
for core_agent in ("claude", "gemini", "copilot"):
383+
assert core_agent in id_set
380384

381385

382386
# ===================================================================

0 commit comments

Comments
 (0)