Expand description
Data directory path abstraction.
ConfigPaths provides a single source of truth for all persistent
directories used by the AGENT: a flat cross-scene global root
(conventionally ~/.agix/), a scene-specific override root nested
under it (<global>/scenes/<scope>/), and a local/project root
(<cwd>/<project dir>/, .agix unless the instance’s Layout names
another). The names themselves are in layout.
The roots are given, never discovered. Nothing in this module reads
the environment: the process entry point decides which directory the
instance owns and passes it down. ~/.agix is what that entry point
usually picks, not something the library assumes — which is what lets a
test, a service account, or a deployment with its state elsewhere work
without every module having to agree separately.
scope identifies which product built on this engine owns the
scene-specific override state (e.g. a coding-agent product might use
"code"). The engine never assumes a default — callers must pass one
explicitly. The local/project root is flat and has no scope segment: a
project is assumed to be worked on by one product instance at a time, so
there’s no collision to avoid the way there is under a shared $HOME.
The user-level tree is split by resource type:
- Global + scene override (config-shaped, keyed by name):
settings.json,skills/,plugins/,agents/,rules/,hooks/. Present at both~/.agix/<resource>/(base) and~/.agix/scenes/<scope>/<resource>/(override) — a scene-specific entry with the same name wins. - Global + project only, no scene tier (history/state-shaped):
memory/,sessions/,recordings/. Present at~/.agix/<resource>/and, for what a project keeps of its own, under the project directory’sstate/(<cwd>/.agix/state/<resource>/), which holds everything the engine writes there for this machine alone and which the project’s.gitignorekeeps out whole. Deliberately not scene-scoped: a scene’s tool/system-prompt config has no bearing on which project a session or memory file belongs to, so borrowing across scenes would be a correctness hazard (e.g. resuming a session recorded under a different scene’s tool set, or a recording replaying against the wrong tool config).
Project-level skills are not under ConfigPaths at all — they live in
.agents/skills/, a sibling of .agix/, because that’s the path Codex
and other external agent tools scan. ConfigPaths only models Agix’s
own private state and extensions, which no other tool reads.
Re-exports§
pub use layout::entry;pub use layout::ConfigRoot;pub use layout::EngineNameError;pub use layout::Layout;pub use layout::LayoutError;pub use layout::ProductNameError;pub use layout::StateRoot;pub use layout::WorktreesDirError;pub use layout::AGENTS_DIR;pub use layout::CLAUDE_DIR;pub use layout::DEFAULT_ENGINE;pub use layout::DEFAULT_PRODUCT_NAME;pub use layout::DEFAULT_PRODUCT_URL;pub use layout::DEFAULT_PROJECT_DIR;pub use layout::DEFAULT_STATE_DIR;pub use layout::DEFAULT_WORKTREES_DIR;pub use layout::ENGINE_CONFIG_DIRS;pub use layout::ENGINE_CONFIG_FILES;pub use layout::FOREIGN_CONFIG_ROOTS;pub use layout::GIT_WORKTREES_DIR;pub use layout::LOCAL_CONFIG_FILES;pub use layout::PROJECT_ENGINE_CONFIG_DIRS;pub use layout::PROJECT_SKILLS_DIR;pub use layout::PROJECT_STATE_ENGINE_DIRS;pub use layout::PROJECT_STATE_ENTRIES;pub use layout::SETTINGS_FILE;pub use layout::SETTINGS_LOCAL_FILE;pub use layout::STATE_RESERVED_NAMES;pub use layout::STATE_ROOT_SCENE_FILES;pub use layout::STATE_ROOT_SCRATCHPAD;pub use layout::STATE_ROOT_SESSION_TMP;pub use layout::STATE_ROOT_WORKING_DIRS;
Modules§
- layout
- The names of the engine’s directories and of what is in them, and the
values that vary between instances: what the engine is called in scripts
and file names, what a project’s directory is called, what the product is
called, and what the repository directory the engine’s worktrees go in is
called (
Layout:agix,.agix,Agixand.wktsunless the embedder or the user’s settings name others).
Structs§
- Config
Paths - Unified management of AGENT persistent directory paths: the three tiers’ roots and every path derived from them. A caller asks for the path here rather than joining a name onto a root.
- Config
Root At - A configuration root in a directory, as
super::SensitivePaths::config_roots_ingives it. - Credential
- Where a credential is: no tool reads or writes it and no permission mode lets a call through to it; a sandboxed command cannot read it.
- Linked
Worktree - A linked worktree of the project, and where in the repository’s git directory a commit in it writes.
- Located
- One
Credentialplaced on disk, for a sandbox backend. - Path
Settings - Path configuration for data directories.
- Prompt
Files - How the engine reads a file it puts in front of the model on its own —
skill listings and bodies, instruction files, rules, agent definitions,
output styles, memory. What the file resolves to may not be a credential
location, and a file spelled under
root(the project, for project content) may not resolve outside it: a repository can commit a symbolic link to anything, and its own files are all it gets to show the model. The state root’s own files are the user’s, not the project’s, even when the state root sits underroot— a project opened at$HOMEholds~/.agix, and the user’s own skills there may link anywhere. - Sensitive
Paths CREDENTIALSand the working space, resolved for one session: what its state root and its project are.- Worktree
Git - The parts of the repository’s git directory that a commit in one linked worktree writes.
Enums§
- KeyFile
Names - Which names a key file has, by the directory it is in.
- Scope
- The directory a
Credential’s secret is in. - Secret
- What, in a
Scope’s directory, is aCredential. - Workspace
- What a session works in (docs/ARCHITECTURE.md §3.2).
Constants§
- CREDENTIALS
- Every credential location.
- GIT_
CONTROL_ FILES - Files in a git directory that decide which programs git runs and where it reads its configuration from.
- GIT_
HOOKS_ DIR - The directory in a git directory whose programs git runs.
- GIT_
WORKTREE_ CONTROL_ FILES - The same in a linked worktree’s entry under
<git dir>/worktrees/, withgitdir, which leads back to the worktree and which git rewrites only when the worktree is moved or repaired. - HOME_
CREDENTIAL_ STORES - The credential stores in a user’s home directory: a sandboxed command
cannot read them unless the settings allow it
(
base::interface::exec::default_deny_read_in). - REPOSITORY_
CONFIG_ DIR - The repository’s own configuration: confirmed like the engine’s rather
than refused —
gitplumbing throughBashis normal work, and a blanket deny on any path containing a.gitcomponent blocks far more than it protects. - SECRET_
FILE_ NAMES - Names of files that hold secrets wherever they are, which the write tools
refuse as a path component, as they do the
credential_dir_names.
Functions§
- credential_
dir_ names - The names of the directories that hold credentials wherever they are.
- ensure_
local_ data_ gitignore - Make sure
dir’s.gitignorehas everylocal_data_gitignoreentry, appending the ones it lacks and touching nothing else in it: in a cloned repository the file is the repository author’s, and the keys and recordings the engine writes here must stay out of it all the same. A.gitignorethat is a symlink is left alone, as is what it points at. - ensure_
project_ data_ gitignore ensure_local_data_gitignorefor a project’s directory, which a cloned repository supplies: only wherediris a directory of its own, not a symlink, and lies insideproject.- fold_
case textcompared without case the way a case-insensitive filesystem compares names: lowercased, and each character whose full case folding is ASCII written as that folding.- home_
dir - This machine’s home directory:
HOME, elseUSERPROFILE; an empty value counts as unset. - known_
state_ roots - The state roots of instances on this machine that a session’s own may
not be:
$HOME/<name>for each oflayout’sLayout::state_dir_names. Nothing on disk lists the others — an instance’sdaemon/instances.dnames the daemons of its own root only. - local_
data_ gitignore - What a data directory’s
.gitignorekeeps out of the repository the directory sits in, one line each:state/and theLOCAL_CONFIG_FILES. - session_
scratch_ dir - Where a session without a project works: a directory of its own in the
state root’s scratchpad,
<state root>/scratchpad/sessions/<session id>. Its delegates share it — they inherit the session’s settings. - tool_
results_ dir - Where a session’s oversized tool results are saved,
<dir>/tool-results/<session>for the state root or a project’sstate/: outsideSTATE_ROOT_WORKING_DIRS, as the engine writes there unsandboxed.