lancet Docs
Getting Started

Lancet Documentation — Installation & Cheat Sheet

One Rust binary for discovery, trigram-indexed search, 24-language AST rewrites, exact reads, and CAS edits.

Lancet replaces the rg + fd + ast-grep + cat + sed + patch + pdftotext chain with one dependency-free Rust binary. Every command shares the same .lancet trigram index, traversal filter rules, 1-based line coordinates, and XXH3-64 rev file revisions.

Design contract in one sentence

The trigram index only decides which files not to open; candidates and live-changed files go through the exact same evaluator as a full scan, and every write runs through locked compare-and-swap.

Installation & Build Variants#

Prebuilt binaries are published on every release for macOS (Apple Silicon & Intel), Linux (x86_64/arm64 glibc and static musl), and Windows.

macOS / Linux (Homebrew)
brew tap CREE1116/lancet https://github.com/CREE1116/lancet
brew install CREE1116/lancet/lancet
macOS / Linux (Prebuilt Release Script)
curl -fsSL https://raw.githubusercontent.com/CREE1116/lancet/main/install.sh | sh
Windows (PowerShell)
irm https://raw.githubusercontent.com/CREE1116/lancet/main/install.ps1 | iex
Cargo (Full vs Lean Code-Only Build)
# Prebuilt binary via cargo-binstall
cargo binstall --git https://github.com/CREE1116/lancet lancet

# Compile full build (~40 MB: 24 Tree-sitter grammars + PDF/Office/HWP/archive adapters)
cargo install --git https://github.com/CREE1116/lancet lancet

# Lean build (~4 MB: pure source/text/code, strips document & archive adapters)
cargo install --git https://github.com/CREE1116/lancet lancet --no-default-features

60-Second End-to-End Walkthrough#

Building .lancet is optional. Every command falls back seamlessly when no index exists, and default auto mode checks file metadata on disk on every query so edited files are never missed.

Terminal
# 1. Optional: build the local trigram index once
lancet index .

# 2. Orient with folder-only tree + usage-ranked core symbols
lancet fd --tree --dirs -d 2 .
lancet refs --rank '*Service' --kind class src --limit 8

# 3. Search with ripgrep flags or LQL boolean/proximity queries
lancet rg -w execute_one src
lancet 'near("gradient", "clip", 30) in function | expand parent'

# 4. Read exact symbol or lines and capture its XXH3-64 `rev`
lancet read src/search.rs --symbol execute_one --json

# 5. Preview dry-run diff, then commit atomically with --rev and --apply
lancet edit src/search.rs --find 'let limit = 20;' \
  --with 'let limit = 50;' --rev <REV> --apply

One-Screen Command Cheat Sheet#

Workflow StepCommandSafety / Performance Guarantee
Folder layoutlancet fd --tree --dirs -d 2 .Respects .gitignore / .ignore
Recent / typed fileslancet fd -t f -e rs --changed-within 7dUnits: s, m, h, d, w
Drop-in ripgreplancet rg -w -t rs 'pat' srcByte-identical to rg + opt-in --docs
Boolean / fuzzy LQLlancet '("a" OR "b") NOT "c" in function'Scan == Auto
Multi-query batchlancet batch src -q 'Q1' -q 'Q2'One index open & directory walk
Skeleton outlinelancet outline src/main.rsFunctions, MD headings, sheets, ZIP entries
Budgeted readlancet read f.rs --lines 10:50 --budget-tokens 800Returns rev + next_line cursor
Symbol readlancet read f.rs --symbol my_fnIncludes doc comments & attributes
Document / archivelancet read r.pdf -p 2:3 · a.zip!app.log1-to-1 line numbers with search; read-only
Ranked declarationslancet refs --rank '*Service' --kind class srcSorted by lexical AST reference count
AST search/rewritelancet ast '$X.unwrap()' src -l rs -r '$X?'24 languages; dry-run until --apply
Atomic multi-editlancet edit f.rs --edits - --rev REV --applyOriginal coordinates, overlap-checked CAS
Unified diff patchgit diff | lancet patch --applyAll-file pre-check + CAS rollback
Local binding renamelancet rename f.rs:42 old new --rev REV --apply6 languages; scope re-resolution proof
MCP stdio serverlancet mcp --root .one lancet tool taking CLI arguments, JSON-RPC 2.0, --read-only option
Index diagnosticslancet explain 'pat' · lancet statusTrigram requirements & selectivity %

Where to Go Next#

MIT OR Apache-2.0 · Single Rust binary View Markdown source on GitHub →