文件历史

提交图

105 次代码提交

作者 SHA1 备注 提交日期
Codex Maintainer 8ce2a69139 Fix symlinked rules and compact cache tokens 2026-07-13 09:58:04 +10:00
晴猫 ac563bc6fb feat(display): show auth method and logged-in account on the first line (#652)
* feat(display): show auth method and logged-in account on the first line

Adds an opt-in segment at the end of the first HUD line showing the
subscription plan of the current login (e.g. "Claude Max 20x") and the
logged-in account, derived from the oauthAccount block that Claude Code
persists in {CLAUDE_CONFIG_DIR}.json.

New display options (all default off):
- display.showAuth: plan label, e.g. "Claude Max 20x" / "API Key"
- display.showAuthUser: email local part (fallback: displayName)
- display.authUserLength: truncation length, 0 = full (default 8)

* fix(auth): strip whole ANSI sequences via shared sanitizeDisplayText helper

Replaces the local codepoint-class regex with the existing
sanitizeDisplayText() util so CSI/OSC sequences are removed entirely
instead of leaving parameter bytes behind (evil\x1b[31m@… -> evil@…),
matching how other externally-sourced display text is sanitized.

* fix(auth): prefer active API key over stale OAuth profile

---------

Co-authored-by: BBleae <yukinoshita.reimu@gmail.com>
Co-authored-by: Jarrod Watts <35651410+jarrodwatts@users.noreply.github.com>
2026-07-13 09:56:46 +10:00
Semianchuk Vitalii 1b4b4b621e fix: correct effort suffix placement and guard check inconsistencies (#650)
* fix: correct effort suffix placement and guard check inconsistencies

the effort level tag (like "max") was showing up after the provider name
instead of after the model — so you'd see "Opus | Bedrock max" when it
should be "Opus max | Bedrock". small thing but it looked wrong.

also fixed a few spots where opt-in features (showDuration, showConfigCounts)
were using !== false checks instead of === true, which could show them
unexpectedly if the config object was partially constructed.

cleaned up duplicate debug namespaces too — two modules were both using
'context' and two were using 'config', which made debug output confusing.

* test: cover effort and opt-in render guards

---------

Co-authored-by: Jarrod Watts <jarrodwatts@users.noreply.github.com>
2026-07-13 09:56:42 +10:00
kywoo26 5c4cfea7ce feat: add opt-in showRoutedCost for Bedrock/Vertex cost (#648)
Closes #621
2026-07-13 09:52:06 +10:00
jorgelaranjo a132b59851 feat: optionally show provider label before model
Add opt-in provider label placement for custom proxy workflows while preserving the existing default model badge order. Compact and expanded layouts now share the same badge formatter.

Closes #620
2026-06-19 12:17:51 -04:00
Jarrod Watts 50c8c9a2ea fix(cost): correct Opus 4.5 pricing
Update Opus 4.5+ local cost estimates to the official standard Anthropic rate of $5/M input and $25/M output while keeping older Opus 4.0/4.1 estimates on $15/M input and $75/M output. Adds focused coverage for Opus 4.5/4.6, Bedrock-style model IDs, and the older fallback. Verified locally with npm ci, npm run build, and node --test tests/core.test.js tests/render.test.js. GitHub CI passed on Node 18 and 20. Fixes #622. Supersedes #624.
2026-06-18 15:52:07 -04:00
John Costa 1772261293 feat: show session compaction count behind opt-in showCompactions setting 2026-06-11 21:10:59 -07:00
Claude 52752b0a0b fix(i18n): translate "token" as 词元 instead of 令牌 in Simplified Chinese
令牌 is the established Chinese rendering of "token" in the
authentication/security sense only (access token → 访问令牌). For the
NLP/LLM sense — the unit of text shown by the HUD's token counters —
the standard term is 词元, officially designated as the Chinese name
for the AI-domain term "token" by the China National Committee for
Terms in Sciences and Technologies on 2026-03-25.

dist/ is intentionally untouched; it is auto-compiled by the
build-dist workflow.
2026-06-10 06:30:11 +00:00
Jarrod Watts 1e002b87b7 Merge pull request #595 from mvanhorn/fix/527-claude-hud
feat: add showSkills / showMcp HUD display elements
2026-06-09 10:53:45 -04:00
Jarrod Watts 0ead5e7c98 fix: harden skills and mcp activity rendering 2026-06-09 10:47:22 -04:00
Jarrod Watts f7fd7410c0 fix: render external balance with usage windows 2026-06-09 10:38:32 -04:00
Kang Seong Jae 33ee67fe4e feat(usage): render balance_label alongside stdin rate_limits
Previously, external-snapshot balance_label was shown only when stdin
rate_limits were absent (mutually exclusive). Rate-limit windows (5h/7d)
and a prepaid/metered dollar balance are complementary data, so both
should be visible when available.

Changes:
- index.ts: when stdin provides rate_limits, also read the external
  snapshot for a balance_label (only when externalUsagePath is set)
  and merge it onto usageData
- session-line.ts: render balance_label as an additive segment after
  the windows block rather than as an exclusive leading branch;
  standalone balance (no window data) preserves existing behaviour
- tests/render.test.js: add test for combined windows + balance display

Backward-compatible: users without externalUsagePath configured see
no behaviour change (no extra file read, no extra segment).
2026-06-09 16:49:58 +09:00
Matt Van Horn 9c87e12467 feat: add showSkills / showMcp HUD display elements 2026-06-07 00:54:54 -07:00
Jarrod Watts 751ff7f514 Merge branch 'main' into feat/advisor-line 2026-06-04 10:01:29 +01:00
Matt Van Horn 5600cffd70 feat: use autoCompactWindow as token-display denominator too 2026-06-02 23:58:07 -07:00
yjtdkj e1cc2a3b64 fix(advisor): security hardening pass on advisor display
Addresses review feedback from #573:

- Sanitize both `ctx.transcript.advisorModel` and `display.advisorOverride`
  through the existing `sanitizeDisplayText` helper before rendering so
  ANSI ESC, OSC, C0/C1 control, and bidi sequences cannot reach the
  terminal. Defence-in-depth: re-sanitize the prettified result too.
- Cap advisor display at 64 chars at the render layer
  (MAX_ADVISOR_DISPLAY_LEN), regardless of source.
- In the transcript parser, capture `advisorModel` only from records
  whose `type === 'assistant'` (matching the documented schema) and
  hard-cap the captured value at 64 chars (ADVISOR_MODEL_MAX_LEN) so a
  malformed log cannot persist an oversized value through the JSON
  cache. Bumps TRANSCRIPT_CACHE_VERSION 6 → 7. The cache deserializer
  also re-applies the cap as belt-and-braces against legacy entries.
- Add 9 new tests covering: CSI/OSC stripping (ANSI ESC + BEL + DEL
  bytes), bidi mark stripping (RLO/PDF), oversize transcript truncation,
  oversize override truncation (display-layer), sanitize-collapses-to-
  empty fallback, non-assistant record rejection (user / custom-title /
  system), inline placement in expanded layout (renderProjectLine), and
  inline placement in compact layout (renderSessionLine).
- Document `display.showAdvisor` and `display.advisorOverride` in
  README.md and README.zh.md configuration tables.

`npm test`: 637 / 639 pass + 1 skip + 1 pre-existing unrelated failure
(`countConfigs cache: miss on nested rules additions`, fails identically
on `main`).
2026-06-02 15:13:46 +08:00
Jarrod Watts 786a55bdb5 fix: stabilize context fallback and todo rendering (#579)
Fixes context fallback for streaming zero frames and guards todo rendering when content is missing.\n\nCloses #576.\nCloses #577.
2026-05-29 13:48:40 +10:00
Unpxre a985c3b7a9 feat: add customLinePosition config to control custom line placement (#575)
Adds display.customLinePosition so users can place customLine before the model badge while preserving the existing default placement.
2026-05-29 13:41:22 +10:00
yjtdkj f416595eb7 feat: add advisor model display (display.showAdvisor)
Surfaces the model configured via Claude Code's `/advisor` command so it
sits inline on the project line:

  [Opus 4.7 (1M context)] │ AthenaKB git:(main*) │ Advisor: Opus 4.7
  Context ██░░░░░░░░ 19%

## How it works

Claude Code stamps an `advisorModel` field onto every assistant record
in the session transcript when `/advisor` is configured. The transcript
parser already walks every line for tool / agent / todo state, so this
just captures the latest non-empty `advisorModel` into the existing
`TranscriptData` shape with no extra IO.

`renderProjectLine` then appends the prettified label (e.g.
`claude-opus-4-7` → `Opus 4.7`) as another part on the same row,
respecting the existing ` │ ` separator and ANSI handling. A
`display.showAdvisor` boolean (default false) gates the whole block;
`display.advisorOverride` lets users force a custom label if needed.

## What's included

- `TranscriptData.advisorModel` field + parser capture
- TRANSCRIPT_CACHE_VERSION bumped 5 → 6 to invalidate caches that
  predate the new field
- `display.showAdvisor` / `display.advisorOverride` config + validation
- `renderProjectLine` integration + `prettifyAdvisorId` helper that
  handles both canonical IDs and short aliases
- i18n labels for en (`Advisor`) and zh-Hans (`顾问`)
- `configure.md` Element Mapping + Turn Off/On flow entries
- 15 new tests covering ID prettification, render gating, transcript
  capture (latest-wins, empty-string-ignored, missing-field fallback),
  and config validation

## Notes

- `dist/` is intentionally untouched per CONTRIBUTING.md
- One pre-existing failure remains in `countConfigs cache: miss on
  nested rules additions` — it fails identically on main without any
  of my changes
2026-05-28 18:11:04 +08:00
Jarrod Watts 368d3a0f69 Merge remote-tracking branch 'origin/pr/572' into HEAD 2026-05-28 12:11:01 +10:00
Matt Van Horn 6f0b33df84 feat: usage elapsed time / percentage display mode 2026-05-26 17:11:43 -07:00
Matt Van Horn e045edc806 feat: configurable tool name truncation and wrap on narrow terminals 2026-05-26 17:11:33 -07:00
Jarrod Watts 1f2d9c8ec4 fix: harden balance label usage rendering 2026-05-13 10:38:16 +10:00
Jarrod Watts e010e72254 Merge pull request #537 from kagura-agent/feat/session-time-529
feat: add session start date and last response timestamp display
2026-05-12 09:39:48 +10:00
Jarrod Watts 5e539f783d fix: polish session time display 2026-05-12 09:37:29 +10:00
xiaodream edb0ce17fd feat: add remaining mode for usage value 2026-05-11 16:06:36 +08:00
Unpxre 6207857f91 feat(config): add barFilled and barEmpty color overrides for progress bars
Allow users to customize the characters used in progress bars via
colors.barFilled and colors.barEmpty. Defaults to the existing
block characters (█/░) so behavior is unchanged without configuration.

The settings live under colors.* rather than display.* because the
bar rendering functions already receive the colors object — this
avoids changing any call signatures.

Co-authored-by: Claude <noreply@anthropic.com>
2026-05-07 16:31:36 +00:00
MingYang a34294b07c fix(speed-tracker): scope cache per session to prevent cross-session contamination
The speed cache was stored in a single global .speed-cache.json file shared
by every concurrent Claude Code session. Because output_tokens in stdin is
session-local, comparing the current frame against a previous value written
by another session produced bogus tok/s readings on idle terminals whenever
another terminal was actively streaming, and poisoned the source terminal's
cache on reset.

Scope the cache by sha256 of the resolved transcript_path, matching the
approach in context-cache.ts. Skip speed tracking when transcript_path is
absent so we never fall back to a cross-session cache. Remove the legacy
global file opportunistically.

Fixes #495
2026-04-25 00:10:35 +08:00
cheats1314 5074a9fa8d fix(render): handle real 40-col terminals and branch links
Fix render width fallback handling, keep usage visible for Enterprise model aliases while still hiding Bedrock usage, and only generate branch hyperlinks for GitHub remotes.\n\nMaintainer review covered security, generated artifacts, subprocess/path/link handling, width-sensitive rendering regressions, and maintainability.\n\nTests: npm test (486 passed, 1 skipped)
2026-04-24 10:22:05 +10:00
Harrison Edwards f68ad279fe feat(context): make colour thresholds configurable (#488)
* feat(context): make colour thresholds configurable

The context bar's warning and critical colours switch at hard-coded
70% and 85%. Those are reasonable defaults for a "compact is imminent"
signal, but workflows with an externally-triggered wrap-up step
(e.g. a pre-compaction hook that itself consumes tokens before
summarisation) need to start de-escalating earlier to leave headroom
for the wrap-up to complete.

Adds two config keys mirroring the existing pushWarningThreshold /
pushCriticalThreshold pattern in gitStatus:

  display.contextWarningThreshold  (default: 70)
  display.contextCriticalThreshold (default: 85)

Defaults are unchanged, so existing installs see no behaviour
difference. Users who want earlier warnings can now set e.g.
{ contextWarningThreshold: 30, contextCriticalThreshold: 50 }.

Values are clamped to 0-100; non-numeric or non-finite values fall
back to the defaults. No ordering invariant is enforced (warning
above critical is allowed — the warning branch simply never fires).

Threaded through getContextColor and coloredBar via a new optional
ContextThresholds parameter; prompt-cache.ts uses getContextColor(0)
to force the "healthy" colour and is unaffected.

* fix(context): extend contextCriticalThreshold to token-breakdown trigger

The previous commit made the context bar's warning and critical
colour thresholds configurable. The token-breakdown detail line
(e.g. `(in: 45k, cache: 12k)`) also had a hard-coded `percent >= 85`
check in both session-line.ts and identity.ts, unchanged by that
commit — which meant a user setting contextCriticalThreshold to e.g.
50 would see the bar turn red at 50% but the detail only appear at
85%. Two different meanings for "critical" in the same UI.

Binds both triggers to `display?.contextCriticalThreshold ?? 85`,
so the single threshold controls both the colour and the detail.

Tests: breakdown shown at 55% when threshold=50; suppressed at 90%
when threshold=95. Mirrored for both renderSessionLine and
renderIdentityLine.

Docs: new keys added to commands/configure.md's "advanced settings
preserved when saving but not edited by this guided flow" list,
alongside usageThreshold and environmentThreshold.
2026-04-23 18:56:13 +10:00
Jarrod Watts d1d90b9684 test: cover compact zh session token summary 2026-04-22 21:03:28 +10:00
Jarrod Watts 234d9aad91 fix(security): harden links and Windows version lookup (#487)
Co-authored-by: Jarrod Watts <jarrod@Jarrods-MBP.modem>
2026-04-22 20:52:21 +10:00
Jarrod Watts 2649ccfd2e feat(cache): add prompt cache countdown (#477)
* feat(cache): add prompt cache countdown

* fix(cache): localize prompt cache and bust stale transcript cache

---------

Co-authored-by: Jarrod Watts <jarrod@Jarrods-MacBook-Pro.local>
2026-04-20 23:55:25 +10:00
Jarrod Watts 9739abc914 feat(layout): add configurable expanded merge groups (#476)
Co-authored-by: Jarrod Watts <jarrod@Jarrods-MacBook-Pro.local>
2026-04-20 23:52:34 +10:00
Jarrod Watts 7610fde8da feat(git): support wrapped branch display (#474)
Co-authored-by: Jarrod Watts <jarrod@Jarrods-MacBook-Pro.local>
2026-04-20 23:50:27 +10:00
zviehrman13 118bf874e4 feat: make usage reset label configurable 2026-04-20 20:52:47 +10:00
Wojciech Pędzimąż 3287adc786 test: add integration tests for timeFormat modes and limit-reached preposition 2026-04-20 18:58:23 +10:00
Wojciech Pędzimąż 01b436cefb fix: correct limit-reached preposition and i18n-ify the absolute "at" prefix
Two bugs caught in review:

1. Limit-reached path hardcoded t("format.resets") = "resets" for ALL
   timeFormat modes, so relative mode (the default) produced "Limit reached
   (resets 2h 30m)" instead of the correct "resets in 2h 30m". Applied the
   same resetsKey selection logic used in formatUsageWindowPart to both
   usage.ts and session-line.ts.

2. formatAbsolute hardcoded the English word "at", breaking zh locale:
   t("format.resets") = "重置于" (resets at) + "at 14:30" = "重置于 at 14:30"
   (doubled preposition). Added "format.at" i18n key (en: "at", zh: "" — zh
   omits the prefix since its "format.resets" already encodes the preposition).

Also updates the render.test.js assertion that was written against the old
incorrect behavior.
2026-04-20 18:58:23 +10:00
Jarrod Watts 84b74d419b fix(render): only pad progress labels when lines stack 2026-04-20 18:54:14 +10:00
kagura-agent 2233a8537c test: update assertions for paddedLabel alignment padding
Adjust two test expectations to account for the trailing spaces
that paddedLabel() adds when aligning shorter labels (Usage, Weekly)
to the width of the longest label (Context = 7 chars).
2026-04-20 18:46:07 +10:00
kagura-agent 4f2775b2bd fix(stdin): use env var instead of model ID to detect Bedrock provider
getProviderLabel was string-matching `anthropic.claude-` in model IDs,
which false-positived on cross-region IDs like `us.anthropic.claude-sonnet-4-6`.
Now checks `CLAUDE_CODE_USE_BEDROCK=1` env var instead.

Fixes #466

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-20 18:29:58 +10:00
Jarrod Watts 565154d5cd fix(cost): prefer native stdin cost with safe fallback 2026-04-05 10:59:33 +10:00
Yimaha b263939c73 feat: use cost.total_cost_usd from stdin instead of manual estimation
Replace the hardcoded Anthropic pricing table and estimateSessionCost()
logic with a direct read of stdin.cost.total_cost_usd — the native field
Claude Code provides after each API response.

- Add cost.* fields to StdinData type
- Extract costUsd in index.ts and pass through RenderContext
- Simplify renderCostEstimate to read ctx.costUsd directly
- Rename i18n key label.estimatedCost → label.cost
- Update label to "Cost ($USD)" / "耗油量(美元)" (zh)
- Remove dead estimateSessionCost, pricing table, and related helpers
- Update tests to use costUsd; add index.test.js coverage for the field
- Update README to reflect native field behavior

Closes #380

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 11:33:17 -04:00
Jarrod Watts 6dddf2ed1b feat: add offline estimated cost display (#305) (#374) 2026-04-04 17:38:30 +11:00
Jarrod Watts 2cc8f28d21 feat: add git push count threshold coloring (#292) (#372) 2026-04-04 15:24:07 +11:00
Jarrod Watts 1816b98fa9 feat: add output style display toggle (#343) (#370) 2026-04-04 15:18:42 +11:00
Jarrod Watts 37711c6c27 Merge pull request #369 from jarrodwatts/maintainer/pr-317-git-files
feat(git): add per-file diffs and files HUD line
2026-04-04 15:00:43 +11:00
Jarrod Watts f8c05371f9 test: cover git file diff rendering 2026-04-04 15:00:05 +11:00
Jarrod Watts 64de69c5cd Merge pull request #336 from krushnamegh/patch-1
Refactor agent rendering and status icon logic
2026-04-04 14:55:16 +11:00
Jarrod Watts 5d923d75ca test: cover agent elapsed formatting 2026-04-04 14:55:08 +11:00