Skip to main content

Settings

Struct Settings 

Source
pub struct Settings {
Show 19 fields pub version: u32, pub thinking_level: ThinkingLevel, pub theme: String, pub default_model: Option<String>, pub default_provider: Option<String>, pub max_tokens: Option<u32>, pub temperature: Option<f32>, pub default_temperature: Option<f64>, pub max_response_tokens: Option<usize>, pub session_history_size: usize, pub session_dir: Option<PathBuf>, pub stream_responses: bool, pub extensions_enabled: bool, pub auto_compaction: bool, pub tool_timeout_seconds: u64, pub extensions: Vec<String>, pub skills: Vec<String>, pub prompts: Vec<String>, pub themes: Vec<String>,
}
Expand description

Application settings

Fields§

§version: u32

Settings format version. Used for automatic migration.

§thinking_level: ThinkingLevel

Thinking level for agent responses

§theme: String

Color theme (e.g., “default”, “monokai”, “dracula”)

§default_model: Option<String>

Default model to use (e.g., “anthropic/claude-sonnet-4-20250514”)

§default_provider: Option<String>

Default provider to use (e.g., “anthropic”, “openai”)

§max_tokens: Option<u32>

Max tokens for responses

§temperature: Option<f32>

Temperature for generation (0.0–2.0)

§default_temperature: Option<f64>

Default temperature as f64 (higher precision, takes precedence over temperature)

§max_response_tokens: Option<usize>

Maximum tokens for generation (usize variant, takes precedence over max_tokens)

§session_history_size: usize

Session history size (entries to keep in memory)

§session_dir: Option<PathBuf>

Directory for storing sessions (default: ~/.oxi/sessions)

§stream_responses: bool

Whether to stream responses

§extensions_enabled: bool

Whether extensions are enabled

§auto_compaction: bool

Whether to auto-compact conversations that exceed context window

§tool_timeout_seconds: u64

Timeout in seconds for tool execution

§extensions: Vec<String>

List of extension paths or npm package sources to load

§skills: Vec<String>

List of skill paths or npm package sources to load

§prompts: Vec<String>

List of prompt template paths to load

§themes: Vec<String>

List of theme paths to load

Implementations§

Source§

impl Settings

Source

pub fn settings_dir() -> Result<PathBuf>

Get the global settings directory path (~/.oxi).

Source

pub fn settings_toml_path() -> Result<PathBuf>

Get the global settings TOML file path (~/.oxi/settings.toml).

Source

pub fn settings_json_path() -> Result<PathBuf>

Get the global settings JSON file path (~/.oxi/settings.json).

Source

pub fn settings_path() -> Result<PathBuf>

Get the global settings file path (JSON takes priority).

Returns the path to the settings file that should be used. If both JSON and TOML exist, JSON is returned (takes priority). If only one exists, that path is returned. If neither exists, returns the JSON path by default.

Source

pub fn settings_path_with_preference(prefer_json: bool) -> Result<PathBuf>

Get the effective settings file path, preferring the specified format.

If prefer_json is true, checks JSON first; otherwise checks TOML first. Returns the first existing file, or the preferred path if neither exists.

Source

pub fn detect_format(path: &Path) -> SettingsFormat

Detect the settings file format from its path.

Source

pub fn find_project_settings(start_dir: &Path) -> Option<PathBuf>

Get the project-local settings file path.

Searches for .oxi/settings.json first, then .oxi/settings.toml. Returns the first one found, or None if neither exists.

Source

pub fn effective_session_dir(&self) -> Result<PathBuf>

Resolve the effective session directory.

Priority: session_dir field → $OXI_SESSION_DIR~/.oxi/sessions.

Source

pub fn load() -> Result<Self>

Load settings, applying all layers:

  1. Built-in defaults
  2. Global ~/.oxi/settings.toml
  3. Project .oxi/settings.toml
  4. Environment variable overrides
Source

pub fn load_from(dir: &Path) -> Result<Self>

Load settings with an explicit working directory for project config discovery.

Source

pub fn load_from_cwd() -> Result<Self>

Convenience: load from current working directory.

Source

pub fn apply_env(&mut self)

Apply environment variable overrides in-place.

Supported variables:

Env varSetting
OXI_MODELdefault_model
OXI_PROVIDERdefault_provider
OXI_THINKINGthinking_level
OXI_THEMEtheme
OXI_MAX_TOKENSmax_tokens
OXI_TEMPERATUREdefault_temperature
OXI_SESSION_DIRsession_dir
OXI_STREAMstream_responses
OXI_EXTENSIONS_ENABLEDextensions_enabled
OXI_AUTO_COMPACTIONauto_compaction
OXI_TOOL_TIMEOUTtool_timeout_seconds
Source

pub fn from_env() -> Self

Build a Settings instance from only environment variables (all other fields stay at defaults).

Source

pub fn save(&self) -> Result<()>

Save settings to the global config file.

Uses the format of the existing file if present, otherwise saves as JSON. Preserves backward compatibility with existing TOML files.

Source

pub fn save_to(&self, path: &Path) -> Result<()>

Save settings to a specific path, using the format determined by the file extension.

Source

pub fn save_project(&self, project_dir: &Path) -> Result<()>

Save settings to the project-local config file.

Uses the format of the existing file if present, otherwise saves as JSON.

Source

pub fn serialize_for_format( settings: &Settings, format: SettingsFormat, ) -> Result<String>

Serialize settings to a string in the specified format.

Source

pub fn parse_from_str(content: &str, format: SettingsFormat) -> Result<Settings>

Parse settings from a string in the specified format.

Source

pub fn merge_cli(&mut self, model: Option<String>, provider: Option<String>)

Merge with CLI arguments (CLI takes precedence).

Source

pub fn effective_model(&self, cli_model: Option<&str>) -> String

Get the effective model ID (provider/model format).

Source

pub fn effective_provider(&self, cli_provider: Option<&str>) -> String

Get the effective provider.

Source

pub fn effective_temperature(&self) -> Option<f64>

Get the effective temperature, preferring default_temperature (f64) over temperature (f32), falling back to None.

Source

pub fn effective_max_tokens(&self) -> Option<usize>

Get the effective max tokens, preferring max_response_tokens (usize) over max_tokens (u32), falling back to None.

Trait Implementations§

Source§

impl Clone for Settings

Source§

fn clone(&self) -> Settings

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Settings

Source§

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

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

impl Default for Settings

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Settings

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Settings

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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: 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: 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<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,