🌊 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
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
feat(ruflo-console): a band that says what matters, in words
ruve96bf7402389
diff --git a/plugins/ruflo-console/hooks/views/bar.ts b/plugins/ruflo-console/hooks/views/bar.tsindex bed3a472c1..76d1ab82df 100644--- a/plugins/ruflo-console/hooks/views/bar.ts+++ b/plugins/ruflo-console/hooks/views/bar.ts@@ -1,49 +1,99 @@/*** The band above the prompt: one row naming what ruflo is doing here, with a mark that pulses while Claude works.* 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 type { State } from '../state'import { clip, count, type Kit } from './common'export const BAR_KEY = 'mark'-/** The band's words, shortest-first droppable parts last. */-export function barText(state: State): string {+export type BarPart = { text: string; tone: 'attention' | 'plain' }++/** The swarm in words: how many agents and how many are working, never "0/0". */+function swarmText(state: State): string | null {const snap = state.snapshot- const parts = ['ruflo']- if (snap?.swarm != null) parts.push(`${snap.swarm.topology} ${snap.agents.filter(agent => /busy|active/i.test(agent.status)).length}/${snap.swarm.agentIds.length || snap.agents.length} busy`)+ if (snap?.swarm == null) return null++ const total = snap.swarm.agentIds.length || snap.agents.length++ if (total === 0) return 'swarm, no agents'++ const busy = snap.agents.filter(agent => /busy|active/i.test(agent.status)).length++ return busy === 0 ? `${total} agent${total === 1 ? '' : 's'} idle` : `${busy}/${total} agents busy`+}++/** Dollars a person reads at a glance: cents under $100, whole dollars with separators above. */+export function money(usd: number): string {+ return usd < 100 ? `$${usd.toFixed(2)}` : `$${Math.round(usd).toLocaleString('en-US')}`+}++export function barParts(state: State, nowMs: number = Date.now()): BarPart[] {+ const snap = state.snapshot+ const parts: BarPart[] = []++ // What needs a person: approvals waiting and warn/bad alerts. Info alerts (a claim held for days) stay in the pane.+ const approvals = approvalsOf(state).length+ const alerts = alertsOf(state, nowMs, state.loadedAtMs).filter(alert => alert.level !== 'info').length++ 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)++ 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' })const claims = snap?.claims ?? []if (claims.length > 0) {const stealable = claims.filter(claim => claim.isStealable).length- parts.push(`${claims.length} claim${claims.length === 1 ? '' : 's'}${stealable > 0 ? ` (${stealable} stealable)` : ''}`)+ parts.push({ text: `${claims.length} claim${claims.length === 1 ? '' : 's'}${stealable > 0 ? ` (${stealable} stealable)` : ''}`, tone: 'plain' })}- if (snap?.neural?.patterns !== undefined) parts.push(`${count(snap.neural.patterns)} patterns`)- if (state.ruflo.route !== null) parts.push(`→ ${state.ruflo.route.agent}`)- if (snap?.plugins.missingFromClone.length) parts.push('marketplace STALE')- if (state.usage?.costUsd !== undefined) parts.push(`$${state.usage.costUsd.toFixed(2)}`)+ 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' })+ }++ return parts+}- return parts.join(' · ')+/** The band's words, for `/ruflo status` and anything that wants it as one line. */+export function barText(state: State, nowMs: number = Date.now()): string {+ return ['ruflo', ...barParts(state, nowMs).map(part => part.text)].join(' · ')}export function barView(kit: Kit, state: State, columns: number, mark: RenderElement | null, onOpen: () => void): RenderElement {- const words = barText(state)- const room = Math.max(8, columns - (state.pane.isOpen ? 14 : 30))-- return kit.Box({- flexDirection: 'row',- children: [- ...(mark !== null ? [mark] : [kit.Text({ color: 'claude', children: '◆ ' })]),- kit.Text({ wrap: 'truncate-end', ...(state.snapshot?.plugins.missingFromClone.length ? { color: 'warning' } : { dimColor: true }), children: clip(words, room) }),- kit.Text({ children: ' ' }),- ...(state.pane.isOpen ? [] : [kit.Text({ dimColor: true, children: '/ruflo to open ' })]),- kit.Button({ key: 'open-console', label: 'console', plain: true, onPress: onOpen }),- ],- })+ // A stale marketplace clone is one of the alerts, so it already turns the band's attention part on.+ const parts = barParts(state)+ let room = Math.max(8, columns - (state.pane.isOpen ? 4 : 22))+ const children: RenderElement[] = [mark !== null ? mark : kit.Text({ color: 'claude', children: '◆ ' }), kit.Text({ dimColor: true, children: 'ruflo' })]++ room -= 5++ for (const part of parts) {+ 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) }))+ room -= words.length+ }++ if (!state.pane.isOpen) children.push(kit.Text({ children: ' ' }), kit.Button({ key: 'open-console', label: 'open console', plain: true, onPress: onOpen }))++ return kit.Box({ flexDirection: 'row', children })}diff --git a/plugins/ruflo-console/tests/band.spec.ts b/plugins/ruflo-console/tests/band.spec.tsnew file mode 100644index 0000000000..c7b03a5538--- /dev/null+++ b/plugins/ruflo-console/tests/band.spec.ts@@ -0,0 +1,73 @@+/**+ * The band's words under vitest: most important first, never a zero that says nothing.+ * npx vitest run plugins/ruflo-console/tests/band.spec.ts+ */+import { describe, expect, it } from 'vitest'++import type { ReadCache } from '../hooks/data/files'+import { readSnapshot } from '../hooks/data/snapshot'+import { newState } from '../hooks/state'+import { barParts, barText, money } from '../hooks/views/bar'+import { RUFLO_FILES } from './fixtures/ruflo-run'++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 capturedState(marketplace: string[]) {+ 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: marketplace.map(name => ({ name })) }),+ }+ const state = newState({})++ state.snapshot = await readSnapshot(memoryFs(files), new Map() as ReadCache, '/work', '/home/dev', {}, 0)++ return state+}++describe('band', () => {+ it('leads with what needs a person, then the swarm in words, then the rest', async () => {+ const state = await capturedState(['ruflo-core', 'ruflo-swarm', 'ruflo-mods', 'ruflo-console'])++ state.usage = { costUsd: 1010.66 }+ state.ruflo.route = { agent: 'coder', confidence: 0.8, matched: true, reason: 'keyword' }+ state.history.patterns = [{ atMs: 0, value: 7466 }, { atMs: 1, value: 7478 }]++ 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')+ })++ it('a stale marketplace clone shows as an alert, not as a separate word', async () => {+ const state = await capturedState(['ruflo-core', 'ruflo-swarm'])++ expect(barParts(state, 0).find(part => part.text.startsWith('⚠'))).toEqual({ text: '⚠1 alert', tone: 'attention' })+ expect(barText(state, 0)).not.toContain('STALE')+ })++ it('never says 0/0: an empty swarm is named as such, and no growth means no learned part', () => {+ const state = newState({})++ state.snapshot = { swarm: { topology: 'hierarchical', agentIds: [] }, agents: [], claims: [], plugins: { missingFromClone: [] }, daemon: null, isRufloProject: true } as never+ state.history.patterns = [{ atMs: 0, value: 7466 }, { atMs: 1, value: 7466 }]+ expect(barText(state, 0)).toBe('ruflo · swarm, no agents')+ })++ it('money: cents under $100, whole dollars with separators above', () => {+ expect(money(0.4213)).toBe('$0.42')+ expect(money(99.994)).toBe('$99.99')+ expect(money(1010.66)).toBe('$1,011')+ })++ it('no spend part until there is a cent to show', () => {+ const state = newState({})++ state.usage = { costUsd: 0.004 }+ expect(barText(state, 0)).toBe('ruflo')+ })+})diff --git a/plugins/ruflo-console/tests/behaviour.test.ts b/plugins/ruflo-console/tests/behaviour.test.tsindex 6ba556f7b6..795ae2b9ce 100644--- a/plugins/ruflo-console/tests/behaviour.test.ts+++ b/plugins/ruflo-console/tests/behaviour.test.ts@@ -211,7 +211,12 @@ describe('behaviour', () => {await $.session.start(SESSION)await $.command.run(command('status'))- expect(textOf(await $.ui.render(BAND))).toContain('ruflo · hierarchical 0/2 busy · 2 claims (1 stealable) · 30.8k patterns · → tester · $0.42')+ // 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)')+ 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')await $.ui.render({ ...BAND, props: { ...BAND.props, isWorking: true } })