Search 100s of Issues with GitHub CLI as Context for AI Studio

The GitHub CLI allows you to search issues and filter on different criteria like amount of comments. This allows you to search for real-world situations and pains/solutions people have using different technology.

With the GitHub CLI in hand we'll drop 100s of issues as context in Googles AI Studio and have Gemini determine the 10 most frequently asked questions. This will give us a sense of how people use a library and where people get hung up.

Share with a coworker

Transcript

[00:00] I'll install Execa for easily running commands as strings. I'll import it and then I'll await and use the GitHub CLI to search issues. Now we're going to search for framer-motion and check out what the result is through standard out. So we'll just log out standard out, come down here, run pnpm node, and I'm doing this because in my npmrc this will force pnpm to use this node version which can now strip types from TypeScript files, and the script is called search issues. So once I run this I'll get a whole bunch of text about the issues it found that have frame or motion.

[00:37] Now I want to limit this to issues that have at least two comments and I'm actually going to extract this into a comment count and then add it back in as a variable. And that's because of the way that Execa uses template strings and will automatically escape this with quotes. You don't have to worry about any escaping if you just inject it as variable. And I'm also going to extract this and we'll call this query. And argv2 means that once we run this and we pass in framer-motion here, if you're to log out console.log argv then we need to make sure and drop in our query.

[01:13] And we run this you'll see that zero is the node binary, one is the scripter running, and then 2 is frame remotion. So that's where that comes from. So if we let this run all the way, it's now only finding issues with more than two comments. Now we can't actually get the comments using the GitHub CLI this way. We can only get the URLs where we can load the comments.

[01:35] So this command will now return JSON which is just an array of objects with URLs on them. So we can actually do as the AI suggests, parse the standard out, put that in an array of issues, and then log each of the URLs. So remove this console log and let's go ahead and run that. And now you can see all of the URLs that came back and we'll remove this console log too. So now we can use one of the other GitHub CLI features which is GitHub issue view and we can view this issue dot URL.

[02:04] And what we want to grab from it is the comments. So the result of this will be on standard out again and if we just log each of these out and run this again you'll see the URL then a whole bunch of comments and they just keep on streaming in. So what I'm going to do is write these all to a file. So I'll append file, and I'm just going to use the path tool. This looks fine.

[02:25] I do need to import append file from node FS promises. And then I'm just going to extract this to a file path. So this way each time some new text comes in we append it to a file in our temp directory called issues. We can actually move this out of the loop and then once we're done it can just log out that we're completed. So if we run this now This is going to take a little while, you'll see each URL come in and then behind the scenes once we get the comments back it's right into that file.

[02:52] So I'll just edit to where this is done. Alright so this is complete. Our file is here and it stopped after 30. We can even bump this up to a limit of 100 because I would just like to get as much context as possible. So I'll delete that and let this run again.

[03:08] And this did take about two minutes but now I have 100 issues worth of content. I'll select all of this. I'll open up AI Studio which can actually now be installed as an app. So I can open AI Studio this way. So now with AI Studio open, I'll paste that entire context inside of 2.0 Flash Experimental.

[03:28] That's 117, 000 tokens worth of FramerMotion discussion. And we can ask it things like, based on all these issues, please write out the 10 most frequently asked questions about FramerMotion. Looks like I need a correct Framer-Motion and then run this and then let it generate those questions so we can learn more about frame or motion. So frame or motion animations not working in Next.js routers, use scroll hooks not updating correctly, layout animations, animations only run a second or later after mount, And this is surfacing many of those much deeper questions about frameworks and libraries that only come up in real-world situations.