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,64 @@
1
+ /**
2
+ * Prompt Quality Checker - Local validation for prompt quality
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { quality } from 'prompts.chat';
7
+ *
8
+ * const result = quality.check("Act as a developer...");
9
+ * console.log(result.score); // 0.85
10
+ * console.log(result.issues); // []
11
+ * ```
12
+ */
13
+ interface QualityIssue {
14
+ type: 'error' | 'warning' | 'suggestion';
15
+ code: string;
16
+ message: string;
17
+ position?: {
18
+ start: number;
19
+ end: number;
20
+ };
21
+ }
22
+ interface QualityResult {
23
+ valid: boolean;
24
+ score: number;
25
+ issues: QualityIssue[];
26
+ stats: {
27
+ characterCount: number;
28
+ wordCount: number;
29
+ sentenceCount: number;
30
+ variableCount: number;
31
+ hasRole: boolean;
32
+ hasTask: boolean;
33
+ hasConstraints: boolean;
34
+ hasExamples: boolean;
35
+ };
36
+ }
37
+ /**
38
+ * Check prompt quality locally (no API needed)
39
+ */
40
+ declare function check(prompt: string): QualityResult;
41
+ /**
42
+ * Validate a prompt and throw if invalid
43
+ */
44
+ declare function validate(prompt: string): void;
45
+ /**
46
+ * Check if a prompt is valid
47
+ */
48
+ declare function isValid(prompt: string): boolean;
49
+ /**
50
+ * Get suggestions for improving a prompt
51
+ */
52
+ declare function getSuggestions(prompt: string): string[];
53
+
54
+ type index_QualityIssue = QualityIssue;
55
+ type index_QualityResult = QualityResult;
56
+ declare const index_check: typeof check;
57
+ declare const index_getSuggestions: typeof getSuggestions;
58
+ declare const index_isValid: typeof isValid;
59
+ declare const index_validate: typeof validate;
60
+ declare namespace index {
61
+ export { type index_QualityIssue as QualityIssue, type index_QualityResult as QualityResult, index_check as check, index_getSuggestions as getSuggestions, index_isValid as isValid, index_validate as validate };
62
+ }
63
+
64
+ export { type QualityResult as Q, isValid as a, type QualityIssue as b, check as c, getSuggestions as g, index as i, validate as v };
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Prompt Quality Checker - Local validation for prompt quality
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { quality } from 'prompts.chat';
7
+ *
8
+ * const result = quality.check("Act as a developer...");
9
+ * console.log(result.score); // 0.85
10
+ * console.log(result.issues); // []
11
+ * ```
12
+ */
13
+ interface QualityIssue {
14
+ type: 'error' | 'warning' | 'suggestion';
15
+ code: string;
16
+ message: string;
17
+ position?: {
18
+ start: number;
19
+ end: number;
20
+ };
21
+ }
22
+ interface QualityResult {
23
+ valid: boolean;
24
+ score: number;
25
+ issues: QualityIssue[];
26
+ stats: {
27
+ characterCount: number;
28
+ wordCount: number;
29
+ sentenceCount: number;
30
+ variableCount: number;
31
+ hasRole: boolean;
32
+ hasTask: boolean;
33
+ hasConstraints: boolean;
34
+ hasExamples: boolean;
35
+ };
36
+ }
37
+ /**
38
+ * Check prompt quality locally (no API needed)
39
+ */
40
+ declare function check(prompt: string): QualityResult;
41
+ /**
42
+ * Validate a prompt and throw if invalid
43
+ */
44
+ declare function validate(prompt: string): void;
45
+ /**
46
+ * Check if a prompt is valid
47
+ */
48
+ declare function isValid(prompt: string): boolean;
49
+ /**
50
+ * Get suggestions for improving a prompt
51
+ */
52
+ declare function getSuggestions(prompt: string): string[];
53
+
54
+ type index_QualityIssue = QualityIssue;
55
+ type index_QualityResult = QualityResult;
56
+ declare const index_check: typeof check;
57
+ declare const index_getSuggestions: typeof getSuggestions;
58
+ declare const index_isValid: typeof isValid;
59
+ declare const index_validate: typeof validate;
60
+ declare namespace index {
61
+ export { type index_QualityIssue as QualityIssue, type index_QualityResult as QualityResult, index_check as check, index_getSuggestions as getSuggestions, index_isValid as isValid, index_validate as validate };
62
+ }
63
+
64
+ export { type QualityResult as Q, isValid as a, type QualityIssue as b, check as c, getSuggestions as g, index as i, validate as v };
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Prompt Parser - Parse and load prompt files in various formats
3
+ *
4
+ * Supports:
5
+ * - .prompt.yml / .prompt.yaml (YAML format)
6
+ * - .prompt.json (JSON format)
7
+ * - .prompt.md (Markdown with frontmatter)
8
+ * - .txt (Plain text)
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { parser } from 'prompts.chat';
13
+ *
14
+ * const prompt = parser.parse(`
15
+ * name: Code Review
16
+ * messages:
17
+ * - role: system
18
+ * content: You are a code reviewer.
19
+ * `);
20
+ * ```
21
+ */
22
+ interface PromptMessage {
23
+ role: 'system' | 'user' | 'assistant';
24
+ content: string;
25
+ }
26
+ interface ParsedPrompt {
27
+ name?: string;
28
+ description?: string;
29
+ model?: string;
30
+ modelParameters?: {
31
+ temperature?: number;
32
+ maxTokens?: number;
33
+ topP?: number;
34
+ frequencyPenalty?: number;
35
+ presencePenalty?: number;
36
+ };
37
+ messages: PromptMessage[];
38
+ variables?: Record<string, {
39
+ description?: string;
40
+ default?: string;
41
+ required?: boolean;
42
+ }>;
43
+ metadata?: Record<string, unknown>;
44
+ }
45
+ /**
46
+ * Parse prompt content in various formats
47
+ */
48
+ declare function parse(content: string, format?: 'yaml' | 'json' | 'markdown' | 'text'): ParsedPrompt;
49
+ /**
50
+ * Serialize a ParsedPrompt to YAML format
51
+ */
52
+ declare function toYaml(prompt: ParsedPrompt): string;
53
+ /**
54
+ * Serialize a ParsedPrompt to JSON format
55
+ */
56
+ declare function toJson(prompt: ParsedPrompt, pretty?: boolean): string;
57
+ /**
58
+ * Get the system message content from a parsed prompt
59
+ */
60
+ declare function getSystemPrompt(prompt: ParsedPrompt): string;
61
+ /**
62
+ * Interpolate variables in a prompt
63
+ */
64
+ declare function interpolate(prompt: ParsedPrompt, values: Record<string, string>): ParsedPrompt;
65
+
66
+ type index_ParsedPrompt = ParsedPrompt;
67
+ type index_PromptMessage = PromptMessage;
68
+ declare const index_getSystemPrompt: typeof getSystemPrompt;
69
+ declare const index_interpolate: typeof interpolate;
70
+ declare const index_parse: typeof parse;
71
+ declare const index_toJson: typeof toJson;
72
+ declare const index_toYaml: typeof toYaml;
73
+ declare namespace index {
74
+ export { type index_ParsedPrompt as ParsedPrompt, type index_PromptMessage as PromptMessage, index_getSystemPrompt as getSystemPrompt, index_interpolate as interpolate, index_parse as parse, index_toJson as toJson, index_toYaml as toYaml };
75
+ }
76
+
77
+ export { type ParsedPrompt as P, toJson as a, interpolate as b, type PromptMessage as c, getSystemPrompt as g, index as i, parse as p, toYaml as t };
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Prompt Parser - Parse and load prompt files in various formats
3
+ *
4
+ * Supports:
5
+ * - .prompt.yml / .prompt.yaml (YAML format)
6
+ * - .prompt.json (JSON format)
7
+ * - .prompt.md (Markdown with frontmatter)
8
+ * - .txt (Plain text)
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { parser } from 'prompts.chat';
13
+ *
14
+ * const prompt = parser.parse(`
15
+ * name: Code Review
16
+ * messages:
17
+ * - role: system
18
+ * content: You are a code reviewer.
19
+ * `);
20
+ * ```
21
+ */
22
+ interface PromptMessage {
23
+ role: 'system' | 'user' | 'assistant';
24
+ content: string;
25
+ }
26
+ interface ParsedPrompt {
27
+ name?: string;
28
+ description?: string;
29
+ model?: string;
30
+ modelParameters?: {
31
+ temperature?: number;
32
+ maxTokens?: number;
33
+ topP?: number;
34
+ frequencyPenalty?: number;
35
+ presencePenalty?: number;
36
+ };
37
+ messages: PromptMessage[];
38
+ variables?: Record<string, {
39
+ description?: string;
40
+ default?: string;
41
+ required?: boolean;
42
+ }>;
43
+ metadata?: Record<string, unknown>;
44
+ }
45
+ /**
46
+ * Parse prompt content in various formats
47
+ */
48
+ declare function parse(content: string, format?: 'yaml' | 'json' | 'markdown' | 'text'): ParsedPrompt;
49
+ /**
50
+ * Serialize a ParsedPrompt to YAML format
51
+ */
52
+ declare function toYaml(prompt: ParsedPrompt): string;
53
+ /**
54
+ * Serialize a ParsedPrompt to JSON format
55
+ */
56
+ declare function toJson(prompt: ParsedPrompt, pretty?: boolean): string;
57
+ /**
58
+ * Get the system message content from a parsed prompt
59
+ */
60
+ declare function getSystemPrompt(prompt: ParsedPrompt): string;
61
+ /**
62
+ * Interpolate variables in a prompt
63
+ */
64
+ declare function interpolate(prompt: ParsedPrompt, values: Record<string, string>): ParsedPrompt;
65
+
66
+ type index_ParsedPrompt = ParsedPrompt;
67
+ type index_PromptMessage = PromptMessage;
68
+ declare const index_getSystemPrompt: typeof getSystemPrompt;
69
+ declare const index_interpolate: typeof interpolate;
70
+ declare const index_parse: typeof parse;
71
+ declare const index_toJson: typeof toJson;
72
+ declare const index_toYaml: typeof toYaml;
73
+ declare namespace index {
74
+ export { type index_ParsedPrompt as ParsedPrompt, type index_PromptMessage as PromptMessage, index_getSystemPrompt as getSystemPrompt, index_interpolate as interpolate, index_parse as parse, index_toJson as toJson, index_toYaml as toYaml };
75
+ }
76
+
77
+ export { type ParsedPrompt as P, toJson as a, interpolate as b, type PromptMessage as c, getSystemPrompt as g, index as i, parse as p, toYaml as t };
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Variable Detection Utility
3
+ * Detects common variable-like patterns in text that could be converted
4
+ * to our supported format: ${variableName} or ${variableName:default}
5
+ */
6
+ interface DetectedVariable {
7
+ original: string;
8
+ name: string;
9
+ defaultValue?: string;
10
+ pattern: VariablePattern;
11
+ startIndex: number;
12
+ endIndex: number;
13
+ }
14
+ type VariablePattern = "double_bracket" | "double_curly" | "single_bracket" | "single_curly" | "angle_bracket" | "percent" | "dollar_curly";
15
+ /**
16
+ * Detect variable-like patterns in text
17
+ * Returns detected variables that are NOT in our supported format
18
+ */
19
+ declare function detectVariables(text: string): DetectedVariable[];
20
+ /**
21
+ * Convert a detected variable to our supported format
22
+ */
23
+ declare function convertToSupportedFormat(variable: DetectedVariable): string;
24
+ /**
25
+ * Convert all detected variables in text to our supported format
26
+ */
27
+ declare function convertAllVariables(text: string): string;
28
+ /**
29
+ * Alias for convertAllVariables - normalizes all variable formats to ${var}
30
+ */
31
+ declare const normalize: typeof convertAllVariables;
32
+ /**
33
+ * Alias for detectVariables
34
+ */
35
+ declare const detect: typeof detectVariables;
36
+ /**
37
+ * Get a human-readable pattern description
38
+ */
39
+ declare function getPatternDescription(pattern: VariablePattern): string;
40
+ /**
41
+ * Extract variables from our supported ${var} or ${var:default} format
42
+ */
43
+ declare function extractVariables(text: string): Array<{
44
+ name: string;
45
+ defaultValue?: string;
46
+ }>;
47
+ /**
48
+ * Compile a prompt template with variable values
49
+ */
50
+ declare function compile(template: string, values: Record<string, string>, options?: {
51
+ useDefaults?: boolean;
52
+ }): string;
53
+
54
+ type index_DetectedVariable = DetectedVariable;
55
+ type index_VariablePattern = VariablePattern;
56
+ declare const index_compile: typeof compile;
57
+ declare const index_convertAllVariables: typeof convertAllVariables;
58
+ declare const index_convertToSupportedFormat: typeof convertToSupportedFormat;
59
+ declare const index_detect: typeof detect;
60
+ declare const index_detectVariables: typeof detectVariables;
61
+ declare const index_extractVariables: typeof extractVariables;
62
+ declare const index_getPatternDescription: typeof getPatternDescription;
63
+ declare const index_normalize: typeof normalize;
64
+ declare namespace index {
65
+ export { type index_DetectedVariable as DetectedVariable, type index_VariablePattern as VariablePattern, index_compile as compile, index_convertAllVariables as convertAllVariables, index_convertToSupportedFormat as convertToSupportedFormat, index_detect as detect, index_detectVariables as detectVariables, index_extractVariables as extractVariables, index_getPatternDescription as getPatternDescription, index_normalize as normalize };
66
+ }
67
+
68
+ export { type DetectedVariable as D, type VariablePattern as V, convertAllVariables as a, compile as b, convertToSupportedFormat as c, detectVariables as d, extractVariables as e, detect as f, getPatternDescription as g, index as i, normalize as n };
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Variable Detection Utility
3
+ * Detects common variable-like patterns in text that could be converted
4
+ * to our supported format: ${variableName} or ${variableName:default}
5
+ */
6
+ interface DetectedVariable {
7
+ original: string;
8
+ name: string;
9
+ defaultValue?: string;
10
+ pattern: VariablePattern;
11
+ startIndex: number;
12
+ endIndex: number;
13
+ }
14
+ type VariablePattern = "double_bracket" | "double_curly" | "single_bracket" | "single_curly" | "angle_bracket" | "percent" | "dollar_curly";
15
+ /**
16
+ * Detect variable-like patterns in text
17
+ * Returns detected variables that are NOT in our supported format
18
+ */
19
+ declare function detectVariables(text: string): DetectedVariable[];
20
+ /**
21
+ * Convert a detected variable to our supported format
22
+ */
23
+ declare function convertToSupportedFormat(variable: DetectedVariable): string;
24
+ /**
25
+ * Convert all detected variables in text to our supported format
26
+ */
27
+ declare function convertAllVariables(text: string): string;
28
+ /**
29
+ * Alias for convertAllVariables - normalizes all variable formats to ${var}
30
+ */
31
+ declare const normalize: typeof convertAllVariables;
32
+ /**
33
+ * Alias for detectVariables
34
+ */
35
+ declare const detect: typeof detectVariables;
36
+ /**
37
+ * Get a human-readable pattern description
38
+ */
39
+ declare function getPatternDescription(pattern: VariablePattern): string;
40
+ /**
41
+ * Extract variables from our supported ${var} or ${var:default} format
42
+ */
43
+ declare function extractVariables(text: string): Array<{
44
+ name: string;
45
+ defaultValue?: string;
46
+ }>;
47
+ /**
48
+ * Compile a prompt template with variable values
49
+ */
50
+ declare function compile(template: string, values: Record<string, string>, options?: {
51
+ useDefaults?: boolean;
52
+ }): string;
53
+
54
+ type index_DetectedVariable = DetectedVariable;
55
+ type index_VariablePattern = VariablePattern;
56
+ declare const index_compile: typeof compile;
57
+ declare const index_convertAllVariables: typeof convertAllVariables;
58
+ declare const index_convertToSupportedFormat: typeof convertToSupportedFormat;
59
+ declare const index_detect: typeof detect;
60
+ declare const index_detectVariables: typeof detectVariables;
61
+ declare const index_extractVariables: typeof extractVariables;
62
+ declare const index_getPatternDescription: typeof getPatternDescription;
63
+ declare const index_normalize: typeof normalize;
64
+ declare namespace index {
65
+ export { type index_DetectedVariable as DetectedVariable, type index_VariablePattern as VariablePattern, index_compile as compile, index_convertAllVariables as convertAllVariables, index_convertToSupportedFormat as convertToSupportedFormat, index_detect as detect, index_detectVariables as detectVariables, index_extractVariables as extractVariables, index_getPatternDescription as getPatternDescription, index_normalize as normalize };
66
+ }
67
+
68
+ export { type DetectedVariable as D, type VariablePattern as V, convertAllVariables as a, compile as b, convertToSupportedFormat as c, detectVariables as d, extractVariables as e, detect as f, getPatternDescription as g, index as i, normalize as n };
@@ -0,0 +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';
@@ -0,0 +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.js';
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.js';
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.js';
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.js';
5
+ export { AudioPromptBuilder, BuiltAudioPrompt, BuiltChatPrompt, BuiltImagePrompt, BuiltPrompt, BuiltVideoPrompt, ChatPromptBuilder, ImagePromptBuilder, PromptBuilder, PromptVariable, VideoPromptBuilder, audio, builder, chat, chatPresets, fromPrompt, image, templates, video } from './builder/index.js';