Skip to main content
Glama

Lancet

Find, read, and change code and documents — on one coordinate system, at index speed.

CI License: MIT OR Apache-2.0

Website & live demo · Docs · 한국어 · Benchmarks · How it works · Why one tool

Lancet is one Rust binary for AI coding agents and the people working beside them. It replaces the rg + fd + ast-grep + cat + sed + patch chain, and every step shares one index and one set of line numbers: find files, search text and syntax, read exact ranges and symbols, and edit — in source code, PDFs, spreadsheets, Korean HWP documents and archives alike.

Install

curl -fsSL https://raw.githubusercontent.com/CREE1116/lancet/main/install.sh | sh     # macOS / Linux
irm https://raw.githubusercontent.com/CREE1116/lancet/main/install.ps1 | iex         # Windows
brew tap CREE1116/lancet https://github.com/CREE1116/lancet && brew install lancet   # Homebrew

The full binary is ~40 MB (every grammar and document adapter); more options, including cargo and a 4 MB text-only build, are in the installation guide.

Related MCP server: LiuHe

A minute with lancet

lancet index .                                    # optional: build the index once; it keeps itself fresh
lancet fd -e rs                                   # fd's flags and output
lancet rg -w retries src                          # ripgrep's flags and output, from the index
lancet read src/net.rs --symbol retry_limit       # one function, with its rev
lancet refs retry_limit src                       # definition and every use
lancet ast '$X.unwrap()' src --lang rs --rewrite '$X?'           # structural rewrite, dry run
lancet edit src/net.rs --old-string 'retries = 3' --new-string 'retries = 5' --rev <REV> --apply
git diff | lancet patch --apply                   # all files or none

Every write is a diff until --apply (-q for just the summary and new rev). Try these in the browser on a small project — the outputs there are recorded from the real binary.

Why lancet

Agents chain tools, and the failures happen between them. Each number below is reproduced by a script in this repository (bench/failure_modes.py, bench/suite.py, CI parity jobs), and each says what it compares. They were measured on one Apple Silicon Mac; reproductions on Linux x86_64 are welcome as an issue.

What was compared

0 / 800 updates lost

Four agents doing read → change → write back on the same files. With no lock or version check, 600 of 800 updates were lost. The same workflow with lancet's --rev check lost none: the loser gets conflict and retries.

300 / 300 parity cases

lancet rg and lancet fd against ripgrep 16 and fd 10.5 in CI (167 + 133 cases): same output, same exit codes. The flags a model already knows just work.

9–10× faster than ripgrep

Rare-literal searches on Linux and LLVM in the default auto mode (9.7× and 8.9×), which still re-reads every file changed since indexing, so results equal a full scan. The same search with --trust-index, which skips that check: 123× and 335× (459× and 866× for a literal with no hits). A regex with no literal to look up runs at ripgrep's speed.

40 / 40 reads on the right line

Searching a .docx with rga, then reading the hit's line with pandoc: 0 of 40 reads held the hit, because the two tools extract text differently. lancet's search and read share one extraction.

The full case, with the multi-agent protocol, file identity and the critiques we took seriously: docs/why-one-tool.md.

How it works, in three lines

  • The index only decides which files not to open. Every candidate is checked by the same code a full scan uses, so results are identical to a scan. Files edited since indexing are found by (mtime, size, ctime, inode) and re-read — no watcher daemon. (What that check can miss.)

  • One coordinate system. A hit on line 42 is line 42 in read and edit, even inside a PDF, spreadsheet or archive.zip!entry. read --symbol, outline, refs and ast share the same Tree-sitter spans.

  • Every write is a compare-and-swap. read reports a rev (a hash of the bytes); edit, ast --apply and patch write only if the file still has it, under a file lock, and refuse edits that add syntax errors.

Index format, compaction, AST prefiltering and the full benchmark tables: docs/how-it-works.md and docs/benchmarks.md.

Commands

Command

What it does

lancet rg

ripgrep's flags and output on lancet's index and document extractors (parity)

lancet fd

fd's flags, output and exit codes, plus --tree and --type-class (parity)

lancet ast

Tree-sitter search and --rewrite in 27 languages (vs ast-grep)

lancet read

Line ranges, --symbol, PDF pages, spreadsheet cells, archive entries, token budgets

lancet edit / write

Change lines, a symbol, exact text or many hunks at once; guarded by --rev

lancet patch

Apply git diff / diff -u across files, all or nothing

lancet refs / outline

Definitions and uses (comments and strings skipped; lexical, so same-named symbols in other scopes are listed too); declaration skeletons, fitted to a token budget with --budget-tokens

lancet rename

Rename a local variable with scope resolution (17 languages: Rust, Python, JS/TS, Go, C/C++, Java, C#, Kotlin, Swift, Ruby, PHP and more)

lancet index

Build or update the index

lancet mcp

MCP server for clients without a shell

lancet completions

Shell completions (the installers set them up)

Documents and archives: PDF, DOCX, PPTX, ODT, HWP, HWPX, EPUB, XLSX/XLS/ODS, ZIP, TAR, GZ — extracted in-process with size caps.

Using lancet with agents

License

Dual-licensed under either of Apache License 2.0 or MIT, at your option.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      The open retrieval layer for AI agents. Index your entire project — code, docs, legal, research, data — and serve surgical context via MCP. FTS5 full-text search, optional semantic search (FastEmbed/ONNX), 10 built-in parsers, incremental auto-sync.
      8
      284 PyPI
      27
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      LLM-native code tools: 44 MCP tools for AI agents to read, understand and modify code. Rust tree-sitter parse daemon (crash-isolated), SQLite symbol index (repo map 98ms), transactional journal-backed writes, deterministic quality gates (zero LLM calls). 512MB cgroup: 128 concurrent, zero OOM. MIT.
      13
      1
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      The IDE for agents — read by symbol, edit against a revision, validate with your own build, revert. It is a local stdio MCP server for coding agents. It reads code by symbol with tree-sitter and real language servers (Go, Java, Scala, TypeScript, Python, Rust, Ruby), edits against a known revision and returns compiler diagnostics with each edit, runs the repository's own build, test etc.
      12
      1
      Apache 2.0
    • A
      license
      C
      quality
      A
      maintenance
      Local search over your code and documents for AI agents. Hybrid search and a code graph over your code and documents (PDF, Word, PowerPoint, Excel, EPUB), served over MCP with file and line spans, from one Rust binary on your machine.
      8
      13
      Apache 2.0