narrarium-engine 0.1.8 → 0.1.9
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 +176 -14
- package/dist/ai/catalog-fetch.d.ts.map +1 -1
- package/dist/ai/catalog-fetch.js +2 -1
- package/dist/ai/catalog-fetch.js.map +1 -1
- package/dist/autopilot/frozen.d.ts +169 -0
- package/dist/autopilot/frozen.d.ts.map +1 -0
- package/dist/autopilot/frozen.js +495 -0
- package/dist/autopilot/frozen.js.map +1 -0
- package/dist/autopilot/outline-check.d.ts +39 -0
- package/dist/autopilot/outline-check.d.ts.map +1 -0
- package/dist/autopilot/outline-check.js +81 -0
- package/dist/autopilot/outline-check.js.map +1 -0
- package/dist/autopilot/planner.d.ts +29 -1
- package/dist/autopilot/planner.d.ts.map +1 -1
- package/dist/autopilot/planner.js +78 -8
- package/dist/autopilot/planner.js.map +1 -1
- package/dist/autopilot/profile-check.d.ts +7 -4
- package/dist/autopilot/profile-check.d.ts.map +1 -1
- package/dist/autopilot/profile-check.js +9 -6
- package/dist/autopilot/profile-check.js.map +1 -1
- package/dist/autopilot/runner.d.ts +17 -3
- package/dist/autopilot/runner.d.ts.map +1 -1
- package/dist/autopilot/runner.js +106 -16
- package/dist/autopilot/runner.js.map +1 -1
- package/dist/autopilot/session.d.ts +34 -1
- package/dist/autopilot/session.d.ts.map +1 -1
- package/dist/autopilot/session.js +201 -1
- package/dist/autopilot/session.js.map +1 -1
- package/dist/autopilot/state.d.ts +8 -0
- package/dist/autopilot/state.d.ts.map +1 -1
- package/dist/autopilot/state.js +168 -3
- package/dist/autopilot/state.js.map +1 -1
- package/dist/autopilot/tasks.d.ts +14 -2
- package/dist/autopilot/tasks.d.ts.map +1 -1
- package/dist/autopilot/tasks.js +478 -34
- package/dist/autopilot/tasks.js.map +1 -1
- package/dist/autopilot/types.d.ts +166 -7
- 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/context.d.ts +3 -0
- package/dist/book/context.d.ts.map +1 -1
- package/dist/book/context.js +7 -1
- package/dist/book/context.js.map +1 -1
- package/dist/book/freeze.d.ts +115 -0
- package/dist/book/freeze.d.ts.map +1 -0
- package/dist/book/freeze.js +286 -0
- package/dist/book/freeze.js.map +1 -0
- package/dist/book/outline.d.ts +245 -0
- package/dist/book/outline.d.ts.map +1 -0
- package/dist/book/outline.js +488 -0
- package/dist/book/outline.js.map +1 -0
- package/dist/book/paths.d.ts +18 -0
- package/dist/book/paths.d.ts.map +1 -1
- package/dist/book/paths.js +25 -0
- package/dist/book/paths.js.map +1 -1
- package/dist/book/snapshot.d.ts +25 -1
- package/dist/book/snapshot.d.ts.map +1 -1
- package/dist/book/snapshot.js +24 -4
- package/dist/book/snapshot.js.map +1 -1
- package/dist/director/opinion.d.ts +6 -0
- package/dist/director/opinion.d.ts.map +1 -1
- package/dist/director/opinion.js +4 -1
- package/dist/director/opinion.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/profiles/evaluation-style.d.ts +44 -0
- package/dist/profiles/evaluation-style.d.ts.map +1 -0
- package/dist/profiles/evaluation-style.js +152 -0
- package/dist/profiles/evaluation-style.js.map +1 -0
- package/dist/server/client.d.ts +46 -2
- package/dist/server/client.d.ts.map +1 -1
- package/dist/server/client.js +57 -0
- package/dist/server/client.js.map +1 -1
- package/dist/server/protocol.d.ts +114 -1
- package/dist/server/protocol.d.ts.map +1 -1
- package/dist/server/protocol.js +36 -0
- package/dist/server/protocol.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,15 +15,18 @@ npm install narrarium-engine
|
|
|
15
15
|
| Area | Main exports |
|
|
16
16
|
|---|---|
|
|
17
17
|
| Book access | `BookStore` (list/read/commit with compare-and-swap, `readMany`), `BookConflictError`, `loadBookSnapshot` |
|
|
18
|
+
| Frozen chapters | `frozenChanges`, `freezeChapterChanges`, `markReviewedChanges`, `unfreezeChapterChanges`, `keepChapterFreeze`, `parseChapterFreeze`, `chapterFreezeRecord`, `FrozenChapterError`, `FROZEN_EDITS_MODES`, `FROZEN_ACTIONS`, `settleFrozenChanges`, `frozenQuestion`, `frozenAnswerAction`: see *Frozen chapters* |
|
|
18
19
|
| Autopilot | `AutopilotSession`, `AutopilotRun`, `advanceState`, `nextStep`, `applyIntervention`, `summarizeAutopilotState`, `effectivePublish`, `hostDefaultPublish`, `normalizeRunLimits`, `runnerActivity`, `runnerHeartbeatAgeMs`, `AutopilotRuleError`, `classifyAutopilotError`, `AUTOPILOT_ERROR_KINDS`, `AUTOPILOT_RULE_ERROR_CODES` |
|
|
19
20
|
| Director | `askDirector`, `listDirectorOpinions`, `parseDirector`, `serializeDirector`, `directorPrompt` |
|
|
20
21
|
| Readers | `readerPersonaSystemPrompt`, `mergeReaderPersonas`, `READER_EVALUATION_TOOL`, `chapterReaderText` |
|
|
21
22
|
| Ghostwriters | `parseGhostwriter`, `ghostwriterPrompt` |
|
|
23
|
+
| Outline (Scaletta) | `parseOutline`, `serializeOutlineChapter`, `serializeOutlineBook`, `outlineChanges`, `outlineEntryDigest`, `outlineBookDigest`, `outlineIndex`, `OutlineReader`, `OutlineCache`, `outlineChapterPath`, `parseOutlineChapterPath`, `outlinePlanStatus`, `effectiveTargetChapters`: see *Outline (Scaletta)* |
|
|
24
|
+
| Evaluation style | `parseEvaluationStyle`, `loadEvaluationStyle`, `evaluationStyleBlock`, `EVALUATION_STYLE_MAX_CHARS`: see *Evaluation style* |
|
|
22
25
|
| Markdown | `parseMarkdown` (with `error`), `splitFrontmatter`, `stripFrontmatter`, `renderMarkdown`, `FrontmatterError` |
|
|
23
26
|
| Text | `clipMiddle`, `truncate`, `tail`, `countWords`, `languageCode`, `tokensPerWord`, `scaleOutputTokens`, `sceneCharacterLimit` |
|
|
24
27
|
| AI | `AiPort` (the only door to language models), `createFetchAi` (OpenAI, Azure OpenAI, GitHub Models), `buildChatRequest`, `resolveAiCandidates`, `pickAiRuntimeConfig`, `redactAiRuntimeConfig`, `AI_THINKING_LEVELS`, `AI_REASONING_PARAMETERS`, `suggestedReasoningParameter`, `AiToolsRequiredError`, `effectiveAiBase`, `endpointOrigin`, `redactSecrets`, the deadlines and limits of a call (`DEFAULT_REQUEST_TIMEOUT_MS`, `MIN_REQUEST_TIMEOUT_MS`, `DEFAULT_IDLE_TIMEOUT_MS`, `TOTAL_REQUEST_CAP_MS`, `MAX_STREAM_TRANSPORT_BYTES`…) |
|
|
25
28
|
| Model catalog | `fetchModelCatalog` (the models of an OpenAI-compatible endpoint, with the window, the largest answer and the capabilities its gateway declares), `probeEndpoint` (does it answer, and how), `fetchLmStudioModels`, the pure parsers `parseModelList`, `parseModelDetails`, `parseModalities`, `tokenLimitsFromDetails`, `modelFieldsFromCatalogEntry`, `parseLmStudioModels`, `lmStudioContext`, `AiCatalogError`, `AI_MODEL_TYPES`, `catalogTarget`: see *Model catalog and declared capabilities* |
|
|
26
|
-
| Personal server | `NarrariumServerClient`, `pairWithServer`, `pairWithServerDetailed`, `verifyServerIdentity`, `serverCompatibility`, `serverSupportsAutopilotControls`, `serverSupportsAutopilotRules`, `remoteBookStore`, protocol types (scopes, pairing, updates), `ServerSentEventParser` |
|
|
29
|
+
| Personal server | `NarrariumServerClient`, `pairWithServer`, `pairWithServerDetailed`, `verifyServerIdentity`, `serverCompatibility`, `serverSupportsAutopilotControls`, `serverSupportsAutopilotRules`, `serverSupportsFrozenChapters`, `remoteBookStore`, protocol types (scopes, pairing, updates), `ServerSentEventParser` |
|
|
27
30
|
| Sync | `planFileSync`, `syncBookStores` (three-way sync of two book stores, with the files it leaves out in `skipped`) |
|
|
28
31
|
| Testing | `narrarium-engine/testing`: `MemoryBookStore`, `seedBookFiles`, `createFakeAutopilotAi` |
|
|
29
32
|
|
|
@@ -71,16 +74,16 @@ A run whose heartbeat is older than `RUNNER_STALE_MINUTES` (20) is taken for dea
|
|
|
71
74
|
|
|
72
75
|
### Pipeline
|
|
73
76
|
|
|
74
|
-
1. **Concept** — story design, world context, characters, locations, factions and secrets (skipped when the book already has a design or prose).
|
|
77
|
+
1. **Concept** — story design, world context, characters, locations, factions and secrets (skipped when the book already has a design or prose). The author's outline, when there is one, is binding for it too.
|
|
75
78
|
2. **Summaries of the author's chapters** — only for a book with chapters written by the author: see *Chapters the author wrote*.
|
|
76
|
-
3. **Plan** — chapter plan; simulated readers react to it and the director approves it or asks for changes. The run can pause here for the author.
|
|
77
|
-
4. **Per chapter** — scene plan, prose scene by scene (streamed), then the review cycle:
|
|
79
|
+
3. **Plan** — chapter plan, following the author's outline as binding when there is one, and filling the outline with what it planned; simulated readers react to it and the director approves it or asks for changes (judging with the method and the severity of the evaluation style). The run can pause here for the author. See *Outline (Scaletta)*.
|
|
80
|
+
4. **Per chapter** — when the author changed the outline of the chapter since it was planned, the chapter is planned again (`replan`); then the scene plan, prose scene by scene (streamed), then the review cycle:
|
|
78
81
|
- blind simulated readers (no canon, no secrets) and a panel summary;
|
|
79
|
-
- specialists (continuity, canon, secrets, timeline, voice, style, pacing) with evidence anchored in the text;
|
|
80
|
-
- the **director** accepts or rejects every finding; the software, not the model, derives the repairs;
|
|
82
|
+
- specialists (continuity, canon, secrets, timeline, voice, style, pacing) with evidence anchored in the text, and the criteria of the evaluation style;
|
|
83
|
+
- the **director** accepts or rejects every finding, judging with the evaluation style; the software, not the model, derives the repairs;
|
|
81
84
|
- accepted fixes are applied; a new round verifies them, up to the director's round limit;
|
|
82
85
|
- consolidation: chapter summary, recap, story so far, `plot.md`.
|
|
83
|
-
5. **Final** — the director's judgement on the whole book.
|
|
86
|
+
5. **Final** — the director's judgement on the whole book, with the evaluation style.
|
|
84
87
|
|
|
85
88
|
### Author interventions
|
|
86
89
|
|
|
@@ -111,11 +114,11 @@ What the web app's quick-command bar uses: pause at the end of the chapter, the
|
|
|
111
114
|
|
|
112
115
|
The engine applies it, so a host only says *how* to publish: `hooks.afterCommit` is called after every saved step when the way is `"step"`; `hooks.afterChapter` when a chapter is closed and the way is `"chapter"` or `"step"`; neither when it is `"off"`. A host that publishes in every way needs both hooks. The way is read at the end of every step and of every chapter, from the state that step saved. A publish that fails is reported as before (a `sync` event with `syncFailed`, or `publishFailed` for a chapter) and never stops the run. `beforeStep` is not a publish: it is called before every step whatever the way.
|
|
113
116
|
|
|
114
|
-
**Changing settings during a run.** `session.updateOptions(partial)` saves the options and answers the saved state. While a run is active only `publishEvery` (`null` takes the choice back, so that the host decides again) and `
|
|
117
|
+
**Changing settings during a run.** `session.updateOptions(partial)` saves the options and answers the saved state. While a run is active only `publishEvery` (`null` takes the choice back, so that the host decides again), `pauseAfterEachChapter` and `frozenEdits` (see *Frozen chapters*) can change (`LIVE_AUTOPILOT_OPTIONS`); any other option throws `AutopilotBusyError`, as `configure` does, and nothing of that request is applied. With no run active any option can change. The change is a compare-and-swap commit, like an intervention: the step in flight is neither failed nor repeated, the run takes the author's value into the state the step saves (`reconcileAuthorChanges`) and reads it at the end of that step, or of the chapter. A value nobody knows changes nothing, and a request that changes nothing writes nothing.
|
|
115
118
|
|
|
116
|
-
**What the summary says.** `AutopilotStateSummary`, which the `state` events carry and `snapshot().summary` holds for a client that connects later, has
|
|
119
|
+
**What the summary says.** `AutopilotStateSummary`, which the `state` events carry and `snapshot().summary` holds for a client that connects later, has five fields that are never saved: `frozenChanges` (how many chapters have a change that waits for the author, absent when none does: see *Frozen chapters*), `pausePending` (`"after-step"`, `"after-chapter"` or `null`), `limits` (`{ steps?, chapters?, stepsDone, chaptersDone }` of the run in progress, `null` when it has none or is over; `chapters` is the stricter of the run's limit and `chaptersPerRun`), `publish` (`effectivePublish` of the options and the host's default) and `retry` (the retry the run is waiting for, present only while it is: see *What the interface reads*). A summary made from the state file alone (`summarizeAutopilotState(state)`) has no `frozenChanges`, no `pausePending`, no `limits` and no `retry`: nothing in the file says them, so a client takes them from the events and the snapshot. They change without the state being written, so `updatedAt` does not move: every change of the pause that waits, and every saved step, is a `state` event, and a client keeps the newest event it has seen, whatever its `updatedAt`.
|
|
117
120
|
|
|
118
|
-
**Message codes.** `run-ended` and `insight` events carry a `code` when a client can say it in its own language: `chapterPause`, `stepLimit` and `chapterLimit` join `takenOver` and the others (`AutopilotMessageCode`). The `message` of the event, and of the saved state, is always in the language of the book.
|
|
121
|
+
**Message codes.** `run-ended` and `insight` events carry a `code` when a client can say it in its own language: `chapterPause`, `stepLimit` and `chapterLimit` join `takenOver` and the others (`AutopilotMessageCode`). The `message` of the event, and of the saved state, is always in the language of the book. The insights about the outline have codes of their own and say which chapter they are about (`chapterNumber`, and `ghostwriter` for one that does not exist): `outlineGhostwriter`, `outlineChanged`, `outlineRemoved`, `outlineWrittenChanged`, `outlineWrittenAuto` and `outlineWarnings` (see *Outline (Scaletta)*); so do the insights about the frozen chapters: `frozenMigrated`, `frozenChanged`, `frozenAuto`, `frozenReviewed`, `frozenCleared` and `frozenInvalid` (see *Frozen chapters*).
|
|
119
122
|
|
|
120
123
|
### What the interface reads
|
|
121
124
|
|
|
@@ -153,7 +156,11 @@ Data the web app's pages used to have to guess (from the text of a step, from th
|
|
|
153
156
|
|
|
154
157
|
**What a model declares.** The safe view of the AI configuration (`redactAiRuntimeConfig(config).integrations[].models[]`, which the personal server's `GET /ai` forwards as it is) says, for every model, what its configuration declares: `supportsToolCalls`, `supportsStreaming`, `supportsReasoning`, `supportsVision`, `maxInputTokens` and `maxOutputTokens`, and the `reasoningParameter` that says how its thinking level is sent (the "Thinking parameter" of the model, «Parametro del thinking»: `reasoning_effort`, `chat_template_kwargs.reasoning_strength` or `none`, with `AI_REASONING_PARAMETERS` for the list and `suggestedReasoningParameter(name, underlyingModel?)` for a hint that a screen may offer, which the engine never applies by itself), each only when it is declared or set (a model that declares nothing is `{ name, capabilities }`, as it always was). An attempt says what it did not do because of it: `onAttempt.notes` (English, absent when there is nothing to say; `ChatRequest.notes` for a host that builds the request itself), and `onAttempt.reasoningParameter` where the level went when it did not go as `reasoning_effort`. A reply cut with nothing written by a model declared as reasoning is a `truncated` error with `reasoningOnly`, so its `errorKind` is `truncated` like any cut reply. What an endpoint says of its models, and whether it answers at all, is what `fetchModelCatalog` and `probeEndpoint` return: see *Model catalog and declared capabilities*. All of it is additive: a configuration that declares nothing reads and runs as it always did.
|
|
155
158
|
|
|
156
|
-
**
|
|
159
|
+
**The outline and the ghostwriter of every chapter.** `PlannedChapter.ghostwriter` is the ghostwriter the outline gives the chapter (the slug of `ghostwriters/<slug>.md`), absent when it is the book's; the chapter's `chapter.md` says it too, so a page that shows the chapter reads it where it always did. `PlannedChapter.outlineDigest` is the digest of the chapter's entry of the outline (`outlineEntryDigest`) as it was when the plan followed it, or wrote it: an entry whose `contentDigest` is not the chapter's `outlineDigest` has been changed by the author since (`outlinePlanStatus(reader, state, language)` says which ones, for a chapter not written yet and for the written ones). `plan.removedChapters` lists the chapters taken out of the plan because the author deleted their entry. `options.fillOutline` (on by default, saved with the other options, not changeable while a run is active) says whether the plan fills the outline. `state.concept.logline` is the pitch of the concept, which becomes the description of the outline. New task kind: `replan` (a chapter planned again from its new entry, or taken out of the plan). New insight codes: `outlineGhostwriter`, `outlineChanged`, `outlineRemoved`, `outlineWrittenChanged`, `outlineWarnings`, each with `chapterNumber` (see *Outline (Scaletta)*). An engine from before these fields drops them on its first write; the outline files stay, the next plan of a newer engine reads them again, and a chapter whose plan lost its digest is not planned again from an entry the autopilot wrote (only from one of the author).
|
|
160
|
+
|
|
161
|
+
**Frozen chapters.** What the pages read of them (see *Frozen chapters* for what they mean): `summary.frozenChanges` (not saved: how many chapters have a change that waits for the author's decision, as the run found it before its last step or the last `frozenStatus()`; absent when none waits, as `retry` is, until one of them looked, and from a summary made from the state file alone); `options.frozenEdits` (`"ask"`, `"auto"`, `"notify"`); `state.pendingReviews` (the decisions recorded: `{ id, kind, number, action, fingerprint, at, note?, auto?, started? }`, `started` while one is carried out, with `phase` and the chapter as it was `before`); `state.question` of kind `frozen-change` or `outline-change`, with `choices` (`{ id, label }`, the labels in the language of the book), `options` (the same labels) and `frozen` (`{ kind, number, slug, fingerprint, title?, by?, frozenAt?, changed?, others? }`); `QuestionAnswer.choice`; `state.frozenSince` and `state.frozenSeen` (the engine's bookkeeping); `state.review.authorEdit` (the round of review of an author's change); `state.revision.afterChapter`, `onlyChapter` and `source` (a revision that comes from a change: `{ kind, chapterNumber, note?, auto?, before?, after? }`); the snapshot's `ChapterInfo.frozen`, `frozenProblem`, `bodyDigest` and `document`, and `ParagraphInfo.bodyDigest`. New task kind: `freeze` (without the model). New insight codes to say in the language of the interface, each with `chapterNumber` but the first: `frozenMigrated` (the chapters an older engine approved are frozen now), `frozenChanged` (`notify`: a frozen chapter changed), `frozenAuto` (`auto`: a change is reviewed and the book updated from it), `outlineWrittenAuto` (`auto`: a chapter is rewritten to follow its outline), `frozenReviewed` (a decision was carried out, or a change was marked as reviewed), `frozenCleared` (a change is gone: its question, or its decision, is dropped), `frozenInvalid` (a record that cannot be read; a warning). New kinds of question: `frozen-change`, `outline-change`; their choices are the actions, by id: `review-and-update`, `review-only`, `mark-reviewed`, `rewrite-to-outline`, `keep-text`.
|
|
162
|
+
|
|
163
|
+
**Older and newer engines.** Every new field is read tolerantly (a value that is not valid is dropped, never made up) and an older file reads as it always did. An engine from before these fields reads a file that has them without trouble but does not know them: `normalizeAutopilotState` of that engine drops `finalReview`, `stats.workedMs`, the kind and the detail of `lastError`, and the `rounds` of the chapters, so the first time it writes the state the history is lost (the activities keep their `errorKind` and `errorDetail`, which it does not look at). The worked time then starts again from zero in the engine that knows it, and the rounds start again with the next review. An engine that knows the rounds and the worked time but not what was added after them (the `verdict` of a round, `stats.workedMsSince`, `lastError.activityId` and the `retryAfterMs` of an error detail) drops those four on its first write, and the engine that knows them does not make them up again: a book that goes back and forth between the two keeps its rounds and its time, and loses the verdicts, the moment and the id of the failed step written meanwhile. The frozen chapters are the same story: an engine from before them drops `pendingReviews`, `frozenSince`, `frozenSeen`, `options.frozenEdits`, the `authorEdit` of a review and the `afterChapter`, `onlyChapter` and `source` of a revision, and reads a question about a change as a question of the director with free text (its `choices` and `frozen` dropped); the records in chapter.md stay. The engine that knows them then asks again about what is still changed, and a state without `frozenSince` freezes the chapters the autopilot approved, once, without asking.
|
|
157
164
|
|
|
158
165
|
### Long books
|
|
159
166
|
|
|
@@ -179,23 +186,157 @@ Values are read as the author wrote them: an autonomy whatever its case (`Full`,
|
|
|
179
186
|
|
|
180
187
|
### Profiles that cannot be read
|
|
181
188
|
|
|
182
|
-
`parseDirector`, `parseGhostwriter` and `
|
|
189
|
+
`parseDirector`, `parseGhostwriter`, `parseReaderPersona` and `parseEvaluationStyle` never throw and never hide a problem: they return `warnings: string[]` (empty when the file is as it says), each naming the file. A warning is YAML that cannot be read (with its line), a value that is not understood (an autonomy nobody knows, a score that is not a number, a list that is not a list, a reader type that is none of `standard`, `genre`, `custom`, a switch that is neither yes nor no, a criterion of the evaluation style that cannot be read), and the profile then has the default for that value, as it always had. The defaults themselves carry `warnings: []`.
|
|
183
190
|
|
|
184
191
|
A profile with warnings is not what the author wrote, so the engine never goes on with it silently and never replaces the file with the defaults:
|
|
185
192
|
|
|
186
|
-
- before a step, the autopilot checks the director, the files of the simulated readers when readers are used, and the ghostwriter of the chapter for a step that writes. When one has warnings it spends nothing, emits an insight with code `profileProblems` and stops with `status: "waiting-author"` and a `message` that lists the problems (in the language of the book); the author corrects the file and resumes.
|
|
193
|
+
- before a step, the autopilot checks the director, the evaluation style (`evaluation-guidelines.md`, when the book has one), the files of the simulated readers when readers are used, and the ghostwriter of the chapter for a step that writes. When one has warnings it spends nothing, emits an insight with code `profileProblems` and stops with `status: "waiting-author"` and a `message` that lists the problems (in the language of the book); the author corrects the file and resumes.
|
|
187
194
|
- `askDirector` still gives its opinion, and reports the problems of `director.md` in `warnings` next to it.
|
|
188
195
|
- a host that saves a profile should not do it over a file that has warnings.
|
|
189
196
|
|
|
197
|
+
## Outline (Scaletta)
|
|
198
|
+
|
|
199
|
+
The outline is the author's chapter-by-chapter trace of the book: a rough description of the book and, for every chapter, a hypothetical title, what happens in it and, when it is not the book's, the ghostwriter that writes it. It is a main part of the book, useful without the autopilot too, kept in files of the book, and the autopilot follows it as binding. It is not `plot.md`, which the autopilot generates from the chapters it closes.
|
|
200
|
+
|
|
201
|
+
### The files
|
|
202
|
+
|
|
203
|
+
| Path | Frontmatter | Body |
|
|
204
|
+
|---|---|---|
|
|
205
|
+
| `outline/book.md` | `type: outline`, `id: outline:book`, `title?` (a working title: the book's own stays in `book.md`), `origin?`, `digest?` | The rough description of the book, free Markdown. |
|
|
206
|
+
| `outline/chapters/<NNN>.md` | `type: outline-chapter`, `id: outline-chapter:<NNN>`, `number`, `title?` (the hypothetical title), `ghostwriter?` (the slug of `ghostwriters/<slug>.md`; absent: the book's), `origin: author \| autopilot`, `digest?` | What happens in the chapter, plain text. |
|
|
207
|
+
|
|
208
|
+
One file per chapter: the outline has no maximum, and no file grows with the book. `<NNN>` has the zero-padding of the chapter folders (`formatOrdinal`): `outlineChapterPath(7)` is `outline/chapters/007.md`, `outlineChapterPath(1500)` is `outline/chapters/1500.md`, and `parseOutlineChapterPath(path)` reads the number back. The number of an entry is the one of its file's name; a frontmatter that says another is a warning, and the name wins. The keys the format does not know are kept whenever the engine rewrites a file. The core (`narrarium`) has the same paths (`OUTLINE_BOOK_FILE`, `OUTLINE_CHAPTERS_DIRECTORY`, `outlineChapterPath`, `parseOutlineChapterPath`), validates the files with `outlineBookSchema` and `outlineChapterSchema` (passthrough), searches them and renames references in them with the rest of the book (`CONTENT_GLOB`), and its doctor warns, never errs, about a number that is not the file's and a ghostwriter that does not exist.
|
|
209
|
+
|
|
210
|
+
### Who wrote an entry: `origin` and `digest`
|
|
211
|
+
|
|
212
|
+
- `origin: author`, or no `origin`: the author's. It binds the autopilot, which never rewrites it.
|
|
213
|
+
- `origin: autopilot` with a `digest`: written by the autopilot from its plan. The digest is `outlineEntryDigest({ title, body, ghostwriter })` of what it wrote: sixteen hexadecimal characters of a SHA-256, where line endings and the spaces around the texts do not count. While the entry still matches its digest it is *intact*: the autopilot's own, which binds nothing and which the autopilot may write again when its plan changes. As soon as the author changes its title, its text or its ghostwriter it no longer matches it, and it is the author's.
|
|
214
|
+
- An entry whose frontmatter cannot be read is the author's: it is read as far as it can be (its text is all there), the author is told, and the autopilot never rewrites it.
|
|
215
|
+
- The description of the book follows the same rules, with `outlineBookDigest({ title, body })`.
|
|
216
|
+
|
|
217
|
+
`parseOutline(files)` (pure: no I/O) gives `{ book, chapters, warnings }`. Every entry has `number`, `title` (empty when it has none), `body`, `ghostwriter?`, `origin`, `digest?`, `contentDigest` (the digest of what it says now), `intact`, `unreadable?`, its `frontmatter` and the `hash` of its file. It never throws: two files for one chapter (`007.md` and `0007.md`: the one named as the core names it counts), a number that is not the file's, an `origin` nobody knows, a text over `OUTLINE_ENTRY_MAX_CHARS` (20 000 characters), YAML that cannot be read, a file of `outline/` that is not an entry and chapters without an entry between two that have one are warnings: `{ code, message, path?, number? }`, the message in English and naming the file.
|
|
218
|
+
|
|
219
|
+
### Editing it
|
|
220
|
+
|
|
221
|
+
`outlineChanges({ outline, edit, ghostwriters? })` makes an edit of the author into `{ changes, warnings }`: the `BookFileChange[]` of one commit, each expecting the file as it was read (`null`: a file that must not exist yet), so an edit made on an outline that changed in the meantime is refused by the store instead of overwriting it. `outline` is what `parseOutline` read, with the hashes of the files; `ghostwriters` the slugs of the book's ghostwriters (without it they are not checked). The edits:
|
|
222
|
+
|
|
223
|
+
| `edit` | What it does |
|
|
224
|
+
|---|---|
|
|
225
|
+
| `{ kind: "append", entry }` | A chapter after the last one. |
|
|
226
|
+
| `{ kind: "insert", at, entry }` | A chapter at position `at`; the entries from there on move one number up. Inserting at the head of an outline of 5000 chapters is 5000 renames and one new file, in the same list. |
|
|
227
|
+
| `{ kind: "move", from, to }` | The entry `from` goes to position `to`, the ones in between follow. |
|
|
228
|
+
| `{ kind: "remove", number, renumber? }` | Deletes the entry and leaves its number empty; with `renumber: true` the following ones move one number down. |
|
|
229
|
+
| `{ kind: "update", number, entry }` | Changes the `title`, the `body` or the `ghostwriter` given (`ghostwriter: null` takes it away: the book's writes); creates the entry when there is none. |
|
|
230
|
+
| `{ kind: "book", title?, body? }` | Changes the working title or the description. |
|
|
231
|
+
|
|
232
|
+
`entry` is `{ title?, body?, ghostwriter? }`. Every entry an edit writes or moves is the author's (`origin: author`, no `digest`): an outline the author arranged is never undone by the autopilot. An entry whose frontmatter cannot be read is moved as it is; one that is edited is written anew from the edit, with a warning. What the outline says is never an error: a ghostwriter that does not exist (`ghostwriter-missing`) or is not a file name (`ghostwriter-invalid`), a text cut at 20 000 characters (`text-too-long`), a title cut at `OUTLINE_TITLE_MAX_CHARS`, 200, because it names the chapter's folder (`title-too-long`), and the chapters left without an entry (`gap`) are warnings. Only an argument that is not a number of a chapter throws. `serializeOutlineChapter(entry)` and `serializeOutlineBook(book)` write one file.
|
|
233
|
+
|
|
234
|
+
### What the autopilot does with it
|
|
235
|
+
|
|
236
|
+
- **What binds.** The outline binds through the entries of the author (every entry but the autopilot's intact ones) and the description of the author. A book whose outline has nothing of the author, none at all or only the autopilot's intact entries, is asked exactly what it was asked before the outline existed.
|
|
237
|
+
- **As many chapters as it has.** The book is planned to `effectiveTargetChapters(state, { lastChapter })`: the brief's `targetChapters`, or the last chapter an entry of the author asks for when it is further. An entry the author adds after the last chapter of a finished book extends it, as raising `targetChapters` does.
|
|
238
|
+
- **The plan follows it.** The request of every batch of the plan carries the description of the book (at most 3000 characters), the entries of the chapters it plans (whole, as far as their share of 24 000 characters allows) and, condensed like every list of chapters, the entries of the chapters not planned yet, with the rule: the same chapters, in the same order, with the same hypothetical titles (the model refines a title only where the entry has none: the engine keeps the entry's own) and the same events; enrich, never change. `brief.synopsis` stays the fallback: alone it binds as it always did; next to an outline it applies where the outline says nothing, and the outline wins. The concept is told that the outline binds it, and the director is told not to ask the plan to change it.
|
|
239
|
+
- **The ghostwriter of a chapter.** A chapter takes the ghostwriter of its entry (`PlannedChapter.ghostwriter`) and the `chapter.md` the plan creates says it, when it is not the book's: the chain scene, chapter, book is the one it always was. An entry that names a ghostwriter that does not exist is said (`outlineGhostwriter`, with `chapterNumber` and `ghostwriter`), and the book's writes the chapter; when the author creates it before the chapter starts, the chapter takes it.
|
|
240
|
+
- **The plan fills it.** After every plan, and every revision of it, the plan writes, in the same commit, the entries of the chapters it planned that have none: the title, and as text the summary of the plan followed by its key events as a list, with `origin: autopilot` and the `digest` of what it wrote; and `outline/book.md` when it is missing, with the logline of the concept (or the brief's idea). The chapters the author wrote get an entry only when they have none, with their summary. An entry of the author is never touched; an intact one of the autopilot follows the plan when the director has it revised. `options.fillOutline: false` writes nothing. Every chapter keeps the digest of its entry (`outlineDigest`).
|
|
241
|
+
- **The author changes it.** Before the scenes of a chapter with nothing written are planned, its entry is compared with `outlineDigest`. An entry the author changed (or wrote for a chapter that had none) has the chapter planned again (`replan`: its title, summary, purpose, events and ghostwriter follow the new entry, its scenes are planned again), with the insight `outlineChanged` ("You changed the outline of chapter 7: I am planning it again"), and no other chapter is touched. An entry the author deleted takes its chapter out of the plan, and out of the book when its folder is empty (`outlineRemoved`): the following chapters keep their numbers, and the chapter counts in `plan.removedChapters` so that the book is not extended to replace it. Deleting the whole `outline/` takes no chapter out. An entry that cannot be read changes nothing until it is corrected (`outlineWarnings`). The entry of a chapter already closed that the author changed is decided like a change of a frozen chapter (`options.frozenEdits`: asked by default, with the choices `rewrite-to-outline`, `keep-text` and `mark-reviewed`; see *Frozen chapters*); one of a chapter still being written is said once a run, and decided once the chapter is closed; one that was deleted is said once a run (`outlineWrittenChanged`) and the chapter stays in the book.
|
|
242
|
+
- **What it costs.** The snapshot knows the files of the outline and their hashes from the list of the book (`snapshot.outline`, an `OutlineIndex`), without reading them; `OutlineReader` reads an entry only when a step needs it, through a cache of the run keyed by path and hash.
|
|
243
|
+
|
|
244
|
+
## Frozen chapters
|
|
245
|
+
|
|
246
|
+
A chapter is **frozen** when the autopilot's director approves it, or when the author freezes it by hand: its `chapter.md` holds a record of the chapter as it was. A change of its text after that is never ignored: before every step the autopilot notices it and, unless the author chose otherwise, stops and asks what to do (as BookWriter's "Review from a saved change": nothing starts by itself).
|
|
247
|
+
|
|
248
|
+
### The record
|
|
249
|
+
|
|
250
|
+
```yaml
|
|
251
|
+
frozen:
|
|
252
|
+
at: 2026-01-01T00:00:00.000Z # when (ISO 8601, UTC)
|
|
253
|
+
by: autopilot # or author
|
|
254
|
+
digest: 0f1e2d3c4b5a6978 # the body of chapter.md, its title heading excluded
|
|
255
|
+
files: # every scene, by the name of its file in the chapter's folder
|
|
256
|
+
001-the-arrival.md: 8a7b6c5d4e3f2a1b
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
- **What it fingerprints.** The text, never the frontmatter: a new summary, an id rewritten by a rename, a new title (and the `# Title` line of chapter.md that repeats it), line endings, spaces at the end of a line and the Unicode normalization are no change. A scene is named by its file in the folder, so a folder that is renamed or renumbered keeps its record; a scene file renamed with the same text is no change, two scenes that swapped their texts are. The digests are sixteen hexadecimal characters of a fast 64-bit hash (`textFingerprint`, `chapterBodyDigest`, `sceneBodyDigest`): they tell a change, they do not protect against one.
|
|
260
|
+
- **Read once.** `loadBookSnapshot` computes the digest of every chapter.md and scene when it reads the file, which it does once for each content (`SnapshotCache`): `ChapterInfo.bodyDigest`, `ParagraphInfo.bodyDigest`, the whole document of chapter.md in `ChapterInfo.document`, and the record in `ChapterInfo.frozen`. A record that cannot be read (`frozen: yes`, a digest that is not one, a moment that is not one…) is `ChapterInfo.frozenProblem` and the chapter counts as **not frozen**: it never blocks anything (the run says it once with `frozenInvalid`, and the core's doctor warns with `chapter-frozen-invalid`). `frozen: false`, or no key, is no record. A record is read tolerantly (`by: Author`, a moment in any zone, digests in capitals) and normalized.
|
|
261
|
+
- **Pure functions** (`book/freeze.ts`, no I/O): `freezeChapterChanges(snapshot, slug, by, at)`, `markReviewedChanges(snapshot, slug, at)` (frozen again as it is, keeping `by`) and `unfreezeChapterChanges(snapshot, slug)` answer the `BookFileChange[]` of one compare-and-swap commit of chapter.md (every other key and the body as they are; the file is made for a folder of scenes that has none; a chapter that does not exist is `FrozenChapterError` `chapter_not_found`, a frontmatter that cannot be read `FrontmatterError`). `frozenChanges(snapshot)` answers every frozen chapter whose text changed, in the order of the book: `{ number, slug, title, path, by, frozenAt, changed: { added, removed, modified, body }, fingerprint }`, where `fingerprint` is the same for the same edits and another for any other. It reads nothing: 5000 frozen chapters are checked in a few milliseconds, and a snapshot loaded again reads only the files whose hash changed. `parseChapterFreeze(value)` and `chapterFreezeRecord({ at, by, chapterBody, scenes })` are the reading and the making of a record.
|
|
262
|
+
- **The core** declares the key: `chapterFreezeSchema` (its shape) and `chapterSchema.frozen` (kept as it is, whatever it holds: a tool that rewrites chapter.md never drops it).
|
|
263
|
+
- **A whole text from elsewhere.** `keepChapterFreeze(proposed, current)` is chapter.md as a host writes it from a whole text it did not make itself (a proposal of a model, a tool that writes any file): with the record the file holds now, exactly, and with none when it holds none; everything else as written. A model never freezes a chapter or takes its freeze away, so its change of a frozen chapter is noticed like the author's, and a record it made up is dropped. A frontmatter that cannot be read, in either text, leaves the text as it is. The site's Copilot and the server's MCP `write_file` call it for the paths `parseChapterFilePath` reads.
|
|
264
|
+
|
|
265
|
+
### When the autopilot freezes
|
|
266
|
+
|
|
267
|
+
- **When it approves a chapter**: the closing of the chapter (`consolidate`) writes the record in the same commit as its summary, from the texts it read. A chapter frozen by the author keeps `by: author` when the autopilot closes it again.
|
|
268
|
+
- **After a revision** that rewrote a frozen chapter: the chapter is reviewed and closed again, so it is frozen again.
|
|
269
|
+
- **Never a chapter the author wrote** (`imported`): only the author freezes those (`freezeChapter`).
|
|
270
|
+
- **An older book.** A state saved before frozen chapters existed has no `state.frozenSince`: its first run freezes the chapters the autopilot approved (status `done`, not imported, with no record) in one `freeze` step that needs no model, says it once (`frozenMigrated`), and sets `frozenSince`; a new state has it from its creation. A chapter the author unfreezes afterwards stays unfrozen until the autopilot closes it again.
|
|
271
|
+
|
|
272
|
+
### When a frozen chapter changes: `options.frozenEdits`
|
|
273
|
+
|
|
274
|
+
Before every step the run compares the frozen chapters with their records (and the outline entries of the chapters already closed with the digest the plan keeps of them), and does with every change that has no decision yet what `options.frozenEdits` says:
|
|
275
|
+
|
|
276
|
+
| Mode | What happens |
|
|
277
|
+
|---|---|
|
|
278
|
+
| `ask` (the default) | The run stops (`waiting-author`) with a question, before anything else is done or spent: one change at a time, in the order of the book, the question saying which other chapters changed too. |
|
|
279
|
+
| `auto` | The change is reviewed and the book updated from it (`review-and-update`; for an outline entry, `rewrite-to-outline`) without asking, with the insight `frozenAuto` (`outlineWrittenAuto`). A chapter the author wrote is never rewritten for a decision of the autopilot: its outline change is only said, and the impact of a change never rewrites one. |
|
|
280
|
+
| `notify` | Every change is said once (`frozenChanged`, `outlineWrittenChanged`; its fingerprint is kept in `state.frozenSeen`, so it is not said again in another run), and nothing is done. |
|
|
281
|
+
|
|
282
|
+
The option is saved with the others, read tolerantly (any case; a value nobody knows changes nothing) and can change while a run goes on (`LIVE_AUTOPILOT_OPTIONS`).
|
|
283
|
+
|
|
284
|
+
- **What is never asked about**: the chapters the autopilot has in its hands (being written or reviewed, rewritten by the revision in progress, or the change being carried out): what happens to their files then is its own work. While it finishes work the author asked for (a revision, the chapters it rewrote reviewed again, the review of a change) no new question is asked: what it rewrites is frozen again at its end, and a change it did not reach is asked about once it is over.
|
|
285
|
+
- **A scene deleted** from a frozen chapter is a change to ask about: the plan follows the files of a frozen chapter, so the scene is never written again in silence (a chapter that is not frozen is reconciled as it always was).
|
|
286
|
+
- **A change taken back** withdraws its question; a change changed again is asked again (the question's `id` is `frozen-<number>-<fingerprint>`). A question that is open stops every run until it is answered.
|
|
287
|
+
|
|
288
|
+
### The question
|
|
289
|
+
|
|
290
|
+
`state.question` has `kind: "frozen-change"` ("You changed chapter 3, frozen on 2026-02-01. What should I do?", in the language of the book) or `kind: "outline-change"`, the typed `choices` (`{ id, label }`), the same labels in `options` (for an interface that only shows those), the context in words (what changed, the other chapters) and `frozen`: `{ kind, number, slug, fingerprint, title?, by?, frozenAt?, changed?, others? }`. The run's `message` says why it stopped.
|
|
291
|
+
|
|
292
|
+
`session.answer({ questionId, choice })` chooses by `id`; so does `answer: "<id>"`, and so does a label in either language, which is what an interface that shows `options` sends (and what an older personal server forwards, as it forwards `answer`). `accept: true` without a choice keeps the author's text (`mark-reviewed`; `keep-text` for the outline). Any other text reviews and updates the book (rewrites to the outline) with the text as the author's note for the director; with `asRule` it becomes a permanent rule too. An empty answer chooses nothing (`FrozenChapterError` `invalid_action`).
|
|
293
|
+
|
|
294
|
+
### The actions
|
|
295
|
+
|
|
296
|
+
| Action | What it does |
|
|
297
|
+
|---|---|
|
|
298
|
+
| `review-and-update` ("Review and update the book from this change") | The changed chapter goes back to review, before the plan: one round of the director (and of the specialists when they are on), without readers, whose accepted fixes are advice for the author and are **never applied** (the author's change stands); the round joins its `rounds`, and the chapter is closed (summary, story so far) and frozen again. Then the later chapters already written are checked: a revision (`state.revision` with `afterChapter`, analyzed with the tool `revision_impact`) is given BEFORE (what the autopilot knew of the chapter when it was frozen: its summary, key events and story so far at its close) and AFTER (its new closing), and chooses the scenes of the later chapters to rewrite; they are rewritten (`revise`), reviewed, closed and frozen again. The book's final judgement is made again. |
|
|
299
|
+
| `review-only` ("Only review the chapter") | The same round of the director on the changed chapter, and its closing, frozen again: nothing is rewritten and the later chapters are not checked. A complete book stays complete. |
|
|
300
|
+
| `mark-reviewed` ("Mark as reviewed") | Frozen again as it is, at once, without the model. For an outline entry, the same as `keep-text`. |
|
|
301
|
+
| `rewrite-to-outline` ("Rewrite the chapter to follow the outline") | The plan of the chapter follows the new entry (its purpose becomes the entry's text, its key events are dropped, `outlineDigest` is the entry's), and a revision limited to the chapter (`onlyChapter`) rewrites the scenes the new entry requires; the chapter is reviewed as usual (fixes applied), closed and frozen again, and then the later chapters are checked as for `review-and-update` (unless nothing was rewritten). |
|
|
302
|
+
| `keep-text` ("Keep the text, update only the outline") | The plan follows the new entry (`outlineDigest`), nothing is rewritten. |
|
|
303
|
+
|
|
304
|
+
A decision that needs the model is recorded in `state.pendingReviews` and carried out by the next run before it goes on with the plan (by a run in progress, at its next step), one at a time, in the order of the book; one whose change is gone by then is dropped (`frozenCleared`), and when it is over the run says it (`frozenReviewed`).
|
|
305
|
+
|
|
306
|
+
### For the hosts
|
|
307
|
+
|
|
308
|
+
- `session.frozenStatus()` answers `{ mode, changes, pending, warnings }`: every change, in the order of the book, with `kind`, `number`, `slug`, `title`, `fingerprint`, the `actions` that can be done with it now (all of its kind for a chapter of the plan; only `mark-reviewed` for a chapter the autopilot has no plan for), `by`, `frozenAt` and `changed` (a frozen chapter), `outline` (`{ title, digest }` of the new entry) and the decision already recorded (`pending: { action, at }`); the decisions recorded; and the chapters whose record cannot be read. It refreshes `summary.frozenChanges`.
|
|
309
|
+
- `session.resolveFrozenChange(number, action, { kind?, note? })` decides about a change, as the answer to the question would, also while a run goes on: `mark-reviewed` at once (one commit of chapter.md, and of the state when there is something to close), `keep-text` at once (at the next step of a run in progress); the others recorded for the run. `kind` (`frozen` or `outline`) tells the change of a chapter that has both; without it the action says it. Refused with `FrozenChapterError`: `chapter_not_found`, `not_changed` (nothing to decide about), `invalid_action` (`FROZEN_CHAPTER_ERROR_CODES`). Answers the status after it.
|
|
310
|
+
- `session.freezeChapter(slug)` and `session.unfreezeChapter(slug)` freeze a chapter by hand (`by: author`, as it is now: a change is accepted) or take its record away; the decisions that waited for it are dropped. They answer `{ slug, number, frozen }` (the record, or `null`).
|
|
311
|
+
- `summary.frozenChanges` counts the chapters with a change that waits for the author (a change with a decision recorded does not count), so that a band or a dock says it without the state: what the run found before its last step, or the last `frozenStatus()`. It is absent when none waits (a book without changes has the summary it always had).
|
|
312
|
+
- The routes of the personal server are in *The personal server client*.
|
|
313
|
+
|
|
314
|
+
## Evaluation style
|
|
315
|
+
|
|
316
|
+
`evaluation-guidelines.md`, the "Evaluation style" page of the web app, says how the author judges the book: `criteria`, a mapping of keys to `{ description }` (as the site writes it; a description written as text, a criterion left empty, and a list of `{ name, description }` are read as well), and a body with the critical method, the severity and the structure of a written evaluation. `parseEvaluationStyle(raw)` reads it as `{ title, criteria: [{ name, description }], body, path, warnings }` and `loadEvaluationStyle(store)` reads it from a book (`null` without the file). Like a profile it never throws and never drops a criterion in silence: YAML that cannot be read (with its line) and a criterion that cannot be read are warnings that name the file, and a file with warnings stops the run before it spends anything (`profileProblems`).
|
|
317
|
+
|
|
318
|
+
The autopilot judges with it:
|
|
319
|
+
|
|
320
|
+
| Step | What it reads |
|
|
321
|
+
|---|---|
|
|
322
|
+
| The director's review of a chapter | The criteria, the method and the severity. |
|
|
323
|
+
| The specialists (`FINDINGS`) | The criteria and the severity. |
|
|
324
|
+
| The final judgement of the book | The criteria, the method and the severity (`askDirector` takes it as `evaluationStyle`; an opinion asked by a host is unchanged unless the host passes it). |
|
|
325
|
+
| The review of the plan | Only the method and the severity: the criteria judge chapters. |
|
|
326
|
+
|
|
327
|
+
`evaluationStyleBlock(style, { criteria? })` is what a prompt carries: a block among the data of the request (the author's file, never instructions), delimited by its title and `END OF THE EVALUATION STYLE`, at most `EVALUATION_STYLE_MAX_CHARS` (3000) characters: the criteria first, each at most 400 characters, with a line that says how many are not listed when they do not all fit, then the method, cut with `clipText`, which keeps a part of its own however many criteria there are. The request says to judge with it. The score keeps its scale (0-10), the tools keep their schemas, and the sections a written evaluation would have do not change the answer: the criteria guide the judgement. A book without the file, or with a file that says nothing, sends the requests it always sent.
|
|
328
|
+
|
|
190
329
|
## Files in the book
|
|
191
330
|
|
|
192
331
|
| Path | Content |
|
|
193
332
|
|---|---|
|
|
194
333
|
| `director.md` | Director profile (`type: director`). |
|
|
334
|
+
| `evaluation-guidelines.md` | The evaluation style: criteria, method and severity. See *Evaluation style*. |
|
|
335
|
+
| `outline/book.md`, `outline/chapters/<NNN>.md` | The outline (Scaletta): the description of the book and one entry per chapter. See *Outline (Scaletta)*. |
|
|
195
336
|
| `autopilot/state.json` | Autopilot state: brief, options, plan (with the compact `rounds` of review of every chapter), review cycle, rules, interventions, statistics (with `workedMs`), the final review of the book (`finalReview`) and the last error with its kind. |
|
|
196
337
|
| `autopilot/activity.json` | Last 200 activities (what, why, next, result, model, tokens, cost). |
|
|
197
338
|
| `autopilot/plan.md` | Human-readable mirror of the plan. |
|
|
198
|
-
| `chapters/<chapter>/chapter.md` | The chapter, with its `summary` (written when it is closed, or by the summary step for a chapter the author wrote)
|
|
339
|
+
| `chapters/<chapter>/chapter.md` | The chapter, with its `summary` (written when it is closed, or by the summary step for a chapter the author wrote), its `ghostwriter` when the outline gives it one that is not the book's, and its freeze record (`frozen`) once the director approved it or the author froze it: see *Frozen chapters*. |
|
|
199
340
|
| `resumes/` | `total.md` (one section per chapter) and `chapters/<chapter>.md` (the recap of each one). |
|
|
200
341
|
| `evaluations/director/` | Director opinions (`book.md`, `chapters/<chapter>.md`, `paragraphs/<chapter>/<paragraph>.md`). |
|
|
201
342
|
| `evaluations/readers/` | Simulated reader evaluations, in the same format as the web app. |
|
|
@@ -501,6 +642,27 @@ A skipped file is not recorded as synced (a file that was never synced stays out
|
|
|
501
642
|
|
|
502
643
|
The `code` of a refusal of a rule is the `code` of the engine's `AutopilotRuleError` (`AUTOPILOT_RULE_ERROR_CODES`: `rule_empty`, `rule_too_long`, `rule_not_found`, `rule_changed`, `rule_duplicate`), which a server can answer as it is (`400` for the first, the third and the last, `404` for `rule_not_found`, `409` for `rule_changed`); `isAutopilotRuleErrorCode(error.code)` tells a refusal of a rule from the other codes of `ServerRequestError`. The client sends the text as it is given and an index as it is given (a number that names no rule is `404 rule_not_found`), and what it gets back is the error it always gives, with the status and the code of the server. The answer to a question of the director that is kept as a rule needs nothing new: `answer(bookId, { questionId, answer, asRule: true })` has always carried `asRule` (`QuestionAnswer`), and a note used once is still the default.
|
|
503
644
|
|
|
645
|
+
- **Frozen chapters.** The changes of the frozen chapters and the decisions about them (see *Frozen chapters*) go through three routes, which the engine's session already serves (`session.frozenStatus`, `session.resolveFrozenChange`, `session.freezeChapter` and `unfreezeChapter`). A server that implements them announces `SERVER_FEATURE_AUTOPILOT_FROZEN` (`"autopilot-frozen"`) in the `features` of `GET /api/v1/info`, and `serverSupportsFrozenChapters(info)` reads it (never throws; an older server, or an odd answer, says no): an older server answers `404 not_found` to the routes. The question needs no new route: an answer is the `answer` of `POST …/autopilot/answer` (the `id` of a choice, or its label), which every server forwards. Every call also answers `401 unauthorized`, `403 scope` and `404 book_not_found`, and `503 maintenance` while the server is about to restart.
|
|
646
|
+
|
|
647
|
+
| Client method | Request | Answer |
|
|
648
|
+
|---|---|---|
|
|
649
|
+
| `frozenStatus(bookId)` | `GET /api/v1/books/:id/autopilot/frozen`, permission `read`. | `200` the `FrozenStatus` (`{ mode, changes, pending, warnings }`). |
|
|
650
|
+
| `resolveFrozenChange(bookId, number, action, { kind?, note? })` | `POST /api/v1/books/:id/autopilot/frozen/:number` with `{ "action": "review-and-update" \| "review-only" \| "mark-reviewed" \| "rewrite-to-outline" \| "keep-text", "kind"?: "frozen" \| "outline", "note"?: string }`, permission `run`. Also while the autopilot runs. | `200` the `FrozenStatus` after it. `400 invalid_request` for a body that is not a JSON object, a number that is not a whole number from 1, or a `note` that is not text; `400 invalid_action`; `404 chapter_not_found`; `409 not_changed` (nothing to decide: it was decided, or taken back, elsewhere); `409 conflict` (the files kept changing under the write: try again); `409 state_corrupt`; `422 frontmatter_invalid` (the chapter.md cannot be read: the author corrects it). |
|
|
651
|
+
| `freezeChapter(bookId, slug, frozen)` | `POST /api/v1/books/:id/chapters/:slug/freeze` with `{ "frozen": boolean }`, permission `write`. | `200` `{ slug, number, frozen }` (the record, or `null`). `400 invalid_request` for a `frozen` that is not a boolean; `404 chapter_not_found`; `409 conflict`; `422 frontmatter_invalid`. |
|
|
652
|
+
|
|
653
|
+
The `code` of a refusal is the `code` of the engine's `FrozenChapterError` (`FROZEN_CHAPTER_ERROR_CODES`), and `isFrozenChapterErrorCode(error.code)` tells one from the other codes of `ServerRequestError`. The setting `frozenEdits` changes through `PUT …/autopilot/options`, like the other live settings.
|
|
654
|
+
|
|
655
|
+
- **The MCP endpoint of a book.** A server that gives each book its own MCP endpoint (`/mcp/<slug>`, which an assistant such as Claude Code, ChatGPT or Claude.ai connects to) announces `SERVER_FEATURE_MCP` (`"mcp"`) in the `features` of `GET /api/v1/info`; one on which apps such as ChatGPT and Claude.ai connect by themselves, through OAuth, also announces `SERVER_FEATURE_MCP_OAUTH` (`"mcp-oauth"`). `serverSupportsMcp(info)` and `serverSupportsMcpOAuth(info)` read them (never throw; an older server, or an odd answer, says no; each entry is read by itself, so one is never taken for the other). A client asks before it offers the setting: a server without `mcp` answers `404 not_found` to the routes below, and a server with `mcp` but without `mcp-oauth` answers `404 not_found` to the two that list and revoke apps, and its status carries neither `connections` nor `oauth` (a missing `connections` is *unknown*, not *none*). The calls fail as `{ "code", "message" }` with the status below, which `ServerRequestError` carries as `status` and `code`; every one also answers `401 unauthorized`, `403 scope` (a token without the permission in the table), `400 invalid_book` for a book id the server cannot keep and `404 book_not_found` for a book that is not there. The types are `ServerMcpStatus` (with `ServerMcpOAuth`), `UpdateMcpRequest`, `ServerMcpClient` and `ServerMcpClientScope`; the answers are passed on as the server gave them (what a newer server adds is not dropped), except that `listMcpClients` answers the list itself, an empty one when nothing is connected and also for an answer that has no list.
|
|
656
|
+
|
|
657
|
+
| Client method | Request | Answer |
|
|
658
|
+
|---|---|---|
|
|
659
|
+
| `mcpStatus(bookId)` | `GET /api/v1/books/:id/mcp` (`read`). | `200` the status: `{ bookId, enabled, slug, path, url, public, message?, protocolVersions, updatedAt, connections?, oauth? }`. `enabled` is false until the owner switches the book on. `url` is the address to paste into the assistant (`<public address>/mcp/<slug>`, or the local one while the server has no public address); `public` says whether it can be reached from outside, and `message` says why not when it cannot. `connections` is how many apps are connected through OAuth, and `oauth` is `{ issuer, metadataUrl, resourceMetadataUrl, scopes }`, where the OAuth server is (both only from a server that announces `mcp-oauth`). Asking for the status of a book that has no slug yet gives it one, and the slug is kept. |
|
|
660
|
+
| `updateMcp(bookId, { enabled?, slug? })` | `PUT /api/v1/books/:id/mcp` (`write`) with `{ "enabled"?: boolean, "slug"?: string }`. Only what is given is sent, and only those two (a `false` is a value). | `200` the status after the change. `400 invalid_slug` (a slug is 1 to 80 characters: lowercase letters and digits, joined by single hyphens), `409 slug_taken` (another book has it), `400 invalid_request` (a body that has neither key, or an `enabled` that is not a boolean), `503 maintenance` while the server is about to restart. **Switching a book off, or giving it another slug, disconnects every app that was connected to it** (`connections` is 0 in the answer): they do not come back when it is switched on again, the owner allows them again. |
|
|
661
|
+
| `listMcpClients(bookId)` | `GET /api/v1/books/:id/mcp/clients` (`write`: it says who may change the book). | `200` `{ "clients": [...] }`, and the method answers the array of `ServerMcpClient`: `{ id, clientId, name, redirectHost, scopes, createdAt, lastUsedAt }`. `id` is the connection's (what `revokeMcpClient` takes; the same app connected twice has two), `clientId` the id the app registered under, `name` what the app calls itself (cleaned, one line: show it as text), `redirectHost` the host the app sends the owner back to, `scopes` what the owner allowed (`read`, `write`, `run`; show the ones you know and leave out the rest), and the two dates are ISO times. Never a token. |
|
|
662
|
+
| `revokeMcpClient(bookId, id)` | `DELETE /api/v1/books/:id/mcp/clients/:id` (`write`), no body. | `200` `{ "revoked": true }`: the app's next call is refused and its tokens are useless, so it has to ask the owner again. `404 client_missing` when the book has no such connection (it was revoked already, it ended with the book's switch or slug, or it belongs to another book), told apart from `404 book_not_found` by the code. |
|
|
663
|
+
|
|
664
|
+
The apps are allowed by the owner on a page of his own server, with a passkey or the admin code: this client never does it, it only lists and revokes. The passkeys, the apps of every book at once and the audit of what was called are the server's admin panel's, and are not part of this API. A host that offers the setting shows `url` to copy and says what it needs: it can be pasted into ChatGPT or Claude.ai only when `public` is true.
|
|
665
|
+
|
|
504
666
|
## Tests
|
|
505
667
|
|
|
506
668
|
```bash
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog-fetch.d.ts","sourceRoot":"","sources":["../../src/ai/catalog-fetch.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAMvD,8HAA8H;AAC9H,eAAO,MAAM,iBAAiB,SAAU,CAAC;AACzC,qHAAqH;AACrH,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AACxC,0HAA0H;AAC1H,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAE3C,MAAM,WAAW,wBAAwB;IACvC,4GAA4G;IAC5G,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,sLAAsL;IACtL,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,gGAAgG;AAChG,MAAM,WAAW,cAAc;IAC7B,uMAAuM;IACvM,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAC9B,mKAAmK;IACnK,MAAM,EAAE;QAAE,MAAM,EAAE,IAAI,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,OAAO,CAAA;KAAE,CAAC;IAChE,yHAAyH;IACzH,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;CAChC;
|
|
1
|
+
{"version":3,"file":"catalog-fetch.d.ts","sourceRoot":"","sources":["../../src/ai/catalog-fetch.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACzB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAMvD,8HAA8H;AAC9H,eAAO,MAAM,iBAAiB,SAAU,CAAC;AACzC,qHAAqH;AACrH,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AACxC,0HAA0H;AAC1H,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAE3C,MAAM,WAAW,wBAAwB;IACvC,4GAA4G;IAC5G,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,sLAAsL;IACtL,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,gGAAgG;AAChG,MAAM,WAAW,cAAc;IAC7B,uMAAuM;IACvM,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAC9B,mKAAmK;IACnK,MAAM,EAAE;QAAE,MAAM,EAAE,IAAI,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,UAAU,EAAE,OAAO,CAAA;KAAE,CAAC;IAChE,yHAAyH;IACzH,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;CAChC;AA0KD;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,mBAAmB,EAAE,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,cAAc,CAAC,CA+BzI;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,mBAAmB,EAAE,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,eAAe,EAAE,GAAG,SAAS,CAAC,CAkB1J"}
|
package/dist/ai/catalog-fetch.js
CHANGED
|
@@ -136,7 +136,8 @@ function readingOf(integration, options) {
|
|
|
136
136
|
return {
|
|
137
137
|
name: nameOf(integration),
|
|
138
138
|
secrets: [integration.apiKey],
|
|
139
|
-
|
|
139
|
+
// The global fetch is called on its own, never as a method of this object: a browser refuses `fetch` called with another `this` (Illegal invocation).
|
|
140
|
+
fetchImpl: options.fetch ?? ((input, init) => fetch(input, init)),
|
|
140
141
|
signal: options.signal,
|
|
141
142
|
timeoutMs: timeoutOf(options.timeoutMs, CATALOG_TIMEOUT_MS),
|
|
142
143
|
};
|
|
@@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AAC,MAAM,CAAC,CAAC;QACvD,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { type ChapterFreeze, type FrozenChapterChange } from "../book/freeze.js";
|
|
2
|
+
import type { BookSnapshot, ChapterInfo } from "../book/snapshot.js";
|
|
3
|
+
import type { OutlineWrittenChange } from "./outline-check.js";
|
|
4
|
+
import type { PlanNote } from "./planner.js";
|
|
5
|
+
import { type AutopilotState, type DirectorQuestion, type FrozenAction, type FrozenChangeKind, type FrozenEditsMode, type PendingFrozenReview, type QuestionAnswer, type RevisionRequest } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* One change the author decides about: the text of a frozen chapter (`frozen`), or the outline entry of a chapter already closed
|
|
8
|
+
* (`outline`). `inPlan` says whether the chapter is one of the plan's, closed: only then can it be reviewed (else it can only be marked
|
|
9
|
+
* as reviewed). `pending` is the decision already recorded for it, when there is one.
|
|
10
|
+
*/
|
|
11
|
+
export interface FrozenWorkItem {
|
|
12
|
+
kind: FrozenChangeKind;
|
|
13
|
+
number: number;
|
|
14
|
+
slug: string;
|
|
15
|
+
title: string;
|
|
16
|
+
fingerprint: string;
|
|
17
|
+
/** The chapter was written by the author before the autopilot took over: never rewritten for a decision the autopilot took. */
|
|
18
|
+
imported: boolean;
|
|
19
|
+
inPlan: boolean;
|
|
20
|
+
change?: FrozenChapterChange;
|
|
21
|
+
outline?: OutlineWrittenChange;
|
|
22
|
+
pending?: PendingFrozenReview;
|
|
23
|
+
}
|
|
24
|
+
/** Whether a question is about a change of a frozen chapter or of the outline of a written one. */
|
|
25
|
+
export declare function isFrozenQuestion(question: DirectorQuestion | null | undefined): question is DirectorQuestion & {
|
|
26
|
+
frozen: NonNullable<DirectorQuestion["frozen"]>;
|
|
27
|
+
};
|
|
28
|
+
/** The decision being carried out, when one is: the autopilot works on one change at a time. */
|
|
29
|
+
export declare function startedReview(state: Pick<AutopilotState, "pendingReviews">): PendingFrozenReview | undefined;
|
|
30
|
+
/** Whether the revision in progress rewrites this chapter (or rewrote it, and reviews it again at its end). */
|
|
31
|
+
export declare function inRevision(state: Pick<AutopilotState, "revision">, number: number): boolean;
|
|
32
|
+
/** The changes of a book and what is decided about them, in the order of the book (a frozen chapter's text before its outline). */
|
|
33
|
+
export declare function frozenWork(state: AutopilotState | null, snapshot: BookSnapshot, outlineWritten?: ReadonlyMap<number, OutlineWrittenChange>): FrozenWorkItem[];
|
|
34
|
+
/** What can be done with a change now: reviewing needs the chapter in the plan, closed; marking reviewed can always be done. */
|
|
35
|
+
export declare function frozenActions(item: Pick<FrozenWorkItem, "kind" | "inPlan">): FrozenAction[];
|
|
36
|
+
/** The chapters the autopilot approved before it froze what it approves (a state saved by an older engine): frozen once, by its first run. Never the author's. */
|
|
37
|
+
export declare function legacyChapters(state: AutopilotState, snapshot: BookSnapshot): ChapterInfo[];
|
|
38
|
+
/** Decisions to mark a frozen chapter reviewed that wait for a run (a host that applied an answer by itself): the `freeze` step carries them out. */
|
|
39
|
+
export declare function queuedMarkReviewed(state: Pick<AutopilotState, "pendingReviews">): PendingFrozenReview[];
|
|
40
|
+
/** Whether the next step is the `freeze` step, which needs no model: the chapters an older engine approved, or changes marked as reviewed. */
|
|
41
|
+
export declare function needsFreezeStep(state: AutopilotState, snapshot: BookSnapshot): boolean;
|
|
42
|
+
/** The label of an action in the language of the book. */
|
|
43
|
+
export declare function frozenActionLabel(action: FrozenAction, language: string): string;
|
|
44
|
+
/** The question the run stops with for a change (one at a time, in the order of the book): it says the others that wait after it. */
|
|
45
|
+
export declare function frozenQuestion(item: FrozenWorkItem, others: FrozenWorkItem[], language: string, now: string): DirectorQuestion;
|
|
46
|
+
/** Why the run stopped, for a question about a change. */
|
|
47
|
+
export declare function frozenQuestionMessage(question: DirectorQuestion, language: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* The action an answer to a question about a change chooses. The `choice` (or the `answer`) names one by its id or its label, in either
|
|
50
|
+
* language, as an interface that only shows `options` sends it; `accept` without a choice keeps what the author did (`mark-reviewed`, or
|
|
51
|
+
* `keep-text` for the outline); any other text reviews and updates the book (rewrites to the outline), with the text as the author's
|
|
52
|
+
* note for the director. An empty answer chooses nothing.
|
|
53
|
+
*/
|
|
54
|
+
export declare function frozenAnswerAction(question: DirectorQuestion, answer: Pick<QuestionAnswer, "answer" | "choice" | "accept">): {
|
|
55
|
+
action: FrozenAction;
|
|
56
|
+
note?: string;
|
|
57
|
+
};
|
|
58
|
+
export interface FrozenDecision {
|
|
59
|
+
kind: FrozenChangeKind;
|
|
60
|
+
number: number;
|
|
61
|
+
action: FrozenAction;
|
|
62
|
+
/** The change decided about (`FrozenWorkItem.fingerprint`). */
|
|
63
|
+
fingerprint: string;
|
|
64
|
+
note?: string;
|
|
65
|
+
/** Taken by the autopilot (`frozenEdits: "auto"`). */
|
|
66
|
+
auto?: boolean;
|
|
67
|
+
/** The author's note becomes a permanent rule too (`QuestionAnswer.asRule`). */
|
|
68
|
+
asRule?: boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The state with a decision recorded: in `pendingReviews` (replacing one that waited for the same change of the same chapter), and the
|
|
72
|
+
* question about it closed. Pure. What needs no model is carried out at once by the session; the rest by the next run, before the plan.
|
|
73
|
+
*/
|
|
74
|
+
export declare function applyFrozenDecision(state: AutopilotState, decision: FrozenDecision, at: string, id: string): AutopilotState;
|
|
75
|
+
/** The state without a decision (carried out, or no longer about anything). */
|
|
76
|
+
export declare function withoutPendingReview(state: AutopilotState, id: string): AutopilotState;
|
|
77
|
+
/** Remove the decisions that wait for this chapter (all, or of one kind) and close the question about it: the author decided otherwise. */
|
|
78
|
+
export declare function forgetFrozenChapter(state: AutopilotState, number: number, kind?: FrozenChangeKind): AutopilotState;
|
|
79
|
+
export interface FrozenSettleInput {
|
|
80
|
+
snapshot: BookSnapshot;
|
|
81
|
+
/** The chapters already closed whose outline entry the author changed (`outlinePlanStatus(...).written`). */
|
|
82
|
+
outlineWritten: ReadonlyMap<number, OutlineWrittenChange>;
|
|
83
|
+
language: string;
|
|
84
|
+
now: string;
|
|
85
|
+
}
|
|
86
|
+
export interface FrozenSettleResult {
|
|
87
|
+
state: AutopilotState;
|
|
88
|
+
/** What the author should know (said once a run, by key). */
|
|
89
|
+
notes: PlanNote[];
|
|
90
|
+
/** How many chapters have a change that waits for the author's decision. */
|
|
91
|
+
waiting: number;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* What the run does with the changes before a step, as `options.frozenEdits` says: `ask` stops with a question (one change at a time,
|
|
95
|
+
* in the order of the book; a question whose change is gone is withdrawn, one whose change changed again is asked again); `auto`
|
|
96
|
+
* decides to review and update (to rewrite to the outline), with an insight, except for the chapters the author wrote, which are only
|
|
97
|
+
* said; `notify` says every change once (its fingerprint is remembered in `frozenSeen`). Records that cannot be read are said, and the
|
|
98
|
+
* state learns since when it knows frozen chapters once there is nothing an older engine approved left to freeze. Pure.
|
|
99
|
+
*/
|
|
100
|
+
export declare function settleFrozenChanges(input: AutopilotState, settle: FrozenSettleInput): FrozenSettleResult;
|
|
101
|
+
/** What the planner knows of the changes when it may start one (the runner, after it settled the changes of the step). */
|
|
102
|
+
export interface PlannerFrozen {
|
|
103
|
+
/** The chapters already closed whose outline entry changed: the new entry of a chapter about to be rewritten to follow it. */
|
|
104
|
+
outlineWritten: ReadonlyMap<number, OutlineWrittenChange>;
|
|
105
|
+
/** The moment the step begins. */
|
|
106
|
+
now: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* What advancing the state does with the decisions (`advanceState` calls it, before it opens the review of the current chapter):
|
|
110
|
+
*
|
|
111
|
+
* - a change of the outline the author kept (`keep-text`, `mark-reviewed`): the plan follows the new entry;
|
|
112
|
+
* - the decision being carried out, once its chapter is closed again: a review and update goes on with the impact on the later chapters
|
|
113
|
+
* (a revision with `afterChapter`), a review only is done, and so is a rewrite to the outline (after its own impact, when it rewrote);
|
|
114
|
+
* - when nothing is in progress (no question, revision or review) and the planner may start one (`frozen` is given), the first decision
|
|
115
|
+
* that waits, in the order of the book: the chapter goes back to `review` for one round of the director that applies nothing, or its
|
|
116
|
+
* rewrite to follow the new entry begins (a revision with `onlyChapter`). A decision whose change is gone is dropped and said.
|
|
117
|
+
*
|
|
118
|
+
* Deterministic: every id and moment comes from the decision or from `frozen.now`.
|
|
119
|
+
*/
|
|
120
|
+
export declare function advancePendingReviews(state: AutopilotState, snapshot: BookSnapshot, report: (note: PlanNote) => void, language: string, frozen?: PlannerFrozen): void;
|
|
121
|
+
/** When the revision that rewrites a chapter to follow its outline is over: whether it rewrote anything (else there is nothing to check after it). */
|
|
122
|
+
export declare function noteOutlineRewrite(state: AutopilotState, revision: RevisionRequest): void;
|
|
123
|
+
export interface FrozenStatusEntry {
|
|
124
|
+
kind: FrozenChangeKind;
|
|
125
|
+
number: number;
|
|
126
|
+
slug: string;
|
|
127
|
+
title: string;
|
|
128
|
+
/** The change: what a decision is about. */
|
|
129
|
+
fingerprint: string;
|
|
130
|
+
/** What can be done with it now (`frozenActions`). */
|
|
131
|
+
actions: FrozenAction[];
|
|
132
|
+
/** For a frozen chapter: who froze it, when, and what changed since. */
|
|
133
|
+
by?: FrozenChapterChange["by"];
|
|
134
|
+
frozenAt?: string;
|
|
135
|
+
changed?: FrozenChapterChange["changed"];
|
|
136
|
+
/** For the outline of a written chapter: the new entry. */
|
|
137
|
+
outline?: {
|
|
138
|
+
title: string;
|
|
139
|
+
digest: string;
|
|
140
|
+
};
|
|
141
|
+
/** The decision recorded for it, which the next run carries out (a run in progress, at its next step). */
|
|
142
|
+
pending?: {
|
|
143
|
+
action: FrozenAction;
|
|
144
|
+
at: string;
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export interface FrozenStatus {
|
|
148
|
+
/** `options.frozenEdits` (`ask` when there is no state yet). */
|
|
149
|
+
mode: FrozenEditsMode;
|
|
150
|
+
/** The changes, in the order of the book, with what can be done with each. */
|
|
151
|
+
changes: FrozenStatusEntry[];
|
|
152
|
+
/** The decisions recorded, also the one being carried out. */
|
|
153
|
+
pending: PendingFrozenReview[];
|
|
154
|
+
/** The chapters whose freeze record cannot be read (they count as not frozen). */
|
|
155
|
+
warnings: Array<{
|
|
156
|
+
slug: string;
|
|
157
|
+
path: string;
|
|
158
|
+
problem: string;
|
|
159
|
+
}>;
|
|
160
|
+
}
|
|
161
|
+
/** A chapter frozen or unfrozen by the author (`AutopilotSession.freezeChapter`, `unfreezeChapter`): its record now, `null` when it is not frozen. */
|
|
162
|
+
export interface FrozenChapterResult {
|
|
163
|
+
slug: string;
|
|
164
|
+
number: number;
|
|
165
|
+
frozen: ChapterFreeze | null;
|
|
166
|
+
}
|
|
167
|
+
/** How many chapters of a status have a change that waits for the author (the summary's `frozenChanges`). */
|
|
168
|
+
export declare function frozenWaitingCount(status: Pick<FrozenStatus, "changes">): number;
|
|
169
|
+
//# sourceMappingURL=frozen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frozen.d.ts","sourceRoot":"","sources":["../../src/autopilot/frozen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACpH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EAErB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAExB,KAAK,cAAc,EAEnB,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AAIpB;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,gBAAgB,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC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