@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,26 @@
1
+ /**
2
+ * Skill collection transformer for directory-based skill imports
3
+ * Scans a directory for subdirectories containing SKILL.md files
4
+ */
5
+ import type { TransformerPreset } from '../types.js';
6
+ /**
7
+ * Skill collection transformer preset
8
+ * Transforms directory imports with ?skills suffix into an array of skill imports
9
+ *
10
+ * Matches:
11
+ * - ./all?skills (recommended - generates all.js in the directory)
12
+ * - ./_skills?skills (generates _skills.js in the directory)
13
+ * - Any path ending with a filename and ?skills
14
+ *
15
+ * NOTE: A filename before ?skills is REQUIRED to avoid naming conflicts.
16
+ * The filename becomes the output module name.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * import skills from './all?skills';
21
+ * // Scans current directory for subdirectories with SKILL.md
22
+ * // Generates all.js containing array of all skills
23
+ * ```
24
+ */
25
+ export declare const skillCollectionTransformer: TransformerPreset;
26
+ //# sourceMappingURL=skill-collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-collection.d.ts","sourceRoot":"","sources":["../../../src/presets/skill-collection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,0BAA0B,EAAE,iBAyDxC,CAAC"}
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Skill transformer preset for markdown files with frontmatter
3
+ */
4
+ import { z } from 'zod';
5
+ import type { TransformerPreset } from '../types.js';
6
+ /**
7
+ * Content type for skill instructions
8
+ */
9
+ export type SkillContentType = 'md' | 'jst';
10
+ /**
11
+ * MUST be kept in sync with @vertesia/tools-sdk SkillDefinition
12
+ * Zod schema for skill definition
13
+ * This validates the structure of skill objects generated from markdown
14
+ * Matches the SkillDefinition interface from @vertesia/tools-sdk
15
+ */
16
+ export declare const SkillDefinitionSchema: z.ZodObject<{
17
+ name: z.ZodString;
18
+ title: z.ZodOptional<z.ZodString>;
19
+ description: z.ZodString;
20
+ instructions: z.ZodString;
21
+ content_type: z.ZodEnum<["md", "jst"]>;
22
+ input_schema: z.ZodOptional<z.ZodObject<{
23
+ type: z.ZodLiteral<"object">;
24
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
25
+ required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
26
+ }, "strip", z.ZodTypeAny, {
27
+ type: "object";
28
+ properties?: Record<string, any> | undefined;
29
+ required?: string[] | undefined;
30
+ }, {
31
+ type: "object";
32
+ properties?: Record<string, any> | undefined;
33
+ required?: string[] | undefined;
34
+ }>>;
35
+ context_triggers: z.ZodOptional<z.ZodObject<{
36
+ keywords: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
37
+ tool_names: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
38
+ data_patterns: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ keywords?: string[] | undefined;
41
+ tool_names?: string[] | undefined;
42
+ data_patterns?: string[] | undefined;
43
+ }, {
44
+ keywords?: string[] | undefined;
45
+ tool_names?: string[] | undefined;
46
+ data_patterns?: string[] | undefined;
47
+ }>>;
48
+ execution: z.ZodOptional<z.ZodObject<{
49
+ language: z.ZodString;
50
+ packages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
51
+ system_packages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
52
+ template: z.ZodOptional<z.ZodString>;
53
+ }, "strip", z.ZodTypeAny, {
54
+ language: string;
55
+ packages?: string[] | undefined;
56
+ system_packages?: string[] | undefined;
57
+ template?: string | undefined;
58
+ }, {
59
+ language: string;
60
+ packages?: string[] | undefined;
61
+ system_packages?: string[] | undefined;
62
+ template?: string | undefined;
63
+ }>>;
64
+ related_tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
65
+ scripts: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
66
+ widgets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
67
+ }, "strip", z.ZodTypeAny, {
68
+ name: string;
69
+ description: string;
70
+ content_type: "md" | "jst";
71
+ instructions: string;
72
+ scripts?: string[] | undefined;
73
+ widgets?: string[] | undefined;
74
+ title?: string | undefined;
75
+ context_triggers?: {
76
+ keywords?: string[] | undefined;
77
+ tool_names?: string[] | undefined;
78
+ data_patterns?: string[] | undefined;
79
+ } | undefined;
80
+ execution?: {
81
+ language: string;
82
+ packages?: string[] | undefined;
83
+ system_packages?: string[] | undefined;
84
+ template?: string | undefined;
85
+ } | undefined;
86
+ related_tools?: string[] | undefined;
87
+ input_schema?: {
88
+ type: "object";
89
+ properties?: Record<string, any> | undefined;
90
+ required?: string[] | undefined;
91
+ } | undefined;
92
+ }, {
93
+ name: string;
94
+ description: string;
95
+ content_type: "md" | "jst";
96
+ instructions: string;
97
+ scripts?: string[] | undefined;
98
+ widgets?: string[] | undefined;
99
+ title?: string | undefined;
100
+ context_triggers?: {
101
+ keywords?: string[] | undefined;
102
+ tool_names?: string[] | undefined;
103
+ data_patterns?: string[] | undefined;
104
+ } | undefined;
105
+ execution?: {
106
+ language: string;
107
+ packages?: string[] | undefined;
108
+ system_packages?: string[] | undefined;
109
+ template?: string | undefined;
110
+ } | undefined;
111
+ related_tools?: string[] | undefined;
112
+ input_schema?: {
113
+ type: "object";
114
+ properties?: Record<string, any> | undefined;
115
+ required?: string[] | undefined;
116
+ } | undefined;
117
+ }>;
118
+ /**
119
+ * TypeScript type inferred from the Zod schema
120
+ * Can also be imported from consumer packages for type safety
121
+ */
122
+ export type SkillDefinition = z.infer<typeof SkillDefinitionSchema>;
123
+ /**
124
+ * Skill transformer preset
125
+ * Transforms markdown files with ?skill suffix OR SKILL.md files into skill definition objects
126
+ *
127
+ * Matches:
128
+ * - Files with ?skill suffix: ./my-skill.md?skill
129
+ * - SKILL.md files: ./my-skill/SKILL.md
130
+ *
131
+ * @example
132
+ * ```typescript
133
+ * import skill1 from './my-skill.md?skill';
134
+ * import skill2 from './my-skill/SKILL.md';
135
+ * // Both are SkillDefinition objects
136
+ * ```
137
+ */
138
+ export declare const skillTransformer: TransformerPreset;
139
+ //# sourceMappingURL=skill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill.d.ts","sourceRoot":"","sources":["../../../src/presets/skill.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIrD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,KAAK,CAAC;AA6E5C;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBhC,CAAC;AAEH;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAiGpE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,EAAE,iBAyC9B,CAAC"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Type definitions for the Vertesia Rollup Import Plugin
3
+ */
4
+ import type { Plugin } from 'rollup';
5
+ import type { z } from 'zod';
6
+ /**
7
+ * Asset file to be copied during build
8
+ */
9
+ export interface AssetFile {
10
+ /** Source file path (absolute) */
11
+ sourcePath: string;
12
+ /** Relative destination path within assets directory */
13
+ destPath: string;
14
+ /** Asset type for categorization */
15
+ type: 'script';
16
+ }
17
+ /**
18
+ * Result of a transform function
19
+ */
20
+ export interface TransformResult {
21
+ /** The data to export (can be text or JSON object) */
22
+ data: unknown;
23
+ /** Optional: additional imports to inject at the top of the generated module */
24
+ imports?: string[];
25
+ /** Optional: custom code to generate instead of default JSON export */
26
+ code?: string;
27
+ /** Optional: additional asset files to copy */
28
+ assets?: AssetFile[];
29
+ /** Optional: widget metadata for compilation */
30
+ widgets?: Array<{
31
+ name: string;
32
+ path: string;
33
+ }>;
34
+ }
35
+ /**
36
+ * Transform function that converts file content into exportable data
37
+ */
38
+ export type TransformFunction = (content: string, filePath: string) => TransformResult | Promise<TransformResult>;
39
+ /**
40
+ * Configuration for a single import transformer rule
41
+ */
42
+ export interface TransformerRule {
43
+ /** Pattern to match import paths (e.g., /\.md\?skill$/ or /\?raw$/) */
44
+ pattern: RegExp;
45
+ /** Transform function to convert file content */
46
+ transform: TransformFunction;
47
+ /** Optional: Zod schema for validation */
48
+ schema?: z.ZodType<any>;
49
+ /** Optional: If true, the transformer generates virtual modules (no file to read) */
50
+ virtual?: boolean;
51
+ /** Optional: additional options for this transformer */
52
+ options?: Record<string, unknown>;
53
+ }
54
+ /**
55
+ * Widget compilation configuration
56
+ */
57
+ export interface WidgetConfig {
58
+ /**
59
+ * External dependencies that should not be bundled
60
+ * Default: ['react', 'react-dom', 'react/jsx-runtime']
61
+ */
62
+ external?: string[];
63
+ /**
64
+ * Path to tsconfig.json for widget compilation
65
+ * Default: './tsconfig.json'
66
+ */
67
+ tsconfig?: string;
68
+ /**
69
+ * Additional options to pass to @rollup/plugin-typescript
70
+ */
71
+ typescript?: Record<string, unknown>;
72
+ /**
73
+ * Minify widget output
74
+ * Default: false
75
+ */
76
+ minify?: boolean;
77
+ }
78
+ /**
79
+ * Plugin configuration
80
+ */
81
+ export interface PluginConfig {
82
+ /** Array of transformer rules to apply */
83
+ transformers: TransformerRule[];
84
+ /**
85
+ * Root directory for asset output (scripts, widgets, etc.)
86
+ * - If specified: assets will be copied to this directory
87
+ * - If false: asset copying is disabled
88
+ * - Default: './dist'
89
+ */
90
+ assetsDir?: string | false;
91
+ /**
92
+ * Directory for script files relative to assetsDir
93
+ * Default: 'scripts'
94
+ */
95
+ scriptsDir?: string;
96
+ /**
97
+ * Directory for widget files relative to assetsDir
98
+ * Default: 'widgets'
99
+ */
100
+ widgetsDir?: string;
101
+ /**
102
+ * Widget compilation configuration
103
+ * If provided, discovered widgets will be automatically compiled
104
+ */
105
+ widgetConfig?: WidgetConfig;
106
+ }
107
+ /**
108
+ * Type for transformer presets
109
+ */
110
+ export type TransformerPreset = TransformerRule;
111
+ /**
112
+ * Plugin factory return type
113
+ */
114
+ export type VertesiaImportPlugin = (config: PluginConfig) => Plugin;
115
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IAEnB,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IAEjB,oCAAoC;IACpC,IAAI,EAAE,QAAQ,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,sDAAsD;IACtD,IAAI,EAAE,OAAO,CAAC;IAEd,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,+CAA+C;IAC/C,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IAErB,gDAAgD;IAChD,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnD;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC5B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,KACf,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAEhB,iDAAiD;IACjD,SAAS,EAAE,iBAAiB,CAAC;IAE7B,0CAA0C;IAC1C,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAExB,qFAAqF;IACrF,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAErC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,0CAA0C;IAC1C,YAAY,EAAE,eAAe,EAAE,CAAC;IAEhC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAE3B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,MAAM,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Utilities for copying asset files during build
3
+ */
4
+ import type { AssetFile } from '../types.js';
5
+ /**
6
+ * Copy an asset file to its destination
7
+ *
8
+ * @param asset - Asset file information
9
+ * @param assetsRoot - Root directory for assets
10
+ */
11
+ export declare function copyAssetFile(asset: AssetFile, assetsRoot: string): void;
12
+ /**
13
+ * Copy multiple asset files
14
+ *
15
+ * @param assets - Array of asset files to copy
16
+ * @param assetsRoot - Root directory for assets
17
+ * @returns Number of files copied
18
+ */
19
+ export declare function copyAssets(assets: AssetFile[], assetsRoot: string): number;
20
+ //# sourceMappingURL=asset-copy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-copy.d.ts","sourceRoot":"","sources":["../../../src/utils/asset-copy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAgB7C;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAgBxE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAS1E"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Utilities for discovering asset files (scripts, widgets) in skill directories
3
+ */
4
+ import type { AssetFile } from '../types.js';
5
+ /**
6
+ * Widget metadata for compilation
7
+ */
8
+ export interface WidgetMetadata {
9
+ /** Widget name (without .tsx extension) */
10
+ name: string;
11
+ /** Absolute path to widget file */
12
+ path: string;
13
+ }
14
+ /**
15
+ * Discovered assets in a skill directory
16
+ */
17
+ export interface DiscoveredAssets {
18
+ /** Script file names (with extensions: .js, .py) */
19
+ scripts: string[];
20
+ /** Widget file names (without .tsx extension) */
21
+ widgets: string[];
22
+ /** Widget metadata for compilation */
23
+ widgetMetadata: WidgetMetadata[];
24
+ /** Asset files to be copied */
25
+ assetFiles: AssetFile[];
26
+ }
27
+ /**
28
+ * Discover assets (scripts and widgets) in a skill directory
29
+ *
30
+ * @param skillFilePath - Absolute path to the skill.md file
31
+ * @param options - Asset discovery options
32
+ * @returns Discovered assets and metadata
33
+ */
34
+ export declare function discoverSkillAssets(skillFilePath: string, options?: {
35
+ scriptsDir?: string;
36
+ widgetsDir?: string;
37
+ }): DiscoveredAssets;
38
+ //# sourceMappingURL=asset-discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-discovery.d.ts","sourceRoot":"","sources":["../../../src/utils/asset-discovery.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IAEb,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,oDAAoD;IACpD,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,iDAAiD;IACjD,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,sCAAsC;IACtC,cAAc,EAAE,cAAc,EAAE,CAAC;IAEjC,+BAA+B;IAC/B,UAAU,EAAE,SAAS,EAAE,CAAC;CAC3B;AAgDD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAC/B,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE;IACL,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CAClB,GACP,gBAAgB,CA0ClB"}
@@ -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 ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@vertesia/build-tools",
3
+ "version": "0.24.0-dev.202601221707",
4
+ "description": "Build tools for Vertesia projects - Rollup and Vite plugins for transforming imports, bundling skills, and compiling widgets",
5
+ "type": "module",
6
+ "main": "./lib/esm/index.js",
7
+ "types": "./lib/types/index.d.ts",
8
+ "files": [
9
+ "lib",
10
+ "src"
11
+ ],
12
+ "license": "Apache-2.0",
13
+ "exports": {
14
+ "types": "./lib/types/index.d.ts",
15
+ "import": "./lib/esm/index.js",
16
+ "require": "./lib/cjs/index.js"
17
+ },
18
+ "devDependencies": {
19
+ "@rollup/plugin-commonjs": "^28.0.3",
20
+ "@rollup/plugin-node-resolve": "^16.0.1",
21
+ "@rollup/plugin-typescript": "^12.1.2",
22
+ "@types/node": "^25.0.3",
23
+ "rollup": "^4.40.2",
24
+ "rollup-plugin-terser": "^7.0.2",
25
+ "ts-dual-module": "^0.6.3",
26
+ "typescript": "^5.9.3",
27
+ "vitest": "^4.0.16"
28
+ },
29
+ "dependencies": {
30
+ "gray-matter": "^4.0.3",
31
+ "zod": "^3.24.1",
32
+ "@llumiverse/common": "0.24.0-dev.202601221707",
33
+ "@vertesia/common": "0.24.0-dev.202601221707"
34
+ },
35
+ "peerDependencies": {
36
+ "rollup": "^4.0.0"
37
+ },
38
+ "ts_dual_module": {
39
+ "outDir": "lib"
40
+ },
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://github.com/vertesia/composableai.git",
44
+ "directory": "packages/build-tools"
45
+ },
46
+ "keywords": [
47
+ "vertesia",
48
+ "rollup",
49
+ "rollup-plugin",
50
+ "vite",
51
+ "vite-plugin",
52
+ "build-tools",
53
+ "imports",
54
+ "transform",
55
+ "compiler",
56
+ "skill",
57
+ "markdown",
58
+ "frontmatter",
59
+ "widget",
60
+ "bundler",
61
+ "zod",
62
+ "validation"
63
+ ],
64
+ "scripts": {
65
+ "test": "vitest run",
66
+ "build": "pnpm exec tsmod build && pnpm exec rollup -c",
67
+ "clean": "rimraf ./node_modules ./lib ./tsconfig.tsbuildinfo"
68
+ }
69
+ }
package/src/index.ts ADDED
@@ -0,0 +1,52 @@
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
+
21
+ // Core plugin
22
+ export { vertesiaImportPlugin } from './plugin.js';
23
+
24
+ // Types
25
+ export type {
26
+ PluginConfig,
27
+ TransformerRule,
28
+ TransformerPreset,
29
+ TransformFunction,
30
+ TransformResult,
31
+ AssetFile,
32
+ WidgetConfig
33
+ } from './types.js';
34
+
35
+ // Presets
36
+ export {
37
+ skillTransformer,
38
+ rawTransformer,
39
+ skillCollectionTransformer,
40
+ promptTransformer,
41
+ SkillDefinitionSchema,
42
+ PromptDefinitionSchema,
43
+ type SkillDefinition,
44
+ type SkillContentType,
45
+ type PromptDefinition,
46
+ type PromptContentType,
47
+ PromptRole,
48
+ TemplateType
49
+ } from './presets/index.js';
50
+
51
+ // Utilities
52
+ export { parseFrontmatter, type FrontmatterResult } from './parsers/frontmatter.js';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Frontmatter parser utility using gray-matter
3
+ */
4
+
5
+ import matter from 'gray-matter';
6
+
7
+ export interface FrontmatterResult {
8
+ /** Parsed frontmatter data */
9
+ frontmatter: Record<string, any>;
10
+
11
+ /** Content without frontmatter */
12
+ content: string;
13
+
14
+ /** Original full content */
15
+ original: string;
16
+ }
17
+
18
+ /**
19
+ * Parse YAML frontmatter from markdown content
20
+ *
21
+ * @param content - Raw markdown content with optional frontmatter
22
+ * @returns Parsed frontmatter and content
23
+ */
24
+ export function parseFrontmatter(content: string): FrontmatterResult {
25
+ const result = matter(content);
26
+
27
+ return {
28
+ frontmatter: result.data,
29
+ content: result.content,
30
+ original: content
31
+ };
32
+ }