{"id":45279996,"url":"https://github.com/mormubis/pgn","last_synced_at":"2026-03-17T14:07:53.829Z","repository":{"id":43962515,"uuid":"254547267","full_name":"mormubis/pgn","owner":"mormubis","description":"PGN is a parser that is part of the ECHECS project, designed to interpret the PGN (Portable Game Notation) specification.","archived":false,"fork":false,"pushed_at":"2026-02-19T13:03:56.000Z","size":6165,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-19T17:12:29.061Z","etag":null,"topics":["chess","fide","parser","pgn"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@echecs/pgn","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mormubis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["mormubis"]}},"created_at":"2020-04-10T04:57:06.000Z","updated_at":"2026-02-19T13:04:00.000Z","dependencies_parsed_at":"2024-09-17T23:48:55.146Z","dependency_job_id":"22b78d42-fa61-415b-aeca-a19686f8cd19","html_url":"https://github.com/mormubis/pgn","commit_stats":{"total_commits":67,"total_committers":3,"mean_commits":"22.333333333333332","dds":0.6119402985074627,"last_synced_commit":"0c64b3129b1d5149462b7ea2d5a4309d7f7f708d"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"purl":"pkg:github/mormubis/pgn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mormubis%2Fpgn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mormubis%2Fpgn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mormubis%2Fpgn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mormubis%2Fpgn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mormubis","download_url":"https://codeload.github.com/mormubis/pgn/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mormubis%2Fpgn/sbom","scorecard":{"id":502116,"data":{"date":"2025-08-11","repo":{"name":"github.com/mormubis/pgn","commit":"f8a86f116d023f2741617e3f5129ef314211cf49"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.9,"checks":[{"name":"Code-Review","score":-1,"reason":"Found no human activity in the last 15 changesets","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":10,"reason":"30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Info: jobLevel 'contents' permission set to 'read': .github/workflows/release.yml:39","Warn: topLevel 'contents' permission set to 'write': .github/workflows/auto-merge.yml:7","Warn: no topLevel permission defined: .github/workflows/format.yml:1","Warn: no topLevel permission defined: .github/workflows/lint.yml:1","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":3,"reason":"branch protection is not maximal on development and all release branches","details":["Info: 'allow deletion' disabled on branch 'main'","Info: 'force pushes' disabled on branch 'main'","Warn: 'branch protection settings apply to administrators' is disabled on branch 'main'","Warn: could not determine whether codeowners review is allowed","Warn: 'up-to-date branches' is disabled on branch 'main'","Info: status check found to merge onto on branch 'main'","Warn: PRs are not required to make changes on branch 'main'; or we don't have data to detect it.If you think it might be the latter, make sure to run Scorecard with a PAT or use Repo Rules (that are always public) instead of Branch Protection settings"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/format.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/format.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/format.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/format.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/format.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/format.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/lint.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/lint.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/lint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/lint.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/release.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/release.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/test.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/mormubis/pgn/test.yml/main?enable=pin","Info:   0 out of   9 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   5 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/release.yml:35"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":4,"reason":"6 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-67mh-4wv8-2f99","Warn: Project is vulnerable to: GHSA-x574-m823-4x7w","Warn: Project is vulnerable to: GHSA-4r4m-qw57-chr8","Warn: Project is vulnerable to: GHSA-xcj6-pq6g-qj4x","Warn: Project is vulnerable to: GHSA-356w-63v5-8wf4","Warn: Project is vulnerable to: GHSA-859w-5945-r5v3"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T22:11:58.160Z","repository_id":43962515,"created_at":"2025-08-19T22:11:58.160Z","updated_at":"2025-08-19T22:11:58.160Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29671692,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T00:11:43.526Z","status":"online","status_checked_at":"2026-02-21T02:00:07.432Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chess","fide","parser","pgn"],"created_at":"2026-02-21T02:33:57.961Z","updated_at":"2026-03-15T02:03:17.544Z","avatar_url":"https://github.com/mormubis.png","language":"TypeScript","funding_links":["https://github.com/sponsors/mormubis"],"categories":[],"sub_categories":[],"readme":"# PGN\n\n[![npm](https://img.shields.io/npm/v/@echecs/pgn)](https://www.npmjs.com/package/@echecs/pgn)\n[![Test](https://github.com/mormubis/pgn/actions/workflows/test.yml/badge.svg)](https://github.com/mormubis/pgn/actions/workflows/test.yml)\n[![Coverage](https://codecov.io/gh/mormubis/pgn/branch/main/graph/badge.svg)](https://codecov.io/gh/mormubis/pgn)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\n**PGN** is a fast TypeScript parser for\n[Portable Game Notation](http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm)\n— the standard format for recording chess games.\n\nIt parses PGN input into structured move objects with decomposed SAN, paired\nwhite/black moves, and full support for annotations and variations. Zero runtime\ndependencies.\n\n## Why this library?\n\nMost PGN parsers on npm either give you raw strings with no structure, or fail\non anything beyond a plain game record. If you're building a chess engine,\nopening book, or game viewer, you need more:\n\n- **Decomposed SAN** — every move is parsed into `piece`, `from`, `to`,\n  `capture`, `promotion`, `check`, and `checkmate` fields. No regex on your\n  side.\n- **Paired move structure** — moves are returned as\n  `[moveNumber, whiteMove, blackMove]` tuples, ready to render or process\n  without further work.\n- **RAV support** — recursive annotation variations (`(...)` sub-lines) are\n  parsed into a `variants` tree on each move. Essential for opening books and\n  annotated games.\n- **NAG support** — symbolic (`!`, `?`, `!!`, `??`, `!?`, `?!`) and numeric\n  (`$1`–`$255`) annotations are surfaced as an `annotations` array. Essential\n  for Lichess and ChessBase exports.\n- **Multi-game files** — parse entire PGN databases in one call, or stream them\n  game-by-game with `stream()` for memory-efficient processing of large files.\n  Tested on files with 3 500+ games.\n- **Fast** — built on a [Peggy](https://peggyjs.org/) PEG parser. Throughput is\n  within 1.1–1.2x of the fastest parsers on npm, which do far less work per move\n  (see [BENCHMARK_RESULTS.md](./BENCHMARK_RESULTS.md)).\n\nIf you only need raw SAN strings and a flat move list, any PGN parser will do.\nIf you need structured, engine-ready output with annotations and variations,\nthis is the one.\n\n## Installation\n\n```bash\nnpm install @echecs/pgn\n```\n\n## Quick Start\n\n```typescript\nimport parse from '@echecs/pgn';\n\nconst games = parse(`\n  [Event \"Example\"]\n  [White \"Player1\"]\n  [Black \"Player2\"]\n  [Result \"1-0\"]\n\n  1. e4 e5 2. Nf3 Nc6 3. Bb5 1-0\n`);\n\nconsole.log(games[0].moves[0]);\n// [1, { piece: 'P', to: 'e4' }, { piece: 'P', to: 'e5' }]\n```\n\n## Usage\n\n### `parse()`\n\nTakes a PGN string and returns an array of game objects — one per game in the\nfile.\n\n```typescript\nparse(input: string): PGN[]\n```\n\n### `stream()`\n\nTakes any `AsyncIterable\u003cstring\u003e` and yields one `PGN` object per game. Memory\nusage stays proportional to one game at a time, making it suitable for large\ndatabases read from disk or a network stream.\n\n```typescript\nstream(input: AsyncIterable\u003cstring\u003e): AsyncGenerator\u003cPGN\u003e\n```\n\n```typescript\nimport { createReadStream } from 'node:fs';\nimport { stream } from '@echecs/pgn';\n\nconst chunks = createReadStream('database.pgn', { encoding: 'utf8' });\nfor await (const game of stream(chunks)) {\n  console.log(game.meta.White, 'vs', game.meta.Black);\n}\n```\n\n### PGN object\n\n```typescript\n{\n  meta:   Meta,      // tag pairs (Event, Site, Date, White, Black, …)\n  moves:  MoveList,  // paired move list\n  result: 1 | 0 | 0.5 | '?'\n}\n```\n\n### Move object\n\n```typescript\n{\n  piece:       'P' | 'R' | 'N' | 'B' | 'Q' | 'K', // always present\n  to:          string,       // destination square, e.g. \"e4\"\n  from?:       string,       // disambiguation: file \"e\", rank \"2\", or square \"e2\"\n  capture?:    true,\n  castling?:   true,\n  check?:      true,\n  checkmate?:  true,\n  promotion?:  'R' | 'N' | 'B' | 'Q',\n  annotations?: string[],   // e.g. [\"!\", \"$14\"]\n  comment?:    string,\n  variants?:   MoveList[],  // recursive annotation variations\n}\n```\n\nMoves are grouped into tuples: `[moveNumber, whiteMove, blackMove]`. Both move\nslots can be `undefined` — `whiteMove` when a variation begins on black's turn,\n`blackMove` when the game or variation ends on white's move.\n\n### Annotations and comments\n\n```pgn\n12. Nf3! $14 { White has a slight advantage }\n```\n\n```typescript\n{\n  piece: 'N', to: 'f3',\n  annotations: ['!', '$14'],\n  comment: 'White has a slight advantage'\n}\n```\n\n### Variations\n\n```pgn\n5... Ba5 (5... Be7 6. d4) 6. Qb3\n```\n\nThe alternative line appears as a `variants` array on the move where it\nbranches:\n\n```typescript\n{\n  piece: 'B', to: 'a5',\n  variants: [\n    [ [5, undefined, { piece: 'B', to: 'e7' }], [6, { piece: 'P', to: 'd4' }] ]\n  ]\n}\n```\n\n## Contributing\n\nContributions are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) for\nguidelines on how to submit issues and pull requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmormubis%2Fpgn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmormubis%2Fpgn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmormubis%2Fpgn/lists"}