[PR #5835] [CLOSED] feat(illustrator): native NovelAI character captions for roleplay illustrations #6960

Closed
opened 2026-10-23 04:15:15 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5835
Author: @stonebystone
Created: 9/4/2026
Status: ❌ Closed

Base: staging ← Head: feat/illustrator-novelai-character-prompts


📝 Commits (5)

  • 4a4c3ad feat(illustrator): native NovelAI character captions for roleplay illustrations
  • e396368 feat(illustrator): source captions from card appearance and tracker outfit
  • e75736a test(regressions): split the NovelAI caption-cap guard into its own file
  • c8d655c fix(illustrator): split ensemble-card appearance per character before captioning
  • a83f102 refactor(illustrator): let the prompt writer own card appearance for captions

📊 Changes

15 files changed (+810 additions, -89 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/media/illustrator-agent.md (+12 -0)
📝 docs/media/image-providers.md (+2 -2)
📝 packages/client/src/components/ui/ImagePromptReviewModal.tsx (+43 -0)
📝 packages/client/src/localization/locales/en.json (+3 -0)
📝 packages/server/src/routes/game.routes.ts (+25 -73)
📝 packages/server/src/routes/generate.routes.ts (+56 -5)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+92 -5)
📝 packages/server/src/services/agents/agent-executor.ts (+31 -0)
📝 packages/server/src/services/generation/illustrator-background-generation.ts (+29 -0)
📝 packages/server/src/services/generation/illustrator-manual-prompt-generation.ts (+7 -0)
➕ packages/server/src/services/image/character-prompts.ts (+228 -0)
📝 packages/server/src/services/image/image-generation.ts (+11 -4)
➕ scripts/regressions/illustrator-character-prompts.regression.ts (+244 -0)
➕ scripts/regressions/novelai-character-caption-cap.regression.ts (+26 -0)

📄 Description

Closes #5833

Why

NovelAI V4, V4.5, and V5 accept native per-character captions with positions, which is the main lever they offer for group scenes: each character's hair, clothing, expression, and pose stay attached to that character instead of blending across the frame. Marinara already used this for game storyboards, but the roleplay Illustrator still sent one flat base prompt, so anyone who switched their image connection to NovelAI got worse multi-character illustrations than the storyboard path produced from the same scene.

Two smaller problems sat next to that gap. The caption cap was a fixed six even on V5, which accepts 22, so ensemble scenes silently lost captions past the sixth. And on V5 any reference image (Maps location, avatar refs) made the whole illustration fail, because NovelAI has not yet shipped Precise Reference for V5.

What changed

  • New services/image/character-prompts.ts holds the caption sanitizer, default layout, model-aware limit (22 on V5, 6 on V4/V4.5), a native-NovelAI connection gate, and the prompt-writer rules. The Storyboard planner now uses it instead of its private copies.
  • When the Illustrator's resolved image connection is NovelAI's own host on a V4+ model, its system prompt gains a characterPrompts schema extension (via _illustratorCharacterPromptInstruction, rendered by the agent executor). No new setting: it activates only where it can be used.
  • The automatic, retry, and manual Illustration paths read characterPrompts off the prompt writer's JSON, validate them against the visible-character list, and forward them on the image request. NovelAI's request builder already maps them to char_captions with centers.
  • The review-before-send dialog lists the captions read-only under the main prompt.
  • The prompt writer is told to copy Danbooru-tagged Appearance fields verbatim, convert prose Appearance fields and tracker outfits into tags, and keep both inside the character's caption. With Attach Card Appearance on, the writer receives a full appearance reference before it runs (every card and persona Appearance field, ensemble [NAME] tags | [NAME] tags blocks split per character, capped at 8000 chars and not subject to the lore-block field limit). The writer is the arbiter: fixed traits go into the matching caption, card clothing is a default the tracker or scene overrides, absent characters are ignored. When captions come back the server appends nothing; when the writer returns none, the classic base-prompt appearance line still applies.
  • NovelAI generation on a non-4.5 model now drops reference images with a warning instead of throwing.
  • Docs: Illustrator guide gains a "Multiple characters on NovelAI" section; providers guide updated for the reference behavior. CHANGELOG entry added.

Validation

  • pnpm check
  • node scripts/run-regressions.mjs --filter illustrator-character-prompts (limit, gate, sanitizer, instruction block, resolver, manual-plan parsing, executor pass-through, and appearance routing into captions)
  • node scripts/run-regressions.mjs --filter novelai-character-caption-cap (NovelAI request builder carries 22 captions on V5, 6 on V4.5)
  • Manually verify a two-character roleplay illustration on a NovelAI V5 connection: the review dialog lists two captions with distinct positions, and the saved PNG's embedded marinara_novelai_request chunk shows two char_captions with use_coords: true
  • Manually verify a single-character scene sends no captions
  • Manually verify, with Attach Card Appearance on and an ensemble card in the chat, that the review dialog shows card tags only inside the captions and the base prompt ends at the scene tags
  • Manually verify a ComfyUI connection is unaffected (no characterPrompts instruction in the Illustrator debug prompt)
  • Manually verify a game storyboard with more than six visible characters on V5 keeps all captions

Notes for reviewers

  • Docs changed under docs/media/; a [docs-i18n] follow-up issue is needed for the translated language packs.
  • The regression runner's fixed 30s per-file budget can time out on a loaded machine for files that import image-generation.ts; the file passes when run directly with tsx.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VGCLPpohNDc1uPX8HcKJ9v

Summary by CodeRabbit

  • New Features

    • Added per-character captions for NovelAI V4, V4.5, and V5 roleplay illustrations and storyboards.
    • Captions include appearance, expression, pose, position, and optional negative prompts.
    • Added a read-only review display for character captions before image generation.
    • Supported up to 6 captions on V4/V4.5 and 22 on V5.
  • Bug Fixes

    • Unsupported NovelAI reference images now fall back to generation without references and record a warning instead of failing.
  • Documentation

    • Added guidance for multi-character captions, appearance sources, model limits, review behavior, and reference-image handling.

🔄 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/Pasta-Devs/Marinara-Engine/pull/5835 **Author:** [@stonebystone](https://github.com/stonebystone) **Created:** 9/4/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `feat/illustrator-novelai-character-prompts` --- ### 📝 Commits (5) - [`4a4c3ad`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4a4c3ad98429588699f4e767bb33d1f148a51063) feat(illustrator): native NovelAI character captions for roleplay illustrations - [`e396368`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e396368c88ef0ec87c223ffd6cd4c620bfe5843a) feat(illustrator): source captions from card appearance and tracker outfit - [`e75736a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e75736adcd8bd8f20533a1275b09c2a4d1bc23c4) test(regressions): split the NovelAI caption-cap guard into its own file - [`c8d655c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c8d655c2a9b866798f42b0be9f13d1f1092f2da7) fix(illustrator): split ensemble-card appearance per character before captioning - [`a83f102`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a83f102d101e2419e34b09506059df3a4acb35ae) refactor(illustrator): let the prompt writer own card appearance for captions ### 📊 Changes **15 files changed** (+810 additions, -89 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/media/illustrator-agent.md` (+12 -0) 📝 `docs/media/image-providers.md` (+2 -2) 📝 `packages/client/src/components/ui/ImagePromptReviewModal.tsx` (+43 -0) 📝 `packages/client/src/localization/locales/en.json` (+3 -0) 📝 `packages/server/src/routes/game.routes.ts` (+25 -73) 📝 `packages/server/src/routes/generate.routes.ts` (+56 -5) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+92 -5) 📝 `packages/server/src/services/agents/agent-executor.ts` (+31 -0) 📝 `packages/server/src/services/generation/illustrator-background-generation.ts` (+29 -0) 📝 `packages/server/src/services/generation/illustrator-manual-prompt-generation.ts` (+7 -0) ➕ `packages/server/src/services/image/character-prompts.ts` (+228 -0) 📝 `packages/server/src/services/image/image-generation.ts` (+11 -4) ➕ `scripts/regressions/illustrator-character-prompts.regression.ts` (+244 -0) ➕ `scripts/regressions/novelai-character-caption-cap.regression.ts` (+26 -0) </details> ### 📄 Description Closes #5833 ## Why NovelAI V4, V4.5, and V5 accept native per-character captions with positions, which is the main lever they offer for group scenes: each character's hair, clothing, expression, and pose stay attached to that character instead of blending across the frame. Marinara already used this for game storyboards, but the roleplay Illustrator still sent one flat base prompt, so anyone who switched their image connection to NovelAI got worse multi-character illustrations than the storyboard path produced from the same scene. Two smaller problems sat next to that gap. The caption cap was a fixed six even on V5, which accepts 22, so ensemble scenes silently lost captions past the sixth. And on V5 any reference image (Maps location, avatar refs) made the whole illustration fail, because NovelAI has not yet shipped Precise Reference for V5. ## What changed - New `services/image/character-prompts.ts` holds the caption sanitizer, default layout, model-aware limit (22 on V5, 6 on V4/V4.5), a native-NovelAI connection gate, and the prompt-writer rules. The Storyboard planner now uses it instead of its private copies. - When the Illustrator's resolved image connection is NovelAI's own host on a V4+ model, its system prompt gains a `characterPrompts` schema extension (via `_illustratorCharacterPromptInstruction`, rendered by the agent executor). No new setting: it activates only where it can be used. - The automatic, retry, and manual Illustration paths read `characterPrompts` off the prompt writer's JSON, validate them against the visible-character list, and forward them on the image request. NovelAI's request builder already maps them to `char_captions` with centers. - The review-before-send dialog lists the captions read-only under the main prompt. - The prompt writer is told to copy Danbooru-tagged Appearance fields verbatim, convert prose Appearance fields and tracker outfits into tags, and keep both inside the character's caption. With Attach Card Appearance on, the writer receives a full appearance reference before it runs (every card and persona Appearance field, ensemble `[NAME] tags | [NAME] tags` blocks split per character, capped at 8000 chars and not subject to the lore-block field limit). The writer is the arbiter: fixed traits go into the matching caption, card clothing is a default the tracker or scene overrides, absent characters are ignored. When captions come back the server appends nothing; when the writer returns none, the classic base-prompt appearance line still applies. - NovelAI generation on a non-4.5 model now drops reference images with a warning instead of throwing. - Docs: Illustrator guide gains a "Multiple characters on NovelAI" section; providers guide updated for the reference behavior. CHANGELOG entry added. ## Validation - [ ] `pnpm check` - [ ] `node scripts/run-regressions.mjs --filter illustrator-character-prompts` (limit, gate, sanitizer, instruction block, resolver, manual-plan parsing, executor pass-through, and appearance routing into captions) - [ ] `node scripts/run-regressions.mjs --filter novelai-character-caption-cap` (NovelAI request builder carries 22 captions on V5, 6 on V4.5) - [ ] Manually verify a two-character roleplay illustration on a NovelAI V5 connection: the review dialog lists two captions with distinct positions, and the saved PNG's embedded `marinara_novelai_request` chunk shows two `char_captions` with `use_coords: true` - [ ] Manually verify a single-character scene sends no captions - [ ] Manually verify, with Attach Card Appearance on and an ensemble card in the chat, that the review dialog shows card tags only inside the captions and the base prompt ends at the scene tags - [ ] Manually verify a ComfyUI connection is unaffected (no `characterPrompts` instruction in the Illustrator debug prompt) - [ ] Manually verify a game storyboard with more than six visible characters on V5 keeps all captions ## Notes for reviewers - Docs changed under `docs/media/`; a `[docs-i18n]` follow-up issue is needed for the translated language packs. - The regression runner's fixed 30s per-file budget can time out on a loaded machine for files that import `image-generation.ts`; the file passes when run directly with `tsx`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01VGCLPpohNDc1uPX8HcKJ9v <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added per-character captions for NovelAI V4, V4.5, and V5 roleplay illustrations and storyboards. * Captions include appearance, expression, pose, position, and optional negative prompts. * Added a read-only review display for character captions before image generation. * Supported up to 6 captions on V4/V4.5 and 22 on V5. * **Bug Fixes** * Unsupported NovelAI reference images now fall back to generation without references and record a warning instead of failing. * **Documentation** * Added guidance for multi-character captions, appearance sources, model limits, review behavior, and reference-image handling. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:15:15 +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
Pasta-Devs/Marinara-Engine#6960
No description provided.