@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,221 @@
1
+ /**
2
+ * Skill transformer preset for markdown files with frontmatter
3
+ */
4
+ import { z } from 'zod';
5
+ import { parseFrontmatter } from '../parsers/frontmatter.js';
6
+ import { discoverSkillAssets } from '../utils/asset-discovery.js';
7
+ /**
8
+ * Context triggers for auto-injection of skills (for frontmatter validation)
9
+ */
10
+ const SkillContextTriggersFrontmatterSchema = z.object({
11
+ keywords: z.array(z.string()).optional(),
12
+ tool_names: z.array(z.string()).optional(),
13
+ data_patterns: z.array(z.string()).optional()
14
+ }).strict();
15
+ /**
16
+ * Context triggers for auto-injection of skills (for output validation)
17
+ */
18
+ const SkillContextTriggersSchema = z.object({
19
+ keywords: z.array(z.string()).optional(),
20
+ tool_names: z.array(z.string()).optional(),
21
+ data_patterns: z.array(z.string()).optional()
22
+ }).optional();
23
+ /**
24
+ * Execution configuration for skills that need code execution (for frontmatter validation)
25
+ */
26
+ const SkillExecutionFrontmatterSchema = z.object({
27
+ language: z.string(),
28
+ packages: z.array(z.string()).optional(),
29
+ system_packages: z.array(z.string()).optional(),
30
+ template: z.string().optional()
31
+ }).strict();
32
+ /**
33
+ * Execution configuration for skills that need code execution (for output validation)
34
+ */
35
+ const SkillExecutionSchema = z.object({
36
+ language: z.string(),
37
+ packages: z.array(z.string()).optional(),
38
+ system_packages: z.array(z.string()).optional(),
39
+ template: z.string().optional()
40
+ }).optional();
41
+ /**
42
+ * Zod schema for skill frontmatter validation
43
+ * This validates the YAML frontmatter before transformation
44
+ * Supports both flat and nested structures
45
+ */
46
+ const SkillFrontmatterSchema = z.object({
47
+ // Required fields
48
+ name: z.string().min(1, 'Skill name is required'),
49
+ description: z.string().min(1, 'Skill description is required'),
50
+ // Optional fields
51
+ title: z.string().optional(),
52
+ content_type: z.enum(['md', 'jst']).optional(),
53
+ // Flat structure fields (legacy)
54
+ keywords: z.array(z.string()).optional(),
55
+ tools: z.array(z.string()).optional(),
56
+ data_patterns: z.array(z.string()).optional(),
57
+ language: z.string().optional(),
58
+ packages: z.array(z.string()).optional(),
59
+ system_packages: z.array(z.string()).optional(),
60
+ // Nested structure fields
61
+ context_triggers: SkillContextTriggersFrontmatterSchema.optional(),
62
+ execution: SkillExecutionFrontmatterSchema.optional(),
63
+ related_tools: z.array(z.string()).optional(),
64
+ input_schema: z.object({
65
+ type: z.literal('object'),
66
+ properties: z.record(z.any()).optional(),
67
+ required: z.array(z.string()).optional()
68
+ }).optional(),
69
+ // Asset fields (auto-discovered but can be overridden)
70
+ scripts: z.array(z.string()).optional(),
71
+ widgets: z.array(z.string()).optional()
72
+ }).strict();
73
+ /**
74
+ * MUST be kept in sync with @vertesia/tools-sdk SkillDefinition
75
+ * Zod schema for skill definition
76
+ * This validates the structure of skill objects generated from markdown
77
+ * Matches the SkillDefinition interface from @vertesia/tools-sdk
78
+ */
79
+ export const SkillDefinitionSchema = z.object({
80
+ name: z.string().min(1, 'Skill name is required'),
81
+ title: z.string().optional(),
82
+ description: z.string().min(1, 'Skill description is required'),
83
+ instructions: z.string(),
84
+ content_type: z.enum(['md', 'jst']),
85
+ input_schema: z.object({
86
+ type: z.literal('object'),
87
+ properties: z.record(z.any()).optional(),
88
+ required: z.array(z.string()).optional()
89
+ }).optional(),
90
+ context_triggers: SkillContextTriggersSchema,
91
+ execution: SkillExecutionSchema,
92
+ related_tools: z.array(z.string()).optional(),
93
+ scripts: z.array(z.string()).optional(),
94
+ widgets: z.array(z.string()).optional()
95
+ });
96
+ /**
97
+ * Build a SkillDefinition from frontmatter and markdown content.
98
+ * This mirrors the logic in @vertesia/tools-sdk parseSkillFile function.
99
+ *
100
+ * Supports two frontmatter structures:
101
+ *
102
+ * 1. Flat structure (matches parseSkillFile in tools-sdk):
103
+ * keywords: [...]
104
+ * tools: [...]
105
+ * language: python
106
+ * packages: [...]
107
+ *
108
+ * 2. Nested structure (for more explicit YAML):
109
+ * context_triggers:
110
+ * keywords: [...]
111
+ * tool_names: [...]
112
+ * execution:
113
+ * language: python
114
+ * packages: [...]
115
+ * related_tools: [...]
116
+ *
117
+ * @param frontmatter - Parsed frontmatter object
118
+ * @param instructions - Markdown content (body of the file)
119
+ * @param contentType - Content type ('md' or 'jst')
120
+ * @param widgets - Discovered widget names
121
+ * @param scripts - Discovered script names
122
+ * @returns Skill definition object
123
+ */
124
+ function buildSkillDefinition(frontmatter, instructions, contentType, widgets, scripts) {
125
+ const skill = {
126
+ name: frontmatter.name,
127
+ title: frontmatter.title,
128
+ description: frontmatter.description,
129
+ instructions,
130
+ content_type: contentType,
131
+ widgets: widgets.length > 0 ? widgets : undefined,
132
+ scripts: scripts.length > 0 ? scripts : undefined,
133
+ };
134
+ // Build context triggers - support both flat and nested structure
135
+ // Nested: context_triggers: { keywords: [...], tool_names: [...] }
136
+ // Flat: keywords: [...], tools: [...]
137
+ const contextTriggers = frontmatter.context_triggers;
138
+ const hasNestedTriggers = contextTriggers && typeof contextTriggers === 'object';
139
+ const hasFlatTriggers = frontmatter.keywords || frontmatter.tools || frontmatter.data_patterns;
140
+ if (hasNestedTriggers || hasFlatTriggers) {
141
+ skill.context_triggers = {
142
+ keywords: hasNestedTriggers ? contextTriggers.keywords : frontmatter.keywords,
143
+ tool_names: hasNestedTriggers ? contextTriggers.tool_names : frontmatter.tools,
144
+ data_patterns: hasNestedTriggers ? contextTriggers.data_patterns : frontmatter.data_patterns,
145
+ };
146
+ }
147
+ // Build execution config - support both flat and nested structure
148
+ const execution = frontmatter.execution;
149
+ const hasNestedExecution = execution && typeof execution === 'object';
150
+ const hasFlatExecution = frontmatter.language;
151
+ if (hasNestedExecution || hasFlatExecution) {
152
+ skill.execution = {
153
+ language: hasNestedExecution ? execution.language : frontmatter.language,
154
+ packages: hasNestedExecution ? execution.packages : frontmatter.packages,
155
+ system_packages: hasNestedExecution ? execution.system_packages : frontmatter.system_packages,
156
+ };
157
+ // Extract code template from instructions if present
158
+ const codeBlockMatch = instructions.match(/```(?:python|javascript|typescript|js|ts|py)\n([\s\S]*?)```/);
159
+ if (codeBlockMatch) {
160
+ skill.execution.template = codeBlockMatch[1].trim();
161
+ }
162
+ }
163
+ // Related tools - support both direct field and from tools field
164
+ if (frontmatter.related_tools) {
165
+ skill.related_tools = frontmatter.related_tools;
166
+ }
167
+ else if (frontmatter.tools && !hasNestedTriggers) {
168
+ // If tools is not part of context_triggers, use it as related_tools
169
+ skill.related_tools = frontmatter.tools;
170
+ }
171
+ // Input schema from frontmatter
172
+ if (frontmatter.input_schema) {
173
+ skill.input_schema = frontmatter.input_schema;
174
+ }
175
+ return skill;
176
+ }
177
+ /**
178
+ * Skill transformer preset
179
+ * Transforms markdown files with ?skill suffix OR SKILL.md files into skill definition objects
180
+ *
181
+ * Matches:
182
+ * - Files with ?skill suffix: ./my-skill.md?skill
183
+ * - SKILL.md files: ./my-skill/SKILL.md
184
+ *
185
+ * @example
186
+ * ```typescript
187
+ * import skill1 from './my-skill.md?skill';
188
+ * import skill2 from './my-skill/SKILL.md';
189
+ * // Both are SkillDefinition objects
190
+ * ```
191
+ */
192
+ export const skillTransformer = {
193
+ pattern: /(\.md\?skill$|\/SKILL\.md$)/,
194
+ schema: SkillDefinitionSchema,
195
+ transform: (content, filePath) => {
196
+ const { frontmatter, content: markdown } = parseFrontmatter(content);
197
+ // Validate frontmatter first to catch unknown properties
198
+ const frontmatterValidation = SkillFrontmatterSchema.safeParse(frontmatter);
199
+ if (!frontmatterValidation.success) {
200
+ const errors = frontmatterValidation.error.errors
201
+ .map((err) => {
202
+ const path = err.path.length > 0 ? err.path.join('.') : 'frontmatter';
203
+ return ` - ${path}: ${err.message}`;
204
+ })
205
+ .join('\n');
206
+ throw new Error(`Invalid frontmatter in ${filePath}:\n${errors}`);
207
+ }
208
+ // Determine content type from frontmatter or file extension
209
+ const content_type = frontmatter.content_type || 'md';
210
+ // Discover assets (scripts and widgets) in the skill directory
211
+ const assets = discoverSkillAssets(filePath);
212
+ // Build skill definition using the same logic as parseSkillFile in tools-sdk
213
+ const skillData = buildSkillDefinition(frontmatter, markdown, content_type, assets.widgets, assets.scripts);
214
+ return {
215
+ data: skillData,
216
+ assets: assets.assetFiles,
217
+ widgets: assets.widgetMetadata
218
+ };
219
+ }
220
+ };
221
+ //# 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,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;IACx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C,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,OAAO,CACjB,CAAC;QAEF,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;;GAEG;AACH,SAAS,MAAM,CAAC,QAAgB;IAC5B,IAAI,CAAC;QACD,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,OAAe;IACxC,IAAI,CAAC;QACD,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YACtC,MAAM,QAAQ,GAAG,I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,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,CAAC;AAI7B;;GAEG;AACH,MAAM,iBAAiB,GAAG;IACtB,OAAO;IACP,WAAW;IACX,mBAAmB;IACnB,uBAAuB;IACvB,kBAAkB;CACrB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAChC,OAAyB,EACzB,SAAiB,EACjB,SAAuB,EAAE;IAEzB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,CAAC,CAAC;IACb,CAAC;IAED,MAAM,EACF,QAAQ,GAAG,iBAAi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AM,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, 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,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, 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,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,63 @@
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
+ import { TemplateType } from '@vertesia/common';
8
+ import { PromptRole } from '@llumiverse/common';
9
+ /**
10
+ * Re-export types for backwards compatibility
11
+ */
12
+ export { TemplateType, PromptRole };
13
+ /**
14
+ * Template type alias
15
+ */
16
+ export type PromptContentType = TemplateType;
17
+ /**
18
+ * MUST be kept in sync with @vertesia/common InCodePrompt
19
+ * Zod schema for prompt definition
20
+ */
21
+ export declare const PromptDefinitionSchema: z.ZodObject<{
22
+ role: z.ZodNativeEnum<typeof PromptRole>;
23
+ content: z.ZodString;
24
+ content_type: z.ZodNativeEnum<typeof TemplateType>;
25
+ schema: z.ZodOptional<z.ZodAny>;
26
+ name: z.ZodOptional<z.ZodString>;
27
+ externalId: z.ZodOptional<z.ZodString>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ content_type: TemplateType;
30
+ content: string;
31
+ role: PromptRole;
32
+ schema?: any;
33
+ name?: string | undefined;
34
+ externalId?: string | undefined;
35
+ }, {
36
+ content_type: TemplateType;
37
+ content: string;
38
+ role: PromptRole;
39
+ schema?: any;
40
+ name?: string | undefined;
41
+ externalId?: string | undefined;
42
+ }>;
43
+ /**
44
+ * TypeScript type inferred from the Zod schema
45
+ */
46
+ export type PromptDefinition = z.infer<typeof PromptDefinitionSchema>;
47
+ /**
48
+ * Prompt transformer preset
49
+ * Transforms template files with ?prompt suffix into prompt definition objects
50
+ *
51
+ * Supported file types:
52
+ * - .jst (JavaScript template literals) → content_type: 'jst'
53
+ * - .hbs (Handlebars templates) → content_type: 'handlebars'
54
+ * - .txt or other → content_type: 'text'
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * import PROMPT from './prompt.hbs?prompt';
59
+ * // PROMPT is an InCodePrompt object
60
+ * ```
61
+ */
62
+ export declare const promptTransformer: TransformerPreset;
63
+ //# 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;AAGrD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC;AAEpC;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAkB7C;;;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,16 @@
1
+ /**
2
+ * Raw transformer preset for importing file content as strings
3
+ */
4
+ import type { TransformerPreset } from '../types.js';
5
+ /**
6
+ * Raw transformer preset
7
+ * Transforms any file with ?raw suffix into a string export
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import template from './template.html?raw';
12
+ * // template is a string containing the file content
13
+ * ```
14
+ */
15
+ export declare const rawTransformer: TransformerPreset;
16
+ //# sourceMappingURL=raw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw.d.ts","sourceRoot":"","sources":["../../../src/presets/raw.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,EAAE,iBAO5B,CAAC"}