Implement the following plan:
Go changelog-parser library
Port of the Ruby changelog-parser gem as a Go library module at github.com/git-pkgs/changelog, following the same patterns as purl, vers, and spdx.
What it does
Parses changelog files (Keep a Changelog, markdown headers, setext/underline style) into structured entries with version, date, and content. Supports auto-detection of format, custom regex patterns, version lookup, and extracting content between versions.
Files to create
All under /Users/andrew/code/git-pkgs/changelog/:
go.mod
module github.com/git-pkgs/changelog
go 1.25.6
No external dependencies needed.
changelog.go
Package docs and primary API. Exported types:
go
Exported functions:
Parse(content string) *Parser - create parser with auto-detection
ParseWithFormat(content string, format Format) *Parser - explicit format
ParseWithPattern(content string, pattern *regexp.Regexp) *Parser - custom regex
ParseFile(path string) (*Parser, error) - parse a file
FindChangelog(directory string) (string, error) - find changelog file in dir
FindAndParse(directory string) (*Parser, error) - find + parse
Parser methods:
Versions() []string - ordered version list
Entry(version string) (Entry, bool) - get single entry
Entries() map[string]Entry - all entries (ordered map via slice internally)
Between(oldVersion, newVersion string) (string, bool) - content between two versions
LineForVersion(version string) int - line number of version header (-1 if not found)
Use an internal ordered representation (slice of version+entry pairs) to preserve insertion order, since Go maps don't.
changelog_test.go
Table-driven tests using testing package. Port all test cases from the Ruby gem:
- Empty/nil input
- Keep a Changelog format (fixture-based)
- Markdown header format (fixture-based)
- Underline format (fixture-based)
- Custom patterns
- Format auto-detection
- Between method (descending, ascending, partial bounds, not found)
- LineForVersion (various header styles, substring avoidance, range avoidance)
- Edge cases: prerelease, build metadata, empty content, order preservation, markdown links, inline code, nested lists, mixed markers, link references
testdata/
Copy the four fixture files from the Ruby gem:
testdata/keep_a_changelog.md
testdata/markdown_header.md
testdata/underline.md
testdata/comprehensive.md
Regex patterns
Direct ports of the Ruby patterns:
go
What to skip
- CLI (git-pkgs main binary would consume this library)
- HTML rendering (separate concern, not in scope)
- Vandamme compatibility (Ruby-specific)
- Validate command (trivial to build on top of the library externally)
Verification
cd /Users/andrew/code/git-pkgs/changelog && go test ./... - all tests pass
go vet ./... - no issues
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/fc727ae6-4584-4a0e-8e60-0c9d705c7c17.jsonl