[PR #327] [MERGED] Horizon mod SDK: the WIT contract, a Rust SDK and an example mod #2495

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

📋 Pull Request Information

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

Base: main ← Head: feat/mod-sdk


📝 Commits (1)

  • 670e055 Horizon mod SDK: the horizon:mods WIT contract, a Rust SDK and an example mod

📊 Changes

8 files changed (+573 additions, -1 deletions)

View changed files

📝 Cargo.lock (+173 -0)
📝 Cargo.toml (+1 -1)
➕ crates/horizon-mod-sdk/Cargo.toml (+13 -0)
➕ crates/horizon-mod-sdk/examples/coords-hud/Cargo.toml (+16 -0)
➕ crates/horizon-mod-sdk/examples/coords-hud/horizon-mod.toml (+8 -0)
➕ crates/horizon-mod-sdk/examples/coords-hud/src/lib.rs (+124 -0)
➕ crates/horizon-mod-sdk/src/lib.rs (+141 -0)
➕ crates/horizon-mod-sdk/wit/horizon.wit (+97 -0)

📄 Description

What

Part 1 of the mod foundation (design: #326).

  • crates/horizon-mod-sdk/wit/horizon.wit: the contract, package horizon:mods@0.1.0. Imports: log (always), game (capability game-read: player and clock), chat (show a line), hud (a retained panel). Export: events (init returning a registration of commands and wanted hooks, tick, frame, command, chat).
  • horizon-mod-sdk: wit-bindgen bindings, a Mod trait with default hooks, Registration builder, export_mod! keeping the mod's state.
  • Example coords-hud: coordinates, facing (Direction.fromYRot) and day/time in the top-left; /where puts the position in chat, /coords hides/shows the panel. 64 KB of wasm.

Guest side only: nothing in the game changes. Next PRs: runtime, cargo horizon-mod, the game.

How tested

cargo build -p coords-hud --target wasm32-unknown-unknown --release; coords-hud unit tests (facing, clock); loaded and run by the runtime's tests in the next PR and in the game (screenshots there).

cargo fmt --all -- --check                                  ok
cargo clippy --workspace --all-targets -- -D warnings       ok
cargo test -p horizon-mods -p horizon-mod-sdk -p coords-hud -p cargo-horizon-mod   ok (sandbox: 6 passed)
cargo test -p horizon-client                                ok (655 + 41 + 15 + ... passed)

🤖 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/327 **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/mod-sdk` --- ### 📝 Commits (1) - [`670e055`](https://github.com/horizon-rust/horizon/commit/670e055f4a0dcf7485eeaac313d3c6157c9b2c65) Horizon mod SDK: the horizon:mods WIT contract, a Rust SDK and an example mod ### 📊 Changes **8 files changed** (+573 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `Cargo.lock` (+173 -0) 📝 `Cargo.toml` (+1 -1) ➕ `crates/horizon-mod-sdk/Cargo.toml` (+13 -0) ➕ `crates/horizon-mod-sdk/examples/coords-hud/Cargo.toml` (+16 -0) ➕ `crates/horizon-mod-sdk/examples/coords-hud/horizon-mod.toml` (+8 -0) ➕ `crates/horizon-mod-sdk/examples/coords-hud/src/lib.rs` (+124 -0) ➕ `crates/horizon-mod-sdk/src/lib.rs` (+141 -0) ➕ `crates/horizon-mod-sdk/wit/horizon.wit` (+97 -0) </details> ### 📄 Description ## What Part 1 of the mod foundation (design: #326). - `crates/horizon-mod-sdk/wit/horizon.wit`: the contract, package `horizon:mods@0.1.0`. Imports: `log` (always), `game` (capability game-read: player and clock), `chat` (show a line), `hud` (a retained panel). Export: `events` (init returning a registration of commands and wanted hooks, tick, frame, command, chat). - `horizon-mod-sdk`: wit-bindgen bindings, a `Mod` trait with default hooks, `Registration` builder, `export_mod!` keeping the mod's state. - Example `coords-hud`: coordinates, facing (Direction.fromYRot) and day/time in the top-left; `/where` puts the position in chat, `/coords` hides/shows the panel. 64 KB of wasm. Guest side only: nothing in the game changes. Next PRs: runtime, `cargo horizon-mod`, the game. ## How tested `cargo build -p coords-hud --target wasm32-unknown-unknown --release`; coords-hud unit tests (facing, clock); loaded and run by the runtime's tests in the next PR and in the game (screenshots there). ``` cargo fmt --all -- --check ok cargo clippy --workspace --all-targets -- -D warnings ok cargo test -p horizon-mods -p horizon-mod-sdk -p coords-hud -p cargo-horizon-mod ok (sandbox: 6 passed) cargo test -p horizon-client ok (655 + 41 + 15 + ... passed) ``` 🤖 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:40 +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#2495
No description provided.