AIfrit Labs — Internal Tooling

Character Generator

A browser-based creation tool for building custom AIfrits Artifacts NPC profiles, dialogue trees, trading behavior, and validation-safe JSON exports. No install, no build step — open the HTML file and go.

What it is

The Complete Character Authoring Environment

The Character Generator lets you build full character files — tree JSON, character JSON, and bundles — without touching raw text. It understands the AIfrit schema deeply: dual next/next_node fields, mood tags, flag scoping, trade outcome blocks, and the full validation layer.

🌐
Zero Install
Pure HTML + JavaScript. Open character_generator.html in any modern browser. Works offline. No server, no dependencies, no build step.
💾
Auto-Save
Every change is written to browser localStorage instantly. Work persists across browser sessions and page refreshes automatically.
Live Validation
Broken links, orphaned nodes, missing gates, and flag mismatches are detected in real-time and surfaced in the Validation tab and sidebar badges.
🕸
Visual Graph
The Graph tab renders your full dialogue tree as an interactive node map — showing connections, entry points, dead ends, and broken routes visually.
📂
Drag & Drop Import
Drop any .json file onto the window — tree, character, or bundle — and it auto-detects the format and loads it immediately.
Command Palette
Press Ctrl+K to open the command palette. Search nodes by name, switch tabs instantly, trigger actions — all from the keyboard.
Getting started

Quickstart Guide

From zero to a working dialogue tree in under five minutes.

1
Open the Studio
Download character_generator.html and open it in any modern browser (Chrome, Firefox, Edge, Safari). No server needed.
2
Set the Tree ID and Character ID
Fill in tree_id and character_id in the top bar. These become the filenames and link the tree to your character. Use snake_case — e.g. tourist_bob_buyer.
3
Apply a Preset or Import
Pick a Preset from the dropdown (buyer, seller, lore, mini-game, courier, quest) and click Apply Preset for a ready-made scaffold. Or drop an existing .json file onto the window to edit it.
4
Click a Node → Edit on the Right
Click any node in the left sidebar. The editor panel opens it with five tabs: Dialogue, Choices, Routing, Advanced, Preview. Write your dialogue, pick moods, add choices.
5
Fill Out the Studio Tab
Go to the Studio tab to set the character's name, role, rarity, personality, lore, avatar paths, AI persona seed, and trade behavior.
6
Check Validation
The Validation tab badge shows a count of warnings. Fix broken links (⚠ in sidebar), unreachable nodes, and hidden nodes without gates before exporting.
7
Export
Click Export Tree ↓ to download the tree JSON. Use Export Char for the character file, or Bundle ↓ for both combined. The export profile controls whether the output uses preserve, hybrid, or scripted runtime style.
💡
Importing existing live files
Keep the export profile on Preserve — imported source style when editing files that are already in production. This ensures the schema stays byte-for-byte consistent with whatever the runtime expects.
Layout

Interface Overview

The studio is a three-column, tabbed editor. Here's what each region does.

Top Bar
Quick-access fields: tree_id, character_id, title, trade mode, version, preset selector, export profile. Action buttons for new, import, and export. The ⌘ Search button opens the command palette.
Node Sidebar (Left)
All nodes for the current tree, filterable by name. Each node shows its type chip, mood emojis, choice count, and status badges (entry end broken orphan). Drag the resize handle to widen or narrow it.
Editor Panel (Right)
Context-sensitive editor. The top shows tree/character breadcrumbs and a node ID / type selector. Below are the main tabs: Node, Studio, Validation, Graph, JSON.
Entry Pickers (Sidebar Bottom)
Dropdowns for entry_node_id and extended_entry_node_id. These define where the runtime starts the conversation on first and return visits.
Node System

Node Types & What They Do

Every node has a type field. The type affects runtime behavior, sidebar color coding, and which validation checks apply.

dialogue
Standard speaking node
farewell
Closes the interaction
terminal
Hard stop, no choices
hidden
Flag-gated, not visible by default
mini_game
Hosts a game payload
success
Positive outcome branch
failure
Negative outcome branch
hidden_failure
Silent fail, flag-gated
conditional
Routes based on conditions
branch
Logic fork, no dialogue
consequence
Outcome with side effects
risk
Gamble branch
narration
No choices, narrative beat
skill_check
Stat-gated branch
dynamic_opener
AI-generated entry
oracle_sequence
Multi-beat AI sequence
menu
Choice hub, no speech
⚠️
Hidden nodes need a gate
Nodes of type hidden should always have a requires_flag or conditions block. The validation system will warn you if a hidden node has no gate — it would be unreachable and silently fail in the runtime.
Node editor

The Five Node Tabs

When you click a node in the sidebar, the editor opens it with five tabs.

◈ Dialogue

Where you write what the character says.


Content Mode toggle — switch between simple dialogue string mode (fastest for buyer/seller trees) and dialogue_lines mode (multi-speaker, per-line delays, AI flags for scripted runtime trees).


Mood Quick Picker — click emoji buttons to toggle mood tags. Active moods appear as MOOD: 😌 😊 prepended to the dialogue text. The live preview below shows exactly how the stored string will look.


Dialogue Body — the text the character speaks, after the mood tag line.


ai_prompt — optional prompt for the AI to rewrite or fill in the dialogue at runtime. Leave blank to use the authored dialogue verbatim.


Mini-Game Payload — collapsed section for mini_game type nodes. Paste the live game payload as JSON here.

◈ Choices

Where you build the player's response options.


Add Choice — adds a new player option to this node. Each choice has a Display Text (what the player sees), a Next Target (dropdown of all node IDs), and an internal id / option_id.


Missing link warning — if a choice points to a node that doesn't exist, the Next Target field shows missing. This also marks the node broken in the sidebar.


↑ ↓ reorder — use the arrow buttons to change the display order of choices.


Choice Metadata (collapsed) — per-choice flags (sets_flag, flag_set, requires_flag), phase gates, gold requirements, rapport/trust deltas, and raw JSON fields for outcomes, effects, and requirements.


Container toggle — switch between exporting as choices or player_options depending on the target runtime style.

◈ Routing

Controls how the engine decides whether to show this node and what happens after it completes.


Gate fieldsrequires_flag (single flag must be set), requires_flags (ALL of these must be set), requires_flags_any (ANY of these must be set). Comma-separated strings.


next_node_id — direct routing without a choice. When set, the node advances automatically after completing without showing choices.


fallback_node_id — where to route if conditions fail or a choice target is missing.


conditions JSON — the full conditions block for priority-based entry point selection (e.g. flag_absent, flag_present, phase_min).


on_complete / outcomes — action blocks that fire when the node finishes. Set enable_trading: true, a price_modifier, reputation_change, flag sets, and checkpoint unlocks here.

◈ Advanced

Less common fields kept out of the main view to avoid clutter.


priority — integer used when multiple nodes are marked is_entry_point: true. Lower numbers fire first when conditions match.


speaker override — overrides the default character speaker for this specific node (useful for multi-character scenes).


character_id override — routes the node to a different character's data context.


behavior_context_injection — checkbox. When on, the runtime injects live behavioral context (rapport level, recent trades, known keywords) into the AI prompt for this node.


notes / scene_note — author-only notes that don't export to the live runtime files.


ambient_effects JSON — runtime ambient overrides (e.g. ui_mode: "antagonist", glitch_enabled: true for characters like Agent VEX).


Passthrough Extras JSON — any live fields the tool doesn't model explicitly are stored here and round-trip safely on export.

◈ Preview

A read-only panel showing what the node will look like in the exported JSON.


Flattened Dialogue Preview — the full dialogue string as it will be stored, including mood tags.


Schema Preview — the full node exported as JSON in the currently selected export profile (preserve/hybrid/scripted).


Route View — "Routes Out" shows every choice and next_node exit from this node. "Reached From" shows every other node that links into this one. This is the fastest way to trace a path through the tree without looking at the graph.


Flags Set / Flags Required — which flags this node sets and which it requires, color-coded by scope (local vs global).

The Four Main Tabs

TabKeyWhat it's for
◈ NODE1 The active node editor with its five sub-tabs. This is where 90% of authoring happens.
🎭 STUDIO2 Character identity, assets, lore, trade behavior, buff/penalty notes, AI persona seed, AI system prompt, flag registries. Edit everything about the person, not just the tree.
✔ VALIDATION3 Full validation report: error/warn/info messages with links to the offending node. Flag Registry showing every flag used, where it's set, and where it's required. Path & Route Summary with entry nodes, farewell nodes, trade closeout nodes, and broken links.
🕸 GRAPH4 Visual node map. Nodes are laid out by BFS depth from entry points. Click any node in the graph to jump to it in the editor. Broken links are drawn in red dashes. Unreachable nodes have a red border.
{} JSON5 Live preview of the tree JSON, character JSON, and bundle JSON as they would be exported right now. Also includes raw JSON editors for Desk Notes and Quest Metadata.
Output

Export Profiles

The export profile controls how the output JSON is shaped. Change it in the top bar dropdown or in Studio Settings.

ProfileUse whenWhat it does
preserve Editing live files Round-trips the file byte-for-byte. Uses the same field names, case style, and key ordering as the file you imported. This is the safest default for production files like tourist_bob or agent_vex.
hybrid New characters Writes both next and next_node_id in choices, uses choices as the key, outputs dialogue as the content field. Suitable for characters that need to work with both older and newer runtimes.
scripted Targeting scripted runtime Uses dialogue_lines arrays, player_options as the choice key, and next_node in choices. Suitable for characters like Agent VEX that need multi-speaker line sequences.
⚠️
Passthrough fields
Any fields that the Studio doesn't explicitly model (stored in _extras) are always passed through on export in all profiles. Switching from preserve to hybrid or scripted will reshape choice key names — the Validation tab will warn you if this affects the current file.
Power user

Keyboard Shortcuts

ShortcutAction
Ctrl + KOpen command palette — search nodes, switch tabs, run actions
Ctrl + SForce save to localStorage with a visual confirmation toast
1Switch to Node tab (when no input is focused)
2Switch to Studio tab
3Switch to Validation tab
4Switch to Graph tab
5Switch to JSON tab
NAdd a new node (when no input focused)
DDuplicate the selected node
EscClose command palette
ℹ️
Tab-switch shortcuts
The number shortcuts (1–5) and the N / D shortcuts only fire when your cursor is not inside a text input, textarea, or select — so they never conflict with typing.
Reference

JSON Schema Reference

The Studio produces two files per character — a tree JSON and a character JSON — plus an optional bundle combining both.

Tree JSON — Top-Level Fields

FieldTypeNotes
tree_idstringPrimary identifier. Used as filename. e.g. tourist_bob_buyer
character_idstringLinks to the character file
titlestringHuman-readable display name
versionnumberIncrement when making breaking changes
trade_modebuyer | seller | neutralControls which trade direction the tree handles
entry_node_idstringDefault conversation start node
extended_entry_node_idstringUsed on return visits or after lore unlocks
nodesNode[]All dialogue nodes for this tree
flags_definedstring[]Flags this tree creates
flags_consumedstring[]Flags this tree reads from other trees
theme_tagsstring[]Searchable content tags
prerequisite_flagsstring[]Flags that must be set before this tree can be entered

Node Fields

FieldNotes
node_idUnique within the tree. Used as the link target for choices.
typeSee node types table above
dialogueFull dialogue string including optional MOOD: 😌\n prefix
dialogue_linesArray of {speaker, text, delay_ms, ai_generated} for scripted runtime
choices / player_optionsArray of player response options
is_entry_pointIf true, engine considers this a candidate for tree entry (with priority + conditions)
priorityLower = checked first. Used when multiple entry nodes exist.
conditionsObject. Supports flag_present, flag_absent, phase_min, phase_max
requires_flagSingle flag that must be set for this node to be visible
requires_flagsArray. ALL must be set.
requires_flags_anyArray. ANY one must be set.
on_completeAction block fired when node finishes. Contains trade, flag, and reputation fields.
outcomesSecondary action block for outcome-specific side effects
next_node_idAuto-advance target (no choice shown)
fallback_node_idWhere to go if gating fails
ai_promptPrompt for AI to rewrite the dialogue line at runtime
behavior_context_injectionInjects live rapport/trade context into the AI call
ambient_effectsRuntime UI overrides (glitch mode, antagonist theme, etc.)
terminalBoolean. True for farewell/terminal types.
hiddenBoolean. True for hidden type.

Choice / Option Fields

FieldNotes
id / option_idInternal identifier. Also exported as option_id for scripted runtime.
textDisplay text shown to the player
next / next_node_id / next_nodeTarget node. The Studio normalizes to next internally and exports all three in hybrid mode.
sets_flag / flag_setFlag to set when this choice is picked
requires_flagFlag required to show this choice
requires_flagsAll of these flags must be set
phase_min / phase_maxConversation phase gates
requires_goldGold cost to select
rapport_change / trust_deltaReputation effects for choosing this option
outcomesJSON block for choice-specific side effects
effectsAdditional effect block
requirementsComplex requirement object for skill checks etc.

on_complete / outcomes Action Block

FieldNotes
enable_tradingBoolean. Triggers the trade UI after this node.
trade_modebuyer | seller | neutral. Overrides tree-level mode for this node.
price_modifierFloat. 1.0 = base price. 1.1 = 10% premium. 0.9 = 10% discount.
reputation_changeInteger delta applied to the player's rapport with this character.
sets_flag / flag_setFlag to set on completion
flag_set_2 / set_flag_2Second flag set on completion
set_flagsArray of flags to set
checkpoint_unlock / note_idUnlock a story checkpoint or journal note
Edge Cases

Special Characters & Advanced Cases

Agent VEX — Antagonist Trees

Agent VEX uses the scripted runtime style — dialogue_lines arrays with player_options as the choice key, next_node in choices, and advanced ambient effects. To edit her tree:


  1. Import agent_vex_tree.json using Import Tree or drag-and-drop
  2. Set export profile to Preserve — imported source style
  3. Enable use dialogue_lines mode in the Dialogue tab for her nodes
  4. Set ambient_effects via the Advanced tab (JSON block) for glitch/antagonist UI mode
  5. Use behavior_context_injection: true on nodes that reference live game state

Her priority and conditions fields on entry nodes enable the multi-visit routing engine. Lower priority = checked first. The flag_absent: vex_encounter_initiated condition gates first-encounter nodes, and flag_present gates return visit nodes.

Flag Scoping

Flags in the system have two scopes:


  • local — scoped to a single character's conversation context. Reset between sessions unless persistence is on.
  • global — shared across all characters. Flags starting with global_ are always treated as global. Others can be declared global in the character's global flag registry field in the Studio tab.

The Flag Registry in the Validation tab shows every flag in the current tree, its scope, where it is set, and where it is required — useful for catching flags that are required but never set.

Mood Tag Format

Mood tags live on the first line of the dialogue field:

MOOD: 😌 😊
The rest of this text is the dialogue body.

The Studio parses and re-assembles this automatically. Click emoji buttons in the Mood Quick Picker to toggle them. The live preview shows the final combined string at all times.


Moods affect the runtime's visual presentation (character expression, ambient music, UI color wash). Multiple moods can be stacked.

Multi-Visit Routing with Priority Entry Nodes

When a character has multiple is_entry_point: true nodes, the runtime checks them in ascending priority order and fires the first one whose conditions pass.


Pattern for first vs. return visits:

// First encounter node
priority: 1
conditions: { flag_absent: "char_met" }

// Return visit node
priority: 2
conditions: { flag_present: "char_met" }

Set the on_complete block of the first encounter node to sets_flag: "char_met".

Changelog

What's New in This Version

🕸
Visual Graph Tab
BFS-ranked node layout showing all connections, entry points, broken links (red dashes), and unreachable nodes. Click any node in the graph to jump to its editor.
Command Palette
Press Ctrl+K to instantly search nodes by name, switch tabs, or trigger actions. Arrow keys and Enter navigate the results.
📂
Drag & Drop Import
Drop a .json file anywhere on the window. Auto-detects tree, character, or bundle format and imports with a toast confirmation.
Resizable Sidebar
Drag the handle between the sidebar and editor to resize. Position is remembered across sessions.
🔔
Toast Notifications
Non-blocking status messages replace alert() dialogs. Every import, export, add, delete, and error now surfaces as a dismissible toast.
Keyboard Shortcuts
Number keys 1–5 for tabs. N/D for add/duplicate node. Ctrl+S for save confirmation. All context-aware so they don't fire while typing.
🎨
AIfrit Visual Design
Full redesign using the AIfrit Labs color palette — deep navy backgrounds, gold accents, Cinzel/Crimson display font. Consistent with the main aifrit.com aesthetic.
🏷
Tab Validation Badges
The Validation tab shows a live warning count badge. Green ✓ when clean, red count when warnings exist — visible without having to click in.

AI-Assisted Character Wizard

The guided wizard is now the recommended starting point for player-friendly character creation. It asks for identity, voice, opening dialogue, player choices, lore, trade behavior, and farewells, then generates an engine-safe dialogue tree.

Open the AI-Assisted Character Wizard or use the Advanced Generator for direct node editing.