sourcegraph / sourcegraph-public-snapshot

Code AI platform with Code Search & Cody
https://sourcegraph.com
Other
10.1k stars 1.27k forks source link

Cannot find local code #56259

Open MagnusMG opened 1 year ago

MagnusMG commented 1 year ago

I have been using Cody in VSCode, and it has been very impressive. When I moved to IntelliJ I installed Cody there too, but I cannot get it to work. I am a very small scale programmer, and I don't have a big code base that Cody needs to know about. I just want Cody to look at the source code of the current project, available in the IDE. In VSCode this is not a problem - I can ask Cody what my project is about and it gives me an answer that clearly takes all the source code into account. But in IntelliJ the same question gets me an answer that only takes the currently open file into account. It does not find the other source code files.

How can I get Cody to look at the entire project? (It is a gradle project. IntelliJ 2023.2.1 Community Edition, on macos Ventura 13.5.)

jdorfman commented 1 year ago

Hey @MagnusMG apologies for the delay, this issue slipped through the cracks.

I appreciate the details, can you attach a screenshot or recording?

MagnusMG commented 1 year ago

Hi @jdorfman, thanks for responding. I tried to create a good example to show you, and discovered that Cody in IntelliJ actually does find all the files. But there is still something weird. The application I'm writing (in this example) is called HallKoll, and it is a kind of time tracking application, helping you to record what you have worked with and how much. I first asked Cody in VSCode this: How can I improve the HallKoll application? I got the following response:

Here are some suggestions for improving the HallKoll application:

Add a graphical user interface (GUI) - This would make the application more user-friendly and accessible. You could use JavaFX or Swing to create the GUI.

Improve error handling - Make sure errors are handled gracefully and useful error messages are displayed to the user.

Add more commands - Expand the functionality by implementing additional commands for managing work units and categories.

Implement reporting - Generate reports to allow users to analyze work unit data. For example, reports on time spent per category over a period.

Allow importing/exporting data - Add ability to import work unit data from CSV files and export data to CSV for analysis in other tools.

Add user accounts - Allow multiple users with individual work unit data. Could store data per user in the database.

Improve test coverage - Add more unit and integration tests to thoroughly test all components and functionality.

Improve documentation - Expand documentation to fully cover all classes, methods, and functionality.

Modularize code - Break code into separate modules/libraries for better separation of concerns. For example, separate core logic from UI code.

Automate builds - Set up a Continuous Integration server to automatically build and test after each commit.

Containerize application - Package application and dependencies into a Docker container for easy deployment.

Let me know if you would like me to expand on any of these suggestions! I'm happy to provide more details on how to implement the improvements.

I then put the same question to Cody in IntelliJ, and got the following response:

I found no context for your request. As your current server setting is Sourcegraph.com, please ensure this repository is public and indexed on Sourcegraph.com and that your access token is valid. I will try to answer without context.

Here are some ways you could potentially improve the HallKoll application:
Add more validation and error handling - check for invalid user input, catch exceptions, provide useful error messages.
Improve code organization - break large classes/methods into smaller, more focused units. Use proper naming conventions.
Write automated tests - unit, integration, UI tests to catch bugs and prevent regressions.
Improve logging - use a logging framework to log events/errors. Add tracing to debug complex flows.
Improve security - encrypt sensitive data, sanitize user input, add authentication.
Optimize performance - profile slow operations, cache redundant work, optimize database queries.
Improve UI/UX - follow UI/UX principles, get feedback through user studies.
Add analytics - track usage patterns, monitor performance metrics.
Support multiple platforms - make it responsive for mobile/web. Allow easy porting to desktop/other OS.
Improve accessibility - use proper colors, fonts, support screen readers.
Internationalize support - allow localization into different languages.
Improve documentation - update readme, add code comments and diagrams.
Enable plugins/extensions - allow custom plugins to extend functionality.
Add cloud support - integrate with backend services like authentication, storage, APIs.
Follow best practices - use industry standard patterns and architecture.
The key is to iteratively improve based on user feedback, bug reports, and performance metrics. Focus on most problematic areas first.
  1. In VSCode, the answer is clearly related to my project. The suggestions are detailed and concrete, and several of them I was planning to do (I have just not got that far yet). It mentions 'categories' and 'work units', which are central concepts in my application.
  2. In IntelliJ, the answer could have been given to any project. Nothing specific to my project at all.
  3. Specifically, in IntelliJ Cody recommends me to 'write automated tests', as if I did not have any. In VSCode, Cody tells me to 'improve test coverage - add more unit and integration tests'. (I have written a fair bit of test classes, but I could definitely write more of them.)
  4. The first comment in IntelliJ confuses me. I found no context for your request. etc. This comment is there every time, no matter what I ask Cody. And it is not there in VSCode.
  5. There might be an element of chance here - in VSCode I'm told how many, and which, source code files Cody has read to generate the answer. It never seems to be all of the files, and often the selection is weird. (But then again, what do I know about which files are appropriate to read in order to answer my questions?) Perhaps there is some limit to how many files Cody can look through, and the quality of answer depends on which files it happens to find?

I'd be happy to give you a screen shot or recording, just tell me what the focus should be.