refactor: replace go-colorful and x/term with stdlib#3
Merged
Jason-Adam merged 2 commits intomainfrom Mar 28, 2026
Merged
Conversation
Replace direct dependency on go-colorful with inline RGB-to-HSL lightness calculation using stdlib image/color. Replace x/term with a raw TIOCGWINSZ ioctl via syscall (unix) with a no-op stub for non-unix platforms. Both packages remain as transitive deps via lipgloss but are no longer part of our direct API surface. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR reduces the project’s direct dependency surface by replacing two direct third-party usages (color lightness and terminal size detection) with stdlib-based implementations while keeping the packages as transitive deps via lipgloss.
Changes:
- Replaced
charmbracelet/x/termterminal size lookup with a UnixTIOCGWINSZioctl implementation plus a non-Unix stub. - Replaced
go-colorfulusage in light/dark background detection with an inline RGB→HSL lightness calculation. - Updated
go.modto dropx/termandgo-colorfulfrom direct requirements (remain indirect).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/gather/termsize_unix.go | Adds Unix-only ioctl-based terminal width detection. |
| internal/gather/termsize_other.go | Adds non-Unix stub returning 0 to trigger env-var fallback. |
| internal/gather/gather.go | Switches terminal width detection to getTermWidth instead of term.GetSize. |
| go.mod | Moves x/term and go-colorful from direct to indirect dependencies. |
| cmd/vitals/main.go | Replaces go-colorful HSL lightness call with stdlib RGB-based lightness computation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Cover black, white, dark/light gray, mid-gray boundary (126 vs 128), pure red, and dark blue to verify the RGB-to-HSL lightness threshold. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
go-colorfuldirect dependency with inline RGB-to-HSL lightness calculation inisLightColor()(~6 lines of stdlib math)charmbracelet/x/termdirect dependency with rawTIOCGWINSZioctl viasyscall(platform-specific files:termsize_unix.go+termsize_other.gostub)Test plan
make checkpasses (fmt, vet, tests)🤖 Generated with Claude Code