mirror of
				https://gitee.com/chuangxxt/share-copilot
				synced 2025-10-30 04:49:50 +00:00 
			
		
		
		
	Compare commits
	
		
			No commits in common. "67a8e7631a5d7a834f485cc66ab7239713a30b0a" and "d7a5a02952ee94385c3982a764fe5290c7379fc0" have entirely different histories.
		
	
	
		
			67a8e7631a
			...
			d7a5a02952
		
	
		
							
								
								
									
										183
									
								
								README-EN.md
									
									
									
									
									
								
							
							
						
						
									
										183
									
								
								README-EN.md
									
									
									
									
									
								
							| @ -1,183 +0,0 @@ | ||||
| The beta version now supports full interface proxy,  | ||||
| 
 | ||||
| So even code suggestions go through the proxy,  | ||||
| 
 | ||||
| Still in testing. | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| *** | ||||
| # share-copilot  | ||||
| 
 | ||||
| - Acts as a proxy server, forwarding requests to the Copilot plugin's API | ||||
| 
 | ||||
| - Supports both vscode and Jetbrains plugins | ||||
| 
 | ||||
| - Supports multiple users sharing a single token | ||||
| 
 | ||||
| - Optimize request logic to reduce suspended probability、 | ||||
| 
 | ||||
|    | ||||
| 
 | ||||
|  | ||||
| 
 | ||||
| *** | ||||
| # 一、Build It Yourself: | ||||
| ```sh | ||||
| Test Environment: Linux4.18.0-305.3.1.el8.x86_64 GNU/Linux | ||||
| Requires Go environment;  | ||||
| resolve any issues chatgpt. | ||||
| ``` | ||||
| ```sh | ||||
| git clone https://gitlab.com/luyoyu/share-copilot.git | ||||
| wget https://dl.google.com/go/go1.21.1.linux-amd64.tar.gz | ||||
| tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz | ||||
| 
 | ||||
| vim ~/.bashrc | ||||
| # Add the following environment variables | ||||
| export PATH=$PATH:/usr/local/go/bin | ||||
| export GOPATH=$HOME/go | ||||
| export PATH=$PATH:$GOPATH/bin | ||||
| 
 | ||||
| # Make the environment variables effective | ||||
| source ~/.bashrc | ||||
| # Verify the installation | ||||
| go version  | ||||
| # CD to the source directory of main.go | ||||
| cd /share-copilot/source | ||||
| go build | ||||
| ``` | ||||
| *** | ||||
| # 二、Use the Ready-Made Version: | ||||
| 
 | ||||
| ### 1.Installation | ||||
| 
 | ||||
| ```sh | ||||
| wget https://gitlab.com/luyoyu/share-copilot/uploads/73bca0887b3ea39622e88cb88d7d0297/share-copilot-linux-amd64.zip | ||||
| ``` | ||||
| ```sh | ||||
| unzip share-copilot-linux-amd64.zip  | ||||
| ``` | ||||
| 
 | ||||
| ```sh | ||||
| cd share-copilot | ||||
| ``` | ||||
| 
 | ||||
| ```sh | ||||
| bash install.sh | ||||
| ``` | ||||
| 
 | ||||
| ### 2.Configuration | ||||
| 
 | ||||
| ```sh | ||||
| vim  config.json  | ||||
| ``` | ||||
| 
 | ||||
| ##### 2.1 Explanation of config.json | ||||
| 
 | ||||
| ```js | ||||
| domain // Listening domain or IP (can be reverse proxied with nginx) | ||||
| host   // IP | ||||
| port   // Port 80 or 443 | ||||
| certPath // Public key path - required for 443 | ||||
| keyPath  // Private key path - required for 443 | ||||
| github_api_url // Default, usually not changed | ||||
| token  // Your Copilot token(s), you can put multiple, they will be used randomly in requests | ||||
| // After logging into the Copilot plugin, find them in %userprofile%\AppData\Local\github-copilot\host.json (starting with "ghu_") | ||||
| verification // Custom verification | ||||
| 
 | ||||
| ``` | ||||
| 
 | ||||
| ##### 2.2 Example  | ||||
| 
 | ||||
| ```json | ||||
| { | ||||
| 	"server": { | ||||
| 		"domain": "example.com", | ||||
| 		"host": "0.0.0.0", | ||||
| 		"port": 443, | ||||
| 		"certPath":"./example.pem", | ||||
| 		"keyPath":"./example.pem" | ||||
| 	}, | ||||
| 	"copilot_config":{ | ||||
| 		"github_api_url": "https://api.github.com/copilot_internal/v2/token", | ||||
| 		"token":[ | ||||
| 			"yours_token_1", | ||||
|             "yours_token_2", | ||||
|             "yours_token_3" | ||||
| 		]}, | ||||
| 	"verification":"" | ||||
| } | ||||
| 
 | ||||
| ``` | ||||
| The format must be correct; | ||||
| 
 | ||||
| ### 3.Run  | ||||
| 
 | ||||
| ```sh | ||||
| scop r  # Run [Ctrl+c to exit]  chmod +x share-copilot if Permission denied | ||||
| scop rb # Run in the background | ||||
| scop st # Stop | ||||
| scop v  # View status | ||||
| ``` | ||||
| 
 | ||||
| ### 4.Complete Example: | ||||
| 
 | ||||
| ##### 4.1 Server-side Configuration (Modify config.json) | ||||
| 
 | ||||
| ```json | ||||
| { | ||||
| 	"server": { | ||||
| 		"domain": "api.example.com", | ||||
| 		"host": "0.0.0.0", | ||||
| 		"port": 443, | ||||
| 		"certPath":"./example.pem", | ||||
| 		"keyPath":"./example.pem" | ||||
| 	}, | ||||
| 	"copilot_config":{ | ||||
| 		"github_api_url": "https://api.github.com/copilot_internal/v2/token", | ||||
| 		"token":[ | ||||
| 		"ghu_xMNAYLcJAPqAfiGoobrWffkJoNcGMVJtETKA", | ||||
|         "ghu_GZgKFwraHorAxXXUvsUclOhxiYERPsSJeNuF", | ||||
|         "ghu_SPUTCLvkMKoeMstPJmhSlYsYvCojhkFjGubl" | ||||
| 		]}, | ||||
| 	"verification":"i_am_free" | ||||
| } | ||||
| ``` | ||||
| 
 | ||||
| ------ | ||||
| 
 | ||||
| ##### 4.3Local Configuration Changes: | ||||
| 
 | ||||
| **Using Windows as an example** | ||||
| 
 | ||||
| - **For Jetbrains Plugin: Modify %userprofile%\AppData\Local\github-copilot\host.json** | ||||
| 
 | ||||
| ```json | ||||
| { | ||||
|     "github.com":{ | ||||
|         "user":"suibian",//Fill in as desired | ||||
|         "oauth_token":"i_am_free",// Corresponds to the "verification" value above | ||||
|         "dev_override":{ | ||||
|             "copilot_token_url":"https://api.example.com/copilot_internal/v2/token"   | ||||
|             					// Your address | ||||
|         } | ||||
|     } | ||||
| } | ||||
| ``` | ||||
| - **For Vscode Plugin: Modify %userprofile%\.vscode\extensions\github.copilot-xxxx\dist\extension.js** | ||||
| 
 | ||||
| ```js | ||||
| //Add the following code, note that you'll need to re-add it if the vscode plugin gets updated; Jetbrains does not require this step | ||||
| process.env.GITHUB_TOKEN="i_am_free"; // Corresponds to the "verification" value above | ||||
| process.env.GITHUB_API_URL="https://api.example.com"; // Your address | ||||
| process.env.CODESPACES="true"; | ||||
| process.env.GITHUB_SERVER_URL="https://github.com"; | ||||
| ``` | ||||
| 
 | ||||
| ------ | ||||
| 
 | ||||
| ##### **Successful Testing:**  | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										58
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										58
									
								
								README.md
									
									
									
									
									
								
							| @ -1,10 +1,5 @@ | ||||
| [中文](README.md) / [English](README-EN.md)  | ||||
| 
 | ||||
| ------ | ||||
| 
 | ||||
| 测试版已经支持全部接口代理, | ||||
| 所有也就是代码提示也走代理, | ||||
| 还在测试中。 | ||||
| 所有也就是代码提示也走代理。:stuck_out_tongue:  | ||||
| 
 | ||||
|  | ||||
| *** | ||||
| @ -13,30 +8,7 @@ | ||||
| - 作为代理服务器,中转copilot插件的API的请求 | ||||
| - 支持vscode插件和jetbrains插件 | ||||
| - 支持多用户共享一个token | ||||
| - 优化请求逻辑,降低suspended概率(别万人骑基本不会) | ||||
| 
 | ||||
| ```sh | ||||
| 简单说一下本地插件原本的请求逻辑: | ||||
| 
 | ||||
| 1.本地插件携ghu_token请求github的API | ||||
| 
 | ||||
| 2.返回带有时间戳的copilot的token(下面简称co_token),代码提示都是用的co_token | ||||
| 
 | ||||
| 3.co_token到期->ghu_token重新请求->获得新的co_token | ||||
| ------------------------------------------------------------- | ||||
| 
 | ||||
| 代理服务器代理的是 ghu_token请求 这一环节: | ||||
| 
 | ||||
| 1.携ghu_token请求github的API,暂存co_token | ||||
| 
 | ||||
| 2.多用户请求时,判断co_token有没有过期,没过期直接返回,减少ghu_token的请求次数(大约10-20分钟过期) | ||||
| 
 | ||||
| 至于本地co_token,也就是代码提示没有走代理(可以代理,但是要修改插件,jetbrains的插件还要重新build) | ||||
| 
 | ||||
| 猜测风控目前也是停留在请求ghu_token这一层 | ||||
| 
 | ||||
| ``` | ||||
| 
 | ||||
| - 优化请求逻辑,降低token被ban概率(别万人骑基本不可能封) | ||||
|  | ||||
| 
 | ||||
| *** | ||||
| @ -46,7 +18,6 @@ | ||||
| 需要 go环境 出问题自行chatgpt | ||||
| ``` | ||||
| ```sh | ||||
| git clone https://gitee.com/chuangxxt/share-copilot.git | ||||
| wget https://dl.google.com/go/go1.21.1.linux-amd64.tar.gz | ||||
| tar -C /usr/local -xzf go1.21.1.linux-amd64.tar.gz | ||||
| 
 | ||||
| @ -55,13 +26,13 @@ vim ~/.bashrc | ||||
| export PATH=$PATH:/usr/local/go/bin | ||||
| export GOPATH=$HOME/go | ||||
| export PATH=$PATH:$GOPATH/bin | ||||
| 
 | ||||
| #使生效环境变量 | ||||
| source ~/.bashrc | ||||
| #验证go配置 | ||||
| #验证安装 | ||||
| go version  | ||||
| 
 | ||||
| #cd到main.go源码目录 | ||||
| cd /share-copilot/src | ||||
| cd /share-copilot/source | ||||
| go build | ||||
| ``` | ||||
| *** | ||||
| @ -70,10 +41,7 @@ go build | ||||
| ### 1.安装 | ||||
| 
 | ||||
| ```sh | ||||
| wget https://gitee.com/chuangxxt/share-copilot/releases/download/1.0.2/share-copilot-linux-amd64.zip | ||||
| ``` | ||||
| ```sh | ||||
| unzip share-copilot-linux-amd64.zip  | ||||
| git clone https://gitlab.com/luyoyu/share-copilot.git | ||||
| ``` | ||||
| ```sh | ||||
| cd share-copilot | ||||
| @ -84,10 +52,6 @@ bash install.sh | ||||
| 
 | ||||
| ### 2.配置 | ||||
| 
 | ||||
| ```sh | ||||
| vim  config.json #修改配置信息 | ||||
| ``` | ||||
| 
 | ||||
| ##### 2.1 config.json文件说明 | ||||
| 
 | ||||
| ```js | ||||
| @ -135,11 +99,11 @@ verification//自定义验证 | ||||
| 
 | ||||
| ### 3.启动  | ||||
| 
 | ||||
| ```sh | ||||
| scop r  #运行 [Ctrl+c退出] 如果运行失败添加可执行权限 chmod +x share-copilot | ||||
| scop rb #后台运行 | ||||
| scop st #停止 | ||||
| scop v  #查看是否运行 | ||||
| ``` | ||||
| scop r  --运行 [Esc退出] | ||||
| scop rb --后台运行 | ||||
| scop st --停止 | ||||
| scop v  --查看状态 | ||||
| ``` | ||||
| 
 | ||||
| ### 4.完整例子: | ||||
|  | ||||
							
								
								
									
										15
									
								
								config.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								config.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| { | ||||
| 	"server": { | ||||
| 		"domain": "example.con", | ||||
| 		"host": "0.0.0.0", | ||||
| 		"port": 443, | ||||
| 		"certPath":"./example.pem", | ||||
| 		"keyPath":"./example.pem" | ||||
| 	}, | ||||
| 	"copilot_config":{ | ||||
| 		"github_api_url": "https://api.github.com/copilot_internal/v2/token", | ||||
| 		"token":[ | ||||
| 			"yours_token" | ||||
| 		]}, | ||||
| 	"verification":"" | ||||
| } | ||||
							
								
								
									
										46
									
								
								install.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								install.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,46 @@ | ||||
| #!/bin/bash | ||||
| SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||||
| START_SCRIPT_PATH="/usr/local/bin/scop" | ||||
| cat > "$START_SCRIPT_PATH" <<EOF | ||||
| #!/bin/bash | ||||
| EXECUTABLE_DIR="$SCRIPT_DIR" | ||||
| EXECUTABLE="\$EXECUTABLE_DIR/share-copilot" | ||||
| case "\$1" in | ||||
|   r) | ||||
|     echo "Running share-copilot..." | ||||
|     "\$EXECUTABLE" | ||||
|     ;; | ||||
|   rb) | ||||
|     echo "Running share-copilot in the background..." | ||||
|     "\$EXECUTABLE" >/dev/null 2>&1 & | ||||
|     ;; | ||||
|   st) | ||||
|     echo "Stopping share-copilot..." | ||||
|     pkill -f "\$EXECUTABLE" | ||||
|     ;; | ||||
|   v) | ||||
|     if pgrep -f "\$EXECUTABLE" >/dev/null; then | ||||
|       echo "share-copilot is running" | ||||
|     else | ||||
|       echo "share-copilot is not running" | ||||
|     fi | ||||
|     ;; | ||||
|   *) | ||||
|     echo "Usage: \$0 {r|rb|st|v}" | ||||
|     exit 1 | ||||
|     ;; | ||||
| esac | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| exit 0 | ||||
| EOF | ||||
| chmod +x "$START_SCRIPT_PATH" | ||||
| echo "----------------- | ||||
| install success! | ||||
| ----------------- | ||||
| scop r  --运行 | ||||
| scop rb --后台运行 | ||||
| scop st --停止 | ||||
| scop v  --查看状态 | ||||
| -----------------" | ||||
							
								
								
									
										
											BIN
										
									
								
								share-copilot
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								share-copilot
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										3
									
								
								uninstall.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								uninstall.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | ||||
| START_SCRIPT_PATH="/usr/local/bin/scop" | ||||
| rm -f "$START_SCRIPT_PATH" | ||||
| echo "卸载完成!" | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user