🚀 Copilot Hub CLI

GitHub Copilot CLI 完整使用教程

Windows macOS Linux
🪟

Windows 使用教程

⚠️ 前置条件
  • VS Code:需为最新版本,请前往 官网下载 更新
  • Copilot CLI:需为最新版本,运行 npm install -g @github/copilot 更新

一、环境准备

1

安装 Node.js(v16 或以上)

  • 下载地址:https://nodejs.org/
  • 安装时勾选 "Add to PATH"
  • 验证安装:
    node -v
    npm -v
2

安装 GitHub Copilot CLI

npm install -g @github/copilot

二、安装 Copilot Hub

npm install -g copilot-hub-cli@latest

三、启动 Copilot Hub

copilot-hub
启动后会显示:
Copilot Hub v1.4.0
🌐 面板地址:http://127.0.0.1:9100
🔑 请在浏览器面板中输入卡密激活

四、浏览器面板操作

  1. 打开浏览器,访问 http://127.0.0.1:9100
  2. 在面板中输入卡密(sk-xxxx),点击 ✨ 激活
  3. 激活成功后,面板会显示代理状态、配额等信息

五、启动 VS Code

在面板中点击 🖥️ 启动 VS Code 按钮,将自动启动已配置好代理的 VS Code。

六、启动 Copilot CLI

  1. 在面板中点击 ⌨️ 启动 Copilot CLI
  2. 选择目录后,选择启动模式:
    • 🔹 普通模式 — 默认启动,执行操作前需确认
    • 最高权限--allow-all 模式,所有操作无需确认
  3. 点击 🚀 启动
🍎

macOS 使用教程

⚠️ 前置条件
  • VS Code:需为最新版本,请前往 官网下载 更新
  • Copilot CLI:需为最新版本,运行 npm install -g @github/copilot 更新

一、环境准备

1

安装 Node.js

推荐使用 Homebrew:

brew install node

验证安装:

node -v
npm -v
2

安装 GitHub Copilot CLI

npm install -g @github/copilot

二、安装 Copilot Hub

npm install -g copilot-hub-cli@latest

如提示权限问题,使用:sudo npm install -g copilot-hub-cli@latest

三、启动 Copilot Hub

copilot-hub

四、浏览器面板操作

  1. 打开浏览器,访问 http://127.0.0.1:9100
  2. 输入卡密(sk-xxxx),点击 ✨ 激活
  3. 激活成功后,面板显示代理状态、配额等信息

五、启动 VS Code

在面板中点击 🖥️ 启动 VS Code 按钮,自动打开已配置好代理的 VS Code。

六、启动 Copilot CLI

在面板中点击 ⌨️ 启动 Copilot CLI,选择目录和模式后点击 🚀 启动

🐧

Linux 使用教程

适用于 Ubuntu、CentOS、Debian、OpenCloudOS、AlmaLinux 等所有 Linux 发行版

⚠️ 前置条件
  • VS Code:需为最新版本,请前往 官网下载 更新
  • Copilot CLI:需为最新版本,运行 npm install -g @github/copilot 更新

一、安装 Node.js

Ubuntu / Debian:

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs

CentOS / RHEL / OpenCloudOS:

curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
sudo yum install -y nodejs

二、安装 Copilot Hub

npm install -g copilot-hub-cli@latest

三、启动服务

copilot-hub

Linux 会自动以后台守护进程方式运行

四、使用 Copilot CLI

copilot-hub shell

进入后自动配置代理环境变量,然后直接使用:

copilot
# 或
copilot --allow-all

五、防火墙设置

Ubuntu / Debian(ufw):

sudo ufw allow 9100/tcp

CentOS / RHEL(firewalld):

sudo firewall-cmd --permanent --add-port=9100/tcp
sudo firewall-cmd --reload

常见问题

如何更新到最新版本?

npm install -g copilot-hub-cli@latest

面板打不开怎么办?

  • 检查服务器面板防火墙是否放行 9100 端口
  • 检查是否已启动:copilot-hub status
  • 检查端口是否被占用:lsof -i :9100(macOS/Linux)
  • 检查防火墙是否放行 9100 端口

浏览器显示旧版面板?

强制刷新:Ctrl+Shift+R(Windows/Linux)或 Cmd+Shift+R(macOS)

激活失败提示连接后端失败?

  • Linux 用户确保使用 copilot-hub shell 进入代理环境后再操作
  • 检查日志:tail -f ~/.copilot-hub/daemon.log

VS Code 中 Copilot 不工作?

  • 确保通过面板的"启动 VS Code"按钮打开(会自动配置代理)
  • 不要手动打开 VS Code,否则代理不会生效