mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2700] [Issue]: ST regex script import drops options (markdownOnly/substituteRegex/runOnEdit), remaps placements, force-defaults flags to gi #1346
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#1346
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?
Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2700
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Importing a SillyTavern character card's embedded regex scripts alters their behavior: ST options
markdownOnly/substituteRegex/runOnEditare silently dropped, placements other than user-input/AI-output are remapped to AI-output, and bare/no-flag patterns are force-defaulted to case-insensitive global (gi) — changing which text matches.Expected behavior
An imported ST regex script should behave the same as in SillyTavern: same scope (display vs prompt), same placements, and the same matching flags as the source pattern.
Actual behavior
convertStRegexScripts(st-character.importer.ts:113-159):promptOnly: false(:148) and never reads ST'smarkdownOnly,substituteRegex, orrunOnEdit. So a script ST runs on the prompt (or as a macro substitution, or on edit) is imported as a display-only, non-substituting, non-edit script — different scope/behavior.convertStPlacements(:96-105) only handles ST placement1(user input) and2(AI output); any other placement (slash commands, world info, reasoning) is dropped, and an empty result defaults to["ai_output"](:137). So scripts scoped to other placements are silently remapped to AI output.(delimited?.[2] || "gi").replace(/[^gimsuy]/g, "")then forced to includeg(:129-130). A bare ST source (no/.../flagsdelimiters) is force-defaulted to case-insensitive global even if ST treated it case-sensitively — changing which text matches.How it breaks the pipeline
Code trace (staging @
b826f8f4) —packages/server/src/services/import/st-character.importer.ts:convertStRegexScripts:113-159;promptOnly: false:148; flags:129-130.convertStPlacements:96-105; placement default:137.Steps to reproduce
extensions.regex_scriptshas a script withmarkdownOnly:false(a prompt-affecting script) → it imports as display-only.placement:[5](or any non-1/2) → it imports as AI-output.findRegexis a bare source (no slashes) intended case-sensitive → it imports asgiand matches case-insensitively.Suggested fix
Map ST's full regex option set: read
markdownOnly/substituteRegex/runOnEditand ST's "Only Format Prompt" to setpromptOnly/display vs prompt scope faithfully; map all ST placements (or at least preserve unknown ones rather than collapsing to AI-output); and derive flags only from the source — do not forcei/gonto a bare source that didn't have them (default to the ST-equivalent flag set, notgi).Environment
b826f8f4)Additional context
Found via a systematic multi-agent audit of import/export round-trips. Affects ST cards/users who rely on embedded regex scripts. Part of a set of import/export fidelity issues filed together.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@kolacheee commented on GitHub (Jun 21, 2026):
Clarification after reading the code (packages/server/src/services/import/st-character.importer.ts, packages/shared/src/types/regex.ts, packages/server/src/db/schema/regex-scripts.ts, packages/server/src/services/regex/regex-application.ts):
ST semantics correction in the repro.
markdownOnly:falsedoes NOT mean "prompt-affecting." In SillyTavern the prompt-scope flag ispromptOnly:true;markdownOnly:false+promptOnly:falsemeans "alter the actual message" (affects display AND prompt, and persists). The genuine scope inversion here is: an ST script withpromptOnly:trueimports as display-only because line 148 hardcodespromptOnly: false. Please reword the first repro step to: "Import a script withpromptOnly:true-> it imports as display-only (line 148 hardcodespromptOnly: false)."Model limitation (fixable scope vs out-of-scope). Marinara's regex model cannot represent several of these options:
RegexPlacementis only"ai_output" | "user_input"(regex.ts:6 — no slash-command/world-info/reasoning), and neither theRegexScripttype nor the Drizzle table (db/schema/regex-scripts.ts) hasmarkdownOnly/substituteRegex/runOnEditfields. Marinara also always macro-substitutes the find pattern (regex-application.ts:110 callsresolveScriptStringonfindRegexunconditionally), sosubstituteRegexis effectively always-ON, not "dropped." So the fixable-in-the-importer parts are: (a) setpromptOnlyfrom ST'spromptOnlyinstead of hardcodingfalse; (b) stop collapsing unknown placements toai_output(line 137) — skip the unrepresentable placement/script rather than silently remapping; (c) fix the flags (see #3). Mapping the remaining ST options (markdownOnly/substituteRegex/runOnEdit, and non-1/2 placements) requires extending the data model (type + zod + DB schema + apply logic) and should be split into a separate model-extension issue rather than implied as a simple "map all options" fix.Flags scope is broader than the repro states. The
|| "gi"fallback (line 129) fires for ANY pattern with empty flags, not just a bare (slash-less) source. A delimited ST pattern with no flags —/pattern/, the common ST form — also gets forced togi(verified against the exact code:/Hello/-> flags "gi";/Hello/g-> "g";Hello-> "gi"). In ST,/pattern/means case-sensitive + first-match-only; importing it asgiflips BOTH case sensitivity and match count. This is the highest-impact, clearly-correct part of the fix: derive flags only from the source and do not forceiorg. Note this will change current import output (ST scripts withoutgbecome first-match-only) — that is the intended correction, not a regression.@SpicyMarinara commented on GitHub (Jun 21, 2026):
Addressed in branch
codex/spicy-issue-sweep-2026-06-21.What changed:
promptOnlyfrom ST-style prompt-only fields instead of hardcoding display-only behavior./pattern/and barepatternnow import with no flags instead of being forced togi;/pattern/gstaysg.ai_output.Skipped by design:
markdownOnly,runOnEdit, and non-user/non-AI placements require extending Marinara's regex data model and apply logic; this importer fix avoids corrupting them into different behavior.Final repo checks will run after the full issue sweep.