glintline 0.3.0 → 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 CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
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
+
10
22
  ## [0.3.0] - 2026-11-15
11
23
 
12
24
  ### Added
package/INSTALL.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # glintline — guided install
2
2
 
3
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 [README.md](./README.md); the fastest path is
4
+ person, the normal instructions live in [docs/install.md](./docs/install.md); the fastest path is
5
5
  `bunx --bun -y glintline@latest` as your `statusLine.command`.
6
6
 
7
7
  If you are an agent: a user has handed you this URL and asked you to install glintline.
@@ -178,7 +178,7 @@ Use `~/.config/glintline/settings.json` unless the user prefers otherwise. All f
178
178
  optional and merge over the defaults, so write only what differs — a `widgets` array is
179
179
  usually the whole file. Other common knobs: `separator` (default `" │ "`), `calmColors`
180
180
  (mute the whole palette), and per-widget blocks like `{ "cache": { "window": "last" } }`.
181
- `README.md` in the repo documents every field.
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
182
 
183
183
  ## Step 6 — Verify
184
184
 
package/README.md CHANGED
@@ -1,29 +1,17 @@
1
1
  # glintline
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/glintline?color=cb3837)](https://www.npmjs.com/package/glintline)
3
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
4
5
  [![Bun](https://img.shields.io/badge/runtime-Bun%20%E2%89%A5%201.1-black)](https://bun.sh)
5
6
  [![Node](https://img.shields.io/badge/runtime-Node%20%E2%89%A5%2022-5FA04E)](https://nodejs.org)
6
- [![TypeScript](https://img.shields.io/badge/TypeScript-strict-3178C6)](./tsconfig.json)
7
7
 
8
- A fast, configurable status line for Claude Code. TypeScript, zero runtime dependencies, ~70ms per render on Bun, ~100ms on Node.
8
+ **Know when you're about to hit the wall — before Claude Code cuts you off mid-flow.**
9
9
 
10
- Default output:
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
11
 
12
12
  ![glintline status line — opus 4.6 1M · high effort · context bar 153K/200K · 5h 64% ↑ ⟳ 2.4h · 7d 41% ↓ ⟳ 1.6d · ⎇ main (+42,-10)](assets/statusline-default.svg)
13
13
 
14
- Extended output:
15
-
16
- ![glintline two-line status line — fable 5, calm palette, compact-buffer context 153K/450K/50K, cache 87%, 5h/7d windows, then session id, cwd and ⎇ main (+42,-10) on the second line](assets/statusline-compact.svg)
17
-
18
- ## Requirements
19
-
20
- - [Bun](https://bun.sh) ≥ 1.1 or [Node](https://nodejs.org) ≥ 22
21
- - [Claude Code](https://claude.com/claude-code) CLI
22
- - Optional (only for the `extra` widget, or `limit7d` with `perModel`): an OAuth token in the macOS Keychain (`Claude Code-credentials`) or `~/.claude/.credentials.json`
23
-
24
- ## Install
25
-
26
- ### Let Claude do it
14
+ ## Install in one paste
27
15
 
28
16
  Paste this into Claude Code:
29
17
 
@@ -31,16 +19,9 @@ Paste this into Claude Code:
31
19
  Install this for me: https://raw.githubusercontent.com/lagunovsky/glintline/main/INSTALL.md
32
20
  ```
33
21
 
34
- [INSTALL.md](./INSTALL.md) is written for the agent rather than for you: it has Claude
35
- detect your runtime, check whether the API-backed widgets will actually render, propose a
36
- widget set, merge `statusLine` into your settings without clobbering what is already
37
- there, and verify the result before declaring success.
38
-
39
- ### Zero-install (recommended)
22
+ Claude checks your runtime, proposes a layout, wires up `settings.json` without touching the rest of it, and verifies it works.
40
23
 
41
- Add to `~/.claude/settings.json` — the runner downloads and caches the latest version on first run.
42
-
43
- On Bun:
24
+ Prefer doing it yourself? Add this to `~/.claude/settings.json`:
44
25
 
45
26
  ```json
46
27
  {
@@ -51,355 +32,54 @@ On Bun:
51
32
  }
52
33
  ```
53
34
 
54
- On Node:
55
-
56
- ```json
57
- {
58
- "statusLine": {
59
- "type": "command",
60
- "command": "npx -y glintline@latest"
61
- }
62
- }
63
- ```
64
-
65
- Pin a specific version if you want reproducibility: `bunx --bun -y glintline@0.3.0`.
35
+ No Bun? `npm install -g glintline` and use `"command": "glintline"`. More options in [docs/install.md](docs/install.md).
66
36
 
67
- The `--bun` flag is what keeps the Bun path fast. The published binary carries a
68
- `#!/usr/bin/env node` shebang so it runs anywhere; without `--bun`, `bunx` honours that
69
- shebang and hands the script to Node.
70
-
71
- `npx` re-resolves the package on every invocation, which adds roughly 200ms per render —
72
- `bunx` does not. On Node, prefer the global install below.
73
-
74
- ### Global install
75
-
76
- ```bash
77
- bun install -g glintline
78
- # or
79
- npm install -g glintline
80
- ```
81
-
82
- Then reference it directly — this runs under Node whichever package manager installed
83
- it, since that is what the shebang selects. Bun users wanting the faster path should
84
- stick to the `bunx --bun` form above.
85
-
86
- ```json
87
- {
88
- "statusLine": {
89
- "type": "command",
90
- "command": "glintline"
91
- }
92
- }
93
- ```
94
-
95
- ### From source
96
-
97
- ```bash
98
- git clone https://github.com/lagunovsky/glintline.git
99
- cd glintline
100
- bun install
101
- bun run build
102
- ```
37
+ ## What you see
103
38
 
104
- Building needs Bun, but the resulting bundle runs on either runtime:
105
-
106
- ```json
107
- {
108
- "statusLine": {
109
- "type": "command",
110
- "command": "bun /absolute/path/to/glintline/dist/glintline.js"
111
- }
112
- }
113
- ```
114
-
115
- Swap `bun` for `node` in that command if you prefer.
116
-
117
- ## Data sources
118
-
119
- | Segment | Source |
39
+ | Segment | What it tells you |
120
40
  |---|---|
121
- | Model / version | `model.id` / `model.display_name` (stdin) |
122
- | Effort | `effort.level` (stdin); on older Claude Code, `transcript_path` (`Set effort level to …`), else `effortLevel` in `~/.claude/settings*.json` |
123
- | Fast marker | `fast_mode` (stdin); on older Claude Code, the last `Fast mode ON/OFF` in `transcript_path` |
124
- | Context | `context_window.current_usage` (stdin) |
125
- | 5h / 7d limits | `rate_limits` (stdin) |
126
- | Cache hit rate / tokens | assistant `usage` in `transcript_path`, one count per response |
127
- | Cache expiry | `prompt_cache` (stdin, Claude Code v2.1.251+) |
128
- | extra / per-model 7d cap | OAuth Usage API — only for `extra` or `limit7d` with `perModel`; 60s cache, non-blocking refresh |
129
- | Git | `git symbolic-ref` + `git diff --numstat HEAD` |
130
- | Worktree | `workspace.git_worktree`, else `worktree.name` (stdin) |
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:
131
49
 
132
- API-only widgets need an OAuth token (macOS Keychain `Claude Code-credentials`, else `~/.claude/.credentials.json`); without it they render nothing.
50
+ ![glintline two-line status line — fable 5, calm palette, compact-buffer context 153K/450K/50K, cache 87%, 5h/7d windows, then session id, cwd and ⎇ main (+42,-10) on the second line](assets/statusline-compact.svg)
133
51
 
134
- ## Configuration
52
+ ## Why glintline
135
53
 
136
- Optional file. The first existing path wins:
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.
137
59
 
138
- 1. `$GLINTLINE_CONFIG`
139
- 2. `~/.config/glintline/settings.json` (preferred — same shape as ccstatusline)
140
- 3. `~/.config/glintline.json`
141
- 4. `~/.claude/glintline.json`
60
+ ## Make it yours
142
61
 
143
- All fields are optional and merge over the defaults.
62
+ Everything is optional; drop what you want to change into `~/.config/glintline/settings.json`:
144
63
 
145
64
  ```json
146
65
  {
147
66
  "widgets": [
148
- ["model", "effort", "cost", "context", "limit5h", "limit7d", "extra", "git.worktree", "git.branch", "git.diff"],
149
- ["session.id", "cwd"]
67
+ ["model", "effort", "context", "cache", "limit5h", "limit7d"],
68
+ ["git.worktree", "git.branch", "git.diff", "cwd"]
150
69
  ],
151
- "separator": " │ ",
152
- "calmColors": false,
153
- "dropWhenNarrow": [],
154
- "statusLinePadding": 0,
155
- "model": { "showFamily": true, "showVersion": true, "showContext": true, "showEffortIcon": true, "label": "✳" },
156
- "effort": { "label": "∼", "icons": { "low": "·", "medium": "⁚", "high": "⁖", "xhigh": "⁘", "max": "⁙" } },
157
- "context": { "showBar": true, "showNumbers": true, "showPercent": false, "showCompactBuffer": false, "showBufferTokens": true, "fillEmpty": true, "barWidth": 10, "barStyle": "square", "gap": " ", "label": "⊠" },
158
- "limit5h": { "showCountdown": true, "separator": " ", "label": "5h", "mono": false, "showBurnRate": true },
159
- "limit7d": { "showCountdown": true, "separator": " ", "label": "7d", "mono": false, "showBurnRate": true, "perModel": false },
160
- "cost": { "precision": 2, "onlyWhenFast": true },
161
- "extra": { "onlyWhenActive": false, "label": "extra", "mono": false },
162
- "git": { "worktreeLabel": "⎘" },
163
- "cache": { "label": "cache", "mono": false, "window": "session", "showPercent": true, "showExpiry": false, "expiryLabel": "⟳", "coldLabel": "cold" },
164
- "session": { "label": "⏱︎", "mono": false, "idLength": 8, "idLabel": "#" },
165
- "cwd": { "format": "smart", "maxLength": 40, "label": "⊕" }
70
+ "calmColors": true,
71
+ "cache": { "window": "both", "showExpiry": true },
72
+ "dropWhenNarrow": ["cache:session", "context:numbers"]
166
73
  }
167
74
  ```
168
75
 
169
- See `glintline.example.json` for a copy-paste starting point. Widget names use dot-namespaces (`git.branch`, `session.id`); their config keys are camelCased siblings of the top-level `Config` (`git.branch` / `git.diff` have no config block, `git.worktree` reads `git`, `session.id` reads `session`).
170
-
171
- ### Available widgets
172
-
173
- | Name | Output |
174
- |---|---|
175
- | `model` | `opus 4.6 1M ⁖` (controlled by `showFamily` / `showVersion` / `showContext` / `showEffortIcon`). Accent color is per family — opus purple, sonnet cyan, haiku silver, fable coral — with a per-generation override so opus 5+ reads lime rather than the 4.x purple. The trailing effort icon is mapped via `effort.icons` and colored like `effort`. |
176
- | `effort` | `high` (yellow), `xhigh` (orange) or `max` (pink); appends ` fast` (orange) when fast mode is on |
177
- | `context` | `■■■□□□□□□■ 153K/450K/50K` (bar + numbers; see Context section) |
178
- | `limit5h`, `limit7d` | `5h 22% ↑ ⟳ 2.4h`. The arrow is a burn-rate hint (see Burn rate); disable via `showBurnRate: false`. With `limit7d.perModel: true`, `limit7d` shows the active model's own weekly cap when it has one (e.g. `7d-fable 20% ↓↓ (92% ↑↑) ⟳ 3.5d`) — primary value is the model cap, the general weekly cap trails dimmed in parens with its own burn-rate arrow, since the two caps drain at different rates. Per-model caps come from the OAuth API's `limits[]` array (matched by `scope.model`), so `perModel` needs the API; models without a cap just show the general `7d`. A window Claude Code does not report is hidden — Ultra plans have no 5-hour limit, so `limit5h` disappears there on its own. |
179
- | `git.worktree` | `⎘ feature-xyz` — the linked worktree the session is in, from stdin `workspace.git_worktree` (any `git worktree add` checkout), else `worktree.name` (a Claude Code worktree session). Hidden in the main checkout. |
180
- | `git.branch` | `⎇ main` |
181
- | `git.diff` | `(+10,-2)`, or `*` for untracked-only changes |
182
- | `cost` | `$0.05` from stdin `cost.total_cost_usd`. Hidden by default unless `cost.onlyWhenFast: false` or fast mode is active. |
183
- | `extra` | `extra: $8.47/$40 (21%)` from `extra_usage` API. With `extra.onlyWhenActive: true`, hidden until fast mode is on or 5h/7d hit 100%. |
184
- | `cache` | `cache 87%` — cache hit rate: `cache_read / (cache_read + cache_creation + input)`, health-colored green ≥ 80%, yellow ≥ 50%, gray below. `cache.window` selects the scope: `"session"` (default) sums over all assistant messages in the transcript — a lifetime rate that stays high even on a resumed session; `"last"` uses only the most recent turn, so it reflects whether the cache is warm right now and drops after a resume re-primes it; `"both"` shows the last turn (primary, colored) then the session total marked `Σ` and dimmed, e.g. `cache 96% Σ91%`. With `cache.showExpiry: true` (off by default), the cache state from stdin `prompt_cache` trails the rate: while warm, the local time it goes cold (`cache 96% ⟳ 14:49`); once cold, `cold` and the tokens the next request writes back to the cache (`cache 96% cold ↑28K`). The expiry is a clock time rather than a countdown because Claude Code does not redraw the line while the session is idle — a countdown would freeze at whatever it read on the last response. Claude Code only reports `prompt_cache` after the first response of the running process, so a freshly resumed session shows the rate alone until then. |
185
- | `cache.tokens` | `↓340K ↑12K` — session cache totals: `↓` tokens reused from cache (green, cheap), `↑` tokens written to cache (yellow, first-time creation). |
186
- | `lines` | `+150/-30` from stdin `cost.total_lines_added/removed` |
187
- | `session` | `⏱ 12m` (session duration from stdin `cost.total_duration_ms`) |
188
- | `session.id` | `# abc12345` — first `session.idLength` chars of the Claude Code session UUID |
189
- | `version` | `v2.1.109` (Claude Code version) |
190
- | `cwd` | `⊕ ~/Work/projects/claude/glintline`. Format controlled by `cwd.format` (`smart` / `home` / `short` / `full`) and `cwd.maxLength`; prefix label via `cwd.label` (default `⊕`, set to `""` to hide) — see Working directory format. |
191
- | `sep` | inserts the configured `separator` literally |
192
- | `space` | inserts a single space |
193
-
194
- ### Customizing labels
195
-
196
- Every widget with a text label exposes it as a config field, so you can rename (or hide, by setting an empty string) it without touching the source:
197
-
198
- | Widget | Field | Default |
199
- |---|---|---|
200
- | `model` | `model.label` | `"✳"` |
201
- | `effort` | `effort.label` | `"∼"` |
202
- | `context` | `context.label` | `"⊠"` |
203
- | `limit5h` | `limit5h.label` | `"5h"` |
204
- | `limit7d` | `limit7d.label` | `"7d"` |
205
- | `extra` | `extra.label` | `"extra"` |
206
- | `cache` | `cache.label` / `cache.expiryLabel` / `cache.coldLabel` | `"cache"` / `"⟳"` / `"cold"` |
207
- | `session` | `session.label` | `"⏱︎"` |
208
- | `session.id` | `session.idLabel` | `"#"` |
209
- | `git.worktree` | `git.worktreeLabel` | `"⎘"` |
210
- | `cwd` | `cwd.label` | `"⊕"` |
211
-
212
- Example — shrink labels to icons:
213
-
214
- ```json
215
- { "cache": { "label": "≣" }, "session": { "label": "⌛" }, "limit5h": { "label": "5h" } }
216
- ```
217
-
218
- ### Narrow terminals
219
-
220
- When a line is wider than the terminal, whatever sits at its end gets truncated — usually the `7d` window rather than something you were willing to lose. `dropWhenNarrow` lists widgets to shed instead, least important first:
221
-
222
- ```json
223
- { "dropWhenNarrow": ["cache", "cost"] }
224
- ```
225
-
226
- The line is measured as rendered; widgets are dropped one at a time (each taking its separator with it) only while the result still overflows, so nothing disappears on a wide terminal. Widgets not in the list are never dropped.
227
-
228
- An entry can also trim a widget instead of removing it, so the line narrows in steps:
229
-
230
- | Step | Effect |
231
- |---|---|
232
- | `cache:session` | `window: "both"` loses the trailing `Σ` session rate: `96% Σ91%` → `96%` |
233
- | `cache:percent` | drops the rates, keeping the expiry/cold state: `96% cold ↑28K` → `cold ↑28K` (the widget disappears when there is no state to show) |
234
- | `context:buffer` | drops the compact buffer from `used/threshold/buffer`: `153K/450K/50K` → `153K/450K` |
235
- | `context:numbers` | drops the numbers, leaving the bar |
236
-
237
- ```json
238
- { "dropWhenNarrow": ["cache:session", "cache:percent", "context:buffer", "context:numbers", "cost"] }
239
- ```
240
-
241
- Steps and whole widgets mix freely and run in the listed order; a step is skipped when its widget is not on the line.
242
-
243
- Width is counted in terminal columns: SGR sequences, combining marks and variation selectors take none; CJK and emoji take two. East-Asian "Ambiguous" glyphs (`■ ∼ ↓ Σ`) count as one, which matches most non-CJK terminals — a terminal configured to render them double-width will be wider than measured.
244
-
245
- Claude Code exports `COLUMNS` before running the status line (v2.1.153+) — the script's stdout is a pipe, so `tput cols` cannot work from inside. When `COLUMNS` is missing or zero the width counts as unknown and nothing is dropped, so older versions keep rendering everything.
246
-
247
- The room is narrower than `COLUMNS`: Claude Code indents the line by two columns plus `statusLine.padding` and keeps the same margin on the right, cutting the rest with `…`. glintline fits lines into `COLUMNS − 2·(2 + statusLinePadding)`; `padding` is not passed to the command, so if you set it in Claude Code, repeat the value in `statusLinePadding`.
248
-
249
- ### Monochrome widgets
250
-
251
- `limit5h`, `limit7d`, `extra`, `cache` and `session` each accept a `mono: true` flag that disables their usage/health color scale — the value is rendered in the same muted `lightGray` as the label, so the widget no longer draws attention based on state.
252
-
253
- ```json
254
- { "cache": { "mono": true }, "limit5h": { "mono": true } }
255
- ```
256
-
257
- Label separators and countdowns stay in the dim gray they already used — only the "hot" color (green/yellow/red, or pink/orange) is flattened.
258
-
259
- ### Burn rate
260
-
261
- `limit5h` and `limit7d` append a single-glyph burn-rate hint
262
- after the percentage. It answers "at this pace, do I run out before the window
263
- resets?" (window start = `resets_at - duration`). The first 10% of the window
264
- always renders as `~` (too little signal to judge), and once the window has
265
- fully elapsed the hint is hidden.
266
-
267
- The projected utilization at reset is `current ÷ elapsed-fraction`. When that
268
- lands **under the cap**, the glyph grades the headroom by where you'd land:
269
-
270
- | Glyph | Projected at reset | Color |
271
- |---|---|---|
272
- | `~` | 80–100% | gray |
273
- | `↓` | 50–80% | muted green |
274
- | `↓↓` | < 50% | muted green |
275
-
276
- When the projection is **over the cap** (you'll hit 100% before reset), the
277
- glyph grades urgency by the share of the *remaining* time you'd spend locked at
278
- the cap — capping only in the final sliver still reads as `~`:
279
-
280
- | Glyph | Remaining time spent capped | Color |
281
- |---|---|---|
282
- | `~` | up to ~15% | gray |
283
- | `↑` | ~15–50% | muted yellow |
284
- | `↑↑` | more than half | muted red |
285
-
286
- This share-of-remaining-time measure stays meaningful for the whole window. A
287
- plain "utilization vs. elapsed pace" ratio is bounded by `1 / elapsed-fraction`,
288
- so `↑↑` (and eventually `↑`) become mathematically unreachable past the window's
289
- midpoint — exactly when the risk of getting cut off is highest.
290
-
291
- With `mono: true` the glyph is rendered in `lightGray` along with the rest of the widget. Set `showBurnRate: false` to hide.
292
-
293
- ### Multi-line layout
294
-
295
- `widgets` is a `string[][]` — each inner array is one rendered line, joined by `\n`. The default ships two lines: the main status line plus `["session.id", "cwd"]`. Empty lines (where every widget returned nothing) are dropped. To go back to a single line, just use one inner array:
296
-
297
- ```json
298
- { "widgets": [["model", "effort", "cost", "git.branch"]] }
299
- ```
300
-
301
- ### Auto-separator vs explicit
302
-
303
- - **Auto** (no `sep` or `space` in a line): the configured `separator` is inserted between non-empty widgets. Widgets sharing a namespace (everything before the dot, e.g. `git.branch` and `git.diff`) are joined by a single space instead, so they read as one segment.
304
- - **Explicit** (any `sep`/`space` in a line): the auto pass is disabled for that line and you place separators yourself. Separators adjacent to empty widgets or sitting at the edges are trimmed automatically.
305
-
306
- ### Working directory format
307
-
308
- `cwd.format` controls how the path is shown:
309
-
310
- | Value | Output for `/Users/me/Work/projects/claude/glintline` |
311
- |---|---|
312
- | `smart` (default) | `~/Work/projects/claude/glintline` if it fits in `cwd.maxLength` (default `40`); otherwise collapses middle segments — e.g. `~/…/claude/glintline`, then `/…/glintline` if still too long. |
313
- | `home` | `~/Work/projects/claude/glintline` (always full home-relative). |
314
- | `short` | `claude/glintline` (last two segments). |
315
- | `full` | `/Users/me/Work/projects/claude/glintline` (absolute, no `~`). |
316
-
317
- ### Bar styles
318
-
319
- `context.barStyle` selects a preset; `context.barChars: { full, empty }` overrides it with custom characters.
320
-
321
- | `barStyle` | Filled | Empty |
322
- |---|---|---|
323
- | `square` (default) | `■` | `□` |
324
- | `circle` (kamranahmedse style) | `●` | `○` |
325
- | `bar` | `█` | `░` |
326
- | `ascii` | `#` | `-` |
327
- | `dots` | `⬢` | `⬡` |
328
-
329
- The filled portion changes color by usage: < 75% green, 75–89% yellow, ≥ 90% red. The same scale colors the `5h`/`7d`/`extra` percentages and context numbers. Set top-level `"calmColors": true` to swap the vivid palette for muted earth tones — sage (ANSI 108) < 75%, warm ochre (179) ≥ 75%, muted brick (167) ≥ 90%.
330
-
331
- `context.gap` is the spacing between the bar and the numbers (default `" "` — two spaces).
332
-
333
- `context.showPercent: true` appends the percentage in parentheses: `153K/450K (34%)`.
334
-
335
- ### Context vs. auto-compact
336
-
337
- When auto-compact env vars are set, the context widget treats the compact threshold as the practical limit:
338
-
339
- - `CLAUDE_CODE_AUTO_COMPACT_WINDOW` — full window (e.g. `500000`)
340
- - `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE` — threshold percentage (e.g. `90`)
341
-
342
- With both set, `total = window × pct/100` (e.g. 450K). With only the window set, `total = window`. With neither, `context_window.context_window_size` from stdin is used.
343
-
344
- `context.showCompactBuffer: true` switches to a buffer-aware view:
345
-
346
- - The bar gets a third segment for the compact buffer, drawn as filled cells in a muted gray (looks "claimed but unavailable").
347
- - The numbers become `used / threshold / buffer`, e.g. `153K/450K/50K`, with `used` in the usage color, `threshold` in the same `lightGray` as widget labels, and `buffer` in the muted gray.
348
- - The color scale still measures `used / threshold`, so it goes red as you approach the compact point — not the full window.
349
-
350
- ### Cost and extra credits
351
-
352
- - `cost.onlyWhenFast: true` (default) keeps `cost` hidden outside fast mode, since fast mode is what burns real credits. Set to `false` to always display the session total.
353
- - `extra.onlyWhenActive: true` hides the `extra` widget unless fast mode is on or any of the 5h/7d windows reaches 100%. Useful as a "balance" warning that only shows when it matters.
354
-
355
- ### Examples
356
-
357
- Compact model, no version/context:
358
- ```json
359
- { "widgets": ["model","effort","context","git.branch","git.diff"], "model": { "showVersion": false, "showContext": false } }
360
- ```
361
- → `✳ opus ⁖ │ ∼ high │ ⊠ ■■□□□□□□□□ 153K/450K │ ⎇ main (+1,-2)`
362
-
363
- Branch and diff in different places, custom layout:
364
- ```json
365
- { "widgets": ["model","sep","git.branch","sep","context","sep","git.diff"] }
366
- ```
367
-
368
- Custom separator:
369
- ```json
370
- { "widgets": ["model","effort","cost","session"], "separator": " • ", "cost": { "onlyWhenFast": false } }
371
- ```
372
- → `✳ opus 4.6 1M ⁖ • ∼ high • $9.32 • ⏱ 1.7h`
373
-
374
- ## Environment variables
375
-
376
- | Variable | Purpose |
377
- |---|---|
378
- | `GLINTLINE_CONFIG` | Absolute path to a config file; overrides the search order. |
379
- | `GLINTLINE_DEBUG` | `1` or `true` — log recoverable errors to stderr as `[glintline:<scope>]`. |
380
- | `GLINTLINE_DUMP_STDIN` | Absolute path — write raw stdin JSON there on every invocation (for capturing fixtures). |
381
- | `GLINTLINE_DUMP_ENV` | Absolute path — write the terminal width Claude Code passed (`COLUMNS` / `LINES`) plus each rendered line and its measured column count, for debugging `dropWhenNarrow`. |
382
- | `CLAUDE_CODE_AUTO_COMPACT_WINDOW` | Full context window in tokens. See [Context vs. auto-compact](#context-vs-auto-compact). |
383
- | `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE` | Compact threshold percentage (0–100). |
384
-
385
- ## Development
386
-
387
- ```bash
388
- bun run dev < test/sample.json # run from sources
389
- bun run build # minified dist/glintline.js
390
- bun run test # bun test ./test
391
- bun run typecheck # tsc --noEmit
392
- bun run check # typecheck + test
393
- ```
394
-
395
- Caches:
396
-
397
- - Transcript scan state — incremental, keyed by transcript path. Stored in `$TMPDIR/glintline-cache/`. Bumped automatically when the cache schema changes (`v` field).
398
- - OAuth API response — 60s fresh window, 24h stale window, refreshed by a detached child process so the foreground render never blocks on the network.
399
-
400
- ## Contributing
76
+ ## Docs
401
77
 
402
- See [CONTRIBUTING.md](./CONTRIBUTING.md). Bug reports and small focused PRs are welcome.
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)
403
83
 
404
84
  ## License
405
85
 
package/dist/glintline.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- var C=(t,e,n)=>()=>{if(t)try{e=t(t=0)}catch(r){n=[r]}if(n)throw n[0];return e};import{readFileSync as Ft}from"node:fs";import{homedir as Y}from"node:os";import{join as X}from"node:path";function k(t){return!!t&&$t.test(t)}function v(t){if(!t)return"claude";for(let[e,n]of Gt)if(e.test(t))return n;return t.toLowerCase().match(/[a-z]+/)?.[0]??t.toLowerCase()}function Pt(t){if(!t)return;let e=t.match(/(\d+)[.-](\d+)/);if(e)return`${e[1]}.${e[2]}`;return t.match(/(\d+)/)?.[1]}function Dt(t,e){let n=`${t??""} ${e??""}`;return k(n)?"1M":void 0}function Bt(){let t=[X(Y(),".claude","settings.local.json"),X(Y(),".claude","settings.json")];for(let e of t)try{let n=Ft(e,"utf8"),r=JSON.parse(n);if(typeof r.effortLevel==="string"&&r.effortLevel.length>0)return r.effortLevel}catch{}return null}function q(t){let{input:e,sessionEffort:n,fast:r}=t,o=e.model?.id,i=e.model?.display_name,a=i??o,l=v(a),c=Pt(a),f=Dt(o,i),d=jt(e,n,c);return{family:l,version:c,context:f,effort:d,effortSessionOnly:n?.sessionOnly,fast:typeof e.fast_mode==="boolean"?e.fast_mode:r}}function jt(t,e,n){let r=t.effort;if(r&&"level"in r)return typeof r.level==="string"?r.level.toLowerCase():void 0;let o=e?.level??Bt()??void 0;return zt(o,n)}function zt(t,e){if(t!=="xhigh")return t;return(e?parseFloat(e):0)>=4.7?t:"high"}var Gt,$t;var O=C(()=>{Gt=[[/opus/i,"opus"],[/sonnet/i,"sonnet"],[/haiku/i,"haiku"],[/fable/i,"fable"]],$t=/(?:\b|\[)1m\b|1[\s_-]?million/i});function p(t,e){if(!Ht)return;let n=e instanceof Error?e.message:String(e);process.stderr.write(`[glintline:${t}] ${n}
3
- `)}var Ht;var y=C(()=>{Ht=process.env.GLINTLINE_DEBUG==="1"||process.env.GLINTLINE_DEBUG==="true"});import{mkdirSync as Jt,readFileSync as Kt,writeFileSync as Vt,statSync as Yt}from"node:fs";import{tmpdir as Xt}from"node:os";import{join as nt}from"node:path";import{createHash as qt}from"node:crypto";function Zt(){try{Jt(rt,{recursive:!0})}catch(t){p("cache.mkdir",t)}}function I(t){Zt();let e=qt("sha256").update(t).digest("hex").slice(0,16);return nt(rt,`${e}.json`)}function w(t,e){let n=I(t);try{let r=Yt(n);if((Date.now()-r.mtimeMs)/1000>e)return null;return JSON.parse(Kt(n,"utf8"))}catch{return null}}function x(t,e){let n=I(t);try{Vt(n,JSON.stringify(e))}catch(r){p("cache.write",r)}}var rt;var N=C(()=>{y();rt=nt(Xt(),"glintline-cache")});import{execFileSync as pe}from"node:child_process";import{readFileSync as me}from"node:fs";import{homedir as ge,platform as he}from"node:os";import{join as ye}from"node:path";function xe(){try{let t=pe("security",["find-generic-password","-s",be,"-w"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(!t)return null;return JSON.parse(t).claudeAiOauth?.accessToken??null}catch(t){return p("credentials.keychain",t),null}}function st(){try{let t=ye(ge(),".claude",".credentials.json"),e=me(t,"utf8");return JSON.parse(e).claudeAiOauth?.accessToken??null}catch(t){return p("credentials.file",t),null}}function W(){if(he()==="darwin")return xe()??st();return st()}var be="Claude Code-credentials";var at=C(()=>{y()});import{createHash as ut}from"node:crypto";import{spawn as _e}from"node:child_process";import{existsSync as Ce,unlinkSync as we}from"node:fs";import{resolve as Se}from"node:path";import{argv as Ee,execPath as Te}from"node:process";function Ne(t){let e={};if(!Array.isArray(t))return e;for(let n of t){if(!n||n.group!=="weekly")continue;let r=n.scope?.model?.display_name;if(typeof r!=="string")continue;let o=U({utilization:n.percent,resets_at:n.resets_at});if(o)e[v(r)]=o}return e}function lt(t){return"usage:"+ut("sha256").update(t).digest("hex").slice(0,16)}function M(t){return"usage-lock:"+ut("sha256").update(t).digest("hex").slice(0,16)}function Ae(t){if(!t)return 0;let e=Date.parse(t);return Number.isFinite(e)?Math.floor(e/1000):0}function U(t){if(!t||t.utilization===void 0)return;return{utilization:t.utilization,resets_at:Ae(t.resets_at)}}function We(t){if(!t||t.utilization===void 0)return;return{is_enabled:t.is_enabled??!1,monthly_limit:t.monthly_limit??0,used_credits:t.used_credits??0,utilization:t.utilization}}function Ue(t){if(!t)return 1/0;return Math.floor(Date.now()/1000)-t.fetched_at}function ct(t){return w(M(t),ve)!==null}function Me(t){x(M(t),{at:Math.floor(Date.now()/1000)})}function Re(t){try{let e=I(M(t));if(Ce(e))we(e)}catch(e){p("usage-api.lock",e)}}function Fe(){let t=Ee[1];if(!t)return;let e=Se(t);try{_e(Te,[e,"--refresh-usage"],{detached:!0,stdio:"ignore"}).unref()}catch(n){p("usage-api.spawn",n)}}async function Ge(t){let e=new AbortController,n=setTimeout(()=>e.abort(),ke);try{let r=await fetch(Oe,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${t}`,"anthropic-beta":"oauth-2025-04-20","User-Agent":"glintline/0.1"},signal:e.signal});if(!r.ok)return p("usage-api.fetch",`HTTP ${r.status}`),null;let o=await r.json(),i={five_hour:U(o.five_hour),seven_day:U(o.seven_day),seven_day_scoped:Ne(o.limits),extra:We(o.extra_usage),fetched_at:Math.floor(Date.now()/1000),source:"api"};return x(lt(t),i),i}catch(r){return p("usage-api.fetch",r),null}finally{clearTimeout(n)}}async function ft(){let t=W();if(!t)return;if(ct(t))return;Me(t);try{await Ge(t)}finally{Re(t)}}function dt(){let t=W();if(!t)return null;let e=w(lt(t),Le);if(Ue(e)>=Ie&&!ct(t))Fe();return e?{...e,source:"cache"}:null}var Oe="https://api.anthropic.com/api/oauth/usage",Ie=60,Le=86400,ke=8000,ve=30;var R=C(()=>{at();O();N();y()});O();import{writeFileSync as vt}from"node:fs";function Z(t,e){let n=process.env[t];if(!n)return null;let r=parseFloat(n);if(!Number.isFinite(r)||r<=0)return null;return Math.min(r,e)}function Q(t,e){let n=Z("CLAUDE_CODE_AUTO_COMPACT_WINDOW",1e7)??t,r=Z("CLAUDE_AUTOCOMPACT_PCT_OVERRIDE",100);if(r===null)return{total:n};let o=Math.round(n*(r/100));if(e)return{total:n,compactThreshold:o};return{total:o}}function tt(t,e){if(!t)return null;return{used:t.used,...Q(t.total,e)}}function et(t,e){let n=t.context_window;if(!n)return null;let r=Q(n.context_window_size??200000,e),o=n.current_usage;if(o){let i=(o.input_tokens??0)+(o.cache_creation_input_tokens??0)+(o.cache_read_input_tokens??0);if(i>0)return{used:i,...r}}if(n.total_input_tokens&&n.total_input_tokens>0)return{used:n.total_input_tokens,...r};if(n.used_percentage!==void 0)return{used:Math.round(n.used_percentage/100*r.total),...r};return null}N();O();y();import{openSync as Qt,readSync as te,closeSync as ee,statSync as ne}from"node:fs";var ot=4,re=604800;function L(){return{v:ot,scannedUpTo:0,ppid:0,effort:null,context:null,fast:!1,totals:{input:0,output:0,cacheRead:0,cacheCreation:0},last:null,lastId:null,lastOutput:0}}var oe=/Set effort level to ([a-z0-9-]+)(?:\s*\(([^)]*)\))?/i,ie=/\x1b\[[0-9;]*m/g,se=/Set model to .*?with ([a-z0-9-]+) effort/i,ae=/Fast mode (ON|OFF)/i,ue=200000;function le(t,e,n){if(n<=0)return"";let r=Qt(t,"r");try{let o=Buffer.alloc(n),i=te(r,o,0,n,e);return o.subarray(0,i).toString("utf8")}finally{ee(r)}}function ce(t){let e;if(typeof t==="string")e=t;else if(Array.isArray(t))e=t.map((r)=>typeof r==="object"&&r&&("text"in r)?String(r.text):"").join("");else return null;return e.match(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/)?.[1]??null}function fe(t){return k(t)?1e6:ue}function de(t,e){if(!t||t[0]!=="{")return;let n;try{n=JSON.parse(t)}catch{return}if(n.type==="user"&&n.message?.role==="user"){let o=ce(n.message.content)?.replace(ie,"");if(o){let i=o.match(oe);if(i){let l=(i[1]??"").toLowerCase(),c=(i[2]??"").toLowerCase();e.effort={level:l,sessionOnly:c.includes("this session only")||c.includes("session only")}}else{let l=o.match(se);if(l)e.effort={level:(l[1]??"").toLowerCase(),sessionOnly:!1}}let a=o.match(ae);if(a)e.fast=a[1].toUpperCase()==="ON"}}if(n.type==="assistant"&&n.message?.usage&&!n.isSidechain){let r=n.message.usage,o=r.input_tokens??0,i=r.output_tokens??0,a=r.cache_creation_input_tokens??0,l=r.cache_read_input_tokens??0,c=n.message.id??null;if(c!==null&&c===e.lastId&&e.last)e.totals.input-=e.last.input,e.totals.output-=e.lastOutput,e.totals.cacheRead-=e.last.cacheRead,e.totals.cacheCreation-=e.last.cacheCreation;e.totals.input+=o,e.totals.output+=i,e.totals.cacheRead+=l,e.totals.cacheCreation+=a,e.last={input:o,cacheRead:l,cacheCreation:a},e.lastId=c,e.lastOutput=i;let f=o+a+l;if(f>0)e.context={used:f,total:fe(n.message.model)}}}function A(t){return"transcript:"+t}function it(t){if(!t)return L();let e;try{e=ne(t).size}catch(g){return p("transcript.stat",g),L()}let n=w(A(t),re),r=n&&n.v===ot?n:L();if(r.scannedUpTo>e)r=L();let o=process.ppid;if(r.ppid!==0&&r.ppid!==o&&r.effort?.sessionOnly)r.effort=null;if(r.ppid=o,r.scannedUpTo===e)return x(A(t),r),r;let i=r.scannedUpTo,a=e-i,l;try{l=le(t,i,a)}catch(g){return p("transcript.read",g),r}let c=l.split(`
2
+ var C=(t,e,n)=>()=>{if(t)try{e=t(t=0)}catch(r){n=[r]}if(n)throw n[0];return e};import{readFileSync as Ft}from"node:fs";import{homedir as Y}from"node:os";import{join as X}from"node:path";function L(t){return!!t&&$t.test(t)}function v(t){if(!t)return"claude";for(let[e,n]of Gt)if(e.test(t))return n;return t.toLowerCase().match(/[a-z]+/)?.[0]??t.toLowerCase()}function Pt(t){if(!t)return;let e=t.match(/(\d+)[.-](\d+)/);if(e)return`${e[1]}.${e[2]}`;return t.match(/(\d+)/)?.[1]}function Dt(t,e){let n=`${t??""} ${e??""}`;return L(n)?"1M":void 0}function Bt(){let t=[X(Y(),".claude","settings.local.json"),X(Y(),".claude","settings.json")];for(let e of t)try{let n=Ft(e,"utf8"),r=JSON.parse(n);if(typeof r.effortLevel==="string"&&r.effortLevel.length>0)return r.effortLevel}catch{}return null}function q(t){let{input:e,sessionEffort:n,fast:r}=t,o=e.model?.id,i=e.model?.display_name,a=i??o,l=v(a),c=Pt(a),f=Dt(o,i),d=jt(e,n,c);return{family:l,version:c,context:f,effort:d,effortSessionOnly:n?.sessionOnly,fast:typeof e.fast_mode==="boolean"?e.fast_mode:r}}function jt(t,e,n){let r=t.effort;if(r&&"level"in r)return typeof r.level==="string"?r.level.toLowerCase():void 0;let o=e?.level??Bt()??void 0;return zt(o,n)}function zt(t,e){if(t!=="xhigh")return t;return(e?parseFloat(e):0)>=4.7?t:"high"}var Gt,$t;var O=C(()=>{Gt=[[/opus/i,"opus"],[/sonnet/i,"sonnet"],[/haiku/i,"haiku"],[/fable/i,"fable"]],$t=/(?:\b|\[)1m\b|1[\s_-]?million/i});function p(t,e){if(!Ht)return;let n=e instanceof Error?e.message:String(e);process.stderr.write(`[glintline:${t}] ${n}
3
+ `)}var Ht;var y=C(()=>{Ht=process.env.GLINTLINE_DEBUG==="1"||process.env.GLINTLINE_DEBUG==="true"});import{mkdirSync as Jt,readFileSync as Kt,writeFileSync as Vt,statSync as Yt}from"node:fs";import{tmpdir as Xt}from"node:os";import{join as nt}from"node:path";import{createHash as qt}from"node:crypto";function Zt(){try{Jt(rt,{recursive:!0})}catch(t){p("cache.mkdir",t)}}function I(t){Zt();let e=qt("sha256").update(t).digest("hex").slice(0,16);return nt(rt,`${e}.json`)}function w(t,e){let n=I(t);try{let r=Yt(n);if((Date.now()-r.mtimeMs)/1000>e)return null;return JSON.parse(Kt(n,"utf8"))}catch{return null}}function x(t,e){let n=I(t);try{Vt(n,JSON.stringify(e))}catch(r){p("cache.write",r)}}var rt;var N=C(()=>{y();rt=nt(Xt(),"glintline-cache")});import{execFileSync as pe}from"node:child_process";import{readFileSync as me}from"node:fs";import{homedir as ge,platform as he}from"node:os";import{join as ye}from"node:path";function xe(){try{let t=pe("security",["find-generic-password","-s",be,"-w"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(!t)return null;return JSON.parse(t).claudeAiOauth?.accessToken??null}catch(t){return p("credentials.keychain",t),null}}function st(){try{let t=ye(ge(),".claude",".credentials.json"),e=me(t,"utf8");return JSON.parse(e).claudeAiOauth?.accessToken??null}catch(t){return p("credentials.file",t),null}}function W(){if(he()==="darwin")return xe()??st();return st()}var be="Claude Code-credentials";var at=C(()=>{y()});import{createHash as ut}from"node:crypto";import{spawn as _e}from"node:child_process";import{existsSync as Ce,unlinkSync as we}from"node:fs";import{resolve as Se}from"node:path";import{argv as Ee,execPath as Te}from"node:process";function Ne(t){let e={};if(!Array.isArray(t))return e;for(let n of t){if(!n||n.group!=="weekly")continue;let r=n.scope?.model?.display_name;if(typeof r!=="string")continue;let o=U({utilization:n.percent,resets_at:n.resets_at});if(o)e[v(r)]=o}return e}function lt(t){return"usage:"+ut("sha256").update(t).digest("hex").slice(0,16)}function M(t){return"usage-lock:"+ut("sha256").update(t).digest("hex").slice(0,16)}function Ae(t){if(!t)return 0;let e=Date.parse(t);return Number.isFinite(e)?Math.floor(e/1000):0}function U(t){if(!t||t.utilization===void 0)return;return{utilization:t.utilization,resets_at:Ae(t.resets_at)}}function We(t){if(!t||t.utilization===void 0)return;return{is_enabled:t.is_enabled??!1,monthly_limit:t.monthly_limit??0,used_credits:t.used_credits??0,utilization:t.utilization}}function Ue(t){if(!t)return 1/0;return Math.floor(Date.now()/1000)-t.fetched_at}function ct(t){return w(M(t),ve)!==null}function Me(t){x(M(t),{at:Math.floor(Date.now()/1000)})}function Re(t){try{let e=I(M(t));if(Ce(e))we(e)}catch(e){p("usage-api.lock",e)}}function Fe(){let t=Ee[1];if(!t)return;let e=Se(t);try{_e(Te,[e,"--refresh-usage"],{detached:!0,stdio:"ignore"}).unref()}catch(n){p("usage-api.spawn",n)}}async function Ge(t){let e=new AbortController,n=setTimeout(()=>e.abort(),Le);try{let r=await fetch(Oe,{method:"GET",headers:{Accept:"application/json",Authorization:`Bearer ${t}`,"anthropic-beta":"oauth-2025-04-20","User-Agent":"glintline/0.1"},signal:e.signal});if(!r.ok)return p("usage-api.fetch",`HTTP ${r.status}`),null;let o=await r.json(),i={five_hour:U(o.five_hour),seven_day:U(o.seven_day),seven_day_scoped:Ne(o.limits),extra:We(o.extra_usage),fetched_at:Math.floor(Date.now()/1000),source:"api"};return x(lt(t),i),i}catch(r){return p("usage-api.fetch",r),null}finally{clearTimeout(n)}}async function ft(){let t=W();if(!t)return;if(ct(t))return;Me(t);try{await Ge(t)}finally{Re(t)}}function dt(){let t=W();if(!t)return null;let e=w(lt(t),ke);if(Ue(e)>=Ie&&!ct(t))Fe();return e?{...e,source:"cache"}:null}var Oe="https://api.anthropic.com/api/oauth/usage",Ie=60,ke=86400,Le=8000,ve=30;var R=C(()=>{at();O();N();y()});O();import{writeFileSync as vt}from"node:fs";function Z(t,e){let n=process.env[t];if(!n)return null;let r=parseFloat(n);if(!Number.isFinite(r)||r<=0)return null;return Math.min(r,e)}function Q(t,e){let n=Z("CLAUDE_CODE_AUTO_COMPACT_WINDOW",1e7)??t,r=Z("CLAUDE_AUTOCOMPACT_PCT_OVERRIDE",100);if(r===null)return{total:n};let o=Math.round(n*(r/100));if(e)return{total:n,compactThreshold:o};return{total:o}}function tt(t,e){if(!t)return null;return{used:t.used,...Q(t.total,e)}}function et(t,e){let n=t.context_window;if(!n)return null;let r=Q(n.context_window_size??200000,e),o=n.current_usage;if(o){let i=(o.input_tokens??0)+(o.cache_creation_input_tokens??0)+(o.cache_read_input_tokens??0);if(i>0)return{used:i,...r}}if(n.total_input_tokens&&n.total_input_tokens>0)return{used:n.total_input_tokens,...r};if(n.used_percentage!==void 0)return{used:Math.round(n.used_percentage/100*r.total),...r};return null}N();O();y();import{openSync as Qt,readSync as te,closeSync as ee,statSync as ne}from"node:fs";var ot=4,re=604800;function k(){return{v:ot,scannedUpTo:0,ppid:0,effort:null,context:null,fast:!1,totals:{input:0,output:0,cacheRead:0,cacheCreation:0},last:null,lastId:null,lastOutput:0}}var oe=/Set effort level to ([a-z0-9-]+)(?:\s*\(([^)]*)\))?/i,ie=/\x1b\[[0-9;]*m/g,se=/Set model to .*?with ([a-z0-9-]+) effort/i,ae=/Fast mode (ON|OFF)/i,ue=200000;function le(t,e,n){if(n<=0)return"";let r=Qt(t,"r");try{let o=Buffer.alloc(n),i=te(r,o,0,n,e);return o.subarray(0,i).toString("utf8")}finally{ee(r)}}function ce(t){let e;if(typeof t==="string")e=t;else if(Array.isArray(t))e=t.map((r)=>typeof r==="object"&&r&&("text"in r)?String(r.text):"").join("");else return null;return e.match(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/)?.[1]??null}function fe(t){return L(t)?1e6:ue}function de(t,e){if(!t||t[0]!=="{")return;let n;try{n=JSON.parse(t)}catch{return}if(n.type==="user"&&n.message?.role==="user"){let o=ce(n.message.content)?.replace(ie,"");if(o){let i=o.match(oe);if(i){let l=(i[1]??"").toLowerCase(),c=(i[2]??"").toLowerCase();e.effort={level:l,sessionOnly:c.includes("this session only")||c.includes("session only")}}else{let l=o.match(se);if(l)e.effort={level:(l[1]??"").toLowerCase(),sessionOnly:!1}}let a=o.match(ae);if(a)e.fast=a[1].toUpperCase()==="ON"}}if(n.type==="assistant"&&n.message?.usage&&!n.isSidechain){let r=n.message.usage,o=r.input_tokens??0,i=r.output_tokens??0,a=r.cache_creation_input_tokens??0,l=r.cache_read_input_tokens??0,c=n.message.id??null;if(c!==null&&c===e.lastId&&e.last)e.totals.input-=e.last.input,e.totals.output-=e.lastOutput,e.totals.cacheRead-=e.last.cacheRead,e.totals.cacheCreation-=e.last.cacheCreation;e.totals.input+=o,e.totals.output+=i,e.totals.cacheRead+=l,e.totals.cacheCreation+=a,e.last={input:o,cacheRead:l,cacheCreation:a},e.lastId=c,e.lastOutput=i;let f=o+a+l;if(f>0)e.context={used:f,total:fe(n.message.model)}}}function A(t){return"transcript:"+t}function it(t){if(!t)return k();let e;try{e=ne(t).size}catch(g){return p("transcript.stat",g),k()}let n=w(A(t),re),r=n&&n.v===ot?n:k();if(r.scannedUpTo>e)r=k();let o=process.ppid;if(r.ppid!==0&&r.ppid!==o&&r.effort?.sessionOnly)r.effort=null;if(r.ppid=o,r.scannedUpTo===e)return x(A(t),r),r;let i=r.scannedUpTo,a=e-i,l;try{l=le(t,i,a)}catch(g){return p("transcript.read",g),r}let c=l.split(`
4
4
  `),d=i>0?1:0;for(let g=d;g<c.length-1;g++)de(c[g]??"",r);let b=c[c.length-1]??"";return r.scannedUpTo=e-Buffer.byteLength(b,"utf8"),x(A(t),r),r}R();function $e(t){if(t===void 0)return 0;if(typeof t==="number")return t;let e=Date.parse(t);return Number.isFinite(e)?Math.floor(e/1000):0}function pt(t){if(!t||t.used_percentage===void 0)return;return{utilization:t.used_percentage,resets_at:$e(t.resets_at)}}function Pe(t){let e=t.rate_limits;if(!e)return null;let n=pt(e.five_hour),r=pt(e.seven_day);if(!n&&!r)return null;return{five_hour:n,seven_day:r,fetched_at:Math.floor(Date.now()/1000),source:"stdin"}}function De(t,e){if(!e)return t;if(!t)return e;return{...e,five_hour:t.five_hour,seven_day:t.seven_day,source:t.source}}function mt(t,e){let n=Pe(t);if(!e)return n;return De(n,dt())}var Be=new Set(["extra"]);function gt(t){let e=(n)=>t.widgets.some((r)=>r.some(n));if(e((n)=>Be.has(n)))return!0;return e((n)=>n==="limit7d")&&t.limit7d.perModel}y();import{execFileSync as je}from"node:child_process";var ze=1500;function S(t,e){return je("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:ze}).trim()}function ht(t){let e="";try{e=S(["symbolic-ref","--short","HEAD"],t)}catch{try{e=S(["rev-parse","--short","HEAD"],t)}catch{return null}}let n=0,r=0,o=!1,i=(a)=>{if(!a)return;o=!0;for(let l of a.split(`
5
5
  `)){let[c,f]=l.split("\t"),d=parseInt(c??"",10),b=parseInt(f??"",10);if(Number.isFinite(d))n+=d;if(Number.isFinite(b))r+=b}};try{i(S(["diff","--numstat"],t))}catch(a){p("git.diff",a)}try{i(S(["diff","--cached","--numstat"],t))}catch(a){p("git.diffCached",a)}try{if(S(["ls-files","--others","--exclude-standard"],t))o=!0}catch(a){p("git.untracked",a)}return{branch:e,added:n,removed:r,dirty:o}}var m=(t)=>`\x1B[38;5;${t}m`,s={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",gray:m(244),darkGray:m(240),darkestGray:m(236),lightGray:m(250),white:m(255),red:m(203),mutedRed:m(167),orange:m(214),yellow:m(220),mutedYellow:m(179),green:m(114),mutedGreen:m(108),cyan:m(73),mutedBlue:m(67),magenta:m(176),purple:m(141),lime:m(149),silver:m(251),pink:m(211),coral:m(209)},u=(t,e)=>`${t}${e}\x1B[0m`;function F(t){return t.replace(/\.0$/,"")}function h(t){if(t>=1e6){let e=t/1e6;return`${e>=10?e.toFixed(0):F(e.toFixed(1))}M`}if(t>=1000)return`${Math.round(t/1000)}K`;return String(t)}function G(t){if(t<=0)return"0m";let e=t/60;if(e<60)return`${Math.round(e)}m`;let n=e/60;if(n<24)return`${n>=10?Math.round(n):F(n.toFixed(1))}h`;let r=n/24;return`${r>=10?Math.round(r):F(r.toFixed(1))}d`}function yt(t){let e=new Date(t*1000);return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`}function _(t,e=!1){if(t>=90)return e?s.mutedRed:s.red;if(t>=75)return e?s.mutedYellow:s.yellow;return e?s.mutedGreen:s.green}function P(t){if(t>=80)return s.green;if(t>=50)return s.yellow;return s.gray}function bt(t,e,n){let r=t+e+n;return r>0?t/r*100:null}var D={square:{full:"■",empty:"□"},circle:{full:"●",empty:"○"},bar:{full:"█",empty:"░"},ascii:{full:"#",empty:"-"},dots:{full:"⬢",empty:"⬡"}};function xt(t,e,n,r){if(e<=0)return"";let{full:o,empty:i,threshold:a,fillEmpty:l=!1,calm:c=!1}=r,f=Math.min(1,Math.max(0,t/e)),d=Math.round(f*n),b=l?o:i,g=l?s.darkestGray:s.darkGray;if(a!==void 0&&a>0&&a<e){let Wt=t/a*100,Ut=_(Wt,c),Mt=Math.round(a/e*n),V=Math.max(0,Mt-d),Rt=Math.max(0,n-d-V);return u(Ut,o.repeat(d))+u(g,b.repeat(V))+u(s.gray,o.repeat(Rt))}let Nt=Math.max(0,n-d),At=_(f*100,c);return u(At,o.repeat(d))+u(g,b.repeat(Nt))}var He={opus:s.purple,sonnet:s.cyan,haiku:s.silver,fable:s.coral},Je=[["opus",5,s.lime]];function Ke(t,e){let n=e?parseFloat(e):0;for(let[r,o,i]of Je)if(t===r&&n>=o)return i;return He[t]??s.white}function Ve(t){let{model:e}=t,n=t.config.model,r=Ke(e.family,e.version),o=[];if(n.showFamily)o.push(u(s.bold+r,e.family));let i=[];if(n.showVersion&&e.version)i.push(e.version);if(n.showContext&&e.context)i.push(e.context);if(i.length>0)o.push(u(r,i.join(" ")));if(n.showEffortIcon&&e.effort){let l=t.config.effort.icons[e.effort];if(l)o.push(u(Ct(e.effort),l))}if(o.length===0)return null;let a=o.join(" ");return n.label?u(s.lightGray,n.label)+" "+a:a}function Ct(t){if(t==="max")return s.pink;if(t==="xhigh")return s.orange;return s.yellow}function Ye(t){let e=t.model.effort;if(!e)return null;let n=u(Ct(e),e);if(t.model.fast)n+=" "+u(s.orange,"fast");let r=t.config.effort.label;return r?u(s.lightGray,r)+" "+n:n}function Xe(t){if(!t.context)return null;let{context:e}=t,n=t.config.context,r=t.config.calmColors,o=e.compactThreshold??e.total,i=o>0?e.used/o*100:0,a=[];if(n.showBar){let c=D[n.barStyle]??D.square,f=n.barChars??c;a.push(xt(e.used,e.total,n.barWidth,{full:f.full,empty:f.empty,threshold:e.compactThreshold,fillEmpty:n.fillEmpty,calm:r}))}if(n.showNumbers){let c=_(i,r),f;if(e.compactThreshold!==void 0&&e.compactThreshold<e.total){let d=e.total-e.compactThreshold;if(f=u(c,h(e.used))+u(s.gray,"/")+u(s.lightGray,h(e.compactThreshold)),n.showBufferTokens)f+=u(s.gray,"/")+u(s.gray,h(d))}else f=u(c,`${h(e.used)}/${h(e.total)}`);if(n.showPercent)f+=" "+u(s.gray,"(")+u(c,`${Math.round(i)}%`)+u(s.gray,")");a.push(f)}if(a.length===0)return null;let l=a.join(n.gap);return n.label?u(s.lightGray,n.label)+" "+l:l}var wt={"5h":18000,"7d":604800};function _t(t,e,n,r){if(t.resets_at<=0)return null;let o=(e-(t.resets_at-n))/n;if(o>=1)return null;let i=r?s.lightGray:null;if(o<0.1)return{icon:"~",color:i??s.gray};let a=t.utilization,l=a/o;if(l<=100){if(l<50)return{icon:"↓↓",color:i??s.mutedGreen};if(l<80)return{icon:"↓",color:i??s.mutedGreen};return{icon:"~",color:i??s.gray}}let c=1-o,d=1-(100-a)/a*o/c;if(d>0.5)return{icon:"↑↑",color:i??s.mutedRed};if(d>0.15)return{icon:"↑",color:i??s.mutedYellow};return{icon:"~",color:i??s.gray}}function j(t,e,n,r,o,i){if(!t)return null;let a=Math.round(t.utilization),l=e.mono?s.lightGray:_(a,r),c=u(s.lightGray,e.label)+u(s.gray,e.separator)+u(l,`${a}%`);if(e.showBurnRate){let f=_t(t,n,o,e.mono);if(f)c+=" "+u(f.color,f.icon)}if(i){let f=u(s.darkGray,`${Math.round(i.utilization)}%`);if(e.showBurnRate){let d=_t(i,n,o,e.mono);if(d)f+=" "+u(d.color,d.icon)}c+=" "+u(s.darkGray,"(")+f+u(s.darkGray,")")}if(e.showCountdown&&t.resets_at>0){let f=t.resets_at-n;if(f>0)c+=u(s.gray,` ⟳ ${G(f)}`)}return c}function qe(t){return j(t.usage?.five_hour,t.config.limit5h,t.nowSec,t.config.calmColors,wt["5h"])}function Ze(t){let e=t.config.limit7d,n=t.usage?.seven_day,r=wt["7d"],o=e.perModel?t.usage?.seven_day_scoped?.[t.model.family]:void 0;if(o){let i=`${e.label}-${t.model.family}`;return j(o,{...e,label:i},t.nowSec,t.config.calmColors,r,n)}return j(n,e,t.nowSec,t.config.calmColors,r)}function Qe(t){let e=t.usage?.extra;if(!e||!e.is_enabled)return null;if(t.config.extra.onlyWhenActive){let a=t.model.fast,l=(t.usage?.five_hour?.utilization??0)>=100,c=(t.usage?.seven_day?.utilization??0)>=100;if(!a&&!l&&!c)return null}let n=Math.round(e.utilization),r=t.config.extra.mono?s.lightGray:_(n,t.config.calmColors),o=(e.used_credits/100).toFixed(2),i=(e.monthly_limit/100).toFixed(0);return u(s.lightGray,t.config.extra.label)+u(s.gray,": ")+u(r,`$${o}`)+u(s.gray,`/$${i}`)+" "+u(s.gray,"(")+u(r,`${n}%`)+u(s.gray,")")}function tn(t){let e=t.input.workspace?.git_worktree??t.input.worktree?.name;if(!e)return null;let n=t.config.git.worktreeLabel;return u(s.cyan,n?`${n} ${e}`:e)}function en(t){if(!t.git||!t.git.branch)return null;return u(s.magenta,"⎇ ")+u(s.bold+s.magenta,t.git.branch)}function nn(t){if(!t.git)return null;let e=t.git;if(e.added>0||e.removed>0)return u(s.gray,"(")+u(s.green,`+${e.added}`)+u(s.gray,",")+u(s.red,`-${e.removed}`)+u(s.gray,")");if(e.dirty)return u(s.yellow,"*");return null}function rn(t){return u(s.darkGray,t.config.separator)}function on(){return" "}function B(t){if(!t)return null;let e=bt(t.cacheRead,t.cacheCreation,t.input);return e===null?null:Math.round(e)}function sn(t){let e=t.config.cache,n=t.input.prompt_cache;if(!e.showExpiry||!n?.caching_observed)return null;let r=n.expires_at??0;if(n.warm&&r>t.nowSec){let a=yt(r);return u(s.gray,e.expiryLabel?`${e.expiryLabel} ${a}`:a)}let o=[];if(e.coldLabel)o.push(u(e.mono?s.lightGray:s.mutedBlue,e.coldLabel));let i=n.recache_tokens_if_cold;if(i)o.push(u(e.mono?s.lightGray:s.yellow,`↑${h(i)}`));return o.length>0?o.join(" "):null}function an(t){let e=t.config.cache,n=[];if(e.window==="both"){let i=B(t.cacheLast),a=B(t.totals);if(i!==null)n.push(u(e.mono?s.lightGray:P(i),`${i}%`));if(a!==null)n.push(u(s.darkGray,`Σ${a}%`))}else{let i=B(e.window==="last"?t.cacheLast:t.totals);if(i!==null)n.push(u(e.mono?s.lightGray:P(i),`${i}%`))}if(n.length===0)return null;if(!e.showPercent)n.length=0;let r=sn(t);if(r)n.push(r);if(n.length===0)return null;return(e.label?u(s.lightGray,e.label)+" ":"")+n.join(" ")}function un(t){let e=t.totals;if(e.cacheRead===0&&e.cacheCreation===0)return null;return u(s.green,`↓${h(e.cacheRead)}`)+" "+u(s.yellow,`↑${h(e.cacheCreation)}`)}function ln(t){if(t.config.cost.onlyWhenFast&&!t.model.fast)return null;let e=t.input.cost?.total_cost_usd;if(e===void 0)return null;return u(s.green,`$${e.toFixed(t.config.cost.precision)}`)}function cn(t){let e=t.input.cost?.total_lines_added,n=t.input.cost?.total_lines_removed;if(e===void 0&&n===void 0)return null;return u(s.green,`+${e??0}`)+u(s.gray,"/")+u(s.red,`-${n??0}`)}function fn(t){let e=t.input.cost?.total_duration_ms;if(!e)return null;let n=t.config.session,r=n.mono?s.lightGray:s.cyan;return(n.label?u(s.gray,n.label)+" ":"")+u(r,G(e/1000))}function dn(t){let e=t.input.version;return e?u(s.darkGray,`v${e}`):null}function pn(t){let e=t.input.workspace?.current_dir??t.input.cwd;if(!e)return null;let n=t.config.cwd,r=u(s.mutedBlue,mn(e,n.format,n.maxLength));return n.label?u(s.lightGray,n.label)+" "+r:r}function mn(t,e,n){let r=process.env.HOME??"",o=r&&t.startsWith(r)?"~"+t.slice(r.length):t;if(e==="full")return t;if(e==="home")return o;if(e==="short")return o.split("/").slice(-2).join("/");if(o.length<=n)return o;let i=o.split("/");if(i.length<=2)return o;let a=i[0],l=i.slice(-2).join("/"),c=`${a}/…/${l}`;if(c.length<=n)return c;let f=i[i.length-1];return`${a}/…/${f}`}function gn(t){let e=t.input.session_id;if(!e)return null;let n=t.config.session,r=n.idLength>0?n.idLength:e.length,o=e.slice(0,r),i=n.mono?s.lightGray:s.gray;return(n.idLabel?u(s.lightGray,n.idLabel)+" ":"")+u(i,o)}var hn={model:Ve,effort:Ye,context:Xe,limit5h:qe,limit7d:Ze,extra:Qe,"git.worktree":tn,"git.branch":en,"git.diff":nn,cache:an,"cache.tokens":un,cost:ln,lines:cn,session:fn,"session.id":gn,version:dn,cwd:pn,sep:rn,space:on},E=new Set(["sep","space"]);function St(t,e){let n=hn[t];return n?n(e):null}function z(t=process.env){let e=Number.parseInt(t.COLUMNS??"",10);return Number.isFinite(e)&&e>0?e:null}var yn=[[4352,4447],[11904,12350],[12353,13311],[13312,19903],[19968,40959],[40960,42191],[44032,55203],[63744,64255],[65072,65135],[65280,65376],[65504,65510],[127744,128591],[128640,128767],[129280,129535],[131072,262141]];function bn(t){return t>=768&&t<=879||t>=65024&&t<=65039||t>=8203&&t<=8205||t===65279}function xn(t){if(bn(t))return 0;for(let[e,n]of yn)if(t>=e&&t<=n)return 2;return 1}function H(t){let e=0;for(let n of t.replace(/\x1b\[[0-9;]*m/g,""))e+=xn(n.codePointAt(0));return e}function Et(t){let e=t.indexOf(".");return e>=0?t.slice(0,e):t}function _n(t,e){let n=u(s.darkGray,e),r=[],o=null;for(let i=0;i<t.length;i++){let a=t[i];if(!a.out)continue;if(o!==null){let l=Et(o)===Et(a.name)&&o!==a.name;r.push(l?{name:"space",out:" "}:{name:"sep",out:n})}r.push(a),o=a.name}return r}function Cn(t){let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(r.out===null||r.out==="")continue;if(E.has(r.name)){let i=e[e.length-1];if(!i)continue;if(!t.slice(n+1).some((l)=>l.out&&!E.has(l.name)))continue;if(E.has(i.name)){e[e.length-1]=r;continue}}e.push(r)}return e.map((n)=>n.out)}function Tt(t,e,n){let r=t.map((a)=>({name:a,out:St(a,e)})),i=t.some((a)=>E.has(a))?r:_n(r,n);return Cn(i).join("")}var wn={"cache:session":(t)=>t.cache.window==="both"?{...t,cache:{...t.cache,window:"last"}}:t,"cache:percent":(t)=>({...t,cache:{...t.cache,showPercent:!1}}),"context:buffer":(t)=>({...t,context:{...t.context,showBufferTokens:!1}}),"context:numbers":(t)=>({...t,context:{...t.context,showNumbers:!1}})};function Sn(t,e,n,r){let o=Tt(t,e,n);if(r===null)return o;let i=t,a=e;for(let l of e.config.dropWhenNarrow){if(H(o)<=r)break;let c=wn[l];if(c){if(!i.includes(l.slice(0,l.indexOf(":"))))continue;a={...a,config:c(a.config)}}else{if(!i.includes(l))continue;i=i.filter((f)=>f!==l)}o=Tt(i,a,n)}return o}function En(t,e){return t===null?null:t-2*(2+Math.max(0,e))}function Ot(t){let e={...t,nowSec:Math.floor(Date.now()/1000)},n=En(t.columns,t.config.statusLinePadding);return t.config.widgets.map((r)=>Sn(r,e,t.config.separator,n)).filter((r)=>r.length>0).join(`
6
- `)}y();import{readFileSync as Tn}from"node:fs";import{homedir as J}from"node:os";import{join as K}from"node:path";var It={widgets:[["model","effort","cost","context","limit5h","limit7d","extra","git.worktree","git.branch","git.diff"],["session.id","cwd"]],separator:" │ ",calmColors:!1,dropWhenNarrow:[],statusLinePadding:0,model:{showFamily:!0,showVersion:!0,showContext:!0,showEffortIcon:!0,label:"✳"},effort:{label:"∼",icons:{low:"·",medium:"⁚",high:"⁖",xhigh:"⁘",max:"⁙"}},context:{showBar:!0,showNumbers:!0,showPercent:!1,showCompactBuffer:!1,showBufferTokens:!0,fillEmpty:!0,barWidth:10,barStyle:"square",gap:" ",label:"⊠"},limit5h:{showCountdown:!0,separator:" ",label:"5h",mono:!1,showBurnRate:!0},limit7d:{showCountdown:!0,separator:" ",label:"7d",mono:!1,showBurnRate:!0,perModel:!1},cost:{precision:2,onlyWhenFast:!0},extra:{onlyWhenActive:!1,label:"extra",mono:!1},cache:{label:"cache",mono:!1,window:"session",showPercent:!0,showExpiry:!1,expiryLabel:"⟳",coldLabel:"cold"},git:{worktreeLabel:"⎘"},session:{label:"⏱︎",mono:!1,idLength:8,idLabel:"#"},cwd:{format:"smart",maxLength:40,label:"⊕"}};function On(){let t=process.env.GLINTLINE_CONFIG;if(t)return[t];return[K(J(),".config","glintline","settings.json"),K(J(),".config","glintline.json"),K(J(),".claude","glintline.json")]}function In(t){try{return JSON.parse(Tn(t,"utf8"))}catch(e){if(e.code!=="ENOENT")p("config.read",e);return null}}function T(t){return typeof t==="object"&&t!==null&&!Array.isArray(t)}var Ln=new Set(["__proto__","constructor","prototype"]);function Lt(t,e){if(!e)return t;if(!T(t)||!T(e))return t;let n={...t};for(let r of Object.keys(e)){if(Ln.has(r))continue;let o=e[r],i=n[r];if(o===void 0)continue;if(T(o)&&T(i))n[r]=Lt(i,o);else n[r]=o}return n}function kt(){for(let t of On()){let e=In(t);if(T(e))return Lt(It,e)}return It}y();async function kn(){if(process.stdin.isTTY)return"";let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf8")}function vn(t){if(!t.trim())return{};try{return JSON.parse(t)}catch{return{}}}async function Nn(){if(process.argv.includes("--refresh-usage")){await Promise.resolve().then(() => R());await ft();return}let t=await kn(),e=process.env.GLINTLINE_DUMP_STDIN;if(e)try{vt(e,t)}catch(d){p("stdin.dump",d)}let n=process.env.GLINTLINE_DUMP_ENV,r=vn(t),o=r.workspace?.current_dir??r.cwd??process.cwd(),i=kt(),a=it(r.transcript_path),l=mt(r,gt(i)),c=et(r,i.context.showCompactBuffer)??tt(a.context,i.context.showCompactBuffer),f=Ot({input:r,model:q({input:r,sessionEffort:a.effort,fast:a.fast}),context:c,usage:l,git:ht(o),totals:a.totals,cacheLast:a.last,config:i,columns:z()});if(n)try{vt(n,JSON.stringify({COLUMNS:process.env.COLUMNS??null,LINES:process.env.LINES??null,parsedColumns:z(),lines:f.split(`
7
- `).map((d)=>({width:H(d),text:d.replace(/\x1b\[[0-9;]*m/g,"")}))},null,2))}catch(d){p("env.dump",d)}process.stdout.write(f)}Nn().catch((t)=>{p("main",t),process.exit(0)});
6
+ `)}y();import{readFileSync as Tn}from"node:fs";import{homedir as J}from"node:os";import{join as K}from"node:path";var It={widgets:[["model","effort","cost","context","limit5h","limit7d","extra","git.worktree","git.branch","git.diff"],["session.id","cwd"]],separator:" │ ",calmColors:!1,dropWhenNarrow:[],statusLinePadding:0,model:{showFamily:!0,showVersion:!0,showContext:!0,showEffortIcon:!0,label:"✳"},effort:{label:"∼",icons:{low:"·",medium:"⁚",high:"⁖",xhigh:"⁘",max:"⁙"}},context:{showBar:!0,showNumbers:!0,showPercent:!1,showCompactBuffer:!1,showBufferTokens:!0,fillEmpty:!0,barWidth:10,barStyle:"square",gap:" ",label:"⊠"},limit5h:{showCountdown:!0,separator:" ",label:"5h",mono:!1,showBurnRate:!0},limit7d:{showCountdown:!0,separator:" ",label:"7d",mono:!1,showBurnRate:!0,perModel:!1},cost:{precision:2,onlyWhenFast:!0},extra:{onlyWhenActive:!1,label:"extra",mono:!1},cache:{label:"cache",mono:!1,window:"session",showPercent:!0,showExpiry:!1,expiryLabel:"⟳",coldLabel:"cold"},git:{worktreeLabel:"⎘"},session:{label:"⏱︎",mono:!1,idLength:8,idLabel:"#"},cwd:{format:"smart",maxLength:40,label:"⊕"}};function On(){let t=process.env.GLINTLINE_CONFIG;if(t)return[t];return[K(J(),".config","glintline","settings.json"),K(J(),".config","glintline.json"),K(J(),".claude","glintline.json")]}function In(t){try{return JSON.parse(Tn(t,"utf8"))}catch(e){if(e.code!=="ENOENT")p("config.read",e);return null}}function T(t){return typeof t==="object"&&t!==null&&!Array.isArray(t)}var kn=new Set(["__proto__","constructor","prototype"]);function kt(t,e){if(!e)return t;if(!T(t)||!T(e))return t;let n={...t};for(let r of Object.keys(e)){if(kn.has(r))continue;let o=e[r],i=n[r];if(o===void 0)continue;if(T(o)&&T(i))n[r]=kt(i,o);else n[r]=o}return n}function Ln(t){let e=t.widgets;if(Array.isArray(e)&&e.every((n)=>typeof n==="string"))return{...t,widgets:[e]};return t}function Lt(){for(let t of On()){let e=In(t);if(T(e))return Ln(kt(It,e))}return It}y();async function vn(){if(process.stdin.isTTY)return"";let t=[];for await(let e of process.stdin)t.push(e);return Buffer.concat(t).toString("utf8")}function Nn(t){if(!t.trim())return{};try{return JSON.parse(t)}catch{return{}}}async function An(){if(process.argv.includes("--refresh-usage")){await Promise.resolve().then(() => R());await ft();return}let t=await vn(),e=process.env.GLINTLINE_DUMP_STDIN;if(e)try{vt(e,t)}catch(d){p("stdin.dump",d)}let n=process.env.GLINTLINE_DUMP_ENV,r=Nn(t),o=r.workspace?.current_dir??r.cwd??process.cwd(),i=Lt(),a=it(r.transcript_path),l=mt(r,gt(i)),c=et(r,i.context.showCompactBuffer)??tt(a.context,i.context.showCompactBuffer),f=Ot({input:r,model:q({input:r,sessionEffort:a.effort,fast:a.fast}),context:c,usage:l,git:ht(o),totals:a.totals,cacheLast:a.last,config:i,columns:z()});if(n)try{vt(n,JSON.stringify({COLUMNS:process.env.COLUMNS??null,LINES:process.env.LINES??null,parsedColumns:z(),lines:f.split(`
7
+ `).map((d)=>({width:H(d),text:d.replace(/\x1b\[[0-9;]*m/g,"")}))},null,2))}catch(d){p("env.dump",d)}process.stdout.write(f)}An().catch((t)=>{p("main",t),process.exit(0)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glintline",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "A fast, configurable status line for Claude Code. Runs on Bun or Node, TypeScript, zero runtime dependencies, ~70ms per render on Bun.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/config.ts CHANGED
@@ -188,11 +188,21 @@ function merge<T>(base: T, over: DeepPartial<T> | undefined): T {
188
188
  return out as T;
189
189
  }
190
190
 
191
+ // A flat `["model", "effort"]` is one line, not a list of lines — without
192
+ // this, every line would be a string and the status line would render empty.
193
+ function normalizeWidgets(cfg: Config): Config {
194
+ const w: unknown = cfg.widgets;
195
+ if (Array.isArray(w) && w.every((name) => typeof name === "string")) {
196
+ return { ...cfg, widgets: [w as string[]] };
197
+ }
198
+ return cfg;
199
+ }
200
+
191
201
  export function loadConfig(): Config {
192
202
  for (const path of candidatePaths()) {
193
203
  const parsed = readJson(path);
194
204
  if (isPlainObject(parsed)) {
195
- return merge(DEFAULT_CONFIG, parsed as DeepPartial<Config>);
205
+ return normalizeWidgets(merge(DEFAULT_CONFIG, parsed as DeepPartial<Config>));
196
206
  }
197
207
  }
198
208
  return DEFAULT_CONFIG;