Skip to content

Commit e03f9d8

Browse files
authored
fix(ai-skills): normalize Copilot .agent templates and preserve fallback behavior
fix(ai-skills): handle Copilot .agent templates and fallback filtering Normalize Copilot command template names by stripping the .agent suffix when deriving skill names and metadata sources, so files like speckit.plan.agent.md produce speckit-plan and map to plan.md metadata. Also align Copilot template discovery with speckit.* filtering while preserving fallback to templates/commands/ when .github/agents contains only user-authored markdown files, and add regression coverage for both non-speckit agent exclusion and fallback behavior.
1 parent 647adb9 commit e03f9d8

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

tests/test_ai_skills.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -458,21 +458,40 @@ def test_copilot_ignores_non_speckit_agents(self, project_dir):
458458
(agents_dir / "speckit.plan.agent.md").write_text(
459459
"---\ndescription: Generate implementation plan.\n---\n\n# Plan\n\nBody.\n"
460460
)
461-
(agents_dir / "other-agent.agent.md").write_text(
462-
"---\ndescription: Some other agent\n---\n\n# Other\n\nBody.\n"
461+
(agents_dir / "my-custom-agent.agent.md").write_text(
462+
"---\ndescription: A user custom agent\n---\n\n# Custom\n\nBody.\n"
463463
)
464464

465465
result = install_ai_skills(project_dir, "copilot")
466466

467467
assert result is True
468-
skills_dir = project_dir / ".github" / "skills"
468+
skills_dir = _get_skills_dir(project_dir, "copilot")
469469
assert skills_dir.exists()
470470
skill_dirs = [d.name for d in skills_dir.iterdir() if d.is_dir()]
471471
assert "speckit-plan" in skill_dirs
472-
assert "speckit-other-agent.agent" not in skill_dirs
473-
assert "speckit-other-agent" not in skill_dirs
472+
assert "speckit-my-custom-agent.agent" not in skill_dirs
473+
assert "speckit-my-custom-agent" not in skill_dirs
474+
475+
def test_copilot_fallback_when_only_non_speckit_agents(self, project_dir):
476+
"""Fallback to templates/commands/ when .github/agents/ has no speckit.*.md files."""
477+
agents_dir = project_dir / ".github" / "agents"
478+
agents_dir.mkdir(parents=True, exist_ok=True)
479+
# Only a user-authored agent, no speckit.* templates
480+
(agents_dir / "my-custom-agent.agent.md").write_text(
481+
"---\ndescription: A user custom agent\n---\n\n# Custom\n\nBody.\n"
482+
)
474483

484+
result = install_ai_skills(project_dir, "copilot")
475485

486+
# Should succeed via fallback to templates/commands/
487+
assert result is True
488+
skills_dir = _get_skills_dir(project_dir, "copilot")
489+
assert skills_dir.exists()
490+
skill_dirs = [d.name for d in skills_dir.iterdir() if d.is_dir()]
491+
# Should have skills from fallback templates, not from the custom agent
492+
assert "speckit-plan" in skill_dirs
493+
assert not any("my-custom" in d for d in skill_dirs)
494+
476495

477496
class TestCommandCoexistence:
478497
"""Verify install_ai_skills never touches command files.

0 commit comments

Comments
 (0)