glintline 0.0.0-stage → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +278 -0
- package/INSTALL.md +214 -0
- package/LICENSE +21 -0
- package/README.md +85 -2
- package/dist/glintline.js +7 -0
- package/glintline.example.json +38 -0
- package/package.json +54 -4
- package/src/ansi.ts +35 -0
- package/src/cache.ts +42 -0
- package/src/config.ts +209 -0
- package/src/context.ts +64 -0
- package/src/credentials.ts +46 -0
- package/src/debug.ts +9 -0
- package/src/format.ts +109 -0
- package/src/git.ts +68 -0
- package/src/index.ts +100 -0
- package/src/model.ts +120 -0
- package/src/render.ts +176 -0
- package/src/transcript.ts +240 -0
- package/src/types.ts +115 -0
- package/src/usage-api.ts +189 -0
- package/src/usage.ts +63 -0
- package/src/widgets.ts +419 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.3.1] - 2026-11-15
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- README is now a short overview; the full reference moved to `docs/`
|
|
15
|
+
(install, widgets, configuration, narrow terminals).
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- A flat `widgets` array (`["model", "effort"]`) rendered an empty status line;
|
|
20
|
+
it now reads as a single line. The old README examples used this shape.
|
|
21
|
+
|
|
22
|
+
## [0.3.0] - 2026-11-15
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- Partial steps in `dropWhenNarrow`: `cache:session`, `cache:percent`,
|
|
27
|
+
`context:buffer`, `context:numbers` trim one piece of a widget instead of
|
|
28
|
+
removing it, so a line narrows gradually — e.g. the cache keeps its cold state
|
|
29
|
+
after losing its rates, the context keeps its bar after losing its numbers.
|
|
30
|
+
Each step is also a plain option: `cache.showPercent`,
|
|
31
|
+
`context.showBufferTokens`.
|
|
32
|
+
- `INSTALL.md` — a guided install written for a coding agent rather than a human.
|
|
33
|
+
Hand Claude Code the file's raw URL and it probes the runtime, checks whether an
|
|
34
|
+
OAuth token is present (so it does not propose widgets that would render blank),
|
|
35
|
+
proposes a widget set, merges `statusLine` into `~/.claude/settings.json` without
|
|
36
|
+
discarding existing keys, and verifies the result with a sample payload.
|
|
37
|
+
- `cache.showExpiry` (off by default) — the `cache` widget trails the prompt cache's
|
|
38
|
+
state from the new stdin `prompt_cache` object (Claude Code v2.1.251+): the
|
|
39
|
+
local time a warm cache goes cold (`cache 96% ⟳ 14:49`), or `cold` plus the
|
|
40
|
+
tokens the next request writes back (`cache 96% cold ↑28K`). A clock time
|
|
41
|
+
rather than a countdown, since the line is not redrawn while the session is
|
|
42
|
+
idle. Labels via `cache.expiryLabel` and `cache.coldLabel`.
|
|
43
|
+
- `git.worktree` widget — the linked worktree the session is in (`⎘ feature-xyz`),
|
|
44
|
+
from stdin `workspace.git_worktree`, else a Claude Code worktree session's
|
|
45
|
+
`worktree.name`; hidden in the main checkout. Shares the `git` namespace, so it
|
|
46
|
+
joins the branch with a space rather than a separator. On by default, placed
|
|
47
|
+
before `git.branch`; label via `git.worktreeLabel`.
|
|
48
|
+
- `StatusInput` types cover the rest of the current stdin schema: `fast_mode`,
|
|
49
|
+
`thinking`, `prompt_cache`, `session_name`, `prompt_id`, `workspace.repo`,
|
|
50
|
+
`pr`, `worktree`, `vim`, `agent`, `rate_limits.spend_limit`.
|
|
51
|
+
|
|
52
|
+
### Changed
|
|
53
|
+
|
|
54
|
+
- Once stdin carries `rate_limits`, its windows are final: one it leaves out
|
|
55
|
+
(the 5-hour window on Ultra plans, which no longer have that limit) is no
|
|
56
|
+
longer filled in from the OAuth API, so `limit5h` hides instead of showing a
|
|
57
|
+
stale `5h: 0%`. Before the session's first response the API is still used.
|
|
58
|
+
- The fast-mode marker (`effort`'s ` fast`, `cost.onlyWhenFast`,
|
|
59
|
+
`extra.onlyWhenActive`) reads stdin `fast_mode`. Parsing `Fast mode ON/OFF`
|
|
60
|
+
out of the transcript remains as the fallback for Claude Code versions that do
|
|
61
|
+
not send it.
|
|
62
|
+
|
|
63
|
+
- The published binary now carries a `#!/usr/bin/env node` shebang instead of
|
|
64
|
+
`bun`, so it installs and runs under plain Node as well. The shebang is what
|
|
65
|
+
picks the runtime — npm and Bun both link `bin` as a symlink to the file
|
|
66
|
+
itself — so a `bun` shebang made the package unusable without Bun installed.
|
|
67
|
+
Nothing in the source needed changing: it was already node-only API. Bun stays
|
|
68
|
+
the fast path via `bunx --bun`, which overrides the shebang.
|
|
69
|
+
- `build` targets `node` rather than `bun`, keeping the bundle free of any
|
|
70
|
+
Bun-specific output. Bun still executes it unchanged.
|
|
71
|
+
- `engines` declares `node: >=22` alongside `bun` — the oldest Node release
|
|
72
|
+
still under support. The code itself needs nothing newer than `fetch`, so the
|
|
73
|
+
floor tracks the support window rather than a language feature.
|
|
74
|
+
|
|
75
|
+
### Removed
|
|
76
|
+
|
|
77
|
+
- The `peak` widget and its `peak.*` options — the peak / off-peak schedule no
|
|
78
|
+
longer applies. A `peak` left in a config renders nothing.
|
|
79
|
+
|
|
80
|
+
### Fixed
|
|
81
|
+
|
|
82
|
+
- `dropWhenNarrow` measured lines against the full `COLUMNS`, but Claude Code
|
|
83
|
+
keeps a two-column margin on each side (plus `statusLine.padding`), so a line
|
|
84
|
+
up to four columns too wide was truncated with `…` instead of shedding a
|
|
85
|
+
widget. Lines now fit into `COLUMNS − 2·(2 + statusLinePadding)`; the new
|
|
86
|
+
`statusLinePadding` option mirrors Claude Code's `statusLine.padding`, which
|
|
87
|
+
is not passed to the command.
|
|
88
|
+
- Session cache totals (`cache` with `window: "session"`/`"both"`,
|
|
89
|
+
`cache.tokens`) counted most responses two or three times: Claude Code writes
|
|
90
|
+
one transcript line per content block (thinking, text, each tool call), and
|
|
91
|
+
every line repeats the response's `usage`. Lines sharing a message id now
|
|
92
|
+
count once. The transcript cache schema bumps to v4, so existing scans are
|
|
93
|
+
redone on the next render.
|
|
94
|
+
|
|
95
|
+
## [0.2.4] - 2026-07-02
|
|
96
|
+
|
|
97
|
+
### Added
|
|
98
|
+
|
|
99
|
+
- `limit7d.perModel` option. When enabled, `limit7d` shows the active model's
|
|
100
|
+
own weekly cap (e.g. Fable) as the primary value — labeled `7d-<family>` —
|
|
101
|
+
with the general weekly cap trailing dimmed in parens, carrying its own
|
|
102
|
+
burn-rate arrow (`7d-fable 20% ↓↓ (92% ↑↑)`) — the two caps drain at
|
|
103
|
+
different rates, so each gets its own pace hint. The parenthesized percentage
|
|
104
|
+
stays dimmed as the secondary number; only its arrow keeps the usual colors.
|
|
105
|
+
Per-model caps come from the OAuth usage API's `limits[]` array, keyed by
|
|
106
|
+
model family (tolerating renames like "Fable 5"); models without a cap show
|
|
107
|
+
the general `7d`. Off by default, so the default `limit7d` still needs no API.
|
|
108
|
+
|
|
109
|
+
- Top-level `dropWhenNarrow` — widgets to shed, least important first, while a
|
|
110
|
+
rendered line still overflows the terminal. Without it the overflow truncates
|
|
111
|
+
whatever sits at the end of the line (typically the `7d` window); with it the
|
|
112
|
+
listed widgets give way instead, each taking its separator along. The line is
|
|
113
|
+
measured as rendered, so nothing is dropped while it fits. Width comes from
|
|
114
|
+
the `COLUMNS` env var Claude Code exports for status lines (v2.1.153+); when
|
|
115
|
+
it is missing or zero the width counts as unknown and nothing is dropped.
|
|
116
|
+
Width is measured in terminal columns: SGR sequences and combining marks /
|
|
117
|
+
variation selectors take none, CJK and emoji take two. East-Asian "Ambiguous"
|
|
118
|
+
glyphs (`■ ∼ ↓ Σ`) count as one, matching the default of most non-CJK setups.
|
|
119
|
+
|
|
120
|
+
- `GLINTLINE_DUMP_ENV` — writes the width Claude Code passed plus each rendered
|
|
121
|
+
line and its measured columns, for debugging `dropWhenNarrow`.
|
|
122
|
+
|
|
123
|
+
- `cache.window` option for the `cache` widget. The default `"session"` keeps
|
|
124
|
+
the cumulative lifetime hit-rate (summed over the whole transcript), which
|
|
125
|
+
stays high even on a resumed session. `"last"` grades only the most recent
|
|
126
|
+
assistant turn, so the value reflects whether the cache is warm right now and
|
|
127
|
+
honestly drops after a resume re-primes it. `"both"` combines them — the last
|
|
128
|
+
turn (primary, health-colored) followed by the session total marked `Σ` in a
|
|
129
|
+
dimmer color, e.g. `cache 96% Σ91%`.
|
|
130
|
+
|
|
131
|
+
### Changed
|
|
132
|
+
|
|
133
|
+
- The `model` accent is now per generation, not just per family: opus 5 and
|
|
134
|
+
later render in lime (149) while 4.x keeps the familiar purple (141). The
|
|
135
|
+
override is scoped to its family, so `sonnet 5` / `fable 5` are unaffected.
|
|
136
|
+
- The haiku family accent moved from green (114) to silver (251), freeing the
|
|
137
|
+
green for its health-scale role (limit percentages, git additions, cache).
|
|
138
|
+
|
|
139
|
+
### Removed
|
|
140
|
+
|
|
141
|
+
- `limit7d-sonnet` widget and its `limit7dSonnet` config — superseded by
|
|
142
|
+
`limit7d.perModel`, which surfaces any model's weekly cap generically.
|
|
143
|
+
|
|
144
|
+
## [0.2.3] - 2026-06-11
|
|
145
|
+
|
|
146
|
+
### Fixed
|
|
147
|
+
|
|
148
|
+
- Burn-rate arrows on the `5h`/`7d` widgets no longer go degenerate late in
|
|
149
|
+
the window. The old indicator graded `utilization / elapsed-fraction`, whose
|
|
150
|
+
ceiling is `1/progress`, so `↑↑` was unreachable past the window's midpoint
|
|
151
|
+
(and `↑` past 80% elapsed) exactly when the risk of getting capped is
|
|
152
|
+
highest. Over-pace windows are now graded by the share of the remaining time
|
|
153
|
+
you would spend locked at the cap, which stays meaningful across the whole
|
|
154
|
+
window; under-pace headroom keeps the same projected-landing thresholds.
|
|
155
|
+
|
|
156
|
+
## [0.2.2] - 2026-06-09
|
|
157
|
+
|
|
158
|
+
### Added
|
|
159
|
+
|
|
160
|
+
- Dedicated coral accent color for the Fable model family.
|
|
161
|
+
|
|
162
|
+
### Fixed
|
|
163
|
+
|
|
164
|
+
- Fable model family is recognized, and an unknown family no longer duplicates
|
|
165
|
+
its version number (e.g. "Fable 5" rendered as "fable 5 5").
|
|
166
|
+
|
|
167
|
+
## [0.2.1] - 2026-06-09
|
|
168
|
+
|
|
169
|
+
### Fixed
|
|
170
|
+
|
|
171
|
+
- Git: repos with no commits (unborn HEAD) now report staged and untracked
|
|
172
|
+
changes instead of showing clean — staged counts come from `diff --cached`
|
|
173
|
+
and each git query runs independently so one failing doesn't suppress others.
|
|
174
|
+
- Transcript scan no longer permanently drops a record that was observed
|
|
175
|
+
mid-write: line completeness is based on a trailing newline rather than
|
|
176
|
+
guessing from the last character.
|
|
177
|
+
- Effort-level parsing accepts hyphenated/numeric levels (`super-max`), not
|
|
178
|
+
just `[a-z]+` (fallback path; stdin `effort.level` is still preferred).
|
|
179
|
+
- Model version is parsed from dashed ids (`claude-opus-4-8` → `4.8`), so the
|
|
180
|
+
fallback effort clamp no longer demotes `xhigh` when only an id is present.
|
|
181
|
+
- Config merge ignores `__proto__` / `constructor` / `prototype` keys, so a
|
|
182
|
+
crafted settings file can't clobber the config object's prototype.
|
|
183
|
+
- Context read from the transcript fallback now honors the auto-compact window
|
|
184
|
+
/ `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE`, matching the stdin path's percentage base.
|
|
185
|
+
- Peak-hours countdown is computed from real epoch timestamps, fixing a
|
|
186
|
+
±1 hour error when the countdown spans a Pacific DST transition.
|
|
187
|
+
|
|
188
|
+
## [0.2.0] - 2026-06-09
|
|
189
|
+
|
|
190
|
+
### Changed
|
|
191
|
+
|
|
192
|
+
- **Breaking:** `widgets` is now `string[][]` — an array of lines. Each
|
|
193
|
+
inner array becomes one rendered line, joined by `\n`. The default
|
|
194
|
+
config now ships a second line (`session.id` + `cwd`). Users must
|
|
195
|
+
migrate any `widgets: ["a", "b"]` to `widgets: [["a", "b"]]`.
|
|
196
|
+
|
|
197
|
+
### Added
|
|
198
|
+
|
|
199
|
+
- `session.id` widget — first 8 chars (configurable via `session.idLength`)
|
|
200
|
+
of the Claude Code session UUID, with optional `session.idLabel` prefix
|
|
201
|
+
(default `#`). Useful for identifying transcripts on disk.
|
|
202
|
+
- `cwd.format` (`"smart"` | `"home"` | `"short"` | `"full"`, default
|
|
203
|
+
`"smart"`) and `cwd.maxLength` (default `40`). `smart` uses a
|
|
204
|
+
home-relative path when it fits in `maxLength`, otherwise truncates
|
|
205
|
+
middle segments with `…`. `short` keeps the previous two-segment
|
|
206
|
+
behavior; `home` shows the full home-relative path; `full` shows the
|
|
207
|
+
absolute path.
|
|
208
|
+
- `limit5h.showBurnRate`, `limit7d.showBurnRate`, `limit7dSonnet.showBurnRate`
|
|
209
|
+
(default `true`) — appends a burn-rate indicator after the percentage:
|
|
210
|
+
`↑↑` / `↑` / `~` / `↓` / `↓↓`, comparing actual utilization to the linear
|
|
211
|
+
pace expected at this point in the window. Shown as `~` (gray) for the
|
|
212
|
+
first 10% of the window and hidden once the window has elapsed. Respects
|
|
213
|
+
the widget's `mono` flag.
|
|
214
|
+
- `model.label`, `effort.label`, `context.label` — optional prefix labels for
|
|
215
|
+
the three unlabeled widgets (defaults `✳`, `∼`, `⊠`). Rendered in
|
|
216
|
+
`lightGray`, matching `5h`/`7d`. Set to an empty string to hide.
|
|
217
|
+
- `model.showEffortIcon` (default `true`) — appends a single-char effort
|
|
218
|
+
icon after the model version/context (e.g. `✳ opus 4.6 1M ≋`). The icon is
|
|
219
|
+
mapped from the current effort level via `effort.icons` (defaults `∼` /
|
|
220
|
+
`≈` / `≋` / `≃` for low / medium / high / max) and colored like the text
|
|
221
|
+
`effort` widget.
|
|
222
|
+
|
|
223
|
+
### Fixed
|
|
224
|
+
|
|
225
|
+
- Read the active reasoning effort from Claude Code's stdin `effort.level`
|
|
226
|
+
(authoritative — it reflects the `CLAUDE_CODE_EFFORT_LEVEL` env var, the
|
|
227
|
+
`effortLevel` setting, the model default and per-model capping) instead of
|
|
228
|
+
inferring it. Fixes a stale `xhigh` shown at session start when the active
|
|
229
|
+
effort was actually `high`. Falls back to the transcript toggle then
|
|
230
|
+
`settings.json` on Claude Code versions that don't send the field.
|
|
231
|
+
- Clamp `xhigh` effort to `high` on models below 4.7, where only four
|
|
232
|
+
effort levels exist (low / medium / high / max).
|
|
233
|
+
|
|
234
|
+
## [0.1.0] - 2026-04-16
|
|
235
|
+
|
|
236
|
+
### Added
|
|
237
|
+
|
|
238
|
+
- Initial public release.
|
|
239
|
+
- Widget-based status line rendering: `model`, `effort`, `cost`, `context`,
|
|
240
|
+
`peak`, `limit5h`, `limit7d`, `limit7d-sonnet`, `extra`, `cache`,
|
|
241
|
+
`cache.tokens`, `git.branch`, `git.diff`, `lines`, `session`, `version`,
|
|
242
|
+
`cwd`, `sep`, `space`.
|
|
243
|
+
- Session-level effort detection via incremental transcript scan (tracks
|
|
244
|
+
`/effort`, `/model … with X effort`, `/fast` toggles).
|
|
245
|
+
- Session-wide cache accounting: transcript scanner sums
|
|
246
|
+
`input_tokens`, `output_tokens`, `cache_creation_input_tokens` and
|
|
247
|
+
`cache_read_input_tokens` across all assistant messages, exposed as
|
|
248
|
+
`cache` (hit rate = `cache_read / (cache_read + cache_creation + input)`)
|
|
249
|
+
and `cache.tokens` (↓ reused / ↑ first-time cache creation).
|
|
250
|
+
- Fast mode detection (`/fast` output) with linked cost display.
|
|
251
|
+
- Anthropic OAuth Usage API integration with stale-while-revalidate cache
|
|
252
|
+
(60s fresh / 24h stale, refreshed by a detached child so the foreground
|
|
253
|
+
render never blocks on the network).
|
|
254
|
+
- Context window bar with optional auto-compact buffer segment
|
|
255
|
+
(`context.showCompactBuffer`). Respects
|
|
256
|
+
`CLAUDE_CODE_AUTO_COMPACT_WINDOW` and `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE`.
|
|
257
|
+
- Pacific-Time peak/off-peak (weekdays 5–11 AM PT) with a countdown to the
|
|
258
|
+
next transition.
|
|
259
|
+
- Config loader with deep-merge over defaults, searched in
|
|
260
|
+
`$GLINTLINE_CONFIG`, `~/.config/glintline/settings.json`,
|
|
261
|
+
`~/.config/glintline.json`, `~/.claude/glintline.json`.
|
|
262
|
+
- Per-widget label overrides (`cache.label`, `session.label`,
|
|
263
|
+
`limit5h.label`, `limit7d.label`, `limit7dSonnet.label`, `extra.label`,
|
|
264
|
+
`peak.labelPeak`, `peak.labelOffPeak`); empty string hides the label.
|
|
265
|
+
- Per-widget `mono: true` flag for `peak`, `limit5h`, `limit7d`,
|
|
266
|
+
`limit7dSonnet`, `extra`, `cache` and `session` — disables the
|
|
267
|
+
usage/health color so the widget stops drawing attention based on state.
|
|
268
|
+
- Top-level `calmColors: true` swaps the vivid usage palette for muted
|
|
269
|
+
earth tones (sage 108 / ochre 179 / brick 167) across `context`,
|
|
270
|
+
`5h`/`7d`/`extra` and all progress-bar segments.
|
|
271
|
+
- Bar styles: `square`, `circle`, `bar`, `ascii`, `dots`, plus custom
|
|
272
|
+
`context.barChars: { full, empty }`.
|
|
273
|
+
- `GLINTLINE_DEBUG=1` logs recoverable errors to stderr as
|
|
274
|
+
`[glintline:<scope>]`; silent by default.
|
|
275
|
+
- `GLINTLINE_DUMP_STDIN=<path>` captures raw stdin for fixtures.
|
|
276
|
+
- MIT license, TypeScript strict mode, zero runtime dependencies.
|
|
277
|
+
- Unit test suite (52 tests) covering formatters, peak-hour math, context
|
|
278
|
+
token math, model detection, config merge, and cache hit rate.
|
package/INSTALL.md
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# glintline — guided install
|
|
2
|
+
|
|
3
|
+
**This file is written for a coding agent, not for a human reader.** If you are a
|
|
4
|
+
person, the normal instructions live in [docs/install.md](./docs/install.md); the fastest path is
|
|
5
|
+
`bunx --bun -y glintline@latest` as your `statusLine.command`.
|
|
6
|
+
|
|
7
|
+
If you are an agent: a user has handed you this URL and asked you to install glintline.
|
|
8
|
+
Work through the steps below in order. They tell you what to probe, what to ask, and how
|
|
9
|
+
to verify. Do not skip the verification step — a broken status line fails silently.
|
|
10
|
+
|
|
11
|
+
glintline is a status line for Claude Code. Claude Code runs the configured command on
|
|
12
|
+
every render, pipes a JSON blob into its stdin, and prints whatever comes back on stdout.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Step 1 — Choose the runtime
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
bun --version 2>/dev/null || echo "no bun"
|
|
20
|
+
node --version 2>/dev/null || echo "no node"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Pick the first row that matches:
|
|
24
|
+
|
|
25
|
+
| Found | `statusLine.command` to use | Notes |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| Bun ≥ 1.1 | `bunx --bun -y glintline@latest` | Fastest (~75ms). `--bun` matters — see below. |
|
|
28
|
+
| Node ≥ 22, no Bun | `glintline`, after `npm install -g glintline` | ~100ms per render. |
|
|
29
|
+
| Node ≥ 22, global install refused | `npx -y glintline@latest` | Works, but `npx` re-resolves the package every render and adds ~200ms. Use only if a global install is not an option. |
|
|
30
|
+
| Neither | **Stop.** | Tell the user glintline needs Bun ≥ 1.1 or Node ≥ 22 and let them install one. |
|
|
31
|
+
|
|
32
|
+
Node 18 and 20 are past end-of-life; the package declares `engines.node: >=22`. An older
|
|
33
|
+
Node will still run the bundle (it needs nothing newer than `fetch`), but npm will warn
|
|
34
|
+
and you should tell the user they are on an unsupported version.
|
|
35
|
+
|
|
36
|
+
The published binary carries a `#!/usr/bin/env node` shebang, which is what makes the
|
|
37
|
+
Node path work at all. It also means plain `bunx glintline` honours that shebang and
|
|
38
|
+
hands the script to Node — so keep `--bun` in the Bun command, or the user silently pays
|
|
39
|
+
the Node startup cost.
|
|
40
|
+
|
|
41
|
+
## Step 2 — Probe the environment
|
|
42
|
+
|
|
43
|
+
These probes decide which widgets are worth proposing. Run them before asking anything.
|
|
44
|
+
|
|
45
|
+
**Existing status line** — never clobber it blindly:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
cat ~/.claude/settings.json 2>/dev/null | grep -A3 statusLine || echo "no statusLine configured"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
If one is already configured, show the user what it is and ask whether to replace it
|
|
52
|
+
before touching the file.
|
|
53
|
+
|
|
54
|
+
**OAuth token** — gates the `extra` widget and `limit7d.perModel`:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# macOS
|
|
58
|
+
security find-generic-password -s "Claude Code-credentials" -w >/dev/null 2>&1 && echo "keychain token: yes" || echo "keychain token: no"
|
|
59
|
+
# any platform
|
|
60
|
+
test -f ~/.claude/.credentials.json && echo "file token: yes" || echo "file token: no"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
If neither exists, do **not** propose `extra` or `limit7d.perModel` — they render nothing
|
|
64
|
+
without a token, and a blank segment reads as a bug.
|
|
65
|
+
|
|
66
|
+
**Terminal width** — a two-line layout is a better default on narrow terminals:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
tput cols
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Below ~100 columns, prefer splitting the widgets across two lines.
|
|
73
|
+
|
|
74
|
+
Git needs no probe: `git.worktree`, `git.branch` and `git.diff` hide themselves when
|
|
75
|
+
there is nothing to show, so they are safe to include unconditionally.
|
|
76
|
+
|
|
77
|
+
## Step 3 — Propose a widget set
|
|
78
|
+
|
|
79
|
+
Ask the user which preset they want, and mention that any of it can be changed later by
|
|
80
|
+
editing one JSON file. Show them what each preset actually renders.
|
|
81
|
+
|
|
82
|
+
**Minimal** — model, effort and the two usage windows:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{ "widgets": [["model", "effort", "limit5h", "limit7d"]] }
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Default** — what glintline ships with; drop `extra` if Step 2 found no token:
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"widgets": [
|
|
93
|
+
["model", "effort", "context", "limit5h", "limit7d", "extra", "git.worktree", "git.branch", "git.diff"]
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Two-line** — better under ~100 columns:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"widgets": [
|
|
103
|
+
["model", "effort", "context", "limit5h", "limit7d"],
|
|
104
|
+
["cwd", "git.worktree", "git.branch", "git.diff"]
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Every available widget:
|
|
110
|
+
|
|
111
|
+
| Name | Renders | Needs |
|
|
112
|
+
|---|---|---|
|
|
113
|
+
| `model` | `✳ opus 5 1M ⁖` | — |
|
|
114
|
+
| `effort` | `∼ xhigh`, plus ` fast` in fast mode | — |
|
|
115
|
+
| `context` | `⊠ ■■■□□□□□□■ 153K/450K` | — |
|
|
116
|
+
| `limit5h` / `limit7d` | `5h 22% ↑ ⟳ 2.4h` | stdin `rate_limits` |
|
|
117
|
+
| `extra` | `extra: $8.47/$40 (21%)` | OAuth token |
|
|
118
|
+
| `cache` | `cache 87%`, or `cache 87% ⟳ 14:49` with `showExpiry: true` — when the prompt cache goes cold | transcript; the time needs Claude Code ≥ 2.1.251 |
|
|
119
|
+
| `cache.tokens` | `↓340K ↑12K` | transcript |
|
|
120
|
+
| `cost` | `$0.05` — hidden unless fast mode, or `cost.onlyWhenFast: false` | — |
|
|
121
|
+
| `lines` | `+150/-30` | — |
|
|
122
|
+
| `session` | `⏱ 12m` | — |
|
|
123
|
+
| `session.id` | `# abc12345` | — |
|
|
124
|
+
| `version` | `v2.1.109` | — |
|
|
125
|
+
| `cwd` | `⊕ ~/Work/projects/glintline` | — |
|
|
126
|
+
| `git.worktree` | `⎘ feature-xyz` | a linked git worktree |
|
|
127
|
+
| `git.branch` / `git.diff` | `⎇ main` / `(+10,-2)` | a git repo |
|
|
128
|
+
| `sep` / `space` | literal separator / single space | — |
|
|
129
|
+
|
|
130
|
+
`limit7d` also takes `perModel: true`, which shows the active model's own weekly cap
|
|
131
|
+
(`7d-fable 42% ↓ (3%)`) instead of only the general one. It needs the OAuth token.
|
|
132
|
+
|
|
133
|
+
## Step 4 — Write the Claude Code settings
|
|
134
|
+
|
|
135
|
+
`~/.claude/settings.json` holds unrelated user settings. Merge, never overwrite, and back
|
|
136
|
+
it up first:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
mkdir -p ~/.claude
|
|
140
|
+
cp ~/.claude/settings.json ~/.claude/settings.json.bak 2>/dev/null || true
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Then merge the one key, substituting the command chosen in Step 1:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
node -e '
|
|
147
|
+
const fs = require("fs"), os = require("os"), path = require("path");
|
|
148
|
+
const dir = path.join(os.homedir(), ".claude"), p = path.join(dir, "settings.json");
|
|
149
|
+
let s = {}, raw = null;
|
|
150
|
+
try { raw = fs.readFileSync(p, "utf8"); }
|
|
151
|
+
catch (e) { if (e.code !== "ENOENT") throw e; }
|
|
152
|
+
if (raw !== null && raw.trim()) {
|
|
153
|
+
try { s = JSON.parse(raw); }
|
|
154
|
+
catch { console.error("settings.json exists but is not valid JSON — aborting, fix it first"); process.exit(1); }
|
|
155
|
+
}
|
|
156
|
+
s.statusLine = { type: "command", command: "bunx --bun -y glintline@latest" };
|
|
157
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
158
|
+
fs.writeFileSync(p, JSON.stringify(s, null, 2) + "\n");
|
|
159
|
+
console.log("statusLine set to:", s.statusLine.command);
|
|
160
|
+
'
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
It refuses to run rather than discard a file it cannot parse — an unparseable
|
|
164
|
+
`settings.json` still holds the user's settings. If it aborts, show them the parse error
|
|
165
|
+
and let them repair the file before retrying.
|
|
166
|
+
|
|
167
|
+
## Step 5 — Write the glintline config
|
|
168
|
+
|
|
169
|
+
Only needed if the user picked something other than the default widget set. First
|
|
170
|
+
existing path wins:
|
|
171
|
+
|
|
172
|
+
1. `$GLINTLINE_CONFIG`
|
|
173
|
+
2. `~/.config/glintline/settings.json`
|
|
174
|
+
3. `~/.config/glintline.json`
|
|
175
|
+
4. `~/.claude/glintline.json`
|
|
176
|
+
|
|
177
|
+
Use `~/.config/glintline/settings.json` unless the user prefers otherwise. All fields are
|
|
178
|
+
optional and merge over the defaults, so write only what differs — a `widgets` array is
|
|
179
|
+
usually the whole file. Other common knobs: `separator` (default `" │ "`), `calmColors`
|
|
180
|
+
(mute the whole palette), and per-widget blocks like `{ "cache": { "window": "last" } }`.
|
|
181
|
+
[`docs/configuration.md`](https://github.com/lagunovsky/glintline/blob/main/docs/configuration.md) documents every field, [`docs/widgets.md`](https://github.com/lagunovsky/glintline/blob/main/docs/widgets.md) every widget.
|
|
182
|
+
|
|
183
|
+
## Step 6 — Verify
|
|
184
|
+
|
|
185
|
+
Claude Code will not tell the user if the command fails — glintline exits 0 and prints
|
|
186
|
+
nothing on error, so a mistake looks like an empty status line. Run it yourself with a
|
|
187
|
+
representative payload:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
echo '{
|
|
191
|
+
"model": { "id": "claude-opus-5", "display_name": "Opus 5" },
|
|
192
|
+
"workspace": { "current_dir": "'"$PWD"'" },
|
|
193
|
+
"session_id": "abc12345-0000-0000-0000-000000000000",
|
|
194
|
+
"version": "2.1.109",
|
|
195
|
+
"cost": { "total_cost_usd": 0.05, "total_duration_ms": 720000 },
|
|
196
|
+
"context_window": { "context_window_size": 200000,
|
|
197
|
+
"current_usage": { "input_tokens": 120000, "cache_read_input_tokens": 30000 } },
|
|
198
|
+
"rate_limits": { "five_hour": { "used_percentage": 22, "resets_at": '"$(($(date +%s)+7200))"' },
|
|
199
|
+
"seven_day": { "used_percentage": 61, "resets_at": '"$(($(date +%s)+259200))"' } }
|
|
200
|
+
}' | bunx --bun -y glintline@latest
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Replace the trailing command with whichever one Step 1 selected. You should get one or
|
|
204
|
+
two colored lines. Then confirm:
|
|
205
|
+
|
|
206
|
+
- **Empty output** — rerun with `GLINTLINE_DEBUG=1` prepended; diagnostics go to stderr.
|
|
207
|
+
- **Widgets missing** — expected for ones whose data is absent. `extra` is blank without a
|
|
208
|
+
token, `cost` is hidden unless fast mode is on, `git.*` is blank outside a repo, and
|
|
209
|
+
`cache`/`session` read the transcript, which this synthetic payload has no path to.
|
|
210
|
+
- **Boxes or blanks instead of glyphs** — the terminal font lacks the symbols. Every label
|
|
211
|
+
is configurable, e.g. `{ "model": { "label": "*" }, "cwd": { "label": "" } }`.
|
|
212
|
+
|
|
213
|
+
Finally, tell the user to start a new Claude Code session (or `/config` in a running one)
|
|
214
|
+
to see the result, and where their config file lives so they can tune it.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ivan Lagunovsky
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,86 @@
|
|
|
1
|
-
#
|
|
1
|
+
# glintline
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/glintline)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](https://bun.sh)
|
|
6
|
+
[](https://nodejs.org)
|
|
7
|
+
|
|
8
|
+
**Know when you're about to hit the wall — before Claude Code cuts you off mid-flow.**
|
|
9
|
+
|
|
10
|
+
A status line for Claude Code that shows what matters while you vibe: how fast you're burning through your limits, how close the next auto-compact is, whether the prompt cache is still warm, and which branch you're on. Renders in ~70ms, zero dependencies.
|
|
11
|
+
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
## Install in one paste
|
|
15
|
+
|
|
16
|
+
Paste this into Claude Code:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
Install this for me: https://raw.githubusercontent.com/lagunovsky/glintline/main/INSTALL.md
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Claude checks your runtime, proposes a layout, wires up `settings.json` without touching the rest of it, and verifies it works.
|
|
23
|
+
|
|
24
|
+
Prefer doing it yourself? Add this to `~/.claude/settings.json`:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"statusLine": {
|
|
29
|
+
"type": "command",
|
|
30
|
+
"command": "bunx --bun -y glintline@latest"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
No Bun? `npm install -g glintline` and use `"command": "glintline"`. More options in [docs/install.md](docs/install.md).
|
|
36
|
+
|
|
37
|
+
## What you see
|
|
38
|
+
|
|
39
|
+
| Segment | What it tells you |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `5h 64% ↑ ⟳ 2.4h` | 64% of the 5-hour limit used, resets in 2.4h — and the `↑` says that at this pace you'll be capped before it does. `↓↓` means plenty of room. |
|
|
42
|
+
| `7d 41% ↓ ⟳ 1.6d` | The same for the weekly cap, optionally per model. |
|
|
43
|
+
| `⊠ ■■■□□□□□□■ 153K/450K/50K` | Context used vs. the auto-compact point, with the compact buffer greyed out. Turns red as a compact gets close. |
|
|
44
|
+
| `cache 96% ⟳ 14:49` | Prompt cache hit rate and when the cache goes cold. Step away past 14:49 and the next message rebuilds it — `cold ↑28K` shows how many tokens that costs. |
|
|
45
|
+
| `✳ opus 5 1M ⁖ │ ∼ high fast` | Model, context size, effort, fast mode — what you're burning credits on. |
|
|
46
|
+
| `⎘ feature-xyz ⎇ main (+42,-10)` | Worktree, branch, uncommitted diff. |
|
|
47
|
+
|
|
48
|
+
Mix them on as many lines as you like:
|
|
49
|
+
|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
## Why glintline
|
|
53
|
+
|
|
54
|
+
- **Fast.** ~70ms per render on Bun, ~100ms on Node. Transcript scans are incremental and the network never blocks a render.
|
|
55
|
+
- **Zero dependencies.** One 25 KB file, nothing pulled into `node_modules`.
|
|
56
|
+
- **Fits any pane.** In a narrow terminal it sheds the parts you marked as least useful instead of chopping off the end.
|
|
57
|
+
- **Burn rate that stays honest.** The arrows grade how much of the remaining window you'd spend capped, so they keep working late in the window, when it matters most.
|
|
58
|
+
- **Loud or calm.** Vivid colors, muted earth tones, or monochrome per widget. Every label is renameable.
|
|
59
|
+
|
|
60
|
+
## Make it yours
|
|
61
|
+
|
|
62
|
+
Everything is optional; drop what you want to change into `~/.config/glintline/settings.json`:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"widgets": [
|
|
67
|
+
["model", "effort", "context", "cache", "limit5h", "limit7d"],
|
|
68
|
+
["git.worktree", "git.branch", "git.diff", "cwd"]
|
|
69
|
+
],
|
|
70
|
+
"calmColors": true,
|
|
71
|
+
"cache": { "window": "both", "showExpiry": true },
|
|
72
|
+
"dropWhenNarrow": ["cache:session", "context:numbers"]
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Docs
|
|
77
|
+
|
|
78
|
+
- [Install](docs/install.md) — Bun, Node, global, from source
|
|
79
|
+
- [Widgets](docs/widgets.md) — every widget, burn-rate math, context & auto-compact, cache, data sources
|
|
80
|
+
- [Configuration](docs/configuration.md) — config files, layout, labels, colors, env vars
|
|
81
|
+
- [Narrow terminals](docs/narrow-terminals.md) — what gets dropped and in which order
|
|
82
|
+
- [Contributing](CONTRIBUTING.md)
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT — see [LICENSE](./LICENSE).
|