Cody: the AI assistant that actually knows your codebase

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
a few weeks ago the team at sourcegraph reached out to me and they're like do you want to make a YouTube video about Cody and I was like yeah I would love to make a YouTube video about Cody and you may be thinking who is Cody and what is this video going to be about a better question is what is Cody Cody is an AI coding assistant and it's just totally free for personal use which is kind of crazy you can pay for it for your Enterprise but for personal use it's just free forever which is kind of wild but more interestingly I think is it knows your code base so so it like ingests your entire repo and that gives it context to answer the questions instead of just kind of making stuff up which can be super frustrating so let me show you how it works here on the laral repo I've just pulled down the entire laral framework and N we're just going to start asking it some questions so whenever you enter a new project and you're like H I don't really know what's going on here this might be a good use case for you so I've got the repo open in vs code here and I've just named it laral Cody because my creativity knows no bounds and I'm going to open Cody and we're going to start chatting with the codebase instead of using Cloud 2.0 or is it Cloud I'm going to use chat GPT 4 this is one of the things I do like is it lets you select the model presumably as new models come out I just get to to use them I don't have to I don't have to do anything so I like that they let you choose the model um and then down here you can enable that enhanced context which is where it knows your entire code base and so I've en enabled those embeddings so now we can just start chatting so I can say um can you give me an overview of this repo coming into a brand new codebase this would be really really useful to kind of get an overview especially when there's no documentation or read me or something like that one of the things that I super love about Cody is it cites its sources so one of the things that's really frustrating with AI is sometimes you feel like it makes stuff up but here it tells you where it got or some of the places it looked for its information and you you can go dive in and look at those same places so let's see how it did um yeah I mean this this is right this is right it's telling me everything about laravel um I imagine it's pulling a lot of it from the read me so it looks like this probably came from security this came from the license um this is interesting because it's not specifically laid out in the readme it's just the repository structure and yeah this is all you know this is all right if I didn't know this codebase this would be more interesting but this is not interesting to me so let's just clear the screen and let's do another one let's go to chat gp4 again and I want to say what do we want to do um how do I add a scope to a model let's see if it can figure out how I can add scope to a model so it looks like it read 15 files um and I'm very curious to see what this comes back with so it looks looks like to add a scope you need to define a method with scope prefix that is correct ah and it's actually writing out a scope for me this is great um so it tells me all of the steps which is nice you know if I if I were to read that would be really helpful we don't read developers don't read you should read the docs but we don't read so moving on it shows me exactly how to do it and it actually got the doc blocks right and everything and then it shows me how to use it so that's pretty cool um yeah remember Scopes are chainable yeah very cool now I kind of asked it a a specific question right like I knew I know what the word scope means if I'm coming into a project and I'm not super familiar with laravel or say I'm opening a rails project for the first time and I'm trying to figure something out what I would probably ask is something more like how can I let's see what would I say how can I create a bit of a reusable query on my models let's see how that does so instead of using the specific like jargon word of how do I create a scope I say like hey here's what I'm trying to do how do I do it and yes thank goodness it nailed it um this is great so you can create reusable queries by defining query Scopes a scope so it picked up that word for me and then it goes on to say there are local Scopes and there are Global Scopes and it shows me um a couple of instances of a local scope how to use it and then a couple instan of a global scope and how to use it which this this is great this is exactly what I'm looking for um and it's continuing to go on with the global scope and shows me how to oh that's nice how to turn off a global scope as well it's just it's continuing to it it's just continuing to produce I didn't know if I knew about Anonymous Global scope so this is pretty good right but there's a lot of content about LEL out there and I feel like I don't know it's kind of a softball give it a huge well-known framework ask a you know a medium level question and it gets it right we're going to look at a repo that is slightly less well-known than the laravel repo and that is the personal and private repository for Aaron francis.com not quite as much has been written about that so let's look for something completely random completely esoteric and boy do I have the file for you it's called blade portal now imagine if laravel blade had portals that would be pretty cool would it be useful not super useful but it would be very very cool and so I wrote that now blade portal never been seen before nobody has any context on it I'm going to highlight the whole thing and ask Cody I don't want Claude I wish it would stay on chat gb4 I'm G to ask Cody uh what is going on here and it's going to take that context and send it off and it's going to figure out what is going on in this completely novel bit of code and it says it's utility for managing content placeholders and portals Within laral blade templates it tells me what blade is and then it gives me a breakdown of the entire class and you can see it looked a few other places for context um I don't know that it got anything valuable out of any of these maybe in uh this one it registers a service provider but it looked at a few places but Mo most importantly it looked at this entire file and then here is here's the overview here's the documentation that I didn't write for blade portal um blade portal and I don't know I don't think it's that useful it's kind of cool maybe I'll do a video on that someday but the important thing is Cody figured it out it's never been published before I sent it off it came back with some actually useful information we've been using Cody to understand code which is nice but why understand code when you can just write bad code and have the computer fix it that's a joke you need to understand your code but anyway let's say we open up Cody here and we say show me the smells in Blade portal and this is going to look through through the blade portal file and figure out what some of the code smells are there's a uh document code command there's a generate tests command and there's one more that I'm going to show you which is just like kind of clean up or make the code better but here's the result here's the result from the smells uh command and it says it's generally sound o op which that's what I'm looking for I just want a computer to tell me I'm doing a good job it does tell me hey here are some things that you can fix the last thing I want to show you is some actual code generation here so here we are in the command that puts the articles on my website it just looks in a views articles folder and then does some stuff but what I'm actually looking for is yeah actually that right there I'm actually just looking for markdown so it figured that out and it wrote that for me I could say you know something like ignore hidden files and drop down here and there you go it would do that but since we restricted it to markdown only I don't super need that so it does do that auto completion and then very interestingly I can come down here and highlight this bit of code and hit command shift V and then I can tell it to do something with this particular bit of code and I can say combine these filter and reject uh functions into one function and it's going to work on that and so the thing here is I'm mapping over this collection twice and you know I don't really need to be and so it's going to do something and then put it back together so now I'm filtering to say if it has an IDE well it has to have an ID and if the app is local that's fine otherwise it can't be a draft and so it combined those two um it combined those two call backs into one call back which in this case doesn't super matter but this is a nice way to refactor to say like hey here's the code I have I'm going to tell you what to do you write the first draft and then I'll come in and do it again and here it pretty much nailed it the first draft I may do a little formatting change but this is what I'm looking for I can see this giving me superpowers on a project that I'm already familiar with or helping me get up to speed on a project that I'm not really that familiar with maybe best of all maybe the best use case is when I open a project that I wrote and I haven't touched in six months there's no worse coder in the world than me six months ago not today six months ago and so instead of looking at this code and thinking what did I do here I can just ask Cody what did I do here and it will tell me if you're watching this video which logically you must be watching this video then Cody is generally available as of December 14th it is generally a available I have found there are a few rough edges sometimes the models time out sometimes it grabs weird context to send off and I just kind of run it again and it works I do wish the PHP storm integration was a little bit better I know that they're working on it um but everyone in the world uses vs code except for me so the VSS code one is great the PHP storm one is coming but they put most of their energy into vs code so try it out go to sourcegraph tocom Cody let me know what you think leave very nice comments here for the source graph team I really appreciate them um sponsoring the channel this way so try it out let me know what you think see you
Info
Channel: Aaron Francis
Views: 18,640
Rating: undefined out of 5
Keywords:
Id: 5Z3TBxUH0lo
Channel Id: undefined
Length: 10min 6sec (606 seconds)
Published: Thu Dec 14 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.