|
| 1 | +# Task: Implement Support for Custom Commands (Issue #409) |
| 2 | + |
| 3 | +## Original Issue Details |
| 4 | + |
| 5 | +**Title:** Feature Request: Support for Custom Commands |
| 6 | + |
| 7 | +**Description:** |
| 8 | +Currently, Code-Forge supports built-in commands like `/new` and `/info`. This feature request proposes extending the command system to support a standardized format for custom commands that can trigger custom event handling. |
| 9 | + |
| 10 | +For example: `/dispatch-gh-issue Create an issue to update the version of tokio` would fire an event with name "gh-issue" and value "Create an issue to update the version of tokio", which could then trigger custom handling. |
| 11 | + |
| 12 | +## Implementation Plan |
| 13 | + |
| 14 | +I'll implement a feature that allows users to use custom commands with the format `/dispatch-event_name value`, which will trigger custom event handling. My implementation will: |
| 15 | + |
| 16 | +1. Extend the `Command` enum with a new `Dispatch` variant |
| 17 | +2. Add a new `dispatch` method to the API trait |
| 18 | +3. Update the command parser to recognize and properly handle dispatch commands |
| 19 | +4. Implement event validation to ensure names follow specified format |
| 20 | +5. Update the main UI to handle custom dispatch commands |
| 21 | +6. Add comprehensive test coverage |
| 22 | + |
| 23 | +## Requirements and Acceptance Criteria |
| 24 | + |
| 25 | +### Command Format |
| 26 | +- Format: `/dispatch-event_name value` |
| 27 | +- Event names must contain only alphanumeric characters, underscores, and hyphens |
| 28 | +- Values can be empty |
| 29 | +- Spaces in values will be preserved |
| 30 | + |
| 31 | +### API Changes |
| 32 | +- Add new `dispatch` method to the `API` trait |
| 33 | +- Implement proper error handling and validation |
| 34 | + |
| 35 | +### User Experience |
| 36 | +- Clear feedback on successful/failed dispatch |
| 37 | +- Proper error messages for invalid event names |
| 38 | +- Consistent behavior with other commands |
| 39 | + |
| 40 | +### Testing |
| 41 | +- Unit tests for command parsing |
| 42 | +- Unit tests for event name validation |
| 43 | +- Integration tests for the entire dispatch flow |
| 44 | + |
| 45 | +## Files to Modify |
| 46 | + |
| 47 | +1. `crates/forge_api/src/lib.rs` - Add dispatch method to API trait |
| 48 | +2. `crates/forge_api/src/api.rs` - Implement dispatch in ForgeAPI |
| 49 | +3. `crates/forge_main/src/model.rs` - Update Command enum and parsing |
| 50 | +4. `crates/forge_main/src/ui.rs` - Handle dispatch commands |
| 51 | +5. `crates/forge_domain/src/dispatch_event.rs` - Add event name validation |
| 52 | + |
| 53 | +## Implementation Progress |
| 54 | + |
| 55 | +- [ ] Add dispatch method to API trait |
| 56 | +- [ ] Implement dispatch method in ForgeAPI |
| 57 | +- [ ] Update Command enum with Dispatch variant |
| 58 | +- [ ] Add command parsing for dispatch commands |
| 59 | +- [ ] Add event name validation |
| 60 | +- [ ] Update UI to handle dispatch commands |
| 61 | +- [ ] Add tests for dispatch command functionality |
0 commit comments