Skip to main content

ContextConfig

Struct ContextConfig 

Source
pub struct ContextConfig {
    pub file_name: String,
    pub global_dir: Option<PathBuf>,
    pub walk_parents: bool,
}
Expand description

How to look for context files. Every knob has a convention-shaped default; none of them encode a task.

Fields§

§file_name: String

File name to look for in each candidate directory.

A bare name and nothing else: this is joined onto every candidate directory, so a .. or a leading / here would make each of them contribute a document from elsewhere while still being reported under that directory’s scope. A path is refused at discovery with ContextError::ContextFileNameNotBare rather than followed; a host that wants a file from somewhere else names a global_dir or supplies a SystemPrompt instead. Empty is none: no name, so nothing is looked for.

Left at DEFAULT_CONTEXT_FILE this is the first of two names — see file_names for the fallback and for why renaming opts out of it.

§global_dir: Option<PathBuf>

Directory holding the user-global context file, if any.

A directory, so it may be anywhere — naming a path is a host taking responsibility for it, the same latitude MemoryConfig’s roots have.

§walk_parents: bool

Whether to walk from the workspace root up to the filesystem root.

Implementations§

Source§

impl ContextConfig

Source

pub fn none() -> Self

No context discovery at all (decision D9): AGENTS.md and CLAUDE.md are simply not read, in the workspace, in any ancestor, or in the global config directory.

Workspace validation still happens. WorkspaceContext::discover_with resolves and checks the path before it ever looks at file_names — a workspace that does not exist, is not a directory, or cannot be canonicalized still fails open the same way it would with discovery on. What stops is reading files: no document is collected, so WorkspaceContext::render is always None and the system prompt is whatever else supplied one — SystemPrompt, the memory index, or nothing.

Reuses the fields rather than adding a fourth: an empty file_name is what file_names treats as no name to look for, so no candidate is ever found in any directory regardless of global_dir or walk_parents — set to their least-surprising values here rather than left at whatever the caller had, so a Debug print of this value does not suggest a knob that still does something.

Who wants this: a host with its own opinion about what an agent should be told and no interest in a repository’s (SystemPrompt::Replace already drops discovery from the prompt, but still pays for reading the files to report them; this skips the read too) — or a test that wants a result independent of whatever AGENTS.md the machine running it happens to carry.

Source

pub fn file_names(&self) -> Vec<&str>

The names to try in one directory, strongest first. The first that is there is the document that directory contributes; the rest are not read.

The fallback belongs to the default name rather than to any name. A host that renamed the convention has said which file it wants, and reading CLAUDE.md behind that name would be basis loading instructions from a file the host never named — the one thing a discovery knob exists to prevent.

Empty is ContextConfig::none’s doing: no name to look for is no candidate ever found, in any directory.

Trait Implementations§

Source§

impl Clone for ContextConfig

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 ContextConfig

Source§

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

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

impl Default for ContextConfig

Source§

fn default() -> Self

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

impl Eq for ContextConfig

Source§

impl PartialEq for ContextConfig

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 ContextConfig

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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