Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 21, 2025

Move slash command code into main package ✅

Summary

Successfully implemented slash command functionality in the main codingcontext package. Slash command parsing is always enabled - no flag needed. When a task contains a slash command (even in parameter values or with leading formatting), it fully replaces both the task name and all parameters.

All Tasks Complete ✅

  • Move slash command parsing code from pkg/slashcommand to pkg/codingcontext
  • Update Context.Run() to always check for slash commands in task content
  • When slash command is found:
    • Extract task name and parameters from slash command
    • Completely replace task name and all parameters (not merge)
    • Always reload task file, even if same task name
    • Improved logging: "Reloading" vs "Switching" based on task name
  • Expand parameters before slash command check - enables slash commands in parameter values
  • Support leading periods and spaces - works with markdown formatting like . /taskname
  • Add comprehensive tests for slash command functionality
  • Refactored code to eliminate duplication
  • Added clarifying comments for code review feedback
  • Merged with main branch - resolved conflicts, compatible with agent targeting functionality
  • Run linting, building, and testing - all passing ✅
  • Update documentation to reflect full replacement behavior
  • Code review completed and all feedback addressed
  • Security scan completed - no vulnerabilities found ✅

How It Works

Basic slash command:

# wrapper.md contains: /fix-bug 123 "critical issue"
coding-context wrapper
# Switches to fix-bug task with params: $1=123, $2="critical issue"

Free-text use case (slash command in parameter value):

# free-text.md contains: ${text}
coding-context -p text="/fix-bug PROJ-123" free-text
# 1. Expands ${text} to "/fix-bug PROJ-123"
# 2. Detects slash command and switches to fix-bug task
# 3. Sets new parameters: $1=PROJ-123
# 4. Expands fix-bug task content with new parameters

Slash command with leading formatting (markdown, bullet points, etc.):

# wrapper.md contains: .   /fix-bug PROJ-456
coding-context wrapper
# Detects slash command even with leading period and spaces
# Switches to fix-bug task with $1=PROJ-456

The slash command fully replaces both the task name and ALL parameters!

Final Testing Results

✅ All unit tests passing (16 test cases including slash command and agent tests)
✅ All integration tests passing
✅ Linting passing with no errors
✅ Manual testing verified all scenarios including . /taskname patterns
✅ Code review feedback fully addressed
✅ Merged with main branch successfully
✅ Security scan - no vulnerabilities found

Backward Compatibility

The original pkg/slashcommand package remains unchanged for backward compatibility. Slash commands now work automatically with:

  • Parameter expansion support
  • Leading formatting support (periods, spaces)
  • Full task and parameter replacement
  • Compatible with new agent targeting functionality from main (both -a and -t flags coexist)
Original prompt

Move the "slash command" code into the main package. The user should be given a WithSlashCommand(bool) option. When this is provided, if the found task contains a slash command, then that should be substituted.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Nov 21, 2025
Copilot AI and others added 3 commits November 21, 2025 01:30
- 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>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copilot AI changed the title [WIP] Move slash command code to main package with option Add slash command substitution to codingcontext package Nov 21, 2025
Copilot AI requested a review from alexec November 21, 2025 01:37
@alexec
Copy link
Contributor

alexec commented Nov 21, 2025

@copilot Make it -l

- 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>
Copy link
Contributor Author

Copilot AI commented Nov 21, 2025

@copilot Make it -l

Changed to -l in commit bdee632. Also updated to always reload the task file even when the slash command references the same task name (e.g., /free-text).

- 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>
@alexec
Copy link
Contributor

alexec commented Nov 21, 2025

@copilot Remove the "WithSlackCommand" option and just default to true..

- 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>
Copy link
Contributor Author

Copilot AI commented Nov 21, 2025

@copilot Remove the "WithSlackCommand" option and just default to true..

Removed WithSlashCommand option and -l flag in commit 91d9206. Slash command parsing is now always enabled by default - no configuration needed.

- 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>
@alexec
Copy link
Contributor

alexec commented Nov 21, 2025

@copilot Try again

- 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>
Copy link
Contributor Author

Copilot AI commented Nov 21, 2025

@copilot Try again

Fixed in commit c59b07b. Now expands parameters before checking for slash commands, enabling the free-text use case where coding-context -p text="/fix-bug PROJ-123" free-text works correctly.

Copilot AI and others added 2 commits November 21, 2025 03:19
- 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>
- 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>
@alexec
Copy link
Contributor

alexec commented Nov 21, 2025

@copilot We should support

"/taskname"
". /taskname"
". /taskname
"

- 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>
Copy link
Contributor Author

Copilot AI commented Nov 21, 2025

@copilot We should support

"/taskname"...

Already supported by the existing implementation. Added explicit test cases in commit 91798f1 to document and test patterns like . /taskname, . /taskname, and with arguments.

@alexec
Copy link
Contributor

alexec commented Nov 21, 2025

@copilot What about if there are no arguments and the end of the taskname is the end of the string?

Copy link
Contributor Author

Copilot AI commented Nov 21, 2025

@copilot What about if there are no arguments and the end of the taskname is the end of the string?

Already handled correctly. When no whitespace is found after the slash (line 50-53 in slashcommand.go), the entire remaining string becomes the task name with empty params. Existing tests cover this: /fix-bug, . /taskname, and . /taskname all work correctly with no arguments.

@alexec alexec enabled auto-merge (squash) November 21, 2025 04:02
@alexec
Copy link
Contributor

alexec commented Nov 21, 2025

@copilot fetch main and resolve conflicts.

- 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>
auto-merge was automatically disabled November 21, 2025 04:12

Head branch was pushed to by a user without write access

Copy link
Contributor Author

Copilot AI commented Nov 21, 2025

@copilot fetch main and resolve conflicts.

Merged origin/main in commit 853f2bd. Resolved conflicts by keeping both -a (agent) and -t (frontmatter) flags, and both test functions. All tests passing.

Copilot AI requested a review from alexec November 21, 2025 04:14
@alexec alexec enabled auto-merge (squash) November 21, 2025 04:40
@alexec alexec merged commit 354ab52 into main Nov 21, 2025
1 check passed
@alexec alexec deleted the copilot/move-slash-command-to-main-package branch November 21, 2025 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants