(bookId: string)
| 232 | } |
| 233 | |
| 234 | async getNextChapterNumber(bookId: string): Promise<number> { |
| 235 | const durableChapter = await resolveDurableStoryProgress({ |
| 236 | bookDir: this.bookDir(bookId), |
| 237 | }); |
| 238 | // Ensure structured state is bootstrapped (side-effect: creates missing |
| 239 | // JSON files), but do NOT trust its chapter number for progress — only |
| 240 | // the contiguous durable artifact chain is authoritative. |
| 241 | await bootstrapStructuredStateFromMarkdown({ |
| 242 | bookDir: this.bookDir(bookId), |
| 243 | fallbackChapter: durableChapter, |
| 244 | }); |
| 245 | return durableChapter + 1; |
| 246 | } |
| 247 | |
| 248 | async getPersistedChapterCount(bookId: string): Promise<number> { |
| 249 | const chaptersDir = join(this.bookDir(bookId), "chapters"); |
no test coverage detected