@forgespace/siza-gen 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,26 +1,22 @@
1
1
  # @forgespace/siza-gen
2
2
 
3
- Siza AI generation engine — multi-framework code generation,
4
- component registry, and ML-powered quality scoring.
3
+ Siza AI generation engine — multi-framework code generation, component registry,
4
+ and ML-powered quality scoring.
5
5
 
6
6
  ## Overview
7
7
 
8
8
  `@forgespace/siza-gen` is the AI brain extracted from
9
- [siza-mcp](https://github.com/Forge-Space/ui-mcp). It
10
- provides:
11
-
12
- - **Framework generators** — React, Vue, Angular, Svelte,
13
- HTML
14
- - **Component registry** — 502 curated snippets (357
15
- component + 85 animation + 60 backend)
16
- - **ML quality scoring** — Embeddings, quality validation,
17
- anti-generic rules
18
- - **Feedback system** — Self-learning, pattern promotion,
19
- feedback-boosted search
20
- - **Template compositions** — Pre-built page templates with
21
- quality gating
22
- - **Brand integration** — Transform branding-mcp tokens into
23
- design context
9
+ [siza-mcp](https://github.com/Forge-Space/ui-mcp). It provides:
10
+
11
+ - **Framework generators** — React, Vue, Angular, Svelte, HTML
12
+ - **Component registry** — 502 curated snippets (357 component + 85 animation +
13
+ 60 backend)
14
+ - **ML quality scoring** — Embeddings, quality validation, anti-generic rules
15
+ - **Feedback system** Self-learning, pattern promotion, feedback-boosted
16
+ search
17
+ - **Template compositions** — Pre-built page templates with quality gating
18
+ - **Brand integration** — Transform branding-mcp tokens into design context
19
+ - **LLM providers** — Ollama, OpenAI, Anthropic, Gemini with auto-fallback
24
20
 
25
21
  ## Installation
26
22
 
package/dist/index.d.ts CHANGED
@@ -3,6 +3,89 @@ import * as pino from 'pino';
3
3
  import pino__default, { Logger } from 'pino';
4
4
  import { z } from 'zod';
5
5
 
6
+ type LLMProviderType = 'ollama' | 'openai' | 'anthropic' | 'gemini';
7
+ interface ILLMConfig {
8
+ provider: LLMProviderType;
9
+ model: string;
10
+ baseUrl?: string;
11
+ apiKey?: string;
12
+ timeoutMs?: number;
13
+ maxTokens?: number;
14
+ temperature?: number;
15
+ }
16
+ interface ILLMGenerateOptions {
17
+ maxTokens?: number;
18
+ temperature?: number;
19
+ systemPrompt?: string;
20
+ timeoutMs?: number;
21
+ }
22
+ interface ILLMResponse {
23
+ text: string;
24
+ model: string;
25
+ provider: LLMProviderType;
26
+ tokensUsed?: number;
27
+ latencyMs: number;
28
+ }
29
+ interface ILLMProvider {
30
+ readonly type: LLMProviderType;
31
+ readonly model: string;
32
+ generate(prompt: string, options?: ILLMGenerateOptions): Promise<ILLMResponse>;
33
+ isAvailable(): Promise<boolean>;
34
+ }
35
+ declare const DEFAULT_TIMEOUT_MS = 30000;
36
+ declare const DEFAULT_MAX_TOKENS = 1024;
37
+ declare const DEFAULT_TEMPERATURE = 0.3;
38
+
39
+ declare class OllamaProvider implements ILLMProvider {
40
+ readonly type: "ollama";
41
+ readonly model: string;
42
+ private readonly baseUrl;
43
+ private readonly defaultTimeout;
44
+ constructor(opts?: {
45
+ model?: string;
46
+ baseUrl?: string;
47
+ timeoutMs?: number;
48
+ });
49
+ generate(prompt: string, options?: ILLMGenerateOptions): Promise<ILLMResponse>;
50
+ isAvailable(): Promise<boolean>;
51
+ }
52
+
53
+ declare class OpenAIProvider implements ILLMProvider {
54
+ readonly type: "openai";
55
+ readonly model: string;
56
+ private readonly baseUrl;
57
+ private readonly apiKey;
58
+ private readonly defaultTimeout;
59
+ constructor(opts: {
60
+ apiKey: string;
61
+ model?: string;
62
+ baseUrl?: string;
63
+ timeoutMs?: number;
64
+ });
65
+ generate(prompt: string, options?: ILLMGenerateOptions): Promise<ILLMResponse>;
66
+ isAvailable(): Promise<boolean>;
67
+ }
68
+
69
+ declare class AnthropicProvider implements ILLMProvider {
70
+ readonly type: "anthropic";
71
+ readonly model: string;
72
+ private readonly baseUrl;
73
+ private readonly apiKey;
74
+ private readonly defaultTimeout;
75
+ constructor(opts: {
76
+ apiKey: string;
77
+ model?: string;
78
+ baseUrl?: string;
79
+ timeoutMs?: number;
80
+ });
81
+ generate(prompt: string, options?: ILLMGenerateOptions): Promise<ILLMResponse>;
82
+ isAvailable(): Promise<boolean>;
83
+ }
84
+
85
+ declare function createProvider(config: ILLMConfig): ILLMProvider;
86
+ declare function detectOllama(baseUrl?: string): Promise<boolean>;
87
+ declare function createProviderWithFallback(config?: ILLMConfig): Promise<ILLMProvider | null>;
88
+
6
89
  /**
7
90
  * Type definitions for the ML subsystem.
8
91
  */
@@ -405,6 +488,9 @@ declare function getTrainingSummary(db: Database.Database): {
405
488
  *
406
489
  * Score range: 0-10 (0 = likely rejected, 10 = likely accepted).
407
490
  */
491
+
492
+ declare function setQualityScorerLLM(provider: ILLMProvider | null): void;
493
+ declare function getQualityScorerLLM(): ILLMProvider | null;
408
494
  /** Quality score result. */
409
495
  interface IQualityScore {
410
496
  /** Score from 0-10. */
@@ -452,6 +538,9 @@ declare function isLikelyAccepted(prompt: string, generatedCode: string, params?
452
538
  * 2. Expand vague terms into specific design tokens
453
539
  * 3. Inject best-practice hints based on component type
454
540
  */
541
+
542
+ declare function setPromptEnhancerLLM(provider: ILLMProvider | null): void;
543
+ declare function getPromptEnhancerLLM(): ILLMProvider | null;
455
544
  /** Enhancement result. */
456
545
  interface IEnhancedPrompt {
457
546
  /** The enhanced prompt text. */
@@ -2421,4 +2510,4 @@ declare function isNetworkError(error: unknown): boolean;
2421
2510
  */
2422
2511
  declare function retry<T>(fn: () => Promise<T>, maxAttempts?: number, delay?: number): Promise<T>;
2423
2512
 
2424
- export { ANIMATION_PRESETS, type AdapterType, AngularGenerator, type AppType, type Architecture, type ArtifactType, type BackendCategory, type BackendFramework, BaseGenerator, type BrandIdentityInput, COLOR_SYSTEMS, COMPONENT_LIBRARIES, type ComponentCategory, type ComponentLibrary, type ComponentLibraryId, type ComponentLibraryIntegration, type ComponentLibrarySetupOptions, type Config, DEFAULT_COLOR_SYSTEM, DEFAULT_CONTEXT, DEFAULT_DESIGN_CONTEXT, DEFAULT_FONT_PAIRING, DEFAULT_LORA_CONFIG, DEFAULT_PRESET, type DeployTarget, FONT_PAIRINGS, type Framework, GeneratorFactory, HtmlGenerator, type IAccessibilityIssue, type IAccessibilityReport, type IArtifactQuery, type IBackendSnippet, ICON_LIBRARIES, type ICodePattern, type IComponentLibrary, type IComponentQuery, type IComponentSnippet, type IComponentStructure, type IConfigFile, type IDesignAnalysisResult, type IDesignContext, type IDirectoryStructure, type IEmbedding, type IEmbeddingConfig, type IEnhancedPrompt, type IEnhancementContext, type IExplicitFeedbackInput, type IFeedback, type IFigmaDesignToken, type IFigmaVariable, type IGeneratedArtifact, type IGeneratedFile, type IGeneration, type IImageAnalysis, type IImplicitSignal, type ILearningStats, type ILoRAConfig, type IModelPaths, INSPIRATION_SOURCES, type IPatternMatch, type IPresetConfig, type IProjectTemplate, type IPromptClassification, type IQualityScore, type IScaffoldOptions, type IScrapedPage, type IScreenElement, type ISearchResult, type ISimilarityResult, type IStyleContext, type IStyleRecommendation, type ITailwindMapping, type ITemplateSelectionCriteria, type ITrainingExample, type ITrainingStatus, type ITransition, type IValidationResult, type ImageType, type IndustryTag, LAYOUT_PATTERNS, type ModelId, type MoodTag, PRESETS, type PageTemplateType, type ProjectType, ReactGenerator, SPACING_SYSTEM, type Scale, type StateManagement$1 as StateManagement, SvelteGenerator, TYPE_SCALE, type VisualStyleId, VueGenerator, applyVisualStyle, brandToDesignContext, buildPromptEnhancerData, buildQualityScorerData, buildStyleRecommenderData, cancelTrainingJob, capitalize, checkTrainingReadiness, classifyPromptPair, classifyPromptText, cleanJsxSyntax, clearAllMicroInteractions, clearCompositions, clearHistory as clearDiversityHistory, clearRegistry, clearSessionCache, closeDatabase, composePageFromTemplate, composeSection, configureEmbeddings, configureModelDir, convertPathForFramework, convertStyleObjectToString, cosineSimilarity, createEmbedding, createError, createLogger, createTrainingJob, customizeTemplate, deleteArtifact, deleteEmbeddings, designContextStore, embed, embedBatch, enhancePrompt, enhancePromptWithRAG, enhanceWithRules, ensureDirectories, ensurePatternsTable, escapeHtml, exportForAdapter, exportRawExamples, exportTrainingData, expressApiTemplate, extractDesignPatterns, extractSkeleton, feedbackBoostedSearch, findBestComposition, findSimilar, fingerprint, fullstackMonoTemplate, generateArtifactId, generateComponent, generateComponentFromLibrary, generateRandomId, getAdapterPath, getAggregateScore, getAllCompositions, getAllInteractions, getAllJobStatuses, getAllPacks, getAllSnippets, getAllTemplates, getAnimationsByCategory, getArtifact, getArtifactCount, getAvailableComponentLibraries, getAvailableComponentsForLibrary, getAvailablePatternsForLibrary, getAvailableTypes, getBaseDir, getBestMatch, getBestMatchWithFeedback, getByCategory, getByIndustry, getByMood, getColorSystem, getColorSystemsByMood, getComponentLibrariesForFramework, getComponentLibrary, getComposition, getConfig, getDatabase, getDefaultIconLibrary, getDiskUsage, getEmbedding, getEmbeddingConfig, getEmbeddingCount, getFallbackDesignReference, getFeedbackBoost, getFeedbackCount, getFeedbackStats, getFileExtension, getFileName, getFontPairing, getFontPairingsByMood, getInspirationByCategory, getInspirationByPriority, getInteractionsByCategory, getLatestJobStatus, getLayoutPattern, getLayoutPatternsByUseCase, getLearningStats, getMicroInteraction, getModelDownloadUrl, getModelPath, getModelPaths, getPack, getPatternStats, getPreset, getPrimaryDesignReference, getPromotablePatternsFromDb, getPromotionCandidates, getRecentArtifacts, getRecommendations, getRecommendedLibrary, getRegistrySize, getSimilarArtifacts, getSnippetById, getTemplate, getTopArtifacts, getTrainingDataPath, getTrainingSummary, getVariants, groupBy, hasEnoughData, hashSkeleton, htmlToJsxAttributes, includesCaseInsensitive, initializeBackendRegistry, initializeInteractions, initializeRegistry, injectAnimations, isAdapterAvailable, isArray, isDuplicateConsecutive, isFunction, isLikelyAccepted, isModelAvailable, isModelLoaded, isNetworkError, isNumber, isObject, isPromotable, isString, isTraining, isValidComponentName, isValidEmail, isValidHexColor, isValidProjectName, isValidUrl, jsxToHtml, jsxToHtmlAttributes, jsxToSvelte, listAdapters, listModels, listPresets, loadConfig, loadEmbeddings, logger, mergeStyles, needsEnhancement, nextAppTemplate, nextSaasTemplate, parseStyleString, pluralize, promotePattern, queryArtifacts, reactEventsToHtml, reactEventsToSvelte, reactSpaTemplate, recommendStyle, recordGeneration as recordDiversityGeneration, recordExplicitFeedback, recordGeneratedArtifact, recordGeneration$1 as recordGeneration, recordPattern, reduxToolkitPattern as reduxToolkitPatterns, registerComposition, registerInteraction, registerInteractions, registerPack, registerSnippet, registerSnippets, resetSchemaInit, retry, runPromotionCycle, safeJSONParse, sanitizeClassName, scoreQuality, scoreQualityWithRAG, searchBackendSnippets, searchComponents, searchPacks, selectTemplate, semanticSearch, setupComponentLibraryProject, sortBy, startTrainingJob, stateManagementPatterns, storeArtifact, storeDesignLearning, storeEmbedding, storeEmbeddings, suggestDiverseVariant, tanstackQueryPattern as tanstackQueryPatterns, templateList, templates, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, triggerPatternPromotion, truncate, unique, unloadModel, updateFeedbackScore, updateJobStatus, updateQualityScore, validateSnippet, validateSnippetStrict, writeJsonl, zustandPatterns };
2513
+ export { ANIMATION_PRESETS, type AdapterType, AngularGenerator, AnthropicProvider, type AppType, type Architecture, type ArtifactType, type BackendCategory, type BackendFramework, BaseGenerator, type BrandIdentityInput, COLOR_SYSTEMS, COMPONENT_LIBRARIES, type ComponentCategory, type ComponentLibrary, type ComponentLibraryId, type ComponentLibraryIntegration, type ComponentLibrarySetupOptions, type Config, DEFAULT_COLOR_SYSTEM, DEFAULT_CONTEXT, DEFAULT_DESIGN_CONTEXT, DEFAULT_FONT_PAIRING, DEFAULT_LORA_CONFIG, DEFAULT_MAX_TOKENS, DEFAULT_PRESET, DEFAULT_TEMPERATURE, DEFAULT_TIMEOUT_MS, type DeployTarget, FONT_PAIRINGS, type Framework, GeneratorFactory, HtmlGenerator, type IAccessibilityIssue, type IAccessibilityReport, type IArtifactQuery, type IBackendSnippet, ICON_LIBRARIES, type ICodePattern, type IComponentLibrary, type IComponentQuery, type IComponentSnippet, type IComponentStructure, type IConfigFile, type IDesignAnalysisResult, type IDesignContext, type IDirectoryStructure, type IEmbedding, type IEmbeddingConfig, type IEnhancedPrompt, type IEnhancementContext, type IExplicitFeedbackInput, type IFeedback, type IFigmaDesignToken, type IFigmaVariable, type IGeneratedArtifact, type IGeneratedFile, type IGeneration, type IImageAnalysis, type IImplicitSignal, type ILLMConfig, type ILLMGenerateOptions, type ILLMProvider, type ILLMResponse, type ILearningStats, type ILoRAConfig, type IModelPaths, INSPIRATION_SOURCES, type IPatternMatch, type IPresetConfig, type IProjectTemplate, type IPromptClassification, type IQualityScore, type IScaffoldOptions, type IScrapedPage, type IScreenElement, type ISearchResult, type ISimilarityResult, type IStyleContext, type IStyleRecommendation, type ITailwindMapping, type ITemplateSelectionCriteria, type ITrainingExample, type ITrainingStatus, type ITransition, type IValidationResult, type ImageType, type IndustryTag, LAYOUT_PATTERNS, type LLMProviderType, type ModelId, type MoodTag, OllamaProvider, OpenAIProvider, PRESETS, type PageTemplateType, type ProjectType, ReactGenerator, SPACING_SYSTEM, type Scale, type StateManagement$1 as StateManagement, SvelteGenerator, TYPE_SCALE, type VisualStyleId, VueGenerator, applyVisualStyle, brandToDesignContext, buildPromptEnhancerData, buildQualityScorerData, buildStyleRecommenderData, cancelTrainingJob, capitalize, checkTrainingReadiness, classifyPromptPair, classifyPromptText, cleanJsxSyntax, clearAllMicroInteractions, clearCompositions, clearHistory as clearDiversityHistory, clearRegistry, clearSessionCache, closeDatabase, composePageFromTemplate, composeSection, configureEmbeddings, configureModelDir, convertPathForFramework, convertStyleObjectToString, cosineSimilarity, createEmbedding, createError, createLogger, createProvider, createProviderWithFallback, createTrainingJob, customizeTemplate, deleteArtifact, deleteEmbeddings, designContextStore, detectOllama, embed, embedBatch, enhancePrompt, enhancePromptWithRAG, enhanceWithRules, ensureDirectories, ensurePatternsTable, escapeHtml, exportForAdapter, exportRawExamples, exportTrainingData, expressApiTemplate, extractDesignPatterns, extractSkeleton, feedbackBoostedSearch, findBestComposition, findSimilar, fingerprint, fullstackMonoTemplate, generateArtifactId, generateComponent, generateComponentFromLibrary, generateRandomId, getAdapterPath, getAggregateScore, getAllCompositions, getAllInteractions, getAllJobStatuses, getAllPacks, getAllSnippets, getAllTemplates, getAnimationsByCategory, getArtifact, getArtifactCount, getAvailableComponentLibraries, getAvailableComponentsForLibrary, getAvailablePatternsForLibrary, getAvailableTypes, getBaseDir, getBestMatch, getBestMatchWithFeedback, getByCategory, getByIndustry, getByMood, getColorSystem, getColorSystemsByMood, getComponentLibrariesForFramework, getComponentLibrary, getComposition, getConfig, getDatabase, getDefaultIconLibrary, getDiskUsage, getEmbedding, getEmbeddingConfig, getEmbeddingCount, getFallbackDesignReference, getFeedbackBoost, getFeedbackCount, getFeedbackStats, getFileExtension, getFileName, getFontPairing, getFontPairingsByMood, getInspirationByCategory, getInspirationByPriority, getInteractionsByCategory, getLatestJobStatus, getLayoutPattern, getLayoutPatternsByUseCase, getLearningStats, getMicroInteraction, getModelDownloadUrl, getModelPath, getModelPaths, getPack, getPatternStats, getPreset, getPrimaryDesignReference, getPromotablePatternsFromDb, getPromotionCandidates, getPromptEnhancerLLM, getQualityScorerLLM, getRecentArtifacts, getRecommendations, getRecommendedLibrary, getRegistrySize, getSimilarArtifacts, getSnippetById, getTemplate, getTopArtifacts, getTrainingDataPath, getTrainingSummary, getVariants, groupBy, hasEnoughData, hashSkeleton, htmlToJsxAttributes, includesCaseInsensitive, initializeBackendRegistry, initializeInteractions, initializeRegistry, injectAnimations, isAdapterAvailable, isArray, isDuplicateConsecutive, isFunction, isLikelyAccepted, isModelAvailable, isModelLoaded, isNetworkError, isNumber, isObject, isPromotable, isString, isTraining, isValidComponentName, isValidEmail, isValidHexColor, isValidProjectName, isValidUrl, jsxToHtml, jsxToHtmlAttributes, jsxToSvelte, listAdapters, listModels, listPresets, loadConfig, loadEmbeddings, logger, mergeStyles, needsEnhancement, nextAppTemplate, nextSaasTemplate, parseStyleString, pluralize, promotePattern, queryArtifacts, reactEventsToHtml, reactEventsToSvelte, reactSpaTemplate, recommendStyle, recordGeneration as recordDiversityGeneration, recordExplicitFeedback, recordGeneratedArtifact, recordGeneration$1 as recordGeneration, recordPattern, reduxToolkitPattern as reduxToolkitPatterns, registerComposition, registerInteraction, registerInteractions, registerPack, registerSnippet, registerSnippets, resetSchemaInit, retry, runPromotionCycle, safeJSONParse, sanitizeClassName, scoreQuality, scoreQualityWithRAG, searchBackendSnippets, searchComponents, searchPacks, selectTemplate, semanticSearch, setPromptEnhancerLLM, setQualityScorerLLM, setupComponentLibraryProject, sortBy, startTrainingJob, stateManagementPatterns, storeArtifact, storeDesignLearning, storeEmbedding, storeEmbeddings, suggestDiverseVariant, tanstackQueryPattern as tanstackQueryPatterns, templateList, templates, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, triggerPatternPromotion, truncate, unique, unloadModel, updateFeedbackScore, updateJobStatus, updateQualityScore, validateSnippet, validateSnippetStrict, writeJsonl, zustandPatterns };