@vertesia/build-tools 1.0.0-dev.20260225.024852Z → 1.0.0-dev.20260227.112605Z
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/lib/build-tools.js +223 -1
- package/lib/build-tools.js.map +1 -1
- package/lib/cjs/index.js +4 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/presets/index.js +6 -1
- package/lib/cjs/presets/index.js.map +1 -1
- 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/utils/template-asset-discovery.js +63 -0
- package/lib/cjs/utils/template-asset-discovery.js.map +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/presets/index.js +2 -0
- package/lib/esm/presets/index.js.map +1 -1
- 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/utils/template-asset-discovery.js +57 -0
- package/lib/esm/utils/template-asset-discovery.js.map +1 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/presets/index.d.ts +2 -0
- package/lib/types/presets/index.d.ts.map +1 -1
- package/lib/types/presets/skill.d.ts +12 -12
- 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 +1 -1
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/utils/template-asset-discovery.d.ts +23 -0
- package/lib/types/utils/template-asset-discovery.d.ts.map +1 -0
- package/package.json +6 -6
- package/src/index.ts +4 -0
- package/src/presets/index.ts +2 -0
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presets/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzI,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/presets/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzI,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,iCAAiC,EAAE,KAAK,2BAA2B,EAAE,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,EAAE,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -55,14 +55,14 @@ export declare const SkillDefinitionSchema: z.ZodObject<{
|
|
|
55
55
|
template: z.ZodOptional<z.ZodString>;
|
|
56
56
|
}, "strip", z.ZodTypeAny, {
|
|
57
57
|
language: string;
|
|
58
|
+
template?: string | undefined;
|
|
58
59
|
packages?: string[] | undefined;
|
|
59
60
|
system_packages?: string[] | undefined;
|
|
60
|
-
template?: string | undefined;
|
|
61
61
|
}, {
|
|
62
62
|
language: string;
|
|
63
|
+
template?: string | undefined;
|
|
63
64
|
packages?: string[] | undefined;
|
|
64
65
|
system_packages?: string[] | undefined;
|
|
65
|
-
template?: string | undefined;
|
|
66
66
|
}>>;
|
|
67
67
|
related_tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
68
68
|
scripts: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -106,14 +106,14 @@ export declare const SkillDefinitionSchema: z.ZodObject<{
|
|
|
106
106
|
template: z.ZodOptional<z.ZodString>;
|
|
107
107
|
}, "strip", z.ZodTypeAny, {
|
|
108
108
|
language: string;
|
|
109
|
+
template?: string | undefined;
|
|
109
110
|
packages?: string[] | undefined;
|
|
110
111
|
system_packages?: string[] | undefined;
|
|
111
|
-
template?: string | undefined;
|
|
112
112
|
}, {
|
|
113
113
|
language: string;
|
|
114
|
+
template?: string | undefined;
|
|
114
115
|
packages?: string[] | undefined;
|
|
115
116
|
system_packages?: string[] | undefined;
|
|
116
|
-
template?: string | undefined;
|
|
117
117
|
}>>;
|
|
118
118
|
related_tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
119
119
|
scripts: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -157,14 +157,14 @@ export declare const SkillDefinitionSchema: z.ZodObject<{
|
|
|
157
157
|
template: z.ZodOptional<z.ZodString>;
|
|
158
158
|
}, "strip", z.ZodTypeAny, {
|
|
159
159
|
language: string;
|
|
160
|
+
template?: string | undefined;
|
|
160
161
|
packages?: string[] | undefined;
|
|
161
162
|
system_packages?: string[] | undefined;
|
|
162
|
-
template?: string | undefined;
|
|
163
163
|
}, {
|
|
164
164
|
language: string;
|
|
165
|
+
template?: string | undefined;
|
|
165
166
|
packages?: string[] | undefined;
|
|
166
167
|
system_packages?: string[] | undefined;
|
|
167
|
-
template?: string | undefined;
|
|
168
168
|
}>>;
|
|
169
169
|
related_tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
170
170
|
scripts: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -217,14 +217,14 @@ export declare const SkillPropertiesSchema: z.ZodObject<{
|
|
|
217
217
|
template: z.ZodOptional<z.ZodString>;
|
|
218
218
|
}, "strip", z.ZodTypeAny, {
|
|
219
219
|
language: string;
|
|
220
|
+
template?: string | undefined;
|
|
220
221
|
packages?: string[] | undefined;
|
|
221
222
|
system_packages?: string[] | undefined;
|
|
222
|
-
template?: string | undefined;
|
|
223
223
|
}, {
|
|
224
224
|
language: string;
|
|
225
|
+
template?: string | undefined;
|
|
225
226
|
packages?: string[] | undefined;
|
|
226
227
|
system_packages?: string[] | undefined;
|
|
227
|
-
template?: string | undefined;
|
|
228
228
|
}>>>;
|
|
229
229
|
related_tools: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
230
230
|
scripts: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
@@ -268,14 +268,14 @@ export declare const SkillPropertiesSchema: z.ZodObject<{
|
|
|
268
268
|
template: z.ZodOptional<z.ZodString>;
|
|
269
269
|
}, "strip", z.ZodTypeAny, {
|
|
270
270
|
language: string;
|
|
271
|
+
template?: string | undefined;
|
|
271
272
|
packages?: string[] | undefined;
|
|
272
273
|
system_packages?: string[] | undefined;
|
|
273
|
-
template?: string | undefined;
|
|
274
274
|
}, {
|
|
275
275
|
language: string;
|
|
276
|
+
template?: string | undefined;
|
|
276
277
|
packages?: string[] | undefined;
|
|
277
278
|
system_packages?: string[] | undefined;
|
|
278
|
-
template?: string | undefined;
|
|
279
279
|
}>>>;
|
|
280
280
|
related_tools: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
281
281
|
scripts: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
@@ -319,14 +319,14 @@ export declare const SkillPropertiesSchema: z.ZodObject<{
|
|
|
319
319
|
template: z.ZodOptional<z.ZodString>;
|
|
320
320
|
}, "strip", z.ZodTypeAny, {
|
|
321
321
|
language: string;
|
|
322
|
+
template?: string | undefined;
|
|
322
323
|
packages?: string[] | undefined;
|
|
323
324
|
system_packages?: string[] | undefined;
|
|
324
|
-
template?: string | undefined;
|
|
325
325
|
}, {
|
|
326
326
|
language: string;
|
|
327
|
+
template?: string | undefined;
|
|
327
328
|
packages?: string[] | undefined;
|
|
328
329
|
system_packages?: string[] | undefined;
|
|
329
|
-
template?: string | undefined;
|
|
330
330
|
}>>>;
|
|
331
331
|
related_tools: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
332
332
|
scripts: z.ZodOptional<z.ZodOptional<z.ZodArray<z.ZodString, "many">>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template collection transformer for directory-based template imports
|
|
3
|
+
* Scans a directory for subdirectories containing TEMPLATE.md files
|
|
4
|
+
*/
|
|
5
|
+
import type { TransformerPreset } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Template collection transformer preset
|
|
8
|
+
* Transforms directory imports with ?templates suffix into an array of template imports
|
|
9
|
+
*
|
|
10
|
+
* Matches:
|
|
11
|
+
* - ./all?templates (recommended - generates all.js in the directory)
|
|
12
|
+
* - Any path ending with a filename and ?templates
|
|
13
|
+
*
|
|
14
|
+
* NOTE: A filename before ?templates is REQUIRED to avoid naming conflicts.
|
|
15
|
+
* The filename becomes the output module name.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import templates from './all?templates';
|
|
20
|
+
* // Scans current directory for subdirectories with TEMPLATE.md
|
|
21
|
+
* // Generates all.js containing array of all templates
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const templateCollectionTransformer: TransformerPreset;
|
|
25
|
+
//# sourceMappingURL=template-collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-collection.d.ts","sourceRoot":"","sources":["../../../src/presets/template-collection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,6BAA6B,EAAE,iBAuD3C,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template transformer preset for markdown files with frontmatter
|
|
3
|
+
*/
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import type { TransformerPreset } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* MUST be kept in sync with @vertesia/tools-sdk RenderingTemplateDefinition
|
|
8
|
+
* Zod schema for template definition
|
|
9
|
+
*/
|
|
10
|
+
export declare const RenderingTemplateDefinitionSchema: z.ZodObject<{
|
|
11
|
+
id: z.ZodString;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
title: z.ZodOptional<z.ZodString>;
|
|
14
|
+
description: z.ZodString;
|
|
15
|
+
instructions: z.ZodString;
|
|
16
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
17
|
+
type: z.ZodEnum<["presentation", "document"]>;
|
|
18
|
+
assets: z.ZodArray<z.ZodString, "many">;
|
|
19
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
20
|
+
id: z.ZodString;
|
|
21
|
+
name: z.ZodString;
|
|
22
|
+
title: z.ZodOptional<z.ZodString>;
|
|
23
|
+
description: z.ZodString;
|
|
24
|
+
instructions: z.ZodString;
|
|
25
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
26
|
+
type: z.ZodEnum<["presentation", "document"]>;
|
|
27
|
+
assets: z.ZodArray<z.ZodString, "many">;
|
|
28
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
29
|
+
id: z.ZodString;
|
|
30
|
+
name: z.ZodString;
|
|
31
|
+
title: z.ZodOptional<z.ZodString>;
|
|
32
|
+
description: z.ZodString;
|
|
33
|
+
instructions: z.ZodString;
|
|
34
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
35
|
+
type: z.ZodEnum<["presentation", "document"]>;
|
|
36
|
+
assets: z.ZodArray<z.ZodString, "many">;
|
|
37
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
38
|
+
/**
|
|
39
|
+
* TypeScript type inferred from the Zod schema
|
|
40
|
+
*/
|
|
41
|
+
export type RenderingTemplateDefinition = z.infer<typeof RenderingTemplateDefinitionSchema>;
|
|
42
|
+
/**
|
|
43
|
+
* Template transformer preset
|
|
44
|
+
* Transforms markdown files with ?template suffix OR TEMPLATE.md files into template definition objects
|
|
45
|
+
*
|
|
46
|
+
* Matches:
|
|
47
|
+
* - Files with ?template suffix: ./my-template.md?template
|
|
48
|
+
* - TEMPLATE.md files: ./my-template/TEMPLATE.md
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* import template1 from './my-template.md?template';
|
|
53
|
+
* import template2 from './my-template/TEMPLATE.md';
|
|
54
|
+
* // Both are RenderingTemplateDefinition objects
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare const templateTransformer: TransformerPreset;
|
|
58
|
+
//# sourceMappingURL=template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../src/presets/template.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAgBrD;;;GAGG;AACH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAS9B,CAAC;AAEjB;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAC;AAgB5F;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB,EAAE,iBA4CjC,CAAC"}
|
package/lib/types/types.d.ts
CHANGED
package/lib/types/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IAEnB,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IAEjB,oCAAoC;IACpC,IAAI,EAAE,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IAEnB,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IAEjB,oCAAoC;IACpC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,sDAAsD;IACtD,IAAI,EAAE,OAAO,CAAC;IAEd,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB,uEAAuE;IACvE,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,+CAA+C;IAC/C,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IAErB,gDAAgD;IAChD,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnD;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC5B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,KACf,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAEhB,iDAAiD;IACjD,SAAS,EAAE,iBAAiB,CAAC;IAE7B,0CAA0C;IAC1C,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAExB,qFAAqF;IACrF,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAEpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAErC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,0CAA0C;IAC1C,YAAY,EAAE,eAAe,EAAE,CAAC;IAEhC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAE3B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,MAAM,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for discovering asset files in template directories
|
|
3
|
+
*/
|
|
4
|
+
import type { AssetFile } from '../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Discovered assets in a template directory
|
|
7
|
+
*/
|
|
8
|
+
export interface DiscoveredTemplateAssets {
|
|
9
|
+
/** Asset file names (relative to template dir) */
|
|
10
|
+
fileNames: string[];
|
|
11
|
+
/** Asset files to be copied */
|
|
12
|
+
assetFiles: AssetFile[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Discover asset files in a template directory.
|
|
16
|
+
* All files except TEMPLATE.md, *.ts, and *.js are considered assets.
|
|
17
|
+
*
|
|
18
|
+
* @param templateFilePath - Absolute path to the TEMPLATE.md file
|
|
19
|
+
* @param templatePath - The template path segment (e.g., "examples/report")
|
|
20
|
+
* @returns Discovered assets and metadata
|
|
21
|
+
*/
|
|
22
|
+
export declare function discoverTemplateAssets(templateFilePath: string, templatePath: string): DiscoveredTemplateAssets;
|
|
23
|
+
//# sourceMappingURL=template-asset-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-asset-discovery.d.ts","sourceRoot":"","sources":["../../../src/utils/template-asset-discovery.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,kDAAkD;IAClD,SAAS,EAAE,MAAM,EAAE,CAAC;IAEpB,+BAA+B;IAC/B,UAAU,EAAE,SAAS,EAAE,CAAC;CAC3B;AAgBD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAClC,gBAAgB,EAAE,MAAM,EACxB,YAAY,EAAE,MAAM,GACrB,wBAAwB,CAgC1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vertesia/build-tools",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.20260227.112605Z",
|
|
4
4
|
"description": "Build tools for Vertesia projects - Rollup and Vite plugins for transforming imports, bundling skills, and compiling widgets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/esm/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
21
21
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
22
22
|
"@types/node": "^25.0.3",
|
|
23
|
-
"rollup": "^4.
|
|
24
|
-
"rollup
|
|
23
|
+
"rollup": "^4.59.0",
|
|
24
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
25
25
|
"ts-dual-module": "^0.6.3",
|
|
26
26
|
"typescript": "^5.9.3",
|
|
27
27
|
"vitest": "^4.0.16"
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"gray-matter": "^4.0.3",
|
|
31
31
|
"zod": "^3.24.1",
|
|
32
|
-
"@
|
|
33
|
-
"@
|
|
32
|
+
"@vertesia/common": "1.0.0-dev.20260227.112605Z",
|
|
33
|
+
"@llumiverse/common": "1.0.0-dev.20260224.234313Z"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"rollup": "^4.
|
|
36
|
+
"rollup": "^4.59.0"
|
|
37
37
|
},
|
|
38
38
|
"ts_dual_module": {
|
|
39
39
|
"outDir": "lib"
|
package/src/index.ts
CHANGED
|
@@ -37,12 +37,16 @@ export {
|
|
|
37
37
|
skillTransformer,
|
|
38
38
|
rawTransformer,
|
|
39
39
|
skillCollectionTransformer,
|
|
40
|
+
templateTransformer,
|
|
41
|
+
templateCollectionTransformer,
|
|
40
42
|
promptTransformer,
|
|
41
43
|
SkillDefinitionSchema,
|
|
42
44
|
SkillPropertiesSchema,
|
|
45
|
+
RenderingTemplateDefinitionSchema,
|
|
43
46
|
PromptDefinitionSchema,
|
|
44
47
|
type SkillDefinition,
|
|
45
48
|
type SkillContentType,
|
|
49
|
+
type RenderingTemplateDefinition,
|
|
46
50
|
type PromptDefinition,
|
|
47
51
|
type PromptContentType,
|
|
48
52
|
PromptRole,
|
package/src/presets/index.ts
CHANGED
|
@@ -4,5 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
export { skillTransformer, SkillDefinitionSchema, SkillPropertiesSchema, type SkillDefinition, type SkillContentType } from './skill.js';
|
|
6
6
|
export { skillCollectionTransformer } from './skill-collection.js';
|
|
7
|
+
export { templateTransformer, RenderingTemplateDefinitionSchema, type RenderingTemplateDefinition } from './template.js';
|
|
8
|
+
export { templateCollectionTransformer } from './template-collection.js';
|
|
7
9
|
export { rawTransformer } from './raw.js';
|
|
8
10
|
export { promptTransformer, PromptDefinitionSchema, type PromptDefinition, type PromptContentType, PromptRole, TemplateType } from './prompt.js';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template collection transformer for directory-based template imports
|
|
3
|
+
* Scans a directory for subdirectories containing TEMPLATE.md files
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { readdirSync, statSync, existsSync } from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import type { TransformerPreset } from '../types.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Template collection transformer preset
|
|
12
|
+
* Transforms directory imports with ?templates suffix into an array of template imports
|
|
13
|
+
*
|
|
14
|
+
* Matches:
|
|
15
|
+
* - ./all?templates (recommended - generates all.js in the directory)
|
|
16
|
+
* - Any path ending with a filename and ?templates
|
|
17
|
+
*
|
|
18
|
+
* NOTE: A filename before ?templates is REQUIRED to avoid naming conflicts.
|
|
19
|
+
* The filename becomes the output module name.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import templates from './all?templates';
|
|
24
|
+
* // Scans current directory for subdirectories with TEMPLATE.md
|
|
25
|
+
* // Generates all.js containing array of all templates
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export const templateCollectionTransformer: TransformerPreset = {
|
|
29
|
+
pattern: /\/[^/?]+\?templates$/,
|
|
30
|
+
virtual: true,
|
|
31
|
+
transform: (_content: string, filePath: string) => {
|
|
32
|
+
// Remove ?templates suffix and the filename to get directory path
|
|
33
|
+
const pathWithoutQuery = filePath.replace(/\?templates$/, '');
|
|
34
|
+
const dirPath = path.dirname(pathWithoutQuery);
|
|
35
|
+
|
|
36
|
+
if (!existsSync(dirPath)) {
|
|
37
|
+
throw new Error(`Directory not found: ${dirPath}`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!statSync(dirPath).isDirectory()) {
|
|
41
|
+
throw new Error(`Not a directory: ${dirPath}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Scan for subdirectories containing TEMPLATE.md
|
|
45
|
+
const entries = readdirSync(dirPath);
|
|
46
|
+
const imports: string[] = [];
|
|
47
|
+
const names: string[] = [];
|
|
48
|
+
|
|
49
|
+
for (const entry of entries) {
|
|
50
|
+
const entryPath = path.join(dirPath, entry);
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
if (statSync(entryPath).isDirectory()) {
|
|
54
|
+
const templateFile = path.join(entryPath, 'TEMPLATE.md');
|
|
55
|
+
if (existsSync(templateFile)) {
|
|
56
|
+
const identifier = `Template_${entry.replace(/[^a-zA-Z0-9_]/g, '_')}`;
|
|
57
|
+
imports.push(`import ${identifier} from './${entry}/TEMPLATE.md';`);
|
|
58
|
+
names.push(identifier);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
} catch (_err) {
|
|
62
|
+
// Skip entries that can't be read
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (names.length === 0) {
|
|
68
|
+
console.warn(`No TEMPLATE.md files found in subdirectories of ${dirPath}`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Generate code that imports all templates and exports as array
|
|
72
|
+
const code = [
|
|
73
|
+
...imports,
|
|
74
|
+
'',
|
|
75
|
+
`export default [${names.join(', ')}];`
|
|
76
|
+
].join('\n');
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
data: null,
|
|
80
|
+
code
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template transformer preset for markdown files with frontmatter
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import type { TransformerPreset } from '../types.js';
|
|
8
|
+
import { parseFrontmatter } from '../parsers/frontmatter.js';
|
|
9
|
+
import { discoverTemplateAssets } from '../utils/template-asset-discovery.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Zod schema for template frontmatter validation.
|
|
13
|
+
* Only includes fields authored by the user.
|
|
14
|
+
* The name and id are inferred from the directory structure.
|
|
15
|
+
*/
|
|
16
|
+
const TemplateFrontmatterSchema = z.object({
|
|
17
|
+
title: z.string().optional(),
|
|
18
|
+
description: z.string().min(1, 'Template description is required'),
|
|
19
|
+
tags: z.array(z.string()).optional(),
|
|
20
|
+
type: z.enum(['presentation', 'document']),
|
|
21
|
+
}).strict();
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* MUST be kept in sync with @vertesia/tools-sdk RenderingTemplateDefinition
|
|
25
|
+
* Zod schema for template definition
|
|
26
|
+
*/
|
|
27
|
+
export const RenderingTemplateDefinitionSchema = z.object({
|
|
28
|
+
id: z.string().min(1, 'Template id is required'),
|
|
29
|
+
name: z.string().min(1, 'Template name is required'),
|
|
30
|
+
title: z.string().optional(),
|
|
31
|
+
description: z.string().min(1, 'Template description is required'),
|
|
32
|
+
instructions: z.string(),
|
|
33
|
+
tags: z.array(z.string()).optional(),
|
|
34
|
+
type: z.enum(['presentation', 'document']),
|
|
35
|
+
assets: z.array(z.string()),
|
|
36
|
+
}).passthrough();
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* TypeScript type inferred from the Zod schema
|
|
40
|
+
*/
|
|
41
|
+
export type RenderingTemplateDefinition = z.infer<typeof RenderingTemplateDefinitionSchema>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Derive the template path segments from the file path.
|
|
45
|
+
*
|
|
46
|
+
* Example: .../templates/examples/report/TEMPLATE.md
|
|
47
|
+
* → category: "examples", name: "report", relative: "examples/report"
|
|
48
|
+
*/
|
|
49
|
+
function deriveTemplatePathInfo(filePath: string): { category: string; templateName: string; relative: string } {
|
|
50
|
+
const templateDir = path.dirname(filePath);
|
|
51
|
+
const templateName = path.basename(templateDir);
|
|
52
|
+
const collectionDir = path.dirname(templateDir);
|
|
53
|
+
const category = path.basename(collectionDir);
|
|
54
|
+
return { category, templateName, relative: `${category}/${templateName}` };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Template transformer preset
|
|
59
|
+
* Transforms markdown files with ?template suffix OR TEMPLATE.md files into template definition objects
|
|
60
|
+
*
|
|
61
|
+
* Matches:
|
|
62
|
+
* - Files with ?template suffix: ./my-template.md?template
|
|
63
|
+
* - TEMPLATE.md files: ./my-template/TEMPLATE.md
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* import template1 from './my-template.md?template';
|
|
68
|
+
* import template2 from './my-template/TEMPLATE.md';
|
|
69
|
+
* // Both are RenderingTemplateDefinition objects
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export const templateTransformer: TransformerPreset = {
|
|
73
|
+
pattern: /(\.md\?template$|\/TEMPLATE\.md$)/,
|
|
74
|
+
schema: RenderingTemplateDefinitionSchema,
|
|
75
|
+
transform: (content: string, filePath: string) => {
|
|
76
|
+
const { frontmatter, content: markdown } = parseFrontmatter(content);
|
|
77
|
+
|
|
78
|
+
// Validate frontmatter
|
|
79
|
+
const frontmatterValidation = TemplateFrontmatterSchema.safeParse(frontmatter);
|
|
80
|
+
if (!frontmatterValidation.success) {
|
|
81
|
+
const errors = frontmatterValidation.error.errors
|
|
82
|
+
.map((err) => {
|
|
83
|
+
const pathStr = err.path.length > 0 ? err.path.join('.') : 'frontmatter';
|
|
84
|
+
return ` - ${pathStr}: ${err.message}`;
|
|
85
|
+
})
|
|
86
|
+
.join('\n');
|
|
87
|
+
throw new Error(
|
|
88
|
+
`Invalid frontmatter in ${filePath}:\n${errors}`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Derive template path from directory structure
|
|
93
|
+
const { category, templateName, relative: templatePath } = deriveTemplatePathInfo(filePath);
|
|
94
|
+
|
|
95
|
+
// Discover asset files in the template directory
|
|
96
|
+
const assets = discoverTemplateAssets(filePath, templatePath);
|
|
97
|
+
|
|
98
|
+
// Build template definition
|
|
99
|
+
// Assets use absolute paths for direct server-side resolution
|
|
100
|
+
const templateData: RenderingTemplateDefinition = {
|
|
101
|
+
id: `${category}:${templateName}`,
|
|
102
|
+
name: templateName,
|
|
103
|
+
title: frontmatter.title,
|
|
104
|
+
description: frontmatter.description,
|
|
105
|
+
instructions: markdown,
|
|
106
|
+
tags: frontmatter.tags,
|
|
107
|
+
type: frontmatter.type,
|
|
108
|
+
assets: assets.fileNames.map(f => `/templates/${templatePath}/${f}`),
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
data: templateData,
|
|
113
|
+
assets: assets.assetFiles,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
};
|
package/src/types.ts
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for discovering asset files in template directories
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { readdirSync, statSync } from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import type { AssetFile } from '../types.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Discovered assets in a template directory
|
|
11
|
+
*/
|
|
12
|
+
export interface DiscoveredTemplateAssets {
|
|
13
|
+
/** Asset file names (relative to template dir) */
|
|
14
|
+
fileNames: string[];
|
|
15
|
+
|
|
16
|
+
/** Asset files to be copied */
|
|
17
|
+
assetFiles: AssetFile[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Files to exclude from template asset discovery
|
|
22
|
+
* (source files and the template definition itself)
|
|
23
|
+
*/
|
|
24
|
+
const EXCLUDED_PATTERNS = [
|
|
25
|
+
/^TEMPLATE\.md$/,
|
|
26
|
+
/\.ts$/,
|
|
27
|
+
/\.js$/,
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
function isExcluded(fileName: string): boolean {
|
|
31
|
+
return EXCLUDED_PATTERNS.some(p => p.test(fileName));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Discover asset files in a template directory.
|
|
36
|
+
* All files except TEMPLATE.md, *.ts, and *.js are considered assets.
|
|
37
|
+
*
|
|
38
|
+
* @param templateFilePath - Absolute path to the TEMPLATE.md file
|
|
39
|
+
* @param templatePath - The template path segment (e.g., "examples/report")
|
|
40
|
+
* @returns Discovered assets and metadata
|
|
41
|
+
*/
|
|
42
|
+
export function discoverTemplateAssets(
|
|
43
|
+
templateFilePath: string,
|
|
44
|
+
templatePath: string,
|
|
45
|
+
): DiscoveredTemplateAssets {
|
|
46
|
+
const templateDir = path.dirname(templateFilePath);
|
|
47
|
+
const fileNames: string[] = [];
|
|
48
|
+
const assetFiles: AssetFile[] = [];
|
|
49
|
+
|
|
50
|
+
let files: string[];
|
|
51
|
+
try {
|
|
52
|
+
files = readdirSync(templateDir).filter(file => {
|
|
53
|
+
try {
|
|
54
|
+
return statSync(path.join(templateDir, file)).isFile();
|
|
55
|
+
} catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
} catch {
|
|
60
|
+
files = [];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
for (const file of files) {
|
|
64
|
+
if (isExcluded(file)) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
fileNames.push(file);
|
|
69
|
+
assetFiles.push({
|
|
70
|
+
sourcePath: path.join(templateDir, file),
|
|
71
|
+
destPath: path.join('templates', templatePath, file),
|
|
72
|
+
type: 'template',
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return { fileNames, assetFiles };
|
|
77
|
+
}
|