Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intellij plugin #10

Closed
nashid opened this issue Aug 5, 2022 · 19 comments
Closed

Intellij plugin #10

nashid opened this issue Aug 5, 2022 · 19 comments

Comments

@nashid
Copy link

nashid commented Aug 5, 2022

Would be awesome to have an plugin for fauxpilot!

@nashid
Copy link
Author

nashid commented Aug 5, 2022

@moyix are you aware of any opensource implementation that we could use to build the Intellij plugin for fauxpilot?

@nashid
Copy link
Author

nashid commented Aug 5, 2022

@Xelef2000 I know you have suggested for vscode plugin https://github.com/hieunc229/copilot-clone.

Are you aware of anything equivalent for Intellij plugin?

@AlexGreason
Copy link

Seconding this. I do wonder if it might be possible to pull some hostsfile trickery with the existing intellij plugin to redirect requests to the local inference server instead.

@moyix
Copy link
Collaborator

moyix commented Aug 8, 2022

You may want to dig into the code of the Copilot IntelliJ plugin to see if they have a similar debug setting to debug.overrideProxyUrl and debug.overrideEngine in the VSCode plugin? But yes, would also be great to have our own customizable IntelliJ plugin for FauxPilot as well :)

@thakkarparth007
Copy link
Collaborator

thakkarparth007 commented Dec 23, 2022

I took a quick look at the plugin code -- the code does seem to look for debug.overrideProxyUrl and debug.overrideEngine variables in "advanced" configuration, just like vscode. Now, I am not an intellij user so I don't know how to get to such advanced/custom configuration UI, but based on these references, I'm assuming there exists one. If that's not the case, please reopen this.

Side note: Both intellij and neo-vim copilot plugins have a thin wrapper that effectively calls common JS code (the same as used by VSCode extension).


When/if you do find the place to set these variables, here are the typical values for them if you're using Fauxpilot with default settings:

debug.overrideProxyUrl should be set to http://localhost:5000
debug.overrideEngine should be set to codegen

@wanyukang
Copy link

Has anyone found the overrideProxyUrl configuration on Intellij ?

@xjtu-blacksmith
Copy link

The advanced options appear in the Jetbrains' copilot plugin source code do not seem to work anywhere. Maybe it is just a residue from code project migration. Jetbrains IDE use something like XML for software settings, and Copilot plugin does not seem to offer interfaces for changing debug options in such config files.

@xjtu-blacksmith
Copy link

I took a quick look at the plugin code -- the code does seem to look for debug.overrideProxyUrl and debug.overrideEngine variables in "advanced" configuration, just like vscode. Now, I am not an intellij user so I don't know how to get to such advanced/custom configuration UI, but based on these references, I'm assuming there exists one. If that's not the case, please reopen this.

Side note: Both intellij and neo-vim copilot plugins have a thin wrapper that effectively calls common JS code (the same as used by VSCode extension).

When/if you do find the place to set these variables, here are the typical values for them if you're using Fauxpilot with default settings:

debug.overrideProxyUrl should be set to http://localhost:5000 debug.overrideEngine should be set to codegen

I've tried to replace agent.js in intellij copilot plugin according to #72, to replace all proxy address to local ones, but when I restart IDE I could still see from network probe that the plugin is connecting to GitHub copilot proxy server. I do not know how these program works, but it seems that intellj use compiled and packed executables, so these server address are hard-coded into the plugin and could not be replaced.

@heurainbow
Copy link

anyone worked on Intellij plugin successfully?

@vibin
Copy link

vibin commented Sep 7, 2023

While the IntelliJ plugin does use the same agent.js to fetch completions from /engines/copilot-codex, it doesn't support debug.overrideProxyUrl.

Yes, you can override system proxy directly in IntelliJ itself, but Copilot throws errors related to self-signed certificates.

As a last resort, I modified the plugin source code and got it working.

Steps to follow:

  1. Go to the plugin's folder. In my case (Mac, Android Studio), it's at: ~/Library/Application Support/Google/AndroidStudioPreview2023.1/plugins/github-copilot-intellij
  2. Rename the binaries under copilot-agent/bin folder. Just add some suffix to all the file names
  3. Open copilot-agent/agent.js in a text editor and make following changes:
    a. Replace "https://copilot-proxy.githubusercontent.com" with your localhost url
    b. Replace "https://copilot-telemetry.githubusercontent.com/telemetry" with your localhost url

Step 2 is required, since the IntelliJ plugin uses agent.js only when it cannot find the binaries.

@bananasmoothii
Copy link

Hello @vibin, did you manage to get it working on the current version of PyCharm? it's currently 1 AM here and I've been trying everything from using an old version of the plugin to reading the source code of the plugin, without success...

@vibin
Copy link

vibin commented Oct 18, 2023

@bananasmoothii the approach which I mentioned should work for all Jetbrains IDEs - I don't think Pycharm is any different.

I have tested in the following IDEs: IntelliJ Ultimate, IntelliJ Community, Android Studio, WebStorm

@bananasmoothii
Copy link

When I wrote this, I was getting 404 errors but I then found out that it was because the sent prompt was too long, now I have issues where it sometimes takes 3 minutes to respond, although sometimes it takes less than a second. Then I have issues where the server apparently doesn't produce valid JSON, and when looking at the data I had a response with multiple data: ... and one data: [STOP] (it may not be "stop", I don't recall)
This is too unreliable, so instead I now just have a small python script using the openai api and I copy paste code around.

@wanyukang
Copy link

hi @vibin , I'm glad to see the solution you proposed.

I tried it locally. After I performed the second step (renaming the binary agent file in the /bin directory) and before performing the third step, I tried to start the IDE to verify the Copilot plug-in. When executing the agent.js file, I found that the status of the Copilot plug-in was abnormal, showing "not signed in to github". This seems inconsistent with what is stated in your scenario.

Step 2 is required, since the IntelliJ plugin uses agent.js only when it cannot find the binaries.

I am currently using IDEA version 21.3.3 and the GitHub Copilot plug-in version 1.2.9.2684. I am not sure whether this is related to the IDE and plug-in version. Can I ask you whether this solution can still be used? It would be great if you could tell me your IDE version and plug-in version.

@vibin
Copy link

vibin commented Dec 7, 2023

hi @vibin , I'm glad to see the solution you proposed.

I tried it locally. After I performed the second step (renaming the binary agent file in the /bin directory) and before performing the third step, I tried to start the IDE to verify the Copilot plug-in. When executing the agent.js file, I found that the status of the Copilot plug-in was abnormal, showing "not signed in to github". This seems inconsistent with what is stated in your scenario.

Step 2 is required, since the IntelliJ plugin uses agent.js only when it cannot find the binaries.

I am currently using IDEA version 21.3.3 and the GitHub Copilot plug-in version 1.2.9.2684. I am not sure whether this is related to the IDE and plug-in version. Can I ask you whether this solution can still be used? It would be great if you could tell me your IDE version and plug-in version.​

@wanyukang Yes, we use this solution in our org. It's tested and working for ~200 developers (IntelliJ, Android Studio)

Have you tried signing into Github with the binary agent flow disabled?

Regarding versions, I think anything latest or near to latest should be fine. For example, try copilot-intellij/1.4.3.3913 and JetBrains-IU/232.10227.8. IntelliJ 21.3.3 is 2 years old, so that could be an issue...

@wanyukang
Copy link

@vibin Thanks for your quick reply. I did try to log into GitHub after disabling the binary, but instead of showing the login window, the plugin threw an error saying "GitHub Copilot: Failed to initiate the GitHub login process. Please try again." I plan to try upgrading my version of IDEA and the version of the GitHub Copilot plugin to see if this is the problem.

@wanyukang
Copy link

hi @vibin , I'm glad to see the solution you proposed.

I tried it locally. After I performed the second step (renaming the binary agent file in the /bin directory) and before performing the third step, I tried to start the IDE to verify the Copilot plug-in. When executing the agent.js file, I found that the status of the Copilot plug-in was abnormal, showing "not signed in to github". This seems inconsistent with what is stated in your scenario.

Step 2 is required, since the IntelliJ plugin uses agent.js only when it cannot find the binaries.

I am currently using IDEA version 21.3.3 and the GitHub Copilot plug-in version 1.2.9.2684. I am not sure whether this is related to the IDE and plug-in version. Can I ask you whether this solution can still be used? It would be great if you could tell me your IDE version and plug-in version.​

I figured it out, it was a problem with the local nodeJS version.

Since I am maintaining an old nodeJS project, my local default node version is node8, so when I manually run node agent.js, an error will also be reported. When I switch to node16, node agent.js starts normally. So when I switch the system's default nodeJS version to 16, and then start IDEA, I can run the plugin using agent.js as expected.

@vibin
Copy link

vibin commented Dec 8, 2023

hi @vibin , I'm glad to see the solution you proposed.

I tried it locally. After I performed the second step (renaming the binary agent file in the /bin directory) and before performing the third step, I tried to start the IDE to verify the Copilot plug-in. When executing the agent.js file, I found that the status of the Copilot plug-in was abnormal, showing "not signed in to github". This seems inconsistent with what is stated in your scenario.

Step 2 is required, since the IntelliJ plugin uses agent.js only when it cannot find the binaries.

I am currently using IDEA version 21.3.3 and the GitHub Copilot plug-in version 1.2.9.2684. I am not sure whether this is related to the IDE and plug-in version. Can I ask you whether this solution can still be used? It would be great if you could tell me your IDE version and plug-in version.​

I figured it out, it was a problem with the local nodeJS version.

Since I am maintaining an old nodeJS project, my local default node version is node8, so when I manually run node agent.js, an error will also be reported. When I switch to node16, node agent.js starts normally. So when I switch the system's default nodeJS version to 16, and then start IDEA, I can run the plugin using agent.js as expected.

@wanyukang Good catch! Yes, most of our developers are on Node16 (we wrote a shell script which installs Node16 if it is not present on the system, before making changes to the plugin).

@wanyukang
Copy link

One more thing, when checking whether the versions of IDEA and Github Copilot are affected, I updated Github Copilot to the latest version 1.4.4.3955. Then I read the code of agent.js and found that debug.overrideProxyUrl already supports setting in environment variables. 😃 (Search setOverridesFromEnvironment() to view the definition of the function)

Currently, there are only 3 supported parameters ["DebugOverrideEngine", "DebugOverrideProxyUrl", "DebugOverrideCapiUrl"]. For example, if you want to set debug.overrideProxyUrl, just set AGENT_DEBUG_OVERRIDE_PROXY_URL in the environment variable.

Combined with the solution proposed by @vibin to use agent.js to run the plug-in, theoretically, we can specify in JetBrains all the advanced parameter settings configurable in VSCode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants