kodevu 0.1.48 → 0.1.50
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 -12
- package/src/progress-ui.js +22 -79
- package/src/report-generator.js +0 -18
- package/src/review-runner.js +7 -7
package/package.json
CHANGED
package/src/logger.js
CHANGED
|
@@ -6,7 +6,6 @@ class Logger {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
this.config = null;
|
|
8
8
|
this.logFile = null;
|
|
9
|
-
this.progressDisplay = null;
|
|
10
9
|
this.initialized = false;
|
|
11
10
|
}
|
|
12
11
|
|
|
@@ -31,10 +30,6 @@ class Logger {
|
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
setProgressDisplay(pd) {
|
|
35
|
-
this.progressDisplay = pd;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
33
|
info(message) {
|
|
39
34
|
this._log("INFO", message);
|
|
40
35
|
}
|
|
@@ -78,14 +73,10 @@ class Logger {
|
|
|
78
73
|
// If it's debug and debug mode is off, skip console
|
|
79
74
|
if (isDebug && !this.config?.debug) return;
|
|
80
75
|
|
|
81
|
-
if (
|
|
82
|
-
|
|
76
|
+
if (isError || isWarn) {
|
|
77
|
+
console.error(logLine);
|
|
83
78
|
} else {
|
|
84
|
-
|
|
85
|
-
console.error(logLine);
|
|
86
|
-
} else {
|
|
87
|
-
console.log(logLine);
|
|
88
|
-
}
|
|
79
|
+
console.log(logLine);
|
|
89
80
|
}
|
|
90
81
|
}
|
|
91
82
|
|
package/src/progress-ui.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { logger } from "./logger.js";
|
|
2
|
-
|
|
3
1
|
function clampProgress(value) {
|
|
4
2
|
if (!Number.isFinite(value)) {
|
|
5
3
|
return 0;
|
|
@@ -8,89 +6,34 @@ function clampProgress(value) {
|
|
|
8
6
|
return Math.max(0, Math.min(1, value));
|
|
9
7
|
}
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
this.progress = 0;
|
|
16
|
-
this.stage = "";
|
|
17
|
-
this.active = false;
|
|
18
|
-
this.lastStatusLine = "";
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
start(stage = "starting") {
|
|
22
|
-
this.active = true;
|
|
23
|
-
this.stage = stage;
|
|
24
|
-
logger.debug(`${this.label} batch start: ${stage}`);
|
|
25
|
-
this.writeStatus();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
update(progress, stage) {
|
|
29
|
-
this.progress = clampProgress(progress);
|
|
30
|
-
|
|
31
|
-
if (stage) {
|
|
32
|
-
this.stage = stage;
|
|
33
|
-
logger.debug(`${this.label} stage: ${stage} (${Math.round(this.progress * 100)}%)`);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
this.writeStatus();
|
|
37
|
-
}
|
|
9
|
+
function formatStatusLine(label, progress, stage) {
|
|
10
|
+
const pct = `${Math.round(progress * 100)}`.padStart(3, " ");
|
|
11
|
+
return `[progress] ${pct}% ${label}${stage ? ` | ${stage}` : ""}`;
|
|
12
|
+
}
|
|
38
13
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
this.display.writeLine(message);
|
|
43
|
-
}
|
|
14
|
+
export function createProgressReporter(label, options = {}) {
|
|
15
|
+
const stream = options.stream || process.stdout;
|
|
16
|
+
let lastStatusLine = "";
|
|
44
17
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
this.finish("[done]", 1, finalMsg);
|
|
48
|
-
logger.debug(`${this.label} batch succeed: ${finalMsg}`);
|
|
18
|
+
function writeLine(message) {
|
|
19
|
+
stream.write(`${message}\n`);
|
|
49
20
|
}
|
|
50
21
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
logger.error(`${this.label} batch fail: ${finalMsg}`);
|
|
55
|
-
}
|
|
22
|
+
return {
|
|
23
|
+
update(progress, stage = "") {
|
|
24
|
+
const line = formatStatusLine(label, clampProgress(progress), stage);
|
|
56
25
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
this.display.writeLine(`${prefix} ${message}`);
|
|
61
|
-
}
|
|
26
|
+
if (line === lastStatusLine) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
62
29
|
|
|
63
|
-
|
|
64
|
-
|
|
30
|
+
lastStatusLine = line;
|
|
31
|
+
writeLine(line);
|
|
32
|
+
},
|
|
65
33
|
|
|
66
|
-
|
|
67
|
-
|
|
34
|
+
finish(status, message) {
|
|
35
|
+
const prefix = status === "fail" ? "[fail]" : "[done]";
|
|
36
|
+
writeLine(`${prefix} ${message || label}`);
|
|
68
37
|
}
|
|
69
|
-
|
|
70
|
-
this.lastStatusLine = line;
|
|
71
|
-
this.display.writeLine(line);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
buildStatusLine() {
|
|
75
|
-
const pct = `${Math.round(this.progress * 100)}`.padStart(3, " ");
|
|
76
|
-
return `[progress] ${pct}% ${this.label}${this.stage ? ` | ${this.stage}` : ""}`;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export class ProgressDisplay {
|
|
81
|
-
constructor(options = {}) {
|
|
82
|
-
this.stream = options.stream || process.stdout;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
createItem(label) {
|
|
86
|
-
return new ProgressItem(this, label);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
writeLine(message) {
|
|
90
|
-
this.stream.write(`${message}\n`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
log(message) {
|
|
94
|
-
this.writeLine(message);
|
|
95
|
-
}
|
|
38
|
+
};
|
|
96
39
|
}
|
package/src/report-generator.js
CHANGED
|
@@ -52,7 +52,6 @@ export function shouldWriteFormat(config, format) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export function buildReport(config, backend, targetInfo, details, diffPayloads, reviewer, reviewerResult, tokenUsage) {
|
|
55
|
-
const stderrText = reviewerResult.stderr?.trim();
|
|
56
55
|
const lang = config.resolvedLang || "en";
|
|
57
56
|
const lines = [
|
|
58
57
|
`# ${backend.displayName} Review Report: ${details.displayId}`,
|
|
@@ -64,8 +63,6 @@ export function buildReport(config, backend, targetInfo, details, diffPayloads,
|
|
|
64
63
|
`- ${getPhrase("date", lang)}: \`${formatDate(details.date)}\``,
|
|
65
64
|
`- Generated At: \`${formatDate(new Date())}\``,
|
|
66
65
|
`- Reviewer: \`${reviewer.displayName}\``,
|
|
67
|
-
`- Reviewer Exit Code: \`${reviewerResult.code}\``,
|
|
68
|
-
`- Reviewer Timed Out: \`${reviewerResult.timedOut ? "yes" : "no"}\``,
|
|
69
66
|
"",
|
|
70
67
|
"## Token Usage",
|
|
71
68
|
"",
|
|
@@ -79,27 +76,12 @@ export function buildReport(config, backend, targetInfo, details, diffPayloads,
|
|
|
79
76
|
"",
|
|
80
77
|
details.message ? "```text\n" + details.message + "\n```" : "_Empty_",
|
|
81
78
|
"",
|
|
82
|
-
"## Review Context",
|
|
83
|
-
"",
|
|
84
|
-
"```text",
|
|
85
|
-
buildPrompt(config, backend, targetInfo, details, diffPayloads.review),
|
|
86
|
-
"```",
|
|
87
|
-
"",
|
|
88
|
-
"## Diff Handling",
|
|
89
|
-
"",
|
|
90
|
-
formatDiffHandling(diffPayloads.review, "Reviewer Input"),
|
|
91
|
-
formatDiffHandling(diffPayloads.report, "Report Diff"),
|
|
92
|
-
"",
|
|
93
79
|
"## Diff",
|
|
94
80
|
"",
|
|
95
81
|
"```diff",
|
|
96
82
|
diffPayloads.report.text.trim() || "(empty diff)",
|
|
97
83
|
"```",
|
|
98
84
|
"",
|
|
99
|
-
"## Reviewer Diagnostics",
|
|
100
|
-
"",
|
|
101
|
-
stderrText ? "```text\n" + stderrText + "\n```" : "_No stderr output._",
|
|
102
|
-
"",
|
|
103
85
|
`## ${reviewer.responseSectionTitle}`,
|
|
104
86
|
"",
|
|
105
87
|
reviewerResult.message?.trim() ? reviewerResult.message.trim() : reviewer.emptyResponseText
|
package/src/review-runner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { createProgressReporter } from "./progress-ui.js";
|
|
3
3
|
import { resolveRepositoryContext } from "./vcs-client.js";
|
|
4
4
|
import { logger } from "./logger.js";
|
|
5
5
|
import {
|
|
@@ -172,10 +172,8 @@ export async function runReviewCycle(config) {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
logger.info(`Reviewing ${backend.displayName} ${backend.changeName}s ${formatChangeList(backend, changeIdsToReview)}`);
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
const progress = progressDisplay.createItem(`${backend.displayName} ${backend.changeName} batch`);
|
|
178
|
-
progress.start("0/" + changeIdsToReview.length + " completed");
|
|
175
|
+
const progress = createProgressReporter(`${backend.displayName} ${backend.changeName} batch`);
|
|
176
|
+
progress.update(0, `0/${changeIdsToReview.length} completed`);
|
|
179
177
|
|
|
180
178
|
for (const [index, changeId] of changeIdsToReview.entries()) {
|
|
181
179
|
logger.debug(`Starting review for ${backend.formatChangeId(changeId)}.`);
|
|
@@ -187,11 +185,13 @@ export async function runReviewCycle(config) {
|
|
|
187
185
|
};
|
|
188
186
|
|
|
189
187
|
try {
|
|
190
|
-
await reviewChange(config, backend, targetInfo, changeId, { update: syncOverallProgress
|
|
188
|
+
await reviewChange(config, backend, targetInfo, changeId, { update: syncOverallProgress });
|
|
191
189
|
updateOverallProgress(progress, index + 1, changeIdsToReview.length, 0, `finished ${displayId}`);
|
|
192
190
|
} catch (error) {
|
|
193
|
-
progress.fail
|
|
191
|
+
progress.finish("fail", `failed at ${displayId} (${index}/${changeIdsToReview.length} completed)`);
|
|
194
192
|
throw error;
|
|
195
193
|
}
|
|
196
194
|
}
|
|
195
|
+
|
|
196
|
+
progress.finish("done", `${backend.displayName} ${backend.changeName} batch complete`);
|
|
197
197
|
}
|