chore: final cleanup

This commit is contained in:
Subarashimo
2025-12-05 18:10:21 +01:00
parent 38328de1bf
commit 7e47dbfd7c
29 changed files with 338 additions and 2168 deletions
-1
View File
@@ -5,7 +5,6 @@
import {
extensionSettings,
pendingDiceRoll,
setPendingDiceRoll
} from '../../core/state.js';
import { saveSettings } from '../../core/persistence.js';
+1 -7
View File
@@ -3,11 +3,10 @@
* Adds maximum activation limit to SillyTavern's World Info system
*/
import { eventSource, event_types } from '../../../../../../../script.js';
import { eventSource } from '../../../../../../../script.js';
let maxActivations = 0; // 0 = unlimited
let settingsInitialized = false;
let activatedEntriesThisGeneration = [];
/**
* Initialize the lorebook limiter
@@ -136,11 +135,6 @@ function injectMaxActivationsUI() {
function patchWorldInfoActivation() {
console.log('[Lorebook Limiter] Setting up activation limiter...');
// We need to intercept at the module level
// Use a Proxy on the module loader
const originalDefine = window.define;
const originalRequire = window.require;
// Try multiple approaches to hook into the WI system
const attemptPatch = () => {
// Approach 1: Direct window access
+2 -66
View File
@@ -3,11 +3,9 @@
* Handles generation of lorebook entries from chat history
*/
import { chat, characters, this_chid, generateRaw, substituteParams, eventSource, event_types } from '../../../../../../../script.js';
import { selected_group } from '../../../../../../group-chats.js';
import { chat, generateRaw, eventSource, event_types } from '../../../../../../../script.js';
import { extensionSettings, addDebugLog } from '../../core/state.js';
import { saveSettings } from '../../core/persistence.js';
import { checkWorldInfo, createNewWorldInfo, openWorldInfoEditor, saveWorldInfo, setWorldInfoSettings } from '../../../../../../world-info.js';
import { checkWorldInfo, createNewWorldInfo, openWorldInfoEditor, saveWorldInfo } from '../../../../../../world-info.js';
/**
* Helper to log to both console and debug logs array
@@ -117,68 +115,6 @@ function createConstantHeaderEntry() {
return entry;
}
/**
* Save a world info entry to a lorebook
* @param {string} lorebookUid - The filename/UID of the lorebook
* @param {Object} entry - The entry data
*/
async function saveWorldInfoEntry(lorebookUid, entry) {
try {
debugLog('[Memory Recollection] Saving entry to lorebook:', lorebookUid);
// Open the world info editor for this lorebook to load its data
await openWorldInfoEditor(lorebookUid);
// Wait for it to load
await new Promise(resolve => setTimeout(resolve, 500));
// Now access the loaded world info data
const worldInfo = window.world_info;
debugLog('[Memory Recollection] World info after opening:', {
type: typeof worldInfo,
isArray: Array.isArray(worldInfo),
hasEntries: worldInfo?.entries !== undefined,
keys: worldInfo ? Object.keys(worldInfo).slice(0, 10) : null
});
// Try different structures - it might be an array or might have different properties
let entries;
if (worldInfo && typeof worldInfo === 'object') {
if (worldInfo.entries) {
entries = worldInfo.entries;
} else if (Array.isArray(worldInfo)) {
// If it's an array, convert to entries object
entries = {};
worldInfo.forEach((e, i) => {
if (e && e.uid) {
entries[e.uid] = e;
}
});
}
}
if (!entries) {
entries = {};
}
// Add the entry
entries[entry.uid] = entry;
debugLog('[Memory Recollection] Entry added, saving world info...');
// Save using the imported saveWorldInfo function
// Pass the entries as the data structure
await saveWorldInfo(lorebookUid, { entries });
debugLog('[Memory Recollection] Entry saved successfully');
return { success: true };
} catch (error) {
console.error('[Memory Recollection] Error saving entry:', error);
throw error;
}
}
/**
* Save multiple world info entries to a lorebook at once
* @param {string} lorebookUid - The filename/UID of the lorebook
-11
View File
@@ -70,7 +70,6 @@ export function setupPlotButtons(handlePlotClick) {
*/
export async function sendPlotProgression(type) {
if (!extensionSettings.enabled) {
// console.log('[RPG Companion] Extension is disabled');
return;
}
@@ -83,8 +82,6 @@ export async function sendPlotProgression(type) {
extensionSettings.enabled = false;
try {
// console.log(`[RPG Companion] Sending ${type} plot progression request...`);
// Build the prompt based on type
let prompt = '';
if (type === 'random') {
@@ -100,13 +97,8 @@ export async function sendPlotProgression(type) {
prompt += '\n\n' + htmlPromptText;
}
// Set flag to indicate we're doing plot progression
// This will be used by onMessageReceived to clear the prompt after generation completes
setIsPlotProgression(true);
// console.log('[RPG Companion] Calling Generate with continuation and plot prompt');
// console.log('[RPG Companion] Full prompt:', prompt);
// Pass the prompt via options with the correct property name
// Based on /continue slash command implementation, it uses quiet_prompt (underscore, not camelCase)
const options = {
@@ -114,10 +106,7 @@ export async function sendPlotProgression(type) {
quietToLoud: true
};
// Call Generate with 'continue' type and our custom prompt
await Generate('continue', options);
// console.log('[RPG Companion] Plot progression generation triggered');
} catch (error) {
console.error('[RPG Companion] Error sending plot progression:', error);
setIsPlotProgression(false);