Enhanced task parsing with participle/v2 parser#143
Conversation
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 We should not find the first slash command. Instead, we need to turn the Task into a prompt (i.e. Markdown). To do this, start with an empty prompt, iterate over each block. If the block is text then append the text to the content. If the block is a slash command, find the correct Markdown command/task file, and append the Markdown content (after expanding the parameters of course). Finally, merge the frontmatter into the task frontmatter. The resulting prompt should include all blocks, the expanded commands, and merged frontmatter. |
- Iterate over all blocks in the parsed task - For text blocks: append content directly - For slash command blocks: find task file, expand params, merge frontmatter - Assemble composite task with merged frontmatter from all slash commands - Parameters from slash commands are cumulative across blocks Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Done in ccaa967. The task processor now:
Example: Results in a composite task with:
|
- Created extractSelectors() helper to avoid code duplication - Used in both block processing and parseTaskFile() - Reduces maintenance burden and ensures consistency Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
|
@copilot lets add a |
- Added Params() method to SlashCommand type that returns parameter map - Moved parameter extraction logic to task_parser.go (closer to the type) - Changed frontmatter handling to use only the first task's frontmatter - Removed mergeFrontmatter() function (no longer needed) - Removed duplicate extractParamsFromCommand and stripQuotes functions Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Done in 8c7e925. Added
Also addressed the new requirement: composite tasks now use only the first slash command's frontmatter (not merged). |
|
@copilot Please revert all changes to context.go. Don't worry about compliation of failing tests. |
Reverted context.go to its original state before implementing composite task support. The file now uses the original parseSlashCommand function instead of ParseTask. Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
- Introduced comprehensive tests for the Context struct, covering various scenarios including default initialization, parameter handling, selector filtering, and command execution. - Implemented helper functions for creating tasks, rules, and commands within test cases. - Validated task execution with different configurations and ensured proper error handling for invalid commands and agents. This commit enhances test coverage and ensures the reliability of the coding context features.
- Updated integration tests to remove leading slashes from task names in `runTool` calls, ensuring consistency in task execution. - Modified the `Context` struct to include a new field for `downloadedPaths`, enhancing the management of remote directories. - Simplified the parsing of markdown files by removing unnecessary type parameters in `ParseMarkdownFile` calls. - Removed obsolete mock functions and streamlined test cases for better clarity and maintainability. These changes improve the reliability and readability of the codebase while ensuring that task execution aligns with the expected behavior.
|
@copilot update this PR with a clear and concise description. |
Updated PR description to be clear and concise. The new description focuses on:
All tests pass. The implementation follows the EBNF grammar from the issue and properly separates concerns between file discovery, parsing, and parameter substitution. |
There was a problem hiding this comment.
Pull request overview
This PR implements a new task parser using participle/v2 to distinguish between tasks and commands. Tasks are now composed of blocks (text or slash commands), where slash commands reference separate command files. The old slash command parsing logic has been removed and replaced with a grammar-based parser that properly handles command arguments.
Key changes:
- New task parser with Block, SlashCommand, and Text types using participle/v2
- Separation of tasks (
.agents/tasks) and commands (.agents/commands,.cursor/commands, etc.) - Removal of old
slashcommand.goand its tests - Updated API with
findTaskandfindCommandfunctions
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/codingcontext/task_parser.go | New grammar-based parser implementation with comprehensive block/command/text parsing |
| pkg/codingcontext/task_parser_test.go | Table-driven tests for parser (follows project standards) |
| pkg/codingcontext/context.go | Refactored to use new parser with findTask and findCommand functions |
| pkg/codingcontext/context_test.go | Simplified integration tests using helper functions |
| pkg/codingcontext/paths.go | Separated task and command search paths |
| pkg/codingcontext/command_frontmatter.go | Placeholder struct for command frontmatter consistency |
| pkg/codingcontext/free_text_task.go | Constants for free-text task handling |
| main.go | Updated usage documentation to reflect task-name instead of task-prompt |
| integration_test.go | Updated all integration tests to use task names without / prefix |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
All code review feedback has been addressed in commit 6066a7d:
The implementation properly separates tasks and commands with distinct search paths and uses the participle/v2 grammar parser as specified. |
- Updated the findTask method to capture and return errors from visitMarkdownFiles, improving error reporting when a task cannot be found. - This change ensures that any issues encountered during the search for tasks are properly communicated, enhancing the robustness of the code.
|
@copilot continue. |
- Changed "task_not_found_returns_empty_task" to "task_not_found_returns_error" - Changed "empty_task_content" to "empty_task_content_returns_error" - Both tests now expect wantErr=true and check for "task not found" in error message - All tests now pass (including linter checks) This completes the breaking change where missing tasks return errors instead of empty tasks. Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Completed all remaining work in 9a27cfc: ✅ Updated 2 failing tests to expect errors for missing/empty tasks The PR is now complete and ready for merge. The enhanced task parser with participle/v2 is fully implemented, tested, and code reviewed. |
Summary
✅ Complete implementation of enhanced task parsing with participle/v2
✅ All tests passing (including updated tests for error handling)
✅ Linter clean - no issues
✅ Code review feedback addressed - all suggestions implemented
Breaking Changes
Architecture
.agents/tasks) vs Commands (command directories)findTask(),findCommand(),expandParams()with clear responsibilitiesOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.