Skip to content

Commit fd21bbd

Browse files
committed
feat: update and version command for skill user and some minor fixes
1 parent d0f92df commit fd21bbd

11 files changed

Lines changed: 175 additions & 42 deletions

File tree

.claude-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"metadata": {
88
"description": "Beautiful themed status line for Claude Code with real-time usage tracking, progress bars, and 10 built-in themes",
9-
"version": "0.3.0"
9+
"version": "0.4.0"
1010
},
1111
"plugins": [
1212
{

.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "claudewatch",
33
"description": "Beautiful themed status line for Claude Code with real-time usage tracking, progress bars, and 10 built-in themes",
4-
"version": "0.3.0",
4+
"version": "0.4.0",
55
"author": {
66
"name": "Nitin Panwar",
77
"url": "https://github.com/nitintf"

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## v0.4.0
4+
5+
- `update` command — fetch latest version and re-register (`claudewatch update`)
6+
- `version` command — print installed version (`claudewatch version`)
7+
- `/claudewatch:update` skill for updating via Claude Code
8+
- Install now creates config file with all keys explicitly set
9+
- `show_cost` defaults to `false` (was `true`)
10+
- Uninstall preserves config file for future reinstalls
11+
- `/claudewatch:config` skill now covers all settings — theme + all segment toggles
12+
313
## v0.3.0
414

515
- Session cost display (`cost $1.23`) from Claude Code status JSON

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,15 @@ Custom themes go in `~/.config/claudewatch/themes/*.toml`.
9494
| Command | Description |
9595
|---------|-------------|
9696
| `/claudewatch:setup` | Install binary and configure theme |
97-
| `/claudewatch:config` | Change theme interactively |
98-
| `/claudewatch:uninstall` | Remove claudewatch completely |
97+
| `/claudewatch:config` | Change theme and toggle segments |
98+
| `/claudewatch:update` | Update to latest version |
99+
| `/claudewatch:uninstall` | Remove claudewatch (keeps config) |
100+
101+
## CLI commands
102+
103+
| Command | Description |
104+
|---------|-------------|
105+
| `claudewatch install` | Register with Claude Code + create config |
106+
| `claudewatch uninstall` | Remove from Claude Code (keeps config) |
107+
| `claudewatch update` | Fetch latest version and re-register |
108+
| `claudewatch version` | Print installed version |

internal/config/config.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import (
1010
// Config holds the user's claudewatch configuration.
1111
type Config struct {
1212
Theme string `toml:"theme"`
13-
ShowPlan *bool `toml:"show_plan,omitempty"`
14-
Show5h *bool `toml:"show_5h,omitempty"`
15-
Show7d *bool `toml:"show_7d,omitempty"`
16-
ShowExtra *bool `toml:"show_extra,omitempty"`
17-
ShowCost *bool `toml:"show_cost,omitempty"`
18-
ShowCwd *bool `toml:"show_cwd,omitempty"`
19-
ShowBranch *bool `toml:"show_branch,omitempty"`
13+
ShowPlan *bool `toml:"show_plan"`
14+
Show5h *bool `toml:"show_5h"`
15+
Show7d *bool `toml:"show_7d"`
16+
ShowExtra *bool `toml:"show_extra"`
17+
ShowCost *bool `toml:"show_cost"`
18+
ShowCwd *bool `toml:"show_cwd"`
19+
ShowBranch *bool `toml:"show_branch"`
2020
}
2121

2222
func boolPtr(b bool) *bool { return &b }
@@ -29,7 +29,7 @@ func DefaultConfig() Config {
2929
Show5h: boolPtr(true),
3030
Show7d: boolPtr(true),
3131
ShowExtra: boolPtr(true),
32-
ShowCost: boolPtr(true),
32+
ShowCost: boolPtr(false),
3333
ShowCwd: boolPtr(false),
3434
ShowBranch: boolPtr(false),
3535
}

internal/statusline/statusline_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ func TestRenderCost(t *testing.T) {
110110
ContextWindow: contextWindow{UsedPercentage: ptrFloat(30)},
111111
Cost: costInfo{TotalCostUSD: 1.23},
112112
}
113-
out := Render(&s, testTheme(), "", nil, defaultCfg())
113+
tr := true
114+
cfg := defaultCfg()
115+
cfg.ShowCost = &tr
116+
out := Render(&s, testTheme(), "", nil, cfg)
114117
if !strings.Contains(out, "$1.23") {
115118
t.Error("expected $1.23 in output")
116119
}

main.go

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"os/exec"
99
"path/filepath"
10+
"runtime/debug"
1011
"strings"
1112

1213
"github.com/nitintf/claudewatch/internal/api"
@@ -24,12 +25,17 @@ func main() {
2425
err = install()
2526
case "uninstall":
2627
err = uninstall()
28+
case "update":
29+
err = update()
30+
case "version":
31+
printVersion()
32+
return
2733
}
2834
if err != nil {
2935
fmt.Fprintln(os.Stderr, err)
3036
os.Exit(1)
3137
}
32-
if os.Args[1] == "install" || os.Args[1] == "uninstall" {
38+
if os.Args[1] == "install" || os.Args[1] == "uninstall" || os.Args[1] == "update" || os.Args[1] == "version" {
3339
return
3440
}
3541
}
@@ -129,6 +135,16 @@ func install() error {
129135
return err
130136
}
131137

138+
// Create default config file if it doesn't exist.
139+
cfgPath, err := config.Path()
140+
if err == nil {
141+
if _, statErr := os.Stat(cfgPath); os.IsNotExist(statErr) {
142+
if saveErr := config.Save(config.DefaultConfig()); saveErr == nil {
143+
fmt.Printf(" config: %s\n", cfgPath)
144+
}
145+
}
146+
}
147+
132148
fmt.Printf("Installed claudewatch as Claude Code status line\n")
133149
fmt.Printf(" binary: %s\n", binaryPath)
134150
fmt.Printf(" settings: %s\n", settingsPath)
@@ -156,10 +172,6 @@ func uninstall() error {
156172
}
157173
}
158174

159-
// Remove config directory.
160-
cfgDir := filepath.Join(home, ".config", "claudewatch")
161-
_ = os.RemoveAll(cfgDir)
162-
163175
// Remove usage cache.
164176
_ = os.Remove(filepath.Join(os.TempDir(), "claudewatch-usage.json"))
165177

@@ -171,14 +183,54 @@ func uninstall() error {
171183

172184
fmt.Printf("Uninstalled claudewatch\n")
173185
fmt.Printf(" removed statusLine from %s\n", settingsPath)
174-
fmt.Printf(" removed config dir %s\n", cfgDir)
186+
fmt.Printf(" kept config at ~/.config/claudewatch/config.toml\n")
175187
if binPath != "" {
176188
fmt.Printf(" removed binary %s\n", binPath)
177189
}
178190
fmt.Printf("\nRestart Claude Code to apply.\n")
179191
return nil
180192
}
181193

194+
func update() error {
195+
// Show current version.
196+
currentVersion := version()
197+
fmt.Printf("Current version: %s\n", currentVersion)
198+
199+
// Fetch and install latest.
200+
fmt.Printf("Fetching latest version...\n")
201+
cmd := exec.Command("go", "install", "github.com/nitintf/claudewatch@latest")
202+
cmd.Stdout = os.Stdout
203+
cmd.Stderr = os.Stderr
204+
if err := cmd.Run(); err != nil {
205+
return fmt.Errorf("go install failed: %w", err)
206+
}
207+
208+
// Show new version.
209+
out, err := exec.Command("claudewatch", "version").Output()
210+
if err == nil {
211+
fmt.Printf("Updated to: %s", string(out))
212+
}
213+
214+
// Re-register to update binary path in settings.
215+
if err := install(); err != nil {
216+
return fmt.Errorf("re-registering: %w", err)
217+
}
218+
219+
return nil
220+
}
221+
222+
func version() string {
223+
info, ok := debug.ReadBuildInfo()
224+
if !ok || info.Main.Version == "" || info.Main.Version == "(devel)" {
225+
return "dev"
226+
}
227+
return info.Main.Version
228+
}
229+
230+
func printVersion() {
231+
fmt.Println(version())
232+
}
233+
182234
func gitBranch() (string, error) {
183235
out, err := exec.Command("git", "rev-parse", "--abbrev-ref", "HEAD").Output()
184236
if err != nil {

skills/config/SKILL.md

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,70 @@ description: Configure claudewatch status line settings interactively
44
allowed-tools: Bash, Read, Write, AskUserQuestion
55
---
66

7-
Configure the claudewatch status line. Read the current config from `~/.config/claudewatch/config.toml` first to show current values, then ask the user what they want to change.
7+
Configure the claudewatch status line. Read the current config from `~/.config/claudewatch/config.toml` first to show ALL current values to the user.
88

9-
## Questions to ask
9+
## Step 1: Show current config
1010

11-
Ask the question, showing the current value as context:
11+
Read and display the full current config as a formatted summary, e.g.:
1212

13-
1. **Theme** — Which theme?
14-
Options: dracula, catppuccin-mocha, catppuccin-latte, nord, tokyo-night, gruvbox, solarized-dark, solarized-light, one-dark, rosepine
15-
Show current value.
13+
```
14+
Current claudewatch config:
15+
theme = dracula
16+
show_plan = true
17+
show_5h = true
18+
show_7d = true
19+
show_extra = true
20+
show_cost = false
21+
show_cwd = false
22+
show_branch = false
23+
```
24+
25+
## Step 2: Ask what to change
26+
27+
Ask the user what they want to configure:
28+
- **Theme** — Change the color theme
29+
- **Segments** — Toggle which segments are shown/hidden
30+
- **Both** — Change theme and segments
31+
32+
## Step 3a: Theme (if selected)
33+
34+
Ask which theme. Show ALL 10 options:
35+
dracula, catppuccin-mocha, catppuccin-latte, nord, tokyo-night, gruvbox, solarized-dark, solarized-light, one-dark, rosepine
36+
37+
Since AskUserQuestion only supports 4 options, split into two questions:
38+
1. First ask with 4 popular options + indicate "Other" for more
39+
2. If they pick "Other", show the remaining themes
40+
41+
## Step 3b: Segments (if selected)
42+
43+
Show all segment toggles with their current values. Ask which segments to toggle (multi-select):
44+
- show_plan (Plan name in model bracket)
45+
- show_5h (5-hour usage quota)
46+
- show_7d (7-day usage quota)
47+
- show_extra (Pay-as-you-go extra usage)
48+
- show_cost (Session cost)
49+
- show_cwd (Working directory name)
50+
- show_branch (Git branch)
51+
52+
Note: model name and context window are always shown and cannot be disabled.
53+
54+
Selected segments will be TOGGLED (true→false, false→true).
1655

17-
## After collecting answers
56+
## Step 4: Write config
1857

19-
Write the updated config to `~/.config/claudewatch/config.toml`:
58+
Write the FULL updated config to `~/.config/claudewatch/config.toml` with ALL keys explicitly set. Example:
2059

2160
```toml
22-
theme = "<theme>"
61+
theme = "dracula"
62+
show_plan = true
63+
show_5h = true
64+
show_7d = true
65+
show_extra = true
66+
show_cost = false
67+
show_cwd = false
68+
show_branch = false
2369
```
2470

25-
Tell the user the config has been updated. If they changed the theme, tell them to restart Claude Code to see the new theme.
71+
## Step 5: Confirm
2672

27-
Note: Plan type and usage limits are auto-detected from your Claude Code credentials — no configuration needed.
73+
Show the updated config summary. If the theme changed, tell them to restart Claude Code. Segment changes take effect on the next status line refresh (automatic).

skills/setup/SKILL.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@ Install claudewatch — a themed status line for Claude Code.
1212

1313
2. **Install binary**: Run `go install github.com/nitintf/claudewatch@latest`
1414

15-
3. **Register with Claude Code**: Run `claudewatch install`
15+
3. **Register with Claude Code**: Run `claudewatch install` — this also creates the default config file with all keys.
1616

1717
4. **Verify**: Read `~/.claude/settings.json` and confirm statusLine is set.
1818

1919
5. **Choose theme**: Ask which theme they want:
20-
Options: dracula, catppuccin-mocha, catppuccin-latte, nord, tokyo-night, gruvbox, solarized-dark, solarized-light, one-dark, rosepine
20+
Options: dracula (default), catppuccin-mocha, catppuccin-latte, nord, tokyo-night, gruvbox, solarized-dark, solarized-light, one-dark, rosepine
2121

22-
6. **Write config**: Write to `~/.config/claudewatch/config.toml`:
23-
```toml
24-
theme = "<chosen-theme>"
25-
```
22+
6. **Write config**: Read the existing config from `~/.config/claudewatch/config.toml`, update only the theme value, and write it back preserving all other keys.
2623

27-
7. **Done**: Tell the user to restart Claude Code. Plan type and usage limits are auto-detected from credentials — no configuration needed.
24+
7. **Done**: Tell the user to restart Claude Code. Plan type and usage limits are auto-detected from credentials. Mention they can run `/claudewatch:config` to toggle individual segments on/off.

skills/uninstall/SKILL.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ Uninstall claudewatch from Claude Code.
88

99
## Steps
1010

11-
1. **Confirm**: Ask the user if they are sure they want to uninstall claudewatch. This will remove the status line, config, and cache.
11+
1. **Confirm**: Ask the user if they are sure they want to uninstall claudewatch. This will remove the status line, cache, and binary. Config is preserved at `~/.config/claudewatch/config.toml` for future reinstalls.
1212

13-
2. **Run uninstall**: Run `claudewatch uninstall`
13+
2. **Run uninstall**: Run `claudewatch uninstall` — this removes the statusLine from settings, clears the cache, and removes the binary. Config is kept.
1414

15-
3. **Remove binary**: Run `rm -f $(which claudewatch)`
16-
17-
4. **Done**: Tell the user claudewatch has been fully removed. Restart Claude Code to apply.
15+
3. **Done**: Tell the user claudewatch has been removed. Config was preserved at `~/.config/claudewatch/` in case they reinstall. Restart Claude Code to apply.

0 commit comments

Comments
 (0)