isep-doctor:講出這台的 ISEP plugin 有沒有真的載入(inkstone/ISEP#150)

根因不是「Desktop 不跑 hook」:Desktop 1.52386.0/CC 2.1.266 內實測專案
PreToolUse hook 照擋。真正斷的是 ~/.claude/settings.json
extraKnownMarketplaces.inkstone.source 多了 path,CC 把它當 git 抓取欄位,
marketplace 被忽略 ⇒ isep@inkstone「Marketplace inkstone not found」,
59 支閘在 CLI 與 Desktop 一起失效,而且沒有任何閘講得出來。

本支從 plugin 外面查(claude plugin list --json + settings 對 known_marketplaces),
點名多出的欄位並印出一行修法。迴歸測試 scripts/test-isep-doctor.sh 5/5。

假設:修 ~/.claude/settings.json 是 leo 的個人設定,由 leo 親手執行,本 commit 不動它。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-13 14:55:26 +08:00
parent c1df3c7a08
commit 8eb4c58d2d
2 changed files with 145 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
# 迴歸測試:scripts/isep-doctorinkstone/ISEP#150
set -u
HERE="$(cd "$(dirname "$0")" && pwd)"
T=$(mktemp -d); trap 'rm -rf "$T"' EXIT
pass=0; fail=0
check() { # name expected_exit grep_pattern
local out code; out=$(ISEP_DOCTOR_CLAUDE_HOME="$T/home" ISEP_DOCTOR_PLUGIN_LIST_JSON="$T/list.json" python3 "$HERE/isep-doctor" 2>&1); code=$?
if [ "$code" = "$2" ] && printf '%s' "$out" | grep -q -- "$3"; then pass=$((pass+1)); echo "ok $1"
else fail=$((fail+1)); echo "FAIL $1 (exit=$code)"; printf '%s\n' "$out" | sed 's/^/ /'; fi
}
mkdir -p "$T/home/plugins"
echo '{"inkstone":{"source":{"source":"git","url":"https://git.uncle6.me/inkstone/ISEP.git"}}}' > "$T/home/plugins/known_marketplaces.json"
# 1. 09-13 實況:settings 多了 path、plugin list 報 Marketplace not found → 1,點名 path
echo '{"extraKnownMarketplaces":{"inkstone":{"source":{"source":"git","url":"https://git.uncle6.me/inkstone/ISEP.git","path":"/Users/x/ISEP"}}}}' > "$T/home/settings.json"
echo '[{"id":"isep@inkstone","version":"0.30.1","enabled":true,"errors":["Marketplace inkstone not found"]}]' > "$T/list.json"
check "path 造成載入失敗" 1 "多了 path"
# 2. 修好後:沒有 path、沒有 errors → 0
echo '{"extraKnownMarketplaces":{"inkstone":{"source":{"source":"git","url":"https://git.uncle6.me/inkstone/ISEP.git"}}}}' > "$T/home/settings.json"
echo '[{"id":"isep@inkstone","version":"0.30.1","enabled":true}]' > "$T/list.json"
check "正常載入" 0 "已載入"
# 3. 別的原因失敗(沒有多餘欄位)→ 1,照實轉述 Claude Code 的錯
echo '[{"id":"isep@inkstone","version":"0.30.1","enabled":true,"errors":["Plugin directory missing"]}]' > "$T/list.json"
check "其他錯誤照實轉述" 1 "Plugin directory missing"
# 4. 根本沒裝 → 1
echo '[]' > "$T/list.json"
check "沒安裝" 1 "沒有安裝"
# 5. 修法那一行真的修得好(在假 HOME 上執行印出來的指令)
echo '{"extraKnownMarketplaces":{"inkstone":{"source":{"source":"git","url":"https://git.uncle6.me/inkstone/ISEP.git","path":"/Users/x/ISEP"}}},"model":"keep"}' > "$T/home/settings.json"
echo '[{"id":"isep@inkstone","version":"0.30.1","enabled":true,"errors":["Marketplace inkstone not found"]}]' > "$T/list.json"
fixline=$(ISEP_DOCTOR_CLAUDE_HOME="$T/home" ISEP_DOCTOR_PLUGIN_LIST_JSON="$T/list.json" python3 "$HERE/isep-doctor" | grep '^ python3 ' | sed 's/^ //')
mkdir -p "$T/fake/.claude" && cp "$T/home/settings.json" "$T/fake/.claude/settings.json"
HOME="$T/fake" bash -c "$fixline" # 原封不動執行印給 leo 的那一行
if python3 -c "import json,sys;d=json.load(open('$T/fake/.claude/settings.json'));s=d['extraKnownMarketplaces']['inkstone']['source'];sys.exit(0 if 'path' not in s and d['model']=='keep' and s['url'].endswith('ISEP.git') else 1)"; then
pass=$((pass+1)); echo "ok 修法一行拿掉 path、其他設定不動"
else fail=$((fail+1)); echo "FAIL 修法一行"; cat "$T/home/settings.json"; fi
echo "pass=$pass fail=$fail"; [ "$fail" = 0 ]