@iyulab/chat-components 0.5.0 → 0.5.2

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +78 -144
  2. package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.128.0}/helpers/decorate.js +1 -1
  3. package/dist/_virtual/{_@oxc-project_runtime@0.122.0 → _@oxc-project_runtime@0.128.0}/helpers/decorateMetadata.js +1 -1
  4. package/dist/components/blocks/UCodeBlock.js +4 -3
  5. package/dist/components/blocks/UFileBlock.js +2 -2
  6. package/dist/components/blocks/UJsonBlock.js +2 -2
  7. package/dist/components/blocks/UMarkedBlock.js +3 -27
  8. package/dist/components/blocks/URefBlock.js +2 -2
  9. package/dist/components/blocks/UTableBlock.js +4 -3
  10. package/dist/components/blocks/UTextBlock.js +2 -2
  11. package/dist/components/blocks/UThinkBlock.js +2 -2
  12. package/dist/components/blocks/UToolBlock.js +2 -2
  13. package/dist/components/buttons/UAttachButton.js +2 -2
  14. package/dist/components/buttons/UCopyButton.js +2 -2
  15. package/dist/components/buttons/UVoteButton.js +2 -2
  16. package/dist/components/intents/UQuestionIntent.js +2 -2
  17. package/dist/components/message/UMessage.js +2 -2
  18. package/dist/components/prompt/UPrompt.d.ts +5 -0
  19. package/dist/components/prompt/UPrompt.js +27 -5
  20. package/dist/components/references/URefCard.js +2 -2
  21. package/dist/components/references/URefCardGroup.js +4 -3
  22. package/dist/components/references/URefTag.js +2 -2
  23. package/dist/components/views/UChartView.js +2 -2
  24. package/dist/components/views/UImagesView.js +2 -2
  25. package/dist/components/views/UMapView.js +2 -2
  26. package/dist/components/views/UVideoView.js +2 -2
  27. package/dist/components/views/UView.js +2 -2
  28. package/dist/events/SendEvent.d.ts +15 -1
  29. package/dist/events/StopEvent.d.ts +11 -1
  30. package/dist/types/Intents.js +1 -1
  31. package/dist/types/Views.js +1 -1
  32. package/dist/utilities/HtmlPlaceholder.d.ts +11 -0
  33. package/dist/utilities/HtmlPlaceholder.js +26 -0
  34. package/package.json +11 -10
  35. package/skills/iyulab-chat-components/SKILL.md +107 -0
  36. package/skills/iyulab-chat-components/references/components/attach-button.md +69 -0
  37. package/skills/iyulab-chat-components/references/components/chart-view.md +65 -0
  38. package/skills/iyulab-chat-components/references/components/code-block.md +42 -0
  39. package/skills/iyulab-chat-components/references/components/copy-button.md +46 -0
  40. package/skills/iyulab-chat-components/references/components/file-block.md +64 -0
  41. package/skills/iyulab-chat-components/references/components/images-view.md +63 -0
  42. package/skills/iyulab-chat-components/references/components/json-block.md +41 -0
  43. package/skills/iyulab-chat-components/references/components/map-view.md +54 -0
  44. package/skills/iyulab-chat-components/references/components/marked-block.md +53 -0
  45. package/skills/iyulab-chat-components/references/components/message.md +60 -0
  46. package/skills/iyulab-chat-components/references/components/prompt.md +102 -0
  47. package/skills/iyulab-chat-components/references/components/question-intent.md +75 -0
  48. package/skills/iyulab-chat-components/references/components/ref-block.md +45 -0
  49. package/skills/iyulab-chat-components/references/components/ref-card-group.md +41 -0
  50. package/skills/iyulab-chat-components/references/components/ref-card.md +48 -0
  51. package/skills/iyulab-chat-components/references/components/ref-tag.md +40 -0
  52. package/skills/iyulab-chat-components/references/components/table-block.md +63 -0
  53. package/skills/iyulab-chat-components/references/components/text-block.md +59 -0
  54. package/skills/iyulab-chat-components/references/components/think-block.md +48 -0
  55. package/skills/iyulab-chat-components/references/components/tool-block.md +57 -0
  56. package/skills/iyulab-chat-components/references/components/video-view.md +55 -0
  57. package/skills/iyulab-chat-components/references/components/view.md +51 -0
  58. package/skills/iyulab-chat-components/references/components/vote-button.md +60 -0
  59. package/skills/iyulab-chat-components/references/types.md +115 -0
  60. package/skills/iyulab-chat-components/references/usage.md +254 -0
  61. package/skills/iyulab-chat-components/references/utilities/intent-prompt-builder.md +123 -0
  62. package/skills/iyulab-chat-components/references/utilities/view-prompt-builder.md +112 -0
@@ -0,0 +1,112 @@
1
+ # ViewPromptBuilder
2
+
3
+ ```ts
4
+ import { ViewPromptBuilder, PresetView } from '@iyulab/chat-components';
5
+ ```
6
+
7
+ Singleton utility that registers views and generates LLM system prompt instructions. No manual parsing is needed — `u-marked-block` automatically renders `view-json` code blocks via `u-view`.
8
+
9
+ ---
10
+
11
+ ## Overview
12
+
13
+ ```ts
14
+ import { ViewPromptBuilder, PresetView } from '@iyulab/chat-components';
15
+
16
+ const builder = ViewPromptBuilder.instance;
17
+
18
+ // 1. Register preset views
19
+ builder.use(PresetView.All);
20
+ // Or selectively
21
+ builder.use(PresetView.Images | PresetView.Chart);
22
+
23
+ // 2. Register a custom view
24
+ builder.add({
25
+ element: MyCustomView, // CustomElementConstructor
26
+ tag: 'my-custom-view',
27
+ description: 'Display a custom visualization',
28
+ properties: {
29
+ data: { type: 'array', description: 'Data array' }
30
+ },
31
+ required: ['data']
32
+ });
33
+
34
+ // 3. Inject into LLM system prompt
35
+ const instruction = builder.build();
36
+ ```
37
+
38
+ When the LLM outputs a `view-json` block, `u-marked-block` renders it automatically:
39
+
40
+ ````
41
+ ```view-json
42
+ {
43
+ "tag": "u-chart-view",
44
+ "properties": {
45
+ "type": "pie",
46
+ "data": {
47
+ "labels": ["A", "B", "C"],
48
+ "datasets": [{ "data": [30, 50, 20] }]
49
+ }
50
+ }
51
+ }
52
+ ```
53
+ ````
54
+
55
+ ---
56
+
57
+ ## API
58
+
59
+ ### `ViewPromptBuilder.instance`
60
+
61
+ Returns the singleton. Created on first access.
62
+
63
+ ### `.use(flags: PresetView): this`
64
+
65
+ Registers preset views by bit flag.
66
+
67
+ ```ts
68
+ builder.use(PresetView.Images);
69
+ builder.use(PresetView.All);
70
+ builder.use(PresetView.Images | PresetView.Chart);
71
+ ```
72
+
73
+ ### `.add(definition: ViewDefinition): this`
74
+
75
+ Registers a custom view and its custom element. Throws if the same `tag` is already registered or if the tag is already defined with a different class.
76
+
77
+ ```ts
78
+ interface ViewDefinition {
79
+ element: CustomElementConstructor;
80
+ tag: string;
81
+ description: string;
82
+ properties?: Record<string, JsonSchema>;
83
+ required?: string[];
84
+ }
85
+ ```
86
+
87
+ ### `.build(): string`
88
+
89
+ Returns LLM system prompt instructions for all registered views. Returns an empty string if no views are registered.
90
+
91
+ ---
92
+
93
+ ## PresetView Flags
94
+
95
+ ```ts
96
+ enum PresetView {
97
+ Images = 1 << 0, // u-images-view
98
+ Video = 1 << 1, // u-video-view
99
+ Map = 1 << 3, // u-map-view
100
+ Chart = 1 << 4, // u-chart-view
101
+ All = Images | Video | Map | Chart
102
+ }
103
+ ```
104
+
105
+ ### Preset View Schema Summary
106
+
107
+ | Tag | Key Properties |
108
+ |-----|----------------|
109
+ | `u-images-view` | `items: [{ src, alt?, caption? }]` |
110
+ | `u-video-view` | `src`, `poster?`, `ratio?` |
111
+ | `u-map-view` | `lat`, `lng`, `zoom?`, `label?`, `description?` |
112
+ | `u-chart-view` | `type`, `data`, `options?` |