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(console): band notices, tone border, /ruflo band|notices|quiet (0.33.23)

ruv616a7ebb015d
diff --git a/plugins/ruflo-console/.claude-plugin/plugin.json b/plugins/ruflo-console/.claude-plugin/plugin.json
index 00aec7528b..3893ab70f5 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.22",
+ "version": "0.33.23",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-console/hooks/commands.ts b/plugins/ruflo-console/hooks/commands.ts
index 8f92e8c52b..96ac80963b 100644
--- a/plugins/ruflo-console/hooks/commands.ts
+++ b/plugins/ruflo-console/hooks/commands.ts
@@ -23,6 +23,9 @@ export type Intent =
| { kind: 'filter'; filter: 'all' | EventKind }
| { kind: 'dump'; view: ViewId | null }
| { kind: 'commands'; query: string }
+ | { kind: 'band'; arg: string }
+ | { kind: 'notices'; isClear: boolean }
+ | { kind: 'quiet'; arg: string }
| { kind: 'unknown'; word: string }
export function parseRuflo(args: string): Intent {
@@ -75,6 +78,12 @@ export function parseRuflo(args: string): Intent {
case 'prev':
case 'k':
return { kind: 'select', by: -1 }
+ case 'band':
+ return { kind: 'band', arg: second }
+ case 'notices':
+ return { kind: 'notices', isClear: second === 'clear' }
+ case 'quiet':
+ return { kind: 'quiet', arg: second }
case 'commands':
case 'catalog':
return { kind: 'commands', query: rest }
@@ -102,6 +111,11 @@ export const HELP = [
' /ruflo dump <view> a view as plain text, without the pane (for claude -p and scripts)',
' /ruflo commands [word] browse the ruflo command catalog (ADR-406): every command, who owns it, how it runs',
'',
+ 'The band above the prompt',
+ ' /ruflo band [auto|on|off|compact|full|reset] show, hide or shrink the band for this session (compact = one row)',
+ ' /ruflo notices [clear] the last ten announcements (approvals, alerts, a mission finishing, a long turn ending, Anatole blocking a call)',
+ ' /ruflo quiet [minutes|off] silence the band\'s notice row for a while; notices are still recorded',
+ '',
'Act (each change asks to confirm; /ruflo yes or /ruflo no answers without focus)',
' /ruflo palette [query] the command palette (key p): spawn, claims, swarm, votes, workers, memory',
' /ruflo run <entry> [text] run a palette entry by id, e.g. run spawn-coder, run route fix the login bug',
diff --git a/plugins/ruflo-console/hooks/controller.ts b/plugins/ruflo-console/hooks/controller.ts
index 1d1d4855d3..03ede2e5e6 100644
--- a/plugins/ruflo-console/hooks/controller.ts
+++ b/plugins/ruflo-console/hooks/controller.ts
@@ -9,6 +9,7 @@ import { PROBES, probeArgv, probeError, probeReady, type ProbeResult } from './d
import { ALL_COST_PROBES as COST_PROBES } from './data/cost-probes'
import { X_PROBES } from './data/xruv'
import { diffEvents, record } from './data/events'
+import { agentName, announceChanges, factsOf } from './notices'
import { plain } from './data/parse'
import { readSnapshot } from './data/snapshot'
import { markPicture } from './gfx/pictures'
@@ -71,11 +72,6 @@ export function segmentOf(state: State): string | null {
return parts.length === 0 ? null : parts.join(' · ')
}
-const sorted = (values: readonly number[]) => [...values].sort((a, b) => a - b)
-
-export const median = (values: readonly number[]) => sorted(values)[Math.floor(values.length / 2)] ?? 0
-export const p95 = (values: readonly number[]) => sorted(values)[Math.min(values.length - 1, Math.floor(values.length * 0.95))] ?? 0
-
export function createController(state: State, host: Host): Controller {
let activityCount = 0
let markRequest: string | null = null
@@ -135,9 +131,14 @@ export function createController(state: State, host: Host): Controller {
const now = Date.now()
const snapshot = await readSnapshot(host.fs, state.cache, state.cwd, state.home, settings, now, state.configDir, state.options.federationNetwork)
if (snapshot.hasNostrKey === false) state.nostrKeyVerifiedAtMs = null
+ // What changed since the last read is announced on the band (the first read announces nothing).
+ const before = previous === null ? null : factsOf(state, now)
+
state.snapshot = snapshot
record(state.events, diffEvents(previous, snapshot, now))
+ if (before !== null) announceChanges(state, before, now)
+
if (route !== null && route.agent !== state.ruflo.route?.agent) record(state.events, [{ atMs: now, kind: 'learning', text: `router picked ${route.agent} (${Math.round(route.confidence * 100)}%)` }])
state.usage = usage
@@ -487,7 +488,7 @@ export function createController(state: State, host: Host): Controller {
push(list, { atMs: Date.now(), tool: plain(tool, 40) }, 200)
state.toolsByAgent.set(who, list)
if (state.toolsByAgent.size > 50) state.toolsByAgent.delete(state.toolsByAgent.keys().next().value as string)
- record(state.events, [{ atMs: Date.now(), kind: 'tools', text: `${who === 'main' ? 'claude' : who}: ${plain(tool, 40)}` }])
+ record(state.events, [{ atMs: Date.now(), kind: 'tools', text: `${agentName(state, agentId)}: ${plain(tool, 40)}` }])
}
const closedByPerson = () => {
diff --git a/plugins/ruflo-console/hooks/dispatch.ts b/plugins/ruflo-console/hooks/dispatch.ts
index 57666e03fb..cf808da69a 100644
--- a/plugins/ruflo-console/hooks/dispatch.ts
+++ b/plugins/ruflo-console/hooks/dispatch.ts
@@ -6,7 +6,6 @@
import { HELP, parseRuflo, type Intent } from './commands'
import { CATALOG_PATH, commandsText, FALLBACK, parseCatalog, type Catalog } from './data/catalog'
import type { Controller } from './controller'
-import { median, p95 } from './controller'
import { plain } from './data/parse'
import { loadEvolve } from './evolve'
import { labAnswer } from './mh-lab'
@@ -16,6 +15,7 @@ import { missionAnswer } from './mission-text'
import { xruvAnswer } from './xruv'
import { barText } from './views/bar'
import { viewText } from './views/pane'
+import { bandReply, noticesReply, quietReply, median, p95 } from './notices'
/** The engine's words when a registered command reaches it with no hook answering (Claude Code 2.1.287). */
const NO_HOOK_ANSWERED = /registered \/ruflo but no command\.run hook answered/
@@ -173,6 +173,16 @@ export async function dispatch(control: Controller, state: State, args: string,
return { text: await dumpOf(control, state, view) }
}
+ case 'band':
+ control.host.invalidate()
+
+ return { text: bandReply(state, intent.arg) }
+ case 'notices':
+ return { text: noticesReply(state, Date.now(), intent.isClear) }
+ case 'quiet':
+ control.host.invalidate()
+
+ return { text: quietReply(state, Date.now(), intent.arg) }
case 'commands':
return { text: commandsText(await loadCatalog(control), intent.query) }
case 'unknown':
diff --git a/plugins/ruflo-console/hooks/notices.ts b/plugins/ruflo-console/hooks/notices.ts
new file mode 100644
index 0000000000..dc1389a54e
--- /dev/null
+++ b/plugins/ruflo-console/hooks/notices.ts
@@ -0,0 +1,177 @@
+/**
+ * Notices: short announcements the band raises when something changes while nobody is looking at it: new approvals or alerts, a mission
+ * finishing, a long Claude turn ending, Project Anatole blocking a call. A notice is recorded (a ring of 30, listed by `/ruflo notices`),
+ * shown on the band's notice row for a short while, and linked to the view it is about. They come only from changes the console observed
+ * between two reads: nothing is synthesised, and the first read announces nothing. Pure, apart from the helpers that edit `state`.
+ */
+import { alertsOf, approvalsOf } from './data/alerts'
+import { agentLabels } from './data/parse'
+import { activeMission, progressOf } from './mission-control'
+import type { State, ViewId } from './state'
+
+export type NoticeLevel = 'ok' | 'info' | 'warn' | 'bad'
+
+export type Notice = { id: number; atMs: number; level: NoticeLevel; text: string; key: string; go?: ViewId; seen: boolean }
+
+/** What a notice is raised from, before it gets an id and a time. */
+export type NoticeDraft = { level: NoticeLevel; text: string; key: string; go?: ViewId }
+
+export const MAX_NOTICES = 30
+/** How long an unseen notice stays on the band's notice row. */
+export const SHOW_MS = 20_000
+/** The same kind of notice (its key) is not raised again inside this window. */
+export const DEDUPE_MS = 60_000
+
+/** The few counts a notice is decided from, read off the state at one moment. */
+export type Facts = {
+ approvals: number
+ alerts: number
+ mission: { id: string; done: number; total: number } | null
+ anatole: { blocked: number; critical: number; degraded: string | null } | null
+}
+
+export function factsOf(state: State, nowMs: number = Date.now()): Facts {
+ const mission = activeMission(state)
+ const tasks = state.snapshot?.tasks ?? []
+ const progress = mission === null || mission.cancelled ? null : progressOf(mission, tasks)
+ const status = state.snapshot?.anatole?.status ?? null
+
+ return {
+ approvals: approvalsOf(state).length,
+ alerts: alertsOf(state, nowMs, state.loadedAtMs).filter(alert => alert.level !== 'info').length,
+ mission: mission === null || progress === null ? null : { id: mission.id, done: progress.done, total: progress.total },
+ anatole: status === null ? null : { blocked: status.blocked, critical: status.open.critical, degraded: status.degraded === false ? null : String(status.degraded).slice(0, 60) },
+ }
+}
+
+const plural = (n: number, word: string): string => `${n} ${word}${n === 1 ? '' : 's'}`
+
+/** What changed between two reads that a person would want announced. The newest Anatole alert's rule rides on a block. */
+export function noticesBetween(before: Facts, after: Facts, newestRule: string | null = null): NoticeDraft[] {
+ const out: NoticeDraft[] = []
+
+ if (after.approvals > before.approvals) out.push({ level: 'warn', text: `${plural(after.approvals - before.approvals, 'new approval')} waiting (q)`, key: 'approvals', go: 'approvals' })
+ if (after.alerts > before.alerts) out.push({ level: 'warn', text: `${plural(after.alerts - before.alerts, 'new alert')}`, key: 'alerts', go: 'overview' })
+
+ if (before.mission !== null && before.mission.done < before.mission.total && after.mission !== null && after.mission.id === before.mission.id && after.mission.done >= after.mission.total) {
+ out.push({ level: 'ok', text: `🎯 mission finished: ${after.mission.done}/${after.mission.total} tasks`, key: 'mission-done', go: 'missions' })
+ }
+
+ if (before.anatole !== null && after.anatole !== null) {
+ if (after.anatole.blocked > before.anatole.blocked) out.push({ level: 'bad', text: `🛡 Anatole blocked ${plural(after.anatole.blocked - before.anatole.blocked, 'call')}${newestRule === null ? '' : ` · ${newestRule}`}`, key: 'anatole-blocked', go: 'secure' })
+ else if (after.anatole.critical > before.anatole.critical) out.push({ level: 'bad', text: '🛡 Anatole: a new critical alert', key: 'anatole-critical', go: 'secure' })
+ if (after.anatole.degraded !== null && before.anatole.degraded === null) out.push({ level: 'warn', text: `🛡 Anatole is degraded: ${after.anatole.degraded}`, key: 'anatole-degraded', go: 'secure' })
+ }
+
+ return out
+}
+
+/** After a read: announces what changed since `before` (the newest open Anatole alert's rule rides on a block). */
+export function announceChanges(state: State, before: Facts, nowMs: number): void {
+ const open = (state.snapshot?.anatole?.alerts ?? []).filter(alert => alert.state === 'open')
+
+ for (const draft of noticesBetween(before, factsOf(state, nowMs), open.at(-1)?.rule ?? null)) addNotice(state, draft, nowMs)
+}
+
+/** Records a notice, unless one with the same key was raised a minute ago. The ring keeps the newest 30. Returns whether it was recorded. */
+export function addNotice(state: State, draft: NoticeDraft, nowMs: number = Date.now()): boolean {
+ if (state.notices.some(notice => notice.key === draft.key && nowMs - notice.atMs < DEDUPE_MS)) return false
+
+ state.noticeSeq += 1
+ state.notices.push({ id: state.noticeSeq, atMs: nowMs, level: draft.level, text: draft.text.slice(0, 120), key: draft.key, ...(draft.go !== undefined && { go: draft.go }), seen: false })
+ if (state.notices.length > MAX_NOTICES) state.notices.splice(0, state.notices.length - MAX_NOTICES)
+
+ return true
+}
+
+/** The notice the band shows now: the newest unseen one still young, none while the person has asked for quiet. */
+export function visibleNotice(state: State, nowMs: number): Notice | null {
+ if (nowMs < state.noticesQuietUntilMs) return null
+
+ for (let i = state.notices.length - 1; i >= 0; i--) {
+ const notice = state.notices[i] as Notice
+
+ if (!notice.seen && nowMs - notice.atMs < SHOW_MS) return notice
+ }
+
+ return null
+}
+
+/** Dismisses what is showing (and anything older and unseen), so the next notice shows on its own. */
+export function dismissNotices(state: State): void {
+ for (const notice of state.notices) notice.seen = true
+}
+
+const AGO = (ms: number): string => (ms < 60_000 ? `${Math.max(0, Math.round(ms / 1000))}s` : ms < 3_600_000 ? `${Math.round(ms / 60_000)}m` : `${Math.round(ms / 3_600_000)}h`)
+
+/** `/ruflo notices`: the last ten, newest first; listing them marks them seen. `clear` empties the ring. */
+export function noticesReply(state: State, nowMs: number, clear: boolean): string {
+ if (clear) {
+ const n = state.notices.length
+
+ state.notices.length = 0
+
+ return n === 0 ? 'no notices to clear' : `cleared ${plural(n, 'notice')}`
+ }
+
+ const recent = state.notices.slice(-10).reverse()
+
+ dismissNotices(state)
+
+ if (recent.length === 0) return 'no notices yet: the band raises one when approvals or alerts arrive, a mission finishes, a long turn ends, or Anatole blocks a call'
+
+ const mark = { ok: '✓', info: 'ℹ', warn: '⚠', bad: '✖' } as const
+
+ return [`notices (newest first${nowMs < state.noticesQuietUntilMs ? `; quiet for ${AGO(state.noticesQuietUntilMs - nowMs)} more` : ''}):`, ...recent.map(notice => ` ${mark[notice.level]} ${notice.text} · ${AGO(nowMs - notice.atMs)} ago${notice.go === undefined ? '' : ` · /ruflo ${notice.go}`}`)].join('\n')
+}
+
+/** `/ruflo quiet [minutes|off]`: silence the notice row for a while (notices are still recorded and listed). */
+export function quietReply(state: State, nowMs: number, arg: string): string {
+ const word = arg.trim().toLowerCase()
+
+ if (word === 'off' || word === '0') {
+ state.noticesQuietUntilMs = 0
+
+ return 'notices are on again'
+ }
+
+ if (word === '') return nowMs < state.noticesQuietUntilMs ? `notices are quiet for ${AGO(state.noticesQuietUntilMs - nowMs)} more (/ruflo quiet off)` : 'notices are on (/ruflo quiet <minutes> silences the band\'s notice row)'
+
+ const minutes = Number(word)
+
+ if (!Number.isFinite(minutes) || minutes < 1 || minutes > 1440) return 'quiet takes a number of minutes from 1 to 1440, or off'
+
+ state.noticesQuietUntilMs = nowMs + Math.round(minutes) * 60_000
+
+ return `notices are quiet for ${Math.round(minutes)}m: they are still recorded (/ruflo notices lists them)`
+}
+
+/** `/ruflo band [auto|on|off|compact|full|reset]`: the band's show/hide and size for this session, over the option. */
+export function bandReply(state: State, arg: string): string {
+ const word = arg.trim().toLowerCase()
+
+ if (word === 'auto' || word === 'on' || word === 'off') state.bandMode = word
+ else if (word === 'compact') state.bandCompact = true
+ else if (word === 'full') state.bandCompact = false
+ else if (word === 'reset') {
+ state.bandMode = null
+ state.bandCompact = false
+ } else if (word !== '') return 'band takes auto, on, off, compact, full or reset'
+
+ return `band: ${state.bandMode ?? `${state.options.bar} (the plugin option)`} · ${state.bandCompact ? 'compact (one row)' : 'full (two rows)'}`
+}
+
+/** A readable name for a subagent in the event stream: the ruflo agent's label when it is one, else "subagent" and the id's first six characters. */
+export function agentName(state: State, agentId: string | undefined): string {
+ if (agentId === undefined) return 'claude'
+
+ const agents = state.snapshot?.agents ?? []
+ const known = agentLabels(agents).get(agentId)
+
+ return known !== undefined ? known : `subagent ${agentId.replace(/[^a-z0-9]/gi, '').slice(0, 6)}`
+}
+
+const sorted = (values: readonly number[]) => [...values].sort((a, b) => a - b)
+
+export const median = (values: readonly number[]) => sorted(values)[Math.floor(values.length / 2)] ?? 0
+export const p95 = (values: readonly number[]) => sorted(values)[Math.min(values.length - 1, Math.floor(values.length * 0.95))] ?? 0
diff --git a/plugins/ruflo-console/hooks/register.ts b/plugins/ruflo-console/hooks/register.ts
index 056c495655..fd1d69501b 100644
--- a/plugins/ruflo-console/hooks/register.ts
+++ b/plugins/ruflo-console/hooks/register.ts
@@ -10,6 +10,7 @@ import type { Host } from './host'
import { ownerLine, ownerOf } from './tool-owner'
import { newState, PANE_ID, restore, restoreSessions, storeKeyOf, termStoreKeyOf } from './state'
import { BAR_KEY, barView } from './views/bar'
+import { addNotice, dismissNotices } from './notices'
import { setBootChecks } from './boot-checks'
import { buildOf, isOurCheckout, setBuild } from './build'
import { runUpdateCheck } from './update-flow'
@@ -306,7 +307,8 @@ export const register: Register = (on, raw: PluginOptions) => {
})
on('ui.render', { component: 'AbovePrompt' }, ($, e, next) => {
- const show = state.options.bar === 'on' || (state.options.bar === 'auto' && state.snapshot?.isRufloProject === true)
+ const mode = state.bandMode ?? state.options.bar
+ const show = mode === 'on' || (mode === 'auto' && state.snapshot?.isRufloProject === true)
if (control === null || e.props.hasSurvey || !show) {
return next(e)
@@ -326,6 +328,13 @@ export const register: Register = (on, raw: PluginOptions) => {
return barView(table, state, Math.floor(Number(e.props.bodyColumns) || 80), mark, () => void bound.open(false), view => {
bound.setView(view)
void bound.open(true)
+ }, () => {
+ dismissNotices(state)
+ try {
+ $.ui.invalidate('ui.render')
+ } catch {
+ // A refused redraw leaves the notice showing until the next one.
+ }
})
})
@@ -357,6 +366,12 @@ export const register: Register = (on, raw: PluginOptions) => {
})
on('turn.complete', ($, e, next) => {
+ if (e.agentId === undefined && state.turnStartedMs !== null) {
+ // A long turn that ends while nobody watches is worth saying: the band announces it (a short one is not news).
+ const took = Date.now() - state.turnStartedMs
+
+ if (took >= 30_000) addNotice(state, { level: 'ok', text: `✓ Claude finished a turn · ${took < 60_000 ? `${Math.round(took / 1000)}s` : `${Math.floor(took / 60_000)}m ${Math.round((took % 60_000) / 1000)}s`}`, key: 'turn-done' })
+ }
if (e.agentId === undefined) state.turnStartedMs = null
if (e.agentId === undefined) control?.markFrame('', false)
if (e.agentId === undefined && host !== null) {
diff --git a/plugins/ruflo-console/hooks/state.ts b/plugins/ruflo-console/hooks/state.ts
index 719df10a83..6e0e52d04d 100644
--- a/plugins/ruflo-console/hooks/state.ts
+++ b/plugins/ruflo-console/hooks/state.ts
@@ -12,6 +12,7 @@ import { emptyMemoryLab, type MemoryLabState } from './memory-lab'
import { emptyVector, type VectorState } from './data/vector'
import type { Snapshot } from './data/snapshot'
import type { RufloRoute, RufloSnapshot } from '../types'
+import type { Notice } from './notices'
export const PLUGIN_NAME = 'ruflo-console'
export const PANE_ID = 'ruflo-console'
@@ -230,6 +231,13 @@ export type State = {
commandNames: string[]
/** True while the primary Claude session is running a turn (the band reports it each draw). */
turnActive: boolean
+ /** Notices the band announced (notices.ts): the newest 30, a running id, and a time before which the notice row stays quiet. */
+ notices: Notice[]
+ noticeSeq: number
+ noticesQuietUntilMs: number
+ /** `/ruflo band`: the band's mode for this session over the plugin option (null = the option), and whether it shows one row. */
+ bandMode: 'auto' | 'on' | 'off' | null
+ bandCompact: 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. */
@@ -338,6 +346,11 @@ export function newState(raw: PluginOptions | undefined): State {
navPick: null,
navQuery: '',
turnActive: false,
+ notices: [],
+ noticeSeq: 0,
+ noticesQuietUntilMs: 0,
+ bandMode: null,
+ bandCompact: false,
turnStartedMs: null,
commandNames: [],
allowed: new Map(),
diff --git a/plugins/ruflo-console/hooks/version.ts b/plugins/ruflo-console/hooks/version.ts
index f40cd4e40e..aff8018138 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.22'
+export const CONSOLE_VERSION = '0.33.23'
diff --git a/plugins/ruflo-console/hooks/views/bar.ts b/plugins/ruflo-console/hooks/views/bar.ts
index 694a17c725..235db58a4e 100644
--- a/plugins/ruflo-console/hooks/views/bar.ts
+++ b/plugins/ruflo-console/hooks/views/bar.ts
@@ -13,6 +13,7 @@ import { agentLabels } from '../data/parse'
import { secMemo } from '../secure'
import type { State, ViewId } from '../state'
import { sparkline } from '../memory-lines'
+import { visibleNotice, type Notice } from '../notices'
import { ago, clip, type Kit } from './common'
export const BAR_KEY = 'mark'
@@ -171,7 +172,7 @@ export function barText(state: State, nowMs: number = Date.now()): string {
* names, so the text stays readable on the ground and a name the host does not know cannot make it refuse the whole band. (A
* Button cannot be coloured: its label takes the theme's, which reads on a dark theme; on a light one it is dim on the dark ground.)
*/
-export const PANEL = { ground: '#1c1c1c', border: '#5f5faf', text: '#d0d0d0', dim: '#8a8a8a', attention: '#ffaf00', live: '#5fd75f' } as const
+export const PANEL = { ground: '#1c1c1c', border: '#5f5faf', text: '#d0d0d0', dim: '#8a8a8a', attention: '#ffaf00', live: '#5fd75f', bad: '#ff5f5f' } as const
/** Links at the end of the standing row, each opening the console on that view: where to go next, whatever is happening. */
export const BAND_LINKS: readonly { label: string; go: ViewId }[] = [
@@ -183,6 +184,24 @@ export const BAND_LINKS: readonly { label: string; go: ViewId }[] = [
{ label: 'Menu', go: 'menu' },
]
+/**
+ * The band's overall state, which colours its border so it reads from across the room: a notice that is bad (or Anatole blocking) is red,
+ * something that needs a person is amber, Claude at work is green, and a quiet band keeps its usual purple.
+ */
+export type BandTone = 'bad' | 'attention' | 'live' | 'idle'
+
+export function bandTone(parts: readonly BarPart[], notice: Notice | null): BandTone {
+ if (notice?.level === 'bad') return 'bad'
+ if (parts.some(part => part.tone === 'attention') || notice?.level === 'warn') return 'attention'
+ if (parts.some(part => part.tone === 'live')) return 'live'
+
+ return 'idle'
+}
+
+const BORDER: Record<BandTone, string> = { bad: PANEL.bad, attention: PANEL.attention, live: PANEL.live, idle: PANEL.border }
+const NOTICE_MARK = { ok: '✓', info: 'ℹ', warn: '⚠', bad: '✖' } as const
+const NOTICE_COLOR = { ok: PANEL.live, info: PANEL.text, warn: PANEL.attention, bad: PANEL.bad } as const
+
const toneColor = (tone: BarPart['tone']): string => (tone === 'attention' ? PANEL.attention : tone === 'live' ? PANEL.live : PANEL.text)
/**
@@ -191,9 +210,10 @@ const toneColor = (tone: BarPart['tone']): string => (tone === 'attention' ? PAN
* then links to the main views. They are separate rows so a long mission title cannot push the standing facts out. Each part is a
* link: a click opens the console on the view it is about. `onGo` opens the console there; `onOpen` opens it as it was.
*/
-export function barView(kit: Kit, state: State, columns: number, mark: RenderElement | null, onOpen: () => void, onGo?: (view: ViewId) => void): RenderElement {
+export function barView(kit: Kit, state: State, columns: number, mark: RenderElement | null, onOpen: () => void, onGo?: (view: ViewId) => void, onDismiss?: () => void): RenderElement {
// A stale marketplace clone is one of the alerts, so it already turns the band's attention part on.
const parts = barParts(state)
+ const notice = visibleNotice(state, Date.now())
const inner = Math.max(16, columns - 4)
const sep = (): RenderElement => kit.Text({ color: PANEL.dim, children: ' · ' })
@@ -243,12 +263,26 @@ export function barView(kit: Kit, state: State, columns: number, mark: RenderEle
room -= link.label.length + (i === 0 ? 3 : 1)
}
+ // An announcement, on its own row: what changed, a link to where it is, and a dismiss. It goes by itself after a short while.
+ const noticeRow = notice === null ? [] : [
+ kit.Box({
+ flexDirection: 'row',
+ children: [
+ kit.Text({ bold: true, color: NOTICE_COLOR[notice.level], children: `${NOTICE_MARK[notice.level]} ` }),
+ kit.Text({ color: NOTICE_COLOR[notice.level], wrap: 'truncate-end', children: clip(notice.text, Math.max(10, inner - 24)) }),
+ kit.Text({ children: ' ' }),
+ ...(notice.go !== undefined && onGo !== undefined ? [kit.Button({ key: 'band-notice-go', label: 'view', plain: true, onPress: () => onGo(notice.go as ViewId) })] : []),
+ ...(onDismiss !== undefined ? [kit.Text({ children: ' ' }), kit.Button({ key: 'band-notice-dismiss', label: '✕', plain: true, dimColor: true, onPress: onDismiss })] : []),
+ ],
+ }),
+ ]
+
return kit.Box({
flexDirection: 'column',
borderStyle: 'round',
- borderColor: PANEL.border,
+ borderColor: BORDER[bandTone(parts, notice)],
backgroundColor: PANEL.ground,
paddingX: 1,
- children: [kit.Box({ flexDirection: 'row', children: first.children }), kit.Box({ flexDirection: 'row', children: second.children })],
+ children: [kit.Box({ flexDirection: 'row', children: first.children }), ...(state.bandCompact ? [] : [kit.Box({ flexDirection: 'row', children: second.children })]), ...noticeRow],
})
}
diff --git a/plugins/ruflo-console/scripts/smoke.sh b/plugins/ruflo-console/scripts/smoke.sh
index bae09db687..07a5a738d4 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.22"
+step "1. plugin.json declares ruflo-console 0.33.23"
grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \
- && grep -q '"version": "0.33.22"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
+ && grep -q '"version": "0.33.23"' "$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/notices.spec.ts b/plugins/ruflo-console/tests/notices.spec.ts
new file mode 100644
index 0000000000..a9bb973887
--- /dev/null
+++ b/plugins/ruflo-console/tests/notices.spec.ts
@@ -0,0 +1,192 @@
+/** Notices: what the band announces, how long, how to silence it; the commands that drive it; the band's tone, notice row and compact mode. */
+import { describe, expect, it } from 'vitest'
+
+import { parseRuflo } from '../hooks/commands'
+import { addNotice, agentName, bandReply, DEDUPE_MS, dismissNotices, MAX_NOTICES, noticesBetween, noticesReply, quietReply, SHOW_MS, visibleNotice, type Facts } from '../hooks/notices'
+import { newState } from '../hooks/state'
+import { bandTone, barView, PANEL, type BarPart } from '../hooks/views/bar'
+
+const NOW = 1_000_000
+const facts = (over: Partial<Facts> = {}): Facts => ({ approvals: 0, alerts: 0, mission: null, anatole: null, ...over })
+const anatole = (over: Partial<NonNullable<Facts['anatole']>> = {}) => ({ blocked: 0, critical: 0, degraded: null, ...over })
+
+describe('what is announced', () => {
+ it('says nothing when nothing changed, or when counts went down', () => {
+ expect(noticesBetween(facts(), facts())).toEqual([])
+ expect(noticesBetween(facts({ approvals: 3, alerts: 2 }), facts({ approvals: 1, alerts: 0 }))).toEqual([])
+ })
+
+ it('announces new approvals and alerts with how many, linked to where they are', () => {
+ expect(noticesBetween(facts(), facts({ approvals: 2, alerts: 1 }))).toEqual([
+ { level: 'warn', text: '2 new approvals waiting (q)', key: 'approvals', go: 'approvals' },
+ { level: 'warn', text: '1 new alert', key: 'alerts', go: 'overview' },
+ ])
+ })
+
+ it('announces a mission finishing once, only for the same mission and only when it was not already done', () => {
+ const running = facts({ mission: { id: 'm1', done: 14, total: 15 } })
+
+ expect(noticesBetween(running, facts({ mission: { id: 'm1', done: 15, total: 15 } }))).toEqual([{ level: 'ok', text: '🎯 mission finished: 15/15 tasks', key: 'mission-done', go: 'missions' }])
+ expect(noticesBetween(running, facts({ mission: { id: 'm2', done: 15, total: 15 } }))).toEqual([])
+ expect(noticesBetween(facts({ mission: { id: 'm1', done: 15, total: 15 } }), facts({ mission: { id: 'm1', done: 15, total: 15 } }))).toEqual([])
+ })
+
+ it('announces Anatole blocking calls as bad, with the rule, a new critical alert, and a mod that went degraded', () => {
+ const blocked = noticesBetween(facts({ anatole: anatole({ blocked: 1 }) }), facts({ anatole: anatole({ blocked: 3 }) }), 'PR-002')
+
+ expect(blocked).toEqual([{ level: 'bad', text: '🛡 Anatole blocked 2 calls · PR-002', key: 'anatole-blocked', go: 'secure' }])
+ expect(noticesBetween(facts({ anatole: anatole() }), facts({ anatole: anatole({ critical: 1 }) }))[0]).toMatchObject({ level: 'bad', key: 'anatole-critical' })
+ expect(noticesBetween(facts({ anatole: anatole() }), facts({ anatole: anatole({ degraded: 'timeout' }) }))[0]).toMatchObject({ level: 'warn', text: '🛡 Anatole is degraded: timeout' })
+ })
+
+ it('announces nothing about Anatole when it was not reporting before (the first read, or the plugin just appeared)', () => {
+ expect(noticesBetween(facts(), facts({ anatole: anatole({ blocked: 9, critical: 2 }) }))).toEqual([])
+ })
+})
+
+describe('the notice ring', () => {
+ it('records a notice, does not repeat the same kind inside a minute, and keeps the newest 30', () => {
+ const state = newState({})
+
+ expect(addNotice(state, { level: 'warn', text: 'a', key: 'k' }, NOW)).toBe(true)
+ expect(addNotice(state, { level: 'warn', text: 'b', key: 'k' }, NOW + DEDUPE_MS - 1)).toBe(false)
+ expect(addNotice(state, { level: 'warn', text: 'c', key: 'k' }, NOW + DEDUPE_MS)).toBe(true)
+
+ for (let i = 0; i < 40; i++) addNotice(state, { level: 'info', text: `n${i}`, key: `key${i}` }, NOW + i)
+
+ expect(state.notices).toHaveLength(MAX_NOTICES)
+ expect(state.notices.at(-1)?.text).toBe('n39')
+ })
+
+ it('shows the newest unseen notice while young, then not; dismiss clears it; quiet hides it', () => {
+ const state = newState({})
+
+ addNotice(state, { level: 'bad', text: 'older', key: 'a' }, NOW)
+ addNotice(state, { level: 'warn', text: 'newer', key: 'b' }, NOW + 1_000)
+ expect(visibleNotice(state, NOW + 2_000)?.text).toBe('newer')
+ expect(visibleNotice(state, NOW + 1_000 + SHOW_MS)).toBeNull()
+
+ dismissNotices(state)
+ expect(visibleNotice(state, NOW + 2_000)).toBeNull()
+
+ addNotice(state, { level: 'ok', text: 'later', key: 'c' }, NOW + 3_000)
+ state.noticesQuietUntilMs = NOW + 60_000
+ expect(visibleNotice(state, NOW + 4_000)).toBeNull()
+ expect(state.notices.at(-1)?.text).toBe('later')
+ })
+})
+
+describe('the commands', () => {
+ it('parses band, notices and quiet', () => {
+ expect(parseRuflo('band compact')).toEqual({ kind: 'band', arg: 'compact' })
+ expect(parseRuflo('band')).toEqual({ kind: 'band', arg: '' })
+ expect(parseRuflo('notices')).toEqual({ kind: 'notices', isClear: false })
+ expect(parseRuflo('notices clear')).toEqual({ kind: 'notices', isClear: true })
+ expect(parseRuflo('quiet 30')).toEqual({ kind: 'quiet', arg: '30' })
+ })
+
+ it('/ruflo band changes the mode and size for the session, says what it is now, and refuses a word it does not know', () => {
+ const state = newState({})
+
+ expect(bandReply(state, '')).toBe('band: auto (the plugin option) · full (two rows)')
+ expect(bandReply(state, 'off')).toBe('band: off · full (two rows)')
+ expect(bandReply(state, 'compact')).toBe('band: off · compact (one row)')
+ expect(bandReply(state, 'reset')).toBe('band: auto (the plugin option) · full (two rows)')
+ expect(bandReply(state, 'sideways')).toContain('band takes auto, on, off, compact, full or reset')
+ expect(state.bandMode).toBeNull()
+ })
+
+ it('/ruflo notices lists the last ten newest first and marks them seen; clear empties it', () => {
+ const state = newState({})
+
+ expect(noticesReply(state, NOW, false)).toContain('no notices yet')
+ addNotice(state, { level: 'bad', text: '🛡 Anatole blocked 1 call', key: 'a', go: 'secure' }, NOW)
+ addNotice(state, { level: 'ok', text: 'done', key: 'b' }, NOW + 5_000)
+
+ const text = noticesReply(state, NOW + 65_000, false)
+
+ expect(text.split('\n').slice(1)).toEqual([' ✓ done · 1m ago', ' ✖ 🛡 Anatole blocked 1 call · 1m ago · /ruflo secure'])
+ expect(state.notices.every(notice => notice.seen)).toBe(true)
+ expect(noticesReply(state, NOW, true)).toBe('cleared 2 notices')
+ expect(state.notices).toHaveLength(0)
+ })
+
+ it('/ruflo quiet silences the notice row for N minutes, reports what is left, and turns back on', () => {
+ const state = newState({})
+
+ expect(quietReply(state, NOW, '')).toContain('notices are on')
+ expect(quietReply(state, NOW, '30')).toContain('quiet for 30m')
+ expect(state.noticesQuietUntilMs).toBe(NOW + 30 * 60_000)
+ expect(quietReply(state, NOW + 10 * 60_000, '')).toContain('quiet for 20m more')
+ expect(quietReply(state, NOW, 'off')).toBe('notices are on again')
+ expect(state.noticesQuietUntilMs).toBe(0)
+ expect(quietReply(state, NOW, 'soon')).toContain('from 1 to 1440')
+ expect(quietReply(state, NOW, '5000')).toContain('from 1 to 1440')
+ })
+})
+
+describe('the subagent label', () => {
+ it('names a subagent by a short id, not the raw one, and the main agent as claude', () => {
+ const state = newState({})
+
+ expect(agentName(state, undefined)).toBe('claude')
+ expect(agentName(state, 'ae593c2526850fe5a')).toBe('subagent ae593c')
+ })
+})
+
+describe('the band', () => {
+ 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 draw = (state: ReturnType<typeof newState>, onGo?: (view: string) => void, onDismiss?: () => void) => barView(kit as never, state, 150, null, () => undefined, onGo as never, onDismiss) as unknown as El
+ const rowsOf = (band: El) => (band.props.children as El[]).filter(child => child.props.flexDirection === 'row')
+
+ it('colours its border by state: red for a bad notice, amber for something needing a person, green while working, purple when quiet', () => {
+ const attention: BarPart = { text: 'x', tone: 'attention' }
+ const live: BarPart = { text: 'x', tone: 'live' }
+
+ expect(bandTone([], null)).toBe('idle')
+ expect(bandTone([live], null)).toBe('live')
+ expect(bandTone([live, attention], null)).toBe('attention')
+ expect(bandTone([live, attention], { id: 1, atMs: 0, level: 'bad', text: '', key: '', seen: false })).toBe('bad')
+
+ const state = newState({})
+
+ expect(draw(state).props.borderColor).toBe(PANEL.border)
+ addNotice(state, { level: 'bad', text: '🛡 Anatole blocked 1 call', key: 'a', go: 'secure' }, Date.now())
+ expect(draw(state).props.borderColor).toBe(PANEL.bad)
+ })
+
+ it('shows the newest notice on its own row with a link and a dismiss, wired to the callbacks; nothing when quiet or dismissed', () => {
+ const state = newState({})
+ const went: string[] = []
+ let dismissed = 0
+
+ addNotice(state, { level: 'warn', text: '2 new approvals waiting (q)', key: 'approvals', go: 'approvals' }, Date.now())
+
+ const band = draw(state, view => went.push(view), () => (dismissed += 1))
+ const rows = rowsOf(band)
+ const buttons = flat(rows.at(-1)).filter(el => el.kind === 'Button')
+
+ expect(rows).toHaveLength(3)
+ expect(flat(rows.at(-1)).filter(el => el.kind === 'Text').map(el => String(el.props.children)).join('')).toContain('âš  2 new approvals waiting (q)')
+ expect(buttons.map(button => button.props.key)).toEqual(['band-notice-go', 'band-notice-dismiss'])
+ ;(buttons[0]?.props.onPress as () => void)()
+ ;(buttons[1]?.props.onPress as () => void)()
+ expect(went).toEqual(['approvals'])
+ expect(dismissed).toBe(1)
+
+ state.noticesQuietUntilMs = Date.now() + 60_000
+ expect(rowsOf(draw(state))).toHaveLength(2)
+ })
+
+ it('shrinks to one row in compact mode and keeps the notice row', () => {
+ const state = newState({})
+
+ state.bandCompact = true
+ expect(rowsOf(draw(state))).toHaveLength(1)
+ addNotice(state, { level: 'ok', text: 'done', key: 'a' }, Date.now())
+ expect(rowsOf(draw(state))).toHaveLength(2)
+ })
+})