@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,15 @@
1
+ /**
2
+ * Widget compilation utility using Rollup
3
+ */
4
+ import type { WidgetConfig } from '../types.js';
5
+ import type { WidgetMetadata } from './asset-discovery.js';
6
+ /**
7
+ * Compile widgets using Rollup
8
+ *
9
+ * @param widgets - Array of widget metadata to compile
10
+ * @param outputDir - Directory to write compiled widgets
11
+ * @param config - Widget compilation configuration
12
+ * @returns Number of widgets compiled
13
+ */
14
+ export declare function compileWidgets(widgets: WidgetMetadata[], outputDir: string, config?: WidgetConfig): Promise<number>;
15
+ //# sourceMappingURL=widget-compiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widget-compiler.d.ts","sourceRoot":"","sources":["../../../src/utils/widget-compiler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAa3D;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAChC,OAAO,EAAE,cAAc,EAAE,EACzB,SAAS,EAAE,MAAM,EACjB,MAAM,GAAE,YAAiB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAiEjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertesia/build-tools",
3
- "version": "1.0.0-dev.20260203.130115Z",
3
+ "version": "1.0.0-dev.20260225.024852Z",
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",
@@ -29,8 +29,8 @@
29
29
  "dependencies": {
30
30
  "gray-matter": "^4.0.3",
31
31
  "zod": "^3.24.1",
32
- "@llumiverse/common": "1.0.0-dev.20260202.145450Z",
33
- "@vertesia/common": "1.0.0-dev.20260203.130115Z"
32
+ "@llumiverse/common": "1.0.0-dev.20260224.234313Z",
33
+ "@vertesia/common": "1.0.0-dev.20260225.024852Z"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "rollup": "^4.0.0"
package/src/index.ts CHANGED
@@ -39,6 +39,7 @@ export {
39
39
  skillCollectionTransformer,
40
40
  promptTransformer,
41
41
  SkillDefinitionSchema,
42
+ SkillPropertiesSchema,
42
43
  PromptDefinitionSchema,
43
44
  type SkillDefinition,
44
45
  type SkillContentType,
@@ -2,7 +2,7 @@
2
2
  * Preset transformers for common use cases
3
3
  */
4
4
 
5
- export { skillTransformer, SkillDefinitionSchema, type SkillDefinition, type SkillContentType } from './skill.js';
5
+ export { skillTransformer, SkillDefinitionSchema, SkillPropertiesSchema, type SkillDefinition, type SkillContentType } from './skill.js';
6
6
  export { skillCollectionTransformer } from './skill-collection.js';
7
7
  export { rawTransformer } from './raw.js';
8
8
  export { promptTransformer, PromptDefinitionSchema, type PromptDefinition, type PromptContentType, PromptRole, TemplateType } from './prompt.js';
@@ -2,6 +2,8 @@
2
2
  * Skill transformer preset for markdown files with frontmatter
3
3
  */
4
4
 
5
+ import path from 'node:path';
6
+ import { existsSync } from 'node:fs';
5
7
  import { z } from 'zod';
6
8
  import type { TransformerPreset } from '../types.js';
7
9
  import { parseFrontmatter } from '../parsers/frontmatter.js';
@@ -92,6 +94,9 @@ const SkillFrontmatterSchema = z.object({
92
94
  * Zod schema for skill definition
93
95
  * This validates the structure of skill objects generated from markdown
94
96
  * Matches the SkillDefinition interface from @vertesia/tools-sdk
97
+ *
98
+ * Note: The isEnabled property is not included in this schema because Zod cannot
99
+ * properly validate function signatures. It will be type-checked by TypeScript instead.
95
100
  */
96
101
  export const SkillDefinitionSchema = z.object({
97
102
  name: z.string().min(1, 'Skill name is required'),
@@ -109,7 +114,17 @@ export const SkillDefinitionSchema = z.object({
109
114
  related_tools: z.array(z.string()).optional(),
110
115
  scripts: z.array(z.string()).optional(),
111
116
  widgets: z.array(z.string()).optional()
112
- });
117
+ }).passthrough();
118
+
119
+ /**
120
+ * Schema for validating properties exported from properties.ts
121
+ * This is a partial schema - allows any subset of SkillDefinition fields
122
+ *
123
+ * Note: Function properties like isEnabled cannot be validated by Zod for their signatures.
124
+ * Zod will only check that they are functions, not their specific parameter/return types.
125
+ * Use TypeScript for proper type checking of function signatures.
126
+ */
127
+ export const SkillPropertiesSchema = SkillDefinitionSchema.partial().passthrough();
113
128
 
114
129
  /**
115
130
  * TypeScript type inferred from the Zod schema
@@ -220,6 +235,11 @@ function buildSkillDefinition(
220
235
  * - Files with ?skill suffix: ./my-skill.md?skill
221
236
  * - SKILL.md files: ./my-skill/SKILL.md
222
237
  *
238
+ * Runtime Properties:
239
+ * - Supports properties.ts file in skill directory for runtime properties (functions, overrides)
240
+ * - Properties from properties.ts override those from frontmatter
241
+ * - See README.md for detailed usage examples
242
+ *
223
243
  * @example
224
244
  * ```typescript
225
245
  * import skill1 from './my-skill.md?skill';
@@ -238,8 +258,8 @@ export const skillTransformer: TransformerPreset = {
238
258
  if (!frontmatterValidation.success) {
239
259
  const errors = frontmatterValidation.error.errors
240
260
  .map((err) => {
241
- const path = err.path.length > 0 ? err.path.join('.') : 'frontmatter';
242
- return ` - ${path}: ${err.message}`;
261
+ const pathStr = err.path.length > 0 ? err.path.join('.') : 'frontmatter';
262
+ return ` - ${pathStr}: ${err.message}`;
243
263
  })
244
264
  .join('\n');
245
265
  throw new Error(
@@ -262,6 +282,34 @@ export const skillTransformer: TransformerPreset = {
262
282
  assets.scripts
263
283
  );
264
284
 
285
+ // Check if properties.ts exists in the skill directory
286
+ const skillDir = path.dirname(filePath);
287
+ const propertiesPath = path.join(skillDir, 'properties.ts');
288
+ const hasProperties = existsSync(propertiesPath);
289
+
290
+ // If properties.ts exists, generate custom code with import and merge
291
+ // Rollup will handle transpiling properties.ts to properties.js
292
+ if (hasProperties) {
293
+ const skillDataJson = JSON.stringify(skillData, null, 2);
294
+ const code = `import properties from './properties.js';
295
+
296
+ // Runtime validation for function properties
297
+ if ('isEnabled' in properties && typeof properties.isEnabled !== 'function') {
298
+ throw new Error('properties.isEnabled must be a function, got ' + typeof properties.isEnabled);
299
+ }
300
+
301
+ const skill = ${skillDataJson};
302
+
303
+ export default { ...skill, ...properties };
304
+ `;
305
+ return {
306
+ data: skillData,
307
+ assets: assets.assetFiles,
308
+ widgets: assets.widgetMetadata,
309
+ code
310
+ };
311
+ }
312
+
265
313
  return {
266
314
  data: skillData,
267
315
  assets: assets.assetFiles,