Use this page to build and submit a change. For behavior-specific reading, use the developer index; for assertions and test boundaries, use Testing.
Install Rust and the MoonBit toolchain. The repository's agent guidelines specify the preferred toolchain channel. Initialize the pinned submodules before development or updating snapshots:
git submodule update --init --recursive
cargo buildFor an installed build, run cargo install --path crates/moon; add --debug
for a faster development build. Cargo installs into its configured binary
directory, which may differ from the MoonBit toolchain's binary directory.
Check which moon your shell resolves before testing an installed build.
| Area | Entry points |
|---|---|
| CLI parsing and command orchestration | moon/src/cli, cli.rs |
| CLI build options and target selection | moon/src/cli/build_flags.rs, target.rs, selection.rs |
moon build package scope and request selection |
moon/src/cli/build/selection.rs |
| Dry-run rendering | moon/src/dry_run.rs |
| Dependency sync and script declaration preparation | moonbuild/src/prepare |
| Package discovery, package resolution, planning, and lowering | moonbuild-rupes-recta/src |
| Build operation and compilation configuration | moonbuild-rupes-recta/src/compile |
| Package identities and import visibility | moonbuild-rupes-recta/src/pkg_name.rs |
| Build sessions, module prebuild, and standalone Wasm compilation | moonbuild/src/compile |
| Build planning and external-input preparation | moonbuild/src/compile.rs |
| Generated package metadata model | moonbuild-rupes-recta/src/metadata.rs |
| Build metadata publication | moonbuild/src/metadata.rs |
| Execution Plans and n2 scheduling | moonbuild/src/execution |
| Compiler diagnostics and source rendering | moonbuild/src/execution/diagnostics.rs, diagnostics/render.rs |
| Test invocation and result reporting | moon/src/run/runtime.rs, run/runtest/report.rs |
| Test result data and expect/snapshot promotion | moon/src/run/runtest.rs, expect.rs |
| Package management and registry access | mooncake/src/pkg, resolver, registry |
| Registry module and package coordinate parsing | mooncake/src/registry/path.rs |
| Module dependency synchronization | mooncake/src/pkg/sync.rs |
| Binary installation commands | moon/src/cli/deps.rs, install_binary.rs |
| Shared package-management CLI and stdin payloads | mooncake/src/cli.rs |
| Module names and name/version validation | moonutil/src/module_name.rs |
| Module sources and resolved dependency graphs | moonutil/src/resolution.rs |
| Package data and JSON schema | moonutil/src/package.rs |
| Manifest loading and in-memory package parsing | moonutil/src/manifest.rs, private package decoding and diagnostics in manifest/package.rs |
| Dependency edits preserving manifest comments | mooncake/src/pkg/manifest_edit.rs |
| Paths, feature flags, and shared types | moonutil/src |
| Wasm runtime | Moonrun developer guide |
| Tests and their support code | Test boundaries and examples |
Start with the affected test using the commands in Testing. Before submitting, run the repository checks:
cargo xtask
cargo test --workspaceOn Linux, the profiling E2E tests require perf with DWARF unwinding support
and permission to record per-process cpu-clock events. The existing Linux CI
test job installs the kernel tools and sets kernel.perf_event_paranoid=1.
cargo xtask checks the test-driver template with Moon, Rust formatting, and
Clippy, using Moonrun's default V8 backend. Optional runtime backends are checked
by their dedicated CI jobs. The exact commands live
in xtask/src/ci.rs. CI also checks spelling with
typos; see the
CI workflow for platform coverage.
Only update expected output for an intentional behavior change or a reviewed test migration. Snapshot review describes how to target an update without rewriting unrelated expectations.
Before submitting, sign the Contributor Copyright Assignment Agreement (CCAA):
- Individuals: sign online.
- Corporations: download the CCAA, sign it, and send it to jichuruanjian@idea.edu.cn.
Follow the repository guidelines and PR template. Explain the problem, why the change is correct, and the boundary of the change.
Keep semi-linear history: rebase the branch onto the latest origin/main, then
merge with a merge commit. On GitHub, choose Update with Rebase when updating
a PR branch. This preserves each PR as a contiguous sequence without merge
commits from branch updates.