[PR #2620] [MERGED] launcher: import a shared instance, or route any dropped file #4480

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

📋 Pull Request Information

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

Base: main ← Head: feat/launcher-import


📝 Commits (1)

  • e28bcba launcher: import a shared instance, or route any dropped file

📊 Changes

5 files changed (+506 additions, -0 deletions)

View changed files

📝 docs/launcher-commands.md (+11 -0)
📝 launcher/src/cli.rs (+55 -0)
➕ launcher/src/import.rs (+232 -0)
➕ launcher/src/import/tests.rs (+207 -0)
📝 launcher/src/lib.rs (+1 -0)

📄 Description

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

Clean room: designed from the feature list in briefs/launcher-features-1.md; no other launcher's code, docs or assets were read. The .mrpack reading follows Modrinth's published modpack format.

Launcher features, item 11, part 1: what a dropped or given file is, and a new instance made from a shared one. This part is the library, the CLI and MCP; the window's drop is the next PR. Stacked on #2618 (export).

horizon_launcher::import

  • what(file): the file's kind comes from its contents, not only its name.
    • A .mrpack with only minecraft in its dependencies (what instance export writes) is a shared instance; with a loader (fabric-loader, neoforge…) it is a Java modpack.
    • A zip is classified in this order: manifest.json → CurseForge modpack; pack.mcmeta + data/ → data pack; pack.mcmeta → resource pack; shaders/ → shader pack; a game folder layout (options.txt, saves/, resourcepacks/…) → shared instance.
    • A .hshader is a shader pack. Anything else is refused with the reason.
  • import_instance(file): makes a new instance named after the pack (or the file), with "(2)" when the name is taken.
    • It copies overrides/ and client-overrides/ (or the zip's entries) into the instance's folder. Only what an instance keeps is copied, using the same list as export plus saves/. Every path must be plain components inside the folder; .., absolute paths, logs and session.json are skipped.
    • Each files entry is downloaded with browser::download::fetch: Modrinth's CDN only, SHA-512 checked. A client-unsupported file is skipped.
    • On any failure the half-made folder is removed.
  • CLI / MCP: horizon-launcher instance import <file> [--instance <i>] does what a drop on the window will do: a new instance, the Modpacks import, a pack into the instance, or a pointer to worlds datapack-add for a data pack.

Proof

  • cargo fmt --check and cargo clippy --all-targets --locked --features gpui/runtime_shaders -- -D warnings are clean. cargo test --locked --features gpui/runtime_shaders --lib --bins: 163 + 36 passed. New tests:
    • says_what_a_dropped_file_is: 10 kinds of file.
    • an_export_comes_back_as_an_instance_and_nothing_escapes_its_folder: a .mrpack and a zip export round trip byte for byte. A zip with ../outside.txt, saves/../../up.txt, logs/ and session.json writes none of them. A non-Modrinth download is refused and the folder removed. A NeoForge .mrpack is not taken as an instance.
  • Live round trip, scratch homes: the Hardcore.mrpack exported in #2617 became Hardcore (2) with its packs, shader packs, world and data packs. Fresh Animations was downloaded from Modrinth and is byte-identical (same SHA-512) to the original.

🤖 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/2620 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/launcher-import` --- ### 📝 Commits (1) - [`e28bcba`](https://github.com/horizon-rust/horizon/commit/e28bcba3d393fab57f1dc242ab1deb3e179d1225) launcher: import a shared instance, or route any dropped file ### 📊 Changes **5 files changed** (+506 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `docs/launcher-commands.md` (+11 -0) 📝 `launcher/src/cli.rs` (+55 -0) ➕ `launcher/src/import.rs` (+232 -0) ➕ `launcher/src/import/tests.rs` (+207 -0) 📝 `launcher/src/lib.rs` (+1 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Clean room: designed from the feature list in briefs/launcher-features-1.md; no other launcher's code, docs or assets were read. The .mrpack reading follows Modrinth's published modpack format. Launcher features, item 11, part 1: what a dropped or given file is, and a new instance made from a shared one. This part is the library, the CLI and MCP; the window's drop is the next PR. Stacked on #2618 (export). ## `horizon_launcher::import` - **`what(file)`:** the file's kind comes from its contents, not only its name. - A `.mrpack` with only `minecraft` in its dependencies (what `instance export` writes) is a **shared instance**; with a loader (`fabric-loader`, `neoforge`…) it is a **Java modpack**. - A zip is classified in this order: `manifest.json` → CurseForge modpack; `pack.mcmeta` + `data/` → data pack; `pack.mcmeta` → resource pack; `shaders/` → shader pack; a game folder layout (options.txt, `saves/`, `resourcepacks/`…) → shared instance. - A `.hshader` is a shader pack. Anything else is refused with the reason. - **`import_instance(file)`:** makes a new instance named after the pack (or the file), with "(2)" when the name is taken. - It copies `overrides/` and `client-overrides/` (or the zip's entries) into the instance's folder. Only what an instance keeps is copied, using the same list as export plus `saves/`. Every path must be plain components inside the folder; `..`, absolute paths, logs and `session.json` are skipped. - Each `files` entry is downloaded with `browser::download::fetch`: Modrinth's CDN only, SHA-512 checked. A client-unsupported file is skipped. - On any failure the half-made folder is removed. - **CLI / MCP:** `horizon-launcher instance import <file> [--instance <i>]` does what a drop on the window will do: a new instance, the Modpacks import, a pack into the instance, or a pointer to `worlds datapack-add` for a data pack. ## Proof - `cargo fmt --check` and `cargo clippy --all-targets --locked --features gpui/runtime_shaders -- -D warnings` are clean. `cargo test --locked --features gpui/runtime_shaders --lib --bins`: 163 + 36 passed. New tests: - `says_what_a_dropped_file_is`: 10 kinds of file. - `an_export_comes_back_as_an_instance_and_nothing_escapes_its_folder`: a .mrpack and a zip export round trip byte for byte. A zip with `../outside.txt`, `saves/../../up.txt`, `logs/` and `session.json` writes none of them. A non-Modrinth download is refused and the folder removed. A NeoForge .mrpack is not taken as an instance. - Live round trip, scratch homes: the `Hardcore.mrpack` exported in #2617 became `Hardcore (2)` with its packs, shader packs, world and data packs. Fresh Animations was downloaded from Modrinth and is byte-identical (same SHA-512) to the original. 🤖 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:17:29 +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#4480
No description provided.