🌊 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): 0.16.0 — Learning page: animated pulse, folded settings and configuration, self-learning actions (pretrain, consolidate, pattern store)
ruv881067bc011f
diff --git a/plugins/ruflo-console/.claude-plugin/plugin.json b/plugins/ruflo-console/.claude-plugin/plugin.jsonindex 5b9a9860b1..7b5507da9a 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; no network by default.",- "version": "0.15.0",+ "version": "0.16.0","author": {"name": "ruvnet","url": "https://github.com/ruvnet"diff --git a/plugins/ruflo-console/hooks/controller.ts b/plugins/ruflo-console/hooks/controller.tsindex affef82737..07f269f087 100644--- a/plugins/ruflo-console/hooks/controller.ts+++ b/plugins/ruflo-console/hooks/controller.ts@@ -22,6 +22,7 @@ import { listSkills } from './skills'import { CLI_PREFIXES, isBooting, NAV_KEY, NAV_STYLES, PANE_ID, push, rowsOf, storeKeyOf, type State } from './state'import type { Actions } from './views/common'import { picturesOf } from './views/frames'+import { pulseDue } from './pulse'const ACTIVITY_BUCKET_MS = 5_000const PANE_WATCH_MS = 1_000@@ -268,6 +269,8 @@ export function createController(state: State, host: Host): Controller {wasBooting = booting+ if (pulseDue(state.view, started)) host.invalidate()+for (const [key, grid] of picturesOf(state, state.pane.columns, Date.now(), Date.now())) {const mounted = state.mounted.get(key)diff --git a/plugins/ruflo-console/hooks/neural.ts b/plugins/ruflo-console/hooks/neural.tsindex f5e0f7926a..7a9a700422 100644--- a/plugins/ruflo-console/hooks/neural.ts+++ b/plugins/ruflo-console/hooks/neural.ts@@ -12,6 +12,7 @@ import { numberOf, plain, recordOf } from './data/parse'import { labLines } from './mh-lab'import type { State } from './state'+const PRETRAIN_NOTE = 'local compute that reads the repository and writes the intelligence store (patterns, no model calls)'const TRAIN_NOTE = 'local compute, seconds to minutes; writes .claude-flow/neural (patterns.json and a checkpoint); no model calls'/** `coordination 50`: a pattern type, then epochs from 1 to 500 (default 20). */@@ -71,6 +72,18 @@ export function routeSpec(text: string): ActionSpec | null {return task === null ? null : autoSpec('nn-route', `which agent for "${task.slice(0, 40)}"`, 'read', ['hooks', 'route', '--task', task, '--format', 'json'], { read: routeRead })}+export function patternSearchSpec(text: string): ActionSpec | null {+ const query = freeText(text, 300)++ return query === null ? null : autoSpec('nn-pattern-search', `search patterns for "${query.slice(0, 40)}"`, 'read', tool('hooks_intelligence_pattern-search', { query, topK: 5 }))+}++export function patternStoreSpec(text: string): ActionSpec | null {+ const pattern = freeText(text, 300)++ return pattern === null ? null : autoSpec('nn-pattern-store', `store the pattern "${pattern.slice(0, 40)}"`, 'local', tool('hooks_intelligence_pattern-store', { pattern, type: 'general' }), { note: 'local; adds one pattern to the ReasoningBank (HNSW-indexed) the router and recall read' })+}+export function explainSpec(text: string): ActionSpec | null {const task = freeText(text, 300)@@ -90,6 +103,10 @@ export function neuralEntries(state: State): AutoEntry[] {['nn-patterns', 'neural patterns: the stored patterns, their confidence and use', autoSpec('nn-patterns', 'neural patterns', 'read', ['neural', 'patterns', '--action', 'list'])],['nn-analyze', 'neural optimize --method analyze: pattern memory by component', autoSpec('nn-analyze', 'pattern memory analysis', 'read', ['neural', 'optimize', '--method', 'analyze'])],['nn-intel', 'hooks intelligence stats: SONA, MoE, EWC++, LoRA and the router', autoSpec('nn-intel', 'intelligence stats', 'read', tool('hooks_intelligence_stats', {}))],+ ['nn-pretrain-shallow', 'hooks pretrain (shallow): bootstrap intelligence from this repository, quickly', autoSpec('nn-pretrain-shallow', 'pretrain from the repository (shallow)', 'local', tool('hooks_pretrain', { depth: 'shallow' }), { note: PRETRAIN_NOTE, timeoutMs: 300_000 })],+ ['nn-pretrain-medium', 'hooks pretrain (medium): the default depth', autoSpec('nn-pretrain-medium', 'pretrain from the repository (medium)', 'local', tool('hooks_pretrain', { depth: 'medium' }), { note: PRETRAIN_NOTE, timeoutMs: 600_000 })],+ ['nn-pretrain-deep', 'hooks pretrain (deep): the whole repository, slower', autoSpec('nn-pretrain-deep', 'pretrain from the repository (deep)', 'local', tool('hooks_pretrain', { depth: 'deep' }), { note: PRETRAIN_NOTE, timeoutMs: 900_000 })],+ ['nn-consolidate', 'agentdb consolidate: ask AgentDB to consolidate retained memories', autoSpec('nn-consolidate', 'consolidate retained memories', 'local', tool('agentdb_consolidate', {}), { note: 'local; rewrites AgentDB’s retained memories (it refuses when the bridge is unavailable)' })],['nn-quantize', 'neural optimize --method quantize: patterns to Int8', autoSpec('nn-quantize', 'quantize the stored patterns to Int8', 'local', ['neural', 'optimize', '--method', 'quantize'], { note: 'local compute; rewrites the stored pattern embeddings as Int8 (about 4x smaller, slightly less exact)' })],['nn-compress', 'neural_compress quantize: compress the neural store', autoSpec('nn-compress', 'compress the neural store (quantize)', 'local', tool('neural_compress', { method: 'quantize' }), { note: 'local compute; rewrites the neural store in .claude-flow/neural (needs memory init first)' })],]@@ -100,6 +117,8 @@ export function neuralEntries(state: State): AutoEntry[] {}out.push({ id: 'nn-train', group: 'neural', label: 'nn-train <pattern> [epochs]: train neural patterns', make: text => trainSpec(state, text) })+ out.push({ id: 'nn-pattern-search', group: 'neural', label: 'nn-pattern-search <query>: search the stored patterns by meaning', make: patternSearchSpec })+ out.push({ id: 'nn-pattern-store', group: 'neural', label: 'nn-pattern-store <text>: store a pattern in the ReasoningBank', make: patternStoreSpec })out.push({ id: 'nn-route', group: 'neural', label: 'nn-route <task>: which agent for this task?', make: routeSpec })out.push({ id: 'nn-explain', group: 'neural', label: 'nn-explain <task>: why the router picks that agent', make: explainSpec })out.push({ id: 'nn-predict', group: 'neural', label: 'nn-predict <text>: the trained models’ top predictions', make: predictSpec })diff --git a/plugins/ruflo-console/hooks/palette.ts b/plugins/ruflo-console/hooks/palette.tsindex a5a790f447..bd80dba1a3 100644--- a/plugins/ruflo-console/hooks/palette.ts+++ b/plugins/ruflo-console/hooks/palette.ts@@ -65,7 +65,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: readonly string[] = ['route', 'store', 'search', 'propose', 'broadcast', 'task', 'mission', 'cost-budget', 'x-join', 'x-read', 'x-publish', 'x-create', 'x-grant', 'x-hub', 'x-admit', 'catalog-install', 'catalog-uninstall', 'catalog-enable', 'catalog-disable', 'catalog-update', 'settings-set', 'settings-core', 'ask', 'ask-aside', 'mission-goal', 'mission-aside', 'mission-guide', 'mission-auto', ...MEM_KEYWORDS, ...SECURE_KEYWORDS, 'skills-find', 'auto-wf-new', 'auto-wf-validate', 'auto-ap-history', 'auto-ses-save', 'auto-cfg-get', 'auto-cfg-set', 'auto-task-new', 'nn-train', 'nn-route', 'nn-explain', 'nn-predict']+const TEXT_KEYWORDS: readonly string[] = ['route', 'store', 'search', 'propose', 'broadcast', 'task', 'mission', 'cost-budget', 'x-join', 'x-read', 'x-publish', 'x-create', 'x-grant', 'x-hub', 'x-admit', 'catalog-install', 'catalog-uninstall', 'catalog-enable', 'catalog-disable', 'catalog-update', 'settings-set', 'settings-core', 'ask', 'ask-aside', 'mission-goal', 'mission-aside', 'mission-guide', 'mission-auto', ...MEM_KEYWORDS, ...SECURE_KEYWORDS, 'skills-find', 'auto-wf-new', 'auto-wf-validate', 'auto-ap-history', 'auto-ses-save', 'auto-cfg-get', 'auto-cfg-set', 'auto-task-new', 'nn-train', 'nn-pattern-search', 'nn-pattern-store', 'nn-route', 'nn-explain', 'nn-predict']/** Every entry for the state as it is, before filtering. */export function paletteEntries(state: State, nowMs: number): PaletteEntry[] {diff --git a/plugins/ruflo-console/hooks/pulse.ts b/plugins/ruflo-console/hooks/pulse.tsnew file mode 100644index 0000000000..2ac57f8860--- /dev/null+++ b/plugins/ruflo-console/hooks/pulse.ts@@ -0,0 +1,17 @@+/**+ * The Learning page's pulse is text drawn from the clock, so the page needs to be redrawn while it is in front: about three times a+ * second (every 350 ms), from the frame loop, which only runs while the pane is shown and focused. No other page asks.+ */+let last = 0++export function pulseDue(view: string, nowMs: number): boolean {+ if (view !== 'learning') return false++ const slot = Math.floor(nowMs / 350)++ if (slot === last) return false++ last = slot++ return true+}diff --git a/plugins/ruflo-console/hooks/views/learning-pulse.ts b/plugins/ruflo-console/hooks/views/learning-pulse.tsnew file mode 100644index 0000000000..70a33b2c44--- /dev/null+++ b/plugins/ruflo-console/hooks/views/learning-pulse.ts@@ -0,0 +1,71 @@+import type { RenderElement } from 'claude-code'++import { gauge, sparkline } from '../memory-lines'+import { count, rule, row, text, THEME, type Ctx } from './common'+import { stagesOf } from './frames'++/** One step of the animation every 160 ms; nothing moves while the pane is hidden (the frame loop stops). */+const beat = (ctx: Ctx, ms: number): number => Math.floor(ctx.nowMs / ms)++/**+ * The learning pulse: text charts that move while the pane is open. A marker travels the pipeline (RETRIEVE → JUDGE → DISTILL →+ * CONSOLIDATE), the router's model mix is a bar chart with a highlight that sweeps along each bar, and the success rate is a sparkline+ * with a scanning cursor. They draw what was measured and nothing else: no data, no chart.+ */+export function pulseRows(ctx: Ctx): RenderElement[] {+ const { state } = ctx+ const rows: RenderElement[] = [rule(ctx, 'Learning pulse', 'live: the marker moves, the data is what ruflo measured')]+ const stages = stagesOf(state)+ const at = beat(ctx, 700) % Math.max(1, stages.length)++ rows.push(+ row(+ ctx,+ stages.flatMap((stage, i) => [+ ctx.kit.Text({ bold: i === at, color: i === at ? THEME.warn : THEME.info, children: ` ${i === at ? '●' : '○'} ${stage.name} ${stage.count ?? 'n/a'}` }),+ ...(i < stages.length - 1 ? [ctx.kit.Text({ dimColor: true, children: ' ━━' })] : []),+ ]),+ 'pulse-pipeline',+ ),+ )++ const router = state.snapshot?.router ?? null+ const mix = router?.distribution.filter(entry => entry.count > 0) ?? []++ if (mix.length > 0) {+ const top = Math.max(...mix.map(entry => entry.count))+ const width = Math.max(8, Math.min(32, ctx.columns - 36))+ const sweep = beat(ctx, 160)++ for (const entry of mix.slice(0, 6)) {+ const bar = gauge(entry.count, top, width).split('')+ const filled = bar.filter(cell => cell === '█').length++ if (filled > 1) bar[sweep % filled] = '▓'+ rows.push(text(ctx, ` ${entry.model.slice(0, 14).padEnd(14)} ${bar.join('')} ${count(entry.count)}`, { color: THEME.ok }))+ }+ } else rows.push(text(ctx, ' model mix: n/a — no .swarm/model-router-state.json', { dimColor: true }))++ const points = state.snapshot?.outcomes?.points ?? []++ if (points.length > 1) {+ // Running success rate over the last 24 outcomes, as eight-level bars; the cursor sweeps left to right.+ const window = points.slice(-24)+ const rates = window.map((_, i) => Math.round((window.slice(0, i + 1).filter(point => point.ok).length / (i + 1)) * 8))+ const bars = sparkline(rates.map(rate => rate + 1)).split('')++ bars[beat(ctx, 200) % bars.length] = '┃'+ rows.push(text(ctx, ` success ${bars.join('')} ${window.filter(point => point.ok).length}/${window.length} of the last ${window.length}`, { color: THEME.ok }))+ } else rows.push(text(ctx, ' success rate: n/a — fewer than two routed outcomes', { dimColor: true }))++ const neural = state.snapshot?.neural ?? null++ if (neural !== null) {+ const sizes = { trajectories: neural.trajectories ?? 0, patterns: neural.patterns ?? 0, signals: neural.signals ?? 0 }+ const top = Math.max(1, sizes.trajectories, sizes.patterns, sizes.signals)++ for (const [name, value] of Object.entries(sizes)) rows.push(text(ctx, ` ${name.padEnd(14)} ${gauge(value, top, 24)} ${count(value)}`, { color: THEME.info }))+ }++ return rows+}diff --git a/plugins/ruflo-console/hooks/views/learning.ts b/plugins/ruflo-console/hooks/views/learning.tsindex 566d7aa94a..c401c94141 100644--- a/plugins/ruflo-console/hooks/views/learning.ts+++ b/plugins/ruflo-console/hooks/views/learning.ts@@ -1,8 +1,52 @@import type { RenderElement } from 'claude-code'import type { Intelligence } from '../data/cli'-import { ago, col, count, kv, live, pct, picture, rule, sourceLine, starts, text, THEME, type Ctx } from './common'+import { ago, col, count, kv, live, pct, picture, row, rule, section, sourceLine, starts, text, THEME, type Ctx } from './common'import { stagesOf } from './frames'+import { settingsOf } from '../settings'+import { resultRows } from './automate'+import { pulseRows } from './learning-pulse'+import { neuralActionRows } from './neural'++/** The two switches that decide whether ruflo learns at all, folded away: each is a confirm-gated `ruflo config set`. */+function configRows(ctx: Ctx): RenderElement[] {+ const core = settingsOf(ctx.state).core+ const keys = [+ { key: 'neural.enabled', title: 'Neural learning', help: 'SONA / MoE pattern learning' },+ { key: 'hooks.enabled', title: 'Hooks', help: 'hooks that learn from your edits and routes' },+ ]++ return section(+ ctx,+ 'learn-config',+ 'Settings & configuration',+ 'what lets ruflo learn · each change asks first',+ [+ ...keys.map(item => {+ const value = core?.get(item.key)++ return row(+ ctx,+ [+ ctx.kit.Text({ bold: true, color: THEME.head, children: ` ${item.title.padEnd(16)}` }),+ ctx.kit.Text({ color: value === 'true' ? THEME.ok : value === 'false' ? THEME.bad : THEME.info, children: ` ${value === undefined ? 'n/a (open Settings to read it)' : value === 'true' ? 'on' : 'off'} ` }),+ ctx.kit.Button({ key: `learn-cfg-on-${item.key}`, label: ' ● on ', plain: true, onPress: () => ctx.act.settings.core(item.key, 'true') }),+ ctx.kit.Button({ key: `learn-cfg-off-${item.key}`, label: ' ○ off ', plain: true, onPress: () => ctx.act.settings.core(item.key, 'false') }),+ ctx.kit.Text({ dimColor: true, wrap: 'truncate-end', children: ` ${item.help}` }),+ ],+ `learn-cfg-${item.key}`,+ )+ }),+ text(ctx, ' every other setting is in Settings (s): the router, memory and swarm keys, the AI preferences', { dimColor: true }),+ ],+ false,+ )+}++/** The Learning Lab's actions on this page, folded: what was learned, training, pretrain, consolidate, the pattern store, the router. */+function actionRows(ctx: Ctx): RenderElement[] {+ return section(ctx, 'learn-actions', 'Self-learning actions', 'train, pretrain, consolidate, teach a pattern, route: the answer opens under the button', neuralActionRows(ctx), false)+}/*** What ruflo has learned, from its own stores: the router's last pick and how routed tasks turned out, the model tier@@ -75,5 +119,5 @@ export function learningView(ctx: Ctx): RenderElement {// 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')+ return col(ctx, [...resultRows(ctx, ['nn-']), ...pulseRows(ctx), ...rows, ...configRows(ctx), ...actionRows(ctx)], 'learning')}diff --git a/plugins/ruflo-console/hooks/views/neural.ts b/plugins/ruflo-console/hooks/views/neural.tsindex b8cbe14e7e..1fa888981a 100644--- a/plugins/ruflo-console/hooks/views/neural.ts+++ b/plugins/ruflo-console/hooks/views/neural.ts@@ -71,6 +71,17 @@ function trainingRows(ctx: Ctx): RenderElement[] {return rows}+/** Bootstrap, consolidate, and the pattern store: the learning loop's own actions. */+function selfLearnRows(ctx: Ctx): RenderElement[] {+ return [+ rule(ctx, 'Self-learning', 'bootstrap, consolidate and teach the ReasoningBank · local, no model calls'),+ strip(ctx, 'nn-pretrain', [{ id: 'nn-pretrain-shallow', label: 'pretrain: shallow', cost: 'local' }, { id: 'nn-pretrain-medium', label: 'medium', cost: 'local' }, { id: 'nn-pretrain-deep', label: 'deep', cost: 'local' }]),+ strip(ctx, 'nn-consolidate', [{ id: 'nn-consolidate', label: 'consolidate retained memories', cost: 'local' }]),+ field(ctx, 'nn-pattern-search', 'pattern search', 'what the stored patterns should be searched for, in words', 'search'),+ field(ctx, 'nn-pattern-store', 'teach a pattern', 'a pattern to remember: always run the auth tests after touching login', 'store'),+ ]+}+function routerRows(ctx: Ctx): RenderElement[] {return [rule(ctx, 'Router', 'which agent for this task? · $0, local'),@@ -80,6 +91,9 @@ function routerRows(ctx: Ctx): RenderElement[] {]}+/** Everything the Learning Lab does, as rows: what was learned, training, self-learning actions and the router. Also drawn, folded, on the Learning page. */+export const neuralActionRows = (ctx: Ctx): RenderElement[] => [...intelligenceRows(ctx), ...trainingRows(ctx), ...selfLearnRows(ctx), ...routerRows(ctx)]+/*** The Learning Lab: what ruflo has learned (from its own files), training with a loss sparkline, and the router's* "which agent?" and "why?". Opening it runs nothing; reads run on a click, training and compression ask first.@@ -89,9 +103,7 @@ export function neuralView(ctx: Ctx): RenderElement {ctx,[...resultRows(ctx, ['nn-']),- ...intelligenceRows(ctx),- ...trainingRows(ctx),- ...routerRows(ctx),+ ...neuralActionRows(ctx),text(ctx, ' $0 read, runs at once · cpu local compute that writes .claude-flow/neural, asks first · no entry here calls a paid model', { dimColor: true }),],'neural',diff --git a/plugins/ruflo-console/hooks/views/pane.ts b/plugins/ruflo-console/hooks/views/pane.tsindex b20601513d..1ab3cc27d8 100644--- a/plugins/ruflo-console/hooks/views/pane.ts+++ b/plugins/ruflo-console/hooks/views/pane.ts@@ -253,6 +253,7 @@ const RESULT_OF: Partial<Record<ViewId, (ctx: Ctx) => RenderElement[]>> = {perf: perfResult,automate: automateResult,neural: neuralResult,+ learning: neuralResult,}export function paneView(base: Ctx): RenderElement {diff --git a/plugins/ruflo-console/scripts/smoke.sh b/plugins/ruflo-console/scripts/smoke.shindex aa5928e471..f54e0028ac 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.15.0"+step "1. plugin.json declares ruflo-console 0.16.0"grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \- && grep -q '"version": "0.15.0"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"+ && grep -q '"version": "0.16.0"' "$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/learning.spec.ts b/plugins/ruflo-console/tests/learning.spec.tsnew file mode 100644index 0000000000..6409f2033f--- /dev/null+++ b/plugins/ruflo-console/tests/learning.spec.ts@@ -0,0 +1,65 @@+/**+ * The Learning page's new actions under vitest: pretrain, consolidate and the pattern store run fixed argv through `mcp exec`, the+ * typed ones validate their text, and every entry is reachable headless (`/ruflo run nn-...`).+ */+import { describe, expect, it } from 'vitest'++import { neuralEntries, patternSearchSpec, patternStoreSpec } from '../hooks/neural'+import { pulseDue } from '../hooks/pulse'+import { newState } from '../hooks/state'++const param = (argv: readonly string[] | undefined): Record<string, unknown> => JSON.parse(argv?.[argv.indexOf('-p') + 1] ?? '{}') as Record<string, unknown>++describe('learning actions', () => {+ it('pretrain has three depths, each a fixed hooks_pretrain call that says it is local and writes the intelligence store', () => {+ const entries = neuralEntries(newState({}))++ for (const depth of ['shallow', 'medium', 'deep']) {+ const entry = entries.find(candidate => candidate.id === `nn-pretrain-${depth}`)++ expect(entry?.spec?.args.slice(0, 4)).toEqual(['mcp', 'exec', '-t', 'hooks_pretrain'])+ expect(param(entry?.spec?.args)).toEqual({ depth })+ expect(entry?.spec?.note).toContain('local')+ expect(entry?.spec?.note).toContain('writes')+ }+ })++ it('consolidate is the agentdb_consolidate tool with no options (it refuses any), and asks as a local write', () => {+ const entry = neuralEntries(newState({})).find(candidate => candidate.id === 'nn-consolidate')++ expect(entry?.spec?.args.slice(0, 4)).toEqual(['mcp', 'exec', '-t', 'agentdb_consolidate'])+ expect(param(entry?.spec?.args)).toEqual({})+ expect(entry?.spec?.isReadOnly).not.toBe(true)+ })++ it('pattern search is a read with the text as the query; pattern store is a local write; empty or flag-shaped text builds nothing', () => {+ const search = patternSearchSpec('auth tests after login')+ const store = patternStoreSpec('always run the auth tests after touching login')++ expect(search?.args.slice(0, 4)).toEqual(['mcp', 'exec', '-t', 'hooks_intelligence_pattern-search'])+ expect(param(search?.args)).toEqual({ query: 'auth tests after login', topK: 5 })+ expect(search?.isReadOnly).toBe(true)+ expect(store?.args.slice(0, 4)).toEqual(['mcp', 'exec', '-t', 'hooks_intelligence_pattern-store'])+ expect(param(store?.args)).toEqual({ pattern: 'always run the auth tests after touching login', type: 'general' })+ expect(store?.isReadOnly).not.toBe(true)+ expect(store?.note).toContain('ReasoningBank')++ for (const bad of ['', ' ', '--force']) {+ expect(patternSearchSpec(bad), bad).toBeNull()+ expect(patternStoreSpec(bad), bad).toBeNull()+ }+ })++ it('only the Learning page asks for a redraw, about every 350 ms, and not twice in one slot', () => {+ expect(pulseDue('overview', 10_000)).toBe(false)+ expect(pulseDue('learning', 10_000)).toBe(true)+ expect(pulseDue('learning', 10_100)).toBe(false)+ expect(pulseDue('learning', 10_400)).toBe(true)+ })++ it('both typed entries are listed for the palette, so /ruflo run nn-pattern-search <text> works headless', () => {+ const ids = neuralEntries(newState({})).map(entry => entry.id)++ expect(ids).toEqual(expect.arrayContaining(['nn-pattern-search', 'nn-pattern-store', 'nn-pretrain-medium', 'nn-consolidate']))+ })+})diff --git a/plugins/ruflo-console/tests/learning.test.ts b/plugins/ruflo-console/tests/learning.test.tsnew file mode 100644index 0000000000..c6953287db--- /dev/null+++ b/plugins/ruflo-console/tests/learning.test.ts@@ -0,0 +1,96 @@+/**+ * The Learning page: a pulse that moves, a folded Settings & configuration section whose switches ask first, and the folded+ * self-learning actions (pretrain, consolidate, the pattern store) whose confirm and answer open under the button pressed.+ */+import type { TestBody } from 'claude-code/testing'+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 keys = (tree: Parameters<typeof elementsOf>[0]) => elementsOf(tree, 'Button').map(keyOf)++type Body = Parameters<TestBody>++async function opened($: Body[0], on: Body[1]) {+ const world = worldOf(on, RUFLO_FILES)+ const clock = mock.clock(on)++ await $.session.start(SESSION)+ await $.command.run(command('learning'))++ const pane = await $.ui.mount({ ...paneAt(150), surface: 'terminal' as const, plugin: PLUGIN })++ await pane.drawn()++ return { world, clock, pane }+}++describe('learning page', () => {+ test('the pulse is there, and it moves: over a couple of seconds the pipeline marker visits more than one stage', { options: { boot: false } }, async ($, on) => {+ const { pane } = await opened($, on)+ const first = textOf(await pane.drawn())++ expect(first).toContain('LEARNING PULSE')+ expect(first).toMatch(/[●○] RETRIEVE/)++ // The pulse reads the clock the pane draws with. A press redraws the page; sample it across real time.+ const seen = new Set<string>()+ const mark = (text: string) => /● ([A-Z]+)/.exec(text)?.[1]++ for (let i = 0; i < 6; i++) {+ await new Promise(resolve => setTimeout(resolve, 450))+ await pane.press({ key: 'sec-learn-config' })++ const at = mark(textOf(await pane.drawn()))++ if (at !== undefined) seen.add(at)+ }++ expect(seen.size).toBeGreaterThan(1)+ await pane.unmount()+ })++ test('Settings & configuration is folded; opened, a switch asks first with its key, and nothing runs until yes', { options: { boot: false } }, async ($, on) => {+ const { world, pane } = await opened($, on)+ const folded = await pane.drawn()++ expect(textOf(folded)).toContain('SETTINGS & CONFIGURATION')+ expect(keys(folded)).toContain('sec-learn-config')+ expect(keys(folded)).not.toContain('learn-cfg-off-neural.enabled')+ await pane.press({ key: 'sec-learn-config' })+ expect(keys(await pane.drawn())).toEqual(expect.arrayContaining(['learn-cfg-on-neural.enabled', 'learn-cfg-off-neural.enabled', 'learn-cfg-on-hooks.enabled']))+ await pane.press({ key: 'learn-cfg-off-neural.enabled' })++ const asked = await pane.drawn()++ expect(textOf(asked)).toContain('neural.enabled')+ expect(textOf(asked)).toContain('CONFIRM NEEDED')+ expect(world.runs.filter(argv => argv.includes('config') && argv.includes('set'))).toEqual([])+ await pane.unmount()+ })++ test('Self-learning actions is folded; opened, pretrain asks first with the confirm right under it; the pattern fields are there', { options: { boot: false } }, async ($, on) => {+ const { world, pane } = await opened($, on)++ expect(keys(await pane.drawn())).not.toContain('run-nn-pretrain-shallow')+ await pane.press({ key: 'sec-learn-actions' })++ const open = await pane.drawn()+ const order = keys(open)++ expect(order).toEqual(expect.arrayContaining(['run-nn-pretrain-shallow', 'run-nn-pretrain-medium', 'run-nn-pretrain-deep', 'run-nn-consolidate']))+ expect(elementsOf(open, 'Input').map(keyOf)).toEqual(expect.arrayContaining(['in-nn-pattern-search', 'in-nn-pattern-store']))+ await pane.press({ key: 'run-nn-pretrain-medium' })++ const asked = await pane.drawn()+ const after = keys(asked)++ expect(textOf(asked)).toContain('CONFIRM NEEDED')+ expect(textOf(asked)).toContain('pretrain from the repository (medium)')+ // The confirm follows the strip of three pretrain buttons, before the next row's button.+ expect(after.indexOf('confirm')).toBe(after.indexOf('run-nn-pretrain-deep') + 1)+ expect(world.runs.filter(argv => argv.includes('hooks_pretrain'))).toEqual([])+ await pane.unmount()+ })+})diff --git a/scripts/ci-test-baseline.txt b/scripts/ci-test-baseline.txtindex 8b63312371..cba4843b4a 100644--- a/scripts/ci-test-baseline.txt+++ b/scripts/ci-test-baseline.txt@@ -166,6 +166,7 @@ plugins/ruflo-console/tests/views.test.tsplugins/ruflo-console/tests/labs.test.tsplugins/ruflo-console/tests/attention.test.tsplugins/ruflo-console/tests/loops.test.ts+plugins/ruflo-console/tests/learning.test.tsplugins/ruflo-console/tests/matrix.test.tsplugins/ruflo-console/tests/missions.test.tsplugins/ruflo-console/tests/settings.test.tsdiff --git a/v3/docs/adr/ADR-408-ruflo-console-mission-control.md b/v3/docs/adr/ADR-408-ruflo-console-mission-control.mdindex 2acc3db331..8f0ed1393c 100644--- a/v3/docs/adr/ADR-408-ruflo-console-mission-control.md+++ b/v3/docs/adr/ADR-408-ruflo-console-mission-control.md@@ -94,3 +94,9 @@ A folded section at the top of the Automation page (`hooks/loops.ts`, `views/loo- **Launcher:** asks first, with the exact text and a note that every tick is a billed Claude Code turn and that a loop auto-expires after 7 days; yes sends one visible `/loop ...` prompt to the main Claude UI (mid-turn it only fills the prompt box), where the engine runs it as a typed command. **List / stop my loops** asks Claude to list `CronList` and pending wake-ups and to ask before stopping any.- **Safety:** a task that starts with `/` must be one plugin command the session lists, followed by a few plain words (a worker needs its plugin); control and bidirectional characters are stripped; a hand-typed task is screened by AIDefence (a preset is the console's own text); the stop-condition grammar is closed; the input is at most 600 characters.- Tests: `tests/loops.spec.ts` (grammar, builder, every preset builds, launch asks first and screens), `tests/loops.test.ts` (the section in the Automation page; a worker preset without its plugin asks nothing).+## 13. The Learning page (0.16.0)++- **Learning pulse** (`views/learning-pulse.ts`): text charts that move while the page is in front: a marker travels RETRIEVE → JUDGE → DISTILL → CONSOLIDATE (700 ms a stage), the router's model mix is a bar chart with a highlight sweeping each bar, the running success rate over the last 24 routed outcomes is a sparkline with a scanning cursor, and SONA's trajectories, patterns and signals are gauges. They draw only what was measured: no data, no chart (`n/a` says so). The frame loop asks for a redraw about three times a second while the Learning page is shown (`controller.ts`); nothing redraws while the pane is hidden or unfocused.+- **Settings & configuration** (folded): the two switches that decide whether ruflo learns at all, `neural.enabled` and `hooks.enabled`, each a confirm-gated `ruflo config set` through the Settings actions; every other key stays in Settings.+- **Self-learning actions** (folded, the Learning Lab's rows on this page): what was learned, training with its loss sparkline, **pretrain** at three depths (`hooks_pretrain` shallow, medium, deep: local compute that reads the repository and writes the intelligence store), **consolidate** (`agentdb_consolidate`, no options), **pattern search** (`hooks_intelligence_pattern-search`, a read) and **teach a pattern** (`hooks_intelligence_pattern-store`, a local write), and the router's route/explain/predict. Each is also `/ruflo run nn-...`. Their answers open under the button pressed (the attention panel, ADR section 11a), and the page keeps its own result block as the fallback.+- No entry calls a paid model. Tests: `tests/learning.spec.ts` (argv, validation, headless ids), `tests/learning.test.ts` (the pulse moves over real time; the folded sections; a confirm right under the pretrain strip).