@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.
- package/LICENSE +13 -0
- package/README.md +334 -0
- package/lib/build-tools.js +1730 -0
- package/lib/build-tools.js.map +1 -0
- package/lib/cjs/index.js +39 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/parsers/frontmatter.js +25 -0
- package/lib/cjs/parsers/frontmatter.js.map +1 -0
- package/lib/cjs/plugin.js +150 -0
- package/lib/cjs/plugin.js.map +1 -0
- package/lib/cjs/presets/index.js +19 -0
- package/lib/cjs/presets/index.js.map +1 -0
- package/lib/cjs/presets/prompt.js +185 -0
- package/lib/cjs/presets/prompt.js.map +1 -0
- package/lib/cjs/presets/raw.js +25 -0
- package/lib/cjs/presets/raw.js.map +1 -0
- package/lib/cjs/presets/skill-collection.js +83 -0
- package/lib/cjs/presets/skill-collection.js.map +1 -0
- package/lib/cjs/presets/skill.js +224 -0
- package/lib/cjs/presets/skill.js.map +1 -0
- package/lib/cjs/types.js +6 -0
- package/lib/cjs/types.js.map +1 -0
- package/lib/cjs/utils/asset-copy.js +61 -0
- package/lib/cjs/utils/asset-copy.js.map +1 -0
- package/lib/cjs/utils/asset-discovery.js +100 -0
- package/lib/cjs/utils/asset-discovery.js.map +1 -0
- package/lib/cjs/utils/widget-compiler.js +115 -0
- package/lib/cjs/utils/widget-compiler.js.map +1 -0
- package/lib/esm/index.js +26 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/parsers/frontmatter.js +19 -0
- package/lib/esm/parsers/frontmatter.js.map +1 -0
- package/lib/esm/plugin.js +144 -0
- package/lib/esm/plugin.js.map +1 -0
- package/lib/esm/presets/index.js +8 -0
- package/lib/esm/presets/index.js.map +1 -0
- package/lib/esm/presets/prompt.js +181 -0
- package/lib/esm/presets/prompt.js.map +1 -0
- package/lib/esm/presets/raw.js +22 -0
- package/lib/esm/presets/raw.js.map +1 -0
- package/lib/esm/presets/skill-collection.js +77 -0
- package/lib/esm/presets/skill-collection.js.map +1 -0
- package/lib/esm/presets/skill.js +221 -0
- package/lib/esm/presets/skill.js.map +1 -0
- package/lib/esm/types.js +5 -0
- package/lib/esm/types.js.map +1 -0
- package/lib/esm/utils/asset-copy.js +54 -0
- package/lib/esm/utils/asset-copy.js.map +1 -0
- package/lib/esm/utils/asset-discovery.js +94 -0
- package/lib/esm/utils/asset-discovery.js.map +1 -0
- package/lib/esm/utils/widget-compiler.js +76 -0
- package/lib/esm/utils/widget-compiler.js.map +1 -0
- package/lib/types/index.d.ts +24 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/parsers/frontmatter.d.ts +19 -0
- package/lib/types/parsers/frontmatter.d.ts.map +1 -0
- package/lib/types/plugin.d.ts +10 -0
- package/lib/types/plugin.d.ts.map +1 -0
- package/lib/types/presets/index.d.ts +8 -0
- package/lib/types/presets/index.d.ts.map +1 -0
- package/lib/types/presets/prompt.d.ts +63 -0
- package/lib/types/presets/prompt.d.ts.map +1 -0
- package/lib/types/presets/raw.d.ts +16 -0
- package/lib/types/presets/raw.d.ts.map +1 -0
- package/lib/types/presets/skill-collection.d.ts +26 -0
- package/lib/types/presets/skill-collection.d.ts.map +1 -0
- package/lib/types/presets/skill.d.ts +139 -0
- package/lib/types/presets/skill.d.ts.map +1 -0
- package/lib/types/types.d.ts +115 -0
- package/lib/types/types.d.ts.map +1 -0
- package/lib/types/utils/asset-copy.d.ts +20 -0
- package/lib/types/utils/asset-copy.d.ts.map +1 -0
- package/lib/types/utils/asset-discovery.d.ts +38 -0
- package/lib/types/utils/asset-discovery.d.ts.map +1 -0
- package/lib/types/utils/widget-compiler.d.ts +15 -0
- package/lib/types/utils/widget-compiler.d.ts.map +1 -0
- package/package.json +69 -0
- package/src/index.ts +52 -0
- package/src/parsers/frontmatter.ts +32 -0
- package/src/plugin.ts +166 -0
- package/src/presets/index.ts +8 -0
- package/src/presets/prompt.ts +227 -0
- package/src/presets/raw.ts +24 -0
- package/src/presets/skill-collection.ts +86 -0
- package/src/presets/skill.ts +271 -0
- package/src/types.ts +140 -0
- package/src/utils/asset-copy.ts +63 -0
- package/src/utils/asset-discovery.ts +138 -0
- package/src/utils/widget-compiler.ts +98 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Skill transformer preset for markdown files with frontmatter
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.skillTransformer = exports.SkillDefinitionSchema = void 0;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const frontmatter_js_1 = require("../parsers/frontmatter.js");
|
|
9
|
+
const asset_discovery_js_1 = require("../utils/asset-discovery.js");
|
|
10
|
+
/**
|
|
11
|
+
* Context triggers for auto-injection of skills (for frontmatter validation)
|
|
12
|
+
*/
|
|
13
|
+
const SkillContextTriggersFrontmatterSchema = zod_1.z.object({
|
|
14
|
+
keywords: zod_1.z.array(zod_1.z.string()).optional(),
|
|
15
|
+
tool_names: zod_1.z.array(zod_1.z.string()).optional(),
|
|
16
|
+
data_patterns: zod_1.z.array(zod_1.z.string()).optional()
|
|
17
|
+
}).strict();
|
|
18
|
+
/**
|
|
19
|
+
* Context triggers for auto-injection of skills (for output validation)
|
|
20
|
+
*/
|
|
21
|
+
const SkillContextTriggersSchema = zod_1.z.object({
|
|
22
|
+
keywords: zod_1.z.array(zod_1.z.string()).optional(),
|
|
23
|
+
tool_names: zod_1.z.array(zod_1.z.string()).optional(),
|
|
24
|
+
data_patterns: zod_1.z.array(zod_1.z.string()).optional()
|
|
25
|
+
}).optional();
|
|
26
|
+
/**
|
|
27
|
+
* Execution configuration for skills that need code execution (for frontmatter validation)
|
|
28
|
+
*/
|
|
29
|
+
const SkillExecutionFrontmatterSchema = zod_1.z.object({
|
|
30
|
+
language: zod_1.z.string(),
|
|
31
|
+
packages: zod_1.z.array(zod_1.z.string()).optional(),
|
|
32
|
+
system_packages: zod_1.z.array(zod_1.z.string()).optional(),
|
|
33
|
+
template: zod_1.z.string().optional()
|
|
34
|
+
}).strict();
|
|
35
|
+
/**
|
|
36
|
+
* Execution configuration for skills that need code execution (for output validation)
|
|
37
|
+
*/
|
|
38
|
+
const SkillExecutionSchema = zod_1.z.object({
|
|
39
|
+
language: zod_1.z.string(),
|
|
40
|
+
packages: zod_1.z.array(zod_1.z.string()).optional(),
|
|
41
|
+
system_packages: zod_1.z.array(zod_1.z.string()).optional(),
|
|
42
|
+
template: zod_1.z.string().optional()
|
|
43
|
+
}).optional();
|
|
44
|
+
/**
|
|
45
|
+
* Zod schema for skill frontmatter validation
|
|
46
|
+
* This validates the YAML frontmatter before transformation
|
|
47
|
+
* Supports both flat and nested structures
|
|
48
|
+
*/
|
|
49
|
+
const SkillFrontmatterSchema = zod_1.z.object({
|
|
50
|
+
// Required fields
|
|
51
|
+
name: zod_1.z.string().min(1, 'Skill name is required'),
|
|
52
|
+
description: zod_1.z.string().min(1, 'Skill description is required'),
|
|
53
|
+
// Optional fields
|
|
54
|
+
title: zod_1.z.string().optional(),
|
|
55
|
+
content_type: zod_1.z.enum(['md', 'jst']).optional(),
|
|
56
|
+
// Flat structure fields (legacy)
|
|
57
|
+
keywords: zod_1.z.array(zod_1.z.string()).optional(),
|
|
58
|
+
tools: zod_1.z.array(zod_1.z.string()).optional(),
|
|
59
|
+
data_patterns: zod_1.z.array(zod_1.z.string()).optional(),
|
|
60
|
+
language: zod_1.z.string().optional(),
|
|
61
|
+
packages: zod_1.z.array(zod_1.z.string()).optional(),
|
|
62
|
+
system_packages: zod_1.z.array(zod_1.z.string()).optional(),
|
|
63
|
+
// Nested structure fields
|
|
64
|
+
context_triggers: SkillContextTriggersFrontmatterSchema.optional(),
|
|
65
|
+
execution: SkillExecutionFrontmatterSchema.optional(),
|
|
66
|
+
related_tools: zod_1.z.array(zod_1.z.string()).optional(),
|
|
67
|
+
input_schema: zod_1.z.object({
|
|
68
|
+
type: zod_1.z.literal('object'),
|
|
69
|
+
properties: zod_1.z.record(zod_1.z.any()).optional(),
|
|
70
|
+
required: zod_1.z.array(zod_1.z.string()).optional()
|
|
71
|
+
}).optional(),
|
|
72
|
+
// Asset fields (auto-discovered but can be overridden)
|
|
73
|
+
scripts: zod_1.z.array(zod_1.z.string()).optional(),
|
|
74
|
+
widgets: zod_1.z.array(zod_1.z.string()).optional()
|
|
75
|
+
}).strict();
|
|
76
|
+
/**
|
|
77
|
+
* MUST be kept in sync with @vertesia/tools-sdk SkillDefinition
|
|
78
|
+
* Zod schema for skill definition
|
|
79
|
+
* This validates the structure of skill objects generated from markdown
|
|
80
|
+
* Matches the SkillDefinition interface from @vertesia/tools-sdk
|
|
81
|
+
*/
|
|
82
|
+
exports.SkillDefinitionSchema = zod_1.z.object({
|
|
83
|
+
name: zod_1.z.string().min(1, 'Skill name is required'),
|
|
84
|
+
title: zod_1.z.string().optional(),
|
|
85
|
+
description: zod_1.z.string().min(1, 'Skill description is required'),
|
|
86
|
+
instructions: zod_1.z.string(),
|
|
87
|
+
content_type: zod_1.z.enum(['md', 'jst']),
|
|
88
|
+
input_schema: zod_1.z.object({
|
|
89
|
+
type: zod_1.z.literal('object'),
|
|
90
|
+
properties: zod_1.z.record(zod_1.z.any()).optional(),
|
|
91
|
+
required: zod_1.z.array(zod_1.z.string()).optional()
|
|
92
|
+
}).optional(),
|
|
93
|
+
context_triggers: SkillContextTriggersSchema,
|
|
94
|
+
execution: SkillExecutionSchema,
|
|
95
|
+
related_tools: zod_1.z.array(zod_1.z.string()).optional(),
|
|
96
|
+
scripts: zod_1.z.array(zod_1.z.string()).optional(),
|
|
97
|
+
widgets: zod_1.z.array(zod_1.z.string()).optional()
|
|
98
|
+
});
|
|
99
|
+
/**
|
|
100
|
+
* Build a SkillDefinition from frontmatter and markdown content.
|
|
101
|
+
* This mirrors the logic in @vertesia/tools-sdk parseSkillFile function.
|
|
102
|
+
*
|
|
103
|
+
* Supports two frontmatter structures:
|
|
104
|
+
*
|
|
105
|
+
* 1. Flat structure (matches parseSkillFile in tools-sdk):
|
|
106
|
+
* keywords: [...]
|
|
107
|
+
* tools: [...]
|
|
108
|
+
* language: python
|
|
109
|
+
* packages: [...]
|
|
110
|
+
*
|
|
111
|
+
* 2. Nested structure (for more explicit YAML):
|
|
112
|
+
* context_triggers:
|
|
113
|
+
* keywords: [...]
|
|
114
|
+
* tool_names: [...]
|
|
115
|
+
* execution:
|
|
116
|
+
* language: python
|
|
117
|
+
* packages: [...]
|
|
118
|
+
* related_tools: [...]
|
|
119
|
+
*
|
|
120
|
+
* @param frontmatter - Parsed frontmatter object
|
|
121
|
+
* @param instructions - Markdown content (body of the file)
|
|
122
|
+
* @param contentType - Content type ('md' or 'jst')
|
|
123
|
+
* @param widgets - Discovered widget names
|
|
124
|
+
* @param scripts - Discovered script names
|
|
125
|
+
* @returns Skill definition object
|
|
126
|
+
*/
|
|
127
|
+
function buildSkillDefinition(frontmatter, instructions, contentType, widgets, scripts) {
|
|
128
|
+
const skill = {
|
|
129
|
+
name: frontmatter.name,
|
|
130
|
+
title: frontmatter.title,
|
|
131
|
+
description: frontmatter.description,
|
|
132
|
+
instructions,
|
|
133
|
+
content_type: contentType,
|
|
134
|
+
widgets: widgets.length > 0 ? widgets : undefined,
|
|
135
|
+
scripts: scripts.length > 0 ? scripts : undefined,
|
|
136
|
+
};
|
|
137
|
+
// Build context triggers - support both flat and nested structure
|
|
138
|
+
// Nested: context_triggers: { keywords: [...], tool_names: [...] }
|
|
139
|
+
// Flat: keywords: [...], tools: [...]
|
|
140
|
+
const contextTriggers = frontmatter.context_triggers;
|
|
141
|
+
const hasNestedTriggers = contextTriggers && typeof contextTriggers === 'object';
|
|
142
|
+
const hasFlatTriggers = frontmatter.keywords || frontmatter.tools || frontmatter.data_patterns;
|
|
143
|
+
if (hasNestedTriggers || hasFlatTriggers) {
|
|
144
|
+
skill.context_triggers = {
|
|
145
|
+
keywords: hasNestedTriggers ? contextTriggers.keywords : frontmatter.keywords,
|
|
146
|
+
tool_names: hasNestedTriggers ? contextTriggers.tool_names : frontmatter.tools,
|
|
147
|
+
data_patterns: hasNestedTriggers ? contextTriggers.data_patterns : frontmatter.data_patterns,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
// Build execution config - support both flat and nested structure
|
|
151
|
+
const execution = frontmatter.execution;
|
|
152
|
+
const hasNestedExecution = execution && typeof execution === 'object';
|
|
153
|
+
const hasFlatExecution = frontmatter.language;
|
|
154
|
+
if (hasNestedExecution || hasFlatExecution) {
|
|
155
|
+
skill.execution = {
|
|
156
|
+
language: hasNestedExecution ? execution.language : frontmatter.language,
|
|
157
|
+
packages: hasNestedExecution ? execution.packages : frontmatter.packages,
|
|
158
|
+
system_packages: hasNestedExecution ? execution.system_packages : frontmatter.system_packages,
|
|
159
|
+
};
|
|
160
|
+
// Extract code template from instructions if present
|
|
161
|
+
const codeBlockMatch = instructions.match(/```(?:python|javascript|typescript|js|ts|py)\n([\s\S]*?)```/);
|
|
162
|
+
if (codeBlockMatch) {
|
|
163
|
+
skill.execution.template = codeBlockMatch[1].trim();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// Related tools - support both direct field and from tools field
|
|
167
|
+
if (frontmatter.related_tools) {
|
|
168
|
+
skill.related_tools = frontmatter.related_tools;
|
|
169
|
+
}
|
|
170
|
+
else if (frontmatter.tools && !hasNestedTriggers) {
|
|
171
|
+
// If tools is not part of context_triggers, use it as related_tools
|
|
172
|
+
skill.related_tools = frontmatter.tools;
|
|
173
|
+
}
|
|
174
|
+
// Input schema from frontmatter
|
|
175
|
+
if (frontmatter.input_schema) {
|
|
176
|
+
skill.input_schema = frontmatter.input_schema;
|
|
177
|
+
}
|
|
178
|
+
return skill;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Skill transformer preset
|
|
182
|
+
* Transforms markdown files with ?skill suffix OR SKILL.md files into skill definition objects
|
|
183
|
+
*
|
|
184
|
+
* Matches:
|
|
185
|
+
* - Files with ?skill suffix: ./my-skill.md?skill
|
|
186
|
+
* - SKILL.md files: ./my-skill/SKILL.md
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```typescript
|
|
190
|
+
* import skill1 from './my-skill.md?skill';
|
|
191
|
+
* import skill2 from './my-skill/SKILL.md';
|
|
192
|
+
* // Both are SkillDefinition objects
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
exports.skillTransformer = {
|
|
196
|
+
pattern: /(\.md\?skill$|\/SKILL\.md$)/,
|
|
197
|
+
schema: exports.SkillDefinitionSchema,
|
|
198
|
+
transform: (content, filePath) => {
|
|
199
|
+
const { frontmatter, content: markdown } = (0, frontmatter_js_1.parseFrontmatter)(content);
|
|
200
|
+
// Validate frontmatter first to catch unknown properties
|
|
201
|
+
const frontmatterValidation = SkillFrontmatterSchema.safeParse(frontmatter);
|
|
202
|
+
if (!frontmatterValidation.success) {
|
|
203
|
+
const errors = frontmatterValidation.error.errors
|
|
204
|
+
.map((err) => {
|
|
205
|
+
const path = err.path.length > 0 ? err.path.join('.') : 'frontmatter';
|
|
206
|
+
return ` - ${path}: ${err.message}`;
|
|
207
|
+
})
|
|
208
|
+
.join('\n');
|
|
209
|
+
throw new Error(`Invalid frontmatter in ${filePath}:\n${errors}`);
|
|
210
|
+
}
|
|
211
|
+
// Determine content type from frontmatter or file extension
|
|
212
|
+
const content_type = frontmatter.content_type || 'md';
|
|
213
|
+
// Discover assets (scripts and widgets) in the skill directory
|
|
214
|
+
const assets = (0, asset_discovery_js_1.discoverSkillAssets)(filePath);
|
|
215
|
+
// Build skill definition using the same logic as parseSkillFile in tools-sdk
|
|
216
|
+
const skillData = buildSkillDefinition(frontmatter, markdown, content_type, assets.widgets, assets.scripts);
|
|
217
|
+
return {
|
|
218
|
+
data: skillData,
|
|
219
|
+
assets: assets.assetFiles,
|
|
220
|
+
widgets: assets.widgetMetadata
|
|
221
|
+
};
|
|
222
|
+
}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B,CAAC,KAAK,CAAC,MAAM;iBAC5C,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;gBACT,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;gBACtE,OAAO,OAAO,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC;YACzC,CAAC,CAAC;iBACD,IAAI,CAAC,IAAI,CAAC,CAAC;YAChB,MAAM,IAAI,KAAK,CACX,0BAA0B,QAAQ,MAAM,MAAM,EAAE,CACnD,CAAC;QACN,CAAC;QAED,4DAA4D;QAC5D,MAAM,YAAY,GAAqB,WAAW,CAAC,YAAY,IAAI,IAAI,CAAC;QAExE,+DAA+D;QAC/D,MAAM,MAAM,GAAG,IAAA,wCAAmB,EAAC,QAAQ,CAAC,CAAC;QAE7C,6EAA6E;QAC7E,MAAM,SAAS,GAAG,oBAAoB,CAClC,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"}
|
package/lib/cjs/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utilities for copying asset files during build
|
|
4
|
+
*/
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.copyAssetFile = copyAssetFile;
|
|
10
|
+
exports.copyAssets = copyAssets;
|
|
11
|
+
const node_fs_1 = require("node:fs");
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
/**
|
|
14
|
+
* Ensure a directory exists, creating it recursively if needed
|
|
15
|
+
*/
|
|
16
|
+
function ensureDirectory(dirPath) {
|
|
17
|
+
try {
|
|
18
|
+
(0, node_fs_1.mkdirSync)(dirPath, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
// Ignore if directory already exists
|
|
22
|
+
if (error.code !== 'EEXIST') {
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Copy an asset file to its destination
|
|
29
|
+
*
|
|
30
|
+
* @param asset - Asset file information
|
|
31
|
+
* @param assetsRoot - Root directory for assets
|
|
32
|
+
*/
|
|
33
|
+
function copyAssetFile(asset, assetsRoot) {
|
|
34
|
+
const destPath = node_path_1.default.join(assetsRoot, asset.destPath);
|
|
35
|
+
const destDir = node_path_1.default.dirname(destPath);
|
|
36
|
+
// Ensure destination directory exists
|
|
37
|
+
ensureDirectory(destDir);
|
|
38
|
+
// Copy file
|
|
39
|
+
try {
|
|
40
|
+
(0, node_fs_1.copyFileSync)(asset.sourcePath, destPath);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
throw new Error(`Failed to copy asset from ${asset.sourcePath} to ${destPath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Copy multiple asset files
|
|
48
|
+
*
|
|
49
|
+
* @param assets - Array of asset files to copy
|
|
50
|
+
* @param assetsRoot - Root directory for assets
|
|
51
|
+
* @returns Number of files copied
|
|
52
|
+
*/
|
|
53
|
+
function copyAssets(assets, assetsRoot) {
|
|
54
|
+
let copied = 0;
|
|
55
|
+
for (const asset of assets) {
|
|
56
|
+
copyAssetFile(asset, assetsRoot);
|
|
57
|
+
copied++;
|
|
58
|
+
}
|
|
59
|
+
return copied;
|
|
60
|
+
}
|
|
61
|
+
//# 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;;;;;AA0BH,sCAgBC;AASD,gCASC;AA1DD,qCAAkD;AAClD,0DAA6B;AAG7B;;GAEG;AACH,SAAS,eAAe,CAAC,OAAe;IACpC,IAAI,CAAC;QACD,IAAA,mBAAS,EAAC,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,SAAgB,aAAa,CAAC,KAAgB,EAAE,UAAkB;IAC9D,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,mBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEvC,sCAAsC;IACtC,eAAe,CAAC,OAAO,CAAC,CAAC;IAEzB,YAAY;IACZ,IAAI,CAAC;QACD,IAAA,sBAAY,EAAC,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,SAAgB,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,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utilities for discovering asset files (scripts, widgets) in skill directories
|
|
4
|
+
*/
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.discoverSkillAssets = discoverSkillAssets;
|
|
10
|
+
const node_fs_1 = require("node:fs");
|
|
11
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
/**
|
|
13
|
+
* Check if a file exists and is a regular file
|
|
14
|
+
*/
|
|
15
|
+
function isFile(filePath) {
|
|
16
|
+
try {
|
|
17
|
+
return (0, node_fs_1.statSync)(filePath).isFile();
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get all files in a directory (non-recursive)
|
|
25
|
+
*/
|
|
26
|
+
function getFilesInDirectory(dirPath) {
|
|
27
|
+
try {
|
|
28
|
+
return (0, node_fs_1.readdirSync)(dirPath).filter(file => {
|
|
29
|
+
const fullPath = node_path_1.default.join(dirPath, file);
|
|
30
|
+
return isFile(fullPath);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Check if a file is a script file (.js or .py)
|
|
39
|
+
*/
|
|
40
|
+
function isScriptFile(fileName) {
|
|
41
|
+
return /\.(js|py)$/.test(fileName);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Check if a file is a widget file (.tsx)
|
|
45
|
+
*/
|
|
46
|
+
function isWidgetFile(fileName) {
|
|
47
|
+
return /\.tsx$/.test(fileName);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Extract widget name from .tsx file (remove extension)
|
|
51
|
+
*/
|
|
52
|
+
function getWidgetName(fileName) {
|
|
53
|
+
return fileName.replace(/\.tsx$/, '');
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Discover assets (scripts and widgets) in a skill directory
|
|
57
|
+
*
|
|
58
|
+
* @param skillFilePath - Absolute path to the skill.md file
|
|
59
|
+
* @param options - Asset discovery options
|
|
60
|
+
* @returns Discovered assets and metadata
|
|
61
|
+
*/
|
|
62
|
+
function discoverSkillAssets(skillFilePath, options = {}) {
|
|
63
|
+
const skillDir = node_path_1.default.dirname(skillFilePath);
|
|
64
|
+
const files = getFilesInDirectory(skillDir);
|
|
65
|
+
const scripts = [];
|
|
66
|
+
const widgets = [];
|
|
67
|
+
const widgetMetadata = [];
|
|
68
|
+
const assetFiles = [];
|
|
69
|
+
const scriptsDir = options.scriptsDir || 'scripts';
|
|
70
|
+
for (const file of files) {
|
|
71
|
+
const fullPath = node_path_1.default.join(skillDir, file);
|
|
72
|
+
if (isScriptFile(file)) {
|
|
73
|
+
// Script file (.js or .py)
|
|
74
|
+
scripts.push(file);
|
|
75
|
+
assetFiles.push({
|
|
76
|
+
sourcePath: fullPath,
|
|
77
|
+
destPath: node_path_1.default.join(scriptsDir, file),
|
|
78
|
+
type: 'script'
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else if (isWidgetFile(file)) {
|
|
82
|
+
// Widget file (.tsx)
|
|
83
|
+
const widgetName = getWidgetName(file);
|
|
84
|
+
widgets.push(widgetName);
|
|
85
|
+
widgetMetadata.push({
|
|
86
|
+
name: widgetName,
|
|
87
|
+
path: fullPath
|
|
88
|
+
});
|
|
89
|
+
// Note: We don't add widget .tsx files to assetFiles
|
|
90
|
+
// Widgets are compiled by the plugin if widgetConfig is provided
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
scripts,
|
|
95
|
+
widgets,
|
|
96
|
+
widgetMetadata,
|
|
97
|
+
assetFiles
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//# 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;;;;;AAuFH,kDAgDC;AArID,qCAAgD;AAChD,0DAA6B;AA+B7B;;GAEG;AACH,SAAS,MAAM,CAAC,QAAgB;IAC5B,IAAI,CAAC;QACD,OAAO,IAAA,kBAAQ,EAAC,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,IAAA,qBAAW,EAAC,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YACtC,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAC1C,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACP,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,EAAE,CAAC;IACd,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,QAAgB;IAClC,OAAO,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,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AAC,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,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Widget compilation utility using Rollup
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.compileWidgets = compileWidgets;
|
|
43
|
+
const rollup_1 = require("rollup");
|
|
44
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
45
|
+
/**
|
|
46
|
+
* Default external dependencies for widgets
|
|
47
|
+
*/
|
|
48
|
+
const DEFAULT_EXTERNALS = [
|
|
49
|
+
'react',
|
|
50
|
+
'react-dom',
|
|
51
|
+
'react/jsx-runtime',
|
|
52
|
+
'react/jsx-dev-runtime',
|
|
53
|
+
'react-dom/client'
|
|
54
|
+
];
|
|
55
|
+
/**
|
|
56
|
+
* Compile widgets using Rollup
|
|
57
|
+
*
|
|
58
|
+
* @param widgets - Array of widget metadata to compile
|
|
59
|
+
* @param outputDir - Directory to write compiled widgets
|
|
60
|
+
* @param config - Widget compilation configuration
|
|
61
|
+
* @returns Number of widgets compiled
|
|
62
|
+
*/
|
|
63
|
+
async function compileWidgets(widgets, outputDir, config = {}) {
|
|
64
|
+
if (widgets.length === 0) {
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
const { external = DEFAULT_EXTERNALS, tsconfig = './tsconfig.json', typescript: typescriptOptions = {}, minify = false } = config;
|
|
68
|
+
// Build each widget separately to get individual bundles
|
|
69
|
+
const buildPromises = widgets.map(async (widget) => {
|
|
70
|
+
// Dynamically import plugins - use any to bypass TypeScript module resolution issues
|
|
71
|
+
const typescript = (await Promise.resolve(`${'@rollup/plugin-typescript'}`).then(s => __importStar(require(s)))).default;
|
|
72
|
+
const nodeResolve = (await Promise.resolve(`${'@rollup/plugin-node-resolve'}`).then(s => __importStar(require(s)))).default;
|
|
73
|
+
const commonjs = (await Promise.resolve(`${'@rollup/plugin-commonjs'}`).then(s => __importStar(require(s)))).default;
|
|
74
|
+
const plugins = [
|
|
75
|
+
typescript({
|
|
76
|
+
tsconfig,
|
|
77
|
+
declaration: false,
|
|
78
|
+
sourceMap: true,
|
|
79
|
+
...typescriptOptions
|
|
80
|
+
}),
|
|
81
|
+
nodeResolve({
|
|
82
|
+
browser: true,
|
|
83
|
+
preferBuiltins: false,
|
|
84
|
+
extensions: ['.tsx', '.ts', '.jsx', '.js']
|
|
85
|
+
}),
|
|
86
|
+
commonjs()
|
|
87
|
+
];
|
|
88
|
+
// Add minification if requested
|
|
89
|
+
if (minify) {
|
|
90
|
+
const { terser } = await Promise.resolve(`${'rollup-plugin-terser'}`).then(s => __importStar(require(s)));
|
|
91
|
+
plugins.push(terser({
|
|
92
|
+
compress: {
|
|
93
|
+
drop_console: false
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
const rollupConfig = {
|
|
98
|
+
input: widget.path,
|
|
99
|
+
output: {
|
|
100
|
+
file: node_path_1.default.join(outputDir, `${widget.name}.js`),
|
|
101
|
+
format: 'es',
|
|
102
|
+
sourcemap: true,
|
|
103
|
+
inlineDynamicImports: true
|
|
104
|
+
},
|
|
105
|
+
external,
|
|
106
|
+
plugins
|
|
107
|
+
};
|
|
108
|
+
const bundle = await (0, rollup_1.rollup)(rollupConfig);
|
|
109
|
+
await bundle.write(rollupConfig.output);
|
|
110
|
+
await bundle.close();
|
|
111
|
+
});
|
|
112
|
+
await Promise.all(buildPromises);
|
|
113
|
+
return widgets.length;
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=widget-compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-compiler.js","sourceRoot":"","sources":["../../../src/utils/widget-compi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QAEF,gCAAgC;QAChC,IAAI,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,MAAM,EAAE,GAAG,yBAAa,sBAA6B,uCAAC,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,mBAAI,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,IAAA,eAAM,EAAC,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"}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
// Core plugin
|
|
21
|
+
export { vertesiaImportPlugin } from './plugin.js';
|
|
22
|
+
// Presets
|
|
23
|
+
export { skillTransformer, rawTransformer, skillCollectionTransformer, promptTransformer, SkillDefinitionSchema, PromptDefinitionSchema, PromptRole, TemplateType } from './presets/index.js';
|
|
24
|
+
// Utilities
|
|
25
|
+
export { parseFrontmatter } from './parsers/frontmatter.js';
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,cAAc;AACd,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAanD,UAAU;AACV,OAAO,EACH,gBAAgB,EAChB,cAAc,EACd,0BAA0B,EAC1B,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EAKtB,UAAU,EACV,YAAY,EACf,MAAM,oBAAoB,CAAC;AAE5B,YAAY;AACZ,OAAO,EAAE,gBAAgB,EAA0B,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frontmatter parser utility using gray-matter
|
|
3
|
+
*/
|
|
4
|
+
import matter from 'gray-matter';
|
|
5
|
+
/**
|
|
6
|
+
* Parse YAML frontmatter from markdown content
|
|
7
|
+
*
|
|
8
|
+
* @param content - Raw markdown content with optional frontmatter
|
|
9
|
+
* @returns Parsed frontmatter and content
|
|
10
|
+
*/
|
|
11
|
+
export function parseFrontmatter(content) {
|
|
12
|
+
const result = matter(content);
|
|
13
|
+
return {
|
|
14
|
+
frontmatter: result.data,
|
|
15
|
+
content: result.content,
|
|
16
|
+
original: content
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=frontmatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../../src/parsers/frontmatter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AAajC;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAE/B,OAAO;QACH,WAAW,EAAE,MAAM,CAAC,IAAI;QACxB,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,QAAQ,EAAE,OAAO;KACpB,CAAC;AACN,CAAC"}
|