π 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
test(console): add reproducible theme workflow demo and video export
rUv3fb35a5a0f34
diff --git a/plugins/ruflo-console/README.md b/plugins/ruflo-console/README.mdindex 2a943cac9d..021cca598b 100644--- a/plugins/ruflo-console/README.md+++ b/plugins/ruflo-console/README.md@@ -117,6 +117,19 @@ Six bundled **Color presets** load with one click and persist across sessions. TSelect a preset to load it immediately. Edit colors or motion and choose **Save and apply** to create a custom copy; bundled originals remain available. Portable version 1 JSON presets also load through **AI β Import theme JSON**, followed by **Save and apply**. **Use configured look** restores the plugin setting.+### Reproduce the theme workflow demo++The demo drives actual console view handlers through boot, Main Menu, all six presets, custom color and motion, save, fresh state restoration from a local JSON store, portable JSON import, reduced motion, and 80/116 column layouts. It checks each transition and writes `receipt.json`. This is a renderer integration demo, not a native Claude host recording: other console actions are not exercised, the FPS setting is changed by the harness, and no AI provider is invoked.++From the repository root, with Node, Python Pillow and ffmpeg available:++```sh+npx tsx plugins/ruflo-console/scripts/theme-demo.mts /tmp/ruflo-demo-new+python3 plugins/ruflo-console/scripts/render-theme-demo.py /tmp/ruflo-demo-new+```++Use a fresh output directory. The capture refuses to overwrite an existing `demo-session.json`; omitting the directory creates a unique temporary directory and prints its path. Outputs include a 38 second MP4 at 12 fps, a GIF at 6 fps, captured cell frames and an assertion receipt. Native host rendering and live AI theme generation remain separate acceptance checks.+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.diff --git a/plugins/ruflo-console/scripts/render-theme-demo.py b/plugins/ruflo-console/scripts/render-theme-demo.pynew file mode 100644index 0000000000..b86d3fb4d2--- /dev/null+++ b/plugins/ruflo-console/scripts/render-theme-demo.py@@ -0,0 +1,43 @@+"""Render theme-demo.mts frames to GIF and MP4. Requires Pillow and ffmpeg."""+import json, sys, subprocess+from pathlib import Path+from PIL import Image, ImageDraw, ImageFont+root=Path(sys.argv[1] if len(sys.argv)>1 else '/tmp/ruflo-console-demo')+frames=json.loads((root/'frames.json').read_text())+font=ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf',16)+small=ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf',12)+width=1208+height=120+max(len(f['rows']) for f in frames)*19+height+=height%2+# Cache rendered terminal cells so repeated text is not rasterized hundreds of times.+cache={}+def tile(c,bg):+ key=(c['ch'],c['fg'],c.get('bg',bg))+ if key not in cache:+ im=Image.new('RGB',(10,19),key[2]);d=ImageDraw.Draw(im)+ if c['ch'] in ['β','β','β']:+ lo=9 if c['ch']=='β' else 0;hi=8 if c['ch']=='β' else 18+ d.rectangle((0,lo,9,hi),fill=c['fg'])+ elif c['ch']!=' ':d.text((0,0),c['ch'],font=font,fill=c['fg'])+ cache[key]=im+ return cache[key]+video=subprocess.Popen(['ffmpeg','-y','-loglevel','error','-f','rawvideo','-pixel_format','rgb24','-video_size',f'{width}x{height}','-framerate','12','-i','-','-an','-c:v','libx264','-preset','fast','-crf','19','-pix_fmt','yuv420p','-movflags','+faststart',str(root/'ruflo-console-demo.mp4')],stdin=subprocess.PIPE)+images=[]+for n,f in enumerate(frames):+ im=Image.new('RGB',(width,height),f['bg']);d=ImageDraw.Draw(im)+ d.text((24,16),'RUFLO / COMPLETE THEME WORKFLOW',font=font,fill=f['accent'])+ d.text((24,45),f['caption'],font=small,fill='#a8b2bd')+ d.line((24,68,width-24,68),fill=f['accent'])+ left=24+(116-f['columns'])*5+ for y,row in enumerate(f['rows']):+ for x,c in enumerate(row):im.paste(tile(c,f['bg']),(left+x*10,78+y*19))+ d.line((24,height-35,24+(width-48)*(n+1)/len(frames),height-35),fill=f['accent'],width=2)+ d.text((24,height-23),'RENDERER DEMO / real UI actions + disk persistence / native host and AI generation unverified',font=small,fill='#a8b2bd')+ video.stdin.write(im.tobytes())+ # GIF at 6 fps; MP4 retains the full 12 fps capture.+ if n%2==0:images.append(im.quantize(colors=128))+ if n in [60,96,180,300,420]:im.save(root/f'check-{n}.png')+video.stdin.close()+if video.wait()!=0:raise RuntimeError('ffmpeg failed')+images[0].save(root/'ruflo-console-demo.gif',save_all=True,append_images=images[1:],duration=[160 if i%3==0 else 170 for i in range(len(images))],loop=0,optimize=False)+print(json.dumps({'width':width,'height':height,'frames':len(frames),'gifFrames':len(images),'seconds':len(frames)/12}))diff --git a/plugins/ruflo-console/scripts/theme-demo.mts b/plugins/ruflo-console/scripts/theme-demo.mtsnew file mode 100644index 0000000000..26e78ef7df--- /dev/null+++ b/plugins/ruflo-console/scripts/theme-demo.mts@@ -0,0 +1,121 @@+/** Reproducible renderer workflow demo. No native host or model invocation is simulated. */+import { writeFileSync, readFileSync, mkdirSync, mkdtempSync } from 'node:fs'+import { resolve, join } from 'node:path'+import { tmpdir } from 'node:os'+import assert from 'node:assert/strict'+import { newState } from '../hooks/state'+import { themesOf, themeActions, activeTheme, loadThemes, THEME_PRESETS } from '../hooks/themes'+import { paneView } from '../hooks/views/pane'+import { setBootChecks } from '../hooks/boot-checks'+import { selfCheckResults } from '../hooks/self-check'+import { picturesOf } from '../hooks/views/frames'+import { THEME } from '../hooks/views/common'+const output=process.argv[2] ? resolve(process.argv[2]) : mkdtempSync(join(tmpdir(),'ruflo-console-demo-'))+mkdirSync(output,{recursive:true})+const storePath=resolve(output,'demo-session.json')+writeFileSync(storePath,'{}',{flag:'wx'})+const host:any={storeGet:async(key:string)=>JSON.parse(readFileSync(storePath,'utf8'))[key],storeSet:async(key:string,value:unknown)=>{const data=JSON.parse(readFileSync(storePath,'utf8'));data[key]=value;writeFileSync(storePath,JSON.stringify(data,null,2))},invalidate:()=>{}}+const fresh=()=>{const s=newState({look:'orbital',boot:false});Object.assign(s.pane,{rows:70,columns:116,isOpen:true,isShown:true,isFocused:true});s.view='menu';s.cwd='/demo/ruflo';return s}+let state=fresh(),columns=116+let actions=themeActions(state,host,()=>{throw Error('AI provider not connected in this renderer demo')})+setBootChecks(selfCheckResults())+const kit=Object.fromEntries(['Box','Text','Button','Input','Raster'].map(type=>[type,(props:any)=>({type,props})]))+const names:any={success:'#72c79b',error:'#ff6868',warning:'#e3ba74',suggestion:'#c6cbc8',claude:'#f06449'}+type C={ch:string,fg:string,bg?:string};type R=C[][]+let focus=''+const line=(s:string,fg:string,bg?:string):R=>[[...s].map(ch=>({ch,fg,bg}))]+const spaces=(n:number)=>Array.from({length:Math.max(0,n)},()=>({ch:' ',fg:THEME.info}))+function render(el:any,avail=columns):R {+ if(!el)return []+ if(typeof el==='string')return line(el,THEME.info)+ const p=el.props;if(!p||p.display==='none')return []+ if(el.type==='Raster'){const b=Buffer.from(p.cells,'base64');return Array.from({length:p.rows},(_,y)=>Array.from({length:p.columns},(_,x)=>{const at=(y*p.columns+x)*12;return {ch:String.fromCodePoint(b.readUInt32LE(at)),fg:'#'+(b.readUInt32LE(at+4)&0xffffff).toString(16).padStart(6,'0'),bg:'#'+(b.readUInt32LE(at+8)&0xffffff).toString(16).padStart(6,'0')}}))}+ if(el.type==='Text')return line(String(p.children??'').slice(0,avail),names[p.color]??p.color??THEME.info,p.backgroundColor)+ if(el.type==='Button')return line((p.plain?p.label:'['+p.label+'] ')??'',p.key===focus?'#ffffff':THEME.info,p.key===focus?'#41404c':undefined)+ if(el.type==='Input')return [...line(p.label,THEME.head),...line(('> '+p.placeholder).slice(0,avail),'#83948f')]+ const nodes=(Array.isArray(p.children)?p.children:[p.children]).filter(Boolean)+ const border=p.borderStyle?1:0,pad=p.paddingX??0,width=Math.min(avail,p.width??avail),inside=Math.max(1,width-2*border-2*pad)+ const kids=nodes.map((n:any)=>render(n,inside));const widths=kids.map(k=>Math.max(0,...k.map(r=>r.length)))+ if(p.flexDirection==='row'&&p.flexWrap!=='wrap'){+ const shrink=nodes.findIndex((n:any)=>n.props?.flexGrow)+ const target=shrink>=0?shrink:nodes.findLastIndex((n:any)=>n.props?.wrap==='truncate-end')+ if(target>=0){const room=Math.max(1,inside-widths.reduce((sum,w,i)=>sum+(i===target?0:w),0)-Math.max(0,kids.length-1)*(p.gap??0));kids[target]=render(nodes[target],room);widths[target]=Math.max(0,...kids[target]!.map(r=>r.length))}+ }+ let rows:R+ if(p.flexDirection!=='row')rows=kids.flatMap((k,i)=>[...k,...Array.from({length:i<kids.length-1?p.gap??0:0},()=>[])])+ else if(p.flexWrap==='wrap'){+ rows=[];let current:R=[];let used=0+ kids.forEach((child,i)=>{+ const w=widths[i]!,gap=used>0?p.gap??0:0+ if(used>0&&used+gap+w>inside){rows.push(...current);current=[];used=0}+ const space=used>0?p.gap??0:0+ const h=Math.max(current.length,child.length)+ current=Array.from({length:h},(_,y)=>[...(current[y]??spaces(used)),...spaces(space),...(child[y]??[]),...spaces(w-(child[y]?.length??0))]);used+=space+w+ });rows.push(...current)+ } else {+ const gap=p.gap??0;let remaining=inside-widths.reduce((a,b)=>a+b,0)-Math.max(0,kids.length-1)*gap+ const grow=nodes.findIndex((n:any)=>n.props?.flexGrow);if(grow>=0&&remaining>0)widths[grow]+=remaining+ const height=Math.max(0,...kids.map(k=>k.length))+ rows=Array.from({length:height},(_,y)=>kids.flatMap((k,i)=>[...(k[y]??[]),...spaces(widths[i]-(k[y]?.length??0)),...spaces(i<kids.length-1?gap:0)]))+ }+ if(border){const w=p.width?width:Math.min(width,Math.max(0,...rows.map(r=>r.length))+2+2*pad);const color=names[p.borderColor]??p.borderColor??THEME.head;const edge=(ch:string)=>({ch,fg:color});rows=rows.map(r=>[edge('β'),...spaces(pad),...r.slice(0,w-2-pad*2),...spaces(w-2-pad-r.length),edge('β')]);rows=[...line('β'+'β'.repeat(Math.max(0,w-2))+'β',color),...rows,...line('β'+'β'.repeat(Math.max(0,w-2))+'β',color)]}+ return [...Array.from({length:p.marginTop??0},()=>[]),...rows]+}++const noop:any=new Proxy(()=>undefined,{get:()=>noop})+const act=new Proxy(noop,{get:(_,key)=>key==='themes'?actions:key==='view'?(view:any)=>{state.view=view}:noop})+const flat=(node:any):any[]=>node&&typeof node==='object'?[node,...(Array.isArray(node.props?.children)?node.props.children.flatMap(flat):flat(node.props?.children))]:[]+let clock=1+const draw=()=>paneView({state,kit,act,columns,nowMs:clock,pictures:picturesOf(state,columns,clock,clock)} as any)+const flush=async()=>{await new Promise(resolve=>setTimeout(resolve,0))}+const evidence:string[]=[]+const click=async(key:string)=>{const el=flat(draw()).find(n=>n.props?.key===key);assert.equal(typeof el?.props.onPress,'function',key);focus=key;el.props.onPress();await flush()}+const submit=async(key:string,value:string)=>{const el=flat(draw()).find(n=>n.props?.key===key);assert.equal(typeof el?.props.onSubmit,'function',key);focus=key;el.props.onSubmit(value);await flush()}+const frames:any[]=[]+function capture(seconds:number,caption:string){+ for(let i=0;i<seconds*12;i++){+ const rows=render(draw());assert.ok(rows.every(r=>r.length<=columns),`overflow at ${columns}: ${Math.max(...rows.map(r=>r.length))}`)+ frames.push({rows,caption,bg:activeTheme(state).palette.background,accent:THEME.head,columns});clock+=1000/12+ }+ focus=''+}+state.options.boot=true;state.pane.bootAtMs=1+capture(3,'01 / BOOT / actual local self checks')+state.options.boot=false+capture(3,'02 / MAIN MENU / full console navigation')+await click('menu-go-themes');assert.equal(state.view,'themes');evidence.push('Main menu opens Theme Studio')+for(const preset of THEME_PRESETS){+ await click(`theme-preset-${preset.id}`)+ assert.equal(activeTheme(state).name,preset.theme.name)+ capture(2,`03 / LOAD PRESET / ${preset.theme.name}`)+}+evidence.push('All six bundled palettes applied through visible buttons')+await click('theme-preset-synthwave')+await submit('theme-name','Night Shift')+await submit('theme-color','#79dfff')+assert.equal(activeTheme(state).name,'Synthwave');capture(2,'04 / CUSTOMIZE / draft leaves active palette unchanged')+await click('theme-tab-motion');await click('theme-speed-0.5');capture(2,'05 / MOTION / half speed globe and orchestration')+await click('theme-save');assert.equal(activeTheme(state).name,'Night Shift');evidence.push('Custom color and motion persisted to disk')+capture(2,'06 / SAVE / custom Night Shift palette applied')+state=fresh();actions=themeActions(state,host,()=>{});await loadThemes(state,host)+assert.equal(activeTheme(state).name,'Night Shift');assert.equal(activeTheme(state).motion.speed,0.5);assert.equal(activeTheme(state).palette.head,'#79dfff');evidence.push('Fresh state restores custom palette and motion from disk')+capture(3,'07 / REOPEN / saved selection restored from disk')+await click('menu-go-themes');await click('theme-tab-generate')+const imported={...THEME_PRESETS[0]!.theme,name:'Imported Arctic'}+await submit('theme-import',JSON.stringify(imported));await click('theme-save');assert.equal(activeTheme(state).name,'Imported Arctic')+evidence.push('Portable JSON imports through input and persists')+capture(2,'08 / IMPORT JSON / portable Arctic preset applied')+await click('theme-tab-motion');state.options.fps=0+const frozen=picturesOf(state,columns,clock,clock).get('title')!.encode()+assert.equal(frozen,picturesOf(state,columns,clock+1000,clock+1000).get('title')!.encode());evidence.push('Reduced motion keeps identical header frames')+capture(2,'09 / REDUCED MOTION / fps 0 freezes graphics')+state.options.fps=12;columns=80;state.pane.columns=80+capture(3,'10 / RESIZE / 80 columns, stacked editor and preview')+columns=116;state.pane.columns=116+capture(2,'11 / RESIZE / 116 columns, editor beside preview')+evidence.push('Renderer bounds verified at 80 and 116 columns; native layout unverified')+await click('tab-menu');assert.equal(state.view,'menu');assert.equal(activeTheme(state).name,'Imported Arctic');capture(2,'12 / MAIN MENU / imported theme retained')+evidence.push('Return to main menu retains imported theme')+writeFileSync(resolve(output,'frames.json'),JSON.stringify(frames))+writeFileSync(resolve(output,'receipt.json'),JSON.stringify({mode:'renderer workflow with actual view handlers and filesystem storage',nativeHost:false,aiProviderInvoked:false,frames:frames.length,fps:12,seconds:frames.length/12,evidence},null,2))+console.log(JSON.stringify({output,frames:frames.length,maxRows:Math.max(...frames.map(f=>f.rows.length)),evidence}))