v3.2.5: Always enable JSON cleaning regex with proper settings
This commit is contained in:
@@ -35,40 +35,53 @@ export async function ensureJsonCleaningRegex(st_extension_settings, saveSetting
|
||||
// Update existing script with new regex pattern if it's different
|
||||
const newPattern = '/```json[\\s\\S]*?```/gim';
|
||||
|
||||
// Always ensure these properties are set correctly
|
||||
let needsSave = false;
|
||||
|
||||
if (existingScript.findRegex !== newPattern) {
|
||||
existingScript.findRegex = newPattern;
|
||||
existingScript.placement = [2]; // 2 = AI Output
|
||||
existingScript.disabled = false; // Ensure it's enabled
|
||||
existingScript.runOnEdit = true; // Ensure it runs on edit
|
||||
existingScript.displayOnly = true; // Alter Chat Display
|
||||
existingScript.onlyFormatDisplay = true; // Ensure display formatting is enabled
|
||||
|
||||
if (typeof saveSettingsDebounced === 'function') {
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
console.log('[RPG Companion] Updated regex pattern and placement.');
|
||||
} else {
|
||||
// Ensure it's enabled even if pattern matches
|
||||
if (existingScript.disabled) {
|
||||
existingScript.disabled = false;
|
||||
if (typeof saveSettingsDebounced === 'function') {
|
||||
saveSettingsDebounced();
|
||||
}
|
||||
console.log('[RPG Companion] Re-enabled disabled regex.');
|
||||
} else {
|
||||
// Also update placement if it's wrong
|
||||
const expectedPlacement = [2]; // 2 = AI Output
|
||||
if (JSON.stringify(existingScript.placement) !== JSON.stringify(expectedPlacement)) {
|
||||
existingScript.placement = expectedPlacement;
|
||||
if (typeof saveSettingsDebounced === 'function') {
|
||||
saveSettingsDebounced();
|
||||
// Force immediate save after a short delay
|
||||
setTimeout(() => saveSettingsDebounced(), 100);
|
||||
}
|
||||
console.log('[RPG Companion] Updated regex placement to [2].');
|
||||
}
|
||||
}
|
||||
needsSave = true;
|
||||
}
|
||||
|
||||
if (JSON.stringify(existingScript.placement) !== JSON.stringify([2])) {
|
||||
existingScript.placement = [2]; // 2 = AI Output
|
||||
needsSave = true;
|
||||
}
|
||||
|
||||
if (existingScript.disabled !== false) {
|
||||
existingScript.disabled = false;
|
||||
needsSave = true;
|
||||
}
|
||||
|
||||
if (existingScript.runOnEdit !== true) {
|
||||
existingScript.runOnEdit = true;
|
||||
needsSave = true;
|
||||
}
|
||||
|
||||
if (existingScript.displayOnly !== true) {
|
||||
existingScript.displayOnly = true; // Alter Chat Display
|
||||
needsSave = true;
|
||||
}
|
||||
|
||||
if (existingScript.onlyFormatDisplay !== true) {
|
||||
existingScript.onlyFormatDisplay = true; // Alter Chat Display
|
||||
needsSave = true;
|
||||
}
|
||||
|
||||
if (existingScript.onlyFormatPrompt !== true) {
|
||||
existingScript.onlyFormatPrompt = true; // Alter Outgoing Prompt
|
||||
needsSave = true;
|
||||
}
|
||||
|
||||
if (existingScript.promptOnly !== true) {
|
||||
existingScript.promptOnly = true; // Enable prompt processing
|
||||
needsSave = true;
|
||||
}
|
||||
|
||||
if (existingScript.filterGaslighting !== true) {
|
||||
existingScript.filterGaslighting = true; // Ephemerality
|
||||
}
|
||||
|
||||
console.log('[RPG Companion] JSON Cleaning Regex is already downloaded and active.');
|
||||
return;
|
||||
}
|
||||
@@ -97,10 +110,11 @@ export async function ensureJsonCleaningRegex(st_extension_settings, saveSetting
|
||||
placement: [2], // 2 = AI Output
|
||||
disabled: false,
|
||||
markdownOnly: false,
|
||||
promptOnly: false,
|
||||
promptOnly: true, // Enable prompt processing
|
||||
runOnEdit: true,
|
||||
displayOnly: true, // Alter Chat Display
|
||||
onlyFormatDisplay: true, // Ensure display formatting is enabled
|
||||
onlyFormatDisplay: true, // Alter Chat Display (enabled)
|
||||
onlyFormatPrompt: true, // Alter Outgoing Prompt (enabled)
|
||||
filterGaslighting: true, // Ephemerality - makes it only affect display
|
||||
substituteRegex: 0,
|
||||
minDepth: null,
|
||||
maxDepth: null
|
||||
|
||||
Reference in New Issue
Block a user