magi-code 0.77.1

Repository-aware CLI coding agent for terminal work
Documentation
use super::*;
use serde_json::json;
use std::{
    collections::BTreeMap,
    fs,
    path::{Path, PathBuf},
    time::{Duration, Instant},
};

use super::super::settings_storage::{
    MAX_SETTINGS_FILE_BYTES, SETTINGS_SCHEMA_RELATIVE_REF, deep_merge_json, settings_file_lock,
    update_settings_json, with_settings_file_lock, write_file_if_changed,
    write_migrated_file_if_snapshot_matches,
};
use super::super::{CliConfigOverrides, CustomProviderConfig, McPaths};
use super::persistence::{
    KNOWN_SUBAGENTS_KEYS, read_settings_document_with_session_settings,
    read_settings_with_session_settings, update_raw_from_settings,
};
use crate::thinking::ThinkingLevel;

fn read_settings_value(paths: &McPaths) -> serde_json::Value {
    serde_json::from_str(&fs::read_to_string(&paths.settings_file).unwrap()).unwrap()
}

fn parse_validated_settings(raw: &str) -> anyhow::Result<Settings> {
    let settings = serde_json::from_str(raw)?;
    validate_settings(&settings)?;
    Ok(settings)
}

fn paths_with_local_settings(temp: &tempfile::TempDir) -> (McPaths, PathBuf) {
    let local_settings = temp.path().join("project/.magi-code/settings.json");
    fs::create_dir_all(local_settings.parent().unwrap()).unwrap();
    fs::write(&local_settings, "{}").unwrap();
    let paths =
        McPaths::from_root_and_project_dir(temp.path().join("mc"), temp.path().join("project"));
    fs::create_dir_all(&paths.root).unwrap();
    (paths, local_settings)
}

mod agent;
mod merge;
mod models;
mod persistence;
mod services;
mod wire;