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 selector support to command frontmatter (#168)
* Initial plan
* Add support for command frontmatter selectors
- Added Selectors field to CommandFrontMatter struct
- Updated findCommand to extract and merge command selectors with task selectors
- Added table-driven tests for command selectors functionality
- Created example command file with selectors
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Update documentation for command selectors feature
- Added documentation for selectors field in command frontmatter
- Explained how command selectors combine with task selectors
- Provided examples of using command selectors
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
* Refactor selector merging to reduce code duplication
- Extracted mergeSelectors helper function
- Updated task and command selector handling to use the helper
- Addresses code review feedback
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>
This is useful when commands contain template syntax that should be preserved.
470
470
471
+
#### `selectors` (optional)
472
+
473
+
**Type:** Map of key-value pairs
474
+
**Purpose:** Specifies selectors that filter which rules are included when this command is used. Command selectors are combined with task selectors and CLI selectors using OR logic.
475
+
476
+
When a task uses a command that has selectors, those selectors are merged with the task's selectors to filter rules. This allows commands to specify which rules they need (e.g., database-specific rules, authentication rules, etc.).
477
+
478
+
**Example:**
479
+
```yaml
480
+
---
481
+
selectors:
482
+
database: postgres
483
+
feature: auth
484
+
---
485
+
486
+
# Database Setup Instructions
487
+
488
+
This command provides database setup instructions.
489
+
```
490
+
491
+
**Usage in a task:**
492
+
```yaml
493
+
---
494
+
selectors:
495
+
env: production
496
+
---
497
+
498
+
Deploy to production environment.
499
+
500
+
/setup-database
501
+
```
502
+
503
+
When this task runs:
504
+
- Rules with `env: production` will be included (from task selector)
505
+
- Rules with `database: postgres` will be included (from command selector)
506
+
- Rules with `feature: auth` will be included (from command selector)
507
+
- Rules that match any of these selectors will be included (OR logic)
508
+
509
+
This allows commands to declare their dependencies on specific rules without requiring every task to manually specify them.
510
+
471
511
### Slash Command Syntax
472
512
473
513
Commands are referenced from tasks using slash command syntax:
0 commit comments