Skip to content

Commit 66c7922

Browse files
cpcloudclaude
andauthored
refactor(deps): migrate Charm TUI ecosystem from v1 to v2 (#788)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e2fc1a1 commit 66c7922

54 files changed

Lines changed: 668 additions & 516 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565

6666
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
6767
with:
68-
go-version: "1.25"
68+
go-version: "1.26"
6969

7070
- name: Install extraction tools (Linux)
7171
if: runner.os == 'Linux'
@@ -172,7 +172,7 @@ jobs:
172172

173173
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
174174
with:
175-
go-version: "1.25"
175+
go-version: "1.26"
176176

177177
- name: Run smoke benchmarks
178178
run: go test -bench . -benchtime 1x -timeout 5m -run '^$' ./...
@@ -192,7 +192,7 @@ jobs:
192192

193193
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
194194
with:
195-
go-version: "1.25"
195+
go-version: "1.26"
196196

197197
- name: Check go mod tidy
198198
run: |

.github/workflows/security.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jobs:
108108

109109
- uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
110110
with:
111-
go-version: "1.25"
111+
go-version: "1.26"
112112

113113
- name: Initialize CodeQL
114114
uses: github/codeql-action/init@b1bff81932f5cdfc8695c7752dcee935dcd061c8 # v4.33.0

cmd/micasa/help.go

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,52 @@ package main
55

66
import (
77
"fmt"
8+
"image/color"
9+
"os"
810
"strings"
911

10-
"github.com/charmbracelet/lipgloss"
12+
"charm.land/lipgloss/v2"
1113
"github.com/spf13/cobra"
1214
"github.com/spf13/pflag"
1315
)
1416

1517
// Wong palette colors (duplicated from internal/app/styles.go so the CLI
1618
// binary does not import the full TUI package).
17-
var (
18-
helpAccent = lipgloss.AdaptiveColor{Light: "#0072B2", Dark: "#56B4E9"}
19-
helpSecondary = lipgloss.AdaptiveColor{Light: "#D55E00", Dark: "#E69F00"}
20-
helpDim = lipgloss.AdaptiveColor{Light: "#4B5563", Dark: "#6B7280"}
21-
helpMid = lipgloss.AdaptiveColor{Light: "#4B5563", Dark: "#9CA3AF"}
22-
)
19+
type helpColor struct{ Light, Dark string }
20+
21+
func (c helpColor) resolve(isDark bool) color.Color {
22+
if isDark {
23+
return lipgloss.Color(c.Dark)
24+
}
25+
return lipgloss.Color(c.Light)
26+
}
2327

2428
var (
25-
helpHeading = lipgloss.NewStyle().
26-
Foreground(helpAccent).
27-
Bold(true)
28-
helpCmd = lipgloss.NewStyle().
29-
Foreground(helpSecondary)
30-
helpFlag = lipgloss.NewStyle().
31-
Foreground(helpSecondary)
32-
helpDesc = lipgloss.NewStyle().
33-
Foreground(helpMid)
34-
helpDimStyle = lipgloss.NewStyle().
35-
Foreground(helpDim)
29+
helpAccentPair = helpColor{Light: "#0072B2", Dark: "#56B4E9"}
30+
helpSecondaryPair = helpColor{Light: "#D55E00", Dark: "#E69F00"}
31+
helpDimPair = helpColor{Light: "#4B5563", Dark: "#6B7280"}
32+
helpMidPair = helpColor{Light: "#4B5563", Dark: "#9CA3AF"}
3633
)
3734

35+
func helpStyles(isDark bool) (heading, cmd, flag, desc, dim lipgloss.Style) {
36+
heading = lipgloss.NewStyle().
37+
Foreground(helpAccentPair.resolve(isDark)).
38+
Bold(true)
39+
cmd = lipgloss.NewStyle().
40+
Foreground(helpSecondaryPair.resolve(isDark))
41+
flag = lipgloss.NewStyle().
42+
Foreground(helpSecondaryPair.resolve(isDark))
43+
desc = lipgloss.NewStyle().
44+
Foreground(helpMidPair.resolve(isDark))
45+
dim = lipgloss.NewStyle().
46+
Foreground(helpDimPair.resolve(isDark))
47+
return
48+
}
49+
3850
func styledHelp(cmd *cobra.Command, _ []string) {
51+
isDark := lipgloss.HasDarkBackground(os.Stdin, os.Stderr)
52+
helpHeading, helpCmd, helpFlag, helpDesc, helpDimStyle := helpStyles(isDark)
53+
3954
var b strings.Builder
4055

4156
if cmd.Long != "" {

cmd/micasa/main.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"path/filepath"
1414
"runtime/debug"
1515

16-
tea "github.com/charmbracelet/bubbletea"
17-
"github.com/charmbracelet/lipgloss"
16+
tea "charm.land/bubbletea/v2"
17+
"charm.land/lipgloss/v2"
1818
"github.com/cpcloud/micasa/internal/app"
1919
"github.com/cpcloud/micasa/internal/config"
2020
"github.com/cpcloud/micasa/internal/data"
@@ -152,9 +152,12 @@ func launchTUI(dbPath string, seed *seedOpts) error {
152152
return fmt.Errorf("load config: %w", err)
153153
}
154154
if len(cfg.Warnings) > 0 {
155-
warnStyle := lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{
156-
Light: "#B8860B", Dark: "#F0E442", // Wong yellow
157-
})
155+
isDark := lipgloss.HasDarkBackground(os.Stdin, os.Stderr)
156+
warnColor := "#F0E442" // Wong yellow (dark bg)
157+
if !isDark {
158+
warnColor = "#B8860B" // Wong yellow (light bg)
159+
}
160+
warnStyle := lipgloss.NewStyle().Foreground(lipgloss.Color(warnColor))
158161
for _, w := range cfg.Warnings {
159162
fmt.Fprintln(os.Stderr, warnStyle.Render("warning:")+" "+w)
160163
}
@@ -219,7 +222,7 @@ func launchTUI(dbPath string, seed *seedOpts) error {
219222
fmt.Fprint(os.Stderr, "\033[22;2t\033]2;micasa\007")
220223
defer fmt.Fprint(os.Stderr, "\033[23;2t")
221224

222-
_, err = tea.NewProgram(model, tea.WithAltScreen(), tea.WithMouseCellMotion()).Run()
225+
_, err = tea.NewProgram(model).Run()
223226
if err != nil {
224227
return fmt.Errorf("running program: %w", err)
225228
}

flake.nix

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@
2626
system:
2727
let
2828
pkgs = import nixpkgs { inherit system; };
29+
go = pkgs.go_1_26;
2930
version = builtins.replaceStrings [ "\n" "\r" ] [ "" "" ] (builtins.readFile ./VERSION);
3031

31-
micasa = pkgs.buildGoModule {
32+
buildGoModule = pkgs.buildGoModule.override { inherit go; };
33+
34+
micasa = buildGoModule {
3235
pname = "micasa";
3336
inherit version;
3437
src = ./.;
3538
subPackages = [ "cmd/micasa" ];
36-
vendorHash = "sha256-QNM5befb9GmsF6XYORg259Q/x7f/DP9ukgKhwujb+uc=";
39+
vendorHash = "sha256-my1oClaNceVd8nhBmaa6hIEF/7Vw8CcxKw9jED/bSNI=";
3740
env.CGO_ENABLED = 0;
3841
preCheck = ''
3942
export HOME="$(mktemp -d)"
@@ -214,7 +217,7 @@
214217
fontDirectories = [ "${pkgs.nerd-fonts.hack}/share/fonts/truetype" ];
215218
};
216219

217-
deadcode = pkgs.buildGoModule {
220+
deadcode = buildGoModule {
218221
pname = "deadcode";
219222
version = "0.43.0";
220223
src = pkgs.fetchFromGitHub {
@@ -232,7 +235,7 @@
232235
name = "run-deadcode";
233236
runtimeInputs = [
234237
deadcode
235-
pkgs.go
238+
go
236239
];
237240
runtimeEnv.CGO_ENABLED = "0";
238241
text = ''
@@ -248,7 +251,7 @@
248251
name = "run-govulncheck";
249252
runtimeInputs = [
250253
pkgs.govulncheck
251-
pkgs.go
254+
go
252255
pkgs.jq
253256
pkgs.ripgrep
254257
];
@@ -288,15 +291,15 @@
288291
name = "run-osv-scanner";
289292
runtimeInputs = [ pkgs.osv-scanner ];
290293
text = ''
291-
osv-scanner scan --config osv-scanner.toml --no-ignore --recursive .
294+
osv-scanner scan --config osv-scanner.toml --no-ignore --no-call-analysis=go --recursive .
292295
'';
293296
};
294297

295298
run-golangci-lint = pkgs.writeShellApplication {
296299
name = "run-golangci-lint";
297300
runtimeInputs = [
298301
pkgs.golangci-lint
299-
pkgs.go
302+
go
300303
];
301304
runtimeEnv.CGO_ENABLED = "0";
302305
text = ''
@@ -311,7 +314,7 @@
311314
goModTidyCheck = pkgs.writeShellApplication {
312315
name = "go-mod-tidy-check";
313316
runtimeInputs = [
314-
pkgs.go
317+
go
315318
pkgs.git
316319
];
317320
text = ''
@@ -326,7 +329,7 @@
326329
goGenerateCheck = pkgs.writeShellApplication {
327330
name = "go-generate-check";
328331
runtimeInputs = [
329-
pkgs.go
332+
go
330333
pkgs.git
331334
];
332335
runtimeEnv.CGO_ENABLED = "0";
@@ -391,6 +394,9 @@
391394
shellHook = ''
392395
${preCommit.shellHook}
393396
397+
# lipgloss v2 does not detect tmux-256color as truecolor-capable (#789)
398+
export TERM=xterm-256color
399+
394400
# Generate test document fixtures if missing.
395401
if [[ ! -f internal/extract/testdata/mixed-inspection.pdf ]]; then
396402
bash internal/extract/gen-sample-pdf.bash
@@ -403,7 +409,7 @@
403409
CGO_ENABLED = "0";
404410
GOFLAGS = "-trimpath";
405411
packages = [
406-
pkgs.go
412+
go
407413
pkgs.osv-scanner
408414
pkgs.git
409415
pkgs.hugo
@@ -645,7 +651,7 @@
645651
run-pre-commit = pkgs.writeShellApplication {
646652
name = "run-pre-commit";
647653
runtimeInputs = [
648-
pkgs.go
654+
go
649655
pkgs.git
650656
]
651657
++ preCommit.enabledPackages;

go.mod

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,18 @@
33

44
module github.com/cpcloud/micasa
55

6-
go 1.25.5
6+
go 1.26
77

88
require (
99
github.com/BurntSushi/toml v1.6.0
1010
github.com/adrg/xdg v0.5.3
1111
github.com/brianvoe/gofakeit/v7 v7.14.1
12-
github.com/charmbracelet/bubbles v1.0.0
13-
github.com/charmbracelet/bubbletea v1.3.10
14-
github.com/charmbracelet/glamour v1.0.0
15-
github.com/charmbracelet/huh v1.0.0
16-
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834
17-
github.com/charmbracelet/x/ansi v0.11.6
1812
github.com/dustin/go-humanize v1.0.1
1913
github.com/go-playground/validator/v10 v10.30.1
2014
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
2115
github.com/iancoleman/strcase v0.3.0
2216
github.com/itchyny/gojq v0.12.18
23-
github.com/lrstanley/bubblezone v1.0.0
2417
github.com/mozilla-ai/any-llm-go v0.9.0
25-
github.com/rmhubbert/bubbletea-overlay v0.6.5
2618
github.com/spf13/cobra v1.10.2
2719
github.com/spf13/pflag v1.0.10
2820
github.com/stretchr/testify v1.11.1
@@ -35,29 +27,39 @@ require (
3527
)
3628

3729
require (
30+
github.com/charmbracelet/ultraviolet v0.0.0-20260223171050-89c142e4aa73 // indirect
31+
github.com/charmbracelet/x/exp/ordered v0.1.0 // indirect
32+
github.com/charmbracelet/x/termios v0.1.1 // indirect
33+
github.com/charmbracelet/x/windows v0.2.2 // indirect
34+
)
35+
36+
require (
37+
charm.land/bubbles/v2 v2.0.0
38+
charm.land/bubbletea/v2 v2.0.2
39+
charm.land/glamour/v2 v2.0.0
40+
charm.land/huh/v2 v2.0.3
41+
charm.land/lipgloss/v2 v2.0.2
3842
cloud.google.com/go v0.123.0 // indirect
3943
cloud.google.com/go/auth v0.18.2 // indirect
4044
cloud.google.com/go/compute/metadata v0.9.0 // indirect
4145
github.com/alecthomas/chroma/v2 v2.23.1 // indirect
4246
github.com/anthropics/anthropic-sdk-go v1.27.0 // indirect
4347
github.com/atotto/clipboard v0.1.4 // indirect
44-
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
4548
github.com/aymerick/douceur v0.2.0 // indirect
4649
github.com/bahlo/generic-list-go v0.2.0 // indirect
4750
github.com/buger/jsonparser v1.1.1 // indirect
4851
github.com/catppuccin/go v0.3.0 // indirect
4952
github.com/cespare/xxhash/v2 v2.3.0 // indirect
5053
github.com/charmbracelet/colorprofile v0.4.3 // indirect
5154
github.com/charmbracelet/harmonica v0.2.0 // indirect
52-
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
55+
github.com/charmbracelet/x/ansi v0.11.6
5356
github.com/charmbracelet/x/exp/slice v0.0.0-20260316093931-f2fb44ab3145 // indirect
5457
github.com/charmbracelet/x/exp/strings v0.1.0 // indirect
5558
github.com/charmbracelet/x/term v0.2.2 // indirect
5659
github.com/clipperhouse/displaywidth v0.11.0 // indirect
5760
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
5861
github.com/davecgh/go-spew v1.1.1 // indirect
5962
github.com/dlclark/regexp2 v1.11.5 // indirect
60-
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
6163
github.com/felixge/httpsnoop v1.0.4 // indirect
6264
github.com/gabriel-vasile/mimetype v1.4.13 // indirect
6365
github.com/go-logr/logr v1.4.3 // indirect
@@ -76,17 +78,14 @@ require (
7678
github.com/jinzhu/inflection v1.0.0 // indirect
7779
github.com/jinzhu/now v1.1.5 // indirect
7880
github.com/leodido/go-urn v1.4.0 // indirect
81+
github.com/lrstanley/bubblezone/v2 v2.0.0
7982
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
8083
github.com/mailru/easyjson v0.9.2 // indirect
8184
github.com/mattn/go-isatty v0.0.20 // indirect
82-
github.com/mattn/go-localereader v0.0.1 // indirect
8385
github.com/mattn/go-runewidth v0.0.21 // indirect
8486
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
8587
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
86-
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
8788
github.com/muesli/cancelreader v0.2.2 // indirect
88-
github.com/muesli/reflow v0.3.0 // indirect
89-
github.com/muesli/termenv v0.16.0 // indirect
9089
github.com/ncruces/go-strftime v1.0.0 // indirect
9190
github.com/ollama/ollama v0.18.1 // indirect
9291
github.com/openai/openai-go v1.12.0 // indirect

0 commit comments

Comments
 (0)