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(console): add Theme Studio and Claude/Codex animated preset skill

rUv8213cfa1db48
diff --git a/plugins/ruflo-console/README.md b/plugins/ruflo-console/README.md
index 596b50dbbe..d9f29bcc13 100644
--- a/plugins/ruflo-console/README.md
+++ b/plugins/ruflo-console/README.md
@@ -99,3 +99,13 @@ Reload plugins after changing the option. Select `bbs` or `plain` to restore tho
Orbital includes a four-row animated ASCII telemetry header with a red scan line, green decorative pulse and orbit marker. The optional boot intro uses a rotating ASCII Earth (one turn per 12 seconds), with actual self-check counts below it. It runs for 1.5 seconds when data is ready, at most 6 seconds while data is pending. Set `fps` to `0` for still headers and no boot intro. Existing frame scheduling stops motion in hidden panes. The pulse and globe are decoration, not measured activity or a progress percentage.
Orbital adapts to the pane allocation. Below 48 drawing columns or 30 available rows, boot uses a compact check summary of at most nine rows. Failure totals remain near the top, with the first failing area shown when a third row fits. The swarm header uses its full graph at 56 drawing columns and 16 available header rows; smaller allocations use a compact animated strip. Header width reserves the existing toolbar icon space and is capped at 120 columns. Extremely small allocations clip text to the available cells. The existing live topology remains in the page body.
+
+### Theme Studio
+
+Open **Main Menu → Tools → Theme Studio**, the **Tools** navigation group, or `/ruflo themes`. Settings also links to the studio. Choose Classic BBS, Terminal plain or Orbital. Studio selections persist and override the plugin's configured look until **Use configured look** is selected.
+
+The terminal color picker provides swatches and exact `#RRGGBB` entry for headings, success, failure, warning, information and background. Preview the globe and swarm motion, adjust speed and decorative layers, then **Save preview and apply**. Up to twelve named custom presets are stored locally through the host; reusing a name replaces that preset. Failed saves leave the active theme unchanged. Settings `fps: 0` still disables animation. Layouts retain the compact/narrow fallbacks.
+
+**Generate with Claude** or **Generate with Codex** runs the bundled `generate-console-theme` skill through AI Terminal with its existing confirmation and model controls. Enter the design brief first, generate a preset, then paste the returned JSON into **Import theme JSON** and review before saving. The generator produces palette and motion variations of the existing Orbital renderer, not executable animation code. No additional API credentials are requested. Installed Claude plugins discover the bundled skill; Codex can read `plugins/ruflo-console/skills/generate-console-theme/SKILL.md` directly in this checkout.
+
+Imports are limited to 4096 characters and a strict version 1 data schema. Status labels and actual check results remain unchanged. Saving requires at least 3:1 foreground/background contrast; the generator aims for 4.5:1.
diff --git a/plugins/ruflo-console/hooks/ask-claude.ts b/plugins/ruflo-console/hooks/ask-claude.ts
index 8bbc83c7ec..e8f2a5c73b 100644
--- a/plugins/ruflo-console/hooks/ask-claude.ts
+++ b/plugins/ruflo-console/hooks/ask-claude.ts
@@ -52,6 +52,7 @@ export const VIEW_ASK: Record<ViewId, ViewAsk> = {
market: { default: 'Which of these plugins would help most for what I am doing?' },
adrs: { default: 'Which of my project’s ADRs matter for what I am working on, and does anything I have changed cut across an accepted decision?' },
whatsnew: { default: 'Which of these plugin changes matter for how I work, and does any breaking change need action from me?' },
+ themes: { default: 'Help me design a readable animated console theme with Theme Studio.' },
settings: { default: 'Which of these settings should I change for how I work?' },
agent: { default: 'What is this agent doing, and is anything wrong with it?' },
}
diff --git a/plugins/ruflo-console/hooks/bindings.ts b/plugins/ruflo-console/hooks/bindings.ts
index 61a1e191e1..c91f36d9fc 100644
--- a/plugins/ruflo-console/hooks/bindings.ts
+++ b/plugins/ruflo-console/hooks/bindings.ts
@@ -21,6 +21,7 @@ import { workflowsActions } from './wf-actions'
import { missionActions } from './mission-control'
import { catalogActions } from './plugin-catalog'
import { saveAllowed } from './remember'
+import { themeActions } from './themes'
import { pluginNames, settingsActions } from './settings'
import { catalogOf } from './plugin-catalog'
import { wireAnatole } from './anatole'
@@ -408,6 +409,7 @@ export function actionsOf(state: State, host: Host, runner: Runner, steps: Steps
// An rvlite query is MCP-only: it goes to the AI terminal typed, as ▸ edit does, and runs only when sent.
vector: vectorActions(state, runner, text => actions.term.load('claude', text)),
evolve: evolveActions(state, host, text => actions.term.ask('claude', text)),
+ themes: themeActions(state, host, (agent, text) => actions.term.ask(agent, text)),
settings: settingsActions(state, host, runner, (agent, text) => actions.term.ask(agent, text), () => CLI_PREFIXES[state.options.cli], () => pluginNames(state, (catalogOf(state).plugins ?? []).filter(plugin => plugin.options.length > 0).map(plugin => plugin.name))),
mission: { ...missionActions(state, host, runner), ...claudeActions(state, host, runner) },
ask: askActions(state, host, runner, () => actions),
diff --git a/plugins/ruflo-console/hooks/controller.ts b/plugins/ruflo-console/hooks/controller.ts
index bf2d63a96c..cf9a9379dc 100644
--- a/plugins/ruflo-console/hooks/controller.ts
+++ b/plugins/ruflo-console/hooks/controller.ts
@@ -23,6 +23,7 @@ import { createRunner, EXPIRY_TIMER, type Runner } from './runner'
import { advance, loadLedger, mcOf } from './mission-control'
import { hasLiveWork } from './mission-list'
import { loadAllowed } from './remember'
+import { loadThemes } from './themes'
import { loadAiPrefs } from './settings'
import { openLoaders } from './view-open'
import { listSkills } from './skills'
@@ -317,6 +318,7 @@ export function createController(state: State, host: Host): Controller {
let lastIdleMs = 0
// The AI terminal's saved model and budget apply from the first turn, not only once Settings was opened.
+ void loadThemes(state, host)
void loadAiPrefs(state, host)
void loadAllowed(state, host)
void loadLedger(state, host)
diff --git a/plugins/ruflo-console/hooks/gfx/orbital.ts b/plugins/ruflo-console/hooks/gfx/orbital.ts
index 71ccaf8b1b..1cedabbf80 100644
--- a/plugins/ruflo-console/hooks/gfx/orbital.ts
+++ b/plugins/ruflo-console/hooks/gfx/orbital.ts
@@ -1,13 +1,13 @@
/** Orbital cell art: decorative motion, never a simulated health or progress measurement. */
+import { ORBITAL_THEME, type ConsoleTheme } from '../themes'
import type { BootCheck } from '../boot-checks'
-import { Grid } from './raster'
+import { Grid, mix } from './raster'
import { bannerPicture } from './pictures'
-const RED = 0xf06449
-const GREEN = 0x72c79b
-const INK = 0xc6cbc8
-const DIM = 0x596561
-const BLACK = 0x000000
+function colors(theme: ConsoleTheme) {
+ const rgb = (hex: string) => parseInt(hex.slice(1), 16)
+ return { RED: rgb(theme.palette.head), GREEN: rgb(theme.palette.ok), INK: rgb(theme.palette.info), BLACK: rgb(theme.palette.background), BAD: rgb(theme.palette.bad), DIM: mix(rgb(theme.palette.background), rgb(theme.palette.info), 0.48) }
+}
const TAU = Math.PI * 2
// Original stylized continent silhouettes in longitude/latitude degrees, for decoration only.
@@ -36,17 +36,19 @@ function onLand(lon: number, lat: number): boolean {
})
}
-function blank(columns: number, rows: number): Grid {
+function blank(columns: number, rows: number, theme = ORBITAL_THEME): Grid {
+ const { INK, BLACK } = colors(theme)
const grid = new Grid(Math.max(1, Math.min(200, Math.floor(columns) || 1)), rows)
for (let y = 0; y < rows; y++) for (let x = 0; x < grid.columns; x++) grid.set(x, y, ' ', INK, BLACK)
return grid
}
/** Tilted orthographic Earth with fixed sunlight and a sparse starfield. One turn takes 12 seconds. */
-export function orbitalGlobe(columns: number, rows: number, timeMs: number): Grid {
+export function orbitalGlobe(columns: number, rows: number, timeMs: number, theme = ORBITAL_THEME): Grid {
+ const { RED, GREEN, INK, BLACK } = colors(theme)
const height = Math.max(5, Math.min(24, Math.floor(rows) || 5))
- const grid = blank(columns, height)
- const radius = Math.min((height - 1) / 2, (grid.columns - 1) / 4)
+ const grid = blank(columns, height, theme)
+ const radius = Math.max(0.25, Math.min((height - 1) / 2, (grid.columns - 1) / 4))
const angle = (Number.isFinite(timeMs) ? timeMs % 12000 : 0) / 12000 * TAU
const tilt = 23.4 * Math.PI / 180
const pitch = 0.18
@@ -66,7 +68,7 @@ export function orbitalGlobe(columns: number, rows: number, timeMs: number): Gri
if (Math.abs(ring - 1) < 0.09) grid.set(x, y, '.', 0x543b32, BLACK)
// Stable positions, slow brightness changes, and clear space around the limb.
const seed = ((x + 17) * 73856093 ^ (y + 11) * 19349663) >>> 0
- if (r2 > 1.2 && seed % 113 === 0) {
+ if (theme.motion.stars && r2 > 1.2 && seed % 113 === 0) {
const glow = 0.45 + 0.3 * (1 + Math.sin(angle + seed % 31)) / 2
grid.set(x, y, seed % 3 === 0 ? '+' : '.', tint(INK, glow), BLACK)
}
@@ -109,10 +111,11 @@ export function orbitalGlobe(columns: number, rows: number, timeMs: number): Gri
}
/** Fixed-height header: red scan line, travelling ASCII pulse and an orbit marker. */
-export function orbitalHeader(label: string, columns: number, timeMs: number, maxRows = 16): Grid {
+export function orbitalHeader(label: string, columns: number, timeMs: number, maxRows = 16, theme = ORBITAL_THEME): Grid {
+ const { RED, GREEN, INK, BLACK, DIM } = colors(theme)
const swarm = /swarm/i.test(label)
- const expanded = swarm && columns >= 56 && maxRows >= 16
- const grid = blank(columns, expanded ? 16 : Math.max(1, Math.min(4, maxRows)))
+ const expanded = theme.motion.topology && swarm && columns >= 56 && maxRows >= 16
+ const grid = blank(columns, expanded ? 16 : Math.max(1, Math.min(4, maxRows)), theme)
const tick = Math.floor((Number.isFinite(timeMs) ? timeMs : 0) / 160)
const fullTitle = ` RUFLO / ${label.toUpperCase()} `
const title = columns >= fullTitle.length ? fullTitle : columns >= 12 ? ` RUFLO / ${swarm ? 'SWARM' : label.toUpperCase()}` : ' RUFLO'
@@ -212,7 +215,7 @@ export function orbitalHeader(label: string, columns: number, timeMs: number, ma
}
/** Map the original banner's neon channels into Orbital's palette, preserving its highlight sweep. */
-function orbitalBrandColor(color: number): number {
+function orbitalBrandColor(color: number, theme = ORBITAL_THEME): number {
const r = (color >>> 16) & 255
const g = (color >>> 8) & 255
// Original magenta and cyan are mixed with white by the shared banner renderer.
@@ -220,39 +223,42 @@ function orbitalBrandColor(color: number): number {
const white = Math.max(0, Math.min(1 - cyan, (g - 42 - 175 * cyan) / 213))
const coral = 1 - cyan - white
const channel = (a: number, z: number, light: number) => Math.round(a * coral + z * cyan + light * white)
- return (channel(240, 114, 240) << 16) | (channel(100, 199, 239) << 8) | channel(73, 155, 226)
+ const { RED, GREEN, INK } = colors(theme)
+ const ch = (shift: number) => channel((RED >>> shift) & 255, (GREEN >>> shift) & 255, (INK >>> shift) & 255)
+ return (ch(16) << 16) | (ch(8) << 8) | ch(0)
}
/** Checks are actual self-check results; the globe and sweep are explicitly decorative. */
-export function orbitalBoot(project: string, columns: number, timeMs: number, checks?: readonly BootCheck[], maxRows = 30): Grid {
+export function orbitalBoot(project: string, columns: number, timeMs: number, checks?: readonly BootCheck[], maxRows = 30, theme = ORBITAL_THEME): Grid {
+ const { RED, GREEN, INK, BLACK, DIM, BAD } = colors(theme)
const available = Math.max(1, Math.min(30, Math.floor(maxRows) || 1))
if (columns < 48 || available < 30) {
- const grid = blank(columns, Math.min(9, available))
+ const grid = blank(columns, Math.min(9, available), theme)
const failed = checks?.filter(check => !check.ok) ?? []
const passed = checks?.filter(check => check.ok).length ?? 0
grid.text(0, 0, 'RUFLO / BOOT', RED)
- grid.text(0, 1, checks === undefined ? 'Pending checks' : `${passed} OK ${failed.length} FAIL`, failed.length ? RED : GREEN)
+ grid.text(0, 1, checks === undefined ? 'Pending checks' : `${passed} OK ${failed.length} FAIL`, failed.length ? BAD : GREEN)
// Reserve the first detail row for a real failure even in very short panes.
- if (grid.rows > 2) grid.text(0, 2, failed.length ? `FAIL ${failed[0]!.area}` : project, failed.length ? RED : DIM)
+ if (grid.rows > 2) grid.text(0, 2, failed.length ? `FAIL ${failed[0]!.area}` : project, failed.length ? BAD : DIM)
if (grid.rows > 3) {
const tick = Math.floor(Math.max(0, Number.isFinite(timeMs) ? timeMs : 0) / 100)
grid.text(0, 3, '.'.repeat(grid.columns), DIM)
grid.set(tick % grid.columns, 3, '>', GREEN)
}
const shown = [...failed, ...(checks?.filter(check => check.ok) ?? [])]
- shown.slice(0, Math.max(0, grid.rows - 5)).forEach((check, i) => grid.text(0, 4 + i, `${check.ok ? 'OK' : 'FAIL'} ${check.area}`, check.ok ? GREEN : RED))
+ shown.slice(0, Math.max(0, grid.rows - 5)).forEach((check, i) => grid.text(0, 4 + i, `${check.ok ? 'OK' : 'FAIL'} ${check.area}`, check.ok ? GREEN : BAD))
if (grid.rows >= 6) grid.text(0, grid.rows - 1, 'Local checks', DIM)
return grid
}
- const grid = blank(columns, 30)
+ const grid = blank(columns, 30, theme)
// Reuse the original console banner, including its half-block font and sweep, recolored for Orbital.
const banner = bannerPicture(project, grid.columns, timeMs, Math.max(0, Number.isFinite(timeMs) ? timeMs : 0))
for (let y = 0; y < banner.rows; y++) for (let x = 0; x < banner.columns; x++) {
const i = (y * banner.columns + x) * 3
- grid.set(x, y, banner.cells[i]!, orbitalBrandColor(banner.cells[i + 1]!), BLACK)
+ grid.set(x, y, banner.cells[i]!, orbitalBrandColor(banner.cells[i + 1]!, theme), BLACK)
}
- grid.text(0, 3, ' ruvnet / ORBITAL', DIM)
- const globe = orbitalGlobe(grid.columns, 16, timeMs)
+ grid.text(0, 3, ` ruvnet / ${theme.name.toUpperCase()}`, DIM)
+ const globe = theme.motion.globe ? orbitalGlobe(grid.columns, 16, timeMs, theme) : blank(grid.columns, 16, theme)
const intro = Math.max(0, Number.isFinite(timeMs) ? timeMs : 0)
const reveal = Math.min(1, Math.max(0, (intro - 150) / 750))
const eased = 1 - Math.pow(1 - reveal, 3)
@@ -275,7 +281,7 @@ export function orbitalBoot(project: string, columns: number, timeMs: number, ch
grid.text(0, 20, ' LOADING CONSOLE / decorative orbit', RED)
const passed = checks?.filter(c => c.ok).length ?? 0
const failed = checks?.filter(c => !c.ok).length ?? 0
- grid.text(0, 21, checks === undefined ? ' Self-check: pending' : ` Self-check: ${passed} passed / ${failed} failed`, failed > 0 ? RED : GREEN)
+ grid.text(0, 21, checks === undefined ? ' Self-check: pending' : ` Self-check: ${passed} passed / ${failed} failed`, failed > 0 ? BAD : GREEN)
const age = Math.max(0, Number.isFinite(timeMs) ? timeMs : 0)
const scan = Math.floor(age / 100) % Math.max(1, grid.columns - 2)
grid.text(0, 22, ' '.repeat(grid.columns), DIM)
@@ -297,7 +303,7 @@ export function orbitalBoot(project: string, columns: number, timeMs: number, ch
const name = check.ok ? check.area.toUpperCase().slice(0, reveal) : check.area.toUpperCase()
const status = check.ok ? '[PASS]' : '[FAIL]'
const detail = !check.ok && check.problems.length > 0 ? ` / ${check.problems[0]}` : ''
- grid.text(0, 23 + i, ` ${status} ${name}${detail}`.slice(0, check.ok && grid.columns >= 55 ? grid.columns - 14 : grid.columns), check.ok ? GREEN : RED)
+ grid.text(0, 23 + i, ` ${status} ${name}${detail}`.slice(0, check.ok && grid.columns >= 55 ? grid.columns - 14 : grid.columns), check.ok ? GREEN : BAD)
const cursor = 8 + name.length
if (check.ok && reveal < check.area.length && cursor < (grid.columns >= 55 ? grid.columns - 14 : grid.columns)) grid.set(cursor, 23 + i, '_', INK)
if (grid.columns >= 55 && check.ok) {
diff --git a/plugins/ruflo-console/hooks/gfx/pictures.ts b/plugins/ruflo-console/hooks/gfx/pictures.ts
index 7a70bfb1a8..7d6e3e004e 100644
--- a/plugins/ruflo-console/hooks/gfx/pictures.ts
+++ b/plugins/ruflo-console/hooks/gfx/pictures.ts
@@ -4,6 +4,7 @@
* always fits the mounted Raster. What motion means is said beside each picture: data where it is data, decoration
* where it is not.
*/
+import type { ConsoleTheme } from '../themes'
import { Braille, COLOR, Grid, mix, ramp, sparkline } from './raster'
import { bigText } from './font'
import { hash } from './boot-cyber'
@@ -21,12 +22,12 @@ export const FLIGHT_MS = 1400
const isBusy = (status: string) => /busy|active|running|working/i.test(status)
const isDown = (status: string) => /stop|terminat|offline|dead|error|fail/i.test(status)
-export function nodeColor(node: TopoNode): number {
- if (node.isLeader) return COLOR.accent
- if (isDown(node.status)) return /error|fail/i.test(node.status) ? COLOR.bad : COLOR.dim
- if (isBusy(node.status)) return COLOR.warn
+export function nodeColor(node: TopoNode, colors = COLOR): number {
+ if (node.isLeader) return colors.accent
+ if (isDown(node.status)) return /error|fail/i.test(node.status) ? colors.bad : colors.dim
+ if (isBusy(node.status)) return colors.warn
- return COLOR.info
+ return colors.info
}
/**
@@ -95,7 +96,9 @@ export function edges(model: TopoModel): [number, number][] {
* A dot runs from the leader to a node once each time the console sees an event about that agent (data); the leader's
* slow heartbeat is decoration.
*/
-export function topologyPicture(model: TopoModel, columns: number, rows: number, t: number, depth = false, motionTime = t): Grid {
+export function topologyPicture(model: TopoModel, columns: number, rows: number, t: number, depth = false, motionTime = t, palette?: ConsoleTheme['palette']): Grid {
+ const rgb = (hex: string) => parseInt(hex.slice(1), 16)
+ const colors = palette ? { ...COLOR, accent: rgb(palette.head), info: rgb(palette.info), ok: rgb(palette.ok), bad: rgb(palette.bad), warn: rgb(palette.warn), dim: mix(rgb(palette.background), rgb(palette.info), 0.45), line: mix(rgb(palette.background), rgb(palette.info), 0.3) } : COLOR
const grid = new Grid(columns, rows)
const canvas = new Braille(columns, rows)
const points = layout(model, canvas.width, canvas.height)
@@ -118,7 +121,7 @@ export function topologyPicture(model: TopoModel, columns: number, rows: number,
const p = points[a]
const q = points[b]
- if (p !== undefined && q !== undefined) canvas.line(p.x, p.y, q.x, q.y, COLOR.line)
+ if (p !== undefined && q !== undefined) canvas.line(p.x, p.y, q.x, q.y, colors.line)
}
// Work in flight: while ruflo has an agent busy, a dim amber dot keeps travelling down its edge from the leader.
@@ -132,8 +135,8 @@ export function topologyPicture(model: TopoModel, columns: number, rows: number,
const x = leader.x + (q.x - leader.x) * k
const y = leader.y + (q.y - leader.y) * k
- canvas.dot(x, y, COLOR.warn)
- canvas.dot(x + 1, y, COLOR.warn)
+ canvas.dot(x, y, colors.warn)
+ canvas.dot(x + 1, y, colors.warn)
})
model.nodes.forEach((node, i) => {
@@ -165,7 +168,7 @@ export function topologyPicture(model: TopoModel, columns: number, rows: number,
const flash = node.pulseAtMs !== undefined && t - node.pulseAtMs >= 0 && t - node.pulseAtMs < PULSE_MS + 600
// A busy agent breathes (brighter and back, about once every 2 s) so it reads as working, not just coloured.
const breath = !node.isLeader && isBusy(node.status) ? 0.45 * Math.sin(t / 330 + i) ** 2 : 0
- const color = flash ? 0xffffff : node.isLeader ? mix(COLOR.accent, 0xffffff, heartbeat) : mix(nodeColor(node), 0xffffff, breath)
+ const color = flash ? 0xffffff : node.isLeader ? mix(colors.accent, 0xffffff, heartbeat) : mix(nodeColor(node, colors), 0xffffff, breath)
if (depth) grid.set(cx + 1, cy + 1, '░', 0x49332c)
grid.set(cx, cy, depth ? (node.isLeader ? '◈' : isDown(node.status) ? '×' : isBusy(node.status) ? '◉' : '◇') : node.isLeader ? '★' : isBusy(node.status) ? '◉' : '●', color)
@@ -173,10 +176,11 @@ export function topologyPicture(model: TopoModel, columns: number, rows: number,
if (room >= 5 || node.isLeader) {
const label = node.label.slice(0, Math.max(3, room - 1))
- grid.text(Math.max(0, Math.min(columns - label.length, cx - Math.floor(label.length / 2))), Math.min(rows - 1, cy + 1), label, node.isLeader ? COLOR.accent : nodeColor(node))
+ grid.text(Math.max(0, Math.min(columns - label.length, cx - Math.floor(label.length / 2))), Math.min(rows - 1, cy + 1), label, node.isLeader ? colors.accent : nodeColor(node, colors))
}
})
+ if (palette) for (let i = 2; i < grid.cells.length; i += 3) grid.cells[i] = rgb(palette.background)
return grid
}
diff --git a/plugins/ruflo-console/hooks/nav-state.ts b/plugins/ruflo-console/hooks/nav-state.ts
index 62678fbf4f..f879738cb9 100644
--- a/plugins/ruflo-console/hooks/nav-state.ts
+++ b/plugins/ruflo-console/hooks/nav-state.ts
@@ -12,7 +12,7 @@ export const NAV_GROUPS: readonly { title: string; icon: string; rows: readonly
{ title: 'MIND', icon: '🧠', rows: [['learning', 'neural', 'metaharness', 'evolve', 'memory', 'vector']] },
{ title: 'SAFETY', icon: '🛡️', rows: [['secure', 'cost', 'perf', 'timeline', 'events', 'room']] },
{ title: 'NETWORK', icon: '🌐', rows: [['federation', 'xruv', 'sandbox', 'skills', 'market']] },
- { title: 'TOOLS', icon: '🛠️', rows: [['terminal', 'automate', 'devtools', 'plugins'], ['adrs', 'whatsnew', 'settings']] },
+ { title: 'TOOLS', icon: '🛠️', rows: [['terminal', 'automate', 'devtools', 'plugins'], ['adrs', 'whatsnew', 'themes', 'settings']] },
]
export const groupOf = (view: ViewId): string | null => NAV_GROUPS.find(group => group.rows.some(row => row.includes(view)))?.title ?? null
diff --git a/plugins/ruflo-console/hooks/state.ts b/plugins/ruflo-console/hooks/state.ts
index 92b0172868..f92cf09f4a 100644
--- a/plugins/ruflo-console/hooks/state.ts
+++ b/plugins/ruflo-console/hooks/state.ts
@@ -28,7 +28,7 @@ export type NavStyle = 'auto' | 'icons' | 'brief' | 'full'
export const NAV_STYLES: readonly NavStyle[] = ['auto', 'icons', 'brief', 'full']
export const NAV_KEY = 'nav-style'
-export type ViewId = 'menu' | 'overview' | 'swarm' | 'workflows' | 'hive' | 'claims' | 'federation' | 'plugins' | 'learning' | 'metaharness' | 'memory' | 'cost' | 'timeline' | 'approvals' | 'events' | 'room' | 'missions' | 'xruv' | 'terminal' | 'skills' | 'agent' | 'secure' | 'perf' | 'automate' | 'neural' | 'vector' | 'evolve' | 'devtools' | 'sandbox' | 'market' | 'settings' | 'whatsnew' | 'adrs'
+export type ViewId = 'menu' | 'overview' | 'swarm' | 'workflows' | 'hive' | 'claims' | 'federation' | 'plugins' | 'learning' | 'metaharness' | 'memory' | 'cost' | 'timeline' | 'approvals' | 'events' | 'room' | 'missions' | 'xruv' | 'terminal' | 'skills' | 'agent' | 'secure' | 'perf' | 'automate' | 'neural' | 'vector' | 'evolve' | 'devtools' | 'sandbox' | 'market' | 'settings' | 'themes' | 'whatsnew' | 'adrs'
/**
* The views in tab order, each with its hotkey and the inline height it asks for. Digits are the first nine; the three
@@ -73,6 +73,7 @@ export const VIEWS: readonly { id: ViewId; key: string; label: string; short: st
{ id: 'market', key: 'm', label: 'Plugin Catalog', short: 'Cat', icon: '📦', blurb: 'every ruflo plugin, mod and skill: what it ships, install, enable, disable, update, view and use', rows: 50 },
{ id: 'adrs', key: '', label: 'ADRs', short: 'ADR', icon: '📐', blurb: 'your project’s Architecture Decision Records: find, propose, accept and supersede them, attach them to a mission so Claude and the swarm follow what was decided', rows: 44 },
{ id: 'whatsnew', key: '', label: 'What’s new', short: 'New', icon: '🆕', blurb: 'what changed in your ruflo plugins, newest first: from each plugin’s own CHANGELOG, breaking changes pinned until you dismiss them', rows: 40 },
+ { id: 'themes', key: '', label: 'Theme Studio', short: 'Themes', icon: '◈', blurb: 'theme selection, color picker, animated palettes and Claude or Codex theme generator', rows: 50 },
{ id: 'settings', key: 's', label: 'Settings', short: 'Set', icon: '⚙️', blurb: 'simple to advanced settings: plugin options, ruflo config, updates, and the AI terminal’s model and budget, each edited in place', rows: 50 },
]
diff --git a/plugins/ruflo-console/hooks/themes.ts b/plugins/ruflo-console/hooks/themes.ts
new file mode 100644
index 0000000000..79a0c3cd8c
--- /dev/null
+++ b/plugins/ruflo-console/hooks/themes.ts
@@ -0,0 +1,143 @@
+/** Theme Studio stores data only. Generated presets never load executable code. */
+import type { Host } from './host'
+import type { State } from './state'
+
+export const COLOR_KEYS = ['head', 'ok', 'bad', 'warn', 'info', 'background'] as const
+export type ColorKey = typeof COLOR_KEYS[number]
+export type ConsoleTheme = {
+ version: 1
+ name: string
+ palette: Record<ColorKey, string>
+ motion: { speed: number; stars: boolean; globe: boolean; topology: boolean }
+}
+export const ORBITAL_THEME: ConsoleTheme = {
+ version: 1, name: 'Orbital',
+ palette: { head: '#f06449', ok: '#72c79b', bad: '#ff6868', warn: '#e3ba74', info: '#c6cbc8', background: '#000000' },
+ motion: { speed: 1, stars: true, globe: true, topology: true },
+}
+const clone = (theme: ConsoleTheme): ConsoleTheme => ({ ...theme, palette: { ...theme.palette }, motion: { ...theme.motion } })
+export const THEME_STORE_KEY = 'console-themes-v1'
+const HEX = /^#[0-9a-f]{6}$/i
+const record = (value: unknown): Record<string, unknown> | null => typeof value === 'object' && value !== null && !Array.isArray(value) ? value as Record<string, unknown> : null
+const exact = (value: Record<string, unknown>, keys: readonly string[]) => Object.keys(value).length === keys.length && keys.every(key => Object.hasOwn(value, key))
+
+/** Strict, bounded schema; drop no unknown fields silently. */
+export function parseTheme(value: unknown): ConsoleTheme | null {
+ const root = record(value), palette = record(root?.palette), motion = record(root?.motion)
+ if (!root || !palette || !motion || !exact(root, ['version', 'name', 'palette', 'motion']) || !exact(palette, COLOR_KEYS) || !exact(motion, ['speed', 'stars', 'globe', 'topology'])) return null
+ if (root.version !== 1 || typeof root.name !== 'string' || !/^[\p{L}\p{N}][\p{L}\p{N} ._-]{0,39}$/u.test(root.name)) return null
+ if (!COLOR_KEYS.every(key => typeof palette[key] === 'string' && HEX.test(palette[key] as string))) return null
+ if (typeof motion.speed !== 'number' || !Number.isFinite(motion.speed) || motion.speed < 0.25 || motion.speed > 2 || !['stars', 'globe', 'topology'].every(key => typeof motion[key] === 'boolean')) return null
+ return { version: 1, name: root.name, palette: Object.fromEntries(COLOR_KEYS.map(key => [key, (palette[key] as string).toLowerCase()])) as ConsoleTheme['palette'], motion: { speed: motion.speed, stars: motion.stars as boolean, globe: motion.globe as boolean, topology: motion.topology as boolean } }
+}
+export function themeFromText(text: string): ConsoleTheme | null {
+ if (text.length > 4096) return null
+ try { return parseTheme(JSON.parse(text.trim().replace(/^```(?:json)?\s*\n([\s\S]*?)\n```$/, '$1'))) } catch { return null }
+}
+export function contrast(a: string, b: string): number {
+ const luminance = (hex: string) => {
+ const rgb = [1, 3, 5].map(i => parseInt(hex.slice(i, i + 2), 16) / 255).map(c => c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4)
+ return rgb[0]! * 0.2126 + rgb[1]! * 0.7152 + rgb[2]! * 0.0722
+ }
+ const x = luminance(a), y = luminance(b)
+ return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05)
+}
+export const lowContrast = (theme: ConsoleTheme): ColorKey[] => COLOR_KEYS.filter(key => key !== 'background' && contrast(theme.palette[key], theme.palette.background) < 3)
+export type ThemeStudio = { saved: ConsoleTheme[]; active: ConsoleTheme | null; draft: ConsoleTheme; selected: string | null; brief: string; message: string; loaded: boolean; revision: number; saving: boolean; initialLook: State['options']['look'] }
+const studios = new WeakMap<State, ThemeStudio>()
+export function themesOf(state: State): ThemeStudio {
+ let studio = studios.get(state)
+ if (!studio) {
+ studio = { saved: [], active: null, draft: clone(ORBITAL_THEME), selected: null, brief: 'A calm cyberpunk theme with readable colors and slow orbital motion', message: '', loaded: false, revision: 0, saving: false, initialLook: state.options.look }
+ studios.set(state, studio)
+ }
+ return studio
+}
+export const activeTheme = (state: State): ConsoleTheme => themesOf(state).active ?? ORBITAL_THEME
+export async function loadThemes(state: State, host: Host): Promise<void> {
+ const studio = themesOf(state)
+ if (studio.loaded) return
+ studio.loaded = true
+ const revision = studio.revision
+ try {
+ const data = record(await host.storeGet(THEME_STORE_KEY))
+ if (!data || studio.revision !== revision) return
+ studio.saved = Array.isArray(data.saved) ? data.saved.slice(0, 12).map(parseTheme).filter((t): t is ConsoleTheme => t !== null) : []
+ const selected = typeof data.selected === 'string' ? data.selected : null
+ const theme = studio.saved.find(t => `custom:${t.name}` === selected)
+ if (theme) { studio.active = clone(theme); studio.draft = clone(theme); studio.selected = selected; state.options.look = 'orbital' }
+ else if (selected === 'bbs' || selected === 'plain' || selected === 'orbital') { studio.selected = selected; state.options.look = selected }
+ host.invalidate()
+ } catch { studio.message = 'Saved themes could not be read; using the configured look.'; host.invalidate() }
+}
+export type ThemeActions = {
+ select: (id: string) => void
+ color: (key: ColorKey, value: string) => void
+ name: (value: string) => void
+ motion: (key: keyof ConsoleTheme['motion'], value: number | boolean) => void
+ import: (text: string) => void
+ save: () => void
+ reset: () => void
+ brief: (value: string) => void
+ generate: (agent: 'claude' | 'codex') => void
+}
+export function themeActions(state: State, host: Host, ask: (agent: 'claude' | 'codex', prompt: string) => void): ThemeActions {
+ const studio = themesOf(state)
+ const tell = (message: string) => { studio.message = message; host.invalidate() }
+ // Serialize writes and commit in-memory selection only after persistence succeeds.
+ const persist = async (selected: string | null, saved: ConsoleTheme[], active: ConsoleTheme | null, look: State['options']['look']) => {
+ if (studio.saving) return tell('A theme is being saved. Try again when it finishes.')
+ studio.saving = true; studio.revision++; host.invalidate()
+ try {
+ await host.storeSet(THEME_STORE_KEY, { selected, saved })
+ studio.selected = selected; studio.saved = saved; studio.active = active; state.options.look = look
+ if (active) studio.draft = clone(active)
+ tell('Theme saved and applied.')
+ } catch { tell('Could not save the theme. The active theme is unchanged.') }
+ finally { studio.saving = false; host.invalidate() }
+ }
+ return {
+ select: id => {
+ if (id === 'bbs' || id === 'plain' || id === 'orbital') { void persist(id, studio.saved, null, id); return }
+ const theme = studio.saved.find(t => `custom:${t.name}` === id)
+ if (theme) void persist(id, studio.saved, clone(theme), 'orbital')
+ },
+ color: (key, value) => {
+ if (!COLOR_KEYS.includes(key) || !HEX.test(value.trim())) return tell('Enter a six digit hex color, for example #72c79b.')
+ studio.draft.palette[key] = value.trim().toLowerCase(); tell('Preview updated. Save to apply.')
+ },
+ name: value => {
+ const candidate = parseTheme({ ...studio.draft, name: value.trim() })
+ if (!candidate) return tell('Use 1 to 40 letters, numbers, spaces, dots or underscores for the name.')
+ studio.draft = candidate; tell('Preview renamed.')
+ },
+ motion: (key, value) => {
+ const candidate = parseTheme({ ...studio.draft, motion: { ...studio.draft.motion, [key]: value } })
+ if (!candidate) return tell('Invalid motion setting.')
+ studio.draft = candidate; tell('Preview updated. Save to apply.')
+ },
+ import: text => {
+ const candidate = themeFromText(text)
+ if (!candidate) return tell('Invalid theme JSON. Expected version 1, name, six hex colors and motion settings; maximum 4096 characters.')
+ studio.draft = candidate; tell('Theme imported into preview. Save to apply.')
+ },
+ save: () => {
+ const theme = parseTheme(studio.draft)
+ if (!theme) return tell('Invalid theme.')
+ const unreadable = lowContrast(theme)
+ if (unreadable.length) return tell(`Increase contrast for: ${unreadable.join(', ')}. Each needs at least 3:1 against the background.`)
+ const saved = studio.saved.filter(t => t.name !== theme.name)
+ if (saved.length >= 12) return tell('Twelve custom themes are saved. Reuse an existing name to replace it.')
+ void persist(`custom:${theme.name}`, [...saved, clone(theme)], clone(theme), 'orbital')
+ },
+ reset: () => { studio.draft = clone(ORBITAL_THEME); void persist(null, studio.saved, null, studio.initialLook) },
+ brief: value => { studio.brief = value.replace(/[\x00-\x1f\x7f]/g, ' ').slice(0, 1200); tell('Design brief ready.') },
+ generate: agent => {
+ void Promise.all([host.fs.read(`${host.pluginRoot}/skills/generate-console-theme/SKILL.md`), host.fs.read(`${host.pluginRoot}/skills/generate-console-theme/references/preset.md`)]).then(parts => {
+ const skill = parts.join('\n\n')
+ if (skill.length > 16000) return tell('Theme generator skill is too large.')
+ ask(agent, `${skill}\n\nDesign brief (user input):\n${studio.brief}\n\nReturn one JSON object for Theme Studio import. Do not write files or run commands. Current draft:\n${JSON.stringify(studio.draft)}`)
+ }, () => tell('The bundled generate-console-theme skill could not be read. Reinstall or update the plugin.'))
+ },
+ }
+}
diff --git a/plugins/ruflo-console/hooks/views/common.ts b/plugins/ruflo-console/hooks/views/common.ts
index 84587bf4fc..3f74270482 100644
--- a/plugins/ruflo-console/hooks/views/common.ts
+++ b/plugins/ruflo-console/hooks/views/common.ts
@@ -3,6 +3,7 @@
* and the pictures computed for this frame. They call nothing on the engine; buttons call the closures in `ctx.act`.
* Text colours are theme names only, so nothing fades on a light background.
*/
+import type { ThemeActions, ConsoleTheme } from '../themes'
import type { AskActions } from '../ask-claude'
import type { OptimizerActions } from '../optimizer'
import { askedBy } from '../data/room'
@@ -143,6 +144,7 @@ export type Actions = {
/** The Workflows page: cursor keys, the inspector's tab, the confirm-gated ruflo agent verbs, and naming a transcript's path. */
workflows: WorkflowsActions
/** Settings: the level, a plugin, an option or ruflo config change (each asks first), AI preferences, and ▸ ask claude/codex. */
+ themes: ThemeActions
settings: SettingsActions
}
@@ -175,10 +177,9 @@ const NEON_LABEL = '#2fbf71'
export const THEME: { head: string; ok: string; bad: string; warn: string; info: string } = { ...PLAIN }
let look: Look = 'plain'
-export function setLook(next: Look): void {
- if (next === look) return
+export function setLook(next: Look, palette?: ConsoleTheme['palette']): void {
look = next
- Object.assign(THEME, next === 'bbs' ? NEON : next === 'orbital' ? ORBITAL : PLAIN)
+ Object.assign(THEME, next === 'bbs' ? NEON : next === 'orbital' ? (palette ?? ORBITAL) : PLAIN)
}
export const isOrbital = (): boolean => look === 'orbital'
diff --git a/plugins/ruflo-console/hooks/views/frames.ts b/plugins/ruflo-console/hooks/views/frames.ts
index 7117ce4ec0..a0811a8792 100644
--- a/plugins/ruflo-console/hooks/views/frames.ts
+++ b/plugins/ruflo-console/hooks/views/frames.ts
@@ -1,3 +1,4 @@
+import { activeTheme, themesOf } from '../themes'
/**
* The pictures of the view in front, by Raster key, for one instant. The render mounts them and the animation loop
* blits them, both through `picturesOf`, so a frame is always the mounted size. Each picture's model is read from the
@@ -7,7 +8,7 @@ import type { AuditTrend, HarnessScore, Intelligence } from '../data/cli'
import { recentByAgent } from '../data/events'
import { agentLabels } from '../data/parse'
import { presentAgents, swarmStatusOf } from '../data/swarm-status'
-import { orbitalBoot, orbitalHeader } from '../gfx/orbital'
+import { orbitalBoot, orbitalHeader, orbitalGlobe } from '../gfx/orbital'
import { getBootChecks } from '../boot-checks'
import { bootFacts } from '../boot-facts'
import { getBuild } from '../build'
@@ -178,13 +179,15 @@ function titleThatFits(paneColumns: number, names: readonly string[], build: (na
export function picturesOf(state: State, columns: number, nowMs: number, t: number): Map<string, Grid> {
const pictures = new Map<string, Grid>()
+ const theme = activeTheme(state)
+ const motionTime = state.options.fps > 0 ? t * theme.motion.speed : 0
// A page in cards (views/card.ts) is narrower by the border and padding: its pictures are drawn to that width, by the render and by the frame loop alike.
const width = Math.max(20, Math.min(200, hasCards(columns, isCompactPane(state)) ? columns - CARD_COLUMNS : columns))
const snapshot = state.snapshot
// The selected boot screen owns the pane for its first seconds; nothing else is drawn under it.
if (isBooting(state, nowMs)) {
- pictures.set('boot', state.options.look === 'orbital' ? orbitalBoot(state.cwd.split('/').filter(Boolean).at(-1) ?? '', Math.max(1, Math.min(columns, width, 90)), state.options.fps > 0 ? nowMs - state.pane.bootAtMs : 0, getBootChecks(), state.pane.rows > 0 ? state.pane.rows : 30) : bootPicture(state.cwd.split('/').filter(Boolean).at(-1) ?? '', Math.min(width, 90), nowMs - state.pane.bootAtMs, state.probes.size, PROBES.length, state.pane.rows, getBootChecks(), bootFacts(state, CONSOLE_VERSION, getBuild())))
+ pictures.set('boot', state.options.look === 'orbital' ? orbitalBoot(state.cwd.split('/').filter(Boolean).at(-1) ?? '', Math.max(1, Math.min(columns, width, 90)), state.options.fps > 0 ? (nowMs - state.pane.bootAtMs) * theme.motion.speed : 0, getBootChecks(), state.pane.rows > 0 ? state.pane.rows : 30, theme) : bootPicture(state.cwd.split('/').filter(Boolean).at(-1) ?? '', Math.min(width, 90), nowMs - state.pane.bootAtMs, state.probes.size, PROBES.length, state.pane.rows, getBootChecks(), bootFacts(state, CONSOLE_VERSION, getBuild())))
return pictures
}
@@ -216,7 +219,13 @@ export function picturesOf(state: State, columns: number, nowMs: number, t: numb
if (state.options.look === 'orbital') {
const page = state.isHelp ? 'help' : state.palette.isOpen ? 'commands' : (VIEWS.find(view => view.id === state.view)?.label ?? state.view)
- pictures.set(state.view === 'menu' ? 'header' : 'title', orbitalHeader(page, Math.max(1, Math.min(120, columns - iconCells(false) - ICON_SLACK)), state.options.fps > 0 ? t : 0, state.pane.rows > 0 ? Math.max(1, state.pane.rows - 12) : 16))
+ pictures.set(state.view === 'menu' ? 'header' : 'title', orbitalHeader(page, Math.max(1, Math.min(120, columns - iconCells(false) - ICON_SLACK)), motionTime, state.pane.rows > 0 ? Math.max(1, state.pane.rows - 12) : 16, theme))
+ }
+
+ if (state.view === 'themes') {
+ const draft = themesOf(state).draft
+ if (draft.motion.globe) pictures.set('theme-globe', orbitalGlobe(Math.max(1, Math.min(columns, width, 72)), 9, state.options.fps > 0 ? t * draft.motion.speed : 0, draft))
+ pictures.set('theme-preview', orbitalHeader('swarm preview', Math.max(1, Math.min(columns, width, 90)), state.options.fps > 0 ? t * draft.motion.speed : 0, state.pane.rows > 0 ? Math.max(1, Math.min(16, state.pane.rows - 12)) : 16, draft))
}
switch (state.view) {
@@ -226,7 +235,7 @@ export function picturesOf(state: State, columns: number, nowMs: number, t: numb
case 'swarm': {
const model = topoModelOf(snapshot, recentByAgent(state.events, nowMs, PULSE_MS + 600), nowMs)
- if (model !== null) pictures.set('topology', topologyPicture(model, width, topologyRows(width, model.nodes.length), t, state.options.look === 'orbital', state.options.fps > 0 ? t : 0))
+ if (model !== null) pictures.set('topology', topologyPicture(model, width, topologyRows(width, model.nodes.length), t, state.options.look === 'orbital' && theme.motion.topology, motionTime, state.options.look === 'orbital' ? theme.palette : undefined))
break
}
case 'hive':
diff --git a/plugins/ruflo-console/hooks/views/menu.ts b/plugins/ruflo-console/hooks/views/menu.ts
index da05916df2..b8c43e9fe9 100644
--- a/plugins/ruflo-console/hooks/views/menu.ts
+++ b/plugins/ruflo-console/hooks/views/menu.ts
@@ -52,7 +52,7 @@ export const GROUPS: readonly { title: string; sections: readonly { name: string
},
{
title: 'TOOLS',
- sections: [{ name: 'tools', items: [{ label: 'AI Terminal', go: 'terminal' }, { label: 'Automation', go: 'automate' }, { label: 'Dev Tools', go: 'devtools' }, { label: 'Plugins & Mods', go: 'plugins' }, { label: 'ADRs', go: 'adrs' }, { label: 'What’s new', go: 'whatsnew' }, { label: 'Settings', go: 'settings' }, { label: 'Command Palette', go: 'palette' }, { label: 'Help', go: 'help' }, { label: 'Log Off', go: 'close' }] }],
+ sections: [{ name: 'tools', items: [{ label: 'AI Terminal', go: 'terminal' }, { label: 'Automation', go: 'automate' }, { label: 'Dev Tools', go: 'devtools' }, { label: 'Plugins & Mods', go: 'plugins' }, { label: 'ADRs', go: 'adrs' }, { label: 'What’s new', go: 'whatsnew' }, { label: 'Theme Studio', go: 'themes' }, { label: 'Settings', go: 'settings' }, { label: 'Command Palette', go: 'palette' }, { label: 'Help', go: 'help' }, { label: 'Log Off', go: 'close' }] }],
},
]
diff --git a/plugins/ruflo-console/hooks/views/pane.ts b/plugins/ruflo-console/hooks/views/pane.ts
index 3561626742..0d9b86fb5c 100644
--- a/plugins/ruflo-console/hooks/views/pane.ts
+++ b/plugins/ruflo-console/hooks/views/pane.ts
@@ -25,6 +25,8 @@ import { ago, button, clip, col, confirmRow, isBbs, isOrbital, row, setLook, tex
import { costView } from './cost'
import { evolveResult, evolveView } from './evolve'
import { catalogView } from './plugin-catalog'
+import { activeTheme } from '../themes'
+import { themesView } from './themes'
import { settingsView } from './settings'
import { whatsnewView } from './whatsnew'
import { adrsView } from './adr'
@@ -96,6 +98,7 @@ export const BODIES: Record<ViewId, (ctx: Ctx) => RenderElement> = {
devtools: devtoolsView,
sandbox: sandboxView,
market: catalogView,
+ themes: themesView,
settings: settingsView,
whatsnew: whatsnewView, adrs: adrsView,
agent: agentView,
@@ -362,7 +365,7 @@ function withIcons(ctx: Ctx, parts: RenderElement[], lead: number): RenderElemen
}
export function paneView(base: Ctx): RenderElement {
- setLook(base.state.options.look)
+ setLook(base.state.options.look, activeTheme(base.state).palette)
// Every Button and Input remembers its key, and a column that holds the origin of the current ask places the confirm and the answer after it.
const attention = newAttention(base.state.origin, [])
@@ -445,7 +448,7 @@ export function paneView(base: Ctx): RenderElement {
? bbs.art.length + (about !== null ? 1 : 0)
: title.length + (isMenu && isBbs() ? 1 : 0)
- return ctx.kit.Box({ flexDirection: 'column', ...(isOrbital() ? { backgroundColor: '#000000' } : {}), children: withIcons(ctx, parts, lead) })
+ return ctx.kit.Box({ flexDirection: 'column', ...(isOrbital() ? { backgroundColor: activeTheme(ctx.state).palette.background } : {}), children: withIcons(ctx, parts, lead) })
}
type Plain = { type: string; props: { children?: unknown; label?: string } }
diff --git a/plugins/ruflo-console/hooks/views/settings.ts b/plugins/ruflo-console/hooks/views/settings.ts
index 965dd8795c..4c054ce7e1 100644
--- a/plugins/ruflo-console/hooks/views/settings.ts
+++ b/plugins/ruflo-console/hooks/views/settings.ts
@@ -356,6 +356,7 @@ export function settingsView(ctx: Ctx): RenderElement {
const rows: RenderElement[] = [rule(ctx, 'Settings', `${shown.length} shown of ${everything.length} · ${changed} changed`)]
+ rows.push(button(ctx, 'st-theme-studio', 'Theme Studio: colors and animation', () => ctx.act.view('themes')))
rows.push(
row(
ctx,
diff --git a/plugins/ruflo-console/hooks/views/themes.ts b/plugins/ruflo-console/hooks/views/themes.ts
new file mode 100644
index 0000000000..cfe886068a
--- /dev/null
+++ b/plugins/ruflo-console/hooks/views/themes.ts
@@ -0,0 +1,49 @@
+import type { RenderElement } from 'claude-code'
+import { activeTheme, COLOR_KEYS, lowContrast, themesOf } from '../themes'
+import { button, clip, col, picture, row, text, THEME, type Ctx } from './common'
+
+/** A terminal color picker: visible swatches and exact hex input, stacked at every width. */
+export function themesView(ctx: Ctx): RenderElement {
+ const pick = (key: string, label: string, run: () => void) => button(ctx, key, clip(label, Math.max(1, ctx.columns - 2)), run)
+ const studio = themesOf(ctx.state), act = ctx.act.themes
+ const input = (key: string, label: string, placeholder: string, submit: (value: string) => void) => ctx.kit.Input
+ ? ctx.kit.Input({ key, label, placeholder, submitLabel: 'preview', onSubmit: submit })
+ : text(ctx, `${label}: text input is unavailable on this surface`, { dimColor: true })
+ const selected = studio.selected ?? ctx.state.options.look
+ const swatches = ['#f06449', '#72c79b', '#78c8ff', '#ca9bff', '#ffcf73', '#f2f4f3', '#000000', '#101820']
+ const rows: RenderElement[] = [
+ text(ctx, 'THEME STUDIO', { bold: true, color: THEME.head }),
+ text(ctx, 'Choose a look. Custom themes use Orbital animation.'),
+ ...(['bbs', 'plain', 'orbital'] as const).map(id => pick(`theme-${id}`, `${selected === id ? '●' : '○'} ${id === 'bbs' ? 'Classic BBS' : id === 'plain' ? 'Terminal plain' : 'Orbital'}`, () => act.select(id))),
+ ...studio.saved.map(theme => pick(`theme-custom-${theme.name}`, `${selected === `custom:${theme.name}` ? '●' : '○'} ${theme.name}`, () => act.select(`custom:${theme.name}`))),
+ pick('theme-reset', 'Use configured look', act.reset),
+ text(ctx, `Active: ${studio.active ? activeTheme(ctx.state).name : ctx.state.options.look}`, { color: THEME.ok }),
+ text(ctx, 'PREVIEW', { bold: true, color: THEME.head }),
+ picture(ctx, 'theme-preview', `Preview: ${studio.draft.name}`),
+ ...(studio.draft.motion.globe ? [picture(ctx, 'theme-globe', 'Globe preview')] : []),
+ input('theme-name', 'Theme name', studio.draft.name, act.name),
+ ]
+ for (const key of COLOR_KEYS) {
+ rows.push(text(ctx, `${key} ${studio.draft.palette[key]}`, { color: THEME.info }))
+ // Four swatches per row at normal widths, two on a narrow pane.
+ const count = ctx.columns < 36 ? 2 : 4
+ for (let i = 0; i < swatches.length; i += count) rows.push(row(ctx, swatches.slice(i, i + count).map((color, j) => col(ctx, [ctx.kit.Text({ color, backgroundColor: studio.draft.palette.background, children: ' ▄▄ ' }), pick(`theme-${key}-${i + j}`, String(i + j + 1), () => act.color(key, color))]))))
+ rows.push(input(`theme-color-${key}`, `${key} hex`, studio.draft.palette[key], value => act.color(key, value)))
+ }
+ rows.push(text(ctx, 'MOTION', { bold: true, color: THEME.head }))
+ for (const key of ['stars', 'globe', 'topology'] as const) rows.push(pick(`theme-motion-${key}`, `${studio.draft.motion[key] ? '●' : '○'} ${key}`, () => act.motion(key, !studio.draft.motion[key])))
+ for (const speed of [0.25, 0.5, 1, 2]) rows.push(pick(`theme-speed-${speed}`, `${studio.draft.motion.speed === speed ? '●' : '○'} ${speed}x motion`, () => act.motion('speed', speed)))
+ rows.push(text(ctx, ctx.state.options.fps === 0 ? 'Reduced motion is on. Previews are still.' : 'Settings > fps = 0 stops all motion.', { dimColor: true }))
+ const low = lowContrast(studio.draft)
+ if (low.length) rows.push(text(ctx, `Low contrast: ${low.join(', ')}. Adjust before saving.`, { color: THEME.warn }))
+ rows.push(pick('theme-save', studio.saving ? 'Saving…' : 'Save preview and apply', act.save))
+ rows.push(text(ctx, 'GENERATE WITH AI', { bold: true, color: THEME.head }))
+ rows.push(input('theme-brief', 'Design brief', studio.brief, act.brief))
+ rows.push(text(ctx, studio.brief, { dimColor: true }))
+ rows.push(pick('theme-generate-claude', 'Generate with Claude', () => act.generate('claude')))
+ rows.push(pick('theme-generate-codex', 'Generate with Codex', () => act.generate('codex')))
+ rows.push(text(ctx, 'Uses the bundled skill in AI Terminal. Paste its JSON below.'))
+ rows.push(input('theme-import', 'Import theme JSON', '{"version":1,...}', act.import))
+ rows.push(text(ctx, studio.message || 'Preview changes stay here until you save.', { color: THEME.info }))
+ return col(ctx, rows, 'themes')
+}
diff --git a/plugins/ruflo-console/skills/generate-console-theme/SKILL.md b/plugins/ruflo-console/skills/generate-console-theme/SKILL.md
new file mode 100644
index 0000000000..7e0fe23ab9
--- /dev/null
+++ b/plugins/ruflo-console/skills/generate-console-theme/SKILL.md
@@ -0,0 +1,16 @@
+---
+name: generate-console-theme
+description: Generate a data-only animated theme preset for Ruflo Console Theme Studio. Use when the user requests a new console color palette, cyberpunk theme, or variation of Orbital globe, stars, and swarm animation in Claude or Codex.
+---
+
+# Generate a Ruflo console theme
+
+Create one preset from the user's visual direction. Use the current assistant, Claude or Codex, to generate the data; no API key, subprocess, or second model is required.
+
+1. Read [the preset contract and example](references/preset.md).
+2. Choose a short theme name and six readable colors. Translate the requested mood into the palette, animation speed, and optional stars, globe, and topology. Reuse the existing Orbital renderer; do not promise new animation geometry from a preset.
+3. Keep text and status colors legible against the background. Aim for at least 4.5:1 contrast for every foreground role. Keep failures visually distinct from successes and warnings; preserve the host's status labels. Prefer calm motion and avoid flashing. Honor a request for less visual activity by disabling decorative layers and lowering speed; the host's zero-FPS setting remains authoritative.
+4. Check the exact keys, types, bounds, six-digit hex colors, and name length against the contract. Never include scripts, CSS, URLs, escape sequences, extra keys, or invented telemetry. Theme settings must not change boot checks, agent states, or reported failures.
+5. Return exactly one JSON object with no Markdown fences or surrounding explanation. Theme Studio accepts the object in its import field; the user can review and save/select the preset there. Do not claim it has been installed or activated merely because JSON was generated.
+
+Use the user's stated preferences directly. When details are absent, choose a dark background, warm readable status colors, all three decorative layers enabled, and speed 1. Do not ask for credentials or make external calls to produce a preset.
diff --git a/plugins/ruflo-console/skills/generate-console-theme/agents/openai.yaml b/plugins/ruflo-console/skills/generate-console-theme/agents/openai.yaml
new file mode 100644
index 0000000000..0d8f895737
--- /dev/null
+++ b/plugins/ruflo-console/skills/generate-console-theme/agents/openai.yaml
@@ -0,0 +1,4 @@
+interface:
+ display_name: "Ruflo Theme Generator"
+ short_description: "Generate animated Ruflo console theme presets"
+ default_prompt: "Use $generate-console-theme to create a readable cyberpunk Ruflo console theme with calm globe and swarm motion."
diff --git a/plugins/ruflo-console/skills/generate-console-theme/references/preset.md b/plugins/ruflo-console/skills/generate-console-theme/references/preset.md
new file mode 100644
index 0000000000..0094829098
--- /dev/null
+++ b/plugins/ruflo-console/skills/generate-console-theme/references/preset.md
@@ -0,0 +1,46 @@
+# Theme preset contract
+
+Return exactly this version 1 object shape. All keys are required; omit additional keys.
+
+| Field | Value |
+| --- | --- |
+| `version` | Integer `1` |
+| `name` | A trimmed name of 1 to 40 characters; start with a Unicode letter or number, then use only Unicode letters, numbers, spaces, dots, underscores, or hyphens |
+| `palette.head` | Heading, accent, and border color |
+| `palette.ok` | Success color |
+| `palette.bad` | Failure color |
+| `palette.warn` | Warning color |
+| `palette.info` | Main information text color |
+| `palette.background` | Background color |
+| Every palette value | String matching `#RRGGBB` with six hexadecimal digits |
+| `motion.speed` | Finite number from `0.25` through `2`, inclusive; `1` is the standard rate |
+| `motion.stars` | Boolean enabling decorative stars |
+| `motion.globe` | Boolean enabling the decorative globe |
+| `motion.topology` | Boolean enabling decorative topology motion |
+
+These are palette and motion parameters for existing responsive Orbital visuals. They do not add arbitrary renderers, change refresh rate preferences, or provide system health data. The host must preserve reduced-motion settings and actual operational state. Disabled decoration must not hide the live topology's operational information.
+
+## Example: calm violet observatory
+
+```json
+{
+ "version": 1,
+ "name": "Violet Observatory",
+ "palette": {
+ "head": "#C5A3FF",
+ "ok": "#83D9AB",
+ "bad": "#FF8C94",
+ "warn": "#F2CE7E",
+ "info": "#DBDDE8",
+ "background": "#0C0D16"
+ },
+ "motion": {
+ "speed": 0.65,
+ "stars": true,
+ "globe": true,
+ "topology": true
+ }
+}
+```
+
+Treat the example as a schema illustration; vary its design to match the user's request.
diff --git a/plugins/ruflo-console/tests/themes.spec.ts b/plugins/ruflo-console/tests/themes.spec.ts
new file mode 100644
index 0000000000..2cae680f3f
--- /dev/null
+++ b/plugins/ruflo-console/tests/themes.spec.ts
@@ -0,0 +1,105 @@
+import { describe, expect, it, vi } from 'vitest'
+import { activeTheme, COLOR_KEYS, loadThemes, lowContrast, ORBITAL_THEME, parseTheme, themeActions, themeFromText, themesOf } from '../hooks/themes'
+import { newState } from '../hooks/state'
+import type { Host } from '../hooks/host'
+import { orbitalBoot, orbitalGlobe, orbitalHeader } from '../hooks/gfx/orbital'
+import { picturesOf } from '../hooks/views/frames'
+import { groupOf, findPages } from '../hooks/nav-state'
+import { GROUPS } from '../hooks/views/menu'
+const flush = async () => { await new Promise(resolve => setTimeout(resolve, 0)) }
+const copy = () => JSON.parse(JSON.stringify(ORBITAL_THEME))
+const hostOf = (store = new Map<string, unknown>()) => ({ storeGet: vi.fn(async (key: string) => store.get(key)), storeSet: vi.fn(async (key: string, value: unknown) => { store.set(key, value) }), invalidate: vi.fn(), fs: { read: vi.fn(async (path: string) => path.endsWith('SKILL.md') ? 'Generate one preset.' : 'version: 1; six hex colors; motion') }, pluginRoot: '/plugin' }) as unknown as Host
+
+describe('Theme Studio', () => {
+ it('is available in main menu and Tools navigation/search', () => {
+ expect(groupOf('themes')).toBe('TOOLS')
+ expect(findPages('color')).toContain('themes')
+ expect(GROUPS.find(g => g.title === 'TOOLS')!.sections.flatMap(s => s.items).some(i => i.go === 'themes')).toBe(true)
+ })
+ it('accepts only bounded data and clones it', () => {
+ const raw = copy(), parsed = parseTheme(raw)!
+ expect(parsed).toEqual(raw)
+ raw.palette.head = '#ffffff'
+ expect(parsed.palette.head).toBe('#f06449')
+ for (const patch of [{ version: 2 }, { script: 'eval()' }, { name: '\x1b[31m' }, { name: 'x'.repeat(41) }, { palette: {} }, { motion: { speed: 3, stars: true, globe: true, topology: true } }]) expect(parseTheme({ ...copy(), ...patch })).toBeNull()
+ for (const color of ['red', '#fff', '#GG0000', '#000000\n']) expect(parseTheme({ ...copy(), palette: { ...copy().palette, head: color } })).toBeNull()
+ expect(themeFromText('x'.repeat(4097))).toBeNull()
+ expect(themeFromText('```json\n' + JSON.stringify(copy()) + '\n```')).toEqual(copy())
+ expect(themeFromText('{}')).toBeNull()
+ })
+ it('previews without changing active look, saves, and restores across sessions', async () => {
+ const store = new Map(), host = hostOf(store), state = newState({ look: 'bbs' }), act = themeActions(state, host, vi.fn())
+ act.name('Violet'); act.color('head', '#ca9bff'); act.motion('speed', 0.5)
+ expect(state.options.look).toBe('bbs')
+ expect(activeTheme(state).palette.head).toBe('#f06449')
+ act.save(); await flush()
+ expect(state.options.look).toBe('orbital')
+ expect(activeTheme(state).palette.head).toBe('#ca9bff')
+ const restored = newState({ look: 'plain' }); await loadThemes(restored, host)
+ expect(activeTheme(restored).name).toBe('Violet')
+ expect(themesOf(restored).saved).toHaveLength(1)
+ themeActions(restored, host, vi.fn()).reset(); await flush()
+ expect(restored.options.look).toBe('plain')
+ })
+ it('keeps the prior theme on storage failure and rejects invalid/low contrast edits', async () => {
+ const state = newState({ look: 'bbs' }), host = hostOf()
+ host.storeSet = vi.fn(async () => { throw Error('denied') })
+ const act = themeActions(state, host, vi.fn())
+ act.select('orbital'); await flush(); expect(state.options.look).toBe('bbs')
+ expect(themesOf(state).message).toContain('Could not save')
+ act.color('head', 'bad'); expect(themesOf(state).draft.palette.head).toBe('#f06449')
+ act.motion('speed', NaN); expect(themesOf(state).draft.motion.speed).toBe(1)
+ act.color('info', '#000000'); act.save()
+ expect(themesOf(state).message).toContain('contrast')
+ expect(lowContrast(ORBITAL_THEME)).toEqual([])
+ })
+ it('rejects overlapping saves and does not let a late load replace user selection', async () => {
+ const state = newState({}), host = hostOf(); let resolve!: (v: unknown) => void
+ host.storeGet = () => new Promise(r => { resolve = r })
+ const loading = loadThemes(state, host), act = themeActions(state, host, vi.fn())
+ act.select('plain'); act.select('orbital'); await flush()
+ resolve({ selected: 'orbital', saved: [] }); await loading
+ expect(state.options.look).toBe('plain')
+ expect(host.storeSet).toHaveBeenCalledTimes(1)
+ })
+ it('sends the bundled skill and contract to the chosen AI route only on request', async () => {
+ const state = newState({}), host = hostOf(), ask = vi.fn(), act = themeActions(state, host, ask)
+ act.brief('Amber stars'); expect(ask).not.toHaveBeenCalled()
+ act.generate('codex'); await flush()
+ expect(ask).toHaveBeenCalledWith('codex', expect.stringContaining('Amber stars'))
+ expect(ask.mock.calls[0]![1]).toContain('six hex colors')
+ expect(host.storeSet).not.toHaveBeenCalled()
+ host.fs.read = async () => { throw Error('missing') }
+ act.generate('claude'); await flush()
+ expect(ask).toHaveBeenCalledTimes(1)
+ expect(themesOf(state).message).toContain('could not be read')
+ })
+ it('applies palette and decorative layers without losing failure checks', () => {
+ const theme = copy(); theme.palette.head = '#ca9bff'; theme.palette.bad = '#ffaaaa'
+ const header = orbitalHeader('swarm', 72, 1200, 16, theme)
+ expect(header.cells[1]).toBe(0xca9bff)
+ theme.motion.topology = false
+ expect(orbitalHeader('swarm', 72, 1200, 16, theme).rows).toBe(4)
+ const withStars = orbitalGlobe(72, 16, 1000, theme).encode()
+ theme.motion.stars = false
+ expect(orbitalGlobe(72, 16, 1000, theme).encode()).not.toBe(withStars)
+ theme.motion.globe = false
+ const checks = [{ area: 'module', ok: false, problems: ['missing'] }]
+ const grid = orbitalBoot('demo', 72, 1500, checks, 30, theme)
+ const text = Array.from({ length: grid.columns * grid.rows }, (_, i) => String.fromCodePoint(grid.cells[i * 3]!)).join('')
+ expect(text).toContain('[FAIL] MODULE / missing')
+ expect(grid.cells[(23 * 72) * 3 + 1]).toBe(0xffaaaa)
+ })
+ it('bounds previews across sizes and holds still at fps zero', () => {
+ const state = newState({ look: 'orbital', fps: 0, boot: false }); state.view = 'themes'
+ for (const width of [12, 20, 44, 72, 160, 240]) for (const rows of [10, 24, 60]) {
+ state.pane.rows = rows
+ const a = picturesOf(state, width, 1000, 1000), b = picturesOf(state, width, 9000, 9000)
+ for (const key of ['theme-preview', 'theme-globe']) {
+ expect(a.get(key)!.columns).toBeLessThanOrEqual(width)
+ expect(a.get(key)!.encode()).toBe(b.get(key)!.encode())
+ }
+ }
+ expect(COLOR_KEYS).toHaveLength(6)
+ })
+})