Skip to content

[WIP] Update default chapter generation to use scene-chunked strategy - #9

Draft
crazyrob425 with Copilot wants to merge 1 commit into
mainfrom
copilot/update-default-chapter-generation
Draft

[WIP] Update default chapter generation to use scene-chunked strategy#9
crazyrob425 with Copilot wants to merge 1 commit into
mainfrom
copilot/update-default-chapter-generation

Conversation

Copilot AI commented Mar 26, 2026

Copy link
Copy Markdown

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.

Original prompt

User preference confirmed: default chapter generation should use scene-chunked generation to minimize token waste.

Update the existing PR changes to:

  • Set scene-chunked generation as the default strategy for chapter generation.
  • Implement chunk planner + rolling micro-summary mechanism.
  • Ensure orchestration budgets and telemetry reflect chunked strategy.
  • Expose a UI setting to toggle between single-pass and chunked generation, defaulting to chunked.

Repository context: crazyrob425/KDP-E-Book-Generator.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: analyze the codes line by line and create a detailed blueprint and todo

Assistant: Below is a codebase analysis + blueprint + TODO plan for crazyrob425/KDP-E-Book-Generator based on the files I could pull from the repo (root, services/, server/, electron/, hooks/, plus directory listings under components/). Where I say “line-by-line”, I’m going file-by-file and section-by-section (the repo has a very large App.tsx, so I’m describing it in contiguous “blocks” of lines / responsibilities rather than literally enumerating 45k lines one by one).


0) High-level: what this repo currently is

Current architecture (as implemented):

  • React + Vite + TypeScript frontend (mostly driven by a single massive App.tsx orchestrator).
  • AI generation via Google Gemini (client-side calls through @google/genai) in services/geminiService.ts.
  • Local persistence:
    • “V5 DB” using IndexedDB wrapper in services/storageService.ts.
    • Extra “AutoSave” feature saving a JSON file via Electron IPC if running as desktop (hooks/useAutoSave.ts).
  • Electron wrapper:
    • electron/main.ts sets up a frameless window + IPC handlers.
    • Bridges to “bot automation” and “market research workers”.
  • Optional Node server:
    • server/server.ts provides WebSocket-based automation sessions.
    • server/automation-worker.ts Playwright automation for KDP upload flow (with CAPTCHA yield/continue).
    • server/market-research-worker.ts fetches Google Trends + scrapes Amazon results + Amazon suggest.

Big gaps (blocking “Binary Books E‑Crafter” spec):

  • EPUB generation is currently stubbed/disabled (services/epubGenerator.ts returns a plain text Blob).
  • The “multi-agent swarm”, lore engine, continuity, long-form pipeline, and robust formatting checks are not implemented yet (only single-pass prompts exist).
  • Scraping/automation will be fragile and has compliance/risk concerns (Amazon ToS, bot detection, CAPTCHA handling, account lock risk).

1) Repository map (what’s here)

Root

  • App.tsx (very large): main UI, state machine, orchestration of steps, saving, generation triggers.
  • index.tsx, index.html: Vite/React entry.
  • types.ts: shared types (MarketReport, BookOutline, Chapter, KDP marketing, Electron API, etc.), includes expansion types for “Universe/Lore”.
  • README.md: describes product as “FraudRob’s AI Book Factory”.

services/

  • geminiService.ts: main AI calls (genres, topics, market report, outline, chapter content, rewrite, image prompts, image generation, cover generation, example cover).
  • realMarketService.ts: (listed; not pulled content in the same batch) likely calls into Electron/Server for “real” market data.
  • storageService.ts: IndexedDB wrapper for saving/loading state + persistent storage/quota helpers.
  • epubGenerator.ts: markdown→HTML helper + EPUB generation stub (disabled).
  • audioService.ts: (listed) audiobook/tts related.
  • thirdPartyServices.ts: (listed) small integration config.
  • kdpAutomationService.ts: (listed) tiny placeholder file (52 bytes).

electron/

  • main.ts: creates BrowserWindow; IPC: window controls, automation start/stop/captcha, market research calls, save/load file dialogs.
  • preload.ts: (listed; not pulled here) likely exposes window.electronAPI.

server/

  • server.ts: Express + HTTP + WebSocket server that runs Playwright automation via async generator.
  • automation-worker.ts: Playwright flow for KDP login → new ebook → upload manuscript/cover → publish; yields CAPTCHA events.
  • market-research-worker.ts: Google Trends via google-trends-api, Amazon scrape via Playwright, Amazon suggest via public endpoint.
  • README.md: server instructions.
  • Dockerfile: empty.

hooks/

  • useAutoSave.ts: interval-based autosave to a JSON file through Electron.

components/

  • Many UI components/steps exist, including steps flow and “ExpansionHub” directories (not pulled contents here).

2) “Line-by-line” analysis (by file & functional blocks)

2.1 types.ts (core domain model)

What it defines:

  • Market research types
    • GoogleTrendsData: interestOverTime[], relatedQueries[]
    • MarketReport: trendAnalysis, targetAudience{...}, keywords[], suggestedBookTypes[], competitorAnalysis[], optional ...

This pull request was created from Copilot chat.


⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants