mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #1184] [CLOSED] feat: native AI-assisted Magic Rewrite for character, persona, and lorebook fields #4965
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#4965
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/1184
Author: @kevin-ho
Created: 5/25/2026
Status: ❌ Closed
Base:
main← Head:magic-rewrite📝 Commits (2)
ecd2816feat: native AI-assisted Magic Rewrite for character, persona, and lorebook fields (#1183)b665962fix: address CodeRabbit review feedback📊 Changes
11 files changed (+587 additions, -41 deletions)
View changed files
📝
packages/client/src/components/connections/ConnectionEditor.tsx(+31 -0)📝
packages/client/src/components/lorebooks/LorebookFormFields.tsx(+78 -24)📝
packages/client/src/components/ui/ExpandedTextarea.tsx(+84 -17)➕
packages/client/src/components/ui/MagicRewritePanel.tsx(+245 -0)📝
packages/server/src/db/migrate.ts(+5 -0)📝
packages/server/src/db/schema/connections.ts(+2 -0)📝
packages/server/src/routes/index.ts(+2 -0)➕
packages/server/src/routes/magic-rewrite.routes.ts(+101 -0)📝
packages/server/src/services/storage/connections.storage.ts(+36 -0)📝
packages/shared/src/schemas/connection.schema.ts(+1 -0)📝
packages/shared/src/types/connection.ts(+2 -0)📄 Description
Linked issue
Closes #1183
Why this change
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 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."
Currently Marinara has no built-in mechanism for this. A Marinara app extension (
magic-rewrite-extension) exists as a proof of concept, but it requires users to manually enter API keys because it cannot access the LLM connections already configured in the app. This PR ships the feature natively, reusing Marinara's existing connection infrastructure so users can leverage their configured endpoints with no additional credential management.What changed
packages/shared/src/types/connection.ts+packages/shared/src/schemas/connection.schema.ts: adddefaultForRewriteboolean field to the shared connection type and Zod create schema.packages/server/src/db/schema/connections.ts+packages/server/src/db/migrate.ts: adddefault_for_rewritetext column to theapi_connectionstable with a migration entry.packages/server/src/services/storage/connections.storage.ts: addgetDefaultForRewrite()method and mutual-exclusion enforcement in create/update — only one non-image-generation connection can hold the rewrite default at a time.packages/server/src/routes/magic-rewrite.routes.ts: newPOST /api/magic-rewrite/generateroute. Acceptstext,instruction, and optionalcontext(character, lorebook, chat history). Resolves connection via rewrite-specific → default chat → agent default chain. UsescreateLLMProvider()andchatComplete()with a focused system prompt that returns only rewritten text.packages/client/src/components/ui/MagicRewritePanel.tsx: new panel component with instruction textarea, context selectors (character card, lorebook entries, chat history with configurable message count up to 250), generate button with loading spinner, and a word-level diff preview showing before/after with changed spans highlighted. Supports persistent instruction recall vialocalStorage.packages/client/src/components/lorebooks/LorebookFormFields.tsx: adds ✨ Rewrite button in the lorebook description editor modal (bottom-right, left of Done). Clicking it enters rewrite mode with Back/Apply controls.packages/client/src/components/ui/ExpandedTextarea.tsx: adds ✨ Rewrite button in the shared full-screen editor header. This automatically makes the feature available in the character editor, persona editor, and chat settings drawer — all of which use this shared component.packages/client/src/components/connections/ConnectionEditor.tsx: adds "Default for Rewrite" toggle beneath the existing "Default for Agents" toggle, with tooltip explaining the fallback behavior. Hidden for image-generation provider connections.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
localStorage.Docs and release impact
UI evidence (if applicable)
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.