prompts.chat 0.0.6 → 0.0.8

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 (41) hide show
  1. package/bin/cli.js +2 -0
  2. package/dist/builder/{index.mjs → index.cjs} +255 -3
  3. package/dist/builder/index.cjs.map +1 -0
  4. package/dist/builder/{index.d.mts → index.d.cts} +83 -0
  5. package/dist/builder/index.d.ts +83 -0
  6. package/dist/builder/index.js +215 -41
  7. package/dist/builder/index.js.map +1 -1
  8. package/dist/cli/index.js +1132 -0
  9. package/dist/cli/index.js.map +1 -0
  10. package/dist/{index.mjs → index.cjs} +285 -13
  11. package/dist/index.cjs.map +1 -0
  12. package/dist/{index.d.mts → index.d.cts} +5 -5
  13. package/dist/index.js +225 -71
  14. package/dist/index.js.map +1 -1
  15. package/dist/parser/{index.mjs → index.cjs} +32 -3
  16. package/dist/parser/{index.mjs.map → index.cjs.map} +1 -1
  17. package/dist/parser/{index.d.mts → index.d.cts} +1 -1
  18. package/dist/parser/index.js +2 -31
  19. package/dist/parser/index.js.map +1 -1
  20. package/dist/quality/{index.mjs → index.cjs} +31 -3
  21. package/dist/quality/{index.mjs.map → index.cjs.map} +1 -1
  22. package/dist/quality/{index.d.mts → index.d.cts} +1 -1
  23. package/dist/quality/index.js +2 -30
  24. package/dist/quality/index.js.map +1 -1
  25. package/dist/similarity/{index.mjs → index.cjs} +35 -3
  26. package/dist/similarity/{index.mjs.map → index.cjs.map} +1 -1
  27. package/dist/similarity/{index.d.mts → index.d.cts} +1 -1
  28. package/dist/similarity/index.js +2 -34
  29. package/dist/similarity/index.js.map +1 -1
  30. package/dist/variables/{index.mjs → index.cjs} +35 -3
  31. package/dist/variables/{index.mjs.map → index.cjs.map} +1 -1
  32. package/dist/variables/{index.d.mts → index.d.cts} +1 -1
  33. package/dist/variables/index.js +2 -34
  34. package/dist/variables/index.js.map +1 -1
  35. package/package.json +18 -1
  36. package/dist/builder/index.mjs.map +0 -1
  37. package/dist/index.mjs.map +0 -1
  38. /package/dist/{index-BEIO8LCd.d.mts → index-BEIO8LCd.d.cts} +0 -0
  39. /package/dist/{index-CSHEKYfQ.d.mts → index-CSHEKYfQ.d.cts} +0 -0
  40. /package/dist/{index-D41E6D9X.d.mts → index-D41E6D9X.d.cts} +0 -0
  41. /package/dist/{index-DOz8zcA0.d.mts → index-DOz8zcA0.d.cts} +0 -0
@@ -1,5 +1,5 @@
1
- export { D as DetectedVariable, V as VariablePattern, b as compile, a as convertAllVariables, c as convertToSupportedFormat, d as detectVariables, f as detectVars, e as extractVariables, n as normalizeVariables, i as variables } from './index-DOz8zcA0.mjs';
2
- export { c as calculateSimilarity, d as deduplicate, f as findDuplicates, g as getContentFingerprint, a as isSimilarContent, n as normalizeContent, i as similarity } from './index-BEIO8LCd.mjs';
3
- export { b as QualityIssue, Q as QualityResult, c as checkQuality, g as getSuggestions, a as isValidPrompt, i as quality, v as validatePrompt } from './index-CSHEKYfQ.mjs';
4
- export { P as ParsedPrompt, c as PromptMessage, g as getSystemPrompt, b as interpolate, p as parsePrompt, i as parser, a as toJson, t as toYaml } from './index-D41E6D9X.mjs';
5
- export { AudioPromptBuilder, BuiltAudioPrompt, BuiltChatPrompt, BuiltImagePrompt, BuiltPrompt, BuiltVideoPrompt, ChatPromptBuilder, ImagePromptBuilder, PromptBuilder, PromptVariable, VideoPromptBuilder, audio, builder, chat, chatPresets, fromPrompt, image, templates, video } from './builder/index.mjs';
1
+ export { D as DetectedVariable, V as VariablePattern, b as compile, a as convertAllVariables, c as convertToSupportedFormat, d as detectVariables, f as detectVars, e as extractVariables, n as normalizeVariables, i as variables } from './index-DOz8zcA0.cjs';
2
+ export { c as calculateSimilarity, d as deduplicate, f as findDuplicates, g as getContentFingerprint, a as isSimilarContent, n as normalizeContent, i as similarity } from './index-BEIO8LCd.cjs';
3
+ export { b as QualityIssue, Q as QualityResult, c as checkQuality, g as getSuggestions, a as isValidPrompt, i as quality, v as validatePrompt } from './index-CSHEKYfQ.cjs';
4
+ export { P as ParsedPrompt, c as PromptMessage, g as getSystemPrompt, b as interpolate, p as parsePrompt, i as parser, a as toJson, t as toYaml } from './index-D41E6D9X.cjs';
5
+ export { AudioPromptBuilder, BuiltAudioPrompt, BuiltChatPrompt, BuiltImagePrompt, BuiltPrompt, BuiltVideoPrompt, ChatPromptBuilder, ImagePromptBuilder, PromptBuilder, PromptVariable, VideoPromptBuilder, audio, builder, chat, chatPresets, fromPrompt, image, templates, video } from './builder/index.cjs';
package/dist/index.js CHANGED
@@ -1,66 +1,8 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
2
  var __export = (target, all) => {
7
3
  for (var name in all)
8
4
  __defProp(target, name, { get: all[name], enumerable: true });
9
5
  };
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/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- AudioPromptBuilder: () => AudioPromptBuilder,
24
- ChatPromptBuilder: () => ChatPromptBuilder,
25
- ImagePromptBuilder: () => ImagePromptBuilder,
26
- PromptBuilder: () => PromptBuilder,
27
- VideoPromptBuilder: () => VideoPromptBuilder,
28
- audio: () => audio,
29
- builder: () => builder,
30
- calculateSimilarity: () => calculateSimilarity,
31
- chat: () => chat,
32
- chatPresets: () => chatPresets,
33
- checkQuality: () => check,
34
- compile: () => compile,
35
- convertAllVariables: () => convertAllVariables,
36
- convertToSupportedFormat: () => convertToSupportedFormat,
37
- deduplicate: () => deduplicate,
38
- detectVariables: () => detectVariables,
39
- detectVars: () => detect,
40
- extractVariables: () => extractVariables,
41
- findDuplicates: () => findDuplicates,
42
- fromPrompt: () => fromPrompt,
43
- getContentFingerprint: () => getContentFingerprint,
44
- getSuggestions: () => getSuggestions,
45
- getSystemPrompt: () => getSystemPrompt,
46
- image: () => image,
47
- interpolate: () => interpolate,
48
- isSimilarContent: () => isSimilarContent,
49
- isValidPrompt: () => isValid,
50
- normalizeContent: () => normalizeContent,
51
- normalizeVariables: () => normalize,
52
- parsePrompt: () => parse,
53
- parser: () => parser_exports,
54
- quality: () => quality_exports,
55
- similarity: () => similarity_exports,
56
- templates: () => templates,
57
- toJson: () => toJson,
58
- toYaml: () => toYaml,
59
- validatePrompt: () => validate,
60
- variables: () => variables_exports,
61
- video: () => video
62
- });
63
- module.exports = __toCommonJS(src_exports);
64
6
 
65
7
  // src/variables/index.ts
66
8
  var variables_exports = {};
@@ -3288,10 +3230,222 @@ var templates = {
3288
3230
  "If you don't know the answer, say so",
3289
3231
  "Cite relevant parts of the context if applicable"
3290
3232
  ]);
3233
+ },
3234
+ /**
3235
+ * Create a debugging prompt
3236
+ */
3237
+ debug: (options = {}) => {
3238
+ const b = builder().role("expert software debugger").task("Analyze the code and error, identify the root cause, and provide a fix.").variable("code", { required: true, description: "The code with the bug" }).variable("error", { required: false, description: "Error message or unexpected behavior" });
3239
+ if (options.language) {
3240
+ b.context(`Debugging ${options.language} code.`);
3241
+ }
3242
+ if (options.errorType) {
3243
+ b.context(`The error appears to be related to: ${options.errorType}`);
3244
+ }
3245
+ return b.constraints([
3246
+ "Identify the root cause, not just symptoms",
3247
+ "Explain why the bug occurs",
3248
+ "Provide a working fix with explanation"
3249
+ ]).output("1. Root cause analysis\n2. Explanation\n3. Fixed code\n4. Prevention tips");
3250
+ },
3251
+ /**
3252
+ * Create a writing assistant prompt
3253
+ */
3254
+ write: (options = {}) => {
3255
+ const typeDescriptions = {
3256
+ blog: "engaging blog post",
3257
+ email: "professional email",
3258
+ essay: "well-structured essay",
3259
+ story: "creative story",
3260
+ documentation: "clear technical documentation"
3261
+ };
3262
+ const b = builder().role("skilled writer").task(`Write a ${typeDescriptions[options.type || "blog"] || "piece of content"} based on the given topic or outline.`).variable("topic", { required: true, description: "Topic or outline to write about" });
3263
+ if (options.tone) {
3264
+ b.constraint(`Use a ${options.tone} tone throughout`);
3265
+ }
3266
+ return b.constraints([
3267
+ "Use clear and engaging language",
3268
+ "Structure content logically",
3269
+ "Maintain consistent voice and style"
3270
+ ]);
3271
+ },
3272
+ /**
3273
+ * Create an explanation/teaching prompt
3274
+ */
3275
+ explain: (options = {}) => {
3276
+ const levelDescriptions = {
3277
+ beginner: "someone new to the topic with no prior knowledge",
3278
+ intermediate: "someone with basic understanding who wants to go deeper",
3279
+ expert: "an expert who wants technical precision and nuance"
3280
+ };
3281
+ const b = builder().role("expert teacher and communicator").task("Explain the concept clearly and thoroughly.").variable("concept", { required: true, description: "The concept to explain" });
3282
+ if (options.level) {
3283
+ b.context(`Target audience: ${levelDescriptions[options.level]}`);
3284
+ }
3285
+ if (options.useAnalogies) {
3286
+ b.constraint("Use relatable analogies and real-world examples");
3287
+ }
3288
+ return b.constraints([
3289
+ "Break down complex ideas into digestible parts",
3290
+ "Build understanding progressively",
3291
+ "Anticipate and address common misconceptions"
3292
+ ]);
3293
+ },
3294
+ /**
3295
+ * Create a data extraction prompt
3296
+ */
3297
+ extract: (options = {}) => {
3298
+ const b = builder().role("data extraction specialist").task("Extract structured data from the provided text.").variable("text", { required: true, description: "Text to extract data from" });
3299
+ if (options.fields && options.fields.length > 0) {
3300
+ b.context(`Fields to extract: ${options.fields.join(", ")}`);
3301
+ }
3302
+ if (options.format) {
3303
+ b.output(`Return extracted data in ${options.format.toUpperCase()} format`);
3304
+ }
3305
+ return b.constraints([
3306
+ "Extract only factual information present in the text",
3307
+ "Use null or empty values for missing fields",
3308
+ "Maintain consistent formatting"
3309
+ ]);
3310
+ },
3311
+ /**
3312
+ * Create a brainstorming prompt
3313
+ */
3314
+ brainstorm: (options = {}) => {
3315
+ const b = builder().role("creative strategist and ideation expert").task("Generate diverse and innovative ideas based on the given topic or challenge.").variable("topic", { required: true, description: "Topic or challenge to brainstorm about" });
3316
+ if (options.count) {
3317
+ b.constraint(`Generate exactly ${options.count} ideas`);
3318
+ }
3319
+ if (options.creative) {
3320
+ b.constraint("Include unconventional and out-of-the-box ideas");
3321
+ }
3322
+ return b.constraints([
3323
+ "Ensure ideas are distinct and varied",
3324
+ "Consider different perspectives and approaches",
3325
+ "Make ideas actionable when possible"
3326
+ ]).output("List each idea with a brief description and potential benefits");
3327
+ },
3328
+ /**
3329
+ * Create a code refactoring prompt
3330
+ */
3331
+ refactor: (options = {}) => {
3332
+ const goalDescriptions = {
3333
+ readability: "improving code readability and clarity",
3334
+ performance: "optimizing performance and efficiency",
3335
+ maintainability: "enhancing maintainability and extensibility",
3336
+ all: "overall code quality improvement"
3337
+ };
3338
+ const b = builder().role("senior software engineer specializing in code quality").task(`Refactor the code with focus on ${goalDescriptions[options.goal || "all"]}.`).variable("code", { required: true, description: "Code to refactor" });
3339
+ if (options.language) {
3340
+ b.context(`The code is written in ${options.language}.`);
3341
+ }
3342
+ return b.constraints([
3343
+ "Preserve existing functionality",
3344
+ "Follow language best practices and idioms",
3345
+ "Explain each significant change"
3346
+ ]).output("1. Refactored code\n2. List of changes made\n3. Explanation of improvements");
3347
+ },
3348
+ /**
3349
+ * Create an API documentation prompt
3350
+ */
3351
+ apiDocs: (options = {}) => {
3352
+ const b = builder().role("technical documentation writer").task("Generate comprehensive API documentation for the provided code or endpoint.").variable("code", { required: true, description: "API code or endpoint definition" });
3353
+ if (options.style) {
3354
+ b.output(`Format documentation in ${options.style.toUpperCase()} style`);
3355
+ }
3356
+ if (options.includeExamples) {
3357
+ b.constraint("Include request/response examples for each endpoint");
3358
+ }
3359
+ return b.constraints([
3360
+ "Document all parameters with types and descriptions",
3361
+ "Include error responses and status codes",
3362
+ "Be precise and developer-friendly"
3363
+ ]);
3364
+ },
3365
+ /**
3366
+ * Create a unit test generation prompt
3367
+ */
3368
+ unitTest: (options = {}) => {
3369
+ const b = builder().role("test automation engineer").task("Generate unit tests for the provided code.").variable("code", { required: true, description: "Code to generate tests for" });
3370
+ if (options.framework) {
3371
+ b.context(`Use ${options.framework} testing framework.`);
3372
+ }
3373
+ const coverageConstraints = options.coverage === "comprehensive" ? ["Cover all code paths including edge cases", "Test error handling scenarios", "Include boundary value tests"] : ["Cover main functionality", "Include basic edge cases"];
3374
+ return b.constraints([
3375
+ ...coverageConstraints,
3376
+ "Write clear, descriptive test names",
3377
+ "Follow AAA pattern (Arrange, Act, Assert)"
3378
+ ]).output("Complete, runnable test file");
3379
+ },
3380
+ /**
3381
+ * Create a commit message prompt
3382
+ */
3383
+ commitMessage: (options = {}) => {
3384
+ const b = builder().role("developer with excellent communication skills").task("Generate a clear and descriptive commit message for the provided code changes.").variable("diff", { required: true, description: "Git diff or description of changes" });
3385
+ if (options.style === "conventional") {
3386
+ b.constraints([
3387
+ "Follow Conventional Commits format (type(scope): description)",
3388
+ "Use appropriate type: feat, fix, docs, style, refactor, test, chore"
3389
+ ]);
3390
+ }
3391
+ if (options.includeBody) {
3392
+ b.constraint("Include a detailed body explaining the why behind changes");
3393
+ }
3394
+ return b.constraints([
3395
+ "Keep subject line under 72 characters",
3396
+ "Use imperative mood (Add, Fix, Update, not Added, Fixed, Updated)"
3397
+ ]);
3398
+ },
3399
+ /**
3400
+ * Create a code review comment prompt
3401
+ */
3402
+ reviewComment: (options = {}) => {
3403
+ const b = builder().role("thoughtful code reviewer").task("Write a helpful code review comment for the provided code snippet.").variable("code", { required: true, description: "Code to comment on" }).variable("issue", { required: true, description: "The issue or improvement to address" });
3404
+ if (options.tone === "constructive") {
3405
+ b.constraint("Frame feedback positively and suggest improvements rather than just pointing out problems");
3406
+ }
3407
+ if (options.severity) {
3408
+ b.constraint("Indicate severity level: nitpick, suggestion, important, or blocker");
3409
+ }
3410
+ return b.constraints([
3411
+ "Be specific and actionable",
3412
+ "Explain the reasoning behind the suggestion",
3413
+ "Provide an example of the improved code when helpful"
3414
+ ]);
3415
+ },
3416
+ /**
3417
+ * Create a regex generator prompt
3418
+ */
3419
+ regex: (options = {}) => {
3420
+ const b = builder().role("regex expert").task("Create a regular expression that matches the described pattern.").variable("pattern", { required: true, description: "Description of the pattern to match" }).variable("examples", { required: false, description: "Example strings that should match" });
3421
+ if (options.flavor) {
3422
+ b.context(`Use ${options.flavor} regex flavor/syntax.`);
3423
+ }
3424
+ return b.constraints([
3425
+ "Provide the regex pattern",
3426
+ "Explain each part of the pattern",
3427
+ "Include test cases showing matches and non-matches"
3428
+ ]).output("1. Regex pattern\n2. Explanation\n3. Test cases");
3429
+ },
3430
+ /**
3431
+ * Create a SQL query prompt
3432
+ */
3433
+ sql: (options = {}) => {
3434
+ const b = builder().role("database expert").task("Write an SQL query based on the requirements.").variable("requirement", { required: true, description: "What the query should accomplish" }).variable("schema", { required: false, description: "Database schema or table definitions" });
3435
+ if (options.dialect) {
3436
+ b.context(`Use ${options.dialect.toUpperCase()} syntax.`);
3437
+ }
3438
+ if (options.optimize) {
3439
+ b.constraint("Optimize for performance and include index recommendations if applicable");
3440
+ }
3441
+ return b.constraints([
3442
+ "Write clean, readable SQL",
3443
+ "Use appropriate JOINs and avoid N+1 patterns",
3444
+ "Include comments explaining complex logic"
3445
+ ]);
3291
3446
  }
3292
3447
  };
3293
- // Annotate the CommonJS export names for ESM import in node:
3294
- 0 && (module.exports = {
3448
+ export {
3295
3449
  AudioPromptBuilder,
3296
3450
  ChatPromptBuilder,
3297
3451
  ImagePromptBuilder,
@@ -3302,13 +3456,13 @@ var templates = {
3302
3456
  calculateSimilarity,
3303
3457
  chat,
3304
3458
  chatPresets,
3305
- checkQuality,
3459
+ check as checkQuality,
3306
3460
  compile,
3307
3461
  convertAllVariables,
3308
3462
  convertToSupportedFormat,
3309
3463
  deduplicate,
3310
3464
  detectVariables,
3311
- detectVars,
3465
+ detect as detectVars,
3312
3466
  extractVariables,
3313
3467
  findDuplicates,
3314
3468
  fromPrompt,
@@ -3318,18 +3472,18 @@ var templates = {
3318
3472
  image,
3319
3473
  interpolate,
3320
3474
  isSimilarContent,
3321
- isValidPrompt,
3475
+ isValid as isValidPrompt,
3322
3476
  normalizeContent,
3323
- normalizeVariables,
3324
- parsePrompt,
3325
- parser,
3326
- quality,
3327
- similarity,
3477
+ normalize as normalizeVariables,
3478
+ parse as parsePrompt,
3479
+ parser_exports as parser,
3480
+ quality_exports as quality,
3481
+ similarity_exports as similarity,
3328
3482
  templates,
3329
3483
  toJson,
3330
3484
  toYaml,
3331
- validatePrompt,
3332
- variables,
3485
+ validate as validatePrompt,
3486
+ variables_exports as variables,
3333
3487
  video
3334
- });
3488
+ };
3335
3489
  //# sourceMappingURL=index.js.map