A status entry with the time, context fill, plan usage, the agent factory's counts and the tool versions, drawn on every surface a session shows on (terminal…

A Claude Code mod that keeps a one-line readout on screen:
20:41 ctx 42% 5h 73% 7d 53% | 6 live: design 2 dev 1 pipe 2 merge 1 | queued 2 | cc 2.1.296 flow 0.27.0 img 2.27.0
TZ), the context window fill, and the plan's 5-hour and 7-day usage when Claude Code supplies those figures;callum-flow-factory-state state: live is every active state (designing, building, reviewing, fixing, parked, merge-queue), design designing, dev building, pipe reviewing, fixing plus parked, merge merge-queue, queued queued. Refreshed every minute; counts at least five minutes old show their age;On usage measurements, it shows a toast once per conversation for each threshold: context at 85% or more, 5-hour usage at 90% or more, and 7-day usage at 90% or more.
It only draws, apart from one local file: the session's context window size, which the worker heartbeat pushes to the fleet (sessions in factory.workers; the factory loop's factory-loop-workspace writes the same file on loop workspaces). Nothing it shows reaches the conversation, and it never calls a model.
Unlike dev-statusline, which only the terminal draws, a mod is drawn by every client the session shows on: the terminal, the desktop app, VS Code and the Claude mobile app through Remote Control.
It ships in the callum marketplace that every dev-system workspace already has, from the first release that includes it. It is opt-in: install it where you want it. If your workspace is pinned to an older release, first follow the consumer update flow.
An orchestrator workspace (Coder). Install it once, at user scope, from the workspace's own Claude session: attach to it (coder ssh <workspace> -- tmux attach -t claude) and type
/plugin install factory-hud@callum
and pick the user scope. It runs from then on, in that session and every later one. From a shell in the workspace instead: claude plugin install factory-hud@callum --scope user, then /reload-plugins in the session (from the terminal, the phone or claude.ai). The counts show on their own there, since the workspace runs with DEV_ROLE=orchestrator.
Watching it from your phone or the desktop app. Nothing to install on that side: the mod runs where the session runs (the workspace), and the app you watch from draws its readout. Open the session in the Claude app or claude.ai as usual.
Local sessions on your own machine (terminal or the desktop app's Code tab). If the callum marketplace is not registered there, first run claude plugin marketplace add cbundy/dev-system#<release-tag>, replacing <release-tag> with a published release tag containing factory-hud. For an existing older pin, use the consumer update flow linked above. Then install from a terminal with claude plugin install factory-hud@callum --scope user and start a new local session (or /reload-plugins in an existing terminal session). The desktop app's local sessions load it too. (/plugin does not work inside the desktop app.)
/hud hides it in the current conversation, and shows it again. It answers with a toast, so the conversation stays untouched.factory option picks when the counts show: auto (the default: when DEV_ROLE is orchestrator), on or off. Change it in /config, or from the phone with /config factory-hud.factory=on.FACTORY_HUD_SOURCE picks the store the counts read: old, new or shadow. The HUD reads it once at session start and sets CALLUM_FLOW_FACTORY_STATE_SOURCE to it for each callum-flow-factory-state run. Unset or empty leaves factory-state's own default (new); FACTORY_HUD_SOURCE=old switches back. Any other value is ignored, with one log line at session start.claude plugin uninstall factory-hud@callum.$.session.usage(), then the session.measure event each time they move), so they cost nothing.callum-flow-factory-state --repo <owner/name> --github off --format json, using the session repo's GitHub origin, run once a minute in the background, so the line never waits on the database. The store it reads follows FACTORY_HUD_SOURCE. A failed read keeps the last counts.dev-version's snapshot (DEV_VERSIONS_FILE, default /tmp/dev-versions.json); outside a dev-system image it shows Claude Code's alone.claude --plugin-dir plugins/factory-hud loads this checkout's copy for one session and reloads it as files change. npm test validates it and runs plugins/factory-hud/tests/*.test.ts through claude plugin validate and claude plugin test when claude is on PATH. Without it, the other suites still run and the summary notes that mods were skipped. CI installs the Claude Code version pinned in .github/claude-code-version and sets TEST_REQUIRE_CLAUDE=1, so a missing claude fails the gate; a daily canary tests the newest Claude Code.
hooks/register.ts 159 lines1// factory-hud: the session readout as a mod, so it draws wherever the session does
2// (terminal, desktop, VS Code, mobile through Remote Control). It only ever draws: the
3// status entry and the toasts never reach the conversation, and no model is called.
4import { atom, read, update } from 'claude-code'
5import type { EngineInterface, Register } from 'claude-code'
6
7import { counts, dueAlerts, hudSource, repoSlug, statusText, versionsText } from './format'
8import type { Readout } from './format'
9
10// Hidden in this conversation (/hud): kept across a reload, not into a new conversation.
11const isHidden = atom({ plugin: 'factory-hud', key: 'isHidden' } as const, false)
12// The toasts already shown in this conversation, so each shows once.
13const alerted = atom({ plugin: 'factory-hud', key: 'alerted' } as const, [] as string[])
14
15const CLOCK_EVERY_MS = 30_000
16const FACTORY_EVERY_MS = 60_000
17
18type Hud = Readout & { repo?: string; zone?: string; source?: string }
19
20// The module's own state; a reload starts it over and session.start fills it again.
21const hud: Hud = { limits: [], isFactoryShown: false, isFactoryLoading: false, versions: '' }
22
23async function draw($: EngineInterface) {
24 if (await read($, isHidden)) {
25 $.ui.status(undefined)
26 return
27 }
28 $.ui.status(statusText(hud, await $.clock.now(), hud.zone))
29}
30
31async function alert($: EngineInterface) {
32 const due = dueAlerts(hud.context, hud.limits, await read($, alerted))
33 if (due.length === 0) return
34 await update($, alerted, shown => [...shown, ...due.map(([key]) => key)])
35 for (const [, text] of due) $.ui.toast(text, { timeoutMs: 8000 })
36}
37
38// output: a command's stdout, or undefined when it cannot run or fails.
39async function output($: EngineInterface, argv: string[], cwd: string, env?: Record<string, string>) {
40 try {
41 const { exitCode, stdout } = await $.process.run(argv, { cwd, timeoutMs: 30_000, ...(env ? { env } : {}) })
42 return exitCode === 0 ? stdout : undefined
43 } catch {
44 return undefined
45 }
46}
47
48async function refreshFactory($: EngineInterface, cwd: string) {
49 if (!hud.repo) return
50 const json = await output(
51 $,
52 ['callum-flow-factory-state', '--repo', hud.repo, '--github', 'off', '--format', 'json'],
53 cwd,
54 hud.source ? { CALLUM_FLOW_FACTORY_STATE_SOURCE: hud.source } : undefined,
55 )
56 // A failed read keeps the last counts, which then show their age.
57 const next = json === undefined ? undefined : counts(json, await $.clock.now())
58 if (next) hud.factory = next
59 hud.isFactoryLoading = false
60 await draw($)
61}
62
63// recordWindow: the session's context window size, one file per session id, which the
64// worker heartbeat pushes to the fleet with the session's liveness. Written only on a
65// change; a failed write is dropped.
66let recorded = ''
67async function recordWindow($: EngineInterface) {
68 const window = hud.context?.window
69 if (!window) return
70 try {
71 const id = await $.session.id()
72 if (recorded === `${id}=${window}`) return
73 const dir = (await $.env.get('DEV_CONTEXT_WINDOW_DIR')) || '/tmp/dev-context-window'
74 await $.fs.write(`${dir}/${id}`, `${window}\n`)
75 recorded = `${id}=${window}`
76 } catch {
77 // a missing window stays a gap in the fleet data
78 }
79}
80
81async function snapshot($: EngineInterface) {
82 try {
83 return await $.fs.read((await $.env.get('DEV_VERSIONS_FILE')) || '/tmp/dev-versions.json')
84 } catch {
85 return undefined
86 }
87}
88
89export const register: Register = (on, options) => {
90 on('session.start', async ($, e, next) => {
91 await $.command.register({
92 name: 'hud',
93 description: 'Hide or show the factory HUD in this conversation',
94 })
95 const role = await $.env.get('DEV_ROLE')
96 // A new session starts from nothing: no counts or repo carried over from the last.
97 hud.factory = undefined
98 hud.repo = undefined
99 hud.source = undefined
100 hud.isFactoryLoading = false
101 hud.isFactoryShown = options.factory === 'on' || (options.factory !== 'off' && role === 'orchestrator')
102 hud.zone = (await $.env.get('TZ')) || undefined
103 const usage = await $.session.usage()
104 hud.context = usage.context
105 hud.limits = usage.rateLimits
106 hud.versions = versionsText((await $.session.version()).version, await snapshot($))
107 await recordWindow($)
108 if (hud.isFactoryShown) {
109 const picked = hudSource(await $.env.get('FACTORY_HUD_SOURCE'))
110 hud.source = picked.source
111 if (picked.warning) $.ui.log(picked.warning)
112 const url = await output($, ['git', 'remote', 'get-url', 'origin'], e.cwd)
113 hud.repo = url === undefined ? undefined : repoSlug(url)
114 hud.isFactoryLoading = hud.repo !== undefined
115 }
116 await draw($)
117 // Background work: a failure (the session ending under it) is dropped, never surfaced.
118 $.clock.every(CLOCK_EVERY_MS, () => draw($).catch(() => undefined))
119 if (hud.isFactoryShown && hud.repo) {
120 void refreshFactory($, e.cwd).catch(() => undefined)
121 $.clock.every(FACTORY_EVERY_MS, () => refreshFactory($, e.cwd).catch(() => undefined))
122 }
123
124 return next(e)
125 })
126
127 on('session.measure', async ($, e, next) => {
128 hud.context = e.context
129 hud.limits = e.rateLimits
130 await draw($)
131 await alert($)
132 await recordWindow($)
133
134 return next(e)
135 })
136
137 // A /clear or /resume moves to another conversation in the same process, with no
138 // session.start: the last one's context figure, toasts and /hud do not carry over.
139 on('session.end', async ($, e, next) => {
140 if (e.reason === 'clear' || e.reason === 'resume') {
141 hud.context = undefined
142 await update($, isHidden, () => false)
143 await update($, alerted, () => [])
144 await draw($)
145 }
146
147 return next(e)
148 })
149
150 // Answered with a toast, not command output, so nothing is added to the conversation.
151 on('command.run', { command: 'hud' }, async $ => {
152 const isNowHidden = await update($, isHidden, was => !was)
153 await draw($)
154 $.ui.toast(isNowHidden ? 'HUD hidden in this conversation' : 'HUD shown')
155
156 return {}
157 })
158}
159hooks/format.ts 145 lines1// The pure half of factory-hud: what the status entry says and which toasts are due.
2// No $ here, so the tests drive it directly.
3import type { SessionContextUsage, SessionRateLimit } from 'claude-code'
4
5export type Factory = {
6 live: number
7 design: number
8 dev: number
9 pipe: number
10 merge: number
11 queued: number
12 at: number
13}
14
15export type Readout = {
16 context?: SessionContextUsage
17 limits: readonly SessionRateLimit[]
18 factory?: Factory
19 isFactoryShown: boolean
20 isFactoryLoading: boolean
21 versions: string
22}
23
24// The v2 states callum-flow-factory-state reports (docs/factory-state.md) that count as live (waiting stays out).
25const LIVE = ['designing', 'building', 'reviewing', 'fixing', 'parked', 'merge-queue']
26const STATES = ['queued', 'designing', 'building', 'reviewing', 'fixing', 'merge-queue', 'parked', 'waiting', 'closed']
27
28// stateOf: the v2 state one issue row shows; an ended row or a lapsed claim is not live (it counts as closed or queued).
29function stateOf(issue: { state?: unknown; ended?: unknown; detail?: unknown }): string | null {
30 if (issue.ended === true) return 'closed'
31 if (typeof issue.detail === 'string' && issue.detail.startsWith('claim lapsed at')) return 'queued'
32 if (typeof issue.state === 'string' && STATES.includes(issue.state)) return issue.state
33 return null
34}
35const WINDOWS: Record<string, string> = { five_hour: '5h', seven_day: '7d' }
36const STALE_MS = 5 * 60_000
37
38// counts: the factory-state JSON document as the counts the entry shows, or undefined
39// when it is not one.
40export function counts(json: string, at: number): Factory | undefined {
41 let doc: { repos?: { issues?: { state?: unknown; ended?: unknown; detail?: unknown }[] }[] }
42 try {
43 doc = JSON.parse(json)
44 } catch {
45 return undefined
46 }
47 if (!Array.isArray(doc?.repos)) return undefined
48 const states = doc.repos.flatMap(repo => repo.issues ?? []).map(stateOf)
49 const n = (names: string[]) => states.filter(state => state !== null && names.includes(state)).length
50 return {
51 live: n(LIVE),
52 design: n(['designing']),
53 dev: n(['building']),
54 pipe: n(['reviewing', 'fixing', 'parked']),
55 merge: n(['merge-queue']),
56 queued: n(['queued']),
57 at,
58 }
59}
60
61// repoSlug: owner/name from a GitHub origin URL (https or ssh).
62export function repoSlug(url: string): string | undefined {
63 return url.trim().match(/github\.com[:/]([^/\s]+\/[^/\s]+?)(?:\.git)?$/)?.[1]
64}
65
66// clock: HH:MM in the zone, or UTC when the zone is unknown.
67export function clock(ms: number, zone: string | undefined): string {
68 try {
69 return new Date(ms).toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit', timeZone: zone })
70 } catch {
71 return new Date(ms).toISOString().slice(11, 16)
72 }
73}
74
75// statusText: the one line the status entry shows.
76export function statusText(r: Readout, now: number, zone: string | undefined): string {
77 const parts = [clock(now, zone)]
78 if (r.context?.percent !== undefined) parts.push(`ctx ${Math.ceil(r.context.percent)}%`)
79 for (const limit of r.limits) {
80 const name = WINDOWS[limit.kind]
81 if (name) parts.push(`${name} ${Math.ceil(limit.percentUsed)}%`)
82 }
83 if (r.isFactoryShown && r.factory) {
84 const f = r.factory
85 const age = now - f.at
86 parts.push(
87 `| ${f.live} live: design ${f.design} dev ${f.dev} pipe ${f.pipe}` +
88 (f.merge > 0 ? ` merge ${f.merge}` : '') +
89 ` | queued ${f.queued}` +
90 (age >= STALE_MS ? ` (${Math.floor(age / 60_000)}m old)` : ''),
91 )
92 } else if (r.isFactoryShown && r.isFactoryLoading) {
93 parts.push('| factory loading')
94 }
95 if (r.versions) parts.push(`| ${r.versions}`)
96 return parts.join(' ')
97}
98
99// versionsText: Claude Code's version, then callum-flow and the base image
100// from dev-version's snapshot when there is one.
101export function versionsText(claude: string, snapshot: string | undefined): string {
102 const parts = [`cc ${claude.split(' ')[0]}`]
103 if (snapshot) {
104 try {
105 const v = JSON.parse(snapshot) as {
106 plugin_version?: string | null
107 base_image?: string | null
108 }
109 if (v.plugin_version) parts.push(`flow ${v.plugin_version}`)
110 if (v.base_image) parts.push(`img ${v.base_image}`)
111 } catch {
112 // A snapshot that is not JSON adds nothing.
113 }
114 }
115 return parts.join(' ')
116}
117
118// dueAlerts: the toasts due now and not yet shown, as [key, text]: context at 85%, a usage
119// window at 90%.
120export function dueAlerts(
121 context: SessionContextUsage | undefined,
122 limits: readonly SessionRateLimit[],
123 shown: readonly string[],
124): [string, string][] {
125 const due: [string, string][] = []
126 if ((context?.percent ?? 0) >= 85) {
127 due.push(['context-85', `Context is ${Math.ceil(context?.percent ?? 0)}% full`])
128 }
129 for (const limit of limits) {
130 const name = WINDOWS[limit.kind]
131 if (name && limit.percentUsed >= 90) {
132 due.push([`${limit.kind}-90`, `${name} usage is at ${Math.ceil(limit.percentUsed)}%`])
133 }
134 }
135 return due.filter(([key]) => !shown.includes(key))
136}
137
138// hudSource: the store the factory counts read, from FACTORY_HUD_SOURCE. Empty or unset
139// leaves factory-state's own default; a value that is not a store gives a warning.
140export function hudSource(raw: string | undefined): { source?: 'old' | 'new' | 'shadow'; warning?: string } {
141 if (raw === undefined || raw === '') return {}
142 if (raw === 'old' || raw === 'new' || raw === 'shadow') return { source: raw }
143 return { warning: `FACTORY_HUD_SOURCE=${raw} is not old, new or shadow; ignored` }
144}
145types/index.d.ts 10 lines1// The alerts the HUD can raise, by key: context at 85%, a usage window at 90%.
2export type AlertKey = string
3
4declare module 'claude-code' {
5 interface PluginState {
6 // isHidden: the HUD is hidden in this conversation (/hud). alerted: the toasts already shown.
7 'factory-hud': { isHidden: boolean; alerted: AlertKey[] }
8 }
9}
10