raibid-cli

DGX Spark Personal CI Agent Pool - TUI-first developer tool for managing self-hosted CI agents

A terminal-based management interface for running ephemeral, auto-scaling CI/CD infrastructure on NVIDIA DGX Spark. Built with Rust and Ratatui for a responsive, SSH-friendly developer experience.

License: MIT OR Apache-2.0

Features

Production Infrastructure πŸš€

  • k3s Cluster - Automated Kubernetes cluster setup on ARM64 and x86_64
  • Gitea + OCI Registry - Self-hosted Git server with container registry
  • Redis Streams - Job queue management with consumer groups
  • KEDA Autoscaling - Event-driven autoscaling (scale 0β†’10 based on queue depth)
  • Flux GitOps - Continuous delivery from Gitea repository
  • Real-time Status - Live cluster monitoring via Kubernetes API

Developer Experience πŸ’»

  • Interactive TUI Dashboard - Real-time monitoring with Ratatui-based terminal interface
  • Job Management - List, view, cancel, and retry CI jobs
  • Agent Management - Monitor and scale build agents dynamically
  • Repository Mirroring - Sync GitHub repositories to local Gitea instance
  • Flexible Configuration - YAML/TOML configuration with environment variable overrides
  • Comprehensive Testing - 100+ unit tests with TDD workflow

Quick Start

Prerequisites

Rust is required to build raibid-cli. Install it using rustup:

# Linux/macOS
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
 
# Follow the prompts, then reload your shell
source $HOME/.cargo/env
 
# Verify installation
rustc --version
cargo --version

For Windows, download and run rustup-init.exe.

Installation

From Source

# Clone the repository
git clone https://github.com/raibid-labs/raibid-cli.git
cd raibid-cli
 
# Build release binary
cargo build --release
 
# Verify the build succeeded
ls -lh target/release/raibid-cli
./target/release/raibid-cli --version
 
# Install to user-local directory (recommended, no sudo required)
mkdir -p ~/.local/bin
cp target/release/raibid-cli ~/.local/bin/
 
# Add to PATH if not already (add to your ~/.bashrc or ~/.zshrc)
export PATH="$HOME/.local/bin:$PATH"

Verify Build Succeeded:

After building, verify the binary was created:

# For native build
ls -lh target/release/raibid-cli
./target/release/raibid-cli --version
 
# Expected output: raibid-cli 0.1.0

If the binary is not found at target/release/raibid-cli, you may have CARGO_TARGET_DIR environment variable set. See the Troubleshooting section below.

Alternative: System-wide Installation

If you prefer system-wide installation:

# Install to /usr/local/bin (requires sudo)
sudo cp target/release/raibid-cli /usr/local/bin/

For DGX Spark (ARM64)

# Add ARM64 target (if not already installed)
rustup target add aarch64-unknown-linux-gnu
 
# Build for ARM64
cargo build --release --target aarch64-unknown-linux-gnu
 
# Verify the build succeeded
ls -lh target/aarch64-unknown-linux-gnu/release/raibid-cli
 
# Verify architecture (optional)
file target/aarch64-unknown-linux-gnu/release/raibid-cli
 
# Install to user-local directory
mkdir -p ~/.local/bin
cp target/aarch64-unknown-linux-gnu/release/raibid-cli ~/.local/bin/

Verify ARM64 Build:

# Check binary exists
ls -lh target/aarch64-unknown-linux-gnu/release/raibid-cli
 
# Verify it's an ARM64 binary
file target/aarch64-unknown-linux-gnu/release/raibid-cli
# Expected output: ELF 64-bit LSB executable, ARM aarch64...
 
# Test version (only works on ARM64 systems)
./target/aarch64-unknown-linux-gnu/release/raibid-cli --version

Installation Directory

By default, raibid-cli setup all installs infrastructure binaries (k3s, flux) to ~/.local/bin. This directory:

  • Requires no sudo/elevated permissions
  • Follows the XDG Base Directory specification
  • Works for single-user setups

If ~/.local/bin is not in your PATH, raibid-cli will display a warning with instructions to add it.

First Run

  1. Initialize configuration:

    raibid-cli config init
  2. Set up infrastructure:

    raibid-cli setup all
  3. Launch TUI dashboard:

    raibid-cli tui

Commands

TUI Dashboard

Launch the interactive terminal UI for real-time monitoring and management:

raibid-cli tui

TUI Features:

  • Jobs Tab - View running, pending, successful, and failed jobs
  • Agents Tab - Monitor agent status, CPU/memory usage, and uptime
  • Config Tab - View current configuration
  • Logs Tab - Real-time log streaming

Keyboard Shortcuts:

  • Tab / Shift+Tab - Navigate between tabs
  • 1-4 - Jump directly to tab (1=Jobs, 2=Agents, 3=Config, 4=Logs)
  • ↑/↓ or j/k - Navigate list items
  • Enter - View details of selected item
  • f - Open filter menu
  • / - Search mode
  • r - Refresh data
  • ? - Show help screen
  • q or Ctrl+C - Quit

Infrastructure Commands

Manage infrastructure components:

# Setup commands
raibid-cli setup k3s       # Bootstrap k3s cluster
raibid-cli setup gitea     # Deploy Gitea with OCI registry
raibid-cli setup redis     # Deploy Redis Streams
raibid-cli setup keda      # Deploy KEDA autoscaler
raibid-cli setup flux      # Bootstrap Flux GitOps
raibid-cli setup all       # Setup all components in order
 
# Teardown commands
raibid-cli teardown <component>  # Remove a specific component
raibid-cli teardown all          # Remove all components
 
# Status commands
raibid-cli status          # Show all component status
raibid-cli status k3s      # Show k3s cluster status

Job Management

Manage CI/CD jobs:

# List jobs
raibid-cli job list                      # List all jobs
raibid-cli job list --status running     # Filter by status
raibid-cli job list --repo raibid/core   # Filter by repository
raibid-cli job list --limit 10           # Limit results
raibid-cli job list --output json        # JSON output
 
# View job details
raibid-cli job show <job-id>             # Show job details
raibid-cli job show <job-id> --output json
 
# Manage jobs
raibid-cli job cancel <job-id>           # Cancel a job (with confirmation)
raibid-cli job cancel <job-id> --force   # Cancel without confirmation
raibid-cli job retry <job-id>            # Retry a failed job

Agent Management

Manage build agents:

# List agents
raibid-cli agent list                    # List all agents
raibid-cli agent list --status idle      # Filter by status
raibid-cli agent list --output json      # JSON output
 
# View agent details
raibid-cli agent show <agent-id>         # Show agent details
raibid-cli agent show <agent-id> --output json
 
# Manage agents
raibid-cli agent restart <agent-id>      # Restart an agent (with confirmation)
raibid-cli agent restart <agent-id> --force
raibid-cli agent scale --count 5         # Scale to 5 agents
raibid-cli agent scale --count 3 --min 2 --max 8

Repository Mirroring

Sync GitHub repositories to local Gitea:

# Add mirrors
raibid-cli mirror add github.com/user/repo              # Add mirror
raibid-cli mirror add github.com/user/repo --name my-repo
raibid-cli mirror add github.com/user/repo --sync-interval 30
 
# List mirrors
raibid-cli mirror list                   # List all mirrors
raibid-cli mirror list --output json     # JSON output
 
# Sync mirrors
raibid-cli mirror sync github.com/user/repo         # Sync repository
raibid-cli mirror sync github.com/user/repo --force # Force sync
 
# Remove mirrors
raibid-cli mirror remove github.com/user/repo       # Remove (with confirmation)
raibid-cli mirror remove github.com/user/repo --force

Configuration Management

Manage configuration files:

# Initialize configuration
raibid-cli config init                   # Create config file
raibid-cli config init --output custom.yaml
raibid-cli config init --minimal         # Minimal config
raibid-cli config init --force           # Overwrite existing
 
# View configuration
raibid-cli config show                   # Show merged config (YAML)
raibid-cli config show --format json     # JSON format
raibid-cli config show --format toml     # TOML format
raibid-cli config show --file path/to/config.yaml
 
# Validate configuration
raibid-cli config validate               # Validate merged config
raibid-cli config validate path/to/config.yaml
 
# Show config path
raibid-cli config path                   # Show config file location

Global Options

raibid-cli --verbose <command>    # Enable verbose logging
raibid-cli --version              # Show version
raibid-cli --help                 # Show help

Configuration

Configuration files are loaded in priority order (highest to lowest):

  1. Environment variables - RAIBID_* prefixed variables
  2. Local file - ./raibid.yaml in current directory
  3. User file - ~/.config/raibid/config.yaml
  4. System file - /etc/raibid/config.yaml
  5. Built-in defaults

Example Configuration

# Cluster configuration
cluster:
  name: "dgx-spark-ci"
  namespace: "raibid-ci"
  kubeconfig: "~/.kube/config"
 
# API server configuration
api:
  host: "localhost"
  port: 8080
  timeout_seconds: 30
 
# Agent configuration
agents:
  min_count: 0           # Scale to zero when idle
  max_count: 8           # Maximum concurrent agents
  idle_timeout_minutes: 5
  image: "raibid/rust-builder:latest"
 
# Gitea configuration
gitea:
  url: "http://gitea.raibid-ci.svc.cluster.local:3000"
  admin_user: "admin"
  # admin_password loaded from RAIBID_GITEA_ADMIN_PASSWORD
 
# Redis configuration
redis:
  url: "redis://redis.raibid-ci.svc.cluster.local:6379"
  stream_name: "ci-jobs"
  consumer_group: "ci-workers"
 
# TUI configuration
tui:
  refresh_interval_ms: 1000
  panel_proportions: [70, 15, 15]  # [main, header, footer]

Environment Variables

Override configuration with environment variables:

export RAIBID_API_HOST="api.example.com"
export RAIBID_API_PORT="9090"
export RAIBID_AGENTS_MAX_COUNT="16"
export RAIBID_GITEA_ADMIN_PASSWORD="secret"

Development

Prerequisites

  • Rust - 1.70+ (latest stable recommended)
  • Cargo - Rust package manager

Building

# Debug build
cargo build
 
# Release build (optimized)
cargo build --release
 
# Check binary size
ls -lh target/release/raibid-cli

Testing

# Run all tests
cargo test --all-features
 
# Run specific test file
cargo test --test cli_test
 
# Run with output
cargo test -- --nocapture
 
# Run specific test
cargo test test_version_flag

Code Quality

# Run clippy linter
cargo clippy -- -D warnings
 
# Format code
cargo fmt
 
# Check formatting
cargo fmt --check

Testing TUI Locally

The TUI uses mock data for development and testing:

# Run TUI with debug logging
RUST_LOG=debug cargo run -- tui
 
# Build and run release version
cargo build --release
./target/release/raibid-cli tui

Architecture

Project Structure

raibid-cli/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ cli/              # CLI argument parsing (clap)
β”‚   β”œβ”€β”€ commands/         # Command implementations
β”‚   β”‚   β”œβ”€β”€ config.rs     # Configuration management
β”‚   β”‚   β”œβ”€β”€ setup.rs      # Infrastructure setup
β”‚   β”‚   β”œβ”€β”€ teardown.rs   # Infrastructure teardown
β”‚   β”‚   β”œβ”€β”€ status.rs     # Status checking
β”‚   β”‚   β”œβ”€β”€ job.rs        # Job management
β”‚   β”‚   β”œβ”€β”€ agent.rs      # Agent management
β”‚   β”‚   └── mirror.rs     # Repository mirroring
β”‚   β”œβ”€β”€ config/           # Configuration loading and validation
β”‚   β”œβ”€β”€ infrastructure/   # Infrastructure provisioning
β”‚   β”‚   β”œβ”€β”€ k3s.rs        # k3s cluster installer
β”‚   β”‚   β”œβ”€β”€ gitea.rs      # Gitea + OCI registry installer
β”‚   β”‚   β”œβ”€β”€ redis.rs      # Redis Streams installer
β”‚   β”‚   β”œβ”€β”€ keda.rs       # KEDA autoscaler installer
β”‚   β”‚   β”œβ”€β”€ flux.rs       # Flux GitOps installer
β”‚   β”‚   β”œβ”€β”€ status.rs     # Real-time status checking
β”‚   β”‚   β”œβ”€β”€ error.rs      # Error handling types
β”‚   β”‚   β”œβ”€β”€ retry.rs      # Retry logic with backoff
β”‚   β”‚   β”œβ”€β”€ rollback.rs   # Transaction-based rollback
β”‚   β”‚   β”œβ”€β”€ preflight.rs  # Pre-flight validation
β”‚   β”‚   └── healthcheck.rs # Health check utilities
β”‚   β”œβ”€β”€ tui/              # Terminal UI (Ratatui)
β”‚   β”‚   β”œβ”€β”€ app.rs        # Application state
β”‚   β”‚   β”œβ”€β”€ ui.rs         # UI rendering
β”‚   β”‚   β”œβ”€β”€ events.rs     # Event handling
β”‚   β”‚   └── mock_data.rs  # Mock data generator
β”‚   β”œβ”€β”€ lib.rs            # Library entry point
β”‚   └── main.rs           # Binary entry point
β”œβ”€β”€ tests/                # Integration tests
β”‚   β”œβ”€β”€ cli_test.rs
β”‚   β”œβ”€β”€ config_test.rs
β”‚   β”œβ”€β”€ tui_test.rs
β”‚   β”œβ”€β”€ redis_test.rs
β”‚   β”œβ”€β”€ flux_test.rs
β”‚   β”œβ”€β”€ status_test.rs
β”‚   └── error_handling_test.rs
β”œβ”€β”€ docs/                 # Documentation
β”‚   β”œβ”€β”€ USER_GUIDE.md
β”‚   β”œβ”€β”€ gitea-installation.md
β”‚   β”œβ”€β”€ redis-deployment.md
β”‚   β”œβ”€β”€ keda-installation.md
β”‚   └── error-recovery.md
└── Cargo.toml

Dependencies

Core:

  • clap - CLI argument parsing
  • anyhow - Error handling
  • tracing - Structured logging

Infrastructure:

  • kube - Kubernetes API client
  • k8s-openapi - Kubernetes resource types
  • tokio - Async runtime
  • reqwest - HTTP client
  • sha256 - Checksum verification

TUI:

  • ratatui - Terminal UI framework
  • crossterm - Terminal manipulation

Config:

  • serde - Serialization framework
  • serde_yaml - YAML support
  • toml - TOML support
  • serde_json - JSON support

Display:

  • comfy-table - ASCII table rendering
  • colored - Terminal colors
  • dialoguer - Interactive prompts

See Cargo.toml for full dependency list.

System Requirements

Minimum Requirements

  • OS: Linux (Ubuntu 22.04+), macOS, Windows (WSL2)
  • Memory: 100MB RAM
  • Disk: 10MB for binary

Target Platform: NVIDIA DGX Spark

  • CPU: 20 cores ARM64 (10x Cortex-X925, 10x Cortex-A725)
  • Memory: 128GB LPDDR5x unified memory
  • Storage: Up to 4TB NVMe
  • Network: 200 Gb/s ConnectX-7

Resource Footprint

  • Base infrastructure: ~4 cores, ~4GB RAM
  • Per agent: ~2 cores, ~4GB RAM
  • TUI client: <10MB RAM

Roadmap

βœ… Completed: WS-01 - CLI/TUI Application

  • βœ… CLI scaffolding with clap
  • βœ… Ratatui TUI with 4-tab dashboard (Jobs, Agents, Config, Logs)
  • βœ… Enhanced TUI widgets and navigation
  • βœ… Interactive controls and popups
  • βœ… Job, agent, and mirror commands
  • βœ… Configuration management with multi-source loading
  • βœ… Comprehensive testing (100+ tests) and documentation

βœ… Completed: WS-04 - Infrastructure Provisioning

  • βœ… k3s cluster installation with binary verification
  • βœ… Gitea deployment with OCI registry via Helm
  • βœ… Redis Streams for job queue management
  • βœ… KEDA autoscaler with Redis Streams trigger
  • βœ… Flux GitOps bootstrap with Gitea integration
  • βœ… Real-time status monitoring via Kubernetes API
  • βœ… Enhanced error handling with retry logic and rollback

πŸ”œ Next: WS-02 - API Server & Job Execution

  • API server implementation in Rust
  • Job dispatcher with Redis Streams
  • Agent lifecycle management
  • Build execution and caching

πŸ“‹ Future Workstreams

  • WS-03: CI agent implementations (Rust, multi-language)
  • WS-05: Repository mirroring automation
  • WS-06: Integration testing and production deployment

Troubleshooting

Permission Denied During Setup

Problem: raibid-cli setup all fails with β€œPermission denied (os error 13)”

Cause: Trying to install to a directory that requires elevated permissions (like /usr/local/bin)

Solution:

By default, raibid-cli now installs to ~/.local/bin which requires no sudo. If you’re seeing this error:

  1. Check your configuration - You may have a custom install_dir set:

    raibid-cli config show
  2. Use the default user-local installation (recommended):

    • Remove any custom install_dir from your config
    • Ensure ~/.local/bin is in your PATH:
      # Add to ~/.bashrc or ~/.zshrc
      export PATH="$HOME/.local/bin:$PATH"
       
      # Reload shell
      source ~/.bashrc  # or source ~/.zshrc
  3. Or use a custom writable directory:

    # Create a custom bin directory
    mkdir -p ~/bin
     
    # Set it in your config (create ~/.config/raibid/config.yaml)
    echo "install_dir: $HOME/bin" > ~/.config/raibid/config.yaml
     
    # Add to PATH
    export PATH="$HOME/bin:$PATH"
  4. System-wide installation (not recommended): If you need system-wide installation, you’ll need to manually install binaries:

    # Download binaries first
    raibid-cli setup all --download-only
     
    # Then manually copy with sudo
    sudo cp ~/.cache/raibid/k3s /usr/local/bin/
    sudo cp ~/.cache/raibid/flux /usr/local/bin/

Binary Not Found After Building

Problem: cargo build --release completes but no binary in target/release/

Cause: You have CARGO_TARGET_DIR environment variable set, which redirects build output.

Solution:

# Check if CARGO_TARGET_DIR is set
echo $CARGO_TARGET_DIR
 
# If set, your binary is at:
ls -lh $CARGO_TARGET_DIR/release/raibid-cli
 
# Option 1: Copy to expected location
mkdir -p target/release
cp $CARGO_TARGET_DIR/release/raibid-cli target/release/
 
# Option 2: Unset and rebuild
unset CARGO_TARGET_DIR
cargo build --release
 
# Option 3: Build with explicit target dir
cargo build --release --target-dir ./target

Cargo Not Found

Problem: cargo: command not found

Solution: Install Rust and add to PATH

# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
 
# Reload shell
source $HOME/.cargo/env
 
# Verify
cargo --version

TUI Not Rendering Properly

# Check terminal compatibility
echo $TERM
 
# Try different terminal emulator
# Recommended: Alacritty, WezTerm, iTerm2, Windows Terminal

Configuration Not Loading

# Check config file location
raibid-cli config path
 
# Validate config syntax
raibid-cli config validate
 
# Show merged config
raibid-cli config show

Build Errors

# Update Rust toolchain
rustup update stable
 
# Clean and rebuild
cargo clean
cargo build --release

Contributing

This project is currently in active development. Contributions are welcome!

Development Guidelines

  1. Follow Rust best practices and idioms
  2. Write tests for new features
  3. Run clippy and rustfmt before committing
  4. Update documentation for user-facing changes

Testing Changes

# Run full test suite
cargo test --all-features
 
# Run linter
cargo clippy -- -D warnings
 
# Format code
cargo fmt

License

This project is dual-licensed under:

You may choose either license for your use.

Acknowledgments


Built for developers, by developers. Optimized for NVIDIA DGX Spark.

Last Updated: 2025-10-30 Status: WS-01 & WS-04 Complete - Production Infrastructure Ready πŸš€