SLOPSHOPPER

Conductor

Context-driven development for Claude Code: setup, spec, plan, implement, review, programmes, and decision tracks.

panebandguardcommandtoaststatus
v1.7.1Apache-2.0updated 2026-10-12newtonmunene99/claudekit/plugins/conductor
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · conductor
│ ┃ Conductor ✕ › fix the failing auth test and add an audit log call │ ┃ No conductor/ here. Run │ ┃ /conductor:conductor-setup to start. ⏺ 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 │ │ › /conductor-board │ ⎿ conductor: Conductor board opened. │ │ ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts

Draws

Pane · Conductor
No conductor/ here. Run /conductor:conductor-setup to start.
README

Conductor Plugin

Context-driven development for Claude Code: setup, spec, plan, implement, review, archive, handoff, and revert.

Measure twice, code once.

Install

/plugin install conductor --marketplace newtonmunene99/claudekit

On Claude Code older than 2.1.275, add the marketplace first, then install:

/plugin marketplace add https://github.com/newtonmunene99/claudekit
/plugin install conductor@claudekit

Update

/plugin marketplace update claudekit
/plugin update conductor@claudekit
/reload-plugins

From a shell: claude plugin marketplace update claudekit && claude plugin update conductor@claudekit, then restart Claude Code.

Commands

CommandDescription
/conductor:conductor-setupProject bootstrap; on an existing project, upgrades it to current conventions
/conductor:conductor-new-trackBrainstorm, spec, plan (single track or programme mode)
/conductor:conductor-implementExecute plan todos (depends_on, eligible picker, cleanup + continue options)
/conductor:conductor-statusProgress, eligible / blocked tracks, deferred checks, unmerged branches, out-of-date files
/conductor:conductor-archiveMove finished tracks' spec and plan to conductor/archive/, keeping a ledger line
/conductor:conductor-handoffSave session state into the plan or backlog and print a short prompt for the next session
/conductor:conductor-revertGit-aware revert (the only skill Claude will not start by itself)
/conductor:conductor-reviewReview against guidelines, plan, spec
/conductor:conductor-programme-reviewReview multi-track programme
/conductor:conductor-validate-reviewValidate review findings against repo
/conductor:conductor-prototypeDecision-track spike on spike/<slug> branch

Execution model

Conductor runs a track as a small execution graph, not a linear chain:

ConcernMechanismWhere
Standing answersWorking Agreements in the project's workflow.md: Conductor files local or committed, who commits, branch, autonomy, hand checks, verifierWorking Agreements Protocol
Plumbing without the modelscripts/conductor_state.py: reads (tracks, plan, backlog, verify-paths, doctor) and state writes (set-todo, track-status, archive)Deterministic Plumbing Protocol
Real dependencies onlytodo blocked_by + files; implement runs any ready todoPlan Authoring Guide
Parallel workdisjoint-file todos and parallel-ready tracks fan out to subagents, user-confirmedParallel Dispatch Protocol
Verification on the edgefresh read-only verifier per phase (the whole track on the last one), per todo for risky changes, and on every plan draftIndependent Verification Protocol
Tests that can failGoogle Testing on the Toilet rules, contract probes, no tautological teststemplates/test-quality.md
Local failuresretry / skip / repair / isolate / escalate / stop tableFailure Policy
Bounded loopsattempts per todo, review_rounds per plan, hard capsConvergence Budgets
Costscripts → cheap model → strong model by taskModel Routing

All protocols live in templates/conductor-protocol.md.

python3 "${CLAUDE_PLUGIN_ROOT}/scripts/conductor_state.py" tracks
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/conductor_state.py" plan conductor/plans/<file>.plan.md
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/conductor_state.py" verify-paths <plan-or-review.md> --create-ok
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/conductor_state.py" backlog
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/conductor_state.py" set-todo <plan> <todo_id> completed --sha <sha>
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/conductor_state.py" track-status <track_id> in_progress
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/conductor_state.py" archive <track_id>
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/conductor_state.py" doctor [--fix] [--stamp]

HUD (mods)

On Claude Code builds with function hooks, the plugin also loads hooks/register.tsx, a mod that keeps the active track on screen. Everything it shows comes from conductor_state.py; it never parses plans itself, and it shows nothing in a repo without conductor/context/tracks.md.

PieceWhat it does
Status line<track> 7/12 while the band is hidden, or the next eligible track when none is in progress
Band above the promptColoured chips in the statusline's palette: the track (its mark spins while a turn runs), progress bar with phase, and red/yellow/blue chips for blocked, deferred and other tracks in flight; the next todo's id and text; Board (b) and Hide buttons
/conductor-boardPane with coloured, iconed sections: overall progress bar, a bar per phase, next todo, parallel batch, waiting and blocked todos, deferred checks, every other track in progress (progress, next todo, its own Implement), other tracks, and buttons that fill in /conductor:conductor-implement, review, archive or status
ToastsPhase done, a todo newly blocked, review hitting its 2-round limit, track complete
Upgrade nudgeAt session start, a toast when doctor finds drift worth /conductor:conductor-setup
Status guardDenies Edit/Write/sed -i/redirects that change a todo's status in conductor/plans/ or rewrite tracks.md, pointing at set-todo. New pending todos and other plan fields pass. It matches spellings, so it is a guardrail, not a boundary; it stays off when python3 cannot run the script

In the terminal, the chips and the Board and Hide buttons have round ends drawn with Powerline glyphs (Ghostty bundles them); with a font that lacks them, set Band chip ends to square in the config menu.

It refreshes after each Edit, Write or Bash call and at the end of every turn, re-running the script only when tracks.md or a plan in progress changed. With several tracks in progress, the status line and band follow the one whose plan changed last. Develop it with claude plugin validate plugins/conductor and claude plugin test plugins/conductor.

What's new in 1.7.0

  • Programmes from anywhere: new-track starts a programme from a request for several tracks, a list of 3+ items, or a grilling session, and carries decisions already made into the specs instead of asking again. A design is approved in one prompt.
  • No more tracks stuck in progress: archive records completed or cancelled in the track's metadata, and doctor repairs archived tracks still marked open (or asks, when the plan can't tell).
  • Backlog sorting: when no next track is ready, Track Cleanup offers to sort the backlog (Keep / Promote / Drop, up to 4 items per prompt); status shows the open count.
  • Local files stay local: Keep local writes conductor/.gitignore (*) instead of editing your root .gitignore; doctor --fix moves the old root line.

Upgrading an existing project

Run /conductor:conductor-setup again. On a project that is already set up it runs doctor, applies the mechanical repairs (plans stranded by old archives, archived tracks still marked in progress, duplicated backlog items, contradictory .gitignore advice, an old conductor/ line in the root .gitignore), reports unreadable track metadata (never rewriting it), adds Working Agreements, refreshes stale workflow sections while keeping project-specific lines, and stamps the version in conductor/context/index.md. /conductor:conductor-status says when a project is out of date.

Evals

Two claude plugin eval suites, kept separate so each runs, costs, and reports on its own:

SuiteDirCovers
statusevals/ (default)/conductor:conductor-status outcomes: counts, eligible / blocked / parallel-ready, legacy format, not-set-up, negative
graphevals-graph/implement picks the first ready todo (blocked_by), offers parallel dispatch, reports typo'd blockers, escalates at attempts: 3; validate-review flags wrong paths; implement not-set-up
claude plugin eval ./plugins/conductor --allow-tools Write
claude plugin eval ./plugins/conductor --eval-dir evals-graph --allow-tools Write Edit

Both suites grade outcomes (last message and files), not tool trajectories: a slash-expanded skill never shows up as a Skill tool call. No case grants Bash, so conductor_state.py is not exercised by the evals; the skills' documented manual fallbacks are. results/ dirs are gitignored.

The script has its own unit tests, which run each subcommand against a throwaway conductor/ tree:

python3 -m unittest discover plugins/conductor/scripts

Programme mode

Starts from any of:

  • a review in conductor/reviews/*.md (validate it first with /conductor:conductor-validate-review),
  • a request for a programme or several tracks, or a list of 3+ items,
  • a grilling or design session in the same conversation that settles 3+ items or names 2+ tracks (its decisions are carried into the specs, not asked again).

Then: split tracks → synthesis → implement in order (continue via explicit cleanup choices when unblocked).

Reference: docs/examples/remediation-programme-example.md

Decision tracks

Deliverable is an OKF decision concept at .adr/decisions/<slug>.md, in the local decision bundle at the repo root. .adr/ carries a .gitignore with *, so decisions, spike evidence and the fallback glossary are never committed unless you ask. Project docs stay in repo knowledge bundles (knowledge/, <pkg>/knowledge/).

Workflow: /engineering:grilling → /engineering:research → /conductor:conductor-prototype → /engineering:grill-with-docs

See OKF v0.1.

Project docs / knowledge requests

  1. Discover existing **/knowledge/index.md bundles
  2. Prefer repo-root knowledge/ or domain <pkg>/knowledge/ beside code
  3. Scaffold from templates/knowledge/bundle-placement-guide.md

Artifacts

  • Conductor: conductor/context/, conductor/specs/, conductor/plans/, conductor/reviews/, conductor/archive/. Commit them, or keep them local (conductor/.gitignore holds *); setup records the choice in Working Agreements and every command follows it.
  • OKF knowledge: knowledge/ or <pkg>/knowledge/ in the repository

Attribution

Conductor from gemini-cli-extensions/conductor. OKF from Google Cloud OKF spec. Engineering skills from mattpocock/skills (MIT).

Output style: Base rules are defined in templates/conductor-protocol.md and templates/output-style.md.

Source 4 files
hooks/register.tsx 472 lines
1// Conductor HUD: a status line, a band above the prompt, a /conductor-board
2// pane, milestone toasts, an upgrade nudge, and a guard that keeps todo
3// status changes on conductor_state.py. All data comes from that script, so
4// the HUD never parses plans itself.
5
6import { atom, read, update } from 'claude-code'
7import type { EngineInterface, Register } from 'claude-code'
8
9import { changesStatus, denyReason, isPlanPath, rewritesConductorFile } from './guard'
10import { hasBand, inFlightPlans, milestones, pickTrack, statusText, toSnapshot } from './snapshot'
11
12type Json = Record<string, any>
13
14const PANE = 'conductor-board'
15const snapshot = atom({ plugin: 'conductor', key: 'snapshot' } as const, null)
16const isBandHidden = atom({ plugin: 'conductor', key: 'isBandHidden' } as const, false)
17
18// The band's colours match the statusline mod's pills, so the two read as one.
19const TONE = {
20  purple: '#e6def5',
21  grey: '#e6e6e6',
22  red: '#f6dcd6',
23  yellow: '#f6ecd2',
24  blue: '#dbe3f6',
25} as const
26const INK = '#2b2b2b'
27const ACCENT = '#7a5cc4'
28const TRACK = '#b5b5b5'
29const LEVEL = { ok: '#5a9a68' } as const
30
31// Section headings of the board: an icon and a colour each.
32const HEAD = {
33  next: { icon: '▸', color: ACCENT },
34  phases: { icon: '◔', color: '#5a9a68' },
35  waiting: { icon: '◷', color: '#4a6fb5' },
36  person: { icon: '!', color: '#c8553d' },
37  others: { icon: '◆', color: ACCENT },
38  tracks: { icon: '≡', color: '#8a8a8a' },
39} as const
40
41const BAR_WIDTH = 10
42
43// Filled and empty cells of a done/total bar.
44function barCells(done: number, total: number): [string, string] {
45  const filled = total ? Math.round((done / total) * BAR_WIDTH) : 0
46  return ['█'.repeat(filled), '░'.repeat(BAR_WIDTH - filled)]
47}
48
49// Boxes have no corner radius, so chips end in half-disc glyphs in their own
50// colour. The terminal's are Powerline's (Ghostty bundles them; the `ends`
51// option squares them for fonts without); a desktop gets Unicode half circles
52// and keeps its native, already rounded, buttons.
53const CAPS = { terminal: ['\ue0b6', '\ue0b4'], other: ['◖', '◗'] } as const
54
55// The track mark spins while a turn runs. The timer starts on the first draw
56// that sees one and stops on the first that does not.
57const SPIN = ['◐', '◓', '◑', '◒']
58let spin: { timer: { cancel: () => void }; frame: number } | null = null
59
60function spinFrame($: EngineInterface): string {
61  if (!spin) {
62    const next = { frame: 0, timer: $.clock.every(250, () => {
63      next.frame += 1
64      $.ui.invalidate('ui.render')
65    }) }
66    spin = next
67  }
68  return SPIN[spin.frame % SPIN.length] ?? '◆'
69}
70
71function stopSpin(): void {
72  spin?.timer.cancel()
73  spin = null
74}
75
76const scriptPath = ($: EngineInterface) => `${$.plugin.root}/scripts/conductor_state.py`
77
78// Module state resets on reload; session.start then fires again and refills it.
79let lastKey = ''
80// Plans of the tracks in progress at the last run; their mtimes are in the key.
81let watchedPlans: string[] = []
82// The guard only steers to set-todo when python3 can actually run it.
83let isScriptUsable = false
84
85async function runScript($: EngineInterface, args: string[]): Promise<Json | null> {
86  try {
87    const { stdout } = await $.process.run(['python3', scriptPath($), ...args], {
88      cwd: await $.session.root(),
89      timeoutMs: 8000,
90    })
91    isScriptUsable = true
92    return JSON.parse(stdout) as Json
93  } catch {
94    return null
95  }
96}
97
98// The status line only while the band is not showing the same track.
99async function syncStatus($: EngineInterface): Promise<void> {
100  const s = await read($, snapshot)
101  const isBandShown = hasBand(s) && !(await read($, isBandHidden))
102  $.ui.status(isBandShown ? undefined : statusText(s))
103}
104
105async function mtime($: EngineInterface, path: string): Promise<number> {
106  try {
107    return (await $.fs.stat(path)).mtimeMs
108  } catch {
109    return 0
110  }
111}
112
113// Re-runs the script only when tracks.md or a plan in progress changed, so
114// calling this after every edit costs a few stats.
115async function refresh($: EngineInterface, force = false): Promise<void> {
116  const root = await $.session.root()
117  const tracksFile = `${root}/conductor/context/tracks.md`
118  const prev = await read($, snapshot)
119  if (!(await $.fs.exists(tracksFile))) {
120    if (prev !== null) await update($, snapshot, () => null)
121    $.ui.status(undefined)
122    return
123  }
124  const planMtimes = async (plans: string[]) =>
125    Object.fromEntries(await Promise.all(plans.map(async p => [p, await mtime($, `${root}/${p}`)] as const)))
126  const watched = await planMtimes(watchedPlans)
127  const key = [await mtime($, tracksFile), ...watchedPlans.map(p => watched[p])].join(':')
128  if (!force && key === lastKey) return
129  lastKey = key
130
131  const tracks = await runScript($, ['tracks'])
132  if (!tracks || tracks.error) return
133  // tracks.md may have started or finished a track since the key was taken.
134  const plans = inFlightPlans(tracks)
135  const mtimes = plans.join() === watchedPlans.join() ? watched : await planMtimes(plans)
136  watchedPlans = plans
137  const track = pickTrack(tracks, mtimes)
138  const plan = track?.plan ? await runScript($, ['plan', track.plan]) : null
139  // The board lists every track in flight, so read the others' plans too.
140  const others = ((tracks.tracks ?? []) as Json[]).filter(
141    t => t.plan && t.track_id !== track?.track_id && (tracks.in_progress ?? []).includes(t.track_id),
142  )
143  const otherPlans = Object.fromEntries(
144    await Promise.all(others.map(async t => [t.track_id, await runScript($, ['plan', t.plan])] as const)),
145  )
146  const next = toSnapshot(tracks, plan, mtimes, otherPlans)
147  await update($, snapshot, () => next)
148  await syncStatus($)
149  for (const line of milestones(prev, next)) $.ui.toast(line, { timeoutMs: 6000 })
150}
151
152async function nudgeUpgrade($: EngineInterface): Promise<void> {
153  const doctor = await runScript($, ['doctor'])
154  // A version stamp alone is no drift: every plugin release would nag otherwise.
155  // Unreadable metadata is no drift either: an upgrade can't clear it, a person must.
156  const issues: Json[] = (doctor?.issues ?? []).filter(
157    (i: Json) => i.id !== 'not_set_up' && i.fix !== 'stamp' && i.id !== 'bad_metadata',
158  )
159  if (issues.length === 0) return
160  const from = doctor?.project_version ?? 'unstamped'
161  $.ui.toast(
162    `Conductor files are behind (${from} → ${doctor?.plugin_version}, ${issues.length} ` +
163      `issue${issues.length === 1 ? '' : 's'}). Run /conductor:conductor-setup to upgrade.`,
164    { timeoutMs: 10000 },
165  )
166}
167
168// Shared by /conductor-board and the band's Board button. The button calls this
169// directly: a plugin's own $.command.run skips its own command.run hook, so the
170// command would come back unanswered.
171async function openBoard($: EngineInterface): Promise<string> {
172  await update($, isBandHidden, () => false)
173  await refresh($, true)
174  const opened = await $.ui.open({ id: PANE, title: 'Conductor' })
175  return opened.isPlaced
176    ? 'Conductor board opened.'
177    : 'Conductor board is waiting for a wider terminal.'
178}
179
180export const register: Register = (on, options) => {
181  const isRound = options.ends !== 'square'
182
183  on('session.start', async ($, e, next) => {
184    const started = await next(e)
185    await $.command.register({
186      name: 'conductor-board',
187      description: 'Show the Conductor track board in a pane',
188    })
189    await refresh($, true)
190    if (await read($, snapshot)) await nudgeUpgrade($)
191    return started
192  })
193
194  on('turn.complete', async ($, e, next) => {
195    const done = await next(e)
196    await refresh($)
197    return done
198  })
199
200  // Guard: todo status changes go through set-todo.
201  on('tool.call', { tool: 'Edit' }, ($, e, next) =>
202    isScriptUsable && isPlanPath(e.file_path) && changesStatus(e.old_string, e.new_string)
203      ? { deny: denyReason(scriptPath($)) }
204      : next(e),
205  )
206
207  on('tool.call', { tool: 'Write' }, async ($, e, next) => {
208    if (isScriptUsable && isPlanPath(e.file_path) && (await $.fs.exists(e.file_path))) {
209      const before = await $.fs.read(e.file_path)
210      if (changesStatus(before, e.content)) return { deny: denyReason(scriptPath($)) }
211    }
212    return next(e)
213  })
214
215  on('tool.call', { tool: 'Bash' }, ($, e, next) =>
216    isScriptUsable && rewritesConductorFile(e.command)
217      ? { deny: denyReason(scriptPath($)) }
218      : next(e),
219  )
220
221  // Keep the HUD live mid-turn: these are the tools that change conductor/.
222  on('tool.call', async ($, e, next) => {
223    const ran = await next(e)
224    if (e.tool === 'Edit' || e.tool === 'Write' || e.tool === 'Bash') await refresh($)
225    return ran
226  })
227
228  // Always answers: a hook that throws is skipped, and the engine then says no
229  // hook answered the command, hiding the real failure.
230  on('command.run', { command: 'conductor-board' }, async $ => {
231    try {
232      return { text: await openBoard($) }
233    } catch (err) {
234      return { text: `Conductor board could not open: ${err instanceof Error ? err.message : err}` }
235    }
236  })
237
238  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
239    const s = await read($, snapshot)
240    if (e.props.hasSurvey || !hasBand(s) || !s?.plan || (await read($, isBandHidden))) {
241      stopSpin()
242      return next(e)
243    }
244    // Another plugin's band beneath stays, under this one.
245    const beneath = await next(e)
246    const { Box, Button, Text } = $.ui.resolve(e)
247    const p = s.plan
248    const [full, empty] = barCells(p.done, p.total)
249    const phase = p.next?.phase ?? p.openPhases[0] ?? null
250    const phaseAt = phase ? p.phases.indexOf(phase) : -1
251    const flags: { key: string; tone: string; text: string }[] = []
252    if (p.blocked.length) flags.push({ key: 'blocked', tone: TONE.red, text: `${p.blocked.length} blocked` })
253    if (p.deferred.length) flags.push({ key: 'deferred', tone: TONE.yellow, text: `${p.deferred.length} deferred` })
254    if (s.inFlight.length > 1) flags.push({ key: 'inflight', tone: TONE.blue, text: `+${s.inFlight.length - 1} in flight` })
255    const mark = e.props.isWorking ? spinFrame($) : '◆'
256    if (!e.props.isWorking) stopSpin()
257
258    const [left, right] = e.surface === 'terminal' ? CAPS.terminal : CAPS.other
259    const chip = (key: string, bg: string, parts: JSX.Element[] | JSX.Element) => (
260      <Box key={key} flexDirection="row">
261        {isRound && <Text color={bg}>{left}</Text>}
262        <Box flexDirection="row" gap={1} paddingX={isRound ? 0 : 1} backgroundColor={bg}>
263          {parts}
264        </Box>
265        {isRound && <Text color={bg}>{right}</Text>}
266      </Box>
267    )
268    const button = (key: 'board' | 'hide', label: string, hotkey: string | undefined, onPress: () => unknown) => {
269      if (e.surface !== 'terminal') return <Button key={key} label={label} hotkey={hotkey} onPress={onPress} />
270      const bg = key === 'board' ? TONE.blue : TONE.grey
271      const text = hotkey ? `${hotkey} ${label}` : label
272      return (
273        <Button key={key} label={label} hotkey={hotkey} plain onPress={onPress}>
274          {isRound ? <Text color={bg}>{left}</Text> : ''}
275          <Text color={INK} backgroundColor={bg}>{isRound ? text : ` ${text} `}</Text>
276          {isRound ? <Text color={bg}>{right}</Text> : ''}
277        </Button>
278      )
279    }
280
281    // No width on the outer box: the engine refuses its own drawing (beneath)
282    // under a Box with a width, and would drop the whole band.
283    return (
284      <Box flexDirection="column">
285        <Box flexDirection="column" width={e.props.bodyColumns}>
286          <Box flexDirection="row" gap={1} flexWrap="wrap">
287            {chip('track', TONE.purple, [
288              <Text key="mark" color={e.props.isWorking ? LEVEL.ok : ACCENT} backgroundColor={TONE.purple}>{mark}</Text>,
289              <Text key="id" color={INK} backgroundColor={TONE.purple} bold>{s.trackId}</Text>,
290            ])}
291            {chip('progress', TONE.grey, [
292              <Text key="bar" color={LEVEL.ok} backgroundColor={TONE.grey}>
293                {full}
294                <Text color={TRACK}>{empty}</Text>
295              </Text>,
296              <Text key="count" color={INK} backgroundColor={TONE.grey} bold>{`${p.done}/${p.total}`}</Text>,
297              ...(phaseAt >= 0
298                ? [<Text key="phase" color={INK} backgroundColor={TONE.grey} dimColor>{`│ phase ${phaseAt + 1}/${p.phases.length}`}</Text>]
299                : []),
300            ])}
301            {flags.map(f => chip(f.key, f.tone, <Text color={INK} backgroundColor={f.tone}>{f.text}</Text>))}
302            <Box flexGrow={1} />
303            {button('board', 'Board', 'b', () => openBoard($))}
304            {button('hide', 'Hide', undefined, async () => {
305              await update($, isBandHidden, () => true)
306              await syncStatus($)
307            })}
308          </Box>
309          {p.next ? (
310            <Box flexDirection="row" gap={1}>
311              <Text dimColor>next</Text>
312              <Text bold color={ACCENT}>{p.next.id}</Text>
313              <Text wrap="truncate-end">{p.next.content}</Text>
314            </Box>
315          ) : (
316            <Text dimColor wrap="truncate-end">{p.blockedReason ?? 'all todos done; run review'}</Text>
317          )}
318        </Box>
319        {beneath}
320      </Box>
321    )
322  })
323
324  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
325    const { Box, Button, Text } = $.ui.resolve(e)
326    const s = await read($, snapshot)
327    if (!s) {
328      return <Text dimColor>No conductor/ here. Run /conductor:conductor-setup to start.</Text>
329    }
330    const p = s.plan
331    const room = Math.max(3, Math.floor(((e.viewport?.rows ?? 30) - 16) / 3))
332    const header = (kind: keyof typeof HEAD, title: string) => (
333      <Text bold color={HEAD[kind].color}>
334        {HEAD[kind].icon} {title}
335      </Text>
336    )
337    const bar = (done: number, total: number) => {
338      const [full, empty] = barCells(done, total)
339      return (
340        <Text>
341          <Text color={LEVEL.ok}>{full}</Text>
342          <Text color={TRACK}>{empty}</Text>
343        </Text>
344      )
345    }
346    const row = (text: string, dim = false) => (
347      <Text dimColor={dim} wrap="truncate-end">
348        {'  '}
349        {text}
350      </Text>
351    )
352    const fill = (cmd: string) => () => $.prompt.fill({ text: cmd })
353
354    return (
355      <Box flexDirection="column" gap={1} width={e.props.bodyColumns}>
356        <Box flexDirection="column">
357          <Box flexDirection="row" gap={1}>
358            <Text bold color={ACCENT}>{s.trackId ?? 'No track'}</Text>
359            {s.trackId && (
360              <Text color={s.isInProgress ? LEVEL.ok : TRACK}>{s.isInProgress ? '● in progress' : '○ next up'}</Text>
361            )}
362          </Box>
363          {s.description && <Text wrap="wrap">{s.description}</Text>}
364          {p && (
365            <Box flexDirection="row" gap={1}>
366              {bar(p.done, p.total)}
367              <Text bold>{`${p.done}/${p.total}`}</Text>
368              <Text dimColor>
369                todos{p.reviewRounds ? ` · review round ${p.reviewRounds}/2` : ''}
370              </Text>
371            </Box>
372          )}
373        </Box>
374
375        {p && (
376          <Box flexDirection="column">
377            {header('next', 'Next')}
378            {row(p.next ? `${p.next.id}: ${p.next.content}` : (p.blockedReason ?? 'nothing ready'))}
379            {p.parallelBatch.length > 0 && row(`parallel batch: ${p.parallelBatch.join(', ')}`, true)}
380          </Box>
381        )}
382
383        {p && p.phaseProgress.some(x => x.total > 0) && (
384          <Box flexDirection="column">
385            {header('phases', 'Phases')}
386            {p.phaseProgress
387              .filter(x => x.total > 0)
388              .map(x => (
389                <Box key={`phase-${x.phase}`} flexDirection="row" gap={1}>
390                  <Text wrap="truncate-end">{'  '}{x.phase}</Text>
391                  {bar(x.done, x.total)}
392                  <Text dimColor={x.done === x.total}>
393                    {x.done}/{x.total}
394                    {x.done === x.total ? ' ✓' : ''}
395                  </Text>
396                </Box>
397              ))}
398          </Box>
399        )}
400
401        {p && p.waiting.length > 0 && (
402          <Box flexDirection="column">
403            {header('waiting', `Waiting (${p.waiting.length})`)}
404            {p.waiting.slice(0, room).map(t => row(`${t.id} ← ${t.blockedBy.join(', ')}`, true))}
405          </Box>
406        )}
407
408        {p && (p.blocked.length > 0 || p.deferred.length > 0) && (
409          <Box flexDirection="column">
410            {header('person', 'Needs a person')}
411            {p.blocked.slice(0, room).map(t => row(`blocked ${t.id}${t.on ? `: ${t.on}` : ''}`))}
412            {p.deferred.slice(0, room).map(t => row(`deferred check ${t.id}${t.phase ? ` (phase ${t.phase})` : ''}`))}
413          </Box>
414        )}
415
416        {s.others.length > 0 && (
417          <Box flexDirection="column">
418            {header('others', `Also in progress (${s.others.length})`)}
419            {s.others.slice(0, room).map(t => (
420              <Box key={t.trackId} flexDirection="column">
421                <Box flexDirection="row" gap={1}>
422                  <Text color={ACCENT} wrap="truncate-end">
423                    {'  '}
424                    {t.trackId}
425                  </Text>
426                  {t.total > 0 && bar(t.done, t.total)}
427                  {t.total > 0 && <Text dimColor>{`${t.done}/${t.total}`}</Text>}
428                  <Box flexGrow={1} />
429                  <Button
430                    key={`implement-${t.trackId}`}
431                    label="Implement"
432                    onPress={fill(`/conductor:conductor-implement ${t.trackId}`)}
433                  />
434                </Box>
435                {row(t.next ? `  next: ${t.next.content}` : '  nothing ready', true)}
436              </Box>
437            ))}
438          </Box>
439        )}
440
441        <Box flexDirection="column">
442          {header('tracks', 'Tracks')}
443          {row(`eligible: ${s.eligible.join(', ') || 'none'}`)}
444          {s.blockedTracks.slice(0, room).map(t => row(`blocked ${t.id} ← ${t.missing.join(', ')}`, true))}
445          {s.archivable.length > 0 && row(`archivable: ${s.archivable.join(', ')}`, true)}
446        </Box>
447
448        <Box flexDirection="row" gap={1} flexWrap="wrap">
449          {s.trackId && (
450            <Button
451              key="implement"
452              label="Implement"
453              hotkey="i"
454              variant="primary"
455              onPress={fill(`/conductor:conductor-implement ${s.trackId}`)}
456            />
457          )}
458          {s.isInProgress && p && !p.next && (
459            <Button key="review" label="Review" hotkey="v" onPress={fill(`/conductor:conductor-review ${s.trackId}`)} />
460          )}
461          {s.archivable.length > 0 && (
462            <Button key="archive" label="Archive" hotkey="a" onPress={fill('/conductor:conductor-archive')} />
463          )}
464          <Button key="status" label="Status" hotkey="s" onPress={fill('/conductor:conductor-status')} />
465          <Button key="refresh" label="Refresh" hotkey="r" onPress={() => refresh($, true)} />
466          <Button key="close" label="Close" role="dismiss" onPress={() => $.ui.close({ id: PANE })} />
467        </Box>
468      </Box>
469    )
470  })
471}
472
hooks/guard.ts 54 lines
1// Keeps todo status changes on conductor_state.py set-todo, as
2// templates/conductor-protocol.md asks. Pure, so tests can call it directly.
3//
4// Gotcha: this matches spellings, so it is a guardrail against slips, not a
5// security boundary. Plan edits that leave statuses alone (review_rounds, new
6// pending todos, body text) always pass, because skills make them by hand.
7
8const PLAN_PATH = /(^|\/)conductor\/plans\/[^/]+\.plan\.md$/
9const STATUS_LINE = /^\s*status:\s*['"]?([A-Za-z_]+)['"]?\s*$/gm
10
11export const isPlanPath = (path: string): boolean => PLAN_PATH.test(path)
12
13function statusCounts(text: string): Map<string, number> {
14  const counts = new Map<string, number>()
15  for (const m of text.matchAll(STATUS_LINE)) {
16    const s = m[1] ?? ''
17    counts.set(s, (counts.get(s) ?? 0) + 1)
18  }
19  return counts
20}
21
22// True when `after` moved a todo's status, as opposed to adding new pending
23// todos or touching other fields.
24export function changesStatus(before: string, after: string): boolean {
25  const a = statusCounts(before)
26  const b = statusCounts(after)
27  for (const s of new Set([...a.keys(), ...b.keys()])) {
28    const delta = (b.get(s) ?? 0) - (a.get(s) ?? 0)
29    if (delta === 0) continue
30    if (s === 'pending' && delta > 0) continue
31    return true
32  }
33  return false
34}
35
36const IN_PLACE = /\b(sed|perl)\b[^|;&]*\s-[a-zA-Z]*i/
37const REDIRECT = /(>|\btee\b)\s*['"]?\S*conductor\/(plans\/\S+\.plan\.md|context\/tracks\.md)/
38const TARGET = /conductor\/(plans\/\S+\.plan\.md|context\/tracks\.md)/
39
40// True when a shell command rewrites a plan or the registry in place.
41export function rewritesConductorFile(command: string): boolean {
42  if (command.includes('conductor_state.py')) return false
43  return (IN_PLACE.test(command) && TARGET.test(command)) || REDIRECT.test(command)
44}
45
46export function denyReason(script: string): string {
47  return (
48    'conductor: change todo status with ' +
49    `\`python3 "${script}" set-todo <plan> <todo_id> <status>\` ` +
50    '(and track status with `track-status`), not by hand. ' +
51    'Hand edits have mangled plans before; see the Deterministic Plumbing Protocol.'
52  )
53}
54
hooks/snapshot.ts 154 lines
1// Pure mapping from conductor_state.py's JSON to the HUD's snapshot, and the
2// milestones worth a toast between two snapshots. No `$` here, so tests can
3// feed it recorded script output.
4
5import type { ConductorPlan, ConductorSnapshot, ConductorTodo } from '../types'
6
7type Json = Record<string, any>
8
9const str = (value: unknown): string | null =>
10  value === null || value === undefined ? null : String(value)
11
12const todo = (raw: Json): ConductorTodo => ({
13  id: String(raw.id),
14  content: String(raw.content ?? ''),
15  phase: str(raw.phase),
16})
17
18// The track the HUD follows: of the tracks in progress, the one whose plan
19// changed last (each todo update rewrites it), so starting a second track moves
20// the HUD to it; else the recommended one. Ties keep tracks.md order.
21export function pickTrack(tracks: Json, planMtimes: Record<string, number> = {}): Json | null {
22  const all: Json[] = tracks.tracks ?? []
23  const byId = (id: unknown) => all.find(t => t.track_id === id) ?? null
24  const inFlight = ((tracks.in_progress ?? []) as unknown[]).map(byId).filter((t): t is Json => t !== null)
25  let picked: Json | null = null
26  for (const t of inFlight) {
27    if (!picked || (planMtimes[t.plan] ?? 0) > (planMtimes[picked.plan] ?? 0)) picked = t
28  }
29  return picked ?? byId(tracks.recommended)
30}
31
32// Plans of the tracks in progress: the files whose changes can move the HUD.
33export function inFlightPlans(tracks: Json): string[] {
34  const ids = new Set(tracks.in_progress ?? [])
35  return ((tracks.tracks ?? []) as Json[])
36    .filter(t => ids.has(t.track_id) && t.plan)
37    .map(t => String(t.plan))
38}
39
40export function toPlan(raw: Json): ConductorPlan {
41  const ready: Json[] = raw.ready ?? []
42  const waiting: Json[] = raw.waiting ?? []
43  const counts: Json = raw.counts ?? {}
44  const open = [...ready, ...waiting, ...(raw.blocked ?? [])]
45    .map(t => str(t.phase))
46    .filter((p): p is string => p !== null)
47  return {
48    path: String(raw.plan),
49    name: str(raw.name),
50    done: (counts.completed ?? 0) + (counts.deferred ?? 0),
51    total: raw.total ?? 0,
52    next: raw.next ? todo(raw.next) : null,
53    ready: ready.map(todo),
54    waiting: waiting.map(t => ({ ...todo(t), blockedBy: (t.blocked_by ?? []).map(String) })),
55    blocked: (raw.blocked ?? []).map((b: Json) => ({ id: String(b.id), on: str(b.on) })),
56    deferred: (raw.deferred ?? []).map((d: Json) => ({ id: String(d.id), phase: str(d.phase) })),
57    parallelBatch: (raw.parallel_batch ?? []).map(String),
58    reviewRounds: Number(raw.review_rounds ?? 0),
59    phases: (raw.phases ?? []).map(String),
60    openPhases: [...new Set(open)],
61    phaseProgress: ((raw.phase_progress ?? []) as Json[]).map(x => ({
62      phase: String(x.phase),
63      done: Number(x.done ?? 0),
64      total: Number(x.total ?? 0),
65    })),
66    blockedReason: str(raw.blocked_reason),
67  }
68}
69
70// otherPlans: the script's plan JSON for the other tracks in progress, by track id.
71export function toSnapshot(
72  tracks: Json,
73  plan: Json | null,
74  planMtimes: Record<string, number> = {},
75  otherPlans: Record<string, Json> = {},
76): ConductorSnapshot {
77  const track = pickTrack(tracks, planMtimes)
78  const inFlight: string[] = (tracks.in_progress ?? []).map(String)
79  const others = inFlight
80    .filter(id => id !== track?.track_id)
81    .map(id => {
82      const t = ((tracks.tracks ?? []) as Json[]).find(x => x.track_id === id)
83      const raw = otherPlans[id]
84      const p = raw && !raw.error ? toPlan(raw) : null
85      return {
86        trackId: id,
87        description: str(t?.description),
88        done: p?.done ?? 0,
89        total: p?.total ?? 0,
90        next: p?.next ?? null,
91      }
92    })
93  return {
94    trackId: track?.track_id ?? null,
95    inFlight,
96    others,
97    description: track?.description ?? null,
98    isInProgress: track?.status === 'in_progress',
99    plan: plan && !plan.error ? toPlan(plan) : null,
100    recommended: tracks.recommended ?? null,
101    eligible: (tracks.eligible ?? []).map((t: Json) => String(t.track_id)),
102    blockedTracks: (tracks.blocked ?? []).map((t: Json) => ({
103      id: String(t.track_id),
104      missing: (t.missing ?? []).map(String),
105    })),
106    archivable: (tracks.archivable ?? []).map(String),
107    allComplete: Boolean(tracks.all_complete),
108  }
109}
110
111// What changed between two refreshes that the person would otherwise only
112// find in scrollback.
113export function milestones(prev: ConductorSnapshot | null, next: ConductorSnapshot): string[] {
114  if (!prev) return []
115  const out: string[] = []
116
117  if (prev.isInProgress && prev.trackId && next.archivable.includes(prev.trackId)) {
118    out.push(`Conductor: track ${prev.trackId} complete`)
119  }
120
121  const a = prev.plan
122  const b = next.plan
123  if (!a || !b || a.path !== b.path) return out
124
125  for (const phase of a.openPhases) {
126    if (!b.openPhases.includes(phase) && b.phases.includes(phase)) {
127      out.push(`Conductor: phase ${phase} done`)
128    }
129  }
130  const wasBlocked = new Set(a.blocked.map(t => t.id))
131  for (const t of b.blocked) {
132    if (!wasBlocked.has(t.id)) out.push(`Conductor: ${t.id} blocked${t.on ? ` on ${t.on}` : ''}`)
133  }
134  if (a.reviewRounds < 2 && b.reviewRounds >= 2) {
135    out.push('Conductor: review hit its 2-round limit; the next round escalates')
136  }
137  return out
138}
139
140// The engine already prefixes a plugin's status line with its name.
141export function statusText(s: ConductorSnapshot | null): string | undefined {
142  if (!s?.trackId) return undefined
143  const more = s.inFlight.length > 1 ? ` (+${s.inFlight.length - 1} in flight)` : ''
144  if (s.isInProgress && s.plan) return `${s.trackId} ${s.plan.done}/${s.plan.total}${more}`
145  if (s.isInProgress) return `${s.trackId}${more}`
146  return `next track ${s.trackId}`
147}
148
149// The band shows the in-progress track's plan; the status line stands in for it
150// otherwise, so the two never repeat each other.
151export function hasBand(s: ConductorSnapshot | null): boolean {
152  return Boolean(s?.isInProgress && s.plan)
153}
154
types/index.d.ts 65 lines
1// State the Conductor HUD keeps for a session: what conductor_state.py last
2// reported, reduced to what the status line, band and board draw.
3
4export type ConductorTodo = {
5  id: string
6  content: string
7  phase: string | null
8}
9
10export type ConductorWaitingTodo = ConductorTodo & { blockedBy: string[] }
11
12export type ConductorPlan = {
13  path: string
14  name: string | null
15  done: number
16  total: number
17  next: ConductorTodo | null
18  ready: ConductorTodo[]
19  waiting: ConductorWaitingTodo[]
20  blocked: { id: string; on: string | null }[]
21  deferred: { id: string; phase: string | null }[]
22  parallelBatch: string[]
23  reviewRounds: number
24  phases: string[]
25  // Phases that still hold a todo that is not completed or deferred.
26  openPhases: string[]
27  // Each phase's completed-or-deferred count and size, in `phases` order.
28  phaseProgress: { phase: string; done: number; total: number }[]
29  blockedReason: string | null
30}
31
32// A track in progress other than the followed one, as the board lists it.
33export type ConductorTrackSummary = {
34  trackId: string
35  description: string | null
36  done: number
37  total: number
38  next: ConductorTodo | null
39}
40
41export type ConductorSnapshot = {
42  trackId: string | null
43  // Every track in progress, in tracks.md order; trackId is the one followed.
44  inFlight: string[]
45  // The other tracks in flight, in tracks.md order.
46  others: ConductorTrackSummary[]
47  description: string | null
48  isInProgress: boolean
49  plan: ConductorPlan | null
50  recommended: string | null
51  eligible: string[]
52  blockedTracks: { id: string; missing: string[] }[]
53  archivable: string[]
54  allComplete: boolean
55}
56
57declare module 'claude-code' {
58  interface PluginState {
59    conductor: {
60      snapshot: ConductorSnapshot | null
61      isBandHidden: boolean
62    }
63  }
64}
65