/** * AI Generation Manager * Coordinates AI-assisted content generation with proper context * * Philosophy: Suggest, don't dictate. Support the author's voice. */ import type { MCPClient } from '../core/database.js'; import type { SynopsisContext, SynopsisLength, OverviewLength } from '../types/novel.js'; export interface CharacterProfileRow { name: string; role?: string; summary?: string; [key: string]: unknown; } export interface WorldRuleRow { rule_name: string; description?: string; [key: string]: unknown; } export interface GenerationContext { projectId: number; genre?: string; tone?: string; currentChapter?: number; currentScene?: number; recentText?: string; characterProfiles?: CharacterProfileRow[]; locationDetails?: Record[]; worldRules?: WorldRuleRow[]; plotThreads?: Record[]; } export interface GenerationOptions { temperature?: number; maxLength?: number; style?: 'descriptive' | 'action' | 'dialogue' | 'introspective'; pov?: string; includeContext?: boolean; count?: number; } export interface GenerationResult { content: string; alternatives: string[]; reasoning?: string; warnings?: string[]; } /** * Manages AI-assisted generation */ export declare class GenerationManager { private mcpClient; private projectId; private claude; private contextAssembler; constructor(mcpClient: MCPClient, projectId: number); /** * Summarize a chapter in up to 5 sentences for story-context memory. * * Routes through `IClaudeClient`, so it works two ways automatically: * - With ANTHROPIC_API_KEY → the API returns the summary text. * - Without a key → PassthroughClaudeClient returns the assembled PROMPT and * `passthrough: true`; the Claude Code session that ran the command does the * summarizing. Either way the caller persists the result to the chapter's * `summary:` frontmatter. * * @param chapterText - chapter prose (frontmatter/markup already stripped) * @param title - optional chapter title, for prompt context */ generateChapterSummary(chapterText: string, title?: string): Promise<{ content: string; passthrough: boolean; }>; /** * Summarize the book the author INTENDS to write, from their planning data: * the outline (plot threads + their beats), the character roster, and any hard * world rules. Unlike `generateSynopsis` — which reads drafted chapter * summaries — this works pre-draft and describes the *planned* book. * * Routes through `IClaudeClient`: with ANTHROPIC_API_KEY the API returns the * prose; without a key the PassthroughClaudeClient returns the assembled * PROMPT and the Claude Code session writes the summary. Returns a `warnings` * entry (and empty content) when there is no outline or cast to summarize. * * @param projectId - Project identifier (string form accepted by callers) * @param length - 'brief' (~150w), 'standard' (~350w), or 'full' (~700w) */ generateOverview(projectId: string, length?: OverviewLength): Promise; /** * Generate character profile from description. * When options.count > 1, instructs Claude to return that many distinct profile options, * numbered, and parses them into alternatives[]. * * Based on NOVEL_CRAFT_PRINCIPLES: believable characters with flaws. */ generateCharacter(description: string, options?: GenerationOptions): Promise; /** * Generate location/world-building details */ generateLocation(description: string, options?: GenerationOptions): Promise; /** * Suggest scene continuation. * Defaults to 3 alternatives. Respects options.count (max 3). * Based on principle: "Follow the headlights" - discovery writing. */ suggestSceneContinuation(currentText: string, sceneId: number, options?: GenerationOptions): Promise; /** * Enhance dialogue for character voice. * When options.count > 1, requests that many dialogue variations. * Based on principle: Give each character a voice. */ enhanceDialogue(dialogue: string, characterName: string, options?: GenerationOptions): Promise; /** * Expand description with sensory details. * When options.count > 1, requests distinct sensory approaches * (e.g. visual-first, sound-first, emotional-first). */ expandDescription(text: string, pov?: string, options?: GenerationOptions): Promise; /** * Suggest plot development. * Defaults to 3 alternatives. Respects options.count (max 3). */ suggestPlotDevelopment(threadName: string, currentStatus: string, options?: GenerationOptions): Promise; private buildCharacterPrompt; private buildLocationPrompt; private buildContinuationPrompt; private buildDialoguePrompt; private buildDescriptionPrompt; private buildPlotPrompt; private assembleProjectContext; private assembleSceneContext; private getCharacterProfile; private getPlotThread; /** * Load a character's voice, personality, and mannerisms from the database. * Returns null if the character is not found or an error occurs. * * @param projectId - The project to search within * @param name - The character's name */ private loadCharacterVoice; /** * Build the POV anchor block to prepend to a prompt when options.pov is set. * Returns an empty string if the character voice cannot be loaded. * * @param options - Generation options that may include a pov character name */ private buildPovBlock; /** * Generate one true sentence to break through writer's block. * Loads the last 500 words of the scene's content from the database and asks * Claude to write a single, precise sentence that continues the story naturally. * * @param projectId - (unused; class already scoped to projectId) * @param sceneId - The scene to continue * @param options - Optional generation configuration */ generateNextSentence(projectId: string, sceneId: number, options?: GenerationOptions): Promise; /** * Assemble all project data needed to generate synopsis, pitch, * query-letter, or comp-title content. * * Queries: projects, characters (protagonist + antagonist), * chapters (summaries), world_rules, narrative_promises. * * @param projectId - Project identifier (string form accepted by callers) */ assembleSynopsisContext(projectId: string): Promise; /** * Generate a synopsis of the specified length. * * @param projectId - Project identifier * @param length - 'short' (~150w), 'medium' (~400w), or 'long' (~800w) */ generateSynopsis(projectId: string, length: SynopsisLength): Promise; /** * Generate a 25-word elevator pitch using the "When…must…before" template. * * @param projectId - Project identifier */ generatePitch(projectId: string): Promise; /** * Generate a professional query letter ready for literary agent submission. * * @param projectId - Project identifier * @param compTitles - Optional list of comp titles provided by the author */ generateQueryLetter(projectId: string, compTitles?: string[]): Promise; /** * Suggest 5 comparative titles published 2020–2025 for the novel. * * @param projectId - Project identifier */ generateComps(projectId: string): Promise; /** * Workshop opening lines for the novel. * Loads project context (title, genre, protagonist, core conflict) via * `assembleSynopsisContext` when available, then asks Claude to generate * `count` distinct opening-line options. * * Each option: * - hooks the reader immediately * - establishes voice and tone * - hints at the central tension * - stands alone as a complete sentence * * @param projectId - Project identifier * @param count - Number of options to generate (default 5, max 10) */ workshopOpeningLines(projectId: string, count?: number): Promise; /** * Generate creative brainstorm ideas from an author prompt. * Returns 5 distinct, numbered ideas grounded in the project genre. * * @param prompt - The brainstorm prompt from the author * @param options - Optional generation configuration */ generateBrainstorm(prompt: string, options?: GenerationOptions): Promise; /** * Generate character name options with cultural context and meaning. * * @param opts - Options controlling culture, gender, count, and name type */ generateName(opts: { culture?: string; gender?: 'male' | 'female' | 'neutral'; count?: number; type?: 'first' | 'last' | 'full'; }): Promise; /** * Workshop a partial premise through structured development questions. * Guides the author through conflict, protagonist, stakes, story question, and uniqueness. * * @param projectId - Project identifier (unused in prompt but kept for API consistency) * @param partialPremise - The author's initial premise idea */ workshopPremise(projectId: string, partialPremise: string): Promise; /** * Generate a quick character sketch to capture an early idea. * Lightweight — name options, core trait, flaw, hidden depth, voice note, and story role. * * @param opts - Optional role, genre, and freeform notes */ generateCharacterSketch(opts?: { role?: string; genre?: string; notes?: string; }): Promise; } //# sourceMappingURL=generation-manager.d.ts.map