You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add slash command substitution to codingcontext package (#118)
* Initial plan
* Add slash command support to main package
- Move slash command parsing from pkg/slashcommand to pkg/codingcontext
- Add WithSlashCommand(bool) option to Context
- Implement slash command substitution in Run()
- Add tests for slash command functionality
- Add --slash-command flag to CLI
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Add documentation for --slash-command flag
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Add logging for parameter overrides in slash commands
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Change flag from --slash-command to -l and always reload task file
- Changed flag from --slash-command to -l for brevity
- Removed conditional check - always reload task file even if same name
- Updated documentation to reflect -l flag
- Added clarification that slash params override existing params
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Improve logging clarity for same vs different task reload
- Use "Reloading" when slash command references same task
- Use "Switching" when slash command references different task
- Makes log messages more accurate and helpful
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Remove WithSlashCommand option - slash commands always enabled
- Removed slashCommand field from Context struct
- Removed WithSlashCommand option function
- Removed -l flag from CLI
- Slash command parsing now always enabled by default
- Updated tests to remove slashCommandEnabled parameter
- Updated documentation to reflect always-on behavior
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Slash command parameters fully replace existing parameters
- Changed from merging to complete replacement of parameters
- When slash command is found, both task name and parameters are replaced
- Removed parameter override logging (no longer relevant)
- Added test case to verify complete parameter replacement
- Updated documentation to clarify full replacement behavior
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Expand parameters before checking for slash commands
- Allows slash commands in parameter values (free-text use case)
- Expand task content with parameters first, then parse for slash commands
- Added test case for slash command in parameter value
- Enables use case: free-text task with text="/fix-bug PROJ-123"
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Refactor to eliminate code duplication
- Extracted parameter expansion to expandParams helper method
- Removed duplicate my-task.md creation in tests
- Improved code maintainability
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Add clarifying comment for double parameter expansion
- Explains why parameters are expanded twice
- First for slash command detection, second for final output
- Task content may differ between expansions if slash command found
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Add test cases for slash commands with leading periods and spaces
- Tests confirm slash commands work with patterns like ". /taskname"
- Already supported by existing implementation
- Added explicit test cases for documentation and regression testing
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Merge origin/main into slash command branch
- Resolved conflicts in main.go (kept both -a and -t flags)
- Resolved conflicts in context_test.go (kept both TestSlashCommandSubstitution and TestTargetAgentIntegration)
- All tests passing
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: Alex Collins <alexec@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs/reference/cli.md
+59Lines changed: 59 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -352,6 +352,65 @@ metadata:
352
352
coding-context -s metadata.language=Go fix-bug
353
353
```
354
354
355
+
## Slash Commands
356
+
357
+
Slash command parsing is **always enabled** in task files. When a task file contains a slash command (e.g., `/task-name arg1 "arg 2"`), the CLI will automatically:
358
+
359
+
1. Extract the task name and arguments from the slash command
360
+
2. Load the referenced task instead of the original task
361
+
3. Pass the slash command arguments as parameters (`$1`, `$2`, `$ARGUMENTS`, etc.)
362
+
4.**Completely replace** any existing parameters with the slash command parameters
363
+
364
+
This enables wrapper tasks that can dynamically delegate to other tasks with arguments. The slash command fully replaces both the task name and all parameters.
Copy file name to clipboardExpand all lines: main.go
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -29,11 +29,11 @@ func main() {
29
29
varremotePaths []string
30
30
31
31
flag.StringVar(&workDir, "C", ".", "Change to directory before doing anything.")
32
-
flag.BoolVar(&resume, "r", false, "Resume mode: skip outputting rules and select task with 'resume: true' in frontmatter.")
33
-
flag.BoolVar(&emitTaskFrontmatter, "t", false, "Print task frontmatter at the beginning of output.")
34
32
flag.Var(¶ms, "p", "Parameter to substitute in the prompt. Can be specified multiple times as key=value.")
33
+
flag.BoolVar(&resume, "r", false, "Resume mode: skip outputting rules and select task with 'resume: true' in frontmatter.")
35
34
flag.Var(&includes, "s", "Include rules with matching frontmatter. Can be specified multiple times as key=value.")
36
35
flag.Var(&targetAgent, "a", "Target agent to use (excludes rules from other agents). Supported agents: cursor, opencode, copilot, claude, gemini, augment, windsurf, codex.")
36
+
flag.BoolVar(&emitTaskFrontmatter, "t", false, "Print task frontmatter at the beginning of output.")
37
37
flag.Func("d", "Remote directory containing rules and tasks. Can be specified multiple times. Supports various protocols via go-getter (http://, https://, git::, s3::, etc.).", func(sstring) error {
0 commit comments