teamsmith 0.1.2 → 0.3.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.
- package/README.md +13 -7
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +67 -0
- package/skills/teamsmith/SKILL.md +26 -8
- package/skills/teamsmith/extension/team-notify.ts +37 -6
- package/skills/teamsmith/extension/team.ts +438 -0
- package/skills/teamsmith/references/agent-adapters.md +7 -7
- package/skills/teamsmith/references/config.md +65 -18
- package/skills/teamsmith/references/migration.md +220 -34
- package/skills/teamsmith/references/protocol.md +250 -25
- package/skills/teamsmith/references/troubleshooting.md +124 -7
- package/skills/teamsmith/references/workflows.md +66 -20
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +525 -90
- package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +71 -10
- package/skills/teamsmith/scripts/lib/cmd-config.sh +562 -128
- package/skills/teamsmith/scripts/lib/cmd-death.sh +2 -15
- package/skills/teamsmith/scripts/lib/cmd-docs.sh +6 -3
- package/skills/teamsmith/scripts/lib/cmd-draft.sh +4 -4
- package/skills/teamsmith/scripts/lib/cmd-help.sh +677 -0
- package/skills/teamsmith/scripts/lib/cmd-init.sh +157 -5
- package/skills/teamsmith/scripts/lib/cmd-interrupt.sh +461 -0
- package/skills/teamsmith/scripts/lib/cmd-meeting.sh +2 -25
- package/skills/teamsmith/scripts/lib/cmd-project.sh +149 -105
- package/skills/teamsmith/scripts/lib/cmd-reap.sh +277 -0
- package/skills/teamsmith/scripts/lib/cmd-reply.sh +96 -0
- package/skills/teamsmith/scripts/lib/cmd-review.sh +188 -40
- package/skills/teamsmith/scripts/lib/cmd-status.sh +268 -30
- package/skills/teamsmith/scripts/lib/cmd-update.sh +36 -7
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +634 -54
- package/skills/teamsmith/scripts/lib/common.sh +1560 -109
- package/skills/teamsmith/scripts/lib/gate-lock.sh +544 -0
- package/skills/teamsmith/scripts/monitor.mjs +34 -3
- package/skills/teamsmith/scripts/panel/README.md +22 -11
- package/skills/teamsmith/scripts/panel/draft-send.sh +11 -1
- package/skills/teamsmith/scripts/panel/panel.js +226 -224
- package/skills/teamsmith/scripts/panel/src/App.tsx +478 -184
- package/skills/teamsmith/scripts/panel/src/clipboard.ts +11 -5
- package/skills/teamsmith/scripts/panel/src/compose.ts +6 -3
- package/skills/teamsmith/scripts/panel/src/data.ts +95 -7
- package/skills/teamsmith/scripts/panel/src/layout.ts +703 -152
- package/skills/teamsmith/scripts/panel/src/main.tsx +129 -19
- package/skills/teamsmith/scripts/panel/src/settings.ts +1 -1
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +76 -31
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +78 -33
- package/skills/teamsmith/scripts/panel/src/types.ts +204 -17
- package/skills/teamsmith/scripts/replies.mjs +896 -0
- package/skills/teamsmith/scripts/shim/tmux +18 -0
- package/skills/teamsmith/scripts/strings/commands.tsv +86 -0
- package/skills/teamsmith/scripts/strings/help.en.tsv +503 -0
- package/skills/teamsmith/scripts/strings/help.zh.tsv +489 -0
- package/skills/teamsmith/scripts/team +20 -6
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +23 -3
- package/skills/teamsmith/templates/BOARD.md.tmpl +2 -2
- package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +7 -3
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +17 -0
- package/skills/teamsmith/templates/config.sh.tmpl +29 -5
- package/skills/teamsmith/templates/memory-seed.md.tmpl +3 -0
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +41 -1
- package/skills/teamsmith/templates/report.md.tmpl +12 -0
- package/skills/teamsmith/templates/task.md.tmpl +4 -0
- package/skills/teamsmith/tests/bg-ledger-harness.mjs +464 -40
- package/skills/teamsmith/tests/bg-ledger.sh +168 -10
- package/skills/teamsmith/tests/checkout-shape-probe.sh +3 -1
- package/skills/teamsmith/tests/config-cli.sh +320 -300
- package/skills/teamsmith/tests/death-cause.sh +5 -2
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +7 -1
- package/skills/teamsmith/tests/fixtures/p287/lint-good.sh.in +3 -0
- package/skills/teamsmith/tests/fixtures/p287/lint-hardcoded.sh.in +3 -0
- package/skills/teamsmith/tests/fixtures/p287/lint-no-ns.sh.in +3 -0
- package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +18 -6
- package/skills/teamsmith/tests/flip-m33.sh +5 -3
- package/skills/teamsmith/tests/flip-m37.sh +4 -1
- package/skills/teamsmith/tests/flip-m4.3.sh +4 -1
- package/skills/teamsmith/tests/flip-m6.3.sh +4 -1
- package/skills/teamsmith/tests/flip-m6.5.sh +4 -1
- package/skills/teamsmith/tests/flip-m7.2.sh +4 -1
- package/skills/teamsmith/tests/flip-p158.sh +2 -1
- package/skills/teamsmith/tests/flip-p210.sh +4 -1
- package/skills/teamsmith/tests/flip-p217.sh +4 -1
- package/skills/teamsmith/tests/flip-p287-lock.sh +342 -0
- package/skills/teamsmith/tests/flip-p287-name.sh +279 -0
- package/skills/teamsmith/tests/flip-p304-read-side.sh +98 -0
- package/skills/teamsmith/tests/flip-p308-skip-not-pass.sh +151 -0
- package/skills/teamsmith/tests/flip-p309-p162-deep.sh +122 -0
- package/skills/teamsmith/tests/flip-p310-lock.sh +216 -0
- package/skills/teamsmith/tests/flip-p310-socket.sh +125 -0
- package/skills/teamsmith/tests/help-surface.sh +1664 -0
- package/skills/teamsmith/tests/install-shape.sh +283 -22
- package/skills/teamsmith/tests/key-replies-pty.sh +374 -0
- package/skills/teamsmith/tests/key-replies-ui.sh +325 -0
- package/skills/teamsmith/tests/key-replies.sh +1314 -0
- package/skills/teamsmith/tests/ledger-ban.sh +9 -8
- package/skills/teamsmith/tests/ledger-claim.sh +248 -0
- package/skills/teamsmith/tests/lib/bounded-spin.sh +90 -0
- package/skills/teamsmith/tests/lib/model-policy.sh +30 -0
- package/skills/teamsmith/tests/lib/model-routing-boundary.sh +420 -0
- package/skills/teamsmith/tests/lib/model-routing-expansion.sh +155 -0
- package/skills/teamsmith/tests/lib/model-routing-flips.py +187 -0
- package/skills/teamsmith/tests/lib/model-routing-roles.sh +250 -0
- package/skills/teamsmith/tests/lib/proc-io.sh +103 -0
- package/skills/teamsmith/tests/lib/reply-fixture.sh +367 -0
- package/skills/teamsmith/tests/lib/section-guard.sh +258 -13
- package/skills/teamsmith/tests/lib/tmp-root.sh +139 -27
- package/skills/teamsmith/tests/lib/tmux-cap.sh +10 -1
- package/skills/teamsmith/tests/lib/tmux-iso.sh +39 -13
- package/skills/teamsmith/tests/loop-inventory.tsv +59 -47
- package/skills/teamsmith/tests/panel-b2.sh +107 -4
- package/skills/teamsmith/tests/panel-b3-stub.sh +139 -4
- package/skills/teamsmith/tests/panel-b3.sh +189 -29
- package/skills/teamsmith/tests/panel-choices.sh +81 -63
- package/skills/teamsmith/tests/panel-cpu.sh +3 -2
- package/skills/teamsmith/tests/panel-knobs.sh +7 -1
- package/skills/teamsmith/tests/panel-p21.sh +445 -241
- package/skills/teamsmith/tests/panel-snapshots.sh +41 -225
- package/skills/teamsmith/tests/panel-strings.mjs +33 -18
- package/skills/teamsmith/tests/perf.sh +122 -31
- package/skills/teamsmith/tests/pm-box-real.sh +1 -1
- package/skills/teamsmith/tests/pulse-nudge-key.sh +1 -1
- package/skills/teamsmith/tests/routes.sh +364 -109
- package/skills/teamsmith/tests/seat-interrupt.sh +1002 -0
- package/skills/teamsmith/tests/seat-visibility.sh +675 -0
- package/skills/teamsmith/tests/section-budgets.tsv +26 -12
- package/skills/teamsmith/tests/section-guard.sh +6 -1
- package/skills/teamsmith/tests/section-needs-audit.sh +24 -7
- package/skills/teamsmith/tests/section-paths.tsv +42 -26
- package/skills/teamsmith/tests/section-select.sh +90 -7
- package/skills/teamsmith/tests/slash-team-e2e.sh +323 -0
- package/skills/teamsmith/tests/slash-team.sh +617 -0
- package/skills/teamsmith/tests/smoke.sh +3762 -628
- package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-120.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-160.txt +9 -9
- package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +1 -1
- package/skills/teamsmith/tests/snapshots/zh-light-59.txt +5 -5
- package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +2 -2
- package/skills/teamsmith/tests/snapshots/zh-light-99.txt +5 -5
- package/skills/teamsmith/tests/task-header-model.sh +2 -1
- package/skills/teamsmith/tests/task-model-routing.sh +1511 -0
- package/skills/teamsmith/tests/tmp-hygiene.sh +782 -45
- package/skills/teamsmith/tests/tmux-identity-leak.sh +773 -0
- package/skills/teamsmith/tests/tmux-lint-legacy.txt +12 -18
- package/skills/teamsmith/tests/upgrade-recipe.sh +537 -0
- package/skills/teamsmith-init/SKILL.md +43 -43
- package/skills/teamsmith-init/references/bootstrap.md +8 -6
- package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +9 -5
|
@@ -30,71 +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:自由文本说明列 ——
|
|
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
|
-
# ----
|
|
40
|
-
TEAM_PROJECT|refuse|text||plain
|
|
41
|
-
TEAM_SESSION|refuse|text||plain
|
|
42
|
-
TEAM_PM_WINDOW|refuse|text||plain|pm
|
|
43
|
-
TEAM_AGENTS|refuse|list||plain
|
|
44
|
-
TEAM_DOCS_DIR|refuse|path|dir,opt|plain|docs/team
|
|
45
|
-
TEAM_WORKTREES_DIR|refuse|text||plain|.worktrees
|
|
46
|
-
TEAM_STATE_DIR|refuse|path|dir,opt|plain|.pi/team/state
|
|
47
|
-
TEAM_MEETINGS_DIR|refuse|path|dir,opt|plain|~/.pi/team/meetings
|
|
48
|
-
TEAM_SPEC_DIR|refuse|path|dir,opt|plain|openspec
|
|
49
|
-
TEAM_ROOT|refuse|path|dir,opt|plain
|
|
50
|
-
TEAM_MAIN_ROOT|refuse|path|dir,opt|plain
|
|
51
|
-
|
|
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
|
|
54
|
-
TEAM_TASK_BRANCH_PREFIX|refuse|text||plain|task
|
|
55
|
-
TEAM_AGENT_BRANCH_PREFIX|refuse|text||plain|agent
|
|
56
|
-
TEAM_PROTECTED_BRANCH|refuse|text||plain|main
|
|
57
|
-
TEAM_REMOTE|refuse|text||plain|origin
|
|
58
|
-
TEAM_VCS|refuse|enum|local,github,gitlab,other|plain|local
|
|
59
|
-
TEAM_TOKEN_FILE|refuse|path|file,opt|plain|.gh-pat
|
|
60
|
-
TEAM_GITLAB_HOST|refuse|text||plain
|
|
61
|
-
TEAM_GITLAB_PROJECT|refuse|text||plain
|
|
62
|
-
TEAM_GITLAB_TOKEN_FILE|refuse|path|file,opt|plain
|
|
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
|
-
# ----
|
|
65
|
-
TEAM_CONFIRM_WRITES|refuse|bool||plain|1
|
|
66
|
-
TEAM_ALLOW_FOREIGN_IDENTITY|refuse|bool||plain|0
|
|
67
|
-
TEAM_ALLOW_FOREIGN_SESSION|refuse|bool||plain|0
|
|
68
|
-
TEAM_GUARD_FOREIGN_TARGET|refuse|bool||plain|1
|
|
69
|
-
TEAM_REPLACE_FOREIGN_PM|refuse|bool||plain|0
|
|
70
|
-
TEAM_ALLOW_DESTRUCTIVE_TMUX|refuse|bool||plain|0
|
|
71
|
-
TEAM_ASSUME_YES|refuse|bool||plain|0
|
|
72
|
-
TEAM_REQUIRE_JS|refuse|bool||plain|1
|
|
73
|
-
TEAM_REQUIRE_OPENSPEC|refuse|bool||plain|1
|
|
74
|
-
TEAM_REQUIRE_MAGIC_CONTEXT|refuse|bool||plain|1
|
|
75
|
-
TEAM_PI_AGENT_DIR|refuse|path|dir,opt|plain
|
|
76
|
-
TEAM_PI_SETTINGS_FILE|refuse|path|file,opt|plain|$HOME/.pi/agent/settings.json
|
|
77
|
-
TEAM_MEMINFO_FILE|refuse|path|file,opt|plain
|
|
78
|
-
TEAM_DISK_STATS_FILE|refuse|path|file,opt|plain
|
|
79
|
-
TEAM_SMOKE_FAST|refuse|bool||plain|0
|
|
80
|
-
TEAM_INBOX_WATCH_FORCE_FAIL|refuse|text||plain
|
|
81
|
-
TEAM_IW_REQUIRE_WATCH|refuse|bool||plain|0
|
|
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
|
|
88
|
-
TEAM_AGENT_NOTIFY_CMD|apply|tpl|notify|plain
|
|
89
|
-
TEAM_AGENT_LOG_GLOB|apply|text||plain
|
|
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
|
|
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
|
-
# ----
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
|
98
103
|
# ---- 工作流与门禁(apply)----
|
|
99
104
|
TEAM_GATES|apply|cmd||plain||-|||workflow
|
|
100
105
|
TEAM_INSTALL_CMD|apply|cmd||plain||-|||workflow
|
|
@@ -122,10 +127,15 @@ TEAM_AGENT_MEM_MB|apply|mb|1,|plain|6144|-||2048,4096,6144|delivery
|
|
|
122
127
|
TEAM_NOTIFY_TMUX|apply|bool||plain|1|-|||delivery
|
|
123
128
|
TEAM_NOTIFY_DEDUP_SEC|apply|seconds|0,|plain|20|-|||delivery
|
|
124
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
|
|
125
131
|
TEAM_NOTIFY_LOG|apply|path|file,opt|plain|/tmp/teamsmith-notify.log|-|||delivery
|
|
126
132
|
TEAM_DEFER_TTL|apply|seconds|0,|plain|300|0 = 投递队列入队即过期||60,300,900|delivery
|
|
127
133
|
TEAM_OUTBOX_MAX|apply|int|0,|plain|200|0 = 队列不设上限(无界)||50,200,1000|delivery
|
|
128
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
|
|
129
139
|
# ---- 巡检与面板(restart:运行中的 pulse/面板拿着启动时的值)----
|
|
130
140
|
TEAM_PULSE_INTERVAL|restart|seconds|60,|plain|900|低于 60 秒 = 巡检转成忙等||300,900,1800,3600|panel
|
|
131
141
|
TEAM_MONITOR_REFRESH|restart|seconds|1,|plain|3|-||2,3,5|panel
|
|
@@ -134,7 +144,7 @@ TEAM_MONITOR_UI|restart|enum|auto,tui,text|plain|auto|-|||panel
|
|
|
134
144
|
TEAM_MONITOR_ACTIVITY|restart|bool||export|1|-|||panel
|
|
135
145
|
TEAM_AGENT_LOG_TAIL_BYTES|restart|bytes|0,1048576|export||-|||panel
|
|
136
146
|
TEAM_PULSE_WINDOW|restart|text||plain|pulse|改的是运行中后端的窗口名:team pulse down(旧名)→ 改 → team pulse up|||panel
|
|
137
|
-
# ----
|
|
147
|
+
# ---- 巡检(apply:一拍一个 team watch --once 子进程)----
|
|
138
148
|
TEAM_PULSE_NUDGE_GAP|apply|seconds|0,|plain|900|-||300,900,1800|patrol
|
|
139
149
|
TEAM_PULSE_PENDING_BOARD|apply|bool||plain|0|-|||patrol
|
|
140
150
|
TEAM_PULSE_REBUILD_TMUX|apply|bool||plain|0|-|||patrol
|
|
@@ -157,10 +167,10 @@ TEAM_INBOX_WATCH_POLL_MS|restart|int|100,|export|5000|-|||session
|
|
|
157
167
|
TEAM_INBOX_WATCH_HEARTBEAT_MS|restart|int|100,|export|5000|-|||session
|
|
158
168
|
TEAM_INBOX_WATCH_TARGET|restart|text||export||-|||session
|
|
159
169
|
TEAM_BG_LOG_MAX_BYTES|restart|bytes|1024,|export|524288|-|||session
|
|
160
|
-
# ---- 信号纪律(
|
|
161
|
-
TEAM_SIGNAL_CALLS_LOG|refuse|path|file,opt|plain
|
|
162
|
-
TEAM_SIGNAL_REAL|refuse|path|exec,opt|plain
|
|
163
|
-
TEAM_BG_STOP_GRACE|refuse|seconds|0,|plain|5
|
|
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
|
|
164
174
|
# ---- 跨项目会议(apply)----
|
|
165
175
|
TEAM_MEETING_TTL_HOURS|apply|int|1,|plain|72|-||24,72,168|meeting
|
|
166
176
|
TEAM_MEETING_MAX_TURNS|apply|int|1,|plain|20|-||5,20,50|meeting
|
|
@@ -219,7 +229,7 @@ team_config_choices_set() { # <row> [known models: 每行一个] → CFG_CHOICES
|
|
|
219
229
|
src="schema"
|
|
220
230
|
IFS=, read -r min max _ <<< "$spec"
|
|
221
231
|
val_list="${suggest//,/$'\n'}" ;;
|
|
222
|
-
model|pairlist|winlist|pattern)
|
|
232
|
+
model|task-model-map|pairlist|winlist|pattern)
|
|
223
233
|
src="known"; val_list="$known" ;;
|
|
224
234
|
path)
|
|
225
235
|
local typ="${spec%%,*}"; note="${typ:-any}" ;;
|
|
@@ -257,7 +267,7 @@ team_config_key_form() { # <KEY> → plain|export(未知键 = plain)
|
|
|
257
267
|
}
|
|
258
268
|
|
|
259
269
|
# notify 扩展用扁平 KEY="value" 读取器解析的八个键:值里出现 ' 就没有转义可用 → 拒写(设计 §4)。
|
|
260
|
-
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 "
|
|
261
271
|
team_config_flat_key() { # <KEY> → 0 = 扁平读取器的键
|
|
262
272
|
case "$TEAM_CONFIG_FLAT_KEYS" in *" $1 "*) return 0 ;; esac
|
|
263
273
|
return 1
|
|
@@ -329,13 +339,13 @@ team_config_validate_value() {
|
|
|
329
339
|
local key="$1" val="${2-}" row class kind spec form
|
|
330
340
|
row="$(team_config_row "$key" 2>/dev/null || true)"
|
|
331
341
|
if [ -z "$row" ]; then
|
|
332
|
-
printf '不是已知的项目设置键(references/config.md
|
|
342
|
+
printf '不是已知的项目设置键(references/config.md 是清单);自定义键写在 .pi/team/config.sh 里\n'
|
|
333
343
|
return 1
|
|
334
344
|
fi
|
|
335
345
|
class="$(team_config_field "$row" 2)"; kind="$(team_config_field "$row" 3)"
|
|
336
346
|
spec="$(team_config_field "$row" 4)"; form="$(team_config_field "$row" 5)"
|
|
337
347
|
if [ "$class" = "refuse" ]; then
|
|
338
|
-
printf '
|
|
348
|
+
printf '不能由命令改(%s)\n' "$(team_config_field "$row" 8)"
|
|
339
349
|
return 1
|
|
340
350
|
fi
|
|
341
351
|
case "$val" in
|
|
@@ -380,6 +390,8 @@ team_config_validate_value() {
|
|
|
380
390
|
local mwhy
|
|
381
391
|
if mwhy="$(team_config_model_violation "$val")"; then return 0; fi
|
|
382
392
|
printf '%s\n' "$mwhy"; return 1 ;;
|
|
393
|
+
task-model-map)
|
|
394
|
+
team_task_map_violation "$val" ;;
|
|
383
395
|
pairlist)
|
|
384
396
|
local tok seat model r mwhy; r=0
|
|
385
397
|
for tok in $val; do
|
|
@@ -714,47 +726,54 @@ team_config_list_json() {
|
|
|
714
726
|
team_config_scan "$path"
|
|
715
727
|
# models 块的 known 先算:它也是模型类键的 choices 词表(choices 必须随键记录一起输出,所以
|
|
716
728
|
# 不能等键循环结束)。token 与顺序和原来逐字一致;每个席位的**显示**模型也在表里(R2)。
|
|
717
|
-
local
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
known_models="$known_models$
|
|
729
|
-
|
|
730
|
-
firstk=0
|
|
731
|
-
team_config_json_escape_set "$tok"; known_list="$known_list\"$CFG_ESC\""
|
|
732
|
-
done
|
|
733
|
-
local a state_model
|
|
729
|
+
local known_models="" known_list="" seen=' ' tok a
|
|
730
|
+
local categories='' assignments='' policy_pm='' pm_launch='{}'
|
|
731
|
+
if team_task_map_violation "${TEAM_TASK_MODELS:-}" >/dev/null; then
|
|
732
|
+
for tok in $TEAM_TASK_MODELS; do
|
|
733
|
+
team_config_json_escape_set "${tok%%=*}"; local ec="$CFG_ESC"
|
|
734
|
+
team_config_json_escape_set "${tok#*=}"; local em="$CFG_ESC"
|
|
735
|
+
categories="${categories:+$categories,}{\"category\":\"$ec\",\"model\":\"$em\"}"
|
|
736
|
+
known_models="$known_models${tok#*=}"$'\n'
|
|
737
|
+
done
|
|
738
|
+
fi
|
|
739
|
+
if team_config_model_shape_ok "${TEAM_PM_MODEL:-}"; then
|
|
740
|
+
policy_pm="$TEAM_PM_MODEL"; known_models="$known_models$policy_pm"$'\n'
|
|
741
|
+
fi
|
|
734
742
|
for a in $(team_agents); do
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
[ "$
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
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
|
|
749
|
+
if team_assignment_load "$a"; then
|
|
750
|
+
assigned=true
|
|
751
|
+
# P228/R6(OBS1):未交付的模型不进「已知模型」,也不当成该席位的模型
|
|
752
|
+
if team_identity_delivered model; then known_models="$known_models${TEAM_ASSIGN[model]}"$'\n'
|
|
753
|
+
else diagnostic='template delivered no model identity'; fi
|
|
754
|
+
else diagnostic="$TEAM_ASSIGN_DIAGNOSTIC"; fi
|
|
755
|
+
for field in task category model selected_via launch_via sid; do
|
|
756
|
+
val=''; [ "$assigned" = false ] || val="${TEAM_ASSIGN[$field]}"
|
|
757
|
+
if [ "$field" = model ] && ! team_identity_delivered model; then val=''; fi
|
|
758
|
+
team_config_json_escape_set "$val"; fields="$fields,\"$field\":\"$CFG_ESC\""
|
|
759
|
+
done
|
|
760
|
+
val=''; [ "$assigned" = false ] || val="$(team_identity_delivered_set)"
|
|
761
|
+
team_config_json_escape_set "$val"; fields="$fields,\"identity_via\":\"$CFG_ESC\""
|
|
762
|
+
team_config_json_escape_set "$diagnostic"; local ed="$CFG_ESC"
|
|
763
|
+
team_config_json_escape_set "$a"
|
|
764
|
+
assignments="${assignments:+$assignments,}{\"agent\":\"$CFG_ESC\",\"assigned\":$assigned,\"record_present\":$present$fields,\"diagnostic\":\"$ed\"}"
|
|
757
765
|
done
|
|
766
|
+
if team_pm_metadata_load; then
|
|
767
|
+
pm_launch="$TEAM_PM_METADATA_JSON"; known_models="$known_models$TEAM_PM_SELECTED_MODEL"$'\n'
|
|
768
|
+
fi
|
|
769
|
+
local dedup=''
|
|
770
|
+
while IFS= read -r tok; do
|
|
771
|
+
[ -n "$tok" ] || continue
|
|
772
|
+
case "$seen" in *" $tok "*) continue ;; esac
|
|
773
|
+
seen="$seen$tok "; dedup="$dedup$tok"$'\n'
|
|
774
|
+
team_config_json_escape_set "$tok"; known_list="${known_list:+$known_list,}\"$CFG_ESC\""
|
|
775
|
+
done <<< "$known_models"
|
|
776
|
+
known_models="$dedup"
|
|
758
777
|
|
|
759
778
|
local schema_keys="|"
|
|
760
779
|
local -a f=()
|
|
@@ -770,9 +789,10 @@ team_config_list_json() {
|
|
|
770
789
|
comment="${CFG_SCAN_COMMENT[$key]}"
|
|
771
790
|
set="true"
|
|
772
791
|
fi
|
|
773
|
-
if [ "$key" =
|
|
774
|
-
local
|
|
775
|
-
|
|
792
|
+
if [ "$key" = TEAM_TASK_MODELS ]; then
|
|
793
|
+
local why; if ! why="$(team_task_map_violation "$value")"; then warning="$why"; fi
|
|
794
|
+
elif [ "$key" = TEAM_PM_MODEL ]; then
|
|
795
|
+
local why; if ! why="$(team_config_model_violation "$value")"; then warning="$why"; fi
|
|
776
796
|
fi
|
|
777
797
|
# P99/R1:名册的读侧 warning 与写侧的值规则是同一份判定(team_config_list_violation)——
|
|
778
798
|
# 手改出一个非法 token 时,读给出警告、写入器拒绝的是同一条规则。
|
|
@@ -804,20 +824,9 @@ team_config_list_json() {
|
|
|
804
824
|
team_config_json_escape_set "$v"; local u_val="$CFG_ESC"
|
|
805
825
|
team_config_json_escape_set "$c"; local u_com="$CFG_ESC"
|
|
806
826
|
team_config_choices_set ""
|
|
807
|
-
out="$out,{\"name\":\"$u_key\",\"class\":\"refuse\",\"kind\":\"text\",\"form\":\"plain\",\"value\":\"$u_val\",\"default\":\"\",\"set\":true,\"comment\":\"$u_com\",\"warning\":\"不是已知的项目设置(见 references/config.md
|
|
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}"
|
|
808
828
|
done <<< "$CFG_SCAN_ORDER"
|
|
809
829
|
|
|
810
|
-
local seats="" firsts=1
|
|
811
|
-
for a in $(team_agents) pm; do
|
|
812
|
-
team_config_seat_split "$(team_config_seat_state "$a")" model src override
|
|
813
|
-
case "$override" in true) ;; *) override="false" ;; esac # override 永远是 JSON 布尔值(P47/R5)
|
|
814
|
-
# 空模型也要出这一行(seats 覆盖每个名册席位 + pm):空模型序列化成 "",不是无值字段也不是丢行。
|
|
815
|
-
team_config_json_escape_set "$a"; local s_agent="$CFG_ESC"
|
|
816
|
-
team_config_json_escape_set "$model"; local s_model="$CFG_ESC"
|
|
817
|
-
[ "$firsts" = "1" ] || seats="$seats,"
|
|
818
|
-
firsts=0
|
|
819
|
-
seats="$seats{\"agent\":\"$s_agent\",\"model\":\"$s_model\",\"source\":\"$(team_config_seat_source_token "$src")\",\"override\":$override}"
|
|
820
|
-
done
|
|
821
830
|
|
|
822
831
|
local audit="" firsta=1 l
|
|
823
832
|
while IFS= read -r l; do
|
|
@@ -828,10 +837,10 @@ team_config_list_json() {
|
|
|
828
837
|
done < <(team_config_audit_tail 10)
|
|
829
838
|
|
|
830
839
|
team_config_json_escape_set "$path"; local e_path="$CFG_ESC"
|
|
831
|
-
team_config_json_escape_set "$
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
"$
|
|
840
|
+
team_config_json_escape_set "$policy_pm"; local e_pm="$CFG_ESC"
|
|
841
|
+
team_config_json_escape_set "$(team_model_policy_issues)"; local e_diag="$CFG_ESC"
|
|
842
|
+
printf '{"path":"%s","fingerprint":"%s","mtime":"%s","keys":[%s],"models":{"policy":{"categories":[%s],"pm":"%s"},"assignments":[%s],"pm_launch":%s,"known":[%s],"diagnostic":"%s"},"audit":[%s]}\n' \
|
|
843
|
+
"$e_path" "$fingerprint" "$mtime" "$out" "$categories" "$e_pm" "$assignments" "$pm_launch" "$known_list" "$e_diag" "$audit"
|
|
835
844
|
}
|
|
836
845
|
|
|
837
846
|
team_cmd_config_list() {
|
|
@@ -860,6 +869,8 @@ team_cmd_config_list() {
|
|
|
860
869
|
if value="$(team_config_file_value "$path" "$key")"; then set=1; else value="$def"; set=0; fi
|
|
861
870
|
printf '%-42s %-8s %-10s %s%s\n' "$key" "$class" "$kind" "$value" "$([ "$set" = "0" ] && printf ' (unset · default)')"
|
|
862
871
|
done < <(team_config_schema)
|
|
872
|
+
local issues; issues="$(team_model_policy_issues)"
|
|
873
|
+
[ -z "$issues" ] || printf '\n%s\n' "$issues"
|
|
863
874
|
printf '\n审计 %s\n' "$(team_config_audit_file)"
|
|
864
875
|
team_config_audit_tail 5 | sed 's/^/ /'
|
|
865
876
|
}
|
|
@@ -884,21 +895,43 @@ TEAM_CONFIG_EXIT_DANGER=7
|
|
|
884
895
|
|
|
885
896
|
# 共用的写路径:<KEY> <value> <actor> <dry> <fp> <allow_danger>
|
|
886
897
|
# 返回值就是机器契约的退出码。
|
|
887
|
-
|
|
898
|
+
team_config_locked_call() { local TEAM_CONFIG_LOCKED=1; "$@"; }
|
|
899
|
+
team_config_write_checked() {
|
|
900
|
+
if [ "${4:-0}" = 1 ] || [ "${TEAM_CONFIG_LOCKED:-0}" = 1 ]; then team_config_write_checked_unlocked "$@"
|
|
901
|
+
else
|
|
902
|
+
local path; path="$(team_config_contract_path)" || return 1
|
|
903
|
+
team_with_lock "config:$path" team_config_locked_call team_config_write_checked_unlocked "$@"
|
|
904
|
+
fi
|
|
905
|
+
}
|
|
906
|
+
team_config_write_checked_unlocked() { # <KEY> <value> <actor> <dry> <fp> <allow_danger>
|
|
888
907
|
local key="$1" val="$2" actor="$3" dry="$4" fp="$5" allow_danger="$6"
|
|
889
908
|
local path; path="$(team_config_contract_path)" || return 1
|
|
890
909
|
local row; row="$(team_config_row "$key" 2>/dev/null || true)"
|
|
891
910
|
local old; old="$(team_config_file_value "$path" "$key" 2>/dev/null || true)"
|
|
892
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
|
+
|
|
893
924
|
if [ -z "$row" ]; then
|
|
894
925
|
team_err "$key 不是已知的项目设置键"
|
|
895
|
-
|
|
926
|
+
case "$key" in TEAM_DEFAULT_MODEL|TEAM_AGENT_MODELS)
|
|
927
|
+
team_dim " retired: $TEAM_CLI config set-task-model <category> <model>;config set TEAM_PM_MODEL <model>;config upgrade-models" >&2 ;;
|
|
928
|
+
*) team_dim " 已知键:$TEAM_CLI config list;自定义键写在 $path 里" >&2 ;; esac
|
|
896
929
|
[ "$dry" = "1" ] || team_config_audit_write refused "$actor" "$key" "$old" "$val" || true
|
|
897
930
|
return "$TEAM_CONFIG_EXIT_REFUSE"
|
|
898
931
|
fi
|
|
899
932
|
local class kind; class="$(team_config_field "$row" 2)"; kind="$(team_config_field "$row" 3)"
|
|
900
933
|
if [ "$class" = "refuse" ]; then
|
|
901
|
-
team_err "$key
|
|
934
|
+
team_err "$key 不能由命令改"
|
|
902
935
|
team_dim " $(team_config_field "$row" 8)" >&2
|
|
903
936
|
[ "$dry" = "1" ] || team_config_audit_write refused "$actor" "$key" "$old" "$val" || true
|
|
904
937
|
return "$TEAM_CONFIG_EXIT_REFUSE"
|
|
@@ -952,7 +985,17 @@ team_config_write_checked() { # <KEY> <value> <actor> <dry> <fp> <allow_danger>
|
|
|
952
985
|
# 3 指纹冲突 / 4 值不合法 / 5 remove 的席位不在名册 / 6 写失败。
|
|
953
986
|
# 席位名合法性只对**结果值**判:移掉一个手改进来的非法 token 是合法的(结果干净),
|
|
954
987
|
# 加进去才非法 —— 一条规则,读写同一份(team_config_list_violation)。
|
|
955
|
-
team_config_write_roster() {
|
|
988
|
+
team_config_write_roster() {
|
|
989
|
+
if [ "${4:-0}" = 1 ] || [ "${TEAM_CONFIG_LOCKED:-0}" = 1 ]; then team_config_write_roster_unlocked "$@"
|
|
990
|
+
else
|
|
991
|
+
local path; path="$(team_config_contract_path)" || return 1
|
|
992
|
+
local rc=0
|
|
993
|
+
team_with_lock "config:$path" team_config_locked_call team_config_write_roster_unlocked "$@" || rc=$?
|
|
994
|
+
[ "$rc" != 0 ] || TEAM_AGENTS="$(team_config_file_value "$path" TEAM_AGENTS)"
|
|
995
|
+
return "$rc"
|
|
996
|
+
fi
|
|
997
|
+
}
|
|
998
|
+
team_config_write_roster_unlocked() { # <add|remove> <seat> [fingerprint] [dry]
|
|
956
999
|
local op="$1" seat="$2" fp="${3:-}" dry="${4:-0}"
|
|
957
1000
|
local path; path="$(team_config_contract_path)" || return 1
|
|
958
1001
|
local old; old="$(team_config_file_value "$path" TEAM_AGENTS 2>/dev/null || true)"
|
|
@@ -1094,7 +1137,7 @@ team_cmd_config_set_agent_model() {
|
|
|
1094
1137
|
[ "$seat" = "pm" ] && audit_key="TEAM_PM_MODEL"
|
|
1095
1138
|
if ! team_config_seat_known "$seat"; then
|
|
1096
1139
|
team_err "未知席位 $seat:名册是($(team_config_roster_text))加 pm"
|
|
1097
|
-
team_dim " 名册的键是 TEAM_AGENTS
|
|
1140
|
+
team_dim " 名册的键是 TEAM_AGENTS(不能由命令改):$TEAM_CLI add-agent $seat --register(或 team teardown --agent $seat --register)" >&2
|
|
1098
1141
|
[ "$dry" = "1" ] || team_config_audit_write refused "$actor" "$audit_key" "$seat" "$model" || true
|
|
1099
1142
|
return "$TEAM_CONFIG_EXIT_REFUSE"
|
|
1100
1143
|
fi
|
|
@@ -1128,6 +1171,393 @@ team_cmd_config_set_agent_model() {
|
|
|
1128
1171
|
return $rc
|
|
1129
1172
|
}
|
|
1130
1173
|
|
|
1174
|
+
# Category edit is a read/modify/write under the SAME file lock as whole-map writes.
|
|
1175
|
+
team_cmd_config_set_task_model() {
|
|
1176
|
+
local cat='' model='' dry=0 fp='' allow_danger=0 actor="${TEAM_ACTOR:-cli}"
|
|
1177
|
+
while [ $# -gt 0 ]; do
|
|
1178
|
+
case "$1" in
|
|
1179
|
+
--dry-run) dry=1; shift ;; --yes|-y) shift ;;
|
|
1180
|
+
--fingerprint) fp="${2:?}"; shift 2 ;; --fingerprint=*) fp="${1#*=}"; shift ;;
|
|
1181
|
+
--actor) actor="${2:?}"; shift 2 ;; --actor=*) actor="${1#*=}"; shift ;;
|
|
1182
|
+
--allow-danger|--allow-dangerous) allow_danger=1; shift ;;
|
|
1183
|
+
-) if [ -z "$cat" ]; then cat='-'; elif [ -z "$model" ]; then model='-'; else team_usage_die 'set-task-model: 多余参数'; fi; shift ;;
|
|
1184
|
+
-*) team_usage_die "set-task-model: 未知参数 $1" ;;
|
|
1185
|
+
*) if [ -z "$cat" ]; then cat="$1"; elif [ -z "$model" ]; then model="$1"; else team_usage_die 'set-task-model: 多余参数'; fi; shift ;;
|
|
1186
|
+
esac
|
|
1187
|
+
done
|
|
1188
|
+
local path reason; path="$(team_config_contract_path)" || return 1
|
|
1189
|
+
if ! team_category_valid "$cat" || [[ "$model" == *=* ]]; then reason='set-task-model requires category provider/model (no removal/fallback)'
|
|
1190
|
+
elif ! reason="$(team_config_model_violation "$model")"; then :
|
|
1191
|
+
else reason=''; fi
|
|
1192
|
+
if [ -n "$reason" ]; then
|
|
1193
|
+
team_err "$reason"
|
|
1194
|
+
[ "$dry" = 1 ] || team_config_audit_write invalid "$actor" TEAM_TASK_MODELS "$(team_config_file_value "$path" TEAM_TASK_MODELS)" "$cat=$model" "$(team_config_fingerprint "$path")" || true
|
|
1195
|
+
return 4
|
|
1196
|
+
fi
|
|
1197
|
+
if [ "$dry" = 1 ]; then team_config_task_upsert "$path" "$cat" "$model" "$actor" "$dry" "$fp" "$allow_danger"
|
|
1198
|
+
else team_with_lock "config:$path" team_config_locked_call team_config_task_upsert "$path" "$cat" "$model" "$actor" "$dry" "$fp" "$allow_danger"; fi
|
|
1199
|
+
}
|
|
1200
|
+
team_config_task_upsert() {
|
|
1201
|
+
local path="$1" cat="$2" model="$3" actor="$4" dry="$5" fp="$6" allow_danger="${7:-0}" old new
|
|
1202
|
+
old="$(team_config_file_value "$path" TEAM_TASK_MODELS)"
|
|
1203
|
+
[ -z "$old" ] || team_task_map_violation "$old" >/dev/null || { team_err '现有映射非法;请 config set TEAM_TASK_MODELS <完整映射> 修复'; return 4; }
|
|
1204
|
+
new="$(team_config_pairlist_upsert "$old" "$cat" "$model")"
|
|
1205
|
+
team_config_write_checked TEAM_TASK_MODELS "$new" "$actor" "$dry" "$fp" "$allow_danger"
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
# Only the four relevant keys are located; unsafe Bash shapes are NOT rewritten.
|
|
1209
|
+
team_config_model_source_shape() {
|
|
1210
|
+
local path="$1" line n=0 key rhs comment quote ch i depth=0 seen=' '
|
|
1211
|
+
while IFS= read -r line || [ -n "$line" ]; do
|
|
1212
|
+
n=$((n + 1))
|
|
1213
|
+
[[ "$line" =~ ^[[:space:]]*# ]] && continue
|
|
1214
|
+
case "$line" in *TEAM_DEFAULT_MODEL*|*TEAM_AGENT_MODELS*|*TEAM_TASK_MODELS*|*TEAM_PM_MODEL*) ;;
|
|
1215
|
+
*)
|
|
1216
|
+
[[ "$line" =~ ^[[:space:]]*(if|case|for|while|until|function)[[:space:]] ]] && depth=$((depth+1))
|
|
1217
|
+
[[ "$line" =~ ^[[:space:]]*(fi|esac|done)([[:space:];]|$) ]] && depth=$((depth>0 ? depth-1 : 0))
|
|
1218
|
+
continue ;;
|
|
1219
|
+
esac
|
|
1220
|
+
if ! [[ "$line" =~ ^(TEAM_DEFAULT_MODEL|TEAM_AGENT_MODELS|TEAM_TASK_MODELS|TEAM_PM_MODEL)= ]] || [ "$depth" -gt 0 ]; then
|
|
1221
|
+
team_err "$path:$n: unsupported relevant source shape;请手工规范为顶层唯一 KEY='literal' 后重试"; return 5
|
|
1222
|
+
fi
|
|
1223
|
+
key="${BASH_REMATCH[1]}"
|
|
1224
|
+
case "$seen" in *" $key "*) team_err "$path:$n: duplicate $key;请手工规范"; return 5 ;; esac
|
|
1225
|
+
seen="$seen$key "
|
|
1226
|
+
comment="$(printf '%s' "$line" | team_config_inline_comment_of_line)"
|
|
1227
|
+
rhs="${line#*=}"; [ -z "$comment" ] || rhs="${rhs%"$comment"}"
|
|
1228
|
+
rhs="$(team_trim "$rhs")"
|
|
1229
|
+
quote=''; i=0
|
|
1230
|
+
if [[ "$rhs" == \"* ]]; then
|
|
1231
|
+
[[ "$rhs" == *\" ]] && [ "${#rhs}" -ge 2 ] || { team_err "$path:$n: multiline/unclosed literal"; return 5; }
|
|
1232
|
+
rhs="${rhs:1:${#rhs}-2}"
|
|
1233
|
+
case "$rhs" in *'$'*|*'`'*|*'\\'*|*'"'*) team_err "$path:$n: expanding double quote;请规范单行 literal"; return 5 ;; esac
|
|
1234
|
+
elif [[ "$rhs" == "'"* ]]; then
|
|
1235
|
+
while [ "$i" -lt "${#rhs}" ]; do
|
|
1236
|
+
ch="${rhs:i:1}"
|
|
1237
|
+
if [ "$quote" = single ]; then [ "$ch" != "'" ] || quote=''
|
|
1238
|
+
else
|
|
1239
|
+
if [ "$ch" = "'" ]; then quote=single
|
|
1240
|
+
elif [ "${rhs:i:2}" = "\\'" ]; then i=$((i+1))
|
|
1241
|
+
else team_err "$path:$n: unsupported literal concatenation"; return 5; fi
|
|
1242
|
+
fi
|
|
1243
|
+
i=$((i+1))
|
|
1244
|
+
done
|
|
1245
|
+
[ -z "$quote" ] || { team_err "$path:$n: multiline/unclosed literal"; return 5; }
|
|
1246
|
+
elif ! [[ "$rhs" =~ ^[a-zA-Z0-9_./:=+-]+$ ]]; then
|
|
1247
|
+
team_err "$path:$n: dynamic/indirect value;请规范顶层单行 literal"; return 5
|
|
1248
|
+
fi
|
|
1249
|
+
done < "$path"
|
|
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
|
+
}
|
|
1482
|
+
team_cmd_config_upgrade_models() {
|
|
1483
|
+
local map='' pm='' dry=1 yes="${TEAM_UPGRADE_CONFIRMED:-0}" fp='' actor="${TEAM_ACTOR:-cli}"
|
|
1484
|
+
[ "$yes" != 1 ] || dry=0
|
|
1485
|
+
while [ $# -gt 0 ]; do
|
|
1486
|
+
case "$1" in
|
|
1487
|
+
--task-models) map="${2:?}"; shift 2 ;; --pm-model) pm="${2:?}"; shift 2 ;;
|
|
1488
|
+
--dry-run) dry=1; shift ;; --yes|-y) yes=1; dry=0; shift ;;
|
|
1489
|
+
--fingerprint) fp="${2:?}"; shift 2 ;; --fingerprint=*) fp="${1#*=}"; shift ;;
|
|
1490
|
+
--actor) actor="${2:?}"; shift 2 ;; *) team_usage_die "upgrade-models: 未知参数 $1" ;;
|
|
1491
|
+
esac
|
|
1492
|
+
done
|
|
1493
|
+
[ -n "$map" ] && [ -n "$pm" ] || { team_err 'upgrade-models requires --task-models <完整映射> --pm-model <独立模型>;默认 preview,--yes 才写'; return 4; }
|
|
1494
|
+
local path; path="$(team_config_contract_path)" || return 1
|
|
1495
|
+
if [ "$dry" = 1 ]; then team_config_upgrade_transaction "$path" "$map" "$pm" "$dry" "$fp" "$actor"
|
|
1496
|
+
else team_with_lock "config:$path" team_config_locked_call team_config_upgrade_transaction "$path" "$map" "$pm" "$dry" "$fp" "$actor"; fi
|
|
1497
|
+
}
|
|
1498
|
+
# <path> <map> <pm> <dry> <fp> <actor> [KEY=VALUE…(附加键,默认空;手工入口不受影响)]
|
|
1499
|
+
team_config_upgrade_transaction() {
|
|
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=("$@")
|
|
1503
|
+
before="$(team_config_fingerprint "$path")"
|
|
1504
|
+
if ! team_task_map_violation "$map" || ! team_config_model_violation "$pm"; then
|
|
1505
|
+
[ "$dry" = 1 ] || team_config_audit_write invalid "$actor" model-upgrade "$before" '' || true
|
|
1506
|
+
return 4
|
|
1507
|
+
fi
|
|
1508
|
+
if [ -n "$fp" ] && [ "$before" != "$fp" ]; then
|
|
1509
|
+
[ "$dry" = 1 ] || team_config_audit_write conflict "$actor" model-upgrade "$before" '' "$fp" "$before" || true
|
|
1510
|
+
team_err 'upgrade-models: 指纹不符,未写'; return 3
|
|
1511
|
+
fi
|
|
1512
|
+
if ! team_config_model_source_shape "$path"; then
|
|
1513
|
+
[ "$dry" = 1 ] || team_config_audit_write refused "$actor" model-upgrade "$before" '' || true
|
|
1514
|
+
return 5
|
|
1515
|
+
fi
|
|
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"
|
|
1518
|
+
[ "$dry" != 1 ] || { printf 'dry-run: no config/audit mutation; --yes to commit\n'; return 0; }
|
|
1519
|
+
tmp="$(mktemp "$(dirname "$path")/.model-upgrade.XXXXXX")" || {
|
|
1520
|
+
team_config_audit_write write-error "$actor" model-upgrade "$before" '' || true; return 6;
|
|
1521
|
+
}
|
|
1522
|
+
cp -p "$path" "$tmp" || {
|
|
1523
|
+
rm -f "$tmp"; team_config_audit_write write-error "$actor" model-upgrade "$before" '' || true; return 6;
|
|
1524
|
+
}
|
|
1525
|
+
local wrote=0
|
|
1526
|
+
team_config_set_in_file "$tmp" TEAM_DEFAULT_MODEL '' remove &&
|
|
1527
|
+
team_config_set_in_file "$tmp" TEAM_AGENT_MODELS '' remove &&
|
|
1528
|
+
team_config_set_in_file "$tmp" TEAM_TASK_MODELS "$map" &&
|
|
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
|
|
1546
|
+
if [ "$rc" = 0 ] && [ "$(team_config_fingerprint "$path")" != "$before" ]; then rc=3; fi
|
|
1547
|
+
if [ "$rc" = 0 ]; then mv -f "$tmp" "$path" || rc=6; fi
|
|
1548
|
+
rm -f "$tmp"
|
|
1549
|
+
if [ "$rc" != 0 ]; then
|
|
1550
|
+
local result=write-error; [ "$rc" != 3 ] || result=conflict
|
|
1551
|
+
team_config_audit_write "$result" "$actor" model-upgrade "$before" '' || true
|
|
1552
|
+
return "$rc"
|
|
1553
|
+
fi
|
|
1554
|
+
after="$(team_config_fingerprint "$path")"
|
|
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
|
|
1558
|
+
printf 'committed: before=%s after=%s\n' "$before" "$after"
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1131
1561
|
# ---------------------------------------------------------------- 子命令分发
|
|
1132
1562
|
team_cmd_config() {
|
|
1133
1563
|
local sub="${1:-}"
|
|
@@ -1136,21 +1566,25 @@ team_cmd_config() {
|
|
|
1136
1566
|
list) team_cmd_config_list "$@" ;;
|
|
1137
1567
|
set) team_cmd_config_set "$@" ;;
|
|
1138
1568
|
log) team_cmd_config_log "$@" ;;
|
|
1139
|
-
set-
|
|
1569
|
+
set-task-model) team_cmd_config_set_task_model "$@" ;;
|
|
1570
|
+
upgrade-models) team_cmd_config_upgrade_models "$@" ;;
|
|
1571
|
+
set-agent-model) team_err "retired: use $TEAM_CLI config set-task-model <category> <model> or config set TEAM_PM_MODEL <model>"; return 5 ;;
|
|
1140
1572
|
''|help|-h|--help)
|
|
1141
1573
|
cat <<EOF
|
|
1142
|
-
用法: $TEAM_CLI config <list|set|log|set-
|
|
1574
|
+
用法: $TEAM_CLI config <list|set|log|set-task-model|upgrade-models> …
|
|
1143
1575
|
|
|
1144
1576
|
$TEAM_CLI config list [--json] 列出契约里每个键(class/kind/当前值/默认值)与
|
|
1145
|
-
models
|
|
1577
|
+
models 块(未来策略与已提交启动身份)
|
|
1146
1578
|
$TEAM_CLI config set <KEY> <VALUE> [--dry-run] 唯一写入口:校验 → 指纹 CAS → 原子写 → 审计
|
|
1147
1579
|
[--fingerprint <sha256>] [--actor <name>] [--allow-danger]
|
|
1148
|
-
$TEAM_CLI config set-
|
|
1580
|
+
$TEAM_CLI config set-task-model <category> <model> 新增/修改类别模型,不改已派身份
|
|
1581
|
+
$TEAM_CLI config upgrade-models --task-models <map> --pm-model <model> [--dry-run] [--yes]
|
|
1582
|
+
[--fingerprint <sha256>] [--actor <name>] 显式四键事务升级
|
|
1149
1583
|
$TEAM_CLI config log [N] 审计尾部(默认 10 行)
|
|
1150
1584
|
|
|
1151
|
-
退出码: 0 写入/校验通过 | 3 指纹冲突 | 4 值不合法 | 5
|
|
1585
|
+
退出码: 0 写入/校验通过 | 3 指纹冲突 | 4 值不合法 | 5 这个键不能由命令改 | 6 写失败 | 7 危险值需 --allow-danger
|
|
1152
1586
|
EOF
|
|
1153
1587
|
;;
|
|
1154
|
-
*) team_usage_die "config: 未知子命令 $sub(list|set|log|set-
|
|
1588
|
+
*) team_usage_die "config: 未知子命令 $sub(list|set|log|set-task-model|upgrade-models)" ;;
|
|
1155
1589
|
esac
|
|
1156
1590
|
}
|