Uh oh!
There was an error while loading. Please reload this page.
lsp: budget diagnostics to cap token noise - #5261
Conversation
22c5a78 to
d4bc89fComparery2009
commented
Dec 8, 2025
2 files in here (around 60 lines) are the harness + testing suite which can be removed if this is wanted but they show clarity to how it is used and can be used |
This is also in coherence with the Biome LSP additions and would not affect each-other negatively |
| return budgetDiagnostics(collected) | ||
| } | ||
| export function budgetDiagnostics(input: Record<string, LSPClient.Diagnostic[]>) { |
There was a problem hiding this comment.
🟡 MEDIUM - Missing explicit return type on function
Category: quality
Description:
Exported function doesn't specify return type
Suggestion:
Add explicit return type: export function budgetDiagnostics(input: Record<string, LSPClient.Diagnostic[]>): Record<string, LSPClient.Diagnostic[]>
Confidence: 72%
Rule:ts_missing_return_type
| const bySeverity = [...input[path]].toSorted((a, b) => (a.severity ?? 3) - (b.severity ?? 3)) | ||
| const capped: LSPClient.Diagnostic[] = [] | ||
| let dropped = 0 | ||
| for (const diag of bySeverity) { | ||
| const message = trimMessage(diag.message) | ||
| const key = `${diag.range.start.line}:${diag.range.start.character}:${diag.range.end.line}:${diag.range.end.character}:${message}` | ||
| if (seen.has(key)) { | ||
| dropped++ | ||
| continue | ||
| } | ||
| seen.add(key) | ||
| if (capped.length >= MAX_PER_FILE) { | ||
| dropped++ | ||
| continue | ||
| } | ||
| const candidate = { ...diag, message } | ||
| const size = JSON.stringify(candidate).length | ||
| if (totalChars + size > MAX_TOTAL_CHARS) { | ||
| dropped++ | ||
| continue | ||
| } | ||
| totalChars += size | ||
| capped.push(candidate) | ||
| } | ||
| if (dropped > 0) { | ||
| const summary: LSPClient.Diagnostic = { | ||
| message: `${dropped} more diagnostics truncated`, | ||
| severity: 3, |
There was a problem hiding this comment.
🔵 LOW - Magic number without named constant
Category: quality
Description:
Numeric literal '3' used for severity default without explanation
Suggestion:
Extract to named constant: const DEFAULT_SEVERITY = 3; // INFO level and use in comparisons. Severity mapping already exists in lines 421-426 but not centralized.
Confidence: 62%
Rule:quality_magic_numbers
diffray-bot
commented
Dec 10, 2025
|
f1ae801 to
08fa7f7CompareClosing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR. |
Summary
Benchmarks
budgeted prompt 1,619 / completion 493 / total 2,112 (≈85% fewer total tokens). Cost: /bin/zsh.00188235 → /bin/zsh.00046185 (~75% cheaper)
Tests