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

@chenlongapps/pi-token-speed

v0.1.1

Published

Pi extension for displaying live token generation speed, average TPS, and TTFT

Readme

@chenlongapps/pi-token-speed

English · npm · GitHub

一个轻量级的 Pi Coding Agent 扩展,在 Pi 的终端状态栏显示实时 LLM token 生成指标。

TPS: 42.0 · AVG: 38.5 · TTFT: 1.2

参考 OpenCode Token Speed 的指标和滑动窗口设计,使用 Pi 官方扩展 API 实现。单个 TypeScript 文件,无额外运行时依赖,无需构建。

安装

pi install npm:@chenlongapps/pi-token-speed@latest

指标

  • TPS:流式生成时,最近 5 秒输出的估算 token 数 ÷ 窗口时长(最少按 1 秒计算),单位为 token/秒。
  • AVG:本次会话统计期间,所有成功完成的模型响应的 token 总数 ÷ 生成时间总和。它是按时长加权的平均值,不是各次 TPS 的算术平均。
  • TTFT:这些响应从 before_provider_request 到首个可观测输出(文本、思考或工具调用)的平均延迟,单位为秒。自定义 provider 未触发该钩子时,使用 turn_start 作为起点。

流式 token 数按 UTF-8 输出每 5 字节约 1 token 估算;完成后,优先使用 provider 返回的 usage.output 计算该次 TPS 和 AVG,缺失、无效或为 0 时使用累计字节估算。Pi 的 usage.reasoning 是 usage.output 的子集,不会重复相加,也不会计入输入或缓存 token。

许可证

MIT