JSPM

@motioneffector/parser

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q24598F
  • License MIT

Text adventure command parser for natural language game input

Package Exports

  • @motioneffector/parser

Readme

@motioneffector/parser

A natural language command parser for text adventures and interactive fiction.

npm version license TypeScript

Features

  • Natural Language Parsing - Understands common text adventure commands
  • Default Vocabulary - Ships with 30+ verbs and directions
  • Custom Vocabulary - Extend or replace with game-specific commands
  • Smart Resolution - Pluggable resolver connects to your game state
  • Disambiguation - Handles multiple matching objects gracefully
  • Pronoun Tracking - Automatic "it" reference management
  • Partial Matching - "exa lamp" matches "examine lamp"
  • Position Tracking - Token positions for error reporting

Read the full manual →

Quick Start

import { createParser } from '@motioneffector/parser'

// Create parser with entity resolver
const parser = createParser({
  resolver: (noun, adjectives, scope) => {
    // Look up entities from your game state
    return [{ id: 'lamp-1', name: 'brass lamp' }]
  }
})

// Parse player input
const result = parser.parse('get lamp')

if (result.type === 'command') {
  console.log(`Verb: ${result.command.verb}`) // "GET"
  console.log(`Subject: ${result.command.subject?.id}`) // "lamp-1"
}

Testing & Validation

  • Comprehensive test suite - 371 unit tests covering core functionality
  • Fuzz tested - Randomized input testing to catch edge cases
  • Strict TypeScript - Full type coverage with no any types
  • Zero dependencies - No supply chain risk

License

MIT © motioneffector