gitea_workflow_init
Initialize issue workflow configuration for a project 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:60-96 (handler)Core handler function for gitea_workflow_init tool. Resolves repository context, generates default workflow configuration using helpers, serializes to YAML, and returns the configuration details./** * 初始化工作流配置 */ 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)Registration of the gitea_workflow_init MCP tool, including title, description, Zod inputSchema for validation, and async handler wrapper that invokes the core workflowInit function.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, }; } } );
- src/utils/workflow-config.ts:284-353 (helper)Critical helper function `generateDefaultConfig` called by the handler to produce the complete WorkflowConfig object, including labels, board columns, automation rules, and notifications tailored to the specified project type./** * 生成默认工作流配置 */ export function generateDefaultConfig( projectName: string, projectType: ProjectType, repo: string, language?: string ): WorkflowConfig { return { project: { name: projectName, type: projectType, repo, language, }, labels: { status: DEFAULT_STATUS_LABELS, priority: DEFAULT_PRIORITY_LABELS, type: DEFAULT_TYPE_LABELS, area: AREA_LABELS_BY_TYPE[projectType], workflow: DEFAULT_WORKFLOW_LABELS, special: DEFAULT_SPECIAL_LABELS, prefixes: DEFAULT_LABEL_PREFIXES, }, board: { name: 'Issue Workflow Board', columns: DEFAULT_BOARD_COLUMNS, }, automation: { label_inference: { enabled: true, confidence_threshold: 0.7, type_keywords: DEFAULT_TYPE_KEYWORDS, priority_keywords: DEFAULT_PRIORITY_KEYWORDS, }, priority_escalation: { enabled: true, rules: DEFAULT_ESCALATION_RULES, }, blocked_detection: { enabled: true, rules: DEFAULT_BLOCKED_RULES, }, status_sync: { enabled: true, direction: 'both', conflict_resolution: 'board-wins', }, new_issue_defaults: { auto_add_to_backlog: true, require_type_label: true, require_priority_label: false, default_priority: 'P2', }, }, notifications: { blocked_issues: { enabled: true, channels: ['issue_comment'], template: '⚠️ 此 Issue 已超过 SLA 时间,请及时处理!', }, priority_escalation: { enabled: true, channels: ['issue_comment'], template: '⬆️ 优先级已自动升级为 {new_priority}', }, }, }; }