mirror of
https://github.com/tradecatlabs/vibe-coding-cn.git
synced 2026-08-20 22:38:04 +00:00
feat: skills - collect remote auto-tmux evidence
This commit is contained in:
@@ -21,6 +21,7 @@ scripts/
|
||||
├── swarm-report-pack.sh # 聚合只读报告包
|
||||
├── swarm-assign.sh # 生成 ready task 到 worker pane 的分配建议
|
||||
├── swarm-health.sh # 汇总只读健康检查报告包
|
||||
├── remote-readonly.sh # SSH 只读采集远端 tmux 证据
|
||||
├── record-summary.sh # 汇总 pipe-pane 录制日志
|
||||
├── completion.bash # Bash completion
|
||||
├── safety-check.sh # 发送/粘贴/分发前的 payload 安全预检
|
||||
@@ -50,6 +51,7 @@ scripts/
|
||||
- 报告包脚本只编排只读脚本并写入显式输出目录,不 claim 任务、不发送 prompt。
|
||||
- 分配建议脚本只读任务和 pane 拓扑,不 claim 任务、不发送 prompt。
|
||||
- 健康检查脚本只读 tmux 与 swarm state,失败项写入报告,不做自动修复。
|
||||
- 远端脚本只能运行 tmux list/capture 等只读命令,不允许 send-keys、kill 或配置写入。
|
||||
- 录制摘要脚本只读 record 日志,输出默认脱敏,不修改日志源文件。
|
||||
- completion 文件只能定义 shell completion,不执行 tmux 写操作。
|
||||
- 安全预检脚本只能读取文本或文件,不控制 tmux,不写状态目录。
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
- [`swarm-report-pack.sh`](./swarm-report-pack.sh) - 聚合 board、依赖图、时间线、阻塞清单、分配建议和 JSONL 导出。
|
||||
- [`swarm-assign.sh`](./swarm-assign.sh) - 根据 ready tasks 和 worker pane 生成只读分配建议。
|
||||
- [`swarm-health.sh`](./swarm-health.sh) - 汇总 doctor、topology、scan、validate、metrics、board 和 assign。
|
||||
- [`remote-readonly.sh`](./remote-readonly.sh) - 通过 SSH 只读采集远端 tmux 拓扑和 pane 输出。
|
||||
- [`record-summary.sh`](./record-summary.sh) - 汇总 `record start` 产生的 pane 日志,生成复盘摘要。
|
||||
- [`completion.bash`](./completion.bash) - Bash completion,补全 `auto-tmux.sh` 和 `swarm-state.sh` 子命令。
|
||||
- [`safety-check.sh`](./safety-check.sh) - 发送、粘贴或分发前检查危险命令、敏感信息和过大 payload。
|
||||
@@ -92,6 +93,9 @@ skills/auto-tmux/scripts/swarm-assign.sh --swarm-dir /tmp/ai_swarm --session ai-
|
||||
# 生成蜂群健康报告包
|
||||
skills/auto-tmux/scripts/swarm-health.sh --session ai-hub --swarm-dir /tmp/ai_swarm --out /tmp/auto-tmux-health
|
||||
|
||||
# 只读采集远端 tmux 证据
|
||||
skills/auto-tmux/scripts/remote-readonly.sh --host user@example.com --session ai-hub --out /tmp/auto-tmux-remote --dry-run
|
||||
|
||||
# 汇总 pane 录制日志
|
||||
skills/auto-tmux/scripts/record-summary.sh --dir /tmp/auto-tmux-records --out /tmp/auto-tmux-record-summary.md
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ SWARM_BLOCKERS="$SCRIPT_DIR/swarm-blockers.sh"
|
||||
SWARM_REPORT_PACK="$SCRIPT_DIR/swarm-report-pack.sh"
|
||||
SWARM_ASSIGN="$SCRIPT_DIR/swarm-assign.sh"
|
||||
SWARM_HEALTH="$SCRIPT_DIR/swarm-health.sh"
|
||||
REMOTE_READONLY="$SCRIPT_DIR/remote-readonly.sh"
|
||||
RECORD_SUMMARY="$SCRIPT_DIR/record-summary.sh"
|
||||
COMPLETION="$SCRIPT_DIR/completion.bash"
|
||||
SAFETY_CHECK="$SCRIPT_DIR/safety-check.sh"
|
||||
@@ -67,6 +68,7 @@ bash -n "$SWARM_BLOCKERS"
|
||||
bash -n "$SWARM_REPORT_PACK"
|
||||
bash -n "$SWARM_ASSIGN"
|
||||
bash -n "$SWARM_HEALTH"
|
||||
bash -n "$REMOTE_READONLY"
|
||||
bash -n "$RECORD_SUMMARY"
|
||||
bash -n "$COMPLETION"
|
||||
bash -n "$SAFETY_CHECK"
|
||||
@@ -187,6 +189,8 @@ grep -q 'swarm-dispatch.sh' "$ASSIGN_FILE"
|
||||
grep -q 'auto-tmux Swarm Health' "$HEALTH_DIR/index.md"
|
||||
test -s "$HEALTH_DIR/state-validate.txt"
|
||||
test -s "$HEALTH_DIR/board.md"
|
||||
"$REMOTE_READONLY" --host example.com --session "$SESSION" --dry-run >/tmp/auto-tmux-smoke-remote-readonly.txt
|
||||
grep -q 'example.com' /tmp/auto-tmux-smoke-remote-readonly.txt
|
||||
"$RENDER_PROMPT" commander --session "$SESSION" --swarm-dir "$SWARM_DIR" --task "smoke" >/tmp/auto-tmux-smoke-commander-prompt.md
|
||||
"$RENDER_PROMPT" worker --session "$SESSION" --target "$worker_target" --swarm-dir "$SWARM_DIR" --task "smoke" >/tmp/auto-tmux-smoke-worker-prompt.md
|
||||
"$SWARM_DISPATCH" --role worker --target "$worker_target" --session "$SESSION" --swarm-dir "$SWARM_DIR" --task "smoke" --out "$DISPATCH_PROMPT" >/tmp/auto-tmux-smoke-dispatch-render.txt
|
||||
|
||||
@@ -153,7 +153,7 @@ cmd_doctor() {
|
||||
status_line "WARN" "tmux server has no reachable session yet"
|
||||
fi
|
||||
|
||||
for script in auto-tmux.sh swarm-state.sh swarm-brief.sh swarm-watch.sh swarm-archive.sh swarm-board.sh swarm-deps-graph.sh swarm-export.sh swarm-timeline.sh swarm-blockers.sh swarm-report-pack.sh swarm-assign.sh swarm-health.sh record-summary.sh safety-check.sh render-swarm-prompt.sh swarm-dispatch.sh auto-tmux-smoke-test.sh validate-auto-tmux.sh; do
|
||||
for script in auto-tmux.sh swarm-state.sh swarm-brief.sh swarm-watch.sh swarm-archive.sh swarm-board.sh swarm-deps-graph.sh swarm-export.sh swarm-timeline.sh swarm-blockers.sh swarm-report-pack.sh swarm-assign.sh swarm-health.sh remote-readonly.sh record-summary.sh safety-check.sh render-swarm-prompt.sh swarm-dispatch.sh auto-tmux-smoke-test.sh validate-auto-tmux.sh; do
|
||||
if [[ -x "$script_dir/$script" ]]; then
|
||||
status_line "OK" "script executable: $script"
|
||||
else
|
||||
|
||||
Executable
+120
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env bash
|
||||
# remote-readonly: collect read-only tmux evidence over SSH.
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
remote-readonly: collect read-only tmux topology/capture evidence over SSH
|
||||
|
||||
Usage:
|
||||
remote-readonly.sh --host HOST [--session NAME] [--out DIR] [-n LINES] [--dry-run]
|
||||
|
||||
Defaults:
|
||||
--out /tmp/auto-tmux-remote-YYYYmmdd-HHMMSS
|
||||
-n 80 capture lines per pane
|
||||
|
||||
This script is read-only. It runs tmux list/capture commands on the remote host.
|
||||
It never sends keys and never mutates remote tmux state.
|
||||
EOF
|
||||
}
|
||||
|
||||
die() {
|
||||
printf 'error: %s\n' "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
host=""
|
||||
session=""
|
||||
out_dir="/tmp/auto-tmux-remote-$(date +%Y%m%d-%H%M%S)"
|
||||
lines=80
|
||||
dry_run="0"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--host)
|
||||
host="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--session)
|
||||
session="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--out)
|
||||
out_dir="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
-n|--lines)
|
||||
lines="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--dry-run)
|
||||
dry_run="1"
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
die "unknown option: $1"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[[ -n "$host" ]] || die "missing --host"
|
||||
[[ "$lines" =~ ^[0-9]+$ ]] || die "--lines must be a number"
|
||||
|
||||
redact() {
|
||||
sed -E \
|
||||
-e 's/(OPENAI_API_KEY|ANTHROPIC_API_KEY|GITHUB_TOKEN|GH_TOKEN|API_KEY|TOKEN|PASSWORD|SECRET)=([^[:space:]]+)/\1=<redacted>/g' \
|
||||
-e 's/(Bearer[[:space:]]+)[A-Za-z0-9._~+\/=-]+/\1<redacted>/g' \
|
||||
-e 's/(sk-[A-Za-z0-9_-]{12,})/<redacted-openai-key>/g'
|
||||
}
|
||||
|
||||
remote_script='
|
||||
set -e
|
||||
session_filter="$1"
|
||||
lines="$2"
|
||||
if ! command -v tmux >/dev/null 2>&1; then
|
||||
echo "tmux not found" >&2
|
||||
exit 2
|
||||
fi
|
||||
if [ -n "$session_filter" ]; then
|
||||
tmux has-session -t "$session_filter"
|
||||
tmux list-windows -t "$session_filter" -F "window #S:#{window_index}: #{window_name} #{window_flags}"
|
||||
tmux list-panes -t "$session_filter" -F "#S:#{window_index}.#{pane_index}" |
|
||||
while read -r pane; do
|
||||
echo "===== [$pane] ====="
|
||||
tmux capture-pane -t "$pane" -p -S "-$lines"
|
||||
done
|
||||
else
|
||||
tmux list-sessions -F "session: #{session_name} windows=#{session_windows} attached=#{session_attached}"
|
||||
tmux list-panes -a -F "#S:#{window_index}.#{pane_index}" |
|
||||
while read -r pane; do
|
||||
echo "===== [$pane] ====="
|
||||
tmux capture-pane -t "$pane" -p -S "-$lines"
|
||||
done
|
||||
fi
|
||||
'
|
||||
|
||||
if [[ "$dry_run" == "1" ]]; then
|
||||
printf 'ssh %q %q -- %q %q\n' "$host" "bash -s" "$session" "$lines"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mkdir -p "$out_dir"
|
||||
ssh "$host" "bash -s" -- "$session" "$lines" <<EOF | redact > "$out_dir/remote-tmux.txt"
|
||||
$remote_script
|
||||
EOF
|
||||
|
||||
cat > "$out_dir/index.md" <<EOF
|
||||
# auto-tmux Remote Readonly
|
||||
|
||||
- created_at: \`$(date -Is)\`
|
||||
- host: \`$host\`
|
||||
- session: \`${session:-<all>}\`
|
||||
- lines: \`$lines\`
|
||||
- evidence: [remote-tmux.txt](./remote-tmux.txt)
|
||||
EOF
|
||||
|
||||
printf 'remote readonly evidence written: %s\n' "$out_dir"
|
||||
@@ -90,6 +90,7 @@ scripts=(
|
||||
"$script_dir/swarm-report-pack.sh"
|
||||
"$script_dir/swarm-assign.sh"
|
||||
"$script_dir/swarm-health.sh"
|
||||
"$script_dir/remote-readonly.sh"
|
||||
"$script_dir/record-summary.sh"
|
||||
"$script_dir/safety-check.sh"
|
||||
"$script_dir/render-swarm-prompt.sh"
|
||||
@@ -118,6 +119,8 @@ 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-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
|
||||
run_gate "remote-readonly dry-run" "$script_dir/remote-readonly.sh" --host example.com --dry-run
|
||||
run_gate "record-summary help" "$script_dir/record-summary.sh" --help
|
||||
run_gate "safety-check help" "$script_dir/safety-check.sh" --help
|
||||
run_gate "safety-check clean text" "$script_dir/safety-check.sh" --text "make test"
|
||||
@@ -141,6 +144,7 @@ require_contains "$skill_dir/SKILL.md" "scripts/swarm-blockers.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"
|
||||
require_contains "$skill_dir/SKILL.md" "scripts/remote-readonly.sh"
|
||||
require_contains "$skill_dir/SKILL.md" "scripts/record-summary.sh"
|
||||
require_contains "$skill_dir/SKILL.md" "scripts/completion.bash"
|
||||
require_contains "$skill_dir/SKILL.md" "scripts/safety-check.sh"
|
||||
@@ -161,6 +165,7 @@ require_contains "$script_dir/README.md" "swarm-blockers.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"
|
||||
require_contains "$script_dir/README.md" "remote-readonly.sh"
|
||||
require_contains "$script_dir/README.md" "record-summary.sh"
|
||||
require_contains "$script_dir/README.md" "completion.bash"
|
||||
require_contains "$script_dir/README.md" "safety-check.sh"
|
||||
@@ -176,6 +181,7 @@ require_contains "$script_dir/AGENTS.md" "swarm-blockers.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"
|
||||
require_contains "$script_dir/AGENTS.md" "remote-readonly.sh"
|
||||
require_contains "$script_dir/AGENTS.md" "record-summary.sh"
|
||||
require_contains "$script_dir/AGENTS.md" "completion.bash"
|
||||
require_contains "$script_dir/AGENTS.md" "safety-check.sh"
|
||||
|
||||
Reference in New Issue
Block a user