@lynx-js/genui 0.0.1-rc.0 → 0.0.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/a2ui/README.md +777 -100
- package/a2ui/dist/catalog/ChoicePicker/catalog.json +265 -0
- package/a2ui/dist/catalog/ChoicePicker/index.d.ts +56 -0
- package/a2ui/dist/catalog/ChoicePicker/index.js +66 -0
- package/a2ui/dist/catalog/ChoicePicker/index.js.map +1 -0
- package/a2ui/dist/catalog/ChoicePicker/utils.d.ts +13 -0
- package/a2ui/dist/catalog/ChoicePicker/utils.js +80 -0
- package/a2ui/dist/catalog/ChoicePicker/utils.js.map +1 -0
- package/a2ui/dist/catalog/Column/index.js +3 -7
- package/a2ui/dist/catalog/Column/index.js.map +1 -1
- package/a2ui/dist/catalog/DateTimeInput/catalog.json +165 -0
- package/a2ui/dist/catalog/DateTimeInput/index.d.ts +43 -0
- package/a2ui/dist/catalog/DateTimeInput/index.js +147 -0
- package/a2ui/dist/catalog/DateTimeInput/index.js.map +1 -0
- package/a2ui/dist/catalog/DateTimeInput/utils.d.ts +53 -0
- package/a2ui/dist/catalog/DateTimeInput/utils.js +248 -0
- package/a2ui/dist/catalog/DateTimeInput/utils.js.map +1 -0
- package/a2ui/dist/catalog/Icon/catalog.json +173 -2
- package/a2ui/dist/catalog/Icon/index.d.ts +2 -2
- package/a2ui/dist/catalog/Icon/index.js.map +1 -1
- package/a2ui/dist/catalog/Image/catalog.json +1 -17
- package/a2ui/dist/catalog/Image/index.d.ts +1 -3
- package/a2ui/dist/catalog/Image/index.js +3 -11
- package/a2ui/dist/catalog/Image/index.js.map +1 -1
- package/a2ui/dist/catalog/LineChart/index.js +3 -3
- package/a2ui/dist/catalog/LineChart/index.js.map +1 -1
- package/a2ui/dist/catalog/Modal/index.js +1 -1
- package/a2ui/dist/catalog/Modal/index.js.map +1 -1
- package/a2ui/dist/catalog/index.d.ts +4 -0
- package/a2ui/dist/catalog/index.js +2046 -3
- package/a2ui/dist/catalog/index.js.map +1 -1
- package/a2ui/dist/index.d.ts +1 -1
- package/a2ui/dist/index.js +1 -1
- package/a2ui/dist/index.js.map +1 -1
- package/a2ui/dist/react/A2UIRenderer.d.ts +1 -0
- package/a2ui/dist/react/A2UIRenderer.js +8 -6
- package/a2ui/dist/react/A2UIRenderer.js.map +1 -1
- package/a2ui/dist/react/useAction.js +2 -1
- package/a2ui/dist/react/useAction.js.map +1 -1
- package/a2ui/dist/react/useChecks.js +7 -2
- package/a2ui/dist/react/useChecks.js.map +1 -1
- package/a2ui/dist/react/useDataBinding.d.ts +1 -1
- package/a2ui/dist/react/useDataBinding.js +24 -48
- package/a2ui/dist/react/useDataBinding.js.map +1 -1
- package/a2ui/dist/store/MessageProcessor.js +7 -19
- package/a2ui/dist/store/MessageProcessor.js.map +1 -1
- package/a2ui/dist/store/SignalStore.d.ts +2 -0
- package/a2ui/dist/store/SignalStore.js +5 -0
- package/a2ui/dist/store/SignalStore.js.map +1 -1
- package/a2ui/dist/store/index.d.ts +3 -1
- package/a2ui/dist/store/index.js +3 -1
- package/a2ui/dist/store/index.js.map +1 -1
- package/a2ui/dist/store/resolveDynamic.d.ts +9 -0
- package/a2ui/dist/store/resolveDynamic.js +88 -0
- package/a2ui/dist/store/resolveDynamic.js.map +1 -0
- package/a2ui/dist/store/resolveFunctionCall.d.ts +2 -4
- package/a2ui/dist/store/resolveFunctionCall.js +24 -82
- package/a2ui/dist/store/resolveFunctionCall.js.map +1 -1
- package/a2ui/dist/store/signalResolution.d.ts +4 -0
- package/a2ui/dist/store/signalResolution.js +25 -0
- package/a2ui/dist/store/signalResolution.js.map +1 -0
- package/a2ui/dist/store/utils.d.ts +7 -0
- package/a2ui/dist/store/utils.js +24 -0
- package/a2ui/dist/store/utils.js.map +1 -0
- package/a2ui/dist/tsconfig.build.tsbuildinfo +1 -1
- package/a2ui/styles/catalog/ChoicePicker.css +157 -0
- package/a2ui/styles/catalog/DateTimeInput.css +375 -0
- package/a2ui/styles/catalog/Icon.css +1 -1
- package/a2ui/styles/catalog/Text.css +11 -11
- package/a2ui/styles/theme.css +2 -1
- package/a2ui-catalog-extractor/README.md +23 -15
- package/a2ui-catalog-extractor/bin/a2ui-catalog-extractor.js +0 -1
- package/a2ui-catalog-extractor/dist/tsconfig.build.tsbuildinfo +1 -1
- package/a2ui-prompt/README.md +1 -2
- package/a2ui-prompt/dist/index.js +65 -31
- package/cli/bin/cli.js +5 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -1
package/a2ui-prompt/README.md
CHANGED
|
@@ -37,8 +37,7 @@ const prompt = buildA2UISystemPrompt({ catalog });
|
|
|
37
37
|
|
|
38
38
|
`readA2UICatalogFromDirectory` expects generated files such as
|
|
39
39
|
`<Component>/catalog.json` and optional function definitions under `functions/`.
|
|
40
|
-
Use `genui a2ui generate catalog`
|
|
41
|
-
`@lynx-js/genui/a2ui-catalog-extractor` to create those artifacts.
|
|
40
|
+
Use `genui a2ui generate catalog` to create those artifacts.
|
|
42
41
|
|
|
43
42
|
## Exports
|
|
44
43
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
|
|
2
|
+
import * as __rspack_external_node_path_c5b9b54f from "node:path";
|
|
3
3
|
const BASIC_CATALOG_ID = 'https://a2ui.org/specification/v0_9/basic_catalog.json';
|
|
4
4
|
const BASIC_CATALOG_EXAMPLES = [
|
|
5
5
|
{
|
|
@@ -338,9 +338,11 @@ const BASIC_CATALOG_EXAMPLES = [
|
|
|
338
338
|
var catalog_namespaceObject = JSON.parse('{"Button":{"properties":{"child":{"type":"string"},"variant":{"type":"string","enum":["primary","borderless"]},"isValid":{"type":"boolean"},"action":{"oneOf":[{"type":"object","properties":{"event":{"type":"object","properties":{"name":{"type":"string"},"context":{"type":"object","additionalProperties":true,"description":"Context is a JSON object map in v0.9."}},"required":["name"],"additionalProperties":false}},"required":["event"],"additionalProperties":false},{"type":"object","properties":{"functionCall":{"type":"object","properties":{"call":{"type":"string"},"args":{"type":"object","additionalProperties":true},"returnType":{"type":"string","enum":["string","number","boolean","object","array","any","void"]}},"required":["call","args"],"additionalProperties":false}},"required":["functionCall"],"additionalProperties":false}],"description":"v0.9 actions should use the `event` wrapper for server-dispatched clicks."},"checks":{"type":"array","items":{"type":"object","properties":{"condition":{"oneOf":[{"type":"boolean"},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false},{"type":"object","properties":{"call":{"type":"string"},"args":{"type":"object","additionalProperties":true},"returnType":{"type":"string","enum":["string","number","boolean","object","array","any","void"]}},"required":["call","args"],"additionalProperties":false}]},"message":{"type":"string"}},"required":["condition","message"],"additionalProperties":false}}},"required":["child","action"]}}');
|
|
339
339
|
var Card_catalog_namespaceObject = JSON.parse('{"Card":{"properties":{"child":{"type":"string"},"variant":{"type":"string","enum":["elevated","outlined","filled","ghost"]},"weight":{"type":"number"}},"required":["child"]}}');
|
|
340
340
|
var CheckBox_catalog_namespaceObject = JSON.parse('{"CheckBox":{"properties":{"label":{"oneOf":[{"type":"string"},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false},{"type":"object","properties":{"call":{"type":"string"},"args":{"type":"object","additionalProperties":true},"returnType":{"type":"string","enum":["string","number","boolean","object","array","any","void"]}},"required":["call","args"],"additionalProperties":false}]},"value":{"oneOf":[{"type":"boolean"},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false},{"type":"object","properties":{"call":{"type":"string"},"args":{"type":"object","additionalProperties":true},"returnType":{"type":"string","enum":["string","number","boolean","object","array","any","void"]}},"required":["call","args"],"additionalProperties":false}]},"checks":{"type":"array","items":{"type":"object","properties":{"condition":{"oneOf":[{"type":"boolean"},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false},{"type":"object","properties":{"call":{"type":"string"},"args":{"type":"object","additionalProperties":true},"returnType":{"type":"string","enum":["string","number","boolean","object","array","any","void"]}},"required":["call","args"],"additionalProperties":false}]},"message":{"type":"string"}},"required":["condition","message"],"additionalProperties":false}}},"required":["label","value"]}}');
|
|
341
|
+
var ChoicePicker_catalog_namespaceObject = JSON.parse('{"ChoicePicker":{"properties":{"label":{"oneOf":[{"type":"string"},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false},{"type":"object","properties":{"call":{"type":"string"},"args":{"type":"object","additionalProperties":true},"returnType":{"type":"string","enum":["string","number","boolean","object","array","any","void"]}},"required":["call","args"],"additionalProperties":false}],"description":"The label for the group of options."},"variant":{"type":"string","enum":["multipleSelection","mutuallyExclusive"],"description":"A hint for how the choice picker should be displayed and behave."},"options":{"type":"array","items":{"type":"object","properties":{"label":{"oneOf":[{"type":"string"},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false},{"type":"object","properties":{"call":{"type":"string"},"args":{"type":"object","additionalProperties":true},"returnType":{"type":"string","enum":["string","number","boolean","object","array","any","void"]}},"required":["call","args"],"additionalProperties":false}],"description":"The text to display for this option."},"value":{"type":"string","description":"The stable value associated with this option."}},"required":["label","value"],"additionalProperties":false},"description":"The list of available options to choose from."},"value":{"oneOf":[{"type":"array","items":{"type":"string"}},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false},{"type":"object","properties":{"call":{"type":"string"},"args":{"type":"object","additionalProperties":true},"returnType":{"type":"string","enum":["string","number","boolean","object","array","any","void"]}},"required":["call","args"],"additionalProperties":false}],"description":"The list of currently selected values."},"displayStyle":{"type":"string","enum":["checkbox","chips"],"description":"The display style of the component."},"filterable":{"type":"boolean","description":"If true, displays a search input to filter the options."},"checks":{"type":"array","items":{"type":"object","properties":{"condition":{"oneOf":[{"type":"boolean"},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false},{"type":"object","properties":{"call":{"type":"string"},"args":{"type":"object","additionalProperties":true},"returnType":{"type":"string","enum":["string","number","boolean","object","array","any","void"]}},"required":["call","args"],"additionalProperties":false}],"description":"The condition that indicates whether the check passes."},"message":{"type":"string","description":"The error message to display if the check fails."}},"required":["condition","message"],"additionalProperties":false},"description":"A list of checks to perform."}},"required":["options","value"]}}');
|
|
341
342
|
var Column_catalog_namespaceObject = JSON.parse('{"Column":{"properties":{"children":{"oneOf":[{"type":"array","items":{"type":"string"}},{"type":"object","properties":{"componentId":{"type":"string"},"path":{"type":"string"}},"required":["componentId","path"],"additionalProperties":false}],"description":"Static child IDs array or template object."},"align":{"type":"string","enum":["start","center","end","stretch"]},"justify":{"type":"string","enum":["start","center","end","stretch","spaceBetween","spaceAround","spaceEvenly"]}},"required":["children"]}}');
|
|
343
|
+
var DateTimeInput_catalog_namespaceObject = JSON.parse('{"DateTimeInput":{"properties":{"value":{"oneOf":[{"type":"string"},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false}],"description":"The current date/time value. Typically bound to a data path."},"label":{"oneOf":[{"type":"string"},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false},{"type":"object","properties":{"call":{"type":"string"},"args":{"type":"object","additionalProperties":true},"returnType":{"type":"string","enum":["string","number","boolean","object","array","any","void"]}},"required":["call","args"],"additionalProperties":false}],"description":"The text label for the input field."},"enableDate":{"type":"boolean","description":"Whether to show the date picker."},"enableTime":{"type":"boolean","description":"Whether to show the time picker."},"outputFormat":{"type":"string","description":"Format string for the output value. Supports YYYY, MM, DD, HH, and mm."},"min":{"type":"string","description":"Minimum allowed date/time value."},"max":{"type":"string","description":"Maximum allowed date/time value."},"checks":{"type":"array","items":{"type":"object","properties":{"condition":{"oneOf":[{"type":"boolean"},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false},{"type":"object","properties":{"call":{"type":"string"},"args":{"type":"object","additionalProperties":true},"returnType":{"type":"string","enum":["string","number","boolean","object","array","any","void"]}},"required":["call","args"],"additionalProperties":false}],"description":"The condition that indicates whether the check passes."},"message":{"type":"string","description":"The error message to display if the check fails."}},"required":["condition","message"],"additionalProperties":false},"description":"A list of checks to perform."}},"required":["value"]}}');
|
|
342
344
|
var Divider_catalog_namespaceObject = JSON.parse('{"Divider":{"properties":{"axis":{"type":"string","enum":["horizontal","vertical"]}},"required":[]}}');
|
|
343
|
-
var Icon_catalog_namespaceObject = JSON.parse('{"Icon":{"properties":{"name":{"oneOf":[{"type":"string"},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false}],"description":"Material icon name
|
|
345
|
+
var Icon_catalog_namespaceObject = JSON.parse('{"Icon":{"properties":{"name":{"oneOf":[{"type":"string","enum":["account_circle","add","arrow_back","arrow_forward","camera","check","close","delete","edit","error","favorite","help","home","info","location_on","lock","mail","menu","more_vert","pause","person","play_arrow","refresh","search","send","settings","share","star","warning"]},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false}],"description":"Google Material icon ligature name, e.g. \\"info\\", \\"account_circle\\", \\"arrow_back\\"."},"size":{"type":"string","enum":["sm","md","lg"]},"color":{"type":"string","enum":["primary","muted","inherit"]}},"required":["name"]}}');
|
|
344
346
|
var Image_catalog_namespaceObject = JSON.parse('{"Image":{"properties":{"url":{"oneOf":[{"type":"string"},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false}],"description":"Image URL or path binding."},"fit":{"type":"string","enum":["contain","cover","fill","none","scale-down"]},"mode":{"type":"string","enum":["center","scaleToFill","aspectFit","aspectFill"]},"variant":{"type":"string","enum":["icon","avatar","smallFeature","mediumFeature","largeFeature","header"]},"weight":{"type":"number"}},"required":["url"]}}');
|
|
345
347
|
var LineChart_catalog_namespaceObject = JSON.parse('{"LineChart":{"properties":{"labels":{"oneOf":[{"type":"array","items":{"type":"string"}},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false}],"description":"Category labels shown along the x axis."},"series":{"oneOf":[{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"values":{"type":"array","items":{"type":"number"}},"color":{"type":"string"}},"required":["name","values"],"additionalProperties":false}},{"type":"object","properties":{"path":{"type":"string"}},"required":["path"],"additionalProperties":false}],"description":"One or more line series to render over the shared labels."},"variant":{"type":"string","enum":["linear","natural","step"]},"xLabel":{"type":"string"},"yLabel":{"type":"string"},"showGrid":{"type":"boolean"},"showLegend":{"type":"boolean"},"height":{"type":"number"}},"required":["labels","series"]}}');
|
|
346
348
|
var List_catalog_namespaceObject = JSON.parse('{"List":{"properties":{"children":{"oneOf":[{"type":"array","items":{"type":"string"}},{"type":"object","properties":{"componentId":{"type":"string"},"path":{"type":"string"}},"required":["componentId","path"],"additionalProperties":false}],"description":"Static child IDs array or template object."},"direction":{"type":"string","enum":["horizontal","vertical"]},"align":{"type":"string","enum":["start","center","end","stretch"]}},"required":["children"]}}');
|
|
@@ -367,6 +369,8 @@ const CATALOG_MANIFESTS = [
|
|
|
367
369
|
catalog_namespaceObject,
|
|
368
370
|
TextField_catalog_namespaceObject,
|
|
369
371
|
CheckBox_catalog_namespaceObject,
|
|
372
|
+
ChoicePicker_catalog_namespaceObject,
|
|
373
|
+
DateTimeInput_catalog_namespaceObject,
|
|
370
374
|
RadioGroup_catalog_namespaceObject,
|
|
371
375
|
Slider_catalog_namespaceObject
|
|
372
376
|
];
|
|
@@ -374,7 +378,9 @@ const COMPONENT_SUMMARIES = {
|
|
|
374
378
|
Button: 'Clickable button. MUST always include an action. Has no "label" prop; use a child Text component for the visible label.',
|
|
375
379
|
Card: 'Card container with exactly one child. Wrap multiple elements in a Column/Row/List first.',
|
|
376
380
|
CheckBox: 'Boolean checkbox with a label and optional validation checks.',
|
|
381
|
+
ChoicePicker: 'Single- or multi-select choice picker with checkbox and chip display styles.',
|
|
377
382
|
Column: 'Vertical layout container.',
|
|
383
|
+
DateTimeInput: 'Date and/or time input with a calendar panel. Without outputFormat, date-enabled inputs write YYYY-MM-DD.',
|
|
378
384
|
Divider: 'Horizontal or vertical separator line.',
|
|
379
385
|
Icon: 'Display an icon by name.',
|
|
380
386
|
Image: 'Display an image by URL.',
|
|
@@ -573,6 +579,10 @@ and exactly ONE of the following keys:
|
|
|
573
579
|
may reference data paths that will be populated by updateDataModel.
|
|
574
580
|
- updateDataModel replaces the whole data model when "path" is omitted or "/".
|
|
575
581
|
With a specific "path", it replaces only the value at that JSON Pointer.
|
|
582
|
+
Its fields MUST be nested inside "updateDataModel":
|
|
583
|
+
{ "version": "v0.9",
|
|
584
|
+
"updateDataModel": { "surfaceId": "main", "path": "/", "value": {} } }
|
|
585
|
+
Never put "path" beside "updateDataModel" at the top level of the message.
|
|
576
586
|
- deleteSurface removes a surface when the UI is no longer needed.
|
|
577
587
|
|
|
578
588
|
## Component model
|
|
@@ -618,35 +628,59 @@ function buildHardRules(catalogId) {
|
|
|
618
628
|
1. Output MUST be a JSON ARRAY of A2UI messages. No prose, no Markdown, no
|
|
619
629
|
code fences, no XML. First character '[' – last character ']'.
|
|
620
630
|
2. Each element MUST include "version": "v0.9".
|
|
621
|
-
3.
|
|
631
|
+
3. Output pretty-printed JSON with 2-space indentation. Do NOT emit minified
|
|
632
|
+
single-line JSON. Put each message object and each component object on its
|
|
633
|
+
own lines so brackets and braces stay balanced.
|
|
634
|
+
4. Before finishing, check the final characters: every component object closes
|
|
635
|
+
once, every "components" array closes once, every message object closes
|
|
636
|
+
once, and the outer array closes exactly once.
|
|
637
|
+
5. For a fresh non-action response, the first message MUST be createSurface with
|
|
622
638
|
catalogId = "${catalogId}". Use surfaceId "main" unless the user specifies
|
|
623
639
|
otherwise.
|
|
624
|
-
|
|
640
|
+
6. For a fresh non-action response, the second message MUST be
|
|
625
641
|
updateComponents; its components list MUST contain exactly one component
|
|
626
642
|
with id "root".
|
|
627
|
-
|
|
643
|
+
7. Use property-based component discriminators: "component": "Text", not
|
|
628
644
|
wrapper objects such as { "Text": {...} }.
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
645
|
+
8. Children are referenced by id only. NEVER inline a child component.
|
|
646
|
+
9. Container references MUST point to components present in the same response.
|
|
647
|
+
10. Card.child is exactly one id; wrap multiple elements in Row/Column/List.
|
|
648
|
+
11. Buttons MUST include a non-empty "action.event.name". Button has NO "label"
|
|
633
649
|
prop – provide the label via a child Text component ("child": "<text-id>").
|
|
634
|
-
|
|
650
|
+
12. When using Modal for a confirmation flow, do NOT put the server action on
|
|
651
|
+
the Modal trigger. The trigger only opens the modal. Put a separate confirm
|
|
652
|
+
Button inside Modal.content, and attach the action to that confirm Button.
|
|
653
|
+
13. Render a Modal by placing the Modal component itself where the trigger
|
|
654
|
+
should appear. Do NOT also list the trigger component as a sibling in the
|
|
655
|
+
parent container, because Modal renders its trigger internally.
|
|
656
|
+
14. The "weight" prop is a small layout ratio for Row/Column children, not CSS
|
|
657
|
+
font-weight. Do NOT use values like 400, 500, 600, or 700 for typography.
|
|
658
|
+
Use text variants for typography, and use small weights such as 1, 1.5, 2,
|
|
659
|
+
3, or 5 only when balancing sibling layout.
|
|
660
|
+
15. Any "{path:...}" reference MUST be populated by some updateDataModel in the
|
|
635
661
|
same response.
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
662
|
+
16. In an updateDataModel message, "path" MUST be inside "updateDataModel",
|
|
663
|
+
never at the top level. Correct:
|
|
664
|
+
{ "version": "v0.9", "updateDataModel": { "surfaceId": "main", "path": "/", "value": {} } }
|
|
665
|
+
Wrong:
|
|
666
|
+
{ "version": "v0.9", "updateDataModel": { "surfaceId": "main", "value": {} }, "path": "/" }
|
|
667
|
+
17. Ids are kebab-case, unique per surface ("root", "title-text", "submit-btn").
|
|
668
|
+
18. Do not invent components outside the catalog.
|
|
669
|
+
19. No comments, trailing commas or unknown fields.
|
|
670
|
+
20. If the user asks for impossible, unsafe, or unsupported UI, render a concise
|
|
640
671
|
explanatory A2UI surface using supported components rather than prose.
|
|
641
|
-
|
|
672
|
+
21. If the latest user message starts with "A2UI_USER_ACTION:", this is an
|
|
642
673
|
action response for an existing surface. Return a non-empty JSON array with
|
|
643
674
|
updateDataModel and/or updateComponents for that same surfaceId. Do NOT
|
|
644
675
|
return [] and do NOT create a new surface unless the action explicitly asks
|
|
645
676
|
to replace the whole UI.
|
|
646
|
-
|
|
677
|
+
22. For action responses, prefer the smallest valid patch: one updateDataModel
|
|
678
|
+
for changed data, plus one updateComponents only if the visible structure
|
|
679
|
+
needs to change.
|
|
680
|
+
23. For UI that should change after a button tap, keep the initial response in
|
|
647
681
|
the pre-action state. Put confirmation, success, or result details in the
|
|
648
682
|
action response instead of showing them before the action happens.
|
|
649
|
-
|
|
683
|
+
24. For Image.url, provide a short English image search query such as
|
|
650
684
|
"fresh pasta on a table" or "city skyline at night". Do NOT invent photo
|
|
651
685
|
CDN URLs. The server resolves Image.url values through its image provider.
|
|
652
686
|
`;
|
|
@@ -686,17 +720,17 @@ function buildA2UISystemPrompt(opts = {}) {
|
|
|
686
720
|
}
|
|
687
721
|
const A2UI_SYSTEM_PROMPT = buildA2UISystemPrompt();
|
|
688
722
|
function readA2UICatalogFromDirectory(options) {
|
|
689
|
-
const cwd = options.cwd ? resolve(options.cwd) : process.cwd();
|
|
690
|
-
const catalogDir = resolve(cwd, options.catalogDir);
|
|
691
|
-
if (!existsSync(catalogDir)) throw new Error(`[a2ui-prompt] Catalog directory does not exist: ${options.catalogDir}`);
|
|
692
|
-
if (!statSync(catalogDir).isDirectory()) throw new Error(`[a2ui-prompt] Catalog path is not a directory: ${options.catalogDir}`);
|
|
723
|
+
const cwd = options.cwd ? __rspack_external_node_path_c5b9b54f.resolve(options.cwd) : process.cwd();
|
|
724
|
+
const catalogDir = __rspack_external_node_path_c5b9b54f.resolve(cwd, options.catalogDir);
|
|
725
|
+
if (!__rspack_external_node_fs_5ea92f0c.existsSync(catalogDir)) throw new Error(`[a2ui-prompt] Catalog directory does not exist: ${options.catalogDir}`);
|
|
726
|
+
if (!__rspack_external_node_fs_5ea92f0c.statSync(catalogDir).isDirectory()) throw new Error(`[a2ui-prompt] Catalog path is not a directory: ${options.catalogDir}`);
|
|
693
727
|
const componentManifests = [];
|
|
694
|
-
for (const entry of readdirSync(catalogDir, {
|
|
728
|
+
for (const entry of __rspack_external_node_fs_5ea92f0c.readdirSync(catalogDir, {
|
|
695
729
|
withFileTypes: true
|
|
696
730
|
})){
|
|
697
731
|
if (!entry.isDirectory() || 'functions' === entry.name) continue;
|
|
698
|
-
const catalogJsonPath = join(catalogDir, entry.name, 'catalog.json');
|
|
699
|
-
if (existsSync(catalogJsonPath)) componentManifests.push(readCatalogManifest(catalogJsonPath));
|
|
732
|
+
const catalogJsonPath = __rspack_external_node_path_c5b9b54f.join(catalogDir, entry.name, 'catalog.json');
|
|
733
|
+
if (__rspack_external_node_fs_5ea92f0c.existsSync(catalogJsonPath)) componentManifests.push(readCatalogManifest(catalogJsonPath));
|
|
700
734
|
}
|
|
701
735
|
if (0 === componentManifests.length) throw new Error(`[a2ui-prompt] No component catalog files found in ${options.catalogDir}. Expected files like <Component>/catalog.json. Run "genui a2ui generate catalog" first or pass --catalog-dir to the generated catalog directory.`);
|
|
702
736
|
return createA2UICatalogFromManifests({
|
|
@@ -712,15 +746,15 @@ function readA2UICatalogFromDirectory(options) {
|
|
|
712
746
|
});
|
|
713
747
|
}
|
|
714
748
|
function readFunctionDefinitions(catalogDir) {
|
|
715
|
-
const functionsDir = join(catalogDir, 'functions');
|
|
716
|
-
if (!existsSync(functionsDir)) return [];
|
|
717
|
-
if (!statSync(functionsDir).isDirectory()) throw new Error(`[a2ui-prompt] Expected functions directory at ${functionsDir}.`);
|
|
749
|
+
const functionsDir = __rspack_external_node_path_c5b9b54f.join(catalogDir, 'functions');
|
|
750
|
+
if (!__rspack_external_node_fs_5ea92f0c.existsSync(functionsDir)) return [];
|
|
751
|
+
if (!__rspack_external_node_fs_5ea92f0c.statSync(functionsDir).isDirectory()) throw new Error(`[a2ui-prompt] Expected functions directory at ${functionsDir}.`);
|
|
718
752
|
const functions = [];
|
|
719
|
-
for (const entry of readdirSync(functionsDir, {
|
|
753
|
+
for (const entry of __rspack_external_node_fs_5ea92f0c.readdirSync(functionsDir, {
|
|
720
754
|
withFileTypes: true
|
|
721
755
|
})){
|
|
722
756
|
if (!entry.isFile() || !entry.name.endsWith('.json')) continue;
|
|
723
|
-
const functionRecord = readJsonObject(join(functionsDir, entry.name));
|
|
757
|
+
const functionRecord = readJsonObject(__rspack_external_node_path_c5b9b54f.join(functionsDir, entry.name));
|
|
724
758
|
for (const [name, value] of Object.entries(functionRecord)){
|
|
725
759
|
if (!src_isRecord(value)) continue;
|
|
726
760
|
const description = value["description"];
|
|
@@ -743,7 +777,7 @@ function readFunctionDefinitions(catalogDir) {
|
|
|
743
777
|
return functions.sort((left, right)=>left.name.localeCompare(right.name));
|
|
744
778
|
}
|
|
745
779
|
function readJsonObject(filePath) {
|
|
746
|
-
const value = JSON.parse(readFileSync(filePath, 'utf8'));
|
|
780
|
+
const value = JSON.parse(__rspack_external_node_fs_5ea92f0c.readFileSync(filePath, 'utf8'));
|
|
747
781
|
if (!src_isRecord(value)) throw new Error(`[a2ui-prompt] Expected JSON object in ${filePath}.`);
|
|
748
782
|
return value;
|
|
749
783
|
}
|
package/cli/bin/cli.js
CHANGED
|
@@ -266,6 +266,9 @@ function printPackageVersion() {
|
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
function isMain(moduleUrl) {
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
if (process.argv[1] === undefined) {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return moduleUrl === pathToFileURL(fs.realpathSync(process.argv[1])).href;
|
|
271
274
|
}
|