npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

glost-dialogue

v0.6.0

Published

Dialogue and conversation support for GLOST documents with turn-based structure and gender variants

Readme

glost-dialogue

Dialogue and conversation support for GLOST documents with turn-based structure and gender variants.

Features

  • Turn-based dialogue structure - Explicit turns vs sentence-level speaker attribution
  • Gender variant support - Parse and apply gender-specific text variants (e.g., Thai ครับ/ค่ะ)
  • Cultural notes - Embedded cultural context within dialogues
  • Upstream compatibility - Bidirectional conversion with flat dialogue format
  • Type-safe - Full TypeScript support with strict typing

Installation

pnpm add glost-dialogue glost-core

Usage

Creating a dialogue

import {
  createDialogueRoot,
  createDialogueTurn,
  createCulturalNote,
} from "glost-dialogue";

const dialogue = createDialogueRoot({
  lang: "th-TH",
  script: "thai",
  participants: [
    { id: "me", gender: "masculine" },
    { id: "other", name: "Friend", gender: "feminine" }
  ],
  children: [
    createDialogueTurn({
      speakerId: "me",
      text: "สวัสดี{ครับ|ค่ะ}",
      lang: "th-TH",
      script: "thai"
    }),
    createDialogueTurn({
      speakerId: "other",
      text: "สวัสดีค่ะ",
      lang: "th-TH",
      script: "thai"
    })
  ],
  culturalNotes: [
    createCulturalNote({
      content: "In Thai, ครับ is used by male speakers and ค่ะ by female speakers",
      topics: ["politeness", "gender"]
    })
  ]
});

Gender variants

Gender variants allow you to write text once with markers for gender-specific particles:

import { parseGenderVariants, applyGender } from "glost-dialogue";

const text = "สวัสดี{ครับ|ค่ะ}";
const variants = parseGenderVariants(text);
// {
//   hasVariants: true,
//   masculine: "สวัสดีครับ",
//   feminine: "สวัสดีค่ะ"
// }

const masculine = applyGender(text, "masculine"); // "สวัสดีครับ"
const feminine = applyGender(text, "feminine");   // "สวัสดีค่ะ"

Working with upstream format

Convert between turn-based and flat (upstream) formats:

import {
  toUpstreamDialogue,
  fromUpstreamDialogue,
} from "glost-dialogue";

// Convert to upstream flat format
const flatDialogue = toUpstreamDialogue(turnBasedDialogue);

// Convert from upstream format
const turnBased = fromUpstreamDialogue(flatDialogue);

API

Types

  • GLOSTDialogueRoot - Root node for a complete dialogue
  • GLOSTDialogueTurn - Single speaker's utterance
  • GLOSTCulturalNote - Cultural note node
  • DialogueParticipant - Participant with gender and metadata
  • GenderVariants - Gender-specific text variants

Builders

  • createDialogueRoot(options) - Create a dialogue root
  • createDialogueTurn(options) - Create a dialogue turn
  • createCulturalNote(options) - Create a cultural note

Utilities

  • addTurn(dialogue, turn) - Add a turn (immutable)
  • addParticipant(dialogue, participant) - Add a participant (immutable)
  • addCulturalNote(dialogue, note) - Add a cultural note (immutable)
  • getTurnsBySpeaker(dialogue, speakerId) - Get turns by speaker
  • getParticipant(dialogue, speakerId) - Get participant by ID
  • getTurnCount(dialogue) - Get total turn count
  • getSpeakerIds(dialogue) - Get unique speaker IDs

Gender Variant Utilities

  • parseGenderVariants(text) - Parse gender variants from text
  • applyGender(text, gender) - Apply gender to text with variants

Adapters

  • toUpstreamDialogue(dialogue) - Convert to upstream flat format
  • fromUpstreamDialogue(dialogue) - Convert from upstream format
  • toUpstreamParticipant(participant) - Convert participant to upstream
  • fromUpstreamParticipant(participant) - Convert participant from upstream

Architecture

This package extends the upstream glost-dialogue package with:

  1. Turn-based structure - Explicit GLOSTDialogueTurn nodes instead of sentence-level speaker attribution
  2. Gender variants - Parse and apply gender-specific text (e.g., Thai polite particles)
  3. Cultural notes - Embedded cultural context nodes
  4. Extended participant metadata - Formality, relationship, and more specific gender types

The upstream flat format is still supported via adapters for interoperability.

License

MIT