mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #4528] [MERGED] feat: let a capability package provide a whole Game mode #6410
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#6410
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4528
Author: @SonaGat3
Created: 8/3/2026
Status: ✅ Merged
Merged: 8/4/2026
Merged by: @SpicyMarinara
Base:
staging← Head:feat/game-mode-experience📝 Commits (10+)
d0cb9abfeat: let a capability package provide a whole Game mode589135brefactor: address review feedback on the game-mode experience seamcca7884fix: restore built-in chrome when an experience package is gone63e3d05fix: close the seam gaps the third review pass foundc2a5d8ffix: clear pending choices and QTEs when the game scope changesc51cca3fix: apply the contributor deadline to thenables, and require a client entrypointdaf0e9efix: hide built-in HUD widgets on mobile too, and read the package config defensively00bfd86fix: render the experience setup from the resolved package, not the remembered idb7130c9fix: invalidate the package's resource writes when game creation fails tood5c7adafix: pin the selected experience while a launch is running📊 Changes
19 files changed (+1003 additions, -62 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
docs/development/optional-agent-packages.md(+11 -1)📝
packages/client/src/components/game/GameNarration.tsx(+19 -6)📝
packages/client/src/components/game/GameSetupWizard.tsx(+7 -1)📝
packages/client/src/components/game/GameSurface.tsx(+320 -41)➕
packages/client/src/components/game/NewGameExperienceChooser.tsx(+280 -0)📝
packages/client/src/hooks/use-capability-packages.ts(+20 -0)📝
packages/client/src/localization/locales/en.json(+4 -0)📝
packages/server/src/app.ts(+9 -0)📝
packages/server/src/routes/game.routes.ts(+19 -0)📝
packages/server/src/routes/generate.routes.ts(+20 -0)📝
packages/server/src/services/capability-packages/capability-module-runtime.service.ts(+16 -0)➕
packages/server/src/services/capability-packages/capability-prompt-context.service.ts(+125 -0)📝
packages/server/src/services/capability-packages/capability-resources.service.ts(+41 -0)📝
packages/server/src/services/game/gm-prompts.ts(+13 -3)📝
packages/shared/src/schemas/capability-package.schema.ts(+31 -5)📝
packages/shared/src/types/capability-runtime.ts(+55 -0)📝
packages/shared/src/types/game.ts(+7 -0)📝
scripts/regressions/capability-package-lifecycle.regression.ts(+5 -5)📄 Description
Linked issue
Closes #4526
Why this change
Marinara can already be extended a lot — a package can add a panel, a chat surface, a settings
section. What it cannot do is provide a Game mode of its own: one that draws its own HUD, menus and
combat, keeps its own state, and replaces the built-in systems it implements. Everything a package can
contribute today sits next to Game mode rather than being one.
This adds that seam, plus the three smaller pieces of host support it turned out to need. All of it is
generic: the engine never names a package, an experience DECLARES what it replaces, and anything left
undeclared stays built-in. A game without an experience behaves exactly as it does today.
It's four separable pieces, described below so they can be reviewed one at a time.
What changed
1. Re-scan the asset manifest after packages activate —
packages/server/src/app.ts(+12)Unrelated to game modes, and useful to any package: a package can install its own art during
activate(), which runs after the boot-time asset scan. Until now that art stayed invisible toeverything that reads the manifest — scene analysis, the asset pickers — until the next restart.
This re-runs the same idempotent scan the upload routes already re-run.
Guarded with
try/catch+app.log.warnon purpose: this call runs over files a package has justwritten, and
scanDiruses barereaddirSync/statSync. A stale manifest costs that package its artuntil the next scan; failing to boot costs the user everything.
2. A per-turn
prompt-contexthook — 3 files + 1 newserver/services/capability-packages/capability-prompt-context.service.tsserver/services/capability-packages/capability-module-runtime.service.ts(+17)server/routes/generate.routes.ts(+23)server/services/game/gm-prompts.ts(+14/−3)The
prompt-contextpermission already existed in the manifest enum but had no consumer, sodeclaring it did nothing. This gives it one: a package that owns live state can append a block to the
system prompt of each turn, so the model narrates in sync with what the player is looking at instead of
guessing.
Registration is gated on the permission. Contributors are keyed by package id, so re-activation replaces
rather than stacks. A contributor that returns nothing is skipped and one that throws is logged and
skipped — a package can never break a turn.
A contribution may also declare which built-in systems it replaces (
provides). Today that's{ inventory?: boolean }: an experience with its own item system takes[inventory: …]and thePLAYER INVENTORY:block out of the GM format reminder. This has to be declarative rather than a line inthe package's own prompt, because the format reminder is injected as the LAST user message — a package
can't out-argue it from the system prompt. Anything not declared stays built-in.
3. Resource writes — 2 files (+97)
shared/types/capability-runtime.ts(+55)server/services/capability-packages/capability-resources.service.ts(+42)The resource facade exposed reads only. A package's setup flow needs to find-or-create the player persona
and its lorebook, so this adds six write methods as thin passthroughs to engine storage.
They are optional members of
CapabilityResourceHost, so adding them is not a breaking type changefor any other implementation, and a host that only wants to expose reads doesn't have to stub six
throwers. The input types are declared narrowly enough to hand straight to storage (a closed
CapabilityLorebookCategoryunion, a required entryname), so nothing needs a cast — a wrong value is acompile error in the package instead of a silent rejection at write time.
4. The game-mode experience seam — 7 files
shared/schemas/capability-package.schema.ts(+16) — thegame-surfaceslot and itscontributions.gameSurface.surfaceClassoptionshared/types/game.ts(+9) andserver/routes/game.routes.ts(+6) —gameExperienceId+experienceConfigon the setup config, copied to the chat metadata on createclient/components/game/GameSurface.tsx(+323/−36) — the mount and every seamclient/components/game/GameSetupWizard.tsx(+10/−1) — an optionalexperiencesSlotclient/components/game/NewGameExperienceChooser.tsx— the Experiences blockclient/components/game/GameNarration.tsx(+27/−6) — five inert theming hooksclient/src/localization/locales/en.json(+4)The experience is chosen when the game is created, from an Experiences block in the setup wizard's
first step, and belongs to that game for its lifetime. It is deliberately not a per-chat toggle: an
experience owns the whole run — its own inventory, combat, calendar and state — so switching one on
midway through an ordinary game, or off midway through its own, leaves a half-built run either way.
Which package it is comes from the manifest (it declares the
game-surfaceslot), so nothing here istied to a specific package id.
grepfor any package name across these files returns zero.The surface mounts twice: the main layer above the narration for HUD and menus, and a presentation-only
underlay in the background band for what must render behind the dialogue box, like a standing
sprite. Same
view, distinguished by constant props, so no new value was needed in theCapabilityElementview union.The seams are all declarative, and each is gated host-side so a stale value can never leak into an
ordinary game: scene background, speaker avatars, the live
activeSpeaker, an in-flow choice slot abovethe narration box, the host's sprite-scale setting, the resolved scene background handed to the underlay,
and a chrome declaration (
providesInventory/providesCombat/providesPlayerInput) by which anexperience says which built-in chrome it replaces. The Inventory and Start-combat buttons are hidden by
simply not receiving their callbacks — withholding beats hiding, since there's no dead button and no way
to reach the built-in flow underneath.
The five hooks in
GameNarrationare class names and onedata-attribute, with no logic. Nothing in theengine styles them, so Classic renders identically; an experience needs them because that chrome renders
outside its own element and is otherwise unreachable from its stylesheet.
The first-game tutorial is suppressed for an experience — it spotlights built-in chrome that isn't on
screen. Suppressed, not consumed: the persisted "never show again" flag is left untouched, so a player
who runs an experience first still gets the tour on their first ordinary game.
5. Clear pending choices and QTEs on a scope change —
packages/client/.../GameSurface.tsx(+3)Pre-existing, and the only change here that touches ordinary games. Choices offered by one game stayed on
screen in the next one and were answerable there; an active QTE leaks the same way and carries a timer
that then fires in the new game. Every site clearing either one is driven by a player action or by the
session concluding, and the effect keyed on the scope resets about twenty other pieces of turn state
without touching these two.
It is fixed here rather than separately because it lives in the same effect this PR was asked to reset the
experience seam state in, and resetting ours while leaving these two leaking would be arbitrary. Say the
word and I will split it out.
Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Ran against
staging, with a package that provides an experience installed:The experience path. The surface mounts, HUD and menus render over the narration, and the standing
sprite draws behind the dialogue box (the underlay mount). Speaker avatars resolve for a cast that has
no character cards. The experience's choice menu lands above the narration box rather than floating over
it. The built-in Inventory and Start-combat buttons are absent, and the text input disappears while a menu
is on screen and comes back when there is nothing to pick — the chrome declaration is live, not one-shot.
Switching between modes. Moved back and forth between an experience game and an ordinary one
repeatedly. No state leaks in either direction: no stuck background, no leftover avatars, no chrome from
one showing up in the other.
Ordinary Game mode. Checked on a fresh ordinary game: the setup wizard is unchanged apart from the
added block, and the Inventory / Start-combat buttons, text input, map, party bar, HUD widgets and
per-scene background and music all behave as before. The first-game tutorial still fires on the first
ordinary game even after playing an experience first, which is the point of suppressing it rather than
consuming the flag.
One deliberate change to ordinary games, described under part 5 below: pending choices and QTEs are now
cleared when the game scope changes.
Empty state. With no experience installed, the block renders its "none downloaded yet" state with an
affordance to open the catalog, and the built-in wizard is untouched.
Part 1 — the manifest is rebuilt after activation and indexes the package's art (114 entries for the
installed package) on the first restart after installing, with no second restart needed.
Part 2 — verified in a real game in both modes: an ordinary game still gets the
[inventory: …]command, and the experience — which declares
provides: { inventory: true }— does not.Part 3 — creating a game through the experience's setup creates the player persona and its lorebook
with the expected fields.
Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)docs/development/optional-agent-packages.md— extended "Package model" to cover full Game-modesurfaces, per-turn prompt contributions, and the resource writes. No version heading, as suggested.
Nothing under
docs/proper changed, so nodocs-i18nwork is needed. No version bump.UI evidence (if applicable)
Before:

After:

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