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

@lykling/pi-bash-timeout

v0.1.0

Published

Default timeout for bash tool calls in the Pi coding agent: fills in a timeout when the model omits one and tells the model how to recover from timeouts and aborts.

Readme

@lykling/pi-bash-timeout

Pi coding agent 的 bash 默认超时扩展:模型调用 bash 工具没传 timeout 时自动补一个默认值, 并在命令到点中止或被用户中断之后,告诉模型该怎么收尾。

为什么需要

pi 的 bash 工具没有默认超时——模型不传 timeout,这次调用就一直等到命令自己退出。 工具执行期间模型不被调用,所以一条跑飞的命令只有 harness 能打断,而 harness 默认不会打断。 典型例子是整读 /proc/kcore 这种表观大小上百 TiB 的伪文件:读上几个小时也读不到有效内容。

安装

pi install npm:@lykling/pi-bash-timeout

然后 /reload(或重启 pi)。

行为

| 钩子 | 作用 | |---|---| | tool_call | bash 调用没传 timeout 时注入默认值;模型显式传了则以模型为准 | | before_agent_start | 在系统提示里声明这个默认值,让模型提前改成后台运行或显式传超时 | | tool_result | bash 结果为「超时」或「被中断」时,在结果末尾追加一段处置提示;超时且默认值是本扩展注入的,还会注明生效的秒数和来源 |

处置提示的内容:

  • 超时:先判断是卡死或代价失控,还是任务本来就需要更久。前者换有界的做法,不要原样重跑; 后者改成后台运行再轮询日志(nohup … > x.log 2>&1 &),或显式传更大的 timeout。
  • 被用户中断:这是用户的明确意图,不要自行重跑,先等用户指示。
  • 两种情况都提醒:sudo 起的 root 进程不会被 pi 杀掉,要用 pgrep -af 查残留、sudo -n pkill -f 清理。

配置

默认超时按下面的优先级解析,配置文件为主,环境变量只是兜底。每次 bash 调用时重新解析,改完文件不需要 /reload。

| 优先级 | 来源 | 说明 | |---|---|---| | 1 | <项目>/.pi/bash-timeout.json | 仅受信项目生效,支持 JSONC 注释 | | 2 | ~/.pi/agent/bash-timeout.json | 全局,支持 JSONC 注释 | | 3 | PI_BASH_DEFAULT_TIMEOUT | 环境变量,单位秒 | | 4 | 内置默认 | 600 秒 |

配置文件只有一个字段:

// ~/.pi/agent/bash-timeout.json
{
  "defaultTimeoutSeconds": 600 // 正整数 = 秒数;null 或 0 = 关闭
}

环境变量 PI_BASH_DEFAULT_TIMEOUT:正整数 = 秒数;0 / off / 空 = 关闭。

某个来源的值不合法(不是正整数,或超过 pi 的上限 2147483 秒)时跳过它,用下一个来源。 命令到点中止时,追加的提示末尾会写明这次生效的秒数和来源,例如「本次默认超时 600 秒,来源:default」, 配置没生效时靠它排查。

已知限制

  • pi 以启动它的用户身份运行,超时和中断只是向进程组发 SIGKILL,杀不掉 sudo 起的 root 进程。 需要 sudo 的命令请写成 sudo -n timeout -k 5 <秒> <命令…>,让 root 一侧自己到点退出。
  • 会话记录里保存的是模型发出的原始参数(不含注入的 timeout);实际生效值以工具结果里的 Command timed out after N seconds 为准。
  • 只管 bash 工具,PowerShell 工具不涉及。

开发

npm ci
npm run typecheck
npm test

发布走 GitHub Actions 的 npm trusted publishing:npm version patch 之后 push 提交和 tag, CI 跑完 typecheck 和测试再发布。

License

MIT