rpg-engine 0.20.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/dist/adventures/index.d.ts +1 -1
  2. package/dist/adventures/index.js +1 -1
  3. package/dist/adventures/source.d.ts +3 -0
  4. package/dist/adventures/source.js +11 -49
  5. package/dist/campaign/create-campaign.d.ts +1 -1
  6. package/dist/campaign/create-campaign.js +3 -2
  7. package/dist/campaign/find-campaign.d.ts +2 -0
  8. package/dist/campaign/find-campaign.js +2 -0
  9. package/dist/campaign/host-files.js +4 -1
  10. package/dist/campaign/index.d.ts +3 -2
  11. package/dist/campaign/index.js +3 -2
  12. package/dist/campaign/port.d.ts +6 -0
  13. package/dist/campaign/port.js +24 -0
  14. package/dist/campaign/settings.d.ts +17 -0
  15. package/dist/campaign/settings.js +26 -3
  16. package/dist/cli/cli.js +15 -0
  17. package/dist/commands/book.d.ts +16 -35
  18. package/dist/commands/book.js +86 -62
  19. package/dist/commands/config/config.js +16 -2
  20. package/dist/commands/config/dashboard.d.ts +6 -2
  21. package/dist/commands/config/dashboard.js +45 -8
  22. package/dist/commands/config/shown.js +4 -0
  23. package/dist/commands/config/words.d.ts +3 -1
  24. package/dist/commands/config/words.js +29 -2
  25. package/dist/commands/image.d.ts +5 -0
  26. package/dist/commands/image.js +6 -3
  27. package/dist/commands/mode.d.ts +1 -1
  28. package/dist/commands/package/data.d.ts +35 -0
  29. package/dist/commands/package/data.js +144 -0
  30. package/dist/commands/package/here.d.ts +7 -2
  31. package/dist/commands/package/here.js +23 -11
  32. package/dist/commands/package/install.js +14 -15
  33. package/dist/commands/package/language.d.ts +15 -0
  34. package/dist/commands/package/language.js +109 -0
  35. package/dist/commands/package/package.js +20 -10
  36. package/dist/commands/package/result.d.ts +19 -0
  37. package/dist/commands/package/theme.d.ts +13 -0
  38. package/dist/commands/package/theme.js +67 -0
  39. package/dist/commands/package/uninstall.d.ts +4 -1
  40. package/dist/commands/package/uninstall.js +29 -9
  41. package/dist/commands/scene/close.d.ts +1 -1
  42. package/dist/commands/scene/close.js +15 -8
  43. package/dist/commands/scene/scene.js +6 -1
  44. package/dist/commands/shared/books/adventures.d.ts +1 -4
  45. package/dist/commands/shared/books/adventures.js +3 -32
  46. package/dist/commands/shared/books/words.js +3 -2
  47. package/dist/commands/shared/campaign/book.d.ts +21 -8
  48. package/dist/commands/shared/campaign/book.js +65 -42
  49. package/dist/commands/shared/campaign/git.d.ts +25 -0
  50. package/dist/commands/shared/campaign/git.js +104 -0
  51. package/dist/commands/shared/campaign/saves.js +7 -3
  52. package/dist/commands/shared/campaign/world.js +2 -1
  53. package/dist/commands/shared/packages/catalog.d.ts +3 -3
  54. package/dist/commands/shared/packages/catalog.js +118 -43
  55. package/dist/commands/shared/packages/unpacked.d.ts +50 -0
  56. package/dist/commands/shared/packages/unpacked.js +146 -0
  57. package/dist/commands/status.d.ts +1 -0
  58. package/dist/commands/status.js +8 -4
  59. package/dist/core/archive.d.ts +13 -0
  60. package/dist/core/archive.js +76 -0
  61. package/dist/core/context.d.ts +4 -0
  62. package/dist/core/context.js +1 -0
  63. package/dist/core/store.d.ts +5 -1
  64. package/dist/core/store.js +15 -2
  65. package/dist/core/version.d.ts +2 -0
  66. package/dist/core/version.js +5 -0
  67. package/dist/dashboard/api.js +24 -1
  68. package/dist/dashboard/app.js +7 -2
  69. package/dist/dashboard/guide/ar.md +11 -9
  70. package/dist/dashboard/guide/cs.md +11 -9
  71. package/dist/dashboard/guide/da.md +12 -10
  72. package/dist/dashboard/guide/de.md +13 -11
  73. package/dist/dashboard/guide/el.md +11 -9
  74. package/dist/dashboard/guide/en.md +10 -8
  75. package/dist/dashboard/guide/es.md +11 -9
  76. package/dist/dashboard/guide/fi.md +11 -9
  77. package/dist/dashboard/guide/fr.md +11 -9
  78. package/dist/dashboard/guide/he.md +11 -9
  79. package/dist/dashboard/guide/hi.md +11 -9
  80. package/dist/dashboard/guide/hu.md +11 -9
  81. package/dist/dashboard/guide/is.md +11 -9
  82. package/dist/dashboard/guide/it.md +11 -9
  83. package/dist/dashboard/guide/ja.md +12 -10
  84. package/dist/dashboard/guide/ko.md +11 -9
  85. package/dist/dashboard/guide/nb.md +12 -10
  86. package/dist/dashboard/guide/nl.md +11 -9
  87. package/dist/dashboard/guide/pl.md +11 -9
  88. package/dist/dashboard/guide/pt.md +11 -9
  89. package/dist/dashboard/guide/ro.md +11 -9
  90. package/dist/dashboard/guide/ru.md +12 -10
  91. package/dist/dashboard/guide/sv.md +11 -9
  92. package/dist/dashboard/guide/tr.md +11 -9
  93. package/dist/dashboard/guide/uk.md +12 -10
  94. package/dist/dashboard/guide/zh.md +11 -9
  95. package/dist/dashboard/i18n/ar.json +58 -5
  96. package/dist/dashboard/i18n/cs.json +58 -5
  97. package/dist/dashboard/i18n/da.json +58 -5
  98. package/dist/dashboard/i18n/de.json +58 -5
  99. package/dist/dashboard/i18n/el.json +58 -5
  100. package/dist/dashboard/i18n/es.json +58 -5
  101. package/dist/dashboard/i18n/fi.json +58 -5
  102. package/dist/dashboard/i18n/fr.json +58 -5
  103. package/dist/dashboard/i18n/he.json +58 -5
  104. package/dist/dashboard/i18n/hi.json +58 -5
  105. package/dist/dashboard/i18n/hu.json +58 -5
  106. package/dist/dashboard/i18n/is.json +58 -5
  107. package/dist/dashboard/i18n/it.json +58 -5
  108. package/dist/dashboard/i18n/ja.json +58 -5
  109. package/dist/dashboard/i18n/ko.json +58 -5
  110. package/dist/dashboard/i18n/nb.json +58 -5
  111. package/dist/dashboard/i18n/nl.json +58 -5
  112. package/dist/dashboard/i18n/pl.json +58 -5
  113. package/dist/dashboard/i18n/pt.json +58 -5
  114. package/dist/dashboard/i18n/ro.json +58 -5
  115. package/dist/dashboard/i18n/ru.json +58 -5
  116. package/dist/dashboard/i18n/sv.json +58 -5
  117. package/dist/dashboard/i18n/tr.json +58 -5
  118. package/dist/dashboard/i18n/uk.json +58 -5
  119. package/dist/dashboard/i18n/zh.json +58 -5
  120. package/dist/dashboard/journal/book.js +3 -2
  121. package/dist/dashboard/journal/journal.js +8 -5
  122. package/dist/dashboard/kit.js +1 -1
  123. package/dist/dashboard/packages/catalog.js +31 -14
  124. package/dist/dashboard/packages/engine.js +46 -2
  125. package/dist/dashboard/packages/installed.js +13 -0
  126. package/dist/dashboard/packages/outcomes.js +21 -0
  127. package/dist/dashboard/packages/packages.js +41 -18
  128. package/dist/dashboard/packages/rows.js +3 -1
  129. package/dist/dashboard/parts/icons.js +3 -0
  130. package/dist/dashboard/parts/labels.js +7 -0
  131. package/dist/dashboard/parts/picture.js +89 -0
  132. package/dist/dashboard/parts/refusals.js +8 -1
  133. package/dist/dashboard/parts/widgets.js +2 -1
  134. package/dist/dashboard/play/scene.js +8 -5
  135. package/dist/dashboard/settings/settings.js +55 -18
  136. package/dist/dashboard/sheet/party.js +5 -2
  137. package/dist/dashboard/sheet/sheet.js +2 -1
  138. package/dist/dashboard/shell/notices.js +2 -2
  139. package/dist/dashboard/shell/system-style.js +132 -15
  140. package/dist/dashboard/shell/tooltip.js +224 -0
  141. package/dist/dashboard/style.css +497 -193
  142. package/dist/dashboard/world/lore.js +4 -3
  143. package/dist/dashboard/world/place-card.js +2 -1
  144. package/dist/git/git.d.ts +12 -0
  145. package/dist/git/git.js +175 -0
  146. package/dist/git/ignore.d.ts +2 -0
  147. package/dist/git/ignore.js +16 -0
  148. package/dist/git/index.d.ts +2 -0
  149. package/dist/git/index.js +2 -0
  150. package/dist/importer/index.d.ts +1 -1
  151. package/dist/importer/index.js +1 -1
  152. package/dist/languages/index.d.ts +1 -1
  153. package/dist/languages/index.js +1 -1
  154. package/dist/languages/pack.d.ts +4 -1
  155. package/dist/languages/pack.js +18 -6
  156. package/dist/packages/engine.d.ts +7 -0
  157. package/dist/packages/engine.js +32 -1
  158. package/dist/packages/index.d.ts +1 -1
  159. package/dist/packages/index.js +1 -1
  160. package/dist/server/bell-listener.d.ts +2 -1
  161. package/dist/server/bell-listener.js +10 -41
  162. package/dist/server/dashboard/engine.d.ts +18 -0
  163. package/dist/server/dashboard/engine.js +31 -0
  164. package/dist/server/dashboard/files.d.ts +11 -3
  165. package/dist/server/dashboard/files.js +66 -17
  166. package/dist/server/dashboard/index.d.ts +18 -2
  167. package/dist/server/dashboard/index.js +62 -23
  168. package/dist/server/dashboard/news.d.ts +3 -2
  169. package/dist/server/dashboard/news.js +19 -5
  170. package/dist/server/dashboard/pictures.d.ts +7 -0
  171. package/dist/server/dashboard/pictures.js +62 -0
  172. package/dist/server/dashboard/ports.d.ts +17 -2
  173. package/dist/server/dashboard/ports.js +60 -4
  174. package/dist/server/dashboard/writes.d.ts +5 -3
  175. package/dist/server/dashboard/writes.js +45 -14
  176. package/dist/server/mcp.d.ts +3 -2
  177. package/dist/server/mcp.js +55 -11
  178. package/dist/testing/index.js +1 -0
  179. package/dist/themes/css.d.ts +1 -1
  180. package/dist/themes/css.js +101 -2
  181. package/dist/themes/index.d.ts +2 -1
  182. package/dist/themes/index.js +4 -2
  183. package/dist/themes/installed.d.ts +14 -0
  184. package/dist/themes/installed.js +28 -0
  185. package/dist/themes/theme.d.ts +38 -0
  186. package/dist/themes/theme.js +192 -13
  187. package/instructions/core.md +4 -3
  188. package/instructions/dashboard-guide.md +2 -1
  189. package/instructions/mentor-hints.md +1 -1
  190. package/instructions/mentor-tutorial.md +1 -1
  191. package/instructions/party.md +1 -1
  192. package/instructions/play.md +2 -2
  193. package/package.json +1 -1
  194. package/systems/free/instructions/outcomes-told.md +1 -1
@@ -2,5 +2,8 @@ import type { Context } from "../../core/context.ts";
2
2
  import type { PackageResult } from "./result.ts";
3
3
  /** Takes an extension out of the campaign; it stays on this computer, for other campaigns. */
4
4
  export declare function removed(root: string, context: Context, name: string): PackageResult;
5
- /** Takes a package off this computer with npm, and out of the campaign when it uses it (D-442); other campaigns that list it ask to install it again. */
5
+ /**
6
+ * Takes a package off this computer with npm, and out of the campaign when it uses it (D-442); other campaigns that list it ask to install it again. A theme
7
+ * or a language of data alone goes by its folder, when no npm package has its name: theme:<id> and language:<code> name them alone.
8
+ */
6
9
  export declare function uninstalled(root: string, context: Context, name: string): Promise<PackageResult>;
@@ -8,8 +8,11 @@ import { comparableText } from "../../core/text.js";
8
8
  import { dropConsent, installedExtensions, shortName } from "../../extensions/index.js";
9
9
  import { isPackageName } from "../../packages/index.js";
10
10
  import { listedExtensions } from "../shared/packages/extensions.js";
11
+ import { findUnpacked, unpackedName } from "../shared/packages/unpacked.js";
11
12
  import { newDatedLogEntry } from "../shared/time/time.js";
12
13
  import { installedExtensionFolder, languagesHere, systemsHere } from "./here.js";
14
+ import { dataLanguageUninstalled } from "./language.js";
15
+ import { themeUninstalled } from "./theme.js";
13
16
  /** Takes an extension out of the campaign; it stays on this computer, for other campaigns. */
14
17
  export function removed(root, context, name) {
15
18
  const listed = listedExtensions(root);
@@ -23,20 +26,37 @@ export function removed(root, context, name) {
23
26
  appendLogEntry(root, newDatedLogEntry(root, context, "package-removed", "public", { package: found }));
24
27
  return { kind: "removed", name: shortName(found) };
25
28
  }
26
- /** Takes a package off this computer with npm, and out of the campaign when it uses it (D-442); other campaigns that list it ask to install it again. */
29
+ /**
30
+ * Takes a package off this computer with npm, and out of the campaign when it uses it (D-442); other campaigns that list it ask to install it again. A theme
31
+ * or a language of data alone goes by its folder, when no npm package has its name: theme:<id> and language:<code> name them alone.
32
+ */
27
33
  export async function uninstalled(root, context, name) {
28
34
  const packages = context.packages;
29
- const system = systemsHere(root, context).find((one) => one.package !== undefined && (one.package === name || comparableText(one.name) === comparableText(name)));
30
- if (system?.used === true) {
31
- throw new Refusal(`The campaign plays ${system.name}: it stays on this computer. Nothing changed.`, "system-played", { name: system.name });
32
- }
33
- const other = system?.package ?? languagesHere(context).find((one) => one.package === name || comparableText(one.code) === comparableText(name))?.package;
35
+ const npmName = name.startsWith("npm:") ? name.slice(4) : name;
36
+ const unpacked = findUnpacked(context, name);
37
+ const system = systemsHere(root, context).find((one) => one.package !== undefined && (one.package === npmName || comparableText(one.name) === comparableText(npmName)));
38
+ const other = system?.package
39
+ ?? languagesHere(context).find((one) => one.unpacked !== true && (one.package === npmName || comparableText(one.code) === comparableText(npmName)))?.package;
34
40
  const found = other === undefined
35
- ? installedExtensions(context.extensionFolders ?? []).find((one) => one.package === name || comparableText(shortName(one.package)) === comparableText(name))
41
+ ? installedExtensions(context.extensionFolders ?? []).find((one) => one.package === npmName || comparableText(shortName(one.package)) === comparableText(npmName))
36
42
  : { package: other };
37
43
  // A package that reads as nothing, as a system whose system.yaml is broken, is still npm's to take away by its folder, under its npm name.
38
- const npmName = name.startsWith("npm:") ? name.slice(4) : name;
39
- if (found === undefined && packages !== undefined && isPackageName(npmName) && (context.extensionFolders ?? []).some((folder) => files().entries(join(folder, ...npmName.split("/"))).length > 0)) {
44
+ const unread = found === undefined && packages !== undefined && isPackageName(npmName)
45
+ && (context.extensionFolders ?? []).some((folder) => files().entries(join(folder, ...npmName.split("/"))).length > 0);
46
+ const npm = unpacked !== undefined && /^(theme|language):/i.test(name) ? undefined : (found?.package ?? (unread ? npmName : undefined));
47
+ // A theme or a language of data alone goes only when no npm package has its name; when both have it, the player says which.
48
+ if (unpacked !== undefined && npm !== undefined) {
49
+ const npmAs = npm.startsWith("@") ? npm : `npm:${npm}`;
50
+ throw new Refusal(`${name} names two packages on this computer: ${npm} from npm, and the ${unpacked.kind} ${unpacked.kind === "theme" ? (unpacked.theme.theme?.name ?? unpacked.theme.id) : unpacked.pack.name}. `
51
+ + `Say which: ${npmAs} for the one from npm, ${unpackedName(unpacked)} for the ${unpacked.kind}. Nothing changed.`, "ambiguous-name", { name, npm: npmAs, unpacked: unpackedName(unpacked) });
52
+ }
53
+ if (unpacked !== undefined) {
54
+ return unpacked.kind === "theme" ? themeUninstalled(root, context, unpacked.theme) : dataLanguageUninstalled(root, context, unpacked.pack);
55
+ }
56
+ if (system?.used === true) {
57
+ throw new Refusal(`The campaign plays ${system.name}: it stays on this computer. Nothing changed.`, "system-played", { name: system.name });
58
+ }
59
+ if (unread && packages !== undefined) {
40
60
  const why = await packages.uninstall(npmName);
41
61
  if (why !== undefined) {
42
62
  throw new Refusal(`${npmName} could not be taken off this computer: ${why}. Nothing changed.`, "uninstall-failed", { name: npmName, why });
@@ -15,6 +15,6 @@ export declare function closedText(result: {
15
15
  fallen?: string;
16
16
  afterPeak?: string;
17
17
  quests: string[];
18
- chapter?: number;
18
+ untold?: number[];
19
19
  craft?: string;
20
20
  } & Saved): string;
@@ -5,7 +5,7 @@ import { readCounter } from "../../counters/index.js";
5
5
  import { findPage, isPartyMember, linksIn, pagesWithName, parsePageReference } from "../../pages/index.js";
6
6
  import { sceneTypes } from "../../scene/index.js";
7
7
  import { formatGameDate } from "../../time/index.js";
8
- import { chapterCraft, sceneChapters } from "../shared/campaign/book.js";
8
+ import { chapterCraft, scenesPerChapter, scenesText, untoldScenes } from "../shared/campaign/book.js";
9
9
  import { firstInChat } from "../shared/campaign/parts.js";
10
10
  import { isTickedOpenQuest, tickedQuestNote } from "../shared/campaign/quests.js";
11
11
  import { isPlayerDead, makeSave, saveText } from "../shared/campaign/saves.js";
@@ -77,10 +77,10 @@ export function close(root, world, summary, context) {
77
77
  ...saved,
78
78
  };
79
79
  }
80
- /** The chapter of the book the scene just closed is, for the master to write, with how to write it once in a chat (T-227). */
80
+ /** The closed scenes that wait for the book's next chapter, for the master to write it where the story turns, with how to write it once in a chat (T-227). */
81
81
  function bookChapter(root, context) {
82
- const chapter = sceneChapters(root).at(-1)?.number;
83
- return chapter === undefined ? {} : { chapter, ...(firstInChat(context, "book") ? { craft: chapterCraft } : {}) };
82
+ const untold = untoldScenes(root).map((scene) => scene.number);
83
+ return untold.length === 0 ? {} : { untold, ...(firstInChat(context, "book") ? { craft: chapterCraft } : {}) };
84
84
  }
85
85
  /**
86
86
  * The save at the end of a scene, named by its title (D-55, SAV-3): none while the player character is dead, since going back is what one is for. A save that
@@ -172,7 +172,7 @@ export function closedText(result) {
172
172
  const advance = "Advance any time it took that you have not advanced yet; write on their pages what it changed for good, such as a fire put out or a door broken.";
173
173
  const endless = result.endless.length === 0 ? "" : `\nStill there, with no end: ${result.endless.join(" · ")}. End those the scene ended, with effect end.`;
174
174
  const ended = `${result.ended.length === 0 ? "" : `\nEnded with the scene: ${result.ended.join(" · ")}.`}${endless}`;
175
- const quests = `${result.quests.map((line) => `\n${line}`).join("")}${chapterLine(result.chapter, result.craft)}`;
175
+ const quests = `${result.quests.map((line) => `\n${line}`).join("")}${chapterLine(result.untold, result.craft)}`;
176
176
  if (result.unreadable !== undefined) {
177
177
  return `The open scene could not be read (${result.unreadable}): closed it, without its copies. ${advance}${ended}${quests}${saved}`;
178
178
  }
@@ -186,7 +186,14 @@ export function closedText(result) {
186
186
  const peak = result.afterPeak === undefined ? "" : `\n${result.afterPeak}`;
187
187
  return `Scene closed${rounds}: ${result.title}.${gone} ${advance}${ended}${left}${fallen}${rewards}${quests}${peak}${saved}`;
188
188
  }
189
- /** The book's chapter the scene leaves to write (T-227). */
190
- function chapterLine(chapter, craft) {
191
- return chapter === undefined ? "" : `\nChapter ${chapter} of the book waits for its prose: write it with book now, while the scene is fresh.${craft === undefined ? "" : ` ${craft}`}`;
189
+ /** The scenes the book's next chapter waits for (T-227): written now where the story turns, and once they are many. */
190
+ function chapterLine(untold, craft) {
191
+ if (untold === undefined) {
192
+ return "";
193
+ }
194
+ const scenes = scenesText(untold.map((number) => ({ number })));
195
+ const when = untold.length >= scenesPerChapter
196
+ ? "write it now with book."
197
+ : "if the story turned here (a goal reached or lost, a place left, a night passed), write it now with book, while the scenes are fresh; else at a later scene's end.";
198
+ return `\nThe book: ${scenes} ${untold.length === 1 ? "waits" : "wait"} for the next chapter; ${when}${craft === undefined ? "" : ` ${craft}`}`;
192
199
  }
@@ -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,10 +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
- /** Whether what was given to package install is an adventure: a .zip, a link, or a folder with adventure.yaml; a document says it is imported instead. */
67
- export declare function isAdventureSpec(spec: string): boolean;
68
- /** The adventure a .zip, a folder or an https link gives (ADV-1): a GitHub repository is read as the zip of its branch. */
69
- export declare function readAdventureSpec(spec: string, context: Context): Promise<AdventureFiles>;
66
+ export declare const installMarkName = ".adventure-install.yaml";
70
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. */
71
68
  export declare function installedAdventures(root: string): InstalledAdventure[];
72
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. */
@@ -1,8 +1,8 @@
1
1
  // The adventures of a campaign (D-476, D-483): installed from a package whole or not at all, taken out while the story has not touched them, and exported as
2
2
  // they were at the start (ADV-1–ADV-7), with the campaign's layers over its game system as they are now (ADV-8).
3
- import { basename, join, relative, resolve, sep } from "node:path";
3
+ import { basename, join, relative, sep } from "node:path";
4
4
  import { parse, parseDocument, stringify, visit } from "yaml";
5
- import { adventureFolderName, adventureTarget, isAdventureFolder, largestAdventure, manifestLine, packAdventure, readAdventureFolder, readAdventureZip } from "../../../adventures/index.js";
5
+ import { adventureFolderName, adventureTarget, manifestLine, packAdventure } from "../../../adventures/index.js";
6
6
  import { houseRulesFolderName, readSettings } from "../../../campaign/index.js";
7
7
  import { appendLogEntry, readLog } from "../../../core/log.js";
8
8
  import { Refusal } from "../../../core/refusal.js";
@@ -25,36 +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";
29
- // The documents a master imports, never a package: their pages are written by the master (D-483 (10)).
30
- const documentPattern = /\.(pdf|docx?|odt|rtf|txt|md|epub)$/i;
31
- /** Whether what was given to package install is an adventure: a .zip, a link, or a folder with adventure.yaml; a document says it is imported instead. */
32
- export function isAdventureSpec(spec) {
33
- if (documentPattern.test(spec)) {
34
- throw new Refusal(`${spec} is a document, not a package: make an adventure from it with import; package install takes only what has adventure.yaml. Nothing changed.`, "document", { name: spec });
35
- }
36
- return /\.zip$/i.test(spec) || /^https:\/\//i.test(spec) || isAdventureFolder(resolve(spec));
37
- }
38
- /** The adventure a .zip, a folder or an https link gives (ADV-1): a GitHub repository is read as the zip of its branch. */
39
- export async function readAdventureSpec(spec, context) {
40
- if (/^https:\/\//i.test(spec)) {
41
- if (context.download === undefined) {
42
- throw new Error("Only the game's server and the command line download an adventure: give a .zip or a folder of this computer.");
43
- }
44
- const repository = /^https:\/\/github\.com\/([^/]+)\/([^/#?]+?)(?:\.git)?(?:\/tree\/([^#?]+))?\/?$/i.exec(spec);
45
- const url = repository === null ? spec : `https://codeload.github.com/${repository[1]}/${repository[2]}/zip/${repository[3] === undefined ? "HEAD" : `refs/heads/${repository[3]}`}`;
46
- return readAdventureZip(await context.download(url, largestAdventure, context.signal), spec);
47
- }
48
- const path = resolve(spec);
49
- if (/\.zip$/i.test(spec)) {
50
- const bytes = files().bytes(path);
51
- if (bytes === undefined) {
52
- throw new Refusal(`There is no file ${path}: give the path of the adventure's .zip. Nothing changed.`, "not-on-computer", { name: path });
53
- }
54
- return readAdventureZip(bytes, basename(path));
55
- }
56
- return readAdventureFolder(path);
57
- }
28
+ export const installMarkName = ".adventure-install.yaml";
58
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. */
59
30
  export function installedAdventures(root) {
60
31
  return adventuresOfLog(readLog(root));
@@ -8,6 +8,7 @@ import { codeAndBase } from "../../../core/language.js";
8
8
  import { files } from "../../../core/store.js";
9
9
  import { languagePackFor, packPhrases } from "../../../languages/index.js";
10
10
  import { layeredSystemWords, systemContentFolders, systemWords } from "../../../systems/index.js";
11
+ import { languageFolders } from "../packages/unpacked.js";
11
12
  // How many phrases go in one request.
12
13
  const batchSize = 130;
13
14
  // How long a language whose translation stopped short waits before it is tried again, so that a writer that fails is not called at every reading.
@@ -51,7 +52,7 @@ export function pageTranslator(context, page, notify) {
51
52
  return {
52
53
  read: (language, system) => {
53
54
  // A translation made by hand, installed as a package, comes before the one made on the fly (D-485 (3)).
54
- const pack = languagePackFor(context.extensionFolders ?? [], language);
55
+ const pack = languagePackFor(languageFolders(context), language);
55
56
  const own = { ...(context.home === undefined ? {} : readJson(join(context.home, "i18n", `${language}.json`))), ...(pack === undefined ? {} : packPhrases(pack)) };
56
57
  const missing = Object.keys(reference()).filter((phrase) => !(phrase in own)).length;
57
58
  const can = context.writer?.ready() === true && context.home !== undefined;
@@ -85,7 +86,7 @@ export function pagePhrase(context, language, phrase) {
85
86
  }
86
87
  const page = context.pageFolder;
87
88
  const codes = codeAndBase(language);
88
- const pack = languagePackFor(context.extensionFolders ?? [], language);
89
+ const pack = languagePackFor(languageFolders(context), language);
89
90
  const shipped = [...codes, codes.at(-1) === "no" ? "nb" : ""].filter((candidate) => candidate !== "").map((candidate) => readJson(join(page, "i18n", `${candidate}.json`)));
90
91
  const own = context.home === undefined ? {} : readJson(join(context.home, "i18n", `${language}.json`));
91
92
  return [pack === undefined ? {} : packPhrases(pack), ...shipped, own].map((phrases) => phrases[phrase]).find((said) => typeof said === "string" && said !== "") ?? phrase;
@@ -1,5 +1,5 @@
1
- /** A scene of the story as a chapter of the book: its number, as the journal counts them, its title and summary, its game date, when it ran in real time, and the log line that opened it. */
2
- export interface SceneChapter {
1
+ /** A scene of the story: its number, as the journal counts them, its title and summary, its game date, when it ran in real time, and the log line that opened it. */
2
+ export interface StoryScene {
3
3
  number: number;
4
4
  title: string;
5
5
  summary?: string;
@@ -15,15 +15,28 @@ export interface BookChapter {
15
15
  title: string;
16
16
  text: string;
17
17
  }
18
+ /** A chapter with the scenes it tells, by their numbers, first and last. */
19
+ export interface WrittenChapter extends BookChapter {
20
+ first: number;
21
+ last: number;
22
+ }
23
+ /** How many closed scenes may wait for their chapter before the master is told to write it now. */
24
+ export declare const scenesPerChapter = 4;
18
25
  /** How the master writes a chapter (T-227): told once in a chat, by the first scene that closes or the first call of book. */
19
26
  export declare const chapterCraft: string;
20
27
  /** The scenes of the story in order, by the public lines of the log, as the journal numbers them: a scene closed with no line that opened it is one too. */
21
- export declare function sceneChapters(root: string): SceneChapter[];
22
- /** The chapters of the book whose scenes are in the story as it stands, in order. */
23
- export declare function campaignBook(root: string): BookChapter[];
24
- /** Writes a scene's chapter, in place of the one it had. */
25
- export declare function writeChapter(root: string, scene: SceneChapter, title: string, text: string): void;
28
+ export declare function storyScenes(root: string): StoryScene[];
29
+ /** The chapters of the book whose scenes are in the story as it stands, in order: each going on from the one before, the first from the first scene. */
30
+ export declare function campaignBook(root: string): WrittenChapter[];
31
+ /** The closed scenes no chapter tells yet, in order: those the next chapter is for. */
32
+ export declare function untoldScenes(root: string, book?: WrittenChapter[]): StoryScene[];
33
+ /** Writes a chapter telling these scenes, in place of the one with its number. */
34
+ export declare function writeChapter(root: string, number: number, scenes: StoryScene[], title: string, text: string): void;
26
35
  /** Takes a chapter out of the book; nothing when it has none. */
27
36
  export declare function removeChapter(root: string, number: number): void;
28
- /** What status says of a book left behind, by a chat closed or a computer turned off: the closed chapters still to write, once the book has begun (T-227). */
37
+ /** What status says of a book left behind, by a chat closed or a computer turned off: the scenes waiting too long for their chapter, once the book has begun. */
29
38
  export declare function bookBehind(root: string): string | undefined;
39
+ /** Scenes by their numbers, as «scene 4» or «scenes 4–7». */
40
+ export declare function scenesText(scenes: {
41
+ number: number;
42
+ }[]): string;
@@ -1,59 +1,74 @@
1
- // The campaign's story told as a book (T-227): a chapter of prose for each closed scene, written by the master into book/, out of the saves. A chapter belongs
2
- // to its scene by the log line that opened it: one whose scene a load undid, or that a reset took away, is left out until the master writes it again.
1
+ // The campaign's story told as a book (T-227): chapters of prose written by the master into book/, out of the saves, each telling the closed scenes since the one
2
+ // before, ended where the story turns. A chapter holds its scenes by the log lines that opened them: one whose scenes a load undid, or that a reset took away, is
3
+ // left out, with those after it, until the master writes it again.
3
4
  import { join } from "node:path";
4
5
  import { parse, stringify } from "yaml";
5
6
  import { bookFolderName } from "../../../campaign/index.js";
6
7
  import { readLog } from "../../../core/log.js";
7
8
  import { files } from "../../../core/store.js";
9
+ /** How many closed scenes may wait for their chapter before the master is told to write it now. */
10
+ export const scenesPerChapter = 4;
8
11
  /** How the master writes a chapter (T-227): told once in a chat, by the first scene that closes or the first call of book. */
9
12
  export const chapterCraft = "How to write a chapter: as a chapter of a novel, never a summary or a report. In the campaign's language, third person with an outside narrator, in the prose style the player chose: "
10
- + "its voice binds the book, its limits on length and its endings in play do not. Pick up where the last chapter left off (book with its number reads it back), without retelling it. "
13
+ + "its voice binds the book, its limits on length and its endings in play do not. A chapter tells the scenes closed since the last one, ended where the story turns: a goal reached or lost, a place left, a night passed. "
14
+ + "Pick up where the last chapter left off (book with its number reads it back), without retelling it. "
11
15
  + "Tell it in scenes: places, gestures, silences, and people's words as dialogue where they mattered; summary only for roads and time passing. "
12
16
  + "The player character does and says only what the player played: their words may be put better, never a deed, a line or a choice of yours added. "
13
17
  + "Only what the player saw and learned: no secret, no hidden roll, nothing you planned, no conclusion they did not reach. No game words: no rolls, points, turns, nor a condition by its game name. "
14
- + "As long as the scene deserves, from about 500 words for a short one to 2000 for a great one; end on an image or a line, never on a question to the player. A chapter may take a title of its own. "
18
+ + "As long as its scenes deserve, from about 1500 words to 4000: a short scene a page of it, a great one most of it; end on an image or a line, never on a question to the player. "
15
19
  + "Paragraphs apart by a blank line, *italics* where a voice or a thought needs them, *** alone on a line for a break within the chapter.";
16
20
  /** The scenes of the story in order, by the public lines of the log, as the journal numbers them: a scene closed with no line that opened it is one too. */
17
- export function sceneChapters(root) {
18
- const chapters = [];
21
+ export function storyScenes(root) {
22
+ const scenes = [];
19
23
  let open;
20
24
  for (const entry of readLog(root).filter((line) => line.visibility === "public")) {
21
25
  if (entry.type !== "scene-opened" && entry.type !== "scene-closed") {
22
26
  continue;
23
27
  }
24
- const scene = entry.type === "scene-opened" ? undefined : open;
25
- const chapter = scene ?? {
26
- number: chapters.length + 1,
28
+ const known = entry.type === "scene-opened" ? undefined : open;
29
+ const scene = known ?? {
30
+ number: scenes.length + 1,
27
31
  title: String(entry.data.title ?? ""),
28
32
  ...(entry.date === undefined ? {} : { date: entry.date }),
29
33
  from: entry.at,
30
34
  scene: entry.id,
31
35
  };
32
- if (scene === undefined) {
33
- chapters.push(chapter);
36
+ if (known === undefined) {
37
+ scenes.push(scene);
34
38
  }
35
39
  if (entry.type === "scene-opened") {
36
- open = chapter;
40
+ open = scene;
37
41
  continue;
38
42
  }
39
43
  const summary = typeof entry.data.summary === "string" ? entry.data.summary.trim() : "";
40
- Object.assign(chapter, { to: entry.at }, summary === "" ? {} : { summary });
44
+ Object.assign(scene, { to: entry.at }, summary === "" ? {} : { summary });
41
45
  open = undefined;
42
46
  }
43
- return chapters;
47
+ return scenes;
44
48
  }
45
- /** The chapters of the book whose scenes are in the story as it stands, in order. */
49
+ /** The chapters of the book whose scenes are in the story as it stands, in order: each going on from the one before, the first from the first scene. */
46
50
  export function campaignBook(root) {
47
- const scenes = new Map(sceneChapters(root).map((scene) => [scene.number, scene.scene]));
48
- return writtenChapters(root)
49
- .filter((chapter) => scenes.get(chapter.number) === chapter.scene)
50
- .sort((one, other) => one.number - other.number)
51
- .map(({ number, title, text }) => ({ number, title, text }));
51
+ const scenes = storyScenes(root);
52
+ const book = [];
53
+ for (const chapter of writtenChapters(root).sort((one, other) => one.number - other.number)) {
54
+ const told = scenes.slice(chapter.first - 1, chapter.last);
55
+ const follows = chapter.number === book.length + 1 && chapter.first === (book.at(-1)?.last ?? 0) + 1;
56
+ if (!follows || told.length !== chapter.scenes.length || told.some((scene, index) => scene.scene !== chapter.scenes[index] || scene.to === undefined)) {
57
+ break;
58
+ }
59
+ book.push({ number: chapter.number, title: chapter.title, text: chapter.text, first: chapter.first, last: chapter.last });
60
+ }
61
+ return book;
62
+ }
63
+ /** The closed scenes no chapter tells yet, in order: those the next chapter is for. */
64
+ export function untoldScenes(root, book = campaignBook(root)) {
65
+ const told = book.at(-1)?.last ?? 0;
66
+ return storyScenes(root).filter((scene) => scene.number > told && scene.to !== undefined);
52
67
  }
53
- /** Writes a scene's chapter, in place of the one it had. */
54
- export function writeChapter(root, scene, title, text) {
55
- const head = stringify({ chapter: scene.number, title, scene: scene.scene }, { lineWidth: 0 });
56
- files().write(chapterPath(root, scene.number), `---\n${head}---\n\n${text}\n`);
68
+ /** Writes a chapter telling these scenes, in place of the one with its number. */
69
+ export function writeChapter(root, number, scenes, title, text) {
70
+ const head = stringify({ chapter: number, title, scenes: scenes.map((scene) => scene.scene) }, { lineWidth: 0 });
71
+ files().write(chapterPath(root, number), `---\n${head}---\n\n${text}\n`);
57
72
  }
58
73
  /** Takes a chapter out of the book; nothing when it has none. */
59
74
  export function removeChapter(root, number) {
@@ -62,34 +77,42 @@ export function removeChapter(root, number) {
62
77
  files().remove(path);
63
78
  }
64
79
  }
80
+ /** What status says of a book left behind, by a chat closed or a computer turned off: the scenes waiting too long for their chapter, once the book has begun. */
81
+ export function bookBehind(root) {
82
+ const book = campaignBook(root);
83
+ const untold = untoldScenes(root, book);
84
+ return book.length === 0 || untold.length < scenesPerChapter ? undefined : `The book is behind: ${scenesText(untold)} wait for their chapter. Write it with book before the story goes on; book lists them with their chats.`;
85
+ }
86
+ /** Scenes by their numbers, as «scene 4» or «scenes 4–7». */
87
+ export function scenesText(scenes) {
88
+ const first = scenes[0]?.number;
89
+ const last = scenes.at(-1)?.number;
90
+ return first === last ? `scene ${first}` : `scenes ${first}–${last}`;
91
+ }
65
92
  function chapterPath(root, number) {
66
93
  return join(root, bookFolderName, `${String(number).padStart(3, "0")}.md`);
67
94
  }
68
- /** The chapters written in the book folder, each with the scene it was written for; a file that does not read as one is left out. */
95
+ /** The chapters written in the book folder, each with the scenes it tells, after the scenes before it; a file that does not read as one is left out. */
69
96
  function writtenChapters(root) {
70
- return files().files(join(root, bookFolderName), (name) => /^\d+\.md$/.test(name)).flatMap((path) => {
71
- const read = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(files().text(path) ?? "");
97
+ const read = files().files(join(root, bookFolderName), (name) => /^\d+\.md$/.test(name)).flatMap((path) => {
98
+ const parts = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/.exec(files().text(path) ?? "");
72
99
  try {
73
- const head = read === null ? undefined : parse(read[1]);
74
- if (read === null || head === null || head === undefined || typeof head.chapter !== "number" || typeof head.scene !== "string") {
100
+ const head = parts === null ? undefined : parse(parts[1]);
101
+ const scenes = Array.isArray(head?.scenes) ? head.scenes.filter((scene) => typeof scene === "string") : [];
102
+ if (parts === null || head === null || head === undefined || typeof head.chapter !== "number" || scenes.length === 0) {
75
103
  return [];
76
104
  }
77
- return [{ number: head.chapter, title: typeof head.title === "string" ? head.title : "", text: read[2].trim(), scene: head.scene }];
105
+ return [{ number: head.chapter, title: typeof head.title === "string" ? head.title : "", text: parts[2].trim(), scenes }];
78
106
  }
79
107
  catch {
80
108
  return [];
81
109
  }
110
+ }).sort((one, other) => one.number - other.number);
111
+ // Each chapter goes on from the scenes of those before it.
112
+ let told = 0;
113
+ return read.map((chapter) => {
114
+ const first = told + 1;
115
+ told += chapter.scenes.length;
116
+ return { ...chapter, first, last: told };
82
117
  });
83
118
  }
84
- /** What status says of a book left behind, by a chat closed or a computer turned off: the closed chapters still to write, once the book has begun (T-227). */
85
- export function bookBehind(root) {
86
- const written = campaignBook(root);
87
- if (written.length === 0) {
88
- return undefined;
89
- }
90
- const missing = sceneChapters(root).filter((scene) => scene.to !== undefined && !written.some((chapter) => chapter.number === scene.number)).map((scene) => scene.number);
91
- const list = missing.length > 10 ? `${missing.slice(0, 10).join(", ")}…` : missing.join(", ");
92
- return missing.length === 0
93
- ? undefined
94
- : `The book lacks ${missing.length === 1 ? "chapter" : "chapters"} ${list}, of scenes closed: write ${missing.length === 1 ? "it" : "them"} with book before the story goes on; book lists them with their chats.`;
95
- }
@@ -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
+ }