[Feature] Load AGENTS.md from the user config dir and from subdirectories
Description
Load instruction files from more than one place: a user-level AGENTS.md in the nanocoder config dir, and AGENTS.md files in subdirectories of the project, in addition to the one at the project root.
Use Case
Today appendAgentsMd in source/utils/prompt-builder.ts reads exactly one file, <project root>/AGENTS.md. Two things follow from that:
- Personal preferences that apply to every project ("never use em dashes", "use pnpm", "keep commit messages to one line") have to be copied into each repo's
AGENTS.md, or left out. There is no user-level file. - In a monorepo,
packages/apiandpackages/weboften have different test commands and conventions. A single root file either gets very long (and is sent on every request, which hurts on small local models) or leaves the per-package rules out.
Proposed Solution
- If
<config dir>/AGENTS.mdexists (same placeagents.config.jsonlives, soNANOCODER_CONFIG_DIRis respected), include it first. - Keep the project root
AGENTS.mdas it is now. - For nested files, add the closest
AGENTS.mdbetween the working directory and the project root once the agent starts reading or editing files under that directory, so nothing extra is sent for packages the session never touches.
Closer files should come later in the prompt so they take precedence on conflicts. The existing tune.includeAgentsMd switch and the nano profile should turn all of this off together.
Alternatives Considered
/rememberand the memory store cover facts about a project, but not standing instructions that should apply everywhere, and they are not plain text a user can edit and version.- Telling users to symlink one file into every repo. It works but is easy to forget and does not help the monorepo case.
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] This feature aligns with the project's goals (local-first AI assistance)
Implementation Notes (optional)
The project root already comes from getProjectRoot(), so walking up from the session cwd to that root is cheap. A size cap per file, with a visible "truncated" note, would keep a large nested file from eating the context window on small models. Other agents do the same thing: Codex reads a global AGENTS.md plus one per directory level, and OpenCode also supports a global rules file next to the project one.
i would like to work one this one @addyCooks or @akramcodez could one of you assign this to me?
Thanks for your interest @Vishesh-Verma-07! You already have a few issues assigned to you, so please finish those first. Once they're done, ping me here and I'll assign this one to you.
done with previous ones. can you assign this