[PR #329] [MERGED] cargo horizon-mod: new, build and run Horizon mods #2496

Closed
opened 2026-11-02 15:56:42 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/329
Author: @ludovic111
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/15/2026
Merged by: @ludovic111

Base: main ← Head: feat/cargo-horizon-mod


📝 Commits (2)

  • b3906d8 Horizon mods runtime: load sandboxed WebAssembly components with wasmtime
  • 0248df4 cargo horizon-mod: new, build and run Horizon mods

📊 Changes

16 files changed (+2182 additions, -17 deletions)

View changed files

📝 .github/workflows/ci.yml (+1 -1)
📝 Cargo.lock (+798 -15)
📝 Cargo.toml (+1 -1)
➕ crates/cargo-horizon-mod/Cargo.toml (+14 -0)
➕ crates/cargo-horizon-mod/src/main.rs (+201 -0)
➕ crates/cargo-horizon-mod/template/Cargo.toml.in (+14 -0)
➕ crates/cargo-horizon-mod/template/gitignore (+1 -0)
➕ crates/cargo-horizon-mod/template/horizon-mod.toml (+12 -0)
➕ crates/cargo-horizon-mod/template/src/lib.rs (+19 -0)
➕ crates/horizon-mods/Cargo.toml (+30 -0)
➕ crates/horizon-mods/src/lib.rs (+14 -0)
➕ crates/horizon-mods/src/manifest.rs (+276 -0)
➕ crates/horizon-mods/src/runtime.rs (+498 -0)
➕ crates/horizon-mods/tests/guest/Cargo.toml (+16 -0)
➕ crates/horizon-mods/tests/guest/src/lib.rs (+44 -0)
➕ crates/horizon-mods/tests/sandbox.rs (+243 -0)

📄 Description

What

Part 3 of the mod foundation (design: #326; stacked on #328).
crates/cargo-horizon-mod, the authoring tool:

  • cargo horizon-mod new <path> [--name N] [--sdk-path DIR]: a mod crate from template/ (cdylib, horizon-mod-sdk as a git dependency, size-optimized release, a /hello mod, a commented manifest). Never overwrites.
  • cargo horizon-mod build [--debug]: cargo build --target wasm32-unknown-unknown, wraps the module into a component (wit-component), checks its imports against the manifest's capabilities before writing, writes target/horizon-mod/<id>.hmod atomically (a running game never reads half a file).
  • cargo horizon-mod run [--game PATH] [-- args]: build, then start horizon-client --dev-mod <hmod> (the flag lands in the next PR); rebuilding reloads it in the game.
  • horizon-mods gains component_imports (pack feature) for that check.

How tested

new + build end to end in a temp dir (10.7 KB .hmod); removing chat from the template's capabilities makes build fail with uses capability chat, missing from horizon-mod.toml; unit test: the template is a valid mod and new refuses an existing path.

cargo fmt --all -- --check                             ok
cargo clippy --workspace --all-targets -- -D warnings  ok
cargo test -p cargo-horizon-mod -p horizon-mods        ok

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/329 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/15/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/cargo-horizon-mod` --- ### 📝 Commits (2) - [`b3906d8`](https://github.com/horizon-rust/horizon/commit/b3906d803d9e082f89b6cebc1f2b7eb4389f0e84) Horizon mods runtime: load sandboxed WebAssembly components with wasmtime - [`0248df4`](https://github.com/horizon-rust/horizon/commit/0248df4d9019b42e465425c50289d31b473558ff) cargo horizon-mod: new, build and run Horizon mods ### 📊 Changes **16 files changed** (+2182 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/ci.yml` (+1 -1) 📝 `Cargo.lock` (+798 -15) 📝 `Cargo.toml` (+1 -1) ➕ `crates/cargo-horizon-mod/Cargo.toml` (+14 -0) ➕ `crates/cargo-horizon-mod/src/main.rs` (+201 -0) ➕ `crates/cargo-horizon-mod/template/Cargo.toml.in` (+14 -0) ➕ `crates/cargo-horizon-mod/template/gitignore` (+1 -0) ➕ `crates/cargo-horizon-mod/template/horizon-mod.toml` (+12 -0) ➕ `crates/cargo-horizon-mod/template/src/lib.rs` (+19 -0) ➕ `crates/horizon-mods/Cargo.toml` (+30 -0) ➕ `crates/horizon-mods/src/lib.rs` (+14 -0) ➕ `crates/horizon-mods/src/manifest.rs` (+276 -0) ➕ `crates/horizon-mods/src/runtime.rs` (+498 -0) ➕ `crates/horizon-mods/tests/guest/Cargo.toml` (+16 -0) ➕ `crates/horizon-mods/tests/guest/src/lib.rs` (+44 -0) ➕ `crates/horizon-mods/tests/sandbox.rs` (+243 -0) </details> ### 📄 Description ## What Part 3 of the mod foundation (design: #326; stacked on #328). `crates/cargo-horizon-mod`, the authoring tool: - `cargo horizon-mod new <path> [--name N] [--sdk-path DIR]`: a mod crate from `template/` (cdylib, horizon-mod-sdk as a git dependency, size-optimized release, a `/hello` mod, a commented manifest). Never overwrites. - `cargo horizon-mod build [--debug]`: `cargo build --target wasm32-unknown-unknown`, wraps the module into a component (wit-component), checks its imports against the manifest's capabilities **before** writing, writes `target/horizon-mod/<id>.hmod` atomically (a running game never reads half a file). - `cargo horizon-mod run [--game PATH] [-- args]`: build, then start `horizon-client --dev-mod <hmod>` (the flag lands in the next PR); rebuilding reloads it in the game. - `horizon-mods` gains `component_imports` (pack feature) for that check. ## How tested `new` + `build` end to end in a temp dir (10.7 KB .hmod); removing `chat` from the template's capabilities makes `build` fail with `uses capability chat, missing from horizon-mod.toml`; unit test: the template is a valid mod and `new` refuses an existing path. ``` cargo fmt --all -- --check ok cargo clippy --workspace --all-targets -- -D warnings ok cargo test -p cargo-horizon-mod -p horizon-mods ok ``` 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:56:42 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2496
No description provided.