mons-rules 0.3.1 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,8 @@
1
1
  # Mons rules engine
2
2
 
3
3
  `mons-rules` is the dependency-free TypeScript rules engine for Super Metal
4
- Mons. The package is an ES module targeting ES2020 and runs in browsers, Web
5
- Workers, Node.js, and Firebase Cloud Functions.
6
-
7
- Version 0.3 introduces an intentionally smaller, idiomatic TypeScript API.
8
- Existing 0.2 users should follow [MIGRATION.md](./MIGRATION.md).
4
+ Mons. It is an ESM-only package for browsers, Web Workers, Node.js, and Firebase
5
+ Cloud Functions.
9
6
 
10
7
  ## Install
11
8
 
@@ -13,71 +10,39 @@ Existing 0.2 users should follow [MIGRATION.md](./MIGRATION.md).
13
10
  npm install mons-rules
14
11
  ```
15
12
 
16
- `mons-rules` is ESM-only:
13
+ ## Use
17
14
 
18
15
  ```ts
19
16
  import { AutomovePreference, Game, GameVariant, type Input } from "mons-rules";
20
17
 
21
18
  const game = new Game({ variant: GameVariant.Classic });
22
-
23
19
  const inputs: Input[] = [
24
20
  { kind: "position", position: { row: 10, column: 5 } },
25
21
  { kind: "position", position: { row: 9, column: 4 } },
26
22
  ];
27
23
  const result = game.play(inputs);
28
-
29
- if (result.kind === "complete") {
30
- console.log(result.events);
31
- }
32
-
33
- const suggestion = game.suggestMove(AutomovePreference.Normal);
34
- console.log(suggestion?.inputFen);
35
- ```
36
-
37
- FEN helpers are available when a wire-format boundary is more convenient:
38
-
39
- ```ts
40
- const game = new Game();
41
- const result = game.playFen("l10,5;l9,4");
42
- const restored = Game.fromFen(game.toFen());
24
+ const suggestion = game.suggestMove(AutomovePreference.Pro);
43
25
  ```
44
26
 
45
- Use `preview` or `previewFen` to inspect a partial input sequence without
46
- mutating the game. Use `play` or `playFen` to apply a complete legal move.
47
- Results, events, board items, positions, and squares are plain discriminated
48
- objects rather than mutable façade classes.
49
-
50
- Published JavaScript uses Web-standard `performance` and `crypto` globals.
51
- Node.js 22.13 through 22.x, or Node.js 24 or newer, is required for Node
52
- consumers and repository tooling.
27
+ Use `preview` or `previewFen` to inspect inputs without mutating the game. Use
28
+ `play` or `playFen` to apply a complete legal move. Serialize games with
29
+ `toFen` and restore them with `Game.fromFen`.
53
30
 
54
- ## Validation
31
+ Published JavaScript targets ES2020 and uses Web-standard `performance` and
32
+ `crypto` globals. Node.js 22.13 through 22.x, or Node.js 24 or newer, is
33
+ required for Node consumers and repository tooling.
55
34
 
56
- Install dependencies and run the complete local gate:
35
+ ## Validate
57
36
 
58
37
  ```sh
59
38
  npm ci --engine-strict
60
39
  npm run check
61
40
  ```
62
41
 
63
- The check streams and replays 699,994 canonical rules transitions without
64
- unpacking the compressed corpus. It also validates the public API,
65
- deterministic automove decisions, and 1,527 complete real-player games
66
- containing 25,185 turns and 169,480 inputs across all 12 variants.
67
-
68
- Run `node ./scripts/check-complete-games.mjs` to validate the immutable public
69
- corpus without replaying it. Run `npm run test:complete-games` for the full
70
- engine replay.
71
-
72
42
  ## Release
73
43
 
74
- Run `npm run bump` to increment the patch version in `package.json` and
75
- `package-lock.json`, then commit the release change. Run
76
- `npm run publish -- --check-only` to validate the unpublished version and
77
- perform an npm dry run. Run `npm run publish` from a clean worktree to publish
78
- that version to `latest`.
79
-
80
- A real publish uses the transient `mons-npm-publish-lock` tag on `origin`, or
81
- the shared remote named by `MONS_PUBLISH_LOCK_REMOTE`, to serialize releases
82
- across hosts. The script prints lease-protected recovery instructions if
83
- cleanup fails.
44
+ ```sh
45
+ npm run bump
46
+ npm run publish -- --check-only
47
+ npm run publish
48
+ ```