@@ -138,12 +138,6 @@ variable "experiment_additional_extensions" {
138138 default = null
139139}
140140
141- variable "app_status_slug" {
142- type = string
143- description = " The slug to use for the app status reporting in MCP"
144- default = " aider"
145- }
146-
147141locals {
148142 base_extensions = <<- EOT
149143coder:
@@ -155,7 +149,7 @@ coder:
155149 description: Report ALL tasks and statuses (in progress, done, failed) you are working on.
156150 enabled: true
157151 envs:
158- CODER_MCP_APP_STATUS_SLUG: ${ var . app_status_slug }
152+ CODER_MCP_APP_STATUS_SLUG: aider
159153 name: Coder
160154 timeout: 3000
161155 type: stdio
@@ -309,36 +303,33 @@ CONVENTIONS_EOF
309303 if [ -n "$CODER_MCP_AIDER_TASK_PROMPT" ]; then
310304 echo "Running Aider with message in tmux session..."
311305 # Start aider with the message flag and yes-always to avoid confirmations
312- tmux new-session -d -s ${ var . session_name } -c ${ var . folder } "export ANTHROPIC_API_KEY=\"$ANTHROPIC_API_KEY\"; export CODER_MCP_APP_STATUS_SLUG=\"${ var . app_status_slug } \"; aider --architect --yes-always --read CONVENTIONS.md --message \"Report each step to Coder. Your task: $CODER_MCP_AIDER_TASK_PROMPT\" | tee -a \"$HOME/.aider.log \""
306+ 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\""
313307 # Create a flag file to indicate this task was executed
314308 touch "$HOME/.aider_task_executed"
315- echo "Aider task started in tmux session '${ var . session_name } '. Check the logs for progress."
309+ echo "Aider task started in tmux session '${ var . session_name } '. Check the UI for progress."
316310 else
317311 # Create a new detached tmux session for interactive use
318- tmux new-session -d -s ${ var . session_name } -c ${ var . folder } "export ANTHROPIC_API_KEY=\"$ANTHROPIC_API_KEY\"; export CODER_MCP_APP_STATUS_SLUG=\"${ var . app_status_slug } \"; aider --read CONVENTIONS.md | tee -a \"$HOME/.aider.log\" "
312+ 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 --read CONVENTIONS.md"
319313 echo "Tmux session '${ var . session_name } ' started. Access it by clicking the Aider button."
320314 fi
321315 else
322316 # Check if we have a task prompt
323317 if [ -n "$CODER_MCP_AIDER_TASK_PROMPT" ]; then
324318 echo "Running Aider with message in screen session..."
325319
326- # Create log file
327- touch "$HOME/.aider.log"
328-
329320 # Ensure the screenrc exists with multi-user settings
330321 if [ ! -f "$HOME/.screenrc" ]; then
331- echo "Creating ~/.screenrc and adding multiuser settings..." | tee -a "$HOME/.aider.log"
322+ echo "Creating ~/.screenrc and adding multiuser settings..."
332323 echo -e "multiuser on\nacladd $(whoami)" > "$HOME/.screenrc"
333324 fi
334325
335326 if ! grep -q "^multiuser on$" "$HOME/.screenrc"; then
336- echo "Adding 'multiuser on' to ~/.screenrc..." | tee -a "$HOME/.aider.log"
327+ echo "Adding 'multiuser on' to ~/.screenrc..."
337328 echo "multiuser on" >> "$HOME/.screenrc"
338329 fi
339330
340331 if ! grep -q "^acladd $(whoami)$" "$HOME/.screenrc"; then
341- echo "Adding 'acladd $(whoami)' to ~/.screenrc..." | tee -a "$HOME/.aider.log"
332+ echo "Adding 'acladd $(whoami)' to ~/.screenrc..."
342333 echo "acladd $(whoami)" >> "$HOME/.screenrc"
343334 fi
344335
@@ -347,40 +338,41 @@ CONVENTIONS_EOF
347338 cd ${ var . folder }
348339 export PATH=\"$HOME/bin:$HOME/.local/bin:$PATH\"
349340 export ANTHROPIC_API_KEY=\"$ANTHROPIC_API_KEY\"
350- export CODER_MCP_APP_STATUS_SLUG=\"${ var . app_status_slug } \"
351- aider --architect --yes-always --read CONVENTIONS.md --message \"Report each step to Coder. Your task: $CODER_MCP_AIDER_TASK_PROMPT\" | tee -a \"$HOME/.aider.log\"
341+ export CODER_MCP_APP_STATUS_SLUG=\"aider\"
342+ echo \"Starting Aider with app status slug: aider\"
343+ aider --architect --yes-always --read CONVENTIONS.md --message \"Report each step to Coder. Your task: $CODER_MCP_AIDER_TASK_PROMPT\"
352344 /bin/bash
353345 "
354346
355347 # Create a flag file to indicate this task was executed
356348 touch "$HOME/.aider_task_executed"
357- echo "Aider task started in screen session '${ var . session_name } '. Check the logs for progress."
349+ echo "Aider task started in screen session '${ var . session_name } '. Check the UI for progress."
358350 else
359351 # Create a new detached screen session for interactive use
360- touch "$HOME/.aider.log"
361352
362353 # Ensure the screenrc exists with multi-user settings
363354 if [ ! -f "$HOME/.screenrc" ]; then
364- echo "Creating ~/.screenrc and adding multiuser settings..." | tee -a "$HOME/.aider.log"
355+ echo "Creating ~/.screenrc and adding multiuser settings..."
365356 echo -e "multiuser on\nacladd $(whoami)" > "$HOME/.screenrc"
366357 fi
367358
368359 if ! grep -q "^multiuser on$" "$HOME/.screenrc"; then
369- echo "Adding 'multiuser on' to ~/.screenrc..." | tee -a "$HOME/.aider.log"
360+ echo "Adding 'multiuser on' to ~/.screenrc..."
370361 echo "multiuser on" >> "$HOME/.screenrc"
371362 fi
372363
373364 if ! grep -q "^acladd $(whoami)$" "$HOME/.screenrc"; then
374- echo "Adding 'acladd $(whoami)' to ~/.screenrc..." | tee -a "$HOME/.aider.log"
365+ echo "Adding 'acladd $(whoami)' to ~/.screenrc..."
375366 echo "acladd $(whoami)" >> "$HOME/.screenrc"
376367 fi
377368
378369 screen -U -dmS ${ var . session_name } bash -c "
379370 cd ${ var . folder }
380371 export PATH=\"$HOME/bin:$HOME/.local/bin:$PATH\"
381372 export ANTHROPIC_API_KEY=\"$ANTHROPIC_API_KEY\"
382- export CODER_MCP_APP_STATUS_SLUG=\"${ var . app_status_slug } \"
383- aider --read CONVENTIONS.md | tee -a \"$HOME/.aider.log\"
373+ export CODER_MCP_APP_STATUS_SLUG=\"aider\"
374+ echo \"Starting Aider with app status slug: aider\"
375+ aider --read CONVENTIONS.md
384376 /bin/bash
385377 "
386378 echo "Screen session '${ var . session_name } ' started. Access it by clicking the Aider button."
@@ -406,6 +398,8 @@ resource "coder_app" "aider_cli" {
406398 export PATH="$HOME/bin:$HOME/.local/bin:$PATH"
407399
408400 # Environment variables are set in the agent template
401+ # Explicitly export the status reporting environment variable
402+ export CODER_MCP_APP_STATUS_SLUG="aider"
409403
410404 # Set up environment for UTF-8 support
411405 export LANG=en_US.UTF-8
@@ -415,11 +409,13 @@ resource "coder_app" "aider_cli" {
415409 if [ "${ var . use_tmux } " = "true" ]; then
416410 # Check if session exists, attach or create
417411 if tmux has-session -t ${ var . session_name } 2>/dev/null; then
418- echo "Attaching to existing Aider tmux session..." | tee -a "$HOME/.aider.log"
412+ echo "Attaching to existing Aider tmux session..."
413+ # Ensure the environment variables are set when attaching
414+ tmux setenv -t ${ var . session_name } CODER_MCP_APP_STATUS_SLUG "aider"
419415 tmux attach-session -t ${ var . session_name }
420416 else
421- echo "Starting new Aider tmux session..." | tee -a "$HOME/.aider.log"
422- tmux new-session -s ${ var . session_name } -c ${ var . folder } "export ANTHROPIC_API_KEY=\"$ANTHROPIC_API_KEY\"; aider --read CONVENTIONS.md | tee -a \"$HOME/.aider.log\" ; exec bash"
417+ echo "Starting new Aider tmux session..."
418+ tmux new-session -s ${ var . session_name } -c ${ var . folder } "export ANTHROPIC_API_KEY=\"$ANTHROPIC_API_KEY\"; export CODER_MCP_APP_STATUS_SLUG=\" aider\"; aider --read CONVENTIONS.md; exec bash"
423419 fi
424420 elif [ "${ var . use_screen } " = "true" ]; then
425421 # Use screen
@@ -428,13 +424,15 @@ resource "coder_app" "aider_cli" {
428424 echo "Error: No existing Aider session found. Please wait for the script to start it."
429425 exit 1
430426 fi
427+ # Set the environment variable before attaching to the screen session
428+ export CODER_MCP_APP_STATUS_SLUG="aider"
431429 # Only attach to existing session
432430 screen -xRR ${ var . session_name }
433431 else
434432 # Run directly without a multiplexer
435433 cd "${ var . folder } "
436- echo "Starting Aider directly..." | tee -a "$HOME/.aider.log"
437- export CODER_MCP_APP_STATUS_SLUG="${ var . app_status_slug } "
434+ echo "Starting Aider directly..."
435+ export CODER_MCP_APP_STATUS_SLUG="aider "
438436 aider --read CONVENTIONS.md
439437 fi
440438 EOT
0 commit comments