teamsmith 0.0.0-stage → 0.1.2
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 +158 -2
- package/bin/team.mjs +59 -0
- package/install.sh +94 -0
- package/package.json +37 -4
- package/skills/teamsmith/CHANGELOG.md +763 -0
- package/skills/teamsmith/SKILL.md +312 -0
- package/skills/teamsmith/extension/team-bg.ts +435 -0
- package/skills/teamsmith/extension/team-inbox-watch.ts +1412 -0
- package/skills/teamsmith/extension/team-notify.ts +663 -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 +222 -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/bg-ledger-harness.mjs +682 -0
- package/skills/teamsmith/tests/bg-ledger.sh +307 -0
- package/skills/teamsmith/tests/checkout-shape-probe.sh +800 -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 +129 -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 +655 -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 +19711 -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,318 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# panel-flip-p125.sh — the break/fix flips for P125 (change panel-board-cards, panel delta).
|
|
3
|
+
#
|
|
4
|
+
# bash skills/teamsmith/tests/panel-flip-p125.sh # both flips
|
|
5
|
+
# bash skills/teamsmith/tests/panel-flip-p125.sh F-INPLACE # selected flips
|
|
6
|
+
#
|
|
7
|
+
# Each flip copies `panel/src` to a scratch tree, patches it, builds a mutant bundle with the pinned
|
|
8
|
+
# bun, and runs the same P125 frame checks against the mutant (they must go red) and against the
|
|
9
|
+
# committed bundle (they must be green). The working tree's sources are never touched — the mutant
|
|
10
|
+
# lives in the scratch tree, and the committed `panel.js` is compared byte for byte at the end.
|
|
11
|
+
#
|
|
12
|
+
# Flips:
|
|
13
|
+
# F-INPLACE the side-by-side tier keeps the pre-P125 in-place folded line (natural width, no
|
|
14
|
+
# three-column frame) → "folding gives the columns back" reds.
|
|
15
|
+
# F-FRAME99 the grouped tier draws the three-column frame instead of the in-place single line
|
|
16
|
+
# → "a narrow pane saves rows" reds.
|
|
17
|
+
#
|
|
18
|
+
# Exit: 0 every selected flip behaved, 1 at least one flip did not, 3 setup failure.
|
|
19
|
+
set -uo pipefail
|
|
20
|
+
|
|
21
|
+
here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
22
|
+
# P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
|
|
23
|
+
. "$here/lib/tmp-root.sh"
|
|
24
|
+
tree="$(cd -P "$here/../../.." && pwd)"
|
|
25
|
+
skill="$tree/skills/teamsmith"
|
|
26
|
+
panel_dir="$skill/scripts/panel"
|
|
27
|
+
src="$panel_dir/src"
|
|
28
|
+
stub="$here/panel-b3-stub.sh"
|
|
29
|
+
committed="$panel_dir/panel.js"
|
|
30
|
+
bun_bin="${BUN:-$(command -v bun || true)}"
|
|
31
|
+
[ -n "$bun_bin" ] || bun_bin="$HOME/.bun/bin/bun"
|
|
32
|
+
js="$(command -v node || command -v bun || true)"
|
|
33
|
+
tmp="$(tmp_root_create panel-flip-p125)" || exit 3
|
|
34
|
+
PASS=0
|
|
35
|
+
FAIL=0
|
|
36
|
+
cleanup() { [ "${BASHPID:-$$}" = "$$" ] || return 0; tmp_root_reap_all; }
|
|
37
|
+
trap cleanup EXIT
|
|
38
|
+
|
|
39
|
+
ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; PASS=$((PASS + 1)); }
|
|
40
|
+
bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL + 1)); }
|
|
41
|
+
|
|
42
|
+
SECTIONS=("$@")
|
|
43
|
+
[ "${#SECTIONS[@]}" -gt 0 ] || SECTIONS=(F-INPLACE F-FRAME99)
|
|
44
|
+
want() { local s; for s in "${SECTIONS[@]}"; do [ "$s" = "$1" ] && return 0; done; return 1; }
|
|
45
|
+
|
|
46
|
+
[ -x "$bun_bin" ] || { printf 'panel-flip-p125: bun is required (rebuilds the mutant bundle)\n' >&2; exit 3; }
|
|
47
|
+
[ -n "$js" ] || { printf 'panel-flip-p125: node or bun is required (runs the frames)\n' >&2; exit 3; }
|
|
48
|
+
[ -d "$panel_dir/node_modules" ] || { printf 'panel-flip-p125: run `bun install --frozen-lockfile` in scripts/panel first\n' >&2; exit 3; }
|
|
49
|
+
[ -f "$stub" ] || { printf 'panel-flip-p125: missing %s\n' "$stub" >&2; exit 3; }
|
|
50
|
+
|
|
51
|
+
ink_pin="$(sed -n 's/.*"ink": *"\([^"]*\)".*/\1/p' "$panel_dir/package.json")"
|
|
52
|
+
react_pin="$(sed -n 's/.*"react": *"\([^"]*\)".*/\1/p' "$panel_dir/package.json")"
|
|
53
|
+
[ -n "$ink_pin" ] && [ -n "$react_pin" ] || { printf 'panel-flip-p125: cannot read the pins\n' >&2; exit 3; }
|
|
54
|
+
|
|
55
|
+
committed_sha_before="$(sha256sum "$committed" | cut -d' ' -f1)"
|
|
56
|
+
|
|
57
|
+
# ---------------------------------------------------------------- the P125 frame checks
|
|
58
|
+
# The probe is one python program over a rendered `--snapshot` frame; each mode prints `ok` or the
|
|
59
|
+
# concrete problem, so the same function is the green side (committed bundle) and the red side
|
|
60
|
+
# (mutant) — a flip cannot pass by moving the yardstick.
|
|
61
|
+
p125_probe() {
|
|
62
|
+
python3 - "$@" <<'PYP'
|
|
63
|
+
import re, sys
|
|
64
|
+
|
|
65
|
+
WIDE = [(0x1100, 0x115f), (0x2e80, 0x303e), (0x3041, 0x33ff), (0x3400, 0x4dbf), (0x4e00, 0x9fff),
|
|
66
|
+
(0xa000, 0xa4cf), (0xac00, 0xd7a3), (0xf900, 0xfaff), (0xfe10, 0xfe19), (0xfe30, 0xfe6f),
|
|
67
|
+
(0xff00, 0xff60), (0xffe0, 0xffe6), (0x1f300, 0x1f64f), (0x1f900, 0x1f9ff)]
|
|
68
|
+
|
|
69
|
+
def chw(ch):
|
|
70
|
+
cp = ord(ch)
|
|
71
|
+
if cp in (0x200d, 0xfe0f) or 0x0300 <= cp <= 0x036f:
|
|
72
|
+
return 0
|
|
73
|
+
return 2 if any(a <= cp <= b for a, b in WIDE) else 1
|
|
74
|
+
|
|
75
|
+
def dw(text):
|
|
76
|
+
return sum(chw(c) for c in text)
|
|
77
|
+
|
|
78
|
+
def slice_dw(text, start, n):
|
|
79
|
+
out, pos = [], 0
|
|
80
|
+
for ch in text:
|
|
81
|
+
w = chw(ch)
|
|
82
|
+
if start <= pos < start + n:
|
|
83
|
+
out.append(ch)
|
|
84
|
+
pos += w
|
|
85
|
+
if pos >= start + n:
|
|
86
|
+
break
|
|
87
|
+
return "".join(out)
|
|
88
|
+
|
|
89
|
+
def read(path):
|
|
90
|
+
return [l.rstrip("\n") for l in open(path, encoding="utf-8")]
|
|
91
|
+
|
|
92
|
+
mode = sys.argv[1]
|
|
93
|
+
problems = []
|
|
94
|
+
|
|
95
|
+
if mode == "wide":
|
|
96
|
+
path, limit, folded, shown_w = sys.argv[2], int(sys.argv[3]), int(sys.argv[4]), int(sys.argv[5])
|
|
97
|
+
rows = read(path)
|
|
98
|
+
over = [(i + 1, dw(r)) for i, r in enumerate(rows) if dw(r) > limit]
|
|
99
|
+
if over:
|
|
100
|
+
problems.append(f"行超过 {limit} 列:{over[:2]}")
|
|
101
|
+
top = next((i for i, r in enumerate(rows) if "╭─" in r), -1)
|
|
102
|
+
if top < 0:
|
|
103
|
+
problems.append("没有车道行(找不到 ╭─)")
|
|
104
|
+
else:
|
|
105
|
+
row = rows[top]
|
|
106
|
+
frames = [dw(row[:m.start()]) for m in re.finditer("╭─╮", row)]
|
|
107
|
+
if len(frames) != folded:
|
|
108
|
+
problems.append(f"三列小框 {len(frames)} 个,期望 {folded}")
|
|
109
|
+
if "(已折叠)" in row:
|
|
110
|
+
problems.append("宽档还画了原地折叠行")
|
|
111
|
+
for x in frames:
|
|
112
|
+
cells, i = [], top
|
|
113
|
+
while i < len(rows):
|
|
114
|
+
cells.append(slice_dw(rows[i], x, 3))
|
|
115
|
+
i += 1
|
|
116
|
+
if cells[-1] == "╰─╯":
|
|
117
|
+
break
|
|
118
|
+
if cells[0] != "╭─╮" or cells[-1] != "╰─╯":
|
|
119
|
+
problems.append(f"框的角落 {cells[0]!r}..{cells[-1]!r}")
|
|
120
|
+
body = cells[1:-1]
|
|
121
|
+
if not body or not all(c in ("│…│", "│⋮│", "│›│") for c in body):
|
|
122
|
+
problems.append(f"框体 {set(body)}")
|
|
123
|
+
mid = [j for j, c in enumerate(body) if c == "│⋮│"]
|
|
124
|
+
want = (len(body) - 1) // 2
|
|
125
|
+
if mid != [want]:
|
|
126
|
+
problems.append(f"竖省略号在 {mid} 行,期望 [{want}](共 {len(body)} 行)")
|
|
127
|
+
if shown_w > 0:
|
|
128
|
+
m = re.search("╭─ ▾ 完成", row)
|
|
129
|
+
if not m:
|
|
130
|
+
problems.append("没有展开的 done 盒子")
|
|
131
|
+
else:
|
|
132
|
+
x = dw(row[:m.start()])
|
|
133
|
+
j = next(j for j in range(x, dw(row)) if slice_dw(row, j, 1) == "╮")
|
|
134
|
+
if j - x + 1 != shown_w:
|
|
135
|
+
problems.append(f"展开车道宽 {j - x + 1},期望 {shown_w}")
|
|
136
|
+
|
|
137
|
+
elif mode == "grouped":
|
|
138
|
+
path, limit = sys.argv[2], int(sys.argv[3])
|
|
139
|
+
rows = read(path)
|
|
140
|
+
over = [(i + 1, dw(r)) for i, r in enumerate(rows) if dw(r) > limit]
|
|
141
|
+
if over:
|
|
142
|
+
problems.append(f"行超过 {limit} 列:{over[:2]}")
|
|
143
|
+
if any("╭" in r for r in rows):
|
|
144
|
+
problems.append("分组档出现了三列小框的圆角")
|
|
145
|
+
if not any("(已折叠)" in r for r in rows):
|
|
146
|
+
problems.append("没有原地折叠行")
|
|
147
|
+
|
|
148
|
+
elif mode == "focus":
|
|
149
|
+
rows = read(sys.argv[2])
|
|
150
|
+
top = next((i for i, r in enumerate(rows) if "╭─" in r), -1)
|
|
151
|
+
if top < 0:
|
|
152
|
+
problems.append("没有车道行")
|
|
153
|
+
else:
|
|
154
|
+
cells, i = [], top
|
|
155
|
+
while i < len(rows):
|
|
156
|
+
cells.append(slice_dw(rows[i], 0, 3))
|
|
157
|
+
i += 1
|
|
158
|
+
if cells[-1] == "╰─╯":
|
|
159
|
+
break
|
|
160
|
+
if not cells or cells[0] != "╭─╮":
|
|
161
|
+
problems.append("首车道不是三列小框")
|
|
162
|
+
elif cells[1] != "│›│":
|
|
163
|
+
problems.append(f"聚焦框内第一行为 {cells[1]!r},期望 │›│")
|
|
164
|
+
if sum(r.count("›") for r in rows) != 1:
|
|
165
|
+
problems.append("焦点光标不是恰好一个")
|
|
166
|
+
if "待办 1" not in rows[-1]:
|
|
167
|
+
problems.append("底栏没有给出被聚焦折叠车道的标签与计数")
|
|
168
|
+
if any("V14" in r for r in rows):
|
|
169
|
+
problems.append("折叠车道仍渲染卡片")
|
|
170
|
+
|
|
171
|
+
elif mode == "rows":
|
|
172
|
+
folded, unfolded = read(sys.argv[2]), read(sys.argv[3])
|
|
173
|
+
if any("╭" in r for r in folded):
|
|
174
|
+
problems.append("分组档的折叠车道画了三列小框(那里折叠要省行)")
|
|
175
|
+
if not any("已放弃" in r for r in folded):
|
|
176
|
+
problems.append("折叠 done 后「已放弃」没有进入窗口(没有省下行)")
|
|
177
|
+
if any("已放弃" in r for r in unfolded):
|
|
178
|
+
problems.append("展开 done 时「已放弃」也在窗口里(对照无效)")
|
|
179
|
+
|
|
180
|
+
print("ok" if not problems else ";".join(problems))
|
|
181
|
+
PYP
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
frame_checks() { # <panel.js> <dir>
|
|
185
|
+
local p="$1" d="$2" rc=0 verdict
|
|
186
|
+
mkdir -p "$d/root/state"
|
|
187
|
+
render() { # <out> <w> <h> [conf...]
|
|
188
|
+
local out="$1" w="$2" h="$3"; shift 3
|
|
189
|
+
rm -f "$d/root/state/panel.conf"
|
|
190
|
+
[ $# -gt 0 ] && printf '%s\n' "$@" >"$d/root/state/panel.conf"
|
|
191
|
+
# Redirect + sed, never a pipe: the panel exits right after its write and a piped reader can
|
|
192
|
+
# lose the tail. The assertions read visible text, so the tone SGR bytes are stripped here.
|
|
193
|
+
( cd "$d" && env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_PROJECT -u TEAM_SESSION \
|
|
194
|
+
"$js" "$p" --snapshot --root "$d/root" --state-dir "$d/root/state" \
|
|
195
|
+
--team-cli "$stub" --lang zh --theme dark --width "$w" --height "$h" --page 4 ) >"$out.raw" 2>/dev/null
|
|
196
|
+
sed 's/\x1b\[[0-9;]*m//g' "$out.raw" >"$out"
|
|
197
|
+
}
|
|
198
|
+
check() { # <probe...> <label>
|
|
199
|
+
local label="${*: -1}" out
|
|
200
|
+
local probe=("${@:1:$#-1}")
|
|
201
|
+
out="$(p125_probe "${probe[@]}")"
|
|
202
|
+
if [ "$out" = "ok" ]; then
|
|
203
|
+
printf ' \033[32m✓\033[0m %s\n' "$label"
|
|
204
|
+
else
|
|
205
|
+
printf ' \033[31m✗\033[0m %s(%s)\n' "$label" "$out"; rc=1
|
|
206
|
+
fi
|
|
207
|
+
}
|
|
208
|
+
# 1) the wide tier: two empty lanes folded by default = two three-column frames; the four shown
|
|
209
|
+
# lanes take (185 - 3*2)/4 = 44 columns each (the even share is 30) and no line overruns 190.
|
|
210
|
+
render "$d/w190.txt" 190 32
|
|
211
|
+
check wide "$d/w190.txt" 190 2 44 "宽档 190:两个三列小框、四条展开车道各 44 列、不超宽"
|
|
212
|
+
# 2) all six folded: six frames, still bounded.
|
|
213
|
+
render "$d/w190all.txt" 190 32 "boardFold=todo,wip,review,done,blocked,dropped"
|
|
214
|
+
check wide "$d/w190all.txt" 190 6 -1 "宽档 190 全折叠:六个三列小框、行不超宽"
|
|
215
|
+
# 3) the grouped tier keeps the in-place single line and never draws the frame.
|
|
216
|
+
render "$d/g99.txt" 99 32
|
|
217
|
+
check grouped "$d/g99.txt" 99 "窄档 99:原地一行、无三列小框、行不超宽"
|
|
218
|
+
# 4) a narrow pane saves rows: with done holding 20 cards the fold lets `已放弃` into the window.
|
|
219
|
+
export B3_STUB_DONE=20
|
|
220
|
+
render "$d/n99show.txt" 99 32 "boardShow=done"
|
|
221
|
+
render "$d/n99fold.txt" 99 32 "boardFold=done"
|
|
222
|
+
unset B3_STUB_DONE
|
|
223
|
+
check rows "$d/n99fold.txt" "$d/n99show.txt" "窄屏省行:折叠 done(20 卡)让「已放弃」进入窗口,展开时进不来"
|
|
224
|
+
# 5) a focused folded lane in the wide tier: the frame carries the cursor, the band names it.
|
|
225
|
+
render "$d/focus.txt" 190 32 "boardFold=todo"
|
|
226
|
+
check focus "$d/focus.txt" "聚焦折叠车道:框内 │›│、恰好一个光标、底栏「待办 1」、卡片不渲染"
|
|
227
|
+
return $rc
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
# ---------------------------------------------------------------- the mutant build
|
|
231
|
+
build_mutant() { # <name> <edit script>
|
|
232
|
+
local name="$1" edit="$2" tree="$tmp/$1"
|
|
233
|
+
rm -rf "$tree"; mkdir -p "$tree"
|
|
234
|
+
cp -r "$src/." "$tree/"
|
|
235
|
+
ln -sfn "$panel_dir/node_modules" "$tree/node_modules"
|
|
236
|
+
if ! FLIP_EDIT="$edit" FLIP_TREE="$tree" python3 - <<'PYEDIT'
|
|
237
|
+
import os
|
|
238
|
+
tree = os.environ["FLIP_TREE"]
|
|
239
|
+
exec(compile(os.environ["FLIP_EDIT"], "<flip>", "exec"))
|
|
240
|
+
PYEDIT
|
|
241
|
+
then
|
|
242
|
+
printf ' \033[31m✗\033[0m %s:源码断点没打上\n' "$name"
|
|
243
|
+
return 1
|
|
244
|
+
fi
|
|
245
|
+
( cd "$panel_dir" && "$bun_bin" build "$tree/main.tsx" --target=node --format=esm --minify \
|
|
246
|
+
--define "__PIN_INK__=\"$ink_pin\"" --define "__PIN_REACT__=\"$react_pin\"" \
|
|
247
|
+
--outfile "$tmp/$name.js" ) >"$tmp/$name-build.log" 2>&1 || {
|
|
248
|
+
printf ' \033[31m✗\033[0m %s:突变的 bundle 构建失败\n' "$name"; tail -3 "$tmp/$name-build.log" >&2; return 1
|
|
249
|
+
}
|
|
250
|
+
return 0
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
# <name> <edit script> <what the flip breaks>
|
|
254
|
+
flip() {
|
|
255
|
+
local name="$1" edit="$2" what="$3"
|
|
256
|
+
printf '\n\033[1m== %s:%s ==\033[0m\n' "$name" "$what"
|
|
257
|
+
build_mutant "$name" "$edit" || { FAIL=$((FAIL + 1)); return; }
|
|
258
|
+
local green="$tmp/$name-green.log" red="$tmp/$name-red.log"
|
|
259
|
+
frame_checks "$committed" "$tmp/$name-green-dir" >"$green" 2>&1; local green_rc=$?
|
|
260
|
+
frame_checks "$tmp/$name.js" "$tmp/$name-red-dir" >"$red" 2>&1; local red_rc=$?
|
|
261
|
+
if [ "$green_rc" -eq 0 ]; then
|
|
262
|
+
ok "$name:提交的 bundle 上同一组检查绿"
|
|
263
|
+
else
|
|
264
|
+
bad "$name:提交的 bundle 上基线就红了(检查本身坏了)"; sed 's/^/ /' "$green" | grep '✗' | head -3
|
|
265
|
+
fi
|
|
266
|
+
if [ "$red_rc" -ne 0 ] && grep -q '✗' "$red"; then
|
|
267
|
+
ok "$name:突变之后变红($(grep -c '✗' "$red") 条;$(grep '✗' "$red" | head -1 | sed 's/^ *✗ *//' | cut -c1-70))"
|
|
268
|
+
else
|
|
269
|
+
bad "$name:突变之后居然还是绿的(翻转失效)"; sed 's/^/ /' "$red"
|
|
270
|
+
fi
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
# ---------------------------------------------------------------- the flips
|
|
274
|
+
if want F-INPLACE; then
|
|
275
|
+
flip F-INPLACE 'p = f"{tree}/layout.ts"
|
|
276
|
+
s = open(p, encoding="utf-8").read()
|
|
277
|
+
old = " return foldedLaneFrame(ctx, lane, focused, slots + 2)"
|
|
278
|
+
new = """ const out: PlacedLine[] = [foldedLaneLine(ctx, lane, cards.length, width, focused)] // FLIP P125
|
|
279
|
+
while (out.length < slots + 2) out.push({ line: [] })
|
|
280
|
+
return out"""
|
|
281
|
+
assert s.count(old) == 1, "anchor: the folded frame branch"
|
|
282
|
+
s = s.replace(old, new)
|
|
283
|
+
old2 = """ for (const lane of foldedLanes) widths.set(lane, FOLD_FRAME_W)
|
|
284
|
+
const eachShown = Math.max(8, Math.floor((usable - FOLD_FRAME_W * foldedLanes.length) / shownLanes.length))"""
|
|
285
|
+
new2 = """ let spent = 0 // FLIP P125: the pre-frame algorithm — folded lanes take their line s width
|
|
286
|
+
for (const lane of foldedLanes) {
|
|
287
|
+
const w = Math.max(1, Math.min(dispWidth(foldedLaneHead(ctx.s, lane, laneCards(rows, lane).length)) + 2, 30))
|
|
288
|
+
widths.set(lane, w)
|
|
289
|
+
spent += w
|
|
290
|
+
}
|
|
291
|
+
const eachShown = Math.max(1, Math.floor((usable - spent) / shownLanes.length))"""
|
|
292
|
+
assert s.count(old2) == 1, "anchor: the folded width share"
|
|
293
|
+
open(p, "w", encoding="utf-8").write(s.replace(old2, new2))
|
|
294
|
+
' "宽档强行用原地一行(自然宽 11–12 列)"
|
|
295
|
+
fi
|
|
296
|
+
|
|
297
|
+
if want F-FRAME99; then
|
|
298
|
+
flip F-FRAME99 'p = f"{tree}/layout.ts"
|
|
299
|
+
s = open(p, encoding="utf-8").read()
|
|
300
|
+
old = " all.push(foldedLaneLine(ctx, lane, cards.length, width, focused))"
|
|
301
|
+
new = " for (const l of foldedLaneFrame(ctx, lane, focused, 3)) all.push(l) // FLIP P125: the grouped tier draws the frame"
|
|
302
|
+
assert s.count(old) == 1, "anchor: the grouped fold branch"
|
|
303
|
+
open(p, "w", encoding="utf-8").write(s.replace(old, new))
|
|
304
|
+
' "窄档强行用三列小框(不再省行)"
|
|
305
|
+
fi
|
|
306
|
+
|
|
307
|
+
# ---------------------------------------------------------------- the committed bundle must be untouched
|
|
308
|
+
committed_sha_after="$(sha256sum "$committed" | cut -d' ' -f1)"
|
|
309
|
+
if [ "$committed_sha_before" = "$committed_sha_after" ]; then
|
|
310
|
+
ok "翻转全程没有碰提交的 panel.js(sha256 不变)"
|
|
311
|
+
else
|
|
312
|
+
bad "翻转改动了提交的 panel.js($committed_sha_before → $committed_sha_after)"
|
|
313
|
+
fi
|
|
314
|
+
|
|
315
|
+
printf '\n\033[1m== 结果 ==\033[0m ✓ %d ✗ %d\n' "$PASS" "$FAIL"
|
|
316
|
+
[ "$FAIL" -eq 0 ] && { printf '\033[32mpanel-flip-p125 全绿\033[0m\n'; exit 0; }
|
|
317
|
+
printf '\033[31mpanel-flip-p125 有失败项\033[0m\n'
|
|
318
|
+
exit 1
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# panel-flip-p128.sh — the break/fix flip for P128 (change panel-board-cards, panel delta).
|
|
3
|
+
#
|
|
4
|
+
# bash skills/teamsmith/tests/panel-flip-p128.sh # the flip
|
|
5
|
+
# bash skills/teamsmith/tests/panel-flip-p128.sh F-COLUMN # same, named
|
|
6
|
+
#
|
|
7
|
+
# Copies `panel/src` to a scratch tree, patches the grouped tier's in-place folded line back to the
|
|
8
|
+
# lane-header column (the pre-P128 shape), builds the mutant bundle with the pinned bun, and runs
|
|
9
|
+
# the P128 checks against the mutant (they must go red) and against the committed bundle (they must
|
|
10
|
+
# be green). The working tree's sources are never touched — the mutant lives in the scratch tree —
|
|
11
|
+
# and the committed `panel.js` is compared byte for byte at the end.
|
|
12
|
+
#
|
|
13
|
+
# The checks are the delta scenario "The in-place folded line lines up with the cards it replaces"
|
|
14
|
+
# (the folded line's marker in the cards' state-glyph column, the focus cursor in the cards' cursor
|
|
15
|
+
# column, the lane header still in its own column) plus the existing narrow-tier shape checks
|
|
16
|
+
# (in place, no three-column frame, rows bounded) as the control group.
|
|
17
|
+
#
|
|
18
|
+
# Flip:
|
|
19
|
+
# F-COLUMN the folded line hangs at the lane-header column again (no leading indent, no cursor
|
|
20
|
+
# column) → the two alignment checks red, the narrow shape checks stay green.
|
|
21
|
+
#
|
|
22
|
+
# Exit: 0 the flip behaved, 1 it did not, 3 setup failure.
|
|
23
|
+
set -uo pipefail
|
|
24
|
+
|
|
25
|
+
here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
26
|
+
# P53:临时根的唯一创建者(${TMPDIR:-/tmp} + owned 家族 + 回收)
|
|
27
|
+
. "$here/lib/tmp-root.sh"
|
|
28
|
+
tree="$(cd -P "$here/../../.." && pwd)"
|
|
29
|
+
skill="$tree/skills/teamsmith"
|
|
30
|
+
panel_dir="$skill/scripts/panel"
|
|
31
|
+
src="$panel_dir/src"
|
|
32
|
+
stub="$here/panel-b3-stub.sh"
|
|
33
|
+
committed="$panel_dir/panel.js"
|
|
34
|
+
bun_bin="${BUN:-$(command -v bun || true)}"
|
|
35
|
+
[ -n "$bun_bin" ] || bun_bin="$HOME/.bun/bin/bun"
|
|
36
|
+
js="$(command -v node || command -v bun || true)"
|
|
37
|
+
tmp="$(tmp_root_create panel-flip-p128)" || exit 3
|
|
38
|
+
PASS=0
|
|
39
|
+
FAIL=0
|
|
40
|
+
cleanup() { [ "${BASHPID:-$$}" = "$$" ] || return 0; tmp_root_reap_all; }
|
|
41
|
+
trap cleanup EXIT
|
|
42
|
+
|
|
43
|
+
ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; PASS=$((PASS + 1)); }
|
|
44
|
+
bad() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=$((FAIL + 1)); }
|
|
45
|
+
|
|
46
|
+
SECTIONS=("$@")
|
|
47
|
+
[ "${#SECTIONS[@]}" -gt 0 ] || SECTIONS=(F-COLUMN)
|
|
48
|
+
want() { local s; for s in "${SECTIONS[@]}"; do [ "$s" = "$1" ] && return 0; done; return 1; }
|
|
49
|
+
|
|
50
|
+
[ -x "$bun_bin" ] || { printf 'panel-flip-p128: bun is required (rebuilds the mutant bundle)\n' >&2; exit 3; }
|
|
51
|
+
[ -n "$js" ] || { printf 'panel-flip-p128: node or bun is required (runs the frames)\n' >&2; exit 3; }
|
|
52
|
+
[ -d "$panel_dir/node_modules" ] || { printf 'panel-flip-p128: run `bun install --frozen-lockfile` in scripts/panel first\n' >&2; exit 3; }
|
|
53
|
+
[ -f "$stub" ] || { printf 'panel-flip-p128: missing %s\n' "$stub" >&2; exit 3; }
|
|
54
|
+
|
|
55
|
+
ink_pin="$(sed -n 's/.*"ink": *"\([^"]*\)".*/\1/p' "$panel_dir/package.json")"
|
|
56
|
+
react_pin="$(sed -n 's/.*"react": *"\([^"]*\)".*/\1/p' "$panel_dir/package.json")"
|
|
57
|
+
[ -n "$ink_pin" ] && [ -n "$react_pin" ] || { printf 'panel-flip-p128: cannot read the pins\n' >&2; exit 3; }
|
|
58
|
+
|
|
59
|
+
committed_sha_before="$(sha256sum "$committed" | cut -d' ' -f1)"
|
|
60
|
+
|
|
61
|
+
# ---------------------------------------------------------------- the P128 frame checks
|
|
62
|
+
# One python program over a rendered `--snapshot` frame; each mode prints `ok` or the concrete
|
|
63
|
+
# problem, so the same function is the green side (committed bundle) and the red side (mutant) —
|
|
64
|
+
# the flip cannot pass by moving the yardstick. Columns are display columns (CJK = 2).
|
|
65
|
+
p128_probe() {
|
|
66
|
+
python3 - "$@" <<'PYP'
|
|
67
|
+
import sys
|
|
68
|
+
|
|
69
|
+
WIDE = [(0x1100, 0x115f), (0x2e80, 0x303e), (0x3041, 0x33ff), (0x3400, 0x4dbf), (0x4e00, 0x9fff),
|
|
70
|
+
(0xa000, 0xa4cf), (0xac00, 0xd7a3), (0xf900, 0xfaff), (0xfe10, 0xfe19), (0xfe30, 0xfe6f),
|
|
71
|
+
(0xff00, 0xff60), (0xffe0, 0xffe6), (0x1f300, 0x1f64f), (0x1f900, 0x1f9ff)]
|
|
72
|
+
|
|
73
|
+
def chw(ch):
|
|
74
|
+
cp = ord(ch)
|
|
75
|
+
if cp in (0x200d, 0xfe0f) or 0x0300 <= cp <= 0x036f:
|
|
76
|
+
return 0
|
|
77
|
+
return 2 if any(a <= cp <= b for a, b in WIDE) else 1
|
|
78
|
+
|
|
79
|
+
def dw(text):
|
|
80
|
+
return sum(chw(c) for c in text)
|
|
81
|
+
|
|
82
|
+
def col_of(row, ch):
|
|
83
|
+
pos = 0
|
|
84
|
+
for c in row:
|
|
85
|
+
if c == ch:
|
|
86
|
+
return pos
|
|
87
|
+
pos += chw(c)
|
|
88
|
+
return -1
|
|
89
|
+
|
|
90
|
+
def read(path):
|
|
91
|
+
return [l.rstrip("\n") for l in open(path, encoding="utf-8")]
|
|
92
|
+
|
|
93
|
+
mode = sys.argv[1]
|
|
94
|
+
problems = []
|
|
95
|
+
|
|
96
|
+
if mode == "grouped":
|
|
97
|
+
path, limit = sys.argv[2], int(sys.argv[3])
|
|
98
|
+
rows = read(path)
|
|
99
|
+
over = [(i + 1, dw(r)) for i, r in enumerate(rows) if dw(r) > limit]
|
|
100
|
+
if over:
|
|
101
|
+
problems.append(f"行超过 {limit} 列:{over[:2]}")
|
|
102
|
+
if any("╭" in r for r in rows):
|
|
103
|
+
problems.append("分组档出现了三列小框的圆角")
|
|
104
|
+
if not any("(已折叠)" in r for r in rows):
|
|
105
|
+
problems.append("没有原地折叠行")
|
|
106
|
+
|
|
107
|
+
elif mode == "align":
|
|
108
|
+
path, kind = sys.argv[2], sys.argv[3]
|
|
109
|
+
rows = read(path)
|
|
110
|
+
folded = [r for r in rows if "(已折叠)" in r]
|
|
111
|
+
|
|
112
|
+
def find(sub):
|
|
113
|
+
return next((r for r in rows if sub in r), "")
|
|
114
|
+
|
|
115
|
+
# ① the unfolded lane header keeps its own marker column (`' ' + ▾`).
|
|
116
|
+
head = find("▾ 进行")
|
|
117
|
+
if not head:
|
|
118
|
+
problems.append("没有展开的 `▾ 进行` 车道头")
|
|
119
|
+
elif col_of(head, "▾") != 1:
|
|
120
|
+
problems.append(f"车道头 ▾ 在第 {col_of(head, '▾')} 列,期望 1:{head!r}")
|
|
121
|
+
# ② an unfocused card's state glyph sits in column 3.
|
|
122
|
+
card = find("P14")
|
|
123
|
+
if not card:
|
|
124
|
+
problems.append("没有 P14 卡片行")
|
|
125
|
+
elif col_of(card, "▸") != 3:
|
|
126
|
+
problems.append(f"卡片 ▸ 在第 {col_of(card, '▸')} 列,期望 3:{card!r}")
|
|
127
|
+
# ③ every in-place folded line's marker sits in column 3 (the cards' glyph column).
|
|
128
|
+
if not folded:
|
|
129
|
+
problems.append("没有原地折叠行")
|
|
130
|
+
for r in folded:
|
|
131
|
+
at = col_of(r, "▸")
|
|
132
|
+
if at != 3:
|
|
133
|
+
problems.append(f"折叠行 ▸ 在第 {at} 列,期望 3(卡片字形列):{r!r}")
|
|
134
|
+
# ④ exactly one focus cursor; its column matches the focused card's cursor column.
|
|
135
|
+
cursors = sum(r.count("›") for r in rows)
|
|
136
|
+
if cursors != 1:
|
|
137
|
+
problems.append(f"焦点光标应当恰好一个,实际 {cursors}")
|
|
138
|
+
if kind == "plain":
|
|
139
|
+
v14 = find("V14")
|
|
140
|
+
if not v14:
|
|
141
|
+
problems.append("plain 帧没有 V14 聚焦卡片行")
|
|
142
|
+
elif col_of(v14, "›") != 1 or col_of(v14, "·") != 3:
|
|
143
|
+
problems.append(f"聚焦卡片 › 在第 {col_of(v14, '›')} 列 / · 在第 {col_of(v14, '·')} 列,期望 1/3:{v14!r}")
|
|
144
|
+
else:
|
|
145
|
+
fr = next((r for r in folded if "›" in r), "")
|
|
146
|
+
if not fr:
|
|
147
|
+
problems.append("focus 帧的折叠行没有光标(焦点没落在折叠车道上)")
|
|
148
|
+
elif col_of(fr, "›") != 1:
|
|
149
|
+
problems.append(f"聚焦折叠行 › 在第 {col_of(fr, '›')} 列,期望 1(与聚焦卡片同列):{fr!r}")
|
|
150
|
+
if "待办 1" not in fr:
|
|
151
|
+
problems.append(f"聚焦折叠行没有标签与计数:{fr!r}")
|
|
152
|
+
|
|
153
|
+
print("ok" if not problems else ";".join(problems))
|
|
154
|
+
PYP
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
frame_checks() { # <panel.js> <dir>
|
|
158
|
+
local p="$1" d="$2" rc=0 verdict
|
|
159
|
+
mkdir -p "$d/root/state"
|
|
160
|
+
render() { # <out> <w> <conf line…>
|
|
161
|
+
local out="$1" w="$2"; shift 2
|
|
162
|
+
rm -f "$d/root/state/panel.conf"
|
|
163
|
+
[ $# -gt 0 ] && printf '%s\n' "$@" >"$d/root/state/panel.conf"
|
|
164
|
+
( cd "$d" && env -u TEAM_ROOT -u TEAM_MAIN_ROOT -u TEAM_PROJECT -u TEAM_SESSION \
|
|
165
|
+
"$js" "$p" --snapshot --root "$d/root" --state-dir "$d/root/state" \
|
|
166
|
+
--team-cli "$stub" --lang zh --theme dark --width "$w" --height 32 --page 4 ) >"$out.raw" 2>/dev/null
|
|
167
|
+
sed 's/\x1b\[[0-9;]*m//g' "$out.raw" >"$out"
|
|
168
|
+
}
|
|
169
|
+
check() { # <probe…> <label>
|
|
170
|
+
local label="${*: -1}" out
|
|
171
|
+
local probe=("${@:1:$#-1}")
|
|
172
|
+
out="$(p128_probe "${probe[@]}")"
|
|
173
|
+
if [ "$out" = "ok" ]; then
|
|
174
|
+
printf ' \033[32m✓\033[0m %s\n' "$label"
|
|
175
|
+
else
|
|
176
|
+
printf ' \033[31m✗\033[0m %s(%s)\n' "$label" "$out"; rc=1
|
|
177
|
+
fi
|
|
178
|
+
}
|
|
179
|
+
# The control group: the existing narrow-tier shape checks (in place, no frame, bounded).
|
|
180
|
+
render "$d/plain99.txt" 99
|
|
181
|
+
check grouped "$d/plain99.txt" 99 "窄档 99:原地一行、无三列小框、行不超宽(既有场景复跑)"
|
|
182
|
+
render "$d/plain60.txt" 60
|
|
183
|
+
check grouped "$d/plain60.txt" 60 "窄档 60(PM 现场档):原地一行、无三列小框、行不超宽"
|
|
184
|
+
# The scenario under test: the folded line's columns. Plain frame: the focus is on V14's card.
|
|
185
|
+
check align "$d/plain99.txt" plain "对齐 99:车道头 ▾ 第 1 列 / 卡片字形第 3 列 / 折叠行标记第 3 列"
|
|
186
|
+
check align "$d/plain60.txt" plain "对齐 60:同 99 —— 折叠行落在卡片列"
|
|
187
|
+
# A folded lane the focus lives in: the cursor takes the card rows' cursor column.
|
|
188
|
+
render "$d/focus99.txt" 99 "boardFold=todo"
|
|
189
|
+
check align "$d/focus99.txt" focus "聚焦折叠行:光标第 1 列(与聚焦卡片同列)、标记第 3 列、恰好一个光标"
|
|
190
|
+
return $rc
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
# ---------------------------------------------------------------- the mutant build
|
|
194
|
+
build_mutant() { # <name> <edit script>
|
|
195
|
+
local name="$1" edit="$2" tree="$tmp/$1"
|
|
196
|
+
rm -rf "$tree"; mkdir -p "$tree"
|
|
197
|
+
cp -r "$src/." "$tree/"
|
|
198
|
+
ln -sfn "$panel_dir/node_modules" "$tree/node_modules"
|
|
199
|
+
if ! FLIP_EDIT="$edit" FLIP_TREE="$tree" python3 - <<'PYEDIT'
|
|
200
|
+
import os
|
|
201
|
+
tree = os.environ["FLIP_TREE"]
|
|
202
|
+
exec(compile(os.environ["FLIP_EDIT"], "<flip>", "exec"))
|
|
203
|
+
PYEDIT
|
|
204
|
+
then
|
|
205
|
+
printf ' \033[31m✗\033[0m %s:源码断点没打上\n' "$name"
|
|
206
|
+
return 1
|
|
207
|
+
fi
|
|
208
|
+
( cd "$panel_dir" && "$bun_bin" build "$tree/main.tsx" --target=node --format=esm --minify \
|
|
209
|
+
--define "__PIN_INK__=\"$ink_pin\"" --define "__PIN_REACT__=\"$react_pin\"" \
|
|
210
|
+
--outfile "$tmp/$name.js" ) >"$tmp/$name-build.log" 2>&1 || {
|
|
211
|
+
printf ' \033[31m✗\033[0m %s:突变的 bundle 构建失败\n' "$name"; tail -3 "$tmp/$name-build.log" >&2; return 1
|
|
212
|
+
}
|
|
213
|
+
return 0
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
# <name> <edit script> <what the flip breaks>
|
|
217
|
+
flip() {
|
|
218
|
+
local name="$1" edit="$2" what="$3"
|
|
219
|
+
printf '\n\033[1m== %s:%s ==\033[0m\n' "$name" "$what"
|
|
220
|
+
build_mutant "$name" "$edit" || { FAIL=$((FAIL + 1)); return; }
|
|
221
|
+
local green="$tmp/$name-green.log" red="$tmp/$name-red.log"
|
|
222
|
+
frame_checks "$committed" "$tmp/$name-green-dir" >"$green" 2>&1; local green_rc=$?
|
|
223
|
+
frame_checks "$tmp/$name.js" "$tmp/$name-red-dir" >"$red" 2>&1; local red_rc=$?
|
|
224
|
+
if [ "$green_rc" -eq 0 ]; then
|
|
225
|
+
ok "$name:提交的 bundle 上同一组检查绿"
|
|
226
|
+
else
|
|
227
|
+
bad "$name:提交的 bundle 上基线就红了(检查本身坏了)"; sed 's/^/ /' "$green" | grep '✗' | head -3
|
|
228
|
+
fi
|
|
229
|
+
if [ "$red_rc" -ne 0 ] && grep -q '✗' "$red"; then
|
|
230
|
+
ok "$name:突变之后变红($(grep -c '✗' "$red") 条;$(grep '✗' "$red" | head -1 | sed 's/^ *✗ *//' | cut -c1-70))"
|
|
231
|
+
else
|
|
232
|
+
bad "$name:突变之后居然还是绿的(翻转失效)"; sed 's/^/ /' "$red"
|
|
233
|
+
fi
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
# ---------------------------------------------------------------- the flip
|
|
237
|
+
if want F-COLUMN; then
|
|
238
|
+
flip F-COLUMN 'p = f"{tree}/layout.ts"
|
|
239
|
+
s = open(p, encoding="utf-8").read()
|
|
240
|
+
old = """ seg(\x27 \x27),
|
|
241
|
+
seg(focused ? `${FOCUS_CURSOR} ` : \x27 \x27, focused ? \x27selected\x27 : \x27dim\x27),"""
|
|
242
|
+
new = """ seg(focused ? `${FOCUS_CURSOR} ` : \x27\x27, \x27selected\x27), // FLIP P128: back to the lane-header column"""
|
|
243
|
+
assert s.count(old) == 1, "anchor: the card-column indent"
|
|
244
|
+
open(p, "w", encoding="utf-8").write(s.replace(old, new))
|
|
245
|
+
' "把折叠行改回车道头那一列(去掉卡片列缩进与光标列)"
|
|
246
|
+
fi
|
|
247
|
+
|
|
248
|
+
# ---------------------------------------------------------------- the committed bundle must be untouched
|
|
249
|
+
committed_sha_after="$(sha256sum "$committed" | cut -d' ' -f1)"
|
|
250
|
+
if [ "$committed_sha_before" = "$committed_sha_after" ]; then
|
|
251
|
+
ok "翻转全程没有碰提交的 panel.js(sha256 不变)"
|
|
252
|
+
else
|
|
253
|
+
bad "翻转改动了提交的 panel.js($committed_sha_before → $committed_sha_after)"
|
|
254
|
+
fi
|
|
255
|
+
|
|
256
|
+
printf '\n\033[1m== 结果 ==\033[0m ✓ %d ✗ %d\n' "$PASS" "$FAIL"
|
|
257
|
+
[ "$FAIL" -eq 0 ] && { printf '\033[32mpanel-flip-p128 全绿\033[0m\n'; exit 0; }
|
|
258
|
+
printf '\033[31mpanel-flip-p128 有失败项\033[0m\n'
|
|
259
|
+
exit 1
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""pty driver for the keystroke probe (pulse-console B1, tasks.md 1.4).
|
|
3
|
+
|
|
4
|
+
`tmux send-keys` cannot be used here: it coalesces the bytes into one write. A real terminal
|
|
5
|
+
delivers one keystroke per read, which is exactly the property the fixture asserts — so the probe
|
|
6
|
+
runs on a pty and the keys are written to the master side with a human-sized gap (E6 §1.1's
|
|
7
|
+
methodology note).
|
|
8
|
+
|
|
9
|
+
python3 panel-keyprobe-pty.py --log FILE --timeout 20 -- <runner> <probe.js> [args...]
|
|
10
|
+
|
|
11
|
+
Prints the child's output and exits with the child's status.
|
|
12
|
+
"""
|
|
13
|
+
import argparse
|
|
14
|
+
import errno
|
|
15
|
+
import os
|
|
16
|
+
import pty
|
|
17
|
+
import select
|
|
18
|
+
import signal
|
|
19
|
+
import sys
|
|
20
|
+
import time
|
|
21
|
+
|
|
22
|
+
KEYS = [b"m", b"h", b"e", b"l", b"l", b"o", b"\r"]
|
|
23
|
+
GAP = 0.12
|
|
24
|
+
FIRST_DELAY = 0.6
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def main() -> int:
|
|
28
|
+
ap = argparse.ArgumentParser()
|
|
29
|
+
ap.add_argument("--log", required=True)
|
|
30
|
+
ap.add_argument("--timeout", type=float, default=20.0)
|
|
31
|
+
ap.add_argument("cmd", nargs=argparse.REMAINDER)
|
|
32
|
+
args = ap.parse_args()
|
|
33
|
+
cmd = args.cmd
|
|
34
|
+
if cmd and cmd[0] == "--":
|
|
35
|
+
cmd = cmd[1:]
|
|
36
|
+
if not cmd:
|
|
37
|
+
print("no command", file=sys.stderr)
|
|
38
|
+
return 64
|
|
39
|
+
|
|
40
|
+
pid, fd = pty.fork()
|
|
41
|
+
if pid == 0: # child
|
|
42
|
+
os.execvp(cmd[0], cmd)
|
|
43
|
+
os._exit(127)
|
|
44
|
+
|
|
45
|
+
deadline = time.time() + args.timeout
|
|
46
|
+
# Wait until the probe has started and opened its log, so the keys land during the refresh.
|
|
47
|
+
started = False
|
|
48
|
+
while time.time() < deadline and not started:
|
|
49
|
+
try:
|
|
50
|
+
with open(args.log) as fh:
|
|
51
|
+
started = '"kind":"start"' in fh.read()
|
|
52
|
+
except OSError:
|
|
53
|
+
pass
|
|
54
|
+
time.sleep(0.05)
|
|
55
|
+
time.sleep(FIRST_DELAY)
|
|
56
|
+
|
|
57
|
+
out = b""
|
|
58
|
+
sent = 0
|
|
59
|
+
status = None
|
|
60
|
+
while True:
|
|
61
|
+
if sent < len(KEYS):
|
|
62
|
+
try:
|
|
63
|
+
os.write(fd, KEYS[sent])
|
|
64
|
+
except OSError as exc:
|
|
65
|
+
if exc.errno != errno.EIO:
|
|
66
|
+
raise
|
|
67
|
+
sent += 1
|
|
68
|
+
time.sleep(GAP)
|
|
69
|
+
r, _, _ = select.select([fd], [], [], 0.1)
|
|
70
|
+
if fd in r:
|
|
71
|
+
try:
|
|
72
|
+
chunk = os.read(fd, 65536)
|
|
73
|
+
except OSError:
|
|
74
|
+
chunk = b""
|
|
75
|
+
if not chunk:
|
|
76
|
+
break
|
|
77
|
+
out += chunk
|
|
78
|
+
done, st = os.waitpid(pid, os.WNOHANG)
|
|
79
|
+
if done == pid:
|
|
80
|
+
status = st
|
|
81
|
+
break
|
|
82
|
+
if time.time() > deadline:
|
|
83
|
+
os.kill(pid, signal.SIGKILL)
|
|
84
|
+
_, st = os.waitpid(pid, 0)
|
|
85
|
+
status = st
|
|
86
|
+
break
|
|
87
|
+
|
|
88
|
+
if status is None:
|
|
89
|
+
_, status = os.waitpid(pid, 0)
|
|
90
|
+
try:
|
|
91
|
+
os.close(fd)
|
|
92
|
+
except OSError:
|
|
93
|
+
pass
|
|
94
|
+
sys.stdout.write(out.decode("utf-8", "replace"))
|
|
95
|
+
return os.waitstatus_to_exitcode(status)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
if __name__ == "__main__":
|
|
99
|
+
sys.exit(main())
|