SLOPSHOPPER

usage-band

A band above the prompt showing context fill, tokens, cost and rate limits: stat tiles in the desktop app, a coloured row in the terminal

band
★ 1v0.4.0no licenseupdated 2026-10-24WeaponizedLego/claude-code-mods/usage-band
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · usage-band
› fix the failing auth test and add an audit log call ⏺ Read(src/auth.ts) ⎿ Read 6 lines ⏺ Update(src/auth.ts) ⎿ Added 2 lines, removed 1 line ⏺ Bash(bun test) ⎿ 3 pass, 1 fail ● Done. refresh now rejects expired claims and logs an audit event. ✻ Worked for 42s · done 4:20 PM ✻ context ━━━━━━━━━━ 49% 97k/200k / $0.42 / ↑6.4k ↓1.5k / cached 91k / 5h 31% ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
✻ context ━━━━━━━━━━ 49% 97k/200k / $0.42 / ↑6.4k ↓1.5k / cached 91k / 5h 31%
README

claude-code-mods

My Claude Code mods, one folder per mod. Needs Claude Code 2.1.287 or newer.

ModWhat it does
usage-bandA band above the prompt showing context fill, tokens, cost and rate limits: stat tiles in the desktop app, a coloured row in the terminal
plan-progressReads a phased plan into a live progress tree: phases, steps, elapsed time and an estimate of what is left
test-userA Haiku test user that clicks through your locally running app and reports UI/UX issues: its task list, findings and failures in a live pane
change-cardA short card explaining what an agent changed on this branch: a headline, a few one-line changes, where to look first and what was not checked
control-towerA board for a sentinel-hill hub: every ticket worktree with its PR, checks and next step, the validate run above the prompt, and guard rails that enforce the hub's steering

All five mods share one look, dark only: square slate panels on a navy ground, hairline rules, small spaced capitals for labels, light wide numerals, arc gauges and square-ended segment tracks. Amber marks what needs a look or is under way, periwinkle what is done, red what failed. In the desktop app's Code tab they draw as images, in Barlow where it is installed and the system sans otherwise; in the terminal they use the same colours as text.

usage-band in the desktop app

Install

At the prompt of a terminal Claude Code session:

/plugin install usage-band --marketplace WeaponizedLego/claude-code-mods
/plugin install plan-progress --marketplace WeaponizedLego/claude-code-mods

Answer y to add the marketplace, then pick the user scope. Or from a shell:

claude plugin marketplace add WeaponizedLego/claude-code-mods
claude plugin install usage-band@claude-code-mods
claude plugin install plan-progress@claude-code-mods

Update later with claude plugin marketplace update claude-code-mods, then claude plugin update usage-band@claude-code-mods.

plan-progress

plan-progress in the desktop app

When a plan with several phases is approved in plan mode, the mod reads its phases and steps (## Phase 1: ... headings, other work headings, or a nested list) into a tree and opens it in a pane. In the terminal it looks like this:

Move auth to sessions                         20m in · ~40m left
━━━━━━━━━━━━━━━━━━ 33%  2/6 steps · phase 2/3

✓ 1 Setup                                                 20m
  ├ ✓ Add the sessions table                              10m
  └ ✓ Write the session store                             10m
● 2 Switch over
  ├ ● Replace token checks in the middleware
  ├ ○ Update the login endpoint
  └ ○ Remove the old token helpers
○ 3 Verify
  └ ○ Run the auth test suite

The status line carries the short form (▰▰▱▱ 2/6 · phase 2/3: Switch over · 20m in · ~40m left). Steps move when Claude calls the mod's plan_mark tool, or by themselves when Claude's tasks or todos are named like a step. Without plan mode, ask Claude to lay the work out in phases and it calls plan_set. The estimate is the pace so far times the steps left.

During a run of small steps Claude can forget to mark them. When the tree hasn't moved for a while (at least 6 tool calls, and 3 minutes or 1.5× the pace so far, whichever is longer), the next tool result reminds Claude which step the tree shows. Claude can then catch up in one call: plan_mark with through: true closes every earlier open step and splits the elapsed time evenly between them.

/plan-progress opens the tree (it also works mid-turn); /plan-progress clear stops tracking.

test-user

test-user in the desktop app

A test user for the app you are running locally. Ask Claude to "test the app" (or a feature, a page, a flow) and it hands the job to test-user:tester, a subagent on Haiku that drives the app in the browser the way a person would: it works out what to test, finds the app (the URL you gave, .claude/launch.json, package.json), plans a handful of user tasks, works through them and reports each problem it sees. It never edits code, stays on localhost and only uses test data.

When you just say "test the app", Claude points it at the feature most recently built in the session; with nothing built, the tester looks at git diff and git log for a recent feature, and failing that tests the whole application.

The pane shows the run as it goes: status, tasks passed out of total, a count per severity (blocker, major, minor, polish), the task list with a note on each failure, a card per finding (worst first, with where and how to reproduce), a red card when it could not test at all, and earlier runs folded at the bottom. The status line carries the short form (test-user ● 3/6 tasks · 2 findings · 4m · Pay with the test card) and a toast says how it ended.

The session gets the full record, not just the tester's closing message: it rides back on the Agent result when the tester ran in the foreground, and on the next prompt (or the background task's notification) otherwise; test_report reads it any time. A tester whose turn ends early and is resumed carries on with the same run.

Claude gets the same reporting tools (test_plan, test_task, test_finding, test_finish), so a test it runs by hand shows in the pane too, and it can amend the latest tester run with what it re-checked. If the tester stops without a verdict, the record decides it; a "passed" never hides a failed task.

/test-user opens the pane; /test-user run [what to test] starts a run; /test-user clear forgets the runs.

change-card

change-card in the desktop app

/changes opens a Changes pane and asks Claude to explain what changed on the branch since it forked from origin/HEAD (or main/master), uncommitted and untracked files included. Run from a folder that is not itself a repository but holds checkouts (a task folder with one worktree per repo), it reads each of them and prefixes their paths with the folder's name. Claude answers by filling in the mod's change_card tool, which keeps the card short by refusing anything over its limits: a 70-character headline, a one-sentence gist, at most 5 one-line changes (with an optional before → after), at most 3 places to look first and 3 things nobody checked. Every changed file has to sit under one of the changes (a path ending in / covers a folder), so nothing hides.

When the code moves on after the card was written, the pane says which files and /changes asks Claude to update just what they affect. After a turn that leaves a sizeable diff (over 5 files or 200 lines) a toast suggests /changes, once per card; nothing is written unasked.

/changes <worktree or branch> explains that one instead of the session's own checkout: a worktree by its path, folder name, branch or any unique part of those (/changes PLAT-421), or a local branch at its tip. When the session's checkout has nothing changed (say, main with the work in .claude/worktrees/), /changes lists the worktrees that do. /changes <ref> compares against another ref; /changes clear forgets the card.

control-tower

control-tower in the desktop app

For a sentinel-hill hub: a repo you run agents from, with a repos.yaml registry, scripts/worktree.sh and one worktree per ticket under work/<repo>/<KEY>-<slug>. The mod does nothing in any other folder.

The pane opens when a session starts in the hub (or with /tower). It reads every worktree under work/ from disk and asks gh about its PR: one card per ticket, those that need you first, each with a big number (unresolved review threads, checks passed, commits ahead, time since merge) beside a five-stop track (start, build, PR, feedback, close). Under each card are buttons for the next step: Review and Finish while you build, Handle feedback when a PR has unresolved threads, Fix checks when they fail, Close task once it is merged. They run the hub's own skills (/review, /task-finish, /handle-pr-feedback, /task-close). A field at the bottom starts a ticket with /task-start or /implement-ticket. The board syncs every 3 minutes and after a push or gh pr create; a toast says when a PR gets new review threads or is merged.

Above the prompt, a band shows the repo's validate commands from repos.yaml as Claude runs them (done out of total, one bar per command, what is running or failed), or says when the hub is not set up (repos.local.yaml missing, or a gh token without read:packages) with a button that walks you through it. The status line names the ticket Claude is working in: ● OPS-123 · platform-apps · base develop · unattended.

control-tower's validate band

Guard rails refuse tool calls that break the hub's steering, with the reason as the tool result so Claude fixes the call and carries on:

  • git add -A, ., -u and the like: add files by name
  • a commit message that does not match the repo's commit_format with the branch's key, or that carries a Co-Authored-By or "Generated with" line
  • git merge
  • gh pr create from a ticket worktree without --draft, or without the label and assignee the repo's pr_labels and pr_assignee ask for
  • writing into a clone listed in repos.local.yaml (the worktree is the place), or into /tmp (use work/scratch/)
  • a Jira key in code or comments inside a worktree (prose files are fine)

The Unattended and Interactive buttons set the hub's mode: in interactive mode each prompt reminds Claude to stop for approval after the plan. /tower refresh syncs now; /tower interactive and /tower unattended set the mode.

Adding a mod

Put it in its own folder (<mod>/.claude-plugin/plugin.json, <mod>/hooks/...) and add an entry to .claude-plugin/marketplace.json. Check it with claude plugin validate ..

Source 3 files
hooks/register.tsx 178 lines
1import { atom, read, update } from 'claude-code'
2import type { Color, Register, SessionContextUsage, SessionCost, SessionRateLimit } from 'claude-code'
3
4import type { Snapshot, Tokens } from '../types'
5import { C, LIMIT_NAMES, TILE_H, bandSvg, compact, dollars, fill, level } from './look'
6
7const snapshot = atom({ plugin: 'usage-band', key: 'snapshot' } as const, null)
8const tokens = atom({ plugin: 'usage-band', key: 'tokens' } as const, { input: 0, output: 0, cacheRead: 0 })
9
10const ZERO: Tokens = { input: 0, output: 0, cacheRead: 0 }
11const BAR_CELLS = 10
12// A hairline bar, as the desktop's gauges: the filled part in the gauge colour, the rest on the track.
13const FILLED = '━'
14const TRACK = '━'
15// Roughly one cell of the desktop's code font, in CSS pixels.
16const CELL_PX = 8
17
18type Figures = { context: SessionContextUsage; rateLimits: SessionRateLimit[]; cost?: SessionCost }
19
20const toSnapshot = ({ context, rateLimits, cost }: Figures): Snapshot => ({
21  contextTokens: context.tokens ?? null,
22  window: context.window,
23  percent: context.percent ?? null,
24  costUsd: cost?.usd ?? null,
25  limits: rateLimits.map(({ kind, percentUsed }) => ({ kind, percentUsed })),
26})
27
28// One run of text in one colour: the band is laid out from these so its width
29// can be counted before it is drawn.
30type Run = { text: string; color?: Color; bold?: boolean }
31type Segment = { runs: Run[]; priority: number }
32
33const width = (runs: Run[]) => runs.reduce((sum, r) => sum + r.text.length, 0)
34
35function segments(snap: Snapshot | null, used: Tokens): Segment[] {
36  const out: Segment[] = []
37
38  const percent = snap?.percent
39  if (percent == null) {
40    out.push({ priority: 0, runs: [{ text: 'context ', color: C.muted }, { text: 'waiting for first reply', color: C.muted }] })
41  } else {
42    const filled = Math.min(BAR_CELLS, Math.round(percent / (100 / BAR_CELLS)))
43    out.push({
44      priority: 0,
45      runs: [
46        { text: 'context ', color: C.muted },
47        { text: FILLED.repeat(filled), color: fill(percent) },
48        { text: TRACK.repeat(BAR_CELLS - filled), color: C.edge },
49        { text: ` ${percent}%`, color: level(percent), bold: true },
50      ],
51    })
52    if (snap?.contextTokens != null) {
53      out.push({ priority: 3, runs: [{ text: ` ${compact(snap.contextTokens)}/${compact(snap.window)}`, color: C.muted }] })
54    }
55  }
56
57  if (snap?.costUsd != null) {
58    out.push({ priority: 1, runs: [{ text: dollars(snap.costUsd), color: C.text, bold: true }] })
59  }
60
61  if (used.input + used.output > 0) {
62    out.push({
63      priority: 2,
64      runs: [
65        { text: '↑', color: C.muted },
66        { text: `${compact(used.input)} `, color: C.done },
67        { text: '↓', color: C.muted },
68        { text: compact(used.output), color: C.text, bold: true },
69      ],
70    })
71    if (used.cacheRead > 0) {
72      out.push({ priority: 5, runs: [{ text: `cached ${compact(used.cacheRead)}`, color: C.muted }] })
73    }
74  }
75
76  for (const limit of snap?.limits ?? []) {
77    out.push({
78      priority: 4,
79      runs: [
80        { text: `${LIMIT_NAMES[limit.kind] ?? limit.kind} `, color: C.muted },
81        { text: `${Math.round(limit.percentUsed)}%`, color: level(limit.percentUsed), bold: true },
82      ],
83    })
84  }
85
86  return out
87}
88
89const SEPARATOR: Run = { text: ' / ', color: C.edge }
90const MARK: Run = { text: '✻ ', color: C.muted }
91
92// Drops the least important segments until the row fits, keeping the order.
93function fit(all: Segment[], columns: number): Run[] {
94  let kept = all
95  const total = (s: Segment[]) => width([MARK]) + s.reduce((sum, seg) => sum + width(seg.runs), 0) + width([SEPARATOR]) * Math.max(0, s.length - 1)
96
97  while (kept.length > 1 && total(kept) > columns) {
98    const worst = Math.max(...kept.map(s => s.priority))
99    const at = kept.map(s => s.priority).lastIndexOf(worst)
100    kept = kept.filter((_, i) => i !== at)
101  }
102
103  const runs: Run[] = [MARK]
104  kept.forEach((seg, i) => {
105    // The context tokens ride right after the bar, without a separator.
106    if (i > 0 && !(seg.priority === 3 && kept[i - 1]?.priority === 0)) runs.push(SEPARATOR)
107    runs.push(...seg.runs)
108  })
109  return runs
110}
111
112export const register: Register = on => {
113  on('session.start', async ($, e, next) => {
114    const result = await next(e)
115    // Fill the band before the first turn: the window size and, on a resumed
116    // session, what it has cost so far.
117    const usage = await $.session.usage()
118    await update($, snapshot, () => toSnapshot(usage))
119    return result
120  })
121
122  on('session.measure', async ($, e, next) => {
123    await update($, snapshot, () => toSnapshot(e))
124    return next(e)
125  })
126
127  on('turn.complete', async ($, e, next) => {
128    const usage = e.usage
129    // Main-thread turns only: a subagent's tokens show up in the cost, not here.
130    if (usage && !e.agentId) {
131      await update($, tokens, t => ({
132        input: t.input + usage.input_tokens + usage.cache_creation_input_tokens,
133        output: t.output + usage.output_tokens,
134        cacheRead: t.cacheRead + usage.cache_read_input_tokens,
135      }))
136    }
137    return next(e)
138  })
139
140  on('session.end', async ($, e, next) => {
141    if (e.reason === 'clear') {
142      await update($, tokens, () => ZERO)
143      await update($, snapshot, () => null)
144    }
145    return next(e)
146  })
147
148  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
149    if (e.props.hasSurvey) return next(e)
150
151    const snap = await read($, snapshot)
152    const used = await read($, tokens)
153
154    // Where the surface draws images and the band has the rows, a strip of stat tiles.
155    if (e.surface !== 'terminal' && e.props.maxRows >= 3) {
156      const { Box, Svg } = $.ui.resolve(e)
157      const strip = bandSvg(snap, used, e.props.bodyColumns * CELL_PX)
158      return (
159        <Box flexDirection="row" key="usage-band">
160          <Svg source={strip.source} alt={strip.alt} width={strip.width} height={TILE_H} />
161        </Box>
162      )
163    }
164
165    const runs = fit(segments(snap, used), e.props.bodyColumns)
166    const { Box, Text } = $.ui.resolve(e)
167    return (
168      <Box flexDirection="row" alignItems="center" key="usage-band">
169        {runs.map(r => (
170          <Text color={r.color} bold={r.bold}>
171            {r.text}
172          </Text>
173        ))}
174      </Box>
175    )
176  })
177}
178
hooks/look.ts 179 lines
1import type { Snapshot, Tokens } from '../types'
2
3// Dark only: slate panels on a navy ground, hairline rules, light wide numerals.
4// Periwinkle while there is room, amber from 70%, red past 90%. An SVG is drawn
5// as an image, so it takes real colours, not theme keys; the terminal uses the same.
6export const C = {
7  ground: '#1f2433',
8  card: '#282e40',
9  stroke: '#353c50',
10  edge: '#4a5168',
11  text: '#e8eaf0',
12  soft: '#c4c8d4',
13  muted: '#9aa1b5',
14  dim: '#6b7287',
15  accent: '#f5a524',
16  done: '#8b90d6',
17  hot: '#f0605d',
18} as const
19
20// Ivory while there is room, amber from 70%, red past 90%.
21export const level = (percent: number): string => (percent > 90 ? C.hot : percent >= 70 ? C.accent : C.text)
22// A gauge or bar is periwinkle while there is room, then takes the level colour.
23export const fill = (percent: number): string => (percent >= 70 ? level(percent) : C.done)
24
25export const compact = (n: number): string => {
26  if (n < 1000) return `${n}`
27  if (n < 1_000_000) return `${(n / 1000).toFixed(n < 10_000 ? 1 : 0)}k`
28  return `${(n / 1_000_000).toFixed(1)}M`
29}
30
31export const dollars = (usd: number): string => `$${usd < 10 ? usd.toFixed(2) : usd.toFixed(1)}`
32
33export const LIMIT_NAMES: Record<string, string> = { five_hour: '5h', seven_day: '7d', spend_limit: 'spend' }
34
35export const SANS = `font-family="Barlow, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif"`
36const esc = (t: string) => t.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')
37
38// Text in an image cannot truncate itself: cut it to an estimated width. Labels
39// are capitals, wider than the average letter.
40const LABEL_CH = 10 * 0.68 + 1.2
41const fit = (t: string, px: number, ch: number) => {
42  const max = Math.max(3, Math.floor(px / ch))
43  return t.length > max ? `${t.slice(0, max - 1)}…` : t
44}
45const label = (x: number, y: number, fill: string, body: string, px: number) =>
46  `<text x="${x.toFixed(1)}" y="${y}" font-size="10" fill="${fill}" letter-spacing="1.2">${esc(fit(body.toUpperCase(), px, LABEL_CH))}</text>`
47/** Estimated width of light numerals at a size. */
48const numeralsWidth = (t: string, size: number) => t.length * size * 0.5
49
50/** An open arc gauge, the gap at the bottom, with the number in the middle. */
51function gauge(cx: number, cy: number, r: number, percent: number, color: string, value: string): string {
52  const circ = 2 * Math.PI * r
53  const arc = circ * 0.8
54  const turn = `transform="rotate(126 ${cx} ${cy})"`
55  const p = Math.max(0, Math.min(100, percent))
56  return (
57    `<circle cx="${cx}" cy="${cy}" r="${r}" fill="none" stroke="${C.edge}" stroke-width="3" stroke-dasharray="${arc.toFixed(1)} ${circ.toFixed(1)}" ${turn}/>` +
58    (p > 0 ? `<circle cx="${cx}" cy="${cy}" r="${r}" fill="none" stroke="${color}" stroke-width="3" stroke-dasharray="${((arc * p) / 100).toFixed(1)} ${circ.toFixed(1)}" ${turn}/>` : '') +
59    `<text x="${cx}" y="${cy + 5}" text-anchor="middle" font-size="${value.length > 3 ? 12 : 15}" font-weight="300" letter-spacing="0.5" fill="${C.text}">${esc(value)}</text>`
60  )
61}
62
63type Tile = {
64  priority: number
65  label: string
66  value: string
67  valueColor: string
68  isHot?: boolean
69  aside?: string
70  sub?: { lead?: string; rest?: string }
71  gauge?: { percent: number; color: string }
72}
73
74function tiles(snap: Snapshot | null, used: Tokens): Tile[] {
75  const out: Tile[] = []
76  const percent = snap?.percent
77  out.push(
78    percent == null
79      ? { priority: 0, label: 'Context', value: '--', valueColor: C.muted, sub: { rest: 'waiting for first reply' } }
80      : {
81          priority: 0,
82          label: 'Context',
83          value: `${percent}%`,
84          valueColor: level(percent),
85          isHot: percent >= 70,
86          aside: snap?.contextTokens != null ? `${compact(snap.contextTokens)} / ${compact(snap.window)}` : undefined,
87          gauge: { percent, color: fill(percent) },
88        },
89  )
90  if (snap?.costUsd != null) {
91    out.push({ priority: 1, label: 'Cost', value: dollars(snap.costUsd), valueColor: C.text, sub: { rest: 'this session' } })
92  }
93  if (used.input + used.output > 0) {
94    out.push({
95      priority: 2,
96      label: 'Tokens',
97      value: compact(used.output),
98      valueColor: C.text,
99      aside: 'out',
100      sub: { lead: `${compact(used.input)} in`, rest: used.cacheRead > 0 ? ` / ${compact(used.cacheRead)} cached` : '' },
101    })
102  }
103  for (const limit of snap?.limits ?? []) {
104    const p = Math.round(limit.percentUsed)
105    out.push({
106      priority: 4,
107      label: `${LIMIT_NAMES[limit.kind] ?? limit.kind} limit`,
108      value: `${p}%`,
109      valueColor: level(p),
110      isHot: p >= 70,
111      gauge: { percent: p, color: fill(p) },
112    })
113  }
114  return out
115}
116
117export const TILE_H = 64
118const MIN_W = 150
119const MAX_W = 220
120const GAP = 8
121const PAD = 14
122const R = 22
123
124/** The band as one strip of stat tiles, the least important dropped to fit. */
125export function bandSvg(snap: Snapshot | null, used: Tokens, width: number): { source: string; width: number; alt: string } {
126  let kept = tiles(snap, used)
127  const fits = (n: number) => n * MIN_W + (n - 1) * GAP <= width
128  while (kept.length > 1 && !fits(kept.length)) {
129    const worst = Math.max(...kept.map(t => t.priority))
130    const at = kept.map(t => t.priority).lastIndexOf(worst)
131    kept = kept.filter((_, i) => i !== at)
132  }
133  const n = kept.length
134  const tileW = Math.max(MIN_W, Math.min(MAX_W, (width - (n - 1) * GAP) / n))
135  const W = Math.round(n * tileW + (n - 1) * GAP)
136  const inner = tileW - 2 * PAD
137
138  const parts = kept.map((t, i) => {
139    const x = i * (tileW + GAP)
140    const lx = x + PAD
141    const g: string[] = []
142    g.push(`<rect x="${(x + 0.5).toFixed(1)}" y="0.5" width="${(tileW - 1).toFixed(1)}" height="${TILE_H - 1}" fill="${C.card}" stroke="${t.isHot ? t.valueColor : C.stroke}"/>`)
143
144    if (t.gauge) {
145      // A gauge at the left, its label and the aside beside it.
146      g.push(gauge(lx + R, TILE_H / 2, R, t.gauge.percent, t.gauge.color, t.value.replace('%', '')))
147      const tx = lx + 2 * R + 12
148      const room = x + tileW - PAD - tx
149      g.push(label(tx, 28, C.muted, `${t.label} %`, room))
150      if (t.aside) g.push(`<text x="${tx.toFixed(1)}" y="46" font-size="13" fill="${C.soft}">${esc(fit(t.aside, room, 13 * 0.55))}</text>`)
151      return g.join('')
152    }
153
154    // A marker and the label, then the value in light numerals, the sub line under.
155    g.push(`<rect x="${lx}" y="9" width="2" height="10" fill="${C.text}"/>`)
156    g.push(label(lx + 8, 18, C.muted, t.label, inner - 8))
157    const size = Math.min(26, inner / Math.max(1, t.value.length * 0.56))
158    g.push(`<text x="${lx}" y="44" font-size="${size.toFixed(1)}" font-weight="300" letter-spacing="1" fill="${t.valueColor}">${esc(t.value)}</text>`)
159    if (t.aside) {
160      const ax = lx + numeralsWidth(t.value, size) + 6
161      // The aside shows whole or not at all.
162      if (t.aside.length * 7 <= x + tileW - PAD - ax) g.push(`<text x="${ax.toFixed(1)}" y="44" font-size="12" fill="${C.muted}">${esc(t.aside)}</text>`)
163    }
164    if (t.sub) {
165      const lead = t.sub.lead ?? ''
166      const whole = fit(lead + (t.sub.rest ?? ''), inner, 11 * 0.55)
167      const head = whole.slice(0, lead.length)
168      const tail = whole.slice(lead.length)
169      const spans = (head ? `<tspan fill="${C.done}">${esc(head)}</tspan>` : '') + (tail ? `<tspan fill="${C.muted}">${esc(tail)}</tspan>` : '')
170      g.push(`<text x="${lx}" y="57" font-size="11">${spans}</text>`)
171    }
172    return g.join('')
173  })
174
175  const source = `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${TILE_H}" viewBox="0 0 ${W} ${TILE_H}" ${SANS}>${parts.join('')}</svg>`
176  const alt = kept.map(t => (t.value === '--' ? `${t.label} ${t.sub?.rest ?? 'not known yet'}` : `${t.label} ${t.value}${t.aside ? ` ${t.aside}` : ''}`)).join(', ')
177  return { source, width: W, alt }
178}
179
types/index.d.ts 18 lines
1export type Limit = { kind: string; percentUsed: number }
2
3export type Snapshot = {
4  contextTokens: number | null
5  window: number
6  percent: number | null
7  costUsd: number | null
8  limits: Limit[]
9}
10
11export type Tokens = { input: number; output: number; cacheRead: number }
12
13declare module 'claude-code' {
14  interface PluginState {
15    'usage-band': { snapshot: Snapshot | null; tokens: Tokens }
16  }
17}
18