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

dsh-new-api-model-sync

v1.0.0

Published

Sync a new-api model catalogue into DSH model entries

Readme

dsh-new-api-model-sync

把 new-api 的 GET /v1/models 清单,转成 DSH 的模型写法(providers.<provider>.models[]), 并直接写进当前配置档。

安装

插件市场(Discover)里搜 dsh-new-api-model-sync,点安装。或者:

dsh plugin --profile <你的 profile> add dsh-new-api-model-sync

装完重启 DSH,会话里多出工具 new_api_sync_models。

两种用法

1. 插件(会话里直接调)

new_api_sync_models()
new_api_sync_models({ apply: false })      // 只看 diff + YAML,不落盘
new_api_sync_models({ prune: true })       // 端点已下架的模型也一起删掉
new_api_sync_models({ provider: 'new-api', entryId: 'llm-pi-ai', baseURL: 'http://127.0.0.1:3000/v1' })

写入走 configEditor,只改 providers.<provider>.models 这一项,配置档里别的行、注释、!!js 都保留, 改完由 Loader 正常校验并生效,不用重启。

2. 命令行(不装插件也能用)

node cli.mjs                     # 打印可直接粘贴的 profile patch 片段
node cli.mjs --json              # 打印 models[] JSON
node cli.mjs --out models.patch.yml
node cli.mjs --prune --provider new-api --entry llm-pi-ai

API Key 解析顺序:--api-key → --api-key-env → 环境变量 NEW_API_API_KEY → ~/.dsh/.credentials.yaml。

字段映射

| new-api /v1/models | DSH 模型写法 | 说明 | | --- | --- | --- | | id | id | 必填,原样透传 | | name | name | 缺失时退回 id | | limit.context | contextWindow | 正整数才写 | | limit.output | maxTokens | 正整数才写 | | modalities.input | input: [text, image] | DSH 只认 text / image,video、pdf 丢弃 | | reasoning_options[].values(type: effort) | reasoningEfforts | none → off: null,其余同名透传 | | reasoning: false | reasoningEfforts: false | 明确关掉推理档位 | | compat 等手写字段 | 原样保留 | 合并时以新发现字段为准,其余键不丢 |

合并规则:发现到的模型按端点顺序排前面,同 id 的旧条目保留手写扩展键,但端点广告的字段(name、 contextWindow、maxTokens、input、reasoningEfforts)以端点为准覆盖; 端点没再返回的旧模型默认保留(prune: true 才删)。

entryId 三种写法都能命中运行期 Loader 行:llm-pi-ai、include:llm-pi-ai、 @deepseek-ai/dsh-llm-pi-ai。预览(apply: false)会报 added / removed / kept / changed 四类计数,changed 列出字段会被改写的模型 id。

配置项

cordis.patch.yml 里的 config:

| 键 | 默认值 | 作用 | | --- | --- | --- | | baseURL | http://127.0.0.1:3000/v1 | 端点根,带不带 /v1 都行 | | apiKeyEnv | NEW_API_API_KEY | 凭据引用名(走 credentials 服务解析) | | provider | new-api | pi-ai 行里的 provider key | | entryId | llm-pi-ai | 承载 providers 的 Loader 行 id | | prune | false | 是否删除端点已下架的模型 | | write | true | 是否落盘(false 只报告) |

兼容性

engines.dsh 声明 >=0.2.1-rc.1 <0.3.0。低于 0.2.1 的 DSH 没有 configEditor,写入会失败, 但 apply: false 的预览和命令行仍然可用。

文件

  • core.js — 纯函数:mapModel / mapModels / mergeModels / renderPatchSnippet / fetchModels
  • index.js — Host 插件,注册 new_api_sync_models
  • cli.mjs — 命令行
  • market/index.json — 插件市场索引条目,随包发布

许可

MIT