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

pi-turn-metrics

v0.1.0

Published

Pi Coding Agent extension for real-time execution turns, steps, LLM/tool durations, TTFT, and TPS in the footer status bar

Readme

pi-turn-metrics

npm pi-package license

English | 中文说明

pi-turn-metrics 是一个为 Pi Coding Agent 打造的底部状态栏扩展插件,用于实时监控对话与任务执行过程中的 轮次 (Turns)步数 (Steps)模型耗时 (LLM Duration)工具耗时 (Tool Duration)首字延迟 (TTFT)生成速率 (TPS)

算法与展示规则 100% 对齐 Deepseek Harness 官方规范,并支持终端窗口宽度的动态自适应排版。


📸 效果预览

# 标准风格(默认 / 终端宽度 ≥ 80 列)
1 turns · 4 steps | LLM 34.1s · Tool call 0.6s | TTFT avg 3.9s · 68 tok/s

# 紧凑风格(窄屏窗口或宽度受限时自动切换)
1t·4s | LLM 34.1s · Tool 0.6s | TTFT 3.9s · 68 tok/s

⚡ 快速安装

# 通过 npm 安装
pi install npm:pi-turn-metrics

# 或通过 git 安装
pi install git:github.com/leon-zym/pi-turn-metrics

# 临时体验(无需安装)
pi -e npm:pi-turn-metrics

在运行中的 Pi 会话中,输入 /reload 即可热重载生效。


🎯 展示内容与特性

Pi 原生状态行主要展示 Token 账目与上下文占用↑ 输入↓ 输出R 缓存读取CH 缓存命中率已用上下文 / 最大容量),pi-turn-metrics 补充了执行流与时间维度的核心指标:

| 模块 | 展示示例 | 含义说明 | | :--- | :--- | :--- | | 执行计数 (Counts) | 1 turns · 4 steps | 用户发起的交互轮次,以及 Agent 自治调用的内部步骤数。 | | 执行耗时 (Durations) | LLM 34.1s · Tool call 0.6s | 细分纯模型推理生成耗时与本地工具/命令执行耗时。 | | 流式性能 (Speeds) | TTFT avg 3.9s · 68 tok/s | 平均首字延迟(TTFT)与解码吞吐速率(TPS)。 |

  • 耗时瓶颈直观诊断:一眼分辨耗时是在等模型生成还是本地命令(构建、测试或安装)。
  • 终端宽度自适应:监听终端列宽及 resize 事件,在标准 Pipe 风格与紧凑缩写风格间自适应切换,避免被终端粗暴截断。

📐 计算逻辑(对齐 Deepseek Harness)

指标计算严格对齐 Deepseek HarnesssessionStats 规范:

  • Turns & Steps:用户每次提问 turns + 1;模型每完成一次响应 steps + 1
  • LLM & Tool 耗时LLM 累加请求发起至组装完成的耗时;Tool call 按工具调用 ID 配对累加执行毫秒数(天然支持并发)。
  • TTFT (首字延迟):捕获首个有效 token delta chunk(文本、思考过程或工具调用)并求各步平均值。
  • TPS (解码吞吐):模型实际输出 Token 总数除以解码总耗时(首 token 到消息结束)。

📄 开源许可证

MIT © 2026 zhangyiming