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

chesschemy

v0.7.1

Published

A TypeScript-first engine for chess and programmable chess variants.

Readme

Chesschemy

A TypeScript chess engine for standard chess and programmable variants.

npm version npm downloads types CI License: MIT

Install · Quick Start · Guides · API

Chesschemy gives you deterministic rules, legal move generation, check filtering, state transitions, validation, FEN helpers, and JSON-friendly serialization. It does not include a renderer, server, database, auth, matchmaking, clocks, or UI.

Use it when you want to build a chess-like game and keep your application code focused on presentation and product behavior.

Install

npm install chesschemy

Package basics:

  • Node.js 20 or newer
  • ESM and CommonJS builds
  • TypeScript declarations included
  • Side-effect free package for tree-shaking

Quick Start

import { Game, move, moves, turn } from 'chesschemy';

let game = Game();

console.log(turn(game)); // "white"
console.log(moves(game, 'e2')); // ['e3', 'e4']

game = move(game, 'e2', 'e4');

console.log(turn(game)); // "black"

You can also pass one move string:

game = move(game, 'Nf3'); // SAN
game = move(game, 'e7e5'); // coordinate notation

Most board APIs accept algebraic squares such as 'e4' and numeric coordinates such as { file: 5, rank: 4 }.

Breaking Changes In 0.7

The package root now presents the simple API first. Older verbose helpers are still available from their focused subpaths, but they are no longer exported from chesschemy.

Use these root imports for common app code:

import {
  Game,
  fen,
  fromFen,
  isCheck,
  load,
  move,
  moves,
  pieceAt,
  result,
  save,
  turn,
  validate,
} from 'chesschemy';

Migration examples:

  • createGame() -> Game()
  • makeMove(game, input) -> move(game, 'e2', 'e4') or move(game, 'Nf3')
  • validateMove(game, input) -> validate(game, 'e2', 'e4')
  • getPieceAt(game, square) -> pieceAt(game, square)
  • legalMoves(game, square) -> moves(game, square) for destination strings
  • serializeFen(game) / deserializeFen(text) -> fen(game) / fromFen(text)
  • serializeGameState(game) / deserializeGameState(data) -> save(game) / load(data)
  • isKingInCheck(game, player) -> isCheck(game, player)

Use Simple API for the short names and Advanced API when you need the full verbose helpers.

What It Supports

  • Standard 8x8 chess initial state
  • Legal move generation with check filtering
  • Castling, en passant, and promotion
  • Checkmate, stalemate, and insufficient-material detection
  • Custom pieces and movement patterns
  • Active, passive, and triggered abilities
  • Statuses, cooldowns, and built-in effect helpers
  • Board query helpers for UI integration
  • Standard chess FEN import/export
  • JSON-friendly game-state serialization

The current rules engine is intentionally two-player and king-based: validated games must have exactly two players and exactly one king piece for each player.

Custom Variants

Custom variants are built with piece definitions, movement patterns, abilities, effects, and an explicit initial position.

import { createVariantGame } from 'chesschemy';
import type { MoveCandidate, PieceBehaviorContext } from 'chesschemy/movement';
import { BasePiece } from 'chesschemy/pieces';

class Wizard extends BasePiece {
  public readonly id = 'wizard';
  public readonly displayName = 'Wizard';

  public override generateMoves(context: PieceBehaviorContext): readonly MoveCandidate[] {
    return this.step(context, 'diagonal');
  }
}

const wizard = new Wizard();

const game = createVariantGame({
  board: { files: 8, ranks: 8 },
  pieces: [
    {
      id: 'white-wizard',
      definitionId: 'wizard',
      owner: 'white',
      position: { file: 4, rank: 1 },
    },
    {
      id: 'white-king',
      definitionId: 'king',
      owner: 'white',
      position: { file: 5, rank: 1 },
    },
    {
      id: 'black-king',
      definitionId: 'king',
      owner: 'black',
      position: { file: 5, rank: 8 },
    },
  ],
  pieceDefinitions: [wizard],
  ruleset: {
    id: 'wizard-chess',
    version: '1.0.0',
    displayName: 'Wizard Chess',
  },
});

console.log(game.ruleset.displayName);

Import Paths

Most application code can import from the package root:

import {
  Game,
  fen,
  fromFen,
  isCheck,
  load,
  move,
  moves,
  pieceAt,
  result,
  save,
  turn,
  validate,
} from 'chesschemy';
const text = fen(game);
const fromText = fromFen(text);

const snapshot = save(game);
const restored = load(snapshot);

Focused subpaths are available for variant-building APIs:

import { useAbility } from 'chesschemy/abilities';
import { teleportSourceToTarget } from 'chesschemy/effects';
import { stepper } from 'chesschemy/movement';

Do not import from src/* or dist/*; those paths are not public API.

Guides

Development

npm install
npm run typecheck
npm run lint
npm test
npm run build

Run npm run prepublishOnly before publishing.