@vertesia/build-tools 0.24.0-dev.202601221707

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 (90) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +334 -0
  3. package/lib/build-tools.js +1730 -0
  4. package/lib/build-tools.js.map +1 -0
  5. package/lib/cjs/index.js +39 -0
  6. package/lib/cjs/index.js.map +1 -0
  7. package/lib/cjs/package.json +3 -0
  8. package/lib/cjs/parsers/frontmatter.js +25 -0
  9. package/lib/cjs/parsers/frontmatter.js.map +1 -0
  10. package/lib/cjs/plugin.js +150 -0
  11. package/lib/cjs/plugin.js.map +1 -0
  12. package/lib/cjs/presets/index.js +19 -0
  13. package/lib/cjs/presets/index.js.map +1 -0
  14. package/lib/cjs/presets/prompt.js +185 -0
  15. package/lib/cjs/presets/prompt.js.map +1 -0
  16. package/lib/cjs/presets/raw.js +25 -0
  17. package/lib/cjs/presets/raw.js.map +1 -0
  18. package/lib/cjs/presets/skill-collection.js +83 -0
  19. package/lib/cjs/presets/skill-collection.js.map +1 -0
  20. package/lib/cjs/presets/skill.js +224 -0
  21. package/lib/cjs/presets/skill.js.map +1 -0
  22. package/lib/cjs/types.js +6 -0
  23. package/lib/cjs/types.js.map +1 -0
  24. package/lib/cjs/utils/asset-copy.js +61 -0
  25. package/lib/cjs/utils/asset-copy.js.map +1 -0
  26. package/lib/cjs/utils/asset-discovery.js +100 -0
  27. package/lib/cjs/utils/asset-discovery.js.map +1 -0
  28. package/lib/cjs/utils/widget-compiler.js +115 -0
  29. package/lib/cjs/utils/widget-compiler.js.map +1 -0
  30. package/lib/esm/index.js +26 -0
  31. package/lib/esm/index.js.map +1 -0
  32. package/lib/esm/parsers/frontmatter.js +19 -0
  33. package/lib/esm/parsers/frontmatter.js.map +1 -0
  34. package/lib/esm/plugin.js +144 -0
  35. package/lib/esm/plugin.js.map +1 -0
  36. package/lib/esm/presets/index.js +8 -0
  37. package/lib/esm/presets/index.js.map +1 -0
  38. package/lib/esm/presets/prompt.js +181 -0
  39. package/lib/esm/presets/prompt.js.map +1 -0
  40. package/lib/esm/presets/raw.js +22 -0
  41. package/lib/esm/presets/raw.js.map +1 -0
  42. package/lib/esm/presets/skill-collection.js +77 -0
  43. package/lib/esm/presets/skill-collection.js.map +1 -0
  44. package/lib/esm/presets/skill.js +221 -0
  45. package/lib/esm/presets/skill.js.map +1 -0
  46. package/lib/esm/types.js +5 -0
  47. package/lib/esm/types.js.map +1 -0
  48. package/lib/esm/utils/asset-copy.js +54 -0
  49. package/lib/esm/utils/asset-copy.js.map +1 -0
  50. package/lib/esm/utils/asset-discovery.js +94 -0
  51. package/lib/esm/utils/asset-discovery.js.map +1 -0
  52. package/lib/esm/utils/widget-compiler.js +76 -0
  53. package/lib/esm/utils/widget-compiler.js.map +1 -0
  54. package/lib/types/index.d.ts +24 -0
  55. package/lib/types/index.d.ts.map +1 -0
  56. package/lib/types/parsers/frontmatter.d.ts +19 -0
  57. package/lib/types/parsers/frontmatter.d.ts.map +1 -0
  58. package/lib/types/plugin.d.ts +10 -0
  59. package/lib/types/plugin.d.ts.map +1 -0
  60. package/lib/types/presets/index.d.ts +8 -0
  61. package/lib/types/presets/index.d.ts.map +1 -0
  62. package/lib/types/presets/prompt.d.ts +63 -0
  63. package/lib/types/presets/prompt.d.ts.map +1 -0
  64. package/lib/types/presets/raw.d.ts +16 -0
  65. package/lib/types/presets/raw.d.ts.map +1 -0
  66. package/lib/types/presets/skill-collection.d.ts +26 -0
  67. package/lib/types/presets/skill-collection.d.ts.map +1 -0
  68. package/lib/types/presets/skill.d.ts +139 -0
  69. package/lib/types/presets/skill.d.ts.map +1 -0
  70. package/lib/types/types.d.ts +115 -0
  71. package/lib/types/types.d.ts.map +1 -0
  72. package/lib/types/utils/asset-copy.d.ts +20 -0
  73. package/lib/types/utils/asset-copy.d.ts.map +1 -0
  74. package/lib/types/utils/asset-discovery.d.ts +38 -0
  75. package/lib/types/utils/asset-discovery.d.ts.map +1 -0
  76. package/lib/types/utils/widget-compiler.d.ts +15 -0
  77. package/lib/types/utils/widget-compiler.d.ts.map +1 -0
  78. package/package.json +69 -0
  79. package/src/index.ts +52 -0
  80. package/src/parsers/frontmatter.ts +32 -0
  81. package/src/plugin.ts +166 -0
  82. package/src/presets/index.ts +8 -0
  83. package/src/presets/prompt.ts +227 -0
  84. package/src/presets/raw.ts +24 -0
  85. package/src/presets/skill-collection.ts +86 -0
  86. package/src/presets/skill.ts +271 -0
  87. package/src/types.ts +140 -0
  88. package/src/utils/asset-copy.ts +63 -0
  89. package/src/utils/asset-discovery.ts +138 -0
  90. package/src/utils/widget-compiler.ts +98 -0
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Core Rollup plugin implementation for transforming imports
3
+ */
4
+ import { readFileSync } from 'node:fs';
5
+ import path from 'node:path';
6
+ import { copyAssets } from './utils/asset-copy.js';
7
+ import { compileWidgets } from './utils/widget-compiler.js';
8
+ /**
9
+ * Creates a Rollup plugin that transforms imports based on configured rules
10
+ */
11
+ export function vertesiaImportPlugin(config) {
12
+ const { transformers, assetsDir = './dist', widgetConfig } = config;
13
+ if (!transformers || transformers.length === 0) {
14
+ throw new Error('vertesiaImportPlugin: At least one transformer must be configured');
15
+ }
16
+ // Track assets to copy and widgets to compile
17
+ const assetsToProcess = [];
18
+ const widgetsToCompile = [];
19
+ const shouldCopyAssets = assetsDir !== false;
20
+ const shouldCompileWidgets = widgetConfig !== undefined && assetsDir !== false;
21
+ return {
22
+ name: 'vertesia-import-plugin',
23
+ /**
24
+ * Resolve import IDs to handle pattern-based imports
25
+ */
26
+ resolveId(source, importer) {
27
+ // Check if any transformer pattern matches
28
+ for (const transformer of transformers) {
29
+ if (transformer.pattern.test(source)) {
30
+ // Handle relative imports
31
+ if (source.startsWith('.') && importer) {
32
+ const cleanSource = source.replace(transformer.pattern, '');
33
+ // Strip query parameters from importer to get the file path
34
+ const cleanImporter = importer.indexOf('?') >= 0
35
+ ? importer.substring(0, importer.indexOf('?'))
36
+ : importer;
37
+ // Always use dirname to get the directory containing the importer
38
+ const baseDir = path.dirname(cleanImporter);
39
+ const resolved = path.resolve(baseDir, cleanSource);
40
+ // Return with the pattern suffix to identify it in load
41
+ const suffix = source.match(transformer.pattern)?.[0] || '';
42
+ return resolved + suffix;
43
+ }
44
+ return source;
45
+ }
46
+ }
47
+ return null; // Let other plugins handle it
48
+ },
49
+ /**
50
+ * Load and transform the file content
51
+ */
52
+ async load(id) {
53
+ // Find matching transformer
54
+ let matchedTransformer;
55
+ let cleanId = id;
56
+ for (const transformer of transformers) {
57
+ if (transformer.pattern.test(id)) {
58
+ matchedTransformer = transformer;
59
+ // Remove query parameters to get actual file path
60
+ // For example: '/path/file.md?skill' -> '/path/file.md'
61
+ // '/path/file.html?raw' -> '/path/file.html'
62
+ const queryIndex = id.indexOf('?');
63
+ cleanId = queryIndex >= 0 ? id.substring(0, queryIndex) : id;
64
+ break;
65
+ }
66
+ }
67
+ if (!matchedTransformer) {
68
+ return null; // Not for us
69
+ }
70
+ try {
71
+ // Read file content (skip for virtual transforms)
72
+ const content = matchedTransformer.virtual
73
+ ? ''
74
+ : readFileSync(cleanId, 'utf-8');
75
+ // Transform the content
76
+ const result = await matchedTransformer.transform(content, cleanId);
77
+ // Collect assets if any
78
+ if (result.assets && shouldCopyAssets) {
79
+ assetsToProcess.push(...result.assets);
80
+ }
81
+ // Collect widgets if any
82
+ if (result.widgets && shouldCompileWidgets) {
83
+ widgetsToCompile.push(...result.widgets);
84
+ }
85
+ // Validate if schema provided
86
+ if (matchedTransformer.schema) {
87
+ const validation = matchedTransformer.schema.safeParse(result.data);
88
+ if (!validation.success) {
89
+ const errors = validation.error.errors
90
+ .map((err) => ` - ${err.path.join('.')}: ${err.message}`)
91
+ .join('\n');
92
+ throw new Error(`Validation failed for ${id}:\n${errors}`);
93
+ }
94
+ }
95
+ // Generate code
96
+ const imports = result.imports ? result.imports.join('\n') + '\n\n' : '';
97
+ if (result.code) {
98
+ // Custom code provided - prepend imports
99
+ return imports + result.code;
100
+ }
101
+ else {
102
+ // Default: export data (escape if string, otherwise stringify as JSON)
103
+ const dataJson = JSON.stringify(result.data, null, 2);
104
+ return `${imports}export default ${dataJson};`;
105
+ }
106
+ }
107
+ catch (error) {
108
+ const message = error instanceof Error ? error.message : String(error);
109
+ this.error(`Failed to transform ${id}: ${message}`);
110
+ }
111
+ },
112
+ /**
113
+ * Copy assets and compile widgets after all modules are loaded
114
+ */
115
+ async buildEnd() {
116
+ // Copy script assets
117
+ if (shouldCopyAssets && assetsToProcess.length > 0) {
118
+ try {
119
+ const copied = copyAssets(assetsToProcess, assetsDir);
120
+ console.log(`Copied ${copied} asset file(s) to ${assetsDir}`);
121
+ }
122
+ catch (error) {
123
+ const message = error instanceof Error ? error.message : String(error);
124
+ this.warn(`Failed to copy assets: ${message}`);
125
+ }
126
+ }
127
+ // Compile widgets
128
+ if (shouldCompileWidgets && widgetsToCompile.length > 0) {
129
+ try {
130
+ const widgetsDir = config.widgetsDir || 'widgets';
131
+ const outputDir = path.join(assetsDir, widgetsDir);
132
+ console.log(`Compiling ${widgetsToCompile.length} widget(s)...`);
133
+ const compiled = await compileWidgets(widgetsToCompile, outputDir, widgetConfig);
134
+ console.log(`Compiled ${compiled} widget(s) to ${outputDir}`);
135
+ }
136
+ catch (error) {
137
+ const message = error instanceof Error ? error.message : String(error);
138
+ this.error(`Failed to compile widgets: ${message}`);
139
+ }
140
+ }
141
+ }
142
+ };
143
+ }
144
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D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,CAAC,MAAM,eAAe,CAAC,CAAC;oBACjE,MAAM,QAAQ,GAAG,MAAM,cAAc,CACjC,gBAAgB,EAChB,SAAS,EACT,YAAY,CACf,CAAC;oBACF,OAAO,CAAC,GAAG,CAAC,YAAY,QAAQ,iBAAiB,SAAS,EAAE,CAAC,CAAC;gBAClE,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACb,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBACvE,IAAI,CAAC,KAAK,CAAC,8BAA8B,OAAO,EAAE,CAAC,CAAC;gBACxD,CAAC;YACL,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Preset transformers for common use cases
3
+ */
4
+ export { skillTransformer, SkillDefinitionSchema } from './skill.js';
5
+ export { skillCollectionTransformer } from './skill-collection.js';
6
+ export { rawTransformer } from './raw.js';
7
+ export { promptTransformer, PromptDefinitionSchema, PromptRole, TemplateType } from './prompt.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/presets/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAA+C,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,EAAiD,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,181 @@
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
+ import { TemplateType } from '@vertesia/common';
9
+ import { PromptRole } from '@llumiverse/common';
10
+ /**
11
+ * Re-export types for backwards compatibility
12
+ */
13
+ export { TemplateType, PromptRole };
14
+ /**
15
+ * Zod schema for prompt frontmatter validation
16
+ */
17
+ const PromptFrontmatterSchema = z.object({
18
+ // Required fields
19
+ role: z.nativeEnum(PromptRole, {
20
+ errorMap: () => ({ message: 'Role must be one of: safety, system, user, assistant, negative' })
21
+ }),
22
+ // Optional fields
23
+ content_type: z.nativeEnum(TemplateType).optional(),
24
+ schema: z.string().optional(),
25
+ name: z.string().optional(),
26
+ externalId: z.string().optional(),
27
+ }).strict();
28
+ /**
29
+ * MUST be kept in sync with @vertesia/common InCodePrompt
30
+ * Zod schema for prompt definition
31
+ */
32
+ export const PromptDefinitionSchema = z.object({
33
+ role: z.nativeEnum(PromptRole),
34
+ content: z.string(),
35
+ content_type: z.nativeEnum(TemplateType),
36
+ schema: z.any().optional(),
37
+ name: z.string().optional(),
38
+ externalId: z.string().optional(),
39
+ });
40
+ /**
41
+ * Normalize schema path for import
42
+ * - Adds './' prefix if not a relative path
43
+ * - Replaces .ts with .js
44
+ * - Adds .js if no extension
45
+ *
46
+ * @param schemaPath - Original schema path from frontmatter
47
+ * @returns Normalized path for ES module import
48
+ */
49
+ function normalizeSchemaPath(schemaPath) {
50
+ let normalized = schemaPath.trim();
51
+ // Add './' prefix if not already a relative path
52
+ if (!normalized.startsWith('.')) {
53
+ normalized = './' + normalized;
54
+ }
55
+ // Get the extension
56
+ const ext = path.extname(normalized);
57
+ if (ext === '.ts') {
58
+ // Replace .ts with .js
59
+ normalized = normalized.slice(0, -3) + '.js';
60
+ }
61
+ else if (!ext) {
62
+ // No extension, add .js
63
+ normalized = normalized + '.js';
64
+ }
65
+ // If extension is already .js or something else, leave as is
66
+ return normalized;
67
+ }
68
+ /**
69
+ * Infer content type from file extension
70
+ *
71
+ * @param filePath - Path to the prompt file
72
+ * @returns Inferred content type
73
+ */
74
+ function inferContentType(filePath) {
75
+ const ext = path.extname(filePath).toLowerCase();
76
+ switch (ext) {
77
+ case '.jst':
78
+ return TemplateType.jst;
79
+ case '.hbs':
80
+ return TemplateType.handlebars;
81
+ default:
82
+ return TemplateType.text;
83
+ }
84
+ }
85
+ /**
86
+ * Build a PromptDefinition from frontmatter and content
87
+ *
88
+ * @param frontmatter - Parsed frontmatter object
89
+ * @param content - Prompt content (body of the file)
90
+ * @param filePath - Path to the prompt file (for content type inference)
91
+ * @returns Prompt definition object and optional imports
92
+ */
93
+ function buildPromptDefinition(frontmatter, content, filePath) {
94
+ // Determine content type from frontmatter or file extension
95
+ const content_type = frontmatter.content_type || inferContentType(filePath);
96
+ const prompt = {
97
+ role: frontmatter.role,
98
+ content,
99
+ content_type,
100
+ };
101
+ // Add optional fields
102
+ if (frontmatter.name) {
103
+ prompt.name = frontmatter.name;
104
+ }
105
+ if (frontmatter.externalId) {
106
+ prompt.externalId = frontmatter.externalId;
107
+ }
108
+ // Handle schema import if specified
109
+ let imports;
110
+ let schemaImportName;
111
+ if (frontmatter.schema) {
112
+ const normalizedPath = normalizeSchemaPath(frontmatter.schema);
113
+ schemaImportName = '__promptSchema';
114
+ imports = [`import ${schemaImportName} from '${normalizedPath}';`];
115
+ }
116
+ return { prompt, imports, schemaImportName };
117
+ }
118
+ /**
119
+ * Prompt transformer preset
120
+ * Transforms template files with ?prompt suffix into prompt definition objects
121
+ *
122
+ * Supported file types:
123
+ * - .jst (JavaScript template literals) → content_type: 'jst'
124
+ * - .hbs (Handlebars templates) → content_type: 'handlebars'
125
+ * - .txt or other → content_type: 'text'
126
+ *
127
+ * @example
128
+ * ```typescript
129
+ * import PROMPT from './prompt.hbs?prompt';
130
+ * // PROMPT is an InCodePrompt object
131
+ * ```
132
+ */
133
+ export const promptTransformer = {
134
+ pattern: /\?prompt$/,
135
+ schema: PromptDefinitionSchema,
136
+ transform: (content, filePath) => {
137
+ const { frontmatter, content: promptContent } = parseFrontmatter(content);
138
+ // Validate frontmatter
139
+ const frontmatterValidation = PromptFrontmatterSchema.safeParse(frontmatter);
140
+ if (!frontmatterValidation.success) {
141
+ const errors = frontmatterValidation.error.errors
142
+ .map((err) => {
143
+ const path = err.path.length > 0 ? err.path.join('.') : 'frontmatter';
144
+ return ` - ${path}: ${err.message}`;
145
+ })
146
+ .join('\n');
147
+ throw new Error(`Invalid frontmatter in ${filePath}:\n${errors}`);
148
+ }
149
+ // Build prompt definition
150
+ const { prompt, imports, schemaImportName } = buildPromptDefinition(frontmatter, promptContent, filePath);
151
+ // If schema is specified, generate custom code with schema reference
152
+ if (schemaImportName) {
153
+ // Build the code manually to avoid JSON.stringify issues with schema reference
154
+ const lines = [
155
+ 'export default {',
156
+ ` role: "${prompt.role}",`,
157
+ ` content: ${JSON.stringify(prompt.content)},`,
158
+ ` content_type: "${prompt.content_type}",`,
159
+ ` schema: ${schemaImportName}`,
160
+ ];
161
+ if (prompt.name) {
162
+ lines.splice(4, 0, ` name: ${JSON.stringify(prompt.name)},`);
163
+ }
164
+ if (prompt.externalId) {
165
+ lines.splice(4, 0, ` externalId: ${JSON.stringify(prompt.externalId)},`);
166
+ }
167
+ lines.push('};');
168
+ const code = lines.join('\n');
169
+ return {
170
+ data: prompt,
171
+ imports,
172
+ code,
173
+ };
174
+ }
175
+ // Standard case without schema
176
+ return {
177
+ data: prompt,
178
+ };
179
+ }
180
+ };
181
+ //# 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;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;A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AAQ,MAAM,MAAM,EAAE,CACnD,CAAC;QACN,CAAC;QAED,0BAA0B;QAC1B,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,qBAAqB,CAC/D,WAAW,EACX,aAAa,EACb,QAAQ,CACX,CAAC;QAEF,qEAAqE;QACrE,IAAI,gBAAgB,EAAE,CAAC;YACnB,+EAA+E;YAC/E,MAAM,KAAK,GAAG;gBACV,kBAAkB;gBAClB,YAAY,MAAM,CAAC,IAAI,IAAI;gBAC3B,cAAc,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG;gBAC/C,oBAAoB,MAAM,CAAC,YAAY,IAAI;gBAC3C,aAAa,gBAAgB,EAAE;aAClC,CAAC;YAEF,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;gBACd,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,22 @@
1
+ /**
2
+ * Raw transformer preset for importing file content as strings
3
+ */
4
+ /**
5
+ * Raw transformer preset
6
+ * Transforms any file with ?raw suffix into a string export
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import template from './template.html?raw';
11
+ * // template is a string containing the file content
12
+ * ```
13
+ */
14
+ export const rawTransformer = {
15
+ pattern: /\?raw$/,
16
+ transform: (content) => {
17
+ return {
18
+ data: content
19
+ };
20
+ }
21
+ };
22
+ //# sourceMappingURL=raw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw.js","sourceRoot":"","sources":["../../../src/presets/raw.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,cAAc,GAAsB;IAC7C,OAAO,EAAE,QAAQ;IACjB,SAAS,EAAE,CAAC,OAAe,EAAE,EAAE;QAC3B,OAAO;YACH,IAAI,EAAE,OAAO;SAChB,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,0BAA0B,GAAsB;IACzD,OAAO,EAAE,mBAAmB;IAC5B,OAAO,EAAE,IAAI,EAAE,+CAA+C;IAC9D,SAAS,EAAE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