license checker
npx skills add https://github.com/digitalspeed/ai-skills --skill 'License Checker'
Skill 文档
License Checker
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.
1. Execution Workflow
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
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.
2. Output Format
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]