magi-code 0.63.3

Repository-aware CLI coding agent for terminal work
Documentation
mod agent;
mod bash_mode;
mod checkpoints;
mod cli;
mod commands;
mod compaction;
pub mod config;
pub mod context;
mod hash;
mod herdr;
mod hex;
mod hooks;
mod http_body;
mod instructions;
mod login;
mod lsp;
mod mcp;
mod model_catalog;
mod output;
mod persistence;
mod primary_agents;
mod prompt_file;
mod providers;
mod rendering;
pub mod sessions;
mod shell;
mod skills;
mod subagents;
#[cfg(test)]
mod test_support;
mod thinking;
mod tool_display;
mod tools;
mod tui;

// Intentional public API surface for the CLI crate. Keep this surface non-breaking unless a
// SemVer-major plan explicitly changes it:
// - `run_from_env()` is the supported binary entrypoint used by `src/bin/magi-code.rs`.
// - `config`, `context`, and `sessions` stay public because they expose durable settings,
//   context-budget/token helpers, and JSONL session IDs used by integration coverage.
// - `ChatMessage`, `MessageRole`, `Usage`, and `ThinkingLevel` stay public because public
//   config/context types use them directly.
// Command, instruction, skill, provider, agent, shell, subagent, TUI, rendering, and tool
// runtime internals stay private to the crate.

pub use providers::{ChatMessage, MessageRole, Usage};
pub use thinking::ThinkingLevel;

use anyhow::Result;
use clap::Parser;

pub fn run_from_env() -> Result<()> {
    run_from_env_inner().map_err(crate::cli::AppError::into_error)
}

pub fn run_from_env_with_exit_code() -> std::process::ExitCode {
    match run_from_env_inner() {
        Ok(()) => std::process::ExitCode::SUCCESS,
        Err(error) => {
            eprintln!("Error: {:?}", error.as_error());
            error.exit_code()
        }
    }
}

fn run_from_env_inner() -> crate::cli::AppResult<()> {
    let args = cli::CliArgs::parse();
    cli::run(args)
}