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

Merge branch 'feat/console-metaharness' into feat/console-now

ruv27b60a65b6a4
diff --cc plugins/ruflo-console/hooks/palette.ts
index 46d93b5601,3d26cc542d..320a67f328
--- a/plugins/ruflo-console/hooks/palette.ts
+++ b/plugins/ruflo-console/hooks/palette.ts
@@@ -3,10 -3,9 +3,11 @@@
* entries from the state; the controller runs the one picked. Text-taking entries (route, store, search) read their
* argument from the query after their keyword: `route fix the login bug`.
*/
+import { HIVE_ROLES, pickedProposal } from './data/hive'
+import { hiveBroadcast, hivePropose, hiveSpawn, hiveVote } from './hive'
import { claimTask, handoffClaim, releaseClaim, stealClaim, type ActionSpec } from './actions'
- import { AGENT_TYPES, agentLogs, dispatchWorker, harnessAudit, harnessScore, memorySearch, memoryStore, reroute, setClaimStatus, spawnAgent, stopAgent, swarmInit, swarmStop, vote, WORKERS } from './ops'
+ import { LAB, labSpec, labWhy } from './mh-lab'
+ import { AGENT_TYPES, agentLogs, dispatchWorker, memorySearch, memoryStore, reroute, setClaimStatus, spawnAgent, stopAgent, swarmInit, swarmStop, vote, WORKERS } from './ops'
import { VIEWS, type State, type ViewId } from './state'
import { selection } from './views/select'
@@@ -83,37 -82,13 +84,37 @@@ export function paletteEntries(state: S
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: '' })
- for (const proposal of state.snapshot?.hive?.pending.slice(-3) ?? []) {
- add(`vote-yes-${proposal.id}`, 'hive', `vote yes on ${proposal.type} (${proposal.id})`, { kind: 'spec', spec: vote(proposal.id, true), why: 'that proposal id cannot be passed to ruflo' })
- add(`vote-no-${proposal.id}`, 'hive', `vote no on ${proposal.type} (${proposal.id})`, { kind: 'spec', spec: vote(proposal.id, false), why: 'that proposal id cannot be passed to ruflo' })
+ // A vote counts only from a registered worker (the CLI exits 0 on a refused one), so the palette votes as the next
+ // worker that has not voted, as the Hive-Mind view does; with no worker left it says so instead of a silent no-op.
+ const hiveNow = state.snapshot?.hive ?? null
+
+ for (const proposal of hiveNow?.pending.slice(-3) ?? []) {
+ const why = 'no registered worker is left to vote as (hive-mind spawn adds workers), or the proposal id cannot be passed'
+
+ add(`vote-yes-${proposal.id}`, 'hive', `vote yes on ${proposal.type} (${proposal.id})`, { kind: 'spec', spec: hiveNow === null ? vote(proposal.id, true) : hiveVote(hiveNow, proposal, true), why })
+ add(`vote-no-${proposal.id}`, 'hive', `vote no on ${proposal.type} (${proposal.id})`, { kind: 'spec', spec: hiveNow === null ? vote(proposal.id, false) : hiveVote(hiveNow, proposal, false), why })
+ }
+
+ const hive = state.snapshot?.hive ?? null
+ const picked = pickedProposal(hive, state.select.item)
+
+ // The Hive-Mind view's actions; a text entry's id is its keyword, as `runById` reads the text after it.
+ if (hive !== null) {
+ if (picked !== null) {
+ const why = hive.workers.length === 0 ? 'no registered worker to vote as: spawn one' : 'every worker has voted on it'
+
+ add('hive-vote-yes', 'hive', `vote for ${picked.type} as the next worker (${picked.id})`, { kind: 'spec', spec: hiveVote(hive, picked, true), why })
+ add('hive-vote-no', 'hive', `vote against ${picked.type} as the next worker (${picked.id})`, { kind: 'spec', spec: hiveVote(hive, picked, false), why })
+ }
+
+ add('propose', 'hive', 'propose <type: text>: put a decision to the hive', { kind: 'text', keyword: 'propose', make: text => hivePropose(hive, text) })
+ add('broadcast', 'hive', 'broadcast <text>: message every hive worker', { kind: 'text', keyword: 'broadcast', make: hiveBroadcast })
+
+ for (const role of HIVE_ROLES) add(`hive-spawn-${role}`, 'hive', `spawn a hive ${role} and join it`, { kind: 'spec', spec: hiveSpawn(hive, role), why: 'unknown role' })
}
- add('mh-score', 'metaharness', 'score the harness now (metaharness score)', { kind: 'spec', spec: harnessScore(), why: '' })
- add('mh-audit', 'metaharness', 'run a MetaHarness audit (oia-audit)', { kind: 'spec', spec: harnessAudit(), why: '' })
+ // The MetaHarness lab: reads run at once, the rest ask first; promotion is never an entry (see mh-lab.ts).
+ for (const entry of LAB) add(entry.id, 'metaharness', entry.label, { kind: 'spec', spec: labSpec(entry, state), why: labWhy(entry) })
for (const worker of WORKERS) add(`worker-${worker}`, 'workers', `dispatch the ${worker} background worker`, { kind: 'spec', spec: dispatchWorker(worker), why: 'unknown worker' })
diff --cc plugins/ruflo-console/hooks/state.ts
index 0ae7a11ed4,6463ddf616..4270e97672
--- a/plugins/ruflo-console/hooks/state.ts
+++ b/plugins/ruflo-console/hooks/state.ts
@@@ -251,10 -245,10 +256,11 @@@ export function newState(raw: PluginOpt
pending: null,
outcome: null,
isActing: false,
+ lab: { result: null, running: null },
isRefreshing: false,
barDrawnAtMs: 0,
- terminal: { harness: 'codex', draft: '', lines: [], runs: new Map(), sessions: {}, isLive: { codex: false, claude: false }, turns: { codex: 0, claude: 0 }, costUsd: 0, asked: null },
+ terminal: { harness: 'codex', draft: '', lines: [], runs: new Map(), sessions: {}, isLive: { codex: false, claude: false }, turns: { codex: 0, claude: 0 }, costUsd: 0, scroll: 0, unseen: 0, asked: null },
+ skills: emptySkills(),
timers: new Map(),
stats: { renders: [], refreshes: [], frames: [] },
}
diff --cc plugins/ruflo-console/tests/actions.test.ts
index 7cfcd67edd,a16e88ef00..7c408afe47
--- a/plugins/ruflo-console/tests/actions.test.ts
+++ b/plugins/ruflo-console/tests/actions.test.ts
@@@ -15,7 -14,14 +15,13 @@@ const CASES: { id: string; setup?: stri
{ 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: 'mh-audit', head: ['metaharness', 'oia-audit'] },
- { 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', '--format', 'json'] },
+ { id: 'mh-bench-create', head: ['metaharness', 'bench', '--op', 'create', '--repo', '.'] },
+ { id: 'mh-redblue-init', head: ['metaharness', 'redblue', 'init'] },
+ { id: 'mh-redblue-real', head: ['metaharness', 'redblue', 'run', '--tests', '10', '--max-cost-usd', '3'] },
+ { id: 'mh-evolve', head: ['metaharness', 'evolve', '--repo', '.', '--confirm'] },
+ { id: 'mh-security-bench', head: ['mcp', 'exec', '-t', 'metaharness_security_bench', '-p', '{}'] },
+ { id: 'mh-flywheel-run', head: ['metaharness', 'flywheel', 'run', '--proposer', 'local'] },
{ id: 'worker-optimize', head: ['hooks', 'worker', 'dispatch', '--trigger', 'optimize'] },
{ id: 'store', text: 'remember the login fix', head: ['memory', 'store', '--key'] },
]
diff --cc plugins/ruflo-console/tests/palette.test.ts
index 7f38d753e2,b12f47bab2..bf0366f178
--- a/plugins/ruflo-console/tests/palette.test.ts
+++ b/plugins/ruflo-console/tests/palette.test.ts
@@@ -86,15 -82,81 +86,90 @@@ describe('palette and /ruflo', () =>
await pane.unmount()
})
+ test('approvals: with no registered worker to vote as, nothing runs and it says why (the CLI would drop the vote silently)', { options: { boot: false } }, async ($, on) => {
+ const world = worldOf(on, RUFLO_FILES)
+ mock.clock(on)
+ await $.session.start(SESSION)
+
+ expect((await $.command.run(command('run vote-yes-proposal-1790903321981-23aov7'))).text).not.toMatch(/^Asked: /)
+ expect(runsOf(world.runs, 'consensus')).toHaveLength(0)
+ })
+
+ test('lab: an inspect entry runs at once with one fixed argv, and its lines fill the result panel', { options: { boot: false } }, async ($, on) => {
+ const world = worldOf(on, RUFLO_FILES)
+ mock.clock(on)
+ await $.session.start(SESSION)
+ await $.command.run(command('metaharness'))
+
+ const pane = await $.ui.mount({ ...paneAt(110), plugin: PLUGIN })
+
+ await pane.press({ key: 'lab-mh-mcp-scan' })
+
+ const text = textOf(await pane.drawn())
+
+ expect(text).not.toContain('Confirm:')
+ expect(text).toContain('by severity: critical 0 · high 0 · medium 0 · low 1 · info 0')
+ expect(text).toContain('[low] 12 unpinned dependency range(s)')
+ expect(world.runs.filter(argv => argv.includes('mcp-scan')).map(argv => argv.slice(4))).toEqual([['metaharness', 'mcp-scan', '--format', 'json']])
+ await pane.unmount()
+ })
+
+ test('lab: a spending entry asks first with its cost on the confirm row, and runs nothing on no', { options: { boot: false } }, async ($, on) => {
+ const world = worldOf(on, RUFLO_FILES)
+ mock.clock(on)
+ await $.session.start(SESSION)
+ await $.command.run(command('metaharness'))
+
+ const pane = await $.ui.mount({ ...paneAt(110), plugin: PLUGIN })
+
+ await pane.press({ key: 'lab-mh-redblue-real' })
+
+ const text = textOf(await pane.drawn())
+
+ expect(text).toContain('Confirm: redblue run with a real model judge (spends, capped at $3)?')
+ expect(text).toContain('runs: ruflo metaharness redblue run --tests 10 --max-cost-usd 3 --format json')
+ expect(text).toContain('COSTS MONEY: a real model judges each attack')
+ await pane.press({ key: 'cancel' })
+ expect(world.runs.some(argv => argv.includes('redblue'))).toBe(false)
+ await pane.unmount()
+ })
+
+ test('lab: promote is never run, not even with every lab button pressed and every ask confirmed', { options: { boot: false } }, async ($, on) => {
+ const world = worldOf(on, RUFLO_FILES)
+ mock.clock(on)
+ await $.session.start(SESSION)
+ await $.command.run(command('metaharness'))
+
+ const pane = await $.ui.mount({ ...paneAt(110), plugin: PLUGIN })
+ const keys = elementsOf(await pane.drawn(), 'Button').map(keyOf).filter(key => key.startsWith('lab-mh-'))
+
+ expect(keys.length).toBeGreaterThan(20)
+
+ for (const key of keys) {
+ await $.command.run(command('metaharness'))
+ await pane.press({ key })
+ if (textOf(await pane.drawn()).includes('Confirm:')) await pane.press({ key: 'confirm' })
+ }
+
+ expect(world.runs.some(argv => argv.includes('promote'))).toBe(false)
+ expect(world.runs.some(argv => argv.includes('flywheel') && argv.includes('--confirm'))).toBe(false)
+ expect((await $.command.run(command('run mh-promote'))).text).toMatch(/^No palette entry "mh-promote"/)
+ await pane.unmount()
+ })
+
+ test('lab headless: /ruflo run mh-mcp-scan answers with what the scan printed', { options: { boot: false } }, async ($, on) => {
+ worldOf(on, RUFLO_FILES)
+ mock.clock(on)
+ await $.session.start({ ...SESSION, isInteractive: false })
+
+ const answer = (await $.command.run(command('run mh-mcp-scan'))).text ?? ''
+
+ expect(answer).toMatch(/^✓ mcp-scan: static MCP findings by severity · exit 0\n/)
+ expect(answer).toContain(' [low] 12 unpinned dependency range(s)')
+ // An entry that cannot run headless says why: the typed ones name the command to type.
+ expect((await $.command.run(command('run mh-learn-run'))).text).toBe('nothing to do: type it in the terminal (i): ruflo metaharness learn --run --format json --host claude-code --model haiku --slice <path>')
+ })
+
test('/ruflo help, an unknown word, and the hints when ruflo-mods or ruflo-swarm are not loaded', { options: { boot: false } }, async ($, on) => {
worldOf(on, RUFLO_FILES)
mock.clock(on)