[PR #805] [MERGED] Fix assistant command escaped text parsing #4778

Closed
opened 2026-10-22 04:10:34 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/805
Author: @cha1latte
Created: 5/13/2026
Status: ✅ Merged
Merged: 5/13/2026
Merged by: @cha1latte

Base: main ← Head: fix/issue-787-command-parser-quotes


📝 Commits (2)

  • 064eb8c Fix assistant command escaped text parsing
  • f39effb Handle smart quote assistant command params

📊 Changes

2 files changed (+138 additions, -23 deletions)

View changed files

📝 packages/server/src/services/conversation/character-commands.ts (+76 -23)
📝 packages/server/test/character-commands.test.ts (+62 -0)

📄 Description

Linked issue

Closes #787
Closes #799

Why this change

Professor Mari's [update_character] command parser treated an escaped double quote inside a text value as the end of that field. That truncated saved character fields at the first \" and left a trailing backslash.

The same parser path also kept escaped newline sequences as literal \n text instead of converting them to actual line breaks before the update command was persisted.

The adjacent smart-punctuation report showed that assistant commands using curly quote delimiters could parse as no command at all, which made character card writes appear successful from the assistant's point of view while no update reached the card-writing path.

What changed

  • Updated assistant quoted-parameter parsing so escaped quotes and backslash escapes are read as part of the field value.
  • Accepted paired curly/smart quote delimiters for assistant command values while preserving smart punctuation inside the stored text.
  • Decoded common escaped text sequences (\", \\, \n, \r, \t) before command values are stored.
  • Reused the safer quoted-parameter helper for nearby create_persona and update_persona assistant text fields.
  • Added parser regression coverage for quoted values, escaped newlines, backslashes, empty-string clearing, list parsing, and adjacent assistant commands.

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

Manual verification notes

Codex machine verification:

  • Reproduced the original parser failure with pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-787-repro.mjs: before the fix, description parsed as She goes by \ and scenario remained literal First paragraph\n\nSecond paragraph.
  • Re-ran the same scratch repro after the fix; it parsed She goes by "The Bread Witch" and everyone knows it. and First paragraph / Second paragraph separated by real newline characters.
  • Reproduced the smart-punctuation parser failure with pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-799-repro.mjs ../../scratch/issue-799-proof-before.json: before the fix, the smart-quoted [update_character] command parsed as no command (commands: []).
  • Re-ran the same smart-punctuation repro after the fix with pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-799-repro.mjs ../../scratch/issue-799-proof-after.json; it parsed the character name, description, em dash, and alternate greetings.
  • Ran pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/character-commands.test.ts; all 13 parser tests passed.
  • Ran pnpm check; it passed.

No true human-only verification is required for the core claim. This is parser logic with focused command-output proof rather than a visible UI change.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

No docs, release, schema, dependency, or version files changed.

UI evidence (if applicable)

N/A. This is assistant command parser logic, not a visible UI change. Proof is command-output based in the validation notes above.


🔄 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/805 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/13/2026 **Status:** ✅ Merged **Merged:** 5/13/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `main` ← **Head:** `fix/issue-787-command-parser-quotes` --- ### 📝 Commits (2) - [`064eb8c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/064eb8cc653cff92b698b5a4ee4e595fe013be54) Fix assistant command escaped text parsing - [`f39effb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f39effb19f0a29f36b98d01a7c91f7af03f313a3) Handle smart quote assistant command params ### 📊 Changes **2 files changed** (+138 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/conversation/character-commands.ts` (+76 -23) 📝 `packages/server/test/character-commands.test.ts` (+62 -0) </details> ### 📄 Description ## Linked issue Closes #787 Closes #799 ## Why this change Professor Mari's `[update_character]` command parser treated an escaped double quote inside a text value as the end of that field. That truncated saved character fields at the first `\"` and left a trailing backslash. The same parser path also kept escaped newline sequences as literal `\n` text instead of converting them to actual line breaks before the update command was persisted. The adjacent smart-punctuation report showed that assistant commands using curly quote delimiters could parse as no command at all, which made character card writes appear successful from the assistant's point of view while no update reached the card-writing path. ## What changed - Updated assistant quoted-parameter parsing so escaped quotes and backslash escapes are read as part of the field value. - Accepted paired curly/smart quote delimiters for assistant command values while preserving smart punctuation inside the stored text. - Decoded common escaped text sequences (`\"`, `\\`, `\n`, `\r`, `\t`) before command values are stored. - Reused the safer quoted-parameter helper for nearby `create_persona` and `update_persona` assistant text fields. - Added parser regression coverage for quoted values, escaped newlines, backslashes, empty-string clearing, list parsing, and adjacent assistant commands. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [ ] `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` ### Manual verification notes Codex machine verification: - Reproduced the original parser failure with `pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-787-repro.mjs`: before the fix, `description` parsed as `She goes by \` and `scenario` remained literal `First paragraph\n\nSecond paragraph`. - Re-ran the same scratch repro after the fix; it parsed `She goes by "The Bread Witch" and everyone knows it.` and `First paragraph` / `Second paragraph` separated by real newline characters. - Reproduced the smart-punctuation parser failure with `pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-799-repro.mjs ../../scratch/issue-799-proof-before.json`: before the fix, the smart-quoted `[update_character]` command parsed as no command (`commands: []`). - Re-ran the same smart-punctuation repro after the fix with `pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-799-repro.mjs ../../scratch/issue-799-proof-after.json`; it parsed the character name, description, em dash, and alternate greetings. - Ran `pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/character-commands.test.ts`; all 13 parser tests passed. - Ran `pnpm check`; it passed. No true human-only verification is required for the core claim. This is parser logic with focused command-output proof rather than a visible UI change. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) No docs, release, schema, dependency, or version files changed. ## UI evidence (if applicable) N/A. This is assistant command parser logic, not a visible UI change. Proof is command-output based in the validation notes above. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:10:34 +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#4778
No description provided.