Skip to content

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

@kevin-ho

Description

@kevin-ho

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clientenhancementNew feature or requestin-prHas an open pull request targeting stagingscope-riskAligned request that needs narrowing or product approval before buildservershared

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions