Skip to main content

mermaid_cli/app/
mod.rs

1// Gateway module for app - follows the Train Station Pattern
2// All external access must go through this gateway
3
4// Private submodules - not directly accessible from outside
5mod config;
6mod editor;
7pub mod event_source;
8pub mod instructions;
9pub mod lifecycle;
10pub mod memory;
11pub mod plugin_assets;
12mod project_config;
13pub mod recorder;
14pub mod replay;
15pub mod run;
16pub mod run_non_interactive;
17pub mod sandbox_exec;
18pub mod skills;
19pub mod terminal;
20
21// Public re-exports - the ONLY way to access app functionality
22pub use config::{
23    AgentTypeConfig, AgentsConfig, CompactionConfig, Config, ConfigLayer, ExecConfig, FetchBackend,
24    FilesystemPolicy, LayeredLoad, McpServerConfig, MemoryConfig, NetworkPolicy, PlanConfig,
25    PlanPermLevel, PlanPermissions, PlanPostApprove, SafetyConfig, SearchBackend, SessionFlags,
26    ThemeChoice, TransportKind, UiConfig, UserProviderConfig, WebConfig, get_config_dir,
27    init_config, load_config, load_config_or_warn, load_layered_config,
28    load_layered_config_or_warn, load_project_scoped_config, persist_default_reasoning,
29    persist_last_model, persist_ollama_allow_ram_offload, persist_ollama_num_ctx_for_model,
30    persist_plan_config, persist_reasoning_for_model, persist_ui_theme, remove_user_config_key,
31    resolve_model_id, update_user_config_key,
32};
33pub use event_source::{event_to_msg, parse_slash_command};
34pub use lifecycle::RuntimeLifecycle;
35pub use recorder::{
36    RECORDING_FORMAT_VERSION, RecordLine, Recorder, Replay, ReplayEntry, SessionHeader,
37};
38pub use replay::{ReplayReport, replay_recording, run_replay};
39pub use run::{InteractiveOptions, run_interactive_with};
40pub use run_non_interactive::{RunOptions, RunResult, format_result, run_non_interactive_with};
41pub use terminal::TerminalGuard;
42
43/// Impure startup backfill of session provenance — the git branch (for the
44/// `--resume` picker), the git SHA at creation, and the CLI version. Done here
45/// rather than in `ConversationHistory::new` so the reducer stays
46/// deterministic for `--replay`. Only fills blanks: a resumed session keeps
47/// what it was saved with; an older session with no stored values gets
48/// backfilled on its next save. Shared by the interactive and headless paths.
49pub(crate) fn stamp_session_provenance(state: &mut crate::domain::State, cwd: &std::path::Path) {
50    let conversation = &mut state.session.conversation;
51    if conversation.git_branch.is_none() {
52        conversation.git_branch = crate::session::detect_git_branch(cwd);
53    }
54    if conversation.git_sha.is_none() {
55        conversation.git_sha = crate::session::detect_git_sha(cwd);
56    }
57    if conversation.cli_version.is_none() {
58        conversation.cli_version = Some(env!("CARGO_PKG_VERSION").to_string());
59    }
60}