BREAKING CHANGES: - Relationship syntax now requires blocks for all participants - Removed self/other perspective blocks from relationships - Replaced 'guard' keyword with 'if' for behavior tree decorators Language Features: - Add tree-sitter grammar with improved if/condition disambiguation - Add comprehensive tutorial and reference documentation - Add SBIR v0.2.0 binary format specification - Add resource linking system for behaviors and schedules - Add year-long schedule patterns (day, season, recurrence) - Add behavior tree enhancements (named nodes, decorators) Documentation: - Complete tutorial series (9 chapters) with baker family examples - Complete reference documentation for all language features - SBIR v0.2.0 specification with binary format details - Added locations and institutions documentation Examples: - Convert all examples to baker family scenario - Add comprehensive working examples Tooling: - Zed extension with LSP integration - Tree-sitter grammar for syntax highlighting - Build scripts and development tools Version Updates: - Main package: 0.1.0 → 0.2.0 - Tree-sitter grammar: 0.1.0 → 0.2.0 - Zed extension: 0.1.0 → 0.2.0 - Storybook editor: 0.1.0 → 0.2.0
tree-sitter-storybook
Tree-sitter grammar for the Storybook narrative DSL.
Overview
This is a Tree-sitter grammar for Storybook, a domain-specific language for narrative design and character development. The grammar provides syntax highlighting, code navigation, and other editor features through Tree-sitter.
Features
- Syntax highlighting for all Storybook constructs
- Symbol outline for navigating characters, templates, relationships, etc.
- Bracket matching including special handling for prose blocks
- Auto-indentation support
Installation
For development
# Install dependencies
npm install
# Generate parser
npm run build
# Run tests
npm run test
For Zed editor
This grammar is integrated into the Zed Storybook extension. See the zed-storybook directory for the extension.
Grammar Structure
The grammar supports the following top-level declarations:
use- Import statementscharacter- Character definitionstemplate- Reusable field templateslife_arc- State machines for character developmentschedule- Daily schedules and routinesbehavior- Behavior trees for AIinstitution- Organizations and groupsrelationship- Multi-party relationshipslocation- Places and settingsspecies- Species definitions with templatesenum- Enumeration types
Special Features
Prose Blocks
The grammar includes an external scanner (written in C) to handle prose blocks:
---backstory
This is a prose block that can contain
multiple lines of narrative text.
---
Expression Support
Full support for expressions in life arc transitions:
on self.age >= 18 and self.location is wonderland -> adult_state
Testing
The grammar includes comprehensive tests. Run them with:
tree-sitter test
To test parsing a specific file:
tree-sitter parse path/to/file.sb
License
MIT