docs: 重构命令和技能文档体系,规范化文档格式和内容组织

This commit is contained in:
2026-01-13 10:25:18 +08:00
parent 5a05d5ab53
commit f31f198407
19 changed files with 1055 additions and 2342 deletions

View File

@@ -2,167 +2,71 @@
description: View current Gitea configuration and runner status
---
# gitea-config
Display the current Gitea configuration and runner status.
查看当前 Gitea 配置信息和 Runner 状态。
## 工作目录
## Features
**macOS / Linux:**
```
~/.config/gitea/
```
- 显示配置的 Gitea URL
- 显示默认组织
- 验证 Token 状态和关联用户
- 显示已配置的 Runner 数量和列表
- 显示配置文件路径
**Windows:**
```
%USERPROFILE%\.config\gitea\
```
## Steps
Please perform the following:
### 1. Check Configuration File
1. **Check if configuration exists:**
- Config file:
- macOS/Linux: `~/.config/gitea/config.env`
- Windows: `%USERPROFILE%\.config\gitea\config.env`
- If not exists, prompt user to run `/gitea-reset`
2. **Load and display configuration:**
**macOS / Linux:**
```bash
config_dir="$HOME/.config/gitea"
config_file="$config_dir/config.env"
if [ ! -f "$config_file" ]; then
echo "❌ Gitea 未配置"
echo "请运行 /gitea-reset 进行配置"
exit 1
fi
source ~/.config/gitea/config.env
```
### 2. Load and Display Configuration
```bash
source "$config_file"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "当前 Gitea 配置"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo " URL: $GITEA_URL"
echo " 默认组织: ${GITEA_DEFAULT_ORG:-<未设置>}"
echo " 配置文件: $config_file"
echo ""
**Windows PowerShell:**
```powershell
Get-Content "$env:USERPROFILE\.config\gitea\config.env" | ForEach-Object {
if ($_ -match '^([^=]+)=(.*)$') {
[Environment]::SetEnvironmentVariable($matches[1], $matches[2], 'Process')
}
}
```
### 3. Validate Token and Display User Info
Show in Chinese:
- Gitea URL
- Default organization (if set)
- Config file path (根据平台显示正确路径)
```bash
response=$(curl -s -w "\n%{http_code}" \
-H "Authorization: token $GITEA_TOKEN" \
"${GITEA_URL}/api/v1/user")
3. **Validate token and display user info:**
- Call API: `GET ${GITEA_URL}/api/v1/user`
- Header: `Authorization: token ${GITEA_TOKEN}`
- Show: Token status (✓ 有效 / ✗ 无效), username, email
http_code=$(echo "$response" | tail -n1)
body=$(echo "$response" | sed '$d')
4. **Display runner information:**
- Runners directory:
- macOS/Linux: `~/.config/gitea/runners`
- Windows: `%USERPROFILE%\.config\gitea\runners`
- Count configured runners
- List each runner with status:
- 🟢 运行中 (process running)
- 🔴 已停止 (process not running)
- ⚠️ 配置异常 (config file missing)
if [ "$http_code" = "200" ]; then
username=$(echo "$body" | jq -r '.login')
email=$(echo "$body" | jq -r '.email // "<未设置>"')
echo " Token 状态: ✓ 有效"
echo " 登录用户: $username"
echo " 邮箱: $email"
else
echo " Token 状态: ✗ 无效或已过期"
fi
5. **Show management commands:**
```
管理命令:
- 重置配置: /gitea-reset
- 切换组织: /gitea-switch-org <org-name>
- 列出 Runners: /gitea-list-runners
- 创建仓库: /create-gitea-repo <repo-name>
```
### 4. Display Runner Information
```bash
runners_dir="$config_dir/runners"
if [ -d "$runners_dir" ]; then
runner_count=$(ls -1 "$runners_dir" 2>/dev/null | wc -l | tr -d ' ')
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Runner 信息"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo " 已配置 Runner 数量: $runner_count"
echo " Runner 目录: $runners_dir"
if [ "$runner_count" -gt 0 ]; then
echo ""
echo " 已配置的 Runners:"
ls -1 "$runners_dir" | while read runner; do
# Check if running
config_file="$runners_dir/$runner/config.yaml"
if [ -f "$config_file" ]; then
if pgrep -f "act_runner daemon --config $config_file" > /dev/null; then
status="🟢"
else
status="🔴"
fi
echo " $status $runner"
else
echo " ⚠️ $runner (配置文件缺失)"
fi
done
fi
else
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Runner 信息"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo " 未配置任何 Runner"
fi
```
### 5. Display Management Commands
```bash
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "管理命令"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo " 重置配置: /gitea-reset"
echo " 切换组织: /gitea-switch-org <org-name>"
echo " 列出 Runners: /gitea-list-runners"
echo " 创建仓库: /create-gitea-repo <repo-name>"
echo ""
```
## Output Example
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
当前 Gitea 配置
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
URL: https://git.digitevents.com
默认组织: ai
配置文件: /Users/voson/.config/gitea/config.env
Token 状态: ✓ 有效
登录用户: your_username
邮箱: your_username@example.com
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Runner 信息
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
已配置 Runner 数量: 2
Runner 目录: /Users/voson/.config/gitea/runners
已配置的 Runners:
🟢 runner-macbook-pro
🔴 runner-mac-mini
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
管理命令
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
重置配置: /gitea-reset
切换组织: /gitea-switch-org <org-name>
列出 Runners: /gitea-list-runners
创建仓库: /create-gitea-repo <repo-name>
```
## Notes
- 使用 `jq` 解析 JSON 响应
- 检查 runner 进程使用 `pgrep`
- Token 验证通过调用 `/api/v1/user` endpoint
- Runner 状态:🟢 运行中、🔴 已停止、⚠️ 配置异常
Use `jq` to parse JSON responses and `pgrep` to check runner process status.