@vertesia/build-tools 1.3.0 → 1.4.0-dev.20260615.042033Z
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/README.md +3 -3
- package/lib/bin/build.d.ts +35 -0
- package/lib/bin/build.d.ts.map +1 -0
- package/lib/bin/build.js +79 -0
- package/lib/bin/build.js.map +1 -0
- package/lib/bin/config.d.ts +24 -0
- package/lib/bin/config.d.ts.map +1 -0
- package/lib/bin/config.js +91 -0
- package/lib/bin/config.js.map +1 -0
- package/lib/core/compilers/widget.d.ts +27 -0
- package/lib/core/compilers/widget.d.ts.map +1 -0
- package/lib/core/compilers/widget.js +37 -0
- package/lib/core/compilers/widget.js.map +1 -0
- package/lib/{types → core}/parsers/frontmatter.d.ts +1 -1
- package/lib/core/parsers/frontmatter.d.ts.map +1 -0
- package/lib/{esm → core}/parsers/frontmatter.js +1 -1
- package/lib/core/parsers/frontmatter.js.map +1 -0
- package/lib/core/transformers/index.d.ts +10 -0
- package/lib/core/transformers/index.d.ts.map +1 -0
- package/lib/core/transformers/index.js +10 -0
- package/lib/core/transformers/index.js.map +1 -0
- package/lib/{types/presets → core/transformers}/prompt.d.ts +7 -21
- package/lib/core/transformers/prompt.d.ts.map +1 -0
- package/lib/{esm/presets → core/transformers}/prompt.js +17 -14
- package/lib/core/transformers/prompt.js.map +1 -0
- package/lib/core/transformers/raw.d.ts.map +1 -0
- package/lib/{esm/presets → core/transformers}/raw.js +2 -2
- package/lib/core/transformers/raw.js.map +1 -0
- package/lib/core/transformers/skill-collection.d.ts.map +1 -0
- package/lib/{esm/presets → core/transformers}/skill-collection.js +5 -12
- package/lib/core/transformers/skill-collection.js.map +1 -0
- package/lib/core/transformers/skill.d.ts +111 -0
- package/lib/core/transformers/skill.d.ts.map +1 -0
- package/lib/{esm/presets → core/transformers}/skill.js +70 -51
- package/lib/core/transformers/skill.js.map +1 -0
- package/lib/core/transformers/template-collection.d.ts.map +1 -0
- package/lib/{esm/presets → core/transformers}/template-collection.js +5 -12
- package/lib/core/transformers/template-collection.js.map +1 -0
- package/lib/{types/presets → core/transformers}/template.d.ts +7 -22
- package/lib/core/transformers/template.d.ts.map +1 -0
- package/lib/{esm/presets → core/transformers}/template.js +16 -11
- package/lib/core/transformers/template.js.map +1 -0
- package/lib/{types → core}/types.d.ts +5 -61
- package/lib/core/types.d.ts.map +1 -0
- package/lib/core/types.js +6 -0
- package/lib/{cjs → core}/types.js.map +1 -1
- package/lib/core/utils/asset-copy.d.ts.map +1 -0
- package/lib/core/utils/asset-copy.js.map +1 -0
- package/lib/core/utils/asset-discovery.d.ts.map +1 -0
- package/lib/{esm → core}/utils/asset-discovery.js +4 -4
- package/lib/core/utils/asset-discovery.js.map +1 -0
- package/lib/core/utils/template-asset-discovery.d.ts.map +1 -0
- package/lib/{esm → core}/utils/template-asset-discovery.js +3 -7
- package/lib/core/utils/template-asset-discovery.js.map +1 -0
- package/lib/import-transform/builtins.d.ts +21 -0
- package/lib/import-transform/builtins.d.ts.map +1 -0
- package/lib/import-transform/builtins.js +50 -0
- package/lib/import-transform/builtins.js.map +1 -0
- package/lib/import-transform/chunk-emitter.d.ts +24 -0
- package/lib/import-transform/chunk-emitter.d.ts.map +1 -0
- package/lib/import-transform/chunk-emitter.js +35 -0
- package/lib/import-transform/chunk-emitter.js.map +1 -0
- package/lib/import-transform/detector.d.ts +24 -0
- package/lib/import-transform/detector.d.ts.map +1 -0
- package/lib/import-transform/detector.js +34 -0
- package/lib/import-transform/detector.js.map +1 -0
- package/lib/import-transform/index.d.ts +47 -0
- package/lib/import-transform/index.d.ts.map +1 -0
- package/lib/import-transform/index.js +115 -0
- package/lib/import-transform/index.js.map +1 -0
- package/lib/import-transform/patterns.d.ts +25 -0
- package/lib/import-transform/patterns.d.ts.map +1 -0
- package/lib/import-transform/patterns.js +27 -0
- package/lib/import-transform/patterns.js.map +1 -0
- package/lib/import-transform/resolver.d.ts +23 -0
- package/lib/import-transform/resolver.d.ts.map +1 -0
- package/lib/import-transform/resolver.js +30 -0
- package/lib/import-transform/resolver.js.map +1 -0
- package/lib/import-transform/rewriter.d.ts +21 -0
- package/lib/import-transform/rewriter.d.ts.map +1 -0
- package/lib/import-transform/rewriter.js +30 -0
- package/lib/import-transform/rewriter.js.map +1 -0
- package/lib/import-transform/scanner.d.ts +17 -0
- package/lib/import-transform/scanner.d.ts.map +1 -0
- package/lib/import-transform/scanner.js +46 -0
- package/lib/import-transform/scanner.js.map +1 -0
- package/lib/index.d.ts +39 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +43 -0
- package/lib/index.js.map +1 -0
- package/lib/vite/api-server.d.ts +54 -0
- package/lib/vite/api-server.d.ts.map +1 -0
- package/lib/vite/api-server.js +94 -0
- package/lib/vite/api-server.js.map +1 -0
- package/lib/vite/dev-server.d.ts +42 -0
- package/lib/vite/dev-server.d.ts.map +1 -0
- package/lib/vite/dev-server.js +111 -0
- package/lib/vite/dev-server.js.map +1 -0
- package/lib/vite/index.d.ts +15 -0
- package/lib/vite/index.d.ts.map +1 -0
- package/lib/vite/index.js +15 -0
- package/lib/vite/index.js.map +1 -0
- package/package.json +38 -28
- package/src/bin/build.ts +83 -0
- package/src/bin/config.ts +113 -0
- package/src/core/compilers/widget.ts +69 -0
- package/src/{parsers → core/parsers}/frontmatter.ts +2 -2
- package/src/core/transformers/index.ts +27 -0
- package/src/{presets → core/transformers}/prompt.ts +35 -32
- package/src/{presets → core/transformers}/raw.ts +2 -2
- package/src/{presets → core/transformers}/skill-collection.ts +5 -12
- package/src/{presets → core/transformers}/skill.ts +119 -99
- package/src/{presets → core/transformers}/template-collection.ts +76 -83
- package/src/{presets → core/transformers}/template.ts +121 -116
- package/src/core/types.ts +71 -0
- package/src/{utils → core/utils}/asset-copy.ts +3 -2
- package/src/{utils → core/utils}/asset-discovery.ts +5 -5
- package/src/{utils → core/utils}/template-asset-discovery.ts +70 -77
- package/src/import-transform/builtins.ts +56 -0
- package/src/import-transform/chunk-emitter.ts +60 -0
- package/src/import-transform/detector.ts +56 -0
- package/src/import-transform/index.ts +171 -0
- package/src/import-transform/patterns.ts +34 -0
- package/src/import-transform/resolver.ts +57 -0
- package/src/import-transform/rewriter.ts +48 -0
- package/src/import-transform/scanner.ts +55 -0
- package/src/index.ts +67 -42
- package/src/vite/api-server.ts +142 -0
- package/src/vite/dev-server.ts +128 -0
- package/src/vite/index.ts +15 -0
- package/lib/build-tools.js +0 -2054
- package/lib/build-tools.js.map +0 -1
- package/lib/cjs/index.js +0 -43
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/parsers/frontmatter.js +0 -25
- package/lib/cjs/parsers/frontmatter.js.map +0 -1
- package/lib/cjs/plugin.js +0 -150
- package/lib/cjs/plugin.js.map +0 -1
- package/lib/cjs/presets/index.js +0 -25
- package/lib/cjs/presets/index.js.map +0 -1
- package/lib/cjs/presets/prompt.js +0 -185
- package/lib/cjs/presets/prompt.js.map +0 -1
- package/lib/cjs/presets/raw.js +0 -25
- package/lib/cjs/presets/raw.js.map +0 -1
- package/lib/cjs/presets/skill-collection.js +0 -83
- package/lib/cjs/presets/skill-collection.js.map +0 -1
- package/lib/cjs/presets/skill.js +0 -272
- package/lib/cjs/presets/skill.js.map +0 -1
- package/lib/cjs/presets/template-collection.js +0 -80
- package/lib/cjs/presets/template-collection.js.map +0 -1
- package/lib/cjs/presets/template.js +0 -105
- package/lib/cjs/presets/template.js.map +0 -1
- package/lib/cjs/types.js +0 -6
- package/lib/cjs/utils/asset-copy.js +0 -61
- package/lib/cjs/utils/asset-copy.js.map +0 -1
- package/lib/cjs/utils/asset-discovery.js +0 -100
- package/lib/cjs/utils/asset-discovery.js.map +0 -1
- package/lib/cjs/utils/template-asset-discovery.js +0 -63
- package/lib/cjs/utils/template-asset-discovery.js.map +0 -1
- package/lib/cjs/utils/widget-compiler.js +0 -115
- package/lib/cjs/utils/widget-compiler.js.map +0 -1
- package/lib/cjs/vite.js +0 -45
- package/lib/cjs/vite.js.map +0 -1
- package/lib/esm/index.js +0 -26
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/parsers/frontmatter.js.map +0 -1
- package/lib/esm/plugin.js +0 -144
- package/lib/esm/plugin.js.map +0 -1
- package/lib/esm/presets/index.js +0 -10
- package/lib/esm/presets/index.js.map +0 -1
- package/lib/esm/presets/prompt.js.map +0 -1
- package/lib/esm/presets/raw.js.map +0 -1
- package/lib/esm/presets/skill-collection.js.map +0 -1
- package/lib/esm/presets/skill.js.map +0 -1
- package/lib/esm/presets/template-collection.js.map +0 -1
- package/lib/esm/presets/template.js.map +0 -1
- package/lib/esm/types.js +0 -5
- package/lib/esm/types.js.map +0 -1
- package/lib/esm/utils/asset-copy.js.map +0 -1
- package/lib/esm/utils/asset-discovery.js.map +0 -1
- package/lib/esm/utils/template-asset-discovery.js.map +0 -1
- package/lib/esm/utils/widget-compiler.js +0 -76
- package/lib/esm/utils/widget-compiler.js.map +0 -1
- package/lib/esm/vite.js +0 -42
- package/lib/esm/vite.js.map +0 -1
- package/lib/types/index.d.ts +0 -24
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/parsers/frontmatter.d.ts.map +0 -1
- package/lib/types/plugin.d.ts +0 -10
- package/lib/types/plugin.d.ts.map +0 -1
- package/lib/types/presets/index.d.ts +0 -10
- package/lib/types/presets/index.d.ts.map +0 -1
- package/lib/types/presets/prompt.d.ts.map +0 -1
- package/lib/types/presets/raw.d.ts.map +0 -1
- package/lib/types/presets/skill-collection.d.ts.map +0 -1
- package/lib/types/presets/skill.d.ts +0 -361
- package/lib/types/presets/skill.d.ts.map +0 -1
- package/lib/types/presets/template-collection.d.ts.map +0 -1
- package/lib/types/presets/template.d.ts.map +0 -1
- package/lib/types/types.d.ts.map +0 -1
- package/lib/types/utils/asset-copy.d.ts.map +0 -1
- package/lib/types/utils/asset-discovery.d.ts.map +0 -1
- package/lib/types/utils/template-asset-discovery.d.ts.map +0 -1
- package/lib/types/utils/widget-compiler.d.ts +0 -15
- package/lib/types/utils/widget-compiler.d.ts.map +0 -1
- package/lib/types/vite.d.ts +0 -32
- package/lib/types/vite.d.ts.map +0 -1
- package/src/plugin.ts +0 -166
- package/src/presets/index.ts +0 -10
- package/src/types.ts +0 -140
- package/src/utils/widget-compiler.ts +0 -98
- package/src/vite.ts +0 -45
- /package/lib/{types/presets → core/transformers}/raw.d.ts +0 -0
- /package/lib/{types/presets → core/transformers}/skill-collection.d.ts +0 -0
- /package/lib/{types/presets → core/transformers}/template-collection.d.ts +0 -0
- /package/lib/{types → core}/utils/asset-copy.d.ts +0 -0
- /package/lib/{esm → core}/utils/asset-copy.js +0 -0
- /package/lib/{types → core}/utils/asset-discovery.d.ts +0 -0
- /package/lib/{types → core}/utils/template-asset-discovery.d.ts +0 -0
package/lib/cjs/presets/skill.js
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Skill transformer preset for markdown files with frontmatter
|
|
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.skillTransformer = exports.SkillPropertiesSchema = exports.SkillDefinitionSchema = void 0;
|
|
10
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
-
const node_fs_1 = require("node:fs");
|
|
12
|
-
const zod_1 = require("zod");
|
|
13
|
-
const frontmatter_js_1 = require("../parsers/frontmatter.js");
|
|
14
|
-
const asset_discovery_js_1 = require("../utils/asset-discovery.js");
|
|
15
|
-
/**
|
|
16
|
-
* Context triggers for auto-injection of skills (for frontmatter validation)
|
|
17
|
-
*/
|
|
18
|
-
const SkillContextTriggersFrontmatterSchema = zod_1.z.object({
|
|
19
|
-
keywords: zod_1.z.array(zod_1.z.string()).optional(),
|
|
20
|
-
tool_names: zod_1.z.array(zod_1.z.string()).optional(),
|
|
21
|
-
data_patterns: zod_1.z.array(zod_1.z.string()).optional()
|
|
22
|
-
}).strict();
|
|
23
|
-
/**
|
|
24
|
-
* Context triggers for auto-injection of skills (for output validation)
|
|
25
|
-
*/
|
|
26
|
-
const SkillContextTriggersSchema = zod_1.z.object({
|
|
27
|
-
keywords: zod_1.z.array(zod_1.z.string()).optional(),
|
|
28
|
-
tool_names: zod_1.z.array(zod_1.z.string()).optional(),
|
|
29
|
-
data_patterns: zod_1.z.array(zod_1.z.string()).optional()
|
|
30
|
-
}).optional();
|
|
31
|
-
/**
|
|
32
|
-
* Execution configuration for skills that need code execution (for frontmatter validation)
|
|
33
|
-
*/
|
|
34
|
-
const SkillExecutionFrontmatterSchema = zod_1.z.object({
|
|
35
|
-
language: zod_1.z.string(),
|
|
36
|
-
packages: zod_1.z.array(zod_1.z.string()).optional(),
|
|
37
|
-
system_packages: zod_1.z.array(zod_1.z.string()).optional(),
|
|
38
|
-
template: zod_1.z.string().optional()
|
|
39
|
-
}).strict();
|
|
40
|
-
/**
|
|
41
|
-
* Execution configuration for skills that need code execution (for output validation)
|
|
42
|
-
*/
|
|
43
|
-
const SkillExecutionSchema = zod_1.z.object({
|
|
44
|
-
language: zod_1.z.string(),
|
|
45
|
-
packages: zod_1.z.array(zod_1.z.string()).optional(),
|
|
46
|
-
system_packages: zod_1.z.array(zod_1.z.string()).optional(),
|
|
47
|
-
template: zod_1.z.string().optional()
|
|
48
|
-
}).optional();
|
|
49
|
-
/**
|
|
50
|
-
* Zod schema for skill frontmatter validation
|
|
51
|
-
* This validates the YAML frontmatter before transformation
|
|
52
|
-
* Supports both flat and nested structures
|
|
53
|
-
*/
|
|
54
|
-
const SkillFrontmatterSchema = zod_1.z.object({
|
|
55
|
-
// Required fields
|
|
56
|
-
name: zod_1.z.string().min(1, 'Skill name is required'),
|
|
57
|
-
description: zod_1.z.string().min(1, 'Skill description is required'),
|
|
58
|
-
// Optional fields
|
|
59
|
-
title: zod_1.z.string().optional(),
|
|
60
|
-
content_type: zod_1.z.enum(['md', 'jst']).optional(),
|
|
61
|
-
// Flat structure fields (legacy)
|
|
62
|
-
keywords: zod_1.z.array(zod_1.z.string()).optional(),
|
|
63
|
-
tools: zod_1.z.array(zod_1.z.string()).optional(),
|
|
64
|
-
data_patterns: zod_1.z.array(zod_1.z.string()).optional(),
|
|
65
|
-
language: zod_1.z.string().optional(),
|
|
66
|
-
packages: zod_1.z.array(zod_1.z.string()).optional(),
|
|
67
|
-
system_packages: zod_1.z.array(zod_1.z.string()).optional(),
|
|
68
|
-
// Nested structure fields
|
|
69
|
-
context_triggers: SkillContextTriggersFrontmatterSchema.optional(),
|
|
70
|
-
execution: SkillExecutionFrontmatterSchema.optional(),
|
|
71
|
-
related_tools: zod_1.z.array(zod_1.z.string()).optional(),
|
|
72
|
-
input_schema: zod_1.z.object({
|
|
73
|
-
type: zod_1.z.literal('object'),
|
|
74
|
-
properties: zod_1.z.record(zod_1.z.any()).optional(),
|
|
75
|
-
required: zod_1.z.array(zod_1.z.string()).optional()
|
|
76
|
-
}).optional(),
|
|
77
|
-
// Asset fields (auto-discovered but can be overridden)
|
|
78
|
-
scripts: zod_1.z.array(zod_1.z.string()).optional(),
|
|
79
|
-
widgets: zod_1.z.array(zod_1.z.string()).optional()
|
|
80
|
-
}).strict();
|
|
81
|
-
/**
|
|
82
|
-
* MUST be kept in sync with @vertesia/tools-sdk SkillDefinition
|
|
83
|
-
* Zod schema for skill definition
|
|
84
|
-
* This validates the structure of skill objects generated from markdown
|
|
85
|
-
* Matches the SkillDefinition interface from @vertesia/tools-sdk
|
|
86
|
-
*
|
|
87
|
-
* Note: The isEnabled property is not included in this schema because Zod cannot
|
|
88
|
-
* properly validate function signatures. It will be type-checked by TypeScript instead.
|
|
89
|
-
*/
|
|
90
|
-
exports.SkillDefinitionSchema = zod_1.z.object({
|
|
91
|
-
name: zod_1.z.string().min(1, 'Skill name is required'),
|
|
92
|
-
title: zod_1.z.string().optional(),
|
|
93
|
-
description: zod_1.z.string().min(1, 'Skill description is required'),
|
|
94
|
-
instructions: zod_1.z.string(),
|
|
95
|
-
content_type: zod_1.z.enum(['md', 'jst']),
|
|
96
|
-
input_schema: zod_1.z.object({
|
|
97
|
-
type: zod_1.z.literal('object'),
|
|
98
|
-
properties: zod_1.z.record(zod_1.z.any()).optional(),
|
|
99
|
-
required: zod_1.z.array(zod_1.z.string()).optional()
|
|
100
|
-
}).optional(),
|
|
101
|
-
context_triggers: SkillContextTriggersSchema,
|
|
102
|
-
execution: SkillExecutionSchema,
|
|
103
|
-
related_tools: zod_1.z.array(zod_1.z.string()).optional(),
|
|
104
|
-
scripts: zod_1.z.array(zod_1.z.string()).optional(),
|
|
105
|
-
widgets: zod_1.z.array(zod_1.z.string()).optional()
|
|
106
|
-
}).passthrough();
|
|
107
|
-
/**
|
|
108
|
-
* Schema for validating properties exported from properties.ts
|
|
109
|
-
* This is a partial schema - allows any subset of SkillDefinition fields
|
|
110
|
-
*
|
|
111
|
-
* Note: Function properties like isEnabled cannot be validated by Zod for their signatures.
|
|
112
|
-
* Zod will only check that they are functions, not their specific parameter/return types.
|
|
113
|
-
* Use TypeScript for proper type checking of function signatures.
|
|
114
|
-
*/
|
|
115
|
-
exports.SkillPropertiesSchema = exports.SkillDefinitionSchema.partial().passthrough();
|
|
116
|
-
/**
|
|
117
|
-
* Build a SkillDefinition from frontmatter and markdown content.
|
|
118
|
-
* This mirrors the logic in @vertesia/tools-sdk parseSkillFile function.
|
|
119
|
-
*
|
|
120
|
-
* Supports two frontmatter structures:
|
|
121
|
-
*
|
|
122
|
-
* 1. Flat structure (matches parseSkillFile in tools-sdk):
|
|
123
|
-
* keywords: [...]
|
|
124
|
-
* tools: [...]
|
|
125
|
-
* language: python
|
|
126
|
-
* packages: [...]
|
|
127
|
-
*
|
|
128
|
-
* 2. Nested structure (for more explicit YAML):
|
|
129
|
-
* context_triggers:
|
|
130
|
-
* keywords: [...]
|
|
131
|
-
* tool_names: [...]
|
|
132
|
-
* execution:
|
|
133
|
-
* language: python
|
|
134
|
-
* packages: [...]
|
|
135
|
-
* related_tools: [...]
|
|
136
|
-
*
|
|
137
|
-
* @param frontmatter - Parsed frontmatter object
|
|
138
|
-
* @param instructions - Markdown content (body of the file)
|
|
139
|
-
* @param contentType - Content type ('md' or 'jst')
|
|
140
|
-
* @param widgets - Discovered widget names
|
|
141
|
-
* @param scripts - Discovered script names
|
|
142
|
-
* @returns Skill definition object
|
|
143
|
-
*/
|
|
144
|
-
function buildSkillDefinition(frontmatter, instructions, contentType, widgets, scripts) {
|
|
145
|
-
const skill = {
|
|
146
|
-
name: frontmatter.name,
|
|
147
|
-
title: frontmatter.title,
|
|
148
|
-
description: frontmatter.description,
|
|
149
|
-
instructions,
|
|
150
|
-
content_type: contentType,
|
|
151
|
-
widgets: widgets.length > 0 ? widgets : undefined,
|
|
152
|
-
scripts: scripts.length > 0 ? scripts : undefined,
|
|
153
|
-
};
|
|
154
|
-
// Build context triggers - support both flat and nested structure
|
|
155
|
-
// Nested: context_triggers: { keywords: [...], tool_names: [...] }
|
|
156
|
-
// Flat: keywords: [...], tools: [...]
|
|
157
|
-
const contextTriggers = frontmatter.context_triggers;
|
|
158
|
-
const hasNestedTriggers = contextTriggers && typeof contextTriggers === 'object';
|
|
159
|
-
const hasFlatTriggers = frontmatter.keywords || frontmatter.tools || frontmatter.data_patterns;
|
|
160
|
-
if (hasNestedTriggers || hasFlatTriggers) {
|
|
161
|
-
skill.context_triggers = {
|
|
162
|
-
keywords: hasNestedTriggers ? contextTriggers.keywords : frontmatter.keywords,
|
|
163
|
-
tool_names: hasNestedTriggers ? contextTriggers.tool_names : frontmatter.tools,
|
|
164
|
-
data_patterns: hasNestedTriggers ? contextTriggers.data_patterns : frontmatter.data_patterns,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
// Build execution config - support both flat and nested structure
|
|
168
|
-
const execution = frontmatter.execution;
|
|
169
|
-
const hasNestedExecution = execution && typeof execution === 'object';
|
|
170
|
-
const hasFlatExecution = frontmatter.language;
|
|
171
|
-
if (hasNestedExecution || hasFlatExecution) {
|
|
172
|
-
skill.execution = {
|
|
173
|
-
language: hasNestedExecution ? execution.language : frontmatter.language,
|
|
174
|
-
packages: hasNestedExecution ? execution.packages : frontmatter.packages,
|
|
175
|
-
system_packages: hasNestedExecution ? execution.system_packages : frontmatter.system_packages,
|
|
176
|
-
};
|
|
177
|
-
// Extract code template from instructions if present
|
|
178
|
-
const codeBlockMatch = instructions.match(/```(?:python|javascript|typescript|js|ts|py)\n([\s\S]*?)```/);
|
|
179
|
-
if (codeBlockMatch) {
|
|
180
|
-
skill.execution.template = codeBlockMatch[1].trim();
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
// Related tools - support both direct field and from tools field
|
|
184
|
-
if (frontmatter.related_tools) {
|
|
185
|
-
skill.related_tools = frontmatter.related_tools;
|
|
186
|
-
}
|
|
187
|
-
else if (frontmatter.tools && !hasNestedTriggers) {
|
|
188
|
-
// If tools is not part of context_triggers, use it as related_tools
|
|
189
|
-
skill.related_tools = frontmatter.tools;
|
|
190
|
-
}
|
|
191
|
-
// Input schema from frontmatter
|
|
192
|
-
if (frontmatter.input_schema) {
|
|
193
|
-
skill.input_schema = frontmatter.input_schema;
|
|
194
|
-
}
|
|
195
|
-
return skill;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Skill transformer preset
|
|
199
|
-
* Transforms markdown files with ?skill suffix OR SKILL.md files into skill definition objects
|
|
200
|
-
*
|
|
201
|
-
* Matches:
|
|
202
|
-
* - Files with ?skill suffix: ./my-skill.md?skill
|
|
203
|
-
* - SKILL.md files: ./my-skill/SKILL.md
|
|
204
|
-
*
|
|
205
|
-
* Runtime Properties:
|
|
206
|
-
* - Supports properties.ts file in skill directory for runtime properties (functions, overrides)
|
|
207
|
-
* - Properties from properties.ts override those from frontmatter
|
|
208
|
-
* - See README.md for detailed usage examples
|
|
209
|
-
*
|
|
210
|
-
* @example
|
|
211
|
-
* ```typescript
|
|
212
|
-
* import skill1 from './my-skill.md?skill';
|
|
213
|
-
* import skill2 from './my-skill/SKILL.md';
|
|
214
|
-
* // Both are SkillDefinition objects
|
|
215
|
-
* ```
|
|
216
|
-
*/
|
|
217
|
-
exports.skillTransformer = {
|
|
218
|
-
pattern: /(\.md\?skill$|\/SKILL\.md$)/,
|
|
219
|
-
schema: exports.SkillDefinitionSchema,
|
|
220
|
-
transform: (content, filePath) => {
|
|
221
|
-
const { frontmatter, content: markdown } = (0, frontmatter_js_1.parseFrontmatter)(content);
|
|
222
|
-
// Validate frontmatter first to catch unknown properties
|
|
223
|
-
const frontmatterValidation = SkillFrontmatterSchema.safeParse(frontmatter);
|
|
224
|
-
if (!frontmatterValidation.success) {
|
|
225
|
-
const errors = frontmatterValidation.error.errors
|
|
226
|
-
.map((err) => {
|
|
227
|
-
const pathStr = err.path.length > 0 ? err.path.join('.') : 'frontmatter';
|
|
228
|
-
return ` - ${pathStr}: ${err.message}`;
|
|
229
|
-
})
|
|
230
|
-
.join('\n');
|
|
231
|
-
throw new Error(`Invalid frontmatter in ${filePath}:\n${errors}`);
|
|
232
|
-
}
|
|
233
|
-
// Determine content type from frontmatter or file extension
|
|
234
|
-
const content_type = frontmatter.content_type || 'md';
|
|
235
|
-
// Discover assets (scripts and widgets) in the skill directory
|
|
236
|
-
const assets = (0, asset_discovery_js_1.discoverSkillAssets)(filePath);
|
|
237
|
-
// Build skill definition using the same logic as parseSkillFile in tools-sdk
|
|
238
|
-
const skillData = buildSkillDefinition(frontmatter, markdown, content_type, assets.widgets, assets.scripts);
|
|
239
|
-
// Check if properties.ts exists in the skill directory
|
|
240
|
-
const skillDir = node_path_1.default.dirname(filePath);
|
|
241
|
-
const propertiesPath = node_path_1.default.join(skillDir, 'properties.ts');
|
|
242
|
-
const hasProperties = (0, node_fs_1.existsSync)(propertiesPath);
|
|
243
|
-
// If properties.ts exists, generate custom code with import and merge
|
|
244
|
-
// Rollup will handle transpiling properties.ts to properties.js
|
|
245
|
-
if (hasProperties) {
|
|
246
|
-
const skillDataJson = JSON.stringify(skillData, null, 2);
|
|
247
|
-
const code = `import properties from './properties.js';
|
|
248
|
-
|
|
249
|
-
// Runtime validation for function properties
|
|
250
|
-
if ('isEnabled' in properties && typeof properties.isEnabled !== 'function') {
|
|
251
|
-
throw new Error('properties.isEnabled must be a function, got ' + typeof properties.isEnabled);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
const skill = ${skillDataJson};
|
|
255
|
-
|
|
256
|
-
export default { ...skill, ...properties };
|
|
257
|
-
`;
|
|
258
|
-
return {
|
|
259
|
-
data: skillData,
|
|
260
|
-
assets: assets.assetFiles,
|
|
261
|
-
widgets: assets.widgetMetadata,
|
|
262
|
-
code
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
return {
|
|
266
|
-
data: skillData,
|
|
267
|
-
assets: assets.assetFiles,
|
|
268
|
-
widgets: assets.widgetMetadata
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
//# sourceMappingURL=skill.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skill.js","sourceRoot":"","sources":["../../../src/presets/skill.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;AAEH,0DAA6B;AAC7B,qCAAqC;AACrC,6BAAwB;AAExB,8DAA6D;AAC7D,oEAAkE;AAOlE;;GAEG;AACH,MAAM,qCAAqC,GAAG,OAAC,CAAC,MAAM,CAAC;IACnD,QAAQ,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACxC,UAAU,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IAC1C,aAAa,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CAChD,CAAC,CAAC,MAAM,EAAE,CAAC;AAEZ;;G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AqB,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,uDAAuD;QACvD,MAAM,QAAQ,GAAG,mBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACxC,MAAM,cAAc,GAAG,mBAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QAC5D,MAAM,aAAa,GAAG,IAAA,oBAAU,EAAC,cAAc,CAAC,CAAC;QAEjD,sEAAsE;QACtE,gEAAgE;QAChE,IAAI,aAAa,EAAE,CAAC;YAChB,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YACzD,MAAM,IAAI,GAAG;;;;;;;gBAOT,aAAa;;;CAG5B,CAAC;YACU,OAAO;gBACH,IAAI,EAAE,SAAS;gBACf,MAAM,EAAE,MAAM,CAAC,UAAU;gBACzB,OAAO,EAAE,MAAM,CAAC,cAAc;gBAC9B,IAAI;aACP,CAAC;QACN,CAAC;QAED,OAAO;YACH,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,MAAM,CAAC,UAAU;YACzB,OAAO,EAAE,MAAM,CAAC,cAAc;SACjC,CAAC;IACN,CAAC;CACJ,CAAC"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Template collection transformer for directory-based template imports
|
|
4
|
-
* Scans a directory for subdirectories containing TEMPLATE.md files
|
|
5
|
-
*/
|
|
6
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
-
};
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.templateCollectionTransformer = void 0;
|
|
11
|
-
const node_fs_1 = require("node:fs");
|
|
12
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
-
/**
|
|
14
|
-
* Template collection transformer preset
|
|
15
|
-
* Transforms directory imports with ?templates suffix into an array of template imports
|
|
16
|
-
*
|
|
17
|
-
* Matches:
|
|
18
|
-
* - ./all?templates (recommended - generates all.js in the directory)
|
|
19
|
-
* - Any path ending with a filename and ?templates
|
|
20
|
-
*
|
|
21
|
-
* NOTE: A filename before ?templates is REQUIRED to avoid naming conflicts.
|
|
22
|
-
* The filename becomes the output module name.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* import templates from './all?templates';
|
|
27
|
-
* // Scans current directory for subdirectories with TEMPLATE.md
|
|
28
|
-
* // Generates all.js containing array of all templates
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
exports.templateCollectionTransformer = {
|
|
32
|
-
pattern: /\/[^/?]+\?templates$/,
|
|
33
|
-
virtual: true,
|
|
34
|
-
transform: (_content, filePath) => {
|
|
35
|
-
// Remove ?templates suffix and the filename to get directory path
|
|
36
|
-
const pathWithoutQuery = filePath.replace(/\?templates$/, '');
|
|
37
|
-
const dirPath = node_path_1.default.dirname(pathWithoutQuery);
|
|
38
|
-
if (!(0, node_fs_1.existsSync)(dirPath)) {
|
|
39
|
-
throw new Error(`Directory not found: ${dirPath}`);
|
|
40
|
-
}
|
|
41
|
-
if (!(0, node_fs_1.statSync)(dirPath).isDirectory()) {
|
|
42
|
-
throw new Error(`Not a directory: ${dirPath}`);
|
|
43
|
-
}
|
|
44
|
-
// Scan for subdirectories containing TEMPLATE.md
|
|
45
|
-
const entries = (0, node_fs_1.readdirSync)(dirPath);
|
|
46
|
-
const imports = [];
|
|
47
|
-
const names = [];
|
|
48
|
-
for (const entry of entries) {
|
|
49
|
-
const entryPath = node_path_1.default.join(dirPath, entry);
|
|
50
|
-
try {
|
|
51
|
-
if ((0, node_fs_1.statSync)(entryPath).isDirectory()) {
|
|
52
|
-
const templateFile = node_path_1.default.join(entryPath, 'TEMPLATE.md');
|
|
53
|
-
if ((0, node_fs_1.existsSync)(templateFile)) {
|
|
54
|
-
const identifier = `Template_${entry.replace(/[^a-zA-Z0-9_]/g, '_')}`;
|
|
55
|
-
imports.push(`import ${identifier} from './${entry}/TEMPLATE.md';`);
|
|
56
|
-
names.push(identifier);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
catch (_err) {
|
|
61
|
-
// Skip entries that can't be read
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (names.length === 0) {
|
|
66
|
-
console.warn(`No TEMPLATE.md files found in subdirectories of ${dirPath}`);
|
|
67
|
-
}
|
|
68
|
-
// Generate code that imports all templates and exports as array
|
|
69
|
-
const code = [
|
|
70
|
-
...imports,
|
|
71
|
-
'',
|
|
72
|
-
`export default [${names.join(', ')}];`
|
|
73
|
-
].join('\n');
|
|
74
|
-
return {
|
|
75
|
-
data: null,
|
|
76
|
-
code
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
//# sourceMappingURL=template-collection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template-collection.js","sourceRoot":"","sources":["../../../src/presets/template-collection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,qCAA4D;AAC5D,0DAA6B;AAG7B;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,6BAA6B,GAAsB;IAC5D,OAAO,EAAE,sBAAsB;IAC/B,OAAO,EAAE,IAAI;IACb,SAAS,EAAE,CAAC,QAAgB,EAAE,QAAgB,EAAE,EAAE;QAC9C,kEAAkE;QAClE,MAAM,gBAAgB,GAAG,QAAQ,CAAC,OAAO,CAAC,cAAc,EAAE,E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AAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,mDAAmD,OAAO,EAAE,CAAC,CAAC;QAC/E,CAAC;QAED,gEAAgE;QAChE,MAAM,IAAI,GAAG;YACT,GAAG,OAAO;YACV,EAAE;YACF,mBAAmB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;SAC1C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEb,OAAO;YACH,IAAI,EAAE,IAAI;YACV,IAAI;SACP,CAAC;IACN,CAAC;CACJ,CAAC"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Template transformer preset for markdown files with frontmatter
|
|
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.templateTransformer = exports.RenderingTemplateDefinitionSchema = void 0;
|
|
10
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
-
const zod_1 = require("zod");
|
|
12
|
-
const frontmatter_js_1 = require("../parsers/frontmatter.js");
|
|
13
|
-
const template_asset_discovery_js_1 = require("../utils/template-asset-discovery.js");
|
|
14
|
-
/**
|
|
15
|
-
* Zod schema for template frontmatter validation.
|
|
16
|
-
* Only includes fields authored by the user.
|
|
17
|
-
* The name and id are inferred from the directory structure.
|
|
18
|
-
*/
|
|
19
|
-
const TemplateFrontmatterSchema = zod_1.z.object({
|
|
20
|
-
title: zod_1.z.string().optional(),
|
|
21
|
-
description: zod_1.z.string().min(1, 'Template description is required'),
|
|
22
|
-
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
23
|
-
type: zod_1.z.enum(['presentation', 'document']),
|
|
24
|
-
}).strict();
|
|
25
|
-
/**
|
|
26
|
-
* MUST be kept in sync with @vertesia/tools-sdk RenderingTemplateDefinition
|
|
27
|
-
* Zod schema for template definition
|
|
28
|
-
*/
|
|
29
|
-
exports.RenderingTemplateDefinitionSchema = zod_1.z.object({
|
|
30
|
-
id: zod_1.z.string().min(1, 'Template id is required'),
|
|
31
|
-
name: zod_1.z.string().min(1, 'Template name is required'),
|
|
32
|
-
title: zod_1.z.string().optional(),
|
|
33
|
-
description: zod_1.z.string().min(1, 'Template description is required'),
|
|
34
|
-
instructions: zod_1.z.string(),
|
|
35
|
-
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
36
|
-
type: zod_1.z.enum(['presentation', 'document']),
|
|
37
|
-
assets: zod_1.z.array(zod_1.z.string()),
|
|
38
|
-
}).passthrough();
|
|
39
|
-
/**
|
|
40
|
-
* Derive the template path segments from the file path.
|
|
41
|
-
*
|
|
42
|
-
* Example: .../templates/examples/report/TEMPLATE.md
|
|
43
|
-
* → category: "examples", name: "report", relative: "examples/report"
|
|
44
|
-
*/
|
|
45
|
-
function deriveTemplatePathInfo(filePath) {
|
|
46
|
-
const templateDir = node_path_1.default.dirname(filePath);
|
|
47
|
-
const templateName = node_path_1.default.basename(templateDir);
|
|
48
|
-
const collectionDir = node_path_1.default.dirname(templateDir);
|
|
49
|
-
const category = node_path_1.default.basename(collectionDir);
|
|
50
|
-
return { category, templateName, relative: `${category}/${templateName}` };
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Template transformer preset
|
|
54
|
-
* Transforms markdown files with ?template suffix OR TEMPLATE.md files into template definition objects
|
|
55
|
-
*
|
|
56
|
-
* Matches:
|
|
57
|
-
* - Files with ?template suffix: ./my-template.md?template
|
|
58
|
-
* - TEMPLATE.md files: ./my-template/TEMPLATE.md
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```typescript
|
|
62
|
-
* import template1 from './my-template.md?template';
|
|
63
|
-
* import template2 from './my-template/TEMPLATE.md';
|
|
64
|
-
* // Both are RenderingTemplateDefinition objects
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
exports.templateTransformer = {
|
|
68
|
-
pattern: /(\.md\?template$|\/TEMPLATE\.md$)/,
|
|
69
|
-
schema: exports.RenderingTemplateDefinitionSchema,
|
|
70
|
-
transform: (content, filePath) => {
|
|
71
|
-
const { frontmatter, content: markdown } = (0, frontmatter_js_1.parseFrontmatter)(content);
|
|
72
|
-
// Validate frontmatter
|
|
73
|
-
const frontmatterValidation = TemplateFrontmatterSchema.safeParse(frontmatter);
|
|
74
|
-
if (!frontmatterValidation.success) {
|
|
75
|
-
const errors = frontmatterValidation.error.errors
|
|
76
|
-
.map((err) => {
|
|
77
|
-
const pathStr = err.path.length > 0 ? err.path.join('.') : 'frontmatter';
|
|
78
|
-
return ` - ${pathStr}: ${err.message}`;
|
|
79
|
-
})
|
|
80
|
-
.join('\n');
|
|
81
|
-
throw new Error(`Invalid frontmatter in ${filePath}:\n${errors}`);
|
|
82
|
-
}
|
|
83
|
-
// Derive template path from directory structure
|
|
84
|
-
const { category, templateName, relative: templatePath } = deriveTemplatePathInfo(filePath);
|
|
85
|
-
// Discover asset files in the template directory
|
|
86
|
-
const assets = (0, template_asset_discovery_js_1.discoverTemplateAssets)(filePath, templatePath);
|
|
87
|
-
// Build template definition
|
|
88
|
-
// Assets use absolute paths for direct server-side resolution
|
|
89
|
-
const templateData = {
|
|
90
|
-
id: `${category}:${templateName}`,
|
|
91
|
-
name: templateName,
|
|
92
|
-
title: frontmatter.title,
|
|
93
|
-
description: frontmatter.description,
|
|
94
|
-
instructions: markdown,
|
|
95
|
-
tags: frontmatter.tags,
|
|
96
|
-
type: frontmatter.type,
|
|
97
|
-
assets: assets.fileNames.map(f => `/templates/${templatePath}/${f}`),
|
|
98
|
-
};
|
|
99
|
-
return {
|
|
100
|
-
data: templateData,
|
|
101
|
-
assets: assets.assetFiles,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
//# sourceMappingURL=template.js.map
|
|
@@ -1 +0,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C5C,CAAC,CAAC;iBACD,IAAI,CAAC,IAAI,CAAC,CAAC;YAChB,MAAM,IAAI,KAAK,CACX,0BAA0B,QAAQ,MAAM,MAAM,EAAE,CACnD,CAAC;QACN,CAAC;QAED,gDAAgD;QAChD,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAC;QAE5F,iDAAiD;QACjD,MAAM,MAAM,GAAG,IAAA,oDAAsB,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAE9D,4BAA4B;QAC5B,8DAA8D;QAC9D,MAAM,YAAY,GAAgC;YAC9C,EAAE,EAAE,GAAG,QAAQ,IAAI,YAAY,EAAE;YACjC,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,WAAW,EAAE,WAAW,CAAC,WAAW;YACpC,YAAY,EAAE,QAAQ;YACtB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,YAAY,IAAI,CAAC,EAAE,CAAC;SACvE,CAAC;QAEF,OAAO;YACH,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE,MAAM,CAAC,UAAU;SAC5B,CAAC;IACN,CAAC;CACJ,CAAC"}
|
package/lib/cjs/types.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,100 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,CAAC;AACvC,CAAC;AAED;;GAEG;AACH,SAAS,YAAY,CAAC,QAAgB;IAClC,OAAO,QAAQ,CAAC,IAAI,CAAC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