Files
storybook/tree-sitter-storybook
Sienna Meridian Satterwhite e6d297420c feat(grammar): update tree-sitter grammar to v0.3.0
Updated tree-sitter grammar to match v0.3.0 LALRPOP parser:

Grammar updates:
- Schedule: block-based syntax with extends, override, recurrence
- Life arc: requires clause for field validation
- Template: uses behaviors/schedules syntax
- Behavior: correct keywords (choose/then/repeat with optional params)
- Type system: concept_comparison with any/is_condition
- Removed concept semicolon requirement

Query file updates:
- highlights.scm: updated node names to *_declaration
- outline.scm: updated for new declaration node names
- indents.scm: updated node names, removed concept semicolon

Corpus test updates:
- Created schedules.txt with v0.3.0 syntax tests
- Created highlights.txt for highlighting tests
- Updated type_system.txt for v0.3.0 type syntax
- Updated behaviors.txt for correct expression wrapping
- Updated declarations.txt to use correct node names
- Updated basic.txt to use character_declaration/character_body
- Deleted obsolete v0.2.0 syntax tests

Integration tests:
- Added tree_sitter_integration.rs test suite
- Fixed test_any_type to use correct v0.3.0 syntax
- Fixed test_tree_sitter_grammar_builds to use generate command
2026-02-14 17:43:26 +00:00
..

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 statements
  • character - Character definitions
  • template - Reusable field templates
  • life_arc - State machines for character development
  • schedule - Daily schedules and routines
  • behavior - Behavior trees for AI
  • institution - Organizations and groups
  • relationship - Multi-party relationships
  • location - Places and settings
  • species - Species definitions with templates
  • enum - 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