Add Rust implementation of JS variable renamer (humanify-rs)#734
Draft
Add Rust implementation of JS variable renamer (humanify-rs)#734
Conversation
This is a Rust rewrite of the core JS AST traversal and variable renaming functionality. Key features: - Parse JavaScript to AST using oxc parser - Visit all binding identifiers (variables, functions, classes, params) - Process identifiers from largest scope to smallest for correct renaming - Support callback-based renaming via the Renamer trait - Handle shadowed variables, reserved keywords, and name collisions - Apply renames via text replacement The implementation passes 24 tests ported from the TypeScript version, covering scope ordering, shadowing, class methods, object properties, and various edge cases. https://claude.ai/code/session_019FrkBNBMtr3yPtHoYzKHDa
Implements local LLM inference for the Rust humanify: - Grammar module (grammar.rs): - GBNF grammar builder for constraining LLM output - Extraction of variable portions from responses - Builder pattern API similar to TypeScript template literals - Model module (model.rs): - Pre-configured model definitions (2B Phi, 8B Llama) - Model path management (~/.humanifyjs/models/) - Chat template support (Phi3, Llama3.1) - ModelConfig builder for configuration - Prompt module (prompt.rs): - Core inference using llama-cpp-2 bindings - Chat template formatting - Token-by-token generation with early stopping All 40 tests pass including 16 new LLM module tests. https://claude.ai/code/session_019FrkBNBMtr3yPtHoYzKHDa
Implements the Rust equivalent of the TypeScript local-llm-rename plugin: - unminify_variable_name(): Two-stage LLM prompting (description -> name) - define_filename(): Infer filename from code snippet using LLM - LocalRenamer: Implements Renamer trait using local LLM inference - local_rename(): Main entry point for processing JavaScript code https://claude.ai/code/session_019FrkBNBMtr3yPtHoYzKHDa
The CLI provides commands to: - `humanify local <file>` - Process JS file with local LLM inference - `humanify download <model>` - Download 2b or 8b model - `humanify models` - List available models and download status Dependencies added: clap for CLI parsing, indicatif for progress bars, ureq for HTTP downloads. https://claude.ai/code/session_019FrkBNBMtr3yPtHoYzKHDa
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.
This is a Rust rewrite of the core JS AST traversal and variable renaming functionality. Key features:
The implementation passes 24 tests ported from the TypeScript version, covering scope ordering, shadowing, class methods, object properties, and various edge cases.
https://claude.ai/code/session_019FrkBNBMtr3yPtHoYzKHDa