SLOPSHOPPER

tristens-tools

Tools menu for Claude Code: Clean View, Prompt Upgrade, model/effort control panel, Agent Dock, Roadtrip minigame.

panebandrowsguardcommandtoast
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · tristens-tools
│ ┃ Tristen's Tools ✕ › fix the failing auth test and add an audit log call │ ┃ ◆ TRISTEN'S TOOLS Opus 5.5 · Medium │ ┃ MODEL Haiku Sonnet Opus Fable ⏺ Read(src/auth.ts) │ ┃ EFFORT Low Med High XHigh Max ⎿ Read 6 lines │ ┃ ⏺ Update(src/auth.ts) │ ┃ S E T T I N G S ⎿ Added 2 lines, removed 1 line │ ┃ ● Clean View [ ○ Off ] ⏺ Bash(bun test) │ ┃ ● Prompt Upgrade [ ○ Off ] ⎿ 3 pass, 1 fail │ ┃ ● Helper agents [ Fast & Cheap ] │ ┃ ● Done. refresh now rejects expired claims and logs an audit event. │ ┃ L A U N C H │ ┃ ✦ Create photo or video ✻ Worked for 42s · done 4:20 PM │ ┃ ◆ Agent Dock │ ┃ ▶ Roadtrip › /tools │ ⎿ tristens-tools: Tristen's Tools opened. │ │ ⟨Claude Code's own drawing⟩ ◆ Opus 5.5 │ effort medium │ ctx ▰▰▱▱▱ 49% │ 5h 31% [ ◆ Tristen's Tools ▾ ] ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
⟨Claude Code's own drawing⟩ ◆ Opus 5.5 │ effort medium │ ctx ▰▰▱▱▱ 49% │ 5h 31% [ ◆ Tristen's Tools ▾ ]
Pane · Tristen's Tools
◆ TRISTEN'S TOOLS Opus 5.5 · Medium MODEL Haiku Sonnet Opus Fable EFFORT Low Med High XHigh Max S E T T I N G S ● Clean View [ ○ Off ] ● Prompt Upgrade [ ○ Off ] ● Helper agents [ Fast & Cheap ] L A U N C H ✦ Create photo or video ◆ Agent Dock ▶ Roadtrip
Pane · Agent Dock
◆ AGENT DOCK STANDING BY TEAM Off 1 3 5 10 20 50 100 Pick a team size; it applies to every request until set to Off. ╭────────────────────────────────────────────────────────╮ │ │ │ ● │ │ No team selected │ │ Requests run on a single agent. │ │ │ ╰────────────────────────────────────────────────────────╯
Pane · Roadtrip
◆ R O A D T R I P score 0 · best 0 │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ 🚗 │ [ ◀ a ][ d ▶ ][ Start (s) ]
README

claude-code-mods

🧩 Claude Code Mods: Make Your Terminal Come Alive

Claude Code now has mods: plugins made of TypeScript function hooks that can draw UI right inside the terminal, react to everything Claude does, and change how it works. This repo contains four mods I use every day. There's a pixel critter that lives above your prompt, a control panel for model, effort and parallel agents, a project launcher box, and a live status bar. It also has everything you need to build your own in about 10 minutes.

pixel-buddy walking, typing on its laptop and blowing bubbles above the Claude Code prompt

Claude Code TypeScript License: MIT

⚠️ Mods are early access. The function-hooks API can change between Claude Code releases. Everything here was built and tested on Claude Code 2.1.294.


⚡ Quick Start (30 seconds)

Open Claude Code in a terminal and paste:

/plugin install pixel-buddy --marketplace Bocskay-Botond/claude-code-mods

Answer y to add the marketplace, press Enter for the user scope, and you're done. A little orange critter appears above your prompt. Start typing and watch it pull out a laptop. 🧡

Want the full setup? 👉 quick-start/


🎮 What's Included

All four running together: the status bar, pixel-buddy, project-box and the Tristen's Tools menu.

statusbar, pixel-buddy, project-box and tristens-tools running together in Claude Code

ModWhat it doesCommands
🐾 pixel-buddyA 12×4 pixel Claude critter above the prompt. It types on a tiny laptop while you type, patrols while Claude works, celebrates when a turn finishes, plays when you're idle (football with a goal, dancing, jump rope, butterflies, bubbles, reading a book), reacts to greetings, thanks, commits, pushes and tool-call combos, shows how much of your 5-hour budget is left, and falls asleep after 3 minutes. Now and then a shot misses and knocks project-box apart, and the box rebuilds itself./buddy /pet
🛠️ tristens-toolsA tools menu and status line: model & effort picker, Clean View (hides tool noise and shows a simple checklist), Prompt Upgrade, Agent Dock (split each request across 1–100 helper agents and watch them live), and a Roadtrip racing minigame./tools /dock /roadtrip
📁 project-boxA folder-tree card beside the status bar listing your projects by category. Click a category, then a project, to see its note and path. pixel-buddy walks over and "types the cd" for you. On a narrow terminal it folds into one row of category buttons./projects
📊 statusbarA minimal one-line status bar: working/idle, tool count, last tool, last turn duration, turns. The simplest real mod in the repo, so read this one first.—
👋 hello-modThe tutorial example: a slash command, a toast and a band in about 35 lines./hello

What's new in 1.2

  • pixel-buddy shows your 5-hour budget: past 75% a battery appears in the corner of its stage (▰▰▱ 20%), past 90% it turns red and blinks and the critter sweats. When the budget runs out the critter goes grey and slumps like a flat battery, with a countdown to the reset (⧗1:23). When the window resets it jumps up: "recharged!". Try it with /buddy limit.
  • Fix: pixel-buddy no longer paints over project-box's left border. The box's published width now reaches the buddy, and the buddy assumes the widest card until it does.

What's new in 1.1

  • Works on narrow terminals: a half-screen window or a phone over SSH (Termius and similar). Every mod lays itself out for the width it gets.
  • pixel-buddy: football with a goal (juggle, dribble, shoot, "GOAL!"), a fixed reading pose, cute reactions (greetings, thanks, commit/push, tool combos, sneezes, /pet counter, a nightcap after 23:00).
  • project-box: stacks above the band on a narrow terminal, publishes its layout for neighbours, and falls apart and rebuilds when pixel-buddy's shot misses.
  • tristens-tools: a real Prompt Upgrade (one cheap Haiku call turns your prompt into a working brief), a model switch that sticks, and a status line that shortens on narrow terminals.

Install any of them the same way:

/plugin install <mod-name> --marketplace Bocskay-Botond/claude-code-mods

📂 Repository Structure

claude-code-mods/
├── .claude-plugin/
│   └── marketplace.json      # makes this repo a plugin marketplace
├── mods/
│   ├── pixel-buddy/          # 🐾 the critter
│   ├── tristens-tools/       # 🛠️ tools menu, Agent Dock, Roadtrip
│   ├── project-box/          # 📁 project launcher card
│   └── statusbar/            # 📊 one-line status bar
├── examples/
│   └── hello-mod/            # 👋 your first mod, fully commented
├── quick-start/              # ⚡ 5-minute setup
├── docs/
│   ├── installation.md       # every way to install & manage mods
│   ├── writing-your-own-mod.md
│   ├── api-cheatsheet.md     # events, $ nouns, UI elements
│   └── troubleshooting.md
├── mod-builder-prompt/       # 🤖 a prompt that makes Claude build mods for you
└── assets/                   # 🖼️ social preview + demo GIFs

Every mod is the same four small files:

my-mod/
├── .claude-plugin/plugin.json   # name, version, description
├── hooks/hooks.json             # { "modules": ["./register.tsx"] }
├── hooks/register.tsx           # the code
└── types/index.d.ts             # the state your mod keeps (optional)

🎯 What You'll Learn

  • What a Claude Code mod is, and how it differs from skills, slash commands and classic shell hooks
  • How the on(event, hook) / next(e) middleware chain works
  • How to draw UI in the terminal: bands above the prompt, panes, buttons, even a pixel raster at 25 fps
  • How to keep state with atoms and have the UI redraw automatically
  • How to change Claude's behaviour: swap the model per request, add system-prompt sections, react to tool calls
  • How to test a mod with claude plugin test and ship it as a GitHub marketplace

🚦 Prerequisites

  • Claude Code 2.1.294 or newer in a terminal (claude --version)
  • A Claude subscription or API key (whatever you already use with Claude Code)
  • Git if you want to clone and hack on the mods
  • Coffee ☕ (highly recommended)

No Node, no npm install, no build step. Claude Code compiles the TypeScript itself.


🔨 Build Your Own Mod

The fastest way is to ask Claude. Inside Claude Code:

Make me a mod that shows a 🍅 pomodoro timer above the prompt and plays a toast when it ends.

Claude Code has a built-in skill for this: it writes the mod, hot-reloads it into your session and tests it. For a better result, paste the prompt from mod-builder-prompt/ first.

Prefer to do it by hand? docs/writing-your-own-mod.md walks through hello-mod line by line, and docs/api-cheatsheet.md has the events and elements you'll use most.


📁 Configure project-box

project-box shows a demo list until you give it yours. Copy the example and edit it:

# macOS / Linux
cp mods/project-box/project-box.example.json ~/.claude/project-box.json

# Windows (PowerShell)
Copy-Item mods\project-box\project-box.example.json $HOME\.claude\project-box.json

Restart Claude Code (or run /reload-plugins) and your projects show up. Colors can be any terminal color name (magenta, cyan, green, yellow, blue, red). Set "live": true for a green dot.


🐛 Troubleshooting

ProblemFix
Nothing appears after installRun /reload-plugins, or restart Claude Code. Make sure you're in a terminal: /plugin isn't available in the desktop app's Code tab.
Marketplace file not foundCheck the repo name: Bocskay-Botond/claude-code-mods
A mod silently does nothingStart with claude --debug. A failing hook is skipped and logged with the reason.
Small window or phone (SSH)Every mod adapts to the terminal width. Below about 70 columns project-box stacks above the status rows, pixel-buddy gets a row of its own, and the tristens-tools line shortens.
Two bands fight for spacepixel-buddy, project-box and tristens-tools are designed to stack. Turn things off with /buddy, /projects, or /plugin → disable.

More: docs/troubleshooting.md


🤝 Contributing

Built a cool mod? PRs are welcome!

  1. Fork the repo
  2. Add your mod under mods/<your-mod>/ (four files, see above)
  3. Make sure claude plugin validate mods/<your-mod> and claude plugin test mods/<your-mod> pass
  4. Add it to .claude-plugin/marketplace.json and to the table in this README
  5. Open a PR with a screenshot or GIF 📸

📄 License

MIT. Do whatever you want, just don't blame me if your critter falls asleep on the job. 😴


🙏 Acknowledgments


☕ Support

If this made your terminal a little more fun, ⭐ star the repo and share it with someone who lives in Claude Code.

Now go build a mod. Your terminal has been boring for long enough. 🚀

Source 2 files
hooks/register.tsx 525 lines
1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, PromptOrigin, Register } from 'claude-code'
3
4import type { AgentRow, Game, Meter, Run, Seen, Step } from '../types'
5
6const BRAND = "Tristen's Tools"
7const ORANGE = '#e8714a'
8const PURPLE = '#a06bd6'
9const GREEN = '#2fd27a'
10
11const isClean = atom({ plugin: 'tristens-tools', key: 'isClean' } as const, false)
12const isUpgrade = atom({ plugin: 'tristens-tools', key: 'isUpgrade' } as const, false)
13const model = atom({ plugin: 'tristens-tools', key: 'model' } as const, 'default')
14const effort = atom({ plugin: 'tristens-tools', key: 'effort' } as const, 'default')
15const helper = atom({ plugin: 'tristens-tools', key: 'helper' } as const, 'haiku')
16const team = atom({ plugin: 'tristens-tools', key: 'team' } as const, '0')
17const IDLE: Run = { phase: 'idle', prompt: '', startedAt: 0, tools: 0, lastTool: '', steps: [] }
18const run = atom({ plugin: 'tristens-tools', key: 'run' } as const, IDLE)
19const agents = atom({ plugin: 'tristens-tools', key: 'agents' } as const, [] as AgentRow[])
20const meter = atom({ plugin: 'tristens-tools', key: 'meter' } as const, { ctx: 0, five: 0, now: 0 } as Meter)
21const seen = atom({ plugin: 'tristens-tools', key: 'seen' } as const, { model: '', effort: '' } as Seen)
22const FRESH: Game = { isRunning: false, isOver: false, x: 1, score: 0, best: 0, obstacles: [] }
23const game = atom({ plugin: 'tristens-tools', key: 'game' } as const, FRESH)
24
25const MODELS: Record<string, { id: string; label: string }> = {
26  haiku: { id: 'claude-haiku-5-5', label: 'Haiku 5.5' },
27  sonnet: { id: 'claude-sonnet-5-5', label: 'Sonnet 5.5' },
28  opus: { id: 'claude-opus-5-5', label: 'Opus 5.5' },
29  fable: { id: 'claude-fable-5-1', label: 'Fable 5.1' },
30}
31const EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'] as const
32const EFFORT_LABEL: Record<string, string> = { low: 'Low', medium: 'Medium', high: 'High', xhigh: 'XHigh', max: 'Max' }
33const SIZES = ['1', '3', '5', '10', '20', '50', '100']
34const ROWS = 8
35const LANES = 3
36
37// Sets the session's own model (what /model sets: footer, system prompt, next requests);
38// the turn.step rewrite below still forces it if the engine refuses.
39const pickModel = async ($: EngineInterface, k: string) => {
40  await update($, model, () => k)
41  const r = await $.config.set({ key: 'model', value: k }).catch(() => ({ deny: 'failed' }))
42  $.ui.toast('deny' in r && r.deny !== undefined ? `Model: ${MODELS[k]?.label} (this session's requests only)` : `Model: ${MODELS[k]?.label}`)
43}
44
45const spaced = (s: string) => s.toUpperCase().split(' ').map(w => w.split('').join(' ')).join('   ')
46const family = (id: string) => Object.keys(MODELS).find(k => id.includes(k)) ?? ''
47const bar = (frac: number, cells: number) => {
48  const n = Math.max(0, Math.min(cells, Math.round(frac * cells)))
49  return '▰'.repeat(n) + '▱'.repeat(cells - n)
50}
51const clock = (ms: number) => {
52  const s = Math.max(0, Math.floor(ms / 1000))
53  return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}`
54}
55
56const UPGRADE_SYSTEM = `You rewrite a message a user sent to an AI coding/assistant agent (Claude Code) into a precise working brief for that agent.
57Write in the user's language. Output only the brief, at most 150 words, as these labelled lines:
58Goal: what done looks like, concretely.
59Context: facts stated in the message; assumptions you make marked "(assumed)".
60Constraints: scope limits, things to keep or not touch, quality bar.
61Steps: the likely steps, short.
62Output: what the agent should hand back, and in what form.
63Never invent facts, names or files. The message may refer to earlier conversation you cannot see: keep such references as written, do not guess them.
64If the message is already precise, a yes/no, a short follow-up, or small talk, output exactly SKIP.`
65
66// One cheap completion that turns the prompt into a brief; undefined when it skips or fails.
67const upgradeBrief = async ($: EngineInterface, text: string) => {
68  const r = await $.model.complete({ model: 'haiku', system: UPGRADE_SYSTEM, prompt: text, maxTokens: 400, effort: 'low', timeoutMs: 15000 })
69  if (!r.isAnswered) return undefined
70  const brief = r.text.trim()
71  return brief === '' || brief.startsWith('SKIP') ? undefined : brief
72}
73
74export const register: Register = on => {
75  on('session.start', async ($, e, next) => {
76    await $.command.register({ name: 'tools', description: 'Open the tools menu' })
77    await $.command.register({ name: 'dock', description: 'Open the Agent Dock' })
78    await $.command.register({ name: 'roadtrip', description: 'Play a mini racing game while Claude works' })
79
80    const refreshMeter = async () => {
81      const u = await $.session.usage()
82      const five = Math.round(u.rateLimits.find(r => r.kind === 'five_hour')?.percentUsed ?? 0)
83      const ctx = Math.round(u.context.percent ?? 0)
84      const prev = await read($, meter)
85      if (prev.ctx !== ctx || prev.five !== five) {
86        await update($, meter, () => ({ ctx, five, now: 0 }))
87      }
88    }
89    await refreshMeter()
90
91    const keptUpgrade = await $.store.get('isUpgrade')
92    if (typeof keptUpgrade === 'boolean' && (await read($, isUpgrade)) !== keptUpgrade) await update($, isUpgrade, () => keptUpgrade)
93
94    const fam = family(await $.session.model())
95    if (fam !== '' && (await read($, model)) === 'default') await update($, model, () => fam)
96
97    $.clock.every(250, async () => {
98      const g = await read($, game)
99      if (!g.isRunning) return
100      await update($, game, cur => {
101        let obstacles = cur.obstacles.map(o => ({ ...o, y: o.y + 1 }))
102        const hit = obstacles.some(o => o.y === ROWS - 1 && o.lane === cur.x)
103        const passed = obstacles.filter(o => o.y >= ROWS).length
104        obstacles = obstacles.filter(o => o.y < ROWS)
105        if (Math.random() < 0.5) obstacles.push({ lane: Math.floor(Math.random() * LANES), y: 0 })
106        const score = cur.score + passed
107        return hit
108          ? { ...cur, obstacles, isRunning: false, isOver: true, best: Math.max(cur.best, score), score }
109          : { ...cur, obstacles, score }
110      })
111    })
112
113    $.clock.every(1000, async () => {
114      const now = await $.clock.now()
115      const list = await $.agent.list()
116      const prev = await read($, agents)
117      const rows: AgentRow[] = list.map(a => ({
118        id: a.id,
119        label: a.description || a.type,
120        status: a.status,
121        startedAt: prev.find(p => p.id === a.id)?.startedAt ?? now,
122      }))
123      const r = await read($, run)
124      if (JSON.stringify(prev) !== JSON.stringify(rows) || rows.some(x => x.status === 'running') || r.phase === 'working') {
125        await update($, agents, () => rows)
126      }
127      await refreshMeter()
128    })
129
130    return next(e)
131  })
132
133  on('session.measure', async ($, e, next) => {
134    const u = await $.session.usage()
135    const five = Math.round(u.rateLimits.find(r => r.kind === 'five_hour')?.percentUsed ?? 0)
136    await update($, meter, () => ({ ctx: Math.round(u.context.percent ?? 0), five, now: 0 }))
137    return next(e)
138  })
139
140  on('command.run', { command: 'tools' }, async $ => {
141    await $.ui.open({ id: 'tools', title: BRAND, focus: true })
142    return { text: `${BRAND} opened.` }
143  })
144  on('command.run', { command: 'dock' }, async $ => {
145    await $.ui.open({ id: 'dock', title: 'Agent Dock', focus: true })
146    return { text: 'Agent Dock open.' }
147  })
148  on('command.run', { command: 'roadtrip' }, async $ => {
149    await $.ui.open({ id: 'roadtrip', title: 'Roadtrip', focus: true })
150    return { text: 'Roadtrip opened: a/d steer, s start.' }
151  })
152
153  // ---- run tracking (Clean View checklist) ----
154  on('prompt.submit', async ($, e, next) => {
155    const now = await $.clock.now()
156    const steps: Step[] = [
157      { text: 'Understand your request', status: 'active' },
158      { text: 'Plan the steps', status: 'next' },
159    ]
160    await update($, run, () => ({ phase: 'working', prompt: e.text, startedAt: now, tools: 0, lastTool: '', steps }))
161
162    const o = e.origin as PromptOrigin | undefined
163    const isTyped = o === undefined || o.kind === 'composer' || o.kind === 'bridge' || (o.kind === 'plugin' && o.asUser === true)
164    const text = e.text.trim()
165    if (!isTyped || !(await read($, isUpgrade)) || text.startsWith('/') || text.length < 15) return next(e)
166    $.ui.status('✦ Prompt Upgrade…')
167    const brief = await upgradeBrief($, e.text).catch(() => undefined)
168    $.ui.status(undefined)
169    if (brief === undefined) return next(e)
170    $.ui.log(`✦ Prompt Upgrade brief:
171${brief}`)
172    const block = `<prompt-upgrade-brief>
173An upgraded brief of the user's message above, written by the Prompt Upgrade tool. Work from it; where it conflicts with the user's own words, the user's words win.
174
175${brief}
176</prompt-upgrade-brief>`
177    return next({ ...e, context: [...(e.context ?? []), block] })
178  })
179  on('tool.call', async ($, e, next) => {
180    const todos = 'todos' in e && Array.isArray(e.todos) ? (e.todos as { content?: string; status?: string }[]) : undefined
181    await update($, run, (r): Run => {
182      let steps: Step[] = r.steps
183      if (todos !== undefined) {
184        steps = todos.map(t => ({
185          text: t.content ?? '',
186          status: t.status === 'completed' ? ('done' as const) : t.status === 'in_progress' ? ('active' as const) : ('next' as const),
187        }))
188      } else if (r.tools === 0) {
189        steps = [
190          { text: 'Understand your request', status: 'done' },
191          { text: 'Plan the steps', status: 'active' },
192        ]
193      }
194      return { ...r, tools: r.tools + 1, lastTool: e.tool, steps }
195    })
196    return next(e)
197  })
198  on('turn.complete', async ($, e, next) => {
199    await update($, run, (r): Run => ({ ...r, phase: 'idle', steps: r.steps.map(s => ({ ...s, status: 'done' as const })) }))
200    return next(e)
201  })
202
203  // ---- control panel: model / effort override, helper agents' model ----
204  on('turn.step', async function* ($, e, next) {
205    const [m, f, hp, s] = await Promise.all([read($, model), read($, effort), read($, helper), read($, seen)])
206    const wanted = e.agentId !== undefined && hp === 'haiku' ? 'haiku' : m
207    const changed = { ...e }
208    if (MODELS[wanted] !== undefined) changed.model = MODELS[wanted].id
209    if (e.agentId === undefined && (EFFORTS as readonly string[]).includes(f)) changed.effort = f as (typeof EFFORTS)[number]
210    if (e.agentId === undefined) {
211      const eff = String(changed.effort ?? '')
212      if (s.model !== changed.model || s.effort !== eff) await update($, seen, () => ({ model: changed.model, effort: eff }))
213    }
214    return yield* next(changed)
215  })
216
217  // ---- Agent Dock + Prompt Upgrade: extra system prompt sections ----
218  on('prompt.compose', async ($, e, next) => {
219    const out = await next(e)
220    const n = Number(await read($, team))
221    const up = await read($, isUpgrade)
222    const sections = [...out.sections]
223    if (n > 0) {
224      sections.push({
225        id: 'tristens-tools:team',
226        text: `Split each request across about ${n} parallel helper subagents (Agent tool), launching up to 10 at a time, then combine their results.`,
227        scope: 'session' as const,
228      })
229    }
230    if (up) {
231      sections.push({
232        id: 'tristens-tools:upgrade',
233        text: "Prompt Upgrade is on. A user message may carry a <prompt-upgrade-brief> block: treat it as the working spec (goal, constraints, steps, output) and check your result against it before you finish; the user's own words override it. When a message has no brief, first restate the request to yourself as goal, constraints and expected output, then work from that.",
234        scope: 'session' as const,
235      })
236    }
237    return { sections }
238  })
239
240  // ---- Clean View: hide technical rows ----
241  on('ui.render', { component: 'ToolUse' }, async ($, e, next) => {
242    if (!(await read($, isClean))) return next(e)
243    const { Text } = $.ui.resolve(e)
244    return <Text>{''}</Text>
245  })
246  on('ui.render', { component: 'ToolResult' }, async ($, e, next) => {
247    if (!(await read($, isClean))) return next(e)
248    const { Text } = $.ui.resolve(e)
249    return <Text>{''}</Text>
250  })
251  on('ui.render', { component: 'ToolGroup' }, async ($, e, next) => {
252    if (!(await read($, isClean))) return next(e)
253    const { Text } = $.ui.resolve(e)
254    return <Text>{''}</Text>
255  })
256
257  // ---- band above the prompt: checklist box, status line, tools button ----
258  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
259    if (e.props.hasSurvey) return next(e)
260    const below = await next(e)
261    const { Box, Text, Button } = $.ui.resolve(e)
262    const [r, clean, ov, ef, m, s, a] = await Promise.all([
263      read($, run), read($, isClean), read($, model), read($, effort), read($, meter), read($, seen), read($, agents),
264    ])
265    const now = await $.clock.now()
266    const fam = ov !== 'default' ? ov : family(s.model)
267    const modelLabel = MODELS[fam]?.label ?? 'Claude'
268    const eff = ef !== 'default' ? ef : s.effort || 'medium'
269    const running = a.filter(x => x.status === 'running').length
270    const working = r.phase === 'working'
271    const activeIdx = Math.max(0, r.steps.findIndex(x => x.status === 'active'))
272    const doneN = r.steps.filter(x => x.status === 'done').length
273    const pct = r.steps.length > 0 ? Math.round((doneN / r.steps.length) * 100) : 0
274    // narrower terminals (a half-screen window, a phone over SSH) drop the
275    // least useful pieces first, so the line never wraps into a mess
276    const cols = e.props.bodyColumns
277    const tier = cols >= 112 ? 'full' : cols >= 80 ? 'mid' : 'small'
278    const shortModel = tier === 'small' ? modelLabel.split(' ')[0] : modelLabel
279    const shortEff = tier === 'small' && eff === 'medium' ? 'med' : eff
280
281    return (
282      <Box flexDirection="column">
283        {below}
284        {clean && working ? (
285          <Box flexDirection="column" borderStyle="round" borderColor="magenta" paddingX={1}>
286            <Box justifyContent="space-between">
287              <Text color="magenta" wrap="truncate-end">◆ {r.prompt.slice(0, Math.max(10, Math.min(48, cols - 14)))}{r.prompt.length > Math.min(48, cols - 14) ? '…' : ''}</Text>
288              <Text dimColor>{Math.max(1, Math.round((now - r.startedAt) / 1000))}s</Text>
289            </Box>
290            <Box justifyContent="space-between">
291              <Text dimColor>Step {Math.min(activeIdx + 1, r.steps.length)} of {r.steps.length}</Text>
292              <Text color="magenta">{pct}%</Text>
293            </Box>
294            {r.steps.map(st => (
295              <Box justifyContent="space-between">
296                <Text wrap="truncate-end" bold={st.status === 'active'} dimColor={st.status === 'next'} color={st.status === 'done' ? 'green' : undefined}>
297                  {st.status === 'done' ? '✓' : st.status === 'active' ? '▶' : ' '} {st.text}
298                </Text>
299                <Text color={st.status === 'active' ? 'magenta' : undefined} dimColor={st.status !== 'active'}>
300                  {st.status === 'active' ? 'Working' : st.status === 'done' ? 'Done' : 'Next'}
301                </Text>
302              </Box>
303            ))}
304          </Box>
305        ) : null}
306        {clean ? (
307          <Box justifyContent="flex-end">
308            <Text dimColor>── Clean View</Text>
309          </Box>
310        ) : null}
311        <Box justifyContent="space-between" flexWrap="wrap">
312          <Text wrap="truncate-end">
313            {tier === 'full' ? (
314              <Text>
315                <Text color="green">◆ </Text>
316                <Text>Subscription</Text>
317                <Text dimColor> │ </Text>
318              </Text>
319            ) : null}
320            <Text color="blue">◆ </Text>
321            <Text bold>{shortModel}</Text>
322            <Text dimColor>{tier === 'small' ? ' │ ' : ' │ effort '}</Text>
323            <Text color="yellow" bold>{shortEff}</Text>
324            <Text dimColor> │ ctx </Text>
325            {tier !== 'small' ? <Text color="green">{bar(m.ctx / 100, tier === 'full' ? 10 : 5)} </Text> : null}
326            <Text color="green" bold>{m.ctx}%</Text>
327            <Text dimColor> │ 5h </Text>
328            <Text color="green" bold>{m.five}%</Text>
329            {tier === 'full' || running > 0 ? <Text dimColor> │ ◇ {running}{tier === 'small' ? '' : ' agents'}</Text> : null}
330          </Text>
331          <Button key="tools" variant="primary" label={tier === 'small' ? '◆ ▾' : `◆ ${BRAND} ▾`} onPress={() => $.ui.open({ id: 'tools', title: BRAND, focus: true })} />
332        </Box>
333      </Box>
334    )
335  })
336
337  // ---- Tristen's Tools panel ----
338  on('ui.render', { component: 'Pane', requestId: 'tools' }, async ($, e) => {
339    const { Box, Text, Button } = $.ui.resolve(e)
340    const [clean, up, ov, ef, hp, s] = await Promise.all([
341      read($, isClean), read($, isUpgrade), read($, model), read($, effort), read($, helper), read($, seen),
342    ])
343    const isWide = e.props.bodyColumns >= 64
344    const fam = ov !== 'default' ? ov : family(s.model)
345    const eff = ef !== 'default' ? ef : s.effort || 'medium'
346    const modelName = (k: string) => (isWide ? MODELS[k]?.label : MODELS[k]?.label.split(' ')[0]) ?? k
347    const effortName = (k: string) => (isWide || k !== 'medium' ? EFFORT_LABEL[k] : 'Med') ?? k
348    const toggle = (key: string, isOn: boolean, flip: () => unknown) => (
349      <Button key={key} label={isOn ? '● On' : '○ Off'} variant={isOn ? 'primary' : 'secondary'} onPress={flip} />
350    )
351    const row = (dot: string, dotColor: string | undefined, name: string, hint: string, control: ReturnType<typeof toggle>) => (
352      <Box justifyContent="space-between">
353        <Text wrap="truncate-end">
354          <Text color={dotColor} dimColor={dotColor === undefined}>{dot} </Text>
355          {name}
356          {isWide ? <Text dimColor>  {hint}</Text> : null}
357        </Text>
358        {control}
359      </Box>
360    )
361
362    return (
363      <Box flexDirection="column" paddingX={1}>
364        <Box justifyContent="space-between" flexWrap="wrap">
365          <Text bold color={ORANGE}>◆ {isWide ? spaced(BRAND) : BRAND.toUpperCase()}</Text>
366          <Text dimColor>{MODELS[fam]?.label ?? 'Claude'} · {EFFORT_LABEL[eff] ?? eff}</Text>
367        </Box>
368        <Box flexWrap="wrap">
369          <Text dimColor>{isWide ? 'MODEL   ' : 'MODEL  '}</Text>
370          {Object.keys(MODELS).map(k =>
371            k === fam ? (
372              <Text key={`m-${k}`} backgroundColor={ORANGE} bold> {modelName(k)} </Text>
373            ) : (
374              <Button key={`m-${k}`} plain dimColor label={` ${modelName(k)} `} onPress={() => pickModel($, k)} />
375            ),
376          )}
377        </Box>
378        <Box flexWrap="wrap">
379          <Text dimColor>{isWide ? 'EFFORT  ' : 'EFFORT '}</Text>
380          {EFFORTS.map(k =>
381            k === eff ? (
382              <Text key={`e-${k}`} backgroundColor={PURPLE} bold> {effortName(k)} </Text>
383            ) : (
384              <Button key={`e-${k}`} plain dimColor label={` ${effortName(k)} `} onPress={async () => {
385                  await update($, effort, () => k)
386                  $.ui.toast(`Effort: ${EFFORT_LABEL[k]} (from the next request)`)
387                }} />
388            ),
389          )}
390        </Box>
391        <Box marginTop={1}>
392          <Text dimColor>{spaced('Settings')}</Text>
393        </Box>
394        {row('●', clean ? GREEN : undefined, 'Clean View', 'simple checklist', toggle('clean', clean, () => update($, isClean, c => !c)))}
395        {row('●', up ? GREEN : undefined, 'Prompt Upgrade', 'better prompts', toggle('upgrade', up, async () => {
396          await update($, isUpgrade, c => !c)
397          await $.store.set('isUpgrade', await read($, isUpgrade))
398        }))}
399        {row(
400          '●',
401          undefined,
402          'Helper agents',
403          'model they use',
404          <Button key="helper" label={hp === 'haiku' ? 'Fast & Cheap' : 'Same model'} onPress={() => update($, helper, v => (v === 'haiku' ? 'same' : 'haiku'))} />,
405        )}
406        <Box marginTop={1}>
407          <Text dimColor>{spaced('Launch')}</Text>
408        </Box>
409        <Box flexDirection={isWide ? 'row' : 'column'} gap={isWide ? 4 : 0}>
410          <Button key="create" plain label="✦ Create photo or video" onPress={() => $.prompt.fill({ text: 'Create a photo or video: ', mode: 'insert' })} />
411          <Button key="dock" plain label="◆ Agent Dock" onPress={() => $.ui.open({ id: 'dock', title: 'Agent Dock', focus: true })} />
412          <Button key="rt" plain label="▶ Roadtrip" onPress={() => $.ui.open({ id: 'roadtrip', title: 'Roadtrip', focus: true })} />
413        </Box>
414      </Box>
415    )
416  })
417
418  // ---- Agent Dock ----
419  on('ui.render', { component: 'Pane', requestId: 'dock' }, async ($, e) => {
420    const { Box, Text, Button } = $.ui.resolve(e)
421    const isWide = e.props.bodyColumns >= 64
422    const [t, hp, list, r] = await Promise.all([read($, team), read($, helper), read($, agents), read($, run)])
423    const now = await $.clock.now()
424    const size = Number(t)
425    const working = list.filter(x => x.status === 'running')
426    const done = list.filter(x => x.status !== 'running')
427    const queued = Math.max(0, size - list.length)
428    const live = r.phase === 'working' && size > 0 && list.length > 0
429    const colors = ['red', 'yellow', 'green', 'cyan', 'blue', 'magenta']
430    const dots = Math.min(Math.max(size, 1), 25)
431    const total = Math.max(size, list.length, 1)
432    const barCells = Math.max(8, Math.min(30, e.props.bodyColumns - 10))
433    const dotRow = Math.max(5, Math.min(25, Math.floor((e.props.bodyColumns - 2) / 2)))
434
435    return (
436      <Box flexDirection="column" paddingX={1}>
437        <Box justifyContent="space-between">
438          <Text bold color={ORANGE}>◆ {isWide ? spaced('Agent Dock') : 'AGENT DOCK'}</Text>
439          <Text color={live ? 'blue' : undefined} dimColor={!live}>{live ? '● LIVE' : isWide ? spaced('Standing by') : 'STANDING BY'}</Text>
440        </Box>
441        <Box flexWrap="wrap">
442          <Text dimColor>{isWide ? spaced('Team size') + '  ' : 'TEAM '}</Text>
443          <Button key="s0" plain dimColor label=" Off " onPress={() => update($, team, () => '0')} />
444          {SIZES.map(k =>
445            k === t ? (
446              <Text backgroundColor={ORANGE} bold> {k} </Text>
447            ) : (
448              <Button key={`s-${k}`} plain dimColor label={` ${k} `} onPress={() => update($, team, () => k)} />
449            ),
450          )}
451        </Box>
452        <Text dimColor>
453          {size > 0 ? `Splits each request across ${size} helpers${isWide ? '   10 at a time' : ''}   ${hp === 'haiku' ? 'Fast & Cheap' : 'Same model'}` : 'Pick a team size; it applies to every request until set to Off.'}
454        </Text>
455        {size > 20 ? <Text color="yellow">Heads up: a big team burns through your plan limits much faster.</Text> : null}
456        {!live ? (
457          <Box flexDirection="column" alignItems="center" borderStyle="round" borderColor="green" paddingY={1} marginTop={1}>
458            <Text wrap="wrap">
459              {Array.from({ length: dots }, (_, i) => (
460                <Text color={colors[i % colors.length]}>● </Text>
461              ))}
462            </Text>
463            <Text bold>{size > 0 ? `Your team of ${size} is standing by` : 'No team selected'}</Text>
464            <Text dimColor>{size > 0 ? `Send a request and it splits across ${size} helpers.` : 'Requests run on a single agent.'}</Text>
465          </Box>
466        ) : (
467          <Box flexDirection="column" marginTop={1}>
468            <Box justifyContent="space-between">
469              <Text dimColor wrap="truncate-end">{isWide ? spaced('Mission') : 'MISSION'}  <Text bold>{r.prompt.slice(0, 40)}</Text></Text>
470              <Text dimColor>{clock(now - r.startedAt)}</Text>
471            </Box>
472            <Text color="green">{bar(done.length / total, barCells)} {Math.round((done.length / total) * 100)}%</Text>
473            <Text>
474              <Text color="blue">● {working.length}</Text><Text dimColor> working   ○ {queued} queued   </Text><Text color="green">✓ {done.length}</Text><Text dimColor> done</Text>
475            </Text>
476            <Text>
477              {list.slice(0, dotRow).map(x => (
478                <Text color={x.status === 'running' ? 'blue' : 'green'}>● </Text>
479              ))}
480              {Array.from({ length: Math.max(0, Math.min(queued, dotRow - list.length)) }, () => (
481                <Text dimColor>· </Text>
482              ))}
483            </Text>
484            <Text dimColor>{isWide ? spaced('Working now') : 'WORKING NOW'}</Text>
485            {working.slice(0, 10).map(x => (
486              <Text wrap="truncate-end">
487                <Text color="blue">{bar(Math.min(0.95, (now - x.startedAt) / 60000), isWide ? 10 : 5)}</Text> {x.label.slice(0, 32)} <Text dimColor>{clock(now - x.startedAt)}</Text>
488              </Text>
489            ))}
490          </Box>
491        )}
492      </Box>
493    )
494  })
495
496  // ---- Roadtrip ----
497  on('ui.render', { component: 'Pane', requestId: 'roadtrip' }, async ($, e) => {
498    const { Box, Text, Button } = $.ui.resolve(e)
499    const g = await read($, game)
500    const lines: string[] = []
501    for (let y = 0; y < ROWS; y++) {
502      let row = '│'
503      for (let l = 0; l < LANES; l++) {
504        const car = y === ROWS - 1 && l === g.x
505        const rock = g.obstacles.some(o => o.y === y && o.lane === l)
506        row += car ? ' 🚗 ' : rock ? ' ▲▲ ' : '    '
507      }
508      lines.push(row + '│')
509    }
510    const steer = (d: number) => update($, game, c => (c.isRunning ? { ...c, x: Math.max(0, Math.min(LANES - 1, c.x + d)) } : c))
511    return (
512      <Box flexDirection="column" paddingX={1}>
513        <Text bold color={ORANGE}>◆ {spaced('Roadtrip')}  <Text dimColor>score {g.score} · best {g.best}</Text></Text>
514        {lines.map(l => <Text>{l}</Text>)}
515        {g.isOver ? <Text color="red">Crash! Press start to retry.</Text> : null}
516        <Box>
517          <Button key="l" label="◀ a" hotkey="a" onPress={() => steer(-1)} />
518          <Button key="r" label="d ▶" hotkey="d" onPress={() => steer(1)} />
519          <Button key="s" label={g.isRunning ? 'Restart (s)' : 'Start (s)'} hotkey="s" variant="primary" onPress={() => update($, game, c => ({ ...FRESH, best: c.best, isRunning: true }))} />
520        </Box>
521      </Box>
522    )
523  })
524}
525
types/index.d.ts 40 lines
1export type Obstacle = { lane: number; y: number }
2export type Game = {
3  isRunning: boolean
4  isOver: boolean
5  x: number
6  score: number
7  best: number
8  obstacles: Obstacle[]
9}
10export type AgentRow = { id: string; label: string; status: string; startedAt: number }
11export type Step = { text: string; status: 'done' | 'active' | 'next' }
12export type Run = {
13  phase: 'idle' | 'working'
14  prompt: string
15  startedAt: number
16  tools: number
17  lastTool: string
18  steps: Step[]
19}
20export type Meter = { ctx: number; five: number; now: number }
21export type Seen = { model: string; effort: string }
22
23declare module 'claude-code' {
24  interface PluginState {
25    'tristens-tools': {
26      isClean: boolean
27      isUpgrade: boolean
28      model: string
29      effort: string
30      helper: string
31      team: string
32      run: Run
33      game: Game
34      agents: AgentRow[]
35      meter: Meter
36      seen: Seen
37    }
38  }
39}
40