@sharpee/if-domain
v5.1.1
Published
Core domain model and contracts for Sharpee Interactive Fiction Platform
Readme
@sharpee/if-domain
Core domain model and contracts for the Sharpee Interactive Fiction Platform.
Installation
npm install @sharpee/if-domainOverview
This package contains the shared domain types, events, and contracts that define the Interactive Fiction domain model. It serves as the single source of truth for domain concepts used across the Sharpee platform.
Contents
Events (events.ts)
IFEvents- Standard interactive fiction event constantsIFEventType- Type-safe event typeIFEventCategory- Event categorization for filtering and handling
Contracts (contracts.ts)
WorldChange- Interface for world state changesWorldConfig,WorldState- World behavior configuration and state storageFindOptions,ContentsOptions- Options for finding entities and querying contentsProcessedEvents,ProcessorOptions- Event processing result and configurationCommandInput,CommandSemantics,EntityReference- Command contractsValidationResult,IActionContext,IAction,IActionRegistry- Action contractsScopeLevel,IScopeResolver- Scope contracts
Changes (changes.ts)
WorldChangeType- Types of world state changes
Language & Parser Contracts
LanguageProvider,ParserLanguageProvider- Language provider interfaces- Parser contracts (
Parser,ParserFactory,BaseParser,Token, …) and the grammar system (ADR-087) - Vocabulary contracts (
VocabularyEntry,PartOfSpeech,vocabularyRegistry, …)
Other Contracts
- Prompt types (ADR-137)
- Channel-I/O type contracts (ADR-163) — the universal UI surface
- Spatial sound propagation contracts (ADR-172)
- Phrase algebra contracts (
phrase.ts, ADR-192) - Room-description snippet contracts (
snippets.ts, ADR-209) - Story ending contract (
endings.ts, ADR-210)
Usage
import { IFEvents, WorldChange } from '@sharpee/if-domain';
// Use event constants
const moveEvent = {
type: IFEvents.ACTOR_MOVED,
// ...
};
// Describe world state changes
const change: WorldChange = {
type: 'move',
entityId: 'player',
// ...
};Design Principles
- Domain-Driven Design: All types represent domain concepts, not technical implementations
- Single Source of Truth: Event constants and core types defined once
- Contracts First: Mostly type definitions and constants, plus a small runtime surface (vocabulary registry, parser factory, grammar engine, scope builder)
- Minimal Dependencies: Only depends on @sharpee/core and @sharpee/text-blocks
Dependencies
@sharpee/core- Core semantic event types@sharpee/text-blocks- Text-block types used by the language, phrase, and channel contracts
Build Order
This package must be built after core but before:
world-modelevent-processorenginestdlib
License
MIT
