Add Deception System and CYOA features with toggles, custom prompts, and proper injection ordering

This commit is contained in:
Spicy_Marinara
2026-01-10 20:24:41 +01:00
parent 681b8ba2bc
commit 995f3a7a98
15 changed files with 368 additions and 95 deletions
+6 -3
View File
@@ -7,10 +7,13 @@ An immersive RPG extension for browsers that tracks character stats, scene infor
## 🆕 What's New ## 🆕 What's New
### v3.3.3 ### v3.4.0
- Strengthened default prompts to not include user's persona in the characters' section. - Added History Persistance in Edit Trackers that allows you to control how many past trackers in the chat history to include.
- Updated some descriptions for buttons and custom fields. - New mobile displays were added that show all the most important trackers from the panel as small, floating widgets around the RPG Companion button, when the main panel is closed.
- Added CYOA toggle.
- Added Deception System toggle.
- The trackers are no longer sent together with an image generation request.
**Special thanks to all the other contributors for this project:** **Special thanks to all the other contributors for this project:**
Paperboygold, Munimunigamer, Subarashimo, Lilminzyu, Claude, IDeathByte, Chungchandev, Joenunezb, Amauragis, and Tomt610. Paperboygold, Munimunigamer, Subarashimo, Lilminzyu, Claude, IDeathByte, Chungchandev, Joenunezb, Amauragis, and Tomt610.
+26 -1
View File
@@ -377,6 +377,16 @@ async function initUI() {
saveSettings(); saveSettings();
}); });
$('#rpg-toggle-deception').on('change', function() {
extensionSettings.enableDeceptionSystem = $(this).prop('checked');
saveSettings();
});
$('#rpg-toggle-cyoa').on('change', function() {
extensionSettings.enableCYOA = $(this).prop('checked');
saveSettings();
});
$('#rpg-toggle-spotify-music').on('change', function() { $('#rpg-toggle-spotify-music').on('change', function() {
extensionSettings.enableSpotifyMusic = $(this).prop('checked'); extensionSettings.enableSpotifyMusic = $(this).prop('checked');
saveSettings(); saveSettings();
@@ -554,6 +564,18 @@ async function initUI() {
updateFeatureTogglesVisibility(); updateFeatureTogglesVisibility();
}); });
$('#rpg-toggle-show-deception-toggle').on('change', function() {
extensionSettings.showDeceptionToggle = $(this).prop('checked');
saveSettings();
updateFeatureTogglesVisibility();
});
$('#rpg-toggle-show-cyoa-toggle').on('change', function() {
extensionSettings.showCYOAToggle = $(this).prop('checked');
saveSettings();
updateFeatureTogglesVisibility();
});
$('#rpg-toggle-show-spotify-toggle').on('change', function() { $('#rpg-toggle-show-spotify-toggle').on('change', function() {
extensionSettings.showSpotifyToggle = $(this).prop('checked'); extensionSettings.showSpotifyToggle = $(this).prop('checked');
saveSettings(); saveSettings();
@@ -851,6 +873,8 @@ async function initUI() {
$('#rpg-toggle-thoughts-in-chat').prop('checked', extensionSettings.showThoughtsInChat); $('#rpg-toggle-thoughts-in-chat').prop('checked', extensionSettings.showThoughtsInChat);
$('#rpg-toggle-html-prompt').prop('checked', extensionSettings.enableHtmlPrompt); $('#rpg-toggle-html-prompt').prop('checked', extensionSettings.enableHtmlPrompt);
$('#rpg-toggle-dialogue-coloring').prop('checked', extensionSettings.enableDialogueColoring); $('#rpg-toggle-dialogue-coloring').prop('checked', extensionSettings.enableDialogueColoring);
$('#rpg-toggle-deception').prop('checked', extensionSettings.enableDeceptionSystem ?? false);
$('#rpg-toggle-cyoa').prop('checked', extensionSettings.enableCYOA ?? false);
$('#rpg-toggle-spotify-music').prop('checked', extensionSettings.enableSpotifyMusic); $('#rpg-toggle-spotify-music').prop('checked', extensionSettings.enableSpotifyMusic);
$('#rpg-toggle-dynamic-weather').prop('checked', extensionSettings.enableDynamicWeather); $('#rpg-toggle-dynamic-weather').prop('checked', extensionSettings.enableDynamicWeather);
@@ -859,6 +883,8 @@ async function initUI() {
// Feature toggle visibility settings // Feature toggle visibility settings
$('#rpg-toggle-show-html-toggle').prop('checked', extensionSettings.showHtmlToggle ?? true); $('#rpg-toggle-show-html-toggle').prop('checked', extensionSettings.showHtmlToggle ?? true);
$('#rpg-toggle-show-dialogue-coloring-toggle').prop('checked', extensionSettings.showDialogueColoringToggle ?? true); $('#rpg-toggle-show-dialogue-coloring-toggle').prop('checked', extensionSettings.showDialogueColoringToggle ?? true);
$('#rpg-toggle-show-deception-toggle').prop('checked', extensionSettings.showDeceptionToggle ?? true);
$('#rpg-toggle-show-cyoa-toggle').prop('checked', extensionSettings.showCYOAToggle ?? true);
$('#rpg-toggle-show-spotify-toggle').prop('checked', extensionSettings.showSpotifyToggle ?? true); $('#rpg-toggle-show-spotify-toggle').prop('checked', extensionSettings.showSpotifyToggle ?? true);
$('#rpg-toggle-show-dynamic-weather-toggle').prop('checked', extensionSettings.showDynamicWeatherToggle ?? true); $('#rpg-toggle-show-dynamic-weather-toggle').prop('checked', extensionSettings.showDynamicWeatherToggle ?? true);
$('#rpg-toggle-show-narrator-mode').prop('checked', extensionSettings.showNarratorMode ?? true); $('#rpg-toggle-show-narrator-mode').prop('checked', extensionSettings.showNarratorMode ?? true);
@@ -928,7 +954,6 @@ async function initUI() {
$('#rpg-generation-mode').val(extensionSettings.generationMode); $('#rpg-generation-mode').val(extensionSettings.generationMode);
$('#rpg-skip-guided-mode').val(extensionSettings.skipInjectionsForGuided); $('#rpg-skip-guided-mode').val(extensionSettings.skipInjectionsForGuided);
$('#rpg-save-tracker-history').prop('checked', extensionSettings.saveTrackerHistory);
updatePanelVisibility(); updatePanelVisibility();
updateSectionVisibility(); updateSectionVisibility();
+1 -1
View File
@@ -48,7 +48,7 @@
</div> </div>
<div style="margin-top: 10px; text-align: center; opacity: 0.6; font-size: 0.85em;"> <div style="margin-top: 10px; text-align: center; opacity: 0.6; font-size: 0.85em;">
v3.3.3 v3.4.0
</div> </div>
</div> </div>
</div> </div>
+26 -8
View File
@@ -100,6 +100,24 @@ export function loadSettings() {
settingsChanged = true; settingsChanged = true;
} }
// Migration to version 4: Enable FAB widgets by default
if (currentVersion < 4) {
// console.log('[RPG Companion] Migrating settings to version 4 (enabling FAB widgets)');
if (!extensionSettings.mobileFabWidgets) {
extensionSettings.mobileFabWidgets = {};
}
extensionSettings.mobileFabWidgets.enabled = true;
extensionSettings.mobileFabWidgets.weatherIcon = { enabled: true };
extensionSettings.mobileFabWidgets.weatherDesc = { enabled: true };
extensionSettings.mobileFabWidgets.clock = { enabled: true };
extensionSettings.mobileFabWidgets.date = { enabled: true };
extensionSettings.mobileFabWidgets.location = { enabled: true };
extensionSettings.mobileFabWidgets.stats = { enabled: true };
extensionSettings.mobileFabWidgets.attributes = { enabled: true };
extensionSettings.settingsVersion = 4;
settingsChanged = true;
}
// Save migrated settings // Save migrated settings
if (settingsChanged) { if (settingsChanged) {
saveSettings(); saveSettings();
@@ -741,8 +759,8 @@ export function createPreset(name) {
id: presetId, id: presetId,
name: name, name: name,
trackerConfig: JSON.parse(JSON.stringify(extensionSettings.trackerConfig)), trackerConfig: JSON.parse(JSON.stringify(extensionSettings.trackerConfig)),
historyPersistence: extensionSettings.historyPersistence historyPersistence: extensionSettings.historyPersistence
? JSON.parse(JSON.stringify(extensionSettings.historyPersistence)) ? JSON.parse(JSON.stringify(extensionSettings.historyPersistence))
: null : null
}; };
// Also set it as the active preset so edits go to the new preset // Also set it as the active preset so edits go to the new preset
@@ -760,8 +778,8 @@ export function saveToPreset(presetId) {
const preset = extensionSettings.presetManager.presets[presetId]; const preset = extensionSettings.presetManager.presets[presetId];
if (preset) { if (preset) {
preset.trackerConfig = JSON.parse(JSON.stringify(extensionSettings.trackerConfig)); preset.trackerConfig = JSON.parse(JSON.stringify(extensionSettings.trackerConfig));
preset.historyPersistence = extensionSettings.historyPersistence preset.historyPersistence = extensionSettings.historyPersistence
? JSON.parse(JSON.stringify(extensionSettings.historyPersistence)) ? JSON.parse(JSON.stringify(extensionSettings.historyPersistence))
: null; : null;
saveSettings(); saveSettings();
// console.log(`[RPG Companion] Saved current config to preset "${preset.name}"`); // console.log(`[RPG Companion] Saved current config to preset "${preset.name}"`);
@@ -904,7 +922,7 @@ export function hasPresetAssociation() {
*/ */
export function autoSwitchPresetForEntity() { export function autoSwitchPresetForEntity() {
const associatedPresetId = getPresetForCurrentEntity(); const associatedPresetId = getPresetForCurrentEntity();
// If there's a character-specific preset, use it // If there's a character-specific preset, use it
if (associatedPresetId && associatedPresetId !== extensionSettings.presetManager.activePresetId) { if (associatedPresetId && associatedPresetId !== extensionSettings.presetManager.activePresetId) {
// Check if the preset still exists // Check if the preset still exists
@@ -915,17 +933,17 @@ export function autoSwitchPresetForEntity() {
removePresetAssociationForCurrentEntity(); removePresetAssociationForCurrentEntity();
} }
} }
// No character association - fall back to default preset if set // No character association - fall back to default preset if set
if (!associatedPresetId) { if (!associatedPresetId) {
const defaultPresetId = extensionSettings.presetManager.defaultPresetId; const defaultPresetId = extensionSettings.presetManager.defaultPresetId;
if (defaultPresetId && if (defaultPresetId &&
defaultPresetId !== extensionSettings.presetManager.activePresetId && defaultPresetId !== extensionSettings.presetManager.activePresetId &&
extensionSettings.presetManager.presets[defaultPresetId]) { extensionSettings.presetManager.presets[defaultPresetId]) {
return loadPreset(defaultPresetId); return loadPreset(defaultPresetId);
} }
} }
return false; return false;
} }
+15 -10
View File
@@ -10,7 +10,7 @@
* Extension settings - persisted to SillyTavern settings * Extension settings - persisted to SillyTavern settings
*/ */
export let extensionSettings = { export let extensionSettings = {
settingsVersion: 3, // Version number for settings migrations (v3 = JSON format) settingsVersion: 4, // Version number for settings migrations (v4 = FAB widgets enabled by default)
enabled: true, enabled: true,
autoUpdate: false, autoUpdate: false,
updateDepth: 4, // How many messages to include in the context updateDepth: 4, // How many messages to include in the context
@@ -27,6 +27,10 @@ export let extensionSettings = {
customHtmlPrompt: '', // Custom HTML prompt text (empty = use default) customHtmlPrompt: '', // Custom HTML prompt text (empty = use default)
enableDialogueColoring: false, // Enable dialogue coloring prompt injection enableDialogueColoring: false, // Enable dialogue coloring prompt injection
customDialogueColoringPrompt: '', // Custom dialogue coloring prompt text (empty = use default) customDialogueColoringPrompt: '', // Custom dialogue coloring prompt text (empty = use default)
enableDeceptionSystem: false, // Enable deception tracking with <lie> tags
customDeceptionPrompt: '', // Custom deception prompt text (empty = use default)
enableCYOA: false, // Enable "Choose Your Own Adventure" formatting with action choices
customCYOAPrompt: '', // Custom CYOA prompt text (empty = use default)
enableSpotifyMusic: false, // Enable Spotify music integration (asks AI for Spotify URLs) enableSpotifyMusic: false, // Enable Spotify music integration (asks AI for Spotify URLs)
customSpotifyPrompt: '', // Custom Spotify prompt text (empty = use default) customSpotifyPrompt: '', // Custom Spotify prompt text (empty = use default)
@@ -34,6 +38,8 @@ export let extensionSettings = {
dismissedHolidayPromo: false, // User dismissed the holiday promotion banner dismissedHolidayPromo: false, // User dismissed the holiday promotion banner
showHtmlToggle: true, // Show Immersive HTML toggle in main panel showHtmlToggle: true, // Show Immersive HTML toggle in main panel
showDialogueColoringToggle: true, // Show Dialogue Coloring toggle in main panel (enabled by default) showDialogueColoringToggle: true, // Show Dialogue Coloring toggle in main panel (enabled by default)
showDeceptionToggle: true, // Show Deception System toggle in main panel
showCYOAToggle: true, // Show CYOA toggle in main panel
showSpotifyToggle: true, // Show Spotify Music toggle in main panel showSpotifyToggle: true, // Show Spotify Music toggle in main panel
showDynamicWeatherToggle: true, // Show Dynamic Weather Effects toggle in main panel showDynamicWeatherToggle: true, // Show Dynamic Weather Effects toggle in main panel
@@ -42,7 +48,6 @@ export let extensionSettings = {
skipInjectionsForGuided: 'none', // skip injections for instruct injections and quiet prompts (GuidedGenerations compatibility) skipInjectionsForGuided: 'none', // skip injections for instruct injections and quiet prompts (GuidedGenerations compatibility)
enableRandomizedPlot: true, // Show randomized plot progression button above chat input enableRandomizedPlot: true, // Show randomized plot progression button above chat input
enableNaturalPlot: true, // Show natural plot progression button above chat input enableNaturalPlot: true, // Show natural plot progression button above chat input
saveTrackerHistory: false, // Save tracker data in chat history for each message
// History persistence settings - inject selected tracker data into historical messages // History persistence settings - inject selected tracker data into historical messages
historyPersistence: { historyPersistence: {
enabled: false, // Master toggle for history persistence feature enabled: false, // Master toggle for history persistence feature
@@ -67,14 +72,14 @@ export let extensionSettings = {
}, // Saved position for mobile FAB button }, // Saved position for mobile FAB button
// Mobile FAB widget display options (8-position system around the button) // Mobile FAB widget display options (8-position system around the button)
mobileFabWidgets: { mobileFabWidgets: {
enabled: false, // Master toggle for FAB widgets enabled: true, // Master toggle for FAB widgets
weatherIcon: { enabled: false, position: 0 }, // Weather emoji (☀️, 🌧️, etc.) weatherIcon: { enabled: true, position: 0 }, // Weather emoji (☀️, 🌧️, etc.)
weatherDesc: { enabled: false, position: 1 }, // Weather description text weatherDesc: { enabled: true, position: 1 }, // Weather description text
clock: { enabled: false, position: 2 }, // Current time display clock: { enabled: true, position: 2 }, // Current time display
date: { enabled: false, position: 3 }, // Date display date: { enabled: true, position: 3 }, // Date display
location: { enabled: false, position: 4 }, // Location name location: { enabled: true, position: 4 }, // Location name
stats: { enabled: false, position: 5 }, // All stats as compact numbers stats: { enabled: true, position: 5 }, // All stats as compact numbers
attributes: { enabled: false, position: 6 } // Compact RPG attributes display attributes: { enabled: true, position: 6 } // Compact RPG attributes display
}, },
userStats: JSON.stringify({ userStats: JSON.stringify({
stats: [ stats: [
+15 -1
View File
@@ -5,7 +5,7 @@
import { togglePlotButtons } from '../ui/layout.js'; import { togglePlotButtons } from '../ui/layout.js';
import { extensionSettings, setIsPlotProgression } from '../../core/state.js'; import { extensionSettings, setIsPlotProgression } from '../../core/state.js';
import { DEFAULT_HTML_PROMPT, DEFAULT_DIALOGUE_COLORING_PROMPT } from '../generation/promptBuilder.js'; import { DEFAULT_HTML_PROMPT, DEFAULT_DIALOGUE_COLORING_PROMPT, DEFAULT_DECEPTION_PROMPT, DEFAULT_CYOA_PROMPT } from '../generation/promptBuilder.js';
import { Generate } from '../../../../../../../script.js'; import { Generate } from '../../../../../../../script.js';
/** /**
@@ -121,6 +121,20 @@ export async function sendPlotProgression(type) {
prompt += '\n\n' + dialogueColoringPromptText; prompt += '\n\n' + dialogueColoringPromptText;
} }
// Add Deception System prompt if enabled
if (extensionSettings.enableDeceptionSystem) {
// Use custom Deception prompt if set, otherwise use default
const deceptionPromptText = extensionSettings.customDeceptionPrompt || DEFAULT_DECEPTION_PROMPT;
prompt += '\n\n' + deceptionPromptText;
}
// Add CYOA prompt if enabled
if (extensionSettings.enableCYOA) {
// Use custom CYOA prompt if set, otherwise use default
const cyoaPromptText = extensionSettings.customCYOAPrompt || DEFAULT_CYOA_PROMPT;
prompt += '\n\n' + cyoaPromptText;
}
// Set flag to indicate we're doing plot progression // Set flag to indicate we're doing plot progression
// This will be used by onMessageReceived to clear the prompt after generation completes // This will be used by onMessageReceived to clear the prompt after generation completes
setIsPlotProgression(true); setIsPlotProgression(true);
-15
View File
@@ -304,21 +304,6 @@ export async function updateRPGData(renderUserStats, renderInfoBox, renderThough
lastGeneratedData.characterThoughts = parsedData.characterThoughts; lastGeneratedData.characterThoughts = parsedData.characterThoughts;
} }
// When saveTrackerHistory is enabled, store tracker data on the user's message too
// This allows scrolling through history and seeing trackers at each point
if (extensionSettings.saveTrackerHistory && lastMessage && lastMessage.is_user) {
if (!lastMessage.extra) {
lastMessage.extra = {};
}
lastMessage.extra.rpg_companion_data = {
userStats: parsedData.userStats,
infoBox: parsedData.infoBox,
characterThoughts: parsedData.characterThoughts,
timestamp: Date.now()
};
// console.log('[RPG Companion] 💾 Stored tracker data on user message for history');
}
// Also store on assistant message if present (existing behavior) // Also store on assistant message if present (existing behavior)
if (lastMessage && !lastMessage.is_user) { if (lastMessage && !lastMessage.is_user) {
if (!lastMessage.extra) { if (!lastMessage.extra) {
+79 -8
View File
@@ -23,6 +23,8 @@ import {
formatHistoricalTrackerData, formatHistoricalTrackerData,
DEFAULT_HTML_PROMPT, DEFAULT_HTML_PROMPT,
DEFAULT_DIALOGUE_COLORING_PROMPT, DEFAULT_DIALOGUE_COLORING_PROMPT,
DEFAULT_DECEPTION_PROMPT,
DEFAULT_CYOA_PROMPT,
DEFAULT_SPOTIFY_PROMPT, DEFAULT_SPOTIFY_PROMPT,
SPOTIFY_FORMAT_INSTRUCTION SPOTIFY_FORMAT_INSTRUCTION
} from './promptBuilder.js'; } from './promptBuilder.js';
@@ -125,7 +127,7 @@ function buildHistoricalContextMap() {
} }
// Build the context wrapper // Build the context wrapper
const preamble = historyPersistence.contextPreamble || '[Context at this point:]'; const preamble = historyPersistence.contextPreamble || 'Context for that moment:';
const wrappedContext = `\n${preamble}\n${formattedContext}`; const wrappedContext = `\n${preamble}\n${formattedContext}`;
// Determine which message index to store based on injection position // Determine which message index to store based on injection position
@@ -261,8 +263,8 @@ export async function onGenerationStarted(type, data, dryRun) {
// console.log('[RPG Companion] Committed Prompt:', committedTrackerData); // console.log('[RPG Companion] Committed Prompt:', committedTrackerData);
// Skip tracker injection for image generation requests // Skip tracker injection for image generation requests
if (data?.quietImage) { if (data?.quietImage || data?.quiet_image || data?.isImageGeneration) {
// console.log('[RPG Companion] Detected image generation (quietImage=true), skipping tracker injection'); // console.log('[RPG Companion] Detected image generation, skipping tracker injection');
return; return;
} }
@@ -467,7 +469,7 @@ export async function onGenerationStarted(type, data, dryRun) {
if (extensionSettings.enableHtmlPrompt && !shouldSuppress) { if (extensionSettings.enableHtmlPrompt && !shouldSuppress) {
// Use custom HTML prompt if set, otherwise use default // Use custom HTML prompt if set, otherwise use default
const htmlPromptText = extensionSettings.customHtmlPrompt || DEFAULT_HTML_PROMPT; const htmlPromptText = extensionSettings.customHtmlPrompt || DEFAULT_HTML_PROMPT;
const htmlPrompt = `\n${htmlPromptText}`; const htmlPrompt = `\n- ${htmlPromptText}\n`;
setExtensionPrompt('rpg-companion-html', htmlPrompt, extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-companion-html', htmlPrompt, extension_prompt_types.IN_CHAT, 0, false);
// console.log('[RPG Companion] Injected HTML prompt at depth 0 for together mode'); // console.log('[RPG Companion] Injected HTML prompt at depth 0 for together mode');
@@ -480,7 +482,7 @@ export async function onGenerationStarted(type, data, dryRun) {
if (extensionSettings.enableDialogueColoring && !shouldSuppress) { if (extensionSettings.enableDialogueColoring && !shouldSuppress) {
// Use custom Dialogue Coloring prompt if set, otherwise use default // Use custom Dialogue Coloring prompt if set, otherwise use default
const dialogueColoringPromptText = extensionSettings.customDialogueColoringPrompt || DEFAULT_DIALOGUE_COLORING_PROMPT; const dialogueColoringPromptText = extensionSettings.customDialogueColoringPrompt || DEFAULT_DIALOGUE_COLORING_PROMPT;
const dialogueColoringPrompt = `\n${dialogueColoringPromptText}`; const dialogueColoringPrompt = `\n- ${dialogueColoringPromptText}\n`;
setExtensionPrompt('rpg-companion-dialogue-coloring', dialogueColoringPrompt, extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-companion-dialogue-coloring', dialogueColoringPrompt, extension_prompt_types.IN_CHAT, 0, false);
// console.log('[RPG Companion] Injected Dialogue Coloring prompt at depth 0 for together mode'); // console.log('[RPG Companion] Injected Dialogue Coloring prompt at depth 0 for together mode');
@@ -489,11 +491,24 @@ export async function onGenerationStarted(type, data, dryRun) {
setExtensionPrompt('rpg-companion-dialogue-coloring', '', extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-companion-dialogue-coloring', '', extension_prompt_types.IN_CHAT, 0, false);
} }
// Inject Deception System prompt separately at depth 0 if enabled
if (extensionSettings.enableDeceptionSystem && !shouldSuppress) {
// Use custom Deception prompt if set, otherwise use default
const deceptionPromptText = extensionSettings.customDeceptionPrompt || DEFAULT_DECEPTION_PROMPT;
const deceptionPrompt = `\n- ${deceptionPromptText}\n`;
setExtensionPrompt('rpg-companion-deception', deceptionPrompt, extension_prompt_types.IN_CHAT, 0, false);
// console.log('[RPG Companion] Injected Deception System prompt at depth 0 for together mode');
} else {
// Clear Deception System prompt if disabled
setExtensionPrompt('rpg-companion-deception', '', extension_prompt_types.IN_CHAT, 0, false);
}
// Inject Spotify prompt separately at depth 0 if enabled // Inject Spotify prompt separately at depth 0 if enabled
if (extensionSettings.enableSpotifyMusic && !shouldSuppress) { if (extensionSettings.enableSpotifyMusic && !shouldSuppress) {
// Use custom Spotify prompt if set, otherwise use default // Use custom Spotify prompt if set, otherwise use default
const spotifyPromptText = extensionSettings.customSpotifyPrompt || DEFAULT_SPOTIFY_PROMPT; const spotifyPromptText = extensionSettings.customSpotifyPrompt || DEFAULT_SPOTIFY_PROMPT;
const spotifyPrompt = `\n${spotifyPromptText} ${SPOTIFY_FORMAT_INSTRUCTION}`; const spotifyPrompt = `\n- ${spotifyPromptText} ${SPOTIFY_FORMAT_INSTRUCTION}\n`;
setExtensionPrompt('rpg-companion-spotify', spotifyPrompt, extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-companion-spotify', spotifyPrompt, extension_prompt_types.IN_CHAT, 0, false);
// console.log('[RPG Companion] Injected Spotify prompt at depth 0 for together mode'); // console.log('[RPG Companion] Injected Spotify prompt at depth 0 for together mode');
@@ -501,6 +516,20 @@ export async function onGenerationStarted(type, data, dryRun) {
// Clear Spotify prompt if disabled // Clear Spotify prompt if disabled
setExtensionPrompt('rpg-companion-spotify', '', extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-companion-spotify', '', extension_prompt_types.IN_CHAT, 0, false);
} }
// Inject CYOA prompt separately at depth 0 if enabled (injected last to appear last in prompt)
if (extensionSettings.enableCYOA && !shouldSuppress) {
// Use custom CYOA prompt if set, otherwise use default
const cyoaPromptText = extensionSettings.customCYOAPrompt || DEFAULT_CYOA_PROMPT;
const cyoaPrompt = `\n- ${cyoaPromptText}\n`;
setExtensionPrompt('rpg-companion-zzz-cyoa', cyoaPrompt, extension_prompt_types.IN_CHAT, 0, false);
// console.log('[RPG Companion] Injected CYOA prompt at depth 0 for together mode');
} else {
// Clear CYOA prompt if disabled
setExtensionPrompt('rpg-companion-zzz-cyoa', '', extension_prompt_types.IN_CHAT, 0, false);
}
} else if (extensionSettings.generationMode === 'separate' || extensionSettings.generationMode === 'external') { } else if (extensionSettings.generationMode === 'separate' || extensionSettings.generationMode === 'external') {
// In SEPARATE and EXTERNAL modes, inject the contextual summary for main roleplay generation // In SEPARATE and EXTERNAL modes, inject the contextual summary for main roleplay generation
const contextSummary = generateContextualSummary(); const contextSummary = generateContextualSummary();
@@ -528,7 +557,7 @@ Ensure these details naturally reflect and influence the narrative. Character be
if (extensionSettings.enableHtmlPrompt && !shouldSuppress) { if (extensionSettings.enableHtmlPrompt && !shouldSuppress) {
// Use custom HTML prompt if set, otherwise use default // Use custom HTML prompt if set, otherwise use default
const htmlPromptText = extensionSettings.customHtmlPrompt || DEFAULT_HTML_PROMPT; const htmlPromptText = extensionSettings.customHtmlPrompt || DEFAULT_HTML_PROMPT;
const htmlPrompt = `\n${htmlPromptText}`; const htmlPrompt = `\n- ${htmlPromptText}\n`;
setExtensionPrompt('rpg-companion-html', htmlPrompt, extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-companion-html', htmlPrompt, extension_prompt_types.IN_CHAT, 0, false);
// console.log('[RPG Companion] Injected HTML prompt at depth 0 for separate/external mode'); // console.log('[RPG Companion] Injected HTML prompt at depth 0 for separate/external mode');
@@ -537,11 +566,37 @@ Ensure these details naturally reflect and influence the narrative. Character be
setExtensionPrompt('rpg-companion-html', '', extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-companion-html', '', extension_prompt_types.IN_CHAT, 0, false);
} }
// Inject Dialogue Coloring prompt separately at depth 0 if enabled
if (extensionSettings.enableDialogueColoring && !shouldSuppress) {
// Use custom Dialogue Coloring prompt if set, otherwise use default
const dialogueColoringPromptText = extensionSettings.customDialogueColoringPrompt || DEFAULT_DIALOGUE_COLORING_PROMPT;
const dialogueColoringPrompt = `\n- ${dialogueColoringPromptText}\n`;
setExtensionPrompt('rpg-companion-dialogue-coloring', dialogueColoringPrompt, extension_prompt_types.IN_CHAT, 0, false);
// console.log('[RPG Companion] Injected Dialogue Coloring prompt at depth 0 for separate/external mode');
} else {
// Clear Dialogue Coloring prompt if disabled
setExtensionPrompt('rpg-companion-dialogue-coloring', '', extension_prompt_types.IN_CHAT, 0, false);
}
// Inject Deception System prompt separately at depth 0 if enabled
if (extensionSettings.enableDeceptionSystem && !shouldSuppress) {
// Use custom Deception prompt if set, otherwise use default
const deceptionPromptText = extensionSettings.customDeceptionPrompt || DEFAULT_DECEPTION_PROMPT;
const deceptionPrompt = `\n- ${deceptionPromptText}\n`;
setExtensionPrompt('rpg-companion-deception', deceptionPrompt, extension_prompt_types.IN_CHAT, 0, false);
// console.log('[RPG Companion] Injected Deception System prompt at depth 0 for separate/external mode');
} else {
// Clear Deception System prompt if disabled
setExtensionPrompt('rpg-companion-deception', '', extension_prompt_types.IN_CHAT, 0, false);
}
// Inject Spotify prompt separately at depth 0 if enabled // Inject Spotify prompt separately at depth 0 if enabled
if (extensionSettings.enableSpotifyMusic && !shouldSuppress) { if (extensionSettings.enableSpotifyMusic && !shouldSuppress) {
// Use custom Spotify prompt if set, otherwise use default // Use custom Spotify prompt if set, otherwise use default
const spotifyPromptText = extensionSettings.customSpotifyPrompt || DEFAULT_SPOTIFY_PROMPT; const spotifyPromptText = extensionSettings.customSpotifyPrompt || DEFAULT_SPOTIFY_PROMPT;
const spotifyPrompt = `\n${spotifyPromptText} ${SPOTIFY_FORMAT_INSTRUCTION}`; const spotifyPrompt = `\n- ${spotifyPromptText} ${SPOTIFY_FORMAT_INSTRUCTION}\n`;
setExtensionPrompt('rpg-companion-spotify', spotifyPrompt, extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-companion-spotify', spotifyPrompt, extension_prompt_types.IN_CHAT, 0, false);
// console.log('[RPG Companion] Injected Spotify prompt at depth 0 for separate/external mode'); // console.log('[RPG Companion] Injected Spotify prompt at depth 0 for separate/external mode');
@@ -550,6 +605,19 @@ Ensure these details naturally reflect and influence the narrative. Character be
setExtensionPrompt('rpg-companion-spotify', '', extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-companion-spotify', '', extension_prompt_types.IN_CHAT, 0, false);
} }
// Inject CYOA prompt separately at depth 0 if enabled (injected last to appear last in prompt)
if (extensionSettings.enableCYOA && !shouldSuppress) {
// Use custom CYOA prompt if set, otherwise use default
const cyoaPromptText = extensionSettings.customCYOAPrompt || DEFAULT_CYOA_PROMPT;
const cyoaPrompt = `\n- ${cyoaPromptText}\n`;
setExtensionPrompt('rpg-companion-zzz-cyoa', cyoaPrompt, extension_prompt_types.IN_CHAT, 0, false);
// console.log('[RPG Companion] Injected CYOA prompt at depth 0 for separate/external mode');
} else {
// Clear CYOA prompt if disabled
setExtensionPrompt('rpg-companion-zzz-cyoa', '', extension_prompt_types.IN_CHAT, 0, false);
}
// Clear together mode injections // Clear together mode injections
setExtensionPrompt('rpg-companion-inject', '', extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-companion-inject', '', extension_prompt_types.IN_CHAT, 0, false);
setExtensionPrompt('rpg-companion-example', '', extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-companion-example', '', extension_prompt_types.IN_CHAT, 0, false);
@@ -559,6 +627,9 @@ Ensure these details naturally reflect and influence the narrative. Character be
setExtensionPrompt('rpg-companion-example', '', extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-companion-example', '', extension_prompt_types.IN_CHAT, 0, false);
setExtensionPrompt('rpg-companion-context', '', extension_prompt_types.IN_CHAT, 1, false); setExtensionPrompt('rpg-companion-context', '', extension_prompt_types.IN_CHAT, 1, false);
setExtensionPrompt('rpg-companion-html', '', extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-companion-html', '', extension_prompt_types.IN_CHAT, 0, false);
setExtensionPrompt('rpg-companion-dialogue-coloring', '', extension_prompt_types.IN_CHAT, 0, false);
setExtensionPrompt('rpg-companion-deception', '', extension_prompt_types.IN_CHAT, 0, false);
setExtensionPrompt('rpg-companion-zzz-cyoa', '', extension_prompt_types.IN_CHAT, 0, false);
setExtensionPrompt('rpg-companion-spotify', '', extension_prompt_types.IN_CHAT, 0, false); setExtensionPrompt('rpg-companion-spotify', '', extension_prompt_types.IN_CHAT, 0, false);
} }
+13 -12
View File
@@ -28,6 +28,16 @@ export const DEFAULT_HTML_PROMPT = `If appropriate, include inline HTML, CSS, an
*/ */
export const DEFAULT_DIALOGUE_COLORING_PROMPT = `Wrap all character/NPC "dialogues" in unique <font color=######>tags</font>, exemplary: <font color=#abc123>"You're pretty good."</font> Assign a distinct color to each speaker and reuse it whenever they speak again.`; export const DEFAULT_DIALOGUE_COLORING_PROMPT = `Wrap all character/NPC "dialogues" in unique <font color=######>tags</font>, exemplary: <font color=#abc123>"You're pretty good."</font> Assign a distinct color to each speaker and reuse it whenever they speak again.`;
/**
* Default Deception System prompt text
*/
export const DEFAULT_DECEPTION_PROMPT = `When a character is lying or deceiving, you should follow up that line with the <lie> tag, containing a brief description of the truth and the lie's reason, using the template below (replace placeholders in brackets). This will be hidden from the user's view, but not to you, making it useful for future consequences: <lie>[Character] is [lying/deceiving/omitting], the truth is [truth]. Reason: [reason].</lie>`;
/**
* Default CYOA prompt text
*/
export const DEFAULT_CYOA_PROMPT = `Since this is a "Choose Your Own Adventure" type of game, you must finish your response by creating a numbered list of 5 different possible action or dialogue options (depending on the scene) for the user to choose from. Make sure they all fit their persona well. They will respond with their choice on how to progress.`;
/** /**
* Default Spotify music prompt text (customizable by users) * Default Spotify music prompt text (customizable by users)
*/ */
@@ -229,7 +239,6 @@ function buildAttributesString() {
*/ */
export function generateTrackerExample() { export function generateTrackerExample() {
let example = ''; let example = '';
const useXmlTags = extensionSettings.saveTrackerHistory;
// Use COMMITTED data for generation context, not displayed data // Use COMMITTED data for generation context, not displayed data
// Apply locks before sending to AI (for JSON format only) // Apply locks before sending to AI (for JSON format only)
@@ -310,19 +319,11 @@ export function generateTrackerInstructions(includeHtmlPrompt = true, includeCon
// Only add tracker instructions if at least one tracker is enabled // Only add tracker instructions if at least one tracker is enabled
if (hasAnyTrackers) { if (hasAnyTrackers) {
// Determine format based on saveTrackerHistory setting
const useXmlTags = extensionSettings.saveTrackerHistory;
const openTag = useXmlTags ? '<trackers>\n' : '';
const closeTag = useXmlTags ? '\n</trackers>' : '';
const codeBlockMarker = ''; const codeBlockMarker = '';
const endCodeBlockMarker = ''; const endCodeBlockMarker = '';
// Universal instruction header // Universal instruction header
if (useXmlTags) { instructions += '\nAt the start of every reply, you must attach an update to the trackers in EXACTLY the JSON format shown below as a single unified JSON object containing all enabled tracker fields. ';
instructions += `\nAt the start of every reply, you must attach an update to the trackers in EXACTLY the JSON format shown below, enclosed in <trackers></trackers> XML tags. `;
} else {
instructions += '\nAt the start of every reply, you must attach an update to the trackers in EXACTLY the JSON format shown below as a single unified JSON object containing all enabled tracker fields. ';
}
// Append custom instruction portion if available // Append custom instruction portion if available
const customPrompt = extensionSettings.customTrackerInstructionsPrompt; const customPrompt = extensionSettings.customTrackerInstructionsPrompt;
@@ -789,7 +790,7 @@ export function formatHistoricalTrackerData(trackerData, trackerConfig, userName
let statsFormatted = ''; let statsFormatted = '';
// Custom stats with persistInHistory enabled // Custom stats with persistInHistory enabled
if (userStatsData.stats && Array.isArray(userStatsData.stats)) { if (userStatsData.stats && Array.isArray(userStatsData.stats) && userStatsConfig.customStats) {
for (const stat of userStatsData.stats) { for (const stat of userStatsData.stats) {
const configStat = userStatsConfig.customStats.find(s => s.id === stat.id); const configStat = userStatsConfig.customStats.find(s => s.id === stat.id);
if (configStat?.persistInHistory && stat.value !== undefined) { if (configStat?.persistInHistory && stat.value !== undefined) {
@@ -1169,7 +1170,7 @@ export async function generateSeparateUpdatePrompt() {
continue; continue;
} }
const preamble = historyPersistence.contextPreamble || '[Context at this point:]'; const preamble = historyPersistence.contextPreamble || 'Context for that moment:';
const wrappedContext = `\n${preamble}\n${formattedContext}`; const wrappedContext = `\n${preamble}\n${formattedContext}`;
// Determine target message based on position // Determine target message based on position
+9 -13
View File
@@ -204,20 +204,16 @@ export async function onMessageReceived(data) {
// Remove the tracker code blocks from the visible message // Remove the tracker code blocks from the visible message
let cleanedMessage = responseText; let cleanedMessage = responseText;
// Only remove trackers if saveTrackerHistory is disabled // Note: JSON code blocks are hidden from display by regex script (but preserved in message data)
// When enabled, trackers are in <trackers> XML tags which SillyTavern auto-hides
if (!extensionSettings.saveTrackerHistory) {
// Note: JSON code blocks are hidden from display by regex script (but preserved in message data)
// Remove old text format code blocks (legacy support) // Remove old text format code blocks (legacy support)
cleanedMessage = cleanedMessage.replace(/```[^`]*?Stats\s*\n\s*---[^`]*?```\s*/gi, ''); cleanedMessage = cleanedMessage.replace(/```[^`]*?Stats\s*\n\s*---[^`]*?```\s*/gi, '');
cleanedMessage = cleanedMessage.replace(/```[^`]*?Info Box\s*\n\s*---[^`]*?```\s*/gi, ''); cleanedMessage = cleanedMessage.replace(/```[^`]*?Info Box\s*\n\s*---[^`]*?```\s*/gi, '');
cleanedMessage = cleanedMessage.replace(/```[^`]*?Present Characters\s*\n\s*---[^`]*?```\s*/gi, ''); cleanedMessage = cleanedMessage.replace(/```[^`]*?Present Characters\s*\n\s*---[^`]*?```\s*/gi, '');
// Remove any stray "---" dividers that might appear after the code blocks // Remove any stray "---" dividers that might appear after the code blocks
cleanedMessage = cleanedMessage.replace(/^\s*---\s*$/gm, ''); cleanedMessage = cleanedMessage.replace(/^\s*---\s*$/gm, '');
// Clean up multiple consecutive newlines // Clean up multiple consecutive newlines
cleanedMessage = cleanedMessage.replace(/\n{3,}/g, '\n\n'); cleanedMessage = cleanedMessage.replace(/\n{3,}/g, '\n\n');
}
// Note: <trackers> XML tags are automatically hidden by SillyTavern // Note: <trackers> XML tags are automatically hidden by SillyTavern
// Note: <Song - Artist/> tags are also automatically hidden by SillyTavern // Note: <Song - Artist/> tags are also automatically hidden by SillyTavern
+19 -1
View File
@@ -4,7 +4,7 @@
*/ */
import { extensionSettings } from '../../core/state.js'; import { extensionSettings } from '../../core/state.js';
import { saveSettings } from '../../core/persistence.js'; import { saveSettings } from '../../core/persistence.js';
import { DEFAULT_HTML_PROMPT, DEFAULT_DIALOGUE_COLORING_PROMPT, DEFAULT_SPOTIFY_PROMPT, DEFAULT_NARRATOR_PROMPT } from '../generation/promptBuilder.js'; import { DEFAULT_HTML_PROMPT, DEFAULT_DIALOGUE_COLORING_PROMPT, DEFAULT_DECEPTION_PROMPT, DEFAULT_CYOA_PROMPT, DEFAULT_SPOTIFY_PROMPT, DEFAULT_NARRATOR_PROMPT } from '../generation/promptBuilder.js';
let $editorModal = null; let $editorModal = null;
let tempPrompts = null; // Temporary prompts for cancel functionality let tempPrompts = null; // Temporary prompts for cancel functionality
@@ -13,6 +13,8 @@ let tempPrompts = null; // Temporary prompts for cancel functionality
const DEFAULT_PROMPTS = { const DEFAULT_PROMPTS = {
html: DEFAULT_HTML_PROMPT, html: DEFAULT_HTML_PROMPT,
dialogueColoring: DEFAULT_DIALOGUE_COLORING_PROMPT, dialogueColoring: DEFAULT_DIALOGUE_COLORING_PROMPT,
deception: DEFAULT_DECEPTION_PROMPT,
cyoa: DEFAULT_CYOA_PROMPT,
spotify: DEFAULT_SPOTIFY_PROMPT, spotify: DEFAULT_SPOTIFY_PROMPT,
narrator: DEFAULT_NARRATOR_PROMPT, narrator: DEFAULT_NARRATOR_PROMPT,
plotRandom: 'Actually, the scene is getting stale. Introduce {{random::stakes::a plot twist::a new character::a cataclysm::a fourth-wall-breaking joke::a sudden atmospheric phenomenon::a plot hook::a running gag::an ecchi scenario::Death from Discworld::a new stake::a drama::a conflict::an angered entity::a god::a vision::a prophetic dream::Il Dottore from Genshin Impact::a new development::a civilian in need::an emotional bit::a threat::a villain::an important memory recollection::a marriage proposal::a date idea::an angry horde of villagers with pitchforks::a talking animal::an enemy::a cliffhanger::a short omniscient POV shift to a completely different character::a quest::an unexpected revelation::a scandal::an evil clone::death of an important character::harm to an important character::a romantic setup::a gossip::a messenger::a plot point from the past::a plot hole::a tragedy::a ghost::an otherworldly occurrence::a plot device::a curse::a magic device::a rival::an unexpected pregnancy::a brothel::a prostitute::a new location::a past lover::a completely random thing::a what-if scenario::a significant choice::war::love::a monster::lewd undertones::Professor Mari::a travelling troupe::a secret::a fortune-teller::something completely different::a killer::a murder mystery::a mystery::a skill check::a deus ex machina::three raccoons in a trench coat::a pet::a slave::an orphan::a psycho::tentacles::"there is only one bed" trope::accidental marriage::a fun twist::a boss battle::sexy corn::an eldritch horror::a character getting hungry, thirsty, or exhausted::horniness::a need for a bathroom break need::someone fainting::an assassination attempt::a meta narration of this all being an out of hand DND session::a dungeon::a friend in need::an old friend::a small time skip::a scene shift::Aurora Borealis, at this time of year, at this time of day, at this part of the country::a grand ball::a surprise party::zombies::foreshadowing::a Spanish Inquisition (nobody expects it)::a natural plot progression}} to make things more interesting! Be creative, but stay grounded in the setting.', plotRandom: 'Actually, the scene is getting stale. Introduce {{random::stakes::a plot twist::a new character::a cataclysm::a fourth-wall-breaking joke::a sudden atmospheric phenomenon::a plot hook::a running gag::an ecchi scenario::Death from Discworld::a new stake::a drama::a conflict::an angered entity::a god::a vision::a prophetic dream::Il Dottore from Genshin Impact::a new development::a civilian in need::an emotional bit::a threat::a villain::an important memory recollection::a marriage proposal::a date idea::an angry horde of villagers with pitchforks::a talking animal::an enemy::a cliffhanger::a short omniscient POV shift to a completely different character::a quest::an unexpected revelation::a scandal::an evil clone::death of an important character::harm to an important character::a romantic setup::a gossip::a messenger::a plot point from the past::a plot hole::a tragedy::a ghost::an otherworldly occurrence::a plot device::a curse::a magic device::a rival::an unexpected pregnancy::a brothel::a prostitute::a new location::a past lover::a completely random thing::a what-if scenario::a significant choice::war::love::a monster::lewd undertones::Professor Mari::a travelling troupe::a secret::a fortune-teller::something completely different::a killer::a murder mystery::a mystery::a skill check::a deus ex machina::three raccoons in a trench coat::a pet::a slave::an orphan::a psycho::tentacles::"there is only one bed" trope::accidental marriage::a fun twist::a boss battle::sexy corn::an eldritch horror::a character getting hungry, thirsty, or exhausted::horniness::a need for a bathroom break need::someone fainting::an assassination attempt::a meta narration of this all being an out of hand DND session::a dungeon::a friend in need::an old friend::a small time skip::a scene shift::Aurora Borealis, at this time of year, at this time of day, at this part of the country::a grand ball::a surprise party::zombies::foreshadowing::a Spanish Inquisition (nobody expects it)::a natural plot progression}} to make things more interesting! Be creative, but stay grounded in the setting.',
@@ -93,6 +95,8 @@ function openPromptsEditor() {
tempPrompts = { tempPrompts = {
html: extensionSettings.customHtmlPrompt || '', html: extensionSettings.customHtmlPrompt || '',
dialogueColoring: extensionSettings.customDialogueColoringPrompt || '', dialogueColoring: extensionSettings.customDialogueColoringPrompt || '',
deception: extensionSettings.customDeceptionPrompt || '',
cyoa: extensionSettings.customCYOAPrompt || '',
spotify: extensionSettings.customSpotifyPrompt || '', spotify: extensionSettings.customSpotifyPrompt || '',
narrator: extensionSettings.customNarratorPrompt || '', narrator: extensionSettings.customNarratorPrompt || '',
plotRandom: extensionSettings.customPlotRandomPrompt || '', plotRandom: extensionSettings.customPlotRandomPrompt || '',
@@ -106,6 +110,8 @@ function openPromptsEditor() {
// Load current values or defaults // Load current values or defaults
$('#rpg-prompt-html').val(extensionSettings.customHtmlPrompt || DEFAULT_PROMPTS.html); $('#rpg-prompt-html').val(extensionSettings.customHtmlPrompt || DEFAULT_PROMPTS.html);
$('#rpg-prompt-dialogue-coloring').val(extensionSettings.customDialogueColoringPrompt || DEFAULT_PROMPTS.dialogueColoring); $('#rpg-prompt-dialogue-coloring').val(extensionSettings.customDialogueColoringPrompt || DEFAULT_PROMPTS.dialogueColoring);
$('#rpg-prompt-deception').val(extensionSettings.customDeceptionPrompt || DEFAULT_PROMPTS.deception);
$('#rpg-prompt-cyoa').val(extensionSettings.customCYOAPrompt || DEFAULT_PROMPTS.cyoa);
$('#rpg-prompt-spotify').val(extensionSettings.customSpotifyPrompt || DEFAULT_PROMPTS.spotify); $('#rpg-prompt-spotify').val(extensionSettings.customSpotifyPrompt || DEFAULT_PROMPTS.spotify);
$('#rpg-prompt-narrator').val(extensionSettings.customNarratorPrompt || DEFAULT_PROMPTS.narrator); $('#rpg-prompt-narrator').val(extensionSettings.customNarratorPrompt || DEFAULT_PROMPTS.narrator);
$('#rpg-prompt-plot-random').val(extensionSettings.customPlotRandomPrompt || DEFAULT_PROMPTS.plotRandom); $('#rpg-prompt-plot-random').val(extensionSettings.customPlotRandomPrompt || DEFAULT_PROMPTS.plotRandom);
@@ -143,6 +149,8 @@ function closePromptsEditor() {
function savePrompts() { function savePrompts() {
extensionSettings.customHtmlPrompt = $('#rpg-prompt-html').val().trim(); extensionSettings.customHtmlPrompt = $('#rpg-prompt-html').val().trim();
extensionSettings.customDialogueColoringPrompt = $('#rpg-prompt-dialogue-coloring').val().trim(); extensionSettings.customDialogueColoringPrompt = $('#rpg-prompt-dialogue-coloring').val().trim();
extensionSettings.customDeceptionPrompt = $('#rpg-prompt-deception').val().trim();
extensionSettings.customCYOAPrompt = $('#rpg-prompt-cyoa').val().trim();
extensionSettings.customSpotifyPrompt = $('#rpg-prompt-spotify').val().trim(); extensionSettings.customSpotifyPrompt = $('#rpg-prompt-spotify').val().trim();
extensionSettings.customNarratorPrompt = $('#rpg-prompt-narrator').val().trim(); extensionSettings.customNarratorPrompt = $('#rpg-prompt-narrator').val().trim();
extensionSettings.customPlotRandomPrompt = $('#rpg-prompt-plot-random').val().trim(); extensionSettings.customPlotRandomPrompt = $('#rpg-prompt-plot-random').val().trim();
@@ -171,6 +179,12 @@ function restorePromptToDefault(promptType) {
case 'dialogueColoring': case 'dialogueColoring':
extensionSettings.customDialogueColoringPrompt = ''; extensionSettings.customDialogueColoringPrompt = '';
break; break;
case 'deception':
extensionSettings.customDeceptionPrompt = '';
break;
case 'cyoa':
extensionSettings.customCYOAPrompt = '';
break;
case 'spotify': case 'spotify':
extensionSettings.customSpotifyPrompt = ''; extensionSettings.customSpotifyPrompt = '';
break; break;
@@ -206,6 +220,8 @@ function restorePromptToDefault(promptType) {
function restoreAllToDefaults() { function restoreAllToDefaults() {
$('#rpg-prompt-html').val(DEFAULT_PROMPTS.html); $('#rpg-prompt-html').val(DEFAULT_PROMPTS.html);
$('#rpg-prompt-dialogue-coloring').val(DEFAULT_PROMPTS.dialogueColoring); $('#rpg-prompt-dialogue-coloring').val(DEFAULT_PROMPTS.dialogueColoring);
$('#rpg-prompt-deception').val(DEFAULT_PROMPTS.deception);
$('#rpg-prompt-cyoa').val(DEFAULT_PROMPTS.cyoa);
$('#rpg-prompt-spotify').val(DEFAULT_PROMPTS.spotify); $('#rpg-prompt-spotify').val(DEFAULT_PROMPTS.spotify);
$('#rpg-prompt-narrator').val(DEFAULT_PROMPTS.narrator); $('#rpg-prompt-narrator').val(DEFAULT_PROMPTS.narrator);
$('#rpg-prompt-plot-random').val(DEFAULT_PROMPTS.plotRandom); $('#rpg-prompt-plot-random').val(DEFAULT_PROMPTS.plotRandom);
@@ -218,6 +234,8 @@ function restoreAllToDefaults() {
// Clear all custom prompts // Clear all custom prompts
extensionSettings.customHtmlPrompt = ''; extensionSettings.customHtmlPrompt = '';
extensionSettings.customDialogueColoringPrompt = ''; extensionSettings.customDialogueColoringPrompt = '';
extensionSettings.customDeceptionPrompt = '';
extensionSettings.customCYOAPrompt = '';
extensionSettings.customSpotifyPrompt = ''; extensionSettings.customSpotifyPrompt = '';
extensionSettings.customNarratorPrompt = ''; extensionSettings.customNarratorPrompt = '';
extensionSettings.customPlotRandomPrompt = ''; extensionSettings.customPlotRandomPrompt = '';
+6
View File
@@ -138,6 +138,8 @@ export function updateFeatureTogglesVisibility() {
const $featuresRow = $('#rpg-features-row'); const $featuresRow = $('#rpg-features-row');
const $htmlToggle = $('#rpg-html-toggle-wrapper'); const $htmlToggle = $('#rpg-html-toggle-wrapper');
const $dialogueColoringToggle = $('#rpg-dialogue-coloring-toggle-wrapper'); const $dialogueColoringToggle = $('#rpg-dialogue-coloring-toggle-wrapper');
const $deceptionToggle = $('#rpg-deception-toggle-wrapper');
const $cyoaToggle = $('#rpg-cyoa-toggle-wrapper');
const $spotifyToggle = $('#rpg-spotify-toggle-wrapper'); const $spotifyToggle = $('#rpg-spotify-toggle-wrapper');
const $dynamicWeatherToggle = $('#rpg-dynamic-weather-toggle-wrapper'); const $dynamicWeatherToggle = $('#rpg-dynamic-weather-toggle-wrapper');
@@ -147,6 +149,8 @@ export function updateFeatureTogglesVisibility() {
// Show/hide individual toggles // Show/hide individual toggles
$htmlToggle.toggle(extensionSettings.showHtmlToggle); $htmlToggle.toggle(extensionSettings.showHtmlToggle);
$dialogueColoringToggle.toggle(extensionSettings.showDialogueColoringToggle); $dialogueColoringToggle.toggle(extensionSettings.showDialogueColoringToggle);
$deceptionToggle.toggle(extensionSettings.showDeceptionToggle ?? true);
$cyoaToggle.toggle(extensionSettings.showCYOAToggle ?? true);
$spotifyToggle.toggle(extensionSettings.showSpotifyToggle); $spotifyToggle.toggle(extensionSettings.showSpotifyToggle);
$dynamicWeatherToggle.toggle(extensionSettings.showDynamicWeatherToggle); $dynamicWeatherToggle.toggle(extensionSettings.showDynamicWeatherToggle);
@@ -156,6 +160,8 @@ export function updateFeatureTogglesVisibility() {
// Hide entire row if all toggles are hidden // Hide entire row if all toggles are hidden
const anyVisible = extensionSettings.showHtmlToggle || const anyVisible = extensionSettings.showHtmlToggle ||
extensionSettings.showDialogueColoringToggle || extensionSettings.showDialogueColoringToggle ||
(extensionSettings.showDeceptionToggle ?? true) ||
(extensionSettings.showCYOAToggle ?? true) ||
extensionSettings.showSpotifyToggle || extensionSettings.showSpotifyToggle ||
extensionSettings.showDynamicWeatherToggle || extensionSettings.showDynamicWeatherToggle ||
extensionSettings.showNarratorMode || extensionSettings.showNarratorMode ||
+4 -4
View File
@@ -1392,15 +1392,15 @@ function renderHistoryPersistenceTab() {
html += '<div class="rpg-editor-input-row" style="margin-top: 12px;">'; html += '<div class="rpg-editor-input-row" style="margin-top: 12px;">';
html += `<label for="rpg-history-injection-position">Injection Position:</label>`; html += `<label for="rpg-history-injection-position">Injection Position:</label>`;
html += `<select id="rpg-history-injection-position" class="rpg-select" style="margin-left: 8px;">`; html += `<select id="rpg-history-injection-position" class="rpg-select" style="margin-left: 8px;">`;
html += `<option value="user_message_end" ${historyPersistence.injectionPosition === 'user_message_end' ? 'selected' : ''}>End of User Message</option>`; html += `<option value="user_message_end" ${historyPersistence.injectionPosition === 'user_message_end' ? 'selected' : ''}>End of the User's Message</option>`;
html += `<option value="assistant_message_end" ${historyPersistence.injectionPosition === 'assistant_message_end' ? 'selected' : ''}>End of Assistant Message</option>`; html += `<option value="assistant_message_end" ${historyPersistence.injectionPosition === 'assistant_message_end' ? 'selected' : ''}>End of the Assistant's Message</option>`;
html += `</select>`; html += `</select>`;
html += '</div>'; html += '</div>';
// Custom preamble // Custom preamble
html += '<div class="rpg-editor-input-row" style="margin-top: 12px;">'; html += '<div class="rpg-editor-input-row" style="margin-top: 12px;">';
html += `<label for="rpg-history-context-preamble">Custom Context Preamble (optional):</label>`; html += `<label for="rpg-history-context-preamble">Custom Context Preamble:</label>`;
html += `<input type="text" id="rpg-history-context-preamble" value="${historyPersistence.contextPreamble || ''}" class="rpg-text-input" placeholder="Leave empty for default: [Context at this point:]" style="width: 100%; margin-top: 4px;">`; html += `<input type="text" id="rpg-history-context-preamble" value="${historyPersistence.contextPreamble || ''}" class="rpg-text-input" placeholder="Context for that moment:" style="width: 100%; margin-top: 4px;">`;
html += '</div>'; html += '</div>';
// User Stats section - which stats to persist // User Stats section - which stats to persist
+81 -1
View File
@@ -4002,7 +4002,6 @@ body:has(.rpg-panel.rpg-position-left) #sheld {
display: flex; display: flex;
gap: 0; gap: 0;
border-bottom: 2px solid var(--rpg-border); border-bottom: 2px solid var(--rpg-border);
margin-bottom: 1em;
} }
.rpg-editor-tab { .rpg-editor-tab {
@@ -10205,3 +10204,84 @@ body[data-theme="cyberpunk"] .rpg-music-widget-play {
100% { transform: rotate(360deg); } 100% { transform: rotate(360deg); }
} }
/* ============================================
FAB WIDGET THEME VARIATIONS
============================================ */
/* Sci-Fi / Synthwave Theme for FAB Widgets */
body:has(.rpg-panel[data-theme="sci-fi"]) .rpg-fab-widget {
background: rgba(10, 14, 39, 0.95);
border: 1px solid rgba(139, 0, 255, 0.5);
color: #00fff9;
box-shadow: 0 3px 12px rgba(139, 0, 255, 0.3), 0 0 8px rgba(255, 0, 110, 0.2);
}
body:has(.rpg-panel[data-theme="sci-fi"]) .rpg-fab-widget:hover {
border-color: rgba(255, 0, 110, 0.7);
box-shadow: 0 4px 16px rgba(139, 0, 255, 0.5), 0 0 12px rgba(255, 0, 110, 0.4);
}
/* Fantasy / Rustic Theme for FAB Widgets */
body:has(.rpg-panel[data-theme="fantasy"]) .rpg-fab-widget {
background: rgba(43, 24, 16, 0.95);
border: 1px solid rgba(139, 105, 20, 0.6);
color: #f4e8d0;
box-shadow: 0 3px 12px rgba(0, 0, 0, 0.6), 0 0 1px rgba(212, 175, 55, 0.3);
}
body:has(.rpg-panel[data-theme="fantasy"]) .rpg-fab-widget:hover {
border-color: rgba(212, 175, 55, 0.8);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.7), 0 0 8px rgba(212, 175, 55, 0.4);
}
/* Cyberpunk Theme for FAB Widgets */
body:has(.rpg-panel[data-theme="cyberpunk"]) .rpg-fab-widget {
background: rgba(15, 5, 25, 0.95);
border: 1px solid rgba(255, 0, 255, 0.4);
color: #00ffff;
box-shadow: 0 3px 12px rgba(255, 0, 255, 0.3), 0 0 8px rgba(0, 255, 255, 0.2);
}
body:has(.rpg-panel[data-theme="cyberpunk"]) .rpg-fab-widget:hover {
border-color: rgba(0, 255, 255, 0.7);
box-shadow: 0 4px 16px rgba(255, 0, 255, 0.5), 0 0 12px rgba(0, 255, 255, 0.4);
}
/* Minimal Theme for FAB Widgets */
body:has(.rpg-panel[data-theme="minimal"]) .rpg-fab-widget {
background: rgba(245, 245, 250, 0.98);
border: 1px solid rgba(200, 200, 210, 0.8);
color: #2c3e50;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
body:has(.rpg-panel[data-theme="minimal"]) .rpg-fab-widget:hover {
border-color: rgba(52, 152, 219, 0.6);
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}
/* Dark Theme for FAB Widgets */
body:has(.rpg-panel[data-theme="dark"]) .rpg-fab-widget {
background: rgba(25, 25, 35, 0.95);
border: 1px solid rgba(70, 70, 90, 0.6);
color: #e0e0e0;
box-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
}
body:has(.rpg-panel[data-theme="dark"]) .rpg-fab-widget:hover {
border-color: rgba(100, 100, 130, 0.8);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}
/* Light Theme for FAB Widgets */
body:has(.rpg-panel[data-theme="light"]) .rpg-fab-widget {
background: rgba(255, 255, 255, 0.98);
border: 1px solid rgba(220, 220, 230, 0.8);
color: #2c3e50;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
body:has(.rpg-panel[data-theme="light"]) .rpg-fab-widget:hover {
border-color: rgba(52, 152, 219, 0.6);
box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
}
+68 -17
View File
@@ -90,6 +90,24 @@
</label> </label>
</div> </div>
<!-- Deception System Toggle -->
<div class="rpg-toggle-container rpg-feature-col" id="rpg-deception-toggle-wrapper">
<label class="rpg-toggle-label" title="Deception System">
<input type="checkbox" id="rpg-toggle-deception">
<i class="fa-solid fa-masks-theater"></i>
<span class="rpg-toggle-text" data-i18n-key="template.mainPanel.deceptionSystem">Deception System</span>
</label>
</div>
<!-- CYOA Toggle -->
<div class="rpg-toggle-container rpg-feature-col" id="rpg-cyoa-toggle-wrapper">
<label class="rpg-toggle-label" title="CYOA">
<input type="checkbox" id="rpg-toggle-cyoa">
<i class="fa-solid fa-list-ol"></i>
<span class="rpg-toggle-text" data-i18n-key="template.mainPanel.cyoa">CYOA</span>
</label>
</div>
<!-- Spotify Music Toggle --> <!-- Spotify Music Toggle -->
<div class="rpg-toggle-container rpg-feature-col" id="rpg-spotify-toggle-wrapper"> <div class="rpg-toggle-container rpg-feature-col" id="rpg-spotify-toggle-wrapper">
<label class="rpg-toggle-label" title="Spotify Music"> <label class="rpg-toggle-label" title="Spotify Music">
@@ -321,6 +339,24 @@
Display a toggle button to enable/disable colored dialogue formatting. Display a toggle button to enable/disable colored dialogue formatting.
</small> </small>
<label class="checkbox_label">
<input type="checkbox" id="rpg-toggle-show-deception-toggle" />
<span data-i18n-key="template.settingsModal.display.showDeceptionToggle">Show Deception System</span>
</label>
<small style="display: block; margin-left: 24px; margin-top: -8px; color: #888; font-size: 11px;"
data-i18n-key="template.settingsModal.display.showDeceptionToggleNote">
Display a toggle button to enable/disable special formatting of lies and deceptions crafted by the model, allowing it to easily track whenever one was committed, without showing it to the user.
</small>
<label class="checkbox_label">
<input type="checkbox" id="rpg-toggle-show-cyoa-toggle" />
<span data-i18n-key="template.settingsModal.display.showCYOAToggle">Show CYOA</span>
</label>
<small style="display: block; margin-left: 24px; margin-top: -8px; color: #888; font-size: 11px;"
data-i18n-key="template.settingsModal.display.showCYOAToggleNote">
Display a toggle button to enable/disable "Choose Your Own Adventure" formatting instruction that makes the model produce five possible actions/dialogues for you to choose from at the end of the output.
</small>
<label class="checkbox_label"> <label class="checkbox_label">
<input type="checkbox" id="rpg-toggle-show-spotify-toggle" /> <input type="checkbox" id="rpg-toggle-show-spotify-toggle" />
<span data-i18n-key="template.settingsModal.display.showSpotifyMusicToggle">Show Spotify Music</span> <span data-i18n-key="template.settingsModal.display.showSpotifyMusicToggle">Show Spotify Music</span>
@@ -397,16 +433,15 @@
<!-- Mobile FAB Options Section --> <!-- Mobile FAB Options Section -->
<div class="rpg-settings-group"> <div class="rpg-settings-group">
<h4 data-i18n-key="template.settingsModal.mobileFabTitle"><i class="fa-solid fa-mobile-screen-button" <h4 data-i18n-key="template.settingsModal.mobileFabTitle">Mobile Button Widgets</h4>
aria-hidden="true"></i> Mobile Button Widgets</h4>
<small class="notes" style="display: block; margin-bottom: 10px;" <small class="notes" style="display: block; margin-bottom: 10px;"
data-i18n-key="template.settingsModal.mobileFabNote"> data-i18n-key="template.settingsModal.mobileFabNote">
<i class="fa-solid fa-info-circle" aria-hidden="true"></i> Show compact info widgets around the floating button on mobile. Widgets are positioned automatically. Show compact info widgets around the floating button on mobile. Widgets are positioned automatically.
</small> </small>
<label class="checkbox_label"> <label class="checkbox_label">
<input type="checkbox" id="rpg-toggle-fab-widgets-enabled" /> <input type="checkbox" id="rpg-toggle-fab-widgets-enabled" />
<span data-i18n-key="template.settingsModal.mobileFab.enabled">Enable FAB Widgets</span> <span data-i18n-key="template.settingsModal.mobileFab.enabled">Enable Floating Mobile Widgets</span>
</label> </label>
<small style="display: block; margin-left: 24px; margin-top: -8px; color: #888; font-size: 11px;" <small style="display: block; margin-left: 24px; margin-top: -8px; color: #888; font-size: 11px;"
data-i18n-key="template.settingsModal.mobileFab.enabledNote"> data-i18n-key="template.settingsModal.mobileFab.enabledNote">
@@ -562,19 +597,7 @@
Automatically refresh RPG info after each message. Automatically refresh RPG info after each message.
</small> </small>
<label class="checkbox_label" style="margin-top: 16px;"> <div class="rpg-setting-row" style="margin-top: 16px;">
<input type="checkbox" id="rpg-save-tracker-history" />
<span data-i18n-key="template.settingsModal.advanced.saveTrackerHistory">Save Tracker History in
Chat</span>
</label>
<small style="display: block; margin-left: 24px; margin-top: -8px; color: #888; font-size: 11px;"
data-i18n-key="template.settingsModal.advanced.saveTrackerHistoryNote">
When enabled, tracker data is saved in chat history for each message. In Together mode, trackers
appear in &lt;trackers&gt; XML tags (hidden from display). In Separate mode, tracker data is stored
in message metadata. When disabled, only the most recent trackers are kept.
</small>
<div class="rpg-setting-row">
<label for="rpg-encounter-history-depth" data-i18n-key="template.settingsModal.advanced.encounterHistoryDepth">Chat History Depth For Encounters:</label> <label for="rpg-encounter-history-depth" data-i18n-key="template.settingsModal.advanced.encounterHistoryDepth">Chat History Depth For Encounters:</label>
<input type="number" id="rpg-encounter-history-depth" min="1" max="20" value="8" <input type="number" id="rpg-encounter-history-depth" min="1" max="20" value="8"
class="rpg-input" /> class="rpg-input" />
@@ -850,6 +873,34 @@
</button> </button>
</div> </div>
<!-- Deception System Prompt -->
<div class="rpg-prompt-editor-section">
<label for="rpg-prompt-deception" style="display: block; margin-bottom: 8px; font-weight: 600;">
<i class="fa-solid fa-masks-theater"></i> Deception System Prompt
</label>
<small style="display: block; margin-bottom: 8px; color: #888; font-size: 11px;">
Injected when "Enable Deception System" is enabled. Instructs AI to mark lies and deceptions with hidden tags.
</small>
<textarea id="rpg-prompt-deception" class="rpg-prompt-textarea" rows="4"></textarea>
<button class="menu_button rpg-restore-prompt-btn" data-prompt="deception" style="margin-top: 8px;">
<i class="fa-solid fa-rotate-left"></i>&nbsp;Restore Default
</button>
</div>
<!-- CYOA Prompt -->
<div class="rpg-prompt-editor-section">
<label for="rpg-prompt-cyoa" style="display: block; margin-bottom: 8px; font-weight: 600;">
<i class="fa-solid fa-list-ol"></i> CYOA Prompt
</label>
<small style="display: block; margin-bottom: 8px; color: #888; font-size: 11px;">
Injected when "Enable CYOA" is enabled. Instructs AI to end responses with numbered action choices. Uses very high priority (depth 102) to ensure it's the last instruction.
</small>
<textarea id="rpg-prompt-cyoa" class="rpg-prompt-textarea" rows="4"></textarea>
<button class="menu_button rpg-restore-prompt-btn" data-prompt="cyoa" style="margin-top: 8px;">
<i class="fa-solid fa-rotate-left"></i>&nbsp;Restore Default
</button>
</div>
<!-- Spotify Music Prompt --> <!-- Spotify Music Prompt -->
<div class="rpg-prompt-editor-section"> <div class="rpg-prompt-editor-section">
<label for="rpg-prompt-spotify" style="display: block; margin-bottom: 8px; font-weight: 600;"> <label for="rpg-prompt-spotify" style="display: block; margin-bottom: 8px; font-weight: 600;">