@vertesia/build-tools 1.0.0-dev.20260203.130115Z → 1.0.0-dev.20260225.024852Z

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 (80) hide show
  1. package/README.md +39 -0
  2. package/lib/build-tools.js +1798 -0
  3. package/lib/build-tools.js.map +1 -0
  4. package/lib/cjs/index.js +40 -0
  5. package/lib/cjs/index.js.map +1 -0
  6. package/lib/cjs/package.json +3 -0
  7. package/lib/cjs/parsers/frontmatter.js +25 -0
  8. package/lib/cjs/parsers/frontmatter.js.map +1 -0
  9. package/lib/cjs/plugin.js +150 -0
  10. package/lib/cjs/plugin.js.map +1 -0
  11. package/lib/cjs/presets/index.js +20 -0
  12. package/lib/cjs/presets/index.js.map +1 -0
  13. package/lib/cjs/presets/prompt.js +185 -0
  14. package/lib/cjs/presets/prompt.js.map +1 -0
  15. package/lib/cjs/presets/raw.js +25 -0
  16. package/lib/cjs/presets/raw.js.map +1 -0
  17. package/lib/cjs/presets/skill-collection.js +83 -0
  18. package/lib/cjs/presets/skill-collection.js.map +1 -0
  19. package/lib/cjs/presets/skill.js +272 -0
  20. package/lib/cjs/presets/skill.js.map +1 -0
  21. package/lib/cjs/types.js +6 -0
  22. package/lib/cjs/types.js.map +1 -0
  23. package/lib/cjs/utils/asset-copy.js +61 -0
  24. package/lib/cjs/utils/asset-copy.js.map +1 -0
  25. package/lib/cjs/utils/asset-discovery.js +100 -0
  26. package/lib/cjs/utils/asset-discovery.js.map +1 -0
  27. package/lib/cjs/utils/widget-compiler.js +115 -0
  28. package/lib/cjs/utils/widget-compiler.js.map +1 -0
  29. package/lib/esm/index.js +26 -0
  30. package/lib/esm/index.js.map +1 -0
  31. package/lib/esm/parsers/frontmatter.js +19 -0
  32. package/lib/esm/parsers/frontmatter.js.map +1 -0
  33. package/lib/esm/plugin.js +144 -0
  34. package/lib/esm/plugin.js.map +1 -0
  35. package/lib/esm/presets/index.js +8 -0
  36. package/lib/esm/presets/index.js.map +1 -0
  37. package/lib/esm/presets/prompt.js +181 -0
  38. package/lib/esm/presets/prompt.js.map +1 -0
  39. package/lib/esm/presets/raw.js +22 -0
  40. package/lib/esm/presets/raw.js.map +1 -0
  41. package/lib/esm/presets/skill-collection.js +77 -0
  42. package/lib/esm/presets/skill-collection.js.map +1 -0
  43. package/lib/esm/presets/skill.js +266 -0
  44. package/lib/esm/presets/skill.js.map +1 -0
  45. package/lib/esm/types.js +5 -0
  46. package/lib/esm/types.js.map +1 -0
  47. package/lib/esm/utils/asset-copy.js +54 -0
  48. package/lib/esm/utils/asset-copy.js.map +1 -0
  49. package/lib/esm/utils/asset-discovery.js +94 -0
  50. package/lib/esm/utils/asset-discovery.js.map +1 -0
  51. package/lib/esm/utils/widget-compiler.js +76 -0
  52. package/lib/esm/utils/widget-compiler.js.map +1 -0
  53. package/lib/types/index.d.ts +24 -0
  54. package/lib/types/index.d.ts.map +1 -0
  55. package/lib/types/parsers/frontmatter.d.ts +19 -0
  56. package/lib/types/parsers/frontmatter.d.ts.map +1 -0
  57. package/lib/types/plugin.d.ts +10 -0
  58. package/lib/types/plugin.d.ts.map +1 -0
  59. package/lib/types/presets/index.d.ts +8 -0
  60. package/lib/types/presets/index.d.ts.map +1 -0
  61. package/lib/types/presets/prompt.d.ts +63 -0
  62. package/lib/types/presets/prompt.d.ts.map +1 -0
  63. package/lib/types/presets/raw.d.ts +16 -0
  64. package/lib/types/presets/raw.d.ts.map +1 -0
  65. package/lib/types/presets/skill-collection.d.ts +26 -0
  66. package/lib/types/presets/skill-collection.d.ts.map +1 -0
  67. package/lib/types/presets/skill.d.ts +361 -0
  68. package/lib/types/presets/skill.d.ts.map +1 -0
  69. package/lib/types/types.d.ts +115 -0
  70. package/lib/types/types.d.ts.map +1 -0
  71. package/lib/types/utils/asset-copy.d.ts +20 -0
  72. package/lib/types/utils/asset-copy.d.ts.map +1 -0
  73. package/lib/types/utils/asset-discovery.d.ts +38 -0
  74. package/lib/types/utils/asset-discovery.d.ts.map +1 -0
  75. package/lib/types/utils/widget-compiler.d.ts +15 -0
  76. package/lib/types/utils/widget-compiler.d.ts.map +1 -0
  77. package/package.json +3 -3
  78. package/src/index.ts +1 -0
  79. package/src/presets/index.ts +1 -1
  80. package/src/presets/skill.ts +51 -3
@@ -0,0 +1,266 @@
1
+ /**
2
+ * Skill transformer preset for markdown files with frontmatter
3
+ */
4
+ import path from 'node:path';
5
+ import { existsSync } from 'node:fs';
6
+ import { z } from 'zod';
7
+ import { parseFrontmatter } from '../parsers/frontmatter.js';
8
+ import { discoverSkillAssets } from '../utils/asset-discovery.js';
9
+ /**
10
+ * Context triggers for auto-injection of skills (for frontmatter validation)
11
+ */
12
+ const SkillContextTriggersFrontmatterSchema = z.object({
13
+ keywords: z.array(z.string()).optional(),
14
+ tool_names: z.array(z.string()).optional(),
15
+ data_patterns: z.array(z.string()).optional()
16
+ }).strict();
17
+ /**
18
+ * Context triggers for auto-injection of skills (for output validation)
19
+ */
20
+ const SkillContextTriggersSchema = z.object({
21
+ keywords: z.array(z.string()).optional(),
22
+ tool_names: z.array(z.string()).optional(),
23
+ data_patterns: z.array(z.string()).optional()
24
+ }).optional();
25
+ /**
26
+ * Execution configuration for skills that need code execution (for frontmatter validation)
27
+ */
28
+ const SkillExecutionFrontmatterSchema = z.object({
29
+ language: z.string(),
30
+ packages: z.array(z.string()).optional(),
31
+ system_packages: z.array(z.string()).optional(),
32
+ template: z.string().optional()
33
+ }).strict();
34
+ /**
35
+ * Execution configuration for skills that need code execution (for output validation)
36
+ */
37
+ const SkillExecutionSchema = z.object({
38
+ language: z.string(),
39
+ packages: z.array(z.string()).optional(),
40
+ system_packages: z.array(z.string()).optional(),
41
+ template: z.string().optional()
42
+ }).optional();
43
+ /**
44
+ * Zod schema for skill frontmatter validation
45
+ * This validates the YAML frontmatter before transformation
46
+ * Supports both flat and nested structures
47
+ */
48
+ const SkillFrontmatterSchema = z.object({
49
+ // Required fields
50
+ name: z.string().min(1, 'Skill name is required'),
51
+ description: z.string().min(1, 'Skill description is required'),
52
+ // Optional fields
53
+ title: z.string().optional(),
54
+ content_type: z.enum(['md', 'jst']).optional(),
55
+ // Flat structure fields (legacy)
56
+ keywords: z.array(z.string()).optional(),
57
+ tools: z.array(z.string()).optional(),
58
+ data_patterns: z.array(z.string()).optional(),
59
+ language: z.string().optional(),
60
+ packages: z.array(z.string()).optional(),
61
+ system_packages: z.array(z.string()).optional(),
62
+ // Nested structure fields
63
+ context_triggers: SkillContextTriggersFrontmatterSchema.optional(),
64
+ execution: SkillExecutionFrontmatterSchema.optional(),
65
+ related_tools: z.array(z.string()).optional(),
66
+ input_schema: z.object({
67
+ type: z.literal('object'),
68
+ properties: z.record(z.any()).optional(),
69
+ required: z.array(z.string()).optional()
70
+ }).optional(),
71
+ // Asset fields (auto-discovered but can be overridden)
72
+ scripts: z.array(z.string()).optional(),
73
+ widgets: z.array(z.string()).optional()
74
+ }).strict();
75
+ /**
76
+ * MUST be kept in sync with @vertesia/tools-sdk SkillDefinition
77
+ * Zod schema for skill definition
78
+ * This validates the structure of skill objects generated from markdown
79
+ * Matches the SkillDefinition interface from @vertesia/tools-sdk
80
+ *
81
+ * Note: The isEnabled property is not included in this schema because Zod cannot
82
+ * properly validate function signatures. It will be type-checked by TypeScript instead.
83
+ */
84
+ export const SkillDefinitionSchema = z.object({
85
+ name: z.string().min(1, 'Skill name is required'),
86
+ title: z.string().optional(),
87
+ description: z.string().min(1, 'Skill description is required'),
88
+ instructions: z.string(),
89
+ content_type: z.enum(['md', 'jst']),
90
+ input_schema: z.object({
91
+ type: z.literal('object'),
92
+ properties: z.record(z.any()).optional(),
93
+ required: z.array(z.string()).optional()
94
+ }).optional(),
95
+ context_triggers: SkillContextTriggersSchema,
96
+ execution: SkillExecutionSchema,
97
+ related_tools: z.array(z.string()).optional(),
98
+ scripts: z.array(z.string()).optional(),
99
+ widgets: z.array(z.string()).optional()
100
+ }).passthrough();
101
+ /**
102
+ * Schema for validating properties exported from properties.ts
103
+ * This is a partial schema - allows any subset of SkillDefinition fields
104
+ *
105
+ * Note: Function properties like isEnabled cannot be validated by Zod for their signatures.
106
+ * Zod will only check that they are functions, not their specific parameter/return types.
107
+ * Use TypeScript for proper type checking of function signatures.
108
+ */
109
+ export const SkillPropertiesSchema = SkillDefinitionSchema.partial().passthrough();
110
+ /**
111
+ * Build a SkillDefinition from frontmatter and markdown content.
112
+ * This mirrors the logic in @vertesia/tools-sdk parseSkillFile function.
113
+ *
114
+ * Supports two frontmatter structures:
115
+ *
116
+ * 1. Flat structure (matches parseSkillFile in tools-sdk):
117
+ * keywords: [...]
118
+ * tools: [...]
119
+ * language: python
120
+ * packages: [...]
121
+ *
122
+ * 2. Nested structure (for more explicit YAML):
123
+ * context_triggers:
124
+ * keywords: [...]
125
+ * tool_names: [...]
126
+ * execution:
127
+ * language: python
128
+ * packages: [...]
129
+ * related_tools: [...]
130
+ *
131
+ * @param frontmatter - Parsed frontmatter object
132
+ * @param instructions - Markdown content (body of the file)
133
+ * @param contentType - Content type ('md' or 'jst')
134
+ * @param widgets - Discovered widget names
135
+ * @param scripts - Discovered script names
136
+ * @returns Skill definition object
137
+ */
138
+ function buildSkillDefinition(frontmatter, instructions, contentType, widgets, scripts) {
139
+ const skill = {
140
+ name: frontmatter.name,
141
+ title: frontmatter.title,
142
+ description: frontmatter.description,
143
+ instructions,
144
+ content_type: contentType,
145
+ widgets: widgets.length > 0 ? widgets : undefined,
146
+ scripts: scripts.length > 0 ? scripts : undefined,
147
+ };
148
+ // Build context triggers - support both flat and nested structure
149
+ // Nested: context_triggers: { keywords: [...], tool_names: [...] }
150
+ // Flat: keywords: [...], tools: [...]
151
+ const contextTriggers = frontmatter.context_triggers;
152
+ const hasNestedTriggers = contextTriggers && typeof contextTriggers === 'object';
153
+ const hasFlatTriggers = frontmatter.keywords || frontmatter.tools || frontmatter.data_patterns;
154
+ if (hasNestedTriggers || hasFlatTriggers) {
155
+ skill.context_triggers = {
156
+ keywords: hasNestedTriggers ? contextTriggers.keywords : frontmatter.keywords,
157
+ tool_names: hasNestedTriggers ? contextTriggers.tool_names : frontmatter.tools,
158
+ data_patterns: hasNestedTriggers ? contextTriggers.data_patterns : frontmatter.data_patterns,
159
+ };
160
+ }
161
+ // Build execution config - support both flat and nested structure
162
+ const execution = frontmatter.execution;
163
+ const hasNestedExecution = execution && typeof execution === 'object';
164
+ const hasFlatExecution = frontmatter.language;
165
+ if (hasNestedExecution || hasFlatExecution) {
166
+ skill.execution = {
167
+ language: hasNestedExecution ? execution.language : frontmatter.language,
168
+ packages: hasNestedExecution ? execution.packages : frontmatter.packages,
169
+ system_packages: hasNestedExecution ? execution.system_packages : frontmatter.system_packages,
170
+ };
171
+ // Extract code template from instructions if present
172
+ const codeBlockMatch = instructions.match(/```(?:python|javascript|typescript|js|ts|py)\n([\s\S]*?)```/);
173
+ if (codeBlockMatch) {
174
+ skill.execution.template = codeBlockMatch[1].trim();
175
+ }
176
+ }
177
+ // Related tools - support both direct field and from tools field
178
+ if (frontmatter.related_tools) {
179
+ skill.related_tools = frontmatter.related_tools;
180
+ }
181
+ else if (frontmatter.tools && !hasNestedTriggers) {
182
+ // If tools is not part of context_triggers, use it as related_tools
183
+ skill.related_tools = frontmatter.tools;
184
+ }
185
+ // Input schema from frontmatter
186
+ if (frontmatter.input_schema) {
187
+ skill.input_schema = frontmatter.input_schema;
188
+ }
189
+ return skill;
190
+ }
191
+ /**
192
+ * Skill transformer preset
193
+ * Transforms markdown files with ?skill suffix OR SKILL.md files into skill definition objects
194
+ *
195
+ * Matches:
196
+ * - Files with ?skill suffix: ./my-skill.md?skill
197
+ * - SKILL.md files: ./my-skill/SKILL.md
198
+ *
199
+ * Runtime Properties:
200
+ * - Supports properties.ts file in skill directory for runtime properties (functions, overrides)
201
+ * - Properties from properties.ts override those from frontmatter
202
+ * - See README.md for detailed usage examples
203
+ *
204
+ * @example
205
+ * ```typescript
206
+ * import skill1 from './my-skill.md?skill';
207
+ * import skill2 from './my-skill/SKILL.md';
208
+ * // Both are SkillDefinition objects
209
+ * ```
210
+ */
211
+ export const skillTransformer = {
212
+ pattern: /(\.md\?skill$|\/SKILL\.md$)/,
213
+ schema: SkillDefinitionSchema,
214
+ transform: (content, filePath) => {
215
+ const { frontmatter, content: markdown } = parseFrontmatter(content);
216
+ // Validate frontmatter first to catch unknown properties
217
+ const frontmatterValidation = SkillFrontmatterSchema.safeParse(frontmatter);
218
+ if (!frontmatterValidation.success) {
219
+ const errors = frontmatterValidation.error.errors
220
+ .map((err) => {
221
+ const pathStr = err.path.length > 0 ? err.path.join('.') : 'frontmatter';
222
+ return ` - ${pathStr}: ${err.message}`;
223
+ })
224
+ .join('\n');
225
+ throw new Error(`Invalid frontmatter in ${filePath}:\n${errors}`);
226
+ }
227
+ // Determine content type from frontmatter or file extension
228
+ const content_type = frontmatter.content_type || 'md';
229
+ // Discover assets (scripts and widgets) in the skill directory
230
+ const assets = discoverSkillAssets(filePath);
231
+ // Build skill definition using the same logic as parseSkillFile in tools-sdk
232
+ const skillData = buildSkillDefinition(frontmatter, markdown, content_type, assets.widgets, assets.scripts);
233
+ // Check if properties.ts exists in the skill directory
234
+ const skillDir = path.dirname(filePath);
235
+ const propertiesPath = path.join(skillDir, 'properties.ts');
236
+ const hasProperties = existsSync(propertiesPath);
237
+ // If properties.ts exists, generate custom code with import and merge
238
+ // Rollup will handle transpiling properties.ts to properties.js
239
+ if (hasProperties) {
240
+ const skillDataJson = JSON.stringify(skillData, null, 2);
241
+ const code = `import properties from './properties.js';
242
+
243
+ // Runtime validation for function properties
244
+ if ('isEnabled' in properties && typeof properties.isEnabled !== 'function') {
245
+ throw new Error('properties.isEnabled must be a function, got ' + typeof properties.isEnabled);
246
+ }
247
+
248
+ const skill = ${skillDataJson};
249
+
250
+ export default { ...skill, ...properties };
251
+ `;
252
+ return {
253
+ data: skillData,
254
+ assets: assets.assetFiles,
255
+ widgets: assets.widgetMetadata,
256
+ code
257
+ };
258
+ }
259
+ return {
260
+ data: skillData,
261
+ assets: assets.assetFiles,
262
+ widgets: assets.widgetMetadata
263
+ };
264
+ }
265
+ };
266
+ //# sourceMappingURL=skill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill.js","sourceRoot":"","sources":["../../../src/presets/skill.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAOlE;;GAEG;AACH,MAAM,qCAAqC,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACxC,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC1C,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CAChD,CAAC,CAAC,MAAM,EAAE,CAAC;AAEZ;;GAEG;AACH,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACxC,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC1C,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CAChD,CAAC,CAAC,QAAQ,EAAE,CAAC;AAEd;;GAEG;AACH,MAAM,+BAA+B,GAAG,CAAC,CAAC,M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AAQ,EAAE,eAAe,CAAC,CAAC;QAC5D,MAAM,aAAa,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;QAEjD,sEAAsE;QACtE,gEAAgE;QAChE,IAAI,aAAa,EAAE,CAAC;YAChB,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YACzD,MAAM,IAAI,GAAG;;;;;;;gBAOT,aAAa;;;CAG5B,CAAC;YACU,OAAO;gBACH,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,MAAM,CAAC,UAAU;gBACzB,OAAO,EAAE,MAAM,CAAC,cAAc;gBAC9B,IAAI;aACP,CAAC;QACN,CAAC;QAED,OAAO;YACH,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,MAAM,CAAC,UAAU;YACzB,OAAO,EAAE,MAAM,CAAC,cAAc;SACjC,CAAC;IACN,CAAC;CACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Type definitions for the Vertesia Rollup Import Plugin
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Utilities for copying asset files during build
3
+ */
4
+ import { copyFileSync, mkdirSync } from 'node:fs';
5
+ import path from 'node:path';
6
+ /**
7
+ * Ensure a directory exists, creating it recursively if needed
8
+ */
9
+ function ensureDirectory(dirPath) {
10
+ try {
11
+ mkdirSync(dirPath, { recursive: true });
12
+ }
13
+ catch (error) {
14
+ // Ignore if directory already exists
15
+ if (error.code !== 'EEXIST') {
16
+ throw error;
17
+ }
18
+ }
19
+ }
20
+ /**
21
+ * Copy an asset file to its destination
22
+ *
23
+ * @param asset - Asset file information
24
+ * @param assetsRoot - Root directory for assets
25
+ */
26
+ export function copyAssetFile(asset, assetsRoot) {
27
+ const destPath = path.join(assetsRoot, asset.destPath);
28
+ const destDir = path.dirname(destPath);
29
+ // Ensure destination directory exists
30
+ ensureDirectory(destDir);
31
+ // Copy file
32
+ try {
33
+ copyFileSync(asset.sourcePath, destPath);
34
+ }
35
+ catch (error) {
36
+ throw new Error(`Failed to copy asset from ${asset.sourcePath} to ${destPath}: ${error instanceof Error ? error.message : String(error)}`);
37
+ }
38
+ }
39
+ /**
40
+ * Copy multiple asset files
41
+ *
42
+ * @param assets - Array of asset files to copy
43
+ * @param assetsRoot - Root directory for assets
44
+ * @returns Number of files copied
45
+ */
46
+ export function copyAssets(assets, assetsRoot) {
47
+ let copied = 0;
48
+ for (const asset of assets) {
49
+ copyAssetFile(asset, assetsRoot);
50
+ copied++;
51
+ }
52
+ return copied;
53
+ }
54
+ //# sourceMappingURL=asset-copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-copy.js","sourceRoot":"","sources":["../../../src/utils/asset-copy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B;;GAEG;AACH,SAAS,eAAe,CAAC,OAAe;IACpC,IAAI,CAAC;QACD,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,qCAAqC;QACrC,IAAK,KAA+B,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACrD,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAgB,EAAE,UAAkB;IAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEvC,sCAAsC;IACtC,eAAe,CAAC,OAAO,CAAC,CAAC;IAEzB,YAAY;IACZ,IAAI,CAAC;QACD,YAAY,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACX,6BAA6B,KAAK,CAAC,UAAU,OAAO,QAAQ,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACtH,EAAE,CACL,CAAC;IACN,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,MAAmB,EAAE,UAAkB;IAC9D,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACzB,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QACjC,MAAM,EAAE,CAAC;IACb,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Utilities for discovering asset files (scripts, widgets) in skill directories
3
+ */
4
+ import { readdirSync, statSync } from 'node:fs';
5
+ import path from 'node:path';
6
+ /**
7
+ * Check if a file exists and is a regular file
8
+ */
9
+ function isFile(filePath) {
10
+ try {
11
+ return statSync(filePath).isFile();
12
+ }
13
+ catch {
14
+ return false;
15
+ }
16
+ }
17
+ /**
18
+ * Get all files in a directory (non-recursive)
19
+ */
20
+ function getFilesInDirectory(dirPath) {
21
+ try {
22
+ return readdirSync(dirPath).filter(file => {
23
+ const fullPath = path.join(dirPath, file);
24
+ return isFile(fullPath);
25
+ });
26
+ }
27
+ catch {
28
+ return [];
29
+ }
30
+ }
31
+ /**
32
+ * Check if a file is a script file (.js or .py)
33
+ */
34
+ function isScriptFile(fileName) {
35
+ return /\.(js|py)$/.test(fileName);
36
+ }
37
+ /**
38
+ * Check if a file is a widget file (.tsx)
39
+ */
40
+ function isWidgetFile(fileName) {
41
+ return /\.tsx$/.test(fileName);
42
+ }
43
+ /**
44
+ * Extract widget name from .tsx file (remove extension)
45
+ */
46
+ function getWidgetName(fileName) {
47
+ return fileName.replace(/\.tsx$/, '');
48
+ }
49
+ /**
50
+ * Discover assets (scripts and widgets) in a skill directory
51
+ *
52
+ * @param skillFilePath - Absolute path to the skill.md file
53
+ * @param options - Asset discovery options
54
+ * @returns Discovered assets and metadata
55
+ */
56
+ export function discoverSkillAssets(skillFilePath, options = {}) {
57
+ const skillDir = path.dirname(skillFilePath);
58
+ const files = getFilesInDirectory(skillDir);
59
+ const scripts = [];
60
+ const widgets = [];
61
+ const widgetMetadata = [];
62
+ const assetFiles = [];
63
+ const scriptsDir = options.scriptsDir || 'scripts';
64
+ for (const file of files) {
65
+ const fullPath = path.join(skillDir, file);
66
+ if (isScriptFile(file)) {
67
+ // Script file (.js or .py)
68
+ scripts.push(file);
69
+ assetFiles.push({
70
+ sourcePath: fullPath,
71
+ destPath: path.join(scriptsDir, file),
72
+ type: 'script'
73
+ });
74
+ }
75
+ else if (isWidgetFile(file)) {
76
+ // Widget file (.tsx)
77
+ const widgetName = getWidgetName(file);
78
+ widgets.push(widgetName);
79
+ widgetMetadata.push({
80
+ name: widgetName,
81
+ path: fullPath
82
+ });
83
+ // Note: We don't add widget .tsx files to assetFiles
84
+ // Widgets are compiled by the plugin if widgetConfig is provided
85
+ }
86
+ }
87
+ return {
88
+ scripts,
89
+ widgets,
90
+ widgetMetadata,
91
+ assetFiles
92
+ };
93
+ }
94
+ //# sourceMappingURL=asset-discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-discovery.js","sourceRoot":"","sources":["../../../src/utils/asset-discovery.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,IAAI,MAAM,WAAW,CAAC;AA+B7B;;GA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AE,CAAC;IAEnC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,SAAS,CAAC;IAEnD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAE3C,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,2BAA2B;YAC3B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnB,UAAU,CAAC,IAAI,CAAC;gBACZ,UAAU,EAAE,QAAQ;gBACpB,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC;gBACrC,IAAI,EAAE,QAAQ;aACjB,CAAC,CAAC;QACP,CAAC;aAAM,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,qBAAqB;YACrB,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACzB,cAAc,CAAC,IAAI,CAAC;gBAChB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;aACjB,CAAC,CAAC;YAEH,qDAAqD;YACrD,iEAAiE;QACrE,CAAC;IACL,CAAC;IAED,OAAO;QACH,OAAO;QACP,OAAO;QACP,cAAc;QACd,UAAU;KACb,CAAC;AACN,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Widget compilation utility using Rollup
3
+ */
4
+ import { rollup } from 'rollup';
5
+ import path from 'node:path';
6
+ /**
7
+ * Default external dependencies for widgets
8
+ */
9
+ const DEFAULT_EXTERNALS = [
10
+ 'react',
11
+ 'react-dom',
12
+ 'react/jsx-runtime',
13
+ 'react/jsx-dev-runtime',
14
+ 'react-dom/client'
15
+ ];
16
+ /**
17
+ * Compile widgets using Rollup
18
+ *
19
+ * @param widgets - Array of widget metadata to compile
20
+ * @param outputDir - Directory to write compiled widgets
21
+ * @param config - Widget compilation configuration
22
+ * @returns Number of widgets compiled
23
+ */
24
+ export async function compileWidgets(widgets, outputDir, config = {}) {
25
+ if (widgets.length === 0) {
26
+ return 0;
27
+ }
28
+ const { external = DEFAULT_EXTERNALS, tsconfig = './tsconfig.json', typescript: typescriptOptions = {}, minify = false } = config;
29
+ // Build each widget separately to get individual bundles
30
+ const buildPromises = widgets.map(async (widget) => {
31
+ // Dynamically import plugins - use any to bypass TypeScript module resolution issues
32
+ const typescript = (await import('@rollup/plugin-typescript')).default;
33
+ const nodeResolve = (await import('@rollup/plugin-node-resolve')).default;
34
+ const commonjs = (await import('@rollup/plugin-commonjs')).default;
35
+ const plugins = [
36
+ typescript({
37
+ tsconfig,
38
+ declaration: false,
39
+ sourceMap: true,
40
+ ...typescriptOptions
41
+ }),
42
+ nodeResolve({
43
+ browser: true,
44
+ preferBuiltins: false,
45
+ extensions: ['.tsx', '.ts', '.jsx', '.js']
46
+ }),
47
+ commonjs()
48
+ ];
49
+ // Add minification if requested
50
+ if (minify) {
51
+ const { terser } = await import('rollup-plugin-terser');
52
+ plugins.push(terser({
53
+ compress: {
54
+ drop_console: false
55
+ }
56
+ }));
57
+ }
58
+ const rollupConfig = {
59
+ input: widget.path,
60
+ output: {
61
+ file: path.join(outputDir, `${widget.name}.js`),
62
+ format: 'es',
63
+ sourcemap: true,
64
+ inlineDynamicImports: true
65
+ },
66
+ external,
67
+ plugins
68
+ };
69
+ const bundle = await rollup(rollupConfig);
70
+ await bundle.write(rollupConfig.output);
71
+ await bundle.close();
72
+ });
73
+ await Promise.all(buildPromises);
74
+ return widgets.length;
75
+ }
76
+ //# sourceMappingURL=widget-compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-compiler.js","sourceRoot":"","sources":["../../../src/utils/widget-compiler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAmC,MAAM,QAAQ,CAAC;AACjE,OAAO,IAAI,MAAM,WAAW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AG,MAAM,MAAM,CAAC,sBAA6B,CAAC,CAAC;YAC/D,OAAO,CAAC,IAAI,CACR,MAAM,CAAC;gBACH,QAAQ,EAAE;oBACN,YAAY,EAAE,KAAK;iBACtB;aACJ,CAAC,CACL,CAAC;QACN,CAAC;QAED,MAAM,YAAY,GAAkB;YAChC,KAAK,EAAE,MAAM,CAAC,IAAI;YAClB,MAAM,EAAE;gBACJ,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,MAAM,CAAC,IAAI,KAAK,CAAC;gBAC/C,MAAM,EAAE,IAAI;gBACZ,SAAS,EAAE,IAAI;gBACf,oBAAoB,EAAE,IAAI;aAC7B;YACD,QAAQ;YACR,OAAO;SACV,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC;QAC1C,MAAM,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,MAAa,CAAC,CAAC;QAC/C,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC,MAAM,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Vertesia Rollup Import Plugin
3
+ *
4
+ * A flexible Rollup plugin for transforming imports with custom compilers and validation.
5
+ * Supports preset transformers for common use cases (skills, raw files) and custom transformers.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { vertesiaImportPlugin, skillTransformer, rawTransformer } from '@vertesia/build-tools';
10
+ *
11
+ * export default {
12
+ * plugins: [
13
+ * vertesiaImportPlugin({
14
+ * transformers: [skillTransformer, rawTransformer]
15
+ * })
16
+ * ]
17
+ * };
18
+ * ```
19
+ */
20
+ export { vertesiaImportPlugin } from './plugin.js';
21
+ export type { PluginConfig, TransformerRule, TransformerPreset, TransformFunction, TransformResult, AssetFile, WidgetConfig } from './types.js';
22
+ export { skillTransformer, rawTransformer, skillCollectionTransformer, promptTransformer, SkillDefinitionSchema, SkillPropertiesSchema, PromptDefinitionSchema, type SkillDefinition, type SkillContentType, type PromptDefinition, type PromptContentType, PromptRole, TemplateType } from './presets/index.js';
23
+ export { parseFrontmatter, type FrontmatterResult } from './parsers/frontmatter.js';
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,0BAA0B,EAC1B,iBAAiB,EACjB,qBAAqB,EACrB,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"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Frontmatter parser utility using gray-matter
3
+ */
4
+ export interface FrontmatterResult {
5
+ /** Parsed frontmatter data */
6
+ frontmatter: Record<string, any>;
7
+ /** Content without frontmatter */
8
+ content: string;
9
+ /** Original full content */
10
+ original: string;
11
+ }
12
+ /**
13
+ * Parse YAML frontmatter from markdown content
14
+ *
15
+ * @param content - Raw markdown content with optional frontmatter
16
+ * @returns Parsed frontmatter and content
17
+ */
18
+ export declare function parseFrontmatter(content: string): FrontmatterResult;
19
+ //# sourceMappingURL=frontmatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../../src/parsers/frontmatter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,iBAAiB;IAC9B,8BAA8B;IAC9B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEjC,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAEhB,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAQnE"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Core Rollup plugin implementation for transforming imports
3
+ */
4
+ import type { Plugin } from 'rollup';
5
+ import type { PluginConfig } from './types.js';
6
+ /**
7
+ * Creates a Rollup plugin that transforms imports based on configured rules
8
+ */
9
+ export declare function vertesiaImportPlugin(config: PluginConfig): Plugin;
10
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +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,CAsJjE"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Preset transformers for common use cases
3
+ */
4
+ export { skillTransformer, SkillDefinitionSchema, SkillPropertiesSchema, type SkillDefinition, type SkillContentType } from './skill.js';
5
+ export { skillCollectionTransformer } from './skill-collection.js';
6
+ export { rawTransformer } from './raw.js';
7
+ export { promptTransformer, PromptDefinitionSchema, type PromptDefinition, type PromptContentType, PromptRole, TemplateType } from './prompt.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,qBAAqB,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzI,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"}