Add generic agent support (bring your own agent)#1639
Add generic agent support (bring your own agent)#1639mnriem wants to merge 1 commit intogithub:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds generic agent support to Spec Kit, allowing users with unsupported AI agents to scaffold projects immediately by specifying their agent's command directory. The PR also includes undocumented support for the Antigravity (agy) agent.
Changes:
- Added
--ai generic --ai-commands-dir <path>support for bring-your-own-agent functionality - Added Antigravity (agy) as a new supported agent (undocumented in PR description)
- Updated release packaging, agent context scripts, and documentation
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/specify_cli/init.py | Added generic and agy to AGENT_CONFIG, --ai-commands-dir parameter with validation, directory renaming logic for generic agent, check command exclusion for generic |
| scripts/powershell/update-agent-context.ps1 | Added agy and generic cases to agent context update script |
| scripts/bash/update-agent-context.sh | Added agy and generic cases to agent context update script |
| pyproject.toml | Version bump to 0.1.1 |
| README.md | Updated supported agents table and CLI reference with agy, generic, and --ai-commands-dir option |
| CHANGELOG.md | Added 0.1.1 release entry documenting generic agent support |
| AGENTS.md | Added Generic to agent table |
| .gitignore | Removed trailing whitespace (cosmetic) |
| .github/workflows/scripts/create-release-packages.sh | Added agy and generic to agent list and build cases |
| .github/workflows/scripts/create-release-packages.ps1 | Added generic to agent list (missing agy support) |
| .github/workflows/scripts/create-github-release.sh | Added agy and generic template packages to release uploads |
Comments suppressed due to low confidence (2)
src/specify_cli/init.py:1114
- When users run the init command without the --ai flag, the interactive agent selection menu includes 'generic' as an option (line 1102 creates choices from all agents in AGENT_CONFIG). However, if a user selects 'generic' interactively, they will immediately hit the validation error at line 1111 because --ai-commands-dir cannot be provided through the interactive flow. Consider either excluding 'generic' from the interactive menu, or prompting for the commands directory when 'generic' is selected interactively.
else:
# Create options dict for selection (agent_key: display_name)
ai_choices = {key: config["name"] for key, config in AGENT_CONFIG.items()}
selected_ai = select_with_arrows(
ai_choices,
"Choose your AI assistant:",
"copilot"
)
# Validate --ai-commands-dir usage
if selected_ai == "generic":
if not ai_commands_dir:
console.print("[red]Error:[/red] --ai-commands-dir is required when using --ai generic")
console.print("[dim]Example: specify init my-project --ai generic --ai-commands-dir .myagent/commands/[/dim]")
raise typer.Exit(1)
src/specify_cli/init.py:1195
- The directory move operation could fail if the target directory already exists. The shutil.move() function will raise an exception if target_dir already exists as a directory. Consider adding a check to handle this case gracefully, either by removing the existing directory first, merging contents, or providing a clear error message to the user.
shutil.move(str(placeholder_dir), str(target_dir))
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -1162,6 +1186,18 @@ | |||
|
|
|||
| download_and_extract_template(project_path, selected_ai, selected_script, here, verbose=False, tracker=tracker, client=local_client, debug=debug, github_token=github_token) | |||
|
|
|||
| # For generic agent, rename placeholder directory to user-specified path | |||
| if selected_ai == "generic" and ai_commands_dir: | |||
| placeholder_dir = project_path / ".speckit" / "commands" | |||
| target_dir = project_path / ai_commands_dir | |||
| if placeholder_dir.is_dir(): | |||
| target_dir.parent.mkdir(parents=True, exist_ok=True) | |||
| shutil.move(str(placeholder_dir), str(target_dir)) | |||
| # Clean up empty .speckit dir if it's now empty | |||
| speckit_dir = project_path / ".speckit" | |||
| if speckit_dir.is_dir() and not any(speckit_dir.iterdir()): | |||
| speckit_dir.rmdir() | |||
|
|
|||
There was a problem hiding this comment.
The new generic agent functionality, including --ai-commands-dir validation and directory renaming logic, lacks test coverage. Consider adding tests that verify: 1) --ai-commands-dir is required when using --ai generic, 2) --ai-commands-dir is rejected with other agents, 3) the placeholder directory is correctly renamed to the user-specified path, 4) proper cleanup of empty .speckit directory, and 5) edge cases like invalid paths or existing target directories.
This issue also appears on line 1100 of the same file.
| @@ -48,6 +48,7 @@ Specify supports multiple AI agents by generating agent-specific command files a | |||
| | **Amp** | `.agents/commands/` | Markdown | `amp` | Amp CLI | | |||
| | **SHAI** | `.shai/commands/` | Markdown | `shai` | SHAI CLI | | |||
| | **IBM Bob** | `.bob/commands/` | Markdown | N/A (IDE-based) | IBM Bob IDE | | |||
There was a problem hiding this comment.
The 'agy' (Antigravity) agent is missing from the Current Supported Agents table in AGENTS.md. Since it's been added to AGENT_CONFIG in init.py, it should also be documented here with its directory (.agent/), format (Markdown), CLI Tool (N/A IDE-based), and description for consistency with other agents.
| | **IBM Bob** | `.bob/commands/` | Markdown | N/A (IDE-based) | IBM Bob IDE | | |
| | **IBM Bob** | `.bob/commands/` | Markdown | N/A (IDE-based) | IBM Bob IDE | | |
| | **Antigravity** | `.agent/` | Markdown | N/A (IDE-based) | Antigravity IDE | |
| - Generates Markdown commands with `$ARGUMENTS` format (compatible with most agents) | ||
| - Example: `specify init my-project --ai generic --ai-commands-dir .myagent/commands/` | ||
| - Enables users to start with Spec Kit immediately while their agent awaits formal support | ||
|
|
There was a problem hiding this comment.
The CHANGELOG entry for version 0.1.1 only mentions the generic agent support but doesn't document the addition of 'agy' (Antigravity) as a new supported agent. Since Antigravity support was added in this PR (as evidenced by changes to AGENT_CONFIG, release scripts, and agent context scripts), it should be included in the CHANGELOG for completeness.
| - **Antigravity Agent (`agy`) Support**: Added first-class support for the Antigravity agent | |
| - Use via `--ai agy` to generate commands tailored for the Antigravity agent | |
| - Integrated into agent configuration, release scripts, and agent context handling | |
| - Recognized as a fully supported AI agent alongside existing agents |
|
|
||
| # Define all agents and scripts | ||
| $AllAgents = @('claude', 'gemini', 'copilot', 'cursor-agent', 'qwen', 'opencode', 'windsurf', 'codex', 'kilocode', 'auggie', 'roo', 'codebuddy', 'amp', 'q', 'bob', 'qoder') | ||
| $AllAgents = @('claude', 'gemini', 'copilot', 'cursor-agent', 'qwen', 'opencode', 'windsurf', 'codex', 'kilocode', 'auggie', 'roo', 'codebuddy', 'amp', 'q', 'bob', 'qoder', 'generic') |
There was a problem hiding this comment.
The PowerShell release packaging script is missing the 'agy' (Antigravity) agent that was added to the bash version (create-release-packages.sh line 233). This inconsistency means the PowerShell script cannot build agy template packages. The 'agy' agent should be added to the $AllAgents array, and a corresponding case should be added to the Build-Variant switch statement (similar to lines 218-220 in the bash version).
| "agy": { | ||
| "name": "Antigravity", | ||
| "folder": ".agent/", | ||
| "install_url": None, # IDE-based | ||
| "requires_cli": False, | ||
| }, |
There was a problem hiding this comment.
The PR description and linked issue #1638 don't mention adding support for the 'agy' (Antigravity) agent. This appears to be an undocumented change that was added alongside the generic agent support. The addition of 'agy' should either be documented in the PR description and CHANGELOG, or it should be removed from this PR and added separately to maintain a clear separation of concerns.
| placeholder_dir = project_path / ".speckit" / "commands" | ||
| target_dir = project_path / ai_commands_dir |
There was a problem hiding this comment.
The directory renaming logic doesn't validate that ai_commands_dir is a relative path. If a user provides an absolute path (e.g., '/tmp/commands/'), the behavior of 'project_path / ai_commands_dir' could be unexpected. Consider adding validation to ensure ai_commands_dir is a relative path and doesn't contain '..' to prevent directory traversal or paths outside the project directory.
This issue also appears on line 1195 of the same file.
| placeholder_dir = project_path / ".speckit" / "commands" | |
| target_dir = project_path / ai_commands_dir | |
| # Ensure ai_commands_dir is a safe, relative path inside the project directory | |
| ai_path = Path(ai_commands_dir) | |
| if ai_path.is_absolute() or ".." in ai_path.parts: | |
| raise ValueError("ai_commands_dir must be a relative path without '..' components.") | |
| project_root = project_path.resolve() | |
| target_dir = (project_root / ai_path).resolve() | |
| # Ensure the target directory is inside the project directory | |
| if target_dir != project_root and project_root not in target_dir.parents: | |
| raise ValueError("ai_commands_dir must point inside the project directory.") | |
| placeholder_dir = project_path / ".speckit" / "commands" |
- Introduced `--ai generic` option for unsupported agents, allowing users to specify their own command directories. - Updated documentation and examples to reflect the new generic agent support. - Enhanced scripts and workflows to accommodate the new agent type.
89fb41e to
30758f2
Compare
Summary
Adds
--ai generic --ai-commands-dir <path>support tospecify init, enabling users with unsupported AI agents to scaffold Spec Kit projects immediately.Closes #1638
Changes
Core CLI (
src/specify_cli/__init__.py):generictoAGENT_CONFIG(folder=None,requires_cli=False)--ai-commands-dirparameter toinit()--ai generic, rejected with other agentsuser's
--ai-commands-dirpathgenericfromcheck()command (not a real tool to check)Release packaging (3 scripts):
genericto agent lists and case/switch statements.speckit/commands/as placeholder directory in ZIPsAgent context scripts (bash + PowerShell):
genericcase with informational messageDocumentation:
Usage
Testing
All 39 existing tests pass.