collet 0.1.0

Relentless agentic coding orchestrator with zero-drop agent loops
Documentation
use serde::{Deserialize, Serialize};

#[derive(Debug, Default, Serialize, Deserialize)]
pub struct DebugSection {
    pub tool_latency_avg_ms: Option<u64>,
    pub api_latency_avg_ms: Option<u64>,
    pub tool_success_rate: Option<f32>,
    pub tokens_per_iteration: Option<u64>,
    pub tools_per_iteration: Option<u32>,
}

#[derive(Debug, Default, Serialize, Deserialize)]
pub struct ApiSection {
    /// Plain-text key (use env var or encrypted for production).
    pub api_key: Option<String>,
    /// AES-256-GCM encrypted key (base64). Use `collet secure` to set.
    pub api_key_enc: Option<String>,
    pub base_url: Option<String>,
    pub model: Option<String>,
    pub max_tokens: Option<u32>,
    /// Active provider name (matches a `[[providers]]` entry).
    pub provider: Option<String>,
    /// Fallback chain: comma-separated "provider/model" pairs.
    /// Resolution order: `providers[0]` → `providers[1]` → … → global `[default]`.
    pub providers: Option<String>,
}

#[derive(Debug, Default, Serialize, Deserialize)]
pub struct AgentSection {
    pub tool_timeout_secs: Option<u64>,
    pub task_timeout_secs: Option<u64>,
    pub max_iterations: Option<u32>,
    pub max_continuations: Option<u32>,
    pub circuit_breaker_threshold: Option<u32>,
    pub stream_idle_timeout_secs: Option<u64>,
    pub stream_max_retries: Option<u32>,
    pub iteration_delay_ms: Option<u64>,
    pub auto_optimize: Option<bool>,
    pub auto_route: Option<bool>,
}

#[derive(Debug, Default, Serialize, Deserialize)]
pub struct ContextSection {
    /// Maximum context window tokens (default: 200000).
    pub max_tokens: Option<usize>,
    /// Compaction threshold as fraction 0.0-1.0 (default: 0.8).
    pub compaction_threshold: Option<f32>,
    /// Enable adaptive threshold adjustment based on tool density (default: true).
    pub adaptive_compaction: Option<bool>,
}

#[derive(Debug, Default, Serialize, Deserialize)]
pub struct HooksSection {
    pub auto_commit: Option<bool>,
    pub lint_cmd: Option<String>,
    pub test_cmd: Option<String>,
}

#[derive(Debug, Default, Serialize, Deserialize)]
pub struct UiSection {
    /// Theme name: "default", "dark", "light", "minimal".
    pub theme: Option<String>,
    /// Enable debug monitor in sidebar (memory, CPU, tokens, tool calls).
    pub debug_mode: Option<bool>,
}

#[derive(Debug, Default, Serialize, Deserialize)]
pub struct BenchSection {
    /// Days to retain bench.jsonl entries (default: 90). Set 0 to keep forever.
    pub retain_days: Option<u32>,
}

/// `[paths]` section — user-configurable runtime data locations.
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct PathsSection {
    /// Override for the collet home directory.
    /// Defaults to `~/.collet`. Overridable via `COLLET_HOME` env var.
    /// Example: `home = "/data/collet"`
    pub home: Option<String>,
}

/// Security settings.
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct SecuritySection {
    /// Enable PII/sensitive data filter on user input before sending to LLM.
    /// Default: true (opt-out).
    pub pii_filter: Option<bool>,

    /// Paths that the agent is never allowed to read or write, regardless of
    /// the approval mode.  Each entry is matched as a path prefix against the
    /// fully-resolved (lexically-normalized) absolute path.
    ///
    /// Supports `~` expansion (e.g. `~/.ssh`) and glob-style `**` prefix
    /// matching (e.g. `**/.env`).
    ///
    /// Example (`collet.toml`):
    /// ```toml
    /// [security]
    /// deny_paths = ["~/.ssh", "~/.gnupg", "~/.aws", "**/.env"]
    /// ```
    #[serde(default)]
    pub deny_paths: Vec<String>,

    /// When `false` (default), symlinks are resolved to their real path before
    /// checking against `deny_paths`.  This prevents symlink-based escapes
    /// (e.g. `ln -s /etc/passwd link.txt`).
    ///
    /// When `true`, symlinks are followed transparently without additional checks.
    pub follow_symlinks: Option<bool>,
}

/// `[soul]` section — agent personality persistence.
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct SoulSection {
    /// Global switch for Soul.md feature. Default: false.
    /// Each agent can override via `soul: true/false` in frontmatter.
    pub enabled: Option<bool>,
}

/// `[evolution]` section — auto-trigger self-improvement loop.
///
/// When enabled, runs one evolution cycle after each agent task completes,
/// using the same workspace-per-agent layout as soul:
/// - global (collet): `~/.collet/workspace/`
/// - per-agent:       `~/.collet/agents/{name}/workspace/`
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct EvolutionSection {
    /// Auto-trigger evolution after agent task completes. Default: false.
    pub enabled: Option<bool>,
    /// Evolver model override (default: inherits from config.model).
    pub model: Option<String>,
    /// Evolution cycles per trigger. Default: 1.
    pub cycles: Option<u32>,
}

/// `[telemetry]` section — anonymous usage analytics and error reporting.
///
/// All telemetry is opt-out: enabled by default, disable with
/// `COLLET_TELEMETRY=0` or `[telemetry] enabled = false`.
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct TelemetrySection {
    /// Master kill-switch. Default: true.
    pub enabled: Option<bool>,
    /// Send anonymous crash/error reports. Default: true.
    pub error_reporting: Option<bool>,
    /// Send anonymous usage analytics (feature frequency, session stats). Default: true.
    pub analytics: Option<bool>,
}