# auto-tmux scripts `scripts/` 存放 `auto-tmux` 的可执行辅助脚本,把常见 tmux 操作封装成安全、可复用、可审计的命令。 ## 入口 - [`auto-tmux.sh`](./auto-tmux.sh) - 统一命令入口,支持拓扑、读取、发送、巡检、救援、录制、等待和 AI 工作台初始化。 - [`swarm-state.sh`](./swarm-state.sh) - 蜂群状态、任务、锁和报告管理。 - [`swarm-brief.sh`](./swarm-brief.sh) - 只读生成蜂群交接报告,汇总 doctor、topology、pane 输出和状态报告。 - [`swarm-watch.sh`](./swarm-watch.sh) - 有限轮次巡检蜂群 pane 输出和状态报告,形成连续证据。 - [`swarm-archive.sh`](./swarm-archive.sh) - 打包 brief、snapshot 和 swarm state,生成可交接归档。 - [`swarm-board.sh`](./swarm-board.sh) - 将 `tasks.tsv`、依赖、锁和状态日志渲染为 Markdown 看板。 - [`swarm-deps-graph.sh`](./swarm-deps-graph.sh) - 将 `deps.tsv` 渲染为 Mermaid 依赖图。 - [`swarm-export.sh`](./swarm-export.sh) - 将任务、依赖和锁导出为 JSONL 包。 - [`swarm-timeline.sh`](./swarm-timeline.sh) - 将 `status.log` 渲染为 Markdown 时间线。 - [`swarm-blockers.sh`](./swarm-blockers.sh) - 聚合 BLOCKED/FAIL 任务、锁和最近异常状态。 - [`swarm-results.sh`](./swarm-results.sh) - 汇总 DONE/FAIL/BLOCKED worker 结果。 - [`swarm-report-pack.sh`](./swarm-report-pack.sh) - 聚合 board、依赖图、时间线、阻塞清单、分配建议和 JSONL 导出。 - 报告包根目录会生成 `index.md` 和 `manifest.json`,附件目录通过 `--attach` 显式加入。 - [`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 输出和 `metadata.jsonl`。 - [`record-summary.sh`](./record-summary.sh) - 汇总 `record start` 产生的 pane 日志,生成复盘摘要。 - [`check-jsonl.sh`](./check-jsonl.sh) - 轻量检查 JSONL 行和必需字段。 - [`review-checklist.sh`](./review-checklist.sh) - 为 report pack 生成 reviewer 审计清单。 - [`verify-report-pack.sh`](./verify-report-pack.sh) - 统一验证 report pack 的 manifest、JSONL 和审计清单。 - [`incident-report.sh`](./incident-report.sh) - 生成误发送、误广播、远程采集和敏感信息风险复盘模板。 - [`audit-package.sh`](./audit-package.sh) - 检查脚本、参考资料、SKILL 入口和 validator 的索引一致性。 - [`completion.bash`](./completion.bash) - Bash completion,补全 `auto-tmux.sh` 和 `swarm-state.sh` 子命令。 - [`safety-check.sh`](./safety-check.sh) - 发送、粘贴或分发前检查危险命令、敏感信息和过大 payload。 - [`render-swarm-prompt.sh`](./render-swarm-prompt.sh) - commander、worker、reviewer 提示词渲染。 - [`swarm-dispatch.sh`](./swarm-dispatch.sh) - 渲染提示词并可选发送到指定 pane,默认只写文件。 - [`auto-tmux-smoke-test.sh`](./auto-tmux-smoke-test.sh) - 创建临时 tmux 会话,端到端验证脚本能力。 - [`validate-auto-tmux.sh`](./validate-auto-tmux.sh) - 汇总脚本权限、语法、help、文档索引、strict 和 smoke 门禁。 ## 常用命令 ```bash # 查看帮助 skills/auto-tmux/scripts/auto-tmux.sh help # 查看 tmux 拓扑 skills/auto-tmux/scripts/auto-tmux.sh topology skills/auto-tmux/scripts/auto-tmux.sh cleanup --session ai-hub --dry-run # 诊断环境 skills/auto-tmux/scripts/auto-tmux.sh doctor --session ai-hub target="$(tmux list-panes -t ai-hub:worker1 -F '#S:#I.#P' | head -n 1)" # 读取指定 pane 最近 80 行 skills/auto-tmux/scripts/auto-tmux.sh inspect -t "$target" -n 40 skills/auto-tmux/scripts/auto-tmux.sh capture -t "$target" -n 80 # 发送命令并回车 skills/auto-tmux/scripts/safety-check.sh --text "make test" skills/auto-tmux/scripts/auto-tmux.sh send -t "$target" --text "make test" --enter skills/auto-tmux/scripts/safety-check.sh --file /tmp/prompt.md --strict skills/auto-tmux/scripts/auto-tmux.sh paste -t "$target" --file /tmp/prompt.md --enter --dry-run # 扫描某个 session 的错误 skills/auto-tmux/scripts/auto-tmux.sh scan --session ai-hub --pattern "ERROR|Traceback" # 受控广播,先 dry-run skills/auto-tmux/scripts/auto-tmux.sh broadcast --session ai-hub --text "pwd" --enter --dry-run # 生成证据快照 skills/auto-tmux/scripts/auto-tmux.sh snapshot --session ai-hub --dir /tmp/auto-tmux-snapshot # 生成蜂群交接报告 skills/auto-tmux/scripts/swarm-brief.sh --session ai-hub --swarm-dir /tmp/ai_swarm --out /tmp/auto-tmux-brief # 采集 3 轮蜂群巡检证据 skills/auto-tmux/scripts/swarm-watch.sh --session ai-hub --swarm-dir /tmp/ai_swarm --iterations 3 --interval 10 # 打包交接归档 skills/auto-tmux/scripts/swarm-archive.sh --session ai-hub --swarm-dir /tmp/ai_swarm --out /tmp/ai-hub-handoff.tar.gz # 生成任务看板 skills/auto-tmux/scripts/swarm-board.sh --dir /tmp/ai_swarm --out /tmp/ai-swarm-board.md # 生成依赖图 skills/auto-tmux/scripts/swarm-deps-graph.sh --dir /tmp/ai_swarm --out /tmp/ai-swarm-deps.md # 导出机器可读状态包 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 # 汇总 worker 结果 skills/auto-tmux/scripts/swarm-results.sh --dir /tmp/ai_swarm --out /tmp/ai-swarm-results.md skills/auto-tmux/scripts/swarm-results.sh --dir /tmp/ai_swarm --out /tmp/ai-swarm-results.md --jsonl /tmp/ai-swarm-results.jsonl # 生成完整报告包 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 # 生成 worker 分配建议 skills/auto-tmux/scripts/swarm-assign.sh --swarm-dir /tmp/ai_swarm --session ai-hub --out /tmp/ai-swarm-assign.md # 生成蜂群健康报告包 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 # 真实采集后输出 index.md、remote-tmux.txt 和 metadata.jsonl # 汇总 pane 录制日志 skills/auto-tmux/scripts/record-summary.sh --dir /tmp/auto-tmux-records --out /tmp/auto-tmux-record-summary.md # 检查 JSONL 字段 skills/auto-tmux/scripts/check-jsonl.sh /tmp/ai-swarm-results.jsonl --require-key type --require-key id --require-key status # 生成 report pack 审计清单 skills/auto-tmux/scripts/review-checklist.sh --pack /tmp/ai-swarm-report-pack --out /tmp/ai-swarm-report-pack/review-checklist.md skills/auto-tmux/scripts/review-checklist.sh --pack /tmp/ai-swarm-report-pack --strict skills/auto-tmux/scripts/verify-report-pack.sh --pack /tmp/ai-swarm-report-pack # 生成事故复盘模板 skills/auto-tmux/scripts/incident-report.sh --type mis-send --out /tmp/auto-tmux-incident.md # 审计 auto-tmux 包索引一致性 skills/auto-tmux/scripts/audit-package.sh # 启用当前 shell 的补全 source skills/auto-tmux/scripts/completion.bash # 初始化蜂群状态并添加任务 skills/auto-tmux/scripts/swarm-state.sh init --dir /tmp/ai_swarm skills/auto-tmux/scripts/swarm-state.sh task-add --id task-001 --text "检查 README 链接" skills/auto-tmux/scripts/swarm-state.sh task-import --file /tmp/tasks.txt --prefix batch --dir /tmp/ai_swarm skills/auto-tmux/scripts/swarm-state.sh task-depend --id task-002 --blocked-by task-001 --dir /tmp/ai_swarm skills/auto-tmux/scripts/swarm-state.sh task-ready --dir /tmp/ai_swarm skills/auto-tmux/scripts/swarm-state.sh task-next --owner "$target" --dir /tmp/ai_swarm skills/auto-tmux/scripts/swarm-state.sh lock-prune --older-than 3600 --dry-run --dir /tmp/ai_swarm skills/auto-tmux/scripts/swarm-state.sh task-block --id task-001 --owner "$target" --reason "等待输入" --dir /tmp/ai_swarm skills/auto-tmux/scripts/swarm-state.sh task-fail --id task-001 --owner "$target" --reason "测试失败" --dir /tmp/ai_swarm skills/auto-tmux/scripts/swarm-state.sh task-list --status FAIL --dir /tmp/ai_swarm skills/auto-tmux/scripts/swarm-state.sh metrics --dir /tmp/ai_swarm skills/auto-tmux/scripts/swarm-state.sh task-reopen --id task-001 --owner "$target" --reason "重新执行" --dir /tmp/ai_swarm skills/auto-tmux/scripts/swarm-state.sh validate --dir /tmp/ai_swarm skills/auto-tmux/scripts/swarm-state.sh report --dir /tmp/ai_swarm # 端到端自测 skills/auto-tmux/scripts/auto-tmux-smoke-test.sh # auto-tmux 专属质量门禁 skills/auto-tmux/scripts/validate-auto-tmux.sh # 渲染 worker prompt skills/auto-tmux/scripts/render-swarm-prompt.sh worker --target "$target" --task "只运行 make test" # 渲染并预演下发 worker prompt skills/auto-tmux/scripts/swarm-dispatch.sh --role worker --target "$target" --task "只运行 make test" --send --dry-run ``` ## 安全约束 - 默认对捕获输出做密钥脱敏。 - `send` 会先打印目标 pane 最近上下文,再发送按键。 - 危险命令默认拒绝,必须显式 `--force`。 - 长 prompt、文件粘贴和 prompt 下发前先运行 `safety-check.sh`。 - 批量操作必须使用明确的 session/window/pane 目标。 - 批量广播必须先 `--dry-run`,确认目标列表后再真实发送。 - 多 worker 协作时用 `swarm-state.sh lock-acquire` 声明文件、目录或服务锁。