bonsai

0plantpot

How it Works

Bonsai is a tool for creating interactive fiction through a mix of manual authoring and AI-assisted generation.

The Process

1

Author your story

Write directly in the script editor using markup, or playtest and click on any text to edit it permanently.

2

Play to explore

Navigate your story as a player. Your input will match defined choices, or the AI will generate new branches. Other players can explore too!

3

Prune your branches

Review AI-generated changes, edit them, then approve or discard. Only the latest unresolved branch can be discarded, so work through them in order.

4

Check the guidebook

The guidebook automatically learns your preferences from edits. Check it occasionally to ensure it's on track, or edit it directly.

Syntax Reference

Scenes

Scenes are marked with @. They define locations or states in your story. Add [allows: new|link|text] to control AI generation.

@HOME
You're in a cozy room.

@GARDEN [allows: new]
The flowers sway gently.
(AI can create new scenes from here)

@HUB [allows: text]
What do you want to do?
(AI can only add flavor text, no scene changes)

new = AI can create scenes (default), link = only existing scenes, text = flavor only

Choices

Use if to define player choices. Separate synonyms with |.

if go outside | leave | exit
    You step out into the garden.
    goto @GARDEN

Navigation

goto @SCENE moves the player to another scene.

if open the door
    The door creaks open.
    goto @HALLWAY

Variables (Counters)

Variables are counters. Use +var to increment (add 1), -var to decrement (subtract 1). Use & ?var after a choice to require it.

if buy sword
    -gold
    +sword
    You got a sword!

if buy another sword
    -gold
    +sword
    Now you have two swords!

if attack & ?sword
    You swing your blade.

Display: sword (count=1), sword (2) (count=2), etc.

Conditional Blocks

Use when var (true if ≥1), when !var (true if 0), or when var >= N for threshold checks.

@SHOP
when gold >= 10
    You can afford the sword!
when !gold
    Your pockets are empty.

@BATTLE
when sword >= 2
    You dual-wield your blades!
when sword
    You swing your sword.
when !sword
    You fight with your fists.

Turn Counter & Global Conditions

A turn variable auto-increments on each player input. Add global conditions before any scene to create time limits or pacing.

when turn >= 10
    Time is running out...
when turn >= 20
    goto @GAME_OVER

@START
You begin your adventure.
if explore
    goto @FOREST

@GAME_OVER
Your time has run out.
goto @END

Images

Add images with [image: url].

@GARDEN
[image: https://example.com/garden.png]
The garden is beautiful.

Indentation

Use tabs to nest content under choices and conditions. Everything indented under an if or when belongs to that block.

when !key
    Oh lookee, there's a key!
    if take it | yes
        +key
        Yoink!
    if leave it | no
        You step back.

Tips

  • Use @END as a special scene to end the story.
  • Synonyms in choices make your game more forgiving to players.
  • Generated branches appear in the branch panel — review and prune regularly.
  • The guidebook learns from your edits to generated content, making future generations better.
  • Use when turn >= N in the global preamble for time limits or pacing events.
  • Stack variables with multiple +var for inventory, XP, or resource systems.
  • Use [allows: text] on hub scenes to force explicit branches, letting AI extend within paths.