rpg-engine 0.7.0 → 0.9.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 (397) hide show
  1. package/dist/adventures/index.d.ts +1 -1
  2. package/dist/adventures/index.js +1 -1
  3. package/dist/adventures/source.js +13 -13
  4. package/dist/campaign/create-campaign.js +10 -1
  5. package/dist/campaign/host-files.d.ts +2 -1
  6. package/dist/campaign/host-files.js +11 -11
  7. package/dist/campaign/index.d.ts +1 -1
  8. package/dist/campaign/index.js +1 -1
  9. package/dist/campaign/settings.d.ts +55 -64
  10. package/dist/campaign/settings.js +171 -174
  11. package/dist/{cli.js → cli/cli.js} +3 -3
  12. package/dist/{command-line.d.ts → cli/command-line.d.ts} +1 -1
  13. package/dist/{command-line.js → cli/command-line.js} +21 -20
  14. package/dist/commands/advance.d.ts +1 -1
  15. package/dist/commands/advance.js +7 -7
  16. package/dist/commands/ask.d.ts +1 -8
  17. package/dist/commands/ask.js +16 -29
  18. package/dist/commands/{change.d.ts → change/change.d.ts} +2 -2
  19. package/dist/commands/{change.js → change/change.js} +46 -52
  20. package/dist/commands/{game-damage.d.ts → change/damage.d.ts} +2 -2
  21. package/dist/commands/{game-damage.js → change/damage.js} +3 -3
  22. package/dist/commands/{game-recipe-pace.d.ts → change/recipe-pace.d.ts} +2 -2
  23. package/dist/commands/{game-recipe-pace.js → change/recipe-pace.js} +4 -4
  24. package/dist/commands/config.d.ts +4 -4
  25. package/dist/commands/config.js +142 -138
  26. package/dist/commands/effect.d.ts +1 -1
  27. package/dist/commands/effect.js +11 -12
  28. package/dist/commands/find.d.ts +4 -4
  29. package/dist/commands/find.js +2 -2
  30. package/dist/commands/image.js +6 -6
  31. package/dist/commands/{import.d.ts → import/import.d.ts} +2 -2
  32. package/dist/commands/{import.js → import/import.js} +101 -101
  33. package/dist/commands/{game-import.d.ts → import/run.d.ts} +3 -3
  34. package/dist/commands/{game-import.js → import/run.js} +13 -12
  35. package/dist/commands/index.js +7 -7
  36. package/dist/commands/init.js +3 -3
  37. package/dist/commands/install.js +1 -1
  38. package/dist/commands/instructions.js +6 -6
  39. package/dist/commands/mode.d.ts +2 -2
  40. package/dist/commands/mode.js +8 -8
  41. package/dist/commands/mood.js +4 -4
  42. package/dist/commands/move.js +13 -20
  43. package/dist/commands/package.d.ts +2 -2
  44. package/dist/commands/package.js +138 -93
  45. package/dist/commands/rename.js +3 -3
  46. package/dist/commands/reveal.js +29 -18
  47. package/dist/commands/{roll.d.ts → roll/roll.d.ts} +4 -4
  48. package/dist/commands/{roll.js → roll/roll.js} +69 -69
  49. package/dist/commands/{game-tables.d.ts → roll/tables.d.ts} +2 -2
  50. package/dist/commands/{game-tables.js → roll/tables.js} +4 -4
  51. package/dist/commands/rules.d.ts +2 -2
  52. package/dist/commands/rules.js +17 -9
  53. package/dist/commands/save.d.ts +1 -1
  54. package/dist/commands/save.js +18 -18
  55. package/dist/commands/scene.d.ts +4 -4
  56. package/dist/commands/scene.js +31 -28
  57. package/dist/commands/{game-advance.d.ts → shared/advance.d.ts} +4 -4
  58. package/dist/commands/{game-advance.js → shared/advance.js} +27 -27
  59. package/dist/commands/{game-adventures.d.ts → shared/adventures.d.ts} +3 -3
  60. package/dist/commands/{game-adventures.js → shared/adventures.js} +20 -27
  61. package/dist/commands/{game-bonds.d.ts → shared/bonds.d.ts} +3 -3
  62. package/dist/commands/{game-bonds.js → shared/bonds.js} +2 -2
  63. package/dist/commands/{game-checks.d.ts → shared/checks.d.ts} +3 -3
  64. package/dist/commands/{game-checks.js → shared/checks.js} +7 -7
  65. package/dist/commands/{game-dice-pool.d.ts → shared/dice-pool.d.ts} +3 -3
  66. package/dist/commands/{game-dice-pool.js → shared/dice-pool.js} +19 -12
  67. package/dist/commands/{effect-layer.d.ts → shared/effect-layer.d.ts} +2 -2
  68. package/dist/commands/{effect-layer.js → shared/effect-layer.js} +12 -12
  69. package/dist/commands/{game-effects.d.ts → shared/effects.d.ts} +7 -7
  70. package/dist/commands/{game-effects.js → shared/effects.js} +19 -19
  71. package/dist/commands/{game-environment.d.ts → shared/environment.d.ts} +1 -1
  72. package/dist/commands/{game-environment.js → shared/environment.js} +3 -3
  73. package/dist/commands/{game-events.d.ts → shared/events.d.ts} +5 -5
  74. package/dist/commands/{game-events.js → shared/events.js} +20 -22
  75. package/dist/commands/{game-examples.d.ts → shared/examples.d.ts} +4 -8
  76. package/dist/commands/{game-examples.js → shared/examples.js} +23 -23
  77. package/dist/commands/{game-experience.d.ts → shared/experience.d.ts} +2 -2
  78. package/dist/commands/{game-experience.js → shared/experience.js} +8 -11
  79. package/dist/commands/{game-grid-moves.d.ts → shared/grid-moves.d.ts} +6 -6
  80. package/dist/commands/{game-grid-moves.js → shared/grid-moves.js} +5 -5
  81. package/dist/commands/{game-grids.d.ts → shared/grids.d.ts} +4 -9
  82. package/dist/commands/{game-grids.js → shared/grids.js} +20 -19
  83. package/dist/commands/{game-images.d.ts → shared/images.d.ts} +3 -3
  84. package/dist/commands/{game-images.js → shared/images.js} +7 -6
  85. package/dist/commands/shared/inputs.d.ts +9 -0
  86. package/dist/commands/shared/inputs.js +12 -0
  87. package/dist/commands/{game-journey.d.ts → shared/journey.d.ts} +4 -6
  88. package/dist/commands/{game-journey.js → shared/journey.js} +13 -15
  89. package/dist/commands/{game-knowledge.d.ts → shared/knowledge.d.ts} +15 -8
  90. package/dist/commands/{game-knowledge.js → shared/knowledge.js} +56 -44
  91. package/dist/{library-reader.js → commands/shared/library-reader.js} +4 -4
  92. package/dist/commands/{game-library.d.ts → shared/library.d.ts} +7 -4
  93. package/dist/commands/{game-library.js → shared/library.js} +70 -50
  94. package/dist/commands/{game-limits.d.ts → shared/limits.d.ts} +3 -3
  95. package/dist/commands/{game-limits.js → shared/limits.js} +3 -3
  96. package/dist/commands/{game-loot.d.ts → shared/loot.d.ts} +2 -2
  97. package/dist/commands/{game-loot.js → shared/loot.js} +3 -3
  98. package/dist/commands/{game-master-rolls.d.ts → shared/master-rolls.d.ts} +2 -2
  99. package/dist/commands/{game-master-rolls.js → shared/master-rolls.js} +6 -6
  100. package/dist/commands/{game-mode.d.ts → shared/mode.d.ts} +4 -6
  101. package/dist/commands/{game-mode.js → shared/mode.js} +10 -10
  102. package/dist/commands/{game-money.d.ts → shared/money.d.ts} +3 -3
  103. package/dist/commands/{game-money.js → shared/money.js} +4 -4
  104. package/dist/commands/{game-moods.d.ts → shared/moods.d.ts} +3 -3
  105. package/dist/commands/{game-moods.js → shared/moods.js} +3 -3
  106. package/dist/commands/{game-moves.d.ts → shared/moves.d.ts} +2 -2
  107. package/dist/commands/{game-moves.js → shared/moves.js} +5 -5
  108. package/dist/commands/{game-offers.d.ts → shared/offers.d.ts} +3 -3
  109. package/dist/commands/{game-offers.js → shared/offers.js} +9 -12
  110. package/dist/commands/{game-outside.d.ts → shared/outside.d.ts} +3 -3
  111. package/dist/commands/{game-outside.js → shared/outside.js} +9 -9
  112. package/dist/commands/{game-catalog.d.ts → shared/packages/catalog.d.ts} +1 -3
  113. package/dist/commands/{game-catalog.js → shared/packages/catalog.js} +17 -22
  114. package/dist/commands/{game-package-code.d.ts → shared/packages/code.d.ts} +10 -14
  115. package/dist/commands/{game-package-code.js → shared/packages/code.js} +156 -59
  116. package/dist/commands/{game-extension-list.d.ts → shared/packages/extensions.d.ts} +6 -6
  117. package/dist/commands/{game-extension-list.js → shared/packages/extensions.js} +43 -22
  118. package/dist/commands/{game-package-hooks.d.ts → shared/packages/hooks.d.ts} +3 -3
  119. package/dist/commands/{game-package-hooks.js → shared/packages/hooks.js} +3 -3
  120. package/dist/commands/{game-widgets.d.ts → shared/packages/widgets.d.ts} +6 -10
  121. package/dist/commands/{game-widgets.js → shared/packages/widgets.js} +57 -57
  122. package/dist/commands/{page-counters.d.ts → shared/page-counters.d.ts} +3 -3
  123. package/dist/commands/{page-counters.js → shared/page-counters.js} +5 -5
  124. package/dist/{page-words.d.ts → commands/shared/page-words.d.ts} +2 -2
  125. package/dist/{page-words.js → commands/shared/page-words.js} +5 -4
  126. package/dist/commands/{parts.d.ts → shared/parts.d.ts} +3 -3
  127. package/dist/commands/{parts.js → shared/parts.js} +4 -4
  128. package/dist/commands/{game-positions.d.ts → shared/positions.d.ts} +3 -5
  129. package/dist/commands/{game-positions.js → shared/positions.js} +6 -7
  130. package/dist/commands/{problems.d.ts → shared/problems.d.ts} +3 -3
  131. package/dist/commands/{problems.js → shared/problems.js} +21 -22
  132. package/dist/commands/{progression.d.ts → shared/progression.d.ts} +2 -2
  133. package/dist/commands/{progression.js → shared/progression.js} +4 -4
  134. package/dist/commands/{game-quests.d.ts → shared/quests.d.ts} +4 -4
  135. package/dist/commands/{game-quests.js → shared/quests.js} +6 -6
  136. package/dist/commands/{game-recipes.d.ts → shared/recipes.d.ts} +3 -3
  137. package/dist/commands/{game-recipes.js → shared/recipes.js} +3 -3
  138. package/dist/commands/{game-reminders.d.ts → shared/reminders.d.ts} +4 -4
  139. package/dist/commands/{game-reminders.js → shared/reminders.js} +4 -4
  140. package/dist/commands/{game-roads.d.ts → shared/roads.d.ts} +5 -5
  141. package/dist/commands/{game-roads.js → shared/roads.js} +43 -44
  142. package/dist/commands/{game-rules.d.ts → shared/rules.d.ts} +13 -5
  143. package/dist/commands/shared/rules.js +66 -0
  144. package/dist/commands/{game-saves.d.ts → shared/saves.d.ts} +4 -4
  145. package/dist/commands/{game-saves.js → shared/saves.js} +51 -51
  146. package/dist/commands/{game-scene.d.ts → shared/scene.d.ts} +13 -3
  147. package/dist/commands/{game-scene.js → shared/scene.js} +41 -13
  148. package/dist/commands/{sheet.d.ts → shared/sheet.d.ts} +5 -5
  149. package/dist/commands/{sheet.js → shared/sheet.js} +76 -76
  150. package/dist/commands/{game-stacks.d.ts → shared/stacks.d.ts} +2 -9
  151. package/dist/commands/{game-stacks.js → shared/stacks.js} +22 -22
  152. package/dist/commands/{game-theme.d.ts → shared/theme.d.ts} +3 -3
  153. package/dist/commands/{game-theme.js → shared/theme.js} +2 -2
  154. package/dist/commands/{game-thoughts.d.ts → shared/thoughts.d.ts} +2 -4
  155. package/dist/commands/{game-thoughts.js → shared/thoughts.js} +6 -8
  156. package/dist/commands/{game-thresholds.d.ts → shared/thresholds.d.ts} +1 -1
  157. package/dist/commands/{game-thresholds.js → shared/thresholds.js} +4 -4
  158. package/dist/commands/{game-time.d.ts → shared/time.d.ts} +4 -4
  159. package/dist/commands/{game-time.js → shared/time.js} +6 -6
  160. package/dist/commands/{game-turn-uses.d.ts → shared/turn-uses.d.ts} +3 -3
  161. package/dist/commands/{game-turn-uses.js → shared/turn-uses.js} +12 -15
  162. package/dist/commands/{game-upkeep.d.ts → shared/upkeep.d.ts} +3 -3
  163. package/dist/commands/{game-upkeep.js → shared/upkeep.js} +69 -57
  164. package/dist/commands/{game-voices.d.ts → shared/voices.d.ts} +1 -1
  165. package/dist/commands/{game-voices.js → shared/voices.js} +2 -2
  166. package/dist/commands/{worked-out.d.ts → shared/worked-out.d.ts} +3 -8
  167. package/dist/commands/{worked-out.js → shared/worked-out.js} +238 -238
  168. package/dist/commands/{game-world.d.ts → shared/world.d.ts} +5 -14
  169. package/dist/commands/{game-world.js → shared/world.js} +72 -76
  170. package/dist/commands/show.d.ts +4 -1
  171. package/dist/commands/show.js +36 -18
  172. package/dist/commands/status.d.ts +1 -1
  173. package/dist/commands/status.js +28 -28
  174. package/dist/commands/thoughts.js +3 -3
  175. package/dist/commands/trade.js +9 -10
  176. package/dist/commands/translate.d.ts +1 -1
  177. package/dist/commands/translate.js +3 -3
  178. package/dist/commands/{game-open.d.ts → travel/open.d.ts} +3 -3
  179. package/dist/commands/{game-open.js → travel/open.js} +4 -5
  180. package/dist/commands/{route.d.ts → travel/route.d.ts} +1 -1
  181. package/dist/commands/{route.js → travel/route.js} +9 -10
  182. package/dist/commands/{travel.d.ts → travel/travel.d.ts} +2 -2
  183. package/dist/commands/{travel.js → travel/travel.js} +19 -21
  184. package/dist/commands/validate.js +5 -5
  185. package/dist/commands/{game-view-journal.d.ts → view/journal.d.ts} +5 -5
  186. package/dist/commands/{game-view-journal.js → view/journal.js} +5 -5
  187. package/dist/commands/{game-view-map.d.ts → view/map.d.ts} +3 -3
  188. package/dist/commands/{game-view-map.js → view/map.js} +15 -16
  189. package/dist/commands/{game-view-place.d.ts → view/place.d.ts} +6 -6
  190. package/dist/commands/{game-view-place.js → view/place.js} +108 -108
  191. package/dist/commands/{view.d.ts → view/view.d.ts} +16 -16
  192. package/dist/commands/{view.js → view/view.js} +41 -36
  193. package/dist/commands/{game-view-world.d.ts → view/world.d.ts} +4 -4
  194. package/dist/commands/{game-view-world.js → view/world.js} +7 -7
  195. package/dist/commands/{game-here.d.ts → write/here.d.ts} +5 -3
  196. package/dist/commands/{game-here.js → write/here.js} +18 -12
  197. package/dist/commands/{write.d.ts → write/write.d.ts} +6 -6
  198. package/dist/commands/{write.js → write/write.js} +44 -41
  199. package/dist/confirm/confirm.d.ts +2 -0
  200. package/dist/confirm/confirm.js +15 -5
  201. package/dist/core/consents.d.ts +3 -2
  202. package/dist/core/consents.js +43 -4
  203. package/dist/core/context.d.ts +8 -6
  204. package/dist/core/context.js +4 -2
  205. package/dist/core/download.js +16 -5
  206. package/dist/core/files.d.ts +8 -1
  207. package/dist/core/files.js +53 -21
  208. package/dist/core/formula.d.ts +7 -2
  209. package/dist/core/formula.js +63 -66
  210. package/dist/core/instruction-parts.js +1 -1
  211. package/dist/core/mood.d.ts +0 -1
  212. package/dist/core/mood.js +3 -3
  213. package/dist/core/package-api.d.ts +11 -0
  214. package/dist/core/package-api.js +2 -1
  215. package/dist/core/package-declarations.d.ts +9 -9
  216. package/dist/core/package-declarations.js +3 -3
  217. package/dist/core/process-mark.d.ts +8 -0
  218. package/dist/core/process-mark.js +72 -0
  219. package/dist/core/registry.d.ts +5 -0
  220. package/dist/core/registry.js +10 -0
  221. package/dist/core/session-store.d.ts +0 -1
  222. package/dist/core/session-store.js +11 -14
  223. package/dist/core/store.d.ts +4 -0
  224. package/dist/core/store.js +29 -8
  225. package/dist/core/text.d.ts +4 -0
  226. package/dist/core/text.js +11 -2
  227. package/dist/core/yaml-file.js +2 -2
  228. package/dist/dashboard/{acts.js → acts/acts.js} +2 -2
  229. package/dist/dashboard/{act-names.js → acts/names.js} +1 -1
  230. package/dist/dashboard/{act-sheet.js → acts/sheet.js} +3 -3
  231. package/dist/dashboard/{act-strip.js → acts/strip.js} +2 -2
  232. package/dist/dashboard/app.js +13 -13
  233. package/dist/dashboard/asked.js +1 -1
  234. package/dist/dashboard/dice/burn.js +1 -1
  235. package/dist/dashboard/dice/stage.js +1 -1
  236. package/dist/dashboard/game-words.js +4 -4
  237. package/dist/dashboard/{guide-blocks.js → help/blocks.js} +1 -1
  238. package/dist/dashboard/{help.js → help/help.js} +6 -6
  239. package/dist/dashboard/journal.js +1 -1
  240. package/dist/dashboard/kit.js +6 -5
  241. package/dist/dashboard/labels.js +7 -3
  242. package/dist/dashboard/markdown.js +1 -1
  243. package/dist/dashboard/{ask-card.js → packages/ask-card.js} +6 -6
  244. package/dist/dashboard/{package-page.js → packages/package-page.js} +3 -3
  245. package/dist/dashboard/{packages.js → packages/packages.js} +12 -12
  246. package/dist/dashboard/{page-code.js → packages/page-code.js} +4 -4
  247. package/dist/dashboard/{extension-widgets.js → packages/widgets.js} +5 -5
  248. package/dist/dashboard/party.js +1 -1
  249. package/dist/dashboard/person-panel.js +2 -13
  250. package/dist/dashboard/{map-sheet.js → place/map-sheet.js} +4 -4
  251. package/dist/dashboard/{place-map-view.js → place/map-view.js} +11 -11
  252. package/dist/dashboard/scene.js +4 -4
  253. package/dist/dashboard/settings.js +1 -1
  254. package/dist/dashboard/sheet.js +4 -4
  255. package/dist/dashboard/text.js +6 -0
  256. package/dist/dashboard/top.js +2 -2
  257. package/dist/dashboard/turns.js +2 -2
  258. package/dist/dashboard/widgets.js +1 -1
  259. package/dist/dashboard/{world-calendar.js → world/calendar.js} +7 -7
  260. package/dist/dashboard/{lore.js → world/known.js} +1 -1
  261. package/dist/dashboard/{world-lore.js → world/lore.js} +9 -9
  262. package/dist/dashboard/{world-map.js → world/map.js} +1 -1
  263. package/dist/dashboard/{world.js → world/world.js} +14 -14
  264. package/dist/dice/evaluate.js +1 -1
  265. package/dist/dice/index.d.ts +2 -2
  266. package/dist/dice/index.js +2 -2
  267. package/dist/dice/notation.d.ts +2 -0
  268. package/dist/dice/notation.js +22 -4
  269. package/dist/documents/markup.js +2 -2
  270. package/dist/documents/read.js +29 -13
  271. package/dist/effects/effect.js +2 -5
  272. package/dist/extensions/extension.js +6 -8
  273. package/dist/extensions/index.d.ts +1 -4
  274. package/dist/extensions/index.js +1 -4
  275. package/dist/extensions/words.js +2 -1
  276. package/dist/{pictures → helpers}/briefs.js +17 -14
  277. package/dist/{pictures → helpers}/claude.js +8 -18
  278. package/dist/{pictures → helpers}/codex.js +3 -15
  279. package/dist/helpers/index.d.ts +7 -0
  280. package/dist/helpers/index.js +9 -0
  281. package/dist/{pictures/helpers.d.ts → helpers/programs.d.ts} +6 -1
  282. package/dist/{pictures/helpers.js → helpers/programs.js} +16 -2
  283. package/dist/images/images.js +7 -5
  284. package/dist/images/index.d.ts +1 -1
  285. package/dist/images/index.js +1 -1
  286. package/dist/importer/index.d.ts +1 -1
  287. package/dist/importer/index.js +1 -1
  288. package/dist/importer/work.d.ts +0 -2
  289. package/dist/importer/work.js +9 -30
  290. package/dist/instructions/index.d.ts +2 -0
  291. package/dist/instructions/index.js +10 -0
  292. package/dist/languages/index.d.ts +1 -1
  293. package/dist/languages/index.js +1 -1
  294. package/dist/languages/language-pack.js +15 -3
  295. package/dist/library/books.js +29 -83
  296. package/dist/{extensions → packages}/engine.d.ts +1 -1
  297. package/dist/{extensions → packages}/engine.js +1 -1
  298. package/dist/packages/index.d.ts +3 -0
  299. package/dist/packages/index.js +4 -0
  300. package/dist/{extensions/packages.d.ts → packages/npm.d.ts} +2 -0
  301. package/dist/{extensions/packages.js → packages/npm.js} +74 -45
  302. package/dist/page.d.ts +9 -11
  303. package/dist/page.js +1 -2
  304. package/dist/pages/check.js +31 -40
  305. package/dist/pages/containers.js +20 -20
  306. package/dist/pages/environment.js +15 -15
  307. package/dist/pages/index.d.ts +9 -9
  308. package/dist/pages/index.js +9 -9
  309. package/dist/pages/inheritance.d.ts +2 -1
  310. package/dist/pages/inheritance.js +24 -24
  311. package/dist/pages/load.js +7 -7
  312. package/dist/pages/maps.d.ts +20 -0
  313. package/dist/pages/maps.js +51 -1
  314. package/dist/pages/markdown.d.ts +2 -0
  315. package/dist/pages/markdown.js +110 -79
  316. package/dist/pages/page-file.d.ts +2 -1
  317. package/dist/pages/page-file.js +31 -29
  318. package/dist/pages/rename-page.d.ts +4 -1
  319. package/dist/pages/rename-page.js +7 -3
  320. package/dist/pages/{stack-entry.d.ts → stacks/entry.d.ts} +0 -2
  321. package/dist/pages/{stack-entry.js → stacks/entry.js} +2 -6
  322. package/dist/pages/{stacks.d.ts → stacks/kinds.d.ts} +8 -1
  323. package/dist/pages/{stacks.js → stacks/kinds.js} +36 -41
  324. package/dist/pages/{stack-writes.d.ts → stacks/writes.d.ts} +2 -2
  325. package/dist/pages/{stack-writes.js → stacks/writes.js} +32 -32
  326. package/dist/pages/system-pages.js +15 -15
  327. package/dist/pages/world.d.ts +4 -0
  328. package/dist/pages/world.js +52 -20
  329. package/dist/pages/write-page.js +35 -34
  330. package/dist/player-notes/index.d.ts +1 -1
  331. package/dist/player-notes/index.js +1 -1
  332. package/dist/rules/page-search.js +3 -4
  333. package/dist/rules/rule-book.js +1 -1
  334. package/dist/rules/search.js +21 -21
  335. package/dist/rules/shown.js +1 -3
  336. package/dist/saves/saves.d.ts +2 -2
  337. package/dist/saves/saves.js +15 -3
  338. package/dist/{bell-listener.js → server/bell-listener.js} +3 -3
  339. package/dist/server/dashboard/files.d.ts +59 -0
  340. package/dist/server/dashboard/files.js +326 -0
  341. package/dist/server/dashboard/index.d.ts +114 -0
  342. package/dist/server/dashboard/index.js +419 -0
  343. package/dist/server/dashboard/news.d.ts +39 -0
  344. package/dist/server/dashboard/news.js +390 -0
  345. package/dist/server/dashboard/player.d.ts +48 -0
  346. package/dist/server/dashboard/player.js +242 -0
  347. package/dist/server/dashboard/ports.d.ts +10 -0
  348. package/dist/server/dashboard/ports.js +15 -0
  349. package/dist/server/dashboard/writes.d.ts +58 -0
  350. package/dist/server/dashboard/writes.js +492 -0
  351. package/dist/{mcp-server.d.ts → server/mcp.d.ts} +2 -2
  352. package/dist/{mcp-server.js → server/mcp.js} +57 -42
  353. package/dist/systems/game-system.d.ts +5 -3
  354. package/dist/systems/game-system.js +178 -149
  355. package/dist/systems/index.d.ts +1 -1
  356. package/dist/systems/index.js +1 -1
  357. package/dist/{testing.d.ts → testing/index.d.ts} +6 -6
  358. package/dist/{testing.js → testing/index.js} +32 -18
  359. package/dist/{system-checks.js → testing/system-checks.js} +18 -12
  360. package/dist/themes/theme.d.ts +3 -3
  361. package/dist/themes/theme.js +14 -14
  362. package/dist/time/calendar.js +5 -2
  363. package/dist/triggers/trigger.js +5 -8
  364. package/instructions/dashboard-guide.md +2 -1
  365. package/instructions/play.md +1 -1
  366. package/package.json +5 -5
  367. package/dist/commands/game-maps.d.ts +0 -20
  368. package/dist/commands/game-maps.js +0 -51
  369. package/dist/commands/game-rules.js +0 -36
  370. package/dist/dashboard-server.d.ts +0 -47
  371. package/dist/dashboard-server.js +0 -1830
  372. package/dist/pictures/index.d.ts +0 -7
  373. package/dist/pictures/index.js +0 -9
  374. /package/dist/{cli.d.ts → cli/cli.d.ts} +0 -0
  375. /package/dist/{library-reader.d.ts → commands/shared/library-reader.d.ts} +0 -0
  376. /package/dist/commands/{notes.d.ts → shared/notes.d.ts} +0 -0
  377. /package/dist/commands/{notes.js → shared/notes.js} +0 -0
  378. /package/dist/dashboard/{guide-markdown.js → help/markdown.js} +0 -0
  379. /package/dist/dashboard/{pack-card.js → packages/card.js} +0 -0
  380. /package/dist/dashboard/{people.js → packages/people.js} +0 -0
  381. /package/dist/dashboard/{place-map.js → place/map.js} +0 -0
  382. /package/dist/dashboard/{calendar.js → world/days.js} +0 -0
  383. /package/dist/{pictures → helpers}/briefs.d.ts +0 -0
  384. /package/dist/{pictures → helpers}/chosen.d.ts +0 -0
  385. /package/dist/{pictures → helpers}/chosen.js +0 -0
  386. /package/dist/{pictures → helpers}/claude.d.ts +0 -0
  387. /package/dist/{pictures → helpers}/codex.d.ts +0 -0
  388. /package/dist/{pictures → helpers}/stop.d.ts +0 -0
  389. /package/dist/{pictures → helpers}/stop.js +0 -0
  390. /package/dist/{pictures → helpers}/svg.d.ts +0 -0
  391. /package/dist/{pictures → helpers}/svg.js +0 -0
  392. /package/dist/{extensions → packages}/tarball.d.ts +0 -0
  393. /package/dist/{extensions → packages}/tarball.js +0 -0
  394. /package/dist/{bell-listener.d.ts → server/bell-listener.d.ts} +0 -0
  395. /package/dist/{player-acts.d.ts → server/player-acts.d.ts} +0 -0
  396. /package/dist/{player-acts.js → server/player-acts.js} +0 -0
  397. /package/dist/{system-checks.d.ts → testing/system-checks.d.ts} +0 -0
@@ -5,7 +5,7 @@ import { installedFromFolder, packageFoldersIn, realPath } from "../core/files.j
5
5
  import { readParts } from "../core/instruction-parts.js";
6
6
  import { apiProblem, declaredWidgets, packagePartsIssues, packagePartsShape } from "../core/package-declarations.js";
7
7
  import { files, isInside } from "../core/store.js";
8
- import { comparableText } from "../core/text.js";
8
+ import { comparableText, wordCount } from "../core/text.js";
9
9
  import { readYamlValues } from "../core/yaml-file.js";
10
10
  /** The file that makes a folder an extension of rpg-engine (D-427). */
11
11
  export const extensionFileName = "extension.yaml";
@@ -57,8 +57,9 @@ export function installedExtensions(folders) {
57
57
  }
58
58
  /** The installed extension of this package, as npm or campaign.yaml names it, or by its name alone (weather); undefined when none is. It throws when it does not read. */
59
59
  export function findExtension(folders, wanted) {
60
- const named = (candidate) => candidate === wanted.trim() || comparableText(shortName(candidate)) === comparableText(wanted.trim());
61
- const found = installedExtensions(folders).find((candidate) => named(candidate.package));
60
+ // A package's whole name first: another's skies is never taken for @rpgengine/skies, nor the other way.
61
+ const installed = installedExtensions(folders);
62
+ const found = installed.find((candidate) => candidate.package === wanted.trim()) ?? installed.find((candidate) => comparableText(shortName(candidate.package)) === comparableText(wanted.trim()));
62
63
  return found === undefined ? undefined : readExtension(found.folder);
63
64
  }
64
65
  /** An extension from its folder: its package.json and its extension.yaml, refused with what is wrong (D-427). */
@@ -90,9 +91,9 @@ export function readExtension(folder) {
90
91
  const parts = readParts(folder, owner);
91
92
  // What the master reads of it in every chat, kept short (D-441).
92
93
  const long = [["about", about, aboutWords], ...Object.entries(parts).map(([name, part]) => [`instructions/${name}.md`, part.text, partWords])]
93
- .find(([, text, most]) => words(text) > most);
94
+ .find(([, text, most]) => wordCount(text) > most);
94
95
  if (long !== undefined) {
95
- throw new Error(`${owner} cannot be used, because its ${long[0]} has ${words(long[1])} words, and ${long[2]} at most are read.`);
96
+ throw new Error(`${owner} cannot be used, because its ${long[0]} has ${wordCount(long[1])} words, and ${long[2]} at most are read.`);
96
97
  }
97
98
  return {
98
99
  kind: "extension",
@@ -137,6 +138,3 @@ function readJson(path) {
137
138
  return undefined;
138
139
  }
139
140
  }
140
- function words(text) {
141
- return text.split(/\s+/).filter((word) => word !== "").length;
142
- }
@@ -1,6 +1,3 @@
1
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";
4
- export { isLocalSpec, issuesPage, isVerified, npmPackages, packageKeyword, verifiedScope } from "./packages.ts";
5
- export { isTarball } from "./tarball.ts";
2
+ export { type CodePackage, type Extension, findExtension, installedExtensions, readExtension, shortName, type SystemAdditions } from "./extension.ts";
6
3
  export { type ExtensionWords, extensionWords, wordIn } from "./words.ts";
@@ -1,7 +1,4 @@
1
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
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";
5
- export { isLocalSpec, issuesPage, isVerified, npmPackages, packageKeyword, verifiedScope } from "./packages.js";
6
- export { isTarball } from "./tarball.js";
3
+ export { findExtension, installedExtensions, readExtension, shortName } from "./extension.js";
7
4
  export { extensionWords, wordIn } from "./words.js";
@@ -34,7 +34,8 @@ export function wordIn(words, text) {
34
34
  }
35
35
  const first = text.charAt(0);
36
36
  const other = first === first.toLowerCase() ? first.toUpperCase() : first.toLowerCase();
37
- const found = list[`${other}${text.slice(1)}`];
37
+ const key = `${other}${text.slice(1)}`;
38
+ const found = Object.hasOwn(list, key) ? list[key] : undefined;
38
39
  if (found === undefined) {
39
40
  return text;
40
41
  }
@@ -14,13 +14,12 @@ export function paintedBrief(subject) {
14
14
  */
15
15
  export function placeBrief(name, seen, unseen = []) {
16
16
  return [
17
- "Use your built-in image generation tool to make exactly one new image from the brief below. Do not copy, save or edit any file and run no commands: "
18
- + 'the caller collects the image itself. If you cannot make it, reply with one line saying why; otherwise reply with only "done".',
17
+ imageAsk,
19
18
  "",
20
19
  "Use case: illustration-story",
21
20
  "Asset type: wide banner for the location screen of a tabletop role-playing game, landscape, 21:9",
22
21
  `Primary request: ${name}, as adventurers see it arriving: ${seen}`,
23
- "Style/medium: painterly digital illustration, fantasy concept art, muted natural colours, soft brushwork",
22
+ paintedStyle,
24
23
  "Composition/framing: wide establishing shot at eye level, the subject in the middle third, edges that can be cropped",
25
24
  "Constraints: show only what is described; no people or creatures; no text, letters, numbers, signs, captions, logos, watermark or frame",
26
25
  ...(unseen.length === 0 ? [] : [`Never show: ${unseen.join("; ")}`]),
@@ -32,13 +31,12 @@ export function placeBrief(name, seen, unseen = []) {
32
31
  */
33
32
  export function questBrief(name, known, unseen = []) {
34
33
  return [
35
- "Use your built-in image generation tool to make exactly one new image from the brief below. Do not copy, save or edit any file and run no commands: "
36
- + 'the caller collects the image itself. If you cannot make it, reply with one line saying why; otherwise reply with only "done".',
34
+ imageAsk,
37
35
  "",
38
36
  "Use case: illustration-story",
39
37
  "Asset type: wide low banner for a quest card of a tabletop role-playing game, landscape, 16:6",
40
38
  `Primary request: the quest ${name}, as an emblem of what it is about: ${known}`,
41
- "Style/medium: painterly digital illustration, fantasy concept art, muted natural colours, soft brushwork",
39
+ paintedStyle,
42
40
  "Composition/framing: the subject in the middle third, half of the height shown, edges that can be cropped",
43
41
  "Constraints: people or creatures only as small distant figures, never faces; no text, letters, numbers, signs, captions, logos, watermark or frame",
44
42
  ...(unseen.length === 0 ? [] : [`Never show: ${unseen.join("; ")}`]),
@@ -50,14 +48,13 @@ export function questBrief(name, known, unseen = []) {
50
48
  */
51
49
  export function portraitBrief(name, seen, unseen = [], who) {
52
50
  return [
53
- "Use your built-in image generation tool to make exactly one new image from the brief below. Do not copy, save or edit any file and run no commands: "
54
- + 'the caller collects the image itself. If you cannot make it, reply with one line saying why; otherwise reply with only "done".',
51
+ imageAsk,
55
52
  "",
56
53
  "Use case: illustration-story",
57
54
  "Asset type: square portrait for the round token of a character of a tabletop role-playing game, 1:1",
58
55
  ...portraitRequest(name, seen, who),
59
- "Style/medium: painterly digital illustration, fantasy concept art, muted natural colours, soft brushwork",
60
- "Composition/framing: a close-up of the face, centred, from the top of the head to the chin and only a hint of the shoulders, the face filling most of the picture; a plain softly lit background, nothing that matters near the corners, which a circle crops",
56
+ paintedStyle,
57
+ `Composition/framing: ${faceFraming}`,
61
58
  "Constraints: this one figure alone; no text, letters, numbers, signs, captions, logos, watermark or frame",
62
59
  ...(unseen.length === 0 ? [] : [`Never show: ${unseen.join("; ")}`]),
63
60
  ].join("\n");
@@ -68,18 +65,24 @@ export function portraitBrief(name, seen, unseen = [], who) {
68
65
  */
69
66
  export function creatureBrief(name, seen, unseen = [], who) {
70
67
  return [
71
- "Use your built-in image generation tool to make exactly one new image from the brief below. Do not copy, save or edit any file and run no commands: "
72
- + 'the caller collects the image itself. If you cannot make it, reply with one line saying why; otherwise reply with only "done".',
68
+ imageAsk,
73
69
  "",
74
70
  "Use case: illustration-story",
75
71
  "Asset type: square picture of a creature for the round token of a tabletop role-playing game, 1:1",
76
72
  ...creatureRequest(name, seen, who),
77
- "Style/medium: painterly digital illustration, fantasy concept art, muted natural colours, soft brushwork",
73
+ paintedStyle,
78
74
  `Composition/framing: ${creatureFraming}`,
79
75
  "Constraints: this one creature alone; no text, letters, numbers, signs, captions, logos, watermark or frame",
80
76
  ...(unseen.length === 0 ? [] : [`Never show: ${unseen.join("; ")}`]),
81
77
  ].join("\n");
82
78
  }
79
+ // What every brief asks of the helper first, and the style every picture is painted in.
80
+ const imageAsk = "Use your built-in image generation tool to make exactly one new image from the brief below. Do not copy, save or edit any file and run no commands: "
81
+ + 'the caller collects the image itself. If you cannot make it, reply with one line saying why; otherwise reply with only "done".';
82
+ const paintedStyle = "Style/medium: painterly digital illustration, fantasy concept art, muted natural colours, soft brushwork";
83
+ // A portrait, a person's or a creature's, as a circle crops it.
84
+ const faceFraming = "a close-up of the face, centred, from the top of the head to the chin and only a hint of the shoulders, the face filling most of the picture; "
85
+ + "a plain softly lit background, nothing that matters near the corners, which a circle crops";
83
86
  const creatureFraming = "a close-up of the head, its face or muzzle centred and filling most of the picture, only a hint of the neck; "
84
87
  + "a plain softly lit background, nothing that matters near the corners, which a circle crops";
85
88
  // The SVG drawing as a probe proved it: depth from layers and gradients, a sober palette, and only the elements the engine keeps.
@@ -96,7 +99,7 @@ export function svgBrief(subject) {
96
99
  'Asset type: square portrait for the round token of a character of a tabletop role-playing game, viewBox="0 0 1024 1024" (1:1)',
97
100
  ...portraitRequest(subject.name, subject.seen, subject.who),
98
101
  svgStyle,
99
- "Composition/framing: a close-up of the face, centred, from the top of the head to the chin and only a hint of the shoulders, the face filling most of the picture; a plain softly lit background, nothing that matters near the corners, which a circle crops",
102
+ `Composition/framing: ${faceFraming}`,
100
103
  "Constraints: this one figure alone; no text, letters, numbers, signs, logos or frame",
101
104
  ];
102
105
  const creature = [
@@ -5,19 +5,19 @@ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
5
5
  import { tmpdir } from "node:os";
6
6
  import { join } from "node:path";
7
7
  import { svgBrief } from "./briefs.js";
8
- import { helperChanges, helperEnvironment, helperState } from "./helpers.js";
8
+ import { helperEnvironment, helperState, knownReady } from "./programs.js";
9
9
  import { stopTree } from "./stop.js";
10
10
  import { cleanSvg, svgIn } from "./svg.js";
11
11
  // How long a picture may take before the engine gives it up: the probe's took 18 to 74 seconds.
12
12
  const longest = 3 * 60 * 1000;
13
13
  // How long a run of the importer may take: Elena's probe read sixteen pages in about four minutes (D-489).
14
14
  const longestReading = 30 * 60 * 1000;
15
- // Claude Code without the chat's own settings, tools, memory or session: only the brief, and the SVG as its answer.
16
- const drawing = (claude) => `${claude} -p --model sonnet --effort low --output-format json --tools "" --setting-sources "" --strict-mcp-config --no-session-persistence `
17
- + `--disable-slash-commands --max-budget-usd 0.5 --system-prompt "You draw pictures as SVG code from a brief. You reply with the SVG alone."`;
18
- // Claude Code as a writer of text (D-406): Sonnet at low effort, with nothing but the brief.
19
- const writing = (claude) => `${claude} -p --model sonnet --effort low --output-format json --tools "" --setting-sources "" --strict-mcp-config --no-session-persistence `
20
- + `--disable-slash-commands --max-budget-usd 0.5 --system-prompt "You write what a brief asks, and only that."`;
15
+ // Claude Code without the chat's own settings, tools, memory or session, Sonnet at low effort: only the brief, and what the system prompt asks as its answer.
16
+ const briefOnly = (claude, prompt) => `${claude} -p --model sonnet --effort low --output-format json --tools "" --setting-sources "" --strict-mcp-config --no-session-persistence `
17
+ + `--disable-slash-commands --max-budget-usd 0.5 --system-prompt "${prompt}"`;
18
+ // The SVG as its answer, and a writer of text (D-406).
19
+ const drawing = (claude) => briefOnly(claude, "You draw pictures as SVG code from a brief. You reply with the SVG alone.");
20
+ const writing = (claude) => briefOnly(claude, "You write what a brief asks, and only that.");
21
21
  /** Claude Code on this computer as a writer of text (D-406): ready where the player's Claude login lets it draw too. */
22
22
  export function claudeWriter(maker = claudePictures()) {
23
23
  return { ready: () => maker.ready().ready, write };
@@ -35,17 +35,7 @@ export const claudeSays = {
35
35
  let claude = "claude";
36
36
  /** Claude Code on this computer, as the player's Claude login lets it draw pictures. */
37
37
  export function claudePictures() {
38
- let known;
39
- return {
40
- ready: (again) => {
41
- const late = again === true && Date.now() - (known?.at ?? 0) > 60_000;
42
- if (known === undefined || (!known.said.ready && (late || known.changes !== helperChanges()))) {
43
- known = { said: claudeReady(), at: Date.now(), changes: helperChanges() };
44
- }
45
- return known.said;
46
- },
47
- make,
48
- };
38
+ return { ready: knownReady(claudeReady), make };
49
39
  }
50
40
  /** Whether Claude Code is there and logged in with the player's Claude plan: asked in a moment, without spending anything. */
51
41
  function claudeReady() {
@@ -6,7 +6,7 @@ import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync } from "node
6
6
  import { homedir, tmpdir } from "node:os";
7
7
  import { join } from "node:path";
8
8
  import { paintedBrief } from "./briefs.js";
9
- import { helperChanges, helperEnvironment, helperState } from "./helpers.js";
9
+ import { helperEnvironment, helperState, knownReady } from "./programs.js";
10
10
  import { stopTree } from "./stop.js";
11
11
  // How long a picture may take before the engine gives it up (D-308): the probe's took 31 to 45 seconds.
12
12
  const longest = 3 * 60 * 1000;
@@ -40,19 +40,7 @@ export const codexSays = {
40
40
  let codex = "codex";
41
41
  /** Codex on this computer, as the player's ChatGPT login lets it make pictures. */
42
42
  export function codexPictures() {
43
- let known;
44
- return {
45
- // Asked once; a no again after a minute, only where the player may be waiting for it, as Settings and image: never on every call of the master; and
46
- // again at once after a program came ready here, as after the player signs in (D-424).
47
- ready: (again) => {
48
- const late = again === true && Date.now() - (known?.at ?? 0) > 60_000;
49
- if (known === undefined || (!known.said.ready && (late || known.changes !== helperChanges()))) {
50
- known = { said: codexReady(), at: Date.now(), changes: helperChanges() };
51
- }
52
- return known.said;
53
- },
54
- make,
55
- };
43
+ return { ready: knownReady(codexReady), make };
56
44
  }
57
45
  /** Codex on this computer as a writer of text (D-406): ready where its ChatGPT login makes pictures too. */
58
46
  export function codexWriter(maker = codexPictures()) {
@@ -99,7 +87,7 @@ function make(subject) {
99
87
  }
100
88
  });
101
89
  const thread = events.find((event) => event.type === "thread.started")?.thread_id;
102
- const pictures = typeof thread === "string" ? join(process.env.CODEX_HOME ?? join(homedir(), ".codex"), "generated_images", thread) : undefined;
90
+ const pictures = typeof thread === "string" ? join(process.env.CODEX_HOME || join(homedir(), ".codex"), "generated_images", thread) : undefined;
103
91
  const file = pictures === undefined || !existsSync(pictures) ? undefined : readdirSync(pictures).find((name) => name.toLowerCase().endsWith(".png"));
104
92
  const clean = () => {
105
93
  rmSync(folder, { recursive: true, force: true });
@@ -0,0 +1,7 @@
1
+ export { paintedBrief, svgBrief } from "./briefs.ts";
2
+ export { codexClient, hostPictures, hostReader, hostWriter } from "./chosen.ts";
3
+ export { claudeSays } from "./claude.ts";
4
+ export { codexPictures, codexSays } from "./codex.ts";
5
+ export { computerHelpers, helperChanges, helperCommand, queueInCodex } from "./programs.ts";
6
+ export { stopProcess } from "./stop.ts";
7
+ export { cleanSvg, svgIn } from "./svg.ts";
@@ -0,0 +1,9 @@
1
+ // Codex and Claude Code on the player's computer, found, installed and signed in with the player's yes (D-424), and what they do for the game: pictures made
2
+ // from words (D-308, D-390), Codex's painted else Claude's SVG, the importer's reading and the page's words; injected through Context, so that tests never spend.
3
+ export { paintedBrief, svgBrief } from "./briefs.js";
4
+ export { codexClient, hostPictures, hostReader, hostWriter } from "./chosen.js";
5
+ export { claudeSays } from "./claude.js";
6
+ export { codexPictures, codexSays } from "./codex.js";
7
+ export { computerHelpers, helperChanges, helperCommand, queueInCodex } from "./programs.js";
8
+ export { stopProcess } from "./stop.js";
9
+ export { cleanSvg, svgIn } from "./svg.js";
@@ -1,4 +1,4 @@
1
- import type { HelperLogin, HelperName, Helpers, HelperState } from "../core/context.ts";
1
+ import type { HelperLogin, HelperName, Helpers, HelperState, PicturesReady } from "../core/context.ts";
2
2
  /** Codex and Claude Code on this computer, the engine's own folder in `folder`. */
3
3
  export declare function computerHelpers(folder?: string): Helpers;
4
4
  /** Where the engine keeps the programs it installs: the player's local data, as they weigh hundreds of megabytes (D-425). */
@@ -12,6 +12,11 @@ export declare function helperState(name: HelperName, folder?: string): {
12
12
  };
13
13
  /** How many times a program came ready on this computer since the engine started: a maker that said no asks again after one. */
14
14
  export declare function helperChanges(): number;
15
+ /**
16
+ * A maker's ready, as its `check` says it: asked once; a no again after a minute, only where the player may be waiting for it, as Settings and image, never on
17
+ * every call of the master; and again at once after a program came ready here, as after the player signs in (D-424).
18
+ */
19
+ export declare function knownReady(check: () => PicturesReady): (again?: boolean) => PicturesReady;
15
20
  /**
16
21
  * The environment of a program: the chat's variables and any API key taken away, where its login and its shell are kept (D-342, D-425); and on Windows the shell
17
22
  * told not to look for programs in the folder it starts in, which could be a campaign's.
@@ -13,6 +13,8 @@ const loginWait = 10 * 60 * 1000;
13
13
  const linkWait = 5000;
14
14
  // How long an installation may take: the probe's took 13 to 21 seconds.
15
15
  const installWait = 5 * 60 * 1000;
16
+ // How long Codex may take to queue a message: the probe's took well under a second.
17
+ const queueWait = 15_000;
16
18
  // The sign-ins under way, or failed and not yet told, by program; the installations under way; how each program stood when last asked; and how many times one
17
19
  // came ready here, after which the makers of pictures ask again.
18
20
  const logins = new Map();
@@ -105,6 +107,20 @@ export function helperState(name, folder = toolsFolder()) {
105
107
  export function helperChanges() {
106
108
  return changes;
107
109
  }
110
+ /**
111
+ * A maker's ready, as its `check` says it: asked once; a no again after a minute, only where the player may be waiting for it, as Settings and image, never on
112
+ * every call of the master; and again at once after a program came ready here, as after the player signs in (D-424).
113
+ */
114
+ export function knownReady(check) {
115
+ let known;
116
+ return (again) => {
117
+ const late = again === true && Date.now() - (known?.at ?? 0) > 60_000;
118
+ if (known === undefined || (!known.said.ready && (late || known.changes !== changes))) {
119
+ known = { said: check(), at: Date.now(), changes };
120
+ }
121
+ return known.said;
122
+ };
123
+ }
108
124
  /**
109
125
  * The environment of a program: the chat's variables and any API key taken away, where its login and its shell are kept (D-342, D-425); and on Windows the shell
110
126
  * told not to look for programs in the folder it starts in, which could be a campaign's.
@@ -217,8 +233,6 @@ export function queueInCodex(thread, message, folder = toolsFolder()) {
217
233
  });
218
234
  });
219
235
  }
220
- // How long Codex may take to queue a message: the probe's took well under a second.
221
- const queueWait = 15_000;
222
236
  /** The file a package's bin names for a program, in a node_modules folder; undefined where it is not there. */
223
237
  function packageBin(name, modules) {
224
238
  const packageFolder = join(modules, ...packages[name].split("/"));
@@ -9,7 +9,12 @@ export const largestImage = 5 * 1024 * 1024;
9
9
  export const imageExtensions = ["png", "jpg", "webp", "svg"];
10
10
  /** Reads the picture at `path`, by what its bytes are rather than by its extension: PNG, JPEG, WebP or SVG, up to largestImage. */
11
11
  export function readImage(path) {
12
- const bytes = files().bytes(path);
12
+ // Its size first, from the disk: a file of gigabytes is never read to be refused.
13
+ const size = files().size(path);
14
+ if (size !== undefined && size > largestImage) {
15
+ return { problem: `${basename(path)} is ${megabytes(size)} MB, and a picture can be ${megabytes(largestImage)} MB at most: make it smaller (512 pixels a side are enough).` };
16
+ }
17
+ const bytes = size === undefined ? undefined : files().bytes(path);
13
18
  if (bytes === undefined) {
14
19
  return { problem: `There is no file at ${path}: give the full path of the picture.` };
15
20
  }
@@ -17,9 +22,6 @@ export function readImage(path) {
17
22
  if (extension === undefined) {
18
23
  return { problem: `${basename(path)} is not a PNG, JPEG, WebP or SVG picture: convert it to one of those, or give another file.` };
19
24
  }
20
- if (bytes.length > largestImage) {
21
- return { problem: `${basename(path)} is ${megabytes(bytes.length)} MB, and a picture can be ${megabytes(largestImage)} MB at most: make it smaller (512 pixels a side are enough).` };
22
- }
23
25
  return { bytes, extension };
24
26
  }
25
27
  /** The file named `name` in the images folder of the first of `folders` that has one, looked for in the folders inside it too; undefined when none has it. */
@@ -61,7 +63,7 @@ const isFormat = {
61
63
  jpg: (bytes) => startsWith(bytes, [0xff, 0xd8, 0xff]),
62
64
  webp: (bytes) => ascii(bytes, 0, 4) === "RIFF" && ascii(bytes, 8, 12) === "WEBP",
63
65
  // An SVG is text: its root element comes after an XML declaration, a doctype or comments, if any.
64
- svg: (bytes) => /^(?:)?\s*(?:<\?xml[^>]*>\s*)?(?:(?:<!--[\s\S]*?-->|<!DOCTYPE[^>]*>)\s*)*<svg[\s>]/i.test(new TextDecoder().decode(bytes.subarray(0, 4096))),
66
+ svg: (bytes) => /^(?:\uFEFF)?\s*(?:<\?xml[^>]*>\s*)?(?:(?:<!--[\s\S]*?-->|<!DOCTYPE[^>]*>)\s*)*<svg[\s>]/i.test(new TextDecoder().decode(bytes.subarray(0, 4096))),
65
67
  };
66
68
  function startsWith(bytes, prefix) {
67
69
  return prefix.every((byte, index) => bytes[index] === byte);
@@ -1 +1 @@
1
- export { findHiddenImage, findImage, hiddenImageName, type ImageExtension, imageExtensions, imageFileName, imageLink, imagesFolderName, largestImage, type ReadImage, readImage } from "./images.ts";
1
+ export { findHiddenImage, findImage, hiddenImageName, type ImageExtension, imageFileName, imageLink, imagesFolderName, largestImage, type ReadImage, readImage } from "./images.ts";
@@ -1,2 +1,2 @@
1
1
  // Pictures of pages: the formats a picture can have, and where the file a page links is (D-267). It knows no game.
2
- export { findHiddenImage, findImage, hiddenImageName, imageExtensions, imageFileName, imageLink, imagesFolderName, largestImage, readImage } from "./images.js";
2
+ export { findHiddenImage, findImage, hiddenImageName, imageFileName, imageLink, imagesFolderName, largestImage, readImage } from "./images.js";
@@ -1 +1 @@
1
- export { beginOpening, claimImport, clearOpening, doneImports, dropDocumentText, dropImport, finishAdventure, hasImport, importAge, importDate, importedPages, type ImportedText, importFile, importFolder, importPiece, importsFolderName, type ImportStart, importStarts, type ImportState, importStyle, isOwnOpening, markOpening, openImport, type OpeningImport, openingImport, openLicense, pieceName, prepareImport, readImportState, releaseImport, runElsewhere, textSize, writeImportState, } from "./work.ts";
1
+ export { beginOpening, claimImport, clearOpening, doneImports, dropDocumentText, dropImport, finishAdventure, hasImport, importAge, importDate, importedPages, type ImportedText, importFile, importFolder, importPiece, type ImportStart, importStarts, type ImportState, importStyle, isOwnOpening, markOpening, openImport, type OpeningImport, openingImport, openLicense, pieceName, prepareImport, readImportState, releaseImport, runElsewhere, writeImportState, } from "./work.ts";
@@ -1,3 +1,3 @@
1
1
  // The importer's folder (D-489): the player's document in pieces, how far the import is, and the adventure the helper writes. Depends on nothing else in
2
2
  // rpg-engine.
3
- export { beginOpening, claimImport, clearOpening, doneImports, dropDocumentText, dropImport, finishAdventure, hasImport, importAge, importDate, importedPages, importFile, importFolder, importPiece, importsFolderName, importStarts, importStyle, isOwnOpening, markOpening, openImport, openingImport, openLicense, pieceName, prepareImport, readImportState, releaseImport, runElsewhere, textSize, writeImportState, } from "./work.js";
3
+ export { beginOpening, claimImport, clearOpening, doneImports, dropDocumentText, dropImport, finishAdventure, hasImport, importAge, importDate, importedPages, importFile, importFolder, importPiece, importStarts, importStyle, isOwnOpening, markOpening, openImport, openingImport, openLicense, pieceName, prepareImport, readImportState, releaseImport, runElsewhere, writeImportState, } from "./work.js";
@@ -128,5 +128,3 @@ export declare function finishAdventure(folder: string, title: string, language:
128
128
  export declare function openLicense(license: string): string | undefined;
129
129
  /** The file of a piece of the document, from the first. */
130
130
  export declare function pieceName(index: number): string;
131
- /** How long a text is, in words: a Chinese, Japanese or Korean letter counts as one, as a model reads it; else about six letters a word. */
132
- export declare function textSize(text: string): number;
@@ -3,6 +3,8 @@
3
3
  import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
4
4
  import { basename, join } from "node:path";
5
5
  import { parse, stringify } from "yaml";
6
+ import { claimMark, isAlive, markHolder, releaseMark } from "../core/process-mark.js";
7
+ import { textSize } from "../core/text.js";
6
8
  /** The folder of the campaign where imports are worked on, apart from its world. */
7
9
  export const importsFolderName = ".imports";
8
10
  // About sixteen printed pages a piece, what Elena's probe read well in one run (D-489).
@@ -69,26 +71,16 @@ export function writeImportState(folder, state) {
69
71
  * another live process holds it.
70
72
  */
71
73
  export function claimImport(folder) {
72
- const file = join(folder, ".running");
73
- const holder = existsSync(file) ? Number(readFileSync(file, "utf8")) : undefined;
74
- if (holder !== undefined && holder !== process.pid && isAlive(holder)) {
75
- return false;
76
- }
77
- writeFileSync(file, String(process.pid));
78
- return true;
74
+ return claimMark(join(folder, ".running"));
79
75
  }
80
76
  /** The live process that runs the import now, other than this one, as the runner the MCP server started apart; undefined when none does. */
81
77
  export function runElsewhere(folder) {
82
- const file = join(folder, ".running");
83
- const holder = existsSync(file) ? Number(readFileSync(file, "utf8")) : undefined;
84
- return holder !== undefined && holder !== process.pid && isAlive(holder) ? holder : undefined;
78
+ const holder = markHolder(join(folder, ".running"));
79
+ return holder === process.pid ? undefined : holder;
85
80
  }
86
81
  /** Lets the import go, once this process stops running it. */
87
82
  export function releaseImport(folder) {
88
- const file = join(folder, ".running");
89
- if (existsSync(file) && Number(readFileSync(file, "utf8")) === process.pid) {
90
- rmSync(file, { force: true });
91
- }
83
+ releaseMark(join(folder, ".running"));
92
84
  }
93
85
  /** The import's folder made from a document: its text in pieces, each part headed by its label, its pictures, and the mark at the start of the reading. */
94
86
  export function prepareImport(folder, title, document, text) {
@@ -234,7 +226,8 @@ export function finishAdventure(folder, title, language) {
234
226
  for (const type of readdirSync(world, { withFileTypes: true }).filter((entry) => entry.isDirectory())) {
235
227
  for (const file of readdirSync(join(world, type.name)).filter((name) => name.endsWith(".md"))) {
236
228
  const image = /^\[\[([^\]|#]+)\]\]$/.exec(String(frontmatterOf(join(world, type.name, file)).image ?? "").trim())?.[1];
237
- if (image !== undefined && existsSync(join(pictures, image))) {
229
+ // A picture's name alone, never a path the helper wrote out of the pictures, as the document's own text (LIB-8).
230
+ if (image !== undefined && basename(image) === image && /\.(?:png|jpe?g|webp|svg)$/i.test(image) && existsSync(join(pictures, image))) {
238
231
  mkdirSync(join(folder, "adventure", "images"), { recursive: true });
239
232
  copyFileSync(join(pictures, image), join(folder, "adventure", "images", image));
240
233
  }
@@ -267,26 +260,12 @@ export function openLicense(license) {
267
260
  export function pieceName(index) {
268
261
  return `${String(index + 1).padStart(2, "0")}.md`;
269
262
  }
270
- /** How long a text is, in words: a Chinese, Japanese or Korean letter counts as one, as a model reads it; else about six letters a word. */
271
- export function textSize(text) {
272
- const letters = text.match(/[\u3040-\u30ff\u3400-\u9fff\uac00-\ud7af]/gu)?.length ?? 0;
273
- return Math.max(text.split(/\s+/).filter((word) => word !== "").length + letters, Math.ceil(text.length / 6));
274
- }
275
263
  function openingFile(root) {
276
264
  return join(root, importsFolderName, "opening.yaml");
277
265
  }
278
- function isAlive(pid) {
279
- try {
280
- process.kill(pid, 0);
281
- return true;
282
- }
283
- catch (error) {
284
- return error.code === "EPERM";
285
- }
286
- }
287
266
  // A page's frontmatter as YAML; nothing when it has none or it does not read.
288
267
  function frontmatterOf(path) {
289
- const match = /^?---\r?\n([\s\S]*?)\r?\n---/.exec(readFileSync(path, "utf8"));
268
+ const match = /^\uFEFF?---\r?\n([\s\S]*?)\r?\n---/.exec(readFileSync(path, "utf8"));
290
269
  try {
291
270
  const fields = match === null ? {} : parse(match[1] ?? "");
292
271
  return typeof fields === "object" && fields !== null ? fields : {};
@@ -18,6 +18,8 @@ export declare function buttonsInstructions(physicalDice: boolean): string;
18
18
  export declare function dashboardInstructions(link: string): string;
19
19
  /** The game master's full instructions, as the `instructions` command gives them. */
20
20
  export declare function masterInstructions(): string;
21
+ /** A section of the master's instructions by its title, up to the next one or the end, as the importer's brief takes the pages' rules; it throws when there is none. */
22
+ export declare function coreSection(title: string): string;
21
23
  /** The core's text of a part of the instructions that a situation opens, such as combat (D-121); undefined when the core has none. */
22
24
  export declare function corePart(name: string): string | undefined;
23
25
  /** A part through its layers, from the core up: each adds its text to those below, or takes their place when it says so (D-121); undefined when none has it. */
@@ -26,6 +26,16 @@ export function dashboardInstructions(link) {
26
26
  export function masterInstructions() {
27
27
  return readInstructions("core.md");
28
28
  }
29
+ /** A section of the master's instructions by its title, up to the next one or the end, as the importer's brief takes the pages' rules; it throws when there is none. */
30
+ export function coreSection(title) {
31
+ const lines = masterInstructions().split("\n");
32
+ const start = lines.findIndex((line) => line.trim() === `## ${title}`);
33
+ if (start === -1) {
34
+ throw new Error(`core.md has no section "${title}": the instructions changed, so the code that reads it must change with them.`);
35
+ }
36
+ const end = lines.findIndex((line, index) => index > start && line.startsWith("## "));
37
+ return lines.slice(start + 1, end === -1 ? undefined : end).join("\n").trim();
38
+ }
29
39
  /** The core's text of a part of the instructions that a situation opens, such as combat (D-121); undefined when the core has none. */
30
40
  export function corePart(name) {
31
41
  if (!/^[a-z][a-z0-9-]*$/.test(name)) {
@@ -1 +1 @@
1
- export { installedLanguages, languageFileName, type LanguagePack, languagePackFor, languagePackProblems, packGuide, packPhrases, packSystemFolder, readLanguagePack } from "./language-pack.ts";
1
+ export { installedLanguages, type LanguagePack, languagePackFor, languagePackProblems, packGuide, packPhrases, packSystemFolder, readLanguagePack } from "./language-pack.ts";
@@ -1,3 +1,3 @@
1
1
  // Languages as packages (D-485 (3)): a translation made by hand of the dashboard's phrases, its Guide and a game system's words, which comes before the
2
2
  // translation on the fly. Depends on nothing else in rpg-engine but the core.
3
- export { installedLanguages, languageFileName, languagePackFor, languagePackProblems, packGuide, packPhrases, packSystemFolder, readLanguagePack } from "./language-pack.js";
3
+ export { installedLanguages, languagePackFor, languagePackProblems, packGuide, packPhrases, packSystemFolder, readLanguagePack } from "./language-pack.js";
@@ -13,7 +13,7 @@ const languageSchema = z.object({
13
13
  }).strict();
14
14
  const phrasesSchema = z.record(z.string(), z.string());
15
15
  // Characters that turn the order of a text, which could make it read otherwise than it is.
16
- const turning = /[‪-‮⁦-⁩]/;
16
+ const turning = /[\u202A-\u202E\u2066-\u2069]/;
17
17
  /** The language packages in these folders, as npm keeps them, in scopes' folders too; the first by a code wins. */
18
18
  export function installedLanguages(folders) {
19
19
  const found = [];
@@ -47,7 +47,7 @@ export function readLanguagePack(folder) {
47
47
  }
48
48
  /** The dashboard's phrases the package translates, by their English; none when it has none that reads. */
49
49
  export function packPhrases(pack) {
50
- const read = phrasesSchema.safeParse(JSON.parse(files().text(join(pack.folder, "phrases.json")) ?? "{}"));
50
+ const read = phrasesSchema.safeParse(phrasesJson(pack));
51
51
  return read.success ? read.data : {};
52
52
  }
53
53
  /** The package's Guide, in markdown; undefined when it has none. */
@@ -64,7 +64,10 @@ export function packSystemFolder(pack, system) {
64
64
  * the order of a text. The English phrases it does not translate are only counted, and come from the next source.
65
65
  */
66
66
  export function languagePackProblems(pack, english) {
67
- const raw = JSON.parse(files().text(join(pack.folder, "phrases.json")) ?? "null");
67
+ const raw = phrasesJson(pack);
68
+ if (raw instanceof Error) {
69
+ return { problems: [`phrases.json does not read as JSON: ${raw.message}`], missing: english.length };
70
+ }
68
71
  if (!phrasesSchema.safeParse(raw).success) {
69
72
  return { problems: ["phrases.json is not an object from each English phrase to its translation"], missing: english.length };
70
73
  }
@@ -84,3 +87,12 @@ export function languagePackProblems(pack, english) {
84
87
  function packageFolders(folders) {
85
88
  return packageFoldersIn(folders).filter((candidate) => files().exists(join(candidate, languageFileName)));
86
89
  }
90
+ /** The package's phrases.json as JSON: undefined when it has none, the error when it does not read. */
91
+ function phrasesJson(pack) {
92
+ try {
93
+ return JSON.parse(files().text(join(pack.folder, "phrases.json")) ?? "null");
94
+ }
95
+ catch (error) {
96
+ return error instanceof Error ? error : new Error(String(error));
97
+ }
98
+ }