ZhijiangTang/dsh-pkg-info0

dsh-pkg-info

DSH 插件:从 npm 和 PyPI 注册表查询包元数据的工具。

AI 分析

核心用途是快速获取指定 npm 或 Python 包的版本、依赖、许可证等元数据。适合需要进行依赖分析、包版本核对的软件开发和维护任务。

包名
dsh-pkg-info
版本
0.1.1
许可证
MIT
最近更新
2026年8月16日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:ZhijiangTang/dsh-pkg-info

dsh-pkg-info

DSH 包信息查询工具插件。注册一个 pkg_info 工具,查询 npmPyPI 两个 registry 的包元数据,把结果规范化为一个结构化 JSON 对象,供模型与 Code Mode 程序化调用。零依赖、纯 ESM、无构建

简介

  • 工具名:pkg_info
  • 能力:查询 npm 包(registry.npmjs.org)与 PyPI 包(pypi.org)的名称、版本、描述、许可证、作者、主页、仓库、版本数、依赖等信息。
  • 行为:永不抛异常。404、网络错误、超时、JSON 解析失败都折叠为 { ok: false, error: { stage, message?, status? } };成功返回 { ok: true, registry, name, version, ... }

安装

dsh plugin --profile  add file:./plugins/dsh-pkg-info
# 或发布后:
dsh plugin --profile  add dsh-pkg-info

参数

参数类型必填默认说明
registryenumnpmnpm / pypi,选择要查询的 registry
namestring包名。npm 作用域包写 @scope/name;PyPI 项目名大小写不敏感
versionstringlatest指定版本(npm 也支持 dist-tag 如 latest/next);缺省查最新版

返回字段

npm(registry: "npm"

字段类型说明
ok / registry / name / versionboolean/string状态、registry、规范包名、解析到的版本
descriptionstring | null包描述
licensestring | nullSPDX 许可证(对象/数组会被规范成字符串)
authorstring | null作者,规范为 "name "
homepagestring | null主页 URL
repositorystring | null仓库 URL
distTagsobjectdist-tags 映射(如 { latest: "2.7.0", ... }
created / modifiedstring | nulltime 字段的创建/修改时间(ISO 8601)
versionsCountinteger已发布版本数
dependenciesobject | null该版本的 dependencies
peerDependenciesobject | null该版本的 peerDependencies

PyPI(registry: "pypi"

字段类型说明
ok / registry / name / versionboolean/string状态、registry、规范项目名、解析到的版本
summarystring | null项目摘要(info.summary
licensestring | null许可证(info.license,空串归一为 null)
authorstring | null作者(info.author
home_pagestring | null主页 URL(info.home_page
releasesCountinteger发布版本数(releases 键数)
requiresDiststring[] | null该版本的 requires_dist 依赖列表

失败(ok: false

{ ok: false, registry, name, error: { stage: 'http'|'request'|'parse', message?, status? } }

  • 404:{ stage: 'http', status: 404 }
  • 网络/超时(10s):{ stage: 'request', message }
  • JSON 解析失败:{ stage: 'parse', message }

示例

// 查 npm 最新版
{ "registry": "npm", "name": "yaml" }
// 查 npm 指定版本
{ "registry": "npm", "name": "yaml", "version": "2.5.0" }
// 查 PyPI 最新版
{ "registry": "pypi", "name": "requests" }
// 查 PyPI 指定版本
{ "registry": "pypi", "name": "requests", "version": "2.28.1" }

License

MIT