@lynx-js/genui 0.0.1-rc.0
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/LICENSE +202 -0
- package/README.md +170 -0
- package/a2ui/README.md +140 -0
- package/a2ui/dist/catalog/Button/catalog.json +156 -0
- package/a2ui/dist/catalog/Button/index.d.ts +35 -0
- package/a2ui/dist/catalog/Button/index.js +35 -0
- package/a2ui/dist/catalog/Button/index.js.map +1 -0
- package/a2ui/dist/catalog/Card/catalog.json +24 -0
- package/a2ui/dist/catalog/Card/index.d.ts +11 -0
- package/a2ui/dist/catalog/Card/index.js +19 -0
- package/a2ui/dist/catalog/Card/index.js.map +1 -0
- package/a2ui/dist/catalog/CheckBox/catalog.json +170 -0
- package/a2ui/dist/catalog/CheckBox/index.d.ts +32 -0
- package/a2ui/dist/catalog/CheckBox/index.js +24 -0
- package/a2ui/dist/catalog/CheckBox/index.js.map +1 -0
- package/a2ui/dist/catalog/Column/catalog.json +57 -0
- package/a2ui/dist/catalog/Column/index.d.ts +15 -0
- package/a2ui/dist/catalog/Column/index.js +55 -0
- package/a2ui/dist/catalog/Column/index.js.map +1 -0
- package/a2ui/dist/catalog/Divider/catalog.json +14 -0
- package/a2ui/dist/catalog/Divider/index.d.ts +9 -0
- package/a2ui/dist/catalog/Divider/index.js +8 -0
- package/a2ui/dist/catalog/Divider/index.js.map +1 -0
- package/a2ui/dist/catalog/Icon/catalog.json +45 -0
- package/a2ui/dist/catalog/Icon/index.d.ts +14 -0
- package/a2ui/dist/catalog/Icon/index.js +11 -0
- package/a2ui/dist/catalog/Icon/index.js.map +1 -0
- package/a2ui/dist/catalog/Image/catalog.json +62 -0
- package/a2ui/dist/catalog/Image/index.d.ts +16 -0
- package/a2ui/dist/catalog/Image/index.js +30 -0
- package/a2ui/dist/catalog/Image/index.js.map +1 -0
- package/a2ui/dist/catalog/LineChart/catalog.json +98 -0
- package/a2ui/dist/catalog/LineChart/index.d.ts +31 -0
- package/a2ui/dist/catalog/LineChart/index.js +195 -0
- package/a2ui/dist/catalog/LineChart/index.js.map +1 -0
- package/a2ui/dist/catalog/List/catalog.json +52 -0
- package/a2ui/dist/catalog/List/index.d.ts +15 -0
- package/a2ui/dist/catalog/List/index.js +53 -0
- package/a2ui/dist/catalog/List/index.js.map +1 -0
- package/a2ui/dist/catalog/Modal/catalog.json +18 -0
- package/a2ui/dist/catalog/Modal/index.d.ts +12 -0
- package/a2ui/dist/catalog/Modal/index.js +33 -0
- package/a2ui/dist/catalog/Modal/index.js.map +1 -0
- package/a2ui/dist/catalog/PieChart/catalog.json +87 -0
- package/a2ui/dist/catalog/PieChart/index.d.ts +37 -0
- package/a2ui/dist/catalog/PieChart/index.js +131 -0
- package/a2ui/dist/catalog/PieChart/index.js.map +1 -0
- package/a2ui/dist/catalog/RadioGroup/catalog.json +184 -0
- package/a2ui/dist/catalog/RadioGroup/index.d.ts +36 -0
- package/a2ui/dist/catalog/RadioGroup/index.js +36 -0
- package/a2ui/dist/catalog/RadioGroup/index.js.map +1 -0
- package/a2ui/dist/catalog/Row/catalog.json +57 -0
- package/a2ui/dist/catalog/Row/index.d.ts +15 -0
- package/a2ui/dist/catalog/Row/index.js +28 -0
- package/a2ui/dist/catalog/Row/index.js.map +1 -0
- package/a2ui/dist/catalog/Slider/catalog.json +183 -0
- package/a2ui/dist/catalog/Slider/index.d.ts +41 -0
- package/a2ui/dist/catalog/Slider/index.js +39 -0
- package/a2ui/dist/catalog/Slider/index.js.map +1 -0
- package/a2ui/dist/catalog/Slider/utils.d.ts +11 -0
- package/a2ui/dist/catalog/Slider/utils.js +58 -0
- package/a2ui/dist/catalog/Slider/utils.js.map +1 -0
- package/a2ui/dist/catalog/Tabs/catalog.json +28 -0
- package/a2ui/dist/catalog/Tabs/index.d.ts +12 -0
- package/a2ui/dist/catalog/Tabs/index.js +32 -0
- package/a2ui/dist/catalog/Tabs/index.js.map +1 -0
- package/a2ui/dist/catalog/Text/catalog.json +74 -0
- package/a2ui/dist/catalog/Text/index.d.ts +18 -0
- package/a2ui/dist/catalog/Text/index.js +27 -0
- package/a2ui/dist/catalog/Text/index.js.map +1 -0
- package/a2ui/dist/catalog/TextField/catalog.json +147 -0
- package/a2ui/dist/catalog/TextField/index.d.ts +35 -0
- package/a2ui/dist/catalog/TextField/index.js +43 -0
- package/a2ui/dist/catalog/TextField/index.js.map +1 -0
- package/a2ui/dist/catalog/TextField/utils.d.ts +7 -0
- package/a2ui/dist/catalog/TextField/utils.js +51 -0
- package/a2ui/dist/catalog/TextField/utils.js.map +1 -0
- package/a2ui/dist/catalog/defineCatalog.d.ts +119 -0
- package/a2ui/dist/catalog/defineCatalog.js +196 -0
- package/a2ui/dist/catalog/defineCatalog.js.map +1 -0
- package/a2ui/dist/catalog/index.d.ts +20 -0
- package/a2ui/dist/catalog/index.js +26 -0
- package/a2ui/dist/catalog/index.js.map +1 -0
- package/a2ui/dist/catalog/utils/chart.d.ts +3 -0
- package/a2ui/dist/catalog/utils/chart.js +28 -0
- package/a2ui/dist/catalog/utils/chart.js.map +1 -0
- package/a2ui/dist/functions/index.d.ts +19 -0
- package/a2ui/dist/functions/index.js +87 -0
- package/a2ui/dist/functions/index.js.map +1 -0
- package/a2ui/dist/index.d.ts +11 -0
- package/a2ui/dist/index.js +35 -0
- package/a2ui/dist/index.js.map +1 -0
- package/a2ui/dist/react/A2UI.d.ts +77 -0
- package/a2ui/dist/react/A2UI.js +159 -0
- package/a2ui/dist/react/A2UI.js.map +1 -0
- package/a2ui/dist/react/A2UIProvider.d.ts +25 -0
- package/a2ui/dist/react/A2UIProvider.js +20 -0
- package/a2ui/dist/react/A2UIProvider.js.map +1 -0
- package/a2ui/dist/react/A2UIRenderer.d.ts +34 -0
- package/a2ui/dist/react/A2UIRenderer.js +161 -0
- package/a2ui/dist/react/A2UIRenderer.js.map +1 -0
- package/a2ui/dist/react/FormContext.d.ts +10 -0
- package/a2ui/dist/react/FormContext.js +12 -0
- package/a2ui/dist/react/FormContext.js.map +1 -0
- package/a2ui/dist/react/index.d.ts +8 -0
- package/a2ui/dist/react/index.js +23 -0
- package/a2ui/dist/react/index.js.map +1 -0
- package/a2ui/dist/react/useA2UIContext.d.ts +7 -0
- package/a2ui/dist/react/useA2UIContext.js +19 -0
- package/a2ui/dist/react/useA2UIContext.js.map +1 -0
- package/a2ui/dist/react/useAction.d.ts +9 -0
- package/a2ui/dist/react/useAction.js +38 -0
- package/a2ui/dist/react/useAction.js.map +1 -0
- package/a2ui/dist/react/useCatalog.d.ts +7 -0
- package/a2ui/dist/react/useCatalog.js +13 -0
- package/a2ui/dist/react/useCatalog.js.map +1 -0
- package/a2ui/dist/react/useChecks.d.ts +27 -0
- package/a2ui/dist/react/useChecks.js +76 -0
- package/a2ui/dist/react/useChecks.js.map +1 -0
- package/a2ui/dist/react/useDataBinding.d.ts +10 -0
- package/a2ui/dist/react/useDataBinding.js +175 -0
- package/a2ui/dist/react/useDataBinding.js.map +1 -0
- package/a2ui/dist/store/FormController.d.ts +23 -0
- package/a2ui/dist/store/FormController.js +40 -0
- package/a2ui/dist/store/FormController.js.map +1 -0
- package/a2ui/dist/store/FunctionRegistry.d.ts +47 -0
- package/a2ui/dist/store/FunctionRegistry.js +23 -0
- package/a2ui/dist/store/FunctionRegistry.js.map +1 -0
- package/a2ui/dist/store/MessageProcessor.d.ts +28 -0
- package/a2ui/dist/store/MessageProcessor.js +408 -0
- package/a2ui/dist/store/MessageProcessor.js.map +1 -0
- package/a2ui/dist/store/MessageStore.d.ts +38 -0
- package/a2ui/dist/store/MessageStore.js +37 -0
- package/a2ui/dist/store/MessageStore.js.map +1 -0
- package/a2ui/dist/store/Resource.d.ts +45 -0
- package/a2ui/dist/store/Resource.js +80 -0
- package/a2ui/dist/store/Resource.js.map +1 -0
- package/a2ui/dist/store/SignalStore.d.ts +10 -0
- package/a2ui/dist/store/SignalStore.js +29 -0
- package/a2ui/dist/store/SignalStore.js.map +1 -0
- package/a2ui/dist/store/index.d.ts +14 -0
- package/a2ui/dist/store/index.js +15 -0
- package/a2ui/dist/store/index.js.map +1 -0
- package/a2ui/dist/store/payloadNormalizer.d.ts +27 -0
- package/a2ui/dist/store/payloadNormalizer.js +179 -0
- package/a2ui/dist/store/payloadNormalizer.js.map +1 -0
- package/a2ui/dist/store/resolveFunctionCall.d.ts +18 -0
- package/a2ui/dist/store/resolveFunctionCall.js +131 -0
- package/a2ui/dist/store/resolveFunctionCall.js.map +1 -0
- package/a2ui/dist/store/types.d.ts +68 -0
- package/a2ui/dist/store/types.js +2 -0
- package/a2ui/dist/store/types.js.map +1 -0
- package/a2ui/dist/tsconfig.build.tsbuildinfo +1 -0
- package/a2ui/styles/catalog/Button.css +83 -0
- package/a2ui/styles/catalog/Card.css +49 -0
- package/a2ui/styles/catalog/CheckBox.css +46 -0
- package/a2ui/styles/catalog/Column.css +89 -0
- package/a2ui/styles/catalog/Divider.css +20 -0
- package/a2ui/styles/catalog/Icon.css +39 -0
- package/a2ui/styles/catalog/Image.css +54 -0
- package/a2ui/styles/catalog/LineChart.css +116 -0
- package/a2ui/styles/catalog/List.css +38 -0
- package/a2ui/styles/catalog/Modal.css +60 -0
- package/a2ui/styles/catalog/PieChart.css +109 -0
- package/a2ui/styles/catalog/RadioGroup.css +123 -0
- package/a2ui/styles/catalog/Row.css +83 -0
- package/a2ui/styles/catalog/Slider.css +96 -0
- package/a2ui/styles/catalog/Tabs.css +46 -0
- package/a2ui/styles/catalog/Text.css +121 -0
- package/a2ui/styles/catalog/TextField.css +48 -0
- package/a2ui/styles/theme.css +62 -0
- package/a2ui-catalog-extractor/README.md +605 -0
- package/a2ui-catalog-extractor/bin/a2ui-catalog-extractor.js +6 -0
- package/a2ui-catalog-extractor/dist/cli.d.ts +12 -0
- package/a2ui-catalog-extractor/dist/cli.js +171 -0
- package/a2ui-catalog-extractor/dist/cli.js.map +1 -0
- package/a2ui-catalog-extractor/dist/index.d.ts +140 -0
- package/a2ui-catalog-extractor/dist/index.js +755 -0
- package/a2ui-catalog-extractor/dist/index.js.map +1 -0
- package/a2ui-catalog-extractor/dist/tsconfig.build.tsbuildinfo +1 -0
- package/a2ui-catalog-extractor/skills/a2ui-catalog-extractor/SKILL.md +30 -0
- package/a2ui-prompt/README.md +65 -0
- package/a2ui-prompt/dist/index.d.ts +91 -0
- package/a2ui-prompt/dist/index.js +767 -0
- package/cli/README.md +88 -0
- package/cli/bin/cli.js +271 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/index.ts +114 -0
- package/openui/README.md +211 -0
- package/openui/dist/catalog/Action/index.d.ts +20 -0
- package/openui/dist/catalog/Action/index.js +23 -0
- package/openui/dist/catalog/Action/index.js.map +1 -0
- package/openui/dist/catalog/Button/index.d.ts +64 -0
- package/openui/dist/catalog/Button/index.js +75 -0
- package/openui/dist/catalog/Button/index.js.map +1 -0
- package/openui/dist/catalog/Card/index.d.ts +34 -0
- package/openui/dist/catalog/Card/index.js +69 -0
- package/openui/dist/catalog/Card/index.js.map +1 -0
- package/openui/dist/catalog/CardHeader/index.d.ts +5 -0
- package/openui/dist/catalog/CardHeader/index.js +18 -0
- package/openui/dist/catalog/CardHeader/index.js.map +1 -0
- package/openui/dist/catalog/Separator/index.d.ts +2 -0
- package/openui/dist/catalog/Separator/index.js +13 -0
- package/openui/dist/catalog/Separator/index.js.map +1 -0
- package/openui/dist/catalog/Stack/index.d.ts +29 -0
- package/openui/dist/catalog/Stack/index.js +61 -0
- package/openui/dist/catalog/Stack/index.js.map +1 -0
- package/openui/dist/catalog/Tag/index.d.ts +4 -0
- package/openui/dist/catalog/Tag/index.js +15 -0
- package/openui/dist/catalog/Tag/index.js.map +1 -0
- package/openui/dist/catalog/TextContent/index.d.ts +11 -0
- package/openui/dist/catalog/TextContent/index.js +33 -0
- package/openui/dist/catalog/TextContent/index.js.map +1 -0
- package/openui/dist/catalog/index.d.ts +7 -0
- package/openui/dist/catalog/index.js +11 -0
- package/openui/dist/catalog/index.js.map +1 -0
- package/openui/dist/catalog/utils.d.ts +2 -0
- package/openui/dist/catalog/utils.js +17 -0
- package/openui/dist/catalog/utils.js.map +1 -0
- package/openui/dist/core/context.d.ts +112 -0
- package/openui/dist/core/context.js +99 -0
- package/openui/dist/core/context.js.map +1 -0
- package/openui/dist/core/createLibrary.d.ts +10 -0
- package/openui/dist/core/createLibrary.js +36 -0
- package/openui/dist/core/createLibrary.js.map +1 -0
- package/openui/dist/core/hooks/index.d.ts +4 -0
- package/openui/dist/core/hooks/index.js +6 -0
- package/openui/dist/core/hooks/index.js.map +1 -0
- package/openui/dist/core/hooks/useFormValidation.d.ts +13 -0
- package/openui/dist/core/hooks/useFormValidation.js +76 -0
- package/openui/dist/core/hooks/useFormValidation.js.map +1 -0
- package/openui/dist/core/hooks/useOpenUIState.d.ts +33 -0
- package/openui/dist/core/hooks/useOpenUIState.js +413 -0
- package/openui/dist/core/hooks/useOpenUIState.js.map +1 -0
- package/openui/dist/core/hooks/useStateField.d.ts +2 -0
- package/openui/dist/core/hooks/useStateField.js +11 -0
- package/openui/dist/core/hooks/useStateField.js.map +1 -0
- package/openui/dist/core/index.d.ts +7 -0
- package/openui/dist/core/index.js +8 -0
- package/openui/dist/core/index.js.map +1 -0
- package/openui/dist/core/library.d.ts +20 -0
- package/openui/dist/core/library.js +13 -0
- package/openui/dist/core/library.js.map +1 -0
- package/openui/dist/core/renderer.css +271 -0
- package/openui/dist/core/renderer.d.ts +9 -0
- package/openui/dist/core/renderer.js +139 -0
- package/openui/dist/core/renderer.js.map +1 -0
- package/openui/dist/core/utils.d.ts +1 -0
- package/openui/dist/core/utils.js +76 -0
- package/openui/dist/core/utils.js.map +1 -0
- package/package.json +120 -0
package/cli/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# GenUI CLI
|
|
2
|
+
|
|
3
|
+
`@lynx-js/genui-cli` is the command line entry point for GenUI workflows. It is
|
|
4
|
+
structured by namespace so A2UI commands can live beside future OpenUI commands
|
|
5
|
+
without adding another package or binary.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
genui <namespace> <command> [options]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Available namespaces:
|
|
14
|
+
|
|
15
|
+
- `a2ui`: generate A2UI catalog artifacts and system prompts.
|
|
16
|
+
- `openui`: reserved for future OpenUI workflows.
|
|
17
|
+
|
|
18
|
+
The package also exposes `genui-cli` as an alias. `a2ui-cli` remains available as
|
|
19
|
+
a compatibility alias for existing A2UI-only scripts.
|
|
20
|
+
|
|
21
|
+
## A2UI Commands
|
|
22
|
+
|
|
23
|
+
Generate a system prompt with the built-in A2UI basic catalog:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
genui a2ui generate prompt --out dist/a2ui-system-prompt.txt
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Generate catalog artifacts for a custom catalog:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
genui a2ui generate catalog \
|
|
33
|
+
--catalog-dir src/catalog \
|
|
34
|
+
--source src/functions \
|
|
35
|
+
--out-dir dist/catalog
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Generate a system prompt for a custom catalog:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
genui a2ui generate prompt \
|
|
42
|
+
--catalog-dir dist/catalog \
|
|
43
|
+
--catalog-id https://example.com/catalogs/custom/v1/catalog.json \
|
|
44
|
+
--out dist/a2ui-system-prompt.txt
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`generate prompt` uses the built-in A2UI basic catalog by default. Pass
|
|
48
|
+
`--catalog-dir` only when generating a prompt for custom generated catalog
|
|
49
|
+
artifacts. When `--catalog-dir` is provided, the directory must contain files
|
|
50
|
+
like `<Component>/catalog.json`.
|
|
51
|
+
|
|
52
|
+
### `genui a2ui generate catalog`
|
|
53
|
+
|
|
54
|
+
Delegates catalog extraction to `@lynx-js/genui/a2ui-catalog-extractor`.
|
|
55
|
+
|
|
56
|
+
Useful options:
|
|
57
|
+
|
|
58
|
+
- `--catalog-dir <dir>`: directory to scan for TypeScript component catalog
|
|
59
|
+
interfaces. Defaults to `src/catalog`.
|
|
60
|
+
- `--source <path>`: source file or directory to scan for catalog functions.
|
|
61
|
+
Repeatable.
|
|
62
|
+
- `--typedoc-json <file>`: read an existing TypeDoc JSON project.
|
|
63
|
+
- `--out-dir <dir>`: output directory for generated catalog artifacts. Defaults
|
|
64
|
+
to `dist/catalog`.
|
|
65
|
+
|
|
66
|
+
### `genui a2ui generate prompt`
|
|
67
|
+
|
|
68
|
+
Delegates prompt construction to `@lynx-js/genui/a2ui-prompt`.
|
|
69
|
+
|
|
70
|
+
Useful options:
|
|
71
|
+
|
|
72
|
+
- `--catalog-dir <dir>`: generated catalog artifact directory. Omit this option
|
|
73
|
+
to use the built-in A2UI basic catalog.
|
|
74
|
+
- `--catalog-id <id>`: catalog id to require in `createSurface` messages.
|
|
75
|
+
Defaults to the built-in A2UI basic catalog id.
|
|
76
|
+
- `--out <file>`: write the prompt to a file instead of stdout.
|
|
77
|
+
- `--appendix <text>`: append extra instructions to the generated prompt.
|
|
78
|
+
|
|
79
|
+
## Compatibility
|
|
80
|
+
|
|
81
|
+
Existing A2UI commands still work:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
a2ui-cli generate catalog --catalog-dir src/catalog --out-dir dist/catalog
|
|
85
|
+
a2ui-cli generate prompt --out dist/a2ui-system-prompt.txt
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
New scripts should prefer `genui a2ui ...`.
|
package/cli/bin/cli.js
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
3
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
4
|
+
// LICENSE file in the root directory of this source tree.
|
|
5
|
+
import * as fs from 'node:fs';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import * as path from 'node:path';
|
|
8
|
+
import { pathToFileURL } from 'node:url';
|
|
9
|
+
|
|
10
|
+
const usage = `Usage: genui <namespace> <command> [options]
|
|
11
|
+
|
|
12
|
+
Namespaces:
|
|
13
|
+
a2ui Generate A2UI catalog artifacts and system prompts.
|
|
14
|
+
openui Reserved for future OpenUI workflows.
|
|
15
|
+
|
|
16
|
+
Examples:
|
|
17
|
+
genui a2ui generate catalog --catalog-dir src/catalog --out-dir dist/catalog
|
|
18
|
+
genui a2ui generate prompt --out dist/a2ui-system-prompt.txt
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
const a2uiUsage = `Usage: genui a2ui generate <target> [options]
|
|
22
|
+
|
|
23
|
+
Targets:
|
|
24
|
+
catalog Generate A2UI component and function catalog files.
|
|
25
|
+
prompt Generate an A2UI system prompt from catalog files.
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
const openuiUsage = `Usage: genui openui <command> [options]
|
|
29
|
+
|
|
30
|
+
OpenUI CLI commands are reserved for future GenUI workflows.
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
function createGenerateCatalogUsage(programName) {
|
|
34
|
+
return `Usage: ${programName} generate catalog [options]
|
|
35
|
+
|
|
36
|
+
Options:
|
|
37
|
+
--catalog-dir <dir> Directory to scan for TypeScript catalog interfaces.
|
|
38
|
+
--source <path> Source file or directory to scan. Repeatable.
|
|
39
|
+
--typedoc-json <file>
|
|
40
|
+
Read an existing TypeDoc JSON project instead of
|
|
41
|
+
running TypeDoc conversion.
|
|
42
|
+
--out-dir <dir> Output directory for component catalog.json files.
|
|
43
|
+
--version Print the package version.
|
|
44
|
+
--help Print this help message.
|
|
45
|
+
|
|
46
|
+
Defaults:
|
|
47
|
+
--catalog-dir src/catalog
|
|
48
|
+
--out-dir dist/catalog
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function createGeneratePromptUsage(programName) {
|
|
53
|
+
return `Usage: ${programName} generate prompt [options]
|
|
54
|
+
|
|
55
|
+
Options:
|
|
56
|
+
--catalog-dir <dir> Directory containing generated catalog files. When
|
|
57
|
+
omitted, use the built-in A2UI basic catalog.
|
|
58
|
+
--catalog-id <id> Catalog id to require in createSurface messages.
|
|
59
|
+
--out <file> Write the prompt to a file instead of stdout.
|
|
60
|
+
--appendix <text> Append extra instructions to the generated prompt.
|
|
61
|
+
--version Print the package version.
|
|
62
|
+
--help Print this help message.
|
|
63
|
+
|
|
64
|
+
Defaults:
|
|
65
|
+
--catalog-id built-in A2UI basic catalog id
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (isMain(import.meta.url)) {
|
|
70
|
+
try {
|
|
71
|
+
process.exitCode = await runCli(process.argv.slice(2), process.cwd(), {
|
|
72
|
+
binName: path.basename(process.argv[1] ?? 'genui'),
|
|
73
|
+
});
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
76
|
+
process.exitCode = 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function runCli(args, cwd = process.cwd(), cliOptions = {}) {
|
|
81
|
+
const binName = cliOptions.binName ?? 'genui';
|
|
82
|
+
if (binName === 'a2ui-cli') {
|
|
83
|
+
return await runA2UICli(args, cwd, { programName: 'a2ui-cli' });
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const command = args[0];
|
|
87
|
+
if (command === undefined || command === '--help' || command === '-h') {
|
|
88
|
+
console.info(usage);
|
|
89
|
+
return 0;
|
|
90
|
+
}
|
|
91
|
+
if (command === '--version' || command === '-v') {
|
|
92
|
+
printPackageVersion();
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (command === 'a2ui') {
|
|
97
|
+
return await runA2UICli(args.slice(1), cwd, { programName: 'genui a2ui' });
|
|
98
|
+
}
|
|
99
|
+
if (command === 'openui') {
|
|
100
|
+
return runOpenUICli(args.slice(1));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
throw new Error(`Unknown namespace: ${command}`);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function runA2UICli(args, cwd, options) {
|
|
107
|
+
const programName = options.programName;
|
|
108
|
+
const command = args[0];
|
|
109
|
+
if (command === undefined || command === '--help' || command === '-h') {
|
|
110
|
+
console.info(programName === 'a2ui-cli' ? legacyA2UIUsage : a2uiUsage);
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
if (command === '--version' || command === '-v') {
|
|
114
|
+
printPackageVersion();
|
|
115
|
+
return 0;
|
|
116
|
+
}
|
|
117
|
+
if (command !== 'generate') {
|
|
118
|
+
throw new Error(`Unknown A2UI command: ${command}`);
|
|
119
|
+
}
|
|
120
|
+
const target = args[1];
|
|
121
|
+
const targetArgs = args.slice(2);
|
|
122
|
+
if (target === undefined || target === '--help' || target === '-h') {
|
|
123
|
+
console.info(programName === 'a2ui-cli' ? legacyA2UIUsage : a2uiUsage);
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
if (target === '--version' || target === '-v') {
|
|
127
|
+
printPackageVersion();
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
if (target === 'catalog') {
|
|
131
|
+
if (targetArgs.includes('--help') || targetArgs.includes('-h')) {
|
|
132
|
+
console.info(createGenerateCatalogUsage(programName));
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
135
|
+
const { runCli: runCatalogExtractorCli } = await import(
|
|
136
|
+
'../../a2ui-catalog-extractor/dist/cli.js'
|
|
137
|
+
);
|
|
138
|
+
return await runCatalogExtractorCli(targetArgs, cwd);
|
|
139
|
+
}
|
|
140
|
+
if (target === 'prompt') {
|
|
141
|
+
return runGeneratePromptCli(targetArgs, cwd, { programName });
|
|
142
|
+
}
|
|
143
|
+
throw new Error(`Unknown generate target: ${target}`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const legacyA2UIUsage = a2uiUsage.replaceAll('genui a2ui', 'a2ui-cli');
|
|
147
|
+
|
|
148
|
+
function runOpenUICli(args) {
|
|
149
|
+
const command = args[0];
|
|
150
|
+
if (command === undefined || command === '--help' || command === '-h') {
|
|
151
|
+
console.info(openuiUsage);
|
|
152
|
+
return 0;
|
|
153
|
+
}
|
|
154
|
+
if (command === '--version' || command === '-v') {
|
|
155
|
+
printPackageVersion();
|
|
156
|
+
return 0;
|
|
157
|
+
}
|
|
158
|
+
throw new Error(
|
|
159
|
+
`Unknown OpenUI command: ${command}. OpenUI CLI commands are not available yet.`,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async function runGeneratePromptCli(args, cwd, cliOptions) {
|
|
164
|
+
const programName = cliOptions.programName;
|
|
165
|
+
const options = parseGeneratePromptArgs(args);
|
|
166
|
+
if (options.help) {
|
|
167
|
+
console.info(createGeneratePromptUsage(programName));
|
|
168
|
+
return 0;
|
|
169
|
+
}
|
|
170
|
+
if (options.version) {
|
|
171
|
+
printPackageVersion();
|
|
172
|
+
return 0;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const {
|
|
176
|
+
BASIC_CATALOG,
|
|
177
|
+
BASIC_CATALOG_ID,
|
|
178
|
+
buildA2UISystemPrompt,
|
|
179
|
+
readA2UICatalogFromDirectory,
|
|
180
|
+
} = await import('../../a2ui-prompt/dist/index.js');
|
|
181
|
+
const catalog = options.catalogDir
|
|
182
|
+
? readA2UICatalogFromDirectory({
|
|
183
|
+
catalogDir: options.catalogDir,
|
|
184
|
+
catalogId: options.catalogId ?? BASIC_CATALOG_ID,
|
|
185
|
+
cwd,
|
|
186
|
+
})
|
|
187
|
+
: (options.catalogId
|
|
188
|
+
? { ...BASIC_CATALOG, id: options.catalogId }
|
|
189
|
+
: undefined);
|
|
190
|
+
if (options.catalogDir && catalog && isEmptyCatalog(catalog)) {
|
|
191
|
+
throw new Error(
|
|
192
|
+
`[${programName}] No components or functions found in generated catalog directory: ${options.catalogDir}`,
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
const systemPrompt = buildA2UISystemPrompt({
|
|
196
|
+
...(catalog ? { catalog } : {}),
|
|
197
|
+
...(options.appendix ? { appendix: options.appendix } : {}),
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
if (options.out) {
|
|
201
|
+
const outPath = path.resolve(cwd, options.out);
|
|
202
|
+
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|
|
203
|
+
fs.writeFileSync(outPath, systemPrompt);
|
|
204
|
+
console.info(`Generated A2UI system prompt at ${options.out}.`);
|
|
205
|
+
} else {
|
|
206
|
+
process.stdout.write(systemPrompt);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return 0;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function parseGeneratePromptArgs(args) {
|
|
213
|
+
const options = {
|
|
214
|
+
help: false,
|
|
215
|
+
version: false,
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
219
|
+
const arg = args[index];
|
|
220
|
+
switch (arg) {
|
|
221
|
+
case '--catalog-dir':
|
|
222
|
+
options.catalogDir = readValue(args, ++index, arg);
|
|
223
|
+
break;
|
|
224
|
+
case '--catalog-id':
|
|
225
|
+
options.catalogId = readValue(args, ++index, arg);
|
|
226
|
+
break;
|
|
227
|
+
case '--out':
|
|
228
|
+
options.out = readValue(args, ++index, arg);
|
|
229
|
+
break;
|
|
230
|
+
case '--appendix':
|
|
231
|
+
options.appendix = readValue(args, ++index, arg);
|
|
232
|
+
break;
|
|
233
|
+
case '--help':
|
|
234
|
+
case '-h':
|
|
235
|
+
options.help = true;
|
|
236
|
+
break;
|
|
237
|
+
case '--version':
|
|
238
|
+
case '-v':
|
|
239
|
+
options.version = true;
|
|
240
|
+
break;
|
|
241
|
+
default:
|
|
242
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return options;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function isEmptyCatalog(catalog) {
|
|
250
|
+
return (!Array.isArray(catalog.components) || catalog.components.length === 0)
|
|
251
|
+
&& (!Array.isArray(catalog.functions) || catalog.functions.length === 0);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function readValue(args, index, option) {
|
|
255
|
+
const value = args[index];
|
|
256
|
+
if (!value || value.startsWith('-')) {
|
|
257
|
+
throw new Error(`Missing value for ${option}.`);
|
|
258
|
+
}
|
|
259
|
+
return value;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function printPackageVersion() {
|
|
263
|
+
const require = createRequire(import.meta.url);
|
|
264
|
+
const packageJson = require('../package.json');
|
|
265
|
+
console.info(packageJson.version);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function isMain(moduleUrl) {
|
|
269
|
+
return process.argv[1] !== undefined
|
|
270
|
+
&& moduleUrl === pathToFileURL(process.argv[1]).href;
|
|
271
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { A2UI, NodeRenderer, useAction, useChecks, useDataBinding, useResolvedProps, } from '@lynx-js/genui/a2ui/react';
|
|
2
|
+
export type { A2UIProps, ActionProps, CheckLike, } from '@lynx-js/genui/a2ui/react';
|
|
3
|
+
export { createFallbackMessagesFromPlainText, createMessageStore, createResource, createTextCardMessages, executeFunctionCall, FunctionRegistry, functionRegistry, isDataBinding, isFunctionCall, MessageProcessor, normalizePayloadToMessages, prepareMessagesForProcessing, resolveDynamicValue, resolveFunctionArguments, SignalStore, } from '@lynx-js/genui/a2ui/store';
|
|
4
|
+
export type { A2UIClientEventMessage, A2UIEvent, ComponentInstance, FunctionCallContext, FunctionEntry, FunctionImpl, GenericComponentProps, MessageStore, MessageStoreOptions, RawResource, ResolveFunctionOptions, Resource, ResourceInfo, ResourceStatus, ServerToClientMessage, Surface, SurfaceId, UserActionPayload, } from '@lynx-js/genui/a2ui/store';
|
|
5
|
+
export { basicFunctions, registerBasicFunctions, } from '@lynx-js/genui/a2ui/functions';
|
|
6
|
+
export * from '@lynx-js/genui/openui';
|
|
7
|
+
export { A2UI_PROTOCOL_VERSION, A2UI_SYSTEM_PROMPT, BASIC_CATALOG, BASIC_CATALOG_EXAMPLES, BASIC_CATALOG_ID, buildA2UISystemPrompt, createA2UICatalogFromManifests, readA2UICatalogFromDirectory, renderCatalogReference, } from '@lynx-js/genui/a2ui-prompt';
|
|
8
|
+
export type { A2UICatalog as A2UIPromptCatalog, A2UIComponentProp, A2UIComponentSpec, A2UIExample, A2UIFunctionSpec, BuildSystemPromptOptions, JsonSchema as A2UIPromptJsonSchema, ReadA2UICatalogDirectoryOptions, } from '@lynx-js/genui/a2ui-prompt';
|
|
9
|
+
export { createA2UICatalog, extractCatalogComponents, extractCatalogComponentsFromTypeDocJson, extractCatalogComponentsFromTypeDocProject, extractCatalogFunctions, extractCatalogFunctionsFromTypeDocJson, extractCatalogFunctionsFromTypeDocProject, findCatalogSourceFiles, writeCatalogArtifacts, writeCatalogComponents, writeCatalogFunctionDefinitions, writeCatalogFunctions, writeComponentCatalogs, } from '@lynx-js/genui/a2ui-catalog-extractor';
|
|
10
|
+
export type { A2UICatalog as ExtractedA2UICatalog, CatalogArtifacts, CatalogComponent as ExtractedCatalogComponent, CatalogFunction, ExtractCatalogFromTypeDocOptions, ExtractCatalogOptions, FunctionDefinition, JsonSchema as ExtractedJsonSchema, TypeDocComment, TypeDocCommentDisplayPart, TypeDocCommentTag, TypeDocProject, TypeDocReflection, TypeDocSignature, TypeDocSource, TypeDocType, WriteComponentCatalogOptions, } from '@lynx-js/genui/a2ui-catalog-extractor';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
export { A2UI, NodeRenderer, useAction, useChecks, useDataBinding, useResolvedProps, } from '@lynx-js/genui/a2ui/react';
|
|
5
|
+
export { createFallbackMessagesFromPlainText, createMessageStore, createResource, createTextCardMessages, executeFunctionCall, FunctionRegistry, functionRegistry, isDataBinding, isFunctionCall, MessageProcessor, normalizePayloadToMessages, prepareMessagesForProcessing, resolveDynamicValue, resolveFunctionArguments, SignalStore, } from '@lynx-js/genui/a2ui/store';
|
|
6
|
+
export { basicFunctions, registerBasicFunctions, } from '@lynx-js/genui/a2ui/functions';
|
|
7
|
+
export * from '@lynx-js/genui/openui';
|
|
8
|
+
export { A2UI_PROTOCOL_VERSION, A2UI_SYSTEM_PROMPT, BASIC_CATALOG, BASIC_CATALOG_EXAMPLES, BASIC_CATALOG_ID, buildA2UISystemPrompt, createA2UICatalogFromManifests, readA2UICatalogFromDirectory, renderCatalogReference, } from '@lynx-js/genui/a2ui-prompt';
|
|
9
|
+
export { createA2UICatalog, extractCatalogComponents, extractCatalogComponentsFromTypeDocJson, extractCatalogComponentsFromTypeDocProject, extractCatalogFunctions, extractCatalogFunctionsFromTypeDocJson, extractCatalogFunctionsFromTypeDocProject, findCatalogSourceFiles, writeCatalogArtifacts, writeCatalogComponents, writeCatalogFunctionDefinitions, writeCatalogFunctions, writeComponentCatalogs, } from '@lynx-js/genui/a2ui-catalog-extractor';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,SAAS,EACT,cAAc,EACd,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAMnC,OAAO,EACL,mCAAmC,EACnC,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,0BAA0B,EAC1B,4BAA4B,EAC5B,mBAAmB,EACnB,wBAAwB,EACxB,WAAW,GACZ,MAAM,2BAA2B,CAAC;AAqBnC,OAAO,EACL,cAAc,EACd,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,8BAA8B,EAC9B,4BAA4B,EAC5B,sBAAsB,GACvB,MAAM,4BAA4B,CAAC;AAWpC,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,uCAAuC,EACvC,0CAA0C,EAC1C,uBAAuB,EACvB,sCAAsC,EACtC,yCAAyC,EACzC,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,+BAA+B,EAC/B,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,uCAAuC,CAAC"}
|