Cantrik (ꦕꦤ꧀ꦠꦿꦶꦏ꧀) — Open-Source AI CLI Agent berbasis Rust
Cantrik adalah CLI agent yang memahami struktur codebase Anda secara semantik, menggunakan LLM multi-provider dengan kemampuan:
- Semantic search berbasis AST dan embeddings lokal
- Session memory yang smart dengan context compression
- Multi-provider LLM (Anthropic, Google Gemini, Ollama)
- Interactive REPL dengan thinking log real-time
- Codebase indexing dengan incremental updates
cantrik ask "apa fungsi dari file ini?"
cantrik plan "refactor database layer"
cantrik index ./src
# Di terminal interaktif, tanpa subcommand: masuk REPL
cantrik- Website (hub + dokumentasi pengguna + plugin registry MVP): apps/cantrik-site — deploy to
https://cantrik.sangkan.dev. Dokumentasi pengguna mulai darihttps://cantrik.sangkan.dev/docs. PRD also mentionscantrik.devas a possible alias/redirect. - Pre-built CLI: Linux x86_64 binary attached to GitHub Releases when you push a version tag
v*(see.github/workflows/release.yml). - Packaging: Homebrew, nfpm
.deb, ArchPKGBUILD, Nix dev shell, Winget manifest (updateInstallerSha256per release).
cantrik init # template generic
cantrik init --template rust-cliSprint board & roadmap: lihat TASK.md.
Verifikasi objektif vs DoD: DEFINITION_OF_DONE.md · gate rilis docs/DOD_RELEASE_GATE.md · matriks bukti docs/DOD_VERIFICATION_MATRIX.md · ringkasan go/no-go docs/DOD_GO_NO_GO.md.
Cek otomatis lokal (fmt, cargo build --release, clippy, test, help smoke):
./scripts/dod-auto-smoke.shBuild LanceDB membutuhkan protoc dan well-known protobuf includes (skrip mengisi PROTOC_INCLUDE jika ditemukan; di CI Ubuntu paket protobuf-compiler).
- Rust 1.70+ (install via rustup)
- Git
# Clone repository
git clone https://github.com/sangkan-dev/cantrik.git
cd cantrik
# Build project
cargo build
# Run CLI (will show config paths and exit)
cargo run --bin cantrik -- --debug-config
# Run tests
cargo test
# Format code
cargo fmt
# Lint (no warnings allowed)
cargo clippy -- -D warningscantrik/
├── Cargo.toml # Workspace root manifest
├── rustfmt.toml # Code formatting config
├── .githooks/pre-commit # Local quality gate
├── .github/
│ ├── copilot-instructions.md # Copilot project rules
│ ├── instructions/
│ │ ├── rust-cantrik.instructions.md
│ │ └── planning-task.instructions.md
│ ├── skills/
│ │ ├── sprint-task-sync/SKILL.md
│ │ └── rust-cli-feature-delivery/SKILL.md
│ └── workflows/
│ ├── ci.yml # Rust: fmt, check, clippy, test
│ ├── cantrik-site.yml # Svelte hub: check, lint, build
│ └── release.yml # Release binary on tag v*
├── apps/
│ ├── README.md # Hub domain & layout notes
│ └── cantrik-site/ # SvelteKit static hub (Sprint 19)
├── prd/
│ ├── cantrik-prd.md # Product Requirements Document
│ └── package.json
├── TASK.md # Sprint tracking board
└── crates/
├── cantrik-core/ # Library: config, providers, tools
│ ├── Cargo.toml
│ └── src/
│ ├── lib.rs
│ └── config.rs # Config loader (global + project)
└── cantrik-cli/ # Binary: CLI entrypoint
├── Cargo.toml
└── src/
└── main.rs # CLI main (tokio async)
cantrik-core (Library)
- Configuration system (2-tier precedence:
~/.config/cantrikvs.cantrik/) - LLM provider abstraction (trait-based for future providers)
- Indexing & semantic search engine
- Session memory & context management
- Tool definitions registry
cantrik-cli (Binary)
- Command-line interface (clap-based)
- Subcommands:
ask,plan,index,doctor,health - REPL integration
- Config resolution & startup
- Project-level (highest priority):
.cantrik/cantrik.toml - Global:
~/.config/cantrik/config.toml - Defaults (lowest priority): built-in
Example config:
[ui]
theme = "dark"
[llm]
provider = "anthropic"
model = "claude-3-sonnet"Set [llm] offline = true in cantrik.toml or export CANTRIK_OFFLINE=1 (also true / yes / on). In that mode Cantrik only uses Ollama targets from your provider chain and requires providers.toml → [providers.ollama] base_url to use a loopback host (127.0.0.1, localhost, or ::1). Cloud providers in fallback_chain are skipped. cantrik fetch / cantrik web with --approve are refused in offline mode. MCP, plugins, webhooks, and non-loopback Ollama may still use the network—see Network surfaces in CONTRIBUTING.md.
Set [memory] adaptive_begawan = true to record summaries when you use --approve on cantrik file write, cantrik exec, and cantrik experiment, and to inject a short “recent decisions” block into session LLM prompts. Cap size with optional [memory] adaptive_begawan_max_chars (default 900).
Default: configured audit command (e.g. cargo audit), cargo clippy, cargo test --workspace --lib. Optional flags: --tree (cargo tree depth 2), --outdated (cargo outdated if the plugin is installed; otherwise reported as skip), --coverage (cargo llvm-cov report --summary-only if cargo-llvm-cov is installed). Use --soft for exit 0 on failures.
- VS Code:
apps/cantrik-vscode—npm install && npm run compile, then “Install from VSIX…” or open folder in VS Code for development; requirescantrikonPATH. Activity bar Cantrik view lists commands and hub/repo links. - Companion:
apps/cantrik-tray—cargo runpolls~/.local/share/cantrik/approval-pending.flagand sends a desktop notification when it appears (same default path as background jobs). Tauri tray scaffold:apps/cantrik-tauri/README.md.
Set [ui] tui_split_pane = true in cantrik.toml to show assistant + preview columns in the TUI; /visualize output appears in the preview when enabled.
We use automated checks before committing:
# Installed in .githooks/pre-commit
# Automatically runs:
# 1. cargo fmt --check
# 2. cargo clippy -- -D warnings
# 3. cargo test
# If you see them fail:
cargo fmt # Auto-fix formatting
cargo clippy # See warnings
cargo test # Run tests# Full workflow (as in CI)
cargo fmt # Format all code
cargo check --workspace # Type check
cargo clippy -- -D warnings # Lint (no errors allowed)
cargo test # Unit tests
# Fast iteration
cargo check # Quick type check
cargo test lib_name # Single testCurrently, reqwest is configured with:
json— JSON serialization supportrustls— TLS via rustls (not OpenSSL)
# In Cargo.toml (workspace deps)
reqwest = { version = "0.13.2", default-features = false,
features = ["json", "rustls"] }- Sprint 1: Workspace, CI, config system
- Sprint 2: CLI scaffold (
ask,plan,index,doctor, completions, one-shot/pipe/REPL) - Sprint 3: Multi-provider LLM bridge (Anthropic, Gemini, Ollama + OpenAI/Azure/OpenRouter/Groq), streaming, fallback
- Sprint 4: Interactive REPL +
ratatuiTUI, thinking log,/cost/memory/doctor
- Sprint 5: AST indexing via
tree-sitter(10+ languages), incremental updates, dependency graph - Sprint 6: Vector store (LanceDB), semantic search, Ollama local embeddings
- Sprint 7: Session memory (SQLite), context pruning, anchors,
read_file/write_file+ diff preview
- Sprint 8: Tool registry, sandbox (bubblewrap), permission tiers,
git_ops - Sprint 9: Checkpoint/rollback, append-only audit log, provenance
- Sprint 10: Planning, re-planning, stuck detection & escalation
- Sprint 11: Multi-agent orchestration (parallel sub-agents, depth limit, isolation)
- Sprint 12: Background daemon,
cantrik status, desktop notifications - Sprint 13: Plugin system (Lua + WASM), skills, rules, macros
- Sprint 14: Smart routing, cost budgets, MCP server + client
- Sprint 15: Semantic diff, handoff, replay, context export/import
- Sprint 16: Git-native workflow,
cantrik review, web research - Sprint 17: Code archaeology,
cantrik teach, dependency intelligence,cantrik audit - Sprint 18: LSP, voice input,
/visualizeMermaid, TUI split-pane, cultural wisdom mode
- Sprint 19: SvelteKit hub,
cantrik inittemplates, GitHub Releases binary, VS Code extension, Tauri tray, health scanner, adaptive Begawan
- Multi-platform release binaries (Linux aarch64 + macOS — CI workflow updated)
- Test coverage ≥ 70% (
cargo llvm-cov) - Deploy
apps/cantrik-site→cantrik.sangkan.dev
See TASK.md for the full sprint board and DEFINITION_OF_DONE.md for release criteria.
- Language: Rust 2024 edition
- Formatting:
rustfmt(automatic via CI) - Linting:
clippywith-D warnings(zero warnings policy) - Testing: Unit tests for non-trivial logic
- Error Handling:
Result<T, E>withthiserrorfor custom errors
-
Create branch from current sprint:
git checkout -b sprint-N/feature-name
-
Make changes following Rust engineering rules
-
Pre-commit check (auto-runs):
.githooks/pre-commit
-
Push and open PR with:
- Clear title referencing TASK.md item
- Link to related issue if applicable
- CI must pass (GitHub Actions)
- Code passes
cargo fmt --check - Code passes
cargo clippy -- -D warnings - Tests added/updated for new logic
- TASK.md status updated (
[/]→[x]) - CI passes on GitHub
# Release build (optimized)
cargo build --release
# Binary location
./target/release/cantrik
# Or install locally
cargo install --path crates/cantrik-cli
# Run
cantrik --version
cantrik ask "what does this codebase do?""cannot find type Config in module config"
- Ensure
src/config.rsexports public types - Check:
pub struct AppConfig { ... }
"feature rustls-tls is not valid"
- Use
rustlsfeature (notrustls-tls) - See Cargo.toml for correct configuration
# Run with output
cargo test -- --nocapture
# Single test
cargo test config_overrides -- --exactMIT License — See LICENSE file for details
- Issues: GitHub Issues
- PRD & Design: prd/cantrik-prd.md
- Sprint Board: TASK.md
Cantrik is built with:
- Rust Language
- Tokio — Async runtime
- Clap — CLI argument parsing
- Serde — Serialization
- Anthropic Claude / Google Gemini / Ollama — LLM providers
Last Updated: Sprint 1–19 Complete (2026-04)
Next Milestone: GA — multi-platform binaries, coverage ≥70%, docs site deploy
