@@ -195,26 +195,36 @@ resource "coder_script" "aider" {
195
195
196
196
# Install essential dependencies
197
197
if [ "$(uname)" = "Linux" ]; then
198
- echo "Installing dependencies on Linux..."
199
- if command -v apt-get >/dev/null 2>&1; then
200
- sudo apt-get update -qq
201
-
202
- # Install terminal multiplexers for persistent sessions
203
- if [ "${ var . use_tmux } " = "true" ]; then
198
+ echo "Checking dependencies for Linux..."
199
+
200
+ # Check and install tmux/screen only if needed and requested
201
+ if [ "${ var . use_tmux } " = "true" ]; then
202
+ if ! command_exists tmux; then
204
203
echo "Installing tmux for persistent sessions..."
205
- sudo apt-get install -y -qq python3-pip python3-venv tmux
204
+ if command -v apt-get >/dev/null 2>&1; then
205
+ sudo apt-get update -qq
206
+ sudo apt-get install -y -qq tmux
207
+ elif command -v dnf >/dev/null 2>&1; then
208
+ sudo dnf install -y -q tmux
209
+ else
210
+ echo "Warning: Unable to install tmux on this system."
211
+ fi
206
212
else
207
- echo "Installing screen for persistent sessions..."
208
- sudo apt-get install -y -qq python3-pip python3-venv screen
213
+ echo "tmux is already installed, skipping installation."
209
214
fi
210
- elif command -v dnf >/dev/null 2>&1; then
211
- # For Red Hat-based distros
212
- if [ "${ var . use_tmux } " = "true" ]; then
213
- echo "Installing tmux for persistent sessions..."
214
- sudo dnf install -y -q python3-pip python3-virtualenv tmux
215
- else
215
+ elif [ "${ var . use_screen } " = "true" ]; then
216
+ if ! command_exists screen; then
216
217
echo "Installing screen for persistent sessions..."
217
- sudo dnf install -y -q python3-pip python3-virtualenv screen
218
+ if command -v apt-get >/dev/null 2>&1; then
219
+ sudo apt-get update -qq
220
+ sudo apt-get install -y -qq screen
221
+ elif command -v dnf >/dev/null 2>&1; then
222
+ sudo dnf install -y -q screen
223
+ else
224
+ echo "Warning: Unable to install screen on this system."
225
+ fi
226
+ else
227
+ echo "screen is already installed, skipping installation."
218
228
fi
219
229
fi
220
230
else
@@ -234,8 +244,23 @@ resource "coder_script" "aider" {
234
244
if [ "${ var . install_aider } " = "true" ]; then
235
245
echo "Installing Aider..."
236
246
247
+ # Check if python3 and pip/venv are installed
248
+ if ! command_exists python3 || ! command_exists pip3; then
249
+ echo "Installing Python dependencies required for Aider..."
250
+ if command -v apt-get >/dev/null 2>&1; then
251
+ sudo apt-get update -qq
252
+ sudo apt-get install -y -qq python3-pip python3-venv
253
+ elif command -v dnf >/dev/null 2>&1; then
254
+ sudo dnf install -y -q python3-pip python3-virtualenv
255
+ else
256
+ echo "Warning: Unable to install Python on this system."
257
+ fi
258
+ else
259
+ echo "Python is already installed, skipping installation."
260
+ fi
261
+
237
262
# Use official installation script
238
- if ! command -v aider &> /dev/null ; then
263
+ if ! command_exists aider; then
239
264
curl -LsSf https://aider.chat/install.sh | sh
240
265
fi
241
266
@@ -304,8 +329,6 @@ CONVENTIONS_EOF
304
329
echo "Running Aider with message in tmux session..."
305
330
# Start aider with the message flag and yes-always to avoid confirmations
306
331
tmux new-session -d -s ${ var . session_name } -c ${ var . folder } "echo \"Starting Aider with app status slug: aider\"; export ANTHROPIC_API_KEY=\"$ANTHROPIC_API_KEY\"; export CODER_MCP_APP_STATUS_SLUG=\"aider\"; aider --architect --yes-always --read CONVENTIONS.md --message \"Report each step to Coder. Your task: $CODER_MCP_AIDER_TASK_PROMPT\""
307
- # Create a flag file to indicate this task was executed
308
- touch "$HOME/.aider_task_executed"
309
332
echo "Aider task started in tmux session '${ var . session_name } '. Check the UI for progress."
310
333
else
311
334
# Create a new detached tmux session for interactive use
@@ -344,8 +367,6 @@ CONVENTIONS_EOF
344
367
/bin/bash
345
368
"
346
369
347
- # Create a flag file to indicate this task was executed
348
- touch "$HOME/.aider_task_executed"
349
370
echo "Aider task started in screen session '${ var . session_name } '. Check the UI for progress."
350
371
else
351
372
# Create a new detached screen session for interactive use
0 commit comments