chesspal 0.3.6 → 0.4.0
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/dist/cli/cli.js +7 -2
- package/dist/cli/command-line.js +5 -3
- package/dist/cli/prompt-hook.d.ts +17 -0
- package/dist/cli/prompt-hook.js +100 -0
- package/dist/commands/analysis/analyse.js +8 -14
- package/dist/commands/analysis/annotate.d.ts +8 -0
- package/dist/commands/analysis/annotate.js +19 -3
- package/dist/commands/answers/agents.d.ts +7 -5
- package/dist/commands/answers/agents.js +16 -9
- package/dist/commands/answers/clock.js +2 -1
- package/dist/commands/answers/drawings.js +6 -2
- package/dist/commands/answers/index.d.ts +4 -3
- package/dist/commands/answers/index.js +4 -3
- package/dist/commands/answers/lines.d.ts +5 -3
- package/dist/commands/answers/lines.js +14 -7
- package/dist/commands/answers/opening-book.d.ts +13 -7
- package/dist/commands/answers/opening-book.js +34 -38
- package/dist/commands/answers/opening-tags.d.ts +4 -0
- package/dist/commands/answers/opening-tags.js +11 -0
- package/dist/commands/answers/play-move.d.ts +3 -1
- package/dist/commands/answers/play-move.js +9 -6
- package/dist/commands/answers/say.js +2 -1
- package/dist/commands/answers/summary.d.ts +5 -2
- package/dist/commands/answers/summary.js +16 -5
- package/dist/commands/game/ai-move.js +4 -4
- package/dist/commands/game/coach.js +7 -6
- package/dist/commands/game/end.js +2 -2
- package/dist/commands/game/export.d.ts +1 -1
- package/dist/commands/game/index.d.ts +1 -1
- package/dist/commands/game/index.js +1 -1
- package/dist/commands/game/new.js +41 -11
- package/dist/commands/game/player-move.d.ts +16 -0
- package/dist/commands/game/player-move.js +69 -19
- package/dist/commands/game/ponder.js +4 -1
- package/dist/commands/game/status.d.ts +1 -1
- package/dist/commands/game/status.js +6 -6
- package/dist/commands/index.d.ts +3 -3
- package/dist/commands/index.js +3 -3
- package/dist/commands/profiles/past-games.d.ts +1 -1
- package/dist/commands/profiles/past-games.js +21 -10
- package/dist/commands/registry/context.d.ts +2 -0
- package/dist/commands/registry/context.js +5 -0
- package/dist/commands/registry/index.d.ts +1 -1
- package/dist/commands/registry/index.js +1 -1
- package/dist/commands/talk/ai-say.d.ts +1 -1
- package/dist/commands/talk/ai-say.js +6 -5
- package/dist/core/game.d.ts +13 -0
- package/dist/core/game.js +29 -3
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +3 -3
- package/dist/core/openings.d.ts +20 -6
- package/dist/core/openings.js +45 -22
- package/dist/core/pgn.d.ts +4 -0
- package/dist/core/pgn.js +35 -6
- package/dist/games/archive.d.ts +25 -5
- package/dist/games/archive.js +52 -19
- package/dist/games/chat-start.d.ts +2 -2
- package/dist/games/chat-start.js +6 -1
- package/dist/games/current-game.d.ts +2 -2
- package/dist/games/current-game.js +3 -2
- package/dist/games/index.d.ts +2 -1
- package/dist/games/index.js +2 -1
- package/dist/games/position-shown.d.ts +24 -0
- package/dist/games/position-shown.js +51 -0
- package/dist/home/index.d.ts +1 -1
- package/dist/home/index.js +1 -1
- package/dist/home/same-path.d.ts +6 -1
- package/dist/home/same-path.js +22 -3
- package/dist/host-files/host-files.d.ts +5 -0
- package/dist/host-files/host-files.js +13 -4
- package/dist/host-files/index.d.ts +1 -1
- package/dist/host-files/index.js +1 -1
- package/dist/page/app/app.js +30 -7
- package/dist/page/app/served.js +9 -4
- package/dist/page/avatars/torretta.css +4 -4
- package/dist/page/base.css +1 -1
- package/dist/page/board/board.css +4 -2
- package/dist/page/dialogs/dialogs.css +3 -1
- package/dist/page/game/column.js +10 -8
- package/dist/page/game/game.css +86 -6
- package/dist/page/game/plies.js +4 -0
- package/dist/page/game/review-progress.js +11 -0
- package/dist/page/guide/drawings/drawings.css +0 -1
- package/dist/page/guide/en.md +2 -2
- package/dist/page/guide/it.md +2 -2
- package/dist/page/layout/icon.ico +0 -0
- package/dist/page/layout/layout.css +32 -15
- package/dist/page/layout/window.js +41 -2
- package/dist/page/legend/legend.css +4 -16
- package/dist/page/legend/legend.js +28 -15
- package/dist/page/profile/settings.js +1 -0
- package/dist/page/table/action.js +42 -0
- package/dist/page/table/table.css +57 -39
- package/dist/page/table/window.js +67 -67
- package/dist/page/talk/talk.css +52 -9
- package/dist/page/talk/talk.js +65 -20
- package/dist/page/talk/voice.js +92 -21
- package/dist/page/text.js +24 -8
- package/dist/server/bell/bell.d.ts +24 -27
- package/dist/server/bell/bell.js +79 -143
- package/dist/server/bell/index.d.ts +1 -1
- package/dist/server/bell/index.js +2 -2
- package/dist/server/mcp/mcp.js +49 -7
- package/dist/server/page/analyses.js +15 -4
- package/dist/server/page/files.js +3 -1
- package/dist/server/page/game.d.ts +5 -0
- package/dist/server/page/game.js +78 -13
- package/dist/server/page/http.d.ts +1 -1
- package/dist/server/page/page.d.ts +14 -9
- package/dist/server/page/page.js +111 -26
- package/dist/server/page/table.d.ts +38 -4
- package/dist/server/page/table.js +61 -23
- package/dist/server/page/windows.d.ts +22 -0
- package/dist/server/page/windows.js +45 -0
- package/dist/server/ports/index.d.ts +1 -0
- package/dist/server/ports/index.js +2 -0
- package/dist/server/ports/ports.d.ts +78 -0
- package/dist/server/ports/ports.js +222 -0
- package/dist/server/table/browser.d.ts +22 -6
- package/dist/server/table/browser.js +98 -20
- package/dist/server/table/hosts/hooks.d.ts +6 -0
- package/dist/server/table/hosts/hooks.js +38 -0
- package/dist/server/table/hosts/hosts.d.ts +13 -5
- package/dist/server/table/hosts/hosts.js +16 -10
- package/dist/server/table/hosts/index.d.ts +1 -0
- package/dist/server/table/hosts/index.js +1 -0
- package/dist/server/table/hosts/play.d.ts +6 -4
- package/dist/server/table/hosts/play.js +58 -16
- package/dist/server/table/index.d.ts +1 -1
- package/dist/server/table/launch.d.ts +5 -4
- package/dist/server/table/launch.js +18 -5
- package/dist/server/table/link.js +1 -0
- package/dist/server/table/table.d.ts +7 -0
- package/dist/server/table/table.js +39 -11
- package/instructions/opponent.md +1 -1
- package/package.json +1 -1
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// to; it closes by itself once no browser has had the page open, and no chat been attached, for a while.
|
|
3
3
|
import { request } from "node:http";
|
|
4
4
|
import { samePath, tableFolder } from "../../home/index.js";
|
|
5
|
-
import { setUpHosts } from "../../host-files/index.js";
|
|
6
|
-
import { pageAt, pagePorts } from "../bell/index.js";
|
|
7
5
|
import { startPage } from "../page/index.js";
|
|
6
|
+
import { pageAt, pagePorts } from "../ports/index.js";
|
|
7
|
+
import { setUpTable } from "./hosts/index.js";
|
|
8
8
|
/** Five minutes with no browser and no chat, looked at every fifteen seconds (D-104). */
|
|
9
9
|
export const tableTimes = { idle: 5 * 60_000, every: 15_000 };
|
|
10
10
|
/**
|
|
@@ -14,7 +14,7 @@ export const tableTimes = { idle: 5 * 60_000, every: 15_000 };
|
|
|
14
14
|
*/
|
|
15
15
|
export async function startTable(context, times = tableTimes, chats, updater) {
|
|
16
16
|
const folder = tableFolder(context.home());
|
|
17
|
-
|
|
17
|
+
setUpTable(folder, context.platform);
|
|
18
18
|
let quit = () => undefined;
|
|
19
19
|
const quitting = new Promise((done) => {
|
|
20
20
|
quit = done;
|
|
@@ -61,19 +61,47 @@ export async function tableAt(folder) {
|
|
|
61
61
|
return port === undefined ? undefined : { url: `http://127.0.0.1:${port}/`, port, version: said[index]?.version, chat: said[index]?.chat };
|
|
62
62
|
}
|
|
63
63
|
/** Asks the table at a port to quit; it answers before it goes, and a table that cannot be reached, or does not answer within a second or so, is let be. */
|
|
64
|
-
export function askToQuit(port) {
|
|
64
|
+
export async function askToQuit(port) {
|
|
65
|
+
await askTable(port, "/api/table/quit");
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Asks the table at a port for an opening of its window: its number, which the window carries, null while another opening has not reached the table
|
|
69
|
+
* yet, so that no second window opens; undefined when the table did not answer.
|
|
70
|
+
*/
|
|
71
|
+
export async function askToOpen(port) {
|
|
72
|
+
const answer = await askTable(port, "/api/table/open");
|
|
73
|
+
const opening = answer?.opening;
|
|
74
|
+
return typeof opening === "number" || opening === null ? opening : undefined;
|
|
75
|
+
}
|
|
76
|
+
/** Lets go of the opening the table at a port gave, whose window will never reach it: the next `chesspal` opens its own at once. */
|
|
77
|
+
export async function askToRelease(port, opening) {
|
|
78
|
+
await askTable(port, "/api/table/open", { release: opening });
|
|
79
|
+
}
|
|
80
|
+
// A POST of JSON to a route of the table: its answer read as JSON, undefined when it could not be reached or read in time.
|
|
81
|
+
function askTable(port, path, body = {}) {
|
|
65
82
|
return new Promise((done) => {
|
|
66
|
-
const asked = request({ host: "127.0.0.1", port, path
|
|
67
|
-
|
|
68
|
-
response.
|
|
83
|
+
const asked = request({ host: "127.0.0.1", port, path, method: "POST", headers: { "Content-Type": "application/json" }, agent: false }, (response) => {
|
|
84
|
+
let body = "";
|
|
85
|
+
response.setEncoding("utf8");
|
|
86
|
+
response.on("data", (chunk) => {
|
|
87
|
+
body += chunk;
|
|
88
|
+
});
|
|
89
|
+
response.on("end", () => {
|
|
90
|
+
try {
|
|
91
|
+
done(JSON.parse(body));
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
done(undefined);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
69
97
|
});
|
|
70
|
-
asked.setTimeout(
|
|
71
|
-
asked.on("error", () => done());
|
|
72
|
-
asked.end(
|
|
98
|
+
asked.setTimeout(tableWait, () => asked.destroy());
|
|
99
|
+
asked.on("error", () => done(undefined));
|
|
100
|
+
asked.end(JSON.stringify(body));
|
|
73
101
|
});
|
|
74
102
|
}
|
|
75
103
|
// A table answers at once: one stuck must not hold the chat's first tool, nor `chesspal`.
|
|
76
|
-
const
|
|
104
|
+
const tableWait = 1_500;
|
|
77
105
|
/** Whether a table of the same folder answers on a lower port than this one's: the other won, and this one goes. */
|
|
78
106
|
async function lostTo(url, folder) {
|
|
79
107
|
const port = Number(new URL(url).port);
|
package/instructions/opponent.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
You choose your moves, explain them briefly and talk with the player.
|
|
2
2
|
|
|
3
3
|
- `status` says where the game stands and what to do next. The game is played on the board page, in the player's browser, and the chat is for talking: when `status` says nobody has it open, give them its address once. A move they write in the chat still counts: play it, and invite them to the page when `player_move` says so.
|
|
4
|
-
- Every move goes through the tools: the player's with `player_move`, which answers with the position for your reply; yours with `ai_move`, with your plan. Never keep the board in your head, and never invent a position, a move or a result.
|
|
4
|
+
- Every move goes through the tools: the player's with `player_move`, which answers with the position for your reply (a move they write alone in Claude Code may come already played by Chesspal, with that position); yours with `ai_move`, with your plan. Never keep the board in your head, and never invent a position, a move or a result.
|
|
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. 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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chesspal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
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": {
|