teamsmith 0.2.0 → 0.3.1

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 (163) hide show
  1. package/README.md +4 -4
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +69 -0
  4. package/skills/teamsmith/SKILL.md +20 -13
  5. package/skills/teamsmith/extension/team-inbox-watch.ts +5 -3
  6. package/skills/teamsmith/extension/team-notify.ts +37 -6
  7. package/skills/teamsmith/extension/team.ts +438 -0
  8. package/skills/teamsmith/references/config.md +39 -6
  9. package/skills/teamsmith/references/migration.md +197 -47
  10. package/skills/teamsmith/references/protocol.md +201 -30
  11. package/skills/teamsmith/references/troubleshooting.md +130 -10
  12. package/skills/teamsmith/references/workflows.md +36 -2
  13. package/skills/teamsmith/scripts/lib/cmd-agents.sh +318 -23
  14. package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +2 -2
  15. package/skills/teamsmith/scripts/lib/cmd-config.sh +349 -67
  16. package/skills/teamsmith/scripts/lib/cmd-draft.sh +4 -4
  17. package/skills/teamsmith/scripts/lib/cmd-help.sh +677 -0
  18. package/skills/teamsmith/scripts/lib/cmd-init.sh +157 -5
  19. package/skills/teamsmith/scripts/lib/cmd-interrupt.sh +461 -0
  20. package/skills/teamsmith/scripts/lib/cmd-meeting.sh +2 -25
  21. package/skills/teamsmith/scripts/lib/cmd-project.sh +30 -103
  22. package/skills/teamsmith/scripts/lib/cmd-reap.sh +277 -0
  23. package/skills/teamsmith/scripts/lib/cmd-reply.sh +3 -3
  24. package/skills/teamsmith/scripts/lib/cmd-review.sh +182 -32
  25. package/skills/teamsmith/scripts/lib/cmd-status.sh +234 -21
  26. package/skills/teamsmith/scripts/lib/cmd-update.sh +36 -7
  27. package/skills/teamsmith/scripts/lib/cmd-watch.sh +564 -46
  28. package/skills/teamsmith/scripts/lib/common.sh +1004 -245
  29. package/skills/teamsmith/scripts/lib/gate-lock.sh +582 -0
  30. package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
  31. package/skills/teamsmith/scripts/panel/panel.js +211 -211
  32. package/skills/teamsmith/scripts/panel/src/App.tsx +58 -21
  33. package/skills/teamsmith/scripts/panel/src/clipboard.ts +12 -5
  34. package/skills/teamsmith/scripts/panel/src/compose.ts +6 -3
  35. package/skills/teamsmith/scripts/panel/src/data.ts +51 -5
  36. package/skills/teamsmith/scripts/panel/src/layout.ts +209 -69
  37. package/skills/teamsmith/scripts/panel/src/main.tsx +37 -8
  38. package/skills/teamsmith/scripts/panel/src/strings/en.ts +39 -29
  39. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +41 -31
  40. package/skills/teamsmith/scripts/panel/src/types.ts +28 -3
  41. package/skills/teamsmith/scripts/replies.mjs +4 -1
  42. package/skills/teamsmith/scripts/shim/killall +10 -0
  43. package/skills/teamsmith/scripts/shim/pgrep +10 -0
  44. package/skills/teamsmith/scripts/shim/pidof +10 -0
  45. package/skills/teamsmith/scripts/shim/pkill +10 -0
  46. package/skills/teamsmith/scripts/shim/signal-gate +108 -31
  47. package/skills/teamsmith/scripts/shim/tmux +18 -0
  48. package/skills/teamsmith/scripts/strings/commands.tsv +86 -0
  49. package/skills/teamsmith/scripts/strings/help.en.tsv +503 -0
  50. package/skills/teamsmith/scripts/strings/help.zh.tsv +489 -0
  51. package/skills/teamsmith/scripts/team +19 -6
  52. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +8 -1
  53. package/skills/teamsmith/templates/config.sh.tmpl +20 -1
  54. package/skills/teamsmith/templates/pm-prompt.md.tmpl +21 -0
  55. package/skills/teamsmith/tests/README.md +31 -0
  56. package/skills/teamsmith/tests/bg-ledger-harness.mjs +464 -40
  57. package/skills/teamsmith/tests/bg-ledger.sh +168 -10
  58. package/skills/teamsmith/tests/checkout-shape-probe.sh +83 -54
  59. package/skills/teamsmith/tests/config-cli.sh +184 -32
  60. package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +7 -1
  61. package/skills/teamsmith/tests/fixtures/p287/lint-good.sh.in +3 -0
  62. package/skills/teamsmith/tests/fixtures/p287/lint-hardcoded.sh.in +3 -0
  63. package/skills/teamsmith/tests/fixtures/p287/lint-no-ns.sh.in +3 -0
  64. package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +18 -6
  65. package/skills/teamsmith/tests/flip-m33.sh +5 -3
  66. package/skills/teamsmith/tests/flip-p158.sh +2 -1
  67. package/skills/teamsmith/tests/flip-p308-skip-not-pass.sh +151 -0
  68. package/skills/teamsmith/tests/flip-p310-lock.sh +210 -0
  69. package/skills/teamsmith/tests/flip-p310-socket.sh +125 -0
  70. package/skills/teamsmith/tests/gate-guard.sh +52 -79
  71. package/skills/teamsmith/tests/help-surface.sh +1664 -0
  72. package/skills/teamsmith/tests/install-shape.sh +359 -22
  73. package/skills/teamsmith/tests/key-replies-pty.sh +9 -10
  74. package/skills/teamsmith/tests/key-replies-ui.sh +2 -8
  75. package/skills/teamsmith/tests/key-replies.sh +281 -28
  76. package/skills/teamsmith/tests/ledger-ban.sh +5 -4
  77. package/skills/teamsmith/tests/ledger-claim.sh +2 -1
  78. package/skills/teamsmith/tests/lib/bounded-spin.sh +90 -0
  79. package/skills/teamsmith/tests/lib/model-policy.sh +4 -0
  80. package/skills/teamsmith/tests/lib/model-routing-flips.py +51 -0
  81. package/skills/teamsmith/tests/lib/pty-wait.sh +21 -111
  82. package/skills/teamsmith/tests/lib/reply-fixture.sh +4 -9
  83. package/skills/teamsmith/tests/lib/section-guard.sh +316 -164
  84. package/skills/teamsmith/tests/lib/tmp-root.sh +139 -27
  85. package/skills/teamsmith/tests/lib/tmux-cap.sh +10 -1
  86. package/skills/teamsmith/tests/lib/tmux-iso.sh +31 -13
  87. package/skills/teamsmith/tests/loop-inventory.tsv +83 -77
  88. package/skills/teamsmith/tests/panel-b2.sh +430 -352
  89. package/skills/teamsmith/tests/panel-b3-stub.sh +112 -4
  90. package/skills/teamsmith/tests/panel-b3.sh +314 -62
  91. package/skills/teamsmith/tests/panel-choices.sh +11 -6
  92. package/skills/teamsmith/tests/panel-cpu.sh +43 -130
  93. package/skills/teamsmith/tests/panel-p21.sh +251 -265
  94. package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
  95. package/skills/teamsmith/tests/panel-strings.mjs +33 -18
  96. package/skills/teamsmith/tests/perf.sh +187 -396
  97. package/skills/teamsmith/tests/routes.sh +440 -117
  98. package/skills/teamsmith/tests/seat-interrupt.sh +1012 -0
  99. package/skills/teamsmith/tests/seat-visibility.sh +675 -0
  100. package/skills/teamsmith/tests/section-guard.sh +13 -102
  101. package/skills/teamsmith/tests/section-needs-audit.sh +24 -7
  102. package/skills/teamsmith/tests/section-paths.tsv +32 -18
  103. package/skills/teamsmith/tests/section-select.sh +371 -19
  104. package/skills/teamsmith/tests/signal-gate.sh +249 -27
  105. package/skills/teamsmith/tests/signal-lint-legacy.txt +4 -1
  106. package/skills/teamsmith/tests/slash-team-e2e.sh +323 -0
  107. package/skills/teamsmith/tests/slash-team.sh +617 -0
  108. package/skills/teamsmith/tests/slice-coverage.sh +206 -0
  109. package/skills/teamsmith/tests/smoke.sh +3595 -788
  110. package/skills/teamsmith/tests/task-model-routing.sh +530 -15
  111. package/skills/teamsmith/tests/team-bg-stop.sh +18 -10
  112. package/skills/teamsmith/tests/tmp-hygiene.sh +782 -45
  113. package/skills/teamsmith/tests/tmux-identity-leak.sh +773 -0
  114. package/skills/teamsmith/tests/tmux-lint-legacy.txt +12 -18
  115. package/skills/teamsmith/tests/upgrade-recipe.sh +537 -0
  116. package/skills/teamsmith/tests/workflow-entry.sh +207 -0
  117. package/skills/teamsmith-init/SKILL.md +12 -12
  118. package/skills/teamsmith-init/references/bootstrap.md +3 -3
  119. package/skills/teamsmith/tests/flip-glue.sh +0 -162
  120. package/skills/teamsmith/tests/flip-m12-26c.sh +0 -129
  121. package/skills/teamsmith/tests/flip-m12.sh +0 -185
  122. package/skills/teamsmith/tests/flip-m16.sh +0 -166
  123. package/skills/teamsmith/tests/flip-m17.sh +0 -204
  124. package/skills/teamsmith/tests/flip-m34.sh +0 -96
  125. package/skills/teamsmith/tests/flip-m37.sh +0 -185
  126. package/skills/teamsmith/tests/flip-m4.3.sh +0 -375
  127. package/skills/teamsmith/tests/flip-m43.sh +0 -128
  128. package/skills/teamsmith/tests/flip-m45.sh +0 -244
  129. package/skills/teamsmith/tests/flip-m46.sh +0 -238
  130. package/skills/teamsmith/tests/flip-m48.sh +0 -304
  131. package/skills/teamsmith/tests/flip-m6.2.sh +0 -205
  132. package/skills/teamsmith/tests/flip-m6.3.sh +0 -283
  133. package/skills/teamsmith/tests/flip-m6.4.sh +0 -267
  134. package/skills/teamsmith/tests/flip-m6.5.sh +0 -113
  135. package/skills/teamsmith/tests/flip-m7.1.sh +0 -135
  136. package/skills/teamsmith/tests/flip-m7.2.sh +0 -321
  137. package/skills/teamsmith/tests/flip-p144.sh +0 -112
  138. package/skills/teamsmith/tests/flip-p156.sh +0 -133
  139. package/skills/teamsmith/tests/flip-p160.sh +0 -182
  140. package/skills/teamsmith/tests/flip-p171.sh +0 -249
  141. package/skills/teamsmith/tests/flip-p18.1.sh +0 -95
  142. package/skills/teamsmith/tests/flip-p20.sh +0 -286
  143. package/skills/teamsmith/tests/flip-p201.sh +0 -249
  144. package/skills/teamsmith/tests/flip-p210.sh +0 -239
  145. package/skills/teamsmith/tests/flip-p211.sh +0 -152
  146. package/skills/teamsmith/tests/flip-p217.sh +0 -288
  147. package/skills/teamsmith/tests/flip-p22.sh +0 -123
  148. package/skills/teamsmith/tests/flip-p23.sh +0 -239
  149. package/skills/teamsmith/tests/flip-p25.sh +0 -165
  150. package/skills/teamsmith/tests/flip-p71.sh +0 -184
  151. package/skills/teamsmith/tests/flip-p72.sh +0 -202
  152. package/skills/teamsmith/tests/load-experiment.sh +0 -290
  153. package/skills/teamsmith/tests/panel-cpu-premise.sh +0 -173
  154. package/skills/teamsmith/tests/panel-flip-m54.sh +0 -207
  155. package/skills/teamsmith/tests/panel-flip-p123.sh +0 -278
  156. package/skills/teamsmith/tests/panel-flip-p125.sh +0 -318
  157. package/skills/teamsmith/tests/panel-flip-p128.sh +0 -259
  158. package/skills/teamsmith/tests/panel-keyprobe-stub.sh +0 -41
  159. package/skills/teamsmith/tests/panel-keyprobe.sh +0 -82
  160. package/skills/teamsmith/tests/panel-knobs.sh +0 -83
  161. package/skills/teamsmith/tests/section-budgets.tsv +0 -154
  162. package/skills/teamsmith/tests/team-bg-flip.sh +0 -239
  163. package/skills/teamsmith/tests/team-inbox-watch-flip.sh +0 -191
@@ -30,70 +30,76 @@
30
30
  # spec:int/seconds/mb/pct/bytes 是「min,max」(空 = 无边);enum 是逗号分隔的值域;
31
31
  # path 是 file|dir|exec|any 加「,opt」(空值有意义);tpl 是 launch|notify|pm
32
32
  # danger:'-' 或一行理由(命中即需要 --allow-danger)
33
- # route:自由文本说明列 —— refuse 类的用法指引,以及 apply 类(frozen 接缝)的备注(面板把它原样展示)
33
+ # route:自由文本说明列 —— 给用户看的说明,面板把它原样画在行下(与命令行的对齐位置见 panel 规格)。
34
+ # 两类标记是数据、不是措辞:只给夹具用的键以 `fixture-only: ` 开头(面板据此隐藏整行),
35
+ # 四个 agent 适配器键的备注说明它们是预留接缝(语义见 memory-and-deps 规格)。
34
36
  # suggest:**可选的第 9 列**,数值类键的建议值(逗号分隔的整值;仍是 schema 数据,不是选项表);
35
37
  # 没有建议的行保持 8 列(读者两形状都认)。读侧(team_config_choices)与写入校验的一致性
36
38
  # 由 tests/panel-choices.sh 的走查夹具钉住:读给出的每个值都必须被 team config set 接受。
37
39
  team_config_schema() {
38
40
  cat <<'EOF'
39
- # ---- 身份与账本布局(refuse:控制台不得改身份、不得搬走它正在读的账本)----
40
- TEAM_PROJECT|refuse|text||plain||-|身份:手改 .pi/team/config.sh(team init 不改它);team init --force 会重渲染整份契约||identity
41
- TEAM_SESSION|refuse|text||plain||-|身份:手改 .pi/team/config.sh(team init 不改它);team init --force 会重渲染整份契约||identity
42
- TEAM_PM_WINDOW|refuse|text||plain|pm|-|身份:手改 .pi/team/config.sh(team init 不改它);team init --force 会重渲染整份契约||identity
43
- TEAM_AGENTS|refuse|list||plain||-|名册:team add-agent <a> --register / team teardown --agent <a> --register(都走审计写入器)||identity
44
- TEAM_DOCS_DIR|refuse|path|dir,opt|plain|docs/team|-|账本布局:手改 .pi/team/config.sh||identity
45
- TEAM_WORKTREES_DIR|refuse|text||plain|.worktrees|-|账本布局:手改 .pi/team/config.sh||identity
46
- TEAM_STATE_DIR|refuse|path|dir,opt|plain|.pi/team/state|-|账本布局:手改 .pi/team/config.sh||identity
47
- TEAM_MEETINGS_DIR|refuse|path|dir,opt|plain|~/.pi/team/meetings|-|账本布局:手改 .pi/team/config.sh||identity
48
- TEAM_SPEC_DIR|refuse|path|dir,opt|plain|openspec|-|账本布局:手改 .pi/team/config.sh||identity
49
- TEAM_ROOT|refuse|path|dir,opt|plain||-|环境定位:用 --root 或手改 .pi/team/config.sh||identity
50
- TEAM_MAIN_ROOT|refuse|path|dir,opt|plain||-|环境定位:用 --root 或手改 .pi/team/config.sh||identity
51
- TEAM_CONFIG_FILE|refuse|path|file,opt|plain||-|环境定位:用 --config 或手改 .pi/team/config.sh||identity
41
+ # ---- 身份与账本(refuse:控制台不得改身份、不得搬走它正在读的账本)----
42
+ TEAM_PROJECT|refuse|text||plain||-|项目身份:只能改项目配置文件 .pi/team/config.sh 里的这一行;team init 不会改它,team init --force 会重写整份文件||identity
43
+ TEAM_SESSION|refuse|text||plain||-|项目身份:只能改项目配置文件 .pi/team/config.sh 里的这一行;team init 不会改它,team init --force 会重写整份文件||identity
44
+ TEAM_PM_WINDOW|refuse|text||plain|pm|-|项目身份:只能改项目配置文件 .pi/team/config.sh 里的这一行;team init 不会改它,team init --force 会重写整份文件||identity
45
+ TEAM_AGENTS|refuse|list||plain||-|席位名单:用 team add-agent <名> --register 添加,team teardown --agent <名> --register 移除||identity
46
+ TEAM_DOCS_DIR|refuse|path|dir,opt|plain|docs/team|-|账本位置:只能改项目配置文件 .pi/team/config.sh||identity
47
+ TEAM_WORKTREES_DIR|refuse|text||plain|.worktrees|-|账本位置:只能改项目配置文件 .pi/team/config.sh||identity
48
+ TEAM_STATE_DIR|refuse|path|dir,opt|plain|.pi/team/state|-|账本位置:只能改项目配置文件 .pi/team/config.sh||identity
49
+ TEAM_MEETINGS_DIR|refuse|path|dir,opt|plain|~/.pi/team/meetings|-|账本位置:只能改项目配置文件 .pi/team/config.sh||identity
50
+ TEAM_SPEC_DIR|refuse|path|dir,opt|plain|openspec|-|账本位置:只能改项目配置文件 .pi/team/config.sh||identity
51
+ TEAM_ROOT|refuse|path|dir,opt|plain||-|位置:启动时用 --root 指定,或改项目配置文件 .pi/team/config.sh||identity
52
+ TEAM_MAIN_ROOT|refuse|path|dir,opt|plain||-|位置:启动时用 --root 指定,或改项目配置文件 .pi/team/config.sh||identity
53
+ TEAM_TMP_ROOT|refuse|path|dir,opt|plain||-|位置:临时根目录(空 = 按 TMPDIR → 平台默认 /var/tmp/teamsmith-<ns> 解析);只能改项目配置文件 .pi/team/config.sh;环境里的 TMPDIR 会盖过它||identity
54
+ TEAM_CONFIG_FILE|refuse|path|file,opt|plain||-|位置:启动时用 --config 指定,或改项目配置文件 .pi/team/config.sh||identity
52
55
  # ---- 分支与 forge(refuse:它们定义「已落地」与凭据位置)----
53
- TEAM_BRANCH_MODE|refuse|enum|task,agent|plain|task|-|分支语义(定义「已落地」):手改 .pi/team/config.sh||branch
54
- TEAM_TASK_BRANCH_PREFIX|refuse|text||plain|task|-|分支语义:手改 .pi/team/config.sh||branch
55
- TEAM_AGENT_BRANCH_PREFIX|refuse|text||plain|agent|-|分支语义:手改 .pi/team/config.sh||branch
56
- TEAM_PROTECTED_BRANCH|refuse|text||plain|main|-|分支语义:手改 .pi/team/config.sh||branch
57
- TEAM_REMOTE|refuse|text||plain|origin|-|分支语义:手改 .pi/team/config.sh||branch
58
- TEAM_VCS|refuse|enum|local,github,gitlab,other|plain|local|-|分支语义/forge:手改 .pi/team/config.sh||branch
59
- TEAM_TOKEN_FILE|refuse|path|file,opt|plain|.gh-pat|-|凭据位置:手改 .pi/team/config.sh||branch
60
- TEAM_GITLAB_HOST|refuse|text||plain||-|凭据位置:手改 .pi/team/config.sh||branch
61
- TEAM_GITLAB_PROJECT|refuse|text||plain||-|凭据位置:手改 .pi/team/config.sh||branch
62
- TEAM_GITLAB_TOKEN_FILE|refuse|path|file,opt|plain||-|凭据位置:手改 .pi/team/config.sh||branch
56
+ TEAM_BRANCH_MODE|refuse|enum|task,agent|plain|task|-|分支与落地判定:只能改项目配置文件 .pi/team/config.sh||branch
57
+ TEAM_TASK_BRANCH_PREFIX|refuse|text||plain|task|-|分支与落地判定:只能改项目配置文件 .pi/team/config.sh||branch
58
+ TEAM_AGENT_BRANCH_PREFIX|refuse|text||plain|agent|-|分支与落地判定:只能改项目配置文件 .pi/team/config.sh||branch
59
+ TEAM_PROTECTED_BRANCH|refuse|text||plain|main|-|分支与落地判定:只能改项目配置文件 .pi/team/config.sh||branch
60
+ TEAM_REMOTE|refuse|text||plain|origin|-|分支与落地判定:只能改项目配置文件 .pi/team/config.sh||branch
61
+ TEAM_VCS|refuse|enum|local,github,gitlab,other|plain|local|-|托管平台:只能改项目配置文件 .pi/team/config.sh||branch
62
+ TEAM_TOKEN_FILE|refuse|path|file,opt|plain|.gh-pat|-|凭据文件位置:只能改项目配置文件 .pi/team/config.sh||branch
63
+ TEAM_GITLAB_HOST|refuse|text||plain||-|凭据文件位置:只能改项目配置文件 .pi/team/config.sh||branch
64
+ TEAM_GITLAB_PROJECT|refuse|text||plain||-|凭据文件位置:只能改项目配置文件 .pi/team/config.sh||branch
65
+ TEAM_GITLAB_TOKEN_FILE|refuse|path|file,opt|plain||-|凭据文件位置:只能改项目配置文件 .pi/team/config.sh||branch
63
66
  TEAM_MERGE_PREFER_THEIRS|apply|text||plain||-|||branch
64
- # ---- 权限与依赖策略(refuse:控制台不得给自己扩权)----
65
- TEAM_CONFIRM_WRITES|refuse|bool||plain|1|-|权限守卫:控制台不给自己扩权;手改 .pi/team/config.sh||policy
66
- TEAM_ALLOW_FOREIGN_IDENTITY|refuse|bool||plain|0|-|权限守卫:手改 .pi/team/config.sh||policy
67
- TEAM_ALLOW_FOREIGN_SESSION|refuse|bool||plain|0|-|权限守卫:手改 .pi/team/config.sh||policy
68
- TEAM_GUARD_FOREIGN_TARGET|refuse|bool||plain|1|-|权限守卫:手改 .pi/team/config.sh||policy
69
- TEAM_REPLACE_FOREIGN_PM|refuse|bool||plain|0|-|权限守卫:手改 .pi/team/config.sh||policy
70
- TEAM_ALLOW_DESTRUCTIVE_TMUX|refuse|bool||plain|0|-|权限守卫(M67 退役):不再授权任何操作(判定按目标);保留为不接受写入的只读墓碑,手改 .pi/team/config.sh||policy
71
- TEAM_ASSUME_YES|refuse|bool||plain|0|-|权限守卫:手改 .pi/team/config.sh||policy
72
- TEAM_REQUIRE_JS|refuse|bool||plain|1|-|依赖策略:手改 .pi/team/config.sh||policy
73
- TEAM_REQUIRE_OPENSPEC|refuse|bool||plain|1|-|依赖策略:手改 .pi/team/config.sh||policy
74
- TEAM_REQUIRE_MAGIC_CONTEXT|refuse|bool||plain|1|-|依赖策略:手改 .pi/team/config.sh||policy
75
- TEAM_PI_AGENT_DIR|refuse|path|dir,opt|plain||-|机器路径:手改 .pi/team/config.sh||policy
76
- TEAM_PI_SETTINGS_FILE|refuse|path|file,opt|plain|$HOME/.pi/agent/settings.json|-|机器路径:手改 .pi/team/config.sh||policy
77
- TEAM_MEMINFO_FILE|refuse|path|file,opt|plain||-|机器路径:手改 .pi/team/config.sh||policy
78
- TEAM_DISK_STATS_FILE|refuse|path|file,opt|plain||-|测试旋钮:磁盘读数夹具(TEAM_MEMINFO_FILE 同族);只在夹具里用||policy
79
- TEAM_SMOKE_FAST|refuse|bool||plain|0|-|测试旋钮:环境变量或手改 .pi/team/config.sh||policy
80
- TEAM_INBOX_WATCH_FORCE_FAIL|refuse|text||plain||-|测试旋钮(M53):强制 watcher 注册失败路径,记录标 forced=1;只在夹具里用||policy
81
- TEAM_IW_REQUIRE_WATCH|refuse|bool||plain|0|-|测试旋钮(M53):inbox-watch 门禁严格模式——不可用的前提判红而不是可见 SKIP||policy
67
+ # ---- 权限与依赖(refuse:控制台不得给自己扩权)----
68
+ TEAM_CONFIRM_WRITES|refuse|bool||plain|1|-|权限:只能改项目配置文件 .pi/team/config.sh(面板不给自己扩权)||policy
69
+ TEAM_ALLOW_FOREIGN_IDENTITY|refuse|bool||plain|0|-|权限:只能改项目配置文件 .pi/team/config.sh(面板不给自己扩权)||policy
70
+ TEAM_ALLOW_FOREIGN_SESSION|refuse|bool||plain|0|-|权限:只能改项目配置文件 .pi/team/config.sh(面板不给自己扩权)||policy
71
+ TEAM_GUARD_FOREIGN_TARGET|refuse|bool||plain|1|-|权限:只能改项目配置文件 .pi/team/config.sh(面板不给自己扩权)||policy
72
+ TEAM_REPLACE_FOREIGN_PM|refuse|bool||plain|0|-|权限:只能改项目配置文件 .pi/team/config.sh(面板不给自己扩权)||policy
73
+ TEAM_ALLOW_DESTRUCTIVE_TMUX|refuse|bool||plain|0|-|已退役:不再授权任何操作,只保留为不可写的记录行,只能改项目配置文件 .pi/team/config.sh||policy
74
+ TEAM_ASSUME_YES|refuse|bool||plain|0|-|权限:只能改项目配置文件 .pi/team/config.sh(面板不给自己扩权)||policy
75
+ TEAM_REQUIRE_JS|refuse|bool||plain|1|-|依赖要求:只能改项目配置文件 .pi/team/config.sh||policy
76
+ TEAM_REQUIRE_OPENSPEC|refuse|bool||plain|1|-|依赖要求:只能改项目配置文件 .pi/team/config.sh||policy
77
+ TEAM_REQUIRE_MAGIC_CONTEXT|refuse|bool||plain|1|-|依赖要求:只能改项目配置文件 .pi/team/config.sh||policy
78
+ TEAM_PI_AGENT_DIR|refuse|path|dir,opt|plain||-|这台机器上的路径:只能改项目配置文件 .pi/team/config.sh||policy
79
+ TEAM_PI_SETTINGS_FILE|refuse|path|file,opt|plain|$HOME/.pi/agent/settings.json|-|这台机器上的路径:只能改项目配置文件 .pi/team/config.sh||policy
80
+ TEAM_MEMINFO_FILE|refuse|path|file,opt|plain||-|这台机器上的路径:只能改项目配置文件 .pi/team/config.sh||policy
81
+ TEAM_DISK_STATS_FILE|refuse|path|file,opt|plain||-|fixture-only: 只在测试套件里用(磁盘读数夹具)||policy
82
+ TEAM_SMOKE_FAST|refuse|bool||plain|0|-|fixture-only: 只在测试套件里用(冒烟快模式)||policy
83
+ TEAM_INBOX_WATCH_FORCE_FAIL|refuse|text||plain||-|fixture-only: 只在测试套件里用(强制 watcher 注册失败)||policy
84
+ TEAM_IW_REQUIRE_WATCH|refuse|bool||plain|0|-|fixture-only: 只在测试套件里用(记录严格模式)||policy
82
85
  # ---- 名册、模型解析与适配器(apply:下一个读契约的进程就生效)----
83
86
  TEAM_MODEL_LIMITS|apply|pattern||plain|kimi-coding/k3=2 openai-codex/*=1|-|||roster
84
87
  TEAM_MODEL_WINDOWS|apply|winlist||plain||-|||roster
85
88
  TEAM_SESSION_WARN_TOKENS|apply|int|0,|plain|200000|-||100000,200000,400000|roster
86
89
  TEAM_EXTRA_PI_ARGS|apply|cmd||plain||-|||roster
87
- TEAM_AGENT_CMD|apply|tpl|launch|plain||-|内部接缝(frozen):为将来非 Pi 适配预留,不承诺兼容;不在 init 问卷里问||roster
88
- TEAM_AGENT_NOTIFY_CMD|apply|tpl|notify|plain||-|内部接缝(frozen):为将来非 Pi 适配预留,不承诺兼容;不在 init 问卷里问||roster
89
- TEAM_AGENT_LOG_GLOB|apply|text||plain||-|内部接缝(frozen):为将来非 Pi 适配预留,不承诺兼容;不在 init 问卷里问||roster
90
+ TEAM_AGENT_CMD|apply|tpl|launch|plain||-|预留:为以后可能更换的 agent 适配器保留,不是受支持的扩展方式,也不承诺兼容;新项目初始化时不问||roster
91
+ TEAM_AGENT_NOTIFY_CMD|apply|tpl|notify|plain||-|预留:为以后可能更换的 agent 适配器保留,不是受支持的扩展方式,也不承诺兼容;新项目初始化时不问||roster
92
+ TEAM_AGENT_LOG_GLOB|apply|text||plain||-|预留:为以后可能更换的 agent 适配器保留,不是受支持的扩展方式,也不承诺兼容;新项目初始化时不问||roster
90
93
  TEAM_PI_BIN|apply|path|exec|plain|pi|-|||roster
91
- TEAM_AGENT_BIN|apply|path|exec,opt|plain||-|内部接缝(frozen):为将来非 Pi 适配预留,不承诺兼容;不在 init 问卷里问||roster
94
+ TEAM_AGENT_BIN|apply|path|exec,opt|plain||-|预留:为以后可能更换的 agent 适配器保留,不是受支持的扩展方式,也不承诺兼容;新项目初始化时不问||roster
92
95
  TEAM_OPENSPEC_BIN|apply|path|exec|plain|openspec|-|||roster
93
96
  TEAM_JS_BIN|apply|path|exec,opt|plain||-|||roster
94
- # ---- Future policy, separate from committed assignments ----
95
- TEAM_TASK_MODELS|apply|task-model-map|req|plain||-|新任务类别:team config set-task-model <category> <model>;恢复保留已派身份||task-model
96
- TEAM_PM_MODEL|restart|model|req|plain||-|独立 PM 模型:team up 启动受 fresh-pm 守卫||task-model
97
+ # ---- 未来策略与已派记录分开 ----
98
+ TEAM_TASK_MODELS|apply|task-model-map|req|plain||-|新任务用哪个模型:用 team config set-task-model <类别> <模型> 改;已经派出去的任务保留它当时的模型||task-model
99
+ TEAM_PM_MODEL|restart|model|req|plain||-|PM 用哪个模型:下次 team up 启动时生效,换模型要用 --fresh-pm;旧记录缺失或不一致时按 pm-lifecycle 合同处理||task-model
100
+ # ---- 工具自身(配置形状号与版本提示;P261 · startup-self-heal)----
101
+ TEAM_CONFIG_VERSION|refuse|int|1,|plain|2|-|配置形状号(工具写、命令不写):新项目由 init/bootstrap 写,旧项目由启动事务(见 references/migration.md)迁移时写;高于本工具已知最新的形状号直接拒绝。行为证据:tests/task-model-routing.sh 的 heal 组||task-model
102
+ TEAM_UPDATE_CHECK|apply|bool||plain|1|-|启动路径上的 npm 版本提示:0 = 连查询都不发生(不读不写缓存);只有本地落后时打一行,工具从不自己安装。行为证据:tests/task-model-routing.sh 的 updatecheck 组||workflow
97
103
  # ---- 工作流与门禁(apply)----
98
104
  TEAM_GATES|apply|cmd||plain||-|||workflow
99
105
  TEAM_INSTALL_CMD|apply|cmd||plain||-|||workflow
@@ -121,10 +127,15 @@ TEAM_AGENT_MEM_MB|apply|mb|1,|plain|6144|-||2048,4096,6144|delivery
121
127
  TEAM_NOTIFY_TMUX|apply|bool||plain|1|-|||delivery
122
128
  TEAM_NOTIFY_DEDUP_SEC|apply|seconds|0,|plain|20|-|||delivery
123
129
  TEAM_INBOX_MAX_CHARS|apply|int|1,|plain|150|-||100,150,300|delivery
130
+ TEAM_NOTIFY_DETAIL_MAX|apply|int|1,|plain|2048|state/notify.log 的事件上界:越界轮转到 state/notify.log.1(只留一代)||512,2048,8192|delivery
124
131
  TEAM_NOTIFY_LOG|apply|path|file,opt|plain|/tmp/teamsmith-notify.log|-|||delivery
125
132
  TEAM_DEFER_TTL|apply|seconds|0,|plain|300|0 = 投递队列入队即过期||60,300,900|delivery
126
133
  TEAM_OUTBOX_MAX|apply|int|0,|plain|200|0 = 队列不设上限(无界)||50,200,1000|delivery
127
134
  TEAM_PANEL_DETAIL_CAP|apply|bytes|1024,|plain|131072|-||65536,131072,262144|delivery
135
+ # P276(change: orphan-visibility):孤儿席位进程的阈值提示、普查开关与夹具接缝。
136
+ TEAM_ORPHAN_WARN_MB|apply|mb|0,|plain|1024|0 = 没有阈值提示(digest 的容量行不再追加孤儿提示)||512,1024,2048|delivery
137
+ TEAM_ORPHAN_SCAN|apply|bool||plain|1|0 = 完全不扫 /proc(读数只剩一行点名的跳过;team reap --orphans 也随之不可用)|||delivery
138
+ TEAM_ORPHAN_PROC_ROOT|refuse|path|dir|plain|/proc|-|fixture-only: 只在测试套件里用(普查的 /proc 接缝:确定性地造「读不到 / 中途消失 / 空环境 / 缺字段」四种边界)||delivery
128
139
  # ---- 巡检与面板(restart:运行中的 pulse/面板拿着启动时的值)----
129
140
  TEAM_PULSE_INTERVAL|restart|seconds|60,|plain|900|低于 60 秒 = 巡检转成忙等||300,900,1800,3600|panel
130
141
  TEAM_MONITOR_REFRESH|restart|seconds|1,|plain|3|-||2,3,5|panel
@@ -133,7 +144,7 @@ TEAM_MONITOR_UI|restart|enum|auto,tui,text|plain|auto|-|||panel
133
144
  TEAM_MONITOR_ACTIVITY|restart|bool||export|1|-|||panel
134
145
  TEAM_AGENT_LOG_TAIL_BYTES|restart|bytes|0,1048576|export||-|||panel
135
146
  TEAM_PULSE_WINDOW|restart|text||plain|pulse|改的是运行中后端的窗口名:team pulse down(旧名)→ 改 → team pulse up|||panel
136
- # ---- 巡检策略(apply:一拍一个 team watch --once 子进程)----
147
+ # ---- 巡检(apply:一拍一个 team watch --once 子进程)----
137
148
  TEAM_PULSE_NUDGE_GAP|apply|seconds|0,|plain|900|-||300,900,1800|patrol
138
149
  TEAM_PULSE_PENDING_BOARD|apply|bool||plain|0|-|||patrol
139
150
  TEAM_PULSE_REBUILD_TMUX|apply|bool||plain|0|-|||patrol
@@ -156,10 +167,10 @@ TEAM_INBOX_WATCH_POLL_MS|restart|int|100,|export|5000|-|||session
156
167
  TEAM_INBOX_WATCH_HEARTBEAT_MS|restart|int|100,|export|5000|-|||session
157
168
  TEAM_INBOX_WATCH_TARGET|restart|text||export||-|||session
158
169
  TEAM_BG_LOG_MAX_BYTES|restart|bytes|1024,|export|524288|-|||session
159
- # ---- 信号纪律(P159 · refuse:闸门接缝与宽限由手改契约控制)----
160
- TEAM_SIGNAL_CALLS_LOG|refuse|path|file,opt|plain||-|P159 信号闸门:每次调用一行(拒绝另存 <log>.forensics,熬得过轮转);窗口启动时由闸门前缀钉值,要改就手改 .pi/team/config.sh||policy
161
- TEAM_SIGNAL_REAL|refuse|path|exec,opt|plain||-|P159 信号闸门的真身路径(夹具钉桩用;拒绝不依赖它能否解析);手改 .pi/team/config.sh||policy
162
- TEAM_BG_STOP_GRACE|refuse|seconds|0,|plain|5|-|P159 team bg stop 的宽限:组 TERM 之后等这么多秒再 KILL(0 = 不等待,立刻升级);手改 .pi/team/config.sh||policy
170
+ # ---- 信号纪律(refuse:闸门与宽限只能改契约文件)----
171
+ TEAM_SIGNAL_CALLS_LOG|refuse|path|file,opt|plain||-|信号调用记录:每次调用写一行(拒绝另存 <log>.forensics,熬得过轮转);窗口启动时由闸门前缀钉值,只能改项目配置文件 .pi/team/config.sh||policy
172
+ TEAM_SIGNAL_REAL|refuse|path|exec,opt|plain||-|信号程序的位置(测试钉桩用,拒绝不依赖它能否解析):只能改项目配置文件 .pi/team/config.sh||policy
173
+ TEAM_BG_STOP_GRACE|refuse|seconds|0,|plain|5|-|停止后台作业前的等待秒数:组 TERM 之后等这么多秒再 KILL(0 = 不等待,立刻升级);只能改项目配置文件 .pi/team/config.sh||policy
163
174
  # ---- 跨项目会议(apply)----
164
175
  TEAM_MEETING_TTL_HOURS|apply|int|1,|plain|72|-||24,72,168|meeting
165
176
  TEAM_MEETING_MAX_TURNS|apply|int|1,|plain|20|-||5,20,50|meeting
@@ -256,7 +267,7 @@ team_config_key_form() { # <KEY> → plain|export(未知键 = plain)
256
267
  }
257
268
 
258
269
  # notify 扩展用扁平 KEY="value" 读取器解析的八个键:值里出现 ' 就没有转义可用 → 拒写(设计 §4)。
259
- TEAM_CONFIG_FLAT_KEYS=" TEAM_SESSION TEAM_PM_WINDOW TEAM_WORKTREES_DIR TEAM_DOCS_DIR TEAM_NOTIFY_TMUX TEAM_NOTIFY_DEDUP_SEC TEAM_INBOX_MAX_CHARS TEAM_NOTIFY_LOG "
270
+ TEAM_CONFIG_FLAT_KEYS=" TEAM_SESSION TEAM_PM_WINDOW TEAM_WORKTREES_DIR TEAM_DOCS_DIR TEAM_NOTIFY_TMUX TEAM_NOTIFY_DEDUP_SEC TEAM_INBOX_MAX_CHARS TEAM_NOTIFY_LOG TEAM_NOTIFY_DETAIL_MAX "
260
271
  team_config_flat_key() { # <KEY> → 0 = 扁平读取器的键
261
272
  case "$TEAM_CONFIG_FLAT_KEYS" in *" $1 "*) return 0 ;; esac
262
273
  return 1
@@ -328,13 +339,13 @@ team_config_validate_value() {
328
339
  local key="$1" val="${2-}" row class kind spec form
329
340
  row="$(team_config_row "$key" 2>/dev/null || true)"
330
341
  if [ -z "$row" ]; then
331
- printf '不是已知的项目设置键(references/config.md 是清单);自定义键请手改 .pi/team/config.sh\n'
342
+ printf '不是已知的项目设置键(references/config.md 是清单);自定义键写在 .pi/team/config.sh 里\n'
332
343
  return 1
333
344
  fi
334
345
  class="$(team_config_field "$row" 2)"; kind="$(team_config_field "$row" 3)"
335
346
  spec="$(team_config_field "$row" 4)"; form="$(team_config_field "$row" 5)"
336
347
  if [ "$class" = "refuse" ]; then
337
- printf '只读键(%s)\n' "$(team_config_field "$row" 8)"
348
+ printf '不能由命令改(%s)\n' "$(team_config_field "$row" 8)"
338
349
  return 1
339
350
  fi
340
351
  case "$val" in
@@ -729,7 +740,12 @@ team_config_list_json() {
729
740
  policy_pm="$TEAM_PM_MODEL"; known_models="$known_models$policy_pm"$'\n'
730
741
  fi
731
742
  for a in $(team_agents); do
732
- local assigned=false diagnostic='' fields='' field val
743
+ local assigned=false diagnostic='' fields='' field val present=false
744
+ # memory-and-deps 的 `record_present` 回答的是「这个席位到底有没有一份记录文件」:文件在、即使读不
745
+ # 出来或不带 assignment 字段也算有(否则面板会对着一个真用过的席位说「还没派过任务」)。
746
+ # 现成的 `team_assignment_record_present` 回答的是另一个问题(「文件自称是一份 assignment 记录」——
747
+ # 没有 assignment 字段的历史/无关文件它报 false),所以这里的判据是文件本身在不在。
748
+ [ -f "$TEAM_STATE_DIR/$a.env" ] && present=true
733
749
  if team_assignment_load "$a"; then
734
750
  assigned=true
735
751
  # P228/R6(OBS1):未交付的模型不进「已知模型」,也不当成该席位的模型
@@ -745,7 +761,7 @@ team_config_list_json() {
745
761
  team_config_json_escape_set "$val"; fields="$fields,\"identity_via\":\"$CFG_ESC\""
746
762
  team_config_json_escape_set "$diagnostic"; local ed="$CFG_ESC"
747
763
  team_config_json_escape_set "$a"
748
- assignments="${assignments:+$assignments,}{\"agent\":\"$CFG_ESC\",\"assigned\":$assigned$fields,\"diagnostic\":\"$ed\"}"
764
+ assignments="${assignments:+$assignments,}{\"agent\":\"$CFG_ESC\",\"assigned\":$assigned,\"record_present\":$present$fields,\"diagnostic\":\"$ed\"}"
749
765
  done
750
766
  if team_pm_metadata_load; then
751
767
  pm_launch="$TEAM_PM_METADATA_JSON"; known_models="$known_models$TEAM_PM_SELECTED_MODEL"$'\n'
@@ -808,7 +824,7 @@ team_config_list_json() {
808
824
  team_config_json_escape_set "$v"; local u_val="$CFG_ESC"
809
825
  team_config_json_escape_set "$c"; local u_com="$CFG_ESC"
810
826
  team_config_choices_set ""
811
- out="$out,{\"name\":\"$u_key\",\"class\":\"refuse\",\"kind\":\"text\",\"form\":\"plain\",\"value\":\"$u_val\",\"default\":\"\",\"set\":true,\"comment\":\"$u_com\",\"warning\":\"不是已知的项目设置(见 references/config.md);手改 .pi/team/config.sh\",\"choices\":$CFG_CHOICES_JSON,\"group\":\"\",\"known\":false}"
827
+ out="$out,{\"name\":\"$u_key\",\"class\":\"refuse\",\"kind\":\"text\",\"form\":\"plain\",\"value\":\"$u_val\",\"default\":\"\",\"set\":true,\"comment\":\"$u_com\",\"warning\":\"不是已知的项目设置(见 references/config.md);只能改项目配置文件 .pi/team/config.sh\",\"choices\":$CFG_CHOICES_JSON,\"group\":\"\",\"known\":false}"
812
828
  done <<< "$CFG_SCAN_ORDER"
813
829
 
814
830
 
@@ -893,17 +909,29 @@ team_config_write_checked_unlocked() { # <KEY> <value> <actor> <dry> <fp> <allow
893
909
  local row; row="$(team_config_row "$key" 2>/dev/null || true)"
894
910
  local old; old="$(team_config_file_value "$path" "$key" 2>/dev/null || true)"
895
911
 
912
+ # P261(返修 O1)· 退休配置上的 config 写路径:任何字节之前拒绝并指向升级。写下去会留下半迁移状态
913
+ # (退休键还在、新键也写了,而新引擎只读新键);建议命令与自动迁移共用同一张推导表(design §3),
914
+ # 所以这里没有第二份文案。拒绝不发审计行:这不是对某个值的拒绝,是这个项目还没迁移(前扪 init/bootstrap
915
+ # 的「任何写入之前停住」同一口径)。
916
+ local legacy_keys; legacy_keys="$(team_config_retired_keys_in_file "$path")"
917
+ if [ -n "$legacy_keys" ]; then
918
+ team_err "$key:$path 还在用退休的模型键($(printf '%s' "$legacy_keys" | tr '\n' ' '))—— 写盘之前停住"
919
+ team_dim " 项目模型策略是破坏式升级:config set 不是迁移路径" >&2
920
+ team_legacy_model_route_lines "$path" >&2
921
+ return "$TEAM_CONFIG_EXIT_REFUSE"
922
+ fi
923
+
896
924
  if [ -z "$row" ]; then
897
925
  team_err "$key 不是已知的项目设置键"
898
926
  case "$key" in TEAM_DEFAULT_MODEL|TEAM_AGENT_MODELS)
899
927
  team_dim " retired: $TEAM_CLI config set-task-model <category> <model>;config set TEAM_PM_MODEL <model>;config upgrade-models" >&2 ;;
900
- *) team_dim " 已知键:$TEAM_CLI config list;自定义键请手改 $path" >&2 ;; esac
928
+ *) team_dim " 已知键:$TEAM_CLI config list;自定义键写在 $path 里" >&2 ;; esac
901
929
  [ "$dry" = "1" ] || team_config_audit_write refused "$actor" "$key" "$old" "$val" || true
902
930
  return "$TEAM_CONFIG_EXIT_REFUSE"
903
931
  fi
904
932
  local class kind; class="$(team_config_field "$row" 2)"; kind="$(team_config_field "$row" 3)"
905
933
  if [ "$class" = "refuse" ]; then
906
- team_err "$key 是只读键,控制台不改它"
934
+ team_err "$key 不能由命令改"
907
935
  team_dim " $(team_config_field "$row" 8)" >&2
908
936
  [ "$dry" = "1" ] || team_config_audit_write refused "$actor" "$key" "$old" "$val" || true
909
937
  return "$TEAM_CONFIG_EXIT_REFUSE"
@@ -1109,7 +1137,7 @@ team_cmd_config_set_agent_model() {
1109
1137
  [ "$seat" = "pm" ] && audit_key="TEAM_PM_MODEL"
1110
1138
  if ! team_config_seat_known "$seat"; then
1111
1139
  team_err "未知席位 $seat:名册是($(team_config_roster_text))加 pm"
1112
- team_dim " 名册的键是 TEAM_AGENTS(只读):$TEAM_CLI add-agent $seat --register(或 team teardown --agent $seat --register)" >&2
1140
+ team_dim " 名册的键是 TEAM_AGENTS(不能由命令改):$TEAM_CLI add-agent $seat --register(或 team teardown --agent $seat --register)" >&2
1113
1141
  [ "$dry" = "1" ] || team_config_audit_write refused "$actor" "$audit_key" "$seat" "$model" || true
1114
1142
  return "$TEAM_CONFIG_EXIT_REFUSE"
1115
1143
  fi
@@ -1220,6 +1248,237 @@ team_config_model_source_shape() {
1220
1248
  fi
1221
1249
  done < "$path"
1222
1250
  }
1251
+ # ---------------------------------------------------------------- 迁移决策(唯一推导表;P261 · startup-self-heal)
1252
+ # 纯决策层:读文件、算计划、给拒绝理由 —— 一个字节都不写。编排(打印/备份/写入/exec)在 cmd-watch.sh 的
1253
+ # team_cmd_up,拒绝建议在 common.sh 的 team_model_policy_issues —— 三处**共用**本节的推导表,不许长第二份。
1254
+ # 形状判定顺序(design §2):标记(TEAM_CONFIG_VERSION)→ 键(有退休键 = 1)→ 表;标记高于已知最新 → 拒绝。
1255
+ TEAM_CONFIG_SHAPE_RETIRED=1
1256
+ TEAM_CONFIG_SHAPE_CURRENT=2
1257
+ team_config_migration_table() { # 一行一条迁移:id|from|to|introduced;加一条迁移 = 加一行 + 一个 transform + 一组夹具
1258
+ cat <<'EOF'
1259
+ m1|1|2|0.2.0
1260
+ EOF
1261
+ }
1262
+ team_config_migration_introduced() { # <from> → 引入该行的工具版本(备份名与 --print 预告用)
1263
+ local id from to introduced
1264
+ while IFS='|' read -r id from to introduced; do
1265
+ case "$id" in ''|'#'*) continue ;; esac
1266
+ [ "$1" = "$from" ] && { printf '%s\n' "$introduced"; return 0; }
1267
+ done < <(team_config_migration_table)
1268
+ printf '%s\n' '0.0.0'
1269
+ }
1270
+ # 文件里有没有某个键的赋值行(注释行不算);与 team_model_policy_issues 的旧判据同一形状。
1271
+ team_config_file_key_present() { # <path> <KEY> → 0 = 在文件里有赋值行
1272
+ grep -vE '^[[:space:]]*#' "$1" 2>/dev/null | grep -Eq "(^|[^A-Za-z0-9_])$2([[:space:]]*=|[[:space:]])"
1273
+ }
1274
+ team_config_retired_keys_in_file() { # <path> → 每行一个文件里的退休键(TEAM_AGENT_MODELS / TEAM_DEFAULT_MODEL)
1275
+ local key
1276
+ for key in TEAM_AGENT_MODELS TEAM_DEFAULT_MODEL; do
1277
+ team_config_file_key_present "$1" "$key" && printf '%s\n' "$key"
1278
+ done
1279
+ return 0
1280
+ }
1281
+ team_config_shape_read() { # <path> → 0/5;形状号在 TEAM_CONFIG_SHAPE,原因在 TEAM_CONFIG_SHAPE_WHY
1282
+ local path="$1" marker
1283
+ TEAM_CONFIG_SHAPE=''; TEAM_CONFIG_SHAPE_WHY=''
1284
+ marker="$(team_config_file_value "$path" TEAM_CONFIG_VERSION 2>/dev/null || true)"
1285
+ if [ -n "$marker" ]; then
1286
+ case "$marker" in
1287
+ *[!0-9]*) TEAM_CONFIG_SHAPE_WHY="TEAM_CONFIG_VERSION 不是整数:$marker"; return 5 ;;
1288
+ esac
1289
+ if [ "$marker" -gt "$TEAM_CONFIG_SHAPE_CURRENT" ]; then
1290
+ TEAM_CONFIG_SHAPE_WHY="这个项目的配置形状号是 $marker,本工具只知道到 $TEAM_CONFIG_SHAPE_CURRENT(不拿旧行去套新形状)"
1291
+ return 5
1292
+ fi
1293
+ TEAM_CONFIG_SHAPE="$marker"; return 0
1294
+ fi
1295
+ if [ -n "$(team_config_retired_keys_in_file "$path")" ]; then
1296
+ TEAM_CONFIG_SHAPE="$TEAM_CONFIG_SHAPE_RETIRED"; return 0
1297
+ fi
1298
+ TEAM_CONFIG_SHAPE="$TEAM_CONFIG_SHAPE_CURRENT"
1299
+ }
1300
+ # 类别名规范化(design §3 的唯一规则):小写、其它字符折成 `-`、折叠并修剪 `-`;结果必须匹配
1301
+ # `^[a-z][a-z0-9-]*$`,否则**拒绝**(不偷偷加前缀 —— 静默改值就是另一条口径)。
1302
+ team_config_category_normalize() { # <旧席位名> → stdout 规范化结果(调用方再用 team_category_valid 判)
1303
+ printf '%s' "${1-}" | tr 'A-Z' 'a-z' | sed -E 's/[^a-z0-9-]+/-/g; s/-+/-/g; s/^-+//; s/-+$//'
1304
+ }
1305
+ # 迁移决策:action=none(已是当前形状)/ action=apply(有可套用的迁移行)/ 非 0 = 拒绝。
1306
+ # 拒绝时 TEAM_MIGRATION_WHY 是点名障碍的人话,TEAM_MIGRATION_SHAPE 是分类名(design §4 八类)。
1307
+ team_config_migration_decide() { # <path>
1308
+ local path="$1" shape=''
1309
+ TEAM_MIGRATION_ACTION=''; TEAM_MIGRATION_WHY=''; TEAM_MIGRATION_SHAPE=''
1310
+ if [ -n "${TEAM_MODEL_RETIRED_ENV:-}" ]; then
1311
+ TEAM_MIGRATION_SHAPE='retired-key-in-env'
1312
+ TEAM_MIGRATION_WHY="退休键在**环境**里($(printf '%s' "$TEAM_MODEL_RETIRED_ENV" | paste -sd'、' -)),文件里改不掉;修法:unset $TEAM_MODEL_RETIRED_ENV"
1313
+ return 1
1314
+ fi
1315
+ if ! team_config_shape_read "$path"; then
1316
+ TEAM_MIGRATION_SHAPE='unknown-shape'; TEAM_MIGRATION_WHY="${TEAM_CONFIG_SHAPE_WHY:-配置形状读不出来}"; return 1
1317
+ fi
1318
+ shape="$TEAM_CONFIG_SHAPE"
1319
+ if [ "$shape" = "$TEAM_CONFIG_SHAPE_CURRENT" ]; then
1320
+ if [ -n "$(team_config_retired_keys_in_file "$path")" ]; then
1321
+ TEAM_MIGRATION_SHAPE='contradictory-shape'
1322
+ TEAM_MIGRATION_WHY="文件里带着形状号 $TEAM_CONFIG_SHAPE_CURRENT 却还有退休键 $(team_config_retired_keys_in_file "$path" | paste -sd'、' -):先手工决定留哪一套"
1323
+ return 1
1324
+ fi
1325
+ TEAM_MIGRATION_ACTION='none'; return 0
1326
+ fi
1327
+ # shape < 当前:按表找 from 匹配的行;缺行 / 更高都拒绝(绝不猜)。
1328
+ local id from to introduced matched=''
1329
+ while IFS='|' read -r id from to introduced; do
1330
+ case "$id" in ''|'#'*) continue ;; esac
1331
+ if [ "$shape" = "$from" ]; then matched="$id|$from|$to|$introduced"; break; fi
1332
+ if [ "$shape" -lt "$from" ]; then
1333
+ TEAM_MIGRATION_SHAPE='missing-migration-row'
1334
+ TEAM_MIGRATION_WHY="形状 $shape 在迁移表里没有对应的行(表的下一行从 $from 起):本工具不知道该怎么补中间这一步"
1335
+ return 1
1336
+ fi
1337
+ done < <(team_config_migration_table)
1338
+ if [ -z "$matched" ]; then
1339
+ TEAM_MIGRATION_SHAPE='missing-migration-row'
1340
+ TEAM_MIGRATION_WHY="形状 $shape 在迁移表里没有对应的行"
1341
+ return 1
1342
+ fi
1343
+ TEAM_MIGRATION_ACTION='apply'
1344
+ TEAM_MIGRATION_ROW="${matched%%|*}"; local rest="${matched#*|}"
1345
+ TEAM_MIGRATION_FROM="${rest%%|*}"; rest="${rest#*|}"
1346
+ TEAM_MIGRATION_TO="${rest%%|*}"; TEAM_MIGRATION_INTRODUCED="${rest#*|}"
1347
+ return 0
1348
+ }
1349
+ # 拒绝建议里的「其余对仍然给出」(design §4):已通过校验的对原样保留,非法的那一对用占位符补位。
1350
+ team_migration_partial_map() { # <已推导出的对…>
1351
+ local pairs="${1:-}"
1352
+ if [ -n "$pairs" ]; then printf '%s <非法那一对用占位符>' "$pairs"; else printf '<完整映射>'; fi
1353
+ }
1354
+ # 推导表(design §3):旧键 → 新键。值一个都不改;每条规范化改过名字的、兜底取默认值的都进 notes。
1355
+ # 成功 → 0:TEAM_MIGRATION_MAP / PM / NOTES / ROWS(old_key|old_value|new_key|new_value|note)就绪。
1356
+ # 失败 → 1:TEAM_MIGRATION_WHY 点名障碍,TEAM_MIGRATION_SHAPE 是分类名;TEAM_MIGRATION_ROWS 为空。
1357
+ team_config_migration_plan() { # <path>
1358
+ local path="$1" nl=$'\n'
1359
+ TEAM_MIGRATION_MAP=''; TEAM_MIGRATION_PM=''; TEAM_MIGRATION_NOTES=''; TEAM_MIGRATION_ROWS=''
1360
+ TEAM_MIGRATION_WHY=''; TEAM_MIGRATION_SHAPE=''; TEAM_MIGRATION_PARTIAL_MAP=''
1361
+ team_config_migration_decide "$path" || return 1
1362
+ [ "$TEAM_MIGRATION_ACTION" = 'apply' ] || return 0
1363
+ local shape_err
1364
+ if ! shape_err="$(C_RED='' C_RESET='' team_config_model_source_shape "$path" 2>&1)"; then
1365
+ shape_err="$(printf '%s' "$shape_err" | head -1)"; shape_err="${shape_err#✗ }"
1366
+ TEAM_MIGRATION_SHAPE='shape-not-locatable'
1367
+ TEAM_MIGRATION_WHY="旧键的形状 upgrade-models 定位不了(${shape_err:-不是顶层单行字面量});先手工规范那一行,本工具一个字节都不写"
1368
+ return 1
1369
+ fi
1370
+ local seats='' default='' pm='' pm_from_default=0
1371
+ seats="$(team_config_file_value "$path" TEAM_AGENT_MODELS 2>/dev/null || true)"
1372
+ default="$(team_config_file_value "$path" TEAM_DEFAULT_MODEL 2>/dev/null || true)"
1373
+ pm="$(team_config_file_value "$path" TEAM_PM_MODEL 2>/dev/null || true)"
1374
+ # 新旧值同时存在且矛盾:文件里既有退休键,又有**非空的新映射键** TEAM_TASK_MODELS —— 迁移会覆盖它,
1375
+ # 所以先手工决定留哪一套。(TEAM_PM_MODEL 不矛盾:design §3 的规则就是原样带过去,存在即沿用。)
1376
+ local newmap; newmap="$(team_config_file_value "$path" TEAM_TASK_MODELS 2>/dev/null || true)"
1377
+ if [ -n "$newmap" ]; then
1378
+ TEAM_MIGRATION_SHAPE='contradictory-values'
1379
+ TEAM_MIGRATION_WHY="文件里既有退休键 $(team_config_retired_keys_in_file "$path" | paste -sd'、' -),又有非空的新键 TEAM_TASK_MODELS='$newmap':先手工决定留哪一套"
1380
+ return 1
1381
+ fi
1382
+ local tok seat model category note taken=' ' map='' notes='' rows='' reason
1383
+ for tok in $seats; do
1384
+ case "$tok" in
1385
+ *=*) seat="${tok%%=*}"; model="${tok#*=}" ;;
1386
+ *) TEAM_MIGRATION_SHAPE='unparsable-seat-token'
1387
+ TEAM_MIGRATION_WHY="旧 TEAM_AGENT_MODELS 里有一个解不开的 token:$tok"; return 1 ;;
1388
+ esac
1389
+ if [ -z "$seat" ] || [ -z "$model" ]; then
1390
+ TEAM_MIGRATION_SHAPE='unparsable-seat-token'
1391
+ TEAM_MIGRATION_WHY="旧 TEAM_AGENT_MODELS 的 token 缺席位名或模型:$tok"; return 1
1392
+ fi
1393
+ if ! reason="$(team_config_model_violation "$model")"; then
1394
+ TEAM_MIGRATION_SHAPE='invalid-model-value'
1395
+ TEAM_MIGRATION_PARTIAL_MAP="$(team_migration_partial_map "$map")"
1396
+ TEAM_MIGRATION_WHY="席位 $seat 的旧模型值不合法($reason):$model"
1397
+ return 1
1398
+ fi
1399
+ category="$(team_config_category_normalize "$seat")"
1400
+ if ! team_category_valid "$category"; then
1401
+ TEAM_MIGRATION_SHAPE='category-not-normalizable'
1402
+ TEAM_MIGRATION_WHY="席位名 $seat 规范化成 '$category',不是合法类别名(^[a-z][a-z0-9-]*$):先手工选一个类别名"
1403
+ return 1
1404
+ fi
1405
+ note=''
1406
+ [ "$category" = "$seat" ] || note="席位 $seat 规范化成类别 $category"
1407
+ case "$taken" in
1408
+ *" $category "*)
1409
+ TEAM_MIGRATION_SHAPE='category-collision'
1410
+ TEAM_MIGRATION_WHY="两个席位规范化后都叫类别 $category:先手工选名字(本工具不偷偷加后缀)"
1411
+ return 1 ;;
1412
+ esac
1413
+ taken="$taken$category "
1414
+ map="${map:+$map }$category=$model"
1415
+ rows="${rows:+$rows$nl}TEAM_AGENT_MODELS|$seat=$model|TEAM_TASK_MODELS|$category=$model|$note"
1416
+ [ -z "$note" ] || notes="${notes:+$notes;}$note"
1417
+ done
1418
+ if [ -n "$default" ]; then
1419
+ if ! reason="$(team_config_model_violation "$default")"; then
1420
+ TEAM_MIGRATION_SHAPE='invalid-model-value'
1421
+ TEAM_MIGRATION_PARTIAL_MAP="$(team_migration_partial_map "$map")"
1422
+ TEAM_MIGRATION_WHY="旧 TEAM_DEFAULT_MODEL 不合法($reason):$default"; return 1
1423
+ fi
1424
+ case "$taken" in
1425
+ *' default '*)
1426
+ TEAM_MIGRATION_SHAPE='fallback-name-collision'
1427
+ TEAM_MIGRATION_WHY='席位派生的类别里已经有一个叫 default:兜底名与它撞名,先手工给旧默认值选一个类别名'; return 1 ;;
1428
+ esac
1429
+ taken="$taken default "
1430
+ map="${map:+$map }default=$default"
1431
+ rows="${rows:+$rows$nl}TEAM_DEFAULT_MODEL|$default|TEAM_TASK_MODELS|default=$default|"
1432
+ fi
1433
+ if [ -z "$pm" ]; then
1434
+ if [ -n "$default" ]; then
1435
+ pm="$default"; pm_from_default=1
1436
+ notes="${notes:+$notes;}TEAM_PM_MODEL 缺失或为空 → 取旧 TEAM_DEFAULT_MODEL 的值"
1437
+ else
1438
+ TEAM_MIGRATION_SHAPE='pm-model-underivable'
1439
+ TEAM_MIGRATION_WHY='推不出 PM 模型:TEAM_PM_MODEL 为空,且没有 TEAM_DEFAULT_MODEL 可兜底'; return 1
1440
+ fi
1441
+ fi
1442
+ if ! reason="$(team_config_model_violation "$pm")"; then
1443
+ TEAM_MIGRATION_SHAPE='invalid-model-value'
1444
+ TEAM_MIGRATION_WHY="PM 模型不合法($reason):$pm"; return 1
1445
+ fi
1446
+ if [ -z "$seats" ] && [ -z "$default" ]; then
1447
+ TEAM_MIGRATION_SHAPE='nothing-to-derive'
1448
+ TEAM_MIGRATION_WHY='退休键里没有可推导的值(TEAM_AGENT_MODELS 与 TEAM_DEFAULT_MODEL 都是空的)'; return 1
1449
+ fi
1450
+ if ! reason="$(team_task_map_violation "$map")"; then
1451
+ TEAM_MIGRATION_SHAPE='invalid-derived-map'
1452
+ TEAM_MIGRATION_WHY="推导出的类别映射过不了既有校验器($reason):$map"; return 1
1453
+ fi
1454
+ if [ "$pm_from_default" = 1 ]; then
1455
+ rows="${rows:+$rows$nl}TEAM_PM_MODEL|(缺失)|TEAM_PM_MODEL|$pm|取旧 TEAM_DEFAULT_MODEL 的值"
1456
+ else
1457
+ rows="${rows:+$rows$nl}TEAM_PM_MODEL|$pm|TEAM_PM_MODEL|$pm|"
1458
+ fi
1459
+ rows="${rows:+$rows$nl}(迁移)|-|TEAM_CONFIG_VERSION|$TEAM_CONFIG_SHAPE_CURRENT|删除两个退休键,并记下新形状号"
1460
+ TEAM_MIGRATION_MAP="$map"; TEAM_MIGRATION_PM="$pm"; TEAM_MIGRATION_NOTES="$notes"; TEAM_MIGRATION_ROWS="$rows"
1461
+ return 0
1462
+ }
1463
+ # 备份路径:$TEAM_STATE_DIR/config-backups/config.sh.pre-<引入版本>-<UTC 时间戳>(design §5)。
1464
+ team_config_backup_dir() { printf '%s\n' "${TEAM_STATE_DIR:-.pi/team/state}/config-backups"; }
1465
+ team_config_backup_name() { # <path> <时间戳> → 备份文件名
1466
+ printf 'config.sh.pre-%s-%s\n' "$(team_config_migration_introduced "$TEAM_MIGRATION_FROM")" "$2"
1467
+ }
1468
+ # 写一份带时间戳的备份,保留最新 5 份(备份是恢复手段不是档案)。
1469
+ team_config_backup_write() { # <path> <时间戳> → stdout 备份的绝对路径
1470
+ local path="$1" ts="$2" dir name
1471
+ dir="$(team_config_backup_dir)"; name="$(team_config_backup_name "$path" "$ts")"
1472
+ mkdir -p "$dir" || return 1
1473
+ cp -p "$path" "$dir/$name" || return 1
1474
+ local keep=5 n f
1475
+ n="$(find "$dir" -maxdepth 1 -type f -name 'config.sh.pre-*' | wc -l | tr -d ' ')"
1476
+ if [ "$n" -gt "$keep" ]; then
1477
+ find "$dir" -maxdepth 1 -type f -name 'config.sh.pre-*' -printf '%f\n' | sort | head -n "$((n - keep))" \
1478
+ | while IFS= read -r f; do [ -n "$f" ] && rm -f "$dir/$f"; done
1479
+ fi
1480
+ printf '%s\n' "$dir/$name"
1481
+ }
1223
1482
  team_cmd_config_upgrade_models() {
1224
1483
  local map='' pm='' dry=1 yes="${TEAM_UPGRADE_CONFIRMED:-0}" fp='' actor="${TEAM_ACTOR:-cli}"
1225
1484
  [ "$yes" != 1 ] || dry=0
@@ -1236,8 +1495,11 @@ team_cmd_config_upgrade_models() {
1236
1495
  if [ "$dry" = 1 ]; then team_config_upgrade_transaction "$path" "$map" "$pm" "$dry" "$fp" "$actor"
1237
1496
  else team_with_lock "config:$path" team_config_locked_call team_config_upgrade_transaction "$path" "$map" "$pm" "$dry" "$fp" "$actor"; fi
1238
1497
  }
1498
+ # <path> <map> <pm> <dry> <fp> <actor> [KEY=VALUE…(附加键,默认空;手工入口不受影响)]
1239
1499
  team_config_upgrade_transaction() {
1240
1500
  local path="$1" map="$2" pm="$3" dry="$4" fp="$5" actor="$6" before after tmp rc=0
1501
+ shift 6 || true
1502
+ local extra_key=; local extra_keys=("$@")
1241
1503
  before="$(team_config_fingerprint "$path")"
1242
1504
  if ! team_task_map_violation "$map" || ! team_config_model_violation "$pm"; then
1243
1505
  [ "$dry" = 1 ] || team_config_audit_write invalid "$actor" model-upgrade "$before" '' || true
@@ -1251,7 +1513,8 @@ team_config_upgrade_transaction() {
1251
1513
  [ "$dry" = 1 ] || team_config_audit_write refused "$actor" model-upgrade "$before" '' || true
1252
1514
  return 5
1253
1515
  fi
1254
- printf 'upgrade-models: remove TEAM_DEFAULT_MODEL TEAM_AGENT_MODELS; TEAM_TASK_MODELS=%s; TEAM_PM_MODEL=%s; before=%s\n' "$map" "$pm" "$before"
1516
+ # 启动迁移(actor=up-migration)自己打印逐键表,这里不再重复同一条;手工入口照旧打印这一行。
1517
+ [ "$actor" = 'up-migration' ] || printf 'upgrade-models: remove TEAM_DEFAULT_MODEL TEAM_AGENT_MODELS; TEAM_TASK_MODELS=%s; TEAM_PM_MODEL=%s; before=%s\n' "$map" "$pm" "$before"
1255
1518
  [ "$dry" != 1 ] || { printf 'dry-run: no config/audit mutation; --yes to commit\n'; return 0; }
1256
1519
  tmp="$(mktemp "$(dirname "$path")/.model-upgrade.XXXXXX")" || {
1257
1520
  team_config_audit_write write-error "$actor" model-upgrade "$before" '' || true; return 6;
@@ -1259,10 +1522,27 @@ team_config_upgrade_transaction() {
1259
1522
  cp -p "$path" "$tmp" || {
1260
1523
  rm -f "$tmp"; team_config_audit_write write-error "$actor" model-upgrade "$before" '' || true; return 6;
1261
1524
  }
1525
+ local wrote=0
1262
1526
  team_config_set_in_file "$tmp" TEAM_DEFAULT_MODEL '' remove &&
1263
1527
  team_config_set_in_file "$tmp" TEAM_AGENT_MODELS '' remove &&
1264
1528
  team_config_set_in_file "$tmp" TEAM_TASK_MODELS "$map" &&
1265
- team_config_set_in_file "$tmp" TEAM_PM_MODEL "$pm" && bash -n "$tmp" || rc=6
1529
+ team_config_set_in_file "$tmp" TEAM_PM_MODEL "$pm" || rc=6
1530
+ if [ "$rc" = 0 ]; then
1531
+ # 附加键(自动迁移写形状号):**逐个显式校验**后才写,写失败整体失败(不做半套迁移)。
1532
+ local pair
1533
+ for pair in "${extra_keys[@]}"; do
1534
+ [ -n "$pair" ] || continue
1535
+ extra_key="${pair%%=*}"
1536
+ # 只允许形状号(refuse 类键由**工具**写;控制台的写路径仍然拒绝它)—— 别的键一律写失败。
1537
+ case "$extra_key" in
1538
+ TEAM_CONFIG_VERSION) case "${pair#*=}" in ''|*[!0-9]*) rc=6; break ;; esac ;;
1539
+ *) rc=6; break ;;
1540
+ esac
1541
+ team_config_set_in_file "$tmp" "$extra_key" "${pair#*=}" || { rc=6; break; }
1542
+ wrote=1
1543
+ done
1544
+ fi
1545
+ [ "$rc" != 0 ] || bash -n "$tmp" || rc=6
1266
1546
  if [ "$rc" = 0 ] && [ "$(team_config_fingerprint "$path")" != "$before" ]; then rc=3; fi
1267
1547
  if [ "$rc" = 0 ]; then mv -f "$tmp" "$path" || rc=6; fi
1268
1548
  rm -f "$tmp"
@@ -1272,7 +1552,9 @@ team_config_upgrade_transaction() {
1272
1552
  return "$rc"
1273
1553
  fi
1274
1554
  after="$(team_config_fingerprint "$path")"
1275
- team_config_audit_write ok "$actor" 'TEAM_DEFAULT_MODEL,TEAM_AGENT_MODELS,TEAM_TASK_MODELS,TEAM_PM_MODEL' "$before" "$after" "$before" "$after" || true
1555
+ local audit_keys='TEAM_DEFAULT_MODEL,TEAM_AGENT_MODELS,TEAM_TASK_MODELS,TEAM_PM_MODEL' pair
1556
+ for pair in "${extra_keys[@]}"; do [ -n "$pair" ] && audit_keys="$audit_keys,${pair%%=*}"; done
1557
+ team_config_audit_write ok "$actor" "$audit_keys" "$before" "$after" "$before" "$after" || true
1276
1558
  printf 'committed: before=%s after=%s\n' "$before" "$after"
1277
1559
  }
1278
1560
 
@@ -1300,7 +1582,7 @@ team_cmd_config() {
1300
1582
  [--fingerprint <sha256>] [--actor <name>] 显式四键事务升级
1301
1583
  $TEAM_CLI config log [N] 审计尾部(默认 10 行)
1302
1584
 
1303
- 退出码: 0 写入/校验通过 | 3 指纹冲突 | 4 值不合法 | 5 键只读 | 6 写失败 | 7 危险值需 --allow-danger
1585
+ 退出码: 0 写入/校验通过 | 3 指纹冲突 | 4 值不合法 | 5 这个键不能由命令改 | 6 写失败 | 7 危险值需 --allow-danger
1304
1586
  EOF
1305
1587
  ;;
1306
1588
  *) team_usage_die "config: 未知子命令 $sub(list|set|log|set-task-model|upgrade-models)" ;;
@@ -49,7 +49,7 @@ team_draft_open() { # [pm]
49
49
  "$(team_identity_env_prefix "$TEAM_MAIN_ROOT")" "$TEAM_MAIN_ROOT" "$wrapper" "$cli" "$TEAM_MAIN_ROOT" "$file" "$(team_draft_target)" "$editor")"
50
50
  if team_draft_window_exists; then
51
51
  # 复用一个已经退出的草稿窗口(remain-on-exit 让回执留在 pane 里)
52
- if tmux respawn-pane -k -t "$TEAM_SESSION:draft" "$cmd" 2>/dev/null; then
52
+ if team_tmux respawn-pane -k -t "$TEAM_SESSION:draft" "$cmd" 2>/dev/null; then
53
53
  team_ok "draft:复用 $TEAM_SESSION:draft($editor $file)"
54
54
  return 0
55
55
  fi
@@ -58,9 +58,9 @@ team_draft_open() { # [pm]
58
58
  fi
59
59
  # 先用一个占位命令把窗口建出来,再开 remain-on-exit,最后才换成真 harness:
60
60
  # 否则当编辑器秒退(脚本/CI)时 harness 会在 set-window-option 之前结束,窗口连同回执一起消失。
61
- tmux new-window -d -t "$TEAM_SESSION" -n draft 'sleep 5' 2>/dev/null || team_die "draft:建窗口失败($TEAM_SESSION)"
62
- tmux set-window-option -t "$TEAM_SESSION:draft" remain-on-exit on 2>/dev/null || true
63
- tmux respawn-pane -k -t "$TEAM_SESSION:draft" "$cmd" 2>/dev/null || team_die "draft:pane 启动失败($TEAM_SESSION:draft)"
61
+ team_tmux new-window -d -t "$TEAM_SESSION" -n draft 'sleep 5' 2>/dev/null || team_die "draft:建窗口失败($TEAM_SESSION)"
62
+ team_tmux set-window-option -t "$TEAM_SESSION:draft" remain-on-exit on 2>/dev/null || true
63
+ team_tmux respawn-pane -k -t "$TEAM_SESSION:draft" "$cmd" 2>/dev/null || team_die "draft:pane 启动失败($TEAM_SESSION:draft)"
64
64
  team_ok "draft:已开 $TEAM_SESSION:draft(不抢焦点;$editor $file)"
65
65
  team_dim " 保存并退出编辑器 → 内容自动入队(回执打印在该窗口里);任何自动化消息都不会打进这个窗口"
66
66
  return 0