rpg-engine 0.21.0 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/README.md +5 -5
  2. package/dist/campaign/create-campaign.d.ts +5 -0
  3. package/dist/campaign/create-campaign.js +40 -12
  4. package/dist/campaign/find-campaign.d.ts +5 -0
  5. package/dist/campaign/find-campaign.js +10 -5
  6. package/dist/campaign/host-files.d.ts +15 -4
  7. package/dist/campaign/host-files.js +134 -14
  8. package/dist/campaign/index.d.ts +4 -3
  9. package/dist/campaign/index.js +4 -3
  10. package/dist/campaign/port.d.ts +6 -0
  11. package/dist/campaign/port.js +24 -0
  12. package/dist/campaign/settings.d.ts +17 -0
  13. package/dist/campaign/settings.js +24 -1
  14. package/dist/cli/cli.js +33 -6
  15. package/dist/commands/config/config.js +15 -1
  16. package/dist/commands/config/dashboard.d.ts +4 -0
  17. package/dist/commands/config/dashboard.js +43 -7
  18. package/dist/commands/config/shown.js +4 -0
  19. package/dist/commands/config/words.d.ts +3 -1
  20. package/dist/commands/config/words.js +29 -2
  21. package/dist/commands/image.d.ts +3 -0
  22. package/dist/commands/image.js +31 -4
  23. package/dist/commands/import/import.d.ts +1 -1
  24. package/dist/commands/import/import.js +5 -0
  25. package/dist/commands/init.d.ts +2 -0
  26. package/dist/commands/init.js +21 -3
  27. package/dist/commands/mode.d.ts +1 -1
  28. package/dist/commands/package/data.js +27 -0
  29. package/dist/commands/package/theme.js +2 -1
  30. package/dist/commands/scene/scene.js +6 -1
  31. package/dist/commands/shared/books/adventures.d.ts +1 -0
  32. package/dist/commands/shared/books/adventures.js +1 -1
  33. package/dist/commands/shared/campaign/git.d.ts +25 -0
  34. package/dist/commands/shared/campaign/git.js +104 -0
  35. package/dist/commands/shared/campaign/images.js +5 -3
  36. package/dist/commands/shared/campaign/saves.js +5 -1
  37. package/dist/commands/shared/characters/voices.d.ts +2 -2
  38. package/dist/commands/shared/characters/voices.js +8 -5
  39. package/dist/commands/shared/packages/catalog.js +24 -5
  40. package/dist/commands/status.d.ts +1 -0
  41. package/dist/commands/status.js +8 -4
  42. package/dist/core/context.d.ts +17 -6
  43. package/dist/core/context.js +2 -1
  44. package/dist/core/version.d.ts +2 -0
  45. package/dist/core/version.js +5 -0
  46. package/dist/dashboard/guide/ar.md +12 -7
  47. package/dist/dashboard/guide/cs.md +11 -6
  48. package/dist/dashboard/guide/da.md +11 -6
  49. package/dist/dashboard/guide/de.md +13 -8
  50. package/dist/dashboard/guide/el.md +11 -6
  51. package/dist/dashboard/guide/en.md +10 -5
  52. package/dist/dashboard/guide/es.md +11 -6
  53. package/dist/dashboard/guide/fi.md +11 -6
  54. package/dist/dashboard/guide/fr.md +12 -7
  55. package/dist/dashboard/guide/he.md +11 -6
  56. package/dist/dashboard/guide/hi.md +11 -6
  57. package/dist/dashboard/guide/hu.md +11 -6
  58. package/dist/dashboard/guide/is.md +11 -6
  59. package/dist/dashboard/guide/it.md +42 -37
  60. package/dist/dashboard/guide/ja.md +12 -7
  61. package/dist/dashboard/guide/ko.md +11 -6
  62. package/dist/dashboard/guide/nb.md +12 -7
  63. package/dist/dashboard/guide/nl.md +13 -8
  64. package/dist/dashboard/guide/pl.md +11 -6
  65. package/dist/dashboard/guide/pt.md +11 -6
  66. package/dist/dashboard/guide/ro.md +11 -6
  67. package/dist/dashboard/guide/ru.md +12 -7
  68. package/dist/dashboard/guide/sv.md +11 -6
  69. package/dist/dashboard/guide/tr.md +12 -7
  70. package/dist/dashboard/guide/uk.md +12 -7
  71. package/dist/dashboard/guide/zh.md +11 -6
  72. package/dist/dashboard/i18n/ar.json +30 -2
  73. package/dist/dashboard/i18n/cs.json +30 -2
  74. package/dist/dashboard/i18n/da.json +30 -2
  75. package/dist/dashboard/i18n/de.json +30 -2
  76. package/dist/dashboard/i18n/el.json +30 -2
  77. package/dist/dashboard/i18n/es.json +30 -2
  78. package/dist/dashboard/i18n/fi.json +30 -2
  79. package/dist/dashboard/i18n/fr.json +30 -2
  80. package/dist/dashboard/i18n/he.json +30 -2
  81. package/dist/dashboard/i18n/hi.json +30 -2
  82. package/dist/dashboard/i18n/hu.json +30 -2
  83. package/dist/dashboard/i18n/is.json +30 -2
  84. package/dist/dashboard/i18n/it.json +30 -2
  85. package/dist/dashboard/i18n/ja.json +30 -2
  86. package/dist/dashboard/i18n/ko.json +30 -2
  87. package/dist/dashboard/i18n/nb.json +30 -2
  88. package/dist/dashboard/i18n/nl.json +30 -2
  89. package/dist/dashboard/i18n/pl.json +30 -2
  90. package/dist/dashboard/i18n/pt.json +30 -2
  91. package/dist/dashboard/i18n/ro.json +30 -2
  92. package/dist/dashboard/i18n/ru.json +30 -2
  93. package/dist/dashboard/i18n/sv.json +30 -2
  94. package/dist/dashboard/i18n/tr.json +30 -2
  95. package/dist/dashboard/i18n/uk.json +30 -2
  96. package/dist/dashboard/i18n/zh.json +30 -2
  97. package/dist/dashboard/packages/installed.js +2 -2
  98. package/dist/dashboard/packages/packages.js +1 -1
  99. package/dist/dashboard/parts/labels.js +7 -0
  100. package/dist/dashboard/settings/settings.js +45 -9
  101. package/dist/dashboard/shell/notices.js +1 -1
  102. package/dist/dashboard/shell/system-style.js +89 -5
  103. package/dist/dashboard/shell/tooltip.js +5 -4
  104. package/dist/dashboard/style.css +245 -84
  105. package/dist/git/git.d.ts +12 -0
  106. package/dist/git/git.js +175 -0
  107. package/dist/git/ignore.d.ts +2 -0
  108. package/dist/git/ignore.js +16 -0
  109. package/dist/git/index.d.ts +2 -0
  110. package/dist/git/index.js +2 -0
  111. package/dist/helpers/briefs.d.ts +4 -0
  112. package/dist/helpers/briefs.js +13 -0
  113. package/dist/helpers/chosen.d.ts +8 -4
  114. package/dist/helpers/chosen.js +38 -14
  115. package/dist/helpers/index.d.ts +3 -2
  116. package/dist/helpers/index.js +5 -3
  117. package/dist/helpers/opencode.d.ts +13 -0
  118. package/dist/helpers/opencode.js +202 -0
  119. package/dist/importer/index.d.ts +1 -1
  120. package/dist/importer/index.js +1 -1
  121. package/dist/instructions/index.d.ts +2 -2
  122. package/dist/instructions/index.js +3 -3
  123. package/dist/languages/pack.js +2 -1
  124. package/dist/server/approver.d.ts +4 -2
  125. package/dist/server/approver.js +27 -7
  126. package/dist/server/bell/antigravity.d.ts +10 -0
  127. package/dist/server/bell/antigravity.js +95 -0
  128. package/dist/server/bell/index.d.ts +2 -0
  129. package/dist/server/bell/index.js +2 -0
  130. package/dist/server/bell/listener.d.ts +43 -0
  131. package/dist/server/bell/listener.js +149 -0
  132. package/dist/server/dashboard/files.d.ts +3 -2
  133. package/dist/server/dashboard/files.js +44 -15
  134. package/dist/server/dashboard/index.d.ts +25 -3
  135. package/dist/server/dashboard/index.js +58 -23
  136. package/dist/server/dashboard/news.d.ts +5 -2
  137. package/dist/server/dashboard/news.js +82 -14
  138. package/dist/server/dashboard/ports.d.ts +17 -2
  139. package/dist/server/dashboard/ports.js +60 -4
  140. package/dist/server/mcp.d.ts +6 -4
  141. package/dist/server/mcp.js +66 -18
  142. package/dist/server/player-acts.d.ts +21 -1
  143. package/dist/server/player-acts.js +38 -2
  144. package/dist/server/route/front.d.ts +3 -0
  145. package/dist/server/route/front.js +97 -0
  146. package/dist/server/route/index.d.ts +3 -0
  147. package/dist/server/route/index.js +3 -0
  148. package/dist/server/route/notes.d.ts +8 -0
  149. package/dist/server/route/notes.js +50 -0
  150. package/dist/server/route/router.d.ts +31 -0
  151. package/dist/server/route/router.js +215 -0
  152. package/dist/themes/css.d.ts +1 -1
  153. package/dist/themes/css.js +101 -2
  154. package/dist/themes/index.d.ts +1 -1
  155. package/dist/themes/index.js +1 -1
  156. package/dist/themes/theme.d.ts +34 -3
  157. package/dist/themes/theme.js +176 -19
  158. package/instructions/core.md +1 -0
  159. package/instructions/dashboard-guide.md +1 -1
  160. package/instructions/start.md +1 -1
  161. package/instructions/voices-opencode.md +1 -0
  162. package/package.json +3 -2
  163. package/plugins/opencode.js +174 -0
  164. package/dist/server/bell-listener.d.ts +0 -9
  165. package/dist/server/bell-listener.js +0 -83
package/dist/cli/cli.js CHANGED
@@ -2,20 +2,32 @@
2
2
  import { runCommandLine } from "./command-line.js";
3
3
  const args = process.argv.slice(2);
4
4
  // "rpg mcp" turns the process into a server for an AI host; "rpg --read-library" reads the player's books apart, as rules starts it (LIB-3); "rpg --listen"
5
- // is Claude Code's doorbell for the player's sentences on the dashboard (D-495); "rpg --approve" is Antigravity's hook that lets the rpg tools run; everything
6
- // else is a command.
5
+ // is the doorbell for the player's sentences on the dashboard (D-495), Claude Code's, or with its host's name another's (D-578); "rpg --approve" is
6
+ // Antigravity's hook that lets the rpg tools run; everything else is a command.
7
7
  if (args.length === 1 && args[0] === "mcp") {
8
8
  // The server and its SDK load only here: every other command starts faster without them (D-194).
9
9
  const { startMcpServer } = await import("../server/mcp.js");
10
- await startMcpServer();
10
+ const { serverInput } = await import("../server/route/index.js");
11
+ // Outside a campaign the router serves (D-578), through children, for Antigravity's app; in one, the server as always.
12
+ const input = serverInput();
13
+ if (input !== undefined) {
14
+ await startMcpServer(input);
15
+ }
11
16
  }
12
17
  else if (args[0] === "--read-library") {
13
18
  const { readLibraryHere } = await import("../commands/shared/books/library-reader.js");
14
19
  await readLibraryHere();
15
20
  }
16
- else if (args.length === 1 && args[0] === "--listen") {
17
- const { listenHere } = await import("../server/bell-listener.js");
18
- await listenHere();
21
+ else if (args[0] === "--listen" && args.length <= 2) {
22
+ const { listen, listeningHosts } = await import("../server/bell/index.js");
23
+ const host = listeningHosts.find((one) => one === (args[1] ?? "claude"));
24
+ if (host === undefined) {
25
+ console.error(`rpg --listen does not know the host ${args[1]}: give one of ${listeningHosts.join(", ")}, or none for Claude Code.`);
26
+ process.exitCode = 1;
27
+ }
28
+ else {
29
+ await listen(host);
30
+ }
19
31
  }
20
32
  else if (args.length === 1 && args[0] === "--approve") {
21
33
  const { approveHere } = await import("../server/approver.js");
@@ -30,4 +42,19 @@ else {
30
42
  console.error(output);
31
43
  }
32
44
  process.exitCode = exitCode;
45
+ await waitForGit();
46
+ }
47
+ /** The commit a command started, and its push, which the process waits for anyway: said, then what went wrong, if anything (D-576). */
48
+ async function waitForGit() {
49
+ const { gitProblem, gitUnderWay } = await import("../commands/shared/campaign/git.js");
50
+ for (const { root, pushes, done } of gitUnderWay()) {
51
+ if (pushes) {
52
+ console.error("Pushing the campaign to git…");
53
+ }
54
+ await done;
55
+ const problem = gitProblem(root);
56
+ if (problem !== undefined) {
57
+ console.error(`git: the ${problem.act} failed: ${problem.why}`);
58
+ }
59
+ }
33
60
  }
@@ -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.
@@ -157,6 +188,8 @@ const madeBy = {
157
188
  Claude: "Claude draws them on this computer, as vector pictures, from your Claude plan.",
158
189
  Antigravity: "Antigravity makes them in your chat, from your Google plan.",
159
190
  };
191
+ // The chat in use draws them itself, as OpenCode (D-572).
192
+ const drawnInChat = "{maker} draws them in your chat, as simple vector pictures, from your plan.";
160
193
  // The master makes them with an image tool of its own, as ElevenLabs's (D-572).
161
194
  const madeWithTool = "The master makes them with {tool}.";
162
195
  const toolAsked = "The master asks you in the chat which tool to use.";
@@ -166,7 +199,7 @@ const madeMeanwhile = "{by} makes them meanwhile.";
166
199
  // Whoever makes them, the player may give a page a picture of their own (D-572 (3)).
167
200
  const ownPicture = "You can also give a page you see a picture of your own: with its picture button, or dropped in the campaign's inbox folder for the master.";
168
201
  /** Every note the pictures' setting may have, which the dashboard writes in its language (D-394). */
169
- export const picturesNotes = [...Object.values(madeBy), madeWithTool, toolAsked, refusedNote, madeMeanwhile, ownPicture, ...[...Object.values(codexSays), ...Object.values(claudeSays)].map(notReadyText)];
202
+ export const picturesNotes = [...Object.values(madeBy), drawnInChat, madeWithTool, toolAsked, refusedNote, madeMeanwhile, ownPicture, ...[...Object.values(codexSays), ...Object.values(claudeSays)].map(notReadyText)];
170
203
  /**
171
204
  * Whether this computer makes pictures, and with whose plan, in the player's words (D-308, D-390); why not and how to have them; where the maker the player
172
205
  * chose made none and the chat in use makes them, why (D-572); nothing where no maker is asked.
@@ -191,6 +224,9 @@ function picturesReadyNote(context) {
191
224
  if (ready.askTool === true) {
192
225
  return { note: { text: toolAsked } };
193
226
  }
227
+ if (ready.draws === true) {
228
+ return { note: { text: drawnInChat, values: { maker: ready.maker ?? "" } } };
229
+ }
194
230
  return { note: { text: madeBy[ready.maker === "Claude" || ready.maker === "Antigravity" ? ready.maker : "Codex"] } };
195
231
  }
196
232
  /** The pictures' note with the line that the player may give a picture of their own after it. */
@@ -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: {
@@ -148,7 +153,7 @@ export const playerWords = {
148
153
  about: "who makes the pictures",
149
154
  values: pictureMakers,
150
155
  means: {
151
- chat: "your AI app, by its own means: Claude draws them as vector pictures, Codex and Antigravity paint them, each from your plan",
156
+ chat: "your AI app, by its own means: Claude draws them as vector pictures, Codex and Antigravity paint them, OpenCode and the other apps draw simple vector pictures in the chat, each from your plan",
152
157
  codex: "Codex paints them on this computer, from your ChatGPT plan (Plus or higher)",
153
158
  elevenlabs: "the master makes them with ElevenLabs, connected to your AI app, from your ElevenLabs plan",
154
159
  other: "another image tool connected to your AI app: the master asks you which in the chat",
@@ -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.
@@ -19,6 +19,8 @@ interface ImageResult {
19
19
  tool?: string;
20
20
  /** The player chose another image tool and has not named it yet: the master asks which (D-572). */
21
21
  askTool?: true;
22
+ /** The brief is the SVG one: the chat draws the picture itself and gives it with svg (D-572). */
23
+ draw?: true;
22
24
  /** Why the chat in use made it, or makes it, in place of the maker the player chose (D-572). */
23
25
  instead?: string;
24
26
  }
@@ -26,6 +28,7 @@ export declare const image: import("../core/registry.ts").Command<z.ZodObject<{
26
28
  page: z.ZodString;
27
29
  file: z.ZodOptional<z.ZodString>;
28
30
  url: z.ZodOptional<z.ZodString>;
31
+ svg: z.ZodOptional<z.ZodString>;
29
32
  describe: z.ZodOptional<z.ZodString>;
30
33
  }, z.core.$strip>, ImageResult>;
31
34
  /** Writes a picture into the campaign's images folder and links it in the page, logging it; `from` is the file it was read from, if any. */
@@ -5,6 +5,7 @@ import { appendLogEntry } from "../core/log.js";
5
5
  import { defineCommand } from "../core/registry.js";
6
6
  import { files, isInside } from "../core/store.js";
7
7
  import { comparableText, withArticle } from "../core/text.js";
8
+ import { cleanSvg, svgIn } from "../helpers/index.js";
8
9
  import { imageFileName, imageLink, imageOfBytes, imagesFolderName, largestImage, readImage } from "../images/index.js";
9
10
  import { baseChain, findPage, isPartyMember, ownField, pageNamed, parsePageReference, writePage } from "../pages/index.js";
10
11
  import { imageFile, ownImage } from "./shared/campaign/images.js";
@@ -17,7 +18,8 @@ export const image = defineCommand({
17
18
  name: "image",
18
19
  description: "Give a page its picture: a portrait for a character, an image for a creature, an item or a place, as the dashboard will show it in a round token. "
19
20
  + "It copies the file into the campaign and links it in the page's image field; a page without one shows the picture of the page it derives from, such as a wolf's icon. "
20
- + "Use it when the player gives you a picture, or after you made one with your own tools: its file, or url with the https address your tool gives, which the engine downloads. "
21
+ + "Use it when the player gives you a picture, or after you made one with your own tools: its file, url with the https address your tool gives, which the engine downloads, "
22
+ + "or svg with the code you drew. "
21
23
  + "The player may drop pictures in the campaign's inbox folder: ask what each is for, give it, then delete it from the inbox. "
22
24
  + "For a place, a quest, a character or a creature of the campaign, describe instead of file has the picture made on this computer, as the campaign's pictures setting allows: "
23
25
  + "for the player character or a companion only when the player asks; for a creature once for each kind, whose copies show it. "
@@ -28,6 +30,7 @@ export const image = defineCommand({
28
30
  page: z.string().describe("the page that gets the picture"),
29
31
  file: z.string().optional().describe("the picture's file, PNG, JPEG, WebP or SVG up to 5 MB: its full path or one from the folder the command runs in; leave it and url out to remove the page's own picture"),
30
32
  url: z.string().optional().describe("instead of file, the picture's https address, as an image tool gives it: the engine downloads it, the same formats up to 5 MB"),
33
+ svg: z.string().optional().describe("instead of file, the picture's SVG code, from <svg to </svg>, as you drew it from the brief image gave you: the engine cleans it and keeps it"),
31
34
  describe: z.string().optional().describe("instead of file, in a few lines, never a victim or wounds: for a place, what the party sees arriving; for a quest, what the character knows of it; "
32
35
  + "for one of the party, their look, their people as this world has them and the rest as the player described it; for a character or a creature met, what the character sees of them, "
33
36
  + "a disguise as the disguise; never what the character does not know. The picture is made where it can be, and comes by itself"),
@@ -44,6 +47,13 @@ export const image = defineCommand({
44
47
  }
45
48
  const url = input.url?.trim() ?? "";
46
49
  const file = input.file?.trim() ?? "";
50
+ const svg = input.svg?.trim() ?? "";
51
+ if (svg !== "") {
52
+ if (file !== "" || url !== "" || (input.describe ?? "").trim() !== "") {
53
+ throw new Error("Give svg alone: it is the picture you drew, and file, url and describe are other ways to give one. Nothing changed.");
54
+ }
55
+ return drawnImage(root, context, world, page, svg);
56
+ }
47
57
  if (input.describe !== undefined && input.describe.trim() !== "") {
48
58
  if (file !== "" || url !== "") {
49
59
  throw new Error("Give file, url or describe, one of them: file and url are a picture you have, describe has one made. Nothing changed.");
@@ -63,7 +73,7 @@ export const image = defineCommand({
63
73
  },
64
74
  format(result) {
65
75
  if (result.paint !== undefined) {
66
- const how = result.askTool === true ? askToolText(result.page) : paintText(result.page, result.tool);
76
+ const how = result.draw === true ? drawText(result.page) : result.askTool === true ? askToolText(result.page) : paintText(result.page, result.tool);
67
77
  return `${result.instead === undefined ? "" : `${result.instead} `}${how}\n\n${result.paint}`;
68
78
  }
69
79
  if (result.making === true) {
@@ -99,6 +109,19 @@ async function downloadedImage(root, context, world, page, url) {
99
109
  });
100
110
  return placeImage(root, context, world, page, imageOfBytes(bytes, "What the address gave"));
101
111
  }
112
+ /**
113
+ * The picture the chat drew as SVG code (D-572), as OpenCode's, whose own writing is denied in a campaign: cleaned as Claude's drawing is, then taken as a file
114
+ * is; refused with how to draw it again when nothing usable is left.
115
+ */
116
+ function drawnImage(root, context, world, page, code) {
117
+ const drawn = svgIn(code);
118
+ const clean = drawn === undefined ? undefined : cleanSvg(drawn);
119
+ if (clean === undefined) {
120
+ throw new Error("svg takes the picture's SVG code, and this is none the engine can use: give one <svg> root that closes, under 100 KB, with only shapes, groups, gradients, masks and blur, "
121
+ + "no text, script, style or image; draw it again so, or go on without. Nothing changed.");
122
+ }
123
+ return placeImage(root, context, world, page, imageOfBytes(Buffer.from(clean), "The SVG"));
124
+ }
102
125
  /** Writes a picture into the campaign's images folder and links it in the page, logging it; `from` is the file it was read from, if any. */
103
126
  export function placeImage(root, context, world, page, picture, from) {
104
127
  if ("problem" in picture) {
@@ -166,7 +189,7 @@ function madePicture(root, context, world, page, seen) {
166
189
  // The chat paints it itself, with its own tool or one it names.
167
190
  if (paint !== undefined) {
168
191
  const instead = ready.instead === undefined ? {} : { instead: insteadText(page.name, ready.instead, false) };
169
- const tool = ready.askTool === true ? { askTool: true } : ready.tool === undefined ? {} : { tool: ready.tool };
192
+ const tool = ready.draws === true ? { draw: true } : ready.askTool === true ? { askTool: true } : ready.tool === undefined ? {} : { tool: ready.tool };
170
193
  return { page: page.name, changed: false, paint, ...tool, ...instead };
171
194
  }
172
195
  const making = context.pictures.make(subject).then((made) => {
@@ -204,7 +227,7 @@ function insteadText(name, instead, made) {
204
227
  function paintText(page, tool) {
205
228
  const give = giveText(page);
206
229
  if (tool === undefined) {
207
- return `Make ${page}'s picture yourself with your own image tool, from this brief, then ${give}; if your tool makes none, go on without.`;
230
+ return `Make ${page}'s picture yourself with your own image tool, from this brief, then ${give}; if your tool makes none, draw it as the brief's last line says, or go on without.`;
208
231
  }
209
232
  if (tool === "ElevenLabs") {
210
233
  return `Make ${page}'s picture with your ElevenLabs image tool, from this brief: one picture (generations_count 1). Its view shows the player the progress, but the game needs the finished file: `
@@ -213,6 +236,10 @@ function paintText(page, tool) {
213
236
  }
214
237
  return `Make ${page}'s picture with ${tool}, from this brief, then ${give}; if it makes none, tell the player why and go on without.`;
215
238
  }
239
+ /** How the master of a chat that draws itself makes a picture (D-572): as SVG code, from the brief, given back with svg. */
240
+ function drawText(page) {
241
+ return `Draw ${page}'s picture yourself as SVG code, from this brief, then give it with image, page ${page}, svg and the code; if you cannot, go on without.`;
242
+ }
216
243
  /** What the master does where the player chose another image tool without naming it (D-572): asks which, writes it, then makes the picture with it. */
217
244
  function askToolText(page) {
218
245
  return `The player chose another image tool for the pictures and has not named it: ask them which, set its name with config pictures-by, then make ${page}'s picture with it from this brief `
@@ -22,7 +22,7 @@ interface ImportResult {
22
22
  /** How many of the document's pages were read from their pictures, as it started (LIB-4). */
23
23
  recognized?: number;
24
24
  /** Begun now by a helper, named when known: the player hears whose plan reads the document, and under whose terms (D-493). */
25
- helper?: "Claude Code" | "Codex" | "a helper";
25
+ helper?: "Claude Code" | "Codex" | "OpenCode" | "a helper";
26
26
  }
27
27
  export declare const importCommand: import("../../core/registry.ts").Command<z.ZodObject<{
28
28
  document: z.ZodOptional<z.ZodString>;
@@ -374,6 +374,11 @@ function helperText(helper) {
374
374
  if (helper === undefined) {
375
375
  return "";
376
376
  }
377
+ // OpenCode reads with the model the player chose in it, whose maker is the one the document goes to.
378
+ if (helper === "OpenCode") {
379
+ return "Tell the player in a few words that their own OpenCode reads it, with the model they last chose in it and on its plan or price, and that the whole document "
380
+ + "goes to that model's provider, or stays on their computer with a local model, under the terms of their account, its choice on training included.";
381
+ }
377
382
  const [program, company] = helper === "Codex" ? ["Codex", "OpenAI"] : helper === "Claude Code" ? ["Claude Code", "Anthropic"] : ["Claude Code or Codex", "Anthropic or OpenAI"];
378
383
  return `Tell the player in a few words that their own ${program} reads it, on their plan and its limits, and that the whole document goes to ${company} `
379
384
  + "under the terms of their account, its choice on training included.";
@@ -21,4 +21,6 @@ export declare const init: import("../core/registry.ts").Command<z.ZodObject<{
21
21
  root: string;
22
22
  name: string;
23
23
  note: string;
24
+ already: boolean;
25
+ app: string | undefined;
24
26
  }>;
@@ -1,6 +1,6 @@
1
1
  import { basename, resolve } from "node:path";
2
2
  import { z } from "zod";
3
- import { createCampaign, difficulties, lethalities, rememberChoice } from "../campaign/index.js";
3
+ import { createCampaign, difficulties, findCampaign, lethalities, refreshUserHostFiles, rememberChoice, updateHostFiles } from "../campaign/index.js";
4
4
  import { appendLogEntry, newLogEntry } from "../core/log.js";
5
5
  import { defineCommand } from "../core/registry.js";
6
6
  import { hostInstructions } from "../instructions/index.js";
@@ -11,6 +11,7 @@ export const init = defineCommand({
11
11
  name: "init",
12
12
  description: "Create a new campaign. "
13
13
  + "It writes the settings, the log, the world's folders, and the .mcp.json, AGENTS.md and CLAUDE.md through which an AI host finds these tools. "
14
+ + "Given the folder of a campaign that exists, it only brings those files up to date. "
14
15
  + "Use it once, when the player starts a new campaign, with master true when you, the AI, create it: the answer then says what is still to agree with the player, to set with config. "
15
16
  + 'Example: name "The Salt Isles", language en.',
16
17
  group: "campaign",
@@ -26,23 +27,40 @@ export const init = defineCommand({
26
27
  }),
27
28
  run(input, context) {
28
29
  const folder = resolve(context.folder, input.folder ?? ".");
30
+ // A campaign that exists keeps its settings: only the files through which the hosts find it are brought up to date.
31
+ if (findCampaign(folder) === folder) {
32
+ updateHostFiles(folder, context.platform, hostInstructions());
33
+ return { root: folder, name: "", note: "", already: true, app: refreshUserFiles(context) };
34
+ }
29
35
  // Only an installed system (D-167), as it is installed.
30
36
  const system = input.system === undefined ? undefined : installedSystemName(input.system, context, "init");
31
37
  const settings = { name: input.name ?? basename(folder), language: input.language, system, difficulty: input.difficulty, lethality: input.lethality };
32
38
  const root = createCampaign(folder, settings, context.platform, hostInstructions());
33
39
  createWorld(root);
34
40
  appendLogEntry(root, newLogEntry(context, "campaign-created", "public", settings));
41
+ const app = refreshUserFiles(context);
35
42
  // What the next campaign's setup suggests (T-134).
36
43
  rememberChoice(context.home, root, "difficulty", settings.difficulty);
37
44
  rememberChoice(context.home, root, "lethality", settings.lethality);
38
- return { root, name: settings.name, note: input.master === true ? campaignNote(root, context) : "" };
45
+ return { root, name: settings.name, note: input.master === true ? campaignNote(root, context) : "", already: false, app };
39
46
  },
40
47
  // The player reads it, who made the campaign in a terminal: what to do next. What the master still agrees with them only when the master made it (T-185).
41
48
  format(result) {
49
+ // Antigravity's own settings, outside the campaign, said apart when they could not be written.
50
+ const app = result.app === undefined ? [] : [result.app];
51
+ if (result.already) {
52
+ // What could not be written is outside the folder: the line says only what is true.
53
+ return [`${result.root} is already a campaign: its files for Claude Code, Codex, Antigravity and OpenCode${app.length > 0 ? " in this folder" : ""} are up to date.`, ...app].join("\n");
54
+ }
42
55
  return [
43
56
  `Created the campaign "${result.name}" in ${result.root}.`,
44
- "To play, open Claude Code, Codex or Antigravity in this folder and say hello: the master asks you the rest.",
57
+ "To play, open Claude Code, Codex, Antigravity or OpenCode in this folder and say hello: the master asks you the rest.",
58
+ ...app,
45
59
  ...(result.note === "" ? [] : ["", `For the master: ${result.note}`]),
46
60
  ].join("\n");
47
61
  },
48
62
  });
63
+ /** The engine's files in the player's home, as Antigravity's app reads them (D-578), and what could not be written; none where the context has no home, as in the tests. */
64
+ function refreshUserFiles(context) {
65
+ return context.userHome === undefined ? undefined : refreshUserHostFiles(context.userHome, context.platform);
66
+ }
@@ -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. */