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-agent-reload

v0.1.2

Published

Let a Pi agent request a runtime reload through a single tool.

Readme

↻ Pi Reload

让 agent 自己重载 Pi。一个工具,没有多余功能。

npm Pi extension License: MIT

修改扩展、技能或提示词之后,直接让 agent 请求 /reload。

安装 · 使用 · 工作原理 · 开发与发布


安装

从 GitHub 安装

pi install git:github.com/LIghtJUNction/pi-reload

从 npm 安装

pi install npm:pi-agent-reload

首次安装后,手动执行一次 /reload,或重启 Pi。 插件必须先加载,agent 才能使用它。

在克隆下来的项目目录中:

# 持久安装
pi install .

# 仅为一次新会话加载
pi -e ./extensions/reload.ts

使用

告诉 agent:

调用 reload_runtime,重新加载 Pi。

插件提供一个不需要参数的工具:reload_runtime。

  • 重载:扩展、技能、提示词、主题和上下文文件。
  • 不做:重启进程、升级 Pi、安装依赖、监控文件或执行 shell 命令。
  • 不自动触发:由 agent 按需调用。

工作原理

使用 Pi 1.4.0 的空闲事件和扩展命令 API:

agent 调用 reload_runtime
          │
          ▼
记录请求,等待 agent_settled
          │
          ▼
显式解析扩展命令 /agent-reload-runtime
          │
          ▼
Pi 处理命令 → await ctx.reload()
          │
          ▼
新运行时加载,旧上下文不再使用

工具上下文没有命令专用的 ctx.reload(),因此插件使用一个内部命令桥接,不模拟键盘、不操作终端。

必须等到 agent_settled 再发送命令,并指定 expandPromptTemplates: true:默认发送行为会把 /命令 当作普通模型消息,执行中直接解析命令则会被 Pi 的忙碌检查拒绝。Pi 会将空闲事件内发送的命令延后到事件处理结束再执行。多次请求合并为一次;中止当前运行会取消待处理重载。

已排队 ≠ 已完成。 工具返回只确认重载请求已记录,以 Pi 实际重载结果为准。agent 必须结束回复,让运行进入空闲状态;继续调用工具不会触发这次重载。需要使用新加载的工具时,等重载完成后再发一条消息。

开发与发布

本地验证

测试需要 Node.js 22.18+,使用 Node 原生 TypeScript 类型擦除能力,无需编译器。

npm ci --ignore-scripts --legacy-peer-deps
npm test
npm pack --dry-run

8 项单元测试覆盖注册、延迟调度、显式命令解析、请求合并、中止取消、等待重载及错误传播。它们模拟 Pi API,不替代真实会话中的交互重载验证。

自动发布

GitHub Actions 仅在推送 v* 版本标签或手动触发时运行,不为日常 push / PR 启动 CI。TypeScript 源码由 Pi 直接加载,不需要编译;发布流程会测试、检查包内容,再发布 npm 并创建 GitHub Release。

首次发布前,维护者需要完成 npm 身份配置,详见 发布指南。

# 工作区保持干净;本地测试通过后更新版本并创建标签
npm version patch

# 将对应提交和标签一起推送,触发发布
git push --atomic origin main --follow-tags

安装后不会在后台自行更新。需要更新时使用 Pi 的包管理命令:

pi update --extensions

标签固定版本不会自动移动到新版。

License

MIT