-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathproject_agent
More file actions
executable file
·198 lines (175 loc) · 5.82 KB
/
project_agent
File metadata and controls
executable file
·198 lines (175 loc) · 5.82 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/bin/zsh
# Unified project maintenance agent
# Combines task list management, reporting, and development tasks
typeset -A CONFIG=(
MODEL "r1"
MAX_ITERATIONS 1000
BASE_SLEEP 1
TASK_SLEEP 60
REPORT_SLEEP 60
MODE "all"
EDIT_FORMAT "diff"
INSTANCES 1
)
# Define a function to build AIDER_ARGS after parsing arguments
build_aider_args() {
AIDER_ARGS=(
--read spec.md
--read issues.txt
--model ${CONFIG[MODEL]}
--no-auto-lint
--no-auto-test
--edit-format ${CONFIG[EDIT_FORMAT]}
--no-browser
--no-suggest-shell-commands
--no-detect-urls
--subtree-only
--architect
--yes-always
)
}
update_task_list() {
echo "\n=== Updating Task List ==="
local worker_msg=""
[[ -n "${CONFIG[WORKER_ID]}" ]] && worker_msg=" You are worker ${CONFIG[WORKER_ID]}."
aider ${AIDER_ARGS} task_list.md --message \
"Review project and update task_list.md with prioritized, non-duplicated tasks.$worker_msg"
sleep ${CONFIG[TASK_SLEEP]}
}
update_project_report() {
echo "\n=== Updating Project Report ==="
local worker_msg=""
[[ -n "${CONFIG[WORKER_ID]}" ]] && worker_msg=" You are worker ${CONFIG[WORKER_ID]}."
aider ${AIDER_ARGS} project_report.md --message \
"Update project_report.md with current status, critical path, architecture issues, simplification opportunities. No long-term planning. Ensure accuracy and no duplication.$worker_msg"
sleep ${CONFIG[REPORT_SLEEP]}
}
handle_development_tasks() {
echo "\n=== Handling Development Tasks ==="
local worker_msg=""
[[ -n "${CONFIG[WORKER_ID]}" ]] && worker_msg=" You are worker ${CONFIG[WORKER_ID]}."
aider ${AIDER_ARGS} --auto-test --message \
"Review spec.md and issues.txt and work on the highest priority items. Only work on pylint issues if the code is rated below 9. If you don't work on linting, go through spec.md. Quote each requirement and tell me if the code fulfills it. If it doesn't fulfill it, create one or more edit blocks to fix the issue before moving on to the next spec requirement. $worker_msg"
sleep ${CONFIG[BASE_SLEEP]}
}
parse_arguments() {
while [[ $# -gt 0 ]]; do
case $1 in
--tasks)
CONFIG[MODE]="tasks"
;;
--report)
CONFIG[MODE]="report"
;;
--dev)
CONFIG[MODE]="dev"
;;
--all)
CONFIG[MODE]="all"
;;
-i|--iterations)
CONFIG[MAX_ITERATIONS]=$2
shift
;;
--edit-format)
CONFIG[EDIT_FORMAT]="$2"
shift
;;
-n|--instances)
CONFIG[INSTANCES]=$2
shift
;;
--worker-id)
CONFIG[WORKER_ID]=$2
shift
;;
--model)
CONFIG[MODEL]="$2"
shift
;;
--help)
help
exit 0
;;
*)
echo "Unknown option: $1"
help
exit 1
;;
esac
shift
done
}
run_cycle() {
local cycle=$1
echo "\n\n=== Cycle $cycle/${CONFIG[MAX_ITERATIONS]} ==="
case $CONFIG[MODE] in
"all")
if (( cycle % 60 == 0 )); then update_task_list; fi
if (( cycle % 60 == 30 )); then update_project_report; fi
handle_development_tasks
;;
"tasks")
update_task_list
;;
"report")
update_project_report
;;
"dev")
handle_development_tasks
;;
esac
}
help() {
echo "Project Maintenance Agent - Unified Development Orchestrator"
echo "Version: 1.2.0 | License: MIT | Model: ${CONFIG[MODEL]}"
echo "Usage: ./project_agent [OPTIONS]"
echo "\nOPERATIONAL MODES:"
echo " --tasks Focus only on task list maintenance (task_list.md)"
echo " --report Generate project status reports (project_report.md)"
echo " --dev Execute development tasks only (code changes)"
echo " --all Full operational mode (default)"
echo "\nOPTIONS:"
echo " -i, --iterations <NUM> Set execution cycles (default: ${CONFIG[MAX_ITERATIONS]})"
echo " --edit-format (diff|whole) Edit format (default: ${CONFIG[EDIT_FORMAT]})"
echo " -n, --instances <NUM> Run N parallel background instances (default: ${CONFIG[INSTANCES]})"
echo " --model <MODEL> Set the AI model to use (default: ${CONFIG[MODEL]})"
echo " --help Show this help menu"
echo "\nCONFIGURATION DEFAULTS:"
echo " Max Iterations: ${CONFIG[MAX_ITERATIONS]}"
echo " Base Sleep: ${CONFIG[BASE_SLEEP]}s"
echo " Task Sleep: ${CONFIG[TASK_SLEEP]}s"
echo " Report Sleep: ${CONFIG[REPORT_SLEEP]}s"
echo "\nEXAMPLES:"
echo " ./project_agent --tasks -i 5 # Refresh task list 5 times"
echo " ./project_agent --report # Generate status report"
echo " ./project_agent --dev # Continuous development mode"
echo " ./project_agent --all -i 100 # Full operation for 100 cycles"
echo " ./project_agent --model gpt-4 # Use GPT-4 model"
echo "\nNOTES:"
echo " - Task priorities update automatically based on project state"
echo " - Reports include architecture analysis and simplification opportunities"
echo " - Development mode prefers isolated, low-complexity changes"
echo " - Use 'aider --help' for details on the underlying AI agent"
}
launch_instance() {
local instance_id=$1
# Use direct command execution instead of nested instance management
kitty --title "Agent $instance_id" zsh -ic "project_agent --${CONFIG[MODE]} --worker-id $instance_id --model ${CONFIG[MODEL]} || echo 'Agent failed - press enter to exit'; read" &
}
main() {
parse_arguments "$@"
build_aider_args
if [[ ${CONFIG[INSTANCES]} -gt 1 ]]; then
for ((instance=1; instance<=${CONFIG[INSTANCES]}; instance++)); do
# Set worker ID for each instance
launch_instance $instance "$@"
done
exit 0
fi
for ((i=1; i<=${CONFIG[MAX_ITERATIONS]}; i++)); do
run_cycle $i
done
}
main "$@"
sleep 3