@@ -168,334 +168,3 @@ $content
168168}
169169
170170
171- object CodeReviewAnalysisTemplate {
172- val EN = """
173- # Code Review Analysis
174-
175- You are an expert code reviewer. Analyze the provided code and linter results to identify the **TOP 10 HIGHEST PRIORITY** issues.
176-
177- ## Available Tools
178-
179- You have access to the following tools through DevIns commands. Use these tools to gather additional context when needed:
180-
181- ${' $' } {toolList}
182-
183- ## Tool Usage Format
184-
185- All tools use the DevIns format with JSON parameters:
186- <devin>
187- /tool-name
188- ```json
189- {"parameter": "value", "optional_param": 123}
190- ```
191- </devin>
192-
193- **IMPORTANT: Execute ONE tool at a time**
194- - ✅ Correct: One <devin> block with one tool call per response
195- - ❌ Wrong: Multiple <devin> blocks or multiple tools in one response
196-
197- ## Response Format
198-
199- For each tool call, respond with:
200- 1. Your reasoning about what to do next (explain your thinking)
201- 2. **EXACTLY ONE** DevIns command (wrapped in <devin></devin> tags)
202- 3. What you expect to happen
203-
204- After gathering all necessary information, provide your final analysis WITHOUT any tool calls.
205-
206- ## Task
207-
208- Review Type: **${' $' } {reviewType}**
209- Files to Review: **${' $' } {fileCount}** files
210-
211- ${' $' } {filePaths}
212-
213- ## Code Content
214-
215- ${' $' } {codeContent}
216-
217- ## Linter Results
218-
219- ${' $' } {lintResults}
220- ${' $' } {diffContext}
221-
222- ## Your Task
223-
224- Provide a **CONCISE SUMMARY** of the top 3-5 critical/high priority issues of all significant issues.
225-
226- **OUTPUT STRUCTURE**:
227- 1. **Console Summary** (Brief - for terminal display)
228-
229- ---
230-
231- ## Console Summary (Keep this SHORT)
232-
233- ### 📊 Quick Summary
234- One sentence overview of code quality.
235-
236- ### ⚠️ Top Priority Issues (Max 5)
237- For CRITICAL/HIGH issues only, list in this compact format:
238-
239- #### #{number}. {Title}
240- **Severity**: CRITICAL | HIGH
241- **Location**: `{file}:{line}` in `{method/class}`
242- **Problem**: {One sentence description}
243- **Fix**: {One sentence suggestion}
244-
245- ## Output Requirements
246-
247- - Use proper Markdown formatting
248- - Start with Summary, then list exactly 5 issues (or fewer if less than 5 significant issues exist)
249- - Use clear section headers with emoji indicators (📊, 🚨)
250- - Keep total output concise and focused
251- """ .trimIndent()
252-
253- val ZH = """
254- # 代码审查分析
255-
256- 你是一位专业的代码审查专家。分析提供的代码和 linter 结果,识别 **优先级最高的前 10 个问题**。
257-
258- ## 可用工具
259-
260- 你可以通过 DevIns 命令访问以下工具。在需要时使用这些工具收集额外的上下文:
261-
262- ${' $' } {toolList}
263-
264- ## 工具使用格式
265-
266- 所有工具都使用 DevIns 格式和 JSON 参数:
267- <devin>
268- /tool-name
269- ```json
270- {"parameter": "value", "optional_param": 123}
271- ```
272- </devin>
273-
274- ## 重要:每次响应只执行一个工具
275-
276- **你必须每次响应只执行一个工具。** 不要在单个响应中包含多个工具调用。
277-
278- - ✅ 正确:一个 <devin> 块包含一个工具调用
279- - ❌ 错误:多个 <devin> 块或一个块中有多个工具
280-
281- ## 响应格式
282-
283- 对于每个工具调用,请回复:
284- 1. 你对下一步该做什么的推理(解释你的思考)
285- 2. **恰好一个** DevIns 命令(包装在 <devin></devin> 标签中)
286- 3. 你期望发生什么
287-
288- 在收集完所有必要信息后,提供你的最终分析,**不要再包含任何工具调用**。
289-
290- ## 任务
291-
292- 审查类型:**${' $' } {reviewType}**
293- 待审查文件:**${' $' } {fileCount}** 个文件
294-
295- ${' $' } {filePaths}
296-
297- ## 代码内容
298-
299- ${' $' } {codeContent}
300-
301- ## Linter 结果
302-
303- ${' $' } {lintResults}
304- ${' $' } {diffContext}
305-
306- ## 你的任务
307-
308- ### ⚠️ 最高优先级问题(最多 5 个)
309- 仅列出 CRITICAL/HIGH 问题,使用此简洁格式:
310-
311- #### #{编号}. {标题}
312- **严重性**: CRITICAL | HIGH
313- **位置**: `{文件}:{行号}` 在 `{方法/类}`
314- **问题**: {一句话描述}
315- **修复**: {一句话建议}
316-
317- 1. **按严重性排序**(使用严格标准):
318- - **CRITICAL**:仅用于必然导致安全漏洞、数据丢失或系统崩溃的问题
319- - 示例:SQL 注入、泄露的密钥、关键路径中的空指针解引用
320- - **HIGH**:必然导致错误行为或显著性能下降的问题
321- - 示例:产生错误结果的逻辑错误、资源泄漏、竞态条件
322- - **MEDIUM**:在特定条件下可能导致问题
323- - 示例:缺少错误处理、次优算法、缺少验证
324- - **LOW/INFO**:不影响功能的代码质量问题
325- - 示例:代码重复、轻微样式不一致、缺少注释
326- 3. **严重性评估规则**:
327- - 除非有明确的 critical/high 影响证据,否则默认为 MEDIUM
328- - Linter 警告应为 LOW/INFO,除非它们指示实际的 bug
329- - 样式问题、命名约定、格式化 → 始终为 LOW/INFO
330- - 缺少空检查 → MEDIUM(除非证明会导致崩溃 → HIGH)
331- - 性能问题 → MEDIUM(除非通过测量证明是瓶颈 → HIGH)
332- 4. **具体说明**:始终引用确切的 文件:行号 位置
333-
334- """ .trimIndent()
335- }
336-
337- /* *
338- * Template for fix generation prompt
339- * Generates unified diff patches for identified issues
340- */
341- object FixGenerationTemplate {
342- val EN = """
343- # Code Fix Generation - Unified Diff Format
344-
345- Generate **unified diff patches** for the critical issues identified in the analysis.
346-
347- ## Original Code
348-
349- ${' $' } {codeContent}
350-
351- ## Lint Issues
352-
353- ${' $' } {lintResults}
354-
355- ## AI Analysis
356-
357- ${' $' } {analysisOutput}
358-
359- ## Your Task
360-
361- Generate **unified diff patches** for the most critical issues. Use standard unified diff format.
362-
363- ### Required Format:
364-
365- For each fix, provide a brief explanation followed by the diff patch:
366-
367- #### Fix #{number}: {Brief Title}
368- **Issue**: {One-line description}
369- **Location**: {file}:{line}
370-
371- ```diff
372- diff --git a/{filepath} b/{filepath}
373- index {old_hash}..{new_hash} {mode}
374- --- a/{filepath}
375- +++ b/{filepath}
376- @@ -{old_start},{old_count} +{new_start},{new_count} @@ {context}
377- {context line}
378- -{removed line}
379- +{added line}
380- {context line}
381- ```
382-
383- ### Example:
384-
385- #### Fix #1: Fix null pointer exception
386- **Issue**: Missing null check for user parameter
387- **Location**: src/User.kt:15
388-
389- ```diff
390- diff --git a/src/User.kt b/src/User.kt
391- index abc1234..def5678 100644
392- --- a/src/User.kt
393- +++ b/src/User.kt
394- @@ -13,7 +13,10 @@ class UserService {
395- fun processUser(user: User?) {
396- - println(user.name)
397- + if (user == null) {
398- + throw IllegalArgumentException("User cannot be null")
399- + }
400- + println(user.name)
401- }
402- }
403- ```
404-
405- ### Guidelines:
406-
407- 1. **Use standard unified diff format** - Must be parseable by standard diff tools
408- 2. **Include context lines** - Show 3 lines of context before and after changes
409- 3. **Accurate line numbers** - Ensure @@ headers have correct line numbers
410- 4. **Complete hunks** - Each hunk should be self-contained and applicable
411- 5. **One fix per patch** - Separate different fixes into different diff blocks
412- 6. **Priority order** - Start with critical/high severity issues
413- 7. **Maximum 5 patches** - Focus on the most important fixes
414-
415- **IMPORTANT**:
416- - Each diff MUST be in a ```diff code block
417- - Use exact line numbers from the original code
418- - Include enough context for patch to be applied correctly
419- - DO NOT use any tools - all code is provided above
420- """ .trimIndent()
421-
422- val ZH = """
423- # 代码修复生成 - 统一差异格式
424-
425- 为分析中识别的关键问题生成 **统一差异补丁**。
426-
427- ## 原始代码
428-
429- ${' $' } {codeContent}
430-
431- ## Lint 问题
432-
433- ${' $' } {lintResults}
434-
435- ## AI 分析
436-
437- ${' $' } {analysisOutput}
438-
439- ## 你的任务
440-
441- 为最关键的问题生成 **统一差异补丁**。使用标准的统一差异格式。
442-
443- ### 必需格式:
444-
445- 对于每个修复,提供简要说明,然后是差异补丁:
446-
447- #### 修复 #{编号}: {简要标题}
448- **问题**: {一行描述}
449- **位置**: {文件}:{行号}
450-
451- ```diff
452- diff --git a/{文件路径} b/{文件路径}
453- index {旧哈希}..{新哈希} {模式}
454- --- a/{文件路径}
455- +++ b/{文件路径}
456- @@ -{旧起始},{旧计数} +{新起始},{新计数} @@ {上下文}
457- {上下文行}
458- -{删除的行}
459- +{添加的行}
460- {上下文行}
461- ```
462-
463- ### 示例:
464-
465- #### 修复 #1: 修复空指针异常
466- **问题**: 缺少用户参数的空检查
467- **位置**: src/User.kt:15
468-
469- ```diff
470- diff --git a/src/User.kt b/src/User.kt
471- index abc1234..def5678 100644
472- --- a/src/User.kt
473- +++ b/src/User.kt
474- @@ -13,7 +13,10 @@ class UserService {
475- fun processUser(user: User?) {
476- - println(user.name)
477- + if (user == null) {
478- + throw IllegalArgumentException("User cannot be null")
479- + }
480- + println(user.name)
481- }
482- }
483- ```
484-
485- ### 指南:
486-
487- 1. **使用标准统一差异格式** - 必须可被标准差异工具解析
488- 2. **包含上下文行** - 在更改前后显示 3 行上下文
489- 3. **准确的行号** - 确保 @@ 头部有正确的行号
490- 4. **完整的块** - 每个块应该是独立的且可应用的
491- 5. **每个补丁一个修复** - 将不同的修复分成不同的差异块
492- 6. **优先级顺序** - 从关键/高严重性问题开始
493- 7. **最多 5 个补丁** - 专注于最重要的修复
494-
495- **重要**:
496- - 每个差异必须在 ```diff 代码块中
497- - 使用原始代码的确切行号
498- - 包含足够的上下文以正确应用补丁
499- - 不要使用任何工具 - 所有代码都在上面提供
500- """ .trimIndent()
501- }
0 commit comments