Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 21, 2025

ParseSlashCommand required commands to start with / and returned errors when not found. Now it searches anywhere in the input string and returns a boolean indicating presence instead of erroring.

Changes

  • Function signature: Changed to (taskName string, params map[string]string, found bool, err error) - found boolean positioned before error and after params
  • Search behavior: Uses strings.Index() to find / anywhere in input, not just at start
  • Argument extraction: Stops at newline (\n or \r) rather than consuming entire string
  • Error semantics: found=false when no command present; errors only for malformed syntax (unclosed quotes)

Example

// Before: Required leading slash, returned error if missing
taskName, params, err := ParseSlashCommand("fix-bug")
// err: "slash command must start with '/'"

// After: Finds command anywhere, returns boolean
taskName, params, found, err := ParseSlashCommand("Please /deploy production now")
// taskName="deploy", params={"ARGUMENTS": "production now", "1": "production", "2": "now"}, found=true

_, _, found, _ := ParseSlashCommand("no command here")
// found=false, err=nil

Text before the / and after newlines is ignored as expected.

Test Coverage

Added 6 test cases covering commands embedded in text, with prefixes, and newline handling. All 26 tests pass.

Original prompt

ParseSlashCommand needs some enhancement. It should find the taskname anywhere in the string. Any argument on the same line should be included. It maybe that some prefix and suffix is lost. That is find. It needs to return a boolean if found, if not found, that is no an error.


💡 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 and others added 3 commits November 21, 2025 01:07
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] Improve ParseSlashCommand to locate task names in strings Make ParseSlashCommand find commands anywhere in string and return found boolean Nov 21, 2025
Copilot AI requested a review from alexec November 21, 2025 01:13
@alexec
Copy link
Contributor

alexec commented Nov 21, 2025

@copilot Put found before error and after params.

Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 21, 2025

@copilot Put found before error and after params.

Done. Updated the signature to (taskName string, params map[string]string, found bool, err error) in commit a79ae68.

@alexec alexec marked this pull request as ready for review November 21, 2025 01:22
@alexec alexec enabled auto-merge (squash) November 21, 2025 01:22
@alexec alexec merged commit 1f7a3fe into main Nov 21, 2025
2 checks passed
@alexec alexec deleted the copilot/enhance-parseslashcommand-function branch November 21, 2025 01: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