koda_core/lib.rs
1//! Koda Core — the engine library for the Koda AI coding agent.
2//!
3//! This crate contains the pure engine logic with zero terminal dependencies.
4//! It communicates exclusively through `EngineEvent` (output) and
5//! `EngineCommand` (input) enums.
6//!
7//! See `DESIGN.md` in the repository root for the full architectural rationale.
8
9#![warn(missing_docs)]
10
11/// Sub-agent configuration, discovery, and invocation.
12pub mod agent;
13/// Tool approval modes, safety gates, and shared mode state.
14pub mod approval;
15/// Heuristic path-escape detection for bash commands.
16pub mod bash_path_lint;
17/// Bash command safety classification (destructive, mutating, read-only).
18pub mod bash_safety;
19/// Context compaction — summarise old messages to reclaim token budget.
20pub mod compact;
21/// Global configuration: provider, model, model settings, CLI flags.
22pub mod config;
23/// Context window management and token budgeting.
24pub mod context;
25/// SQLite persistence layer — sessions, messages, usage tracking.
26pub mod db;
27/// Engine protocol: `EngineEvent` / `EngineCommand` enums.
28pub mod engine;
29/// Git helpers — status, diff, blame, log.
30pub mod git;
31/// The main inference loop — send messages, stream responses, dispatch tools.
32pub mod inference;
33/// Shared helpers used by the inference loop.
34pub mod inference_helpers;
35/// Credential storage (OS keychain via `keyring`).
36pub mod keystore;
37/// Guardrail against runaway tool-call loops.
38pub mod loop_guard;
39/// MCP (Model Context Protocol) server connections and tool routing.
40pub mod mcp;
41/// Project memory — `MEMORY.md` / `CLAUDE.md` read/write.
42pub mod memory;
43/// Hardcoded context-window lookup table (fallback when API doesn't report).
44pub mod model_context;
45/// Context-scaled output caps for tool results.
46pub mod output_caps;
47/// `Persistence` trait — the database contract.
48pub mod persistence;
49/// Diff preview generation for file mutations.
50pub mod preview;
51/// Progress reporting helpers for long operations.
52pub mod progress;
53/// System prompt construction.
54pub mod prompt;
55/// LLM provider abstraction — Anthropic, Gemini, OpenAI-compatible.
56pub mod providers;
57/// Environment variable access (mockable for tests).
58pub mod runtime_env;
59/// Session lifecycle — create, resume, list, delete.
60pub mod session;
61/// User settings persistence (`~/.config/koda/settings.json`).
62pub mod settings;
63/// Skill discovery and activation (project, user, built-in).
64pub mod skills;
65/// Cache for sub-agent provider/model config across invocations.
66pub mod sub_agent_cache;
67/// Tool dispatch — routes tool calls from inference to the registry.
68pub mod tool_dispatch;
69/// Tool registry, definitions, execution, and path safety.
70pub mod tools;
71/// Token-safe output truncation.
72pub mod truncate;
73/// Undo stack for file mutations.
74pub mod undo;
75/// Version string and update-check helpers.
76pub mod version;