teamsmith 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +8 -8
  2. package/package.json +2 -6
  3. package/skills/teamsmith/CHANGELOG.md +77 -0
  4. package/skills/teamsmith/SKILL.md +83 -163
  5. package/skills/teamsmith/extension/team-inbox-watch.ts +30 -1
  6. package/skills/teamsmith/extension/team-notify.ts +162 -21
  7. package/skills/teamsmith/extension/team-reply.ts +105 -0
  8. package/skills/teamsmith/references/agent-adapters.md +4 -2
  9. package/skills/teamsmith/references/config.md +21 -12
  10. package/skills/teamsmith/references/migration.md +47 -3
  11. package/skills/teamsmith/references/protocol.md +85 -31
  12. package/skills/teamsmith/references/reminders.md +131 -0
  13. package/skills/teamsmith/references/troubleshooting.md +26 -8
  14. package/skills/teamsmith/references/workflows.md +18 -16
  15. package/skills/teamsmith/scripts/lib/cmd-agents.sh +290 -68
  16. package/skills/teamsmith/scripts/lib/cmd-config.sh +1 -1
  17. package/skills/teamsmith/scripts/lib/cmd-project.sh +193 -21
  18. package/skills/teamsmith/scripts/lib/cmd-remind.sh +103 -0
  19. package/skills/teamsmith/scripts/lib/cmd-status.sh +177 -21
  20. package/skills/teamsmith/scripts/lib/cmd-update.sh +7 -4
  21. package/skills/teamsmith/scripts/lib/cmd-watch.sh +11 -1
  22. package/skills/teamsmith/scripts/lib/common.sh +50 -6
  23. package/skills/teamsmith/scripts/lib/outbox.sh +103 -21
  24. package/skills/teamsmith/scripts/panel/panel.js +1 -1
  25. package/skills/teamsmith/scripts/panel/src/strings/en.ts +1 -1
  26. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +1 -1
  27. package/skills/teamsmith/scripts/remind-store.mjs +529 -0
  28. package/skills/teamsmith/scripts/replies.mjs +9 -3
  29. package/skills/teamsmith/scripts/reply-capture.mjs +596 -0
  30. package/skills/teamsmith/scripts/state-authority.mjs +500 -0
  31. package/skills/teamsmith/scripts/strings/commands.tsv +2 -1
  32. package/skills/teamsmith/scripts/strings/help.en.tsv +16 -2
  33. package/skills/teamsmith/scripts/strings/help.zh.tsv +16 -2
  34. package/skills/teamsmith/scripts/team +2 -0
  35. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +68 -123
  36. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +48 -55
  37. package/skills/teamsmith/templates/config.sh.tmpl +2 -1
  38. package/skills/teamsmith/templates/pm-prompt.md.tmpl +126 -119
  39. package/skills/teamsmith/tests/bg-ledger-harness.mjs +17 -6
  40. package/skills/teamsmith/tests/bg-ledger.sh +16 -5
  41. package/skills/teamsmith/tests/checkout-shape-probe.sh +6 -5
  42. package/skills/teamsmith/tests/delivery-truth.sh +82 -47
  43. package/skills/teamsmith/tests/fixtures/delivery-truth-real/README.md +71 -23
  44. package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
  45. package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-dirty-ab.py +143 -0
  46. package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py +26 -9
  47. package/skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh +92 -20
  48. package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +47 -3
  49. package/skills/teamsmith/tests/fixtures/reply-capture-provider.ts +76 -0
  50. package/skills/teamsmith/tests/flip-p410-order2.sh +205 -0
  51. package/skills/teamsmith/tests/frames/README.md +3 -1
  52. package/skills/teamsmith/tests/gate-guard.sh +20 -4
  53. package/skills/teamsmith/tests/help-surface.sh +61 -3
  54. package/skills/teamsmith/tests/install-shape.sh +400 -38
  55. package/skills/teamsmith/tests/key-replies-pty.sh +197 -21
  56. package/skills/teamsmith/tests/key-replies.sh +187 -68
  57. package/skills/teamsmith/tests/ledger-claim.sh +8 -6
  58. package/skills/teamsmith/tests/lib/box-judge.sh +2 -1
  59. package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +104 -0
  60. package/skills/teamsmith/tests/lib/pm-window.sh +127 -0
  61. package/skills/teamsmith/tests/lib/reply-fixture.sh +7 -19
  62. package/skills/teamsmith/tests/lib/reply-guard.sh +188 -0
  63. package/skills/teamsmith/tests/lib/section-calls.pl +171 -0
  64. package/skills/teamsmith/tests/loop-inventory.tsv +7 -5
  65. package/skills/teamsmith/tests/meta-suite.sh +215 -0
  66. package/skills/teamsmith/tests/panel-b3-pty-mouse.py +154 -17
  67. package/skills/teamsmith/tests/panel-b3.sh +33 -4
  68. package/skills/teamsmith/tests/panel-choices.sh +11 -7
  69. package/skills/teamsmith/tests/remind-cli.sh +574 -0
  70. package/skills/teamsmith/tests/reply-capture-real.mjs +360 -0
  71. package/skills/teamsmith/tests/reply-capture-real.sh +5 -0
  72. package/skills/teamsmith/tests/reply-capture.mjs +622 -0
  73. package/skills/teamsmith/tests/section-paths.tsv +41 -10
  74. package/skills/teamsmith/tests/section-select.sh +180 -26
  75. package/skills/teamsmith/tests/smoke.sh +1829 -249
  76. package/skills/teamsmith/tests/state-authority-node.mjs +42 -0
  77. package/skills/teamsmith/tests/state-authority.sh +629 -0
  78. package/skills/teamsmith/tests/task-model-routing.sh +10 -1
  79. package/skills/teamsmith/tests/team-inbox-watch-harness.mjs +33 -0
  80. package/skills/teamsmith/tests/team-notify-knock-marker.mjs +91 -0
  81. package/skills/teamsmith/tests/workflow-entry.sh +123 -3
  82. package/skills/teamsmith-init/SKILL.md +1 -1
@@ -1490,7 +1490,16 @@ if has flip; then
1490
1490
  init-legacy-proceeds)
1491
1491
  check flip-init-legacy-proceeds-plain grep -q '^FAIL init-legacy-plain-refused$' "$TMP/flip-$mutation.log"
1492
1492
  check flip-init-legacy-proceeds-force grep -q '^FAIL init-legacy-force-refused$' "$TMP/flip-$mutation.log"
1493
- check flip-init-legacy-proceeds-bootstrap grep -q '^FAIL init-legacy-bootstrap-refused$' "$TMP/flip-$mutation.log" ;;
1493
+ # P377:**非 --print** 的 bootstrap 在变异 scratch 上不能按 rc 判红。scratch 只拷
1494
+ # scripts/references/templates/extension(不看 SKILL.md、也不带 teamsmith-init / handover),
1495
+ # 不是可安装的 skill 源:闸门一拆,bootstrap 过了策略闸门就在装 skill 处 rc=1
1496
+ # (`✗ 技能源不合法:… 没有 SKILL.md`)。于是 `init-legacy-bootstrap-refused`(只看
1497
+ # rc≠0)在变异体上假绿、在**控制与变异两侧都绿**,这条臂点不到名(0.3.4 冻结门的唯一红)。
1498
+ # 闸门被拆掉后同一路径上**真的消失**的是拒绝输出里的推导路线 —— 用它做命名断言;
1499
+ # rc 侧的翻转由不装 skill 的 --print 路径证明(变异体 rc=0 → 拒绝断言红)。
1500
+ check flip-init-legacy-proceeds-bootstrap grep -q '^FAIL init-legacy-bootstrap-derived$' "$TMP/flip-$mutation.log"
1501
+ check flip-init-legacy-proceeds-bootstrap-startup grep -q '^FAIL init-legacy-bootstrap-startup-route$' "$TMP/flip-$mutation.log"
1502
+ check flip-init-legacy-proceeds-print grep -q '^FAIL init-legacy-print-refused$' "$TMP/flip-$mutation.log" ;;
1494
1503
  template-retired-key)
1495
1504
  check flip-template-retired-key-specific grep -q '^FAIL init-fresh-no-retired-key$' "$TMP/flip-$mutation.log" ;;
1496
1505
  migration-row-removed)
@@ -378,6 +378,16 @@ if (only('S4')) {
378
378
  const body = lastText()
379
379
  check('S4 long payload is truncated in the wake (no payload dump)', !body.includes('TAIL-MARKER') && body.includes('…'),
380
380
  `len=${body.length}`)
381
+ // notice-fulltext-and-asks(P370 B):wake 这一层**自己**剪、自己说(160 字的剪断常常把 spool 层那个标记
382
+ // 剪掉)—— 必须看得见 `truncated=preview:<shown>/<total>B` 与指向 durable 收件箱的 `full=`。
383
+ {
384
+ const wakeLine = body.split('\n').find(l => l.startsWith('- ') && l.includes('…')) ?? ''
385
+ const m = /truncated=preview:(\d+)\/(\d+)B full=(\S+)/.exec(wakeLine)
386
+ const preview = process.env.TEAM_INBOX_WATCH_PREVIEW
387
+ check('S4 the wake names its own cut and where the whole text is',
388
+ !!m && Number(m[1]) > 0 && Number(m[1]) < Number(m[2]) && /\/inbox\/pm\.md$/.test(m[3]),
389
+ `${m ? `shown=${m[1]} total=${m[2]} full=${m[3]}` : 'no marker'} preview=${preview} :: ${wakeLine}`)
390
+ }
381
391
  const before2 = sent.length
382
392
  for (let i = 0; i < 8; i++) appendWake('say', 'dev', 'pm', `many ${i}`)
383
393
  await sleep(600)
@@ -1054,6 +1064,29 @@ const degradedFiles = () => (existsSync(WATCH_DIR) ? readdirSync(WATCH_DIR).filt
1054
1064
  process.env.TEAM_INBOX_WATCH_POLL_MS = '3600000'
1055
1065
  }
1056
1066
 
1067
+ // ── S27(P370 B)· wake 层自己写截断标记:**轮询路径**(不依赖 fs.watch)────────────
1068
+ // 为什么要有这一条:S4 走 watcher,前提不可用时只能可见 SKIP;而「预览被剪就说出来」是产品的行为,
1069
+ // 不该随机器能力变成空跑。这里用 100ms 轮询把同一条行为再判一次(两种前提下都真跑)。
1070
+ process.env.TEAM_INBOX_WATCH_POLL_MS = '100'
1071
+ if (only('S27')) {
1072
+ await resetState()
1073
+ await sessionStart()
1074
+ const before = sent.length // sent 是跨用例的累积数组:只看**这一拍新增**的那条
1075
+ appendWake('knock', 'dev', 'pm', `${'X'.repeat(400)}TAIL-MARKER`)
1076
+ const woke = await waitFor(() => sent.length > before)
1077
+ const body = lastText()
1078
+ const m = /truncated=preview:(\d+)\/(\d+)B full=(\S+)/.exec(body)
1079
+ check('S27 the wake names its own cut and where the whole text is',
1080
+ woke && !!m && Number(m[1]) > 0 && Number(m[1]) < Number(m[2]) && /\/inbox\/pm\.md$/.test(m[3]) && !body.includes('TAIL-MARKER'),
1081
+ `${m ? `shown=${m[1]} total=${m[2]} full=${m[3]}` : 'no marker'} preview=${process.env.TEAM_INBOX_WATCH_PREVIEW} :: ${body.replace(/\n/g, ' | ').slice(0, 220)}`)
1082
+ const before2 = sent.length
1083
+ appendWake('say', 'pm', 'pm', 'S27 short line with no cut')
1084
+ await waitFor(() => sent.length > before2)
1085
+ check('S27 a preview that was not cut carries no marker', sent.length > before2 && !lastText().includes('truncated='),
1086
+ lastText().replace(/\n/g, ' | ').slice(0, 220))
1087
+ }
1088
+ process.env.TEAM_INBOX_WATCH_POLL_MS = '100'
1089
+
1057
1090
  // ═══════════════════════════════════════════════════════════════════════════════
1058
1091
  // P81 · wake-delivery-idempotence:投递日志 / 至多一次 / fail-closed / 源行点名
1059
1092
  // 事故:一条 nudge 让 PM 在一个多小时里被「同一条」叫醒三次,而 durable 文件回答不了
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env node
2
+ // P370 · 敲门层的标记样品(`smoke.sh` §12b-pi 的三层形状比对之一:TS×2 + bash×1 必须同一种标记)。
3
+ //
4
+ // node skills/teamsmith/tests/team-notify-knock-marker.mjs skills/teamsmith/extension/team-notify.ts
5
+ //
6
+ // 做法:在一个一次性 git 项目 + 工作树里,用**产品扩展本身**跑一次 `agent_settled`(末消息 3000 字),
7
+ // 再从它产出的敲门载荷里取出那串 `truncated=preview:<shown>/<total>B full=<path>[:<line>]`,打到 stdout。
8
+ // 假 tmux 只在 PATH 里:它让投递走既有的「多行内容落成 draft 文件、只打一行指针」路径,于是载荷落在
9
+ // 项目自己的 `state/draft/` 里可读。
10
+ //
11
+ // 没有载荷 / 载荷没有被剪 / 扩展报错 → stdout 空、退出码 0:判定留给调用方("缺样品" 在那里是红,
12
+ // 不是这里的热闹)。真正的失败信息走 stderr,调用方把它贴进门禁日志。
13
+ import { execFileSync } from 'node:child_process'
14
+ import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'
15
+ import { tmpdir } from 'node:os'
16
+ import { join, resolve } from 'node:path'
17
+
18
+ const ext = resolve(process.argv[2] ?? '')
19
+ if (!existsSync(ext)) {
20
+ console.error(`team-notify-knock-marker: 找不到扩展 ${ext}`)
21
+ process.exit(2)
22
+ }
23
+
24
+ // 身份隔离(M7.2 纪律):一条继承来的 TEAM_* 都不许把样品指到真实项目/真实账本上。
25
+ for (const k of Object.keys(process.env)) if (k.startsWith('TEAM_')) delete process.env[k]
26
+ delete process.env.TMUX_PANE
27
+ delete process.env.TMUX
28
+
29
+ const TMP = mkdtempSync(join(tmpdir(), 'p370-knock-'))
30
+ process.on('exit', () => { try { rmSync(TMP, { recursive: true, force: true }) } catch { /* ignore */ } })
31
+
32
+ const ROOT = join(TMP, 'repo')
33
+ const WT = join(ROOT, '.worktrees/dev')
34
+ const git = (...a) => execFileSync('git', ['-C', ROOT, ...a], { stdio: 'pipe' })
35
+ mkdirSync(join(ROOT, 'docs/team/inbox'), { recursive: true })
36
+ mkdirSync(join(ROOT, '.pi/team'), { recursive: true })
37
+ git('init', '-q', '-b', 'main')
38
+ git('config', 'user.email', 'knock-marker@teamsmith')
39
+ git('config', 'user.name', 'knock-marker')
40
+ writeFileSync(join(ROOT, 'README.md'), '# p370 knock marker\n')
41
+ writeFileSync(join(ROOT, '.pi/team/config.sh'), [
42
+ 'TEAM_PROJECT="p370-knock"', 'TEAM_SESSION="p370-knock"', 'TEAM_PM_WINDOW="pm"',
43
+ 'TEAM_WORKTREES_DIR=".worktrees"', 'TEAM_DOCS_DIR="docs/team"',
44
+ 'TEAM_NOTIFY_TMUX="1"', 'TEAM_NOTIFY_DEDUP_SEC="0"', 'TEAM_INBOX_MAX_CHARS="150"',
45
+ `TEAM_NOTIFY_LOG="${join(TMP, 'notify.log')}"`, 'TEAM_AGENTS="dev"', '',
46
+ ].join('\n'))
47
+ git('add', '-A')
48
+ git('commit', '-qm', 'init')
49
+ git('worktree', 'add', '-q', '-b', 'agent/dev', WT)
50
+
51
+ const shim = join(TMP, 'shim')
52
+ mkdirSync(shim)
53
+ writeFileSync(join(shim, 'tmux'), `#!/usr/bin/env bash
54
+ case "$*" in
55
+ *pane_current_command*) printf 'pi\\n' ;;
56
+ *window_name*) printf 'dev\\n' ;;
57
+ *session_name*) printf 'p370-knock\\n' ;;
58
+ *) printf '' ;;
59
+ esac
60
+ exit 0
61
+ `, { mode: 0o755 })
62
+ process.env.PATH = `${shim}:${process.env.PATH}`
63
+ process.env.TMUX_PANE = 'knock-marker-pane'
64
+
65
+ const mod = await import(`${ext}?t=${Date.now()}`)
66
+ let settle = null
67
+ mod.default({ on: (n, f) => { if (n === 'agent_settled') settle = f }, registerCommand: () => {}, registerTool: () => {}, sendMessage: () => {} })
68
+ if (!settle) {
69
+ console.error('team-notify-knock-marker: 扩展没有注册 agent_settled')
70
+ process.exit(3)
71
+ }
72
+
73
+ // 3000 字 > TEAM_INBOX_MAX_CHARS(150):载荷必然被剪,于是必然带标记。
74
+ const text = 'P370-KNOCK-MARKER-' + 'q'.repeat(2980)
75
+ await settle({}, { cwd: WT, sessionManager: { getEntries: () => [{ message: { role: 'assistant', stopReason: 'stop', content: [{ text }] } }] } })
76
+
77
+ const state = join(ROOT, '.pi/team/state')
78
+ const walk = (d) => { try { return readdirSync(d, { withFileTypes: true }).flatMap(e => e.isDirectory() ? walk(join(d, e.name)) : [join(d, e.name)]) } catch { return [] } }
79
+ const payloads = [...walk(join(state, 'draft')), ...walk(join(state, 'outbox'))]
80
+ .map(f => { try { return readFileSync(f, 'utf8') } catch { return '' } })
81
+ .filter(t => t.includes('P370-KNOCK-MARKER-'))
82
+ if (payloads.length === 0) {
83
+ console.error('team-notify-knock-marker: 一次 settle 之后找不到敲门载荷(state/draft 与 state/outbox 都是空的)')
84
+ process.exit(0)
85
+ }
86
+ const marker = payloads.map(t => /truncated=preview:[0-9]+\/[0-9]+B full=[^ \n]*/.exec(t)).find(Boolean)
87
+ if (!marker) {
88
+ console.error(`team-notify-knock-marker: 载荷被剪了却没有标记(${payloads[0].slice(0, 120)}…)`)
89
+ process.exit(0)
90
+ }
91
+ console.log(marker[0])
@@ -6,16 +6,21 @@
6
6
  # 2026-10-20 C4 里**已经真跑过**的那次宿主侧检查固化成可重跑的入口:它执行的是工作流**自己的**
7
7
  # `run:` 块(不是对 YAML 的再解释),只把两个 GitHub 表达式换成环境值、把 `docker` 换成记录 argv 的桩。
8
8
  #
9
- # 只验三件已经成立过的行为(不建解析框架、不建矩阵):
9
+ # 只验四件已经成立过的行为(不建解析框架、不建矩阵):
10
10
  # ① 有效基点 + 特殊文件名(换行 / 空格 / 引号+反斜杠)→ 路径逐字节到达容器的套件参数,
11
11
  # 且容器命令里带 `--floor --paths "$@"`;
12
12
  # ② 基点不可解析(空 / 全零 / 不在仓里)→ 一条 `::warning::` + 退回**全套**(命令里没有 `--floor`);
13
13
  # ③ 底层执行失败(docker rc≠0)→ 这一步照旧非 0(失败不被 `|| true` 之类吞掉)。
14
+ # ④ P380:版本比较是**可执行**的,且**两条到容器的路**(`--floor --paths` 与退回全套)都被覆盖。
15
+ # 容器命令把比较交给 `ci/check-pi-version.sh`(`"$PI_EXPECT_VERSION"` 与现场 `pi --version`),
16
+ # 本段用**受控 pi** 真的把每一支跑起来:相等 → rc=0 并打印实测值;不等 → 非 0 且点名两边。每支另有
17
+ # 一条影子断言:把比较从容器命令里删掉,同一份「不等」输入必须逃过去 —— 证明那条红由比较产生,不是
18
+ # 字符串长得像。删掉比较(整条或只留 printf)或删掉任一支的 `-e PI_EXPECT_VERSION` 都会点名变红。
14
19
  #
15
20
  # 用法:
16
21
  # bash skills/teamsmith/tests/workflow-entry.sh [--tree <仓库根>]
17
22
  # 退出码:
18
- # 0 = 三条行为都成立;1 = 有不成立项(逐条 ✗ 并点名);2 = 缺前提(打印 SKIP(条件不满足)——
23
+ # 0 = 四条行为都成立;1 = 有不成立项(逐条 ✗ 并点名);2 = 缺前提(打印 SKIP(条件不满足)——
19
24
  # **跳过不是通过**):检出里没有 `.github/workflows/gates.yml`(产品面检出不含 CI 源码)或宿主没有 git。
20
25
  # 不写工作树:全部落在 $TMPDIR 下的私有根里,退出时删掉自己的根(失败可 TEAM_TMP_KEEP=1 保留现场)。
21
26
  set -uo pipefail
@@ -101,8 +106,11 @@ chmod +x "$STUB/docker"
101
106
 
102
107
  run_block() { # <argv 日志> <stub rc> <before> <sha> → 跑一次工作流的 run 块
103
108
  local log="$1" rc="$2" before="$3" sha="$4"
109
+ # P380:PI_EXPECT_VERSION 是工作流 step env 里的解析结果;这里给一个可辨认的值,
110
+ # 让 ④ 能断言它真的到了容器 argv,而不是只写在 YAML 里。
104
111
  ( cd "$REPO" && PATH="$STUB:$PATH" DOCKER_ARGV="$log" STUB_RC="$rc" \
105
112
  GH_BEFORE="$before" GH_TIP="$sha" TEAM_CI_TMP_ROOT="$TMP/ci-tmp" \
113
+ PI_EXPECT_VERSION="$WF_PI_VERSION" \
106
114
  bash "$BLOCK" )
107
115
  }
108
116
  argv_field() { # <argv 日志> <下标> → 第 N 个参数(NUL 分隔,逐字节)
@@ -113,6 +121,13 @@ argv_field() { # <argv 日志> <下标> → 第 N 个参数(NUL 分隔,逐
113
121
  done < "$log"
114
122
  return 1
115
123
  }
124
+ argv_env_value() { # <argv 日志> <变量名> → `-e VAR=…` 这个元素的值(没有就空)
125
+ local log="$1" var="$2" a
126
+ while IFS= read -r -d '' a; do
127
+ case "$a" in "$var="*) printf '%s' "${a#*=}"; return 0 ;; esac
128
+ done < "$log"
129
+ return 0
130
+ }
116
131
  argv_index_of() { # <argv 日志> <精确值> → 下标(用于找 `_` 这类固定占位符)
117
132
  local log="$1" want="$2" i=0 a
118
133
  while IFS= read -r -d '' a; do
@@ -123,6 +138,8 @@ argv_index_of() { # <argv 日志> <精确值> → 下标(用于找 `_` 这类
123
138
  }
124
139
 
125
140
  # ── ① 有效基点 + 特殊文件名:路径逐字节到达容器的套件参数 ───────────────────────────────────────
141
+ # P380:工作流 step env 从 `resolve-pi` 拿到的值;④ 断言它真的到了容器 argv。
142
+ WF_PI_VERSION="9.9.9"
126
143
  REPO="$TMP/repo"; mkdir -p "$REPO/skills/teamsmith/tests"
127
144
  cp "$WF" "$REPO/gates.yml" # 只为让临时仓库里有一个受版本控制的文件
128
145
  git -C "$REPO" init -q -b main
@@ -183,8 +200,11 @@ for badbase in "" "0000000000000000000000000000000000000000" "no-such-sha-$$"; d
183
200
  CMD2="$(argv_field "$TMP/argv-bad.bin" "$(( $(argv_index_of "$TMP/argv-bad.bin" teamsmith-gates:ci 2>/dev/null || printf 0) + 3 ))")"
184
201
  # 「退回全套」要**正向确认**:命令里必须真的以完整入口跑起来(`bash skills/teamsmith/tests/smoke.sh --keep`
185
202
  # + 前面的 openspec 校验),不能只看「缺了 --floor」—— 命令为空时那个条件也成立。
203
+ # 期望串只钉「两段都在、openspec 校验在前」:`--strict` 不再是本仓的门禁口径(P407:OpenSpec 1.16
204
+ # 把超过 500 字符的需求判成 warning,`--strict` 下 20/20 全红,本仓暂跑非 strict,烧完再开),所以这里
205
+ # 不再钉它;但两段都必须在前面的命令里,退化成只查其中一段就等于没确认「完整入口」。
186
206
  case "$CMD2" in
187
- *'openspec validate --all --strict'*'bash skills/teamsmith/tests/smoke.sh --keep '*) _runs_full=1 ;;
207
+ *'openspec validate --all'*'bash skills/teamsmith/tests/smoke.sh --keep '*) _runs_full=1 ;;
188
208
  *) _runs_full=0 ;;
189
209
  esac
190
210
  if [ "$RC2" -eq 0 ] && grep -qF '::warning::changed-path base is unresolvable' "$TMP/bad.out" \
@@ -204,4 +224,104 @@ else
204
224
  bad "workflow-entry ③:容器执行失败后这一步仍退 0(失败被吞了)"
205
225
  fi
206
226
 
227
+ # ── ④ P380:版本比较是可执行的,且**两条到容器的路都**透传并真的比较 ───────────────────────────
228
+ # 工作流的 run 块有两条路:有可解析基点时 `--floor --paths "$@"`(changed-path),基点不可解析时退回全套
229
+ # (没有 `--floor`)。两条都必须把本轮解析出的 pi 版本交给容器并真的比较 —— 只覆盖其中一条时,删掉另一条的
230
+ # 透传不会有任何断言看得见(V109 的补充)。
231
+ SANDBOX="$TMP/sandbox"; SANDBOX_REPO="$TMP/sandbox-repo"
232
+ mkdir -p "$SANDBOX" "$TMP/ci-tmp"
233
+ printf '#!/usr/bin/env bash\nprintf "%%s\\n" "${STUB_PI_VERSION:?}"\nexit "${STUB_PI_EXIT:-0}"\n' > "$SANDBOX/pi"
234
+ printf '#!/usr/bin/env bash\nexit 0\n' > "$SANDBOX/openspec"
235
+ chmod +x "$SANDBOX/pi" "$SANDBOX/openspec"
236
+ rm -rf "$SANDBOX_REPO"; cp -a "$REPO" "$SANDBOX_REPO"
237
+ mkdir -p "$SANDBOX_REPO/ci" "$SANDBOX_REPO/skills/teamsmith/tests"
238
+ printf '#!/usr/bin/env bash\nexit 0\n' > "$SANDBOX_REPO/skills/teamsmith/tests/smoke.sh"
239
+ chmod +x "$SANDBOX_REPO/skills/teamsmith/tests/smoke.sh"
240
+ if [ -f "$TREE/ci/check-pi-version.sh" ]; then
241
+ cp "$TREE/ci/check-pi-version.sh" "$SANDBOX_REPO/ci/check-pi-version.sh"
242
+ else
243
+ bad "workflow-entry ④:检出里没有 ci/check-pi-version.sh(工作流的两条路都要调它)"
244
+ fi
245
+ # 与工作流里 `docker run … -e PI_EXPECT_VERSION=… -e TMPDIR=… bash -c '<命令>' _ <路径…>` 同一环境。
246
+ run_container_cmd() { # <命令> <受控 pi 报的版本> <argv 里的 PI_EXPECT_VERSION(空 = 没有 -e)> [pi 的退出码]
247
+ # 期望值**取自记录的 argv**,不是取自本脚本的记忆:工作流若不再 `-e PI_EXPECT_VERSION=…`,容器里就没有
248
+ # 这个变量(真实容器里 `set -u` 会让命令直接失败;这里照原样不设),行为断言因此自己变红。
249
+ # 第四个参数让受控 pi「报对版本但自己失败」—— V109 第三处:`"$(pi --version)"` 当参数会把它的退出码丢掉。
250
+ local cmd="$1" ver="$2" expected="$3" pi_exit="${4:-0}"
251
+ local envs=(PATH="$SANDBOX:$PATH" STUB_PI_VERSION="$ver" STUB_PI_EXIT="$pi_exit" SHARD_SLICE="1/4")
252
+ [ -z "$expected" ] || envs+=(PI_EXPECT_VERSION="$expected")
253
+ ( cd "$SANDBOX_REPO" || return 1
254
+ mkdir -p "$TMP/ci-tmp/$ver-$pi_exit" || return 1
255
+ env "${envs[@]}" TMPDIR="$TMP/ci-tmp/$ver-$pi_exit" bash -c "$cmd" _ )
256
+ }
257
+
258
+ check_pi_branch() { # <分支标签> <argv 日志>
259
+ local label="$1" log="$2" cmd rc out shadow expected
260
+ expected="$(argv_env_value "$log" PI_EXPECT_VERSION)"
261
+ if [ "$expected" = "$WF_PI_VERSION" ]; then
262
+ ok "workflow-entry ④[$label]:解析出的 pi 版本作为 PI_EXPECT_VERSION 进了容器 argv"
263
+ else
264
+ bad "workflow-entry ④[$label]:容器 argv 里的 PI_EXPECT_VERSION=${expected:-<缺失>},期望 $WF_PI_VERSION(这一支没把版本交给运行时)"
265
+ fi
266
+ cmd="$(argv_field "$log" "$(( $(argv_index_of "$log" -c) + 1 ))")"
267
+ if [ -z "$cmd" ]; then
268
+ bad "workflow-entry ④[$label]:取不出容器的 bash -c 命令(这一步的形状变了?)"
269
+ return 0
270
+ fi
271
+ case "$cmd" in
272
+ *'ci/check-pi-version.sh'*) ok "workflow-entry ④[$label]:容器命令把版本比较交给可执行检查 ci/check-pi-version.sh(不是内联比对)" ;;
273
+ *) bad "workflow-entry ④[$label]:容器命令没有调用 ci/check-pi-version.sh(比较被内联或删掉了)" ;;
274
+ esac
275
+ out="$(run_container_cmd "$cmd" "$WF_PI_VERSION" "$expected" 2>&1)"; rc=$?
276
+ if [ "$rc" -eq 0 ] && printf '%s' "$out" | grep -qF "pi $WF_PI_VERSION (resolved for this run: $WF_PI_VERSION)"; then
277
+ ok "workflow-entry ④[$label]:受控 pi=$WF_PI_VERSION → 整条容器命令 rc=0,并打印实测值与解析值"
278
+ else
279
+ bad "workflow-entry ④[$label]:受控 pi=$WF_PI_VERSION 没有通过(rc=$rc):$(printf '%s' "$out" | tail -2 | tr '\n' ' ')"
280
+ fi
281
+ out="$(run_container_cmd "$cmd" 0.0.0 "$expected" 2>&1)"; rc=$?
282
+ if [ "$rc" -ne 0 ] && printf '%s' "$out" | grep -qF 'pi 0.0.0' && printf '%s' "$out" | grep -qF "$WF_PI_VERSION"; then
283
+ ok "workflow-entry ④[$label]:受控 pi=0.0.0(≠解析值)→ 整条容器命令 rc=$rc,并点名两边"
284
+ else
285
+ bad "workflow-entry ④[$label]:版本不等没有让容器命令变红/没有点名两边(rc=$rc):$(printf '%s' "$out" | tail -2 | tr '\n' ' ')"
286
+ fi
287
+ # V109 第三处:受控 pi **报对版本但自己退出 42** → 必须先被拒(保留退出码、点名)、不打印「比较成功」。
288
+ out="$(run_container_cmd "$cmd" "$WF_PI_VERSION" "$expected" 42 2>&1)"; rc=$?
289
+ if [ "$rc" -eq 42 ] \
290
+ && printf '%s' "$out" | grep -qF '::error::' \
291
+ && printf '%s' "$out" | grep -qF '42' \
292
+ && ! printf '%s' "$out" | grep -qF "pi $WF_PI_VERSION (resolved for this run"; then
293
+ ok "workflow-entry ④[$label]:受控 pi 报对版本但退出 42 → 整条容器命令 rc=42 并点名,且没有打印「比较成功」"
294
+ else
295
+ bad "workflow-entry ④[$label]:pi --version 的退出码没有被保留/点名(rc=$rc):$(printf '%s' "$out" | tail -2 | tr '\n' ' ')"
296
+ fi
297
+ # 影子(第三处):删掉「检查 pi 自己退出码」那一段(V109 的变异形式:留下读取、不做检查)→ 同一份
298
+ # 「退出 42」输入必须逃过去。否则上面那条红不是由保留退出码产生的。
299
+ STATUS_SHADOW="$(printf '%s' "$cmd" | sed 's#if \[ "$pi_rc" -ne 0 \]; then.*fi; ##')"
300
+ if [ "$STATUS_SHADOW" = "$cmd" ]; then
301
+ bad "workflow-entry ④[$label]:状态影子没生效(容器命令里找不到「检查 pi 退出码」那一段;形状变了,影子要跟着改)"
302
+ else
303
+ out="$(run_container_cmd "$STATUS_SHADOW" "$WF_PI_VERSION" "$expected" 42 2>&1)"; rc=$?
304
+ if [ "$rc" -eq 0 ] && printf '%s' "$out" | grep -qF "pi $WF_PI_VERSION (resolved for this run"; then
305
+ ok "workflow-entry ④[$label]:状态影子(删掉退出码检查)在「退出 42」输入上 rc=0 —— 上面那条红确实由保留退出码产生"
306
+ else
307
+ bad "workflow-entry ④[$label]:状态影子仍然 rc=$rc:说明那条红不是由保留退出码决定的"
308
+ fi
309
+ fi
310
+ # 影子:删掉那条比较 → 同一份「不等」输入必须逃过。否则上面那条红不是由比较决定的(V109 的形状)。
311
+ shadow="$(printf '%s' "$cmd" | sed 's#bash ci/check-pi-version.sh[^;]*;##')"
312
+ if [ "$shadow" = "$cmd" ]; then
313
+ bad "workflow-entry ④[$label]:影子没生效(容器命令里找不到要删的那条比较;形状变了,影子要跟着改)"
314
+ else
315
+ out="$(run_container_cmd "$shadow" 0.0.0 "$expected" 2>&1)"; rc=$?
316
+ if [ "$rc" -eq 0 ]; then
317
+ ok "workflow-entry ④[$label]:影子(删掉比较)在同一份不等输入上 rc=0 —— 上面那条红确实由比较产生"
318
+ else
319
+ bad "workflow-entry ④[$label]:影子(删掉比较)仍然 rc=$rc:说明那条红不是比较决定的"
320
+ fi
321
+ fi
322
+ }
323
+
324
+ check_pi_branch "changed-path" "$TMP/argv-valid.bin"
325
+ check_pi_branch "full-suite" "$TMP/argv-bad.bin"
326
+
207
327
  summary
@@ -3,7 +3,7 @@ name: teamsmith-init
3
3
  description: teamsmith-init is the new-project entry point of the teamsmith toolkit — organize multiple agents into a team, set up an agent collaboration protocol, and bootstrap this skill into a new project. It walks the questions to settle with the user first (dependencies, session and roster, the task-category mapping and the independent PM model, gates, VCS mode, install command, and the project's ROADMAP/OWNERSHIP/AGENTS.md red lines), then runs the one command that writes `.pi/team/config.sh` + the `docs/team/` skeleton + the `AGENTS.md` protocol section and starts the pulse, and finally hands day-to-day operation to the `teamsmith` skill. Use when the user wants to bootstrap teamsmith into a new repository, set up a brand-new team, organize multiple agents into a team, or set up an agent collaboration protocol where none exists yet.
4
4
  license: MIT
5
5
  metadata:
6
- version: "0.3.3"
6
+ version: "0.4.0"
7
7
  ---
8
8
 
9
9
  # teamsmith-init · bring a new project to "ready to dispatch"