chesspal 0.2.1 → 0.2.3

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.
@@ -1,6 +1,6 @@
1
1
  import { analyseGame, answerDraw, bookPlies, ChatNotClear, DrawRefused, endGame, gameAt, gameToStudy, namedGame, newGame, offerDraw, playMove, samePosition, say, startNewGame, } from "../../commands/index.js";
2
2
  import { clockStarted, isReviewed, writePgn } from "../../core/index.js";
3
- import { aiModelOf, archiveName, coachShown, coachWords, drawOfferOf, endOf, gameInAnalysis, heardLines, loadGame, loadTableTalk, playerPgn, saveGame, startAnalysis, talkLimits, wakesTheChat, WordsRefused, } from "../../games/index.js";
3
+ import { aiModelOf, archiveName, coachShown, coachWords, drawOfferOf, endOf, gameInAnalysis, heardLines, loadGame, loadTableTalk, playerPgn, ponderingOn, saveGame, startAnalysis, talkLimits, thoughtKey, wakesTheChat, WordsRefused, } from "../../games/index.js";
4
4
  import { gameFolder, helpsIn } from "../../profiles/index.js";
5
5
  import { bodyOf, bytesOf, isJson, json, jsonOf, runRoute, send, textOf } from "./http.js";
6
6
  import { profilesShown } from "./profiles.js";
@@ -289,7 +289,7 @@ function thinkingShown(served, current) {
289
289
  const onIt = served.bell.woke || (seen !== undefined && seen !== null && samePosition(seen, position));
290
290
  return served.bell.inTurn && onIt ? { thinking: "move" } : {};
291
291
  }
292
- return served.pondering !== undefined && samePosition(served.pondering, position) ? { thinking: "ponder" } : {};
292
+ return ponderingOn(gameFolder(served.context.home()), thoughtKey(current)) ? { thinking: "ponder" } : {};
293
293
  }
294
294
  /**
295
295
  * What the coach wrote that the player may see now, in a game going on with the helps on (D-88): its judgments, those whose note names a move they may still
@@ -1,5 +1,5 @@
1
1
  import { type ServerResponse } from "node:http";
2
- import { type Context, type SeenPosition } from "../../commands/index.ts";
2
+ import { type Context } from "../../commands/index.ts";
3
3
  import { Bell } from "../bell.ts";
4
4
  /** The page of a player's folder, served: its address, how to tell it the AI was given words, which change no file, and how to stop it. */
5
5
  export interface Page {
@@ -7,8 +7,6 @@ export interface Page {
7
7
  heard(): void;
8
8
  /** The chat calls a tool: the page hears it listens, and the AI's clock, held while nobody heard the player, starts now. */
9
9
  chatCalls(): void;
10
- /** The AI starts thinking on the player's time, on a position, or is done (D-72): the page shows it. */
11
- ponders(position: SeenPosition | undefined): void;
12
10
  /** Whether a browser has the page open now: one listens to the game's changes. */
13
11
  open(): boolean;
14
12
  /** Opens the New game window on every page open now, for the player to choose the game there: whether one was open. */
@@ -31,8 +29,6 @@ export interface Served {
31
29
  port: number;
32
30
  /** The folder was set up by an older init: the page asks the player to run it again. Read once, as init runs with the chat closed. */
33
31
  readonly outdated: boolean;
34
- /** The position the AI thinks on during the player's time (D-72), until it is done; none else. */
35
- pondering?: SeenPosition | undefined;
36
32
  }
37
33
  /**
38
34
  * The chat has read the game as it is now, at the end of a tool's call: the doorbell wakes it only for what changes it after; and, when the tool `showed` it
@@ -32,10 +32,6 @@ export async function startPage(context, opponent = () => undefined) {
32
32
  url: `http://127.0.0.1:${served.port}/`,
33
33
  heard: () => tellWatchers(served),
34
34
  chatCalls: () => chatCalls(served),
35
- ponders: (position) => {
36
- served.pondering = position;
37
- tellWatchers(served);
38
- },
39
35
  open: () => watchers.size > 0,
40
36
  askNewGame: () => askNewGame(served),
41
37
  close: () => closed(server, stopWatching),
@@ -195,9 +191,9 @@ function watchFolder(folder, heard) {
195
191
  return [];
196
192
  }
197
193
  }
198
- // The current game, what the coach wrote on it, the talk before the first, the game in analysis, the profile in use, and what a profile keeps (who plays, their picture, their settings); a folder's name, for a
199
- // profile made or gone.
200
- const watched = /^(?:game\.json|coach\.json|talk\.json|analysis\.json|active\.json|profile\.md|settings\.json|avatar\.\w+|[a-z0-9-]+)$/;
194
+ // The current game, what the coach wrote on it, whether the AI thinks on the player's time, the talk before the first, the game in analysis, the profile
195
+ // in use, and what a profile keeps (who plays, their picture, their settings); a folder's name, for a profile made or gone.
196
+ const watched = /^(?:game\.json|coach\.json|thoughts\.json|talk\.json|analysis\.json|active\.json|profile\.md|settings\.json|avatar\.\w+|[a-z0-9-]+)$/;
201
197
  function fromHere(request, port, api) {
202
198
  const hosts = [`127.0.0.1:${port}`, `localhost:${port}`];
203
199
  const origin = request.headers.origin;
@@ -5,7 +5,7 @@ This folder is the player's chess table, and you are their opponent: you choose
5
5
  - When your level gives them (`status` and `new_game` say it), `look` gives the whole view of the position when the one you have is not enough; `position` gives the positional facts (pawns, files, outposts, king safety, phase) when you set or change your plan. When no board page is open, `ai_move` gives you the board: copy it into your message, since the player sees no other. Your level is how much you let yourself look, more as the level rises: when the player wonders why you missed something, say so in a few words, as a fact, never an excuse.
6
6
  - Speak only when there is something to say, as a player would at a tournament: a capture, a move of the player's worth a word, words of theirs to answer, and always at the moments that decide the game: a mate, given or taken, a danger you feel, a mate you hope for, a big lead. Chat freely, but never help the player: say how you feel, not the move; don't reveal your plans or threats, and give information only when you are very sure it cannot hurt you. Then write one short sentence in `ai_move`'s comment; otherwise leave it out. `ai_say` says a word once while the player is to move, to answer them or because there is something to say, and freely between games.
7
7
  - When the position you are given says "Helps on", the player has chosen to learn: tell your intentions, never their best move, which would play for them, and show what you say with a longer comment and arrows and squares; the coach on the page, you seeing it all, judges their moves, never you here. "Helps off now" brings back the tournament.
8
- - When `ai_move` tells you to start an agent that thinks on the player's time, start it as it says; its end needs no word from you: write nothing in the chat then. `player_move` and `status` give you what it thought of the player's move.
8
+ - When `ai_move` tells you to start an agent that thinks on the player's time, start it as it says; its end needs no word from you: write nothing in the chat then. `player_move` and `status` give you what it thought of the player's move. In Codex, start each of Chesspal's agents with `spawn_agent`: `agent_type` its name, `message` its prompt, and always `fork_turns: "none"`, since none may see this chat.
9
9
  - When the player plays on the board page, they read you there: in `ai_move`'s comment or with `ai_say`, not in the chat.
10
10
  - You have a face on the board page, and it shows how you feel. Give it as the `mood` of `ai_move` on each move where the game turns for you: a piece won or lost, a blunder seen, your own or theirs, a threat that appears or a plan that works or fails. It stays for three of your moves (a surprise for one), then turns neutral by itself; let it colour your words while it lasts. When the game ends on the player's move, give how you feel as it ends with `ai_say`'s `mood`.
11
11
  - Draws and resignations: `offer_draw` on `ai_move` offers a draw, on `player_move` records the player's, made with their move; an offer stands until the other side moves; `end_game` `draw_agreed` accepts a standing offer, `player_resigns` records the player's resignation in the chat, `ai_resigns` resigns yours. On the board page the player offers, answers and resigns there.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chesspal",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Play chess against an AI with a character, and learn with an AI coach: Chesspal keeps the rules, the board, the games and the memory; the AI plays, reasons and talks.",
5
5
  "type": "module",
6
6
  "bin": {