Live data from Hacker News

Show HN: No more copy-pasting – a ChatGPT plugin to read code from your computer

github.com

1–10 of 28 posts

Show HN: No more copy-pasting – a ChatGPT plugin to read code from your computer

#1
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.

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.

Say goodbye to the days of incessant copy-pasting and welcome a more streamlined code discussion experience .

I'd love to hear your thoughts, experiences, and suggestions for improvement. Let's discuss and evolve this tool together!

Show HN: No more copy-pasting – a ChatGPT plugin to read code from your computer
github.com

Re: Show HN: No more copy-pasting – a ChatGPT plugin to read code from your computer

#3

I use Github Copilot Chat for the same which works with vscode directly. Any advantage over that?

I believe Github Copilot Chat only has access to the single currently viewed file, any other context/code from other files in the repo need to be copy/pasted in.

Re: Show HN: No more copy-pasting – a ChatGPT plugin to read code from your computer

#4
Smart approach to have a locally running application as a way of letting chatgpt plug-ins access local files, nice!

And nice ChatGPT written post ;) it seems to love saying things like “let’s [] and [] together!”

This seems really useful, thanks for making it.

Re: Show HN: No more copy-pasting – a ChatGPT plugin to read code from your computer

#5

I use Github Copilot Chat for the same which works with vscode directly. Any advantage over that?

I believe Github Copilot Chat only has access to the single currently viewed file, any other context/code from other files in the repo need to be copy/pasted in.

I have seen it do things that make me think it has access to a few of the other tabs of code that are also open.

Re: Show HN: No more copy-pasting – a ChatGPT plugin to read code from your computer

#6
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.

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.

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.

Looks like you're using typescript-estree to parse the 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.

Re: Show HN: No more copy-pasting – a ChatGPT plugin to read code from your computer

#7

I use Github Copilot Chat for the same which works with vscode directly. Any advantage over that?

I believe Github Copilot Chat only has access to the single currently viewed file, any other context/code from other files in the repo need to be copy/pasted in.

That's not correct. It has context from anything that's open, and it knows about your overall project structure (for example, it knows if you have a pom.xml or a cargo.toml). That said, note that Microsoft has been deliberately vague about what does and doesn't get sent to Copilot, so I don't think there is an official answer to this.
Post reply on HN