teamsmith 0.3.4 → 0.4.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/README.md +8 -8
- package/package.json +1 -1
- package/skills/teamsmith/CHANGELOG.md +40 -0
- package/skills/teamsmith/SKILL.md +83 -163
- package/skills/teamsmith/extension/team-notify.ts +1 -1
- package/skills/teamsmith/extension/team-reply.ts +105 -0
- package/skills/teamsmith/references/agent-adapters.md +1 -1
- package/skills/teamsmith/references/config.md +20 -11
- package/skills/teamsmith/references/migration.md +47 -3
- package/skills/teamsmith/references/protocol.md +64 -31
- package/skills/teamsmith/references/reminders.md +131 -0
- package/skills/teamsmith/references/troubleshooting.md +19 -5
- package/skills/teamsmith/references/workflows.md +18 -16
- package/skills/teamsmith/scripts/lib/cmd-agents.sh +77 -49
- package/skills/teamsmith/scripts/lib/cmd-project.sh +193 -21
- package/skills/teamsmith/scripts/lib/cmd-remind.sh +103 -0
- package/skills/teamsmith/scripts/lib/cmd-update.sh +7 -4
- package/skills/teamsmith/scripts/lib/common.sh +44 -4
- package/skills/teamsmith/scripts/lib/outbox.sh +72 -18
- package/skills/teamsmith/scripts/remind-store.mjs +529 -0
- package/skills/teamsmith/scripts/replies.mjs +9 -3
- package/skills/teamsmith/scripts/reply-capture.mjs +612 -0
- package/skills/teamsmith/scripts/state-authority.mjs +500 -0
- package/skills/teamsmith/scripts/strings/commands.tsv +2 -1
- package/skills/teamsmith/scripts/strings/help.en.tsv +16 -2
- package/skills/teamsmith/scripts/strings/help.zh.tsv +16 -2
- package/skills/teamsmith/scripts/team +1 -0
- package/skills/teamsmith/templates/AGENTS.section.md.tmpl +68 -123
- package/skills/teamsmith/templates/PROTOCOL.md.tmpl +48 -55
- package/skills/teamsmith/templates/pm-prompt.md.tmpl +126 -119
- package/skills/teamsmith/tests/checkout-shape-probe.sh +6 -5
- package/skills/teamsmith/tests/delivery-truth.sh +82 -47
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/README.md +71 -23
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/__pycache__/judge-second.cpython-313.pyc +0 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-dirty-ab.py +143 -0
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/judge-second.py +26 -9
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/run-case.sh +92 -20
- package/skills/teamsmith/tests/fixtures/delivery-truth-real/scenario.sh +47 -3
- package/skills/teamsmith/tests/fixtures/reply-capture-provider.ts +76 -0
- package/skills/teamsmith/tests/flip-p410-order2.sh +205 -0
- package/skills/teamsmith/tests/frames/README.md +3 -1
- package/skills/teamsmith/tests/gate-guard.sh +20 -4
- package/skills/teamsmith/tests/help-surface.sh +60 -2
- package/skills/teamsmith/tests/install-shape.sh +312 -0
- package/skills/teamsmith/tests/key-replies-pty.sh +197 -21
- package/skills/teamsmith/tests/key-replies.sh +187 -68
- package/skills/teamsmith/tests/ledger-claim.sh +8 -6
- package/skills/teamsmith/tests/lib/box-judge.sh +2 -1
- package/skills/teamsmith/tests/lib/main-team-fingerprint.sh +104 -0
- package/skills/teamsmith/tests/lib/pm-window.sh +143 -0
- package/skills/teamsmith/tests/lib/reply-fixture.sh +7 -19
- package/skills/teamsmith/tests/lib/reply-guard.sh +188 -0
- package/skills/teamsmith/tests/lib/section-calls.pl +171 -0
- package/skills/teamsmith/tests/loop-inventory.tsv +7 -5
- package/skills/teamsmith/tests/meta-suite.sh +215 -0
- package/skills/teamsmith/tests/panel-b3-pty-mouse.py +154 -17
- package/skills/teamsmith/tests/panel-b3.sh +33 -4
- package/skills/teamsmith/tests/remind-cli.sh +574 -0
- package/skills/teamsmith/tests/reply-capture-real.mjs +360 -0
- package/skills/teamsmith/tests/reply-capture-real.sh +5 -0
- package/skills/teamsmith/tests/reply-capture.mjs +756 -0
- package/skills/teamsmith/tests/section-paths.tsv +40 -9
- package/skills/teamsmith/tests/section-select.sh +180 -26
- package/skills/teamsmith/tests/smoke.sh +1235 -238
- package/skills/teamsmith/tests/state-authority-node.mjs +42 -0
- package/skills/teamsmith/tests/state-authority.sh +629 -0
- package/skills/teamsmith/tests/workflow-entry.sh +123 -3
- package/skills/teamsmith-init/SKILL.md +1 -1
|
@@ -41,17 +41,47 @@ for g in "${KR_SEL[@]}"; do
|
|
|
41
41
|
done
|
|
42
42
|
trap reply_fixture_cleanup EXIT
|
|
43
43
|
|
|
44
|
-
# 直驱 pty
|
|
44
|
+
# 直驱 pty 的最后一个完整同步帧 → 可见文本;空流、缺帧和末尾残帧不能证明「不存在」。
|
|
45
45
|
kr_chunk_text() { # <dump>
|
|
46
46
|
python3 - "$1" <<'PYF'
|
|
47
47
|
import re, sys
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
try:
|
|
49
|
+
raw = open(sys.argv[1], 'rb').read()
|
|
50
|
+
except OSError as exc:
|
|
51
|
+
sys.exit(f'cannot read pty output: {exc}')
|
|
52
|
+
start_mark, end_mark = b'\x1b[?2026h', b'\x1b[?2026l'
|
|
53
|
+
end = raw.rfind(end_mark)
|
|
54
|
+
start = raw.rfind(start_mark, 0, end) if end >= 0 else -1
|
|
55
|
+
if start < 0 or raw.rfind(start_mark) > end:
|
|
56
|
+
sys.exit('pty output has no complete final frame')
|
|
57
|
+
tail = raw[end + len(end_mark):]
|
|
58
|
+
if any(tail.endswith(start_mark[:n]) for n in range(1, len(start_mark))):
|
|
59
|
+
sys.exit('pty output ends in a partial frame marker')
|
|
60
|
+
try:
|
|
61
|
+
frame = raw[start + len(start_mark):end].decode('utf-8')
|
|
62
|
+
except UnicodeDecodeError as exc:
|
|
63
|
+
sys.exit(f'pty frame is not complete UTF-8: {exc}')
|
|
64
|
+
clean = re.sub(r'\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)', '', frame)
|
|
50
65
|
clean = re.sub(r'\x1b\[[0-9;?]*[a-zA-Z]', '', clean)
|
|
66
|
+
if not clean.strip():
|
|
67
|
+
sys.exit('pty final frame is empty')
|
|
51
68
|
sys.stdout.write(clean)
|
|
52
69
|
PYF
|
|
53
70
|
}
|
|
54
71
|
|
|
72
|
+
kr_wheel_chunk() { # <driver-rc> <raw> <text> <log> <label>
|
|
73
|
+
local rc="$1" raw="$2" text="$3" log="$4" label="$5"
|
|
74
|
+
if [ "$rc" != 0 ]; then
|
|
75
|
+
bad "$label:驱动失败(rc=$rc:$(tail -2 "$log" | tr '\n' ' '))"
|
|
76
|
+
return 1
|
|
77
|
+
fi
|
|
78
|
+
if ! kr_chunk_text "$raw" >"$text" 2>"$text.error"; then
|
|
79
|
+
bad "$label:输出缺失或残缺($(tr '\n' ' ' <"$text.error"))"
|
|
80
|
+
return 1
|
|
81
|
+
fi
|
|
82
|
+
ok "$label:驱动成功且最终帧完整"
|
|
83
|
+
}
|
|
84
|
+
|
|
55
85
|
# ---------------------------------------------------------------- 组:pages
|
|
56
86
|
kr_group_pages() {
|
|
57
87
|
section "pages · 第 5 页 / 重启 / 坏 store(3.1)"
|
|
@@ -195,6 +225,150 @@ PYB
|
|
|
195
225
|
ev_save "$tmp/$current/end.txt" "pty-body-end.txt"
|
|
196
226
|
}
|
|
197
227
|
|
|
228
|
+
# P383:真列表的缺失就绪标记 + 两个受控屏障失败。子进程的进度管道逐行转发给
|
|
229
|
+
# §63 的守卫,同时留副本检查轮数、期望和最后一帧;独立运行时也检查同一条管道。
|
|
230
|
+
kr_wait_accounting() {
|
|
231
|
+
local fake="$tmp/p383-stuck-overlay.py" checks="$tmp/p383-wait-checks.txt" rc line result message
|
|
232
|
+
python3 - "$fake" <<'PYFAKE'
|
|
233
|
+
import sys
|
|
234
|
+
from pathlib import Path
|
|
235
|
+
Path(sys.argv[1]).write_text('''import os, select, sys, tty
|
|
236
|
+
start, end = b"\\x1b[?2026h", b"\\x1b[?2026l"
|
|
237
|
+
tty.setraw(0)
|
|
238
|
+
def frame(text):
|
|
239
|
+
os.write(1, start + ("teamsmith pulse\\r\\n" + text + "\\r\\n").encode() + end)
|
|
240
|
+
frame("#38 鼠标 38 号")
|
|
241
|
+
os.write(1, b"\\x1b[?1006h")
|
|
242
|
+
opened = False
|
|
243
|
+
while True:
|
|
244
|
+
ready, _, _ = select.select([0], [], [], 0.3)
|
|
245
|
+
if ready:
|
|
246
|
+
data = os.read(0, 4096)
|
|
247
|
+
if not data:
|
|
248
|
+
break
|
|
249
|
+
if b"," in data and os.environ["P383_FAKE_MODE"] == "close":
|
|
250
|
+
opened = True
|
|
251
|
+
frame("语言" if opened else "#38 鼠标 38 号")
|
|
252
|
+
''')
|
|
253
|
+
PYFAKE
|
|
254
|
+
python3 - "$SELF_DIR/panel-b3-pty-mouse.py" "$js" "$panel" "$ROOT" "$state" "$team_cli" "$tmp" "$fake" >"$checks" 2>"$tmp/p383-wait-checks.error" <<'PYCHECK'
|
|
255
|
+
import contextlib
|
|
256
|
+
import importlib.util
|
|
257
|
+
import io
|
|
258
|
+
import os
|
|
259
|
+
import re
|
|
260
|
+
import subprocess
|
|
261
|
+
import sys
|
|
262
|
+
import time
|
|
263
|
+
from pathlib import Path
|
|
264
|
+
|
|
265
|
+
driver, js, panel, root, state, cli, tmp, fake = sys.argv[1:]
|
|
266
|
+
tmp = Path(tmp)
|
|
267
|
+
parent_fd = os.environ.get("TEAM_PTY_PROGRESS_FD")
|
|
268
|
+
failures = 0
|
|
269
|
+
|
|
270
|
+
def check(name, condition, detail=""):
|
|
271
|
+
global failures
|
|
272
|
+
print(("PASS " if condition else "FAIL ") + name + (" — " + detail if detail else ""), flush=True)
|
|
273
|
+
failures += not condition
|
|
274
|
+
|
|
275
|
+
def relay(line):
|
|
276
|
+
if parent_fd is not None:
|
|
277
|
+
os.write(int(parent_fd), line.encode())
|
|
278
|
+
|
|
279
|
+
def probe(name, real, mode, ready, barrier, wait):
|
|
280
|
+
rfd, wfd = os.pipe()
|
|
281
|
+
env = dict(os.environ, TEAM_PTY_PROGRESS_FD=str(wfd), P383_FAKE_MODE=mode)
|
|
282
|
+
raw = tmp / f"p383-{name}.bin"
|
|
283
|
+
log = tmp / f"p383-{name}.log"
|
|
284
|
+
cmd = [sys.executable, driver, "--js", js if real else sys.executable,
|
|
285
|
+
"--panel", panel if real else fake, "--root", root, "--state-dir", state,
|
|
286
|
+
"--team-cli", cli, "--out", str(raw), "--no-click", "--wheel", "down",
|
|
287
|
+
"--wheel-clicks", "1", "--wheel-ready", ready, "--wheel-barrier", barrier,
|
|
288
|
+
"--wait", str(wait)]
|
|
289
|
+
if real:
|
|
290
|
+
cmd += ["--send", "5"]
|
|
291
|
+
with log.open("wb") as err:
|
|
292
|
+
proc = subprocess.Popen(cmd, stdout=err, stderr=err, env=env, pass_fds=(wfd,))
|
|
293
|
+
os.close(wfd)
|
|
294
|
+
lines = []
|
|
295
|
+
with os.fdopen(rfd, encoding="utf-8") as progress:
|
|
296
|
+
for line in progress:
|
|
297
|
+
lines.append(line)
|
|
298
|
+
relay(line)
|
|
299
|
+
rc = proc.wait()
|
|
300
|
+
(tmp / f"p383-{name}.progress").write_text("".join(lines))
|
|
301
|
+
return rc, raw.read_bytes(), log.read_text(), lines
|
|
302
|
+
|
|
303
|
+
sys.dont_write_bytecode = True # the gate must not write __pycache__ into its checkout
|
|
304
|
+
spec = importlib.util.spec_from_file_location("p383_mouse", driver)
|
|
305
|
+
mouse = importlib.util.module_from_spec(spec)
|
|
306
|
+
spec.loader.exec_module(mouse)
|
|
307
|
+
cases = [
|
|
308
|
+
("ready", True, "ready", "NEVER-P383-READY", "语言", 25, "wheel-ready", "#38 鼠标 38 号"),
|
|
309
|
+
("open", False, "open", "#38 鼠标 38 号", "语言", 4, "wheel-barrier-open", "#38 鼠标 38 号"),
|
|
310
|
+
("close", False, "close", "#38 鼠标 38 号", "语言", 4, "wheel-barrier-close", "语言"),
|
|
311
|
+
]
|
|
312
|
+
for name, real, mode, ready, barrier, wait, target, last_marker in cases:
|
|
313
|
+
rc, raw, log, lines = probe(name, real, mode, ready, barrier, wait)
|
|
314
|
+
target_lines = [line for line in lines if f"wait={target} " in line]
|
|
315
|
+
rounds = [re.search(r"round=(\d+)/(\d+)", line) for line in target_lines]
|
|
316
|
+
counted = (len(rounds) >= 2 and all(rounds) and
|
|
317
|
+
[int(m.group(1)) for m in rounds] == list(range(1, len(rounds) + 1)) and
|
|
318
|
+
len({int(m.group(2)) for m in rounds}) == 1)
|
|
319
|
+
check(f"P383 {target} 每轮进度递增", counted, f"rounds={len(rounds)}")
|
|
320
|
+
final = rounds[-1] if rounds and rounds[-1] else None
|
|
321
|
+
attribution = (final is not None and f"wait={target} {final.group(1)}/{final.group(2)} expected=" in log
|
|
322
|
+
and "last=" in log and last_marker in log.split("panel-b3-pty-mouse:")[-1])
|
|
323
|
+
check(f"P383 {target} 失败点名期望和最后帧", rc == 2 and attribution, f"rc={rc}")
|
|
324
|
+
if name == "ready":
|
|
325
|
+
check("P383 不存在的就绪标记不能掩盖真列表 #38",
|
|
326
|
+
b"#38 \xe9\xbc\xa0\xe6\xa0\x87 38 \xe5\x8f\xb7" in mouse.last_complete_frame(raw)
|
|
327
|
+
and ready.encode() not in mouse.last_complete_frame(raw))
|
|
328
|
+
|
|
329
|
+
# Exercise the count cap independently of the wall-clock deadline.
|
|
330
|
+
class Alive:
|
|
331
|
+
def __init__(self):
|
|
332
|
+
self.polls = 0
|
|
333
|
+
def poll(self):
|
|
334
|
+
self.polls += 1
|
|
335
|
+
# If the counter is broken, let the mutated unit return instead of filling the pipe.
|
|
336
|
+
return 0 if self.polls > 4 else None
|
|
337
|
+
rfd, wfd = os.pipe()
|
|
338
|
+
old_fd = os.environ.get("TEAM_PTY_PROGRESS_FD")
|
|
339
|
+
os.environ["TEAM_PTY_PROGRESS_FD"] = str(wfd)
|
|
340
|
+
old_drain = mouse.drain
|
|
341
|
+
mouse.drain = lambda *args, **kwargs: b""
|
|
342
|
+
frame = mouse.FRAME_START + b"observed #38" + mouse.FRAME_END
|
|
343
|
+
with contextlib.redirect_stderr(io.StringIO()):
|
|
344
|
+
_, error = mouse.wait_frame(0, Alive(), time.monotonic() + 60, "cap-probe",
|
|
345
|
+
"never arrives", frame, lambda _: False, cap=3)
|
|
346
|
+
mouse.drain = old_drain
|
|
347
|
+
os.close(wfd)
|
|
348
|
+
with os.fdopen(rfd, encoding="utf-8") as progress:
|
|
349
|
+
cap_lines = list(progress)
|
|
350
|
+
for line in cap_lines:
|
|
351
|
+
relay(line)
|
|
352
|
+
if old_fd is None:
|
|
353
|
+
del os.environ["TEAM_PTY_PROGRESS_FD"]
|
|
354
|
+
else:
|
|
355
|
+
os.environ["TEAM_PTY_PROGRESS_FD"] = old_fd
|
|
356
|
+
check("P383 轮数上限 3/3 归因最后读数",
|
|
357
|
+
len(cap_lines) == 3 and [re.search(r"round=(\d+)/3", s).group(1) for s in cap_lines] == ["1", "2", "3"]
|
|
358
|
+
and error is not None and "wait=cap-probe 3/3 expected=never arrives" in error
|
|
359
|
+
and "observed #38" in error and "process_status=None" in error)
|
|
360
|
+
sys.exit(1 if failures else 0)
|
|
361
|
+
PYCHECK
|
|
362
|
+
rc=$?
|
|
363
|
+
while IFS= read -r line; do
|
|
364
|
+
result="${line%% *}"; message="${line#* }"
|
|
365
|
+
case "$result" in PASS) ok "$message" ;; FAIL) bad "$message" ;; *) bad "P383 等待检查输出无效:$line" ;; esac
|
|
366
|
+
done <"$checks"
|
|
367
|
+
if [ "$rc" -ne 0 ] && ! grep -q '^FAIL ' "$checks"; then
|
|
368
|
+
bad "P383 等待检查异常退出(rc=$rc:$(tail -3 "$tmp/p383-wait-checks.error" | tr '\n' ' '))"
|
|
369
|
+
fi
|
|
370
|
+
}
|
|
371
|
+
|
|
198
372
|
# ---------------------------------------------------------------- 组:mouse
|
|
199
373
|
kr_group_mouse() {
|
|
200
374
|
section "mouse · 真实 SGR 鼠标(3.2)"
|
|
@@ -224,30 +398,32 @@ kr_group_mouse() {
|
|
|
224
398
|
rc=$?
|
|
225
399
|
if [ "$rc" = "0" ]; then ok "mouse:Back 芯片点击注入成功"; else bad "mouse:Back 点击失败(rc=$rc:$(tail -2 "$tmp/m-back.log" | tr '\n' ' '))"; fi
|
|
226
400
|
want_frame m_back "mouse:Back 回到列表(同一页与焦点)" "› #38 鼠标 38 号"
|
|
227
|
-
# 滚轮:tmux 会吃掉滚轮事件(既有测量),所以滚轮走直驱 pty
|
|
228
|
-
#
|
|
229
|
-
# ② 滚 40 格 → 到底被夹住:最旧的 #1 进入窗口、最新号不再重绘(越界不换页、不空帧)
|
|
401
|
+
# 滚轮:tmux 会吃掉滚轮事件(既有测量),所以滚轮走直驱 pty。先等 #38 的完整列表帧,
|
|
402
|
+
# 再分别检查下滚 3 格和 40 格后的最后完整帧;驱动失败或没有完整帧时不能判缺席为通过。
|
|
230
403
|
python3 "$SELF_DIR/panel-b3-pty-mouse.py" --js "$js" --panel "$panel" --root "$ROOT" --state-dir "$state" \
|
|
231
404
|
--team-cli "$team_cli" --out "$tmp/m-wheel.bin" --out2 "$tmp/m-wheel-after.bin" --no-click \
|
|
232
|
-
--send "5" --wheel down --wheel-clicks 3 --expect-enable yes >"$tmp/m-wheel.log" 2>&1
|
|
233
|
-
|
|
234
|
-
if
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
405
|
+
--send "5" --wheel-ready "#38 鼠标 38 号" --wheel-barrier "语言" --wheel down --wheel-clicks 3 --expect-enable yes >"$tmp/m-wheel.log" 2>&1
|
|
406
|
+
rc=$?
|
|
407
|
+
if kr_wheel_chunk "$rc" "$tmp/m-wheel-after.bin" "$tmp/m-wheel-chunk.txt" "$tmp/m-wheel.log" "mouse:下滚 3 格"; then
|
|
408
|
+
assert_not "$tmp/m-wheel-chunk.txt" "#38 鼠标 38 号" "mouse:下滚 3 格后最新行不再重绘(顶部让位)"
|
|
409
|
+
local chunk_max
|
|
410
|
+
chunk_max="$(grep -oE '#[0-9]+ ' "$tmp/m-wheel-chunk.txt" | tr -dc '0-9\n' | sort -n | tail -1)"
|
|
411
|
+
if [ -n "$chunk_max" ] && [ "$chunk_max" -lt 38 ]; then
|
|
412
|
+
ok "mouse:下滚 3 格后帧里的最大编号是 #$chunk_max(< 最新号 38)"
|
|
413
|
+
else
|
|
414
|
+
bad "mouse:下滚 3 格后帧里没有更旧的行(最大 #${chunk_max:-?})"
|
|
415
|
+
fi
|
|
243
416
|
fi
|
|
244
417
|
python3 "$SELF_DIR/panel-b3-pty-mouse.py" --js "$js" --panel "$panel" --root "$ROOT" --state-dir "$state" \
|
|
245
418
|
--team-cli "$team_cli" --out "$tmp/m-end.bin" --out2 "$tmp/m-end-after.bin" --no-click \
|
|
246
|
-
--send "5" --wheel down --wheel-clicks 40 >"$tmp/m-end.log" 2>&1
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
419
|
+
--send "5" --wheel-ready "#38 鼠标 38 号" --wheel-barrier "语言" --wheel down --wheel-clicks 40 >"$tmp/m-end.log" 2>&1
|
|
420
|
+
rc=$?
|
|
421
|
+
if kr_wheel_chunk "$rc" "$tmp/m-end-after.bin" "$tmp/m-end-chunk.txt" "$tmp/m-end.log" "mouse:下滚 40 格"; then
|
|
422
|
+
assert_has "$tmp/m-end-chunk.txt" "#1 鼠标一号" "mouse:滚 40 格到底被夹住(最旧的 #1 进入窗口,不换页)"
|
|
423
|
+
assert_not "$tmp/m-end-chunk.txt" "#38 鼠标 38 号" "mouse:到底后最新号不再在窗口里"
|
|
424
|
+
fi
|
|
250
425
|
assert_eq "mouse:滚轮之后 tmux 里那块面板仍活着" "$(pty_pane_state | cut -d: -f1)" "0"
|
|
426
|
+
kr_wait_accounting
|
|
251
427
|
ev_save "$tmp/$current/m_open.txt" "pty-mouse-open.txt"
|
|
252
428
|
}
|
|
253
429
|
|