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 shows how long Claude has been working, the tool-call rhythm and the context gauge (0.33.24)

ruvb2d030c88df7
diff --git a/plugins/ruflo-console/.claude-plugin/plugin.json b/plugins/ruflo-console/.claude-plugin/plugin.json
index 23c7ee1464..b89ddabc19 100644
--- a/plugins/ruflo-console/.claude-plugin/plugin.json
+++ b/plugins/ruflo-console/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "ruflo-console",
"description": "ruflo's cockpit inside Claude Code and the one /ruflo command for every ruflo mod (function hooks, early access). Views: overview with health alerts, swarm topology graph, claims flow with TTL rings, federation map, plugin health matrix, learning curve and pipeline, MetaHarness radar and audit trend, memory, cost gauge, agent timeline, approvals queue, event stream, a main menu, an x.ruv.io federation board, an AI terminal (codex, claude or both in remembered sessions, streamed), Skills (npx skills), a Hive-Mind view, a MetaHarness lab, agent drill-down; a command palette for confirm-gated actions through the ruflo CLI; a band above the prompt. Reads ruflo's files and the CLI's local JSON; anything not measured reads n/a. The one network call it makes by itself is a daily read of the published plugin.json at github.com/ruvnet/ruflo to offer an update (Settings → Updates: ask, auto, or off); it installs only through Claude Code's own claude plugin update, and never a new major version without asking.",
- "version": "0.33.20",
+ "version": "0.33.24",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-console/hooks/register.ts b/plugins/ruflo-console/hooks/register.ts
index 4390536466..056c495655 100644
--- a/plugins/ruflo-console/hooks/register.ts
+++ b/plugins/ruflo-console/hooks/register.ts
@@ -345,6 +345,7 @@ export const register: Register = (on, raw: PluginOptions) => {
on('turn.start', ($, e, next) => {
// A new turn: the per-turn cap on Claude's console actions starts over.
state.control.turnCalls = 0
+ if (e.agentId === undefined) state.turnStartedMs = Date.now()
try {
$.ui.invalidate('ui.render')
@@ -356,6 +357,7 @@ export const register: Register = (on, raw: PluginOptions) => {
})
on('turn.complete', ($, e, next) => {
+ if (e.agentId === undefined) state.turnStartedMs = null
if (e.agentId === undefined) control?.markFrame('', false)
if (e.agentId === undefined && host !== null) {
try {
diff --git a/plugins/ruflo-console/hooks/state.ts b/plugins/ruflo-console/hooks/state.ts
index ec45bf284a..719df10a83 100644
--- a/plugins/ruflo-console/hooks/state.ts
+++ b/plugins/ruflo-console/hooks/state.ts
@@ -230,6 +230,8 @@ export type State = {
commandNames: string[]
/** True while the primary Claude session is running a turn (the band reports it each draw). */
turnActive: boolean
+ /** When the person-facing turn began (the band shows how long Claude has been working), null between turns. */
+ turnStartedMs: number | null
/** Collapsible sections the person flipped from their default (`<view>/<id>`): open ones closed, closed ones open. */
sections: Set<string>
/** What one-shot entry fields hold while typed (cleared on Enter), by field key. */
@@ -336,6 +338,7 @@ export function newState(raw: PluginOptions | undefined): State {
navPick: null,
navQuery: '',
turnActive: false,
+ turnStartedMs: null,
commandNames: [],
allowed: new Map(),
sections: new Set(),
diff --git a/plugins/ruflo-console/hooks/version.ts b/plugins/ruflo-console/hooks/version.ts
index a2b7983d6b..80144abbb5 100644
--- a/plugins/ruflo-console/hooks/version.ts
+++ b/plugins/ruflo-console/hooks/version.ts
@@ -2,4 +2,4 @@
* The console's version, shown on the header so a person can tell which build is running. Kept equal to the plugin's manifest
* (`.claude-plugin/plugin.json`); tests/version.spec.ts fails if the two drift.
*/
-export const CONSOLE_VERSION = '0.33.20'
+export const CONSOLE_VERSION = '0.33.24'
diff --git a/plugins/ruflo-console/hooks/views/bar.ts b/plugins/ruflo-console/hooks/views/bar.ts
index 79ebfa8004..694a17c725 100644
--- a/plugins/ruflo-console/hooks/views/bar.ts
+++ b/plugins/ruflo-console/hooks/views/bar.ts
@@ -12,6 +12,7 @@ import { alertsOf, approvalsOf } from '../data/alerts'
import { agentLabels } from '../data/parse'
import { secMemo } from '../secure'
import type { State, ViewId } from '../state'
+import { sparkline } from '../memory-lines'
import { ago, clip, type Kit } from './common'
export const BAR_KEY = 'mark'
@@ -26,6 +27,27 @@ export type BarPart = { text: string; tone: 'attention' | 'live' | 'plain'; go?:
/** How long an event counts as "now" on the band. */
const FRESH_MS = 60_000
+/** The window of the activity sparkline: one bar per minute. */
+export const ACTIVITY_MINUTES = 10
+
+/**
+ * Tool calls per minute over the last ten minutes, oldest left, one bar a minute: how busy an unattended session has been, at a glance.
+ * Null when fewer than three calls fell in the window (a rhythm needs more than a blip). Counts only what the console observed.
+ */
+export function activityBars(events: readonly { atMs: number; kind: string }[], nowMs: number): string | null {
+ const start = nowMs - ACTIVITY_MINUTES * 60_000
+ const counts = Array.from({ length: ACTIVITY_MINUTES }, () => 0)
+ let total = 0
+
+ for (const event of events) {
+ if (event.kind !== 'tools' || event.atMs < start || event.atMs > nowMs) continue
+ counts[Math.min(ACTIVITY_MINUTES - 1, Math.floor((event.atMs - start) / 60_000))] += 1
+ total += 1
+ }
+
+ return total < 3 ? null : sparkline(counts)
+}
+
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. */
@@ -86,7 +108,9 @@ export function barParts(state: State, nowMs: number = Date.now()): BarPart[] {
if (missing !== null) parts.push(missing)
- // What is happening now: agents at work, the AI terminal's runs, and the newest event while it is fresh.
+ // What is happening now: how long Claude has been on this turn, agents at work, the AI terminal's runs, and the newest event while it is fresh.
+ if (state.turnActive && state.turnStartedMs !== null) parts.push({ text: `â–¶ Claude working${since(state.turnStartedMs, nowMs)}`, tone: 'live', go: 'events' })
+
parts.push(...workingParts(state, nowMs))
for (const [agent, run] of state.terminal.runs) parts.push({ text: `💻 ${agent} answering${since(run.startedAtMs, nowMs)}`, tone: 'live', go: 'terminal' })
@@ -107,6 +131,10 @@ export function barParts(state: State, nowMs: number = Date.now()): BarPart[] {
// last did with it), claims held, this session's spend, what the last scan found, and a published update not yet taken.
if (latest !== undefined && !isFresh) parts.push({ text: `${clip(latest.text, 44)} ·${since(latest.atMs, nowMs)} ago`, tone: 'plain', go: 'events', row: 'standing', compact: `${clip(latest.text, 18)} ·${since(latest.atMs, nowMs)} ago` })
+ const bars = activityBars(state.events, nowMs)
+
+ if (bars !== null) parts.push({ text: `${bars} tool calls, ${ACTIVITY_MINUTES}m`, tone: 'plain', go: 'events', row: 'standing', compact: bars })
+
const claims = snap?.claims ?? []
if (claims.length > 0) {
@@ -117,6 +145,13 @@ export function barParts(state: State, nowMs: number = Date.now()): BarPart[] {
if (state.usage?.costUsd !== undefined && state.usage.costUsd >= 0.01) parts.push({ text: `${money(state.usage.costUsd)} this session`, tone: 'plain', go: 'cost', row: 'standing', compact: money(state.usage.costUsd) })
+ // The context window filling: quiet until it matters, amber when it is close, with the hint that acts on it.
+ const context = state.usage?.contextPercent
+
+ if (context !== undefined && context >= 60) {
+ parts.push({ text: `ctx ${Math.round(context)}%${context >= 85 ? ' · /compact soon' : ''}`, tone: context >= 80 ? 'attention' : 'plain', go: 'cost', row: 'standing', compact: `ctx ${Math.round(context)}%` })
+ }
+
const findings = secMemo(state).findings
const serious = findings === null ? 0 : findings.counts.critical + findings.counts.high
@@ -173,15 +208,16 @@ export function barView(kit: Kit, state: State, columns: number, mark: RenderEle
}
// A row whose parts do not all fit in full uses their compact forms (a part with none keeps its words), so a part is shortened by
// its own choice of words, not cut in the middle of one.
- const fill = (lead: RenderElement[], room: number, shown: BarPart[], from: number): { children: RenderElement[]; room: number } => {
+ // `bare` is a row whose lead already ends in its own space (the standing row's "↳ "): its first part needs no separator before it.
+ const fill = (lead: RenderElement[], room: number, shown: BarPart[], from: number, bare = false): { children: RenderElement[]; room: number } => {
const children = [...lead]
const tight = shown.reduce((sum, part) => sum + part.text.length + 3, 0) > room
const forms = shown.map(part => (tight && part.compact !== undefined ? { ...part, text: part.compact } : part))
for (const [i, part] of forms.entries()) {
if (room <= 6) break
- children.push(sep(), partElement(part, `band-${from + i}`, room))
- room -= part.text.length + 3
+ children.push(...(bare && i === 0 ? [] : [sep()]), partElement(part, `band-${from + i}`, room))
+ room -= part.text.length + (bare && i === 0 ? 0 : 3)
}
return { children, room }
@@ -194,7 +230,7 @@ export function barView(kit: Kit, state: State, columns: number, mark: RenderEle
if (!state.pane.isOpen) first.children.push(kit.Text({ children: ' ' }), kit.Button({ key: 'open-console', label: 'open console', plain: true, onPress: onOpen }))
// The second row: the standing facts, then the links with what room is left (a link that does not fit is dropped, not cut).
- const second = fill([kit.Text({ color: PANEL.dim, children: '↳ ' })], inner - 2, standing, status.length)
+ const second = fill([kit.Text({ color: PANEL.dim, children: '↳ ' })], inner - 2, standing, status.length, true)
let room = second.room
for (const [i, link] of BAND_LINKS.entries()) {
diff --git a/plugins/ruflo-console/scripts/smoke.sh b/plugins/ruflo-console/scripts/smoke.sh
index 4940f0d5ba..3ba3c54b2c 100755
--- a/plugins/ruflo-console/scripts/smoke.sh
+++ b/plugins/ruflo-console/scripts/smoke.sh
@@ -11,9 +11,9 @@ step() { printf "→ %s ... " "$1"; }
ok() { printf "PASS\n"; PASS=$((PASS+1)); }
bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }
-step "1. plugin.json declares ruflo-console 0.33.20"
+step "1. plugin.json declares ruflo-console 0.33.24"
grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \
- && grep -q '"version": "0.33.20"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
+ && grep -q '"version": "0.33.24"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
step "2. hooks.json names exactly one module and no classic hook commands"
grep -q '"modules": \["./register.ts"\]' "$HOOKS/hooks.json" && ! grep -q '"command"' "$HOOKS/hooks.json" \
diff --git a/plugins/ruflo-console/tests/band-live.spec.ts b/plugins/ruflo-console/tests/band-live.spec.ts
new file mode 100644
index 0000000000..7461000ffc
--- /dev/null
+++ b/plugins/ruflo-console/tests/band-live.spec.ts
@@ -0,0 +1,104 @@
+/** The band's live signals: how long Claude has been working, the tool-call rhythm of the last ten minutes, and the context window filling. */
+import { describe, expect, it } from 'vitest'
+
+import { newState } from '../hooks/state'
+import { activityBars, barParts, barView } from '../hooks/views/bar'
+
+const NOW = 100 * 60_000
+const tools = (...minutesAgo: number[]) => minutesAgo.map(m => ({ atMs: NOW - m * 60_000 + 1_000, kind: 'tools' as const, text: 'claude: Bash' }))
+
+describe('the working timer', () => {
+ it('says how long Claude has been on this turn, only while one runs', () => {
+ const state = newState({})
+
+ expect(barParts(state, NOW).some(part => part.text.includes('Claude working'))).toBe(false)
+
+ state.turnActive = true
+ state.turnStartedMs = NOW - 41_000
+ expect(barParts(state, NOW).find(part => part.text.includes('Claude working'))).toMatchObject({ text: 'â–¶ Claude working 41s', tone: 'live', go: 'events' })
+
+ state.turnActive = false
+ expect(barParts(state, NOW).some(part => part.text.includes('Claude working'))).toBe(false)
+ })
+
+ it('does not count a turn that has no start time (a band opened mid-turn)', () => {
+ const state = newState({})
+
+ state.turnActive = true
+ expect(barParts(state, NOW).some(part => part.text.includes('Claude working'))).toBe(false)
+ })
+})
+
+describe('the activity sparkline', () => {
+ it('draws one bar a minute over the last ten, oldest left, tallest where most calls fell', () => {
+ // A call "m minutes ago" lands in bar 10 - m (m = 10 is the oldest bar, m = 1 the newest): 1 call in bar 1, 6 in bar 5, 3 in bar 9.
+ const bars = Array.from(activityBars([...tools(9), ...tools(5, 5, 5, 5, 5, 5), ...tools(1, 1, 1)], NOW) ?? '')
+
+ expect(bars).toHaveLength(10)
+ expect(bars.map((bar, i) => (bar === '·' ? '' : String(i))).filter(Boolean)).toEqual(['1', '5', '9'])
+ expect(bars[5]).toBe('â–ˆ')
+ expect(bars[1]).not.toBe('â–ˆ')
+ expect(bars[9]).not.toBe('â–ˆ')
+ })
+
+ it('stays silent for a blip, other events, and calls outside the window', () => {
+ expect(activityBars(tools(2, 3), NOW)).toBeNull()
+ expect(activityBars(Array.from({ length: 8 }, () => ({ atMs: NOW - 1_000, kind: 'swarm', text: 'x' })), NOW)).toBeNull()
+ expect(activityBars(tools(11, 12, 13, 14), NOW)).toBeNull()
+ })
+
+ it('is a standing part with a short form for a narrow band', () => {
+ const state = newState({})
+
+ state.events = [...tools(4, 3, 2, 1)]
+
+ const part = barParts(state, NOW).find(candidate => candidate.text.endsWith('tool calls, 10m'))
+
+ expect(part).toMatchObject({ tone: 'plain', go: 'events', row: 'standing' })
+ expect(part?.compact).toHaveLength(10)
+ })
+})
+
+describe('the context gauge', () => {
+ const part = (percent: number | undefined) => {
+ const state = newState({})
+
+ state.usage = percent === undefined ? null : { contextPercent: percent }
+
+ return barParts(state, NOW).find(candidate => candidate.text.startsWith('ctx'))
+ }
+
+ it('is quiet below 60%, plain to 79%, amber from 80%, and says so when it is time to compact', () => {
+ expect(part(undefined)).toBeUndefined()
+ expect(part(59.9)).toBeUndefined()
+ expect(part(62)).toMatchObject({ text: 'ctx 62%', tone: 'plain', row: 'standing', compact: 'ctx 62%' })
+ expect(part(82)).toMatchObject({ text: 'ctx 82%', tone: 'attention' })
+ expect(part(91)).toMatchObject({ text: 'ctx 91% · /compact soon', tone: 'attention', compact: 'ctx 91%' })
+ })
+})
+
+describe('the standing row', () => {
+ type El = { kind: string; props: Record<string, unknown> }
+ const make = (kind: string) => (props: Record<string, unknown>): El => ({ kind, props })
+ const kit = { Box: make('Box'), Text: make('Text'), Button: make('Button'), Input: make('Input') }
+ const flat = (node: unknown): El[] => (Array.isArray(node) ? node.flatMap(flat) : node !== null && typeof node === 'object' ? [node as El, ...flat((node as El).props.children)] : [])
+ const rowsOf = (state: ReturnType<typeof newState>, columns: number): string[] =>
+ flat(barView(kit as never, state, columns, null, () => undefined, () => undefined))
+ .filter(el => el.kind === 'Box' && el.props.flexDirection === 'row')
+ .map(box => flat(box.props.children).filter(el => el.kind === 'Text' || el.kind === 'Button').map(el => String(el.props.children ?? el.props.label)).join(''))
+
+ it('starts with its marker and its first fact, with no doubled separator, and shows the live signals', () => {
+ const state = newState({})
+
+ state.usage = { costUsd: 397, contextPercent: 83 }
+ // barView reads the real clock, so the calls are dated from now.
+ state.events = [5, 4, 3, 2, 1].map(m => ({ atMs: Date.now() - m * 60_000 + 1_000, kind: 'tools' as const, text: 'claude: Bash' }))
+
+ const standing = rowsOf(state, 150)[1] ?? ''
+
+ expect(standing).toMatch(/^↳ \S/)
+ expect(standing).not.toMatch(/^↳ {2}/)
+ expect(standing).toContain('tool calls, 10m')
+ expect(standing).toContain('$397 this session · ctx 83%')
+ })
+})