kui-vue 6.0.0 → 6.2.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/AI.en-US.md +21 -1
- package/AI.md +37 -1
- package/ai/behaviors.json +82 -0
- package/ai/evals/README.md +59 -0
- package/ai/evals/cases.json +91 -24
- package/ai/evals/config.json +4 -0
- package/ai/evals/evaluate.mjs +267 -0
- package/ai/evals/run.mjs +118 -0
- package/ai/kui-components.json +7894 -955
- package/ai/kui-components.schema.json +67 -0
- package/ai/mcp.mjs +210 -166
- package/ai/skills/kui-vue/SKILL.md +2 -1
- package/ai/skills/kui-vue/references/mcp.md +12 -12
- package/ai/templates/form.vue +49 -0
- package/ai/templates/index.json +23 -0
- package/ai/templates/modal-editor.vue +59 -0
- package/ai/templates/table.vue +63 -0
- package/ai/validate.mjs +225 -0
- package/dist/index.js +2 -2
- package/es/index.js +2180 -2179
- package/es/locale/de.js +1 -1
- package/es/locale/el.js +1 -1
- package/es/locale/en.js +1 -1
- package/es/locale/fr.js +1 -1
- package/es/locale/it.js +1 -1
- package/es/locale/ja.js +1 -1
- package/es/locale/ko.js +1 -1
- package/es/locale/ru.js +1 -1
- package/es/locale/th.js +1 -1
- package/es/locale/uk.js +1 -1
- package/es/locale/vi.js +1 -1
- package/es/locale/zh-CN.js +1 -1
- package/es/locale/zh-TW.js +1 -1
- package/lib/index.cjs +2 -2
- package/lib/locale/de.cjs +1 -1
- package/lib/locale/el.cjs +1 -1
- package/lib/locale/en.cjs +1 -1
- package/lib/locale/fr.cjs +1 -1
- package/lib/locale/it.cjs +1 -1
- package/lib/locale/ja.cjs +1 -1
- package/lib/locale/ko.cjs +1 -1
- package/lib/locale/ru.cjs +1 -1
- package/lib/locale/th.cjs +1 -1
- package/lib/locale/uk.cjs +1 -1
- package/lib/locale/vi.cjs +1 -1
- package/lib/locale/zh-CN.cjs +1 -1
- package/lib/locale/zh-TW.cjs +1 -1
- package/package.json +37 -31
- package/style/base.css +1 -1
- package/style/components.css +2 -2
- package/style/index.css +2 -2
- package/style/motion.css +1 -1
- package/style/theme.css +2 -2
- package/types/affix/index.d.ts +5 -5
- package/types/alert/index.d.ts +9 -7
- package/types/anchor/anchor-link.d.ts +4 -4
- package/types/anchor/anchor.d.ts +6 -6
- package/types/anchor/context.d.ts +1 -1
- package/types/anchor/index.d.ts +4 -4
- package/types/auto-complete/index.d.ts +7 -11
- package/types/avatar/avatar-group.d.ts +5 -5
- package/types/avatar/avatar.d.ts +6 -6
- package/types/avatar/context.d.ts +1 -1
- package/types/avatar/index.d.ts +4 -4
- package/types/back-top/index.d.ts +5 -5
- package/types/badge/index.d.ts +6 -6
- package/types/base/transition.d.ts +1 -1
- package/types/breadcrumb/breadcrumb-item.d.ts +6 -6
- package/types/breadcrumb/breadcrumb.d.ts +4 -4
- package/types/breadcrumb/index.d.ts +4 -4
- package/types/button/button-group.d.ts +5 -5
- package/types/button/button.d.ts +4 -4
- package/types/button/index.d.ts +4 -4
- package/types/calendar/index.d.ts +8 -5
- package/types/card/card-meta.d.ts +4 -4
- package/types/card/index.d.ts +8 -8
- package/types/carousel/carousel-item.d.ts +1 -1
- package/types/carousel/carousel.d.ts +20 -7
- package/types/carousel/index.d.ts +3 -3
- package/types/cascader/index.d.ts +41 -32
- package/types/cascader/types.d.ts +7 -3
- package/types/check-card/check-card-group.d.ts +10 -7
- package/types/check-card/check-card.d.ts +21 -8
- package/types/check-card/context.d.ts +3 -3
- package/types/check-card/index.d.ts +5 -5
- package/types/check-card/types.d.ts +2 -2
- package/types/checkbox/checkbox-group.d.ts +20 -7
- package/types/checkbox/checkbox.d.ts +4 -3
- package/types/checkbox/index.d.ts +5 -5
- package/types/collapse/collapse-panel.d.ts +6 -6
- package/types/collapse/collapse.d.ts +7 -7
- package/types/collapse/context.d.ts +1 -1
- package/types/collapse/index.d.ts +4 -4
- package/types/color-picker/alpha.d.ts +10 -6
- package/types/color-picker/hue.d.ts +7 -4
- package/types/color-picker/index.d.ts +34 -20
- package/types/color-picker/mode.d.ts +9 -9
- package/types/color-picker/paint.d.ts +9 -6
- package/types/color-picker/presets.d.ts +7 -7
- package/types/color-picker/types.d.ts +1 -0
- package/types/components.d.ts +166 -161
- package/types/config/context.d.ts +2 -2
- package/types/config/index.d.ts +7 -7
- package/types/config/popup.d.ts +1 -1
- package/types/const/types.d.ts +2 -2
- package/types/date-picker/index.d.ts +49 -19
- package/types/descriptions/descriptions-item.d.ts +5 -5
- package/types/descriptions/descriptions.d.ts +5 -5
- package/types/descriptions/index.d.ts +4 -2
- package/types/directives/outsiteclick.d.ts +1 -1
- package/types/directives/resize.d.ts +1 -1
- package/types/directives/scroll.d.ts +1 -1
- package/types/divider/index.d.ts +5 -5
- package/types/drawer/index.d.ts +24 -11
- package/types/dropdown/dropdown-button.d.ts +7 -7
- package/types/dropdown/dropdown.d.ts +12 -16
- package/types/dropdown/index.d.ts +4 -2
- package/types/dropdown/trigger.d.ts +6 -6
- package/types/empty/index.d.ts +1 -1
- package/types/feature-card/index.d.ts +7 -7
- package/types/feedback-panel/feedback-panel.d.ts +7 -7
- package/types/feedback-panel/index.d.ts +3 -3
- package/types/flame-wrap/index.d.ts +9 -9
- package/types/flex/index.d.ts +7 -7
- package/types/flex/types.d.ts +1 -1
- package/types/form/context.d.ts +3 -3
- package/types/form/form-item.d.ts +6 -6
- package/types/form/form.d.ts +9 -13
- package/types/form/index.d.ts +6 -6
- package/types/global.d.ts +2 -0
- package/types/grid/grid-item.d.ts +2 -2
- package/types/grid/grid.d.ts +3 -3
- package/types/grid/index.d.ts +5 -5
- package/types/grid/useBreakpoint.d.ts +1 -1
- package/types/icon/index.d.ts +8 -8
- package/types/image/context.d.ts +2 -2
- package/types/image/group.d.ts +4 -4
- package/types/image/image.d.ts +7 -7
- package/types/image/index.d.ts +5 -5
- package/types/image/instance.d.ts +11 -4
- package/types/image/preview.d.ts +6 -6
- package/types/index.d.cts +2 -2
- package/types/index.d.ts +2 -2
- package/types/input/index.d.ts +6 -6
- package/types/input/input-box.d.ts +6 -6
- package/types/input/input-group.d.ts +5 -5
- package/types/input/input.d.ts +27 -10
- package/types/input/textarea.d.ts +17 -8
- package/types/input-number/index.d.ts +10 -7
- package/types/input-otp/index.d.ts +3 -3
- package/types/input-otp/input-otp.d.ts +21 -8
- package/types/input-tag/index.d.ts +6 -6
- package/types/kanban/index.d.ts +5 -5
- package/types/layout/index.d.ts +17 -17
- package/types/list-panel/index.d.ts +7 -7
- package/types/mentions/index.d.ts +7 -7
- package/types/menu/index.d.ts +6 -6
- package/types/menu/menu-context.d.ts +4 -2
- package/types/menu/menu-divider.d.ts +1 -1
- package/types/menu/menu-group.d.ts +4 -4
- package/types/menu/menu-item.d.ts +10 -6
- package/types/menu/menu.d.ts +24 -17
- package/types/menu/recursive-menu.d.ts +5 -5
- package/types/menu/sub-menu.d.ts +6 -6
- package/types/menu/types.d.ts +2 -2
- package/types/message/index.d.ts +3 -3
- package/types/modal/index.d.ts +15 -10
- package/types/modal/modal.d.ts +25 -97
- package/types/modal/toast.d.ts +11 -10
- package/types/notice/container.d.ts +3 -3
- package/types/notice/content.d.ts +10 -77
- package/types/notice/index.d.ts +3 -3
- package/types/notice/instance.d.ts +2 -2
- package/types/page/index.d.ts +6 -6
- package/types/page-header/index.d.ts +4 -4
- package/types/popconfirm/index.d.ts +8 -45
- package/types/poptip/index.d.ts +9 -47
- package/types/popup/index.d.ts +251 -0
- package/types/popup/layers.d.ts +9 -0
- package/types/popup/types.d.ts +15 -0
- package/types/progress/index.d.ts +6 -6
- package/types/qrcode/index.d.ts +7 -7
- package/types/radio/index.d.ts +8 -7
- package/types/radio/radio-button.d.ts +8 -8
- package/types/radio/radio-group.d.ts +4 -3
- package/types/radio/radio.d.ts +7 -7
- package/types/radio/types.d.ts +1 -1
- package/types/rate/index.d.ts +7 -7
- package/types/rate/star.d.ts +7 -7
- package/types/result/index.d.ts +3 -3
- package/types/result/result.d.ts +7 -7
- package/types/ripple/index.d.ts +6 -6
- package/types/row-col/col.d.ts +4 -4
- package/types/row-col/index.d.ts +4 -4
- package/types/row-col/row.d.ts +4 -4
- package/types/segmented/index.d.ts +6 -4
- package/types/select/index.d.ts +5 -5
- package/types/select/option.d.ts +13 -14
- package/types/select/select.d.ts +10 -6
- package/types/select/types.d.ts +1 -1
- package/types/skeleton/index.d.ts +10 -10
- package/types/skeleton/skeleton-avatar.d.ts +13 -13
- package/types/skeleton/skeleton-button.d.ts +15 -15
- package/types/skeleton/skeleton-image.d.ts +11 -11
- package/types/skeleton/skeleton-text.d.ts +11 -11
- package/types/skeleton/skeleton.d.ts +15 -15
- package/types/skeleton/types.d.ts +2 -2
- package/types/skeleton/use-skeleton-loading.d.ts +1 -1
- package/types/slider/index.d.ts +8 -3
- package/types/slider/thumb.d.ts +7 -7
- package/types/space/index.d.ts +4 -4
- package/types/spin/index.d.ts +18 -5
- package/types/splitter/index.d.ts +2 -2
- package/types/splitter/splitter-panel.d.ts +4 -4
- package/types/splitter/splitter.d.ts +6 -6
- package/types/stat-card/countup.d.ts +4 -4
- package/types/stat-card/index.d.ts +5 -5
- package/types/stat-card/rollup.d.ts +6 -4
- package/types/stat-card/stat-card.d.ts +7 -7
- package/types/stat-card/stat-number.d.ts +19 -6
- package/types/stat-card/types.d.ts +1 -1
- package/types/stat-card/utils/countup.d.ts +1 -1
- package/types/stat-card/utils/odometer.d.ts +8 -5
- package/types/steps/index.d.ts +8 -8
- package/types/switch/index.d.ts +3 -2
- package/types/table/column-setting.d.ts +7 -7
- package/types/table/index.d.ts +13 -26
- package/types/table/types.d.ts +2 -2
- package/types/table/utils.d.ts +1 -1
- package/types/tabs/index.d.ts +5 -4
- package/types/tabs/tab-panel.d.ts +6 -6
- package/types/tabs/tabs.d.ts +6 -6
- package/types/tabs/types.d.ts +1 -1
- package/types/tag/index.d.ts +9 -7
- package/types/time-line/index.d.ts +5 -5
- package/types/time-line/timeline-item.d.ts +5 -5
- package/types/time-line/timeline.d.ts +6 -6
- package/types/tooltip/index.d.ts +21 -35
- package/types/tour/index.d.ts +34 -23
- package/types/transfer/index.d.ts +18 -5
- package/types/tree/context.d.ts +1 -1
- package/types/tree/index.d.ts +13 -10
- package/types/tree/types.d.ts +1 -1
- package/types/tree/utils.d.ts +1 -1
- package/types/tree-select/index.d.ts +14 -7
- package/types/typography/index.d.ts +26 -17
- package/types/upload/file-list.d.ts +8 -8
- package/types/upload/index.d.ts +9 -22
- package/types/upload/picture-sort.d.ts +2 -0
- package/types/upload/selector.d.ts +9 -9
- package/types/upload/types.d.ts +1 -1
- package/types/utils/checked.d.ts +1 -1
- package/types/utils/model-value.d.ts +10 -0
- package/types/utils/number.d.ts +1 -1
- package/types/utils/placement.d.ts +1 -1
- package/types/utils/popup.d.ts +11 -0
- package/types/utils/selection-tags.d.ts +18 -0
- package/types/utils/vnode.d.ts +3 -3
- package/types/utils/vue.d.ts +7 -1
- package/types/virtual-list/index.d.ts +6 -6
- package/types/watermark/index.d.ts +8 -8
- package/vetur/attributes.json +1717 -781
- package/vetur/tags.json +359 -159
- package/vetur/web-types.json +7563 -6197
- package/types/directives/transfer.d.ts +0 -2
|
@@ -42,6 +42,57 @@
|
|
|
42
42
|
"name": {
|
|
43
43
|
"type": "string"
|
|
44
44
|
},
|
|
45
|
+
"behavior": {
|
|
46
|
+
"type": "object",
|
|
47
|
+
"required": [
|
|
48
|
+
"rules"
|
|
49
|
+
],
|
|
50
|
+
"properties": {
|
|
51
|
+
"rules": {
|
|
52
|
+
"type": "array",
|
|
53
|
+
"items": {
|
|
54
|
+
"type": "string"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"methods": {
|
|
58
|
+
"type": "array",
|
|
59
|
+
"items": {
|
|
60
|
+
"type": "string"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"slots": {
|
|
64
|
+
"type": "array",
|
|
65
|
+
"items": {
|
|
66
|
+
"type": "string"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"slotsComplete": {
|
|
70
|
+
"type": "boolean"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"models": {
|
|
75
|
+
"type": "array",
|
|
76
|
+
"items": {
|
|
77
|
+
"type": "object",
|
|
78
|
+
"required": [
|
|
79
|
+
"prop",
|
|
80
|
+
"event",
|
|
81
|
+
"directive"
|
|
82
|
+
],
|
|
83
|
+
"properties": {
|
|
84
|
+
"prop": {
|
|
85
|
+
"type": "string"
|
|
86
|
+
},
|
|
87
|
+
"event": {
|
|
88
|
+
"type": "string"
|
|
89
|
+
},
|
|
90
|
+
"directive": {
|
|
91
|
+
"type": "string"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
45
96
|
"tags": {
|
|
46
97
|
"type": "array",
|
|
47
98
|
"items": {
|
|
@@ -137,6 +188,22 @@
|
|
|
137
188
|
"boolean": {
|
|
138
189
|
"type": "boolean"
|
|
139
190
|
},
|
|
191
|
+
"enumValues": {
|
|
192
|
+
"type": "array",
|
|
193
|
+
"items": {
|
|
194
|
+
"type": [
|
|
195
|
+
"string",
|
|
196
|
+
"number",
|
|
197
|
+
"boolean"
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"required": {
|
|
202
|
+
"type": "boolean"
|
|
203
|
+
},
|
|
204
|
+
"defaultExpression": {
|
|
205
|
+
"type": "string"
|
|
206
|
+
},
|
|
140
207
|
"documented": {
|
|
141
208
|
"type": "boolean"
|
|
142
209
|
}
|
package/ai/mcp.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import process from "node:process";
|
|
4
|
-
import {
|
|
4
|
+
import { validateUsage } from "./validate.mjs";
|
|
5
5
|
|
|
6
6
|
const metadata = JSON.parse(fs.readFileSync(new URL("./kui-components.json", import.meta.url)));
|
|
7
7
|
const byName = new Map(metadata.components.map((item) => [item.name.toLowerCase(), item]));
|
|
@@ -10,18 +10,54 @@ const byTag = new Map(
|
|
|
10
10
|
[item.name, ...item.tags].map((tag) => [tag.toLowerCase(), item]),
|
|
11
11
|
),
|
|
12
12
|
);
|
|
13
|
+
const templates = JSON.parse(fs.readFileSync(new URL("./templates/index.json", import.meta.url)));
|
|
13
14
|
const tools = [
|
|
14
15
|
["search_components", "Search components by name, tag, or API description", "query"],
|
|
15
|
-
["get_component_api", "Get
|
|
16
|
+
["get_component_api", "Get component API and behavior contracts without example source", "name"],
|
|
17
|
+
["list_component_examples", "List example IDs and titles for a component", "name"],
|
|
18
|
+
[
|
|
19
|
+
"get_component_example",
|
|
20
|
+
"Read one complete example; pass its ID from list_component_examples",
|
|
21
|
+
"name",
|
|
22
|
+
],
|
|
23
|
+
["list_templates", "List runnable business templates (optional search query)", "query"],
|
|
24
|
+
["get_template", "Read a complete runnable Vue business template", "id"],
|
|
16
25
|
["recommend_components", "Recommend components for a UI requirement", "requirement"],
|
|
17
|
-
[
|
|
26
|
+
[
|
|
27
|
+
"validate_kui_usage",
|
|
28
|
+
"Check static props, values, events, models and known slots; reports skipped checks, not full type safety",
|
|
29
|
+
"source",
|
|
30
|
+
],
|
|
18
31
|
].map(([name, description, argument]) => ({
|
|
19
32
|
name,
|
|
20
33
|
description,
|
|
21
34
|
inputSchema: {
|
|
22
35
|
type: "object",
|
|
23
|
-
properties: {
|
|
24
|
-
|
|
36
|
+
properties: {
|
|
37
|
+
[argument]: { type: "string" },
|
|
38
|
+
...(["search_components", "list_component_examples"].includes(name)
|
|
39
|
+
? {
|
|
40
|
+
offset: { type: "integer", minimum: 0 },
|
|
41
|
+
limit: { type: "integer", minimum: 1, maximum: 20 },
|
|
42
|
+
}
|
|
43
|
+
: {}),
|
|
44
|
+
...(name === "get_component_api"
|
|
45
|
+
? {
|
|
46
|
+
section: {
|
|
47
|
+
type: "string",
|
|
48
|
+
enum: ["all", "props", "events", "slots", "behavior", "models"],
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
: {}),
|
|
52
|
+
...(name === "get_component_example" ? { id: { type: "string" } } : {}),
|
|
53
|
+
},
|
|
54
|
+
required:
|
|
55
|
+
name === "list_templates"
|
|
56
|
+
? []
|
|
57
|
+
: name === "get_component_example"
|
|
58
|
+
? [argument, "id"]
|
|
59
|
+
: [argument],
|
|
60
|
+
additionalProperties: false,
|
|
25
61
|
},
|
|
26
62
|
}));
|
|
27
63
|
const prompts = [
|
|
@@ -35,26 +71,12 @@ const prompts = [
|
|
|
35
71
|
}));
|
|
36
72
|
const promptText = {
|
|
37
73
|
build_form: ({ fields = "" }) =>
|
|
38
|
-
`
|
|
74
|
+
`Adapt this runnable Kui Vue template for fields: ${fields}.\n${getTemplate("form").setup}\n${getTemplate("form").source}`,
|
|
39
75
|
build_table: ({ columns = "" }) =>
|
|
40
|
-
`
|
|
76
|
+
`Adapt this runnable Kui Vue template for columns: ${columns}.\n${getTemplate("table").setup}\n${getTemplate("table").source}`,
|
|
41
77
|
build_modal_editor: ({ entity = "" }) =>
|
|
42
|
-
`
|
|
78
|
+
`Adapt this runnable Kui Vue template for entity: ${entity}.\n${getTemplate("modal-editor").setup}\n${getTemplate("modal-editor").source}`,
|
|
43
79
|
};
|
|
44
|
-
const standardAttributes = new Set([
|
|
45
|
-
"class",
|
|
46
|
-
"style",
|
|
47
|
-
"id",
|
|
48
|
-
"key",
|
|
49
|
-
"ref",
|
|
50
|
-
"role",
|
|
51
|
-
"title",
|
|
52
|
-
"slot",
|
|
53
|
-
"name",
|
|
54
|
-
"aria-label",
|
|
55
|
-
"tabindex",
|
|
56
|
-
]);
|
|
57
|
-
|
|
58
80
|
const search = (query) => {
|
|
59
81
|
const terms = String(query).toLowerCase().split(/\s+/).filter(Boolean);
|
|
60
82
|
return metadata.components.filter((item) => {
|
|
@@ -80,77 +102,46 @@ const recommend = (requirement) => {
|
|
|
80
102
|
.forEach((item) => names.add(item.name));
|
|
81
103
|
return [...names].map((name) => byName.get(name.toLowerCase())).filter(Boolean);
|
|
82
104
|
};
|
|
83
|
-
const validate = (source) =>
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
if (Array.isArray(node.children)) node.children.forEach(visit);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const validateElement = (node) => {
|
|
107
|
-
const component = byTag.get(node.tag.toLowerCase());
|
|
108
|
-
if (!component) return;
|
|
109
|
-
const publicNames = new Set(
|
|
110
|
-
component.props.flatMap((prop) => [
|
|
111
|
-
prop.name.toLowerCase(),
|
|
112
|
-
prop.name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`).toLowerCase(),
|
|
113
|
-
]),
|
|
114
|
-
);
|
|
115
|
-
|
|
116
|
-
for (const attribute of node.props) {
|
|
117
|
-
let rawName;
|
|
118
|
-
if (attribute.type === NodeTypes.ATTRIBUTE) {
|
|
119
|
-
rawName = attribute.name;
|
|
120
|
-
} else if (
|
|
121
|
-
attribute.type === NodeTypes.DIRECTIVE &&
|
|
122
|
-
(attribute.name === "bind" || attribute.name === "model") &&
|
|
123
|
-
attribute.arg?.type === NodeTypes.SIMPLE_EXPRESSION &&
|
|
124
|
-
attribute.arg.isStatic
|
|
125
|
-
) {
|
|
126
|
-
rawName =
|
|
127
|
-
attribute.name === "model" && !attribute.arg.content
|
|
128
|
-
? "modelValue"
|
|
129
|
-
: attribute.arg.content;
|
|
130
|
-
} else if (attribute.type === NodeTypes.DIRECTIVE && attribute.name === "model") {
|
|
131
|
-
rawName = "modelValue";
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (!rawName) continue;
|
|
135
|
-
const name = rawName.toLowerCase();
|
|
136
|
-
if (standardAttributes.has(name) || name.startsWith("aria-") || name.startsWith("data-")) {
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
if (!publicNames.has(name)) {
|
|
140
|
-
issues.push({
|
|
141
|
-
kind: "prop",
|
|
142
|
-
component: component.name,
|
|
143
|
-
prop: rawName,
|
|
144
|
-
message: `Unknown prop ${rawName} on ${component.name}`,
|
|
145
|
-
line: attribute.loc.start.line,
|
|
146
|
-
column: attribute.loc.start.column,
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
}
|
|
105
|
+
const validate = (source) => validateUsage(source, metadata);
|
|
106
|
+
const getComponent = (name) => {
|
|
107
|
+
const item = byName.get(String(name).toLowerCase()) || byTag.get(String(name).toLowerCase());
|
|
108
|
+
if (!item) throw new Error(`Unknown component: ${name}`);
|
|
109
|
+
return item;
|
|
110
|
+
};
|
|
111
|
+
const pageOf = (items, args) => ({
|
|
112
|
+
total: items.length,
|
|
113
|
+
offset: args.offset || 0,
|
|
114
|
+
items: items.slice(args.offset || 0, (args.offset || 0) + (args.limit || 10)),
|
|
115
|
+
});
|
|
116
|
+
const getTemplate = (id) => {
|
|
117
|
+
const entry = templates.find((item) => item.id === id);
|
|
118
|
+
if (!entry) throw new Error(`Unknown template: ${id}`);
|
|
119
|
+
return {
|
|
120
|
+
...entry,
|
|
121
|
+
setup:
|
|
122
|
+
"Vue 3.5+ with kui-vue installed; import kui-vue/style/index.css once in main.ts. Save source as App.vue. Mock requests are local and must be replaced for production.",
|
|
123
|
+
source: fs.readFileSync(new URL(`./templates/${entry.file}`, import.meta.url), "utf8"),
|
|
150
124
|
};
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
125
|
+
};
|
|
126
|
+
const validateArguments = (name, args) => {
|
|
127
|
+
const tool = tools.find((item) => item.name === name);
|
|
128
|
+
if (!tool) throw new Error(`Unknown tool: ${name}`);
|
|
129
|
+
if (!args || typeof args !== "object" || Array.isArray(args))
|
|
130
|
+
throw new Error("Arguments must be an object");
|
|
131
|
+
for (const key of tool.inputSchema.required)
|
|
132
|
+
if (!(key in args)) throw new Error(`Missing argument: ${key}`);
|
|
133
|
+
for (const [key, value] of Object.entries(args)) {
|
|
134
|
+
const spec = tool.inputSchema.properties[key];
|
|
135
|
+
if (!spec) throw new Error(`Unknown argument: ${key}`);
|
|
136
|
+
if (spec.type === "string" && typeof value !== "string")
|
|
137
|
+
throw new Error(`${key} must be a string`);
|
|
138
|
+
if (
|
|
139
|
+
spec.type === "integer" &&
|
|
140
|
+
(!Number.isInteger(value) || value < spec.minimum || (spec.maximum && value > spec.maximum))
|
|
141
|
+
)
|
|
142
|
+
throw new Error(`${key} is out of range`);
|
|
143
|
+
if (spec.enum && !spec.enum.includes(value)) throw new Error(`Invalid ${key}`);
|
|
144
|
+
}
|
|
154
145
|
};
|
|
155
146
|
const toolResult = (value) => ({
|
|
156
147
|
content: [{ type: "text", text: JSON.stringify(value, null, 2) }],
|
|
@@ -166,80 +157,133 @@ process.stdin.on("data", (chunk) => {
|
|
|
166
157
|
buffer = lines.pop() || "";
|
|
167
158
|
for (const line of lines) {
|
|
168
159
|
if (!line.trim()) continue;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
.
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
} else if (
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
160
|
+
let request;
|
|
161
|
+
try {
|
|
162
|
+
request = JSON.parse(line);
|
|
163
|
+
} catch {
|
|
164
|
+
send({ jsonrpc: "2.0", id: null, error: { code: -32700, message: "Invalid JSON" } });
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (!request || typeof request !== "object" || Array.isArray(request)) {
|
|
168
|
+
send({ jsonrpc: "2.0", id: null, error: { code: -32600, message: "Invalid request" } });
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
let result = {};
|
|
173
|
+
if (request.method === "initialize") {
|
|
174
|
+
result = {
|
|
175
|
+
protocolVersion: "2025-06-18",
|
|
176
|
+
capabilities: { tools: {}, resources: {}, prompts: {} },
|
|
177
|
+
serverInfo: { name: "kui-vue", version: metadata.version },
|
|
178
|
+
};
|
|
179
|
+
} else if (request.method === "tools/list") result = { tools };
|
|
180
|
+
else if (request.method === "resources/list") {
|
|
181
|
+
result = {
|
|
182
|
+
resources: metadata.components.map((item) => ({
|
|
183
|
+
uri: `kui-vue://components/${item.name}`,
|
|
184
|
+
name: item.name,
|
|
185
|
+
description: item.documentation,
|
|
186
|
+
mimeType: "application/json",
|
|
187
|
+
})),
|
|
188
|
+
};
|
|
189
|
+
} else if (request.method === "resources/read") {
|
|
190
|
+
const name =
|
|
191
|
+
String(request.params?.uri || "")
|
|
192
|
+
.split("/")
|
|
193
|
+
.at(-1) || "";
|
|
194
|
+
const item = byName.get(name.toLowerCase());
|
|
195
|
+
result = {
|
|
196
|
+
contents: item
|
|
197
|
+
? [
|
|
198
|
+
{
|
|
199
|
+
uri: request.params.uri,
|
|
200
|
+
mimeType: "application/json",
|
|
201
|
+
text: JSON.stringify(item, null, 2),
|
|
202
|
+
},
|
|
203
|
+
]
|
|
204
|
+
: [],
|
|
205
|
+
};
|
|
206
|
+
} else if (request.method === "prompts/list") result = { prompts };
|
|
207
|
+
else if (request.method === "prompts/get") {
|
|
208
|
+
const create = promptText[request.params?.name];
|
|
209
|
+
result = {
|
|
210
|
+
description: prompts.find((item) => item.name === request.params?.name)?.description,
|
|
211
|
+
messages: create
|
|
212
|
+
? [
|
|
213
|
+
{
|
|
214
|
+
role: "user",
|
|
215
|
+
content: { type: "text", text: create(request.params?.arguments || {}) },
|
|
216
|
+
},
|
|
217
|
+
]
|
|
218
|
+
: [],
|
|
219
|
+
};
|
|
220
|
+
} else if (request.method === "tools/call") {
|
|
221
|
+
const { name, arguments: args = {} } = request.params || {};
|
|
222
|
+
validateArguments(name, args);
|
|
223
|
+
let value;
|
|
224
|
+
if (name === "search_components") {
|
|
225
|
+
value = pageOf(
|
|
226
|
+
search(args.query).map(({ name, tags, documentation }) => ({
|
|
227
|
+
name,
|
|
228
|
+
tags,
|
|
229
|
+
documentation,
|
|
230
|
+
})),
|
|
231
|
+
args,
|
|
232
|
+
);
|
|
233
|
+
} else if (name === "get_component_api") {
|
|
234
|
+
const { examples, ...api } = getComponent(args.name);
|
|
235
|
+
value =
|
|
236
|
+
args.section && args.section !== "all"
|
|
237
|
+
? { name: api.name, version: metadata.version, [args.section]: api[args.section] }
|
|
238
|
+
: { ...api, version: metadata.version, exampleCount: examples.length };
|
|
239
|
+
} else if (name === "list_component_examples") {
|
|
240
|
+
value = pageOf(
|
|
241
|
+
getComponent(args.name).examples.map(({ title, file }) => ({ id: file, title })),
|
|
242
|
+
args,
|
|
243
|
+
);
|
|
244
|
+
} else if (name === "get_component_example") {
|
|
245
|
+
const example = getComponent(args.name).examples.find((item) => item.file === args.id);
|
|
246
|
+
if (!example) throw new Error(`Unknown example: ${args.id}`);
|
|
247
|
+
value = example;
|
|
248
|
+
} else if (name === "list_templates") {
|
|
249
|
+
value = templates.filter(
|
|
250
|
+
(item) =>
|
|
251
|
+
!args.query || JSON.stringify(item).toLowerCase().includes(args.query.toLowerCase()),
|
|
252
|
+
);
|
|
253
|
+
} else if (name === "get_template") {
|
|
254
|
+
value = getTemplate(args.id);
|
|
255
|
+
} else if (name === "recommend_components") {
|
|
256
|
+
value = recommend(args.requirement).map(
|
|
257
|
+
({ name, tags, documentation, parent, children }) => ({
|
|
258
|
+
name,
|
|
259
|
+
tags,
|
|
260
|
+
documentation,
|
|
261
|
+
parent,
|
|
262
|
+
children,
|
|
263
|
+
}),
|
|
264
|
+
);
|
|
265
|
+
} else if (name === "validate_kui_usage") value = validate(args.source);
|
|
266
|
+
else value = { error: `Unknown tool: ${name}` };
|
|
267
|
+
result = toolResult(value);
|
|
268
|
+
} else if (!["notifications/initialized", "ping"].includes(request.method)) {
|
|
269
|
+
if (request.id !== undefined)
|
|
270
|
+
send({
|
|
271
|
+
jsonrpc: "2.0",
|
|
272
|
+
id: request.id,
|
|
273
|
+
error: { code: -32601, message: "Unknown method" },
|
|
274
|
+
});
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
if (request.id !== undefined) send({ jsonrpc: "2.0", id: request.id, result });
|
|
278
|
+
} catch (error) {
|
|
279
|
+
if (request.id !== undefined)
|
|
280
|
+
send({
|
|
281
|
+
jsonrpc: "2.0",
|
|
282
|
+
id: request.id,
|
|
283
|
+
...(request.method === "tools/call"
|
|
284
|
+
? { result: { isError: true, content: [{ type: "text", text: error.message }] } }
|
|
285
|
+
: { error: { code: -32602, message: error.message } }),
|
|
286
|
+
});
|
|
242
287
|
}
|
|
243
|
-
if (request.id !== undefined) send({ jsonrpc: "2.0", id: request.id, result });
|
|
244
288
|
}
|
|
245
289
|
});
|
|
@@ -13,7 +13,8 @@ description: Build Vue 3 interfaces with Kui Vue components and APIs. Use when c
|
|
|
13
13
|
4. Prefer existing Kui Vue controls, layout primitives, popup behavior, theme, size, and shape conventions over custom replacements.
|
|
14
14
|
5. Use TypeScript types exported by `kui-vue`; avoid `any` and native-element substitutions when a library component exists.
|
|
15
15
|
6. After changes, run the consuming project's typecheck, lint, and relevant tests.
|
|
16
|
-
7. When
|
|
16
|
+
7. When MCP is available, query `get_component_api` for exact APIs and behavior/model contracts. Fetch only the needed example via `list_component_examples` and `get_component_example`; use `get_template` for common business flows.
|
|
17
|
+
8. Run `validate_kui_usage` before finishing, read its `skipped` checks, and still run application typecheck and relevant tests. Static `valid` does not mean the code is fully verified.
|
|
17
18
|
|
|
18
19
|
## Common patterns
|
|
19
20
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# Kui Vue MCP
|
|
2
2
|
|
|
3
|
-
Start
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- `
|
|
8
|
-
- `
|
|
9
|
-
- `
|
|
10
|
-
- `
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Component resources
|
|
3
|
+
Start with `pnpm exec kui-vue-mcp` in the consuming project.
|
|
4
|
+
|
|
5
|
+
- `search_components({ query, offset?, limit? })`: paginated component discovery (default 10, max 20).
|
|
6
|
+
- `recommend_components({ requirement })`: suggested component names.
|
|
7
|
+
- `get_component_api({ name, section? })`: props/events/slots/models/behavior or all; excludes example source.
|
|
8
|
+
- `list_component_examples({ name, offset?, limit? })`: titles and IDs.
|
|
9
|
+
- `get_component_example({ name, id })`: one complete example.
|
|
10
|
+
- `list_templates({ query? })`: business template summaries.
|
|
11
|
+
- `get_template({ id })`: runnable form, table or modal-editor SFC and setup instructions.
|
|
12
|
+
- `validate_kui_usage({ source })`: static prop/value/event/model/known-slot checks. Read skipped checks; valid does not guarantee type or runtime correctness.
|
|
13
|
+
|
|
14
|
+
Component resources remain available at `kui-vue://components/{Name}` (full metadata). Prefer tools for smaller responses. Prompts build_form/build_table/build_modal_editor include the corresponding complete template. Templates use local mock requests, not a production backend.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { reactive, ref } from "vue";
|
|
3
|
+
import { Button, Form, FormItem, Input, Space, type FormRule, type FormSubmitEvent } from "kui-vue";
|
|
4
|
+
|
|
5
|
+
const model = reactive({ name: "", email: "" });
|
|
6
|
+
const saving = ref(false);
|
|
7
|
+
const result = ref("");
|
|
8
|
+
const rules: Record<string, FormRule[]> = {
|
|
9
|
+
name: [{ required: true, message: "请输入姓名" }],
|
|
10
|
+
email: [
|
|
11
|
+
{ required: true, message: "请输入邮箱" },
|
|
12
|
+
{ type: "mail", message: "邮箱格式不正确" },
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
async function onSubmit({ valid }: FormSubmitEvent) {
|
|
16
|
+
if (!valid || saving.value) return;
|
|
17
|
+
saving.value = true;
|
|
18
|
+
result.value = "";
|
|
19
|
+
try {
|
|
20
|
+
// Replace this local mock with your API request. Keep the snapshot stable during saving.
|
|
21
|
+
const payload = { ...model };
|
|
22
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
23
|
+
result.value = `已保存:${payload.name}`;
|
|
24
|
+
} catch {
|
|
25
|
+
result.value = "保存失败,请重试";
|
|
26
|
+
} finally {
|
|
27
|
+
saving.value = false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<template>
|
|
33
|
+
<Form
|
|
34
|
+
:model="model"
|
|
35
|
+
:rules="rules"
|
|
36
|
+
:disabled="saving"
|
|
37
|
+
layout="vertical"
|
|
38
|
+
@submit="onSubmit"
|
|
39
|
+
@reset="result = ''"
|
|
40
|
+
>
|
|
41
|
+
<FormItem label="姓名" prop="name"><Input /></FormItem>
|
|
42
|
+
<FormItem label="邮箱" prop="email"><Input /></FormItem>
|
|
43
|
+
<Space>
|
|
44
|
+
<Button type="primary" html-type="submit" :loading="saving" :disabled="saving">保存</Button>
|
|
45
|
+
<Button html-type="reset" :disabled="saving">重置</Button>
|
|
46
|
+
</Space>
|
|
47
|
+
<p role="status">{{ result }}</p>
|
|
48
|
+
</Form>
|
|
49
|
+
</template>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "form",
|
|
4
|
+
"title": "Validated form",
|
|
5
|
+
"description": "Required/email validation, disabled state, submit, reset, loading and error handling.",
|
|
6
|
+
"file": "form.vue",
|
|
7
|
+
"components": ["Form", "FormItem", "Input", "Button", "Space"]
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "table",
|
|
11
|
+
"title": "Searchable paginated table",
|
|
12
|
+
"description": "Local asynchronous mock API, search, paging, loading, errors and stale response protection.",
|
|
13
|
+
"file": "table.vue",
|
|
14
|
+
"components": ["Table", "Page", "Input", "Button", "Space"]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "modal-editor",
|
|
18
|
+
"title": "Create/edit modal",
|
|
19
|
+
"description": "Isolated editing draft, validation, asynchronous save, cancel and loading state.",
|
|
20
|
+
"file": "modal-editor.vue",
|
|
21
|
+
"components": ["Modal", "Form", "FormItem", "Input", "Button", "Space"]
|
|
22
|
+
}
|
|
23
|
+
]
|