[GH-ISSUE #4526] [Feature]: Let a capability package provide a whole Game mode #2467

Closed
opened 2026-10-21 05:48:28 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @SonaGat3 on GitHub (Aug 3, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4526

Originally assigned to: @SpicyMarinara on GitHub.

What problem does this solve?

A package can extend Marinara in a lot of ways — a panel, a chat surface, a settings section, a
conversation game. 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.

Building one surfaced four gaps, three of them small and independent of the main idea:

  1. GameSurface has no capability slot. view="surface" exists only in ConversationView, for
    turn-games. There is no way for a package to render over the game area.
  2. The prompt-context permission has no consumer. It is in the manifest enum, but nothing in the
    server reads it — declaring it does nothing. A package that owns live state has no way to tell the
    model about it, so the model narrates against state it cannot see.
  3. The resource facade is read-only. A package's setup cannot create the player persona or a
    lorebook, which is the minimum a game mode needs to start.
  4. A package's own art is invisible until the next restart. The asset scan runs at boot, before
    packages activate and install their assets, and nothing re-runs it. Anything reading the manifest —
    scene analysis, the asset pickers — cannot see that art for a whole session. This one affects any
    package that ships assets, not just game modes.

The motivating case is a Persona-style game mode (calendar, bonds, palaces, card combat).

Proposed solution

Four separable pieces. Everything is declarative: 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.

1. Re-run the asset manifest scan after packages activate. The same idempotent scan the upload routes
already re-run, guarded so a package's freshly written files can't take down startup.

2. A per-turn prompt-context hook. Gives the existing permission a consumer: a package can append a
block to the system prompt of each turn. Contributors are keyed by package id, gated on the permission,
and a contributor that throws is logged and skipped so it can never break a turn. A contribution may also
declare which built-in systems it replaces (provides, today { inventory }), and the GM prompt stops
driving those.

3. Resource writes. Six optional methods on CapabilityResourceHost, thin passthroughs to storage, so
a setup flow can find-or-create the player persona and its lorebook.

4. A game-surface slot. The experience is chosen when the game is CREATED, from an Experiences block
in the setup wizard, and belongs to that game for its lifetime — not a per-chat toggle, since an
experience owns the whole run. Which package it is comes from the manifest. The seams are declarative and
each is gated host-side: background, speaker avatars, active speaker, an in-flow choice slot, sprite
scale, and a chrome declaration by which the experience says which built-in chrome it replaces.

Alternatives considered

Doing it entirely package-side. This was the starting assumption and most of it does work that way —
the state, the assets, the sprites, the combat, the storage all live in the package. These four are what
could not: there is no slot to render into, the format reminder is host-built, the resource facade is
read-only, and the manifest scan is host-side.

Injecting per-turn state through a constant lorebook entry instead of a prompt hook. Rejected after
measuring: that block is ~3-5k tokens on a typical turn, and a lorebook entry lands inside the lorebook's
own tokenBudget (15k, shared with every other entry), so it would compete with — and truncate — the
lore it sits next to.

Using gameSpecialInstructions for the same thing. It is injected every turn, but it is capped at
2000 characters, an order of magnitude short.

Telling the model not to use the built-in inventory from the package's own prompt, instead of the
provides declaration. The [inventory: …] command lives in the format reminder, which is pushed as
the last user message — closest to generation. A rule in the package's system prompt loses that argument,
and the model keeps logging items into a panel the player cannot see.

Hiding built-in chrome with CSS from the package's stylesheet rather than withholding the callbacks.
There are no stable selectors for those buttons, and hiding leaves the built-in flow reachable underneath
the surface.

Registering the cast as tracked NPCs (chatMeta.gameNpcs) so the narration would resolve avatars
without a new seam. Rejected: those NPCs are injected into the GM prompt as <tracked_npcs>, so a
25-character cast would pollute every turn and the persisted state.

Enabling the experience as a per-chat agent, which is how the first version worked. Changed on
@SpicyMarinara's direction, and it is better: toggling mid-run left a half-built game either way.

Additional context

  • Nothing here names a package: grep for any package id across the changed files returns zero.
  • Validated on staging: pnpm check, pnpm version:check, pnpm guard:installer-artifacts and
    scripts/test-owner-approval.mjs all pass; pnpm regression:prompt passes 147 checks and leaves one
    failure that reproduces identically on unmodified staging.
  • Two pre-existing problems I ran into and can file separately if useful: pnpm regression:prompt is
    currently red on staging for Storyboard host consumes package-owned prompts without restoring Engine globals; and pnpm smoke:ui cannot run where pnpm is the standalone binary, because
    e2e/start-servers.mjs assumes npm_execpath points at a JS file (with @pnpm/exe it points at
    pnpm.exe, so Node tries to parse the executable as a script).
  • One open question for the PR: this adds API surface but leaves supportedCapabilityApi at 1.7, since
    bumping it felt like a maintainer call. Bumping would be backward compatible either way.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @SonaGat3 on GitHub (Aug 3, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/4526 Originally assigned to: @SpicyMarinara on GitHub. ## What problem does this solve? A package can extend Marinara in a lot of ways — a panel, a chat surface, a settings section, a conversation game. 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. Building one surfaced four gaps, three of them small and independent of the main idea: 1. **`GameSurface` has no capability slot.** `view="surface"` exists only in `ConversationView`, for turn-games. There is no way for a package to render over the game area. 2. **The `prompt-context` permission has no consumer.** It is in the manifest enum, but nothing in the server reads it — declaring it does nothing. A package that owns live state has no way to tell the model about it, so the model narrates against state it cannot see. 3. **The resource facade is read-only.** A package's setup cannot create the player persona or a lorebook, which is the minimum a game mode needs to start. 4. **A package's own art is invisible until the next restart.** The asset scan runs at boot, before packages activate and install their assets, and nothing re-runs it. Anything reading the manifest — scene analysis, the asset pickers — cannot see that art for a whole session. This one affects any package that ships assets, not just game modes. The motivating case is a Persona-style game mode (calendar, bonds, palaces, card combat). ## Proposed solution Four separable pieces. Everything is declarative: 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. **1. Re-run the asset manifest scan after packages activate.** The same idempotent scan the upload routes already re-run, guarded so a package's freshly written files can't take down startup. **2. A per-turn `prompt-context` hook.** Gives the existing permission a consumer: a package can append a block to the system prompt of each turn. Contributors are keyed by package id, gated on the permission, and a contributor that throws is logged and skipped so it can never break a turn. A contribution may also declare which built-in systems it replaces (`provides`, today `{ inventory }`), and the GM prompt stops driving those. **3. Resource writes.** Six optional methods on `CapabilityResourceHost`, thin passthroughs to storage, so a setup flow can find-or-create the player persona and its lorebook. **4. A `game-surface` slot.** The experience is chosen when the game is CREATED, from an Experiences block in the setup wizard, and belongs to that game for its lifetime — not a per-chat toggle, since an experience owns the whole run. Which package it is comes from the manifest. The seams are declarative and each is gated host-side: background, speaker avatars, active speaker, an in-flow choice slot, sprite scale, and a chrome declaration by which the experience says which built-in chrome it replaces. ## Alternatives considered **Doing it entirely package-side.** This was the starting assumption and most of it does work that way — the state, the assets, the sprites, the combat, the storage all live in the package. These four are what could not: there is no slot to render into, the format reminder is host-built, the resource facade is read-only, and the manifest scan is host-side. **Injecting per-turn state through a constant lorebook entry** instead of a prompt hook. Rejected after measuring: that block is ~3-5k tokens on a typical turn, and a lorebook entry lands inside the lorebook's own `tokenBudget` (15k, shared with every other entry), so it would compete with — and truncate — the lore it sits next to. **Using `gameSpecialInstructions`** for the same thing. It is injected every turn, but it is capped at 2000 characters, an order of magnitude short. **Telling the model not to use the built-in inventory** from the package's own prompt, instead of the `provides` declaration. The `[inventory: …]` command lives in the **format reminder**, which is pushed as the last user message — closest to generation. A rule in the package's system prompt loses that argument, and the model keeps logging items into a panel the player cannot see. **Hiding built-in chrome with CSS** from the package's stylesheet rather than withholding the callbacks. There are no stable selectors for those buttons, and hiding leaves the built-in flow reachable underneath the surface. **Registering the cast as tracked NPCs** (`chatMeta.gameNpcs`) so the narration would resolve avatars without a new seam. Rejected: those NPCs are injected into the GM prompt as `<tracked_npcs>`, so a 25-character cast would pollute every turn and the persisted state. **Enabling the experience as a per-chat agent**, which is how the first version worked. Changed on @SpicyMarinara's direction, and it is better: toggling mid-run left a half-built game either way. ## Additional context - Nothing here names a package: `grep` for any package id across the changed files returns zero. - Validated on `staging`: `pnpm check`, `pnpm version:check`, `pnpm guard:installer-artifacts` and `scripts/test-owner-approval.mjs` all pass; `pnpm regression:prompt` passes 147 checks and leaves one failure that **reproduces identically on unmodified `staging`**. - Two pre-existing problems I ran into and can file separately if useful: `pnpm regression:prompt` is currently red on `staging` for `Storyboard host consumes package-owned prompts without restoring Engine globals`; and `pnpm smoke:ui` cannot run where pnpm is the standalone binary, because `e2e/start-servers.mjs` assumes `npm_execpath` points at a JS file (with `@pnpm/exe` it points at `pnpm.exe`, so Node tries to parse the executable as a script). - One open question for the PR: this adds API surface but leaves `supportedCapabilityApi` at 1.7, since bumping it felt like a maintainer call. Bumping would be backward compatible either way. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
Author
Owner

@SpicyMarinara commented on GitHub (Aug 3, 2026):

Groundwork for adding Agents introducing new Game modes.

<!-- gh-comment-id:5168573838 --> @SpicyMarinara commented on GitHub (Aug 3, 2026): Groundwork for adding Agents introducing new Game modes.
Author
Owner

@SpicyMarinara commented on GitHub (Aug 4, 2026):

Implemented and merged into staging via #4528 (merge commit 4efeafe7df).

<!-- gh-comment-id:5177261107 --> @SpicyMarinara commented on GitHub (Aug 4, 2026): Implemented and merged into staging via #4528 (merge commit 4efeafe7df9442de252a00d18d98ae1a35d96645).
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
Pasta-Devs/Marinara-Engine#2467
No description provided.