Skip to content

feat: add modpack sources and harden build key handling - #45

Merged
000hen merged 30 commits into
masterfrom
feature/modpack-support
Jul 20, 2026
Merged

000hen merged 30 commits into
masterfrom
feature/modpack-support

Conversation

@000hen

@000hen 000hen commented Jul 18, 2026 •

Copy link
Copy Markdown
Owner

Summary / 摘要

  • Adds end-to-end modpack browsing, installation, import, update, and export with unified multi-role Lua sources.
  • Preserves the latest master WinUI design by moving new dialogs and finite UI states into XAML-owned localization resources.
  • Completes CurseForge API-key XOR obfuscation for GitHub Actions, build.ps1, Visual Studio/MSBuild, and MSIX builds through one shared PowerShell implementation.
  • Clears the plaintext key before child builds and adds regression checks against plaintext or MSBuild-log exposure.
  • Makes modpack updates transactional and coordinates create, start, update, stop, delete, and remove-all-data lifecycle races.
  • Keeps close-to-tray protection synchronized across startup, live server state changes, active servers, modpack operations, backups, server mutations, and data cleanup.

The earlier obfuscation implementation did not cover every build entry point. This PR unifies those paths while retaining master's XAML-first resource architecture and fixing the lifecycle failures found during review.

XOR is obfuscation rather than cryptographic secrecy because the binary contains both cipher and pad. The embedded key must remain scoped and rotatable.

Testing / 測試

  • go test ./... (from engine/) — 388 tests passed in 21 packages
  • dotnet test app/JustHostMC.Core.Tests/JustHostMC.Core.Tests.csproj — 35 tests passed
  • I performed any relevant manual testing. / 我已完成相關的手動測試。
  • go vet ./...
  • dotnet build app/JustHostMC.App/JustHostMC.App.csproj -p:Platform=x64 — 0 errors, 0 warnings
  • Resource, finite-state, and tray lifecycle tests — 41 tests passed
  • Changed C# files pass clang-format; git diff --check passes
  • GitHub Check code formatting workflow — passed
  • Final code review — no remaining Critical or Important findings

Screenshots / 螢幕截圖

No before/after screenshots were captured. UI changes were validated through the x64 WinUI build and resource/finite-state tests, but not through a manual visual test pass.

Checklist / 檢查清單

  • The change is focused and does not include unrelated edits. / 這項變更範圍明確,且未包含無關修改。
  • I updated tests for changed behavior where practical. / 我已在適當情況下更新測試,以涵蓋行為變更。
  • I updated documentation for user-facing or developer-facing changes. / 我已更新與使用者或開發者相關的文件。
  • I regenerated protobuf outputs locally if files under proto/ changed. / 若修改了 proto/,我已在本機重新產生 protobuf 輸出。
  • I did not commit credentials, private server data, or generated build artifacts. / 我未提交憑證、私人伺服器資料或建置產物。

000hen and others added 25 commits July 17, 2026 01:18
…odpacks

Implements the four-track plan.

Shop sources (A): manage mod-shop scripts (import/remove/permissions) from
the Scripts page, alongside providers/parsers/automation.

Typed script config (B): ConfigOption/ScriptConfig proto + GetConfig/SetConfig
on all four script services; engine ConfigStore + meta.config validation +
ctx.config injection; a Configure dialog on each script card (secrets are
write-only).

Mod compatibility (C): new engine compat package (loader-family + Fabric/Maven
version-range matching) sets ModFile.Compat; builtin parsers emit game
versions/range; installed-mod and shop-version compat badges in the app.

FTB modpacks (D): ModKind.MODPACK + ProviderCapabilities.hidden/
free_form_versions + Server.loader; an ftb shop (browse) and a hidden ftb
provider (installs a pack as a whole server, resolving CurseForge-hosted files
via the shared key); a modpack Create-server flow in the Mod Shop. LaunchSpec
now carries mc_version/loader so a modpack resolves its concrete version at
install.

Contract-first: proto edits regenerated on both sides. Verified: engine
go build/vet + 274 unit tests; app build (0 warnings) + 5 Core integration tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- introduce ShopContext.ForModpackBrowsing with CreateServer callback to
  start whole-server installs via the main window's global install flow
- update ShopDetailViewModel to hand modpack create requests to
  CreateServer
  and show a "creation started" status
- filter available shops by context (server-scoped vs global) and
  surface a
  "no sources" status when none are visible
- add home-page button, ShopWindow title variant, and localization
  entries
  for the modpack shop
- remove ServerCreated event and handler; rely on the global install
  flow for
  new-server creation tracking
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ftb.lua echoes the opaque packId/versionId back as pack_version on the
launch spec; the engine stores it (new provider_version SQLite column with
migration) and returns it on the Server proto so the app can offer
update/export for modpack servers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Worker pool (default 6, cap 16) over errgroup; items carry a direct url or
a resolve endpoint (CurseForge download-url convention) resolved inside the
worker, so CF API round-trips parallelize too. First error cancels the
batch; progress is per-file completion with serialized emission.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
provider.Updater interface + ErrUpdateUnsupported sentinel; the Lua host
shares ctx-table construction and spec parsing between install() and
update(), which additionally receives ctx.old_version.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Streams progress like Create; requires a stopped modpack server; failure
restores STOPPED and leaves the existing install untouched. Empty spec.Args
from update() keeps the server's current launch args.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
manifest.json lists every CF-hosted file including client-only mods; the
server's live config dirs and hand-added mods go into overrides/;
client-only direct-URL files are downloaded at export time.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Server header flyout gains Update/Export modpack items (modpack servers
only; update requires the server stopped). Both stream through the global
per-server progress tracker: update picks a version fetched from the shop
and refreshes the list on completion; export saves a CurseForge client
pack zip via a file picker.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Live export against the real API failed with a JSON unmarshal error: the
manifest's curseforge.project/file are numeric strings, not numbers. Accept
both via flexInt64 and skip zero ids. Adds an opt-in live-export diagnostic
test (JHMC_LIVE_EXPORT_DIR/_PACK).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
New server from a local CurseForge client pack zip or Modrinth .mrpack,
streaming install progress like Create.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extract the loader-install steps (fabric/forge/neoforge) and the file
download/diff bookkeeping out of ftb.lua into a shared `mplib` module,
loaded into every script sandbox by prepare(). New providers (CurseForge,
Modrinth, import) build on it instead of copying ~140 lines.

Add a {prefix=...} option to jhmc.unzip so a pack's overrides/ tree can be
splatted into the server root, and have ftb.lua persist a normalized
.jhmc/modpack.json at install/update so export and update work without
re-fetching the upstream source.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Export now reads the server's normalized .jhmc/modpack.json when present,
building the CurseForge client zip from it instead of re-fetching the FTB
API. This makes Export work for every modpack provider (CurseForge,
Modrinth, imported) and offline; the FTB-API path stays as a fallback for
legacy FTB servers installed before manifests were persisted. Relax the
ExportModpack RPC gate from FTB-only to any modpack server.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a browseable CurseForge modpack shop (classId 4471) and a hidden
provider that installs a pack from its client manifest: download the pack
zip, resolve every listed mod's name/hash/url via the batch files endpoint,
install the pinned loader, splat overrides/ into the server root, and
persist the normalized manifest for export/update. The shared install and
update routines live in mplib so the import provider can reuse them. All
CurseForge sources share one API key, seeded from the CurseForge shop key.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a keyless Modrinth modpack shop (project_type:modpack) and a hidden
provider that installs a pack from its .mrpack: download the mrpack, install
the files modrinth.index.json lists (skipping env.server=="unsupported",
which are kept as client_only for export fidelity), extract overrides/ then
server-overrides/ (server wins), install the pinned loader, and persist the
normalized manifest. Quilt packs are rejected with a clear message. The
shared mrpack routines live in mplib for the import provider to reuse.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add the ImportModpack handler: it validates the picked file, stages it into
the new server dir at .jhmc/import.zip, and drives a hidden "import" provider
that detects the format (CurseForge manifest.json or Modrinth
modrinth.index.json) and reuses the shared mplib install routines. The
create flow is factored into runCreate with a staging hook shared by Create
and ImportModpack. Imported servers persist the normalized manifest (Export
works) but have no update() (Update stays Unimplemented — a local file has no
upstream to diff).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add an Import button to the home header: it picks a .zip (CurseForge) or
.mrpack (Modrinth) file, prompts for a server name (defaulted from the file
name) and memory, and streams install progress through the shared
new-server flow (InstallServerAsync and the new ImportModpackAsync now both
route through RunNewServerInstallAsync). Imported servers show Export but not
Update — the Update menu item hides when the provider id is "import".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…mented

A provider whose script has no update() (imported packs) returns
provider.ErrUpdateUnsupported, which mapInstallError routed to Internal.
Map it to codes.Unimplemented so it matches the non-Updater path in
UpdateModpack. UI-unreachable today (the app hides Update for imports), but
the status code is now correct. Add a regression test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@000hen
000hen marked this pull request as ready for review July 18, 2026 14:27
000hen added 4 commits July 18, 2026 22:41
- Make SelectedShopIsModpack derive from Context.Kind rather than
  merged shop capabilities
- Read IsModpack in ShopDetailViewModel from SelectedShopIsModpack
- Add ShopBrowsingContractTests to assert browse mode comes from context
@000hen
000hen merged commit ac5cf85 into master Jul 20, 2026
2 checks passed
@000hen
000hen deleted the feature/modpack-support branch July 20, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant