feat: skills - attach evidence to auto-tmux reports

This commit is contained in:
tukuaiai
2026-05-19 13:58:16 +08:00
parent 9e54175449
commit 33a4f01099
6 changed files with 50 additions and 5 deletions
+1
View File
@@ -86,6 +86,7 @@ skills/auto-tmux/scripts/swarm-blockers.sh --dir /tmp/ai_swarm --out /tmp/ai-swa
# 生成完整报告包
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
# 生成 worker 分配建议
skills/auto-tmux/scripts/swarm-assign.sh --swarm-dir /tmp/ai_swarm --session ai-hub --out /tmp/ai-swarm-assign.md
+32 -1
View File
@@ -7,13 +7,14 @@ usage() {
swarm-report-pack: build an auto-tmux swarm report pack
Usage:
swarm-report-pack.sh [--dir DIR] [--session NAME] [--out DIR]
swarm-report-pack.sh [--dir DIR] [--session NAME] [--out DIR] [--attach DIR ...]
Defaults:
--dir AUTO_TMUX_SWARM_DIR or /tmp/ai_swarm
--out /tmp/auto-tmux-report-pack-YYYYmmdd-HHMMSS
This script is read-only for tmux and swarm state. It writes only to --out.
Use --attach to copy explicit external evidence directories into the report pack.
EOF
}
@@ -26,6 +27,7 @@ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
swarm_dir="${AUTO_TMUX_SWARM_DIR:-/tmp/ai_swarm}"
session=""
out_dir="/tmp/auto-tmux-report-pack-$(date +%Y%m%d-%H%M%S)"
attachments=()
while [[ $# -gt 0 ]]; do
case "$1" in
@@ -41,6 +43,10 @@ while [[ $# -gt 0 ]]; do
out_dir="${2:-}"
shift 2
;;
--attach)
attachments+=("${2:-}")
shift 2
;;
-h|--help)
usage
exit 0
@@ -76,6 +82,30 @@ else
run_report "assign" "$script_dir/swarm-assign.sh" --swarm-dir "$swarm_dir" --out "$out_dir/assign.md"
fi
attachment_lines=""
if ((${#attachments[@]} > 0)); then
mkdir -p "$out_dir/attachments"
cat > "$out_dir/attachments.md" <<EOF
# Attachments
EOF
for attachment in "${attachments[@]}"; do
[[ -d "$attachment" ]] || die "attachment is not a directory: $attachment"
name="$(basename "$attachment")"
safe_name="$(printf '%s' "$name" | tr -c 'A-Za-z0-9._-' '_')"
dest="$out_dir/attachments/$safe_name"
suffix=1
while [[ -e "$dest" ]]; do
dest="$out_dir/attachments/${safe_name}_$suffix"
suffix=$((suffix + 1))
done
cp -a "$attachment" "$dest"
rel_path="attachments/$(basename "$dest")"
printf -- '- [%s](./%s)\n' "$attachment" "$rel_path" >> "$out_dir/attachments.md"
attachment_lines+="- [$rel_path](./$rel_path)"$'\n'
done
fi
cat > "$out_dir/index.md" <<EOF
# auto-tmux Swarm Report Pack
@@ -91,6 +121,7 @@ cat > "$out_dir/index.md" <<EOF
- [blockers.md](./blockers.md)
- [assign.md](./assign.md)
- [export/manifest.json](./export/manifest.json)
$(if [[ -n "$attachment_lines" ]]; then printf '%s' "- [attachments.md](./attachments.md)"; fi)
EOF
rm -f /tmp/auto-tmux-report-pack.log
@@ -138,6 +138,16 @@ 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-report-pack help" "$script_dir/swarm-report-pack.sh" --help
run_gate "swarm-report-pack attachment" bash -c '
tmp="$(mktemp -d)"
mkdir -p "$tmp/swarm" "$tmp/remote"
printf "id\ttext\tstatus\towner\tupdated_at\tresult\n" > "$tmp/swarm/tasks.tsv"
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 "remote-tmux.txt" "$tmp/out/attachments/remote/remote-tmux.txt"
rm -rf "$tmp"
' _ "$script_dir/swarm-report-pack.sh"
run_gate "swarm-assign help" "$script_dir/swarm-assign.sh" --help
run_gate "swarm-health help" "$script_dir/swarm-health.sh" --help
run_gate "remote-readonly help" "$script_dir/remote-readonly.sh" --help