Rust文档语义搜索工具

rsdoc是一个为Rust crate文档提供语义搜索功能的工具,通过自然语言查询快速定位相关文档内容。

  • by jcdickinson
  • Go
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 jcdickinson/ferrisfetch

使用说明

rsdoc

Rust crate文档的语义搜索。从docs.rs获取rustdoc JSON,将其解析为markdown,使用Voyage AI对其进行矢量化,并使用HNSW索引将所有内容存储在SQLite中。

特性

  • 语义搜索:使用自然语言查询查找文档
  • 内容寻址存储:跨机箱版本重复数据消除文档-对相同文档重新编制索引无需API调用
  • 读取时自动获取:请求您尚未索引的板条箱的文档,它会自动获取
  • 再出口决议:如下 pub use 查找规范文档的链
  • crates.io搜索:按名称或关键字搜索板条箱
  • 后台守护程序:繁重的工作在后台守护进程中运行,后台守护进程在不活动后自动退出

快速开始

先决条件

安装

从源代码构建

git clone https://github.com/jcdickinson/ferrisfetch
cd ferrisfetch
go build -o rsdoc ./cmd/rsdoc

无

nix run github:jcdickinson/ferrisfetch
nix profile install github:jcdickinson/ferrisfetch

配置

创建 ~/.config/ferrisfetch/config.toml:

[voyage_ai]
model = "voyage-3.5"
rerank_model = "rerank-lite-1"

# Read API key from a file (recommended)
api_key = { path = "~/.config/ferrisfetch/voyage_api_key.txt" }
# Or inline (not recommended)
# api_key = "your-api-key"

或者使用环境变量:

export FERRISFETCH_VOYAGE_AI_API_KEY="your-api-key"

用法

当 CLAUDECODE=1 或 AGENT=1 设置, rsdoc --help 输出为AI代理量身定制的降价指令。要使代理了解该工具,请添加 CLI Tools 部分到您的 CLAUDE.md 或 AGENTS.md:

## CLI Tools

These tools are intended to be used in the same way that MCPs are. stderr is for logging and you should typically ignore it.

- `rsdoc --help`: used to search for crates, as well as semantic search across indexed crates. Use this instead of fetching documentation from doc.rs.

CLI工具通常比MCP使用更少的令牌。

命令

rsdoc add serde tokio            # Index crates (latest version)
rsdoc add tokio@1.44.2           # Index a specific version
rsdoc search "async runtime"     # Semantic search
rsdoc search-crates serde        # Search crates.io
rsdoc get serde/latest/serde::Serialize  # Read a doc item (rsdoc:// prefix optional)
rsdoc status                     # Show indexed crates
rsdoc logs                       # Tail daemon log
rsdoc stop                       # Stop the daemon
rsdoc clear-cache                # Clear version resolution cache

使用 --debug 在进程内运行守护进程,并显示日志输出。

建筑

单二进制,两种模式:

  1. 命令行界面 (rsdoc <command>):将请求转发到守护进程的瘦客户端。
  2. 守护进程 (rsdoc daemon):执行繁重任务的后台进程——获取文档、生成嵌入、运行搜索。通过Unix套接字进行通信。如果未运行,则自动生成,在10分钟不活动后自动退出。

数据存在于 ~/.cache/ferrisfetch/:

  • db.db --带有HNSW索引的SQLite数据库
  • cas/ --用于文档标记的内容可寻址存储
  • json/ --从docs.rs缓存rustdoc JSON
  • daemon.log --守护进程日志输出

许可证

看 许可证.

学分