rpg-engine 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/dist/campaign/host-files.js +4 -1
  2. package/dist/campaign/index.d.ts +2 -1
  3. package/dist/campaign/index.js +2 -1
  4. package/dist/campaign/port.d.ts +6 -0
  5. package/dist/campaign/port.js +24 -0
  6. package/dist/campaign/settings.d.ts +17 -0
  7. package/dist/campaign/settings.js +24 -1
  8. package/dist/cli/cli.js +15 -0
  9. package/dist/commands/config/config.js +15 -1
  10. package/dist/commands/config/dashboard.d.ts +4 -0
  11. package/dist/commands/config/dashboard.js +37 -6
  12. package/dist/commands/config/shown.js +4 -0
  13. package/dist/commands/config/words.d.ts +3 -1
  14. package/dist/commands/config/words.js +28 -1
  15. package/dist/commands/mode.d.ts +1 -1
  16. package/dist/commands/package/data.js +27 -0
  17. package/dist/commands/package/theme.js +2 -1
  18. package/dist/commands/scene/scene.js +6 -1
  19. package/dist/commands/shared/books/adventures.d.ts +1 -0
  20. package/dist/commands/shared/books/adventures.js +1 -1
  21. package/dist/commands/shared/campaign/git.d.ts +25 -0
  22. package/dist/commands/shared/campaign/git.js +104 -0
  23. package/dist/commands/shared/campaign/saves.js +5 -1
  24. package/dist/commands/shared/packages/catalog.js +24 -5
  25. package/dist/commands/status.d.ts +1 -0
  26. package/dist/commands/status.js +8 -4
  27. package/dist/core/context.d.ts +2 -0
  28. package/dist/core/version.d.ts +2 -0
  29. package/dist/core/version.js +5 -0
  30. package/dist/dashboard/guide/ar.md +6 -4
  31. package/dist/dashboard/guide/cs.md +6 -4
  32. package/dist/dashboard/guide/da.md +6 -4
  33. package/dist/dashboard/guide/de.md +8 -6
  34. package/dist/dashboard/guide/el.md +6 -4
  35. package/dist/dashboard/guide/en.md +5 -3
  36. package/dist/dashboard/guide/es.md +6 -4
  37. package/dist/dashboard/guide/fi.md +6 -4
  38. package/dist/dashboard/guide/fr.md +6 -4
  39. package/dist/dashboard/guide/he.md +6 -4
  40. package/dist/dashboard/guide/hi.md +6 -4
  41. package/dist/dashboard/guide/hu.md +6 -4
  42. package/dist/dashboard/guide/is.md +6 -4
  43. package/dist/dashboard/guide/it.md +6 -4
  44. package/dist/dashboard/guide/ja.md +7 -5
  45. package/dist/dashboard/guide/ko.md +6 -4
  46. package/dist/dashboard/guide/nb.md +7 -5
  47. package/dist/dashboard/guide/nl.md +6 -4
  48. package/dist/dashboard/guide/pl.md +6 -4
  49. package/dist/dashboard/guide/pt.md +6 -4
  50. package/dist/dashboard/guide/ro.md +6 -4
  51. package/dist/dashboard/guide/ru.md +6 -4
  52. package/dist/dashboard/guide/sv.md +6 -4
  53. package/dist/dashboard/guide/tr.md +6 -4
  54. package/dist/dashboard/guide/uk.md +6 -4
  55. package/dist/dashboard/guide/zh.md +6 -4
  56. package/dist/dashboard/i18n/ar.json +25 -0
  57. package/dist/dashboard/i18n/cs.json +25 -0
  58. package/dist/dashboard/i18n/da.json +25 -0
  59. package/dist/dashboard/i18n/de.json +25 -0
  60. package/dist/dashboard/i18n/el.json +25 -0
  61. package/dist/dashboard/i18n/es.json +25 -0
  62. package/dist/dashboard/i18n/fi.json +25 -0
  63. package/dist/dashboard/i18n/fr.json +25 -0
  64. package/dist/dashboard/i18n/he.json +25 -0
  65. package/dist/dashboard/i18n/hi.json +25 -0
  66. package/dist/dashboard/i18n/hu.json +25 -0
  67. package/dist/dashboard/i18n/is.json +25 -0
  68. package/dist/dashboard/i18n/it.json +25 -0
  69. package/dist/dashboard/i18n/ja.json +25 -0
  70. package/dist/dashboard/i18n/ko.json +25 -0
  71. package/dist/dashboard/i18n/nb.json +25 -0
  72. package/dist/dashboard/i18n/nl.json +25 -0
  73. package/dist/dashboard/i18n/pl.json +25 -0
  74. package/dist/dashboard/i18n/pt.json +25 -0
  75. package/dist/dashboard/i18n/ro.json +25 -0
  76. package/dist/dashboard/i18n/ru.json +25 -0
  77. package/dist/dashboard/i18n/sv.json +25 -0
  78. package/dist/dashboard/i18n/tr.json +25 -0
  79. package/dist/dashboard/i18n/uk.json +25 -0
  80. package/dist/dashboard/i18n/zh.json +25 -0
  81. package/dist/dashboard/packages/installed.js +2 -2
  82. package/dist/dashboard/packages/packages.js +1 -1
  83. package/dist/dashboard/parts/labels.js +7 -0
  84. package/dist/dashboard/settings/settings.js +33 -6
  85. package/dist/dashboard/shell/system-style.js +89 -5
  86. package/dist/dashboard/shell/tooltip.js +5 -4
  87. package/dist/dashboard/style.css +234 -81
  88. package/dist/git/git.d.ts +12 -0
  89. package/dist/git/git.js +175 -0
  90. package/dist/git/ignore.d.ts +2 -0
  91. package/dist/git/ignore.js +16 -0
  92. package/dist/git/index.d.ts +2 -0
  93. package/dist/git/index.js +2 -0
  94. package/dist/importer/index.d.ts +1 -1
  95. package/dist/importer/index.js +1 -1
  96. package/dist/languages/pack.js +2 -1
  97. package/dist/server/bell-listener.d.ts +2 -1
  98. package/dist/server/bell-listener.js +10 -41
  99. package/dist/server/dashboard/files.d.ts +3 -2
  100. package/dist/server/dashboard/files.js +44 -15
  101. package/dist/server/dashboard/index.d.ts +15 -2
  102. package/dist/server/dashboard/index.js +52 -22
  103. package/dist/server/dashboard/news.d.ts +3 -2
  104. package/dist/server/dashboard/news.js +19 -5
  105. package/dist/server/dashboard/ports.d.ts +17 -2
  106. package/dist/server/dashboard/ports.js +60 -4
  107. package/dist/server/mcp.d.ts +3 -2
  108. package/dist/server/mcp.js +55 -11
  109. package/dist/themes/css.d.ts +1 -1
  110. package/dist/themes/css.js +101 -2
  111. package/dist/themes/index.d.ts +1 -1
  112. package/dist/themes/index.js +1 -1
  113. package/dist/themes/theme.d.ts +34 -3
  114. package/dist/themes/theme.js +176 -19
  115. package/instructions/core.md +1 -0
  116. package/instructions/dashboard-guide.md +1 -1
  117. package/package.json +1 -1
@@ -202,7 +202,10 @@ function codexConfigFile(root, platform, effort = chosenEffort(root)) {
202
202
  const text = effort === undefined ? hidden : withTopKey(hidden, "model_reasoning_effort", effort === "app" ? undefined : JSON.stringify(effort));
203
203
  const server = rpgServer(platform);
204
204
  const tables = [
205
- ["mcp_servers.rpg", `command = ${JSON.stringify(server.command)}\nargs = [${server.args.map((arg) => JSON.stringify(arg)).join(", ")}]\ntool_timeout_sec = 1800\ndefault_tools_approval_mode = "approve"\nenv_vars = ["CODEX_HOME"]`],
205
+ [
206
+ "mcp_servers.rpg",
207
+ `command = ${JSON.stringify(server.command)}\nargs = [${server.args.map((arg) => JSON.stringify(arg)).join(", ")}]\ntool_timeout_sec = 1800\ndefault_tools_approval_mode = "approve"\nenv_vars = ["CODEX_HOME", "SSH_AUTH_SOCK", "HTTPS_PROXY", "HTTP_PROXY", "NO_PROXY", "https_proxy", "http_proxy", "no_proxy"]`,
208
+ ],
206
209
  ["memories", "generate_memories = false\nuse_memories = false"],
207
210
  ];
208
211
  // A table's header with a comment after it is that table all the same.
@@ -4,5 +4,6 @@ export { bookFolderName, campaignFileName, findCampaign, houseRulesFolderName, i
4
4
  export { hasCharacterAgent, hostFileNames, refreshHostFiles, writeEffortFiles } from "./host-files.ts";
5
5
  export { lastChoices, rememberChoice, rememberedSettings } from "./last-choices.ts";
6
6
  export { type CountedByGame, customLevel, customLevels, customSettings, difficulties, difficultyItems, itemMeaning, leveled, type LeveledSetting, rigorItems, rigors, startingLevels } from "./levels.ts";
7
- export { type CampaignSettings, changeExtensions, changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, characterWays, checkSettingName, checkSettings, chosenPictureMaker, clearSetting, closedSettings, companionWays, diceWays, efforts, entrySettingNames, lengths, lethalities, listLimits, listSettingNames, mapSettingNames, masterRollWays, mentorWays, missingSettings, pictureMakers, pictureWays, preparations, proseWays, readCampaignData, readListSetting, readOneSetting, readSettings, readTextSetting, saveModes, settingDescription, settingMeaning, type SettingName, settingNames, setupSettingNames, storyWays, styleTextLengths, unansweredSettings, unitSystems, voiceWays, } from "./settings.ts";
7
+ export { portFileName, savedPort, savePort } from "./port.ts";
8
+ export { type CampaignSettings, changeExtensions, changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, characterWays, checkSettingName, checkSettings, chosenPictureMaker, clearSetting, closedSettings, companionWays, diceWays, efforts, entrySettingNames, gitIncludeWays, gitWays, lengths, lethalities, listLimits, listSettingNames, mapSettingNames, masterRollWays, mentorWays, missingSettings, pictureMakers, pictureWays, preparations, proseWays, readCampaignData, readListSetting, readOneSetting, readSettings, readTextSetting, saveModes, settingDescription, settingMeaning, type SettingName, settingNames, setupSettingNames, storyWays, styleTextLengths, unansweredSettings, unitSystems, voiceWays, } from "./settings.ts";
8
9
  export { type CampaignState, changeState, changeStateAt, readState, readStateValues } from "./state.ts";
@@ -5,5 +5,6 @@ export { bookFolderName, campaignFileName, findCampaign, houseRulesFolderName, i
5
5
  export { hasCharacterAgent, hostFileNames, refreshHostFiles, writeEffortFiles } from "./host-files.js";
6
6
  export { lastChoices, rememberChoice, rememberedSettings } from "./last-choices.js";
7
7
  export { customLevel, customLevels, customSettings, difficulties, difficultyItems, itemMeaning, leveled, rigorItems, rigors, startingLevels } from "./levels.js";
8
- export { changeExtensions, changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, characterWays, checkSettingName, checkSettings, chosenPictureMaker, clearSetting, closedSettings, companionWays, diceWays, efforts, entrySettingNames, lengths, lethalities, listLimits, listSettingNames, mapSettingNames, masterRollWays, mentorWays, missingSettings, pictureMakers, pictureWays, preparations, proseWays, readCampaignData, readListSetting, readOneSetting, readSettings, readTextSetting, saveModes, settingDescription, settingMeaning, settingNames, setupSettingNames, storyWays, styleTextLengths, unansweredSettings, unitSystems, voiceWays, } from "./settings.js";
8
+ export { portFileName, savedPort, savePort } from "./port.js";
9
+ export { changeExtensions, changeListSetting, changeListSettingToNone, changeMapSetting, changeOtherSetting, changeSetting, characterWays, checkSettingName, checkSettings, chosenPictureMaker, clearSetting, closedSettings, companionWays, diceWays, efforts, entrySettingNames, gitIncludeWays, gitWays, lengths, lethalities, listLimits, listSettingNames, mapSettingNames, masterRollWays, mentorWays, missingSettings, pictureMakers, pictureWays, preparations, proseWays, readCampaignData, readListSetting, readOneSetting, readSettings, readTextSetting, saveModes, settingDescription, settingMeaning, settingNames, setupSettingNames, storyWays, styleTextLengths, unansweredSettings, unitSystems, voiceWays, } from "./settings.js";
9
10
  export { changeState, changeStateAt, readState, readStateValues } from "./state.js";
@@ -0,0 +1,6 @@
1
+ /** The file that keeps the port of the campaign's page, in its folder: this computer's, which the engine's .gitignore leaves out. */
2
+ export declare const portFileName = ".dashboard-port";
3
+ /** The port kept for the campaign's page; undefined when none is, or one that is no port. */
4
+ export declare function savedPort(root: string): number | undefined;
5
+ /** Keeps the port of the campaign's page; nothing when it cannot be written, as the page works all the same and the next chat chooses again. */
6
+ export declare function savePort(root: string, port: number): void;
@@ -0,0 +1,24 @@
1
+ // The port of the campaign's page on this computer (D-577): chosen once, kept in a file of the campaign's own that git leaves out, so that it moves with
2
+ // the folder and never to another computer, and changed only when another program or campaign holds it.
3
+ import { join } from "node:path";
4
+ import { files } from "../core/store.js";
5
+ /** The file that keeps the port of the campaign's page, in its folder: this computer's, which the engine's .gitignore leaves out. */
6
+ export const portFileName = ".dashboard-port";
7
+ /** The port kept for the campaign's page; undefined when none is, or one that is no port. */
8
+ export function savedPort(root) {
9
+ const text = files().text(join(root, portFileName))?.trim() ?? "";
10
+ const port = /^\d+$/.test(text) ? Number(text) : Number.NaN;
11
+ return Number.isInteger(port) && port > 0 && port < 65536 ? port : undefined;
12
+ }
13
+ /** Keeps the port of the campaign's page; nothing when it cannot be written, as the page works all the same and the next chat chooses again. */
14
+ export function savePort(root, port) {
15
+ if (savedPort(root) === port) {
16
+ return;
17
+ }
18
+ try {
19
+ files().write(join(root, portFileName), `${port}\n`);
20
+ }
21
+ catch {
22
+ // A folder that cannot be written keeps no port.
23
+ }
24
+ }
@@ -6,6 +6,10 @@ import { type CountedByGame } from "./levels.ts";
6
6
  export declare const lethalities: readonly ["narrative", "epic", "dice"];
7
7
  /** When the game may go back (D-55): never, to the last end of a scene once the player character dies, or to any save, which the player may also ask for. */
8
8
  export declare const saveModes: readonly ["permadeath", "checkpoint", "free"];
9
+ /** What the engine does with git in a campaign that is a repository (D-576): nothing, a commit at each session's start, save and end of a scene, or a push too. */
10
+ export declare const gitWays: readonly ["off", "commit", "push"];
11
+ /** Whether the saves or the chats go into the campaign's repository (D-576): left out, as when unset, or in. */
12
+ export declare const gitIncludeWays: readonly ["out", "in"];
9
13
  /**
10
14
  * What the chosen difficulty, rigor or mentor means, as status and config give it, the rigor with what the game counts itself, a custom one with the levels of
11
15
  * its items as custom-difficulty or custom-rigor writes them (T-132); undefined for another setting or a value it does not take.
@@ -242,6 +246,19 @@ export declare const settingsSchema: z.ZodObject<{
242
246
  precedents: z.ZodOptional<z.ZodNullable<z.ZodPreprocess<z.ZodArray<z.ZodPreprocess<z.ZodString, unknown>>, unknown>>>;
243
247
  learned: z.ZodOptional<z.ZodNullable<z.ZodPreprocess<z.ZodArray<z.ZodPreprocess<z.ZodString, unknown>>, unknown>>>;
244
248
  library: z.ZodOptional<z.ZodNullable<z.ZodPreprocess<z.ZodArray<z.ZodPreprocess<z.ZodString, unknown>>, unknown>>>;
249
+ git: z.ZodOptional<z.ZodEnum<{
250
+ push: "push";
251
+ off: "off";
252
+ commit: "commit";
253
+ }>>;
254
+ "git-saves": z.ZodOptional<z.ZodEnum<{
255
+ out: "out";
256
+ in: "in";
257
+ }>>;
258
+ "git-sessions": z.ZodOptional<z.ZodEnum<{
259
+ out: "out";
260
+ in: "in";
261
+ }>>;
245
262
  coins: z.ZodOptional<z.ZodUnknown>;
246
263
  calendar: z.ZodOptional<z.ZodUnknown>;
247
264
  fields: z.ZodOptional<z.ZodUnknown>;
@@ -12,6 +12,10 @@ const settingsHold = 'settings, such as "name: ..."';
12
12
  export const lethalities = ["narrative", "epic", "dice"];
13
13
  /** When the game may go back (D-55): never, to the last end of a scene once the player character dies, or to any save, which the player may also ask for. */
14
14
  export const saveModes = ["permadeath", "checkpoint", "free"];
15
+ /** What the engine does with git in a campaign that is a repository (D-576): nothing, a commit at each session's start, save and end of a scene, or a push too. */
16
+ export const gitWays = ["off", "commit", "push"];
17
+ /** Whether the saves or the chats go into the campaign's repository (D-576): left out, as when unset, or in. */
18
+ export const gitIncludeWays = ["out", "in"];
15
19
  /**
16
20
  * What the chosen difficulty, rigor or mentor means, as status and config give it, the rigor with what the game counts itself, a custom one with the levels of
17
21
  * its items as custom-difficulty or custom-rigor writes them (T-132); undefined for another setting or a value it does not take.
@@ -404,6 +408,10 @@ export const settingsSchema = z.object({
404
408
  precedents: listSetting.describe("the rulings made without the text, each starting with the name of the rule in the system's language: Poisoned: …"),
405
409
  learned: listSetting.describe("the game's mechanics the master has explained, by their names in the system's language: explained again only when the player gets one wrong"),
406
410
  library: listSetting.describe("the player's library (D-491): folders of their books, or books, by full path, which rules searches after the game system"),
411
+ git: z.enum(gitWays).optional().describe("what rpg does with git where the campaign's folder is a repository: off (unset, nothing), commit (a commit at the start of each session, at each save and each end of a scene) "
412
+ + "or push (a commit, then a push)"),
413
+ "git-saves": z.enum(gitIncludeWays).optional().describe("whether the saves' zips go into the campaign's repository: out (unset) or in"),
414
+ "git-sessions": z.enum(gitIncludeWays).optional().describe("whether the chats kept as text, all the player wrote, go into the campaign's repository: out (unset) or in, for a private one"),
407
415
  // Checked by the money module (MON-1): coins written wrongly by hand must not stop the other settings from being read.
408
416
  coins: z.unknown().optional().describe("the coins, for a game with money: each with its value in the smallest coin, such as gp 100, sp 10, cp 1"),
409
417
  // Checked by the time module (TIM-8): a mistake there never stops the game, whose date stays day N.
@@ -443,7 +451,22 @@ const premiseSettingNames = ["premise", "preparation", "length"];
443
451
  // The pictures: the setup asks them; in a campaign made before, status asks for them once, only where they can be made (D-308, D-572).
444
452
  // How the master writes: the core's own until the player chooses (D-395).
445
453
  const styleSettingNames = ["prose", "story", "author", "style"];
446
- const optionalSettingNames = ["coins", "pictures", "effort", "voices", "calendar", "calendar-start", "between-sessions", ...entrySettingNames, ...setupSettingNames, ...premiseSettingNames, ...styleSettingNames];
454
+ const optionalSettingNames = [
455
+ "coins",
456
+ "pictures",
457
+ "effort",
458
+ "voices",
459
+ "calendar",
460
+ "calendar-start",
461
+ "between-sessions",
462
+ "git",
463
+ "git-saves",
464
+ "git-sessions",
465
+ ...entrySettingNames,
466
+ ...setupSettingNames,
467
+ ...premiseSettingNames,
468
+ ...styleSettingNames,
469
+ ];
447
470
  /** The YAML list of a list setting, edited in place so that its comments stay; created when missing. */
448
471
  function listNode(document, setting) {
449
472
  const node = document.get(setting, true);
package/dist/cli/cli.js CHANGED
@@ -30,4 +30,19 @@ else {
30
30
  console.error(output);
31
31
  }
32
32
  process.exitCode = exitCode;
33
+ await waitForGit();
34
+ }
35
+ /** The commit a command started, and its push, which the process waits for anyway: said, then what went wrong, if anything (D-576). */
36
+ async function waitForGit() {
37
+ const { gitProblem, gitUnderWay } = await import("../commands/shared/campaign/git.js");
38
+ for (const { root, pushes, done } of gitUnderWay()) {
39
+ if (pushes) {
40
+ console.error("Pushing the campaign to git…");
41
+ }
42
+ await done;
43
+ const problem = gitProblem(root);
44
+ if (problem !== undefined) {
45
+ console.error(`git: the ${problem.act} failed: ${problem.why}`);
46
+ }
47
+ }
33
48
  }
@@ -10,6 +10,7 @@ import { declaredKind } from "../../pages/index.js";
10
10
  import { campaignDataNames, rulesetSetting } from "../../systems/index.js";
11
11
  import { readBetweenSessions, readCalendar, readCalendarStart } from "../../time/index.js";
12
12
  import { checkLibraryRemovals, libraryAdditions, libraryRemovals, startLibraryReading } from "../shared/books/library.js";
13
+ import { gitProblem, isCampaignRepository } from "../shared/campaign/git.js";
13
14
  import { campaignMode, campaignNote } from "../shared/campaign/mode.js";
14
15
  import { campaignCoins } from "../shared/campaign/money.js";
15
16
  import { askedBy, heldSystemSettings, offerRefusal, playedEngineSetting, unofferedLines, valuePart } from "../shared/campaign/offers.js";
@@ -63,7 +64,7 @@ export const config = defineCommand({
63
64
  if (input.setting === "library" && (input.add !== undefined || input.remove !== undefined)) {
64
65
  return changeLibrary(input, context);
65
66
  }
66
- const result = configure(input, context);
67
+ const result = withGitState(configure(input, context), input, context);
67
68
  // A system installed in this chat, as in the setup, brings its code once the campaign plays it (D-513 (1)).
68
69
  return input.setting === "system" && input.value !== undefined ? loadNewSystemCode(context).then(() => result) : result;
69
70
  },
@@ -89,6 +90,19 @@ async function changeLibrary(input, context) {
89
90
  startLibraryReading(context);
90
91
  return result;
91
92
  }
93
+ /** The setting of git with what the master cannot see otherwise (D-576): a folder that is no repository yet, and what went wrong the last time git ran. */
94
+ function withGitState(result, input, context) {
95
+ if (input.setting !== "git") {
96
+ return result;
97
+ }
98
+ const root = requireCampaign(context.folder);
99
+ const problem = gitProblem(root);
100
+ const lines = [
101
+ isCampaignRepository(root) ? "" : "This folder is not a git repository yet: nothing is committed until it is.",
102
+ problem === undefined ? "" : `The last ${problem.act} failed: ${problem.why}`,
103
+ ].filter((line) => line !== "");
104
+ return lines.length === 0 ? result : { ...result, note: [result.note, ...lines].filter((line) => line !== "").join("\n") };
105
+ }
92
106
  function configure(input, context) {
93
107
  const root = requireCampaign(context.folder);
94
108
  const listChange = input.add !== undefined || input.remove !== undefined;
@@ -46,9 +46,13 @@ export declare function setupQuestions(root: string, context: Context, writtenWo
46
46
  export declare function setupSettingNamed(root: string, name: string): PlayerSetting | undefined;
47
47
  /** The player's settings as the dashboard shows them (D-341): with what this computer lacks, as pictures without Codex, asked again. */
48
48
  export declare function shownPlayerSettings(root: string, context: Context): PlayerSetting[];
49
+ /** Every note the setting of git may have, which the dashboard writes in its language (D-394). */
50
+ export declare const gitNotes: string[];
49
51
  /** The player's settings with their values, then those the game system adds (D-341). */
50
52
  export declare function playerSettings(root: string, context: Context): PlayerSetting[];
51
53
  /** One of the player's settings by its name, in any case, as the dashboard changes them (D-341); undefined for a setting of the master's or none. */
52
54
  export declare function playerSettingNamed(root: string, context: Context, name: string): PlayerSetting | undefined;
55
+ /** Every question of git the setup may ask, which the dashboard writes in its language. */
56
+ export declare const gitQuestions: string[];
53
57
  /** Every note the pictures' setting may have, which the dashboard writes in its language (D-394). */
54
58
  export declare const picturesNotes: string[];
@@ -3,10 +3,11 @@ import { customLevel, customLevels, customSettings, lastChoices, listSettingName
3
3
  import { comparableText } from "../../core/text.js";
4
4
  import { claudeSays, codexClient, codexSays } from "../../helpers/index.js";
5
5
  import { readBetweenSessions } from "../../time/index.js";
6
+ import { gitProblem, isCampaignRepository, isInLargerRepository } from "../shared/campaign/git.js";
6
7
  import { heldSystemSettings, isLeading, offeredValues, playedEngineSetting } from "../shared/campaign/offers.js";
7
8
  import { playedSettingValue } from "../shared/campaign/world.js";
8
9
  import { customOf } from "./custom-levels.js";
9
- import { betweenSessionsWays, playerSettingNames, playerWords, setupWords, wordsOf } from "./words.js";
10
+ import { betweenSessionsWays, gitSettingNames, playerSettingNames, playerWords, setupWords, wordsOf } from "./words.js";
10
11
  /**
11
12
  * The setup's questions as the dashboard asks them (D-370), each with its value or items, if answered, and its values with what each means: the player's
12
13
  * settings of the setup, how the character and the companions come, the preparation and length of a world not written, those the game system adds, then the lines and veils.
@@ -39,7 +40,7 @@ export function setupQuestions(root, context, writtenWorld) {
39
40
  const offered = suggestion !== undefined && (question.choices === undefined || question.choices.some((choice) => choice.value === suggestion));
40
41
  const asked = { ...question, ...(question.choices === undefined ? {} : { choices: question.choices.filter((choice) => choice.value !== customLevel) }) };
41
42
  const lastOne = offered && last[question.name] === suggestion ? { last: suggestion } : {};
42
- const worded = Object.hasOwn(questionTexts, question.name) ? { question: questionTexts[question.name] } : {};
43
+ const worded = Object.hasOwn(questionTexts, question.name) ? { question: questionText(question.name, root) } : {};
43
44
  return { ...(question.name === "mentor" ? mentorQuestion(asked, game ?? "") : unsetUnanswered(asked, settings)), ...worded, ...(offered ? { suggested: suggestion } : {}), ...lastOne };
44
45
  });
45
46
  }
@@ -66,7 +67,24 @@ export function setupSettingNamed(root, name) {
66
67
  }
67
68
  /** The player's settings as the dashboard shows them (D-341): with what this computer lacks, as pictures without Codex, asked again. */
68
69
  export function shownPlayerSettings(root, context) {
69
- return playerSettings(root, context).map((setting) => (setting.name === "pictures" ? { ...setting, ...withOwnPicture(picturesReadyNote(context)) } : setting));
70
+ return playerSettings(root, context).map((setting) => {
71
+ if (setting.name === "pictures") {
72
+ return { ...setting, ...withOwnPicture(picturesReadyNote(context)) };
73
+ }
74
+ return setting.name === "git" ? { ...setting, ...gitNote(root) } : setting;
75
+ });
76
+ }
77
+ // What went wrong the last time git ran (D-576), told until it goes right.
78
+ const gitFailed = {
79
+ commit: "The last commit failed; the game goes on all the same. Ask the master to look at it. ({why})",
80
+ push: "The last push failed: the campaign is safe on this computer, only its copy online is behind. Ask the master to look at it. ({why})",
81
+ };
82
+ /** Every note the setting of git may have, which the dashboard writes in its language (D-394). */
83
+ export const gitNotes = Object.values(gitFailed);
84
+ /** What went wrong the last time git ran for the campaign; nothing when it went right. */
85
+ function gitNote(root) {
86
+ const problem = gitProblem(root);
87
+ return problem === undefined ? {} : { note: { text: gitFailed[problem.act], values: { why: problem.why } } };
70
88
  }
71
89
  /** The player's settings with their values, then those the game system adds (D-341). */
72
90
  export function playerSettings(root, context) {
@@ -95,7 +113,8 @@ export function playerSettings(root, context) {
95
113
  ...(choices === undefined ? {} : { choices }),
96
114
  ...(words.most === undefined ? {} : { most: words.most }),
97
115
  }];
98
- }).flatMap((setting) => offeredSetting(root, context, setting)).map((setting) => (setting.name === "pictures-by" ? makersInChat(context, setting) : setting)),
116
+ }).flatMap((setting) => offeredSetting(root, context, setting)).map((setting) => (setting.name === "pictures-by" ? makersInChat(context, setting) : setting))
117
+ .filter((setting) => !gitSettingNames.includes(setting.name) || isCampaignRepository(root)),
99
118
  ...own,
100
119
  ];
101
120
  }
@@ -105,9 +124,21 @@ export function playerSettingNamed(root, context, name) {
105
124
  }
106
125
  // The setup's questions, in the order the player meets them on the dashboard: how well they know the game, how it plays, how it is rolled, who comes along,
107
126
  // the world and how long it plays, then the limits.
108
- const setupOrder = ["mentor", "difficulty", "lethality", "saves", "rigor", "dice", "master-rolls", "units", "character", "companions", "preparation", "length", "pictures", "pictures-by"];
127
+ const setupOrder = ["mentor", "difficulty", "lethality", "saves", "rigor", "dice", "master-rolls", "units", "character", "companions", "preparation", "length", "pictures", "pictures-by", "git"];
109
128
  // The questions the setup's cards ask in place of a setting's name (D-572).
110
- const questionTexts = { pictures: "Do you want pictures of places and of those you meet?", "pictures-by": "Who makes them?" };
129
+ const questionTexts = {
130
+ pictures: "Do you want pictures of places and of those you meet?",
131
+ "pictures-by": "Who makes them?",
132
+ git: "This campaign's folder is a git repository: what should the engine do with it?",
133
+ };
134
+ // The question of git where the repository holds more than the campaign: a push sends the player's other commits too (D-576).
135
+ const largerGitQuestion = "This campaign's folder is in a git repository that holds other folders too: what should the engine do with it? A push sends your commits on those folders as well.";
136
+ /** Every question of git the setup may ask, which the dashboard writes in its language. */
137
+ export const gitQuestions = [questionTexts.git, largerGitQuestion];
138
+ /** The question a setting's card asks in the setup. */
139
+ function questionText(name, root) {
140
+ return name === "git" && isInLargerRepository(root) ? largerGitQuestion : questionTexts[name];
141
+ }
111
142
  // The mentor as the setup asks it (D-347): how well the player knows the game, each answer a way of the mentor, from the newest player's.
112
143
  const mentorAnswers = { tutorial: "never played it", hints: "a little", off: "I know it" };
113
144
  // What the setup asks only of a world not written (D-80, D-558): a written one has its own.
@@ -37,6 +37,10 @@ export function shownValue(root, context, settings, name) {
37
37
  voices: "auto (a subagent at key moments, as you choose, where the app has them)",
38
38
  "master-rolls": "behind the screen (unset: roll hides your rolls for foes and NPCs)",
39
39
  "between-sessions": "stops (unset: no game time passes between sessions)",
40
+ // Git, unset: off, the player's to choose where the campaign's folder is a repository (D-576).
41
+ git: "off (unset: the player's to choose where the campaign's folder is a git repository)",
42
+ "git-saves": "out (unset)",
43
+ "git-sessions": "out (unset)",
40
44
  };
41
45
  if (settings[name] === undefined && Object.hasOwn(own, name)) {
42
46
  return own[name];
@@ -1,7 +1,9 @@
1
1
  export declare const styleSettingNames: string[];
2
2
  export declare const betweenSessionsWays: readonly ["stops", "1d per 7d", "1d per 1d"];
3
3
  /** The settings the player changes on the dashboard (D-341): how the game plays for them; the master's own, as house rules, coins and precedents, stay in the chat. */
4
- export declare const playerSettingNames: readonly ["difficulty", "custom-difficulty", "lethality", "saves", "rigor", "custom-rigor", "between-sessions", "mentor", "learned", "prose", "story", "author", "style", "dice", "master-rolls", "units", "voices", "pictures", "pictures-by", "effort", "lines", "veils", "orders", "language"];
4
+ export declare const playerSettingNames: readonly ["difficulty", "custom-difficulty", "lethality", "saves", "rigor", "custom-rigor", "between-sessions", "mentor", "learned", "prose", "story", "author", "style", "dice", "master-rolls", "units", "voices", "pictures", "pictures-by", "effort", "lines", "veils", "orders", "language", "git", "git-saves", "git-sessions"];
5
+ /** The settings of git (D-576), which count, and which the dashboard shows, only where the campaign's folder is a git repository. */
6
+ export declare const gitSettingNames: string[];
5
7
  export declare const playerWords: Record<(typeof playerSettingNames)[number], PlayerWords>;
6
8
  /**
7
9
  * What a setting of the player's is to them, its values and what each means; what the master does when an item is added to a list or taken off it, or a text
@@ -1,5 +1,5 @@
1
1
  // What each player setting and setup question is, in the player's words
2
- import { characterWays, companionWays, customLevel, diceWays, difficulties, efforts, lengths, lethalities, listLimits, masterRollWays, mentorWays, pictureMakers, pictureWays, preparations, proseWays, rigors, saveModes, storyWays, styleTextLengths, unitSystems, voiceWays, } from "../../campaign/index.js";
2
+ import { characterWays, companionWays, customLevel, diceWays, difficulties, efforts, gitIncludeWays, gitWays, lengths, lethalities, listLimits, masterRollWays, mentorWays, pictureMakers, pictureWays, preparations, proseWays, rigors, saveModes, storyWays, styleTextLengths, unitSystems, voiceWays, } from "../../campaign/index.js";
3
3
  export const styleSettingNames = ["prose", "story", "author", "style"];
4
4
  // The game time between sessions the dashboard offers (D-133): stopped, a day of the game for each real week, or as real time.
5
5
  export const betweenSessionsWays = ["stops", "1d per 7d", "1d per 1d"];
@@ -29,7 +29,12 @@ export const playerSettingNames = [
29
29
  "veils",
30
30
  "orders",
31
31
  "language",
32
+ "git",
33
+ "git-saves",
34
+ "git-sessions",
32
35
  ];
36
+ /** The settings of git (D-576), which count, and which the dashboard shows, only where the campaign's folder is a git repository. */
37
+ export const gitSettingNames = ["git", "git-saves", "git-sessions"];
33
38
  // What each of the player's settings is, and what its values mean to the player, in their words rather than the master's.
34
39
  export const playerWords = {
35
40
  difficulty: {
@@ -171,6 +176,28 @@ export const playerWords = {
171
176
  most: listLimits.orders?.length,
172
177
  },
173
178
  language: { about: "the language the master plays in, and the page's too when it is translated" },
179
+ git: {
180
+ about: "what the engine does with git, as this campaign's folder is a git repository",
181
+ values: gitWays,
182
+ means: {
183
+ off: "nothing: you keep the repository yourself",
184
+ commit: "a commit at the start of each session, at each save and at each end of a scene",
185
+ push: "a commit at the start of each session, at each save and at each end of a scene, then a push",
186
+ },
187
+ unset: "off",
188
+ },
189
+ "git-saves": {
190
+ about: "whether the saves go into the repository",
191
+ values: gitIncludeWays,
192
+ means: { out: "the repository keeps the story without them", in: "each save's zip too, which makes the repository grow quickly" },
193
+ unset: "out",
194
+ },
195
+ "git-sessions": {
196
+ about: "whether your chats with the master go into the repository",
197
+ values: gitIncludeWays,
198
+ means: { out: "they stay on this computer", in: "everything you wrote to the master: keep the repository private" },
199
+ unset: "out",
200
+ },
174
201
  };
175
202
  // What the setup asks besides the player's settings (D-370): how the player character and the companions come, how far ahead a world is made and how long it
176
203
  // plays, the campaign's name.
@@ -3,8 +3,8 @@ import { type Mode } from "./shared/campaign/mode.ts";
3
3
  import { type ResetPoint } from "./shared/campaign/saves.ts";
4
4
  export declare const mode: import("../core/registry.ts").Command<z.ZodObject<{
5
5
  to: z.ZodEnum<{
6
- "session zero": "session zero";
7
6
  setup: "setup";
7
+ "session zero": "session zero";
8
8
  play: "play";
9
9
  }>;
10
10
  }, z.core.$strip>, {
@@ -1,11 +1,13 @@
1
1
  // Packages of data alone: an adventure, a theme or a language, from an https link, a .zip or a folder of this computer, read once into its files and told by
2
2
  // the file at its top. No npm and no code, so no player's yes; packages with code come from npm.
3
3
  import { basename, join, relative, resolve, sep } from "node:path";
4
+ import { parse } from "yaml";
4
5
  import { largestAdventure, manifestFileName, readAdventureEntries } from "../../adventures/index.js";
5
6
  import { packageEntries, topFile, unzipFiles, zipListing } from "../../core/archive.js";
6
7
  import { filesIn } from "../../core/files.js";
7
8
  import { Refusal } from "../../core/refusal.js";
8
9
  import { files } from "../../core/store.js";
10
+ import { getVersion, newerEngineAsked } from "../../core/version.js";
9
11
  import { languageFileName } from "../../languages/index.js";
10
12
  import { themeFileName } from "../../themes/index.js";
11
13
  import { installAdventure } from "../shared/books/adventures.js";
@@ -85,8 +87,33 @@ export async function installDataPackage(root, context, data, from) {
85
87
  if (data.kind === "adventure") {
86
88
  return { kind: "adventure-installed", ...installAdventure(root, context, readAdventureEntries(data.label, data.entries), from) };
87
89
  }
90
+ checkEngine(data);
88
91
  return data.kind === "theme" ? themeInstalled(root, context, data) : await dataLanguageInstalled(root, context, data);
89
92
  }
93
+ /**
94
+ * Refuses a theme or a language whose file at its top asks a newer rpg-engine than this one, read loosely before any check, so that one with keys this engine
95
+ * does not know yet says what it needs, as an npm package made for a newer API does.
96
+ */
97
+ function checkEngine(data) {
98
+ const read = looseTopFile(data);
99
+ const engine = newerEngineAsked(read?.engine);
100
+ if (engine === undefined) {
101
+ return;
102
+ }
103
+ const name = typeof read?.name === "string" && read.name.trim() !== "" ? read.name : data.label;
104
+ const version = typeof read?.version === "string" || typeof read?.version === "number" ? String(read.version) : "";
105
+ throw new Refusal(`${[name, version].filter((part) => part !== "").join(" ")} needs rpg-engine ${engine} or newer; this is ${getVersion()}. The player updates RPG Engine on the dashboard's Packages page, never you; then add it again. Nothing changed.`, "engine-too-old", { name, version });
106
+ }
107
+ /** The file at a package's top, read as YAML without any check; undefined when it does not read, which the checks of its kind then say. */
108
+ function looseTopFile(data) {
109
+ const bytes = topFile(data.entries, topFiles[data.kind])?.[1];
110
+ try {
111
+ return bytes === undefined ? undefined : parse(new TextDecoder().decode(bytes)) ?? undefined;
112
+ }
113
+ catch {
114
+ return undefined;
115
+ }
116
+ }
90
117
  /** A part of an address as written, its %20 and such read back: a link copied from a browser or typed by hand gives the same. */
91
118
  function plainPart(text) {
92
119
  try {
@@ -19,7 +19,8 @@ export function themeInstalled(root, context, data) {
19
19
  if (folder === undefined) {
20
20
  throw new Error("Themes are installed only by the game's server or the command line, which keep them for every campaign on this computer.");
21
21
  }
22
- const named = new Set(themeFilesNamed(new TextDecoder().decode(topFile(data.entries, themeFileName)?.[1] ?? new Uint8Array())));
22
+ const text = (bytes) => (bytes === undefined ? undefined : new TextDecoder().decode(bytes));
23
+ const named = new Set(themeFilesNamed(text(topFile(data.entries, themeFileName)?.[1]) ?? "", (name) => text(data.entries.find(([parts]) => parts.join("/") === name)?.[1])));
23
24
  const keep = (parts) => isThemeYaml(parts) || named.has(parts.join("/")) || (parts.length === 1 && licence.test(parts[0]));
24
25
  const kept = keptFiles(data.label, data.entries, keep, "theme-refused", "a theme").map(([parts, bytes]) => [isThemeYaml(parts) ? [themeFileName] : parts, bytes]);
25
26
  // Checked where it is written, in a folder of its own that no list reads, then put where its id puts it.
@@ -6,6 +6,7 @@ import { defineCommand } from "../../core/registry.js";
6
6
  import { sameName } from "../../core/text.js";
7
7
  import { isEmptyField, linkListItems, parsePageReference } from "../../pages/index.js";
8
8
  import { sceneTypes } from "../../scene/index.js";
9
+ import { commitCampaign } from "../shared/campaign/git.js";
9
10
  import { campaignWorld } from "../shared/campaign/world.js";
10
11
  import { textList } from "../shared/inputs.js";
11
12
  import { openScene, updateScene } from "../shared/scene/scene.js";
@@ -64,7 +65,11 @@ export const scene = defineCommand({
64
65
  checkParameters(input);
65
66
  const world = campaignWorld(root, context);
66
67
  if (input.action === "close") {
67
- return close(root, world, input.summary ?? "", context);
68
+ const closed = close(root, world, input.summary ?? "", context);
69
+ // The save made at the end of the scene commits it already; a scene closed with no save is committed here (D-576).
70
+ const firstLine = input.summary?.trim().split(/\r?\n/)[0] ?? "";
71
+ void commitCampaign(root, firstLine === "" ? "rpg: scene closed" : `rpg: scene closed, ${firstLine}`);
72
+ return closed;
68
73
  }
69
74
  const current = openScene(root);
70
75
  if (input.action === "open") {
@@ -63,6 +63,7 @@ export interface AdventureExported {
63
63
  /** The pages and layers written from the player's documents (source:), when no license was given: the zip keeps them to the player. */
64
64
  sourced?: string[];
65
65
  }
66
+ export declare const installMarkName = ".adventure-install.yaml";
66
67
  /** The adventures the log says are installed and not taken out, in the order they came (ADV-6): they go back with a save. */
67
68
  export declare function installedAdventures(root: string): InstalledAdventure[];
68
69
  /** Installs an adventure in the campaign (ADV-2–ADV-5): checked whole, then written, or nothing at all; installed again, it finishes what stopped. */
@@ -25,7 +25,7 @@ import { houseRules, systemRuleBook } from "./rules.js";
25
25
  // What the system's attribution adds when the adventure carries layers over its pages: an open licence asks to say that the material was changed (ADV-8).
26
26
  const changesMade = "Changes were made: the files under layers/ modify pages the game system adapted from that material.";
27
27
  // The mark of an install under way, with its title and the days it moves dates by: while it is there, installing the same adventure finishes it (ADV-5).
28
- const installMarkName = ".adventure-install.yaml";
28
+ export const installMarkName = ".adventure-install.yaml";
29
29
  /** The adventures the log says are installed and not taken out, in the order they came (ADV-6): they go back with a save. */
30
30
  export function installedAdventures(root) {
31
31
  return adventuresOfLog(readLog(root));
@@ -0,0 +1,25 @@
1
+ import type { Context } from "../../../core/context.ts";
2
+ /** What went wrong the last time git ran for a campaign, which the dashboard tells the player until a commit and a push go right (D-576). */
3
+ export interface GitProblem {
4
+ act: "commit" | "push";
5
+ why: string;
6
+ }
7
+ /** Whether the campaign's folder is in a git repository: only then the settings of git count, and the dashboard shows them. */
8
+ export declare function isCampaignRepository(root: string): boolean;
9
+ /** Whether the campaign's repository holds more than the campaign, its .git in a folder above: a push sends the player's other commits too. */
10
+ export declare function isInLargerRepository(root: string): boolean;
11
+ /**
12
+ * Commits the campaign's changes with `message`, then pushes them, as its settings of git say (D-576); nothing where they are off or the folder is no
13
+ * repository. It never throws: what fails is kept for the dashboard. The commits of a campaign run one after the other.
14
+ */
15
+ export declare function commitCampaign(root: string, message: string): Promise<void>;
16
+ /** The commits still running, by campaign, and whether each pushes: what the command line waits for before it ends, saying so (D-576). */
17
+ export declare function gitUnderWay(): {
18
+ root: string;
19
+ pushes: boolean;
20
+ done: Promise<void>;
21
+ }[];
22
+ /** The commit at the start of a session: what the last one left, with its chats copied first when they go into the repository. */
23
+ export declare function commitSessionStart(root: string, context: Context): Promise<void>;
24
+ /** What went wrong the last time git ran for the campaign; undefined when it went right, or has not run. */
25
+ export declare function gitProblem(root: string): GitProblem | undefined;
@@ -0,0 +1,104 @@
1
+ // The campaign in its git repository (D-576): a commit at the start of a session, at each save and at each end of a scene, then a push, as the settings say.
2
+ import { join, resolve } from "node:path";
3
+ import { hostFileNames, inboxFolderName, portFileName, readSettings, sessionsFolderName } from "../../../campaign/index.js";
4
+ import { files } from "../../../core/store.js";
5
+ import { commitFolder, isRepository, push, repositoryRoot, withIgnoreBlock } from "../../../git/index.js";
6
+ import { importsFolderName } from "../../../importer/index.js";
7
+ import { installMarkName } from "../books/adventures.js";
8
+ import { copyChats } from "./chats.js";
9
+ import { exportsFolderName, savesFolderName } from "./saves.js";
10
+ /** Whether the campaign's folder is in a git repository: only then the settings of git count, and the dashboard shows them. */
11
+ export function isCampaignRepository(root) {
12
+ return isRepository(root);
13
+ }
14
+ /** Whether the campaign's repository holds more than the campaign, its .git in a folder above: a push sends the player's other commits too. */
15
+ export function isInLargerRepository(root) {
16
+ const found = repositoryRoot(root);
17
+ return found !== undefined && found !== resolve(root);
18
+ }
19
+ /**
20
+ * Commits the campaign's changes with `message`, then pushes them, as its settings of git say (D-576); nothing where they are off or the folder is no
21
+ * repository. It never throws: what fails is kept for the dashboard. The commits of a campaign run one after the other.
22
+ */
23
+ export function commitCampaign(root, message) {
24
+ const next = (running.get(root) ?? Promise.resolve()).then(() => commitNow(root, message)).finally(() => {
25
+ if (running.get(root) === next) {
26
+ running.delete(root);
27
+ }
28
+ });
29
+ running.set(root, next);
30
+ return next;
31
+ }
32
+ /** The commits still running, by campaign, and whether each pushes: what the command line waits for before it ends, saying so (D-576). */
33
+ export function gitUnderWay() {
34
+ return [...running].map(([root, done]) => ({ root, pushes: pushesTo(root), done }));
35
+ }
36
+ /** The commit at the start of a session: what the last one left, with its chats copied first when they go into the repository. */
37
+ export function commitSessionStart(root, context) {
38
+ try {
39
+ if (readSettings(root)["git-sessions"] === "in") {
40
+ copyChats(root, context);
41
+ }
42
+ }
43
+ catch {
44
+ // The commit goes on with the chats already copied.
45
+ }
46
+ return commitCampaign(root, `rpg: start of a session, ${context.now().toISOString().slice(0, 16).replace("T", " ")} UTC`);
47
+ }
48
+ /** What went wrong the last time git ran for the campaign; undefined when it went right, or has not run. */
49
+ export function gitProblem(root) {
50
+ return problems.get(root);
51
+ }
52
+ // The commits under way, by campaign, and what went wrong with the last.
53
+ const running = new Map();
54
+ const problems = new Map();
55
+ /** What the engine writes again whenever it likes, or the player keeps on this computer alone: never in the repository. */
56
+ function alwaysIgnored() {
57
+ // .gemini/ of the campaigns made before D-493, which it leaves on the disk.
58
+ return [".agents/", ".claude/", ".codex/", ".gemini/", ".mcp.json", ...hostFileNames, `${inboxFolderName}/`, `${exportsFolderName}/`, `${importsFolderName}/`, installMarkName, `${savesFolderName}/*.txt`, portFileName];
59
+ }
60
+ function pushesTo(root) {
61
+ try {
62
+ return readSettings(root).git === "push";
63
+ }
64
+ catch {
65
+ return false;
66
+ }
67
+ }
68
+ async function commitNow(root, message) {
69
+ let settings;
70
+ try {
71
+ settings = readSettings(root);
72
+ }
73
+ catch {
74
+ return;
75
+ }
76
+ if ((settings.git ?? "off") === "off" || !isRepository(root)) {
77
+ return;
78
+ }
79
+ const chosen = [...(settings["git-saves"] === "in" ? [] : [`${savesFolderName}/`]), ...(settings["git-sessions"] === "in" ? [] : [`${sessionsFolderName}/`])];
80
+ const left = [...alwaysIgnored(), ...chosen];
81
+ let act = "commit";
82
+ try {
83
+ writeIgnore(root, left.map((path) => `/${path}`));
84
+ // What the .gitignore leaves out goes out of the repository too, had the player committed it before.
85
+ await commitFolder(root, message, left.map((path) => path.replace(/\/$/, "")));
86
+ if (settings.git === "push") {
87
+ act = "push";
88
+ await push(root);
89
+ }
90
+ problems.delete(root);
91
+ }
92
+ catch (error) {
93
+ problems.set(root, { act, why: error instanceof Error ? error.message : String(error) });
94
+ }
95
+ }
96
+ /** Writes the engine's block of the campaign's .gitignore, when it changes. */
97
+ function writeIgnore(root, lines) {
98
+ const file = join(root, ".gitignore");
99
+ const text = files().text(file);
100
+ const written = withIgnoreBlock(text, lines);
101
+ if (written !== text) {
102
+ files().write(file, written);
103
+ }
104
+ }