Commit Graph

38 Commits

Author SHA1 Message Date
2c898347ee feat(lang): rename schedule keyword from extends to modifies
Changed the schedule composition keyword from "extends" to "modifies"
to better reflect the semantic meaning of schedule inheritance. When
a schedule modifies another, it inherits base blocks and can override
them by name or add new blocks.

This is a breaking change for all existing Storybook files that use
schedule composition. The migration is a simple find-and-replace:
  schedule X extends Y → schedule X modifies Y

Changes include:
- Grammar: Updated tree-sitter grammar and lexer token
- Parser: Updated lalrpop parser and AST field names
- Documentation: Updated all reference docs, tutorials, and specs
- Examples: Updated baker-family example schedules
- Tests: Updated all test cases and corpus files
- Testing: Added type system keywords to prop_tests exclusion list
- Tooling: Added xtask for workspace cleanup
- Version: Bumped to v0.3.1 (skipping v0.3.0)
- Spec: Created SBIR v0.3.1 spec documenting the change

BREAKING CHANGE: The "extends" keyword for schedules has been
replaced with "modifies". Update all schedule declarations.
2026-02-16 22:52:48 +00:00
a9445fd80c chore(zed): update grammar revision to e6d2974 2026-02-14 17:47:01 +00:00
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
0c4994acd2 chore(zed): update grammar revision to f440247
Updated to include the any_type highlighting fix.
2026-02-14 16:43:12 +00:00
f440247537 fix(tree-sitter): correct any_type highlighting in queries
Changed highlights.scm to use (any_type) node type instead of the
string literal "any". The grammar defines any as any_type rule,
not as a bare keyword string.
2026-02-14 16:41:37 +00:00
50b9ee2034 chore(zed): update grammar revision to latest commit
Updated rev to 26bbef58d3 which
includes the fixed span tracking in LALRPOP parser.
2026-02-14 16:33:51 +00:00
26bbef58d3 fix(lsp): correct line numbers in convert species/template tests
The tests were using line: 2 but the character declarations were on
line: 1 (due to the leading newline in the raw string literal). This
caused the cursor position to be outside the character span, making
the code actions fail to trigger.

Fixed by changing line: 2 to line: 1 in both test_convert_species_to_template
and test_convert_template_to_species.
2026-02-14 16:29:22 +00:00
b042f81aeb feat(examples): expand baker-family with relationships and world context
Added comprehensive v0.3.0 feature demonstration:

Characters (5 total):
- Martha & Jane (married lesbian couple, co-owners of bakery)
- Emma (their daughter, apprentice baker)
- Henry (loyal customer, retired teacher)
- Roland (competing baker)

New declarations:
- 6 relationships with asymmetric perspectives (Marriage, ParentChild×2,
  BusinessPartnership, CustomerRelationship, Competition)
- Locations with prose (MarthasBakery, MainStreet)
- Institution (BakersGuild)
- Life arcs (MarriageQuality, BusinessGrowth)

Features demonstrated:
- Concept comparison usage (skill_tier: Master/Journeyman)
- Life arc applied to relationship
- Asymmetric participant perspectives
- Family coherence across files
2026-02-14 15:54:43 +00:00
45fd3b52cb docs: update type terminology from Int/Float/String/Bool to Number/Decimal/Text/Boolean 2026-02-14 15:35:41 +00:00
ea83433e93 chore: add release process checklist template 2026-02-14 15:33:32 +00:00
5e2a132827 docs: update README for v0.3.0
Added "What's New in v0.3" section covering species, concepts,
sub_concepts, concept_comparison, template species inheritance,
and life arc field requirements. Updated quick start example
with v0.3 syntax including species and type system declarations.
2026-02-14 14:45:17 +00:00
a48e7d418d feat(lsp): add semantic highlighting tests for type system
Added tests verifying semantic token highlighting for concept,
sub_concept (enum and record forms), and concept_comparison
declarations. Made token_type_index pub(crate) for test access.
2026-02-14 14:41:41 +00:00
6e11126267 docs: create SBIR v0.3.0 specification
Updated binary format spec for v0.3.0 type system changes:
- Section 3 (Types): concept, sub_concept, concept_comparison encoding
- Section 4 (Characters): Value/Expression discriminant renames
- Section 5 (Templates): species_base field for inheritance
- Section 12 (Life Arcs): required_fields with type annotations
- Section 13 (Enums): note on sub_concept enum distinction
- Changelog and version history updated

Also fixed clippy/import issues in LSP semantic tokens module.
2026-02-14 14:36:34 +00:00
b3110c8b0f feat(lsp): add completions for type system keywords
Added top-level keyword completions for:
- concept: with semicolon-terminated snippet
- sub_concept: with dot notation snippet
- concept_comparison: with brace-delimited snippet

Added test verifying type system keywords appear in
completions with correct snippet formatting.
2026-02-14 14:32:51 +00:00
de95332fe1 feat(zed): update extension for v0.3 grammar
Updated extension.toml:
- Version bumped to 0.3.0
- Grammar rev updated to v0.3 tree-sitter commit

Updated Zed highlights.scm with type system support:
- concept, sub_concept, concept_comparison keywords
- any keyword highlighting
- Named field highlights for type system declarations
- Template species reference highlighting
- sub_concept_field property highlighting
2026-02-14 14:30:57 +00:00
51c4f33a31 feat(life-arc): add field requirements for life arcs
Added optional requires clause to life_arc declarations:
  life_arc Baker requires { skill_level: Number } { ... }
Includes new FieldRequirement AST type, requires keyword token,
and parser support for the requires clause.
2026-02-14 14:30:11 +00:00
c49b00a2dc feat(grammar): add type system nodes to tree-sitter
Added grammar rules for v0.3 type system declarations:
- concept_declaration: semicolon-terminated base type
- sub_concept: enum and record forms with dot notation
- concept_comparison: nested pattern matching with variant_pattern
- any_type: named node for the 'any' keyword
- template species extension: optional ': Species' syntax

Updated query files:
- highlights.scm: new keywords and named field highlights
- outline.scm: concept/sub_concept/concept_comparison in outline
- indents.scm: indentation for new brace-delimited nodes

Fixed pre-existing query issues:
- Replaced invalid repeat_node reference with decorator_node
- Removed invalid '?' punctuation reference

Added comprehensive test corpus (type_system.txt) covering:
- concept declaration (simple and multiple)
- sub_concept enum and record forms
- concept_comparison with any/is conditions
- template with species extension
- full combined example
2026-02-14 14:29:29 +00:00
4ce325e4ac feat(validate): validate concept_comparison patterns
Checks that concept_comparison variant names exist in the referenced
concept's enum sub-concepts and that all variants are covered
(exhaustiveness checking).
2026-02-14 14:24:05 +00:00
e0f5a78b69 feat(types): add concept registry for type checking
ConceptRegistry tracks all concepts and sub_concepts, providing lookup
and validation for sub-concept variant/field references. Supports both
enum and record sub-concept kinds.
2026-02-14 14:21:49 +00:00
eded129438 feat(validate): enforce type invariance in species inheritance
When a template extends a species via species_base, shared field names
must have compatible types. Range values are compatible with their
underlying numeric types (Number or Decimal).
2026-02-14 14:17:40 +00:00
5f1492a66a feat(resolve): implement species->template->character override chain
When a template has a species_base, its fields are loaded first as the
lowest priority layer. Override order: species -> includes -> template
-> character (last-one-wins for field values).
2026-02-14 14:16:23 +00:00
9e2cdea6f4 feat(ast): add species base to template declarations
Added optional species_base field to Template struct enabling
template-species inheritance syntax: `template Name: Species { ... }`.
Updated LALRPOP grammar and all Template construction sites.
2026-02-14 14:12:52 +00:00
0dae430841 feat(validate): check parent concept exists for sub_concepts
Added validation that sub_concept declarations reference an existing
parent concept. Produces clear error message with guidance to add
the missing concept declaration.
2026-02-14 14:07:39 +00:00
0cd00a9e73 feat(parser): add dot notation for sub_concept declarations
Changed sub_concept syntax from heuristic parent extraction to
explicit dot notation: `sub_concept Parent.Name { ... }`

The old syntax inferred the parent concept from the name using
uppercase letter heuristics. The new syntax makes the parent
concept explicit and unambiguous.

Added type_system_tests module with comprehensive tests.
2026-02-14 14:05:47 +00:00
8e4bdd3942 refactor(ast): rename value types to Number/Decimal/Text/Boolean
Renamed AST value types for v0.3 naming convention:
- Value::Int -> Value::Number
- Value::Float -> Value::Decimal
- Value::String -> Value::Text
- Value::Bool -> Value::Boolean
- Expr::IntLit -> Expr::NumberLit
- Expr::FloatLit -> Expr::DecimalLit
- Expr::StringLit -> Expr::TextLit
- Expr::BoolLit -> Expr::BooleanLit

Updated all references across parser, resolver, validator, LSP,
query engine, tests, and editor.
2026-02-14 14:03:21 +00:00
8c3c380cfd refactor(lexer): rename value type tokens for v0.3
Renamed lexer tokens to align with new v0.3 naming convention:
- IntLit -> NumberLit
- FloatLit -> DecimalLit
- StringLit -> TextLit

Updated all references across parser grammar, property tests,
and editor highlighting.
2026-02-14 13:58:46 +00:00
4e4e5500b0 chore: prep v0.3 work
Signed-off-by: Sienna Meridian Satterwhite <sienna@r3t.io>
2026-02-14 13:29:33 +00:00
25d59d6107 feat(type-system): implement concept_comparison with pattern matching
Added complete support for the new type system syntax including:

- concept: Base type declarations
- sub_concept: Enum and record sub-type definitions
- concept_comparison: Compile-time pattern matching with conditional guards

Parser changes:
- Added VariantPattern, FieldCondition, and Condition AST nodes
- Implemented "is" keyword for pattern matching (e.g., "CupType is Glass or CupType is Plastic")
- Added Value::Any variant to support universal type matching
- Disambiguated enum-like vs record-like sub_concept syntax

LSP updates:
- Added Value::Any match arms across code_actions, completion, hover, inlay_hints, and semantic_tokens
- Type inference and formatting support for Any values

Example fixes:
- Fixed syntax error in baker-family behaviors (missing closing brace in nested if)
- Removed deprecated core_enums.sb file
2026-02-14 09:28:20 +00:00
6e3b35e68f feat(ast): add type system declaration nodes
Added AST structures for new type system:
- ConceptDecl: Base type definition
- SubConceptDecl: Enum or record subtype with SubConceptKind
- ConceptComparisonDecl: Compile-time enum mapping
- ConceptMapping: Individual mapping entry

Added Declaration enum variants and stubs throughout codebase
for LSP, resolve, and semantic analysis modules.
2026-02-13 22:41:03 +00:00
f258a526e3 feat(lexer): add type system keywords
Added four keywords for new type system:
- concept: Base type definition
- sub_concept: Enum/record sub-type definition
- concept_comparison: Compile-time enum mapping
- any: Universal type for dynamic contexts

Also added:
- CLAUDE.md with project instructions and commit guidelines
- Test coverage for new keywords
- Crate-level deny directives for unused variables and dead code

Fixed pre-existing clippy issues to pass pre-commit hooks.
2026-02-13 22:31:56 +00:00
16deb5d237 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
v0.2.0
2026-02-13 21:52:03 +00:00
80332971b8 fix(tree-sitter): resolve if keyword ambiguity in behavior nodes
Separate if(expr) condition from if(expr) { child } decorator to fix
grammar conflicts. Simplify decorator_params to accept only integer,
range, or duration.
2026-02-13 20:21:31 +00:00
b100ded3d3 feat(tree-sitter): add Tree-sitter grammar for Storybook DSL 2026-02-09 22:06:25 +00:00
734eb93f12 chore(tree-sitter): add .gitignore for tree-sitter-storybook 2026-02-09 22:05:34 +00:00
ae5e9fdcd8 docs: add Alice in Wonderland example storybook
Add comprehensive example demonstrating all major features of the
Storybook DSL through Lewis Carroll's Alice in Wonderland.

Contents:
- 12 characters (Alice, WhiteRabbit, CheshireCat, MadHatter, etc.)
- 7 relationships with named participant blocks
- 3 institutions (tea parties, royal court)
- 1 schedule (Mad Tea Party eternal rotation)
- 12 behavior trees using new syntax features
- 1 life arc (Alice's journey)

Demonstrates:
- Cross-file template resolution (schema/templates.sb)
- Template inheritance and includes
- Strict template validation
- Action parameters and repeater decorators
- Named participant relationship blocks
- Species-based character typing
- Rich prose blocks throughout

All content validates successfully.
2026-02-08 15:46:52 +00:00
a8882eb3ec feat(parser): add action parameters, repeater decorator, and named participants
Add syntax enhancements for more expressive behavior trees and relationships.

Action parameters:
- Support typed/positional parameters: WaitDuration(2.0)
- Support named parameters: SetValue(field: value)
- Enable inline values without field names

Repeater decorator:
- Add * { node } syntax for repeating behavior nodes
- Maps to Decorator("repeat", node)

Named participant blocks:
- Replace self/other blocks with named participant syntax
- Support multi-party relationships
- Example: Alice { role: seeker } instead of self { role: seeker }

Schedule block syntax:
- Require braces for schedule blocks to support narrative fields
- Update tests to use new syntax: 04:00 -> 06:00: Activity { }
2026-02-08 15:45:56 +00:00
4c89c80748 feat(resolver): implement cross-file template resolution
Enable characters to inherit from templates defined in different files
across the project structure.

- Add file_index field to NameEntry to track declaration source files
- Update NameTable::from_files() to set file indices when merging tables
- Change conversion pipeline to pass &[ast::File] instead of flat arrays
- Update merge functions to use two-level indexing:
  all_files[entry.file_index].declarations[entry.decl_index]
- Update all affected tests to use new signatures
2026-02-08 15:45:30 +00:00
9c20dd4092 feat: implement storybook DSL with template composition and validation
Add complete domain-specific language for authoring narrative content for
agent simulations.

Features:
- Complete parser using LALRPOP + logos lexer
- Template composition (includes + multiple inheritance)
- Strict mode validation for templates
- Reserved keyword protection
- Semantic validators (trait ranges, schedule overlaps, life arcs, behaviors)
- Name resolution and cross-reference tracking
- CLI tool (validate, inspect, query commands)
- Query API with filtering
- 260 comprehensive tests (unit, integration, property-based)

Implementation phases:
- Phase 1 (Parser): Complete
- Phase 2 (Resolution + Validation): Complete
- Phase 3 (Public API + CLI): Complete

BREAKING CHANGE: Initial implementation
2026-02-08 13:24:35 +00:00