Skip to content

fix: replace mock API with real SillyTavern context — tested end-to-end#1

Open
LiweiDonVee wants to merge 2 commits into
X00LA:mainfrom
LiweiDonVee:main
Open

fix: replace mock API with real SillyTavern context — tested end-to-end#1
LiweiDonVee wants to merge 2 commits into
X00LA:mainfrom
LiweiDonVee:main

Conversation

@LiweiDonVee
Copy link
Copy Markdown

What happened

The extension never worked. In both the original (AugieIsHere) and this fork (X00LA), the core function was hardcoded to return empty results — it never called any LLM.

Root cause

In both versions, src/dynamicLore.js contains:

async function generateRaw(prompt, headers) {
    return JSON.stringify({ entries: [] });  // never calls an API
}

Combined with a broken webpack build (invalid externals map for SillyTavern's module system), the extension produced zero results.

Changes

Issue Fix
generateRaw() mock Uses SillyTavern.getContext().generateRaw() — ST's real API
Broken webpack externals Bypassed entirely — plain IIFE loaded via script src
world_info.sync() (doesn't exist) Uses ctx().saveWorldInfo(name, data, true)
Single-keyword false matches Multi-keyword scoring (>=2 match threshold)
AI parent keyword pollution System prompt explicitly forbids parent keywords

Testing

End-to-end tested with DeepSeek V4 Flash against a 10-message conversation. Correctly extracted 4 entries (2 new characters, 1 location, 1 artifact), matched 2 updates to existing WI entries, and wrote valid SillyTavern World Info entries.

Stats

14 files changed, +601 / -4046 lines (removed 3.6MB dist/ artifact, broken webpack, unused src/)

Credits

  • Fixed by: Julian (DeepSeek V4 Pro), 2025
  • Original by: AugieIsHere (Claude 3.7 Sonnet), 2025
  • Fork by: X00LA (Claude 3.5 Sonnet), 2025

Root cause: generateRaw() was hardcoded to return JSON.stringify({entries:[]})
in both the original and X00LA fork. The extension never called any LLM.

Changes:
- Replace broken webpack build with plain IIFE, loaded via <script src>
- Use SillyTavern.getContext().generateRaw() for real API calls
- Replace non-existent world_info.sync() with ctx().saveWorldInfo()
- Implement multi-keyword scoring (>=2 match threshold) for WI matching
- Add system prompt rule to prevent parent keyword pollution in child entries
- Remove 3.6MB dist/ artifact, broken webpack config, unused src/

Tested end-to-end with DeepSeek V4 Flash — correctly extracts characters,
locations, objects, and events from chat conversations and writes them
as valid SillyTavern World Info entries.

Fixed-by: Julian (DeepSeek V4 Pro)
Original-by: AugieIsHere (Claude 3.7 Sonnet)
Fork-by: X00LA (Claude 3.5 Sonnet)
@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented May 8, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  manifest.json  22% smaller
  README.md Unsupported file format
  dist/index.js Unsupported file format
  dist/index.js.LICENSE.txt Unsupported file format
  index.js  0% smaller
  package-lock.json  0% smaller
  package.json  0% smaller
  src/dynamicLore.js  0% smaller
  src/functions.js  0% smaller
  src/index.js  0% smaller
  src/ui.js  0% smaller
  src/ui.js.new Unsupported file format
  webpack.config.js  0% smaller
  webpack.mock.js  0% smaller

Bugs fixed (code-review with find-bugs + code-review skills):

HIGH:
- Race condition: add `analyzing` guard + await lock to prevent
  concurrent generateRaw() calls from onMessage/slash-command
- applyEntry could write to wrong WI book when multiple books
  existed — now uses created book directly instead of re-scanning

MEDIUM:
- XSS: all dynamic content in buildCard now escaped via esc()
  (AI-generated name/content/reason went directly into innerHTML)
- mergeKeys: String(null) produced literal "null" keyword
- getCurrentWIData: warns when multiple books exist without target

LOW:
- buildCard crash on null oldContent.slice()
- Loading indicator with spinner + button disable during analysis
- UI IDs namespaced (dl_* → dynamiclore_*) to prevent collisions

Fixed-by: Julian (DeepSeek V4 Pro)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant