diff --git a/index.js b/index.js index b04927b..7eb82d5 100644 --- a/index.js +++ b/index.js @@ -138,7 +138,7 @@ import { // Feature modules import { setupPlotButtons, sendPlotProgression } from './src/systems/features/plotProgression.js'; import { setupClassicStatsButtons } from './src/systems/features/classicStats.js'; -import { ensureHtmlCleaningRegex, detectConflictingRegexScripts, ensureTrackerCleaningRegex, ensureOmniscienceFilterCleaningRegex } from './src/systems/features/htmlCleaning.js'; +import { ensureHtmlCleaningRegex, detectConflictingRegexScripts, ensureTrackerCleaningRegex } from './src/systems/features/htmlCleaning.js'; import { ensureJsonCleaningRegex, removeJsonCleaningRegex } from './src/systems/features/jsonCleaning.js'; import { parseAndStoreSpotifyUrl } from './src/systems/features/musicPlayer.js'; import { DEFAULT_HTML_PROMPT } from './src/systems/generation/promptBuilder.js'; @@ -1219,14 +1219,6 @@ jQuery(async () => { // Non-critical - continue without it } - // Import the omniscience filter cleaning regex (hides tags from display) - try { - await ensureOmniscienceFilterCleaningRegex(st_extension_settings, saveSettingsDebounced); - } catch (error) { - console.error('[RPG Companion] Omniscience filter regex import failed:', error); - // Non-critical - continue without it - } - // Import the JSON cleaning regex to clean up JSON in messages // This cleans historical messages when displayed try { diff --git a/src/systems/features/htmlCleaning.js b/src/systems/features/htmlCleaning.js index 81a2196..371496a 100644 --- a/src/systems/features/htmlCleaning.js +++ b/src/systems/features/htmlCleaning.js @@ -197,87 +197,3 @@ export async function ensureTrackerCleaningRegex(st_extension_settings, saveSett // Don't throw - this is a nice-to-have feature } } - -/** - * Automatically imports a regex script to clean tags from displayed messages. - * This hides omniscience filter content (events the player character cannot perceive) - * from the visible chat while keeping them in the message data. - * @param {Object} st_extension_settings - SillyTavern extension settings object - * @param {Function} saveSettingsDebounced - Function to save settings - */ -export async function ensureOmniscienceFilterCleaningRegex(st_extension_settings, saveSettingsDebounced) { - try { - // Validate extension settings structure - if (!st_extension_settings || typeof st_extension_settings !== 'object') { - console.warn('[RPG Companion] Invalid extension_settings object, skipping omniscience filter regex import'); - return; - } - - // Check if the omniscience filter cleaning regex already exists - const scriptName = 'Clean Omniscience Filter Tags (Display Only)'; - const existingScripts = st_extension_settings?.regex || []; - - // Validate regex array - if (!Array.isArray(existingScripts)) { - console.warn('[RPG Companion] extension_settings.regex is not an array, resetting to empty array'); - st_extension_settings.regex = []; - } - - const alreadyExists = existingScripts.some(script => - script && typeof script === 'object' && script.scriptName === scriptName - ); - - if (alreadyExists) { - // console.log('[RPG Companion] Omniscience filter cleaning regex already exists, skipping import'); - return; - } - - // Generate a UUID for the script - const uuidv4 = () => { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - const r = Math.random() * 16 | 0; - const v = c === 'x' ? r : (r & 0x3 | 0x8); - return v.toString(16); - }); - }; - - // Create the regex script to remove tags from display - // This regex matches the specific tag format used by omniscience filter - // Pattern: or - const regexScript = { - id: uuidv4(), - scriptName: scriptName, - findRegex: '/]*\\/?>(?:<\\/filter>)?/gi', - replaceString: '', - trimStrings: [], - placement: [1], // 1 = Display only (affects visible chat, not outgoing prompts) - disabled: false, - markdownOnly: false, - promptOnly: false, - runOnEdit: true, - substituteRegex: 0, - minDepth: null, - maxDepth: null - }; - - // Add to global regex scripts - if (!Array.isArray(st_extension_settings.regex)) { - st_extension_settings.regex = []; - } - - st_extension_settings.regex.push(regexScript); - - // Save the changes - if (typeof saveSettingsDebounced === 'function') { - saveSettingsDebounced(); - } else { - console.warn('[RPG Companion] saveSettingsDebounced is not a function, cannot save omniscience filter regex'); - } - - // console.log('[RPG Companion] ✅ Omniscience filter cleaning regex imported successfully'); - } catch (error) { - console.error('[RPG Companion] Failed to import omniscience filter cleaning regex:', error); - console.error('[RPG Companion] Error details:', error.message, error.stack); - // Don't throw - this is a nice-to-have feature - } -} diff --git a/src/systems/generation/promptBuilder.js b/src/systems/generation/promptBuilder.js index d1b06be..78cfc53 100644 --- a/src/systems/generation/promptBuilder.js +++ b/src/systems/generation/promptBuilder.js @@ -41,19 +41,20 @@ export const DEFAULT_OMNISCIENCE_FILTER_PROMPT = `OMNISCIENCE FILTER INSTRUCTION You must strictly separate what the player character can directly perceive from what they cannot. The player should only read narrative content that their character can actually see, hear, smell, touch, or otherwise directly sense. If the player character cannot directly perceive something, but it is happening, it ABSOLUTELY MUST be placed inside of a tag. BEFORE writing any narrative content that involves events, actions, or details the player character CANNOT directly perceive (because they're not looking, too far away, behind them, in another room, happening silently, etc.), you MUST first output that hidden information inside a tag using this exact format: - + CRITICAL RULES: 1. The tag must come BEFORE any sensory hints (sounds, smells, etc.) that the player DOES perceive from that event 2. Only write narrative that reflects what the player character actually experiences through their senses -3. Instead of "Jake sweeps the floor behind you", write: followed by narrative like "You hear soft sweeping sounds behind you" +3. Instead of "Jake sweeps the floor behind you", write: followed by narrative like "You hear soft sweeping sounds behind you" 4. NPCs' internal thoughts, silent actions, and events in other locations MUST go in tags 5. The player's narrative should create natural mystery and immersion - they experience the world through limited senses, not omniscient narration 6. Be liberal and proactive in using tags to hide information the player cannot perceive directly +7. Don't forget to properly enclose the tag. EXAMPLE: Wrong: "As you read the newspaper, Sarah quietly pockets the key from the table behind you and slips out the back door." -Correct: You hear a faint click from somewhere behind you, but when you glance up from your newspaper, the room seems unchanged. The afternoon light streams through the windows as you return to your reading.`; +Correct: You hear a faint click from somewhere behind you, but when you glance up from your newspaper, the room seems unchanged. The afternoon light streams through the windows as you return to your reading.`; /**