Git Delegation Management
This skill enables the Manager to execute any git operation on behalf of Workers. Workers cannot access git credentials, so they delegate all git operations to the Manager.
Prerequisites
The Manager has access to:
- - Host's
.gitconfig via /host-share/.gitconfig (symlinked to /root/.gitconfig) - Git credentials (SSH keys, credential helpers) configured on the host
This allows git operations to use the correct author name, email, and authentication.
Handling git-request: Messages
When a Worker sends a message containing git-request::
CODEBLOCK0
Extract:
- -
task-id: Task identifier - INLINECODE6 : Path to work in (for clone: parent directory; for other ops: repo directory)
- INLINECODE7 : List of git commands to execute (literally what to run)
- INLINECODE8 : (Optional) What the Worker is trying to accomplish
Execution Flow
1. Sync and Check Processing Marker
CODEBLOCK1
2. Execute Git Commands
Navigate to the workspace and execute the git commands:
CODEBLOCK2
You know how to use git. Execute the commands the Worker requests. If something goes wrong (merge conflict, authentication failure, etc.), handle it appropriately.
3. Cleanup and Respond
CODEBLOCK3
On success — send to Worker:
CODEBLOCK4
On failure — send to Worker:
@{worker}:DOMAIN task-{task-id} git-failed:
Git operation failed: {error message}
{Suggestion for how to fix it, if applicable}
What Operations Can Be Delegated
Any git operation, including but not limited to:
| Category | Commands |
|---|
| Repository | INLINECODE9 , INLINECODE10 |
| Branches |
git branch,
git checkout,
git switch |
| Remote |
git remote,
git fetch,
git pull,
git push |
| Commits |
git add,
git commit,
git reset,
git revert |
| History |
git log,
git show,
git diff |
| Rebase |
git rebase,
git rebase -i |
| Cherry-pick |
git cherry-pick |
| Merge |
git merge |
| Stash |
git stash |
| Tags |
git tag |
| Submodules |
git submodule |
| Config |
git config (local to repo) |
If git can do it, the Worker can delegate it.
Error Handling
When git operations fail:
- 1. Read the error message and understand what went wrong
- Try to fix it if it's a simple issue (e.g., set upstream, configure user locally)
- Report to Worker if it requires their action (e.g., merge conflicts, rebasing decisions)
- Escalate to admin if it's a credential or permission issue
Common issues:
- - Merge conflicts → Ask Worker to resolve locally
- Authentication failure → Check
/host-share/.gitconfig and credential helper - Branch divergence → Worker may need to pull/rebase first
Integration with Task Coordination
Always use the .processing marker to prevent conflicts when both Worker and Manager might modify the workspace.
Git 委托管理
此技能使管理者能够代表工作者执行任何 git 操作。工作者无法访问 git 凭据,因此他们将所有 git 操作委托给管理者。
前提条件
管理者可以访问:
- - 通过 /host-share/.gitconfig(符号链接到 /root/.gitconfig)访问主机的 .gitconfig
- 在主机上配置的 git 凭据(SSH 密钥、凭据助手)
这使得 git 操作能够使用正确的作者姓名、电子邮件和身份验证。
处理 git-request: 消息
当工作者发送包含 git-request: 的消息时:
task-{task-id} git-request:
workspace: /root/hiclaw-fs/shared/tasks/{task-id}/workspace/{repo-name}
operations:
- git clone https://github.com/org/repo.git
- git checkout -b feature-auth
- git add .
- git commit -m feat: add authentication
- git push origin feature-auth
---CONTEXT---
{对他们试图完成的任务的描述}
---END---
提取:
- - task-id:任务标识符
- workspace:工作路径(对于克隆:父目录;对于其他操作:仓库目录)
- operations:要执行的 git 命令列表(字面意义上要运行的内容)
- context:(可选)工作者试图完成的任务
执行流程
1. 同步并检查处理标记
bash
task_id=task-YYYYMMDD-HHMMSS
workspace=/root/hiclaw-fs/shared/tasks/${task_id}/workspace/{repo-name}
从 MinIO 同步
mc mirror hiclaw/hiclaw-storage/shared/tasks/${task_id}/ \
/root/hiclaw-fs/shared/tasks/${task_id}/
检查处理标记
bash /opt/hiclaw/agent/skills/task-coordination/scripts/check-processing-marker.sh $task_id
if [ $? -ne 0 ]; then
# 回复 git-failed:解释冲突
exit 1
fi
创建处理标记
bash /opt/hiclaw/agent/skills/task-coordination/scripts/create-processing-marker.sh $task_id manager 15
2. 执行 Git 命令
导航到工作区并执行 git 命令:
bash
cd $workspace
执行每个 git 命令
git clone https://github.com/org/repo.git
git checkout -b feature-auth
... 等等
记录输出用于调试
你知道如何使用 git。执行工作者请求的命令。如果出现问题(合并冲突、身份验证失败等),请适当处理。
3. 清理并回复
bash
移除处理标记
bash /opt/hiclaw/agent/skills/task-coordination/scripts/remove-processing-marker.sh $task_id
同步到 MinIO
mc mirror /root/hiclaw-fs/shared/tasks/${task_id}/ \
hiclaw/hiclaw-storage/shared/tasks/${task_id}/ --overwrite
成功时 — 发送给工作者:
@{worker}:DOMAIN task-{task-id} git-result:
Git 操作成功完成。
{已完成操作的摘要 - 提交、推送、创建的分支等}
运行 bash /opt/hiclaw/agent/skills/file-sync/scripts/hiclaw-sync.sh 进行同步。
失败时 — 发送给工作者:
@{worker}:DOMAIN task-{task-id} git-failed:
Git 操作失败:{错误消息}
{如果适用,提供修复建议}
可以委托哪些操作
任何 git 操作,包括但不限于:
| 类别 | 命令 |
|---|
| 仓库 | git clone、git init |
| 分支 |
git branch、git checkout、git switch |
| 远程 | git remote、git fetch、git pull、git push |
| 提交 | git add、git commit、git reset、git revert |
| 历史 | git log、git show、git diff |
| 变基 | git rebase、git rebase -i |
| 挑选 | git cherry-pick |
| 合并 | git merge |
| 暂存 | git stash |
| 标签 | git tag |
| 子模块 | git submodule |
| 配置 | git config(仓库本地) |
如果 git 可以做到,工作者就可以委托。
错误处理
当 git 操作失败时:
- 1. 阅读错误消息并理解出了什么问题
- 尝试修复如果是简单问题(例如,设置上游、本地配置用户)
- 报告给工作者如果需要他们采取行动(例如,合并冲突、变基决策)
- 升级给管理员如果是凭据或权限问题
常见问题:
- - 合并冲突 → 要求工作者本地解决
- 身份验证失败 → 检查 /host-share/.gitconfig 和凭据助手
- 分支分歧 → 工作者可能需要先拉取/变基
与任务协调的集成
始终使用 .processing 标记来防止工作者和管理者都可能修改工作区时的冲突。