blessed-widget-generator
npx machina-cli add skill a5c-ai/babysitter/blessed-widget-generator --openclawFiles (1)
SKILL.md
4.3 KB
Blessed Widget Generator
Generate blessed widgets for Node.js terminal UIs.
Capabilities
- Generate blessed widget definitions
- Create dashboard layouts
- Set up interactive forms
- Implement custom components
- Configure styling and borders
- Create event handling patterns
Usage
Invoke this skill when you need to:
- Build terminal dashboards with Node.js
- Create complex TUI layouts
- Implement monitoring interfaces
- Set up blessed project structure
Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| layout | string | No | Layout type (dashboard, form, list) |
| widgets | array | No | Widget definitions |
Generated Patterns
Dashboard Layout
const blessed = require('blessed');
const contrib = require('blessed-contrib');
// Create screen
const screen = blessed.screen({
smartCSR: true,
title: 'System Dashboard',
});
// Create grid layout
const grid = new contrib.grid({
rows: 12,
cols: 12,
screen: screen,
});
// CPU Line Chart
const cpuLine = grid.set(0, 0, 4, 6, contrib.line, {
style: { line: 'yellow', text: 'green', baseline: 'black' },
xLabelPadding: 3,
xPadding: 5,
showLegend: true,
label: 'CPU Usage',
});
// Memory Gauge
const memGauge = grid.set(0, 6, 4, 6, contrib.gauge, {
label: 'Memory Usage',
stroke: 'green',
fill: 'white',
});
// Log Box
const logBox = grid.set(4, 0, 4, 12, contrib.log, {
fg: 'green',
selectedFg: 'green',
label: 'Logs',
});
// Process Table
const processTable = grid.set(8, 0, 4, 12, contrib.table, {
keys: true,
fg: 'white',
selectedFg: 'white',
selectedBg: 'blue',
interactive: true,
label: 'Processes',
columnSpacing: 4,
columnWidth: [10, 30, 10, 10],
});
// Update data
function updateDashboard() {
// CPU data
cpuLine.setData([{
title: 'CPU',
x: ['1', '2', '3', '4', '5'],
y: [Math.random() * 100, Math.random() * 100, Math.random() * 100, Math.random() * 100, Math.random() * 100],
}]);
// Memory
memGauge.setPercent(Math.random() * 100);
// Logs
logBox.log(`[${new Date().toISOString()}] System event`);
// Processes
processTable.setData({
headers: ['PID', 'Name', 'CPU', 'MEM'],
data: [
['1234', 'node', '2.5%', '150MB'],
['5678', 'chrome', '15.2%', '500MB'],
],
});
screen.render();
}
// Key bindings
screen.key(['escape', 'q', 'C-c'], () => process.exit(0));
// Update interval
setInterval(updateDashboard, 1000);
updateDashboard();
screen.render();
Form Widget
const blessed = require('blessed');
const screen = blessed.screen({
smartCSR: true,
title: 'Configuration Form',
});
const form = blessed.form({
parent: screen,
keys: true,
left: 'center',
top: 'center',
width: 60,
height: 20,
border: { type: 'line' },
style: { border: { fg: 'blue' } },
});
// Input field
blessed.text({
parent: form,
top: 1,
left: 2,
content: 'Username:',
});
const usernameInput = blessed.textbox({
parent: form,
name: 'username',
top: 1,
left: 12,
height: 1,
width: 40,
inputOnFocus: true,
style: { fg: 'white', bg: 'black' },
});
// Password field
blessed.text({
parent: form,
top: 3,
left: 2,
content: 'Password:',
});
const passwordInput = blessed.textbox({
parent: form,
name: 'password',
top: 3,
left: 12,
height: 1,
width: 40,
censor: true,
inputOnFocus: true,
style: { fg: 'white', bg: 'black' },
});
// Submit button
const submitBtn = blessed.button({
parent: form,
name: 'submit',
content: ' Submit ',
top: 6,
left: 'center',
shrink: true,
style: {
fg: 'white',
bg: 'blue',
focus: { bg: 'green' },
},
});
submitBtn.on('press', () => {
form.submit();
});
form.on('submit', (data) => {
console.log('Form data:', data);
process.exit(0);
});
screen.key(['escape', 'q'], () => process.exit(0));
screen.render();
Dependencies
{
"dependencies": {
"blessed": "^0.1.81",
"blessed-contrib": "^4.10.1"
}
}
Target Processes
- tui-application-framework
- dashboard-monitoring-tui
- interactive-form-implementation
Source
git clone https://github.com/a5c-ai/babysitter/blob/main/plugins/babysitter/skills/babysit/process/specializations/cli-mcp-development/skills/blessed-widget-generator/SKILL.mdView on GitHub Overview
Blessed Widget Generator helps you scaffold blessed UI components for Node.js terminal apps. It supports dashboards, forms, and interactive widgets, enabling structured layouts, styling, and responsive event handling. The tool outputs blessed widget definitions and ready-to-use patterns with blessed-contrib grid.
How This Skill Works
You provide a projectName, optional layout, and widget definitions. The skill then generates blessed widget code and layout patterns (like a Dashboard Layout and a Form Widget) using blessed and blessed-contrib, wiring up grids, data updates, and event handlers, so you can render and interact with the UI immediately.
When to Use It
- Building terminal dashboards with Node.js to monitor system metrics
- Creating complex TUI layouts combining charts, gauges, logs, and tables
- Setting up interactive forms for configuration or input collection
- Prototyping dashboards and forms before full implementation
- Establishing a blessed project structure with reusable components
Quick Start
- Step 1: Install blessed and blessed-contrib and initialize a project (define projectName)
- Step 2: Define a Dashboard Layout or Form Widget using blessed and blessed-contrib components
- Step 3: Implement update logic and render loop (e.g., screen.render() with setInterval)
Best Practices
- Start with a clear dashboard layout using blessed-contrib grid for predictable placement
- Modularize widgets (charts, gauges, tables) for reuse across screens
- Keep widget data models in sync with setData and update loops
- Wire keyboard and mouse events early to ensure accessible navigation
- Validate inputs and gracefully handle rendering errors to avoid crashes
Example Use Cases
- System dashboard with CPU line, memory gauge, logs, and processes table using a grid layout
- Configuration form with username and password fields and a submit button
- Live log viewer panel paired with a real-time status table
- Processes monitor showing a table with PID, Name, CPU, and MEM columns
- Skeleton app demonstrating screen, grid, and update loop with event bindings
Frequently Asked Questions
Add this skill to your agents