文件历史

244 次代码提交

作者 SHA1 备注 提交日期
Jarrod Watts adec51ef12 feat: add safe Jujutsu status indicators (#685)
Add opt-in Jujutsu status to compact and expanded layouts with prompt-safe repository probing, bounded non-interactive execution, strict output parsing, Git fallback, and maintainer-reviewed documentation and tests.\n\nPreserves the contribution and commit history from #684.
2026-07-21 12:37:32 +10:00
Ayush Sharaf 5226e96f83 feat: add projectLineOrder to customize first-line segment order (#680)
* feat: add projectLineOrder to customize first-line segment order

Adds a dedicated ordering key for the identity/project line, with
coarse segments shared by the expanded and compact renderers:
model (provider + model + effort; compact mode keeps the context bar
attached), project (path + added dirs + git as one segment), advisor,
sessionName, version, extra, duration, cost, speed, auth.

The key is reordering-only: visibility stays with the display.show*
flags. Unknown entries and duplicates are dropped, and segments
missing from a partial list (including segments added in future
versions) are appended in default order, so existing configs and the
default layout are unchanged. Renderer-specific compact parts (config
counts, usage, prompt cache, ...) keep their current slots, and the
custom line stays pinned by customLinePosition.

Closes #654

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix: keep first-line ordering opt-in

* test: cover reordered untrusted full paths

---------

Co-authored-by: Ayush Kumar Sharaf <ayush.sharaf@314ecorp.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Jarrod Watts <35651410+jarrodwatts@users.noreply.github.com>
2026-07-20 17:39:20 +10:00
Vinod Philominraj 1793f48622 feat: support pathLevels: "full" to show the entire absolute cwd (#678)
* feat: support pathLevels: "full" to show the entire absolute cwd

pathLevels was hard-capped at 1-3 segments, with no way to see the
full working directory in the project badge. Add a "full" option
that shows the entire absolute path, and fix the leading slash being
dropped when the full path is shown (split-then-join by "/" loses
the empty leading segment on POSIX absolute paths).

* fix: preserve cross-platform path semantics

---------

Co-authored-by: Jarrod Watts <35651410+jarrodwatts@users.noreply.github.com>
2026-07-20 17:31:46 +10:00
Minhyeok Lee 36d438c17e fix: read the agent model from toolUseResult.resolvedModel (#679)
* fix: read the agent model from toolUseResult.resolvedModel

The agents line only rendered a model when the caller passed `model`
explicitly. Whenever a subagent inherits the session model — the common
case — the Agent tool call carries no `model` input, so the label was
dropped entirely.

The harness already reports the answer: the record carrying the
tool_result stamps `toolUseResult.resolvedModel` with the model the
subagent actually runs on, at launch time for async agents. Read that
through sanitizeTranscriptModel, preferring it over the caller's alias,
and compact the raw ID into a statusline-sized label
(claude-opus-4-8[1m] -> opus-4.8).

Routes the caller-supplied alias and the cache deserialize path through
the same sanitizer, so agent.model holds one invariant everywhere.

Bumps TRANSCRIPT_CACHE_VERSION so existing caches re-parse.

* fix: preserve unknown agent model identifiers

---------

Co-authored-by: Jarrod Watts <35651410+jarrodwatts@users.noreply.github.com>
2026-07-20 17:29:00 +10:00
Jarrod Watts a476c14f47 fix: align CJK progress labels (#673) 2026-07-17 09:24:22 +10:00
Jarrod Watts 987985f0d1 build: prevent stale compiled artifacts (#670)
Clean dist before TypeScript compilation and enforce source-to-artifact parity so deleted modules cannot remain directly package-addressable.
2026-07-16 09:33:36 +10:00
Aster ef77604add feat: render model-scoped weekly usage windows (#669)
Parse and render bounded model-scoped weekly usage data from Claude Code stdin.

Harden untrusted labels and values, cover expanded and compact layouts, and prevent scoped-only data from overwriting shared external snapshots.
2026-07-16 09:22:36 +10:00
hanboy587 819f103d4d fix: harden git refs and extra command labels (#664)
Show detached tags and commits, preserve slash-separated branch links, and accept sanitized plain-text output for explicitly enabled extra commands. Sanitize compact Git refs and add focused regression coverage.
2026-07-15 10:16:49 +10:00
Jarrod Watts 828bd60819 fix weekly usage threshold default (#662) 2026-07-14 09:12:02 +10:00
CctoctoFX a26585e322 feat: add display.modelSource for proxy users (auto/stdin/transcript) (#643)
* feat: add display.modelSource for proxy users (auto/stdin/transcript)

Users behind API proxies (cc-switch, LiteLLM, OpenRouter passthrough)
see the wrong model name because Claude Code reports the configured
model, not the one the proxy actually served.

This PR adds a `display.modelSource` config option:

- `auto` (default): uses stdin model for Claude models, transcript model
  for non-Claude. Zero impact on existing users.
- `stdin`: always use Claude Code's reported model (current behavior).
- `transcript`: always use the model from the API response's
  `message.model` field. Best for proxy users who want the real model.

Implementation:
- TranscriptData.lastAssistantModel: captures the actual model from
  each assistant message's `message.model` field
- stdin.resolveModelName(): resolves model based on modelSource config
- project.ts + session-line.ts: use resolveModelName instead of
  getModelName
- Cache serialization updated to persist lastAssistantModel

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

* Harden transcript model display

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude HUD Maintainer <claude-hud-maintainer@users.noreply.github.com>
2026-07-13 10:06:14 +10:00
YutenC a0debadd81 feat(i18n): add Traditional Chinese (zh-Hant / zh-TW) locale (#645)
- Add src/i18n/zh-Hant.ts with full Traditional Chinese translations
- Update Language type to include 'zh-Hant' and 'zh-TW'
- Register zh-Hant locale and zh-TW alias in i18n index
- Update validateLanguage() in config.ts to accept zh-Hant and zh-TW
- Fix session-time.ts: replace getLanguage() === 'zh' with isCjkLanguage()
  so zh-Hant also gets correct no-space formatting (e.g. '5m前' not '5m 前')
- Add test coverage for zh-Hant and zh-TW in i18n.test.js

Co-authored-by: YutenC <yuten.c.tcg@tc168.cloud>
2026-07-13 10:03:15 +10:00
hyunsh 691d27b207 feat(effort): show ultracode sessions as ultracode(xhigh) (#640)
Claude Code reports ultracode as a normal level (xhigh) in stdin, so the
statusline recovers it from the transcript: the ultra_effort_enter /
ultra_effort_exit attachment markers and the immediate /effort command
output, latest signal wins. When active, the reported level is wrapped as
ultracode(<level>), taken as-is rather than assumed to be xhigh.

Also drop the ps-based parent-process --effort fallback (#471); the effort
label now comes solely from Claude Code stdin, removing a subprocess spawn
on every statusline refresh.

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-13 10:02:28 +10:00
Jarrod Watts f5c4ea2884 Fix symlinked rules and compact cache tokens (#659)
Co-authored-by: Codex Maintainer <codex-maintainer@example.com>
2026-07-13 09:58:49 +10:00
yuanliu c2df4a5806 fix: Fix duplicate counting issue in assistant message usage statistics (#646)
* fix: Fix duplicate counting issue in assistant message usage statistics

* Harden transcript usage deduplication

---------

Co-authored-by: yuanliu <yuanliu147@qq.com>
Co-authored-by: Claude HUD Maintainer <claude-hud-maintainer@users.noreply.github.com>
2026-07-13 09:56:49 +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
Unpxre cbb2d0780b refactor(i18n): let locales own layout via a tiny interpolate() helper (#647) 2026-07-13 09:52:02 +10:00
Longado 296faaa181 test: handle non-ASCII entrypoint paths (#655) 2026-07-13 09:51:59 +10:00
Jarrod Watts 5bbb956560 test: lock down usage and speed cache hardening
Document the absolute read-path requirement for external usage snapshots and add focused tests for relative read rejection plus private speed-cache directory and file modes.
2026-06-19 12:24:59 -04: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
devin-ai-integration[bot] f262936d82 test(cost): clarify Bedrock test intent and add real-session coverage (#636)
Add a comment explaining that the existing bedrockOpus46 test exercises
regex normalization (display_name only), not real Bedrock pricing behavior.

Add a complementary test confirming that real Bedrock sessions (with
model.id containing 'anthropic.claude-') correctly skip cost estimation
via the isBedrockModelId early return.

Co-authored-by: Jarrod Watts <jarrodwatts16@gmail.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-06-19 11:38:45 -04:00
devin-ai-integration[bot] dd3f44718f Add unit tests for modules with lowest coverage (#635)
Add comprehensive tests targeting the 6 modules with the least test coverage:
- cost.ts: 87.64% → 100% statements, 75.6% → 100% branch
- identity.ts: 87.96% → 96.29% statements, 40.74% → 76.31% branch
- session-tokens.ts: 85.71% → 100% statements, 76.92% → 100% branch
- usage.ts: 85.95% → 97.94% statements, 82.29% → 88.88% branch
- memory.ts: 77.41% → 79.03% statements, 73.33% → 85.71% branch
- version.ts: 72.78% → 74.68% statements, 66.66% → 80.3% branch

Overall coverage improved from 93.56% → 94.6% statements, 84.54% → 86.23% branch.

Co-authored-by: Jarrod Watts <jarrodwatts16@gmail.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-06-19 11:37:41 -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
jorgelaranjo 46817ecf1c fix(security): require opt-in for extra command
Require CLAUDE_HUD_ALLOW_EXTRA_CMD before executing --extra-cmd, tighten cache file permissions, and document the local command trust boundary. Maintainer follow-up removed generated dist artifacts from the PR and added extra opt-in parsing coverage. Verified locally with npm ci, npm test, and node --test tests/extra-cmd.test.js. Fixes #618.
2026-06-18 15:51:43 -04:00
CDD-Jarvis 4d1a111074 fix: merge seven-day usage from external snapshot
Merge missing seven-day usage from a configured external snapshot when stdin only supplies the five-hour window. Adds regression coverage for the partial-stdin fallback path. Verified locally with npm ci, npm run build, and node --test tests/index.test.js tests/external-usage.test.js.
2026-06-18 15:51:32 -04:00
Jarrod Watts 64c332c140 Merge pull request #610 from UnpxreTW/feat/env-disable
feat: add CLAUDE_HUD_DISABLE env var to disable the HUD per session
2026-06-15 09:14:03 -04:00
Unpxre f05c37d520 feat: add CLAUDE_HUD_DISABLE env var kill-switch to disable the HUD 2026-06-12 17:11:15 +08:00
John Costa 1772261293 feat: show session compaction count behind opt-in showCompactions setting 2026-06-11 21:10:59 -07:00
Jarrod Watts 9a2cfa7df9 Merge pull request #608 from ViewWay/feat/fallback-speed-estimation
feat: add fallback speed estimation via transcript file growth
2026-06-11 14:31:15 -04:00
Jarrod Watts 8d69be50ba test: harden transcript speed fallback 2026-06-11 14:29:09 -04: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 6e3d1a06f7 fix: stabilize setup and bash tool targets 2026-06-09 10:54:16 -04: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
Jarrod Watts 5cfad40384 fix: validate autoCompactWindow as an integer 2026-06-04 09:57:22 +01:00
Matt Van Horn 5600cffd70 feat: use autoCompactWindow as token-display denominator too 2026-06-02 23:58:07 -07:00
Matt Van Horn d7142a726a feat: add optional autoCompactWindow context denominator 2026-06-02 23:54:57 -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 6501dbcebc fix: harden external usage snapshot writer 2026-05-28 12:18:13 +10:00
Jarrod Watts 6e75065e53 Merge remote-tracking branch 'origin/main' into HEAD 2026-05-28 12:14:03 +10: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