Dependency Autopsy — 依赖树深度健康分析
v1.0.0对依赖树进行深度健康分析,不仅检查是否过时,还评估维护者是否活跃、依赖是否被废弃、包体积是否臃肿、是否存在许可证风险等,帮助开发者全面了解生产环境中依赖的真实健康状况。
详细分析 ▾
运行时依赖
版本
首次发布
安装命令 点击复制
技能文档
"Every dependency is a bet: you're betting that someone you've never met will maintain code you've never read for as long as you need it. How much do you actually know about those bets?"
它做什么
npm audit 告诉你已知的漏洞。npm outdated 告诉你版本漂移。两者都不能告诉你真正重要的事情:
- 维护者是否仍在积极开发?
- 上次有意义的提交是什么时候(不仅仅是 CI 配置调整)?
- 这个包的 14,000 行代码你实际使用了多少?
- 如果这个包明天消失,更换有多难?
- 这个包是否为了一个工具函数引入了 47 个传递依赖?
- 这个包的 bus factor 是否 literally 是 1?
Dependency Autopsy 对你树中的每个依赖执行完整健康检查并生成风险调整后的报告。
尸检报告卡
每个依赖都会收到七项生命体征的健康评分:
生命体征 1:脉搏(活跃度)
这个项目还活着吗?
| 信号 | 健康 | 警告 | 危险 |
|---|---|---|---|
| 上次有意义的提交 | < 3 个月 | 3-12 个月 | > 12 个月 |
| 开放 issue 响应时间 | < 1 周 | 1-4 周 | > 4 周或从不 |
| 发布频率 | 规律 | 放缓 | 停止 |
| CI 状态 | 通过 | 不稳定 | 失败或缺失 |
| 无人 review 的开放 PR | < 5 | 5-20 | > 20 |
"Last meaningful commit" means a commit that changes source code. Dependency bumps, CI tweaks, and README updates don't count. A project can look active while being effectively abandoned.
生命体征 2:Bus Factor(维护者健康)
有多少人需要消失这个项目才会死亡?
| 信号 | 健康 | 警告 | 危险 |
|---|---|---|---|
| 独立提交者(过去一年) | > 5 | 2-5 | 1 |
| 有组织所有权(非个人) | 是 | - | 否(个人仓库) |
| 有多个 npm/PyPI 发布者 | 是 | - | 否(单一发布者) |
| 企业支持 | 是 | 非正式 | 无 |
| 继任计划可见 | 是 | 不清楚 | 否 |
生命体征 3:膨胀因子(重量)
这个包你实际使用了多少?
ANALYSIS:
├── Total package size: 2.4 MB
├── Exports used by your code: 3 of 147 (2%)
├── Tree-shakeable: No
├── Transitive dependencies: 23
├── Transitive dependencies YOU also use directly: 2
│ └── (the other 21 exist solely because of this package)
├── Estimated bundle impact: +340 KB
└── Could be replaced with: ~30 lines of codeVERDICT: You imported an aircraft carrier to cross a creek.
生命体征 4:替换难度
如果这个依赖今天消失,换掉有多难?
| 难度 | 描述 | 示例 |
|---|---|---|
| trivial | 存在即插即用的替代品,或者你可以内联代码 | left-pad → 1 行代码 |
| Easy | 存在替代品但有轻微 API 差异 | moment → date-fns(有完善文档的迁移) |
| Moderate | 存在替代品但需要实质性重构 | Express → Fastify(不同的中间件模型) |
| Hard | 很少有替代品,已深度集成 | React → Vue(重写) |
| Critical | 没有替代品,深度嵌入,你被锁定 | Terraform → ?(供应商锁定) |
生命体征 5:版本健康
你的版本是当前的吗,升级安全吗?
ANALYSIS:
├── Your version: 3.2.1
├── Latest stable: 5.1.0
├── Versions behind: 2 major, 0 minor
├── Breaking changes between yours and latest: 14
├── Deprecated APIs you use: 3 (removed in v4+)
├── Security patches you're missing: 1 (medium severity)
├── Estimated upgrade effort: 8 hours
└── Risk of staying: Medium (deprecated APIs may break with Node upgrade)
生命体征 6:许可证健康
你法律上安全吗?
ANALYSIS:
├── Direct dependency license: MIT ✓
├── Transitive dependency licenses:
│ ├── MIT: 19 packages ✓
│ ├── Apache-2.0: 3 packages ✓
│ ├── ISC: 1 package ✓
│ └── GPL-3.0: 1 package ⚠ (copyleft — may require your code to be GPL)
└── License compatibility with your project: WARNING — GPL transitive dep
生命体征 7:依赖深度
兔子洞有多深?
YOUR PACKAGE
└── dependency-a (you chose this)
├── dep-a-1 (you didn't choose this)
│ ├── dep-a-1-1 (you definitely didn't choose this)
│ │ └── dep-a-1-1-1 (nobody chose this)
│ └── dep-a-1-2
├── dep-a-2
└── dep-a-3
└── dep-a-3-1
└── dep-a-3-1-1
└── dep-a-3-1-1-1 (8 levels deep. Welcome to JavaScript.)STATS:
├── Direct dependencies you chose: 24
├── Total dependency tree: 847 packages
├── Maximum depth: 11 levels
├── Packages with 0 weekly downloads: 3 (why do these exist?)
├── Packages last published > 3 years ago: 12
└── Packages with install scripts (potential risk): 2
完整尸检报告
╔══════════════════════════════════════════════════════════════╗
║ DEPENDENCY AUTOPSY ║
║ 24 direct / 847 total dependencies ║
║ Overall Health: B+ (Good, with concerns) ║
╠══════════════════════════════════════════════════════════════╣
║ ║
║ CRITICAL FINDINGS (2): ║
║ ├── 🔴 image-tools@1.3.0 ║
║ │ ├── Pulse: DEAD (last commit 26 months ago) ║
║ │ ├── Bus Factor: 1 (personal GitHub repo) ║
║ │ ├── You use: 1 of 23 functions (4%) ║
║ │ ├── Known vulns: 1 (high — prototype pollution) ║
║ │ └── RECOMMENDATION: Replace with sharp (actively ║
║ │ maintained, covers your use case). ~2h effort. ║
║ │ ║
║ │── 🔴 GPL-3.0 license found in transitive dependency ║
║ │ ├── Package: obscure-xml-parser@0.1.2 ║
║ │ ├── Required by: dep-a → dep-a-1 → obscure-xml-parser ║
║ │ └── RECOMMENDATION: Confirm GPL compatibility or find ║
║ │ alternative XML parser in dep-a-1. ║
║ ║
║ WARNINGS (4): ║
║ ├── 🟡 lodash@4.17.21 — you use 3 functions. Consider ║
║ │ individual imports or native replacements (-340KB). ║
║ ├── 🟡 auth-lib@2.1.0 — 2 major versions behind. ║
║ │ 3 deprecated APIs in your code. Upgrade: ~8h. ║
║ ├── 🟡 date-formatter@3.0.0 — bus factor 1, slowing pulse. ║
║ │ Consider date-fns as insurance. ║
║ └── 🟡 config-parser@1.0.0 — pulls 21 transitive deps ║
║ for a 40-line utility. Consider inlining. ║
║ ║
║ HEALTHY (18): ║
║ All vitals green. Active maintenance, healthy bus factor, ║
║ appropriate usage, compatible licenses. ║
║ ║
║ TREE STATS: ║
║ ├── Duplicate packages (different versions): 7 ║
║ ├── Total install size: 148 MB ║
║ ├── Estimated used code: 12 MB (8% of installed) ║
║ └── Potential size reduction: 89 MB (remove bloat + dupes) ║
╚══════════════════════════════════════════════════════════════╝
何时调用
- 添加新依赖之前 — 在你
npm install之前进行完整尸检 - 每月对现有依赖进行健康检查
- 在评估是否升级或替换库时
- 在安全审计或合规审查之前
- 在调查意外的 bundle 大小增长时
- 在任何
npm audit报告之后(深入了解不仅仅是 CVE 编号)
为什么重要
平均 JavaScript 项目有 800+ 个传递依赖。平均 Python 项目有 40+ 个。每一个都是你没有编写、没有审查、且无法控制的代码——以与你的代码相同的权限运行。
npm audit 告诉你已知的漏洞。Dependency Autopsy 告诉你可能未来的问题——被废弃的项目、单维护者风险、许可证雷区和膨胀。
尚未发现的漏洞存在于没有人关注的包中。
零外部依赖。零 API 调用。纯包清单和注册表分析。
免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制