[PR #7657] [MERGED] feat(director): make the Secret Plot prompt editable #7860

Closed
opened 2026-10-24 04:08:13 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7657
Author: @stonebystone
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/secret-plot-prompt


📝 Commits (5)

  • cd8325c feat(director): make the Secret Plot prompt editable
  • c6a6e30 fix(director): label the Secret Plot prompt field and name the required arc fields
  • eec46b0 test(director): cover the Secret Plot reroll route with a custom prompt
  • 5a0c70a Merge branch 'staging' into feat/secret-plot-prompt
  • 5fb4fff fix(backup): exempt only the known Secret Plot settings from redaction

📊 Changes

8 files changed (+160 additions, -13 deletions)

View changed files

📝 docs/roleplay/narrative-director.md (+16 -0)
📝 packages/client/src/components/agents/AgentEditor.tsx (+69 -0)
📝 packages/client/src/localization/locales/en.json (+2 -0)
📝 packages/server/src/routes/backup.routes.ts (+4 -1)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+2 -9)
📝 packages/server/src/services/generation/director-secret-plot-runtime.ts (+7 -1)
📝 scripts/regressions/agent-retry-batching.regression.ts (+37 -2)
📝 scripts/regressions/prompt.regression.ts (+23 -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 #7655

cc @SpicyMarinara (I can't assign PRs from this account)

Why this change

  • The Narrative Director's direction prompt is editable, but the prompt that writes and maintains the Secret Plot arc is hard-coded. Every arc gets framed as a mystery to uncover, and a new arc is generated whenever one completes. That works for adventure and intrigue, but it pushes character-driven roleplay toward conspiracy plots. Right now the only alternative is turning Secret Plot off.

What changed

  • Agent Editor, Narrative Director → Secret Plot: new Secret Plot Prompt field. It shows the built-in prompt read-only until you click Copy default to edit; Reset to default returns to the built-in one. It's saved as settings.secretPlotPromptTemplate. It isn't saved when blank or when it's an unedited copy of the built-in prompt, so future changes to the default still reach those users. The field shows whether the agent-level Secret Plot toggle is on or off, because chats can switch Secret Plot on themselves.
  • Server: the new resolveDirectorSecretPlotPromptTemplate uses the agent's custom prompt and falls back to NARRATIVE_DIRECTOR_SECRET_PLOT_PROMPT. buildDirectorSecretPlotAgent uses it. The secret-plot reroll path in retry-agents-route.ts now calls buildDirectorSecretPlotAgent instead of an inline copy of the same object. Behavior is unchanged apart from the prompt lookup.
  • Profile export/backup: redactAgentSecrets nulled every agent setting whose key contains "secret". That already wiped secretPlotEnabled and secretPlotRunInterval from exported profiles, and it would have wiped the new prompt too. The three Secret Plot settings (secretPlotEnabled, secretPlotRunInterval, secretPlotPromptTemplate) are now exempted by name; every other matching key, including any other secretPlot* key, is still redacted.
  • Docs: docs/roleplay/narrative-director.md gets a "Secret Plot prompt" subsection.
  • Regression: prompt.regression.ts checks the built-in fallback (missing and blank) and the custom prompt, and that the result type stays secret_plot.
  • Localization: two new English keys (secretPlotPrompt, secretPlotPromptHelp); the existing "Copy default to edit" and "Reset to default" keys are reused.

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

Commands run by the agent in a clean worktree off origin/staging (07b0a11e7):

  • pnpm check: passed. The one lint warning is pre-existing, in HomeProfessorMariChat.tsx:378.
  • pnpm localization:check: passed.
  • pnpm regression:prompt: passed (prompt, prompt-attachments and context-fit).
  • The CodeRabbit CLI isn't available on this machine, so the local review was done by an independent review agent instead. It found two issues, both fixed here: the backup-redaction loss and the frozen-copy-of-default problem. It also confirmed that every Secret Plot run path goes through buildDirectorSecretPlotAgent, and that agent settings reach it unstripped.

Manual verification notes

The agent ran these checks on a local test instance of this branch (commit cd8325c24), started on port 7871 against a copy of a real profile:

  1. The field shows with Secret Plot off. Agents → Narrative Director → Secret Plot displays the Secret Plot Prompt with the built-in text, read-only, and a Copy default to edit button.
  2. An edit persists. Copy default to edit, then rewriting the prompt and saving, stored the text exactly as typed. The other Director settings were unchanged, and the edit reloaded after a page refresh.
  3. An unedited copy isn't stored. Copy default to edit followed by Save without changes stores nothing, and the field returns to the read-only default.
  4. Arc maintenance uses the custom prompt. In a Roleplay chat with Secret Plot on (interval 1), a new message triggered maintenance. With debug logging on, the Director's request contained the custom prompt in full and none of the built-in "preserve its core mystery" text.
  5. Regenerate uses it too. The panel's Regenerate request (/generate/retry-agents, secretPlotRerollMode: "full") also sent the custom prompt.
  6. Reset to default removes it. Reset to default followed by Save removes secretPlotPromptTemplate from the stored settings.
  7. Profile export keeps it. The native ZIP export keeps secretPlotPromptTemplate, secretPlotEnabled and secretPlotRunInterval, while a test testApiKey setting was still blanked.
  8. Mobile. At 375 px wide the field stacks under Run Interval, and Reset to default fits on the label row.

Light mode was checked by hand and looks fine.

Not verified:

  • Containers. These were left to CI.
  • The later commits only add an accessible label, shorten the help text, narrow the export exemption to the three settings by name, and add a retry-route regression. The click-through wasn't repeated after them. pnpm check and the regressions were.

Screenshots of checks 1, 2 and 8 are attached under UI evidence.

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)

Docs: docs/roleplay/narrative-director.md was updated. Translations are tracked in the follow-up issue #7658.

UI evidence (if applicable)

1-default-readonly-secret-plot-off 2-custom-prompt-editing 3-mobile-secret-plot-on

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Narrative Director agents can use a custom Secret Plot prompt, saved with the agent and applied across its chats.
    • View the built-in prompt, copy it into the editor to customize, or clear the field to restore the built-in prompt.
    • Custom prompts are retained in agent exports and backups, and Secret Plot replies keep the required JSON format during retries.
  • Documentation
    • Added guidance on customizing and restoring the Secret Plot prompt.

🔄 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/7657 **Author:** [@stonebystone](https://github.com/stonebystone) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/secret-plot-prompt` --- ### 📝 Commits (5) - [`cd8325c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cd8325c2400083c1675cd46e5e7d2c855c640368) feat(director): make the Secret Plot prompt editable - [`c6a6e30`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c6a6e300eec823b91d03ab03be728917a4b14f94) fix(director): label the Secret Plot prompt field and name the required arc fields - [`eec46b0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/eec46b094408a80113b3a79bd3c87ad06aa0e8ee) test(director): cover the Secret Plot reroll route with a custom prompt - [`5a0c70a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5a0c70ac3e89d485a42612f90984dbd3633c431a) Merge branch 'staging' into feat/secret-plot-prompt - [`5fb4fff`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5fb4fff9bebf281fa36375a7cb8fe376bedaa239) fix(backup): exempt only the known Secret Plot settings from redaction ### 📊 Changes **8 files changed** (+160 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `docs/roleplay/narrative-director.md` (+16 -0) 📝 `packages/client/src/components/agents/AgentEditor.tsx` (+69 -0) 📝 `packages/client/src/localization/locales/en.json` (+2 -0) 📝 `packages/server/src/routes/backup.routes.ts` (+4 -1) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+2 -9) 📝 `packages/server/src/services/generation/director-secret-plot-runtime.ts` (+7 -1) 📝 `scripts/regressions/agent-retry-batching.regression.ts` (+37 -2) 📝 `scripts/regressions/prompt.regression.ts` (+23 -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`. ## Linked issue Closes #7655 cc @SpicyMarinara (I can't assign PRs from this account) ## Why this change - The Narrative Director's direction prompt is editable, but the prompt that writes and maintains the Secret Plot arc is hard-coded. Every arc gets framed as a mystery to uncover, and a new arc is generated whenever one completes. That works for adventure and intrigue, but it pushes character-driven roleplay toward conspiracy plots. Right now the only alternative is turning Secret Plot off. ## What changed - **Agent Editor, Narrative Director → Secret Plot:** new **Secret Plot Prompt** field. It shows the built-in prompt read-only until you click **Copy default to edit**; **Reset to default** returns to the built-in one. It's saved as `settings.secretPlotPromptTemplate`. It isn't saved when blank or when it's an unedited copy of the built-in prompt, so future changes to the default still reach those users. The field shows whether the agent-level Secret Plot toggle is on or off, because chats can switch Secret Plot on themselves. - **Server:** the new `resolveDirectorSecretPlotPromptTemplate` uses the agent's custom prompt and falls back to `NARRATIVE_DIRECTOR_SECRET_PLOT_PROMPT`. `buildDirectorSecretPlotAgent` uses it. The secret-plot reroll path in `retry-agents-route.ts` now calls `buildDirectorSecretPlotAgent` instead of an inline copy of the same object. Behavior is unchanged apart from the prompt lookup. - **Profile export/backup:** `redactAgentSecrets` nulled every agent setting whose key contains "secret". That already wiped `secretPlotEnabled` and `secretPlotRunInterval` from exported profiles, and it would have wiped the new prompt too. The three Secret Plot settings (`secretPlotEnabled`, `secretPlotRunInterval`, `secretPlotPromptTemplate`) are now exempted by name; every other matching key, including any other `secretPlot*` key, is still redacted. - **Docs:** `docs/roleplay/narrative-director.md` gets a "Secret Plot prompt" subsection. - **Regression:** `prompt.regression.ts` checks the built-in fallback (missing and blank) and the custom prompt, and that the result type stays `secret_plot`. - Localization: two new English keys (`secretPlotPrompt`, `secretPlotPromptHelp`); the existing "Copy default to edit" and "Reset to default" keys are reused. ## Validation - [x] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` Commands run by the agent in a clean worktree off `origin/staging` (`07b0a11e7`): - `pnpm check`: passed. The one lint warning is pre-existing, in `HomeProfessorMariChat.tsx:378`. - `pnpm localization:check`: passed. - `pnpm regression:prompt`: passed (prompt, prompt-attachments and context-fit). - The CodeRabbit CLI isn't available on this machine, so the local review was done by an independent review agent instead. It found two issues, both fixed here: the backup-redaction loss and the frozen-copy-of-default problem. It also confirmed that every Secret Plot run path goes through `buildDirectorSecretPlotAgent`, and that agent settings reach it unstripped. ### Manual verification notes The agent ran these checks on a local test instance of this branch (commit `cd8325c24`), started on port 7871 against a copy of a real profile: 1. **The field shows with Secret Plot off.** Agents → Narrative Director → Secret Plot displays the Secret Plot Prompt with the built-in text, read-only, and a **Copy default to edit** button. 2. **An edit persists.** Copy default to edit, then rewriting the prompt and saving, stored the text exactly as typed. The other Director settings were unchanged, and the edit reloaded after a page refresh. 3. **An unedited copy isn't stored.** Copy default to edit followed by Save without changes stores nothing, and the field returns to the read-only default. 4. **Arc maintenance uses the custom prompt.** In a Roleplay chat with Secret Plot on (interval 1), a new message triggered maintenance. With debug logging on, the Director's request contained the custom prompt in full and none of the built-in "preserve its core mystery" text. 5. **Regenerate uses it too.** The panel's Regenerate request (`/generate/retry-agents`, `secretPlotRerollMode: "full"`) also sent the custom prompt. 6. **Reset to default removes it.** Reset to default followed by Save removes `secretPlotPromptTemplate` from the stored settings. 7. **Profile export keeps it.** The native ZIP export keeps `secretPlotPromptTemplate`, `secretPlotEnabled` and `secretPlotRunInterval`, while a test `testApiKey` setting was still blanked. 8. **Mobile.** At 375 px wide the field stacks under Run Interval, and Reset to default fits on the label row. Light mode was checked by hand and looks fine. Not verified: - **Containers.** These were left to CI. - **The later commits** only add an accessible label, shorten the help text, narrow the export exemption to the three settings by name, and add a retry-route regression. The click-through wasn't repeated after them. `pnpm check` and the regressions were. Screenshots of checks 1, 2 and 8 are attached under UI evidence. ## Docs and release impact - [ ] No docs changes needed - [x] 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) Docs: `docs/roleplay/narrative-director.md` was updated. Translations are tracked in the follow-up issue #7658. ## UI evidence (if applicable) <img width="800" height="514" alt="1-default-readonly-secret-plot-off" src="https://github.com/user-attachments/assets/56d2b796-8dfd-43db-90a2-9d6164a67eec" /> <img width="800" height="514" alt="2-custom-prompt-editing" src="https://github.com/user-attachments/assets/c20cce6f-60c1-4e3b-a6fa-dc788f0bf3ae" /> <img width="750" height="1624" alt="3-mobile-secret-plot-on" src="https://github.com/user-attachments/assets/365db480-9866-407e-bebc-cb5095f5527d" /> 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Narrative Director agents can use a custom Secret Plot prompt, saved with the agent and applied across its chats. * View the built-in prompt, copy it into the editor to customize, or clear the field to restore the built-in prompt. * Custom prompts are retained in agent exports and backups, and Secret Plot replies keep the required JSON format during retries. * **Documentation** * Added guidance on customizing and restoring the Secret Plot prompt. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:08:13 +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#7860
No description provided.