@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.
@@ -0,0 +1,443 @@
1
+ /**
2
+ * @wundr/prompt-templates - Type definitions for dynamic prompt templating
3
+ */
4
+ import { z } from 'zod';
5
+ /**
6
+ * JSON-compatible primitive types
7
+ */
8
+ export type JsonPrimitive = string | number | boolean | null;
9
+ /**
10
+ * JSON-compatible value types
11
+ */
12
+ export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
13
+ /**
14
+ * JSON-compatible object type
15
+ */
16
+ export interface JsonObject {
17
+ readonly [key: string]: JsonValue;
18
+ }
19
+ /**
20
+ * JSON-compatible array type
21
+ */
22
+ export type JsonArray = ReadonlyArray<JsonValue>;
23
+ /**
24
+ * Context data passed to templates for rendering
25
+ */
26
+ export interface TemplateContext {
27
+ /** Variables available in the template */
28
+ readonly variables: Record<string, unknown>;
29
+ /** System-level context (e.g., current date, user info) */
30
+ readonly system?: SystemContext;
31
+ /** Memory/history context for conversation-aware templates */
32
+ readonly memory?: MemoryContext;
33
+ /** Tools/functions available to the AI */
34
+ readonly tools?: ToolDefinition[];
35
+ /** Additional metadata */
36
+ readonly metadata?: Record<string, unknown>;
37
+ }
38
+ /**
39
+ * System-level context available to all templates
40
+ */
41
+ export interface SystemContext {
42
+ /** Current timestamp */
43
+ readonly timestamp?: Date;
44
+ /** User identifier */
45
+ readonly userId?: string;
46
+ /** Session identifier */
47
+ readonly sessionId?: string;
48
+ /** Environment (development, production, test) */
49
+ readonly environment?: 'development' | 'production' | 'test';
50
+ /** Model being used */
51
+ readonly model?: string;
52
+ /** Custom system values */
53
+ readonly [key: string]: unknown;
54
+ }
55
+ /**
56
+ * Memory context for conversation history
57
+ */
58
+ export interface MemoryContext {
59
+ /** Previous messages in the conversation */
60
+ readonly messages?: ConversationMessage[];
61
+ /** Key facts/context to remember */
62
+ readonly facts?: string[];
63
+ /** Short-term working memory */
64
+ readonly shortTerm?: Record<string, unknown>;
65
+ /** Long-term persistent memory */
66
+ readonly longTerm?: Record<string, unknown>;
67
+ }
68
+ /**
69
+ * Conversation message structure
70
+ */
71
+ export interface ConversationMessage {
72
+ /** Role of the message sender */
73
+ readonly role: 'system' | 'user' | 'assistant' | 'tool';
74
+ /** Message content */
75
+ readonly content: string;
76
+ /** Optional message name */
77
+ readonly name?: string;
78
+ /** Timestamp when message was sent */
79
+ readonly timestamp?: Date;
80
+ /** Additional message metadata */
81
+ readonly metadata?: Record<string, unknown>;
82
+ }
83
+ /**
84
+ * Tool/function definition for AI prompts
85
+ */
86
+ export interface ToolDefinition {
87
+ /** Tool name */
88
+ readonly name: string;
89
+ /** Tool description */
90
+ readonly description: string;
91
+ /** Input parameters schema */
92
+ readonly parameters?: ToolParameters;
93
+ /** Whether the tool returns data */
94
+ readonly returnsData?: boolean;
95
+ /** Example usage */
96
+ readonly examples?: string[];
97
+ }
98
+ /**
99
+ * Tool parameters schema (JSON Schema-like)
100
+ */
101
+ export interface ToolParameters {
102
+ /** Parameter type */
103
+ readonly type: 'object' | 'array' | 'string' | 'number' | 'boolean';
104
+ /** Object properties */
105
+ readonly properties?: Record<string, ToolParameterProperty>;
106
+ /** Required property names */
107
+ readonly required?: string[];
108
+ /** Additional properties allowed */
109
+ readonly additionalProperties?: boolean;
110
+ }
111
+ /**
112
+ * Individual tool parameter property
113
+ */
114
+ export interface ToolParameterProperty {
115
+ /** Property type */
116
+ readonly type: 'string' | 'number' | 'boolean' | 'array' | 'object';
117
+ /** Property description */
118
+ readonly description?: string;
119
+ /** Enum values for constrained types */
120
+ readonly enum?: readonly (string | number)[];
121
+ /** Default value */
122
+ readonly default?: unknown;
123
+ /** Array item schema */
124
+ readonly items?: ToolParameterProperty;
125
+ }
126
+ /**
127
+ * Prompt template configuration
128
+ */
129
+ export interface PromptTemplateConfig {
130
+ /** Unique template identifier */
131
+ readonly id: string;
132
+ /** Template name for display */
133
+ readonly name: string;
134
+ /** Template description */
135
+ readonly description?: string;
136
+ /** Template version */
137
+ readonly version: string;
138
+ /** The template content (Handlebars format) */
139
+ readonly template: string;
140
+ /** Default context values */
141
+ readonly defaults?: Partial<TemplateContext>;
142
+ /** Required variables that must be provided */
143
+ readonly requiredVariables?: string[];
144
+ /** Template tags for categorization */
145
+ readonly tags?: string[];
146
+ /** Template author */
147
+ readonly author?: string;
148
+ /** Creation timestamp */
149
+ readonly createdAt?: Date;
150
+ /** Last update timestamp */
151
+ readonly updatedAt?: Date;
152
+ }
153
+ /**
154
+ * Macro definition for reusable template components
155
+ */
156
+ export interface MacroDefinition {
157
+ /** Macro name */
158
+ readonly name: string;
159
+ /** Macro description */
160
+ readonly description?: string;
161
+ /** Macro template content */
162
+ readonly template: string;
163
+ /** Expected parameters */
164
+ readonly parameters?: MacroParameter[];
165
+ /** Example usage */
166
+ readonly example?: string;
167
+ }
168
+ /**
169
+ * Macro parameter definition
170
+ */
171
+ export interface MacroParameter {
172
+ /** Parameter name */
173
+ readonly name: string;
174
+ /** Parameter description */
175
+ readonly description?: string;
176
+ /** Parameter type */
177
+ readonly type?: 'string' | 'number' | 'boolean' | 'array' | 'object';
178
+ /** Whether the parameter is required */
179
+ readonly required?: boolean;
180
+ /** Default value */
181
+ readonly default?: unknown;
182
+ }
183
+ /**
184
+ * Helper function definition
185
+ */
186
+ export interface HelperDefinition {
187
+ /** Helper name */
188
+ readonly name: string;
189
+ /** Helper description */
190
+ readonly description?: string;
191
+ /** The helper function implementation */
192
+ readonly fn: HelperFunction;
193
+ }
194
+ /**
195
+ * Helper function signature (Handlebars-compatible)
196
+ */
197
+ export type HelperFunction = (...args: unknown[]) => string | SafeString | undefined;
198
+ /**
199
+ * Handlebars SafeString type for HTML-safe output
200
+ */
201
+ export interface SafeString {
202
+ readonly toHTML: () => string;
203
+ readonly toString: () => string;
204
+ }
205
+ /**
206
+ * Template render options
207
+ */
208
+ export interface RenderOptions {
209
+ /** Strict mode - throw on undefined variables */
210
+ readonly strict?: boolean;
211
+ /** Custom delimiters for template parsing */
212
+ readonly delimiters?: [string, string];
213
+ /** Enable HTML escaping (default: false for prompts) */
214
+ readonly escapeHtml?: boolean;
215
+ /** Maximum template depth for nested templates */
216
+ readonly maxDepth?: number;
217
+ /** Timeout for template rendering (ms) */
218
+ readonly timeout?: number;
219
+ }
220
+ /**
221
+ * Template render result
222
+ */
223
+ export interface RenderResult {
224
+ /** Whether rendering was successful */
225
+ readonly success: boolean;
226
+ /** Rendered output (if successful) */
227
+ readonly output?: string;
228
+ /** Error information (if failed) */
229
+ readonly error?: TemplateError;
230
+ /** Rendering metadata */
231
+ readonly metadata?: RenderMetadata;
232
+ }
233
+ /**
234
+ * Template error information
235
+ */
236
+ export interface TemplateError {
237
+ /** Error code */
238
+ readonly code: string;
239
+ /** Error message */
240
+ readonly message: string;
241
+ /** Line number where error occurred */
242
+ readonly line?: number;
243
+ /** Column number where error occurred */
244
+ readonly column?: number;
245
+ /** Template ID that caused the error */
246
+ readonly templateId?: string;
247
+ /** Original error stack */
248
+ readonly stack?: string;
249
+ }
250
+ /**
251
+ * Metadata about the render operation
252
+ */
253
+ export interface RenderMetadata {
254
+ /** Time taken to render (ms) */
255
+ readonly renderTime: number;
256
+ /** Template ID used */
257
+ readonly templateId?: string;
258
+ /** Variables that were used */
259
+ readonly usedVariables?: string[];
260
+ /** Macros that were invoked */
261
+ readonly usedMacros?: string[];
262
+ /** Helpers that were invoked */
263
+ readonly usedHelpers?: string[];
264
+ }
265
+ /**
266
+ * Template loader options
267
+ */
268
+ export interface LoaderOptions {
269
+ /** Base directory for template files */
270
+ readonly baseDir?: string;
271
+ /** File extension for template files */
272
+ readonly extension?: string;
273
+ /** Enable template caching */
274
+ readonly cache?: boolean;
275
+ /** Watch for file changes */
276
+ readonly watch?: boolean;
277
+ }
278
+ /**
279
+ * Template engine events
280
+ */
281
+ export interface EngineEvents {
282
+ readonly 'template:loaded': {
283
+ templateId: string;
284
+ };
285
+ readonly 'template:rendered': {
286
+ templateId: string;
287
+ renderTime: number;
288
+ };
289
+ readonly 'template:error': {
290
+ templateId: string;
291
+ error: TemplateError;
292
+ };
293
+ readonly 'macro:registered': {
294
+ name: string;
295
+ };
296
+ readonly 'helper:registered': {
297
+ name: string;
298
+ };
299
+ }
300
+ /**
301
+ * Template engine event handler
302
+ */
303
+ export type EngineEventHandler<K extends keyof EngineEvents> = (event: EngineEvents[K]) => void;
304
+ /**
305
+ * Zod schema for PromptTemplateConfig
306
+ */
307
+ export declare const PromptTemplateConfigSchema: z.ZodObject<{
308
+ id: z.ZodString;
309
+ name: z.ZodString;
310
+ description: z.ZodOptional<z.ZodString>;
311
+ version: z.ZodString;
312
+ template: z.ZodString;
313
+ defaults: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
314
+ requiredVariables: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
315
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
316
+ author: z.ZodOptional<z.ZodString>;
317
+ createdAt: z.ZodOptional<z.ZodDate>;
318
+ updatedAt: z.ZodOptional<z.ZodDate>;
319
+ }, "strip", z.ZodTypeAny, {
320
+ id: string;
321
+ name: string;
322
+ version: string;
323
+ template: string;
324
+ description?: string | undefined;
325
+ defaults?: Record<string, unknown> | undefined;
326
+ requiredVariables?: string[] | undefined;
327
+ tags?: string[] | undefined;
328
+ author?: string | undefined;
329
+ createdAt?: Date | undefined;
330
+ updatedAt?: Date | undefined;
331
+ }, {
332
+ id: string;
333
+ name: string;
334
+ version: string;
335
+ template: string;
336
+ description?: string | undefined;
337
+ defaults?: Record<string, unknown> | undefined;
338
+ requiredVariables?: string[] | undefined;
339
+ tags?: string[] | undefined;
340
+ author?: string | undefined;
341
+ createdAt?: Date | undefined;
342
+ updatedAt?: Date | undefined;
343
+ }>;
344
+ /**
345
+ * Zod schema for ToolDefinition
346
+ */
347
+ export declare const ToolDefinitionSchema: z.ZodObject<{
348
+ name: z.ZodString;
349
+ description: z.ZodString;
350
+ parameters: z.ZodOptional<z.ZodObject<{
351
+ type: z.ZodEnum<["object", "array", "string", "number", "boolean"]>;
352
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
353
+ required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
354
+ additionalProperties: z.ZodOptional<z.ZodBoolean>;
355
+ }, "strip", z.ZodTypeAny, {
356
+ type: "string" | "number" | "boolean" | "object" | "array";
357
+ properties?: Record<string, unknown> | undefined;
358
+ required?: string[] | undefined;
359
+ additionalProperties?: boolean | undefined;
360
+ }, {
361
+ type: "string" | "number" | "boolean" | "object" | "array";
362
+ properties?: Record<string, unknown> | undefined;
363
+ required?: string[] | undefined;
364
+ additionalProperties?: boolean | undefined;
365
+ }>>;
366
+ returnsData: z.ZodOptional<z.ZodBoolean>;
367
+ examples: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
368
+ }, "strip", z.ZodTypeAny, {
369
+ name: string;
370
+ description: string;
371
+ parameters?: {
372
+ type: "string" | "number" | "boolean" | "object" | "array";
373
+ properties?: Record<string, unknown> | undefined;
374
+ required?: string[] | undefined;
375
+ additionalProperties?: boolean | undefined;
376
+ } | undefined;
377
+ returnsData?: boolean | undefined;
378
+ examples?: string[] | undefined;
379
+ }, {
380
+ name: string;
381
+ description: string;
382
+ parameters?: {
383
+ type: "string" | "number" | "boolean" | "object" | "array";
384
+ properties?: Record<string, unknown> | undefined;
385
+ required?: string[] | undefined;
386
+ additionalProperties?: boolean | undefined;
387
+ } | undefined;
388
+ returnsData?: boolean | undefined;
389
+ examples?: string[] | undefined;
390
+ }>;
391
+ /**
392
+ * Zod schema for MacroDefinition
393
+ */
394
+ export declare const MacroDefinitionSchema: z.ZodObject<{
395
+ name: z.ZodString;
396
+ description: z.ZodOptional<z.ZodString>;
397
+ template: z.ZodString;
398
+ parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
399
+ name: z.ZodString;
400
+ description: z.ZodOptional<z.ZodString>;
401
+ type: z.ZodOptional<z.ZodEnum<["string", "number", "boolean", "array", "object"]>>;
402
+ required: z.ZodOptional<z.ZodBoolean>;
403
+ default: z.ZodOptional<z.ZodUnknown>;
404
+ }, "strip", z.ZodTypeAny, {
405
+ name: string;
406
+ description?: string | undefined;
407
+ type?: "string" | "number" | "boolean" | "object" | "array" | undefined;
408
+ required?: boolean | undefined;
409
+ default?: unknown;
410
+ }, {
411
+ name: string;
412
+ description?: string | undefined;
413
+ type?: "string" | "number" | "boolean" | "object" | "array" | undefined;
414
+ required?: boolean | undefined;
415
+ default?: unknown;
416
+ }>, "many">>;
417
+ example: z.ZodOptional<z.ZodString>;
418
+ }, "strip", z.ZodTypeAny, {
419
+ name: string;
420
+ template: string;
421
+ description?: string | undefined;
422
+ parameters?: {
423
+ name: string;
424
+ description?: string | undefined;
425
+ type?: "string" | "number" | "boolean" | "object" | "array" | undefined;
426
+ required?: boolean | undefined;
427
+ default?: unknown;
428
+ }[] | undefined;
429
+ example?: string | undefined;
430
+ }, {
431
+ name: string;
432
+ template: string;
433
+ description?: string | undefined;
434
+ parameters?: {
435
+ name: string;
436
+ description?: string | undefined;
437
+ type?: "string" | "number" | "boolean" | "object" | "array" | undefined;
438
+ required?: boolean | undefined;
439
+ default?: unknown;
440
+ }[] | undefined;
441
+ example?: string | undefined;
442
+ }>;
443
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;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B,IAAI,CAAC;AAIV;;GAEG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYrC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAa/B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBhC,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ /**
3
+ * @wundr/prompt-templates - Type definitions for dynamic prompt templating
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MacroDefinitionSchema = exports.ToolDefinitionSchema = exports.PromptTemplateConfigSchema = void 0;
7
+ const zod_1 = require("zod");
8
+ // Zod schemas for validation
9
+ /**
10
+ * Zod schema for PromptTemplateConfig
11
+ */
12
+ exports.PromptTemplateConfigSchema = zod_1.z.object({
13
+ id: zod_1.z.string().min(1),
14
+ name: zod_1.z.string().min(1),
15
+ description: zod_1.z.string().optional(),
16
+ version: zod_1.z.string().regex(/^\d+\.\d+\.\d+$/),
17
+ template: zod_1.z.string().min(1),
18
+ defaults: zod_1.z.record(zod_1.z.unknown()).optional(),
19
+ requiredVariables: zod_1.z.array(zod_1.z.string()).optional(),
20
+ tags: zod_1.z.array(zod_1.z.string()).optional(),
21
+ author: zod_1.z.string().optional(),
22
+ createdAt: zod_1.z.date().optional(),
23
+ updatedAt: zod_1.z.date().optional(),
24
+ });
25
+ /**
26
+ * Zod schema for ToolDefinition
27
+ */
28
+ exports.ToolDefinitionSchema = zod_1.z.object({
29
+ name: zod_1.z.string().min(1),
30
+ description: zod_1.z.string().min(1),
31
+ parameters: zod_1.z
32
+ .object({
33
+ type: zod_1.z.enum(['object', 'array', 'string', 'number', 'boolean']),
34
+ properties: zod_1.z.record(zod_1.z.unknown()).optional(),
35
+ required: zod_1.z.array(zod_1.z.string()).optional(),
36
+ additionalProperties: zod_1.z.boolean().optional(),
37
+ })
38
+ .optional(),
39
+ returnsData: zod_1.z.boolean().optional(),
40
+ examples: zod_1.z.array(zod_1.z.string()).optional(),
41
+ });
42
+ /**
43
+ * Zod schema for MacroDefinition
44
+ */
45
+ exports.MacroDefinitionSchema = zod_1.z.object({
46
+ name: zod_1.z.string().min(1),
47
+ description: zod_1.z.string().optional(),
48
+ template: zod_1.z.string().min(1),
49
+ parameters: zod_1.z
50
+ .array(zod_1.z.object({
51
+ name: zod_1.z.string().min(1),
52
+ description: zod_1.z.string().optional(),
53
+ type: zod_1.z
54
+ .enum(['string', 'number', 'boolean', 'array', 'object'])
55
+ .optional(),
56
+ required: zod_1.z.boolean().optional(),
57
+ default: zod_1.z.unknown().optional(),
58
+ }))
59
+ .optional(),
60
+ example: zod_1.z.string().optional(),
61
+ });
62
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,6BAAwB;AA6TxB,6BAA6B;AAE7B;;GAEG;AACU,QAAA,0BAA0B,GAAG,OAAC,CAAC,MAAM,CAAC;IACjD,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACrB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC;IAC5C,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,QAAQ,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC1C,i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B,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5C,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,UAAU,EAAE,OAAC;SACV,KAAK,CACJ,OAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACvB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAClC,IAAI,EAAE,OAAC;aACJ,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;aACxD,QAAQ,EAAE;QACb,QAAQ,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;QAChC,OAAO,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;KAChC,CAAC,CACH;SACA,QAAQ,EAAE;IACb,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@wundr.io/prompt-templates",
3
+ "version": "1.0.3",
4
+ "description": "Jinja2-style dynamic prompt templating using Handlebars for the Wundr platform",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": ["dist", "src"],
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "build:watch": "tsc --watch",
11
+ "clean": "rm -rf dist",
12
+ "dev": "tsc --watch",
13
+ "test": "jest",
14
+ "test:watch": "jest --watch",
15
+ "test:coverage": "jest --coverage",
16
+ "lint": "eslint src/**/*.ts",
17
+ "format": "prettier --write src/**/*.ts",
18
+ "format:check": "prettier --check src/**/*.ts",
19
+ "typecheck": "tsc --noEmit"
20
+ },
21
+ "dependencies": {
22
+ "handlebars": "^4.7.8",
23
+ "zod": "^3.25.76"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^20.9.0",
27
+ "jest": "^29.7.0",
28
+ "ts-jest": "^29.4.1",
29
+ "typescript": "^5.2.2",
30
+ "eslint": "^8.57.1",
31
+ "prettier": "^3.3.3"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "keywords": [
37
+ "wundr",
38
+ "prompt",
39
+ "templates",
40
+ "handlebars",
41
+ "jinja2",
42
+ "ai",
43
+ "llm"
44
+ ]
45
+ }