mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #1059] [CLOSED] feat: character-scoped regex scripts with ST card import #4908
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#4908
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/1059
Author: @kolacheee
Created: 5/21/2026
Status: ❌ Closed
Base:
staging← Head:feature/character-scoped-regex📝 Commits (3)
671b8a0feat: add character-scoped regex scripts with ST card import31f4bbafeat: add per-character isolation, tri-state mode, and Chat Settings UI for scoped regex73f90f0fix: include game party member IDs in scoped regex script fetch📊 Changes
16 files changed (+628 additions, -45 deletions)
View changed files
📝
packages/client/src/components/characters/CharacterEditor.tsx(+117 -1)📝
packages/client/src/components/chat/ChatInput.tsx(+16 -6)📝
packages/client/src/components/chat/ChatMessage.tsx(+16 -2)📝
packages/client/src/components/chat/ChatSettingsDrawer.tsx(+206 -4)📝
packages/client/src/components/chat/ConversationInput.tsx(+21 -8)📝
packages/client/src/components/game/GameNarration.tsx(+20 -2)📝
packages/client/src/hooks/use-apply-regex.ts(+45 -15)📝
packages/client/src/hooks/use-regex-scripts.ts(+5 -3)📝
packages/server/src/db/schema/regex-scripts.ts(+2 -0)📝
packages/server/src/routes/characters.routes.ts(+2 -0)📝
packages/server/src/routes/import.routes.ts(+6 -0)📝
packages/server/src/routes/regex-scripts.routes.ts(+6 -1)📝
packages/server/src/services/import/st-character.importer.ts(+112 -1)📝
packages/server/src/services/storage/regex-scripts.storage.ts(+51 -2)📝
packages/shared/src/schemas/regex.schema.ts(+1 -0)📝
packages/shared/src/types/regex.ts(+2 -0)📄 Description
Summary
characterIdcolumn to the regex scripts table, enabling scripts to be scoped to a specific character rather than applying globallyWhy
SillyTavern character cards embed
regex_scriptsin their extensions metadata — these scripts transform AI output to render custom UI elements like expression sprites, mood widgets, and structural HTML. Without importing these scripts, cards that rely on regex-driven theming (like the KZK card) render without their intended visual presentation.In group chats, scoped scripts must be isolated per-character so one character's regexes don't transform another character's messages. The tri-state mode gives users control: Exclusive (default) keeps each character's scripts on their own messages, Disabled turns off scoped scripts entirely, and Chat applies all scoped scripts globally (useful for 1-on-1 chats where users want scoped scripts to also apply to their own persona).
Changes
Schema & types:
packages/server/src/db/schema/regex-scripts.ts— addcharacter_idcolumnpackages/shared/src/types/regex.ts— addcharacterIdtoRegexScriptpackages/shared/src/schemas/regex.schema.ts— addcharacterIdto create schemaStorage & API:
packages/server/src/services/storage/regex-scripts.storage.ts— addlistForCharacters,listByCharacter,createBatch,removeByCharactermethods;list()filtered to global-only (characterId IS NULL)packages/server/src/routes/regex-scripts.routes.ts— support?characterIds=query param on list endpointpackages/server/src/routes/characters.routes.ts— clean up character-scoped scripts on character deletionImport:
packages/server/src/services/import/st-character.importer.ts— extractextensions.regex_scriptsfrom ST cards, convert format (numeric placements → named,disabled→enabled,/pattern/flags→ separate fields), batch-create as character-scoped scriptspackages/server/src/routes/import.routes.ts— add regex script fields to inspect preview responsesClient — per-character isolation:
packages/client/src/hooks/use-apply-regex.ts— tri-stateScopedRegexMode(disabled/exclusive/chat) withfilterForMode()that gates which scripts run per messagepackages/client/src/components/chat/ChatMessage.tsx— passesmessage.characterIdandscopedRegexModefrom chat metadata toapplyToAIOutputpackages/client/src/components/game/GameNarration.tsx— maps messageId → characterId for source attribution, passesscopedModeandcharacterIdper messagepackages/client/src/components/chat/ChatInput.tsx— passesscopedModetoapplyToUserInputpackages/client/src/components/chat/ConversationInput.tsx— passesscopedModetoapplyToUserInputat all three call sitesClient — Chat Settings UI:
packages/client/src/components/chat/ChatSettingsDrawer.tsx— new "Scoped Regex Scripts" section withScopedRegexModeSelector(tri-state button group with hover tooltips) andScopedRegexCharacterGroups(collapsible per-character groups with enabled/total counts and individual On/Off toggles)Client — Character Editor:
packages/client/src/components/characters/CharacterEditor.tsx— new "Regex Scripts" tab (after Lorebook) showing imported scripts with pattern, flags, replacement, placement badges, on/off toggle, and delete with confirmationTest plan
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.