gitea_workflow_init
Initialize issue workflow configuration for Gitea projects by generating .gitea/issue-workflow.yaml with labels, board columns, and automation rules based on project type.
Instructions
Initialize Issue workflow configuration for a project. Generates .gitea/issue-workflow.yaml with labels, board columns, and automation rules based on project type.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | No | Repository owner. Uses context if not provided | |
| repo | No | Repository name. Uses context if not provided | |
| project_type | Yes | Project type for template selection | |
| language | No | Primary programming language (e.g., go, typescript, python) |
Implementation Reference
- src/tools/workflow.ts:63-96 (handler)The core handler function `workflowInit` that initializes the Gitea issue workflow by generating a default .gitea/issue-workflow.yaml configuration file based on the project type and optional language. It resolves owner/repo from context, generates config using helpers, serializes to YAML, and returns the content.export async function workflowInit( ctx: WorkflowToolsContext, args: { owner?: string; repo?: string; project_type: ProjectType; language?: string; } ): Promise<{ success: boolean; message: string; config_path: string; config_content: string; }> { logger.debug({ args }, 'Initializing workflow config'); const { owner, repo } = ctx.contextManager.resolveOwnerRepo(args.owner, args.repo); // 生成默认配置 const config = generateDefaultConfig(repo, args.project_type, `${owner}/${repo}`, args.language); // 序列化为 YAML const yamlContent = serializeConfig(config); const configPath = '.gitea/issue-workflow.yaml'; logger.info({ owner, repo, project_type: args.project_type }, 'Workflow config generated'); return { success: true, message: `工作流配置已生成,请将以下内容保存到 ${configPath}`, config_path: configPath, config_content: yamlContent, }; }
- src/tools-registry/workflow-registry.ts:19-52 (registration)Tool registration for 'gitea_workflow_init' in the MCP server, including title, description, Zod input schema validation, and handler wrapper that calls the workflowInit function from workflow tools.mcpServer.registerTool( 'gitea_workflow_init', { title: '初始化工作流配置', description: 'Initialize Issue workflow configuration for a project. Generates .gitea/issue-workflow.yaml with labels, board columns, and automation rules based on project type.', inputSchema: z.object({ owner: z.string().optional().describe('Repository owner. Uses context if not provided'), repo: z.string().optional().describe('Repository name. Uses context if not provided'), project_type: z .enum(['backend', 'frontend', 'fullstack', 'library']) .describe('Project type for template selection'), language: z.string().optional().describe('Primary programming language (e.g., go, typescript, python)'), }), }, async (args) => { try { const result = await WorkflowTools.workflowInit( { client: ctx.client, contextManager: ctx.contextManager }, args ); return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }], isError: !result.success, }; } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: 'text' as const, text: `Error: ${errorMessage}` }], isError: true, }; } } );
- Zod input schema defining parameters for the tool: optional owner/repo (resolved from context), required project_type enum, optional language.inputSchema: z.object({ owner: z.string().optional().describe('Repository owner. Uses context if not provided'), repo: z.string().optional().describe('Repository name. Uses context if not provided'), project_type: z .enum(['backend', 'frontend', 'fullstack', 'library']) .describe('Project type for template selection'), language: z.string().optional().describe('Primary programming language (e.g., go, typescript, python)'), }), },