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

@hex4c59/pi-ext-claude-tools

v0.1.2

Published

Claude Code-style action/result markers for Pi tool rows.

Readme

claude-tools

给 Pi 的工具行加 Claude Code 风格的层次,不改变 Pi 的布局:

● $ wc -l sample.txt (timeout 60s)
  └─ 3 sample.txt
  • ●:工具动作行
  • └─:工具结果层级,结果文字位于连接符后

包名 @hex4c59/pi-ext-claude-tools。

安装

在本仓库根目录执行:

pi install npm:@hex4c59/pi-ext-claude-tools

调试本地源码时在本仓库根目录执行 pi install ./claude-tools。

回到 Pi 执行 /reload,或重新启动 Pi。只试用一次:

pi -e ./claude-tools

本包不注册命令,加载后自动生效;只在交互式 TUI 模式包装工具行。

行为

  • 完成后折叠结果:工具执行结束时,非空结果显示一行摘要(首条可见内容 + +N lines + 展开提示)。read、bash、powershell 直接从工具的实际文本输出生成摘要,避免读取结果被原生折叠隐藏,或再次折叠 shell 的预览提示;其他工具继续基于原渲染内容生成摘要。
  • 执行中不折叠:isPartial 期间原样显示,Working 时仍能看到命令输出与进度。
  • 按需展开:Ctrl+O 展开后恢复原渲染器的完整结果;再次按下重新折叠。快捷键提示读取 Pi 当前的 app.tools.expand 绑定。Pi 已在 skill/docs/resource 动作行给出展开提示时,结果摘要不重复添加。
  • 状态保留:折叠摘要与原始组件分开保存,传回原渲染器的 lastComponent 始终是它自己创建的组件,反复展开、折叠和刷新时保留原生状态。
  • 状态面板刷新时复用内容和宽度相同的工具行,省去对历史工具行的重复排版。
  • 通过 Pi 的 registerToolRenderer() 包装现有 renderCall / renderResult,用 next() 保留内置或第三方工具渲染器。
  • 结果前缀缩进为子层级;续行悬挂缩进到正文起始列,空行保持为空;不重写工具内容,空结果不显示前缀。
  • 摘要只取第一条可见内容,其后非空行数记为 +N lines;跳过开头空行,不把首条内容重复计数。按实际宽度为展开提示预留空间,再截短首行,摘要保持单行。摘要行铺上与原生工具块相同的面板底色(成功 toolSuccessBg、失败 toolErrorBg)并补齐到整行宽度;截断省略号或工具输出中的 SGR 全复位会重新下发背景序列,折叠行与上方内容连成一块,不会露出终端默认底色。
  • 保留原有参数流式更新、Diff、展开/折叠、错误、图片和复制行为。
  • 子组件按少两列(动作行)或五列(结果行)的宽度排版;结果续行自动对齐到正文,整行再截断到可用宽度。
  • 鼠标事件转发给子组件时会扣除对应前缀的实际列宽。
  • 没有现成 renderCall / renderResult 的工具(例如部分未提供渲染器的 MCP 工具)保持 Pi 原生回退显示,不强行生成标记。
  • 包装链按扩展加载顺序解析;如果其他扩展在本包之后替换同一工具的 renderer,后加载者生效。

和 status 的分工

本包只处理工具行。常驻状态与 Working · esc to interrupt 由 compact-footer 提供;主题配色由 theme 提供。

限制

  • 默认动作标记是 ●;设置 PI_CLAUDE_TOOLS_GLYPHS=claude 可切回 Claude 原版 ⏺ 的文本变体(⏺︎)。
  • 不修改工具执行、权限、模型或会话内容。
  • ● 占两列,└─ 结果层级占五列;极窄终端下前缀会自动隐藏或内容截断。
  • 子组件的内部鼠标区域会做 x 偏移;如果某个第三方 renderer 自己缓存了绝对坐标,仍需要单独核对。
  • 未实现 Claude Code 的随机工作动词、权限模式和专属快捷键。

验证

  • TypeScript 严格检查与 14 项测试通过。测试覆盖工具行缓存、宽度变化、折叠和展开,以及展开提示去重。直接使用 Pi 1.5.0 的原生 renderer 验证 read、bash 和 powershell,并用真实 Theme 与原生 Box 检查折叠行的面板底色。
  • 在 Pi 1.6.0 的 112×66 fullscreen TUI 内回放约 9400 行历史和 800 次工具调用。模拟后台状态刷新时,刷新帧的第 95 百分位耗时从约 15–19 ms 降到 5–7 ms。滚动与长代码块流式输出同时发生的录制和计时保存在 quality/ui/,文件名为 transcript-wheel-26083efbab80.gif 和 transcript-wheel-26083efbab80.json。
  • Pi 1.6.0 中验证了实际 read 的折叠、展开和重新折叠。执行 /reload 时,Pi 会以原生样式重建历史工具行,改动前后均可复现。
  • Windows ConPTY 使用 Pi 1.5.1、隔离配置和本地确定性 provider 验证真实 read / bash:└─ 清晰连接工具调用与结果,展开后续行按正文悬挂缩进;120/60 列、重复三次 Ctrl+O 展开/折叠均通过,网络请求为 0。当前快照与结果见仓库忽略目录 tmp/claude-tools-tree-marker/;Pi 1.5.0 的旧标记验证保留在 tmp/claude-tools-folding/。