@mixio-pro/kalaasetu-mcp 1.2.2 → 2.0.1-beta

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.
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Prompt Enhancer Utility
3
+ *
4
+ * A fluent builder pattern for constructing prompt enhancers that can be
5
+ * applied to improve prompts for image and video generation models.
6
+ */
7
+
8
+ /**
9
+ * Configuration interface for a prompt enhancer.
10
+ */
11
+ export interface PromptEnhancerConfig {
12
+ /** Added before the user prompt */
13
+ prefix?: string;
14
+ /** Added after the user prompt */
15
+ suffix?: string;
16
+ /** Style/quality modifiers (e.g., "cinematic, 8k, hyperdetailed") */
17
+ styleGuide?: string;
18
+ /** Elements to avoid (used where supported as negative_prompt) */
19
+ negativeElements?: string;
20
+ /** How to join parts (default: " ") */
21
+ separator?: string;
22
+ /**
23
+ * Template to wrap the entire result. Use "{prompt}" as placeholder.
24
+ * Example: "A cinematic shot of {prompt}, dramatic lighting"
25
+ */
26
+ wrapTemplate?: string;
27
+ }
28
+
29
+ /**
30
+ * Fluent builder for constructing PromptEnhancer instances.
31
+ */
32
+ export class PromptEnhancerBuilder {
33
+ private config: PromptEnhancerConfig = {};
34
+
35
+ /**
36
+ * Add text before the user's prompt.
37
+ * Useful for establishing shot type or scene context.
38
+ */
39
+ withPrefix(text: string): this {
40
+ this.config.prefix = text;
41
+ return this;
42
+ }
43
+
44
+ /**
45
+ * Add text after the user's prompt.
46
+ * Useful for technical specifications or quality modifiers.
47
+ */
48
+ withSuffix(text: string): this {
49
+ this.config.suffix = text;
50
+ return this;
51
+ }
52
+
53
+ /**
54
+ * Add style guide modifiers that get appended.
55
+ * Examples: "cinematic, film grain, dramatic lighting"
56
+ */
57
+ withStyleGuide(styles: string): this {
58
+ this.config.styleGuide = styles;
59
+ return this;
60
+ }
61
+
62
+ /**
63
+ * Set negative elements to avoid in generation.
64
+ * Used as negative_prompt where supported.
65
+ */
66
+ withNegativeElements(elements: string): this {
67
+ this.config.negativeElements = elements;
68
+ return this;
69
+ }
70
+
71
+ /**
72
+ * Set the separator between prompt parts.
73
+ * Default is a single space " ".
74
+ */
75
+ withSeparator(sep: string): this {
76
+ this.config.separator = sep;
77
+ return this;
78
+ }
79
+
80
+ /**
81
+ * Set a template that wraps the entire enhanced prompt.
82
+ * Use "{prompt}" as placeholder for the combined prompt content.
83
+ */
84
+ withTemplate(template: string): this {
85
+ this.config.wrapTemplate = template;
86
+ return this;
87
+ }
88
+
89
+ /**
90
+ * Build the final PromptEnhancer instance.
91
+ */
92
+ build(): PromptEnhancer {
93
+ return PromptEnhancer.fromConfig({ ...this.config });
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Main prompt enhancer class.
99
+ * Applies configured transformations to improve prompts for AI generation.
100
+ */
101
+ export class PromptEnhancer {
102
+ private config: PromptEnhancerConfig;
103
+
104
+ private constructor(config: PromptEnhancerConfig) {
105
+ this.config = config;
106
+ }
107
+
108
+ /**
109
+ * Create a new fluent builder instance.
110
+ */
111
+ static builder(): PromptEnhancerBuilder {
112
+ return new PromptEnhancerBuilder();
113
+ }
114
+
115
+ /**
116
+ * Create a PromptEnhancer directly from a config object.
117
+ */
118
+ static fromConfig(config: PromptEnhancerConfig): PromptEnhancer {
119
+ return new PromptEnhancer({ ...config });
120
+ }
121
+
122
+ /**
123
+ * A no-op enhancer that returns prompts unchanged.
124
+ */
125
+ static readonly PASSTHROUGH = new PromptEnhancer({});
126
+
127
+ /**
128
+ * Enhance a prompt by applying all configured transformations.
129
+ *
130
+ * Order of operations:
131
+ * 1. Combine: prefix + prompt + suffix + styleGuide
132
+ * 2. Apply wrapTemplate if set
133
+ */
134
+ enhance(prompt: string): string {
135
+ const separator = this.config.separator ?? " ";
136
+ const parts: string[] = [];
137
+
138
+ if (this.config.prefix) {
139
+ parts.push(this.config.prefix);
140
+ }
141
+
142
+ parts.push(prompt);
143
+
144
+ if (this.config.suffix) {
145
+ parts.push(this.config.suffix);
146
+ }
147
+
148
+ if (this.config.styleGuide) {
149
+ parts.push(this.config.styleGuide);
150
+ }
151
+
152
+ let result = parts.join(separator);
153
+
154
+ if (this.config.wrapTemplate) {
155
+ result = this.config.wrapTemplate.replace("{prompt}", result);
156
+ }
157
+
158
+ return result;
159
+ }
160
+
161
+ /**
162
+ * Get the negative elements (for use as negative_prompt).
163
+ */
164
+ getNegativeElements(): string | undefined {
165
+ return this.config.negativeElements;
166
+ }
167
+
168
+ /**
169
+ * Check if this enhancer has any transformations configured.
170
+ */
171
+ hasTransformations(): boolean {
172
+ return !!(
173
+ this.config.prefix ||
174
+ this.config.suffix ||
175
+ this.config.styleGuide ||
176
+ this.config.wrapTemplate
177
+ );
178
+ }
179
+
180
+ /**
181
+ * Export the enhancer's configuration.
182
+ */
183
+ toConfig(): PromptEnhancerConfig {
184
+ return { ...this.config };
185
+ }
186
+ }