Skip to content

Commit 9b9481d

Browse files
committed
feat(gemini): move YOLO wrapper to entrypoint for better reliability
1 parent 6fbff09 commit 9b9481d

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

packages/lib/src/core/templates-entrypoint/gemini.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@ docker_git_link_gemini_file() {
5050
docker_git_link_gemini_file "$GEMINI_CONFIG_DIR/.api-key" "$GEMINI_HOME_DIR/.api-key"
5151
docker_git_link_gemini_file "$GEMINI_CONFIG_DIR/.env" "$GEMINI_HOME_DIR/.env"
5252
53+
# Ensure gemini YOLO wrapper exists
54+
GEMINI_REAL_BIN="$(command -v gemini || echo "/usr/local/bin/gemini")"
55+
GEMINI_WRAPPER_BIN="/usr/local/bin/gemini-wrapper"
56+
if [[ -f "$GEMINI_REAL_BIN" && "$GEMINI_REAL_BIN" != "$GEMINI_WRAPPER_BIN" ]]; then
57+
if [[ ! -f "$GEMINI_WRAPPER_BIN" ]]; then
58+
cat <<'EOF' > "$GEMINI_WRAPPER_BIN"
59+
#!/usr/bin/env bash
60+
GEMINI_ORIGINAL_BIN="__GEMINI_REAL_BIN__"
61+
exec "$GEMINI_ORIGINAL_BIN" --yolo "$@"
62+
EOF
63+
sed -i "s#__GEMINI_REAL_BIN__#$GEMINI_REAL_BIN#g" "$GEMINI_WRAPPER_BIN" || true
64+
chmod 0755 "$GEMINI_WRAPPER_BIN" || true
65+
# Create an alias or symlink if needed, but here we just ensure it exists
66+
fi
67+
fi
68+
5369
# Special case for .gemini folder: we want the folder itself to be the link if it doesn't exist
5470
# or its content to be linked if we want to manage it.
5571
if [[ -d "$GEMINI_CONFIG_DIR/.gemini" ]]; then
@@ -137,7 +153,7 @@ printf "export GEMINI_HOME=%q\n" "${config.geminiHome}" >> "$GEMINI_PROFILE"
137153
printf "export GEMINI_CLI_DISABLE_UPDATE_CHECK=true\n" >> "$GEMINI_PROFILE"
138154
printf "export GEMINI_CLI_NONINTERACTIVE=true\n" >> "$GEMINI_PROFILE"
139155
printf "export GEMINI_CLI_APPROVAL_MODE=yolo\n" >> "$GEMINI_PROFILE"
140-
printf "alias gemini='gemini --yolo'\n" >> "$GEMINI_PROFILE"
156+
printf "alias gemini='/usr/local/bin/gemini-wrapper'\n" >> "$GEMINI_PROFILE"
141157
cat <<'EOF' >> "$GEMINI_PROFILE"
142158
if [[ -f "$GEMINI_HOME/.api-key" ]]; then
143159
export GEMINI_API_KEY="$(cat "$GEMINI_HOME/.api-key" | tr -d '\r\n')"

packages/lib/src/core/templates/dockerfile.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ RUN oh-my-opencode --version
6262
RUN npm install -g @anthropic-ai/claude-code@latest
6363
RUN claude --version
6464
RUN npm install -g @google/gemini-cli@latest --force
65-
RUN gemini --version
66-
RUN mv /usr/local/bin/gemini /usr/local/bin/gemini-original && printf "#!/usr/bin/env bash\nexec /usr/local/bin/gemini-original --yolo \"\\\$@\"\n" > /usr/local/bin/gemini && chmod +x /usr/local/bin/gemini`
65+
RUN gemini --version`
6766

6867
const renderDockerfileOpenCode = (): string =>
6968
`# Tooling: OpenCode (binary)

0 commit comments

Comments
 (0)