Aider es una herramienta que utiliza IA para ayudarte a escribir código. Es un chatbot que puede ayudarte a escribir código, corregir errores e incluso escribir pruebas.
OpenRouter es una herramienta que te permite enrutar peticiones a diferentes APIs. En este caso, la usaremos para enrutar la petición a Aider.
Con Aider podemos ejecutar el siguiente comando para generar una instrucción de pull request:
1
2
3
4
5
6
7
8
9
aider \
--model "openrouter/meta-llama/llama-3-8b-instruct:free"\
--message="/ask Generate PR description from diff.log using INSTRUCTIONS.MD and PR_TEMPLATE.MD"\
--read INSTRUCTIONS.MD \
--read PR_TEMPLATE.MD \
--read diff.log \
--no-stream \
--dry-run \
--no-git
Como puedes ver, estamos pasando el modelo que queremos usar, el mensaje que queremos enviar a Aider y los archivos que queremos usar para generar el pull request.
INSTRUCTIONS.MD es un archivo que contiene las instrucciones para el pull request, por ejemplo:
# Description:-Provideaclearandconcisedescriptionofthechangesintroducedinthispullrequest.-Highlightkeyupdatesorfeatures.# Jira:-[x]Relatedticket:ENG-# What areas of the site does it impact?-(Describewhatpartsofthesiteareimpactedand_if_codeupdatedotherareas)Ex.Checkout,Redemption,Homepage# Other Notes-(AddanyadditionalinformationthatwouldbeusefultothedeveloperorQAtester)# How to Test-Bestwaytotest?-IsthispartofanA/Btest?(Giveexperimentslug&variants)-Whatshouldthetesterlookoutfor?# Visual changes (if applicable)### - Before:|Mobile|Tablet|Desktop||-------------------|-------------------|--------------------||<screenshot_mobile>|<screenshot_tablet>|<screenshot_desktop>|### - After:|Mobile|Tablet|Desktop||-------------------|-------------------|--------------------||<screenshot_mobile>|<screenshot_tablet>|<screenshot_desktop>|# Developer Checklist-[]Ihaveperformedself-reviewofmycode-[]Ihaveaddedunitteststhatprovemyfeatureworks-[]IhaveconfirmedallthePRcheckspass-[]IhaveaddedReviewerstothisPRonGithub# Rollback Plan-[]Ihaveadocumentedplantodeployandrollbackifthereisanissue
diff.log es el archivo que contiene los cambios que hicimos en el código (básicamente git diff > diff.log).
#!/bin/bash
PROVIDER="openrouter/"MODEL="google/gemini-2.0-flash-exp:free"script_dir="$(cd"$(dirname "$0")"&&pwd)"# Parse command line argumentsproject="my-default-project-folder"# Default projectwhilegetopts"p:" opt;docase$opt in
p)project="$OPTARG";;\?)echo"Invalid option: -$OPTARG" >&2exit1;;esacdone# Change to project directorycd ~/projects/$project# Ticket number to use in the PR templatebranch_name=$(git rev-parse --abbrev-ref HEAD)ticket_number=$(echo"$branch_name"| awk -F'/''{print $2}')# Generate diff filegit diff origin/develop...HEAD > "$script_dir/diff.log"# Go to the path where the script is locatedcd"$script_dir"aider \
--model "$PROVIDER$MODEL"\
--cache-prompts \
--message="/ask Generate PR description from diff.log using INSTRUCTIONS.MD and PR_TEMPLATE.MD (#$ticket_number)"\
--read INSTRUCTIONS.MD \
--read PR_TEMPLATE.MD \
--read diff.log \
--no-stream \
--dry-run \
--no-git \
--no-show-model-warnings