rpg-engine 0.20.0 → 0.22.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.
Files changed (194) hide show
  1. package/dist/adventures/index.d.ts +1 -1
  2. package/dist/adventures/index.js +1 -1
  3. package/dist/adventures/source.d.ts +3 -0
  4. package/dist/adventures/source.js +11 -49
  5. package/dist/campaign/create-campaign.d.ts +1 -1
  6. package/dist/campaign/create-campaign.js +3 -2
  7. package/dist/campaign/find-campaign.d.ts +2 -0
  8. package/dist/campaign/find-campaign.js +2 -0
  9. package/dist/campaign/host-files.js +4 -1
  10. package/dist/campaign/index.d.ts +3 -2
  11. package/dist/campaign/index.js +3 -2
  12. package/dist/campaign/port.d.ts +6 -0
  13. package/dist/campaign/port.js +24 -0
  14. package/dist/campaign/settings.d.ts +17 -0
  15. package/dist/campaign/settings.js +26 -3
  16. package/dist/cli/cli.js +15 -0
  17. package/dist/commands/book.d.ts +16 -35
  18. package/dist/commands/book.js +86 -62
  19. package/dist/commands/config/config.js +16 -2
  20. package/dist/commands/config/dashboard.d.ts +6 -2
  21. package/dist/commands/config/dashboard.js +45 -8
  22. package/dist/commands/config/shown.js +4 -0
  23. package/dist/commands/config/words.d.ts +3 -1
  24. package/dist/commands/config/words.js +29 -2
  25. package/dist/commands/image.d.ts +5 -0
  26. package/dist/commands/image.js +6 -3
  27. package/dist/commands/mode.d.ts +1 -1
  28. package/dist/commands/package/data.d.ts +35 -0
  29. package/dist/commands/package/data.js +144 -0
  30. package/dist/commands/package/here.d.ts +7 -2
  31. package/dist/commands/package/here.js +23 -11
  32. package/dist/commands/package/install.js +14 -15
  33. package/dist/commands/package/language.d.ts +15 -0
  34. package/dist/commands/package/language.js +109 -0
  35. package/dist/commands/package/package.js +20 -10
  36. package/dist/commands/package/result.d.ts +19 -0
  37. package/dist/commands/package/theme.d.ts +13 -0
  38. package/dist/commands/package/theme.js +67 -0
  39. package/dist/commands/package/uninstall.d.ts +4 -1
  40. package/dist/commands/package/uninstall.js +29 -9
  41. package/dist/commands/scene/close.d.ts +1 -1
  42. package/dist/commands/scene/close.js +15 -8
  43. package/dist/commands/scene/scene.js +6 -1
  44. package/dist/commands/shared/books/adventures.d.ts +1 -4
  45. package/dist/commands/shared/books/adventures.js +3 -32
  46. package/dist/commands/shared/books/words.js +3 -2
  47. package/dist/commands/shared/campaign/book.d.ts +21 -8
  48. package/dist/commands/shared/campaign/book.js +65 -42
  49. package/dist/commands/shared/campaign/git.d.ts +25 -0
  50. package/dist/commands/shared/campaign/git.js +104 -0
  51. package/dist/commands/shared/campaign/saves.js +7 -3
  52. package/dist/commands/shared/campaign/world.js +2 -1
  53. package/dist/commands/shared/packages/catalog.d.ts +3 -3
  54. package/dist/commands/shared/packages/catalog.js +118 -43
  55. package/dist/commands/shared/packages/unpacked.d.ts +50 -0
  56. package/dist/commands/shared/packages/unpacked.js +146 -0
  57. package/dist/commands/status.d.ts +1 -0
  58. package/dist/commands/status.js +8 -4
  59. package/dist/core/archive.d.ts +13 -0
  60. package/dist/core/archive.js +76 -0
  61. package/dist/core/context.d.ts +4 -0
  62. package/dist/core/context.js +1 -0
  63. package/dist/core/store.d.ts +5 -1
  64. package/dist/core/store.js +15 -2
  65. package/dist/core/version.d.ts +2 -0
  66. package/dist/core/version.js +5 -0
  67. package/dist/dashboard/api.js +24 -1
  68. package/dist/dashboard/app.js +7 -2
  69. package/dist/dashboard/guide/ar.md +11 -9
  70. package/dist/dashboard/guide/cs.md +11 -9
  71. package/dist/dashboard/guide/da.md +12 -10
  72. package/dist/dashboard/guide/de.md +13 -11
  73. package/dist/dashboard/guide/el.md +11 -9
  74. package/dist/dashboard/guide/en.md +10 -8
  75. package/dist/dashboard/guide/es.md +11 -9
  76. package/dist/dashboard/guide/fi.md +11 -9
  77. package/dist/dashboard/guide/fr.md +11 -9
  78. package/dist/dashboard/guide/he.md +11 -9
  79. package/dist/dashboard/guide/hi.md +11 -9
  80. package/dist/dashboard/guide/hu.md +11 -9
  81. package/dist/dashboard/guide/is.md +11 -9
  82. package/dist/dashboard/guide/it.md +11 -9
  83. package/dist/dashboard/guide/ja.md +12 -10
  84. package/dist/dashboard/guide/ko.md +11 -9
  85. package/dist/dashboard/guide/nb.md +12 -10
  86. package/dist/dashboard/guide/nl.md +11 -9
  87. package/dist/dashboard/guide/pl.md +11 -9
  88. package/dist/dashboard/guide/pt.md +11 -9
  89. package/dist/dashboard/guide/ro.md +11 -9
  90. package/dist/dashboard/guide/ru.md +12 -10
  91. package/dist/dashboard/guide/sv.md +11 -9
  92. package/dist/dashboard/guide/tr.md +11 -9
  93. package/dist/dashboard/guide/uk.md +12 -10
  94. package/dist/dashboard/guide/zh.md +11 -9
  95. package/dist/dashboard/i18n/ar.json +58 -5
  96. package/dist/dashboard/i18n/cs.json +58 -5
  97. package/dist/dashboard/i18n/da.json +58 -5
  98. package/dist/dashboard/i18n/de.json +58 -5
  99. package/dist/dashboard/i18n/el.json +58 -5
  100. package/dist/dashboard/i18n/es.json +58 -5
  101. package/dist/dashboard/i18n/fi.json +58 -5
  102. package/dist/dashboard/i18n/fr.json +58 -5
  103. package/dist/dashboard/i18n/he.json +58 -5
  104. package/dist/dashboard/i18n/hi.json +58 -5
  105. package/dist/dashboard/i18n/hu.json +58 -5
  106. package/dist/dashboard/i18n/is.json +58 -5
  107. package/dist/dashboard/i18n/it.json +58 -5
  108. package/dist/dashboard/i18n/ja.json +58 -5
  109. package/dist/dashboard/i18n/ko.json +58 -5
  110. package/dist/dashboard/i18n/nb.json +58 -5
  111. package/dist/dashboard/i18n/nl.json +58 -5
  112. package/dist/dashboard/i18n/pl.json +58 -5
  113. package/dist/dashboard/i18n/pt.json +58 -5
  114. package/dist/dashboard/i18n/ro.json +58 -5
  115. package/dist/dashboard/i18n/ru.json +58 -5
  116. package/dist/dashboard/i18n/sv.json +58 -5
  117. package/dist/dashboard/i18n/tr.json +58 -5
  118. package/dist/dashboard/i18n/uk.json +58 -5
  119. package/dist/dashboard/i18n/zh.json +58 -5
  120. package/dist/dashboard/journal/book.js +3 -2
  121. package/dist/dashboard/journal/journal.js +8 -5
  122. package/dist/dashboard/kit.js +1 -1
  123. package/dist/dashboard/packages/catalog.js +31 -14
  124. package/dist/dashboard/packages/engine.js +46 -2
  125. package/dist/dashboard/packages/installed.js +13 -0
  126. package/dist/dashboard/packages/outcomes.js +21 -0
  127. package/dist/dashboard/packages/packages.js +41 -18
  128. package/dist/dashboard/packages/rows.js +3 -1
  129. package/dist/dashboard/parts/icons.js +3 -0
  130. package/dist/dashboard/parts/labels.js +7 -0
  131. package/dist/dashboard/parts/picture.js +89 -0
  132. package/dist/dashboard/parts/refusals.js +8 -1
  133. package/dist/dashboard/parts/widgets.js +2 -1
  134. package/dist/dashboard/play/scene.js +8 -5
  135. package/dist/dashboard/settings/settings.js +55 -18
  136. package/dist/dashboard/sheet/party.js +5 -2
  137. package/dist/dashboard/sheet/sheet.js +2 -1
  138. package/dist/dashboard/shell/notices.js +2 -2
  139. package/dist/dashboard/shell/system-style.js +132 -15
  140. package/dist/dashboard/shell/tooltip.js +224 -0
  141. package/dist/dashboard/style.css +497 -193
  142. package/dist/dashboard/world/lore.js +4 -3
  143. package/dist/dashboard/world/place-card.js +2 -1
  144. package/dist/git/git.d.ts +12 -0
  145. package/dist/git/git.js +175 -0
  146. package/dist/git/ignore.d.ts +2 -0
  147. package/dist/git/ignore.js +16 -0
  148. package/dist/git/index.d.ts +2 -0
  149. package/dist/git/index.js +2 -0
  150. package/dist/importer/index.d.ts +1 -1
  151. package/dist/importer/index.js +1 -1
  152. package/dist/languages/index.d.ts +1 -1
  153. package/dist/languages/index.js +1 -1
  154. package/dist/languages/pack.d.ts +4 -1
  155. package/dist/languages/pack.js +18 -6
  156. package/dist/packages/engine.d.ts +7 -0
  157. package/dist/packages/engine.js +32 -1
  158. package/dist/packages/index.d.ts +1 -1
  159. package/dist/packages/index.js +1 -1
  160. package/dist/server/bell-listener.d.ts +2 -1
  161. package/dist/server/bell-listener.js +10 -41
  162. package/dist/server/dashboard/engine.d.ts +18 -0
  163. package/dist/server/dashboard/engine.js +31 -0
  164. package/dist/server/dashboard/files.d.ts +11 -3
  165. package/dist/server/dashboard/files.js +66 -17
  166. package/dist/server/dashboard/index.d.ts +18 -2
  167. package/dist/server/dashboard/index.js +62 -23
  168. package/dist/server/dashboard/news.d.ts +3 -2
  169. package/dist/server/dashboard/news.js +19 -5
  170. package/dist/server/dashboard/pictures.d.ts +7 -0
  171. package/dist/server/dashboard/pictures.js +62 -0
  172. package/dist/server/dashboard/ports.d.ts +17 -2
  173. package/dist/server/dashboard/ports.js +60 -4
  174. package/dist/server/dashboard/writes.d.ts +5 -3
  175. package/dist/server/dashboard/writes.js +45 -14
  176. package/dist/server/mcp.d.ts +3 -2
  177. package/dist/server/mcp.js +55 -11
  178. package/dist/testing/index.js +1 -0
  179. package/dist/themes/css.d.ts +1 -1
  180. package/dist/themes/css.js +101 -2
  181. package/dist/themes/index.d.ts +2 -1
  182. package/dist/themes/index.js +4 -2
  183. package/dist/themes/installed.d.ts +14 -0
  184. package/dist/themes/installed.js +28 -0
  185. package/dist/themes/theme.d.ts +38 -0
  186. package/dist/themes/theme.js +192 -13
  187. package/instructions/core.md +4 -3
  188. package/instructions/dashboard-guide.md +2 -1
  189. package/instructions/mentor-hints.md +1 -1
  190. package/instructions/mentor-tutorial.md +1 -1
  191. package/instructions/party.md +1 -1
  192. package/instructions/play.md +2 -2
  193. package/package.json +1 -1
  194. package/systems/free/instructions/outcomes-told.md +1 -1
@@ -1,3 +1,3 @@
1
1
  export { type AdventureManifest, manifestFileName, manifestLine, readManifest, writeManifest } from "./manifest.ts";
2
2
  export { adventureFolderName, adventureTarget } from "./placement.ts";
3
- export { type AdventureFiles, isAdventureFolder, largestAdventure, packAdventure, readAdventureFolder, readAdventureZip } from "./source.ts";
3
+ export { type AdventureFiles, isAdventureFolder, largestAdventure, packAdventure, readAdventureEntries, readAdventureFolder, readAdventureZip } from "./source.ts";
@@ -2,4 +2,4 @@
2
2
  // .zip an export writes (ADV-7).
3
3
  export { manifestFileName, manifestLine, readManifest, writeManifest } from "./manifest.js";
4
4
  export { adventureFolderName, adventureTarget } from "./placement.js";
5
- export { isAdventureFolder, largestAdventure, packAdventure, readAdventureFolder, readAdventureZip } from "./source.js";
5
+ export { isAdventureFolder, largestAdventure, packAdventure, readAdventureEntries, readAdventureFolder, readAdventureZip } from "./source.js";
@@ -1,3 +1,4 @@
1
+ import { type PackageEntry } from "../core/archive.ts";
1
2
  import { type AdventureManifest } from "./manifest.ts";
2
3
  /** The folders an adventure has, as a campaign has them (D-372). */
3
4
  export declare const adventureFolders: readonly ["world", "images", "rules"];
@@ -21,3 +22,5 @@ export declare function readAdventureZip(bytes: Uint8Array, label: string): Adve
21
22
  export declare function readAdventureFolder(folder: string): AdventureFiles;
22
23
  /** The .zip of an adventure, its manifest first and its files in order of path: the same adventure gives the same bytes (ADV-7). */
23
24
  export declare function packAdventure(manifest: AdventureManifest, held: Record<string, Uint8Array>): Uint8Array;
25
+ /** The adventure from a package's files whose paths are checked, its manifest at their top (ADV-1); it throws, saying why, when it is refused. */
26
+ export declare function readAdventureEntries(label: string, inner: PackageEntry[]): AdventureFiles;
@@ -1,6 +1,7 @@
1
- import { unzipSync, zipSync } from "fflate";
1
+ import { zipSync } from "fflate";
2
2
  import { relative, sep } from "node:path";
3
- import { archivePathParts, refuseTwice } from "../core/archive-paths.js";
3
+ import { refuseTwice } from "../core/archive-paths.js";
4
+ import { packageEntries, topFile, unzipFiles } from "../core/archive.js";
4
5
  import { filesIn } from "../core/files.js";
5
6
  import { Refusal } from "../core/refusal.js";
6
7
  import { files } from "../core/store.js";
@@ -14,8 +15,6 @@ const layersFolder = "layers";
14
15
  export const largestAdventure = 512 * 1024 * 1024;
15
16
  // What each folder may hold: pages and rules are markdown, pictures as the engine shows them.
16
17
  const allowed = { world: /\.md$/i, images: /\.(png|jpg|webp|svg)$/i, rules: /\.md$/i };
17
- // What a computer leaves beside files, which no one put in the adventure.
18
- const litter = /^(\..*|__macosx|thumbs\.db|desktop\.ini)$/i;
19
18
  // The time every file of an exported zip carries, so that the same adventure gives the same bytes.
20
19
  const fixedTime = new Date(1980, 0, 1);
21
20
  /** Whether a folder of this computer is an adventure: it has a manifest. */
@@ -24,24 +23,7 @@ export function isAdventureFolder(folder) {
24
23
  }
25
24
  /** The adventure a .zip holds (ADV-1), at its top or inside one folder there, as GitHub zips a repository; it throws, saying why, when it is refused. */
26
25
  export function readAdventureZip(bytes, label) {
27
- let declared = 0;
28
- let read;
29
- try {
30
- read = unzipSync(bytes, {
31
- filter: (file) => {
32
- declared += file.originalSize;
33
- if (declared > largestAdventure) {
34
- throw new Error(`it unpacks to more than ${largestAdventure / 1024 / 1024} MB, more than an adventure may`);
35
- }
36
- return true;
37
- },
38
- });
39
- }
40
- catch (error) {
41
- throw new Refusal(`${label} is not a .zip that reads: ${error instanceof Error ? error.message : String(error)}. Nothing changed.`, "archive-unread", { name: label });
42
- }
43
- const named = Object.entries(read).filter(([name]) => !/[\\/]$/.test(name)).map(([name, data]) => [utf8Name(label, name), data]);
44
- return adventureOf(label, named);
26
+ return adventureOf(label, unzipFiles(bytes, label, largestAdventure, "an adventure"));
45
27
  }
46
28
  /** The adventure a folder of this computer holds (ADV-1); it throws, saying why, when it is refused. */
47
29
  export function readAdventureFolder(folder) {
@@ -56,33 +38,9 @@ export function packAdventure(manifest, held) {
56
38
  }
57
39
  return zipSync(ordered, { level: 6, mtime: fixedTime });
58
40
  }
59
- /**
60
- * A file's name in a .zip as it was written: one without the zip's UTF-8 mark reads byte by byte, so its UTF-8 is read again, as macOS writes it; one in an old
61
- * code page, as Windows' own tar writes it, is refused with what to do.
62
- */
63
- function utf8Name(label, name) {
64
- if (/^[\u0000-ÿ]*$/.test(name) && /[\u0080-ÿ]/.test(name)) {
65
- try {
66
- return new TextDecoder("utf-8", { fatal: true }).decode(Uint8Array.from(name, (character) => character.charCodeAt(0))).normalize("NFC");
67
- }
68
- catch {
69
- // Not UTF-8 byte by byte: a name the zip marked as UTF-8 already, or one in an old code page.
70
- }
71
- }
72
- if (/[\u0080-\u009f]/.test(name)) {
73
- throw new Refusal(`${label} names a file with accents not written in UTF-8 (${name}): make the zip again with 7-Zip, or Compress-Archive in PowerShell. Nothing changed.`, "archive-accents", { name: label });
74
- }
75
- return name.normalize("NFC");
76
- }
77
- /** The adventure from a package's files: its paths checked, the one folder at its top that holds it all taken away, and what it may hold kept. */
78
- function adventureOf(label, entries) {
79
- // What a computer leaves beside the files, as macOS's __MACOSX, goes before the folder at the top is looked for.
80
- const checked = entries.map(([name, data]) => [archivePathParts(label, name, "the adventure"), data])
81
- .filter(([parts]) => parts.length > 0 && !parts.some((part) => litter.test(part)));
82
- const atTop = checked.some(([parts]) => parts.length === 1 && parts[0].toLowerCase() === manifestFileName);
83
- const tops = new Set(checked.map(([parts]) => parts[0]));
84
- const inner = !atTop && tops.size === 1 ? checked.map(([parts, data]) => [parts.slice(1), data]).filter(([parts]) => parts.length > 0) : checked;
85
- const manifest = inner.find(([parts]) => parts.length === 1 && parts[0].toLowerCase() === manifestFileName);
41
+ /** The adventure from a package's files whose paths are checked, its manifest at their top (ADV-1); it throws, saying why, when it is refused. */
42
+ export function readAdventureEntries(label, inner) {
43
+ const manifest = topFile(inner, manifestFileName);
86
44
  if (manifest === undefined) {
87
45
  throw new Refusal(`${label} has no ${manifestFileName} at its top: it is not an adventure. A document or a folder of notes is imported by the master, who writes its pages. Nothing changed.`, "not-adventure", { name: label });
88
46
  }
@@ -121,6 +79,10 @@ function adventureOf(label, entries) {
121
79
  refuseTwice(label, layerPaths);
122
80
  return { manifest: read, files: held, layers, ignored: [...ignored].sort() };
123
81
  }
82
+ /** The adventure from a package's files: its paths checked, the one folder at its top that holds it all taken away, and what it may hold kept. */
83
+ function adventureOf(label, entries) {
84
+ return readAdventureEntries(label, packageEntries(label, entries, "the adventure", [manifestFileName]));
85
+ }
124
86
  /**
125
87
  * Where a file under layers/ lies over the pages of the game system (ADV-8): only in layers/<the system the adventure needs>/world/, in markdown. Another folder
126
88
  * there, a file of another kind, or layers in an adventure that needs no system refuse it whole.
@@ -1,7 +1,7 @@
1
1
  import { type HostInstructions } from "./host-files.ts";
2
2
  import { type CampaignSettings } from "./settings.ts";
3
3
  /**
4
- * Creates a campaign in `folder`: campaign.yaml, state.yaml, the sessions folder, the .mcp.json through which AI hosts such as Claude Code find the rpg tools,
4
+ * Creates a campaign in `folder`: campaign.yaml, state.yaml, the sessions folder, the inbox for the player's pictures, the .mcp.json through which AI hosts such as Claude Code find the rpg tools,
5
5
  * and the host files that send them to the start lines and give Claude Code the character agent (D-97, D-242, D-490). `platform` is the operating system, as Node names it. Returns the campaign's full path.
6
6
  */
7
7
  export declare function createCampaign(folder: string, settings: CampaignSettings, platform: string, instructions: HostInstructions): string;
@@ -3,11 +3,11 @@ import { join, resolve } from "node:path";
3
3
  import { stringify } from "yaml";
4
4
  import { z } from "zod";
5
5
  import { files } from "../core/store.js";
6
- import { campaignFileName, findCampaign, sessionsFolderName } from "./find-campaign.js";
6
+ import { campaignFileName, findCampaign, inboxFolderName, sessionsFolderName } from "./find-campaign.js";
7
7
  import { hostFileChanges, rpgServer, writeHostFile } from "./host-files.js";
8
8
  import { settingsSchema } from "./settings.js";
9
9
  /**
10
- * Creates a campaign in `folder`: campaign.yaml, state.yaml, the sessions folder, the .mcp.json through which AI hosts such as Claude Code find the rpg tools,
10
+ * Creates a campaign in `folder`: campaign.yaml, state.yaml, the sessions folder, the inbox for the player's pictures, the .mcp.json through which AI hosts such as Claude Code find the rpg tools,
11
11
  * and the host files that send them to the start lines and give Claude Code the character agent (D-97, D-242, D-490). `platform` is the operating system, as Node names it. Returns the campaign's full path.
12
12
  */
13
13
  export function createCampaign(folder, settings, platform, instructions) {
@@ -20,6 +20,7 @@ export function createCampaign(folder, settings, platform, instructions) {
20
20
  const mcpConfig = mcpConfigWithRpg(root, platform);
21
21
  const hostFiles = hostFileChanges(root, instructions, platform);
22
22
  files().makeFolder(join(root, sessionsFolderName));
23
+ files().makeFolder(join(root, inboxFolderName));
23
24
  files().write(join(root, campaignFileName), `# Campaign settings: change them with the config command.\n${stringify(parsed.data)}`);
24
25
  // A new campaign starts in setup (MOD-1).
25
26
  files().write(join(root, "state.yaml"), "# The present of the game, kept by rpg: mode, date and current scene.\nmode: setup\n");
@@ -4,6 +4,8 @@ export declare const campaignFileName = "campaign.yaml";
4
4
  export declare const houseRulesFolderName = "rules";
5
5
  /** The folder of a campaign with its chats as text, copied from the AI hosts as they go on, kept out of the saves (T-225). */
6
6
  export declare const sessionsFolderName = "sessions";
7
+ /** The folder of a campaign where the player drops pictures of their own, which the master gives to pages with image (D-572 (3)); kept out of the saves. */
8
+ export declare const inboxFolderName = "inbox";
7
9
  /** The folder of a campaign with its story told as a book, a chapter for each closed scene, kept out of the saves (T-227). */
8
10
  export declare const bookFolderName = "book";
9
11
  /** The campaign that holds `folder`: the nearest folder, from `folder` upwards, with a campaign.yaml. */
@@ -6,6 +6,8 @@ export const campaignFileName = "campaign.yaml";
6
6
  export const houseRulesFolderName = "rules";
7
7
  /** The folder of a campaign with its chats as text, copied from the AI hosts as they go on, kept out of the saves (T-225). */
8
8
  export const sessionsFolderName = "sessions";
9
+ /** The folder of a campaign where the player drops pictures of their own, which the master gives to pages with image (D-572 (3)); kept out of the saves. */
10
+ export const inboxFolderName = "inbox";
9
11
  /** The folder of a campaign with its story told as a book, a chapter for each closed scene, kept out of the saves (T-227). */
10
12
  export const bookFolderName = "book";
11
13
  /** The campaign that holds `folder`: the nearest folder, from `folder` upwards, with a campaign.yaml. */
@@ -202,7 +202,10 @@ function codexConfigFile(root, platform, effort = chosenEffort(root)) {
202
202
  const text = effort === undefined ? hidden : withTopKey(hidden, "model_reasoning_effort", effort === "app" ? undefined : JSON.stringify(effort));
203
203
  const server = rpgServer(platform);
204
204
  const tables = [
205
- ["mcp_servers.rpg", `command = ${JSON.stringify(server.command)}\nargs = [${server.args.map((arg) => JSON.stringify(arg)).join(", ")}]\ntool_timeout_sec = 1800\ndefault_tools_approval_mode = "approve"\nenv_vars = ["CODEX_HOME"]`],
205
+ [
206
+ "mcp_servers.rpg",
207
+ `command = ${JSON.stringify(server.command)}\nargs = [${server.args.map((arg) => JSON.stringify(arg)).join(", ")}]\ntool_timeout_sec = 1800\ndefault_tools_approval_mode = "approve"\nenv_vars = ["CODEX_HOME", "SSH_AUTH_SOCK", "HTTPS_PROXY", "HTTP_PROXY", "NO_PROXY", "https_proxy", "http_proxy", "no_proxy"]`,
208
+ ],
206
209
  ["memories", "generate_memories = false\nuse_memories = false"],
207
210
  ];
208
211
  // A table's header with a comment after it is that table all the same.
@@ -1,8 +1,9 @@
1
1
  export { type ChoiceItem, type ChoiceSet, type PickRange, pickText, readChoices, readPick, writeChoices } from "./choices.ts";
2
2
  export { createCampaign } from "./create-campaign.ts";
3
- export { bookFolderName, campaignFileName, findCampaign, houseRulesFolderName, requireCampaign, sessionsFolderName } from "./find-campaign.ts";
3
+ export { bookFolderName, campaignFileName, findCampaign, houseRulesFolderName, inboxFolderName, requireCampaign, sessionsFolderName } from "./find-campaign.ts";
4
4
  export { hasCharacterAgent, hostFileNames, refreshHostFiles, writeEffortFiles } from "./host-files.ts";
5
5
  export { lastChoices, rememberChoice, rememberedSettings } from "./last-choices.ts";
6
6
  export { type CountedByGame, customLevel, customLevels, customSettings, difficulties, difficultyItems, itemMeaning, leveled, type LeveledSetting, rigorItems, rigors, startingLevels } from "./levels.ts";
7
- export { type CampaignSettings, changeExtensions, changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, characterWays, checkSettingName, checkSettings, chosenPictureMaker, clearSetting, closedSettings, companionWays, diceWays, efforts, entrySettingNames, lengths, lethalities, listLimits, listSettingNames, mapSettingNames, masterRollWays, mentorWays, missingSettings, pictureMakers, pictureWays, preparations, proseWays, readCampaignData, readListSetting, readOneSetting, readSettings, readTextSetting, saveModes, settingDescription, settingMeaning, type SettingName, settingNames, setupSettingNames, storyWays, styleTextLengths, unansweredSettings, unitSystems, voiceWays, } from "./settings.ts";
7
+ export { portFileName, savedPort, savePort } from "./port.ts";
8
+ export { type CampaignSettings, changeExtensions, changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, characterWays, checkSettingName, checkSettings, chosenPictureMaker, clearSetting, closedSettings, companionWays, diceWays, efforts, entrySettingNames, gitIncludeWays, gitWays, lengths, lethalities, listLimits, listSettingNames, mapSettingNames, masterRollWays, mentorWays, missingSettings, pictureMakers, pictureWays, preparations, proseWays, readCampaignData, readListSetting, readOneSetting, readSettings, readTextSetting, saveModes, settingDescription, settingMeaning, type SettingName, settingNames, setupSettingNames, storyWays, styleTextLengths, unansweredSettings, unitSystems, voiceWays, } from "./settings.ts";
8
9
  export { type CampaignState, changeState, changeStateAt, readState, readStateValues } from "./state.ts";
@@ -1,9 +1,10 @@
1
1
  // The campaign: a folder with campaign.yaml, its settings, the present, the sessions and the files an AI host reads.
2
2
  export { pickText, readChoices, readPick, writeChoices } from "./choices.js";
3
3
  export { createCampaign } from "./create-campaign.js";
4
- export { bookFolderName, campaignFileName, findCampaign, houseRulesFolderName, requireCampaign, sessionsFolderName } from "./find-campaign.js";
4
+ export { bookFolderName, campaignFileName, findCampaign, houseRulesFolderName, inboxFolderName, requireCampaign, sessionsFolderName } from "./find-campaign.js";
5
5
  export { hasCharacterAgent, hostFileNames, refreshHostFiles, writeEffortFiles } from "./host-files.js";
6
6
  export { lastChoices, rememberChoice, rememberedSettings } from "./last-choices.js";
7
7
  export { customLevel, customLevels, customSettings, difficulties, difficultyItems, itemMeaning, leveled, rigorItems, rigors, startingLevels } from "./levels.js";
8
- export { changeExtensions, changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, characterWays, checkSettingName, checkSettings, chosenPictureMaker, clearSetting, closedSettings, companionWays, diceWays, efforts, entrySettingNames, lengths, lethalities, listLimits, listSettingNames, mapSettingNames, masterRollWays, mentorWays, missingSettings, pictureMakers, pictureWays, preparations, proseWays, readCampaignData, readListSetting, readOneSetting, readSettings, readTextSetting, saveModes, settingDescription, settingMeaning, settingNames, setupSettingNames, storyWays, styleTextLengths, unansweredSettings, unitSystems, voiceWays, } from "./settings.js";
8
+ export { portFileName, savedPort, savePort } from "./port.js";
9
+ export { changeExtensions, changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, characterWays, checkSettingName, checkSettings, chosenPictureMaker, clearSetting, closedSettings, companionWays, diceWays, efforts, entrySettingNames, gitIncludeWays, gitWays, lengths, lethalities, listLimits, listSettingNames, mapSettingNames, masterRollWays, mentorWays, missingSettings, pictureMakers, pictureWays, preparations, proseWays, readCampaignData, readListSetting, readOneSetting, readSettings, readTextSetting, saveModes, settingDescription, settingMeaning, settingNames, setupSettingNames, storyWays, styleTextLengths, unansweredSettings, unitSystems, voiceWays, } from "./settings.js";
9
10
  export { changeState, changeStateAt, readState, readStateValues } from "./state.js";
@@ -0,0 +1,6 @@
1
+ /** The file that keeps the port of the campaign's page, in its folder: this computer's, which the engine's .gitignore leaves out. */
2
+ export declare const portFileName = ".dashboard-port";
3
+ /** The port kept for the campaign's page; undefined when none is, or one that is no port. */
4
+ export declare function savedPort(root: string): number | undefined;
5
+ /** Keeps the port of the campaign's page; nothing when it cannot be written, as the page works all the same and the next chat chooses again. */
6
+ export declare function savePort(root: string, port: number): void;
@@ -0,0 +1,24 @@
1
+ // The port of the campaign's page on this computer (D-577): chosen once, kept in a file of the campaign's own that git leaves out, so that it moves with
2
+ // the folder and never to another computer, and changed only when another program or campaign holds it.
3
+ import { join } from "node:path";
4
+ import { files } from "../core/store.js";
5
+ /** The file that keeps the port of the campaign's page, in its folder: this computer's, which the engine's .gitignore leaves out. */
6
+ export const portFileName = ".dashboard-port";
7
+ /** The port kept for the campaign's page; undefined when none is, or one that is no port. */
8
+ export function savedPort(root) {
9
+ const text = files().text(join(root, portFileName))?.trim() ?? "";
10
+ const port = /^\d+$/.test(text) ? Number(text) : Number.NaN;
11
+ return Number.isInteger(port) && port > 0 && port < 65536 ? port : undefined;
12
+ }
13
+ /** Keeps the port of the campaign's page; nothing when it cannot be written, as the page works all the same and the next chat chooses again. */
14
+ export function savePort(root, port) {
15
+ if (savedPort(root) === port) {
16
+ return;
17
+ }
18
+ try {
19
+ files().write(join(root, portFileName), `${port}\n`);
20
+ }
21
+ catch {
22
+ // A folder that cannot be written keeps no port.
23
+ }
24
+ }
@@ -6,6 +6,10 @@ import { type CountedByGame } from "./levels.ts";
6
6
  export declare const lethalities: readonly ["narrative", "epic", "dice"];
7
7
  /** When the game may go back (D-55): never, to the last end of a scene once the player character dies, or to any save, which the player may also ask for. */
8
8
  export declare const saveModes: readonly ["permadeath", "checkpoint", "free"];
9
+ /** What the engine does with git in a campaign that is a repository (D-576): nothing, a commit at each session's start, save and end of a scene, or a push too. */
10
+ export declare const gitWays: readonly ["off", "commit", "push"];
11
+ /** Whether the saves or the chats go into the campaign's repository (D-576): left out, as when unset, or in. */
12
+ export declare const gitIncludeWays: readonly ["out", "in"];
9
13
  /**
10
14
  * What the chosen difficulty, rigor or mentor means, as status and config give it, the rigor with what the game counts itself, a custom one with the levels of
11
15
  * its items as custom-difficulty or custom-rigor writes them (T-132); undefined for another setting or a value it does not take.
@@ -242,6 +246,19 @@ export declare const settingsSchema: z.ZodObject<{
242
246
  precedents: z.ZodOptional<z.ZodNullable<z.ZodPreprocess<z.ZodArray<z.ZodPreprocess<z.ZodString, unknown>>, unknown>>>;
243
247
  learned: z.ZodOptional<z.ZodNullable<z.ZodPreprocess<z.ZodArray<z.ZodPreprocess<z.ZodString, unknown>>, unknown>>>;
244
248
  library: z.ZodOptional<z.ZodNullable<z.ZodPreprocess<z.ZodArray<z.ZodPreprocess<z.ZodString, unknown>>, unknown>>>;
249
+ git: z.ZodOptional<z.ZodEnum<{
250
+ push: "push";
251
+ off: "off";
252
+ commit: "commit";
253
+ }>>;
254
+ "git-saves": z.ZodOptional<z.ZodEnum<{
255
+ out: "out";
256
+ in: "in";
257
+ }>>;
258
+ "git-sessions": z.ZodOptional<z.ZodEnum<{
259
+ out: "out";
260
+ in: "in";
261
+ }>>;
245
262
  coins: z.ZodOptional<z.ZodUnknown>;
246
263
  calendar: z.ZodOptional<z.ZodUnknown>;
247
264
  fields: z.ZodOptional<z.ZodUnknown>;
@@ -12,6 +12,10 @@ const settingsHold = 'settings, such as "name: ..."';
12
12
  export const lethalities = ["narrative", "epic", "dice"];
13
13
  /** When the game may go back (D-55): never, to the last end of a scene once the player character dies, or to any save, which the player may also ask for. */
14
14
  export const saveModes = ["permadeath", "checkpoint", "free"];
15
+ /** What the engine does with git in a campaign that is a repository (D-576): nothing, a commit at each session's start, save and end of a scene, or a push too. */
16
+ export const gitWays = ["off", "commit", "push"];
17
+ /** Whether the saves or the chats go into the campaign's repository (D-576): left out, as when unset, or in. */
18
+ export const gitIncludeWays = ["out", "in"];
15
19
  /**
16
20
  * What the chosen difficulty, rigor or mentor means, as status and config give it, the rigor with what the game counts itself, a custom one with the levels of
17
21
  * its items as custom-difficulty or custom-rigor writes them (T-132); undefined for another setting or a value it does not take.
@@ -258,8 +262,8 @@ export function checkSettingName(name) {
258
262
  export const mentorWays = ["off", "hints", "tutorial"];
259
263
  /** What each way of the mentor means to the master, which config gives for the chosen one, and the player's change of it on the dashboard (D-347). */
260
264
  const mentorMeanings = {
261
- off: "the story alone: no tips or explanations of yours, only your answers to what the player asks between brackets",
262
- hints: "a tip of a sentence or two, in brackets, before a choice that matters and when a rule slips by, as the mentor's part of your instructions says; no lessons",
265
+ off: "the story alone: no tips or explanations of yours, only your answers to what the player asks in [OOC: …]",
266
+ hints: "a tip of a sentence or two, in [OOC: …], before a choice that matters and when a rule slips by, as the mentor's part of your instructions says; no lessons",
263
267
  tutorial: "each mechanic explained the first time it comes up, the whole sum of a roll shown, a debrief after fights and at the end of a session, "
264
268
  + "as the mentor's part of your instructions says",
265
269
  };
@@ -404,6 +408,10 @@ export const settingsSchema = z.object({
404
408
  precedents: listSetting.describe("the rulings made without the text, each starting with the name of the rule in the system's language: Poisoned: …"),
405
409
  learned: listSetting.describe("the game's mechanics the master has explained, by their names in the system's language: explained again only when the player gets one wrong"),
406
410
  library: listSetting.describe("the player's library (D-491): folders of their books, or books, by full path, which rules searches after the game system"),
411
+ git: z.enum(gitWays).optional().describe("what rpg does with git where the campaign's folder is a repository: off (unset, nothing), commit (a commit at the start of each session, at each save and each end of a scene) "
412
+ + "or push (a commit, then a push)"),
413
+ "git-saves": z.enum(gitIncludeWays).optional().describe("whether the saves' zips go into the campaign's repository: out (unset) or in"),
414
+ "git-sessions": z.enum(gitIncludeWays).optional().describe("whether the chats kept as text, all the player wrote, go into the campaign's repository: out (unset) or in, for a private one"),
407
415
  // Checked by the money module (MON-1): coins written wrongly by hand must not stop the other settings from being read.
408
416
  coins: z.unknown().optional().describe("the coins, for a game with money: each with its value in the smallest coin, such as gp 100, sp 10, cp 1"),
409
417
  // Checked by the time module (TIM-8): a mistake there never stops the game, whose date stays day N.
@@ -443,7 +451,22 @@ const premiseSettingNames = ["premise", "preparation", "length"];
443
451
  // The pictures: the setup asks them; in a campaign made before, status asks for them once, only where they can be made (D-308, D-572).
444
452
  // How the master writes: the core's own until the player chooses (D-395).
445
453
  const styleSettingNames = ["prose", "story", "author", "style"];
446
- const optionalSettingNames = ["coins", "pictures", "effort", "voices", "calendar", "calendar-start", "between-sessions", ...entrySettingNames, ...setupSettingNames, ...premiseSettingNames, ...styleSettingNames];
454
+ const optionalSettingNames = [
455
+ "coins",
456
+ "pictures",
457
+ "effort",
458
+ "voices",
459
+ "calendar",
460
+ "calendar-start",
461
+ "between-sessions",
462
+ "git",
463
+ "git-saves",
464
+ "git-sessions",
465
+ ...entrySettingNames,
466
+ ...setupSettingNames,
467
+ ...premiseSettingNames,
468
+ ...styleSettingNames,
469
+ ];
447
470
  /** The YAML list of a list setting, edited in place so that its comments stay; created when missing. */
448
471
  function listNode(document, setting) {
449
472
  const node = document.get(setting, true);
package/dist/cli/cli.js CHANGED
@@ -30,4 +30,19 @@ else {
30
30
  console.error(output);
31
31
  }
32
32
  process.exitCode = exitCode;
33
+ await waitForGit();
34
+ }
35
+ /** The commit a command started, and its push, which the process waits for anyway: said, then what went wrong, if anything (D-576). */
36
+ async function waitForGit() {
37
+ const { gitProblem, gitUnderWay } = await import("../commands/shared/campaign/git.js");
38
+ for (const { root, pushes, done } of gitUnderWay()) {
39
+ if (pushes) {
40
+ console.error("Pushing the campaign to git…");
41
+ }
42
+ await done;
43
+ const problem = gitProblem(root);
44
+ if (problem !== undefined) {
45
+ console.error(`git: the ${problem.act} failed: ${problem.why}`);
46
+ }
47
+ }
33
48
  }
@@ -1,55 +1,36 @@
1
1
  import { z } from "zod";
2
- import { type SceneChapter } from "./shared/campaign/book.ts";
2
+ import { type StoryScene } from "./shared/campaign/book.ts";
3
3
  export declare const book: import("../core/registry.ts").Command<z.ZodObject<{
4
4
  chapter: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
5
5
  title: z.ZodOptional<z.ZodString>;
6
6
  text: z.ZodOptional<z.ZodString>;
7
+ through: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
7
8
  }, z.core.$strip>, {
9
+ kind: "written";
10
+ number: number;
11
+ title: string;
12
+ scenes: StoryScene[];
13
+ words: number;
14
+ untold: number;
15
+ } | {
8
16
  kind: "list";
9
17
  written: number;
10
- closed: number;
11
- missing: SceneChapter[];
18
+ untold: StoryScene[];
12
19
  craft: string | undefined;
13
- scene?: undefined;
14
20
  chapter?: undefined;
15
- had?: undefined;
16
- title?: undefined;
17
- words?: undefined;
18
- left?: undefined;
21
+ number?: undefined;
19
22
  } | {
20
23
  kind: "read";
21
- scene: SceneChapter;
22
- chapter: import("./shared/campaign/book.ts").BookChapter | undefined;
24
+ chapter: import("./shared/campaign/book.ts").WrittenChapter;
23
25
  craft: string | undefined;
24
26
  written?: undefined;
25
- closed?: undefined;
26
- missing?: undefined;
27
- had?: undefined;
28
- title?: undefined;
29
- words?: undefined;
30
- left?: undefined;
27
+ untold?: undefined;
28
+ number?: undefined;
31
29
  } | {
32
30
  kind: "removed";
33
- scene: SceneChapter;
34
- had: boolean;
35
- written?: undefined;
36
- closed?: undefined;
37
- missing?: undefined;
38
- craft?: undefined;
39
- chapter?: undefined;
40
- title?: undefined;
41
- words?: undefined;
42
- left?: undefined;
43
- } | {
44
- kind: "written";
45
- scene: SceneChapter;
46
- title: string;
47
- words: number;
48
- left: number[];
31
+ number: number;
49
32
  written?: undefined;
50
- closed?: undefined;
51
- missing?: undefined;
33
+ untold?: undefined;
52
34
  craft?: undefined;
53
35
  chapter?: undefined;
54
- had?: undefined;
55
36
  }>;