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

tree-sitter-sgf

v0.1.0

Published

Tree-sitter grammar for Smart Game Format (SGF).

Readme

tree-sitter-sgf

This grammar implements the Smart Game Format, SGF. It targets FF[4] standard, and has limited support for the older versions. It supports Go and other games.

Development

Install dependencies, generate the parser, and run the public corpus tests with:

npm install
npm run generate
npm run check

Installation

Install from npm:

npm install tree-sitter-sgf
const Parser = require("tree-sitter");
const SGF = require("tree-sitter-sgf");

const parser = new Parser();
parser.setLanguage(SGF);
const tree = parser.parse("(;GM[1]FF[4]SZ[19];B[pd];W[dd])");

Install from crates.io:

cargo add tree-sitter-sgf
let mut parser = tree_sitter::Parser::new();
let language = tree_sitter_sgf::LANGUAGE;
parser.set_language(&language.into())?;
let tree = parser.parse("(;GM[1]FF[4])", None).unwrap();

Install from PyPI:

pip install tree-sitter-sgf
import tree_sitter_sgf
from tree_sitter import Language, Parser

language = Language(tree_sitter_sgf.language())
parser = Parser(language)
tree = parser.parse(b"(;GM[1]FF[4])")

The grammar follows the SGF FF[4] syntax definition: a source file is a collection of one or more game trees; game trees contain sequences, nodes, properties, and bracketed property values. It intentionally does not validate SGF semantics such as property placement, point coordinates, move legality, duplicate properties, or game-specific value formats.

Helix

For local Helix testing, point Helix at this repository in ~/.config/helix/languages.toml:

[[language]]
name = "sgf"
scope = "source.sgf"
auto-format = false
injection-regex = "sgf"
file-types = ["sgf"]

[[grammar]]
name = "sgf"
source = { path = "/absolute/path/to/tree-sitter-sgf" }

Then link the Helix query set into Helix's user runtime:

REPO="$(pwd)"
mkdir -p ~/.config/helix/runtime/queries
ln -sfn "$REPO/queries/helix" ~/.config/helix/runtime/queries/sgf
hx -g build
hx --health sgf

queries/helix/highlights.scm intentionally duplicates the shared highlight query instead of using ; inherits: sgf. When the Helix runtime path is a symlink named sgf, inheriting from sgf would inherit from itself.

Neovim

Neovim uses queries/sgf/highlights.scm. The Helix indent and textobject queries are kept under queries/helix/ and are not required for Neovim.

Build a shared parser for local testing:

npm run generate
npm run build:parser

Register the local parser, filetype, and runtime path with the example config in editors/nvim/init.lua. When copying that file outside this repository, set TREE_SITTER_SGF_REPO to the repository path or replace the sgf_repo value.

Smoke-test the local Neovim setup with:

npm run smoke:nvim

If you have a local untracked SGF corpus under corpus/, parse it with:

npm run parse:corpus

References

The SGF official specification.