wolverine icon indicating copy to clipboard operation
wolverine copied to clipboard

[wolverine] Integrate openai into my editor

Open yacineMTB opened this issue 2 years ago • 5 comments

Just goofing around. Going to work with @biobootloader to see if we can get this merged & extend with wolverine.

I didn't have time to integrate VSCode's node runtime with a keychain. Do NOT add your keys to a json that lives raw on your filesystem. Unless you have a limit, and you don't care about potentially losing 20 bucks.

Want to pull and build?

  1. pull
  2. cd vscode_extension/wolverine
  3. npm install
  4. npm run package && npm run vsce
  5. ctrl shift p => install extensions => the three little dots on top right
  6. slurp up the vsix file you just generated

This branch should have a vsix file that you can just use! If you want to develop, open up vscode in the extension's directory and hit F5

Demo

https://user-images.githubusercontent.com/10282244/233265760-05af619e-a536-47e9-a061-142261a4167d.mp4

Please don't share on twitter dot com bird app site yet, I'm making a goofy video

yacineMTB avatar Apr 20 '23 05:04 yacineMTB

https://user-images.githubusercontent.com/10282244/233284504-798258ed-922b-4bc2-b75c-f271ba56615b.mp4

probably overkill for this repo, but computers should probably embed the whole world before doing things, including voice

yacineMTB avatar Apr 20 '23 06:04 yacineMTB

Incredible!

Let me get to some of the older PRs before tackling this beast 🔥

biobootloader avatar Apr 22 '23 23:04 biobootloader

yeah big guy i'm gonna actually toy around with this and make it not hot garbage only attend once it's not in draft :) shared it early for someone else who asked for it

yacineMTB avatar Apr 23 '23 16:04 yacineMTB

I was programming something else and was getting a little annoyed about how it didn't have any context. So I made it do what I want!

image

Now if I cast "directed heal" on this selected text, it'll have the references to all visible text. However; it won't include the actual internals of the function. It'll be replaced with ... instead.

Also; here's the new prompt.

const constructPrompt = async (text: string, filepath: string): Promise<string> => {
	const defaultPrompt = `
ADDITIONAL CONTEXT:
filepath: ${filepath}
INSTRUCTIONS: 
- The text under 'CODE' has come straight from my text editor. 
- Your entire output MUST be valid code.
- You may communicate back, but they MUST be in comments
- The code sent to you might have some instructions under comments. Follow the instructions. Only attend to instructions contained between [[SELECTED]] & [[/SELECTED]]
- The code between [[SELECTED]] [[/SELECTED]] is code that I need you to replace. So when you start responding, only respond with code that could replace it
- MAKE SURE YOU ONLY WRITE CODE BETWEEN [[SELECTED]] AND [[/SELECTED]]. The rest of it doesnt need to be replace
- The rest of the code is provided as context. Sometimes, I'll collapse my code for you, and hide the details under '...'. Follow the style of the rest of the provided code.
- DO NOT WRITE THE ENTIRE CODE FILE. ONLY REPLACE WHAT IS NECESSARY IN SELECTED
- Prefer functional programming principles.
CODE:
${text}
NEW CODE TO REPLACE WHAT IS BETWEEN [[SELECTED]] and [/SELECTED]:
`;
	const configuredPrompt = await workspace.getConfiguration().get('wolverine.prompt');
	if (configuredPrompt) {
		return configuredPrompt + text;
	}
	return defaultPrompt;
};

yacineMTB avatar May 12 '23 00:05 yacineMTB

cc @biobootloader FYI I've been using this on my own dev I'm keeping this branch updated with whatever my patches are as I figure out what works for me vs what doesn't

The code is an awful mess, I plan to encapsulate all of the state transitions.

yacineMTB avatar May 12 '23 18:05 yacineMTB