SLOPSHOPPER

needs-you

Band above the prompt showing what the session needs from you and where the branch stands

bandguardpromptmodelprocesstimer
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · needs-you
› 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 feat/auth-refresh · 2 uncommitted [ /implement ] [ /review-brief ] [ /review-changes ] [ /open-pr ] ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Band
feat/auth-refresh · 2 uncommitted [ /implement ] [ /review-brief ] [ /review-changes ] [ /open-pr ]
README

Dotfiles

Collection of my personal dotfiles.

Installation

To install the majority of the dotfiles, use the Terminal GUI by starting "./dotfiles.py". There the specific dotfiles can be selected for installation. This will however will not install software and system wide configurations. When launching for the first time, it will download the required dependencies automatically. The dependencies used are listed in ./requirements.txt.

Windows

These dotfiles should also work on Windows, but requires some manual steps.

  • After installing a Font, restart the Service "Windows Font Cache Service" to make the font available. Or just restart the system.
  • At leas install following software with winget:
winget install Python Git.Git zig.zig ajeetdsouza.zoxide junegunn.fzf OpenJS.NodeJS Starship.Starship
  • For a better experience, also install the following software with winget:
winget install Neovide.Neovide SomePythonThings.WingetUIStore 7zip.7zip GitHub.cli

Uninstallation

To uninstall the dotfiles, use the Terminal GUI by starting "./dotfiles.py" and just remove the dotfiles that were installed. This will revert the changes made by the dotfiles and leave the system in the same state as before the installation. Since it does not install software, it will not remove any software as well. ./config.json contains the configuration of theses dotfiles, it is required to correctly uninstall the dotfiles.

gw (Git Worktree Tool)

gw is a local helper script in this repo for git worktree workflows.

Main commands

  • gw new -b <branch>: create a new worktree and new branch (from HEAD by default)
  • gw new -b <branch> --from <ref>: create from another base ref
  • gw move: move the currently checked out branch into a new worktree
  • gw ls / gw ls --json: list worktrees
  • gw cd: pick and switch to a worktree
  • gw rm: remove a worktree
  • gw prune: prune stale worktree metadata
  • gw doctor: validate worktree setup and health

Automation flags

Common non-interactive flags:

  • --yes: auto-confirm destructive/interactive actions
  • --no-prompt: fail instead of prompting
  • --path / --index: explicit target selection for gw rm / gw cd

Shell integration contract

For shell wrappers, gw emits:

GW_CD_TARGET=<path>

Wrappers should only parse this machine-readable line for auto-cd.

gw tests

Run:

./scripts/test-gw.sh

Software

Software I use regularly. The software on this list is available on linux, but some is also compatible with windows.

GUI

  • adw-gtk-theme: GTK3 theme with libadwaita look
  • appimagelauncher: Integrate AppImages into the system
  • mpv: media player
  • moserial: serial monitor
  • neovide: neovim gui with animations
  • kitty: terminal emulator
  • timeshift: btrfs snapshot manager
  • Gnome Tweaks: more gnome settings
  • Rnote: note taking app
  • Flatseal: manage flatpak permissions
  • Extension Manager: manage gnome extensions
  • Black Box: terminal emulator
  • Bottles: wine manager
  • Inkscape: vector graphics editor
  • Prusaslicer: 3d printer slicer
  • Firefox: web browser
  • Brave: web browser (chromium based)
  • Kicad: schematic and pcb design
  • Easyeffects: audio effects
  • Vlc: media player
  • Libreoffice: office suite
  • Pikabackup: backup manager
  • Qalculate (GTK): calculator
  • File Roller: archive manager (GNOME)
  • Ark: archive manager (KDE), more powerful than file roller
  • REW: room acoustics measurement
  • Joplin: text based note taking app
  • Audacity: Basic audio editor
  • Blender: 3d modeling and animation

CLI

  • topgrade: upgrade all software
  • bat: cat clone with syntax highlighting
  • ripgrep: grep clone with better visuals and usability
  • htop: interactive process viewer
  • btop: htop clone with better visuals
  • aria2: download manager
  • exa: ls clone with better visuals
  • fd: find clone with better visuals and usability
  • fzf: fuzzy finder
  • neofetch: system info
  • ncdu: disk usage analyzer
  • nvtop: (nvidia) gpu monitor
  • powertop: power consumption monitor
  • stress: basic stress test
  • tldr: better man pages
  • tmux: terminal multiplexer
  • tokei: code statistics

Development

  • ninja: build system
  • cmake: build system generator
  • nodejs/npm: javascript runtime and package manager
  • docker: containerization
  • docker-compose: container orchestration
  • rustup: up to date rust toolchain
  • openocd: embedded debugging
  • clang: c/c++ compiler
  • stlink: stlink debugger
  • stcubeide: stm microcontroller ide
  • etcher: flash images to sd cards
  • flutter: mobile app development
  • esp-idf: esp32 development
  • avrdude: avr programmer

Windows

  • winget: windows package manager
  • scoop: windows package manager (does not require admin rights, more developer tools, remember to add buckets)
  • WingetUI: GUI for windows package managers
  • 7zip: archive manager
  • teracopy: replace windows copy
  • notepad++: text editor
  • MusicBee: music player with good replaygain calculation
  • mp3tag: tag editor
  • windirstat: disk usage analyzer

VSCode Plugins

  • C/C++: C/C++ language support from Microsoft
  • PlatformIO IDE: IDE for embedded development
  • Material Theme: Material Theme for VSCode
  • Copilot: AI code completion
  • Matieral Icon Theme: Material Design Icons for Visual Studio Code
  • rust extension pack: rust language support
  • git graph: Display a git graph of your repository
  • todo tree: Show TODO, FIXME, etc. comment tags of a project

Device Specific

See device_specific for device specific configurations and notes for my personal devices.

Notes (Linux)

To set environment variables for a user on X11, write them to ~/.profile with the following format:

export VAR=value

This will not work for wayland with gnome. write them to ~/.config/environment.d/envvars.conf with the following format:

VAR=value

When using flatpak apps, just add the environment variables via Flatseal.

Environment variables

For Firefox (and I think Thunderbird), set the following environment variables for wayland support:

MOZ_USE_XINPUT2=1
MOZ_ENABLE_WAYLAND=1

For neovide, set the following environment variables:

NEOVIDE_MULTIGRID=true

For development of GObject Introspection based libraries, set the following environment variables (maybe use ~/.local/lib...?):

GI_TYPELIB_PATH=/usr/local/lib/girepository-1.0

For flutter development, set the following environment variables to not use Chrome (flatpak webbrowsers are as far as I know not supported):

CHROME_EXECUTABLE=brave

Maybe also set if using pyopengl (works on my intel integrated gpu):

PYOPENGL_PLATFORM=osmesa

Awesome WM

I no longer use Awesome WM, but on very old systems it still works better than gnome. The configuration is not exactly finished (especially the app picker), but it works. It requres following software (some is optional): nm-applet, Jonaburg's picom, light-locker (with lightdm), unclutter, copyq, mate-volume-control-status-icon, blueman-applet, touchegg, polkit-gnome-authentication-agent-1, acpi Maybe some more, but I don't remember.

Source 2 files
hooks/register.tsx 482 lines
1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { AskOption, GitFacts, Item, ItemKind, Reply } from '../types'
5
6const items = atom({ plugin: 'needs-you', key: 'items' } as const, [])
7const reply = atom({ plugin: 'needs-you', key: 'reply' } as const, null)
8const git = atom({ plugin: 'needs-you', key: 'git' } as const, null)
9const now = atom({ plugin: 'needs-you', key: 'now' } as const, 0)
10const tldr = atom({ plugin: 'needs-you', key: 'tldr' } as const, null)
11const shown = atom({ plugin: 'needs-you', key: 'shown' } as const, null)
12const laterOpen = atom({ plugin: 'needs-you', key: 'laterOpen' } as const, false)
13const lastCall = atom({ plugin: 'needs-you', key: 'lastCall' } as const, 0)
14const keepWarm = atom({ plugin: 'needs-you', key: 'keepWarm' } as const, false)
15
16const KINDS: readonly ItemKind[] = ['answer', 'do', 'later']
17const USER_ORIGINS = ['composer', 'bridge', 'sdk']
18const SPAWN_TASK = 'mcp__ccd_session__spawn_task'
19const SHOWN = 3
20const COMMANDS = ['/implement', '/review-brief', '/review-changes', '/open-pr']
21const NO_REPLY: Reply = { question: null, done: null, options: [] }
22const MIN_ANSWER = 20
23const CACHE_TTL_MS = 60 * 60000
24const WARM_MARGIN_MS = 5 * 60000
25const MAX_PINGS = 4
26
27const CLASSIFY = `You keep the list of things the user of an AI coding assistant still has to act on. You get the open list, the user's latest prompts and the assistant's latest reply.
28Answer with JSON only, no prose, in this shape:
29{"resolved": number[], "new": [{"kind": "answer" | "do" | "later", "text": string, "same": number}], "done": string, "question": string, "options": [{"label": string, "fill": string, "send": boolean}], "tldr": string}
30
31resolved: the ids of open items the latest prompts or the reply dealt with: the user answered or decided it, did the task, or the assistant fixed it, opened an issue for it or dropped it. Also resolve an answer or do item that a newer item replaced. A later item stays open while the work moves on. Suggesting an item as a background task does not deal with it. Leave an item the reply asks again out of resolved.
32
33new: everything the reply asks of the user or sets aside, one entry each, new ones first, at most 5. same: the id of the open item the entry repeats, even when worded differently, or -1 when it is new.
34- "answer": a question or decision for the user. Not a request for permission to go ahead (make or apply changes, commit, push, open a PR, post), and not a request to review a draft or changes: those only get question and options below.
35- "do": something the user must do themselves (test a UI, run a command, restart a device, log in).
36- "later": a problem or follow-up the reply leaves out of the current work ("found a bug, but it does not belong in this PR"). Not the assistant's own next steps in the current work.
37text: under 80 characters and clear without reading the reply, so name what it is about. For "later", a noun phrase naming the problem and where it is ("Race in queue reload in the player provider"). Otherwise start with a verb ("Answer: fix needs-you duplicates now or log first?").
38
39done: when the reply asks nothing, what was done, under 60 characters. Otherwise "".
40
41question: the reply's main question in under 50 characters, shown in front of the option buttons ("Push and open the PR form?"), or "" when options is empty.
42
43options: buttons that answer the reply's main question, at most 4. label is one to three words. fill is the answer the user would type, under 100 characters, naming what it answers so it reads clearly on its own ("Yes, add setup-notes to the mod list in settings.json").
44- A go-ahead to open a PR: "Web form", "Draft", "Ready" and "No" entries, fill "Yes, open the PR with the web form", "Yes, open the PR as a draft", "Yes, open the PR ready for review" and "No, don't open the PR yet".
45- A go-ahead to ship PR fixes or drafted review replies: "Ship" and "No" entries, fill "Push, post the drafted replies, resolve those threads, and re-request a Copilot review" and "No, hold off".
46- A PR web form the reply opened for the user to submit: question "Opened the PR?" and one "Opened" entry, fill "I opened the PR. Bind it and turn on the monitor with Auto-fix".
47- Any other yes/no question: a "Yes" and a "No" entry.
48send: true only for the "Web form", "Draft" and "Ready" entries of a go-ahead to open a PR, the "Ship" entry of a go-ahead to ship and the "Opened" entry, false otherwise.
49- A choice between named alternatives: one entry per alternative, labeled with it ("Fix now", "Measure first").
50- Numbered options to pick from: one entry per number, labeled with the number, even when the options also have names.
51- Several numbered questions: one entry per number, labeled with the number, fill "<number> - " for the user to finish.
52Otherwise [].
53
54tldr: what the whole session is working on, under 70 characters, as a noun phrase ("Building a band mod that shows what the session needs"). Start from the previous TLDR and change it only when the latest prompts moved the work somewhere new.
55`
56
57// Keep more of the tail, where replies put their questions.
58function clip(text: string, max: number) {
59  if (text.length <= max) return text
60  const head = Math.floor(max / 4)
61
62  return `${text.slice(0, head)}\n[...]\n${text.slice(text.length - (max - head))}`
63}
64
65function parseJson(text: string) {
66  const start = text.indexOf('{')
67  const end = text.lastIndexOf('}')
68  if (start < 0 || end <= start) return null
69  try {
70    return JSON.parse(text.slice(start, end + 1))
71  } catch {
72    return null
73  }
74}
75
76function parseNew(raw: unknown, openIds: number[]): Pick<Item, 'kind' | 'text'>[] {
77  if (!Array.isArray(raw)) return []
78
79  return raw
80    .filter(n => KINDS.includes(n?.kind) && typeof n?.text === 'string' && n.text.trim() !== '')
81    .filter(n => !openIds.includes(n.same))
82    .slice(0, 5)
83    .map(n => ({ kind: n.kind, text: n.text.trim().slice(0, 100) }))
84}
85
86function parseReply(raw: any): Reply {
87  const options: AskOption[] = Array.isArray(raw.options)
88    ? raw.options
89        .filter((o: unknown): o is AskOption =>
90          typeof (o as AskOption)?.label === 'string' &&
91          typeof (o as AskOption)?.fill === 'string',
92        )
93        .slice(0, 4)
94        .map((o: AskOption) => ({ label: o.label, fill: o.fill, send: o.send === true }))
95    : []
96  const done = typeof raw.done === 'string' && raw.done.trim() !== '' ? raw.done.trim().slice(0, 80) : null
97  const question =
98    typeof raw.question === 'string' && raw.question.trim() !== '' ? raw.question.trim().slice(0, 60) : null
99
100  return { question, done, options }
101}
102
103async function changeItems(
104  $: EngineInterface,
105  resolved: number[],
106  added: Pick<Item, 'kind' | 'text' | 'fromTask'>[],
107) {
108  const at = await $.clock.now()
109  await update($, items, (list: Item[]) => {
110    let id = list.reduce((max, i) => Math.max(max, i.id), 0)
111    const kept = list.filter(i => !resolved.includes(i.id))
112
113    return [...kept, ...added.map(a => ({ ...a, id: ++id, at }))]
114  })
115}
116
117async function runGit($: EngineInterface, cwd: string, args: string[]) {
118  const ran = await $.process.run(['git', ...args], { cwd, timeoutMs: 5000 })
119
120  return ran.exitCode === 0 ? ran.stdout.trim() : null
121}
122
123async function refreshGit($: EngineInterface) {
124  const cwd = await $.session.cwd()
125  const branch = await runGit($, cwd, ['rev-parse', '--abbrev-ref', 'HEAD'])
126  if (branch === null) {
127    await update($, git, () => null)
128    return
129  }
130  const upstream = await runGit($, cwd, ['rev-list', '--count', '@{u}..HEAD'])
131  const ahead = await runGit($, cwd, ['rev-list', '--count', 'origin/HEAD..HEAD'])
132  const status = (await runGit($, cwd, ['status', '--porcelain'])) ?? ''
133  const facts: GitFacts = {
134    branch,
135    unpushed: Number(upstream ?? ahead ?? 0),
136    ahead: ahead === null ? null : Number(ahead),
137    hasUpstream: upstream !== null,
138    uncommitted: status === '' ? 0 : status.split('\n').length,
139  }
140  await update($, git, () => facts)
141}
142
143async function classify(
144  $: EngineInterface,
145  prompt: string,
146  answer: string,
147  isCurrent: () => boolean,
148) {
149  const current = await read($, items)
150  const open = current.map(i => `[${i.id}] ${i.kind}: ${i.text}`).join('\n')
151  const previous = (await read($, tldr)) ?? '(none yet)'
152  const completed = await $.model.complete({
153    model: 'sonnet',
154    effort: 'low',
155    maxTokens: 700,
156    timeoutMs: 20000,
157    prompt: `${CLASSIFY}\nOpen items:\n${open || '(none)'}\n\nPrevious TLDR:\n${previous}\n\nLatest prompts:\n${clip(prompt, 2000)}\n\nReply:\n${clip(answer, 4000)}`,
158  })
159  const raw = completed.isAnswered ? parseJson(completed.text) : null
160  if (raw === null) {
161    if (isCurrent()) await update($, reply, () => NO_REPLY)
162    return
163  }
164  const resolved = Array.isArray(raw.resolved) ? raw.resolved.filter(Number.isInteger) : []
165  await changeItems($, resolved, parseNew(raw.new, current.map(i => i.id).filter(id => !resolved.includes(id))))
166  if (typeof raw.tldr === 'string' && raw.tldr.trim() !== '') {
167    await update($, tldr, () => raw.tldr.trim().slice(0, 90))
168  }
169  if (isCurrent()) await update($, reply, () => parseReply(raw))
170}
171
172function keyOf(item: Item) {
173  return `${item.id}:${item.at}`
174}
175
176async function expand($: EngineInterface, item: Item) {
177  const change = (patch: Partial<Item>) =>
178    update($, items, (list: Item[]) => list.map(i => (keyOf(i) === keyOf(item) ? { ...i, ...patch } : i)))
179  await change({ expanding: true })
180  const forked = await $.model.fork({
181    prompt: `The user's status band shows this open item from this session (${item.kind}): "${item.text}". Expand it in at most three short sentences of plain text, using what you know from this session: what it is about, what the user needs to know to act on it, and your recommendation if you have one. Don't repeat the item, and don't use lists or headings.`,
182  })
183  await change({
184    expanding: false,
185    detail: forked.isAnswered ? forked.text.trim() : `No detail: ${forked.reason}`,
186    failed: !forked.isAnswered,
187  })
188  if (forked.isAnswered) await update($, lastCall, () => Date.now())
189  await update($, shown, () => keyOf(item))
190}
191
192let pings = 0
193let pinging = false
194
195// Fork the session shortly before the cache expires, since a cache read restarts its lifetime.
196async function tick($: EngineInterface) {
197  const at = Date.now()
198  await update($, now, () => at)
199  const last = await read($, lastCall)
200  if (pinging || !(await read($, keepWarm)) || last === 0) return
201  if (at - last < CACHE_TTL_MS - WARM_MARGIN_MS) return
202  if (pings >= MAX_PINGS) {
203    await update($, keepWarm, () => false)
204    return
205  }
206  pings += 1
207  pinging = true
208  const forked = await $.model.fork({ prompt: 'Reply with only the word ok.' })
209  pinging = false
210  if (forked.isAnswered) await update($, lastCall, () => at)
211}
212
213function minutesSince(at: number, current: number) {
214  const minutes = Math.floor((current - at) / 60000)
215  if (minutes < 1) return ''
216  if (minutes < 60) return ` · ${minutes} min`
217
218  return ` · ${Math.floor(minutes / 60)} h ${minutes % 60} min`
219}
220
221export const register: Register = on => {
222  let prompts: string[] = []
223  let generation = 0
224  let queue: Promise<void> = Promise.resolve()
225
226  on('session.start', async ($, e, next) => {
227    const started = await next(e)
228    await update($, now, () => Date.now())
229    $.clock.every(60000, () => void tick($))
230    await refreshGit($)
231
232    return started
233  })
234
235  on('turn.step', async function* ($, e, next) {
236    if (e.agentId === undefined && !pinging) {
237      pings = 0
238      await update($, lastCall, () => Date.now())
239    }
240
241    return yield* next(e)
242  })
243
244  on('prompt.submit', async ($, e, next) => {
245    if (USER_ORIGINS.includes(e.origin.kind) || (e.origin.kind === 'plugin' && e.origin.name === 'needs-you')) {
246      generation += 1
247      prompts.push(e.text)
248      await update($, reply, () => null)
249    }
250
251    return next(e)
252  })
253
254  on('tool.call', { tool: 'Bash' }, async ($, e, next) => {
255    const ran = await next(e)
256    if (typeof e.command === 'string' && /\b(git|gh)\b/.test(e.command)) await refreshGit($)
257
258    return ran
259  })
260
261  on('tool.call', { tool: SPAWN_TASK }, async ($, e, next) => {
262    const ran = await next(e)
263    if (typeof e.title === 'string' && ran.deny === undefined && ran.isError !== true) {
264      await changeItems($, [], [{ kind: 'later', text: e.title.slice(0, 80), fromTask: true }])
265    }
266
267    return ran
268  })
269
270  on('turn.complete', async ($, e, next) => {
271    const done = await next(e)
272    if (e.agentId === undefined && !e.isAborted && e.answer.trim().length >= MIN_ANSWER) {
273      generation += 1
274      const mine = generation
275      const answer = e.answer
276      const prompt = prompts.join('\n\n') || '(none)'
277      prompts = []
278      const run = () => classify($, prompt, answer, () => generation === mine)
279      // Run classifications in order so each one sees the items the previous one added.
280      $.clock.after(0, () => {
281        queue = queue.then(run, run)
282      })
283    } else if (e.agentId === undefined) {
284      await update($, reply, () => NO_REPLY)
285    }
286    void refreshGit($)
287
288    return done
289  })
290
291  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
292    if (e.props.hasSurvey) return next(e)
293
294    const open = await read($, items)
295    const latest = e.props.isWorking ? null : await read($, reply)
296    const asks = latest === null ? [] : open.filter(i => i.kind === 'answer' || i.kind === 'do')
297    const later = open.filter(i => i.kind === 'later')
298    const facts = await read($, git)
299    const current = await read($, now)
300    const topic = await read($, tldr)
301    const shownId = await read($, shown)
302    const isLaterOpen = await read($, laterOpen)
303    const last = await read($, lastCall)
304    const isKeepingWarm = await read($, keepWarm)
305    if (open.length === 0 && latest === null && facts === null && topic === null) return next(e)
306
307    const { Box, Button, Text } = $.ui.resolve(e)
308
309    const fill = async (text: string) => {
310      const box = await $.prompt.read()
311      const isEmpty = box.text.trim() === ''
312      await $.prompt.fill(
313        isEmpty ? { text, mode: 'replace' } : { text: `\n${text}`, mode: 'append' },
314      )
315    }
316
317    const send = (text: string) => $.prompt.submit({ text, asUser: true })
318
319    const start = async (command: string) => {
320      const typed = (await $.prompt.read()).text.trim()
321      const previous = COMMANDS.find(c => typed === c || typed.startsWith(`${c} `))
322      const args = previous === undefined ? typed : typed.slice(previous.length).trim()
323      await $.prompt.fill({ text: '', mode: 'replace' })
324      await $.command.run({ command: command.slice(1), args })
325    }
326
327    const dismiss = (item: Item) => (
328      <Button
329        key={`dismiss-${item.id}`}
330        label="x"
331        plain
332        dimColor
333        onPress={() => void update($, items, (list: Item[]) => list.filter(i => i.id !== item.id))}
334      />
335    )
336
337    const action = (item: Item, label: string, press: () => Promise<unknown>) => (
338      <Button key={`${label}-${item.id}`} label={label} plain dimColor onPress={() => void press()} />
339    )
340
341    const more = (item: Item) => (
342      <Button
343        key={`more-${item.id}`}
344        label={item.expanding ? 'expanding' : shownId === keyOf(item) ? 'less' : 'more'}
345        plain
346        dimColor
347        onPress={() => {
348          if (item.expanding) return
349          if (shownId === keyOf(item)) void update($, shown, () => null)
350          else if (item.detail !== undefined && !item.failed) void update($, shown, () => keyOf(item))
351          else void expand($, item)
352        }}
353      />
354    )
355
356    const detail = (item: Item) =>
357      shownId === keyOf(item) &&
358      item.detail !== undefined && (
359        <Box paddingLeft={2}>
360          <Text dimColor>{item.detail}</Text>
361        </Box>
362      )
363
364    const replyButtons = (latest?.options ?? []).map((o, i) => (
365      <Button
366        key={`opt-${i}`}
367        label={o.label}
368        hotkey={/^[1-9]$/.test(o.label) ? o.label : undefined}
369        onPress={() => void (o.send ? send(o.fill) : fill(o.fill))}
370      />
371    ))
372
373    const statusParts: string[] = []
374    if (facts !== null) {
375      statusParts.push(facts.branch)
376      if (facts.unpushed > 0) {
377        statusParts.push(`${facts.unpushed} unpushed${facts.hasUpstream ? '' : ' (no upstream)'}`)
378      }
379      if (facts.uncommitted > 0) statusParts.push(`${facts.uncommitted} uncommitted`)
380    }
381    if (last > 0) {
382      const left = CACHE_TTL_MS - (Math.max(current, last) - last)
383      statusParts.push(left > 0 ? `cache ~${Math.ceil(left / 60000)} min` : 'cache cold')
384    }
385
386    const hasChanges = facts !== null && (facts.ahead !== 0 || facts.uncommitted > 0)
387    const commands = COMMANDS.filter(c => hasChanges || !['/review-brief', '/open-pr'].includes(c))
388    const showLater = later.length === 1 || isLaterOpen
389
390    return (
391      <Box flexDirection="column">
392        {topic !== null && (
393          <Text dimColor wrap="truncate-end">
394            TLDR: {topic}
395          </Text>
396        )}
397        {asks.slice(-SHOWN).map(item => (
398          <Box key={`ask-${item.id}`} flexDirection="column">
399            <Box flexDirection="row" gap={1}>
400              <Text color="yellow" wrap="truncate-end">
401                ● Needs you: {item.text}
402                {minutesSince(item.at, current)}
403              </Text>
404              {item.kind === 'do' && action(item, 'done', () => fill(`Done: ${item.text}`))}
405              {more(item)}
406              {dismiss(item)}
407            </Box>
408            {detail(item)}
409          </Box>
410        ))}
411        {asks.length > SHOWN && <Text dimColor>+{asks.length - SHOWN} older asks</Text>}
412        {latest?.done != null && (
413          <Text dimColor wrap="truncate-end">
414            Done: {latest.done}
415          </Text>
416        )}
417        {replyButtons.length > 0 && (
418          <Box flexDirection="row" gap={1}>
419            {latest?.question != null && <Text color="yellow">{latest.question}</Text>}
420            {replyButtons}
421          </Box>
422        )}
423        {later.length > 1 && (
424          <Box flexDirection="row" gap={1}>
425            <Text color="magenta">◆ {later.length} later</Text>
426            <Button
427              key="later-toggle"
428              label={isLaterOpen ? 'hide' : 'show'}
429              plain
430              dimColor
431              onPress={() => void update($, laterOpen, (o: boolean) => !o)}
432            />
433          </Box>
434        )}
435        {showLater && later.slice(-SHOWN).map(item => (
436          <Box key={`later-${item.id}`} flexDirection="column">
437            <Box flexDirection="row" gap={1}>
438              <Text color="magenta" wrap="truncate-end">
439                ◆ Later: {item.text}
440              </Text>
441              {action(item, 'now', () => fill(`Work on this now: ${item.text}`))}
442              {!item.fromTask && action(item, 'task', () => send(`Suggest a background task for: ${item.text}`))}
443              {more(item)}
444              {dismiss(item)}
445            </Box>
446            {detail(item)}
447          </Box>
448        ))}
449        {showLater && later.length > SHOWN && <Text dimColor>+{later.length - SHOWN} older later</Text>}
450        {statusParts.length > 0 && (
451          <Box flexDirection="row" gap={1}>
452            <Text dimColor wrap="truncate-end">
453              {statusParts.join(' · ')}
454            </Text>
455            {last > 0 && (
456              <Button
457                key="keep-warm"
458                label={isKeepingWarm ? 'keep warm: on' : 'keep warm: off'}
459                plain
460                dimColor
461                onPress={() => void update($, keepWarm, (isOn: boolean) => !isOn)}
462              />
463            )}
464          </Box>
465        )}
466        {!e.props.isWorking && (
467          <Box flexDirection="row" gap={1}>
468            {commands.map(command => (
469              <Button
470                key={`cmd-${command}`}
471                label={command}
472                dimColor
473                onPress={() => void start(command)}
474              />
475            ))}
476          </Box>
477        )}
478      </Box>
479    )
480  })
481}
482
types/index.d.ts 45 lines
1export type ItemKind = 'answer' | 'do' | 'later'
2
3export type Item = {
4  id: number
5  kind: ItemKind
6  text: string
7  at: number
8  detail?: string
9  expanding?: boolean
10  failed?: boolean
11  fromTask?: boolean
12}
13
14export type AskOption = { label: string; fill: string; send?: boolean }
15
16export type Reply = {
17  question: string | null
18  done: string | null
19  options: AskOption[]
20}
21
22export type GitFacts = {
23  branch: string
24  unpushed: number
25  ahead: number | null
26  hasUpstream: boolean
27  uncommitted: number
28}
29
30declare module 'claude-code' {
31  interface PluginState {
32    'needs-you': {
33      items: Item[]
34      reply: Reply | null
35      git: GitFacts | null
36      now: number
37      tldr: string | null
38      shown: string | null
39      laterOpen: boolean
40      lastCall: number
41      keepWarm: boolean
42    }
43  }
44}
45