diff --git a/skills/vala_git_workspace_backup/SKILL.md b/skills/vala_git_workspace_backup/SKILL.md index 8bec78d..eb35c30 100644 --- a/skills/vala_git_workspace_backup/SKILL.md +++ b/skills/vala_git_workspace_backup/SKILL.md @@ -3,6 +3,7 @@ 自动将OpenClaw workspace内容定期备份到Git仓库,自动过滤敏感信息,无硬编码凭证。 ## 特性 - ✅ 全流程自动化,无需手动提前创建Git仓库 +- ✅ 支持多数字员工共用同一个Git账号,按数字员工名称区分仓库 - ✅ 自动排除密钥、密码等敏感文件(secrets.md、.env、*.key等) - ✅ 内置公司Git服务(git.valavala.com)支持,无需额外配置地址 - ✅ 支持自定义定时备份时间 @@ -20,10 +21,11 @@ ## 配置参数 | 参数名 | 类型 | 必填 | 说明 | |--------|------|------|------| -| git_token | string | 是 | Git仓库访问Token | -| git_username | string | 是 | Git用户名 | +| agent_name | string | 是 | 数字员工唯一名称(如xiaoyan/xiaoxi/xiaokui等),用于生成唯一仓库名 | +| git_token | string | 是 | Git仓库访问Token(所有数字员工共用同一个Git账号的Token) | +| git_username | string | 是 | Git用户名(所有数字员工共用同一个Git账号) | | git_email | string | 是 | Git提交邮箱 | -| git_repo_url | string | 否 | Git仓库HTTPS地址(格式:https://域名/所有者/仓库名.git),默认使用公司git.valavala.com服务,自动生成仓库地址:https://git.valavala.com/{git_username}/ai_member_{git_username}.git | +| git_repo_url | string | 否 | Git仓库HTTPS地址(格式:https://域名/所有者/仓库名.git),默认使用公司git.valavala.com服务,自动生成仓库地址:https://git.valavala.com/{git_username}/ai_member_{agent_name}.git | | cron_schedule | string | 否 | 定时任务cron表达式,默认值:`30 8 * * *`(每天早上8:30) | ## 使用方法 ### 1. 初始化配置 diff --git a/skills/vala_git_workspace_backup/scripts/setup.sh b/skills/vala_git_workspace_backup/scripts/setup.sh index f0d4d98..80e1f5d 100755 --- a/skills/vala_git_workspace_backup/scripts/setup.sh +++ b/skills/vala_git_workspace_backup/scripts/setup.sh @@ -1,13 +1,14 @@ #!/bin/bash set -e # 从传入参数获取配置,无硬编码敏感信息 -GIT_TOKEN="$1" -GIT_USERNAME="$2" -GIT_EMAIL="$3" -GIT_REPO_URL="${4:-https://git.valavala.com/${GIT_USERNAME}/ai_member_${GIT_USERNAME}.git}" -CRON_SCHEDULE="${5:-30 8 * * *}" +AGENT_NAME="$1" +GIT_TOKEN="$2" +GIT_USERNAME="$3" +GIT_EMAIL="$4" +GIT_REPO_URL="${5:-https://git.valavala.com/${GIT_USERNAME}/ai_member_${AGENT_NAME}.git}" +CRON_SCHEDULE="${6:-30 8 * * *}" # 自动创建Git仓库(如果不存在) -REPO_NAME="ai_member_${GIT_USERNAME}" +REPO_NAME="ai_member_${AGENT_NAME}" echo "🔍 检查Git仓库是否存在: $REPO_NAME" REPO_CHECK=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GIT_TOKEN" "https://git.valavala.com/api/v1/repos/$GIT_USERNAME/$REPO_NAME") if [ "$REPO_CHECK" -eq 404 ]; then @@ -18,7 +19,7 @@ if [ "$REPO_CHECK" -eq 404 ]; then -d "{ \"name\": \"$REPO_NAME\", \"private\": false, - \"description\": \"${GIT_USERNAME} workspace 备份\", + \"description\": \"${AGENT_NAME} workspace 备份\", \"auto_init\": false }") if echo "$CREATE_RESPONSE" | grep -q '"id":'; then diff --git a/skills/vala_git_workspace_backup/skill.yml b/skills/vala_git_workspace_backup/skill.yml index 6e4da75..8252856 100644 --- a/skills/vala_git_workspace_backup/skill.yml +++ b/skills/vala_git_workspace_backup/skill.yml @@ -3,12 +3,16 @@ description: 自动备份OpenClaw workspace到Git仓库,支持定时任务, version: 1.0.0 author: xiaoyan parameters: + agent_name: + description: 数字员工名称(如xiaoyan/xiaoxi/xiaokui等),用于生成仓库名 + required: true + type: string git_token: - description: Git仓库访问Token + description: Git仓库访问Token(所有数字员工共用同一个Git账号的Token) required: true type: string git_username: - description: Git用户名 + description: Git用户名(所有数字员工共用同一个Git账号) required: true type: string git_email: @@ -16,7 +20,7 @@ parameters: required: true type: string git_repo_url: - description: Git仓库HTTPS地址(可选,默认使用公司git.valavala.com服务,仓库名规则:ai_member_${git_username}) + description: Git仓库HTTPS地址(可选,默认使用公司git.valavala.com服务,仓库名规则:ai_member_${agent_name}) required: false type: string cron_schedule: