feat: skills - gate auto-tmux jsonl fields

This commit is contained in:
tukuaiai
2026-05-19 14:15:08 +08:00
parent dfeb3762dc
commit 25b072ad26
10 changed files with 99 additions and 6 deletions
+3 -1
View File
@@ -28,6 +28,7 @@ skills/auto-tmux/
│ ├── swarm-health.sh
│ ├── remote-readonly.sh
│ ├── record-summary.sh
│ ├── check-jsonl.sh
│ ├── completion.bash
│ ├── safety-check.sh
│ ├── render-swarm-prompt.sh
@@ -70,6 +71,7 @@ skills/auto-tmux/
- `scripts/swarm-health.sh` 是健康检查层,汇总 tmux 和 swarm state 的只读报告包。
- `scripts/remote-readonly.sh` 是远端只读层,通过 SSH 采集 tmux 拓扑和输出证据。
- `scripts/record-summary.sh` 是复盘摘要层,将 pane 录制日志整理为 Markdown。
- `scripts/check-jsonl.sh` 是轻量 JSONL 字段门禁层,不替代完整 JSON parser。
- `scripts/completion.bash` 是本地补全层,补全 `auto-tmux.sh``swarm-state.sh`
- `scripts/safety-check.sh` 是安全预检层,检查待发送 payload 的危险命令、敏感信息和大小。
- `scripts/render-swarm-prompt.sh` 是提示词渲染层,生成 commander/worker/reviewer 协议文本。
@@ -84,4 +86,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-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`
- 脚本验证:`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/check-jsonl.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`
+1
View File
@@ -35,6 +35,7 @@ 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/check-jsonl.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
+4 -1
View File
@@ -49,6 +49,7 @@ 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/check-jsonl.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
@@ -170,6 +171,7 @@ cp -n "$repo_root/skills/auto-tmux/assets/oh-my-tmux/.tmux.conf.local" ~/.tmux.c
skills/auto-tmux/scripts/auto-tmux.sh record start -t <session>:<window>.<pane> --dir /tmp/auto-tmux-records
skills/auto-tmux/scripts/auto-tmux.sh record stop -t <session>:<window>.<pane>
skills/auto-tmux/scripts/record-summary.sh --dir /tmp/auto-tmux-records --out /tmp/auto-tmux-record-summary.md
skills/auto-tmux/scripts/check-jsonl.sh /tmp/ai-swarm-results.jsonl --require-key type --require-key id --require-key status
```
**等待 pane 出现完成信号**
@@ -299,6 +301,7 @@ skills/auto-tmux/scripts/swarm-dispatch.sh --role worker --target <session>:<win
- `scripts/swarm-health.sh`: 汇总 tmux 与 swarm state 的只读健康检查报告包
- `scripts/remote-readonly.sh`: 通过 SSH 只读采集远端 tmux 拓扑、pane 输出和 `metadata.jsonl`
- `scripts/record-summary.sh`: 汇总 pane 录制日志并生成复盘摘要
- `scripts/check-jsonl.sh`: 轻量检查 JSONL 行和必需字段
- `scripts/completion.bash`: Bash completion,补全 `auto-tmux.sh``swarm-state.sh`
- `scripts/safety-check.sh`: 发送/粘贴/分发前检查危险命令、敏感信息和过大 payload
- `scripts/render-swarm-prompt.sh`: commander/worker/reviewer 提示词渲染脚本
@@ -323,6 +326,6 @@ skills/auto-tmux/scripts/swarm-dispatch.sh --role worker --target <session>:<win
4. ≥3 个端到端示例,含输入/步骤/验收。
5. 长文档放在 `references/` 并可导航;无文档堆砌。
6. 不确定项给出验证路径;禁止虚构 tmux 行为。
7. `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``bash -n skills/auto-tmux/scripts/validate-auto-tmux.sh` 通过。
7. `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/check-jsonl.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``bash -n skills/auto-tmux/scripts/validate-auto-tmux.sh` 通过。
8. `skills/auto-tmux/scripts/auto-tmux-smoke-test.sh` 通过或在无 tmux 环境下明确跳过。
9. 运行 `skills/auto-tmux/scripts/validate-auto-tmux.sh``skills/auto-skill/scripts/validate-skill.sh skills/auto-tmux --strict` 通过。
@@ -45,6 +45,7 @@
| `swarm-health.sh` | 汇总 tmux 与 swarm state 健康报告 | 只读,不自动修复 |
| `remote-readonly.sh` | SSH 只读采集远端 tmux 证据 | 不发送按键,输出默认脱敏,生成 `metadata.jsonl` |
| `record-summary.sh` | 汇总 pane 录制日志 | 只读,输出默认脱敏 |
| `check-jsonl.sh` | 轻量检查 JSONL 行和必需字段 | 无 jq 依赖,不替代完整 JSON parser |
| `completion.bash` | Bash 子命令和常用参数补全 | 只定义 shell completion |
| `swarm-dispatch.sh` | 渲染并可选下发提示词 | 默认只写文件,发送需 `--send` |
| `validate-auto-tmux.sh` | 执行技能专属质量门禁 | 覆盖脚本、文档索引、strict 和 smoke |
@@ -197,6 +198,7 @@ skills/auto-tmux/scripts/auto-tmux.sh record start -t "$target" --dir /tmp/auto-
target="$(tmux list-panes -t ai-hub:worker1 -F '#S:#I.#P' | head -n 1)"
skills/auto-tmux/scripts/auto-tmux.sh record stop -t "$target"
skills/auto-tmux/scripts/record-summary.sh --dir /tmp/auto-tmux-records --out /tmp/auto-tmux-record-summary.md
skills/auto-tmux/scripts/check-jsonl.sh /tmp/ai-swarm-results.jsonl --require-key type --require-key id --require-key status
```
## AI 蜂群协作建议
@@ -288,6 +290,7 @@ 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/check-jsonl.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
@@ -43,13 +43,14 @@
| 35 | `7a2ff13` | 报告包 manifest | `swarm-report-pack.sh` 输出根级 `manifest.json` |
| 36 | `9eac52f` | 报告包压缩 | `swarm-report-pack.sh --tar` |
| 37 | `ab6d8f2` | worker 结果收敛 | `swarm-results.sh` |
| 38 | `本轮` | 结果摘要导出 | `swarm-results.sh --jsonl` |
| 38 | `3b10fb6` | 结果摘要导出 | `swarm-results.sh --jsonl` |
| 39 | `本轮` | JSONL 字段门禁 | `check-jsonl.sh` |
## 后续候选方向
| 优先级 | 方向 | 说明 |
|:---|:---|:---|
| P3 | 结果摘要校验 | 对 `swarm-results.sh` 输出做 schema-like 字段检查 |
| P3 | JSONL 格式治理 | 将 remote metadata 和 swarm results 的字段约定写入 reference |
## 每轮验收清单
+2
View File
@@ -24,6 +24,7 @@ scripts/
├── swarm-health.sh # 汇总只读健康检查报告包
├── remote-readonly.sh # SSH 只读采集远端 tmux 证据
├── record-summary.sh # 汇总 pipe-pane 录制日志
├── check-jsonl.sh # 轻量 JSONL 字段门禁
├── completion.bash # Bash completion
├── safety-check.sh # 发送/粘贴/分发前的 payload 安全预检
├── render-swarm-prompt.sh # commander/worker/reviewer 提示词渲染
@@ -55,6 +56,7 @@ scripts/
- 健康检查脚本只读 tmux 与 swarm state,失败项写入报告,不做自动修复。
- 远端脚本只能运行 tmux list/capture 等只读命令,不允许 send-keys、kill 或配置写入。
- 录制摘要脚本只读 record 日志,输出默认脱敏,不修改日志源文件。
- JSONL 检查脚本只能做轻量字段门禁,不替代完整 JSON parser。
- completion 文件只能定义 shell completion,不执行 tmux 写操作。
- 安全预检脚本只能读取文本或文件,不控制 tmux,不写状态目录。
- 状态脚本只能写入显式状态目录,不保存密钥、Token、密码或私密项目内容。
+4
View File
@@ -21,6 +21,7 @@
- [`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 行和必需字段。
- [`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 提示词渲染。
@@ -108,6 +109,9 @@ skills/auto-tmux/scripts/remote-readonly.sh --host user@example.com --session ai
# 汇总 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
# 启用当前 shell 的补全
source skills/auto-tmux/scripts/completion.bash
+1 -1
View File
@@ -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-results.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
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-results.sh swarm-report-pack.sh swarm-assign.sh swarm-health.sh remote-readonly.sh record-summary.sh check-jsonl.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
+65
View File
@@ -0,0 +1,65 @@
#!/usr/bin/env bash
# check-jsonl: lightweight JSONL field gate without jq dependency.
set -euo pipefail
usage() {
cat <<'EOF'
check-jsonl: validate JSONL-like lines contain required fields
Usage:
check-jsonl.sh FILE [--require-key KEY ...]
Defaults:
Requires no fixed keys unless --require-key is provided.
This is a lightweight gate: it checks non-empty lines look like JSON objects and
contain required top-level key names. It does not replace a full JSON parser.
EOF
}
die() {
printf 'error: %s\n' "$*" >&2
exit 1
}
file=""
required_keys=()
while [[ $# -gt 0 ]]; do
case "$1" in
--require-key)
required_keys+=("${2:-}")
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
if [[ -z "$file" ]]; then
file="$1"
shift
else
die "unknown option: $1"
fi
;;
esac
done
[[ -n "$file" ]] || die "missing FILE"
[[ -f "$file" ]] || die "file not found: $file"
line_no=0
checked=0
while IFS= read -r line || [[ -n "$line" ]]; do
line_no=$((line_no + 1))
[[ -n "$line" ]] || continue
[[ "$line" =~ ^\{.*\}$ ]] || die "line $line_no is not a JSON object"
for key in "${required_keys[@]}"; do
[[ "$line" == *"\"$key\""* ]] || die "line $line_no missing key: $key"
done
checked=$((checked + 1))
done < "$file"
((checked > 0)) || die "no JSONL records found"
printf 'jsonl ok: %s records=%s\n' "$file" "$checked"
+13 -1
View File
@@ -114,6 +114,7 @@ scripts=(
"$script_dir/swarm-health.sh"
"$script_dir/remote-readonly.sh"
"$script_dir/record-summary.sh"
"$script_dir/check-jsonl.sh"
"$script_dir/safety-check.sh"
"$script_dir/render-swarm-prompt.sh"
"$script_dir/swarm-dispatch.sh"
@@ -148,8 +149,9 @@ run_gate "swarm-results jsonl" bash -c '
"$1" --dir "$tmp/swarm" --out "$tmp/results.md" --jsonl "$tmp/results.jsonl" >/dev/null
grep -Fq "t1" "$tmp/results.md"
grep -Fq "\"type\":\"swarm-result\"" "$tmp/results.jsonl"
"$2" "$tmp/results.jsonl" --require-key type --require-key id --require-key status >/dev/null
rm -rf "$tmp"
' _ "$script_dir/swarm-results.sh"
' _ "$script_dir/swarm-results.sh" "$script_dir/check-jsonl.sh"
run_gate "swarm-report-pack help" "$script_dir/swarm-report-pack.sh" --help
run_gate "swarm-report-pack attachment" bash -c '
tmp="$(mktemp -d)"
@@ -174,6 +176,13 @@ 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 "remote-readonly package with fake ssh" test_remote_readonly_package
run_gate "record-summary help" "$script_dir/record-summary.sh" --help
run_gate "check-jsonl help" "$script_dir/check-jsonl.sh" --help
run_gate "check-jsonl required keys" bash -c '
tmp="$(mktemp)"
printf "{\"type\":\"swarm-result\",\"id\":\"t1\",\"status\":\"DONE\"}\n" > "$tmp"
"$1" "$tmp" --require-key type --require-key id --require-key status >/dev/null
rm -f "$tmp"
' _ "$script_dir/check-jsonl.sh"
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"
if "$script_dir/safety-check.sh" --text "rm -rf /tmp/example" >/tmp/auto-tmux-validate-gate.log 2>&1; then
@@ -199,6 +208,7 @@ 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/check-jsonl.sh"
require_contains "$skill_dir/SKILL.md" "scripts/completion.bash"
require_contains "$skill_dir/SKILL.md" "scripts/safety-check.sh"
require_contains "$skill_dir/SKILL.md" "scripts/swarm-dispatch.sh"
@@ -227,6 +237,7 @@ require_contains "$script_dir/README.md" "swarm-health.sh"
require_contains "$script_dir/README.md" "remote-readonly.sh"
require_contains "$script_dir/README.md" "metadata.jsonl"
require_contains "$script_dir/README.md" "record-summary.sh"
require_contains "$script_dir/README.md" "check-jsonl.sh"
require_contains "$script_dir/README.md" "completion.bash"
require_contains "$script_dir/README.md" "safety-check.sh"
require_contains "$script_dir/AGENTS.md" "validate-auto-tmux.sh"
@@ -244,6 +255,7 @@ 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" "check-jsonl.sh"
require_contains "$script_dir/AGENTS.md" "completion.bash"
require_contains "$script_dir/AGENTS.md" "safety-check.sh"