prompts.chat 0.0.1 → 0.0.2

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 +877 -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
package/README.md ADDED
@@ -0,0 +1,877 @@
1
+ # prompts.chat
2
+
3
+ The **D3.js of prompt engineering** — a comprehensive developer toolkit for building, validating, and parsing AI prompts. Create structured prompts for chat models, image generators, video AI, and music generation with fluent, type-safe APIs.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install prompts.chat
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { builder, chat, image, audio, variables, quality } from 'prompts.chat';
15
+
16
+ // Build structured text prompts
17
+ const prompt = builder()
18
+ .role("Senior TypeScript Developer")
19
+ .task("Review the following code for bugs and improvements")
20
+ .constraints(["Be concise", "Focus on critical issues"])
21
+ .variable("code", { required: true })
22
+ .build();
23
+
24
+ // Build chat prompts with full control
25
+ const chatPrompt = chat()
26
+ .role("expert code reviewer")
27
+ .tone("professional")
28
+ .expertise("TypeScript", "React", "Node.js")
29
+ .task("Review code and provide actionable feedback")
30
+ .stepByStep()
31
+ .json()
32
+ .build();
33
+
34
+ // Build image generation prompts
35
+ const imagePrompt = image()
36
+ .subject("a cyberpunk samurai")
37
+ .environment("neon-lit Tokyo streets")
38
+ .shot("medium")
39
+ .lens("35mm")
40
+ .lightingType("neon")
41
+ .medium("cinematic")
42
+ .build();
43
+
44
+ // Build music generation prompts
45
+ const musicPrompt = audio()
46
+ .genre("electronic")
47
+ .mood("energetic")
48
+ .bpm(128)
49
+ .instruments(["synthesizer", "drums", "bass"])
50
+ .build();
51
+
52
+ // Normalize variable formats
53
+ const normalized = variables.normalize("Hello {{name}}, you are [ROLE]");
54
+ // → "Hello ${name}, you are ${role}"
55
+
56
+ // Check quality locally (no API needed)
57
+ const result = quality.check("Act as a developer...");
58
+ console.log(result.score); // 0.85
59
+ ```
60
+
61
+ ---
62
+
63
+ ## CLI: Create Your Own Instance
64
+
65
+ ```bash
66
+ npx prompts.chat my-prompts
67
+ ```
68
+
69
+ This will:
70
+ 1. Download the latest prompts.chat codebase
71
+ 2. Install dependencies
72
+ 3. Run the interactive setup wizard
73
+
74
+ ### CLI Options
75
+
76
+ | Option | Description |
77
+ |--------|-------------|
78
+ | `[project-name]` | Name of the directory to create |
79
+ | `-y, --yes` | Use defaults, skip interactive prompts |
80
+ | `--no-setup` | Skip the setup wizard |
81
+
82
+ ---
83
+
84
+ ## Modules
85
+
86
+ - [Variables](#-variables) — Variable detection and normalization
87
+ - [Similarity](#-similarity) — Content deduplication
88
+ - [Builder](#️-builder) — Structured text prompts
89
+ - [Chat Builder](#-chat-builder) — Chat/conversational prompts
90
+ - [Image Builder](#-image-builder) — Image generation prompts
91
+ - [Video Builder](#-video-builder) — Video generation prompts
92
+ - [Audio Builder](#-audio-builder) — Music/audio generation prompts
93
+ - [Quality](#-quality) — Prompt validation
94
+ - [Parser](#-parser) — Multi-format parsing
95
+
96
+ ---
97
+
98
+ ## 🔧 Variables
99
+
100
+ Universal variable detection and normalization across different formats.
101
+
102
+ ```typescript
103
+ import { variables } from 'prompts.chat';
104
+
105
+ // Detect variables in any format
106
+ const detected = variables.detect("Hello {{name}}, welcome to [COMPANY]");
107
+ // → [{ name: "name", pattern: "double_curly" }, { name: "COMPANY", pattern: "single_bracket" }]
108
+
109
+ // Normalize all formats to ${var}
110
+ const normalized = variables.normalize("Hello {{name}}, you are [ROLE]");
111
+ // → "Hello ${name}, you are ${role}"
112
+
113
+ // Extract variables from ${var} format
114
+ const vars = variables.extractVariables("Hello ${name:World}");
115
+ // → [{ name: "name", defaultValue: "World" }]
116
+
117
+ // Compile template with values
118
+ const result = variables.compile("Hello ${name:World}", { name: "Developer" });
119
+ // → "Hello Developer"
120
+
121
+ // Get pattern descriptions
122
+ variables.getPatternDescription("double_bracket"); // → "[[...]]"
123
+ ```
124
+
125
+ ### Supported Formats
126
+
127
+ | Format | Example | Pattern Name |
128
+ |--------|---------|--------------|
129
+ | `${var}` | `${name}` | `dollar_curly` |
130
+ | `${var:default}` | `${name:World}` | `dollar_curly` |
131
+ | `{{var}}` | `{{name}}` | `double_curly` |
132
+ | `[[var]]` | `[[name]]` | `double_bracket` |
133
+ | `[VAR]` | `[NAME]` | `single_bracket` |
134
+ | `{VAR}` | `{NAME}` | `single_curly` |
135
+ | `<VAR>` | `<NAME>` | `angle_bracket` |
136
+ | `%VAR%` | `%NAME%` | `percent` |
137
+
138
+ ### API Reference
139
+
140
+ | Function | Description |
141
+ |----------|-------------|
142
+ | `detect(text)` | Detect variables in any format |
143
+ | `normalize(text)` | Convert all formats to `${var}` |
144
+ | `extractVariables(text)` | Extract from `${var}` format |
145
+ | `compile(text, values, options?)` | Replace variables with values |
146
+ | `convertToSupportedFormat(variable)` | Convert a single variable |
147
+ | `getPatternDescription(pattern)` | Get human-readable pattern |
148
+
149
+ ---
150
+
151
+ ## 📊 Similarity
152
+
153
+ Content similarity detection for deduplication using Jaccard and n-gram algorithms.
154
+
155
+ ```typescript
156
+ import { similarity } from 'prompts.chat';
157
+
158
+ // Calculate similarity score (0-1)
159
+ const score = similarity.calculate(prompt1, prompt2);
160
+ // → 0.87
161
+
162
+ // Check if prompts are duplicates (default threshold: 0.85)
163
+ const isDupe = similarity.isDuplicate(prompt1, prompt2, 0.85);
164
+ // → true
165
+
166
+ // Find groups of duplicate prompts
167
+ const groups = similarity.findDuplicates(prompts, 0.85);
168
+ // → [[prompt1, prompt3], [prompt2, prompt5]]
169
+
170
+ // Deduplicate an array (keeps first occurrence)
171
+ const unique = similarity.deduplicate(prompts, 0.85);
172
+
173
+ // Get content fingerprint for indexing
174
+ const fingerprint = similarity.getContentFingerprint(prompt);
175
+
176
+ // Normalize content for comparison
177
+ const normalized = similarity.normalizeContent(text);
178
+ ```
179
+
180
+ ### API Reference
181
+
182
+ | Function | Description |
183
+ |----------|-------------|
184
+ | `calculate(content1, content2)` | Calculate similarity score (0-1) |
185
+ | `isDuplicate(content1, content2, threshold?)` | Check if similar (default 0.85) |
186
+ | `findDuplicates(prompts, threshold?)` | Find groups of duplicates |
187
+ | `deduplicate(prompts, threshold?)` | Remove duplicates |
188
+ | `normalizeContent(content)` | Normalize for comparison |
189
+ | `getContentFingerprint(content)` | Get fingerprint for indexing |
190
+
191
+ ---
192
+
193
+ ## 🏗️ Builder
194
+
195
+ Fluent DSL for creating structured text prompts.
196
+
197
+ ```typescript
198
+ import { builder, fromPrompt, templates } from 'prompts.chat';
199
+
200
+ // Build a custom prompt
201
+ const prompt = builder()
202
+ .role("Senior Developer")
203
+ .context("You are helping review a React application")
204
+ .task("Analyze the code for performance issues")
205
+ .constraints([
206
+ "Be concise",
207
+ "Focus on critical issues",
208
+ "Suggest fixes with code examples"
209
+ ])
210
+ .output("JSON with { issues: [], suggestions: [] }")
211
+ .variable("code", { required: true, description: "Code to review" })
212
+ .example("const x = 1;", '{ "issues": [], "suggestions": [] }')
213
+ .section("Additional Notes", "Consider React 18 best practices")
214
+ .build();
215
+
216
+ console.log(prompt.content);
217
+ console.log(prompt.variables);
218
+ console.log(prompt.metadata);
219
+
220
+ // Create from existing prompt
221
+ const existing = fromPrompt("You are a helpful assistant...").build();
222
+ ```
223
+
224
+ ### Builder Methods
225
+
226
+ | Method | Description |
227
+ |--------|-------------|
228
+ | `.role(role)` | Set AI persona (alias: `.persona()`) |
229
+ | `.context(context)` | Set background info (alias: `.background()`) |
230
+ | `.task(task)` | Set main instruction (alias: `.instruction()`) |
231
+ | `.constraints(list)` | Add multiple constraints (alias: `.rules()`) |
232
+ | `.constraint(text)` | Add single constraint |
233
+ | `.output(format)` | Set output format (alias: `.format()`) |
234
+ | `.example(input, output)` | Add input/output example |
235
+ | `.examples(list)` | Add multiple examples |
236
+ | `.variable(name, options?)` | Define a variable |
237
+ | `.section(title, content)` | Add custom section |
238
+ | `.raw(content)` | Set raw content |
239
+ | `.build()` | Build the prompt |
240
+ | `.toString()` | Get content string |
241
+
242
+ ### Pre-built Templates
243
+
244
+ ```typescript
245
+ import { templates } from 'prompts.chat';
246
+
247
+ // Code review template
248
+ const review = templates.codeReview({
249
+ language: "TypeScript",
250
+ focus: ["performance", "security"]
251
+ });
252
+
253
+ // Translation template
254
+ const translate = templates.translation("English", "Spanish");
255
+
256
+ // Summarization template
257
+ const summary = templates.summarize({
258
+ maxLength: 100,
259
+ style: "bullet"
260
+ });
261
+
262
+ // Q&A template
263
+ const qa = templates.qa("You are answering questions about React.");
264
+ ```
265
+
266
+ ---
267
+
268
+ ## 💬 Chat Builder
269
+
270
+ Model-agnostic builder for conversational AI prompts. Works with GPT-4, Claude, Gemini, and any chat model.
271
+
272
+ ```typescript
273
+ import { chat, chatPresets } from 'prompts.chat';
274
+
275
+ const prompt = chat()
276
+ // Persona
277
+ .role("senior software architect")
278
+ .tone("professional", "analytical")
279
+ .expertise("system design", "microservices", "cloud architecture")
280
+
281
+ // Context
282
+ .context("Designing a scalable e-commerce platform")
283
+ .domain("software engineering")
284
+
285
+ // Task
286
+ .task("Review the architecture proposal and provide feedback")
287
+ .objectives(["Identify bottlenecks", "Suggest improvements"])
288
+
289
+ // Constraints
290
+ .constraints(["Focus on scalability", "Consider cost"])
291
+ .avoid(["Over-engineering", "Vendor lock-in"])
292
+
293
+ // Reasoning
294
+ .stepByStep()
295
+ .showReasoning()
296
+
297
+ // Output
298
+ .json({ schema: { type: "object", properties: { feedback: { type: "array" } } } })
299
+ .detailed()
300
+
301
+ // Examples
302
+ .example("Simple API design", "Consider using API Gateway for rate limiting...")
303
+
304
+ // Messages
305
+ .user("Here's my architecture proposal...")
306
+ .build();
307
+
308
+ // Access outputs
309
+ console.log(prompt.systemPrompt); // Full system prompt
310
+ console.log(prompt.messages); // Message array
311
+ console.log(prompt.userPrompt); // Latest user message
312
+
313
+ // Output formats
314
+ const yaml = prompt.toYAML();
315
+ const md = prompt.toMarkdown();
316
+ const json = prompt.toJSON();
317
+ ```
318
+
319
+ ### Chat Builder Methods
320
+
321
+ #### Persona
322
+ | Method | Description |
323
+ |--------|-------------|
324
+ | `.role(role)` | Set the AI's role |
325
+ | `.tone(tones...)` | Set communication tone(s) |
326
+ | `.expertise(areas...)` | Define expertise areas |
327
+ | `.personality(traits...)` | Set personality traits |
328
+
329
+ #### Context
330
+ | Method | Description |
331
+ |--------|-------------|
332
+ | `.context(text)` | Set situation context |
333
+ | `.domain(domain)` | Set knowledge domain |
334
+ | `.audience(audience)` | Define target audience |
335
+ | `.background(text)` | Add background info |
336
+
337
+ #### Task
338
+ | Method | Description |
339
+ |--------|-------------|
340
+ | `.task(description)` | Main task description |
341
+ | `.objectives(list)` | Add objectives |
342
+ | `.scope(scope)` | Define scope |
343
+ | `.priority(priority)` | Set priority |
344
+
345
+ #### Constraints
346
+ | Method | Description |
347
+ |--------|-------------|
348
+ | `.constraints(list)` | Must-follow rules |
349
+ | `.avoid(list)` | Things to avoid |
350
+ | `.requirements(list)` | Requirements |
351
+
352
+ #### Reasoning
353
+ | Method | Description |
354
+ |--------|-------------|
355
+ | `.stepByStep()` | Enable step-by-step reasoning |
356
+ | `.showReasoning()` | Show reasoning process |
357
+ | `.thinkFirst()` | Think before answering |
358
+ | `.socratic()` | Use Socratic method |
359
+
360
+ #### Output
361
+ | Method | Description |
362
+ |--------|-------------|
363
+ | `.json(schema?)` | Output as JSON |
364
+ | `.markdown()` | Output as Markdown |
365
+ | `.yaml()` | Output as YAML |
366
+ | `.xml()` | Output as XML |
367
+ | `.code(language?)` | Output as code |
368
+ | `.concise()` | Brief output |
369
+ | `.detailed()` | Detailed output |
370
+ | `.comprehensive()` | Comprehensive output |
371
+
372
+ #### Messages
373
+ | Method | Description |
374
+ |--------|-------------|
375
+ | `.system(content)` | Add system message |
376
+ | `.user(content)` | Add user message |
377
+ | `.assistant(content)` | Add assistant message |
378
+ | `.example(input, output)` | Add few-shot example |
379
+ | `.memory(key, value, priority?)` | Store memory |
380
+
381
+ ### Chat Presets
382
+
383
+ ```typescript
384
+ import { chatPresets } from 'prompts.chat';
385
+
386
+ // Expert coder
387
+ const coder = chatPresets.coder("TypeScript");
388
+
389
+ // Creative writer
390
+ const writer = chatPresets.writer("technical");
391
+
392
+ // Patient tutor
393
+ const tutor = chatPresets.tutor("mathematics");
394
+
395
+ // Data analyst
396
+ const analyst = chatPresets.analyst();
397
+
398
+ // Socratic teacher
399
+ const socratic = chatPresets.socratic();
400
+
401
+ // JSON responder
402
+ const jsonBot = chatPresets.jsonResponder({
403
+ type: "object",
404
+ properties: { answer: { type: "string" } }
405
+ });
406
+
407
+ // Summarizer
408
+ const summarizer = chatPresets.summarizer(100);
409
+
410
+ // Translator
411
+ const translator = chatPresets.translator("English", "Japanese");
412
+ ```
413
+
414
+ ---
415
+
416
+ ## 🎨 Image Builder
417
+
418
+ Comprehensive builder for image generation prompts (Midjourney, DALL-E, Stable Diffusion, etc.).
419
+
420
+ ```typescript
421
+ import { image } from 'prompts.chat';
422
+
423
+ const prompt = image()
424
+ // Subject
425
+ .subject("a cyberpunk samurai warrior")
426
+ .subjectDetails({
427
+ pose: "dynamic battle stance",
428
+ expression: "determined",
429
+ clothing: "neon-lit armor with glowing circuits",
430
+ accessories: ["katana", "holographic visor"]
431
+ })
432
+
433
+ // Environment
434
+ .environment("rain-soaked Tokyo alley")
435
+ .setting("urban", "futuristic")
436
+ .atmosphere("electric", "mysterious")
437
+ .weather("rain")
438
+ .timeOfDay("night")
439
+
440
+ // Camera
441
+ .shot("medium")
442
+ .angle("low-angle")
443
+ .lens("35mm")
444
+ .aperture("f/1.8")
445
+ .focus("sharp")
446
+ .cameraBrand("Sony")
447
+ .cameraModel("A7R V")
448
+ .bokeh("smooth")
449
+
450
+ // Lighting
451
+ .lightingType("neon")
452
+ .lightingDirection("rim")
453
+ .lightingIntensity("dramatic")
454
+
455
+ // Style
456
+ .medium("cinematic")
457
+ .artStyle("cyberpunk")
458
+ .artist("Syd Mead")
459
+ .era("futuristic")
460
+ .filmStock("Kodak Vision3 500T")
461
+
462
+ // Color
463
+ .colorPalette("cyberpunk")
464
+ .colorGrade("teal and orange")
465
+ .saturation("vibrant")
466
+
467
+ // Technical
468
+ .resolution("8K")
469
+ .quality("ultra-detailed")
470
+ .aspectRatio("16:9")
471
+ .build();
472
+
473
+ console.log(prompt.prompt); // Text prompt
474
+ console.log(prompt.negativePrompt); // Negative prompt
475
+
476
+ // Output formats
477
+ const json = prompt.toJSON();
478
+ const yaml = prompt.toYAML();
479
+ const md = prompt.toMarkdown();
480
+ ```
481
+
482
+ ### Camera Options
483
+
484
+ | Category | Examples |
485
+ |----------|----------|
486
+ | **Brands** | Canon, Nikon, Sony, ARRI, RED, Hasselblad, Leica, Fujifilm |
487
+ | **Shot Types** | extreme-close-up, close-up, medium, full, wide, aerial |
488
+ | **Angles** | eye-level, low-angle, high-angle, dutch, bird's-eye, worm's-eye |
489
+ | **Lens Types** | wide, standard, telephoto, macro, fisheye, anamorphic |
490
+ | **Film Stocks** | Kodak Portra, Fuji Velvia, Kodak Vision3, Ilford HP5 |
491
+
492
+ ### Lighting Options
493
+
494
+ | Type | Examples |
495
+ |------|----------|
496
+ | **Lighting Types** | natural, studio, rim, butterfly, rembrandt, neon, volumetric |
497
+ | **Time of Day** | golden-hour, blue-hour, midday, sunset, night, dawn |
498
+ | **Weather** | clear, cloudy, rain, snow, fog, storm |
499
+
500
+ ### Style Options
501
+
502
+ | Category | Examples |
503
+ |----------|----------|
504
+ | **Art Styles** | photorealistic, anime, oil-painting, watercolor, cyberpunk, art-deco |
505
+ | **Mediums** | photography, cinematic, illustration, 3d-render, concept-art |
506
+ | **Color Palettes** | warm, cool, pastel, neon, monochrome, vintage |
507
+
508
+ ---
509
+
510
+ ## � Video Builder
511
+
512
+ Builder for video generation prompts (Sora, Runway, Pika, etc.).
513
+
514
+ ```typescript
515
+ import { video } from 'prompts.chat';
516
+
517
+ const prompt = video()
518
+ // Scene
519
+ .scene("A lone astronaut walks across the Martian surface")
520
+ .location("Mars", "Olympus Mons base camp")
521
+ .environment("dusty red landscape", "thin atmosphere")
522
+ .time("dusk")
523
+ .weather("dust storm approaching")
524
+
525
+ // Subject
526
+ .character("astronaut", {
527
+ appearance: "NASA spacesuit, reflective visor",
528
+ action: "walking purposefully",
529
+ emotion: "determined"
530
+ })
531
+
532
+ // Camera
533
+ .movement("tracking")
534
+ .shot("wide")
535
+ .angle("low-angle")
536
+ .speed("slow")
537
+ .lens("anamorphic")
538
+ .cameraBrand("ARRI")
539
+ .cameraModel("ALEXA 65")
540
+ .stabilization("gimbal")
541
+
542
+ // Motion
543
+ .pacing("slow")
544
+ .transitions("fade")
545
+ .motionBlur(true)
546
+
547
+ // Lighting
548
+ .lightingType("golden hour")
549
+ .lightingMood("epic")
550
+
551
+ // Style
552
+ .style("cinematic")
553
+ .colorGrade("orange and teal")
554
+ .filmGrain("subtle")
555
+ .styleFilmStock("Kodak Vision3 500T")
556
+
557
+ // Audio
558
+ .audioMood("epic orchestral")
559
+ .soundDesign("wind, footsteps, breathing")
560
+
561
+ // Technical
562
+ .duration(10)
563
+ .fps(24)
564
+ .resolution("4K")
565
+ .aspectRatio("2.39:1")
566
+ .build();
567
+
568
+ console.log(prompt.prompt);
569
+ console.log(prompt.structure);
570
+
571
+ // Output formats
572
+ const json = prompt.toJSON();
573
+ const yaml = prompt.toYAML();
574
+ ```
575
+
576
+ ### Video-Specific Options
577
+
578
+ | Category | Examples |
579
+ |----------|----------|
580
+ | **Camera Movement** | static, pan, tilt, dolly, tracking, crane, handheld, drone |
581
+ | **Transitions** | cut, fade, dissolve, wipe, zoom |
582
+ | **Pacing** | slow-motion, normal, fast-motion, timelapse |
583
+ | **Frame Rates** | 24, 30, 60, 120 fps |
584
+
585
+ ---
586
+
587
+ ## 🎵 Audio Builder
588
+
589
+ Builder for music and audio generation prompts (Suno, Udio, etc.).
590
+
591
+ ```typescript
592
+ import { audio } from 'prompts.chat';
593
+
594
+ const prompt = audio()
595
+ // Genre & Style
596
+ .genre("electronic")
597
+ .subgenre("synthwave")
598
+ .era("1980s")
599
+ .influences(["Kavinsky", "Carpenter Brut", "Perturbator"])
600
+
601
+ // Mood & Energy
602
+ .mood("nostalgic")
603
+ .energy("high")
604
+ .emotion("triumphant")
605
+
606
+ // Tempo & Rhythm
607
+ .bpm(120)
608
+ .feel("driving")
609
+ .groove("steady")
610
+
611
+ // Vocals
612
+ .vocalStyle("ethereal")
613
+ .vocalRange("tenor")
614
+ .lyrics("retro-futuristic themes")
615
+ .harmony("layered")
616
+
617
+ // Instrumentation
618
+ .instruments(["synthesizer", "drums", "bass", "electric guitar"])
619
+ .lead("analog synth lead")
620
+ .rhythm("drum machine")
621
+ .bass("deep sub bass")
622
+ .pads("lush synth pads")
623
+
624
+ // Structure
625
+ .intro("atmospheric build")
626
+ .verse("rhythmic drive")
627
+ .chorus("anthemic climax")
628
+ .bridge("breakdown")
629
+ .outro("fade out")
630
+ .duration(210) // 3:30
631
+
632
+ // Production
633
+ .productionStyle("polished")
634
+ .mixing("wide stereo")
635
+ .effects(["reverb", "delay", "sidechain compression"])
636
+
637
+ // Technical
638
+ .key("A minor")
639
+ .timeSignature("4/4")
640
+ .build();
641
+
642
+ console.log(prompt.stylePrompt);
643
+ console.log(prompt.lyricsPrompt);
644
+ console.log(prompt.structure);
645
+
646
+ // Output formats
647
+ const json = prompt.toJSON();
648
+ const yaml = prompt.toYAML();
649
+ ```
650
+
651
+ ### Audio Options
652
+
653
+ | Category | Examples |
654
+ |----------|----------|
655
+ | **Genres** | pop, rock, jazz, classical, electronic, hip-hop, ambient, cinematic |
656
+ | **Moods** | happy, sad, energetic, calm, dark, uplifting, melancholic |
657
+ | **Instruments** | piano, guitar, drums, bass, synthesizer, violin, saxophone |
658
+ | **Vocal Styles** | clean, breathy, raspy, falsetto, operatic, whispered |
659
+ | **Keys** | C major, A minor, G major, E minor, etc. |
660
+ | **Time Signatures** | 4/4, 3/4, 6/8, 5/4, 7/8 |
661
+
662
+ ---
663
+
664
+ ## ✅ Quality
665
+
666
+ Local prompt quality validation (no API required).
667
+
668
+ ```typescript
669
+ import { quality } from 'prompts.chat';
670
+
671
+ // Check prompt quality
672
+ const result = quality.check("Act as a senior developer...");
673
+
674
+ console.log(result.valid); // true
675
+ console.log(result.score); // 0.85 (0-1)
676
+ console.log(result.issues); // Array of issues
677
+ console.log(result.stats); // Detailed statistics
678
+
679
+ // Statistics include:
680
+ // - characterCount, wordCount, sentenceCount
681
+ // - variableCount
682
+ // - hasRole, hasTask, hasConstraints, hasExamples
683
+
684
+ // Validate (throws if invalid)
685
+ quality.validate(promptText);
686
+
687
+ // Check validity
688
+ const isValid = quality.isValid(promptText);
689
+
690
+ // Get improvement suggestions
691
+ const suggestions = quality.getSuggestions(promptText);
692
+ // → ["Add a role definition", "Consider adding examples"]
693
+ ```
694
+
695
+ ### Quality Checks
696
+
697
+ | Check | Type | Description |
698
+ |-------|------|-------------|
699
+ | `EMPTY` | error | Prompt is empty |
700
+ | `TOO_SHORT` | error | Below minimum length |
701
+ | `GIBBERISH` | error | Random/keyboard patterns |
702
+ | `FEW_WORDS` | warning | Very few words |
703
+ | `UNBALANCED_BRACKETS` | warning | Mismatched brackets |
704
+ | `LONG_LINES` | suggestion | Lines over 500 chars |
705
+ | `NO_CLEAR_INSTRUCTION` | suggestion | Missing role or task |
706
+
707
+ ---
708
+
709
+ ## 📄 Parser
710
+
711
+ Parse prompt files in YAML, JSON, Markdown, and plain text formats.
712
+
713
+ ```typescript
714
+ import { parser } from 'prompts.chat';
715
+
716
+ // Auto-detect format
717
+ const prompt = parser.parse(content);
718
+
719
+ // Parse YAML
720
+ const yamlPrompt = parser.parse(`
721
+ name: Code Review
722
+ model: gpt-4
723
+ modelParameters:
724
+ temperature: 0.7
725
+ messages:
726
+ - role: system
727
+ content: You are a code reviewer.
728
+ `, 'yaml');
729
+
730
+ // Parse JSON
731
+ const jsonPrompt = parser.parse(`{
732
+ "name": "Assistant",
733
+ "messages": [{"role": "system", "content": "You are helpful."}]
734
+ }`, 'json');
735
+
736
+ // Parse Markdown with frontmatter
737
+ const mdPrompt = parser.parse(`
738
+ ---
739
+ name: Creative Writer
740
+ model: gpt-4
741
+ ---
742
+ You are a creative writing assistant.
743
+ `, 'markdown');
744
+
745
+ // Parse plain text (becomes system message)
746
+ const textPrompt = parser.parse("You are a helpful assistant.", 'text');
747
+
748
+ // Serialize
749
+ const yaml = parser.toYaml(prompt);
750
+ const json = parser.toJson(prompt, true); // pretty print
751
+
752
+ // Get system message
753
+ const systemPrompt = parser.getSystemPrompt(prompt);
754
+
755
+ // Interpolate variables
756
+ const filled = parser.interpolate(prompt, { name: "John" });
757
+ ```
758
+
759
+ ### ParsedPrompt Structure
760
+
761
+ ```typescript
762
+ interface ParsedPrompt {
763
+ name?: string;
764
+ description?: string;
765
+ model?: string;
766
+ modelParameters?: {
767
+ temperature?: number;
768
+ maxTokens?: number;
769
+ topP?: number;
770
+ frequencyPenalty?: number;
771
+ presencePenalty?: number;
772
+ };
773
+ messages: PromptMessage[];
774
+ variables?: Record<string, {
775
+ description?: string;
776
+ default?: string;
777
+ required?: boolean;
778
+ }>;
779
+ metadata?: Record<string, unknown>;
780
+ }
781
+ ```
782
+
783
+ ---
784
+
785
+ ## Tree-Shakeable Imports
786
+
787
+ Import only what you need for smaller bundles:
788
+
789
+ ```typescript
790
+ // Full namespace imports
791
+ import { variables, similarity, quality, parser } from 'prompts.chat';
792
+
793
+ // Direct builder imports
794
+ import { builder, chat, image, video, audio } from 'prompts.chat';
795
+ import { templates, chatPresets } from 'prompts.chat';
796
+
797
+ // Direct module imports (smallest bundle)
798
+ import { detect, normalize, compile } from 'prompts.chat/variables';
799
+ import { calculate, isDuplicate } from 'prompts.chat/similarity';
800
+ import { check, validate, getSuggestions } from 'prompts.chat/quality';
801
+ import { parse, toYaml, toJson } from 'prompts.chat/parser';
802
+ import { builder, templates } from 'prompts.chat/builder';
803
+ ```
804
+
805
+ ---
806
+
807
+ ## TypeScript Support
808
+
809
+ Full TypeScript support with comprehensive type exports:
810
+
811
+ ```typescript
812
+ import type {
813
+ // Variables
814
+ DetectedVariable,
815
+ VariablePattern,
816
+
817
+ // Builder
818
+ BuiltPrompt,
819
+ PromptVariable,
820
+
821
+ // Chat
822
+ BuiltChatPrompt,
823
+ ChatMessage,
824
+ ChatPersona,
825
+ PersonaTone,
826
+ ReasoningStyle,
827
+
828
+ // Image
829
+ BuiltImagePrompt,
830
+ ImageSubject,
831
+ ImageCamera,
832
+ CameraAngle,
833
+ ShotType,
834
+ LensType,
835
+
836
+ // Video
837
+ BuiltVideoPrompt,
838
+ VideoScene,
839
+ VideoCamera,
840
+
841
+ // Audio
842
+ BuiltAudioPrompt,
843
+ MusicGenre,
844
+ Instrument,
845
+
846
+ // Quality
847
+ QualityResult,
848
+ QualityIssue,
849
+
850
+ // Parser
851
+ ParsedPrompt,
852
+ PromptMessage,
853
+ } from 'prompts.chat';
854
+ ```
855
+
856
+ ---
857
+
858
+ ## Requirements
859
+
860
+ - **Node.js** 18+
861
+ - **TypeScript** 5+ (optional, for type checking)
862
+
863
+ ---
864
+
865
+ ## Testing
866
+
867
+ ```bash
868
+ npm test # Run all tests
869
+ npm run test:watch # Watch mode
870
+ npm run test:coverage # With coverage
871
+ ```
872
+
873
+ ---
874
+
875
+ ## License
876
+
877
+ MIT © [Fatih Kadir Akın](https://github.com/f)