Files
ISEP/docs/cloud-setup-script.sh
T
Leo 47ed778cc4 改走「直接複製進薄殼 repo」,並修掉一支會偷跑指令的閘
leo 2026-08-21:「你應該把 Plugin 直接裝進 Github repo,從本地直接複製就好了」

為什麼這條對:雲端 session 是 fresh clone 薄殼 repo,而 setup script 讀不到
環境變數。走 marketplace 就得同時處理憑證、repo 可見性、環境快取三件事——
今天這三件各失敗過一次。複製進 repo 之後,clone 下來就有,沒有任何前置條件。

新增 scripts/vendor-to-shell.py:
  把 hooks/skills/commands/scripts/.claude-plugin 整份複製到 .claude/isep/,
  並把 54 條 hook 註冊改寫成薄殼裡的絕對路徑。
  保留 CLAUDE_PLUGIN_ROOT 這個變數名(44 支閘內部靠它定位自己的 lib/),
  只是把它指到複製過來的那份。

冒煙測試(54 條註冊全跑一遍,找路徑壞掉的):
  第一輪 4 條壞 → 3 條是 log 目錄不存在(已補建 .claude/hooks/)
                  1 條在真身也一樣壞 ⇒ 不是複製造成的
  第二輪 0 條壞

順手修掉那支既有 bug:wiki-first-search.sh
  python3 -c 用雙引號,註解裡的反引號被 shell 當指令替換
  ⇒ 這支閘每次觸發都在偷跑 bge-m3 與 head changelog.md。
  改成全形引號後實測靜默 exit 0。
  (crude grep 掃出 6 支疑似,但冒煙測試證明只有這一支真的中——
    再一次:證據勝過掃描。)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 00:51:00 +08:00

39 lines
1.9 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 貼進 claude.ai → Cloud environments → 你的環境 → Setup script 欄位。
#
# 🔴 2026-08-21:這支腳本從「要 token」變成「不要 token」,因為查文件查出兩件事——
#
# ① **setup script 讀不到 Environment variables。**
# 官方原文:「Each session copies the environment's values once, **at startup**,
# into ordinary environment variables」,而 setup script 是
# 「**before Claude Code launches**」跑的 ⇒ 注入發生在它之後。
# ⇒ 舊版把 token 放進 Environment variables 再要這裡讀,永遠讀不到。
#
# ② **非零結束會讓整個 session 開不起來。**
# 官方原文:「**Exit zero**: if the script exits non-zero, the session fails to start.」
# ⇒ 這裡一律 exit 0。任何失敗只記錄,不擋門。
#
# 解法是拿掉憑證需求本身:`inkstone` org 與 `inkstone/ISEP` 都改成 Public
# ⇒ 匿名 clone 得到(2026-08-21 實測:匿名 git-upload-pack HTTP 200、
# 真隔離環境(無憑證、GIT_CONFIG_NOSYSTEM=1ls-remote 成功)
# ⇒ **雲端不再需要任何金鑰就能裝 ISEP。**
#
# 真正讓 plugin 生效的是薄殼 repo 的 .claude/settings.json
# extraKnownMarketplaces enabledPlugins)——官方文件:
# 「Installed at session start from the marketplace you declared.」
# 下面兩行是備援,讓 marketplace 在 session 啟動前就已經在快照裡。
set -uo pipefail
claude plugin marketplace add https://git.uncle6.me/inkstone/ISEP.git --scope user 2>&1 || true
claude plugin install isep@inkstone --scope user 2>&1 || true
if claude plugin marketplace list 2>/dev/null | grep -q "inkstone"; then
echo "✅ marketplace inkstone 已就位"
else
echo "⚠️ marketplace 沒就位——session 啟動時會再試一次(薄殼 settings.json 宣告的那條路)。"
echo " 若 session 開頭看不到「🟢 ISEP v… 已載入」,就是這條也失敗了。"
fi
exit 0