mores.dev

Social norms as composable modules. Import, configure, ship.

Get started

Overview

Mores is a lightweight library for encoding, analyzing, and composing social norms. It provides a declarative API for describing customs, conventions, and behavioral expectations as structured data.

Instead of hard-coding social rules into your application logic, Mores lets you define them as configurable modules that can be imported, combined, and adapted to different cultural contexts.

import { norm, compose } from 'mores';

const greeting = norm({
  name: 'formal-greeting',
  context: 'professional',
  rules: [
    { action: 'handshake', duration: 'brief' },
    { action: 'eye-contact', level: 'direct' },
    { action: 'address', form: 'title-surname' }
  ]
});

const social = compose(greeting, smallTalk, farewell);

Installation

Install via your preferred package manager:

# npm
npm install mores

# yarn
yarn add mores

# pnpm
pnpm add mores

Mores has zero dependencies and is tree-shakeable. The core library is 4.2kB gzipped.

Requirements

  • Node.js 18+ or modern browser (ES2022)
  • TypeScript 5.0+ (optional, types included)
  • No framework dependency

API Reference

The core API consists of four functions:

Function Description Returns
norm(config) Create a single social norm from a configuration object Norm
compose(...norms) Combine multiple norms into a behavioral sequence ComposedNorm
validate(norm, context) Check if a norm is appropriate for a given context ValidationResult
adapt(norm, culture) Transform a norm for a different cultural context Norm

norm(config)

Creates a new social norm. The config object must include a name, context, and rules array.

const config = {
  name: 'table-manners',
  context: 'dining',
  region: 'western',      // optional locale
  formality: 'high',      // 'low' | 'medium' | 'high'
  rules: [
    { action: 'utensils', style: 'continental' },
    { action: 'napkin', placement: 'lap' },
    { action: 'elbows', position: 'off-table' }
  ]
};

Examples

Cultural Adaptation

Adapt a norm to different cultural contexts:

import { norm, adapt } from 'mores';

const westernGreeting = norm({
  name: 'greeting',
  context: 'casual',
  rules: [
    { action: 'wave', distance: 'arm-length' },
    { action: 'verbal', phrase: 'Hey!' }
  ]
});

const japaneseGreeting = adapt(westernGreeting, {
  culture: 'jp',
  transforms: {
    'wave': { action: 'bow', angle: '15deg' },
    'verbal': { phrase: 'Konnichiwa' }
  }
});

Composition

Chain norms into social sequences:

import { norm, compose, validate } from 'mores';

const meetingProtocol = compose(
  greeting,
  introduction,
  smallTalk({ duration: '2min' }),
  agendaReview,
  farewell
);

const result = validate(meetingProtocol, {
  setting: 'corporate',
  participants: 'mixed-hierarchy'
});
// result.valid === true

Type Reference

Full TypeScript type definitions:

interface NormConfig {
  name: string;
  context: 'casual' | 'professional' | 'formal' | 'ceremonial';
  region?: string;
  formality?: 'low' | 'medium' | 'high';
  rules: Rule[];
}

interface Rule {
  action: string;
  [key: string]: string | number | boolean;
}

interface ValidationResult {
  valid: boolean;
  warnings: Warning[];
  conflicts: Conflict[];
}

interface CultureTransform {
  culture: string;
  transforms: Record<string, Partial<Rule>>;
}

Versioning

Mores follows semantic versioning. Cultural norm databases are versioned independently from the core library.

Package Current Status
mores 2.4.1 Stable
@mores/cultures 1.8.0 Stable
@mores/validator 0.9.2 Beta