[GH-ISSUE #1183] [Feature] Native AI-assisted text rewriting for character, persona, and lorebook fields #582

Closed
opened 2026-10-20 17:30:27 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @kevin-ho on GitHub (May 25, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1183

What problem does this solve?

Writing and maintaining long-form text entries — character descriptions, persona definitions, lorebook entries, system prompts — is one of the more tedious parts of setting up a roleplay session. Other RP platforms (SillyTavern via extensions, Agnai, etc.) offer AI-assisted rewriting that lets users iteratively refine these fields with natural language instructions: "add more detail about their childhood," "convert to XML format," "make this more token-efficient," "rewrite in a darker tone."

Currently Marinara has no built-in mechanism for this. Users who want AI assistance have to copy text out to an external tool, get the rewrite, and paste it back — breaking flow and losing context.

Proposed solution

Add a native Magic Rewrite feature that integrates directly into the existing expand-textarea editors used across the app. Key elements:

  • POST /api/magic-rewrite/generate server endpoint that accepts text + user instructions + optional context bundle (character card, lorebook entries, chat history), and returns a rewritten version using one of the user's configured LLM connections.
  • Connection resolution follows a priority chain: a user-designated "rewrite" connection → the default chat connection → the agent default connection. A new "Default for Rewrite" toggle in Connection Settings lets users pick which endpoint handles rewrites.
  • UI integration via a sparkle (✨) button in the expanded textarea modal. Clicking it swaps the editor view to a split-pane layout with an instructions textarea, context selectors, and a before/after diff preview. Apply saves the rewrite; Back returns to the editor unchanged.
  • Context awareness — users can optionally include the active character card, selected lorebook entries, and recent chat history to give the LLM relevant world-building context for more accurate rewrites.

Alternatives considered

  1. App extension — this is how it currently exists (as a Marinara extension with hardcoded LLM credentials). The drawback is that it can't use the LLM connections already configured in the app, so users have to manually enter API keys directly into the extension settings. Shipping this natively lets users leverage their existing connections with no credential management.
  2. Generic "ask AI" popover — a simpler approach but loses the structured rewrite workflow (instructions → preview diff → apply/reject) that makes this feature actually useful for iterative editing.
  3. External tool integration — e.g., sending text to a separate service. Adds complexity and another dependency when the app already has LLM connection infrastructure.

Additional context

This was prototyped as a Marinara extension (magic-rewrite-extension) and proven to work well in practice. The native implementation reuses Marinara's existing createLLMProvider() and connection storage, so no new infrastructure is needed — just the route, the panel component, and a small DB column for the per-connection rewrite default.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @kevin-ho on GitHub (May 25, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1183 ## What problem does this solve? Writing and maintaining long-form text entries — character descriptions, persona definitions, lorebook entries, system prompts — is one of the more tedious parts of setting up a roleplay session. Other RP platforms (SillyTavern via extensions, Agnai, etc.) offer AI-assisted rewriting that lets users iteratively refine these fields with natural language instructions: "add more detail about their childhood," "convert to XML format," "make this more token-efficient," "rewrite in a darker tone." Currently Marinara has no built-in mechanism for this. Users who want AI assistance have to copy text out to an external tool, get the rewrite, and paste it back — breaking flow and losing context. ## Proposed solution Add a native **Magic Rewrite** feature that integrates directly into the existing expand-textarea editors used across the app. Key elements: - **`POST /api/magic-rewrite/generate`** server endpoint that accepts text + user instructions + optional context bundle (character card, lorebook entries, chat history), and returns a rewritten version using one of the user's configured LLM connections. - **Connection resolution** follows a priority chain: a user-designated "rewrite" connection → the default chat connection → the agent default connection. A new "Default for Rewrite" toggle in Connection Settings lets users pick which endpoint handles rewrites. - **UI integration** via a sparkle (✨) button in the expanded textarea modal. Clicking it swaps the editor view to a split-pane layout with an instructions textarea, context selectors, and a before/after diff preview. Apply saves the rewrite; Back returns to the editor unchanged. - **Context awareness** — users can optionally include the active character card, selected lorebook entries, and recent chat history to give the LLM relevant world-building context for more accurate rewrites. ## Alternatives considered 1. **App extension** — this is how it currently exists (as a Marinara extension with hardcoded LLM credentials). The drawback is that it can't use the LLM connections already configured in the app, so users have to manually enter API keys directly into the extension settings. Shipping this natively lets users leverage their existing connections with no credential management. 2. **Generic "ask AI" popover** — a simpler approach but loses the structured rewrite workflow (instructions → preview diff → apply/reject) that makes this feature actually useful for iterative editing. 3. **External tool integration** — e.g., sending text to a separate service. Adds complexity and another dependency when the app already has LLM connection infrastructure. ## Additional context This was prototyped as a Marinara extension (`magic-rewrite-extension`) and proven to work well in practice. The native implementation reuses Marinara's existing `createLLMProvider()` and connection storage, so no new infrastructure is needed — just the route, the panel component, and a small DB column for the per-connection rewrite default. ## Template check - [ ] I DID NOT read this template and provide the requested details.
Author
Owner

@WhatsUpJerks commented on GitHub (May 25, 2026):

There's already the professor mari assistant that can do all of this, isn't there?

<!-- gh-comment-id:4534716843 --> @WhatsUpJerks commented on GitHub (May 25, 2026): There's already the professor mari assistant that can do all of this, isn't there?
Author
Owner

@cha1latte commented on GitHub (May 25, 2026):

Triage note: labeling this as scope-risk because native Magic Rewrite is aligned with content authoring, but the proposed slice spans a new server route, connection defaults/storage, shared schemas, multiple editor surfaces, context selectors, and diff/apply UI.

The least risky next step is to keep review focused on one native rewrite path and make sure it does not drift into a general assistant surface already covered by Professor Mari or extensions.

<!-- gh-comment-id:4536674112 --> @cha1latte commented on GitHub (May 25, 2026): Triage note: labeling this as `scope-risk` because native Magic Rewrite is aligned with content authoring, but the proposed slice spans a new server route, connection defaults/storage, shared schemas, multiple editor surfaces, context selectors, and diff/apply UI. The least risky next step is to keep review focused on one native rewrite path and make sure it does not drift into a general assistant surface already covered by Professor Mari or extensions.
Author
Owner

@kevin-ho commented on GitHub (May 25, 2026):

I can redo the PR to use the 'Default Agent Connection' for making the rewrite calls, which would eliminate the "new server route, connection defaults/storage, shared schemas" changes. Though that toggle setting wouldn't be accurate any more.

<!-- gh-comment-id:4537220965 --> @kevin-ho commented on GitHub (May 25, 2026): I can redo the PR to use the 'Default Agent Connection' for making the rewrite calls, which would eliminate the "new server route, connection defaults/storage, shared schemas" changes. Though that toggle setting wouldn't be accurate any more.
Author
Owner

@cha1latte commented on GitHub (May 26, 2026):

v1 ported in #1260 !

<!-- gh-comment-id:4547184304 --> @cha1latte commented on GitHub (May 26, 2026): v1 ported in #1260 !
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#582
No description provided.