Commit Graph

5 Commits

Author SHA1 Message Date
Jarrod Watts
daf37a8537 fix: use percentage-based autocompact buffer with config toggle (#55)
* fix: use percentage-based autocompact buffer with config toggle

- Change hardcoded 45k buffer to 22.5% of context window
- Scales correctly for enterprise windows (>200k)
- Add `display.autocompactBuffer` config option ('enabled' | 'disabled')
- Default 'enabled' preserves current behavior (buffered %)
- 'disabled' shows raw % for users with autocompact off

Fixes #48, #16
Related: #4, #30, #43, #49

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test: add autocompactBuffer tests for renderSessionLine

Address review feedback:
- Add tests verifying autocompactBuffer: 'enabled' uses buffered %
- Add tests verifying autocompactBuffer: 'disabled' uses raw %
- Add autocompactBuffer check to loadConfig test
- Update baseContext() to include autocompactBuffer

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: add clickable GitHub URLs to CHANGELOG credits

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add debug log for autocompactBuffer mode

When DEBUG=claude-hud is set and autocompactBuffer='disabled',
logs both raw and buffered percentages to help troubleshoot mismatches.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 11:58:46 +11:00
melon
364c76e50c fix: exclude disabled MCP servers from count (#47)
* fix: exclude disabled MCP servers from count

Fixes #3 - MCP count was showing all servers regardless of
enabled/disabled state.

## Root Cause

The HUD was counting all MCP server keys from config files without
checking if they were in the disabled lists:
- `disabledMcpServers` in `~/.claude.json` (user-scope)
- `disabledMcpjsonServers` in `settings.local.json` (project .mcp.json)

## Changes

- Add `getDisabledMcpServers()` function to read disabled arrays
- Add `DisabledMcpKey` union type for compile-time safety
- Filter disabled servers when counting MCPs
- Add debug logging (enable via `DEBUG=claude-hud`)
- Add 8 new tests including Issue #3 regression test

## Test Coverage

- User-scope disabled filtering
- Project .mcp.json disabled filtering
- All MCPs disabled → 0
- Non-string values in disabled arrays (ignored)
- Cross-scope duplicate counting behavior
- Case-sensitive server name matching
- Issue #3 exact scenario (6 MCPs, disable progressively)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor: extract debug logging into shared helper module

Per PR feedback, consolidate duplicate debug logging code from
config-reader.ts and usage-api.ts into a shared debug.ts helper.

- Add src/debug.ts with createDebug() factory function
- Update config-reader.ts to use createDebug('config')
- Update usage-api.ts to use createDebug('usage')
- Same functionality, better DRY compliance

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: melon-hub <melon-hub@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-08 08:47:41 +11:00
melon
6176ba474a fix: add autocompact buffer to context percentage calculation (#6)
Adds AUTOCOMPACT_BUFFER (45k tokens) to match /context output.
This accounts for the reserved space Claude Code uses for autocompact.

Changes:
- Add src/constants.ts with AUTOCOMPACT_BUFFER export
- Update getContextPercent to include buffer in calculation
- Add edge case guard for invalid context window sizes
- Update tests to use realistic 200k context sizes

Closes #4

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: melon-hub <melon-hub@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 22:19:44 +11:00
Jarrod Watts
fcaa8da6d6 test coverage 2026-01-03 18:52:12 +11:00
Jarrod Watts
e9b0e9f680 feat: comprehensive config detection across all scopes
- Add ~/.claude.json user-scope MCP support
- Add .mcp.json project MCP support
- Add .claude/settings.local.json support
- Add CLAUDE.local.md and .claude/CLAUDE.md detection
- Deduplicate MCPs that appear in multiple files

Locations now covered:
- User: ~/.claude/CLAUDE.md, ~/.claude/rules/, ~/.claude/settings.json, ~/.claude.json
- Project: CLAUDE.md, CLAUDE.local.md, .claude/CLAUDE.md, .claude/rules/, .mcp.json
- Project settings: .claude/settings.json, .claude/settings.local.json

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-03 18:10:26 +11:00