forked from tom-doerr/path_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaider_multi_agent
More file actions
executable file
·128 lines (113 loc) · 6.16 KB
/
aider_multi_agent
File metadata and controls
executable file
·128 lines (113 loc) · 6.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# Define prompts
PROMPTS=(
"please look at context.txt. are there issues? if so what are they? where do they occur and why do they occur? please go through each issue and update the report.md and make sure we have for each issue documented why it occurs, how we can fix it or what pytest tests we could add to find out why it occurs"
"please go through each line in the spec and check if the code fulfills the requirement and why it does or does not fulfill it. document it in detail in the report.md"
"are there features in the codebase that are not part of the specs in spec.md? what are they? can we remove them? should we remove them? how much additional code do they cause? do they add a lot of complexity? are they really useful and would be appreciated? please document them in report.md"
"consider the current code architecture. could it be restructured someway? what are alternatives? what are alternatives that would be easy to implement? can we restructure it in a way that would reduce total lines of code? can we restructure it in a way that reduces complexity or makes it easier to work with in general? those do not need to be large things, even tiny changes can have an impact. please add report.md with your findings"
"please look through the content in report.md. what are the highest priority items in there? can you identify dependencies between tasks? would implementing some of those tasks make other tasks easier? please update the report with a list of tasks in a markdown table with each task containing task description, task-id, priority(1-9), the tasks it depends on, the tasks that depend on it (just enter the task ids for those two in the table). do not make the task list ordered since reprioritizing tasks is harder if reordering is required as well."
"please go through report.md and refactor it. are there items that should be grouped together? should some sections be restructered?"
"please go through report.md and check if there are duplicate section or if there is duplicate content. please remove any duplication"
"please go through report.md and create a plan for how we can takle the highest priority items. please update the report.md with your plan, do not implement it just yet"
"please go through report.md and work on the highest priority tasks"
"please go through report.md and check if the plan was successfully implemented. remove the plan if it was completed and mark the tasks as done. if there are issues with the implementation update the report.md accordingly"
)
show_help() {
echo "Usage: aider_multi_agent [options]"
echo
echo "Options:"
echo " -h, --help Show this help message and exit"
echo " -i ITERATIONS Number of iterations to run (default: 1000)"
echo " -m MODEL Model to use (default: r1)"
echo " -w WEAK_MODEL Weak model to use (default: gemini-2.0-flash-001)"
echo " -n SESSIONS Number of tmux sessions to create (default: 1)"
echo " -k Kill all running aider_multi_agent tmux sessions"
echo
echo "This script runs multiple aider agents through a series of prompts to analyze and improve code."
echo
echo "To start multiple sessions:"
echo " aider_multi_agent -n 3 # Starts 3 vertical splits"
echo
echo "To stop all sessions:"
echo " aider_multi_agent -k"
}
# Main script
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
show_help
exit 0
fi
# Parse arguments
ITERATIONS=1000
MODEL="r1"
WEAK_MODEL="gemini-2.0-flash-001"
SESSIONS=1
KILL_MODE=false
while getopts "i:m:w:n:kh" opt; do
case $opt in
i) ITERATIONS=$OPTARG ;;
m) MODEL=$OPTARG ;;
w) WEAK_MODEL=$OPTARG ;;
n) SESSIONS=$OPTARG ;;
k) KILL_MODE=true ;;
h) show_help; exit 0 ;;
*) show_help; exit 1 ;;
esac
done
# Kill all sessions if -k flag is set
if $KILL_MODE; then
echo "Killing all aider_multi_agent sessions..."
tmux list-sessions -F '#{session_name}' | grep '^aider_multi_agent_' | while read -r session; do
tmux kill-session -t "$session"
done
exit 0
fi
# Create tmux session
SESSION_NAME="aider_multi_agent_$(date +%s)"
CUSTOM_HISTORY_FILE=custom_aider_history.md
# Create new tmux session with horizontal splits
if [ "$SESSIONS" -gt 1 ]; then
echo "Creating $SESSIONS tmux sessions..."
# Get current working directory
CURRENT_DIR=$(pwd)
# Create initial session with first window
tmux new-session -d -s "$SESSION_NAME" -n "Session 1" "cd '$CURRENT_DIR' && ./$0 -i $ITERATIONS -m $MODEL -w $WEAK_MODEL"
# Create additional windows
for ((s=2; s<=SESSIONS; s++)); do
# Create new window
tmux new-window -t "$SESSION_NAME" -n "Session $s" "cd '$CURRENT_DIR' && ./$0 -i $ITERATIONS -m $MODEL -w $WEAK_MODEL"
done
# Split each window horizontally after brief delay
for ((s=1; s<=SESSIONS; s++)); do
tmux split-window -h -t "$SESSION_NAME:$s" "sleep 0.1; cd '$CURRENT_DIR' && ./$0 -i $ITERATIONS -m $MODEL -w $WEAK_MODEL"
tmux select-layout -t "$SESSION_NAME:$s" even-horizontal
sleep 0.1 # Allow time for window creation
done
# Select first window and attach
tmux select-window -t "$SESSION_NAME:1"
tmux attach-session -t "$SESSION_NAME"
exit 0
fi
# Normal execution for single session
for ((i=1; i<=ITERATIONS; i++)); do
echo "Iteration $i"' ========================= '$(date)' ============================'
for prompt in "${PROMPTS[@]}"; do
rm -f $CUSTOM_HISTORY_FILE
for run in {1..3}; do
aider --yes-always \
--read "${PWD}/plex.md" \
--read "${HOME}/git/dotfiles/instruction.md" \
--read "${PWD}/spec.md" \
--read "${PWD}/context.txt" \
--edit-format diff \
--model "openrouter/deepseek/deepseek-r1" \
--no-show-model-warnings \
--weak-model $WEAK_MODEL \
--architect \
--chat-history-file $CUSTOM_HISTORY_FILE \
--restore-chat-history \
report.md **/*py \
--message "$prompt"
done
done
sleep 1
done