Skip to content

Conversation

@privatenumber
Copy link

Summary

  • add allow/block agent frontmatter and filtering at generation time
  • generate per-agent optional rules files and a shared AGENTS.md group optional file to keep agents in sync
  • update tests and docs for new filtering behavior

Testing

  • cargo test

Closes #25

Signed-off-by: Hiroki Osame <hiroki.osame@gmail.com>
@jonandersen
Copy link
Collaborator

@privatenumber thank you for submitting a PR for this!

I tested it out a little (there's an example folder you can play around in and run sh ai-rules.sh generate to generate the examples.

Didn't seem to work fully as expected. I tried to allow only cursor to have a rule but it ended up getting applied to AGENTS.md

We have an issue i'm not sure how to solve, several agents share AGENTS.md which is problematic if one of the rules has allowed/blocked e.g if goose has a specific rule that only applies to it, that would get added to the AGENTS.md file. I'm not sure how we can solve that, do you have any ideas?

Signed-off-by: Hiroki Osame <hiroki.osame@gmail.com>
@privatenumber
Copy link
Author

Thanks for the feedback! I pushed an update that should address both issues:

  1. Cursor-only rule appearing in AGENTS.md

    Fixed. Rules now filter correctly per agent. A rule with allowedAgents: [cursor] will only appear in Cursor's .cursor/rules/ directory, not in AGENTS.md.

  2. AGENTS.md shared file problem

    Solved by requiring rules to apply to all agents in the group. The logic:

    • AGENTS.md is shared by: amp, cline, codex, copilot, goose, kilocode, roo
    • A rule with allowedAgents: [goose] won't appear in AGENTS.md (since it doesn't apply to all 7 agents)
    • A rule with blockedAgents: [cursor] will appear in AGENTS.md (applies to all 7)

    When a rule targets a subset, a warning is emitted:

    Warning: Rule 'goose-specific' applies to a subset of AGENTS.md agents; it will be excluded from AGENTS.md.
    

Let me know if this works for your use case or if you'd like any adjustments to the behavior.

Copy link
Collaborator

@jonandersen jonandersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@privatenumber Looks good, i'm just wondering if it's better for
allowedAgents: [goose] to include it for all AGENTS.md and just give a warning instead of excluding it? Either way can work but think that would be the cleanest IMO

pub const OPTIONAL_RULES_FILENAME: &str = "ai-rules-generated-optional.md";
pub const AGENTS_MD_FILENAME: &str = "AGENTS.md";
pub const AGENTS_MD_GROUP_NAME: &str = "agents-md";
pub const AGENTS_MD_AGENTS: [&str; 7] = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we should infer this from the dynamic loading and check where they store their files.
Might be hard to remember to update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable/enable agent in front matter

2 participants