teamsmith 0.4.7 → 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 (42) hide show
  1. package/README.md +4 -4
  2. package/package.json +1 -1
  3. package/skills/teamsmith/CHANGELOG.md +11 -0
  4. package/skills/teamsmith/SKILL.md +12 -8
  5. package/skills/teamsmith/references/config.md +11 -12
  6. package/skills/teamsmith/scripts/lib/cmd-review.sh +21 -33
  7. package/skills/teamsmith/scripts/lib/common.sh +1 -1
  8. package/skills/teamsmith/scripts/panel/README.md +35 -33
  9. package/skills/teamsmith/scripts/panel/panel.js +217 -199
  10. package/skills/teamsmith/scripts/panel/src/App.tsx +221 -66
  11. package/skills/teamsmith/scripts/panel/src/layout.ts +139 -302
  12. package/skills/teamsmith/scripts/panel/src/project-settings.ts +46 -0
  13. package/skills/teamsmith/scripts/panel/src/strings/en.ts +71 -205
  14. package/skills/teamsmith/scripts/panel/src/strings/index.ts +3 -5
  15. package/skills/teamsmith/scripts/panel/src/strings/zh.ts +72 -204
  16. package/skills/teamsmith/scripts/panel/src/types.ts +23 -4
  17. package/skills/teamsmith/scripts/strings/commands.tsv +1 -1
  18. package/skills/teamsmith/templates/AGENTS.section.md.tmpl +7 -0
  19. package/skills/teamsmith/templates/pm-prompt.md.tmpl +10 -6
  20. package/skills/teamsmith/tests/help-surface.sh +75 -7
  21. package/skills/teamsmith/tests/install-shape.sh +7 -7
  22. package/skills/teamsmith/tests/key-replies-ui.sh +11 -5
  23. package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +2 -0
  24. package/skills/teamsmith/tests/lib/model-routing-boundary.sh +255 -90
  25. package/skills/teamsmith/tests/lib/model-routing-expansion.sh +181 -61
  26. package/skills/teamsmith/tests/lib/model-routing-roles.sh +125 -67
  27. package/skills/teamsmith/tests/lib/reply-fixture.sh +14 -9
  28. package/skills/teamsmith/tests/lib/tmp-root.sh +1 -1
  29. package/skills/teamsmith/tests/loop-inventory.tsv +2 -0
  30. package/skills/teamsmith/tests/panel-b2.sh +91 -31
  31. package/skills/teamsmith/tests/panel-p21.sh +607 -1162
  32. package/skills/teamsmith/tests/panel-strings.mjs +21 -113
  33. package/skills/teamsmith/tests/remind-adversarial-faults.mjs +65 -38
  34. package/skills/teamsmith/tests/remind-adversarial-faults.sh +64 -12
  35. package/skills/teamsmith/tests/remind-adversarial-real.sh +13 -12
  36. package/skills/teamsmith/tests/remind-tool-real.mjs +159 -112
  37. package/skills/teamsmith/tests/remind-tool-real.sh +178 -3
  38. package/skills/teamsmith/tests/section-paths.tsv +10 -10
  39. package/skills/teamsmith/tests/smoke.sh +108 -114
  40. package/skills/teamsmith/tests/task-model-routing.sh +57 -26
  41. package/skills/teamsmith/tests/tmp-hygiene.sh +1 -1
  42. package/skills/teamsmith-init/SKILL.md +1 -1
@@ -644,11 +644,12 @@ scenario_clipboard() {
644
644
  cond_skip "B4 模型夹具" "本机没有 bun"
645
645
  fi
646
646
 
647
- # The fake tools: each call is logged; the mode comes from the panel's environment.
647
+ # The fake tools log every real call and read this fixture's current mode input each time.
648
648
  cat > "$fx/fakebin/wl-paste" <<'EOWS'
649
649
  #!/usr/bin/env bash
650
650
  printf 'wl-paste %s\n' "$*" >> "$P20_CLIP_LOG"
651
- case "${P20_WL_MODE:-image}" in
651
+ IFS= read -r mode < "$P20_WL_MODE_FILE" || exit 1
652
+ case "$mode" in
652
653
  image)
653
654
  case "$1" in
654
655
  --list-types) printf 'text/plain;charset=utf-8\nimage/png\n' ;;
@@ -668,29 +669,69 @@ EOWS
668
669
  cat > "$fx/fakebin/xclip" <<'EOXC'
669
670
  #!/usr/bin/env bash
670
671
  printf 'xclip %s\n' "$*" >> "$P20_CLIP_LOG"
671
- case "${P20_X_MODE:-image}" in
672
+ IFS= read -r mode < "$P20_X_MODE_FILE" || exit 1
673
+ case "$mode" in
672
674
  image) case "$*" in *TARGETS*) printf 'image/png\n' ;; *) printf 'XCLIPDATA' ;; esac ;;
673
675
  *) exit 1 ;;
674
676
  esac
675
677
  EOXC
676
678
  chmod +x "$fx/fakebin/wl-paste" "$fx/fakebin/xclip"
677
679
 
678
- clip_env() { # <wl mode> <x mode> [extra]
679
- printf 'PATH=%s:%s TMPDIR=%s P20_CLIP_LOG=%s P20_WL_MODE=%s P20_X_MODE=%s %s' \
680
- "$fx/fakebin" "$PATH" "$fx/tmpdir" "$fx/calls.log" "$1" "$2" "${3:-}"
680
+ clip_modes() { # <wl mode> <x mode>; change only after the preceding probe and edits finish
681
+ printf '%s\n' "$1" > "$fx/wl-mode"
682
+ printf '%s\n' "$2" > "$fx/x-mode"
683
+ }
684
+ clip_env() { # the same input paths for every retained panel start
685
+ printf 'PATH=%s:%s TMPDIR=%s P20_CLIP_LOG=%s P20_WL_MODE_FILE=%s P20_X_MODE_FILE=%s' \
686
+ "$fx/fakebin" "$PATH" "$fx/tmpdir" "$fx/calls.log" "$fx/wl-mode" "$fx/x-mode"
681
687
  }
682
688
  pasted_file() { ls "$fx/tmpdir"/teamsmith-paste-* 2>/dev/null | head -1; }
683
689
  paste_count() { ls "$fx/tmpdir" 2>/dev/null | grep -c 'teamsmith-paste-' || true; }
684
690
  reset_clip() { rm -f "$fx/tmpdir"/teamsmith-paste-*; : > "$fx/calls.log"; }
685
691
 
692
+ # 理由行里要有**整条**路径 —— 但路径比一行宽时产品会折行画出(P309 起临时根就比 120 列面板宽:夹具这条
693
+ # 156 列 > 可用的 116 列),逐行 grep 整条路径会把一条真的存在的事实判红。所以先把**理由框自己那几行**
694
+ # (标题行之后连续的 `│ ` 行,止于第一行别的东西)按画出的顺序拼回一行,再在这段文字里找整条路径:框外
695
+ # 的行不进这段文字,别处的路径顶替不了;路径为空时这条直接红,不会退化成 `grep -F ''` 的通真。
696
+ reason_text() { # <capture> → 待命原因框里被画的完整文本(拼成一行)
697
+ awk '/待命原因/{inbox=1; next}
698
+ inbox && /^│ /{sub(/^│ /,""); sub(/^> /,""); sub(/^ +/,""); out=out $0; next}
699
+ inbox{exit}
700
+ END{printf "%s", out}' "$1"
701
+ }
702
+ # 只在本次等待的子 shell 里绑定回调;原可见帧不变,ready 必须来自实际图片及相应正文。
703
+ # 引擎的 rc 直接回父调用方计失败,不指望子 shell 的 PTY_WAIT_FAILED 传回。
704
+ wait_clip_image() ( # <label> <PNG bytes> <draft|reason>
705
+ local label="$1" expected="$2" kind="$3"
706
+ pty_cap() {
707
+ local frame file ready=0
708
+ frame="$(cap_visible)"
709
+ printf '%s\n' "$frame"
710
+ file="$(pasted_file)"
711
+ if [ -n "$file" ] && [ -f "$file" ] && [ "$(cat "$file")" = "$expected" ]; then
712
+ case "$kind" in
713
+ draft) [ "$(draft)" = "a${file}d" ] && ready=1 ;;
714
+ reason)
715
+ [ "$(draft)" = 'half a thought' ] \
716
+ && [ "$(reason_text <(printf '%s\n' "$frame"))" = "why${file}" ] && ready=1 ;;
717
+ esac
718
+ fi
719
+ [ "$ready" -eq 1 ] && printf '@@clipboard %s %s ready @@\n' "$expected" "$kind"
720
+ return 0
721
+ }
722
+ pty_wait_frame - "$label" "@@clipboard $expected $kind ready @@"
723
+ )
724
+
686
725
  # ① 图片 → 临时文件路径,插在插入点;Wayland 优先且 xclip 不被调用
687
726
  printf 'ad' > "$(draft_file)"
688
727
  reset_clip
689
728
  start_pm '' ''
690
- start_panel "$(clip_env image image)"
729
+ clip_modes image image
730
+ start_panel "$(clip_env)"
691
731
  keys m; wait_frame "B4 写信托盘" 'Enter 发送'
692
732
  keys Left
693
- keys C-v; wait_frame "B4 图片落成临时文件路径" 'teamsmith-paste-'
733
+ keys C-v
734
+ wait_clip_image "B4 图片落成临时文件路径" PNGDATA8 draft || bad "B4 图片落成临时文件路径:未等到 PNGDATA8 和 a<path>d"
694
735
  cap_to image
695
736
  local file
696
737
  file="$(pasted_file)"
@@ -707,12 +748,19 @@ EOXC
707
748
 
708
749
  # ② Wayland 失败 → X11:仍成图,调用日志里 wl-paste 在 xclip 之前
709
750
  keys Escape; wait_frame "B4 写信收起" '!Enter 发送'
710
- printf 'ad' > "$(draft_file)"
711
751
  reset_clip
712
- start_panel "$(clip_env fail image)"
752
+ clip_modes fail image
713
753
  keys m; wait_frame "B4 写信托盘" 'Enter 发送'
754
+ keys C-e; keys C-u
755
+ type_text 'ad'
756
+ wait_draft "B4 X11 准备:完整草稿 ad" 'ad'
757
+ if [ "$PTY_WAIT_FAILED" -ne 0 ]; then
758
+ bad "B4 X11 准备:未等到完整草稿 ad"
759
+ return 1
760
+ fi
714
761
  keys Left
715
- keys C-v; wait_frame "B4 Wayland 失败后 X11 回退成图" 'teamsmith-paste-'
762
+ keys C-v
763
+ wait_clip_image "B4 Wayland 失败后 X11 回退成图" XCLIPDATA draft || bad "B4 Wayland 失败后 X11 回退成图:未等到 XCLIPDATA 和 a<path>d"
716
764
  cap_to x11
717
765
  file="$(pasted_file)"
718
766
  assert_eq "B4 X11 回退:文件内容 XCLIPDATA" "$(cat "$file" 2>/dev/null)" "XCLIPDATA"
@@ -728,10 +776,16 @@ EOXC
728
776
 
729
777
  # ③ 无图片 → 文本回退,且不调用 xclip
730
778
  keys Escape; wait_frame "B4 写信收起" '!Enter 发送'
731
- printf 'ad' > "$(draft_file)"
732
779
  reset_clip
733
- start_panel "$(clip_env text image)"
780
+ clip_modes text image
734
781
  keys m; wait_frame "B4 写信托盘" 'Enter 发送'
782
+ keys C-e; keys C-u
783
+ type_text 'ad'
784
+ wait_draft "B4 文本回退准备:完整草稿 ad" 'ad'
785
+ if [ "$PTY_WAIT_FAILED" -ne 0 ]; then
786
+ bad "B4 文本回退准备:未等到完整草稿 ad"
787
+ return 1
788
+ fi
735
789
  keys Left
736
790
  keys C-v; wait_frame "B4 文本回退进草稿" '> afrom the clipboardd'
737
791
  cap_to text-fallback
@@ -741,10 +795,16 @@ EOXC
741
795
 
742
796
  # ④ 两个工具都不给东西:什么都不变;挂死的工具在界内被放弃
743
797
  keys Escape; wait_frame "B4 写信收起" '!Enter 发送'
744
- printf 'half a thought' > "$(draft_file)"
745
798
  reset_clip
746
- start_panel "$(clip_env fail fail)"
799
+ clip_modes fail fail
747
800
  keys m; wait_frame "B4 写信托盘" 'Enter 发送'
801
+ keys C-e; keys C-u
802
+ type_text 'half a thought'
803
+ wait_draft "B4 无工具准备:完整草稿 half a thought" 'half a thought'
804
+ if [ "$PTY_WAIT_FAILED" -ne 0 ]; then
805
+ bad "B4 无工具准备:未等到完整草稿 half a thought"
806
+ return 1
807
+ fi
748
808
  keys C-v; wait_draft "B4 无工具:探测什么都不改" 'half a thought'
749
809
  cap_to no-tool
750
810
  assert_eq "B4 无工具:草稿不变" "$(draft)" "half a thought"
@@ -754,10 +814,16 @@ EOXC
754
814
  assert_eq "B4 无工具后仍能打字" "$(draft)" "half a thoughtZ"
755
815
 
756
816
  keys Escape; wait_frame "B4 写信收起" '!Enter 发送'
757
- printf 'half a thought' > "$(draft_file)"
758
817
  reset_clip
759
- start_panel "$(clip_env hang fail)"
818
+ clip_modes hang fail
760
819
  keys m; wait_frame "B4 写信托盘" 'Enter 发送'
820
+ keys C-e; keys C-u
821
+ type_text 'half a thought'
822
+ wait_draft "B4 挂死工具准备:完整草稿 half a thought" 'half a thought'
823
+ if [ "$PTY_WAIT_FAILED" -ne 0 ]; then
824
+ bad "B4 挂死工具准备:未等到完整草稿 half a thought"
825
+ return 1
826
+ fi
761
827
  # 保留(P336):挂死的工具下探测的结果是「什么都不发生」——没有回执行、没有文件、没有忙行,
762
828
  # 它的“结束”无处可观测;而这条要证明的正是「工具企着的时候面板照旧可输入」,所以 Z 必须落在
763
829
  # 工具还在挂的时候,这段空闲窗口不是等一个状态。
@@ -773,22 +839,14 @@ EOXC
773
839
  # ⑤ 理由模式:路径进理由行,消息草稿不动
774
840
  printf 'half a thought' > "$(draft_file)"
775
841
  reset_clip
776
- start_panel "$(clip_env image image)"
842
+ clip_modes image image
843
+ start_panel "$(clip_env)"
777
844
  keys s; wait_frame "B4 待命理由输入行" 'Enter 进入待命'
778
845
  type_text 'why'
779
- keys C-v; wait_frame "B4 理由行里出现图片路径" 'teamsmith-paste-'
846
+ keys C-v
847
+ wait_clip_image "B4 理由行里出现图片路径" PNGDATA8 reason || bad "B4 理由行里出现图片路径:未等到 why<path> 和原消息草稿"
780
848
  cap_to reason
781
849
  file="$(pasted_file)"
782
- # 理由行里要有**整条**路径 —— 但路径比一行宽时产品会折行画出(P309 起临时根就比 120 列面板宽:夹具这条
783
- # 156 列 > 可用的 116 列),逐行 grep 整条路径会把一条真的存在的事实判红。所以先把**理由框自己那几行**
784
- # (标题行之后连续的 `│ ` 行,止于第一行别的东西)按画出的顺序拼回一行,再在这段文字里找整条路径:框外
785
- # 的行不进这段文字,别处的路径顶替不了;路径为空时这条直接红,不会退化成 `grep -F ''` 的通真。
786
- reason_text() { # <capture> → 待命原因框里被画的完整文本(拼成一行)
787
- awk '/待命原因/{inbox=1; next}
788
- inbox && /^│ /{sub(/^│ /,""); sub(/^> /,""); sub(/^ +/,""); out=out $0; next}
789
- inbox{exit}
790
- END{printf "%s", out}' "$1"
791
- }
792
850
  if [ -z "$file" ]; then
793
851
  bad "B4 理由行里有图片路径(理由模式没有文件落地:路径为空)"
794
852
  else
@@ -809,9 +867,10 @@ EOS
809
867
  printf 'ad' > "$(draft_file)"
810
868
  reset_clip
811
869
  : > "$fx/team.log"
870
+ clip_modes image image
812
871
  tmux -L "$sock" kill-window -t "$sess:panel" 2>/dev/null || true
813
872
  tmux -L "$sock" new-window -d -t "$sess" -n panel -c "$ROOT" \
814
- "TEAM_JS_BIN=$(printf '%q' "$js") $(clip_env image image) exec '$js' '$panel' --root '$ROOT' --team-cli '$fx/teamwrap.sh' --state-dir '$ROOT/.pi/team/state' --no-pulse --interval 1"
873
+ "TEAM_JS_BIN=$(printf '%q' "$js") $(clip_env) exec '$js' '$panel' --root '$ROOT' --team-cli '$fx/teamwrap.sh' --state-dir '$ROOT/.pi/team/state' --no-pulse --interval 1"
815
874
  wait_panel
816
875
  keys m; wait_frame "B4 写信托盘" 'Enter 发送'
817
876
  keys Left
@@ -827,7 +886,8 @@ EOS
827
886
  # 「窗口过去了」自己);两段 5s 就是被测的长度。
828
887
  reset_clip
829
888
  : > "$fx/calls.log"
830
- start_panel "$(clip_env image image)"
889
+ clip_modes image image
890
+ start_panel "$(clip_env)"
831
891
  sleep 5
832
892
  local idle_idle idle_compose
833
893
  idle_idle="$(wc -l < "$fx/calls.log" | tr -d ' ')"