-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreview-single.ts
More file actions
56 lines (46 loc) · 1.6 KB
/
review-single.ts
File metadata and controls
56 lines (46 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import fs from 'fs';
import { reviewBug } from './review-utils';
async function main() {
const commentLink = process.argv[2];
if (!commentLink) {
console.error('Please provide a comment link as argument');
process.exit(1);
}
// Read bugs.json
const bugsData = JSON.parse(fs.readFileSync('bugs.json', 'utf8'));
// Find the specific bug
const isArray = Array.isArray(bugsData);
const bug = isArray
? bugsData.find(b => b.commentLink === commentLink)
: Object.values(bugsData).find((b: any) => b.commentLink === commentLink);
if (!bug) {
console.error('Comment not found in bugs.json');
process.exit(1);
}
// Log previous state
console.log('Previous review state:', {
wasReviewed: bug.LLMReviewed || false,
previousResult: bug.LLMReviewPassed || false
});
// Review the bug
const result = await reviewBug(bug);
console.log('New review result:', result);
// Update the bug object
bug.LLMReviewed = true;
bug.LLMReviewPassed = result;
bug.reReviewedAfterJan27th = true;
// Update the file
if (isArray) {
const index = bugsData.findIndex(b => b.commentLink === commentLink);
bugsData[index] = bug;
} else {
const key = Object.entries(bugsData).find(([_, b]: [string, any]) => b.commentLink === commentLink)?.[0];
if (key) {
bugsData[key] = bug;
}
}
// Write back to file
fs.writeFileSync('bugs.json', JSON.stringify(bugsData, null, 2));
console.log('Updated bugs.json file');
}
main().catch(console.error);