diff --git a/packages/imajin-app/src/index.ts b/packages/imajin-app/src/index.ts deleted file mode 100644 index c8d95a26..00000000 --- a/packages/imajin-app/src/index.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * @lilith/imajin-app - * - * Core entry point for image generation: pipelines, parsing, configuration. - * Used by @lilith/imajin-react, @lilith/imajin-electron, and consumer apps. - */ - -// Config (ports, URLs) -export { - PORTS, - getPort, - getServiceUrls, - createServiceUrls, - DEFAULT_URLS, - type PortKey, - type ServiceUrls, -} from './config/index.js'; - -// Types -export type { - ImageModel, - PipelineConfig, - ParsedPrompt, - GeneratePromptsRequest, - GeneratePromptsResponse, -} from './types.js'; - -// Parsing utilities -export { - parseAssistantPrompts, - isValidPrompt, - normalizePrompt, -} from './parsing.js'; - -// Pipelines (re-export from submodule) -export { - PIPELINES, - SKELETON_PIPELINE, - ERROR_PAGES_PIPELINE, - getPipelineById, - getPipelineIds, - isValidPipelineId, -} from './pipelines/index.js'; - -// Prompts (re-export from submodule) -export { - SKELETON_SYSTEM_PROMPT, - SKELETON_STYLES, - buildSkeletonPromptGuidance, - ERROR_PAGES_SYSTEM_PROMPT, - ERROR_TYPE_GUIDANCE, - buildErrorPageGuidance, - type SkeletonStyle, - type ErrorType, -} from './prompts/index.js'; diff --git a/packages/imajin-app/src/parsing.ts b/packages/imajin-app/src/parsing.ts deleted file mode 100644 index 685fbb64..00000000 --- a/packages/imajin-app/src/parsing.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Parsing utilities for extracting prompts from LLM responses - */ - -import type { ParsedPrompt } from './types.js'; - -/** - * Parse LLM assistant response to extract prompt JSON objects - * - * Handles various JSON formats that may be embedded in natural language text. - * Extracts objects with name, prompt, and optional negativePrompt fields. - * - * @param response - Raw LLM response text - * @returns Array of parsed prompts - */ -export function parseAssistantPrompts(response: string): ParsedPrompt[] { - const prompts: ParsedPrompt[] = []; - - // Match JSON objects in the response - // This regex handles objects that may span multiple lines - const jsonRegex = /\{[\s\S]*?"name"[\s\S]*?"prompt"[\s\S]*?\}/g; - const matches = response.match(jsonRegex); - - if (!matches) { - return prompts; - } - - for (const match of matches) { - try { - const parsed = JSON.parse(match); - if (parsed.name && parsed.prompt) { - prompts.push({ - name: String(parsed.name), - prompt: String(parsed.prompt), - negativePrompt: parsed.negativePrompt ? String(parsed.negativePrompt) : '', - }); - } - } catch { - // Skip invalid JSON - common when LLM includes partial objects - continue; - } - } - - return prompts; -} - -/** - * Validate that a parsed prompt has all required fields - */ -export function isValidPrompt(prompt: unknown): prompt is ParsedPrompt { - if (!prompt || typeof prompt !== 'object') { - return false; - } - - const p = prompt as Record; - return ( - typeof p.name === 'string' && - p.name.length > 0 && - typeof p.prompt === 'string' && - p.prompt.length > 0 - ); -} - -/** - * Clean and normalize a prompt string - */ -export function normalizePrompt(prompt: string): string { - return prompt - .replace(/\s+/g, ' ') - .trim(); -} diff --git a/packages/imajin-app/src/types.ts b/packages/imajin-app/src/types.ts deleted file mode 100644 index 0b9e1711..00000000 --- a/packages/imajin-app/src/types.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Core types for imagen pipelines and prompts - */ - -/** Available image generation models */ -export type ImageModel = 'photorealistic' | 'anime'; - -/** Pipeline configuration for image generation */ -export interface PipelineConfig { - /** Unique pipeline identifier */ - id: string; - /** Display name */ - name: string; - /** Description of the pipeline purpose */ - description: string; - /** Category for image-generator API */ - category: string; - /** Model to use for generation */ - model: ImageModel; - /** Image families to generate */ - families: string[]; - /** System prompt for the LLM assistant */ - systemPrompt: string; - /** Example prompts to help users get started */ - examplePrompts: string[]; -} - -/** Parsed prompt from LLM response */ -export interface ParsedPrompt { - /** Prompt identifier/name */ - name: string; - /** Positive prompt for image generation */ - prompt: string; - /** Negative prompt (things to avoid) */ - negativePrompt: string; -} - -/** Request to generate prompts via imagegen-assistant */ -export interface GeneratePromptsRequest { - /** Pipeline ID to use */ - pipelineId: string; - /** User's input/request */ - userInput: string; - /** Optional context for the generation */ - context?: Record; -} - -/** Response from imagegen-assistant */ -export interface GeneratePromptsResponse { - /** Raw LLM response text */ - rawResponse: string; - /** Parsed prompts extracted from response */ - prompts: ParsedPrompt[]; - /** Model used for generation */ - model: string; - /** Time taken in milliseconds */ - durationMs: number; -}