@opentiny/tiny-vue-mcp 0.0.2 → 0.0.3
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/dist/index.d.ts +2 -0
- package/dist/index.js +20 -16
- package/dist/src/form/index.d.ts +5 -0
- package/dist/src/form/index.js +44 -0
- package/dist/src/grid/index.js +22 -22
- package/dist/src/lang/en.d.ts +18 -0
- package/dist/src/lang/en.js +19 -1
- package/dist/src/lang/zh-CN.d.ts +18 -0
- package/dist/src/lang/zh-CN.js +19 -1
- package/dist/src/tree/index.d.ts +5 -0
- package/dist/src/tree/index.js +49 -0
- package/dist/src/utils/defineTool.js +4 -4
- package/index.ts +5 -1
- package/package.json +2 -2
- package/src/form/index.ts +67 -0
- package/src/form/resouces.en.md +3 -0
- package/src/form/resouces.zh.md +3 -0
- package/src/grid/index.ts +1 -0
- package/src/lang/en.ts +24 -1
- package/src/lang/zh-CN.ts +21 -2
- package/src/tree/index.ts +77 -0
- package/src/tree/resouces.en.md +3 -0
- package/src/tree/resouces.zh.md +3 -0
- package/src/utils/defineTool.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,9 @@ export declare const getTinyVueMcpConfig: ({ t }?: {
|
|
|
15
15
|
version: string;
|
|
16
16
|
components: {
|
|
17
17
|
Grid: import('./src/utils/defineComponentTool').RealComponentTool;
|
|
18
|
+
Tree: import('./src/utils/defineComponentTool').RealComponentTool;
|
|
18
19
|
BaseSelect: import('./src/utils/defineComponentTool').RealComponentTool;
|
|
19
20
|
Button: import('./src/utils/defineComponentTool').RealComponentTool;
|
|
21
|
+
Form: import('./src/utils/defineComponentTool').RealComponentTool;
|
|
20
22
|
};
|
|
21
23
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
import { defineTool as
|
|
2
|
-
import { default as
|
|
3
|
-
import { default as
|
|
4
|
-
import { getGridConfig as
|
|
5
|
-
import {
|
|
1
|
+
import { defineTool as m } from "./src/utils/defineTool.js";
|
|
2
|
+
import { default as y } from "./src/lang/zh-CN.js";
|
|
3
|
+
import { default as G } from "./src/lang/en.js";
|
|
4
|
+
import { getGridConfig as n } from "./src/grid/index.js";
|
|
5
|
+
import { getTreeConfig as f } from "./src/tree/index.js";
|
|
6
|
+
import { getBaseSelectConfig as p } from "./src/base-select/index.js";
|
|
6
7
|
import { i18n as e } from "./src/utils/locale.js";
|
|
7
|
-
import { getButtonConfig as
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import { getButtonConfig as g } from "./src/button/index.js";
|
|
9
|
+
import { getFormConfig as c } from "./src/form/index.js";
|
|
10
|
+
const B = (o, { server: t, business: r }, i) => {
|
|
11
|
+
m({ business: r, componentMcpConfig: i, instance: o, server: t });
|
|
12
|
+
}, x = ({ t: o } = {}) => (e && o && (e.t = o), {
|
|
11
13
|
name: "tiny-vue-mcp",
|
|
12
14
|
version: "0.0.1",
|
|
13
15
|
components: {
|
|
14
|
-
Grid:
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
Grid: n(),
|
|
17
|
+
Tree: f(),
|
|
18
|
+
BaseSelect: p(),
|
|
19
|
+
Button: g(),
|
|
20
|
+
Form: c()
|
|
17
21
|
}
|
|
18
22
|
});
|
|
19
23
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
B as createMcpTools,
|
|
25
|
+
G as enUS,
|
|
26
|
+
x as getTinyVueMcpConfig,
|
|
23
27
|
e as i18n,
|
|
24
|
-
|
|
28
|
+
y as zhCN
|
|
25
29
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z as i } from "zod";
|
|
2
|
+
import { defineComponentTool as o } from "../utils/defineComponentTool.js";
|
|
3
|
+
import { t as a } from "../utils/locale.js";
|
|
4
|
+
const d = () => o({
|
|
5
|
+
name: "form_component_tools",
|
|
6
|
+
description: a("ai.form.description"),
|
|
7
|
+
tools: {
|
|
8
|
+
resetFields: {
|
|
9
|
+
paramsSchema: i.boolean().optional().describe(a("ai.form.resetFields")),
|
|
10
|
+
cb: (e) => (e.resetFields(), { type: "text", text: "success" })
|
|
11
|
+
},
|
|
12
|
+
clearValidate: {
|
|
13
|
+
paramsSchema: i.string().optional().describe(a("ai.form.clearValidate")),
|
|
14
|
+
cb: (e, t) => {
|
|
15
|
+
if (typeof t == "string" && t) {
|
|
16
|
+
const r = t.split(",");
|
|
17
|
+
r.length > 0 ? e.clearValidate(r) : e.clearValidate(t);
|
|
18
|
+
}
|
|
19
|
+
return { type: "text", text: "success" };
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
clearValidateAll: {
|
|
23
|
+
paramsSchema: i.boolean().optional().describe(a("ai.form.clearValidateAll")),
|
|
24
|
+
cb: (e) => (e.clearValidate(), { type: "text", text: "success" })
|
|
25
|
+
},
|
|
26
|
+
validate: {
|
|
27
|
+
paramsSchema: i.boolean().optional().describe(a("ai.form.validate")),
|
|
28
|
+
cb: async (e) => ({ type: "text", text: await e.validate() ? "success" : "fail" })
|
|
29
|
+
},
|
|
30
|
+
validateField: {
|
|
31
|
+
paramsSchema: i.string().optional().describe(a("ai.form.validateField")),
|
|
32
|
+
cb: (e, t) => {
|
|
33
|
+
if (typeof t == "string" && t) {
|
|
34
|
+
const r = t.split(",");
|
|
35
|
+
r.length > 0 ? e.validateField(r) : e.validateField(t);
|
|
36
|
+
}
|
|
37
|
+
return { type: "text", text: "success" };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
export {
|
|
43
|
+
d as getFormConfig
|
|
44
|
+
};
|
package/dist/src/grid/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z as
|
|
1
|
+
import { z as r } from "zod";
|
|
2
2
|
import { defineComponentTool as s } from "../utils/defineComponentTool.js";
|
|
3
3
|
import { t as a } from "../utils/locale.js";
|
|
4
4
|
const p = () => s({
|
|
@@ -6,63 +6,63 @@ const p = () => s({
|
|
|
6
6
|
description: a("ai.grid.description"),
|
|
7
7
|
tools: {
|
|
8
8
|
scrollToRow: {
|
|
9
|
-
paramsSchema:
|
|
9
|
+
paramsSchema: r.record(r.any()).optional().describe(a("ai.grid.scrollToRow")),
|
|
10
10
|
cb: (e, t) => {
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
13
|
-
return e.scrollToRow(
|
|
11
|
+
const o = e.getRowById(t._RID);
|
|
12
|
+
if (o)
|
|
13
|
+
return e.scrollToRow(o), { type: "text", text: "success" };
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
getColumns: {
|
|
17
|
-
paramsSchema:
|
|
17
|
+
paramsSchema: r.boolean().optional().describe(a("ai.grid.getColumns")),
|
|
18
18
|
cb: (e) => {
|
|
19
|
-
const
|
|
19
|
+
const o = e.getColumns().filter((i) => i.property && i.title).map((i) => ({
|
|
20
20
|
property: i.property,
|
|
21
21
|
title: i.title
|
|
22
22
|
}));
|
|
23
|
-
return { type: "text", text: JSON.stringify(
|
|
23
|
+
return { type: "text", text: JSON.stringify(o) };
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
getTableData: {
|
|
27
|
-
paramsSchema:
|
|
27
|
+
paramsSchema: r.boolean().optional().describe(a("ai.grid.getTableData")),
|
|
28
28
|
cb: (e) => {
|
|
29
29
|
const t = e.getTableData().tableData;
|
|
30
30
|
return { type: "text", text: JSON.stringify(t) };
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
setSelection: {
|
|
34
|
-
paramsSchema:
|
|
34
|
+
paramsSchema: r.record(r.any()).optional().describe(a("ai.grid.setSelection")),
|
|
35
35
|
cb: (e, t) => {
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
return e.setSelection(
|
|
36
|
+
const o = e.getRowById(t._RID);
|
|
37
|
+
if (o)
|
|
38
|
+
return e.scrollToRow(o), e.setSelection(o, !0), { type: "text", text: "success" };
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
setAllSelection: {
|
|
42
|
-
paramsSchema:
|
|
42
|
+
paramsSchema: r.boolean().optional().describe(a("ai.grid.setAllSelection")),
|
|
43
43
|
cb: (e, t) => (e.setAllSelection(t), { type: "text", text: "success" })
|
|
44
44
|
},
|
|
45
45
|
insertRow: {
|
|
46
|
-
paramsSchema:
|
|
46
|
+
paramsSchema: r.record(r.any()).optional().describe(a("ai.grid.insertRow")),
|
|
47
47
|
cb: (e, t) => (e.insert(t), { type: "text", text: "success" })
|
|
48
48
|
},
|
|
49
49
|
updateRow: {
|
|
50
|
-
paramsSchema:
|
|
50
|
+
paramsSchema: r.record(r.any()).optional().describe(a("ai.grid.updateRow")),
|
|
51
51
|
cb: (e, t) => {
|
|
52
52
|
if (t) {
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
55
|
-
return Object.assign(
|
|
53
|
+
const o = e.getRowById(t._RID);
|
|
54
|
+
if (o)
|
|
55
|
+
return Object.assign(o, t), { type: "text", text: "success" };
|
|
56
56
|
}
|
|
57
57
|
return { type: "text", text: "failed" };
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
removeRow: {
|
|
61
|
-
paramsSchema:
|
|
61
|
+
paramsSchema: r.record(r.any()).optional().describe(a("ai.grid.removeRow")),
|
|
62
62
|
cb: (e, t) => {
|
|
63
63
|
if (t) {
|
|
64
|
-
const
|
|
65
|
-
return e.remove(
|
|
64
|
+
const o = e.getRowById(t._RID);
|
|
65
|
+
return e.remove(o), { type: "text", text: "success" };
|
|
66
66
|
}
|
|
67
67
|
return { type: "text", text: "failed" };
|
|
68
68
|
}
|
package/dist/src/lang/en.d.ts
CHANGED
|
@@ -22,6 +22,24 @@ declare const _default: {
|
|
|
22
22
|
description: string;
|
|
23
23
|
triggerClick: string;
|
|
24
24
|
};
|
|
25
|
+
tree: {
|
|
26
|
+
description: string;
|
|
27
|
+
getTreeData: string;
|
|
28
|
+
setCurrentKey: string;
|
|
29
|
+
expandHlNode: string;
|
|
30
|
+
collapseHlNode: string;
|
|
31
|
+
removeNode: string;
|
|
32
|
+
insertBefore: string;
|
|
33
|
+
insertAfter: string;
|
|
34
|
+
};
|
|
35
|
+
form: {
|
|
36
|
+
description: string;
|
|
37
|
+
resetFields: string;
|
|
38
|
+
clearValidate: string;
|
|
39
|
+
clearValidateAll: string;
|
|
40
|
+
validate: string;
|
|
41
|
+
validateField: string;
|
|
42
|
+
};
|
|
25
43
|
};
|
|
26
44
|
};
|
|
27
45
|
export default _default;
|
package/dist/src/lang/en.js
CHANGED
|
@@ -5,7 +5,7 @@ const e = {
|
|
|
5
5
|
scrollToRow: 'Scroll to specified row, need to pass the data of the row to scroll to, requirement: the data must contain the "_RID" field',
|
|
6
6
|
getTableData: "Get table data",
|
|
7
7
|
getColumns: 'Get table column configuration, "property" field represents the field property of table data, "title" represents the column title',
|
|
8
|
-
setSelection: 'Select a row in the table, need to pass the data to be selected, requirement:
|
|
8
|
+
setSelection: 'Select a row in the table, need to pass the data to be selected, requirement: the data must contain the "_RID" field',
|
|
9
9
|
setAllSelection: "Set table full selection status, true: select all, false: cancel all selection",
|
|
10
10
|
insertRow: "Insert or add a row of data, need to get table data first, then add corresponding data according to the table data format",
|
|
11
11
|
updateRow: 'Update specified row data in the table, need to pass the data to be updated, requirement: the data must contain the "_RID" field',
|
|
@@ -21,6 +21,24 @@ const e = {
|
|
|
21
21
|
button: {
|
|
22
22
|
description: "Button component related tool set",
|
|
23
23
|
triggerClick: "Button click, click the button"
|
|
24
|
+
},
|
|
25
|
+
tree: {
|
|
26
|
+
description: "Collection of Tools Related to Tree Control Components",
|
|
27
|
+
getTreeData: "Obtain table data",
|
|
28
|
+
setCurrentKey: "Please enter the ID value to set the current selected state of a node",
|
|
29
|
+
expandHlNode: "Please enter the ID value to set the current deployment status of a node",
|
|
30
|
+
collapseHlNode: "Please enter the ID value to set the collapsed state of a node",
|
|
31
|
+
removeNode: "Please enter the ID value to delete a node",
|
|
32
|
+
insertBefore: "Add a node in front of a node",
|
|
33
|
+
insertAfter: "Add a node after a node"
|
|
34
|
+
},
|
|
35
|
+
form: {
|
|
36
|
+
description: "Form component related tool set, including getting form validation, resetting form and other functions",
|
|
37
|
+
resetFields: "Reset the entire form, resetting all field values to their initial values and removing validation results",
|
|
38
|
+
clearValidate: "Remove the validation results of the form item, you can pass in the prop of the form item to be removed, or an array of props, if not passed in, the validation results of the entire form will be removed",
|
|
39
|
+
clearValidateAll: "Remove the validation results of the entire form",
|
|
40
|
+
validate: "Validate the entire form, the parameter is a callback function (the callback function will be called after the validation is completed and passed two parameters: 1, whether the validation is successful 2, the fields that failed validation) returns a Promise object",
|
|
41
|
+
validateField: "Validate the specified field by passing in the prop of the form item to be validated, or separating the props with commas"
|
|
24
42
|
}
|
|
25
43
|
}
|
|
26
44
|
};
|
package/dist/src/lang/zh-CN.d.ts
CHANGED
|
@@ -22,6 +22,24 @@ declare const _default: {
|
|
|
22
22
|
description: string;
|
|
23
23
|
triggerClick: string;
|
|
24
24
|
};
|
|
25
|
+
tree: {
|
|
26
|
+
description: string;
|
|
27
|
+
getTreeData: string;
|
|
28
|
+
setCurrentKey: string;
|
|
29
|
+
expandHlNode: string;
|
|
30
|
+
collapseHlNode: string;
|
|
31
|
+
removeNode: string;
|
|
32
|
+
insertBefore: string;
|
|
33
|
+
insertAfter: string;
|
|
34
|
+
};
|
|
35
|
+
form: {
|
|
36
|
+
description: string;
|
|
37
|
+
resetFields: string;
|
|
38
|
+
clearValidate: string;
|
|
39
|
+
clearValidateAll: string;
|
|
40
|
+
validate: string;
|
|
41
|
+
validateField: string;
|
|
42
|
+
};
|
|
25
43
|
};
|
|
26
44
|
};
|
|
27
45
|
export default _default;
|
package/dist/src/lang/zh-CN.js
CHANGED
|
@@ -5,7 +5,7 @@ const e = {
|
|
|
5
5
|
scrollToRow: '滚动到指定行,需要传递需要滚动的行的数据,要求数据中包含"_RID"字段',
|
|
6
6
|
getTableData: "获取表格数据",
|
|
7
7
|
getColumns: '获取表格列配置,"property" 字段代表表格数据的字段属性,"title" 代表表格列的标题',
|
|
8
|
-
setSelection: '
|
|
8
|
+
setSelection: '选中或者选择表格一条数据,需要传递需要选中的数据,要求数据中包含"_RID"字段',
|
|
9
9
|
setAllSelection: "用来设置表格全选状态,true:全选,false:取消全选",
|
|
10
10
|
insertRow: "插入或者新增一行数据,需要先获取表格数据,根据表格数据的格式新增对应的数据",
|
|
11
11
|
updateRow: '更新修改表格中指定行数据,需要传递需要更新的数据,要求数据中包含"_RID"字段',
|
|
@@ -21,6 +21,24 @@ const e = {
|
|
|
21
21
|
button: {
|
|
22
22
|
description: "按钮组件相关工具集合",
|
|
23
23
|
triggerClick: "按钮点击,点击按钮"
|
|
24
|
+
},
|
|
25
|
+
tree: {
|
|
26
|
+
description: "树形控件组件相关工具集合",
|
|
27
|
+
getTreeData: "获取表格数据",
|
|
28
|
+
setCurrentKey: '设置节点的选中状态,要求数据中包含"id"字段',
|
|
29
|
+
expandHlNode: '设置节点的展开状态,要求数据中包含"id"字段',
|
|
30
|
+
collapseHlNode: '设置节点的收起状态,要求数据中包含"id"字段',
|
|
31
|
+
removeNode: '删除某个节点,要求数据中包含"id"字段',
|
|
32
|
+
insertBefore: '在一个节点的前面增加一个节点,要求数据中包含"id"字段',
|
|
33
|
+
insertAfter: '在一个节点的后面增加一个节点,要求数据中包含"id"字段'
|
|
34
|
+
},
|
|
35
|
+
form: {
|
|
36
|
+
description: "表单组件相关工具集合,包含获取表单校验、重置表单等功能",
|
|
37
|
+
resetFields: "对整个表单进行重置,将所有字段值重置为初始值并移除校验结果",
|
|
38
|
+
clearValidate: "移除表单项的校验结果,可传入待移除的表单项的 prop ,或者 prop 用逗号隔开,如不传则移除整个表单的校验结果",
|
|
39
|
+
clearValidateAll: "移除整个表单的校验结果",
|
|
40
|
+
validate: "对整个表单进行校验的方法,参数为一个回调函数(该回调函数会在校验结束后被调用,并传入两个参数:1、是否校验成功 2、未通过校验的字段)返回一个 Promise对象",
|
|
41
|
+
validateField: "对指定字段进行校验,可传入待校验的表单项的 prop ,或者 prop 用逗号隔开"
|
|
24
42
|
}
|
|
25
43
|
}
|
|
26
44
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z as r } from "zod";
|
|
2
|
+
import { defineComponentTool as a } from "../utils/defineComponentTool.js";
|
|
3
|
+
import { t as o } from "../utils/locale.js";
|
|
4
|
+
const p = () => a({
|
|
5
|
+
name: "tree_component_tools",
|
|
6
|
+
description: o("ai.tree.description"),
|
|
7
|
+
tools: {
|
|
8
|
+
setCurrentKey: {
|
|
9
|
+
paramsSchema: r.string().optional().describe(o("ai.tree.setCurrentKey")),
|
|
10
|
+
cb: (t, e) => (t.showCheckbox ? t.setCheckedKeys([e]) : t.setCurrentKey(e), { type: "text", text: "success" })
|
|
11
|
+
},
|
|
12
|
+
getTreeData: {
|
|
13
|
+
paramsSchema: r.boolean().optional().describe(o("ai.tree.getTreeData")),
|
|
14
|
+
cb: (t) => {
|
|
15
|
+
const e = t.data;
|
|
16
|
+
return { type: "text", text: JSON.stringify(e) };
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
expandHlNode: {
|
|
20
|
+
paramsSchema: r.string().optional().describe(o("ai.tree.expandHlNode")),
|
|
21
|
+
cb: (t, e) => (t.getNode(e).expand(), { type: "text", text: "success" })
|
|
22
|
+
},
|
|
23
|
+
collapseHlNode: {
|
|
24
|
+
paramsSchema: r.string().optional().describe(o("ai.tree.collapseHlNode")),
|
|
25
|
+
cb: (t, e) => (t.getNode(e).collapse(), { type: "text", text: "success" })
|
|
26
|
+
},
|
|
27
|
+
removeNode: {
|
|
28
|
+
paramsSchema: r.string().optional().describe(o("ai.tree.removeNode")),
|
|
29
|
+
cb: (t, e) => (t.remove(e), { type: "text", text: "success" })
|
|
30
|
+
},
|
|
31
|
+
insertBefore: {
|
|
32
|
+
paramsSchema: r.record(r.any()).optional().describe(o("ai.tree.insertBefore")),
|
|
33
|
+
cb: (t, e) => {
|
|
34
|
+
let s = 1e3;
|
|
35
|
+
return t.insertBefore({ id: s, label: e.label }, e.id), s++, { type: "text", text: "success" };
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
insertAfter: {
|
|
39
|
+
paramsSchema: r.record(r.any()).optional().describe(o("ai.tree.insertAfter")),
|
|
40
|
+
cb: (t, e) => {
|
|
41
|
+
let s = 1e3;
|
|
42
|
+
return t.insertAfter({ id: s, label: e.label }, e.id), s++, { type: "text", text: "success" };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
export {
|
|
48
|
+
p as getTreeConfig
|
|
49
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
|
|
1
|
+
const o = ({ componentMcpConfig: e, instance: a, server: s, business: t }) => {
|
|
2
|
+
const r = `${t.id}_${e.name}`, c = `${t.description}-${e.description}`, i = e.paramsSchema || {}, d = (m) => e.cb(a, m);
|
|
3
|
+
s.registerTool(r, { title: r, description: c, inputSchema: i }, d);
|
|
4
4
|
};
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
o as defineTool
|
|
7
7
|
};
|
package/index.ts
CHANGED
|
@@ -4,9 +4,11 @@ import type { Business, ComponentMcpConfig } from './src/utils/defineTool'
|
|
|
4
4
|
import zhCN from './src/lang/zh-CN'
|
|
5
5
|
import enUS from './src/lang/en'
|
|
6
6
|
import { getGridConfig } from './src/grid'
|
|
7
|
+
import { getTreeConfig } from './src/tree'
|
|
7
8
|
import { getBaseSelectConfig } from './src/base-select'
|
|
8
9
|
import { i18n } from './src/utils/locale'
|
|
9
10
|
import { getButtonConfig } from './src/button'
|
|
11
|
+
import { getFormConfig } from './src/form'
|
|
10
12
|
|
|
11
13
|
export { zhCN, enUS, i18n }
|
|
12
14
|
|
|
@@ -28,8 +30,10 @@ export const getTinyVueMcpConfig = ({ t }: { t?: ((path: string) => string) | nu
|
|
|
28
30
|
version: '0.0.1',
|
|
29
31
|
components: {
|
|
30
32
|
Grid: getGridConfig(),
|
|
33
|
+
Tree: getTreeConfig(),
|
|
31
34
|
BaseSelect: getBaseSelectConfig(),
|
|
32
|
-
Button: getButtonConfig()
|
|
35
|
+
Button: getButtonConfig(),
|
|
36
|
+
Form: getFormConfig()
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentiny/tiny-vue-mcp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"zod": "^3.25.23",
|
|
15
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
15
|
+
"@modelcontextprotocol/sdk": "^1.17.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"vite": "^6.3.1",
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { defineComponentTool } from '../utils/defineComponentTool'
|
|
3
|
+
import resourcesZh from './resouces.zh.md?raw'
|
|
4
|
+
import resourcesEn from './resouces.en.md?raw'
|
|
5
|
+
import { t } from '../utils/locale'
|
|
6
|
+
|
|
7
|
+
export const resources = {
|
|
8
|
+
zh: resourcesZh,
|
|
9
|
+
en: resourcesEn
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const getFormConfig = () =>
|
|
13
|
+
defineComponentTool({
|
|
14
|
+
name: 'form_component_tools',
|
|
15
|
+
description: t('ai.form.description'),
|
|
16
|
+
tools: {
|
|
17
|
+
resetFields: {
|
|
18
|
+
paramsSchema: z.boolean().optional().describe(t('ai.form.resetFields')),
|
|
19
|
+
cb: (instance) => {
|
|
20
|
+
instance.resetFields()
|
|
21
|
+
return { type: 'text', text: 'success' }
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
clearValidate: {
|
|
25
|
+
paramsSchema: z.string().optional().describe(t('ai.form.clearValidate')),
|
|
26
|
+
cb: (instance, value) => {
|
|
27
|
+
if (typeof value === 'string' && value) {
|
|
28
|
+
const arr = value.split(',')
|
|
29
|
+
if(arr.length > 0) {
|
|
30
|
+
instance.clearValidate(arr)
|
|
31
|
+
}else {
|
|
32
|
+
instance.clearValidate(value)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return { type: 'text', text: 'success' }
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
clearValidateAll: {
|
|
39
|
+
paramsSchema: z.boolean().optional().describe(t('ai.form.clearValidateAll')),
|
|
40
|
+
cb: (instance) => {
|
|
41
|
+
instance.clearValidate()
|
|
42
|
+
return { type: 'text', text: 'success' }
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
validate: {
|
|
46
|
+
paramsSchema: z.boolean().optional().describe(t('ai.form.validate')),
|
|
47
|
+
cb: async (instance) => {
|
|
48
|
+
const result = await instance.validate()
|
|
49
|
+
return { type: 'text', text: result ? 'success' : 'fail' }
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
validateField: {
|
|
53
|
+
paramsSchema: z.string().optional().describe(t('ai.form.validateField')),
|
|
54
|
+
cb: (instance, value) => {
|
|
55
|
+
if (typeof value === 'string' && value) {
|
|
56
|
+
const arr = value.split(',')
|
|
57
|
+
if(arr.length > 0) {
|
|
58
|
+
instance.validateField(arr)
|
|
59
|
+
}else {
|
|
60
|
+
instance.validateField(value)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return { type: 'text', text: 'success' }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
})
|
package/src/grid/index.ts
CHANGED
|
@@ -50,6 +50,7 @@ export const getGridConfig = () =>
|
|
|
50
50
|
cb: (instance, value) => {
|
|
51
51
|
const targetRow = instance.getRowById(value._RID)
|
|
52
52
|
if (targetRow) {
|
|
53
|
+
instance.scrollToRow(targetRow)
|
|
53
54
|
instance.setSelection(targetRow, true)
|
|
54
55
|
return { type: 'text', text: 'success' }
|
|
55
56
|
}
|
package/src/lang/en.ts
CHANGED
|
@@ -9,7 +9,7 @@ export default {
|
|
|
9
9
|
getColumns:
|
|
10
10
|
'Get table column configuration, "property" field represents the field property of table data, "title" represents the column title',
|
|
11
11
|
setSelection:
|
|
12
|
-
'Select a row in the table, need to pass the data to be selected, requirement:
|
|
12
|
+
'Select a row in the table, need to pass the data to be selected, requirement: the data must contain the "_RID" field',
|
|
13
13
|
setAllSelection: 'Set table full selection status, true: select all, false: cancel all selection',
|
|
14
14
|
insertRow:
|
|
15
15
|
'Insert or add a row of data, need to get table data first, then add corresponding data according to the table data format',
|
|
@@ -29,6 +29,29 @@ export default {
|
|
|
29
29
|
button: {
|
|
30
30
|
description: 'Button component related tool set',
|
|
31
31
|
triggerClick: 'Button click, click the button'
|
|
32
|
+
},
|
|
33
|
+
tree: {
|
|
34
|
+
description: 'Collection of Tools Related to Tree Control Components',
|
|
35
|
+
getTreeData: 'Obtain table data',
|
|
36
|
+
setCurrentKey: 'Please enter the ID value to set the current selected state of a node',
|
|
37
|
+
expandHlNode: 'Please enter the ID value to set the current deployment status of a node',
|
|
38
|
+
collapseHlNode: 'Please enter the ID value to set the collapsed state of a node',
|
|
39
|
+
removeNode: 'Please enter the ID value to delete a node',
|
|
40
|
+
insertBefore: 'Add a node in front of a node',
|
|
41
|
+
insertAfter: 'Add a node after a node'
|
|
42
|
+
},
|
|
43
|
+
form: {
|
|
44
|
+
description:
|
|
45
|
+
'Form component related tool set, including getting form validation, resetting form and other functions',
|
|
46
|
+
resetFields:
|
|
47
|
+
'Reset the entire form, resetting all field values to their initial values and removing validation results',
|
|
48
|
+
clearValidate:
|
|
49
|
+
'Remove the validation results of the form item, you can pass in the prop of the form item to be removed, or an array of props, if not passed in, the validation results of the entire form will be removed',
|
|
50
|
+
clearValidateAll: 'Remove the validation results of the entire form',
|
|
51
|
+
validate:
|
|
52
|
+
'Validate the entire form, the parameter is a callback function (the callback function will be called after the validation is completed and passed two parameters: 1, whether the validation is successful 2, the fields that failed validation) returns a Promise object',
|
|
53
|
+
validateField:
|
|
54
|
+
'Validate the specified field by passing in the prop of the form item to be validated, or separating the props with commas'
|
|
32
55
|
}
|
|
33
56
|
}
|
|
34
57
|
}
|
package/src/lang/zh-CN.ts
CHANGED
|
@@ -5,8 +5,7 @@ export default {
|
|
|
5
5
|
scrollToRow: '滚动到指定行,需要传递需要滚动的行的数据,要求数据中包含"_RID"字段',
|
|
6
6
|
getTableData: '获取表格数据',
|
|
7
7
|
getColumns: '获取表格列配置,"property" 字段代表表格数据的字段属性,"title" 代表表格列的标题',
|
|
8
|
-
setSelection:
|
|
9
|
-
'选中或者选择表格一条数据,需要传递需要选中的数据,要求:选中之前先滚动到选中行,要求数据中包含"_RID"字段',
|
|
8
|
+
setSelection: '选中或者选择表格一条数据,需要传递需要选中的数据,要求数据中包含"_RID"字段',
|
|
10
9
|
setAllSelection: '用来设置表格全选状态,true:全选,false:取消全选',
|
|
11
10
|
insertRow: '插入或者新增一行数据,需要先获取表格数据,根据表格数据的格式新增对应的数据',
|
|
12
11
|
updateRow: '更新修改表格中指定行数据,需要传递需要更新的数据,要求数据中包含"_RID"字段',
|
|
@@ -22,6 +21,26 @@ export default {
|
|
|
22
21
|
button: {
|
|
23
22
|
description: '按钮组件相关工具集合',
|
|
24
23
|
triggerClick: '按钮点击,点击按钮'
|
|
24
|
+
},
|
|
25
|
+
tree: {
|
|
26
|
+
description: '树形控件组件相关工具集合',
|
|
27
|
+
getTreeData: '获取表格数据',
|
|
28
|
+
setCurrentKey: '设置节点的选中状态,要求数据中包含"id"字段',
|
|
29
|
+
expandHlNode: '设置节点的展开状态,要求数据中包含"id"字段',
|
|
30
|
+
collapseHlNode: '设置节点的收起状态,要求数据中包含"id"字段',
|
|
31
|
+
removeNode: '删除某个节点,要求数据中包含"id"字段',
|
|
32
|
+
insertBefore: '在一个节点的前面增加一个节点,要求数据中包含"id"字段',
|
|
33
|
+
insertAfter: '在一个节点的后面增加一个节点,要求数据中包含"id"字段'
|
|
34
|
+
},
|
|
35
|
+
form: {
|
|
36
|
+
description: '表单组件相关工具集合,包含获取表单校验、重置表单等功能',
|
|
37
|
+
resetFields: '对整个表单进行重置,将所有字段值重置为初始值并移除校验结果',
|
|
38
|
+
clearValidate:
|
|
39
|
+
'移除表单项的校验结果,可传入待移除的表单项的 prop ,或者 prop 用逗号隔开,如不传则移除整个表单的校验结果',
|
|
40
|
+
clearValidateAll: '移除整个表单的校验结果',
|
|
41
|
+
validate:
|
|
42
|
+
'对整个表单进行校验的方法,参数为一个回调函数(该回调函数会在校验结束后被调用,并传入两个参数:1、是否校验成功 2、未通过校验的字段)返回一个 Promise对象',
|
|
43
|
+
validateField: '对指定字段进行校验,可传入待校验的表单项的 prop ,或者 prop 用逗号隔开'
|
|
25
44
|
}
|
|
26
45
|
}
|
|
27
46
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { defineComponentTool } from '../utils/defineComponentTool'
|
|
3
|
+
import resourcesZh from './resouces.zh.md?raw'
|
|
4
|
+
import resourcesEn from './resouces.en.md?raw'
|
|
5
|
+
import { t } from '../utils/locale'
|
|
6
|
+
|
|
7
|
+
export const resources = {
|
|
8
|
+
zh: resourcesZh,
|
|
9
|
+
en: resourcesEn
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const getTreeConfig = () =>
|
|
13
|
+
defineComponentTool({
|
|
14
|
+
name: 'tree_component_tools',
|
|
15
|
+
description: t('ai.tree.description'),
|
|
16
|
+
tools: {
|
|
17
|
+
setCurrentKey: {
|
|
18
|
+
paramsSchema: z.string().optional().describe(t('ai.tree.setCurrentKey')),
|
|
19
|
+
cb: (instance, value) => {
|
|
20
|
+
if(instance.showCheckbox){
|
|
21
|
+
instance.setCheckedKeys([value])
|
|
22
|
+
}else{
|
|
23
|
+
instance.setCurrentKey(value)
|
|
24
|
+
}
|
|
25
|
+
return { type: 'text', text: 'success' }
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
getTreeData: {
|
|
29
|
+
paramsSchema: z.boolean().optional().describe(t('ai.tree.getTreeData')),
|
|
30
|
+
cb: (instance) => {
|
|
31
|
+
const treeData = instance.data
|
|
32
|
+
return { type: 'text', text: JSON.stringify(treeData) }
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
expandHlNode: {
|
|
36
|
+
paramsSchema: z.string().optional().describe(t('ai.tree.expandHlNode')),
|
|
37
|
+
cb: (instance, value) => {
|
|
38
|
+
const node = instance.getNode(value)
|
|
39
|
+
node.expand()
|
|
40
|
+
return { type: 'text', text: 'success' }
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
collapseHlNode: {
|
|
44
|
+
paramsSchema: z.string().optional().describe(t('ai.tree.collapseHlNode')),
|
|
45
|
+
cb: (instance, value) => {
|
|
46
|
+
const node = instance.getNode(value)
|
|
47
|
+
node.collapse()
|
|
48
|
+
return { type: 'text', text: 'success' }
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
removeNode: {
|
|
52
|
+
paramsSchema: z.string().optional().describe(t('ai.tree.removeNode')),
|
|
53
|
+
cb: (instance, value) => {
|
|
54
|
+
instance.remove(value)
|
|
55
|
+
return { type: 'text', text: 'success' }
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
insertBefore: {
|
|
59
|
+
paramsSchema: z.record(z.any()).optional().describe(t('ai.tree.insertBefore')),
|
|
60
|
+
cb: (instance, value) => {
|
|
61
|
+
let id = 1000
|
|
62
|
+
instance.insertBefore({ id, label: value.label }, value.id)
|
|
63
|
+
id++
|
|
64
|
+
return { type: 'text', text: 'success' }
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
insertAfter: {
|
|
68
|
+
paramsSchema: z.record(z.any()).optional().describe(t('ai.tree.insertAfter')),
|
|
69
|
+
cb: (instance, value) => {
|
|
70
|
+
let id = 1000
|
|
71
|
+
instance.insertAfter({ id, label: value.label }, value.id)
|
|
72
|
+
id++
|
|
73
|
+
return { type: 'text', text: 'success' }
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
})
|
package/src/utils/defineTool.ts
CHANGED
|
@@ -37,5 +37,5 @@ export const defineTool = ({ componentMcpConfig, instance, server, business }: D
|
|
|
37
37
|
return componentMcpConfig.cb(instance, args)
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
server.
|
|
40
|
+
server.registerTool(name, { title: name, description, inputSchema: paramsSchema }, cb)
|
|
41
41
|
}
|