fix(cli): add clear-indicator and refresh-indicator subcommands (#26)#27
Merged
Merged
Conversation
The nerf statusline indicator was push-only — the value got written
during nerf_* tool calls but nothing refreshed it on context-shifting
events like compaction or /clear. Result: post-compaction the widget
kept showing the pre-compaction percentage (e.g. 126%) until the user
manually ran /nerf status.
Add a CLI surface to the existing binary so hook scripts can poke the
indicator without going through MCP stdio:
nerf-server clear-indicator # idempotent removeIndicator
nerf-server refresh-indicator [--session-id <id>]
# re-runs the analyzer and
# writes a fresh indicator
The dispatch sits at the top of index.ts and exits before MCP setup
when argv[0] is a known subcommand, so MCP-stdio mode is unchanged
for the no-arg invocation. parseSessionIdFlag rejects empty-string
values to keep the override-present-or-not contract aligned with
resolveSessionId's truthiness check.
The companion claudecode-workflow PR will wire PreCompact +
SessionStart:compact hooks that shell out to these subcommands.
Closes #26
Co-authored-by: Baker B <bakerb@waveeng.com>
Co-authored-by: Claude Opus 4.7 (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
Adds two CLI subcommands to the
nerf-serverbinary so future Claude Code hooks (PreCompact,SessionStart:compact) can keep thenerf:statusline indicator aligned with the real context size across compaction boundaries. Without this, the indicator goes stale post-compaction (the widget kept showing 126% after the actual context dropped to 41%) until the user manually ran/nerf status.Changes
cli.ts—clear-indicator(idempotent removeIndicator) andrefresh-indicator [--session-id <id>](re-runs analyzer + writes fresh indicator).index.tsdispatches subcommands at the top and exits before MCP setup; no-arg invocation continues to start the MCP stdio server unchanged.tests/cli.test.ts— pure tests forisSubcommand/parseSessionIdFlag(incl. empty-string rejection) plus smoke tests for the no-agent-file no-op path.parseSessionIdFlagexplicitly rejects empty-string values so the override-present-or-not contract matchesresolveSessionId's truthiness check; exhaustiveness guard added on therunSubcommandswitch.Linked Issues
Closes #26
Test Plan
./scripts/ci/validate.sh— tsc clean, shellcheck clean, 140 tests pass (was 139, +1 for empty-string flag rejection).dist/nerf-server-linux-x64and smoke-tested live:clear-indicatorremovednerf:*entries from/tmp/claude-statusline-rules-lawyer.jsonrefresh-indicator --session-id 991053c7-...ran the analyzer and wrotenerf:⚡ 80%tests/server.test.tspassing.Companion PR in
claudecode-workflowwill wire the actual hooks once a v1.2.3 release of this repo is cut.