@ambitresearch/genie 1.3.1
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 +15 -0
- package/dist/auth/bearer.d.ts +49 -0
- package/dist/auth/bearer.d.ts.map +1 -0
- package/dist/auth/bearer.js +159 -0
- package/dist/auth/bearer.js.map +1 -0
- package/dist/auth/oauth/authorize.d.ts +19 -0
- package/dist/auth/oauth/authorize.d.ts.map +1 -0
- package/dist/auth/oauth/authorize.js +111 -0
- package/dist/auth/oauth/authorize.js.map +1 -0
- package/dist/auth/oauth/config.d.ts +10 -0
- package/dist/auth/oauth/config.d.ts.map +1 -0
- package/dist/auth/oauth/config.js +16 -0
- package/dist/auth/oauth/config.js.map +1 -0
- package/dist/auth/oauth/dcr.d.ts +15 -0
- package/dist/auth/oauth/dcr.d.ts.map +1 -0
- package/dist/auth/oauth/dcr.js +38 -0
- package/dist/auth/oauth/dcr.js.map +1 -0
- package/dist/auth/oauth/jwt.d.ts +13 -0
- package/dist/auth/oauth/jwt.d.ts.map +1 -0
- package/dist/auth/oauth/jwt.js +46 -0
- package/dist/auth/oauth/jwt.js.map +1 -0
- package/dist/auth/oauth/metadata.d.ts +9 -0
- package/dist/auth/oauth/metadata.d.ts.map +1 -0
- package/dist/auth/oauth/metadata.js +19 -0
- package/dist/auth/oauth/metadata.js.map +1 -0
- package/dist/auth/oauth/router.d.ts +32 -0
- package/dist/auth/oauth/router.d.ts.map +1 -0
- package/dist/auth/oauth/router.js +159 -0
- package/dist/auth/oauth/router.js.map +1 -0
- package/dist/auth/oauth/store.d.ts +55 -0
- package/dist/auth/oauth/store.d.ts.map +1 -0
- package/dist/auth/oauth/store.js +63 -0
- package/dist/auth/oauth/store.js.map +1 -0
- package/dist/auth/oauth/token.d.ts +21 -0
- package/dist/auth/oauth/token.d.ts.map +1 -0
- package/dist/auth/oauth/token.js +77 -0
- package/dist/auth/oauth/token.js.map +1 -0
- package/dist/auth/oidc/group-policy.d.ts +43 -0
- package/dist/auth/oidc/group-policy.d.ts.map +1 -0
- package/dist/auth/oidc/group-policy.js +54 -0
- package/dist/auth/oidc/group-policy.js.map +1 -0
- package/dist/auth/oidc/verifier.d.ts +42 -0
- package/dist/auth/oidc/verifier.d.ts.map +1 -0
- package/dist/auth/oidc/verifier.js +145 -0
- package/dist/auth/oidc/verifier.js.map +1 -0
- package/dist/auth/token-cli.d.ts +9 -0
- package/dist/auth/token-cli.d.ts.map +1 -0
- package/dist/auth/token-cli.js +98 -0
- package/dist/auth/token-cli.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +149 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/redact.d.ts +20 -0
- package/dist/config/redact.d.ts.map +1 -0
- package/dist/config/redact.js +77 -0
- package/dist/config/redact.js.map +1 -0
- package/dist/config/secrets.d.ts +100 -0
- package/dist/config/secrets.d.ts.map +1 -0
- package/dist/config/secrets.js +130 -0
- package/dist/config/secrets.js.map +1 -0
- package/dist/framework/html.d.ts +103 -0
- package/dist/framework/html.d.ts.map +1 -0
- package/dist/framework/html.js +271 -0
- package/dist/framework/html.js.map +1 -0
- package/dist/framework/interface.d.ts +130 -0
- package/dist/framework/interface.d.ts.map +1 -0
- package/dist/framework/interface.js +112 -0
- package/dist/framework/interface.js.map +1 -0
- package/dist/framework/react.d.ts +133 -0
- package/dist/framework/react.d.ts.map +1 -0
- package/dist/framework/react.js +243 -0
- package/dist/framework/react.js.map +1 -0
- package/dist/framework/vue.d.ts +99 -0
- package/dist/framework/vue.d.ts.map +1 -0
- package/dist/framework/vue.js +375 -0
- package/dist/framework/vue.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/client.d.ts +81 -0
- package/dist/llm/client.d.ts.map +1 -0
- package/dist/llm/client.js +141 -0
- package/dist/llm/client.js.map +1 -0
- package/dist/llm/component-response.d.ts +111 -0
- package/dist/llm/component-response.d.ts.map +1 -0
- package/dist/llm/component-response.js +167 -0
- package/dist/llm/component-response.js.map +1 -0
- package/dist/llm/generated-files.d.ts +10 -0
- package/dist/llm/generated-files.d.ts.map +1 -0
- package/dist/llm/generated-files.js +26 -0
- package/dist/llm/generated-files.js.map +1 -0
- package/dist/llm/prompts/CHANGELOG.md +70 -0
- package/dist/llm/prompts/generate-component.system.md +99 -0
- package/dist/llm/prompts/refine-component.system.md +112 -0
- package/dist/llm/prompts.d.ts +66 -0
- package/dist/llm/prompts.d.ts.map +1 -0
- package/dist/llm/prompts.js +78 -0
- package/dist/llm/prompts.js.map +1 -0
- package/dist/llm/retry.d.ts +183 -0
- package/dist/llm/retry.d.ts.map +1 -0
- package/dist/llm/retry.js +475 -0
- package/dist/llm/retry.js.map +1 -0
- package/dist/llm/schema.d.ts +129 -0
- package/dist/llm/schema.d.ts.map +1 -0
- package/dist/llm/schema.js +147 -0
- package/dist/llm/schema.js.map +1 -0
- package/dist/llm/validate.d.ts +107 -0
- package/dist/llm/validate.d.ts.map +1 -0
- package/dist/llm/validate.js +174 -0
- package/dist/llm/validate.js.map +1 -0
- package/dist/manifest/compiler.d.ts +112 -0
- package/dist/manifest/compiler.d.ts.map +1 -0
- package/dist/manifest/compiler.js +306 -0
- package/dist/manifest/compiler.js.map +1 -0
- package/dist/manifest/ensure.d.ts +46 -0
- package/dist/manifest/ensure.d.ts.map +1 -0
- package/dist/manifest/ensure.js +49 -0
- package/dist/manifest/ensure.js.map +1 -0
- package/dist/manifest/index.d.ts +13 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +13 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/middleware/plan-guard.d.ts +167 -0
- package/dist/middleware/plan-guard.d.ts.map +1 -0
- package/dist/middleware/plan-guard.js +190 -0
- package/dist/middleware/plan-guard.js.map +1 -0
- package/dist/plans/index.d.ts +71 -0
- package/dist/plans/index.d.ts.map +1 -0
- package/dist/plans/index.js +252 -0
- package/dist/plans/index.js.map +1 -0
- package/dist/schemas/component.schema.json +114 -0
- package/dist/server.d.ts +96 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +258 -0
- package/dist/server.js.map +1 -0
- package/dist/store/empty-manifest.d.ts +58 -0
- package/dist/store/empty-manifest.d.ts.map +1 -0
- package/dist/store/empty-manifest.js +59 -0
- package/dist/store/empty-manifest.js.map +1 -0
- package/dist/store/git-host.d.ts +120 -0
- package/dist/store/git-host.d.ts.map +1 -0
- package/dist/store/git-host.js +796 -0
- package/dist/store/git-host.js.map +1 -0
- package/dist/store/index.d.ts +5 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +4 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/interface.d.ts +322 -0
- package/dist/store/interface.d.ts.map +1 -0
- package/dist/store/interface.js +100 -0
- package/dist/store/interface.js.map +1 -0
- package/dist/store/kit-files.d.ts +88 -0
- package/dist/store/kit-files.d.ts.map +1 -0
- package/dist/store/kit-files.js +199 -0
- package/dist/store/kit-files.js.map +1 -0
- package/dist/store/local.d.ts +70 -0
- package/dist/store/local.d.ts.map +1 -0
- package/dist/store/local.js +651 -0
- package/dist/store/local.js.map +1 -0
- package/dist/store/manifest.d.ts +44 -0
- package/dist/store/manifest.d.ts.map +1 -0
- package/dist/store/manifest.js +116 -0
- package/dist/store/manifest.js.map +1 -0
- package/dist/store/viewer-assets.d.ts +20 -0
- package/dist/store/viewer-assets.d.ts.map +1 -0
- package/dist/store/viewer-assets.js +118 -0
- package/dist/store/viewer-assets.js.map +1 -0
- package/dist/sync/anchor.d.ts +125 -0
- package/dist/sync/anchor.d.ts.map +1 -0
- package/dist/sync/anchor.js +210 -0
- package/dist/sync/anchor.js.map +1 -0
- package/dist/sync/index.d.ts +15 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +15 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/orchestrator.d.ts +160 -0
- package/dist/sync/orchestrator.d.ts.map +1 -0
- package/dist/sync/orchestrator.js +288 -0
- package/dist/sync/orchestrator.js.map +1 -0
- package/dist/tools/bind_kit.d.ts +29 -0
- package/dist/tools/bind_kit.d.ts.map +1 -0
- package/dist/tools/bind_kit.js +70 -0
- package/dist/tools/bind_kit.js.map +1 -0
- package/dist/tools/conjure.d.ts +141 -0
- package/dist/tools/conjure.d.ts.map +1 -0
- package/dist/tools/conjure.js +655 -0
- package/dist/tools/conjure.js.map +1 -0
- package/dist/tools/conjure_screen.d.ts +174 -0
- package/dist/tools/conjure_screen.d.ts.map +1 -0
- package/dist/tools/conjure_screen.js +458 -0
- package/dist/tools/conjure_screen.js.map +1 -0
- package/dist/tools/create_kit.d.ts +32 -0
- package/dist/tools/create_kit.d.ts.map +1 -0
- package/dist/tools/create_kit.js +131 -0
- package/dist/tools/create_kit.js.map +1 -0
- package/dist/tools/create_project.d.ts +267 -0
- package/dist/tools/create_project.d.ts.map +1 -0
- package/dist/tools/create_project.js +546 -0
- package/dist/tools/create_project.js.map +1 -0
- package/dist/tools/delete_files.d.ts +93 -0
- package/dist/tools/delete_files.d.ts.map +1 -0
- package/dist/tools/delete_files.js +276 -0
- package/dist/tools/delete_files.js.map +1 -0
- package/dist/tools/delete_project.d.ts +43 -0
- package/dist/tools/delete_project.d.ts.map +1 -0
- package/dist/tools/delete_project.js +118 -0
- package/dist/tools/delete_project.js.map +1 -0
- package/dist/tools/get_kit.d.ts +28 -0
- package/dist/tools/get_kit.d.ts.map +1 -0
- package/dist/tools/get_kit.js +95 -0
- package/dist/tools/get_kit.js.map +1 -0
- package/dist/tools/get_project.d.ts +37 -0
- package/dist/tools/get_project.d.ts.map +1 -0
- package/dist/tools/get_project.js +71 -0
- package/dist/tools/get_project.js.map +1 -0
- package/dist/tools/list_components.d.ts +42 -0
- package/dist/tools/list_components.d.ts.map +1 -0
- package/dist/tools/list_components.js +125 -0
- package/dist/tools/list_components.js.map +1 -0
- package/dist/tools/list_files.d.ts +32 -0
- package/dist/tools/list_files.d.ts.map +1 -0
- package/dist/tools/list_files.js +109 -0
- package/dist/tools/list_files.js.map +1 -0
- package/dist/tools/list_kits.d.ts +14 -0
- package/dist/tools/list_kits.d.ts.map +1 -0
- package/dist/tools/list_kits.js +41 -0
- package/dist/tools/list_kits.js.map +1 -0
- package/dist/tools/list_projects.d.ts +23 -0
- package/dist/tools/list_projects.d.ts.map +1 -0
- package/dist/tools/list_projects.js +66 -0
- package/dist/tools/list_projects.js.map +1 -0
- package/dist/tools/plan.d.ts +16 -0
- package/dist/tools/plan.d.ts.map +1 -0
- package/dist/tools/plan.js +146 -0
- package/dist/tools/plan.js.map +1 -0
- package/dist/tools/preview.d.ts +289 -0
- package/dist/tools/preview.d.ts.map +1 -0
- package/dist/tools/preview.js +672 -0
- package/dist/tools/preview.js.map +1 -0
- package/dist/tools/read_file.d.ts +40 -0
- package/dist/tools/read_file.d.ts.map +1 -0
- package/dist/tools/read_file.js +114 -0
- package/dist/tools/read_file.js.map +1 -0
- package/dist/tools/refine.d.ts +220 -0
- package/dist/tools/refine.d.ts.map +1 -0
- package/dist/tools/refine.js +501 -0
- package/dist/tools/refine.js.map +1 -0
- package/dist/tools/validate.d.ts +74 -0
- package/dist/tools/validate.d.ts.map +1 -0
- package/dist/tools/validate.js +224 -0
- package/dist/tools/validate.js.map +1 -0
- package/dist/tools/write_files.d.ts +158 -0
- package/dist/tools/write_files.d.ts.map +1 -0
- package/dist/tools/write_files.js +541 -0
- package/dist/tools/write_files.js.map +1 -0
- package/dist/transport.d.ts +77 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +448 -0
- package/dist/transport.js.map +1 -0
- package/dist/ui/card-asset-broker.d.ts +42 -0
- package/dist/ui/card-asset-broker.d.ts.map +1 -0
- package/dist/ui/card-asset-broker.js +479 -0
- package/dist/ui/card-asset-broker.js.map +1 -0
- package/dist/ui/grid-resource.d.ts +252 -0
- package/dist/ui/grid-resource.d.ts.map +1 -0
- package/dist/ui/grid-resource.js +680 -0
- package/dist/ui/grid-resource.js.map +1 -0
- package/dist/ui/viewer-static/index.html +95 -0
- package/dist/ui/viewer-static/viewer.css +451 -0
- package/dist/ui/viewer-static/viewer.js +1405 -0
- package/dist/validate/full-scan.d.ts +87 -0
- package/dist/validate/full-scan.d.ts.map +1 -0
- package/dist/validate/full-scan.js +299 -0
- package/dist/validate/full-scan.js.map +1 -0
- package/dist/validate/index.d.ts +15 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +18 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/validate/marker.d.ts +89 -0
- package/dist/validate/marker.d.ts.map +1 -0
- package/dist/validate/marker.js +87 -0
- package/dist/validate/marker.js.map +1 -0
- package/dist/validate/phash.d.ts +135 -0
- package/dist/validate/phash.d.ts.map +1 -0
- package/dist/validate/phash.js +307 -0
- package/dist/validate/phash.js.map +1 -0
- package/dist/validate/render.d.ts +38 -0
- package/dist/validate/render.d.ts.map +1 -0
- package/dist/validate/render.js +155 -0
- package/dist/validate/render.js.map +1 -0
- package/dist/watch/index.d.ts +12 -0
- package/dist/watch/index.d.ts.map +1 -0
- package/dist/watch/index.js +12 -0
- package/dist/watch/index.js.map +1 -0
- package/dist/watch/watcher.d.ts +65 -0
- package/dist/watch/watcher.d.ts.map +1 -0
- package/dist/watch/watcher.js +238 -0
- package/dist/watch/watcher.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Plugin } from "esbuild";
|
|
2
|
+
import { type AdapterFile, type FrameworkAdapter, type Framework, type RenderInput, type Viewport } from "./interface.js";
|
|
3
|
+
/**
|
|
4
|
+
* v2 tracking issue this adapter was implemented under (kept exported for
|
|
5
|
+
* provenance and referenced by the conformance suite). Retained now that Vue is
|
|
6
|
+
* no longer a stub so historical links and the AC3 URL-shape assertion still
|
|
7
|
+
* resolve.
|
|
8
|
+
*/
|
|
9
|
+
export declare const VUE_TRACKING_ISSUE = "https://github.com/ambitresearch/genie/issues/129";
|
|
10
|
+
/**
|
|
11
|
+
* The host-provided browser global the preview IIFE resolves Vue from. The M4
|
|
12
|
+
* preview iframe must load the vendored Vue 3 global build (which self-assigns
|
|
13
|
+
* `window.Vue`) before the component bundle — see the *Preview host contract*
|
|
14
|
+
* above. Kept here so the adapter is the single source of truth for the contract.
|
|
15
|
+
*/
|
|
16
|
+
export declare const VUE_HOST_GLOBAL = "Vue";
|
|
17
|
+
/**
|
|
18
|
+
* esbuild plugin implementing the {@link VUE_HOST_GLOBAL} contract (parity with
|
|
19
|
+
* React's `hostReactGlobalsPlugin`). It intercepts the bare `vue` specifier every
|
|
20
|
+
* compiled SFC imports its runtime helpers from and resolves it to an in-memory
|
|
21
|
+
* virtual module that reads `window.Vue` — so the emitted IIFE contains **no**
|
|
22
|
+
* `require("vue")` and instead references the host global.
|
|
23
|
+
*
|
|
24
|
+
* Vue's compiled output only ever imports from the bare `"vue"` entry (unlike
|
|
25
|
+
* React's automatic-JSX runtime, which also pulls `react/jsx-runtime`), so a
|
|
26
|
+
* single specifier rewrite is sufficient.
|
|
27
|
+
*/
|
|
28
|
+
export declare function hostVueGlobalPlugin(): Plugin;
|
|
29
|
+
export declare class VueAdapter implements FrameworkAdapter {
|
|
30
|
+
readonly framework: Framework;
|
|
31
|
+
/**
|
|
32
|
+
* A comfortable default card for a Vue component when the caller has no better
|
|
33
|
+
* viewport. Matches the React adapter (and the RFC's default preview grid cell,
|
|
34
|
+
* §7.5) so a framework switch never resizes a card by default.
|
|
35
|
+
*/
|
|
36
|
+
readonly defaultViewport: Viewport;
|
|
37
|
+
/**
|
|
38
|
+
* The framework directive `conjure` injects into the generation prompt (AC4):
|
|
39
|
+
* name the target framework and the Vue SFC shape the model should emit. Asking
|
|
40
|
+
* for an **exported** props interface makes {@link extractDts} productive (it
|
|
41
|
+
* emits the SFC script block's exported declarations), mirroring the React
|
|
42
|
+
* adapter's "exported interface" guidance.
|
|
43
|
+
*/
|
|
44
|
+
readonly promptDirective: string;
|
|
45
|
+
/**
|
|
46
|
+
* The canonical source file: `<Name>.vue`, carrying the model-authored SFC
|
|
47
|
+
* verbatim. `text/x-vue` matches the MIME the kit-file classifier already maps
|
|
48
|
+
* `.vue` to (`store/kit-files.ts`), so an adapter-emitted source and a
|
|
49
|
+
* store-read source report the same type.
|
|
50
|
+
*/
|
|
51
|
+
renderSource(input: RenderInput): AdapterFile;
|
|
52
|
+
/**
|
|
53
|
+
* Bundle the SFC to a browser-ready **IIFE** exposing the compiled component on
|
|
54
|
+
* `globalThis.${PREVIEW_GLOBAL_NAME}` (`{ default, <Name> }`). The pipeline
|
|
55
|
+
* mirrors what `@vitejs/plugin-vue` does — compile the script and the template
|
|
56
|
+
* as *separate* modules and stitch them — so it renders every SFC shape
|
|
57
|
+
* (`<script setup>`, options-API `<script>`, and template-only) identically:
|
|
58
|
+
*
|
|
59
|
+
* 1. `@vue/compiler-sfc#parse` → SFC descriptor.
|
|
60
|
+
* 2. `compileScript({ inlineTemplate: false })` lowers `<script setup>` (or a
|
|
61
|
+
* plain options-API `<script>`) to the component object, exposing its
|
|
62
|
+
* `bindings` so the template can bind setup state correctly. `inlineTemplate`
|
|
63
|
+
* is deliberately **off**: it only bakes the template into `<script setup>`
|
|
64
|
+
* output — for an options-API `<script>` it silently drops the render
|
|
65
|
+
* function, leaving a component that mounts to nothing.
|
|
66
|
+
* 3. `compileTemplate` compiles `<template>` to a standalone `render`, fed the
|
|
67
|
+
* script's `bindings` (so `<script setup>` refs resolve) and the scope id,
|
|
68
|
+
* then assigned onto the component. A template-only SFC starts from an empty
|
|
69
|
+
* component object; a script-only SFC skips this step.
|
|
70
|
+
* 4. `<style scoped>` blocks are compiled with the matching scope id and
|
|
71
|
+
* inlined as a guarded runtime `<style>` injection so the preview is a
|
|
72
|
+
* single self-contained script (the interface returns one file).
|
|
73
|
+
* 5. esbuild bundles it to an IIFE, rewriting `"vue"` → `window.Vue` via
|
|
74
|
+
* {@link hostVueGlobalPlugin} — no `require("vue")` at runtime.
|
|
75
|
+
*
|
|
76
|
+
* The SFC compiler, esbuild and ts-morph are all imported lazily so resolving a
|
|
77
|
+
* `VueAdapter` never pulls them until a preview is actually built.
|
|
78
|
+
*/
|
|
79
|
+
renderPreview(input: RenderInput): Promise<AdapterFile>;
|
|
80
|
+
/**
|
|
81
|
+
* Extract the component's `.d.ts` typings with ts-morph (parity with React), via
|
|
82
|
+
* an in-memory declaration-only emit so nothing touches disk. Vue's props/emits
|
|
83
|
+
* live in the SFC's `<script setup>` (and/or `<script>`) block; this feeds those
|
|
84
|
+
* blocks' TypeScript to ts-morph and emits the **exported** declarations — so a
|
|
85
|
+
* component that exports its props interface (as the `promptDirective` asks)
|
|
86
|
+
* yields that interface in its `.d.ts`.
|
|
87
|
+
*
|
|
88
|
+
* The `defineProps` / `defineEmits` / `withDefaults` compiler macros are left as
|
|
89
|
+
* unresolved identifiers, but we never type-check — only emit declarations
|
|
90
|
+
* (`skipLibCheck` + `emitDeclarationOnly`) — so their presence never blocks the
|
|
91
|
+
* exported types from surfacing. A source with no exported declarations (inline
|
|
92
|
+
* prop types, or a template-only SFC) falls back to a valid empty module.
|
|
93
|
+
*
|
|
94
|
+
* ts-morph and the SFC parser are imported lazily for the same reason as
|
|
95
|
+
* {@link renderPreview}: keep resolving the adapter cheap.
|
|
96
|
+
*/
|
|
97
|
+
extractDts(input: RenderInput): Promise<AdapterFile>;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vue.d.ts","sourceRoot":"","sources":["../../src/framework/vue.ts"],"names":[],"mappings":"AAmDA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,QAAQ,EACd,MAAM,gBAAgB,CAAC;AAQxB;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,sDAAsD,CAAC;AAEtF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QAAQ,CAAC;AAyBrC;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAW5C;AAmCD,qBAAa,UAAW,YAAW,gBAAgB;IACjD,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAS;IAEtC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAA+B;IAEjE;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,CAMnB;IAEb;;;;;OAKG;IACH,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW;IAQ7C;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAiI7D;;;;;;;;;;;;;;;;OAgBG;IACG,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CAwC3D"}
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `VueAdapter` (M2-08 stub → **v2 · DRO-616**) — the Vue 3 framework adapter.
|
|
3
|
+
*
|
|
4
|
+
* Lowers a neutral {@link RenderInput} (the component's `.vue` **single-file
|
|
5
|
+
* component** source) into the three Vue target artefacts, mirroring
|
|
6
|
+
* {@link ReactAdapter} method-for-method so `conjure` treats every framework the
|
|
7
|
+
* same:
|
|
8
|
+
* - {@link VueAdapter.renderSource} → `<Name>.vue` (the canonical SFC source)
|
|
9
|
+
* - {@link VueAdapter.renderPreview} → `<Name>.preview.js` — an **esbuild IIFE
|
|
10
|
+
* bundle** exposing the compiled component on `globalThis.GenieComponent` for
|
|
11
|
+
* the M4 iframe grid to mount with `Vue.createApp(GenieComponent.default)`
|
|
12
|
+
* - {@link VueAdapter.extractDts} → `<Name>.d.ts` — the component's exported
|
|
13
|
+
* prop/emit types, extracted with **ts-morph** (declaration-only in-memory emit)
|
|
14
|
+
*
|
|
15
|
+
* ── Import-time safety ────────────────────────────────────────────────────────
|
|
16
|
+
* `@vue/compiler-sfc`, `esbuild` and `ts-morph` are heavy transitive graphs.
|
|
17
|
+
* None is imported at this module's top level — each is reached through a lazy
|
|
18
|
+
* `await import(...)` *inside* the one method that needs it. So the registry
|
|
19
|
+
* (`interface.ts#getAdapter`) can resolve a `VueAdapter` — and `conjure` can read
|
|
20
|
+
* its `promptDirective` / `defaultViewport` on the generation hot path — without
|
|
21
|
+
* ever pulling the SFC compiler, the bundler, or the TS compiler, which only load
|
|
22
|
+
* when a preview / `.d.ts` is actually produced. The only compile-time references
|
|
23
|
+
* at module scope are `import type`s (erased under `verbatimModuleSyntax`), which
|
|
24
|
+
* emit no runtime `require(...)` and do not defeat the lazy-load.
|
|
25
|
+
*
|
|
26
|
+
* ── Preview host contract (parity with DRO-624's React contract) ──────────────
|
|
27
|
+
* The `<Name>.preview.js` bundle does **not** carry its own copy of Vue, nor does
|
|
28
|
+
* it `require("vue")`. Vue's SFC compiler lowers a `<script setup>` / template
|
|
29
|
+
* into a module that imports its runtime helpers (`defineComponent`, `openBlock`,
|
|
30
|
+
* `createElementBlock`, `toDisplayString`, …) from the bare specifier `"vue"`.
|
|
31
|
+
* {@link hostVueGlobalPlugin} rewrites that specifier at bundle time to read a
|
|
32
|
+
* **host-provided browser global** the preview iframe must define *before* the
|
|
33
|
+
* bundle's `<script>` runs:
|
|
34
|
+
*
|
|
35
|
+
* - `window.{@link VUE_HOST_GLOBAL}` → the Vue 3 runtime (`window.Vue`)
|
|
36
|
+
*
|
|
37
|
+
* exactly as the React adapter rewrites `react` → `window.React`. Per the on-disk
|
|
38
|
+
* layout (PRD §6.6) the kit vendors the runtime under `_vendor/` (the Vue 3
|
|
39
|
+
* *global* build — `vue.runtime.global.prod.js` — which self-assigns
|
|
40
|
+
* `window.Vue`), and the iframe host page `<script>`-includes it ahead of the
|
|
41
|
+
* component bundle. Marking `vue` esbuild-`external` under `format:"iife"` would
|
|
42
|
+
* lower the import to a throwing `require("vue")` (the same failure mode DRO-624
|
|
43
|
+
* fixed for React), so the plugin is the mechanism, not `external`.
|
|
44
|
+
*
|
|
45
|
+
* NOTE — **Vue 3 global build**: the contract depends on a runtime that ships a
|
|
46
|
+
* build defining a `window.Vue` global carrying the full runtime helper surface.
|
|
47
|
+
* The vendored `_vendor/vue.runtime.global.prod.js` must be a Vue 3 global build
|
|
48
|
+
* (the adapter's execution test pins the same major).
|
|
49
|
+
*/
|
|
50
|
+
import { createHash } from "node:crypto";
|
|
51
|
+
import { componentPath, } from "./interface.js";
|
|
52
|
+
// The M4 grid's preview-global name is a cross-framework contract; import the
|
|
53
|
+
// single source of truth from the React adapter rather than redeclaring it, so
|
|
54
|
+
// Vue and React cards are mounted through the identical `window.GenieComponent`
|
|
55
|
+
// handle. (react.js has no heavy top-level imports — only `import type` — so
|
|
56
|
+
// this stays cheap and does not pull esbuild/ts-morph.)
|
|
57
|
+
import { PREVIEW_GLOBAL_NAME } from "./react.js";
|
|
58
|
+
/**
|
|
59
|
+
* v2 tracking issue this adapter was implemented under (kept exported for
|
|
60
|
+
* provenance and referenced by the conformance suite). Retained now that Vue is
|
|
61
|
+
* no longer a stub so historical links and the AC3 URL-shape assertion still
|
|
62
|
+
* resolve.
|
|
63
|
+
*/
|
|
64
|
+
export const VUE_TRACKING_ISSUE = "https://github.com/ambitresearch/genie/issues/129";
|
|
65
|
+
/**
|
|
66
|
+
* The host-provided browser global the preview IIFE resolves Vue from. The M4
|
|
67
|
+
* preview iframe must load the vendored Vue 3 global build (which self-assigns
|
|
68
|
+
* `window.Vue`) before the component bundle — see the *Preview host contract*
|
|
69
|
+
* above. Kept here so the adapter is the single source of truth for the contract.
|
|
70
|
+
*/
|
|
71
|
+
export const VUE_HOST_GLOBAL = "Vue";
|
|
72
|
+
/**
|
|
73
|
+
* esbuild namespace the virtual `vue` shim module lives in (kept off the real
|
|
74
|
+
* filesystem so nothing resolves to an on-disk `node_modules/vue`).
|
|
75
|
+
*/
|
|
76
|
+
const HOST_NAMESPACE = "genie-vue-host-global";
|
|
77
|
+
/** A clear, actionable error when the iframe forgot to load the vendored global. */
|
|
78
|
+
function hostMissingMessage() {
|
|
79
|
+
return (`genie preview host contract violated: window.${VUE_HOST_GLOBAL} is not defined. ` +
|
|
80
|
+
`The preview iframe must load the vendored _vendor/vue.runtime.global.prod.js ` +
|
|
81
|
+
`(Vue 3 global build) before the component bundle — see the preview host contract in vue.ts.`);
|
|
82
|
+
}
|
|
83
|
+
/** CJS body for the virtual `vue` module that re-exports the host global. */
|
|
84
|
+
function hostGlobalModule() {
|
|
85
|
+
return [
|
|
86
|
+
`if (!window.${VUE_HOST_GLOBAL}) throw new Error(${JSON.stringify(hostMissingMessage())});`,
|
|
87
|
+
`module.exports = window.${VUE_HOST_GLOBAL};`,
|
|
88
|
+
].join("\n");
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* esbuild plugin implementing the {@link VUE_HOST_GLOBAL} contract (parity with
|
|
92
|
+
* React's `hostReactGlobalsPlugin`). It intercepts the bare `vue` specifier every
|
|
93
|
+
* compiled SFC imports its runtime helpers from and resolves it to an in-memory
|
|
94
|
+
* virtual module that reads `window.Vue` — so the emitted IIFE contains **no**
|
|
95
|
+
* `require("vue")` and instead references the host global.
|
|
96
|
+
*
|
|
97
|
+
* Vue's compiled output only ever imports from the bare `"vue"` entry (unlike
|
|
98
|
+
* React's automatic-JSX runtime, which also pulls `react/jsx-runtime`), so a
|
|
99
|
+
* single specifier rewrite is sufficient.
|
|
100
|
+
*/
|
|
101
|
+
export function hostVueGlobalPlugin() {
|
|
102
|
+
return {
|
|
103
|
+
name: "genie-vue-host-global",
|
|
104
|
+
setup(build) {
|
|
105
|
+
build.onResolve({ filter: /^vue$/ }, () => ({ path: "vue", namespace: HOST_NAMESPACE }));
|
|
106
|
+
build.onLoad({ filter: /.*/, namespace: HOST_NAMESPACE }, () => ({
|
|
107
|
+
contents: hostGlobalModule(),
|
|
108
|
+
loader: "js",
|
|
109
|
+
}));
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A deterministic 8-hex scope id derived from the component identity + source, so
|
|
115
|
+
* a given SFC always compiles to the same `data-v-…` attribute (stable preview
|
|
116
|
+
* bytes across runs — no `Date.now()`/random). Vue's SFC compiler uses this id to
|
|
117
|
+
* scope both the template's root attribute and the `<style scoped>` selectors.
|
|
118
|
+
*/
|
|
119
|
+
function scopeHash(input) {
|
|
120
|
+
return createHash("sha256")
|
|
121
|
+
.update(`${input.componentName} ${input.source}`)
|
|
122
|
+
.digest("hex")
|
|
123
|
+
.slice(0, 8);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* A guarded, idempotent runtime `<style>` injector snippet. `<style scoped>` CSS
|
|
127
|
+
* is intrinsic to an SFC, so the preview must carry it; the snippet appends one
|
|
128
|
+
* `<style>` element (keyed by `styleKey` so re-evaluating the bundle never
|
|
129
|
+
* duplicates it) and is a no-op outside a DOM (SSR / static analysis).
|
|
130
|
+
*/
|
|
131
|
+
function styleInjectorSnippet(css, styleKey) {
|
|
132
|
+
const elementId = `genie-style-${styleKey}`;
|
|
133
|
+
return [
|
|
134
|
+
`(function () {`,
|
|
135
|
+
` if (typeof document === "undefined") return;`,
|
|
136
|
+
` if (document.getElementById(${JSON.stringify(elementId)})) return;`,
|
|
137
|
+
` var __genieStyle = document.createElement("style");`,
|
|
138
|
+
` __genieStyle.id = ${JSON.stringify(elementId)};`,
|
|
139
|
+
` __genieStyle.textContent = ${JSON.stringify(css)};`,
|
|
140
|
+
` document.head.appendChild(__genieStyle);`,
|
|
141
|
+
`})();`,
|
|
142
|
+
].join("\n");
|
|
143
|
+
}
|
|
144
|
+
export class VueAdapter {
|
|
145
|
+
framework = "vue";
|
|
146
|
+
/**
|
|
147
|
+
* A comfortable default card for a Vue component when the caller has no better
|
|
148
|
+
* viewport. Matches the React adapter (and the RFC's default preview grid cell,
|
|
149
|
+
* §7.5) so a framework switch never resizes a card by default.
|
|
150
|
+
*/
|
|
151
|
+
defaultViewport = { width: 400, height: 300 };
|
|
152
|
+
/**
|
|
153
|
+
* The framework directive `conjure` injects into the generation prompt (AC4):
|
|
154
|
+
* name the target framework and the Vue SFC shape the model should emit. Asking
|
|
155
|
+
* for an **exported** props interface makes {@link extractDts} productive (it
|
|
156
|
+
* emits the SFC script block's exported declarations), mirroring the React
|
|
157
|
+
* adapter's "exported interface" guidance.
|
|
158
|
+
*/
|
|
159
|
+
promptDirective = [
|
|
160
|
+
"Target framework: vue",
|
|
161
|
+
'Emit an idiomatic Vue 3 Single File Component (.vue) using <script setup lang="ts">. ' +
|
|
162
|
+
"Type props by passing an exported interface to defineProps (e.g. " +
|
|
163
|
+
"`defineProps<ButtonProps>()`) so the component's prop types are recoverable, and " +
|
|
164
|
+
"declare events with defineEmits.",
|
|
165
|
+
].join("\n");
|
|
166
|
+
/**
|
|
167
|
+
* The canonical source file: `<Name>.vue`, carrying the model-authored SFC
|
|
168
|
+
* verbatim. `text/x-vue` matches the MIME the kit-file classifier already maps
|
|
169
|
+
* `.vue` to (`store/kit-files.ts`), so an adapter-emitted source and a
|
|
170
|
+
* store-read source report the same type.
|
|
171
|
+
*/
|
|
172
|
+
renderSource(input) {
|
|
173
|
+
return {
|
|
174
|
+
path: componentPath(input, `${input.componentName}.vue`),
|
|
175
|
+
content: input.source,
|
|
176
|
+
mimeType: "text/x-vue",
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Bundle the SFC to a browser-ready **IIFE** exposing the compiled component on
|
|
181
|
+
* `globalThis.${PREVIEW_GLOBAL_NAME}` (`{ default, <Name> }`). The pipeline
|
|
182
|
+
* mirrors what `@vitejs/plugin-vue` does — compile the script and the template
|
|
183
|
+
* as *separate* modules and stitch them — so it renders every SFC shape
|
|
184
|
+
* (`<script setup>`, options-API `<script>`, and template-only) identically:
|
|
185
|
+
*
|
|
186
|
+
* 1. `@vue/compiler-sfc#parse` → SFC descriptor.
|
|
187
|
+
* 2. `compileScript({ inlineTemplate: false })` lowers `<script setup>` (or a
|
|
188
|
+
* plain options-API `<script>`) to the component object, exposing its
|
|
189
|
+
* `bindings` so the template can bind setup state correctly. `inlineTemplate`
|
|
190
|
+
* is deliberately **off**: it only bakes the template into `<script setup>`
|
|
191
|
+
* output — for an options-API `<script>` it silently drops the render
|
|
192
|
+
* function, leaving a component that mounts to nothing.
|
|
193
|
+
* 3. `compileTemplate` compiles `<template>` to a standalone `render`, fed the
|
|
194
|
+
* script's `bindings` (so `<script setup>` refs resolve) and the scope id,
|
|
195
|
+
* then assigned onto the component. A template-only SFC starts from an empty
|
|
196
|
+
* component object; a script-only SFC skips this step.
|
|
197
|
+
* 4. `<style scoped>` blocks are compiled with the matching scope id and
|
|
198
|
+
* inlined as a guarded runtime `<style>` injection so the preview is a
|
|
199
|
+
* single self-contained script (the interface returns one file).
|
|
200
|
+
* 5. esbuild bundles it to an IIFE, rewriting `"vue"` → `window.Vue` via
|
|
201
|
+
* {@link hostVueGlobalPlugin} — no `require("vue")` at runtime.
|
|
202
|
+
*
|
|
203
|
+
* The SFC compiler, esbuild and ts-morph are all imported lazily so resolving a
|
|
204
|
+
* `VueAdapter` never pulls them until a preview is actually built.
|
|
205
|
+
*/
|
|
206
|
+
async renderPreview(input) {
|
|
207
|
+
const { parse, compileScript, compileStyle, compileTemplate } = await import("@vue/compiler-sfc");
|
|
208
|
+
const esbuild = (await import("esbuild")).default;
|
|
209
|
+
const filename = `${input.componentName}.vue`;
|
|
210
|
+
const { descriptor, errors } = parse(input.source, { filename });
|
|
211
|
+
if (errors.length > 0) {
|
|
212
|
+
throw new Error(`Vue SFC parse failed for ${filename}: ${errors.map((e) => String(e)).join("; ")}`);
|
|
213
|
+
}
|
|
214
|
+
if (!descriptor.scriptSetup && !descriptor.script && !descriptor.template) {
|
|
215
|
+
throw new Error(`Vue SFC ${filename} has neither a <script> nor a <template> block to render.`);
|
|
216
|
+
}
|
|
217
|
+
const id = scopeHash(input);
|
|
218
|
+
const scopeId = `data-v-${id}`;
|
|
219
|
+
const hasScoped = descriptor.styles.some((s) => s.scoped);
|
|
220
|
+
// The identifier the compiled component is bound to before we re-export it —
|
|
221
|
+
// renaming `export default` (via `genDefaultAs`) lets us attach `render` /
|
|
222
|
+
// `__scopeId` and re-export under both `default` and the component name.
|
|
223
|
+
const COMPONENT_BINDING = "__genie_component__";
|
|
224
|
+
// ── 2. script (setup or options API) → component object + binding metadata ─
|
|
225
|
+
const moduleParts = [];
|
|
226
|
+
// `BindingMetadata | undefined` — passed to compileTemplate so a `<script
|
|
227
|
+
// setup>` binding referenced in the template resolves to the right access.
|
|
228
|
+
let bindings;
|
|
229
|
+
if (descriptor.scriptSetup || descriptor.script) {
|
|
230
|
+
const script = compileScript(descriptor, {
|
|
231
|
+
id,
|
|
232
|
+
inlineTemplate: false,
|
|
233
|
+
genDefaultAs: COMPONENT_BINDING,
|
|
234
|
+
});
|
|
235
|
+
bindings = script.bindings;
|
|
236
|
+
moduleParts.push(script.content);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
// Template-only SFC: start from a bare component object the render attaches to.
|
|
240
|
+
moduleParts.push(`const ${COMPONENT_BINDING} = {};`);
|
|
241
|
+
}
|
|
242
|
+
// ── 3. template → standalone render, assigned onto the component ───────────
|
|
243
|
+
if (descriptor.template) {
|
|
244
|
+
const template = compileTemplate({
|
|
245
|
+
source: descriptor.template.content,
|
|
246
|
+
filename,
|
|
247
|
+
id,
|
|
248
|
+
scoped: hasScoped,
|
|
249
|
+
compilerOptions: {
|
|
250
|
+
bindingMetadata: bindings,
|
|
251
|
+
...(hasScoped ? { scopeId } : {}),
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
if (template.errors.length > 0) {
|
|
255
|
+
throw new Error(`Vue template compile failed for ${filename}: ` +
|
|
256
|
+
template.errors.map((e) => String(e)).join("; "));
|
|
257
|
+
}
|
|
258
|
+
// compileTemplate emits `export function render(...)`; drop the `export` so
|
|
259
|
+
// it is a local we can assign onto the component binding.
|
|
260
|
+
moduleParts.push(template.code.replace(/\bexport function render/, "function render"));
|
|
261
|
+
moduleParts.push(`${COMPONENT_BINDING}.render = render;`);
|
|
262
|
+
}
|
|
263
|
+
// ── 4. styles (scoped + plain), compiled and concatenated ─────────────────
|
|
264
|
+
let css = "";
|
|
265
|
+
for (const style of descriptor.styles) {
|
|
266
|
+
const compiled = compileStyle({
|
|
267
|
+
source: style.content,
|
|
268
|
+
filename,
|
|
269
|
+
id: scopeId,
|
|
270
|
+
scoped: style.scoped,
|
|
271
|
+
});
|
|
272
|
+
if (compiled.errors.length > 0) {
|
|
273
|
+
throw new Error(`Vue style compile failed for ${filename}: ` +
|
|
274
|
+
compiled.errors.map((e) => String(e)).join("; "));
|
|
275
|
+
}
|
|
276
|
+
css += `${compiled.code}\n`;
|
|
277
|
+
}
|
|
278
|
+
// ── assemble the esbuild entry ────────────────────────────────────────────
|
|
279
|
+
const entry = [
|
|
280
|
+
...moduleParts,
|
|
281
|
+
hasScoped ? `${COMPONENT_BINDING}.__scopeId = ${JSON.stringify(scopeId)};` : "",
|
|
282
|
+
css.trim() ? styleInjectorSnippet(css, id) : "",
|
|
283
|
+
`export default ${COMPONENT_BINDING};`,
|
|
284
|
+
`export const ${input.componentName} = ${COMPONENT_BINDING};`,
|
|
285
|
+
]
|
|
286
|
+
.filter(Boolean)
|
|
287
|
+
.join("\n");
|
|
288
|
+
// ── 5. bundle to a host-global IIFE ───────────────────────────────────────
|
|
289
|
+
const result = await esbuild.build({
|
|
290
|
+
stdin: {
|
|
291
|
+
contents: entry,
|
|
292
|
+
loader: "ts",
|
|
293
|
+
sourcefile: `${input.componentName}.vue.ts`,
|
|
294
|
+
resolveDir: process.cwd(),
|
|
295
|
+
},
|
|
296
|
+
bundle: true,
|
|
297
|
+
write: false,
|
|
298
|
+
format: "iife",
|
|
299
|
+
globalName: PREVIEW_GLOBAL_NAME,
|
|
300
|
+
platform: "browser",
|
|
301
|
+
// `vue` is rewritten to the preview host's browser global (window.Vue)
|
|
302
|
+
// rather than inlined or left as a throwing `require("vue")` — see the
|
|
303
|
+
// Preview host contract.
|
|
304
|
+
plugins: [hostVueGlobalPlugin()],
|
|
305
|
+
logLevel: "silent",
|
|
306
|
+
});
|
|
307
|
+
const output = result.outputFiles[0];
|
|
308
|
+
if (!output) {
|
|
309
|
+
// esbuild returns at least one output file on success; this guards the
|
|
310
|
+
// types, it is not an expected runtime branch.
|
|
311
|
+
throw new Error("esbuild produced no preview output for the Vue component.");
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
path: componentPath(input, `${input.componentName}.preview.js`),
|
|
315
|
+
content: output.text,
|
|
316
|
+
mimeType: "text/javascript",
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Extract the component's `.d.ts` typings with ts-morph (parity with React), via
|
|
321
|
+
* an in-memory declaration-only emit so nothing touches disk. Vue's props/emits
|
|
322
|
+
* live in the SFC's `<script setup>` (and/or `<script>`) block; this feeds those
|
|
323
|
+
* blocks' TypeScript to ts-morph and emits the **exported** declarations — so a
|
|
324
|
+
* component that exports its props interface (as the `promptDirective` asks)
|
|
325
|
+
* yields that interface in its `.d.ts`.
|
|
326
|
+
*
|
|
327
|
+
* The `defineProps` / `defineEmits` / `withDefaults` compiler macros are left as
|
|
328
|
+
* unresolved identifiers, but we never type-check — only emit declarations
|
|
329
|
+
* (`skipLibCheck` + `emitDeclarationOnly`) — so their presence never blocks the
|
|
330
|
+
* exported types from surfacing. A source with no exported declarations (inline
|
|
331
|
+
* prop types, or a template-only SFC) falls back to a valid empty module.
|
|
332
|
+
*
|
|
333
|
+
* ts-morph and the SFC parser are imported lazily for the same reason as
|
|
334
|
+
* {@link renderPreview}: keep resolving the adapter cheap.
|
|
335
|
+
*/
|
|
336
|
+
async extractDts(input) {
|
|
337
|
+
const { parse } = await import("@vue/compiler-sfc");
|
|
338
|
+
const { Project, ts } = await import("ts-morph");
|
|
339
|
+
const filename = `${input.componentName}.vue`;
|
|
340
|
+
const { descriptor } = parse(input.source, { filename });
|
|
341
|
+
const scriptContent = [descriptor.script?.content, descriptor.scriptSetup?.content]
|
|
342
|
+
.filter((c) => Boolean(c && c.trim()))
|
|
343
|
+
.join("\n");
|
|
344
|
+
const project = new Project({
|
|
345
|
+
useInMemoryFileSystem: true,
|
|
346
|
+
// `skipLibCheck` + declaration-only emit means the unresolved compiler
|
|
347
|
+
// macros / missing libs never block emission; we want the *shape*, not a
|
|
348
|
+
// clean type-check.
|
|
349
|
+
compilerOptions: {
|
|
350
|
+
declaration: true,
|
|
351
|
+
emitDeclarationOnly: true,
|
|
352
|
+
skipLibCheck: true,
|
|
353
|
+
target: ts.ScriptTarget.ES2022,
|
|
354
|
+
module: ts.ModuleKind.ESNext,
|
|
355
|
+
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
356
|
+
},
|
|
357
|
+
});
|
|
358
|
+
// `.ts` (not `.vue`): we hand ts-morph the extracted script block, which is
|
|
359
|
+
// plain TypeScript once the SFC wrapper is stripped.
|
|
360
|
+
project.createSourceFile(`${input.componentName}.ts`, scriptContent, { overwrite: true });
|
|
361
|
+
const emitted = project.emitToMemory({ emitOnlyDtsFiles: true });
|
|
362
|
+
const dtsText = emitted.getFiles().find((f) => f.filePath.endsWith(".d.ts"))?.text;
|
|
363
|
+
// Fallback: a source with no exported declarations — inline prop types
|
|
364
|
+
// (`defineProps<{…}>()`) or a template-only SFC with no script block — yields
|
|
365
|
+
// an empty or absent `.d.ts`. Emit a minimal module marker rather than an
|
|
366
|
+
// empty file so the artefact is always a valid `.d.ts`.
|
|
367
|
+
const content = dtsText && dtsText.trim().length > 0 ? dtsText : `export {};\n`;
|
|
368
|
+
return {
|
|
369
|
+
path: componentPath(input, `${input.componentName}.d.ts`),
|
|
370
|
+
content,
|
|
371
|
+
mimeType: "text/plain",
|
|
372
|
+
};
|
|
373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,8EAA8E;QAC9E,0EAA0E;QAC1E,wDAAwD;QACxD,MAAM,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC;QAChF,OAAO;YACL,IAAI,EAAE,aAAa,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,aAAa,OAAO,CAAC;YACzD,OAAO;YACP,QAAQ,EAAE,YAAY;SACvB,CAAC;IACJ,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createServer, SERVER_INFO } from "./server.js";
|
|
2
|
+
export { startTransport, isLoopbackHost, normalizeListenHost, formatHttpEndpoint, createStreamableHttpRequestHandler, registerServerDisposer, resolvePreviewLocality, resolveTransport, type TransportKind, type StartOptions, type StreamableHttpHandlerOptions, } from "./transport.js";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACL,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,kCAAkC,EAClC,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,4BAA4B,GAClC,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createServer, SERVER_INFO } from "./server.js";
|
|
2
|
+
export { startTransport, isLoopbackHost, normalizeListenHost, formatHttpEndpoint, createStreamableHttpRequestHandler, registerServerDisposer, resolvePreviewLocality, resolveTransport, } from "./transport.js";
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EACL,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,kCAAkC,EAClC,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,GAIjB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM client wrapper (M2-01) — genie's single point of contact with the
|
|
3
|
+
* operator's configured OpenAI-compatible chat-completions endpoint.
|
|
4
|
+
*
|
|
5
|
+
* genie calls a **configurable**
|
|
6
|
+
* OpenAI-compatible endpoint. LiteLLM is the reference gateway, but Ollama /
|
|
7
|
+
* OpenAI / vLLM / any compatible endpoint work the same way — no provider URL
|
|
8
|
+
* or API key is ever hardcoded here. Both come from env vars
|
|
9
|
+
* (`GENIE_LLM_BASE_URL` / `GENIE_LLM_API_KEY`), validated at construction so a
|
|
10
|
+
* misconfigured deployment fails fast (`MissingLLMConfigError`) rather than
|
|
11
|
+
* failing confusingly deep inside a generation call.
|
|
12
|
+
*
|
|
13
|
+
* All future generation verbs (`conjure` / `refine`, M2-03/M2-04) call through
|
|
14
|
+
* `createChatCompletion` rather than importing the `openai` SDK directly, so
|
|
15
|
+
* this module is the one place that knows about env vars, timeouts, and
|
|
16
|
+
* request logging for LLM calls.
|
|
17
|
+
*
|
|
18
|
+
* Out of scope (per the M2-01 issue): retry/backoff (M2-06) — `withRetry` in
|
|
19
|
+
* a later issue wraps `createChatCompletion` itself — and structured-output
|
|
20
|
+
* schema validation (M2-07).
|
|
21
|
+
*/
|
|
22
|
+
import OpenAI from "openai";
|
|
23
|
+
/** Base URL of the operator's OpenAI-compatible endpoint. No default (AC3). */
|
|
24
|
+
export declare const GENIE_LLM_BASE_URL_ENV = "GENIE_LLM_BASE_URL";
|
|
25
|
+
/** API key/token for the configured endpoint. No default (AC3). */
|
|
26
|
+
export declare const GENIE_LLM_API_KEY_ENV = "GENIE_LLM_API_KEY";
|
|
27
|
+
/** Per-request timeout override, in milliseconds. */
|
|
28
|
+
export declare const GENIE_LLM_REQUEST_TIMEOUT_MS_ENV = "GENIE_LLM_REQUEST_TIMEOUT_MS";
|
|
29
|
+
/** Default request timeout: 120 000 ms (AC5). */
|
|
30
|
+
export declare const DEFAULT_LLM_REQUEST_TIMEOUT_MS = 120000;
|
|
31
|
+
/**
|
|
32
|
+
* Thrown when one or both required LLM env vars are unset (AC2). Callers
|
|
33
|
+
* should let this propagate at startup — there is no safe fallback endpoint
|
|
34
|
+
* to construct a client against (AC3).
|
|
35
|
+
*/
|
|
36
|
+
export declare class MissingLLMConfigError extends Error {
|
|
37
|
+
readonly missing: readonly string[];
|
|
38
|
+
constructor(missing: readonly string[]);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolve `GENIE_LLM_REQUEST_TIMEOUT_MS`, falling back to the 120s default
|
|
42
|
+
* (AC5) when unset, blank, non-numeric, or non-positive. Mirrors the
|
|
43
|
+
* established fallback shape of `getPlanTTL` in `plans/index.ts`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveTimeoutMs(env?: NodeJS.ProcessEnv): number;
|
|
46
|
+
/**
|
|
47
|
+
* Construct an `openai` SDK client from env vars (AC1). Throws
|
|
48
|
+
* `MissingLLMConfigError` synchronously if `GENIE_LLM_BASE_URL` or
|
|
49
|
+
* `GENIE_LLM_API_KEY` is unset or blank (AC2/AC3) — no default base URL is
|
|
50
|
+
* ever substituted.
|
|
51
|
+
*
|
|
52
|
+
* Exported as a factory (in addition to the `llmClient` singleton below) so
|
|
53
|
+
* tests can construct additional clients against a stub server, and so a
|
|
54
|
+
* future preflight/health-check path can validate config without relying on
|
|
55
|
+
* module-load side effects.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createLLMClient(env?: NodeJS.ProcessEnv): OpenAI;
|
|
58
|
+
/**
|
|
59
|
+
* The shared `openai` client every generation verb calls through (AC1).
|
|
60
|
+
* Constructed once at module load from env vars — a deployment missing
|
|
61
|
+
* `GENIE_LLM_BASE_URL`/`GENIE_LLM_API_KEY` fails the moment anything imports
|
|
62
|
+
* this module, rather than partway through a generation request.
|
|
63
|
+
*/
|
|
64
|
+
export declare const llmClient: OpenAI;
|
|
65
|
+
/** Input accepted by {@link createChatCompletion} — a non-streaming chat-completion request. */
|
|
66
|
+
export type ChatCompletionInput = OpenAI.ChatCompletionCreateParamsNonStreaming;
|
|
67
|
+
/** Result returned by {@link createChatCompletion}. */
|
|
68
|
+
export type ChatCompletionResult = OpenAI.ChatCompletion;
|
|
69
|
+
/**
|
|
70
|
+
* Thin wrapper around `llmClient.chat.completions.create` (AC4). Emits a
|
|
71
|
+
* structured `{ model, promptTokens, completionTokens, latencyMs }` log line
|
|
72
|
+
* to **stderr** on success — never stdout, which on the stdio transport *is*
|
|
73
|
+
* the JSON-RPC protocol stream (see `transport.ts` / `tools/plan.ts`'s audit
|
|
74
|
+
* log for the same convention).
|
|
75
|
+
*
|
|
76
|
+
* Does not retry and does not swallow errors: a rejected `create()` call
|
|
77
|
+
* propagates to the caller untouched so M2-06's `withRetry(createChatCompletion)`
|
|
78
|
+
* can wrap this function directly.
|
|
79
|
+
*/
|
|
80
|
+
export declare function createChatCompletion(input: ChatCompletionInput): Promise<ChatCompletionResult>;
|
|
81
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/llm/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAI5B,+EAA+E;AAC/E,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;AAC3D,mEAAmE;AACnE,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,qDAAqD;AACrD,eAAO,MAAM,gCAAgC,iCAAiC,CAAC;AAE/E,iDAAiD;AACjD,eAAO,MAAM,8BAA8B,SAAU,CAAC;AAItD;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;aAClB,OAAO,EAAE,SAAS,MAAM,EAAE;gBAA1B,OAAO,EAAE,SAAS,MAAM,EAAE;CASvD;AAID;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAS7E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CA+B5E;AAID;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,MAA0B,CAAC;AAInD,gGAAgG;AAChG,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,sCAAsC,CAAC;AAChF,uDAAuD;AACvD,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,cAAc,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,oBAAoB,CAAC,CAgB/B"}
|