teamsmith 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +156 -2
- package/bin/team.mjs +59 -0
- package/install.sh +94 -0
- package/package.json +37 -4
- package/skills/teamsmith/CHANGELOG.md +747 -0
- package/skills/teamsmith/SKILL.md +312 -0
- package/skills/teamsmith/extension/team-bg.ts +399 -0
- package/skills/teamsmith/extension/team-inbox-watch.ts +1412 -0
- package/skills/teamsmith/extension/team-notify.ts +524 -0
- package/skills/teamsmith/references/agent-adapters.md +643 -0
- package/skills/teamsmith/references/config.md +477 -0
- package/skills/teamsmith/references/meeting.md +124 -0
- package/skills/teamsmith/references/memory.md +133 -0
- package/skills/teamsmith/references/migration.md +227 -0
- package/skills/teamsmith/references/openspec.md +208 -0
- package/skills/teamsmith/references/philosophy.md +95 -0
- package/skills/teamsmith/references/protocol.md +712 -0
- package/skills/teamsmith/references/troubleshooting.md +1384 -0
- package/skills/teamsmith/references/workflows.md +448 -0
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +1709 -0
- package/skills/teamsmith/scripts/lib/cmd-bg.sh +284 -0
- package/skills/teamsmith/scripts/lib/cmd-bootstrap.sh +311 -0
- package/skills/teamsmith/scripts/lib/cmd-config.sh +1156 -0
- package/skills/teamsmith/scripts/lib/cmd-death.sh +562 -0
- package/skills/teamsmith/scripts/lib/cmd-docs.sh +149 -0
- package/skills/teamsmith/scripts/lib/cmd-draft.sh +124 -0
- package/skills/teamsmith/scripts/lib/cmd-init.sh +212 -0
- package/skills/teamsmith/scripts/lib/cmd-meeting.sh +904 -0
- package/skills/teamsmith/scripts/lib/cmd-outbox.sh +196 -0
- package/skills/teamsmith/scripts/lib/cmd-project.sh +642 -0
- package/skills/teamsmith/scripts/lib/cmd-review.sh +1393 -0
- package/skills/teamsmith/scripts/lib/cmd-status.sh +1399 -0
- package/skills/teamsmith/scripts/lib/cmd-update.sh +191 -0
- package/skills/teamsmith/scripts/lib/cmd-watch.sh +1681 -0
- package/skills/teamsmith/scripts/lib/common.sh +4964 -0
- package/skills/teamsmith/scripts/lib/draft-entry.sh +51 -0
- package/skills/teamsmith/scripts/lib/outbox.sh +2042 -0
- package/skills/teamsmith/scripts/lib/tmux-argv.sh +165 -0
- package/skills/teamsmith/scripts/monitor.mjs +616 -0
- package/skills/teamsmith/scripts/panel/README.md +192 -0
- package/skills/teamsmith/scripts/panel/build.sh +47 -0
- package/skills/teamsmith/scripts/panel/bun.lock +109 -0
- package/skills/teamsmith/scripts/panel/draft-send.sh +68 -0
- package/skills/teamsmith/scripts/panel/package.json +24 -0
- package/skills/teamsmith/scripts/panel/panel.js +388 -0
- package/skills/teamsmith/scripts/panel/src/App.tsx +2150 -0
- package/skills/teamsmith/scripts/panel/src/clipboard.ts +154 -0
- package/skills/teamsmith/scripts/panel/src/compose.ts +691 -0
- package/skills/teamsmith/scripts/panel/src/data.ts +555 -0
- package/skills/teamsmith/scripts/panel/src/format.ts +50 -0
- package/skills/teamsmith/scripts/panel/src/layout.ts +2562 -0
- package/skills/teamsmith/scripts/panel/src/main.tsx +894 -0
- package/skills/teamsmith/scripts/panel/src/markdown.ts +340 -0
- package/skills/teamsmith/scripts/panel/src/sanitize.ts +42 -0
- package/skills/teamsmith/scripts/panel/src/settings.ts +154 -0
- package/skills/teamsmith/scripts/panel/src/strings/en.ts +416 -0
- package/skills/teamsmith/scripts/panel/src/strings/index.ts +65 -0
- package/skills/teamsmith/scripts/panel/src/strings/types.ts +9 -0
- package/skills/teamsmith/scripts/panel/src/strings/zh.ts +414 -0
- package/skills/teamsmith/scripts/panel/src/theme.ts +116 -0
- package/skills/teamsmith/scripts/panel/src/types.ts +652 -0
- package/skills/teamsmith/scripts/panel/src/width.ts +105 -0
- package/skills/teamsmith/scripts/panel/tsconfig.json +16 -0
- package/skills/teamsmith/scripts/shim/signal-gate +156 -0
- package/skills/teamsmith/scripts/shim/tmux +403 -0
- package/skills/teamsmith/scripts/team +143 -0
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +147 -0
- package/skills/teamsmith/templates/BOARD.md.tmpl +18 -0
- package/skills/teamsmith/templates/DECISIONS.md.tmpl +22 -0
- package/skills/teamsmith/templates/OWNERSHIP.md.tmpl +25 -0
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +84 -0
- package/skills/teamsmith/templates/ROADMAP.md.tmpl +29 -0
- package/skills/teamsmith/templates/config.sh.tmpl +106 -0
- package/skills/teamsmith/templates/memory-seed.md.tmpl +46 -0
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +110 -0
- package/skills/teamsmith/templates/report.md.tmpl +36 -0
- package/skills/teamsmith/templates/task.md.tmpl +65 -0
- package/skills/teamsmith/templates/threads-README.md +17 -0
- package/skills/teamsmith/tests/checkout-shape-probe.sh +571 -0
- package/skills/teamsmith/tests/config-cli.sh +1562 -0
- package/skills/teamsmith/tests/container-tmux.sh +493 -0
- package/skills/teamsmith/tests/coverage-inventory.sh +173 -0
- package/skills/teamsmith/tests/death-cause.sh +564 -0
- package/skills/teamsmith/tests/delivery-truth.sh +1231 -0
- package/skills/teamsmith/tests/fake-tui.py +450 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/README.md +60 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py +139 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/mock-server.py +29 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/observe.ts +20 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh +79 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +175 -0
- package/skills/teamsmith/tests/fixtures/p55/flip-p49.sh +229 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/README.md +22 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/dev2.seen +8 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/dev2.wake +9 -0
- package/skills/teamsmith/tests/fixtures/p71-incident/pm-nudges.wake +3 -0
- package/skills/teamsmith/tests/fixtures/signal-lint-cases.txt +40 -0
- package/skills/teamsmith/tests/flip-glue.sh +162 -0
- package/skills/teamsmith/tests/flip-m12-26c.sh +129 -0
- package/skills/teamsmith/tests/flip-m12.sh +185 -0
- package/skills/teamsmith/tests/flip-m16.sh +166 -0
- package/skills/teamsmith/tests/flip-m17.sh +204 -0
- package/skills/teamsmith/tests/flip-m33.sh +284 -0
- package/skills/teamsmith/tests/flip-m34.sh +96 -0
- package/skills/teamsmith/tests/flip-m37.sh +185 -0
- package/skills/teamsmith/tests/flip-m4.3.sh +375 -0
- package/skills/teamsmith/tests/flip-m43.sh +128 -0
- package/skills/teamsmith/tests/flip-m44.sh +262 -0
- package/skills/teamsmith/tests/flip-m45.sh +244 -0
- package/skills/teamsmith/tests/flip-m46.sh +238 -0
- package/skills/teamsmith/tests/flip-m48.sh +304 -0
- package/skills/teamsmith/tests/flip-m6.2.sh +205 -0
- package/skills/teamsmith/tests/flip-m6.3.sh +283 -0
- package/skills/teamsmith/tests/flip-m6.4.sh +267 -0
- package/skills/teamsmith/tests/flip-m6.5.sh +113 -0
- package/skills/teamsmith/tests/flip-m7.1.sh +135 -0
- package/skills/teamsmith/tests/flip-m7.2.sh +321 -0
- package/skills/teamsmith/tests/flip-p144.sh +112 -0
- package/skills/teamsmith/tests/flip-p156.sh +133 -0
- package/skills/teamsmith/tests/flip-p158.sh +301 -0
- package/skills/teamsmith/tests/flip-p160.sh +182 -0
- package/skills/teamsmith/tests/flip-p171.sh +249 -0
- package/skills/teamsmith/tests/flip-p18.1.sh +95 -0
- package/skills/teamsmith/tests/flip-p20.sh +286 -0
- package/skills/teamsmith/tests/flip-p201.sh +249 -0
- package/skills/teamsmith/tests/flip-p210.sh +239 -0
- package/skills/teamsmith/tests/flip-p211.sh +152 -0
- package/skills/teamsmith/tests/flip-p217.sh +288 -0
- package/skills/teamsmith/tests/flip-p22.sh +123 -0
- package/skills/teamsmith/tests/flip-p23.sh +239 -0
- package/skills/teamsmith/tests/flip-p25.sh +165 -0
- package/skills/teamsmith/tests/flip-p71.sh +184 -0
- package/skills/teamsmith/tests/flip-p72.sh +202 -0
- package/skills/teamsmith/tests/frames/README.md +176 -0
- package/skills/teamsmith/tests/frames/p78-conversation-rule-below-box.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-cursor-mid-draft.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-below-cursor-line.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-below-cursor.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-blank-region.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-draft-rule-only.txt +5 -0
- package/skills/teamsmith/tests/frames/p78-spinner-row-below-cursor.txt +6 -0
- package/skills/teamsmith/tests/frames/p78-wider-rule-below-cursor.txt +6 -0
- package/skills/teamsmith/tests/frames/p86-f1-mixed-width-disjoint-box.txt +8 -0
- package/skills/teamsmith/tests/frames/p86-f1-narrower-width-disjoint-box.txt +8 -0
- package/skills/teamsmith/tests/frames/p86-f1-spinner-top-disjoint-box.txt +8 -0
- package/skills/teamsmith/tests/frames/pi-0.85.1-update-banner.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-draft-half-sentence.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-empty-box.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-one-line-draft.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.87.0-project-trust-prompt.txt +30 -0
- package/skills/teamsmith/tests/frames/pi-0.99.2-empty-editor.txt +32 -0
- package/skills/teamsmith/tests/frames/pi-0.99.2-human-draft.txt +32 -0
- package/skills/teamsmith/tests/frames/pi-1.0.0-git-error-in-box.txt +32 -0
- package/skills/teamsmith/tests/gate-guard.sh +112 -0
- package/skills/teamsmith/tests/guard-matrix.sh +233 -0
- package/skills/teamsmith/tests/install-shape.sh +731 -0
- package/skills/teamsmith/tests/ledger-ban.sh +612 -0
- package/skills/teamsmith/tests/lib/box-judge.sh +68 -0
- package/skills/teamsmith/tests/lib/checkout-shape.sh +77 -0
- package/skills/teamsmith/tests/lib/loop-scan.awk +114 -0
- package/skills/teamsmith/tests/lib/pty-wait.sh +676 -0
- package/skills/teamsmith/tests/lib/section-guard.sh +855 -0
- package/skills/teamsmith/tests/lib/shell-lex.pl +261 -0
- package/skills/teamsmith/tests/lib/tmp-root.sh +528 -0
- package/skills/teamsmith/tests/lib/tmux-cap.sh +35 -0
- package/skills/teamsmith/tests/lib/tmux-iso-call-probe.sh +81 -0
- package/skills/teamsmith/tests/lib/tmux-iso-probe.sh +46 -0
- package/skills/teamsmith/tests/lib/tmux-iso.sh +381 -0
- package/skills/teamsmith/tests/load-experiment.sh +290 -0
- package/skills/teamsmith/tests/loop-inventory.tsv +84 -0
- package/skills/teamsmith/tests/panel-b2-slow-stub.sh +19 -0
- package/skills/teamsmith/tests/panel-b2.sh +1183 -0
- package/skills/teamsmith/tests/panel-b3-pty-mouse.py +240 -0
- package/skills/teamsmith/tests/panel-b3-pty-tmux-mouse.py +138 -0
- package/skills/teamsmith/tests/panel-b3-stub.sh +279 -0
- package/skills/teamsmith/tests/panel-b3.sh +1301 -0
- package/skills/teamsmith/tests/panel-choices.sh +572 -0
- package/skills/teamsmith/tests/panel-clipboard-model.ts +187 -0
- package/skills/teamsmith/tests/panel-compose-model.ts +290 -0
- package/skills/teamsmith/tests/panel-contrast.mjs +81 -0
- package/skills/teamsmith/tests/panel-cpu-premise.sh +173 -0
- package/skills/teamsmith/tests/panel-cpu.sh +391 -0
- package/skills/teamsmith/tests/panel-flip-m54.sh +207 -0
- package/skills/teamsmith/tests/panel-flip-p123.sh +278 -0
- package/skills/teamsmith/tests/panel-flip-p125.sh +318 -0
- package/skills/teamsmith/tests/panel-flip-p128.sh +259 -0
- package/skills/teamsmith/tests/panel-keyprobe-pty.py +99 -0
- package/skills/teamsmith/tests/panel-keyprobe-stub.sh +41 -0
- package/skills/teamsmith/tests/panel-keyprobe.sh +82 -0
- package/skills/teamsmith/tests/panel-keyprobe.tsx +116 -0
- package/skills/teamsmith/tests/panel-knobs.sh +83 -0
- package/skills/teamsmith/tests/panel-p21.sh +2181 -0
- package/skills/teamsmith/tests/panel-snapshots.sh +802 -0
- package/skills/teamsmith/tests/panel-strings.mjs +195 -0
- package/skills/teamsmith/tests/perf.sh +740 -0
- package/skills/teamsmith/tests/pm-box-real.sh +350 -0
- package/skills/teamsmith/tests/pulse-nudge-key.sh +563 -0
- package/skills/teamsmith/tests/routes.sh +1652 -0
- package/skills/teamsmith/tests/section-budgets.tsv +150 -0
- package/skills/teamsmith/tests/section-guard.sh +231 -0
- package/skills/teamsmith/tests/section-needs-audit.sh +94 -0
- package/skills/teamsmith/tests/section-paths.tsv +142 -0
- package/skills/teamsmith/tests/section-select.sh +648 -0
- package/skills/teamsmith/tests/signal-gate.sh +366 -0
- package/skills/teamsmith/tests/signal-lint-legacy.txt +14 -0
- package/skills/teamsmith/tests/signal-lint.pl +416 -0
- package/skills/teamsmith/tests/skill-load.mjs +65 -0
- package/skills/teamsmith/tests/smoke.sh +19599 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-120-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-120-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-120.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-160-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-160.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-59-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-59-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-59.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-99-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-dark-99.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-120-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-120-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-120.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-160-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-160.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-59-detail.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-59-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-59.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-99-p4.txt +32 -0
- package/skills/teamsmith/tests/snapshots/zh-light-99.txt +32 -0
- package/skills/teamsmith/tests/spec-ledger-refs.tsv +78 -0
- package/skills/teamsmith/tests/spec-refs.sh +826 -0
- package/skills/teamsmith/tests/task-header-model.sh +267 -0
- package/skills/teamsmith/tests/team-bg-flip.sh +239 -0
- package/skills/teamsmith/tests/team-bg-harness.mjs +392 -0
- package/skills/teamsmith/tests/team-bg-stop.sh +434 -0
- package/skills/teamsmith/tests/team-inbox-watch-flip.sh +191 -0
- package/skills/teamsmith/tests/team-inbox-watch-harness.mjs +1559 -0
- package/skills/teamsmith/tests/tmp-hygiene.sh +1190 -0
- package/skills/teamsmith/tests/tmux-lint-legacy.txt +31 -0
- package/skills/teamsmith/tests/tmux-lint.pl +604 -0
- package/skills/teamsmith-init/SKILL.md +100 -0
- package/skills/teamsmith-init/references/bootstrap.md +74 -0
- package/skills/teamsmith-init/templates/bootstrap-prompt.md.tmpl +46 -0
|
@@ -0,0 +1,731 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# install-shape.sh — headless fixtures for the npm bin entry and the project-local skill install (P40).
|
|
3
|
+
#
|
|
4
|
+
# bash skills/teamsmith/tests/install-shape.sh # every section
|
|
5
|
+
# bash skills/teamsmith/tests/install-shape.sh install conflict # selected sections
|
|
6
|
+
# TEAM_INSTALL_KEEP=1 bash ... # keep the fixture directory
|
|
7
|
+
# TEAM_INSTALL_TREE=<tree> bash ... # run against another checkout (the flip section builds scratch trees)
|
|
8
|
+
#
|
|
9
|
+
# Sections: surfaces install conflict shell pack doctor flip
|
|
10
|
+
# Exit: 0 every selected section green, 1 at least one assertion failed, 3 setup failure.
|
|
11
|
+
#
|
|
12
|
+
# Nothing here touches the caller's project: every fixture is a fresh git repo under $TMPDIR, the caller's
|
|
13
|
+
# TEAM_*/TMUX identity is stripped first, and no tmux or pi process is started. The doctor section uses a
|
|
14
|
+
# stub `pi` on PATH so its assertions are about the install row, not about the host's agent CLI.
|
|
15
|
+
set -uo pipefail
|
|
16
|
+
|
|
17
|
+
# ── 身份隔离(必须最先做):绝不继承调用者的团队身份 ──────────────────────────────
|
|
18
|
+
# (自己声明的树参数先存下来:下面的清理会把 TEAM_* 全清掉)
|
|
19
|
+
_tree_arg="${TEAM_INSTALL_TREE:-}"
|
|
20
|
+
_keep_arg="${TEAM_INSTALL_KEEP:-0}"
|
|
21
|
+
_tmpkeep="${TEAM_TMP_KEEP:-}"
|
|
22
|
+
while IFS='=' read -r _v _; do
|
|
23
|
+
case "$_v" in TEAM_*) unset "$_v" 2>/dev/null || true ;; esac
|
|
24
|
+
done < <(env)
|
|
25
|
+
unset _v 2>/dev/null || true
|
|
26
|
+
unset TMUX TMUX_PANE 2>/dev/null || true
|
|
27
|
+
|
|
28
|
+
here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
29
|
+
# P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
|
|
30
|
+
. "$here/lib/tmp-root.sh"
|
|
31
|
+
tree="${_tree_arg:-$(cd -P "$here/../../.." && pwd)}"
|
|
32
|
+
team_cli="$tree/skills/teamsmith/scripts/team"
|
|
33
|
+
wrapper="$tree/bin/team.mjs"
|
|
34
|
+
|
|
35
|
+
[ -f "$team_cli" ] || { printf 'install-shape: 没有 CLI:%s\n' "$team_cli" >&2; exit 3; }
|
|
36
|
+
|
|
37
|
+
[ -n "$_tmpkeep" ] && export TEAM_TMP_KEEP="$_tmpkeep"
|
|
38
|
+
keep="$_keep_arg"
|
|
39
|
+
[ "$keep" = "1" ] && export TEAM_TMP_KEEP=1
|
|
40
|
+
tmp="$(tmp_root_create install-shape)" || exit 3
|
|
41
|
+
PASS=0
|
|
42
|
+
FAIL=0
|
|
43
|
+
SKIP=0
|
|
44
|
+
|
|
45
|
+
cleanup() {
|
|
46
|
+
[ "${BASHPID:-$$}" = "$$" ] || return 0
|
|
47
|
+
if [ "$keep" = "1" ]; then printf '\n保留夹具目录:%s\n' "$tmp"
|
|
48
|
+
else tmp_root_reap_all; fi
|
|
49
|
+
}
|
|
50
|
+
trap cleanup EXIT
|
|
51
|
+
|
|
52
|
+
section() { printf '\n\033[1m== %s ==\033[0m\n' "$1"; }
|
|
53
|
+
ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; PASS=$((PASS + 1)); }
|
|
54
|
+
bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL + 1)); }
|
|
55
|
+
skip() { printf ' \033[33mSKIP\033[0m %s\n' "$1"; SKIP=$((SKIP + 1)); }
|
|
56
|
+
assert_eq() { [ "$2" = "$3" ] && ok "$1" || bad "$1(期望 [$3],实际 [$2])"; }
|
|
57
|
+
assert_has() { grep -qF -- "$2" "$1" 2>/dev/null && ok "$3" || bad "$3($1 里找不到 [$2])"; }
|
|
58
|
+
assert_not() { grep -qF -- "$2" "$1" 2>/dev/null && bad "$3(不该出现 [$2])" || ok "$3"; }
|
|
59
|
+
assert_file() { [ -f "$1" ] && ok "$2" || bad "$2(缺 $1)"; }
|
|
60
|
+
assert_not_file() { [ ! -e "$1" ] && [ ! -L "$1" ] && ok "$2" || bad "$2($1 不该存在)"; }
|
|
61
|
+
assert_link_to() { [ -L "$1" ] && [ "$(readlink -f "$1" 2>/dev/null)" = "$2" ] && ok "$3" \
|
|
62
|
+
|| bad "$3($1 → $(readlink -f "$1" 2>/dev/null || echo '不是软链'),期望 $2)"; }
|
|
63
|
+
|
|
64
|
+
SECTIONS=("$@")
|
|
65
|
+
[ "${#SECTIONS[@]}" -gt 0 ] || SECTIONS=(surfaces install conflict shell pack doctor flip)
|
|
66
|
+
want() { local s; for s in "${SECTIONS[@]}"; do [ "$s" = "$1" ] && return 0; done; return 1; }
|
|
67
|
+
|
|
68
|
+
# ---------------------------------------------------------------- helpers
|
|
69
|
+
git_new() { # <dir>:新 git 仓库(一个空提交)
|
|
70
|
+
mkdir -p "$1"
|
|
71
|
+
( cd "$1" && git init -q -b main && git config user.email c@teamsmith && git config user.name c \
|
|
72
|
+
&& git commit -q --allow-empty -m init ) >/dev/null 2>&1
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
run_tree() { # <tree> <repo> <team args...>:在夹具仓库里跑那棵树的 CLI
|
|
76
|
+
local t="$1" d="$2"; shift 2
|
|
77
|
+
( cd "$d" && bash "$t/skills/teamsmith/scripts/team" "$@" 2>&1 )
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
init_proj() { # <tree> <repo> [extra init args...]
|
|
81
|
+
local t="$1" p="$2"; shift 2
|
|
82
|
+
run_tree "$t" "$p" init --session "$(basename "$p")" --agents "dev verify" --vcs local --gates true "$@"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
paths_of() { local t="$1" d="$2"; ( cd "$d" && bash "$t/skills/teamsmith/scripts/team" paths 2>&1 ); }
|
|
86
|
+
|
|
87
|
+
assert_isolated() { # <tree> <repo>:任何写盘命令之前,先证明 team 认的是夹具仓库
|
|
88
|
+
local out; out="$(paths_of "$1" "$2")"
|
|
89
|
+
case "$out" in
|
|
90
|
+
*"\"main_root\": \"$2\""*) ok "身份隔离:team paths 认的是夹具仓库 $(basename "$2")" ;;
|
|
91
|
+
*) bad "身份隔离失败(写盘前必须证明):$out" ;;
|
|
92
|
+
esac
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
files_hash() { # <dir>:目录内容指纹(只算普通文件,软链不跟随)
|
|
96
|
+
( cd "$1" 2>/dev/null && find . -type f -exec sha256sum {} + 2>/dev/null | sort | sha256sum | awk '{print $1}' )
|
|
97
|
+
}
|
|
98
|
+
file_hash() { sha256sum "$1" 2>/dev/null | awk '{print $1}'; }
|
|
99
|
+
|
|
100
|
+
inbox_hash() { # <仓库>:真实仓库收件箱指纹(M7.2 的反向守卫:夹具不许往真账本喂幻影待办)
|
|
101
|
+
( cd "$1" 2>/dev/null || return 0
|
|
102
|
+
find docs/team/inbox -type f 2>/dev/null | sort \
|
|
103
|
+
| while IFS= read -r f; do sha256sum "$f"; done | sha256sum | awk '{print $1}'
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
# ── 版本锚点(P218):唯一来源 = 那棵树自己的 common.sh(TEAM_VERSION),本文件里不出现版本字面量 ──
|
|
108
|
+
# 现场(P214):这四处改坏副本的 sed 原来写死成当时的版本号(`1.42.0`);版本改成 0.1.0 后 sed 空转 → 副本没被改坏 →
|
|
109
|
+
# 五条断言连带红,而 flip ③ 的红侧成了橡皮章(它红是因为前提不成立,证明不了「warn 被静默」)。
|
|
110
|
+
# 纪律:改坏之后必须**回读**证明版本真的与运行版本不同;不成立就报「夹具没生效」并停(exit 3),
|
|
111
|
+
# 不许继续往下跑 —— 假红之后跟着的每一条绿都没有意义。
|
|
112
|
+
fail_setup() { # <原因>:夹具前提不成立 —— 响亮、非 0(3 = setup failure,见文件头),不往下跑
|
|
113
|
+
printf '\033[31m✗ 夹具没生效(setup)\033[0m %s\n' "$*" >&2
|
|
114
|
+
[ "${BASHPID:-$$}" = "$$" ] \
|
|
115
|
+
|| printf ' 注意:在子 shell 里($(…)/管道)被调用 —— exit 只杀子 shell,父进程会继续跑。\n' >&2
|
|
116
|
+
exit 3
|
|
117
|
+
}
|
|
118
|
+
tree_version() { # <tree> → 该树的运行版本(TEAM_VERSION,唯一来源)
|
|
119
|
+
local t="$1" v
|
|
120
|
+
v="$(sed -n 's/^TEAM_VERSION="\([^"]*\)"[[:space:]]*$/\1/p' \
|
|
121
|
+
"$t/skills/teamsmith/scripts/lib/common.sh" 2>/dev/null | head -1)"
|
|
122
|
+
[ -n "$v" ] || fail_setup "读不到 TEAM_VERSION($t/skills/teamsmith/scripts/lib/common.sh)"
|
|
123
|
+
case "$v" in *[!A-Za-z0-9._+-]*) fail_setup "运行版本含 sed 元字符:[$v]" ;; esac
|
|
124
|
+
printf '%s' "$v"
|
|
125
|
+
}
|
|
126
|
+
skill_md_version_of() { # <skill 目录> → frontmatter 的 version(与产品 team_skill_md_version 同一读法)
|
|
127
|
+
awk '
|
|
128
|
+
/^---[[:space:]]*$/ { n++; if (n == 2) exit 0; next }
|
|
129
|
+
n == 1 && /^[[:space:]]+version:[[:space:]]*/ {
|
|
130
|
+
sub(/^[[:space:]]+version:[[:space:]]*/, ""); gsub(/"/, ""); sub(/[[:space:]]+$/, ""); print; exit 0
|
|
131
|
+
}
|
|
132
|
+
' "$1/SKILL.md" 2>/dev/null
|
|
133
|
+
}
|
|
134
|
+
drift_skill_copy() { # <tree> <repo> → DRIFT_VER = 漂移版本;自检不过 = 报「夹具没生效」并 exit 3
|
|
135
|
+
# 结果走全局 DRIFT_VER(照上面 doctor_capture 的 DOC_OUT 形态),**不靠 stdout**:
|
|
136
|
+
# 若在 $(…) 里调用,fail_setup 的 exit 只杀子 shell,守卫会静默失效(P218 红侧实测把它抓了出来)。
|
|
137
|
+
local t="$1" p="$2" dest v_run v_before v_drift
|
|
138
|
+
DRIFT_VER=""
|
|
139
|
+
dest="$p/.pi/skills/teamsmith"
|
|
140
|
+
v_run="$(tree_version "$t")"
|
|
141
|
+
v_before="$(skill_md_version_of "$dest")"
|
|
142
|
+
[ -n "$v_before" ] || fail_setup "副本没有可读的 SKILL.md frontmatter version($dest)"
|
|
143
|
+
[ "$v_before" = "$v_run" ] || fail_setup "副本版本 $v_before ≠ 运行版本 $v_run(副本不是这棵树装的?)"
|
|
144
|
+
v_drift="${v_run}-drift"
|
|
145
|
+
sed -i "s/^ version: \"[^\"]*\"/ version: \"$v_drift\"/" "$dest/SKILL.md"
|
|
146
|
+
[ "$(skill_md_version_of "$dest")" = "$v_drift" ] \
|
|
147
|
+
|| fail_setup "副本版本改不动(sed 没命中 frontmatter 的 version 行):$dest/SKILL.md"
|
|
148
|
+
[ "$v_drift" != "$v_run" ] || fail_setup "漂移版本与运行版本相同:[$v_drift]"
|
|
149
|
+
ok "漂移副本自检:$dest 的版本 $v_before → $v_drift(≠ 运行版本 $v_run)"
|
|
150
|
+
DRIFT_VER="$v_drift"
|
|
151
|
+
}
|
|
152
|
+
DRIFT_VER=""
|
|
153
|
+
|
|
154
|
+
# 假 pi:doctor 的其它行不该由宿主环境决定(本节只测 install 行)
|
|
155
|
+
FAKE_PI="$tmp/fake-pi"
|
|
156
|
+
mkdir -p "$FAKE_PI"
|
|
157
|
+
cat > "$FAKE_PI/pi" <<'EOPI'
|
|
158
|
+
#!/usr/bin/env bash
|
|
159
|
+
case "${1:-}" in
|
|
160
|
+
--version|-v) printf 'pi 0.0.0 (install-shape-stub)\n' ;;
|
|
161
|
+
--help|-h) printf 'usage: pi [--session-id <id>] [-e <ext>] [--skill <dir>]\n' ;;
|
|
162
|
+
esac
|
|
163
|
+
exit 0
|
|
164
|
+
EOPI
|
|
165
|
+
chmod +x "$FAKE_PI/pi"
|
|
166
|
+
|
|
167
|
+
run_doctor() { # <tree> <repo>:stub pi + 依赖项降级,让退出码只反映 install 行以外的硬失败
|
|
168
|
+
( cd "$2" && PATH="$FAKE_PI:$PATH" TEAM_REQUIRE_MAGIC_CONTEXT=0 TEAM_REQUIRE_OPENSPEC=0 TEAM_REQUIRE_JS=0 \
|
|
169
|
+
bash "$1/skills/teamsmith/scripts/team" doctor 2>&1 )
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
# doctor 一次 3 秒级(真跑环境探针):每个夹具状态只跑一次,输出与 rc 都缓存下来
|
|
173
|
+
doctor_capture() { # <tree> <repo> → DOC_OUT / DOC_RC
|
|
174
|
+
DOC_OUT="$(run_doctor "$1" "$2")"; DOC_RC=$?
|
|
175
|
+
}
|
|
176
|
+
install_row_in() { # <captured 输出> → install 行(没有则空)
|
|
177
|
+
printf '%s\n' "$1" | grep -F '项目 skill 安装' | head -1
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
# ── 可重用判据(正常段与 flip 段都用同一份;返回 0 = 判据成立,非 0 = 红并把原因写在 stdout)──
|
|
181
|
+
|
|
182
|
+
chk_wrapper_transparent() { # <tree>:包装器与 bash 入口逐字节、逐 rc 一致
|
|
183
|
+
local t="$1" v1 v2 rc1 rc2
|
|
184
|
+
[ -f "$t/bin/team.mjs" ] || { printf '缺 %s/bin/team.mjs\n' "$t"; return 1; }
|
|
185
|
+
v1="$("$NODE_BIN" "$t/bin/team.mjs" version 2>&1)"; rc1=$?
|
|
186
|
+
v2="$(bash "$t/skills/teamsmith/scripts/team" version 2>&1)"; rc2=$?
|
|
187
|
+
if [ "$rc1" != "$rc2" ] || [ "$v1" != "$v2" ]; then
|
|
188
|
+
printf 'version 不一致:wrapper rc=%s [%s] / bash rc=%s [%s]\n' "$rc1" "$v1" "$rc2" "$v2"; return 1
|
|
189
|
+
fi
|
|
190
|
+
if ! diff <("$NODE_BIN" "$t/bin/team.mjs" help 2>&1) <(bash "$t/skills/teamsmith/scripts/team" help 2>&1) >/dev/null; then
|
|
191
|
+
printf 'help 输出不一致\n'; return 1
|
|
192
|
+
fi
|
|
193
|
+
"$NODE_BIN" "$t/bin/team.mjs" bogus >/dev/null 2>&1; rc1=$?
|
|
194
|
+
bash "$t/skills/teamsmith/scripts/team" bogus >/dev/null 2>&1; rc2=$?
|
|
195
|
+
if [ "$rc1" != "$rc2" ]; then printf '未知子命令 rc 不一致:wrapper=%s bash=%s\n' "$rc1" "$rc2"; return 1; fi
|
|
196
|
+
if [ "$rc1" = "0" ]; then printf '未知子命令居然退出 0\n'; return 1; fi
|
|
197
|
+
printf 'version/help/未知子命令 rc 三处一致(rc=%s)\n' "$rc1"
|
|
198
|
+
return 0
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
# 最低大版本只有一处真源:bin/team.mjs 的 BASH_MIN_MAJOR。夹具从这里读,禁止写死
|
|
202
|
+
# (2026-10-01 实测:把 CLI 的下限从 4 提到 5 之后,本文件里写死的 4 让 39 段红了三条 ✗)
|
|
203
|
+
bash_floor_of() { # <tree>
|
|
204
|
+
grep -oE 'BASH_MIN_MAJOR *= *[0-9]+' "$1/bin/team.mjs" 2>/dev/null | grep -oE '[0-9]+' | head -1
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
chk_no_bash_red() { # <tree> <空 PATH 目录>:没有 bash 时必须拒跑、给修法、不打版本行
|
|
208
|
+
local t="$1" d="$2" out rc floor; floor="$(bash_floor_of "$t")"
|
|
209
|
+
[ -n "$floor" ] || { printf '找不到 BASH_MIN_MAJOR(真源缺失)\n'; return 1; }
|
|
210
|
+
out="$(PATH="$d" "$NODE_BIN" "$t/bin/team.mjs" version 2>&1)"; rc=$?
|
|
211
|
+
if [ "$rc" -eq 0 ]; then printf '没有 bash 时居然 rc=0\n'; return 1; fi
|
|
212
|
+
case "$out" in *bash*) ;; *) printf '没点名 bash:[%s]\n' "$out"; return 1 ;; esac
|
|
213
|
+
case "$out" in *"$floor"*) ;; *) printf '没点名最低版本 %s:[%s]\n' "$floor" "$out"; return 1 ;; esac
|
|
214
|
+
case "$out" in *Requirements*) ;; *) printf '没有指向 README 的 Requirements:[%s]\n' "$out"; return 1 ;; esac
|
|
215
|
+
if printf '%s' "$out" | grep -qE '^teamsmith [0-9]'; then printf '居然打了版本行:[%s]\n' "$out"; return 1; fi
|
|
216
|
+
printf '拒跑并给修法(rc=%s)\n' "$rc"
|
|
217
|
+
return 0
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
chk_old_bash_red() { # <tree> <假 bash 目录(对 BASH_VERSINFO 探针答 3,其余转交真 bash)>
|
|
221
|
+
local t="$1" shim="$2" out rc floor; floor="$(bash_floor_of "$t")"
|
|
222
|
+
[ -n "$floor" ] || { printf '找不到 BASH_MIN_MAJOR(真源缺失)\n'; return 1; }
|
|
223
|
+
out="$(PATH="$shim:$PATH" "$NODE_BIN" "$t/bin/team.mjs" version 2>&1)"; rc=$?
|
|
224
|
+
if [ "$rc" -eq 0 ]; then printf '老 bash 下居然 rc=0\n'; return 1; fi
|
|
225
|
+
case "$out" in *bash*) ;; *) printf '没点名 bash:[%s]\n' "$out"; return 1 ;; esac
|
|
226
|
+
case "$out" in *3*) ;; *) printf '没点名找到的大版本 3:[%s]\n' "$out"; return 1 ;; esac
|
|
227
|
+
case "$out" in *"$floor"*) ;; *) printf '没点名最低大版本 %s:[%s]\n' "$floor" "$out"; return 1 ;; esac
|
|
228
|
+
if printf '%s' "$out" | grep -qE '^teamsmith [0-9]'; then printf 'CLI 居然跑了:[%s]\n' "$out"; return 1; fi
|
|
229
|
+
printf '点名找到的 3 与最低的 %s(rc=%s)\n' "$floor" "$rc"
|
|
230
|
+
return 0
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
chk_unknown_survives() { # <tree> <已在 .pi/skills/teamsmith 放了未识别条目的仓库>
|
|
234
|
+
local t="$1" p="$2" before after out rc dest
|
|
235
|
+
dest="$p/.pi/skills/teamsmith"
|
|
236
|
+
before="$(files_hash "$dest")"
|
|
237
|
+
out="$(init_proj "$t" "$p")"; rc=$?
|
|
238
|
+
if [ "$rc" -eq 0 ]; then printf '未识别的条目居然 rc=0\n'; return 1; fi
|
|
239
|
+
case "$out" in *红线*|*不认识的条目*) ;; *) printf '没说明红线:[%s]\n' "$(printf '%s' "$out" | tail -2 | tr '\n' ' ')"; return 1 ;; esac
|
|
240
|
+
after="$(files_hash "$dest")"
|
|
241
|
+
if [ "$before" != "$after" ]; then printf '拒绝时把字节改了\n'; return 1; fi
|
|
242
|
+
out="$(init_proj "$t" "$p" --force)"; rc=$?
|
|
243
|
+
if [ "$rc" -eq 0 ]; then printf '--force 下未识别的条目居然 rc=0\n'; return 1; fi
|
|
244
|
+
after="$(files_hash "$dest")"
|
|
245
|
+
if [ "$before" != "$after" ]; then printf '--force 把未识别的条目动了\n'; return 1; fi
|
|
246
|
+
printf '拒绝且连 --force 都不删(rc=%s,sha 不变)\n' "$rc"
|
|
247
|
+
return 0
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
mk_unknown() { # <repo> <shape>:造一个不认识的条目(nodir=没有 SKILL.md / othername=name 不符 / file=普通文件)
|
|
251
|
+
local p="$1" shape="$2" dest
|
|
252
|
+
dest="$p/.pi/skills/teamsmith"
|
|
253
|
+
case "$shape" in
|
|
254
|
+
nodir) mkdir -p "$dest"; printf 'not a skill\n' > "$dest/random.txt" ;;
|
|
255
|
+
othername) mkdir -p "$dest"; printf -- '---\nname: something-else\n---\n\n# other\n' > "$dest/SKILL.md" ;;
|
|
256
|
+
file) mkdir -p "$p/.pi/skills"; printf 'not a directory\n' > "$dest" ;;
|
|
257
|
+
esac
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
chk_doctor_drift_warns() { # <tree> <已装了一份漂移副本的仓库> <漂移版本(drift_skill_copy 的输出)>
|
|
261
|
+
local out rc row
|
|
262
|
+
out="$(run_doctor "$1" "$2")"; rc=$?
|
|
263
|
+
if [ "$rc" -ne 0 ]; then printf 'doctor 因 install 行以外的东西非 0(rc=%s)\n' "$rc"; return 1; fi
|
|
264
|
+
row="$(install_row_in "$out")"
|
|
265
|
+
case "$row" in *'!'*) ;; *) printf 'install 行没有 warn:[%s]\n' "$row"; return 1 ;; esac
|
|
266
|
+
case "$row" in *"$3"*) ;; *) printf 'warn 没点名找到的版本 %s:[%s]\n' "$3" "$row"; return 1 ;; esac
|
|
267
|
+
case "$row" in *'team init --force'*) ;; *) printf 'warn 没给修法:[%s]\n' "$row"; return 1 ;; esac
|
|
268
|
+
printf 'warn 点名版本 %s 与修法(%s)\n' "$3" "$(printf '%s' "$row" | awk '{print $NF}')"
|
|
269
|
+
return 0
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
chk_bootstrap_installs() { # <tree> <已初始化但删掉 .pi/skills 的仓库>
|
|
273
|
+
local t="$1" p="$2" h1 h2 out rc
|
|
274
|
+
h1="$(file_hash "$p/.pi/team/config.sh")"
|
|
275
|
+
out="$(run_tree "$t" "$p" bootstrap --no-pulse --agents dev)"; rc=$?
|
|
276
|
+
if [ "$rc" -ne 0 ]; then printf 'bootstrap rc=%s:[%s]\n' "$rc" "$(printf '%s' "$out" | tail -2 | tr '\n' ' ')"; return 1; fi
|
|
277
|
+
if [ ! -L "$p/.pi/skills/teamsmith" ]; then printf '没有装上 .pi/skills/teamsmith\n'; return 1; fi
|
|
278
|
+
if [ "$(readlink -f "$p/.pi/skills/teamsmith")" != "$t/skills/teamsmith" ]; then printf '软链目标不对\n'; return 1; fi
|
|
279
|
+
h2="$(file_hash "$p/.pi/team/config.sh")"
|
|
280
|
+
if [ "$h1" != "$h2" ]; then printf 'config.sh 被改了\n'; return 1; fi
|
|
281
|
+
if ! printf '%s\n' "$out" | grep -qF -- 'pi --approve'; then
|
|
282
|
+
printf 'bootstrap 升级路径没打信任提示行\n'; return 1
|
|
283
|
+
fi
|
|
284
|
+
printf '已存在配置也装了 skill,config.sh 未动,信任提示行也在\n'
|
|
285
|
+
return 0
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
# P59:安装步的信任提示行 —— 同一行必须点名触发资源(.pi/skills/)与三条出路
|
|
289
|
+
# (pi --approve / /trust / team init --no-skills),而且只能出现一次。
|
|
290
|
+
chk_trust_hint() { # <init 捕获输出>
|
|
291
|
+
local line n
|
|
292
|
+
line="$(printf '%s\n' "$1" | grep -F -- 'pi --approve' | head -1)"
|
|
293
|
+
if [ -z "$line" ]; then
|
|
294
|
+
printf '输出里没有信任提示行(要一行点名 .pi/skills/ + pi --approve + /trust + team init --no-skills)\n'
|
|
295
|
+
return 1
|
|
296
|
+
fi
|
|
297
|
+
case "$line" in *'.pi/skills/'*'pi --approve'*'/trust'*'team init --no-skills'*) ;; *)
|
|
298
|
+
printf '提示行缺要点:[%s]\n' "$line"; return 1 ;; esac
|
|
299
|
+
n="$(printf '%s' "$1" | grep -cF -- 'pi --approve' || true)"
|
|
300
|
+
if [ "$n" != "1" ]; then printf '提示行不是恰好一行(%s 行)\n' "$n"; return 1; fi
|
|
301
|
+
printf '信任提示行打了一次:[%s]\n' "$(printf '%s' "$line" | LC_ALL=C sed 's/^[[:space:]]*//' | cut -c1-56)"
|
|
302
|
+
return 0
|
|
303
|
+
}
|
|
304
|
+
chk_trust_hint_case() { # <tree> <repo>:init 一次并检查提示行
|
|
305
|
+
local out rc
|
|
306
|
+
out="$(init_proj "$1" "$2")"; rc=$?
|
|
307
|
+
[ "$rc" -eq 0 ] || { printf 'init rc=%s\n' "$rc"; return 1; }
|
|
308
|
+
chk_trust_hint "$out"
|
|
309
|
+
}
|
|
310
|
+
chk_no_skills_silent() { # <tree> <repo>:--no-skills 下不许出现这一行
|
|
311
|
+
local out rc
|
|
312
|
+
out="$(init_proj "$1" "$2" --no-skills)"; rc=$?
|
|
313
|
+
[ "$rc" -eq 0 ] || { printf -- '--no-skills init rc=%s\n' "$rc"; return 1; }
|
|
314
|
+
if printf '%s\n' "$out" | grep -qF -- 'pi --approve'; then printf -- '--no-skills 下打了信任提示行\n'; return 1; fi
|
|
315
|
+
printf -- '--no-skills 安静(没打信任提示行)\n'
|
|
316
|
+
return 0
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
chk_pack_manifest() { # <tree>:声明面 —— 恰好一个 bin 键,files 带着 bin/
|
|
320
|
+
python3 - "$1/package.json" <<'PYMANI'
|
|
321
|
+
import json, sys
|
|
322
|
+
p = json.load(open(sys.argv[1]))
|
|
323
|
+
binmap = p.get("bin") or {}
|
|
324
|
+
files = p.get("files") or []
|
|
325
|
+
problems = []
|
|
326
|
+
if list(binmap.keys()) != ["team"]:
|
|
327
|
+
problems.append("bin 键不是恰好一个 team:%r" % (list(binmap.keys()),))
|
|
328
|
+
elif binmap["team"].lstrip("./") != "bin/team.mjs":
|
|
329
|
+
problems.append("bin.team 指向 %r(要 bin/team.mjs)" % binmap["team"])
|
|
330
|
+
if "bin/" not in files:
|
|
331
|
+
problems.append("files 白名单里没有 bin/:%r" % (files,))
|
|
332
|
+
if problems:
|
|
333
|
+
print(";".join(problems)); sys.exit(1)
|
|
334
|
+
print("bin 一项 + files 带 bin/(%r)" % (binmap["team"],))
|
|
335
|
+
PYMANI
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
chk_pack_walk() { # <tree>:npm pack --dry-run 清单齐全且不含账本
|
|
339
|
+
local t="$1" json="$tmp/pack-walk.json"
|
|
340
|
+
( cd "$t" && npm pack --dry-run --json >"$json" 2>/dev/null ) || { printf 'npm pack --dry-run 失败\n'; return 1; }
|
|
341
|
+
python3 - "$json" <<'PYPACK'
|
|
342
|
+
import json, sys
|
|
343
|
+
data = json.load(open(sys.argv[1]))
|
|
344
|
+
files = [f["path"] for f in data[0]["files"]]
|
|
345
|
+
want = ["bin/team.mjs", "skills/teamsmith/SKILL.md", "skills/teamsmith-init/SKILL.md", "install.sh"]
|
|
346
|
+
missing = [p for p in want if p not in files]
|
|
347
|
+
forbidden = [p for p in files if p.startswith(("docs/team/", ".pi/", "openspec/")) or "node_modules" in p]
|
|
348
|
+
if missing:
|
|
349
|
+
print("缺:" + "、".join(missing)); sys.exit(1)
|
|
350
|
+
if forbidden:
|
|
351
|
+
print("不该在包里:" + "、".join(forbidden[:3])); sys.exit(1)
|
|
352
|
+
print("清单齐全(%d 项)且不含账本/node_modules" % len(files))
|
|
353
|
+
PYPACK
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
chk_prefix_install() { # <tree>:npm 私有 prefix 安装后与 bash 入口一致
|
|
357
|
+
local t="$1" tgz prefix v1 v2
|
|
358
|
+
tgz="$(cd "$tmp" && npm pack "$t" 2>/dev/null | tail -1)"
|
|
359
|
+
[ -n "$tgz" ] && [ -f "$tmp/$tgz" ] || { printf 'npm pack 没产出 tgz\n'; return 1; }
|
|
360
|
+
prefix="$tmp/prefix-$$"; rm -rf "$prefix"; mkdir -p "$prefix"
|
|
361
|
+
if ! npm install -g --prefix "$prefix" --no-audit --no-fund "$tmp/$tgz" >"$tmp/npm-i.log" 2>&1; then
|
|
362
|
+
printf 'npm install -g --prefix 失败:%s\n' "$(tail -1 "$tmp/npm-i.log")"; return 1
|
|
363
|
+
fi
|
|
364
|
+
if [ ! -x "$prefix/lib/node_modules/teamsmith/bin/team.mjs" ]; then printf 'npm 没把 bin 目标 chmod 成可执行\n'; return 1; fi
|
|
365
|
+
v1="$("$prefix/bin/team" version 2>&1)"
|
|
366
|
+
v2="$(bash "$t/skills/teamsmith/scripts/team" version 2>&1)"
|
|
367
|
+
if [ "$v1" != "$v2" ]; then printf 'prefix 的 version 不一致:[%s] vs [%s]\n' "$v1" "$v2"; return 1; fi
|
|
368
|
+
if ! diff <("$prefix/bin/team" help 2>&1) <(bash "$t/skills/teamsmith/scripts/team" help 2>&1) >/dev/null; then
|
|
369
|
+
printf 'prefix 的 help 与 bash 入口不一致\n'; return 1
|
|
370
|
+
fi
|
|
371
|
+
printf '私有 prefix 安装后 version/help 与 bash 入口一致(%s/bin/team)\n' "$prefix"
|
|
372
|
+
return 0
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
check_holds() { # <label> <chk fn> <args...>:判据成立 → 绿
|
|
376
|
+
local label="$1" fn="$2"; shift 2
|
|
377
|
+
local out rc
|
|
378
|
+
out="$("$fn" "$@" 2>&1)"; rc=$?
|
|
379
|
+
if [ "$rc" -eq 0 ]; then ok "$label:$out"; else bad "$label:$out"; fi
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
check_breaks() { # <label> <chk fn> <args...>:判据必须红(翻转侧)
|
|
383
|
+
local label="$1" fn="$2"; shift 2
|
|
384
|
+
local out rc
|
|
385
|
+
out="$("$fn" "$@" 2>&1)"; rc=$?
|
|
386
|
+
if [ "$rc" -ne 0 ]; then ok "$label:翻转后红($out)"; else bad "$label:翻转后判据还绿(没钉住)"; fi
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
scratch_tree() { # <dir>:从被测树复制出一棵可运行的最小 CLI 树(不含 .git 与 node_modules)
|
|
390
|
+
local d="$1"
|
|
391
|
+
mkdir -p "$d"
|
|
392
|
+
( cd "$tree" && tar -cf - --exclude='./.git' --exclude='*/node_modules' \
|
|
393
|
+
package.json install.sh bin skills ) | tar -C "$d" -xf -
|
|
394
|
+
return 0
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
NODE_BIN="$(command -v node 2>/dev/null || true)"
|
|
398
|
+
# 反向守卫(M7.2):整轮夹具跑完,真实仓库的收件箱必须一个字节都没变
|
|
399
|
+
inbox_before="$(inbox_hash "$tree")"
|
|
400
|
+
|
|
401
|
+
# ---------------------------------------------------------------- surfaces · R1
|
|
402
|
+
if want surfaces; then
|
|
403
|
+
section "surfaces · 安装节在前、.pi/skills 被点名(R1 的四个宣称面)"
|
|
404
|
+
init_skill="$tree/skills/teamsmith-init/SKILL.md"
|
|
405
|
+
daily_skill="$tree/skills/teamsmith/SKILL.md"
|
|
406
|
+
lines="$(wc -l < "$init_skill")"
|
|
407
|
+
[ "$lines" -le 100 ] && ok "teamsmith-init/SKILL.md 仍是 $lines 行(≤ 100)" || bad "teamsmith-init/SKILL.md 超行数($lines)"
|
|
408
|
+
n_npm="$(grep -nF 'npm install -g teamsmith' "$init_skill" | head -1 | cut -d: -f1)"
|
|
409
|
+
n_init="$(grep -nF 'team init' "$init_skill" | head -1 | cut -d: -f1)"
|
|
410
|
+
n_boot="$(grep -nF 'team bootstrap' "$init_skill" | head -1 | cut -d: -f1)"
|
|
411
|
+
if [ -n "$n_npm" ] && [ -n "$n_init" ] && [ -n "$n_boot" ] && [ "$n_npm" -lt "$n_init" ] && [ "$n_init" -lt "$n_boot" ]; then
|
|
412
|
+
ok "init SKILL 的行序:npm($n_npm) < team init($n_init) < team bootstrap($n_boot)"
|
|
413
|
+
else
|
|
414
|
+
bad "init SKILL 行序不对:npm=[$n_npm] init=[$n_init] bootstrap=[$n_boot]"
|
|
415
|
+
fi
|
|
416
|
+
grep -qF '.pi/skills/' "$init_skill" && ok "init SKILL 点名项目目标 .pi/skills/" || bad "init SKILL 没点名 .pi/skills/"
|
|
417
|
+
grep -qF 'pi install' "$init_skill" && grep -qF 'install.sh' "$init_skill" \
|
|
418
|
+
&& ok "init SKILL 同时保留两条替代路线(pi install / install.sh)" \
|
|
419
|
+
|| bad "init SKILL 少了替代路线"
|
|
420
|
+
help_out="$(bash "$team_cli" help 2>&1)"
|
|
421
|
+
help_init="$(printf '%s\n' "$help_out" | grep -A2 '^ init ')"
|
|
422
|
+
case "$help_init" in *'.pi/skills'*'--copy'*'--no-skills'*)
|
|
423
|
+
ok "team help 的 init 行点名 .pi/skills / --copy / --no-skills" ;;
|
|
424
|
+
*) bad "team help 的 init 行没说全($(printf '%s' "$help_init" | tr '\n' ' '))" ;;
|
|
425
|
+
esac
|
|
426
|
+
printf '%s\n' "$help_out" | grep -A2 '^ bootstrap ' | grep -qF '.pi/skills' \
|
|
427
|
+
&& ok "team help 的 bootstrap 行点名装 skill 一步" || bad "team help 的 bootstrap 行没点名装 skill"
|
|
428
|
+
grep -F '| Init / self-check |' "$daily_skill" | grep -qF '.pi/skills/' \
|
|
429
|
+
&& ok "日常 skill 的命令表 init 行点名项目 skill 安装" || bad "日常 skill 的命令表 init 行没点名安装"
|
|
430
|
+
n_r_npm="$(grep -nF 'npm install -g teamsmith' "$tree/README.md" | head -1 | cut -d: -f1)"
|
|
431
|
+
n_r_pi="$(grep -nF 'pi install' "$tree/README.md" | head -1 | cut -d: -f1)"
|
|
432
|
+
n_r_sh="$(grep -nF './install.sh' "$tree/README.md" | head -1 | cut -d: -f1)"
|
|
433
|
+
if [ -n "$n_r_npm" ] && [ -n "$n_r_pi" ] && [ -n "$n_r_sh" ] && [ "$n_r_npm" -lt "$n_r_pi" ] && [ "$n_r_npm" -lt "$n_r_sh" ]; then
|
|
434
|
+
ok "README §Install 的行序:npm+team init($n_r_npm) 在两条替代路线之前"
|
|
435
|
+
else
|
|
436
|
+
bad "README §Install 行序不对:npm=[$n_r_npm] pi install=[$n_r_pi] install.sh=[$n_r_sh]"
|
|
437
|
+
fi
|
|
438
|
+
local floor_r; floor_r="$(bash_floor_of "$tree")"
|
|
439
|
+
grep -F 'bash' "$tree/README.md" | grep -F "≥ $floor_r" | grep -qiF 'checks' \
|
|
440
|
+
&& ok "README 的 bash 行写明入口会检查它(≥ $floor_r)" || bad "README 的 bash 行没写检查(要求 ≥ $floor_r 且有 checks;真源 BASH_MIN_MAJOR=$floor_r)"
|
|
441
|
+
fi
|
|
442
|
+
|
|
443
|
+
# ---------------------------------------------------------------- install · R2
|
|
444
|
+
if want install; then
|
|
445
|
+
section "install · link/--copy/--no-skills/幂等/.gitignore/linked worktree/bootstrap 升级路径"
|
|
446
|
+
# ① 默认 link 两条 + .gitignore + 第二次 init skip
|
|
447
|
+
p="$tmp/p-link"; git_new "$p"; assert_isolated "$tree" "$p"
|
|
448
|
+
out="$(init_proj "$tree" "$p")"; rc=$?
|
|
449
|
+
assert_eq "init 退出码 0" "$rc" "0"
|
|
450
|
+
assert_eq "输出逐 skill 一条 link 行" "$(printf '%s' "$out" | grep -cE '^ link .*/\.pi/skills/(teamsmith|teamsmith-init) → ' || true)" "2"
|
|
451
|
+
assert_link_to "$p/.pi/skills/teamsmith" "$tree/skills/teamsmith" ".pi/skills/teamsmith 是指向运行树的软链"
|
|
452
|
+
assert_link_to "$p/.pi/skills/teamsmith-init" "$tree/skills/teamsmith-init" ".pi/skills/teamsmith-init 是指向兄弟目录的软链"
|
|
453
|
+
# P59:装完打一行信任提示(.pi/skills/ 是 Pi 的信任资源 → 第一次跑 pi 会问;三条出路)
|
|
454
|
+
check_holds "P59 装完一行信任提示(触发资源 + 三条出路)" chk_trust_hint "$out"
|
|
455
|
+
case "$out" in *"link $p/.pi/skills/teamsmith → $tree/skills/teamsmith"*) ok "link 行是逐 skill 一行(含目标与源)" ;;
|
|
456
|
+
*) bad "link 行形状不对:$(printf '%s' "$out" | grep link | tr '\n' ' ')" ;; esac
|
|
457
|
+
assert_eq ".gitignore 有 .pi/skills/ 且只一条" "$(grep -cxF '.pi/skills/' "$p/.gitignore" || true)" "1"
|
|
458
|
+
t1="$(readlink -f "$p/.pi/skills/teamsmith")"; t2="$(readlink -f "$p/.pi/skills/teamsmith-init")"
|
|
459
|
+
out2="$(init_proj "$tree" "$p")"; rc2=$?
|
|
460
|
+
assert_eq "第二次 init 退出码 0" "$rc2" "0"
|
|
461
|
+
case "$out2" in *"skip $p/.pi/skills/teamsmith("*) ok "第二次 init 报 skip" ;; *) bad "第二次 init 没有 skip 行" ;; esac
|
|
462
|
+
assert_eq "第二次 init 后目标不变" "$(readlink -f "$p/.pi/skills/teamsmith")" "$t1"
|
|
463
|
+
assert_eq "第二次 init 后兄弟目标不变" "$(readlink -f "$p/.pi/skills/teamsmith-init")" "$t2"
|
|
464
|
+
check_holds "P59 重跑(skip)仍然打那一行" chk_trust_hint "$out2"
|
|
465
|
+
assert_eq ".pi/skills/ 里仍然只有两条" "$(ls -1A "$p/.pi/skills" | wc -l)" "2"
|
|
466
|
+
out3="$(init_proj "$tree" "$p" --copy)"; rc3=$?
|
|
467
|
+
assert_eq "--copy 对着已有软链退出 0(skip,不是覆盖)" "$rc3" "0"
|
|
468
|
+
assert_eq "--copy 后仍是同一软链目标" "$(readlink -f "$p/.pi/skills/teamsmith")" "$t1"
|
|
469
|
+
|
|
470
|
+
# ② --no-skills:不建目录、也不动 .gitignore
|
|
471
|
+
p="$tmp/p-noskills"; git_new "$p"; assert_isolated "$tree" "$p"
|
|
472
|
+
out="$(init_proj "$tree" "$p" --no-skills)"; rc=$?
|
|
473
|
+
assert_eq "--no-skills 退出码 0" "$rc" "0"
|
|
474
|
+
case "$out" in *'--no-skills'*) ok "--no-skills 明说跳过了这一步" ;; *) bad "--no-skills 没有说明" ;; esac
|
|
475
|
+
check_holds "P59 --no-skills 不打信任提示行" chk_no_skills_silent "$tree" "$p"
|
|
476
|
+
assert_not_file "$p/.pi/skills" "--no-skills 没建 .pi/skills/"
|
|
477
|
+
assert_eq ".gitignore 没被塞进 .pi/skills/" "$(grep -cxF '.pi/skills/' "$p/.gitignore" || true)" "0"
|
|
478
|
+
|
|
479
|
+
# ③ --copy:真目录、字节相等、不带 node_modules/.git
|
|
480
|
+
p="$tmp/p-copy"; git_new "$p"; assert_isolated "$tree" "$p"
|
|
481
|
+
init_proj "$tree" "$p" --copy >/dev/null; rc=$?
|
|
482
|
+
assert_eq "--copy 退出码 0" "$rc" "0"
|
|
483
|
+
[ -d "$p/.pi/skills/teamsmith" ] && [ ! -L "$p/.pi/skills/teamsmith" ] \
|
|
484
|
+
&& ok "--copy 装的是真目录(不是软链)" || bad "--copy 装的不是目录"
|
|
485
|
+
assert_eq "--copy 的 SKILL.md 与源逐字节相等" "$(cmp -s "$tree/skills/teamsmith/SKILL.md" "$p/.pi/skills/teamsmith/SKILL.md" && echo same || echo differ)" "same"
|
|
486
|
+
assert_file "$p/.pi/skills/teamsmith/scripts/team" "--copy 带着可运行的 scripts/team"
|
|
487
|
+
assert_not_file "$p/.pi/skills/teamsmith/scripts/panel/node_modules" "--copy 排除了 node_modules/"
|
|
488
|
+
assert_not_file "$p/.pi/skills/teamsmith/.git" "--copy 排除了 .git/"
|
|
489
|
+
assert_not_file "$p/.pi/skills/teamsmith-init/scripts/panel/node_modules" "--copy 的兄弟条目也排除 node_modules/"
|
|
490
|
+
|
|
491
|
+
# ④ linked worktree:装到主工作树,不装到 worktree
|
|
492
|
+
p="$tmp/p-wt"; git_new "$p"; init_proj "$tree" "$p" --no-skills >/dev/null
|
|
493
|
+
( cd "$p" && git add -A >/dev/null 2>&1 && git commit -qm init2 >/dev/null 2>&1 )
|
|
494
|
+
( cd "$p" && git worktree add -q "$p/.worktrees/wt" -b task/wt >/dev/null 2>&1 )
|
|
495
|
+
out="$(run_tree "$tree" "$p/.worktrees/wt" init --session wt --vcs local --gates true)"; rc=$?
|
|
496
|
+
assert_eq "worktree 里 init 退出码 0" "$rc" "0"
|
|
497
|
+
assert_link_to "$p/.pi/skills/teamsmith" "$tree/skills/teamsmith" "安装落在主工作树的 .pi/skills/"
|
|
498
|
+
assert_not_file "$p/.worktrees/wt/.pi/skills" "worktree 侧没有安装条目"
|
|
499
|
+
|
|
500
|
+
# ⑤ bootstrap 升级路径(配置已存在、.pi/skills 缺席)
|
|
501
|
+
p="$tmp/p-boot"; git_new "$p"; assert_isolated "$tree" "$p"
|
|
502
|
+
init_proj "$tree" "$p" >/dev/null; rm -rf "$p/.pi/skills"
|
|
503
|
+
check_holds "bootstrap 对已存在的项目跑同一实现" chk_bootstrap_installs "$tree" "$p"
|
|
504
|
+
assert_eq "bootstrap 后 .gitignore 仍有 .pi/skills/(幂等,不重复)" "$(grep -cxF '.pi/skills/' "$p/.gitignore" || true)" "1"
|
|
505
|
+
|
|
506
|
+
# ⑥ bootstrap --print:点名这一步、什么都不写
|
|
507
|
+
p="$tmp/p-bootprint"; git_new "$p"; assert_isolated "$tree" "$p"
|
|
508
|
+
before="$(files_hash "$p/.git")"
|
|
509
|
+
out="$(run_tree "$tree" "$p" bootstrap --no-pulse --print)"; rc=$?
|
|
510
|
+
assert_eq "bootstrap --print 退出码 0" "$rc" "0"
|
|
511
|
+
case "$out" in *'.pi/skills/'*) ok "--print 的计划点名装 skill 一步" ;; *) bad "--print 没点名装 skill 一步" ;; esac
|
|
512
|
+
assert_not_file "$p/.pi/skills" "--print 没写 .pi/skills/"
|
|
513
|
+
assert_not_file "$p/.pi/team/config.sh" "--print 没写配置"
|
|
514
|
+
assert_eq "--print 没动仓库(.git 指纹不变)" "$(files_hash "$p/.git")" "$before"
|
|
515
|
+
fi
|
|
516
|
+
|
|
517
|
+
# ---------------------------------------------------------------- conflict · R2
|
|
518
|
+
if want conflict; then
|
|
519
|
+
section "conflict · 冲突表逐格:认得出的可被 --force 替换,不认识的连 --force 都不删"
|
|
520
|
+
# ① 三种不认识的形状:都拒绝、字节不动、--force 也不删
|
|
521
|
+
for shape in nodir othername file; do
|
|
522
|
+
p="$tmp/c-$shape"; git_new "$p"; mk_unknown "$p" "$shape"
|
|
523
|
+
check_holds "未识别形状 $shape:拒绝且字节不动(含 --force)" chk_unknown_survives "$tree" "$p"
|
|
524
|
+
done
|
|
525
|
+
# ② 手改过的副本:默认拒绝(字节不动),--force 换成源
|
|
526
|
+
p="$tmp/c-copy"; git_new "$p"; init_proj "$tree" "$p" --copy >/dev/null
|
|
527
|
+
drift_skill_copy "$tree" "$p"
|
|
528
|
+
before="$(file_hash "$p/.pi/skills/teamsmith/SKILL.md")"
|
|
529
|
+
out="$(init_proj "$tree" "$p")"; rc=$?
|
|
530
|
+
[ "$rc" -ne 0 ] && ok "手改副本:默认 init 非 0(rc=$rc)" || bad "手改副本:默认 init 居然 0"
|
|
531
|
+
case "$out" in *'team init --force'*|*'init --force'*) ok "冲突消息给出 --force 出路" ;; *) bad "冲突消息没给 --force 出路" ;; esac
|
|
532
|
+
assert_eq "手改副本:拒绝时 SKILL.md 字节不变" "$(file_hash "$p/.pi/skills/teamsmith/SKILL.md")" "$before"
|
|
533
|
+
init_proj "$tree" "$p" --force >/dev/null 2>&1; rc=$?
|
|
534
|
+
assert_eq "手改副本:--force 退出 0" "$rc" "0"
|
|
535
|
+
assert_eq "手改副本:--force 后 SKILL.md 与源逐字节相等" \
|
|
536
|
+
"$(cmp -s "$tree/skills/teamsmith/SKILL.md" "$p/.pi/skills/teamsmith/SKILL.md" && echo same || echo differ)" "same"
|
|
537
|
+
# ③ 指向别处的软链:默认拒绝且目标不变,--force 重指
|
|
538
|
+
p="$tmp/c-foreign"; git_new "$p"; mkdir -p "$p/.pi/skills" "$tmp/foreign-skill"
|
|
539
|
+
printf -- '---\nname: teamsmith\n---\n' > "$tmp/foreign-skill/SKILL.md"
|
|
540
|
+
ln -s "$tmp/foreign-skill" "$p/.pi/skills/teamsmith"
|
|
541
|
+
out="$(init_proj "$tree" "$p")"; rc=$?
|
|
542
|
+
[ "$rc" -ne 0 ] && ok "别源软链:默认 init 非 0(rc=$rc)" || bad "别源软链:默认 init 居然 0"
|
|
543
|
+
assert_eq "别源软链:拒绝时没被重指" "$(readlink "$p/.pi/skills/teamsmith")" "$tmp/foreign-skill"
|
|
544
|
+
init_proj "$tree" "$p" --force >/dev/null 2>&1; rc=$?
|
|
545
|
+
assert_eq "别源软链:--force 退出 0" "$rc" "0"
|
|
546
|
+
assert_link_to "$p/.pi/skills/teamsmith" "$tree/skills/teamsmith" "别源软链:--force 重指到运行树"
|
|
547
|
+
fi
|
|
548
|
+
|
|
549
|
+
# ---------------------------------------------------------------- shell · R4
|
|
550
|
+
if want shell; then
|
|
551
|
+
section "shell · 包装器的三面:透明 / 没有 bash / bash 太旧"
|
|
552
|
+
if [ -z "$NODE_BIN" ]; then
|
|
553
|
+
skip "本机没有 node:包装器的三面都跳过(npm 入口要 node)"
|
|
554
|
+
else
|
|
555
|
+
check_holds "真实树:包装器与 bash 入口逐字节逐 rc 一致" chk_wrapper_transparent "$tree"
|
|
556
|
+
nobash="$tmp/no-bash"; mkdir -p "$nobash"
|
|
557
|
+
check_holds "没有 bash:拒跑、点名 bash 与最低版本、指向 Requirements" chk_no_bash_red "$tree" "$nobash"
|
|
558
|
+
real_bash="$(command -v bash)"
|
|
559
|
+
shim="$tmp/old-bash"; mkdir -p "$shim"
|
|
560
|
+
printf '#!%s\nfor a in "$@"; do case "$a" in *BASH_VERSINFO*) printf 3; exit 0 ;; esac; done\nexec %s "$@"\n' \
|
|
561
|
+
"$real_bash" "$real_bash" > "$shim/bash"
|
|
562
|
+
chmod +x "$shim/bash"
|
|
563
|
+
check_holds "老 bash(探针答 3):点名找到的版本与最低版本、CLI 没跑" chk_old_bash_red "$tree" "$shim"
|
|
564
|
+
fi
|
|
565
|
+
fi
|
|
566
|
+
|
|
567
|
+
# ---------------------------------------------------------------- pack · R3
|
|
568
|
+
if want pack; then
|
|
569
|
+
section "pack · npm pack 清单 + 私有 prefix 安装后的真用户路径"
|
|
570
|
+
if ! command -v npm >/dev/null 2>&1; then
|
|
571
|
+
skip "本机没有 npm:打包清单与 prefix 安装都跳过(可见 SKIP,不是静默通过)"
|
|
572
|
+
else
|
|
573
|
+
check_holds "声明面:一个 bin 键(team → bin/team.mjs)+ files 带 bin/" chk_pack_manifest "$tree"
|
|
574
|
+
check_holds "打包清单:bin/team.mjs + 两个 SKILL.md + install.sh,不含账本" chk_pack_walk "$tree"
|
|
575
|
+
check_holds "私有 prefix 安装:version/help 与 bash 入口一致" chk_prefix_install "$tree"
|
|
576
|
+
fi
|
|
577
|
+
fi
|
|
578
|
+
|
|
579
|
+
# ---------------------------------------------------------------- doctor · R5
|
|
580
|
+
if want doctor; then
|
|
581
|
+
section "doctor · 三条口径:link=pass / 没有=安静 / 漂移=warn+修法(永不 fail)"
|
|
582
|
+
# ① link → pass 行点名路径与目标;doctor 退出 0
|
|
583
|
+
p="$tmp/d-link"; git_new "$p"; init_proj "$tree" "$p" >/dev/null 2>&1
|
|
584
|
+
doctor_capture "$tree" "$p"; row="$(install_row_in "$DOC_OUT")"
|
|
585
|
+
case "$row" in *'✓'*"$p/.pi/skills/teamsmith"*"$tree/skills/teamsmith"*)
|
|
586
|
+
ok "link:pass 行点名入口与目标" ;; *) bad "link:行不对($row)" ;; esac
|
|
587
|
+
case "$row" in *'!'*) bad "link:居然 warn" ;; *) ok "link:不 warn" ;; esac
|
|
588
|
+
assert_eq "link:doctor 退出 0" "$DOC_RC" "0"
|
|
589
|
+
# ② 没有安装 → 不刷行;doctor 退出 0
|
|
590
|
+
p="$tmp/d-absent"; git_new "$p"; init_proj "$tree" "$p" --no-skills >/dev/null 2>&1
|
|
591
|
+
doctor_capture "$tree" "$p"
|
|
592
|
+
assert_eq "没有安装:doctor 里没有 install 行" "$(install_row_in "$DOC_OUT" | wc -l)" "0"
|
|
593
|
+
assert_eq "没有安装:doctor 退出 0" "$DOC_RC" "0"
|
|
594
|
+
# ③ 漂移的副本 → warn 点名版本与修法;--force 之后回到 pass
|
|
595
|
+
p="$tmp/d-drift"; git_new "$p"; init_proj "$tree" "$p" --copy >/dev/null 2>&1
|
|
596
|
+
drift_skill_copy "$tree" "$p"; d_drift="$DRIFT_VER"
|
|
597
|
+
check_holds "漂移副本:warn 点名 $d_drift 与 team init --force" chk_doctor_drift_warns "$tree" "$p" "$d_drift"
|
|
598
|
+
init_proj "$tree" "$p" --force >/dev/null 2>&1
|
|
599
|
+
doctor_capture "$tree" "$p"; row="$(install_row_in "$DOC_OUT")"
|
|
600
|
+
case "$row" in *'✓'*"$tree/skills/teamsmith"*) ok "漂移修复:--force 后回到 pass" ;; *) bad "漂移修复后行不对($row)" ;; esac
|
|
601
|
+
# ④ 指向别处的软链 → warn 点名两侧路径;--force 修复
|
|
602
|
+
p="$tmp/d-foreign"; git_new "$p"; init_proj "$tree" "$p" --no-skills >/dev/null 2>&1
|
|
603
|
+
mkdir -p "$p/.pi/skills"
|
|
604
|
+
ln -s "$tmp/foreign-skill" "$p/.pi/skills/teamsmith"
|
|
605
|
+
doctor_capture "$tree" "$p"; row="$(install_row_in "$DOC_OUT")"
|
|
606
|
+
case "$row" in *'!'*"$tmp/foreign-skill"*"$tree/skills/teamsmith"*'team init --force'*)
|
|
607
|
+
ok "别源软链:warn 点名两侧路径与修法" ;; *) bad "别源软链:行不对($row)" ;; esac
|
|
608
|
+
assert_eq "别源软链:warn 不改退出码(doctor 0)" "$DOC_RC" "0"
|
|
609
|
+
init_proj "$tree" "$p" --force >/dev/null 2>&1
|
|
610
|
+
assert_link_to "$p/.pi/skills/teamsmith" "$tree/skills/teamsmith" "别源软链:--force 修复到运行树"
|
|
611
|
+
fi
|
|
612
|
+
|
|
613
|
+
# ---------------------------------------------------------------- flip
|
|
614
|
+
if want flip; then
|
|
615
|
+
section "flip · 每条承诺一个 scratch 树红侧(真实树不动;结束比对 git status)"
|
|
616
|
+
porcelain_before="$(cd "$tree" && git status --porcelain | sha256sum)"
|
|
617
|
+
# ① 包装器把 exit status 透传改成 exit 0 → 一致性判据红
|
|
618
|
+
ft="$tmp/f-exit"; scratch_tree "$ft"
|
|
619
|
+
python3 - "$ft/bin/team.mjs" <<'PYEXIT'
|
|
620
|
+
import sys
|
|
621
|
+
p = sys.argv[1]
|
|
622
|
+
s = open(p, encoding='utf-8').read()
|
|
623
|
+
n = s.replace("process.exit(child.status ?? 1)", "process.exit(0)")
|
|
624
|
+
if n == s:
|
|
625
|
+
print("没找到透传行"); sys.exit(1)
|
|
626
|
+
open(p, "w", encoding="utf-8").write(n)
|
|
627
|
+
PYEXIT
|
|
628
|
+
if [ -z "$NODE_BIN" ]; then skip "没有 node:包装器翻转跳过"; else
|
|
629
|
+
check_holds "① 对照:真实树一致" chk_wrapper_transparent "$tree"
|
|
630
|
+
check_breaks "① 翻转 exit status → exit 0" chk_wrapper_transparent "$ft"
|
|
631
|
+
fi
|
|
632
|
+
# ② 冲突表里「不认识的目录」改成可删 → 红线判据红
|
|
633
|
+
ft="$tmp/f-conflict"; scratch_tree "$ft"
|
|
634
|
+
python3 - "$ft/skills/teamsmith/scripts/lib/cmd-init.sh" <<'PYCONF'
|
|
635
|
+
import sys
|
|
636
|
+
p = sys.argv[1]
|
|
637
|
+
s = open(p, encoding='utf-8').read()
|
|
638
|
+
old = 'team_skill_install_refuse_unknown "$dest" "$name"\n rc=1'
|
|
639
|
+
new = 'rm -rf "$dest"\n rc=1'
|
|
640
|
+
if old not in s:
|
|
641
|
+
print("没找到未识别拒绝行"); sys.exit(1)
|
|
642
|
+
open(p, "w", encoding="utf-8").write(s.replace(old, new, 1))
|
|
643
|
+
PYCONF
|
|
644
|
+
pg="$tmp/f-conflict-green"; git_new "$pg"; mk_unknown "$pg" nodir
|
|
645
|
+
pf="$tmp/f-conflict-red"; git_new "$pf"; mk_unknown "$pf" nodir
|
|
646
|
+
check_holds "② 对照:真实树拒绝不认识的目录" chk_unknown_survives "$tree" "$pg"
|
|
647
|
+
check_breaks "② 翻转:把未识别目录改成可删(rm -rf)" chk_unknown_survives "$ft" "$pf"
|
|
648
|
+
# ③ doctor 的 warn 静默 → 漂移判据红
|
|
649
|
+
ft="$tmp/f-doctor"; scratch_tree "$ft"
|
|
650
|
+
printf '\n# FLIP:把 doctor 的 install 行静默掉\nteam_project_skill_install_row() { return 0; }\n' \
|
|
651
|
+
>> "$ft/skills/teamsmith/scripts/lib/cmd-init.sh"
|
|
652
|
+
pg="$tmp/f-doctor-green"; git_new "$pg"; init_proj "$tree" "$pg" --copy >/dev/null 2>&1
|
|
653
|
+
drift_skill_copy "$tree" "$pg"; pg_drift="$DRIFT_VER"
|
|
654
|
+
pf="$tmp/f-doctor-red"; git_new "$pf"; init_proj "$ft" "$pf" --copy >/dev/null 2>&1
|
|
655
|
+
drift_skill_copy "$ft" "$pf"; pf_drift="$DRIFT_VER"
|
|
656
|
+
check_holds "③ 对照:真实树漂移 warn" chk_doctor_drift_warns "$tree" "$pg" "$pg_drift"
|
|
657
|
+
check_breaks "③ 翻转:doctor 的 warn 被静默" chk_doctor_drift_warns "$ft" "$pf" "$pf_drift"
|
|
658
|
+
# ④ bootstrap 的装 skill 步去掉 → 升级路径判据红
|
|
659
|
+
ft="$tmp/f-bootstrap"; scratch_tree "$ft"
|
|
660
|
+
python3 - "$ft/skills/teamsmith/scripts/lib/cmd-bootstrap.sh" <<'PYBOOT'
|
|
661
|
+
import sys
|
|
662
|
+
p = sys.argv[1]
|
|
663
|
+
s = open(p, encoding='utf-8').read()
|
|
664
|
+
old = ' team_init_install_skills || return 1\n'
|
|
665
|
+
if old not in s:
|
|
666
|
+
print("没找到 bootstrap 的装 skill 调用"); sys.exit(1)
|
|
667
|
+
open(p, "w", encoding="utf-8").write(s.replace(old, '', 1))
|
|
668
|
+
PYBOOT
|
|
669
|
+
pg="$tmp/f-boot-green"; git_new "$pg"; init_proj "$tree" "$pg" >/dev/null 2>&1; rm -rf "$pg/.pi/skills"
|
|
670
|
+
pf="$tmp/f-boot-red"; git_new "$pf"; init_proj "$ft" "$pf" >/dev/null 2>&1; rm -rf "$pf/.pi/skills"
|
|
671
|
+
check_holds "④ 对照:真实树 bootstrap 装 skill" chk_bootstrap_installs "$tree" "$pg"
|
|
672
|
+
check_breaks "④ 翻转:bootstrap 去掉装 skill 一步" chk_bootstrap_installs "$ft" "$pf"
|
|
673
|
+
# ⑤ 声明面 flip:files 丢掉 bin/ → 声明面判据红;bin 目标文件不在 → 打包清单判据红
|
|
674
|
+
if ! command -v npm >/dev/null 2>&1; then
|
|
675
|
+
skip "没有 npm:打包相关翻转跳过"
|
|
676
|
+
else
|
|
677
|
+
ft="$tmp/f-pack"; scratch_tree "$ft"
|
|
678
|
+
python3 - "$ft/package.json" <<'PYPACKF'
|
|
679
|
+
import json, sys
|
|
680
|
+
p = sys.argv[1]
|
|
681
|
+
d = json.load(open(p))
|
|
682
|
+
d["files"] = [f for f in d["files"] if f != "bin/"]
|
|
683
|
+
json.dump(d, open(p, "w"), indent=2)
|
|
684
|
+
PYPACKF
|
|
685
|
+
check_holds "⑤a 对照:真实树声明面齐全" chk_pack_manifest "$tree"
|
|
686
|
+
check_breaks "⑤a 翻转:files 丢掉 bin/(npm 仍会带 bin 目标,所以钉在声明面)" chk_pack_manifest "$ft"
|
|
687
|
+
ft="$tmp/f-pack2"; scratch_tree "$ft"; rm -f "$ft/bin/team.mjs"
|
|
688
|
+
check_holds "⑤b 对照:真实树打包清单齐全" chk_pack_walk "$tree"
|
|
689
|
+
check_breaks "⑤b 翻转:bin 目标文件不在(package 不完整)" chk_pack_walk "$ft"
|
|
690
|
+
fi
|
|
691
|
+
# ⑦ P59:安装步的信任提示行 —— 去掉它 → 判据红;让它在 --no-skills 下出现 → 判据红
|
|
692
|
+
ft="$tmp/f-trustline"; scratch_tree "$ft"
|
|
693
|
+
python3 - "$ft/skills/teamsmith/scripts/lib/cmd-init.sh" <<'PYTRUST'
|
|
694
|
+
import sys
|
|
695
|
+
p = sys.argv[1]
|
|
696
|
+
s = open(p, encoding='utf-8').read()
|
|
697
|
+
i = s.find(' team_dim " 提示:.pi/skills/')
|
|
698
|
+
if i < 0:
|
|
699
|
+
print("没找到信任提示行"); sys.exit(1)
|
|
700
|
+
j = s.find("\n", i)
|
|
701
|
+
open(p, "w", encoding="utf-8").write(s[:i] + s[j+1:])
|
|
702
|
+
PYTRUST
|
|
703
|
+
pg="$tmp/f-trust-green"; git_new "$pg"
|
|
704
|
+
pf="$tmp/f-trust-red"; git_new "$pf"
|
|
705
|
+
check_holds "⑦a 对照:真实树装完打信任提示行" chk_trust_hint_case "$tree" "$pg"
|
|
706
|
+
check_breaks "⑦a 翻转:去掉安装步的信任提示行" chk_trust_hint_case "$ft" "$pf"
|
|
707
|
+
ft2="$tmp/f-trust-noskills"; scratch_tree "$ft2"
|
|
708
|
+
python3 - "$ft2/skills/teamsmith/scripts/lib/cmd-init.sh" <<'PYTRUST2'
|
|
709
|
+
import sys
|
|
710
|
+
p = sys.argv[1]
|
|
711
|
+
s = open(p, encoding='utf-8').read()
|
|
712
|
+
old = " printf ' skip %s(--no-skills:只做配置/文档,没装项目本地 skill)\\n' \"$target\"\n return 0"
|
|
713
|
+
if old not in s:
|
|
714
|
+
print("没找到 --no-skills 分支"); sys.exit(1)
|
|
715
|
+
new = old.replace(' return 0', ' team_dim " 提示:.pi/skills/ pi --approve /trust team init --no-skills"\n return 0')
|
|
716
|
+
open(p, "w", encoding="utf-8").write(s.replace(old, new, 1))
|
|
717
|
+
PYTRUST2
|
|
718
|
+
pg2="$tmp/f-trust-noskills-green"; git_new "$pg2"
|
|
719
|
+
pf2="$tmp/f-trust-noskills-red"; git_new "$pf2"
|
|
720
|
+
check_holds "⑦b 对照:真实树 --no-skills 安静" chk_no_skills_silent "$tree" "$pg2"
|
|
721
|
+
check_breaks "⑦b 翻转:提示行也打进 --no-skills 分支" chk_no_skills_silent "$ft2" "$pf2"
|
|
722
|
+
# ⑥ 真实树没被夹具动过:git status 指纹前后一致
|
|
723
|
+
porcelain_after="$(cd "$tree" && git status --porcelain | sha256sum)"
|
|
724
|
+
assert_eq "⑥ 夹具没碰真实树(git status 指纹不变)" "$porcelain_after" "$porcelain_before"
|
|
725
|
+
fi
|
|
726
|
+
|
|
727
|
+
# ---------------------------------------------------------------- 结果
|
|
728
|
+
assert_eq "反向守卫(M7.2):整轮夹具没往真实仓库收件箱写一个字节" "$(inbox_hash "$tree")" "$inbox_before"
|
|
729
|
+
printf '\n\033[1m== 结果 ==\033[0m ✓ %d ✗ %d SKIP %d\n' "$PASS" "$FAIL" "$SKIP"
|
|
730
|
+
[ "$FAIL" -eq 0 ] && exit 0
|
|
731
|
+
exit 1
|