[PR #8660] [MERGED] feat(scene): draft a premise and opening for a new chat (scenario setup 1/5) #8730

Closed
opened 2026-11-07 17:39:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8660
Author: @Gunterlie
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @Gunterlie

Base: scenarios-for-hoes ← Head: scenarios/01-draft-route


📝 Commits (5)

  • 2bf2d4a feat(scene): draft a premise and opening for a new chat
  • c68d649 fix(scene): narrow parsed scenario opening
  • b0d1ee3 style(scene): format scenario draft route
  • 718da6e fix(scene): tighten scenario draft input checks
  • 375ef00 fix(scene): keep the opening speaker when revising

📊 Changes

3 files changed (+194 additions, -0 deletions)

View changed files

📝 packages/server/src/routes/scene.routes.ts (+144 -0)
📝 packages/shared/src/types/scene.ts (+20 -0)
➕ scripts/regressions/scene-scenario-draft.regression.ts (+30 -0)

📄 Description

Why

Starting a new roleplay or conversation with a character you like still takes work: you have to invent the situation and write a good first message. Game mode can already invent a setup; normal chats cannot. This feature lets the user describe what they are in the mood for, preview a premise and an opening, edit them, and start the chat.

This is part 1 of 5 of the scenario setup feature. Every part goes into the feature branch scenarios-for-hoes as its own reviewed PR; one feature PR then brings the whole branch into staging. There is no linked issue: this is planned work, tracked by the PR series.

What changed

  • New route POST /scene/scenario-draft. It drafts { premise, opening: { characterId, content } } for a chat that already exists (the setup wizard creates the empty chat first).
  • Nothing is saved. The route only reads the chat, characters and persona, then makes one model call. Part 2 (wizard UI) writes the approved draft.
  • Roleplay chats get a narrated opening. Conversation chats get a short, natural first text. Game chats are rejected.
  • The premise holds lasting facts only and must not invent the user's actions or feelings.
  • Onboarding answers reach the prompt: character fields are resolved with the chat's macro variables (resolveMacrosForPreview on a copied macro context, so no chat state changes).
  • revise regenerates only the premise or only the opening. Code returns the other part byte-identical; the opening keeps its speaker.
  • Input checks: idea and note ≤ 4000 characters, current draft texts ≤ 8000, note must be text, opener must be a chat member.
  • Final prompt is logged with logDebugOverride (debug mode / DEBUG_AGENTS).
  • Shared types SceneScenarioDraft, SceneScenarioDraftRequest, SceneScenarioDraftResponse.
  • Regression scripts/regressions/scene-scenario-draft.regression.ts for the parser (valid, fenced, empty, malformed, missing opening, revise keeps the other part).

Validation

  • pnpm check passed (before the last one-line fix); after the fix: server tsc --noEmit passed, Prettier passed, the new regression passed.
  • Local CodeRabbit: 1 finding (revised opening lost its speaker in group chats), fixed.
  • Opus review: no blockers; 6 findings fixed (size limits, premise revision sees the kept opening, opener membership, note type, game chats, token budget).

Manual verification

  • Call the route against a real model for a roleplay chat and check the premise/opening JSON.
  • Call it for a conversation chat and check the opening reads like a text message.
  • Call it with revise.part = "opening" on a group chat and check the speaker stays the same.

Not done: no UI in this PR, and no real-model call yet.


🔄 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/8660 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `scenarios-for-hoes` ← **Head:** `scenarios/01-draft-route` --- ### 📝 Commits (5) - [`2bf2d4a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2bf2d4a359183439ec6a9e1111174eccaeaebd7a) feat(scene): draft a premise and opening for a new chat - [`c68d649`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c68d649148814792f3d0e76e2f06b8330c34660f) fix(scene): narrow parsed scenario opening - [`b0d1ee3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b0d1ee3537eb0d7cd57fd1c051f088be17312245) style(scene): format scenario draft route - [`718da6e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/718da6e1310adcedd5b78c2dbd2b1751feae8cc3) fix(scene): tighten scenario draft input checks - [`375ef00`](https://github.com/Pasta-Devs/Marinara-Engine/commit/375ef00c9bfffc37dc2aaf407b7a87696f7b119f) fix(scene): keep the opening speaker when revising ### 📊 Changes **3 files changed** (+194 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/scene.routes.ts` (+144 -0) 📝 `packages/shared/src/types/scene.ts` (+20 -0) ➕ `scripts/regressions/scene-scenario-draft.regression.ts` (+30 -0) </details> ### 📄 Description ## Why Starting a new roleplay or conversation with a character you like still takes work: you have to invent the situation and write a good first message. Game mode can already invent a setup; normal chats cannot. This feature lets the user describe what they are in the mood for, preview a premise and an opening, edit them, and start the chat. This is **part 1 of 5** of the scenario setup feature. Every part goes into the feature branch `scenarios-for-hoes` as its own reviewed PR; one feature PR then brings the whole branch into `staging`. There is no linked issue: this is planned work, tracked by the PR series. ## What changed - New route `POST /scene/scenario-draft`. It drafts `{ premise, opening: { characterId, content } }` for a chat that already exists (the setup wizard creates the empty chat first). - **Nothing is saved.** The route only reads the chat, characters and persona, then makes one model call. Part 2 (wizard UI) writes the approved draft. - Roleplay chats get a narrated opening. Conversation chats get a short, natural first text. Game chats are rejected. - The premise holds lasting facts only and must not invent the user's actions or feelings. - Onboarding answers reach the prompt: character fields are resolved with the chat's macro variables (`resolveMacrosForPreview` on a copied macro context, so no chat state changes). - `revise` regenerates only the premise or only the opening. Code returns the other part byte-identical; the opening keeps its speaker. - Input checks: idea and note ≤ 4000 characters, current draft texts ≤ 8000, note must be text, opener must be a chat member. - Final prompt is logged with `logDebugOverride` (debug mode / `DEBUG_AGENTS`). - Shared types `SceneScenarioDraft`, `SceneScenarioDraftRequest`, `SceneScenarioDraftResponse`. - Regression `scripts/regressions/scene-scenario-draft.regression.ts` for the parser (valid, fenced, empty, malformed, missing opening, revise keeps the other part). ## Validation - `pnpm check` passed (before the last one-line fix); after the fix: server `tsc --noEmit` passed, Prettier passed, the new regression passed. - Local CodeRabbit: 1 finding (revised opening lost its speaker in group chats), fixed. - Opus review: no blockers; 6 findings fixed (size limits, premise revision sees the kept opening, opener membership, note type, game chats, token budget). ## Manual verification - [ ] Call the route against a real model for a roleplay chat and check the premise/opening JSON. - [ ] Call it for a conversation chat and check the opening reads like a text message. - [ ] Call it with `revise.part = "opening"` on a group chat and check the speaker stays the same. Not done: no UI in this PR, and no real-model call yet. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:39:17 +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#8730
No description provided.