Skip to content

Commit 5013944

Browse files
committed
feat: enhance tools to include framework name in descriptions and update ToolContext type
1 parent 50f9da4 commit 5013944

File tree

10 files changed

+55
-28
lines changed

10 files changed

+55
-28
lines changed

src/tools/umi-build.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import { z } from 'zod';
33
import { parse } from '../parse';
44
import { ToolContext } from '../types';
55

6-
export const umiBuild = async ({ server, root }: ToolContext) => {
6+
export const umiBuild = async ({
7+
server,
8+
root,
9+
frameworkName,
10+
}: ToolContext) => {
711
const BuildParams = z.object({
812
ANALYZE: z
913
.union([z.literal(1), z.literal(0)])
@@ -30,7 +34,7 @@ export const umiBuild = async ({ server, root }: ToolContext) => {
3034

3135
server.addTool({
3236
name: 'umi-build',
33-
description: 'Build the umi project.',
37+
description: `Build the ${frameworkName} project.`,
3438
parameters: BuildParams,
3539
execute: async (params) => {
3640
const { binPath } = parse(root);

src/tools/umi-config.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ import { z } from 'zod';
33
import { parse } from '../parse';
44
import { ToolContext } from '../types';
55

6-
export const umiConfig = async ({ server, root }: ToolContext) => {
6+
export const umiConfig = async ({
7+
server,
8+
root,
9+
frameworkName,
10+
}: ToolContext) => {
711
server.addTool({
812
name: 'umi-config-list',
9-
description: 'List all available umi config',
13+
description: `List all available ${frameworkName} config`,
1014
parameters: z.object({}),
1115
execute: async () => {
1216
const { binPath } = parse(root);
@@ -17,7 +21,7 @@ export const umiConfig = async ({ server, root }: ToolContext) => {
1721

1822
server.addTool({
1923
name: 'umi-config-get',
20-
description: 'Get the value of a config of the umi project',
24+
description: `Get the value of a config of the ${frameworkName} project`,
2125
parameters: z.object({
2226
key: z.string(),
2327
}),
@@ -30,7 +34,7 @@ export const umiConfig = async ({ server, root }: ToolContext) => {
3034

3135
server.addTool({
3236
name: 'umi-config-set',
33-
description: 'Set the value of a config of the umi project',
37+
description: `Set the value of a config of the ${frameworkName} project`,
3438
parameters: z.object({
3539
key: z.string(),
3640
value: z.string(),
@@ -46,7 +50,7 @@ export const umiConfig = async ({ server, root }: ToolContext) => {
4650

4751
server.addTool({
4852
name: 'umi-config-remove',
49-
description: 'Remove a config of the umi project',
53+
description: `Remove a config of the ${frameworkName} project`,
5054
parameters: z.object({
5155
key: z.string(),
5256
}),

src/tools/umi-deadcode.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ import { z } from 'zod';
33
import { parse } from '../parse';
44
import { ToolContext } from '../types';
55

6-
export const umiDeadcode = async ({ server, root }: ToolContext) => {
6+
export const umiDeadcode = async ({
7+
server,
8+
root,
9+
frameworkName,
10+
}: ToolContext) => {
711
server.addTool({
812
name: 'umi-deadcode',
9-
description: 'Find the dead code of the umi project',
13+
description: `Find the dead code of the ${frameworkName} project`,
1014
parameters: z.object({}),
1115
execute: async () => {
1216
const { binPath } = parse(root);

src/tools/umi-generate.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@ const executeGenerator = (command: string, cwd: string): string => {
3232
return result.toString();
3333
};
3434

35-
export const umiGenerate = async ({ server, root }: ToolContext) => {
35+
export const umiGenerate = async ({
36+
server,
37+
root,
38+
frameworkName,
39+
}: ToolContext) => {
3640
const { binPath } = parse(root);
3741

3842
// 页面生成器
3943
server.addTool({
4044
name: 'umi-generate-page',
41-
description: 'Generate a page for the umi project',
45+
description: `Generate a page for the ${frameworkName} project`,
4246
parameters: z.object({
4347
name: z.string().describe('Page name to generate'),
4448
dir: z
@@ -60,7 +64,7 @@ export const umiGenerate = async ({ server, root }: ToolContext) => {
6064
// 组件生成器
6165
server.addTool({
6266
name: 'umi-generate-component',
63-
description: 'Generate a component for the umi project',
67+
description: `Generate a component for the ${frameworkName} project`,
6468
parameters: z.object({
6569
name: z.string().describe('Component name to generate'),
6670
}),
@@ -77,7 +81,7 @@ export const umiGenerate = async ({ server, root }: ToolContext) => {
7781
// RouteAPI 生成器
7882
server.addTool({
7983
name: 'umi-generate-api',
80-
description: 'Generate a route API for the umi project',
84+
description: `Generate a route API for the ${frameworkName} project`,
8185
parameters: z.object({
8286
name: z.string().describe('API route name to generate'),
8387
}),
@@ -93,7 +97,7 @@ export const umiGenerate = async ({ server, root }: ToolContext) => {
9397
// Mock 生成器
9498
server.addTool({
9599
name: 'umi-generate-mock',
96-
description: 'Generate a mock file for the umi project',
100+
description: `Generate a mock file for the ${frameworkName} project`,
97101
parameters: z.object({
98102
name: z.string().describe('Mock file name to generate'),
99103
}),
@@ -109,7 +113,7 @@ export const umiGenerate = async ({ server, root }: ToolContext) => {
109113
// Prettier 生成器、Jest 生成器、TailwindCSS 生成器、Dva 生成器、Precommit 生成器
110114
server.addTool({
111115
name: 'umi-generate-others',
112-
description: 'Generate more tools for the umi project',
116+
description: `Generate more tools for the ${frameworkName} project`,
113117
parameters: z.object({
114118
type: z
115119
.enum(['prettier', 'jest', 'tailwindcss', 'dva', 'precommit'])

src/tools/umi-help.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { z } from 'zod';
33
import { parse } from '../parse';
44
import { ToolContext } from '../types';
55

6-
export const umiHelp = async ({ server, root }: ToolContext) => {
6+
export const umiHelp = async ({ server, root, frameworkName }: ToolContext) => {
77
server.addTool({
88
name: 'umi-help',
9-
description: 'Get help description for umi',
9+
description: `Get help description for ${frameworkName}`,
1010
parameters: z.object({}),
1111
execute: async () => {
1212
const { binPath } = parse(root);

src/tools/umi-lint.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { z } from 'zod';
33
import { parse } from '../parse';
44
import { ToolContext } from '../types';
55

6-
export const umiLint = async ({ server, root }: ToolContext) => {
6+
export const umiLint = async ({ server, root, frameworkName }: ToolContext) => {
77
server.addTool({
88
name: 'umi-lint',
9-
description: 'Run the linting of the umi project',
9+
description: `Run the linting of the ${frameworkName} project`,
1010
parameters: z.object({
1111
fix: z.boolean().optional().describe('Fix lint automatically'),
1212
eslintOnly: z

src/tools/umi-plugin.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ import { z } from 'zod';
33
import { parse } from '../parse';
44
import { ToolContext } from '../types';
55

6-
export const umiPlugin = async ({ server, root }: ToolContext) => {
6+
export const umiPlugin = async ({
7+
server,
8+
root,
9+
frameworkName,
10+
}: ToolContext) => {
711
server.addTool({
812
name: 'umi-plugin-list',
9-
description: 'List all plugins of the umi project',
13+
description: `List all plugins of the ${frameworkName} project`,
1014
parameters: z.object({}),
1115
execute: async () => {
1216
const { binPath } = parse(root);

src/tools/umi-setup.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ import { z } from 'zod';
33
import { parse } from '../parse';
44
import { ToolContext } from '../types';
55

6-
export const umiSetup = async ({ server, root }: ToolContext) => {
6+
export const umiSetup = async ({
7+
server,
8+
root,
9+
frameworkName,
10+
}: ToolContext) => {
711
server.addTool({
812
name: 'umi-setup',
9-
description:
10-
'Setup the umi project and generate the tmp files in the `.umi` directory',
13+
description: `Setup the ${frameworkName} project and generate tmp files in the .umi directory`,
1114
parameters: z.object({}),
1215
execute: async () => {
1316
const { binPath } = parse(root);

src/tools/umi-version.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ import { z } from 'zod';
33
import { parse } from '../parse';
44
import { ToolContext } from '../types';
55

6-
export const umiVersion = async ({ server, root }: ToolContext) => {
6+
export const umiVersion = async ({
7+
server,
8+
root,
9+
frameworkName,
10+
}: ToolContext) => {
711
server.addTool({
812
name: 'umi-version',
9-
description: 'Get the version of the umi project.',
13+
description: `Get the version of the ${frameworkName} project.`,
1014
parameters: z.object({}),
1115
execute: async () => {
1216
const { binPath } = parse(root);

types.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
export type ToolContext = {
33
server: any;
44
root: string;
5+
frameworkName: string;
56
};
67

7-
export function registerTools(toolContext: ToolContext) {
8-
}
8+
export function registerTools(toolContext: ToolContext): void;

0 commit comments

Comments
 (0)