Skip to content

Commit 81dac4d

Browse files
Copilotalexec
andauthored
Remove -d flag and set comprehensive defaults for -m and -t (#29)
* Initial plan * Remove dirs flag and set suitable defaults for memories and tasks 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 41623a4 commit 81dac4d

3 files changed

Lines changed: 33 additions & 42 deletions

File tree

README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@ coding-context [options] <task-name>
8282
8383
Options:
8484
-b Automatically run the bootstrap script after generating it
85-
-d <directory> Directory that may contain a memories/ or tasks/ subdirectory (can be used multiple times)
86-
Default: .prompts, ~/.config/prompts, /var/local/prompts
8785
-m <path> Directory containing memories, or a single memory file (can be used multiple times)
88-
Default: AGENTS.md
86+
Defaults: AGENTS.md, .github/copilot-instructions.md, CLAUDE.md, .cursorrules,
87+
.cursor/rules/, .instructions.md, .continuerules, .prompts/memories,
88+
~/.config/prompts/memories, /var/local/prompts/memories
8989
-t <path> Directory containing tasks, or a single task file (can be used multiple times)
90+
Defaults: .prompts/tasks, ~/.config/prompts/tasks, /var/local/prompts/tasks
9091
-o <directory> Output directory for generated files (default: .)
9192
-p <key=value> Template parameter for prompt substitution (can be used multiple times)
9293
-s <key=value> Include memories with matching frontmatter (can be used multiple times)
@@ -100,15 +101,6 @@ Options:
100101
coding-context -p feature="Authentication" -p language=Go add-feature
101102
```
102103

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-
112104
**Example with custom memory and task paths:**
113105
```bash
114106
# Specify explicit memory files or directories

integration_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Please help with this task.
6666
}
6767

6868
// Run the binary
69-
cmd = exec.Command(binaryPath, "-d", contextDir, "-o", outputDir, "test-task")
69+
cmd = exec.Command(binaryPath, "-m", memoriesDir, "-t", tasksDir, "-o", outputDir, "test-task")
7070
cmd.Dir = tmpDir
7171
if output, err := cmd.CombinedOutput(); err != nil {
7272
t.Fatalf("failed to run binary: %v\n%s", err, output)
@@ -158,7 +158,7 @@ echo "Setting up Jira"
158158
}
159159

160160
// Run the binary
161-
cmd = exec.Command(binaryPath, "-d", contextDir, "-o", outputDir, "test-task")
161+
cmd = exec.Command(binaryPath, "-m", memoriesDir, "-t", tasksDir, "-o", outputDir, "test-task")
162162
cmd.Dir = tmpDir
163163
if output, err := cmd.CombinedOutput(); err != nil {
164164
t.Fatalf("failed to run binary: %v\n%s", err, output)
@@ -243,7 +243,7 @@ Please help with this task.
243243
}
244244

245245
// Run the binary
246-
cmd = exec.Command(binaryPath, "-d", contextDir, "-o", outputDir, "test-task")
246+
cmd = exec.Command(binaryPath, "-m", memoriesDir, "-t", tasksDir, "-o", outputDir, "test-task")
247247
cmd.Dir = tmpDir
248248
if output, err := cmd.CombinedOutput(); err != nil {
249249
t.Fatalf("failed to run binary: %v\n%s", err, output)
@@ -310,7 +310,7 @@ func TestMultipleBootstrapFiles(t *testing.T) {
310310
}
311311

312312
// Run the binary
313-
cmd = exec.Command(binaryPath, "-d", contextDir, "-o", outputDir, "test-task")
313+
cmd = exec.Command(binaryPath, "-m", memoriesDir, "-t", tasksDir, "-o", outputDir, "test-task")
314314
cmd.Dir = tmpDir
315315
if output, err := cmd.CombinedOutput(); err != nil {
316316
t.Fatalf("failed to run binary: %v\n%s", err, output)
@@ -370,7 +370,7 @@ func TestSelectorFiltering(t *testing.T) {
370370
}
371371

372372
// Test 1: Include by env=production
373-
cmd = exec.Command(binaryPath, "-d", contextDir, "-o", outputDir, "-s", "env=production", "test-task")
373+
cmd = exec.Command(binaryPath, "-m", memoriesDir, "-t", tasksDir, "-o", outputDir, "-s", "env=production", "test-task")
374374
cmd.Dir = tmpDir
375375
if output, err := cmd.CombinedOutput(); err != nil {
376376
t.Fatalf("failed to run binary: %v\n%s", err, output)
@@ -400,7 +400,7 @@ func TestSelectorFiltering(t *testing.T) {
400400
os.RemoveAll(outputDir)
401401

402402
// Test 2: Include by language=go (should include prod and test, and nofm)
403-
cmd = exec.Command(binaryPath, "-d", contextDir, "-o", outputDir, "-s", "language=go", "test-task")
403+
cmd = exec.Command(binaryPath, "-m", memoriesDir, "-t", tasksDir, "-o", outputDir, "-s", "language=go", "test-task")
404404
cmd.Dir = tmpDir
405405
if output, err := cmd.CombinedOutput(); err != nil {
406406
t.Fatalf("failed to run binary: %v\n%s", err, output)
@@ -428,7 +428,7 @@ func TestSelectorFiltering(t *testing.T) {
428428
os.RemoveAll(outputDir)
429429

430430
// Test 3: Exclude by env=production (should include dev and test, and nofm)
431-
cmd = exec.Command(binaryPath, "-d", contextDir, "-o", outputDir, "-S", "env=production", "test-task")
431+
cmd = exec.Command(binaryPath, "-m", memoriesDir, "-t", tasksDir, "-o", outputDir, "-S", "env=production", "test-task")
432432
cmd.Dir = tmpDir
433433
if output, err := cmd.CombinedOutput(); err != nil {
434434
t.Fatalf("failed to run binary: %v\n%s", err, output)
@@ -456,7 +456,7 @@ func TestSelectorFiltering(t *testing.T) {
456456
os.RemoveAll(outputDir)
457457

458458
// Test 4: Multiple includes env=production language=go (should include only prod and nofm)
459-
cmd = exec.Command(binaryPath, "-d", contextDir, "-o", outputDir, "-s", "env=production", "-s", "language=go", "test-task")
459+
cmd = exec.Command(binaryPath, "-m", memoriesDir, "-t", tasksDir, "-o", outputDir, "-s", "env=production", "-s", "language=go", "test-task")
460460
cmd.Dir = tmpDir
461461
if output, err := cmd.CombinedOutput(); err != nil {
462462
t.Fatalf("failed to run binary: %v\n%s", err, output)
@@ -484,7 +484,7 @@ func TestSelectorFiltering(t *testing.T) {
484484
os.RemoveAll(outputDir)
485485

486486
// Test 5: Mix of include and exclude -s env=production -S language=python (should include only prod with go)
487-
cmd = exec.Command(binaryPath, "-d", contextDir, "-o", outputDir, "-s", "env=production", "-S", "language=python", "test-task")
487+
cmd = exec.Command(binaryPath, "-m", memoriesDir, "-t", tasksDir, "-o", outputDir, "-s", "env=production", "-S", "language=python", "test-task")
488488
cmd.Dir = tmpDir
489489
if output, err := cmd.CombinedOutput(); err != nil {
490490
t.Fatalf("failed to run binary: %v\n%s", err, output)
@@ -543,7 +543,7 @@ The project is for $company.
543543

544544
// Run the binary with parameters
545545
cmd = exec.Command(binaryPath,
546-
"-d", contextDir,
546+
"-t", tasksDir,
547547
"-o", outputDir,
548548
"-p", "taskName=AddAuth",
549549
"-p", "feature=Authentication",
@@ -608,7 +608,7 @@ Missing var: ${missingVar}
608608

609609
// Run the binary with only one parameter
610610
cmd = exec.Command(binaryPath,
611-
"-d", contextDir,
611+
"-t", tasksDir,
612612
"-o", outputDir,
613613
"-p", "providedVar=ProvidedValue",
614614
"test-missing")
@@ -694,7 +694,7 @@ t.Fatalf("failed to write prompt file: %v", err)
694694
}
695695

696696
// Run the binary WITH the -b flag
697-
cmd = exec.Command(binaryPath, "-d", contextDir, "-o", outputDir, "-b", "test-task")
697+
cmd = exec.Command(binaryPath, "-m", memoriesDir, "-t", tasksDir, "-o", outputDir, "-b", "test-task")
698698
cmd.Dir = tmpDir
699699
if output, err := cmd.CombinedOutput(); err != nil {
700700
t.Fatalf("failed to run binary: %v\n%s", err, output)
@@ -773,7 +773,7 @@ t.Fatalf("failed to write prompt file: %v", err)
773773
}
774774

775775
// Run the binary WITHOUT the -b flag
776-
cmd = exec.Command(binaryPath, "-d", contextDir, "-o", outputDir, "test-task")
776+
cmd = exec.Command(binaryPath, "-m", memoriesDir, "-t", tasksDir, "-o", outputDir, "test-task")
777777
cmd.Dir = tmpDir
778778
if output, err := cmd.CombinedOutput(); err != nil {
779779
t.Fatalf("failed to run binary: %v\n%s", err, output)
@@ -842,7 +842,7 @@ t.Fatalf("failed to write prompt file: %v", err)
842842
}
843843

844844
// Run the binary WITH the -b flag and send interrupt signal
845-
cmd = exec.Command(binaryPath, "-d", contextDir, "-o", outputDir, "-b", "test-task")
845+
cmd = exec.Command(binaryPath, "-m", memoriesDir, "-t", tasksDir, "-o", outputDir, "-b", "test-task")
846846
cmd.Dir = tmpDir
847847

848848
// Start the command

main.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
var bootstrap string
1919

2020
var (
21-
dirs stringSlice
2221
memories stringSlice
2322
tasks stringSlice
2423
outputDir = "."
@@ -38,17 +37,25 @@ func main() {
3837
os.Exit(1)
3938
}
4039

41-
dirs = []string{
42-
".prompts",
43-
filepath.Join(userConfigDir, "prompts"),
44-
"/var/local/prompts",
45-
}
46-
4740
memories = []string{
4841
"AGENTS.md",
42+
".github/copilot-instructions.md",
43+
"CLAUDE.md",
44+
".cursorrules",
45+
".cursor/rules/",
46+
".instructions.md",
47+
".continuerules",
48+
".prompts/memories",
49+
filepath.Join(userConfigDir, "prompts", "memories"),
50+
"/var/local/prompts/memories",
51+
}
52+
53+
tasks = []string{
54+
".prompts/tasks",
55+
filepath.Join(userConfigDir, "prompts", "tasks"),
56+
"/var/local/prompts/tasks",
4957
}
5058

51-
flag.Var(&dirs, "d", "Directory that may contain a memories/ or tasks/ subdirectory. Can be specified multiple times.")
5259
flag.Var(&memories, "m", "Directory containing memories, or a single memory file. Can be specified multiple times.")
5360
flag.Var(&tasks, "t", "Directory containing tasks, or a single task file. Can be specified multiple times.")
5461
flag.StringVar(&outputDir, "o", ".", "Directory to write the context files to.")
@@ -95,14 +102,6 @@ func run(ctx context.Context, args []string) error {
95102
}
96103
defer output.Close()
97104

98-
for _, dir := range dirs {
99-
// insert the dirs into the start of the list
100-
memory := filepath.Join(dir, "memories")
101-
memories = append([]string{memory}, memories...)
102-
task := filepath.Join(dir, "tasks")
103-
tasks = append([]string{task}, tasks...)
104-
}
105-
106105
for _, memory := range memories {
107106

108107
// Skip if the file doesn't exist

0 commit comments

Comments
 (0)