From a1bd0eea22366a3d074adabe401267216e652b84 Mon Sep 17 00:00:00 2001 From: jimcody1995 Date: Sun, 5 Jul 2026 05:49:19 +0200 Subject: [PATCH] fix(review): rank long-form doc extensions in diffFilePriority GUIDE.markdown and spec.asciidoc were treated as source(0) under a tight diff budget, displacing real code. Align review-grounding and review-diff with rag.ts and path-matchers doc spellings. Co-authored-by: Cursor --- src/review/review-diff.ts | 2 +- src/review/review-grounding.ts | 2 +- test/unit/review-diff.test.ts | 7 +++++++ test/unit/review-grounding.test.ts | 7 +++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/review/review-diff.ts b/src/review/review-diff.ts index 932fc012b0..bc8befe97a 100644 --- a/src/review/review-diff.ts +++ b/src/review/review-diff.ts @@ -22,7 +22,7 @@ export const DEFAULT_DIFF_BUDGET = 80_000; export function diffFilePriority(path: string): number { if (/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb|cargo\.lock|poetry\.lock|composer\.lock|go\.sum)$|\.(min\.(js|css)|map|snap)$/i.test(path)) return 4; if (/(^|\/)(dist|build|out|coverage|vendor|node_modules)\//i.test(path)) return 4; - if (/\.(md|mdx|rst|txt|adoc)$/i.test(path)) return 2; + if (/\.(md|mdx|markdown|rst|adoc|asciidoc|txt)$/i.test(path)) return 2; if (isTestPath(path)) return 1; return 0; // source code } diff --git a/src/review/review-grounding.ts b/src/review/review-grounding.ts index c9774ddaa2..f21fbbb246 100644 --- a/src/review/review-grounding.ts +++ b/src/review/review-grounding.ts @@ -112,7 +112,7 @@ export function buildGrounding(f: GroundingFlags, checks?: CheckAggregate, fileC export function diffFilePriority(path: string): number { if (/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb|cargo\.lock|poetry\.lock|composer\.lock|go\.sum)$|\.(min\.(js|css)|map|snap)$/i.test(path)) return 4; if (/(^|\/)(dist|build|out|coverage|vendor|node_modules)\//i.test(path)) return 4; - if (/\.(md|mdx|rst|txt|adoc)$/i.test(path)) return 2; + if (/\.(md|mdx|markdown|rst|adoc|asciidoc|txt)$/i.test(path)) return 2; if (isTestPath(path)) return 1; return 0; // source code } diff --git a/test/unit/review-diff.test.ts b/test/unit/review-diff.test.ts index 72079b3f07..5ac43388e6 100644 --- a/test/unit/review-diff.test.ts +++ b/test/unit/review-diff.test.ts @@ -11,6 +11,13 @@ describe("diffFilePriority — source survives, noise drops first", () => { expect(diffFilePriority("app.min.css")).toBe(4); }); + it("ranks long-form doc spellings as docs(2), matching rag.ts and path-matchers", () => { + for (const path of ["GUIDE.markdown", "docs/spec.asciidoc", "notes.ADOC"]) { + expect(diffFilePriority(path)).toBe(2); + expect(diffFilePriority(path)).toBeGreaterThan(diffFilePriority("src/a.ts")); + } + }); + it("ranks every canonical test convention as tests(1), not source(0)", () => { // These are all tests; before delegating to isTestPath the inline regex missed them and ranked // them SOURCE(0), so on a tight budget they could displace real source (the opposite of the goal). diff --git a/test/unit/review-grounding.test.ts b/test/unit/review-grounding.test.ts index b5e64be2e4..eb455f9250 100644 --- a/test/unit/review-grounding.test.ts +++ b/test/unit/review-grounding.test.ts @@ -102,6 +102,13 @@ describe("review-grounding: diffFilePriority (source survives the budget first)" expect(diffFilePriority("src/a.ts")).toBeLessThan(diffFilePriority("README.md")); }); + it("ranks long-form doc spellings as docs(2), matching rag.ts and path-matchers", () => { + for (const path of ["GUIDE.markdown", "docs/spec.asciidoc", "notes.ADOC"]) { + expect(diffFilePriority(path)).toBe(2); + expect(diffFilePriority(path)).toBeGreaterThan(diffFilePriority("src/a.ts")); + } + }); + it("ranks every canonical test convention as tests(1) so real source is inlined first", () => { for (const path of [ "e2e/checkout.cy.ts", // Cypress