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

ruflo-console 0.33.2: Room and Mods UX — clickable Mods detail, blocked filter, jump from feed entries

ruvc4116f23773d
diff --git a/plugins/ruflo-console/.claude-plugin/plugin.json b/plugins/ruflo-console/.claude-plugin/plugin.json
index 4fae1545e6..8b708b7f4d 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.1",
+ "version": "0.33.2",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-console/README.md b/plugins/ruflo-console/README.md
new file mode 100644
index 0000000000..8d1829bbaf
--- /dev/null
+++ b/plugins/ruflo-console/README.md
@@ -0,0 +1,13 @@
+# ruflo-console
+
+ruflo's cockpit inside Claude Code: the `/ruflo` command, its pages, and a band above the prompt. It reads ruflo's own files; anything it cannot measure reads `n/a`. Design notes: ADR-407 (cockpit), ADR-448 (the Room), ADR-446 (plugin mods).
+
+## Room and Mods
+
+Open it with `/ruflo room` (menu: Safety → The Room).
+
+- **Waiting for a yes**: the one confirm that is pending, with the seconds left to answer it.
+- **The feed**: events, Claude's console actions and what you said, newest first. Filter by who, search, pause, page back. **â›” blocked** shows only what was refused or failed: Claude's actions the control log marked denied or error, and events that say denied. Press a line to open it; an event that came from a page of its own (swarm, claims, learning, plugins, missions) offers a jump button to that page.
+- **Mods**: one line per plugin mod that has written `.claude-flow/<name>-mod/status.json`. Press a line for its detail: what it guards (the file's own `summary`), guard, calls, blocked, the *class* of its last refusal (`secret`, `destructive`, `path`, `network`, `policy`, `other`; the refused text is never kept), `modVersion`, session start, last write, file age, and a stale marker when the last write was an earlier session.
+
+A status file is data, not instructions: it is size-capped, shape-checked (`version: 1` only), and every string is stripped of control and bidi characters and cut to length before it is drawn. `summary`, `modVersion` and `lastDenied` are optional; a mod that does not write them shows "not reported".
diff --git a/plugins/ruflo-console/hooks/data/mods.ts b/plugins/ruflo-console/hooks/data/mods.ts
index 2671d2fe57..a80104120d 100644
--- a/plugins/ruflo-console/hooks/data/mods.ts
+++ b/plugins/ruflo-console/hooks/data/mods.ts
@@ -1,5 +1,5 @@
import { readBounded, under, type ReadCache, type ReaderFs } from './files'
-import { jsonObject } from './parse'
+import { jsonObject, plain } from './parse'
/** The most mod folders read, and the most bytes of one status file (a larger one is refused, not trimmed). */
export const MODS_MAX_FILES = 60
@@ -10,8 +10,15 @@ export const MODS_STALE_MS = 6 * 3_600_000
const ROOT = '.claude-flow'
const DIR = /^[a-z0-9][a-z0-9-]{0,40}-mod$/
-/** One mod's status file (ADR-446): the counters every mod writes; per-plugin counters are not read here. */
-export type ModRow = { name: string; guard: boolean | null; calls: number | null; blocked: number; updatedMs: number | null; startedMs: number | null }
+/** Why a mod last refused something, as a fixed class: the raw reason text (which may name a path or a secret) is never kept. */
+export const DENY_CLASSES = ['secret', 'destructive', 'path', 'network', 'policy', 'other'] as const
+export type DenyClass = (typeof DENY_CLASSES)[number]
+
+/**
+ * One mod's status file (ADR-446): the counters every mod writes; per-plugin counters are not read here. The last four are optional and only
+ * present when the file reported them (modVersion, a one-line summary of what it guards, the class of its last refusal, the file's age source).
+ */
+export type ModRow = { name: string; guard: boolean | null; calls: number | null; blocked: number; updatedMs: number | null; startedMs: number | null; modVersion?: string; summary?: string; lastDenied?: DenyClass; fileMs?: number }
/** What the folder scan found: the rows kept, how many folders were refused (unknown shape, too large, unreadable), and whether the cap cut the list. */
export type ModsFacts = { rows: ModRow[]; refused: number; truncated: boolean }
@@ -20,8 +27,28 @@ export const NO_MODS: ModsFacts = { rows: [], refused: 0, truncated: false }
const whole = (v: unknown): number | null => (typeof v === 'number' && Number.isFinite(v) && v >= 0 ? Math.floor(v) : null)
+const SUMMARY_MAX = 120
+const VERSION = /^[0-9][0-9A-Za-z.+-]{0,15}$/
+const CLASS_TESTS: readonly [DenyClass, RegExp][] = [
+ ['secret', /secret|token|credential|password|api[-_ ]?key|\.env|private[-_ ]?key/i],
+ ['destructive', /destruct|rm -|delete|wipe|force|reset --hard|drop /i],
+ ['path', /path|travers|outside|directory|file/i],
+ ['network', /network|url|host|curl|http|exfil/i],
+ ['policy', /polic|permission|deny|denied|block|guard|rule/i],
+]
+
+/** A mod's own version string when it is a short plain version, else null. */
+export const modVersionOf = (v: unknown): string | null => (typeof v === 'string' && VERSION.test(v) ? v : null)
+
+/** The class of a refusal reason (never the reason itself), or null when the file reported none. */
+export function denyClassOf(v: unknown): DenyClass | null {
+ const text = plain(v, 200)
+
+ return text === '' ? null : (CLASS_TESTS.find(([, test]) => test.test(text))?.[0] ?? 'other')
+}
+
/** Parses one status file; anything that is not version 1 of an object is null (the console never guesses at a shape it does not know). */
-export function parseModStatus(name: string, text: string | null): ModRow | null {
+export function parseModStatus(name: string, text: string | null, fileMs: number | null = null): ModRow | null {
const value = jsonObject(text)
if (value === null || value.version !== 1) return null
@@ -33,6 +60,10 @@ export function parseModStatus(name: string, text: string | null): ModRow | null
blocked: whole(value.blocked) ?? 0,
updatedMs: whole(value.updatedMs),
startedMs: whole(value.startedMs),
+ ...(modVersionOf(value.modVersion) !== null && { modVersion: modVersionOf(value.modVersion) as string }),
+ ...(plain(value.summary, SUMMARY_MAX) !== '' && { summary: plain(value.summary, SUMMARY_MAX) }),
+ ...(denyClassOf(value.lastDenied) !== null && { lastDenied: denyClassOf(value.lastDenied) as DenyClass }),
+ ...(fileMs !== null && fileMs >= 0 && { fileMs }),
}
}
@@ -58,7 +89,7 @@ export async function readMods(fs: ReaderFs, cache: ReadCache, cwd: string): Pro
for (const { name, read } of reads) {
if (read.text === null && read.reason === 'missing') continue
- const row = parseModStatus(name, read.text)
+ const row = parseModStatus(name, read.text, 'mtimeMs' in read ? read.mtimeMs : null)
if (row === null) refused += 1
else rows.push(row)
diff --git a/plugins/ruflo-console/hooks/data/room.ts b/plugins/ruflo-console/hooks/data/room.ts
index d4156384aa..ef921c83e9 100644
--- a/plugins/ruflo-console/hooks/data/room.ts
+++ b/plugins/ruflo-console/hooks/data/room.ts
@@ -36,6 +36,12 @@ export function saidStatus(said: Said, pending: Pending, outcome: Outcome): { te
return { text: 'not confirmed', tone: 'info' }
}
+/** The page an event kind belongs on, for the feed's jump; kinds with no page of their own have none. */
+export const VIEW_OF_KIND: Readonly<Record<string, string>> = { swarm: 'swarm', claims: 'claims', learning: 'learning', mods: 'plugins', missions: 'missions', federation: 'federation' }
+
+/** Refused or failed: Claude's console actions the control log marked denied or error, and events that say something was denied. */
+export const isBlocked = (item: RoomItem): boolean => (item.source === 'claude' ? item.tone === 'bad' : item.source === 'event' && /denied/i.test(item.text))
+
export type FeedInput = {
events: readonly ConsoleEvent[]
log: readonly ControlEntry[]
@@ -44,6 +50,8 @@ export type FeedInput = {
outcome: Outcome
source: 'all' | RoomSource
query: string
+ /** Only what was refused or failed (see isBlocked). */
+ blocked?: boolean
/** The newest time shown: set while paused so the tail holds still. */
untilMs: number | null
}
@@ -69,7 +77,9 @@ export function roomFeed(input: FeedInput): RoomItem[] {
const query = input.query.trim().toLowerCase()
const kept = query === '' ? out : out.filter(item => item.text.toLowerCase().includes(query) || item.who.includes(query))
- return kept.sort((a, b) => b.atMs - a.atMs).slice(0, ROOM_MAX)
+ const shown = input.blocked === true ? kept.filter(isBlocked) : kept
+
+ return shown.sort((a, b) => b.atMs - a.atMs).slice(0, ROOM_MAX)
}
/** The banner for the one pending confirm: what, what it expects, where it was raised and how much of the window is left. */
diff --git a/plugins/ruflo-console/hooks/help-topics-more.ts b/plugins/ruflo-console/hooks/help-topics-more.ts
index 3daecf84bd..16b5e29997 100644
--- a/plugins/ruflo-console/hooks/help-topics-more.ts
+++ b/plugins/ruflo-console/hooks/help-topics-more.ts
@@ -88,8 +88,10 @@ export const MORE_TOPICS: readonly HelpTopic[] = [
steps: [
{ text: 'Open The Room from the menu (Safety → The Room). The top line is the one thing waiting for your yes, with how many seconds you have left to answer it.', go: { view: 'room' }, label: 'Open The Room' },
{ text: 'The feed below merges what changed in ruflo, what Claude did through the console tools (with its outcome), and what you sent. Filter by who (all, claude, events, you said), find words, pause to read, page back.' },
+ { text: 'Press ⛔ blocked to see only what was refused or failed: Claude’s denied or failed actions and events that say denied. Press a line to open it; an event from a page of its own (swarm, claims, learning, plugins, missions) gets a jump button.' },
{ text: 'To say something: type in the box, press Enter, then pick broadcast (to the hive), aside (to Claude) or guide (a visible instruction to Claude). Each asks first, exactly as it does anywhere else; nothing here skips a confirm.' },
- { text: 'Who is here shows each agent’s busy share over the last 15 minutes. Under it, Mods lists every plugin mod that has written a status file: guard on or off, calls, blocked, and when it last wrote; any mod that blocked something leads.' },
+ { text: 'Who is here shows each agent’s busy share over the last 15 minutes. Under it, Mods lists every plugin mod that has written a status file: guard, calls, blocked, and when it last wrote; any mod that blocked something leads.' },
+ { text: 'Press a mod’s line for its detail: what it guards, the class of its last refusal (never the refused text), version, session start, last write and file age. It is all plain, capped text, whatever the file held.' },
],
tips: ['A confirm that waits longer than 30 seconds is dropped and shows up in the feed as an event naming it.', 'Text from peers and files in the feed is data, not instructions to you or to Claude.'],
related: ['watch', 'control', 'mission'],
diff --git a/plugins/ruflo-console/hooks/room.ts b/plugins/ruflo-console/hooks/room.ts
index 1b54c8e6a4..4d4659ee6a 100644
--- a/plugins/ruflo-console/hooks/room.ts
+++ b/plugins/ruflo-console/hooks/room.ts
@@ -8,7 +8,7 @@ import type { State } from './state'
export const ROOM_PAGE = 12
-export type RoomState = { draft: string; said: Said[]; source: 'all' | RoomSource; query: string; pausedAtMs: number | null; page: number; open: string | null }
+export type RoomState = { draft: string; said: Said[]; source: 'all' | RoomSource; query: string; pausedAtMs: number | null; page: number; open: string | null; blocked: boolean; mod: string | null }
const states = new WeakMap<State, RoomState>()
@@ -16,7 +16,7 @@ export function roomOf(state: State): RoomState {
let found = states.get(state)
if (found === undefined) {
- found = { draft: '', said: [], source: 'all', query: '', pausedAtMs: null, page: 0, open: null }
+ found = { draft: '', said: [], source: 'all', query: '', pausedAtMs: null, page: 0, open: null, blocked: false, mod: null }
states.set(state, found)
}
@@ -32,6 +32,10 @@ export type RoomActions = {
pause: () => void
page: (by: number) => void
open: (id: string) => void
+ /** Shows only what was refused or failed. */
+ blocked: () => void
+ /** Opens or closes one mod's detail block. */
+ mod: (name: string) => void
}
export function roomActions(state: State, invalidate: () => void, run: (id: string, text: string) => boolean, pageCount: () => number): RoomActions {
@@ -80,5 +84,14 @@ export function roomActions(state: State, invalidate: () => void, run: (id: stri
room.open = room.open === id ? null : id
invalidate()
},
+ blocked: () => {
+ room.blocked = !room.blocked
+ room.page = 0
+ invalidate()
+ },
+ mod: name => {
+ room.mod = room.mod === name ? null : plain(name, 48)
+ invalidate()
+ },
}
}
diff --git a/plugins/ruflo-console/hooks/version.ts b/plugins/ruflo-console/hooks/version.ts
index c282fe8640..1afc8e79d8 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.1'
+export const CONSOLE_VERSION = '0.33.2'
diff --git a/plugins/ruflo-console/hooks/views/mods.ts b/plugins/ruflo-console/hooks/views/mods.ts
index b040fc0a37..9430ebfae0 100644
--- a/plugins/ruflo-console/hooks/views/mods.ts
+++ b/plugins/ruflo-console/hooks/views/mods.ts
@@ -1,16 +1,40 @@
import type { RenderElement } from 'claude-code'
-import { isStale, NO_MODS } from '../data/mods'
+import { isStale, NO_MODS, type ModRow } from '../data/mods'
+import { plain } from '../data/parse'
+import { roomOf } from '../room'
import { ago, clip, count, row, rule, text, THEME, type Ctx } from './common'
const SHOWN = 12
+const REASON_WORDS: Record<string, string> = { 'secret': 'a secret or credential', 'destructive': 'a destructive command', 'path': 'a file path outside what is allowed', 'network': 'a network call', 'policy': 'a policy rule', 'other': 'a rule of its own' }
+
+/** The detail block for one mod: every field its status file reported, as plain capped text; fields it did not report say so. */
+export function modDetail(ctx: Ctx, mod: ModRow): RenderElement[] {
+ const stale = isStale(mod, ctx.nowMs)
+ const when = (ms: number | null | undefined) => (ms === null || ms === undefined ? 'not reported' : `${ago(ms, ctx.nowMs)} (${new Date(ms).toISOString()})`)
+ const line = (label: string, value: string, color?: string) => text(ctx, ` ${label.padEnd(13)}${plain(value, Math.max(20, ctx.columns - 22))}`, color === undefined ? { dimColor: true } : { color })
+
+ return [
+ line('guards', mod.summary ?? 'no summary reported by this mod'),
+ line('guard', mod.guard === null ? 'not reported' : mod.guard ? 'on' : 'off'),
+ line('calls', mod.calls === null ? 'not reported' : count(mod.calls)),
+ line('blocked', count(mod.blocked), mod.blocked > 0 ? THEME.warn : undefined),
+ line('last refusal', mod.lastDenied === undefined ? (mod.blocked > 0 ? 'class not reported' : 'none') : `${mod.lastDenied}: it asked for ${REASON_WORDS[mod.lastDenied] ?? 'a rule of its own'}`),
+ line('version', mod.modVersion ?? 'not reported'),
+ line('session began', when(mod.startedMs)),
+ line('last wrote', `${when(mod.updatedMs)}${stale ? ' · stale: an earlier session' : ''}`),
+ line('file age', mod.fileMs === undefined ? 'not reported' : ago(mod.fileMs, ctx.nowMs)),
+ ]
+}
+
/**
* The "Mods" section (ADR-446): one line per per-plugin mod that has written `.claude-flow/<short>-mod/status.json`: guard on or off, calls, blocked,
* when it last wrote, a marker when that was an earlier session. Any mod that has blocked something leads. It reads the files; it never calls a mod.
*/
export function modsRows(ctx: Ctx): RenderElement[] {
const { rows, refused, truncated } = ctx.state.snapshot?.mods ?? NO_MODS
+ const open = roomOf(ctx.state).mod
const blocked = rows.filter(mod => mod.blocked > 0).length
const out: RenderElement[] = [rule(ctx, 'Mods', rows.length === 0 ? 'none reporting' : `${rows.length} reporting${blocked > 0 ? ` · ${blocked} blocked something` : ''}`)]
@@ -21,11 +45,13 @@ export function modsRows(ctx: Ctx): RenderElement[] {
for (const [i, mod] of rows.slice(0, SHOWN).entries()) {
const stale = isStale(mod, ctx.nowMs)
+ const isOpen = open === mod.name
+
out.push(
row(
ctx,
[
- ctx.kit.Text({ bold: true, color: mod.blocked > 0 ? THEME.warn : THEME.head, children: ` ${clip(mod.name, 22).padEnd(22)}` }),
+ ctx.kit.Button({ key: `mod-open-${mod.name}`, label: ` ${isOpen ? 'â–ľ' : 'â–¸'} ${clip(mod.name, 22).padEnd(22)}`, plain: true, onPress: () => ctx.act.room.mod(mod.name) }),
ctx.kit.Text({ color: mod.guard === true ? THEME.ok : undefined, dimColor: mod.guard !== true, children: ` guard ${mod.guard === null ? '–' : mod.guard ? 'on ' : 'off'}` }),
ctx.kit.Text({ children: ` · calls ${mod.calls === null ? '–' : count(mod.calls)}` }),
ctx.kit.Text({ color: mod.blocked > 0 ? THEME.warn : undefined, dimColor: mod.blocked === 0, children: ` · blocked ${count(mod.blocked)}` }),
@@ -34,6 +60,8 @@ export function modsRows(ctx: Ctx): RenderElement[] {
`mod-${i}-${mod.name}`,
),
)
+
+ if (isOpen) out.push(...modDetail(ctx, mod))
}
if (rows.length > SHOWN) out.push(text(ctx, ` +${rows.length - SHOWN} more mods reporting`, { dimColor: true }))
diff --git a/plugins/ruflo-console/hooks/views/room.ts b/plugins/ruflo-console/hooks/views/room.ts
index 4933d5c165..2a54f8a7bf 100644
--- a/plugins/ruflo-console/hooks/views/room.ts
+++ b/plugins/ruflo-console/hooks/views/room.ts
@@ -1,10 +1,11 @@
import type { RenderElement } from 'claude-code'
-import { pendingBanner, roomFeed, SAY_IDS, SAY_LABEL, type RoomItem, type RoomSource } from '../data/room'
+import { isBlocked, pendingBanner, roomFeed, SAY_IDS, SAY_LABEL, VIEW_OF_KIND, type RoomItem, type RoomSource } from '../data/room'
import { PENDING_TTL_MS } from '../runner'
import { ROOM_PAGE, roomOf } from '../room'
import { ago, button, clip, col, row, rule, text, THEME, type Ctx } from './common'
import { lanesOf } from './frames'
+import { VIEWS, type ViewId } from '../state'
import { statsOf } from './manage'
import { modsRows } from './mods'
@@ -24,7 +25,15 @@ export function roomShown(ctx: Pick<Ctx, 'state'>): RoomItem[] {
const { state } = ctx
const room = roomOf(state)
- return roomFeed({ events: state.events, log: state.control.log, said: room.said, pending: state.pending, outcome: state.outcome, source: room.source, query: room.query, untilMs: room.pausedAtMs })
+ return roomFeed({ events: state.events, log: state.control.log, said: room.said, pending: state.pending, outcome: state.outcome, source: room.source, query: room.query, untilMs: room.pausedAtMs, blocked: room.blocked })
+}
+
+/** How many items the feed holds that were refused or failed, whatever the filters: the number on the blocked chip. */
+export function roomBlockedCount(ctx: Pick<Ctx, 'state'>): number {
+ const { state } = ctx
+ const room = roomOf(state)
+
+ return roomFeed({ events: state.events, log: state.control.log, said: room.said, pending: state.pending, outcome: state.outcome, source: 'all', query: '', untilMs: room.pausedAtMs }).filter(isBlocked).length
}
export const roomPages = (state: Ctx['state']): number => Math.max(1, Math.ceil(roomShown({ state }).length / ROOM_PAGE))
@@ -64,6 +73,7 @@ export function roomView(ctx: Ctx): RenderElement {
ctx,
[
...SOURCES.map(source => chip(ctx, `room-src-${source.id}`, source.label, room.source === source.id, () => ctx.act.room.source(source.id))),
+ chip(ctx, 'room-blocked', `â›” blocked ${roomBlockedCount(ctx)}`, room.blocked, ctx.act.room.blocked),
ctx.kit.Button({ key: 'room-pause', label: room.pausedAtMs === null ? ' ⏸ pause ' : ' ▶ resume ', ...(room.pausedAtMs === null ? { plain: true as const } : { variant: 'primary' as const }), onPress: ctx.act.room.pause }),
...(room.query === '' ? [] : [ctx.kit.Button({ key: 'room-clear', label: ' âś• clear find ', plain: true, dimColor: true, onPress: () => ctx.act.room.query('') })]),
],
@@ -89,7 +99,13 @@ export function roomView(ctx: Ctx): RenderElement {
),
)
- if (isOpen) rows.push(text(ctx, ` ${item.text} · ${new Date(item.atMs).toISOString()}`, { dimColor: true }))
+ if (isOpen) {
+ const target = item.kind === undefined ? undefined : VIEW_OF_KIND[item.kind]
+ const view = target === undefined ? undefined : VIEWS.find(entry => entry.id === target)
+
+ rows.push(text(ctx, ` ${item.text} · ${new Date(item.atMs).toISOString()}`, { dimColor: true }))
+ rows.push(row(ctx, [text(ctx, ` ${item.source === 'event' ? `event: ${item.kind ?? 'unknown'}` : item.source === 'claude' ? 'a console action by Claude' : 'what you said'}${isBlocked(item) ? ' · refused or failed' : ''}`, { dimColor: true }), ...(view === undefined ? [] : [button(ctx, `room-jump-${item.id}`, `jump to ${view.label}`, () => ctx.act.view(view.id as ViewId))])], `room-detail-${item.id}`))
+ }
}
if (pages > 1) rows.push(row(ctx, [text(ctx, ` page ${page + 1}/${pages} `, { dimColor: true }), ...(page < pages - 1 ? [button(ctx, 'room-older', 'older â–¸', () => ctx.act.room.page(1))] : []), ...(page > 0 ? [button(ctx, 'room-newer', 'â—‚ newer', () => ctx.act.room.page(-1))] : [])], 'room-pages'))
diff --git a/plugins/ruflo-console/scripts/smoke.sh b/plugins/ruflo-console/scripts/smoke.sh
index 26efac8e36..19f0c09c3b 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.1"
+step "1. plugin.json declares ruflo-console 0.33.2"
grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \
- && grep -q '"version": "0.33.1"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
+ && grep -q '"version": "0.33.2"' "$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/mods-section.spec.ts b/plugins/ruflo-console/tests/mods-section.spec.ts
index a46051e874..07463922b3 100644
--- a/plugins/ruflo-console/tests/mods-section.spec.ts
+++ b/plugins/ruflo-console/tests/mods-section.spec.ts
@@ -8,8 +8,9 @@ import type { ReaderFs } from '../hooks/data/files'
import { newState } from '../hooks/state'
import { readSnapshot } from '../hooks/data/snapshot'
import type { Actions } from '../hooks/views/common'
+import { roomOf } from '../hooks/room'
import { viewText } from '../hooks/views/pane'
-import { isStale, MODS_MAX_BYTES, MODS_MAX_FILES, MODS_STALE_MS, orderMods, parseModStatus, readMods, type ModRow } from '../hooks/data/mods'
+import { denyClassOf, isStale, MODS_MAX_BYTES, MODS_MAX_FILES, MODS_STALE_MS, orderMods, parseModStatus, readMods, type ModRow } from '../hooks/data/mods'
const status = (extra: Record<string, unknown> = {}) => JSON.stringify({ version: 1, updatedMs: 1_000, calls: 5, blocked: 0, startedMs: 500, guard: true, ...extra })
const row = (name: string, blocked: number, updatedMs: number | null): ModRow => ({ name, guard: true, calls: 1, blocked, updatedMs, startedMs: null })
@@ -135,3 +136,66 @@ describe('the Mods section on the pages', () => {
expect(overview).toContain('The Room: Mods')
})
})
+
+describe('the Mods detail block', () => {
+ const NOW = 30_000_000
+ const act = new Proxy(() => undefined, { get: () => act, apply: () => undefined }) as unknown as Actions
+ const empty: ReaderFs = { read: () => Promise.reject(new Error('ENOENT')), stat: () => Promise.reject(new Error('ENOENT')), list: () => Promise.reject(new Error('ENOENT')) }
+ const draw = async (rows: ModRow[], open: string | null) => {
+ const state = newState({})
+ const snapshot = await readSnapshot(empty, new Map(), '/work', '/home/dev', {}, 0)
+
+ state.snapshot = { ...snapshot, mods: { rows: orderMods(rows), refused: 0, truncated: false } }
+ state.view = 'room'
+ roomOf(state).mod = open
+
+ return viewText({ state, nowMs: NOW, columns: 100, act }, 'room')
+ }
+
+ it('reads the optional fields and keeps only a class of the last refusal, never its text', () => {
+ const parsed = parseModStatus('docs-mod', status({ modVersion: '1.2.3', summary: 'blocks writes to .env files', lastDenied: 'read of /home/u/.ssh/id_rsa private key sk-live-123' }), 7000)
+
+ expect(parsed).toMatchObject({ modVersion: '1.2.3', summary: 'blocks writes to .env files', lastDenied: 'secret', fileMs: 7000 })
+ expect(JSON.stringify(parsed)).not.toContain('id_rsa')
+ expect(denyClassOf('a destructive delete')).toBe('destructive')
+ expect(denyClassOf('outside the project directory')).toBe('path')
+ expect(denyClassOf('xyzzy')).toBe('other')
+ expect(denyClassOf('')).toBeNull()
+ expect(denyClassOf(42)).toBeNull()
+ })
+
+ it('drops a hostile version and caps and cleans the summary', () => {
+ const parsed = parseModStatus('docs-mod', status({ modVersion: '\u001b[31m9'.repeat(5), summary: `\u001b[31mred\u202e${'x'.repeat(5000)}` }))
+
+ expect(parsed?.modVersion).toBeUndefined()
+ expect(parsed?.summary?.length).toBeLessThanOrEqual(120)
+ expect(parsed?.summary).not.toMatch(/[\u0000-\u001f\u202e]/)
+ })
+
+ it('shows nothing extra closed, and every reported field open; an unreported one says so', async () => {
+ const mod: ModRow = { ...row('docs', 3, NOW - 60_000), startedMs: NOW - 3_600_000, modVersion: '1.2.3', summary: 'blocks writes to .env files', lastDenied: 'secret', fileMs: NOW - 90_000 }
+
+ expect(await draw([mod], null)).not.toContain('last refusal')
+ expect(await draw([mod], null)).toContain('â–¸ docs')
+
+ const open = await draw([mod], 'docs')
+
+ expect(open).toContain('â–ľ docs')
+ expect(open).toMatch(/guards\s+blocks writes to .env files/)
+ expect(open).toMatch(/last refusal\s+secret: it asked for a secret or credential/)
+ expect(open).toMatch(/version\s+1.2.3/)
+ expect(open).toMatch(/file age\s+1m/)
+ expect(await draw([row('plain', 0, NOW - 1000)], 'plain')).toMatch(/guards\s+no summary reported by this mod/)
+ })
+
+ it('renders a hostile status file safely, however it was read', async () => {
+ const text = JSON.stringify({ version: 1, updatedMs: NOW, guard: true, calls: 1e308, blocked: 2, modVersion: '99'.repeat(30), summary: `\u001b[2J\u202e${'A'.repeat(9000)}`, lastDenied: '\u001b]0;pwn\u0007 token' })
+ const mod = parseModStatus('evil-mod', text, 5) as ModRow
+ const drawn = await draw([mod], 'evil')
+
+ expect(drawn).not.toMatch(/[\u0000-\u0008\u000b-\u001f\u007f\u202e]/)
+ expect(drawn).toContain('secret: it asked for a secret or credential')
+ expect(drawn).not.toContain('pwn')
+ expect(drawn.split('\n').every(line => line.length < 400)).toBe(true)
+ })
+})
diff --git a/plugins/ruflo-console/tests/room-ux.test.ts b/plugins/ruflo-console/tests/room-ux.test.ts
new file mode 100644
index 0000000000..d54a2b9286
--- /dev/null
+++ b/plugins/ruflo-console/tests/room-ux.test.ts
@@ -0,0 +1,60 @@
+import { describe, expect, mock, test } from 'claude-code/testing'
+
+import { RUFLO_FILES } from './fixtures/ruflo-run'
+import { command, elementsOf, keyOf, paneAt, PLUGIN, SESSION, textOf, worldOf } from './fixtures/world'
+
+const NOW = Date.now()
+const STATUS = (extra: Record<string, unknown>) => JSON.stringify({ version: 1, updatedMs: NOW - 5000, guard: true, calls: 7, blocked: 2, startedMs: NOW - 600_000, ...extra })
+// A good mod, and a hostile one: escape sequences, a bidi override, a huge summary, a nonsense version.
+const FILES = {
+ ...RUFLO_FILES,
+ '.claude-flow/docs-mod/status.json': STATUS({ modVersion: '1.4.0', summary: 'blocks writes to .env files', lastDenied: 'read of an api key' }),
+ '.claude-flow/evil-mod/status.json': STATUS({ modVersion: '\u001b[2J99', summary: `\u001b[31mred‮${'A'.repeat(4000)}`, lastDenied: '\u001b]0;pwn\u0007' }),
+}
+
+describe('the Room: Mods rows and the blocked chip', () => {
+ test('each Mods row is a button that opens its detail, and a hostile file renders as plain text', { options: { boot: false } }, async ($, on) => {
+ worldOf(on, FILES)
+ mock.clock(on)
+ await $.session.start(SESSION)
+ await $.command.run(command('room'))
+
+ const pane = await $.ui.mount({ ...paneAt(120), surface: 'terminal' as const, plugin: PLUGIN })
+ const before = textOf(await pane.drawn())
+
+ expect(before).toContain('2 reporting')
+ expect(before).not.toContain('last refusal')
+ await pane.press({ key: 'mod-open-docs' })
+
+ const open = textOf(await pane.drawn())
+
+ expect(open).toMatch(/guards\s+blocks writes to .env files/)
+ expect(open).toMatch(/last refusal\s+secret/)
+ expect(open).toMatch(/version\s+1.4.0/)
+ await pane.press({ key: 'mod-open-docs' })
+ expect(textOf(await pane.drawn())).not.toContain('last refusal')
+ await pane.press({ key: 'mod-open-evil' })
+
+ const hostile = textOf(await pane.drawn())
+
+ expect(hostile).not.toMatch(/[\u0000-\u0008\u000b-\u001f\u007f‮]/)
+ expect(hostile).not.toContain('pwn')
+ await pane.unmount()
+ })
+
+ test('the blocked chip is reachable, shows its count, and toggles', { options: { boot: false } }, async ($, on) => {
+ worldOf(on, FILES)
+ mock.clock(on)
+ await $.session.start(SESSION)
+ await $.command.run(command('room'))
+
+ const pane = await $.ui.mount({ ...paneAt(120), surface: 'terminal' as const, plugin: PLUGIN })
+ const tree = await pane.drawn()
+
+ expect(elementsOf(tree, 'Button').map(keyOf)).toContain('room-blocked')
+ expect(textOf(tree)).toContain('â—‹ â›” blocked')
+ await pane.press({ key: 'room-blocked' })
+ expect(textOf(await pane.drawn())).toContain('â—Ź â›” blocked')
+ await pane.unmount()
+ })
+})
diff --git a/plugins/ruflo-console/tests/room.spec.ts b/plugins/ruflo-console/tests/room.spec.ts
index 1c10c1ab0f..9260927245 100644
--- a/plugins/ruflo-console/tests/room.spec.ts
+++ b/plugins/ruflo-console/tests/room.spec.ts
@@ -6,7 +6,9 @@
import { describe, expect, it } from 'vitest'
import type { ConsoleEvent } from '../hooks/data/events'
-import { DRAFT_MAX, pendingBanner, ROOM_MAX, roomFeed, SAID_MAX, SAY_IDS, saidStatus, type Said } from '../hooks/data/room'
+import { DRAFT_MAX, isBlocked, pendingBanner, VIEW_OF_KIND, ROOM_MAX, roomFeed, SAID_MAX, SAY_IDS, saidStatus, type Said } from '../hooks/data/room'
+import type { Actions } from '../hooks/views/common'
+import { viewText } from '../hooks/views/pane'
import { roomActions, roomOf } from '../hooks/room'
import { newState, VIEWS } from '../hooks/state'
import type { ControlEntry } from '../hooks/state'
@@ -163,6 +165,60 @@ describe('cost', () => {
})
})
+describe('the blocked filter and the jump', () => {
+ it('keeps only what Claude was refused or failed, and events that say denied', () => {
+ const input = { ...base, events: [ev(1000, 'swarm up'), ev(2000, 'bash denied by permission rule', 'mods')], log: [ctl(3000, 'open a', 'ok'), ctl(4000, 'run b', 'denied'), ctl(5000, 'run c', 'error'), ctl(6000, 'wait d', 'waiting')], said: [{ atMs: 7000, id: 'broadcast' as const, text: 'x', label: null }] }
+ const blocked = roomFeed({ ...input, blocked: true })
+
+ expect(blocked.map(item => item.atMs)).toEqual([5000, 4000, 2000])
+ expect(blocked.every(isBlocked)).toBe(true)
+ expect(roomFeed({ ...input, blocked: true, source: 'event' }).map(item => item.atMs)).toEqual([2000])
+ expect(roomFeed(input)).toHaveLength(7)
+ })
+
+ it('maps an event kind to the page that raised it, and nothing else', () => {
+ expect(VIEW_OF_KIND).toMatchObject({ swarm: 'swarm', claims: 'claims', learning: 'learning', mods: 'plugins', missions: 'missions' })
+ expect(VIEW_OF_KIND.tools).toBeUndefined()
+ expect(Object.values(VIEW_OF_KIND).every(id => VIEWS.some(view => view.id === id))).toBe(true)
+ })
+
+ it('an open event entry names its kind and offers a jump to the page that raised it; one with no page offers none', () => {
+ const act = new Proxy(() => undefined, { get: () => act, apply: () => undefined }) as unknown as Actions
+ const draw = (kind: ConsoleEvent['kind'], text: string) => {
+ const state = newState({})
+
+ state.view = 'room'
+ state.events = [ev(1000, text, kind)]
+ roomOf(state).open = `event:1000:${text.length}`
+
+ return viewText({ state, nowMs: 5000, columns: 100, act }, 'room')
+ }
+
+ expect(draw('mods', 'bash denied')).toMatch(/event: mods · refused or failed/)
+ expect(draw('mods', 'bash denied')).toContain('jump to Plugins')
+ expect(draw('swarm', 'swarm up')).toContain('jump to Swarm')
+ expect(draw('tools', 'a tool ran')).not.toContain('jump to')
+ })
+
+ it('the toggle resets the page and the mod opens and closes', () => {
+ const state = newState({})
+ const act = roomActions(state, () => undefined, () => true, () => 3)
+ const room = roomOf(state)
+
+ act.page(2)
+ act.blocked()
+ expect(room).toMatchObject({ blocked: true, page: 0 })
+ act.blocked()
+ expect(room.blocked).toBe(false)
+ act.mod('docs')
+ expect(room.mod).toBe('docs')
+ act.mod('docs')
+ expect(room.mod).toBeNull()
+ act.mod('x'.repeat(500))
+ expect(room.mod?.length).toBeLessThanOrEqual(48)
+ })
+})
+
describe('the page is wired', () => {
it('is a named-only page (every letter is taken) with a blurb and room for the feed', () => {
const view = VIEWS.find(entry => entry.id === 'room')
diff --git a/scripts/ci-test-baseline.txt b/scripts/ci-test-baseline.txt
index 8f6b348b15..3070d4107c 100644
--- a/scripts/ci-test-baseline.txt
+++ b/scripts/ci-test-baseline.txt
@@ -174,6 +174,7 @@ plugins/ruflo-console/tests/watch.test.ts
plugins/ruflo-console/tests/missions.test.ts
plugins/ruflo-console/tests/settings.test.ts
plugins/ruflo-console/tests/plugin-catalog.test.ts
+plugins/ruflo-console/tests/room-ux.test.ts
plugins/ruflo-console/tests/sweep.test.ts
plugins/ruflo-console/tests/devtools.test.ts
plugins/ruflo-console/tests/evolve.test.ts