Skip to content

Latest commit

 

History

History

vs-code-extension

Clippy AI is a simple wrapper around OpenAI Codex. It allows you to send Codex your current file as well as some instructions in plain-text English. It then opens a diff view in your editor so you can easily see the suggested changes and accept or reject them.

Clippy is free to use for the moment, because it rely's on OpenAI's new edit endpoint which is currently free while in testing. Once OpenAI moves that endpoint into production it'll likely move to a pay-per-usage model like OpenAI's other offerings.

How it Works

Just type what you want Codex to do, and get a diff back with Codex's proposed changes. A GIF is worth a thousand words:

clippy-example-3

Installation

Install this extension from the VS Code Marketplace

Usage

Open the command palette (eg. cmd+shift+P on the mac). Search for the new command "Clippy AI: edit file or selection". (Alternatively, we bind the "cmd+;" keyboard shortcut by default.)

When you run the command, an input box will pop up. In plain english, type the instruction you want Clippy to perform. Clippy will send your current file and the instruction to OpenAI's "edit" endpoint and attempt to make the change to the current file. (Note that unlike Github Copilot, Clippy currently only sends the current file, not other files in your workspace.)

If no likely edit is possible, Clippy will show an error message. Otherwise, you'll see Clippy's suggested edits appear in a few seconds in a diff view.

Edits can also be performed on selections; simply select some text before running Clippy to run in this mode.

Using Voice Commands

Clippy AI includes experimental functionality to record commands with your voice! Note that this is highly experimental, and may not work on your machine. It has only been tested on MacOS. If you try this and nothing happens, open an issue and I'll take a look.

Steps to enable:

  1. Install ffmpeg, eg. brew install ffmpeg
  2. Open your VS Code settings and search for "Clippy-ai: Use Voice Input". Check the box.
  3. Open a file you want to edit and run Clippy as normal. MacOS will prompt you to give microphone access to VS Code. Once you allow that, you should see a prompt box pop up with the placeholder "Press 'enter' to finish recording your command..."
  4. After you speak your command, press "enter". On the backend, the command is converted to text using Google's speech-to-text service, then sent to Codex like normal.

Sample Prompts

It may take some time to learn what Clippy is good and bad at. Here are some examples that have worked for me:

General

"Add types hints to all function definitions"

Screen Shot 2022-03-22 at 4 27 50 PM

"Fix all syntax errors"

Screen Shot 2022-03-22 at 4 24 06 PM

"Remove commented-out code"

Screen Shot 2022-03-22 at 4 21 58 PM

"Remove dead code"

Screen Shot 2022-03-22 at 4 17 07 PM

Project-Specific

"Add a command to package and install the extension locally"

Screen Shot 2022-03-22 at 4 04 02 PM

"Remove all logging statements"

Screen Shot 2022-03-19 at 9 58 01 PM

"Fix types for the edit variable"

Screen Shot 2022-03-22 at 4 12 13 PM

^ This one is particularly cool because it highlights Clippy's understanding both of my codebase and the VS Code extension API. I modified my code to require `edits` to handle either a `Selection` or a `Range`, and then used Clippy to fix the types of `edits`. I expected it to change the type to `vscode.Selection | vscode.Range`, but Clippy actually correctly realized that `vscode.Selection` is a subclass of `vscode.Range`, so `vscode.Range` is sufficient on its own!