SLOPSHOPPER

corgi-band

A band above the prompt: corgi sessions waiting on you elsewhere (with Focus), this branch when it conflicts, fails its checks or has changes requested (with…

panebandguardcommandtoaststatus
★ 37v0.2.0MITupdated 2026-10-23Andriiklymiuk/corgi/plugins/corgi-band
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · corgi-band
│ ┃ corgi ✕ › fix the failing auth test and add an audit log call │ ┃ Sessions Refresh │ ┃ none running ⏺ Read(src/auth.ts) │ ┃ ⎿ Read 6 lines │ ┃ Tickets ⏺ Update(src/auth.ts) │ ┃ nothing waiting ⎿ 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 │ │ › /corgi │ ⎿ corgi-band: corgi board opened. │ │ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Pane · corgi
Sessions Refresh none running Tickets nothing waiting
README

corgi-band

A Claude Code mod for people who run corgi.

  • Band above the prompt. Sessions elsewhere that stopped on a question or a permission, each with a Focus button (corgi agent focus). This branch, when it needs something: it conflicts with its base, its checks fail, changes are requested, the tests failed - each with Fix it, which asks this session to do it - or it is ready to merge, merged, or the context is past 70%. Anything this turn said to other people that failed (a Slack post, a ticket move, a PR verb, a push), with the error: a revoked Slack token shows here, not in a report you have to read. What went through says nothing. Hide puts it away until something changes.
  • Toast the moment one of those fails.
  • Status line corgi · 2 waiting on you · 5h 91% - only when something waits or the 5-hour window is past 80%.
  • /corgi opens a pane: every live session (waiting first, with Focus), the tickets that want a person (Blocked, Review, Inbox, with Work on it → corgi agent watch work), the stack of this folder (corgi status), and the budget while its window is current.

It reads corgi --json agent sessions, corgi --json agent kanban and corgi --json status every 20 seconds; without corgi on PATH it stays silent.

Install

/plugin install corgi-band --marketplace Andriiklymiuk/corgi

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

Source 3 files
hooks/register.tsx 221 lines
1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { Action, Here, Snapshot, Waiting } from '../types'
5import {
6  actionsIn, budgetOf, cardsOf, failureOf, fiveHourOf, glyph, hereLine, hereOf, readBoard, sessionsOf, settle, signature, stackOf, statusText, waitingOf,
7} from './board'
8
9const waiting = atom({ plugin: 'corgi-band', key: 'waiting' } as const, [] as Waiting[])
10const here = atom({ plugin: 'corgi-band', key: 'here' } as const, null as Here | null)
11const actions = atom({ plugin: 'corgi-band', key: 'actions' } as const, [] as Action[])
12const hidden = atom({ plugin: 'corgi-band', key: 'hidden' } as const, '')
13const snapshot = atom({ plugin: 'corgi-band', key: 'snapshot' } as const, null as Snapshot | null)
14
15const PANE = 'corgi-board'
16
17const POLL_MS = 20_000
18
19const me = { id: '', configDir: '', wantsPane: false }
20
21async function runJSON($: EngineInterface, argv: string[]): Promise<string | undefined> {
22  try {
23    const out = await $.process.run(argv, { timeoutMs: 15_000 })
24    return out.exitCode === 0 ? out.stdout : undefined
25  } catch {
26    return undefined
27  }
28}
29
30async function refreshPane($: EngineInterface): Promise<void> {
31  const [boardOut, kanbanOut, stackOut] = await Promise.all([
32    runJSON($, ['corgi', '--json', 'agent', 'sessions']),
33    runJSON($, ['corgi', '--json', 'agent', 'kanban']),
34    runJSON($, ['corgi', '--json', 'status']),
35  ])
36  const board = boardOut === undefined ? undefined : readBoard(boardOut)
37  const now = await $.clock.now()
38  const next: Snapshot = {
39    sessions: board ? sessionsOf(board) : [],
40    cards: kanbanOut ? cardsOf(kanbanOut).slice(0, 8) : [],
41    stack: stackOut ? stackOf(stackOut) : [],
42    budget: board ? budgetOf(board, me.configDir, now) : undefined,
43    at: now,
44  }
45  await update($, snapshot, () => next)
46}
47
48async function refresh($: EngineInterface): Promise<boolean> {
49  let out
50  try {
51    out = await $.process.run(['corgi', '--json', 'agent', 'sessions'], { timeoutMs: 10_000 })
52  } catch {
53    return false
54  }
55  const board = out.exitCode === 0 ? readBoard(out.stdout) : undefined
56  if (board === undefined) return true
57  const now = await $.clock.now()
58  const list = waitingOf(board, me.id)
59  await update($, waiting, () => list)
60  const mine = hereOf(board, me.id) ?? null
61  await update($, here, () => mine)
62  $.ui.status(statusText(list.length, fiveHourOf(board, me.configDir, now)))
63  if (me.wantsPane) await refreshPane($)
64  return true
65}
66
67export const register: Register = on => {
68  on('session.start', async ($, e, next) => {
69    me.id = await $.session.id()
70    me.configDir = (await $.env.get('CLAUDE_CONFIG_DIR')) ?? ''
71    if (!e.isInteractive) return next(e)
72    await $.command.register({ name: 'corgi', description: 'corgi board: sessions waiting on you, tickets, the stack, the budget' })
73    void refresh($).then(found => {
74      if (found) $.clock.every(POLL_MS, () => void refresh($))
75    })
76    return next(e)
77  })
78
79  on('command.run', { command: 'corgi' }, async $ => {
80    me.wantsPane = true
81    await $.ui.open({ id: PANE, title: 'corgi' })
82    await refreshPane($)
83    return { text: 'corgi board opened.' }
84  })
85
86  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
87    const { Box, Button, Text } = $.ui.resolve(e)
88    const snap = await read($, snapshot)
89    if (snap === null) return <Text dimColor>Reading corgi…</Text>
90    const down = snap.stack.filter(s => !s.isHealthy)
91
92    return (
93      <Box flexDirection="column">
94        <Box>
95          <Text bold>Sessions </Text>
96          <Button key="refresh" label="Refresh" plain dimColor onPress={() => refreshPane($)} />
97        </Box>
98        {snap.sessions.length === 0 && <Text dimColor>  none running</Text>}
99        {snap.sessions.map(s => (
100          <Box key={`s-${s.id}`}>
101            <Text color={s.status === 'needs_input' ? 'yellow' : s.status === 'working' ? 'green' : undefined}>{glyph(s.status)} </Text>
102            <Text wrap="truncate-end" dimColor={s.id === me.id}>
103              {s.name}
104              {s.what ? ` · ${s.what}` : ''}
105              {s.context !== undefined ? ` · ${s.context}%` : ''}
106              {s.id === me.id ? ' (here)' : ''}{' '}
107            </Text>
108            {s.id !== me.id && (
109              <Button key={`focus-${s.id}`} label="Focus" onPress={() => void runJSON($, ['corgi', 'agent', 'focus', s.id])} />
110            )}
111          </Box>
112        ))}
113        <Text> </Text>
114        <Text bold>Tickets</Text>
115        {snap.cards.length === 0 && <Text dimColor>  nothing waiting</Text>}
116        {snap.cards.map(c => (
117          <Box key={`c-${c.ref}`}>
118            <Text dimColor>{c.column.padEnd(8)}</Text>
119            <Text wrap="truncate-end">
120              {c.ref} {c.title}{' '}
121            </Text>
122            {c.column !== 'Running' && (
123              <Button key={`work-${c.ref}`} label="Work on it" onPress={() => void runJSON($, ['corgi', 'agent', 'watch', 'work', c.ref])} />
124            )}
125          </Box>
126        ))}
127        {snap.stack.length > 0 && (
128          <Box flexDirection="column">
129            <Text> </Text>
130            <Text bold>Stack</Text>
131            <Text wrap="wrap">
132              {snap.stack.map(s => `${s.isHealthy ? '✓' : '✗'} ${s.label}${s.port ? ` :${s.port}` : ''}`).join('   ')}
133            </Text>
134            {down.length > 0 && <Text color="red">{down.length} down - ask me to debug it, or run corgi run</Text>}
135          </Box>
136        )}
137        {snap.budget !== undefined && (
138          <Box flexDirection="column">
139            <Text> </Text>
140            <Text dimColor>budget {snap.budget}</Text>
141          </Box>
142        )}
143      </Box>
144    )
145  })
146
147  on('prompt.submit', async ($, e, next) => {
148    await update($, actions, () => [])
149    return next(e)
150  }).catch(($, e, next) => next(e))
151
152  on('tool.call', { tool: 'Bash' }, async ($, e, next) => {
153    const labels = actionsIn(e.command)
154    if (labels.length === 0) return next(e)
155    const ran = await next(e)
156    const why = ran.deny ?? failureOf(ran.isError === true, ran.text ?? '')
157    if (why !== undefined) await update($, actions, list => [...list, ...settle(labels, why)].slice(-6))
158    if (why !== undefined) {
159      $.ui.toast(`corgi: ${labels.join(', ')} failed - ${why}`, { timeoutMs: 8000 })
160    }
161    return ran
162  }).catch(($, e, next) => next(e))
163
164  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
165    const list = await read($, waiting)
166    const failed = e.props.isWorking ? [] : await read($, actions)
167    const mine = e.props.isWorking ? null : await read($, here)
168    const isHidden = (await read($, hidden)) === signature(list, failed, mine ?? undefined)
169    if (e.props.hasSurvey || isHidden || (list.length === 0 && failed.length === 0 && mine === null)) {
170      return next(e)
171    }
172    const { Box, Button, Text } = $.ui.resolve(e)
173    const shown = list.slice(0, 3)
174
175    return (
176      <Box flexDirection="column">
177        {shown.map(w => (
178          <Box key={`w-${w.id}`}>
179            <Text color="yellow">◐ </Text>
180            <Text wrap="truncate-end">
181              {w.name} waits on you: {w.what}{' '}
182            </Text>
183            <Button
184              key={`focus-${w.id}`}
185              label="Focus"
186              onPress={() => void $.process.run(['corgi', 'agent', 'focus', w.id]).catch(() => undefined)}
187            />
188          </Box>
189        ))}
190        {list.length > shown.length && <Text dimColor>+{list.length - shown.length} more waiting</Text>}
191        {mine !== null && (
192          <Box>
193            <Text color={mine.fix ? 'red' : undefined} dimColor={!mine.fix}>{mine.fix ? '✗ ' : '· '}</Text>
194            <Text wrap="truncate-end">this branch: {hereLine(mine)} </Text>
195            {mine.fix && (
196              <Button key="fix" label="Fix it" onPress={() => void $.prompt.submit({ text: mine.fix! })} />
197            )}
198          </Box>
199        )}
200        {failed.map((a, i) => (
201          <Box key={`f-${i}`}>
202            <Text color="red">✗ </Text>
203            <Text wrap="truncate-end">
204              {a.label} failed: {a.why}{' '}
205            </Text>
206          </Box>
207        ))}
208        <Box>
209          <Button
210            key="hide"
211            label="Hide"
212            plain
213            dimColor
214            onPress={() => update($, hidden, () => signature(list, failed, mine ?? undefined))}
215          />
216        </Box>
217      </Box>
218    )
219  })
220}
221
hooks/board.ts 200 lines
1import type { Action, Here, PaneCard, PaneService, PaneSession, Waiting } from '../types'
2
3type BoardSession = {
4  id: string
5  status?: string
6  title?: string
7  display?: string
8  label?: string
9  detail?: string
10  configDir?: string
11  pending?: { tool?: string; subject?: string } | null
12  standing?: { word?: string; why?: string } | null
13  context?: { percent?: number } | null
14}
15type Window = { percent?: number; resetsAt?: string }
16type Board = {
17  sessions?: BoardSession[]
18  accounts?: { configDir?: string; limits?: { fiveHour?: Window; sevenDay?: Window } }[]
19}
20
21export function readBoard(stdout: string): Board | undefined {
22  try {
23    return JSON.parse(stdout) as Board
24  } catch {
25    return undefined
26  }
27}
28
29export function waitingOf(board: Board, me: string): Waiting[] {
30  return (board.sessions ?? [])
31    .filter(s => s.status === 'needs_input' && s.id !== me)
32    .map(s => {
33      const pending = s.pending?.tool ? [s.pending.tool, s.pending.subject].filter(Boolean).join(' ') : ''
34      return {
35        id: s.id,
36        name: s.title || s.display || s.label || s.id.slice(0, 8),
37        what: clip(pending || s.detail || 'a question', 60),
38      }
39    })
40}
41
42const fixes: Record<string, (why: string) => string> = {
43  conflicts: why =>
44    `This branch conflicts with its base (${why}). Rebase it, resolve every conflict keeping both sides' intent, run the tests, and push.`,
45  'checks failing': why =>
46    `The checks on this branch's pull request are failing (${why}). Read the failing job's log, fix the cause, run it locally, and push.`,
47  'tests failing': () => 'The last test run on this branch failed. Find why, fix it, and run the tests again.',
48  'changes requested': () =>
49    "This branch's pull request has changes requested. Read the open threads with `corgi agent watch pr threads`, fix each valid one, reply, and push.",
50}
51
52const worthSaying = new Set([...Object.keys(fixes), 'ready to merge', 'approved', 'merged', 'closed', 'stuck', 'blocked', 'handoff waits'])
53
54const contextWorthSaying = 70
55
56export function hereOf(board: Board, me: string): Here | undefined {
57  const s = (board.sessions ?? []).find(x => x.id === me)
58  if (s === undefined) return undefined
59  const word = s.standing?.word ?? ''
60  const why = s.standing?.why ?? ''
61  const context = s.context?.percent
62  const showWord = worthSaying.has(word)
63  const showContext = context !== undefined && context >= contextWorthSaying
64  if (!showWord && !showContext) return undefined
65  return {
66    word: showWord ? word : '',
67    why: showWord ? clip(why, 70) : '',
68    context: showContext ? context : undefined,
69    fix: showWord ? fixes[word]?.(why) : undefined,
70  }
71}
72
73export function hereLine(h: Here): string {
74  const parts = [h.word && (h.why ? `${h.word} · ${h.why}` : h.word), h.context !== undefined && `context ${h.context}%`].filter(Boolean)
75  return parts.join(' · ')
76}
77
78export function fiveHourOf(board: Board, configDir: string, now: number): number | undefined {
79  const account = (board.accounts ?? []).find(a => (a.configDir ?? '') === configDir)
80  const w = account?.limits?.fiveHour
81  if (w?.percent === undefined || (w.resetsAt !== undefined && Date.parse(w.resetsAt) < now)) {
82    return undefined
83  }
84  return w.percent
85}
86
87export function statusText(waiting: number, fiveHour: number | undefined): string | undefined {
88  const parts: string[] = []
89  if (waiting > 0) parts.push(`${waiting} waiting on you`)
90  if (fiveHour !== undefined && fiveHour >= 80) parts.push(`5h ${fiveHour}%`)
91  return parts.length ? `corgi · ${parts.join(' · ')}` : undefined
92}
93
94const flags = String.raw`(?:\s+--?\S+)*`
95const corgiAgent = String.raw`\bcorgi${flags}\s+agent${flags}`
96const arg = String.raw`("[^"]*"|'[^']*'|\S+)`
97const patterns: [RegExp, (m: RegExpExecArray) => string][] = [
98  [new RegExp(`${corgiAgent}\\s+chat\\s+(announce|post)\\b`, 'g'), () => 'Slack post'],
99  [new RegExp(`${corgiAgent}\\s+watch\\s+move\\s+${arg}\\s+${arg}`, 'g'), m => `moved ${bare(m[1])} → ${bare(m[2])}`],
100  [new RegExp(`${corgiAgent}\\s+watch\\s+(comment|assign|workpad)\\s+${arg}`, 'g'), m => `${m[1]} ${bare(m[2])}`],
101  [new RegExp(`${corgiAgent}\\s+watch\\s+pr\\s+(ready|merge|close|approve|request|comment)\\s+${arg}`, 'g'), m => `PR ${m[1]} ${short(bare(m[2]))}`],
102  [/\bgh\s+pr\s+(create|ready|merge|comment|review)\b/g, m => `gh pr ${m[1]}`],
103  [/\bglab\s+mr\s+(create|merge|note|update|approve)\b/g, m => `glab mr ${m[1]}`],
104  [/\bgit(?:\s+-C\s+\S+)?\s+push\b(?![^;&|]*--dry-run)/g, () => 'git push'],
105]
106
107export function actionsIn(command: string): string[] {
108  const found: string[] = []
109  for (const [re, label] of patterns) {
110    re.lastIndex = 0
111    for (let m = re.exec(command); m; m = re.exec(command)) {
112      found.push(label(m))
113    }
114  }
115  return found
116}
117
118export function failureOf(isError: boolean, text: string): string | undefined {
119  const line = text.split('\n').map(l => l.trim()).find(l => /^(error|fatal|refused|rejected|denied)\b|token_revoked|invalid_auth|! \[rejected\]/i.test(l))
120  if (line !== undefined) return clip(line.replace(/^Exit code \d+\s*/, ''), 80)
121  if (!isError) return undefined
122  const first = text.split('\n').map(l => l.replace(/^Exit code \d+\s*/, '').trim()).find(Boolean)
123  return clip(first ?? 'failed', 80)
124}
125
126export function settle(labels: string[], why: string | undefined): Action[] {
127  return labels.map(label => (why === undefined ? { label, isDone: true } : { label, isDone: false, why }))
128}
129
130export function signature(waiting: Waiting[], actions: Action[], here?: Here): string {
131  return JSON.stringify([waiting.map(w => w.id + w.what), actions, here ? hereLine(here) : ''])
132}
133
134function bare(s: string | undefined): string {
135  return (s ?? '').replace(/^["']|["']$/g, '')
136}
137
138function short(s: string): string {
139  const m = /\/([^/]+)\/(?:pull|-\/merge_requests)\/(\d+)/.exec(s)
140  return m ? `${m[1]}#${m[2]}` : s
141}
142
143function clip(s: string, n: number): string {
144  return s.length > n ? s.slice(0, n - 1) + '…' : s
145}
146
147const statusOrder: Record<string, number> = { needs_input: 0, limited: 1, working: 2, done: 3, unknown: 4 }
148
149export function sessionsOf(board: Board): PaneSession[] {
150  return (board.sessions ?? [])
151    .filter(s => s.status !== 'gone' && s.status !== 'stale')
152    .map(s => ({
153      id: s.id,
154      name: clip(s.title || s.display || s.label || s.id.slice(0, 8), 40),
155      status: s.status ?? 'unknown',
156      what: clip((s.pending?.tool ? [s.pending.tool, s.pending.subject].filter(Boolean).join(' ') : s.detail) || '', 40),
157      context: (s as { context?: { percent?: number } }).context?.percent,
158    }))
159    .sort((a, b) => (statusOrder[a.status] ?? 9) - (statusOrder[b.status] ?? 9))
160}
161
162const columnOrder: Record<string, number> = { Blocked: 0, Review: 1, Inbox: 2, Ready: 3, Running: 4 }
163
164export function cardsOf(stdout: string): PaneCard[] {
165  let parsed: { cards?: { ref?: string; title?: string; column?: string; workspace?: string; why?: string }[] }
166  try {
167    parsed = JSON.parse(stdout)
168  } catch {
169    return []
170  }
171  return (parsed.cards ?? [])
172    .filter(c => c.ref && c.column && c.column !== 'Done' && !c.ref.startsWith('slack-'))
173    .map(c => ({ ref: c.ref!, title: clip(c.title ?? '', 50), column: c.column!, workspace: c.workspace ?? '', why: c.why }))
174    .sort((a, b) => (columnOrder[a.column] ?? 9) - (columnOrder[b.column] ?? 9))
175}
176
177export function stackOf(stdout: string): PaneService[] {
178  let parsed: { label?: string; port?: number; healthy?: boolean }[]
179  try {
180    parsed = JSON.parse(stdout)
181  } catch {
182    return []
183  }
184  if (!Array.isArray(parsed)) return []
185  return parsed.map(s => ({ label: (s.label ?? '?').replace(/^(services|db_services)\./, ''), port: s.port, isHealthy: s.healthy === true }))
186}
187
188export function budgetOf(board: Board, configDir: string, now: number): string | undefined {
189  const account = (board.accounts ?? []).find(a => (a.configDir ?? '') === configDir)
190  const limits = account?.limits as { fiveHour?: Window; sevenDay?: Window } | undefined
191  const part = (name: string, w?: Window) =>
192    w?.percent === undefined || (w.resetsAt !== undefined && Date.parse(w.resetsAt) < now) ? undefined : `${name} ${w.percent}%`
193  const parts = [part('5h', limits?.fiveHour), part('week', limits?.sevenDay)].filter(Boolean)
194  return parts.length ? parts.join(' · ') : undefined
195}
196
197export function glyph(status: string): string {
198  return { needs_input: '◐', working: '●', limited: '⏸', done: '✓' }[status] ?? '◌'
199}
200
types/index.d.ts 20 lines
1export type Waiting = { id: string; name: string; what: string }
2export type Here = { word: string; why: string; context?: number; fix?: string }
3export type Action = { label: string; isDone: boolean; why?: string }
4export type PaneSession = { id: string; name: string; status: string; what: string; context?: number }
5export type PaneCard = { ref: string; title: string; column: string; workspace: string; why?: string }
6export type PaneService = { label: string; port?: number; isHealthy: boolean }
7export type Snapshot = {
8  sessions: PaneSession[]
9  cards: PaneCard[]
10  stack: PaneService[]
11  budget?: string
12  at: number
13}
14
15declare module 'claude-code' {
16  interface PluginState {
17    'corgi-band': { waiting: Waiting[]; here: Here | null; actions: Action[]; hidden: string; snapshot: Snapshot | null }
18  }
19}
20