Skip to main content

Module context_files

Module context_files 

Source
Expand description

Layered context files: AGENT.md, USER.md, MEMORY.md.

Three questions, three files, three scopes:

FileWho writes itScopePurpose
AGENT.mdthe userglobal or per projecthow to work here: conventions, commands, gotchas
USER.mdthe userper profilewho the operator is: preferences, environment, standing rules
MEMORY.mdthe agentper profiledurable 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 Config so 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_rsa here.

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 show use, so what the CLI prints is what gets injected. plugins is what loaded: a plugin’s own skills are part of the index.
for_config_with
for_config, with the skills index narrowed to only when it is set (#509).
gather
Gather every context file for a run.
project_files
The AGENT.md files 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.