[PR #8543] [MERGED] feat(characters): split a character's description into its fields #8663

Closed
opened 2026-11-07 16:46:19 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8543
Author: @Promansis
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @Promansis

Base: staging ← Head: feature(characters)/split-description-fields


📝 Commits (10+)

  • 463c3a1 feat(characters): split description into fields (WIP)
  • d49d9c4 Merge upstream/staging into feature(characters)/split-description-fields
  • 83262e2 feat(bot-browser): offer the description split on downloaded cards
  • ef772fd feat(characters): split one-line PList cards
  • 27db358 feat(characters): save description splits as a new card version
  • 2643833 feat(characters): show the split summary after imports and warn about keyword-sorted prose
  • 769277c fix(characters): split interview profiles, persona W++ prefixes, bare PLists and {{char}} chat lines
  • cd2f169 Merge upstream/staging into feature(characters)/split-description-fields
  • 7f74a5a fix(characters): keep the description splitter linear on crafted lines
  • 5d10dae Merge branch 'staging' into feature(characters)/split-description-fields

📊 Changes

14 files changed (+2633 additions, -12 deletions)

View changed files

📝 packages/client/src/components/bot-browser/BotBrowserView.tsx (+101 -2)
📝 packages/client/src/components/characters/CharacterEditor.tsx (+78 -3)
➕ packages/client/src/components/characters/DescriptionSplitDialog.tsx (+165 -0)
📝 packages/client/src/components/modals/ImportCharacterModal.tsx (+103 -2)
➕ packages/client/src/lib/description-split-mari.ts (+15 -0)
📝 packages/client/src/localization/locales/en.json (+44 -0)
📝 packages/client/vite.config.ts (+4 -0)
📝 packages/server/src/routes/characters.routes.ts (+11 -5)
📝 packages/server/src/routes/import.routes.ts (+15 -0)
📝 packages/server/src/services/import/st-character.importer.ts (+34 -0)
📝 packages/shared/src/index.ts (+1 -0)
➕ packages/shared/src/utils/character-description-split.ts (+1610 -0)
➕ scripts/regressions/character-description-split-version.regression.ts (+99 -0)
➕ scripts/regressions/character-description-split.regression.ts (+353 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #8542

Why this change

  • Many downloaded cards put personality, appearance, backstory, scenario, instructions and example dialogue into the description. The Engine's separate fields stay empty, and the description is one block that is hard to edit.
  • Sorting a card by hand risks losing lines and does not scale to a library. This adds an optional, lossless split where cards arrive and in the editor.

What changed

  • Deterministic splitter in packages/shared/src/utils/character-description-split.ts. It recognises labelled sections, Markdown headings, W++ and PList trait lists (bracketed or bare, one-line, {{char}}'s persona prefixes), JSON-style blocks, wrapper tags, {{user}}:/{{char}}: dialogue and <START> blocks. It moves text verbatim, and every line lands in exactly one field.
  • Interview profiles. In a {{user}}: Personality? / Appearance? / Past? interview, each answer goes to the field its question names. "Introduction?" names the description. A dialogue run with no field question becomes example dialogue.
  • Safe defaults. Narrator cards, multi-character cards and empty descriptions are skipped unless the user forces the split. When unlabelled prose was sorted by its wording, the result is flagged and the summary shows a warning.
  • Three entry points. A checkbox in the character import window, a checkbox in the Bot Browser download dialog for characters and personas, and an editor button next to version history that previews the split before applying it.
  • Version history. Every split is saved as a new card version with the source description-split, so the original stays one click away. PATCH /api/characters/personas/:id accepts versionSource/versionReason for the Bot Browser persona path.
  • Summary dialog after imports: which fields were filled, the keyword-sorting warning, and an "Ask Professor Mari" button for characters.
  • The splitter has its own client chunk in vite.config.ts because the shared chunk was near its size budget. New UI copy uses localization keys in en.json.
import window / Bot Browser / editor button
  splitCharacterDescription(card)            # packages/shared
    tokenize -> mark examples & interviews -> assign fields
    -> { status, changed[], after, keywordSorted }
  save as new card version (source "description-split")
  DescriptionSplitDialog (preview or "applied" summary)

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Agent-run checks on 6ebbb0b65 (current staging merged at 5d10dae89). The boxes above are left for the human contributor.

pnpm check                                                      exit 0 (one existing lint warning, HomeProfessorMariChat.tsx:428)
node ./scripts/run-regressions.mjs --filter character-description-split   2/2 passed
  character-description-split.regression.ts          layouts, interviews, skips, lossless joins, symbol-only text, crafted long lines < 2 s
  character-description-split-version.regression.ts  split saved as a new version, unversioned cards

Corpus checks with throwaway probes outside the repository:

Corpus Result
Local library, 564 readable cards 557 match the existing normalizer script field for field. Six differences are better PList and code-fence handling; the seventh is an interview card whose answers now land in description, personality and appearance. No lost text.
Public Pygmalion cards, 182 Interview answers land in their named fields. Unquoted {{char}}: chat and bare PLists are recognised. No lost text.

ReDoS fixes (CodeQL #684–#686)

7f74a5a97 replaces the three flagged regexes, plus further super-linear ones that fuzzing found: trailing-whitespace tidy, the #/==/[[ ]]/bold heading patterns and the name: scans. Output matches the old regexes on 400k random heading strings and an exhaustive bold-heading sweep. Library and Pygmalion results are unchanged.

631ddd921 fixes Dottore's three findings. The [Label: bracket heading regex was exponential on a run of {{macros}} (22 macros: 100 ms, doubling per macro). The spoken-quote check was cubic on an unclosed quote (2k words: 3.9 s). Text with no letters or digits (..., ♡) was dropped or replaced as already present. a7395b3e7 keeps a bare <START> marker out of that symbol fallback, so a stray marker does not leave an empty example block. The two code helpers match their regexes on 51M exhaustive and random strings. An A/B run over the 564 library cards and the Pygmalion cards shows no output change.

Crafted input Before After
Alerts #684 / #685 / #686, 40k chars 2661 / 1339 / 578 ms ~1 ms
= heading, 10k chars 277 s < 10 ms
Bold heading, 1k chars hangs (cubic) < 10 ms
[ + 40 {{a}} macros exponential (hours) < 1 ms
x " + 2k words, no closing quote 3.9 s 2 ms
Blank lines, 20k 894 ms 78 ms
</ + 20k spaces ~1–2 min est. (cubic; 377 ms at 3.2k) 2 ms
[ + 20k spaces ~1–2 min est. (cubic; 446 ms at 3.2k) 1 ms
<!-- + 20k spaces ~30 min est. (cubic; 7.9 s at 3.2k) 1 ms
< + 20k spaces (plain key: value) 335 ms 3 ms
Personality: + 20k ; (value trim) 333 ms 2 ms
Name: + 20k newlines (name scans) 820 ms 52 ms

69cdec986 fixes the last six padded-label patterns, which a full crafted-input scan found. These are the plain key: value label, </tag>, [Title], <!-- note -->, the value's trailing ]}); trim and the two Name: scans. Each is now read in code, or rewritten with a single padding run, and returns what the old regex returned: 60M exhaustive and random strings show no mismatch. The library and Pygmalion A/B runs show no output change. The scan, which tries 29 line prefixes × 40 fillers × 12 tails at 400 and 1.6k characters, now reports no super-linear pattern. 6ebbb0b65 replaces the two copies of the Name: line regex (collectNames capped values at 60 characters, skipReason at 40) with one shared NAME_LINE_RE capped at 60. skipReason keeps only the first word of each value, so the only possible change is a single word longer than 40 characters with no spaces. The A/B runs show no change.

Manual verification notes

  • Manually verify the import window: import a card with "Split description into fields" ticked. Check that the summary dialog opens, the fields are filled, and version history shows "· description-split".
  • Manually verify the Bot Browser: download a character and a persona with the split checkbox ticked, and check the summary and saved fields.
  • Manually verify an interview card such as Lucoa: personality and appearance are filled, and example dialogue stays empty.
  • Manually verify the editor button: preview, Apply, Split anyway on a skipped card, and Ask Professor Mari.
  • Manually verify that the keyword-sorting warning appears on a prose-only card.
  • Manually verify the dialog in light and dark mode and at a mobile width.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

No files under docs/ change. No version bump and no CHANGELOG entry.

Merge danger

Door: two-way. The split is opt-in at every entry point, and each split is a new card version that version history can restore.

Blast radius: contained. Imports without the checkbox behave as before. The shared touch points are the import route's new flag, the persona PATCH's optional version fields and a separate client chunk.

UI evidence (if applicable)

Screenshots still to add: the import checkbox, the Bot Browser checkbox, the editor preview and the applied summary with the warning.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8543 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `staging` ← **Head:** `feature(characters)/split-description-fields` --- ### 📝 Commits (10+) - [`463c3a1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/463c3a1d3571a287af5ac5640a2f806f20ba14e6) feat(characters): split description into fields (WIP) - [`d49d9c4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d49d9c4000f4db44fe1707f8807e528445cfe18b) Merge upstream/staging into feature(characters)/split-description-fields - [`83262e2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/83262e237b517979bd97666dfb3b491eafc7b83b) feat(bot-browser): offer the description split on downloaded cards - [`ef772fd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ef772fd3afeb996fe3e1b691041b0e4573c6515a) feat(characters): split one-line PList cards - [`27db358`](https://github.com/Pasta-Devs/Marinara-Engine/commit/27db358346cf6453b23928c1d1c16573940e447c) feat(characters): save description splits as a new card version - [`2643833`](https://github.com/Pasta-Devs/Marinara-Engine/commit/26438336cf23be288ffcad7716c9f34bafff4280) feat(characters): show the split summary after imports and warn about keyword-sorted prose - [`769277c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/769277c62084c1cbafb8e0b74d8005ba823ef4d0) fix(characters): split interview profiles, persona W++ prefixes, bare PLists and {{char}} chat lines - [`cd2f169`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cd2f169d06019391e644d23f5508bd1bda80363e) Merge upstream/staging into feature(characters)/split-description-fields - [`7f74a5a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7f74a5a97b256d48ba81b26409c2e865f49bf61c) fix(characters): keep the description splitter linear on crafted lines - [`5d10dae`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5d10dae89cc616054eab482ee38207233c87d00c) Merge branch 'staging' into feature(characters)/split-description-fields ### 📊 Changes **14 files changed** (+2633 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/bot-browser/BotBrowserView.tsx` (+101 -2) 📝 `packages/client/src/components/characters/CharacterEditor.tsx` (+78 -3) ➕ `packages/client/src/components/characters/DescriptionSplitDialog.tsx` (+165 -0) 📝 `packages/client/src/components/modals/ImportCharacterModal.tsx` (+103 -2) ➕ `packages/client/src/lib/description-split-mari.ts` (+15 -0) 📝 `packages/client/src/localization/locales/en.json` (+44 -0) 📝 `packages/client/vite.config.ts` (+4 -0) 📝 `packages/server/src/routes/characters.routes.ts` (+11 -5) 📝 `packages/server/src/routes/import.routes.ts` (+15 -0) 📝 `packages/server/src/services/import/st-character.importer.ts` (+34 -0) 📝 `packages/shared/src/index.ts` (+1 -0) ➕ `packages/shared/src/utils/character-description-split.ts` (+1610 -0) ➕ `scripts/regressions/character-description-split-version.regression.ts` (+99 -0) ➕ `scripts/regressions/character-description-split.regression.ts` (+353 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #8542 ## Why this change - Many downloaded cards put personality, appearance, backstory, scenario, instructions and example dialogue into the description. The Engine's separate fields stay empty, and the description is one block that is hard to edit. - Sorting a card by hand risks losing lines and does not scale to a library. This adds an optional, lossless split where cards arrive and in the editor. ## What changed - **Deterministic splitter** in `packages/shared/src/utils/character-description-split.ts`. It recognises labelled sections, Markdown headings, W++ and PList trait lists (bracketed or bare, one-line, `{{char}}'s persona` prefixes), JSON-style blocks, wrapper tags, `{{user}}:`/`{{char}}:` dialogue and `<START>` blocks. It moves text verbatim, and every line lands in exactly one field. - **Interview profiles.** In a `{{user}}: Personality?` / `Appearance?` / `Past?` interview, each answer goes to the field its question names. "Introduction?" names the description. A dialogue run with no field question becomes example dialogue. - **Safe defaults.** Narrator cards, multi-character cards and empty descriptions are skipped unless the user forces the split. When unlabelled prose was sorted by its wording, the result is flagged and the summary shows a warning. - **Three entry points.** A checkbox in the character import window, a checkbox in the Bot Browser download dialog for characters and personas, and an editor button next to version history that previews the split before applying it. - **Version history.** Every split is saved as a new card version with the source `description-split`, so the original stays one click away. `PATCH /api/characters/personas/:id` accepts `versionSource`/`versionReason` for the Bot Browser persona path. - **Summary dialog** after imports: which fields were filled, the keyword-sorting warning, and an "Ask Professor Mari" button for characters. - The splitter has its own client chunk in `vite.config.ts` because the shared chunk was near its size budget. New UI copy uses localization keys in `en.json`. ```text import window / Bot Browser / editor button splitCharacterDescription(card) # packages/shared tokenize -> mark examples & interviews -> assign fields -> { status, changed[], after, keywordSorted } save as new card version (source "description-split") DescriptionSplitDialog (preview or "applied" summary) ``` ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Agent-run checks on `6ebbb0b65` (current `staging` merged at `5d10dae89`). The boxes above are left for the human contributor. ```text pnpm check exit 0 (one existing lint warning, HomeProfessorMariChat.tsx:428) node ./scripts/run-regressions.mjs --filter character-description-split 2/2 passed character-description-split.regression.ts layouts, interviews, skips, lossless joins, symbol-only text, crafted long lines < 2 s character-description-split-version.regression.ts split saved as a new version, unversioned cards ``` Corpus checks with throwaway probes outside the repository: | Corpus | Result | | --- | --- | | Local library, 564 readable cards | 557 match the existing normalizer script field for field. Six differences are better PList and code-fence handling; the seventh is an interview card whose answers now land in description, personality and appearance. No lost text. | | Public Pygmalion cards, 182 | Interview answers land in their named fields. Unquoted `{{char}}:` chat and bare PLists are recognised. No lost text. | ### ReDoS fixes (CodeQL #684–#686) `7f74a5a97` replaces the three flagged regexes, plus further super-linear ones that fuzzing found: trailing-whitespace tidy, the `#`/`==`/`[[ ]]`/bold heading patterns and the `name:` scans. Output matches the old regexes on 400k random heading strings and an exhaustive bold-heading sweep. Library and Pygmalion results are unchanged. `631ddd921` fixes Dottore's three findings. The `[Label:` bracket heading regex was exponential on a run of `{{macros}}` (22 macros: 100 ms, doubling per macro). The spoken-quote check was cubic on an unclosed quote (2k words: 3.9 s). Text with no letters or digits (`...`, `♡`) was dropped or replaced as already present. `a7395b3e7` keeps a bare `<START>` marker out of that symbol fallback, so a stray marker does not leave an empty example block. The two code helpers match their regexes on 51M exhaustive and random strings. An A/B run over the 564 library cards and the Pygmalion cards shows no output change. | Crafted input | Before | After | | --- | --- | --- | | Alerts #684 / #685 / #686, 40k chars | 2661 / 1339 / 578 ms | ~1 ms | | `=` heading, 10k chars | 277 s | < 10 ms | | Bold heading, 1k chars | hangs (cubic) | < 10 ms | | `[` + 40 `{{a}}` macros | exponential (hours) | < 1 ms | | `x "` + 2k words, no closing quote | 3.9 s | 2 ms | | Blank lines, 20k | 894 ms | 78 ms | | `</` + 20k spaces | ~1–2 min est. (cubic; 377 ms at 3.2k) | 2 ms | | `[` + 20k spaces | ~1–2 min est. (cubic; 446 ms at 3.2k) | 1 ms | | `<!--` + 20k spaces | ~30 min est. (cubic; 7.9 s at 3.2k) | 1 ms | | `<` + 20k spaces (plain `key: value`) | 335 ms | 3 ms | | `Personality: ` + 20k `;` (value trim) | 333 ms | 2 ms | | `Name: ` + 20k newlines (name scans) | 820 ms | 52 ms | `69cdec986` fixes the last six padded-label patterns, which a full crafted-input scan found. These are the plain `key: value` label, `</tag>`, `[Title]`, `<!-- note -->`, the value's trailing `]});` trim and the two `Name:` scans. Each is now read in code, or rewritten with a single padding run, and returns what the old regex returned: 60M exhaustive and random strings show no mismatch. The library and Pygmalion A/B runs show no output change. The scan, which tries 29 line prefixes × 40 fillers × 12 tails at 400 and 1.6k characters, now reports no super-linear pattern. `6ebbb0b65` replaces the two copies of the `Name:` line regex (`collectNames` capped values at 60 characters, `skipReason` at 40) with one shared `NAME_LINE_RE` capped at 60. `skipReason` keeps only the first word of each value, so the only possible change is a single word longer than 40 characters with no spaces. The A/B runs show no change. ### Manual verification notes - Manually verify the import window: import a card with "Split description into fields" ticked. Check that the summary dialog opens, the fields are filled, and version history shows "· description-split". - Manually verify the Bot Browser: download a character and a persona with the split checkbox ticked, and check the summary and saved fields. - Manually verify an interview card such as Lucoa: personality and appearance are filled, and example dialogue stays empty. - Manually verify the editor button: preview, Apply, Split anyway on a skipped card, and Ask Professor Mari. - Manually verify that the keyword-sorting warning appears on a prose-only card. - Manually verify the dialog in light and dark mode and at a mobile width. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) No files under `docs/` change. No version bump and no CHANGELOG entry. ## Merge danger **Door:** two-way. The split is opt-in at every entry point, and each split is a new card version that version history can restore. **Blast radius:** contained. Imports without the checkbox behave as before. The shared touch points are the import route's new flag, the persona PATCH's optional version fields and a separate client chunk. ## UI evidence (if applicable) Screenshots still to add: the import checkbox, the Bot Browser checkbox, the editor preview and the applied summary with the warning. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:46:19 +07:00
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#8663
No description provided.