@vertesia/build-tools 1.3.0 → 1.4.0-dev.20260614.160504Z
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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rewrites query-style import specifiers inside a JavaScript source file to
|
|
3
|
+
* point at the chunks emitted by the chunk-emitter.
|
|
4
|
+
*
|
|
5
|
+
* All replacements are intra-line (only the quoted string changes), which
|
|
6
|
+
* preserves line numbers — so existing source maps remain valid at the line
|
|
7
|
+
* level without re-emitting them.
|
|
8
|
+
*/
|
|
9
|
+
export interface ImportReplacement {
|
|
10
|
+
/** Offset where the opening quote begins in the original content. */
|
|
11
|
+
quoteStart: number;
|
|
12
|
+
/** Offset where the closing quote ends (exclusive). */
|
|
13
|
+
quoteEnd: number;
|
|
14
|
+
/** Quote character to wrap the new specifier with. */
|
|
15
|
+
quote: "'" | '"' | '`';
|
|
16
|
+
/** Replacement specifier (without quotes). */
|
|
17
|
+
newSpecifier: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function rewriteImports(content: string, replacements: ImportReplacement[]): string;
|
|
20
|
+
export declare function writeRewrittenFile(filePath: string, content: string, replacements: ImportReplacement[]): boolean;
|
|
21
|
+
//# sourceMappingURL=rewriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewriter.d.ts","sourceRoot":"","sources":["../../src/import-transform/rewriter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,WAAW,iBAAiB;IAC9B,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;IAEnB,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;IAEjB,sDAAsD;IACtD,KAAK,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAEvB,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAazF;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAOhH"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rewrites query-style import specifiers inside a JavaScript source file to
|
|
3
|
+
* point at the chunks emitted by the chunk-emitter.
|
|
4
|
+
*
|
|
5
|
+
* All replacements are intra-line (only the quoted string changes), which
|
|
6
|
+
* preserves line numbers — so existing source maps remain valid at the line
|
|
7
|
+
* level without re-emitting them.
|
|
8
|
+
*/
|
|
9
|
+
import { writeFileSync } from 'node:fs';
|
|
10
|
+
export function rewriteImports(content, replacements) {
|
|
11
|
+
if (replacements.length === 0) {
|
|
12
|
+
return content;
|
|
13
|
+
}
|
|
14
|
+
const sorted = [...replacements].sort((a, b) => b.quoteStart - a.quoteStart);
|
|
15
|
+
let out = content;
|
|
16
|
+
for (const r of sorted) {
|
|
17
|
+
const literal = `${r.quote}${r.newSpecifier}${r.quote}`;
|
|
18
|
+
out = out.slice(0, r.quoteStart) + literal + out.slice(r.quoteEnd);
|
|
19
|
+
}
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
22
|
+
export function writeRewrittenFile(filePath, content, replacements) {
|
|
23
|
+
if (replacements.length === 0) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
const next = rewriteImports(content, replacements);
|
|
27
|
+
writeFileSync(filePath, next, 'utf-8');
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=rewriter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewriter.js","sourceRoot":"","sources":["../../src/import-transform/rewriter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAgBxC,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,YAAiC;IAC7E,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,MAAM,MAAM,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC;IAE7E,IAAI,GAAG,GAAG,OAAO,CAAC;IAClB,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACrB,MAAM,OAAO,GAAG,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,YAAY,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;QACxD,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAgB,EAAE,OAAe,EAAE,YAAiC;IACnG,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,IAAI,GAAG,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACnD,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACvC,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walks a compiled library directory to find candidate JavaScript files
|
|
3
|
+
* that may contain Vertesia query-style imports (`?skill`, `?raw`, …) or
|
|
4
|
+
* `SKILL.md` imports.
|
|
5
|
+
*
|
|
6
|
+
* Returns absolute paths to `.js` files whose content matches a quick
|
|
7
|
+
* content sniff for any of the trigger tokens, avoiding a re-read in the
|
|
8
|
+
* detector.
|
|
9
|
+
*/
|
|
10
|
+
export interface ScannedFile {
|
|
11
|
+
/** Absolute path to the file. */
|
|
12
|
+
path: string;
|
|
13
|
+
/** File content, captured during scanning. */
|
|
14
|
+
content: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function scanLibForQueryImports(libDir: string): ScannedFile[];
|
|
17
|
+
//# sourceMappingURL=scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../src/import-transform/scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,MAAM,WAAW,WAAW;IACxB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IAEb,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CAIpE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walks a compiled library directory to find candidate JavaScript files
|
|
3
|
+
* that may contain Vertesia query-style imports (`?skill`, `?raw`, …) or
|
|
4
|
+
* `SKILL.md` imports.
|
|
5
|
+
*
|
|
6
|
+
* Returns absolute paths to `.js` files whose content matches a quick
|
|
7
|
+
* content sniff for any of the trigger tokens, avoiding a re-read in the
|
|
8
|
+
* detector.
|
|
9
|
+
*/
|
|
10
|
+
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { SNIFF_PATTERN } from './patterns.js';
|
|
13
|
+
export function scanLibForQueryImports(libDir) {
|
|
14
|
+
const results = [];
|
|
15
|
+
walk(libDir, results);
|
|
16
|
+
return results;
|
|
17
|
+
}
|
|
18
|
+
function walk(dir, out) {
|
|
19
|
+
let entries;
|
|
20
|
+
try {
|
|
21
|
+
entries = readdirSync(dir);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
const full = path.join(dir, entry);
|
|
28
|
+
let stats;
|
|
29
|
+
try {
|
|
30
|
+
stats = statSync(full);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (stats.isDirectory()) {
|
|
36
|
+
walk(full, out);
|
|
37
|
+
}
|
|
38
|
+
else if (stats.isFile() && full.endsWith('.js')) {
|
|
39
|
+
const content = readFileSync(full, 'utf-8');
|
|
40
|
+
if (SNIFF_PATTERN.test(content)) {
|
|
41
|
+
out.push({ path: full, content });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../src/import-transform/scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAU9C,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACjD,MAAM,OAAO,GAAkB,EAAE,CAAC;IAClC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtB,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,SAAS,IAAI,CAAC,GAAW,EAAE,GAAkB;IACzC,IAAI,OAAiB,CAAC;IACtB,IAAI,CAAC;QACD,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACL,OAAO;IACX,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC1B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACnC,IAAI,KAAkC,CAAC;QACvC,IAAI,CAAC;YACD,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACL,SAAS;QACb,CAAC;QAED,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACtB,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACpB,CAAC;aAAM,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAChD,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC5C,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC9B,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YACtC,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vertesia Build Tools
|
|
3
|
+
*
|
|
4
|
+
* Transformers for custom import syntaxes (`?skill`, `?raw`, `?prompt`,
|
|
5
|
+
* `?template`, `?skills`, `?templates`, and bare `SKILL.md` / `TEMPLATE.md`),
|
|
6
|
+
* a standalone CLI (`vertesia-build`) that runs them as a post-`tsc` step,
|
|
7
|
+
* and Vite plugins for dev-mode integration.
|
|
8
|
+
*
|
|
9
|
+
* Two consumer entry points:
|
|
10
|
+
*
|
|
11
|
+
* - **Build-time:** invoke the `vertesia-build` CLI from your package
|
|
12
|
+
* scripts (after `tsc`). Config lives under `vertesia-build` in your
|
|
13
|
+
* `package.json`. The CLI calls `transformImports()` internally — you
|
|
14
|
+
* can also call it directly if you need finer control.
|
|
15
|
+
*
|
|
16
|
+
* - **Dev-time (Vite):** import `vertesiaDevServerPlugin` (or
|
|
17
|
+
* `apiServerPlugin` for full Hono tool-server wiring) from
|
|
18
|
+
* `@vertesia/build-tools/vite`. Same transformers, same behavior,
|
|
19
|
+
* applied to source files at request time.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { transformImports } from '@vertesia/build-tools';
|
|
24
|
+
*
|
|
25
|
+
* await transformImports({
|
|
26
|
+
* libDir: './lib',
|
|
27
|
+
* srcDir: './src',
|
|
28
|
+
* transformers: ['skill', 'raw'],
|
|
29
|
+
* assetsDir: './dist',
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export { compileWidget, compileWidgets, type WidgetCompilerConfig, type WidgetInput, } from './core/compilers/widget.js';
|
|
34
|
+
export { type FrontmatterResult, parseFrontmatter } from './core/parsers/frontmatter.js';
|
|
35
|
+
export { type PromptContentType, type PromptDefinition, PromptDefinitionSchema, PromptRole, promptTransformer, type RenderingTemplateDefinition, RenderingTemplateDefinitionSchema, rawTransformer, type SkillContentType, type SkillDefinition, SkillDefinitionSchema, SkillPropertiesSchema, skillCollectionTransformer, skillTransformer, TemplateType, templateCollectionTransformer, templateTransformer, } from './core/transformers/index.js';
|
|
36
|
+
export type { AssetFile, TransformerPreset, TransformerRule, TransformFunction, TransformResult, } from './core/types.js';
|
|
37
|
+
export { BUILTIN_TRANSFORMER_NAMES, BUILTIN_TRANSFORMERS, resolveTransformerNames, } from './import-transform/builtins.js';
|
|
38
|
+
export { type TransformImportsOptions, type TransformImportsResult, transformImports, } from './import-transform/index.js';
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EACH,aAAa,EACb,cAAc,EACd,KAAK,oBAAoB,EACzB,KAAK,WAAW,GACnB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,KAAK,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEzF,OAAO,EACH,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,UAAU,EACV,iBAAiB,EACjB,KAAK,2BAA2B,EAChC,iCAAiC,EACjC,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,gBAAgB,EAChB,YAAY,EACZ,6BAA6B,EAC7B,mBAAmB,GACtB,MAAM,8BAA8B,CAAC;AAEtC,YAAY,EACR,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,eAAe,GAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACH,yBAAyB,EACzB,oBAAoB,EACpB,uBAAuB,GAC1B,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACH,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,gBAAgB,GACnB,MAAM,6BAA6B,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vertesia Build Tools
|
|
3
|
+
*
|
|
4
|
+
* Transformers for custom import syntaxes (`?skill`, `?raw`, `?prompt`,
|
|
5
|
+
* `?template`, `?skills`, `?templates`, and bare `SKILL.md` / `TEMPLATE.md`),
|
|
6
|
+
* a standalone CLI (`vertesia-build`) that runs them as a post-`tsc` step,
|
|
7
|
+
* and Vite plugins for dev-mode integration.
|
|
8
|
+
*
|
|
9
|
+
* Two consumer entry points:
|
|
10
|
+
*
|
|
11
|
+
* - **Build-time:** invoke the `vertesia-build` CLI from your package
|
|
12
|
+
* scripts (after `tsc`). Config lives under `vertesia-build` in your
|
|
13
|
+
* `package.json`. The CLI calls `transformImports()` internally — you
|
|
14
|
+
* can also call it directly if you need finer control.
|
|
15
|
+
*
|
|
16
|
+
* - **Dev-time (Vite):** import `vertesiaDevServerPlugin` (or
|
|
17
|
+
* `apiServerPlugin` for full Hono tool-server wiring) from
|
|
18
|
+
* `@vertesia/build-tools/vite`. Same transformers, same behavior,
|
|
19
|
+
* applied to source files at request time.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { transformImports } from '@vertesia/build-tools';
|
|
24
|
+
*
|
|
25
|
+
* await transformImports({
|
|
26
|
+
* libDir: './lib',
|
|
27
|
+
* srcDir: './src',
|
|
28
|
+
* transformers: ['skill', 'raw'],
|
|
29
|
+
* assetsDir: './dist',
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
// esbuild-based widget bundler
|
|
34
|
+
export { compileWidget, compileWidgets, } from './core/compilers/widget.js';
|
|
35
|
+
// Parsers
|
|
36
|
+
export { parseFrontmatter } from './core/parsers/frontmatter.js';
|
|
37
|
+
// Transformers (the pure transformation functions)
|
|
38
|
+
export { PromptDefinitionSchema, PromptRole, promptTransformer, RenderingTemplateDefinitionSchema, rawTransformer, SkillDefinitionSchema, SkillPropertiesSchema, skillCollectionTransformer, skillTransformer, TemplateType, templateCollectionTransformer, templateTransformer, } from './core/transformers/index.js';
|
|
39
|
+
// CLI-friendly transformer name registry
|
|
40
|
+
export { BUILTIN_TRANSFORMER_NAMES, BUILTIN_TRANSFORMERS, resolveTransformerNames, } from './import-transform/builtins.js';
|
|
41
|
+
// Standalone import transformer (tsc → vertesia-build pipeline)
|
|
42
|
+
export { transformImports, } from './import-transform/index.js';
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,+BAA+B;AAC/B,OAAO,EACH,aAAa,EACb,cAAc,GAGjB,MAAM,4BAA4B,CAAC;AACpC,UAAU;AACV,OAAO,EAA0B,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACzF,mDAAmD;AACnD,OAAO,EAGH,sBAAsB,EACtB,UAAU,EACV,iBAAiB,EAEjB,iCAAiC,EACjC,cAAc,EAGd,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,gBAAgB,EAChB,YAAY,EACZ,6BAA6B,EAC7B,mBAAmB,GACtB,MAAM,8BAA8B,CAAC;AAStC,yCAAyC;AACzC,OAAO,EACH,yBAAyB,EACzB,oBAAoB,EACpB,uBAAuB,GAC1B,MAAM,gCAAgC,CAAC;AACxC,gEAAgE;AAChE,OAAO,EAGH,gBAAgB,GACnB,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite plugin set that mounts a Vertesia Hono tool server as middleware on
|
|
3
|
+
* the Vite dev server. Includes the Vertesia import transformers needed by
|
|
4
|
+
* `ssrLoadModule` to handle `?skill` / `?template` / `?prompt` / `?raw`
|
|
5
|
+
* imports in the tool server source.
|
|
6
|
+
*
|
|
7
|
+
* - `vite dev` → loads the server entry via `ssrLoadModule` (source,
|
|
8
|
+
* with HMR invalidation)
|
|
9
|
+
* - `vite preview` → loads the compiled server from `lib/` (validates
|
|
10
|
+
* production output)
|
|
11
|
+
*
|
|
12
|
+
* The Hono app is served on the same port as Vite under `/api`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // vite.config.ts
|
|
17
|
+
* import { defineConfig } from 'vite';
|
|
18
|
+
* import { apiServerPlugin } from '@vertesia/build-tools/vite';
|
|
19
|
+
*
|
|
20
|
+
* export default defineConfig({
|
|
21
|
+
* plugins: [
|
|
22
|
+
* apiServerPlugin({ entry: './src/tool-server/server.ts' }),
|
|
23
|
+
* ],
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
import type { Plugin } from 'vite';
|
|
28
|
+
export interface ApiServerPluginOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Tool server entry point (TypeScript source). Resolved by Vite from the
|
|
31
|
+
* project root in dev mode.
|
|
32
|
+
* @default './src/tool-server/server.ts'
|
|
33
|
+
*/
|
|
34
|
+
entry?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Compiled server module path used in preview mode. Resolved relative to
|
|
37
|
+
* `process.cwd()` (the consuming project's root when running `vite preview`).
|
|
38
|
+
* @default './lib/server.js'
|
|
39
|
+
*/
|
|
40
|
+
compiledEntry?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Path prefix that routes requests to the Hono server. Requests whose URL
|
|
43
|
+
* starts with this prefix are forwarded; others fall through to Vite.
|
|
44
|
+
* @default '/api'
|
|
45
|
+
*/
|
|
46
|
+
apiPrefix?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Names of transformers to enable in dev mode. Defaults to all built-ins
|
|
49
|
+
* (`skill`, `skills`, `template`, `templates`, `prompt`, `raw`).
|
|
50
|
+
*/
|
|
51
|
+
transformers?: readonly string[];
|
|
52
|
+
}
|
|
53
|
+
export declare function apiServerPlugin(options?: ApiServerPluginOptions): Plugin[];
|
|
54
|
+
//# sourceMappingURL=api-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-server.d.ts","sourceRoot":"","sources":["../../src/vite/api-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AASlD,MAAM,WAAW,sBAAsB;IACnC;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,sBAA2B,GAAG,MAAM,EAAE,CA6B9E"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite plugin set that mounts a Vertesia Hono tool server as middleware on
|
|
3
|
+
* the Vite dev server. Includes the Vertesia import transformers needed by
|
|
4
|
+
* `ssrLoadModule` to handle `?skill` / `?template` / `?prompt` / `?raw`
|
|
5
|
+
* imports in the tool server source.
|
|
6
|
+
*
|
|
7
|
+
* - `vite dev` → loads the server entry via `ssrLoadModule` (source,
|
|
8
|
+
* with HMR invalidation)
|
|
9
|
+
* - `vite preview` → loads the compiled server from `lib/` (validates
|
|
10
|
+
* production output)
|
|
11
|
+
*
|
|
12
|
+
* The Hono app is served on the same port as Vite under `/api`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // vite.config.ts
|
|
17
|
+
* import { defineConfig } from 'vite';
|
|
18
|
+
* import { apiServerPlugin } from '@vertesia/build-tools/vite';
|
|
19
|
+
*
|
|
20
|
+
* export default defineConfig({
|
|
21
|
+
* plugins: [
|
|
22
|
+
* apiServerPlugin({ entry: './src/tool-server/server.ts' }),
|
|
23
|
+
* ],
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
import path from 'node:path';
|
|
28
|
+
import { getRequestListener } from '@hono/node-server';
|
|
29
|
+
import { vertesiaDevServerPlugin } from './dev-server.js';
|
|
30
|
+
export function apiServerPlugin(options = {}) {
|
|
31
|
+
const { entry = './src/tool-server/server.ts', compiledEntry = './lib/server.js', apiPrefix = '/api', transformers, } = options;
|
|
32
|
+
// Resolve compiled entry relative to the consumer's cwd. Vite is run from
|
|
33
|
+
// the project root by convention, so this lands at the right file.
|
|
34
|
+
const absoluteCompiledEntry = path.resolve(process.cwd(), compiledEntry);
|
|
35
|
+
return [
|
|
36
|
+
// Vertesia query-import transformer (skill / raw / prompt / template etc.).
|
|
37
|
+
vertesiaDevServerPlugin(transformers ? { transformers } : undefined),
|
|
38
|
+
// Hono middleware bridge for dev + preview.
|
|
39
|
+
{
|
|
40
|
+
name: 'vertesia-api-server',
|
|
41
|
+
configureServer(server) {
|
|
42
|
+
server.middlewares.use(createDevListener(server, entry, apiPrefix));
|
|
43
|
+
},
|
|
44
|
+
configurePreviewServer(server) {
|
|
45
|
+
server.middlewares.use(createPreviewListener(absoluteCompiledEntry, apiPrefix));
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Connect-compatible middleware that loads the Hono app from source via
|
|
52
|
+
* Vite's `ssrLoadModule` (preserving HMR invalidation on changes).
|
|
53
|
+
*/
|
|
54
|
+
function createDevListener(server, entry, apiPrefix) {
|
|
55
|
+
return async (req, res, next) => {
|
|
56
|
+
if (!req.url?.startsWith(apiPrefix)) {
|
|
57
|
+
return next();
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const mod = await server.ssrLoadModule(entry);
|
|
61
|
+
const app = mod.default;
|
|
62
|
+
const requestListener = getRequestListener(app.fetch);
|
|
63
|
+
void requestListener(req, res);
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
next(e);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Connect-compatible middleware that loads the compiled Hono app from `lib/`
|
|
72
|
+
* for production validation. The compiled module is cached after first load
|
|
73
|
+
* (no HMR in preview mode).
|
|
74
|
+
*/
|
|
75
|
+
function createPreviewListener(compiledEntry, apiPrefix) {
|
|
76
|
+
let appPromise = null;
|
|
77
|
+
return async (req, res, next) => {
|
|
78
|
+
if (!req.url?.startsWith(apiPrefix)) {
|
|
79
|
+
return next();
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
if (!appPromise) {
|
|
83
|
+
appPromise = import(compiledEntry).then((mod) => mod.default);
|
|
84
|
+
}
|
|
85
|
+
const app = await appPromise;
|
|
86
|
+
const requestListener = getRequestListener(app.fetch);
|
|
87
|
+
void requestListener(req, res);
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
next(e);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=api-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-server.js","sourceRoot":"","sources":["../../src/vite/api-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAqC1D,MAAM,UAAU,eAAe,CAAC,UAAkC,EAAE;IAChE,MAAM,EACF,KAAK,GAAG,6BAA6B,EACrC,aAAa,GAAG,iBAAiB,EACjC,SAAS,GAAG,MAAM,EAClB,YAAY,GACf,GAAG,OAAO,CAAC;IAEZ,0EAA0E;IAC1E,mEAAmE;IACnE,MAAM,qBAAqB,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC;IAEzE,OAAO;QACH,4EAA4E;QAC5E,uBAAuB,CAAC,YAAY,CAAC,CAAC,CAAC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CAAC,GAAG,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAClC,OAAO,IAAI,EAAE,CAAC;QAClB,CAAC;QACD,IAAI,CAAC;YACD,IAAI,CAAC,UAAU,EAAE,CAAC;gBACd,UAAU,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAClE,CAAC;YACD,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC;YAC7B,MAAM,eAAe,GAAG,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACtD,KAAK,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,IAAI,CAAC,CAAC,CAAC,CAAC;QACZ,CAAC;IACL,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite plugin that transforms Vertesia query-style imports
|
|
3
|
+
* (`?skill`, `?skills`, `?prompt`, `?template`, `?templates`, `?raw`) on the
|
|
4
|
+
* fly during development, plus bare `SKILL.md` / `TEMPLATE.md` imports.
|
|
5
|
+
*
|
|
6
|
+
* This is the dev-mode counterpart to the standalone `transformImports` CLI
|
|
7
|
+
* used at build time. It runs Vite's `resolveId` + `load` hooks against the
|
|
8
|
+
* configured transformers, so the same source files work in both `vite dev`
|
|
9
|
+
* and post-`tsc` build modes.
|
|
10
|
+
*
|
|
11
|
+
* Asset copying and widget bundling are skipped in dev — they're build-time
|
|
12
|
+
* concerns only.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // vite.config.ts
|
|
17
|
+
* import { defineConfig } from 'vite';
|
|
18
|
+
* import { vertesiaDevServerPlugin } from '@vertesia/build-tools/vite';
|
|
19
|
+
*
|
|
20
|
+
* export default defineConfig({
|
|
21
|
+
* plugins: [vertesiaDevServerPlugin()],
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Default transformers include all built-ins (skill / skills / template /
|
|
26
|
+
* templates / prompt / raw). Pass `transformers` to restrict the set:
|
|
27
|
+
*
|
|
28
|
+
* ```typescript
|
|
29
|
+
* vertesiaDevServerPlugin({ transformers: ['skill', 'raw'] });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
import type { Plugin } from 'vite';
|
|
33
|
+
export interface VertesiaDevServerPluginOptions {
|
|
34
|
+
/**
|
|
35
|
+
* Names of transformers to activate. Defaults to all built-ins:
|
|
36
|
+
* `['skill', 'skills', 'template', 'templates', 'prompt', 'raw']`.
|
|
37
|
+
* Pass a subset to disable transformers you don't use.
|
|
38
|
+
*/
|
|
39
|
+
transformers?: readonly string[];
|
|
40
|
+
}
|
|
41
|
+
export declare function vertesiaDevServerPlugin(options?: VertesiaDevServerPluginOptions): Plugin;
|
|
42
|
+
//# sourceMappingURL=dev-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-server.d.ts","sourceRoot":"","sources":["../../src/vite/dev-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAInC,MAAM,WAAW,8BAA8B;IAC3C;;;;OAIG;IACH,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAED,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,8BAAmC,GAAG,MAAM,CAoE5F"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite plugin that transforms Vertesia query-style imports
|
|
3
|
+
* (`?skill`, `?skills`, `?prompt`, `?template`, `?templates`, `?raw`) on the
|
|
4
|
+
* fly during development, plus bare `SKILL.md` / `TEMPLATE.md` imports.
|
|
5
|
+
*
|
|
6
|
+
* This is the dev-mode counterpart to the standalone `transformImports` CLI
|
|
7
|
+
* used at build time. It runs Vite's `resolveId` + `load` hooks against the
|
|
8
|
+
* configured transformers, so the same source files work in both `vite dev`
|
|
9
|
+
* and post-`tsc` build modes.
|
|
10
|
+
*
|
|
11
|
+
* Asset copying and widget bundling are skipped in dev — they're build-time
|
|
12
|
+
* concerns only.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* // vite.config.ts
|
|
17
|
+
* import { defineConfig } from 'vite';
|
|
18
|
+
* import { vertesiaDevServerPlugin } from '@vertesia/build-tools/vite';
|
|
19
|
+
*
|
|
20
|
+
* export default defineConfig({
|
|
21
|
+
* plugins: [vertesiaDevServerPlugin()],
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Default transformers include all built-ins (skill / skills / template /
|
|
26
|
+
* templates / prompt / raw). Pass `transformers` to restrict the set:
|
|
27
|
+
*
|
|
28
|
+
* ```typescript
|
|
29
|
+
* vertesiaDevServerPlugin({ transformers: ['skill', 'raw'] });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
import { readFileSync } from 'node:fs';
|
|
33
|
+
import path from 'node:path';
|
|
34
|
+
import { BUILTIN_TRANSFORMER_NAMES, resolveTransformerNames } from '../import-transform/builtins.js';
|
|
35
|
+
export function vertesiaDevServerPlugin(options = {}) {
|
|
36
|
+
const names = options.transformers ?? BUILTIN_TRANSFORMER_NAMES;
|
|
37
|
+
const transformers = resolveTransformerNames([...names]);
|
|
38
|
+
return {
|
|
39
|
+
name: 'vertesia-dev-server',
|
|
40
|
+
enforce: 'pre',
|
|
41
|
+
/**
|
|
42
|
+
* Map relative query-style imports to absolute paths so Vite's loader
|
|
43
|
+
* sees a stable id keyed by the original file location. The query
|
|
44
|
+
* suffix is preserved in the id and used by `load` to pick the right
|
|
45
|
+
* transformer.
|
|
46
|
+
*/
|
|
47
|
+
resolveId(source, importer) {
|
|
48
|
+
for (const transformer of transformers) {
|
|
49
|
+
if (!transformer.pattern.test(source))
|
|
50
|
+
continue;
|
|
51
|
+
// Only relative specifiers can be resolved meaningfully against an importer.
|
|
52
|
+
if (source.startsWith('.') && importer) {
|
|
53
|
+
const cleanSource = source.replace(transformer.pattern, '');
|
|
54
|
+
const cleanImporter = importer.includes('?')
|
|
55
|
+
? importer.substring(0, importer.indexOf('?'))
|
|
56
|
+
: importer;
|
|
57
|
+
const baseDir = path.dirname(cleanImporter);
|
|
58
|
+
const resolved = path.resolve(baseDir, cleanSource);
|
|
59
|
+
const suffix = source.match(transformer.pattern)?.[0] ?? '';
|
|
60
|
+
return resolved + suffix;
|
|
61
|
+
}
|
|
62
|
+
// Bare or absolute matches are returned as-is.
|
|
63
|
+
return source;
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* Read the source file (skipping reads for virtual transformers),
|
|
69
|
+
* run the matched transformer, and return ES module source code.
|
|
70
|
+
*/
|
|
71
|
+
async load(id) {
|
|
72
|
+
const matched = findMatchingTransformer(id, transformers);
|
|
73
|
+
if (!matched)
|
|
74
|
+
return null;
|
|
75
|
+
const cleanId = stripQuery(id);
|
|
76
|
+
try {
|
|
77
|
+
const content = matched.virtual ? '' : readFileSync(cleanId, 'utf-8');
|
|
78
|
+
const result = await matched.transform(content, cleanId);
|
|
79
|
+
if (matched.schema) {
|
|
80
|
+
const validation = matched.schema.safeParse(result.data);
|
|
81
|
+
if (!validation.success) {
|
|
82
|
+
const errors = validation.error.issues
|
|
83
|
+
.map((err) => ` - ${err.path.join('.')}: ${err.message}`)
|
|
84
|
+
.join('\n');
|
|
85
|
+
throw new Error(`Validation failed for ${id}:\n${errors}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const importsBlock = result.imports && result.imports.length > 0 ? `${result.imports.join('\n')}\n\n` : '';
|
|
89
|
+
const body = result.code ?? `export default ${JSON.stringify(result.data, null, 2)};`;
|
|
90
|
+
return importsBlock + body;
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
94
|
+
// Vite/Rollup plugin context: `this.error` halts the load with a meaningful message.
|
|
95
|
+
this.error(`vertesia-dev-server: failed to transform ${id}: ${message}`);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function findMatchingTransformer(id, transformers) {
|
|
101
|
+
for (const t of transformers) {
|
|
102
|
+
if (t.pattern.test(id))
|
|
103
|
+
return t;
|
|
104
|
+
}
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
function stripQuery(id) {
|
|
108
|
+
const i = id.indexOf('?');
|
|
109
|
+
return i >= 0 ? id.substring(0, i) : id;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=dev-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-server.js","sourceRoot":"","sources":["../../src/vite/dev-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAWrG,MAAM,UAAU,uBAAuB,CAAC,UAA0C,EAAE;IAChF,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,IAAI,yBAAyB,CAAC;IAChE,MAAM,YAAY,GAAG,uBAAuB,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAEzD,OAAO;QACH,IAAI,EAAE,qBAAqB;QAC3B,OAAO,EAAE,KAAK;QAEd;;;;;WAKG;QACH,SAAS,CAAC,MAAc,EAAE,QAA4B;YAClD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;gBACrC,IAAI,CAAC,WAAW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AAC;QACL,CAAC;KACJ,CAAC;AACN,CAAC;AAED,SAAS,uBAAuB,CAAC,EAAU,EAAE,YAA+B;IACxE,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE,CAAC;QAC3B,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAAE,OAAO,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,UAAU,CAAC,EAAU;IAC1B,MAAM,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite integration for Vertesia build tools.
|
|
3
|
+
*
|
|
4
|
+
* - `vertesiaDevServerPlugin` — transforms `?skill` / `?raw` / `?prompt` /
|
|
5
|
+
* `?template` (and `?skills` / `?templates`) imports on the fly during
|
|
6
|
+
* `vite dev`. Same transformer set as the `vertesia-build` CLI used at
|
|
7
|
+
* build time, so source files behave identically in both modes.
|
|
8
|
+
*
|
|
9
|
+
* - `apiServerPlugin` — mounts a Hono tool server as Vite middleware under
|
|
10
|
+
* `/api`, with `vertesiaDevServerPlugin` already included so the tool
|
|
11
|
+
* server's query-style imports work without extra wiring.
|
|
12
|
+
*/
|
|
13
|
+
export { type ApiServerPluginOptions, apiServerPlugin } from './api-server.js';
|
|
14
|
+
export { type VertesiaDevServerPluginOptions, vertesiaDevServerPlugin } from './dev-server.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,KAAK,sBAAsB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,KAAK,8BAA8B,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vite integration for Vertesia build tools.
|
|
3
|
+
*
|
|
4
|
+
* - `vertesiaDevServerPlugin` — transforms `?skill` / `?raw` / `?prompt` /
|
|
5
|
+
* `?template` (and `?skills` / `?templates`) imports on the fly during
|
|
6
|
+
* `vite dev`. Same transformer set as the `vertesia-build` CLI used at
|
|
7
|
+
* build time, so source files behave identically in both modes.
|
|
8
|
+
*
|
|
9
|
+
* - `apiServerPlugin` — mounts a Hono tool server as Vite middleware under
|
|
10
|
+
* `/api`, with `vertesiaDevServerPlugin` already included so the tool
|
|
11
|
+
* server's query-style imports work without extra wiring.
|
|
12
|
+
*/
|
|
13
|
+
export { apiServerPlugin } from './api-server.js';
|
|
14
|
+
export { vertesiaDevServerPlugin } from './dev-server.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAA+B,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAuC,uBAAuB,EAAE,MAAM,iBAAiB,CAAC"}
|