Skip to content

[WIP] Update chapter generation defaults for scene strategy and emotion polish#10

Draft
Copilot wants to merge 1 commit into
mainfrom
copilot/update-chapter-generation-defaults
Draft

[WIP] Update chapter generation defaults for scene strategy and emotion polish#10
Copilot wants to merge 1 commit into
mainfrom
copilot/update-chapter-generation-defaults

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

Update chapter generation defaults to use scene-chunked strategy with randomized scene count per chapter and a polish pass that enhances emotion.

Repo: crazyrob425/KDP-E-Book-Generator (ref main)

Requirements:

  1. Default chapter generation strategy = chunked scenes.
  2. Scene count per chapter should be randomized between 11 and 14 (inclusive) to avoid cookie-cutter structure while remaining controllable/reproducible.
    • Add a deterministic seeded RNG option so reruns with same seed produce same scene count.
    • If seed not provided, derive from projectId/chapter number/time as appropriate.
  3. Scene plan step should produce JSON with scene fields and include per-scene word/token budgets.
  4. Scene drafting should use rolling micro-summaries to keep context small and continuity strong.
  5. Add final polish step that enhances emotion (<= 5–8% expansion cap), improves flow, and removes repetition without changing plot facts.
  6. Add UI setting(s):
    • Toggle: Chunked vs single-pass (default chunked)
    • Slider/select: scene count range min/max (default 11–14)
    • Toggle: emotional polish (default ON)
  7. Add token telemetry updates to reflect chunked generation (per scene + polish), and track cache hits.
  8. Ensure these defaults are persisted in project state (IndexedDB) and migrated safely for existing saved projects.

Acceptance:

  • New projects default to chunked + 11–14 randomized scenes + emotional polish.
  • Existing projects load without errors; if settings missing, defaults apply.
  • Generation uses scene planner + per-scene writer + polish pass with cap.

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: (liste...

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

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