fix: install/update 雙語化(預設英文) + 修 macOS bash 3.2 安裝崩潰 + bump 1.7.0

- 修崩潰:bash 3.2 + set -u 展開空陣列會炸 unbound variable;移除多餘
  ${SKIPPED[*]} no-op;多位元組字串旁變數改用 ${VAR} 防 curl|bash 串流切斷
- install/update 訊息依 locale 雙語,預設英文(curl|bash 常 LANG=C),zh_TW 切繁中
- 寫進 CLAUDE.md 的 raw source 宣告依 locale 只寫一種語言(不撐爆 context)
- 修措辭:一般開發案不再顯示誤導的「偵測到 vault 類型:docs」
- 新增 README.en.md(繁中↔English 切換)
- gitignore dogfooding 自裝產物(CLAUDE.md/docs 子目錄/.claude/settings*)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-26 12:40:28 +08:00
parent bc0fe3f01c
commit e9d6d78032
7 changed files with 460 additions and 72 deletions
+39 -20
View File
@@ -15,6 +15,14 @@
set -euo pipefail
# ── i18n:依 locale 選語言,預設英文(curl | bash 常為 LANG=C)──
case "${LC_ALL:-${LC_MESSAGES:-${LANG:-}}}" in
zh*|*Hant*|*Hans*) IS_ZH="yes" ;;
*) IS_ZH="no" ;;
esac
t() { if [ "$IS_ZH" = "yes" ]; then printf '%s\n' "$1"; else printf '%s\n' "$2"; fi; }
tn() { if [ "$IS_ZH" = "yes" ]; then printf '%s' "$1"; else printf '%s' "$2"; fi; }
REPO_RAW="https://raw.githubusercontent.com/uncle6me-web/system-dev-template/main"
TEMPLATE_URL="$REPO_RAW/template"
@@ -24,25 +32,29 @@ NEW=()
TEMPLATED=()
# ── 版本比對:先看本機 vs 遠端,給使用者「值不值得更新」的判斷 ──
LOCAL_VER="(未知)"
LOCAL_VER="$(tn '(未知)' '(unknown)')"
[ -f ".claude/VERSION" ] && LOCAL_VER="$(tr -d '[:space:]' < .claude/VERSION)"
REMOTE_VER="$(curl -sSL "$TEMPLATE_URL/.claude/VERSION" 2>/dev/null | tr -d '[:space:]' || echo '')"
echo ""
echo "🔄 system-dev-template updater"
echo "================================="
echo " 本機版本:${LOCAL_VER:-未知}"
echo " 最新版本:${REMOTE_VER:-取不到(檢查網路)}"
t " 本機版本:${LOCAL_VER}" " Local version: ${LOCAL_VER}"
t " 最新版本:${REMOTE_VER:-取不到(檢查網路)}" \
" Latest version: ${REMOTE_VER:-unavailable (check network)}"
echo ""
if [ -z "$REMOTE_VER" ]; then
echo "❌ 取不到遠端版本,可能是網路問題。請稍後再試。"
t "❌ 取不到遠端版本,可能是網路問題。請稍後再試。" \
"❌ Could not fetch the remote version (likely a network issue). Please try again later."
exit 1
fi
if [ "$LOCAL_VER" = "$REMOTE_VER" ]; then
echo "✅ 已是最新版($LOCAL_VER),不需更新。"
echo " (仍會同步模板邏輯檔,確保 hooks/commands 與最新一致。)"
t "✅ 已是最新版($LOCAL_VER),不需更新。" \
"✅ Already up to date ($LOCAL_VER), nothing to update."
t " (仍會同步模板邏輯檔,確保 hooks/commands 與最新一致。)" \
" (Template logic files will still be synced to keep hooks/commands in line with the latest.)"
echo ""
fi
@@ -61,14 +73,14 @@ update_file() {
fi
else
rm -f "$dest.tmp"
echo " ⚠️ 抓取失敗,保留原檔:$dest"
t " ⚠️ 抓取失敗,保留原檔:$dest" " ⚠️ Download failed, keeping the original: $dest"
fi
else
if curl -sSL "$src" -o "$dest" 2>/dev/null && [ -s "$dest" ]; then
NEW+=("$dest") # 新功能:舊版沒有的檔
else
rm -f "$dest"
echo " ⚠️ 抓取失敗:$dest"
t " ⚠️ 抓取失敗:$dest" " ⚠️ Download failed: $dest"
fi
fi
}
@@ -107,10 +119,12 @@ HAS_SDD=false
[ -d ".claude/wiki" ] && HAS_WIKI=true
if [ -f ".claude/hooks/sdd-guard.sh" ] || [ -d "docs/3-specs/TEMPLATE-sdd" ]; then HAS_SDD=true; fi
echo "📦 偵測到已安裝模組:"
t "📦 偵測到已安裝模組:" "📦 Detected installed modules:"
$HAS_WIKI && echo " • LLM Wiki"
$HAS_SDD && echo " • SDD"
{ $HAS_WIKI || $HAS_SDD; } || echo " (未偵測到任何模組——這裡可能還沒安裝,請改跑 install.sh"
{ $HAS_WIKI || $HAS_SDD; } || \
t " (未偵測到任何模組——這裡可能還沒安裝,請改跑 install.sh" \
" (No modules detected — nothing installed here yet; run install.sh instead.)"
echo ""
# ── 客製檔:使用者手填的 guardrail,永不覆蓋(issue #3)──
@@ -167,29 +181,33 @@ echo ""
echo "─────────────────────────────────"
if [ ${#NEW[@]} -gt 0 ]; then
echo ""
echo "🆕 新功能(舊版沒有,已加入):"
t "🆕 新功能(舊版沒有,已加入):" "🆕 New features (absent in the old version, now added):"
for f in "${NEW[@]}"; do echo " + $f"; done
fi
if [ ${#UPDATED[@]} -gt 0 ]; then
echo ""
echo "⬆️ 已更新(覆蓋成新版):"
t "⬆️ 已更新(覆蓋成新版):" "⬆️ Updated (overwritten with the new version):"
for f in "${UPDATED[@]}"; do echo " ~ $f"; done
fi
if [ ${#NEW[@]} -eq 0 ] && [ ${#UPDATED[@]} -eq 0 ]; then
echo ""
echo "✨ 模板邏輯檔已全部最新,無需變動。"
t "✨ 模板邏輯檔已全部最新,無需變動。" \
"✨ All template logic files are already up to date — no changes needed."
fi
if [ ${#KEPT[@]} -gt 0 ]; then
echo ""
echo "🔒 完整保留(你的內容/設定,從未碰過):"
t "🔒 完整保留(你的內容/設定,從未碰過):" \
"🔒 Fully preserved (your content/settings, never touched):"
for f in "${KEPT[@]}"; do echo " = $f"; done
fi
if [ ${#TEMPLATED[@]} -gt 0 ]; then
echo ""
echo "📋 客製檔有新版範本(你的原檔沒動,新版另存旁邊,請自行 diff 採納):"
t "📋 客製檔有新版範本(你的原檔沒動,新版另存旁邊,請自行 diff 採納):" \
"📋 Custom files have a new template version (your original is untouched; the new one is saved alongside — diff and adopt as you like):"
for f in "${TEMPLATED[@]}"; do
echo "$f"
echo " 比對:diff \"${f%.template.sh}.sh\" \"$f\""
t " 比對:diff \"${f%.template.sh}.sh\" \"$f\"" \
" compare: diff \"${f%.template.sh}.sh\" \"$f\""
done
fi
@@ -201,13 +219,14 @@ if [ -f ".claude/settings.json" ]; then
$HAS_SDD && ! grep -q "sdd-guard.sh" .claude/settings.json && MISSING+=("PreToolUse(Write|Edit): sdd-guard.sh")
if [ ${#MISSING[@]} -gt 0 ]; then
echo ""
echo "📌 settings.json 是你的設定(沒動),但偵測到缺以下 hook,請手動補上:"
t "📌 settings.json 是你的設定(沒動),但偵測到缺以下 hook,請手動補上:" \
"📌 settings.json is yours (untouched), but these hooks are missing — please add them manually:"
for h in "${MISSING[@]}"; do echo "$h"; done
fi
fi
echo ""
echo "🚀 更新完成:${LOCAL_VER}${REMOTE_VER}"
echo " 下次更新直接跑:bash scripts/update.sh"
echo " 改了什麼看:CHANGELOG.md"
t "🚀 更新完成:${LOCAL_VER}${REMOTE_VER}" "🚀 Update complete: ${LOCAL_VER}${REMOTE_VER}"
t " 下次更新直接跑:bash scripts/update.sh" " Next time, just run: bash scripts/update.sh"
t " 改了什麼看:CHANGELOG.md" " See what changed: CHANGELOG.md"
echo ""