Skip to content

Add slash command shorthand syntax: on: /command#7146

Merged
pelikhan merged 6 commits intomainfrom
copilot/add-slash-command-syntax
Dec 21, 2025
Merged

Add slash command shorthand syntax: on: /command#7146
pelikhan merged 6 commits intomainfrom
copilot/add-slash-command-syntax

Conversation

Copy link
Contributor

Copilot AI commented Dec 21, 2025

Implementation Plan for Slash Command Shorthand Syntax

Goal: Add support for on: /command as shorthand for on: { slash_command: command, workflow_dispatch: null }

Analysis Complete

  • Understand how on: daily shorthand works
  • Identify schedule preprocessing in pkg/workflow/schedule_preprocessing.go
  • Locate slash_command handling in pkg/workflow/compiler_safe_outputs.go and pkg/workflow/frontmatter_extraction.go
  • Review schema validation in pkg/parser/schemas/main_workflow_schema.json

Implementation Tasks

  • Add slash command detection to preprocessScheduleFields in schedule_preprocessing.go
  • Handle on: /command format to convert to proper structure
  • Update JSON schema to allow slash command strings in on field
  • Add tests for the new shorthand syntax
  • Verify end-to-end compilation works
  • Update documentation to reflect new shorthand
  • Refactor parser into separate helper file with extensive tests

Refactoring (Latest Commit)

✅ Created pkg/workflow/slash_command_parser.go with dedicated helper functions
✅ Created pkg/workflow/slash_command_parser_test.go with 24 comprehensive test cases
✅ Updated schedule_preprocessing.go to use the extracted helpers
✅ All tests pass (existing + new)
✅ End-to-end compilation verified

Test Coverage Summary

  • Parse tests: 13 test cases covering valid inputs, errors, and non-slash commands
  • Expand tests: 4 test cases for map generation
  • Edge case tests: 6 test cases for special characters, unicode, multiple slashes
  • Whitespace tests: 3 test cases for leading/trailing/tab handling

Implementation complete!

Original prompt

Similarly to the "on:daily" short syntax, add support for a slash command short syntax:

on: /command

which is equivalent to

on:
slash_command: command
workflow_dispatch:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits December 21, 2025 16:41
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Implement support for the slash command shorthand syntax similar to "on: daily".
Now users can write "on: /command" which automatically expands to:
  on:
    slash_command: command
    workflow_dispatch:

Changes:
- Modified preprocessScheduleFields to detect and expand slash command shorthand
- Added comprehensive tests in TestSlashCommandShorthand
- Updated JSON schema to document the new shorthand format
- Added debug logging for troubleshooting

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
All tests pass and workflows compile successfully with the new slash command shorthand syntax.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Added documentation for the new `on: /command` shorthand format in:
- reference/triggers.md - Added ultra-short syntax section
- reference/command-triggers.md - Updated shorthand examples

The documentation explains that `on: /my-bot` automatically expands to include
slash_command and workflow_dispatch triggers, similar to `on: daily`.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
// Check if "on" is a string - might be a schedule expression shorthand
// Check if "on" is a string - might be a schedule expression or slash command shorthand
if onStr, ok := onValue.(string); ok {
schedulePreprocessingLog.Printf("Processing on field as string: %s", onStr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot move schedule parser to helper function in own file, add extensive tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored slash command parser into separate file with extensive tests in commit e2e3b8f.

Created:

  • pkg/workflow/slash_command_parser.go with parseSlashCommandShorthand() and expandSlashCommandShorthand() helper functions
  • pkg/workflow/slash_command_parser_test.go with 24 comprehensive test cases covering valid commands, errors, edge cases, and whitespace handling

All existing tests pass and end-to-end compilation verified.

Copilot AI changed the title [WIP] Add support for slash command short syntax Add slash command shorthand syntax: on: /command Dec 21, 2025
Copilot AI requested a review from pelikhan December 21, 2025 17:03
- Extracted parseSlashCommandShorthand() and expandSlashCommandShorthand() helper functions
- Created new file pkg/workflow/slash_command_parser.go for parser logic
- Added pkg/workflow/slash_command_parser_test.go with 4 test suites covering:
  - Valid commands (simple, hyphens, underscores, numbers, long names)
  - Error cases (empty command after slash)
  - Non-slash commands (regular events, schedules, cron)
  - Edge cases (single char, spaces, special chars, unicode, multiple slashes)
  - Whitespace handling (leading, trailing, tabs)
- Total of 24 test cases ensuring comprehensive coverage
- Updated schedule_preprocessing.go to use the new helper functions
- All existing tests pass, end-to-end compilation verified

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review December 21, 2025 17:22
@pelikhan pelikhan merged commit 05fa6df into main Dec 21, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/add-slash-command-syntax branch December 21, 2025 17:22
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