mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #330] [MERGED] feat(server): prompt-overrides registry for image prompts #4564
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#4564
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/330
Author: @RaynoldVanHeyningen
Created: 4/30/2026
Status: ✅ Merged
Merged: 5/3/2026
Merged by: @SpicyMarinara
Base:
main← Head:feat/prompt-overrides📝 Commits (2)
9d55751feat(server): prompt-overrides registry, routes, sprite conversion735cb41feat(server): register 7 more flat-template prompt-override keys📊 Changes
18 files changed (+878 additions, -112 deletions)
View changed files
📝
packages/server/src/db/migrate.ts(+6 -0)📝
packages/server/src/db/schema/index.ts(+1 -0)➕
packages/server/src/db/schema/prompt-overrides.ts(+14 -0)📝
packages/server/src/routes/game.routes.ts(+7 -0)📝
packages/server/src/routes/generate.routes.ts(+15 -18)📝
packages/server/src/routes/index.ts(+2 -0)➕
packages/server/src/routes/prompt-overrides.routes.ts(+115 -0)📝
packages/server/src/routes/sprites.routes.ts(+36 -54)📝
packages/server/src/services/game/game-asset-generation.ts(+50 -40)➕
packages/server/src/services/prompt-overrides/index.ts(+31 -0)➕
packages/server/src/services/prompt-overrides/load-prompt.ts(+31 -0)➕
packages/server/src/services/prompt-overrides/registry.ts(+62 -0)➕
packages/server/src/services/prompt-overrides/registry/conversation.ts(+58 -0)➕
packages/server/src/services/prompt-overrides/registry/game-assets.ts(+148 -0)➕
packages/server/src/services/prompt-overrides/registry/sprites.ts(+164 -0)➕
packages/server/src/services/prompt-overrides/template.ts(+51 -0)➕
packages/server/src/services/prompt-overrides/types.ts(+21 -0)➕
packages/server/src/services/storage/prompt-overrides.storage.ts(+66 -0)📄 Description
Linked issue
Closes #329
Why this change
The image-generation prompts (sprite sheets, NPC portraits, scene CGs, the
selfie meta-prompt, location backgrounds) are currently hardcoded TS strings
inside route handlers and asset-generation services. Users have no way to tune
them without forking the source.
This is observably user-facing. The multi-cell sprite-sheet prompt in
particular dedicates most of its budget to grid bookkeeping (
EXACTLY N cells,strict NxM grid,no extra rows,no merged cells) and ahardcoded "solid white studio background", which on many image models steers
the result toward a flat, low-contrast aesthetic. The prompt has no field
where users can inject style or quality keywords — the character's
appearancefield is the only lever, and it is already crowded with physicaldescriptors. (Sprite generation runs from the character editor outside any
game session, so it deliberately has no concept of a game-level art style —
this is a separate gap from in-game asset coherence.)
This PR introduces a generic registry that lets user-supplied templates
replace each registered prompt builder, with default behavior unchanged at
every call site.
What changed
New
prompt_overridestable. Idempotent CREATE inrunMigrations(); noseparate
pnpm db:pushneeded.New
services/prompt-overrides/module:(
${name}markers), a canonical default builder, and a realistic examplecontext used for previews.
${name}substitution, deliberately limited toflat variable expansion (no conditionals — see "Not included" below).
loadPrompt(storage, def, ctx)helper: returns the user's renderedtemplate if present and enabled, otherwise the canonical default. Falls
back to the default on any error so prompt rendering can never break the
surrounding feature.
New
/api/prompt-overridesroutes://:key/:key/default/:key{ template, enabled }— validates${vars}/:key/:key/previewPUT and
/previewreject templates that reference variables not declared bythe registered key (HTTP 400 with
unknownVariablesanddeclaredVariablesin the body).
Eight prompts registered and converted:
sprites.expressionSheetsprites.routes.ts)sprites.singlePortraitsprites.singleFullBodysprites.fullBodySheetgame.npcPortraitbuildNpcPortraitPromptingame-asset-generation.tsgame.backgroundgenerateBackgroundgame.sceneIllustrationgenerateSceneIllustrationconversation.selfiegenerate.routes.tsDefault behavior at every call site is byte-for-byte identical.
Conditional logic (e.g. "include this line only when X is non-empty", "use
this rule for non-human NPCs", "add the blank line before the tags block")
stays in TypeScript at the call site; the result is exposed as a pre-computed
string variable (
appearanceLine,nonHumanRule,selfieTagsBlock, etc.)that the user can rearrange in their template but cannot re-conditionalize.
This keeps the engine free of conditional constructs.
Not included by design.
gm.systemPrompt,gm.formatReminder,scene.analyzerSystem, party agent, session recap,etc.) are deliberately out of scope. The flat
${var}engine cannotrepresent ~15 conditional blocks per prompt without re-implementing parts
of Mustache. Either splitting each into sub-prompts or extending the
engine with a minimal
{{#if name}}…{{/if}}construct is a separatedesign decision worth its own PR.
extension can add an in-app editor without core changes.
Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
This PR is server-only — no UI surface yet. A human reviewer should manually
verify:
against an existing
marinara-engine.db; confirm theprompt_overridestable is created without touching other tables (e.g.
sqlite3 packages/server/data/marinara-engine.db ".schema prompt_overrides").no errors and table state stays consistent.
generate a 2×3 sprite expression sheet for a character. The image and the
prompt sent to the image model should be the same as before this PR. With
LOG_LEVEL=debugyou can see the prompt in the server log.check in Game Mode with image generation enabled.
The meta-prompt sent to the chat LLM should look the same as before.
(verify with
LOG_LEVEL=debug).${doesNotExist}should return HTTP 400 with
unknownVariables: ["doesNotExist"].DELETE /:keyandre-generate; behavior matches default again.
Docs and release impact
A
CHANGELOG.mdentry could be added — leaving that to maintainerpreference. The feature is undocumented in
docs/because it has no in-appsurface in this PR; a follow-up PR (or a community extension) can add
user-facing docs once the API is stable.
UI evidence (if applicable)
N/A — server-only. Routes are exercisable via curl; sample requests are in
the Manual verification notes above.
Summary by CodeRabbit
New Features
Chores
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.