npx skills add https://github.com/digitalspeed/ai-skills --skill license-checker扫描 node_modules 中的所有包并生成许可证合规性报告。切勿将原始文件内容读入上下文——首先使用 bash 进行模式匹配;仅缓冲无法简化的未知集合。
步骤 1 — 批量解析(单次 bash 调用,处理作用域包,上下文中零文件读取):
SPDX='MIT|ISC|BSD-[0-9]+-Clause|Apache-2\.0|GPL-[23]\.0(-only|-or-later)?|LGPL-[23]\.0|AGPL-3\.0|MPL-2\.0|Unlicense|CC0-1\.0|CDDL-1\.[01]|EPL-[12]\.0|EUPL-1\.[12]'
find node_modules -mindepth 2 -maxdepth 3 -name 'package.json' \
! -path '*/.bin/*' ! -path '*/node_modules/*/node_modules/*' | while read pjson; do
dir=$(dirname "$pjson")
row=$(jq -r '[.name, .version, (.license // (.licenses | if type=="array" then map(.type//"") | join(" OR ") else (.//"") end) // ""), (.repository.url // .repository // "")] | @tsv' "$pjson" 2>/dev/null)
lic=$(printf '%s' "$row" | cut -f3)
if [ -z "$lic" ]; then
lfile=$(find "$dir" -maxdepth 1 \( -iname 'license*' -o -iname 'licence*' -o -iname 'copying*' \) 2>/dev/null | head -1)
match=$(grep -iom1 -E "$SPDX" "$lfile" 2>/dev/null | head -1)
if [ -n "$match" ]; then
printf '%s\t%s*\tgrep\n' "$(printf '%s' "$row" | cut -f1-2,4)" "$match"
else
printf '%s\tUNKNOWN\t—\n' "$(printf '%s' "$row" | cut -f1-2,4)"
fi
else
printf '%s\tpackage.json\n' "$row"
fi
done
输出为 TSV 格式:。许可证为 的行进入步骤 2。
Scan all packages in node_modules and produce a license compliance report. Never read raw file contents into context — use bash to pattern-match first; only buffer the irreducible unknown set.
Step 1 — Bulk resolve (single bash call, handles scoped packages, zero file reads in context):
SPDX='MIT|ISC|BSD-[0-9]+-Clause|Apache-2\.0|GPL-[23]\.0(-only|-or-later)?|LGPL-[23]\.0|AGPL-3\.0|MPL-2\.0|Unlicense|CC0-1\.0|CDDL-1\.[01]|EPL-[12]\.0|EUPL-1\.[12]'
find node_modules -mindepth 2 -maxdepth 3 -name 'package.json' \
! -path '*/.bin/*' ! -path '*/node_modules/*/node_modules/*' | while read pjson; do
dir=$(dirname "$pjson")
row=$(jq -r '[.name, .version, (.license // (.licenses | if type=="array" then map(.type//"") | join(" OR ") else (.//"") end) // ""), (.repository.url // .repository // "")] | @tsv' "$pjson" 2>/dev/null)
lic=$(printf '%s' "$row" | cut -f3)
if [ -z "$lic" ]; then
lfile=$(find "$dir" -maxdepth 1 \( -iname 'license*' -o -iname 'licence*' -o -iname 'copying*' \) 2>/dev/null | head -1)
match=$(grep -iom1 -E "$SPDX" "$lfile" 2>/dev/null | head -1)
if [ -n "$match" ]; then
printf '%s\t%s*\tgrep\n' "$(printf '%s' "$row" | cut -f1-2,4)" "$match"
else
printf '%s\tUNKNOWN\t—\n' "$(printf '%s' "$row" | cut -f1-2,4)"
fi
else
printf '%s\tpackage.json\n' "$row"
fi
done
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
名称 版本 许可证 仓库UNKNOWN步骤 2 — 仅对剩余未知项进行 LLM 推断: 对于每个 UNKNOWN 包,读取其许可证文件(如果没有则读取 README)的前 500 个字符。应用:
仅 SPDX 标识符。如果是从文件推断(非 package.json),则附加 *。文本:
[500 字符缓冲区]
步骤 3 — 生成报告,使用第 2 节中的格式。
按 名称@版本 字母顺序排序的树形格式。许可证后的 * 后缀表示它是从文件推断出来的,而非来自 package.json。
├─ lodash@4.17.21
│ ├─ 仓库: https://github.com/lodash/lodash
│ └─ 许可证: MIT
├─ some-lib@1.2.0
│ ├─ 仓库: https://github.com/some/lib
│ └─ 许可证: GPL-3.0*
└─ ghost-pkg@1.0.0
└─ 许可证: UNKNOWN
如果 仓库 字段为空,则省略该行。除最后一项外,所有条目使用 ├─,最后一项使用 └─。子字段始终使用 │ ├─ / │ └─(或在 └─ 父项下使用 ├─ / └─)。
树形图后的摘要行:
已扫描: N | 已确认: N | 已推断 (*): N | 未知: N
⚠️ 著佐权许可证: [包含 GPL / LGPL / AGPL / MPL / EUPL 许可证的包]
每周安装量
1
仓库
首次出现
11 天前
安全审计
安装于
amp1
cline1
opencode1
cursor1
continue1
kimi-cli1
Output is TSV: name version license repository. Rows where license is UNKNOWN proceed to step 2.
Step 2 — LLM inference for residual unknowns only: For each UNKNOWN package, read the first 500 chars of its license file (or README if absent). Apply:
SPDX ID only. Append * if inferred from file (not package.json). Text:
[500-char buffer]
Step 3 — Render report using the format in §2.
Tree format sorted alphabetically by name@version. An * suffix on a license means it was inferred from a file, not package.json.
├─ lodash@4.17.21
│ ├─ repository: https://github.com/lodash/lodash
│ └─ licenses: MIT
├─ some-lib@1.2.0
│ ├─ repository: https://github.com/some/lib
│ └─ licenses: GPL-3.0*
└─ ghost-pkg@1.0.0
└─ licenses: UNKNOWN
Omit the repository line if the field is empty. Use ├─ for all entries except the last, which uses └─. Sub-fields always use │ ├─ / │ └─ (or ├─ / └─ under a └─ parent).
Summary line after the tree:
Scanned: N | Confirmed: N | Inferred (*): N | Unknown: N
⚠️ Copyleft: [packages with GPL / LGPL / AGPL / MPL / EUPL licenses]
Weekly Installs
1
Repository
First Seen
11 days ago
Security Audits
Installed on
amp1
cline1
opencode1
cursor1
continue1
kimi-cli1
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
109,600 周安装