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-models-discovery

v1.1.0

Published

Pi extension: discover models from {baseUrl}/models for providers marked with discoverModels in models.json

Readme

pi-models-discovery

通用模型发现插件:读取 ~/.pi/agent/models.json 中带 "discoverModels": true 的 provider,请求 GET {baseUrl}/models 自动发现模型并注册,无需手写 models 数组。首次发现成功后模型列表持久化到本地缓存,之后每次启动直接读缓存,不再请求网络

适合本地/自建 LLM 代理(一个网关暴露多个模型)、Ollama、vLLM 等 OpenAI 兼容服务。

安装

pi install npm:pi-models-discovery

配置

方式一:pi 终端内交互配置(推荐)

/config:model-discovery

交互式添加 / 删除 / 重新发现 provider:输入 id、baseUrl、api 类型、apiKey(可留空)、显示名(可留空),确认后写入 models.json 并立即生效(无需 /reload)。写入前自动备份到 models.json.discovery-bak

注意:写回时 models.json 中的注释与自定义排版不被保留(会格式化为 4 空格缩进)。

方式二:手编 models.json

~/.pi/agent/models.json 的 provider 上加 "discoverModels": true 标记:

{
  "providers": {
    "llm-proxy": {
      "name": "LLM Proxy",
      "baseUrl": "http://127.0.0.1:9000/pi/v1",
      "apiKey": "sk-1234",
      "api": "openai-completions",
      "discoverModels": true
    }
  }
}

baseUrlapi 必填;apiKey 可选(无鉴权服务可省略)。同一 baseUrl+apiKey 的多个 provider 共享一次 /models 请求。

手编方式修改配置后需 /reload 生效;/config:model-discovery 命令的修改立即生效。

刷新缓存

/config:model-discovery-refresh

强制重新拉取所有发现 provider 的模型列表并更新本地缓存,逐个 notify 结果。

行为

  • 启动(缓存优先):缓存命中时直接用持久化的模型列表注册,零网络请求;缓存文件位于 ~/.pi/agent/extensions/pi-models-discovery/cache.json。provider 配置指纹(baseUrl+api+apiKey+headers+compat)变化时缓存自动失效,重新走网络发现。
  • 在线刷新/config:model-discovery-refresh/model 打开时触发的 refreshModels 在线重新发现,并同步更新缓存。
  • 离线 / 拉取失败:保留 models.json 里手写的 models(如有,作为回退),并通过会话内 notify 显式警告,不静默降级;单个 provider 失败不影响其他 provider。
  • apiKey 解析(仅发现请求):支持字面量与 $ENV_VAR / ${ENV_VAR} 插值;!command 形式跳过发现并显式警告(聊天请求仍由 pi 自身解析执行,不受影响)。
  • 发现的模型默认参数:reasoning: trueinput: ["text", "image"]、cost 全 0、contextWindow 1M、maxTokens 64K、compat.supportsDeveloperRole: false;provider 级 compat 会合并进每个发现的模型。
  • 模型元数据可携带 name / context_window(或 contextWindow)/ max_tokens(或 maxTokens),缺失时用默认值。

旧的 /model-discovery/model-discovery-refresh/pi-model-discovery/pi-model-discovery-refresh 名称仍作为兼容别名保留。

卸载

pi remove pi-models-discovery

卸载后 provider 回退为 models.json 中的静态配置(手写 models 或空)。