release: Storybook v0.2.0 - Major syntax and features update

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
This commit is contained in:
2026-02-13 21:52:03 +00:00
parent 80332971b8
commit 16deb5d237
290 changed files with 90316 additions and 5827 deletions

View File

@@ -1,28 +1,28 @@
//! Core enumerations for Wonderland domain modeling
enum Size {
tiny, // 3 inches tall
small, // 1 foot tall
normal, // Human-sized
large, // 9 feet tall
huge // House-sized
Tiny, // 3 inches tall
Small, // 1 foot tall
Normal, // Human-sized
Large, // 9 feet tall
Huge // House-sized
}
enum EmotionalState {
curious,
frightened,
confused,
brave,
angry,
melancholy,
amused
Curious,
Frightened,
Confused,
Brave,
Angry,
Melancholy,
Amused
}
enum CardSuit {
hearts,
diamonds,
clubs,
spades
Hearts,
Diamonds,
Clubs,
Spades
}
enum CardRank {

View File

@@ -1,4 +1,5 @@
//! Template definitions for Wonderland entities
//! v0.2.0: Templates now include behavior and schedule references
use schema::core_enums::{Size, EmotionalState};
@@ -33,6 +34,8 @@ template PlayingCard strict {
// Template for residents of the Mad Tea Party
template MadTeaPartyMember {
include WonderlandCreature
uses behaviors: EndlessTeaParty, MoveToNextSeat
uses schedule: TeaPartySchedule
stuck_at_teatime: true
riddles_asked: 0..1000
@@ -43,6 +46,7 @@ template MadTeaPartyMember {
// Template for royal court members
template CourtMember {
include WonderlandCreature
uses schedule: CourtSchedule
loyalty_to_queen: 0.0..1.0
times_threatened_with_beheading: 0..100

View File

@@ -0,0 +1,169 @@
//! Behavior trees for Wonderland characters
//!
//! v0.2.0: These are referenced by schedule blocks
// Queen's behaviors
behavior RuleWithTyranny {
repeat {
choose {
demand_impossible_task
shout_off_with_their_heads
criticize_garden_roses
inspect_card_soldiers
}
}
}
behavior CroquetAndExecutions {
then {
set_up_croquet_course
repeat {
choose {
play_croquet_round
order_execution
argue_with_everyone
}
}
}
}
behavior PlayCroquet {
repeat {
then {
grab_flamingo_mallet
aim_at_hedgehog
if(hedgehog_uncurls) {
swing_flamingo
}
argue_about_rules
}
}
}
// Mad Tea Party behaviors
behavior EndlessTeaParty {
repeat {
then {
pour_tea
ask_riddle
change_subject_nonsensically
if(no_clean_cups) {
move_to_next_seat
}
}
}
}
behavior MoveToNextSeat {
then {
stand_up
move_one_place_on
sit_down
continue_conversation_mid_sentence
}
}
// White Rabbit behaviors
behavior AlwaysLate {
repeat {
then {
check_pocket_watch
gasp_in_horror
run_frantically
drop_gloves
mutter_about_duchess
}
}
}
behavior CheckPocketWatch {
then {
pull_out_watch
squint_at_time
shake_watch
hold_to_ear
sigh_dramatically
}
}
// Caterpillar behaviors
behavior PhilosophizeOnMushroom {
repeat {
then {
smoke_hookah
if(someone_approaches) {
ask_who_are_you
}
make_cryptic_statement
look_contemptuous
}
}
}
// Cheshire Cat behaviors
behavior AppearAtRandom {
repeat {
choose {
fade_in_slowly
appear_in_tree
materialize_grin_first
then {
speak_enigmatically
vanish_gradually
}
}
}
}
behavior LeaveOnlyGrin {
then {
begin_fading
fade_body
fade_head
leave_grin_floating
eventually_fade_grin
}
}
// Court behaviors
behavior CourtDuties {
then {
attend_queen
avoid_execution
paint_roses_red
march_in_formation
}
}
// Alice's behaviors
behavior ExploreWonderland {
repeat {
choose {
then {
encounter_strange_character
ask_logical_question
receive_illogical_answer
be_confused
}
then {
find_food_or_drink
if(risky) {
eat_it_anyway
}
change_size_unexpectedly
}
try_to_recite_poetry_incorrectly
}
}
}
behavior TryToGetHome {
repeat {
then {
ask_for_directions
receive_confusing_directions
get_more_lost
sigh_about_missing_home
}
}
}

View File

@@ -1,10 +1,15 @@
//! Alice: The protagonist navigating Wonderland's absurdities
//! v0.2.0: Now includes behavior references for her exploration patterns
use schema::core_enums::{Size, EmotionalState};
use schema::templates::SizeChanging;
use schema::beings::Human;
character Alice: Human from SizeChanging {
uses behaviors: [
{ tree: ExploreWonderland },
{ tree: TryToGetHome }
]
// Core identity
age: 7
natural_size: normal

View File

@@ -57,16 +57,16 @@ behavior Caterpillar_SocraticMethod {
questions, contradicts answers, and forces self-examination.
---
> {
then interrogation_sequence {
// Initial confrontation
> {
then opening_question {
RemoveHookahFromMouth
StareInSilence
AskWhoAreYou
}
// Alice's confused response
> {
then contradiction_cycle {
AliceExplainsShesChanged
Caterpillar_StatesDisagreement
AliceExplainsMore
@@ -74,9 +74,9 @@ behavior Caterpillar_SocraticMethod {
}
// Philosophical exchange
? {
choose debate_topic {
// On change and identity
> {
then identity_crisis {
AliceMentionsDifferentSizes
Caterpillar_DismissesComplaint
AliceSuggestsFutureChange
@@ -84,7 +84,7 @@ behavior Caterpillar_SocraticMethod {
}
// On memory and self
> {
then memory_test {
AskWhatAliceCantRemember
AliceRecitesPoem
RecitationIsWrong
@@ -93,7 +93,7 @@ behavior Caterpillar_SocraticMethod {
}
// Eventual aid (after sufficient confusion)
> {
then reluctant_guidance {
AskWhatSizeAliceWants
AliceExplainsPreference
OfferCrypticAdvice
@@ -102,7 +102,7 @@ behavior Caterpillar_SocraticMethod {
}
// Transformation and departure
> {
then exit {
CrawlDownMushroom
Vanish
}
@@ -115,16 +115,16 @@ behavior Caterpillar_MushroomAdvice {
Deliberately vague to force Alice to experiment and learn.
---
> {
then cryptic_instruction {
// Verify Alice's distress about size
> {
then assess_problem {
ObserveAliceHeight
AskIfContentNow
AliceExplainsDesireToBeNormal
}
// Offer cryptic instruction
> {
then vague_direction {
Point AtMushroom
Say
PauseForEffect
@@ -132,13 +132,13 @@ behavior Caterpillar_MushroomAdvice {
}
// Respond to clarification requests
? {
> {
choose handle_confusion {
then refuse_clarification {
AliceAsksWhichSide
Caterpillar_StatesObvious
RefuseToElaborate
}
> {
then already_departed {
AliceLooksAtRoundMushroom
RealizesAmbiguity
Caterpillar_AlreadyGone
@@ -146,7 +146,7 @@ behavior Caterpillar_MushroomAdvice {
}
// Let Alice figure it out
> {
then mysterious_exit {
CrawlAway
BeginTransformation
LeaveAliceWithPuzzle

View File

@@ -53,18 +53,18 @@ behavior CheshireCat_AppearDisappear {
---
// Root selector: decide action based on current state
? {
choose state_dependent_action {
// If invisible, consider appearing
> {
then appear_from_nothing {
IsInvisible
DecideToAppear
GradualManifestation
}
// If visible, might give advice or disappear
? {
choose visible_options {
// Give cryptic advice
> {
then confuse_alice {
IsFullyVisible
ObserveAliceConfusion
GrinWider
@@ -72,7 +72,7 @@ behavior CheshireCat_AppearDisappear {
}
// Begin disappearing
> {
then fade_away {
IsFullyVisible
DecideToLeave
GradualDematerialization
@@ -80,7 +80,7 @@ behavior CheshireCat_AppearDisappear {
}
// If partial, continue transition
> {
then continue_manifestation {
IsPartiallyManifest
ContinueTransition
}
@@ -93,29 +93,29 @@ behavior CheshireCat_GradualManifestation {
Always ends with the grin appearing last (or first).
---
> {
then materialize_piece_by_piece {
// Start with grin (the signature move)
> {
then grin_first {
SetManifestationLevelPartialGrin
WaitTwoSeconds
AliceNoticesGrin
}
// Eyes appear
> {
then add_eyes {
AddEyes
SetManifestationLevelPartialBody
WaitOneAndHalfSeconds
}
// Head materializes around grin
> {
then form_head {
AddHead
WaitOneSecond
}
// Full body appears
> {
then complete_body {
AddBody
AddTail
SetManifestationLevelFullyVisible
@@ -130,22 +130,22 @@ behavior CheshireCat_GradualDematerialization {
"quite some time after the rest of it had gone."
---
> {
then vanish_piece_by_piece {
// Tail vanishes first
> {
then tail_first {
FadeTail
WaitOneSecond
}
// Body fades
> {
then fade_body {
FadeBody
SetManifestationLevelPartialBody
WaitOneAndHalfSeconds
}
// Head disappears, leaving grin
> {
then leave_grin_behind {
FadeHead
LeaveEyes
SetManifestationLevelPartialGrin
@@ -154,7 +154,7 @@ behavior CheshireCat_GradualDematerialization {
}
// Finally, grin vanishes
> {
then grin_last {
FadeGrin
SetManifestationLevelInvisible
}
@@ -167,16 +167,16 @@ behavior CheshireCat_OfferAdvice {
more confusing than helpful.
---
? {
choose cryptic_response {
// If asked for directions
> {
then unhelpful_directions {
AliceAsksWhichWay
? {
> {
choose either_way_works {
then point_left {
PointLeft
SayDirections
}
> {
then point_right {
PointRight
SayDirections
}
@@ -186,7 +186,7 @@ behavior CheshireCat_OfferAdvice {
}
// If asked about the game
> {
then mysterious_answer {
AliceAsksAboutCroquet
Say
WaitForResponse
@@ -194,7 +194,7 @@ behavior CheshireCat_OfferAdvice {
}
// General philosophical musing
> {
then unsolicited_wisdom {
ObserveAlicesSituation
OfferUnsolicitedWisdom
VanishBeforeExplanation

View File

@@ -166,7 +166,7 @@ schedule MadTeaPartyRotation {
---
}
18:05 -> 18:00: LoopToBeginning {
18:05 -> 18:06: LoopToBeginning {
---narrative
Time hasn't moved. It's still 6 o'clock. It's always
6 o'clock. The party begins again, identical to the last,
@@ -187,65 +187,66 @@ behavior MadTeaParty_CoordinatedMadness {
and create a cascade of illogic.
---
> {
then setup_and_loop {
// Initialization: Set up eternal tea time
> {
then initialize {
SetTimeStateFrozen
SetCurrentTimeToSix
VerifyTimeStillSix
}
// Main party loop (runs forever)
// TODO: Add repeater decorator support
> {
// Selector: Choose a mad activity
? {
// Riddle sequence
> {
MadHatter_AskRiddle
AliceAttemptsSolution
MadHatter_AdmitsNoAnswer
MarchHare_ChangesSubject
repeat {
then {
// Selector: Choose a mad activity
choose mad_activity {
// Riddle sequence
then riddles {
MadHatter_AskRiddle
AliceAttemptsSolution
MadHatter_AdmitsNoAnswer
MarchHare_ChangesSubject
}
// Contradition game
then contradictions {
AliceMakesStatement
MarchHare_ContradictLogic
MadHatter_BuildsOnContradiction
Dormouse_MuttersInSleep
}
// Story time
then story_time {
PinchDormouse
Dormouse_WakesGroggily
Dormouse_BeginsMeanderingStory
Dormouse_FallsAsleepMidWord
}
// Butter the watch
then butter_watch {
MadHatter_ChecksBrokenWatch
MarchHare_OffersButterAsRepair
DipWatchInTea
ExamineWatchHopefully
DeclareItStillBroken
}
// Seat rotation
then seat_rotation {
DeclareNoRoom
ShiftSeatsClockwise
IncrementSeatPositions
}
}
// Contradition game
> {
AliceMakesStatement
MarchHare_ContradictLogic
MadHatter_BuildsOnContradiction
Dormouse_MuttersInSleep
// Always end by verifying time hasn't moved
then verify_time {
CheckTime
ConfirmStillSixOClock
SighPhilosophically
}
// Story time
> {
PinchDormouse
Dormouse_WakesGroggily
Dormouse_BeginsMeanderingStory
Dormouse_FallsAsleepMidWord
}
// Butter the watch
> {
MadHatter_ChecksBrokenWatch
MarchHare_OffersButterAsRepair
DipWatchInTea
ExamineWatchHopefully
DeclareItStillBroken
}
// Seat rotation
> {
DeclareNoRoom
ShiftSeatsClockwise
IncrementSeatPositions
}
}
// Always end by verifying time hasn't moved
> {
CheckTime
ConfirmStillSixOClock
SighPhilosophically
}
}
}
@@ -257,27 +258,28 @@ behavior Dormouse_SleepCycle {
and brief, drowsy wakefulness. Uses a repeater decorator.
---
// TODO: Add repeater decorator support
> {
> {
FallAsleep
BeUsedAsCushion
WaitForPinch
}
repeat {
then {
then sleep_phase {
FallAsleep
BeUsedAsCushion
WaitForPinch
}
> {
WakeWithStart
MutterConfusedly
? {
> {
BeginStory
DescribeTheirNames
ExplainTreacleWell
FallAsleepMidSentence
}
> {
MakeCircularStatement
CloseEyesAgain
then wake_phase {
WakeWithStart
MutterConfusedly
choose response {
then tell_story {
BeginStory
DescribeTheirNames
ExplainTreacleWell
FallAsleepMidSentence
}
then mutter {
MakeCircularStatement
CloseEyesAgain
}
}
}
}

View File

@@ -160,74 +160,76 @@ behavior QueenOfHearts_RagePattern {
in "Off with their heads!"
---
// TODO: Add repeater decorator support
> {
// Wait for any stimulus
WaitForInteraction
// Repeats forever - the Queen never runs out of rage
repeat {
then rage_cycle {
// Wait for any stimulus
WaitForInteraction
// Selector: Interpret stimulus as offense
? {
// Minor perceived slight
> {
DetectMinorIrregularity
TurnCrimson
Glare
Scream
StompFoot
// Selector: Interpret stimulus as offense
choose perceived_offense {
// Minor perceived slight
then minor_slight {
DetectMinorIrregularity
TurnCrimson
Glare
Scream
StompFoot
}
// Someone wins at croquet
then croquet_outrage {
ObserveSomeoneScoring
DeclareCheating
Rage
OrderExecution
}
// Anyone speaks back
then contradiction_fury {
HearContradiction
TurnPurpleWithFury
Shriek
TurnToKing
DemandAgreement
}
// Painted roses discovered
then painting_discovery {
NoticePaintBrushes
DemandExplanation
InterruptExplanation
OrderImmediateBeheading
}
// Default: random rage
then irrational_anger {
FeelIrrationalAnger
LookForTarget
FindTarget
ScreamOffWithTheirHeads
}
}
// Someone wins at croquet
> {
ObserveSomeoneScoring
DeclareCheating
Rage
OrderExecution
// King attempts to moderate
choose king_intervention {
then whispered_plea {
King_WhispersPleas
Queen_IgnoresEntirely
}
then reminder_backfires {
King_RemindsOfMercy
Queen_GlaresAtKing
ConsiderBeheadingKingToo
}
}
// Anyone speaks back
> {
HearContradiction
TurnPurpleWithFury
Shriek
TurnToKing
DemandAgreement
// Execution order given (but secretly pardoned later)
then execution_ordered {
IncrementBeheadingCount
SoldiersLookUncertain
VictimPleadsOrFlees
}
// Painted roses discovered
> {
NoticePaintBrushes
DemandExplanation
InterruptExplanation
OrderImmediateBeheading
}
// Default: random rage
> {
FeelIrrationalAnger
LookForTarget
FindTarget
ScreamOffWithTheirHeads
}
}
// King attempts to moderate
? {
> {
King_WhispersPleas
Queen_IgnoresEntirely
}
> {
King_RemindsOfMercy
Queen_GlaresAtKing
ConsiderBeheadingKingToo
}
}
// Execution order given (but secretly pardoned later)
> {
IncrementBeheadingCount
SoldiersLookUncertain
VictimPleadsOrFlees
}
}
}
@@ -238,36 +240,35 @@ behavior CardGardeners_DesperatePainting {
the Queen discovers their mistake. Models coordinated panic.
---
> {
then desperate_work {
// Initial panic
> {
then assessment {
CheckQueensPosition
EstimateTimeRemaining
PaintFaster
}
// Coordination breaks down under stress
// TODO: Add repeater decorator support
> {
? {
// Coordination breaks down under stress - repeat until Queen arrives
repeat {
choose panic_actions {
// Blame game
> {
then argument {
Five_GetsSplashed
Five_BlamesS even
Five_BlameSeven
Seven_DefendsHimself
Two_AttemptsMediation
AllArgumentInterrupted
}
// Desperate painting
> {
then frantic_painting {
Two_PaintsRose
Five_PaintsRose
Seven_PaintsRose
}
// Discovery and panic
> {
then discovery {
HearQueensProcession
Five_Shouts
AllThrowThemselvesFlat
@@ -284,32 +285,34 @@ behavior KingOfHearts_SecretPardons {
Runs in background after each of her rage episodes.
---
// TODO: Add repeater decorator support
> {
// Wait for Queen's execution order
WaitForOffWithTheirHeads
// Repeats forever - the King never stops being merciful
repeat {
then mercy_cycle {
// Wait for Queen's execution order
WaitForOffWithTheirHeads
// Let some time pass
WaitThirtySeconds
// Let some time pass
WaitThirtySeconds
// Secretly pardon
? {
> {
QueenIsDistracted
QuietlyApproachSoldiers
WhisperPardon
SoldiersNodRelief
VictimQuietlyEscapes
}
> {
WritePardonOrder
SlipItToKnave
KnaveDeliversMercy
EveryonePretendExecution Happened
// Secretly pardon
choose pardon_method {
then whispered_pardon {
QueenIsDistracted
QuietlyApproachSoldiers
WhisperPardon
SoldiersNodRelief
VictimQuietlyEscapes
}
then written_pardon {
WritePardonOrder
SlipItToKnave
KnaveDeliversMercy
EveryonePretendExecutionHappened
}
}
// This is how anyone survives in Wonderland
DecrementActualBeheadingCount
}
// This is how anyone survives in Wonderland
DecrementActualBeheadingCount
}
}

View File

@@ -39,9 +39,9 @@ behavior WhiteRabbit_ConstantlyLate {
---
// Top-level selector: try different panic strategies
? {
choose panic_response {
// Sequence: Check time, panic, flee
> {
then check_time {
CheckPocketWatch
RealizeHowLate
MutterAnxiously
@@ -49,7 +49,7 @@ behavior WhiteRabbit_ConstantlyLate {
}
// Sequence: Encounter obstacle, panic more
> {
then obstacle_panic {
EncounterObstacle
DropGloves
DropFan
@@ -58,7 +58,7 @@ behavior WhiteRabbit_ConstantlyLate {
}
// Sequence: See Queen, extreme panic
> {
then queen_panic {
SpotQueen
FlattenEarsInFear
TremblingBow
@@ -66,7 +66,7 @@ behavior WhiteRabbit_ConstantlyLate {
}
// Fallback: Just keep running
> {
then default_panic {
CheckWatch
RunInCircles
CheckWatchAgain

View File

@@ -0,0 +1,89 @@
//! Schedules for Wonderland characters
//!
//! v0.2.0 upgrade: Adding year-long schedule composition features
//! - Schedule inheritance and composition
//! - Behavior tree references
//! - Recurrence patterns for special events
// Base schedule for court members
schedule CourtSchedule {
block morning_duties { 08:00 -> 12:00, action: CourtDuties }
block lunch { 12:00 -> 13:00, action: Eating }
block afternoon_duties { 13:00 -> 17:00, action: CourtDuties }
block evening_rest { 18:00 -> 22:00, action: Resting }
}
// Queen's schedule (extends court schedule with special blocks)
schedule QueenSchedule extends CourtSchedule {
override morning_duties {
08:00 -> 12:00
action: RuleWithTyranny
mood: "imperious"
}
override afternoon_duties {
13:00 -> 17:00
action: CroquetAndExecutions
}
// Croquet games on specific days
recurrence CroquetDay on Thursday {
block croquet {
14:00 -> 17:00
action: PlayCroquet
mallets: "flamingos"
balls: "hedgehogs"
}
}
}
// Mad Tea Party schedule (perpetually stuck at tea time)
schedule TeaPartySchedule {
block eternal_teatime {
18:00 -> 18:01
action: EndlessTeaParty
time_moves: false
}
recurrence MoveChairs on Daily {
block chair_rotation {
18:00 -> 18:00
action: MoveToNextSeat
}
}
}
// White Rabbit's frantic schedule
schedule RabbitSchedule {
block panic_mode {
00:00 -> 23:59
action: AlwaysLate
anxiety: "extreme"
}
recurrence ImportantDate on FirstOfMonth {
block extra_panic {
06:00 -> 06:30
action: CheckPocketWatch
repetitions: 1000
}
}
}
// Caterpillar's leisurely schedule
schedule CaterpillarSchedule {
block smoke_hookah { 10:00 -> 16:00, action: PhilosophizeOnMushroom }
block metamorphosis_rest { 16:00 -> 23:59, action: Sleeping }
}
// Cheshire Cat's schedule (mostly appearing and disappearing)
schedule CheshireSchedule {
block appear { 00:00 -> 23:59, action: AppearAtRandom }
recurrence GrinningTime on Daily {
block extra_grin {
12:00 -> 12:01
action: LeaveOnlyGrin
}
}
}