Skip to content

Commit c7165df

Browse files
Copilotalexec
andauthored
Select tasks by task_name frontmatter field instead of filename (#66)
* Initial plan * Implement task selection by front-matter task_name field Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> * Update documentation for task_name frontmatter selection Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> * Address code review feedback: fix selector filtering and error handling Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> * Simplify task selection logic per 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>
1 parent 10834e4 commit c7165df

3 files changed

Lines changed: 332 additions & 21 deletions

File tree

README.md

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ coding-context-cli -p jira_issue_key=PROJ-1234 fix-bug | llm -m gemini-pro
6262
```
6363

6464
This command will:
65-
1. Find the `fix-bug.md` task file.
65+
1. Find a task file with `task_name: fix-bug` in its frontmatter.
6666
2. Find all rule files in the search paths.
6767
3. Filter the rules based on selectors.
6868
4. Execute any associated bootstrap scripts.
@@ -72,7 +72,7 @@ This command will:
7272

7373
### Example Tasks
7474

75-
The `<task-name>` is the name of the task you want the agent to perform. Here are some common examples:
75+
The `<task-name>` is the value of the `task_name` field in the frontmatter of task files. Here are some common examples:
7676

7777
- `triage-bug`
7878
- `review-pull-request`
@@ -82,7 +82,7 @@ The `<task-name>` is the name of the task you want the agent to perform. Here ar
8282
- `remove-feature-flag`
8383
- `speed-up-build`
8484

85-
Each of these would have a corresponding `.md` file in a `tasks` directory (e.g., `triage-bug.md`).
85+
Each of these would have a corresponding `.md` file with `task_name` in the frontmatter (e.g., a file with `task_name: triage-bug`).
8686

8787
## How It Works
8888

@@ -91,7 +91,7 @@ The tool assembles the context in the following order:
9191
1. **Rule Files**: It searches a list of predefined locations for rule files (`.md` or `.mdc`). These locations include the current directory, ancestor directories, user's home directory, and system-wide directories.
9292
2. **Bootstrap Scripts**: For each rule file found (e.g., `my-rule.md`), it looks for an executable script named `my-rule-bootstrap`. If found, it runs the script before processing the rule file. These scripts are meant for bootstrapping the environment (e.g., installing tools) and their output is sent to `stderr`, not into the main context.
9393
3. **Filtering**: If `-s` (include) flag is used, it parses the YAML frontmatter of each rule file to decide whether to include it.
94-
4. **Task Prompt**: It finds the task prompt file (e.g., `<task-name>.md`) in one of the search paths.
94+
4. **Task Prompt**: It searches for a task file with `task_name: <task-name>` in its frontmatter. The filename doesn't matter. If selectors are provided with `-s`, they are used to filter between multiple task files with the same `task_name`.
9595
5. **Parameter Expansion**: It substitutes variables in the task prompt using the `-p` flags.
9696
6. **Output**: It prints the content of all included rule files, followed by the expanded task prompt, to standard output.
9797
7. **Token Count**: A running total of estimated tokens is printed to standard error.
@@ -101,9 +101,9 @@ The tool assembles the context in the following order:
101101
The tool looks for task and rule files in the following locations, in order of precedence:
102102

103103
**Tasks:**
104-
- `./.agents/tasks/<task-name>.md`
105-
- `~/.agents/tasks/<task-name>.md`
106-
- `/etc/agents/tasks/<task-name>.md`
104+
- `./.agents/tasks/*.md` (any `.md` file with matching `task_name` in frontmatter)
105+
- `~/.agents/tasks/*.md`
106+
- `/etc/agents/tasks/*.md`
107107

108108
**Rules:**
109109
The tool searches for a variety of files and directories, including:
@@ -118,15 +118,49 @@ The tool searches for a variety of files and directories, including:
118118

119119
### Task Files
120120

121-
Task files are Markdown files that can contain variables for substitution.
121+
Task files are Markdown files with a required `task_name` field in the frontmatter. The filename itself doesn't matter - only the `task_name` value is used for selection. Task files can contain variables for substitution and can use selectors in frontmatter to provide different prompts for the same task.
122122

123123
**Example (`.agents/tasks/fix-bug.md`):**
124124
```markdown
125+
---
126+
task_name: fix-bug
127+
---
125128
# Task: Fix Bug in ${jira_issue_key}
126129

127130
Here is the context for the bug. Please analyze the following files and provide a fix.
128131
```
129132

133+
**Example with selectors for multiple prompts (`.agents/tasks/deploy-staging.md`):**
134+
```markdown
135+
---
136+
task_name: deploy
137+
environment: staging
138+
---
139+
# Deploy to Staging
140+
141+
Deploy the application to the staging environment with extra validation.
142+
```
143+
144+
**Example for production (`.agents/tasks/deploy-prod.md`):**
145+
```markdown
146+
---
147+
task_name: deploy
148+
environment: production
149+
---
150+
# Deploy to Production
151+
152+
Deploy the application to production with all safety checks.
153+
```
154+
155+
You can then select the appropriate task using:
156+
```bash
157+
# Deploy to staging
158+
coding-context-cli -s environment=staging deploy
159+
160+
# Deploy to production
161+
coding-context-cli -s environment=production deploy
162+
```
163+
130164
### Rule Files
131165

132166
Rule files are Markdown (`.md`) or `.mdc` files, optionally with YAML frontmatter for filtering.

0 commit comments

Comments
 (0)