Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

feat(ruflo-console): the main menu gets an accent per group, key chips, live badges and a palette strip (ADR 430)

ruv26715daa5213
diff --git a/plugins/ruflo-console/hooks/menu-style.ts b/plugins/ruflo-console/hooks/menu-style.ts
new file mode 100644
index 0000000000..6adebf9df6
--- /dev/null
+++ b/plugins/ruflo-console/hooks/menu-style.ts
@@ -0,0 +1,65 @@
+/**
+ * The main menu's colours and live badges, pure (the menu that draws them is views/menu.ts). Each group has an accent: its border, a
+ * solid title bar and its key chips are drawn in it, the way a BBS menu set its sections apart. The colours are from the xterm
+ * 256-colour cube and grey ramp (so they render the same where a terminal has no truecolor, and in tmux), and the ink on an accent
+ * has contrast enough to read: tests/menu-style.spec.ts checks both. An entry also carries a badge when there is something to say
+ * about it (approvals waiting, a mission under way, findings, an update), from the same facts the band above the prompt reads; an
+ * entry with nothing to say gets none, never a zero.
+ */
+import { activeMission, progressOf } from './mission-control'
+import { alertsOf, approvalsOf } from './data/alerts'
+import { secMemo } from './secure'
+import type { State, ViewId } from './state'
+import { money } from './views/bar'
+
+/** The ink on an accent's solid bar, and the muted ink for a badge that is only information. */
+export const INK = '#1c1c1c'
+export const MUTED = '#8a8a8a'
+export const LOUD = '#ffaf00'
+
+/** One accent per menu group, by the group's title. */
+export const ACCENT: Readonly<Record<string, string>> = {
+ SWARM: '#ffaf00',
+ INTELLIGENCE: '#5fd7ff',
+ 'SAFETY & OPS': '#ff5f5f',
+ 'NETWORK & EXTEND': '#5fd75f',
+ TOOLS: '#d787ff',
+}
+
+/** The palette strip above the groups: the accents in menu order. */
+export const PALETTE: readonly string[] = ['#ffaf00', '#5fd7ff', '#ff5f5f', '#5fd75f', '#d787ff']
+
+export type Badge = { text: string; tone: 'attention' | 'plain' }
+
+/**
+ * What an entry of the menu has to say right now, by the page it opens. Only entries with something to say appear. Attention is for
+ * what needs a person (approvals, alerts, critical findings, an update); the rest is information.
+ */
+export function badgesOf(state: State, nowMs: number): Partial<Record<ViewId, Badge>> {
+ const out: Partial<Record<ViewId, Badge>> = {}
+ const snap = state.snapshot
+ const approvals = approvalsOf(state).length
+ const alerts = alertsOf(state, nowMs, state.loadedAtMs).filter(alert => alert.level !== 'info').length
+ const mission = activeMission(state)
+ const busy = snap?.agents.filter(agent => /busy|active|working/i.test(agent.status)).length ?? 0
+ const claims = snap?.claims.length ?? 0
+ const findings = secMemo(state).findings
+ const serious = findings === null ? 0 : findings.counts.critical + findings.counts.high
+
+ if (mission !== null && !mission.cancelled) {
+ const { done, total } = progressOf(mission, snap?.tasks ?? [])
+
+ if (total > 0 && done < total) out.missions = { text: `${done}/${total}`, tone: 'plain' }
+ }
+
+ if (approvals > 0) out.approvals = { text: String(approvals), tone: 'attention' }
+ if (alerts > 0) out.overview = { text: `⚠ ${alerts}`, tone: 'attention' }
+ if (busy > 0) out.swarm = { text: `β–Ά ${busy}`, tone: 'plain' }
+ if (claims > 0) out.claims = { text: String(claims), tone: 'plain' }
+ if (findings !== null && serious > 0) out.secure = { text: `πŸ”’ ${serious}`, tone: findings.counts.critical > 0 ? 'attention' : 'plain' }
+ if (state.usage?.costUsd !== undefined && state.usage.costUsd >= 0.01) out.cost = { text: money(state.usage.costUsd), tone: 'plain' }
+ if (state.terminal.runs.size > 0) out.terminal = { text: '●', tone: 'plain' }
+ if (state.updateAvailable !== '') out.settings = { text: `⬆ ${state.updateAvailable}`, tone: 'attention' }
+
+ return out
+}
diff --git a/plugins/ruflo-console/hooks/views/menu.ts b/plugins/ruflo-console/hooks/views/menu.ts
index a24b388f81..bb426a943c 100644
--- a/plugins/ruflo-console/hooks/views/menu.ts
+++ b/plugins/ruflo-console/hooks/views/menu.ts
@@ -1,5 +1,6 @@
import type { RenderElement } from 'claude-code'
+import { ACCENT, badgesOf, INK, LOUD, MUTED, PALETTE } from '../menu-style'
import { VIEWS, type ViewId } from '../state'
import { barParts } from './bar'
import { clip, col, isBbs, row, text, THEME, type Ctx } from './common'
@@ -16,7 +17,7 @@ const keyOf = (item: Item): string => COMMAND_KEYS[item.go] ?? VIEWS.find(view =
* commands. Keys are the pane's own hotkeys; an area without one (`Β·`) is reached by its name at the prompt. An
* entry for a view this build does not have is left out.
*/
-const GROUPS: readonly { title: string; sections: readonly { name: string; items: readonly Item[] }[] }[] = [
+export const GROUPS: readonly { title: string; sections: readonly { name: string; items: readonly Item[] }[] }[] = [
{
title: 'SWARM',
sections: [
@@ -83,17 +84,27 @@ export function menuView(ctx: Ctx): RenderElement {
rows.push(text(ctx, ' '))
rows.push(...missionStrip(ctx))
+ // In the BBS look each group is set apart by an accent: its border, a solid title bar and its key chips. The plain look keeps the theme's
+ // colours and has none of this. A badge says what is going on behind an entry (approvals waiting, a mission under way, findings, an update).
+ const bbs = isBbs()
+ const badges = badgesOf(state, nowMs)
+
// Each group a bordered box: β–“β–’β–‘ TITLE β–‘β–’β–“ on top, then its sub-sections, each a dim ── name ── rule and its items.
- const box = (group: (typeof GROUPS)[number]) =>
- ctx.kit.Box({
+ const box = (group: (typeof GROUPS)[number]) => {
+ const accent = ACCENT[group.title] ?? '#d0d0d0'
+ const title = clip(`β–“β–’β–‘ ${group.title} β–‘β–’β–“`, width - 4)
+
+ return ctx.kit.Box({
flexDirection: 'column',
width,
borderStyle: 'single',
- borderColor: isBbs() ? '#d0d0d0' : 'inactive',
+ borderColor: bbs ? accent : 'inactive',
paddingX: 1,
key: `menu-${group.title}`,
children: [
- ctx.kit.Text({ bold: true, color: THEME.head, wrap: 'truncate-end', children: clip(`β–“β–’β–‘ ${group.title} β–‘β–’β–“`, width - 4) }),
+ bbs
+ ? ctx.kit.Box({ backgroundColor: accent, key: `menu-bar-${group.title}`, children: [ctx.kit.Text({ bold: true, color: INK, wrap: 'truncate-end', children: ` ${title}`.padEnd(width - 2).slice(0, width - 2) })] })
+ : ctx.kit.Text({ bold: true, color: THEME.head, wrap: 'truncate-end', children: title }),
...group.sections.flatMap(section => {
const items = section.items.filter(isShown)
@@ -101,20 +112,29 @@ export function menuView(ctx: Ctx): RenderElement {
? []
: [
ctx.kit.Text({ color: THEME.info, dimColor: true, wrap: 'truncate-end', children: clip(`── ${section.name} ${'─'.repeat(Math.max(0, width - section.name.length - 8))}`, width - 4) }),
- ...items.map(item =>
- ctx.kit.Box({
+ ...items.map(item => {
+ const badge = badges[item.go as ViewId]
+ const key = keyOf(item)
+
+ return ctx.kit.Box({
flexDirection: 'row',
key: `mi-${item.go}`,
children: [
- ctx.kit.Text({ bold: true, color: THEME.ok, children: ` (${keyOf(item)})` }),
- ctx.kit.Button({ key: `menu-go-${item.go}`, label: clip(item.label, width - 9), plain: true, onPress: go(item) }),
+ // The key is a chip in the accent in the BBS look, so the keys read as the commands; plain, as it always was.
+ bbs ? ctx.kit.Text({ bold: true, color: INK, backgroundColor: accent, children: ` ${key} ` }) : ctx.kit.Text({ bold: true, color: THEME.ok, children: ` (${key})` }),
+ ctx.kit.Button({ key: `menu-go-${item.go}`, label: ` ${clip(item.label, width - 11 - (badge === undefined ? 0 : badge.text.length + 1))}`, plain: true, onPress: go(item) }),
+ ...(badge === undefined ? [] : [ctx.kit.Text({ bold: badge.tone === 'attention', color: bbs ? (badge.tone === 'attention' ? LOUD : MUTED) : badge.tone === 'attention' ? THEME.warn : THEME.info, children: ` ${badge.text}` })]),
],
- }),
- ),
+ })
+ }),
]
}),
],
})
+ }
+
+ // A strip of the accents across the top, as a BBS drew its palette: one block of each, the width of the pane shared between them.
+ if (bbs) rows.push(ctx.kit.Box({ flexDirection: 'row', key: 'menu-palette', children: PALETTE.map((color, i) => ctx.kit.Text({ color, children: 'β–€'.repeat(Math.max(1, Math.floor((ctx.columns - 2) / PALETTE.length))), key: `menu-palette-${i}` })) }))
for (let i = 0; i < GROUPS.length; i += perRow) {
rows.push(ctx.kit.Box({ flexDirection: 'row', gap: 1, key: `menu-row-${i}`, children: GROUPS.slice(i, i + perRow).map(box) }))
@@ -131,10 +151,10 @@ export function menuView(ctx: Ctx): RenderElement {
rows.push(
ctx.kit.Box({
flexDirection: 'row',
- backgroundColor: isBbs() ? '#8b1a1a' : undefined,
+ backgroundColor: isBbs() ? '#870000' : undefined,
key: 'menu-status',
children: [
- ctx.kit.Text({ bold: true, color: '#ffd319', children: line }),
+ ctx.kit.Text({ bold: true, color: '#ffd700', children: line }),
// The live facts are links: a click goes to the view each is about.
...facts.flatMap((part, i) => {
if (room <= 6) return []
@@ -144,14 +164,14 @@ export function menuView(ctx: Ctx): RenderElement {
room -= label.length + 3
return [
- ctx.kit.Text({ bold: true, color: '#ffd319', children: ' β”‚ ' }),
+ ctx.kit.Text({ bold: true, color: '#ffd700', children: ' β”‚ ' }),
part.go !== undefined
? ctx.kit.Button({ key: `status-${i}`, label, plain: true, onPress: () => ctx.act.view(part.go as ViewId) })
- : ctx.kit.Text({ bold: true, color: '#ffd319', children: label }),
+ : ctx.kit.Text({ bold: true, color: '#ffd700', children: label }),
]
}),
ctx.kit.Box({ flexGrow: 1, key: 'status-gap', children: [ctx.kit.Text({ children: ' ' })] }),
- ctx.kit.Text({ bold: true, color: '#ffd319', children: right }),
+ ctx.kit.Text({ bold: true, color: '#ffd700', children: right }),
],
}),
)
diff --git a/plugins/ruflo-console/tests/menu-style.spec.ts b/plugins/ruflo-console/tests/menu-style.spec.ts
new file mode 100644
index 0000000000..28d080c183
--- /dev/null
+++ b/plugins/ruflo-console/tests/menu-style.spec.ts
@@ -0,0 +1,130 @@
+/**
+ * The main menu's colours and badges, pure: every group has an accent, every colour is one the 256-colour palette has (so it renders the
+ * same without truecolor and in tmux), the ink on an accent can be read, and an entry has a badge only when there is something to say.
+ * Run with
+ * npx vitest run plugins/ruflo-console/tests/menu-style.spec.ts
+ */
+import { describe, expect, it } from 'vitest'
+
+import type { ReadCache } from '../hooks/data/files'
+import { readSnapshot } from '../hooks/data/snapshot'
+import { ACCENT, badgesOf, INK, LOUD, MUTED, PALETTE } from '../hooks/menu-style'
+import { secMemo } from '../hooks/secure'
+import { newState, VIEWS } from '../hooks/state'
+import { GROUPS } from '../hooks/views/menu'
+import { RUFLO_FILES } from './fixtures/ruflo-run'
+
+const CUBE = [0, 95, 135, 175, 215, 255]
+const channels = (hex: string): [number, number, number] => [1, 3, 5].map(i => Number.parseInt(hex.slice(i, i + 2), 16)) as [number, number, number]
+/** Is this colour one the xterm 256 palette has: a step of the 6x6x6 cube on each channel, or a grey of the ramp (8 to 238 in tens)? */
+const isXterm256 = (hex: string): boolean => {
+ const [r, g, b] = channels(hex)
+
+ return (CUBE.includes(r) && CUBE.includes(g) && CUBE.includes(b)) || (r === g && g === b && r >= 8 && r <= 238 && (r - 8) % 10 === 0)
+}
+const luminance = (hex: string): number => {
+ const [r, g, b] = channels(hex).map(value => {
+ const unit = value / 255
+
+ return unit <= 0.03928 ? unit / 12.92 : ((unit + 0.055) / 1.055) ** 2.4
+ }) as [number, number, number]
+
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b
+}
+/** WCAG contrast ratio: 4.5 is the floor for text a person has to read. */
+const contrast = (a: string, b: string): number => {
+ const [light, dark] = [luminance(a), luminance(b)].sort((x, y) => y - x) as [number, number]
+
+ return (light + 0.05) / (dark + 0.05)
+}
+
+describe('the menu accents', () => {
+ it('gives every group an accent, and no accent to a group that is not there', () => {
+ expect(GROUPS.map(group => group.title).sort()).toEqual(Object.keys(ACCENT).sort())
+ })
+
+ it('draws the palette strip in the accents, in the menu order', () => {
+ expect(PALETTE).toEqual(GROUPS.map(group => ACCENT[group.title]))
+ })
+
+ it('uses only colours the 256-colour palette has, so they render the same without truecolor and in tmux', () => {
+ for (const color of [...Object.values(ACCENT), ...PALETTE, INK, MUTED, LOUD]) expect(isXterm256(color), color).toBe(true)
+ })
+
+ it('has ink on every accent that can be read (contrast 4.5 or more), and no two groups share a colour', () => {
+ for (const [group, color] of Object.entries(ACCENT)) expect(contrast(INK, color), group).toBeGreaterThanOrEqual(4.5)
+ expect(new Set(Object.values(ACCENT)).size).toBe(Object.keys(ACCENT).length)
+ })
+
+ it('knows its own checks: a colour off the palette fails, and so does ink that cannot be read', () => {
+ expect(isXterm256('#8b1a1a')).toBe(false)
+ expect(isXterm256('#ffaf01')).toBe(false)
+ expect(contrast('#d0d0d0', '#ffffff')).toBeLessThan(4.5)
+ })
+})
+
+const memoryFs = (files: Record<string, string>) => ({
+ read: async (path: string) => files[path] ?? Promise.reject(new Error('ENOENT')),
+ stat: async (path: string) => (files[path] !== undefined ? { mtimeMs: 1, size: (files[path] as string).length } : Promise.reject(new Error('ENOENT'))),
+ list: async () => Promise.reject(new Error('ENOENT')),
+})
+
+async function projectState() {
+ const files = {
+ ...Object.fromEntries(Object.entries(RUFLO_FILES).map(([path, text]) => [`/work/${path}`, text])),
+ '/home/dev/.claude/plugins/known_marketplaces.json': JSON.stringify({ ruflo: { installLocation: '/home/dev/m/ruflo' } }),
+ '/home/dev/m/ruflo/.claude-plugin/marketplace.json': JSON.stringify({ plugins: [{ name: 'ruflo-core' }, { name: 'ruflo-swarm' }] }),
+ }
+ const state = newState({})
+
+ state.snapshot = await readSnapshot(memoryFs(files), new Map() as ReadCache, '/work', '/home/dev', {}, 0)
+
+ return state
+}
+
+describe('the menu badges', () => {
+ it('has none when there is nothing to say: no zero, no empty word', () => {
+ expect(badgesOf(newState({}), 0)).toEqual({})
+ })
+
+ it('names approvals waiting and alerts as attention, and claims as information, on the pages they open', async () => {
+ const state = await projectState()
+ const badges = badgesOf(state, 0)
+
+ expect(badges.approvals).toEqual({ text: '2', tone: 'attention' })
+ expect(badges.overview).toEqual({ text: '⚠ 1', tone: 'attention' })
+ expect(badges.claims).toMatchObject({ tone: 'plain' })
+ expect(Number(badges.claims?.text)).toBeGreaterThan(0)
+ })
+
+ it('shows spend only from a cent, findings only when high or critical (loud only for critical), a running terminal, and an update not yet taken', () => {
+ const state = newState({})
+
+ state.usage = { costUsd: 0.004 }
+ expect(badgesOf(state, 0).cost).toBeUndefined()
+ state.usage = { costUsd: 19.81 }
+ expect(badgesOf(state, 0).cost).toEqual({ text: '$19.81', tone: 'plain' })
+
+ secMemo(state).findings = { source: 'scan', counts: { critical: 0, high: 235, medium: 60, low: 0 }, atMs: 0 }
+ expect(badgesOf(state, 0).secure).toEqual({ text: 'πŸ”’ 235', tone: 'plain' })
+ secMemo(state).findings = { source: 'scan', counts: { critical: 1, high: 2, medium: 0, low: 0 }, atMs: 0 }
+ expect(badgesOf(state, 0).secure).toEqual({ text: 'πŸ”’ 3', tone: 'attention' })
+ secMemo(state).findings = { source: 'scan', counts: { critical: 0, high: 0, medium: 9, low: 0 }, atMs: 0 }
+ expect(badgesOf(state, 0).secure).toBeUndefined()
+
+ state.terminal.runs.set('codex', { label: 'codex', startedAtMs: 0, stop: () => undefined })
+ expect(badgesOf(state, 0).terminal).toEqual({ text: '●', tone: 'plain' })
+
+ state.updateAvailable = '0.27.0'
+ expect(badgesOf(state, 0).settings).toEqual({ text: '⬆ 0.27.0', tone: 'attention' })
+ })
+
+ it('only badges pages that exist', async () => {
+ const state = await projectState()
+
+ state.usage = { costUsd: 5 }
+ state.updateAvailable = '0.27.0'
+ state.terminal.runs.set('codex', { label: 'codex', startedAtMs: 0, stop: () => undefined })
+ for (const view of Object.keys(badgesOf(state, 0))) expect(VIEWS.some(entry => entry.id === view), view).toBe(true)
+ })
+})
diff --git a/v3/docs/adr/ADR-430-console-main-menu-accents-chips-and-badges.md b/v3/docs/adr/ADR-430-console-main-menu-accents-chips-and-badges.md
new file mode 100644
index 0000000000..af0e3229ea
--- /dev/null
+++ b/v3/docs/adr/ADR-430-console-main-menu-accents-chips-and-badges.md
@@ -0,0 +1,47 @@
+# ADR 430: The main menu: an accent for each group, key chips, live badges and a palette strip
+
+Status: Accepted (ships in ruflo-console 0.26.0)
+
+Date: 2026 10 03
+
+Decision owner: Ruflo maintainers
+
+Scope: `plugins/ruflo-console`: `hooks/menu-style.ts` (new, pure), `hooks/views/menu.ts` (`GROUPS` exported; the group box, the key, the badge, the strip), `tests/menu-style.spec.ts` (new).
+
+Extends: ADR 407 (the BBS look and its Main Menu), ADR 429 (the band, whose facts the badges share).
+
+## 1. Context
+
+The Main Menu is the first screen in the BBS look: five bordered groups, each a title, short sub-sections, and entries as a key and a button, under the mission strip and a red status bar. Every group was drawn the same, in one grey border and the one title colour, so the eye had nothing to find a group by, the keys (the fastest way in) looked like part of the label, and nothing on the menu said where anything was going on: approvals waiting, a mission under way and 235 high findings looked the same as an empty project.
+
+## 2. Decision
+
+In the BBS look:
+
+- **An accent for each group.** Its border, a solid title bar (dark ink on the accent) and its key chips are in it: SWARM amber, INTELLIGENCE cyan, SAFETY & OPS red, NETWORK & EXTEND green, TOOLS violet.
+- **Key chips.** The key of an entry is a solid chip in the group's accent, ` 1 `, instead of `(1)` in the label colour, so the keys read as the commands they are.
+- **A palette strip** of the five accents across the top, as a BBS drew its palette.
+- **Badges, in both looks.** An entry carries a short badge when there is something to say about the page it opens: approvals waiting (loud), alerts (`⚠ n`, loud), the mission's progress (`3/15`), busy agents (`β–Ά n`), claims, high or critical findings (`πŸ”’ n`, loud only when one is critical), spend from a cent, a running terminal, an update not yet taken (`⬆ 0.27.0`, loud). They come from the facts the band above the prompt reads, so the two cannot disagree, and an entry with nothing to say gets none, never a zero.
+
+The plain look keeps the theme's colours, with no accents, chips, strip or title bars, and gets the badges in the theme's warn and info colours.
+
+Nothing moves: every part is static, so `fps: 0` and a terminal that redraws slowly lose nothing.
+
+## 3. Colours
+
+Every colour this adds is a step of the xterm 256-colour cube or its grey ramp, so it renders the same where a terminal has no truecolor, and in tmux (the console's Rasters render in 256 colours there). The ink on an accent is `#1c1c1c`; the spec holds its contrast to 4.5 against each of the five, which is the WCAG floor for text a person must read. The status bar's two colours, which were off the palette (`#8b1a1a` and `#ffd319`), moved to the nearest steps (`#870000`, `#ffd700`).
+
+## 4. Alternatives considered
+
+- **A cursor that moves over the entries with the arrow keys, the selected row filled.** Not done: it is a change in how the menu takes keys, with its own state and tests, and the keys already reach every page. It is the next thing to try, not part of this.
+- **A gradient across the title bars.** Rejected: a Text takes one colour, so a gradient is a run of Texts per bar, for a small gain over a solid bar, and it breaks when the width changes.
+- **Theme colour names for the accents.** Rejected: a theme can make them near each other, and an unknown name can make the host refuse the tree (ADR 429). The palette's own hexes are the same on every theme.
+- **Showing a zero for an empty badge.** Rejected, as on the band: a part with nothing to say is left out.
+
+## 5. What this does not prove
+
+It has not been seen. The spec holds the colours, the contrast and what a badge says; the layout is in the kit tests (which need the `claude-code/testing` host package and run in CI) and the real screen. Two things to look at first: a group's title bar and chips against a **light** terminal background (the bar and chips carry their own ground, but a badge and the sub-section rules are drawn on the terminal's), and the width of the longest entry with its badge at the narrowest two-column pane.
+
+## 6. Tests
+
+`tests/menu-style.spec.ts` (9): every group has an accent and no accent is without a group; the palette is the accents in menu order; every colour is on the 256 palette; the ink on each accent has contrast 4.5 or more and no two groups share a colour; the spec's own checks fail on a colour off the palette and on ink that cannot be read; an empty state has no badges; approvals and alerts are loud and claims are information on the pages they open; spend shows only from a cent, findings only when high or critical (loud only for critical), a running terminal, and an update not yet taken; and only pages that exist are badged.