vigthoria-cli 1.6.31 → 1.6.32
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/dist/commands/generate.js +2 -1
- package/dist/utils/api.js +29 -18
- package/package.json +1 -1
|
@@ -105,9 +105,10 @@ class GenerateCommand {
|
|
|
105
105
|
if (options.output) {
|
|
106
106
|
await this.saveToFile(options.output, code);
|
|
107
107
|
}
|
|
108
|
-
else {
|
|
108
|
+
else if (process.stdout.isTTY) {
|
|
109
109
|
await this.promptForAction(code, options.language);
|
|
110
110
|
}
|
|
111
|
+
// Non-TTY: code was already printed above — skip interactive menu
|
|
111
112
|
}
|
|
112
113
|
catch (error) {
|
|
113
114
|
spinner.stop();
|
package/dist/utils/api.js
CHANGED
|
@@ -3588,9 +3588,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
3588
3588
|
'Rules:',
|
|
3589
3589
|
'- Return concrete, line-specific issues with severity.',
|
|
3590
3590
|
'- Every issue MUST reference a line number.',
|
|
3591
|
-
'-
|
|
3591
|
+
'- Report each distinct bug ONCE. Do NOT report the same bug multiple times with different wording.',
|
|
3592
|
+
'- For trivial/short code (< 10 lines), report at most 2 issues unless there are genuinely more distinct bugs.',
|
|
3592
3593
|
'- Prioritize REAL BUGS: wrong operators, logic errors, off-by-one, type mismatches.',
|
|
3593
|
-
'- Only report style issues
|
|
3594
|
+
'- Only report style/robustness issues if there are no real bugs to report.',
|
|
3594
3595
|
'- Return ONLY the JSON object, no markdown fences or extra text.',
|
|
3595
3596
|
].join('\n');
|
|
3596
3597
|
let raw = {};
|
|
@@ -3605,25 +3606,35 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
|
3605
3606
|
const score = typeof raw.score === 'number' ? raw.score : 0;
|
|
3606
3607
|
const issues = Array.isArray(raw.issues) ? raw.issues : [];
|
|
3607
3608
|
const suggestions = Array.isArray(raw.suggestions) ? raw.suggestions : [];
|
|
3608
|
-
//
|
|
3609
|
-
//
|
|
3610
|
-
// even when the server only reports style issues like console.log.
|
|
3609
|
+
// Merge client-side heuristics, but with tight dedup to avoid
|
|
3610
|
+
// redundant over-reporting when the model already found the bug.
|
|
3611
3611
|
const heuristic = this.heuristicCodeIssues(code, language);
|
|
3612
3612
|
for (const h of heuristic) {
|
|
3613
|
-
//
|
|
3614
|
-
//
|
|
3615
|
-
//
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3613
|
+
// Semantic duplicate check: same line + (similar type OR overlapping
|
|
3614
|
+
// keywords in the message). This catches cases where the model
|
|
3615
|
+
// and heuristic describe the same bug with different wording.
|
|
3616
|
+
const hWords = new Set(h.message.toLowerCase().split(/\W+/).filter(w => w.length > 3));
|
|
3617
|
+
const hTypeNorm = h.type.toLowerCase().replace(/[^a-z]/g, '');
|
|
3618
|
+
const isSemanticallyDuplicate = issues.some((existing) => {
|
|
3619
|
+
if (existing.line !== h.line)
|
|
3620
|
+
return false;
|
|
3621
|
+
// Normalize types: "logic-error", "logic_error", "logic" all match
|
|
3622
|
+
const eTypeNorm = existing.type.toLowerCase().replace(/[^a-z]/g, '');
|
|
3623
|
+
if (eTypeNorm === hTypeNorm || eTypeNorm.startsWith(hTypeNorm) || hTypeNorm.startsWith(eTypeNorm))
|
|
3624
|
+
return true;
|
|
3625
|
+
// Both errors on same line about the same category of problem
|
|
3626
|
+
if (existing.severity === 'error' && h.severity === 'error')
|
|
3627
|
+
return true;
|
|
3628
|
+
// Check keyword overlap — if ≥2 significant words match, it's the same finding
|
|
3629
|
+
const eWords = existing.message.toLowerCase().split(/\W+/).filter(w => w.length > 3);
|
|
3630
|
+
let overlap = 0;
|
|
3631
|
+
for (const w of eWords) {
|
|
3632
|
+
if (hWords.has(w))
|
|
3633
|
+
overlap++;
|
|
3620
3634
|
}
|
|
3621
|
-
|
|
3622
|
-
}
|
|
3623
|
-
|
|
3624
|
-
// already reported on the same line with the same type.
|
|
3625
|
-
const isDuplicate = issues.some((existing) => existing.line === h.line && existing.type === h.type);
|
|
3626
|
-
if (!isDuplicate) {
|
|
3635
|
+
return overlap >= 2;
|
|
3636
|
+
});
|
|
3637
|
+
if (!isSemanticallyDuplicate) {
|
|
3627
3638
|
issues.push(h);
|
|
3628
3639
|
}
|
|
3629
3640
|
}
|