Skip to main content

Settings

Struct Settings 

Source
pub struct Settings {
Show 24 fields pub version: u32, pub thinking_level: ThinkingLevel, pub theme: String, pub default_model: Option<String>, pub default_provider: Option<String>, pub last_used_model: Option<String>, pub last_used_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 disabled_tools: Vec<String>, pub tool_timeout_seconds: u64, pub extensions: Vec<String>, pub skills: Vec<String>, pub prompts: Vec<String>, pub themes: Vec<String>, pub custom_providers: Vec<CustomProvider>, pub dynamic_models: HashMap<String, 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 name without provider prefix (e.g., “claude-sonnet-4-20250514”)

§default_provider: Option<String>

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

§last_used_model: Option<String>

Last used model (automatically updated when user selects a model)

§last_used_provider: Option<String>

Last used provider (automatically updated when user selects a model)

§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

§disabled_tools: Vec<String>

Built-in tools to disable (by name, e.g. ["web_search", "github_search"]). All tools are enabled by default; list tools here to turn them off.

§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

§custom_providers: Vec<CustomProvider>

Registered custom providers (loaded from [[custom_provider]] TOML sections).

§dynamic_models: HashMap<String, Vec<String>>

Cached model lists fetched from provider /models endpoints. Key is the provider name, value is a list of model IDs. Updated when API keys are entered in setup wizard or on demand.

Implementations§

Source§

impl Settings

Source

pub fn settings_dir() -> Result<PathBuf, Error>

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

Source

pub fn settings_toml_path() -> Result<PathBuf, Error>

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

Source

pub fn settings_json_path() -> Result<PathBuf, Error>

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

Source

pub fn settings_path() -> Result<PathBuf, Error>

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, Error>

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, Error>

Resolve the effective session directory.

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

Source

pub fn load() -> Result<Settings, Error>

Load settings, applying all layers:

  1. Built-in defaults
  2. Global ~/.oxi/settings.toml
  3. Project .oxi/settings.toml
  4. Environment variable overrides
§Examples
use oxi_cli::Settings;

let settings = Settings::load().expect("Failed to load settings");
println!("Using model: {}", settings.effective_model(None));
Source

pub fn load_from(dir: &Path) -> Result<Settings, Error>

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

Source

pub fn load_from_cwd() -> Result<Settings, Error>

Convenience: load from current working directory.

Source

pub fn apply_env(&mut self)

Apply environment variable overrides in-place.

DEPRECATED: Environment variable overrides are being phased out in favor of file-based configuration (~/.oxi/settings.toml). This method is kept for CI/CD compatibility but should not be relied upon for local development. Use oxi config set or oxi setup instead.

Supported variables (CI/CD only):

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

pub fn from_env() -> Settings

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

DEPRECATED: Returns defaults since env overrides are disabled. Use Settings::load() to load from settings.toml instead.

Source

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

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<(), Error>

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

Source

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

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, Error>

Serialize settings to a string in the specified format.

Source

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

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>) -> Option<String>

Get the effective model ID (provider/model format). Combines default_provider + default_model when both are set. Returns None if no model is configured.

Source

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

Get the effective provider. Returns None if no provider is configured.

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.

Source

pub fn save_last_used(model_id: &str)

Save the last used model/provider and persist to disk.

Source

pub fn save_theme(&mut self, name: &str) -> Result<(), Error>

Save the current theme to settings and persist to disk.

Source

pub fn get_theme_name(&self) -> String

Get the theme name from settings, returning a default if not set.

Source§

impl Settings

Source

pub fn validate(&self) -> ValidationReport

현재 설정의 유효성을 검증한다.

에러는 즉시 프로그램 종료 사유가 되며, 경고는 로그에 남기만 한다.

Trait Implementations§

Source§

impl Clone for Settings

Source§

fn clone(&self) -> Settings

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 Settings

Source§

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

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

impl Default for Settings

Source§

fn default() -> Settings

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

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

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Settings, <__D as Deserializer<'de>>::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 as Serializer>::Ok, <__S as Serializer>::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> GetSetFdFlags for T

Source§

fn get_fd_flags(&self) -> Result<FdFlags, Error>
where T: AsFilelike,

Query the “status” flags for the self file descriptor.
Source§

fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>
where T: AsFilelike,

Create a new SetFdFlags value for use with set_fd_flags. Read more
Source§

fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>
where T: AsFilelike,

Set the “status” flags for the self file descriptor. Read more
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> Pointee for T

Source§

type Pointer = u32

Source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

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<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>,