Skip to main content

Module paths

Module paths 

Source
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’s state/ (<cwd>/.agix/state/<resource>/), which holds everything the engine writes there for this machine alone and which the project’s .gitignore keeps 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, Agix and .wkts unless the embedder or the user’s settings name others).

Structs§

ConfigPaths
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.
ConfigRootAt
A configuration root in a directory, as super::SensitivePaths::config_roots_in gives 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.
LinkedWorktree
A linked worktree of the project, and where in the repository’s git directory a commit in it writes.
Located
One Credential placed on disk, for a sandbox backend.
PathSettings
Path configuration for data directories.
PromptFiles
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 under root — a project opened at $HOME holds ~/.agix, and the user’s own skills there may link anywhere.
SensitivePaths
CREDENTIALS and the working space, resolved for one session: what its state root and its project are.
WorktreeGit
The parts of the repository’s git directory that a commit in one linked worktree writes.

Enums§

KeyFileNames
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 a Credential.
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/, with gitdir, 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 — git plumbing through Bash is normal work, and a blanket deny on any path containing a .git component 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 .gitignore has every local_data_gitignore entry, 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 .gitignore that is a symlink is left alone, as is what it points at.
ensure_project_data_gitignore
ensure_local_data_gitignore for a project’s directory, which a cloned repository supplies: only where dir is a directory of its own, not a symlink, and lies inside project.
fold_case
text compared 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, else USERPROFILE; 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 of layout’s Layout::state_dir_names. Nothing on disk lists the others — an instance’s daemon/instances.d names the daemons of its own root only.
local_data_gitignore
What a data directory’s .gitignore keeps out of the repository the directory sits in, one line each: state/ and the LOCAL_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’s state/: outside STATE_ROOT_WORKING_DIRS, as the engine writes there unsandboxed.