Skip to content

Commit 68d6c79

Browse files
committed
feat(agent-bootstrap): warn on unexpected shell level for agents
Generated-by: aiautocommit
1 parent 4739700 commit 68d6c79

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

.config/mbianco/agent-bootstrap

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,24 @@ ai_load_agent_configuration() {
2121
# return 0
2222
# fi
2323

24-
# Return early if not the first shell level
25-
# if (( ${SHLVL:-0} != 1 )); then
26-
# [[ ${AGENT_DEBUG:-} -eq 1 ]] && echo "Not first shell level, returning"
27-
# return 1
28-
# fi
24+
# Check expected SHLVL for each agent type, we want to know if the logic here changes
25+
local shlvl="${SHLVL:-0}"
26+
if [[ -n "${CURSOR_AGENT:-}" ]]; then
27+
# Cursor should use SHLVL=3
28+
if [[ "$shlvl" != "3" ]]; then
29+
echo -e "\033[33mWarning: Cursor agent with unexpected SHLVL=$shlvl (expected 3)\033[0m"
30+
fi
31+
elif [[ "${VSCODE_AGENT:-}" == "1" ]]; then
32+
# VS Code should use SHLVL=1
33+
if [[ "$shlvl" != "1" ]]; then
34+
echo -e "\033[33mWarning: VS Code agent with unexpected SHLVL=$shlvl (expected 1)\033[0m"
35+
fi
36+
else
37+
# Other agents should use SHLVL=1
38+
if [[ "$shlvl" != "1" ]]; then
39+
echo -e "\033[33mWarning: Agent with unexpected SHLVL=$shlvl (expected 1)\033[0m"
40+
fi
41+
fi
2942

3043
# VS Code does not operate the same as Cursor: terminals are interactive, not dumb, and no ENV var is set to indicate
3144
# it's being managed by an agent. We manually set a variable in our VCS config to indicate this.

0 commit comments

Comments
 (0)