[PR #1901] [MERGED] Mod API 0.3: typed server commands, in players' command trees #3852

Closed
opened 2026-11-03 04:12:47 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: feat/server-mods-commands


📝 Commits (6)

  • c5bb51b Mod API 0.3: typed server commands, in players' command trees
  • 574d65a stability.md: server mods' row names world and typed commands
  • 121731f Merge branch 'feat/server-mods-world' into feat/server-mods-commands
  • c5534f0 Merge remote-tracking branch 'origin/main' into feat/server-mods-commands
  • 4fe8f71 Merge remote-tracking branch 'origin/main' into feat/server-mods-commands
  • 55cc847 Merge remote-tracking branch 'origin/main' into feat/server-mods-commands

📊 Changes

21 files changed (+927 additions, -109 deletions)

View changed files

📝 crates/cargo-horizon-mod/src/check.rs (+1 -1)
📝 crates/horizon-client/src/game/mods.rs (+4 -1)
📝 crates/horizon-client/src/game/server_mods.rs (+73 -1)
📝 crates/horizon-client/src/lan/commands.rs (+53 -10)
📝 crates/horizon-client/src/lan/hub.rs (+28 -1)
📝 crates/horizon-mod-sdk/examples/beacons/horizon-mod.toml (+1 -1)
📝 crates/horizon-mod-sdk/examples/beacons/src/lib.rs (+31 -15)
📝 crates/horizon-mod-sdk/examples/beacons/tests/beacons.toml (+18 -1)
📝 crates/horizon-mod-sdk/examples/welcome/src/lib.rs (+16 -9)
📝 crates/horizon-mod-sdk/examples/welcome/tests/commands.toml (+16 -1)
📝 crates/horizon-mod-sdk/src/lib.rs (+127 -8)
📝 crates/horizon-mod-sdk/wit/horizon.wit (+58 -10)
➕ crates/horizon-mods/src/commands.rs (+301 -0)
📝 crates/horizon-mods/src/lib.rs (+2 -0)
📝 crates/horizon-mods/src/runtime.rs (+98 -24)
📝 crates/horizon-mods/src/testing.rs (+1 -1)
📝 crates/horizon-mods/tests/sandbox.rs (+7 -5)
📝 docs/api/mods-reference.md (+53 -10)
📝 docs/api/mods.md (+7 -4)
📝 docs/api/stability.md (+1 -1)

...and 1 more files

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Stacked on #1895 (capability world), itself on #1894. This PR's own diff is its last commit (20 files, +922 −107).

What

Server mods (API 0.3, experimental) declare typed arguments for their commands. The server parses them with vanilla's messages, and players' clients get them in the command tree, so chat completes and hints them like a vanilla command.

  • WIT: argument-kind (word, text, integer(min, max), number, boolean, player, block-pos), argument { name, kind, optional }, server-command { name, arguments }. The command hook gets the parsed values by name.
  • Parsing (horizon-mods/src/commands.rs): ~ ~1 ~ relative to the player, an online player's name or @s, integer bounds, a missing or extra argument. A failure answers the player in red with vanilla's text ("Integer must not be more than 64, found 99", "No player was found", "Incorrect argument for command"), and the mod isn't called.
  • Checked at load: names [A-Za-z0-9_], distinct, only the last ones optional, text last.
  • Command tree: CommandTree::packet_with grafts the mods' commands under the root as Brigadier nodes (brigadier:string word/greedy, brigadier:integer with min/max, brigadier:double, brigadier:bool, minecraft:entity single player, minecraft:block_pos). The hub resends the tree when Mods::generation() changes (start, stop, reload). Server thread, LAN and dedicated.
  • SDK: Registration::command_with(name, [Argument::integer("height", 1, 64).optional()]) and Args (integer, number, string, boolean, player, block_pos, text). command(name) keeps working: free text as one optional text argument.
  • Examples: welcome /mined [player] ("Alex broke 2 block(s)"), beacons /beacon [height 1..64] and /ground [pos] ("X Y Z is minecraft:stone in minecraft:forest", "That block isn't loaded"). Their test scripts cover the new arguments.
  • Docs: docs/mods.md "Typed commands" (the kinds table), docs/api/mods.md changelog, the regenerated reference.

How tested

welcome and beacons built with this branch's cargo horizon-mod build and given as --dev-mod. A scratch driver over horizon-ctl ran each game with fresh HORIZON_HOME, launcher home and XDG folders, and HORIZON_NO_AUDIO=1. 45/45 checks pass in each of: single player on the server thread, --in-frame, LAN with the host in-frame (the guest types), LAN with the host on its server thread, and --dedicated with a guest. They cover a good value, an out-of-range one, a relative position, an unloaded block, a missing player, and the earlier /beacon and /ground checks. Screenshots show the client's chat hint [<height>] after /beacon (server thread and dedicated): the client got the tree.

cargo test -p horizon-mods --features runtime,pack: the parser's 4 unit tests and the sandbox tests, with the scripts. lan::commands test server_mods_commands_follow_vanillas checks the grafted nodes. Clippy is clean with and without mods.

A/B: with no server mod, send_server_mod_commands returns on a generation check and the tree is built as before. #1894 measured the whole server-mods path with no mod: equal within noise.

Self-check: pr_ready --quick on this branch (its scope line counts the whole stack against main):

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 6a065fa48, 26 min 7 s)

Check Result
Scope ⚠️ 41 files, +3948 −191; 3366 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ changes with a Cargo.toml
Public tree ✅
Python tests ➖ no Python change
rustfmt ✅ (14 s)
clippy ✅ (3 min 52 s)
tests: workspace ✅ 2069 passed (17 min 25 s)
doc tests ✅ 2 passed (2 min 1 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ✅ (3 s)
launcher clippy ✅ (1 min 9 s)
launcher tests ✅ 119 passed (1 min 22 s)
Parity ➖ 331 affected, to run in CI (--quick)

Parity: parity.py --changed-files over the whole stack's files (#1894, #1895, #1901) on its top commit c5bb51bb0: 110 passed, 0 failed (42 min, Mac mini).

Label skip-release: experimental API 0.3. Nothing changes for players without a server mod.

Leftovers

  • Kinds not there yet: entity selectors beyond one player, item, block state, ^ ^ ^ local coordinates.
  • In-frame single player (no server thread), the client's chat completion lists a server mod's commands by name only, as before.

🤖 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/1901 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/server-mods-commands` --- ### 📝 Commits (6) - [`c5bb51b`](https://github.com/horizon-rust/horizon/commit/c5bb51bb053a7f41acf7361f831091a7b54ce493) Mod API 0.3: typed server commands, in players' command trees - [`574d65a`](https://github.com/horizon-rust/horizon/commit/574d65a03ca86775593d52472da4b1802f0a7d2a) stability.md: server mods' row names world and typed commands - [`121731f`](https://github.com/horizon-rust/horizon/commit/121731f261c37b00820c439fda69c6f2e61331e3) Merge branch 'feat/server-mods-world' into feat/server-mods-commands - [`c5534f0`](https://github.com/horizon-rust/horizon/commit/c5534f0d7bfac8373e0c83960e7f8b0bb926f5d5) Merge remote-tracking branch 'origin/main' into feat/server-mods-commands - [`4fe8f71`](https://github.com/horizon-rust/horizon/commit/4fe8f71530b64a379702aab288c004b19e3643c8) Merge remote-tracking branch 'origin/main' into feat/server-mods-commands - [`55cc847`](https://github.com/horizon-rust/horizon/commit/55cc84718ac01553b99486146a3509e50338051c) Merge remote-tracking branch 'origin/main' into feat/server-mods-commands ### 📊 Changes **21 files changed** (+927 additions, -109 deletions) <details> <summary>View changed files</summary> 📝 `crates/cargo-horizon-mod/src/check.rs` (+1 -1) 📝 `crates/horizon-client/src/game/mods.rs` (+4 -1) 📝 `crates/horizon-client/src/game/server_mods.rs` (+73 -1) 📝 `crates/horizon-client/src/lan/commands.rs` (+53 -10) 📝 `crates/horizon-client/src/lan/hub.rs` (+28 -1) 📝 `crates/horizon-mod-sdk/examples/beacons/horizon-mod.toml` (+1 -1) 📝 `crates/horizon-mod-sdk/examples/beacons/src/lib.rs` (+31 -15) 📝 `crates/horizon-mod-sdk/examples/beacons/tests/beacons.toml` (+18 -1) 📝 `crates/horizon-mod-sdk/examples/welcome/src/lib.rs` (+16 -9) 📝 `crates/horizon-mod-sdk/examples/welcome/tests/commands.toml` (+16 -1) 📝 `crates/horizon-mod-sdk/src/lib.rs` (+127 -8) 📝 `crates/horizon-mod-sdk/wit/horizon.wit` (+58 -10) ➕ `crates/horizon-mods/src/commands.rs` (+301 -0) 📝 `crates/horizon-mods/src/lib.rs` (+2 -0) 📝 `crates/horizon-mods/src/runtime.rs` (+98 -24) 📝 `crates/horizon-mods/src/testing.rs` (+1 -1) 📝 `crates/horizon-mods/tests/sandbox.rs` (+7 -5) 📝 `docs/api/mods-reference.md` (+53 -10) 📝 `docs/api/mods.md` (+7 -4) 📝 `docs/api/stability.md` (+1 -1) _...and 1 more files_ </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Stacked on #1895 (capability `world`), itself on #1894. This PR's own diff is its last commit (20 files, +922 −107). ## What Server mods (API 0.3, experimental) declare **typed arguments** for their commands. The server parses them with vanilla's messages, and players' clients get them in the command tree, so chat completes and hints them like a vanilla command. - WIT: `argument-kind` (`word`, `text`, `integer(min, max)`, `number`, `boolean`, `player`, `block-pos`), `argument { name, kind, optional }`, `server-command { name, arguments }`. The `command` hook gets the parsed values by name. - Parsing (`horizon-mods/src/commands.rs`): `~ ~1 ~` relative to the player, an online player's name or `@s`, integer bounds, a missing or extra argument. A failure answers the player in red with vanilla's text ("Integer must not be more than 64, found 99", "No player was found", "Incorrect argument for command"), and the mod isn't called. - Checked at load: names `[A-Za-z0-9_]`, distinct, only the last ones optional, `text` last. - **Command tree:** `CommandTree::packet_with` grafts the mods' commands under the root as Brigadier nodes (`brigadier:string` word/greedy, `brigadier:integer` with min/max, `brigadier:double`, `brigadier:bool`, `minecraft:entity` single player, `minecraft:block_pos`). The hub resends the tree when `Mods::generation()` changes (start, stop, reload). Server thread, LAN and dedicated. - **SDK:** `Registration::command_with(name, [Argument::integer("height", 1, 64).optional()])` and `Args` (`integer`, `number`, `string`, `boolean`, `player`, `block_pos`, `text`). `command(name)` keeps working: free text as one optional `text` argument. - **Examples:** `welcome` `/mined [player]` ("Alex broke 2 block(s)"), `beacons` `/beacon [height 1..64]` and `/ground [pos]` ("X Y Z is minecraft:stone in minecraft:forest", "That block isn't loaded"). Their test scripts cover the new arguments. - Docs: docs/mods.md "Typed commands" (the kinds table), docs/api/mods.md changelog, the regenerated reference. ## How tested `welcome` and `beacons` built with this branch's `cargo horizon-mod build` and given as `--dev-mod`. A scratch driver over horizon-ctl ran each game with fresh `HORIZON_HOME`, launcher home and XDG folders, and `HORIZON_NO_AUDIO=1`. 45/45 checks pass in each of: single player on the server thread, `--in-frame`, LAN with the host in-frame (the guest types), LAN with the host on its server thread, and `--dedicated` with a guest. They cover a good value, an out-of-range one, a relative position, an unloaded block, a missing player, and the earlier `/beacon` and `/ground` checks. Screenshots show the client's chat hint `[<height>]` after `/beacon ` (server thread and dedicated): the client got the tree. `cargo test -p horizon-mods --features runtime,pack`: the parser's 4 unit tests and the sandbox tests, with the scripts. `lan::commands` test `server_mods_commands_follow_vanillas` checks the grafted nodes. Clippy is clean with and without `mods`. **A/B:** with no server mod, `send_server_mod_commands` returns on a generation check and the tree is built as before. #1894 measured the whole server-mods path with no mod: equal within noise. **Self-check:** `pr_ready --quick` on this branch (its scope line counts the whole stack against main): **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 6a065fa48, 26 min 7 s) | Check | Result | | --- | --- | | Scope | ⚠️ 41 files, +3948 −191; 3366 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ changes with a Cargo.toml | | Public tree | ✅ | | Python tests | ➖ no Python change | | rustfmt | ✅ (14 s) | | clippy | ✅ (3 min 52 s) | | tests: workspace | ✅ 2069 passed (17 min 25 s) | | doc tests | ✅ 2 passed (2 min 1 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ✅ (3 s) | | launcher clippy | ✅ (1 min 9 s) | | launcher tests | ✅ 119 passed (1 min 22 s) | | Parity | ➖ 331 affected, to run in CI (--quick) | Parity: `parity.py --changed-files` over the whole stack's files (#1894, #1895, #1901) on its top commit c5bb51bb0: **110 passed, 0 failed** (42 min, Mac mini). Label `skip-release`: experimental API 0.3. Nothing changes for players without a server mod. ## Leftovers - Kinds not there yet: entity selectors beyond one player, item, block state, `^ ^ ^` local coordinates. - In-frame single player (no server thread), the client's chat completion lists a server mod's commands by name only, as before. 🤖 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-03 04:12:47 +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#3852
No description provided.