SLOPSHOPPER

ship-state

Band above the prompt: branch, dirty files, ahead/behind, PR, CI and prod deploy for the repo the session works in; toasts when CI finishes or prod goes live…

bandguardtoastprocesstimer
v0.1.0MITupdated 2026-10-20tyree88/tempered_plugins/mods/ship-state
A shopper browsing a rack in a slop shop
README

Tempered Plugins

This repository holds plugins from Tempered Works for AI coding tools. Five plugins are for Claude Code. One plugin is for Codex.

A Claude Code "mod" is a plugin of function hooks. A function hook is code that Claude Code runs when an event occurs, for example when a tool call ends. The five Claude Code plugins here are mods. They run inside Claude Code, in the terminal and in the desktop Code tab.

What is in this repository

FolderToolWhat it does
ship-state/Claude CodeShows the git, pull request, CI and deploy state of the current repo in one line above the prompt. Ends the line with a button to commit or push.
timeline/Claude CodeShows a side pane with what is running now, what is next, and what is blocked. The history of the work is below.
limit-resume/Claude CodeShows your usage limits and continues a turn after a rate limit resets.
followups/Claude CodeShows 4 options for your next prompt above the prompt box after each answer. You press 1 to 4 to put one in the box.
lessons/Claude CodeFinds wins and pitfalls in your prompts. It then asks Claude to run your own win-logger and pitfall-logger skills. The status line shows how many entries you logged.
multi-harness/CodexGives Codex 6 skills to plan large work in waves and to track it to completion.
.claude-plugin/marketplace.jsonClaude CodeLists the 5 Claude Code plugins so that Claude Code can install them from this repository.

Why these plugins exist

ship-state. During a coding session, you often need to know if your work is pushed, if CI passed, and if production has the change. Without this plugin, you ask Claude, and Claude runs git and gh commands to find out. Each check costs a model turn. ship-state shows the answer on screen at all times and makes no model calls. When the tree has uncommitted files, the line ends with a button. One key sends the commit prompt. You do not type it.

timeline. Long work with many steps and many subagents is hard to follow. Without a record, you ask "what is running now?", "what is next?" and "what is blocked?" many times. You also cannot see which model each subagent uses. timeline answers these 3 questions at a glance in a side pane. The history of the work is below the answers. timeline keeps one record per repo across sessions.

limit-resume. When a session hits a usage limit, the work stops until you type "try again". If you are away, the session stays idle after the limit resets. limit-resume continues the work at the reset time. It also shows your usage before you reach the limit.

followups. Claude Code shows one grey suggestion for your next prompt. That suggestion is often the wrong one. followups shows 4 options in 4 directions: continue the plan, verify the work, take the alternative path, and wrap up. These options cover the usual next moves. You choose one and edit it. followups sends nothing until you press Enter.

lessons. The same mistakes happen again, and good patterns get lost. A skill that logs them is useful, but it often does not run at the right moment. lessons makes the skill run. It reads your prompts for praise, frustration, and repeated requests. When it finds one, it tells Claude to run the matching skill after Claude finishes your request. The skill always asks "Log it? y/n" before it writes. You stay in control.

multi-harness. Large product work needs a plan, branch and pull request gates, tracker updates, QA evidence, and a safe closeout. multi-harness gives Codex a repeatable method for these steps. The method is the same for every product.

Requirements

  • Claude Code with support for function-hook plugins. We tested the plugins on Claude Code 2.1.288 on macOS. All Claude Code plugins pass claude plugin validate.
  • git 2.31 or newer.
  • The GitHub CLI gh, signed in. ship-state and timeline use it for pull request, CI and deploy data. Without gh, they show only local git data.
  • Production deploy data comes from GitHub deployment records. Vercel and most hosting services create these records.

How to install the Claude Code plugins

Use one of these 2 methods.

Method 1: install from the marketplace. Run these commands in a Claude Code session:

/plugin marketplace add tyree88/tempered_plugins
/plugin install ship-state@tempered-plugins
/plugin install timeline@tempered-plugins
/plugin install limit-resume@tempered-plugins
/plugin install followups@tempered-plugins
/plugin install lessons@tempered-plugins

Install only the plugins that you want.

Method 2: load the folders directly. Clone this repository. Then add the plugin folders to the env block of ~/.claude/settings.json. Separate the folders with :.

{ "env": { "CLAUDE_CODE_PLUGIN_DIRS": "/path/to/tempered_plugins/ship-state:/path/to/tempered_plugins/timeline:/path/to/tempered_plugins/followups:/path/to/tempered_plugins/lessons" } }

New sessions load the plugins. Sessions that are already open do not.

How to use ship-state

ship-state needs no action. It starts with each session.

  1. Look at the band above the prompt. It shows the current repo and branch.
  2. Read the state from left to right:
app ⎇ feat/waitlist  ·  3 dirty  ·  ↑2 ↓0  ·  PR #312  ·  CI ⏳ 4/5  ·  prod = HEAD ✓ 2h ago  ·  0: commit 3 files
PartMeaning
3 dirty3 files have changes that are not committed.
↑2 ↓02 commits are not pushed. 0 commits are not pulled.
PR #312The branch has open pull request 312.
CI ⏳ 4/54 of 5 CI checks are complete.
prod = HEAD ✓Production runs the current commit.
0: commit 3 filesA button. Press 0 in an empty prompt box, or click it. ship-state sends "Commit the working tree changes with a sensible message." to Claude. After 5 minutes, the button also shows how long the files have waited, for example · 24m ago. The key 0 works only when the prompt box is empty. If you type 0 as the first character of a message, it presses the button and sends the commit prompt. Type a space first to start a message with 0.
  1. After a push or a merge, wait for the toast. ship-state shows "CI ✓", "CI ✗" with the failed check names, or "Live on prod".
  2. When the tree is clean and commits are not pushed, the button reads push ↑2. It has no key. Click it, or press ctrl+x tab to focus the band, press Tab or an arrow key to move to push ↑2, then press Enter. It sends "Push the branch." to Claude. The button does not show while Claude works. After you press it, the button stays hidden until Claude's turn ends, or for 60 seconds at most.

ship-state follows Claude when Claude changes to another repo or worktree. It reads local git data every 20 seconds. It reads GitHub data every 5 minutes. After a push or merge, it reads GitHub data every 20 seconds for 10 minutes.

The band of ship-state stacks with the bands of other plugins, such as followups. followups uses the keys 1 to 4. ship-state uses the key 0 for commit only.

How to use timeline

  1. Type /timeline to open or close the pane.
  2. Wait for the pane to open by itself. It opens once per session, on the first of these events:
  3. Claude logs a task.
  4. Claude has 3 or more open tasks.
  5. Claude starts a subagent.
  6. Read the pane from top to bottom. The table below lists the zones.
  7. Look for ⚠ inherited model on a subagent in NOW. This mark means that no model was set for the subagent, so it uses the model of the main session.
  8. If HISTORY has more than 30 entries, use ◀ older and newer ▶ to move between pages.

The pane uses the text and colors of the app, on the desktop and in the terminal. It fits any width. At 70 columns or more, NEXT and BLOCKED sit side by side. At fewer columns, they stack.

ZoneWhat it shows
HeaderThe repo and the branch.
GOALThe title of the plan while the plan has unticked boxes. Otherwise, the latest active task that Claude logged in the last 24 hours.
PLANA progress bar, the current section of the plan file, and the steps done out of the total. It shows only when at least 1 box in the plan is ticked.
NOWThe tasks that Claude logged as in progress in the last 24 hours, with a progress bar when the task has steps. Then the tasks that Claude has in progress, and the subagents that run now. A subagent shows its title, type, model, elapsed time, tool calls and tokens. It also shows now: (the current tool) and next: (the next step) when they are known. Subagents from another session that started more than 24 hours ago do not show.
NEXTUp to 5 pending tasks that wait on nothing. Then +N more.
BLOCKEDPending tasks that wait on an unfinished task (waits on #N). Also the tasks that Claude logged as blocked in the last 24 hours.
AGENTS · last 15 minOne bar for each subagent run in the last 15 minutes, up to 8. Each bar has the short description of the subagent as its label, not the type. The bar starts when the subagent starts and stops when it ends. The colors are blue for running, green for done, red for failed and gray for status unknown. The terminal draws the bars with block characters. Below the bars are the start time, the middle time and now.
HISTORYOne line for each entry, newest first: the time, a mark, and the text. Each subagent shows below the task that it ran for, on a line that starts with ├ or └. A subagent that ran for no logged task has a line of its own. A subagent line shows the type, the model, the title and the run time. History does not show the results of subagents. Each page has 30 entries, and each entry keeps its subagent lines.

The marks in HISTORY are:

MarkMeaning
💬A request or a decision.
▶Running.
✓Done.
⚠Blocked.
✗Failed.
?Status unknown.
↳A commit, a push, a pull request or a CI result.

timeline reads 4 sources:

  • The task list of Claude (TaskCreate, TaskUpdate, TaskList and TodoWrite).
  • The subagents.
  • The plan file that Claude reads or edits. A plan file is a markdown file with checkboxes. Its name contains "plan", or it has 3 or more boxes.
  • The tool mcp__timeline__log.

How timeline works:

  • The plugin adds a tool, mcp__timeline__log. It also adds an instruction of about 100 tokens that tells Claude when to log. Claude logs once for each change of direction, and once at the start, each step, the end, or a block of each task.
  • Each subagent gets a shorter instruction to log its own progress.
  • The instruction tells Claude to write each title, how and next in Simplified Technical English: one short sentence, active voice, no filler.
  • The log tool needs no permission prompt.
  • timeline stores the history per repo in ~/.claude/timelines/<repo>-<hash>/. Each session writes only its own files. Worktrees of a repo share one timeline.
  • If 2 sessions work in the same repo, each pane shows the entries of the other session within 10 seconds.

Usage cost: each logged entry costs approximately 40 to 80 output tokens. The instruction costs approximately 140 tokens in each session.

Privacy: the timeline files contain Claude's one-line summaries, the first 2000 characters of each subagent prompt, and commit subjects. The files stay on your computer.

How to use followups

followups needs no action. It starts with each session.

  1. Wait for Claude to finish an answer. A few seconds later, 4 options appear in the band above the prompt box. Each option has its own row: 1: … to 4: ….
  2. Read the options. Each option goes in a different direction:
  3. Continue the plan.
  4. Verify or test the work.
  5. Take the alternative path, or ask an open question.
  6. Wrap up or commit.
  7. Press 1 to 4 when the prompt box is empty. You can also click an option. The text of the option goes into the prompt box.
  8. Edit the text, or press Enter to send it. followups never sends anything by itself.
  9. To ignore the options, type your own message.
  10. To turn the plugin off or on, type /followups off or /followups on. Type /followups status to see the current setting and the last error, for example a refused model call.

When the band shows, a digit that you type in an empty prompt box picks an option. To start a message with a digit, type a space first.

The band hides while the prompt box has text, while a turn runs, and while a survey uses the band. It comes back when the prompt box is empty.

followups hides the built-in grey suggestion of Claude Code, but only after its own band has drawn once. In a surface without the band, the built-in suggestion stays.

followups makes no options for subagent turns, interrupted turns, errors, and empty answers. If you send a prompt before Haiku answers, followups drops the old reply. After /clear or a resume, followups removes the old options.

Usage cost: followups makes one Haiku call for each answered turn. A call costs approximately 2,000 input tokens and 150 output tokens. followups adds nothing to the context of the main model.

Privacy: the first 1,500 characters of your last prompt and the last 4,000 characters of the answer go to Haiku. The call uses the API client of Claude Code.

How to use lessons

lessons needs 2 skills of your own. Name them win-logger and pitfall-logger. This repository does not include them. The skills decide where an entry goes, for example a Notion database. Each skill always asks "Log it? y/n" before it writes.

  1. Add the 2 skills to Claude Code. Any skills with these names work.
  2. Work as usual. lessons watches only the prompts that you send yourself: in the terminal, in Remote Control, in your own Slack ping, and in the Claude desktop app. It ignores prompts from plugins, notifications, other sessions, and subagents.
  3. Send a prompt that shows a win or a pitfall. The table below lists the signals.
  4. Claude finishes your request first. Then Claude runs the matching skill. lessons adds a short note to your prompt to cause this. You do not see the note.
  5. Read the draft that the skill shows. Answer y to log it. Answer n to skip it.
  6. Look at the status line. 🌱 2 · ⚠ 1 means 2 wins and 1 pitfall are logged in this session. lessons counts a row when you answer y to a draft. The count resets after /clear or a resume.
  7. To turn the plugin off or on, type /lessons off or /lessons on. Type /lessons status to see the setting, the counts, and where each skill was found.
KindSignals
WinPraise, for example "perfect", "nailed it", "love this", "this is great", "exactly what I wanted". Or an ask: "log this win", "log this as a win", "add this to learnings", "remember this worked".
PitfallFrustration, for example "I already told you", "no, I said", "still wrong", "still failing", "this is the third time", "why did you change…", "not what I asked". Or shouting: several words in all capitals. Or the same request sent again: it has high word overlap with one of your last 10 prompts. Or an ask: "log this", "add this to pitfalls", "remember this lesson".

lessons avoids common false signals. These prompts do not trigger it: "exactly 3 retries", "pixel perfect", "log this error to sentry", "why did you choose zod?", "the second time I click it throws". File names such as README or CHANGELOG do not trigger it. HTTP method names do not trigger it.

lessons adds at most 1 note of each kind for each 5 prompts.

lessons looks for the skills in 2 places:

  • The skills loaded in the session. The name can also be anthropic-skills:<name>.
  • On macOS, the synced-skills folder of the Claude desktop app.

If a skill is missing, lessons shows a toast at most once a day. /lessons status shows "missing" for that skill.

Usage cost: lessons makes no model calls. A note costs approximately 40 tokens. lessons adds a note only to a prompt that matches.

Privacy: your last 10 prompts stay in memory only, for the repeat check. lessons does not write them to disk.

How to use limit-resume

limit-resume needs no action. It starts with each session.

  1. Read the status line below the prompt. It shows your usage, for example 5h 62% · 7d 41%. 5h is the 5-hour window. 7d is the 7-day window.
  2. If the 5-hour usage reaches 85%, a toast tells you. Commit your work at this point.
  3. If a turn stops because of a usage limit, the status line shows when the work continues. At the reset time plus 1 minute, limit-resume sends "Continue from where you left off".
  4. If a turn stops because of a temporary API error, limit-resume tries again after 1, 2, 4, and 8 minutes, then every 15 minutes. It stops after 12 tries.
  5. To cancel a pending continue, type any message.
  6. To turn the plugin off or on, type /autoresume off or /autoresume on. Type /autoresume status to see the current setting.

Claude Code has a built-in setting, autoContinueAtUsageLimit, that also continues after a usage limit. Do not use the built-in setting and limit-resume together for usage limits. If you do, the turn gets 2 "continue" messages.

How to use multi-harness

multi-harness is a Codex plugin. Its manifest is multi-harness/.codex-plugin/plugin.json, and its plugin name is platform-orchestrator. It is not in the Claude Code marketplace file.

  1. Install the multi-harness folder with the Codex plugin installer.
  2. Ask Codex to use Platform Orchestrator on a backlog. For example: "Use Platform Orchestrator to turn this backlog into shippable waves, branch and PR gates, tracker updates, and verification evidence."
  3. Use the templates in multi-harness/assets/templates/ for wave plans, tracker updates, QA evidence, and pull request closeout.

The 6 skills are:

SkillUse
platform-wave-orchestratorDivide a backlog into agent lanes and implementation waves.
platform-agent-patternsChoose how agents work together on a wave.
platform-pr-closeoutGate and close branches and pull requests.
platform-tracker-syncUpdate GitHub and Notion trackers.
platform-qa-evidenceCollect QA evidence for each change.
platform-safety-reviewReview work that touches sensitive data, regulated text, or trust and safety limits.

To check the folder structure, run python3 multi-harness/scripts/check_plugin_structure.py.

Development

Each Claude Code plugin has checks for its logic. Node 23 or newer runs the .ts check files directly.

node limit-resume/check.ts
node ship-state/check.ts
node followups/checks/ask.check.ts
node lessons/checks/detect.check.ts
bash timeline/checks/run.sh

To run the behavior test of ship-state, run claude plugin test ship-state. It runs 16 cases on the terminal and desktop surfaces.

To run the behavior test of timeline, run claude plugin test timeline. It runs 18 cases on the terminal and desktop surfaces.

To run the behavior test of followups, run claude plugin test followups. It runs 8 cases on the terminal and desktop surfaces.

To run the behavior test of lessons, run claude plugin test lessons. It runs 9 cases.

To type-check timeline, do these 2 steps:

  1. In a Claude Code session in this repository, run /plugin-types .claude/types. This command writes the Claude Code type declarations.
  2. Run tsc -p timeline/tsconfig.check.json.

License

MIT. See LICENSE. Copyright 2026 Tempered Works LLC.

Source 3 files
hooks/register.tsx 196 lines
1import { atom, read, update } from 'claude-code'
2import type { EngineInterface as Engine, Register } from 'claude-code'
3
4import type { Snap } from '../types'
5import { action, isPending, lastCd, segments, summarize } from './lib'
6
7const snap = atom({ plugin: 'ship-state', key: 'snap' } as const, null)
8
9const TICK = 20_000 // local git every tick; remote too while CI or a deploy is pending
10const REMOTE_EVERY = 5 * 60_000
11const WATCH = 10 * 60_000 // after a push/merge, poll remote fast for this long
12const PUSH = /\bgit\s+push\b|\bgh\s+pr\s+(merge|create)\b|\bvercel\b.*--prod/
13const TONE = { dim: undefined, ok: 'green', warn: 'yellow', bad: 'red' } as const
14const SENT_FOR = 60_000 // after a press, hide the button until the turn completes, or this long if no turn comes
15
16const parse = (text: string | undefined) => {
17  try {
18    return text ? JSON.parse(text) : undefined
19  } catch {
20    return undefined
21  }
22}
23
24// Shared by the hooks and the top-level helpers below: the loader lets $ reach only functions declared at the top of this file.
25const st = {
26  dir: undefined as string | undefined,
27  cur: null as Snap | null,
28  gh: 'gh',
29  remoteAt: 0,
30  watchUntil: 0,
31  isBusy: false,
32  sentAt: 0, // ms of the last button press; 0 when none pending
33  seen: { ciPending: '', prod: '' },
34}
35
36const run = async ($: Engine, argv: string[], cwd?: string) => {
37  try {
38    const r = await $.process.run(argv, cwd ? { cwd, timeoutMs: 15_000 } : { timeoutMs: 15_000 })
39    return r.exitCode === 0 ? r.stdout.trim() : undefined
40  } catch {
41    return undefined
42  }
43}
44const toplevel = ($: Engine, path: string) => run($, ['git', '-C', path, 'rev-parse', '--show-toplevel'])
45
46const notify = ($: Engine, s: Snap) => {
47  if (s.ci?.pending) st.seen.ciPending = s.ci.sha
48  else if (s.ci && st.seen.ciPending === s.ci.sha) {
49    st.seen.ciPending = ''
50    const sha = s.ci.sha.slice(0, 7)
51    $.ui.toast(s.ci.failed.length ? `CI ✗ ${s.ci.failed.join(', ')} @${sha}` : `CI ✓ all ${s.ci.total} green @${sha}`, {
52      timeoutMs: 10_000,
53    })
54  }
55  const key = s.prod ? `${s.prod.sha}:${s.prod.state}` : ''
56  if (st.seen.prod && s.prod && key !== st.seen.prod) {
57    const sha = s.prod.sha.slice(0, 7)
58    if (s.prod.state === 'success') $.ui.toast(`Live on prod: ${sha}${s.prod.url ? ` → ${s.prod.url}` : ''}`, { timeoutMs: 15_000 })
59    if (s.prod.state === 'failure' || s.prod.state === 'error') $.ui.toast(`Prod deploy ${s.prod.state}: ${sha}`, { timeoutMs: 15_000 })
60  }
61  st.seen.prod = key
62}
63
64// A press of the band button: hide it, then submit the prompt as the person's own words. A refused submit is ignored.
65const press = async ($: Engine, prompt: string) => {
66  st.sentAt = await $.clock.now()
67  await update($, snap, s => (s ? { ...s } : s)) // a new version redraws the band without the button
68  try {
69    await $.prompt.submit({ text: prompt, asUser: true })
70  } catch {
71    st.sentAt = 0 // nothing was queued: show the button again
72    await update($, snap, s => (s ? { ...s } : s))
73  }
74}
75
76const refresh = async ($: Engine, wantRemote: boolean) => {
77  const d = st.dir // a `cd` can move `dir` mid-refresh; this snapshot stays on one repo
78  if (st.isBusy || !d) return
79  st.isBusy = true
80  const git = (...args: string[]) => run($, ['git', ...args], d)
81  const api = async (path: string) => parse(await run($, [st.gh, 'api', `repos/{owner}/{repo}/${path}`], d))
82  try {
83    const head = await git('rev-parse', 'HEAD')
84    if (!head) {
85      st.cur = null
86      await update($, snap, () => null)
87      return
88    }
89    const branch = (await git('symbolic-ref', '--short', '-q', 'HEAD')) ?? `detached ${head.slice(0, 7)}`
90    const dirty = ((await git('status', '--porcelain')) ?? '').split('\n').filter(Boolean).length
91    const counts = await git('rev-list', '--left-right', '--count', '@{u}...HEAD')
92    const [behind, ahead] = counts ? counts.split(/\s+/).map(Number) : [null, null]
93    const now = await $.clock.now()
94    // After a hot reload `st.cur` is null; the persisted snapshot keeps `dirtySince` so the age does not restart.
95    const kept = st.cur ?? (await read($, snap))
96    const prev = kept?.dir === d ? kept : undefined
97    const s: Snap = { ...prev, dir: d, branch, head, dirty, ahead, behind }
98    if (dirty) s.dirtySince = prev?.dirtySince ?? now
99    else delete s.dirtySince
100    if (wantRemote || isPending(st.cur) || now < st.watchUntil || now - st.remoteAt > REMOTE_EVERY) {
101      st.remoteAt = now
102      const upstream = await git('rev-parse', '@{u}')
103      const runs = upstream && (await api(`commits/${upstream}/check-runs?per_page=100`))
104      const status = upstream && (await api(`commits/${upstream}/status`))
105      s.ci = upstream && (runs || status)
106        ? { sha: upstream, ...summarize(runs?.check_runs ?? [], status?.statuses ?? []) }
107        : undefined
108      s.pr = branch.startsWith('detached') ? undefined : parse(await run($, [st.gh, 'pr', 'view', '--json', 'number,state'], d))
109      const dep = (await api('deployments?environment=Production&per_page=1'))?.[0]
110      const last = dep && (await api(`deployments/${dep.id}/statuses?per_page=1`))?.[0]
111      s.prod = dep
112        ? { sha: dep.sha, state: last?.state ?? 'pending', url: last?.environment_url, at: last?.created_at ?? dep.created_at }
113        : undefined
114      notify($, s)
115    }
116    st.cur = s
117    await update($, snap, () => s)
118  } finally {
119    st.isBusy = false
120  }
121}
122
123export const register: Register = on => {
124  on('session.start', async ($, e, next) => {
125    st.dir = await toplevel($, await $.session.cwd())
126    // The desktop app's PATH may lack Homebrew or /usr/local: try the usual install locations.
127    for (const candidate of ['gh', '/opt/homebrew/bin/gh', '/usr/local/bin/gh']) {
128      if (await run($, [candidate, '--version'], undefined)) {
129        st.gh = candidate
130        break
131      }
132    }
133    void refresh($, true)
134    $.clock.every(TICK, () => void refresh($, false))
135    return next(e)
136  })
137
138  // Follow the repo Claude actually works in (it often `cd`s into a worktree), and watch after a push or merge.
139  on('tool.call', { tool: 'Bash' }, async ($, e, next) => {
140    const ran = await next(e)
141    if (e.agentId) return ran
142
143    const target = lastCd(e.command, st.dir ?? (await $.session.cwd()))
144    const top = target && (await toplevel($, target))
145    if (top && top !== st.dir) {
146      st.dir = top
147      st.cur = null
148      st.remoteAt = 0 // new repo: fetch its CI/prod now, not in 5 min
149      st.seen.ciPending = st.seen.prod = ''
150    }
151    const isPushed = PUSH.test(e.command) && ran.deny === undefined && ran.isError !== true
152    if (isPushed) st.watchUntil = (await $.clock.now()) + WATCH
153    if (top || isPushed || /\b(git|gh)\b/.test(e.command)) void refresh($, isPushed)
154    return ran
155  })
156
157  on('turn.complete', ($, e, next) => {
158    if (!e.agentId) {
159      st.sentAt = 0
160      void refresh($, false)
161    }
162    return next(e)
163  })
164
165  // Stacks: our row, then whatever the plugins beneath drew (followups' options).
166  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
167    const beneath = await next(e)
168    const s = await read($, snap)
169    if (!s || e.props.hasSurvey) return beneath
170
171    const { Box, Text, Button } = $.ui.resolve(e)
172    const now = await $.clock.now()
173    const act = e.props.isWorking || now - st.sentAt < SENT_FOR ? undefined : action(s, now)
174
175    return (
176      <Box flexDirection="column">
177        <Box flexDirection="row">
178          {segments(s, now).map((seg, i) => (
179            <Text key={String(i)} color={TONE[seg.tone]} dimColor={seg.tone === 'dim'} wrap="truncate">
180              {i ? '  ·  ' : ''}
181              {seg.text}
182            </Text>
183          ))}
184          {act && (
185            <Text key="sep" dimColor>
186              {'  ·  '}
187            </Text>
188          )}
189          {act && <Button key="act" hotkey={act.hotkey} plain dimColor label={act.label} onPress={() => void press($, act.prompt)} />}
190        </Box>
191        {beneath}
192      </Box>
193    )
194  })
195}
196
hooks/lib.ts 83 lines
1import type { Checks, Snap } from '../types'
2
3export type Run = { name: string; status: string; conclusion: string | null; started_at?: string | null }
4export type Status = { context: string; state: string }
5export type Seg = { text: string; tone: 'dim' | 'ok' | 'warn' | 'bad' }
6
7const FAIL = new Set(['failure', 'timed_out', 'action_required', 'error'])
8const WAIT = new Set(['pending', 'queued', 'in_progress'])
9
10// Last `cd <dir>` in a shell command, resolved against base; undefined when there is none.
11export function lastCd(command: string, base: string): string | undefined {
12  const all = [...command.matchAll(/(?:^|&&|;|\|\||\n)\s*cd\s+(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))/g)]
13  const m = all.at(-1)
14  const p = m && (m[1] ?? m[2] ?? m[3])
15  if (!p || /^[~$-]/.test(p)) return undefined
16  return p.startsWith('/') ? p : `${base}/${p}`
17}
18
19// One verdict per check name: the newest non-skipped run wins; commit statuses are already latest per context.
20export function summarize(runs: Run[], statuses: Status[]): Checks {
21  const verdict = new Map<string, string>()
22  const live = runs
23    .filter(r => r.conclusion !== 'skipped' && r.conclusion !== 'neutral')
24    .sort((a, b) => (b.started_at ?? '').localeCompare(a.started_at ?? ''))
25  for (const r of live) {
26    if (!verdict.has(r.name)) verdict.set(r.name, r.status === 'completed' ? (r.conclusion ?? 'neutral') : 'pending')
27  }
28  for (const s of statuses) if (!verdict.has(s.context)) verdict.set(s.context, s.state)
29  const all = [...verdict]
30  return {
31    total: all.length,
32    pending: all.filter(([, v]) => WAIT.has(v)).length,
33    failed: all.filter(([, v]) => FAIL.has(v)).map(([n]) => n),
34  }
35}
36
37export const isPending = (s: Snap | null) =>
38  !!s && ((s.ci?.pending ?? 0) > 0 || WAIT.has(s.prod?.state ?? ''))
39
40const ago = (at: number, now: number) => {
41  const m = Math.max(0, Math.round((now - at) / 60_000))
42  return m < 60 ? `${m}m ago` : m < 1440 ? `${Math.round(m / 60)}h ago` : `${Math.round(m / 1440)}d ago`
43}
44
45export function segments(s: Snap, now: number): Seg[] {
46  const segs: Seg[] = [{ text: `${s.dir.split('/').at(-1)} ⎇ ${s.branch}`, tone: 'dim' }]
47  segs.push(s.dirty ? { text: `${s.dirty} dirty`, tone: 'warn' } : { text: 'clean', tone: 'dim' })
48  if (s.ahead === null) segs.push({ text: 'no upstream', tone: 'warn' })
49  else segs.push({ text: `↑${s.ahead} ↓${s.behind}`, tone: s.ahead || s.behind ? 'warn' : 'dim' })
50  if (s.pr) segs.push({ text: `PR #${s.pr.number}${s.pr.state === 'OPEN' ? '' : ` ${s.pr.state.toLowerCase()}`}`, tone: 'dim' })
51  if (s.ci?.total) {
52    const at = s.ci.sha === s.head ? '' : ` @${s.ci.sha.slice(0, 7)}`
53    if (s.ci.failed.length) segs.push({ text: `CI ✗ ${s.ci.failed.join(', ')}${at}`, tone: 'bad' })
54    else if (s.ci.pending) segs.push({ text: `CI ⏳ ${s.ci.total - s.ci.pending}/${s.ci.total}${at}`, tone: 'warn' })
55    else segs.push({ text: `CI ✓ ${s.ci.total}${at}`, tone: 'ok' })
56  }
57  if (s.prod) {
58    const { sha, state, at } = s.prod
59    const who = sha === s.head ? 'prod = HEAD' : `prod ${sha.slice(0, 7)}`
60    if (state === 'success') segs.push({ text: `${who} ✓ ${ago(Date.parse(at), now)}`, tone: 'ok' })
61    else if (FAIL.has(state)) segs.push({ text: `${who} ✗ ${state}`, tone: 'bad' })
62    else if (WAIT.has(state)) segs.push({ text: `${who} ⏳ deploying`, tone: 'warn' })
63    else segs.push({ text: `${who} ${state}`, tone: 'dim' })
64  }
65  return segs
66}
67
68export type Action = { label: string; prompt: string; hotkey?: '0' }
69
70export const COMMIT_PROMPT = 'Commit the working tree changes with a sensible message.'
71export const PUSH_PROMPT = 'Push the branch.'
72const AGE_AFTER = 5 * 60_000 // show how long the tree has been dirty once it is this old
73
74// The band's one-key action: commit (key 0) while the tree is dirty; else push (click only) while commits wait on an upstream; else none.
75export function action(s: Snap, now: number): Action | undefined {
76  if (s.dirty) {
77    const age = s.dirtySince !== undefined && now - s.dirtySince >= AGE_AFTER ? ` · ${ago(s.dirtySince, now)}` : ''
78    return { label: `commit ${s.dirty} ${s.dirty === 1 ? 'file' : 'files'}${age}`, prompt: COMMIT_PROMPT, hotkey: '0' }
79  }
80  if (s.ahead) return { label: `push ↑${s.ahead}`, prompt: PUSH_PROMPT } // no key: a stray 0 must never push
81  return undefined
82}
83
types/index.d.ts 21 lines
1export type Checks = { total: number; pending: number; failed: string[] }
2
3export type Snap = {
4  dir: string
5  branch: string
6  head: string
7  dirty: number
8  dirtySince?: number // ms since epoch when `dirty` last went from 0 to > 0; absent while clean
9  ahead: number | null
10  behind: number | null
11  pr?: { number: number; state: string }
12  ci?: Checks & { sha: string }
13  prod?: { sha: string; state: string; url?: string; at: string }
14}
15
16declare module 'claude-code' {
17  interface PluginState {
18    'ship-state': { snap: Snap | null }
19  }
20}
21