agentleFS
web3infra-foundationweb3infra-foundation/mega/.github/copilot-instructions.md

mega

Copilot instructions522 starsChanged 21 months agoApache-2.0View on GitHub

Mega is an unofficial open-source implementation of Google Piper: a monorepo/monolithic codebase management system with Git compatibility, FUSE mounting, and Buck2 integration. When proposing designs or code, optimize for very large repos, content-addressed storage, and Git internals (packfiles, MIDX, commit-graph, delta chains). License is Apache-2.0 + MIT; keep new files compatible with both. See docs/architecture.md for the full workspace map. Note: Scorpio (FUSE implementation) has been moved to https://github.com/web3infra-foundation/scorpiofs For FUSE-related development, refer to the scorpiofs repository.

We split this copilot-instructions.md into the rules it gives an agent

24 rules. About 1 is common, 21 are distinctive, and 2 are very specific to this project.

  • ≈1

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈21

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Prefer Rust (Edition 2021+).

    line 9
  2. Distinctive:

    Avoid unsafe unless there’s a measurable win (perf or FFI).

    line 11
  3. Distinctive:

    When generating commands, prefer:

    line 19
  4. Common:

    Treat clippy warnings as errors for new/changed code.

    line 45
  5. Distinctive:

    Prefer iterator and slice APIs to heap-allocating vectors in hot paths.

    line 47
  6. Distinctive:

    When dealing with Git objects/packs, consider delta-chain depth, fanout tables, OID (SHA-1 vs SHA-256), and zstd/deflate trade-offs.

    line 52
  7. Distinctive:

    Write unit + integration + property tests.

    line 67
  8. Distinctive:

    Add concurrency tests (Tokio multi-task) where IO/state is involved.

    line 68
  9. Distinctive:

    Prefer hermetic tests with temp dirs.

    line 69
  10. Distinctive:

    Use tracing spans/fields; do not log secrets.

    line 73
  11. Distinctive:

    No plaintext secrets, keys, or tokens in code or tests.

    line 78
  12. Distinctive:

    Default to Rustls for TLS.

    line 79
  13. Distinctive:

    Keep third-party code in third-party/ with license notices.

    line 80
  14. Distinctive:

    Add module-level docs (//!) and public item docs (///) for all public items.

    line 84
  15. Distinctive:

    Use present tense (e.g., "Add feature X" not "Added feature X").

    line 95
  16. Distinctive:

    Keep lines under 72 characters.

    line 96
  17. Distinctive:

    When the user asks for code, emit Rust first, then Buck2 snippets/macros if relevant.

    line 101
  18. Distinctive:

    When suggesting design options, list trade-offs (perf, memory, portability, compatibility with Git).

    line 102
  19. Distinctive:

    Prefer minimal, composable abstractions.

    line 103
  20. Distinctive:

    Do not recommend migrating away from Git without explicit request.

    line 107
  21. Distinctive:

    Do not propose language rewrites away from Rust unless integrating with existing systems.

    line 108
  22. Very specific:

    DO:: When generating code, provide solutions in Rust for backend/core logic and TypeScript for frontend/tooling/SDKs.

    line 113
  23. Distinctive:

    DO:: Ensure all commit message examples adhere to the Conventional Commits standard.

    line 114
  24. Very specific:

    DO:: When asked about building or testing, refer to the Buck2 build system.

    line 115

≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

Mega – Repository Custom Instructions for GitHub Copilot

What this repo is

Mega is an unofficial open-source implementation of Google Piper: a monorepo/monolithic codebase management system with Git compatibility, FUSE mounting, and Buck2 integration. When proposing designs or code, optimize for very large repos, content-addressed storage, and Git internals (packfiles, MIDX, commit-graph, delta chains). License is Apache-2.0 + MIT; keep new files compatible with both.

Languages & defaults

  • Prefer Rust (Edition 2021+). Use async/await with Tokio, and structured logging with tracing.
  • Serialization: serde; CLI: clap; errors: thiserror (library) and anyhow (bin/tests/tools).
  • Avoid unsafe unless there’s a measurable win (perf or FFI). If unsafe is required, add a // SAFETY: rationale comment and tests.
  • For small utilities, you may use Python or Bash, but default to Rust when feasible.

Build & run

  • Primary build: Buck2. Provide buck2 rules/macros and examples when adding code or docs.
  • Crate local build: cargo build -p <crate> is welcomed for dev loops; ensure parity with Buck2 rules.
  • When generating commands, prefer:
buck2 build //... for CI-style full builds
buck2 test //... for tests
cargo nextest run -p <crate> when suggesting fast local test runs

Key Components (Modules)

CrateRole
monoServer binary (HTTP REST, Git HTTP/SSH, Swagger)
ceresDomain library: transport, application, HTTP DTOs
jupiter / callistoStorage and SeaORM entities
jupiter-migrateDatabase migrations
orion / orion-server / orion-schedulerBuild orchestration
saturnCedar policy
vaultCrypto and secrets
moonFrontend (TypeScript)

See docs/architecture.md for the full workspace map.

Coding style & quality

  • Run rustfmt defaults.
  • Treat clippy warnings as errors for new/changed code; prefer #[must_use], #[deny(unsafe_op_in_unsafe_fn)] where appropriate.
  • Return Result<T, E>; avoid unwrap()/expect() in library code except in tests or when invariant-proofed and documented.
  • Prefer iterator and slice APIs to heap-allocating vectors in hot paths. Use SmallVec, bytes, or no_std-friendly patterns when beneficial.

Performance & memory

  • Mega targets huge repos; prioritize O(n) single-pass algorithms, streaming IO, mmap when safe, and bounded allocations.
  • When dealing with Git objects/packs, consider delta-chain depth, fanout tables, OID (SHA-1 vs SHA-256), and zstd/deflate trade-offs. Include micro-benchmarks for hot paths via criterion.

Filesystems & FUSE

Note: Scorpio (FUSE implementation) has been moved to https://github.com/web3infra-foundation/scorpiofs

For FUSE-related development, refer to the scorpiofs repository.

API & CLI guidelines

  • Public APIs: lean toward stable, versioned boundaries; avoid leaking internal pack/layout details unless clearly documented.
  • CLI should default to safe, read-only modes for destructive commands; provide --dry-run and --json where reasonable.

Testing

  • Write unit + integration + property tests. Use proptest for object/pack fuzzing, and insta for snapshots when output is textual.
  • Add concurrency tests (Tokio multi-task) where IO/state is involved.
  • Prefer hermetic tests with temp dirs; avoid network unless explicitly required.

Observability & errors

  • Use tracing spans/fields; do not log secrets.
  • Provide actionable error messages (context via anyhow::Context), and map OS/IO errors precisely.

Security & compliance

  • No plaintext secrets, keys, or tokens in code or tests.
  • Default to Rustls for TLS; avoid new C FFI unless justified.
  • Keep third-party code in third-party/ with license notices; check compatibility with Apache-2.0/MIT.

Documentation

  • Add module-level docs (//!) and public item docs (///) for all public items.
  • For complex algorithms (e.g., pack rewriter, multi-pack-index), include a short overview, invariants, and example.
  • English comments preferred; Chinese allowed for tricky parts (bilingual welcome).

Git workflow

We favor Trunk-Based Development and Conventional Commits.

Commit messages

  • Concise imperative subject; body explains why and outlines bench/test evidence.
  • Use present tense (e.g., "Add feature X" not "Added feature X").
  • Keep lines under 72 characters.
  • Reference issues/PRs liberally (e.g., "Fix #123" or "Add feature X (#123)").

How to talk back to us (Copilot prompts)

  • When the user asks for code, emit Rust first, then Buck2 snippets/macros if relevant.
  • When suggesting design options, list trade-offs (perf, memory, portability, compatibility with Git).
  • Prefer minimal, composable abstractions; avoid premature global singletons.

Non-goals

  • Do not recommend migrating away from Git without explicit request.
  • Do not propose language rewrites away from Rust unless integrating with existing systems.

How to Assist Developers (Guidelines for Copilot)

  • DON'T: Propose language rewrites away from Rust unless integrating with existing systems.
  • DO: When generating code, provide solutions in Rust for backend/core logic and TypeScript for frontend/tooling/SDKs.
  • DO: Ensure all commit message examples adhere to the Conventional Commits standard.
  • DO: When asked about building or testing, refer to the Buck2 build system. Avoid suggesting root-level cargo or npm commands unless they are specific to a sub-package.
  • DON'T: Confuse this project with "mega.nz" (the cloud storage service) or other projects named "Mega." This project is "mega" for version control infrastructure.
  • DO: Point users to CONTRIBUTING.md for contribution guidelines and setup instructions.

Download now (ZIP)

  • Other versions1 project uses a version of this.

    Word for word · 1

    1. gitmono-dev/mega★ 517100% same

    Edited · 0

    None found.

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.

    Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.