feat(widgets): add Caveman Mode badge widget#493
Open
Khairul989 wants to merge 1 commit into
Open
Conversation
Surfaces the caveman plugin's active compression mode in the status line. The plugin ships its own statusLine bash script, but that slot is single-occupancy — with ccstatusline installed the badge can never render. A native widget lets both coexist, enabled from the TUI picker. ## New Widget: Caveman Mode - src/utils/caveman.ts: getCavemanStatus() reads the plugin's state files ($CLAUDE_CONFIG_DIR/.caveman-active mode word and .caveman-statusline-suffix pre-rendered savings string) with the same hardening as the plugin's own script: O_NOFOLLOW open (atomic symlink refusal), 64-byte read cap, mode whitelist, control-byte strip - src/widgets/CavemanMode.ts: renders [CAVEMAN] / [CAVEMAN:ULTRA] plus optional token-savings suffix; hides when the plugin is inactive; raw value mode returns the bare mode word; 's' keybind toggles the savings suffix via item metadata (mirrors VoiceStatus) ## Integration - Registered in WIDGET_MANIFEST and the widget barrel; appears under the Core category in the TUI picker - docs/USAGE.md: widget description and keybind entries ## Tests - src/utils/__tests__/caveman.test.ts: 12 cases against real temp files — symlink refusal on both state files, 64-byte cap proven via suffix length, whitelist rejection, ANSI-escape stripping - src/widgets/__tests__/CavemanMode.test.ts: 22 cases with the reader mocked — badge formats, savings toggle round-trip, rawValue, preview
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.
What
Adds a Caveman Mode widget (Core category) that surfaces the caveman plugin's active compression mode as a status line badge —
[CAVEMAN],[CAVEMAN:ULTRA], etc. — with an optional lifetime token-savings suffix (⛏ 12.4k). The widget hides entirely when the plugin is inactive.Why
The caveman plugin ships its own statusline badge as a bash script wired into Claude Code's
settings.jsonstatusLineslot. That slot is single-occupancy, so anyone running ccstatusline can never see the badge — the plugin's installer detects the existing statusline and backs off. A native widget lets both coexist, enabled from the TUI picker like any other widget.How
src/utils/caveman.ts—getCavemanStatus()reads the plugin's two state files under$CLAUDE_CONFIG_DIR(.caveman-activemode word,.caveman-statusline-suffixpre-rendered savings string). Ports the plugin script's own hardening, and tightens it: atomicO_NOFOLLOWopen (the bash original has an lstat-then-read TOCTOU gap), 64-byte read cap, mode whitelist, control-byte strip on the suffix.src/widgets/CavemanMode.ts— mirrors the VoiceStatus pattern: metadata-backedskeybind toggles the savings suffix, raw value mode returns the bare mode word, preview support, no React editor needed.WIDGET_MANIFEST+ barrel export; documented indocs/USAGE.md(widget list + keybinds).Testing
bun run lintclean, full suite 1662 pass / 0 fail[CAVEMAN:ULTRA] ⛏ 12.4k, hides on absent flag, hides on symlinked flag