Skip to content

Latest commit

 

History

History
120 lines (72 loc) · 6.65 KB

File metadata and controls

120 lines (72 loc) · 6.65 KB

Mega — Monorepo Infrastructure for the AI Agent Era

Mega is an open-source implementation of Google Piper — a Git-compatible monorepo engine built for AI-native engineering workflows. Written entirely in Rust, Mega is designed to manage petabyte-scale codebases while serving as the infrastructure backbone for AI coding agents.

Why Mega?

AI coding agents are becoming first-class participants in software engineering. But today's version control systems were designed for human developers working in isolated branches — they lack the unified context, structured metadata, and programmatic interfaces that agents need to operate reliably at scale.

Monorepos solve the context problem. When an agent can see the entire codebase — dependencies, downstream consumers, build targets, and test coverage — it makes better decisions, produces fewer hallucinations, and delivers atomic cross-project changes in a single commit.

Mega brings Google-scale monorepo infrastructure to the open-source world, purpose-built for the agentic future.

Mega + Libra: Version Control for Agents

Mega works together with Libra, our Rust-based, Git-compatible client with SQLite-backed storage, to provide a complete version control workflow where AI agents are tracked, attributable contributors:

  • Mega (server-side) — The centralized monorepo engine. Manages code at scale with full codebase context, trunk-based development, and fine-grained access control. Provides the global visibility that agents need for dependency analysis, impact assessment, and cross-project reasoning.
  • Libra (agent-side) — A lightweight, embeddable Git client optimized for programmatic access. Agents use Libra to clone, commit, and push with structured metadata and intent tracking — no shell-out to git required.

Together, they enable a new paradigm: from intent to merge, every agent action is versioned, attributed, and traceable.

Features

Git Compatible

Mega offers full Git protocol support with a monorepo. Clone or pull any folder in the monorepo into your local filesystem as a standard Git repository, and seamlessly push changes back. Both human developers and AI agents interact through the same familiar Git interface.

Trunk-Based Development

Large-scale codebases thrive on trunk-based development — a single source of truth, continuous integration, and short-lived branches. This model is especially critical for AI agents, which benefit from always operating against the latest, consistent state of the codebase. Learn more at Trunk-Based Development.

Conventional Commits

Mega supports Conventional Commits, enabling both humans and agents to produce structured, machine-readable commit messages that power automated changelogs, semantic versioning, and audit trails.

Scorpio — FUSE Filesystem for Monorepo

Scorpio is a FUSE filesystem that mounts any monorepo folder as a local filesystem. Developers and agents work with their codebase as if it were local, while Mega handles the scale underneath — no need to check out the entire repository.

Buck2 Integration

Mega integrates Buck2 as its default build system. Developed by Meta in Rust, Buck2 enables declarative, reproducible, and highly parallelized builds — essential for maintaining build correctness across a monorepo that both humans and agents contribute to simultaneously.

Roadmap

Mega is evolving toward deeper AI-native capabilities:

  • IntentSpec — A structured, machine-readable intent contract that drives agent task execution with security policies and provenance binding.
  • Multi-Agent DAG Orchestration — Pipeline architecture for coordinating multiple AI agents across complex, multi-step code generation workflows.
  • Code Attribution — Line-level tracking of AI-generated vs. human-written code, enabling auditability and trust in agent contributions.

Quick Start

To facilitate a rapid deployment and hands-on experience with the Mega service, the following instructions are derived from the project's documentation.

Community

Discord Channel - https://discord.gg/HMFuu6pJmQ

Contributing

The mega project relies on community contributions and aims to simplify getting started. To develop Mega, clone the repository, then install all dependencies and initialize the database schema, run the test suite and try it out locally. Pick an issue, make changes, and submit a pull request for community review.

Pre-submission Checks

Before submitting a Pull Request, please ensure your code passes the following checks:

# Run clippy with all warnings treated as errors (warnings will be treated as errors)
cargo clippy --all-targets --all-features -- -D warnings

# Check code formatting (requires nightly toolchain)
cargo +nightly fmt --all --check

Both commands must complete without any warnings. The clippy check treats all warnings as errors, and the formatter check ensures code follows the project style guide. Only PRs that pass these checks will be accepted for merge.

If the formatting check fails, you can automatically fix formatting issues by running:

cargo +nightly fmt --all

Buck2 Build Requirements

This project builds with Buck2. Please install both Buck2 and cargo-buckal before development:

# Install buck2: download the latest release tarball from
# https://github.com/facebook/buck2/releases, extract the binary,
# and place it in ~/.cargo/bin (ensure ~/.cargo/bin is on PATH).
# Example (replace <tag> and <platform> with the latest for your OS):
wget https://github.com/facebook/buck2/releases/download/<tag>/buck2-<platform>.tar.gz
tar -xzf buck2-<platform>.tar.gz
mv buck2 ~/.cargo/bin/

# Install cargo-buckal (requires Rust toolchain)
cargo install --git https://github.com/buck2hub/cargo-buckal.git

Pull Requests must also pass the Buck2 build:

cargo buckal build

When you update dependencies in Cargo.toml, regenerate Buck metadata and third-party lockfiles:

cargo buckal migrate

More information on contributing to Mega is available in the Contributing Guide.

License

Mega is licensed under this License: