Skip to content

Commit 41623a4

Browse files
Copilotalexec
andauthored
Fix duplicate flag definition and task resolution logic (#28)
* Initial plan * Fix duplicate flag and task file finding logic Co-authored-by: alexec <1142830+alexec@users.noreply.github.com> * Update README with new flags and memory file formats 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 ad3f7cf commit 41623a4

2 files changed

Lines changed: 63 additions & 3 deletions

File tree

README.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,42 @@ coding-context [options] <task-name>
8282
8383
Options:
8484
-b Automatically run the bootstrap script after generating it
85-
-d <directory> Add a directory to include in the context (can be used multiple times)
85+
-d <directory> Directory that may contain a memories/ or tasks/ subdirectory (can be used multiple times)
8686
Default: .prompts, ~/.config/prompts, /var/local/prompts
87+
-m <path> Directory containing memories, or a single memory file (can be used multiple times)
88+
Default: AGENTS.md
89+
-t <path> Directory containing tasks, or a single task file (can be used multiple times)
8790
-o <directory> Output directory for generated files (default: .)
8891
-p <key=value> Template parameter for prompt substitution (can be used multiple times)
8992
-s <key=value> Include memories with matching frontmatter (can be used multiple times)
9093
-S <key=value> Exclude memories with matching frontmatter (can be used multiple times)
9194
```
9295

96+
**Important:** The task file name **MUST** match the task name you provide on the command line. For example, if you run `coding-context my-task`, the tool will look for `my-task.md` in the task directories.
97+
9398
**Example:**
9499
```bash
95100
coding-context -p feature="Authentication" -p language=Go add-feature
96101
```
97102

103+
**Example with directories:**
104+
```bash
105+
# Add a custom directory that contains memories/ and tasks/ subdirectories
106+
coding-context -d /path/to/custom/prompts my-task
107+
108+
# The -d flag prepends directories to search paths, so custom directories take priority
109+
# Search order becomes: /path/to/custom/prompts/memories, .prompts/memories, ~/.config/prompts/memories, ...
110+
```
111+
112+
**Example with custom memory and task paths:**
113+
```bash
114+
# Specify explicit memory files or directories
115+
coding-context -m .github/copilot-instructions.md -m CLAUDE.md my-task
116+
117+
# Specify custom task directory
118+
coding-context -t ./custom-tasks my-task
119+
```
120+
98121
**Example with selectors:**
99122
```bash
100123
# Include only production memories
@@ -131,6 +154,8 @@ Memory files are included in every generated context. They contain reusable info
131154

132155
Prompt files define specific tasks. They can use template variables (like `${taskName}` or `$taskName`) that you provide via command-line parameters.
133156

157+
**IMPORTANT:** The file name **MUST** match the task name you'll use on the command line. For example, a file named `my-task.md` is invoked with `coding-context my-task`.
158+
134159
```markdown
135160
# Task: ${taskName}
136161

@@ -183,6 +208,10 @@ Each directory should contain:
183208

184209
Markdown files with YAML frontmatter and Go template support.
185210

211+
**CRITICAL:** The prompt file name (without the `.md` extension) **MUST** exactly match the task name you provide on the command line. For example:
212+
- To run `coding-context add-feature`, you need a file named `add-feature.md`
213+
- To run `coding-context my-custom-task`, you need a file named `my-custom-task.md`
214+
186215
**Example** (`.prompts/tasks/add-feature.md`):
187216
```markdown
188217
# Task: ${feature}
@@ -195,6 +224,8 @@ Run with:
195224
coding-context -p feature="User Login" -p language=Go add-feature
196225
```
197226

227+
This will look for `add-feature.md` in the task directories.
228+
198229
### Memory Files
199230

200231
Markdown files included in every generated context. Bootstrap scripts can be provided in separate files.
@@ -218,6 +249,36 @@ npm install
218249

219250
For each memory file `<name>.md`, you can optionally create a corresponding `<name>-bootstrap` file that will be executed during setup.
220251

252+
### Supported Memory File Formats
253+
254+
This tool can work with various memory file formats used by popular AI coding assistants. By default, it looks for `AGENTS.md` in the current directory. You can also specify additional memory files or directories using the `-m` flag.
255+
256+
#### Common Memory File Names
257+
258+
The following memory file formats are commonly used by AI coding assistants and can be used with this tool:
259+
260+
- **`AGENTS.md`** - Default memory file (automatically included)
261+
- **`.github/copilot-instructions.md`** - GitHub Copilot instructions file
262+
- **`CLAUDE.md`** - Claude-specific instructions
263+
- **`.cursorrules`** - Cursor editor rules (if in Markdown format)
264+
- **`.cursor/rules/`** - Directory containing Cursor-specific rule files
265+
- **`.instructions.md`** - General instructions file
266+
- **`.continuerules`** - Continue.dev rules (if in Markdown format)
267+
268+
**Example:** Using multiple memory sources
269+
```bash
270+
# Include GitHub Copilot instructions and CLAUDE.md
271+
coding-context -m .github/copilot-instructions.md -m CLAUDE.md my-task
272+
273+
# Include all rules from Cursor directory
274+
coding-context -m .cursor/rules/ my-task
275+
276+
# Combine default AGENTS.md with additional memories
277+
coding-context -m .instructions.md my-task
278+
```
279+
280+
**Note:** All memory files should be in Markdown format (`.md` extension) or contain Markdown-compatible content. The tool will automatically process frontmatter in YAML format if present.
281+
221282

222283
## Filtering Memories with Selectors
223284

main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ func main() {
4848
"AGENTS.md",
4949
}
5050

51-
flag.Var(&dirs, "d", "Directory to include in the context. Can be specified multiple times.")
5251
flag.Var(&dirs, "d", "Directory that may contain a memories/ or tasks/ subdirectory. Can be specified multiple times.")
5352
flag.Var(&memories, "m", "Directory containing memories, or a single memory file. Can be specified multiple times.")
5453
flag.Var(&tasks, "t", "Directory containing tasks, or a single task file. Can be specified multiple times.")
@@ -184,7 +183,7 @@ func run(ctx context.Context, args []string) error {
184183
continue
185184
}
186185
if stat.IsDir() {
187-
path = filepath.Join(path, stat.Name())
186+
path = filepath.Join(path, taskName+".md")
188187
if _, err := os.Stat(path); os.IsNotExist(err) {
189188
continue
190189
}

0 commit comments

Comments
 (0)