@wundr.io/prompt-templates 1.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.
- package/dist/engine.d.ts +206 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +506 -0
- package/dist/engine.js.map +1 -0
- package/dist/helpers.d.ts +201 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +566 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +56 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +129 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +415 -0
- package/dist/loader.js.map +1 -0
- package/dist/macros.d.ts +64 -0
- package/dist/macros.d.ts.map +1 -0
- package/dist/macros.js +620 -0
- package/dist/macros.js.map +1 -0
- package/dist/types.d.ts +443 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +62 -0
- package/dist/types.js.map +1 -0
- package/package.json +45 -0
- package/src/engine.ts +616 -0
- package/src/helpers.ts +650 -0
- package/src/index.ts +138 -0
- package/src/loader.ts +468 -0
- package/src/macros.ts +635 -0
- package/src/types.ts +380 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @wundr/prompt-templates - Built-in Handlebars helpers for prompt templating
|
|
3
|
+
*/
|
|
4
|
+
import Handlebars from 'handlebars';
|
|
5
|
+
import type { ToolDefinition, ConversationMessage, HelperDefinition } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Format tools array into a structured prompt format
|
|
8
|
+
*
|
|
9
|
+
* @param tools - Array of tool definitions
|
|
10
|
+
* @param options - Handlebars helper options
|
|
11
|
+
* @returns Formatted tools string
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* {{formatTools tools}}
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatTools(tools: ToolDefinition[] | undefined, options?: Handlebars.HelperOptions): string;
|
|
17
|
+
/**
|
|
18
|
+
* Conditionally render block if value is defined and not null/undefined
|
|
19
|
+
*
|
|
20
|
+
* @param value - Value to check
|
|
21
|
+
* @param options - Handlebars helper options
|
|
22
|
+
* @returns Rendered block or empty string
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* {{#ifDefined user.name}}Hello, {{user.name}}{{/ifDefined}}
|
|
26
|
+
*/
|
|
27
|
+
export declare function ifDefined(this: unknown, value: unknown, options: Handlebars.HelperOptions): string;
|
|
28
|
+
/**
|
|
29
|
+
* Wrap content in a code block with optional language
|
|
30
|
+
*
|
|
31
|
+
* @param language - Programming language for syntax highlighting
|
|
32
|
+
* @param options - Handlebars helper options
|
|
33
|
+
* @returns Code block formatted string
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* {{#codeBlock "javascript"}}
|
|
37
|
+
* const x = 1;
|
|
38
|
+
* {{/codeBlock}}
|
|
39
|
+
*/
|
|
40
|
+
export declare function codeBlock(this: unknown, language: string | Handlebars.HelperOptions, options?: Handlebars.HelperOptions): string;
|
|
41
|
+
/**
|
|
42
|
+
* Format memory/conversation history into a readable format
|
|
43
|
+
*
|
|
44
|
+
* @param messages - Array of conversation messages
|
|
45
|
+
* @param options - Handlebars helper options
|
|
46
|
+
* @returns Formatted memory string
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* {{formatMemory memory.messages}}
|
|
50
|
+
*/
|
|
51
|
+
export declare function formatMemory(messages: ConversationMessage[] | undefined, options?: Handlebars.HelperOptions): string;
|
|
52
|
+
/**
|
|
53
|
+
* Repeat content n times
|
|
54
|
+
*
|
|
55
|
+
* @param count - Number of times to repeat
|
|
56
|
+
* @param options - Handlebars helper options
|
|
57
|
+
* @returns Repeated content
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* {{#repeat 3}}Item {{@index}}{{/repeat}}
|
|
61
|
+
*/
|
|
62
|
+
export declare function repeat(this: unknown, count: number, options: Handlebars.HelperOptions): string;
|
|
63
|
+
/**
|
|
64
|
+
* Format a date value
|
|
65
|
+
*
|
|
66
|
+
* @param date - Date to format
|
|
67
|
+
* @param formatStr - Format string (iso, locale, relative, or custom)
|
|
68
|
+
* @returns Formatted date string
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* {{formatDate timestamp "iso"}}
|
|
72
|
+
*/
|
|
73
|
+
export declare function formatDate(date: Date | string | number | undefined, formatStr?: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* JSON stringify with formatting options
|
|
76
|
+
*
|
|
77
|
+
* @param value - Value to stringify
|
|
78
|
+
* @param options - Handlebars helper options
|
|
79
|
+
* @returns JSON string
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* {{json data indent=2}}
|
|
83
|
+
*/
|
|
84
|
+
export declare function json(value: unknown, options?: Handlebars.HelperOptions): string;
|
|
85
|
+
/**
|
|
86
|
+
* Truncate text to a maximum length
|
|
87
|
+
*
|
|
88
|
+
* @param text - Text to truncate
|
|
89
|
+
* @param length - Maximum length
|
|
90
|
+
* @param suffix - Suffix to add when truncated (default: '...')
|
|
91
|
+
* @returns Truncated text
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* {{truncate description 100 "..."}}
|
|
95
|
+
*/
|
|
96
|
+
export declare function truncate(text: string | undefined, length?: number | Handlebars.HelperOptions, suffix?: string | Handlebars.HelperOptions): string;
|
|
97
|
+
/**
|
|
98
|
+
* Join array items with a separator
|
|
99
|
+
*
|
|
100
|
+
* @param items - Array to join
|
|
101
|
+
* @param separator - Separator string (default: ', ')
|
|
102
|
+
* @returns Joined string
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* {{join tags ", "}}
|
|
106
|
+
*/
|
|
107
|
+
export declare function join(items: unknown[] | undefined, separator?: string | Handlebars.HelperOptions): string;
|
|
108
|
+
/**
|
|
109
|
+
* String comparison helper
|
|
110
|
+
*
|
|
111
|
+
* @param a - First value
|
|
112
|
+
* @param operator - Comparison operator
|
|
113
|
+
* @param b - Second value
|
|
114
|
+
* @param options - Handlebars helper options
|
|
115
|
+
* @returns Rendered block based on comparison result
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* {{#compare role "eq" "admin"}}Admin content{{/compare}}
|
|
119
|
+
*/
|
|
120
|
+
export declare function compare(this: unknown, a: unknown, operator: string, b: unknown, options: Handlebars.HelperOptions): string;
|
|
121
|
+
/**
|
|
122
|
+
* Capitalize first letter of string
|
|
123
|
+
*
|
|
124
|
+
* @param text - Text to capitalize
|
|
125
|
+
* @returns Capitalized text
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* {{capitalize name}}
|
|
129
|
+
*/
|
|
130
|
+
export declare function capitalize(text: string | undefined): string;
|
|
131
|
+
/**
|
|
132
|
+
* Convert string to uppercase
|
|
133
|
+
*
|
|
134
|
+
* @param text - Text to convert
|
|
135
|
+
* @returns Uppercase text
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* {{uppercase status}}
|
|
139
|
+
*/
|
|
140
|
+
export declare function uppercase(text: string | undefined): string;
|
|
141
|
+
/**
|
|
142
|
+
* Convert string to lowercase
|
|
143
|
+
*
|
|
144
|
+
* @param text - Text to convert
|
|
145
|
+
* @returns Lowercase text
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* {{lowercase status}}
|
|
149
|
+
*/
|
|
150
|
+
export declare function lowercase(text: string | undefined): string;
|
|
151
|
+
/**
|
|
152
|
+
* Indent text by a number of spaces
|
|
153
|
+
*
|
|
154
|
+
* @param text - Text to indent
|
|
155
|
+
* @param spaces - Number of spaces (default: 2)
|
|
156
|
+
* @returns Indented text
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* {{indent content 4}}
|
|
160
|
+
*/
|
|
161
|
+
export declare function indent(text: string | undefined, spaces?: number | Handlebars.HelperOptions): string;
|
|
162
|
+
/**
|
|
163
|
+
* Wrap text to a maximum line width
|
|
164
|
+
*
|
|
165
|
+
* @param text - Text to wrap
|
|
166
|
+
* @param width - Maximum line width (default: 80)
|
|
167
|
+
* @returns Wrapped text
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* {{wrap longText 72}}
|
|
171
|
+
*/
|
|
172
|
+
export declare function wrap(text: string | undefined, width?: number | Handlebars.HelperOptions): string;
|
|
173
|
+
/**
|
|
174
|
+
* Create a bulleted list from array
|
|
175
|
+
*
|
|
176
|
+
* @param items - Array of items
|
|
177
|
+
* @param options - Handlebars helper options
|
|
178
|
+
* @returns Bulleted list string
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* {{bulletList items bullet="*"}}
|
|
182
|
+
*/
|
|
183
|
+
export declare function bulletList(items: unknown[] | undefined, options?: Handlebars.HelperOptions): string;
|
|
184
|
+
/**
|
|
185
|
+
* Create a numbered list from array
|
|
186
|
+
*
|
|
187
|
+
* @param items - Array of items
|
|
188
|
+
* @param options - Handlebars helper options
|
|
189
|
+
* @returns Numbered list string
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* {{numberedList steps start=1}}
|
|
193
|
+
*/
|
|
194
|
+
export declare function numberedList(items: unknown[] | undefined, options?: Handlebars.HelperOptions): string;
|
|
195
|
+
/**
|
|
196
|
+
* Get all built-in helper definitions
|
|
197
|
+
*
|
|
198
|
+
* @returns Array of helper definitions
|
|
199
|
+
*/
|
|
200
|
+
export declare function getBuiltinHelpers(): HelperDefinition[];
|
|
201
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,KAAK,EACV,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACz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