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 band leads with what is happening now; the main menu in four boxed groups with sub-sections

ruve847fc27f39b
diff --git a/plugins/ruflo-console/hooks/views/bar.ts b/plugins/ruflo-console/hooks/views/bar.ts
index 76d1ab82df..719ca9cc8b 100644
--- a/plugins/ruflo-console/hooks/views/bar.ts
+++ b/plugins/ruflo-console/hooks/views/bar.ts
@@ -1,32 +1,45 @@
/**
- * The band above the prompt: one row naming what ruflo is doing here, with a mark that pulses while Claude works.
+ * The band above the prompt: one row saying what is happening here now, with a mark that pulses while Claude works.
+ * Parts come most-urgent first, so a narrow band truncates the least useful ones: what needs a person, who is
+ * working on what (and for how long), the AI terminal's runs, the newest event while it is fresh; only then the
+ * standing context (claims, this session's spend). With nothing happening it says so, and when it last did.
* Each part is a fact on disk or n/a; a part with nothing to say is left out rather than shown as zero.
- * Parts come most-important first, so a narrow band truncates the least useful ones: what needs a person,
- * then the swarm, this session's spend, claims, the router's last pick, and what was learned since load.
*/
import type { RenderElement } from 'claude-code'
import { alertsOf, approvalsOf } from '../data/alerts'
+import { agentLabels } from '../data/parse'
import type { State } from '../state'
-import { clip, count, type Kit } from './common'
+import { ago, clip, type Kit } from './common'
export const BAR_KEY = 'mark'
-export type BarPart = { text: string; tone: 'attention' | 'plain' }
+export type BarPart = { text: string; tone: 'attention' | 'live' | 'plain' }
-/** The swarm in words: how many agents and how many are working, never "0/0". */
-function swarmText(state: State): string | null {
+/** How long an event counts as "now" on the band. */
+const FRESH_MS = 60_000
+
+const since = (atMs: number | undefined, nowMs: number): string => (atMs === undefined ? '' : ` ${ago(atMs, nowMs).replace(' ago', '')}`)
+
+/** Who is working, each on what: the agent's in-progress task, or just "working". At most two, then a count. */
+function workingParts(state: State, nowMs: number): BarPart[] {
const snap = state.snapshot
- if (snap?.swarm == null) return null
+ if (snap === null) return []
- const total = snap.swarm.agentIds.length || snap.agents.length
+ const busy = snap.agents.filter(agent => /busy|active|working/i.test(agent.status))
+ const labels = agentLabels(snap.agents)
+ const parts = busy.slice(0, 2).map(agent => {
+ const task = snap.tasks.find(entry => entry.assignedTo.includes(agent.id) && /progress|running|active/i.test(entry.status))
+ const what = task !== undefined ? ` on ${clip(task.description || task.type, 40)}` : ' working'
+ const span = state.statusLog.get(agent.id)?.at(-1)?.atMs
- if (total === 0) return 'swarm, no agents'
+ return { text: `â–¶ ${labels.get(agent.id) ?? agent.type}${what}${since(span, nowMs)}`, tone: 'live' as const }
+ })
- const busy = snap.agents.filter(agent => /busy|active/i.test(agent.status)).length
+ if (busy.length > 2) parts.push({ text: `+${busy.length - 2} more working`, tone: 'live' })
- return busy === 0 ? `${total} agent${total === 1 ? '' : 's'} idle` : `${busy}/${total} agents busy`
+ return parts
}
/** Dollars a person reads at a glance: cents under $100, whole dollars with separators above. */
@@ -45,11 +58,24 @@ export function barParts(state: State, nowMs: number = Date.now()): BarPart[] {
if (approvals > 0) parts.push({ text: `${approvals} to approve (q)`, tone: 'attention' })
if (alerts > 0) parts.push({ text: `âš  ${alerts} alert${alerts === 1 ? '' : 's'}`, tone: 'attention' })
- const swarm = swarmText(state)
+ // What is happening now: agents at work, the AI terminal's runs, and the newest event while it is fresh.
+ parts.push(...workingParts(state, nowMs))
- if (swarm !== null) parts.push({ text: swarm, tone: 'plain' })
- if (state.usage?.costUsd !== undefined && state.usage.costUsd >= 0.01) parts.push({ text: `${money(state.usage.costUsd)} this session`, tone: 'plain' })
+ for (const [agent, run] of state.terminal.runs) parts.push({ text: `💻 ${agent} answering${since(run.startedAtMs, nowMs)}`, tone: 'live' })
+
+ const latest = state.events.at(-1)
+ const isFresh = latest !== undefined && nowMs - latest.atMs < FRESH_MS
+
+ if (isFresh) parts.push({ text: `${clip(latest.text, 44)} ·${since(latest.atMs, nowMs)} ago`, tone: 'plain' })
+
+ // Nothing moving: say so, with how many agents stand ready and when something last happened.
+ if (!parts.some(part => part.tone === 'live') && !isFresh && snap?.swarm != null) {
+ const ready = snap.agents.length
+ parts.push({ text: `${ready > 0 ? `idle · ${ready} agent${ready === 1 ? '' : 's'} ready` : 'swarm, no agents'}${latest !== undefined ? ` · last activity${since(latest.atMs, nowMs)} ago` : ''}`, tone: 'plain' })
+ }
+
+ // Standing context last: claims held, this session's spend.
const claims = snap?.claims ?? []
if (claims.length > 0) {
@@ -58,16 +84,7 @@ export function barParts(state: State, nowMs: number = Date.now()): BarPart[] {
parts.push({ text: `${claims.length} claim${claims.length === 1 ? '' : 's'}${stealable > 0 ? ` (${stealable} stealable)` : ''}`, tone: 'plain' })
}
- if (state.ruflo.route !== null) parts.push({ text: `routed → ${state.ruflo.route.agent}`, tone: 'plain' })
-
- // Learning shows as growth since the console loaded; the running total lives in the Learning view (6).
- const patterns = state.history.patterns
-
- if (patterns.length > 1) {
- const learned = (patterns[patterns.length - 1] as { value: number }).value - (patterns[0] as { value: number }).value
-
- if (learned > 0) parts.push({ text: `+${count(learned)} learned`, tone: 'plain' })
- }
+ if (state.usage?.costUsd !== undefined && state.usage.costUsd >= 0.01) parts.push({ text: `${money(state.usage.costUsd)} this session`, tone: 'plain' })
return parts
}
@@ -89,7 +106,7 @@ export function barView(kit: Kit, state: State, columns: number, mark: RenderEle
const words = ` · ${part.text}`
if (room <= 3) break
- children.push(kit.Text({ wrap: 'truncate-end', ...(part.tone === 'attention' ? { color: 'warning' } : { dimColor: true }), children: clip(words, room) }))
+ children.push(kit.Text({ wrap: 'truncate-end', ...(part.tone === 'attention' ? { color: 'warning' } : part.tone === 'live' ? { color: 'success' } : { dimColor: true }), children: clip(words, room) }))
room -= words.length
}
diff --git a/plugins/ruflo-console/hooks/views/menu.ts b/plugins/ruflo-console/hooks/views/menu.ts
index a277468150..ef4041805c 100644
--- a/plugins/ruflo-console/hooks/views/menu.ts
+++ b/plugins/ruflo-console/hooks/views/menu.ts
@@ -1,48 +1,51 @@
import type { RenderElement } from 'claude-code'
-import type { ViewId } from '../state'
+import { VIEWS, type ViewId } from '../state'
import { barParts } from './bar'
import { clip, col, isBbs, row, text, THEME, type Ctx } from './common'
-type Item = { key: string; label: string; go: ViewId | 'palette' | 'help' | 'close' }
+type Item = { key: string; label: string; go: string }
-/** The board's three menus, as the old BBS main menus grouped their commands. Keys are the pane's own hotkeys. */
-const MENUS: readonly { title: string; items: readonly Item[] }[] = [
+/**
+ * The board's menus: four groups, each split into short sub-sections, the way the old BBS main menus grouped their
+ * 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[] }[] }[] = [
+ {
+ title: 'SWARM',
+ sections: [
+ { name: 'live', items: [{ key: '1', label: 'Overview', go: 'overview' }, { key: '2', label: 'Swarm Topology', go: 'swarm' }, { key: '·', label: 'Hive-Mind', go: 'hive' }] },
+ { name: 'work', items: [{ key: '3', label: 'Claims Board', go: 'claims' }, { key: 'm', label: 'Missions', go: 'missions' }, { key: 'q', label: 'Approvals', go: 'approvals' }] },
+ { name: 'watch', items: [{ key: 'g', label: 'Agent Timeline', go: 'timeline' }, { key: 'e', label: 'Event Stream', go: 'events' }] },
+ ],
+ },
{
- title: 'Swarm Commands',
- items: [
- { key: '1', label: 'Overview', go: 'overview' },
- { key: '2', label: 'Swarm Topology', go: 'swarm' },
- { key: '3', label: 'Claims Board', go: 'claims' },
- { key: 'q', label: 'Approvals', go: 'approvals' },
- { key: 'm', label: 'Missions', go: 'missions' },
- { key: 'g', label: 'Agent Timeline', go: 'timeline' },
- { key: 'e', label: 'Event Stream', go: 'events' },
+ title: 'INTELLIGENCE',
+ sections: [
+ { name: 'learn', items: [{ key: '6', label: 'Learning', go: 'learning' }, { key: '7', label: 'MetaHarness', go: 'metaharness' }] },
+ { name: 'remember', items: [{ key: '8', label: 'Memory Base', go: 'memory' }] },
+ { name: 'spend', items: [{ key: '9', label: 'Cost & Budget', go: 'cost' }] },
],
},
{
- title: 'System Features',
- items: [
- { key: '4', label: 'Federation', go: 'federation' },
- { key: '5', label: 'Plugins & Mods', go: 'plugins' },
- { key: '6', label: 'Learning', go: 'learning' },
- { key: '7', label: 'MetaHarness', go: 'metaharness' },
- { key: '8', label: 'Memory Base', go: 'memory' },
- { key: '9', label: 'Cost & Budget', go: 'cost' },
+ title: 'NETWORK & EXTEND',
+ sections: [
+ { name: 'federate', items: [{ key: '4', label: 'Federation', go: 'federation' }, { key: 'w', label: 'x.ruv.io Board', go: 'xruv' }] },
+ { name: 'extend', items: [{ key: '5', label: 'Plugins & Mods', go: 'plugins' }, { key: '·', label: 'Skills', go: 'skills' }] },
],
},
{
- title: 'Other Commands',
- items: [
- { key: 'w', label: 'x.ruv.io Board', go: 'xruv' },
- { key: 'i', label: 'Terminal', go: 'terminal' },
- { key: 'p', label: 'Command Palette', go: 'palette' },
- { key: 'h', label: 'Help', go: 'help' },
- { key: 'O', label: 'Log Off', go: 'close' },
+ title: 'TOOLS',
+ sections: [
+ { name: 'run', items: [{ key: 'i', label: 'AI Terminal', go: 'terminal' }, { key: 'p', label: 'Command Palette', go: 'palette' }] },
+ { name: 'session', items: [{ key: 'h', label: 'Help', go: 'help' }, { key: 'O', label: 'Log Off', go: 'close' }] },
],
},
]
+const COMMANDS = new Set(['palette', 'help', 'close'])
+
const mmss = (ms: number): string => {
const s = Math.max(0, Math.floor(ms / 1000))
@@ -51,14 +54,17 @@ const mmss = (ms: number): string => {
/**
* The main menu, the board's front door: where the cockpit lands when it opens in the BBS look. The name in block
- * art comes from the frame; under it the host line, three boxed menus whose entries go where their keys go, a status
+ * art comes from the frame; under it the host line, four boxed groups whose entries go where their keys go, a status
* bar in the old modem style with this project's live facts, and a prompt that takes a key or a name and Enter.
*/
export function menuView(ctx: Ctx): RenderElement {
const { state, nowMs } = ctx
const project = state.cwd.split('/').filter(Boolean).at(-1) ?? 'ruflo'
- const go = (item: Item) => () => (item.go === 'palette' ? ctx.act.palette('all') : item.go === 'help' ? ctx.act.help() : item.go === 'close' ? ctx.act.close() : ctx.act.view(item.go))
- const width = Math.max(18, Math.floor((ctx.columns - 4) / (ctx.columns >= 66 ? 3 : 1)))
+ const go = (item: Item) => () => (item.go === 'palette' ? ctx.act.palette('all') : item.go === 'help' ? ctx.act.help() : item.go === 'close' ? ctx.act.close() : ctx.act.view(item.go as ViewId))
+ const isShown = (item: Item) => COMMANDS.has(item.go) || VIEWS.some(view => view.id === item.go)
+ // Two boxes a row where the pane is wide enough, else one; each box is a group with its own border.
+ const perRow = ctx.columns >= 60 ? 2 : 1
+ const width = Math.max(24, Math.floor((ctx.columns - 1) / perRow) - 1)
const rows: RenderElement[] = []
rows.push(
@@ -77,36 +83,42 @@ export function menuView(ctx: Ctx): RenderElement {
)
rows.push(text(ctx, ' '))
- rows.push(
+ // 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({
- flexDirection: 'row',
- flexWrap: 'wrap',
+ flexDirection: 'column',
+ width,
borderStyle: 'single',
borderColor: isBbs() ? '#d0d0d0' : 'inactive',
paddingX: 1,
- key: 'menu-box',
- children: MENUS.map(menu =>
- ctx.kit.Box({
- flexDirection: 'column',
- width,
- key: `menu-${menu.title}`,
- children: [
- ctx.kit.Text({ bold: true, color: THEME.head, wrap: 'truncate-end', children: clip(`â– ${menu.title}â– `, width) }),
- ...menu.items.map(item =>
- ctx.kit.Box({
- flexDirection: 'row',
- key: `mi-${item.key}`,
- children: [
- ctx.kit.Text({ bold: true, children: `(${item.key})` }),
- ctx.kit.Button({ key: `menu-go-${item.key}`, label: clip(item.label, width - 4), plain: true, onPress: go(item) }),
- ],
- }),
- ),
- ],
+ key: `menu-${group.title}`,
+ children: [
+ ctx.kit.Text({ bold: true, color: THEME.head, wrap: 'truncate-end', children: clip(`â–“â–’â–‘ ${group.title} â–‘â–’â–“`, width - 4) }),
+ ...group.sections.flatMap(section => {
+ const items = section.items.filter(isShown)
+
+ return items.length === 0
+ ? []
+ : [
+ 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({
+ flexDirection: 'row',
+ key: `mi-${item.go}`,
+ children: [
+ ctx.kit.Text({ bold: true, color: THEME.ok, children: ` (${item.key})` }),
+ ctx.kit.Button({ key: `menu-go-${item.go}`, label: clip(item.label, width - 9), plain: true, onPress: go(item) }),
+ ],
+ }),
+ ),
+ ]
}),
- ),
- }),
- )
+ ],
+ })
+
+ 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) }))
+ }
// The status bar under the box: the line, then what is live in this project, then how long the board has been open.
const online = mmss(nowMs - (state.pane.bootAtMs > 0 ? state.pane.bootAtMs : state.loadedAtMs))
diff --git a/plugins/ruflo-console/tests/band.spec.ts b/plugins/ruflo-console/tests/band.spec.ts
index c7b03a5538..2bd00ea657 100644
--- a/plugins/ruflo-console/tests/band.spec.ts
+++ b/plugins/ruflo-console/tests/band.spec.ts
@@ -40,7 +40,26 @@ describe('band', () => {
const parts = barParts(state, 0)
expect(parts.filter(part => part.tone === 'attention').map(part => part.text)).toEqual(['2 to approve (q)'])
- expect(barText(state, 0)).toBe('ruflo · 2 to approve (q) · 2 agents idle · $1,011 this session · 2 claims (1 stealable) · routed → coder · +12 learned')
+ // Nothing moving: it says so; the totals (routes, patterns learned) live in their views, not on the band.
+ expect(barText(state, 0)).toBe('ruflo · 2 to approve (q) · idle · 2 agents ready · 2 claims (1 stealable) · $1,011 this session')
+ })
+
+ it('leads with what is happening now: who works on what and for how long, terminal runs, a fresh event', async () => {
+ const state = await capturedState(['ruflo-core', 'ruflo-swarm', 'ruflo-mods', 'ruflo-console'])
+ const snap = state.snapshot as NonNullable<typeof state.snapshot>
+ const agent = snap.agents[0] as (typeof snap.agents)[number]
+
+ agent.status = 'busy'
+ snap.tasks.push({ id: 'task-9', type: 'feature', description: 'add OAuth login to the API gateway', status: 'in_progress', assignedTo: [agent.id] })
+ state.statusLog.set(agent.id, [{ atMs: 0, status: 'busy' }])
+ state.terminal.runs.set('codex', { label: 'codex', startedAtMs: 100_000, stop: () => undefined })
+ state.events.push({ atMs: 150_000, kind: 'claims', text: 'claim task-9 by coder' })
+
+ const parts = barParts(state, 160_000)
+
+ expect(parts.filter(part => part.tone === 'live').map(part => part.text)).toEqual([`▶ ${agent.name ?? agent.type} on add OAuth login to the API gateway 2m`, '💻 codex answering 1m'])
+ expect(barText(state, 160_000)).toContain('claim task-9 by coder · 10s ago')
+ expect(barText(state, 160_000)).not.toContain('idle')
})
it('a stale marketplace clone shows as an alert, not as a separate word', async () => {
diff --git a/plugins/ruflo-console/tests/behaviour.test.ts b/plugins/ruflo-console/tests/behaviour.test.ts
index 1dc294cd03..81ce7e4a3b 100644
--- a/plugins/ruflo-console/tests/behaviour.test.ts
+++ b/plugins/ruflo-console/tests/behaviour.test.ts
@@ -229,7 +229,8 @@ describe('behaviour', () => {
// One Text per part (attention parts are coloured); the row lays them side by side, the harness joins with \n.
const band = textOf(await $.ui.render(BAND)).replace(/\n/g, '')
- expect(band).toContain('ruflo · 3 to approve (q) · ⚠ 1 alert · 2 agents idle · $0.42 this session · 2 claims (1 stealable)')
+ // Urgent first, then what is happening now (a fresh event), then the standing context.
+ expect(band).toContain('ruflo · 3 to approve (q) · ⚠ 1 alert · router picked tester (60%) · 0s ago · 2 claims')
expect(band).not.toMatch(/0\/\d+ busy|\d patterns/)
expect(band).toContain('open console')
expect(textOf(await $.ui.render({ ...BAND, props: { ...BAND.props, hasSurvey: true } }))).toBe('engine')
diff --git a/plugins/ruflo-console/tests/views.test.ts b/plugins/ruflo-console/tests/views.test.ts
index baa060ff2b..95c7667db4 100644
--- a/plugins/ruflo-console/tests/views.test.ts
+++ b/plugins/ruflo-console/tests/views.test.ts
@@ -242,7 +242,8 @@ describe('views', () => {
const menu = await pane.drawn()
expect(elementsOf(menu, 'Raster').map(keyOf)).toEqual(['header', 'title'])
- expect(textOf(menu)).toContain('â– Swarm Commandsâ– ')
+ expect(textOf(menu)).toContain('â–“â–’â–‘ SWARM â–‘â–’â–“')
+ expect(textOf(menu)).toContain('── live')
expect(textOf(menu)).toContain('Swarm Topology')
expect(textOf(menu)).toContain('ANSI-BBS')
expect(elementsOf(menu, 'Input').map(keyOf)).toEqual(['menu-prompt'])