{"id":15440707,"url":"https://github.com/jonluca/repo-refactor","last_synced_at":"2025-07-26T16:08:06.712Z","repository":{"id":163747919,"uuid":"621485661","full_name":"jonluca/repo-refactor","owner":"jonluca","description":"Refactor any directory into a different language","archived":false,"fork":false,"pushed_at":"2023-07-13T02:41:31.000Z","size":538,"stargazers_count":22,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-17T03:44:16.700Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonluca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-30T19:00:47.000Z","updated_at":"2025-02-28T05:23:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"8d2e3b54-b210-46dd-bfca-83b1c0def915","html_url":"https://github.com/jonluca/repo-refactor","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jonluca/repo-refactor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonluca%2Frepo-refactor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonluca%2Frepo-refactor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonluca%2Frepo-refactor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonluca%2Frepo-refactor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonluca","download_url":"https://codeload.github.com/jonluca/repo-refactor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonluca%2Frepo-refactor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267191045,"owners_count":24050318,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T19:15:05.487Z","updated_at":"2025-07-26T16:08:06.694Z","avatar_url":"https://github.com/jonluca.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LLM-based Code Refactoring Tool\n\nThis TypeScript program is designed to refactor a library, repo, or directory of code written in one programming language into another programming language using Language Models (LLMs).\n\n![image](./img.png)\n\n## Introduction\n\nThis tool uses the OpenAI API, which provides a wide range of pre-trained LLMs for various languages. It also utilizes the [glob](https://github.com/isaacs/node-glob) package to match files and directories. It will do a lot of the initial heavy lifting when translating or refactoring code.\n\n## Installation\n\nTo install the required packages, run the following command:\n\n```bash\nyarn install\n```\n\n## Usage\n\nYou will need an OpenAI API key, which can be obtained by signing up for an account [here](https://platform.openai.com/account/api-keys). Once you have an API key, you can set it as an environment variable by running the following command:\n\n```bash\nexport OPENAI_API_KEY=\"\u003ckey\u003e\"\n```\n\nYou can also pass it to the cli using the `--openaiApiKey` flag\n\nTo use the program, simply run the following command:\n\n```bash\nyarn refactor --src \u003csource_directory\u003e --dest \u003cdestination_directory\u003e --from \u003csource_language\u003e --to \u003ctarget_language\u003e\n```\n\nHere's an example:\n\n```bash\nyarn refactor --src ./src --dest ./dist --from python --to javascript\n```\n\nThis command will refactor all files in the `src` directory that have a `.py` extension into JavaScript files with a `.js` extension, and place the refactored files in the `dist` directory.\n\n## How It Works\n\nThe program works by recursively searching the source directory for files with the specified source language extension, and then passing the contents of each file through a pre-trained LLM for the source language.\n\nThe refactored code is then written to a file in the destination directory with the specified target language extension. Any non-code files in the source directory are simply copied to the destination directory.\n\n## Known Issues\n\n[ ] The program currently does a poor job of converting files with \u003e7000 tokens, due to the chunking\n[ ] The refactoring logic does not currently take into account common package managers - for instance, we should be able to read package.json, understand the dependencies, and lookup equivalents/pass them to the model for the destination language\n[ ] When there's a fundamentall different concept in a language that doesn't exist or isn't necessary in another languages (like mutex locks in rust when moving to javascript), it's difficult for the model to omit that code\n\n## Limitations\n\nWhile this tool can be very useful in automating the refactoring of code from one language to another, it does have its limitations. The accuracy of the refactored code will depend largely on the quality of the pre-trained LLMs used for each language, as well as the complexity of the code being refactored. Additionally, the tool has varying degrees of success in handling any language-specific libraries or dependencies that may be present in the original code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonluca%2Frepo-refactor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonluca%2Frepo-refactor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonluca%2Frepo-refactor/lists"}