Skip to content
anywayePublic

About

A secure, reproducible VPS bootstrap for developers

Resources

Stars

6 stars

Watchers

1 watching

Forks

Repository files navigation

Mainframe

Secure, reproducible VPS bootstrap and machine configuration for developers.

Take a fresh machine to a fully configured dev box in one command. Supports both dev and prod modes.

# Install the mf CLI
curl -fsSL https://raw.githubusercontent.com/anywaye/mainframe/master/install.sh | bash

# Create a new config repo
mf new my-mainframe
cd my-mainframe

# Apply config to this machine
mf apply

# Or clone an existing config repo
mf init https://github.com/your-org/mainframe.git
mf apply

Philosophy

Mainframe is a framework, not a configuration.

Like Rails provides the structure for web apps, Mainframe provides the structure for machine configurations. You don't write the framework — you write your config. The framework handles the how; you provide the what.

  • mf new my-mainframe scaffolds the structure
  • You fill in packages.conf, shell/, editor/, mcp/, etc.
  • mf setup --dev sets up a dev machine (provision + apply)
  • mf setup --prod sets up a production server (provision only)
  • mf capture scans a machine and generates config

The framework provides the structure and logic. The user provides the content.

Not everyone uses zsh. Not everyone uses neovim. Not everyone uses tmux. Mainframe doesn't assume any of these. If a directory is empty, it's skipped. If a section is missing, it's ignored. You use what you need, skip what you don't.

The framework grows with you. As your tools change, your config changes. As the framework adds features, your existing config keeps working. mf apply is idempotent — run it 100 times, it's safe every time.

Two repos, one system

Framework (anywaye/mainframe) Config (your-org/mainframe)
What CLI tool + OS provisioning engine Your personal configuration
Installed via `curl -fsSL https://raw.githubusercontent.com/anywaye/mainframe/master/install.sh bash`
Edited by Framework maintainers You
Contains Go code, shell scripts, templates YAML, JSON, shell configs, dotfiles
OS-specific lib/os/<family>.sh (provisioning logic) os/<family>.sh (your preferences, optional)

The framework is installed once. The config repo is cloned per-machine. The framework reads the config repo and applies it.

Base + environment-specific pattern

Mainframe follows the base + environment-specific pattern used by Terraform, Helm, Docker Compose, and Ansible:

  • packages.conf — base packages (all machines)
  • packages.dev.conf — dev-only packages (optional, only applied in dev mode)
  • packages.prod.conf — prod-only packages (optional, only applied in prod mode)
  • mcp/, skills/, shell/, etc. — dev config (only applied via mf apply)
  • mainframe.yml has dev: and prod: sections for environment-specific config

The framework provides the merge logic; the user provides the content.

Config repo structure

my-mainframe/
├── mainframe.yml          # Machine config (mode, secrets, references)
├── packages.conf          # System packages (brew/apt/dnf)
├── runtimes.conf          # Language versions (mise format)
├── mcp/                   # MCP servers (registry + configs)
├── skills/                # AI agent skills
├── shell/                 # Shell config (optional)
├── git/                   # Git config (optional)
├── editor/                # Editor config (optional)
├── terminal/              # Terminal config (optional)
├── ssh/                   # SSH config (optional, no keys)
├── bin/                   # Custom scripts (optional)
├── os/                    # OS-specific settings (optional)
├── os.sh                  # OS-conditional settings (optional)
├── fleet/                 # Machine fleet definitions (optional)
│   ├── dev.yml            # Development machines
│   └── prod.yml           # Production servers
├── .env.template          # Environment variables (no values)
├── sandbox.yml            # Sandbox spec
├── Dockerfile             # Container image
├── sync.sh                # Sync script
└── README.md

Every directory is optional. The framework applies what's there, skips what's not.

Commands

Setup (recommended)

Command Description
mf setup --dev Full dev machine setup (provision + apply)
mf setup --prod Production server setup (provision only)

Provisioning (advanced)

Command Description
mf provision Provision a VPS (dev mode, default)
mf provision --mode prod Provision a production server
mf provision --dry-run Preview without executing

Configuration (advanced)

Command Description
mf apply Apply dev config to current machine
mf apply --dry-run Preview without applying
mf apply --host user@host Apply to remote machine
mf capture Scan current machine → generate config
mf diff Show differences between machine and config
mf sync Sync config between machines

Project management

Command Description
mf new [name] Create a new config repo
mf init <url> Clone an existing config repo

Fleet (machine groups)

Command Description
mf fleet create <name> Create a new fleet
mf fleet create <name> --boax Create a fleet with boax pool registration
mf fleet list List all fleets
mf fleet show <name> Show fleet details and machines
mf fleet add <fleet> <name> Add a machine to a fleet
mf fleet remove <fleet> <name> Remove a machine from a fleet
mf fleet apply <fleet> Apply config to all machines in a fleet
mf fleet sync <fleet> Sync config across all machines in a fleet
mf fleet status <fleet> Show health status of fleet machines
mf fleet diff <fleet> Compare all machines in a fleet vs config
mf fleet diff <fleet> Compare all machines in a fleet vs config

Chat sync (agent conversations)

Command Description
mf chats pull [fleet] Pull chat sessions from all reachable fleet machines (idempotent)
mf chats push [fleet] Push local chat sessions to all reachable fleet machines
mf chats status [fleet] Show chat sync status per machine
mf chats list List all chat sessions across agents (ZCode, OpenCode)
mf chats daemon start Start the chat sync daemon (MinIO + Litestream)
mf chats daemon stop Stop the chat sync daemon
mf chats daemon status Show daemon status

Chat sync is peer-to-peer: every machine is a full replica. No single point of failure. Uses MinIO for storage and Litestream for real-time SQLite replication. Supported agents: ZCode, OpenCode (extensible to others).

Security & SSH

Command Description
mf harden Apply security hardening
mf audit Run security audit
mf recover Emergency recovery
mf ssh verify SSH health check
mf deadman arm 5 Arm deadman timer

MCP

Command Description
mf mcp list List MCP servers
mf mcp add SERVER Add MCP server
mf mcp apply Apply MCP config to agents
mf mcp test SERVER Test MCP server

Secrets

Command Description
mf secrets status Show secrets backend status
mf secrets status --mode=personal Show Bitwarden status
mf secrets setup Set up Infisical (self-host or cloud)
mf secrets setup --self-host Self-host Infisical via Docker Compose
mf secrets login Login to Infisical interactively
mf secrets identity-create Save machine identity to credentials file
mf secrets set KEY=val Set secret in Infisical
mf secrets get KEY Get secret from Infisical
mf secrets export Export all secrets as .env
mf secrets --mode=personal unlock Unlock Bitwarden vault
mf secrets --mode=personal get ITEM Get item from Bitwarden

Utilities

Command Description
mf doctor Diagnose issues
mf status Show system status
mf version Print version
mf update Check for updates

OS support

Multi-OS via lib/os/<family>.sh modules:

  • macOS (Darwin) — Homebrew, mise, MAS apps
  • Debian/Ubuntu (apt) — fully implemented
  • Fedora/RHEL/CentOS (dnf) — partial
  • Arch (pacman) — partial
  • Alpine (apk) — partial

Adding a new OS is just adding a new file that implements the standard interface.

Environments

Like Rails, mainframe supports multiple environments:

  • mf apply — dev environment (default)
  • mf apply --env=prod — production environment
  • INFISICAL_ENV=prod mf apply — via env var

The environment determines which secrets are fetched from Infisical (dev vs prod), which packages are installed, and which hardening is applied.

Modes

  • dev (default): Interactive, relaxed firewall, dev tools installed
  • prod: Hardened, tailscale-only, no public ports, k3s-ready

Machine Identity (for VPS/CI)

For non-interactive secret access (VPS, CI/CD):

mf secrets identity-create

This saves credentials to ~/.config/mainframe/infisical.env (mode 600). mf apply auto-loads this file. No manual env vars needed.

Secrets Architecture

Two tiers, cleanly separated:

Tier Backend Used By In mainframe.yml
Machine Infisical mf apply, VPS, CI/CD Yes
Personal Bitwarden/1Password Humans only No

Machine secrets (SSH keys, API tokens, env vars) live in Infisical. Personal secrets (web logins, credit cards) live in Bitwarden. mf manages Infisical; Bitwarden is a convenience wrapper.

Secrets

Secrets are never stored in the config repo. They're referenced by name and fetched from Infisical at apply time. Infisical is the only secrets backend.

Supported backends: Infisical (self-hosted or cloud).

License

MIT


Role boundaries: mf · boax · any

The Anywaye stack has three tools and each answers exactly one question. Before adding a feature, check the table: if a change makes mf answer another tool's question, extend the owner instead.

Tool The only question it answers Verb
mf What should machine X look like, and is it converged? converges
boax Where does untrusted work execute, and how is that world created and destroyed? isolates
any What work is being done, and how does it complete and merge back? orchestrates

mf is the control plane for machines. Its duties stop at: converge host state, publish box specs, declare fleet membership, replicate persistent state (chats), and hold the secrets mesh. It never creates boxes (boax's job), never runs or schedules agent work (any's job), and never executes inside sandboxes.

Contracts

  1. mf publishes → boax consumes. The box spec — base image, packages, provision script, agent skills/MCP — lives here in the mf config repo and is published to boax as templates + profiles. sandbox.yml + sync.sh are the source of truth for what an agent box contains; boax config carries only a projection of it. Host installs (mf apply) configure the user's own interactive agent environment; box provisioning consumes the same artifacts — same source, two consumers, not duplication.
  2. mf fleet declares box hosts. fleet/*.yml says which machines accept sandboxes; hosts enroll via boax setup / devhost BYOC. mf does not place or schedule anything.
  3. Secrets: mf owns the store and trust (age mesh, peer-synced). Consumers (boax per-box injection, any run declarations) receive scoped credentials — never the whole store.
  4. Chats: mf replicates persistent host agent state across the fleet. Run transcripts are any artifacts on the host rollout; mf carries them, but boxes hold no synced chat state.

The invariant

Only boax deletes boax-managed paths. mf's destructive steps (mf apply steps, snapshot rotation) are human-gated, dry-run by default, restricted to an explicit allowlist, and may never be invoked by an agent or a run. Nothing in mf may name a real user home as a disposable path.

(This section is intentionally duplicated across the mf, boax, and any READMEs so the boundary is visible from whichever repo you are working in. Keep the copies in sync.)

About

A secure, reproducible VPS bootstrap for developers

Resources

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages