feat(codegraph): helper extraction v2 — parameterize proposals + external OSS case studies#95
Merged
Merged
Conversation
…rnal OSS case studies v2 turns near-dupe DETECTION into a concrete CONSOLIDATION proposal, and proves the whole pipeline on three real open-source repos. - proposeParameterizedHelper (PURE): aligns cluster bodies token-by-token (literals kept, own name neutralized), turns each varying position into a parameter (co-varying positions collapse into one), names params from context (`kind: "min"` → param `kind`), and emits the reference body with substitutions + the exact call each original becomes. Conservative: declines with the reason when bodies don't align or >4 parts vary; mixed structural variants keep the LARGEST aligned subset and report the rest as dropped. - find_similar_helpers appends proposals for the top clusters (still detection-only — no edits). - Nested-member fix: an inner function no longer clusters with its own parent (caught live on axios: buildPath inside formDataToJSON). - docs/ADOPTION.md external case studies (real tool output, commits pinned, 2026-07-02): zod 912f0f5 → 38 clusters / ~671 lines (7-copy positive/negative family + the real parameterize proposal); hono b20d422 → importPublicKey/importPrivateKey ~95% + dup getQueryString; axios e435384 → setFormDataHeaders byte-near-identical across two files (manually verified). With the honest caveats (detection-only; duplication can be deliberate).
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.
Two of the roadmap items in one coherent change: Helper Extraction v2 and external OSS case studies (the v2 output is the highlight of the case studies).
v2 — from "these look similar" to "here is the exact consolidation"
proposeParameterizedHelper(PURE) aligns a cluster's bodies token-by-token (literals kept, each function's own name neutralized) and:kind: "min"→ paramkind(fallback p1/p2)droppedAlso fixes a live false positive: an inner function no longer clusters with its own parent (caught on axios:
buildPathnested insideformDataToJSON).Case studies — real repos, real output, commits pinned
912f0f5positive/negativefamily comes back as a concrete proposal:helper(kind, inclusive)with per-member call mappingb20d422importPublicKey/importPrivateKey~95% (~26 lines) + duplicatedgetQueryString(~92%)e435384setFormDataHeadersbyte-near-identical acrossresolveConfig.js+adapters/http.js— verified by eye (only a|| {}differs)Documented in
docs/ADOPTION.mdwith reproduction commands and honest caveats (detection-only; duplication in mature libs can be deliberate — mechanical evidence, human judgment).+6 tests (param naming, co-varying collapse, honest declines, best-subset with
dropped, nested-member regression). Full suite 1514 green, tsc clean.