Introducing the Code ChatGPT Plugin - a new era of seamless interaction between ChatGPT and your codebase. This TypeScript Code Analyzer furnishes a suite of utilities to analyze TypeScript code, enabling ChatGPT to "talk" with YOUR code.<p>Fetch a list of all the files in your project, list of every function in a TypeScript or JavaScript file, or even get the content of a specific function, all while staying in your conversation with ChatGPT. With accessible API endpoints, you can effortlessly navigate your codebase and ask ChatGPT anything you can think of about it.<p>Say goodbye to the days of incessant copy-pasting and welcome a more streamlined code discussion experience .<p>I'd love to hear your thoughts, experiences, and suggestions for improvement. Let's discuss and evolve this tool together!
I'd like to know how these kinds of tools (Copilot included) avoid reading users' secret tokens and passwords.<p>But knowing how we programmers work and how we treat security collectively, I guess I've already had the answer.
Smart approach to have a locally running application as a way of letting chatgpt plug-ins access local files, nice!<p>And nice ChatGPT written post ;) it seems to love saying things like “let’s [] and [] together!”<p>This seems really useful, thanks for making it.
IMPORTANT: A fascinating approach to better improve on a project-wide basis instead of a small-scope basis.<p>1. Prompt: "Read project code files. Describe the flow of <whatever it is doing>? Just a step by step description of each operation taking place that this software is doing. Be as detailed as you possibly can."<p>2. Prompt: "Suggest improvements to this process described above, how <new feature>, how <new feature> taken into account, and add any additional edge cases that you can think of to make the process more robust and to cause it <do whatever> in a more complete way.<p>3. *WRITE THE TWO ABOVE ANSWERS INTO A FILE CALLED GAME_PLAN.md*<p>4. Prompt: "Read the file called GAME_PLAN.md and write code that implements the first improvement."<p>5. Profit!
Reminds me of a little vscode extension I wrote for myself to integrate ChatGPT into my projects. I didn't do a great job with documentation, but you can reference other files within comments to send them as context. So something like<p>/*
Write tests for [xyz/(./xyz.ts) using [abc tests](./abc.spec.ts) as an example to reference<p>@ChatGPT
*/<p>Reference: <a href="https://github.com/CapsuleCat/sora-by-capsule-cat">https://github.com/CapsuleCat/sora-by-capsule-cat</a><p>I'll have to check out how your version pulls in the project as context.
"a new era", really?<p>ChatGPT can be quite corny in default mode. I recommend experimenting with prompts to make it sound more natural, and not using its responses verbatim in your communications.<p>Cool project though.
Super interesting project! I like that you're exposing the structure of the git repo to GPT, and helping it understand and access the code in a semantically meaningful way via the function definition APIs.<p>I've been working on similar things with GPT, but in a language agnostic way. That makes things a bit trickier, having to parse arbitrary source code languages.<p>I was curious how you were parsing/lexing the files to pull out functions. I asked GPT about your repo, to see if I might find some useful tools for my project. It provided the helpful summary below.<p>Looks like you're using typescript-estree to parse the code?<p><pre><code> $ git clone https://github.com/kesor/chatgpt-code-plugin.git
$ cd chatgpt-code-plugin
$ aider
Using git repo: .git
Use /help to see in-chat commands.
>>> how does this package find and index all the functions?
This package finds and indexes all the functions using the following process:
1 It starts by getting a list of all the files in the project using the getFileList function in src/function-utils.ts. This function recursively traverses the directories and returns an array
of file paths.
2 For each file in the list, the getFunctionList function in src/function-utils.ts is called. This function reads the file content and parses it into an Abstract Syntax Tree (AST) using a
TypeScript parser.
3 The findFunctionsInFile function in src/function-utils.ts is then called with the AST as an argument. This function traverses the AST and identifies function declarations, function
expressions, and class methods. It collects information about each function, such as its name, start and end positions, and stores it in an array.
4 Finally, the package returns an array of objects containing information about all the functions found in the project. This array can be used to index the functions and perform further
operations, such as retrieving the function's code or analyzing its structure.
>>> does it use any pre-built packages for this? or is it all homebrew?
Yes, this package uses some pre-built packages to achieve its functionality. Here are the main ones:
1 @typescript-eslint/typescript-estree: This package is used to parse TypeScript code into an Abstract Syntax Tree (AST). It is used in the getFunctionList function to parse the file content
and generate an AST.
2 fs: This is a built-in Node.js module for working with the file system. It is used to read directories, read file content, and check file stats.
3 ignore: This package is used to filter out files and directories based on the rules specified in the .gitignore file. It is used in the getFileList function to exclude files and directories
that should not be processed.
4 path: This is a built-in Node.js module for working with file and directory paths. It is used to join and resolve paths, and to get relative paths.
These pre-built packages are combined with custom code to find and index all the functions in the project.</code></pre>