feat: add drop-in replacement fix field to lint output#58
Conversation
📝 WalkthroughWalkthroughThe PR extends type definitions and LLM schemas across the codebase to support an optional Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/cli/orchestrator.ts (1)
401-409:⚠️ Potential issue | 🟡 MinorType assertion is missing the new
fixfield.The explicit
as Array<{...}>cast here omitsfix, even though the source type (JudgeResult.criteria[].violations[]) now carriesfix: string. While this works at runtime (the property is still present on the object), the cast is stale after this PR's changes. It should includefixfor completeness and to avoid confusion for future maintainers.Proposed fix
const violationResult = locateAndReportViolations({ violations: violations as Array<{ line?: number; quoted_text?: string; context_before?: string; context_after?: string; analysis?: string; suggestion?: string; + fix?: string; }>,
🧹 Nitpick comments (2)
src/scoring/scorer.ts (1)
56-64: Truthiness check silently drops empty-stringfixvalues.
item.fix && { fix: item.fix }(line 59) filters out"", which is the same pattern used forsuggestion(line 58). Since the LLM schema marksfixas required, the LLM may returnfix: ""for violations with no applicable replacement. This is likely acceptable (no meaningful fix to propagate), but note that the judge path inaverageJudgeScores(line 221) preserves empty strings viav.fix || "". If you want consistent behavior, consider usingitem.fix !== undefinedinstead.src/cli/orchestrator.ts (1)
108-141: Inconsistent empty-string handling between ValeJson and Json/RdJson forfix(andsuggestion).Line 119 uses
fix !== undefined(includes empty strings), while line 138 uses truthinessfix ? ...(excludes empty strings). This mirrors the existingsuggestionhandling on lines 118 vs 137, so this is a pre-existing inconsistency. Just calling it out for awareness — if a downstream consumer of the Json/RdJson format relies on seeingfix: ""to distinguish "no fix available" from "fix field absent," it would be silently dropped.
Does VectorLint have a rule called StyleGuide, or is this from the user instructions? |
That’s just a content example not the actual test data from vectorlint |
* feat: add fix field support to violation reporting * feat: add fix field support to Judge and Check schemas * feat: add fix field support to JSON formatter * feat(prompts): add fix field to directive loader schema * feat(scoring): add fix field support to violation reporting and scoring
This PR introduces a new
fixfield to the lint output across all JSON-based formatters. While the existingsuggestionfield provides a human-readable instruction (e.g., "Replace 'leverage' with 'use'"), the newfixfield contains the literal corrected text (e.g., "use") that can be used as a direct drop-in replacement for the identified violation.This enables downstream consumers (like IDE extensions or automated refactoring scripts) to apply corrections programmatically without parsing the natural language suggestion.
Example Output
{ "line": 5, "column": 12, "severity": "warning", "message": "AI buzzword detected", "rule": "StyleGuide.Clarity", "match": "leverage our synergies", "suggestion": "Replace with simpler language", "fix": "use our combined strengths" } <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added optional fix suggestions for detected violations and issues. Fix fields now appear in reporting outputs and scoring results, providing corrected replacement text that can be directly applied to resolve issues. <!-- end of auto-generated comment: release notes by coderabbit.ai -->