Files
sideline/examples
David Gwilliam fb0dd4592f feat(repl): Add REPL effect with HUD-style interactive interface
Implement a Read-Eval-Print Loop (REPL) effect that provides a
HUD-style overlay for interactive pipeline control.

## New Files

- engine/effects/plugins/repl.py - REPL effect plugin with command processor
- engine/display/backends/terminal.py - Added raw mode and input handling
- examples/repl_simple.py - Simple demonstration script
- tests/test_repl_effect.py - 18 comprehensive tests

## Features

### REPL Interface
- HUD-style overlay showing FPS, command history, output buffer size
- Command history navigation (Up/Down arrows)
- Command execution (Enter)
- Character input and backspace support
- Output buffer with scrolling

### Commands
- help - Show available commands
- status - Show pipeline status and metrics
- effects - List all effects in pipeline
- effect <name> <on|off> - Toggle effect
- param <effect> <param> <value> - Set parameter
- pipeline - Show current pipeline order
- clear - Clear output buffer
- quit - Show exit message

### Terminal Input Support
- Added set_raw_mode() to TerminalDisplay for capturing keystrokes
- Added get_input_keys() to read keyboard input
- Proper terminal state restoration on cleanup

## Usage

Add 'repl' to effects in your configuration:

## Testing

All 18 REPL tests pass, covering:
- Effect registration
- Command processing
- Navigation (history, editing)
- Configuration
- Rendering

## Integration

The REPL effect integrates with the existing pipeline system:
- Uses EffectPlugin interface
- Supports partial updates
- Reads metrics from EffectContext
- Can be controlled via keyboard when terminal display is in raw mode

Next steps:
- Integrate REPL input handling into pipeline_runner.py
- Add keyboard event processing loop
- Create full demo with interactive features
2026-03-21 21:12:38 -07:00
..

Examples

This directory contains example scripts demonstrating how to use Mainline's features.

hybrid_visualization.py - Renders visualization using the hybrid preset-graph format.

python examples/hybrid_visualization.py

This uses 70% less space than verbose node DSL while providing the same flexibility.

Configuration

The hybrid format uses inline objects and arrays:

[pipeline]
source = "headlines"
camera = { mode = "scroll", speed = 1.0 }
effects = [
    { name = "noise", intensity = 0.3 },
    { name = "fade", intensity = 0.5 }
]
display = { backend = "terminal", positioning = "mixed" }

See docs/hybrid-config.md for complete documentation.


Default Visualization (Verbose Node DSL)

default_visualization.py - Renders the standard Mainline visualization using the verbose graph DSL.

python examples/default_visualization.py

This demonstrates the verbose node-based syntax (more flexible for complex DAGs):

[nodes.source] type = "source" source = "headlines"
[nodes.camera] type = "camera" mode = "scroll"
[nodes.noise] type = "effect" effect = "noise" intensity = 0.3
[nodes.display] type = "display" backend = "terminal"
[connections] list = ["source -> camera -> noise -> display"]

Graph DSL Demonstration

graph_dsl_demo.py - Demonstrates the graph-based DSL in multiple ways:

python examples/graph_dsl_demo.py

Shows:

  • Imperative Python API for building graphs
  • Dictionary-based API
  • Graph validation (cycles, disconnected nodes)
  • Different node types and configurations

Integration Test

test_graph_integration.py - Tests the graph system with actual pipeline execution:

python examples/test_graph_integration.py

Verifies:

  • Graph loading from TOML
  • Pipeline execution
  • Output rendering
  • Comparison with preset-based pipelines

Other Demos

  • demo-lfo-effects.py - LFO modulation of effect intensities (Pygame display)
  • demo_oscilloscope.py - Oscilloscope visualization
  • demo_image_oscilloscope.py - Image-based oscilloscope

Configuration Format Comparison

Format Use Case Lines Example
Hybrid Recommended for most use cases 20 hybrid_config.toml
Verbose Node DSL Complex DAGs, branching 39 default_visualization.toml
Preset Simple configurations 10 presets.toml

Reference

  • docs/hybrid-config.md - Hybrid preset-graph configuration
  • docs/graph-dsl.md - Verbose node-based graph DSL
  • docs/presets-usage.md - Preset system usage