@vertesia/build-tools 0.80.0 → 0.80.1

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 (40) hide show
  1. package/lib/build-tools.js +286 -8
  2. package/lib/build-tools.js.map +1 -1
  3. package/lib/cjs/index.js +6 -1
  4. package/lib/cjs/index.js.map +1 -1
  5. package/lib/cjs/plugin.js +14 -6
  6. package/lib/cjs/plugin.js.map +1 -1
  7. package/lib/cjs/presets/index.js +8 -1
  8. package/lib/cjs/presets/index.js.map +1 -1
  9. package/lib/cjs/presets/prompt.js +203 -0
  10. package/lib/cjs/presets/prompt.js.map +1 -0
  11. package/lib/cjs/presets/skill-collection.js +83 -0
  12. package/lib/cjs/presets/skill-collection.js.map +1 -0
  13. package/lib/esm/index.js +1 -1
  14. package/lib/esm/index.js.map +1 -1
  15. package/lib/esm/plugin.js +14 -6
  16. package/lib/esm/plugin.js.map +1 -1
  17. package/lib/esm/presets/index.js +2 -0
  18. package/lib/esm/presets/index.js.map +1 -1
  19. package/lib/esm/presets/prompt.js +197 -0
  20. package/lib/esm/presets/prompt.js.map +1 -0
  21. package/lib/esm/presets/skill-collection.js +77 -0
  22. package/lib/esm/presets/skill-collection.js.map +1 -0
  23. package/lib/types/index.d.ts +1 -1
  24. package/lib/types/index.d.ts.map +1 -1
  25. package/lib/types/plugin.d.ts.map +1 -1
  26. package/lib/types/presets/index.d.ts +2 -0
  27. package/lib/types/presets/index.d.ts.map +1 -1
  28. package/lib/types/presets/prompt.d.ts +77 -0
  29. package/lib/types/presets/prompt.d.ts.map +1 -0
  30. package/lib/types/presets/skill-collection.d.ts +26 -0
  31. package/lib/types/presets/skill-collection.d.ts.map +1 -0
  32. package/lib/types/types.d.ts +2 -0
  33. package/lib/types/types.d.ts.map +1 -1
  34. package/package.json +1 -1
  35. package/src/index.ts +8 -1
  36. package/src/plugin.ts +14 -6
  37. package/src/presets/index.ts +2 -0
  38. package/src/presets/prompt.ts +242 -0
  39. package/src/presets/skill-collection.ts +86 -0
  40. package/src/types.ts +3 -0
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Prompt transformer preset for template files with frontmatter
3
+ * Supports .jst, .hbs, and plain text files
4
+ */
5
+ import { z } from 'zod';
6
+ import { parseFrontmatter } from '../parsers/frontmatter.js';
7
+ import path from 'path';
8
+ /**
9
+ * Template type for prompt content
10
+ * MUST match TemplateType from @vertesia/common
11
+ */
12
+ export var TemplateType;
13
+ (function (TemplateType) {
14
+ TemplateType["jst"] = "jst";
15
+ TemplateType["handlebars"] = "handlebars";
16
+ TemplateType["text"] = "text";
17
+ })(TemplateType || (TemplateType = {}));
18
+ /**
19
+ * Prompt role enum
20
+ * MUST match PromptRole from @llumiverse/common
21
+ */
22
+ export var PromptRole;
23
+ (function (PromptRole) {
24
+ PromptRole["safety"] = "safety";
25
+ PromptRole["system"] = "system";
26
+ PromptRole["user"] = "user";
27
+ PromptRole["assistant"] = "assistant";
28
+ PromptRole["negative"] = "negative";
29
+ })(PromptRole || (PromptRole = {}));
30
+ /**
31
+ * Zod schema for prompt frontmatter validation
32
+ */
33
+ const PromptFrontmatterSchema = z.object({
34
+ // Required fields
35
+ role: z.nativeEnum(PromptRole, {
36
+ errorMap: () => ({ message: 'Role must be one of: safety, system, user, assistant, negative' })
37
+ }),
38
+ // Optional fields
39
+ content_type: z.nativeEnum(TemplateType).optional(),
40
+ schema: z.string().optional(),
41
+ name: z.string().optional(),
42
+ externalId: z.string().optional(),
43
+ }).strict();
44
+ /**
45
+ * MUST be kept in sync with @vertesia/common InCodePrompt
46
+ * Zod schema for prompt definition
47
+ */
48
+ export const PromptDefinitionSchema = z.object({
49
+ role: z.nativeEnum(PromptRole),
50
+ content: z.string(),
51
+ content_type: z.nativeEnum(TemplateType),
52
+ schema: z.any().optional(),
53
+ name: z.string().optional(),
54
+ externalId: z.string().optional(),
55
+ });
56
+ /**
57
+ * Normalize schema path for import
58
+ * - Adds './' prefix if not a relative path
59
+ * - Replaces .ts with .js
60
+ * - Adds .js if no extension
61
+ *
62
+ * @param schemaPath - Original schema path from frontmatter
63
+ * @returns Normalized path for ES module import
64
+ */
65
+ function normalizeSchemaPath(schemaPath) {
66
+ let normalized = schemaPath.trim();
67
+ // Add './' prefix if not already a relative path
68
+ if (!normalized.startsWith('.')) {
69
+ normalized = './' + normalized;
70
+ }
71
+ // Get the extension
72
+ const ext = path.extname(normalized);
73
+ if (ext === '.ts') {
74
+ // Replace .ts with .js
75
+ normalized = normalized.slice(0, -3) + '.js';
76
+ }
77
+ else if (!ext) {
78
+ // No extension, add .js
79
+ normalized = normalized + '.js';
80
+ }
81
+ // If extension is already .js or something else, leave as is
82
+ return normalized;
83
+ }
84
+ /**
85
+ * Infer content type from file extension
86
+ *
87
+ * @param filePath - Path to the prompt file
88
+ * @returns Inferred content type
89
+ */
90
+ function inferContentType(filePath) {
91
+ const ext = path.extname(filePath).toLowerCase();
92
+ switch (ext) {
93
+ case '.jst':
94
+ return TemplateType.jst;
95
+ case '.hbs':
96
+ return TemplateType.handlebars;
97
+ default:
98
+ return TemplateType.text;
99
+ }
100
+ }
101
+ /**
102
+ * Build a PromptDefinition from frontmatter and content
103
+ *
104
+ * @param frontmatter - Parsed frontmatter object
105
+ * @param content - Prompt content (body of the file)
106
+ * @param filePath - Path to the prompt file (for content type inference)
107
+ * @returns Prompt definition object and optional imports
108
+ */
109
+ function buildPromptDefinition(frontmatter, content, filePath) {
110
+ // Determine content type from frontmatter or file extension
111
+ const content_type = frontmatter.content_type || inferContentType(filePath);
112
+ const prompt = {
113
+ role: frontmatter.role,
114
+ content,
115
+ content_type,
116
+ };
117
+ // Add optional fields
118
+ if (frontmatter.name) {
119
+ prompt.name = frontmatter.name;
120
+ }
121
+ if (frontmatter.externalId) {
122
+ prompt.externalId = frontmatter.externalId;
123
+ }
124
+ // Handle schema import if specified
125
+ let imports;
126
+ let schemaImportName;
127
+ if (frontmatter.schema) {
128
+ const normalizedPath = normalizeSchemaPath(frontmatter.schema);
129
+ schemaImportName = '__promptSchema';
130
+ imports = [`import ${schemaImportName} from '${normalizedPath}';`];
131
+ }
132
+ return { prompt, imports, schemaImportName };
133
+ }
134
+ /**
135
+ * Prompt transformer preset
136
+ * Transforms template files with ?prompt suffix into prompt definition objects
137
+ *
138
+ * Supported file types:
139
+ * - .jst (JavaScript template literals) → content_type: 'jst'
140
+ * - .hbs (Handlebars templates) → content_type: 'handlebars'
141
+ * - .txt or other → content_type: 'text'
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * import PROMPT from './prompt.hbs?prompt';
146
+ * // PROMPT is an InCodePrompt object
147
+ * ```
148
+ */
149
+ export const promptTransformer = {
150
+ pattern: /\?prompt$/,
151
+ schema: PromptDefinitionSchema,
152
+ transform: (content, filePath) => {
153
+ const { frontmatter, content: promptContent } = parseFrontmatter(content);
154
+ // Validate frontmatter
155
+ const frontmatterValidation = PromptFrontmatterSchema.safeParse(frontmatter);
156
+ if (!frontmatterValidation.success) {
157
+ const errors = frontmatterValidation.error.errors
158
+ .map((err) => {
159
+ const path = err.path.length > 0 ? err.path.join('.') : 'frontmatter';
160
+ return ` - ${path}: ${err.message}`;
161
+ })
162
+ .join('\n');
163
+ throw new Error(`Invalid frontmatter in ${filePath}:\n${errors}`);
164
+ }
165
+ // Build prompt definition
166
+ const { prompt, imports, schemaImportName } = buildPromptDefinition(frontmatter, promptContent, filePath);
167
+ // If schema is specified, generate custom code with schema reference
168
+ if (schemaImportName) {
169
+ // Build the code manually to avoid JSON.stringify issues with schema reference
170
+ const lines = [
171
+ 'export default {',
172
+ ` role: "${prompt.role}",`,
173
+ ` content: ${JSON.stringify(prompt.content)},`,
174
+ ` content_type: "${prompt.content_type}",`,
175
+ ` schema: ${schemaImportName}`,
176
+ ];
177
+ if (prompt.name) {
178
+ lines.splice(4, 0, ` name: ${JSON.stringify(prompt.name)},`);
179
+ }
180
+ if (prompt.externalId) {
181
+ lines.splice(4, 0, ` externalId: ${JSON.stringify(prompt.externalId)},`);
182
+ }
183
+ lines.push('};');
184
+ const code = lines.join('\n');
185
+ return {
186
+ data: prompt,
187
+ imports,
188
+ code,
189
+ };
190
+ }
191
+ // Standard case without schema
192
+ return {
193
+ data: prompt,
194
+ };
195
+ }
196
+ };
197
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/presets/prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACpB,2BAAW,CAAA;IACX,yCAAyB,CAAA;IACzB,6BAAa,CAAA;AACjB,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB;AAOD;;;GAGG;AACH,MAAM,CAAN,IAAY,UAMX;AAND,WAAY,UAAU;IAClB,+BAAiB,CAAA;IACjB,+BAAiB,CAAA;IACjB,2BAAa,CAAA;IACb,qCAAuB,CAAA;IACvB,mCAAqB,CAAA;AACzB,CAAC,EANW,UAAU,KAAV,UAAU,QAMrB;AAED;;GAEG;AACH,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,kBAAkB;IAClB,IAAI,EAAE,CAAC,CAAC,UAAU,CAAC,UAAU,EAAE;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,gEAAgE,EAAE,CAAC;KAClG,CAAC;IAEF,kBAAkB;IAClB,YAAY,EAAE,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE;IACnD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,UAAU,EA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,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClE,CAAC;YACD,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBACpB,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,iBAAiB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAC9E,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE9B,OAAO;gBACH,IAAI,EAAE,MAAM;gBACZ,OAAO;gBACP,IAAI;aACP,CAAC;QACN,CAAC;QAED,+BAA+B;QAC/B,OAAO;YACH,IAAI,EAAE,MAAM;SACf,CAAC;IACN,CAAC;CACJ,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Skill collection transformer for directory-based skill imports
3
+ * Scans a directory for subdirectories containing SKILL.md files
4
+ */
5
+ import { readdirSync, statSync, existsSync } from 'node:fs';
6
+ import path from 'node:path';
7
+ /**
8
+ * Skill collection transformer preset
9
+ * Transforms directory imports with ?skills suffix into an array of skill imports
10
+ *
11
+ * Matches:
12
+ * - ./all?skills (recommended - generates all.js in the directory)
13
+ * - ./_skills?skills (generates _skills.js in the directory)
14
+ * - Any path ending with a filename and ?skills
15
+ *
16
+ * NOTE: A filename before ?skills is REQUIRED to avoid naming conflicts.
17
+ * The filename becomes the output module name.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * import skills from './all?skills';
22
+ * // Scans current directory for subdirectories with SKILL.md
23
+ * // Generates all.js containing array of all skills
24
+ * ```
25
+ */
26
+ export const skillCollectionTransformer = {
27
+ pattern: /\/[^/?]+\?skills$/,
28
+ virtual: true, // Indicates this doesn't transform a real file
29
+ transform: (_content, filePath) => {
30
+ // Remove ?skills suffix and the filename to get directory path
31
+ // Example: /path/code/all?skills -> /path/code/all -> /path/code/
32
+ const pathWithoutQuery = filePath.replace(/\?skills$/, '');
33
+ const dirPath = path.dirname(pathWithoutQuery);
34
+ if (!existsSync(dirPath)) {
35
+ throw new Error(`Directory not found: ${dirPath}`);
36
+ }
37
+ if (!statSync(dirPath).isDirectory()) {
38
+ throw new Error(`Not a directory: ${dirPath}`);
39
+ }
40
+ // Scan for subdirectories containing SKILL.md
41
+ const entries = readdirSync(dirPath);
42
+ const imports = [];
43
+ const names = [];
44
+ for (const entry of entries) {
45
+ const entryPath = path.join(dirPath, entry);
46
+ try {
47
+ if (statSync(entryPath).isDirectory()) {
48
+ const skillFile = path.join(entryPath, 'SKILL.md');
49
+ if (existsSync(skillFile)) {
50
+ // Generate unique identifier from directory name
51
+ const identifier = `Skill_${entry.replace(/[^a-zA-Z0-9_]/g, '_')}`;
52
+ imports.push(`import ${identifier} from './${entry}/SKILL.md';`);
53
+ names.push(identifier);
54
+ }
55
+ }
56
+ }
57
+ catch (err) {
58
+ // Skip entries that can't be read
59
+ continue;
60
+ }
61
+ }
62
+ if (names.length === 0) {
63
+ console.warn(`No SKILL.md files found in subdirectories of ${dirPath}`);
64
+ }
65
+ // Generate code that imports all skills and exports as array
66
+ const code = [
67
+ ...imports,
68
+ '',
69
+ `export default [${names.join(', ')}];`
70
+ ].join('\n');
71
+ return {
72
+ data: null, // Not used when custom code is provided
73
+ code
74
+ };
75
+ }
76
+ };
77
+ //# sourceMappingURL=skill-collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-collection.js","sourceRoot":"","sources":["../../../src/presets/skill-collection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,0BA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U,YAAY,KAAK,aAAa,CAAC,CAAC;wBACjE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;oBAC3B,CAAC;gBACL,CAAC;YACL,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACX,kCAAkC;gBAClC,SAAS;YACb,CAAC;QACL,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,gDAAgD,OAAO,EAAE,CAAC,CAAC;QAC5E,CAAC;QAED,6DAA6D;QAC7D,MAAM,IAAI,GAAG;YACT,GAAG,OAAO;YACV,EAAE;YACF,mBAAmB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;SAC1C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEb,OAAO;YACH,IAAI,EAAE,IAAI,EAAE,wCAAwC;YACpD,IAAI;SACP,CAAC;IACN,CAAC;CACJ,CAAC"}
@@ -19,6 +19,6 @@
19
19
  */
20
20
  export { vertesiaImportPlugin } from './plugin.js';
21
21
  export type { PluginConfig, TransformerRule, TransformerPreset, TransformFunction, TransformResult, AssetFile, WidgetConfig } from './types.js';
22
- export { skillTransformer, rawTransformer, SkillDefinitionSchema, type SkillDefinition, type SkillContentType } from './presets/index.js';
22
+ export { skillTransformer, rawTransformer, skillCollectionTransformer, promptTransformer, SkillDefinitionSchema, PromptDefinitionSchema, type SkillDefinition, type SkillContentType, type PromptDefinition, type PromptContentType, PromptRole, TemplateType } from './presets/index.js';
23
23
  export { parseFrontmatter, type FrontmatterResult } from './parsers/frontmatter.js';
24
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnD,YAAY,EACR,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,SAAS,EACT,YAAY,EACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EACH,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACxB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnD,YAAY,EACR,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,SAAS,EACT,YAAY,EACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EACH,gBAAgB,EAChB,cAAc,EACd,0BAA0B,EAC1B,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,UAAU,EACV,YAAY,EACf,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,KAAK,EAAE,YAAY,EAA8B,MAAM,YAAY,CAAC;AAK3E;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CA8IjE"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,KAAK,EAAE,YAAY,EAA8B,MAAM,YAAY,CAAC;AAK3E;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAsJjE"}
@@ -2,5 +2,7 @@
2
2
  * Preset transformers for common use cases
3
3
  */
4
4
  export { skillTransformer, SkillDefinitionSchema, type SkillDefinition, type SkillContentType } from './skill.js';
5
+ export { skillCollectionTransformer } from './skill-collection.js';
5
6
  export { rawTransformer } from './raw.js';
7
+ export { promptTransformer, PromptDefinitionSchema, type PromptDefinition, type PromptContentType, PromptRole, TemplateType } from './prompt.js';
6
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presets/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presets/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAClH,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Prompt transformer preset for template files with frontmatter
3
+ * Supports .jst, .hbs, and plain text files
4
+ */
5
+ import { z } from 'zod';
6
+ import type { TransformerPreset } from '../types.js';
7
+ /**
8
+ * Template type for prompt content
9
+ * MUST match TemplateType from @vertesia/common
10
+ */
11
+ export declare enum TemplateType {
12
+ jst = "jst",
13
+ handlebars = "handlebars",
14
+ text = "text"
15
+ }
16
+ /**
17
+ * Template type alias
18
+ */
19
+ export type PromptContentType = TemplateType;
20
+ /**
21
+ * Prompt role enum
22
+ * MUST match PromptRole from @llumiverse/common
23
+ */
24
+ export declare enum PromptRole {
25
+ safety = "safety",
26
+ system = "system",
27
+ user = "user",
28
+ assistant = "assistant",
29
+ negative = "negative"
30
+ }
31
+ /**
32
+ * MUST be kept in sync with @vertesia/common InCodePrompt
33
+ * Zod schema for prompt definition
34
+ */
35
+ export declare const PromptDefinitionSchema: z.ZodObject<{
36
+ role: z.ZodNativeEnum<typeof PromptRole>;
37
+ content: z.ZodString;
38
+ content_type: z.ZodNativeEnum<typeof TemplateType>;
39
+ schema: z.ZodOptional<z.ZodAny>;
40
+ name: z.ZodOptional<z.ZodString>;
41
+ externalId: z.ZodOptional<z.ZodString>;
42
+ }, "strip", z.ZodTypeAny, {
43
+ content_type: TemplateType;
44
+ content: string;
45
+ role: PromptRole;
46
+ schema?: any;
47
+ name?: string | undefined;
48
+ externalId?: string | undefined;
49
+ }, {
50
+ content_type: TemplateType;
51
+ content: string;
52
+ role: PromptRole;
53
+ schema?: any;
54
+ name?: string | undefined;
55
+ externalId?: string | undefined;
56
+ }>;
57
+ /**
58
+ * TypeScript type inferred from the Zod schema
59
+ */
60
+ export type PromptDefinition = z.infer<typeof PromptDefinitionSchema>;
61
+ /**
62
+ * Prompt transformer preset
63
+ * Transforms template files with ?prompt suffix into prompt definition objects
64
+ *
65
+ * Supported file types:
66
+ * - .jst (JavaScript template literals) → content_type: 'jst'
67
+ * - .hbs (Handlebars templates) → content_type: 'handlebars'
68
+ * - .txt or other → content_type: 'text'
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * import PROMPT from './prompt.hbs?prompt';
73
+ * // PROMPT is an InCodePrompt object
74
+ * ```
75
+ */
76
+ export declare const promptTransformer: TransformerPreset;
77
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../../src/presets/prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIrD;;;GAGG;AACH,oBAAY,YAAY;IACpB,GAAG,QAAQ;IACX,UAAU,eAAe;IACzB,IAAI,SAAS;CAChB;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAE7C;;;GAGG;AACH,oBAAY,UAAU;IAClB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,SAAS,cAAc;IACvB,QAAQ,aAAa;CACxB;AAkBD;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;EAOjC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAiGtE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,EAAE,iBA4D/B,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Skill collection transformer for directory-based skill imports
3
+ * Scans a directory for subdirectories containing SKILL.md files
4
+ */
5
+ import type { TransformerPreset } from '../types.js';
6
+ /**
7
+ * Skill collection transformer preset
8
+ * Transforms directory imports with ?skills suffix into an array of skill imports
9
+ *
10
+ * Matches:
11
+ * - ./all?skills (recommended - generates all.js in the directory)
12
+ * - ./_skills?skills (generates _skills.js in the directory)
13
+ * - Any path ending with a filename and ?skills
14
+ *
15
+ * NOTE: A filename before ?skills is REQUIRED to avoid naming conflicts.
16
+ * The filename becomes the output module name.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import skills from './all?skills';
21
+ * // Scans current directory for subdirectories with SKILL.md
22
+ * // Generates all.js containing array of all skills
23
+ * ```
24
+ */
25
+ export declare const skillCollectionTransformer: TransformerPreset;
26
+ //# sourceMappingURL=skill-collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-collection.d.ts","sourceRoot":"","sources":["../../../src/presets/skill-collection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,0BAA0B,EAAE,iBAyDxC,CAAC"}
@@ -46,6 +46,8 @@ export interface TransformerRule {
46
46
  transform: TransformFunction;
47
47
  /** Optional: Zod schema for validation */
48
48
  schema?: z.ZodType<any>;
49
+ /** Optional: If true, the transformer generates virtual modules (no file to read) */
50
+ virtual?: boolean;
49
51
  /** Optional: additional options for this transformer */
50
52
  options?: Record<string, unknown>;
51
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IAEnB,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IAEjB,oCAAoC;IACpC,IAAI,EAAE,QAAQ,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,sDAAsD;IACtD,IAAI,EAAE,OAAO,CAAC;IAEd,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,+CAA+C;IAC/C,MAAM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,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAErC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,0CAA0C;IAC1C,YAAY,EAAE,eAAe,EAAE,CAAC;IAEhC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAE3B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertesia/build-tools",
3
- "version": "0.80.0",
3
+ "version": "0.80.1",
4
4
  "description": "Build tools for Vertesia projects - Rollup and Vite plugins for transforming imports, bundling skills, and compiling widgets",
5
5
  "type": "module",
6
6
  "main": "./lib/esm/index.js",
package/src/index.ts CHANGED
@@ -36,9 +36,16 @@ export type {
36
36
  export {
37
37
  skillTransformer,
38
38
  rawTransformer,
39
+ skillCollectionTransformer,
40
+ promptTransformer,
39
41
  SkillDefinitionSchema,
42
+ PromptDefinitionSchema,
40
43
  type SkillDefinition,
41
- type SkillContentType
44
+ type SkillContentType,
45
+ type PromptDefinition,
46
+ type PromptContentType,
47
+ PromptRole,
48
+ TemplateType
42
49
  } from './presets/index.js';
43
50
 
44
51
  // Utilities
package/src/plugin.ts CHANGED
@@ -39,7 +39,13 @@ export function vertesiaImportPlugin(config: PluginConfig): Plugin {
39
39
  // Handle relative imports
40
40
  if (source.startsWith('.') && importer) {
41
41
  const cleanSource = source.replace(transformer.pattern, '');
42
- const resolved = path.resolve(path.dirname(importer), cleanSource);
42
+ // Strip query parameters from importer to get the file path
43
+ const cleanImporter = importer.indexOf('?') >= 0
44
+ ? importer.substring(0, importer.indexOf('?'))
45
+ : importer;
46
+ // Always use dirname to get the directory containing the importer
47
+ const baseDir = path.dirname(cleanImporter);
48
+ const resolved = path.resolve(baseDir, cleanSource);
43
49
  // Return with the pattern suffix to identify it in load
44
50
  const suffix = source.match(transformer.pattern)?.[0] || '';
45
51
  return resolved + suffix;
@@ -75,8 +81,10 @@ export function vertesiaImportPlugin(config: PluginConfig): Plugin {
75
81
  }
76
82
 
77
83
  try {
78
- // Read file content
79
- const content = readFileSync(cleanId, 'utf-8');
84
+ // Read file content (skip for virtual transforms)
85
+ const content = matchedTransformer.virtual
86
+ ? ''
87
+ : readFileSync(cleanId, 'utf-8');
80
88
 
81
89
  // Transform the content
82
90
  const result = await matchedTransformer.transform(content, cleanId);
@@ -105,12 +113,12 @@ export function vertesiaImportPlugin(config: PluginConfig): Plugin {
105
113
  }
106
114
 
107
115
  // Generate code
116
+ const imports = result.imports ? result.imports.join('\n') + '\n\n' : '';
108
117
  if (result.code) {
109
- // Custom code provided
110
- return result.code;
118
+ // Custom code provided - prepend imports
119
+ return imports + result.code;
111
120
  } else {
112
121
  // Default: export data (escape if string, otherwise stringify as JSON)
113
- const imports = result.imports ? result.imports.join('\n') + '\n\n' : '';
114
122
  const dataJson = JSON.stringify(result.data, null, 2);
115
123
  return `${imports}export default ${dataJson};`;
116
124
  }
@@ -3,4 +3,6 @@
3
3
  */
4
4
 
5
5
  export { skillTransformer, SkillDefinitionSchema, type SkillDefinition, type SkillContentType } from './skill.js';
6
+ export { skillCollectionTransformer } from './skill-collection.js';
6
7
  export { rawTransformer } from './raw.js';
8
+ export { promptTransformer, PromptDefinitionSchema, type PromptDefinition, type PromptContentType, PromptRole, TemplateType } from './prompt.js';