kodevu 0.1.36 → 0.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kodevu",
3
- "version": "0.1.36",
3
+ "version": "0.1.37",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "Poll SVN revisions or Git commits, send each change diff to a reviewer CLI, and write configurable review reports.",
@@ -2,11 +2,65 @@ export function getCoreReviewInstruction(lang) {
2
2
  const lowLang = (lang || "").toLowerCase();
3
3
  if (lowLang.startsWith("zh")) {
4
4
  if (lowLang === "zh-tw" || lowLang === "zh-hk") {
5
- return "請嚴格審查目前的更改,優先考慮錯誤、回歸風險、相容性問題、安全問題、邊界條件缺陷和缺失的測試。請使用 Markdown 進行回覆。如果未發現明顯缺陷,請寫「未發現明顯缺陷」並補充風險。";
5
+ return `你是一位擁有 10 年以上經驗的高級軟體架構師和代碼審查專家。你的任務是對以下代碼變更進行嚴格且高質量的審查。
6
+ 你的目標是:
7
+ 1. 發現代碼中的 Bug、邏輯缺陷和潛在的回歸風險。
8
+ 2. 識別性能瓶頸、記憶體洩漏或不必要的計算。
9
+ 3. 檢查安全漏洞(如注入、越權、敏感信息洩露等)。
10
+ 4. 評估代碼的可維護性、可讀性和是否符合最佳實踐。
11
+ 5. 檢查是否涵蓋了必要的單元測試和邊界條件。
12
+
13
+ 你的輸出格式必須清晰,請使用以下 Markdown 結構:
14
+ ### 1. 變更總結 (Summary)
15
+ 簡要描述這次提交的主要目的和影響面。
16
+ ### 2. 核心缺陷 (Critical Issues)
17
+ 列出 Bug、安全隱患或會導致程序崩潰/邏輯錯誤的問題。請註明檔案名和行號。
18
+ ### 3. 改進建議 (Suggestions)
19
+ 列出關於代碼風格、性能優化或架構設計的改進點。
20
+ ### 4. 審查結論 (Conclusion)
21
+ 如果發現明顯缺陷,總結修復建議;如果未發現明顯缺陷,請說明「未發現明顯缺陷」並指出可能的殘留風險。
22
+
23
+ 注意:你正處於唯讀審查模式,請勿表現出「正在應用補丁」或「準備執行代碼」的行為。只需提供文字審查分析。`;
6
24
  }
7
- return "请严格审查当前的更改,优先处理 Bug、回归风险、兼容性问题、安全问题、边界条件缺陷和缺失的测试。请使用 Markdown 进行回复。如果未发现明显缺陷,请写“未发现明显缺陷”并补充残留风险。";
25
+ return `你是一位拥有 10 年以上经验的高级软件架构师和代码审查专家。你的任务是对以下代码变更进行严格且高质量的审查。
26
+ 你的目标是:
27
+ 1. 发现代码中的 Bug、逻辑缺陷和潜在的回归风险。
28
+ 2. 识别性能瓶颈、内存泄漏或不必要的计算。
29
+ 3. 检查安全漏洞(如注入、越权、敏感信息泄露等)。
30
+ 4. 评估代码的可维护性、可读性和是否符合最佳实践。
31
+ 5. 检查是否涵盖了必要的单元测试和边界条件。
32
+
33
+ 你的输出格式必须清晰,请使用以下 Markdown 结构:
34
+ ### 1. 变更总结 (Summary)
35
+ 简要描述这次提交的主要目的和影响面。
36
+ ### 2. 核心缺陷 (Critical Issues)
37
+ 列出 Bug、安全隐患或会导致程序崩溃/逻辑错误的问题。请注明文件名和行号。
38
+ ### 3. 改进建议 (Suggestions)
39
+ 列出关于代码风格、性能优化或架构设计的改进点。
40
+ ### 4. 审查结论 (Conclusion)
41
+ 如果发现明显缺陷,总结修复建议;如果未发现明显缺陷,请说明“未发现明显缺陷”并指出可能的残留风险。
42
+
43
+ 注意:你正处于只读审查模式,请勿表现出“正在应用补丁”或“准备执行代码”的行为。只需提供文字审查分析。`;
8
44
  }
9
- return "Please strictly review the current changes, prioritizing bugs, regression risks, compatibility issues, security concerns, boundary condition flaws, and missing tests. Please use Markdown for your response. If no clear flaws are found, write \"No clear flaws found\" and supplement with residual risks.";
45
+ return `You are a Senior Software Engineer and Code Review Expert with over 10 years of experience. Your task is to perform a rigorous and high-quality review of the following code changes.
46
+ Your goals are to:
47
+ 1. Identify bugs, logical flaws, and potential regression risks.
48
+ 2. Spot performance bottlenecks, memory leaks, or unnecessary computations.
49
+ 3. Check for security vulnerabilities (e.g., injection, authorization issues, sensitive data leaks).
50
+ 4. Evaluate maintainability, readability, and adherence to best practices.
51
+ 5. Verify coverage of necessary unit tests and boundary conditions.
52
+
53
+ Your output must be structured using the following Markdown headers:
54
+ ### 1. Summary
55
+ Briefly describe the purpose and impact of this change.
56
+ ### 2. Critical Issues
57
+ List bugs, security risks, or problems that could cause crashes or logical errors. Include file names and line numbers.
58
+ ### 3. Suggestions
59
+ List points for improvement regarding code style, performance, or architectural design.
60
+ ### 4. Conclusion
61
+ Summarize with a "Pass" or "Needs Revision". If no clear flaws are found, state "No clear flaws found" and mention any residual risks.
62
+
63
+ Note: You are in a read-only review mode. Do not act as if you are "applying the patch" or "executing code". Provide only textual analysis and feedback.`;
10
64
  }
11
65
 
12
66
  export function getReviewWorkspaceRoot(config, backend, targetInfo) {
@@ -40,52 +94,52 @@ function getLanguageDisplayName(lang) {
40
94
 
41
95
  const LOCALIZED_PHRASES = {
42
96
  en: {
43
- workspaceRoot: "You are running inside a read-only workspace rooted at:",
97
+ workspaceRoot: "Workspace context (read-only):",
44
98
  noWorkspace: "No local repository workspace is available for this review run.",
45
- besidesDiff: "Besides the diff below, you may read other related files in the workspace when needed to understand call sites, shared utilities, configuration, tests, or data flow. Do not modify files or rely on shell commands.",
46
- reviewFromDiff: "Review primarily from the diff below. Do not assume access to other local files, shell commands, or repository history.",
47
- fileRefs: "Use plain text file references like path/to/file.js:123. Do not emit clickable workspace links.",
99
+ besidesDiff: "You can read related files in the workspace to understand call sites, shared utilities, configuration, or data flow.",
100
+ reviewFromDiff: "Review primarily based on the provided diff. Do not assume access to other local files or shell commands.",
101
+ fileRefs: "Reference files using plain text like 'path/to/file.js:123'. Do not generate clickable workspace links.",
48
102
  repoType: "Repository Type",
49
103
  changeId: "Change ID",
50
104
  author: "Author",
51
105
  date: "Date",
52
106
  changedFiles: "Changed files",
53
107
  commitMessage: "Commit message",
54
- diffNoteTruncated: "Diff delivery note: the diff was truncated before being sent to the reviewer to stay within configured size limits. Original diff size was {originalLineCount} lines / {originalCharCount} chars, and the included excerpt is {outputLineCount} lines / {outputCharCount} chars. Use the changed file list and inspect related workspace files when needed.",
55
- diffNoteFull: "Diff delivery note: the full diff is included. Size is {originalLineCount} lines / {originalCharCount} chars.",
56
- langRule: "--- IMPORTANT LANGUAGE RULE ---\nYou MUST respond strictly in {langName}. No other language should be used for the explanation and comments."
108
+ diffNoteTruncated: "Note: The diff was truncated to fit size limits. Original: {originalLineCount} lines / {originalCharCount} chars. Included: {outputLineCount} lines / {outputCharCount} chars.",
109
+ diffNoteFull: "Note: Full diff provided ({originalLineCount} lines / {originalCharCount} chars).",
110
+ langRule: "--- LANGUAGE RULE ---\nYour entire response must be in {langName}. No other language allowed."
57
111
  },
58
112
  zh: {
59
- workspaceRoot: "你正运行在一个只读工作区内,根目录为:",
113
+ workspaceRoot: "只读工作区上下文:",
60
114
  noWorkspace: "此审查运行没有可用的本地仓库工作区。",
61
- besidesDiff: "除了下面的 Diff,你可以在需要时阅读工作区中的其他相关文件,以了解调用点、共享工具、配置、测试或数据流。请勿修改文件或依赖 Shell 命令。",
62
- reviewFromDiff: "主要根据下面的 Diff 进行审查。不要假设可以访问其他本地文件、Shell 命令或仓库历史。",
63
- fileRefs: "使用纯文本文件引用,如 path/to/file.js:123。不要生成可点击的工作区链接。",
115
+ besidesDiff: "你可以阅读工作区中的其他文件以了解调用点、工具类、配置或数据流。",
116
+ reviewFromDiff: "主要根据提供的 Diff 进行审查。不要假设可以访问其他文件或执行 Shell 命令。",
117
+ fileRefs: "使用纯文本引用文件,如 'path/to/file.js:123'。不要生成可点击的链接。",
64
118
  repoType: "仓库类型",
65
119
  changeId: "变更 ID",
66
120
  author: "作者",
67
121
  date: "日期",
68
122
  changedFiles: "已变更文件",
69
123
  commitMessage: "提交信息",
70
- diffNoteTruncated: "Diff 交付说明:Diff 在发送给审查者之前已被截斷,以保持在配置的大小限制内。原始 Diff 大小为 {originalLineCount} 行 / {originalCharCount} 个字符,包含的摘录为 {outputLineCount} 行 / {outputCharCount} 个字符。在需要时使用已更正文件列表并检查相关工作区文件。",
71
- diffNoteFull: "Diff 交付说明:包含完整的 Diff。大小为 {originalLineCount} 行 / {originalCharCount} 个字符。",
72
- langRule: "--- 重要语言规则 ---\n你必须严格使用 {langName} 进行回复。解释、评论和总结均不得使用其他语言。"
124
+ diffNoteTruncated: "注意:Diff 已截断。原始:{originalLineCount} 行 / {originalCharCount} 字符。包含:{outputLineCount} 行 / {outputCharCount} 字符。",
125
+ diffNoteFull: "注意:包含完整 Diff ({originalLineCount} 行 / {originalCharCount} 字符)。",
126
+ langRule: "--- 语言规则 ---\n你必须完全使用 {langName} 进行回复。不得使用其他语言进行解释或总结。"
73
127
  },
74
128
  "zh-tw": {
75
- workspaceRoot: "你正運行在一個唯讀工作區內,根目錄為:",
129
+ workspaceRoot: "唯讀工作區上下文:",
76
130
  noWorkspace: "此審查運行沒有可用的本地倉庫工作區。",
77
- besidesDiff: "除了下面的 Diff,你可以在需要時閱讀工作區中的其他相關文件,以了解調用點、共享工具、配置、測試或資料流。請勿修改文件或依賴 Shell 命令。",
78
- reviewFromDiff: "主要根據下面的 Diff 進行審查。不要假設可以訪問其他本地文件、Shell 命令或倉庫歷史。",
79
- fileRefs: "使用純文本文件引用,如 path/to/file.js:123。不要生成可點擊的工作區連結。",
131
+ besidesDiff: "你可以閱讀工作區中的其他文件以了解調用點、工具類、配置或資料流。",
132
+ reviewFromDiff: "主要根據提供的 Diff 進行審查。不要假設可以訪問其他文件或執行 Shell 命令。",
133
+ fileRefs: "使用純文本引用文件,如 'path/to/file.js:123'。不要生成可點擊的連結。",
80
134
  repoType: "倉庫類型",
81
135
  changeId: "變更 ID",
82
136
  author: "作者",
83
137
  date: "日期",
84
138
  changedFiles: "已變更文件",
85
139
  commitMessage: "提交信息",
86
- diffNoteTruncated: "Diff 交付說明:Diff 在傳送給審查者之前已被截斷,以保持在配置的大小限制內。原始 Diff 大小為 {originalLineCount} 行 / {originalCharCount} 個字符,包含的摘錄為 {outputLineCount} 行 / {outputCharCount} 個字符。在需要時使用已更正文件列表並檢查相關工作區文件。",
87
- diffNoteFull: "Diff 交付說明:包含完整的 Diff。大小為 {originalLineCount} 行 / {originalCharCount} 個字符。",
88
- langRule: "--- 重要語言規則 ---\n你必須嚴格使用 {langName} 進行回覆。解釋、評論和總結均不得使用其他語言。"
140
+ diffNoteTruncated: "注意:Diff 已截斷。原始:{originalLineCount} 行 / {originalCharCount} 字符。包含:{outputLineCount} 行 / {outputCharCount} 字符。",
141
+ diffNoteFull: "注意:包含完整 Diff ({originalLineCount} 行 / {originalCharCount} 字符)。",
142
+ langRule: "--- 語言規則 ---\n你必須完全使用 {langName} 進行回覆。不得使用其他語言進行解釋或總結。"
89
143
  }
90
144
  };
91
145
 
@@ -109,51 +163,52 @@ export function buildPrompt(config, backend, targetInfo, details, reviewDiffPayl
109
163
  const langName = getLanguageDisplayName(lang);
110
164
  const lowLang = lang.toLowerCase();
111
165
 
112
- let langInstruction = `IMPORTANT: Your entire response MUST be in ${langName}. All explanations, comments, and structure should strictly follow the ${langName} language rules.`;
113
-
166
+ let langInstruction = `CRITICAL: YOUR ENTIRE RESPONSE MUST BE IN ${langName.toUpperCase()}.`;
114
167
  if (lowLang.startsWith("zh")) {
115
168
  if (lowLang === "zh-tw" || lowLang === "zh-hk") {
116
- langInstruction += "\n請務必使用繁體中文進行回覆,所有的審查評論和分析都必須以繁體中文呈現。";
169
+ langInstruction += "\n請務必完全使用繁體中文進行回覆。";
117
170
  } else {
118
- langInstruction += "\n请务必使用简体中文进行回复,所有的审查评论和分析都必须以简体中文呈现。";
171
+ langInstruction += "\n请务必完全使用简体中文进行回复。";
119
172
  }
120
173
  }
121
174
 
122
- return [
123
- langInstruction,
124
- getCoreReviewInstruction(lang),
125
- config.prompt,
126
- canReadRelatedFiles
127
- ? `${getPhrase("workspaceRoot", lang)} ${workspaceRoot}`
128
- : getPhrase("noWorkspace", lang),
129
- canReadRelatedFiles
130
- ? getPhrase("besidesDiff", lang)
131
- : getPhrase("reviewFromDiff", lang),
132
- getPhrase("fileRefs", lang),
175
+ const metadata = [
133
176
  `${getPhrase("repoType", lang)}: ${backend.displayName}`,
134
177
  `${getPhrase("changeId", lang)}: ${details.displayId}`,
135
178
  `${getPhrase("author", lang)}: ${details.author}`,
136
179
  `${getPhrase("date", lang)}: ${details.date || "unknown"}`,
137
180
  `${getPhrase("changedFiles", lang)}:\n${fileList || "(none)"}`,
138
- `${getPhrase("commitMessage", lang)}:\n${details.message || "(empty)"}`,
139
- reviewDiffPayload.wasTruncated
140
- ? getPhrase("diffNoteTruncated", lang, {
141
- originalLineCount: reviewDiffPayload.originalLineCount,
142
- originalCharCount: reviewDiffPayload.originalCharCount,
143
- outputLineCount: reviewDiffPayload.outputLineCount,
144
- outputCharCount: reviewDiffPayload.outputCharCount
145
- })
146
- : getPhrase("diffNoteFull", lang, {
147
- originalLineCount: reviewDiffPayload.originalLineCount,
148
- originalCharCount: reviewDiffPayload.originalCharCount
149
- }),
150
- getPhrase("langRule", lang, { langName }) +
151
- (lowLang.startsWith("zh")
152
- ? lowLang === "zh-tw" || lowLang === "zh-hk"
153
- ? "\n請務必完全使用繁體中文進行回覆,所有的審查分析、注釋和總結都必須使用繁體中文。"
154
- : "\n请务必完全使用简体中文进行回复,所有的审查分析、注释和总结都必须使用简体中文。"
155
- : "")
156
- ].filter(Boolean).join("\n\n");
181
+ `${getPhrase("commitMessage", lang)}:\n${details.message || "(empty)"}`
182
+ ].join("\n");
183
+
184
+ const diffNote = reviewDiffPayload.wasTruncated
185
+ ? getPhrase("diffNoteTruncated", lang, {
186
+ originalLineCount: reviewDiffPayload.originalLineCount,
187
+ originalCharCount: reviewDiffPayload.originalCharCount,
188
+ outputLineCount: reviewDiffPayload.outputLineCount,
189
+ outputCharCount: reviewDiffPayload.outputCharCount
190
+ })
191
+ : getPhrase("diffNoteFull", lang, {
192
+ originalLineCount: reviewDiffPayload.originalLineCount,
193
+ originalCharCount: reviewDiffPayload.originalCharCount
194
+ });
195
+
196
+ const sections = [
197
+ langInstruction,
198
+ getCoreReviewInstruction(lang),
199
+ config.prompt ? `### Additional User Instructions:\n${config.prompt}` : null,
200
+ "### Change Context:",
201
+ metadata,
202
+ diffNote,
203
+ "### Environment:",
204
+ canReadRelatedFiles
205
+ ? `${getPhrase("workspaceRoot", lang)} ${workspaceRoot}\n${getPhrase("besidesDiff", lang)}`
206
+ : getPhrase("noWorkspace", lang),
207
+ getPhrase("fileRefs", lang),
208
+ getPhrase("langRule", lang, { langName })
209
+ ];
210
+
211
+ return sections.filter(Boolean).join("\n\n");
157
212
  }
158
213
 
159
214
  export function formatTokenUsage(tokenUsage) {