pub struct Layout { /* private fields */ }Expand description
The names an instance gives its directories and itself. One per pool, carried in the pool’s paths and every session’s settings.
Implementations§
Source§impl Layout
impl Layout
Sourcepub fn new(project_dir: &str) -> Result<Self, LayoutError>
pub fn new(project_dir: &str) -> Result<Self, LayoutError>
The default layout with its project directory project_dir
(Self::with_project_dir).
Sourcepub fn with_project_dir(self, name: &str) -> Result<Self, LayoutError>
pub fn with_project_dir(self, name: &str) -> Result<Self, LayoutError>
This layout with its project directory <project>/<name>: one path
component of [a-z0-9._-], at most 64 long — the configuration
checks split shell text on any other character, and a lowercase-only
name is the same directory on every filesystem. It starts with .:
the engine refuses writes to its configuration subdirectories, which
a project’s own src or docs must never be subject to, and a
hidden directory is where tools keep their state. Not ., .., a
directory that is another tool’s (OTHER_TOOLS_DIRS), nor where
the worktrees go.
Sourcepub fn with_engine(self, name: &str) -> Result<Self, EngineNameError>
pub fn with_engine(self, name: &str) -> Result<Self, EngineNameError>
This layout under the engine name name, with its project directory
.<name>: name another with Self::with_project_dir after this.
[a-z][a-z0-9]*, at most 16 long, and a name a script can be given
as a new global (crate::interface::script::check_global_name):
the base library is installed under it. .<name> must be a project
directory Self::with_project_dir accepts.
Sourcepub fn with_worktrees_dir(self, name: &str) -> Result<Self, WorktreesDirError>
pub fn with_worktrees_dir(self, name: &str) -> Result<Self, WorktreesDirError>
This layout with its worktrees in <repository>/<name>/: one path
component of ASCII letters, digits, ., _ and -, at most 64 long,
starting with . — the repository’s .gitignore ignores it, every
entry in it counts as a copy of the main checkout, and the sandbox
keeps commands from adding, renaming or removing those entries, none
of which a project’s own src must be subject to. Not ., .., a
configuration root (Self::config_roots), a directory another tool
owns (OTHER_TOOLS_DIRS) nor anything starting with .git, which
git and the forges keep their files under, compared without case: a
worktree in one would sit inside configuration the sandbox shuts.
Sourcepub fn with_product_name(self, name: &str) -> Result<Self, ProductNameError>
pub fn with_product_name(self, name: &str) -> Result<Self, ProductNameError>
This layout under the product name name: an ASCII letter, then up
to 31 ASCII letters, digits, - or _. Its lowercase form is a path
component (/etc/<name>, state/<name>), a git ref component
(<name>/worktree-) and an HTTP token (<name>/<version>), all of
which these characters are safe in, and none of
STATE_RESERVED_NAMES.
Sourcepub fn engine(&self) -> &str
pub fn engine(&self) -> &str
The engine’s name in scripts and file names: the base library’s global, the start of its errors’ name.
Sourcepub fn state_dir_names(&self) -> impl Iterator<Item = String>
pub fn state_dir_names(&self) -> impl Iterator<Item = String>
The directories under $HOME instances keep their state in unless
told otherwise: .<engine> for this engine’s, then agixd’s
DEFAULT_STATE_DIR when that is not it.
pub fn project_dir_name(&self) -> &str
Sourcepub fn worktrees_dir_name(&self) -> &str
pub fn worktrees_dir_name(&self) -> &str
The name of the repository directory the engine’s worktrees go in.
Sourcepub fn product_name(&self) -> &str
pub fn product_name(&self) -> &str
The product’s name as people read it: in prompts, messages, a consent page, a notification.
Sourcepub fn product_id(&self) -> String
pub fn product_id(&self) -> String
The product’s name where a machine reads it: lowercase.
Sourcepub fn user_agent(&self) -> String
pub fn user_agent(&self) -> String
<product id>/<version>, the User-Agent of the engine’s requests.
Sourcepub fn worktree_branch_prefix(&self) -> String
pub fn worktree_branch_prefix(&self) -> String
The branch a worktree the engine makes is checked out on, before its
name: <product id>/worktree-.
Sourcepub fn quarantine_prefix(&self) -> String
pub fn quarantine_prefix(&self) -> String
The name a nested repository’s .git is moved aside to, before its
date: .git.<product id>-quarantine-.
Sourcepub fn machine_dir(&self) -> PathBuf
pub fn machine_dir(&self) -> PathBuf
The product’s machine-wide directory, where a deployment puts what
stands above every user and project: macOS /Library/Application Support/<name>, Windows %ProgramData%\<name>, elsewhere
/etc/<id>. Only this product’s: a renamed product has no reason to
read another’s, and its name cannot spell a path out of the parent.
Sourcepub fn managed_settings_file(&self) -> PathBuf
pub fn managed_settings_file(&self) -> PathBuf
<machine dir>/managed-settings.json: the managed settings layer.
Sourcepub fn mcp_policy_file(&self) -> PathBuf
pub fn mcp_policy_file(&self) -> PathBuf
<machine dir>/mcp-policy.json: which MCP servers may connect.
Sourcepub fn attribution(&self) -> String
pub fn attribution(&self) -> String
The product as a commit or pull request the model writes credits it: a link where it is published, else its name.
Sourcepub fn project_dir(&self, project_root: &Path) -> PathBuf
pub fn project_dir(&self, project_root: &Path) -> PathBuf
<project_root>/<name>.
Sourcepub fn worktrees_dir(&self, repo_root: &Path) -> PathBuf
pub fn worktrees_dir(&self, repo_root: &Path) -> PathBuf
<repo_root>/<worktrees dir>: where the engine makes its worktrees.
Sourcepub fn worktrees_dir_names(&self) -> impl Iterator<Item = &str>
pub fn worktrees_dir_names(&self) -> impl Iterator<Item = &str>
The directories at a repository’s root that hold the engine’s
worktrees: this layout’s, then DEFAULT_WORKTREES_DIR when that is
not it — where the worktrees made before the settings named another
directory, or by an instance whose settings name none, are.
Sourcepub fn project_state_dir(&self, project_root: &Path) -> PathBuf
pub fn project_state_dir(&self, project_root: &Path) -> PathBuf
<project_root>/<name>/state: what the engine keeps in the project
for this machine alone, all of it out of the repository.
Sourcepub fn host_state_dir(&self, project_root: &Path) -> PathBuf
pub fn host_state_dir(&self, project_root: &Path) -> PathBuf
<project_root>/<name>/state/<product id>: the embedder’s own state
in the project, which the engine never writes and guards as it
guards its own.
Sourcepub fn gitignore_entry(&self) -> String
pub fn gitignore_entry(&self) -> String
The repository .gitignore line keeping the worktrees directory out.
Sourcepub fn config_roots(&self) -> impl Iterator<Item = ConfigRoot<'_>>
pub fn config_roots(&self) -> impl Iterator<Item = ConfigRoot<'_>>
The configuration roots the engine guards in a directory: its own
name first, then each of FOREIGN_CONFIG_ROOTS that is not it.
Sourcepub fn engine_dir_names(&self) -> impl Iterator<Item = &str>
pub fn engine_dir_names(&self) -> impl Iterator<Item = &str>
The directories an engine of this family writes a project’s keys to:
the instance’s own, and .agix when that is not it.
Sourcepub fn is_own_dir_component(&self, component: &str) -> bool
pub fn is_own_dir_component(&self, component: &str) -> bool
Whether a path component, compared without case, is the instance’s own project directory.
Sourcepub fn main_checkout_copies(&self, path: &Path) -> Vec<PathBuf>
pub fn main_checkout_copies(&self, path: &Path) -> Vec<PathBuf>
What path names inside a git worktree an engine made,
<repo>/<worktrees dir>/<w>/<rest> for any of
Self::worktrees_dir_names, as the main checkout holds it:
<repo>/<rest>, and for a worktree made inside another, each checkout
out to the main one. Nothing is read from disk: without case.
Sourcepub fn worktree_of(&self, path: &Path) -> Option<PathBuf>
pub fn worktree_of(&self, path: &Path) -> Option<PathBuf>
<repo>/<worktrees dir>/<w> when path is in one of the engine’s
worktrees, the outermost when they nest.