rpg-engine 0.19.1 → 0.21.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/README.md +9 -6
- package/dist/adventures/index.d.ts +1 -1
- package/dist/adventures/index.js +1 -1
- package/dist/adventures/source.d.ts +3 -0
- package/dist/adventures/source.js +11 -49
- package/dist/campaign/create-campaign.d.ts +1 -1
- package/dist/campaign/create-campaign.js +4 -3
- package/dist/campaign/find-campaign.d.ts +6 -0
- package/dist/campaign/find-campaign.js +7 -1
- package/dist/campaign/host-files.js +22 -0
- package/dist/campaign/index.d.ts +2 -2
- package/dist/campaign/index.js +2 -2
- package/dist/campaign/last-choices.d.ts +10 -4
- package/dist/campaign/last-choices.js +43 -17
- package/dist/campaign/settings.d.ts +10 -2
- package/dist/campaign/settings.js +32 -8
- package/dist/chats/chat.d.ts +33 -0
- package/dist/chats/chat.js +50 -0
- package/dist/chats/claude-code.d.ts +5 -0
- package/dist/chats/claude-code.js +39 -0
- package/dist/chats/codex.d.ts +3 -0
- package/dist/chats/codex.js +42 -0
- package/dist/chats/index.d.ts +5 -0
- package/dist/chats/index.js +12 -0
- package/dist/chats/keep.d.ts +10 -0
- package/dist/chats/keep.js +50 -0
- package/dist/chats/read.d.ts +8 -0
- package/dist/chats/read.js +46 -0
- package/dist/cli/cli.js +6 -1
- package/dist/cli/command-line.js +3 -2
- package/dist/commands/book.d.ts +36 -0
- package/dist/commands/book.js +129 -0
- package/dist/commands/chats.d.ts +38 -0
- package/dist/commands/chats.js +93 -0
- package/dist/commands/config/config.js +2 -2
- package/dist/commands/config/dashboard.d.ts +8 -1
- package/dist/commands/config/dashboard.js +70 -16
- package/dist/commands/config/words.d.ts +1 -1
- package/dist/commands/config/words.js +18 -5
- package/dist/commands/find.js +1 -1
- package/dist/commands/image.d.ts +14 -0
- package/dist/commands/image.js +100 -20
- package/dist/commands/index.js +4 -0
- package/dist/commands/init.js +3 -3
- package/dist/commands/package/data.d.ts +35 -0
- package/dist/commands/package/data.js +117 -0
- package/dist/commands/package/here.d.ts +7 -2
- package/dist/commands/package/here.js +23 -11
- package/dist/commands/package/install.js +14 -15
- package/dist/commands/package/language.d.ts +15 -0
- package/dist/commands/package/language.js +109 -0
- package/dist/commands/package/package.js +20 -10
- package/dist/commands/package/result.d.ts +19 -0
- package/dist/commands/package/theme.d.ts +13 -0
- package/dist/commands/package/theme.js +66 -0
- package/dist/commands/package/uninstall.d.ts +4 -1
- package/dist/commands/package/uninstall.js +29 -9
- package/dist/commands/scene/close.d.ts +2 -0
- package/dist/commands/scene/close.js +20 -2
- package/dist/commands/scene/result.d.ts +2 -0
- package/dist/commands/scene/scene.d.ts +2 -0
- package/dist/commands/shared/books/adventures.d.ts +0 -4
- package/dist/commands/shared/books/adventures.js +2 -31
- package/dist/commands/shared/books/words.js +3 -2
- package/dist/commands/shared/campaign/book.d.ts +42 -0
- package/dist/commands/shared/campaign/book.js +118 -0
- package/dist/commands/shared/campaign/chats.d.ts +11 -0
- package/dist/commands/shared/campaign/chats.js +29 -0
- package/dist/commands/shared/campaign/images.js +7 -1
- package/dist/commands/shared/campaign/mode.js +3 -1
- package/dist/commands/shared/campaign/saves.js +13 -5
- package/dist/commands/shared/campaign/world.js +2 -1
- package/dist/commands/shared/packages/catalog.d.ts +3 -3
- package/dist/commands/shared/packages/catalog.js +98 -42
- package/dist/commands/shared/packages/unpacked.d.ts +50 -0
- package/dist/commands/shared/packages/unpacked.js +146 -0
- package/dist/commands/shared/sheet/sheet.d.ts +7 -0
- package/dist/commands/shared/sheet/sheet.js +27 -0
- package/dist/commands/status.d.ts +1 -0
- package/dist/commands/status.js +4 -0
- package/dist/commands/view/page.js +4 -3
- package/dist/commands/view/result.d.ts +2 -0
- package/dist/commands/view/view.d.ts +1 -0
- package/dist/commands/view/view.js +4 -0
- package/dist/core/archive.d.ts +13 -0
- package/dist/core/archive.js +76 -0
- package/dist/core/consents.d.ts +2 -2
- package/dist/core/consents.js +3 -3
- package/dist/core/context.d.ts +40 -2
- package/dist/core/context.js +1 -0
- package/dist/core/download.js +1 -1
- package/dist/core/store.d.ts +5 -1
- package/dist/core/store.js +15 -2
- package/dist/dashboard/acts/names.js +10 -5
- package/dist/dashboard/acts/sending.js +5 -2
- package/dist/dashboard/acts/sheet.js +66 -15
- package/dist/dashboard/api.js +27 -4
- package/dist/dashboard/app.js +9 -4
- package/dist/dashboard/guide/ar.md +16 -15
- package/dist/dashboard/guide/cs.md +15 -14
- package/dist/dashboard/guide/da.md +17 -16
- package/dist/dashboard/guide/de.md +17 -16
- package/dist/dashboard/guide/el.md +17 -16
- package/dist/dashboard/guide/en.md +14 -13
- package/dist/dashboard/guide/es.md +15 -14
- package/dist/dashboard/guide/fi.md +15 -14
- package/dist/dashboard/guide/fr.md +20 -19
- package/dist/dashboard/guide/he.md +15 -14
- package/dist/dashboard/guide/hi.md +15 -14
- package/dist/dashboard/guide/hu.md +19 -18
- package/dist/dashboard/guide/is.md +15 -14
- package/dist/dashboard/guide/it.md +18 -17
- package/dist/dashboard/guide/ja.md +15 -14
- package/dist/dashboard/guide/ko.md +16 -15
- package/dist/dashboard/guide/nb.md +17 -16
- package/dist/dashboard/guide/nl.md +15 -14
- package/dist/dashboard/guide/pl.md +16 -15
- package/dist/dashboard/guide/pt.md +16 -15
- package/dist/dashboard/guide/ro.md +15 -14
- package/dist/dashboard/guide/ru.md +16 -15
- package/dist/dashboard/guide/sv.md +15 -14
- package/dist/dashboard/guide/tr.md +18 -17
- package/dist/dashboard/guide/uk.md +19 -18
- package/dist/dashboard/guide/zh.md +16 -15
- package/dist/dashboard/i18n/ar.json +63 -9
- package/dist/dashboard/i18n/cs.json +63 -9
- package/dist/dashboard/i18n/da.json +63 -9
- package/dist/dashboard/i18n/de.json +63 -9
- package/dist/dashboard/i18n/el.json +63 -9
- package/dist/dashboard/i18n/es.json +63 -9
- package/dist/dashboard/i18n/fi.json +63 -9
- package/dist/dashboard/i18n/fr.json +63 -9
- package/dist/dashboard/i18n/he.json +63 -9
- package/dist/dashboard/i18n/hi.json +63 -9
- package/dist/dashboard/i18n/hu.json +63 -9
- package/dist/dashboard/i18n/is.json +63 -9
- package/dist/dashboard/i18n/it.json +64 -10
- package/dist/dashboard/i18n/ja.json +63 -9
- package/dist/dashboard/i18n/ko.json +63 -9
- package/dist/dashboard/i18n/nb.json +63 -9
- package/dist/dashboard/i18n/nl.json +63 -9
- package/dist/dashboard/i18n/pl.json +63 -9
- package/dist/dashboard/i18n/pt.json +63 -9
- package/dist/dashboard/i18n/ro.json +63 -9
- package/dist/dashboard/i18n/ru.json +63 -9
- package/dist/dashboard/i18n/sv.json +63 -9
- package/dist/dashboard/i18n/tr.json +63 -9
- package/dist/dashboard/i18n/uk.json +63 -9
- package/dist/dashboard/i18n/zh.json +63 -9
- package/dist/dashboard/journal/book.js +107 -0
- package/dist/dashboard/journal/journal.js +16 -12
- package/dist/dashboard/kit.js +1 -1
- package/dist/dashboard/packages/catalog.js +31 -14
- package/dist/dashboard/packages/engine.js +46 -2
- package/dist/dashboard/packages/installed.js +13 -0
- package/dist/dashboard/packages/outcomes.js +21 -0
- package/dist/dashboard/packages/packages.js +41 -18
- package/dist/dashboard/packages/rows.js +3 -1
- package/dist/dashboard/parts/icons.js +3 -0
- package/dist/dashboard/parts/labels.js +6 -0
- package/dist/dashboard/parts/picture.js +89 -0
- package/dist/dashboard/parts/refusals.js +8 -1
- package/dist/dashboard/parts/widgets.js +3 -2
- package/dist/dashboard/place/view.js +1 -1
- package/dist/dashboard/play/scene.js +8 -5
- package/dist/dashboard/settings/settings.js +32 -16
- package/dist/dashboard/settings/setup.js +5 -3
- package/dist/dashboard/sheet/party.js +5 -2
- package/dist/dashboard/sheet/sheet.js +10 -6
- package/dist/dashboard/shell/notices.js +2 -2
- package/dist/dashboard/shell/system-style.js +45 -12
- package/dist/dashboard/shell/tooltip.js +223 -0
- package/dist/dashboard/style.css +775 -261
- package/dist/dashboard/world/calendar.js +1 -1
- package/dist/dashboard/world/lore.js +5 -4
- package/dist/dashboard/world/place-card.js +2 -1
- package/dist/helpers/briefs.d.ts +5 -0
- package/dist/helpers/briefs.js +8 -0
- package/dist/helpers/chosen.d.ts +8 -2
- package/dist/helpers/chosen.js +110 -6
- package/dist/helpers/codex.js +2 -1
- package/dist/helpers/index.d.ts +2 -2
- package/dist/helpers/index.js +2 -2
- package/dist/images/images.d.ts +2 -0
- package/dist/images/images.js +16 -2
- package/dist/images/index.d.ts +1 -1
- package/dist/images/index.js +1 -1
- package/dist/languages/index.d.ts +1 -1
- package/dist/languages/index.js +1 -1
- package/dist/languages/pack.d.ts +4 -1
- package/dist/languages/pack.js +16 -5
- package/dist/packages/engine.d.ts +7 -0
- package/dist/packages/engine.js +32 -1
- package/dist/packages/index.d.ts +1 -1
- package/dist/packages/index.js +1 -1
- package/dist/server/approver.d.ts +6 -0
- package/dist/server/approver.js +28 -0
- package/dist/server/chats.d.ts +3 -0
- package/dist/server/chats.js +27 -0
- package/dist/server/dashboard/engine.d.ts +18 -0
- package/dist/server/dashboard/engine.js +31 -0
- package/dist/server/dashboard/files.d.ts +8 -1
- package/dist/server/dashboard/files.js +30 -10
- package/dist/server/dashboard/index.d.ts +3 -0
- package/dist/server/dashboard/index.js +10 -1
- package/dist/server/dashboard/news.js +36 -5
- package/dist/server/dashboard/pictures.d.ts +7 -0
- package/dist/server/dashboard/pictures.js +62 -0
- package/dist/server/dashboard/writes.d.ts +5 -3
- package/dist/server/dashboard/writes.js +45 -14
- package/dist/server/mcp.js +37 -6
- package/dist/server/player-acts.d.ts +7 -2
- package/dist/server/player-acts.js +10 -3
- package/dist/testing/index.js +1 -0
- package/dist/themes/index.d.ts +2 -1
- package/dist/themes/index.js +4 -2
- package/dist/themes/installed.d.ts +14 -0
- package/dist/themes/installed.js +28 -0
- package/dist/themes/theme.d.ts +7 -0
- package/dist/themes/theme.js +22 -0
- package/instructions/core.md +3 -3
- package/instructions/dashboard-guide.md +1 -0
- package/instructions/mentor-hints.md +1 -1
- package/instructions/mentor-tutorial.md +1 -1
- package/instructions/party.md +1 -1
- package/instructions/play.md +2 -2
- package/instructions/start.md +1 -1
- package/package.json +2 -2
- package/systems/free/instructions/outcomes-told.md +1 -1
package/dist/server/mcp.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
|
+
import { homedir } from "node:os";
|
|
4
5
|
import { join } from "node:path";
|
|
5
6
|
import { z } from "zod";
|
|
6
|
-
import { findCampaign, hasCharacterAgent, readTextSetting, refreshHostFiles } from "../campaign/index.js";
|
|
7
|
+
import { chosenPictureMaker, findCampaign, hasCharacterAgent, readTextSetting, refreshHostFiles } from "../campaign/index.js";
|
|
8
|
+
import { chatFolders } from "../chats/index.js";
|
|
7
9
|
import { commands } from "../commands/index.js";
|
|
8
10
|
import { installCampaignSystem } from "../commands/package/install.js";
|
|
9
11
|
import { libraryRunner } from "../commands/shared/books/library-reader.js";
|
|
@@ -25,6 +27,7 @@ import { computerHelpers, hostPictures, hostReader, hostWriter } from "../helper
|
|
|
25
27
|
import { hostInstructions, startInstructions } from "../instructions/index.js";
|
|
26
28
|
import { npmEngine, npmPackages } from "../packages/index.js";
|
|
27
29
|
import { loadSystemCode } from "../systems/index.js";
|
|
30
|
+
import { chatKeeper } from "./chats.js";
|
|
28
31
|
import { startDashboard } from "./dashboard/index.js";
|
|
29
32
|
// While the player decides, the call reports progress this often, so that a host does not take it for a call that hangs.
|
|
30
33
|
const progressEvery = 20 * 1000;
|
|
@@ -50,6 +53,8 @@ export function createMcpServer(context = defaultContext(), environment = proces
|
|
|
50
53
|
// A server lives as long as its chat: it gives each part of the instructions once (D-97).
|
|
51
54
|
context.told ??= new Set();
|
|
52
55
|
context.chat ??= { calls: 0 };
|
|
56
|
+
// What came after a call answered, as a picture made in its place or none, for the next (D-572).
|
|
57
|
+
context.later ??= laterLines();
|
|
53
58
|
// What changed outside the chat's commands, at the head of each call (OUT-1–OUT-4).
|
|
54
59
|
const outside = context.files instanceof SessionStore ? watchOutside(context, context.files) : { take: () => [], giveBack: () => undefined };
|
|
55
60
|
// The campaign's game system, one of ours, installed by itself when it is not on this computer, and said once (SYS-10).
|
|
@@ -66,8 +71,11 @@ export function createMcpServer(context = defaultContext(), environment = proces
|
|
|
66
71
|
// The examples of the descriptions in the names of the campaign's system, read without the session's store before the host asks for the tools (D-518).
|
|
67
72
|
const examples = { shown: examplesFor(context, new FileStore(context.systemFolders)) };
|
|
68
73
|
const coreTools = new Map();
|
|
74
|
+
// The chats copied into the campaign, the first time as the server starts, once its world is read (T-225).
|
|
75
|
+
const keepChats = chatKeeper(context);
|
|
69
76
|
// After every call the descriptions follow the campaign's system, as after init or config system, and the extensions' tools follow campaign.yaml.
|
|
70
77
|
const afterCall = () => {
|
|
78
|
+
keepChats();
|
|
71
79
|
refreshExamples(coreTools, examples, examplesFor(context, context.files ?? new FileStore(context.systemFolders)));
|
|
72
80
|
return extensions();
|
|
73
81
|
};
|
|
@@ -113,12 +121,12 @@ export async function startMcpServer() {
|
|
|
113
121
|
const leave = () => process.exit(0);
|
|
114
122
|
process.stdin.on("end", leave);
|
|
115
123
|
process.stdin.on("close", leave);
|
|
116
|
-
// The pictures, by the chat in use, which names itself as the session starts (D-308, D-
|
|
124
|
+
// The pictures, by the campaign's choice, else by the chat in use, which names itself as the session starts (D-308, D-572).
|
|
117
125
|
let server;
|
|
118
126
|
const host = () => server?.server.getClientVersion()?.name;
|
|
119
127
|
const context = {
|
|
120
128
|
...defaultContext(),
|
|
121
|
-
pictures: hostPictures(host),
|
|
129
|
+
pictures: hostPictures(host, () => chosenPictureMaker(context.folder)),
|
|
122
130
|
writer: hostWriter(host),
|
|
123
131
|
reader: hostReader(host),
|
|
124
132
|
// The command line that started this server runs the import apart, `rpg import` in the campaign's folder, with the chat's own helper.
|
|
@@ -132,6 +140,7 @@ export async function startMcpServer() {
|
|
|
132
140
|
download: downloadBytes,
|
|
133
141
|
host,
|
|
134
142
|
chat: { calls: 0 },
|
|
143
|
+
chatFolders: chatFolders(process.env, homedir()),
|
|
135
144
|
};
|
|
136
145
|
// The systems' code, loaded once for the session, as the engine's own: a system changed since needs the server started again (D-448).
|
|
137
146
|
context.systemCode = await loadSystemCode(context.systemFolders);
|
|
@@ -317,6 +326,7 @@ async function runTool(command, input, context, extra, prepare, installer, outsi
|
|
|
317
326
|
let news;
|
|
318
327
|
let changedOutside = [];
|
|
319
328
|
let installed = [];
|
|
329
|
+
let later = [];
|
|
320
330
|
// The call tells its parts on a copy of what the chat was told, given back at its end: an answer that never goes tells nothing, so its parts are told again
|
|
321
331
|
// (D-97), and what a call beside it told stays told.
|
|
322
332
|
const before = new Set(context.told);
|
|
@@ -337,11 +347,13 @@ async function runTool(command, input, context, extra, prepare, installer, outsi
|
|
|
337
347
|
await prepare();
|
|
338
348
|
// The campaign's system installed by itself, said first (SYS-10); a call stopped while it installed leaves the line to the next.
|
|
339
349
|
installed = extra.signal.aborted ? [] : installer.take();
|
|
350
|
+
// What came after the last calls answered, as a picture Claude drew in another's place, right after (D-572).
|
|
351
|
+
later = extra.signal.aborted ? [] : (context.later?.take() ?? []);
|
|
340
352
|
// After a load the chat going on remembers what is gone: nothing runs in it, until a new chat begins with instructions (D-361).
|
|
341
353
|
const back = chatAfterLoad(context, command.name, input);
|
|
342
354
|
if (back.refused !== undefined) {
|
|
343
355
|
news = context.news?.(told);
|
|
344
|
-
return { content: [{ type: "text", text: [...installed, ...(news?.lines ?? []), back.refused].join("\n\n") }, masterOnly(context)], isError: true };
|
|
356
|
+
return { content: [{ type: "text", text: [...installed, ...later, ...(news?.lines ?? []), back.refused].join("\n\n") }, masterOnly(context)], isError: true };
|
|
345
357
|
}
|
|
346
358
|
const checked = checkedInput(command, input, examples.shown);
|
|
347
359
|
// Stopped while the call was made ready, as while the system installed: the command never runs, so that calling it again does it once.
|
|
@@ -354,11 +366,12 @@ async function runTool(command, input, context, extra, prepare, installer, outsi
|
|
|
354
366
|
const text = command.format(await command.run(checked, { ...context, told, signal: extra.signal }));
|
|
355
367
|
// What the player changed on the dashboard comes first, once, what they changed while the call waited included (D-341).
|
|
356
368
|
news = context.news?.(told);
|
|
357
|
-
return { content: [{ type: "text", text: [...installed, ...(news?.lines ?? []), ...changedOutside, ...back.begun, text].join("\n\n") }, masterOnly(context)] };
|
|
369
|
+
return { content: [{ type: "text", text: [...installed, ...later, ...(news?.lines ?? []), ...changedOutside, ...back.begun, text].join("\n\n") }, masterOnly(context)] };
|
|
358
370
|
}
|
|
359
371
|
catch (error) {
|
|
360
372
|
news ??= context.news?.(told);
|
|
361
|
-
|
|
373
|
+
const said = error instanceof Error ? error.message : String(error);
|
|
374
|
+
return { content: [{ type: "text", text: [...installed, ...later, ...(news?.lines ?? []), ...changedOutside, said].join("\n\n") }, masterOnly(context)], isError: true };
|
|
362
375
|
}
|
|
363
376
|
finally {
|
|
364
377
|
clearInterval(keepAlive);
|
|
@@ -367,6 +380,7 @@ async function runTool(command, input, context, extra, prepare, installer, outsi
|
|
|
367
380
|
if (extra.signal.aborted) {
|
|
368
381
|
news?.restore();
|
|
369
382
|
installer.giveBack(installed);
|
|
383
|
+
context.later?.giveBack(later);
|
|
370
384
|
outside.giveBack(changedOutside);
|
|
371
385
|
if (chat !== undefined) {
|
|
372
386
|
chat.dashboardOffered = offered;
|
|
@@ -412,6 +426,23 @@ function systemInstaller(context) {
|
|
|
412
426
|
},
|
|
413
427
|
};
|
|
414
428
|
}
|
|
429
|
+
/** Lines a command leaves for the master's next call, as of a picture that came after its call answered (D-572). */
|
|
430
|
+
function laterLines() {
|
|
431
|
+
let untold = [];
|
|
432
|
+
return {
|
|
433
|
+
add: (line) => {
|
|
434
|
+
untold = [...untold, line];
|
|
435
|
+
},
|
|
436
|
+
take: () => {
|
|
437
|
+
const lines = untold;
|
|
438
|
+
untold = [];
|
|
439
|
+
return lines;
|
|
440
|
+
},
|
|
441
|
+
giveBack: (lines) => {
|
|
442
|
+
untold = [...lines, ...untold];
|
|
443
|
+
},
|
|
444
|
+
};
|
|
445
|
+
}
|
|
415
446
|
/**
|
|
416
447
|
* What changed outside the chat's commands since its last call (OUT-1–OUT-4): the world as it was is read before the session lets the changes in, so that the
|
|
417
448
|
* events they set off fire; at the server's first call, the files changed while no chat was open.
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export interface Act {
|
|
3
3
|
id: string;
|
|
4
4
|
text: string;
|
|
5
|
+
/** The thing of the sheet it starts from, by its page, whose known text the master hears with it (T-218). */
|
|
6
|
+
item?: string;
|
|
5
7
|
rung?: boolean;
|
|
6
8
|
}
|
|
7
9
|
/** The sentences said and not yet heard, in order, and the ids of those heard lately, for the page to tell. */
|
|
@@ -20,8 +22,11 @@ export declare function markRung(acts: Acts): void;
|
|
|
20
22
|
export declare function markHeard(acts: Acts, ids: string[]): void;
|
|
21
23
|
/** Gives a sentence back to the head of those waiting, as one Codex never took. */
|
|
22
24
|
export declare function giveBackAct(acts: Acts, act: Act): void;
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The sentences for the head of the master's call, marked heard; given back, in order, when that call never answers. `known` gives what the player character
|
|
27
|
+
* already knows of a sentence's thing, for the master to tell only what is new (T-218).
|
|
28
|
+
*/
|
|
29
|
+
export declare function takeActs(acts: Acts, quoted: (text: string) => string, known?: (item: string) => string | undefined): {
|
|
25
30
|
lines: string[];
|
|
26
31
|
restore(): void;
|
|
27
32
|
};
|
|
@@ -38,12 +38,19 @@ export function giveBackAct(acts, act) {
|
|
|
38
38
|
acts.pending.unshift(act);
|
|
39
39
|
acts.heard = acts.heard.filter((id) => id !== act.id);
|
|
40
40
|
}
|
|
41
|
-
/**
|
|
42
|
-
|
|
41
|
+
/**
|
|
42
|
+
* The sentences for the head of the master's call, marked heard; given back, in order, when that call never answers. `known` gives what the player character
|
|
43
|
+
* already knows of a sentence's thing, for the master to tell only what is new (T-218).
|
|
44
|
+
*/
|
|
45
|
+
export function takeActs(acts, quoted, known = () => undefined) {
|
|
43
46
|
const taken = [...acts.pending];
|
|
44
47
|
markHeard(acts, taken.map((act) => act.id));
|
|
45
48
|
return {
|
|
46
|
-
lines: taken.map((act) =>
|
|
49
|
+
lines: taken.map((act) => {
|
|
50
|
+
const already = act.item === undefined ? undefined : known(act.item);
|
|
51
|
+
return already === undefined ? actNews(act.text, quoted) : `${actNews(act.text, quoted)}
|
|
52
|
+
${already}`;
|
|
53
|
+
}),
|
|
47
54
|
restore: () => {
|
|
48
55
|
acts.pending = [...taken, ...acts.pending];
|
|
49
56
|
acts.heard = acts.heard.filter((id) => !taken.some((act) => act.id === id));
|
package/dist/testing/index.js
CHANGED
|
@@ -60,6 +60,7 @@ export async function testCampaign(options) {
|
|
|
60
60
|
systemFolders,
|
|
61
61
|
systemCode: await loadSystemCode(systemFolders),
|
|
62
62
|
extensionFolders: [packages],
|
|
63
|
+
unpacked: join(base, "unpacked"),
|
|
63
64
|
};
|
|
64
65
|
const started = [];
|
|
65
66
|
// Each call reads the campaign's context as the test left it, a page or a signal of its own included.
|
package/dist/themes/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { contrast } from "./contrast.ts";
|
|
2
2
|
export { themeCss } from "./css.ts";
|
|
3
|
-
export {
|
|
3
|
+
export { type InstalledTheme, installedThemes, isThemeId, themeId } from "./installed.ts";
|
|
4
|
+
export { drawnOrnament, readTheme, themeFile, themeFileName, themeFilesNamed, themeIconNames, type ThemeReading } from "./theme.ts";
|
package/dist/themes/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
// The dashboard's themes (D-527, D-528): a folder of data a game system names,
|
|
1
|
+
// The dashboard's themes (D-527, D-528): a folder of data a game system names, or a package of its own installed on this computer, read and checked here,
|
|
2
|
+
// its CSS of custom properties written here.
|
|
2
3
|
export { contrast } from "./contrast.js";
|
|
3
4
|
export { themeCss } from "./css.js";
|
|
4
|
-
export {
|
|
5
|
+
export { installedThemes, isThemeId, themeId } from "./installed.js";
|
|
6
|
+
export { drawnOrnament, readTheme, themeFile, themeFileName, themeFilesNamed, themeIconNames } from "./theme.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Theme } from "./theme.ts";
|
|
2
|
+
/** A theme installed on this computer: its id, which names its folder and its address; the theme when it passes its checks, else what to fix, each a line. */
|
|
3
|
+
export interface InstalledTheme {
|
|
4
|
+
id: string;
|
|
5
|
+
folder: string;
|
|
6
|
+
theme?: Theme;
|
|
7
|
+
problems: string[];
|
|
8
|
+
}
|
|
9
|
+
/** The themes in this folder, by their id; one refused is listed with its problems, for the player to see why it is not offered. */
|
|
10
|
+
export declare function installedThemes(folder: string): InstalledTheme[];
|
|
11
|
+
/** Whether a text is a theme's id: lowercase letters and digits, joined by hyphens. */
|
|
12
|
+
export declare function isThemeId(text: string): boolean;
|
|
13
|
+
/** The id of a theme by its name, lowercase letters, digits and hyphens: Old Parchment is old-parchment; a name without such letters, by a print of it. */
|
|
14
|
+
export declare function themeId(name: string): string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// The themes installed on this computer for every campaign, as packages of data alone: each in a folder of its own named by its id, read and checked as a
|
|
2
|
+
// game system's theme is.
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { files } from "../core/store.js";
|
|
6
|
+
import { readTheme } from "./theme.js";
|
|
7
|
+
// What an id is made of; a folder being unpacked starts with a dot, and is none.
|
|
8
|
+
const idPattern = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
9
|
+
/** The themes in this folder, by their id; one refused is listed with its problems, for the player to see why it is not offered. */
|
|
10
|
+
export function installedThemes(folder) {
|
|
11
|
+
return files().entries(folder)
|
|
12
|
+
.filter((entry) => entry.isFolder && idPattern.test(entry.name))
|
|
13
|
+
.map((entry) => entry.name)
|
|
14
|
+
.sort()
|
|
15
|
+
.map((id) => {
|
|
16
|
+
const path = join(folder, id);
|
|
17
|
+
return { id, folder: path, ...readTheme(path) };
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** Whether a text is a theme's id: lowercase letters and digits, joined by hyphens. */
|
|
21
|
+
export function isThemeId(text) {
|
|
22
|
+
return idPattern.test(text);
|
|
23
|
+
}
|
|
24
|
+
/** The id of a theme by its name, lowercase letters, digits and hyphens: Old Parchment is old-parchment; a name without such letters, by a print of it. */
|
|
25
|
+
export function themeId(name) {
|
|
26
|
+
const id = name.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").slice(0, 64).replace(/^-+|-+$/g, "");
|
|
27
|
+
return id === "" ? `theme-${createHash("sha256").update(name).digest("hex").slice(0, 8)}` : id;
|
|
28
|
+
}
|
package/dist/themes/theme.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ type ColourName = (typeof requiredColours)[number] | (typeof optionalColours)[nu
|
|
|
14
14
|
/** A theme as read, its files checked and its derived colours filled in. */
|
|
15
15
|
export interface Theme {
|
|
16
16
|
name: string;
|
|
17
|
+
/** Its version, as a theme installed on its own gives it. */
|
|
18
|
+
version?: string;
|
|
17
19
|
/** The folder it was read from: its files are served from there. */
|
|
18
20
|
folder: string;
|
|
19
21
|
fonts: ThemeFont[];
|
|
@@ -66,6 +68,11 @@ export interface ThemeReading {
|
|
|
66
68
|
export declare function readTheme(folder: string): ThemeReading;
|
|
67
69
|
/** The real path of a file of a theme's folder, only when it is one and inside it, links resolved: what the dashboard serves. */
|
|
68
70
|
export declare function themeFile(folder: string, name: string): string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* The files a theme.yaml names, with forward slashes, as written from its folder: its fonts and their licences, its ornament, icons and textures. None when
|
|
73
|
+
* it does not read: its checks say why.
|
|
74
|
+
*/
|
|
75
|
+
export declare function themeFilesNamed(text: string): string[];
|
|
69
76
|
/** An ornament drawn in one colour, turned for a page that reads right to left: the theme gives one drawing for both modes and both directions. */
|
|
70
77
|
export declare function drawnOrnament(svg: string, ink: string, mirrored: boolean): string;
|
|
71
78
|
export {};
|
package/dist/themes/theme.js
CHANGED
|
@@ -90,6 +90,7 @@ export function readTheme(folder) {
|
|
|
90
90
|
}
|
|
91
91
|
const theme = {
|
|
92
92
|
name: given.name,
|
|
93
|
+
...optional("version", given.version),
|
|
93
94
|
folder,
|
|
94
95
|
fonts,
|
|
95
96
|
...optional("textFont", family("text-font")),
|
|
@@ -118,6 +119,26 @@ export function themeFile(folder, name) {
|
|
|
118
119
|
return undefined;
|
|
119
120
|
}
|
|
120
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* The files a theme.yaml names, with forward slashes, as written from its folder: its fonts and their licences, its ornament, icons and textures. None when
|
|
124
|
+
* it does not read: its checks say why.
|
|
125
|
+
*/
|
|
126
|
+
export function themeFilesNamed(text) {
|
|
127
|
+
let data;
|
|
128
|
+
try {
|
|
129
|
+
data = parse(text);
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
const given = (typeof data === "object" && data !== null ? data : {});
|
|
135
|
+
const field = (value, key) => (typeof value === "object" && value !== null ? value[key] : undefined);
|
|
136
|
+
const fonts = Array.isArray(given.fonts) ? given.fonts.flatMap((font) => [field(font, "file"), field(font, "license")]) : [];
|
|
137
|
+
const icons = typeof given.icons === "object" && given.icons !== null ? Object.values(given.icons) : [];
|
|
138
|
+
const textures = ["light", "dark"].flatMap((mode) => ["page-texture", "bar-texture"].map((texture) => field(field(given[mode], texture), "picture")));
|
|
139
|
+
const named = [...fonts, ...icons, ...textures, field(given.cards, "ornament")];
|
|
140
|
+
return named.filter((one) => typeof one === "string").map((one) => one.replaceAll("\\", "/").replace(/^(\.\/)+/, ""));
|
|
141
|
+
}
|
|
121
142
|
/** An ornament drawn in one colour, turned for a page that reads right to left: the theme gives one drawing for both modes and both directions. */
|
|
122
143
|
export function drawnOrnament(svg, ink, mirrored) {
|
|
123
144
|
const coloured = svg.replaceAll("currentColor", ink);
|
|
@@ -164,6 +185,7 @@ const modeSchema = z.object({
|
|
|
164
185
|
}).strict();
|
|
165
186
|
const themeSchema = z.object({
|
|
166
187
|
name: z.string().min(1),
|
|
188
|
+
version: z.union([z.string().min(1), z.number()]).transform(String).optional(),
|
|
167
189
|
fonts: z.array(z.object({
|
|
168
190
|
family: z.string().regex(/^[\p{L}\p{N} _-]+$/u, { error: "letters, numbers, spaces and hyphens alone" }),
|
|
169
191
|
file: fileName,
|
package/instructions/core.md
CHANGED
|
@@ -8,10 +8,10 @@ You are the game master of this table. It is a craft, and you inhabit it as an a
|
|
|
8
8
|
|
|
9
9
|
1. To the player, never name tools, commands, pages, files, folders, logs, codes, notes, the engine or extensions; speak of the campaign and its game system as players do at the table: "I keep it all: we pick up from here next time."
|
|
10
10
|
2. Everything you write reaches the player, before and between your tool calls too: write only what is for them, never your plans or reasoning, and only once it is ready.
|
|
11
|
-
3. While the tools work, write nothing,
|
|
11
|
+
3. While the tools work, write nothing, off-game either, even when the app asks what you are doing: no "[OOC: Un momento, sto preparando]", no note to yourself such as "Fails the save." or "Torch out at midnight"; keep those in your thinking.
|
|
12
12
|
4. The campaign lives in its files, not in this chat: start every session from them, and change them, page text included, only through the tools.
|
|
13
|
-
5. Speak the campaign's language. Out of setup, off-game talk, yours or the player's, goes in
|
|
14
|
-
6. Inside the story, never break it. Asked in earnest, off-game, whether you are an AI, say yes in one
|
|
13
|
+
5. Speak the campaign's language. Out of setup, off-game talk, yours or the player's, goes in *[OOC: like this]*, in italics, never plain brackets, in a sentence or two; read a player's plain brackets as off-game too, without remarks; answer theirs first, only what they asked and nothing the story is about to tell, so the message ends in the story.
|
|
14
|
+
6. Inside the story, never break it. Asked in earnest, off-game, whether you are an AI, say yes in one *[OOC: …]* line, then go back to the game.
|
|
15
15
|
|
|
16
16
|
### Truth and rulings
|
|
17
17
|
|
|
@@ -4,5 +4,6 @@ How the player uses their dashboard, to answer in a few words, as part of the ga
|
|
|
4
4
|
- Scene: where the party is, with its picture and text, its map with who stands where, and the open scene. While a scene goes by turns, as a fight, it shows on top whose turn it is and who comes next, and their character's card beside the map; on other sections a notice leads there on their turn.
|
|
5
5
|
- Journal: the quests, those followed with their star beside the page; the story by scenes; the companions' diaries; their own notes, which they may share with you.
|
|
6
6
|
- World: what their character knows of the world, in four tabs: Map, the places they know with distances; Lore, the pages they know; Documents, what they have read; Calendar, the days and what is set on them.
|
|
7
|
+
- On a page they see, as a character, a place or a quest, a button gives it a picture of their own in place of the one it has; your next call says so.
|
|
7
8
|
- The icons at the row's end: Saves, to save or go back as the campaign's saves setting allows; Help, how to play with the chat and the page; Settings, the same as `config` (difficulty, dice digital or physical, units, language, pictures, lines and veils, mentor); Packages, the game systems, extensions and languages on this computer, and RPG Engine's own update, which the player makes there, never you, and in its menu the pages a game system or extension adds; About.
|
|
8
9
|
- When you call `ask`, the buttons appear on the page too: a click rolls the dice of a check, or with "By hand" a click on the lit row of their sheet or a throw of the tray's dice, and they may write their own words instead; their own dice are the physical setting, and then they give you the faces in the chat. They may also propose changes to their character's story there, which reach you to write with their yes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
The player wants a hint now and then (mentor hints). Besides answering what they ask, add at most one tip of a sentence or two, in
|
|
1
|
+
The player wants a hint now and then (mentor hints). Besides answering what they ask, add at most one tip of a sentence or two, in [OOC: …], when they face a choice that matters, forget something of their sheet that fits, or get a rule wrong; most messages have none, and never two in a row. A tip names what the player may miss from the sheet, the rules or what their character knows; never a summary of the scene they just read ("[OOC: Rosa is at the inn. Two nights to the new moon.]"). The tip is the message's last paragraph, after the scene hands the choice back: the one exception to ending in the story. Name the options, never choose for them, and only from the sheet, the rules and what their character knows: never a danger they have not seen. No tip in the message that tells a fall, a death or a revelation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
The player is learning the game (mentor tutorial). The first time a mechanic comes up, explain it in a sentence or two, in
|
|
1
|
+
The player is learning the game (mentor tutorial). The first time a mechanic comes up, explain it in a sentence or two, in [OOC: …], before they choose: two new ones a message at most, as the message's last paragraph after the scene hands the choice back, the one exception to ending in the story. Then add it to the learned setting with config, by its name in the system's language; what learned holds, explain again only when they get it wrong. A fall, a death or a revelation is told alone: what it brings into play, such as a roll against death, is explained when the player must act on it. Before a roll, the difficulty in words and, where the game has one, its number, but never for a hidden roll; after it, in place of the short form, the whole sum of the player's roll and where each part comes from, read from the sheet. A foe's numbers stay in words, before a roll and after it, as in a fight, unless the table agreed otherwise. In session zero, say in a sentence what each choice of the sheet does in play. When a fight ends, and when the player ends the session, a debrief in [OOC: …], three lines at most for a fight and five for a session: what worked, one thing to try next time, what their sheet could have done; only what they have seen and you are sure happened, as the files and this chat hold it. A fight that ends in a death has its debrief at the session's end. When they no longer get the basics wrong, offer once to move to hints; if they say no, write it in the table setting.
|
package/instructions/party.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
## More than one player character
|
|
2
2
|
|
|
3
|
-
More than one player character is played here, by one player or by several at the same screen: wherever these instructions say the player, read whoever plays the character at hand. A message says who acts as "Ettore: …" or "@Ettore";
|
|
3
|
+
More than one player character is played here, by one player or by several at the same screen: wherever these instructions say the player, read whoever plays the character at hand. A message says who acts as "Ettore: …" or "@Ettore"; [OOC: …] stays off-game. When it names no one and the scene does not make it plain, ask whose it is.
|
|
4
4
|
|
|
5
5
|
- One spotlight per message: it follows whoever acted, the others a sentence at most. End by handing the choice to one character by name ("E tu, Lena?"), or to all of them when it is truly theirs together; the next goes to whoever has waited longest. A player character the message does not name waits, doing nothing new.
|
|
6
6
|
- When the party splits, tell one group at a time, each in a scene of its own; cut on a hook or a choice, never settling both groups in one message. Never cut away in the middle of a fight. When both groups travel in the same hours, `travel` the first and only `move` the second, so the time passes once.
|
package/instructions/play.md
CHANGED
|
@@ -19,7 +19,7 @@ The story is on. Besides the tools above:
|
|
|
19
19
|
5. Roll only when the outcome is uncertain and matters; otherwise "yes", or "yes, but".
|
|
20
20
|
6. What their trade, past or senses would give them needs no roll; a roll adds more, never holds the only clue or way on.
|
|
21
21
|
7. Before a roll of the character, whoever calls it, say what is at stake either way and which checks fit, with the conditions and effects that change them rolled in, and keep to it.
|
|
22
|
-
8. Then stop: the player says which they roll, or changes their mind. After the outcome, a misunderstanding or a mistake of yours is always undone, said in
|
|
22
|
+
8. Then stop: the player says which they roll, or changes their mind. After the outcome, a misunderstanding or a mistake of yours is always undone, said in [OOC: …]; any other take-back is yours to grant as the difficulty says, never to roll the same check again. A check they only ask about, such as "[OOC: Perception?]", is no roll yet: give its stakes and wait.
|
|
23
23
|
9. With physical dice the player gives their faces; in a fight, the action they declare is enough.
|
|
24
24
|
10. Show every roll the player sees in brackets, with its numbers, right after the moment it decides, even one they asked to see, and let the story tell the outcome.
|
|
25
25
|
11. Failure brings a complication or a cost, never a dead end: time, harm, something spent, a worse position, someone alerted, a hard choice. That way may close, never every way; trying again costs something new.
|
|
@@ -64,4 +64,4 @@ The story is on. Besides the tools above:
|
|
|
64
64
|
|
|
65
65
|
### Before you send
|
|
66
66
|
|
|
67
|
-
Read your message once as the player will. Does it answer all they did, rolled and asked? Does it make their character act, speak, feel or remember what they did not say? Does it name a tool, a page or a file? Does it tell what the character has not found out? Does a roll come without its stakes said first? Does the story pass 150 words, one scene or two companions speaking, or
|
|
67
|
+
Read your message once as the player will. Does it answer all they did, rolled and asked? Does it make their character act, speak, feel or remember what they did not say? Does it name a tool, a page or a file? Does it tell what the character has not found out? Does a roll come without its stakes said first? Does the story pass 150 words, one scene or two companions speaking, or an [OOC: …] two sentences? Does it end with the scene handing the choice back?
|
package/instructions/start.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
This folder is a tabletop role-playing campaign and you are its game master: you invent, play and rule; the `rpg` tools remember, roll and keep the accounts. Before your first reply in every chat, and again whenever the conversation has been summarized, call `instructions` (how to be its game master), then `status` (where the game stands). Follow them. Never mention tools, files or the engine to the player.
|
|
1
|
+
This folder is a tabletop role-playing campaign and you are its game master: you invent, play and rule; the `rpg` tools remember, roll and keep the accounts. Before your first reply in every chat, and again whenever the conversation has been summarized, call `instructions` (how to be its game master), then `status` (where the game stands). Follow them. Never mention tools, files or the engine to the player. Never read your app's past chats or their logs: the game remembers only through `status`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rpg-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Play a tabletop role-playing game with an AI as your game master: the AI tells the story; RPG Engine remembers the world, rolls the dice and keeps the accounts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"dprint": "^0.64.3",
|
|
81
81
|
"eslint": "^10.11.0",
|
|
82
82
|
"fast-check": "^4.10.2",
|
|
83
|
-
"playwright-core": "~1.
|
|
83
|
+
"playwright-core": "~1.65.0",
|
|
84
84
|
"typescript": "^6.0.3",
|
|
85
85
|
"vitest": "^5.0.5"
|
|
86
86
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
- The player never rolls: what they try succeeds, costs or fails as the situation, their abilities and the world say, and you tell it. Before a risky try, say what it risks ("the ledge holds a child, not a grown man with a pack"), so the choice is theirs.
|
|
2
|
-
- If they ask for dice, say in
|
|
2
|
+
- If they ask for dice, say in [OOC: …] that this campaign plays without them, and give the choice the dice would have decided.
|
|
3
3
|
- Your 1d100 on the world is always hidden here, and never mentioned.
|
|
4
4
|
- Lethality is narrative or epic. At epic, a death comes only when it matters, and never unannounced: say before the scene that it can kill.
|