diff --git a/skills/auto-tmux/AGENTS.md b/skills/auto-tmux/AGENTS.md index 49e7d3d..51a4c0f 100644 --- a/skills/auto-tmux/AGENTS.md +++ b/skills/auto-tmux/AGENTS.md @@ -22,6 +22,7 @@ skills/auto-tmux/ │ ├── swarm-export.sh │ ├── swarm-timeline.sh │ ├── swarm-blockers.sh +│ ├── swarm-results.sh │ ├── swarm-report-pack.sh │ ├── swarm-assign.sh │ ├── swarm-health.sh @@ -63,6 +64,7 @@ skills/auto-tmux/ - `scripts/swarm-export.sh` 是机器可读导出层,将任务、依赖和锁导出为 JSONL。 - `scripts/swarm-timeline.sh` 是状态时间线层,将 `status.log` 渲染为 Markdown。 - `scripts/swarm-blockers.sh` 是阻塞报告层,聚合 BLOCKED/FAIL、锁和异常状态。 +- `scripts/swarm-results.sh` 是结果收敛层,汇总 DONE/FAIL/BLOCKED worker 结果。 - `scripts/swarm-report-pack.sh` 是报告包层,聚合多个只读报告与 JSONL 导出。 - `scripts/swarm-assign.sh` 是分配建议层,将 ready task 轮询映射到 worker pane。 - `scripts/swarm-health.sh` 是健康检查层,汇总 tmux 和 swarm state 的只读报告包。 @@ -82,4 +84,4 @@ skills/auto-tmux/ - 上游来源:`tools/external/.tmux` 与 `tools/external/tmux`。 - 下游使用:`SKILL.md` 和 `references/` 中的命令示例。 - 验证入口:`skills/auto-skill/scripts/validate-skill.sh skills/auto-tmux --strict`。 -- 脚本验证:`skills/auto-tmux/scripts/validate-auto-tmux.sh`、`bash -n skills/auto-tmux/scripts/auto-tmux.sh`、`bash -n skills/auto-tmux/scripts/swarm-state.sh`、`bash -n skills/auto-tmux/scripts/swarm-brief.sh`、`bash -n skills/auto-tmux/scripts/swarm-watch.sh`、`bash -n skills/auto-tmux/scripts/swarm-archive.sh`、`bash -n skills/auto-tmux/scripts/swarm-board.sh`、`bash -n skills/auto-tmux/scripts/swarm-deps-graph.sh`、`bash -n skills/auto-tmux/scripts/swarm-export.sh`、`bash -n skills/auto-tmux/scripts/swarm-timeline.sh`、`bash -n skills/auto-tmux/scripts/swarm-blockers.sh`、`bash -n skills/auto-tmux/scripts/swarm-report-pack.sh`、`bash -n skills/auto-tmux/scripts/swarm-assign.sh`、`bash -n skills/auto-tmux/scripts/swarm-health.sh`、`bash -n skills/auto-tmux/scripts/remote-readonly.sh`、`bash -n skills/auto-tmux/scripts/record-summary.sh`、`bash -n skills/auto-tmux/scripts/completion.bash`、`bash -n skills/auto-tmux/scripts/safety-check.sh`、`bash -n skills/auto-tmux/scripts/render-swarm-prompt.sh`、`bash -n skills/auto-tmux/scripts/swarm-dispatch.sh`、`skills/auto-tmux/scripts/auto-tmux-smoke-test.sh`。 +- 脚本验证:`skills/auto-tmux/scripts/validate-auto-tmux.sh`、`bash -n skills/auto-tmux/scripts/auto-tmux.sh`、`bash -n skills/auto-tmux/scripts/swarm-state.sh`、`bash -n skills/auto-tmux/scripts/swarm-brief.sh`、`bash -n skills/auto-tmux/scripts/swarm-watch.sh`、`bash -n skills/auto-tmux/scripts/swarm-archive.sh`、`bash -n skills/auto-tmux/scripts/swarm-board.sh`、`bash -n skills/auto-tmux/scripts/swarm-deps-graph.sh`、`bash -n skills/auto-tmux/scripts/swarm-export.sh`、`bash -n skills/auto-tmux/scripts/swarm-timeline.sh`、`bash -n skills/auto-tmux/scripts/swarm-blockers.sh`、`bash -n skills/auto-tmux/scripts/swarm-results.sh`、`bash -n skills/auto-tmux/scripts/swarm-report-pack.sh`、`bash -n skills/auto-tmux/scripts/swarm-assign.sh`、`bash -n skills/auto-tmux/scripts/swarm-health.sh`、`bash -n skills/auto-tmux/scripts/remote-readonly.sh`、`bash -n skills/auto-tmux/scripts/record-summary.sh`、`bash -n skills/auto-tmux/scripts/completion.bash`、`bash -n skills/auto-tmux/scripts/safety-check.sh`、`bash -n skills/auto-tmux/scripts/render-swarm-prompt.sh`、`bash -n skills/auto-tmux/scripts/swarm-dispatch.sh`、`skills/auto-tmux/scripts/auto-tmux-smoke-test.sh`。 diff --git a/skills/auto-tmux/README.md b/skills/auto-tmux/README.md index 84fb8f0..ad545b9 100644 --- a/skills/auto-tmux/README.md +++ b/skills/auto-tmux/README.md @@ -29,6 +29,7 @@ bash -n skills/auto-tmux/scripts/swarm-deps-graph.sh bash -n skills/auto-tmux/scripts/swarm-export.sh bash -n skills/auto-tmux/scripts/swarm-timeline.sh bash -n skills/auto-tmux/scripts/swarm-blockers.sh +bash -n skills/auto-tmux/scripts/swarm-results.sh bash -n skills/auto-tmux/scripts/swarm-report-pack.sh bash -n skills/auto-tmux/scripts/swarm-assign.sh bash -n skills/auto-tmux/scripts/swarm-health.sh diff --git a/skills/auto-tmux/SKILL.md b/skills/auto-tmux/SKILL.md index 844f95d..4a87e52 100644 --- a/skills/auto-tmux/SKILL.md +++ b/skills/auto-tmux/SKILL.md @@ -43,6 +43,7 @@ bash -n skills/auto-tmux/scripts/swarm-deps-graph.sh bash -n skills/auto-tmux/scripts/swarm-export.sh bash -n skills/auto-tmux/scripts/swarm-timeline.sh bash -n skills/auto-tmux/scripts/swarm-blockers.sh +bash -n skills/auto-tmux/scripts/swarm-results.sh bash -n skills/auto-tmux/scripts/swarm-report-pack.sh bash -n skills/auto-tmux/scripts/swarm-assign.sh bash -n skills/auto-tmux/scripts/swarm-health.sh @@ -133,6 +134,7 @@ skills/auto-tmux/scripts/swarm-deps-graph.sh --dir /tmp/ai_swarm --out /tmp/ai-s skills/auto-tmux/scripts/swarm-export.sh --dir /tmp/ai_swarm --out /tmp/ai-swarm-export skills/auto-tmux/scripts/swarm-timeline.sh --dir /tmp/ai_swarm --out /tmp/ai-swarm-timeline.md skills/auto-tmux/scripts/swarm-blockers.sh --dir /tmp/ai_swarm --out /tmp/ai-swarm-blockers.md +skills/auto-tmux/scripts/swarm-results.sh --dir /tmp/ai_swarm --out /tmp/ai-swarm-results.md skills/auto-tmux/scripts/swarm-report-pack.sh --dir /tmp/ai_swarm --session ai-hub --out /tmp/ai-swarm-report-pack skills/auto-tmux/scripts/swarm-report-pack.sh --dir /tmp/ai_swarm --out /tmp/ai-swarm-report-pack --attach /tmp/auto-tmux-remote skills/auto-tmux/scripts/swarm-report-pack.sh --dir /tmp/ai_swarm --out /tmp/ai-swarm-report-pack --tar @@ -290,6 +292,7 @@ skills/auto-tmux/scripts/swarm-dispatch.sh --role worker --target :: "$out_dir/manifest.json" < "$out_dir/index.md" <&2 + exit 1 +} + +swarm_dir="${AUTO_TMUX_SWARM_DIR:-/tmp/ai_swarm}" +out_file="" +limit=80 + +while [[ $# -gt 0 ]]; do + case "$1" in + --dir|--swarm-dir) + swarm_dir="${2:-}" + shift 2 + ;; + --out) + out_file="${2:-}" + shift 2 + ;; + --limit) + limit="${2:-}" + shift 2 + ;; + -h|--help) + usage + exit 0 + ;; + *) + die "unknown option: $1" + ;; + esac +done + +[[ "$limit" =~ ^[0-9]+$ ]] || die "--limit must be a number" + +tasks_tsv="$swarm_dir/tasks.tsv" +results_dir="$swarm_dir/results" +status_log="$swarm_dir/status.log" +[[ -f "$tasks_tsv" ]] || die "tasks file not found: $tasks_tsv" + +render_results() { + printf '# auto-tmux Swarm Results\n\n' + printf -- '- dir: `%s`\n' "$swarm_dir" + printf -- '- created_at: `%s`\n\n' "$(date -Is)" + + printf '## Summary\n\n' + awk -F '\t' ' + NR > 1 {count[$2]++} + END { + print "| status | count |" + print "|:---|---:|" + n = split("DONE FAIL BLOCKED DOING TODO", order, " ") + for (i = 1; i <= n; i++) { + status = order[i] + print "| `" status "` | " (count[status] + 0) " |" + } + } + ' "$tasks_tsv" + + printf '\n## Terminal Results\n\n' + printf '| status | id | owner | text | result |\n' + printf '|:---|:---|:---|:---|:---|\n' + awk -F '\t' -v limit="$limit" ' + function esc(value) { + gsub(/\|/, "\\|", value) + return value + } + NR > 1 && ($2 == "DONE" || $2 == "FAIL" || $2 == "BLOCKED") { + print "| `" esc($2) "` | `" esc($1) "` | `" esc($3) "` | " esc($4) " | " esc($5) " |" + shown++ + if (shown >= limit) exit + } + END {if (shown == 0) print "| - | - | - | - | - |"} + ' "$tasks_tsv" + + printf '\n## Result Files\n\n' + if [[ -d "$results_dir" ]] && find "$results_dir" -mindepth 1 -maxdepth 1 -type f -name '*.txt' -print -quit | grep -q .; then + find "$results_dir" -mindepth 1 -maxdepth 1 -type f -name '*.txt' -print | sort | while read -r path; do + printf -- '- `%s`: %s\n' "$(basename "$path")" "$(head -n 1 "$path")" + done + else + printf -- '- no result files\n' + fi + + printf '\n## Recent Terminal Status\n\n' + if [[ -s "$status_log" ]]; then + tail -n 30 "$status_log" | grep -E '\[(DONE|FAIL|BLOCKED)\]' | sed 's/^/- /' || printf -- '- no recent terminal status\n' + else + printf -- '- no status log\n' + fi +} + +if [[ -n "$out_file" ]]; then + mkdir -p "$(dirname "$out_file")" + render_results > "$out_file" + printf 'swarm results written: %s\n' "$out_file" +else + render_results +fi diff --git a/skills/auto-tmux/scripts/validate-auto-tmux.sh b/skills/auto-tmux/scripts/validate-auto-tmux.sh index bfccda4..7a60637 100755 --- a/skills/auto-tmux/scripts/validate-auto-tmux.sh +++ b/skills/auto-tmux/scripts/validate-auto-tmux.sh @@ -108,6 +108,7 @@ scripts=( "$script_dir/swarm-export.sh" "$script_dir/swarm-timeline.sh" "$script_dir/swarm-blockers.sh" + "$script_dir/swarm-results.sh" "$script_dir/swarm-report-pack.sh" "$script_dir/swarm-assign.sh" "$script_dir/swarm-health.sh" @@ -137,6 +138,7 @@ run_gate "swarm-deps-graph help" "$script_dir/swarm-deps-graph.sh" --help run_gate "swarm-export help" "$script_dir/swarm-export.sh" --help run_gate "swarm-timeline help" "$script_dir/swarm-timeline.sh" --help run_gate "swarm-blockers help" "$script_dir/swarm-blockers.sh" --help +run_gate "swarm-results help" "$script_dir/swarm-results.sh" --help run_gate "swarm-report-pack help" "$script_dir/swarm-report-pack.sh" --help run_gate "swarm-report-pack attachment" bash -c ' tmp="$(mktemp -d)" @@ -145,6 +147,7 @@ run_gate "swarm-report-pack attachment" bash -c ' printf "remote evidence\n" > "$tmp/remote/remote-tmux.txt" "$1" --dir "$tmp/swarm" --out "$tmp/out" --attach "$tmp/remote" >/dev/null grep -Fq "attachments.md" "$tmp/out/index.md" + grep -Fq "results.md" "$tmp/out/index.md" grep -Fq "manifest.json" "$tmp/out/index.md" grep -Fq "\"type\": \"auto-tmux-swarm-report-pack\"" "$tmp/out/manifest.json" grep -Fq "\"attachments\"" "$tmp/out/manifest.json" @@ -178,6 +181,7 @@ require_contains "$skill_dir/SKILL.md" "scripts/swarm-deps-graph.sh" require_contains "$skill_dir/SKILL.md" "scripts/swarm-export.sh" require_contains "$skill_dir/SKILL.md" "scripts/swarm-timeline.sh" require_contains "$skill_dir/SKILL.md" "scripts/swarm-blockers.sh" +require_contains "$skill_dir/SKILL.md" "scripts/swarm-results.sh" require_contains "$skill_dir/SKILL.md" "scripts/swarm-report-pack.sh" require_contains "$skill_dir/SKILL.md" "scripts/swarm-assign.sh" require_contains "$skill_dir/SKILL.md" "scripts/swarm-health.sh" @@ -204,6 +208,7 @@ require_contains "$script_dir/README.md" "swarm-deps-graph.sh" require_contains "$script_dir/README.md" "swarm-export.sh" require_contains "$script_dir/README.md" "swarm-timeline.sh" require_contains "$script_dir/README.md" "swarm-blockers.sh" +require_contains "$script_dir/README.md" "swarm-results.sh" require_contains "$script_dir/README.md" "swarm-report-pack.sh" require_contains "$script_dir/README.md" "swarm-assign.sh" require_contains "$script_dir/README.md" "swarm-health.sh" @@ -221,6 +226,7 @@ require_contains "$script_dir/AGENTS.md" "swarm-deps-graph.sh" require_contains "$script_dir/AGENTS.md" "swarm-export.sh" require_contains "$script_dir/AGENTS.md" "swarm-timeline.sh" require_contains "$script_dir/AGENTS.md" "swarm-blockers.sh" +require_contains "$script_dir/AGENTS.md" "swarm-results.sh" require_contains "$script_dir/AGENTS.md" "swarm-report-pack.sh" require_contains "$script_dir/AGENTS.md" "swarm-assign.sh" require_contains "$script_dir/AGENTS.md" "swarm-health.sh"