Skip to content

Crate Overview

clido is a Cargo workspace with 11 crates. Each crate has a single, well-defined responsibility.

crates/
clido-cli/ — Binary; CLI parsing, TUI, command dispatch
clido-agent/ — Agent loop, EventEmitter, AskUser traits
clido-providers/ — LLM provider implementations
clido-tools/ — Tool trait, registry, built-in tools
clido-core/ — Shared types, config, pricing, errors
clido-storage/ — Session JSONL, audit log, paths
clido-context/ — Token counting, context assembly, compaction
clido-memory/ — Long-term memory (SQLite + FTS5)
clido-index/ — Repository file+symbol index (SemanticSearch)
clido-workflows/ — YAML workflow executor
clido-planner/ — LLM-based task decomposition (DAG)

The binary crate. Contains Clap argument parsing, command dispatch, the Ratatui TUI, and all top-level commands (sessions, audit, memory, index, workflow, etc.).

Key modules:

ModulePurpose
cli.rsClap Cli struct and all subcommand enums
main.rsEntry point, dispatch, terminal restoration
tui.rsRatatui TUI: render loop, input handling, state
run.rsNon-TTY agent invocation
setup.rsclido init wizard
doctor.rsclido doctor health checks
sessions.rsclido sessions commands
audit_cmd.rsclido audit
memory_cmd.rsclido memory commands
index_cmd.rsclido index commands
workflow.rsclido workflow commands
stats.rsclido stats
config.rsclido config show/set
models.rsclido list-models, fetch-models
pricing_cmd.rsclido update-pricing
agent_setup.rsProvider + registry construction
agent_loop.rsCLI-level agent loop wrapper

Dependencies: clido-agent, clido-tools, clido-core, clido-storage, clido-context, clido-providers, clido-memory, clido-index, clido-workflows, ratatui, crossterm, clap, tokio

The agent loop. Manages conversation history, calls the provider, dispatches tool calls, emits events, enforces turn/budget limits, and writes to the session file.

Key types:

TypePurpose
AgentLoopMain agent struct; holds history, provider, tools, config
AgentLoop::run()Execute the agent loop for one session turn batch
EventEmitterTrait for observing tool calls in real time
AskUserTrait for permission prompts
session_lines_to_messages()Reconstruct history from JSONL for resume
SubAgentSpawns a child agent for workflow steps

Dependencies: clido-core, clido-providers, clido-tools, clido-storage, clido-context, clido-memory, tokio, async-trait

LLM provider implementations. Each provider wraps an HTTP client and translates between clido’s internal Message format and the provider’s wire format.

Key types:

TypePurpose
ModelProviderTrait: complete(), stream_complete(), name()
AnthropicProviderClaude API implementation
OpenAIProviderOpenAI-compatible implementation
OpenRouterProviderOpenRouter wrapper (extends OpenAI)
LocalProviderOllama/local model wrapper
make_provider()Factory function: constructs provider from config

Dependencies: clido-core, reqwest, serde, tokio

The Tool trait, ToolRegistry, and all built-in tool implementations.

Key types:

TypePurpose
ToolTrait: name(), description(), schema(), execute()
ToolRegistryHashMap of tools; supports allow/disallow filtering
BashToolShell command execution with timeout
ReadToolFile reading with line-range slicing
WriteToolFile creation and overwrite
EditToolPrecise string replacement in files
GlobToolFile pattern matching
GrepToolRegex content search
SemanticSearchToolFull-text search over repository index
ExitPlanModeToolSignals the agent to end plan-only mode
McpToolWrapper for a single MCP server tool
PathGuardEnforces workspace root path restrictions
FileTrackerTracks read files for stale detection
default_registry()Build the default V1 tool set

Dependencies: clido-core, clido-context, clido-index, async-trait, serde_json, tokio

Shared types, configuration structs, pricing data, and error types. This crate has no dependencies on other clido crates.

Key types:

TypePurpose
AgentConfigRuntime agent configuration
ProviderConfigProvider credentials and model
PermissionModeEnum: Default, AcceptAll, PlanOnly
HooksConfigPre/post tool hooks
ConfigFileDeserialised config.toml structure
LoadedConfigMerged config (global + project)
ProfileEntryOne provider+model+credentials entry
Message, ContentBlock, RoleLLM message types
ModelResponse, StopReason, UsageProvider response types
ToolSchemaTool description for the LLM
PricingTableModel pricing data
ClidoErrorTop-level error enum

Dependencies: serde, toml, directories (no other clido crates)

Session JSONL files, the audit log, and filesystem paths.

Key types:

TypePurpose
SessionLineEnum of all JSONL line variants
SessionWriterAppend-only writer for a session file
SessionReaderIterator over session lines
SessionSummarySummary for sessions list
AuditLogAppend-only audit log writer
AuditEntryOne audit log record
data_dir()Platform data directory
session_file_path()Full path for a session file
list_sessions()All sessions, sorted by recency
stale_paths()Files modified since session end

Dependencies: clido-core, serde, serde_json, chrono, directories

Token counting and context assembly (system prompt + memory + history) before each provider call.

Key functions:

FunctionPurpose
assemble()Build final message list for provider call
estimate_tokens_str()Approximate token count for a string
DEFAULT_MAX_CONTEXT_TOKENSDefault context window (200,000)
DEFAULT_COMPACTION_THRESHOLDDefault compaction trigger (0.75)

Also contains a ReadCache for deduplicating file reads within a session.

Dependencies: clido-core, clido-memory

Long-term memory store backed by SQLite with FTS5 full-text search.

Key types:

TypePurpose
MemoryStoreSQLite-backed memory store
MemoryStore::search()FTS5 query
MemoryStore::insert()Add a memory record
MemoryStore::list()Most-recent-first listing
MemoryStore::prune()Keep N most recent, delete rest
MemoryStore::reset()Delete all memories

Dependencies: rusqlite, serde, chrono

Repository file and symbol index for the SemanticSearch tool.

Key types:

TypePurpose
IndexStoreSQLite-backed index
IndexStore::build()Incremental index build
IndexStore::search()FTS5 symbol search
IndexStore::stats()File/symbol counts
IndexStore::clear()Delete all index data

Dependencies: rusqlite, tree-sitter (for symbol extraction), walkdir

YAML workflow parser, validator, and executor.

Key types:

TypePurpose
WorkflowDeserialised workflow YAML
WorkflowStepOne step definition
WorkflowRunnerExecutes a workflow against an agent
WorkflowRunner::validate()Schema + dependency checks
WorkflowRunner::inspect()Returns the step DAG
WorkflowRunner::check()Preflight checks

Dependencies: clido-agent, clido-core, serde_yaml, tokio

Experimental task decomposition. Sends a single LLM call to decompose the user’s prompt into a DAG of subtasks.

Key types:

TypePurpose
PlannerMakes the planning LLM call
PlanDeserialised task graph (nodes + edges)
PlanNodeOne task in the graph
Planner::plan()Returns Ok(Plan) or error (triggers fallback)

Dependencies: clido-providers, clido-core, serde_json, tokio