Skip to main content

Module app

Module app 

Source

Re-exports§

pub use event_source::event_to_msg;
pub use event_source::parse_slash_command;
pub use lifecycle::RuntimeLifecycle;
pub use recorder::RECORDING_FORMAT_VERSION;
pub use recorder::RecordLine;
pub use recorder::Recorder;
pub use recorder::Replay;
pub use recorder::ReplayEntry;
pub use recorder::SessionHeader;
pub use replay::ReplayReport;
pub use replay::replay_recording;
pub use replay::run_replay;
pub use run::InteractiveOptions;
pub use run::run_interactive_with;
pub use run_non_interactive::RunOptions;
pub use run_non_interactive::RunResult;
pub use run_non_interactive::format_result;
pub use run_non_interactive::run_non_interactive_with;
pub use terminal::TerminalGuard;

Modules§

event_source
Crossterm event stream → Msg.
instructions
Project-instructions loader (Step 5h).
lifecycle
Process lifecycle signal handling.
memory
Durable semantic memory (v0.10.0).
plugin_assets
Plugin-contributed assets beyond skills: MCP servers (manifest.mcp), slash-command prompts (manifest.prompts), and agent types (manifest.agents).
recorder
--record / --replay support.
replay
--replay <file>: fold a recorded Msg log back through the pure reducer and reconstruct the session it describes.
run
The ~30-line main loop.
run_non_interactive
Headless driver for mermaid run <prompt>.
sandbox_exec
The hidden mermaid __sandbox-exec re-exec launcher.
skills
SKILL.md discovery + the always-injected skills index.
terminal
Terminal setup and teardown.

Structs§

AgentTypeConfig
One user-defined agent type (see AgentsConfig::types). Every field is optional; an empty table behaves like the built-in general type.
AgentsConfig
Subagent (agent tool) settings.
CompactionConfig
Context-compaction settings.
Config
Main configuration structure
ExecConfig
Foreground execute_command behavior ([exec] table).
LayeredLoad
A completed layered load: the merged config plus the messages the startup path surfaces.
McpServerConfig
MCP server configuration
MemoryConfig
Durable semantic memory settings (v0.10.0).
PlanConfig
Plan-mode settings ([plan]).
PlanPermissions
Per-category permission profile applied while a plan is being drafted. The read-only floor stays the base; these levels decide how far each carve-out opens. The plan file itself is not a category — being able to author the plan IS plan mode.
SafetyConfig
SessionFlags
The per-invocation config overrides carried by CLI flags — the Session layer’s inputs. Built from the parsed CLI by Cli::session_flags().
UiConfig
TUI appearance preferences.
UserProviderConfig
User-supplied remote provider configuration. All fields are optional for a built-in provider; fully custom OpenAI-compatible providers require a base URL and API-key environment variable.
WebConfig
Web tool backend configuration.

Enums§

ConfigLayer
One source of configuration in the layered merge. Declaration order IS precedence: every later layer’s table is deep-merged over the earlier ones, so Defaults < User < Profile < Project < Session.
FetchBackend
Backend for the web_fetch tool.
FilesystemPolicy
Where model-driven shell commands may write. Project engages Linux Landlock write-confinement (--confine-fs): writes are allowed only beneath the project directory, the system temp directory, and /dev; reads and execution stay unrestricted. Best-effort (no-op on kernels without Landlock and on other platforms). Default Unrestricted preserves today’s behavior.
NetworkPolicy
Whether model-driven actions may reach the network. Deny removes web capabilities and engages the shell-command network kill-switch where the OS sandbox supports it. Default Allow preserves explicit network use.
PlanPermLevel
Permission level for one plan-mode category. Mirrors the safety-mode ladder so the picker reads familiarly: allow runs, auto is vetted by the Auto classifier, ask raises the approval modal, deny blocks with the plan-flavored teaching denial.
PlanPostApprove
What approval does once granted, when the user has pinned it in config.
SearchBackend
Backend for the web_search tool.
ThemeChoice
Which built-in color theme the TUI renders with. A typed enum (not a free string) so a typo in config.toml is a clear deserialize error and the reducer’s match stays exhaustive when a theme is added.
TransportKind
Which transport an McpServerConfig selects: a spawned child process (stdio) or a remote Streamable HTTP endpoint.

Functions§

get_config_dir
Get the configuration directory
init_config
Create a default configuration file if it doesn’t exist
load_config
Load the user-scope configuration (defaults + the user file, no project or session layers). This is the view persistence baselines, the daemon, and runtime re-reads use — anything that must not observe another repo’s project config or a one-off CLI flag.
load_config_or_warn
Like load_config (user scope, no session flags) but never fails: on a malformed config, warn on stderr (secret-redacted, #F13) and fall back to defaults (#111). For standalone subcommands that only read user settings.
load_layered_config
Load the full layered configuration: defaults < user file < project file < session flags. cwd locates the project layer (<git-root>/.mermaid/config.toml, sanitized + safety-clamped); pass None to skip it (daemon, tests).
load_layered_config_or_warn
Like load_layered_config but never fails — the startup entry point. On success, prints notices and layer-attributed warnings to stderr. On a malformed layer, warns (secret-redacted, #F13) and degrades: the session flags are re-applied over bare defaults so --no-network/-c survive a corrupt user file rather than being silently dropped with it.
load_project_scoped_config
The project-scoped view (defaults + user + project, NO session flags) for runtime re-reads keyed to a workdir — e.g. the memory settings consulted per operation. Never fails and never prints; warnings/notices were already surfaced by the startup load.
persist_default_reasoning
Persist the user’s default reasoning level. Used by the /reasoning slash command and the Alt+T cycle handler so the choice survives across sessions.
persist_last_model
Persist the last used model to the user config file.
persist_ollama_allow_ram_offload
Persist the Ollama RAM-offload toggle (/context offload on|off).
persist_ollama_num_ctx_for_model
Persist (or clear) a per-model Ollama num_ctx override. Some(n) sets it, None removes the entry (returning that model to auto-fit).
persist_plan_config
Persist the whole [plan] table (the /plan config picker). Values the user set through the picker are explicit choices, so writing them — including ones that currently match defaults — is correct; unset Options stay absent via skip_serializing_if.
persist_reasoning_for_model
Persist a reasoning level for a specific model ID (e.g. <provider>/<model>). The TUI calls this from Alt+T, /reasoning <level>, and the does-not-support-thinking auto-snap so the choice sticks per-model rather than bleeding into other models on next session start.
persist_ui_theme
Persist the TUI theme choice (/theme dark|light).
remove_user_config_key
Remove one key (pre-split path segments) from the USER config file. Returns whether the key existed.
resolve_model_id
Resolve which model to use: CLI arg > last_used > default_model > any available
update_user_config_key
Set one key (pre-split path segments, so map keys containing dots — e.g. reasoning_per_model."ollama/qwen3:8b" — address correctly) in the USER config file, leaving every other key untouched.