身為總管,我要雲端 setup 失敗時大聲喊出來,我才不會又交出一個零閘的環境 #44
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "isep",
|
||||
"description": "InkStone Environment Plugin —— leo 的 Claude Code 環境唯一真相源:43 支機械閘(53 條註冊,白話盤點見 docs/hooks-inventory.md)、7 支 slash command、2 支 skill、27 支腳本,外加治理規範與標籤真相源。本機與雲端裝同一份,沒有子集。",
|
||||
"version": "0.0.0",
|
||||
"version": "0.3.0",
|
||||
"keywords": [
|
||||
"inkstone",
|
||||
"guardrails",
|
||||
|
||||
@@ -27,12 +27,46 @@ if [ -z "${GITEA_TOKEN_CLAUDE_CODE:-}" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 官方文件建議的私有 marketplace 認證寫法:只重寫這個 host 的 URL,不動其他 git 操作。
|
||||
git config --global url."https://x-access-token:${GITEA_TOKEN_CLAUDE_CODE}@git.uncle6.me/".insteadOf \
|
||||
# ── git 認證:三個機制都設,因為它們失效的方式不同 ────────────────
|
||||
# ① URL 重寫(global) ② 憑證存檔(global) ③ 系統層(HOME 無關,best effort)
|
||||
# 2026-08-20 雲端實測:session 裡 git 是「匿名」的 ⇒ setup 設的東西沒生效到 session。
|
||||
# 原因未定(沒跑到/HOME 不同/快照沒帶),所以三條都設,並在下面自我驗證。
|
||||
git config --global url."https://claude-code:${GITEA_TOKEN_CLAUDE_CODE}@git.uncle6.me/".insteadOf \
|
||||
"https://git.uncle6.me/"
|
||||
git config --global credential.helper store
|
||||
printf 'https://claude-code:%s@git.uncle6.me\n' "$GITEA_TOKEN_CLAUDE_CODE" > "$HOME/.git-credentials"
|
||||
chmod 600 "$HOME/.git-credentials"
|
||||
git config --system url."https://claude-code:${GITEA_TOKEN_CLAUDE_CODE}@git.uncle6.me/".insteadOf \
|
||||
"https://git.uncle6.me/" 2>/dev/null || echo "(system 層設不了,只靠 global——非致命)"
|
||||
|
||||
# 用乾淨網址(不帶 token)加 marketplace,實際認證交給上面那條 URL 重寫。
|
||||
claude plugin marketplace add https://git.uncle6.me/inkstone/ISEP.git --scope user
|
||||
claude plugin install isep@inkstone --scope user
|
||||
# ── 🔴 自我驗證一:認證真的通了嗎 ──────────────────────────
|
||||
# 這一步是 2026-08-20 事故的直接產物:舊版設完就結束,token 沒生效也不出聲,
|
||||
# 於是雲端 session 開起來才發現 marketplace 拉不下來,而 setup log 一片綠。
|
||||
echo "── 驗證 git 認證 ──"
|
||||
if GIT_TERMINAL_PROMPT=0 git ls-remote https://git.uncle6.me/inkstone/ISEP.git >/dev/null 2>&1; then
|
||||
echo "✅ git 認證通:拉得到 inkstone/ISEP"
|
||||
else
|
||||
echo "❌ git 認證不通——marketplace 一定裝不起來,後面不用往下做了。" >&2
|
||||
echo " 檢查:GITEA_TOKEN_CLAUDE_CODE 的值對不對、那把 token 有沒有被撤銷。" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ ISEP 已裝成 user-scope plugin,之後每個 session 啟動時直接生效。"
|
||||
# ── 安裝(user scope 只是備援)─────────────────────────────
|
||||
# 🔴 官方文件(cloud-environments 的 what-carries-over 表)明文:
|
||||
# 「Plugins enabled only in your user settings」→ **不會**帶到雲端 session。
|
||||
# 真正生效的是薄殼 repo 的 .claude/settings.json 裡的 enabledPlugins + extraKnownMarketplaces。
|
||||
# 這兩行留著當本地備援,不是主要路徑——不要以為裝完就等於雲端有了。
|
||||
claude plugin marketplace add https://git.uncle6.me/inkstone/ISEP.git --scope user 2>/dev/null || true
|
||||
claude plugin install isep@inkstone --scope user 2>/dev/null || true
|
||||
|
||||
# ── 🔴 自我驗證二:marketplace 真的拉下來了嗎 ────────────────
|
||||
echo "── 驗證 marketplace ──"
|
||||
if claude plugin marketplace list 2>/dev/null | grep -q "inkstone"; then
|
||||
echo "✅ marketplace inkstone 已就位"
|
||||
else
|
||||
echo "❌ marketplace 沒就位——session 啟動時 enabledPlugins 會是一張跳票的支票。" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ setup 完成。session 啟動後請用「有鑑別力的探針」驗閘,"
|
||||
echo " 不要用 git tag(它在三支閘的白名單裡,閘死了也會過)。"
|
||||
|
||||
@@ -178,6 +178,10 @@
|
||||
{
|
||||
"type": "command",
|
||||
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/skill-deploy-drift-guard.sh"
|
||||
},
|
||||
{
|
||||
"type": "command",
|
||||
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/isep-presence-beacon.sh"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
# isep-presence-beacon.sh — SessionStart:報出「ISEP 真的載入了,幾版、幾支閘」
|
||||
#
|
||||
# 這不是閘,是**信標**。存在的理由是 2026-08-20 的雲端事故:
|
||||
# 雲端 session 的閘全滅,而三個驗證步驟全部回綠——因為它們沒有鑑別力
|
||||
# (`git tag` 在三支閘的白名單裡;`Skills(9)/Hooks(5)` 剛好是薄殼自己的 .claude/ 產生的數字)。
|
||||
#
|
||||
# 🔴 鑑別力就是這支的全部意義:
|
||||
# 這行出現 ⇒ plugin 一定載入了(因為它自己就住在 plugin 裡)
|
||||
# 這行不見 ⇒ plugin 沒載入,那個 session 是零閘狀態
|
||||
# ——沒有第三種情況,也沒有「剛好也會過」的巧合。
|
||||
set -uo pipefail
|
||||
|
||||
ROOT="${CLAUDE_PLUGIN_ROOT:-}"
|
||||
[ -n "$ROOT" ] || exit 0
|
||||
|
||||
VER="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' \
|
||||
"$ROOT/.claude-plugin/plugin.json" 2>/dev/null | head -1)"
|
||||
VER="${VER:-未知}"
|
||||
GATES="$(ls "$ROOT"/hooks/*.sh 2>/dev/null | wc -l | tr -d ' ')"
|
||||
|
||||
MSG="🟢 ISEP v${VER} 已載入(${GATES} 支閘在 ${ROOT})"
|
||||
|
||||
printf '%s\n' "{
|
||||
\"systemMessage\": \"${MSG}\",
|
||||
\"hookSpecificOutput\": {
|
||||
\"hookEventName\": \"SessionStart\",
|
||||
\"additionalContext\": \"${MSG}。這行是 ISEP plugin 自己發的——看得到它就表示閘真的生效了。若某個 session 從頭到尾沒有這行,那個 session 是零閘狀態,先修 plugin 再做事,不要用『跑得動』當證據。\"
|
||||
}
|
||||
}"
|
||||
Reference in New Issue
Block a user