gitea_workflow_check_issues
Analyzes open issues for workflow compliance by identifying missing labels, detecting conflicts, and providing actionable improvement suggestions.
Instructions
Check all open issues against workflow rules. Identifies missing labels, conflicts, and provides suggestions for improvement.
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 | |
| issue_number | No | Check only a specific issue (optional) | |
| rules | No | Apply only specific rules (optional) |
Implementation Reference
- src/tools/workflow.ts:370-489 (handler)Main handler function implementing the tool logic: loads config, fetches issues, checks for missing labels, conflicts, backlog needs, and generates problems/suggestions.export async function workflowCheckIssues( ctx: WorkflowToolsContext, args: { owner?: string; repo?: string; config?: WorkflowConfig; issue_number?: number; rules?: string[]; } ): Promise<{ success: boolean; checked: number; issues_with_problems: Array<{ number: number; title: string; problems: string[]; suggestions: string[]; }>; error?: string; }> { logger.debug({ args: { ...args, config: args.config ? '[provided]' : undefined } }, 'Checking issues'); const { owner, repo } = ctx.contextManager.resolveOwnerRepo(args.owner, args.repo); // 获取配置 let config = args.config; if (!config) { const loadResult = await workflowLoadConfig(ctx, { owner, repo }); if (!loadResult.success || !loadResult.config) { return { success: false, checked: 0, issues_with_problems: [], error: loadResult.error || '无法加载配置', }; } config = loadResult.config; } const issuesWithProblems: Array<{ number: number; title: string; problems: string[]; suggestions: string[]; }> = []; try { // 获取 Issue 列表 let issues: Issue[]; if (args.issue_number) { const issue = await ctx.client.get<Issue>(`/repos/${owner}/${repo}/issues/${args.issue_number}`); issues = [issue]; } else { issues = await ctx.client.get<Issue[]>(`/repos/${owner}/${repo}/issues?state=open&limit=100`); } const inferenceEngine = new LabelInferenceEngine(config); const boardSyncManager = new BoardSyncManager(config); for (const issue of issues) { const problems: string[] = []; const suggestions: string[] = []; // 检查标签完整性 const missingLabels = inferenceEngine.checkMissingLabels(issue); if (missingLabels.length > 0) { problems.push(`缺少必要标签: ${missingLabels.join(', ')}`); // 推断标签 const inference = inferenceEngine.inferAll(issue); for (const item of inference.all) { suggestions.push(`建议添加标签 ${item.label} (置信度: ${(item.confidence * 100).toFixed(0)}%)`); } } // 检查标签冲突 const conflicts = boardSyncManager.checkLabelConflicts(issue); if (conflicts.length > 0) { problems.push(...conflicts); suggestions.push('建议保留最新的标签,移除冲突标签'); } // 检查是否需要添加到 Backlog if (boardSyncManager.shouldAddToBacklog(issue)) { const prefixes = getLabelPrefixes(config); suggestions.push(`建议添加 ${buildLabel(prefixes.status, 'backlog')} 标签`); } if (problems.length > 0 || suggestions.length > 0) { issuesWithProblems.push({ number: issue.number, title: issue.title, problems, suggestions, }); } } logger.info( { owner, repo, checked: issues.length, problems: issuesWithProblems.length }, 'Issues checked' ); return { success: true, checked: issues.length, issues_with_problems: issuesWithProblems, }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); logger.error({ owner, repo, error: errorMessage }, 'Failed to check issues'); return { success: false, checked: 0, issues_with_problems: [], error: errorMessage, }; } }
- src/tools-registry/workflow-registry.ts:153-184 (registration)MCP tool registration including name, title, description, Zod input schema, and async handler wrapper that calls the implementation.mcpServer.registerTool( 'gitea_workflow_check_issues', { title: '检查 Issue 工作流', description: 'Check all open issues against workflow rules. Identifies missing labels, conflicts, and provides suggestions for improvement.', 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'), issue_number: z.number().optional().describe('Check only a specific issue (optional)'), rules: z.array(z.string()).optional().describe('Apply only specific rules (optional)'), }), }, async (args) => { try { const result = await WorkflowTools.workflowCheckIssues( { 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: owner, repo, optional issue_number and rules.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'), issue_number: z.number().optional().describe('Check only a specific issue (optional)'), rules: z.array(z.string()).optional().describe('Apply only specific rules (optional)'), }),