kodevu 0.1.37 → 0.1.39
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 +1 -1
- package/src/logger.js +3 -2
- package/src/report-generator.js +14 -9
- package/src/review-runner.js +3 -2
- package/src/utils.js +22 -0
package/package.json
CHANGED
package/src/logger.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { formatDate } from "./utils.js";
|
|
3
4
|
|
|
4
5
|
class Logger {
|
|
5
6
|
constructor() {
|
|
@@ -18,7 +19,7 @@ class Logger {
|
|
|
18
19
|
if (!fs.existsSync(config.logsDir)) {
|
|
19
20
|
fs.mkdirSync(config.logsDir, { recursive: true });
|
|
20
21
|
}
|
|
21
|
-
const date = new Date()
|
|
22
|
+
const date = formatDate(new Date()).split(" ")[0];
|
|
22
23
|
this.logFile = path.join(config.logsDir, `run-${date}.log`);
|
|
23
24
|
|
|
24
25
|
// Simple rotation: Clean up logs older than 7 days
|
|
@@ -57,7 +58,7 @@ class Logger {
|
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
_log(level, message) {
|
|
60
|
-
const timestamp = new Date()
|
|
61
|
+
const timestamp = formatDate(new Date());
|
|
61
62
|
const logLine = `[${timestamp}] [${level}] ${message}`;
|
|
62
63
|
|
|
63
64
|
// Write to file
|
package/src/report-generator.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatDate } from "./utils.js";
|
|
1
2
|
export function getCoreReviewInstruction(lang) {
|
|
2
3
|
const lowLang = (lang || "").toLowerCase();
|
|
3
4
|
if (lowLang.startsWith("zh")) {
|
|
@@ -107,7 +108,8 @@ const LOCALIZED_PHRASES = {
|
|
|
107
108
|
commitMessage: "Commit message",
|
|
108
109
|
diffNoteTruncated: "Note: The diff was truncated to fit size limits. Original: {originalLineCount} lines / {originalCharCount} chars. Included: {outputLineCount} lines / {outputCharCount} chars.",
|
|
109
110
|
diffNoteFull: "Note: Full diff provided ({originalLineCount} lines / {originalCharCount} chars).",
|
|
110
|
-
langRule: "--- LANGUAGE RULE ---\nYour entire response must be in {langName}. No other language allowed."
|
|
111
|
+
langRule: "--- LANGUAGE RULE ---\nYour entire response must be in {langName}. No other language allowed.",
|
|
112
|
+
outputDirective: "--- BEGIN REVIEW ---\nNow output your COMPLETE code review. Cover ALL four sections (Summary, Critical Issues, Suggestions, Conclusion). Do NOT ask clarifying questions, do NOT acknowledge these instructions, do NOT say you are ready. Start your response directly with the review content."
|
|
111
113
|
},
|
|
112
114
|
zh: {
|
|
113
115
|
workspaceRoot: "只读工作区上下文:",
|
|
@@ -123,7 +125,8 @@ const LOCALIZED_PHRASES = {
|
|
|
123
125
|
commitMessage: "提交信息",
|
|
124
126
|
diffNoteTruncated: "注意:Diff 已截断。原始:{originalLineCount} 行 / {originalCharCount} 字符。包含:{outputLineCount} 行 / {outputCharCount} 字符。",
|
|
125
127
|
diffNoteFull: "注意:包含完整 Diff ({originalLineCount} 行 / {originalCharCount} 字符)。",
|
|
126
|
-
langRule: "--- 语言规则 ---\n你必须完全使用 {langName} 进行回复。不得使用其他语言进行解释或总结。"
|
|
128
|
+
langRule: "--- 语言规则 ---\n你必须完全使用 {langName} 进行回复。不得使用其他语言进行解释或总结。",
|
|
129
|
+
outputDirective: "--- 开始输出审查结果 ---\n请立即输出完整的代码审查结果,必须包含全部四个章节(变更总结、核心缺陷、改进建议、审查结论)。不要提问,不要确认收到指令,不要说准备好了,直接以审查内容开始输出。"
|
|
127
130
|
},
|
|
128
131
|
"zh-tw": {
|
|
129
132
|
workspaceRoot: "唯讀工作區上下文:",
|
|
@@ -139,7 +142,8 @@ const LOCALIZED_PHRASES = {
|
|
|
139
142
|
commitMessage: "提交信息",
|
|
140
143
|
diffNoteTruncated: "注意:Diff 已截斷。原始:{originalLineCount} 行 / {originalCharCount} 字符。包含:{outputLineCount} 行 / {outputCharCount} 字符。",
|
|
141
144
|
diffNoteFull: "注意:包含完整 Diff ({originalLineCount} 行 / {originalCharCount} 字符)。",
|
|
142
|
-
langRule: "--- 語言規則 ---\n你必須完全使用 {langName} 進行回覆。不得使用其他語言進行解釋或總結。"
|
|
145
|
+
langRule: "--- 語言規則 ---\n你必須完全使用 {langName} 進行回覆。不得使用其他語言進行解釋或總結。",
|
|
146
|
+
outputDirective: "--- 開始輸出審查結果 ---\n請立即輸出完整的代碼審查結果,必須包含全部四個章節(變更總結、核心缺陷、改進建議、審查結論)。不要提問,不要確認收到指令,不要說準備好了,直接以審查內容開始輸出。"
|
|
143
147
|
}
|
|
144
148
|
};
|
|
145
149
|
|
|
@@ -176,7 +180,7 @@ export function buildPrompt(config, backend, targetInfo, details, reviewDiffPayl
|
|
|
176
180
|
`${getPhrase("repoType", lang)}: ${backend.displayName}`,
|
|
177
181
|
`${getPhrase("changeId", lang)}: ${details.displayId}`,
|
|
178
182
|
`${getPhrase("author", lang)}: ${details.author}`,
|
|
179
|
-
`${getPhrase("date", lang)}: ${details.date || "unknown"}`,
|
|
183
|
+
`${getPhrase("date", lang)}: ${formatDate(details.date) || "unknown"}`,
|
|
180
184
|
`${getPhrase("changedFiles", lang)}:\n${fileList || "(none)"}`,
|
|
181
185
|
`${getPhrase("commitMessage", lang)}:\n${details.message || "(empty)"}`
|
|
182
186
|
].join("\n");
|
|
@@ -205,7 +209,8 @@ export function buildPrompt(config, backend, targetInfo, details, reviewDiffPayl
|
|
|
205
209
|
? `${getPhrase("workspaceRoot", lang)} ${workspaceRoot}\n${getPhrase("besidesDiff", lang)}`
|
|
206
210
|
: getPhrase("noWorkspace", lang),
|
|
207
211
|
getPhrase("fileRefs", lang),
|
|
208
|
-
getPhrase("langRule", lang, { langName })
|
|
212
|
+
getPhrase("langRule", lang, { langName }),
|
|
213
|
+
getPhrase("outputDirective", lang)
|
|
209
214
|
];
|
|
210
215
|
|
|
211
216
|
return sections.filter(Boolean).join("\n\n");
|
|
@@ -260,8 +265,8 @@ export function buildReport(config, backend, targetInfo, details, diffPayloads,
|
|
|
260
265
|
`- Target: \`${targetInfo.targetDisplay || config.target}\``,
|
|
261
266
|
`- Change ID: \`${details.displayId}\``,
|
|
262
267
|
`- Author: \`${details.author}\``,
|
|
263
|
-
`- Commit Date: \`${details.date
|
|
264
|
-
`- Generated At: \`${new Date()
|
|
268
|
+
`- Commit Date: \`${formatDate(details.date)}\``,
|
|
269
|
+
`- Generated At: \`${formatDate(new Date())}\``,
|
|
265
270
|
`- Reviewer: \`${reviewer.displayName}\``,
|
|
266
271
|
`- Reviewer Exit Code: \`${reviewerResult.code}\``,
|
|
267
272
|
`- Reviewer Timed Out: \`${reviewerResult.timedOut ? "yes" : "no"}\``,
|
|
@@ -309,8 +314,8 @@ export function buildJsonReport(config, backend, targetInfo, details, diffPayloa
|
|
|
309
314
|
target: targetInfo.targetDisplay || config.target,
|
|
310
315
|
changeId: details.displayId,
|
|
311
316
|
author: details.author,
|
|
312
|
-
commitDate: details.date
|
|
313
|
-
generatedAt: new Date()
|
|
317
|
+
commitDate: formatDate(details.date),
|
|
318
|
+
generatedAt: formatDate(new Date()),
|
|
314
319
|
reviewer: {
|
|
315
320
|
name: reviewer.displayName,
|
|
316
321
|
exitCode: reviewerResult.code,
|
package/src/review-runner.js
CHANGED
|
@@ -5,7 +5,8 @@ import { logger } from "./logger.js";
|
|
|
5
5
|
import {
|
|
6
6
|
ensureDir,
|
|
7
7
|
writeTextFile,
|
|
8
|
-
writeJsonFile
|
|
8
|
+
writeJsonFile,
|
|
9
|
+
formatDate
|
|
9
10
|
} from "./utils.js";
|
|
10
11
|
import {
|
|
11
12
|
shouldWriteFormat,
|
|
@@ -42,7 +43,7 @@ async function reviewChange(config, backend, targetInfo, changeId, progress) {
|
|
|
42
43
|
repositoryType: backend.displayName,
|
|
43
44
|
target: targetInfo.targetDisplay || config.target,
|
|
44
45
|
changeId: details.displayId,
|
|
45
|
-
generatedAt: new Date()
|
|
46
|
+
generatedAt: formatDate(new Date()),
|
|
46
47
|
skipped: true,
|
|
47
48
|
message: "No file changes were captured for this change under the configured target."
|
|
48
49
|
});
|
package/src/utils.js
CHANGED
|
@@ -32,3 +32,25 @@ export function countLines(text) {
|
|
|
32
32
|
}
|
|
33
33
|
return text.split(/\r?\n/).length;
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
export function formatDate(dateInput) {
|
|
37
|
+
if (!dateInput || dateInput === "unknown") return "unknown";
|
|
38
|
+
const d = new Date(dateInput);
|
|
39
|
+
if (isNaN(d.getTime())) return dateInput;
|
|
40
|
+
|
|
41
|
+
const offsetMinutes = -d.getTimezoneOffset();
|
|
42
|
+
const offsetHours = Math.floor(Math.abs(offsetMinutes) / 60);
|
|
43
|
+
const offsetMins = Math.abs(offsetMinutes) % 60;
|
|
44
|
+
const sign = offsetMinutes >= 0 ? "+" : "-";
|
|
45
|
+
|
|
46
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
47
|
+
const year = d.getFullYear();
|
|
48
|
+
const month = pad(d.getMonth() + 1);
|
|
49
|
+
const day = pad(d.getDate());
|
|
50
|
+
const hours = pad(d.getHours());
|
|
51
|
+
const minutes = pad(d.getMinutes());
|
|
52
|
+
const seconds = pad(d.getSeconds());
|
|
53
|
+
const offset = `${sign}${pad(offsetHours)}:${pad(offsetMins)}`;
|
|
54
|
+
|
|
55
|
+
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds} ${offset}`;
|
|
56
|
+
}
|