Skip to main content

aft/
config.rs

1use std::path::PathBuf;
2
3/// Runtime configuration for the aft process.
4///
5/// Holds project-scoped settings and tuning knobs. Values are set at startup
6/// and remain immutable for the lifetime of the process.
7#[derive(Debug, Clone)]
8pub struct Config {
9    /// Root directory of the project being analyzed. `None` if not scoped.
10    pub project_root: Option<PathBuf>,
11    /// How many levels of call-graph edges to follow during validation (default: 1).
12    pub validation_depth: u32,
13    /// Hours before a checkpoint expires and is eligible for cleanup (default: 24).
14    pub checkpoint_ttl_hours: u32,
15    /// Maximum depth for recursive symbol resolution (default: 10).
16    pub max_symbol_depth: u32,
17    /// Seconds before killing a formatter subprocess (default: 10).
18    pub formatter_timeout_secs: u32,
19    /// Seconds before killing a type-checker subprocess (default: 30).
20    pub type_checker_timeout_secs: u32,
21    /// Whether to auto-format files after edits (default: true).
22    pub format_on_edit: bool,
23    /// Whether to auto-validate files after edits (default: false).
24    /// When "syntax", only tree-sitter parse check. When "full", runs type checker.
25    pub validate_on_edit: Option<String>,
26    /// Per-language formatter overrides. Keys: "typescript", "python", "rust", "go".
27    /// Values: "biome", "prettier", "deno", "ruff", "black", "rustfmt", "goimports", "gofmt", "none".
28    pub formatter: std::collections::HashMap<String, String>,
29    /// Per-language type checker overrides. Keys: "typescript", "python", "rust", "go".
30    /// Values: "tsc", "biome", "pyright", "ruff", "cargo", "go", "staticcheck", "none".
31    pub checker: std::collections::HashMap<String, String>,
32    /// Whether to restrict file operations to within `project_root` (default: false).
33    /// When true, write-capable commands reject paths outside the project root.
34    pub restrict_to_project_root: bool,
35    /// Enable the experimental trigram search index (default: false).
36    pub experimental_search_index: bool,
37    /// Maximum file size to fully index in bytes (default: 1MB).
38    pub search_index_max_file_size: u64,
39    /// Whether grep/glob text output should use compressed summaries (default: true).
40    pub compress_tool_output: bool,
41}
42
43impl Default for Config {
44    fn default() -> Self {
45        Config {
46            project_root: None,
47            validation_depth: 1,
48            checkpoint_ttl_hours: 24,
49            max_symbol_depth: 10,
50            formatter_timeout_secs: 10,
51            type_checker_timeout_secs: 30,
52            format_on_edit: true,
53            validate_on_edit: None,
54            formatter: std::collections::HashMap::new(),
55            checker: std::collections::HashMap::new(),
56            // Default to false to match OpenCode's existing permission-based model.
57            // The plugin opts into root restriction explicitly when desired.
58            restrict_to_project_root: false,
59            experimental_search_index: false,
60            search_index_max_file_size: 1_048_576,
61            compress_tool_output: true,
62        }
63    }
64}