Git Product home page Git Product logo

chisel's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.