Implement the following plan:
Currently all code lives in one flat reuse package. Move parsers into public subpackages, matching the internal/core + type alias pattern used by manifests and registries.
Root package (project.go) imports subpackages. Subpackages need ReuseInfo, SourceType, PrecedenceType from root. That's a cycle.
Fix: move shared types to internal/core. Root re-exports them as type aliases (type ReuseInfo = core.ReuseInfo). Subpackages import internal/core directly. No cycles.
reuse/
reuse.go type aliases from internal/core, package docs
project.go Project, OpenProject, ReuseInfoOf, AllReuseInfo
project_test.go
covered.go IsCoveredFile, CoveredFiles, IsIgnoredDir, IsIgnoredFile
covered_test.go
internal/
core/
core.go ReuseInfo, SourceType, PrecedenceType (actual definitions + methods)
extract/
extract.go ExtractReuseInfo, ExtractFromFile, FilterIgnoreBlocks
extract_test.go
dep5/
dep5.go Dep5, ParseDep5, ParseDep5File, ReuseInfoOf
dep5_test.go
toml/
toml.go ReuseTOML, Annotation, ParseReuseTOML, ParseReuseTOMLFile, ReuseInfoOf
toml_test.go
glob.go GlobMatch (only used by toml, stays here)
glob_test.go
reuse.go types/constants/methods -> internal/core/core.goreuse.go becomes type aliases + package docextract.go + test -> extract/ subpackage, package extract, imports internal/coredep5.go + test -> dep5/ subpackage, package dep5, imports internal/coretoml.go + test -> toml/ subpackage, package toml, imports internal/core and uses alias for BurntSushi/toml (btoml)glob.go + test -> toml/ subpackage (glob is only used by toml matching)covered.go + test -> stays in root (no deps on subpackages, no cycle risk)project.go + test -> stays in root, imports extract, dep5, toml subpackagesConsumer usage:
reuse.gopackage coretype ReuseInfo = core.ReuseInfo, type SourceType = core.SourceType, etc.const (FileHeader = core.FileHeader; ...)package reuse -> package extractgithub.com/git-pkgs/reuse/internal/coreReuseInfo with core.ReuseInfo, FileHeader with core.FileHeaderpackage reuse -> package dep5github.com/git-pkgs/reuse/internal/corepackage reuse -> package tomlbtoml "github.com/BurntSushi/toml" (alias to avoid name conflict with package name)github.com/git-pkgs/reuse/internal/corepackage reuse -> package tomlextract, dep5, toml subpackagesExtractFromFile -> extract.ExtractFromFile, etc.ParseReuseTOMLFile -> toml.ParseReuseTOMLFileParseDep5File -> dep5.ParseDep5FileReuseInfo etc. since root re-exports themassertSlice helper is duplicated into each test package (or made a shared test helper)mkfile helper stays in root test (project_test.go, covered_test.go)extract_test.go and dep5_test.go each get their own assertSlicego build ./...go test -v -race ./...go vet ./...If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/andrew/.claude/projects/-Users-andrew-code-git-pkgs/e29c14b3-41b4-4a33-a3ba-dc32811240a3.jsonl
I'll start by reading the current files to understand the exact code before making changes.
Now let me read all the test files.
I have a clear picture of the full codebase. Let me create the task list and then implement everything. The key challenge is that Go won't compile with duplicate symbols, so I need to swap old files for new ones atomically.
Good, the diagnostic is just from the file being created in stages. Now the toml test files:
Now update project.go to import the subpackages:
Now I need to add assertSlice to covered_test.go (since it's used by both covered_test.go and project_test.go in the root package, and extract_test.go which defined it is moving away). And delete the old files from root.
Now delete the old files from root:
The diagnostic is stale from before the delete. Let me build and test:
All 64 tests pass across all packages. Build, vet, and tests all clean.
Everything is done. Here's a summary of what changed:
New files:
internal/core/core.go -- ReuseInfo, SourceType, PrecedenceType and all their constants/methodsextract/extract.go + extract/extract_test.go -- SPDX header extraction (was root extract.go)dep5/dep5.go + dep5/dep5_test.go -- dep5 parser (was root dep5.go)toml/toml.go + toml/toml_test.go -- REUSE.toml parser (was root toml.go)toml/glob.go + toml/glob_test.go -- glob matching (was root glob.go, moved here since only toml uses it)Modified files:
reuse.go -- rewritten to type aliases and constant re-exports from internal/coreproject.go -- imports extract, dep5, toml subpackages; Project struct fields now use subpackage typescovered_test.go -- added assertSlice helper (previously lived in extract_test.go)Deleted files:
extract.go, extract_test.go, dep5.go, dep5_test.go, toml.go, toml_test.go, glob.go, glob_test.go from rootUnchanged files:
covered.go, project_test.gocommit this with "Hello world"
Committed as 15fc8b5 with message "Hello world".
empty repo here: https://github.com/git-pkgs/reuse
Ready to push to git@github.com:git-pkgs/reuse.git. This will push the main branch to the remote. Want me to go ahead?
yes
Pushed to https://github.com/git-pkgs/reuse.
failing ci
Lint failure: toml/glob.go:31 wants a tagged switch instead of if/else chain on next.
Tests pass. Want me to commit and push this fix?
yes
Pushed as 1fb6b84.
check if ci passes now
Still running. Let me wait a bit.
CI passes.
now let's look at the dependabot PRs
No open PRs. Dependabot may have auto-merged or the updates were applied directly. Let me check if there are recently closed/merged ones.
No PRs at all. The Dependabot runs we saw earlier were just the initial config checks, not actual PRs. Nothing to review.
can this tool be used in a similar way to scancode license checker?
They solve related problems but work differently.
ScanCode scans file contents and matches them against a database of known license texts. It can identify a license even when there are no SPDX tags, by recognizing patterns in license headers, notices, and full license texts. It's detection-based.
This library reads structured SPDX metadata that authors have explicitly added following the REUSE spec: SPDX-License-Identifier headers, .license sidecars, REUSE.toml annotations, and dep5 files. It doesn't try to identify licenses from arbitrary text. If a file has no SPDX tags and isn't covered by a REUSE.toml or dep5 entry, this library just reports it as having no licensing info.
So ScanCode works on projects that haven't adopted any particular standard. This library works on projects that follow the REUSE specification. In a REUSE-compliant project, every covered file has explicit SPDX metadata, and this library is all you need. For projects without that discipline, you'd want something like ScanCode.
They could complement each other: use ScanCode to audit a project that lacks structured metadata, then use the results to add REUSE-compliant tags, then use this library going forward.