-
Notifications
You must be signed in to change notification settings - Fork 1
Add -a flag to specify target agent (excludes target agent's own paths) #116
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
Conversation
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
|
@copilot lets have a type for the agent
Don't call in "WithExclude", instead "WithAgent". |
…hExcludes to WithAgent Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Done! Refactored to use a typed |
…ally from agentPathPatterns Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
|
@copilot Use "-a" rather than "-x" |
pkg/codingcontext/agent.go
Outdated
|
|
||
| // ParseAgent parses a string into an Agent type | ||
| func ParseAgent(s string) (Agent, error) { | ||
| normalized := Agent(strings.ToLower(strings.TrimSpace(s))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Don't be case-insensitive, don't trim spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed case-insensitive normalization and trimming from ParseAgent. See commit 7566314.
|
@copilot it is probably worthwhile noting that you exclude the rules, because you are going to use that agent. The agent name should automatically be added as a "selector". Lets not call in "exclude", "target agent". |
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
…dex patterns Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Refactored from "exclude" to "target agent" concept. When you specify |
|
@copilot sorry - the target is the agent you plan to use the rules with. The result should exclude rules for that agent based on path, but include generic rules based on frontmatter selector. |
…les with selectors Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Fixed! Now when you specify a target agent (e.g., |
|
@copilot Sorry, I meant all rules that that agent itself would use, e.g. "cursor" should not include ".cursorrules" but should include opencode and .agents. |
…ric rules Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
Fixed! Now |
|
@copilot TargetAgent to string, empty string means no agent specified |
Co-authored-by: alexec <1142830+alexec@users.noreply.github.com>
|
@copilot Try again |
Done! TargetAgent is now a simple string type where an empty string means no agent is specified. See commit b6c2ca3. The type now works as:
|

When using a specific AI coding agent, the agent itself reads its own configuration files. This adds a target agent feature to reduce context size and token usage by excluding the target agent's own paths while including rules from other agents and generic rules. Uses a typed Agent enum for better type safety and maintainability.
Changes
New
-aflagcursor,opencode,copilot,claude,gemini,augment,windsurf,codexImplementation
pkg/codingcontext/agent.go: TypedAgentenum with constants (AgentCursor,AgentOpenCode, etc.) for type safetyParseAgent()function validates input (case-sensitive, no trimming) and provides helpful error messagesagentPathPatternsmap defines path patterns for each agent (.cursor/,.opencode/agent,AGENTS.mdfor codex, etc.)TargetAgenttype is a simple string type (empty string means no agent specified)pkg/codingcontext/context.go: UsesWithAgent()option to configure target agent; filters paths infindExecuteRuleFiles()andruleFileWalker()to exclude only the target agent's own pathsagent: cursorin frontmatter.agents/rulespaths are never excludedAllAgents()and error messages dynamically generated fromagentPathPatternsmap for easier maintenanceHow it works:
When you specify
-a cursor:.cursor/,.cursorrules) - Cursor reads these itself.opencode/,.github/copilot-instructions.md, etc.).agents/rules/are includedagent: cursor)agent: cursorin frontmatter to be cursor-specificTests
Example
Token reduction: 18-61% depending on agent-specific rule density.
Benefits
agentPathPatternsmapAllAgents()provides programmatic access to supported agentsTargetAgentis a string type where empty string means no agent specifiedOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.