Roadmaps as a dependency graph: JSON source of truth, mechanical status recompute, projected task lists, Mermaid diagrams, an HTML dashboard, the interview…

claude plugin marketplace add JasonWarrenUK/goblin-mode
claude plugin install roadmap@goblin-mode
Requires python3 (3.8+, stdlib only) on PATH. The /ready pane needs Claude Code 2.1.287 or later and draws in the terminal; the skills work on any version.
| Situation | Skill |
|---|---|
| Choose the next task (one pick) | /roadmap:next-suggest |
| See the whole ready-set | /roadmap:next-group |
| Situation | Skill | |
|---|---|---|
| Add a task, a chain of tasks or a milestone | /roadmap:update-tasks | |
| Tasks need owners, or a dev's load needs handing over | /roadmap:update-devs | |
| You are starting a task, or dropping one | `/roadmap:claim [<task id>] [<assignee>\ | release]` |
| Situation | Skill |
|---|---|
Work landed / statuses drifted (add reconcile to check against code) | /roadmap:maintain |
| Priorities, freshness or dependency-graph review | /roadmap:review |
| Render the HTML dashboard | /roadmap:dashboard |
| Write the dashboard somewhere other than the default path | /roadmap:configure artefact <path> [phase] |
| Situation | Skill |
|---|---|
| No roadmap yet | /roadmap:create |
| Half-formed ideas to explore into tasks | /roadmap:create-interview |
| Old single-file format detected | /roadmap:migrate |
/ready: The Ready Set as a PaneOpens a pane with the whole ready set, the claims in play and each milestone's progress by release tier, read from the .claude/roadmaps.json above the session's working directory. Running /ready again closes it. It runs inside Claude Code with no turn, so it works while Claude is busy.
The ready set is split into subgroups, by dev unless you change it, each subgroup in leverage order. Every ready task draws; when the list outgrows the pane the body scrolls (the arrow keys while the pane has the keyboard, or the wheel). The digits follow the drawn order, so the subgroups you put first take 1 upwards.
| Key | Does |
|---|---|
1 to 9 | Picks one of the first nine ready rows. Rows past the ninth have no digit; Tab reaches them. |
q w e t y u i o p | Picks a claim in play, in the order listed. |
c | Claims the picked ready task: asks who is doing it (a name is never inferred or pre-filled), then runs claim <id> --assignee=<name> --reassign, so a name typed here replaces any assignee the task already had. The change is in roadmaps.json; commit it when you are ready. |
a | Assigns the picked task without starting it, ready or in play: asks who will do it, then runs assign <id> --assignee=<name>. Submitting a blank name clears the assignee (assign <id> --unassign). |
g | Cycles what the ready set is grouped by: dev, milestone, tier, nothing. |
s | Asks which subgroups lead, as a comma-separated list of names or ids (Jason, unassigned; M8; secondary), matched without regard to case. The rest follow in natural order: devs alphabetically with the unassigned last, milestones by number, tiers lowest first. A blank answer restores the natural order. |
r | Refreshes from the CLI. |
Esc, or /ready | Closes the pane. |
The grouping and the order are kept in the plugin's own store on your machine, never in the roadmap, so each dev's pane remembers their own: Jaz's can lead with Jaz while Jason's leads with Jason, from the same roadmaps.json.
The pane refreshes itself every two minutes while open and whenever a tool call touches roadmaps.json or runs the CLI. It is a tab beside any other pane, /diff included: Ctrl+X Tab moves the keyboard between panes, and only one shows at a time. In a fullscreen terminal of 110 columns or more it docks beside the transcript; narrower, it sits above the prompt. Without a roadmap it says so and names /roadmap:create.
A claim says someone has started a task. The task gains a started date, and views show it as in progress while it is todo or blocked (a paused, deferred or finished status wins); its status stays computed, so a claim never changes one. A blocked task can be claimed when every task or milestone member blocking it is already claimed in the same file (work stacked on the work that unblocks it); a gate always refuses.
You rarely claim by hand. When a branch appears (from a git command or a worktree, or one you made just before) or a session starts on a branch that claims nothing, the plugin has Claude ask one question: which ready task this is, who is doing it and whether to push the branch so the team sees the claim. Nothing is written until you answer. To claim or drop a task yourself, run /roadmap:claim: it lists the ready tasks when you give no ID, asks who is doing it and commits the change.
| To | Run | |
|---|---|---|
| Claim by hand (no skill) | python3 <plugin-root>/scripts/roadmap.py claim <ID> [--assignee NAME] | |
| Assign without claiming | `python3 <plugin-root>/scripts/roadmap.py assign <ID> (--assignee NAME \ | --unassign)` |
| Drop a claim (no skill) | python3 <plugin-root>/scripts/roadmap.py release <ID> [--unassign] | |
| Stop the question on one branch | git config branch.<name>.roadmapClaim none |
The hooks need python3 too; without it they stay silent.
| File | Path | Notes |
|---|---|---|
| Roadmap Source of Truth | <project>/.claude/roadmaps.json | every skill finds it by walking up from the working directory |
| File | Path |
|---|---|
| Roadmap Conventions | references/roadmap-conventions.md |
| The CLI every skill and the pane run | scripts/roadmap.py; python3 -m unittest test_roadmap in that directory runs its tests |
| The pane's code | hooks/register.tsx; claude plugin test <plugin-root> runs its tests |
hooks/register.tsx 642 lines1// The roadmap pane: `/ready` opens the whole ready set the CLI computes, in
2// leverage order, with the claims in play and the milestones' progress, and
3// runs again to close it. The ready set is split into subgroups (by dev unless
4// this person chose otherwise), the body scrolls when it outgrows the pane,
5// and the first nine rows take a digit; the rest are reached with Tab. A
6// letter picks a claim in play; `c` claims a ready row after asking who
7// (replacing any assignee it already had), `a` assigns or, left blank, clears
8// an assignee without starting anything, `g` cycles what the set is grouped
9// by, `s` asks which subgroups lead, `r` refreshes. An assignee is never
10// inferred. The CLI is the plugin's own scripts/roadmap.py, the same file the
11// skills run, so the pane needs python3 and nothing else. Nothing here edits
12// roadmaps.json except through `claim` and `assign`.
13//
14// The grouping lives in the plugin's store, a file of this machine's, so each
15// dev keeps their own without anything in the roadmap saying so.
16//
17// Colours are the engine's theme keys, never raw values: the pane follows
18// whichever theme the person runs. A release tier takes one hue everywhere it
19// appears (the tier row, its milestone chips, the task ids drawn from it).
20
21import { atom, read, update } from 'claude-code'
22import type { EngineInterface, Register } from 'claude-code'
23
24import type { Asking, Candidate, Claimed, GroupBy, Grouping, Milestone, Problem, Snapshot } from '../types'
25
26const PANE = 'ready'
27// Only the first nine ready rows take a digit; the rest are reached with Tab.
28const DIGITS = 9
29// Hotkeys for the claims in play; digits belong to the ready rows and c, a, g, s, r to the actions.
30const IN_PLAY_KEYS = 'qwetyuiop'
31const BAR_CELLS = 5
32const TIER_LABEL_WIDTH = 11
33const GROUP_BYS: readonly GroupBy[] = ['dev', 'milestone', 'tier', 'none']
34const DEFAULT_GROUPING: Grouping = { by: 'dev', first: [] }
35const UNASSIGNED = 'unassigned'
36
37const snapshot = atom({ plugin: 'roadmap', key: 'snapshot' } as const, null as Snapshot | null)
38const selected = atom({ plugin: 'roadmap', key: 'selected' } as const, null as string | null)
39const asking = atom({ plugin: 'roadmap', key: 'asking' } as const, null as Asking | null)
40const grouping = atom({ plugin: 'roadmap', key: 'grouping' } as const, null as Grouping | null)
41const ordering = atom({ plugin: 'roadmap', key: 'ordering' } as const, false)
42
43// Module-level because the validator holds `$` to top-level functions; only
44// the CLI path lives here, which no drawing reads.
45let cli = ''
46
47type Ui = ReturnType<EngineInterface['ui']['resolve']>
48
49const isRecord = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v)
50const str = (v: unknown): string => (typeof v === 'string' ? v : typeof v === 'number' ? String(v) : '')
51const num = (v: unknown): number => (typeof v === 'number' && Number.isFinite(v) ? v : 0)
52
53// No cwd: the default is the session's working directory read per call, so a
54// move into a worktree takes the pane with it and the CLI finds that branch's
55// roadmaps.json by walking up from there.
56const run = ($: EngineInterface, args: readonly string[]) => $.process.run(['python3', cli, ...args], { timeoutMs: 15_000 })
57
58const firstLine = (text: string): string => text.trim().split('\n')[0] ?? ''
59
60const lastLine = (text: string): string => text.trim().split('\n').pop() ?? ''
61
62/** What the CLI said when it refused: its own `✗` line goes to stdout; a traceback's last line is the error. */
63export const reasonOf = (ran: { stdout: string; stderr: string }, fallback: string): string => {
64 if (/Traceback \(most recent call last\)/.test(ran.stderr)) return lastLine(ran.stderr) || fallback
65 return firstLine(ran.stdout) || firstLine(ran.stderr) || fallback
66}
67
68const isPaneOpen = async ($: EngineInterface): Promise<boolean> => {
69 try {
70 return (await $.ui.panes()).some(p => p.id === PANE)
71 } catch {
72 return false
73 }
74}
75
76const TIER_NAMES = ['Core', 'Secondary', 'Tertiary', 'Quaternary', 'Quinary']
77const TIER_HUES = ['claude', 'suggestion', 'remember', 'permission'] as const
78
79/** One hue per release tier, cycling past the fourth. */
80export const tierHue = (tier: number): string => TIER_HUES[Math.max(0, tier) % TIER_HUES.length] ?? 'subtle'
81
82/** A fixed-width bar: `███░░` for 60% in five cells. */
83export const bar = (pct: number, cells: number): string => {
84 const filled = Math.round((Math.max(0, Math.min(100, pct)) / 100) * cells)
85 return '█'.repeat(filled) + '░'.repeat(cells - filled)
86}
87
88/** The dashes that finish a labelled rule across `columns`: `── Ready now ─────────`, with the label drawn apart so it can be bright. */
89export const ruleTail = (label: string, columns: number): string => '─'.repeat(Math.max(2, columns - label.length - 4))
90
91const isGroupBy = (v: unknown): v is GroupBy => typeof v === 'string' && (GROUP_BYS as readonly string[]).includes(v)
92
93/** The grouping the store holds, read defensively; anything unset or odd falls back to grouping by dev in natural order. */
94export const parseGrouping = (by: unknown, first: unknown): Grouping => ({
95 by: isGroupBy(by) ? by : DEFAULT_GROUPING.by,
96 first: Array.isArray(first) ? first.filter((s): s is string => typeof s === 'string' && s.trim() !== '').map(s => s.trim()) : [],
97})
98
99/** The next key in the cycle after `by`. */
100export const nextGroupBy = (by: GroupBy): GroupBy => GROUP_BYS[(GROUP_BYS.indexOf(by) + 1) % GROUP_BYS.length] ?? 'dev'
101
102/** The names typed into the order field: comma-separated, trimmed, blanks dropped. */
103export const parseFirst = (text: string): string[] =>
104 text
105 .split(',')
106 .map(s => s.trim())
107 .filter(s => s !== '')
108
109const milestoneNumber = (id: string): number => {
110 const n = Number.parseInt(id.replace(/^\D+/, ''), 10)
111 return Number.isFinite(n) ? n : Number.MAX_SAFE_INTEGER
112}
113
114export type Subgroup = { key: string; label: string; members: Candidate[] }
115
116/**
117 * The ready set split by `by`, each subgroup in leverage order. The subgroups
118 * named in `first` lead in that order (matched case-insensitively on the
119 * key, or on the label for a tier, whose key is only its index); the rest
120 * follow in natural order: devs alphabetically with the unassigned last,
121 * milestones by number, tiers lowest first. Grouping by nothing gives one
122 * unlabelled subgroup.
123 */
124export const subgroup = (candidates: readonly Candidate[], by: GroupBy, first: readonly string[]): Subgroup[] => {
125 if (by === 'none') return [{ key: '', label: '', members: [...candidates] }]
126 const groups = new Map<string, Subgroup>()
127 for (const c of candidates) {
128 const { key, label } =
129 by === 'dev'
130 ? { key: c.assignee.trim() || UNASSIGNED, label: c.assignee.trim() || UNASSIGNED }
131 : by === 'milestone'
132 ? { key: c.milestone, label: c.milestoneName ? `${c.milestone} ${c.milestoneName}` : c.milestone }
133 : { key: String(c.tier), label: c.tierLabel || TIER_NAMES[c.tier] || `Tier ${c.tier + 1}` }
134 const group = groups.get(key) ?? { key, label, members: [] }
135 group.members.push(c)
136 groups.set(key, group)
137 }
138 const natural = (a: Subgroup, b: Subgroup): number => {
139 if (by === 'dev') {
140 if (a.key === UNASSIGNED) return 1
141 if (b.key === UNASSIGNED) return -1
142 return a.key.localeCompare(b.key, undefined, { sensitivity: 'base' })
143 }
144 if (by === 'milestone') return milestoneNumber(a.key) - milestoneNumber(b.key) || a.key.localeCompare(b.key)
145 return Number(a.key) - Number(b.key)
146 }
147 const wanted = first.map(s => s.toLowerCase())
148 const rank = (g: Subgroup): number => {
149 const i = wanted.indexOf((by === 'tier' ? g.label : g.key).toLowerCase())
150 return i === -1 ? wanted.length : i
151 }
152 return [...groups.values()].sort((a, b) => rank(a) - rank(b) || natural(a, b))
153}
154
155/** The grouping this machine remembers, into the pane's state; absent, the default. */
156const loadGrouping = async ($: EngineInterface): Promise<void> => {
157 try {
158 const [by, first] = await Promise.all([$.store.get('groupBy'), $.store.get('groupOrder')])
159 await update($, grouping, () => parseGrouping(by, first))
160 } catch {
161 await update($, grouping, () => DEFAULT_GROUPING)
162 }
163}
164
165/** Remembers a grouping on this machine and draws it. */
166const saveGrouping = async ($: EngineInterface, next: Grouping): Promise<void> => {
167 await update($, grouping, () => next)
168 try {
169 await Promise.all([$.store.set('groupBy', next.by), $.store.set('groupOrder', next.first)])
170 } catch {
171 $.ui.toast('the grouping could not be saved; it holds for this session')
172 }
173}
174
175/** Milestones grouped by release tier, lowest tier first, each group in roadmap order. */
176export const groupByTier = (milestones: readonly Milestone[]): { tier: number; label: string; milestones: Milestone[] }[] => {
177 const tiers = [...new Set(milestones.map(m => m.tier))].sort((a, b) => a - b)
178 return tiers.map(tier => {
179 const members = milestones.filter(m => m.tier === tier)
180 return { tier, label: members[0]?.tierLabel || TIER_NAMES[tier] || `Tier ${tier + 1}`, milestones: members }
181 })
182}
183
184/** Turn the CLI's two JSON documents into what the pane draws. */
185export const parseSnapshot = (readyText: string, statsText: string, at: number): Snapshot => {
186 const ready: unknown = JSON.parse(readyText)
187 const stats: unknown = JSON.parse(statsText)
188 if (!isRecord(ready) || !isRecord(stats)) throw new Error('not an object')
189 const candidates: Candidate[] = (Array.isArray(ready.candidates) ? ready.candidates : []).filter(isRecord).map(c => ({
190 id: str(c.id),
191 description: str(c.description),
192 milestone: str(c.milestone),
193 milestoneName: str(c.milestoneName),
194 milestoneDonePct: num(c.milestoneDonePct),
195 tier: num(c.tier),
196 tierLabel: str(c.tierLabel),
197 transitiveUnblocks: num(c.transitiveUnblocks),
198 isMilestoneSink: c.isMilestoneSink === true,
199 assignee: str(c.assignee),
200 }))
201 const claimed: Claimed[] = (Array.isArray(ready.claimed) ? ready.claimed : []).filter(isRecord).map(c => ({
202 id: str(c.id),
203 description: str(c.description),
204 assignee: str(c.assignee),
205 started: str(c.started),
206 }))
207 const milestones: Milestone[] = (Array.isArray(stats.milestones) ? stats.milestones : []).filter(isRecord).map(m => ({
208 id: str(m.id),
209 name: str(m.name),
210 donePct: num(m.donePct),
211 tier: num(m.tier),
212 tierLabel: str(m.tierLabel) || TIER_NAMES[num(m.tier)] || '',
213 state: str(m.state),
214 }))
215 const byStatus = isRecord(stats.byStatus) ? stats.byStatus : {}
216 return {
217 ok: true,
218 problem: 'none',
219 reason: '',
220 phase: str(ready.phase) || str(stats.phase),
221 donePct: num(stats.donePct),
222 doneCount: num(byStatus.done),
223 inScope: num(stats.inScope),
224 milestones,
225 candidates,
226 claimed,
227 at,
228 }
229}
230
231const refresh = async ($: EngineInterface): Promise<void> => {
232 const at = await $.clock.now()
233 const failed = (problem: Problem, reason: string): Snapshot => ({
234 ok: false,
235 problem,
236 reason,
237 phase: '',
238 donePct: 0,
239 doneCount: 0,
240 inScope: 0,
241 milestones: [],
242 candidates: [],
243 claimed: [],
244 at,
245 })
246 try {
247 const detect = await run($, ['detect'])
248 if (detect.exitCode === 3) return void (await update($, snapshot, () => failed('legacy', 'old single-file roadmap')))
249 if (detect.exitCode === 2) return void (await update($, snapshot, () => failed('missing', reasonOf(detect, 'no roadmap above this directory'))))
250 if (detect.exitCode !== 0) return void (await update($, snapshot, () => failed('broken', reasonOf(detect, 'the CLI refused'))))
251 const [ready, stats] = await Promise.all([run($, ['ready', '--json']), run($, ['stats', '--json'])])
252 if (ready.exitCode !== 0 || stats.exitCode !== 0) {
253 return void (await update($, snapshot, () => failed('broken', reasonOf(ready.exitCode !== 0 ? ready : stats, 'the CLI refused'))))
254 }
255 const next = parseSnapshot(ready.stdout, stats.stdout, at)
256 await update($, snapshot, () => next)
257 } catch (error) {
258 await update($, snapshot, () => failed('broken', error instanceof Error && /ENOENT|not found/i.test(error.message) ? 'python3 is not on PATH' : 'the CLI could not run'))
259 }
260}
261
262const claim = async ($: EngineInterface, id: string, assignee: string): Promise<string> => {
263 const who = assignee.trim()
264 if (!who) return 'a claim needs a name.'
265 try {
266 // The person typed the name on purpose, so a different assignee gives way to it.
267 const ran = await run($, ['claim', id, `--assignee=${who}`, '--reassign'])
268 if (ran.exitCode !== 0) return reasonOf(ran, `claim ${id} refused`)
269 return `claimed ${id} for ${who}. commit roadmaps.json when you are ready.`
270 } catch {
271 return 'the CLI could not run'
272 }
273}
274
275/** Sets who will do a task without starting it; a blank name clears the assignee. */
276const assign = async ($: EngineInterface, id: string, assignee: string): Promise<string> => {
277 const who = assignee.trim()
278 try {
279 const ran = await run($, who ? ['assign', id, `--assignee=${who}`] : ['assign', id, '--unassign'])
280 if (ran.exitCode !== 0) return reasonOf(ran, `assign ${id} refused`)
281 return `${who ? `assigned ${id} to ${who}` : `cleared ${id}'s assignee`}. commit roadmaps.json when you are ready.`
282 } catch {
283 return 'the CLI could not run'
284 }
285}
286
287/** One step of the empty state: a numbered line, what it does, the command that does it. */
288const step = (ui: Ui, n: number, what: string, pointer: string) => {
289 const { Box, Text } = ui
290 const [command = '', alt = ''] = pointer.split(' or ')
291 return (
292 <Box key={`step-${n}`} flexDirection="row" columnGap={1} flexWrap="wrap">
293 <Text color="suggestion" bold>
294 {n}
295 </Text>
296 <Text>{what.padEnd(12)}</Text>
297 <Text color="claude" bold>
298 {command}
299 </Text>
300 {alt && <Text dimColor>or {alt}</Text>}
301 </Box>
302 )
303}
304
305/** No roadmap to draw: a framed card that says why and what to do about it. */
306const emptyState = ($: EngineInterface, ui: Ui, snap: Snapshot, width: number) => {
307 const { Box, Text, Button } = ui
308 const frame = snap.problem === 'broken' ? 'error' : 'subtle'
309 const content =
310 snap.problem === 'legacy'
311 ? {
312 glyph: '◈',
313 title: 'Old roadmap format',
314 lead: 'This roadmap is a single file. The pane reads the phase-array format.',
315 steps: [step(ui, 1, 'Convert it', '/roadmap:migrate'), step(ui, 2, 'Reopen', '/ready or press r')],
316 }
317 : snap.problem === 'broken'
318 ? {
319 glyph: '✗',
320 title: 'The roadmap would not load',
321 lead: snap.reason,
322 steps: [step(ui, 1, 'Check it', '/roadmap:maintain'), step(ui, 2, 'Then', 'r or refresh')],
323 }
324 : {
325 glyph: '◇',
326 title: 'No roadmap in this project',
327 lead: 'Nothing at .claude/roadmaps.json above this directory.',
328 steps: [step(ui, 1, 'Start one', '/roadmap:create'), step(ui, 2, 'Reopen', '/ready or press r')],
329 }
330 return (
331 <Box flexDirection="column" width={width} rowGap={1}>
332 <Box flexDirection="column" borderStyle="round" borderColor={frame} paddingX={2} paddingY={1} rowGap={1}>
333 <Box flexDirection="row" columnGap={1}>
334 <Text color={frame === 'error' ? 'error' : 'claude'} bold>
335 {content.glyph}
336 </Text>
337 <Text bold>{content.title}</Text>
338 </Box>
339 <Text color={snap.problem === 'broken' ? 'error' : undefined} dimColor={snap.problem !== 'broken'}>
340 {content.lead}
341 </Text>
342 {snap.problem === 'missing' && <Text dimColor>A roadmap holds your tasks as a dependency graph. This pane then shows what is unblocked, what it unlocks and who has claimed what.</Text>}
343 <Box flexDirection="column">{content.steps}</Box>
344 </Box>
345 <Box flexDirection="row" columnGap={2}>
346 <Button key="refresh" label="refresh" hotkey="r" onPress={() => refresh($)} />
347 <Text dimColor>esc or /ready closes</Text>
348 </Box>
349 </Box>
350 )
351}
352
353/** The phase line and one row per release tier, each milestone a chip of its own progress. */
354const header = (ui: Ui, snap: Snapshot, inner: number) => {
355 const { Box, Text } = ui
356 const tiers = groupByTier(snap.milestones)
357 const barCells = Math.max(10, Math.min(24, inner - 40))
358 return (
359 <Box flexDirection="column" borderStyle="round" borderColor="subtle" paddingX={1} width={inner + 4}>
360 <Box flexDirection="row" columnGap={2} flexWrap="wrap">
361 <Text bold>{snap.phase || 'roadmap'}</Text>
362 <Text color={snap.donePct >= 100 ? 'success' : 'claude'}>{bar(snap.donePct, barCells)}</Text>
363 <Text bold>{snap.donePct}%</Text>
364 {snap.inScope > 0 && (
365 <Text dimColor>
366 {snap.doneCount}/{snap.inScope} tasks
367 </Text>
368 )}
369 </Box>
370 {tiers.length > 0 && <Text dimColor>{'─'.repeat(Math.max(2, inner))}</Text>}
371 {tiers.map(group => {
372 const hue = tierHue(group.tier)
373 const deferred = group.milestones.every(m => m.state === 'deferred')
374 return (
375 <Box key={`tier-${group.tier}`} flexDirection="row" columnGap={1}>
376 <Box width={TIER_LABEL_WIDTH}>
377 <Text color={hue} bold dimColor={deferred}>
378 {`${group.tier === 0 ? '●' : '○'} ${group.label}`}
379 </Text>
380 </Box>
381 <Box flexDirection="row" columnGap={2} flexWrap="wrap" flexGrow={1}>
382 {group.milestones.map(m => (
383 <Box key={`ms-${m.id}`} flexDirection="row" columnGap={1}>
384 <Text color={hue} dimColor={m.state === 'deferred'} bold={m.donePct < 100 && m.donePct > 0}>
385 {m.id}
386 </Text>
387 {m.donePct >= 100 ? (
388 <Text color="success">✓</Text>
389 ) : (
390 <Text color={m.donePct > 0 ? hue : 'subtle'} dimColor={m.donePct === 0}>
391 {bar(m.donePct, BAR_CELLS)} {m.donePct}%
392 </Text>
393 )}
394 </Box>
395 ))}
396 </Box>
397 </Box>
398 )
399 })}
400 </Box>
401 )
402}
403
404/** A section heading: dim rule either side, the label at full strength so it reads. */
405const heading = (ui: Ui, label: string, inner: number) => {
406 const { Box, Text } = ui
407 return (
408 <Box flexDirection="row" columnGap={1}>
409 <Text dimColor>──</Text>
410 <Text bold>{label}</Text>
411 <Text dimColor>{ruleTail(label, inner)}</Text>
412 </Box>
413 )
414}
415
416/** A subgroup's heading inside the ready set: who or what it is, and how many rows it holds. */
417const subheading = (ui: Ui, group: Subgroup, by: GroupBy) => {
418 const { Box, Text } = ui
419 const colour = by === 'dev' ? (group.key === UNASSIGNED ? undefined : 'warning') : tierHue(group.members[0]?.tier ?? 0)
420 return (
421 <Box key={`sub-${group.key}`} flexDirection="row" columnGap={1} paddingLeft={1}>
422 <Text color={colour} bold>
423 {group.label}
424 </Text>
425 <Text dimColor>· {group.members.length}</Text>
426 </Box>
427 )
428}
429
430/** One ready task: hotkey (the first nine) and id on the first line with the description, the leverage signals beneath. */
431const taskRow = ($: EngineInterface, ui: Ui, c: Candidate, i: number, picked: string | null, inner: number) => {
432 const { Box, Text, Button } = ui
433 const hue = tierHue(c.tier)
434 const isPicked = picked === c.id
435 const lead = 3 + 3 + c.id.length + 1
436 return (
437 <Box key={`task-${c.id}`} flexDirection="column">
438 <Box flexDirection="row" columnGap={1}>
439 <Text color={hue} bold>
440 {isPicked ? '▶' : ' '}
441 </Text>
442 <Button
443 key={`row-${c.id}`}
444 plain
445 hotkey={i < DIGITS ? String(i + 1) : undefined}
446 dimColor={picked !== null && !isPicked}
447 label={c.id}
448 onPress={async () => {
449 await update($, selected, () => c.id)
450 await update($, asking, () => null)
451 await update($, ordering, () => false)
452 }}
453 />
454 <Box width={Math.max(10, inner - lead)}>
455 <Text bold={isPicked} dimColor={picked !== null && !isPicked} wrap={isPicked ? 'wrap' : 'truncate-end'}>
456 {c.description}
457 </Text>
458 </Box>
459 </Box>
460 <Box flexDirection="row" flexWrap="wrap" paddingLeft={5} columnGap={1}>
461 <Text dimColor>↳</Text>
462 <Text color={hue}>unblocks {c.transitiveUnblocks}</Text>
463 <Text dimColor>·</Text>
464 <Text dimColor>
465 {c.milestone} {c.milestoneName ? `${c.milestoneName} ` : ''}
466 {c.milestoneDonePct}%
467 </Text>
468 {c.isMilestoneSink && <Text color="success">completes it</Text>}
469 {c.assignee && <Text color="warning">● {c.assignee}</Text>}
470 </Box>
471 </Box>
472 )
473}
474
475/** Claims in play: who holds which task, and since when. The first nine take a letter hotkey so an assignee can be handed over. */
476const claimedRows = ($: EngineInterface, ui: Ui, claimed: readonly Claimed[], picked: string | null, inner: number) => {
477 const { Box, Text, Button } = ui
478 return claimed.map((c, i) => (
479 <Box key={`claimed-${c.id}`} flexDirection="row" columnGap={1}>
480 <Text color="warning">{picked === c.id ? '▶' : '●'}</Text>
481 <Button
482 key={`claimed-row-${c.id}`}
483 plain
484 hotkey={IN_PLAY_KEYS[i]}
485 dimColor={picked !== null && picked !== c.id}
486 label={c.id}
487 onPress={async () => {
488 await update($, selected, () => c.id)
489 await update($, asking, () => null)
490 await update($, ordering, () => false)
491 }}
492 />
493 <Text color="warning">{c.assignee || 'someone'}</Text>
494 <Text dimColor>since {c.started || '?'}</Text>
495 <Box width={Math.max(8, inner - c.id.length - (c.assignee || 'someone').length - (c.started || '?').length - 14)}>
496 <Text dimColor wrap="truncate-end">
497 {c.description}
498 </Text>
499 </Box>
500 </Box>
501 ))
502}
503
504export const register: Register = on => {
505 on('session.start', async ($, e, next) => {
506 cli = `${$.plugin.root}/scripts/roadmap.py`
507 await loadGrouping($)
508 try {
509 await $.command.register({
510 name: 'ready',
511 description: 'The roadmap ready set in a pane, or closes it: a digit picks, c claims, a assigns, g groups, s orders, r refreshes',
512 immediate: true,
513 })
514 } catch {
515 // the name is taken; nothing else to do
516 }
517 // Only while the pane is actually placed: an unplaced or closed pane spawns nothing.
518 $.clock.every(120_000, () => {
519 void isPaneOpen($).then(open => {
520 if (open) void refresh($)
521 })
522 })
523 return next(e)
524 })
525
526 // Open or close: the pane is a tab beside any other, /diff included, and
527 // the same command takes it down again.
528 on('command.run', { command: 'ready' }, async $ => {
529 if (await isPaneOpen($)) {
530 await $.ui.close({ id: PANE })
531 return {}
532 }
533 await refresh($)
534 // the whole ready set draws, so ask for the room; the body scrolls past what the layout spares
535 await $.ui.open({ id: PANE, title: 'ready', focus: true, closeOnEscape: true, rows: 28 })
536 return {}
537 })
538
539 // A change to the roadmap by any route redraws the pane while it is open.
540 on('tool.call', async ($, e, next) => {
541 const ran = await next(e)
542 if (e.agentId) return ran
543 const touched =
544 ((e.tool === 'Edit' || e.tool === 'Write') && /roadmaps\.json$/.test(e.file_path)) ||
545 (e.tool === 'Bash' && /roadmap\.py|roadmaps\.json/.test(e.command))
546 if (touched && (await isPaneOpen($))) await refresh($)
547 return ran
548 })
549
550 on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e, next) => {
551 if (e.surface !== 'terminal') return next(e)
552 const ui = $.ui.resolve(e)
553 const { Box, Text, Button, Input } = ui
554 const [snap, picked, ask, kept, isOrdering] = await Promise.all([read($, snapshot), read($, selected), read($, asking), read($, grouping), read($, ordering)])
555 if (!snap) return <Text dimColor>reading the roadmap…</Text>
556 const width = Math.max(40, e.props.bodyColumns)
557 if (!snap.ok) return emptyState($, ui, snap, width - 1)
558 // the header's frame and padding take four columns; every line inside it shares the measure
559 const inner = width - 5
560 const group = kept ?? DEFAULT_GROUPING
561 const groups = subgroup(snap.candidates, group.by, group.first)
562 // the digits follow the drawn order, so the subgroups a person puts first get 1 upwards
563 const ordered = groups.flatMap(g => g.members)
564 const pickedReady = ordered.find(c => c.id === picked) ?? null
565 const pickedInPlay = pickedReady ? null : (snap.claimed.find(c => c.id === picked) ?? null)
566 const current = pickedReady ?? pickedInPlay
567 // a task already in play is past claiming; it can only change hands
568 const claimable = pickedReady !== null
569 const asked = current && ask?.id === current.id ? ask : null
570 let index = 0
571 return (
572 <Box flexDirection="column" width={width} rowGap={1}>
573 {header(ui, snap, inner)}
574 <Box flexDirection="column" paddingX={1}>
575 {heading(ui, `Ready now · ${snap.candidates.length}`, inner)}
576 {ordered.length === 0 && <Text dimColor>nothing is ready. a blocker or a gate holds everything; /roadmap:review names it.</Text>}
577 <Box flexDirection="column" rowGap={1}>
578 {groups.map(g => (
579 <Box key={`group-${g.key}`} flexDirection="column" rowGap={1}>
580 {g.label !== '' && subheading(ui, g, group.by)}
581 {g.members.map(c => taskRow($, ui, c, index++, picked, inner))}
582 </Box>
583 ))}
584 </Box>
585 </Box>
586 {snap.claimed.length > 0 && (
587 <Box flexDirection="column" paddingX={1}>
588 {heading(ui, `In play · ${snap.claimed.length}`, inner)}
589 {claimedRows($, ui, snap.claimed, picked, inner)}
590 </Box>
591 )}
592 <Box flexDirection="column" paddingX={1}>
593 {ask === null && !isOrdering && (
594 <Box flexDirection="row" columnGap={2} flexWrap="wrap">
595 {current && claimable && (
596 <Button key="claim" label="claim" hotkey="c" variant="primary" onPress={() => update($, asking, () => ({ id: current.id, mode: 'claim' }))} />
597 )}
598 {current && <Button key="assign" label="assign" hotkey="a" onPress={() => update($, asking, () => ({ id: current.id, mode: 'assign' }))} />}
599 <Button key="group" label={`group: ${group.by}`} hotkey="g" onPress={() => saveGrouping($, { ...group, by: nextGroupBy(group.by) })} />
600 <Button key="order" label={group.first.length > 0 ? `first: ${group.first.join(', ')}` : 'first: natural'} hotkey="s" onPress={() => update($, ordering, () => true)} />
601 <Button key="refresh" label="refresh" hotkey="r" onPress={() => refresh($)} />
602 </Box>
603 )}
604 {isOrdering && (
605 <Input
606 key="first"
607 label="subgroups that lead, in order"
608 placeholder="names or ids, comma-separated; blank for the natural order"
609 value={group.first.join(', ')}
610 submitLabel="order"
611 autoFocus
612 onSubmit={async value => {
613 await saveGrouping($, { ...group, first: parseFirst(value) })
614 await update($, ordering, () => false)
615 }}
616 />
617 )}
618 {current && asked && (
619 <Input
620 key="assignee"
621 label={asked.mode === 'claim' ? `who is doing ${current.id}` : `who will do ${current.id}`}
622 placeholder={asked.mode === 'claim' ? 'a name; never inferred, never pre-filled' : 'a name, or blank to clear; never inferred'}
623 submitLabel={asked.mode}
624 autoFocus
625 onSubmit={async value => {
626 if (asked.mode === 'claim' && !value.trim()) {
627 $.ui.toast('a claim needs a name.')
628 return
629 }
630 $.ui.toast(asked.mode === 'claim' ? await claim($, current.id, value) : await assign($, current.id, value))
631 await update($, asking, () => null)
632 await refresh($)
633 }}
634 />
635 )}
636 <Text dimColor>1-9 pick (tab past nine) · q-p in play · c claim · a assign · g group by · s order · r refresh · esc or /ready closes</Text>
637 </Box>
638 </Box>
639 )
640 })
641}
642types/index.d.ts 82 lines1// The state contract for the roadmap plugin's pane mod: the pane draws from a
2// snapshot the CLI produced, the row the person picked, the task that is
3// waiting for an assignee and how this person groups the ready set.
4
5export type Candidate = {
6 id: string
7 description: string
8 milestone: string
9 milestoneName: string
10 milestoneDonePct: number
11 tier: number
12 tierLabel: string
13 transitiveUnblocks: number
14 isMilestoneSink: boolean
15 assignee: string
16}
17
18export type Claimed = {
19 id: string
20 description: string
21 assignee: string
22 started: string
23}
24
25export type Milestone = {
26 id: string
27 name: string
28 donePct: number
29 tier: number
30 tierLabel: string
31 state: string
32}
33
34/** The name the pane is waiting for: whose task, and whether the answer claims it or only assigns it. */
35export type Asking = {
36 id: string
37 mode: 'claim' | 'assign'
38}
39
40/** Why the pane has no roadmap to draw: none above the directory, the old single-file format, or a CLI that refused or could not run. */
41export type Problem = 'none' | 'missing' | 'legacy' | 'broken'
42
43/** What the ready set is split by: the assignee, the milestone, the release tier, or nothing. */
44export type GroupBy = 'dev' | 'milestone' | 'tier' | 'none'
45
46/**
47 * How this person likes the ready set split: the key it is grouped by and
48 * which subgroups lead, in order. Kept in the plugin's store, so each dev's
49 * own machine remembers it and Jaz's pane can lead with Jaz while Jason's
50 * leads with Jason.
51 */
52export type Grouping = {
53 by: GroupBy
54 first: string[]
55}
56
57export type Snapshot = {
58 ok: boolean
59 problem: Problem
60 reason: string
61 phase: string
62 donePct: number
63 doneCount: number
64 inScope: number
65 milestones: Milestone[]
66 candidates: Candidate[]
67 claimed: Claimed[]
68 at: number
69}
70
71declare module 'claude-code' {
72 interface PluginState {
73 'roadmap': {
74 snapshot: Snapshot | null
75 selected: string | null
76 asking: Asking | null
77 grouping: Grouping | null
78 ordering: boolean
79 }
80 }
81}
82