CLI  ·  Node ≥ 18  ·  GPL

Codemancer

A command-line tool that uses OpenAI to generate code from a prompt and an input file. Change code in-place, write new files, or just ask questions. A versatile AI-powered programming assistant that streamlines tasks and boosts productivity.

$ npm install -g codemancer

Setup

To use Codemancer with your own OpenAI API key, set OPENAI_API_KEY in your environment.

export OPENAI_API_KEY=your_api_key_here

Defaults to GPT-4. If you don't have access and hit a 404, you can fall back to GPT-3.5 with -m "gpt-3.5-turbo" — code generation is less reliable on 3.5.

Usage

Reading and writing to the same file

codemancer -i input_file -p "break the /recipe/<id> route into /recipe/<id>/info and /recipe/<id>/image"

Reading and writing to a different file

codemancer -i input_file -o output_file -p "extract inlined types into interfaces in a separate file"

Writing from prompt to file

codemancer -o output_file -p "I need an AppleScript to wipe Safari history on restart"

Simple prompting

codemancer -p "what's a bulletproof regex for validating emails"

Customizing model and temperature

codemancer -i input_file -m gpt-3.5-turbo -t 0.5 -p "change all variable names to obscure animals"

Limitations

License

GPL License — this code was largely written by AI with some human guidance.