首页Home 特性Features 快速开始Quickstart 插件Extensions 文档Docs 更新日志Changelog

项目介绍Introduction

Rpi 是什么,从哪里来,能做什么。 What Rpi is, where it comes from, and what it can do.

Rpi 是一个运行在终端里的 AI 编程助手,用 Rust 编写。它可以读取你的代码、按你的要求修改文件、执行命令,并管理多轮会话——所有工作都在终端里完成,无需离开命令行。项目的设计源自 Pi(earendil-works/pi),并在此基础上独立演进。 Rpi is an AI coding assistant that lives in your terminal, written in Rust. It reads your code, edits files on request, runs commands, and manages multi-turn sessions — all without leaving the command line. The design originates from Pi (earendil-works/pi) and evolves independently from there.

主要特性Highlights

  • 单二进制:静态链接,无运行时依赖,拷贝即可运行。Single binary: statically linked, zero runtime dependencies, copy and run.
  • 完整终端界面:流式输出、语法高亮、斜杠命令、@ 文件引用、会话树。Complete terminal UI: streaming output, syntax highlighting, slash commands, @ file references, session tree.
  • 内置工具:读写文件、编辑代码、执行命令;长对话自动压缩上下文。Built-in tools: read/write files, edit code, run commands; automatic context compaction for long conversations.
  • 38 家模型服务商:OpenAI、Anthropic、DeepSeek、Kimi、Google、Bedrock 等开箱即用。38 model providers: OpenAI, Anthropic, DeepSeek, Kimi, Google, Bedrock and more, out of the box.
  • 插件系统:支持 WebAssembly 与原生动态库两种插件,可热重载。Plugin system: WebAssembly and native dynamic-library plugins, with hot reload.
  • 会话分享:导出 HTML 或生成分享链接。Session sharing: export to HTML or generate a share link.
  • 隐私可控:网络请求可逐项关闭,配置全部保存在本机 ~/.rpiPrivacy control: every network request can be disabled; all configuration stays in ~/.rpi.

许可证与致谢License & credits

Rpi 以 MIT 许可证开源,与上游项目 Pi 一致。感谢 earendil-works/pi 提供了设计原型。源码与 Issue 见 GitHub 仓库 Rpi is open source under the MIT license, same as the upstream project Pi. Thanks to earendil-works/pi for the design it originates from. Source code and issues live in the GitHub repository.

快速开始Quickstart

从安装到第一次对话,大约三分钟。 From install to your first conversation in about three minutes.

1. 安装1. Install

一行命令安装预编译二进制,脚本会自动匹配你当前的平台: Install the prebuilt binary with one command — the script matches your current platform automatically:

# Linux(x86_64 / aarch64,glibc 与 musl 自动识别)
$ curl -fsSL https://revpi.dev/install.sh | sh

# macOS(Apple silicon)
$ curl -fsSL https://revpi.dev/install.sh | sh

# Windows(x86_64,PowerShell)
PS> irm https://revpi.dev/install.ps1 | iex

默认安装位置:Linux / macOS 为 ~/.local/bin--prefix 可覆盖,需写入系统目录时脚本会提示用 sudo 重跑);Windows 为 %LOCALAPPDATA%\Programs\rpi-Prefix 可覆盖)。安装目录不在 PATH 时,脚本会打印对应的 PATH 配置提示。 Default locations: ~/.local/bin on Linux / macOS (override with --prefix; the script suggests re-running with sudo for system directories) and %LOCALAPPDATA%\Programs\rpi on Windows (-Prefix). When the install directory is not on your PATH, the script prints the exact line to add.

手动安装:从 GitHub Releases 下载对应平台的 rpi-<version>-<target>.tar.gz(Windows 为 .zip)与 .sha256 校验文件,核对校验和后解压到 PATH 中的任意目录。 Manual install: download rpi-<version>-<target>.tar.gz (.zip on Windows) and its .sha256 sidecar for your platform from GitHub Releases, verify the checksum, and unpack the binary anywhere on your PATH.

也可以从源码构建:需要安装 Rust 工具链。构建产物是单个可执行文件 target/release/rpi,可以拷贝到 PATH 中的任意位置。 You can also build from source: you need the Rust toolchain. The build produces a single executable, target/release/rpi, which you can copy anywhere on your PATH.

$ git clone https://github.com/revpidev/rpi.git
$ cd rpi
$ cargo build --release
$ ./target/release/rpi

2. 更新2. Update

一条命令自更新到最新版本;失败(如权限不足)时会给出 sudo 重跑或手动替换的具体指引: Self-update to the latest release with one command; on failure (e.g. permissions) it prints exact sudo / manual-replace guidance:

$ rpi update --self

重新运行安装脚本同样可以更新。Windows 上运行中的可执行文件无法被替换,请退出 rpi 后重新运行 install.ps1 或按提示手动替换。有新版本时交互模式启动横幅会提示 rpi update --self Re-running the install script updates an existing installation too. On Windows a running executable cannot replace itself — exit rpi and re-run install.ps1 (or follow the printed manual steps). The interactive-mode startup banner points at rpi update --self when a new version is available.

3. 卸载3. Uninstall

$ rpi self-uninstall           # 删除二进制与安装清单,保留 ~/.rpi 数据
$ rpi self-uninstall --purge   # 连同 ~/.rpi(会话、认证、设置)一起删除

默认保留 ~/.rpi 数据目录(交互式运行会先询问,非交互默认保留),卸载结束会打印遗留物清单。Windows 无法删除运行中的可执行文件,self-uninstall 会跳过并打印需要手动删除的准确路径(rpi.exerpi.install.json)。 The ~/.rpi data directory is kept by default (interactive runs ask first; non-interactive runs always keep), and the command prints a leftover list when done. Windows cannot delete a running executable, so self-uninstall skips it and prints the exact paths (rpi.exe, rpi.install.json) to remove by hand.

4. 配置模型4. Configure a model

Rpi 内置了 38 家模型服务商的模型清单。大多数情况下只需要在 ~/.rpi/agent/models.json 里写入你的 API Key(以 DeepSeek 为例): Rpi ships model catalogs for 38 providers. In most cases you only need to add your API key in ~/.rpi/agent/models.json (DeepSeek example):

{"providers": {"deepseek": {
  "apiKey": "DEEPSEEK_API_KEY",
  "models": [{"id": "deepseek-v4-flash"}]}}}

apiKey 也可以直接写 Key 字符串;写环境变量名时会从环境读取。 apiKey accepts either a literal key or the name of an environment variable to read it from.

5. 三种运行模式5. Three run modes

命令Command 模式Mode 适用场景Use case
rpi 交互模式Interactive 日常使用:多轮对话、边聊边改代码Everyday work: multi-turn chat, edit as you go
rpi --print "..." 一次性问答One-shot 脚本集成:问一个问题,拿到答案就退出Scripting: ask one question, print the answer, exit
rpi --rpc RPC 给其他程序(编辑器、IDE)调用Driving Rpi from other programs (editors, IDEs)

6. (可选)关闭网络请求6. (Optional) Disable network requests

Rpi 默认会在线获取模型目录更新和新版本提示。如果不需要,可以用环境变量逐项关闭: By default Rpi fetches model catalog updates and new-version notices online. Each can be turned off individually:

$ export RPI_MODEL_CATALOG_URL=off
$ export RPI_VERSION_CHECK_URL=off
$ export RPI_TELEMETRY_URL=off

全部设为 off 后,除你自己配置的模型服务商之外,Rpi 不发起任何网络请求。 With all three set to off, Rpi makes no network requests beyond the model providers you configured yourself.

配置参考Configuration

所有配置项、默认值与作用位置。改动保存后重启 rpi 生效。 Every setting, its default, and where it lives. Restart rpi after editing.

配置文件Settings files

位置Location 作用域Scope
~/.rpi/agent/settings.json 全局(所有项目)Global (all projects)
<project>/.rpi/settings.json 仅当前项目;与全局深合并,项目键优先;项目首次打开需信任Current project only; deep-merged over global, project keys win; requires project trust

交互模式里执行 /settings 可在界面中直接修改常用项;类型写错的键会回退到默认值而不是报错。模型与 API Key 配置在 快速开始 一节。 Run /settings inside a session to edit the common items in the UI; a wrongly-typed value silently falls back to the default. Model and API-key setup lives in Quickstart.

请求超时与重试Timeouts & retry

最容易踩的一个设置:httpIdleTimeoutMs 名字里带 idle,实际是整个请求的总超时——从发起连接到流式响应读完为止,期间一直在正常收数据也会计时。默认 5 分钟;长思考档位(max 等)的深度推理模型单轮输出超过 5 分钟时,请求会在整 300 秒处被切断,表现为 error decoding response body。遇到这种情况把它调大: The one that bites most often: despite the name, httpIdleTimeoutMs is a total request timeout — it covers connecting through the last byte of a streamed response and keeps counting even while data flows. Default is 5 minutes; a deep-reasoning model on a high thinking level can exceed that in one turn, and the request is cut at exactly 300 s with error decoding response body. Raise it when that happens:

{
  "httpIdleTimeoutMs": 1800000
}
Key 取值Value 默认Default 说明Notes
httpIdleTimeoutMs 毫秒数 / 0 / "disabled"ms / 0 / "disabled" 300000 模型请求总超时(含流式读取)。0"disabled" 关闭Total timeout per model request, streaming included. 0/"disabled" turns it off
websocketConnectTimeoutMs 毫秒数ms 15000 WebSocket 传输(如 codex-ws)的连接超时Connect timeout for WebSocket transports (e.g. codex-ws)
retry.enabled 布尔boolean true 可重试错误(429/5xx/网络)自动重试总开关Master switch for auto-retry on retryable errors (429/5xx/network)
retry.maxRetries 整数integer 3 最大重试次数Maximum retry attempts
retry.baseDelayMs 毫秒数ms 2000 指数退避基数Exponential backoff base
retry.provider.timeoutMs 毫秒数ms 未设unset 单次 provider 请求超时;设置后优先于 httpIdleTimeoutMsPer-request provider timeout; takes precedence over httpIdleTimeoutMs when set
retry.provider.maxRetries 整数integer 未设unset 单 provider 重试覆盖Per-provider retry override
retry.provider.maxRetryDelayMs 毫秒数ms 60000 重试间隔上限Retry delay ceiling

模型与会话Model & session

Key 取值Value 默认Default 说明Notes
defaultProvider 字符串string 未设unset 默认模型服务商Default model provider
defaultModel 字符串string 未设unset 默认模型 IDDefault model ID
defaultThinkingLevel minimal|low|medium|high|xhigh|max|off 模型默认model default 默认思考档位;不支持的档位自动就近收敛(xhigh/max 仅部分模型支持)Default thinking level; unsupported levels clamp to the nearest supported one (xhigh/max on selected models only)
enabledModels 字符串数组string[] 未设(全部)unset (all) 模型选择列表白名单Whitelist for the model picker
sessionDir 路径path 未设unset 会话 JSONL 存储目录覆盖Override for the session JSONL directory
statusLine 对象object 未设unset 自定义 statusline(需安装 rpi-statusline 插件):{type:"command", command, padding?, placement?, refreshInterval?, timeoutMs?}——命令收到 Claude Code 契约的会话 JSON(stdin),其 stdout(多行+ANSI)渲染为 footer;placement 默认 replace 整条替换内置 footer,可选 widget(编辑器与内置 footer 之间的独立行,多行全彩且保留内置 footer 与其他插件状态行)或 status 追加单行状态;子键 liveTokens(bool 或 {refreshMs?},默认关)开启实时输出 token 计数——流式期间按 refreshMs(300..5000,默认 1000ms)节流重跑脚本,stdin 的 rpi.live_output 块携带本次消息的字符累计/增量窗口/精确 token 数等纯测量值,token 换算与速率计算由脚本自定(参考 rpi-docs statusline 03 文档)Custom statusline (requires the rpi-statusline plugin): {type:"command", command, padding?, placement?, refreshInterval?, timeoutMs?} — the command receives the session JSON (Claude Code contract) on stdin and its stdout (multi-line + ANSI) renders as the footer; placement defaults to replace (replaces the built-in footer), widget (an independent multi-line row between the editor and the built-in footer, which is preserved) or status (appends a single status row); the sub-key liveTokens (bool or {refreshMs?}, default off) enables live output-token counting — while streaming the script re-runs throttled by refreshMs (300..5000, default 1000ms) and the stdin rpi.live_output block carries raw measurements (per-message char accumulators, delta window, exact tokens) for the script to convert (see the rpi-docs statusline 03 doc)
steeringMode one-at-a-time|all one-at-a-time 生成途中插话的处理方式How queued steering messages are handled mid-generation
followUpMode one-at-a-time|all one-at-a-time 追问排队方式Follow-up message queuing
thinkingBudgets {minimal,low,medium,high} 未设unset 各思考档位的 token 预算上限(仅支持 thinking_token_budget 的服务商生效)Per-level token budgets (applies only to providers with thinking_token_budget support)

上下文管理Context management

Key 取值Value 默认Default 说明Notes
compaction.enabled 布尔boolean true 长对话自动压缩Automatic context compaction
compaction.reserveTokens 整数integer 16384 压缩触发的预留 token 数Token reserve that triggers compaction
compaction.keepRecentTokens 整数integer 20000 压缩时保留的最近消息 token 数Recent tokens kept intact when compacting
branchSummary.reserveTokens 整数integer 16384 分支切换摘要的预留Reserve for branch summaries
branchSummary.skipPrompt 布尔boolean false 生成分支摘要前不再询问Skip the confirmation prompt before summarizing

界面显示Display

Key 取值Value 默认Default 说明Notes
theme 主题名theme name dark 配色主题Color theme
tuiMode regular|fullscreen regular 界面模式;全屏模式占用 alt screen 并支持鼠标UI mode; fullscreen takes over the alt screen with mouse support
fullscreenExitOutput transcript|resume-hint transcript 退出全屏后主屏输出内容What the main screen prints after exiting fullscreen
hideThinkingBlock 布尔boolean false 默认折叠思考过程块Collapse thinking blocks by default
showCacheMissNotices 布尔boolean false 显示缓存未命中提示Show cache-miss notices
terminal.showImages 布尔boolean true 终端内联渲染图片(需终端支持)Render images inline (requires terminal support)
terminal.imageWidthCells 整数integer 60 内联图片宽度(终端字符列)Inline image width in terminal cells
terminal.showTerminalProgress 布尔boolean false 在终端标题栏显示进度Progress in the terminal title bar
images.autoResize 布尔boolean true 图片自动缩放到终端宽度Auto-scale images to terminal width
images.blockImages 布尔boolean false 完全禁止图片渲染Block image rendering entirely
markdown.codeBlockIndent 字符串string "  " 代码块缩进Code block indent
markdown.mermaid streaming|final|off streaming Mermaid 图渲染时机When Mermaid diagrams render
editorPaddingX 整数integer 0 输入框左右留白Editor horizontal padding
outputPad 0|1 1 消息块之间的空行Blank lines between message blocks
autocompleteMaxVisible 整数integer 5 自动补全菜单最多可见项Max visible autocomplete items
doubleEscapeAction tree|fork|none tree 连按两次 Esc 的动作Action for a double Esc
treeFilterMode default|no-tools|user-only|labeled-only|all default 会话树节点过滤Session tree node filtering
showHardwareCursor 布尔boolean 环境默认environment 硬件光标(部分终端需关闭)Hardware cursor (some terminals need it off)
quietStartup 布尔boolean false 静默启动(不打印横幅)Suppress the startup banner
collapseChangelog 布尔boolean false 默认折叠新版本变更列表Collapse the release changelog by default

Shell 与编辑器Shell & editor

Key 取值Value 默认Default 说明Notes
shellPath 路径path 未设(自动探测)unset (auto) bash 工具使用的 shellShell used by the bash tool
shellCommandPrefix 字符串string 未设unset 命令包装前缀(如 docker exec 类沙箱)Command wrapper prefix (e.g. sandboxing via docker exec)
externalEditor 命令command nano / notepad nano / notepad 外部编辑器;EDITOR/VISUAL 环境变量次之External editor; EDITOR/VISUAL env vars are checked next
npmCommand 字符串数组string[] 未设(自动探测)unset (auto) npm: 包安装命令覆盖Override for npm-package installs
defaultProjectTrust ask|always|never ask 打开新项目时的默认信任策略Default trust policy for new projects

隐私与网络Privacy & network

rpi 默认只向三类官方端点发起非模型请求:模型目录更新、新版本检查、安装统计。三者都可以用设置键或同名环境变量指向自建地址,设为 off 整体禁用: Beyond your model providers, rpi contacts three house-keeping endpoints: model catalog refresh, version check, and install telemetry. Each can be pointed at a self-hosted URL via the setting or the matching env var, or disabled with off:

$ export RPI_MODEL_CATALOG_URL=off   # 禁用模型目录在线更新
$ export RPI_VERSION_CHECK_URL=off   # 禁用新版本检查
$ export RPI_TELEMETRY_URL=off       # 禁用安装统计上报
$ export RPI_REGISTRY_URL=off        # 禁用插件 registry(rpi install 退化为直连渠道)
Key 取值Value 默认Default 说明Notes
enableAnalytics 布尔boolean false 使用统计(默认关闭)Usage analytics (off by default)
enableInstallTelemetry 布尔boolean true 安装成功事件上报(仅一次)One-shot install-success event
modelCatalogUrl / versionCheckUrl / telemetryUrl URLURL 官方地址official 对应环境变量 RPI_MODEL_CATALOG_URL / RPI_VERSION_CHECK_URL / RPI_TELEMETRY_URLMatching env vars: RPI_MODEL_CATALOG_URL / RPI_VERSION_CHECK_URL / RPI_TELEMETRY_URL

扩展与包Extensions & packages

Key 取值Value 默认Default 说明Notes
packages 包源数组package sources empty 每项 {source, autoload, extensions, skills, prompts, themes};source 支持 npm/git 路径;autoload:false 时仅加载显式列出的资源Each item is {source, autoload, extensions, skills, prompts, themes}; npm/git paths; autoload:false loads only explicitly listed resources
extensionPaths 路径数组path[] empty 额外的扩展发现目录Extra extension discovery directories
skillPaths / promptTemplatePaths / themePaths 路径数组path[] empty 技能 / 提示模板 / 主题的额外发现目录Extra discovery dirs for skills / prompt templates / themes
enableSkillCommands 布尔boolean true 把技能暴露为斜杠命令Expose skills as slash commands

插件的安装与信任模型见 插件开发指南rpi install --help For plugin installation and the trust model see the plugin guide and rpi install --help.

插件开发指南Plugin guide

用插件给 Rpi 增加新工具、新命令和新行为。 Extend Rpi with new tools, commands and behaviors.

两种插件形态Two plugin formats

形态Format 文件File 特点Characteristics
WebAssembly .wasm 在沙箱中运行,按声明的能力授权;可用任何能编译到 wasm32 的语言编写Runs in a sandbox with declared capabilities; write in any language that targets wasm32
原生动态库Native library .so / .dll / .dylib 性能最好,但无沙箱,拥有与 Rpi 进程相同的权限,只安装可信来源Best performance, but unsandboxed — same permissions as the Rpi process; install only from sources you trust

一个插件长什么样Anatomy of a plugin

一个插件就是一个目录,里面放一个清单元文件 rpi-extension.json 和插件本体: A plugin is a directory containing a manifest file, rpi-extension.json, plus the plugin binary:

permission-gate/
├── rpi-extension.json   # 清单 / manifest
└── dist/
    └── permission_gate.wasm
{
  "name": "permission-gate",
  "version": "0.1.0",
  "description": "Block a tool + register a custom tool",
  "wasm": "dist/permission_gate.wasm",
  "capabilities": ["tools", "session"],
  "rpiAbi": 1
}

capabilities 声明插件需要的能力,未声明的能力在运行时会被拒绝。原生动态库插件把 wasm 字段换成 native capabilities declares what the plugin is allowed to do; anything undeclared is denied at runtime. Native plugins use a native field instead of wasm.

安装与重载Install & reload

把插件目录拷贝(或软链)到以下任一位置,Rpi 启动时会自动发现: Copy (or symlink) the plugin directory into either location below; Rpi discovers it at startup:

  • ~/.rpi/agent/extensions/<name>/对所有项目生效applies to every project
  • .rpi/extensions/<name>/仅当前项目生效applies to the current project only

修改插件后无需退出 Rpi,在会话里执行 /reload 即可热重载。 After changing a plugin, run /reload inside the session — no need to restart Rpi.

从示例开始Start from the example

仓库里的 examples/wasm-extension/ 是一个完整示例:拦截指定工具的调用,并注册一个自定义工具。构建并安装: The repository ships a complete example at examples/wasm-extension/: it intercepts calls to a specific tool and registers a custom one. Build and install it:

$ rustup target add wasm32-unknown-unknown   # 一次性 / one-time
$ cd examples/wasm-extension
$ cargo build --target wasm32-unknown-unknown --release
$ mkdir -p dist
$ cp ../../target/wasm32-unknown-unknown/release/rpi_wasm_extension_example.wasm dist/permission_gate.wasm
$ cp -r ../wasm-extension ~/.rpi/agent/extensions/permission-gate

插件与宿主之间的完整通信规范(消息格式、能力列表、错误类型)见仓库中的 Extension ABI 文档 The full contract between plugins and the host — message formats, capability list, error kinds — is documented in the Extension ABI document in the repository.