@opentiny/tiny-vue-mcp 0.0.1-alpha.1 → 0.0.1-alpha.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.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -13
- package/dist/src/base-select/index.js +29 -8
- package/dist/src/button/index.d.ts +5 -0
- package/dist/src/button/index.js +16 -0
- package/dist/src/grid/index.js +13 -2
- package/dist/src/lang/en.d.ts +8 -0
- package/dist/src/lang/en.js +10 -2
- package/dist/src/lang/zh-CN.d.ts +8 -0
- package/dist/src/lang/zh-CN.js +10 -2
- package/index.ts +3 -1
- package/package.json +1 -1
- package/src/base-select/index.ts +34 -0
- package/src/button/index.ts +25 -0
- package/src/button/resouces.en.md +3 -0
- package/src/button/resouces.zh.md +3 -0
- package/src/grid/index.ts +14 -0
- package/src/lang/en.ts +12 -2
- package/src/lang/zh-CN.ts +11 -2
package/dist/index.d.ts
CHANGED
|
@@ -16,5 +16,6 @@ export declare const getTinyVueMcpConfig: ({ t }?: {
|
|
|
16
16
|
components: {
|
|
17
17
|
Grid: import('./src/utils/defineComponentTool').RealComponentTool;
|
|
18
18
|
BaseSelect: import('./src/utils/defineComponentTool').RealComponentTool;
|
|
19
|
+
Button: import('./src/utils/defineComponentTool').RealComponentTool;
|
|
19
20
|
};
|
|
20
21
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import { defineTool as
|
|
2
|
-
import { default as
|
|
3
|
-
import { default as
|
|
1
|
+
import { defineTool as i } from "./src/utils/defineTool.js";
|
|
2
|
+
import { default as x } from "./src/lang/zh-CN.js";
|
|
3
|
+
import { default as T } from "./src/lang/en.js";
|
|
4
4
|
import { getGridConfig as f } from "./src/grid/index.js";
|
|
5
5
|
import { getBaseSelectConfig as m } from "./src/base-select/index.js";
|
|
6
|
-
import { i18n as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import { i18n as e } from "./src/utils/locale.js";
|
|
7
|
+
import { getButtonConfig as p } from "./src/button/index.js";
|
|
8
|
+
const l = (o, { server: t, business: r }, n) => {
|
|
9
|
+
i({ business: r, componentMcpConfig: n, instance: o, server: t });
|
|
10
|
+
}, d = ({ t: o } = {}) => (e && o && (e.t = o), {
|
|
10
11
|
name: "tiny-vue-mcp",
|
|
11
12
|
version: "0.0.1",
|
|
12
13
|
components: {
|
|
13
14
|
Grid: f(),
|
|
14
|
-
BaseSelect: m()
|
|
15
|
+
BaseSelect: m(),
|
|
16
|
+
Button: p()
|
|
15
17
|
}
|
|
16
18
|
});
|
|
17
19
|
export {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
l as createMcpTools,
|
|
21
|
+
T as enUS,
|
|
22
|
+
d as getTinyVueMcpConfig,
|
|
23
|
+
e as i18n,
|
|
24
|
+
x as zhCN
|
|
23
25
|
};
|
|
@@ -1,16 +1,37 @@
|
|
|
1
|
-
import { z as
|
|
2
|
-
import { defineComponentTool as
|
|
3
|
-
import { t as
|
|
4
|
-
const
|
|
1
|
+
import { z as c } from "zod";
|
|
2
|
+
import { defineComponentTool as l } from "../utils/defineComponentTool.js";
|
|
3
|
+
import { t as s } from "../utils/locale.js";
|
|
4
|
+
const b = () => l({
|
|
5
5
|
name: "base_select_component_tools",
|
|
6
|
-
description:
|
|
6
|
+
description: s("ai.baseSelect.description"),
|
|
7
7
|
tools: {
|
|
8
8
|
openMenu: {
|
|
9
|
-
paramsSchema:
|
|
10
|
-
cb: (
|
|
9
|
+
paramsSchema: c.boolean().describe(s("ai.baseSelect.openMenu")),
|
|
10
|
+
cb: (e, t) => (e.state.visible = t, { type: "text", text: "success" })
|
|
11
|
+
},
|
|
12
|
+
selectByLabel: {
|
|
13
|
+
paramsSchema: c.string().describe(s("ai.baseSelect.selectByLabel")),
|
|
14
|
+
cb: (e, t) => {
|
|
15
|
+
const a = (e.state.cachedOptions || []).find((o) => o.label === t);
|
|
16
|
+
return a ? (e.updateModelValue(a.value), { type: "text", text: "success" }) : { type: "text", text: `Option with label "${t}" not found.` };
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
clearValue: {
|
|
20
|
+
paramsSchema: c.string().describe(s("ai.baseSelect.clearValue")),
|
|
21
|
+
cb: (e, t) => (e.updateModelValue(""), { type: "text", text: "success" })
|
|
22
|
+
},
|
|
23
|
+
getOptions: {
|
|
24
|
+
paramsSchema: c.string().describe(s("ai.baseSelect.getOptions")),
|
|
25
|
+
cb: (e, t) => {
|
|
26
|
+
const a = (e.state.cachedOptions || []).map((o) => ({
|
|
27
|
+
label: o.label,
|
|
28
|
+
value: o.value
|
|
29
|
+
}));
|
|
30
|
+
return { type: "text", text: JSON.stringify(a) };
|
|
31
|
+
}
|
|
11
32
|
}
|
|
12
33
|
}
|
|
13
34
|
});
|
|
14
35
|
export {
|
|
15
|
-
|
|
36
|
+
b as getBaseSelectConfig
|
|
16
37
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z as i } from "zod";
|
|
2
|
+
import { defineComponentTool as n } from "../utils/defineComponentTool.js";
|
|
3
|
+
import { t } from "../utils/locale.js";
|
|
4
|
+
const p = () => n({
|
|
5
|
+
name: "button_component_tools",
|
|
6
|
+
description: t("ai.button.description"),
|
|
7
|
+
tools: {
|
|
8
|
+
triggerClick: {
|
|
9
|
+
paramsSchema: i.boolean().describe(t("ai.button.triggerClick")),
|
|
10
|
+
cb: (o, e) => (o.handleClick(e), { type: "text", text: "success" })
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
export {
|
|
15
|
+
p as getButtonConfig
|
|
16
|
+
};
|
package/dist/src/grid/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z as o } from "zod";
|
|
2
2
|
import { defineComponentTool as s } from "../utils/defineComponentTool.js";
|
|
3
3
|
import { t as r } from "../utils/locale.js";
|
|
4
|
-
const
|
|
4
|
+
const p = () => s({
|
|
5
5
|
name: "grid_component_tools",
|
|
6
6
|
description: r("ai.grid.description"),
|
|
7
7
|
tools: {
|
|
@@ -36,6 +36,17 @@ const m = () => s({
|
|
|
36
36
|
paramsSchema: o.record(o.any()).optional().describe(r("ai.grid.insertRow")),
|
|
37
37
|
cb: (t, e) => (t.insert(e), { type: "text", text: "success" })
|
|
38
38
|
},
|
|
39
|
+
updateRow: {
|
|
40
|
+
paramsSchema: o.record(o.any()).optional().describe(r("ai.grid.updateRow")),
|
|
41
|
+
cb: (t, e) => {
|
|
42
|
+
if (e && typeof e.tiny_mcp_index == "number") {
|
|
43
|
+
const a = t.getData()[e.tiny_mcp_index];
|
|
44
|
+
if (a)
|
|
45
|
+
return Object.assign(a, e), { type: "text", text: "success" };
|
|
46
|
+
}
|
|
47
|
+
return { type: "text", text: "failed" };
|
|
48
|
+
}
|
|
49
|
+
},
|
|
39
50
|
removeRow: {
|
|
40
51
|
paramsSchema: o.number().optional().describe(r("ai.grid.removeRow")),
|
|
41
52
|
cb: (t, e) => {
|
|
@@ -46,5 +57,5 @@ const m = () => s({
|
|
|
46
57
|
}
|
|
47
58
|
});
|
|
48
59
|
export {
|
|
49
|
-
|
|
60
|
+
p as getGridConfig
|
|
50
61
|
};
|
package/dist/src/lang/en.d.ts
CHANGED
|
@@ -7,11 +7,19 @@ declare const _default: {
|
|
|
7
7
|
setSelection: string;
|
|
8
8
|
setAllSelection: string;
|
|
9
9
|
insertRow: string;
|
|
10
|
+
updateRow: string;
|
|
10
11
|
removeRow: string;
|
|
11
12
|
};
|
|
12
13
|
baseSelect: {
|
|
13
14
|
description: string;
|
|
14
15
|
openMenu: string;
|
|
16
|
+
selectByLabel: string;
|
|
17
|
+
clearValue: string;
|
|
18
|
+
getOptions: string;
|
|
19
|
+
};
|
|
20
|
+
button: {
|
|
21
|
+
description: string;
|
|
22
|
+
triggerClick: string;
|
|
15
23
|
};
|
|
16
24
|
};
|
|
17
25
|
};
|
package/dist/src/lang/en.js
CHANGED
|
@@ -7,11 +7,19 @@ const e = {
|
|
|
7
7
|
setSelection: "Select the specified row,need to get the table data first,then select the data according to the index of the data in the table data,requirement:scroll to the selected row before selecting",
|
|
8
8
|
setAllSelection: "Set the table all selection status,true:all selection,false:cancel all selection,requirement:scroll to the selected row before selecting",
|
|
9
9
|
insertRow: "Insert or add a row of data,need to get the table data first,then add the corresponding data according to the format of the table data",
|
|
10
|
+
updateRow: 'Update the specified row data in the table,need to get the table data first,then update the corresponding data according to the index of the data in the table data,requirement:the index of the data in the table data is passed in as the "tiny_mcp_index" field',
|
|
10
11
|
removeRow: "Remove the specified row in the table,need to get the table data first,then remove the corresponding data according to the index of the data in the table data"
|
|
11
12
|
},
|
|
12
13
|
baseSelect: {
|
|
13
|
-
description: "Base select component related tool set, including opening the drop-down panel",
|
|
14
|
-
openMenu: "Open the drop-down panel"
|
|
14
|
+
description: "Base select component related tool set, including opening the drop-down panel,set selected value or clear selected value and get selected options",
|
|
15
|
+
openMenu: "Open the drop-down panel",
|
|
16
|
+
selectByLabel: "update select value by label",
|
|
17
|
+
clearValue: "clear select value,remove value",
|
|
18
|
+
getOptions: "get all options of the select component"
|
|
19
|
+
},
|
|
20
|
+
button: {
|
|
21
|
+
description: "Button component related tool set",
|
|
22
|
+
triggerClick: "trigger button click,click self"
|
|
15
23
|
}
|
|
16
24
|
}
|
|
17
25
|
};
|
package/dist/src/lang/zh-CN.d.ts
CHANGED
|
@@ -7,11 +7,19 @@ declare const _default: {
|
|
|
7
7
|
setSelection: string;
|
|
8
8
|
setAllSelection: string;
|
|
9
9
|
insertRow: string;
|
|
10
|
+
updateRow: string;
|
|
10
11
|
removeRow: string;
|
|
11
12
|
};
|
|
12
13
|
baseSelect: {
|
|
13
14
|
description: string;
|
|
14
15
|
openMenu: string;
|
|
16
|
+
selectByLabel: string;
|
|
17
|
+
clearValue: string;
|
|
18
|
+
getOptions: string;
|
|
19
|
+
};
|
|
20
|
+
button: {
|
|
21
|
+
description: string;
|
|
22
|
+
triggerClick: string;
|
|
15
23
|
};
|
|
16
24
|
};
|
|
17
25
|
};
|
package/dist/src/lang/zh-CN.js
CHANGED
|
@@ -7,11 +7,19 @@ const e = {
|
|
|
7
7
|
setSelection: "选中或者选择表格一条数据,需要先获取表格数据,然后根据表格数据中的数组下标索引选中或者选择数据,要求:选中之前先滚动到选中行",
|
|
8
8
|
setAllSelection: "用来设置表格全选状态,true:全选,false:取消全选",
|
|
9
9
|
insertRow: "插入或者新增一行数据,需要先获取表格数据,根据表格数据的格式新增对应的数据",
|
|
10
|
+
updateRow: '更新修改表格中指定行数据,需要先获取表格数据,根据表格数据中的数组下标索引更新对应的数据,要求:将更新数据的数组下标以"tiny_mcp_index"字段传入',
|
|
10
11
|
removeRow: "删除表格中指定行,需要先获取表格数据,根据表格数据中的数组下标索引删除对应的数据"
|
|
11
12
|
},
|
|
12
13
|
baseSelect: {
|
|
13
|
-
description: "
|
|
14
|
-
openMenu: "打开下拉面板"
|
|
14
|
+
description: "下拉组件相关工具集合,包含获取下拉数据、选中下拉数据,清除选中值等功能",
|
|
15
|
+
openMenu: "打开下拉面板",
|
|
16
|
+
selectByLabel: "根据标签选中下拉数据",
|
|
17
|
+
clearValue: "清除下拉值",
|
|
18
|
+
getOptions: "查询下拉选择的所有选项值"
|
|
19
|
+
},
|
|
20
|
+
button: {
|
|
21
|
+
description: "按钮组件相关工具集合",
|
|
22
|
+
triggerClick: "按钮点击,点击按钮"
|
|
15
23
|
}
|
|
16
24
|
}
|
|
17
25
|
};
|
package/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import enUS from './src/lang/en'
|
|
|
6
6
|
import { getGridConfig } from './src/grid'
|
|
7
7
|
import { getBaseSelectConfig } from './src/base-select'
|
|
8
8
|
import { i18n } from './src/utils/locale'
|
|
9
|
+
import { getButtonConfig } from './src/button'
|
|
9
10
|
|
|
10
11
|
export { zhCN, enUS, i18n }
|
|
11
12
|
|
|
@@ -27,7 +28,8 @@ export const getTinyVueMcpConfig = ({ t }: { t?: ((path: string) => string) | nu
|
|
|
27
28
|
version: '0.0.1',
|
|
28
29
|
components: {
|
|
29
30
|
Grid: getGridConfig(),
|
|
30
|
-
BaseSelect: getBaseSelectConfig()
|
|
31
|
+
BaseSelect: getBaseSelectConfig(),
|
|
32
|
+
Button: getButtonConfig()
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
}
|
package/package.json
CHANGED
package/src/base-select/index.ts
CHANGED
|
@@ -20,6 +20,40 @@ export const getBaseSelectConfig = () =>
|
|
|
20
20
|
instance.state.visible = value
|
|
21
21
|
return { type: 'text', text: 'success' }
|
|
22
22
|
}
|
|
23
|
+
},
|
|
24
|
+
selectByLabel: {
|
|
25
|
+
paramsSchema: z.string().describe(t('ai.baseSelect.selectByLabel')),
|
|
26
|
+
|
|
27
|
+
cb: (instance, value) => {
|
|
28
|
+
const options = instance.state.cachedOptions || []
|
|
29
|
+
const targetOption = options.find((option) => option.label === value)
|
|
30
|
+
if (targetOption) {
|
|
31
|
+
instance.updateModelValue(targetOption.value)
|
|
32
|
+
return { type: 'text', text: 'success' }
|
|
33
|
+
} else {
|
|
34
|
+
return { type: 'text', text: `Option with label "${value}" not found.` }
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
clearValue: {
|
|
39
|
+
paramsSchema: z.string().describe(t('ai.baseSelect.clearValue')),
|
|
40
|
+
|
|
41
|
+
cb: (instance, value) => {
|
|
42
|
+
instance.updateModelValue('')
|
|
43
|
+
return { type: 'text', text: 'success' }
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
getOptions: {
|
|
47
|
+
paramsSchema: z.string().describe(t('ai.baseSelect.getOptions')),
|
|
48
|
+
|
|
49
|
+
cb: (instance, value) => {
|
|
50
|
+
const options = instance.state.cachedOptions || []
|
|
51
|
+
const cleanOptions = options.map((option) => ({
|
|
52
|
+
label: option.label,
|
|
53
|
+
value: option.value
|
|
54
|
+
}))
|
|
55
|
+
return { type: 'text', text: JSON.stringify(cleanOptions) }
|
|
56
|
+
}
|
|
23
57
|
}
|
|
24
58
|
}
|
|
25
59
|
})
|
|
@@ -0,0 +1,25 @@
|
|
|
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 getButtonConfig = () =>
|
|
13
|
+
defineComponentTool({
|
|
14
|
+
name: 'button_component_tools',
|
|
15
|
+
description: t('ai.button.description'),
|
|
16
|
+
tools: {
|
|
17
|
+
triggerClick: {
|
|
18
|
+
paramsSchema: z.boolean().describe(t('ai.button.triggerClick')),
|
|
19
|
+
cb: (instance, value) => {
|
|
20
|
+
instance.handleClick(value)
|
|
21
|
+
return { type: 'text', text: 'success' }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
})
|
package/src/grid/index.ts
CHANGED
|
@@ -57,6 +57,20 @@ export const getGridConfig = () =>
|
|
|
57
57
|
return { type: 'text', text: 'success' }
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
|
+
updateRow: {
|
|
61
|
+
paramsSchema: z.record(z.any()).optional().describe(t('ai.grid.updateRow')),
|
|
62
|
+
cb: (instance, value) => {
|
|
63
|
+
if (value && typeof value.tiny_mcp_index === 'number') {
|
|
64
|
+
const tableData = instance.getData()
|
|
65
|
+
const targetRow = tableData[value.tiny_mcp_index]
|
|
66
|
+
if (targetRow) {
|
|
67
|
+
Object.assign(targetRow, value)
|
|
68
|
+
return { type: 'text', text: 'success' }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return { type: 'text', text: 'failed' }
|
|
72
|
+
}
|
|
73
|
+
},
|
|
60
74
|
removeRow: {
|
|
61
75
|
paramsSchema: z.number().optional().describe(t('ai.grid.removeRow')),
|
|
62
76
|
cb: (instance, value) => {
|
package/src/lang/en.ts
CHANGED
|
@@ -12,12 +12,22 @@ export default {
|
|
|
12
12
|
'Set the table all selection status,true:all selection,false:cancel all selection,requirement:scroll to the selected row before selecting',
|
|
13
13
|
insertRow:
|
|
14
14
|
'Insert or add a row of data,need to get the table data first,then add the corresponding data according to the format of the table data',
|
|
15
|
+
updateRow:
|
|
16
|
+
'Update the specified row data in the table,need to get the table data first,then update the corresponding data according to the index of the data in the table data,requirement:the index of the data in the table data is passed in as the "tiny_mcp_index" field',
|
|
15
17
|
removeRow:
|
|
16
18
|
'Remove the specified row in the table,need to get the table data first,then remove the corresponding data according to the index of the data in the table data'
|
|
17
19
|
},
|
|
18
20
|
baseSelect: {
|
|
19
|
-
description:
|
|
20
|
-
|
|
21
|
+
description:
|
|
22
|
+
'Base select component related tool set, including opening the drop-down panel,set selected value or clear selected value and get selected options',
|
|
23
|
+
openMenu: 'Open the drop-down panel',
|
|
24
|
+
selectByLabel: 'update select value by label',
|
|
25
|
+
clearValue: 'clear select value,remove value',
|
|
26
|
+
getOptions: 'get all options of the select component'
|
|
27
|
+
},
|
|
28
|
+
button: {
|
|
29
|
+
description: 'Button component related tool set',
|
|
30
|
+
triggerClick: 'trigger button click,click self'
|
|
21
31
|
}
|
|
22
32
|
}
|
|
23
33
|
}
|
package/src/lang/zh-CN.ts
CHANGED
|
@@ -8,11 +8,20 @@ export default {
|
|
|
8
8
|
'选中或者选择表格一条数据,需要先获取表格数据,然后根据表格数据中的数组下标索引选中或者选择数据,要求:选中之前先滚动到选中行',
|
|
9
9
|
setAllSelection: '用来设置表格全选状态,true:全选,false:取消全选',
|
|
10
10
|
insertRow: '插入或者新增一行数据,需要先获取表格数据,根据表格数据的格式新增对应的数据',
|
|
11
|
+
updateRow:
|
|
12
|
+
'更新修改表格中指定行数据,需要先获取表格数据,根据表格数据中的数组下标索引更新对应的数据,要求:将更新数据的数组下标以"tiny_mcp_index"字段传入',
|
|
11
13
|
removeRow: '删除表格中指定行,需要先获取表格数据,根据表格数据中的数组下标索引删除对应的数据'
|
|
12
14
|
},
|
|
13
15
|
baseSelect: {
|
|
14
|
-
description: '
|
|
15
|
-
openMenu: '打开下拉面板'
|
|
16
|
+
description: '下拉组件相关工具集合,包含获取下拉数据、选中下拉数据,清除选中值等功能',
|
|
17
|
+
openMenu: '打开下拉面板',
|
|
18
|
+
selectByLabel: '根据标签选中下拉数据',
|
|
19
|
+
clearValue: '清除下拉值',
|
|
20
|
+
getOptions: '查询下拉选择的所有选项值'
|
|
21
|
+
},
|
|
22
|
+
button: {
|
|
23
|
+
description: '按钮组件相关工具集合',
|
|
24
|
+
triggerClick: '按钮点击,点击按钮'
|
|
16
25
|
}
|
|
17
26
|
}
|
|
18
27
|
}
|