feat: add current lorebook entries plugin api#1450
Open
yaa19212-droid wants to merge 1 commit into
Open
Conversation
cubicj
approved these changes
May 31, 2026
Collaborator
cubicj
left a comment
There was a problem hiding this comment.
Verified the plugin API path. It returns a snapshot of the current raw lorebook sources without touching DB write APIs.
Check, tests, and build pass locally.
Approving — thanks for the contribution!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Summary
Adds
risuai.getCurrentLorebookEntries()to the v3 plugin API.The new API returns raw lorebook entries from these current sources:
globalLorelocalLoreIt does not apply lorebook activation, recursive scanning, or token budget filtering.
Related Issues
None.
Changes
getCurrentLorebookEntries()toRisuaiPluginAPI.getCurrentLorebookEntries()in the v3 plugin API.getModuleLorebooks()for currently active module lorebooks instead of reimplementing active module resolution in the plugin API layer.RisuAI already combines the same source categories when building lorebook prompts:
This PR exposes that raw source collection to plugins without exposing whole character, chat, or module objects.
Impact
This is an additive v3 plugin API. Existing APIs and lorebook activation behavior are unchanged.
The API is intended for plugins that need to search lorebook entries from the current character, chat, and active modules. Existing workarounds can require snapshotting larger parent objects:
getCharacter()for character or groupglobalLoregetChatFromIndex()for chatlocalLoregetDatabase(['modules'])plus plugin-side active module resolution formodule lorebooks
Large character cards or modules may contain unrelated fields such as asset reference arrays, trigger/script data, HTML/CSS, or long chat data. Module asset binaries are stored separately, but module objects can still include large asset metadata/reference arrays with names, file names, and SHA-256-based asset paths.
Behavior notes:
globalLore, matching the source collection used byloadLoreBookV3Prompt().Additional Notes
Verification:
pnpm run check.svelte-checkreported 0 errors and 0 warnings.Local benchmark context:
I tested the current workaround with a v3 benchmark plugin against a local RisuAI database containing large modules. In that environment:
getDatabase(['enabledModules'])returned in about 1-2 ms with a payload of a few hundred bytes.getDatabase(['modules'])took about 300 ms and returned about 4.20 MB.getCharacter()took about 1 second in the tested character contexts.The exact numbers depend on user data, but the results show that current workarounds can copy large parent objects and asset reference arrays that are unrelated to lorebook lookup.
Footnotes
Modifies the behavior of prompting, requesting, or handling responses from AI models. ↩
Over 80% of the code is AI generated. ↩