mcpField
G
github-copilot

github-copilot

github.com/okou-ai其他81103 次安装1 周前更新
代码仓库

关于 github-copilot

此技能帮助 GitHub Copilot Business/Enterprise 组织管理员通过 GitHub API 管理席位并查看使用情况。它涵盖组织和团队级查询,以及用户和团队的席位分配。

主要功能

  1. 01查看组织 Copilot 账单与席位概况
  2. 02列出席位及用户活动时间
  3. 03查询单个用户的席位详情
  4. 04为用户或团队分配、移除席位
  5. 05查看组织及团队使用指标

适用场景

  1. 01盘点组织的 Copilot 席位与活跃情况
  2. 02为新成员或团队开通 Copilot 席位
  3. 03移除不再需要的席位
  4. 04按组织或团队检查 Copilot 使用数据

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/okou-ai/okou-skills --skill github-copilot

安装后在 Claude Code 中输入/github-copilot确认已加载。

详细介绍

故障排除

如果请求失败,请运行 okou doctor check-connector --env-name GITHUB_TOKEN 或 okou doctor check-connector --url https://api.github.com/orgs/your-org/copilot/billing --method GET

使用方法

以下所有示例均假设你已设置 GITHUB_TOKEN。

基础 URL:https://api.github.com

必需的请求头:

  • Authorization: Bearer ${GITHUB_TOKEN}
  • Accept: application/vnd.github+json
  • X-GitHub-Api-Version: 2022-11-28
1. 获取 Copilot 账单信息

获取组织的席位明细和设置。将 your-org-name 替换为你的组织名称:

curl -s -X GET "https://api.github.com/orgs/your-org-name/copilot/billing" --header "Authorization: Bearer $GITHUB_TOKEN" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28"

响应:

{
  "seat_breakdown": {
  "total": 12,
  "added_this_cycle": 2,
  "pending_cancellation": 0,
  "pending_invitation": 1,
  "active_this_cycle": 12,
  "inactive_this_cycle": 0
  },
  "seat_management_setting": "assign_selected",
  "public_code_suggestions": "block"
}
2. 列出所有 Copilot 席位分配

获取所有拥有 Copilot 席位的用户。将 your-org-name 替换为你的组织名称:

curl -s -X GET "https://api.github.com/orgs/your-org-name/copilot/billing/seats?per_page=50" --header "Authorization: Bearer $GITHUB_TOKEN" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28" | jq '.seats[] | {login: .assignee.login, last_activity: .last_activity_at}'
3. 获取用户的 Copilot 席位详情

获取特定用户的 Copilot 席位信息。将 your-org-name 替换为你的组织名称,并将 username 替换为目标用户名:

curl -s -X GET "https://api.github.com/orgs/your-org-name/members/username/copilot" --header "Authorization: Bearer $GITHUB_TOKEN" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28"
4. 将用户添加到 Copilot 订阅

为特定用户分配 Copilot 席位。将 your-org-name 替换为你的组织名称:

写入 /tmp/github_copilot_request.json:

{
  "selected_usernames": ["user1", "user2"]
}

然后运行:

curl -s -X POST "https://api.github.com/orgs/your-org-name/copilot/billing/selected_users" --header "Authorization: Bearer $GITHUB_TOKEN" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28" --header "Content-Type: application/json" -d @/tmp/github_copilot_request.json

响应:

{
  "seats_created": 2
}
5. 将用户从 Copilot 订阅中移除

移除特定用户的 Copilot 席位。将 your-org-name 替换为你的组织名称:

写入 /tmp/github_copilot_request.json:

{
  "selected_usernames": ["user1", "user2"]
}

然后运行:

curl -s -X DELETE "https://api.github.com/orgs/your-org-name/copilot/billing/selected_users" --header "Authorization: Bearer $GITHUB_TOKEN" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28" --header "Content-Type: application/json" -d @/tmp/github_copilot_request.json

响应:

{
  "seats_cancelled": 2
}
6. 将团队添加到 Copilot 订阅

为整个团队分配 Copilot。将 your-org-name 替换为你的组织名称:

写入 /tmp/github_copilot_request.json:

{
  "selected_teams": ["engineering", "design"]
}

然后运行:

curl -s -X POST "https://api.github.com/orgs/your-org-name/copilot/billing/selected_teams" --header "Authorization: Bearer $GITHUB_TOKEN" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28" --header "Content-Type: application/json" -d @/tmp/github_copilot_request.json
7. 将团队从 Copilot 订阅中移除

从团队中移除 Copilot。将 your-org-name 替换为你的组织名称:

写入 /tmp/github_copilot_request.json:

{
  "selected_teams": ["engineering"]
}

然后运行:

curl -s -X DELETE "https://api.github.com/orgs/your-org-name/copilot/billing/selected_teams" --header "Authorization: Bearer $GITHUB_TOKEN" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28" --header "Content-Type: application/json" -d @/tmp/github_copilot_request.json
8. 获取组织的 Copilot 使用指标

获取使用统计信息(需要 5 名以上活跃用户)。将 your-org-name 替换为你的组织名称:

curl -s -X GET "https://api.github.com/orgs/your-org-name/copilot/metrics?per_page=7" --header "Authorization: Bearer $GITHUB_TOKEN" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28" | jq '.[] | {date, total_active_users, total_engaged_users}'

响应:

{
  "date": "2024-06-24",
  "total_active_users": 24,
  "total_engaged_users": 20
}
9. 获取团队的 Copilot 指标

获取特定团队的使用指标。将 your-org-name 替换为你的组织名称,并将 team-name 替换为目标团队:

curl -s -X GET "https://api.github.com/orgs/your-org-name/team/team-name/copilot/metrics" --header "Authorization: Bearer $GITHUB_TOKEN" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28"

指标数据结构

指标响应包括:

字段描述
total_active_users有 Copilot 活动的用户
total_engaged_users接受了建议的用户
copilot_ide_code_completions按语言/编辑器统计的代码补全数据
copilot_ide_chatIDE 聊天使用统计
copilot_dotcom_chatGitHub.com 聊天使用情况
copilot_dotcom_pull_requestsPR 摘要使用情况

指南

  1. 需要 Copilot Business/Enterprise:免费版用户无法使用此 API
  2. 指标需要 5 名以上用户:只有活跃 Copilot 用户达到 5 名以上时,才提供使用指标
  3. 数据保留期限:指标最长可查询 100 天
  4. 速率限制:适用 GitHub API 标准速率限制
  5. API 处于预览阶段:部分端点可能会变更

评论

支持 Markdown