Skip to content

martinpllu/chisel

Repository files navigation

chisel

A command line GPT-4 chat loop that can directly read and write code on your local filesystem.

Status

alpha/proof of concept.

Currently this is can only work with small apps, or subdirectories of larger apps. The model used, gpt-4-1106-preview has a 128k token context window ("300 pages of text"). Larger codebases and longer chats could exceed that window and chisel might start forgetting about your code or its job. The CLI logs the number of tokens used.

The maximum output size is also 4096 tokens, so there may be issues on larger files.

Quick Start

  • git clone https://github.com/martinpllu/chisel
  • cd chisel
  • npm install
  • Add a file .env containing:
OPENAI_API_KEY=your_api_key_here
  • (Note that you need to enable pay-as-you-go billing and have a positive credit balance, e.g. $10)
  • Start via npx tsx src/index.ts --directory=/path/to/your/app
  • chisel will start by sending the content of all files in the directory to chatgpt.
    • Files in src/read-files.ts#DEFAULT_IGNORE_PATHS will be ignored, as will any glob paths passed as --ignorePaths
  • Prompt the CLI to make a code change, e.g. add a feature, refactor or fix an issue.
  • chisel will change the required file(s)
  • You can then review changes. If your application is managed with git you can review the diffs and commit.
  • You can also ask chisel questions about the code.
  • Press Ctri-C to quit.

How does it work?

chisel uses ChatGPT's function calling feature. Two functions are used:

  • readFiles which reads all files in the supplied directory (the --directory argument), apart from the ignored files and returns their contents.
  • writeFiles which accepts a list of paths within the directory, and a corresponding list of file contents to write.

Sequence diagram

Safety

chisel can only read and write files within the directory specified on the command line. All ChatGPT-supplied paths are checked to ensure that they resolve to files which are actually within the directory.

License

This project is open source and available under the MIT License.

About

A command line GPT-4 chat loop that can directly read and write code on your local filesystem

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published