Commit Graph

24 Commits

Author SHA1 Message Date
Jarrod Watts
0786f4c50b Merge pull request #357 from kagura-agent/fix/preserve-taskid-map-across-todowrite
fix: preserve taskIdToIndex map across TodoWrite operations (#345)
2026-04-04 13:25:59 +11:00
kagura-agent
9955880815 fix: preserve taskIdToIndex map across TodoWrite operations (#345)
When TodoWrite is called, the taskIdToIndex map was cleared and
rebuilt from scratch. However, TodoItem objects only contain content
and status fields — no taskId. This meant all taskId mappings from
prior TaskCreate calls were permanently lost, causing subsequent
TaskUpdate operations to silently fail.

Fix: Before clearing the map, build a reverse lookup of content →
taskIds from the existing state. After replacing latestTodos with the
new TodoWrite items, re-register taskId mappings for items whose
content matches a previously-known task. Stale mappings (for content
no longer present) are naturally dropped.

Adds two tests:
- TaskCreate → TodoWrite → TaskUpdate flow preserves taskId
- TodoWrite-only regression test (no TaskCreate involved)
2026-04-03 17:19:49 +08:00
Zane Wang
ab4c564892 feat: add display.modelOverride for custom model display names
Users can now set a fully custom model name in their config:

  { "display": { "modelOverride": "zane's intelligent opus 4.6" } }

When set, the override completely replaces the auto-detected model
name (while preserving the provider qualifier like "| Bedrock").

Follows the same pattern as customLine: string type, max 80 chars,
empty string means disabled (falls through to modelFormat).
2026-04-03 06:42:25 +08:00
Zane Wang
5676041f19 feat: add configurable modelFormat option (full/compact/short)
Redesign from mandatory stripping to user-configurable display format.
Adds display.modelFormat with three levels:

  full:    Show raw display name as-is (default, backward-compatible)
  compact: Strip redundant context-window suffix
  short:   Strip context suffix AND "Claude " prefix

Examples with Bedrock model "Opus 4.6 (1M context)":
  full:    [Opus 4.6 (1M context) | Bedrock]
  compact: [Opus 4.6 | Bedrock]
  short:   [Opus 4.6 | Bedrock]

Examples with API model "Claude Sonnet 3.5 (200k context)":
  full:    [Claude Sonnet 3.5 (200k context)]
  compact: [Claude Sonnet 3.5]
  short:   [Sonnet 3.5]
2026-04-03 06:37:26 +08:00
Zane Wang
c12e514465 feat: strip redundant context-window suffix from model display names
Claude Code may include the context window size in display_name
(e.g. "Opus 4.6 (1M context)"), but the HUD already shows context
usage via the context bar — making the parenthetical redundant.

This adds stripContextSuffix() which removes any parenthetical
containing the word "context" from the display name. It handles
common variants like "(1M context)", "(200k context)",
"(with 1M context)", and "(extended context window)" while
preserving non-context parentheticals like "(beta)" or "(preview)".

Before: [Opus 4.6 (1M context) | Bedrock]
After:  [Opus 4.6 | Bedrock]
2026-04-03 06:25:24 +08:00
Jarrod Watts
3aebe1b973 Simplify usage display to stdin only (#288)
* Simplify usage display to stdin only

* chore: bump version to 0.0.11
2026-03-23 14:47:39 +11:00
Jarrod Watts
738a0ce52c milestone-4: refine stdin usage fallback 2026-03-23 13:24:15 +11:00
Jarrod Watts
60cf0c65c8 prefer stdin rate limits for usage display 2026-03-23 13:19:14 +11:00
Jarrod Watts
aac2bcf532 milestone-3: avoid caching partial transcript parses 2026-03-23 13:04:46 +11:00
Jarrod Watts
c29a55e1dd mitigate transcript reparsing cost 2026-03-23 13:00:41 +11:00
Xingxing
069f194fb2 fix(context): scale autocompact buffer by raw usage (#190)
* fix(context): scale autocompact buffer by raw usage to avoid inflated percentages at low context

Previously the buffered context percentage applied a flat 22.5% buffer
regardless of actual usage. This caused the HUD to show ~28% context
used immediately after /clear or at session start, when real usage was
only ~5%. The fix scales the buffer linearly: zero buffer at ≤5% raw
usage, ramping to full buffer at ≥50%, matching when autocompact
actually kicks in.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: harden autocompact buffer startup coverage

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Jarrod Watts <jarrod@cubelabs.xyz>
2026-03-14 10:57:49 +11:00
Jarrod Watts
499ddc881e fix(context): adjust autocompact fallback buffer (#184) 2026-03-09 14:37:25 +11:00
Jarrod Watts
a47f5b7905 fix: address Windows setup, Bedrock labels, and usage API reliability (#164)
* docs(setup): handle win32 bash vs powershell command paths

* fix(stdin): normalize bedrock model ids when display_name is missing

* fix(usage): harden proxy oauth fallback and timeout handling
2026-03-05 18:32:44 +11:00
Jarrod Watts
9ae17fb644 fix: consolidate CLAUDE_CONFIG_DIR handling and keychain fallback (#160)
* fix: consolidate CLAUDE_CONFIG_DIR handling and keychain fallback

* chore: remove dist artifacts from this PR

* chore: bump version to 0.0.8

* docs: expand 0.0.8 changelog from post-0.0.7 commits
2026-03-03 16:47:15 +11:00
myaiexp
bdfa4454b3 feat: show session name in statusline (#155)
* feat: show session name in statusline

Reads the session slug (auto-generated) and custom title (set via
/rename) from the transcript JSONL and displays it in dim text after
the project/git info on both expanded and compact layouts.

Custom title takes priority over auto-generated slug when both exist.

* test: add session name coverage and harden integration spawn

---------

Co-authored-by: Jarrod Watts <jarrod@cubelabs.xyz>
2026-03-03 13:54:01 +11:00
Ricky (aka 利器君)
bd520e42d7 fix: prevent double-counting CLAUDE.md when cwd is home directory (#141)
* fix: prevent double-counting CLAUDE.md when cwd is home directory

When the working directory is the user's home directory, the project
scope check for {cwd}/.claude/CLAUDE.md resolves to the same path as
the user scope check (~/.claude/CLAUDE.md), causing the HUD to display
"2 CLAUDE.md" instead of "1 CLAUDE.md". Skip the project scope
.claude/ checks when cwd equals the home directory.

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

* fix: handle home cwd config counting edge cases

* fix: avoid home cwd double-counting for rules and settings

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Jarrod Watts <jarrod@cubelabs.xyz>
2026-03-03 13:48:30 +11:00
Jarrod Watts
9fc2858619 feat: detect bedrock provider (#111) 2026-02-03 12:47:13 +11:00
Jarrod Watts
44adb2631d fix(transcript): support task todo updates (#106) 2026-02-03 12:14:27 +11:00
melon
7518dc41d1 feat: add native context percentage support for Claude Code v2.1.6+ (#69)
* fix: add autocompact buffer to context percentage calculation

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: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add native context percentage support for Claude Code v2.1.6+

Use `used_percentage` field from stdin when available, providing accurate
context percentage that matches `/context` output. Falls back automatically
to manual calculation for older Claude Code versions.

- Add `used_percentage` and `remaining_percentage` to StdinData type
- Add `getNativePercent()` helper with edge case handling (NaN, <0, >100)
- Update both `getContextPercent()` and `getBufferedPercent()` to prefer native
- Add 8 comprehensive tests for native percentage behavior

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-14 10:40:42 +11:00
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