prompts.chat 0.0.1 → 0.0.3

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.
Files changed (46) hide show
  1. package/README.md +856 -0
  2. package/dist/builder/index.d.mts +1067 -0
  3. package/dist/builder/index.d.ts +1067 -0
  4. package/dist/builder/index.js +2471 -0
  5. package/dist/builder/index.js.map +1 -0
  6. package/dist/builder/index.mjs +2432 -0
  7. package/dist/builder/index.mjs.map +1 -0
  8. package/dist/index-BEIO8LCd.d.mts +61 -0
  9. package/dist/index-BEIO8LCd.d.ts +61 -0
  10. package/dist/index-CSHEKYfQ.d.mts +64 -0
  11. package/dist/index-CSHEKYfQ.d.ts +64 -0
  12. package/dist/index-D41E6D9X.d.mts +77 -0
  13. package/dist/index-D41E6D9X.d.ts +77 -0
  14. package/dist/index-DOz8zcA0.d.mts +68 -0
  15. package/dist/index-DOz8zcA0.d.ts +68 -0
  16. package/dist/index.d.mts +5 -0
  17. package/dist/index.d.ts +5 -0
  18. package/dist/index.js +3335 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/index.mjs +3276 -0
  21. package/dist/index.mjs.map +1 -0
  22. package/dist/parser/index.d.mts +1 -0
  23. package/dist/parser/index.d.ts +1 -0
  24. package/dist/parser/index.js +288 -0
  25. package/dist/parser/index.js.map +1 -0
  26. package/dist/parser/index.mjs +259 -0
  27. package/dist/parser/index.mjs.map +1 -0
  28. package/dist/quality/index.d.mts +1 -0
  29. package/dist/quality/index.d.ts +1 -0
  30. package/dist/quality/index.js +212 -0
  31. package/dist/quality/index.js.map +1 -0
  32. package/dist/quality/index.mjs +184 -0
  33. package/dist/quality/index.mjs.map +1 -0
  34. package/dist/similarity/index.d.mts +1 -0
  35. package/dist/similarity/index.d.ts +1 -0
  36. package/dist/similarity/index.js +123 -0
  37. package/dist/similarity/index.js.map +1 -0
  38. package/dist/similarity/index.mjs +91 -0
  39. package/dist/similarity/index.mjs.map +1 -0
  40. package/dist/variables/index.d.mts +1 -0
  41. package/dist/variables/index.d.ts +1 -0
  42. package/dist/variables/index.js +306 -0
  43. package/dist/variables/index.js.map +1 -0
  44. package/dist/variables/index.mjs +274 -0
  45. package/dist/variables/index.mjs.map +1 -0
  46. package/package.json +77 -6
@@ -0,0 +1,2471 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/builder/index.ts
21
+ var builder_exports = {};
22
+ __export(builder_exports, {
23
+ AudioPromptBuilder: () => AudioPromptBuilder,
24
+ ChatPromptBuilder: () => ChatPromptBuilder,
25
+ ImagePromptBuilder: () => ImagePromptBuilder,
26
+ PromptBuilder: () => PromptBuilder,
27
+ VideoPromptBuilder: () => VideoPromptBuilder,
28
+ audio: () => audio,
29
+ builder: () => builder,
30
+ chat: () => chat,
31
+ chatPresets: () => chatPresets,
32
+ fromPrompt: () => fromPrompt,
33
+ image: () => image,
34
+ templates: () => templates,
35
+ video: () => video
36
+ });
37
+ module.exports = __toCommonJS(builder_exports);
38
+
39
+ // src/builder/media.ts
40
+ var ImagePromptBuilder = class {
41
+ constructor() {
42
+ this._negative = [];
43
+ this._custom = [];
44
+ }
45
+ // --- Subject Methods ---
46
+ subject(main) {
47
+ if (typeof main === "string") {
48
+ this._subject = { ...this._subject || {}, main };
49
+ } else {
50
+ this._subject = { ...this._subject || {}, ...main };
51
+ }
52
+ return this;
53
+ }
54
+ subjectDetails(details) {
55
+ this._subject = { ...this._subject || { main: "" }, details };
56
+ return this;
57
+ }
58
+ expression(expression) {
59
+ this._subject = { ...this._subject || { main: "" }, expression };
60
+ return this;
61
+ }
62
+ pose(pose) {
63
+ this._subject = { ...this._subject || { main: "" }, pose };
64
+ return this;
65
+ }
66
+ action(action) {
67
+ this._subject = { ...this._subject || { main: "" }, action };
68
+ return this;
69
+ }
70
+ clothing(clothing) {
71
+ this._subject = { ...this._subject || { main: "" }, clothing };
72
+ return this;
73
+ }
74
+ accessories(accessories) {
75
+ this._subject = { ...this._subject || { main: "" }, accessories };
76
+ return this;
77
+ }
78
+ subjectCount(count) {
79
+ this._subject = { ...this._subject || { main: "" }, count };
80
+ return this;
81
+ }
82
+ // --- Camera Methods ---
83
+ camera(settings) {
84
+ this._camera = { ...this._camera || {}, ...settings };
85
+ return this;
86
+ }
87
+ angle(angle) {
88
+ this._camera = { ...this._camera || {}, angle };
89
+ return this;
90
+ }
91
+ shot(shot) {
92
+ this._camera = { ...this._camera || {}, shot };
93
+ return this;
94
+ }
95
+ lens(lens) {
96
+ this._camera = { ...this._camera || {}, lens };
97
+ return this;
98
+ }
99
+ focus(focus) {
100
+ this._camera = { ...this._camera || {}, focus };
101
+ return this;
102
+ }
103
+ aperture(aperture) {
104
+ this._camera = { ...this._camera || {}, aperture };
105
+ return this;
106
+ }
107
+ filmStock(filmStock) {
108
+ this._camera = { ...this._camera || {}, filmStock };
109
+ return this;
110
+ }
111
+ filmFormat(format) {
112
+ this._camera = { ...this._camera || {}, filmFormat: format };
113
+ return this;
114
+ }
115
+ cameraBrand(brand) {
116
+ this._camera = { ...this._camera || {}, brand };
117
+ return this;
118
+ }
119
+ cameraModel(model) {
120
+ this._camera = { ...this._camera || {}, model };
121
+ return this;
122
+ }
123
+ sensor(sensor) {
124
+ this._camera = { ...this._camera || {}, sensor };
125
+ return this;
126
+ }
127
+ lensModel(model) {
128
+ this._camera = { ...this._camera || {}, lensModel: model };
129
+ return this;
130
+ }
131
+ lensBrand(brand) {
132
+ this._camera = { ...this._camera || {}, lensBrand: brand };
133
+ return this;
134
+ }
135
+ focalLength(length) {
136
+ this._camera = { ...this._camera || {}, focalLength: length };
137
+ return this;
138
+ }
139
+ bokeh(style) {
140
+ this._camera = { ...this._camera || {}, bokeh: style };
141
+ return this;
142
+ }
143
+ filter(filter) {
144
+ this._camera = { ...this._camera || {}, filter };
145
+ return this;
146
+ }
147
+ iso(iso) {
148
+ this._camera = { ...this._camera || {}, iso };
149
+ return this;
150
+ }
151
+ shutterSpeed(speed) {
152
+ this._camera = { ...this._camera || {}, shutterSpeed: speed };
153
+ return this;
154
+ }
155
+ whiteBalance(wb) {
156
+ this._camera = { ...this._camera || {}, whiteBalance: wb };
157
+ return this;
158
+ }
159
+ colorProfile(profile) {
160
+ this._camera = { ...this._camera || {}, colorProfile: profile };
161
+ return this;
162
+ }
163
+ // --- Lighting Methods ---
164
+ lighting(settings) {
165
+ this._lighting = { ...this._lighting || {}, ...settings };
166
+ return this;
167
+ }
168
+ lightingType(type) {
169
+ this._lighting = { ...this._lighting || {}, type };
170
+ return this;
171
+ }
172
+ timeOfDay(time) {
173
+ this._lighting = { ...this._lighting || {}, time };
174
+ return this;
175
+ }
176
+ weather(weather) {
177
+ this._lighting = { ...this._lighting || {}, weather };
178
+ return this;
179
+ }
180
+ lightDirection(direction) {
181
+ this._lighting = { ...this._lighting || {}, direction };
182
+ return this;
183
+ }
184
+ lightIntensity(intensity) {
185
+ this._lighting = { ...this._lighting || {}, intensity };
186
+ return this;
187
+ }
188
+ // --- Composition Methods ---
189
+ composition(settings) {
190
+ this._composition = { ...this._composition || {}, ...settings };
191
+ return this;
192
+ }
193
+ ruleOfThirds() {
194
+ this._composition = { ...this._composition || {}, ruleOfThirds: true };
195
+ return this;
196
+ }
197
+ goldenRatio() {
198
+ this._composition = { ...this._composition || {}, goldenRatio: true };
199
+ return this;
200
+ }
201
+ symmetry(type) {
202
+ this._composition = { ...this._composition || {}, symmetry: type };
203
+ return this;
204
+ }
205
+ foreground(fg) {
206
+ this._composition = { ...this._composition || {}, foreground: fg };
207
+ return this;
208
+ }
209
+ midground(mg) {
210
+ this._composition = { ...this._composition || {}, midground: mg };
211
+ return this;
212
+ }
213
+ background(bg) {
214
+ this._composition = { ...this._composition || {}, background: bg };
215
+ return this;
216
+ }
217
+ // --- Environment Methods ---
218
+ environment(setting) {
219
+ if (typeof setting === "string") {
220
+ this._environment = { ...this._environment || { setting: "" }, setting };
221
+ } else {
222
+ this._environment = { ...this._environment || { setting: "" }, ...setting };
223
+ }
224
+ return this;
225
+ }
226
+ location(location) {
227
+ this._environment = { ...this._environment || { setting: "" }, location };
228
+ return this;
229
+ }
230
+ props(props) {
231
+ this._environment = { ...this._environment || { setting: "" }, props };
232
+ return this;
233
+ }
234
+ atmosphere(atmosphere) {
235
+ this._environment = { ...this._environment || { setting: "" }, atmosphere };
236
+ return this;
237
+ }
238
+ season(season) {
239
+ this._environment = { ...this._environment || { setting: "" }, season };
240
+ return this;
241
+ }
242
+ // --- Style Methods ---
243
+ style(settings) {
244
+ this._style = { ...this._style || {}, ...settings };
245
+ return this;
246
+ }
247
+ medium(medium) {
248
+ this._style = { ...this._style || {}, medium };
249
+ return this;
250
+ }
251
+ artist(artist) {
252
+ this._style = { ...this._style || {}, artist };
253
+ return this;
254
+ }
255
+ influence(influences) {
256
+ this._style = { ...this._style || {}, influence: influences };
257
+ return this;
258
+ }
259
+ // --- Color Methods ---
260
+ color(settings) {
261
+ this._color = { ...this._color || {}, ...settings };
262
+ return this;
263
+ }
264
+ palette(palette) {
265
+ this._color = { ...this._color || {}, palette };
266
+ return this;
267
+ }
268
+ primaryColors(colors) {
269
+ this._color = { ...this._color || {}, primary: colors };
270
+ return this;
271
+ }
272
+ accentColors(colors) {
273
+ this._color = { ...this._color || {}, accent: colors };
274
+ return this;
275
+ }
276
+ colorGrade(grade) {
277
+ this._color = { ...this._color || {}, grade };
278
+ return this;
279
+ }
280
+ // --- Technical Methods ---
281
+ technical(settings) {
282
+ this._technical = { ...this._technical || {}, ...settings };
283
+ return this;
284
+ }
285
+ aspectRatio(ratio) {
286
+ this._technical = { ...this._technical || {}, aspectRatio: ratio };
287
+ return this;
288
+ }
289
+ resolution(resolution) {
290
+ this._technical = { ...this._technical || {}, resolution };
291
+ return this;
292
+ }
293
+ quality(quality) {
294
+ this._technical = { ...this._technical || {}, quality };
295
+ return this;
296
+ }
297
+ // --- Mood & Misc ---
298
+ mood(mood) {
299
+ this._mood = mood;
300
+ return this;
301
+ }
302
+ negative(items) {
303
+ this._negative = [...this._negative, ...items];
304
+ return this;
305
+ }
306
+ custom(text) {
307
+ this._custom.push(text);
308
+ return this;
309
+ }
310
+ // --- Build Methods ---
311
+ buildPromptText() {
312
+ const parts = [];
313
+ if (this._subject) {
314
+ let subjectText = this._subject.main;
315
+ if (this._subject.count && this._subject.count !== "single") {
316
+ subjectText = `${this._subject.count} ${subjectText}`;
317
+ }
318
+ if (this._subject.expression) subjectText += `, ${this._subject.expression} expression`;
319
+ if (this._subject.pose) subjectText += `, ${this._subject.pose}`;
320
+ if (this._subject.action) subjectText += `, ${this._subject.action}`;
321
+ if (this._subject.clothing) subjectText += `, wearing ${this._subject.clothing}`;
322
+ if (this._subject.accessories?.length) subjectText += `, with ${this._subject.accessories.join(", ")}`;
323
+ if (this._subject.details?.length) subjectText += `, ${this._subject.details.join(", ")}`;
324
+ parts.push(subjectText);
325
+ }
326
+ if (this._environment) {
327
+ let envText = this._environment.setting;
328
+ if (this._environment.location) envText += ` in ${this._environment.location}`;
329
+ if (this._environment.atmosphere) envText += `, ${this._environment.atmosphere} atmosphere`;
330
+ if (this._environment.season) envText += `, ${this._environment.season}`;
331
+ if (this._environment.props?.length) envText += `, with ${this._environment.props.join(", ")}`;
332
+ parts.push(envText);
333
+ }
334
+ if (this._composition) {
335
+ const compParts = [];
336
+ if (this._composition.foreground) compParts.push(`foreground: ${this._composition.foreground}`);
337
+ if (this._composition.midground) compParts.push(`midground: ${this._composition.midground}`);
338
+ if (this._composition.background) compParts.push(`background: ${this._composition.background}`);
339
+ if (this._composition.ruleOfThirds) compParts.push("rule of thirds composition");
340
+ if (this._composition.goldenRatio) compParts.push("golden ratio composition");
341
+ if (this._composition.symmetry && this._composition.symmetry !== "none") {
342
+ compParts.push(`${this._composition.symmetry} symmetry`);
343
+ }
344
+ if (compParts.length) parts.push(compParts.join(", "));
345
+ }
346
+ if (this._camera) {
347
+ const camParts = [];
348
+ if (this._camera.shot) camParts.push(`${this._camera.shot} shot`);
349
+ if (this._camera.angle) camParts.push(`${this._camera.angle}`);
350
+ if (this._camera.lens) camParts.push(`${this._camera.lens} lens`);
351
+ if (this._camera.focus) camParts.push(`${this._camera.focus} depth of field`);
352
+ if (this._camera.aperture) camParts.push(`f/${this._camera.aperture}`);
353
+ if (this._camera.filmStock) camParts.push(`shot on ${this._camera.filmStock}`);
354
+ if (this._camera.brand) camParts.push(`${this._camera.brand}`);
355
+ if (camParts.length) parts.push(camParts.join(", "));
356
+ }
357
+ if (this._lighting) {
358
+ const lightParts = [];
359
+ if (this._lighting.type) {
360
+ const types = Array.isArray(this._lighting.type) ? this._lighting.type : [this._lighting.type];
361
+ lightParts.push(`${types.join(" and ")} lighting`);
362
+ }
363
+ if (this._lighting.time) lightParts.push(this._lighting.time);
364
+ if (this._lighting.weather) lightParts.push(`${this._lighting.weather} weather`);
365
+ if (this._lighting.direction) lightParts.push(`light from ${this._lighting.direction}`);
366
+ if (this._lighting.intensity) lightParts.push(`${this._lighting.intensity} light`);
367
+ if (lightParts.length) parts.push(lightParts.join(", "));
368
+ }
369
+ if (this._style) {
370
+ const styleParts = [];
371
+ if (this._style.medium) {
372
+ const mediums = Array.isArray(this._style.medium) ? this._style.medium : [this._style.medium];
373
+ styleParts.push(mediums.join(", "));
374
+ }
375
+ if (this._style.artist) {
376
+ const artists = Array.isArray(this._style.artist) ? this._style.artist : [this._style.artist];
377
+ styleParts.push(`in the style of ${artists.join(" and ")}`);
378
+ }
379
+ if (this._style.era) styleParts.push(this._style.era);
380
+ if (this._style.influence?.length) styleParts.push(`influenced by ${this._style.influence.join(", ")}`);
381
+ if (this._style.quality?.length) styleParts.push(this._style.quality.join(", "));
382
+ if (styleParts.length) parts.push(styleParts.join(", "));
383
+ }
384
+ if (this._color) {
385
+ const colorParts = [];
386
+ if (this._color.palette) {
387
+ const palettes = Array.isArray(this._color.palette) ? this._color.palette : [this._color.palette];
388
+ colorParts.push(`${palettes.join(" and ")} color palette`);
389
+ }
390
+ if (this._color.primary?.length) colorParts.push(`primary colors: ${this._color.primary.join(", ")}`);
391
+ if (this._color.accent?.length) colorParts.push(`accent colors: ${this._color.accent.join(", ")}`);
392
+ if (this._color.grade) colorParts.push(`${this._color.grade} color grade`);
393
+ if (this._color.temperature) colorParts.push(`${this._color.temperature} tones`);
394
+ if (colorParts.length) parts.push(colorParts.join(", "));
395
+ }
396
+ if (this._mood) {
397
+ const moods = Array.isArray(this._mood) ? this._mood : [this._mood];
398
+ parts.push(`${moods.join(", ")} mood`);
399
+ }
400
+ if (this._technical) {
401
+ const techParts = [];
402
+ if (this._technical.quality) techParts.push(`${this._technical.quality} quality`);
403
+ if (this._technical.detail) techParts.push(`${this._technical.detail} detail`);
404
+ if (this._technical.resolution) techParts.push(this._technical.resolution);
405
+ if (techParts.length) parts.push(techParts.join(", "));
406
+ }
407
+ if (this._custom.length) {
408
+ parts.push(this._custom.join(", "));
409
+ }
410
+ let prompt = parts.join(", ");
411
+ if (this._negative.length) {
412
+ prompt += ` --no ${this._negative.join(", ")}`;
413
+ }
414
+ if (this._technical?.aspectRatio) {
415
+ prompt += ` --ar ${this._technical.aspectRatio}`;
416
+ }
417
+ return prompt;
418
+ }
419
+ build() {
420
+ return {
421
+ prompt: this.buildPromptText(),
422
+ structure: {
423
+ subject: this._subject,
424
+ camera: this._camera,
425
+ lighting: this._lighting,
426
+ composition: this._composition,
427
+ style: this._style,
428
+ color: this._color,
429
+ environment: this._environment,
430
+ technical: this._technical,
431
+ mood: this._mood,
432
+ negative: this._negative.length ? this._negative : void 0
433
+ }
434
+ };
435
+ }
436
+ toString() {
437
+ return this.build().prompt;
438
+ }
439
+ toJSON() {
440
+ return JSON.stringify(this.build().structure, null, 2);
441
+ }
442
+ toYAML() {
443
+ return objectToYaml(this.build().structure);
444
+ }
445
+ toMarkdown() {
446
+ const built = this.build();
447
+ const sections = ["# Image Prompt\n"];
448
+ sections.push("## Prompt\n```\n" + built.prompt + "\n```\n");
449
+ if (built.structure.subject) {
450
+ sections.push("## Subject\n" + objectToMarkdownList(built.structure.subject));
451
+ }
452
+ if (built.structure.environment) {
453
+ sections.push("## Environment\n" + objectToMarkdownList(built.structure.environment));
454
+ }
455
+ if (built.structure.camera) {
456
+ sections.push("## Camera\n" + objectToMarkdownList(built.structure.camera));
457
+ }
458
+ if (built.structure.lighting) {
459
+ sections.push("## Lighting\n" + objectToMarkdownList(built.structure.lighting));
460
+ }
461
+ if (built.structure.composition) {
462
+ sections.push("## Composition\n" + objectToMarkdownList(built.structure.composition));
463
+ }
464
+ if (built.structure.style) {
465
+ sections.push("## Style\n" + objectToMarkdownList(built.structure.style));
466
+ }
467
+ if (built.structure.color) {
468
+ sections.push("## Color\n" + objectToMarkdownList(built.structure.color));
469
+ }
470
+ if (built.structure.technical) {
471
+ sections.push("## Technical\n" + objectToMarkdownList(built.structure.technical));
472
+ }
473
+ return sections.join("\n");
474
+ }
475
+ format(fmt) {
476
+ switch (fmt) {
477
+ case "json":
478
+ return this.toJSON();
479
+ case "yaml":
480
+ return this.toYAML();
481
+ case "markdown":
482
+ return this.toMarkdown();
483
+ default:
484
+ return this.toString();
485
+ }
486
+ }
487
+ };
488
+ function objectToYaml(obj, indent = 0) {
489
+ const spaces = " ".repeat(indent);
490
+ const lines = [];
491
+ for (const [key, value] of Object.entries(obj)) {
492
+ if (value === void 0 || value === null) continue;
493
+ if (Array.isArray(value)) {
494
+ if (value.length === 0) continue;
495
+ lines.push(`${spaces}${key}:`);
496
+ for (const item of value) {
497
+ if (typeof item === "object") {
498
+ lines.push(`${spaces} -`);
499
+ lines.push(objectToYaml(item, indent + 2).replace(/^/gm, " "));
500
+ } else {
501
+ lines.push(`${spaces} - ${item}`);
502
+ }
503
+ }
504
+ } else if (typeof value === "object") {
505
+ lines.push(`${spaces}${key}:`);
506
+ lines.push(objectToYaml(value, indent + 1));
507
+ } else {
508
+ lines.push(`${spaces}${key}: ${value}`);
509
+ }
510
+ }
511
+ return lines.join("\n");
512
+ }
513
+ function objectToMarkdownList(obj, indent = 0) {
514
+ const spaces = " ".repeat(indent);
515
+ const lines = [];
516
+ for (const [key, value] of Object.entries(obj)) {
517
+ if (value === void 0 || value === null) continue;
518
+ if (Array.isArray(value)) {
519
+ lines.push(`${spaces}- **${key}:** ${value.join(", ")}`);
520
+ } else if (typeof value === "object") {
521
+ lines.push(`${spaces}- **${key}:**`);
522
+ lines.push(objectToMarkdownList(value, indent + 1));
523
+ } else {
524
+ lines.push(`${spaces}- **${key}:** ${value}`);
525
+ }
526
+ }
527
+ return lines.join("\n");
528
+ }
529
+ function image() {
530
+ return new ImagePromptBuilder();
531
+ }
532
+
533
+ // src/builder/video.ts
534
+ var VideoPromptBuilder = class {
535
+ constructor() {
536
+ this._actions = [];
537
+ this._shots = [];
538
+ this._transitions = [];
539
+ this._custom = [];
540
+ }
541
+ // --- Scene Methods ---
542
+ scene(description) {
543
+ if (typeof description === "string") {
544
+ this._scene = { ...this._scene || { description: "" }, description };
545
+ } else {
546
+ this._scene = { ...this._scene || { description: "" }, ...description };
547
+ }
548
+ return this;
549
+ }
550
+ setting(setting) {
551
+ this._scene = { ...this._scene || { description: "" }, setting };
552
+ return this;
553
+ }
554
+ // --- Subject Methods ---
555
+ subject(main) {
556
+ if (typeof main === "string") {
557
+ this._subject = { ...this._subject || { main: "" }, main };
558
+ } else {
559
+ this._subject = { ...this._subject || { main: "" }, ...main };
560
+ }
561
+ return this;
562
+ }
563
+ appearance(appearance) {
564
+ this._subject = { ...this._subject || { main: "" }, appearance };
565
+ return this;
566
+ }
567
+ clothing(clothing) {
568
+ this._subject = { ...this._subject || { main: "" }, clothing };
569
+ return this;
570
+ }
571
+ // --- Camera Methods ---
572
+ camera(settings) {
573
+ this._camera = { ...this._camera || {}, ...settings };
574
+ return this;
575
+ }
576
+ shot(shot) {
577
+ this._camera = { ...this._camera || {}, shot };
578
+ return this;
579
+ }
580
+ angle(angle) {
581
+ this._camera = { ...this._camera || {}, angle };
582
+ return this;
583
+ }
584
+ movement(movement) {
585
+ this._camera = { ...this._camera || {}, movement };
586
+ return this;
587
+ }
588
+ lens(lens) {
589
+ this._camera = { ...this._camera || {}, lens };
590
+ return this;
591
+ }
592
+ platform(platform) {
593
+ this._camera = { ...this._camera || {}, platform };
594
+ return this;
595
+ }
596
+ cameraSpeed(speed) {
597
+ this._camera = { ...this._camera || {}, movementSpeed: speed };
598
+ return this;
599
+ }
600
+ movementDirection(direction) {
601
+ this._camera = { ...this._camera || {}, movementDirection: direction };
602
+ return this;
603
+ }
604
+ rig(rig) {
605
+ this._camera = { ...this._camera || {}, rig };
606
+ return this;
607
+ }
608
+ gimbal(gimbal) {
609
+ this._camera = { ...this._camera || {}, gimbal };
610
+ return this;
611
+ }
612
+ cameraBrand(brand) {
613
+ this._camera = { ...this._camera || {}, brand };
614
+ return this;
615
+ }
616
+ cameraModel(model) {
617
+ this._camera = { ...this._camera || {}, model };
618
+ return this;
619
+ }
620
+ sensor(sensor) {
621
+ this._camera = { ...this._camera || {}, sensor };
622
+ return this;
623
+ }
624
+ lensModel(model) {
625
+ this._camera = { ...this._camera || {}, lensModel: model };
626
+ return this;
627
+ }
628
+ lensBrand(brand) {
629
+ this._camera = { ...this._camera || {}, lensBrand: brand };
630
+ return this;
631
+ }
632
+ focalLength(length) {
633
+ this._camera = { ...this._camera || {}, focalLength: length };
634
+ return this;
635
+ }
636
+ anamorphic(ratio) {
637
+ this._camera = { ...this._camera || {}, anamorphic: true, anamorphicRatio: ratio };
638
+ return this;
639
+ }
640
+ aperture(aperture) {
641
+ this._camera = { ...this._camera || {}, aperture };
642
+ return this;
643
+ }
644
+ frameRate(fps) {
645
+ this._camera = { ...this._camera || {}, frameRate: fps };
646
+ return this;
647
+ }
648
+ slowMotion(enabled = true) {
649
+ this._camera = { ...this._camera || {}, slowMotion: enabled };
650
+ return this;
651
+ }
652
+ shutterAngle(angle) {
653
+ this._camera = { ...this._camera || {}, shutterAngle: angle };
654
+ return this;
655
+ }
656
+ filter(filter) {
657
+ this._camera = { ...this._camera || {}, filter };
658
+ return this;
659
+ }
660
+ filmStock(stock) {
661
+ this._camera = { ...this._camera || {}, filmStock: stock };
662
+ return this;
663
+ }
664
+ filmGrain(grain) {
665
+ this._camera = { ...this._camera || {}, filmGrain: grain };
666
+ return this;
667
+ }
668
+ halation(enabled = true) {
669
+ this._camera = { ...this._camera || {}, halation: enabled };
670
+ return this;
671
+ }
672
+ // --- Lighting Methods ---
673
+ lighting(settings) {
674
+ this._lighting = { ...this._lighting || {}, ...settings };
675
+ return this;
676
+ }
677
+ lightingType(type) {
678
+ this._lighting = { ...this._lighting || {}, type };
679
+ return this;
680
+ }
681
+ timeOfDay(time) {
682
+ this._lighting = { ...this._lighting || {}, time };
683
+ this._scene = { ...this._scene || { description: "" }, timeOfDay: time };
684
+ return this;
685
+ }
686
+ weather(weather) {
687
+ this._lighting = { ...this._lighting || {}, weather };
688
+ this._scene = { ...this._scene || { description: "" }, weather };
689
+ return this;
690
+ }
691
+ // --- Action & Motion Methods ---
692
+ action(action, options = {}) {
693
+ this._actions.push({
694
+ beat: this._actions.length + 1,
695
+ action,
696
+ ...options
697
+ });
698
+ return this;
699
+ }
700
+ actions(actions) {
701
+ actions.forEach((a, i) => this._actions.push({ beat: i + 1, action: a }));
702
+ return this;
703
+ }
704
+ motion(settings) {
705
+ this._motion = { ...this._motion || {}, ...settings };
706
+ return this;
707
+ }
708
+ motionBeats(beats) {
709
+ this._motion = { ...this._motion || {}, beats };
710
+ return this;
711
+ }
712
+ // --- Style Methods ---
713
+ style(settings) {
714
+ this._style = { ...this._style || {}, ...settings };
715
+ return this;
716
+ }
717
+ format(format) {
718
+ this._style = { ...this._style || {}, format };
719
+ return this;
720
+ }
721
+ era(era) {
722
+ this._style = { ...this._style || {}, era };
723
+ return this;
724
+ }
725
+ styleFilmStock(stock) {
726
+ this._style = { ...this._style || {}, filmStock: stock };
727
+ return this;
728
+ }
729
+ look(look) {
730
+ this._style = { ...this._style || {}, look };
731
+ return this;
732
+ }
733
+ reference(references) {
734
+ this._style = { ...this._style || {}, reference: references };
735
+ return this;
736
+ }
737
+ // --- Color Methods ---
738
+ color(settings) {
739
+ this._color = { ...this._color || {}, ...settings };
740
+ return this;
741
+ }
742
+ palette(palette) {
743
+ this._color = { ...this._color || {}, palette };
744
+ return this;
745
+ }
746
+ colorAnchors(anchors) {
747
+ this._color = { ...this._color || {}, anchors };
748
+ return this;
749
+ }
750
+ colorGrade(grade) {
751
+ this._color = { ...this._color || {}, grade };
752
+ return this;
753
+ }
754
+ // --- Audio Methods ---
755
+ audio(settings) {
756
+ this._audio = { ...this._audio || {}, ...settings };
757
+ return this;
758
+ }
759
+ dialogue(dialogue) {
760
+ this._audio = { ...this._audio || {}, dialogue };
761
+ return this;
762
+ }
763
+ ambient(ambient) {
764
+ this._audio = { ...this._audio || {}, ambient };
765
+ return this;
766
+ }
767
+ diegetic(sounds) {
768
+ this._audio = { ...this._audio || {}, diegetic: sounds };
769
+ return this;
770
+ }
771
+ soundEffects(effects) {
772
+ this._audio = { ...this._audio || {}, soundEffects: effects };
773
+ return this;
774
+ }
775
+ music(music) {
776
+ this._audio = { ...this._audio || {}, music };
777
+ return this;
778
+ }
779
+ // --- Technical Methods ---
780
+ technical(settings) {
781
+ this._technical = { ...this._technical || {}, ...settings };
782
+ return this;
783
+ }
784
+ duration(seconds) {
785
+ this._technical = { ...this._technical || {}, duration: seconds };
786
+ return this;
787
+ }
788
+ resolution(res) {
789
+ this._technical = { ...this._technical || {}, resolution: res };
790
+ return this;
791
+ }
792
+ fps(fps) {
793
+ this._technical = { ...this._technical || {}, fps };
794
+ return this;
795
+ }
796
+ aspectRatio(ratio) {
797
+ this._technical = { ...this._technical || {}, aspectRatio: ratio };
798
+ return this;
799
+ }
800
+ // --- Shot List Methods ---
801
+ addShot(shot) {
802
+ this._shots.push(shot);
803
+ return this;
804
+ }
805
+ shotList(shots) {
806
+ this._shots = [...this._shots, ...shots];
807
+ return this;
808
+ }
809
+ // --- Mood & Pacing ---
810
+ mood(mood) {
811
+ this._mood = mood;
812
+ return this;
813
+ }
814
+ pacing(pacing) {
815
+ this._pacing = pacing;
816
+ return this;
817
+ }
818
+ transition(transition) {
819
+ this._transitions.push(transition);
820
+ return this;
821
+ }
822
+ transitions(transitions) {
823
+ this._transitions = [...this._transitions, ...transitions];
824
+ return this;
825
+ }
826
+ custom(text) {
827
+ this._custom.push(text);
828
+ return this;
829
+ }
830
+ // --- Build Methods ---
831
+ buildPromptText() {
832
+ const sections = [];
833
+ if (this._scene) {
834
+ let sceneText = this._scene.description;
835
+ if (this._scene.setting) sceneText = `${this._scene.setting}. ${sceneText}`;
836
+ if (this._scene.atmosphere) sceneText += `, ${this._scene.atmosphere} atmosphere`;
837
+ sections.push(sceneText);
838
+ }
839
+ if (this._subject) {
840
+ let subjectText = this._subject.main;
841
+ if (this._subject.appearance) subjectText += `, ${this._subject.appearance}`;
842
+ if (this._subject.clothing) subjectText += `, wearing ${this._subject.clothing}`;
843
+ sections.push(subjectText);
844
+ }
845
+ const cinematography = [];
846
+ if (this._camera) {
847
+ if (this._camera.shot) cinematography.push(`${this._camera.shot} shot`);
848
+ if (this._camera.angle) cinematography.push(this._camera.angle);
849
+ if (this._camera.movement) cinematography.push(`${this._camera.movement} camera`);
850
+ if (this._camera.lens) cinematography.push(`${this._camera.lens} lens`);
851
+ if (this._camera.platform) cinematography.push(this._camera.platform);
852
+ if (this._camera.focus) cinematography.push(`${this._camera.focus} focus`);
853
+ }
854
+ if (cinematography.length) {
855
+ sections.push(`Cinematography: ${cinematography.join(", ")}`);
856
+ }
857
+ if (this._lighting) {
858
+ const lightParts = [];
859
+ if (this._lighting.type) {
860
+ const types = Array.isArray(this._lighting.type) ? this._lighting.type : [this._lighting.type];
861
+ lightParts.push(`${types.join(" and ")} lighting`);
862
+ }
863
+ if (this._lighting.time) lightParts.push(this._lighting.time);
864
+ if (this._lighting.weather) lightParts.push(`${this._lighting.weather} weather`);
865
+ if (this._lighting.intensity) lightParts.push(`${this._lighting.intensity} light`);
866
+ if (this._lighting.sources?.length) lightParts.push(`light sources: ${this._lighting.sources.join(", ")}`);
867
+ if (lightParts.length) sections.push(`Lighting: ${lightParts.join(", ")}`);
868
+ }
869
+ if (this._actions.length) {
870
+ const actionText = this._actions.map((a) => `- ${a.action}`).join("\n");
871
+ sections.push(`Actions:
872
+ ${actionText}`);
873
+ }
874
+ if (this._motion?.beats?.length) {
875
+ sections.push(`Motion beats: ${this._motion.beats.join(", ")}`);
876
+ }
877
+ if (this._style) {
878
+ const styleParts = [];
879
+ if (this._style.format) styleParts.push(this._style.format);
880
+ if (this._style.era) styleParts.push(this._style.era);
881
+ if (this._style.filmStock) styleParts.push(`shot on ${this._style.filmStock}`);
882
+ if (this._style.look) {
883
+ const looks = Array.isArray(this._style.look) ? this._style.look : [this._style.look];
884
+ styleParts.push(looks.join(", "));
885
+ }
886
+ if (styleParts.length) sections.push(`Style: ${styleParts.join(", ")}`);
887
+ }
888
+ if (this._color) {
889
+ const colorParts = [];
890
+ if (this._color.palette) {
891
+ const palettes = Array.isArray(this._color.palette) ? this._color.palette : [this._color.palette];
892
+ colorParts.push(`${palettes.join(" and ")} palette`);
893
+ }
894
+ if (this._color.anchors?.length) colorParts.push(`color anchors: ${this._color.anchors.join(", ")}`);
895
+ if (this._color.grade) colorParts.push(this._color.grade);
896
+ if (colorParts.length) sections.push(`Color: ${colorParts.join(", ")}`);
897
+ }
898
+ if (this._audio) {
899
+ const audioParts = [];
900
+ if (this._audio.dialogue) audioParts.push(`Dialogue: "${this._audio.dialogue}"`);
901
+ if (this._audio.ambient) audioParts.push(`Ambient: ${this._audio.ambient}`);
902
+ if (this._audio.diegetic?.length) audioParts.push(`Diegetic sounds: ${this._audio.diegetic.join(", ")}`);
903
+ if (this._audio.music) audioParts.push(`Music: ${this._audio.music}`);
904
+ if (audioParts.length) sections.push(`Audio:
905
+ ${audioParts.join("\n")}`);
906
+ }
907
+ if (this._mood) {
908
+ const moods = Array.isArray(this._mood) ? this._mood : [this._mood];
909
+ sections.push(`Mood: ${moods.join(", ")}`);
910
+ }
911
+ if (this._pacing) {
912
+ sections.push(`Pacing: ${this._pacing}`);
913
+ }
914
+ if (this._custom.length) {
915
+ sections.push(this._custom.join("\n"));
916
+ }
917
+ return sections.join("\n\n");
918
+ }
919
+ build() {
920
+ return {
921
+ prompt: this.buildPromptText(),
922
+ structure: {
923
+ scene: this._scene,
924
+ subject: this._subject,
925
+ camera: this._camera,
926
+ lighting: this._lighting,
927
+ actions: this._actions.length ? this._actions : void 0,
928
+ motion: this._motion,
929
+ style: this._style,
930
+ color: this._color,
931
+ audio: this._audio,
932
+ technical: this._technical,
933
+ shots: this._shots.length ? this._shots : void 0,
934
+ mood: this._mood,
935
+ pacing: this._pacing,
936
+ transitions: this._transitions.length ? this._transitions : void 0
937
+ }
938
+ };
939
+ }
940
+ toString() {
941
+ return this.build().prompt;
942
+ }
943
+ toJSON() {
944
+ return JSON.stringify(this.build().structure, null, 2);
945
+ }
946
+ toYAML() {
947
+ return objectToYaml2(this.build().structure);
948
+ }
949
+ toMarkdown() {
950
+ const built = this.build();
951
+ const sections = ["# Video Prompt\n"];
952
+ sections.push("## Prompt\n```\n" + built.prompt + "\n```\n");
953
+ if (built.structure.scene) {
954
+ sections.push("## Scene\n" + objectToMarkdownList2(built.structure.scene));
955
+ }
956
+ if (built.structure.subject) {
957
+ sections.push("## Subject\n" + objectToMarkdownList2(built.structure.subject));
958
+ }
959
+ if (built.structure.camera) {
960
+ sections.push("## Camera\n" + objectToMarkdownList2(built.structure.camera));
961
+ }
962
+ if (built.structure.lighting) {
963
+ sections.push("## Lighting\n" + objectToMarkdownList2(built.structure.lighting));
964
+ }
965
+ if (built.structure.actions) {
966
+ sections.push("## Actions\n" + built.structure.actions.map((a) => `- **Beat ${a.beat}:** ${a.action}`).join("\n"));
967
+ }
968
+ if (built.structure.style) {
969
+ sections.push("## Style\n" + objectToMarkdownList2(built.structure.style));
970
+ }
971
+ if (built.structure.audio) {
972
+ sections.push("## Audio\n" + objectToMarkdownList2(built.structure.audio));
973
+ }
974
+ if (built.structure.technical) {
975
+ sections.push("## Technical\n" + objectToMarkdownList2(built.structure.technical));
976
+ }
977
+ return sections.join("\n");
978
+ }
979
+ outputFormat(fmt) {
980
+ switch (fmt) {
981
+ case "json":
982
+ return this.toJSON();
983
+ case "yaml":
984
+ return this.toYAML();
985
+ case "markdown":
986
+ return this.toMarkdown();
987
+ default:
988
+ return this.toString();
989
+ }
990
+ }
991
+ };
992
+ function objectToYaml2(obj, indent = 0) {
993
+ const spaces = " ".repeat(indent);
994
+ const lines = [];
995
+ for (const [key, value] of Object.entries(obj)) {
996
+ if (value === void 0 || value === null) continue;
997
+ if (Array.isArray(value)) {
998
+ if (value.length === 0) continue;
999
+ lines.push(`${spaces}${key}:`);
1000
+ for (const item of value) {
1001
+ if (typeof item === "object") {
1002
+ lines.push(`${spaces} -`);
1003
+ lines.push(objectToYaml2(item, indent + 2).replace(/^/gm, " "));
1004
+ } else {
1005
+ lines.push(`${spaces} - ${item}`);
1006
+ }
1007
+ }
1008
+ } else if (typeof value === "object") {
1009
+ lines.push(`${spaces}${key}:`);
1010
+ lines.push(objectToYaml2(value, indent + 1));
1011
+ } else {
1012
+ lines.push(`${spaces}${key}: ${value}`);
1013
+ }
1014
+ }
1015
+ return lines.join("\n");
1016
+ }
1017
+ function objectToMarkdownList2(obj, indent = 0) {
1018
+ const spaces = " ".repeat(indent);
1019
+ const lines = [];
1020
+ for (const [key, value] of Object.entries(obj)) {
1021
+ if (value === void 0 || value === null) continue;
1022
+ if (Array.isArray(value)) {
1023
+ lines.push(`${spaces}- **${key}:** ${value.join(", ")}`);
1024
+ } else if (typeof value === "object") {
1025
+ lines.push(`${spaces}- **${key}:**`);
1026
+ lines.push(objectToMarkdownList2(value, indent + 1));
1027
+ } else {
1028
+ lines.push(`${spaces}- **${key}:** ${value}`);
1029
+ }
1030
+ }
1031
+ return lines.join("\n");
1032
+ }
1033
+ function video() {
1034
+ return new VideoPromptBuilder();
1035
+ }
1036
+
1037
+ // src/builder/audio.ts
1038
+ var AudioPromptBuilder = class {
1039
+ constructor() {
1040
+ this._tags = [];
1041
+ this._custom = [];
1042
+ }
1043
+ // --- Genre Methods ---
1044
+ genre(primary) {
1045
+ if (typeof primary === "string") {
1046
+ this._genre = { ...this._genre || { primary: "pop" }, primary };
1047
+ } else {
1048
+ this._genre = { ...this._genre || { primary: "pop" }, ...primary };
1049
+ }
1050
+ return this;
1051
+ }
1052
+ subgenre(subgenre) {
1053
+ this._genre = { ...this._genre || { primary: "pop" }, subgenre };
1054
+ return this;
1055
+ }
1056
+ fusion(genres) {
1057
+ this._genre = {
1058
+ ...this._genre || { primary: "pop" },
1059
+ secondary: genres,
1060
+ fusion: genres
1061
+ };
1062
+ return this;
1063
+ }
1064
+ // --- Mood Methods ---
1065
+ mood(primary, ...secondary) {
1066
+ this._mood = {
1067
+ primary,
1068
+ secondary: secondary.length ? secondary : void 0
1069
+ };
1070
+ return this;
1071
+ }
1072
+ energy(level) {
1073
+ this._mood = { ...this._mood || { primary: "energetic" }, energy: level };
1074
+ return this;
1075
+ }
1076
+ emotion(emotion) {
1077
+ this._mood = { ...this._mood || { primary: "emotional" }, emotion };
1078
+ return this;
1079
+ }
1080
+ // --- Tempo Methods ---
1081
+ tempo(bpmOrSettings) {
1082
+ if (typeof bpmOrSettings === "number") {
1083
+ this._tempo = { ...this._tempo || {}, bpm: bpmOrSettings };
1084
+ } else {
1085
+ this._tempo = { ...this._tempo || {}, ...bpmOrSettings };
1086
+ }
1087
+ return this;
1088
+ }
1089
+ bpm(bpm) {
1090
+ this._tempo = { ...this._tempo || {}, bpm };
1091
+ return this;
1092
+ }
1093
+ tempoMarking(marking) {
1094
+ this._tempo = { ...this._tempo || {}, marking };
1095
+ return this;
1096
+ }
1097
+ tempoFeel(feel) {
1098
+ this._tempo = { ...this._tempo || {}, feel };
1099
+ return this;
1100
+ }
1101
+ // --- Vocal Methods ---
1102
+ vocals(settings) {
1103
+ this._vocals = { ...this._vocals || {}, ...settings };
1104
+ return this;
1105
+ }
1106
+ vocalStyle(style) {
1107
+ this._vocals = { ...this._vocals || {}, style };
1108
+ return this;
1109
+ }
1110
+ language(language) {
1111
+ this._vocals = { ...this._vocals || {}, language };
1112
+ return this;
1113
+ }
1114
+ lyrics(lyrics) {
1115
+ this._vocals = { ...this._vocals || {}, lyrics };
1116
+ return this;
1117
+ }
1118
+ lyricsTheme(theme) {
1119
+ this._vocals = { ...this._vocals || {}, theme };
1120
+ return this;
1121
+ }
1122
+ delivery(delivery) {
1123
+ this._vocals = { ...this._vocals || {}, delivery };
1124
+ return this;
1125
+ }
1126
+ instrumental() {
1127
+ this._vocals = { ...this._vocals || {}, language: "instrumental" };
1128
+ return this;
1129
+ }
1130
+ // --- Instrumentation Methods ---
1131
+ instruments(instruments) {
1132
+ this._instrumentation = {
1133
+ ...this._instrumentation || {},
1134
+ lead: instruments
1135
+ };
1136
+ return this;
1137
+ }
1138
+ instrumentation(settings) {
1139
+ this._instrumentation = { ...this._instrumentation || {}, ...settings };
1140
+ return this;
1141
+ }
1142
+ leadInstrument(instrument) {
1143
+ this._instrumentation = { ...this._instrumentation || {}, lead: instrument };
1144
+ return this;
1145
+ }
1146
+ rhythmSection(instruments) {
1147
+ this._instrumentation = { ...this._instrumentation || {}, rhythm: instruments };
1148
+ return this;
1149
+ }
1150
+ bassInstrument(instrument) {
1151
+ this._instrumentation = { ...this._instrumentation || {}, bass: instrument };
1152
+ return this;
1153
+ }
1154
+ percussion(instruments) {
1155
+ this._instrumentation = { ...this._instrumentation || {}, percussion: instruments };
1156
+ return this;
1157
+ }
1158
+ pads(instruments) {
1159
+ this._instrumentation = { ...this._instrumentation || {}, pads: instruments };
1160
+ return this;
1161
+ }
1162
+ featuredInstrument(instrument) {
1163
+ this._instrumentation = { ...this._instrumentation || {}, featured: instrument };
1164
+ return this;
1165
+ }
1166
+ // --- Structure Methods ---
1167
+ structure(settings) {
1168
+ if ("sections" in settings || "form" in settings || "duration" in settings) {
1169
+ this._structure = { ...this._structure || {}, ...settings };
1170
+ } else {
1171
+ const sections = [];
1172
+ for (const [type, bars] of Object.entries(settings)) {
1173
+ if (typeof bars === "number") {
1174
+ sections.push({ type, bars });
1175
+ }
1176
+ }
1177
+ this._structure = { ...this._structure || {}, sections };
1178
+ }
1179
+ return this;
1180
+ }
1181
+ section(type, bars, description) {
1182
+ const sections = this._structure?.sections || [];
1183
+ sections.push({ type, bars, description });
1184
+ this._structure = { ...this._structure || {}, sections };
1185
+ return this;
1186
+ }
1187
+ form(form) {
1188
+ this._structure = { ...this._structure || {}, form };
1189
+ return this;
1190
+ }
1191
+ duration(seconds) {
1192
+ this._structure = { ...this._structure || {}, duration: seconds };
1193
+ return this;
1194
+ }
1195
+ // --- Production Methods ---
1196
+ production(settings) {
1197
+ this._production = { ...this._production || {}, ...settings };
1198
+ return this;
1199
+ }
1200
+ productionStyle(style) {
1201
+ this._production = { ...this._production || {}, style };
1202
+ return this;
1203
+ }
1204
+ era(era) {
1205
+ this._production = { ...this._production || {}, era };
1206
+ return this;
1207
+ }
1208
+ reference(artists) {
1209
+ this._production = { ...this._production || {}, reference: artists };
1210
+ return this;
1211
+ }
1212
+ texture(texture) {
1213
+ this._production = { ...this._production || {}, texture };
1214
+ return this;
1215
+ }
1216
+ effects(effects) {
1217
+ this._production = { ...this._production || {}, effects };
1218
+ return this;
1219
+ }
1220
+ // --- Technical Methods ---
1221
+ technical(settings) {
1222
+ this._technical = { ...this._technical || {}, ...settings };
1223
+ return this;
1224
+ }
1225
+ key(key) {
1226
+ this._technical = { ...this._technical || {}, key };
1227
+ return this;
1228
+ }
1229
+ timeSignature(sig) {
1230
+ this._technical = { ...this._technical || {}, timeSignature: sig };
1231
+ return this;
1232
+ }
1233
+ formatType(format) {
1234
+ this._technical = { ...this._technical || {}, format };
1235
+ return this;
1236
+ }
1237
+ // --- Tags & Custom ---
1238
+ tag(tag) {
1239
+ this._tags.push(tag);
1240
+ return this;
1241
+ }
1242
+ tags(tags) {
1243
+ this._tags = [...this._tags, ...tags];
1244
+ return this;
1245
+ }
1246
+ custom(text) {
1247
+ this._custom.push(text);
1248
+ return this;
1249
+ }
1250
+ // --- Build Methods ---
1251
+ buildStylePrompt() {
1252
+ const parts = [];
1253
+ if (this._genre) {
1254
+ let genreText = this._genre.primary;
1255
+ if (this._genre.subgenre) genreText = `${this._genre.subgenre} ${genreText}`;
1256
+ if (this._genre.secondary?.length) {
1257
+ genreText += ` with ${this._genre.secondary.join(" and ")} influences`;
1258
+ }
1259
+ parts.push(genreText);
1260
+ }
1261
+ if (this._mood) {
1262
+ let moodText = String(this._mood.primary);
1263
+ if (this._mood.secondary?.length) {
1264
+ moodText += `, ${this._mood.secondary.join(", ")}`;
1265
+ }
1266
+ if (this._mood.energy) moodText += `, ${this._mood.energy} energy`;
1267
+ parts.push(moodText);
1268
+ }
1269
+ if (this._tempo) {
1270
+ const tempoParts = [];
1271
+ if (this._tempo.bpm) tempoParts.push(`${this._tempo.bpm} BPM`);
1272
+ if (this._tempo.marking) tempoParts.push(this._tempo.marking);
1273
+ if (this._tempo.feel) tempoParts.push(`${this._tempo.feel} feel`);
1274
+ if (tempoParts.length) parts.push(tempoParts.join(", "));
1275
+ }
1276
+ if (this._instrumentation) {
1277
+ const instrParts = [];
1278
+ if (this._instrumentation.lead) {
1279
+ const leads = Array.isArray(this._instrumentation.lead) ? this._instrumentation.lead : [this._instrumentation.lead];
1280
+ instrParts.push(leads.join(", "));
1281
+ }
1282
+ if (this._instrumentation.featured) {
1283
+ instrParts.push(`featuring ${this._instrumentation.featured}`);
1284
+ }
1285
+ if (instrParts.length) parts.push(instrParts.join(", "));
1286
+ }
1287
+ if (this._vocals) {
1288
+ const vocalParts = [];
1289
+ if (this._vocals.language === "instrumental") {
1290
+ vocalParts.push("instrumental");
1291
+ } else {
1292
+ if (this._vocals.style) {
1293
+ const styles = Array.isArray(this._vocals.style) ? this._vocals.style : [this._vocals.style];
1294
+ vocalParts.push(`${styles.join(" and ")} vocals`);
1295
+ }
1296
+ if (this._vocals.language && this._vocals.language !== "english") {
1297
+ vocalParts.push(`in ${this._vocals.language}`);
1298
+ }
1299
+ }
1300
+ if (vocalParts.length) parts.push(vocalParts.join(" "));
1301
+ }
1302
+ if (this._production) {
1303
+ const prodParts = [];
1304
+ if (this._production.style) {
1305
+ const styles = Array.isArray(this._production.style) ? this._production.style : [this._production.style];
1306
+ prodParts.push(`${styles.join(", ")} production`);
1307
+ }
1308
+ if (this._production.era) prodParts.push(`${this._production.era} sound`);
1309
+ if (this._production.texture) prodParts.push(this._production.texture);
1310
+ if (prodParts.length) parts.push(prodParts.join(", "));
1311
+ }
1312
+ if (this._technical) {
1313
+ const techParts = [];
1314
+ if (this._technical.key) techParts.push(`in the key of ${this._technical.key}`);
1315
+ if (this._technical.timeSignature && this._technical.timeSignature !== "4/4") {
1316
+ techParts.push(`${this._technical.timeSignature} time`);
1317
+ }
1318
+ if (techParts.length) parts.push(techParts.join(", "));
1319
+ }
1320
+ if (this._tags.length) {
1321
+ parts.push(this._tags.join(", "));
1322
+ }
1323
+ if (this._custom.length) {
1324
+ parts.push(this._custom.join(", "));
1325
+ }
1326
+ return parts.join(", ");
1327
+ }
1328
+ buildLyricsPrompt() {
1329
+ if (!this._vocals?.lyrics && !this._vocals?.theme) return void 0;
1330
+ const parts = [];
1331
+ if (this._vocals.theme) {
1332
+ parts.push(`Theme: ${this._vocals.theme}`);
1333
+ }
1334
+ if (this._vocals.lyrics) {
1335
+ parts.push(this._vocals.lyrics);
1336
+ }
1337
+ return parts.join("\n\n");
1338
+ }
1339
+ buildFullPrompt() {
1340
+ const sections = [];
1341
+ sections.push(`Style: ${this.buildStylePrompt()}`);
1342
+ if (this._structure?.sections?.length) {
1343
+ const structureText = this._structure.sections.map((s) => `[${s.type.toUpperCase()}]${s.description ? ` ${s.description}` : ""}`).join("\n");
1344
+ sections.push(`Structure:
1345
+ ${structureText}`);
1346
+ }
1347
+ const lyrics = this.buildLyricsPrompt();
1348
+ if (lyrics) {
1349
+ sections.push(`Lyrics:
1350
+ ${lyrics}`);
1351
+ }
1352
+ return sections.join("\n\n");
1353
+ }
1354
+ build() {
1355
+ return {
1356
+ prompt: this.buildFullPrompt(),
1357
+ stylePrompt: this.buildStylePrompt(),
1358
+ lyricsPrompt: this.buildLyricsPrompt(),
1359
+ structure: {
1360
+ genre: this._genre,
1361
+ mood: this._mood,
1362
+ tempo: this._tempo,
1363
+ vocals: this._vocals,
1364
+ instrumentation: this._instrumentation,
1365
+ structure: this._structure,
1366
+ production: this._production,
1367
+ technical: this._technical,
1368
+ tags: this._tags.length ? this._tags : void 0
1369
+ }
1370
+ };
1371
+ }
1372
+ toString() {
1373
+ return this.build().prompt;
1374
+ }
1375
+ toStyleString() {
1376
+ return this.build().stylePrompt;
1377
+ }
1378
+ toJSON() {
1379
+ return JSON.stringify(this.build().structure, null, 2);
1380
+ }
1381
+ toYAML() {
1382
+ return objectToYaml3(this.build().structure);
1383
+ }
1384
+ toMarkdown() {
1385
+ const built = this.build();
1386
+ const sections = ["# Audio Prompt\n"];
1387
+ sections.push("## Style Prompt\n```\n" + built.stylePrompt + "\n```\n");
1388
+ if (built.lyricsPrompt) {
1389
+ sections.push("## Lyrics\n```\n" + built.lyricsPrompt + "\n```\n");
1390
+ }
1391
+ if (built.structure.genre) {
1392
+ sections.push("## Genre\n" + objectToMarkdownList3(built.structure.genre));
1393
+ }
1394
+ if (built.structure.mood) {
1395
+ sections.push("## Mood\n" + objectToMarkdownList3(built.structure.mood));
1396
+ }
1397
+ if (built.structure.tempo) {
1398
+ sections.push("## Tempo\n" + objectToMarkdownList3(built.structure.tempo));
1399
+ }
1400
+ if (built.structure.vocals) {
1401
+ sections.push("## Vocals\n" + objectToMarkdownList3(built.structure.vocals));
1402
+ }
1403
+ if (built.structure.instrumentation) {
1404
+ sections.push("## Instrumentation\n" + objectToMarkdownList3(built.structure.instrumentation));
1405
+ }
1406
+ if (built.structure.production) {
1407
+ sections.push("## Production\n" + objectToMarkdownList3(built.structure.production));
1408
+ }
1409
+ return sections.join("\n");
1410
+ }
1411
+ outputFormat(fmt) {
1412
+ switch (fmt) {
1413
+ case "json":
1414
+ return this.toJSON();
1415
+ case "yaml":
1416
+ return this.toYAML();
1417
+ case "markdown":
1418
+ return this.toMarkdown();
1419
+ default:
1420
+ return this.toString();
1421
+ }
1422
+ }
1423
+ };
1424
+ function objectToYaml3(obj, indent = 0) {
1425
+ const spaces = " ".repeat(indent);
1426
+ const lines = [];
1427
+ for (const [key, value] of Object.entries(obj)) {
1428
+ if (value === void 0 || value === null) continue;
1429
+ if (Array.isArray(value)) {
1430
+ if (value.length === 0) continue;
1431
+ lines.push(`${spaces}${key}:`);
1432
+ for (const item of value) {
1433
+ if (typeof item === "object") {
1434
+ lines.push(`${spaces} -`);
1435
+ lines.push(objectToYaml3(item, indent + 2).replace(/^/gm, " "));
1436
+ } else {
1437
+ lines.push(`${spaces} - ${item}`);
1438
+ }
1439
+ }
1440
+ } else if (typeof value === "object") {
1441
+ lines.push(`${spaces}${key}:`);
1442
+ lines.push(objectToYaml3(value, indent + 1));
1443
+ } else {
1444
+ lines.push(`${spaces}${key}: ${value}`);
1445
+ }
1446
+ }
1447
+ return lines.join("\n");
1448
+ }
1449
+ function objectToMarkdownList3(obj, indent = 0) {
1450
+ const spaces = " ".repeat(indent);
1451
+ const lines = [];
1452
+ for (const [key, value] of Object.entries(obj)) {
1453
+ if (value === void 0 || value === null) continue;
1454
+ if (Array.isArray(value)) {
1455
+ lines.push(`${spaces}- **${key}:** ${value.join(", ")}`);
1456
+ } else if (typeof value === "object") {
1457
+ lines.push(`${spaces}- **${key}:**`);
1458
+ lines.push(objectToMarkdownList3(value, indent + 1));
1459
+ } else {
1460
+ lines.push(`${spaces}- **${key}:** ${value}`);
1461
+ }
1462
+ }
1463
+ return lines.join("\n");
1464
+ }
1465
+ function audio() {
1466
+ return new AudioPromptBuilder();
1467
+ }
1468
+
1469
+ // src/builder/chat.ts
1470
+ var ChatPromptBuilder = class {
1471
+ constructor() {
1472
+ this._messages = [];
1473
+ this._examples = [];
1474
+ this._customSystemParts = [];
1475
+ }
1476
+ // --- Message Methods ---
1477
+ system(content) {
1478
+ this._messages = this._messages.filter((m) => m.role !== "system");
1479
+ this._messages.unshift({ role: "system", content });
1480
+ return this;
1481
+ }
1482
+ user(content, name) {
1483
+ this._messages.push({ role: "user", content, name });
1484
+ return this;
1485
+ }
1486
+ assistant(content) {
1487
+ this._messages.push({ role: "assistant", content });
1488
+ return this;
1489
+ }
1490
+ message(role, content, name) {
1491
+ this._messages.push({ role, content, name });
1492
+ return this;
1493
+ }
1494
+ messages(messages) {
1495
+ this._messages = [...this._messages, ...messages];
1496
+ return this;
1497
+ }
1498
+ conversation(turns) {
1499
+ for (const turn of turns) {
1500
+ this.user(turn.user);
1501
+ if (turn.assistant) {
1502
+ this.assistant(turn.assistant);
1503
+ }
1504
+ }
1505
+ return this;
1506
+ }
1507
+ // --- Persona Methods ---
1508
+ persona(settings) {
1509
+ if (typeof settings === "string") {
1510
+ this._persona = { ...this._persona || {}, role: settings };
1511
+ } else {
1512
+ this._persona = { ...this._persona || {}, ...settings };
1513
+ }
1514
+ return this;
1515
+ }
1516
+ role(role) {
1517
+ this._persona = { ...this._persona || {}, role };
1518
+ return this;
1519
+ }
1520
+ tone(tone) {
1521
+ this._persona = { ...this._persona || {}, tone };
1522
+ return this;
1523
+ }
1524
+ expertise(expertise) {
1525
+ this._persona = { ...this._persona || {}, expertise };
1526
+ return this;
1527
+ }
1528
+ personality(traits) {
1529
+ this._persona = { ...this._persona || {}, personality: traits };
1530
+ return this;
1531
+ }
1532
+ background(background) {
1533
+ this._persona = { ...this._persona || {}, background };
1534
+ return this;
1535
+ }
1536
+ speakAs(name) {
1537
+ this._persona = { ...this._persona || {}, name };
1538
+ return this;
1539
+ }
1540
+ responseLanguage(language) {
1541
+ this._persona = { ...this._persona || {}, language };
1542
+ return this;
1543
+ }
1544
+ // --- Context Methods ---
1545
+ context(settings) {
1546
+ if (typeof settings === "string") {
1547
+ this._context = { ...this._context || {}, background: settings };
1548
+ } else {
1549
+ this._context = { ...this._context || {}, ...settings };
1550
+ }
1551
+ return this;
1552
+ }
1553
+ domain(domain) {
1554
+ this._context = { ...this._context || {}, domain };
1555
+ return this;
1556
+ }
1557
+ audience(audience) {
1558
+ this._context = { ...this._context || {}, audience };
1559
+ return this;
1560
+ }
1561
+ purpose(purpose) {
1562
+ this._context = { ...this._context || {}, purpose };
1563
+ return this;
1564
+ }
1565
+ constraints(constraints) {
1566
+ const existing = this._context?.constraints || [];
1567
+ this._context = { ...this._context || {}, constraints: [...existing, ...constraints] };
1568
+ return this;
1569
+ }
1570
+ constraint(constraint) {
1571
+ return this.constraints([constraint]);
1572
+ }
1573
+ assumptions(assumptions) {
1574
+ this._context = { ...this._context || {}, assumptions };
1575
+ return this;
1576
+ }
1577
+ knowledge(facts) {
1578
+ this._context = { ...this._context || {}, knowledge: facts };
1579
+ return this;
1580
+ }
1581
+ // --- Task Methods ---
1582
+ task(instruction) {
1583
+ if (typeof instruction === "string") {
1584
+ this._task = { ...this._task || { instruction: "" }, instruction };
1585
+ } else {
1586
+ this._task = { ...this._task || { instruction: "" }, ...instruction };
1587
+ }
1588
+ return this;
1589
+ }
1590
+ instruction(instruction) {
1591
+ this._task = { ...this._task || { instruction: "" }, instruction };
1592
+ return this;
1593
+ }
1594
+ steps(steps) {
1595
+ this._task = { ...this._task || { instruction: "" }, steps };
1596
+ return this;
1597
+ }
1598
+ deliverables(deliverables) {
1599
+ this._task = { ...this._task || { instruction: "" }, deliverables };
1600
+ return this;
1601
+ }
1602
+ criteria(criteria) {
1603
+ this._task = { ...this._task || { instruction: "" }, criteria };
1604
+ return this;
1605
+ }
1606
+ avoid(antiPatterns) {
1607
+ this._task = { ...this._task || { instruction: "" }, antiPatterns };
1608
+ return this;
1609
+ }
1610
+ priority(priority) {
1611
+ this._task = { ...this._task || { instruction: "" }, priority };
1612
+ return this;
1613
+ }
1614
+ // --- Example Methods ---
1615
+ example(input, output, explanation) {
1616
+ this._examples.push({ input, output, explanation });
1617
+ return this;
1618
+ }
1619
+ examples(examples) {
1620
+ this._examples = [...this._examples, ...examples];
1621
+ return this;
1622
+ }
1623
+ fewShot(examples) {
1624
+ for (const ex of examples) {
1625
+ this._examples.push(ex);
1626
+ }
1627
+ return this;
1628
+ }
1629
+ // --- Output Methods ---
1630
+ output(settings) {
1631
+ this._output = { ...this._output || {}, ...settings };
1632
+ return this;
1633
+ }
1634
+ outputFormat(format) {
1635
+ this._output = {
1636
+ ...this._output || {},
1637
+ format: { type: format }
1638
+ };
1639
+ return this;
1640
+ }
1641
+ json(schema) {
1642
+ if (schema) {
1643
+ this._output = {
1644
+ ...this._output || {},
1645
+ format: { type: "json", jsonSchema: schema }
1646
+ };
1647
+ } else {
1648
+ this._output = {
1649
+ ...this._output || {},
1650
+ format: { type: "json" }
1651
+ };
1652
+ }
1653
+ return this;
1654
+ }
1655
+ jsonSchema(name, schema, description) {
1656
+ this._output = {
1657
+ ...this._output || {},
1658
+ format: {
1659
+ type: "json",
1660
+ jsonSchema: { name, schema, description }
1661
+ }
1662
+ };
1663
+ return this;
1664
+ }
1665
+ markdown() {
1666
+ this._output = { ...this._output || {}, format: { type: "markdown" } };
1667
+ return this;
1668
+ }
1669
+ code(language) {
1670
+ this._output = { ...this._output || {}, format: { type: "code", language } };
1671
+ return this;
1672
+ }
1673
+ table() {
1674
+ this._output = { ...this._output || {}, format: { type: "table" } };
1675
+ return this;
1676
+ }
1677
+ length(length) {
1678
+ this._output = { ...this._output || {}, length };
1679
+ return this;
1680
+ }
1681
+ style(style) {
1682
+ this._output = { ...this._output || {}, style };
1683
+ return this;
1684
+ }
1685
+ brief() {
1686
+ return this.length("brief");
1687
+ }
1688
+ moderate() {
1689
+ return this.length("moderate");
1690
+ }
1691
+ detailed() {
1692
+ return this.length("detailed");
1693
+ }
1694
+ comprehensive() {
1695
+ return this.length("comprehensive");
1696
+ }
1697
+ exhaustive() {
1698
+ return this.length("exhaustive");
1699
+ }
1700
+ withExamples() {
1701
+ this._output = { ...this._output || {}, includeExamples: true };
1702
+ return this;
1703
+ }
1704
+ withExplanation() {
1705
+ this._output = { ...this._output || {}, includeExplanation: true };
1706
+ return this;
1707
+ }
1708
+ withSources() {
1709
+ this._output = { ...this._output || {}, includeSources: true };
1710
+ return this;
1711
+ }
1712
+ withConfidence() {
1713
+ this._output = { ...this._output || {}, includeConfidence: true };
1714
+ return this;
1715
+ }
1716
+ // --- Reasoning Methods ---
1717
+ reasoning(settings) {
1718
+ this._reasoning = { ...this._reasoning || {}, ...settings };
1719
+ return this;
1720
+ }
1721
+ reasoningStyle(style) {
1722
+ this._reasoning = { ...this._reasoning || {}, style };
1723
+ return this;
1724
+ }
1725
+ stepByStep() {
1726
+ this._reasoning = { ...this._reasoning || {}, style: "step-by-step", showWork: true };
1727
+ return this;
1728
+ }
1729
+ chainOfThought() {
1730
+ this._reasoning = { ...this._reasoning || {}, style: "chain-of-thought", showWork: true };
1731
+ return this;
1732
+ }
1733
+ treeOfThought() {
1734
+ this._reasoning = { ...this._reasoning || {}, style: "tree-of-thought", showWork: true };
1735
+ return this;
1736
+ }
1737
+ firstPrinciples() {
1738
+ this._reasoning = { ...this._reasoning || {}, style: "first-principles", showWork: true };
1739
+ return this;
1740
+ }
1741
+ devilsAdvocate() {
1742
+ this._reasoning = { ...this._reasoning || {}, style: "devil-advocate", considerAlternatives: true };
1743
+ return this;
1744
+ }
1745
+ showWork(show = true) {
1746
+ this._reasoning = { ...this._reasoning || {}, showWork: show };
1747
+ return this;
1748
+ }
1749
+ verifyAnswer(verify = true) {
1750
+ this._reasoning = { ...this._reasoning || {}, verifyAnswer: verify };
1751
+ return this;
1752
+ }
1753
+ considerAlternatives(consider = true) {
1754
+ this._reasoning = { ...this._reasoning || {}, considerAlternatives: consider };
1755
+ return this;
1756
+ }
1757
+ explainAssumptions(explain = true) {
1758
+ this._reasoning = { ...this._reasoning || {}, explainAssumptions: explain };
1759
+ return this;
1760
+ }
1761
+ // --- Memory Methods ---
1762
+ memory(memory) {
1763
+ this._memory = { ...this._memory || {}, ...memory };
1764
+ return this;
1765
+ }
1766
+ remember(facts) {
1767
+ const existing = this._memory?.facts || [];
1768
+ this._memory = { ...this._memory || {}, facts: [...existing, ...facts] };
1769
+ return this;
1770
+ }
1771
+ preferences(prefs) {
1772
+ this._memory = { ...this._memory || {}, preferences: prefs };
1773
+ return this;
1774
+ }
1775
+ history(messages) {
1776
+ this._memory = { ...this._memory || {}, history: messages };
1777
+ return this;
1778
+ }
1779
+ summarizeHistory(summary) {
1780
+ this._memory = { ...this._memory || {}, summary };
1781
+ return this;
1782
+ }
1783
+ // --- Custom System Prompt Parts ---
1784
+ addSystemPart(part) {
1785
+ this._customSystemParts.push(part);
1786
+ return this;
1787
+ }
1788
+ raw(content) {
1789
+ this._customSystemParts = [content];
1790
+ return this;
1791
+ }
1792
+ // --- Build Methods ---
1793
+ buildSystemPrompt() {
1794
+ const parts = [];
1795
+ if (this._persona) {
1796
+ let personaText = "";
1797
+ if (this._persona.name) {
1798
+ personaText += `You are ${this._persona.name}`;
1799
+ if (this._persona.role) personaText += `, ${this._persona.role}`;
1800
+ personaText += ".";
1801
+ } else if (this._persona.role) {
1802
+ personaText += `You are ${this._persona.role}.`;
1803
+ }
1804
+ if (this._persona.tone) {
1805
+ const tones = Array.isArray(this._persona.tone) ? this._persona.tone : [this._persona.tone];
1806
+ personaText += ` Your tone is ${tones.join(" and ")}.`;
1807
+ }
1808
+ if (this._persona.expertise) {
1809
+ const areas = Array.isArray(this._persona.expertise) ? this._persona.expertise : [this._persona.expertise];
1810
+ personaText += ` You have expertise in ${areas.join(", ")}.`;
1811
+ }
1812
+ if (this._persona.personality?.length) {
1813
+ personaText += ` You are ${this._persona.personality.join(", ")}.`;
1814
+ }
1815
+ if (this._persona.background) {
1816
+ personaText += ` ${this._persona.background}`;
1817
+ }
1818
+ if (this._persona.verbosity) {
1819
+ personaText += ` Keep responses ${this._persona.verbosity}.`;
1820
+ }
1821
+ if (this._persona.language) {
1822
+ personaText += ` Respond in ${this._persona.language}.`;
1823
+ }
1824
+ if (personaText) parts.push(personaText.trim());
1825
+ }
1826
+ if (this._context) {
1827
+ const contextParts = [];
1828
+ if (this._context.background) {
1829
+ contextParts.push(this._context.background);
1830
+ }
1831
+ if (this._context.domain) {
1832
+ contextParts.push(`Domain: ${this._context.domain}`);
1833
+ }
1834
+ if (this._context.audience) {
1835
+ contextParts.push(`Target audience: ${this._context.audience}`);
1836
+ }
1837
+ if (this._context.purpose) {
1838
+ contextParts.push(`Purpose: ${this._context.purpose}`);
1839
+ }
1840
+ if (this._context.knowledge?.length) {
1841
+ contextParts.push(`Known facts:
1842
+ ${this._context.knowledge.map((k) => `- ${k}`).join("\n")}`);
1843
+ }
1844
+ if (this._context.assumptions?.length) {
1845
+ contextParts.push(`Assumptions:
1846
+ ${this._context.assumptions.map((a) => `- ${a}`).join("\n")}`);
1847
+ }
1848
+ if (contextParts.length) {
1849
+ parts.push(`## Context
1850
+ ${contextParts.join("\n")}`);
1851
+ }
1852
+ }
1853
+ if (this._task) {
1854
+ const taskParts = [];
1855
+ if (this._task.instruction) {
1856
+ taskParts.push(this._task.instruction);
1857
+ }
1858
+ if (this._task.priority) {
1859
+ taskParts.push(`Priority: ${this._task.priority}`);
1860
+ }
1861
+ if (this._task.steps?.length) {
1862
+ taskParts.push(`
1863
+ Steps:
1864
+ ${this._task.steps.map((s, i) => `${i + 1}. ${s}`).join("\n")}`);
1865
+ }
1866
+ if (this._task.deliverables?.length) {
1867
+ taskParts.push(`
1868
+ Deliverables:
1869
+ ${this._task.deliverables.map((d) => `- ${d}`).join("\n")}`);
1870
+ }
1871
+ if (this._task.criteria?.length) {
1872
+ taskParts.push(`
1873
+ Success criteria:
1874
+ ${this._task.criteria.map((c) => `- ${c}`).join("\n")}`);
1875
+ }
1876
+ if (this._task.antiPatterns?.length) {
1877
+ taskParts.push(`
1878
+ Avoid:
1879
+ ${this._task.antiPatterns.map((a) => `- ${a}`).join("\n")}`);
1880
+ }
1881
+ if (taskParts.length) {
1882
+ parts.push(`## Task
1883
+ ${taskParts.join("\n")}`);
1884
+ }
1885
+ }
1886
+ if (this._context?.constraints?.length) {
1887
+ parts.push(`## Constraints
1888
+ ${this._context.constraints.map((c, i) => `${i + 1}. ${c}`).join("\n")}`);
1889
+ }
1890
+ if (this._examples.length) {
1891
+ const examplesText = this._examples.map((ex, i) => {
1892
+ let text = `### Example ${i + 1}
1893
+ **Input:** ${ex.input}
1894
+ **Output:** ${ex.output}`;
1895
+ if (ex.explanation) text += `
1896
+ **Explanation:** ${ex.explanation}`;
1897
+ return text;
1898
+ }).join("\n\n");
1899
+ parts.push(`## Examples
1900
+ ${examplesText}`);
1901
+ }
1902
+ if (this._output) {
1903
+ const outputParts = [];
1904
+ if (this._output.format) {
1905
+ switch (this._output.format.type) {
1906
+ case "json":
1907
+ if (this._output.format.jsonSchema) {
1908
+ outputParts.push(`Respond in valid JSON matching this schema:
1909
+ \`\`\`json
1910
+ ${JSON.stringify(this._output.format.jsonSchema.schema, null, 2)}
1911
+ \`\`\``);
1912
+ } else {
1913
+ outputParts.push("Respond in valid JSON format.");
1914
+ }
1915
+ break;
1916
+ case "markdown":
1917
+ outputParts.push("Format your response using Markdown.");
1918
+ break;
1919
+ case "code":
1920
+ outputParts.push(`Respond with code${this._output.format.language ? ` in ${this._output.format.language}` : ""}.`);
1921
+ break;
1922
+ case "table":
1923
+ outputParts.push("Format your response as a table.");
1924
+ break;
1925
+ }
1926
+ }
1927
+ if (this._output.length) {
1928
+ outputParts.push(`Keep your response ${this._output.length}.`);
1929
+ }
1930
+ if (this._output.style) {
1931
+ const styleMap = {
1932
+ "prose": "flowing prose",
1933
+ "bullet-points": "bullet points",
1934
+ "numbered-list": "a numbered list",
1935
+ "table": "a table",
1936
+ "code": "code",
1937
+ "mixed": "a mix of prose and lists",
1938
+ "qa": "Q&A format",
1939
+ "dialogue": "dialogue format"
1940
+ };
1941
+ outputParts.push(`Structure as ${styleMap[this._output.style]}.`);
1942
+ }
1943
+ if (this._output.language) {
1944
+ outputParts.push(`Respond in ${this._output.language}.`);
1945
+ }
1946
+ if (this._output.includeExamples) {
1947
+ outputParts.push("Include relevant examples.");
1948
+ }
1949
+ if (this._output.includeExplanation) {
1950
+ outputParts.push("Include clear explanations.");
1951
+ }
1952
+ if (this._output.includeSources) {
1953
+ outputParts.push("Cite your sources.");
1954
+ }
1955
+ if (this._output.includeConfidence) {
1956
+ outputParts.push("Include your confidence level in the answer.");
1957
+ }
1958
+ if (outputParts.length) {
1959
+ parts.push(`## Output Format
1960
+ ${outputParts.join("\n")}`);
1961
+ }
1962
+ }
1963
+ if (this._reasoning) {
1964
+ const reasoningParts = [];
1965
+ if (this._reasoning.style) {
1966
+ const styleInstructions = {
1967
+ "step-by-step": "Think through this step by step.",
1968
+ "chain-of-thought": "Use chain-of-thought reasoning to work through the problem.",
1969
+ "tree-of-thought": "Consider multiple approaches and evaluate each before deciding.",
1970
+ "direct": "Provide a direct answer.",
1971
+ "analytical": "Analyze the problem systematically.",
1972
+ "comparative": "Compare different options or approaches.",
1973
+ "deductive": "Use deductive reasoning from general principles.",
1974
+ "inductive": "Use inductive reasoning from specific examples.",
1975
+ "first-principles": "Reason from first principles, breaking down to fundamental truths.",
1976
+ "analogical": "Use analogies to explain and reason about the problem.",
1977
+ "devil-advocate": "Consider and argue against your own conclusions."
1978
+ };
1979
+ reasoningParts.push(styleInstructions[this._reasoning.style]);
1980
+ }
1981
+ if (this._reasoning.showWork) {
1982
+ reasoningParts.push("Show your reasoning process.");
1983
+ }
1984
+ if (this._reasoning.verifyAnswer) {
1985
+ reasoningParts.push("Verify your answer before presenting it.");
1986
+ }
1987
+ if (this._reasoning.considerAlternatives) {
1988
+ reasoningParts.push("Consider alternative perspectives and solutions.");
1989
+ }
1990
+ if (this._reasoning.explainAssumptions) {
1991
+ reasoningParts.push("Explicitly state any assumptions you make.");
1992
+ }
1993
+ if (reasoningParts.length) {
1994
+ parts.push(`## Reasoning
1995
+ ${reasoningParts.join("\n")}`);
1996
+ }
1997
+ }
1998
+ if (this._memory) {
1999
+ const memoryParts = [];
2000
+ if (this._memory.summary) {
2001
+ memoryParts.push(`Previous conversation summary: ${this._memory.summary}`);
2002
+ }
2003
+ if (this._memory.facts?.length) {
2004
+ memoryParts.push(`Known facts:
2005
+ ${this._memory.facts.map((f) => `- ${f}`).join("\n")}`);
2006
+ }
2007
+ if (this._memory.preferences?.length) {
2008
+ memoryParts.push(`User preferences:
2009
+ ${this._memory.preferences.map((p) => `- ${p}`).join("\n")}`);
2010
+ }
2011
+ if (memoryParts.length) {
2012
+ parts.push(`## Memory
2013
+ ${memoryParts.join("\n")}`);
2014
+ }
2015
+ }
2016
+ if (this._customSystemParts.length) {
2017
+ parts.push(...this._customSystemParts);
2018
+ }
2019
+ return parts.join("\n\n");
2020
+ }
2021
+ build() {
2022
+ const systemPrompt = this.buildSystemPrompt();
2023
+ let messages = [...this._messages];
2024
+ const hasSystemMessage = messages.some((m) => m.role === "system");
2025
+ if (systemPrompt && !hasSystemMessage) {
2026
+ messages = [{ role: "system", content: systemPrompt }, ...messages];
2027
+ } else if (systemPrompt && hasSystemMessage) {
2028
+ messages = messages.map(
2029
+ (m) => m.role === "system" ? { ...m, content: `${systemPrompt}
2030
+
2031
+ ${m.content}` } : m
2032
+ );
2033
+ }
2034
+ if (this._memory?.history) {
2035
+ const systemIdx = messages.findIndex((m) => m.role === "system");
2036
+ const insertIdx = systemIdx >= 0 ? systemIdx + 1 : 0;
2037
+ messages.splice(insertIdx, 0, ...this._memory.history);
2038
+ }
2039
+ const userMessages = messages.filter((m) => m.role === "user");
2040
+ const userPrompt = userMessages.length ? userMessages[userMessages.length - 1].content : void 0;
2041
+ return {
2042
+ messages,
2043
+ systemPrompt,
2044
+ userPrompt,
2045
+ metadata: {
2046
+ persona: this._persona,
2047
+ context: this._context,
2048
+ task: this._task,
2049
+ output: this._output,
2050
+ reasoning: this._reasoning,
2051
+ examples: this._examples.length ? this._examples : void 0
2052
+ }
2053
+ };
2054
+ }
2055
+ // --- Output Methods ---
2056
+ toString() {
2057
+ return this.buildSystemPrompt();
2058
+ }
2059
+ toSystemPrompt() {
2060
+ return this.buildSystemPrompt();
2061
+ }
2062
+ toMessages() {
2063
+ return this.build().messages;
2064
+ }
2065
+ toJSON() {
2066
+ return JSON.stringify(this.build(), null, 2);
2067
+ }
2068
+ toYAML() {
2069
+ return objectToYaml4(this.build());
2070
+ }
2071
+ toMarkdown() {
2072
+ const built = this.build();
2073
+ const sections = ["# Chat Prompt\n"];
2074
+ sections.push("## System Prompt\n```\n" + built.systemPrompt + "\n```\n");
2075
+ if (built.messages.length > 1) {
2076
+ sections.push("## Messages\n");
2077
+ for (const msg of built.messages) {
2078
+ if (msg.role === "system") continue;
2079
+ sections.push(`**${msg.role.toUpperCase()}${msg.name ? ` (${msg.name})` : ""}:**
2080
+ ${msg.content}
2081
+ `);
2082
+ }
2083
+ }
2084
+ return sections.join("\n");
2085
+ }
2086
+ };
2087
+ function objectToYaml4(obj, indent = 0) {
2088
+ const spaces = " ".repeat(indent);
2089
+ const lines = [];
2090
+ for (const [key, value] of Object.entries(obj)) {
2091
+ if (value === void 0 || value === null) continue;
2092
+ if (Array.isArray(value)) {
2093
+ if (value.length === 0) continue;
2094
+ lines.push(`${spaces}${key}:`);
2095
+ for (const item of value) {
2096
+ if (typeof item === "object") {
2097
+ lines.push(`${spaces} -`);
2098
+ lines.push(objectToYaml4(item, indent + 2).replace(/^/gm, " "));
2099
+ } else {
2100
+ lines.push(`${spaces} - ${item}`);
2101
+ }
2102
+ }
2103
+ } else if (typeof value === "object") {
2104
+ lines.push(`${spaces}${key}:`);
2105
+ lines.push(objectToYaml4(value, indent + 1));
2106
+ } else if (typeof value === "string" && value.includes("\n")) {
2107
+ lines.push(`${spaces}${key}: |`);
2108
+ for (const line of value.split("\n")) {
2109
+ lines.push(`${spaces} ${line}`);
2110
+ }
2111
+ } else {
2112
+ lines.push(`${spaces}${key}: ${value}`);
2113
+ }
2114
+ }
2115
+ return lines.join("\n");
2116
+ }
2117
+ function chat() {
2118
+ return new ChatPromptBuilder();
2119
+ }
2120
+ var chatPresets = {
2121
+ /**
2122
+ * Code assistant preset
2123
+ */
2124
+ coder: (language) => {
2125
+ const c = chat().role("expert software developer").expertise("coding").tone("technical");
2126
+ if (language) {
2127
+ c.context(`Programming language: ${language}`);
2128
+ }
2129
+ return c;
2130
+ },
2131
+ /**
2132
+ * Writing assistant preset
2133
+ */
2134
+ writer: (style) => {
2135
+ const c = chat().role("skilled writer and editor").expertise("writing");
2136
+ if (style) {
2137
+ c.tone(style === "creative" ? "creative" : style === "academic" ? "academic" : "professional");
2138
+ }
2139
+ return c;
2140
+ },
2141
+ /**
2142
+ * Teacher/tutor preset
2143
+ */
2144
+ tutor: (subject) => {
2145
+ const c = chat().role("patient and knowledgeable tutor").expertise("teaching").tone(["friendly", "empathetic"]).stepByStep().withExamples();
2146
+ if (subject) {
2147
+ c.domain(subject);
2148
+ }
2149
+ return c;
2150
+ },
2151
+ /**
2152
+ * Analyst preset
2153
+ */
2154
+ analyst: () => {
2155
+ return chat().role("data analyst and researcher").expertise("analysis").tone("analytical").chainOfThought().detailed().withSources();
2156
+ },
2157
+ /**
2158
+ * Socratic dialogue preset
2159
+ */
2160
+ socratic: () => {
2161
+ return chat().role("Socratic philosopher and teacher").tone("socratic").reasoning({ style: "deductive", showWork: true }).avoid(["Give direct answers", "Lecture", "Be condescending"]);
2162
+ },
2163
+ /**
2164
+ * Critic preset
2165
+ */
2166
+ critic: () => {
2167
+ return chat().role("constructive critic").tone(["analytical", "professional"]).devilsAdvocate().detailed().avoid(["Be harsh", "Dismiss ideas without explanation"]);
2168
+ },
2169
+ /**
2170
+ * Brainstormer preset
2171
+ */
2172
+ brainstormer: () => {
2173
+ return chat().role("creative brainstorming partner").tone(["creative", "encouraging"]).expertise("creative").considerAlternatives().avoid(["Dismiss ideas", "Be negative", "Limit creativity"]);
2174
+ },
2175
+ /**
2176
+ * JSON response preset
2177
+ */
2178
+ jsonResponder: (schemaName, schema) => {
2179
+ return chat().role("data processing assistant").tone("concise").jsonSchema(schemaName, schema).avoid(["Include markdown", "Add explanations outside JSON", "Include code fences"]);
2180
+ },
2181
+ /**
2182
+ * Summarizer preset
2183
+ */
2184
+ summarizer: (length = "brief") => {
2185
+ return chat().role("expert summarizer").expertise("analysis").tone("concise").length(length).task("Summarize the provided content, preserving key information");
2186
+ },
2187
+ /**
2188
+ * Translator preset
2189
+ */
2190
+ translator: (targetLanguage) => {
2191
+ return chat().role("professional translator").expertise("languages").responseLanguage(targetLanguage).avoid(["Add commentary", "Change meaning", "Omit content"]);
2192
+ }
2193
+ };
2194
+
2195
+ // src/builder/index.ts
2196
+ var PromptBuilder = class {
2197
+ constructor() {
2198
+ this._constraints = [];
2199
+ this._examples = [];
2200
+ this._variables = [];
2201
+ this._customSections = [];
2202
+ }
2203
+ /**
2204
+ * Set the role/persona for the AI
2205
+ */
2206
+ role(role) {
2207
+ this._role = role;
2208
+ return this;
2209
+ }
2210
+ /**
2211
+ * Alias for role()
2212
+ */
2213
+ persona(persona) {
2214
+ return this.role(persona);
2215
+ }
2216
+ /**
2217
+ * Set the context/background information
2218
+ */
2219
+ context(context) {
2220
+ this._context = context;
2221
+ return this;
2222
+ }
2223
+ /**
2224
+ * Alias for context()
2225
+ */
2226
+ background(background) {
2227
+ return this.context(background);
2228
+ }
2229
+ /**
2230
+ * Set the main task/instruction
2231
+ */
2232
+ task(task) {
2233
+ this._task = task;
2234
+ return this;
2235
+ }
2236
+ /**
2237
+ * Alias for task()
2238
+ */
2239
+ instruction(instruction) {
2240
+ return this.task(instruction);
2241
+ }
2242
+ /**
2243
+ * Add constraints/rules the AI should follow
2244
+ */
2245
+ constraints(constraints) {
2246
+ this._constraints = [...this._constraints, ...constraints];
2247
+ return this;
2248
+ }
2249
+ /**
2250
+ * Add a single constraint
2251
+ */
2252
+ constraint(constraint) {
2253
+ this._constraints.push(constraint);
2254
+ return this;
2255
+ }
2256
+ /**
2257
+ * Alias for constraints()
2258
+ */
2259
+ rules(rules) {
2260
+ return this.constraints(rules);
2261
+ }
2262
+ /**
2263
+ * Set the expected output format
2264
+ */
2265
+ output(format) {
2266
+ this._outputFormat = format;
2267
+ return this;
2268
+ }
2269
+ /**
2270
+ * Alias for output()
2271
+ */
2272
+ format(format) {
2273
+ return this.output(format);
2274
+ }
2275
+ /**
2276
+ * Add an example input/output pair
2277
+ */
2278
+ example(input, output) {
2279
+ this._examples.push({ input, output });
2280
+ return this;
2281
+ }
2282
+ /**
2283
+ * Add multiple examples
2284
+ */
2285
+ examples(examples) {
2286
+ this._examples = [...this._examples, ...examples];
2287
+ return this;
2288
+ }
2289
+ /**
2290
+ * Define a variable placeholder
2291
+ */
2292
+ variable(name, options = {}) {
2293
+ this._variables.push({
2294
+ name,
2295
+ description: options.description,
2296
+ required: options.required ?? true,
2297
+ defaultValue: options.defaultValue
2298
+ });
2299
+ return this;
2300
+ }
2301
+ /**
2302
+ * Add a custom section
2303
+ */
2304
+ section(title, content) {
2305
+ this._customSections.push({ title, content });
2306
+ return this;
2307
+ }
2308
+ /**
2309
+ * Set raw content (bypasses structured building)
2310
+ */
2311
+ raw(content) {
2312
+ this._rawContent = content;
2313
+ return this;
2314
+ }
2315
+ /**
2316
+ * Build the final prompt
2317
+ */
2318
+ build() {
2319
+ if (this._rawContent) {
2320
+ return {
2321
+ content: this._rawContent,
2322
+ variables: this._variables,
2323
+ metadata: {}
2324
+ };
2325
+ }
2326
+ const sections = [];
2327
+ if (this._role) {
2328
+ sections.push(`You are ${this._role}.`);
2329
+ }
2330
+ if (this._context) {
2331
+ sections.push(`
2332
+ ## Context
2333
+ ${this._context}`);
2334
+ }
2335
+ if (this._task) {
2336
+ sections.push(`
2337
+ ## Task
2338
+ ${this._task}`);
2339
+ }
2340
+ if (this._constraints.length > 0) {
2341
+ const constraintsList = this._constraints.map((c, i) => `${i + 1}. ${c}`).join("\n");
2342
+ sections.push(`
2343
+ ## Constraints
2344
+ ${constraintsList}`);
2345
+ }
2346
+ if (this._outputFormat) {
2347
+ sections.push(`
2348
+ ## Output Format
2349
+ ${this._outputFormat}`);
2350
+ }
2351
+ if (this._examples.length > 0) {
2352
+ const examplesText = this._examples.map((e, i) => `### Example ${i + 1}
2353
+ **Input:** ${e.input}
2354
+ **Output:** ${e.output}`).join("\n\n");
2355
+ sections.push(`
2356
+ ## Examples
2357
+ ${examplesText}`);
2358
+ }
2359
+ for (const section of this._customSections) {
2360
+ sections.push(`
2361
+ ## ${section.title}
2362
+ ${section.content}`);
2363
+ }
2364
+ if (this._variables.length > 0) {
2365
+ const varsText = this._variables.map((v) => {
2366
+ const placeholder = v.defaultValue ? `\${${v.name}:${v.defaultValue}}` : `\${${v.name}}`;
2367
+ const desc = v.description ? ` - ${v.description}` : "";
2368
+ const req = v.required ? " (required)" : " (optional)";
2369
+ return `- ${placeholder}${desc}${req}`;
2370
+ }).join("\n");
2371
+ sections.push(`
2372
+ ## Variables
2373
+ ${varsText}`);
2374
+ }
2375
+ return {
2376
+ content: sections.join("\n").trim(),
2377
+ variables: this._variables,
2378
+ metadata: {
2379
+ role: this._role,
2380
+ context: this._context,
2381
+ task: this._task,
2382
+ constraints: this._constraints.length > 0 ? this._constraints : void 0,
2383
+ outputFormat: this._outputFormat,
2384
+ examples: this._examples.length > 0 ? this._examples : void 0
2385
+ }
2386
+ };
2387
+ }
2388
+ /**
2389
+ * Build and return only the content string
2390
+ */
2391
+ toString() {
2392
+ return this.build().content;
2393
+ }
2394
+ };
2395
+ function builder() {
2396
+ return new PromptBuilder();
2397
+ }
2398
+ function fromPrompt(content) {
2399
+ return new PromptBuilder().raw(content);
2400
+ }
2401
+ var templates = {
2402
+ /**
2403
+ * Create a code review prompt
2404
+ */
2405
+ codeReview: (options = {}) => {
2406
+ const b = builder().role("expert code reviewer").task("Review the provided code and identify issues, improvements, and best practices.").variable("code", { required: true, description: "The code to review" });
2407
+ if (options.language) {
2408
+ b.context(`You are reviewing ${options.language} code.`);
2409
+ }
2410
+ if (options.focus && options.focus.length > 0) {
2411
+ b.constraints(options.focus.map((f) => `Focus on ${f}`));
2412
+ }
2413
+ return b.output("Provide a structured review with: issues found, suggestions, and overall assessment.");
2414
+ },
2415
+ /**
2416
+ * Create a translation prompt
2417
+ */
2418
+ translation: (from, to) => {
2419
+ return builder().role(`professional translator fluent in ${from} and ${to}`).task(`Translate the following text from ${from} to ${to}.`).constraints([
2420
+ "Maintain the original meaning and tone",
2421
+ "Use natural, idiomatic expressions in the target language",
2422
+ "Preserve formatting and structure"
2423
+ ]).variable("text", { required: true, description: "Text to translate" });
2424
+ },
2425
+ /**
2426
+ * Create a summarization prompt
2427
+ */
2428
+ summarize: (options = {}) => {
2429
+ const b = builder().role("expert summarizer").task("Summarize the following content concisely while preserving key information.").variable("content", { required: true, description: "Content to summarize" });
2430
+ if (options.maxLength) {
2431
+ b.constraint(`Keep the summary under ${options.maxLength} words`);
2432
+ }
2433
+ if (options.style === "bullet") {
2434
+ b.output("Provide the summary as bullet points");
2435
+ }
2436
+ return b;
2437
+ },
2438
+ /**
2439
+ * Create a Q&A prompt
2440
+ */
2441
+ qa: (context) => {
2442
+ const b = builder().role("helpful assistant").task("Answer the question based on the provided context.").variable("question", { required: true, description: "The question to answer" });
2443
+ if (context) {
2444
+ b.context(context);
2445
+ } else {
2446
+ b.variable("context", { required: false, description: "Additional context" });
2447
+ }
2448
+ return b.constraints([
2449
+ "Be accurate and concise",
2450
+ "If you don't know the answer, say so",
2451
+ "Cite relevant parts of the context if applicable"
2452
+ ]);
2453
+ }
2454
+ };
2455
+ // Annotate the CommonJS export names for ESM import in node:
2456
+ 0 && (module.exports = {
2457
+ AudioPromptBuilder,
2458
+ ChatPromptBuilder,
2459
+ ImagePromptBuilder,
2460
+ PromptBuilder,
2461
+ VideoPromptBuilder,
2462
+ audio,
2463
+ builder,
2464
+ chat,
2465
+ chatPresets,
2466
+ fromPrompt,
2467
+ image,
2468
+ templates,
2469
+ video
2470
+ });
2471
+ //# sourceMappingURL=index.js.map