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-timing

v1.3.0

Published

Timing widget for pi: per-turn generation time (with thinking estimate), tool time, cumulative active time (excluding idle), and session span. Commands: /timing, /timing list

Readme

pi-timing

English Docs

pi 的计时组件 —— 显示每次回复实际花了多长时间,以及你的会话里有多少是真正干活、多少是在空等。

功能

  • 每次生成耗时 — 每次 LLM 流式的墙钟(思考 + 回复),含思考时间估算(思考≈
  • 工具耗时 — 工具执行墙钟,并行工具按组只计一次
  • 逐回复标注行 — 每条 AI 输出下方一行灰色小字:中间轮(带工具调用)显示本轮生成耗时与工具次数;最终回复显示回复总耗时(用户消息 → 回复完成,含思考+生成+工具)+ 工具总次数 + 末轮生成耗时;随会话持久化(不进 LLM 上下文),重启后仍在
  • 累计活跃时间 — Σ(生成) + Σ(工具),不含空闲;通过每轮 timing-snapshot 条目跨重启持久化
  • 会话跨度 — 首条消息到末条消息的墙钟(含空闲),显示在最前
  • 历史重算 — 重启时从会话文件恢复累计;/tree 分支包含跳转点之前的历史(祖先链)
  • 多语言 — widget 语言自动跟随你的消息语言(中/英),初始取系统 locale;可用 /timing lang 强制

安装

pi install npm:pi-timing

或者把 extensions/timing 拷贝到 ~/.pi/agent/extensions/(或项目级 .pi/extensions/)。

安装后执行 /reload(或重启 pi)生效。

使用方法

生效后,widget 显示在输入框上方。输入任意消息并回车 —— widget 立即开始工作(生成中实时计时,回复完成后显示最终拆解)。

Widget 示例(中文显示):

⏱ 会话跨度 10h31m  ·  累计活跃 36m26s (14轮)  ·  上次回复 30.4s (生成 25.2s · 思考≈25.2s · 工具 3.0s)

Widget 示例(英文显示——消息语言为英文时自动切换,或 /timing lang en 强制):

⏱ elapsed 10h31m  ·  active time 36m26s (14 turns)  ·  last reply 30.4s (gen 25.2s · think≈25.2s · tool 3.0s)

工作中(实时跳秒,中文显示):

⏱ 会话跨度 1h02m · 累计活跃 12.4s (3轮) · 本轮已耗时 5m37s · 生成 1.7s · 工具运行中 5m35s

工作中(实时跳秒,英文显示):

⏱ elapsed 1h02m · active time 12.4s (3 turns) · turn 5m37s · gen 1.7s · tool running 5m35s

逐回复标注行(每条 AI 输出下方一行灰色小字):

⏱ 生成 12.4s · 🔧 3 次工具调用                        ← 中间轮(带工具调用的 AI 输出)
⏱ 回复 45.2s · 🔧 37 次工具调用 (生成 12.4s)   ← 最终回复:回复总耗时 + 工具总次数 + 末轮生成耗时
⏱ gen 12.4s · 🔧 3 tool calls
⏱ reply 45.2s · 🔧 37 tool calls (gen 12.4s)

斜杠命令

所有命令在 pi 输入框输入,回车执行。

/timing — 开关 widget

/timing
  • 执行一次隐藏 widget,再执行一次显示。
  • 隐藏期间计时器照常运行,不会丢失任何数据。
  • 无确认提示,widget 直接消失/出现。

/timing list — 逐轮明细列表

/timing list

在 widget 内显示最近 20 轮,最新在前(中文显示):

#1 生成 575ms  思考≈9ms  工具 9ms
#2 生成 776ms  思考≈700ms  工具 0ms

英文显示:

#1 gen 575ms think≈9ms tool 9ms
#2 gen 776ms think≈700ms tool 0ms

再次执行 /timing list 隐藏列表。

/timing lang zh|en|auto — widget 语言

/timing lang zh     # 强制中文
/timing lang en     # 强制英文
/timing lang auto   # 恢复自动(默认)
  • auto(默认):初始取系统 locale,之后跟随你的消息语言(CJK 占比检测)。
  • auto 模式下,斜杠命令和过短的消息不会触发切换,避免误切。
  • 执行后屏幕底部会显示确认通知(如 timing language: en)。
  • 设置为内存态:重启 pi 后恢复 auto

/timing lines on|off — 逐回复标注行开关

/timing lines       # 切换
/timing lines off   # 关闭
/timing lines on    # 开启(默认)

每条 AI 输出下方追加一行灰色小字:中间轮显示本轮生成耗时与工具次数,最终回复额外显示回复总耗时(用户消息 → 回复完成)。语言在追加时定格(跟随发起该回复的消息语言)。开关为内存态(重启恢复 on);已写入的标注行保留在会话中。

术语对照

| 中文 | English | |---|---| | 会话跨度 | elapsed(墙钟,含空闲) | | 累计活跃 | active time(Σ生成 + Σ工具,不含空闲) | | 本轮已耗时 | turn | | 生成 / 生成中 | gen / generating | | 思考≈ | think≈(思考时间估算) | | 工具 / 工具运行中 | tool / tool running | | 上次回复 / 上次生成 | last reply / last gen |

时间格式

  • <1s500ms
  • <60s1.5s
  • <60m1m05s
  • <24h1h05m
  • >=24h1d03h

实现原理

  • message_start / message_end 事件计算生成耗时(思考结束点锚定流式的 thinking_end 事件)
  • tool_execution_start / tool_execution_end 计算工具墙钟(并行组只计一次)
  • 每轮最终回复后追加 timing-snapshot custom 条目,重启时恢复精确值(而非时间戳差估算)
  • timing-line custom 条目渲染逐回复标注行;在 turn_end 追加(此时最终 assistant 消息已落盘,标注行正好落在回复下方)
  • session_start / session_tree 从会话 JSONL 重算历史(/tree 分支用祖先链)
  • input 事件检测消息语言(CJK 占比)自动切换 widget 语言;初始值取系统 locale(Intl

开发

仓库结构:

pi-timing/
├── package.json              # pi-package 清单(pi install 用)
├── extensions/timing/index.ts  # 扩展本体
└── README.md / README.zh-CN.md

本地开发用软链接(改源码 → /reload 立即生效):

ln -s ~/.pi/dev/pi-timing/extensions/timing ~/.pi/agent/extensions/timing

如果之前用 pi install 装过包,先移除避免重复加载:

pi remove npm:pi-timing

许可证

MIT