Merge pull request 'fix(codex-hooks): 避免 Claude manifest 在 Codex 變成空路徑' (#50) from fix/codex-claude-hook-manifest into develop

Reviewed-on: #50
This commit was merged in pull request #50.
This commit is contained in:
2026-08-28 10:09:31 +00:00
6 changed files with 37 additions and 19 deletions
+18
View File
@@ -188,6 +188,18 @@ has_lang_guard() {
grep -qF "$_first" "$1" 2>/dev/null
}
codex_plugin_hooks_json() {
_base="${CODEX_HOME:-$HOME/.codex}/plugins/cache/jsc/jsc-hooks"
[ -d "$_base" ] || return 1
find "$_base" -path '*/hooks/hooks.json' -type f 2>/dev/null | sort | tail -n1
}
codex_plugin_hooks_safe() {
_hooks_json=$(codex_plugin_hooks_json || true)
[ -n "$_hooks_json" ] || return 0
! grep -qF 'command": "sh \"${CLAUDE_PLUGIN_ROOT}/hooks/' "$_hooks_json" 2>/dev/null
}
# 以標記整段取代(冪等);標記不存在就在檔尾新增;檔案不存在就建立。
# 適用 markdown 規則檔與 shell rc 檔:這兩種檔案沒有「區段」概念,附在檔尾就對了。
# $1=檔案 $2=開頭標記行 $3=結尾標記行 $4=標記之間要寫入的內容
@@ -986,6 +998,12 @@ if [ "$action" = status ]; then
st_lang_guard lang-guard "${CODEX_HOME:-$HOME/.codex}/AGENTS.md"
st_runtime_paths runtime-paths "$config" "# jsc-hooks" "# /jsc-hooks"
st_runtime_paths alias-paths "$HOME/.bashrc" "# jsc-hooks:codex" "# /jsc-hooks:codex"
_codex_plugin_hooks=$(codex_plugin_hooks_json || true)
if codex_plugin_hooks_safe; then
st_item plugin-user-prompt-root "${_codex_plugin_hooks:-${CODEX_HOME:-$HOME/.codex}/plugins/cache/jsc/jsc-hooks}" present
else
st_item plugin-user-prompt-root "$_codex_plugin_hooks" missing
fi
st_degrade="STE100 降級為 prompt 檔,SDLC 模型鎖降級為技能步驟檢查,無 pre-tool hook 可接版本前置檢查與部署後重啟閘門,註解範圍與繁中編碼改為每輪結束掃整個工作區,不是逐檔即時" ;;
copilot)