Commit 31ba393
authored
feat(slash-commands): add generator for AI assistant native slash commands (#19)
* docs(tasks): add spec/tasks for slash commands helper
* feat(slash-commands): bootstrap config and detection
- add command format enum and agent registry for 14 tools
- implement auto-detection helpers with deterministic ordering
- add targeted pytest coverage and close Task 1.0 foundations
Related to Task 1.0 in Spec
* feat: implement Markdown and TOML command generators with override support
- Add CommandGenerator base class with Markdown and TOML subclasses
- Implement agent override support for descriptions, arguments, and enabled flags
- Add placeholder replacement for $ARGUMENTS and {{args}}
- Support argument merging for agent-specific overrides
- Add comprehensive test coverage for both generator types
- Update MarkdownPrompt to include agent_overrides field
Related to T2.4 in Spec
* feat: add output normalization and snapshot regression tests
- Add _normalize_output function for consistent whitespace/encoding
- Normalize line endings to LF, remove trailing whitespace
- Add snapshot-style regression tests for both generators
- Tests verify output structure, valid TOML, and no trailing whitespace
Related to T2.5 in Spec
* chore: mark task 2.0 complete - all generator subtasks finished
- All subtasks 2.1-2.5 are complete
- Demo criteria satisfied: generators transform MarkdownPrompt objects
- All tests passing: pytest tests/test_generators.py -v
* feat: implement slash command writer with multi-agent support
- Add SlashCommandWriter class orchestrating prompt loading and generation
- Support single and multi-agent generation with dry-run mode
- Create parent directories automatically
- Add comprehensive test coverage for writer functionality
- Export writer interface from slash_commands package
Related to T3.0 in Spec
* chore: remove generated test files
* feat: implement Typer CLI with auto-detection and selection flows
- Add Typer CLI app with comprehensive command options
- Support --agents, --list-agents, --dry-run, --prompts-dir flags
- Auto-detect configured agents from filesystem
- Add comprehensive test coverage for CLI functionality
- Register CLI entry point in pyproject.toml
- Export CLI from slash_commands package
Related to T4.0 in Spec
* feat: implement overwrite handling with backup support
- Add prompt_overwrite_action and create_backup utilities
- Implement overwrite detection and handling in SlashCommandWriter
- Add support for cancel, overwrite, backup, and overwrite-all actions
- Track backups created and report them in CLI summary
- Add tests for overwrite handling scenarios
- Update CLI to honor --yes flag for auto-overwrite
Related to T5.1, T5.2, T5.3 in Spec
* docs: add slash command generator documentation
- Create comprehensive documentation for slash command generator
- Document CLI usage, supported agents, and file formats
- Add overview of overwrite handling and backup features
- Update README with link to new documentation
Related to T5.4 in Spec
* docs: mark task 5.0 and all subtasks complete
- All overwrite handling features implemented and tested
- Documentation added for slash command generator
- Dependencies verified and tests passing
Related to T5.0 completion in Spec
* fix: add missing tomli-w dependency and update documentation
- Add tomli-w>=1.0.0 to dependencies for TOML generation
- Update documentation to use 'uv run' prefix for all commands
- Clarify that uv projects require 'uv run' to execute scripts
Fixes issue where sdd-generate-commands was not found
* feat: Fix critical audit issues and add detection path option
- Implement interactive overwrite prompt using questionary.select()
- Add interactive agent selection UI with checkboxes
- Fix documentation agent list to match actual 14 agents
- Update directory structure examples to reflect actual agents
- Fix backup timestamp format to use YYYYMMDD-HHMMSS
- Update TOML format example to match actual generator output
- Add --detection-path option for flexible agent detection
- Add integration tests for interactive flows
- Add questionary dependency to pyproject.toml
- Add spec addendum documenting detection default location oversight
- Add task 8.0 to fix default detection to home directory
All tests passing (56 tests)
* docs: Add reference links to supported agents table
Add Reference column with home and documentation links for all 14 agents
* feat: implement consistent exit codes and improved error handling
- Implement consistent exit codes (0=success, 1=user cancel, 2=validation error, 3=I/O error)
- Add comprehensive error messages with guidance for common failure scenarios
- Expand troubleshooting section in docs with detailed solutions
- Update examples to show actual command output and file structures
- Add backup file cleanup documentation
- Add --target-dir alias for --base-path option
Related to task 7.0 in Spec 0003
* feat: change default paths to home directory and unify option names
- Replace --base-path/--target-dir with single --target-path option
- Set --target-path default to home directory instead of current directory
- Set --detection-path default to home directory instead of current directory
- Update all tests to use --target-path instead of --base-path
- Update documentation to reflect new default behavior
- Add detection path section to documentation
Related to task 8.0 in Spec 0003
* feat: improve --list-agents output with Rich table
- Add Rich table formatting for --list-agents output
- Add Target Path column showing command directory for each agent
- Add Detected column showing whether agent detection directories exist
- Use checkmarks (✓) and crosses (✗) to indicate detection status
- Apply color styling to table columns
* feat: improve list-agents table formatting
- Add ~/ prefix to target paths to show home directory relative paths
- Change ✗ marks to red color for better visual distinction
- Use Rich markup syntax for colored checkmarks and crosses
* fix: correct detection logic to check command directory
- Change detection logic to check if command directory exists
- Previously checked detection directories which could be misleading
- Now shows ✓ only when the actual command directory exists
- Fixes issue where agents were marked as detected when command dir didn't exist
* fix: correct agent command directories based on official documentation
- Change Cursor from .cursorrules/commands to .cursor/commands
- Change Amp from .amp/commands to .agents/commands
- Change Auggie CLI from .auggie/commands to .augment/commands
- Change Kilo Code from .kilo/commands to .kilocode/rules
- Change opencode from .opencode/commands to .config/opencode/commands
- Update detection directories to match command directories
- Update tests to match new configurations
* refactor: remove unsupported agents and update remaining paths
- Remove amazon-q-developer, amp, auggie-cli, crush, github-copilot, kilo-code, opencode, qwen-code, roo-code
- Rename codebuddy-cli to vs-code
- Update paths to verified working locations:
- Cursor: .cursor/rules/.mdc
- Codex: .codex/prompts
- Windsurf: .codeium/windsurf/global_workflows
- VS Code: .config/Code/User/prompts/.prompt.md
- Update tests to match new configuration
- Reduce from 15 to 6 supported agents
* fix(config): correct Cursor agent command directory and file extension
Update Cursor agent configuration to use .cursor/commands instead
of .cursor/rules and change file extension from .mdc to .md.
Also remove legacy .cursorrules from detection directories.
This aligns with official Cursor documentation for slash commands.
* feat(slash-commands): add version and updated_at metadata to generated commands
Add two new metadata fields to all generated slash command files:
- version: reads from pyproject.toml via centralized __version__ constant
- updated_at: ISO format timestamp of when command was generated
Centralize version management by reading from pyproject.toml in
mcp_server/__init__.py instead of hardcoding. Generators now import
and use this version, making it the single source of truth.
Both Markdown and TOML generators include these fields in their
metadata sections, and tests verify their presence.
* refactor(generators): align TOML format with official Gemini CLI spec
Refactored TomlCommandGenerator to match the official Gemini CLI custom commands spec (https://geminicli.com/docs/cli/custom-commands/).
Changes:
- Simplify TOML structure to flat format with prompt and description fields
- Preserve {{args}} placeholder for Gemini CLI context-aware injection
- Add metadata fields for version tracking (ignored by Gemini CLI)
- Remove unused helper methods and simplify implementation
- Update tests to validate new structure and {{args}} preservation
Benefits:
- Commands are now properly detected by Gemini CLI
- Maintains version tracking capabilities for our tooling
- Follows official Gemini CLI specification exactly
- All 58 tests passing
* feat(slash-commands): add cleanup command for generated files
Add a new cleanup command to the slash command generator that can
detect and remove generated command files and backups based on metadata.
Features:
- Detect generated files via metadata (source_prompt, version)
- Support both Markdown and TOML file formats
- Detect backup files by timestamp pattern
- Rich table formatting for file listing
- Confirmation prompt with warning panel
- Dry-run mode for safety
- Comprehensive test coverage
The cleanup command uses Rich formatting with tables for file listings
and panels for warnings and summaries, improving the user experience
compared to plain text output.
* docs(tasks): add spec and task list for code review fixes
Add specification document 0004-spec-review-fixes.md detailing the
code review findings that need to be addressed, along with a
comprehensive task list breaking down the implementation into 5
demoable units of work with 23 actionable subtasks.
The spec covers fixes for:
- Package discovery configuration
- TOML reading documentation
- Generated content validation tests
- Centralized version management
- Troubleshooting documentation
* feat: add slash_commands to package discovery configuration
- Added slash_commands to packages list in pyproject.toml
- Verified package installs successfully with uv pip install -e .
- Verified CLI works without import errors
- Verified slash_commands directory is included in installed package
Related to T1.0 in Spec 0004
* docs: document TOML reading approach and Python version requirements
- Added Python Version Requirements section to docs
- Clarified Python 3.12+ requirement and tomllib availability
- Added comment to writer.py explaining tomllib is from stdlib
- Verified tomllib import works correctly
- All tests pass successfully
Related to T2.0 in Spec 0004
* test: add generated content validation tests
- Created tests/test_validation.py with validation tests
- Added test_toml_round_trip_parsing to verify TOML can be parsed back
- Added test_yaml_frontmatter_parsing to validate YAML structure
- Added test_invalid_toml_content_caught to catch invalid TOML
- Added test_invalid_yaml_content_caught to catch invalid YAML
- All 75 tests pass including 5 new validation tests
Related to T3.0 in Spec 0004
* refactor: centralize version management
- Created __version__.py at project root for centralized version management
- Updated slash_commands/generators.py to import from __version__ instead of mcp_server
- Updated mcp_server/__init__.py to import from shared __version__.py module
- Version now read from pyproject.toml via single source of truth
- All 75 tests pass successfully
Related to T4.0 in Spec 0004
* docs: enhance troubleshooting documentation and Python version requirements
- Enhanced Python Version Requirements section with detailed explanations
- Added 'Why Python 3.12+' subsection with clear rationale
- Added 'No Additional Dependencies Required' subsection explaining tomllib benefits
- Verified all troubleshooting scenarios are documented
- Verified documentation renders correctly as markdown
- All 75 tests pass successfully
Related to T5.0 in Spec 0004
* docs(slash-command-generator): align documentation with actual implementation
- Corrected supported agents count from 14 to 6 actual agents
- Added comprehensive documentation for cleanup command
- Added missing vs-code agent to supported agents table
- Documented interactive agent selection feature
- Documented command_prefix metadata field
- Updated directory structure examples to match actual paths
- Updated examples to show actual CLI output format
- Removed undocumented environment variables section
* test(coverage): add pytest-cov configuration and documentation
- Configure pytest-cov to report coverage for mcp_server and slash_commands modules
- Add HTML coverage report generation
- Update CI workflow to include slash_commands in coverage reporting
- Add htmlcov directory to .gitignore
- Update CONTRIBUTING.md with coverage viewing instructions
- Update docs/operations.md with coverage command and HTML report details
Provides 85% overall coverage across both modules with terminal and HTML reporting.
* refactor(version): support both local and installed package modes
- Update __version__.py to handle both local development and installed
package scenarios using importlib.metadata fallback
- Add fallback imports in mcp_server/__init__.py and
slash_commands/generators.py to use importlib.metadata when
__version__ is not available
- Include __version__.py in wheel package via force-include
Enables the package to work correctly when installed via uvx --from
git+ URL or from PyPI, while maintaining backward compatibility
with local development.
* feat(server): add command-line argument parsing for transport and port
- Add sys.argv parsing to main() function
- Support --transport argument to choose between stdio and http
- Support --port argument for HTTP transport
- Add __main__ block to allow direct execution
Enables running the MCP server via uvx with transport and port
options: uvx spec-driven-development-mcp --transport http --port 8000
* docs: reorganize README with clearer usage options
- Restructure Hands-On Usage section into three clear options:
Option 1: Manual Copy-Paste (No Tooling Required)
Option 2: Native Slash Commands (Recommended)
Option 3: MCP Server (Advanced)
- Add git URL examples for running via uvx --from
- Improve organization from simplest to most automated
- Add PyPI notes for future simplified syntax
Provides a clearer progression for users choosing their preferred
workflow integration method.
* fix: address CodeRabbitAI review comments
- Use argparse for CLI argument parsing in server.py
- Use cross-platform webbrowser command in CONTRIBUTING.md
- Fix agent count and hyphenation in tasks file
- Fix test ordering assertions to follow SUPPORTED_AGENTS order
- Add explicit UTF-8 encoding to conftest.py
- Use iter_detection_dirs() in detection.py
- Clarify TOML dependency documentation
- Remove Qwen Code reference from docs
- Simplify test_writer.py fixture
- Add command prefix assertion in test_validation.py
- Show actual agent keys in error messages
- Preserve intentional blank lines in normalization
- Add argument deduplication in generators.py
* fix: update typer version constraint to match available PyPI version
- Change typer>=0.20.0 to typer>=0.19.0 to match latest available version (0.19.2)
* chore: update all packages to latest compatible versions
Updated 16 packages including:
- fastmcp v2.12.4 -> v2.12.5
- pydantic v2.12.0 -> v2.12.3
- ruff v0.14.0 -> v2.14.1
- cyclopts v3.24.0 -> v4.0.0
- coverage v7.10.7 -> v7.11.0
- And 11 other packages
* fix: address additional CodeRabbit review comments
- Fix dry-run file count to report actual file count regardless of mode
- Add explicit UTF-8 encoding when writing generated files
- Fix single-element tuple in test detection_dirs
- Move prompts directory from packages to force-include in pyproject.toml
* ci: add pre-push test hook and fix dry_run file count bug
- Add local pre-commit hook to run pytest before push
- Fix writer to correctly report files_written=0 in dry_run mode
- Prevents CI test failures from incorrect file counting
* fix: address remaining CodeRabbit AI review comments
- Fix coverage exclude pattern for __main__ guard in pyproject.toml
- Add PackageNotFoundError handling for version fallback in generators.py
- Store only basename in source_path to avoid leaking absolute paths
- Fix agents=None to default to all supported agents in writer.py
These changes address 4 remaining CodeRabbit AI review comments that were not
covered in the previous fixes.
* fix: address PR review feedback for slash command generator
- Fix agent argument overrides to actually override existing args
- Sanitize prompt.name to prevent path traversal
- Use safe_dump for YAML generation
- Remove unused helper function
- Show actual supported agent keys in error messages
- Prefer Typer-controlled exits over sys.exit
- Use agent.iter_detection_dirs() for consistency
- Respect empty agent lists in find_generated_files
- Normalize path types to strings in return values
- Use UTC timestamps in backup filenames
* fix: normalize path return types to strings in find_generated_files
- Use os.fspath() to convert Path objects to strings
- Update tests to verify string return type
- Ensures consistent return types for JSON serialization
* fix(install): add fallback to find prompts in installed package
When running the tool via uvx, the prompts directory
may not be available relative to the current working directory.
This commit adds a fallback mechanism to locate prompts
in the installed package directory when the specified
prompts directory doesn't exist.
Changes:
- Add _find_package_prompts_dir() helper function to locate
prompts in package root
- Update _load_prompts() to fall back to package prompts
when specified directory doesn't exist
- Update tests to mock fallback function for error cases
- Add test to verify fallback behavior works correctly
This enables the tool to work seamlessly when installed
via uvx without requiring --prompts-dir to be specified.
* docs: add TLDR section to README showing quick start workflow
Add a concise TLDR section at the top of the README that shows:
- How to install prompts via uvx
- Example of running /generate-spec with an idea
- Continuing through the workflow with task list and management
- The end goal (profit)
This makes it easier for new users to quickly understand
and get started with the spec-driven development workflow.
* docs: replace Profit with SHIP IT meme in TLDR
* docs(specs): add spec for fixing bundled prompts directory resolution
- Fix prompts directory resolution for remote installation via uvx
- Enable automatic detection of bundled prompts in installed packages
- Maintain backward compatibility with custom prompts directories
- Improve error messages for better user experience
* docs(specs): add task list for fixing bundled prompts directory resolution
- Add tasks-0005-spec-fix-bundled-prompts-path.md
- Task list covers updating importlib.resources usage
- Includes CLI changes to distinguish default vs explicit paths
- Ensures backward compatibility and proper error handling
* feat: add importlib.resources support for bundled prompts resolution
- Import importlib.resources module in writer.py
- Add strategy using importlib.resources.files() to locate bundled prompts
- Keep existing fallback strategy using Path(__file__).parent.parent
- Add proper error handling for importlib edge cases
- Add unit test test_writer_finds_bundled_prompts for importlib.resources path resolution
Related to task 1.0 in tasks-0005-spec-fix-bundled-prompts-path.md
* fix: only fall back to bundled prompts for default directory
Update CLI and Writer to distinguish between explicitly provided
prompts directory and default directory. Only attempt fallback to
bundled prompts when using the default path (not explicitly provided).
- Change CLI prompts_dir default from Path("prompts") to None
- Add is_explicit_prompts_dir flag to track user intent
- Update Writer._load_prompts() to skip fallback for explicit paths
- Improve error messages to distinguish default vs explicit paths
- Add test for explicit path error handling
- Update existing tests to pass is_explicit_prompts_dir parameter
- Mark completed tasks in task list
This fixes the issue where explicitly providing an invalid path would
attempt to fall back to bundled prompts, causing confusing behavior.
* docs(tasks): update task list for bundled prompts resolution
- Mark tasks 3.0 and 4.0 as completed
- Mark all subtasks of 3.0 and 4.0 as completed
- Progress on task 5.0: completed subtasks 5.1-5.4
- Task 5.5 (manual uvx test) remains pending
* docs(tasks): mark all tasks complete for bundled prompts resolution
- All 5 main tasks completed
- Manual uvx test confirmed working
- Spec implementation complete
* docs: improve README with numbered steps and supported AI tools table
* fix(review): address PR review feedback
- Fix README repository URLs and CLI command examples
- Fix pyproject.toml coverage exclude pattern regex
- Add explicit UTF-8 encoding to test fixtures
- Fix documentation wording (CLI interface → CLI)
* fix(writer): improve importlib.resources package anchor path
Use slash_commands module as anchor for importlib.resources instead of
spec_driven_development_mcp to provide more reliable path resolution
when finding bundled prompts directory.
- Navigate from slash_commands package to parent then to prompts dir
- Add explicit test for _find_package_prompts_dir() with importlib
- Improve comments explaining the traversal approach
This makes the package prompts discovery more robust across different
installation scenarios (wheel, editable install, etc.).1 parent 3213088 commit 31ba393
File tree
32 files changed
+6437
-752
lines changed- .github/workflows
- docs
- mcp_server
- slash_commands
- tasks
- tests
32 files changed
+6437
-752
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
62 | 63 | | |
63 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
64 | 67 | | |
65 | 68 | | |
| 69 | + | |
| 70 | + | |
66 | 71 | | |
67 | 72 | | |
68 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
18 | 41 | | |
19 | 42 | | |
20 | 43 | | |
| |||
115 | 138 | | |
116 | 139 | | |
117 | 140 | | |
118 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
119 | 146 | | |
120 | 147 | | |
121 | 148 | | |
122 | 149 | | |
123 | 150 | | |
124 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
125 | 165 | | |
126 | | - | |
| 166 | + | |
127 | 167 | | |
128 | | - | |
| 168 | + | |
129 | 169 | | |
130 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
131 | 192 | | |
132 | 193 | | |
133 | 194 | | |
| |||
141 | 202 | | |
142 | 203 | | |
143 | 204 | | |
144 | | - | |
145 | | - | |
| 205 | + | |
| 206 | + | |
146 | 207 | | |
147 | 208 | | |
148 | 209 | | |
| |||
153 | 214 | | |
154 | 215 | | |
155 | 216 | | |
| 217 | + | |
156 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
157 | 222 | | |
158 | 223 | | |
159 | 224 | | |
| |||
165 | 230 | | |
166 | 231 | | |
167 | 232 | | |
| 233 | + | |
168 | 234 | | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
169 | 238 | | |
170 | 239 | | |
| 240 | + | |
| 241 | + | |
171 | 242 | | |
172 | 243 | | |
173 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| |||
0 commit comments