@vertesia/build-tools 1.0.0-dev.20260203.130115Z → 1.0.0-dev.20260227.104700Z
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 +39 -0
- package/lib/build-tools.js +2020 -0
- package/lib/build-tools.js.map +1 -0
- package/lib/cjs/index.js +43 -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 +25 -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 +272 -0
- package/lib/cjs/presets/skill.js.map +1 -0
- package/lib/cjs/presets/template-collection.js +80 -0
- package/lib/cjs/presets/template-collection.js.map +1 -0
- package/lib/cjs/presets/template.js +105 -0
- package/lib/cjs/presets/template.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/template-asset-discovery.js +63 -0
- package/lib/cjs/utils/template-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 +10 -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 +266 -0
- package/lib/esm/presets/skill.js.map +1 -0
- package/lib/esm/presets/template-collection.js +74 -0
- package/lib/esm/presets/template-collection.js.map +1 -0
- package/lib/esm/presets/template.js +99 -0
- package/lib/esm/presets/template.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/template-asset-discovery.js +57 -0
- package/lib/esm/utils/template-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 +10 -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 +361 -0
- package/lib/types/presets/skill.d.ts.map +1 -0
- package/lib/types/presets/template-collection.d.ts +25 -0
- package/lib/types/presets/template-collection.d.ts.map +1 -0
- package/lib/types/presets/template.d.ts +58 -0
- package/lib/types/presets/template.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/template-asset-discovery.d.ts +23 -0
- package/lib/types/utils/template-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 +6 -6
- package/src/index.ts +5 -0
- package/src/presets/index.ts +3 -1
- package/src/presets/skill.ts +51 -3
- package/src/presets/template-collection.ts +83 -0
- package/src/presets/template.ts +116 -0
- package/src/types.ts +1 -1
- package/src/utils/template-asset-discovery.ts +77 -0
|
@@ -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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,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC;gBACrC,IAAI,EAAE,QAAQ;aACjB,CAAC,CAAC;QACP,CAAC;aAAM,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,qBAAqB;YACrB,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACzB,cAAc,CAAC,IAAI,CAAC;gBAChB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;aACjB,CAAC,CAAC;YAEH,qDAAqD;YACrD,iEAAiE;QACrE,CAAC;IACL,CAAC;IAED,OAAO;QACH,OAAO;QACP,OAAO;QACP,cAAc;QACd,UAAU;KACb,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utilities for discovering asset files in template 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.discoverTemplateAssets = discoverTemplateAssets;
|
|
10
|
+
const node_fs_1 = require("node:fs");
|
|
11
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
/**
|
|
13
|
+
* Files to exclude from template asset discovery
|
|
14
|
+
* (source files and the template definition itself)
|
|
15
|
+
*/
|
|
16
|
+
const EXCLUDED_PATTERNS = [
|
|
17
|
+
/^TEMPLATE\.md$/,
|
|
18
|
+
/\.ts$/,
|
|
19
|
+
/\.js$/,
|
|
20
|
+
];
|
|
21
|
+
function isExcluded(fileName) {
|
|
22
|
+
return EXCLUDED_PATTERNS.some(p => p.test(fileName));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Discover asset files in a template directory.
|
|
26
|
+
* All files except TEMPLATE.md, *.ts, and *.js are considered assets.
|
|
27
|
+
*
|
|
28
|
+
* @param templateFilePath - Absolute path to the TEMPLATE.md file
|
|
29
|
+
* @param templatePath - The template path segment (e.g., "examples/report")
|
|
30
|
+
* @returns Discovered assets and metadata
|
|
31
|
+
*/
|
|
32
|
+
function discoverTemplateAssets(templateFilePath, templatePath) {
|
|
33
|
+
const templateDir = node_path_1.default.dirname(templateFilePath);
|
|
34
|
+
const fileNames = [];
|
|
35
|
+
const assetFiles = [];
|
|
36
|
+
let files;
|
|
37
|
+
try {
|
|
38
|
+
files = (0, node_fs_1.readdirSync)(templateDir).filter(file => {
|
|
39
|
+
try {
|
|
40
|
+
return (0, node_fs_1.statSync)(node_path_1.default.join(templateDir, file)).isFile();
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
files = [];
|
|
49
|
+
}
|
|
50
|
+
for (const file of files) {
|
|
51
|
+
if (isExcluded(file)) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
fileNames.push(file);
|
|
55
|
+
assetFiles.push({
|
|
56
|
+
sourcePath: node_path_1.default.join(templateDir, file),
|
|
57
|
+
destPath: node_path_1.default.join('templates', templatePath, file),
|
|
58
|
+
type: 'template',
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return { fileNames, assetFiles };
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=template-asset-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-asset-discovery.js","sourceRoot":"","sources":["../../../src/utils/template-asset-discovery.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;AAuCH,wDAmCC;AAxED,qCAAgD;AAChD,0DAA6B;AAc7B;;;GAGG;AACH,MAAM,iBAAiB,GAAG;IACtB,gBAAgB;IAChB,OAAO;IACP,OAAO;CACV,CAAC;AAEF,SAAS,UAAU,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-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-compiler.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BH,wCAqEC;AA7FD,mCAAiE;AACjE,0DAA6B;AAI7B;;GAEG;AACH,MAAM,iBAAiB,GAAG;IACtB,OAAO;IACP,WAAW;IACX,mBAAmB;IACnB,uBAAuB;IACvB,kBAAkB;CACrB,CAAC;AAEF;;;;;;;GAOG;A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ChC,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, templateTransformer, templateCollectionTransformer, promptTransformer, SkillDefinitionSchema, SkillPropertiesSchema, RenderingTemplateDefinitionSchema, 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,mBAAmB,EACnB,6BAA6B,EAC7B,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,EACrB,iCAAiC,EACjC,sBAAsB,EAMtB,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"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Rollup plugin implementation for transforming imports
|
|
3
|
+
*/
|
|
4
|
+
import { readFileSync } from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { copyAssets } from './utils/asset-copy.js';
|
|
7
|
+
import { compileWidgets } from './utils/widget-compiler.js';
|
|
8
|
+
/**
|
|
9
|
+
* Creates a Rollup plugin that transforms imports based on configured rules
|
|
10
|
+
*/
|
|
11
|
+
export function vertesiaImportPlugin(config) {
|
|
12
|
+
const { transformers, assetsDir = './dist', widgetConfig } = config;
|
|
13
|
+
if (!transformers || transformers.length === 0) {
|
|
14
|
+
throw new Error('vertesiaImportPlugin: At least one transformer must be configured');
|
|
15
|
+
}
|
|
16
|
+
// Track assets to copy and widgets to compile
|
|
17
|
+
const assetsToProcess = [];
|
|
18
|
+
const widgetsToCompile = [];
|
|
19
|
+
const shouldCopyAssets = assetsDir !== false;
|
|
20
|
+
const shouldCompileWidgets = widgetConfig !== undefined && assetsDir !== false;
|
|
21
|
+
return {
|
|
22
|
+
name: 'vertesia-import-plugin',
|
|
23
|
+
/**
|
|
24
|
+
* Resolve import IDs to handle pattern-based imports
|
|
25
|
+
*/
|
|
26
|
+
resolveId(source, importer) {
|
|
27
|
+
// Check if any transformer pattern matches
|
|
28
|
+
for (const transformer of transformers) {
|
|
29
|
+
if (transformer.pattern.test(source)) {
|
|
30
|
+
// Handle relative imports
|
|
31
|
+
if (source.startsWith('.') && importer) {
|
|
32
|
+
const cleanSource = source.replace(transformer.pattern, '');
|
|
33
|
+
// Strip query parameters from importer to get the file path
|
|
34
|
+
const cleanImporter = importer.indexOf('?') >= 0
|
|
35
|
+
? importer.substring(0, importer.indexOf('?'))
|
|
36
|
+
: importer;
|
|
37
|
+
// Always use dirname to get the directory containing the importer
|
|
38
|
+
const baseDir = path.dirname(cleanImporter);
|
|
39
|
+
const resolved = path.resolve(baseDir, cleanSource);
|
|
40
|
+
// Return with the pattern suffix to identify it in load
|
|
41
|
+
const suffix = source.match(transformer.pattern)?.[0] || '';
|
|
42
|
+
return resolved + suffix;
|
|
43
|
+
}
|
|
44
|
+
return source;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return null; // Let other plugins handle it
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
50
|
+
* Load and transform the file content
|
|
51
|
+
*/
|
|
52
|
+
async load(id) {
|
|
53
|
+
// Find matching transformer
|
|
54
|
+
let matchedTransformer;
|
|
55
|
+
let cleanId = id;
|
|
56
|
+
for (const transformer of transformers) {
|
|
57
|
+
if (transformer.pattern.test(id)) {
|
|
58
|
+
matchedTransformer = transformer;
|
|
59
|
+
// Remove query parameters to get actual file path
|
|
60
|
+
// For example: '/path/file.md?skill' -> '/path/file.md'
|
|
61
|
+
// '/path/file.html?raw' -> '/path/file.html'
|
|
62
|
+
const queryIndex = id.indexOf('?');
|
|
63
|
+
cleanId = queryIndex >= 0 ? id.substring(0, queryIndex) : id;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (!matchedTransformer) {
|
|
68
|
+
return null; // Not for us
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
// Read file content (skip for virtual transforms)
|
|
72
|
+
const content = matchedTransformer.virtual
|
|
73
|
+
? ''
|
|
74
|
+
: readFileSync(cleanId, 'utf-8');
|
|
75
|
+
// Transform the content
|
|
76
|
+
const result = await matchedTransformer.transform(content, cleanId);
|
|
77
|
+
// Collect assets if any
|
|
78
|
+
if (result.assets && shouldCopyAssets) {
|
|
79
|
+
assetsToProcess.push(...result.assets);
|
|
80
|
+
}
|
|
81
|
+
// Collect widgets if any
|
|
82
|
+
if (result.widgets && shouldCompileWidgets) {
|
|
83
|
+
widgetsToCompile.push(...result.widgets);
|
|
84
|
+
}
|
|
85
|
+
// Validate if schema provided
|
|
86
|
+
if (matchedTransformer.schema) {
|
|
87
|
+
const validation = matchedTransformer.schema.safeParse(result.data);
|
|
88
|
+
if (!validation.success) {
|
|
89
|
+
const errors = validation.error.errors
|
|
90
|
+
.map((err) => ` - ${err.path.join('.')}: ${err.message}`)
|
|
91
|
+
.join('\n');
|
|
92
|
+
throw new Error(`Validation failed for ${id}:\n${errors}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Generate code
|
|
96
|
+
const imports = result.imports ? result.imports.join('\n') + '\n\n' : '';
|
|
97
|
+
if (result.code) {
|
|
98
|
+
// Custom code provided - prepend imports
|
|
99
|
+
return imports + result.code;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
// Default: export data (escape if string, otherwise stringify as JSON)
|
|
103
|
+
const dataJson = JSON.stringify(result.data, null, 2);
|
|
104
|
+
return `${imports}export default ${dataJson};`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
109
|
+
this.error(`Failed to transform ${id}: ${message}`);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* Copy assets and compile widgets after all modules are loaded
|
|
114
|
+
*/
|
|
115
|
+
async buildEnd() {
|
|
116
|
+
// Copy script assets
|
|
117
|
+
if (shouldCopyAssets && assetsToProcess.length > 0) {
|
|
118
|
+
try {
|
|
119
|
+
const copied = copyAssets(assetsToProcess, assetsDir);
|
|
120
|
+
console.log(`Copied ${copied} asset file(s) to ${assetsDir}`);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
124
|
+
this.warn(`Failed to copy assets: ${message}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Compile widgets
|
|
128
|
+
if (shouldCompileWidgets && widgetsToCompile.length > 0) {
|
|
129
|
+
try {
|
|
130
|
+
const widgetsDir = config.widgetsDir || 'widgets';
|
|
131
|
+
const outputDir = path.join(assetsDir, widgetsDir);
|
|
132
|
+
console.log(`Compiling ${widgetsToCompile.length} widget(s)...`);
|
|
133
|
+
const compiled = await compileWidgets(widgetsToCompile, outputDir, widgetConfig);
|
|
134
|
+
console.log(`Compiled ${compiled} widget(s) to ${outputDir}`);
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
138
|
+
this.error(`Failed to compile widgets: ${message}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAoB;IACrD,MAAM,EAAE,YAAY,EAAE,SAAS,GAAG,QAAQ,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IAEpE,IAAI,CAAC,YAAY,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;IACzF,CAAC;IAED,8CA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K,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBACvE,IAAI,CAAC,KAAK,CAAC,8BAA8B,OAAO,EAAE,CAAC,CAAC;gBACxD,CAAC;YACL,CAAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preset transformers for common use cases
|
|
3
|
+
*/
|
|
4
|
+
export { skillTransformer, SkillDefinitionSchema, SkillPropertiesSchema } from './skill.js';
|
|
5
|
+
export { skillCollectionTransformer } from './skill-collection.js';
|
|
6
|
+
export { templateTransformer, RenderingTemplateDefinitionSchema } from './template.js';
|
|
7
|
+
export { templateCollectionTransformer } from './template-collection.js';
|
|
8
|
+
export { rawTransformer } from './raw.js';
|
|
9
|
+
export { promptTransformer, PromptDefinitionSchema, PromptRole, TemplateType } from './prompt.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/presets/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,qBAAqB,EAA+C,MAAM,YAAY,CAAC;AACzI,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,iCAAiC,EAAoC,MAAM,eAAe,CAAC;AACzH,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAiD,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompt transformer preset for template files with frontmatter
|
|
3
|
+
* Supports .jst, .hbs, and plain text files
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { parseFrontmatter } from '../parsers/frontmatter.js';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { TemplateType } from '@vertesia/common';
|
|
9
|
+
import { PromptRole } from '@llumiverse/common';
|
|
10
|
+
/**
|
|
11
|
+
* Re-export types for backwards compatibility
|
|
12
|
+
*/
|
|
13
|
+
export { TemplateType, PromptRole };
|
|
14
|
+
/**
|
|
15
|
+
* Zod schema for prompt frontmatter validation
|
|
16
|
+
*/
|
|
17
|
+
const PromptFrontmatterSchema = z.object({
|
|
18
|
+
// Required fields
|
|
19
|
+
role: z.nativeEnum(PromptRole, {
|
|
20
|
+
errorMap: () => ({ message: 'Role must be one of: safety, system, user, assistant, negative' })
|
|
21
|
+
}),
|
|
22
|
+
// Optional fields
|
|
23
|
+
content_type: z.nativeEnum(TemplateType).optional(),
|
|
24
|
+
schema: z.string().optional(),
|
|
25
|
+
name: z.string().optional(),
|
|
26
|
+
externalId: z.string().optional(),
|
|
27
|
+
}).strict();
|
|
28
|
+
/**
|
|
29
|
+
* MUST be kept in sync with @vertesia/common InCodePrompt
|
|
30
|
+
* Zod schema for prompt definition
|
|
31
|
+
*/
|
|
32
|
+
export const PromptDefinitionSchema = z.object({
|
|
33
|
+
role: z.nativeEnum(PromptRole),
|
|
34
|
+
content: z.string(),
|
|
35
|
+
content_type: z.nativeEnum(TemplateType),
|
|
36
|
+
schema: z.any().optional(),
|
|
37
|
+
name: z.string().optional(),
|
|
38
|
+
externalId: z.string().optional(),
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* Normalize schema path for import
|
|
42
|
+
* - Adds './' prefix if not a relative path
|
|
43
|
+
* - Replaces .ts with .js
|
|
44
|
+
* - Adds .js if no extension
|
|
45
|
+
*
|
|
46
|
+
* @param schemaPath - Original schema path from frontmatter
|
|
47
|
+
* @returns Normalized path for ES module import
|
|
48
|
+
*/
|
|
49
|
+
function normalizeSchemaPath(schemaPath) {
|
|
50
|
+
let normalized = schemaPath.trim();
|
|
51
|
+
// Add './' prefix if not already a relative path
|
|
52
|
+
if (!normalized.startsWith('.')) {
|
|
53
|
+
normalized = './' + normalized;
|
|
54
|
+
}
|
|
55
|
+
// Get the extension
|
|
56
|
+
const ext = path.extname(normalized);
|
|
57
|
+
if (ext === '.ts') {
|
|
58
|
+
// Replace .ts with .js
|
|
59
|
+
normalized = normalized.slice(0, -3) + '.js';
|
|
60
|
+
}
|
|
61
|
+
else if (!ext) {
|
|
62
|
+
// No extension, add .js
|
|
63
|
+
normalized = normalized + '.js';
|
|
64
|
+
}
|
|
65
|
+
// If extension is already .js or something else, leave as is
|
|
66
|
+
return normalized;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Infer content type from file extension
|
|
70
|
+
*
|
|
71
|
+
* @param filePath - Path to the prompt file
|
|
72
|
+
* @returns Inferred content type
|
|
73
|
+
*/
|
|
74
|
+
function inferContentType(filePath) {
|
|
75
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
76
|
+
switch (ext) {
|
|
77
|
+
case '.jst':
|
|
78
|
+
return TemplateType.jst;
|
|
79
|
+
case '.hbs':
|
|
80
|
+
return TemplateType.handlebars;
|
|
81
|
+
default:
|
|
82
|
+
return TemplateType.text;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Build a PromptDefinition from frontmatter and content
|
|
87
|
+
*
|
|
88
|
+
* @param frontmatter - Parsed frontmatter object
|
|
89
|
+
* @param content - Prompt content (body of the file)
|
|
90
|
+
* @param filePath - Path to the prompt file (for content type inference)
|
|
91
|
+
* @returns Prompt definition object and optional imports
|
|
92
|
+
*/
|
|
93
|
+
function buildPromptDefinition(frontmatter, content, filePath) {
|
|
94
|
+
// Determine content type from frontmatter or file extension
|
|
95
|
+
const content_type = frontmatter.content_type || inferContentType(filePath);
|
|
96
|
+
const prompt = {
|
|
97
|
+
role: frontmatter.role,
|
|
98
|
+
content,
|
|
99
|
+
content_type,
|
|
100
|
+
};
|
|
101
|
+
// Add optional fields
|
|
102
|
+
if (frontmatter.name) {
|
|
103
|
+
prompt.name = frontmatter.name;
|
|
104
|
+
}
|
|
105
|
+
if (frontmatter.externalId) {
|
|
106
|
+
prompt.externalId = frontmatter.externalId;
|
|
107
|
+
}
|
|
108
|
+
// Handle schema import if specified
|
|
109
|
+
let imports;
|
|
110
|
+
let schemaImportName;
|
|
111
|
+
if (frontmatter.schema) {
|
|
112
|
+
const normalizedPath = normalizeSchemaPath(frontmatter.schema);
|
|
113
|
+
schemaImportName = '__promptSchema';
|
|
114
|
+
imports = [`import ${schemaImportName} from '${normalizedPath}';`];
|
|
115
|
+
}
|
|
116
|
+
return { prompt, imports, schemaImportName };
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Prompt transformer preset
|
|
120
|
+
* Transforms template files with ?prompt suffix into prompt definition objects
|
|
121
|
+
*
|
|
122
|
+
* Supported file types:
|
|
123
|
+
* - .jst (JavaScript template literals) → content_type: 'jst'
|
|
124
|
+
* - .hbs (Handlebars templates) → content_type: 'handlebars'
|
|
125
|
+
* - .txt or other → content_type: 'text'
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* import PROMPT from './prompt.hbs?prompt';
|
|
130
|
+
* // PROMPT is an InCodePrompt object
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export const promptTransformer = {
|
|
134
|
+
pattern: /\?prompt$/,
|
|
135
|
+
schema: PromptDefinitionSchema,
|
|
136
|
+
transform: (content, filePath) => {
|
|
137
|
+
const { frontmatter, content: promptContent } = parseFrontmatter(content);
|
|
138
|
+
// Validate frontmatter
|
|
139
|
+
const frontmatterValidation = PromptFrontmatterSchema.safeParse(frontmatter);
|
|
140
|
+
if (!frontmatterValidation.success) {
|
|
141
|
+
const errors = frontmatterValidation.error.errors
|
|
142
|
+
.map((err) => {
|
|
143
|
+
const path = err.path.length > 0 ? err.path.join('.') : 'frontmatter';
|
|
144
|
+
return ` - ${path}: ${err.message}`;
|
|
145
|
+
})
|
|
146
|
+
.join('\n');
|
|
147
|
+
throw new Error(`Invalid frontmatter in ${filePath}:\n${errors}`);
|
|
148
|
+
}
|
|
149
|
+
// Build prompt definition
|
|
150
|
+
const { prompt, imports, schemaImportName } = buildPromptDefinition(frontmatter, promptContent, filePath);
|
|
151
|
+
// If schema is specified, generate custom code with schema reference
|
|
152
|
+
if (schemaImportName) {
|
|
153
|
+
// Build the code manually to avoid JSON.stringify issues with schema reference
|
|
154
|
+
const lines = [
|
|
155
|
+
'export default {',
|
|
156
|
+
` role: "${prompt.role}",`,
|
|
157
|
+
` content: ${JSON.stringify(prompt.content)},`,
|
|
158
|
+
` content_type: "${prompt.content_type}",`,
|
|
159
|
+
` schema: ${schemaImportName}`,
|
|
160
|
+
];
|
|
161
|
+
if (prompt.name) {
|
|
162
|
+
lines.splice(4, 0, ` name: ${JSON.stringify(prompt.name)},`);
|
|
163
|
+
}
|
|
164
|
+
if (prompt.externalId) {
|
|
165
|
+
lines.splice(4, 0, ` externalId: ${JSON.stringify(prompt.externalId)},`);
|
|
166
|
+
}
|
|
167
|
+
lines.push('};');
|
|
168
|
+
const code = lines.join('\n');
|
|
169
|
+
return {
|
|
170
|
+
data: prompt,
|
|
171
|
+
imports,
|
|
172
|
+
code,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
// Standard case without schema
|
|
176
|
+
return {
|
|
177
|
+
data: prompt,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/presets/prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC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ACN,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Raw transformer preset for importing file content as strings
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Raw transformer preset
|
|
6
|
+
* Transforms any file with ?raw suffix into a string export
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import template from './template.html?raw';
|
|
11
|
+
* // template is a string containing the file content
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export const rawTransformer = {
|
|
15
|
+
pattern: /\?raw$/,
|
|
16
|
+
transform: (content) => {
|
|
17
|
+
return {
|
|
18
|
+
data: content
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=raw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw.js","sourceRoot":"","sources":["../../../src/presets/raw.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,cAAc,GAAsB;IAC7C,OAAO,EAAE,QAAQ;IACjB,SAAS,EAAE,CAAC,OAAe,EAAE,EAAE;QAC3B,OAAO;YACH,IAAI,EAAE,OAAO;SAChB,CAAC;IACN,CAAC;CACJ,CAAC"}
|