chore: 规范标点

This commit is contained in:
pluv committed 2026-10-03 14:56:56 +08:00
1 parent 15e79887fa
commit 3dd2231c70
81 files changed
+1751 -1751

No files matched your search

+7 -7
View File
@@ -3,13 +3,13 @@
交互式 shell 的原始输出里混着转义序列、重绘空格和全屏程序的整屏画面.
不清洗的话模型看到的就是几百个空格加一串光标定位; 清过头又会把命令和
状态行一起吃掉. 这里用 printf 造出确定的输入来钉住行为:
状态行一起吃掉. 这里用 printf 造出确定的输入来钉住行为:
1. 备用屏幕 (vim/less/top 走这条路)——画面必须省略, 只留首尾标记;
2. 成片空格 (nano/top 靠空格重绘)——必须压掉, 但短缩进要原样保留;
3. 大输出里夹着的备用屏幕——跨 read 也要能认出来.
用法:
用法:
shell_screen_check.py <ligent 二进制> <mock base-url>
"""
import glob
@@ -38,7 +38,7 @@ def drive(binary, base, commands, wait=1.6, term="xterm-256color"):
else:
os.environ["TERM"] = term
# 每轮都清空归档:归档名是随机的, 按文件名排序取"最后一个"会拿到上一轮.
# 每轮都清空归档: 归档名是随机的, 按文件名排序取"最后一个"会拿到上一轮.
bindir = os.path.dirname(os.path.abspath(binary))
shutil.rmtree(os.path.join(bindir, "ligent.archive"), ignore_errors=True)
@@ -48,7 +48,7 @@ def drive(binary, base, commands, wait=1.6, term="xterm-256color"):
os._exit(127)
# 行编辑器每次回到提示符都会打开括号粘贴 —— 用它当"轮到输入了"的信号.
# 只按"输出安静"等是不行的:等待动画每 250ms 画一帧, pty 永远不会安静
# 只按"输出安静"等是不行的: 等待动画每 250ms 画一帧, pty 永远不会安静
# 超过 idle, 于是每次都要白等满整个额度.
PROMPT_READY = b"\x1b[?2004h"
ready_seen = 0
@@ -135,7 +135,7 @@ def main():
fails += 1
print(" ✗ %s%s" % (name, (" " + detail) if detail else ""))
# ---- 1. 备用屏幕:画面省略, 只留首尾标记 ----
# ---- 1. 备用屏幕: 画面省略, 只留首尾标记 ----
print("备用屏幕 (vim/less 路径)")
rec = drive(binary, base, [
r"printf '\033[?1049h" + ALT_TEXT + r"\033[?1049l'",
@@ -154,7 +154,7 @@ def main():
check("标记之外的输出还在", NORMAL_TEXT in rec)
check("记录里没有裸转义符", "\x1b" not in rec)
# ---- 2. 成片空格:压掉, 但缩进保留 ----
# ---- 2. 成片空格: 压掉, 但缩进保留 ----
print("成片空格 (nano/top 重绘路径)")
rec = drive(binary, base, [
r"printf 'A'; printf '%0.s ' $(seq 1 200); printf 'B\n'",
@@ -210,7 +210,7 @@ def main():
check("拿到记录", False, "没有生成归档")
continue
check("%s 时补上可用 TERM" % label, "TERM_IS=xterm-256color" in rec,
"实际记录:%s" % rec.strip().replace("\n", " | ")[-80:])
"实际记录: %s" % rec.strip().replace("\n", " | ")[-80:])
shutil.rmtree(archive, ignore_errors=True)
print("\n%d 项检查, %d 项失败" % (total, fails))