Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 79 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,88 @@
# DynamicLore Extension for SillyTavern
# DynamicLore — Auto World Info for SillyTavern

**This extension is not affiliated with or endorsed by the SillyTavern team. Use at your own risk.**
Automatically scans your roleplay conversation and proposes new or updated **World Info (lorebook) entries** using your connected LLM. Review and accept/reject each suggestion with one click.

*Human Note: Completely created by AI (Claude 3.7 Sonnett with Reasoning). I don't know if or how this works. Try at your own risk.*
*Human Note: Completely fixed by AI (Claude 3.5 Sonnett with Reasoning). I don't know if or how this works. Try at your own risk.*
## Quick Install

**This extension is designed to enhance your SillyTavern experience by automatically updating your World Info and Lorebook entries based on ongoing conversations. It uses a connected Large Language Model (LLM) to analyze chat content and suggest new or updated entries, ensuring your lore remains rich and relevant without manual effort.**
In SillyTavern, go to **Extensions → Download Extensions and Assets** and paste:
```
https://github.com/LiweiDonVee/Extension-DynamicLore
```

Or manually: clone into `data/default-user/extensions/DynamicLore/`.

**Requires:** SillyTavern ≥ 1.12.0 with a configured chat API (works with any provider — OpenAI, DeepSeek, Claude, Gemini, local models).

## Features

- **Automated Analysis**: Scans conversations for new information to add to your World Info
- **Smart Updates**: Suggests improvements to existing entries when new related information appears
- **Keyword Optimization**: Recommends optimal keywords for entry activation
- **Full User Control**: Review all suggestions before they're applied
- 🔍 **Chat Analysis** — Scans the last N messages for new characters, locations, objects, and events
- 🧠 **LLM-Powered** — Uses your currently connected model (no separate API key needed)
- 🔄 **Smart Matching** — Finds existing WI entries by multi-keyword scoring before proposing updates
- ✅ **Review & Accept** — All suggestions shown as cards with confidence scores; accept or reject each
- 🤖 **Auto Mode** — Runs every N messages automatically
- ⌨️ **Slash Commands** — `/dynamiclore analyze` | `/dynamiclore interval 10` | `/dynamiclore book MyWorld`

## Usage

| Action | How |
|--------|-----|
| Manual scan | Click "Analyze Chat Now" or `/dynamiclore analyze` |
| Change interval | Set the number in the panel, or `/dynamiclore interval 5` |
| Target a specific WI book | `/dynamiclore book MyWorld` |
| Toggle auto mode | Check/uncheck "Auto" in the panel |

After analysis, cards appear showing proposed entries. Each card shows:
- Entry name, type (character/location/object/event), confidence %
- Content preview, suggested keywords
- For updates: old content vs new merged content
- **Accept** / **Reject** buttons

## What Was Fixed

The original extension (by AugieIsHere, generated by Claude 3.7 Sonnet) and its fork (by X00LA) both contained a critical bug:

```js
// BROKEN — both versions returned empty results
async function generateRaw(prompt, headers) {
return JSON.stringify({ entries: [] });
}
```

The `generateRaw` function was **hardcoded to return empty results** — it never called any LLM. Combined with a broken webpack build (invalid externals map), the extension was non-functional from day one.

### This version:

| Issue | Fix |
|-------|-----|
| `generateRaw()` mock | Uses `SillyTavern.getContext().generateRaw()` — the real ST API |
| Broken webpack externals | Bypassed entirely; plain IIFE script loaded via `<script src>` |
| `world_info.sync()` (doesn't exist) | Uses `ctx().saveWorldInfo(name, data, true)` — the correct ST API |
| Single-keyword false matches | Multi-keyword scoring (≥2 match threshold) with name-in-content fallback |
| AI uses parent keywords for child entries | System prompt explicitly forbids this (e.g., don't tag "镜厅" with "布斯巴顿") |

## Architecture

```
index.js (487 lines, no build step)
├── init() → registers slash commands, builds UI, starts listeners
├── analyzeCurrentChat() → builds prompt, calls ctx().generateRaw()
├── extractJSON() → strips markdown fences, parses AI response
├── processEntries() → matches against existing WI, classifies as NEW/UPDATE
├── findMatchingEntry() → multi-keyword scoring algorithm
├── applyEntry() → writes to WI book via ctx().saveWorldInfo()
├── buildUI() → creates the panel and result cards
└── showResults() → renders accept/reject cards
```

All communication with SillyTavern goes through `SillyTavern.getContext()` (exposed on `globalThis` since ST v1.12.0). No webpack, no module bundling, no external dependencies.

## Credits & License

## Installation
- **Fixed by**: Julian (DeepSeek V4 Pro), 2025 — identified root cause, rewrote architecture, end-to-end tested
- **Fork by**: X00LA, 2025 — attempted rework (changed import paths, added `world_info.sync()` calls)
- **Original by**: AugieIsHere, 2025 — initial concept and skeleton (AI-generated by Claude 3.7 Sonnet)
- **License**: AGPL-3.0 (inherited from original)

Install via SillyTavern's built-in "Download Extensions and Assets" tool, or use the direct GitHub link.
---

**Note**: Ensure you have the latest version of SillyTavern for compatibility.
*Built for roleplayers who want their lorebook to write itself.*
2 changes: 0 additions & 2 deletions dist/index.js

This file was deleted.

35 changes: 0 additions & 35 deletions dist/index.js.LICENSE.txt

This file was deleted.

Loading