narrarium-engine 0.1.22 → 0.1.24
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.
- package/README.md +23 -6
- package/dist/autopilot/campaign.d.ts +72 -5
- package/dist/autopilot/campaign.d.ts.map +1 -1
- package/dist/autopilot/campaign.js +338 -36
- package/dist/autopilot/campaign.js.map +1 -1
- package/dist/autopilot/design.d.ts +77 -0
- package/dist/autopilot/design.d.ts.map +1 -0
- package/dist/autopilot/design.js +234 -0
- package/dist/autopilot/design.js.map +1 -0
- package/dist/autopilot/estimate-texts.d.ts +6 -0
- package/dist/autopilot/estimate-texts.d.ts.map +1 -1
- package/dist/autopilot/estimate-texts.js +20 -7
- package/dist/autopilot/estimate-texts.js.map +1 -1
- package/dist/autopilot/estimate.d.ts +36 -5
- package/dist/autopilot/estimate.d.ts.map +1 -1
- package/dist/autopilot/estimate.js +100 -35
- package/dist/autopilot/estimate.js.map +1 -1
- package/dist/autopilot/frozen.d.ts +8 -0
- package/dist/autopilot/frozen.d.ts.map +1 -1
- package/dist/autopilot/frozen.js +9 -1
- package/dist/autopilot/frozen.js.map +1 -1
- package/dist/autopilot/outline-check.d.ts +9 -0
- package/dist/autopilot/outline-check.d.ts.map +1 -1
- package/dist/autopilot/outline-check.js +16 -0
- package/dist/autopilot/outline-check.js.map +1 -1
- package/dist/autopilot/outline-compose.d.ts +3 -3
- package/dist/autopilot/outline-compose.d.ts.map +1 -1
- package/dist/autopilot/outline-compose.js +4 -4
- package/dist/autopilot/outline-compose.js.map +1 -1
- package/dist/autopilot/planner.d.ts +13 -11
- package/dist/autopilot/planner.d.ts.map +1 -1
- package/dist/autopilot/planner.js +105 -27
- package/dist/autopilot/planner.js.map +1 -1
- package/dist/autopilot/prompts.d.ts +18 -0
- package/dist/autopilot/prompts.d.ts.map +1 -1
- package/dist/autopilot/prompts.js +163 -0
- package/dist/autopilot/prompts.js.map +1 -1
- package/dist/autopilot/review-policy.d.ts +22 -0
- package/dist/autopilot/review-policy.d.ts.map +1 -0
- package/dist/autopilot/review-policy.js +56 -0
- package/dist/autopilot/review-policy.js.map +1 -0
- package/dist/autopilot/runner.d.ts.map +1 -1
- package/dist/autopilot/runner.js +39 -12
- package/dist/autopilot/runner.js.map +1 -1
- package/dist/autopilot/session.d.ts +9 -1
- package/dist/autopilot/session.d.ts.map +1 -1
- package/dist/autopilot/session.js +36 -2
- package/dist/autopilot/session.js.map +1 -1
- package/dist/autopilot/state.d.ts +19 -4
- package/dist/autopilot/state.d.ts.map +1 -1
- package/dist/autopilot/state.js +200 -8
- package/dist/autopilot/state.js.map +1 -1
- package/dist/autopilot/tasks.d.ts +3 -1
- package/dist/autopilot/tasks.d.ts.map +1 -1
- package/dist/autopilot/tasks.js +471 -78
- package/dist/autopilot/tasks.js.map +1 -1
- package/dist/autopilot/types.d.ts +252 -9
- package/dist/autopilot/types.d.ts.map +1 -1
- package/dist/autopilot/types.js +8 -1
- package/dist/autopilot/types.js.map +1 -1
- package/dist/book/design.d.ts +265 -0
- package/dist/book/design.d.ts.map +1 -0
- package/dist/book/design.js +632 -0
- package/dist/book/design.js.map +1 -0
- package/dist/book/outline.d.ts +20 -4
- package/dist/book/outline.d.ts.map +1 -1
- package/dist/book/outline.js +46 -9
- package/dist/book/outline.js.map +1 -1
- package/dist/director/opinion.d.ts +2 -0
- package/dist/director/opinion.d.ts.map +1 -1
- package/dist/director/opinion.js +4 -3
- package/dist/director/opinion.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/server/client.d.ts +10 -4
- package/dist/server/client.d.ts.map +1 -1
- package/dist/server/client.js +33 -12
- package/dist/server/client.js.map +1 -1
- package/dist/server/protocol.d.ts +35 -1
- package/dist/server/protocol.d.ts.map +1 -1
- package/dist/server/protocol.js +38 -0
- package/dist/server/protocol.js.map +1 -1
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +67 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
import { parseMarkdown, renderMarkdown } from "../markdown/frontmatter.js";
|
|
2
|
+
import { sha256Hex } from "../util/hash.js";
|
|
3
|
+
import { clipText, isItalian, truncate } from "../util/text.js";
|
|
4
|
+
import { chapterNumberFromSlug } from "./paths.js";
|
|
5
|
+
/** The fields of a design, in the order the files, the prompts and the interfaces show them. */
|
|
6
|
+
export const OUTLINE_DESIGN_FIELDS = Object.freeze([
|
|
7
|
+
{ key: "goal", kind: "text" },
|
|
8
|
+
{ key: "pov", kind: "list" },
|
|
9
|
+
{ key: "characters", kind: "list" },
|
|
10
|
+
{ key: "setting", kind: "text" },
|
|
11
|
+
{ key: "time", kind: "text" },
|
|
12
|
+
{ key: "events", kind: "list" },
|
|
13
|
+
{ key: "scenes", kind: "list" },
|
|
14
|
+
{ key: "conflicts", kind: "list" },
|
|
15
|
+
{ key: "emotions", kind: "text" },
|
|
16
|
+
{ key: "reveals", kind: "list" },
|
|
17
|
+
{ key: "withholds", kind: "list" },
|
|
18
|
+
{ key: "clues", kind: "list" },
|
|
19
|
+
{ key: "previous", kind: "text" },
|
|
20
|
+
{ key: "next", kind: "text" },
|
|
21
|
+
{ key: "ending", kind: "text" },
|
|
22
|
+
{ key: "cliffhanger", kind: "flag" },
|
|
23
|
+
{ key: "notes", kind: "text" },
|
|
24
|
+
]);
|
|
25
|
+
export const OUTLINE_DESIGN_KEYS = Object.freeze(OUTLINE_DESIGN_FIELDS.map((field) => field.key));
|
|
26
|
+
/** The fields without which a design is incomplete: a chapter with a design but none of these is said (`outlineDesignGaps`). */
|
|
27
|
+
export const OUTLINE_DESIGN_KEY_FIELDS = Object.freeze(["goal", "pov", "events", "ending"]);
|
|
28
|
+
/** Characters of one text of a design, and of one item of a list, that an edit may write: a longer one is cut, with a warning. */
|
|
29
|
+
export const OUTLINE_DESIGN_TEXT_MAX_CHARS = 4000;
|
|
30
|
+
/** Items of one list of a design that an edit may write. */
|
|
31
|
+
export const OUTLINE_DESIGN_LIST_MAX_ITEMS = 40;
|
|
32
|
+
const KIND_OF = new Map(OUTLINE_DESIGN_FIELDS.map((field) => [field.key, field.kind]));
|
|
33
|
+
function isMapping(value) {
|
|
34
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
35
|
+
}
|
|
36
|
+
function lineText(value) {
|
|
37
|
+
return value.replace(/\r\n?/g, "\n").trim();
|
|
38
|
+
}
|
|
39
|
+
function quoted(value) {
|
|
40
|
+
if (Array.isArray(value))
|
|
41
|
+
return "a list";
|
|
42
|
+
if (isMapping(value))
|
|
43
|
+
return "a mapping";
|
|
44
|
+
const text = String(value);
|
|
45
|
+
return `«${text.length > 40 ? `${text.slice(0, 40)}…` : text}»`;
|
|
46
|
+
}
|
|
47
|
+
function readFlag(value) {
|
|
48
|
+
if (typeof value === "boolean")
|
|
49
|
+
return value;
|
|
50
|
+
if (typeof value === "string") {
|
|
51
|
+
const word = value.trim().toLowerCase();
|
|
52
|
+
if (word === "true" || word === "yes")
|
|
53
|
+
return true;
|
|
54
|
+
if (word === "false" || word === "no")
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The design of an entry as the engine reads it from the value of `design:`. `problems` says, in English, every field that could not be read (it is left out of
|
|
61
|
+
* `design`, and stays in the file); a value that is not a mapping is one problem and no design. Absent `design`: the entry has none, or nothing in it is usable.
|
|
62
|
+
*/
|
|
63
|
+
export function readOutlineDesign(value) {
|
|
64
|
+
const problems = [];
|
|
65
|
+
if (value === undefined || value === null)
|
|
66
|
+
return { problems };
|
|
67
|
+
if (!isMapping(value))
|
|
68
|
+
return { problems: [`design must be a mapping of fields (${quoted(value)} is not): it is not read`] };
|
|
69
|
+
const design = {};
|
|
70
|
+
for (const { key, kind } of OUTLINE_DESIGN_FIELDS) {
|
|
71
|
+
const raw = value[key];
|
|
72
|
+
if (raw === undefined || raw === null)
|
|
73
|
+
continue;
|
|
74
|
+
if (kind === "text") {
|
|
75
|
+
if (typeof raw === "string" || typeof raw === "number" || typeof raw === "boolean") {
|
|
76
|
+
const text = lineText(String(raw));
|
|
77
|
+
if (text)
|
|
78
|
+
design[key] = text;
|
|
79
|
+
}
|
|
80
|
+
else
|
|
81
|
+
problems.push(`design.${key} must be text (${quoted(raw)} is not): it is not read`);
|
|
82
|
+
}
|
|
83
|
+
else if (kind === "flag") {
|
|
84
|
+
const flag = readFlag(raw);
|
|
85
|
+
if (flag === undefined)
|
|
86
|
+
problems.push(`design.${key} must be true or false (${quoted(raw)} is not): it is not read`);
|
|
87
|
+
else
|
|
88
|
+
design[key] = flag;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const items = typeof raw === "string" || typeof raw === "number" ? [raw] : Array.isArray(raw) ? raw : null;
|
|
92
|
+
if (!items) {
|
|
93
|
+
problems.push(`design.${key} must be a list of lines (${quoted(raw)} is not): it is not read`);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const lines = [];
|
|
97
|
+
let skipped = 0;
|
|
98
|
+
for (const item of items) {
|
|
99
|
+
if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
|
|
100
|
+
const text = lineText(String(item));
|
|
101
|
+
if (text)
|
|
102
|
+
lines.push(text);
|
|
103
|
+
}
|
|
104
|
+
else if (item !== null && item !== undefined)
|
|
105
|
+
skipped += 1;
|
|
106
|
+
}
|
|
107
|
+
if (skipped)
|
|
108
|
+
problems.push(`design.${key}: ${skipped === 1 ? "an item is" : `${skipped} items are`} not a line of text and ${skipped === 1 ? "is" : "are"} not read`);
|
|
109
|
+
if (lines.length)
|
|
110
|
+
design[key] = lines;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return Object.keys(design).length ? { design: design, problems } : { problems };
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* A design that an edit or a model gives, made what the files keep: texts trimmed, lists of non-empty lines, cut to the limits (each cut is said in
|
|
117
|
+
* `problems`, in English). Fields that are not the design's are left out. `null`/empty values say "take it away" (`cleared`).
|
|
118
|
+
*/
|
|
119
|
+
export function normalizeDesignPatch(value) {
|
|
120
|
+
const problems = [];
|
|
121
|
+
const patch = {};
|
|
122
|
+
if (!isMapping(value))
|
|
123
|
+
return { patch, problems };
|
|
124
|
+
for (const { key, kind } of OUTLINE_DESIGN_FIELDS) {
|
|
125
|
+
if (!(key in value))
|
|
126
|
+
continue;
|
|
127
|
+
const raw = value[key];
|
|
128
|
+
if (raw === undefined)
|
|
129
|
+
continue;
|
|
130
|
+
if (raw === null) {
|
|
131
|
+
patch[key] = null;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (kind === "flag") {
|
|
135
|
+
const flag = readFlag(raw);
|
|
136
|
+
patch[key] = flag === undefined ? null : flag;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (kind === "text") {
|
|
140
|
+
const text = typeof raw === "string" || typeof raw === "number" ? lineText(String(raw)) : Array.isArray(raw) ? raw.filter((item) => typeof item === "string").map(lineText).filter(Boolean).join("\n") : "";
|
|
141
|
+
if (text.length > OUTLINE_DESIGN_TEXT_MAX_CHARS)
|
|
142
|
+
problems.push(`design.${key} was ${text.length} characters long and is cut at ${OUTLINE_DESIGN_TEXT_MAX_CHARS}`);
|
|
143
|
+
patch[key] = text ? clipText(text, OUTLINE_DESIGN_TEXT_MAX_CHARS).trim() : null;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
// A text of several lines is a list of them (a bullet that opens a line is not part of it); a list is taken as it is.
|
|
147
|
+
const items = typeof raw === "string" ? raw.split("\n").map((line) => line.trim().replace(/^[-*•]\s+/, "")) : Array.isArray(raw) ? raw : [];
|
|
148
|
+
let lines = items.filter((item) => typeof item === "string" || typeof item === "number").map((item) => lineText(String(item))).filter(Boolean);
|
|
149
|
+
if (lines.length > OUTLINE_DESIGN_LIST_MAX_ITEMS) {
|
|
150
|
+
problems.push(`design.${key} had ${lines.length} items and keeps the first ${OUTLINE_DESIGN_LIST_MAX_ITEMS}`);
|
|
151
|
+
lines = lines.slice(0, OUTLINE_DESIGN_LIST_MAX_ITEMS);
|
|
152
|
+
}
|
|
153
|
+
if (lines.some((line) => line.length > OUTLINE_DESIGN_TEXT_MAX_CHARS)) {
|
|
154
|
+
problems.push(`design.${key}: an item longer than ${OUTLINE_DESIGN_TEXT_MAX_CHARS} characters is cut`);
|
|
155
|
+
lines = lines.map((line) => clipText(line, OUTLINE_DESIGN_TEXT_MAX_CHARS).trim());
|
|
156
|
+
}
|
|
157
|
+
patch[key] = lines.length ? lines : null;
|
|
158
|
+
}
|
|
159
|
+
return { patch, problems };
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The value of `design:` once `patch` is applied to the one the file has (`base`, as it was read: a key the engine does not know is kept, in its place).
|
|
163
|
+
* `null` takes the whole design away. `undefined` when nothing is left: the file then has no `design:`.
|
|
164
|
+
*/
|
|
165
|
+
export function applyDesignPatch(base, patch) {
|
|
166
|
+
if (patch === null)
|
|
167
|
+
return undefined;
|
|
168
|
+
const next = isMapping(base) ? { ...base } : {};
|
|
169
|
+
if (patch) {
|
|
170
|
+
for (const key of OUTLINE_DESIGN_KEYS) {
|
|
171
|
+
if (!(key in patch))
|
|
172
|
+
continue;
|
|
173
|
+
const value = patch[key];
|
|
174
|
+
if (value === undefined)
|
|
175
|
+
continue;
|
|
176
|
+
if (value === null || (Array.isArray(value) && !value.length) || (typeof value === "string" && !value.trim()))
|
|
177
|
+
delete next[key];
|
|
178
|
+
else
|
|
179
|
+
next[key] = value;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// The engine's fields in their order, then the others as they were.
|
|
183
|
+
const ordered = {};
|
|
184
|
+
for (const key of OUTLINE_DESIGN_KEYS)
|
|
185
|
+
if (next[key] !== undefined && next[key] !== null)
|
|
186
|
+
ordered[key] = next[key];
|
|
187
|
+
for (const [key, value] of Object.entries(next))
|
|
188
|
+
if (!KIND_OF.has(key) && value !== undefined)
|
|
189
|
+
ordered[key] = value;
|
|
190
|
+
return Object.keys(ordered).length ? ordered : undefined;
|
|
191
|
+
}
|
|
192
|
+
/** A design as the engine writes it whole: the same as patching nothing with every field of `design` (and no other key). */
|
|
193
|
+
export function designMapping(design) {
|
|
194
|
+
if (!design)
|
|
195
|
+
return undefined;
|
|
196
|
+
return applyDesignPatch(undefined, normalizeDesignPatch(design).patch);
|
|
197
|
+
}
|
|
198
|
+
/** Whether a design says nothing. */
|
|
199
|
+
export function isDesignEmpty(design) {
|
|
200
|
+
return !design || OUTLINE_DESIGN_KEYS.every((key) => {
|
|
201
|
+
const value = design[key];
|
|
202
|
+
return value === undefined || value === null || (Array.isArray(value) && !value.length) || (typeof value === "string" && !value.trim());
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/** The key fields (`OUTLINE_DESIGN_KEY_FIELDS`) a design lacks. */
|
|
206
|
+
export function missingDesignFields(design) {
|
|
207
|
+
return OUTLINE_DESIGN_KEY_FIELDS.filter((key) => {
|
|
208
|
+
const value = design?.[key];
|
|
209
|
+
return value === undefined || (Array.isArray(value) && !value.length) || (typeof value === "string" && !value.trim());
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/** A value of the frontmatter as the fingerprint of an entry sees it: texts trimmed with their line endings made one, empty values gone, keys in order. */
|
|
213
|
+
function canonicalValue(value) {
|
|
214
|
+
if (typeof value === "string") {
|
|
215
|
+
const text = lineText(value);
|
|
216
|
+
return text ? text : undefined;
|
|
217
|
+
}
|
|
218
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
219
|
+
return value;
|
|
220
|
+
if (Array.isArray(value)) {
|
|
221
|
+
const items = value.map(canonicalValue).filter((item) => item !== undefined);
|
|
222
|
+
return items.length ? items : undefined;
|
|
223
|
+
}
|
|
224
|
+
if (isMapping(value)) {
|
|
225
|
+
const entries = Object.keys(value).sort().map((key) => [key, canonicalValue(value[key])]).filter(([, item]) => item !== undefined);
|
|
226
|
+
return entries.length ? Object.fromEntries(entries) : undefined;
|
|
227
|
+
}
|
|
228
|
+
return undefined;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* What the design of an entry adds to its fingerprint (`outlineEntryDigest`): the whole value of `design:` (the keys the engine does not know too), in a form
|
|
232
|
+
* that does not depend on how the YAML is written. `""` for an entry with no design, or an empty one: its fingerprint is the one it always had.
|
|
233
|
+
*/
|
|
234
|
+
export function designFingerprint(value) {
|
|
235
|
+
const canonical = canonicalValue(value);
|
|
236
|
+
return canonical === undefined ? "" : JSON.stringify(canonical);
|
|
237
|
+
}
|
|
238
|
+
/** The labels of the fields, as the prompts and the plain-text views say them. */
|
|
239
|
+
export const OUTLINE_DESIGN_LABELS = Object.freeze({
|
|
240
|
+
goal: "Narrative goal",
|
|
241
|
+
pov: "Point of view",
|
|
242
|
+
characters: "Characters",
|
|
243
|
+
setting: "Setting",
|
|
244
|
+
time: "Time",
|
|
245
|
+
events: "Main events",
|
|
246
|
+
scenes: "Planned scenes",
|
|
247
|
+
conflicts: "Conflicts",
|
|
248
|
+
emotions: "Emotional evolution",
|
|
249
|
+
reveals: "Revealed to the reader",
|
|
250
|
+
withholds: "Kept from the reader",
|
|
251
|
+
clues: "Clues and foreshadowing",
|
|
252
|
+
previous: "Picks up from earlier chapters",
|
|
253
|
+
next: "Sets up for later chapters",
|
|
254
|
+
ending: "Ending",
|
|
255
|
+
cliffhanger: "Cliffhanger",
|
|
256
|
+
notes: "Notes for the ghostwriter",
|
|
257
|
+
});
|
|
258
|
+
/** A design as lines of text, for a prompt or a plain view: a line a field, the lists joined; `maxChars` keeps it within a share of a prompt. */
|
|
259
|
+
export function designText(design, maxChars = 2400) {
|
|
260
|
+
if (!design)
|
|
261
|
+
return "";
|
|
262
|
+
const lines = [];
|
|
263
|
+
for (const { key, kind } of OUTLINE_DESIGN_FIELDS) {
|
|
264
|
+
const value = design[key];
|
|
265
|
+
if (value === undefined)
|
|
266
|
+
continue;
|
|
267
|
+
if (kind === "flag") {
|
|
268
|
+
if (value === true)
|
|
269
|
+
lines.push(`${OUTLINE_DESIGN_LABELS[key]}: yes`);
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
const text = Array.isArray(value) ? value.join("; ") : String(value);
|
|
273
|
+
if (text)
|
|
274
|
+
lines.push(`${OUTLINE_DESIGN_LABELS[key]}: ${text.replace(/\s+/g, " ")}`);
|
|
275
|
+
}
|
|
276
|
+
return truncate(lines.join("\n"), maxChars);
|
|
277
|
+
}
|
|
278
|
+
/** The keys of the frontmatter the ledger is made of. */
|
|
279
|
+
export const SECRET_LEDGER_KEYS = Object.freeze(["learned_by", "reader_knows", "clues", "red_herrings", "consequences"]);
|
|
280
|
+
/** Items of a list of the ledger, and characters of one note, that the engine writes. */
|
|
281
|
+
export const SECRET_LEDGER_MAX_ITEMS = 60;
|
|
282
|
+
export const SECRET_LEDGER_NOTE_MAX_CHARS = 1000;
|
|
283
|
+
export function emptySecretLedger() {
|
|
284
|
+
return { learnedBy: [], readerKnows: [], clues: [], redHerrings: [], consequences: [] };
|
|
285
|
+
}
|
|
286
|
+
/** A chapter as the ledger says it: a whole number from 0 (0: before the book begins), or a chapter reference (`chapter:007-the-wreck`). */
|
|
287
|
+
export function ledgerChapter(value) {
|
|
288
|
+
if (typeof value === "number")
|
|
289
|
+
return Number.isSafeInteger(value) && value >= 0 ? value : undefined;
|
|
290
|
+
if (typeof value === "string") {
|
|
291
|
+
const text = value.trim();
|
|
292
|
+
if (/^\d+$/.test(text))
|
|
293
|
+
return Number(text);
|
|
294
|
+
const slug = text.replace(/^chapter:/, "").trim();
|
|
295
|
+
return chapterNumberFromSlug(slug) ?? (/^\d+$/.test(slug) ? Number(slug) : undefined);
|
|
296
|
+
}
|
|
297
|
+
return undefined;
|
|
298
|
+
}
|
|
299
|
+
function noteText(value) {
|
|
300
|
+
return typeof value === "string" || typeof value === "number" ? String(value).replace(/\r\n?/g, "\n").trim() : "";
|
|
301
|
+
}
|
|
302
|
+
function readNotes(value, key, problems) {
|
|
303
|
+
if (value === undefined || value === null)
|
|
304
|
+
return [];
|
|
305
|
+
if (!Array.isArray(value)) {
|
|
306
|
+
problems.push(`${key} must be a list of { chapter, note } (it is not): it is not read`);
|
|
307
|
+
return [];
|
|
308
|
+
}
|
|
309
|
+
const notes = [];
|
|
310
|
+
let skipped = 0;
|
|
311
|
+
for (const item of value) {
|
|
312
|
+
const record = isMapping(item) ? item : null;
|
|
313
|
+
const chapter = record ? ledgerChapter(record.chapter) : undefined;
|
|
314
|
+
const note = record ? noteText(record.note) : "";
|
|
315
|
+
if (chapter === undefined || !note)
|
|
316
|
+
skipped += 1;
|
|
317
|
+
else
|
|
318
|
+
notes.push({ chapter, note });
|
|
319
|
+
}
|
|
320
|
+
if (skipped)
|
|
321
|
+
problems.push(`${key}: ${skipped === 1 ? "an item has" : `${skipped} items have`} no chapter or no note and ${skipped === 1 ? "is" : "are"} not read`);
|
|
322
|
+
return notes.sort((left, right) => left.chapter - right.chapter);
|
|
323
|
+
}
|
|
324
|
+
/** The ledger of a secret from its frontmatter, and what could not be read of it (in English). */
|
|
325
|
+
export function readSecretLedger(frontmatter) {
|
|
326
|
+
const problems = [];
|
|
327
|
+
const learnedBy = [];
|
|
328
|
+
const raw = frontmatter.learned_by;
|
|
329
|
+
if (raw !== undefined && raw !== null) {
|
|
330
|
+
if (!Array.isArray(raw))
|
|
331
|
+
problems.push("learned_by must be a list of { character, chapter } (it is not): it is not read");
|
|
332
|
+
else {
|
|
333
|
+
let skipped = 0;
|
|
334
|
+
for (const item of raw) {
|
|
335
|
+
const record = isMapping(item) ? item : null;
|
|
336
|
+
const character = record ? noteText(record.character) : "";
|
|
337
|
+
const chapter = record ? ledgerChapter(record.chapter) : undefined;
|
|
338
|
+
if (!character || chapter === undefined)
|
|
339
|
+
skipped += 1;
|
|
340
|
+
else
|
|
341
|
+
learnedBy.push({ character, chapter });
|
|
342
|
+
}
|
|
343
|
+
if (skipped)
|
|
344
|
+
problems.push(`learned_by: ${skipped === 1 ? "an item has" : `${skipped} items have`} no character or no chapter and ${skipped === 1 ? "is" : "are"} not read`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
const consequences = [];
|
|
348
|
+
const rawConsequences = frontmatter.consequences;
|
|
349
|
+
if (typeof rawConsequences === "string") {
|
|
350
|
+
if (rawConsequences.trim())
|
|
351
|
+
consequences.push(rawConsequences.trim());
|
|
352
|
+
}
|
|
353
|
+
else if (Array.isArray(rawConsequences)) {
|
|
354
|
+
for (const item of rawConsequences)
|
|
355
|
+
if (noteText(item))
|
|
356
|
+
consequences.push(noteText(item));
|
|
357
|
+
}
|
|
358
|
+
else if (rawConsequences !== undefined && rawConsequences !== null) {
|
|
359
|
+
problems.push("consequences must be a list of lines (it is not): it is not read");
|
|
360
|
+
}
|
|
361
|
+
return {
|
|
362
|
+
ledger: {
|
|
363
|
+
learnedBy: learnedBy.sort((left, right) => left.chapter - right.chapter),
|
|
364
|
+
readerKnows: readNotes(frontmatter.reader_knows, "reader_knows", problems),
|
|
365
|
+
clues: readNotes(frontmatter.clues, "clues", problems),
|
|
366
|
+
redHerrings: readNotes(frontmatter.red_herrings, "red_herrings", problems),
|
|
367
|
+
consequences,
|
|
368
|
+
},
|
|
369
|
+
problems,
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
/** Whether a ledger says nothing. */
|
|
373
|
+
export function isLedgerEmpty(ledger) {
|
|
374
|
+
return !ledger.learnedBy.length && !ledger.readerKnows.length && !ledger.clues.length && !ledger.redHerrings.length && !ledger.consequences.length;
|
|
375
|
+
}
|
|
376
|
+
const clipNote = (text) => clipText(text.trim(), SECRET_LEDGER_NOTE_MAX_CHARS).trim();
|
|
377
|
+
/** The keys of the frontmatter a ledger is written as: a list that is empty is no key (`undefined`, so that rendering leaves it out). */
|
|
378
|
+
export function secretLedgerFrontmatter(ledger) {
|
|
379
|
+
const notes = (items) => {
|
|
380
|
+
const list = [...items].filter((item) => item.note.trim()).sort((left, right) => left.chapter - right.chapter).slice(0, SECRET_LEDGER_MAX_ITEMS).map((item) => ({ chapter: item.chapter, note: clipNote(item.note) }));
|
|
381
|
+
return list.length ? list : undefined;
|
|
382
|
+
};
|
|
383
|
+
const learned = [...ledger.learnedBy].filter((item) => item.character.trim()).sort((left, right) => left.chapter - right.chapter).slice(0, SECRET_LEDGER_MAX_ITEMS).map((item) => ({ character: item.character.trim(), chapter: item.chapter }));
|
|
384
|
+
const consequences = ledger.consequences.map(clipNote).filter(Boolean).slice(0, SECRET_LEDGER_MAX_ITEMS);
|
|
385
|
+
return {
|
|
386
|
+
learned_by: learned.length ? learned : undefined,
|
|
387
|
+
reader_knows: notes(ledger.readerKnows),
|
|
388
|
+
clues: notes(ledger.clues),
|
|
389
|
+
red_herrings: notes(ledger.redHerrings),
|
|
390
|
+
consequences: consequences.length ? consequences : undefined,
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* The ledger the design of chapters `from` to `to` gives a secret, merged into the one it had: what falls in those chapters is the batch's, what falls elsewhere stays
|
|
395
|
+
* (a book designed in batches gets its ledger batch by batch). The consequences are the batch's when it gives them.
|
|
396
|
+
*/
|
|
397
|
+
export function mergeSecretLedger(base, batch, from, to) {
|
|
398
|
+
const inRange = (chapter) => chapter >= from && chapter <= to;
|
|
399
|
+
const byChapter = (left, right) => left.chapter - right.chapter;
|
|
400
|
+
const merge = (kept, added) => [...kept.filter((item) => !inRange(item.chapter)), ...(added ?? []).filter((item) => inRange(item.chapter))].sort(byChapter);
|
|
401
|
+
return {
|
|
402
|
+
learnedBy: merge(base.learnedBy, batch.learnedBy),
|
|
403
|
+
readerKnows: merge(base.readerKnows, batch.readerKnows),
|
|
404
|
+
clues: merge(base.clues, batch.clues),
|
|
405
|
+
redHerrings: merge(base.redHerrings, batch.redHerrings),
|
|
406
|
+
consequences: batch.consequences?.length ? [...batch.consequences] : [...base.consequences],
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* The fingerprint of the ledger a file holds now (the keys of the ledger as they are written, whatever is in them): the design run keeps the one of every ledger
|
|
411
|
+
* it wrote, and rewrites a ledger only while the file still has that one (a change of the author makes the ledger the author's).
|
|
412
|
+
*/
|
|
413
|
+
export async function secretLedgerDigest(frontmatter) {
|
|
414
|
+
const keys = SECRET_LEDGER_KEYS.map((key) => [key, frontmatter[key] ?? null]);
|
|
415
|
+
return (await sha256Hex(JSON.stringify(["secret-ledger", keys]))).slice(0, 16);
|
|
416
|
+
}
|
|
417
|
+
// ─── The files of `bible/` ──────────────────────────────────────────────────
|
|
418
|
+
/**
|
|
419
|
+
* The `bible/` folder: the parts of the Story Bible that have no other home in a book. Everything else the Bible shows is in the book's own files (the description
|
|
420
|
+
* and the Synopsis in `outline/`, the story design, the world context, the characters, places, factions, items and secrets): the Bible composes them, and never
|
|
421
|
+
* copies them here.
|
|
422
|
+
*
|
|
423
|
+
* - `bible/themes.md` (`type: bible`, `id: bible:themes`): the themes of the book (`themes`, a list) and its tone (`tone`).
|
|
424
|
+
* - `bible/world.md` (`type: bible`, `id: bible:world`): the rules of the world the story must never break (`rules`, a list).
|
|
425
|
+
*
|
|
426
|
+
* The body of each file is free notes. A design run writes them when they are missing, and never rewrites them: they are the author's from then on.
|
|
427
|
+
*/
|
|
428
|
+
export const BIBLE_DIRECTORY = "bible";
|
|
429
|
+
export const BIBLE_THEMES_FILE = "bible/themes.md";
|
|
430
|
+
export const BIBLE_WORLD_FILE = "bible/world.md";
|
|
431
|
+
function lines(value) {
|
|
432
|
+
if (typeof value === "string")
|
|
433
|
+
return value.split("\n").map((line) => line.replace(/^[-*•]\s+/, "").trim()).filter(Boolean);
|
|
434
|
+
if (!Array.isArray(value))
|
|
435
|
+
return [];
|
|
436
|
+
return value.filter((item) => typeof item === "string" || typeof item === "number").map((item) => String(item).trim()).filter(Boolean);
|
|
437
|
+
}
|
|
438
|
+
function text(value) {
|
|
439
|
+
return typeof value === "string" || typeof value === "number" ? String(value).trim() : "";
|
|
440
|
+
}
|
|
441
|
+
/** The themes and the tone of the book from `bible/themes.md` (empty when the file has none). */
|
|
442
|
+
export function readBibleThemes(content) {
|
|
443
|
+
const document = parseMarkdown(content ?? "");
|
|
444
|
+
return { themes: lines(document.frontmatter.themes), tone: text(document.frontmatter.tone), notes: document.body };
|
|
445
|
+
}
|
|
446
|
+
/** The rules of the world from `bible/world.md` (empty when the file has none). */
|
|
447
|
+
export function readBibleWorld(content) {
|
|
448
|
+
const document = parseMarkdown(content ?? "");
|
|
449
|
+
return { rules: lines(document.frontmatter.rules), notes: document.body };
|
|
450
|
+
}
|
|
451
|
+
/** `bible/themes.md` with these themes and this tone; the keys of `existing` that the format does not manage are kept. */
|
|
452
|
+
export function serializeBibleThemes(value, existing) {
|
|
453
|
+
const document = parseMarkdown(existing ?? "");
|
|
454
|
+
const themes = lines(value.themes ?? []);
|
|
455
|
+
const tone = (value.tone ?? "").trim();
|
|
456
|
+
return renderMarkdown({
|
|
457
|
+
...document.frontmatter,
|
|
458
|
+
type: "bible",
|
|
459
|
+
id: "bible:themes",
|
|
460
|
+
title: typeof document.frontmatter.title === "string" && document.frontmatter.title.trim() ? document.frontmatter.title : "Themes and tone",
|
|
461
|
+
themes: themes.length ? themes : undefined,
|
|
462
|
+
tone: tone || undefined,
|
|
463
|
+
}, (value.notes ?? document.body ?? "").trim());
|
|
464
|
+
}
|
|
465
|
+
/** `bible/world.md` with these rules; the keys of `existing` that the format does not manage are kept. */
|
|
466
|
+
export function serializeBibleWorld(value, existing) {
|
|
467
|
+
const document = parseMarkdown(existing ?? "");
|
|
468
|
+
const rules = lines(value.rules ?? []);
|
|
469
|
+
return renderMarkdown({
|
|
470
|
+
...document.frontmatter,
|
|
471
|
+
type: "bible",
|
|
472
|
+
id: "bible:world",
|
|
473
|
+
title: typeof document.frontmatter.title === "string" && document.frontmatter.title.trim() ? document.frontmatter.title : "World rules",
|
|
474
|
+
rules: rules.length ? rules : undefined,
|
|
475
|
+
}, (value.notes ?? document.body ?? "").trim());
|
|
476
|
+
}
|
|
477
|
+
/** Findings told at most, so that a book of five thousand chapters does not drown the author: the rest is counted. */
|
|
478
|
+
export const DESIGN_FINDINGS_MAX = 200;
|
|
479
|
+
function normalizeName(value) {
|
|
480
|
+
return value.normalize("NFKD").replace(/[\u0300-\u036f]/g, "").replace(/[«»"'“”‘’()[\]]/g, " ").replace(/\s+/g, " ").trim().toLowerCase();
|
|
481
|
+
}
|
|
482
|
+
/** The canon entry a name or an id points to: the id, the name, an alias, or (for a character) a lone first name or the first name of a fuller one. */
|
|
483
|
+
function matchCanon(value, canon, kind) {
|
|
484
|
+
const text = value.trim();
|
|
485
|
+
const ref = new RegExp(`^${kind}:(.+)$`).exec(text);
|
|
486
|
+
if (ref)
|
|
487
|
+
return canon.find((entry) => entry.slug === ref[1].trim());
|
|
488
|
+
const candidate = normalizeName(text);
|
|
489
|
+
if (!candidate)
|
|
490
|
+
return undefined;
|
|
491
|
+
const names = (entry) => [entry.name, ...(entry.aliases ?? [])].map(normalizeName).filter(Boolean);
|
|
492
|
+
const exact = canon.find((entry) => names(entry).includes(candidate) || entry.slug === candidate);
|
|
493
|
+
if (exact || kind !== "character")
|
|
494
|
+
return exact;
|
|
495
|
+
const first = (name) => name.split(" ")[0];
|
|
496
|
+
return canon.find((entry) => names(entry).some((name) => (!candidate.includes(" ") && first(name) === candidate) || (!name.includes(" ") && first(candidate) === name)));
|
|
497
|
+
}
|
|
498
|
+
/** A place an entry's setting names: an id, a name or an alias of the canon, also inside a longer description («the lamp room of the Lighthouse»). */
|
|
499
|
+
function settingKnown(setting, locations) {
|
|
500
|
+
if (matchCanon(setting, locations, "location"))
|
|
501
|
+
return true;
|
|
502
|
+
const text = ` ${normalizeName(setting)} `;
|
|
503
|
+
return locations.some((entry) => [entry.name, ...(entry.aliases ?? [])].map(normalizeName).some((name) => name.length >= 3 && text.includes(` ${name} `)));
|
|
504
|
+
}
|
|
505
|
+
/** Whether a line of a design names the secret: its id, or its title. */
|
|
506
|
+
function mentionsSecret(line, secret) {
|
|
507
|
+
const text = normalizeName(line);
|
|
508
|
+
return text.includes(`secret:${secret.slug}`) || (normalizeName(secret.title).length >= 3 && text.includes(normalizeName(secret.title)));
|
|
509
|
+
}
|
|
510
|
+
/** Names that stand for no one in particular, which a design may put among the characters. */
|
|
511
|
+
const GENERIC = new Set(["everyone", "all", "nobody", "the crowd", "crowd", "tutti", "nessuno", "la folla", "folla", "narrator", "narratore"]);
|
|
512
|
+
/** The deterministic checks of a design (`DesignFindingCode`), in a stable order: the secrets, then the chapters. */
|
|
513
|
+
export function designChecks(input) {
|
|
514
|
+
const findings = [];
|
|
515
|
+
const last = input.lastChapter ?? input.chapters.reduce((highest, chapter) => Math.max(highest, chapter.number), 0);
|
|
516
|
+
const chapters = [...input.chapters].sort((left, right) => left.number - right.number);
|
|
517
|
+
for (const secret of input.secrets) {
|
|
518
|
+
const subject = { slug: secret.slug, title: secret.title };
|
|
519
|
+
const reveal = secret.revealChapter;
|
|
520
|
+
const known = secret.knownFromChapter;
|
|
521
|
+
if (!reveal)
|
|
522
|
+
findings.push({ code: "reveal-missing", severity: "warning", secret: subject });
|
|
523
|
+
else if (last && reveal > last)
|
|
524
|
+
findings.push({ code: "reveal-out-of-range", severity: "warning", secret: subject, chapter: reveal, other: last });
|
|
525
|
+
if (reveal && known && reveal < known)
|
|
526
|
+
findings.push({ code: "reveal-before-known", severity: "warning", secret: subject, chapter: reveal, other: known });
|
|
527
|
+
// From this chapter on the reader knows the truth: what is planted there or later is no clue.
|
|
528
|
+
const threshold = [reveal, known].filter((value) => typeof value === "number" && value > 0).reduce((lowest, value) => Math.min(lowest, value), Number.POSITIVE_INFINITY);
|
|
529
|
+
for (const clue of secret.ledger.clues) {
|
|
530
|
+
if (Number.isFinite(threshold) && clue.chapter >= threshold)
|
|
531
|
+
findings.push({ code: "clue-after-reveal", severity: "warning", secret: subject, chapter: clue.chapter, other: threshold });
|
|
532
|
+
}
|
|
533
|
+
if (reveal && reveal > 1 && !secret.ledger.clues.some((clue) => clue.chapter < reveal))
|
|
534
|
+
findings.push({ code: "secret-without-clue", severity: "info", secret: subject, chapter: reveal });
|
|
535
|
+
if (last) {
|
|
536
|
+
const beyond = [...secret.ledger.clues, ...secret.ledger.redHerrings, ...secret.ledger.readerKnows].map((item) => item.chapter)
|
|
537
|
+
.concat(secret.ledger.learnedBy.map((item) => item.chapter))
|
|
538
|
+
.filter((chapter) => chapter > last);
|
|
539
|
+
for (const chapter of [...new Set(beyond)].sort((left, right) => left - right))
|
|
540
|
+
findings.push({ code: "chapter-out-of-range", severity: "warning", secret: subject, chapter, other: last });
|
|
541
|
+
}
|
|
542
|
+
// A point of view that reveals what that character learns only later.
|
|
543
|
+
for (const learner of secret.ledger.learnedBy) {
|
|
544
|
+
const learnerEntry = matchCanon(learner.character, input.characters, "character");
|
|
545
|
+
const sameCharacter = (name) => {
|
|
546
|
+
if (normalizeName(name) === normalizeName(learner.character))
|
|
547
|
+
return true;
|
|
548
|
+
const entry = matchCanon(name, input.characters, "character");
|
|
549
|
+
return Boolean(entry && learnerEntry && entry.slug === learnerEntry.slug);
|
|
550
|
+
};
|
|
551
|
+
if (secret.holders.some(sameCharacter))
|
|
552
|
+
continue;
|
|
553
|
+
for (const chapter of chapters) {
|
|
554
|
+
if (chapter.number >= learner.chapter)
|
|
555
|
+
break;
|
|
556
|
+
const design = chapter.design;
|
|
557
|
+
if (!design?.reveals?.some((line) => mentionsSecret(line, secret)))
|
|
558
|
+
continue;
|
|
559
|
+
if (design.pov?.some(sameCharacter))
|
|
560
|
+
findings.push({ code: "knowledge-before-learning", severity: "warning", secret: subject, chapter: chapter.number, name: learnerEntry?.name ?? learner.character, other: learner.chapter });
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
for (const chapter of chapters) {
|
|
565
|
+
const design = chapter.design;
|
|
566
|
+
if (!design)
|
|
567
|
+
continue;
|
|
568
|
+
if (input.characters.length) {
|
|
569
|
+
const named = [...new Set([...(design.pov ?? []), ...(design.characters ?? [])].map((name) => name.trim()).filter(Boolean))];
|
|
570
|
+
for (const name of named) {
|
|
571
|
+
if (GENERIC.has(normalizeName(name)) || matchCanon(name, input.characters, "character"))
|
|
572
|
+
continue;
|
|
573
|
+
findings.push({ code: "unknown-character", severity: "info", chapter: chapter.number, name });
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
if (input.locations.length && design.setting && !settingKnown(design.setting, input.locations)) {
|
|
577
|
+
findings.push({ code: "unknown-location", severity: "info", chapter: chapter.number, name: design.setting });
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
return findings;
|
|
581
|
+
}
|
|
582
|
+
const FIELD_WORDS = {
|
|
583
|
+
goal: ["narrative goal", "obiettivo narrativo"],
|
|
584
|
+
pov: ["point of view", "punto di vista"],
|
|
585
|
+
characters: ["characters", "personaggi"],
|
|
586
|
+
setting: ["setting", "ambientazione"],
|
|
587
|
+
time: ["time", "tempo"],
|
|
588
|
+
events: ["main events", "eventi principali"],
|
|
589
|
+
scenes: ["planned scenes", "scene previste"],
|
|
590
|
+
conflicts: ["conflicts", "conflitti"],
|
|
591
|
+
emotions: ["emotional evolution", "evoluzione emotiva"],
|
|
592
|
+
reveals: ["what the reader learns", "cosa scopre il lettore"],
|
|
593
|
+
withholds: ["what stays hidden", "cosa resta nascosto"],
|
|
594
|
+
clues: ["clues", "indizi"],
|
|
595
|
+
previous: ["link to the chapters before", "legame con i capitoli precedenti"],
|
|
596
|
+
next: ["link to the chapters after", "legame con i capitoli successivi"],
|
|
597
|
+
ending: ["ending", "chiusura"],
|
|
598
|
+
cliffhanger: ["cliffhanger", "cliffhanger"],
|
|
599
|
+
notes: ["notes for the ghostwriter", "note per il ghostwriter"],
|
|
600
|
+
};
|
|
601
|
+
/** A finding in words, in English or in Italian (the language of the book, or of the interface). */
|
|
602
|
+
export function designFindingText(finding, language) {
|
|
603
|
+
const it = isItalian(language);
|
|
604
|
+
const secret = finding.secret ? `«${finding.secret.title}»` : "";
|
|
605
|
+
const chapter = finding.chapter ?? 0;
|
|
606
|
+
const other = finding.other ?? 0;
|
|
607
|
+
switch (finding.code) {
|
|
608
|
+
case "reveal-missing":
|
|
609
|
+
return it ? `Il segreto ${secret} non ha un capitolo che lo riveli: un mistero senza soluzione.` : `The secret ${secret} has no chapter that reveals it: a mystery without a resolution.`;
|
|
610
|
+
case "reveal-out-of-range":
|
|
611
|
+
return it ? `Il segreto ${secret} si rivela nel capitolo ${chapter}, dopo l'ultimo capitolo del libro (${other}).` : `The secret ${secret} is revealed in chapter ${chapter}, after the last chapter of the book (${other}).`;
|
|
612
|
+
case "reveal-before-known":
|
|
613
|
+
return it ? `Il segreto ${secret} si rivela nel capitolo ${chapter}, prima del capitolo da cui il lettore può conoscerlo (${other}).` : `The secret ${secret} is revealed in chapter ${chapter}, before the chapter from which the reader may know it (${other}).`;
|
|
614
|
+
case "clue-after-reveal":
|
|
615
|
+
return it ? `Un indizio del segreto ${secret} è nel capitolo ${chapter}, quando il lettore conosce già la verità (dal capitolo ${other}): non rivela più nulla.` : `A clue of the secret ${secret} is in chapter ${chapter}, when the reader already knows the truth (from chapter ${other}): it reveals nothing any more.`;
|
|
616
|
+
case "secret-without-clue":
|
|
617
|
+
return it ? `Il segreto ${secret} si rivela nel capitolo ${chapter} senza alcun indizio prima: la rivelazione arriva senza preparazione.` : `The secret ${secret} is revealed in chapter ${chapter} with no clue before it: the reveal comes without a setup.`;
|
|
618
|
+
case "chapter-out-of-range":
|
|
619
|
+
return it ? `Il registro del segreto ${secret} parla del capitolo ${chapter}, dopo l'ultimo capitolo del libro (${other}).` : `The ledger of the secret ${secret} names chapter ${chapter}, after the last chapter of the book (${other}).`;
|
|
620
|
+
case "knowledge-before-learning":
|
|
621
|
+
return it ? `Nel capitolo ${chapter} il punto di vista di ${finding.name} rivela il segreto ${secret}, che ${finding.name} scopre solo nel capitolo ${other}.` : `In chapter ${chapter} the point of view of ${finding.name} reveals the secret ${secret}, which ${finding.name} only learns in chapter ${other}.`;
|
|
622
|
+
case "unknown-character":
|
|
623
|
+
return it ? `Il capitolo ${chapter} nomina «${finding.name}», che non è tra i personaggi del canone.` : `Chapter ${chapter} names «${finding.name}», who is not among the characters of the canon.`;
|
|
624
|
+
case "unknown-location":
|
|
625
|
+
return it ? `L'ambientazione del capitolo ${chapter} («${finding.name}») non nomina un luogo del canone.` : `The setting of chapter ${chapter} («${finding.name}») names no place of the canon.`;
|
|
626
|
+
case "design-incomplete": {
|
|
627
|
+
const fields = (finding.fields ?? []).map((field) => FIELD_WORDS[field][it ? 1 : 0]).join(", ");
|
|
628
|
+
return it ? `Il progetto del capitolo ${chapter} non dice: ${fields}.` : `The design of chapter ${chapter} does not say: ${fields}.`;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
//# sourceMappingURL=design.js.map
|