atomgit

SkillDB 作者 weidongkl v3.0.0

AtomGit/GitCode 仓库管理技能,提供用户、仓库、Issue、PR、文件、分支等 API 操作。AtomGit 和 GitCode 是同一平台的不同域名(atomgit.com / gitcode.com),共享相同的 API 后端。

源码 ↗

安装 / 下载方式

TotalClaw CLI推荐
totalclaw install skilldb:weidongkl~atomgit
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/skilldb%3Aweidongkl~atomgit/file -o atomgit.md
Git 仓库获取源码
git clone https://github.com/openclaw/skills/commit/5683027b1f1c3dac671d655de04d0bd94e5fd0af
# atomgit - AtomGit/GitCode API 技能

直接调用 AtomGit/GitCode OpenAPI v5,通过 curl 命令执行操作。

> **注意**:AtomGit (atomgit.com) 和 GitCode (gitcode.com) 是**同一平台的不同域名**,共享相同的 API 后端。无论使用哪个域名,API 端点都相同。

## 前置条件

1. **AtomGit/GitCode Token** - 访问以下任一地址生成:
   - https://gitcode.com/setting/token-classic
   - https://atomgit.com/setting/token-classic
2. **权限**:`api`, `read_user`, `read_repository`, `write_repository`, `issues`, `pull_requests`

> Token 在两个平台通用,因为后端是同一套系统。

## 配置方法

### 方式一:Gateway 配置(推荐)

编辑 `~/.openclaw/openclaw.json`,添加 skill 配置:

```json
{
  "skills": {
    "entries": {
      "atomgit": {
        "enabled": true,
        "env": {
          "ATOMGIT_TOKEN": "your-token-here"
        }
      }
    }
  }
}
```

或使用环境变量占位符:

```json
{
  "skills": {
    "entries": {
      "atomgit": {
        "enabled": true,
        "env": {
          "ATOMGIT_TOKEN": "__ATOMGIT_TOKEN__"
        }
      }
    }
  }
}
```

然后在终端设置环境变量:

```bash
export ATOMGIT_TOKEN="your-token-here"
```

### 方式二:终端环境变量

直接在终端设置:

```bash
export ATOMGIT_TOKEN="your-token-here"
```

## API 信息

- **Base URL**: 
  - `https://api.gitcode.com/api/v5` (推荐)
  - `https://api.atomgit.com/api/v5` (等效)
- **认证**: `Authorization: Bearer <TOKEN>`
- **速率限制**: 50 次/分钟

> 两个 API 端点完全等效,数据互通。

---

## 完整 API 接口列表 (294 个端点)

### 一、用户 API (User) - 42 个端点

#### ✅ 已验证可用的接口

```bash
# 获取当前用户信息
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/user

# 获取当前用户邮箱
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/user/emails

# 获取当前用户仓库列表
curl -H "Authorization: Bearer $TOKEN" "https://api.gitcode.com/api/v5/user/repos?per_page=20"

# 获取当前用户收藏的仓库
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/user/starred

# 获取当前用户订阅的仓库
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/user/subscriptions

# 获取指定用户信息
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/users/:username

# 获取指定用户的仓库
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/users/:username/repos

# 获取指定用户收藏的仓库
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/users/:username/starred

# 获取用户的组织
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/users/:username/orgs

# 获取当前用户的组织
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/user/orgs

# 添加 SSH 密钥
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"title":"My Key","key":"ssh-rsa AAA..."}' \
  https://api.gitcode.com/api/v5/user/keys

# 获取 SSH 密钥列表
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/user/keys

# 删除 SSH 密钥
curl -X DELETE -H "Authorization: Bearer $TOKEN" \
  https://api.gitcode.com/api/v5/user/keys/:id
```

---

### 二、仓库 API (Repository) - 168 个端点

#### ✅ 已验证可用的接口

```bash
# 获取仓库详情
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo

# 获取仓库分支列表
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/branches

# 获取仓库提交列表
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/commits

# 获取单个提交详情
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/commits/:sha

# 获取提交 diff
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/commits/:sha/diff

# 获取仓库标签列表
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/tags

# 获取文件内容
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/contents/:path

# 获取目录树
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/git/trees/:sha

# 获取贡献者列表
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/contributors

# 获取语言统计
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/languages

# 获取 Star 用户列表
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/stargazers

# 获取 Fork 列表
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/forks

# 获取协作者列表
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/collaborators

# 获取 Webhook 列表
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/hooks

# 获取版本列表
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/releases

# 获取仓库通知
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/notifications

# 创建用户仓库
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"name":"my-repo","description":"My repo","private":false,"auto_init":true}' \
  https://api.gitcode.com/api/v5/user/repos

# 创建组织仓库
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"name":"org-repo","description":"Org repo"}' \
  https://api.gitcode.com/api/v5/orgs/:org/repos

# 更新仓库
curl -X PUT -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"description":"New description","private":false}' \
  https://api.gitcode.com/api/v5/repos/:owner/:repo

# 删除仓库 ⚠️
curl -X DELETE -H "Authorization: Bearer $TOKEN" \
  https://api.gitcode.com/api/v5/repos/:owner/:repo

# Fork 仓库
curl -X POST -H "Authorization: Bearer $TOKEN" \
  https://api.gitcode.com/api/v5/repos/:owner/:repo/forks

# 转移仓库
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"new_owner":"new-owner"}' \
  https://api.gitcode.com/api/v5/repos/:owner/:repo/transfer
```

#### ⚠️ 已知问题的接口

```bash
# 获取文件列表 - 404 Not Found
# curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/file-list

# 获取最新版本 - 400 Bad Request (无 release 时)
# curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/releases/latest
```

---

### 三、分支 API (Branch) - 10 个端点

#### ✅ 已验证可用的接口

```bash
# 获取分支列表
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/branches

# 获取单个分支详情
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/branches/:branch

# 获取保护分支
curl -H "Authorization: Bearer $TOKEN" https://api.gitcode.com/api/v5/repos/:owner/:repo/protect-branches
```

#### ⚠️ 已知问题的接口

```bash
# 创建分支 - 400 PARAMETER_ERROR
# 参数格式不明确,需要官方文档确认
# curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
#   -d '{"branch":"feature","ref":"main"}' \
#   https://api.gitcode.com/api/v5/repos/:owner/:repo/branches

# 删除分支 ⚠️
# curl -X DELETE -H "Authorization: Bearer $TOKEN" \
#   https://api.gitcode.com/api/v5/repos/:owner/:repo/branches/:name
```

---

### 四、文件 API (Content) - 8 个端点

#### ✅ 已验证可用的接口

```bash
# 获取文件内容
curl -H "Authorization: Bearer $TOKEN" \
  https://api.gitcode.com/api/v5/repos/:owner/:repo/contents/:path

# 获取原始文件
curl -H "Authorization: Bearer $TOKEN" \
  https://api.gitcode.com/api/v5/repos/:owner/:repo/raw/:path

# 获取目录树
curl -H "Authorization: Bearer $TOKEN" \
  https://api.gitcode.com/api/v5/repos/:owner/:repo/git/trees/:sha
```

#### ⚠️ 已知问题的接口

```bash
# 创建/更新文件 - 400 Bad Request (需要提供 sha)
# 更新文件时必须提供当前文件的 sha
# curl -X PUT -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
#   -d '{"content":"base64 编码","message":"Update file","branch":"main","sha":"xxx"}' \
#   https://api.gitcode.com/api/v5/repos/:owner/:repo/contents/:path

# 删除文件 ⚠️
# curl -X DELETE -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
#   -d '{"message":"Delete file","branch":"main","sha":"xxx"}' \
#   https://api.gitcode.com/api/v5/repos/:owner/:repo/contents/:path
```

---

### 五、Issue API - 38 个端点

#### ✅ 已验证可用的接口

```bash
# 获取 Issue 列表
curl -H "Authorization: Bearer $TOKEN" \
  "https://api.gitcode.com/api/v5/repos/:owner/:repo/issues?state=all"

# 获取 Issue 详情
curl -H "Authorization: Bearer $TOKEN" \
  https://api.gitcode