diff --git a/skills/auto-tmux/AGENTS.md b/skills/auto-tmux/AGENTS.md index 51a4c0f..9b76171 100644 --- a/skills/auto-tmux/AGENTS.md +++ b/skills/auto-tmux/AGENTS.md @@ -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`。 diff --git a/skills/auto-tmux/README.md b/skills/auto-tmux/README.md index ad545b9..f5bcbd3 100644 --- a/skills/auto-tmux/README.md +++ b/skills/auto-tmux/README.md @@ -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 diff --git a/skills/auto-tmux/SKILL.md b/skills/auto-tmux/SKILL.md index 345a34d..19f3140 100644 --- a/skills/auto-tmux/SKILL.md +++ b/skills/auto-tmux/SKILL.md @@ -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 :. --dir /tmp/auto-tmux-records skills/auto-tmux/scripts/auto-tmux.sh record stop -t :. 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 ::&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" diff --git a/skills/auto-tmux/scripts/validate-auto-tmux.sh b/skills/auto-tmux/scripts/validate-auto-tmux.sh index e3ebb32..49cc6ef 100755 --- a/skills/auto-tmux/scripts/validate-auto-tmux.sh +++ b/skills/auto-tmux/scripts/validate-auto-tmux.sh @@ -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"