npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wbline/pi-acp-openidea

v0.1.4

Published

ACP adapter for the pi coding agent (OpenIDEA primary host)

Downloads

1,070

Readme

@wbline/pi-acp-openidea

pi coding agent 的 ACP(Agent Client Protocol)适配器,宿主为 OpenIDEA(Rust + Tauri 桌面 IDE,内置 ACP 客户端)。

在 OpenIDEA 的智能体聊天中注册本适配器后,即可使用 pi 作为智能体驱动:模型发现、工具调用、权限确认、会话持久化(/load、/fork)、plan/build 模式、思考等级选择等能力全部可用。

安装

npm install -g @wbline/pi-acp-openidea

前提:已安装并登录 pi CLI(pi 命令可用)。无需向 pi 注册任何包:适配器拉起 pi 时会自动注入自带的 MCP 桥接扩展(--extension),npm 全局安装即可。

在 OpenIDEA 中注册

在 OpenIDEA 配置目录的 agents/ 子目录下新建 TOML 文件(如 <config>/agents/pi.toml):

name = "pi"
driver = "acp"
command = "pi-acp-openidea"
# args = []              # 可选:额外启动参数
# env = { KEY = "value" } # 可选:环境变量,如 { PI_ACP_OPENIDEA_DEBUG_BRIDGE = "1" }

重启 OpenIDEA(或刷新智能体列表)后,聊天界面的智能体选择器中即可看到 pi。

环境变量

| 变量 | 作用 | | --- | --- | | PI_ACP_OPENIDEA_PI_COMMAND | 自定义 pi 命令路径(默认从 PATH 解析 pi) | | PI_ACP_OPENIDEA_SESSION_MAP | 自定义会话映射文件路径(默认 ~/.pi/pi-acp-openidea/session-map.json) | | PI_ACP_OPENIDEA_DEBUG_BRIDGE | 设为 1 时,把收到的 MCP 服务器描述符脱敏后打印到 stderr,用于排查桥接问题 | | PI_ACP_OPENIDEA_EMBEDDED_CONTEXT | 设为 true 时,允许宿主在用户消息里夹带选中的代码、引用的文件等内容(默认关闭,只发纯文本) | | PI_ACP_OPENIDEA_GUIDANCE | 设为 off 时,不注入「优先使用 IDE 工具」引导(见下文) | | PI_ACP_OPENIDEA_EXTRA_TOOLS | 逗号分隔的远程工具名,放行被「默认安全拒绝清单」拦截的工具(见下文) | | PI_ACP_OPENIDEA_CODEMODE | 设为 0 时不向 pi 注入 --tools +codemode,关闭 codemode 批量调用通道(默认注入) |

MCP 桥接

OpenIDEA 在 session/new 下发的标准 mcpServers 数组会被桥接为 pi 扩展工具:

  • stdio:本机命令行 MCP 服务器,直接拉起子进程
  • SSE:type: "sse" 的远程服务器,按 URL + headers 连接(自动补 /sse 后缀)
  • ACP:经 ACP 协议回连宿主的 MCP 服务器

桥接后的工具以 ide_<server>_<tool> 命名出现在 pi 的工具列表中,支持发现、调用、取消与超时;tools/list_changed 通知会自动去重刷新。凭证类环境变量(如 *_TOKEN、*_SECRET、*_KEY)在调试输出中默认脱敏。

注意:mcpCapabilities.http 声明为 false,streamable-http 型 MCP 服务器暂不桥接。

默认安全拒绝清单

适配器把宿主下发的 MCP 工具注册给 pi 之前,会拦截两类高危远程工具,默认不注册(模型看不到、也调用不了):

  • execute_tool:通用命令执行通道,等价于把「任意执行权」交给模型
  • xdebug_*(整个前缀):调试器的启动、接管与断点变异

拦截不是无声的:startup info 中会列出每个被拦工具、拦截原因和放行方法。确认需要这些能力时,在启动适配器的环境中设置(例如 OpenIDEA 的 agents/*.toml 里加 env 字段):

env = { PI_ACP_OPENIDEA_EXTRA_TOOLS = "execute_tool, xdebug_set_breakpoint" }

规则是「逐个点名」:写几个放几个,不支持通配符。OpenIDEA 的内置工具不涉及该清单;只有当会话配置了带高危名工具的其他 MCP 服务器时,这个变量才会实际用到。

OpenIDEA 工具优先引导

startup info 只发给 ACP 客户端 UI,模型看不到;桥接工具对模型而言只是普通扩展工具。为让模型主动优先使用宿主 IDE 工具,适配器会按 remote 名(read_file、apply_patch、search_text、check_files 等)从实际注册的目录中解析能力,并把一段「优先使用 ide_* 工具」的引导注入 pi 系统提示(before_agent_start),未注册任何可识别工具时不注入。

设 PI_ACP_OPENIDEA_GUIDANCE=off 可关闭该引导。

codemode 批量通道

适配器拉起 pi 子进程时注入 --tools +codemode(+ 为增量语法,不覆盖用户自己的 defaultTools),模型可在一段 codemode 脚本里并行(Promise.allSettled)或串联(await)多个工具调用。单个操作保持直接调用对应工具;上面的「优先 IDE 工具」引导里含明确的批量规则。PI_ACP_OPENIDEA_CODEMODE=0 关闭注入。

前提:pi ≥ 1.1.0(--tools 的 +name 语法自该版本引入)。npm run smoke:full 中的 smoke-codemode-flag 探针会检查本机 pi 是否接受该参数。

开发

npm install
npm run build        # tsup 构建 dist/
npm run typecheck    # tsc --noEmit
npm run lint         # eslint
npm test             # node --test(unit + component)
npm run smoke        # 构建 + startupinfo/acp 冒烟
npm run smoke:full   # 全量冒烟矩阵(15 个探针)

License

MIT