Support recursive @file imports in AGENTS.md
ECA could support resolving @file references inside AGENTS.md, similar to how Claude Code handles CLAUDE.md imports. Currently, @ references may be understood by some models, but ECA does not parse and inject these files into the context.
This would allow efficient and predictable context management, ensuring files are included without relying on model inference.
Proposed behavior:
- Parse AGENTS.md for @file references.
- Slurp referenced files and include their content in context.
- Support recursive @ imports up to a safe max depth (e.g. 5).
- Work with both relative and absolute paths.
- Avoid evaluating @ inside code spans or code blocks.
I believe this is a considerably easy addition but I'm wondering if we have any side-effects or bad things that could happen including in this agents.md the file content, maybe not, WDYT @editor-code-assistant/maintainers?
I like it, I think it should work like this:
Example of GLOBAL AGENTS.md file:
Instructions for your your personality:
1) @~/AI/file1.md
2) @~/AI/file2.md
General guidelines
- Add failing tests first, then fix them
- Don't commit changes, leave it for the user to review and make commits
Example of PROJECT AGENTS.MD file:
Respect instructions here: @file3.md
- It would result in something like this:
Reference the provided codebase and user instructions for your answers; these mandatory instructions supersede all default behavior and must be strictly adhered to.
Contents of /Project/AGENTS.md (Global User Instructions):
1) @~/AI/file1.md
2) @~/AI/file2.md
General guidelines
- Add failing tests first, then fix them
- Don't commit changes, leave it for the user to review and make commits
Contents of /Users/user/AI/file1.md (Global User Instructions):
Do what Rich Hickey would do
Contents of /Users/user/AI/file2.md (Global User Instructions):
Act like na 8-year-old
Contents of /Users/user//Project/AGENTS.md (Project User Instructions):
Respect instructions here: @file3.md
Contents of /Users/user/Project/file3.md:
Be always funny!
@file4.md
Contents of /Users/user/Project/file4.md:
And be polite!
NOTE: The relevance of this information to your tasks is variable. You should only address it if it is crucial to your task completion.
Note: If a markdown file is mentioned twice, its "Contents ..." block is not added again. Then there is no risk of cyclic dependency.
That looks good, I will take a look and check if there are any other things to consider with that approach, otherwise prioritize it
Done, now we support recursive abs/relative file mentions via @ in agents.md file