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

@wbline/pi-dynamic-models

v0.1.1

Published

Dynamic model discovery for Pi coding agent — fetches models from any configured API server at startup

Readme

pi-dynamic-models

pi install npm:@wbline/pi-dynamic-models

Pi 会把包记录到 ~/.pi/agent/settings.json,并自动启用其中声明的扩展。仅 npm install -g 不会激活 Pi 扩展。

pi 提供动态模型发现能力。启动时从配置的 OpenAI 兼容服务器拉取模型列表与元数据,自动注册为可选 provider——无需手动维护模型清单。

配置

1. 安装包

在 Pi agent 设置(~/.pi/agent/settings.json)中添加:

{
  "packages": [
    "local:/path/to/playbook/packages/pi-dynamic-models"
  ]
}

2. 创建配置文件

创建 ~/.pi/agent/pi-dynamic-models.json

[
  {
    "provider": "my-provider",
    "baseUrl": "https://your-server.com/v1",
    "apiKey": "your-api-key",
    "api": "openai-completions"
  }
]

字段说明

| 字段 | 必填 | 说明 | |------|------|------| | provider | ✓ | 在模型选择器中显示的名称 | | baseUrl | ✓ | 服务器地址,如需要请包含 /v1 | | apiKey | | 字面量密钥、环境变量名或 $ENV_VAR。开放服务器可省略或设为 "none"。 | | api | | Pi API 类型(默认:openai-completions)。 |

支持的 API 类型

| 值 | 适用场景 | |----|----------| | openai-completions | Ollama、vLLM、LM Studio、llama.cpp 及大多数本地服务器 | | openai-responses | 兼容 OpenAI Responses API 的服务器 | | anthropic-messages | 兼容 Anthropic 的代理 | | google-generative-ai | 兼容 Google AI 的服务器 | | azure-openai-responses | Azure OpenAI |

工作原理

启动时对每个 provider 并行请求:

  1. GET {baseUrl}/models — 模型 ID 列表
  2. GET {baseUrl}/metas — 模型元数据

/metas 支持如下响应格式:

{
  "object": "list",
  "data": [
    {
      "id": "example-model",
      "object": "meta",
      "owned_by": "relay",
      "context_window": 524288,
      "max_tokens": 65536,
      "input": ["text", "image"]
    }
  ]
}

字段映射:

| metas 字段 | 模型字段 | 缺省 | |------------|----------|------| | id | id | — | | name | name | 回退为 id | | context_window | contextWindow | 128000 | | max_tokens | maxTokens | 16384 | | input | input | ["text"] | | reasoning | reasoning | false | | thinking_level_map | thinkingLevelMap | 不传 | | cost | costcache_readcacheRead 等) | 全 0 |

两个端点的职责不同:只有 /models 成功才会注册该 provider/metas 仅作补充——命中列表中模型时覆写元数据,未命中则忽略,失败也不影响注册(对应字段使用默认值)。

故障排查

模型列表为空:确认配置文件位于 ~/.pi/agent/pi-dynamic-models.json,且 {baseUrl}/models{baseUrl}/metas 可访问。

API 行为异常:为服务器类型设置正确的 api 字段。

API key 未解析:支持裸环境变量名(如 CLINE_API_KEY)与 $CLINE_API_KEY / ${CLINE_API_KEY} 写法;也可直接写字面量密钥。

contextWindow 始终为 128000:确认 /metas 中对应模型带有非空的 context_window