Skip to content

Instantly share code, notes, and snippets.

@maledorak
Created July 12, 2024 07:49
Show Gist options
  • Select an option

  • Save maledorak/cf1f90d37f585a6f36a9aab5093e6c60 to your computer and use it in GitHub Desktop.

Select an option

Save maledorak/cf1f90d37f585a6f36a9aab5093e6c60 to your computer and use it in GitHub Desktop.

Revisions

  1. maledorak created this gist Jul 12, 2024.
    86 changes: 86 additions & 0 deletions aider-workflow.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,86 @@
    #!/bin/bash

    SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

    CMD=$1
    TASK=$2
    shift 2

    if [ -z "$CMD" ] || [ -z "$TASK" ]; then
    echo "Usage: aider <cmd> <task>"
    exit 1
    fi

    if [ ! -d "$SCRIPT_DIR/tasks/$TASK" ]; then
    echo "Task '$TASK' does not exist. Do you want to create it? [y/n]"
    read answer
    if [ "$answer" != "y" ]; then
    exit 1
    fi
    mkdir $SCRIPT_DIR/tasks/$TASK
    fi

    TASK_DIR=$SCRIPT_DIR/tasks/$TASK
    TASK_AIDER_DIR=$SCRIPT_DIR/tasks/$TASK/.aider
    cat $SCRIPT_DIR/templates/$CMD.md | sed "s/{{task}}/$TASK/g" | sed "s/{{date}}/$(date -I)/g" > $TASK_DIR/conventions.md

    case $CMD in
    plan)
    echo "Planning '$TASK'"

    aider \
    --vim \
    --no-auto-commit \
    --input-history-file $TASK_AIDER_DIR/.plan.input.history \
    --chat-history-file $TASK_AIDER_DIR/.plan.chat.history \
    --llm-history-file $TASK_AIDER_DIR/.plan.llm.history \
    $@ \
    $SCRIPT_DIR/tasks/$TASK/conventions.md \
    $SCRIPT_DIR/tasks/$TASK/plan.md \
    'pyproject.toml'
    ;;
    implement)
    echo "Implementing '$TASK'"

    aider \
    --vim \
    --no-auto-commit \
    --input-history-file $TASK_AIDER_DIR/.implement.input.history \
    --chat-history-file $TASK_AIDER_DIR/.implement.chat.history \
    --llm-history-file $TASK_AIDER_DIR/.implement.llm.history \
    $@ \
    $SCRIPT_DIR/tasks/$TASK/conventions.md \
    $SCRIPT_DIR/tasks/$TASK/plan.md \
    'pyproject.toml'
    ;;
    code)
    echo "Coding '$TASK'"

    aider \
    --vim \
    --no-auto-commit \
    --input-history-file $TASK_AIDER_DIR/.code.input.history \
    --chat-history-file $TASK_AIDER_DIR/.code.chat.history \
    --llm-history-file $TASK_AIDER_DIR/.code.llm.history \
    $@ \
    $SCRIPT_DIR/tasks/$TASK/conventions.md \
    'pyproject.toml'
    ;;
    review)
    echo "Reviewing '$TASK'"

    aider \
    --vim \
    --no-auto-commit \
    --input-history-file $TASK_AIDER_DIR/.review.input.history \
    --chat-history-file $TASK_AIDER_DIR/.review.chat.history \
    --llm-history-file $TASK_AIDER_DIR/.review.llm.history \
    $@ \
    $SCRIPT_DIR/tasks/$TASK/conventions.md \
    'pyproject.toml'
    ;;
    *)
    echo "Unknown phase"
    exit 1
    ;;
    esac