feat(meta): 新增 tools/ste100-lint.sh 語言機檢工具並補列參考表

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-21 14:18:42 +08:00
co-authored by Claude Fable 5
parent 9e9db57f7a
commit f1f7e6163a
3 changed files with 36 additions and 2 deletions
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env sh
# ste100-lint.sh — 檢查檔案是否違反 STE100 擬人台灣感規則(可機檢的部分)。
# 用法: ste100-lint.sh <file|dir> [...]
# 檢查項目:
# 1. 中國用語(references/ste100.md 的替換表左欄)
# 2. 中文句內的半形標點(, ; ! ? 緊鄰中日韓字元)
# 3. 常見 AI 套話(總的來說、綜上所述、希望這對你有幫助 等)
# 輸出: {檔案}:{行號}:{類別}:{命中內容};全部通過 exit 0,有命中 exit 1。
# 限制: 只掃 .md 檔;程式碼圍欄內的內容可能誤報,人工複核。
set -u
TERMS='默認|支持某|兼容|信息|數據庫|服務器|軟件|硬件|網絡|質量|卸載|反饋|視頻|屏幕|鼠標|打印|立馬|靠譜|賦能|閉環|抓手|復盤'
CLICHES='總的來說|綜上所述|希望這對你有幫助|好問題|在當今|瞬息萬變|標誌著|奠定了基礎|體現了|不僅僅是|讓我們一起'
hit=0
files() {
for p in "$@"; do
if [ -d "$p" ]; then find "$p" -name '*.md' -not -path '*/.git/*'; else echo "$p"; fi
done
}
check() { # $1=檔案 $2=類別 $3=grep 模式 $4=grep 旗標
out=$(grep -n"$4" "$3" "$1" 2>/dev/null | sed "s|^|$1:|;s|:\([0-9]*\):|:\1:$2:|")
if [ -n "$out" ]; then printf '%s\n' "$out"; hit=1; fi
}
for f in $(files "$@"); do
check "$f" "中國用語" "$TERMS" E
check "$f" "半形標點" '[\x{4e00}-\x{9fff}][,;!?]|[,;][\x{4e00}-\x{9fff}]' P
check "$f" "AI 套話" "$CLICHES" E
done
exit $hit