MCPcopy Index your code
hub / github.com/bmen25124/SillyTavern-Custom-Scenario

github.com/bmen25124/SillyTavern-Custom-Scenario @0.4.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.4.5 ↗ · + Follow
132 symbols 316 edges 24 files 8 documented · 6%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

SillyTavern Custom Scenario

A SillyTavern extension that let you create/play interactive character cards. Do you want to ask a question before starting the scenario? Like the character traits, starting location, etc. You can do it here.

What it does

  • Create scenarios with custom questions
  • Use variables in the description/first message/personality/scenario/character note.
  • Add simple scripts to make things dynamic. (JavaScript)
  • Import/export scenarios as JSON/PNG

How to install

Install via the SillyTavern extension installer.

https://github.com/bmen25124/SillyTavern-Custom-Scenario

Question types

  • Text input
  • Dropdown select
  • Checkbox

How to use

Create a scenario

Click the puzzle icon on the character create/edit sidebar.

create icon

Fill out the form.

create dialog question - text

Open script accordion and test it with the preview button

simple preview in first message

Export it.

Play a scenario

Click the play icon on the characters sidebar and select the JSON/PNG file.

play icon

Fill inputs.

play dialog

Created card

created card

Example Cards

Check rentry page(half NSFW) for examples. You can import on Create Dialog to see how scripts are working.

Simple scripting

You can write basic JavaScript to manipulate variables. For example:

If your description is:

{{user}} just received a package with a gift from an unknown sender. The package is labeled as containing {{gift}}.

You also received a card with the following message: {{occasionMessage}}

Assume this was the answer to the question:

gift: "a book"
message: "birthday"
# As you see, there is no `occasionMessage`

You can write a script for setting occasionMessage

variables.occasionMessage = `Happy {{message}}! Enjoy your new {{gift}}`;

Or:

variables.occasionMessage = `Happy ${variables.message}! Enjoy your new ${variables.gift}`;

Or:

variables.occasionMessage = "Happy " + variables.message + "! Enjoy your new " + variables.gift;

Output will be:

{{user}} just received a package with a gift from an unknown sender. The package is labeled as containing a book.

You also received a card with the following message: Happy birthday! Enjoy your new book

Scripting Details

  • variables is an object that holds all the variables. Aka the answers to the questions.
  • All variables can be accessed and modified.
  • Example usage: (Let's say question id is gift)
    • If question type is text, variables.gift
    • If the question type is dropdown, variables.gift.value and variables.gift.label. When creating the card, variables.gift.label is used.
    • If question type is checkbox, variables.gift. (boolean)
  • Show Script is a script that decides whether to show the question or not in the play dialog. Example: return variables.gift === "birthday" will show the question only if the answer is "birthday".
  • In preview, empty strings are showing as {{variable}} but in the created card, they are not shown.
  • We can get single lorebook entry by await world.getFirst({name?: string, keyword: string}). Example usage:
const info = await world.getFirst({keyword: "triggerWord"}); // name is optional, default name is character lorebook
if (info) {
    variables.f_companion_content = info.content;
}
  • We can get all lorebook entries by await world.getAll({name?: string, keyword: string}). Example usage:
const infos = await world.getAll({keyword: "triggerWord"}); // name is optional, default name is character lorebook
if (infos && infos.length > 0) {
    variables.f_companion_content = infos[0].content;
}

FAQ:

Why did you create this?

I saw this on AIDungeon and liked it. You can see in this reddit post with an example.

Why version is 0.4.4

It is because of UI, not functionality.

Known Issues

  • Tags are not importing to SillyTavern because I don't want to show Import Tags dialog for each play. So I'm planning to add a extension setting to enable/disable this.

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 101
Interface 25
Class 4
Enum 2

Languages

TypeScript92%
Python8%

Modules by API surface

src/create/CreateDialog.tsx30 symbols
src/config.ts23 symbols
src/Popup.tsx11 symbols
src/play/PlayDialog.tsx9 symbols
src/utils/data-handlers.ts8 symbols
src/types/types.ts8 symbols
src/utils/script-utils.ts6 symbols
src/create/ScriptInputs.tsx5 symbols
src/create/QuestionComponent.tsx5 symbols
src/create/App.tsx4 symbols
scripts/storycard_to_lorebook.py4 symbols
scripts/models.py4 symbols

For agents

$ claude mcp add SillyTavern-Custom-Scenario \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page