Commit graph

443 commits

Author SHA1 Message Date
munimunigamer
d092bfecbb added providers with easy provider configurations 2026-02-02 21:52:20 -06:00
munimunigamer
efbb6830e1 fixed json for non-response models 2026-02-02 20:55:19 -06:00
Tony Frazier
9d86054d45 Remove unused jsonrepair module 2026-02-02 21:34:56 -05:00
Tony Frazier
4c5d590cf6 Add extractJsonMiddleware to generate and streamStructured 2026-02-02 20:36:48 -05:00
munimunigamer
bf96aa5793 removed suggestsions folder 2026-02-02 00:53:22 -06:00
munimunigamer
16c289ef9e refactor(01.1-01): remove JSON format instructions from wizard.ts templates
Cleaned 10 templates:
- settingExpansionPromptTemplate: Removed JSON schema block
- settingRefinementPromptTemplate: Removed JSON schema block and 'Return...JSON format' instruction
- protagonistGenerationPromptTemplate: Removed JSON schema block
- characterElaborationPromptTemplate: Removed JSON schema block
- characterRefinementPromptTemplate: Removed JSON schema block and 'Return...JSON format' instruction
- supportingCharactersPromptTemplate: Removed JSON array schema block
- openingRefinementAdventurePromptTemplate: Removed 'Return...JSON format' instruction
- openingRefinementCreativePromptTemplate: Removed 'Return...JSON format' instruction
- characterCardImportPromptTemplate: Removed OUTPUT FORMAT section with JSON schema and 'Output valid JSON only' instruction
- vaultCharacterImportPromptTemplate: Removed OUTPUT FORMAT section with JSON schema and 'Output valid JSON only' instruction

All semantic guidance (semantic task descriptions, field guidelines, category definitions) preserved. Structured output now enforced solely via Zod schemas in SDK.
2026-02-02 00:42:58 -06:00
munimunigamer
e637104177 refactor(01.1-02): remove JSON format instructions from translation.ts templates
- Removed "Respond with a JSON array in the same format" from translateUITemplate
- Removed "Respond with a JSON array in the same format" from translateSuggestionsTemplate
- Removed "Respond with a JSON array in the same format" from translateActionChoicesTemplate
- Preserved all translation rules (what to translate, what to keep unchanged)
- Plain text templates (narration, input, wizard) already use generatePlainText, untouched
2026-02-02 00:42:42 -06:00
munimunigamer
47bc5ec92f refactor(01.1-01): remove JSON format instructions from analysis.ts templates
- Removed 'Respond with valid JSON only' from styleReviewerPromptTemplate content
- Removed JSON format example block from styleReviewerPromptTemplate userContent
- Removed 'Respond only with the JSON array' from lorebookClassifierPromptTemplate content
- Removed JSON format example from lorebookClassifierPromptTemplate userContent

Semantic task descriptions and category definitions preserved. Structured output now enforced solely via Zod schemas in SDK.
2026-02-02 00:40:28 -06:00
munimunigamer
3c87e3b4a4 fix(01): add missing context placeholders (translatedNarrativeBlock, char, user) 2026-02-01 23:30:21 -06:00
munimunigamer
2713ed6a95 refactor(01-02): update templates/index.ts and reduce definitions.ts to facade
- templates/index.ts now combines ALL templates (39 total):
  - storyTemplates (2): adventure, creative-writing
  - analysisTemplates (4): classifier, style-reviewer, lorebook-classifier, tier3
  - memoryTemplates (6): chapter-analysis, summarization, retrieval, lore-mgmt
  - SUGGESTIONS_TEMPLATES (1): preserved from existing migration
  - generationTemplates (3): action-choices, timeline-fill
  - wizardTemplates (12): setting, character, opening templates
  - translationTemplates (6): narration, input, UI translations
  - imageTemplates (6): style presets, prompt analysis, portrait

- definitions.ts reduced from ~2,049 lines to 70 lines
- Re-exports macros from ./definitions/macros/
- Re-exports templates from ./templates/
- Helper functions preserved: getMacroByToken, getTemplateById, etc.
- Public API unchanged for backward compatibility
2026-02-01 22:56:46 -06:00
munimunigamer
9eeba92cb2 feat(01-02): create modular template files by domain
Split ~40 templates from definitions.ts into 7 domain-specific files:
- narrative.ts: adventure, creative-writing story templates (2)
- analysis.ts: classifier, style-reviewer, lorebook-classifier, tier3 templates (4)
- memory.ts: chapter-analysis, summarization, retrieval, lore-management (6)
- generation.ts: action-choices, timeline-fill templates (3)
- wizard.ts: setting, character, opening generation templates (12)
- translation.ts: narration, input, UI translation templates (6)
- image.ts: style presets and image prompt analysis templates (6)

Each file exports individual templates and a combined array for registration.
Suggestions template preserved in existing location.
2026-02-01 22:55:16 -06:00
munimunigamer
d9b4c1cbc5 feat(01-03): add template validation to PromptService.init()
- Add validateTemplateReferences() to check templates against BUILTIN_MACROS and CONTEXT_PLACEHOLDERS
- Add validateAllTemplates() that validates all templates on init, failing fast with clear errors
- Call validation at start of init() before registering custom macros
- Error messages include template ID and list of unknown tokens
2026-02-01 22:47:46 -06:00
munimunigamer
24350802da refactor(01-01): update definitions.ts as facade importing from modular macros
- definitions.ts now imports BUILTIN_MACROS, CONTEXT_PLACEHOLDERS from ./definitions/macros
- Re-exports macros for backward compatibility
- Removes inline macro definitions (~800 lines removed)
- Keeps all template definitions in place (for Plan 02)
- definitions/index.ts now exports macros and re-exports templates
2026-02-01 22:42:59 -06:00
munimunigamer
5b4b6b9ef4 feat(01-01): create modular macro system with domain files
- Split 18 macros into 4 domain files:
  - core.ts: 5 basic story context macros
  - context.ts: 3 story context building blocks
  - narrative.ts: 3 POV/tense-aware complex macros
  - features.ts: 7 feature-specific macros
- Move CONTEXT_PLACEHOLDERS to placeholders.ts
- Create index.ts that exports BUILTIN_MACROS via spread
2026-02-01 22:41:01 -06:00
munimunigamer
070c8e9cbc chore(01-01): clean up existing partial migration files
- Replace definitions/index.ts with placeholder for macro exports
- Preserve templates/ structure for Plan 02 extension
2026-02-01 22:37:09 -06:00
munimunigamer
ca504fad8e implemented final sdk migrations 2026-02-01 17:57:21 -06:00
munimunigamer
9723dff31b fixed loading states 2026-02-01 16:52:59 -06:00
munimunigamer
1418226061 removed actioninputorchestrator (kinda too muhc splitting) 2026-02-01 16:04:06 -06:00
munimunigamer
fe1b32095a feat: [US-012] - Final cleanup and verification
- Reduce ActionInput.svelte from 1521 to 689 lines (55% reduction)
- Create ActionInputOrchestrator.ts for reusable helpers (suggestions, translation)
- Remove unused imports and consolidate builder functions
- All extracted services properly export types from index.ts
- Typecheck passes (only pre-existing errors remain)
- ActionInput is now pure UI code with business logic in services
2026-02-01 12:56:37 -06:00
munimunigamer
8b6b9426ec feat: [US-011] - Wire up PipelineEventHandler in ActionInput 2026-02-01 12:42:11 -06:00
munimunigamer
c28dcca343 feat: [US-010] - Create PipelineEventHandler for UI event mapping 2026-02-01 12:33:15 -06:00
munimunigamer
3b1d53de26 feat: [US-009] - Wire up SuggestionsRefreshService in ActionInput 2026-02-01 12:29:22 -06:00
munimunigamer
94eafb4896 feat: [US-008] - Create SuggestionsRefreshService for manual suggestion refresh 2026-02-01 12:26:31 -06:00
munimunigamer
388d20b28f feat: [US-007] - Wire up WorldStateTranslationService in ActionInput
- Import WorldStateTranslationService from generation module
- Add buildWorldStateTranslationDependencies() helper
- Add buildWorldStateTranslationCallbacks() helper
- Replace inline translateWorldStateElements() call with service
- Remove 65-line translateWorldStateElements() function
- Remove unused hasDescriptors/descriptorsToString imports
- Net reduction: 30 lines
2026-02-01 12:21:36 -06:00
munimunigamer
5501afdec2 feat: [US-006] - Create WorldStateTranslationService for entity translation
- Create src/lib/services/generation/WorldStateTranslationService.ts (127 lines)
- Extract translateWorldStateElements() logic from ActionInput.svelte
- Service accepts WorldStateTranslationDependencies interface (AI translate method)
- WorldStateTranslationCallbacks interface for DB update callbacks
- translateEntities() method handles characters, locations, items, storyBeats
- Export from src/lib/services/generation/index.ts
2026-02-01 12:18:05 -06:00
munimunigamer
d94cab4777 feat: [US-005] - Wire up BackgroundTaskCoordinator in ActionInput
- Import BackgroundTaskCoordinator and related types
- Add buildBackgroundTaskDependencies() helper function
- Add buildBackgroundTaskInput() helper function to build coordinator input
- Replace inline checkAutoSummarize() and checkStyleReview() calls with coordinator.runBackgroundTasks()
- Remove checkAutoSummarize(), runLoreManagement(), checkStyleReview() functions from ActionInput
- Remove unused Chapter type import
- Update ChapterServiceDependencies to use proper StoryMode/POV/Tense types
- ActionInput reduced by 132 lines (1734 -> 1602 lines)
2026-02-01 12:13:04 -06:00
munimunigamer
2330804236 feat: [US-004] - Create BackgroundTaskCoordinator for post-response task orchestration 2026-02-01 12:06:40 -06:00
munimunigamer
45b9cbc3be feat: [US-003] - Create StyleReviewScheduler for style review timing 2026-02-01 12:04:13 -06:00
munimunigamer
3d6719de9a feat: [US-002] - Create LoreManagementCoordinator for lore management orchestration 2026-02-01 12:00:46 -06:00
munimunigamer
fff965a34b feat: [US-001] - Create ChapterService for chapter creation logic
- Create src/lib/services/generation/ChapterService.ts (141 lines)
- Extract checkAutoSummarize() logic from ActionInput.svelte
- Add checkAndCreateChapter() method returning ChapterCreationResult
- ChapterServiceDependencies interface for injected AI/DB methods
- Service does NOT import Svelte stores - uses injected dependencies
- Export from src/lib/services/generation/index.ts
2026-02-01 11:57:42 -06:00
munimunigamer
5b697903e5 fix: image inline generation cleaned up 2026-02-01 10:56:32 -06:00
munimunigamer
c00db31e24 fix: Set currentStory in createStoryFromWizard and add missing imageAnalysis preset assignment 2026-02-01 01:37:09 -06:00
munimunigamer
2cb73e16af Merge branch 'vercel-ai-sdk' of github-aventura:unkarelian/Aventura into vercel-ai-sdk 2026-02-01 01:19:33 -06:00
munimunigamer
c1b674da53 feat: [US-016] - Extract ExportCoordinationService
Extract export data gathering logic from Header.svelte into a dedicated
coordination service. The service gathers all story data in parallel:
entries, characters, locations, items, story beats, lorebook entries,
embedded images, checkpoints, branches, and chapters.

ExportCoordinationService is 81 lines. Header.svelte now delegates to
gatherStoryData() instead of inline Promise.all calls.
2026-02-01 00:56:31 -06:00
munimunigamer
373938bac9 feat: [US-015] - Extract ImageEmbeddingService
Extract image embedding/processing logic from StoryEntry.svelte into
a dedicated service. Provides four functions for processing narrative
content with embedded images:

- processContentWithImages: Standard regex-based marker system
- processVisualProseWithImages: HTML sanitization with image injection
- processContentWithInlineImages: <pic> tag replacement
- processVisualProseWithInlineImages: Combined Visual Prose + inline
2026-02-01 00:51:11 -06:00
munimunigamer
decf23facb feat: [US-014] - Extract LorebookImportService 2026-02-01 00:45:18 -06:00
munimunigamer
9d30a03b49 feat: [US-013] - Extract RetryService from ActionInput
- Created RetryService.ts (236 lines) for retry/stop/restore operations
- Service handles full state restore (in-memory backup with snapshots)
- Service handles persistent restore (ID-based cleanup for cross-session retry)
- Uses callback pattern to avoid direct store imports
- ActionInput.svelte delegates to retryService.handleStopGeneration()
  and retryService.handleRetryLastMessage()
- ActionInput.svelte reduced from 1765 to 1702 lines (63 lines less)
2026-02-01 00:39:34 -06:00
munimunigamer
9b718bb09b feat: [US-012] - Update ActionInput.svelte to use GenerationPipeline
- Refactored ActionInput.svelte to delegate generation orchestration to GenerationPipeline
- Replaced inline retrieval/narrative/classification/translation/image/post phases with pipeline
- Added buildPipelineDependencies() helper to wire AIService methods to pipeline
- Added handlePipelineEvent() for processing pipeline events and updating UI state
- Extracted translateWorldStateElements() as a helper function
- Fixed PostGenerationPhase to use activeThreads: StoryBeat[] instead of pendingQuests: string[]
- Fixed WorldState.currentLocation type to be Location | undefined
- Made lorebookEntries optional in restoreFromRetryBackup parameter

Note: ActionInput.svelte is now 1765 lines (down from ~2288). Further reduction requires
extracting RetryService (US-013) and potentially other services.
2026-02-01 00:34:20 -06:00
munimunigamer
27300419ba feat: [US-011] - Create GenerationPipeline orchestrator
Thin orchestrator that coordinates all generation phases in order:
pre → retrieval → narrative → classification → translation → image → post

- Aggregates all phase dependencies into PipelineDependencies interface
- Runs phases sequentially, yielding all events for UI updates
- Handles abort signals and fatal errors
- Returns comprehensive PipelineResult with all phase results
2026-02-01 00:23:26 -06:00
munimunigamer
4836723254 feat: [US-010] - Create PostGenerationPhase service 2026-02-01 00:18:23 -06:00
Kurvaz
d0397a9be9 Migrate translation service to vercel sdk 2026-01-31 23:16:02 -07:00
munimunigamer
6cd58bd7ce feat: [US-009] - Create ImagePhase service
Add ImagePhase service for coordinating image generation in the pipeline:
- Check if image generation is enabled and auto-generate is on
- Call aiService.generateImagesForNarrative() for both inline and analyzed modes
- Support skip reasons: disabled, auto_generate_off, not_configured, aborted
- Handle errors gracefully (non-fatal)
2026-02-01 00:13:29 -06:00
munimunigamer
3ba9867e8a feat: [US-008] - Create TranslationPhase service
Adds TranslationPhase service for handling narration translation.
- Checks if translation is enabled via TranslationService.shouldTranslateNarration()
- Gracefully handles translation stub errors (non-fatal)
- Yields phase_start and phase_complete events
- Returns TranslationResult2 with translated content or null on skip/error
2026-02-01 00:09:11 -06:00
munimunigamer
140459a85e feat: [US-007] - Create ClassificationPhase service
Extract world state classification logic into a dedicated phase service
that coordinates entity updates (characters, locations, items, story
beats) via dependency injection.
2026-02-01 00:05:41 -06:00
munimunigamer
f1dc4a47be feat: [US-006] - Create NarrativePhase service 2026-02-01 00:02:47 -06:00
munimunigamer
038b38d19d feat: [US-005] - Create RetrievalPhase service
Extract memory and lorebook retrieval logic into dedicated phase service.
Coordinates timeline fill or agentic retrieval based on settings, and
runs lorebook entry retrieval (tiered injection) in parallel.
2026-01-31 23:59:24 -06:00
munimunigamer
1238920937 feat: [US-004] - Create PreGenerationPhase service
Add PreGenerationPhase service to handle pre-generation setup:
- Prepare retry state backup data for restore capability
- Capture time tracking context in backup
- Yield phase_start and phase_complete events

Files added:
- src/lib/services/generation/phases/PreGenerationPhase.ts (113 lines)
- src/lib/services/generation/phases/index.ts

The phase prepares RetryBackupData that the caller applies via
ui.createRetryBackup(), maintaining separation from UI store.
2026-01-31 23:54:52 -06:00
munimunigamer
63801f91d4 feat: [US-003] - Create generation service types and directory structure 2026-01-31 23:51:13 -06:00
munimunigamer
801e0a1af4 feat: [US-002] - Add scenario schema to index
Export scenario schema from the central schema registry to ensure
all schema files are properly accessible.
2026-01-31 23:47:42 -06:00
munimunigamer
1b8b99eb0b feat: [US-001] - Remove provider-specific routing code
Remove OpenRouter-specific provider routing code. Users can now use
the manual body JSON feature for any provider-specific options like
{ "provider": { "order": ["openai"] } }.

Changes:
- Delete providers.ts (DEFAULT_PROVIDERS list)
- Delete ProviderOnlySelector.svelte component
- Remove providerOnly from GenerationPreset and related types
- Remove providerOnly from apiSettings and all service settings
- Remove provider routing code from generate.ts
- Remove providerOnly handling from requestOverrides.ts
- Update all components to remove providerOptions prop chain
- Update prompt export/import to exclude providerOnly
2026-01-31 23:45:39 -06:00