-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreview-single-difficulty.ts
More file actions
66 lines (55 loc) · 2.08 KB
/
review-single-difficulty.ts
File metadata and controls
66 lines (55 loc) · 2.08 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
57
58
59
60
61
62
63
64
65
66
import fs from 'fs';
import { assessBugDifficulty } from './review-utils-difficulty';
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);
}
// Only assess difficulty if the bug passed review
if (!bug.LLMReviewPassed) {
console.error('Cannot assess difficulty - bug did not pass LLM review');
process.exit(1);
}
// Log previous state
console.log('Previous difficulty assessment:', {
hadDifficultyAssessment: bug.difficultyLevel !== undefined,
previousDifficulty: bug.difficultyLevel || 'none'
});
// Assess difficulty
const difficultyLevel = await assessBugDifficulty(bug);
console.log('New difficulty assessment:', difficultyLevel);
if (difficultyLevel !== null) {
// Update the bug object
bug.difficultyLevel = difficultyLevel;
bug.difficultyAssessedAt = new Date().toISOString();
// 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');
} else {
console.error('Failed to assess difficulty');
process.exit(1);
}
}
main().catch(console.error);