SLOPSHOPPER

where-am-i

A live recap above the prompt as one card: the goal as its title; now, waiting on you and next with their status; and suggested next prompts in the same box…

bandguardcommandpromptmodeltimer
v0.3.0MITupdated 2026-10-21Luminous13/claude-mods/mods/where-am-i
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · where-am-i
› 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 › /where ⎿ where-am-i: OK ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │ ✦ Suggested next steps click one, or type ; then a number │ │ ● OK [ 1 ] │ │ ○ Dismiss [ 0 ] │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ⟨Claude Code's own drawing⟩ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │ ✦ Suggested next steps click one, or type ; then a number │ │ ● OK [ 1 ] │ │ ○ Dismiss [ 0 ] │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ⟨Claude Code's own drawing⟩
README

claude-mods

Claude Code mods by Nereo Valeriano. Each one is a plugin in this marketplace.

ModWhat it does
auto-modelPicks the model and effort for each of your prompts, and the model for each subagent. Shows a colored bar under the input (above it in Desktop) with the model, effort, context and limits.
where-am-iA card above the prompt with where the session stands: goal, status and recent progress, plus suggested next steps with clickable number badges. Fork of Hamza Zafar's where-am-i, with his next-steps folded in.

Install

/plugin marketplace add Luminous13/claude-mods
/plugin install auto-model@claude-mods
/plugin install where-am-i@claude-mods

Don't also install Hamza's originals of where-am-i or next-steps. where-am-i has the same name and would clash, and next-steps would draw a second list of suggestions.

If you installed next-steps from here before, uninstall it: where-am-i does its job now.

where-am-i settings

  • Suggested next steps (on by default): after each turn, 2 or 3 likely next prompts inside the card, one small Haiku call per turn. Turn it off to keep the plain Next row.
  • Leader key (;, , or \): type it in an empty prompt, then 1, 2 or 3 to draft a suggestion, or 0 to dismiss them. A bare digit types as usual.

auto-model picker

Set picker in the plugin settings:

  • jev (default): needs a TypeSafe API key at api.typesafe.ai. Set it in the settings or as TYPESAFE_API_KEY.
  • openai: needs an OpenAI API key, set in the settings or as OPENAI_API_KEY.
  • claude: asks Haiku through your own Claude Code session. Needs no key, and nothing goes to a third party. Its confidence is its own estimate and a pick takes longer.

Subagent picking was ported from Hamza Zafar's switchboard. See NOTICE.md.

Licence

MIT. See LICENSE. The where-am-i fork keeps Hamza Zafar's copyright; see its NOTICE.md.

Source 2 files
hooks/register.tsx 440 lines
1// Where Am I: a live recap above the prompt (goal, now, waiting on you, next), plus /where.
2// Local fork of hamzafer/claude-code-mods where-am-i 0.1.4, with next-steps 0.1.1 folded in:
3// after each turn, 2 or 3 likely next prompts inside the same card (the `nextSteps` option
4// turns them off). In an empty prompt the leader key and then 1 to 3 drafts one (nothing sends
5// on its own), the leader and 0 dismisses; a bare digit types as usual.
6import { atom, read, update } from 'claude-code'
7import type { EngineInterface, Register } from 'claude-code'
8
9import type { NextSteps, Recap } from '../types'
10
11const MODEL = 'haiku'
12const MAX_LOG = 20
13const MAX_ITEMS = 3
14const MAX_CHARS = 60 // what the model is asked for, per suggestion
15const MAX_KEPT = 120 // a longer suggestion is dropped, never cut: a cut draft would send half a prompt
16const MIN_ANSWER = 20 // a reply shorter than this is not worth a suggestions call
17const LEADERS = [';', ',', '\\'] // what the leader may be set to; ; by default
18
19// Held by the host, so they survive a hot reload of this file.
20const recap = atom({ plugin: 'where-am-i', key: 'recap' } as const, null as Recap | null)
21const live = atom({ plugin: 'where-am-i', key: 'live' } as const, '')
22// The pulse's step, moved on a timer while a turn runs so the blocks beside Working travel.
23const frame = atom({ plugin: 'where-am-i', key: 'frame' } as const, 0)
24// The suggested next prompts for the last turn, or null.
25const steps = atom({ plugin: 'where-am-i', key: 'steps' } as const, null as NextSteps | null)
26// True while the prompt holds the leader alone: the card then shows the digits to press.
27const armed = atom({ plugin: 'where-am-i', key: 'armed' } as const, false)
28
29const PINK = '#f472b6'
30const BORDER = '#fb7185'
31const PALETTE = ['#fdba74', '#f472b6', '#c4b5fd', '#93c5fd'] // the goal's words, in turn
32const PULSE = ['#831843', '#be185d', '#ec4899', '#f9a8d4'] // the blocks beside Working
33const PULSE_MS = 150 // one step of the pulse
34const ROW_COLORS = ['#f472b6', '#a5b4fc', '#5eead4'] // suggestion 1, 2 and 3
35const ROW_TINTS = ['#f9a8d4', '#c7d2fe', '#99f6e4'] // their text, a shade lighter
36// Each row in its own color, as the auto-model bar colors its values: now pink, done green,
37// waiting yellow, next lavender. The bullet and status in the full color, the text a tint of it.
38const TONE = {
39  working: { mark: '#f472b6', text: '#f9a8d4' },
40  done: { mark: '#34d399', text: '#a7f3d0' },
41  waiting: { mark: '#fbbf24', text: '#fde68a' },
42  next: { mark: '#c4b5fd', text: '#ddd6fe' },
43} as const
44const HEADING: [string, string][] = [['Suggested ', '#fdba74'], ['next ', '#f472b6'], ['steps', '#c4b5fd']]
45const CARD_MIN_COLUMNS = 40
46
47let pulse: { cancel: () => void } | null = null
48
49// Steps the pulse while the turn runs; the tick stops itself once the turn is over.
50function startPulse($: EngineInterface) {
51  if (pulse) return
52  pulse = $.clock.every(PULSE_MS, () => void tick($).catch(() => {}))
53}
54
55async function tick($: EngineInterface) {
56  if ((await read($, live)) === '') return stopPulse()
57  await update($, frame, n => (n + 1) % PULSE.length)
58}
59
60function stopPulse() {
61  pulse?.cancel()
62  pulse = null
63}
64
65export const register: Register = (on, options) => {
66  const suggests = options.nextSteps !== false
67  const leader = LEADERS.find(l => l === options.leader) ?? ';'
68  let prompt = ''
69  let log: string[] = []
70  // The turn a suggestion may still be shown for. A submit or a new turn moves it on.
71  let latest = ''
72  let submits = 0
73  // A survey answers bare digits in the band: leave them to it.
74  let hasSurvey = false
75  // What `armed` was last written as, so a keystroke that changes nothing writes nothing.
76  const arm = { now: false }
77
78  on('session.start', async ($, e, next) => {
79    const r = await next(e)
80    await $.command.register({ name: 'where', description: 'Recap the session so far in a few bullets' }).catch(() => {}) // a name Claude Code already has is refused: start anyway
81    return r
82  })
83
84  on('prompt.submit', async ($, e, next) => {
85    prompt = e.text.slice(0, 1500)
86    log = []
87    latest = `submit-${++submits}`
88    await update($, steps, () => null)
89    await setArmed($, arm, false)
90    await update($, live, () => 'reading your message')
91    startPulse($)
92    return next(e)
93  })
94
95  on('turn.start', async ($, e, next) => {
96    latest = e.turnId
97    await update($, steps, () => null)
98    return next(e)
99  })
100
101  // Observe only: note what is happening, then let the call run untouched.
102  // Only Claude's own calls count: one another mod makes in the background (`$.tool.call`,
103  // `$.mcp.call`) is raised by that plugin, and `next.origin` names it instead of the engine.
104  on('tool.call', async ($, e, next) => {
105    if (next.origin.plugin !== 'engine') return next(e)
106    const line = describe(e as unknown as Record<string, unknown>)
107    log = [...log, e.agentId ? `(agent) ${line}` : line].slice(-MAX_LOG)
108    if (!e.agentId) await update($, live, () => line)
109    const r = await next(e)
110    return r
111  })
112
113  on('turn.complete', async ($, e, next) => {
114    const r = await next(e)
115    if (e.agentId) return r // a subagent's turn, not the person's
116    await update($, live, () => '')
117    stopPulse()
118    void summarize($, prompt, log, e.answer).catch(() => {}) // in the background, so the turn ends at once
119    latest = e.turnId // also for a turn that raised no turn.start, and after a hot reload
120    if (suggests && e.reason === 'answer' && e.answer.trim().length >= MIN_ANSWER) {
121      void suggest($, e.turnId, e.answer, () => latest).catch(() => {})
122    }
123    return r
124  })
125
126  // The leader typed alone into an empty prompt lands as text; a digit right after it picks a
127  // suggestion in its place. A paste carries no key, so a pasted ";1" lands as typed.
128  if (suggests) {
129    on('prompt.edit', async ($, e, next) => {
130      const n = leader.length
131      const isPick = !hasSurvey && !!e.key && !e.key.ctrl && !e.key.meta && e.text === leader && e.start === n && e.end === n && /^[0-9]$/.test(e.inputText)
132      const s = isPick ? await read($, steps) : null
133      if (s && e.inputText === '0') {
134        await update($, steps, () => null)
135        await setArmed($, arm, false)
136        return { text: '', cursor: 0 } // consumed: the leader goes too, the box is empty again
137      }
138      const pick = s?.items[Number(e.inputText) - 1]
139      if (pick) {
140        await setArmed($, arm, false)
141        return { text: pick, cursor: pick.length } // the leader becomes the draft: the person edits it or presses Enter
142      }
143      const r = await next(e)
144      await setArmed($, arm, r.text === leader)
145      return r
146    })
147  }
148
149  on('command.run', { command: 'where' }, async $ => ({ text: await longRecap($, prompt, log) }))
150
151  // One card above the prompt, like the auto-model bar: the goal as its title; now, waiting on
152  // you and next as rows with their status on the right; and, once a turn ends, the suggested
153  // next steps inside the same box. A band too short or narrow for it gets compact lines.
154  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
155    const rest = await next(e) // what other mods and Claude Code draw here stays
156    hasSurvey = e.props.hasSurvey
157    const r = await read($, recap)
158    const s = suggests ? await read($, steps) : null
159    if (e.props.hasSurvey || (!r && !s?.items.length)) return rest
160
161    const { Box, Button, Text } = $.ui.resolve(e)
162    const doing = await read($, live)
163    const busy = e.props.isWorking || doing !== ''
164    const now = clip(doing || r?.now || '')
165    const items = busy ? [] : (s?.items ?? [])
166    const isArmed = items.length > 0 && (await read($, armed))
167    const nextStep = items.length > 0 ? '' : (r?.next ?? '') // the suggestions stand in for next
168    const waiting = busy ? '' : (r?.waiting ?? '') // a stale ask while Claude works again
169
170    const row = (left: JSX.Element[], right: JSX.Element[]) => (
171      <Box flexDirection="row">
172        <Box flexGrow={1} flexShrink={1}>
173          <Text wrap="truncate-end">{left}</Text>
174        </Box>
175        <Box flexShrink={0} marginLeft={2}>
176          <Text>{right}</Text>
177        </Box>
178      </Box>
179    )
180    const title = r && (
181      <Text wrap="truncate-end">
182        <Text color={PINK}>{'✧ '}</Text>
183        {words(r.goal).map((w, i) => (
184          <Text color={PALETTE[i % PALETTE.length] ?? PINK} bold>
185            {w}
186          </Text>
187        ))}
188      </Text>
189    )
190    const tone = busy ? TONE.working : TONE.done
191    const step = busy ? await read($, frame) : 0 // read only while busy, so an idle card is not redrawn
192    const working = [...PULSE.map((_, i) => <Text color={PULSE[(i - step + PULSE.length) % PULSE.length]}>{'▇'}</Text>), <Text color={TONE.working.mark} bold>{'  Working'}</Text>]
193    const nowLeft = [<Text color={tone.mark}>{busy ? '● ' : '✓ '}</Text>, <Text color={tone.text} {...(busy ? { bold: true } : {})}>{now}</Text>]
194    const rows: JSX.Element[] = []
195    if (now !== '') rows.push(row(nowLeft, busy ? working : [<Text color={TONE.done.mark} bold>{'Done'}</Text>]))
196    if (waiting !== '') rows.push(row([<Text color={TONE.waiting.mark}>{'◆ '}</Text>, <Text color={TONE.waiting.text}>{clip(waiting)}</Text>], [<Text color={TONE.waiting.mark} bold>{'Waiting on you'}</Text>]))
197    if (nextStep !== '') rows.push(row([<Text color={TONE.next.mark}>{'○ '}</Text>, <Text color={TONE.next.text}>{clip(nextStep)}</Text>], [<Text color={TONE.next.mark} bold>{'Next'}</Text>]))
198
199    const hint = isArmed ? <Text color="warning" bold>{`press ${choices(items.length)} · 0 dismisses`}</Text> : <Text dimColor>{`click one, or type ${leader} then a number`}</Text>
200    // The number on a filled keycap-like square that a click presses; the leader stays out of it.
201    const badge = (n: number, color: string, onPress: () => void) => (
202      <Button key={`pick-${n}`} label={`${n}`} onPress={onPress}>
203        <Text backgroundColor={color} color="black" bold>{` ${n} `}</Text>
204      </Button>
205    )
206    const rowB = (left: JSX.Element[], right: JSX.Element) => (
207      <Box flexDirection="row">
208        <Box flexGrow={1} flexShrink={1}>
209          <Text wrap="truncate-end">{left}</Text>
210        </Box>
211        <Box flexShrink={0} marginLeft={2}>
212          {right}
213        </Box>
214      </Box>
215    )
216    // The badges, shared by the card and the compact lines: a pick drafts its suggestion, 0 hides them.
217    const pick = (i: number) => badge(i + 1, ROW_COLORS[i] ?? PINK, () => void $.prompt.fill({ text: items[i] ?? '' }).catch(() => {}))
218    const dismiss = badge(0, '#6b7280', () => void update($, steps, () => null).catch(() => {}))
219    const suggestions = items.length === 0 ? [] : [
220      row([<Text color={PINK}>{'✦ '}</Text>, ...HEADING.map(([w, c]) => <Text color={c} bold>{w}</Text>)], [hint]),
221      ...items.map((t, i) => rowB([<Text color={ROW_COLORS[i] ?? PINK}>{'● '}</Text>, <Text color={ROW_TINTS[i] ?? PINK}>{t}</Text>], pick(i))),
222      rowB([<Text dimColor>{'○ '}</Text>, <Text dimColor>{'Dismiss'}</Text>], dismiss),
223    ]
224
225    // Two borders, the title and the rows; a blank row between the recap and the suggestions if it fits.
226    const tight = 2 + (title ? 1 : 0) + rows.length + suggestions.length
227    const fits = fitsCard(tight, e.props.maxRows, e.props.bodyColumns)
228    const spaced = fits && suggestions.length > 0 && rows.length > 0 && tight + 1 <= e.props.maxRows
229    if (fits) {
230      return (
231        <Box flexDirection="column">
232          <Box flexDirection="column" borderStyle="round" borderColor={isArmed ? 'warning' : BORDER} paddingX={1} width={e.props.bodyColumns}>
233            {title}
234            {rows}
235            {spaced && <Text>{' '}</Text>}
236            {suggestions}
237          </Box>
238          {rest}
239        </Box>
240      )
241    }
242
243    // Compact: the title, one line for now / waiting / next, one row of key chips.
244    const dot = <Text dimColor>{'  ·  '}</Text>
245    const status = [
246      ...(now !== '' ? [<Text color={tone.mark}>{busy ? '● ' : '✓ '}</Text>, <Text color={tone.text}>{now}</Text>] : []),
247      ...(waiting !== '' ? [dot, <Text color={TONE.waiting.mark} bold>{'◆ waiting on you: '}</Text>, <Text color={TONE.waiting.text}>{clip(waiting)}</Text>] : []),
248      ...(nextStep !== '' ? [dot, <Text color={TONE.next.mark} bold>{'next: '}</Text>, <Text color={TONE.next.text}>{clip(nextStep)}</Text>] : []),
249    ]
250    return (
251      <Box flexDirection="column">
252        <Box flexDirection="column" paddingX={1}>
253          {title}
254          {status.length > 0 && <Text wrap="truncate-end">{[<Text>{'  '}</Text>, ...status]}</Text>}
255          {items.length > 0 && (
256            // The same badges as the card, each text giving way first where the band is narrow.
257            <Box flexDirection="row">
258              <Box flexShrink={0}>
259                <Text color={isArmed ? 'warning' : PINK} bold>{isArmed ? '✦ pick ' : '✦ next '}</Text>
260              </Box>
261              {items.flatMap((t, i) => [
262                <Box flexShrink={0}>{pick(i)}</Box>,
263                <Box flexShrink={1} marginRight={2}>
264                  <Text color={ROW_TINTS[i] ?? PINK} wrap="truncate-end">{` ${t}`}</Text>
265                </Box>,
266              ])}
267              <Box flexShrink={0}>{dismiss}</Box>
268              <Box flexShrink={1}>
269                <Text dimColor wrap="truncate-end">{' dismiss'}</Text>
270              </Box>
271            </Box>
272          )}
273        </Box>
274        {rest}
275      </Box>
276    )
277  })
278}
279
280// Whether the bordered card fits: enough rows for all of it, and wide enough.
281export function fitsCard(rows: number, maxRows: number, columns: number) {
282  return columns >= CARD_MIN_COLUMNS && rows <= maxRows
283}
284
285// Whether the prompt holds the leader alone, written only when that changes.
286async function setArmed($: EngineInterface, arm: { now: boolean }, value: boolean) {
287  if (arm.now === value) return
288  arm.now = value
289  await update($, armed, () => value)
290}
291
292// The goal's words, each to take the next color of the title's palette.
293export function words(goal: string): string[] {
294  const all = clip(goal).split(' ').filter(w => w !== '')
295  return all.map((w, i) => (i < all.length - 1 ? `${w} ` : w))
296}
297
298// "1, 2 or 3" for three suggestions.
299export function choices(n: number): string {
300  const digits = Array.from({ length: Math.max(1, n) }, (_, i) => `${i + 1}`)
301  return digits.length > 1 ? `${digits.slice(0, -1).join(', ')} or ${digits.at(-1)}` : (digits[0] ?? '1')
302}
303
304// A short label for one tool call: what a person would say Claude is doing.
305export function describe(e: Record<string, unknown>): string {
306  const tool = String(e.tool)
307  const s = (k: string) => (typeof e[k] === 'string' ? (e[k] as string) : '')
308  const file = (p: string) => p.split('/').slice(-2).join('/')
309  if (tool === 'Bash') return `running ${s('description') || s('command').slice(0, 60)}`
310  if (tool === 'Edit' || tool === 'Write') return `editing ${file(s('file_path'))}`
311  if (tool === 'Read') return `reading ${file(s('file_path'))}`
312  if (tool === 'Grep' || tool === 'Glob') return `searching for ${s('pattern').slice(0, 40)}`
313  if (tool === 'Agent') return `starting an agent: ${s('description')}`
314  if (tool === 'AskUserQuestion') return 'asking you a question'
315  if (tool.startsWith('mcp__')) return `using ${tool.split('__').slice(1).join(' ')}`
316  return `using ${tool}`
317}
318
319async function summarize($: EngineInterface, prompt: string, log: string[], answer: string) {
320  const before = await read($, recap)
321  const r = await $.model.complete({
322    model: MODEL,
323    maxTokens: 300,
324    system:
325      'You keep a one-glance recap of a coding session for someone with ADHD. Plain words, no em dashes, ' +
326      'each field at most 70 characters. Reply with JSON only: {"goal","now","waiting","next"}. ' +
327      '"goal": the overall aim of the session (keep the previous goal unless it clearly changed). ' +
328      '"now": what was just done. "waiting": what the assistant is waiting on from the person, or "". ' +
329      '"next": the next step.',
330    prompt: [
331      `Previous recap: ${before ? JSON.stringify(before) : 'none'}`,
332      `The person's latest message: ${prompt}`,
333      `Tools used this turn: ${log.join('; ') || 'none'}`,
334      `The assistant's reply: ${answer.slice(0, 2500)}`,
335    ].join('\n\n'),
336  })
337  if (!r.isAnswered) return
338  const parsed = parseRecap(r.text)
339  if (parsed) await update($, recap, () => parsed)
340}
341
342async function suggest($: EngineInterface, turnId: string, answer: string, current: () => string) {
343  // Wait for background agents: the main agent picks up again once they finish.
344  const agents = await $.agent.list().catch(() => [])
345  if (agents.some(a => a.status === 'running')) return
346
347  const all = (await $.session.messages().catch(() => [])).filter(m => m.text.trim() !== '')
348  if (all.at(-1)?.role === 'assistant') all.pop() // the latest reply goes in on its own below
349  const messages = all.slice(-6)
350  const r = await $.model.complete({
351    model: MODEL,
352    maxTokens: 200,
353    timeoutMs: 20_000,
354    system:
355      'You predict what a person will type next to their coding assistant, after reading a transcript of their session. ' +
356      `Give 2 or 3 short, concrete follow-up prompts, each an instruction in the imperative, under ${MAX_CHARS} characters, ` +
357      'specific to what just happened (name the file, test or feature). Plain words, no em dashes, no numbering, no quotes. ' +
358      'One per line and nothing else. If nothing sensible follows, reply with the single word NONE.\n' +
359      'Example reply:\nRun the login tests again\nAdd the same check to signup.ts\nOpen a draft PR',
360    prompt: [
361      `<transcript>\n${messages.map(m => `[${m.role === 'user' ? 'person' : 'assistant'}] ${m.text.slice(0, 800)}`).join('\n')}\n</transcript>`,
362      `<latest_reply>\n${answer.slice(0, 2000)}\n</latest_reply>`,
363      'Write the follow-up prompts the person is likely to send next: the lines only, not a reply to the transcript.',
364    ].join('\n\n'),
365  })
366  if (!r.isAnswered) return
367  const items = parseSteps(r.text)
368  // Checked inside the write, so a submit or a new turn that lands meanwhile always wins.
369  await update($, steps, before => (current() !== turnId ? before : items.length > 0 ? { turnId, items } : null))
370}
371
372async function longRecap($: EngineInterface, prompt: string, log: string[]) {
373  const messages = (await $.session.messages()).slice(-12)
374  const r = await $.model.complete({
375    model: MODEL,
376    maxTokens: 500,
377    system:
378      'Write a recap of this coding session for someone who lost track. Plain words, no em dashes. ' +
379      'At most 6 short bullets: the goal, what is done, what is happening now, what is waiting on them, the next step.',
380    prompt: [
381      `<transcript>\n${messages.filter(m => m.text.trim() !== '').map(m => `[${m.role === 'user' ? 'person' : 'assistant'}] ${m.text.slice(0, 800)}`).join('\n')}\n</transcript>`,
382      `Latest message: ${prompt}`,
383      `Recent tool calls: ${log.join('; ') || 'none'}`,
384      'Write the recap of the transcript above now: the bullets only, not a reply to it.',
385    ].join('\n\n'),
386  })
387  return r.isAnswered ? r.text : 'Could not build a recap right now.'
388}
389
390// At most 70 characters, cut at a word: the model does not always keep to the limit.
391export function clip(text: string, max = 70) {
392  const first = text.split(/(?<=[.!?])\s/)[0] ?? text // one sentence
393  if (first.length <= max) return first.replace(/\.$/, '')
394  return `${first.slice(0, first.lastIndexOf(' ', max - 1))}…`
395}
396
397// The model's JSON, tolerating a code fence around it.
398export function parseRecap(text: string): Recap | null {
399  const body = text.slice(text.indexOf('{'), text.lastIndexOf('}') + 1)
400  try {
401    const o = JSON.parse(body) as Record<string, unknown>
402    const field = (k: string) => (typeof o[k] === 'string' ? clip((o[k] as string).replace(/\s*—\s*/g, ', ').trim()) : '')
403    if (!field('goal')) return null
404    return { goal: field('goal'), now: field('now'), waiting: field('waiting'), next: field('next') }
405  } catch {
406    return null
407  }
408}
409
410// The model's suggestion lines, cleaned: no fences, bullets, numbers or em dashes; at most three.
411// A preamble, a "nothing to add" or a line too long to draft whole is dropped.
412export function parseSteps(text: string): string[] {
413  const body = text.replace(/```[a-z]*\n?/gi, '').trim()
414  let lines = body.split('\n')
415  if (body.startsWith('[') || body.startsWith('{')) {
416    try {
417      const o = JSON.parse(body) as unknown
418      const arr = Array.isArray(o) ? o : Object.values(o as Record<string, unknown>).find(Array.isArray)
419      lines = Array.isArray(arr) ? arr.filter((x): x is string => typeof x === 'string') : []
420    } catch {
421      // not JSON after all: read it as lines
422    }
423  }
424  const out: string[] = []
425  for (const line of lines) {
426    const clean = line
427      .replace(/\*\*/g, '')
428      .replace(/^\s*(?:[-*•]|\d+[.):])\s*/, '')
429      .replace(/^["'`]+|["'`,]+$/g, '')
430      .replace(/\s*—\s*/g, ', ')
431      .replace(/\.$/, '')
432      .trim()
433    if (clean === '' || clean.endsWith(':') || clean.length > MAX_KEPT) continue
434    if (/^(none|no |nothing|here are|here's|sure)/i.test(clean) || /^[[\]{}]$/.test(clean)) continue
435    if (!out.some(o => o.toLowerCase() === clean.toLowerCase())) out.push(clean)
436    if (out.length === MAX_ITEMS) break
437  }
438  return out
439}
440
types/index.d.ts 10 lines
1export type Recap = { goal: string; now: string; waiting: string; next: string }
2export type NextSteps = { turnId: string; items: string[] }
3
4declare module 'claude-code' {
5  interface PluginState {
6    // steps: the suggested next prompts for a turn; armed: the prompt holds the leader alone.
7    'where-am-i': { recap: Recap | null; live: string; frame: number; steps: NextSteps | null; armed: boolean }
8  }
9}
10