-
Notifications
You must be signed in to change notification settings - Fork 1
Add centralized agent path configuration and simplify path handling #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
93c6ba5
Initial plan
Copilot 2316416
Add AgentPaths type and configuration map
Copilot 951d954
Refactor AgentsPaths to use method-based API with private map
Copilot 64500a5
Refactor path functions to use AgentsPaths configuration
Copilot 8788f5a
Simplify path functions to use same paths for all directories
Copilot 72a163e
Merge branch 'main' of https://github.com/kitproj/coding-context-cli …
Copilot 638709b
Simplify AgentsPaths to use map directly without wrapper struct
Copilot a5943c7
Make agentPathsConfig fields private
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package codingcontext | ||
|
|
||
| // agentPathsConfig describes the search paths for a specific agent. | ||
| // This is the internal configuration structure used by the agentsPaths map. | ||
| type agentPathsConfig struct { | ||
| rulesPaths []string // Paths to search for rule files | ||
| skillsPath string // Path to search for skill directories | ||
| commandsPath string // Path to search for command files | ||
| tasksPath string // Path to search for task files | ||
| } | ||
|
|
||
| // agentsPaths maps each agent to its specific search paths. | ||
| // Empty string agent ("") represents the generic .agents directory structure. | ||
| // If a path is empty, it is not defined for that agent. | ||
| var agentsPaths = map[Agent]agentPathsConfig{ | ||
alexec marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Generic .agents directory structure (empty agent name) | ||
| Agent(""): { | ||
| rulesPaths: []string{".agents/rules"}, | ||
| skillsPath: ".agents/skills", | ||
| commandsPath: ".agents/commands", | ||
| tasksPath: ".agents/tasks", | ||
| }, | ||
| // Cursor agent paths | ||
| AgentCursor: { | ||
| rulesPaths: []string{".cursor/rules", ".cursorrules"}, | ||
| skillsPath: ".cursor/skills", | ||
| commandsPath: ".cursor/commands", | ||
| // No tasks path defined for Cursor | ||
| }, | ||
| // OpenCode agent paths | ||
| AgentOpenCode: { | ||
| rulesPaths: []string{".opencode/agent", ".opencode/rules"}, | ||
| commandsPath: ".opencode/command", | ||
| // No skills or tasks paths defined for OpenCode | ||
| }, | ||
| // Copilot agent paths | ||
| AgentCopilot: { | ||
| rulesPaths: []string{".github/copilot-instructions.md", ".github/agents"}, | ||
| // No skills, commands, or tasks paths defined for Copilot | ||
| }, | ||
| // Claude agent paths | ||
| AgentClaude: { | ||
| rulesPaths: []string{".claude", "CLAUDE.md", "CLAUDE.local.md"}, | ||
| // No skills, commands, or tasks paths defined for Claude | ||
| }, | ||
| // Gemini agent paths | ||
| AgentGemini: { | ||
| rulesPaths: []string{".gemini/styleguide.md", ".gemini", "GEMINI.md"}, | ||
| // No skills, commands, or tasks paths defined for Gemini | ||
| }, | ||
| // Augment agent paths | ||
| AgentAugment: { | ||
| rulesPaths: []string{".augment/rules", ".augment/guidelines.md"}, | ||
| // No skills, commands, or tasks paths defined for Augment | ||
| }, | ||
| // Windsurf agent paths | ||
| AgentWindsurf: { | ||
| rulesPaths: []string{".windsurf/rules", ".windsurfrules"}, | ||
| // No skills, commands, or tasks paths defined for Windsurf | ||
| }, | ||
| // Codex agent paths | ||
| AgentCodex: { | ||
| rulesPaths: []string{".codex", "AGENTS.md"}, | ||
| // No skills, commands, or tasks paths defined for Codex | ||
| }, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| package codingcontext | ||
|
|
||
| import ( | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestAgentPaths_Structure(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| agent Agent | ||
| }{ | ||
| { | ||
| name: "empty agent (generic .agents)", | ||
| agent: Agent(""), | ||
| }, | ||
| { | ||
| name: "cursor agent", | ||
| agent: AgentCursor, | ||
| }, | ||
| { | ||
| name: "opencode agent", | ||
| agent: AgentOpenCode, | ||
| }, | ||
| { | ||
| name: "copilot agent", | ||
| agent: AgentCopilot, | ||
| }, | ||
| { | ||
| name: "claude agent", | ||
| agent: AgentClaude, | ||
| }, | ||
| { | ||
| name: "gemini agent", | ||
| agent: AgentGemini, | ||
| }, | ||
| { | ||
| name: "augment agent", | ||
| agent: AgentAugment, | ||
| }, | ||
| { | ||
| name: "windsurf agent", | ||
| agent: AgentWindsurf, | ||
| }, | ||
| { | ||
| name: "codex agent", | ||
| agent: AgentCodex, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| paths, exists := agentsPaths[tt.agent] | ||
| if !exists { | ||
| t.Errorf("Agent %q not found in agentsPaths", tt.agent) | ||
| return | ||
| } | ||
|
|
||
| // Check that at least one path is defined | ||
| hasAnyPath := len(paths.rulesPaths) > 0 || | ||
| paths.skillsPath != "" || | ||
| paths.commandsPath != "" || | ||
| paths.tasksPath != "" | ||
|
|
||
| if !hasAnyPath { | ||
| t.Errorf("Agent %q has no paths defined", tt.agent) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestAgentPaths_EmptyAgentHasAllPaths(t *testing.T) { | ||
| paths, exists := agentsPaths[Agent("")] | ||
| if !exists { | ||
| t.Fatal("Empty agent not found in agentsPaths") | ||
| } | ||
|
|
||
| if len(paths.rulesPaths) == 0 { | ||
| t.Error("Empty agent should have rulesPaths defined") | ||
| } | ||
| if paths.skillsPath == "" { | ||
| t.Error("Empty agent should have skillsPath defined") | ||
| } | ||
| if paths.commandsPath == "" { | ||
| t.Error("Empty agent should have commandsPath defined") | ||
| } | ||
| if paths.tasksPath == "" { | ||
| t.Error("Empty agent should have tasksPath defined") | ||
| } | ||
| } | ||
|
|
||
| func TestAgentPaths_RulesPathsNotEmpty(t *testing.T) { | ||
| // Every agent should have at least one rules path | ||
| for agent, paths := range agentsPaths { | ||
| if len(paths.rulesPaths) == 0 { | ||
| t.Errorf("Agent %q should have at least one rulesPaths entry", agent) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestAgentPaths_NoAbsolutePaths(t *testing.T) { | ||
| // All paths should be relative (not absolute) | ||
| for agent, paths := range agentsPaths { | ||
| for _, rulePath := range paths.rulesPaths { | ||
| if len(rulePath) > 0 && rulePath[0] == '/' { | ||
| t.Errorf("Agent %q rulesPaths contains absolute path: %q", agent, rulePath) | ||
| } | ||
| } | ||
| if len(paths.skillsPath) > 0 && paths.skillsPath[0] == '/' { | ||
| t.Errorf("Agent %q skillsPath is absolute: %q", agent, paths.skillsPath) | ||
| } | ||
| if len(paths.commandsPath) > 0 && paths.commandsPath[0] == '/' { | ||
| t.Errorf("Agent %q commandsPath is absolute: %q", agent, paths.commandsPath) | ||
| } | ||
| if len(paths.tasksPath) > 0 && paths.tasksPath[0] == '/' { | ||
| t.Errorf("Agent %q tasksPath is absolute: %q", agent, paths.tasksPath) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func TestAgentPaths_Count(t *testing.T) { | ||
| // Should have 9 entries: 1 empty agent + 8 named agents | ||
| expectedCount := 9 | ||
| if len(agentsPaths) != expectedCount { | ||
| t.Errorf("agentsPaths should have %d entries, got %d", expectedCount, len(agentsPaths)) | ||
| } | ||
| } | ||
|
|
||
| func TestAgent_Paths(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| agent Agent | ||
| wantRulesPaths []string | ||
| wantSkillsPath string | ||
| }{ | ||
| { | ||
| name: "cursor agent", | ||
| agent: AgentCursor, | ||
| wantRulesPaths: []string{".cursor/rules", ".cursorrules"}, | ||
| wantSkillsPath: ".cursor/skills", | ||
| }, | ||
| { | ||
| name: "empty agent", | ||
| agent: Agent(""), | ||
| wantRulesPaths: []string{".agents/rules"}, | ||
| wantSkillsPath: ".agents/skills", | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| paths, exists := agentsPaths[tt.agent] | ||
| if !exists { | ||
| t.Fatalf("Agent %q not found in agentsPaths", tt.agent) | ||
| } | ||
|
|
||
| gotRulesPaths := paths.rulesPaths | ||
| if len(gotRulesPaths) != len(tt.wantRulesPaths) { | ||
| t.Errorf("rulesPaths length = %d, want %d", len(gotRulesPaths), len(tt.wantRulesPaths)) | ||
| } | ||
| for i, want := range tt.wantRulesPaths { | ||
| if i < len(gotRulesPaths) && gotRulesPaths[i] != want { | ||
| t.Errorf("rulesPaths[%d] = %q, want %q", i, gotRulesPaths[i], want) | ||
| } | ||
| } | ||
|
|
||
| if got := paths.skillsPath; got != tt.wantSkillsPath { | ||
| t.Errorf("skillsPath = %q, want %q", got, tt.wantSkillsPath) | ||
| } | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.