Codeshift is a command-line tool to translate and transform source code files between programming languages.
stdout
Run npm install -g @uday-rana/codeshift
.
Run npx codeshift
. This will generate a .codeshift.config.toml
file in your current directory.
In .codeshift.config.toml
, set the base URL for your preferred provider and add your API key. It should look something like this:
# .codeshift.config.toml
[settings]
baseUrl="https://openrouter.ai/api/v1"
apiKey="sk-or-v1-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
outputFile="xxxxxxxxxxx"
model=""
tokenUsage=true
stream=true
https://api.openai.com/v1
https://openrouter.ai/api/v1
https://api.groq.com/openai/v1
.npx codeshift [options] <output-language> <input-files...>
<output-language>
: The desired language to convert source files to<input-files...>
: Paths to the source files, separated by spaces-o, --output-file
: Specify filename to write output to-t, --token-usage
: Display the number of tokens used by the AI for processing-s, --stream
: Stream the response from the LLM.-h, --help
: Display the help message explaining usage, options, and arguments-v, --version
: Display the program name and version number# Converts a JavaScript file (index.js) to Go, saving the output in index.go
npx codeshift -o index.go go examples/index.js
See CONTRIBUTING.md
This project is licensed under the MIT License. See the LICENSE file for more details.