fix(shell): keep Cursor on agent and Grok on grok

Grok's installer prepends ~/.grok/bin and steals ~/.local/bin/agent.
easyzsh already shims `grok`; claim `agent` for Cursor and drop the
vendor bin from PATH so a later Grok upgrade cannot shadow it.
This commit is contained in:
Frank Qing
2026-08-13 17:36:56 +08:00
parent e41d2b6e93
commit 82c6a57c3a
5 changed files with 77 additions and 6 deletions
+18 -2
View File
@@ -154,11 +154,27 @@ install -m 644 "${ROOT}/.zshrc" "${TARGET_HOME}/.zshrc"
"${ZSH_CFG}/local.zsh.example" \
"${TARGET_HOME}/.config/zshenv.local"
# Ensure intentional grok shim when the binary tree exists.
# Grok is `grok`. Cursor owns `agent` when its CLI is present.
if [[ -e "${TARGET_HOME}/.grok/bin/grok" ]]; then
ln -sfn "${TARGET_HOME}/.grok/bin/grok" "${TARGET_HOME}/.local/bin/grok"
echo "Ensured ~/.local/bin/grok -> ~/.grok/bin/grok"
fi
agent_link="${TARGET_HOME}/.local/bin/agent"
cursor_agent="${TARGET_HOME}/.local/bin/cursor-agent"
agent_target=""
if [[ -L "$agent_link" ]]; then
agent_target=$(readlink "$agent_link")
fi
if [[ -x "$cursor_agent" ]]; then
if [[ ! -e "$agent_link" || "$agent_target" == *'/.grok/'* ]]; then
ln -sfn "$cursor_agent" "$agent_link"
echo "Ensured ~/.local/bin/agent -> cursor-agent"
fi
elif [[ -L "$agent_link" && "$agent_target" == *'/.grok/'* ]]; then
rm -f "$agent_link"
echo "Removed ~/.local/bin/agent (was Grok; Cursor is not installed)"
fi
echo "Deploy complete."
echo "Verify: env -i HOME=\"$TARGET_HOME\" PATH=/usr/bin:/bin zsh -c '. ~/.zshenv; command -v grok'"
echo "Verify: env -i HOME=\"$TARGET_HOME\" PATH=/usr/bin:/bin zsh -c '. ~/.zshenv; command -v grok; command -v agent'"