chore: 重构 OpenCode 命令和技能文档体系
- 新增:统一的 git 命令文档(add/commit/push/pull 等) - 新增:整合的 Gitea 技能文档(API、运行器、工作流等) - 新增:工作流模板(Android、Go、Node.js 等) - 移除:已弃用的旧命令脚本和发布脚本 - 改进:.gitignore 添加敏感文件保护规则 - 改进:AGENTS.md 完善了开发规范和示例 此次重组统一了命令和技能的文档结构,便于后续维护和扩展。
This commit is contained in:
168
command/gitea-config.md
Normal file
168
command/gitea-config.md
Normal file
@@ -0,0 +1,168 @@
|
||||
---
|
||||
description: View current Gitea configuration and runner status
|
||||
---
|
||||
|
||||
# gitea-config
|
||||
|
||||
查看当前 Gitea 配置信息和 Runner 状态。
|
||||
|
||||
## Features
|
||||
|
||||
- 显示配置的 Gitea URL
|
||||
- 显示默认组织
|
||||
- 验证 Token 状态和关联用户
|
||||
- 显示已配置的 Runner 数量和列表
|
||||
- 显示配置文件路径
|
||||
|
||||
## Steps
|
||||
|
||||
### 1. Check Configuration File
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
### 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 ""
|
||||
```
|
||||
|
||||
### 3. Validate Token and Display User Info
|
||||
|
||||
```bash
|
||||
response=$(curl -s -w "\n%{http_code}" \
|
||||
-H "Authorization: token $GITEA_TOKEN" \
|
||||
"${GITEA_URL}/api/v1/user")
|
||||
|
||||
http_code=$(echo "$response" | tail -n1)
|
||||
body=$(echo "$response" | sed '$d')
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
### 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 状态:🟢 运行中、🔴 已停止、⚠️ 配置异常
|
||||
Reference in New Issue
Block a user