Agent guidance for the @echecs/trf package — FIDE Tournament Report File (TRF)
parser.
See also: REFERENCES.md |
COMPARISON.md | SPEC.md
See the root AGENTS.md for workspace-wide conventions (package manager,
TypeScript settings, formatting, naming, testing, ESLint rules).
Backlog: tracked in GitHub Issues.
Parser and serializer library, no runtime dependencies. Named exports:
parse(input, options?) → Tournament | null and
stringify(tournament, options?) → string. Never throws; parse failures return
null and call options.onError. Recoverable issues emit options.onWarning.
Mirrors the API style of @echecs/pgn.
pnpm run build # bundle → dist/pnpm run test # run all tests once
pnpm run test:watch # watch mode
pnpm run test:coverage # with coverage report
pnpm run test src/__tests__/index.spec.ts # single filepnpm run lint # ESLint + tsc type-check (auto-fixes style)
pnpm run lint:ci # strict — zero warnings, no auto-fix
pnpm run lint:style # ESLint only
pnpm run lint:types # tsc --noEmit only
pnpm run format # Prettier (writes)
pnpm run format:ci # Prettier check onlypnpm lint && pnpm test && pnpm build@echecs/trf and @echecs/tunx both produce and consume a Tournament type
with compatible structure. The core shared shape:
Tournament— top-level container withplayers: Player[],rounds: number, and optional metadata (name,chiefArbiter,startDate,endDate, etc.).Player— structurally identical across both packages:name,pairingNumber,points,rank,results: RoundResult[], plus optional FIDE fields.RoundResult—round,color,opponentId,result: ResultCode.ResultCode— same union:'1','0','=','+','-','W','D','L', etc.
TRF's Tournament is a superset (teams, scoring systems, acceleration, byes).
TUNX's Tournament adds format-specific fields (_raw, pairings, header).
The types are duplicated, not shared — each package defines its own.
When modifying shared types (Player, RoundResult, ResultCode, or the
common Tournament fields), keep both packages in sync. Changes to one must be
reflected in the other so their parse() output remains structurally
compatible.
- ESM-only — the package ships only ESM. Do not add a CJS build.
- No runtime dependencies — keep it that way.
parse()is synchronous — do not introduce async.src/index.tsis a re-export barrel. Logic lives insrc/parse.tsandsrc/stringify.ts.src/columns.tscontains shared column offset constants.src/types.tscontains all exported types.- All interface fields sorted alphabetically (
sort-keysis an ESLint error). - Always use
.jsextensions on relative imports (NodeNext resolution).
Input validation is mostly provided by TypeScript's strict type system at
compile time. There is no runtime validation library — the type signatures
enforce correct usage. Do not add runtime type-checking guards (e.g. typeof
checks, assertion functions) unless there is an explicit trust boundary.
- Returns
nullfor unrecoverable failures; callsoptions.onError. - Emits
options.onWarningfor recoverable issues (unknown tags, malformed rating, unknown result code). - Never throws.
Step-by-step process for releasing a new version. CI auto-publishes to npm when
version in package.json changes on main.
-
Verify the package is clean:
pnpm lint && pnpm test && pnpm build
Do not proceed if any step fails.
-
Decide the semver level:
patch— bug fixes, internal refactors with no API changeminor— new features, new exports, non-breaking additionsmajor— breaking changes to the public API
-
Update
CHANGELOG.mdfollowing Keep a Changelog format:## [x.y.z] - YYYY-MM-DD ### Added - … ### Changed - … ### Fixed - … ### Removed - …
Include only sections that apply. Use past tense.
-
Update
README.mdif the release introduces new public API, changes usage examples, or deprecates/removes existing features. -
Bump the version:
npm version <major|minor|patch> --no-git-tag-version
-
Open a release PR:
git checkout -b release/x.y.z git add package.json CHANGELOG.md README.md git commit -m "release: @echecs/trf@x.y.z" git push -u origin release/x.y.z gh pr create --title "release: @echecs/trf@x.y.z" --body "<description>"
Wait for CI (format, lint, test) to pass on the PR before merging.
-
Merge the PR: Once CI is green, merge (squash) into
main. The release workflow detects the version bump, publishes to npm, and creates a GitHub Release with a git tag.
Do not manually publish with npm publish. Do not create git tags manually —
the release workflow handles tagging.