跳到正文
DEV Community· Juanmidev·· 1 天前AI 評分48

我以 Rust 開發 repo-pack:用於打包 LLM 程式碼庫的單一二進制 CLI 與 MCP Server

I Built repo-pack: A Single-Binary Rust CLI & MCP Server to Pack Repos for LLMs

AI 導讀

repo-pack 是以 Rust 開發的單一二進制 CLI 與 MCP Server,可離線快速打包程式碼庫,並支援輸出 XML 或 Markdown。

正文

Juanmidev

When working with LLMs on real codebases, feeding the right context without blowing up your token budget (or waiting seconds for heavy runtimes to boot) is half the battle.

Tools like Repomix are great, but I wanted something that shipped as a single native binary with zero Node/Python runtime dependencies, ran in a few milliseconds offline, and could strip function implementations at the AST level when I only needed architectural context.

So I built repo-pack in Rust.


What makes it different?

1. Single binary, zero runtime overhead

repo-pack compiles down to a single static binary (~8 MB with Tree-sitter grammars included, or under 3 MB with --no-default-features). It walks your project respecting .gitignore and .ignore (even outside git repos), skips binaries and lockfiles automatically, and outputs structured XML or Markdown in milliseconds.

2. AST Skeleton Mode (--skeleton & --focus)

Dumping an entire repository raw wastes massive amounts of context on function internals you don't care about.

With --skeleton, repo-pack parses Rust, TypeScript/TSX, JavaScript/JSX, and Python using Tree-sitter, replacing function and method bodies with { ... } (or ... in Python while preserving docstrings). Imports, types, structs, classes, and signatures stay intact.


bash
# Skeletonize the entire repository for high-level architectural context
repo-pack . --skeleton

# Keep full code only for auth files, skeletonize everything else
repo-pack . --focus "src/auth/*"

來源:DEV Community · dev.to