teamsmith 0.4.6 → 0.4.8

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 (91) hide show
  1. package/README.md +6 -6
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +35 -0
  4. package/skills/teamsmith/SKILL.md +43 -30
  5. package/skills/teamsmith/extension/team-bg.ts +5 -3
  6. package/skills/teamsmith/extension/team-inbox-watch.ts +14 -3
  7. package/skills/teamsmith/extension/team-notify.ts +20 -13
  8. package/skills/teamsmith/extension/team-remind.ts +189 -0
  9. package/skills/teamsmith/extension/team-reply.ts +4 -7
  10. package/skills/teamsmith/references/config.md +11 -12
  11. package/skills/teamsmith/references/migration.md +101 -0
  12. package/skills/teamsmith/references/openspec.md +43 -27
  13. package/skills/teamsmith/references/protocol.md +26 -15
  14. package/skills/teamsmith/references/reminders.md +153 -161
  15. package/skills/teamsmith/references/troubleshooting.md +12 -7
  16. package/skills/teamsmith/references/workflows.md +84 -31
  17. package/skills/teamsmith/scripts/lib/cmd-agents.sh +10 -4
  18. package/skills/teamsmith/scripts/lib/cmd-project.sh +88 -6
  19. package/skills/teamsmith/scripts/lib/cmd-remind.sh +88 -2
  20. package/skills/teamsmith/scripts/lib/cmd-review.sh +61 -35
  21. package/skills/teamsmith/scripts/lib/cmd-watch.sh +48 -11
  22. package/skills/teamsmith/scripts/lib/common.sh +83 -13
  23. package/skills/teamsmith/scripts/panel/README.md +35 -33
  24. package/skills/teamsmith/scripts/panel/panel.js +217 -199
  25. package/skills/teamsmith/scripts/panel/src/App.tsx +221 -66
  26. package/skills/teamsmith/scripts/panel/src/data.ts +71 -15
  27. package/skills/teamsmith/scripts/panel/src/layout.ts +159 -310
  28. package/skills/teamsmith/scripts/panel/src/main.tsx +83 -21
  29. package/skills/teamsmith/scripts/panel/src/project-settings.ts +46 -0
  30. package/skills/teamsmith/scripts/panel/src/strings/en.ts +71 -205
  31. package/skills/teamsmith/scripts/panel/src/strings/index.ts +3 -5
  32. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +72 -204
  33. package/skills/teamsmith/scripts/panel/src/types.ts +23 -4
  34. package/skills/teamsmith/scripts/remind-capability.mjs +261 -0
  35. package/skills/teamsmith/scripts/remind-store.mjs +55 -24
  36. package/skills/teamsmith/scripts/remind-tick.mjs +5 -2
  37. package/skills/teamsmith/scripts/reply-capture.mjs +8 -9
  38. package/skills/teamsmith/scripts/state-authority.mjs +72 -6
  39. package/skills/teamsmith/scripts/strings/commands.tsv +1 -1
  40. package/skills/teamsmith/scripts/team +1 -0
  41. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +18 -8
  42. package/skills/teamsmith/templates/DECISIONS.md.tmpl +2 -2
  43. package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +3 -3
  44. package/skills/teamsmith/templates/PROTOCOL.md.tmpl +19 -14
  45. package/skills/teamsmith/templates/memory-seed.md.tmpl +2 -2
  46. package/skills/teamsmith/templates/pm-prompt.md.tmpl +41 -25
  47. package/skills/teamsmith/templates/report.md.tmpl +33 -0
  48. package/skills/teamsmith/tests/bg-ledger-harness.mjs +217 -33
  49. package/skills/teamsmith/tests/bg-ledger.sh +24 -10
  50. package/skills/teamsmith/tests/checkout-shape-probe.sh +7 -6
  51. package/skills/teamsmith/tests/fixtures/remind-adversarial-delay.ts +27 -0
  52. package/skills/teamsmith/tests/fixtures/remind-tool-provider.ts +65 -0
  53. package/skills/teamsmith/tests/help-surface.sh +78 -12
  54. package/skills/teamsmith/tests/install-shape.sh +7 -7
  55. package/skills/teamsmith/tests/isolation-ledger.sh +6 -2
  56. package/skills/teamsmith/tests/key-replies-ui.sh +64 -5
  57. package/skills/teamsmith/tests/key-replies.sh +307 -106
  58. package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +2 -0
  59. package/skills/teamsmith/tests/lib/model-routing-boundary.sh +255 -90
  60. package/skills/teamsmith/tests/lib/model-routing-expansion.sh +181 -61
  61. package/skills/teamsmith/tests/lib/model-routing-roles.sh +125 -67
  62. package/skills/teamsmith/tests/lib/reply-fixture.sh +14 -9
  63. package/skills/teamsmith/tests/lib/routes-pages.sh +243 -0
  64. package/skills/teamsmith/tests/lib/tmp-root.sh +1 -1
  65. package/skills/teamsmith/tests/loop-inventory.tsv +3 -0
  66. package/skills/teamsmith/tests/panel-b2.sh +91 -31
  67. package/skills/teamsmith/tests/panel-b3-stub.sh +9 -2
  68. package/skills/teamsmith/tests/panel-p21.sh +607 -1162
  69. package/skills/teamsmith/tests/panel-strings.mjs +21 -113
  70. package/skills/teamsmith/tests/remind-adversarial-faults.mjs +190 -0
  71. package/skills/teamsmith/tests/remind-adversarial-faults.sh +78 -0
  72. package/skills/teamsmith/tests/remind-adversarial-real.sh +28 -0
  73. package/skills/teamsmith/tests/remind-cli.sh +108 -3
  74. package/skills/teamsmith/tests/remind-delivery-node.mjs +13 -0
  75. package/skills/teamsmith/tests/remind-delivery.sh +123 -35
  76. package/skills/teamsmith/tests/remind-lifecycle.sh +197 -0
  77. package/skills/teamsmith/tests/remind-pulse.sh +199 -0
  78. package/skills/teamsmith/tests/remind-recovery-real.sh +5 -0
  79. package/skills/teamsmith/tests/remind-recovery-unit.sh +118 -0
  80. package/skills/teamsmith/tests/remind-tool-node.mjs +159 -0
  81. package/skills/teamsmith/tests/remind-tool-real.mjs +801 -0
  82. package/skills/teamsmith/tests/remind-tool-real.sh +180 -0
  83. package/skills/teamsmith/tests/reply-capture-real.mjs +93 -2
  84. package/skills/teamsmith/tests/routes.sh +213 -293
  85. package/skills/teamsmith/tests/section-paths.tsv +19 -17
  86. package/skills/teamsmith/tests/smoke.sh +583 -133
  87. package/skills/teamsmith/tests/state-authority.sh +152 -8
  88. package/skills/teamsmith/tests/task-model-routing.sh +57 -26
  89. package/skills/teamsmith/tests/tmp-hygiene.sh +1 -1
  90. package/skills/teamsmith-init/SKILL.md +5 -5
  91. package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
@@ -18,30 +18,31 @@
18
18
  # --flip=standby-ignore 迁移不读旧标记 → “迁移保留原因/时间”必须红
19
19
  # --flip=standby-file 读路径退回旧标记文件 → “迁移后旧标记不再是真相”必须红
20
20
  # --flip=standby-write 写待命退回 state/standby → “写入后统一状态记下 on”必须红
21
- # 不带 --flip 时七条臂全跑;带一条时只跑那一条,其余臂跳过(跳过即不计入,不是通过)。
22
- # 用法:bash tests/state-authority.sh [--flip=unlocked|version|foreign|manifest|standby-ignore|standby-file|standby-write]
21
+ # --flip=flock-resolution 解析不再检查执行权限 → “不可执行 flock 必须被拒”必须红
22
+ # 不带 --flip 时八条臂全跑;带一条时只跑那一条,其余臂跳过(跳过即不计入,不是通过)。
23
+ # 用法:bash tests/state-authority.sh [--flip=unlocked|version|foreign|manifest|standby-ignore|standby-file|standby-write|flock-resolution]
23
24
  # 退出码:0 全绿 / 1 有失败 / 2 参数不认识 / 3 前提缺失(JS 运行时或 flock;可见跳过,不算通过)
24
25
  set -uo pipefail
25
26
 
26
27
  HERE="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
27
28
  SKILL="$(cd -P "$HERE/.." && pwd)"
28
29
 
29
- # 参数面:只有这四个 --flip 值;认不出来就拒绝(静默照跑等于把一条臂当成了四条)。
30
+ # 参数面:只接受下列 --flip 值;认不出来就拒绝(静默照跑会把单臂证据当成全套证据)。
30
31
  FLIP=""
31
32
  flip_err() { printf 'state-authority: %s\n' "$1" >&2; }
32
33
  for arg in "$@"; do
33
34
  case "$arg" in
34
- --flip=unlocked|--flip=version|--flip=foreign|--flip=manifest|--flip=standby-ignore|--flip=standby-file|--flip=standby-write)
35
+ --flip=unlocked|--flip=version|--flip=foreign|--flip=manifest|--flip=standby-ignore|--flip=standby-file|--flip=standby-write|--flip=flock-resolution)
35
36
  if [ -n "$FLIP" ] && [ "$FLIP" != "${arg#--flip=}" ]; then
36
37
  flip_err "互相冲突的 --flip($FLIP / ${arg#--flip=}):一次只跑一条臂"; exit 2
37
38
  fi
38
39
  FLIP="${arg#--flip=}" ;;
39
40
  --flip=*)
40
- flip_err "不认识的 --flip 值 [${arg#--flip=}];只接受 unlocked|version|foreign|manifest|standby-ignore|standby-file|standby-write"; exit 2 ;;
41
+ flip_err "不认识的 --flip 值 [${arg#--flip=}];只接受 unlocked|version|foreign|manifest|standby-ignore|standby-file|standby-write|flock-resolution"; exit 2 ;;
41
42
  -h|--help)
42
- printf 'usage: bash tests/state-authority.sh [--flip=unlocked|version|foreign|manifest|standby-ignore|standby-file|standby-write]\n'; exit 0 ;;
43
+ printf 'usage: bash tests/state-authority.sh [--flip=unlocked|version|foreign|manifest|standby-ignore|standby-file|standby-write|flock-resolution]\n'; exit 0 ;;
43
44
  *)
44
- flip_err "不认识的参数 [$arg](只接受 --flip=<unlocked|version|foreign|manifest>)"; exit 2 ;;
45
+ flip_err "不认识的参数 [$arg](只接受 --flip=<unlocked|version|foreign|manifest|standby-ignore|standby-file|standby-write|flock-resolution>)"; exit 2 ;;
45
46
  esac
46
47
  done
47
48
  arm_selected() { [ -z "$FLIP" ] || [ "$FLIP" = "$1" ]; }
@@ -315,6 +316,7 @@ rm -f "$orphan"
315
316
 
316
317
  # ---------------------------------------------------------------- 6. 有界锁失败 + 持锁者被杀
317
318
  LOCK="$A_STATE/reminders/authority.lock"
319
+ LOCK_FAIL_BEFORE="$(sha256sum "$A_STATE/reminders/state.json" | cut -d' ' -f1)"
318
320
  bash -c 'exec 9>"$1"; flock -x 9; sleep 30' _ "$LOCK" &
319
321
  HOLDER=$!
320
322
  sleep 0.4
@@ -331,6 +333,7 @@ if [ "$elapsed_ms" -ge 4500 ] && [ "$elapsed_ms" -le 12000 ]; then
331
333
  else
332
334
  bad "锁等待不是有界的 5s(实测 ${elapsed_ms}ms)"
333
335
  fi
336
+ assert_eq_local "真实锁竞争失败后快照一字未改" "$(sha256sum "$A_STATE/reminders/state.json" | cut -d' ' -f1)" "$LOCK_FAIL_BEFORE"
334
337
  kill -9 "$HOLDER" 2>/dev/null
335
338
  wait "$HOLDER" 2>/dev/null
336
339
  start_ns="$(date +%s%N)"
@@ -517,7 +520,7 @@ assert_eq_local "⑤f 清残留不加代次" "$(jget "$(cat "$I_SNAP")" standby.
517
520
 
518
521
  # ⑥ 代次语义:每次 on 都是新的一代,off 不动代次、重复 off 不写盘
519
522
  J="$(make_repo J)" || { bad "夹具建不出仓库 J"; result; exit 1; }
520
- J_SNAP="$J/.pi/team/state/reminders/state.json"
523
+ J_STATE="$J/.pi/team/state"; J_SNAP="$J_STATE/reminders/state.json"
521
524
  sb "$J" 'team_standby_on "first"' >/dev/null
522
525
  assert_eq_local "⑥a 第一次 on:代次 1" "$(jget "$(cat "$J_SNAP")" standby.generation)" "1"
523
526
  sb "$J" 'team_standby_on "second"' >/dev/null
@@ -572,6 +575,128 @@ else
572
575
  note "跳过 ⑦(这台机器上造不出没有 flock 的 PATH)"
573
576
  fi
574
577
 
578
+ # ---------------------------------------------------------------- 7b. 不可执行 / 实际 flock 失败(P451 · 1.3.2)
579
+ BADFLOCK="$ROOT/flip/badflock-bin"
580
+ cp -a "$NOFLOCK" "$BADFLOCK"
581
+ printf 'not executable\n' >"$BADFLOCK/flock"
582
+ chmod 0644 "$BADFLOCK/flock"
583
+ M="$(make_repo M)" || { bad "夹具建不出仓库 M"; result; exit 1; }
584
+ M_STATE="$M/.pi/team/state"; mkdir -p "$M_STATE"
585
+ printf '2026-11-12T00:00:00Z bad flock\n' >"$M_STATE/standby"
586
+ out="$(runchild "$M" TEAM_JS_BIN="$RUNNER" BADFLOCK="$BADFLOCK" -- "$PREP; PATH=\"\$BADFLOCK\" team_standby_on x 2>&1; printf ' rc=%s' \"\$?\"" 2>&1)"
587
+ if case "$out" in *"is not an executable regular file"*"rc=1"*) true ;; *) false ;; esac; then
588
+ ok "⑦g 不可执行 flock:点名实际路径与权限问题,写入非零退出"
589
+ else
590
+ bad "⑦g 不可执行 flock 没有明确失败(输出:$(printf '%s' "$out" | tr '\n' '|'))"
591
+ fi
592
+ [ ! -e "$M/.pi/team/reminder-locator.json" ] && [ ! -e "$M_STATE/reminders" ] \
593
+ && ok "⑦h 不可执行 flock 没有留下定位器或快照" || bad "⑦h 不可执行 flock 留下了半个权威"
594
+ resolution="$(env PATH="$BADFLOCK" "$RUNNER" "$NODE_HELPER" --flock-check)"
595
+ assert_eq_local "⑦i 共享解析器区分不可执行(不是 missing)" "$(printf '%s' "$resolution" | cut -f1-2)" "unusable $BADFLOCK/flock"
596
+
597
+ ENOLCK="$ROOT/flip/enolck-bin"
598
+ cp -a "$NOFLOCK" "$ENOLCK"
599
+ cat >"$ENOLCK/flock" <<'EOF'
600
+ #!/usr/bin/env bash
601
+ if [ "${1:-}" = "--version" ]; then printf 'flock from util-linux fixture\n'; exit 0; fi
602
+ printf '%s\n' "$*" >>"$FLOCK_TEST_LOG"
603
+ printf 'flock: %s: No locks available\n' "${6:-unknown}" >&2
604
+ exit 1
605
+ EOF
606
+ chmod +x "$ENOLCK/flock"
607
+ : >"$ROOT/enolck.calls"
608
+ shown="$(runchild "$J" TEAM_JS_BIN="$RUNNER" ENOLCK="$ENOLCK" -- "$PREP; PATH=\"\$ENOLCK\" team_flock_runner")"
609
+ assert_eq_local "⑦j paths 使用与事务相同的 flock 解析结果" "$shown" "$ENOLCK/flock"
610
+ J_H1="$(sha256sum "$J_SNAP" | cut -d' ' -f1)"
611
+ out="$(runchild "$J" TEAM_JS_BIN="$RUNNER" ENOLCK="$ENOLCK" FLOCK_TEST_LOG="$ROOT/enolck.calls" -- "$PREP; PATH=\"\$ENOLCK\" FLOCK_TEST_LOG=\"\$FLOCK_TEST_LOG\" team_standby_on must-not-write 2>&1; printf ' rc=%s' \"\$?\"" 2>&1)"
612
+ if case "$out" in *"exclusive flock failed at $J_STATE/reminders/authority.lock"*"No locks available"*"no state was written"*"rc=1"*) true ;; *) false ;; esac; then
613
+ ok "⑦k flock 返回 ENOLCK:错误点名真实 authority.lock、文件系统与未写状态"
614
+ else
615
+ bad "⑦k ENOLCK 没有按锁/文件系统失败报告(输出:$(printf '%s' "$out" | tr '\n' '|'))"
616
+ fi
617
+ assert_eq_local "⑦l ENOLCK 后快照一字未改" "$(sha256sum "$J_SNAP" | cut -d' ' -f1)" "$J_H1"
618
+ if grep -q -- "-x -w 5 -E 75 $J_STATE/reminders/authority.lock" "$ROOT/enolck.calls"; then
619
+ ok "⑦m 失败来自实际执行的 flock(参数与真实锁路径已记录),不是伪造成交"
620
+ else
621
+ bad "⑦m 没有执行到真实 flock 调用(日志:$(cat "$ROOT/enolck.calls"))"
622
+ fi
623
+ out="$(runchild "$J" TEAM_JS_BIN="$RUNNER" ENOLCK="$ENOLCK" FLOCK_TEST_LOG="$ROOT/enolck.calls" -- "PATH=\"\$ENOLCK\" FLOCK_TEST_LOG=\"\$FLOCK_TEST_LOG\" bash \"$SKILL/scripts/team\" --root \"$J\" doctor" 2>&1)"; rc=$?
624
+ if [ "$rc" -ne 0 ] && case "$out" in *"真实 authority.lock 加锁失败"*"No locks available"*"不会无锁降级"*) true ;; *) false ;; esac; then
625
+ ok "⑦m2 doctor 对真实 authority.lock 的锁失败给出文件系统修复方式"
626
+ else
627
+ bad "⑦m2 doctor 没诊断真实锁失败(rc=$rc,输出:$(printf '%s' "$out" | grep -A2 -B1 '状态锁 flock' | tr '\n' '|'))"
628
+ fi
629
+ assert_eq_local "⑦m3 doctor 锁探针不改快照" "$(sha256sum "$J_SNAP" | cut -d' ' -f1)" "$J_H1"
630
+ out="$(runchild "$J" -- "bash \"$SKILL/scripts/team\" --root \"$J\" doctor" 2>&1)"
631
+ if case "$out" in *"真实 authority.lock 排他锁可用"*) true ;; *) false ;; esac; then
632
+ ok "⑦m4 恢复真实 flock 后 doctor 探针转绿(同一项目、同一锁文件)"
633
+ else
634
+ bad "⑦m4 恢复后 doctor 锁探针仍不绿(输出:$(printf '%s' "$out" | grep -A2 -B1 '状态锁 flock' | tr '\n' '|'))"
635
+ fi
636
+
637
+ # ---------------------------------------------------------------- 7c. 静止迁移失败与回滚导出(P451 · 1.3.2)
638
+ R="$(make_repo R)" || { bad "夹具建不出仓库 R"; result; exit 1; }
639
+ R_STATE="$R/.pi/team/state"; R_SNAP="$R_STATE/reminders/state.json"
640
+ sb "$R" 'team_authority_init' >/dev/null
641
+ # 合法的旧快照没有 migrated 键;这里只回到那个升级前形状,随后让旧标记无法导入。
642
+ sed -i 's/"migrated":true/"migrated":false/' "$R_SNAP"
643
+ mkdir "$R_STATE/standby"
644
+ R_H1="$(sha256sum "$R_SNAP" | cut -d' ' -f1)"
645
+ out="$(sb "$R" 'team_standby_migrate' 2>&1)"; rc=$?
646
+ if [ "$rc" -ne 0 ] && case "$out" in *"legacy Standby marker is not a regular file"*) true ;; *) false ;; esac; then
647
+ ok "⑦n 静止迁移遇到坏旧标记:显式失败并点名原因"
648
+ else
649
+ bad "⑦n 坏旧标记没有让迁移失败(rc=$rc,输出:$(printf '%s' "$out" | tr '\n' '|'))"
650
+ fi
651
+ assert_eq_local "⑦o 迁移失败后快照保持原状态" "$(sha256sum "$R_SNAP" | cut -d' ' -f1)" "$R_H1"
652
+ [ -d "$R_STATE/standby" ] && [ ! -e "$R_STATE/standby.migrated" ] \
653
+ && ok "⑦p 迁移失败后旧标记未退役、未伪造迁移完成" || bad "⑦p 迁移失败后旧标记状态变了"
654
+
655
+ U="$(make_repo U)" || { bad "夹具建不出仓库 U"; result; exit 1; }
656
+ U_STATE="$U/.pi/team/state"; U_SNAP="$U_STATE/reminders/state.json"
657
+ sb "$U" 'team_standby_on "rollback export reason"' >/dev/null
658
+ EXPORT="$ROOT/rollback-export"; OLD_CODE="$ROOT/old-code-state"
659
+ mkdir -p "$EXPORT" "$OLD_CODE"
660
+ cp "$U_SNAP" "$EXPORT/state.json"
661
+ # 与 references/migration.md 相同的实际操作:从导出快照重建旧版唯一读取的待命标记。
662
+ "$RUNNER" -e '
663
+ const fs = require("fs");
664
+ const [snapshotFile, markerFile] = process.argv.slice(1);
665
+ const s = JSON.parse(fs.readFileSync(snapshotFile, "utf8"));
666
+ if (!s.standby.migrated) throw new Error("snapshot has not completed Standby migration");
667
+ if (s.standby.on) fs.writeFileSync(markerFile, `${s.standby.since} ${s.standby.reason}\n`);
668
+ ' "$EXPORT/state.json" "$OLD_CODE/standby"
669
+ expected_marker="$(jget "$(cat "$EXPORT/state.json")" standby.since) $(jget "$(cat "$EXPORT/state.json")" standby.reason)"
670
+ assert_eq_local "⑦q 回滚导出可重建旧版待命标记" "$(cat "$OLD_CODE/standby")" "$expected_marker"
671
+ mv "$OLD_CODE/standby" "$EXPORT/standby.before-restore-check"
672
+ "$RUNNER" -e '
673
+ const fs = require("fs");
674
+ const [snapshotFile, markerFile] = process.argv.slice(1);
675
+ const s = JSON.parse(fs.readFileSync(snapshotFile, "utf8"));
676
+ if (!s.standby.migrated) throw new Error("snapshot has not completed Standby migration");
677
+ if (s.standby.on) fs.writeFileSync(markerFile, `${s.standby.since} ${s.standby.reason}\n`);
678
+ ' "$EXPORT/state.json" "$OLD_CODE/standby"
679
+ if cmp -s "$EXPORT/standby.before-restore-check" "$OLD_CODE/standby"; then
680
+ ok "⑦q2 移走旧标记后可从导出快照逐字节恢复它"
681
+ else
682
+ bad "⑦q2 导出快照不能恢复旧标记"
683
+ fi
684
+ cp "$EXPORT/state.json" "$EXPORT/state.restore-check.json"
685
+ printf 'corrupt restore\n' >>"$EXPORT/state.restore-check.json"
686
+ if cmp -s "$EXPORT/state.json" "$EXPORT/state.restore-check.json"; then
687
+ bad "⑦r 反向改坏:损坏的恢复副本竟与导出原件相同"
688
+ else
689
+ ok "⑦r 反向改坏:恢复副本损坏会被逐字节比较发现"
690
+ fi
691
+ cp "$EXPORT/state.json" "$EXPORT/state.restore-check.json"
692
+ if cmp -s "$EXPORT/state.json" "$EXPORT/state.restore-check.json" \
693
+ && [ "$(jget "$(cat "$EXPORT/state.restore-check.json")" standby.reason)" = "rollback export reason" ]; then
694
+ ok "⑦s 从导出原件恢复后字节与待命原因都复原"
695
+ else
696
+ bad "⑦s 导出原件无法恢复"
697
+ fi
698
+ [ ! -e "$OLD_CODE/reminders/state.json" ] && ok "⑦t 回滚快照留在旧代码状态路径之外" || bad "⑦t 回滚快照落进了旧代码路径"
699
+
575
700
  # ---------------------------------------------------------------- 10. 红侧:同一个判据,改坏实现必须红
576
701
  flip_copy() { # <名字> <sed 表达式> —— 变异必须真的改到(否则红侧就是橡皮章)
577
702
  authority_helper_copy "$ROOT/flip/$1.mjs"
@@ -584,6 +709,25 @@ flip_helper() { # <helper> <repo> <state> <op> [args…] → 打印输出
584
709
  ( cd "$repo" && env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_PROJECT -u TEAM_SESSION HOME="$ROOT/home" \
585
710
  "$RUNNER" "$helper" --cli "$repo" "$state" "$@" 2>&1 )
586
711
  }
712
+ # 10a0. flock 解析退化成「文件存在就算可用」:不可执行诊断必须翻错(P451)
713
+ if arm_selected flock-resolution; then
714
+ FLIPS_RUN="${FLIPS_RUN:+$FLIPS_RUN,}flock-resolution"
715
+ if flip_copy flock-resolution '/fs\.accessSync(file, fs\.constants\.X_OK);/d'; then
716
+ ok "flip 变异已落地:flock 解析不再检查执行权限"
717
+ else
718
+ bad "flip 变异没落地(共享 flock 解析器形状变了)"
719
+ fi
720
+ orig_res="$(env PATH="$BADFLOCK" "$RUNNER" "$NODE_HELPER" --flock-check)"
721
+ mut_res="$(env PATH="$BADFLOCK" "$RUNNER" "$ROOT/flip/flock-resolution.mjs" --flock-check)"
722
+ if [ "$(printf '%s' "$orig_res" | cut -f1)" = "unusable" ] && [ "$(printf '%s' "$mut_res" | cut -f1)" = "ok" ]; then
723
+ ok "flip(不查执行权限):原实现报 unusable,变异体报 ok —— ⑦i 与 paths/doctor 判据会红"
724
+ else
725
+ bad "flip(不查执行权限)没被咬住(原 [$orig_res],变异 [$mut_res])"
726
+ fi
727
+ else
728
+ note "跳过红侧臂 flock-resolution(本次 --flip=${FLIP})"
729
+ fi
730
+
587
731
  # 10a. 不持锁的直写:只把生产代码里那条 flock 调用换成直接事务(一行之差,不放大任何窗口)
588
732
  if arm_selected unlocked; then
589
733
  FLIPS_RUN="${FLIPS_RUN:+$FLIPS_RUN,}unlocked"
@@ -15,7 +15,7 @@ while [ $# -gt 0 ]; do
15
15
  case "$1" in --select) SELECT="${2:?}"; shift 2 ;; --flip) SELECT=flip; shift ;; *) printf 'unknown option: %s\n' "$1"; exit 2 ;; esac
16
16
  done
17
17
  for group in ${SELECT//,/ }; do
18
- case "$group" in policy|machine|config|upgrade|dispatch|resume|transaction|limits|preview|sid-readers|pm|boundary|init|heal|adopt|updatecheck|flip) ;; *) printf 'unknown group: %s\n' "$group"; exit 2 ;; esac
18
+ case "$group" in policy|machine|config|upgrade|dispatch|resume|transaction|limits|preview|sid-readers|pm|boundary|init|heal|adopt|updatecheck|parameters|argv-worker|argv-pm|flip) ;; *) printf 'unknown group: %s\n' "$group"; exit 2 ;; esac
19
19
  done
20
20
  while IFS='=' read -r k _; do case "$k" in TEAM_*) unset "$k" 2>/dev/null || true ;; esac; done < <(env)
21
21
  TMP="$(tmp_root_create task-model-routing)" || exit 3
@@ -46,7 +46,25 @@ contains() { [[ "$1" == *"$2"* ]]; }
46
46
  sha() { if [ -f "$1" ]; then sha256sum "$1" | cut -d' ' -f1; else printf absent; fi; }
47
47
  CLI="$TREE/skills/teamsmith/scripts/team"
48
48
  SKILL="$TREE/skills/teamsmith"
49
- REPO="$TMP/repo"; mkdir -p "$REPO/.pi/team" "$REPO/docs/team/tasks" "$REPO/docs/team/threads"
49
+ REPO="$TMP/repo"; STATE="$REPO/.pi/team/state"; CONFIG="$REPO/.pi/team/config.sh"
50
+ if has parameters; then
51
+ [ "$SELECT" = parameters ] || { printf 'parameters cannot combine with full groups: %s\n' "$SELECT"; exit 2; }
52
+ source "$SKILL/scripts/lib/common.sh" || exit 3
53
+ routing_parameter_probes
54
+ printf '\nRESULT pass=%s fail=%s selected=%s\n' "$PASS" "$FAIL" "$SELECT"
55
+ [ "$FAIL" = 0 ]; exit $?
56
+ fi
57
+ if has argv-worker || has argv-pm; then
58
+ for group in ${SELECT//,/ }; do
59
+ case "$group" in argv-worker|argv-pm) ;; *) printf 'argv samples cannot combine with full groups: %s\n' "$group"; exit 2 ;; esac
60
+ done
61
+ routing_argv_setup || { printf 'ERROR argv-setup failed\n'; exit 3; }
62
+ if has argv-worker; then routing_worker_argv_probe; fi
63
+ if has argv-pm; then routing_pm_argv_probes; fi
64
+ printf '\nRESULT pass=%s fail=%s selected=%s\n' "$PASS" "$FAIL" "$SELECT"
65
+ [ "$FAIL" = 0 ]; exit $?
66
+ fi
67
+ mkdir -p "$REPO/.pi/team" "$REPO/docs/team/tasks" "$REPO/docs/team/threads"
50
68
  git -C "$REPO" init -q -b main
51
69
  git -C "$REPO" config user.name fixture; git -C "$REPO" config user.email fixture@example.invalid
52
70
  printf '# fixture\n' > "$REPO/README.md"; git -C "$REPO" add README.md; git -C "$REPO" commit -qm fixture
@@ -440,6 +458,7 @@ run_hook() { RC=0; effect_snapshot "before hook $*"; OUT="$(hooked "$@" 2>&1)" |
440
458
  stop_fixture_seat() { (cd "$REPO" && tmux kill-window -t "routing-fixture:$1") 2>/dev/null || true; }
441
459
  assignment_snapshot() { printf '%s:%s:%s' "$(sha "$STATE/dev.env")" "$(sha "$STATE/dev.pending")" "$(sha "$REPO/docs/team/BOARD.md")"; }
442
460
  if has boundary; then
461
+ routing_parameter_probes
443
462
  routing_template_probes
444
463
  routing_pm_template_probes
445
464
  routing_expansion_probes worker
@@ -447,6 +466,7 @@ if has boundary; then
447
466
  routing_role_probes worker
448
467
  routing_role_probes pm
449
468
  routing_resume_role_probes
469
+ routing_renderer_refusal_probes
450
470
  fi
451
471
  if has limits || has transaction; then
452
472
  run config set TEAM_TASK_MODELS 'routine=vendor/routine analysis=vendor/analysis verify=vendor/verify' --yes
@@ -1392,12 +1412,10 @@ fi
1392
1412
 
1393
1413
  if has flip; then
1394
1414
  CORE='policy,machine,init,config,upgrade,dispatch,resume,transaction,limits,preview,sid-readers,pm,heal,adopt,updatecheck,boundary'
1395
- # P358:臂预算。`flip_run` 只能给**所有臂一个值**(每条臂跑哪些组由变异体决定,耗时差一个量级),
1396
- # 所以这个值是**最慢那条臂**的上限,不是典型值:`template-shadow` 把 identity guard 整个拆掉之后,
1397
- # boundary 组 29 类故障模板 × 4 种模式全部走到真派单 —— 变异树实测 842s(2026-10-21,P358;同一条
1398
- # 命令的绿基线 411s)。原来的 900s 只剩 6% 余量,机器一忙就必然撞上(发布那轮 fail=2 → fail=1 的
1399
- # 漂移就是这里来的)。取实测 × 2 = 1800s,与整段 7200s 同一个口径:**它只回答「它没动」,不回答
1400
- # 「它慢」**。整段的上限归 §61b 那条段(smoke.sh 的 7200s),不因这里而变。
1415
+ # P358's shared arm budget stays unchanged. Its historical 842s template-shadow
1416
+ # reading preceded P468's parameters selection; it is not a reading of this
1417
+ # replacement. The timeout distinguishes an unfinished child from intended red,
1418
+ # never judges performance; the section-level 7200s budget is unchanged too.
1401
1419
  FLIP_ARM_BUDGET=1800
1402
1420
  # 撞上限只是 rc=124(1 是「它自己判红」)。超时必须是一条**点名**的红:只留 rc=124 就把「哪条臂、
1403
1421
  # 用满多少秒」留给下一个人去猜,那正是同一类问题的下一次复发(P358)。
@@ -1406,7 +1424,8 @@ if has flip; then
1406
1424
  printf 'FAIL flip-%s-arm-budget 臂 %s 用满臂预算 %ss(实跑 %ss)仍未出结果 —— 这是「它没跑完」,不是「它红了」\n' \
1407
1425
  "$1" "$1" "$FLIP_ARM_BUDGET" "$2"
1408
1426
  }
1409
- # One green baseline and one green restoration of the whole slice; each red arm has its own copy.
1427
+ # One full normal baseline; each red arm has its own copy. The two resplit
1428
+ # and five parameter arms observe healthy/restored on that same copy.
1410
1429
  flip_run() {
1411
1430
  local tag="$1" tree="$2" groups="$3" rc=0 started ended
1412
1431
  started="$(date +%s)"
@@ -1432,7 +1451,9 @@ if has flip; then
1432
1451
  latest-shell|latest-monitor) groups=sid-readers ;;
1433
1452
  pm-fallback) groups=pm ;;
1434
1453
  pm-publication) groups=dispatch,pm ;;
1435
- extra-shadow|template-shadow|template-unbound|template-roles|literal-shell-expansion|pm-literal-resplit|worker-literal-resplit) groups=boundary ;;
1454
+ extra-shadow|template-shadow|template-unbound|template-roles|literal-shell-expansion) groups=parameters ;;
1455
+ pm-literal-resplit) groups=argv-pm ;;
1456
+ worker-literal-resplit) groups=argv-worker ;;
1436
1457
  monitor-record-drift) groups=sid-readers ;;
1437
1458
  init-legacy-proceeds|template-retired-key) groups=init ;;
1438
1459
  migration-row-removed|no-backup|no-shape-number) groups=heal ;;
@@ -1448,6 +1469,10 @@ if has flip; then
1448
1469
  [ ! -d "$SKILL/$source_dir" ] || cp -a "$SKILL/$source_dir" "$scratch/skills/teamsmith/"
1449
1470
  done
1450
1471
  before="$(find "$scratch/skills/teamsmith/scripts" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1)"
1472
+ case "$mutation" in pm-literal-resplit|worker-literal-resplit|extra-shadow|template-shadow|template-unbound|template-roles|literal-shell-expansion)
1473
+ flip_run "$mutation-healthy" "$scratch" "$groups"
1474
+ check "flip-$mutation-healthy" eq "$FLIP_RC" 0 ;;
1475
+ esac
1451
1476
  python3 "$here/lib/model-routing-flips.py" "$scratch" "$mutation" > "$TMP/mutation-$mutation.json"
1452
1477
  check "flip-$mutation-target-matched" eq "$?" 0
1453
1478
  check "flip-$mutation-shape-valid" bash -c 'for file in "$1"/scripts/lib/*.sh; do bash -n "$file" || exit; done; node --check "$1/scripts/monitor.mjs"' _ "$scratch/skills/teamsmith"
@@ -1465,23 +1490,23 @@ if has flip; then
1465
1490
  check flip-identity-overclaim-argv grep -q '^FAIL publication-record-equals-argv:model-only$' "$TMP/flip-$mutation.log"
1466
1491
  check flip-identity-overclaim-opaque grep -q '^FAIL publication-record:opaque$' "$TMP/flip-$mutation.log"
1467
1492
  check flip-identity-overclaim-claim grep -q '^FAIL publication-claim-gap:model-only$' "$TMP/flip-$mutation.log" ;;
1468
- template-shadow) check flip-template-shadow-specific-worker grep -q '^FAIL template-refused:all-hardcoded:preview$' "$TMP/flip-$mutation.log"
1469
- check flip-template-shadow-specific-pm grep -q '^FAIL pm-template-refused:provider:launch$' "$TMP/flip-$mutation.log" ;;
1493
+ extra-shadow) check flip-extra-shadow-specific-model grep -q '^FAIL parameter-extra-refused:model$' "$TMP/flip-$mutation.log" ;;
1494
+ template-shadow) check flip-template-shadow-specific-worker grep -q '^FAIL parameter-template-refused:worker:all-hardcoded:continued$' "$TMP/flip-$mutation.log"
1495
+ check flip-template-shadow-specific-pm grep -q '^FAIL parameter-template-refused:pm:provider:fresh$' "$TMP/flip-$mutation.log" ;;
1470
1496
  template-unbound)
1471
- check flip-unbound-worker-positional grep -q '^FAIL template-refused:positional-model:launch$' "$TMP/flip-$mutation.log"
1472
- check flip-unbound-worker-data grep -q '^FAIL template-refused:data-sid:preview$' "$TMP/flip-$mutation.log"
1473
- check flip-unbound-pm-positional grep -q '^FAIL pm-custom-missing-refused:positional-model:launch$' "$TMP/flip-$mutation.log"
1474
- check flip-unbound-pm-data grep -q '^FAIL pm-template-refused:data-provider:preview$' "$TMP/flip-$mutation.log" ;;
1497
+ check flip-unbound-worker-positional grep -q '^FAIL parameter-template-refused:worker:positional-model:continued$' "$TMP/flip-$mutation.log"
1498
+ check flip-unbound-worker-data grep -q '^FAIL parameter-template-refused:worker:data-sid:continued$' "$TMP/flip-$mutation.log"
1499
+ check flip-unbound-pm-positional grep -q '^FAIL parameter-template-refused:pm:positional-model:continued$' "$TMP/flip-$mutation.log"
1500
+ check flip-unbound-pm-data grep -q '^FAIL parameter-template-refused:pm:data-provider:fresh$' "$TMP/flip-$mutation.log" ;;
1475
1501
  template-roles)
1476
- check flip-role-worker-selector-as-data grep -q '^FAIL worker-role-refused:model:--skill:launch$' "$TMP/flip-$mutation.log"
1477
- check flip-role-pm-selector-as-data grep -q '^FAIL pm-role-refused:provider:--skill:launch$' "$TMP/flip-$mutation.log"
1478
- check flip-role-pm-resume-data grep -q '^FAIL pm-role-resume-refused:builtin:--skill --continue:launch$' "$TMP/flip-$mutation.log" ;;
1502
+ check flip-role-worker-selector-as-data grep -q '^FAIL parameter-role-refused:worker:model:--skill$' "$TMP/flip-$mutation.log"
1503
+ check flip-role-pm-selector-as-data grep -q '^FAIL parameter-role-refused:pm:provider:--skill$' "$TMP/flip-$mutation.log"
1504
+ check flip-role-pm-resume-data grep -q '^FAIL parameter-resume-role-refused:--skill --continue$' "$TMP/flip-$mutation.log" ;;
1479
1505
  monitor-record-drift) check flip-monitor-record-drift-specific-nonce grep -q '^FAIL reader-monitor-unavailable:nonce$' "$TMP/flip-$mutation.log" ;;
1480
1506
  literal-shell-expansion)
1481
- check flip-literal-shell-specific-worker-template grep -q '^FAIL worker-expansion-refused:template:model-glob:launch$' "$TMP/flip-$mutation.log"
1482
- check flip-literal-shell-specific-worker-extra grep -q '^FAIL worker-expansion-refused:extra:model-glob:launch$' "$TMP/flip-$mutation.log"
1483
- check flip-literal-shell-specific-pm-template grep -q '^FAIL pm-expansion-refused:template:model-glob:launch$' "$TMP/flip-$mutation.log"
1484
- check flip-literal-shell-specific-pm-extra grep -q '^FAIL pm-expansion-refused:extra:model-glob:launch$' "$TMP/flip-$mutation.log" ;;
1507
+ check flip-literal-shell-specific-worker-template grep -q '^FAIL parameter-expansion-refused:worker-template:model-glob$' "$TMP/flip-$mutation.log"
1508
+ check flip-literal-shell-specific-pm-template grep -q '^FAIL parameter-expansion-refused:pm-template:model-glob$' "$TMP/flip-$mutation.log"
1509
+ check flip-literal-shell-specific-shared-extra grep -q '^FAIL parameter-expansion-refused:shared-extra:model-glob$' "$TMP/flip-$mutation.log" ;;
1485
1510
  pm-literal-resplit)
1486
1511
  check flip-pm-resplit-specific-extra grep -q '^FAIL pm-expansion-literal-argv:extra$' "$TMP/flip-$mutation.log"
1487
1512
  check flip-pm-resplit-specific-resume grep -q '^FAIL pm-resume-literal-argv:builtin$' "$TMP/flip-$mutation.log" ;;
@@ -1525,13 +1550,19 @@ if has flip; then
1525
1550
  check flip-legacy-route-write-path grep -q '^FAIL init-legacy-config-set-derived$' "$TMP/flip-$mutation.log"
1526
1551
  check flip-legacy-route-paste grep -q '^FAIL init-paste-derived-exact$' "$TMP/flip-$mutation.log" ;;
1527
1552
  esac
1528
- cp -a "$SKILL/scripts/." "$scratch/skills/teamsmith/scripts/"
1553
+ case "$mutation" in
1554
+ extra-shadow|template-shadow|template-unbound|template-roles|literal-shell-expansion)
1555
+ cp -p "$SKILL/scripts/lib/common.sh" "$scratch/skills/teamsmith/scripts/lib/common.sh" ;;
1556
+ *) cp -a "$SKILL/scripts/." "$scratch/skills/teamsmith/scripts/" ;;
1557
+ esac
1529
1558
  restored="$(find "$scratch/skills/teamsmith/scripts" -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d' ' -f1)"
1530
1559
  check "flip-$mutation-source-restored" eq "$restored" "$before"
1531
1560
  printf 'CONTROL %s source_before=%s source_restored=%s\n' "$mutation" "$before" "$restored"
1561
+ case "$mutation" in pm-literal-resplit|worker-literal-resplit|extra-shadow|template-shadow|template-unbound|template-roles|literal-shell-expansion)
1562
+ flip_run "$mutation-restored" "$scratch" "$groups"
1563
+ check "flip-$mutation-restored" eq "$FLIP_RC" 0 ;;
1564
+ esac
1532
1565
  done
1533
- flip_run restored "$TREE" "$CORE"
1534
- check flip-restored-all-green eq "$FLIP_RC" 0
1535
1566
  fi
1536
1567
  fi
1537
1568
  printf '\nRESULT pass=%s fail=%s selected=%s\n' "$PASS" "$FAIL" "$SELECT"
@@ -164,7 +164,7 @@ _proc_start() { # <pid> → /proc/<pid>/stat 的 starttime
164
164
  # shellcheck disable=SC2086
165
165
  set -- $stat
166
166
  [ -n "${20:-}" ] || return 1
167
- printf '%s\n' "$20"
167
+ printf '%s\n' "${20}"
168
168
  }
169
169
  _proc_alive() { # <pid> [start]
170
170
  local pid="${1:-}" want="${2:-}" st state
@@ -3,13 +3,12 @@ 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.4.6"
6
+ version: "0.4.8"
7
7
  ---
8
8
 
9
9
  # teamsmith-init · bring a new project to "ready to dispatch"
10
10
 
11
- You are the first session in a repository that has no team yet. **Install first**, then settle the questions below
12
- with the user, run one command, then hand day-to-day operation to the **`teamsmith`** skill.
11
+ You are the first session in a repository that has no team yet. **Install first**, then settle the questions below with the user, run one command, then hand day-to-day operation to the **`teamsmith`** skill.
13
12
  ## 0. Install the CLI and the project's skills
14
13
 
15
14
  ```bash
@@ -82,8 +81,9 @@ Alternatives to npm: `pi install …` at a released tag, `./install.sh` from a c
82
81
 
83
82
  ## 2. Handoff
84
83
 
85
- Day-to-day operation lives in the **`teamsmith`** skill: the PM loop, dispatch, independent verification, merging,
86
- the pulse, updates and troubleshooting are all there — read `skills/teamsmith/SKILL.md` and follow it. The three
84
+ Day-to-day operation lives in the **`teamsmith`** skill: the PM dispatches and accepts evidence while non-implementer
85
+ workers execute independent verification and archive; merging, the pulse, updates and troubleshooting are all there —
86
+ read `skills/teamsmith/SKILL.md` and follow it. The three
87
87
  commands that answer "what now?": `team digest` (pending work), `team pulse status` (patrol and PM liveness),
88
88
  `team doctor` (environment). The handover is three steps, and the middle one is the one people skip:
89
89
  1. **Bootstrap** — already done in step 6 above (a rerun is idempotent; `--print` shows the plan).