kodevu 0.1.42 → 0.1.44
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/config.js +4 -3
- package/src/report-generator.js +1 -0
- package/src/review-runner.js +3 -0
- package/src/reviewers.js +35 -13
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -161,7 +161,8 @@ export function parseCliArgs(argv) {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
if (value === "--last" || value === "-n") {
|
|
164
|
-
|
|
164
|
+
const hasLastValue = nextValue !== undefined && /^-?\d+$/.test(nextValue);
|
|
165
|
+
if (!hasLastValue) throw new Error(`Missing value for ${value}`);
|
|
165
166
|
args.last = nextValue;
|
|
166
167
|
index += 1;
|
|
167
168
|
continue;
|
|
@@ -258,7 +259,7 @@ export async function resolveConfig(cliArgs = {}) {
|
|
|
258
259
|
config.last = Number(config.last);
|
|
259
260
|
config.outputFormats = normalizeOutputFormats(config.outputFormats);
|
|
260
261
|
|
|
261
|
-
if (!config.rev && (isNaN(config.last) || config.last
|
|
262
|
+
if (!config.rev && (isNaN(config.last) || config.last === 0)) {
|
|
262
263
|
config.last = 1;
|
|
263
264
|
}
|
|
264
265
|
|
|
@@ -277,7 +278,7 @@ Options:
|
|
|
277
278
|
--prompt, -p Additional instructions or @file.txt to read from file
|
|
278
279
|
--lang, -l Output language (e.g. zh, en, auto)
|
|
279
280
|
--rev, -v Review specific revision(s), hashes, branches or ranges (comma-separated)
|
|
280
|
-
--last, -n Review the latest N revisions (
|
|
281
|
+
--last, -n Review the latest N revisions; use negative (-N) to review only the Nth-from-last revision (default: 1)
|
|
281
282
|
--output, -o Output directory (default: ~/.kodevu)
|
|
282
283
|
--format, -f Output formats (markdown, json, comma-separated)
|
|
283
284
|
--debug, -d Print extra debug information
|
package/src/report-generator.js
CHANGED
|
@@ -208,6 +208,7 @@ export function buildPrompt(config, backend, targetInfo, details, reviewDiffPayl
|
|
|
208
208
|
canReadRelatedFiles
|
|
209
209
|
? `${getPhrase("workspaceRoot", lang)} ${workspaceRoot}\n${getPhrase("besidesDiff", lang)}`
|
|
210
210
|
: getPhrase("noWorkspace", lang),
|
|
211
|
+
getPhrase("reviewFromDiff", lang),
|
|
211
212
|
getPhrase("fileRefs", lang),
|
|
212
213
|
getPhrase("langRule", lang, { langName }),
|
|
213
214
|
getPhrase("outputDirective", lang)
|
package/src/review-runner.js
CHANGED
|
@@ -159,6 +159,9 @@ export async function runReviewCycle(config) {
|
|
|
159
159
|
|
|
160
160
|
if (config.rev) {
|
|
161
161
|
changeIdsToReview = await backend.resolveChangeIds(config, targetInfo, config.rev);
|
|
162
|
+
} else if (config.last < 0) {
|
|
163
|
+
const candidates = await backend.getLatestChangeIds(config, targetInfo, Math.abs(config.last));
|
|
164
|
+
changeIdsToReview = candidates.length > 0 ? [candidates[0]] : [];
|
|
162
165
|
} else {
|
|
163
166
|
changeIdsToReview = await backend.getLatestChangeIds(config, targetInfo, config.last || 1);
|
|
164
167
|
}
|
package/src/reviewers.js
CHANGED
|
@@ -76,28 +76,50 @@ export const REVIEWERS = {
|
|
|
76
76
|
responseSectionTitle: "Copilot Response",
|
|
77
77
|
emptyResponseText: "_No final response returned from copilot._",
|
|
78
78
|
async run(config, workingDir, promptText, diffText) {
|
|
79
|
+
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "kodevu-copilot-"));
|
|
80
|
+
const reviewInputFile = path.join(tempDir, "review-input.md");
|
|
81
|
+
const copilotPrompt = [
|
|
82
|
+
`Use the file-reading tools to open this exact file path: ${reviewInputFile}`,
|
|
83
|
+
"That file contains the full review instructions and the unified diff to review.",
|
|
84
|
+
"Follow the instructions from that file exactly and output the final review directly.",
|
|
85
|
+
"Do not ask clarifying questions. Do not mention tool usage. Do not say you are ready.",
|
|
86
|
+
"Start immediately with the review content."
|
|
87
|
+
].join("\n");
|
|
79
88
|
const args = [
|
|
80
89
|
"-p",
|
|
81
|
-
|
|
90
|
+
copilotPrompt,
|
|
82
91
|
"-s",
|
|
83
92
|
"--no-color",
|
|
84
93
|
"--no-ask-user",
|
|
94
|
+
"--no-custom-instructions",
|
|
85
95
|
"--allow-all-tools",
|
|
86
96
|
"--add-dir",
|
|
87
|
-
workingDir
|
|
97
|
+
workingDir,
|
|
98
|
+
"--add-dir",
|
|
99
|
+
tempDir
|
|
88
100
|
];
|
|
89
|
-
const execResult = await runCommand("copilot", args, {
|
|
90
|
-
cwd: workingDir,
|
|
91
|
-
input: ["Unified diff:", diffText].join("\n\n"),
|
|
92
|
-
allowFailure: true,
|
|
93
|
-
timeoutMs: config.commandTimeoutMs,
|
|
94
|
-
debug: config.debug
|
|
95
|
-
});
|
|
96
101
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
try {
|
|
103
|
+
await fs.writeFile(
|
|
104
|
+
reviewInputFile,
|
|
105
|
+
[promptText, "### Unified Diff", "```diff", diffText, "```"].join("\n\n"),
|
|
106
|
+
"utf8"
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const execResult = await runCommand("copilot", args, {
|
|
110
|
+
cwd: workingDir,
|
|
111
|
+
allowFailure: true,
|
|
112
|
+
timeoutMs: config.commandTimeoutMs,
|
|
113
|
+
debug: config.debug
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
...execResult,
|
|
118
|
+
message: execResult.stdout
|
|
119
|
+
};
|
|
120
|
+
} finally {
|
|
121
|
+
await fs.rm(tempDir, { recursive: true, force: true });
|
|
122
|
+
}
|
|
101
123
|
}
|
|
102
124
|
}
|
|
103
125
|
};
|