Skip to content
Merged
5 changes: 4 additions & 1 deletion src/specify_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,10 @@ def install_ai_skills(project_path: Path, selected_ai: str, tracker: StepTracker
console.print("[yellow]Warning: command templates not found, skipping skills installation[/yellow]")
return False

command_files = sorted(templates_dir.glob("*.md"))
if selected_ai == "copilot":
command_files = sorted(templates_dir.glob("speckit.*.md"))
else:
command_files = sorted(templates_dir.glob("*.md"))
if not command_files:
if tracker:
tracker.skip("ai-skills", "no command templates found")
Expand Down
27 changes: 25 additions & 2 deletions tests/test_ai_skills.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,12 @@ def test_skills_install_for_all_agents(self, temp_dir, agent_key):

# Place .md templates in the agent's commands directory
agent_folder = AGENT_CONFIG[agent_key]["folder"]
cmds_dir = proj / agent_folder.rstrip("/") / "commands"
commands_subdir = AGENT_CONFIG[agent_key].get("commands_subdir", "commands")
cmds_dir = proj / agent_folder.rstrip("/") / commands_subdir
cmds_dir.mkdir(parents=True)
(cmds_dir / "specify.md").write_text(
# Copilot uses speckit.*.agent.md templates; other agents use plain names
fname = "speckit.specify.agent.md" if agent_key == "copilot" else "specify.md"
(cmds_dir / fname).write_text(
"---\ndescription: Test command\n---\n\n# Test\n\nBody.\n"
)

Expand All @@ -448,6 +451,26 @@ def test_skills_install_for_all_agents(self, temp_dir, agent_key):
assert expected_skill_name in skill_dirs
assert (skills_dir / expected_skill_name / "SKILL.md").exists()

def test_copilot_ignores_non_speckit_agents(self, project_dir):
"""Non-speckit markdown in .github/agents/ must not produce skills."""
agents_dir = project_dir / ".github" / "agents"
agents_dir.mkdir(parents=True, exist_ok=True)
(agents_dir / "speckit.plan.agent.md").write_text(
"---\ndescription: Generate implementation plan.\n---\n\n# Plan\n\nBody.\n"
)
(agents_dir / "other-agent.agent.md").write_text(
"---\ndescription: Some other agent\n---\n\n# Other\n\nBody.\n"
)

result = install_ai_skills(project_dir, "copilot")

assert result is True
skills_dir = project_dir / ".github" / "skills"
assert skills_dir.exists()
skill_dirs = [d.name for d in skills_dir.iterdir() if d.is_dir()]
assert "speckit-plan" in skill_dirs
assert "speckit-other-agent.agent" not in skill_dirs



class TestCommandCoexistence:
Expand Down
Loading