Expand description
Layered context files: AGENT.md, USER.md, MEMORY.md.
Three questions, three files, three scopes:
| File | Who writes it | Scope | Purpose |
|---|---|---|---|
AGENT.md | the user | global or per project | how to work here: conventions, commands, gotchas |
USER.md | the user | per profile | who the operator is: preferences, environment, standing rules |
MEMORY.md | the agent | per profile | durable facts it learned; §-separated, budgeted |
A fourth layer, the skills index, comes after them. It is not a file and has its own budget
([skills] index_budget_chars), so it neither counts against the file budget nor is dropped by
it; see crate::skills.
Everything here is pure: paths in, labelled text out. Nothing is written by this module
except through crate::memory, which owns MEMORY.md’s budget and lock.
Structs§
- Budget
- Context
- Everything gathered for one run, already in injection order.
- Editable
- One of the three files, as the dashboard’s editor needs it: where it is, what is in it, what the prompt will do with it, and the budget it is measured against.
- Layer
- One context file as it will be injected.
- Sources
- Where the files may be found. Separate from
Configso the discovery rules can be tested without a config file on disk.
Enums§
- Which
- Which of the three files a request means. A fixed set, never a path: the dashboard cannot ask
for a file the loader would not inject, and there is no way to spell
../../.ssh/id_rsahere.
Constants§
- DEFAULT_
BUDGET_ CHARS - Ceiling across all the file layers, in characters.
- DEFAULT_
MAX_ FILE_ CHARS - Per-file ceiling before truncation, in characters.
Functions§
- assemble
- The system prompt: the configured base, then the instruction files, then plugin prompt fragments, then the user model, then memory, then the skills index.
- editable
- The three files, resolved by the loader’s own discovery, with what the prompt does with them.
- for_
config - Gather the context files and the skills index this configuration describes — the one entry
point both the runtime and
eclipse context showuse, so what the CLI prints is what gets injected.pluginsis what loaded: a plugin’s own skills are part of the index. - for_
config_ with for_config, with the skills index narrowed toonlywhen it is set (#509).- gather
- Gather every context file for a run.
- project_
files - The
AGENT.mdfiles between the workspace and its repository root (or$HOME), outermost first so the nearest one can override. - project_
walk project_files, plus the directory the walk stopped at.- write_
file - Write one of the three, then answer with the file as it now stands.