mirror of
https://github.com/jehna/humanify.git
synced 2026-04-28 01:55:56 +03:00
[GH-ISSUE #8] Unsafe identifier renames #5
Labels
No labels
bug
enhancement
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/humanify#5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @j4k0xb on GitHub (Dec 12, 2023).
Original GitHub issue: https://github.com/jehna/humanify/issues/8
Minifiers only rename variable/function/parameter bindings and not any other identifier like properties because it's almost impossible to guarantee the program still works then.
Example input file:
humanify output:
I think thats the only change necessary but it needs some testing:
github.com/jehna/humanify@4dfe05e20f/src/openai/rename-variables-and-functions.ts (L16)Or how about renaming all variables to something unique so it doesn't mix up minified ones and then supplying a list of binding names it is allowed to change in the prompt?
Also it can happen that a variable gets renamed but another one with the same name already exists in the scope, or the code gets split up in such a way that not all references are renamed.
Maybe use babel's scope-aware rename that also handles these conflicts (have to find a way of getting rid of the
_prefix): https://astexplorer.net/#/gist/7283141e13dab314521744603a95e9b7/05b11370db8d5ef257550b2916b87d6e72e4eb1d@0xdevalias commented on GitHub (Dec 12, 2023):
I've laid out some of my thoughts on this concept in general, in the following issues/comments:
Off the top of my head, if it's not easily solved via tweaking the prompt, you could potentially have it do a 'refinement/feedback round' where you provide feedback to the LLM + get it to correct the issues (which could be repeated up to X times) eg.
@j4k0xb commented on GitHub (Feb 28, 2024):
copilot now has a similar feature: https://code.visualstudio.com/updates/v1_87#_rename-suggestions
worth looking into how they've done it
@0xdevalias commented on GitHub (Feb 29, 2024):
Release detailed here:
Couldn't see any overly relevant commits in that range, but did find the following searching the issue manually:
Which lead me to this label:
And these issues, which sound like there are 'rename providers' used by the feature:
More docs about rename providers here:
Based on the above, and the release notes explicitly mentioning copilot, I suspect the implementation will be in the Copilot extension itself (which isn't open-source):
Downloading that gives
GitHub.copilot-1.168.741.vsix, which seems to just be a.zipfile:Though unzipping that and searching for
provideRenamedidn't seem to turn up anything useful unfortunately; so not sure if that means it's not implemented in the copilot extension, it doesn't use VSCode's 'rename provider' API, or I just wasn't looking right.@isidorn commented on GitHub (Mar 4, 2024):
Hi VS Code PM here,
A team member pointed me to this issue because it links to one of our VS Code issues.
I wanted to share that reverse engineering GitHub copilot is violating the general terms of the use agreement https://github.com/customer-terms/general-terms
Feel free to reach out to me if I can help with the general terms clarification inikolic@microsoft.com
Thank you
Isidor
@0xdevalias commented on GitHub (Mar 5, 2024):
@isidorn It's less about "reverse engineering GitHub copilot" and more about "trying to figure out where the 'rename suggestions' change mentioned in the VSCode release notes was actually implemented; and what mechanism 'integrates' it into VSCode'".
The above is assumptions + an attempt to figure that out; but if you're able to point me to the actual issue/commit on the VSCode side (assuming it was implemented there), or confirm whether it's implemented on the closed source GitHub Copilot extension side of things (if it was implemented there), that would be really helpful.
If it was implemented on the GitHub Copilot extension side of things, then confirming whether the VSCode extension 'rename provider' is the right part of the VSCode extension API to look at to implement a similar feature would be awesome.
@ulugbekna commented on GitHub (Mar 5, 2024):
Thank you for taking interest in this API. The rename suggestions feature is powered by a proposed API defined here. Extensions provide the suggestions, while the vscode shows them in the rename widget.
@0xdevalias commented on GitHub (Mar 6, 2024):
@ulugbekna Awesome; thanks for pointing that out! Shall have a closer read :)
Edit: See also:
@sagarika-fynd commented on GitHub (Mar 29, 2024):
I renamed all variables to unique names, and then ran the unminify code, most of the stuff was unminified, but i still had some random code, which wasnts, so i added a check to only rename variables which are in the pattern of my naming convention, and instructed the same to GPT, had to run this a few times, but it made sure sancity of previous naming convention was maintained
@0xdevalias commented on GitHub (Aug 29, 2024):
See also:
Semi-related:
@0xdevalias commented on GitHub (Sep 29, 2024):
Just made a similar suggestion for this pattern while debugging another issue, referencing it here for continuity:
@jehna commented on GitHub (Oct 18, 2024):
Using
BindingIdentifierinstead ofIdentifiernow, thanks for reporting this! Closing for now, should be fixed@0xdevalias commented on GitHub (Feb 18, 2025):
For continuity, I believe this was implemented in:
github.com/jehna/humanify@1fffcde1d1github.com/jehna/humanify@311758f42f/src/plugins/local-llm-rename/visit-all-identifiers.ts (L68-L77)