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

v0.1.0

Published

Auto-discover OpenAI-compatible gateway models for pi (independent of models.json)

Readme

pi-autoprovider

models.json 之外的独立 provider 配置文件,支持从 OpenAI 兼容网关 GET {baseUrl}/models 自动发现模型列表。

安装

pi install git:github.com/dbydd/pi-autoprovider

仓库只含扩展代码。网关地址和 key 放在你本地的 autoprovider.json 里, 不会进仓库。

配置文件

| 层级 | 路径 | |------|------| | 全局 | <agentDir>/autoprovider.jsonagentDir = getAgentDir(),跟随 PI_CODING_AGENT_DIR) | | 项目 | <cwd>/.pi/autoprovider.json,从 cwd 向上遍历到 $HOME,由外向内逐层深合并 |

项目层只在项目受信任时加载(ctx.isProjectTrusted()),/reload 会触发 resources_discover 事件,扩展自动重载。

最小配置示例(~/.pi/agent/autoprovider.json):

{
  "defaults": {
    "baseUrl": "http://localhost:3000/v1",
    "apiKey": "$GATEWAY_API_KEY"
  },
  "providers": {
    "axonhub": { "api": "openai-responses", "discover": true }
  }
}

变量展开

  • ${PI_AGENT_DIR} / ${PI_HOME}getAgentDir()(如 ~/.pi/agent
  • ${PI_CODING_AGENT_DIR}$VAR${VAR}process.env
  • 行首 ~$HOME
  • 解析失败的变量保持原样,apiKey$VAR / !command 语义由 pi 在请求时处理。
  • 配置文件支持 // 整行注释。

合并规则

对象递归合并,标量与非 models 数组直接覆盖, providers.<id> 按 provider id 合并,providers.<id>.models 按 model id upsert。 defaults 作为所有 provider 的基线。

Schema

{
  "defaults": {
    "baseUrl": "http://localhost:3000/v1",
    "apiKey": "ah-...",
    "timeoutMs": 10000,          // 发现请求超时
    "refreshIntervalMs": 3600000,// 刷新 TTL(refreshModels / 重建时生效)
    "modelDefaults": {
      "reasoning": true,
      "input": ["text"],
      "contextWindow": 262144,
      "maxTokens": 128000
    }
  },
  "providers": {
    // 路由型:空对象 = 继承 defaults,把内置 catalog 走网关(等价于 models.json 只写 baseUrl/apiKey)
    "anthropic": {},
    // 发现型:自动拉取网关模型 + 静态条目按 id 覆盖元数据
    "axonhub": {
      "api": "openai-responses",
      "discover": {
        "endpoint": "/models",      // 缺省为 baseUrl + /models,绝对 URL 也可
        "query": ["include=all"],   // 缺省即 include=all;设 includeMeta:false 关掉
        "owners": ["configured"],   // 按 /v1/models 的 owned_by 过滤(可选)
        "include": ["^gpt-"],       // id 正则白名单(可选)
        "exclude": [":free$"]       // id 正则黑名单,优先于 include
      },
      "models": [
        { "id": "supercheap", "input": ["text", "image"], "contextWindow": 1048576 }
      ]
    },
    // 关闭某个 provider(恢复内置):{ "enabled": false }
  }
}

discover: true 为简写(默认 endpoint,?include=all,全部模型)。 meta 映射:context_length→contextWindow、max_output_tokens→maxTokens、 modalities.input→input(仅识别 image,其余归 text)、 capabilities.reasoning→reasoning、pricing→cost。无 meta 的条目回退到 modelDefaults。 静态 models 条目支持 name / reasoning / thinkingLevelMap / input / cost / contextWindow / maxTokens / api / headers / compat / samplingParams, 未在网关列表里的静态 id 会保留(网关故障时的 fallback 语义)。 优先级:手写 > 网关 meta > 内置/pi 默认。

命令

  • /autoprovider:状态(provider 模型数、上次刷新)
  • /autoprovider reload:重读配置文件并重建全部 provider
  • /autoprovider refresh [name...]:强制忽略 TTL 重新发现

License

MIT