herosal-herodev

Crates.ioherosal-herodev
lib.rsherosal-herodev
version0.1.1
created_at2025-12-14 03:09:57.261739+00
updated_at2025-12-14 13:34:38.69145+00
descriptionHeroDev - CLI tool for managing developer sessions with btrfs snapshots
homepage
repositoryhttps://github.com/threefoldtech/sal
max_upload_size
id1983704
size162,696
kristof de spiegeleer (despiegk)

documentation

README

HeroDev - Developer Session Manager

A Rust CLI tool for managing developer sessions with btrfs snapshots, enabling isolated Claude coding environments.

Overview

HeroDev manages developer sessions where each session gets a btrfs snapshot of /code, allowing developers to make changes in isolation. Sessions are tied to system users named dev_${name}.

System Requirements

  • Ubuntu Linux
  • sudo privileges
  • The following packages (auto-installed by herodev init):
    • git
    • buildah
    • podman
    • btrfs-progs

Installation

cargo build -p herodev --release
# Binary will be at target/release/herodev

Quick Start

Run init to check and install all dependencies:

# Interactive mode - will prompt before installing
herodev init

# Force mode - automatically install everything without prompts
herodev -f init

# Specify btrfs image size (default: 50GB)
herodev init --size 100

Usage

Global Options

-f, --force    Force mode - automatically install/configure without prompts

Commands

# System setup and checks
herodev init                              # Check system, prompt to install missing deps
herodev -f init                           # Force install all missing deps without prompts
herodev init --size 100                   # Use 100GB for btrfs image

# Session management
herodev sessions list                     # List all dev sessions
herodev sessions create <name>            # Create a new session
herodev sessions delete <name>            # Delete a session
herodev sessions enter <name>             # Enter session with shell
herodev sessions enter <name> --repo <path>        # Enter at specific repo
herodev sessions enter <name> --repo <path> --claude  # Enter with Claude Code

# Repository management
herodev repos list                        # List git repos in /code
herodev repos list --path /some/dir       # List repos in specific directory
herodev repos reorganize                  # Reorganize repos to match remote URL structure
herodev repos reorganize --path /some/dir

# Changes management
herodev changes list <session>            # View changes in a session
herodev changes push <session> --all -m "commit message"  # Push all changes

Interactive Mode

Launch the interactive TUI menu:

herodev

Init Process

The herodev init command performs the following:

  1. System Checks

    • Verifies Ubuntu Linux
    • Verifies sudo access
    • Checks for required packages (git, buildah, podman, btrfs-progs)
    • Checks if /code is a btrfs subvolume
  2. Package Installation (if missing)

    • Runs apt-get update
    • Installs missing packages
  3. Btrfs Setup (if /code not configured)

    • Creates a loopback btrfs image at /var/lib/btrfs-code.img
    • Formats as btrfs filesystem
    • Creates root subvolume
    • Mounts at /code
    • Adds entry to /etc/fstab for persistence

Directory Conventions

/code/                          # Root btrfs subvolume
├── .sessions/                  # Session snapshots
│   └── dev_<name>/            # Individual session snapshot
├── ${serverhostname}/          # Server hostname (regular directory)
│   ├── ${orgname}/             # Organization (regular directory)
│   │   └── ${reponame}/        # Git repository (regular directory)

How It Works

  1. Session Creation: Creates a new Linux user dev_<name> and a btrfs snapshot of /code at /code/.sessions/dev_<name>

  2. Isolation: Each session has its own copy of the codebase via copy-on-write btrfs snapshots

  3. Mount Namespace: When entering a session, HeroDev uses Linux mount namespaces to bind-mount the session's snapshot to /code. This means inside the session, /code shows the session's isolated copy while the rest of the system sees the original /code

  4. Changes Tracking: HeroDev can scan for git repositories with uncommitted changes within a session

  5. Push Changes: Commit and push changes from session repos back to their remotes

  6. Repository Reorganization: Move repositories to follow the /code/{server}/{org}/{repo} convention based on their git remote URLs

Features

  • Automatic Setup: herodev init installs all dependencies and configures btrfs
  • Force Mode: Use -f flag to skip all prompts for scripted deployments
  • System Checks: Verify Ubuntu, btrfs, sudo, git, buildah, podman availability
  • Session CRUD: Create, list, enter, and delete developer sessions
  • Git Integration: Scan repos, detect changes, commit and push
  • Repository Reorganization: Auto-organize repos by remote URL structure
  • Interactive TUI: Menu-driven interface with colored output
  • CLI Interface: Scriptable commands for automation

License

Apache-2.0

Commit count: 0

cargo fmt