refactor: consolidate agent configurations and improve test coverage#1712
refactor: consolidate agent configurations and improve test coverage#1712neelneelpurk wants to merge 1 commit intogithub:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the AI agent configuration system by consolidating agent metadata into a single source of truth (src/specify_cli/agent_config.py), eliminating duplication between __init__.py and extensions.py. The refactoring improves maintainability by ensuring consistent configuration across the CLI initialization and extension registration systems.
Changes:
- Created
agent_config.pyas the single source of truth for all agent metadata, including newly added fields for command format, args, and extension - Updated
extensions.pyto dynamically generateCommandRegistrar.AGENT_CONFIGSfrom the shared configuration with improved internal field naming - Expanded test coverage with parametrized tests that verify command registration for all 18 configured agents (including AGY/Antigravity)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/agent_config.py |
New file defining AGENT_CONFIG dictionary with comprehensive agent metadata including command format specifications |
src/specify_cli/__init__.py |
Removed duplicate AGENT_CONFIG definition and imports from new agent_config module |
src/specify_cli/extensions.py |
Updated to import and dynamically transform AGENT_CONFIG into AGENT_CONFIGS, renamed internal fields (format→command_format, args→command_args, extension→command_extension) |
tests/test_extensions.py |
Enhanced with parametrized tests covering all agents for command registration and alias handling |
AGENTS.md |
Updated documentation to reference new config location and document new field names |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@neelneelpurk Can you please resolve Run uvx ruff check src/ Found 1 error. |
Summary
This PR refactors the AI agent configuration system to eliminate duplication, reduce the risk of configuration drift, and improve maintainability. It also enhances the test suite to ensure consistent command registration across all supported agents.
Changes
Consolidated Configuration: Moved the agent metadata from
src/specify_cli/__init__.pyto a new dedicated file:src/specify_cli/agent_config.py.Dynamic Registry: Updated
src/specify_cli/extensions.pyto dynamically generate theCommandRegistrar.AGENT_CONFIGSregistry from the shared source of truth.Improved Internal Naming: Renamed internal configuration keys to be more descriptive and avoid namespace collisions:
"format"→"command_format""args"→"command_args""extension"→"command_extension"Generic Command Registration: Updated
src/specify_cli/extensions.pyto use a generic registration flow that works for all agents without special-case logic.Expanded Test Coverage: Updated
tests/test_extensions.pyusing@pytest.mark.parametrizeto loop through every supported agent (includingagy,codex,gemini, etc.) to verify command and alias registration.Updated Documentation: Refactored
AGENTS.mdto point developers to the new configuration location and reflect the updated field names.Impact
src/specify_cli/agent_config.py.Testing
uv run specify --helpuv sync && uv run pytestAI Disclosure
Used Antigravity for code generation and review.
Issue
Fixes #1705