SLOPSHOPPER

ladakh-ride

A Ladakh road trip above the prompt: a Royal Enfield rides from Leh to Khardung La as the context window fills.

bandcommandtoasttimer
v0.8.0no licenseupdated 2026-10-24shailendergoud2907/ladakh-ride
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · ladakh-ride
› 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 › /ride ⎿ ladakh-ride: Ride hidden. Type /ride to bring it back. ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts
README

ladakh-ride

A Ladakh road trip above the Claude prompt. A Royal Enfield rides from Leh to Khardung La as your conversation's context window fills up.

  • Snow peaks, a Pangong Tso lake, prayer flags, a stupa at Leh and 25/50/75% milestones.
  • Caption shows percent of context used, tokens used out of the window, a flavour-only altitude, and your 5-hour limit when your account reports one.
  • Toasts at 75% and 90% full.
  • /ride hides or shows it. Terminals that cannot draw images get a text track instead.

Install

Type this at the prompt of a terminal Claude Code session:

/plugin install ladakh-ride --marketplace shailendergoud2907/ladakh-ride

Answer y to add the marketplace, then pick the user scope.

Develop

claude plugin validate .
claude plugin test .

More mods in this repo

ModWhat it doesInstall
ride-statusStatus line shows context used as altitude/plugin install ride-status --marketplace shailendergoud2907/ladakh-ride
safe-rideBlocks rm -rf on home or root, plain force-push, git reset --hard/plugin install safe-ride --marketplace shailendergoud2907/ladakh-ride
tool-logSide panel of tool calls, /tool-log/plugin install tool-log --marketplace shailendergoud2907/ladakh-ride
done-chimeChime and toast after a turn of 30 s or more (sound plays on macOS)/plugin install done-chime --marketplace shailendergoud2907/ladakh-ride
limit-alertToast at 80% and 95% of the 5-hour limit/plugin install limit-alert --marketplace shailendergoud2907/ladakh-ride
mba-voiceAdds a short working-style note to the system prompt/plugin install mba-voice --marketplace shailendergoud2907/ladakh-ride
ladakh-tips/ladakh prints a riding tip/plugin install ladakh-tips --marketplace shailendergoud2907/ladakh-ride
ladakh-themeLadakh Dusk and Ladakh Glacier colour themes, pick with /theme/plugin install ladakh-theme --marketplace shailendergoud2907/ladakh-ride
mba-shortcuts/mba-shortcuts:case, :pitch, :redteam, :memo/plugin install mba-shortcuts --marketplace shailendergoud2907/ladakh-ride

/ridetimer 25 (focus timer) and the rider pet live inside ladakh-ride and show in the band. The timer is not called /focus because that name is built in.

Source 2 files
hooks/register.tsx 384 lines
1import { atom, read, update } from 'claude-code'
2import type { Register } from 'claude-code'
3
4import type { Ride } from '../types'
5
6const ride = atom({ plugin: 'ladakh-ride', key: 'ride' } as const, null)
7const isHidden = atom({ plugin: 'ladakh-ride', key: 'isHidden' } as const, false)
8const isHappy = atom({ plugin: 'ladakh-ride', key: 'isHappy' } as const, false)
9const focusLeft = atom({ plugin: 'ladakh-ride', key: 'focusLeft' } as const, null)
10
11const LEH_M = 3500
12const KHARDUNG_LA_M = 5359
13
14const fmtK = (n: number) => (n >= 1000 ? `${Math.round(n / 100) / 10}k` : `${n}`)
15const fmtInt = (n: number) => String(Math.round(n)).replace(/\B(?=(\d{3})+(?!\d))/g, ',')
16
17const toRide = (
18  context: { tokens?: number; window: number; percent?: number },
19  rateLimits: { kind: string; percentUsed: number }[],
20): Ride => {
21  const tokens = context.tokens ?? 0
22  const percent = clamp(
23    context.percent ?? (context.window > 0 ? (tokens / context.window) * 100 : 0),
24  )
25  const five = rateLimits.find(r => r.kind === 'five_hour')
26
27  return {
28    percent: Math.round(percent),
29    tokens,
30    window: context.window,
31    fiveHour: five ? five.percentUsed : null,
32  }
33}
34
35const INK = '#151a26'
36const W = 720
37const START_X = 44
38const END_X = 676
39const clamp = (n: number) => Math.max(0, Math.min(100, n))
40
41type Mood = 'idle' | 'working' | 'happy'
42
43const GREEN = '#2f6b45'
44const GREEN_HI = '#5aa174'
45const CHROME = '#d5dae2'
46const SKIN = '#f1c9a0'
47
48// A chibi rider on a classic green roadster, facing right, tyres on y=0. About 150 wide, 135 tall.
49const rider = (mood: Mood, isRolling: boolean) => {
50  const wheel = (cx: number) => {
51    const cy = -24
52    let spokes = ''
53    for (let a = 0; a < 180; a += 20) {
54      const t = (a * Math.PI) / 180
55      spokes += `<line x1="${(cx - Math.cos(t) * 17).toFixed(1)}" y1="${(cy - Math.sin(t) * 17).toFixed(1)}" x2="${(cx + Math.cos(t) * 17).toFixed(1)}" y2="${(cy + Math.sin(t) * 17).toFixed(1)}" stroke="#8a93a2" stroke-width="1.2"/>`
56    }
57    const spin = isRolling
58      ? `<animateTransform attributeName="transform" type="rotate" from="0 ${cx} ${cy}" to="360 ${cx} ${cy}" dur="0.45s" repeatCount="indefinite"/>`
59      : ''
60
61    return (
62      `<circle cx="${cx}" cy="${cy}" r="24" fill="#23262e" stroke="${INK}" stroke-width="3"/>` +
63      `<circle cx="${cx}" cy="${cy}" r="18" fill="#f3f4f7" stroke="${CHROME}" stroke-width="2.4"/>` +
64      `<g>${spin}${spokes}<circle cx="${cx + 14}" cy="${cy}" r="1.8" fill="${INK}"/></g>` +
65      `<circle cx="${cx}" cy="${cy}" r="5" fill="${CHROME}" stroke="${INK}" stroke-width="1.6"/>`
66    )
67  }
68
69  const eyes =
70    mood === 'happy'
71      ? `<path d="M30 -100 q3.6 -5 7.2 0 M42 -100 q3.6 -5 7.2 0" fill="none" stroke="${INK}" stroke-width="2.4" stroke-linecap="round"/>`
72      : mood === 'working'
73        ? `<ellipse cx="34" cy="-99" rx="3" ry="2.4" fill="${INK}"/><ellipse cx="46" cy="-99" rx="3" ry="2.4" fill="${INK}"/>` +
74          `<path d="M29 -105 l9 2 M51 -105 l-9 2" stroke="${INK}" stroke-width="2.2" stroke-linecap="round"/>`
75        : `<ellipse cx="34" cy="-99" rx="3.2" ry="4" fill="${INK}"><animate attributeName="ry" values="4;4;0.5;4;4" keyTimes="0;0.9;0.94;0.98;1" dur="4s" repeatCount="indefinite"/></ellipse>` +
76          `<ellipse cx="46" cy="-99" rx="3.2" ry="4" fill="${INK}"><animate attributeName="ry" values="4;4;0.5;4;4" keyTimes="0;0.9;0.94;0.98;1" dur="4s" repeatCount="indefinite"/></ellipse>` +
77          `<circle cx="35" cy="-100.6" r="1.2" fill="#fff"/><circle cx="47" cy="-100.6" r="1.2" fill="#fff"/>`
78
79  const mouth =
80    mood === 'happy'
81      ? `<path d="M33 -90 q7 8 14 0 Z" fill="#a8384a" stroke="${INK}" stroke-width="1.4" stroke-linejoin="round"/>`
82      : `<path d="M35 -90 q5 3.4 10 0" fill="none" stroke="${INK}" stroke-width="1.8" stroke-linecap="round"/>`
83
84  const body =
85    // exhaust, behind the wheels' front
86    `<path d="M62 -20 Q70 -14 54 -12 L-6 -14" fill="none" stroke="${INK}" stroke-width="7" stroke-linecap="round"/>` +
87    `<rect x="-16" y="-24" width="52" height="11" rx="5.5" fill="${CHROME}" stroke="${INK}" stroke-width="2.4"/>` +
88    `<path d="M-10 -21 H30" stroke="#fff" stroke-width="2" stroke-linecap="round"/>` +
89    // rear fender, tail light
90    `<path d="M-24 -36 Q0 -62 20 -44" fill="none" stroke="${INK}" stroke-width="8" stroke-linecap="round"/>` +
91    `<path d="M-24 -36 Q0 -62 20 -44" fill="none" stroke="${GREEN}" stroke-width="5" stroke-linecap="round"/>` +
92    `<circle cx="-24" cy="-37" r="3.2" fill="#d9372e" stroke="${INK}" stroke-width="1.2"/>` +
93    // engine
94    `<rect x="36" y="-46" width="36" height="26" rx="6" fill="#4b5262" stroke="${INK}" stroke-width="2.4"/>` +
95    `<path d="M41 -40 H67 M41 -34 H67 M41 -28 H67" stroke="#8b94a3" stroke-width="2"/>` +
96    `<circle cx="54" cy="-30" r="9" fill="${CHROME}" stroke="${INK}" stroke-width="2.2"/><circle cx="54" cy="-30" r="3.4" fill="#8a93a2"/>` +
97    // seat
98    `<path d="M-6 -52 Q16 -60 40 -52 L40 -44 L-6 -44 Z" fill="#7a4a2a" stroke="${INK}" stroke-width="2.4" stroke-linejoin="round"/>` +
99    // tank
100    `<path d="M32 -62 Q60 -80 92 -64 Q96 -50 82 -46 L40 -46 Q28 -52 32 -62 Z" fill="${GREEN}" stroke="${INK}" stroke-width="2.6" stroke-linejoin="round"/>` +
101    `<path d="M40 -64 Q60 -74 84 -64" fill="none" stroke="${GREEN_HI}" stroke-width="3" stroke-linecap="round"/>` +
102    `<path d="M44 -56 Q62 -62 82 -55" fill="none" stroke="#f1e6c8" stroke-width="2" stroke-linecap="round"/>` +
103    // fork and front fender
104    `<line x1="96" y1="-66" x2="100" y2="-24" stroke="${INK}" stroke-width="8" stroke-linecap="round"/>` +
105    `<line x1="96" y1="-66" x2="100" y2="-24" stroke="${CHROME}" stroke-width="4.4" stroke-linecap="round"/>` +
106    `<path d="M80 -40 Q100 -56 122 -38" fill="none" stroke="${INK}" stroke-width="8" stroke-linecap="round"/>` +
107    `<path d="M80 -40 Q100 -56 122 -38" fill="none" stroke="${GREEN}" stroke-width="5" stroke-linecap="round"/>` +
108    // headlamp
109    `<circle cx="110" cy="-62" r="10" fill="${CHROME}" stroke="${INK}" stroke-width="2.4"/>` +
110    `<circle cx="112.5" cy="-62" r="7" fill="#fff3a8" stroke="${INK}" stroke-width="1.4"/>` +
111    `<circle cx="102" cy="-52" r="3" fill="#ffb347" stroke="${INK}" stroke-width="1.2"/>` +
112    wheel(0) +
113    wheel(100)
114
115  const person =
116    // leg
117    `<path d="M8 -52 L44 -44 L48 -24" fill="none" stroke="${INK}" stroke-width="14" stroke-linecap="round" stroke-linejoin="round"/>` +
118    `<path d="M8 -52 L44 -44 L48 -24" fill="none" stroke="#3f5f8f" stroke-width="10.4" stroke-linecap="round" stroke-linejoin="round"/>` +
119    `<path d="M40 -26 h20 q4 0 4 6 v6 h-24 Z" fill="#7a4a2a" stroke="${INK}" stroke-width="2.2" stroke-linejoin="round"/>` +
120    // torso (jacket)
121    `<path d="M8 -54 L26 -84" fill="none" stroke="${INK}" stroke-width="24" stroke-linecap="round"/>` +
122    `<path d="M8 -54 L26 -84" fill="none" stroke="#5a3a26" stroke-width="20" stroke-linecap="round"/>` +
123    `<path d="M14 -62 L22 -76" fill="none" stroke="#7d5538" stroke-width="3" stroke-linecap="round"/>` +
124    // arm to the bars
125    `<path d="M30 -80 L52 -76 L84 -72" fill="none" stroke="${INK}" stroke-width="12" stroke-linecap="round" stroke-linejoin="round"/>` +
126    `<path d="M30 -80 L52 -76 L84 -72" fill="none" stroke="#5a3a26" stroke-width="8.4" stroke-linecap="round" stroke-linejoin="round"/>` +
127    `<circle cx="86" cy="-72" r="5.4" fill="#1b1d24" stroke="${INK}" stroke-width="1.6"/>` +
128    // handlebar and mirror
129    `<line x1="80" y1="-70" x2="96" y2="-70" stroke="${INK}" stroke-width="4" stroke-linecap="round"/>` +
130    `<line x1="88" y1="-72" x2="82" y2="-92" stroke="${INK}" stroke-width="2" stroke-linecap="round"/>` +
131    `<circle cx="81" cy="-96" r="5.6" fill="#aebdd0" stroke="${INK}" stroke-width="1.8"/>` +
132    // helmet: glossy black, open visor showing the face
133    `<circle cx="40" cy="-103" r="23" fill="#1b1d24" stroke="${INK}" stroke-width="2.6"/>` +
134    `<path d="M56 -120 Q66 -106 58 -90" fill="none" stroke="#fff" stroke-width="2.6" stroke-linecap="round" opacity="0.5"/>` +
135    `<ellipse cx="42" cy="-99" rx="17" ry="14" fill="${SKIN}" stroke="${INK}" stroke-width="2"/>` +
136    `<path d="M22 -108 Q40 -128 58 -108" fill="#1b1d24" stroke="${INK}" stroke-width="2"/>` +
137    `<path d="M40 -122 Q56 -118 61 -104" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" opacity="0.4"/>` +
138    eyes +
139    `<circle cx="29" cy="-93" r="2.6" fill="#f0a7a7" opacity="0.7"/><circle cx="51" cy="-93" r="2.6" fill="#f0a7a7" opacity="0.7"/>` +
140    mouth
141
142  return body + person
143}
144
145const sparkle = (x: number, y: number, delay: number) =>
146  `<path d="M${x} ${y - 5} L${x + 1.5} ${y - 1.5} L${x + 5} ${y} L${x + 1.5} ${y + 1.5} L${x} ${y + 5} L${x - 1.5} ${y + 1.5} L${x - 5} ${y} L${x - 1.5} ${y - 1.5} Z" fill="#f2c230" stroke="${INK}" stroke-width="0.8">` +
147  `<animate attributeName="opacity" values="0;1;0" dur="0.8s" begin="${delay}s" repeatCount="indefinite"/></path>`
148
149const speedLines = () =>
150  [0, 1, 2]
151    .map(
152      i =>
153        `<line x1="-30" y1="${-28 - i * 22}" x2="${-60 - i * 6}" y2="${-28 - i * 22}" stroke="#e8e0cc" stroke-width="2.4" stroke-linecap="round" opacity="0">` +
154        `<animate attributeName="opacity" values="0;0.8;0" dur="0.5s" begin="${i * 0.16}s" repeatCount="indefinite"/>` +
155        `<animateTransform attributeName="transform" type="translate" values="0 0;-18 0" dur="0.5s" begin="${i * 0.16}s" repeatCount="indefinite"/></line>`,
156    )
157    .join('')
158
159const bob = (amp: number, dur: number) =>
160  `<animateTransform attributeName="transform" type="translate" values="0 0;0 ${-amp};0 0;0 ${-amp / 2};0 0" dur="${dur}s" repeatCount="indefinite"/>`
161
162const lowSky = (p: number) =>
163  `<defs><linearGradient id="sky" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#3a3350"/><stop offset="0.7" stop-color="#9a6a78"/><stop offset="1" stop-color="#f1b27f"/></linearGradient></defs>` +
164  `<rect width="${W}" height="400" fill="url(#sky)"/>` +
165  `<circle cx="610" cy="${(36 + p * 0.3).toFixed(1)}" r="14" fill="#ffe0a0" opacity="0.9"/>`
166
167const ridge = (base: number, scale: number) => {
168  const peaks: [number, number, number][] = [
169    [70, 30, 70], [190, 12, 80], [320, 28, 76], [450, 8, 86], [585, 24, 78], [690, 16, 66],
170  ]
171  let out = ''
172  for (const [x, y, hw] of peaks) {
173    const yy = base - (base - y) * scale
174    out += `<polygon points="${x},${yy} ${x - hw},${base} ${x + hw * 0.1},${base}" fill="#e3a679"/>`
175    out += `<polygon points="${x},${yy} ${x + hw * 0.1},${base} ${x + hw},${base}" fill="#a96f86"/>`
176    out += `<polygon points="${x},${yy} ${x - 9},${yy + 12} ${x - 2},${yy + 10} ${x + 3},${yy + 15} ${x + 9},${yy + 11}" fill="#fff4de"/>`
177  }
178
179  return out
180}
181
182const road = (y: number, w: number, dash: number, isMoving: boolean) =>
183  `<rect x="-10" y="${y - w / 2 - 3}" width="${W + 20}" height="${w + 6}" fill="#4a3a2c"/>` +
184  `<rect x="-10" y="${y - w / 2}" width="${W + 20}" height="${w}" fill="#3a3a40"/>` +
185  `<line x1="-40" y1="${y}" x2="${W + 40}" y2="${y}" stroke="#f2d36b" stroke-width="${dash}" stroke-dasharray="16 14">` +
186  (isMoving ? `<animate attributeName="stroke-dashoffset" from="0" to="30" dur="0.5s" repeatCount="indefinite"/>` : '') +
187  `</line>`
188
189const label = (x: number, y: number, size: number, anchor: string, text: string) =>
190  `<text x="${x}" y="${y}" font-size="${size}" font-weight="700" text-anchor="${anchor}" fill="#f3e4c8" font-family="system-ui, sans-serif">${text}</text>`
191
192// The band above the prompt box. The rider's place on the road is context used; mood follows what Claude is doing.
193const scene = (percent: number, mood: Mood) => {
194  const p = clamp(percent)
195  const bx = 80 + (p / 100) * (END_X - 80 - 120)
196  const isRolling = mood === 'working'
197
198  return (
199    `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="118" viewBox="0 0 ${W} 118">` +
200    lowSky(p) +
201    ridge(66, 0.55) +
202    `<rect y="66" width="${W}" height="52" fill="#6b5240"/>` +
203    road(98, 26, 2, isRolling) +
204    label(START_X, 114, 8, 'middle', 'LEH') +
205    label(END_X, 114, 8, 'end', 'KHARDUNG LA') +
206    `<g transform="translate(${bx.toFixed(1)} 102) scale(0.58)">` +
207    `<ellipse cx="50" cy="1" rx="76" ry="5" fill="#000" opacity="0.3"/>` +
208    `<g>${mood === 'happy' ? `<animateTransform attributeName="transform" type="translate" values="0 0;0 -10;0 0" dur="0.5s" repeatCount="indefinite"/>` : isRolling ? bob(2, 0.4) : ''}` +
209    rider(mood, isRolling) +
210    (mood === 'happy' ? sparkle(-20, -120, 0) + sparkle(120, -110, 0.25) + sparkle(60, -150, 0.5) : '') +
211    (isRolling ? speedLines() : '') +
212    `</g></g>` +
213    `</svg>`
214  )
215}
216
217// Fresh chat: the rider rolls across the whole width on a loop.
218const starter = () =>
219  `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="190" viewBox="0 0 ${W} 190">` +
220  lowSky(0) +
221  ridge(112, 0.9) +
222  `<rect y="112" width="${W}" height="78" fill="#6b5240"/>` +
223  road(158, 40, 3, true) +
224  label(14, 184, 10, 'start', 'LEH 3,500 m') +
225  label(706, 184, 10, 'end', 'KHARDUNG LA 5,359 m') +
226  `<g><animateTransform attributeName="transform" type="translate" from="-200 0" to="760 0" dur="9s" repeatCount="indefinite"/>` +
227  `<g transform="translate(0 164) scale(0.85)">` +
228  `<ellipse cx="50" cy="1" rx="76" ry="5" fill="#000" opacity="0.3"/>` +
229  `<g>${bob(2.4, 0.4)}` + rider('working', true) + speedLines() + `</g></g></g>` +
230  `</svg>`
231
232
233export const register: Register = on => {
234  let lastBand = 0
235
236  on('session.start', async ($, e, next) => {
237    await $.command.register({
238      name: 'ride',
239      description: 'Show or hide the Ladakh ride above the prompt',
240    })
241    await $.command.register({
242      name: 'ridetimer',
243      description: '/ridetimer 25 starts a focus timer shown in the ride band, /ridetimer stop cancels it',
244    })
245
246    try {
247      const usage = await $.session.usage()
248      await update($, ride, () => toRide(usage.context, usage.rateLimits))
249    } catch {
250      // No reading yet: the bike waits at Leh until the first response.
251    }
252
253    return next(e)
254  })
255
256  let tick: { cancel: () => void } | null = null
257  let done: { cancel: () => void } | null = null
258  const stopFocus = () => {
259    tick?.cancel()
260    done?.cancel()
261    tick = null
262    done = null
263  }
264
265  on('command.run', { command: 'ridetimer' }, async ($, e) => {
266    const arg = e.args.trim().toLowerCase()
267    if (arg === 'stop') {
268      stopFocus()
269      await update($, focusLeft, () => null)
270
271      return { text: 'Focus timer stopped.' }
272    }
273
274    const minutes = arg === '' ? 25 : Number(arg)
275    if (!Number.isFinite(minutes) || minutes < 1 || minutes > 240) {
276      return { text: 'Use /ridetimer 25 (minutes, 1 to 240) or /ridetimer stop.' }
277    }
278
279    stopFocus()
280    const endsAt = (await $.clock.now()) + minutes * 60_000
281    const show = async () => {
282      const left = Math.max(0, Math.ceil((endsAt - (await $.clock.now())) / 60_000))
283      await update($, focusLeft, () => left)
284    }
285    await show()
286    tick = $.clock.every(30_000, () => void show())
287    done = $.clock.after(minutes * 60_000, () => {
288      stopFocus()
289      void update($, focusLeft, () => null)
290      void $.ui.toast(`Focus block done (${minutes} min). Take a break.`, { timeoutMs: 15_000 })
291    })
292
293    return { text: `Focus timer set for ${minutes} min. It shows in the ride band.` }
294  })
295
296  on('command.run', { command: 'ride' }, async $ => {
297    const wasHidden = await read($, isHidden)
298    await update($, isHidden, () => !wasHidden)
299
300    return {
301      text: wasHidden ? 'The ride is back above your prompt.' : 'Ride hidden. Type /ride to bring it back.',
302    }
303  })
304
305  on('session.measure', async ($, e, next) => {
306    const reading = toRide(e.context, e.rateLimits)
307    await update($, ride, () => reading)
308
309    const band = reading.percent >= 90 ? 2 : reading.percent >= 75 ? 1 : 0
310    if (band > lastBand) {
311      $.ui.toast(
312        band === 2
313          ? `Khardung La is in sight: context ${reading.percent}% full. A fresh chat or /compact clears the road.`
314          : `Past Pangong: context ${reading.percent}% full.`,
315      )
316    }
317    lastBand = band
318
319    return next(e)
320  })
321
322  let happyTimer: { cancel: () => void } | null = null
323  on('turn.complete', async ($, e, next) => {
324    const out = await next(e)
325    if (e.agentId === undefined && !e.isAborted) {
326      happyTimer?.cancel()
327      await update($, isHappy, () => true)
328      happyTimer = $.clock.after(6_000, () => void update($, isHappy, () => false))
329    }
330
331    return out
332  })
333
334  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
335    if (e.props.hasSurvey || (await read($, isHidden))) {
336      return next(e)
337    }
338
339    const state = await read($, ride)
340    const focus = await read($, focusLeft)
341    const happy = await read($, isHappy)
342    const mood: Mood = e.props.isWorking ? 'working' : happy ? 'happy' : 'idle'
343    const isFresh = state === null || state.tokens === 0
344    const percent = state?.percent ?? 0
345    const altitude = LEH_M + (percent / 100) * (KHARDUNG_LA_M - LEH_M)
346    const ui = $.ui.resolve(e)
347    const { Box, Text, Button } = ui
348
349    const caption = isFresh
350      ? 'Parked at Leh. Send a message and the ride begins.'
351      : `Leh to Khardung La: ${percent}% of context used (${fmtK(state.tokens)} of ${fmtK(state.window)} tokens), about ${fmtInt(altitude)} m up` +
352        (state.fiveHour === null ? '' : `. 5-hour limit ${Math.round(state.fiveHour)}%`)
353    const line = focus === null ? caption : `${caption}. Focus: ${focus} min left`
354
355    const picture =
356      'Svg' in ui ? (
357        <ui.Svg
358          key="scene"
359          source={isFresh ? starter() : scene(percent, mood)}
360          alt={
361            isFresh
362              ? 'A motorcycle parked on a mountain road at Leh, ready to ride to Khardung La'
363              : `A motorcycle riding from Leh to Khardung La, ${percent} percent of the way`
364          }
365          isInteractive
366        />
367      ) : (
368        <Text key="track">
369          {`Leh ${'-'.repeat(Math.round((percent / 100) * 36))}[RE]${'-'.repeat(36 - Math.round((percent / 100) * 36))} Khardung La`}
370        </Text>
371      )
372
373    return (
374      <Box flexDirection="column">
375        {picture}
376        <Box>
377          <Text dimColor>{line} </Text>
378          <Button key="hide" label="Hide" onPress={() => update($, isHidden, () => true)} />
379        </Box>
380      </Box>
381    )
382  })
383}
384
types/index.d.ts 13 lines
1export type Ride = {
2  percent: number
3  tokens: number
4  window: number
5  fiveHour: number | null
6}
7
8declare module 'claude-code' {
9  interface PluginState {
10    'ladakh-ride': { ride: Ride | null; isHidden: boolean; focusLeft: number | null; isHappy: boolean }
11  }
12}
13