SLOPSHOPPER

io-meter

Context window fill plus where session time goes: API requests (main and subagents) and per-tool totals

bandguard
v0.1.0no licenseupdated 2026-10-15a19simma/configs/shell/.claude/mods/io-meter
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · io-meter
› 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 ☁ Cloudy 49% of context 97.4k / 200.0k last turns █ · $0.42 total (p90) │ api 0.0s (0.0s) │ tools 0.2s │ Bash 0.1s (0.0s) │ Write 0.0s (0.0s) │ Read 0.0s (0.0s) │ Grep 0.0s (0 ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
☁ Cloudy 49% of context 97.4k / 200.0k last turns █ · $0.42 total (p90) │ api 0.0s (0.0s) │ tools 0.2s │ Bash 0.1s (0.0s) │ Write 0.0s (0.0s) │ Read 0.0s (0.0s
README

Configuration Repository

This repository contains my dotfiles and configurations, managed with GNU Stow for symlink management and Homebrew for cross-platform dependency installation.

Nvim setup is based on kickstart.nvim

🚀 One-Command Setup

Linux/macOS:

git clone https://github.com/a19simma/configs ~/repos/configs && source ~/repos/configs/shell/.bashrc && bootstrap-configs

Windows (PowerShell):

git clone https://github.com//a19simma/configs $env:USERPROFILE\repos\configs; . $env:USERPROFILE\repos\configs\PowerShell\Microsoft.PowerShell_profile.ps1; Bootstrap-Configs

Structure

The repository is organized into Stow packages:

  • shell/ - Shell configuration (.zshrc, .bashrc)
  • nushell/ - Nushell configuration (config.nu, env.nu)
  • neovim/ - Neovim configuration
  • alacritty/ - Alacritty terminal config
  • vscode/ - VS Code settings and profiles
  • tmux/ - Tmux configuration (.tmux.conf)

Getting Started

Quick Bootstrap (Recommended)

Fresh Linux/macOS system:

# 1. Clone repository
git clone <your-repo-url> ~/repos/configs

# 2. Source the shell config to get bootstrap function
source ~/repos/configs/shell/.bashrc  # or .zshrc

# 3. Run bootstrap (installs mise + all dependencies + deploys configs)
bootstrap-configs

Fresh Windows system:

# 1. Clone repository
git clone <your-repo-url> $env:USERPROFILE\repos\configs

# 2. Import PowerShell profile to get bootstrap function
. $env:USERPROFILE\repos\configs\PowerShell\Microsoft.PowerShell_profile.ps1

# 3. Run bootstrap (installs scoop + mise + all dependencies + deploys configs)
Bootstrap-Configs

Manual Installation

Install Dependencies:

# Linux/macOS: Install via Homebrew Bundle
mise run install-deps

# Windows: Install via Scoop
mise run install-deps-windows

# Linux only: Install system-level dependencies
mise run install-system-deps

Deploy Dotfiles

Linux/macOS (GNU Stow):

# Deploy all dotfiles using GNU Stow
mise run stow-deploy

# Remove dotfiles
mise run stow-remove

Windows (PowerShell):

# Deploy Windows configurations
mise run deploy-windows

# Remove Windows configs
mise run remove-windows

Other Commands

# Backup existing configs
mise run backup-configs

# Sync configs from system to repo
mise run sync-from-local

# Update from kickstart.nvim
mise run sync-kickstart
Source 2 files
hooks/register.tsx 177 lines
1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { Reading, Timing } from '../types'
5
6const EMPTY: Timing = { ms: 0, samples: [] }
7
8const tools = atom({ plugin: 'io-meter', key: 'toolTimes' } as const, {})
9const api = atom({ plugin: 'io-meter', key: 'apiTimes' } as const, { main: EMPTY, sub: EMPTY })
10const readings = atom({ plugin: 'io-meter', key: 'readings' } as const, [])
11const usd = atom({ plugin: 'io-meter', key: 'usd' } as const, null)
12
13const SKIP = new Set(['Agent'])
14const TOP = 5
15const HISTORY = 12
16const SAMPLES = 200
17const BARS = '▁▂▃▄▅▆▇█'
18
19const FORECAST = [
20  { upTo: 25, icon: '☀', word: 'Clear', color: 'yellow' },
21  { upTo: 50, icon: '☁', word: 'Cloudy', color: 'cyan' },
22  { upTo: 75, icon: '☂', word: 'Showers', color: 'blue' },
23  { upTo: 90, icon: '☇', word: 'Storm', color: 'magenta' },
24  { upTo: Infinity, icon: '↯', word: 'Compact soon', color: 'red' },
25]
26
27function fmt(ms: number): string {
28  if (ms < 10_000) return (ms / 1000).toFixed(1) + 's'
29  if (ms < 60_000) return Math.round(ms / 1000) + 's'
30  const m = Math.floor(ms / 60_000)
31  return m + 'm' + String(Math.round((ms % 60_000) / 1000)).padStart(2, '0')
32}
33
34function short(n: number): string {
35  if (n >= 1_000_000) return (n / 1_000_000).toFixed(1) + 'M'
36  if (n >= 1_000) return (n / 1_000).toFixed(1) + 'k'
37  return String(n)
38}
39
40function bucket(tool: string): string {
41  const m = /^mcp__(.+?)__/.exec(tool)
42  return m ? m[1] : tool
43}
44
45function add(t: Timing, ms: number): Timing {
46  return { ms: t.ms + ms, samples: [...t.samples, ms].slice(-SAMPLES) }
47}
48
49function p90(t: Timing): number {
50  const sorted = [...t.samples].sort((x, y) => x - y)
51  return sorted[Math.ceil(sorted.length * 0.9) - 1] ?? 0
52}
53
54function forecastFor(percent: number) {
55  return FORECAST.find(f => percent < f.upTo) ?? FORECAST[FORECAST.length - 1]
56}
57
58function chart(rs: Reading[]): string {
59  const top = Math.max(...rs.map(r => r.tokens), 1)
60  return rs.map(r => BARS[Math.min(BARS.length - 1, Math.floor((r.tokens / top) * (BARS.length - 1)))]).join('')
61}
62
63function trend(rs: Reading[]): string {
64  const [prev, last] = rs.slice(-2)
65  if (!prev || !last) return ''
66  const delta = last.tokens - prev.tokens
67  if (delta > 0) return '▲ +' + short(delta)
68  if (delta < 0) return '▼ ' + short(-delta)
69  return 'steady'
70}
71
72async function measure($: EngineInterface) {
73  const { context: c, cost } = await $.session.usage({ breakdown: 'summary' })
74  await update($, usd, () => cost?.usd ?? null)
75  const window = Math.min(c.window, c.breakdown?.rawMaxTokens ?? c.window)
76  if (!window) return
77  const tokens = c.tokens ?? 0
78  const reading: Reading = { tokens, window, percent: Math.round((tokens / window) * 100) }
79  await update($, readings, rs => {
80    const last = rs[rs.length - 1]
81    if (last && last.tokens === reading.tokens && last.window === reading.window) return rs
82    return [...rs.filter(r => r.tokens > 0), reading].slice(-HISTORY)
83  })
84}
85
86export const register: Register = on => {
87  on('session.start', async ($, e, next) => {
88    const result = await next(e)
89    await measure($)
90    return result
91  })
92
93  on('session.measure', async ($, e, next) => {
94    await measure($)
95    return next(e)
96  })
97
98  on('tool.call', async ($, e, next) => {
99    const t0 = await $.clock.now()
100    const result = await next(e)
101    if (!SKIP.has(e.tool)) {
102      const ms = (await $.clock.now()) - t0
103      const key = bucket(e.tool)
104      await update($, tools, all => ({ ...all, [key]: add(all[key] ?? EMPTY, ms) }))
105    }
106    return result
107  })
108
109  on('turn.step', async function* ($, e, next) {
110    const t0 = await $.clock.now()
111    const result = yield* next(e)
112    const ms = (await $.clock.now()) - t0
113    await update($, api, a => (e.agentId ? { ...a, sub: add(a.sub, ms) } : { ...a, main: add(a.main, ms) }))
114    return result
115  })
116
117  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
118    if (e.props.hasSurvey) return next(e)
119
120    const rs = await read($, readings)
121    const cost = await read($, usd)
122    const a = await read($, api)
123    const t = await read($, tools)
124    const wide = (e.viewport?.columns ?? 80) >= 60
125    const { Box, Text } = $.ui.resolve(e)
126
127    const top = Object.entries(t)
128      .sort((x, y) => y[1].ms - x[1].ms)
129      .slice(0, TOP)
130    const toolMs = Object.values(t).reduce((s, v) => s + v.ms, 0)
131
132    const now = rs[rs.length - 1]
133    const f = now && forecastFor(now.percent)
134    const tr = trend(rs)
135
136    const ctxRow = now && f && (
137      <Box flexDirection="row">
138        <Text color={f.color} bold>
139          {f.icon} {f.word}
140        </Text>
141        <Text>  {now.percent}% of context</Text>
142        <Text dimColor>  {short(now.tokens)} / {short(now.window)}</Text>
143        {wide && <Text dimColor>   last turns </Text>}
144        {wide && <Text color={f.color}>{chart(rs)}</Text>}
145        {wide && tr !== '' && <Text dimColor>  {tr}</Text>}
146        {cost !== null && <Text dimColor>  · ${cost.toFixed(2)}</Text>}
147      </Box>
148    )
149
150    const ioRow = (
151      <Box flexDirection="row">
152        <Text dimColor>total (p90) │ api </Text>
153        <Text>{fmt(a.main.ms)}</Text>
154        <Text dimColor> ({fmt(p90(a.main))})</Text>
155        {a.sub.samples.length > 0 && <Text dimColor> + sub </Text>}
156        {a.sub.samples.length > 0 && <Text>{fmt(a.sub.ms)}</Text>}
157        {a.sub.samples.length > 0 && <Text dimColor> ({fmt(p90(a.sub))})</Text>}
158        <Text dimColor> │ tools </Text>
159        <Text>{fmt(toolMs)}</Text>
160        {wide &&
161          top.map(([name, s]) => (
162            <Text key={name} dimColor>
163              {' │ '}{name} {fmt(s.ms)} ({fmt(p90(s))})
164            </Text>
165          ))}
166      </Box>
167    )
168
169    return (
170      <Box flexDirection="column" paddingX={1}>
171        {ctxRow}
172        {ioRow}
173      </Box>
174    )
175  })
176}
177
types/index.d.ts 15 lines
1export type Timing = { ms: number; samples: number[] }
2export type ApiTiming = { main: Timing; sub: Timing }
3export type Reading = { tokens: number; window: number; percent: number }
4
5declare module 'claude-code' {
6  interface PluginState {
7    'io-meter': {
8      toolTimes: Record<string, Timing>
9      apiTimes: ApiTiming
10      readings: Reading[]
11      usd: number | null
12    }
13  }
14}
15