fix: flexible prompts
This commit is contained in:
@@ -210,7 +210,10 @@ export function parseResponse(responseText) {
|
|||||||
content.match(/User Stats\s*\n\s*---/i) ||
|
content.match(/User Stats\s*\n\s*---/i) ||
|
||||||
content.match(/Player Stats\s*\n\s*---/i) ||
|
content.match(/Player Stats\s*\n\s*---/i) ||
|
||||||
// Fallback: look for stat keywords without strict header
|
// Fallback: look for stat keywords without strict header
|
||||||
(content.match(/Health:\s*\d+%/i) && content.match(/Energy:\s*\d+%/i));
|
(content.match(/Health:\s*\d+%/i) && content.match(/Energy:\s*\d+%/i)) ||
|
||||||
|
// Fallback: inventory-only or quests-only blocks (no stats header)
|
||||||
|
(content.match(/^(On Person:|Inventory:|Main Quests?:|Optional Quests:)/im) &&
|
||||||
|
!content.match(/Info Box/i) && !content.match(/Present Characters/i));
|
||||||
|
|
||||||
// Match Info Box section - flexible patterns
|
// Match Info Box section - flexible patterns
|
||||||
const isInfoBox =
|
const isInfoBox =
|
||||||
|
|||||||
@@ -212,8 +212,10 @@ export function generateTrackerInstructions(includeHtmlPrompt = true, includeCon
|
|||||||
const trackerConfig = extensionSettings.trackerConfig;
|
const trackerConfig = extensionSettings.trackerConfig;
|
||||||
let instructions = '';
|
let instructions = '';
|
||||||
|
|
||||||
// Check if any trackers are enabled
|
// Check if any trackers are enabled (including inventory and quests as independent sections)
|
||||||
const hasAnyTrackers = extensionSettings.showUserStats || extensionSettings.showInfoBox || extensionSettings.showCharacterThoughts;
|
const hasAnyTrackers = extensionSettings.showUserStats || extensionSettings.showInfoBox ||
|
||||||
|
extensionSettings.showCharacterThoughts || extensionSettings.showInventory ||
|
||||||
|
extensionSettings.showQuests;
|
||||||
|
|
||||||
// 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) {
|
||||||
@@ -221,40 +223,46 @@ export function generateTrackerInstructions(includeHtmlPrompt = true, includeCon
|
|||||||
const trackerPrompt = (extensionSettings.customTrackerPrompt || DEFAULT_TRACKER_PROMPT).replace(/\{\{user\}\}/g, userName);
|
const trackerPrompt = (extensionSettings.customTrackerPrompt || DEFAULT_TRACKER_PROMPT).replace(/\{\{user\}\}/g, userName);
|
||||||
instructions += `\n${trackerPrompt}\n`;
|
instructions += `\n${trackerPrompt}\n`;
|
||||||
|
|
||||||
// Add format specifications for each enabled tracker
|
// Check if we need a combined stats/inventory/quests code block
|
||||||
if (extensionSettings.showUserStats) {
|
const hasStatsBlock = extensionSettings.showUserStats || extensionSettings.showInventory || extensionSettings.showQuests;
|
||||||
|
|
||||||
|
if (hasStatsBlock) {
|
||||||
const userStatsConfig = trackerConfig?.userStats;
|
const userStatsConfig = trackerConfig?.userStats;
|
||||||
const enabledStats = userStatsConfig?.customStats?.filter(s => s && s.enabled && s.name) || [];
|
const enabledStats = userStatsConfig?.customStats?.filter(s => s && s.enabled && s.name) || [];
|
||||||
|
|
||||||
instructions += '```\n';
|
instructions += '```\n';
|
||||||
instructions += `${userName}'s Stats\n`;
|
|
||||||
instructions += '---\n';
|
// Add user stats section if enabled
|
||||||
|
if (extensionSettings.showUserStats) {
|
||||||
|
instructions += `${userName}'s Stats\n`;
|
||||||
|
instructions += '---\n';
|
||||||
|
|
||||||
// Add custom stats dynamically
|
// Add custom stats dynamically
|
||||||
for (const stat of enabledStats) {
|
for (const stat of enabledStats) {
|
||||||
instructions += `- ${stat.name}: X%\n`;
|
instructions += `- ${stat.name}: X%\n`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add status section if enabled
|
// Add status section if enabled
|
||||||
if (userStatsConfig?.statusSection?.enabled) {
|
if (userStatsConfig?.statusSection?.enabled) {
|
||||||
const statusFields = userStatsConfig.statusSection.customFields || [];
|
const statusFields = userStatsConfig.statusSection.customFields || [];
|
||||||
const statusFieldsText = statusFields.map(f => `${f}`).join(', ');
|
const statusFieldsText = statusFields.map(f => `${f}`).join(', ');
|
||||||
|
|
||||||
if (userStatsConfig.statusSection.showMoodEmoji) {
|
if (userStatsConfig.statusSection.showMoodEmoji) {
|
||||||
instructions += `Status: [Mood Emoji${statusFieldsText ? ', ' + statusFieldsText : ''}]\n`;
|
instructions += `Status: [Mood Emoji${statusFieldsText ? ', ' + statusFieldsText : ''}]\n`;
|
||||||
} else if (statusFieldsText) {
|
} else if (statusFieldsText) {
|
||||||
instructions += `Status: [${statusFieldsText}]\n`;
|
instructions += `Status: [${statusFieldsText}]\n`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add skills section if enabled
|
||||||
|
if (userStatsConfig?.skillsSection?.enabled) {
|
||||||
|
const skillFields = userStatsConfig.skillsSection.customFields || [];
|
||||||
|
const skillFieldsText = skillFields.map(f => `[${f}]`).join(', ');
|
||||||
|
instructions += `Skills: [${skillFieldsText || 'Skill1, Skill2, etc.'}]\n`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add skills section if enabled
|
// Add inventory format - independent of showUserStats
|
||||||
if (userStatsConfig?.skillsSection?.enabled) {
|
|
||||||
const skillFields = userStatsConfig.skillsSection.customFields || [];
|
|
||||||
const skillFieldsText = skillFields.map(f => `[${f}]`).join(', ');
|
|
||||||
instructions += `Skills: [${skillFieldsText || 'Skill1, Skill2, etc.'}]\n`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add inventory format - only if showInventory is enabled
|
|
||||||
if (extensionSettings.showInventory) {
|
if (extensionSettings.showInventory) {
|
||||||
if (extensionSettings.useSimplifiedInventory) {
|
if (extensionSettings.useSimplifiedInventory) {
|
||||||
// Simplified single-line inventory format
|
// Simplified single-line inventory format
|
||||||
@@ -271,7 +279,7 @@ export function generateTrackerInstructions(includeHtmlPrompt = true, includeCon
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add quests section - only if showQuests is enabled
|
// Add quests section - independent of showUserStats
|
||||||
if (extensionSettings.showQuests) {
|
if (extensionSettings.showQuests) {
|
||||||
instructions += 'Main Quests: [Short title of the currently active main quest (for example, "Save the world"), or "None"]\n';
|
instructions += 'Main Quests: [Short title of the currently active main quest (for example, "Save the world"), or "None"]\n';
|
||||||
instructions += 'Optional Quests: [Short titles of the currently active optional quests (for example, "Find Zandik\'s book"), or "None"]\n';
|
instructions += 'Optional Quests: [Short titles of the currently active optional quests (for example, "Find Zandik\'s book"), or "None"]\n';
|
||||||
|
|||||||
Reference in New Issue
Block a user