Skip to content

Commit db3f6dd

Browse files
committed
SEO twerking
1 parent 10215db commit db3f6dd

3 files changed

Lines changed: 25 additions & 26 deletions

File tree

PLAN_openings_gz.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,22 @@ _Depends on Step 4._
8989
- Add export to `src/chessPGN.ts` entry point
9090
- Run `npm run api:update` to record new API surface
9191

92-
_Steps 6-8 parallel with Phase 3. Depends on Phase 2 being published._
92+
**Step 9** — Document multi-game annotation pattern in docs
93+
94+
- `annotateOpenings()` mutates a single `IChessGame` in place; `game.pgn()` returns the annotated PGN string
95+
- For multi-game PGN files, document the expected pattern:
96+
```typescript
97+
const parts: string[] = [];
98+
for await (const game of cursor) {
99+
await annotateOpenings(game, opts);
100+
parts.push(game.pgn());
101+
}
102+
const multiGamePgn = parts.join("\n\n");
103+
```
104+
- No built-in multi-game reassembly method — this is intentional (trivial for callers, avoids over-engineering)
105+
- Note: `openingBook()` is fetched once and cached; no per-game network overhead
106+
107+
_Steps 6-9 parallel with Phase 3. Depends on Phase 2 being published._
93108

94109
---
95110

README.md

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# @chess-openings/eco.json
1+
# eco.json (Published as @chess-openings/eco.json)
22

33
[![npm version](https://badge.fury.io/js/%40chess-openings%2Feco.json.svg)](https://www.npmjs.com/package/@chess-openings/eco.json)
44
[![npm downloads](https://img.shields.io/npm/dm/@chess-openings/eco.json.svg)](https://www.npmjs.com/package/@chess-openings/eco.json)
@@ -36,19 +36,14 @@ import { openingBook, findOpening, getFromTos } from "@chess-openings/eco.json";
3636
const openings = await openingBook();
3737

3838
// Look up an opening by FEN
39-
const opening = findOpening(
40-
openings,
41-
"rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1",
42-
);
39+
const opening = findOpening(openings, "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1");
4340

4441
console.log(opening?.name); // "King's Pawn Opening"
4542
console.log(opening?.eco); // "B00"
4643
console.log(opening?.moves); // "1. e4"
4744

4845
// Get next and previous positions
49-
const { next, from } = await getFromTos(
50-
"rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1",
51-
);
46+
const { next, from } = await getFromTos("rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1");
5247

5348
console.log(next[0]?.name); // "Sicilian Defense"
5449
console.log(from[0]?.name); // "Starting Position"
@@ -96,11 +91,7 @@ const openings = await openingBook();
9691
Looks up an opening by FEN with automatic position-only fallback.
9792

9893
```typescript
99-
import {
100-
findOpening,
101-
getPositionBook,
102-
openingBook,
103-
} from "@chess-openings/eco.json";
94+
import { findOpening, getPositionBook, openingBook } from "@chess-openings/eco.json";
10495

10596
const openings = await openingBook();
10697
const posBook = getPositionBook(openings);
@@ -124,11 +115,7 @@ This function tries to find an opening match at the current position. If no matc
124115

125116
```typescript
126117
import { ChessPGN } from "@chess-pgn/chess-pgn";
127-
import {
128-
openingBook,
129-
lookupByMoves,
130-
getPositionBook,
131-
} from "@chess-openings/eco.json";
118+
import { openingBook, lookupByMoves, getPositionBook } from "@chess-openings/eco.json";
132119

133120
const chess = new ChessPGN();
134121
chess.loadPgn("1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6");
@@ -173,9 +160,7 @@ Compatible libraries: chess.js, @chess-pgn/chess-pgn, and others with similar AP
173160

174161
```typescript
175162
// Many moves deep into a game
176-
chess.loadPgn(
177-
"1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3 O-O 9. h3 Na5",
178-
);
163+
chess.loadPgn("1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 d6 8. c3 O-O 9. h3 Na5");
179164

180165
const result = lookupByMoves(chess, openings, { maxMovesBack: 10 });
181166

@@ -220,10 +205,7 @@ console.log(`Found ${caroKann.length} variations`);
220205
Returns all openings for an ECO category (A, B, C, D, or E).
221206

222207
```typescript
223-
import {
224-
getOpeningsByEcoCategory,
225-
openingBook,
226-
} from "@chess-openings/eco.json";
208+
import { getOpeningsByEcoCategory, openingBook } from "@chess-openings/eco.json";
227209

228210
// Get all semi-open games (category B)
229211
const semiOpen = await getOpeningsByEcoCategory("B");

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
"publish:public": "npm publish --access public"
2525
},
2626
"keywords": [
27+
"eco.json",
28+
"chess-openings",
2729
"chess",
2830
"openings",
2931
"eco",

0 commit comments

Comments
 (0)