welcome to code with JV I'm excited about what I've got for you today it is a production ready AI powered coding assistant I've started integrating it into my daily workflow and I'm seeing it lots of other people online saying the same thing first AI powered assistant that they're actually using for production work day to day let's dive into it it's called Ida Ada hey Ida I'm going with Ida I don't know I'm guessing it's a portmento of AI encoder it is a CLI tool you run it in your terminal it's powered by open AIS apis so gpt4 GPT three and a half plans to integrate it with others over time I've seen some tickets about playing around with Claude which means you're burning credits when you use it but it's well worth it it's tightly integrated with Git which means it is committing to get for you and it can do not just create sample code but it can perform operations like ad unit tests refactor move this at a particular function change it to this the tasks you do day-to-day coding you can start to do those things but it is tightly integrated with Git which is sort of a plus and a minus but I think that's why it's getting cut through is just its usability it's being updated maintained Paul who leads the project lovely responsive on GitHub new features coming out I'm seeing issues resolved every day it's looking good enough that I actually went ahead and integrated it with my favorite editor more on that in a bit the guides are excellent really good tips about how to use it great installation tips so I won't go through a full install for you but I'll just give you some pointers one of the things about this approach of sending requests to open AI is that every time you send requests you've got to give chat GPT the information about your code base this is a lot of what Ida does it gives you tools for managing what information you send to chatgpt each time you talk to it it is a pip module so just pip install either chat we'll get it into your code base you might want to wrap it in an environment or I've just installed it globally because I use it everywhere it also uses a feature called ctags which is old Tech initially used for coding editors to know the types of function you've got in your code Etc to enhance Ides you don't need to use C tags but if you do it performs better this is where ctags creates a summary of all your functions that are used that can be passed to really summarize your entire code base and help catch EBT give you better responses it needs to have the Json flag I had actually uninstall my original version of C tags which was exuberance tags and then I had to replace it with universal C tags so at get install Universal C tags got me the right version to integrate in once you've done that then you just need to have an open AI key saved in your environment in the right format and you're good to go I'm in a new folder here let's open it in vs code this is a useful way of just seeing what's happening in the code as we go let's launch it so either no Flags it will start to initialize a git repo because like I said it's tightly coupled with Git and the reason is because it can change your files on you and sometimes it can make bad mistakes you don't want putting it in git is a way of making sure you can quickly unroll anything it does for you because if you've got something that isn't git and either trashes it you might lose some data you can run it with a no get flag if you want it's got some extensive Flags hopefully let's have a look at that so if you go either help you'll see all the things you can do like don't use it with Git turn off auto commits you can start to change the themes and everything in there you can start to change which model you're using a lot of options here so quite a full featured application let's turn it back on but it'll tell you what model it's using it will tell you whether it's using C tags or not and it's going to use a thousand tokens as its quota for how much space the C tags can take up you can modify that like most things in it type help and you'll see the commands you can run in the program now just by doing this starting at making a git repo it's gone and made all these hidden files up here first thing you want to do get that into a git ignore the tool is quite sensitive to the state of your git so if you fire it up with uncommitted changes like I said before it's going to try and protect you by making sure everything that it touches is saved and get before it does anything so it can seem a bit annoying but once you realize it's there to protect your files you can roll with it if we type in tokens it's got a system message and it's got a repository map so this is where you can start to see how many tokens it's using every time you make a chat it will store that summary of it so that it continues to be aware of previous discussions like a good chatbot would anything you type here is just an instruction to GPT please create a hello like so I find gbd4 there's a bit of lag with it coming back three and a half it's much faster but not as good so here it's saying let's make a Hello World file let's do a print do you want me to add the file yep it's edited it we have ourselves a file we've got the hello world oh one tip I wouldn't actually run it in the terminal in vs code I'd run it in a separate window because the terminal gets quite stuttery in the output's not as good here we've got this right hand hello world no surprises that's not that notable let's look at our git history you'll see it's actually very verbose in the git history when you've got Auto commits turned on so every time you do a chat message by default it will save something into your git history and you'll be able to see what the chat was what the response was Etc I think the innovation of this tool was like let's get the output in diffs and let's put those diffs straight into git that's what's turned up from just I wouldn't really use it to actually this is functional enough like I said before you can turn off auto commits if you want to have more control over what your git history looks like if you type help you'll see there are some things like commit diff Etc undo hey I don't like what you just did that commit is gone dropping hello world all right thank you and now it's gone in step back so if it makes a change you don't like you can just do undo roll back all right that's a starting point if you've got either minus three now you're in GPT three and a half mode and the difference is some of it's Financial so gbd4 three cents a thousand tokens AK window three and a half a tenth the price twice the number of tokens but you've got to be a lot more precise when you're using three and a half and give it smaller tasks right what should we try and make I've made pong before maybe we can do naughts and Crosses yeah see what it can do eye level very abstract task here we can see it is checking the win playing the game malformed response right up I'm in three and a half the speed was giving that away let's see how three and a half did at this job print board check win play game maybe it was good enough but this is one of the advantages of a tool like this is switching between your models based off the task you've got to hand if I was watching gpt4 to that it's more expensive tons slower is what bothers me more you're watching a tick tick tick three and a half spins it out quite quickly so maybe that was a fortunate mistake lots and Crosses oh yeah into a row 0. 0 into the column it looks like it's a two-player game and we've got one five one five it busts it doesn't have error handling in it but hey it's a step in the right direction let's see how three and a half goes at changing this one of the things you now if I type tokens you'll see that token count has gone up because it's got the code itself it's also got chat history if you type clear you can remove your chat history it forgets about what you've been talking about if you type drop it is going to remove context that it sends down to it this is what I mean by having a lot of control over the context you send your AI tools on every query but I'm happy with that for now let's go with a Next Step let's add some error checking for bad input now let's have a look at what the app looks like I'm gonna go five hey that's wrong so that is a reasonable task and I wonder if it gets the win condition right zero zero like so I want to do two zero right okay and now let's have a race zero one all right who's going to win damn got it wrong okay I'm beating myself and I it's confusing on things so I'm gonna go two two play X win so it's got a win Condition it's a naughts and Crosses game we're probably talking about a cent of credits to make a simple start like this now that's all well and good let's start to see how it handles multiple files a typical task I do here is like actually let's get your display logic and your business logic out let's see if I can refactor this into multiple files it's got themes where you can mess with the colors to make them all visible in different contexts it's making a board. py and it's making a game.
py we've got our game we've got our board and noughts and Crosses it is left untouched so it looks like it's just made two new ones I might do a git log where I can actually see notice that three and a half has less verbose git commits okay so it's made those changes if we go python game Etc so it looks like the game's still playable and it's refactored that out this is where it started to create files look at this it's got a board it's got a print board it's an update it's a whole board class and here is a game code which has got a bunch of the game things which uses the board class you can give it instructions like please move to functional programming please translate into another language and it can start to do tasks like this quite quickly and this is all on three and a half we haven't even touched the powerful model yet and it's still doing useful work in this toy domain few more things you can look at here the reason I went to multiple files is a bit of less LS these are the files in chat ah I don't think we need noughts and Crosses anymore drop it and now the token count will be just these files here you can also do things like is a chat history useful probably not clear now the chat history is gone and just those files are in there so as you're coding you can start to control the tokens because maybe you want to control the costs on the expensive models though I was coding for hours and spent like five six bucks before seeing this tool I was like oh yeah AI tools are coming for programmers it's going to affect us you know it's affecting us already I'm using chat GPT mostly even GitHub Copart I found is only okay after seeing this I'm starting to form the view that like six months from now 12 months from now if someone is paying you to write code and you are not using this tool you are probably doing them a disservice unless there's a good reason not to be using AI tools such as private code bases organizational policy Etc otherwise I think you are wasting your clients money if you type all the stuff out and you don't lean on these types of tools they're getting to that level of utility and Ida's still early it's still got bugs I still got things that are being worked out but fast forward six months 12 months from now I think you need to be using it which is interesting to get to such a strong Viewpoint search quickly but who knows what will happen let's actually try and ship a real feature remember how I said I integrated it with my favorite editor which is of course Vim I've been using Vim for 20 years and I love it so much and it's just become ingrained in how I work one of the things about them is it's a personalized coding environment which you configure to work the way you want I want it to work with Ida so I build a plugin to do so here is the plugin so fast it's pretty vanilla at the moment it doesn't do much apart from if I open up a code base so I'm in them now and I've got the this is the the main guts of the plugin all it really does is say hey if I type a keyboard shortcut it opens up either in a separate window I can close out of it quite quickly and easily but I can also hit a different keyboard shortcut and now I've opened it in silent mode so it's not doing Auto commits or a different one and now I'm using dvd3 so with a couple of keystrokes it's firing up different models of Ida in the code base and that that's enough for me to prefer using it in Vim as opposed to having a separate terminal window running just that flexibility to shift the commands quite quickly if I have a look at my Ida plugin this is where I can quickly set up different keyboard shortcuts to open either with whatever Flags I want whatever models I want that's a good starting point but let's do something more because one of the biggest drags about Ida is manually managing what you want to send and how what I would like to do is when I'm in a file and I open it up I go LS here it doesn't have any files in its context it doesn't know about the file I was just in be pretty easy to send it it's just a command line argument so that's what I'll do I'm going to go and say add either I'm adding in the I might add the docs as well if you look at some of the issues which are interesting there is one around automatic file context window management so like how does it drop files when you don't need them how to add them as you need them without you having to manually do it as much putting smarts in there there was another one for learn from documentation wouldn't it be nice to have a slash research command in there and give it a URL or give it a name of a library and it went and hoovered up the information online and smartly Managed IT and sent the right bits to chat GBC as you need those features it will just lift this up to the next level of Awesomeness so I just want to make it a little nibble on this one for my particular use case which is instead of having to manually add things in there let's have it automatically manage some of them to do that GPT needs to know a little bit about the command line tool it doesn't know anything about Ida it knows about this code here but that's got limited info in it so what I might do is if I just go either help like so I have just made a little text file which is a file which can be added to either itself which has the command line tool interfaces on it and I think you can do this where you copy and paste documentation just stick it in there without any improvements to the tool you can quickly start to do things where you add them in yourself although one problem here is if you do this and I try and go add it's not going to find it because it only knows about stuff in Git it won't add anything unless it's in git because it wants to protect you so if we go here like this or I'm in main we don't want to do a main I'm calling this a auto add buffer I'll probably throw that away once I finish this code base but just as an example of how things need to be and get to use it it's a stepping stone and now I haven't had to refresh either it just looks in real time to see is it allowed to edit help text now I can see it knows about the help docs it knows about the documentation which I don't think is actually going to help it and this is the game of like oh what does chat chipity need to know to do this job similar to if I had an intern or a junior programmer I'd ask myself what do they need to know to do this work go look at these docs and so on and sort of cultivating someone else to succeed is a little bit of the skill I think you need to get the most out of these AI tools let's drop and I don't need the doctor thing now we can start to give it some tasks what I want it to do is automatically add the buffers to the window when we open it so when I open either I'm going to use automatically to add all the buffer files and also check to see if actually I'll do it step by step because if you give it too many tasks it gets a bit overloaded if you give it smaller tasks it's more likely to get it right less likely to have to redo work and let's see what it does here you can probably see the speed difference between four and three and a half it is modifying this existing function and I didn't have a huge amount of code here but this is the code it's saying change this function oh and let's go and do some things where I'm mapping over the buffers in Vim a buffer is sort of like all the files that you have opened I'll show you about them in a second it's added them and now it's made a commit reload it now I've got this code in here so testing Vim plugins well that's the thing in itself I'm just going to re-update it this is updating all of them but I think I might actually need to restart the whole thing yeah I know it seems like you're trying to talk to close and open files with them sorry chat GPT but thank you for the input I find that my biggest problem with them is that I use it so much I often type it's shortcuts into other contexts where it doesn't help let's have a look here and let's get Lua open now did it work look at that so with that change this is a useful feature I'll be shipping this to the repo Zone which is up here at either. nvim if anyone else is a Vim User it's automatically adding that context hey that's an improvement I would nearly ship this but we need to do a bit more testing first because I can quickly load this context I'm just closing either again I open it when I need it buffers in them if I go call an LS it's saying I've got two open buffers at the moment I've got the Ida lure and I've got the terminal which was open before because the buffers are not the windows that are open they're basically any files you have opened in this session if I open up the readme and now if I go back to the other one I've only got one file open but I have multiple buffers open and it will send them all to Ida whenever I load it up which is kind of a feature but what if I did something like this add new file.