An optional /mods menu that lists the installed mods (status line, clean screen, mode, permissions, tree-explained) and opens each one's page in a pane.

An optional /mods menu. It opens a small pane that lists the mods you have installed from this collection (status line, clean screen, mode, permissions, tree-explained), each with a one-line summary. Pick one to open its settings page; "back" returns to the list.
◆ mods button sits in the footer under the prompt (the status line draws it when it is on).1 to 5 open the rows; b goes back; esc closes.Install:
/plugin install menu@malka-claude-mods
Use: /mods, or /mods statusline, /mods cleanscreen, /mods mode, /mods permissions, /mods tree-explained to open straight on a page.
Uninstall: /plugin uninstall menu@malka-claude-mods. The other mods keep working; they simply stop showing the ◆ mods button.
Known limits: the open/closed state is kept in memory, so a hot reload can leave it out of step with the pane; if the menu is disabled mid-session, the other mods still think it is present until you restart.
Um menu /mods opcional. Abre um painel pequeno que lista os mods desta coleção que você instalou (status line, clean screen, mode, permissions, tree-explained), cada um com um resumo de uma linha. Escolha um para abrir a página de configurações; "back" volta à lista.
◆ mods fica no rodapé, sob o prompt (a status line o desenha quando está ligada).1 a 5 abrem as linhas; b volta; esc fecha.Instalar:
/plugin install menu@malka-claude-mods
Usar: /mods, ou /mods statusline, /mods cleanscreen, /mods mode, /mods permissions, /mods tree-explained para abrir direto numa página.
Desinstalar: /plugin uninstall menu@malka-claude-mods. Os outros mods continuam funcionando; só deixam de mostrar o botão ◆ mods.
Limites conhecidos: o estado aberto/fechado fica em memória, então um hot reload pode deixá-lo fora de sincronia com o painel; se o menu for desativado no meio da sessão, os outros mods ainda o veem como presente até reiniciar.
hooks/register.tsx 178 lines1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type {} from '../types/statusline'
5import type {} from '../types/cleanscreen'
6import type {} from '../types/mode'
7import type {} from '../types/permissions'
8import type {} from '../types/tree-explained'
9
10const panelAtom = atom({ plugin: 'menu', key: 'panel' } as const, 'main')
11const presentAtom = atom({ plugin: 'menu', key: 'present' } as const, false)
12
13// Members known statically (state refs must be source literals). Each publishes `menuEntry` (apiVersion 1).
14const statuslineEntry = { plugin: 'statusline', key: 'menuEntry' } as const
15const cleanscreenEntry = { plugin: 'cleanscreen', key: 'menuEntry' } as const
16const modeEntry = { plugin: 'mode', key: 'menuEntry' } as const
17const permissionsEntry = { plugin: 'permissions', key: 'menuEntry' } as const
18const treeEntry = { plugin: 'tree-explained', key: 'menuEntry' } as const
19
20const PANE = 'mods-menu'
21const NAMES = ['statusline', 'cleanscreen', 'mode', 'permissions', 'tree-explained']
22
23type Row = { name: string; title: string; summary: string; order: number }
24
25// The installed members' entries: missing, malformed or another apiVersion are skipped; sorted by `order`.
26async function entries($: EngineInterface): Promise<Row[]> {
27 const none = () => ({ value: undefined })
28 const found = [
29 (await $.state.get(statuslineEntry).catch(none)).value,
30 (await $.state.get(cleanscreenEntry).catch(none)).value,
31 (await $.state.get(modeEntry).catch(none)).value,
32 (await $.state.get(permissionsEntry).catch(none)).value,
33 (await $.state.get(treeEntry).catch(none)).value,
34 ]
35 const rows: Row[] = []
36 found.forEach((v, i) => {
37 if (v && v.apiVersion === 1 && typeof v.title === 'string') rows.push({ name: NAMES[i]!, title: v.title, summary: String(v.summary), order: Number(v.order) || 0 })
38 })
39 return rows.sort((a, b) => a.order - b.order)
40}
41
42// The engine's hint on one row: it can carry a second line holding only a separator, which drew as a stray dot.
43const hintText = (hint: string) =>
44 hint
45 .split(/\r?\n/)
46 .map(line => line.trim())
47 .filter(line => /[\p{L}\p{N}]/u.test(line))
48 .join(' · ')
49
50let isOpen = false
51
52async function toggle($: EngineInterface, panel = 'main') {
53 if (isOpen) {
54 isOpen = false
55 await $.ui.close({ id: PANE })
56 return
57 }
58 await update($, panelAtom, () => panel)
59 isOpen = true
60 await $.ui.open({ id: PANE, title: 'mods', focus: true, closeOnEscape: true, rows: 16, columns: 56 })
61}
62
63const goTo = ($: EngineInterface, panel: string) => update($, panelAtom, () => panel)
64
65// A member page only when its entry is present now; otherwise main, with a toast.
66async function goToMember($: EngineInterface, name: string) {
67 if ((await entries($)).some(r => r.name === name)) return goTo($, name)
68 $.ui.toast(`${name} is not installed`)
69 return goTo($, 'main')
70}
71
72async function back($: EngineInterface, e: any, next: any) {
73 await goTo($, 'main')
74 return next(e)
75}
76
77function mainPage({ Box, Text, Button }: { Box: any; Text: any; Button: any }, rows: Row[], onOpen: (name: string) => unknown) {
78 return (
79 <Box flexDirection="column" paddingX={1}>
80 <Text bold color="claude">
81 ◆ mods
82 </Text>
83 {rows.length === 0 && (
84 <Box flexDirection="column" marginTop={1}>
85 <Text>No mods installed</Text>
86 <Text dimColor>Install one with /plugin install statusline@malka-claude-mods</Text>
87 <Text dimColor>(also cleanscreen, mode, permissions or tree-explained).</Text>
88 </Box>
89 )}
90 {rows.map((r, i) => (
91 <Box key={`row-${r.name}`} flexDirection="column" marginTop={1}>
92 <Button
93 key={`open-${r.name}`}
94 plain
95 hotkey={String(i + 1)}
96 autoFocus={i === 0 ? true : undefined}
97 label={`${r.title} ›`}
98 onPress={() => onOpen(r.name)}
99 />
100 <Text dimColor> {r.summary}</Text>
101 </Box>
102 ))}
103 <Box marginTop={1}>
104 <Text dimColor>↑↓ move · enter select · esc close</Text>
105 </Box>
106 </Box>
107 )
108}
109
110export const register: Register = on => {
111 on('session.start', async ($, e, next) => {
112 await update($, presentAtom, () => true)
113 await update($, panelAtom, () => 'main')
114 isOpen = false
115 await $.command
116 .register({ name: 'mods', description: 'Open the mods menu', argumentHint: '[statusline|cleanscreen|mode|permissions|tree-explained]', immediate: true })
117 .catch(() => undefined)
118 return next(e)
119 })
120
121 on('command.run', { command: 'mods' }, async ($, e) => {
122 try {
123 const arg = e.args.trim().toLowerCase()
124 const known = NAMES.includes(arg)
125 const panel = known && (await entries($)).some(r => r.name === arg) ? arg : 'main'
126 if (known && panel === 'main') $.ui.toast(`${arg} is not installed`)
127 if (isOpen) await goTo($, panel)
128 else await toggle($, panel)
129 return { text: 'The mods menu is open.' }
130 } catch (error) {
131 return { text: `The mods menu could not open: ${String(error)}` }
132 }
133 })
134
135 // Main page only: a member draws its own page when the panel is its name (the hooks beneath).
136 on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e, next) => {
137 const rows = await entries($)
138 const panel = await read($, panelAtom)
139 // a member page whose entry is gone falls back to main
140 if (panel !== 'main' && rows.some(r => r.name === panel)) return next(e)
141 return mainPage($.ui.resolve(e), rows, name => goToMember($, name))
142 })
143
144 // However the pane closes (esc, its mark, the footer button), the menu resets.
145 on('ui.close', { id: PANE }, async ($, e, next) => {
146 isOpen = false
147 await update($, panelAtom, () => 'main').catch(() => undefined)
148 return next(e)
149 }).catch(() => undefined)
150
151 on('ui.press', { plugin: 'statusline', element: 'mods-back' }, back)
152 on('ui.press', { plugin: 'cleanscreen', element: 'mods-back' }, back)
153 on('ui.press', { plugin: 'mode', element: 'mods-back' }, back)
154 on('ui.press', { plugin: 'permissions', element: 'mods-back' }, back)
155 on('ui.press', { plugin: 'tree-explained', element: 'mods-back' }, back)
156
157 on('ui.press', { plugin: 'statusline', element: 'mods-open' }, async ($, e, next) => {
158 await toggle($)
159 return next(e)
160 })
161
162 // Footer, disjoint with the status line: when it is on, the engine's hint row stays as is and the status band
163 // (above the prompt) draws the ◆ mods button; when it is off, this row and button are drawn here.
164 on('ui.render', { component: 'PromptHint' }, async ($, e, next) => {
165 const { value } = await $.state.get(statuslineEntry).catch(() => ({ value: undefined }))
166 if (value?.summary === 'on') return next(e)
167 const { Box, Text, Button } = $.ui.resolve(e)
168 return (
169 <Box justifyContent="space-between" flexGrow={1} gap={1}>
170 <Text dimColor wrap="truncate">
171 {hintText(e.props.hint)}
172 </Text>
173 <Button key="mods-open" plain label="◆ mods" onPress={() => toggle($)} />
174 </Box>
175 )
176 })
177}
178types/index.d.ts 13 lines1// Menu contract, apiVersion 1.
2export type Panel = string
3declare module 'claude-code' {
4 interface PluginState {
5 menu: {
6 // 'main' or the name of the member whose page the pane shows
7 panel: Panel
8 // true while this mod is loaded (set at session.start)
9 present: boolean
10 }
11 }
12}
13