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): auto-open only in a ruflo project, remember a person's close, every action argv tested

ruvb84cd3b777d3
diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json
index 9670837790..adb6a8c400 100644
--- a/.claude-plugin/marketplace.json
+++ b/.claude-plugin/marketplace.json
@@ -229,7 +229,7 @@
{
"name": "ruflo-console",
"source": "./plugins/ruflo-console",
- "description": "Early access: ruflo's real-time cockpit as a Claude Code mod (function hooks) \u2014 eight views (overview, swarm topology graph, claims board with confirm-gated actions, federation, plugins and marketplace freshness, self-learning, MetaHarness, memory and cost) plus a band above the prompt; reads ruflo's files and the CLI's local JSON, no network by default"
+ "description": "Early access: ruflo's cockpit as a Claude Code mod (function hooks) and the one /ruflo command for every ruflo mod \u2014 overview with health alerts, swarm topology, claims flow, federation map, plugin health, learning pipeline, MetaHarness radar, memory, cost gauge, agent timeline, approvals and events; a command palette for confirm-gated actions through the ruflo CLI; auto-opens where it docks; no network by default"
}
]
}
diff --git a/plugins/ruflo-console/hooks/controller.ts b/plugins/ruflo-console/hooks/controller.ts
index fb509bc0e3..a74e7fbfde 100644
--- a/plugins/ruflo-console/hooks/controller.ts
+++ b/plugins/ruflo-console/hooks/controller.ts
@@ -33,6 +33,8 @@ export type Controller = {
open: (focus?: boolean) => Promise<{ isPlaced: boolean; reason: string }>
/** At session start, with `panel: auto`: opens where it docks, never taking the keys; else leaves a hint. */
autoOpen: () => void
+ /** The person closed the pane (Esc, its mark): auto-open stands down until /ruflo opens it again. */
+ closedByPerson: () => void
close: () => Promise<void>
setView: (view: State['view']) => void
drill: (agentId: string) => void
@@ -308,7 +310,7 @@ export function createController(state: State, host: Host): Controller {
}
function autoOpen(): void {
- if (state.options.panel !== 'auto' || state.pane.isOpen || state.pane.isClosedByPerson || state.pane.autoTried) return
+ if (state.options.panel !== 'auto' || state.snapshot?.isRufloProject !== true || state.pane.isOpen || state.pane.isClosedByPerson || state.pane.autoTried) return
state.pane.autoTried = true
// From a timer, never a render hook; without `focus`, so the prompt keeps the keys. The engine seats an unasked pane
@@ -404,5 +406,10 @@ export function createController(state: State, host: Host): Controller {
record(state.events, [{ atMs: Date.now(), kind: 'tools', text: `${who === 'main' ? 'claude' : who}: ${plain(tool, 40)}` }])
}
- return { refresh, probe, start, resume, stop, open, autoOpen, close, setView, drill, animate, noteToolCall, actions, runner, markFrame }
+ const closedByPerson = () => {
+ state.pane.isClosedByPerson = true
+ persist()
+ }
+
+ return { refresh, probe, start, resume, stop, open, autoOpen, closedByPerson, close, setView, drill, animate, noteToolCall, actions, runner, markFrame }
}
diff --git a/plugins/ruflo-console/hooks/gfx/flow.ts b/plugins/ruflo-console/hooks/gfx/flow.ts
index adb5604ba4..8c276563fc 100644
--- a/plugins/ruflo-console/hooks/gfx/flow.ts
+++ b/plugins/ruflo-console/hooks/gfx/flow.ts
@@ -4,7 +4,7 @@
* for an instant on the real clock. The ring is data: time left to `expiresAt` where ruflo set one, else the claim's
* age on a 24 h scale; an expired claim's ring blinks.
*/
-import type { ClaimRecord, TaskRecord } from '../data/parse'
+import type { AgentRecord, ClaimRecord, TaskRecord } from '../data/parse'
import { COLOR, Grid, mix } from './raster'
export const LANES = ['open', 'claimed', 'working', 'done', 'stealable'] as const
@@ -26,7 +26,10 @@ export function laneOf(claim: ClaimRecord): LaneId {
return 'working'
}
-export function flowModelOf(claims: readonly ClaimRecord[], openTasks: readonly TaskRecord[]): FlowCard[] {
+/** Cards for the lanes; a handoff names its target by the agent's name where the store has one. */
+export function flowModelOf(claims: readonly ClaimRecord[], openTasks: readonly TaskRecord[], agents: readonly AgentRecord[] = []): FlowCard[] {
+ const nameOf = (id: string) => agents.find(agent => agent.id === id)?.name ?? agents.find(agent => agent.id === id)?.type ?? id
+
return [
...openTasks.slice(0, 40).map(task => ({ id: task.id, owner: task.description || task.type, lane: 'open' as const })),
...claims.slice(0, 200).map(claim => ({
@@ -35,7 +38,7 @@ export function flowModelOf(claims: readonly ClaimRecord[], openTasks: readonly
lane: laneOf(claim),
...(claim.claimedAtMs !== undefined && { claimedAtMs: claim.claimedAtMs }),
...(claim.expiresAtMs !== undefined && { expiresAtMs: claim.expiresAtMs }),
- ...(claim.handoffTo !== undefined && { handoffTo: claim.handoffTo }),
+ ...(claim.handoffTo !== undefined && { handoffTo: nameOf(claim.handoffTo) }),
...(claim.progress !== undefined && { progress: claim.progress }),
})),
]
diff --git a/plugins/ruflo-console/hooks/gfx/maps.ts b/plugins/ruflo-console/hooks/gfx/maps.ts
index f289baf60b..ec1c91111f 100644
--- a/plugins/ruflo-console/hooks/gfx/maps.ts
+++ b/plugins/ruflo-console/hooks/gfx/maps.ts
@@ -95,7 +95,7 @@ export type Lane = { label: string; spans: { fromMs: number; toMs: number; busy:
* Agents × time: a row per agent over [fromMs, toMs], busy stretches amber, idle blue, a white tick per tool call the
* console saw. Only what was observed since the console loaded is drawn; before that the row is blank.
*/
-export function ganttPicture(lanes: readonly Lane[], columns: number, fromMs: number, toMs: number, nowMs: number): Grid {
+export function ganttPicture(lanes: readonly Lane[], columns: number, fromMs: number, toMs: number): Grid {
const rows = Math.max(2, Math.min(lanes.length, 30) + 1)
const grid = new Grid(columns, rows)
const labelWidth = Math.min(16, Math.max(6, ...lanes.map(lane => lane.label.length + 1)))
@@ -104,8 +104,7 @@ export function ganttPicture(lanes: readonly Lane[], columns: number, fromMs: nu
const minutes = Math.max(1, Math.round((toMs - fromMs) / 60_000))
grid.text(labelWidth, 0, `${minutes}m ago`, COLOR.dim)
- grid.text(columns - 3, 0, 'now', COLOR.dim)
- grid.set(Math.min(columns - 1, xOf(nowMs)), 0, 'â–¾', COLOR.accent)
+ grid.text(columns - 4, 0, 'nowâ–¾', COLOR.dim)
lanes.slice(0, rows - 1).forEach((lane, i) => {
const y = i + 1
diff --git a/plugins/ruflo-console/hooks/palette.ts b/plugins/ruflo-console/hooks/palette.ts
index 612024e283..5b38c583a3 100644
--- a/plugins/ruflo-console/hooks/palette.ts
+++ b/plugins/ruflo-console/hooks/palette.ts
@@ -76,7 +76,7 @@ export function paletteEntries(state: State, nowMs: number): PaletteEntry[] {
if (task !== null && agent !== null) add('task-claim', 'claims', `claim task ${task.id} for ${agent.name ?? agent.type}`, { kind: 'spec', spec: claimTask(task, agent), why: 'an id cannot be passed to ruflo' })
- for (const type of AGENT_TYPES) add(`spawn-${type}`, 'swarm', `spawn a ${type} agent`, { kind: 'spec', spec: spawnAgent(type, nowMs), why: 'unknown agent type' })
+ for (const type of AGENT_TYPES) add(`spawn-${type}`, 'swarm', `spawn ${/^[aeiou]/.test(type) ? 'an' : 'a'} ${type} agent`, { kind: 'spec', spec: spawnAgent(type, nowMs), why: 'unknown agent type' })
add('swarm-init', 'swarm', 'start a swarm: init hierarchical, max 8, specialized', { kind: 'spec', spec: swarmInit(), why: '' })
add('swarm-stop', 'swarm', 'stop the swarm', { kind: 'spec', spec: swarmStop(), why: '' })
diff --git a/plugins/ruflo-console/hooks/register.ts b/plugins/ruflo-console/hooks/register.ts
index 074b2b9597..19a3d6c10e 100644
--- a/plugins/ruflo-console/hooks/register.ts
+++ b/plugins/ruflo-console/hooks/register.ts
@@ -187,6 +187,7 @@ export const register: Register = (on, raw: PluginOptions) => {
if (e.id === PANE_ID && result.deny === undefined) {
state.pane.isOpen = false
state.pane.isShown = false
+ if (e.origin.kind === 'person') control?.closedByPerson()
control?.animate()
}
diff --git a/plugins/ruflo-console/hooks/views/frames.ts b/plugins/ruflo-console/hooks/views/frames.ts
index a82a2847f3..6aa45e1383 100644
--- a/plugins/ruflo-console/hooks/views/frames.ts
+++ b/plugins/ruflo-console/hooks/views/frames.ts
@@ -19,8 +19,10 @@ import { live } from './common'
import { openTasks } from './select'
export const MAX_NODES = 100
-export const HEALTH_CHECKS = ['installed', 'enabled', 'in clone', 'mod'] as const
+export const HEALTH_CHECKS = ['installed', 'enabled', 'clone', 'mod'] as const
const TIMELINE_MS = 15 * 60_000
+/** The radar's axis words: the score's own dimension names, shortened to fit at a spoke's end. */
+const AXIS: Record<string, string> = { harnessFit: 'fit', compileConfidence: 'compile', taskCoverage: 'coverage', toolSafety: 'safety', memoryUsefulness: 'memory' }
/** The swarm as a graph: the hive's queen leads where there is one, else the swarm itself stands at the root. */
export function topoModelOf(snapshot: Snapshot | null, pulses: Map<string, number> = new Map()): TopoModel | null {
@@ -126,7 +128,7 @@ export function picturesOf(state: State, columns: number, nowMs: number, t: numb
break
}
case 'claims': {
- const cards = flowModelOf(snapshot?.claims ?? [], openTasks(state))
+ const cards = flowModelOf(snapshot?.claims ?? [], openTasks(state), snapshot?.agents ?? [])
if (cards.length > 0) pictures.set('flow', flowPicture(cards, width, flowRows(cards), nowMs))
break
@@ -154,7 +156,7 @@ export function picturesOf(state: State, columns: number, nowMs: number, t: numb
if (score !== null) {
if (!scoreShown.has(score)) scoreShown.set(score, t)
- pictures.set('radar', radarPicture(score.dims, width, 13, t, scoreShown.get(score) ?? t))
+ pictures.set('radar', radarPicture(score.dims.map(dim => ({ ...dim, name: AXIS[dim.name] ?? dim.name })), width, 13, t, scoreShown.get(score) ?? t))
}
pictures.set(
@@ -183,7 +185,7 @@ export function picturesOf(state: State, columns: number, nowMs: number, t: numb
case 'timeline': {
const lanes = lanesOf(state, nowMs)
- if (lanes.length > 0) pictures.set('gantt', ganttPicture(lanes, width, nowMs - TIMELINE_MS, nowMs, nowMs))
+ if (lanes.length > 0) pictures.set('gantt', ganttPicture(lanes, width, nowMs - TIMELINE_MS, nowMs))
break
}
default:
diff --git a/plugins/ruflo-console/hooks/views/plugins.ts b/plugins/ruflo-console/hooks/views/plugins.ts
index ff8fe86be9..4ec1121f17 100644
--- a/plugins/ruflo-console/hooks/views/plugins.ts
+++ b/plugins/ruflo-console/hooks/views/plugins.ts
@@ -46,7 +46,7 @@ export function pluginsView(ctx: Ctx): RenderElement {
rows.push(rule(ctx, 'Installed', facts.installed === null ? 'n/a' : `${ruflo.length} ruflo · ${enabled} enabled · ${(facts.installed ?? []).length} total`))
rows.push(picture(ctx, 'health', `${ruflo.length} ruflo plugins installed`))
- rows.push(text(ctx, 'columns: I installed · E enabled · I in the marketplace clone · M mod loaded here — ■ yes (green) / no (red), · unknown', { dimColor: true }))
+ rows.push(text(ctx, 'columns: I installed · E enabled · C listed by the marketplace clone · M mod loaded here — ■ yes (green) / no (red), · unknown', { dimColor: true }))
const gone = ruflo.filter(plugin => facts.rufloOffered !== null && !facts.rufloOffered.includes(plugin.name))
diff --git a/plugins/ruflo-console/tests/actions.test.ts b/plugins/ruflo-console/tests/actions.test.ts
new file mode 100644
index 0000000000..f7a5fec53c
--- /dev/null
+++ b/plugins/ruflo-console/tests/actions.test.ts
@@ -0,0 +1,46 @@
+import { describe, expect, mock, test } from 'claude-code/testing'
+
+import { RUFLO_FILES } from './fixtures/ruflo-run'
+import { command, SESSION, worldOf } from './fixtures/world'
+
+/** Every palette action that changes something: the selection it needs, and the head of the argv it must run. */
+const CASES: { id: string; setup?: string[]; text?: string; head: string[] }[] = [
+ { id: 'task-claim', head: ['mcp', 'exec', '-t', 'claims_claim'] },
+ { id: 'claim-release', head: ['mcp', 'exec', '-t', 'claims_release'] },
+ { id: 'claim-pause', head: ['mcp', 'exec', '-t', 'claims_status'] },
+ { id: 'claim-handoff', setup: ['swarm', 'next'], head: ['mcp', 'exec', '-t', 'claims_handoff'] },
+ { id: 'claim-steal', setup: ['claims', 'next'], head: ['mcp', 'exec', '-t', 'claims_steal'] },
+ { id: 'agent-stop', head: ['agent', 'stop', 'agent-1790903032181-97m25s'] },
+ { id: 'spawn-tester', head: ['agent', 'spawn', '--type', 'tester'] },
+ { id: 'swarm-init', head: ['swarm', 'init', '--topology', 'hierarchical', '--max-agents', '8', '--strategy', 'specialized'] },
+ { id: 'swarm-stop', head: ['swarm', 'stop'] },
+ { id: 'vote-no-proposal-1790903321981-23aov7', head: ['hive-mind', 'consensus', '--action', 'vote', '--proposal-id', 'proposal-1790903321981-23aov7', '--vote', 'no'] },
+ { id: 'mh-audit', head: ['metaharness', 'oia-audit'] },
+ { id: 'worker-optimize', head: ['hooks', 'worker', 'dispatch', '--trigger', 'optimize'] },
+ { id: 'store', text: 'remember the login fix', head: ['memory', 'store', '--key'] },
+]
+
+describe('every confirm-gated action', () => {
+ for (const entry of CASES) {
+ test(`${entry.id}: asks first, runs nothing until yes, then exactly its fixed argv`, async ($, on) => {
+ const world = worldOf(on, RUFLO_FILES)
+ mock.clock(on)
+ await $.session.start(SESSION)
+
+ for (const step of entry.setup ?? []) await $.command.run(command(step))
+
+ const before = world.runs.length
+ const asked = await $.command.run(command(`run ${entry.id}${entry.text !== undefined ? ` ${entry.text}` : ''}`))
+
+ expect(asked.text).toMatch(/^Asked: /)
+ expect(world.runs.slice(before).filter(argv => argv.join(' ').includes(entry.head.slice(0, 2).join(' ')))).toHaveLength(0)
+
+ await $.command.run(command('yes'))
+
+ const ran = world.runs.slice(before).filter(argv => argv.slice(4, 4 + entry.head.length).join(' ') === entry.head.join(' '))
+
+ expect(ran).toHaveLength(1)
+ expect(ran[0]?.slice(0, 4)).toEqual(['npx', '--offline', '-y', '@claude-flow/cli@latest'])
+ })
+ }
+})
diff --git a/plugins/ruflo-console/tests/diagrams.spec.ts b/plugins/ruflo-console/tests/diagrams.spec.ts
index 55c6acccc2..0d776c0b0b 100644
--- a/plugins/ruflo-console/tests/diagrams.spec.ts
+++ b/plugins/ruflo-console/tests/diagrams.spec.ts
@@ -38,7 +38,7 @@ function all(t: number): [string, Grid, number, number][] {
['burn', samplesPicture('spend', [{ value: 0.1 }, { value: 0.4 }], 80), 80, 1],
['fedmap', federationPicture('this node', [{ label: 'peer-a', trust: 'pinned', trafficAtMs: 0 }, { label: '#ops', trust: 'channel' }, { label: 'npub1x', trust: 'roster' }], 80, 11, t), 80, 11],
['health', heatmapPicture([{ name: 'core', cells: [true, true, true, null] }, { name: 'mods', cells: [false, null, false, true] }], ['installed', 'enabled', 'clone', 'mod'], 80, 5), 80, 5],
- ['gantt', ganttPicture([{ label: 'coder', spans: [{ fromMs: 0, toMs: 500, busy: true }], ticks: [200] }], 80, 0, 1_000, t), 80, 2],
+ ['gantt', ganttPicture([{ label: 'coder', spans: [{ fromMs: 0, toMs: 500, busy: true }], ticks: [200] }], 80, 0, 1_000), 80, 2],
]
}
diff --git a/plugins/ruflo-console/tests/palette.test.ts b/plugins/ruflo-console/tests/palette.test.ts
index c1a9f09ac7..01eab5fb62 100644
--- a/plugins/ruflo-console/tests/palette.test.ts
+++ b/plugins/ruflo-console/tests/palette.test.ts
@@ -138,4 +138,13 @@ describe('palette and /ruflo', () => {
expect(world.runs.some(argv => argv.join(' ').includes('memory stats'))).toBe(true)
expect(world.opened).toHaveLength(0)
})
+
+ test('panel auto stays shut outside a ruflo project', { options: { panel: 'auto' } }, async ($, on) => {
+ const world = worldOf(on, { 'README.md': 'not ruflo' })
+ const clock = mock.clock(on)
+ await $.session.start(SESSION)
+ await clock.advance(500)
+
+ expect(world.openArgs).toHaveLength(0)
+ })
})
diff --git a/plugins/ruflo-mods/README.md b/plugins/ruflo-mods/README.md
index 6e1e3f3729..b9100b576d 100644
--- a/plugins/ruflo-mods/README.md
+++ b/plugins/ruflo-mods/README.md
@@ -8,7 +8,7 @@ ruflo mods doctor # function hooks on? refused by policy? what does it own
ruflo mods uninstall # remove only what install added
```
-In a session, `/ruflo-mods` reports what the mod owns, routed, recorded and tightened.
+In a session, `/ruflo mods` (through ruflo-console's `/ruflo`) reports what the mod owns, routed, recorded and tightened. `/ruflo-mods` still works for one release as a deprecated alias.
## What it does
diff --git a/plugins/ruflo-swarm/README.md b/plugins/ruflo-swarm/README.md
index 3af6bb90ba..3a242beec1 100644
--- a/plugins/ruflo-swarm/README.md
+++ b/plugins/ruflo-swarm/README.md
@@ -87,9 +87,11 @@ commands, skills and agents above behave as they always have.
the prompt (a person still presses Enter). Stop, steal and hand off ask for a second press. After each action the
pane re-reads the disk and says whether the change shows there. A CLI that exits 0 while nothing changes on disk is
reported as unverified.
-- **Commands**: `/ruflo-swarm-pane`, `/ruflo-swarm-status [json]`, `/ruflo-swarm-topology`, `/ruflo-swarm-claims`,
- `/ruflo-swarm-consensus`. `/ruflo-swarm:watch` also opens the pane.
-- **Options** (`/config`): `panel` (auto | command | off), `cli` (`npx-offline`, the default, never touches the
+- **Commands**: `/ruflo swarm pane|status [json]|topology|claims|consensus`, through ruflo-console's `/ruflo`. The old
+ `/ruflo-swarm-pane`, `/ruflo-swarm-status`, `/ruflo-swarm-topology`, `/ruflo-swarm-claims` and
+ `/ruflo-swarm-consensus` still work for one release, as deprecated aliases. `/ruflo-swarm:watch` also opens the pane.
+- **Options** (`/config`): `panel` (command, the default since ruflo-console's cockpit is the pane that opens by
+ itself | auto | off), `cli` (`npx-offline`, the default, never touches the
network), `routeThreshold`, `injectSpawnContext` (off by default: appends a one-line swarm note to spawned subagents'
prompts) and `audit` (off by default: event names, tool names and agent ids into ruflo memory, never content).
- The mod does not register `prompt.submit` or `tool.check` hooks, and its `tool.call` hook only observes.
diff --git a/scripts/ci-test-baseline.txt b/scripts/ci-test-baseline.txt
index ae4afe2720..e3fe62415a 100644
--- a/scripts/ci-test-baseline.txt
+++ b/scripts/ci-test-baseline.txt
@@ -159,6 +159,7 @@ plugins/ruflo-ruos/tests/vendored-types.test.mjs
plugins/ruflo-ruos/tests/mod.test.ts
# ruflo-console: Claude Code engine-kit tests (import 'claude-code/testing', run by `claude plugin test plugins/ruflo-console`);
# root vitest cannot resolve that import. The pure readers and graphics run under root vitest via tests/*.spec.ts
+plugins/ruflo-console/tests/actions.test.ts
plugins/ruflo-console/tests/behaviour.test.ts
plugins/ruflo-console/tests/palette.test.ts
plugins/ruflo-console/tests/views.test.ts