rpg-engine 0.5.0 → 0.6.1

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 (218) hide show
  1. package/dist/campaign/settings.d.ts +1 -0
  2. package/dist/campaign/settings.js +6 -5
  3. package/dist/command-line.js +12 -5
  4. package/dist/commands/advance.js +1 -1
  5. package/dist/commands/ask.d.ts +1 -1
  6. package/dist/commands/ask.js +66 -24
  7. package/dist/commands/change.js +28 -17
  8. package/dist/commands/config.d.ts +1 -1
  9. package/dist/commands/config.js +67 -21
  10. package/dist/commands/effect.js +42 -23
  11. package/dist/commands/find.js +1 -1
  12. package/dist/commands/game-adventures.js +2 -2
  13. package/dist/commands/game-catalog.d.ts +13 -0
  14. package/dist/commands/game-catalog.js +26 -2
  15. package/dist/commands/game-checks.js +23 -21
  16. package/dist/commands/{game-hit-dice.d.ts → game-dice-pool.d.ts} +3 -3
  17. package/dist/commands/{game-hit-dice.js → game-dice-pool.js} +7 -7
  18. package/dist/commands/game-effects.d.ts +12 -4
  19. package/dist/commands/game-effects.js +21 -13
  20. package/dist/commands/game-examples.d.ts +22 -0
  21. package/dist/commands/game-examples.js +72 -0
  22. package/dist/commands/game-extension-list.d.ts +31 -3
  23. package/dist/commands/game-extension-list.js +83 -7
  24. package/dist/commands/game-images.d.ts +1 -1
  25. package/dist/commands/game-images.js +3 -2
  26. package/dist/commands/game-library.d.ts +3 -0
  27. package/dist/commands/game-library.js +2 -2
  28. package/dist/commands/game-mode.js +1 -1
  29. package/dist/commands/game-package-code.d.ts +87 -0
  30. package/dist/commands/game-package-code.js +648 -0
  31. package/dist/commands/game-package-hooks.d.ts +37 -0
  32. package/dist/commands/game-package-hooks.js +116 -0
  33. package/dist/commands/game-recipes.js +2 -2
  34. package/dist/commands/game-reminders.d.ts +5 -2
  35. package/dist/commands/game-reminders.js +7 -4
  36. package/dist/commands/game-rules.d.ts +4 -1
  37. package/dist/commands/game-rules.js +7 -1
  38. package/dist/commands/game-upkeep.js +3 -3
  39. package/dist/commands/game-view-place.d.ts +8 -20
  40. package/dist/commands/game-view-place.js +16 -35
  41. package/dist/commands/game-widgets.d.ts +39 -10
  42. package/dist/commands/game-widgets.js +138 -35
  43. package/dist/commands/game-world.d.ts +17 -0
  44. package/dist/commands/game-world.js +70 -12
  45. package/dist/commands/image.js +1 -1
  46. package/dist/commands/init.js +2 -2
  47. package/dist/commands/mode.d.ts +1 -1
  48. package/dist/commands/package.d.ts +8 -0
  49. package/dist/commands/package.js +81 -24
  50. package/dist/commands/progression.d.ts +2 -0
  51. package/dist/commands/progression.js +7 -2
  52. package/dist/commands/roll.d.ts +2 -0
  53. package/dist/commands/roll.js +50 -24
  54. package/dist/commands/rules.js +6 -4
  55. package/dist/commands/scene.d.ts +1 -1
  56. package/dist/commands/scene.js +13 -10
  57. package/dist/commands/sheet.js +10 -1
  58. package/dist/commands/status.d.ts +1 -0
  59. package/dist/commands/status.js +14 -4
  60. package/dist/commands/trade.js +6 -4
  61. package/dist/commands/translate.js +2 -2
  62. package/dist/commands/travel.js +1 -1
  63. package/dist/commands/validate.js +2 -2
  64. package/dist/commands/view.d.ts +8 -4
  65. package/dist/commands/view.js +7 -6
  66. package/dist/commands/worked-out.js +11 -5
  67. package/dist/commands/write.d.ts +8 -1
  68. package/dist/commands/write.js +84 -25
  69. package/dist/core/command-reference.js +3 -2
  70. package/dist/core/consents.d.ts +18 -0
  71. package/dist/core/consents.js +93 -0
  72. package/dist/core/context.d.ts +51 -29
  73. package/dist/core/context.js +3 -1
  74. package/dist/core/examples.d.ts +25 -0
  75. package/dist/core/examples.js +19 -0
  76. package/dist/{extensions/api.d.ts → core/package-api.d.ts} +134 -32
  77. package/dist/core/package-declarations.d.ts +102 -0
  78. package/dist/core/package-declarations.js +81 -0
  79. package/dist/core/registry.d.ts +2 -0
  80. package/dist/core/text.d.ts +5 -0
  81. package/dist/core/text.js +12 -0
  82. package/dist/dashboard/acts.js +31 -24
  83. package/dist/dashboard/address.js +4 -1
  84. package/dist/dashboard/api.js +54 -0
  85. package/dist/dashboard/app.js +140 -96
  86. package/dist/dashboard/ask-card.js +76 -25
  87. package/dist/dashboard/asked-dice.js +57 -0
  88. package/dist/dashboard/dice/tray.js +3 -3
  89. package/dist/dashboard/extension-widgets.js +104 -10
  90. package/dist/dashboard/i18n/ar.json +25 -29
  91. package/dist/dashboard/i18n/cs.json +25 -29
  92. package/dist/dashboard/i18n/da.json +25 -29
  93. package/dist/dashboard/i18n/de.json +25 -29
  94. package/dist/dashboard/i18n/el.json +25 -29
  95. package/dist/dashboard/i18n/es.json +25 -29
  96. package/dist/dashboard/i18n/fi.json +25 -29
  97. package/dist/dashboard/i18n/fr.json +25 -29
  98. package/dist/dashboard/i18n/he.json +25 -29
  99. package/dist/dashboard/i18n/hi.json +25 -29
  100. package/dist/dashboard/i18n/hu.json +25 -29
  101. package/dist/dashboard/i18n/is.json +25 -29
  102. package/dist/dashboard/i18n/it.json +25 -29
  103. package/dist/dashboard/i18n/ja.json +25 -29
  104. package/dist/dashboard/i18n/ko.json +25 -29
  105. package/dist/dashboard/i18n/nb.json +25 -29
  106. package/dist/dashboard/i18n/nl.json +25 -29
  107. package/dist/dashboard/i18n/pl.json +25 -29
  108. package/dist/dashboard/i18n/pt.json +25 -29
  109. package/dist/dashboard/i18n/ro.json +25 -29
  110. package/dist/dashboard/i18n/ru.json +25 -29
  111. package/dist/dashboard/i18n/sv.json +25 -29
  112. package/dist/dashboard/i18n/tr.json +25 -29
  113. package/dist/dashboard/i18n/uk.json +25 -29
  114. package/dist/dashboard/i18n/zh.json +25 -29
  115. package/dist/dashboard/icons.js +4 -1
  116. package/dist/dashboard/kit.js +35 -0
  117. package/dist/dashboard/labels.js +1 -0
  118. package/dist/dashboard/pack-card.js +7 -2
  119. package/dist/dashboard/package-page.js +50 -0
  120. package/dist/dashboard/packages.js +172 -23
  121. package/dist/dashboard/page-code.js +248 -0
  122. package/dist/dashboard/party.js +13 -14
  123. package/dist/dashboard/people.js +4 -0
  124. package/dist/dashboard/person-panel.js +110 -0
  125. package/dist/dashboard/place-map-view.js +11 -6
  126. package/dist/dashboard/scene.js +12 -9
  127. package/dist/dashboard/settings.js +55 -9
  128. package/dist/dashboard/sheet.js +21 -13
  129. package/dist/dashboard/status.js +69 -15
  130. package/dist/dashboard/style.css +592 -825
  131. package/dist/dashboard/top.js +75 -25
  132. package/dist/dashboard/turns.js +34 -13
  133. package/dist/dashboard/widgets.js +9 -2
  134. package/dist/dashboard-server.js +189 -10
  135. package/dist/dice/roll-dice.js +1 -1
  136. package/dist/effects/effect.d.ts +7 -4
  137. package/dist/effects/effect.js +12 -9
  138. package/dist/extensions/engine.d.ts +4 -0
  139. package/dist/extensions/engine.js +74 -0
  140. package/dist/extensions/extension.d.ts +25 -37
  141. package/dist/extensions/extension.js +26 -48
  142. package/dist/extensions/index.d.ts +3 -2
  143. package/dist/extensions/index.js +4 -1
  144. package/dist/extensions/packages.d.ts +6 -0
  145. package/dist/extensions/packages.js +100 -11
  146. package/dist/index.d.ts +1 -3
  147. package/dist/mcp-server.js +51 -14
  148. package/dist/page-words.d.ts +4 -0
  149. package/dist/page-words.js +4 -4
  150. package/dist/page.d.ts +218 -0
  151. package/dist/page.js +2 -0
  152. package/dist/pages/load.d.ts +7 -1
  153. package/dist/pages/load.js +10 -5
  154. package/dist/pages/page-file.js +1 -1
  155. package/dist/pages/stack-writes.js +5 -4
  156. package/dist/pages/world.d.ts +8 -0
  157. package/dist/pages/world.js +9 -2
  158. package/dist/systems/game-system.d.ts +52 -26
  159. package/dist/systems/game-system.js +141 -42
  160. package/dist/systems/index.d.ts +3 -3
  161. package/dist/systems/index.js +3 -3
  162. package/dist/systems/system-code.d.ts +29 -88
  163. package/dist/systems/system-code.js +68 -23
  164. package/dist/systems/words.d.ts +2 -0
  165. package/dist/systems/words.js +11 -0
  166. package/dist/testing.d.ts +20 -5
  167. package/dist/testing.js +49 -14
  168. package/instructions/combat.md +2 -2
  169. package/instructions/core.md +2 -2
  170. package/instructions/dashboard.md +2 -2
  171. package/instructions/mentor-tutorial.md +1 -1
  172. package/instructions/play.md +3 -3
  173. package/instructions/setup.md +1 -1
  174. package/package.json +10 -2
  175. package/systems/5e/LICENSE.md +13 -3
  176. package/systems/5e/dist/dying.js +83 -16
  177. package/systems/5e/dist/index.js +2 -2
  178. package/systems/5e/dist/page-style.js +634 -0
  179. package/systems/5e/dist/page.js +166 -0
  180. package/systems/5e/dist/shown.js +23 -0
  181. package/systems/5e/instructions/combat.md +1 -0
  182. package/systems/5e/package.json +4 -2
  183. package/systems/5e/system.yaml +37 -9
  184. package/systems/5e/versions/srd-5.1/system.yaml +2 -0
  185. package/systems/5e/words/ar.yaml +30 -0
  186. package/systems/5e/words/cs.yaml +30 -0
  187. package/systems/5e/words/da.yaml +30 -0
  188. package/systems/5e/words/de.yaml +30 -0
  189. package/systems/5e/words/el.yaml +30 -0
  190. package/systems/5e/words/es.yaml +30 -0
  191. package/systems/5e/words/fi.yaml +30 -0
  192. package/systems/5e/words/fr.yaml +30 -0
  193. package/systems/5e/words/he.yaml +30 -0
  194. package/systems/5e/words/hi.yaml +30 -0
  195. package/systems/5e/words/hu.yaml +30 -0
  196. package/systems/5e/words/is.yaml +30 -0
  197. package/systems/5e/words/it.yaml +30 -0
  198. package/systems/5e/words/ja.yaml +30 -0
  199. package/systems/5e/words/ko.yaml +30 -0
  200. package/systems/5e/words/nb.yaml +30 -0
  201. package/systems/5e/words/nl.yaml +30 -0
  202. package/systems/5e/words/pl.yaml +30 -0
  203. package/systems/5e/words/pt.yaml +30 -0
  204. package/systems/5e/words/ro.yaml +30 -0
  205. package/systems/5e/words/ru.yaml +30 -0
  206. package/systems/5e/words/sv.yaml +30 -0
  207. package/systems/5e/words/tr.yaml +30 -0
  208. package/systems/5e/words/uk.yaml +30 -0
  209. package/systems/5e/words/zh.yaml +30 -0
  210. package/dist/commands/game-extensions.d.ts +0 -34
  211. package/dist/commands/game-extensions.js +0 -407
  212. package/dist/commands/game-system-code.d.ts +0 -33
  213. package/dist/commands/game-system-code.js +0 -188
  214. package/dist/dashboard/death-save.js +0 -67
  215. package/dist/dashboard/dying.js +0 -46
  216. package/dist/dashboard/save-outcome.js +0 -42
  217. package/dist/dashboard/spend.js +0 -115
  218. /package/dist/{extensions/api.js → core/package-api.js} +0 -0
@@ -1,9 +1,10 @@
1
1
  import { existsSync } from "node:fs";
2
- import { join } from "node:path";
2
+ import { join, resolve } from "node:path";
3
3
  import { z } from "zod";
4
- import { installedFromFolder, packageFoldersIn } from "../core/files.js";
4
+ import { installedFromFolder, packageFoldersIn, realPath } from "../core/files.js";
5
5
  import { readParts } from "../core/instruction-parts.js";
6
- import { files } from "../core/store.js";
6
+ import { apiProblem, declaredWidgets, packagePartsIssues, packagePartsShape } from "../core/package-declarations.js";
7
+ import { files, isInside } from "../core/store.js";
7
8
  import { comparableText } from "../core/text.js";
8
9
  import { readYamlValues } from "../core/yaml-file.js";
9
10
  /** The file that makes a folder an extension of rpg-engine (D-427). */
@@ -11,37 +12,8 @@ export const extensionFileName = "extension.yaml";
11
12
  // The longest about and part of the instructions an extension may give, in words (D-441).
12
13
  const aboutWords = 40;
13
14
  const partWords = 400;
14
- /**
15
- * The version of the API an extension's code is given (api.ts), which its package.json names: 2 added the widgets (D-502), 3 its additions to the game system,
16
- * the pages, the scene, writing its own fields and asking the player (D-505). A package made for this one or an older one is read; one made for a newer one is
17
- * refused, as an older rpg-engine refuses this one's.
18
- */
19
- export const extensionApi = 3;
20
15
  /** What an extension may add to the campaign's game system in extension.yaml, written as campaign.yaml writes it (CAM-2, D-505). */
21
- export const systemAdditionNames = ["fields", "tables", "computed", "counters", "recipes", "values"];
22
- /** Whether this rpg-engine reads a package made for this version of the API: from 1 up to its own. */
23
- export function readsApi(api) {
24
- return api !== undefined && Number.isInteger(api) && api >= 1 && api <= extensionApi;
25
- }
26
- /** The places of the dashboard a widget may stand in (D-502): a chip in the top, a card in the table's column beside the rolls, or a card in a page. */
27
- export const widgetPlaces = ["top", "side", "page"];
28
- /** The pages a widget's card may stand in: the Scene, the sheet, the World and the Journal. */
29
- export const widgetPages = ["scene", "sheet", "world", "journal"];
30
- // How many icons and widgets an extension may declare, and the longest path of an icon.
31
- const mostIcons = 40;
32
- const mostWidgets = 8;
33
- const longestPath = 4000;
34
- /** A name of an icon or a widget, as weather or sky-rain. */
35
- const ownName = z.string().regex(/^[a-z][a-z0-9-]*$/, "use lowercase letters, digits and hyphens, as sky-rain");
36
- const widgetSchema = z.object({
37
- title: z.string().trim().min(1).max(40),
38
- icon: ownName.optional(),
39
- place: z.enum(widgetPlaces, { error: `a widget's place is ${widgetPlaces.join(", ")}` }),
40
- page: z.enum(widgetPages, { error: `a card's page is ${widgetPages.join(", ")}` }).optional(),
41
- order: z.int().min(-100).max(100).optional(),
42
- }).strict().refine((widget) => (widget.place === "page") === (widget.page !== undefined), {
43
- error: "a widget in place page names its page (scene, sheet, world or journal), and only one in a page does",
44
- });
16
+ export const systemAdditionNames = ["fields", "tables", "computed", "counters", "recipes", "values", "condition-icons"];
45
17
  /** An addition to the game system, which the system checks as it reads it (CAM-3). */
46
18
  const addition = z.record(z.string(), z.unknown(), { error: "give it as a map by name, as campaign.yaml does" }).optional();
47
19
  const extensionSchema = z.object({
@@ -51,22 +23,18 @@ const extensionSchema = z.object({
51
23
  attribution: z.string().trim().min(1).optional(),
52
24
  needs: z.object({ system: z.string().trim().min(1).optional() }).strict().optional(),
53
25
  calendar: z.unknown().optional(),
54
- icons: z.record(ownName, z.string().max(longestPath).regex(/^[MmLlHhVvCcSsQqTtAaZz\d\s,.+-]+$/, "an icon is the path of an SVG, as M4 12h16")).optional(),
55
- widgets: z.record(ownName, widgetSchema).optional(),
26
+ ...packagePartsShape,
56
27
  fields: addition,
57
28
  tables: addition,
58
29
  computed: addition,
59
30
  counters: addition,
60
31
  recipes: addition,
61
32
  values: addition,
33
+ // The drawings of effects by their names, over the system's (D-516).
34
+ "condition-icons": addition,
62
35
  }).strict().superRefine((declared, check) => {
63
- const icons = Object.keys(declared.icons ?? {});
64
- const widgets = Object.entries(declared.widgets ?? {});
65
- if (icons.length > mostIcons || widgets.length > mostWidgets) {
66
- check.addIssue({ code: "custom", message: `an extension declares at most ${mostIcons} icons and ${mostWidgets} widgets` });
67
- }
68
- for (const [name, widget] of widgets.filter(([, widget]) => widget.icon !== undefined && !icons.includes(widget.icon))) {
69
- check.addIssue({ code: "custom", path: ["widgets", name, "icon"], message: `the icon ${widget.icon ?? ""} is not among the icons: add it there` });
36
+ for (const issue of packagePartsIssues(declared, "an extension")) {
37
+ check.addIssue({ code: "custom", ...issue });
70
38
  }
71
39
  });
72
40
  const packageSchema = z.object({
@@ -74,7 +42,7 @@ const packageSchema = z.object({
74
42
  version: z.string().min(1),
75
43
  main: z.string().min(1).optional(),
76
44
  // What says it is a package for rpg-engine, of which kind, and for which version of the API (D-439).
77
- "rpg-engine": z.object({ kind: z.string(), api: z.number().optional() }).optional(),
45
+ "rpg-engine": z.object({ kind: z.string(), api: z.number().optional(), page: z.string().min(1).optional() }).optional(),
78
46
  });
79
47
  /** The extensions installed in these folders, each a package folder, or a scope's folder of them as npm keeps them (@rpgengine/weather); the first by a name wins. */
80
48
  export function installedExtensions(folders) {
@@ -102,15 +70,22 @@ export function readExtension(folder) {
102
70
  }
103
71
  const owner = `The extension ${manifest.data.name}`;
104
72
  const marker = manifest.data["rpg-engine"];
105
- if (marker?.kind !== "extension" || !readsApi(marker.api)) {
106
- const made = marker?.kind !== "extension" ? 'its package.json does not say "rpg-engine": {"kind": "extension"}' : `it is made for the extension API ${marker.api ?? "none"}`;
107
- throw new Error(`${owner} cannot be used, because ${made}; this rpg-engine reads the API 1 to ${extensionApi}: install a version of it made for these.`);
73
+ if (marker?.kind !== "extension") {
74
+ throw new Error(`${owner} cannot be used, because its package.json does not say "rpg-engine": {"kind": "extension"}: install a version of it made for rpg-engine.`);
75
+ }
76
+ const unread = apiProblem(marker.api, "extension");
77
+ if (unread !== undefined) {
78
+ throw new Error(`${owner} cannot be used, because ${unread}.`);
108
79
  }
109
80
  const declared = extensionSchema.safeParse(readYamlValues(where(extensionFileName), "what the extension is, such as title: ..."));
110
81
  if (!declared.success) {
111
82
  throw new Error(`${owner} cannot be read, because its ${extensionFileName} is not valid: ${z.prettifyError(declared.error).replace(/\s+/g, " ")}`);
112
83
  }
113
- const { title, about, language, attribution, needs, calendar, icons, widgets } = declared.data;
84
+ const { title, about, language, attribution, needs, calendar, icons, widgets, figures } = declared.data;
85
+ // Its page code is a file of its own, by real paths, links included (D-510).
86
+ if (marker.page !== undefined && !isInside(realPath(folder), realPath(resolve(folder, marker.page)))) {
87
+ throw new Error(`${owner} cannot be used, because its page, ${marker.page}, is not inside its package: name a file of its own, such as dist/page.js.`);
88
+ }
114
89
  const adds = Object.fromEntries(systemAdditionNames.flatMap((key) => (declared.data[key] === undefined ? [] : [[key, declared.data[key]]])));
115
90
  const parts = readParts(folder, owner);
116
91
  // What the master reads of it in every chat, kept short (D-441).
@@ -120,6 +95,7 @@ export function readExtension(folder) {
120
95
  throw new Error(`${owner} cannot be used, because its ${long[0]} has ${words(long[1])} words, and ${long[2]} at most are read.`);
121
96
  }
122
97
  return {
98
+ kind: "extension",
123
99
  package: manifest.data.name,
124
100
  name: shortName(manifest.data.name),
125
101
  version: manifest.data.version,
@@ -132,9 +108,11 @@ export function readExtension(folder) {
132
108
  ...(calendar === undefined ? {} : { calendar }),
133
109
  adds,
134
110
  icons: icons ?? {},
135
- widgets: Object.entries(widgets ?? {}).map(([name, widget]) => ({ name, ...widget, order: widget.order ?? 0 })),
111
+ widgets: declaredWidgets(widgets),
136
112
  parts,
137
113
  ...(manifest.data.main === undefined ? {} : { code: where(manifest.data.main) }),
114
+ ...(marker.page === undefined ? {} : { page: where(marker.page) }),
115
+ figures: figures ?? {},
138
116
  linked: installedFromFolder(folder),
139
117
  };
140
118
  }
@@ -1,5 +1,6 @@
1
- export type { Asked, AskedRoll, ButtonWords, CalendarDay, DieTone, ExtensionCode, ExtensionCommand, ExtensionEntry, ExtensionKit, Game, GameMoment, GamePage, GameView, Rolled, RollFor, TimePassage, Track, Widget, WidgetPart, WidgetText, WidgetValue, } from "./api.ts";
2
- export { type DeclaredWidget, type Extension, extensionApi, extensionFileName, findExtension, installedExtensions, readExtension, readsApi, shortName, systemAdditionNames, type SystemAdditions, type WidgetPage, widgetPages, type WidgetPlace, widgetPlaces, } from "./extension.ts";
1
+ export { dropConsent, hasConsent, packageFingerprint, recordConsent } from "../core/consents.ts";
2
+ export { npmEngine } from "./engine.ts";
3
+ export { type CodePackage, type Extension, extensionFileName, findExtension, installedExtensions, readExtension, shortName, systemAdditionNames, type SystemAdditions } from "./extension.ts";
3
4
  export { isLocalSpec, issuesPage, isVerified, npmPackages, packageKeyword, verifiedScope } from "./packages.ts";
4
5
  export { isTarball } from "./tarball.ts";
5
6
  export { type ExtensionWords, extensionWords, wordIn } from "./words.ts";
@@ -1,4 +1,7 @@
1
- export { extensionApi, extensionFileName, findExtension, installedExtensions, readExtension, readsApi, shortName, systemAdditionNames, widgetPages, widgetPlaces, } from "./extension.js";
1
+ // The extensions installed beside the engine (D-427, D-428): which they are and what each declares. Depends on nothing else in rpg-engine.
2
+ export { dropConsent, hasConsent, packageFingerprint, recordConsent } from "../core/consents.js";
3
+ export { npmEngine } from "./engine.js";
4
+ export { extensionFileName, findExtension, installedExtensions, readExtension, shortName, systemAdditionNames } from "./extension.js";
2
5
  export { isLocalSpec, issuesPage, isVerified, npmPackages, packageKeyword, verifiedScope } from "./packages.js";
3
6
  export { isTarball } from "./tarball.js";
4
7
  export { extensionWords, wordIn } from "./words.js";
@@ -26,3 +26,9 @@ export declare function issuesPage(manifest: {
26
26
  bugs?: unknown;
27
27
  repository?: unknown;
28
28
  }): string | undefined;
29
+ /** The code npm's JSON error gives, as ENOTCACHED; undefined when it wrote none. */
30
+ export declare function npmErrorCode(ran: NpmRun): string | undefined;
31
+ /** What npm said went wrong: its JSON error, with --json, else the last line it wrote that is not the pointer to its log. */
32
+ export declare function npmError(ran: NpmRun): string;
33
+ /** Runs npm with these arguments, in a folder of no campaign, stopped with all it started after a while. */
34
+ export declare function runNpm(args: string): Promise<NpmRun>;
@@ -1,12 +1,15 @@
1
1
  import { spawn, spawnSync } from "node:child_process";
2
- import { cpSync, existsSync, readdirSync, readFileSync, renameSync, rmSync } from "node:fs";
2
+ import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync } from "node:fs";
3
3
  import { tmpdir } from "node:os";
4
4
  import { isAbsolute, join, resolve } from "node:path";
5
+ import { ourScope } from "../core/consents.js";
6
+ import { packageApi, readsApi } from "../core/package-declarations.js";
7
+ import { isNewerVersion } from "../core/version.js";
5
8
  import { isTarball, tarballText, unpackTarball } from "./tarball.js";
6
9
  /** The keyword of the packages for rpg-engine on npm, by which they are found (D-439). */
7
10
  export const packageKeyword = "rpg-engine-package";
8
11
  /** The npm scope of the packages we publish, the verified ones (D-428, D-441). */
9
- export const verifiedScope = "@rpgengine/";
12
+ export const verifiedScope = ourScope;
10
13
  const registry = "https://registry.npmjs.org";
11
14
  // Where the packages given as a .tgz are unpacked, in the packages' folder (D-452).
12
15
  const localFolder = "local";
@@ -22,12 +25,12 @@ const installOptions = "--install-links=true --ignore-scripts --save-exact --no-
22
25
  * npm on this computer, installing in this folder (D-436): never globally, never running a package's scripts, always linking a folder (D-441 tells a package
23
26
  * from a folder by its link). Its registry is read directly; `run` runs npm, a fake in tests.
24
27
  */
25
- export function npmPackages(folder, run = npm) {
28
+ export function npmPackages(folder, run = runNpm) {
26
29
  // What each .tgz said of itself when it was described, before the player's yes: the file installed must still say the same.
27
30
  const described = new Map();
28
31
  return {
29
32
  describe: async (spec) => {
30
- const read = isLocalSpec(spec) ? localPackage(spec) : await registryPackage(spec);
33
+ const read = isLocalSpec(spec) ? localPackage(spec) : await registryPackage(spec).then((found) => ("unreachable" in found ? cachedPackage(spec, run) : found));
31
34
  if (isLocalSpec(spec) && !("failed" in read)) {
32
35
  described.set(resolve(spec), `${read.name}@${read.version}`);
33
36
  }
@@ -38,8 +41,17 @@ export function npmPackages(folder, run = npm) {
38
41
  if (isLocalSpec(spec)) {
39
42
  return await installCopy(folder, spec, described.get(resolve(spec)), run);
40
43
  }
41
- const ran = await run(`install --prefix ${quotedFolder(folder)} ${isLocalSpec(spec) ? quotedFolder(spec) : checkedSpec(spec)} ${installOptions}`);
42
- return ran.code === 0 ? undefined : `npm said: ${npmError(ran)}`;
44
+ // What npm installed of the same version goes aside first, as it would keep it whatever it holds now: the files are npm's (D-510).
45
+ const named = spec.replace(/(?<=.)@[^@/]*$/, "");
46
+ const aside = join(folder, "aside", ...named.split("/"));
47
+ mkdirSync(join(aside, ".."), { recursive: true });
48
+ // Without the registry, from what npm keeps of it on this computer (D-452).
49
+ const install = async () => {
50
+ const ran = await run(`install --prefix ${quotedFolder(folder)} ${checkedSpec(spec)} ${installOptions}`);
51
+ return ran.code !== 0 && isUnreachable(ran) ? await run(`install --prefix ${quotedFolder(folder)} ${checkedSpec(spec)} ${installOptions} --offline`) : ran;
52
+ };
53
+ const ran = await installedAside(join(folder, "node_modules", ...named.split("/")), aside, install);
54
+ return ran.code === 0 ? undefined : npmErrorCode(ran) === "ENOTCACHED" ? offlineAdvice(named) : `npm said: ${npmError(ran)}`;
43
55
  },
44
56
  uninstall: async (name) => {
45
57
  const ran = await run(`uninstall --prefix ${quotedFolder(folder)} ${checkedSpec(name)} --ignore-scripts --no-audit --no-fund --json --loglevel=error`);
@@ -109,17 +121,94 @@ function httpsLink(text) {
109
121
  return undefined;
110
122
  }
111
123
  }
112
- /** What npm's registry says of a package, at a version or its latest, with what its package.json says for rpg-engine. */
124
+ /**
125
+ * What npm says of a package when its registry does not answer here: by npm itself, which reaches it through the proxy it is told of, else from what it keeps
126
+ * of it on this computer (D-452); with the two ways to have it when it has nothing.
127
+ */
128
+ async function cachedPackage(spec, run) {
129
+ const online = await run(`view ${checkedSpec(spec)} --json --loglevel=error`);
130
+ const ran = online.code !== 0 && isUnreachable(online) ? await run(`view ${checkedSpec(spec)} --json --offline --loglevel=error`) : online;
131
+ if (ran.code !== 0) {
132
+ const code = npmErrorCode(ran);
133
+ return code === "E404" ? { failed: `npm has no package ${spec}`, missing: true } : { failed: code === "ENOTCACHED" || isUnreachable(ran) ? offlineAdvice(spec) : `npm said: ${npmError(ran)}` };
134
+ }
135
+ try {
136
+ // A version range gives a list, its newest last.
137
+ const read = JSON.parse(ran.out);
138
+ const manifest = Array.isArray(read) ? read.at(-1) : read;
139
+ return manifest?.name === undefined ? { failed: `npm has no package ${spec}`, missing: true } : infoOf(manifest);
140
+ }
141
+ catch {
142
+ return { failed: `npm said of ${spec} what does not read: ${ran.out.slice(0, 200)}` };
143
+ }
144
+ }
145
+ /** What to do when npm can reach neither its registry nor a copy of the package on this computer (D-452): connect once, or give it as a file or a folder. */
146
+ function offlineAdvice(spec) {
147
+ const name = spec.replace(/(?<=.)@[^@/]*$/, "");
148
+ const file = `${name.replace(/^@/, "").replace("/", "-")}-<version>.tgz`;
149
+ return `npm cannot reach its registry from this computer, and has no copy of ${name} from before: connect the computer to the internet once and install it again, `
150
+ + `or give the package as a .tgz file or a folder of this computer, such as package install D:/Downloads/${file}`;
151
+ }
152
+ // What npm says when it cannot reach its registry, by the codes of Node and of npm's fetch.
153
+ const unreachableCodes = new Set(["ECONNREFUSED", "ENOTFOUND", "EAI_AGAIN", "ETIMEDOUT", "ECONNRESET", "EHOSTUNREACH", "ENETUNREACH", "ENETDOWN", "ERR_SOCKET_TIMEOUT"]);
154
+ /** Whether npm failed because it could not reach its registry, rather than for what it was asked. */
155
+ function isUnreachable(ran) {
156
+ return unreachableCodes.has(npmErrorCode(ran) ?? "") || /FetchError|network|ECONNREFUSED|ENOTFOUND|EAI_AGAIN|ETIMEDOUT/i.test(npmError(ran));
157
+ }
158
+ /** The code npm's JSON error gives, as ENOTCACHED; undefined when it wrote none. */
159
+ export function npmErrorCode(ran) {
160
+ try {
161
+ return JSON.parse(ran.out).error?.code;
162
+ }
163
+ catch {
164
+ return undefined;
165
+ }
166
+ }
167
+ /** What npm's registry says of a package, at a version or its latest, with what its package.json says for rpg-engine; unreachable when it does not answer. */
113
168
  async function registryPackage(spec) {
114
169
  const checked = checkedSpec(spec);
115
170
  const at = checked.lastIndexOf("@");
116
171
  const [name, version] = at > 0 ? [checked.slice(0, at), checked.slice(at + 1)] : [checked, "latest"];
117
172
  try {
118
173
  const read = await json(`${registry}/${name.replace("/", "%2f")}/${version}`);
119
- return read === undefined ? { failed: `npm has no package ${spec}`, missing: true } : infoOf(read);
174
+ if (read === undefined) {
175
+ return { failed: `npm has no package ${spec}`, missing: true };
176
+ }
177
+ // Asked by its name alone, the newest version this engine reads, with the newer one and the engine it needs (D-515 (2)).
178
+ const info = infoOf(read);
179
+ return at > 0 || !madeForNewer(info) ? info : await readableVersion(name, info);
120
180
  }
121
181
  catch (error) {
122
- return { failed: `npm's registry could not be reached: ${error instanceof Error ? error.message : String(error)}` };
182
+ return { failed: `npm's registry could not be reached: ${error instanceof Error ? error.message : String(error)}`, unreachable: true };
183
+ }
184
+ }
185
+ /** Whether a package is an extension or a game system made for a newer API than this engine reads (D-515). */
186
+ function madeForNewer(info) {
187
+ return (info.kind === "extension" || info.kind === "system") && info.api !== undefined && info.api > packageApi;
188
+ }
189
+ /**
190
+ * The newest version of a package this engine reads, beside its latest, which needs a newer engine (D-515 (2)): with that one and the first rpg-engine on npm
191
+ * that reads it. The latest alone when no version reads, which is then refused.
192
+ */
193
+ async function readableVersion(name, latest) {
194
+ const all = await json(`${registry}/${name.replace("/", "%2f")}`);
195
+ const kind = latest.kind === "system" ? "system" : "extension";
196
+ const readable = Object.values(all?.versions ?? {}).map(infoOf).filter((one) => !one.version.includes("-") && readsApi(one.api, kind));
197
+ const newest = readable.reduce((best, one) => (best === undefined || isNewerVersion(one.version, best.version) ? one : best), undefined);
198
+ const engine = await engineReading(latest.api ?? 0);
199
+ const newer = { version: latest.version, ...(engine === undefined ? {} : { engine }) };
200
+ return newest === undefined ? latest : { ...newest, newer };
201
+ }
202
+ /** The first version of rpg-engine on npm that reads a package made for this API, as its package.json says; undefined when none does yet, or npm does not say. */
203
+ async function engineReading(api) {
204
+ try {
205
+ const all = await json(`${registry}/rpg-engine`);
206
+ const reads = (one) => typeof one["rpg-engine"]?.api === "number" && one["rpg-engine"].api >= api;
207
+ const reading = Object.values(all?.versions ?? {}).filter((one) => typeof one.version === "string" && !one.version.includes("-") && reads(one));
208
+ return reading.reduce((first, one) => (first === undefined || isNewerVersion(first, one.version ?? "") ? one.version : first), undefined);
209
+ }
210
+ catch {
211
+ return undefined;
123
212
  }
124
213
  }
125
214
  /** What a package's folder or .tgz says of it, by its package.json: a .tgz's name must be one npm takes, as it becomes a folder's. */
@@ -258,7 +347,7 @@ function quotedFolder(folder) {
258
347
  return `"${path}"`;
259
348
  }
260
349
  /** What npm said went wrong: its JSON error, with --json, else the last line it wrote that is not the pointer to its log. */
261
- function npmError(ran) {
350
+ export function npmError(ran) {
262
351
  try {
263
352
  const read = JSON.parse(ran.out);
264
353
  if (read.error?.summary !== undefined) {
@@ -272,7 +361,7 @@ function npmError(ran) {
272
361
  return lines.at(-1) ?? "nothing";
273
362
  }
274
363
  /** Runs npm with these arguments, in a folder of no campaign, stopped with all it started after a while. */
275
- function npm(args) {
364
+ export function runNpm(args) {
276
365
  return new Promise((done) => {
277
366
  const child = spawn(`npm ${args}`, { shell: true, windowsHide: true, cwd: tmpdir(), env: { ...process.env, NoDefaultCurrentDirectoryInExePath: "1" }, stdio: ["ignore", "pipe", "pipe"] });
278
367
  let [out, errors] = ["", ""];
package/dist/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  export { getVersion } from "./core/version.ts";
2
- export type { SaveAsked } from "./core/context.ts";
3
- export type { Asked, AskedRoll, ButtonWords, CalendarDay, DieTone, ExtensionCode, ExtensionCommand, ExtensionEntry, ExtensionKit, Game, GameMoment, GamePage, GameView, Rolled, RollFor, TimePassage, Track, Widget, WidgetPart, WidgetText, WidgetValue, } from "./extensions/index.ts";
4
- export type { CounterChange, RollMade, SystemEntry, SystemGame, SystemHooks, SystemPage, SystemReader } from "./systems/index.ts";
2
+ export type { Asked, AskedRoll, Asking, AskingQuestion, ButtonWords, CalendarDay, CardTint, CounterChange, DieTone, Game, GameMoment, GamePage, GameView, PackageCode, PackageCommand, PackageEntry, PackageKit, Rolled, RollFor, TimePassage, Track, Widget, WidgetPart, WidgetText, WidgetValue, } from "./core/package-api.ts";
@@ -3,20 +3,22 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
3
3
  import { spawn } from "node:child_process";
4
4
  import { z } from "zod";
5
5
  import { findCampaign, hasCharacterAgent, refreshHostFiles } from "./campaign/index.js";
6
- import { extensionCommands } from "./commands/game-extensions.js";
6
+ import { campaignExamples } from "./commands/game-examples.js";
7
7
  import { outsideNews, whileClosedNews } from "./commands/game-outside.js";
8
+ import { packageCommands } from "./commands/game-package-code.js";
8
9
  import { newChatText, wentBackTo } from "./commands/game-saves.js";
9
10
  import { campaignWorld } from "./commands/game-world.js";
10
11
  import { commands } from "./commands/index.js";
11
12
  import { systemConfirm } from "./confirm/index.js";
12
13
  import { defaultContext, packagesFolder } from "./core/context.js";
13
14
  import { downloadBytes } from "./core/download.js";
15
+ import { neutralExamples, withExamples } from "./core/examples.js";
14
16
  import { SessionStore } from "./core/session-store.js";
15
17
  import { FileStore, withFiles } from "./core/store.js";
16
18
  import { getVersion } from "./core/version.js";
17
19
  import { startDashboard } from "./dashboard-server.js";
18
20
  import { systemPageReader } from "./documents/index.js";
19
- import { npmPackages } from "./extensions/index.js";
21
+ import { npmEngine, npmPackages } from "./extensions/index.js";
20
22
  import { hostInstructions, startInstructions } from "./instructions/index.js";
21
23
  import { libraryRunner } from "./library-reader.js";
22
24
  import { computerHelpers, hostPictures, hostReader, hostWriter } from "./pictures/index.js";
@@ -53,11 +55,20 @@ export function createMcpServer(context = defaultContext(), environment = proces
53
55
  askingTools.filter((tool) => !tool.enabled).forEach((tool) => tool.enable());
54
56
  }
55
57
  };
58
+ // 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).
59
+ const examples = { shown: examplesFor(context, new FileStore(context.systemFolders)) };
60
+ const coreTools = new Map();
61
+ // After every call the descriptions follow the campaign's system, as after init or config system, and the extensions' tools follow campaign.yaml.
62
+ const afterCall = () => {
63
+ refreshExamples(coreTools, examples, examplesFor(context, context.files ?? new FileStore(context.systemFolders)));
64
+ return extensions();
65
+ };
56
66
  // The tools of the campaign's extensions, kept in step after every call, as one that installs an extension or makes the campaign (D-63).
57
- const extensions = extensionTools(server, context, (command) => (input, extra) => runTool(command, input, context, extra, prepare, outside).finally(extensions));
67
+ const extensions = extensionTools(server, context, (command) => (input, extra) => runTool(command, input, context, extra, prepare, outside, examples).finally(afterCall));
58
68
  firstExtensions.set(server, extensions());
59
69
  for (const command of commands) {
60
- const tool = server.registerTool(command.name, toolConfig(command), (input, extra) => runTool(command, input, context, extra, prepare, outside).finally(extensions));
70
+ const tool = server.registerTool(command.name, toolConfig(command, examples.shown), (input, extra) => runTool(command, input, context, extra, prepare, outside, examples).finally(afterCall));
71
+ coreTools.set(command, tool);
61
72
  if (command.needsPlayer && context.player === undefined) {
62
73
  tool.disable();
63
74
  askingTools.push(tool);
@@ -101,6 +112,7 @@ export async function startMcpServer() {
101
112
  importRunner: (root) => spawn(process.execPath, [process.argv[1] ?? "", "import"], { cwd: root, detached: true, stdio: "ignore", windowsHide: true, env: { ...process.env, RPG_HOST: host() ?? "" } }).unref(),
102
113
  helpers: computerHelpers(),
103
114
  packages: npmPackages(packagesFolder()),
115
+ engine: npmEngine(),
104
116
  confirm: systemConfirm(process.platform, process.env),
105
117
  ocr: systemPageReader(process.platform, process.env),
106
118
  readLibrary: libraryRunner(),
@@ -173,7 +185,7 @@ function extensionTools(server, context, handler) {
173
185
  const store = context.files ?? new FileStore(context.systemFolders);
174
186
  const own = await withFiles(store, async () => {
175
187
  const root = findCampaign(context.folder);
176
- return root === undefined ? { commands: [], sources: {} } : await extensionCommands(root, context, taken);
188
+ return root === undefined ? { commands: [], sources: {} } : await packageCommands(root, context, taken);
177
189
  });
178
190
  for (const command of own.commands) {
179
191
  const kept = registered.get(command.name);
@@ -182,7 +194,7 @@ function extensionTools(server, context, handler) {
182
194
  kept.tool.remove();
183
195
  }
184
196
  if (kept === undefined || kept.source !== source) {
185
- registered.set(command.name, { tool: server.registerTool(command.name, toolConfig(command), handler(command)), source });
197
+ registered.set(command.name, { tool: server.registerTool(command.name, toolConfig(command, neutralExamples), handler(command)), source });
186
198
  }
187
199
  else if (!kept.tool.enabled) {
188
200
  kept.tool.enable();
@@ -201,30 +213,55 @@ function extensionTools(server, context, handler) {
201
213
  * The host is shown each tool's parameters as they are, strict; the SDK lets any object through, so that runTool checks it and says how to call the tool:
202
214
  * a master who calls one without loading its schema reads its parameters in the answer, not zod's words before our handler.
203
215
  */
204
- function toolConfig(command) {
216
+ function toolConfig(command, examples) {
205
217
  const annotations = command.readOnly ? { readOnlyHint: true } : undefined;
206
218
  const meta = command.alwaysLoad ? { "anthropic/alwaysLoad": true } : undefined;
207
- return { description: command.description, inputSchema: z.looseObject({}).meta(shownInput(command)), annotations, _meta: meta };
219
+ return { description: withExamples(command.description, examples), inputSchema: shownSchema(command, examples), annotations, _meta: meta };
220
+ }
221
+ /** The examples for the campaign of the server's folder, read through a store; neutral where it has none, or where it does not read. */
222
+ function examplesFor(context, store) {
223
+ try {
224
+ return withFiles(store, () => campaignExamples(findCampaign(context.folder), context));
225
+ }
226
+ catch {
227
+ return neutralExamples;
228
+ }
229
+ }
230
+ /** Gives the core's tools the examples of a system other than the one shown, as after config system: the host hears that the list changed. */
231
+ function refreshExamples(tools, examples, now) {
232
+ if (JSON.stringify(now) === JSON.stringify(examples.shown)) {
233
+ return;
234
+ }
235
+ examples.shown = now;
236
+ for (const [command, tool] of tools) {
237
+ tool.inputSchema = shownSchema(command, now);
238
+ tool.update({ description: withExamples(command.description, now) });
239
+ }
240
+ }
241
+ function shownSchema(command, examples) {
242
+ return z.looseObject({}).meta(shownInput(command, examples));
208
243
  }
209
244
  // The JSON schema of each command's input, as the SDK would write it from the strict schema.
210
245
  const shownInputs = new WeakMap();
211
- function shownInput(command) {
246
+ function shownInput(command, examples) {
212
247
  let shown = shownInputs.get(command);
213
248
  if (shown === undefined) {
214
249
  shown = z.toJSONSchema(command.input.strict(), { target: "draft-7", io: "input" });
215
250
  shownInputs.set(command, shown);
216
251
  }
217
- return shown;
252
+ const fields = shown.properties ?? {};
253
+ const properties = Object.entries(fields).map(([name, field]) => [name, field.description === undefined ? field : { ...field, description: withExamples(field.description, examples) }]);
254
+ return shown.properties === undefined ? shown : { ...shown, properties: Object.fromEntries(properties) };
218
255
  }
219
256
  /** The command's input, checked as its schema says; what is wrong comes with every parameter the tool takes, for a call made without the schema. */
220
- function checkedInput(command, input) {
257
+ function checkedInput(command, input, examples) {
221
258
  const parsed = command.input.strict().safeParse(input ?? {});
222
259
  if (parsed.success) {
223
260
  return parsed.data;
224
261
  }
225
262
  const given = typeof input === "object" && input !== null ? input : {};
226
263
  const wrong = parsed.error.issues.map((issue) => inputIssue(command.name, issue, given));
227
- const shown = shownInput(command);
264
+ const shown = shownInput(command, examples);
228
265
  const required = shown.required ?? [];
229
266
  const parameters = Object.entries(shown.properties ?? {}).map(([name, field]) => `- ${name}${required.includes(name) ? "" : " (optional)"}${field.description === undefined ? "" : `: ${field.description}`}`);
230
267
  const takes = parameters.length === 0 ? `${command.name} takes no parameters.` : `${command.name} takes:\n${parameters.join("\n")}`;
@@ -242,7 +279,7 @@ function inputIssue(tool, issue, given) {
242
279
  }
243
280
  return path === "" ? `${issue.message}.` : `${path}: ${issue.message}.`;
244
281
  }
245
- async function runTool(command, input, context, extra, prepare, outside) {
282
+ async function runTool(command, input, context, extra, prepare, outside, examples) {
246
283
  const keepAlive = command.needsPlayer || command.waitsForPlayer
247
284
  ? reportProgress(extra, () => (context.page?.asking?.() === true ? "waiting for the player's click on the dashboard" : "waiting for the player"))
248
285
  : command.slow === true
@@ -272,7 +309,7 @@ async function runTool(command, input, context, extra, prepare, outside) {
272
309
  news = context.news?.();
273
310
  return { content: [{ type: "text", text: [...(news?.lines ?? []), back.refused].join("\n\n") }], isError: true };
274
311
  }
275
- const checked = checkedInput(command, input);
312
+ const checked = checkedInput(command, input, examples.shown);
276
313
  // What changed outside the chat comes before the command runs on it, its events fired (OUT-3).
277
314
  changedOutside = outside.take();
278
315
  // The call's own context, with its cancel, as the user stopping it (ASK-9).
@@ -11,6 +11,10 @@ export interface PageWords {
11
11
  export interface WordsSystem {
12
12
  name: string;
13
13
  folder: string;
14
+ /** The version of its rules the campaign plays, whose words go over the common ones (VER-3). */
15
+ version?: {
16
+ folder: string;
17
+ };
14
18
  }
15
19
  /** The page's words on the fly: what a language has, and the phrases the page asks first; `notify` tells the pages when more have come. */
16
20
  export interface PageTranslator {
@@ -6,7 +6,7 @@ import { dirname, join } from "node:path";
6
6
  import { stringify } from "yaml";
7
7
  import { files } from "./core/store.js";
8
8
  import { languagePackFor, packPhrases } from "./languages/index.js";
9
- import { systemWords } from "./systems/index.js";
9
+ import { layeredSystemWords, systemContentFolders, systemWords } from "./systems/index.js";
10
10
  // How many phrases go in one request.
11
11
  const batchSize = 130;
12
12
  // How long a language whose translation stopped short waits before it is tried again, so that a writer that fails is not called at every reading.
@@ -114,13 +114,13 @@ export function homeSystemWords(home, system, language) {
114
114
  }
115
115
  /** The system's words a language still lacks in the player's data folder, against its Italian list. */
116
116
  function systemMissing(home, language, system) {
117
- const italian = systemWords(system.folder, "it");
117
+ const italian = layeredSystemWords(systemContentFolders(system), "it");
118
118
  const own = homeSystemWords(home, system, language);
119
119
  return italian !== undefined && Object.keys(wordEntries(italian)).some((id) => !(id in wordEntries(own ?? { groups: {}, fields: {}, words: {} })));
120
120
  }
121
121
  /** The game system's words translated at once, all in one request so that one concept has one term, after its Italian list. */
122
122
  async function translateSystem(writer, home, language, system) {
123
- const italian = systemWords(system.folder, "it");
123
+ const italian = layeredSystemWords(systemContentFolders(system), "it");
124
124
  if (italian === undefined || !systemMissing(home, language, system)) {
125
125
  return;
126
126
  }
@@ -142,7 +142,7 @@ function missingPhrases(home, page, language) {
142
142
  }
143
143
  /** The game system's words a language still lacks on this computer, each by a short id from its place in the system's Italian list, with what it is. */
144
144
  function missingWords(home, language, system) {
145
- const italian = systemWords(system.folder, "it");
145
+ const italian = layeredSystemWords(systemContentFolders(system), "it");
146
146
  const own = wordEntries(homeSystemWords(home, system, language) ?? { groups: {}, fields: {}, words: {} });
147
147
  return Object.entries(italian === undefined ? {} : wordEntries(italian)).flatMap(([key, word], index) => {
148
148
  const section = key.includes(": ") ? key.slice(0, key.indexOf(": ")) : key;