Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces duplicated logic across the codebase (tests, CLI, language definitions, resolution utilities, renderers) and improves output by (a) coalescing duplicate-detector group results and (b) surfacing high-confidence duplicate opportunities in inspect output along with a follow-up duplicates command.
Changes:
- Added shared helpers (test temp dirs/path normalization, graph edge keying, package
exportstarget selection, whitespace tokenizer, CSS-like language definition fragments, C-family query fragments, MCP dependency schema, shared JVM import override wrapper). - Enhanced duplicate detection output by coalescing groups with identical primary ranges, adding guardrails for very different-sized grouped units, and filtering groups by
minConfidence. - Extended
codegraph inspectJSON output with a boundedduplicatessection and updated CLI regression tests/docs accordingly.
Reviewed changes
Copilot reviewed 52 out of 52 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/ts-paths-workspace.test.ts | Uses shared test filesystem helpers for tmp dir + path normalization. |
| tests/symbols-detailed-edgecases.test.ts | Uses shared mkTmpDir helper. |
| tests/sqlite.test.ts | Uses shared tmp dir + path normalization helpers for incremental sqlite assertions. |
| tests/sql-review-context.test.ts | Switches to shared mkTmpDir and passes explicit prefix. |
| tests/sql-artifact-graph.test.ts | Uses shared mkTmpDir for SQL graph fixtures. |
| tests/robust-fast-graph.test.ts | Uses shared tmp dir + path normalization and shared edge-key helper. |
| tests/resolution-precedence.test.ts | Uses shared mkTmpDir helper. |
| tests/parsed-cache-reuse.test.ts | Uses shared mkTmpDir helper. |
| tests/parsed-cache-eviction.test.ts | Uses shared mkTmpDir helper. |
| tests/node-modules-and-paths.test.ts | Uses shared tmp dir + path normalization helper. |
| tests/monorepo-fast-graph.test.ts | Uses shared graphEdgeKey helper for parity comparisons. |
| tests/helpers/graph.ts | New shared graph-test helpers (edge keying + edgeFrom). |
| tests/helpers/filesystem.ts | Adds shared mkTmpDir and normalizeTestPath for tests. |
| tests/fast-graph.test.ts | Uses shared mkTmpDir + graphEdgeKey helper. |
| tests/fast-graph-edgecases.test.ts | Uses shared tmp dir/path normalization and shared edgeFrom. |
| tests/dynamic-resolution.test.ts | Uses shared tmp dir + path normalization helper. |
| tests/duplicates.test.ts | Adds coverage for coalescing duplicate groups with identical primary ranges. |
| tests/disk-cache-sqlite.test.ts | Uses shared mkTmpDir helper. |
| tests/cli-regressions.test.ts | Extends inspect regression coverage to assert duplicates output + recommended command. |
| src/util/workspace.ts | Dedupes package.json#exports target selection via shared helper. |
| src/util/resolution/node.ts | Dedupes node_modules exports target selection via shared helper. |
| src/util/projectFiles.ts | Exports matchesDiscoveryGlob for reuse by CLI glob filtering. |
| src/util/packageExports.ts | New shared exports target selection helper. |
| src/sqlite/canned-query.ts | Dedupes direct deps/dependents sqlite query loader via parameterized helper. |
| src/mcp/tools.ts | Dedupes MCP deps/rdeps input schema via dependencyInputSchema(). |
| src/mcp/server.ts | Dedupes deps/rdeps handler logic via collectMcpDependencyEntries. |
| src/languages/definitions/less.ts | Reuses extracted CSS-like definition fragments. |
| src/languages/definitions/cssLike.ts | New shared CSS-like structure/graph/nodeTypes helpers. |
| src/languages/definitions/css.ts | Reuses extracted CSS-like definition fragments. |
| src/languages/definitions/cpp.ts | Reuses extracted C-family query fragments + split points. |
| src/languages/definitions/cFamily.ts | Adds shared C-family split points and query-building utilities. |
| src/languages/definitions/c.ts | Reuses extracted C-family query fragments + split points. |
| src/indexer/imports/languageSpecific.ts | Dedupes Java/Kotlin import override plumbing via applyJvmStatementOverride. |
| src/impact/suggestions.ts | Reuses shared toRange helper from src/util/ast.ts. |
| src/impact/report-suggestions.ts | Dedupes line counting across covered/total coverage sets. |
| src/graphs/symbol-render.ts | Extracts shared file/symbol render model used by Mermaid + DOT outputs. |
| src/duplicates.ts | Coalesces groups with same primary ranges; adds nearby-chunk clustering + length-ratio guard; filters groups by confidence threshold. |
| src/cli/search.ts | Reuses shared CliAgentCommandContext type. |
| src/cli/inspect.ts | Adds bounded duplicates section to inspect output + recommended duplicates command; refactors indexing path. |
| src/cli/graph.ts | Extracts shared compact symbol projection builder for compact JSON output. |
| src/cli/explain.ts | Reuses shared CliAgentCommandContext type. |
| src/cli/context.ts | Reuses exported matchesDiscoveryGlob; centralizes shared agent command context type. |
| src/cli/artifact.ts | Reuses shared CliAgentCommandContext type. |
| src/chunking/tokenizer.ts | New shared whitespace token counter. |
| src/chunking/chunkTextFile.ts | Reuses shared whitespace tokenizer type/impl. |
| src/chunking/chunkFile.ts | Reuses shared whitespace tokenizer type/impl. |
| src/agent/handles.ts | Dedupes parsing logic for file-like handles (file: / graph:). |
| src/agent-tools.ts | Dedupes dependency tool response mapping and tightens return types. |
| README.md | Documents inspect duplicates output (but example needs refresh—see comment). |
| docs/superpowers/plans/2026-05-23-eliminate-duplicate-findings.md | Adds a detailed refactor/verification plan and scan notes for duplicates cleanup. |
| docs/cli.md | Updates CLI docs to mention inspect duplicate opportunities + follow-up command. |
| codegraph-skill/codegraph/SKILL.md | Updates skill guide to mention inspect duplicate opportunities. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1119
to
+1145
| const variantsByKey = new Map<string, DuplicateSuggestion>(); | ||
| for (const group of grouped) { | ||
| for (const variant of group.variants) { | ||
| variantsByKey.set(suggestionVariantKey(variant), variant); | ||
| } | ||
| } | ||
| const variants = Array.from(variantsByKey.values()).sort(compareSuggestionsForPrimary).slice(0, variantLimit); | ||
| const rawPairCount = grouped.reduce((count, group) => count + group.rawPairCount, 0); | ||
| let score = primary.score; | ||
| let confidence = primary.confidence; | ||
| let cloneType = primary.cloneType; | ||
| for (const group of grouped.slice(1)) { | ||
| score = Math.max(score, group.score); | ||
| confidence = bestConfidence(confidence, group.confidence); | ||
| cloneType = bestCloneType(cloneType, group.cloneType); | ||
| } | ||
| coalesced.push({ | ||
| ...primary, | ||
| id: shortHashText(key), | ||
| score, | ||
| confidence, | ||
| cloneType, | ||
| variants, | ||
| variantCount: variants.length, | ||
| rawPairCount, | ||
| omittedVariantCount: Math.max(0, rawPairCount - variants.length), | ||
| reasons: mergeGroupReasons(grouped), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.