Skip to main content

Layout

Struct Layout 

Source
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

Source

pub fn new(project_dir: &str) -> Result<Self, LayoutError>

The default layout with its project directory project_dir (Self::with_project_dir).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn project_dir_name(&self) -> &str

Source

pub fn worktrees_dir_name(&self) -> &str

The name of the repository directory the engine’s worktrees go in.

Source

pub fn product_name(&self) -> &str

The product’s name as people read it: in prompts, messages, a consent page, a notification.

Source

pub fn product_id(&self) -> String

The product’s name where a machine reads it: lowercase.

Source

pub fn user_agent(&self) -> String

<product id>/<version>, the User-Agent of the engine’s requests.

Source

pub fn worktree_branch_prefix(&self) -> String

The branch a worktree the engine makes is checked out on, before its name: <product id>/worktree-.

Source

pub fn quarantine_prefix(&self) -> String

The name a nested repository’s .git is moved aside to, before its date: .git.<product id>-quarantine-.

Source

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.

Source

pub fn managed_settings_file(&self) -> PathBuf

<machine dir>/managed-settings.json: the managed settings layer.

Source

pub fn mcp_policy_file(&self) -> PathBuf

<machine dir>/mcp-policy.json: which MCP servers may connect.

Source

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.

Source

pub fn project_dir(&self, project_root: &Path) -> PathBuf

<project_root>/<name>.

Source

pub fn worktrees_dir(&self, repo_root: &Path) -> PathBuf

<repo_root>/<worktrees dir>: where the engine makes its worktrees.

Source

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.

Source

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.

Source

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.

Source

pub fn teams_dir(&self, dir: &Path) -> PathBuf

<dir>/<name>/state/teams.

Source

pub fn gitignore_entry(&self) -> String

The repository .gitignore line keeping the worktrees directory out.

Source

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.

Source

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.

Source

pub fn is_own_dir_component(&self, component: &str) -> bool

Whether a path component, compared without case, is the instance’s own project directory.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Layout

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Layout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Layout

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Layout

Source§

impl Hash for Layout

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Layout

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Layout

Auto Trait Implementations§

§

impl Forget for Layout

§

impl Freeze for Layout

§

impl Move for Layout

§

impl RefUnwindSafe for Layout

§

impl Send for Layout

§

impl Sync for Layout

§

impl Unpin for Layout

§

impl UnsafeUnpin for Layout

§

impl UnwindSafe for Layout

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more