🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
feat(ruflo-console): empty sections start with a button, not a command to copy; a conformance test against the real CLI
ruva21b524a55e9
diff --git a/plugins/ruflo-console/hooks/bindings.ts b/plugins/ruflo-console/hooks/bindings.tsindex a52ccfc673..38bf993bbe 100644--- a/plugins/ruflo-console/hooks/bindings.ts+++ b/plugins/ruflo-console/hooks/bindings.ts@@ -5,6 +5,7 @@import { claimTask, handoffClaim, releaseClaim, stealClaim, whyNot } from './actions'import { EVENT_KINDS } from './data/events'import { HARNESSES, harnessSpec, isLive, newSession, send, whyNotRun } from './harness'+import { startSpec } from './starts'import { plain } from './data/parse'import type { Host } from './host'import { filterPalette, paletteEntries } from './palette'@@ -125,6 +126,7 @@ export function actionsOf(state: State, host: Host, runner: Runner, steps: Stepsstate.eventFilter = order[(at + 1) % order.length] ?? 'all'host.invalidate()},+ start: (id, text = '') => runner.ask(startSpec(id, Date.now(), text), id === 'mission' || id === 'task' ? 'type it first (it may not start with -)' : 'that start cannot run here'),// The main menu's prompt, as a board's: a key (2, w, i), a name (swarm, x.ruv.io), ? for help, O to log off.menu: text => {const word = text.trim().toLowerCase()diff --git a/plugins/ruflo-console/hooks/palette.ts b/plugins/ruflo-console/hooks/palette.tsindex 320a67f328..ecbadd0b4d 100644--- a/plugins/ruflo-console/hooks/palette.ts+++ b/plugins/ruflo-console/hooks/palette.ts@@ -4,6 +4,7 @@* argument from the query after their keyword: `route fix the login bug`.*/import { HIVE_ROLES, pickedProposal } from './data/hive'+import { START_IDS, START_LABEL, startSpec } from './starts'import { hiveBroadcast, hivePropose, hiveSpawn, hiveVote } from './hive'import { claimTask, handoffClaim, releaseClaim, stealClaim, type ActionSpec } from './actions'import { LAB, labSpec, labWhy } from './mh-lab'@@ -49,7 +50,7 @@ export function fuzzy(query: string, label: string): number | null {return whole < 0 ? score : score + 5 + (whole === 0 || text[whole - 1] === ' ' ? 3 : 0)}-const TEXT_KEYWORDS = ['route', 'store', 'search', 'propose', 'broadcast'] as const+const TEXT_KEYWORDS = ['route', 'store', 'search', 'propose', 'broadcast', 'task', 'mission'] as const/** Every entry for the state as it is, before filtering. */export function paletteEntries(state: State, nowMs: number): PaletteEntry[] {@@ -81,6 +82,11 @@ export function paletteEntries(state: State, nowMs: number): PaletteEntry[] {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' })+ // One-click starts, also reachable as `/ruflo run <id>`: everything an empty section offers.+ for (const id of START_IDS) add(id, 'start', `${START_LABEL[id]}`, { kind: 'spec', spec: startSpec(id, nowMs), why: 'that start cannot run here' })+ add('task', 'start', 'task <text>: put a task on the board', { kind: 'text', keyword: 'task', make: text => startSpec('task', nowMs, text) })+ add('mission', 'start', 'mission <objective>: create an ADR-406 mission', { kind: 'text', keyword: 'mission', make: text => startSpec('mission', nowMs, text) })+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/starts.ts b/plugins/ruflo-console/hooks/starts.tsnew file mode 100644index 0000000000..baec45406e--- /dev/null+++ b/plugins/ruflo-console/hooks/starts.ts@@ -0,0 +1,128 @@+/**+ * One-click starts: what a section offers when there is nothing in it yet. Every view's empty state was a command to+ * copy ("`npx ruflo hive-mind init` starts one"); the console is the place to use ruflo, so each is now a button that+ * asks (the confirm row shows the exact argv) and runs it, and the disk is re-read to say whether it took. Each is one+ * fixed argv through the ruflo CLI, flags checked against `<command> --help` on CLI 3.51.1. Joining the federation+ * reaches the network, and `mods install` writes Claude Code settings; both say so on the confirm row.+ */+import type { ActionSpec } from './actions'+import { spawnAgent, swarmInit, textArg } from './ops'++export type StartId =+ | 'init'+ | 'daemon'+ | 'swarm'+ | 'spawn-coder'+ | 'spawn-tester'+ | 'spawn-reviewer'+ | 'hive'+ | 'hive-workers'+ | 'pretrain'+ | 'federation-join'+ | 'channel-read'+ | 'marketplace'+ | 'mission'+ | 'task'++/** The words each start shows on its button. */+export const START_LABEL: Record<StartId, string> = {+ init: 'init ruflo here',+ daemon: 'start the daemon',+ swarm: 'start a swarm',+ 'spawn-coder': 'spawn a coder',+ 'spawn-tester': 'spawn a tester',+ 'spawn-reviewer': 'spawn a reviewer',+ hive: 'start a hive-mind (raft)',+ 'hive-workers': 'spawn 3 hive workers',+ pretrain: 'pretrain on this repo',+ 'federation-join': 'join the federation',+ 'channel-read': 'read pub:announce',+ marketplace: 'add the ruflo marketplace',+ mission: 'create the mission',+ task: 'create the task',+}++/** The ask for a start, or null when its text cannot be passed (a mission objective is the only text). */+export function startSpec(id: StartId, nowMs: number, text = ''): ActionSpec | null {+ switch (id) {+ case 'init':+ return {+ label: 'initialise ruflo in this project (.claude-flow, .claude settings and the mods)',+ args: ['init', '--no-signup', '--no-global'],+ expect: 'ruflo state in .claude-flow',+ verify: snapshot => snapshot.isRufloProject,+ }+ case 'daemon':+ return { label: 'start the ruflo daemon (background workers: map, audit, optimize, consolidate, testgaps)', args: ['daemon', 'start'], expect: 'daemon-state.json saying running', verify: snapshot => snapshot.daemon?.running === true }+ case 'swarm':+ return swarmInit()+ case 'spawn-coder':+ case 'spawn-tester':+ case 'spawn-reviewer':+ return spawnAgent(id.slice(6), nowMs)+ case 'hive':+ return {+ label: 'start a hive-mind: a queen with raft consensus',+ args: ['hive-mind', 'init', '--consensus', 'raft'],+ expect: 'a queen in .claude-flow/hive-mind/state.json',+ verify: snapshot => snapshot.hive !== null,+ }+ case 'hive-workers':+ return {+ label: 'spawn 3 hive workers (they vote; the CLI counts only registered workers)',+ args: ['hive-mind', 'spawn', '--count', '3'],+ expect: 'three workers in the hive',+ verify: snapshot => (snapshot.hive?.workers.length ?? 0) > 0,+ }+ case 'pretrain':+ return {+ label: 'pretrain the learning loop on this repository (local, shallow)',+ args: ['hooks', 'pretrain', '--depth', 'shallow'],+ expect: 'patterns learned from the repo',+ verify: snapshot => snapshot.sona !== null || snapshot.neural !== null || snapshot.outcomes !== null,+ }+ case 'federation-join':+ return {+ label: 'join the open federation with your own key (makes ~/.ruflo/nostr.key, registers on x.ruv.io: network)',+ args: ['federation', 'join'],+ expect: 'a nostr key and a registration',+ verify: snapshot => snapshot.hasNostrKey === true,+ }+ case 'channel-read':+ return { label: 'read the pub:announce channel (network)', args: ['federation', 'channel', '--action', 'read', '--channel', 'pub:announce', '--limit', '10'], expect: 'the latest announcements', isReadOnly: true }+ case 'marketplace':+ return {+ label: 'add the ruflo marketplace to Claude Code and install the ruflo mods (ruflo mods install: settings.local.json + claude plugin install)',+ args: ['mods', 'install'],+ expect: 'the ruflo marketplace in known_marketplaces.json',+ verify: snapshot => snapshot.plugins.missingFromClone !== undefined && snapshot.isRufloProject,+ }+ case 'task': {+ const description = textArg(text, 200)++ return description === null+ ? null+ : {+ label: `create a task: ${description.slice(0, 60)}`,+ args: ['task', 'create', '--type', 'implementation', '--description', description],+ expect: 'the task in .claude-flow/tasks/store.json',+ verify: snapshot => snapshot.tasks.some(task => task.description === description),+ }+ }+ case 'mission': {+ const objective = textArg(text, 300)++ return objective === null+ ? null+ : {+ label: `create a mission: ${objective.slice(0, 60)}`,+ args: ['mission', 'create', '--objective', objective, '--request-id', `console-${nowMs}`],+ expect: 'the mission in .claude-flow/missions',+ verify: snapshot => snapshot.missions !== null,+ }+ }+ }+}++/** The starts that need no text: each is also a palette entry, so `/ruflo run init` works headless (the spawn buttons use the palette's existing spawn-<type> ids). */+export const START_IDS: readonly StartId[] = ['init', 'daemon', 'swarm', 'hive', 'hive-workers', 'pretrain', 'federation-join', 'channel-read', 'marketplace']diff --git a/plugins/ruflo-console/hooks/views/claims.ts b/plugins/ruflo-console/hooks/views/claims.tsindex 6455dcc839..922f66d649 100644--- a/plugins/ruflo-console/hooks/views/claims.ts+++ b/plugins/ruflo-console/hooks/views/claims.ts@@ -1,7 +1,7 @@import type { RenderElement } from 'claude-code'import type { ClaimRecord } from '../data/parse'-import { button, clip, col, picture, row, rule, text, THEME, type Ctx } from './common'+import { button, clip, col, picture, row, rule, startField, starts, text, THEME, type Ctx } from './common'import { selection } from './select'const who = (claim: ClaimRecord): string => (claim.claimant.kind === 'agent' ? `${claim.claimant.agentType ?? 'agent'} ${claim.claimant.id}` : `human ${claim.claimant.name ?? claim.claimant.id}`)@@ -47,6 +47,10 @@ export function claimsView(ctx: Ctx): RenderElement {if (claims.length > 10) rows.push(text(ctx, `+${claims.length - 10} more`, { dimColor: true }))}+ // Nothing to claim, or nobody to claim it: say so with the button that fixes it.+ if (pick.agent === null) rows.push(starts(ctx, 'No agents to claim for.', ['swarm', 'spawn-coder', 'spawn-tester']))+ if (pick.task === null) rows.push(startField(ctx, 'task', 'a task to put on the board, e.g. add OAuth login to the API'))+rows.push(rule(ctx, 'Act', ctx.state.isActing ? 'running…' : ''))rows.push(text(ctx, `picked claim ${pick.claim?.issueId ?? 'n/a'} · agent ${pick.agent !== null ? `${pick.agent.name ?? pick.agent.type} (${pick.agent.id})` : 'n/a — no agents on disk'}`, { dimColor: true }))rows.push(text(ctx, `open task ${pick.task === null ? 'n/a — every task is claimed' : `${pick.task.id}: ${pick.task.description || pick.task.type}`}`, { dimColor: true }))diff --git a/plugins/ruflo-console/hooks/views/common.ts b/plugins/ruflo-console/hooks/views/common.tsindex 482d9f5b70..a27706920a 100644--- a/plugins/ruflo-console/hooks/views/common.ts+++ b/plugins/ruflo-console/hooks/views/common.ts@@ -8,6 +8,7 @@ import type { Elements, RenderChildren, RenderElement } from 'claude-code'import type { ProbeResult } from '../data/cli'import type { Grid } from '../gfx/raster'import type { SkillActions } from '../skills'+import { START_LABEL, type StartId } from '../starts'import type { HarnessId, State, ViewId } from '../state'export type Kit = Pick<Elements['terminal'], 'Box' | 'Text' | 'Button'> & { Raster?: Elements['terminal']['Raster']; Input?: Elements['terminal']['Input'] }@@ -39,6 +40,8 @@ export type Actions = {/** Cycles the events view's filter. */filter: () => void/** The terminal view: pick a harness, follow the field, ask to run its text, stop the run, clear the scrollback. */+ /** A one-click start for an empty section (init, swarm, hive, workers…): asks, runs, and re-reads the disk. */+ start: (id: StartId, text?: string) => void/** The main menu's prompt: a key or a name takes the person to that area. */menu: (text: string) => voidterm: { harness: (id: HarnessId) => void; draft: (text: string) => void; submit: (text: string) => void; stop: () => void; fresh: () => void; clear: () => void; load: (id: HarnessId, text: string) => void; /** Moves the window up (positive) or down by screen rows. */ scroll: (by: number) => void; /** Puts an earlier question back in the field. */ reuse: (text: string) => void }@@ -161,6 +164,24 @@ export function button(ctx: Ctx, key: string, label: string, onPress: () => voidreturn ctx.kit.Button({ key, label, onPress, ...(options.hotkey !== undefined && { hotkey: options.hotkey }), ...(options.primary === true && { variant: 'primary' as const }) })}+/** A start that takes a sentence (a task, a mission objective): a text field whose Enter asks, with the confirm after. */+export function startField(ctx: Ctx, id: StartId, placeholder: string): RenderElement {+ return ctx.kit.Input === undefined+ ? text(ctx, ` ${START_LABEL[id]}: this surface has no text field (/ruflo run ${id} <text>)`, { dimColor: true })+ : ctx.kit.Input({ key: `start-field-${id}`, label: START_LABEL[id], placeholder, submitLabel: 'ask', onSubmit: value => ctx.act.start(id, value) })+}++/**+ * What an empty section offers instead of a command to copy: a line saying what is missing, then a button per start+ * (each asks first, with the exact command on the confirm row, and the view fills in once it has run).+ */+export function starts(ctx: Ctx, why: string, ids: readonly StartId[], scope = ''): RenderElement {+ return col(ctx, [+ text(ctx, ` ${why}`, { color: THEME.warn }),+ row(ctx, [text(ctx, ' '), ...ids.map(id => button(ctx, `start-${scope}${id}`, `▸ ${START_LABEL[id]}`, () => ctx.act.start(id)))]),+ ])+}+/** How a CLI-sourced fact reads: its value's age, running, failing with a stale value, or never measured. */export function sourceLine(result: ProbeResult | undefined, nowMs: number, what: string): { text: string; color?: string } {if (result === undefined || (result.okAtMs === null && result.error === null)) {diff --git a/plugins/ruflo-console/hooks/views/federation.ts b/plugins/ruflo-console/hooks/views/federation.tsindex 32e6b1b129..416e5f722f 100644--- a/plugins/ruflo-console/hooks/views/federation.ts+++ b/plugins/ruflo-console/hooks/views/federation.ts@@ -1,7 +1,7 @@import type { RenderElement } from 'claude-code'import type { Channels, Peers, Roster } from '../data/cli'-import { ago, col, kv, live, picture, rule, sourceLine, text, THEME, type Ctx } from './common'+import { ago, col, kv, live, picture, rule, sourceLine, starts, text, THEME, type Ctx } from './common'/*** This node's federation standing from local state and local CLI answers only. The roster lives on the public relay,@@ -24,7 +24,7 @@ export function federationView(ctx: Ctx): RenderElement {kv(ctx,'nostr identity',- snap?.hasNostrKey === true ? '~/.ruflo/nostr.key present (never read here)' : snap?.hasNostrKey === false ? 'none — `npx ruflo federation join` makes one' : 'n/a',+ snap?.hasNostrKey === true ? '~/.ruflo/nostr.key present (never read here)' : snap?.hasNostrKey === false ? 'none yet (join below makes one)' : 'n/a',snap?.hasNostrKey === true ? THEME.ok : undefined,),)@@ -41,6 +41,8 @@ export function federationView(ctx: Ctx): RenderElement {),)+ if (snap?.hasNostrKey === false) rows.push(starts(ctx, 'This node has no federation identity yet.', ['federation-join', 'channel-read']))+rows.push(rule(ctx, 'Peers', 'agentbbs'))if (peers !== null && peers.peers.length > 0) {diff --git a/plugins/ruflo-console/hooks/views/hive.ts b/plugins/ruflo-console/hooks/views/hive.tsindex 1076db6249..3249e4e492 100644--- a/plugins/ruflo-console/hooks/views/hive.ts+++ b/plugins/ruflo-console/hooks/views/hive.ts@@ -10,7 +10,7 @@ import { faultTolerance, membersOf, nextVoter, nodesOf, pickedProposal, proposalimport { shortId, type HiveInfo } from '../data/parse'import { HIVE_COLOR, type HiveCell, type HivePictureModel } from '../gfx/hive'import type { State } from '../state'-import { ago, button, clip, col, kv, picture, row, rule, text, THEME, type Ctx } from './common'+import { ago, button, clip, col, kv, picture, row, rule, starts, text, THEME, type Ctx } from './common'const ROLE_GLYPH: Record<string, string> = { worker: '●', specialist: '◆', scout: '▲' }const LIVE_COLOR: Record<Liveness, number> = { busy: HIVE_COLOR.yellow, idle: HIVE_COLOR.cyan, error: HIVE_COLOR.pink, down: HIVE_COLOR.grey, unknown: HIVE_COLOR.wall }@@ -101,7 +101,7 @@ function workersSection(ctx: Ctx, hive: HiveInfo, members: Member[]): RenderElemconst picked = pickedProposal(hive, ctx.state.select.item)const rows: RenderElement[] = [rule(ctx, 'Workers', `${members.length} · role · liveness · ballot on the picked proposal`)]- if (members.length === 0) rows.push(text(ctx, 'No workers have joined. A vote needs a registered worker: spawn one below.', { dimColor: true }))+ if (members.length === 0) rows.push(starts(ctx, 'No workers have joined. A vote needs a registered worker.', ['hive-workers']))for (const member of members.slice(0, 12)) {const ballot = picked?.ballots.find(entry => entry.voter === member.id)@@ -152,7 +152,8 @@ function proposalsSection(ctx: Ctx, hive: HiveInfo): RenderElement[] {...(voter === null ? [] : [button(ctx, 'hive-vote-yes', 'Vote for', () => void ctx.act.run('hive-vote-yes'), { hotkey: 'f' }), button(ctx, 'hive-vote-no', 'Vote against', () => void ctx.act.run('hive-vote-no'), { hotkey: 'a' })]),]),)- rows.push(text(ctx, voter === null ? `vote: n/a — ${hive.workers.length === 0 ? 'no registered worker to vote as (the CLI counts only workers): spawn one' : 'every worker has voted on it'}` : `a vote is cast as the next worker that has not voted: ${voter}`, { dimColor: true }))+ if (voter === null && hive.workers.length === 0) rows.push(starts(ctx, 'No registered worker to vote as (the CLI counts only workers).', ['hive-workers'], 'vote-'))+ else rows.push(text(ctx, voter === null ? `vote: n/a — ${hive.workers.length === 0 ? 'no registered worker to vote as (the CLI counts only workers): spawn one' : 'every worker has voted on it'}` : `a vote is cast as the next worker that has not voted: ${voter}`, { dimColor: true }))}return rows@@ -222,7 +223,7 @@ export function hiveView(ctx: Ctx): RenderElement {if (snap === null) return text(ctx, 'reading ruflo state…', { dimColor: true })if (hive === null) {- return col(ctx, [rule(ctx, 'Hive-Mind', 'not initialised'), text(ctx, 'No hive-mind here. `npx ruflo hive-mind init --consensus raft` starts one with a queen; spawn workers to vote.', { dimColor: true })], 'hive')+ return col(ctx, [rule(ctx, 'Hive-Mind', 'not initialised'), starts(ctx, 'No hive-mind here yet: start one with a queen, then spawn workers to vote.', ['hive', 'hive-workers'])], 'hive')}const members = membersOf(hive, snap.hiveAgents, snap.agents)diff --git a/plugins/ruflo-console/hooks/views/learning.ts b/plugins/ruflo-console/hooks/views/learning.tsindex 07d1eefb57..566d7aa94a 100644--- a/plugins/ruflo-console/hooks/views/learning.ts+++ b/plugins/ruflo-console/hooks/views/learning.ts@@ -1,7 +1,7 @@import type { RenderElement } from 'claude-code'import type { Intelligence } from '../data/cli'-import { ago, col, count, kv, live, pct, picture, rule, sourceLine, text, THEME, type Ctx } from './common'+import { ago, col, count, kv, live, pct, picture, rule, sourceLine, starts, text, THEME, type Ctx } from './common'import { stagesOf } from './frames'/**@@ -72,5 +72,8 @@ export function learningView(ctx: Ctx): RenderElement {)rows.push(text(ctx, 'live engine: hooks_intelligence_stats in a fresh CLI process, so in-memory counters start at zero there', { dimColor: true }))+ // Nothing learned yet: the loop starts from the repository itself.+ if ((snap?.sona === null || snap?.sona === undefined) && (neural === null || neural === undefined) && snap?.isRufloProject === true) rows.push(starts(ctx, 'Nothing learned yet in this project.', ['pretrain']))+return col(ctx, rows, 'learning')}diff --git a/plugins/ruflo-console/hooks/views/missions.ts b/plugins/ruflo-console/hooks/views/missions.tsindex 889a7b6b10..ff053ce39f 100644--- a/plugins/ruflo-console/hooks/views/missions.ts+++ b/plugins/ruflo-console/hooks/views/missions.ts@@ -1,7 +1,7 @@import type { RenderElement } from 'claude-code'import { money, type Mission } from '../data/missions'-import { ago, col, kv, rule, text, THEME, type Ctx } from './common'+import { ago, col, kv, rule, startField, text, THEME, type Ctx } from './common'const STATE_COLOR: Record<string, string> = { running: THEME.warn, verifying: THEME.warn, completed: THEME.ok, failed: THEME.bad, blocked: THEME.bad, paused: THEME.info, queued: THEME.info }@@ -44,7 +44,8 @@ export function missionsView(ctx: Ctx): RenderElement {const rows: RenderElement[] = [rule(ctx, 'Missions', observation === null ? 'no observation' : `${observation.missions.length}${observation.isTruncated ? '+' : ''} · observed ${ago(observation.observedAtMs, ctx.nowMs)}`)]if (observation === null) {- rows.push(text(ctx, 'n/a — no .claude-flow/missions/observation.json (ADR-406). `npx ruflo mission create --objective <text> --request-id <id>` starts one.', { dimColor: true }))+ rows.push(text(ctx, ' No mission yet (ADR-406): a mission is an objective the swarm works toward, with a plan, a budget and acceptance.', { color: THEME.warn }))+ rows.push(startField(ctx, 'mission', 'the objective, e.g. ship a verified OAuth login'))return col(ctx, rows, 'missions')}diff --git a/plugins/ruflo-console/hooks/views/overview.ts b/plugins/ruflo-console/hooks/views/overview.tsindex 92e3da61e9..b07aebc468 100644--- a/plugins/ruflo-console/hooks/views/overview.ts+++ b/plugins/ruflo-console/hooks/views/overview.ts@@ -2,7 +2,8 @@ import type { RenderElement } from 'claude-code'import { alertsOf } from '../data/alerts'import type { MemoryStats } from '../data/cli'-import { ago, col, count, kv, live, picture, rule, sourceLine, text, THEME, type Ctx } from './common'+import type { StartId } from '../starts'+import { ago, col, count, kv, live, picture, rule, sourceLine, starts, text, THEME, type Ctx } from './common'/** Each subsystem in one line: what it is, from where, as of when. Nothing on this view is estimated. */export function overviewView(ctx: Ctx): RenderElement {@@ -23,7 +24,7 @@ export function overviewView(ctx: Ctx): RenderElement {kv(ctx,'project',- snap === null ? 'reading…' : snap.isRufloProject ? `ruflo state in ${state.cwd.split('/').slice(-2).join('/')}` : 'n/a — no .claude-flow here; `npx ruflo init` makes one',+ snap === null ? 'reading…' : snap.isRufloProject ? `ruflo state in ${state.cwd.split('/').slice(-2).join('/')}` : 'n/a — no .claude-flow here (see Get going below)',snap?.isRufloProject === true ? THEME.ok : undefined,),)@@ -69,6 +70,18 @@ export function overviewView(ctx: Ctx): RenderElement {rows.push(kv(ctx, 'function hooks', `on (this mod runs) · mods seen since it loaded: ${loaded} loaded, ${refused} refused`, refused > 0 ? THEME.warn : THEME.ok))rows.push(kv(ctx, 'swarm', swarm === null ? 'n/a — no swarm on disk' : `${swarm.id} · ${swarm.topology} · ${swarm.status} · ${swarm.agentIds.length || (snap?.agents.length ?? 0)} agents`))+ // What is missing here, each with the button that adds it, most basic first.+ const missing: StartId[] = []++ if (snap !== null && !snap.isRufloProject) missing.push('init')+ if (snap?.isRufloProject === true && snap.daemon?.running !== true) missing.push('daemon')+ if (snap?.isRufloProject === true && swarm === null) missing.push('swarm')+ if (snap?.isRufloProject === true && snap.hive === null) missing.push('hive')+ if (missing.length > 0) {+ rows.push(rule(ctx, 'Get going', 'one click each: it asks, shows the command, then runs it'))+ rows.push(starts(ctx, snap?.isRufloProject === true ? 'Not running yet in this project:' : 'No ruflo state in this project.', missing))+ }+const alerts = alertsOf(state, nowMs, state.loadedAtMs)rows.push(rule(ctx, 'Health', alerts.length === 0 ? 'no alerts' : `${alerts.length} alert${alerts.length === 1 ? '' : 's'}`))diff --git a/plugins/ruflo-console/hooks/views/plugins.ts b/plugins/ruflo-console/hooks/views/plugins.tsindex 4ec1121f17..695b85f9be 100644--- a/plugins/ruflo-console/hooks/views/plugins.ts+++ b/plugins/ruflo-console/hooks/views/plugins.ts@@ -2,7 +2,7 @@ import type { RenderElement } from 'claude-code'import { EXPECTED_IN_MARKET, RUFLO_MARKET } from '../data/snapshot'import { PLUGIN_NAME } from '../state'-import { ago, col, kv, picture, rule, text, THEME, type Ctx } from './common'+import { ago, col, kv, picture, rule, starts, text, THEME, type Ctx } from './common'const WEEK = 7 * 86_400_000@@ -25,7 +25,8 @@ export function pluginsView(ctx: Ctx): RenderElement {if (state.configDir === null) {rows.push(text(ctx, 'n/a — neither CLAUDE_CONFIG_DIR nor HOME is readable to this mod, so the plugin records cannot be found', { dimColor: true }))} else if (market === null) {- rows.push(kv(ctx, 'ruflo clone', facts.markets === null ? 'n/a — no known_marketplaces.json' : 'not added — /plugin marketplace add ruvnet/ruflo'))+ rows.push(kv(ctx, 'ruflo clone', facts.markets === null ? 'n/a — no known_marketplaces.json' : 'not added yet'))+ rows.push(starts(ctx, 'The ruflo marketplace is not added to Claude Code, so its plugins cannot be installed or updated.', ['marketplace']))} else {const isOld = market.updatedMs !== undefined && nowMs - market.updatedMs > WEEKdiff --git a/plugins/ruflo-console/hooks/views/swarm.ts b/plugins/ruflo-console/hooks/views/swarm.tsindex ad320974a0..161838655c 100644--- a/plugins/ruflo-console/hooks/views/swarm.ts+++ b/plugins/ruflo-console/hooks/views/swarm.ts@@ -1,7 +1,7 @@import type { RenderElement } from 'claude-code'import { agentLabels, shortId } from '../data/parse'-import { button, clip, col, kv, picture, row, rule, text, THEME, type Ctx } from './common'+import { button, clip, col, kv, picture, row, rule, starts, text, THEME, type Ctx } from './common'import { selection } from './select'const STATUS_COLOR = (status: string): string | undefined =>@@ -22,7 +22,7 @@ export function swarmView(ctx: Ctx): RenderElement {if (snap === null) return text(ctx, 'reading ruflo state…', { dimColor: true })if (swarm === null && hive === null && agents.length === 0) {- rows.push(text(ctx, 'No swarm on disk here. `npx ruflo swarm init --topology hierarchical` starts one (or p → "start a swarm").', { dimColor: true }))+ rows.push(starts(ctx, 'No swarm here yet: start a hierarchical one, then spawn agents into it.', ['swarm', 'spawn-coder', 'spawn-tester', 'spawn-reviewer']))return col(ctx, rows, 'swarm')}@@ -62,7 +62,7 @@ export function swarmView(ctx: Ctx): RenderElement {// A short summary: the Hive-Mind view (👑) holds the queen, quorum, proposals, voting and broadcasts.if (hive === null) {- rows.push(text(ctx, 'n/a — `npx ruflo hive-mind init` for queen-led consensus', { dimColor: true }))+ rows.push(starts(ctx, 'No hive-mind yet: queen-led consensus for the swarm.', ['hive'], 'swarm-'))} else {const newest = hive.pending.at(-1)diff --git a/plugins/ruflo-console/tests/behaviour.test.ts b/plugins/ruflo-console/tests/behaviour.test.tsindex c942f81718..1c5b22f5b8 100644--- a/plugins/ruflo-console/tests/behaviour.test.ts+++ b/plugins/ruflo-console/tests/behaviour.test.ts@@ -131,7 +131,7 @@ describe('behaviour', () => {expect(overview).toContain('n/a — no swarm on disk')expect(overview).not.toMatch(/\b0 agents\b/)await $.command.run(command('swarm'))- expect(textOf(await $.ui.render(paneAt(110)))).toContain('No swarm on disk here')+ expect(textOf(await $.ui.render(paneAt(110)))).toContain('No swarm here yet: start a hierarchical one')expect(textOf(await $.ui.render(BAND))).toBe('engine')})diff --git a/plugins/ruflo-console/tests/conformance.spec.ts b/plugins/ruflo-console/tests/conformance.spec.tsnew file mode 100644index 0000000000..44ad362643--- /dev/null+++ b/plugins/ruflo-console/tests/conformance.spec.ts@@ -0,0 +1,162 @@+/**+ * Every action the console can issue, checked against the real ruflo CLI: the subcommand exists and every `--flag` in+ * the argv is one that subcommand documents (its `--help`), and every `mcp exec -t <tool>` names a real MCP tool. An+ * invented flag or tool fails here, not in a person's pane. It runs the CLI, so it is opt-in:+ * RUFLO_CONFORMANCE=1 npx vitest run plugins/ruflo-console/tests/conformance.spec.ts+ * Entries are collected from the palette (every spec and text entry), the one-click starts and the MetaHarness lab,+ * over a project with a hive-mind, so the entries that need a selection exist.+ */+import { spawnSync } from 'node:child_process'+import { readFileSync, readdirSync } from 'node:fs'+import { describe, expect, it } from 'vitest'++import type { ActionSpec } from '../hooks/actions'+import type { ReadCache } from '../hooks/data/files'+import { readSnapshot } from '../hooks/data/snapshot'+import { LAB, labSpec } from '../hooks/mh-lab'+import { paletteEntries } from '../hooks/palette'+import { START_IDS, startSpec } from '../hooks/starts'+import { newState } from '../hooks/state'+import { HIVE_FILES } from './fixtures/hive'++const CLI = ['npx', '--offline', '-y', '@claude-flow/cli@latest']+const SRC = new URL('../../../v3/@claude-flow/cli/src/', import.meta.url).pathname+const TOOLS_DIR = `${SRC}mcp-tools/`+const PLUGIN_SCRIPTS = new URL('../../ruflo-metaharness/scripts/', import.meta.url).pathname++const memoryFs = (files: Record<string, string>) => ({+ read: async (path: string) => files[path] ?? Promise.reject(new Error('ENOENT')),+ stat: async (path: string) => (files[path] !== undefined ? { mtimeMs: 1, size: (files[path] as string).length } : Promise.reject(new Error('ENOENT'))),+ list: async () => Promise.reject(new Error('ENOENT')),+})++/** Every spec the console can build for a project that has a swarm, claims, a task and a hive with workers. */+async function allSpecs(): Promise<{ id: string; spec: ActionSpec }[]> {+ const files = Object.fromEntries(Object.entries(HIVE_FILES).map(([path, text]) => [`/work/${path}`, text]))+ const state = newState({})++ state.snapshot = await readSnapshot(memoryFs(files), new Map() as ReadCache, '/work', '/home/dev', {}, 0)++ const out: { id: string; spec: ActionSpec }[] = []+ const nowMs = 1_790_000_000_000++ for (const entry of paletteEntries(state, nowMs)) {+ if (entry.run.kind === 'spec' && entry.run.spec !== null) out.push({ id: entry.id, spec: entry.run.spec })+ if (entry.run.kind === 'text') {+ const spec = entry.run.make(`${entry.run.keyword === 'propose' ? 'design: ' : ''}sample text`)++ if (spec !== null) out.push({ id: `${entry.id} <text>`, spec })+ }+ }++ for (const id of START_IDS) {+ const spec = startSpec(id, nowMs)++ if (spec !== null) out.push({ id: `start:${id}`, spec })+ }++ for (const id of ['task', 'mission'] as const) {+ const spec = startSpec(id, nowMs, 'sample text')++ if (spec !== null) out.push({ id: `start:${id}`, spec })+ }++ for (const entry of LAB) {+ const spec = labSpec(entry, state)++ if (spec !== null) out.push({ id: `lab:${entry.id}`, spec })+ }++ return out+}++const helpCache = new Map<string, string>()++/** `ruflo <words…> --help` as text (ANSI stripped), cached; empty when the command does not exist. */+function helpOf(words: readonly string[]): string {+ const key = words.join(' ')++ if (!helpCache.has(key)) {+ const run = spawnSync(CLI[0] as string, [...CLI.slice(1), ...words, '--help'], { encoding: 'utf8', timeout: 90_000 })++ helpCache.set(key, `${run.stdout ?? ''}${run.stderr ?? ''}`.replace(/\u001b\[[0-9;]*m/g, ''))+ }++ return helpCache.get(key) as string+}++/** The command path of an argv: its leading words up to the first flag, at most three. */+function pathOf(args: readonly string[]): string[] {+ const words: string[] = []++ for (const word of args) {+ if (word.startsWith('-') || words.length === 3) break+ words.push(word)+ }++ return words+}++/**+ * Whether a command's source declares `--flag`: in the parser's global options or in the command's own file. Help text+ * is no authority here: a nested subcommand prints its parent's help, and global flags (--format) are not listed in it.+ */+function declares(command: string, flag: string): boolean {+ const name = flag.slice(2)+ // `metaharness` hands its flags to the plugin's scripts (redblue.mjs, bench…), which declare them.+ const scripts = command === 'metaharness' ? readdirSync(PLUGIN_SCRIPTS).map(file => `${PLUGIN_SCRIPTS}${file}`) : []+ const sources = [`${SRC}parser.ts`, `${SRC}commands/${command}.ts`, ...scripts].flatMap(file => {+ try {+ return [readFileSync(file, 'utf8')]+ } catch {+ return []+ }+ })++ return sources.some(text => text.includes(`'${name}'`) || text.includes(`--${name}`))+}++/** Every MCP tool name the CLI registers, read from its source. */+function toolNames(): Set<string> {+ const names = new Set<string>()++ for (const file of readdirSync(TOOLS_DIR).filter(name => name.endsWith('.ts'))) {+ for (const match of readFileSync(`${TOOLS_DIR}${file}`, 'utf8').matchAll(/name:\s*'([a-z0-9_-]+)'/g)) names.add(match[1] as string)+ }++ return names+}++describe.skipIf(process.env.RUFLO_CONFORMANCE !== '1')('console actions vs the real CLI', () => {+ it('every subcommand exists and every long flag in every argv is documented by it', async () => {+ const tools = toolNames()+ const problems: string[] = []++ for (const { id, spec } of await allSpecs()) {+ const args = spec.args as readonly string[]++ if (args[0] === 'mcp' && args[1] === 'exec') {+ const tool = args[args.indexOf('-t') + 1] ?? ''++ if (!tools.has(tool)) problems.push(`${id}: no MCP tool "${tool}"`)++ continue+ }++ const path = pathOf(args)+ const help = helpOf(path)++ if (/unknown command|not found|Unknown/i.test(help.slice(0, 300)) && !/Usage|USAGE|Options/i.test(help)) {+ problems.push(`${id}: no such command "${path.join(' ')}"`)++ continue+ }++ for (const flag of args.filter(word => /^--[a-z]/.test(word))) {+ if (!help.includes(flag) && !declares(path[0] ?? '', flag)) problems.push(`${id}: "${path.join(' ')}" declares no ${flag} (not in its help or its source)`)+ }+ }++ expect(problems).toEqual([])+ }, 900_000)+})diff --git a/plugins/ruflo-console/tests/views.test.ts b/plugins/ruflo-console/tests/views.test.tsindex 39a1187e2b..7baee5c2d3 100644--- a/plugins/ruflo-console/tests/views.test.ts+++ b/plugins/ruflo-console/tests/views.test.ts@@ -270,7 +270,10 @@ describe('views', () => {mock.clock(on)await $.session.start(SESSION)- expect((await drawn($, 'missions')).text).toContain('n/a — no .claude-flow/missions/observation.json')+ const missions = await drawn($, 'missions')++ expect(missions.text).toContain('No mission yet (ADR-406)')+ expect(elementsOf(missions.tree, 'Input').map(keyOf)).toEqual(['start-field-mission'])})test('x.ruv.io: the federation menu with its commands, and no registry or roster asked with the network off', { options: { boot: false } }, async ($, on) => {@@ -345,6 +348,48 @@ describe('views', () => {await pane.unmount()})+ test('empty sections offer the button that starts them, not a command to copy; a start asks first and runs one fixed argv', { options: { boot: false } }, async ($, on) => {+ const { ".claude-flow/hive-mind/state.json": _hive, ...withoutHive } = RUFLO_FILES+ const world = worldOf(on, withoutHive)++ mock.clock(on)+ await $.session.start(SESSION)++ // A project with no hive-mind: the view says so and offers to start one.+ await $.command.run(command('hive'))++ const pane = await $.ui.mount({ ...paneAt(110), surface: 'terminal' as const, plugin: PLUGIN })+ const hive = await pane.drawn()++ expect(textOf(hive)).toContain('No hive-mind here yet')+ expect(textOf(hive)).not.toContain('npx ruflo')+ expect(elementsOf(hive, 'Button').map(keyOf)).toContain('start-hive')++ await pane.press({ key: 'start-hive' })+ expect(textOf(await pane.drawn())).toContain('Confirm: start a hive-mind: a queen with raft consensus?')+ expect(world.runs.some(argv => argv.includes('hive-mind') && argv.includes('init'))).toBe(false)++ await pane.press({ key: 'confirm' })++ const ran = world.runs.filter(argv => argv.includes('hive-mind') && argv.includes('init'))++ expect(ran.map(argv => argv.slice(4))).toEqual([['hive-mind', 'init', '--consensus', 'raft']])+ await pane.unmount()+ })++ test('starts that take a sentence refuse a leading dash and an empty one; nothing runs', { options: { boot: false } }, async ($, on) => {+ const world = worldOf(on, RUFLO_FILES)++ mock.clock(on)+ await $.session.start(SESSION)++ for (const text of ['', '--force']) {+ expect((await $.command.run(command(`run start-task ${text}`))).text ?? '').not.toMatch(/^Asked: /)+ }++ expect(world.runs.some(argv => argv.includes('task') && argv.includes('create'))).toBe(false)+ })+test('main menu: bare /ruflo lands on it in the BBS look; its prompt takes a key or a name', { options: { boot: false } }, async ($, on) => {worldOf(on, RUFLO_FILES)mock.clock(on)