teamsmith 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +13 -7
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +39 -0
  4. package/skills/teamsmith/SKILL.md +18 -7
  5. package/skills/teamsmith/references/agent-adapters.md +7 -7
  6. package/skills/teamsmith/references/config.md +29 -15
  7. package/skills/teamsmith/references/migration.md +38 -2
  8. package/skills/teamsmith/references/protocol.md +81 -13
  9. package/skills/teamsmith/references/workflows.md +31 -19
  10. package/skills/teamsmith/scripts/lib/cmd-agents.sh +210 -70
  11. package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +70 -9
  12. package/skills/teamsmith/scripts/lib/cmd-config.sh +222 -70
  13. package/skills/teamsmith/scripts/lib/cmd-death.sh +2 -15
  14. package/skills/teamsmith/scripts/lib/cmd-docs.sh +6 -3
  15. package/skills/teamsmith/scripts/lib/cmd-project.sh +134 -17
  16. package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
  17. package/skills/teamsmith/scripts/lib/cmd-review.sh +13 -10
  18. package/skills/teamsmith/scripts/lib/cmd-status.sh +42 -13
  19. package/skills/teamsmith/scripts/lib/cmd-watch.sh +75 -13
  20. package/skills/teamsmith/scripts/lib/common.sh +797 -71
  21. package/skills/teamsmith/scripts/monitor.mjs +34 -3
  22. package/skills/teamsmith/scripts/panel/README.md +22 -11
  23. package/skills/teamsmith/scripts/panel/panel.js +217 -215
  24. package/skills/teamsmith/scripts/panel/src/App.tsx +421 -164
  25. package/skills/teamsmith/scripts/panel/src/data.ts +84 -4
  26. package/skills/teamsmith/scripts/panel/src/layout.ts +502 -91
  27. package/skills/teamsmith/scripts/panel/src/main.tsx +97 -12
  28. package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
  29. package/skills/teamsmith/scripts/panel/src/strings/en.ts +56 -21
  30. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +56 -21
  31. package/skills/teamsmith/scripts/panel/src/types.ts +178 -16
  32. package/skills/teamsmith/scripts/replies.mjs +893 -0
  33. package/skills/teamsmith/scripts/team +1 -0
  34. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +15 -2
  35. package/skills/teamsmith/templates/BOARD.md.tmpl +2 -2
  36. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +7 -3
  37. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +17 -0
  38. package/skills/teamsmith/templates/config.sh.tmpl +10 -5
  39. package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
  40. package/skills/teamsmith/templates/pm-prompt.md.tmpl +20 -1
  41. package/skills/teamsmith/templates/report.md.tmpl +12 -0
  42. package/skills/teamsmith/templates/task.md.tmpl +4 -0
  43. package/skills/teamsmith/tests/config-cli.sh +162 -288
  44. package/skills/teamsmith/tests/death-cause.sh +5 -2
  45. package/skills/teamsmith/tests/install-shape.sh +4 -2
  46. package/skills/teamsmith/tests/key-replies-pty.sh +375 -0
  47. package/skills/teamsmith/tests/key-replies-ui.sh +332 -0
  48. package/skills/teamsmith/tests/key-replies.sh +1075 -0
  49. package/skills/teamsmith/tests/ledger-ban.sh +4 -4
  50. package/skills/teamsmith/tests/ledger-claim.sh +247 -0
  51. package/skills/teamsmith/tests/lib/model-policy.sh +26 -0
  52. package/skills/teamsmith/tests/lib/model-routing-boundary.sh +420 -0
  53. package/skills/teamsmith/tests/lib/model-routing-expansion.sh +155 -0
  54. package/skills/teamsmith/tests/lib/model-routing-flips.py +136 -0
  55. package/skills/teamsmith/tests/lib/model-routing-roles.sh +250 -0
  56. package/skills/teamsmith/tests/lib/proc-io.sh +103 -0
  57. package/skills/teamsmith/tests/lib/reply-fixture.sh +372 -0
  58. package/skills/teamsmith/tests/lib/tmux-iso.sh +8 -0
  59. package/skills/teamsmith/tests/panel-b2.sh +1 -1
  60. package/skills/teamsmith/tests/panel-b3-stub.sh +27 -0
  61. package/skills/teamsmith/tests/panel-b3.sh +14 -10
  62. package/skills/teamsmith/tests/panel-choices.sh +74 -61
  63. package/skills/teamsmith/tests/panel-cpu.sh +1 -1
  64. package/skills/teamsmith/tests/panel-p21.sh +311 -190
  65. package/skills/teamsmith/tests/perf.sh +1 -1
  66. package/skills/teamsmith/tests/pm-box-real.sh +1 -1
  67. package/skills/teamsmith/tests/pulse-nudge-key.sh +1 -1
  68. package/skills/teamsmith/tests/routes.sh +43 -22
  69. package/skills/teamsmith/tests/section-budgets.tsv +8 -4
  70. package/skills/teamsmith/tests/section-paths.tsv +26 -16
  71. package/skills/teamsmith/tests/section-select.sh +82 -6
  72. package/skills/teamsmith/tests/smoke.sh +782 -180
  73. package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +2 -2
  74. package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +2 -2
  75. package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +9 -9
  76. package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +2 -2
  77. package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +9 -9
  78. package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +1 -1
  79. package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +1 -1
  80. package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +5 -5
  81. package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +2 -2
  82. package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +5 -5
  83. package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +2 -2
  84. package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +2 -2
  85. package/skills/teamsmith/tests/snapshots/zh-light-120.txt +9 -9
  86. package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +2 -2
  87. package/skills/teamsmith/tests/snapshots/zh-light-160.txt +9 -9
  88. package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +1 -1
  89. package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +1 -1
  90. package/skills/teamsmith/tests/snapshots/zh-light-59.txt +5 -5
  91. package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +2 -2
  92. package/skills/teamsmith/tests/snapshots/zh-light-99.txt +5 -5
  93. package/skills/teamsmith/tests/task-header-model.sh +2 -1
  94. package/skills/teamsmith/tests/task-model-routing.sh +1014 -0
  95. package/skills/teamsmith-init/SKILL.md +38 -38
  96. package/skills/teamsmith-init/references/bootstrap.md +6 -4
  97. package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
@@ -4,7 +4,7 @@
4
4
  # failure carries its own scene — the mechanics live in tests/lib/pty-wait.sh (sourced below).
5
5
  #
6
6
  # bash skills/teamsmith/tests/panel-p21.sh # every scenario
7
- # bash skills/teamsmith/tests/panel-p21.sh settings seats # selected scenarios
7
+ # bash skills/teamsmith/tests/panel-p21.sh settings categories # selected scenarios
8
8
  # bash skills/teamsmith/tests/panel-p21.sh settings groups wheel # P30: grouping + the view's wheel
9
9
  # TEAM_P21_KEEP=1 bash ... # keep the fixture directory
10
10
  #
@@ -236,6 +236,8 @@ if [ -z "$js" ]; then printf 'panel-p21: no node/bun runtime\n' >&2; exit 3; fi
236
236
  # shared helper (its --self-test injects the incident's mid-frame; smoke §38-c runs it).
237
237
  # shellcheck source=lib/pty-wait.sh
238
238
  . "$here/lib/pty-wait.sh"
239
+ # shellcheck source=lib/model-policy.sh
240
+ . "$here/lib/model-policy.sh" # P232:完整派单记录构造器(S1 的共享夹具)
239
241
  # Fixture-wide knobs. PTY_WAIT_ITERS is a failure-detector horizon, never spent on a green run (a
240
242
  # green wait returns on the first settled frame, usually rounds 1-3); per-wait overrides use local.
241
243
  PTY_TRACE="${_trace_arg:-0}"
@@ -255,7 +257,7 @@ if p21_fixture_on; then
255
257
  fi
256
258
 
257
259
  SECTIONS=("$@")
258
- [ "${#SECTIONS[@]}" -gt 0 ] || SECTIONS=(settings groups wheel choices choices-schema write conflict seats readonly)
260
+ [ "${#SECTIONS[@]}" -gt 0 ] || SECTIONS=(settings groups wheel choices choices-schema write conflict categories policy readonly)
259
261
  want() { local s; for s in "${SECTIONS[@]}"; do [ "$s" = "$1" ] && return 0; done; return 1; }
260
262
 
261
263
  # ---------------------------------------------------------------- fixture plumbing
@@ -269,7 +271,7 @@ server_up() { # <name> [agents] → fresh project + private tmux session + argv-
269
271
  && printf '{"name":"%s","scripts":{"verify":"true"}}\n' "$1" > package.json \
270
272
  && git add -A && git commit -qm init ) >/dev/null 2>&1
271
273
  ( cd "$ROOT" && bash "$skill/scripts/team" init --session "$sess" --agents "$agents" --vcs local \
272
- --gates "true" --docs docs/team ) >"$tmp/$1-init.log" 2>&1 \
274
+ --gates "true" --docs docs/team --task-models 'routine=deepseek/deepseek-flash analysis=xai/grok-4.6 verify=kimi-coding/k3-256k' --pm-model 'deepseek/deepseek-flash' ) >"$tmp/$1-init.log" 2>&1 \
273
275
  || { printf 'panel-p21: team init failed (%s)\n' "$1" >&2; tail -3 "$tmp/$1-init.log" >&2; exit 3; }
274
276
  state="$ROOT/.pi/team/state"
275
277
  mkdir -p "$state" "$ROOT/docs/team"
@@ -376,6 +378,17 @@ audit_lines() { [ -f "$(audit_log)" ] && wc -l < "$(audit_log)" || echo 0; }
376
378
  sha() { sha256sum "$1" 2>/dev/null | awk '{print $1}'; }
377
379
  tree_hash() { ( cd "$ROOT" && find "$@" -type f 2>/dev/null | sort | while IFS= read -r f; do printf '%s ' "$f"; sha "$f"; done ) | sha256sum | awk '{print $1}'; }
378
380
  conf_set() { mkdir -p "$state"; printf '%s\n' "$@" > "$state/panel.conf"; }
381
+ # P232:把 fixture 契约换成新的类别策略 + 独立 PM(走真实事务入口 upgrade-models)——退休键真的
382
+ # 离开文件,视图才在「当前契约」这一档上跑;老契约的档由 scn_categories 的 legacy 段专门覆盖。
383
+ policy_new() { # <task-models> <pm-model>
384
+ ( cd "$ROOT" && bash "$skill/scripts/team" config upgrade-models --task-models "$1" --pm-model "$2" --yes ) \
385
+ > "$tmp/$current-upgrade.log" 2>&1
386
+ }
387
+ # 一份**完整**的已提交派单记录(tests/lib/model-policy.sh 的共享构造器;S1 的读面契约)。
388
+ record_fixture() { # <seat> <model> <sid> <task> <category>
389
+ mkdir -p "$state"
390
+ routing_fixture_record "$state" "$1" "$4" "$ROOT" "$ROOT/docs/team/tasks/$4-x.md" "$2" "$3" policy 2026-10-09T00:00:00Z "$5"
391
+ }
379
392
  panel_pid() { tmux -L "$sock" list-panes -t "$sess:panel" -F '#{pane_pid}' 2>/dev/null | head -1; }
380
393
 
381
394
  # Open the overlay and its project-settings navigation row (the sixth row), then wait for data.
@@ -549,6 +562,10 @@ pick_option() {
549
562
  scn_settings() {
550
563
  section "settings · 标签/类徽章/默认值/过滤/窗口/点击/CLI 对齐/refuse 路由/q(B2 + M49)"
551
564
  server_up settings
565
+ # P232:这一段的契约是新的(类别策略 + 独立 PM)。老契约的档由 scn_categories 的 legacy 段专门覆盖;
566
+ # 这里要的是「正常契约下视图里没有裸 TEAM_*」这一条能成立。
567
+ policy_new 'routine=kimi-coding/k3-256k analysis=openai-codex/gpt-5.6-terra:xhigh' 'openai-codex/gpt-6.1-sol:high' \
568
+ || bad "策略升级事务没有跑通"
552
569
  python3 - "$(cfg)" <<'PYFIX'
553
570
  import re, sys
554
571
  p = sys.argv[1]
@@ -742,8 +759,9 @@ import sys
742
759
  p = sys.argv[1]
743
760
  s = open(p, encoding='utf-8').read()
744
761
  s = s.replace('TEAM_GATES|apply|cmd||plain||-|', 'TEAM_GATES|refuse|cmd||plain||-|改门禁请手改(scratch 夹具)')
745
- s = s.replace('TEAM_DEFAULT_MODEL|restart|model|req|plain|deepseek/deepseek-flash|-|',
746
- 'TEAM_ZZZ_TEST|apply|text||plain|zzz-default|-|||workflow\nTEAM_DEFAULT_MODEL|restart|model|req|plain|deepseek/deepseek-flash|-|')
762
+ anchor = 'TEAM_INSTALL_CMD|apply|cmd||plain||-|||workflow'
763
+ assert anchor in s, '找不到 TEAM_INSTALL_CMD 的 schema 行'
764
+ s = s.replace(anchor, 'TEAM_ZZZ_TEST|apply|text||plain|zzz-default|-|||workflow\n' + anchor, 1)
747
765
  open(p, 'w', encoding='utf-8').write(s)
748
766
  PYFIX
749
767
  cat > "$tmp/$current-scratch-wrapper.sh" <<EOF2
@@ -785,7 +803,7 @@ EOF2
785
803
  open_view
786
804
  local want_count
787
805
  want_count="$( (cd "$ROOT" && bash "$skill/scripts/team" config list --json) \
788
- | python3 -c 'import json,sys; d=json.load(sys.stdin); print(len(d["keys"]) + len(d.get("models",{}).get("seats",[])))' )"
806
+ | python3 -c 'import json,sys; d=json.load(sys.stdin); m=d.get("models",{}); print(len(d["keys"]) + len(m.get("policy",{}).get("categories",[])) + len(m.get("assignments",[])) + (1 if m.get("pm_launch") else 0))' )"
789
807
  [ "${want_count:-0}" -gt 0 ] || bad "读数拿不到键数(前提不成立)"
790
808
  local h s rows up down gap prev_rows=""
791
809
  for h in 45 33 30 25; do
@@ -796,7 +814,7 @@ EOF2
796
814
  # ① 内容结束到键栏的空白 ≤1 行(P32 前:45 行里 16 行)
797
815
  if [ "$gap" -le 1 ]; then ok "${h} 行:内容结尾到键栏只剩 $gap 行空白(≤1)"; else bad "${h} 行:内容结尾到键栏还有 $gap 行空白"; fi
798
816
  # ③ 记账诚实:窗口画出的行 + 两条计数 = 命令报的总行数
799
- assert_eq "${h} 行:rows($rows) + ↑($up) + ↓($down) = 命令报的键+席位($want_count)" \
817
+ assert_eq "${h} 行:rows($rows) + ↑($up) + ↓($down) = 命令报的键+类别+派单记录($want_count)" \
800
818
  "$((rows + up + down))" "$want_count"
801
819
  case "$h" in
802
820
  45) prev_rows="$rows" ;;
@@ -836,9 +854,12 @@ s = re.sub(r'^TEAM_AGENT_BIN=.*$', 'TEAM_AGENT_BIN="/nonexistent/m55-agent"', s,
836
854
  s = re.sub(r'^TEAM_MIN_FREE_SWAP_MB=.*$', 'TEAM_MIN_FREE_SWAP_MB="0"', s, count=1, flags=re.M)
837
855
  open(p, 'w', encoding='utf-8').write(s)
838
856
  PY
839
- # 席位模型:28 个记录 → known 变长,滚轮用例的条目列表会超出可视预算(不需要改 pane 几何)。
840
- mkdir -p "$state"
841
- for i in $(seq 2 28); do printf 'model=provider/m%s\n' "$i" > "$state/dev$i.env"; done
857
+ # 长词表:28 个类别(每类别一个模型)+ 独立 PM → known 变长,滚轮用例的条目列表会超出可视预算
858
+ # (不需要改 pane 几何)。P232:词汇表现在来自项目自己的类别策略,席位记录是**已提交派单**、
859
+ # 不完整的记录不贡献任何模型。
860
+ local map="routine=provider/m0 analysis=provider/m1"
861
+ for i in $(seq 2 27); do map="$map cat$i=provider/m$i"; done
862
+ policy_new "$map" 'provider/pm' || bad "策略升级事务没有跑通(见 $tmp/$current-upgrade.log)"
842
863
  conf_set "lang=zh" "page=1" "activity=1" "mouse=1" "density=comfortable" "theme=auto"
843
864
  # R2 的机器目录夹具:scratch HOME 里放一个含 sub2api(已下线的 provider)与 openrouter 的 Pi 模型
844
865
  # 目录 —— 读与选择器都不许出现它们(真实的 models-store.json 是活缓存,绝不能被当成选项来源)。
@@ -1080,16 +1101,17 @@ PY2
1080
1101
  leave_editor TEAM_GATES
1081
1102
  wait_no_editor || bad "cmd 编辑器没有关干净"
1082
1103
 
1083
- # ── (7) pairlist:Enter 把焦点移到席位块,绝不在这里组合(不读、不开编辑器) ──
1084
- filter_to TEAM_AGENT_MODELS
1104
+ # ── (7) task-model-map:Enter 把焦点移到类别块,绝不在这里组合映射(不读、不开编辑器) ──
1105
+ # P232:夹具契约是先 upgrade-models 过的(这一段上面已经升过),所以类别块里至少有一个 routine 行。
1106
+ filter_to TEAM_TASK_MODELS
1085
1107
  sleep 0.5
1086
1108
  keys Enter
1087
- if wait_cap pairlist "席位块就是这一行的编辑器"; then ok "pairlist 行把焦点交给席位块"; else bad "pairlist 路由的说明行没出现"; fi
1109
+ if wait_cap pairlist "类别块就是这一行的编辑器"; then ok "整映射行把焦点交给类别块"; else bad "类别块路由的说明行没出现"; fi
1088
1110
  cap_to pairlist
1089
- assert_not "$tmp/$current/pairlist.txt" "╭─ TEAM_AGENT_MODELS" "pairlist 不开写编辑器"
1090
- assert_not "$tmp/$current/pairlist.txt" " · TEAM_AGENT_MODELS" "pairlist 不开选择器"
1091
- assert_match "$tmp/$current/pairlist.txt" '› dev +' "焦点移到席位块的第一行"
1092
- assert_has "$tmp/$current/pairlist.txt" "team config set-agent-model" "命令行点名 set-agent-model(唯一写者)"
1111
+ assert_not "$tmp/$current/pairlist.txt" "╭─ TEAM_TASK_MODELS" "整映射行不开写编辑器"
1112
+ assert_not "$tmp/$current/pairlist.txt" " · TEAM_TASK_MODELS" "整映射行不开选择器"
1113
+ assert_match "$tmp/$current/pairlist.txt" '› 类别 routine' "焦点移到类别块的第一行"
1114
+ assert_has "$tmp/$current/pairlist.txt" "team config set-task-model" "命令行点名 set-task-model(唯一写者)"
1093
1115
 
1094
1116
  # ── (8) 鼠标:第一次点击只移光标(不写);第二次点击 = 接受并直写;esc 什么都不写 ──
1095
1117
  wait_no_editor || bad "点击用例开始前还有编辑器开着"
@@ -1131,7 +1153,7 @@ PY2
1131
1153
  assert_eq "esc 后审计不增长" "$(audit_lines)" "$esc_audit"
1132
1154
  argv_since "$esc0" "$tmp/$current/esc-argv.log"
1133
1155
  assert_not "$tmp/$current/esc-argv.log" "config set" "esc 的窗口里没有 config set"
1134
- assert_not "$tmp/$current/esc-argv.log" "set-agent-model" "esc 的窗口里没有席位写"
1156
+ assert_not "$tmp/$current/esc-argv.log" "set-task-model" "esc 的窗口里没有类别写"
1135
1157
  # M59 判据②(真实场景):此刻选择器已被上面那条 esc 关掉 —— 清理点的 esc 必须先确认状态。
1136
1158
  # 旧写法的裸 esc 在这里会把设置视图整个关掉,之后每段都在错的视图里跑(§38-b 的级联入口)。
1137
1159
  PTY_TRACE=1 pty_cleanup_esc "回归钉:已关闭的选择器" " · TEAM_MONITOR_UI" > "$tmp/$current/cleanup-trace.txt" 2>&1
@@ -1148,10 +1170,10 @@ PY2
1148
1170
 
1149
1171
  # ── (9) 滚轮:条目列表比可视预算长时滚得动(焦点走过的就是列表滚过的) ──
1150
1172
  wait_no_editor || bad "滚轮用例开始前还有编辑器开着"
1151
- filter_to TEAM_DEFAULT_MODEL
1173
+ filter_to TEAM_PM_MODEL
1152
1174
  sleep 0.5
1153
1175
  keys Enter
1154
- wait_picker TEAM_DEFAULT_MODEL '↓' || bad "长列表选择器没有打开"
1176
+ wait_picker TEAM_PM_MODEL '↓' || bad "长列表选择器没有打开"
1155
1177
  cap_to wheel-before
1156
1178
  local before_hidden
1157
1179
  before_hidden="$(grep -oE '↓[0-9]+' "$tmp/$current/wheel-before.txt" | head -1 | tr -d '↓' || true)"
@@ -1185,13 +1207,13 @@ PY2
1185
1207
  ( cd "$ROOT" && HOME="$home" bash "$skill/scripts/team" config list --json ) > "$tmp/$current/read-json.json" 2>&1
1186
1208
  assert_not "$tmp/$current/read-json.json" "sub2api" "同一 scratch HOME 下的读也不含目录 provider"
1187
1209
  # 硬化自检(M55 第一次复验 FAIL 的回归钉 + M59 判据①/③)……
1188
- if wait_picker_quick TEAM_DEFAULT_MODEL '这条目不存在-硬线自检'; then
1210
+ if wait_picker_quick TEAM_PM_MODEL '这条目不存在-硬线自检'; then
1189
1211
  bad "wait_picker 只凭标题就放行了(条目标记/稳定帧没起作用)"
1190
1212
  else
1191
1213
  ok "wait_picker 要的条目不在稳定帧里时判负(标题命中不算,现场见上面的黄点场景)"
1192
1214
  fi
1193
1215
  # 清理守卫把 esc 只打在真开着的选择器上(这里选择器确实开着 → 恰好一个 esc)。
1194
- leave_picker TEAM_DEFAULT_MODEL || bad "回归钉之后的选择器没有关掉"
1216
+ leave_picker TEAM_PM_MODEL || bad "回归钉之后的选择器没有关掉"
1195
1217
 
1196
1218
  # ── (10) 危险值来自选项:第一次 accept 只给警告(不写、不审计),第二次才带 danger allowance 写入 ──
1197
1219
  filter_to TEAM_MIN_FREE_SWAP_MB
@@ -1450,154 +1472,247 @@ PY
1450
1472
  assert_has "$tmp/$current/reloaded.txt" "team config set TEAM_PULSE_NUDGE_GAP" "视图仍点名原始键(照敲命令用)"
1451
1473
  }
1452
1474
 
1453
- scn_seats() {
1454
- section "seats · 来源三态 / picker / 一 token diff / 移除回退 / 运行中的席位不变(B4)"
1455
- server_up seats "dev verify dev2"
1456
- python3 - "$(cfg)" <<'PY'
1457
- import re, sys
1458
- p = sys.argv[1]
1459
- s = open(p, encoding='utf-8').read()
1460
- s = s.replace('TEAM_AGENT_MODELS=""', 'TEAM_AGENT_MODELS="dev=deepseek/deepseek-flash"')
1461
- # model-id-shape R1:known 里必须有一个三段 id(pm 席位)——席位选择器要能列出并选中它。
1462
- s = re.sub(r'^TEAM_PM_MODEL=.*$', 'TEAM_PM_MODEL="openrouter/amazon/nova-lite-v1"', s, count=1, flags=re.M)
1463
- open(p, 'w', encoding='utf-8').write(s)
1464
- PY
1465
- mkdir -p "$state"
1466
- printf 'model=xai/grok-4.6\n' > "$state/dev.env"
1467
- printf 'model=deepseek/deepseek-flash\n' > "$state/verify.env"
1468
- printf 'model=kimi-coding/k3-256k\nmodel_src=explicit\n' > "$state/dev2.env"
1475
+ # ---------------------------------------------------------------- P232(类别策略 vs 已派记录)
1476
+ # 窄判据:类别行 + 策略/实际分离 + 一次类别直写。flip 段把它当靶子(把写入路由或显示规则弄坏,
1477
+ # 这一段必须红)。它刻意只走一条路径,好让红侧点名到具体的断言。
1478
+ scn_policy() {
1479
+ section "policy · 类别行 / 策略 vs 实际 / 类别直写走 set-task-model(P232 的窄判据)"
1480
+ server_up policy "dev verify"
1481
+ policy_new 'routine=kimi-coding/k3-256k analysis=openai-codex/gpt-5.6-terra:xhigh' 'openai-codex/gpt-6.1-sol:high' \
1482
+ || bad "策略升级事务没有跑通(见 $tmp/$current-upgrade.log)"
1483
+ record_fixture dev 'xai/grok-4.6' sid-dev-232 T232-x routine
1484
+ conf_set "lang=zh" "page=1" "activity=1" "mouse=1" "density=comfortable" "theme=auto"
1469
1485
  start_panel
1470
1486
  open_view
1471
- filter_to verify
1472
- wait_row seats-verify "席位 verify 行显示配置来源" 'verify' 'deepseek/deepseek-flash · 配置' \
1473
- || bad "席位 verify 的行没有在预算内出现"
1474
- assert_match "$tmp/$current/seats-verify.txt" 'verify +deepseek/deepseek-flash · 配置' "配置解析 → 配置"
1475
- filter_to dev2
1476
- wait_row seats-dev2 "席位 dev2 行显示显式来源" 'dev2' 'kimi-coding/k3-256k · 显式' \
1477
- || bad "席位 dev2 的行没有在预算内出现"
1478
- assert_match "$tmp/$current/seats-dev2.txt" 'dev2 +kimi-coding/k3-256k · 显式' "显式记录 → 显式"
1487
+ # ① 类别行:未来策略 + 「新任务」徽章 + 命令行点名 set-task-model
1488
+ filter_to 类别
1489
+ wait_row policy-cat "类别 routine 行(策略模型 + 新任务徽章)" '任务类别(未来策略)' '类别 routine' 'kimi-coding/k3-256k' \
1490
+ || bad "类别行没有在预算内出现"
1491
+ # 视图的快照行、命令行提示行都跟着**焦点**走:先把光标移到类别行,再看这一行的两半(M49)。
1492
+ if focus_row '› 类别 routine'; then :; else bad "没能把焦点移到类别 routine 行"; fi
1493
+ cap_to policy-cat
1494
+ assert_match "$tmp/$current/policy-cat.txt" '› 类别 routine +kimi-coding/k3-256k · 新任务' "类别行 = 类别 + 策略模型 + 新任务徽章"
1495
+ assert_has "$tmp/$current/policy-cat.txt" "team config set-task-model routine <model>" "命令行点名 set-task-model(唯一写者)"
1496
+ # ② 策略 ≠ 实际:dev 的只读行显示**记录**里的模型,行里不出现策略模型
1479
1497
  filter_to dev
1480
- wait_row seats "席位 dev 行显示历史记录来源" 'dev' 'xai/grok-4.6 · 历史记录' \
1481
- || bad "席位 dev 的行没有在预算内出现"
1482
- assert_match "$tmp/$current/seats.txt" 'dev +xai/grok-4.6 · 历史记录' "记录与配置不一致 → 历史记录 + 记录的模型"
1483
- ( cd "$ROOT" && bash "$skill/scripts/team" roster ) > "$tmp/$current/roster.txt" 2>/dev/null
1484
- assert_match "$tmp/$current/roster.txt" 'xai/grok-4\.6·历史记录' "team roster 的标签与 models 块同口径"
1485
- # Focus the dev seat row (its line carries the record's model) and open the picker.
1486
- # M59: Enter only follows a successful walk (focus_row tolerates the row set being replaced).
1487
- sleep 0.3
1488
- if focus_row 'dev +xai/grok-4.6'; then
1489
- keys Enter
1498
+ wait_row policy-dev "dev 的只读派单行" '实际派单记录(只读)' 'xai/grok-4.6' \
1499
+ || bad "dev 的派单行没有在预算内出现"
1500
+ if focus_row '› dev '; then :; else bad "没能把焦点移到 dev 的派单行"; fi
1501
+ cap_to policy-dev
1502
+ assert_match "$tmp/$current/policy-dev.txt" 'dev +xai/grok-4.6 · 只读' "记录模型逐字显示(不是策略模型)"
1503
+ assert_not "$tmp/$current/policy-dev.txt" "kimi-coding/k3-256k" "派单行里不出现未来策略的模型"
1504
+ assert_has "$tmp/$current/policy-dev.txt" "SID sid-dev-232" "派单行带已提交的 SID"
1505
+ assert_has "$tmp/$current/policy-dev.txt" "只读:实际模型来自已提交的派单记录" "命令行说明这是派单决定的只读面"
1506
+ # ③ 没有记录的席位:不借策略模型
1507
+ filter_to verify
1508
+ wait_row policy-verify "verify 的「没有完整派单记录」行" 'verify' '没有完整派单记录' \
1509
+ || bad "无记录席位行没有在预算内出现"
1510
+ assert_not "$tmp/$current/policy-verify.txt" "kimi-coding/k3-256k" "无记录席位行不借未来策略的模型"
1511
+ # ④ 一次类别直写:picker 用项目自己的词表,写走 set-task-model 的 dry-run → --yes
1512
+ filter_to 类别
1513
+ sleep 0.5
1514
+ if focus_row '› 类别 routine'; then keys Enter; else bad "没能把焦点移到类别行"; fi
1515
+ if pty_wait_frame "$tmp/$current/policy-picker.txt" "类别 picker" "选择类别 routine 的模型" "…(自由输入)"; then
1516
+ ok "类别 picker 打开(标题点名类别 + 自由输入项)"
1490
1517
  else
1491
- bad "没能把焦点移到 dev 席位行"
1518
+ bad "类别 picker 没有打开"
1492
1519
  fi
1493
- # M59: conditional — wait for the seat picker on a settled frame (title + the three-segment known entry).
1494
- pty_wait_frame "$tmp/$current/picker.txt" "seat picker dev" "选择 dev 的模型" "openrouter/amazon/nova-lite-v1" \
1495
- || bad "seat picker 没有打开(标题或已知模型不在稳定帧上)"
1496
- assert_match "$tmp/$current/picker.txt" '选择 dev 的模型' "picker 打开并点名席位"
1497
- assert_has "$tmp/$current/picker.txt" "openrouter/amazon/nova-lite-v1" "picker 列出命令报告的三段已知模型"
1498
- assert_has "$tmp/$current/picker.txt" "kimi-coding/k3-256k" "picker 同时列出记录来源的已知模型"
1499
- assert_has "$tmp/$current/picker.txt" "-(移除覆盖,回退默认)" "picker 有移除项"
1500
- assert_has "$tmp/$current/picker.txt" "自由输入" "picker 有自由输入项"
1501
- # Choose the three-segment known model that differs from the seat's displayed one, then confirm through the editor.
1502
- pick_option 'openrouter/amazon/nova-lite-v1' || bad "picker 里没有 openrouter/amazon/nova-lite-v1"
1503
- wait_editor dev || bad "seat 编辑器没有打开"
1504
- sleep 0.3
1505
- local line_before; line_before="$(grep '^TEAM_AGENT_MODELS=' "$(cfg)")"
1506
- keys Enter
1507
- if wait_cap seat-confirm "确认席位 dev"; then ok "确认行点名席位"; else bad "确认行没有出现"; fi
1508
- assert_has "$tmp/$current/seat-confirm.txt" "下次 dispatch/resume 生效" "确认行说明下次 spawn 生效"
1509
- keys Enter
1510
- if wait_cap seat-written "✓ 已写入席位 dev = "; then
1511
- cap_to seat-written
1512
- assert_match "$tmp/$current/seat-written.txt" '✓ 已写入席位 dev = openrouter/amazon/nova-lite-v1 · 下次 dispatch/resume 生效' "写入回执带完整三段 id(不是最后一段)"
1520
+ cap_to policy-picker
1521
+ assert_has "$tmp/$current/policy-picker.txt" "kimi-coding/k3-256k · 当前" "picker 标出策略的当前值"
1522
+ assert_has "$tmp/$current/policy-picker.txt" "xai/grok-4.6" "picker 列出项目自己的已知模型"
1523
+ assert_not "$tmp/$current/policy-picker.txt" "移除" "类别 picker 没有移除项(写者没有删除操作,面板不发明它)"
1524
+ local pol_sha pol_audit pol_argv pol_pid_args pol_record
1525
+ pol_sha="$(sha "$(cfg)")"; pol_audit="$(audit_lines)"; pol_argv="$(argv_count)"
1526
+ pol_record="$(sha "$state/dev.env")"
1527
+ pol_pid_args="$(tr '\0' ' ' < "/proc/$(panel_pid)/cmdline" 2>/dev/null || true)"
1528
+ cp "$(cfg)" "$tmp/$current/before-cat.cfg"
1529
+ pick_option 'xai/grok-4.6' || bad "picker 里没有 xai/grok-4.6"
1530
+ if wait_cap policy-written "已写入类别 routine = xai/grok-4.6"; then
1531
+ ok "类别直写的回执"
1513
1532
  else
1514
- bad "席位写入的回执没有出现(见 seat-written.txt)"
1533
+ bad "类别直写的回执没有出现"
1515
1534
  fi
1516
- assert_match "$(cfg)" '^TEAM_AGENT_MODELS=.*dev=openrouter/amazon/nova-lite-v1' "契约里 dev 的 token 落盘(完整三段 id)"
1517
- assert_eq "契约行只改了一行" "$(diff <(printf '%s\n' "$line_before") <(grep '^TEAM_AGENT_MODELS=' "$(cfg)") | grep -c '^[<>]' || true)" "2"
1518
- assert_match "$(argv_log)" 'config set-agent-model dev .* --actor panel --dry-run --fingerprint [0-9a-f]{64}' "wrapper 记录了 set-agent-model 的 --dry-run"
1519
- assert_match "$(argv_log)" 'config set-agent-model dev .* --actor panel --yes --fingerprint [0-9a-f]{64}' "wrapper 记录了 set-agent-model 的写入"
1520
- assert_eq "席位记录 state/dev.env 未被碰" "$(cat "$state/dev.env")" "model=xai/grok-4.6"
1521
- # Removal: the picker's `-` row falls back to TEAM_DEFAULT_MODEL.
1522
- filter_to dev
1523
- # M55/M59:刚写过的席位让视图异步重读合同(行集会被整批替换、甚至整段空缺等块重建)。
1524
- # focus_row 自己容忍这个窗口;Enter 只跟在成功的走位后(盲发 Enter 实测打到 dev2 行)。
1525
- sleep 0.3
1526
- if focus_row 'dev +xai/grok-4.6'; then
1527
- keys Enter
1535
+ cap_to policy-written
1536
+ assert_not "$tmp/$current/policy-written.txt" "确认:" "值条目直写没有确认帧"
1537
+ assert_has "$tmp/$current/policy-written.txt" "只影响新任务" "回执说明只影响新任务"
1538
+ assert_has "$tmp/$current/policy-written.txt" "没有重启任何进程" "回执说明没有进程被重启"
1539
+ argv_since "$pol_argv" "$tmp/$current/policy-argv.log"
1540
+ assert_match "$tmp/$current/policy-argv.log" 'config set-task-model routine xai/grok-4.6 --actor panel --dry-run --fingerprint [0-9a-f]{64}' "argv 记录 set-task-model --dry-run"
1541
+ assert_match "$tmp/$current/policy-argv.log" 'config set-task-model routine xai/grok-4.6 --actor panel --yes --fingerprint [0-9a-f]{64}' "argv 记录 set-task-model 的写入"
1542
+ assert_not "$tmp/$current/policy-argv.log" "set-agent-model" "argv 里没有退休的席位写入"
1543
+ assert_eq "类别写入审计长一行" "$(audit_lines)" "$((pol_audit + 1))"
1544
+ assert_match "$(cfg)" '^TEAM_TASK_MODELS=.*routine=xai/grok-4.6' "契约里类别映射落盘(完整三段 id 逐字)"
1545
+ assert_has "$(cfg)" "xai/grok-4.6" "契约里写的是完整 id"
1546
+ assert_eq "契约只改了一行" "$(diff "$tmp/$current/before-cat.cfg" "$(cfg)" | grep -c '^[<>]' || true)" "2"
1547
+ assert_match "$(cfg)" "^TEAM_PM_MODEL=" "PM 行没有被类别写碰"
1548
+ assert_eq "派单记录 state/dev.env 未被碰" "$(sha "$state/dev.env")" "$pol_record"
1549
+ assert_not "$tmp/$current/policy-argv.log" "dispatch" "写入窗口里没有 dispatch"
1550
+ assert_not "$tmp/$current/policy-argv.log" "resume" "写入窗口里没有 resume"
1551
+ assert_not "$tmp/$current/policy-argv.log" "restart" "写入窗口里没有 restart"
1552
+ assert_eq "面板进程 argv 不变(没有重启)" "$(tr '\0' ' ' < "/proc/$(panel_pid)/cmdline" 2>/dev/null || true)" "$pol_pid_args"
1553
+ }
1554
+
1555
+ scn_categories() {
1556
+ section "categories · picker 条目与取消 / PM 编辑 / 陈旧指纹 / 删类别后的保留恢复 / 遗留配置 / 无 spawn(P232)"
1557
+ server_up categories "dev verify"
1558
+ policy_new 'routine=kimi-coding/k3-256k analysis=openai-codex/gpt-5.6-terra:xhigh verify=deepseek/deepseek-flash' \
1559
+ 'openai-codex/gpt-6.1-sol:high' || bad "策略升级事务没有跑通(见 $tmp/$current-upgrade.log)"
1560
+ record_fixture dev 'xai/grok-4.6' sid-dev-232 T232-x routine
1561
+ conf_set "lang=zh" "page=1" "activity=1" "mouse=1" "density=comfortable" "theme=auto"
1562
+ local scn_argv scn_windows
1563
+ scn_argv="$(argv_count)"
1564
+ start_panel
1565
+ scn_windows="$(tmux -L "$sock" list-windows -t "$sess" -F '#{window_name}' 2>/dev/null | sort | tr '\n' ',')"
1566
+ open_view
1567
+ # ① 类别 picker 的条目顺序(当前 → 已知模型(去重)→ 自由输入),没有任何移除/整映射组合项
1568
+ filter_to 类别
1569
+ sleep 0.5
1570
+ if focus_row '› 类别 routine'; then keys Enter; else bad "没能把焦点移到类别 routine 行"; fi
1571
+ if pty_wait_frame "$tmp/$current/cat-picker.txt" "类别 picker" "选择类别 routine 的模型" "…(自由输入)"; then
1572
+ ok "类别 picker 打开"
1528
1573
  else
1529
- bad "移除前没能把焦点移到 dev 席位行"
1574
+ bad "类别 picker 没有打开"
1530
1575
  fi
1531
- pty_wait_frame - "seat picker dev(移除用例)" "选择 dev 的模型" || bad "移除用例的 seat picker 没有打开"
1532
- pick_option '-(移除覆盖' || bad "picker 里没有移除项"
1533
- wait_editor dev || bad "移除用例的 seat 编辑器没有打开"
1576
+ cap_to cat-picker
1577
+ assert_has "$tmp/$current/cat-picker.txt" "kimi-coding/k3-256k · 当前" "条目:策略当前值带「当前」标记"
1578
+ assert_not "$tmp/$current/cat-picker.txt" "routing=" "picker 不组合整张映射"
1579
+ local cat_sha cat_audit
1580
+ cat_sha="$(sha "$(cfg)")"; cat_audit="$(audit_lines)"
1581
+ # ② esc 取消:什么都不写、不留审计
1582
+ pty_key_when "类别 picker 的 esc" "选择类别 routine 的模型" Escape || bad "类别 picker 不在稳定帧上,esc 没有发"
1583
+ wait_row cat-picker-closed "一次 esc 关掉类别 picker" '!选择类别 routine 的模型' '╭─ 项目设置' \
1584
+ || bad "一次 esc 没有关掉类别 picker"
1585
+ assert_not "$tmp/$current/cat-picker-closed.txt" "选择类别 routine 的模型" "一次 esc 关掉 picker"
1586
+ assert_eq "取消后契约不变" "$(sha "$(cfg)")" "$cat_sha"
1587
+ assert_eq "取消后审计不增长" "$(audit_lines)" "$cat_audit"
1588
+ # ③ PM 编辑:自由输入 + 两次确认;回执点名 team up / fresh;一行 diff;argv 走 config set
1589
+ local pm_before; pm_before="$(grep '^TEAM_PM_MODEL=' "$(cfg)")"
1590
+ local pm_audit; pm_audit="$(audit_lines)"
1591
+ filter_to TEAM_PM_MODEL
1592
+ sleep 0.5
1534
1593
  keys Enter
1535
- sleep 2
1594
+ wait_picker TEAM_PM_MODEL '· 当前' || bad "PM 行的选择器没有打开"
1595
+ pick_option '自由输入' || bad "PM 行没有自由输入项"
1596
+ wait_editor TEAM_PM_MODEL || bad "PM 行的编辑器没有打开"
1597
+ keys C-u; sleep 0.3
1598
+ type_text "kimi-coding/k3-256k"; sleep 0.4
1536
1599
  keys Enter
1537
- if wait_cap removed "已移除席位 dev 的覆盖"; then
1538
- ok "移除回执说回到默认"
1600
+ if wait_cap pm-confirm "确认:TEAM_PM_MODEL"; then ok "PM 编辑先给确认行"; else bad "PM 的确认行没有出现"; fi
1601
+ keys Enter
1602
+ if wait_cap pm-written "已写入 PM 模型"; then ok "PM 编辑落盘"; else bad "PM 的写入回执没有出现"; fi
1603
+ cap_to pm-written
1604
+ assert_has "$tmp/$current/pm-written.txt" "fresh-pm" "PM 回执点名换模型的 fresh-pm 守卫"
1605
+ assert_has "$tmp/$current/pm-written.txt" "没有重启任何进程" "PM 回执说明没有进程被重启"
1606
+ assert_match "$(argv_log)" 'config set TEAM_PM_MODEL kimi-coding/k3-256k --actor panel --dry-run --fingerprint [0-9a-f]{64}' "argv 记录 PM 的 --dry-run"
1607
+ assert_match "$(argv_log)" 'config set TEAM_PM_MODEL kimi-coding/k3-256k --actor panel --yes --fingerprint [0-9a-f]{64}' "argv 记录 PM 的写入"
1608
+ assert_eq "PM 写入审计长一行" "$(audit_lines)" "$((pm_audit + 1))"
1609
+ assert_neq "PM 行确实变了" "$(grep '^TEAM_PM_MODEL=' "$(cfg)")" "$pm_before"
1610
+ assert_has "$(cfg)" "kimi-coding/k3-256k" "PM 的新模型在文件里"
1611
+ # ④ 陈旧指纹:picker 开着时另一个写者改契约 → accept 判冲突、对方字节保住、审计一行 conflict
1612
+ filter_to 类别
1613
+ sleep 0.5
1614
+ if focus_row '› 类别 analysis'; then keys Enter; else bad "没能把焦点移到类别 analysis 行"; fi
1615
+ pty_wait_frame - "类别 picker(冲突用例)" "选择类别 analysis 的模型" || bad "冲突用例的 picker 没有打开"
1616
+ printf '# other writer\n' >> "$(cfg)"
1617
+ local other_sha; other_sha="$(sha "$(cfg)")"
1618
+ pick_option 'deepseek/deepseek-flash' || bad "冲突用例的 picker 里没有 deepseek/deepseek-flash"
1619
+ if wait_cap cat-conflict "指纹不符"; then ok "陈旧指纹被命令拒绝(回执点名冲突)"; else bad "陈旧指纹的冲突回执没有出现"; fi
1620
+ assert_eq "对方的字节被保住" "$(sha "$(cfg)")" "$other_sha"
1621
+ assert_match "$(audit_log)" 'result=conflict actor=panel key=TEAM_TASK_MODELS' "审计增了一行 conflict(actor=panel)"
1622
+ # ⑤ 删掉未来类别:策略行消失,已提交记录的模型/SID 原样保留(恢复不看映射成员)
1623
+ ( cd "$ROOT" && bash "$skill/scripts/team" config set TEAM_TASK_MODELS 'analysis=openai-codex/gpt-5.6-terra:xhigh verify=deepseek/deepseek-flash' --yes ) >/dev/null 2>&1 \
1624
+ || bad "整映射删除 routine 失败"
1625
+ reopen_view
1626
+ filter_to dev
1627
+ wait_row cat-kept "删类别后 dev 的派单行仍在" 'xai/grok-4.6' 'SID sid-dev-232' \
1628
+ || bad "删类别后派单行没有在预算内出现"
1629
+ assert_match "$tmp/$current/cat-kept.txt" 'dev +xai/grok-4.6 · 只读' "删类别后记录模型仍是记录里的值"
1630
+ assert_has "$tmp/$current/cat-kept.txt" "SID sid-dev-232" "删类别后 SID 原样"
1631
+ filter_to 类别
1632
+ cap_to cat-deleted
1633
+ assert_not "$tmp/$current/cat-deleted.txt" "类别 routine" "被删的类别不再有策略行"
1634
+ assert_match "$tmp/$current/cat-deleted.txt" '类别 (analysis|verify)' "其余类别照旧在策略块里"
1635
+ assert_match "$tmp/$current/cat-deleted.txt" '^│ ── 任务类别(未来策略) ─+' "类别块本身还在(只删了 routine)"
1636
+ # ⑥ 无 spawn/重启:整段没有任何 dispatch/resume/restart,窗口集合不变
1637
+ argv_since "$scn_argv" "$tmp/$current/categories-argv.log"
1638
+ assert_not "$tmp/$current/categories-argv.log" "dispatch" "整个场景没有 dispatch"
1639
+ assert_not "$tmp/$current/categories-argv.log" "resume" "整个场景没有 resume"
1640
+ assert_not "$tmp/$current/categories-argv.log" "restart" "整个场景没有 restart"
1641
+ assert_not "$tmp/$current/categories-argv.log" "set-agent-model" "整个场景没有退休的席位写入"
1642
+ assert_eq "tmux 窗口集合不变(没有 spawn 席位)" \
1643
+ "$(tmux -L "$sock" list-windows -t "$sess" -F '#{window_name}' 2>/dev/null | sort | tr '\n' ',')" "$scn_windows"
1644
+ # ⑦ 遗留配置:退休键在文件里 → 可见的迁移诊断 + 命令行给 CLI 升级路线;没有席位编辑器
1645
+ server_up categories-legacy "dev verify"
1646
+ start_panel
1647
+ open_view
1648
+ # 诊断行按 头…尾 换行(不截断路线):命令原文可能跨两行,所以断言的是路线的**词**都在屏幕上
1649
+ # (升级命令名 + 它的参数),而不是一整串连续子串。
1650
+ wait_row legacy-diagnosis "遗留配置的迁移诊断" '策略迁移诊断' '含退休键' 'upgrade-models' \
1651
+ || bad "遗留配置的迁移诊断没有在预算内出现"
1652
+ assert_has "$tmp/$current/legacy-diagnosis.txt" "upgrade-models" "诊断给出 CLI 升级命令(命令名可见)"
1653
+ assert_has "$tmp/$current/legacy-diagnosis.txt" "--task-models" "诊断给出升级命令的参数(不被截掉)"
1654
+ assert_has "$tmp/$current/legacy-diagnosis.txt" "--dry-run" "诊断给出升级命令的预览步骤(不被截掉)"
1655
+ assert_has "$tmp/$current/legacy-diagnosis.txt" "TEAM_DEFAULT_MODEL" "诊断点名退休键"
1656
+ local legacy_cat_heading
1657
+ legacy_cat_heading="$(cap_line_heading "$tmp/$current/legacy-diagnosis.txt" '任务类别(未来策略)')"
1658
+ assert_eq "遗留配置没有可编辑的类别块(没有假的可编辑策略)" "$legacy_cat_heading" "0"
1659
+ filter_to TEAM_DEFAULT_MODEL
1660
+ # 筛选也匹配行内注释(M49 的既有口径),而 TEAM_PM_MODEL 的初始化注释里就写着 TEAM_DEFAULT_MODEL ——
1661
+ # 所以这里必须先把光标走到退休键那一行,否则回车打到的是 PM 行(第一遍就是这么红的)。
1662
+ if focus_row '› TEAM_DEFAULT_MODEL'; then :; else bad "没能把焦点移到退休键行"; fi
1663
+ cap_to legacy-key
1664
+ assert_match "$tmp/$current/legacy-key.txt" 'TEAM_DEFAULT_MODEL +.*未知键' "退休键变成只读的未知键行(没有席位默认编辑器)"
1665
+ keys Enter
1666
+ if wait_cap legacy-route "不是已知的项目设置"; then ok "退休键的回执点名它不在 schema 里(不给编辑)"; else bad "退休键的回执没有出现"; fi
1667
+ cap_to legacy-route
1668
+ assert_not "$tmp/$current/legacy-route.txt" " · TEAM_DEFAULT_MODEL" "退休键不开选择器"
1669
+ assert_not "$tmp/$current/legacy-route.txt" "╭─ TEAM_DEFAULT_MODEL" "退休键不开写编辑器"
1670
+ assert_not "$tmp/$current/legacy-route.txt" "set-agent-model" "遗留视图里没有席位写入路线"
1671
+ }
1672
+
1673
+ scn_flip() {
1674
+ section "flip · 写入路由改成席位写入 / 把未来策略当实际显示 → policy 段必须红;还原 → 绿(P232 对抗控制)"
1675
+ local ft="$tmp/flip"
1676
+ mkdir -p "$ft"
1677
+ cp "$panel" "$ft/panel-route.js"
1678
+ cp "$panel" "$ft/panel-actual.js"
1679
+ python3 - "$ft/panel-route.js" "$ft/panel-actual.js" <<'PYPATCH'
1680
+ import sys
1681
+ route, actual = sys.argv[1], sys.argv[2]
1682
+ s = open(route, encoding='utf-8').read()
1683
+ old = '"config","set-task-model"'
1684
+ assert old in s, "找不到面板的 set-task-model 路由字节"
1685
+ open(route, 'w', encoding='utf-8').write(s.replace(old, '"config","set-agent-model"', 1))
1686
+ a = open(actual, encoding='utf-8').read()
1687
+ old2 = 'B.assigned?B.model||J.dash:J.dash'
1688
+ assert old2 in a, "找不到派单行的显示规则字节"
1689
+ open(actual, 'w', encoding='utf-8').write(a.replace(old2, 'Q.blocks.settings.models.policy.categories[0].model', 1))
1690
+ PYPATCH
1691
+ # 红侧 ①:面板的写入路由改成退休的席位写入 → 写路径的 argv 断言必须红
1692
+ TEAM_P21_PANEL="$ft/panel-route.js" bash "$here/panel-p21.sh" policy > "$tmp/flip-route-red.log" 2>&1
1693
+ local rc_red=$?
1694
+ if [ "$rc_red" -eq 1 ] && grep -a '✗' "$tmp/flip-route-red.log" | grep -q 'set-task-model'; then
1695
+ ok "红侧①:路由改成席位写入后 argv 断言红且点名 set-task-model(rc=$rc_red)"
1539
1696
  else
1540
- bad "移除回执没有出现(见 removed.txt)"
1697
+ bad "红侧①:路由改了却没人红(rc=$rc_red)"
1541
1698
  fi
1542
- assert_eq "dev 的 token 离开契约行" "$(grep '^TEAM_AGENT_MODELS=' "$(cfg)")" "TEAM_AGENT_MODELS=''"
1543
- # A shapeless model is refused by the owning command (free-text row → deepseek-flash).
1544
- local sha_b; sha_b="$(sha "$(cfg)")"
1545
- # 刚写过的席位:视图会重读合同(行上的“覆盖”变成“回退默认”)。等它落定再走位,否则走位可能在
1546
- # 一个正在被替换的行集上做过(实测:拿旧帧算出 40 步,新帧一到就冲过 dev 行)。
1547
- wait_cap removed-fresh 'xai/grok-4.6 · 历史记录 · 回退默认' || bad "移除后视图没有重读合同"
1548
- filter_to dev
1549
- sleep 0.3
1550
- if focus_row 'dev +xai/grok-4.6'; then
1551
- keys Enter
1699
+ # 红侧 ②:把未来策略的模型当实际显示 → 策略/实际分离的断言必须红
1700
+ TEAM_P21_PANEL="$ft/panel-actual.js" bash "$here/panel-p21.sh" policy > "$tmp/flip-actual-red.log" 2>&1
1701
+ rc_red=$?
1702
+ if [ "$rc_red" -eq 1 ] && grep -a '✗' "$tmp/flip-actual-red.log" | grep -q '策略'; then
1703
+ ok "红侧②:把策略模型当实际显示后分离断言红且点名策略(rc=$rc_red)"
1552
1704
  else
1553
- bad "拒绝用例没能把焦点移到 dev 席位行"
1705
+ bad "红侧②:显示规则改了却没人红(rc=$rc_red)"
1554
1706
  fi
1555
- pty_wait_frame - "seat picker dev(拒绝用例)" "选择 dev 的模型" || bad "拒绝用例的 seat picker 没有打开"
1556
- pick_option '自由输入' || bad "picker 里没有自由输入项"
1557
- wait_editor dev || bad "自由输入用例的 seat 编辑器没有打开"
1558
- type_text "deepseek-flash"
1559
- sleep 0.3
1560
- keys Enter
1561
- if wait_cap shapeless "provider/model"; then ok "没有 provider 的模型被命令拒绝"; else bad "拒绝回执没有出现"; fi
1562
- leave_editor dev || bad "拒绝用例的 esc 发了但 seat 编辑器还在"
1563
- assert_eq "被拒后契约 sha 不变" "$(sha "$(cfg)")" "$sha_b"
1564
- # The running seat's window keeps its model; the next dispatch would use the new one.
1565
- local sha_b; sha_b="$(sha "$(cfg)")"
1566
- # P24 起 dispatch 要求任务书声明锚(change: 或 anchor:)——夹具的 P22-x 也补上,否则
1567
- # `dispatch --print` 在渲染启动命令前就被拒(与面板无关的夹具漂移)。
1568
- cat > "$ROOT/docs/team/tasks/P22-x.md" <<'BRIEF'
1569
- # P22-x fixture brief
1570
-
1571
- ```
1572
- task: P22-x
1573
- agent: dev
1574
- issue: -
1575
- change: -
1576
- specs: -
1577
- phase: apply
1578
- deps: -
1579
- anchor: none (infra) — panel-p21 夹具:只为 dispatch --print 渲染启动命令
1580
- status: todo
1581
- budget: -
1582
- ```
1583
-
1584
- body
1585
- BRIEF
1586
- tmux -L "$sock" new-window -d -t "$sess" -n dev -c "$ROOT" 'sleep 900'
1587
- # A stub `pi` so `dispatch --print` can render the command it would run.
1588
- printf '#!/bin/sh\nexit 0\n' > "$tmp/$current-pi.sh"; chmod +x "$tmp/$current-pi.sh"
1589
- ( cd "$ROOT" && bash "$skill/scripts/team" config set TEAM_PI_BIN "$tmp/$current-pi.sh" --yes ) >/dev/null 2>&1
1590
- sleep 0.5
1591
- local win_before; win_before="$(tmux -L "$sock" list-panes -t "$sess:dev" -F '#{pane_start_command}' 2>/dev/null)"
1592
- ( cd "$ROOT" && bash "$skill/scripts/team" config set-agent-model dev kimi-coding/k3-256k --yes ) >/dev/null 2>&1
1593
- sleep 0.5
1594
- assert_eq "运行中的 dev 窗口参数不变" "$(tmux -L "$sock" list-panes -t "$sess:dev" -F '#{pane_start_command}' 2>/dev/null)" "$win_before"
1595
- ( cd "$ROOT" && bash "$skill/scripts/team" dispatch dev P22-x "$ROOT/docs/team/tasks/P22-x.md" --print ) > "$tmp/$current/dispatch.txt" 2>&1
1596
- local wtcmd
1597
- wtcmd="$(sed -n 's/^ 先由 PM 建: //p' "$tmp/$current/dispatch.txt" | head -1)"
1598
- [ -n "$wtcmd" ] && eval "$wtcmd" >/dev/null 2>&1
1599
- ( cd "$ROOT" && bash "$skill/scripts/team" dispatch dev P22-x "$ROOT/docs/team/tasks/P22-x.md" --print ) > "$tmp/$current/dispatch.txt" 2>&1
1600
- assert_has "$tmp/$current/dispatch.txt" "--model k3-256k" "下一次 dispatch --print 用新模型(--provider kimi-coding --model k3-256k)"
1707
+ # 绿侧:真树的 bundle(两个靶子的字节都还原)跑同一段必须全绿
1708
+ bash "$here/panel-p21.sh" policy > "$tmp/flip-green.log" 2>&1
1709
+ local rc_green=$?
1710
+ [ "$rc_green" -eq 0 ] && ok "绿侧:真树 bundle 跑 policy 段全绿" || bad "绿侧:真树也红了(rc=$rc_green)"
1711
+ { grep -a '== 结果 ==' "$tmp/flip-route-red.log" || true; } | grep -q '✗ 0$' && bad "红侧①的结果行是全绿(判据没抓住破坏)" || ok "红侧①的结果行确实不是全绿"
1712
+ printf ' --- 红侧①尾部 ---\n'
1713
+ { grep -aE '✗|== 结果' "$tmp/flip-route-red.log" || true; } | tail -5 | sed 's/^/ /'
1714
+ printf ' --- 红侧②尾部 ---\n'
1715
+ { grep -aE '✗|== 结果' "$tmp/flip-actual-red.log" || true; } | tail -5 | sed 's/^/ /'
1601
1716
  }
1602
1717
 
1603
1718
  scn_readonly() {
@@ -1830,7 +1945,7 @@ PY
1830
1945
  if [ "$rc" -eq 0 ]; then ok "$msg($out)"; else bad "$msg:$out"; fi
1831
1946
  }
1832
1947
 
1833
- # 把焦点走到列表末尾(窗口跟着焦点走),让尾部的「未分组」与席位块同一屏 —— 这两样都在
1948
+ # 把焦点走到列表末尾(窗口跟着焦点走),让尾部的「未分组」与类别块同一屏 —— 这两样都在
1834
1949
  # 「分组之后」,是场景要看的相对顺序。
1835
1950
  walk_to_tail() { # <capture name>
1836
1951
  local i attempt name="${1:-tail}" hit=0
@@ -1838,7 +1953,7 @@ walk_to_tail() { # <capture name>
1838
1953
  for i in $(seq 1 140); do keys Down; sleep 0.01; done
1839
1954
  for i in $(seq 1 12); do
1840
1955
  cap_to "$name"
1841
- if grep -q '席位' "$tmp/$current/$name.txt" && grep -q '›' "$tmp/$current/$name.txt"; then hit=1; break; fi
1956
+ if grep -q '任务类别' "$tmp/$current/$name.txt" && grep -q '›' "$tmp/$current/$name.txt"; then hit=1; break; fi
1842
1957
  sleep 0.4 # 块被 TTL 重读换成摘要行(已知现象)→ 等它回来,必要时再走一轮
1843
1958
  done
1844
1959
  [ "$hit" = 1 ] && break
@@ -1849,6 +1964,9 @@ walk_to_tail() { # <capture name>
1849
1964
  scn_groups() {
1850
1965
  section "groups · 记录带 group、视图按功能域分组(P30/D1-D3):功能域标题/读取顺序/schema 序/未分组降级/无键→域表/徽章词+tone"
1851
1966
  server_up groups
1967
+ # P232:尾部的相对顺序现在是「未分组 → 类别块」,类别块要有行才画得出标题。
1968
+ policy_new 'routine=kimi-coding/k3-256k analysis=openai-codex/gpt-5.6-terra:xhigh' 'openai-codex/gpt-6.1-sol:high' \
1969
+ || bad "策略升级事务没有跑通"
1852
1970
  # 契约里手加一个 schema 不认识的键:它必须落在可见的「未分组」组里(和缺 token 的 schema 行同一条降级路径)。
1853
1971
  printf 'TEAM_HAND_ADDED="hand"\n' >> "$(cfg)"
1854
1972
  conf_set "lang=zh" "page=1" "activity=1" "mouse=1" "density=comfortable" "theme=auto"
@@ -1916,15 +2034,15 @@ scn_groups() {
1916
2034
  filter_clear
1917
2035
  sleep 0.4
1918
2036
  walk_to_tail tail
1919
- local n_ungrouped n_seats
2037
+ local n_ungrouped n_categories
1920
2038
  n_ungrouped="$(cap_line_heading "$tmp/$current/tail.txt" '未分组')"
1921
- n_seats="$(cap_line_heading "$tmp/$current/tail.txt" '席位')"
1922
- if [ "$n_ungrouped" -gt 0 ] && [ "$n_seats" -gt 0 ] && [ "$n_ungrouped" -lt "$n_seats" ]; then
1923
- ok "「未分组」在席位块之前(未分组=$n_ungrouped < 席位=$n_seats)"
2039
+ n_categories="$(cap_line_heading "$tmp/$current/tail.txt" '任务类别')"
2040
+ if [ "$n_ungrouped" -gt 0 ] && [ "$n_categories" -gt 0 ] && [ "$n_ungrouped" -lt "$n_categories" ]; then
2041
+ ok "「未分组」在类别块之前(未分组=$n_ungrouped < 任务类别=$n_categories)"
1924
2042
  else
1925
- bad "尾部顺序不对(未分组=$n_ungrouped 席位=$n_seats)"
2043
+ bad "尾部顺序不对(未分组=$n_ungrouped 任务类别=$n_categories)"
1926
2044
  fi
1927
- assert_match "$tmp/$current/tail.txt" '^│ ── 席位 ─+' "席位块标题也是同一种分节线(标题体系一致)"
2045
+ assert_match "$tmp/$current/tail.txt" '^│ ── 任务类别(未来策略) ─+' "类别块标题也是同一种分节线(标题体系一致)"
1928
2046
  # ⑤ 无键→域表:scratch CLI 让 TEAM_ZZZ_TEST 带 workflow、把 TEAM_GATES 移到 meeting;
1929
2047
  # 提交的那份 bundle 必须跟着两个标题走(bundle 里没有第二张键表/组表)。
1930
2048
  local scratch="$tmp/$current/scratch"
@@ -1992,17 +2110,20 @@ PY
1992
2110
  assert_has "$tmp/$current/tail-scratch.txt" "门禁命令" "降级组里畸形行同屏(schema 行可见)"
1993
2111
  local n_u n_s
1994
2112
  n_u="$(cap_line_heading "$tmp/$current/tail-scratch.txt" '未分组')"
1995
- n_s="$(cap_line_heading "$tmp/$current/tail-scratch.txt" '席位')"
2113
+ n_s="$(cap_line_heading "$tmp/$current/tail-scratch.txt" '任务类别')"
1996
2114
  if [ "$n_u" -gt 0 ] && [ "$n_s" -gt 0 ] && [ "$n_u" -lt "$n_s" ]; then
1997
- ok "scratch 尾部:「未分组」仍在席位块之前($n_u < $n_s)"
2115
+ ok "scratch 尾部:「未分组」仍在类别块之前($n_u < $n_s)"
1998
2116
  else
1999
- bad "scratch 尾部顺序不对(未分组=$n_u 席位=$n_s)"
2117
+ bad "scratch 尾部顺序不对(未分组=$n_u 任务类别=$n_s)"
2000
2118
  fi
2001
2119
  }
2002
2120
 
2003
2121
  scn_wheel_settings() {
2004
2122
  section "wheel · 设置视图自己的窗口(P30/D5):一格一行/焦点不动/计数行跟随/不穿透页面/焦点推窗/两个 picker"
2005
2123
  server_up settings-wheel
2124
+ # P232:类别 picker 用例要有类别可开。
2125
+ policy_new 'routine=kimi-coding/k3-256k analysis=openai-codex/gpt-5.6-terra:xhigh' 'openai-codex/gpt-6.1-sol:high' \
2126
+ || bad "策略升级事务没有跑通"
2006
2127
  # 页面(page 3 的巡检块)要真的滚得动,「页面没被穿透」才有可观察的对照:写满 12 行巡检日志。
2007
2128
  mkdir -p "$state"
2008
2129
  python3 - "$state/watchdog.log" <<'PY'
@@ -2094,36 +2215,34 @@ PY
2094
2215
  || bad "一次 esc 没有关掉选择器(或不在设置视图里了)"
2095
2216
  assert_not "$tmp/$current/picker-closed.txt" " · TEAM_PULSE_INTERVAL" "一次 esc 就把选择器关掉(不穿透)"
2096
2217
  assert_has "$tmp/$current/picker-closed.txt" "╭─ 项目设置" "关闭后仍在设置视图里"
2097
- # ⑤ 席位 picker 的滚轮同样走条目(这一支原来会穿透到页面)。
2098
- filter_to dev
2218
+ # ⑤ 类别 picker 走同一套 widget(条目滚动已在 ④ 证过)。P232:席位 picker 随席位模型一起退休,
2219
+ # 类别 picker 是它的接任者 —— 这里守两件事:它自己的条目列表在滚轮下会走,且页面不因此滚动
2220
+ # (⑥ 关掉视图后仍断言页面停在这一屏)。
2221
+ filter_clear
2222
+ filter_to 类别
2099
2223
  sleep 0.5
2100
- if focus_row 'dev +deepseek'; then
2224
+ if focus_row '› 类别 routine'; then
2101
2225
  keys Enter
2102
2226
  else
2103
- bad "没能把焦点移到 dev 席位行"
2227
+ bad "没能把焦点移到类别 routine 行"
2104
2228
  fi
2105
- # 席位 picker 的标题是「选择 <seat> 的模型」(没有 ` · KEY` 后缀),所以用 pty_wait_frame 等它。
2106
- if pty_wait_frame "$tmp/$current/seat-picker.txt" "seat picker dev" "选择 dev 的模型" "回退默认"; then
2107
- ok "席位 picker 打开(标题 + 已知模型)"
2229
+ # 类别 picker 的标题是「选择类别 <category> 的模型」(没有 ` · KEY` 后缀),用 pty_wait_frame 等它。
2230
+ if pty_wait_frame "$tmp/$current/cat-picker.txt" "类别 picker" "选择类别 routine 的模型" "…(自由输入)"; then
2231
+ ok "类别 picker 打开(标题 + 自由输入项)"
2108
2232
  else
2109
- bad "席位 picker 没有打开"
2233
+ bad "类别 picker 没有打开"
2110
2234
  fi
2111
- cap_to seat-wheel-before
2112
- sel_before="$(cap_line_of "$tmp/$current/seat-wheel-before.txt" '›')"
2235
+ cap_to cat-wheel-before
2236
+ sel_before="$(cap_line_of "$tmp/$current/cat-wheel-before.txt" '›')"
2113
2237
  wheel_at down 20 12 2
2114
- wait_line_gt seat-wheel-after "席位 picker 滚轮把选中行推下去" '›' "${sel_before:-0}" \
2115
- || bad "席位 picker 里的滚轮没有走条目(选中行停在 $sel_before)"
2116
- sel_after="$(cap_line_of "$tmp/$current/seat-wheel-after.txt" '›')"
2117
- if [ "$sel_before" -gt 0 ] && [ "$sel_after" -gt "$sel_before" ]; then
2118
- ok "席位 picker 里的滚轮走条目($sel_before → $sel_after)"
2119
- else
2120
- bad "席位 picker 里的滚轮没有走条目($sel_before → $sel_after)"
2121
- fi
2122
- pty_key_when "席位 picker 的 esc" '选择 dev 的模型' Escape || bad "席位 picker 不在稳定帧上,esc 没有发"
2123
- # P68:等席位 picker 关掉(仍在设置视图里)在稳定帧上。
2124
- wait_row seat-closed "一次 esc 关掉席位 picker" '!选择 dev 的模型' '╭─ 项目设置' \
2125
- || bad "一次 esc 没有关掉席位 picker"
2126
- assert_not "$tmp/$current/seat-closed.txt" "选择 dev 的模型" "一次 esc 关掉席位 picker"
2238
+ sleep 0.6
2239
+ cap_to cat-wheel-after
2240
+ assert_has "$tmp/$current/cat-wheel-after.txt" "选择类别 routine 的模型" "滚轮之后类别 picker 还开着(没穿透)"
2241
+ pty_key_when "类别 picker 的 esc" '选择类别 routine 的模型' Escape || bad "类别 picker 不在稳定帧上,esc 没有发"
2242
+ # P68:等类别 picker 关掉(仍在设置视图里)在稳定帧上。
2243
+ wait_row cat-picker-closed "一次 esc 关掉类别 picker" '!选择类别 routine 的模型' '╭─ 项目设置' \
2244
+ || bad "一次 esc 没有关掉类别 picker"
2245
+ assert_not "$tmp/$current/cat-picker-closed.txt" "选择类别 routine 的模型" "一次 esc 关掉类别 picker"
2127
2246
  # ⑥ 回到页面:视图把滚轮吃掉了 —— 页面还是进视图前的那一屏(P-01 出屏、P-04 可见)。
2128
2247
  pty_key_when "关设置视图" '╭─ 项目设置' Escape || bad "关闭视图前它不在稳定帧上"
2129
2248
  # P68:等浮层自己回到稳定帧上再发第二个 esc(原来是两个固定 sleep 给按键让路)。
@@ -2159,7 +2278,9 @@ for s in "${SECTIONS[@]}"; do
2159
2278
  choices-schema) scn_choices_schema ;;
2160
2279
  write) scn_write ;;
2161
2280
  conflict) scn_conflict ;;
2162
- seats) scn_seats ;;
2281
+ categories) scn_categories ;;
2282
+ policy) scn_policy ;;
2283
+ flip) scn_flip ;;
2163
2284
  readonly) scn_readonly ;;
2164
2285
  *) printf 'panel-p21: 未知场景 %s\n' "$s" >&2; exit 3 ;;
2165
2286
  esac