diff --git a/content/docs/tools/_index.md b/content/docs/tools/_index.md index 07d655c..d216f7e 100644 --- a/content/docs/tools/_index.md +++ b/content/docs/tools/_index.md @@ -10,6 +10,7 @@ Standalone tools built alongside git-pkgs. Each is a single binary (or workflow) - **pin** vendors browser assets without npm - **outline** reduces a source tree to a structural skeleton for LLMs - **capcheck** fails CI when Go code gains new privileged capabilities +- **licenses** scans repositories for license text against ScanCode's rule corpus - **distill** trains an oss-taxonomy classifier from an LLM-labelled corpus - **actions** are reusable GitHub Actions wrapping git-pkgs commands - **skills** is a Claude Code plugin exposing git-pkgs as agent skills @@ -20,6 +21,7 @@ Standalone tools built alongside git-pkgs. Each is a single binary (or workflow) {{< card link="pin" title="pin" subtitle="Browser asset vendoring" >}} {{< card link="outline" title="outline" subtitle="Source tree compression" >}} {{< card link="capcheck" title="capcheck" subtitle="Go capability drift" >}} + {{< card link="licenses" title="licenses" subtitle="License text scanning" >}} {{< card link="distill" title="distill" subtitle="oss-taxonomy classifier training" >}} {{< card link="actions" title="actions" subtitle="Reusable GitHub Actions" >}} {{< card link="skills" title="skills" subtitle="Claude Code plugin" >}} diff --git a/content/docs/tools/licenses.md b/content/docs/tools/licenses.md new file mode 100644 index 0000000..4398f82 --- /dev/null +++ b/content/docs/tools/licenses.md @@ -0,0 +1,44 @@ +--- +title: licenses +--- + +Scan a repository for license text using ScanCode's rule corpus. Matching runs from an embedded, prebuilt index with no network access, cgo, or Python. + +The scanner uses whole-file hashes, exact token sequences, and `SPDX-License-Identifier` tag lines. It does not do fuzzy or sequence matching, so edits inside a license text can prevent a match. On a repository like Forgejo (~7 000 files) a scan finishes in about a second. + +``` +licenses . scan the current directory +licenses -json path/to/repo > licenses.json write a JSON report +licenses -scope all -max-files 0 path include vendored dependencies +licenses -version print binary and corpus versions +``` + +JSON output reports each file's detections with rule, expression, kind, method, score, and byte range. Detections carry `identification` set to `identified`, `partial`, or `NOASSERTION` depending on whether the expression names concrete licenses or ScanCode placeholders. Exit status 0 means detections were found, 2 means the scan was incomplete, 3 means no conclusive detections. + +## Library + +```go +matcher, err := licenses.New() +if err != nil { + return err +} +result, err := matcher.Match(ctx, text) +``` + +The corpus is loaded once per process and shared by every `Matcher`. + +## Installation + +```bash +brew tap git-pkgs/git-pkgs +brew trust --tap git-pkgs/git-pkgs +brew install licenses +``` + +or + +```bash +go install github.com/git-pkgs/licenses/cmd/licenses@latest +``` + +[View on GitHub](https://github.com/git-pkgs/licenses)