An open-source, trunk-based monorepo storage and Git hosting server written in Rust, with Git Smart HTTP, Git LFS, an OCI container registry, build-artifact storage, and Agent Session Capture.
English · 中文
The first-generation Mega established the foundation for our monorepo and Git-hosting platform. Mega2 is the second-generation engine built for AI agents, with two core capabilities: a Monorepo engine and Agent Session Capture.
The open-source edition of Mega2 runs in trunk / storage-only mode and does not include a Web UI or Change List. Mega2 provides the server-side monorepo storage and APIs; Libra provides a terminal interface for interactive browsing.
Start with the Quick Start, then see the documentation index for user, operator, and contributor guides. Repository and push behavior is covered in the User Guide; contribution checks are in the Contributing Guide.
| Item | Details |
|---|---|
| What it is | Monorepo engine and Git hosting server for AI agents |
| Website | gitmega.ai |
| Language | Rust (edition 2024), a single Cargo package mega2 |
| Mode | Trunk / storage-only: refs/heads/main is the public trunk |
| Protocols and interfaces | Git Smart HTTP, read-only SSH, Git LFS, OCI Distribution (/v2), HTTP API |
| API docs | OpenAPI: /api/openapi.json; Swagger UI: /swagger-ui |
| Storage | Postgres for metadata; local filesystem or S3-compatible object storage for Git objects, LFS, artifacts, and images |
| Image | Docker Hub genedna/mega2, default HTTP port 9000 |
| Not included | Web UI, Change List, multi-branch monorepo workflows |
| Companion tools | Libra (agent-side version control and terminal browser), ScorpioFS (monorepo filesystem mount) |
| License | MIT OR Apache-2.0 |
The best practice for agent-oriented monorepo development is to use Mega2 + ScorpioFS + Libra together:
- Mega2 provides centralized monorepo storage and hosting, with optional Agent Session Capture.
- ScorpioFS mounts remote monorepo paths as a local filesystem for development tools and agents to browse.
- Libra provides agent-side version-control workflows and a terminal browser for Mega2.
Use libra mega2 browser --server https://mega2.example.com to browse a remote monorepo. The terminal interface displays one directory level at a time, supports creating, deleting, moving, and renaming directories, and has a Tag panel for listing, creating, and deleting root tags; write credentials are required to create or delete tags. This command reads remote tree data; it does not run Git clone, fetch, or push. See Using Mega2 with Libra.
Mega2 provides trunk-based Git storage and hosting for monorepos. Regular Monorepo paths expose refs/heads/main as the public trunk; Git clients cannot push other branches or tags. Use the HTTP API or Libra's terminal browser for supported Tag and directory operations. The open-source edition does not include the multi-branch Change List feature.
Git metadata is stored in Postgres, while Git objects live in local or S3-compatible object storage. ImportRepos under [monorepo].import_dir (default /third-party) follow ordinary Git semantics, including multiple branches and client-managed tags, and can hold third-party repositories that need independent synchronization. ImportRepos accept later pushes (branches and tags) and can be removed through POST /api/v1/import-repo/remove (which needs a push token; push_auth=none deployments run mega2 import-repo remove on the server instead); see ImportRepo lifecycle. See Monorepo path policy and first use for path provisioning and push rules.
Agent Session Capture is an optional HTTP capability, separate from Git push. When enabled with [agent_capture].enabled=true and an ingest token in a storage-only deployment, Mega2 can capture agent sessions, events, checkpoints, file operations, and transcript data for later querying, review, and audit. Git branch and receive-pack rules do not govern this API. See the Configuration Guide for setup.
- Git and large files: Git Smart HTTP supports clone, fetch, pull, and push; SSH is read-only in storage-only mode; Git LFS is supported.
- Build artifacts and OCI: Artifact Sets store build outputs. When
[oci].enabled=true, the/v2endpoint provides an OCI container registry. Git, LFS, Artifact, and OCI data can share object storage. - HTTP API: Read and write monorepo files, directories, and tags. See the User Guide for the API and workflows.
- Security and operations: Push-token authentication, embedded Vault and SecretRef, webhook notifications, and configuration validation, profiles, and controlled hot reload. See the Configuration Guide and Deployment Guide.
The evaluation stack pulls the official release image from Docker Hub (genedna/mega2:latest) — no source build, no bootstrap. Pick the compose file for your platform (they differ in how artifact presigned URLs are made reachable from the host — see the Deployment Guide):
# macOS with OrbStack
docker compose -f macos-orbstack-mega2-compose.yml up -d --wait
# Linux Docker
docker compose -f linux-mega2-compose.yml up -d --waitHTTP: http://127.0.0.1:9000/. This is a local-only anonymous setup (push_auth=none, bound to 127.0.0.1); for token-based or shared deployments see the Deployment Guide and docs/deploy-trunk.md (Chinese). Start and push with the Quick Start, then see Usage Recipes for repository migration, LFS, OCI, and build-artifact examples.
For local development and tests, see the Contributing Guide.
The -v flag deletes data stored in the Docker volumes.
docker compose -f macos-orbstack-mega2-compose.yml down -v # or linux-mega2-compose.ymlFor a large change, follow this process:
- Open an issue. Describe the problem, motivation, scope, and non-goals. Get agreement on the direction before implementation.
- Then write a plan. Copy the structure from the English Plan Template into
docs/plan/plan-YYYYMMDD.md. Do not delete mandatory sections; writeN/Aand the reason when a section does not apply. - Implement only after the plan is reviewed. Split work into task cards, add tests and docs, and pass the submit gates before merge.
A plan is not an implementation. When drafting one, verify assumptions against the current source, tests, config, and docs. Agreements in an issue do not replace the task card's verification commands.
Before submitting code, run:
cargo +nightly fmt --all --check
cargo clippy --all-targets --all-features -- -D warnings
source .env.test && cargo test --allDetails: AGENTS.md, the Contributing Guide, and docs/plan/README.md (Chinese).
| Start here | What it covers |
|---|---|
docs/README.md |
Index of user, operator, and developer documentation |
docs/quick-start.md |
Start the local Compose stack and make your first push |
docs/recipes.md |
Repository migration, LFS, OCI, artifacts, and persistent data |
docs/user-guide.md |
Git, HTTP API, Libra, and CLI usage |
docs/configuration.md |
Config sources, SecretRef, profiles, hot reload, and validation |
docs/deployment.md |
Deploying and hardening a trunk / storage-only service |
docs/architecture.md |
Module boundaries, storage, and the write path |
docs/contributing.md |
Local development, contribution process, code conventions, and integration tests |
Subsystem references and project records are linked from the documentation index.
Mega2 is dual-licensed under MIT and Apache-2.0 (MIT OR Apache-2.0); you may choose either license:
Third-party code copied directly into this repository, if any, is declared in LICENSE-THIRD-PARTY.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project, as defined in the Apache-2.0 license, shall be dual-licensed as above, without any additional terms or conditions.