Skip to content

alchaincyf/huashu-skills / huashu-agent-swarm

huashu-agent-swarm

Verified

多Agent蜂群并行协作,纯git自组织,适合大型项目开发。当用户提到"蜂群模式"、"多agent"、"并行开发"、"agent swarm"时使用。

FileKindSize
SKILL.mdskill md3.6 KB
references/agent-prompt-template.mdmarkdown4.1 KB
references/carlini-lessons.mdmarkdown3.3 KB
scripts/agent_loop.shexecutablescript2.8 KB
scripts/dashboard.pyexecutablescript20.6 KB
scripts/send_input.shexecutablescript1.0 KB
scripts/setup_project.shexecutablescript2.7 KB
scripts/start_swarm.shexecutablescript3.3 KB
scripts/status.shexecutablescript2.7 KB
scripts/stop_swarm.shexecutablescript2.3 KB

scripts/agent_loop.sh

View on GitHub
#!/bin/bash
# agent_loop.sh - 单个Agent的无限循环逻辑
# 环境变量: AGENT_ID, WORK_DIR, LOG_DIR
# 用法: AGENT_ID=1 WORK_DIR=/path/to/worktree LOG_DIR=/path/to/logs bash agent_loop.sh

set -e

AGENT_ID="${AGENT_ID:-1}"
WORK_DIR="${WORK_DIR:-.}"
LOG_DIR="${LOG_DIR:-./agent_logs}"
SLEEP_INTERVAL="${SLEEP_INTERVAL:-5}"
MODEL="${MODEL:-claude-opus-4-6}"
MAX_SESSIONS="${MAX_SESSIONS:-0}"  # 0=无限

mkdir -p "$LOG_DIR"

SESSION_COUNT=0

echo "[Agent-${AGENT_ID}] 启动,工作目录: $WORK_DIR"
echo "[Agent-${AGENT_ID}] 模型: $MODEL, 休息间隔: ${SLEEP_INTERVAL}s"

while true; do
    SESSION_COUNT=$((SESSION_COUNT + 1))

    # 检查最大session限制
    if [ "$MAX_SESSIONS" -gt 0 ] && [ "$SESSION_COUNT" -gt "$MAX_SESSIONS" ]; then
        echo "[Agent-${AGENT_ID}] 已达到最大session数 ($MAX_SESSIONS),退出"
        break
    fi

    echo ""
    echo "================================================"
    echo "[Agent-${AGENT_ID}] Session #${SESSION_COUNT} 开始 - $(date '+%Y-%m-%d %H:%M:%S')"
    echo "================================================"

    cd "$WORK_DIR"

    # 同步最新代码
    echo "[Agent-${AGENT_ID}] 同步最新代码..."
    git pull --rebase origin main 2>/dev/null || true

    COMMIT=$(git rev-parse --short=6 HEAD 2>/dev/null || echo "unknown")
    TIMESTAMP=$(date +%Y%m%d_%H%M%S)
    LOGFILE="${LOG_DIR}/agent_${AGENT_ID}_session_${SESSION_COUNT}_${TIMESTAMP}.log"

    echo "[Agent-${AGENT_ID}] 当前HEAD: $COMMIT"
    echo "[Agent-${AGENT_ID}] 日志: $LOGFILE"

    # 启动Claude会话
    echo "[Agent-${AGENT_ID}] 启动Claude会话..."
    claude --dangerously-skip-permissions \
           -p "$(cat AGENT_PROMPT.md)

你是 Agent-${AGENT_ID},这是你的第 ${SESSION_COUNT} 个session。
当前时间: $(date '+%Y-%m-%d %H:%M:%S')
当前HEAD: ${COMMIT}

请按照 AGENT_PROMPT.md 的工作流程执行任务。" \
           --model "$MODEL" \
           2>&1 | tee "$LOGFILE"

    EXIT_CODE=${PIPESTATUS[0]}
    echo "[Agent-${AGENT_ID}] Claude退出,状态码: $EXIT_CODE"

    # 推送成果(如果有新commit)
    NEW_COMMIT=$(git rev-parse --short=6 HEAD 2>/dev/null || echo "unknown")
    if [ "$NEW_COMMIT" != "$COMMIT" ]; then
        echo "[Agent-${AGENT_ID}] 有新提交,推送中..."
        git push origin HEAD:main 2>/dev/null || {
            echo "[Agent-${AGENT_ID}] 推送失败,尝试rebase后重推..."
            git fetch origin main 2>/dev/null && git rebase origin/main 2>/dev/null || true
            git push origin HEAD:main 2>/dev/null || echo "[Agent-${AGENT_ID}] 推送仍失败,跳过"
        }
    else
        echo "[Agent-${AGENT_ID}] 无新提交"
    fi

    # 休息,避免API限流
    echo "[Agent-${AGENT_ID}] 休息 ${SLEEP_INTERVAL}s..."
    sleep "$SLEEP_INTERVAL"
done

echo "[Agent-${AGENT_ID}] 循环结束"
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 323kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 323kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 323kUpdated Claude CodeCodexVerifiedInstall