golem-cc 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/golem +290 -249
- package/bin/install.cjs +11 -5
- package/golem/prompts/PROMPT_build.md +47 -60
- package/golem/prompts/PROMPT_plan.md +41 -71
- package/package.json +1 -1
package/bin/golem
CHANGED
|
@@ -14,6 +14,12 @@
|
|
|
14
14
|
#
|
|
15
15
|
set -euo pipefail
|
|
16
16
|
|
|
17
|
+
# Exit codes for scripting
|
|
18
|
+
readonly EXIT_COMPLETE=0
|
|
19
|
+
readonly EXIT_INCOMPLETE=1
|
|
20
|
+
readonly EXIT_NO_PLAN=2
|
|
21
|
+
readonly EXIT_ERROR=3
|
|
22
|
+
|
|
17
23
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
18
24
|
# When installed globally, GOLEM_DIR is ~/.golem
|
|
19
25
|
# When run from source, it's the parent of bin/
|
|
@@ -29,9 +35,103 @@ GREEN='\033[0;32m'
|
|
|
29
35
|
YELLOW='\033[0;33m'
|
|
30
36
|
BLUE='\033[0;34m'
|
|
31
37
|
CYAN='\033[0;36m'
|
|
38
|
+
BOLD='\033[1m'
|
|
32
39
|
DIM='\033[2m'
|
|
33
40
|
NC='\033[0m'
|
|
34
41
|
|
|
42
|
+
# Terminal width for consistent formatting
|
|
43
|
+
TERM_WIDTH=60
|
|
44
|
+
|
|
45
|
+
# Helper: print a horizontal rule
|
|
46
|
+
hr() {
|
|
47
|
+
local char="${1:-━}"
|
|
48
|
+
local color="${2:-$CYAN}"
|
|
49
|
+
printf "${color}"
|
|
50
|
+
printf '%*s' "$TERM_WIDTH" '' | tr ' ' "$char"
|
|
51
|
+
printf "${NC}\n"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# Helper: print centered text
|
|
55
|
+
center() {
|
|
56
|
+
local text="$1"
|
|
57
|
+
local color="${2:-$NC}"
|
|
58
|
+
local text_len=${#text}
|
|
59
|
+
local padding=$(( (TERM_WIDTH - text_len) / 2 ))
|
|
60
|
+
printf "${color}%*s%s%*s${NC}\n" "$padding" '' "$text" "$padding" ''
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
# Helper: print a header box
|
|
64
|
+
header_box() {
|
|
65
|
+
local title="$1"
|
|
66
|
+
local color="${2:-$CYAN}"
|
|
67
|
+
echo ""
|
|
68
|
+
hr "━" "$color"
|
|
69
|
+
center "$title" "$color"
|
|
70
|
+
hr "━" "$color"
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
# Helper: print status line with icon
|
|
74
|
+
status_line() {
|
|
75
|
+
local icon="$1"
|
|
76
|
+
local color="$2"
|
|
77
|
+
local text="$3"
|
|
78
|
+
echo -e " ${color}${icon}${NC} ${text}"
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
# Helper: print a key-value line
|
|
82
|
+
kv_line() {
|
|
83
|
+
local key="$1"
|
|
84
|
+
local value="$2"
|
|
85
|
+
local key_color="${3:-$DIM}"
|
|
86
|
+
printf " ${key_color}%-12s${NC} %s\n" "$key" "$value"
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
# Audit logging
|
|
90
|
+
log_event() {
|
|
91
|
+
local event="$1"
|
|
92
|
+
local details="${2:-}"
|
|
93
|
+
local log_file=".golem/golem.log"
|
|
94
|
+
[[ -d ".golem" ]] && echo "[$(date -Iseconds)] $event: $details" >> "$log_file"
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
# Robust completion detection
|
|
98
|
+
is_plan_complete() {
|
|
99
|
+
local plan=".golem/IMPLEMENTATION_PLAN.md"
|
|
100
|
+
[[ ! -f "$plan" ]] && return $EXIT_NO_PLAN
|
|
101
|
+
|
|
102
|
+
# Count unchecked boxes (any format: - [ ], * [ ], ### [ ], etc.)
|
|
103
|
+
# Note: grep -c returns exit 1 when count is 0, so we need || true to prevent pipefail exit
|
|
104
|
+
local unchecked
|
|
105
|
+
unchecked=$(grep -ciE '\[ \]' "$plan" 2>/dev/null | tr -d '[:space:]' || true)
|
|
106
|
+
[[ -z "$unchecked" ]] && unchecked=0
|
|
107
|
+
|
|
108
|
+
# Count checked boxes to verify plan isn't empty
|
|
109
|
+
local checked
|
|
110
|
+
checked=$(grep -ciE '\[[xX]\]' "$plan" 2>/dev/null | tr -d '[:space:]' || true)
|
|
111
|
+
[[ -z "$checked" ]] && checked=0
|
|
112
|
+
|
|
113
|
+
if [[ "$unchecked" -eq 0 ]] && [[ "$checked" -gt 0 ]]; then
|
|
114
|
+
return $EXIT_COMPLETE
|
|
115
|
+
fi
|
|
116
|
+
return $EXIT_INCOMPLETE
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
# Get task counts for display
|
|
120
|
+
get_task_counts() {
|
|
121
|
+
local plan=".golem/IMPLEMENTATION_PLAN.md"
|
|
122
|
+
local unchecked=0
|
|
123
|
+
local checked=0
|
|
124
|
+
|
|
125
|
+
if [[ -f "$plan" ]]; then
|
|
126
|
+
unchecked=$(grep -ciE '\[ \]' "$plan" 2>/dev/null | tr -d '[:space:]' || true)
|
|
127
|
+
checked=$(grep -ciE '\[[xX]\]' "$plan" 2>/dev/null | tr -d '[:space:]' || true)
|
|
128
|
+
[[ -z "$unchecked" ]] && unchecked=0
|
|
129
|
+
[[ -z "$checked" ]] && checked=0
|
|
130
|
+
fi
|
|
131
|
+
|
|
132
|
+
echo "$unchecked $checked"
|
|
133
|
+
}
|
|
134
|
+
|
|
35
135
|
print_banner() {
|
|
36
136
|
echo ""
|
|
37
137
|
echo -e "${CYAN}"
|
|
@@ -54,6 +154,7 @@ print_usage() {
|
|
|
54
154
|
echo " run build Run autonomous build loop"
|
|
55
155
|
echo " simplify [path] Run code simplifier"
|
|
56
156
|
echo " status Show project status"
|
|
157
|
+
echo " status --check Exit 0 if complete, 1 if incomplete, 2 if no plan"
|
|
57
158
|
echo ""
|
|
58
159
|
echo -e "${BLUE}Options:${NC}"
|
|
59
160
|
echo " --install Install golem to current project"
|
|
@@ -65,13 +166,21 @@ print_usage() {
|
|
|
65
166
|
echo " 1. claude → /golem:spec Define requirements (interactive)"
|
|
66
167
|
echo " 2. golem run plan Generate implementation plan"
|
|
67
168
|
echo " 3. golem run build Autonomous build loop"
|
|
169
|
+
echo ""
|
|
170
|
+
echo -e "${BLUE}Scripting:${NC}"
|
|
171
|
+
echo " golem status --check && echo 'Done!' # Check completion"
|
|
172
|
+
echo " while ! golem status --check; do # Loop until complete"
|
|
173
|
+
echo " golem run build --iterations 1"
|
|
174
|
+
echo " done"
|
|
68
175
|
}
|
|
69
176
|
|
|
70
177
|
# Check if golem is installed in current project
|
|
71
178
|
check_installed() {
|
|
72
179
|
if [[ ! -d ".golem" ]]; then
|
|
73
|
-
echo
|
|
74
|
-
|
|
180
|
+
echo ""
|
|
181
|
+
status_line "✗" "$RED" "Golem not installed in this project"
|
|
182
|
+
echo -e " ${DIM}Run: golem --install${NC}"
|
|
183
|
+
echo ""
|
|
75
184
|
exit 1
|
|
76
185
|
fi
|
|
77
186
|
}
|
|
@@ -79,13 +188,13 @@ check_installed() {
|
|
|
79
188
|
# Install golem to current project
|
|
80
189
|
cmd_install() {
|
|
81
190
|
print_banner
|
|
82
|
-
|
|
191
|
+
header_box "INSTALLING" "$BLUE"
|
|
83
192
|
echo ""
|
|
84
193
|
|
|
85
194
|
# Create directories
|
|
86
195
|
mkdir -p .golem/prompts
|
|
87
196
|
mkdir -p .golem/agents
|
|
88
|
-
mkdir -p specs
|
|
197
|
+
mkdir -p .golem/specs
|
|
89
198
|
|
|
90
199
|
# Copy prompts and agents
|
|
91
200
|
local copied_agents=false
|
|
@@ -105,8 +214,8 @@ cmd_install() {
|
|
|
105
214
|
fi
|
|
106
215
|
|
|
107
216
|
# Create AGENTS.md if it doesn't exist
|
|
108
|
-
if [[ ! -f "AGENTS.md" ]]; then
|
|
109
|
-
cat > AGENTS.md << 'EOF'
|
|
217
|
+
if [[ ! -f ".golem/AGENTS.md" ]]; then
|
|
218
|
+
cat > .golem/AGENTS.md << 'EOF'
|
|
110
219
|
# Operational Guide
|
|
111
220
|
|
|
112
221
|
## Commands
|
|
@@ -134,14 +243,14 @@ npm run build
|
|
|
134
243
|
## Learnings
|
|
135
244
|
<!-- Updated during build iterations -->
|
|
136
245
|
EOF
|
|
137
|
-
echo -e "${GREEN}✓${NC} Created AGENTS.md"
|
|
246
|
+
echo -e "${GREEN}✓${NC} Created .golem/AGENTS.md"
|
|
138
247
|
fi
|
|
139
248
|
|
|
140
249
|
# Auto-detect project type
|
|
141
250
|
detect_project
|
|
142
251
|
|
|
143
252
|
echo -e "${GREEN}✓${NC} Created .golem/ directory"
|
|
144
|
-
echo -e "${GREEN}✓${NC} Created specs/ directory"
|
|
253
|
+
echo -e "${GREEN}✓${NC} Created .golem/specs/ directory"
|
|
145
254
|
echo ""
|
|
146
255
|
echo -e "${BLUE}Next steps:${NC}"
|
|
147
256
|
echo -e " 1. Run ${CYAN}claude${NC} then ${CYAN}/golem:spec${NC} to define requirements"
|
|
@@ -168,7 +277,7 @@ detect_project() {
|
|
|
168
277
|
fi
|
|
169
278
|
|
|
170
279
|
# Update AGENTS.md with detected commands
|
|
171
|
-
cat > AGENTS.md << EOF
|
|
280
|
+
cat > .golem/AGENTS.md << EOF
|
|
172
281
|
# Operational Guide
|
|
173
282
|
|
|
174
283
|
## Commands
|
|
@@ -178,28 +287,28 @@ detect_project() {
|
|
|
178
287
|
${test_cmd}
|
|
179
288
|
\`\`\`
|
|
180
289
|
EOF
|
|
181
|
-
[[ -n "$typecheck_cmd" ]] && cat >> AGENTS.md << EOF
|
|
290
|
+
[[ -n "$typecheck_cmd" ]] && cat >> .golem/AGENTS.md << EOF
|
|
182
291
|
|
|
183
292
|
### Type Checking
|
|
184
293
|
\`\`\`bash
|
|
185
294
|
${typecheck_cmd}
|
|
186
295
|
\`\`\`
|
|
187
296
|
EOF
|
|
188
|
-
[[ -n "$lint_cmd" ]] && cat >> AGENTS.md << EOF
|
|
297
|
+
[[ -n "$lint_cmd" ]] && cat >> .golem/AGENTS.md << EOF
|
|
189
298
|
|
|
190
299
|
### Linting
|
|
191
300
|
\`\`\`bash
|
|
192
301
|
${lint_cmd}
|
|
193
302
|
\`\`\`
|
|
194
303
|
EOF
|
|
195
|
-
[[ -n "$build_cmd" ]] && cat >> AGENTS.md << EOF
|
|
304
|
+
[[ -n "$build_cmd" ]] && cat >> .golem/AGENTS.md << EOF
|
|
196
305
|
|
|
197
306
|
### Build
|
|
198
307
|
\`\`\`bash
|
|
199
308
|
${build_cmd}
|
|
200
309
|
\`\`\`
|
|
201
310
|
EOF
|
|
202
|
-
cat >> AGENTS.md << 'EOF'
|
|
311
|
+
cat >> .golem/AGENTS.md << 'EOF'
|
|
203
312
|
|
|
204
313
|
## Learnings
|
|
205
314
|
<!-- Updated during build iterations -->
|
|
@@ -214,16 +323,16 @@ EOF
|
|
|
214
323
|
# Show spec workflow hint
|
|
215
324
|
cmd_spec() {
|
|
216
325
|
print_banner
|
|
217
|
-
|
|
326
|
+
header_box "SPEC BUILDER" "$BLUE"
|
|
218
327
|
echo ""
|
|
219
|
-
echo -e "To build specs, run ${CYAN}claude${NC} and use
|
|
328
|
+
echo -e " To build specs, run ${CYAN}claude${NC} and use ${CYAN}/golem:spec${NC}"
|
|
220
329
|
echo ""
|
|
221
|
-
echo -e "${
|
|
222
|
-
echo -e "
|
|
223
|
-
echo -e "
|
|
224
|
-
echo -e "
|
|
225
|
-
echo -e "
|
|
226
|
-
echo -e "
|
|
330
|
+
echo -e " ${BOLD}Workflow${NC}"
|
|
331
|
+
echo -e " ${DIM}1.${NC} claude ${DIM}Start Claude Code${NC}"
|
|
332
|
+
echo -e " ${DIM}2.${NC} /golem:spec ${DIM}Build specs interactively${NC}"
|
|
333
|
+
echo -e " ${DIM}3.${NC} exit ${DIM}Exit when done${NC}"
|
|
334
|
+
echo -e " ${DIM}4.${NC} golem run plan ${DIM}Generate implementation plan${NC}"
|
|
335
|
+
echo -e " ${DIM}5.${NC} golem run build ${DIM}Run autonomous build loop${NC}"
|
|
227
336
|
echo ""
|
|
228
337
|
}
|
|
229
338
|
|
|
@@ -271,55 +380,34 @@ cmd_run() {
|
|
|
271
380
|
|
|
272
381
|
run_plan_mode() {
|
|
273
382
|
print_banner
|
|
274
|
-
|
|
275
|
-
echo
|
|
383
|
+
header_box "PLANNING" "$BLUE"
|
|
384
|
+
echo ""
|
|
385
|
+
echo -e " ${DIM}Analyzing specs and creating implementation plan...${NC}"
|
|
276
386
|
echo ""
|
|
277
387
|
|
|
278
|
-
#
|
|
279
|
-
local prompt_file
|
|
280
|
-
trap "rm -f $prompt_file" EXIT
|
|
281
|
-
|
|
282
|
-
cat > "$prompt_file" << 'PROMPT_HEADER'
|
|
283
|
-
You are in PLANNING MODE. Your job is to analyze the specs and create IMPLEMENTATION_PLAN.md.
|
|
284
|
-
|
|
285
|
-
DO NOT implement anything. Only create the plan.
|
|
286
|
-
|
|
287
|
-
PROMPT_HEADER
|
|
288
|
-
|
|
289
|
-
# Add planning prompt if available
|
|
388
|
+
# Find prompt file (uses @file references for context)
|
|
389
|
+
local prompt_file=""
|
|
290
390
|
if [[ -f ".golem/prompts/PROMPT_plan.md" ]]; then
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
echo "# Specs" >> "$prompt_file"
|
|
298
|
-
echo "" >> "$prompt_file"
|
|
299
|
-
|
|
300
|
-
for spec in specs/*.md; do
|
|
301
|
-
if [[ -f "$spec" ]]; then
|
|
302
|
-
echo "## $(basename "$spec" .md)" >> "$prompt_file"
|
|
303
|
-
echo "" >> "$prompt_file"
|
|
304
|
-
cat "$spec" >> "$prompt_file"
|
|
305
|
-
echo "" >> "$prompt_file"
|
|
306
|
-
fi
|
|
307
|
-
done
|
|
308
|
-
|
|
309
|
-
if [[ -f "AGENTS.md" ]]; then
|
|
310
|
-
echo "---" >> "$prompt_file"
|
|
311
|
-
echo "" >> "$prompt_file"
|
|
312
|
-
echo "# Operational Guide" >> "$prompt_file"
|
|
313
|
-
echo "" >> "$prompt_file"
|
|
314
|
-
cat AGENTS.md >> "$prompt_file"
|
|
391
|
+
prompt_file=".golem/prompts/PROMPT_plan.md"
|
|
392
|
+
elif [[ -f "$GOLEM_DIR/golem/prompts/PROMPT_plan.md" ]]; then
|
|
393
|
+
prompt_file="$GOLEM_DIR/golem/prompts/PROMPT_plan.md"
|
|
394
|
+
else
|
|
395
|
+
status_line "✗" "$RED" "No PROMPT_plan.md found. Run golem --install first."
|
|
396
|
+
exit 1
|
|
315
397
|
fi
|
|
316
398
|
|
|
317
|
-
#
|
|
318
|
-
cat "$prompt_file" | claude -p
|
|
399
|
+
# Ralph pattern: cat PROMPT | claude -p
|
|
400
|
+
cat "$prompt_file" | claude -p \
|
|
401
|
+
--dangerously-skip-permissions \
|
|
402
|
+
--model opus \
|
|
403
|
+
--verbose
|
|
319
404
|
|
|
320
405
|
echo ""
|
|
321
|
-
|
|
322
|
-
echo
|
|
406
|
+
header_box "PLANNING COMPLETE" "$GREEN"
|
|
407
|
+
echo ""
|
|
408
|
+
status_line "✓" "$GREEN" "Implementation plan created"
|
|
409
|
+
echo -e " ${DIM}Next:${NC} golem run build"
|
|
410
|
+
echo ""
|
|
323
411
|
}
|
|
324
412
|
|
|
325
413
|
run_build_loop() {
|
|
@@ -329,181 +417,96 @@ run_build_loop() {
|
|
|
329
417
|
print_banner
|
|
330
418
|
|
|
331
419
|
# Verify prerequisites
|
|
332
|
-
if [[ ! -f "IMPLEMENTATION_PLAN.md" ]]; then
|
|
333
|
-
echo
|
|
334
|
-
|
|
335
|
-
|
|
420
|
+
if [[ ! -f ".golem/IMPLEMENTATION_PLAN.md" ]]; then
|
|
421
|
+
echo ""
|
|
422
|
+
status_line "!" "$YELLOW" "No implementation plan found"
|
|
423
|
+
echo -e " ${DIM}Run: golem run plan${NC}"
|
|
424
|
+
echo ""
|
|
425
|
+
log_event "BUILD_ABORT" "No implementation plan found"
|
|
426
|
+
exit $EXIT_NO_PLAN
|
|
336
427
|
fi
|
|
337
428
|
|
|
338
|
-
if [[ ! -d "specs" ]] || [[ -z "$(ls -A specs/*.md 2>/dev/null)" ]]; then
|
|
339
|
-
echo
|
|
340
|
-
|
|
341
|
-
|
|
429
|
+
if [[ ! -d ".golem/specs" ]] || [[ -z "$(ls -A .golem/specs/*.md 2>/dev/null)" ]]; then
|
|
430
|
+
echo ""
|
|
431
|
+
status_line "!" "$YELLOW" "No specs found"
|
|
432
|
+
echo -e " ${DIM}Run: /golem:spec in Claude first${NC}"
|
|
433
|
+
echo ""
|
|
434
|
+
log_event "BUILD_ABORT" "No specs found"
|
|
435
|
+
exit $EXIT_ERROR
|
|
342
436
|
fi
|
|
343
437
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
if [[
|
|
347
|
-
|
|
438
|
+
# Find prompt file
|
|
439
|
+
local build_prompt=""
|
|
440
|
+
if [[ -f ".golem/prompts/PROMPT_build.md" ]]; then
|
|
441
|
+
build_prompt=".golem/prompts/PROMPT_build.md"
|
|
442
|
+
elif [[ -f "$GOLEM_DIR/golem/prompts/PROMPT_build.md" ]]; then
|
|
443
|
+
build_prompt="$GOLEM_DIR/golem/prompts/PROMPT_build.md"
|
|
444
|
+
else
|
|
445
|
+
status_line "✗" "$RED" "No PROMPT_build.md found"
|
|
446
|
+
echo -e " ${DIM}Run: golem --install${NC}"
|
|
447
|
+
log_event "BUILD_ABORT" "No PROMPT_build.md found"
|
|
448
|
+
exit $EXIT_ERROR
|
|
348
449
|
fi
|
|
349
|
-
|
|
450
|
+
|
|
451
|
+
header_box "BUILD LOOP" "$CYAN"
|
|
350
452
|
|
|
351
453
|
local iteration=0
|
|
352
454
|
local start_time=$(date +%s)
|
|
353
|
-
|
|
354
|
-
trap "rm -f $prompt_file" EXIT
|
|
455
|
+
log_event "BUILD_START" "max_iterations=${max_iterations:-unlimited} simplify=$simplify"
|
|
355
456
|
|
|
457
|
+
# Ralph loop: while :; do cat PROMPT | claude -p; done
|
|
356
458
|
while true; do
|
|
459
|
+
# Check completion BEFORE incrementing iteration
|
|
460
|
+
if is_plan_complete; then
|
|
461
|
+
log_event "BUILD_COMPLETE" "All tasks done after $iteration iterations"
|
|
462
|
+
break
|
|
463
|
+
fi
|
|
464
|
+
|
|
357
465
|
iteration=$((iteration + 1))
|
|
358
466
|
|
|
359
467
|
# Check iteration limit
|
|
360
468
|
if [[ -n "$max_iterations" ]] && [[ $iteration -gt $max_iterations ]]; then
|
|
361
|
-
echo
|
|
469
|
+
echo ""
|
|
470
|
+
status_line "◦" "$YELLOW" "Reached iteration limit ($max_iterations)"
|
|
471
|
+
log_event "BUILD_LIMIT" "Stopped at iteration $iteration (limit: $max_iterations)"
|
|
362
472
|
break
|
|
363
473
|
fi
|
|
364
474
|
|
|
365
|
-
#
|
|
366
|
-
|
|
367
|
-
if [[ "$remaining" == "0" ]]; then
|
|
368
|
-
echo -e "${GREEN}All tasks completed!${NC}"
|
|
369
|
-
break
|
|
370
|
-
fi
|
|
475
|
+
# Get task counts for display
|
|
476
|
+
read -r remaining checked <<< "$(get_task_counts)"
|
|
371
477
|
|
|
372
478
|
echo ""
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
479
|
+
hr "─" "$BLUE"
|
|
480
|
+
local total=$((remaining + checked))
|
|
481
|
+
local progress_pct=0
|
|
482
|
+
[[ $total -gt 0 ]] && progress_pct=$((checked * 100 / total))
|
|
483
|
+
echo -e "${BLUE} ▸ Iteration ${BOLD}$iteration${NC}${BLUE} Tasks: ${GREEN}$checked${BLUE}/${total} ${DIM}($progress_pct%)${NC}"
|
|
484
|
+
hr "─" "$BLUE"
|
|
485
|
+
|
|
486
|
+
local iter_start=$(date +%s)
|
|
487
|
+
log_event "ITERATION_START" "iteration=$iteration remaining=$remaining"
|
|
488
|
+
|
|
489
|
+
# Ralph pattern: cat PROMPT | claude -p
|
|
490
|
+
local claude_exit=0
|
|
491
|
+
cat "$build_prompt" | claude -p \
|
|
492
|
+
--dangerously-skip-permissions \
|
|
493
|
+
--model opus \
|
|
494
|
+
--verbose || claude_exit=$?
|
|
495
|
+
|
|
496
|
+
local iter_end=$(date +%s)
|
|
497
|
+
local iter_duration=$((iter_end - iter_start))
|
|
498
|
+
log_event "ITERATION_END" "iteration=$iteration exit_code=$claude_exit duration=${iter_duration}s"
|
|
499
|
+
|
|
500
|
+
# Push changes after each iteration (like Ralph)
|
|
501
|
+
local current_branch=$(git branch --show-current)
|
|
502
|
+
git push origin "$current_branch" 2>/dev/null || {
|
|
503
|
+
echo -e " ${DIM}Creating remote branch...${NC}"
|
|
504
|
+
git push -u origin "$current_branch" 2>/dev/null || true
|
|
505
|
+
}
|
|
376
506
|
|
|
377
|
-
# ═══════════════════════════════════════════════════════════
|
|
378
|
-
# STEP 1: IMPLEMENT
|
|
379
|
-
# ═══════════════════════════════════════════════════════════
|
|
380
507
|
echo ""
|
|
381
|
-
echo -e "${
|
|
382
|
-
|
|
383
|
-
# Build prompt file (Ralph pattern)
|
|
384
|
-
cat > "$prompt_file" << 'IMPLEMENT_HEADER'
|
|
385
|
-
You are in BUILD MODE. Complete ONE task from the plan.
|
|
386
|
-
|
|
387
|
-
DO NOT commit - just implement, test, update the plan, and stage changes.
|
|
388
|
-
The commit will happen after simplification.
|
|
389
|
-
|
|
390
|
-
IMPLEMENT_HEADER
|
|
391
|
-
|
|
392
|
-
# Add build prompt if available
|
|
393
|
-
if [[ -f ".golem/prompts/PROMPT_build.md" ]]; then
|
|
394
|
-
cat .golem/prompts/PROMPT_build.md >> "$prompt_file"
|
|
395
|
-
echo "" >> "$prompt_file"
|
|
396
|
-
fi
|
|
397
|
-
|
|
398
|
-
echo "---" >> "$prompt_file"
|
|
399
|
-
echo "" >> "$prompt_file"
|
|
400
|
-
echo "# Specs" >> "$prompt_file"
|
|
401
|
-
echo "" >> "$prompt_file"
|
|
402
|
-
|
|
403
|
-
for spec in specs/*.md; do
|
|
404
|
-
if [[ -f "$spec" ]]; then
|
|
405
|
-
echo "## $(basename "$spec" .md)" >> "$prompt_file"
|
|
406
|
-
echo "" >> "$prompt_file"
|
|
407
|
-
cat "$spec" >> "$prompt_file"
|
|
408
|
-
echo "" >> "$prompt_file"
|
|
409
|
-
fi
|
|
410
|
-
done
|
|
411
|
-
|
|
412
|
-
if [[ -f "AGENTS.md" ]]; then
|
|
413
|
-
echo "---" >> "$prompt_file"
|
|
414
|
-
echo "" >> "$prompt_file"
|
|
415
|
-
echo "# Operational Guide" >> "$prompt_file"
|
|
416
|
-
echo "" >> "$prompt_file"
|
|
417
|
-
cat AGENTS.md >> "$prompt_file"
|
|
418
|
-
echo "" >> "$prompt_file"
|
|
419
|
-
fi
|
|
420
|
-
|
|
421
|
-
echo "---" >> "$prompt_file"
|
|
422
|
-
echo "" >> "$prompt_file"
|
|
423
|
-
echo "# Implementation Plan" >> "$prompt_file"
|
|
424
|
-
echo "" >> "$prompt_file"
|
|
425
|
-
cat IMPLEMENTATION_PLAN.md >> "$prompt_file"
|
|
426
|
-
|
|
427
|
-
# Run implementation (Ralph pattern: cat PROMPT | claude -p)
|
|
428
|
-
cat "$prompt_file" | claude -p --dangerously-skip-permissions
|
|
429
|
-
|
|
430
|
-
local exit_code=$?
|
|
431
|
-
if [[ $exit_code -ne 0 ]]; then
|
|
432
|
-
echo -e "${RED}Implementation step exited with error code $exit_code${NC}"
|
|
433
|
-
fi
|
|
434
|
-
|
|
435
|
-
# ═══════════════════════════════════════════════════════════
|
|
436
|
-
# STEP 2: SIMPLIFY + COMMIT
|
|
437
|
-
# ═══════════════════════════════════════════════════════════
|
|
508
|
+
echo -e "${DIM} ─────────────────────────────────────────────────────────${NC}"
|
|
438
509
|
echo ""
|
|
439
|
-
echo -e "${GREEN}▶ Step 2: Simplify + Commit${NC}"
|
|
440
|
-
|
|
441
|
-
# Get staged files
|
|
442
|
-
local staged_files=$(git diff --cached --name-only 2>/dev/null | grep -E '\.(ts|tsx|js|jsx|py|go|rs|vue)$' | grep -v '\.test\.' | grep -v '\.spec\.' | head -10)
|
|
443
|
-
|
|
444
|
-
# Build simplify prompt file
|
|
445
|
-
cat > "$prompt_file" << 'SIMPLIFY_HEADER'
|
|
446
|
-
You are in SIMPLIFY + COMMIT MODE.
|
|
447
|
-
|
|
448
|
-
SIMPLIFY_HEADER
|
|
449
|
-
|
|
450
|
-
if [[ "$simplify" == "true" ]] && [[ -n "$staged_files" ]]; then
|
|
451
|
-
cat >> "$prompt_file" << 'SIMPLIFY_INSTRUCTIONS'
|
|
452
|
-
1. Simplify the staged source files (not tests)
|
|
453
|
-
2. Run tests to verify no regressions
|
|
454
|
-
3. Stage any changes from simplification
|
|
455
|
-
4. Create a single commit with a comprehensive message
|
|
456
|
-
|
|
457
|
-
SIMPLIFY_INSTRUCTIONS
|
|
458
|
-
|
|
459
|
-
# Add code-simplifier agent if available
|
|
460
|
-
if [[ -f ".golem/agents/code-simplifier.md" ]]; then
|
|
461
|
-
cat .golem/agents/code-simplifier.md >> "$prompt_file"
|
|
462
|
-
echo "" >> "$prompt_file"
|
|
463
|
-
fi
|
|
464
|
-
|
|
465
|
-
echo "---" >> "$prompt_file"
|
|
466
|
-
echo "" >> "$prompt_file"
|
|
467
|
-
echo "# Staged source files to simplify" >> "$prompt_file"
|
|
468
|
-
echo "" >> "$prompt_file"
|
|
469
|
-
echo "$staged_files" >> "$prompt_file"
|
|
470
|
-
echo "" >> "$prompt_file"
|
|
471
|
-
else
|
|
472
|
-
cat >> "$prompt_file" << 'NO_SIMPLIFY'
|
|
473
|
-
No source files to simplify. Just create the commit.
|
|
474
|
-
|
|
475
|
-
Use conventional commit format with a descriptive body.
|
|
476
|
-
|
|
477
|
-
NO_SIMPLIFY
|
|
478
|
-
fi
|
|
479
|
-
|
|
480
|
-
# Get current task for commit context
|
|
481
|
-
local current_task=$(grep -A3 '^\- \[ \]' IMPLEMENTATION_PLAN.md 2>/dev/null | head -4)
|
|
482
|
-
echo "---" >> "$prompt_file"
|
|
483
|
-
echo "" >> "$prompt_file"
|
|
484
|
-
echo "# Task that was just completed" >> "$prompt_file"
|
|
485
|
-
echo "" >> "$prompt_file"
|
|
486
|
-
echo "$current_task" >> "$prompt_file"
|
|
487
|
-
echo "" >> "$prompt_file"
|
|
488
|
-
|
|
489
|
-
if [[ -f "AGENTS.md" ]]; then
|
|
490
|
-
echo "---" >> "$prompt_file"
|
|
491
|
-
echo "" >> "$prompt_file"
|
|
492
|
-
echo "# Operational Guide (for running tests)" >> "$prompt_file"
|
|
493
|
-
echo "" >> "$prompt_file"
|
|
494
|
-
cat AGENTS.md >> "$prompt_file"
|
|
495
|
-
fi
|
|
496
|
-
|
|
497
|
-
# Run simplify + commit (Ralph pattern)
|
|
498
|
-
cat "$prompt_file" | claude -p --dangerously-skip-permissions
|
|
499
|
-
|
|
500
|
-
exit_code=$?
|
|
501
|
-
if [[ $exit_code -ne 0 ]]; then
|
|
502
|
-
echo -e "${RED}Simplify + commit step exited with error code $exit_code${NC}"
|
|
503
|
-
fi
|
|
504
|
-
|
|
505
|
-
# Brief pause between iterations
|
|
506
|
-
sleep 2
|
|
507
510
|
done
|
|
508
511
|
|
|
509
512
|
local end_time=$(date +%s)
|
|
@@ -511,18 +514,25 @@ NO_SIMPLIFY
|
|
|
511
514
|
local minutes=$((duration / 60))
|
|
512
515
|
local seconds=$((duration % 60))
|
|
513
516
|
|
|
517
|
+
read -r remaining checked <<< "$(get_task_counts)"
|
|
518
|
+
local total=$((remaining + checked))
|
|
519
|
+
|
|
520
|
+
echo ""
|
|
521
|
+
header_box "BUILD COMPLETE" "$GREEN"
|
|
514
522
|
echo ""
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
523
|
+
kv_line "Iterations" "$iteration"
|
|
524
|
+
kv_line "Duration" "${minutes}m ${seconds}s"
|
|
525
|
+
kv_line "Tasks" "$checked / $total completed"
|
|
526
|
+
|
|
527
|
+
if [[ $remaining -eq 0 ]]; then
|
|
528
|
+
echo ""
|
|
529
|
+
status_line "✓" "$GREEN" "All tasks completed successfully"
|
|
530
|
+
else
|
|
531
|
+
echo ""
|
|
532
|
+
status_line "◦" "$YELLOW" "$remaining tasks remaining"
|
|
525
533
|
fi
|
|
534
|
+
|
|
535
|
+
log_event "BUILD_SUMMARY" "iterations=$iteration duration=${duration}s completed=$checked remaining=$remaining"
|
|
526
536
|
echo ""
|
|
527
537
|
}
|
|
528
538
|
|
|
@@ -530,7 +540,9 @@ cmd_simplify() {
|
|
|
530
540
|
local target="${1:-.}"
|
|
531
541
|
check_installed
|
|
532
542
|
print_banner
|
|
533
|
-
|
|
543
|
+
header_box "SIMPLIFY" "$BLUE"
|
|
544
|
+
echo ""
|
|
545
|
+
echo -e " ${DIM}Target:${NC} $target"
|
|
534
546
|
echo ""
|
|
535
547
|
|
|
536
548
|
if [[ -f ".golem/agents/code-simplifier.md" ]]; then
|
|
@@ -543,44 +555,72 @@ cmd_simplify() {
|
|
|
543
555
|
}
|
|
544
556
|
|
|
545
557
|
cmd_status() {
|
|
558
|
+
local check_only=false
|
|
559
|
+
|
|
560
|
+
# Parse options
|
|
561
|
+
while [[ $# -gt 0 ]]; do
|
|
562
|
+
case $1 in
|
|
563
|
+
--check)
|
|
564
|
+
check_only=true
|
|
565
|
+
shift
|
|
566
|
+
;;
|
|
567
|
+
*)
|
|
568
|
+
shift
|
|
569
|
+
;;
|
|
570
|
+
esac
|
|
571
|
+
done
|
|
572
|
+
|
|
573
|
+
# --check mode: just return exit code, no output
|
|
574
|
+
if [[ "$check_only" == "true" ]]; then
|
|
575
|
+
is_plan_complete
|
|
576
|
+
exit $?
|
|
577
|
+
fi
|
|
578
|
+
|
|
546
579
|
check_installed
|
|
547
580
|
print_banner
|
|
548
|
-
|
|
549
|
-
echo -e "${BLUE}PROJECT STATUS${NC}"
|
|
550
|
-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
581
|
+
header_box "PROJECT STATUS" "$BLUE"
|
|
551
582
|
echo ""
|
|
552
583
|
|
|
553
584
|
# Specs
|
|
554
|
-
echo -e "${
|
|
555
|
-
if [[ -d "specs" ]]; then
|
|
556
|
-
local count=$(ls -1 specs/*.md 2>/dev/null | wc -l | tr -d ' ')
|
|
557
|
-
|
|
558
|
-
for f in specs/*.md; do
|
|
559
|
-
[[ -f "$f" ]] && echo "
|
|
585
|
+
echo -e " ${BOLD}Specs${NC}"
|
|
586
|
+
if [[ -d ".golem/specs" ]]; then
|
|
587
|
+
local count=$(ls -1 .golem/specs/*.md 2>/dev/null | wc -l | tr -d ' ')
|
|
588
|
+
kv_line "Files" "$count"
|
|
589
|
+
for f in .golem/specs/*.md; do
|
|
590
|
+
[[ -f "$f" ]] && echo -e " ${DIM}•${NC} $(basename "$f" .md)"
|
|
560
591
|
done
|
|
561
592
|
else
|
|
562
|
-
echo "
|
|
593
|
+
echo -e " ${DIM}No specs directory${NC}"
|
|
563
594
|
fi
|
|
564
595
|
echo ""
|
|
565
596
|
|
|
566
597
|
# Plan
|
|
567
|
-
echo -e "${
|
|
568
|
-
if [[ -f "IMPLEMENTATION_PLAN.md" ]]; then
|
|
569
|
-
|
|
570
|
-
local
|
|
571
|
-
local
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
598
|
+
echo -e " ${BOLD}Implementation Plan${NC}"
|
|
599
|
+
if [[ -f ".golem/IMPLEMENTATION_PLAN.md" ]]; then
|
|
600
|
+
read -r remaining checked <<< "$(get_task_counts)"
|
|
601
|
+
local total=$((remaining + checked))
|
|
602
|
+
local progress_pct=0
|
|
603
|
+
[[ $total -gt 0 ]] && progress_pct=$((checked * 100 / total))
|
|
604
|
+
|
|
605
|
+
kv_line "Progress" "$checked / $total tasks ($progress_pct%)"
|
|
606
|
+
|
|
607
|
+
if is_plan_complete; then
|
|
608
|
+
status_line "✓" "$GREEN" "Complete"
|
|
609
|
+
else
|
|
610
|
+
status_line "◦" "$YELLOW" "In progress ($remaining remaining)"
|
|
611
|
+
fi
|
|
575
612
|
else
|
|
576
|
-
echo "
|
|
613
|
+
echo -e " ${DIM}No plan yet${NC}"
|
|
614
|
+
echo -e " ${DIM}Run: golem run plan${NC}"
|
|
577
615
|
fi
|
|
578
616
|
echo ""
|
|
579
617
|
|
|
580
618
|
# Git
|
|
581
619
|
if git rev-parse --is-inside-work-tree &>/dev/null; then
|
|
582
|
-
echo -e "${
|
|
583
|
-
git log --oneline -5 2>/dev/null
|
|
620
|
+
echo -e " ${BOLD}Recent Commits${NC}"
|
|
621
|
+
git log --oneline -5 2>/dev/null | while read -r line; do
|
|
622
|
+
echo -e " ${DIM}•${NC} $line"
|
|
623
|
+
done || echo -e " ${DIM}No commits yet${NC}"
|
|
584
624
|
fi
|
|
585
625
|
echo ""
|
|
586
626
|
}
|
|
@@ -613,7 +653,8 @@ main() {
|
|
|
613
653
|
cmd_simplify "$@"
|
|
614
654
|
;;
|
|
615
655
|
status)
|
|
616
|
-
|
|
656
|
+
shift
|
|
657
|
+
cmd_status "$@"
|
|
617
658
|
;;
|
|
618
659
|
"")
|
|
619
660
|
# No command - just launch claude
|
package/bin/install.cjs
CHANGED
|
@@ -127,11 +127,17 @@ golem() {
|
|
|
127
127
|
content = fs.readFileSync(configPath, 'utf8');
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
// Remove old golem function/alias
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
// Remove ALL old golem function/alias definitions
|
|
131
|
+
// Match golem() function blocks (various formats)
|
|
132
|
+
content = content.replace(/\n# Golem[^\n]*\n# Installed by:[^\n]*\ngolem\(\) \{[\s\S]*?\n\}\n?/g, '\n');
|
|
133
|
+
content = content.replace(/\n# Golem alias for Claude Code\ngolem\(\) \{[\s\S]*?\n\}\n?/g, '\n');
|
|
134
|
+
// Match old-style alias definitions (from golem --install)
|
|
135
|
+
content = content.replace(/\n# Added by: golem --install[^\n]*\n[^\n]*\nalias golem=[^\n]*\n?/g, '\n');
|
|
136
|
+
content = content.replace(/\n# Golem alias[^\n]*\nalias golem=[^\n]*\n?/g, '\n');
|
|
137
|
+
// Clean up any standalone alias golem= lines
|
|
138
|
+
content = content.replace(/\nalias golem=[^\n]*\n?/g, '\n');
|
|
139
|
+
// Clean up multiple consecutive newlines
|
|
140
|
+
content = content.replace(/\n{3,}/g, '\n\n');
|
|
135
141
|
|
|
136
142
|
content = content.trimEnd() + '\n' + golemFunction;
|
|
137
143
|
fs.writeFileSync(configPath, content);
|
|
@@ -1,60 +1,47 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
You are
|
|
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
|
-
- Add new tasks if implementation revealed missing work
|
|
49
|
-
|
|
50
|
-
### Staging (No Commit!)
|
|
51
|
-
Run `git add` on the files you changed, but DO NOT commit.
|
|
52
|
-
The commit will happen after the simplification step.
|
|
53
|
-
|
|
54
|
-
## Important
|
|
55
|
-
|
|
56
|
-
- Complete ONE task per iteration, then exit
|
|
57
|
-
- Fresh context on next iteration will continue from updated plan
|
|
58
|
-
- If stuck on a task for more than 3 attempts, mark it blocked and move on
|
|
59
|
-
- Trust the tests - if they pass, the implementation is correct
|
|
60
|
-
- DO NOT commit - simplification step will handle that
|
|
1
|
+
# Build Mode
|
|
2
|
+
|
|
3
|
+
You are in BUILD MODE. Implement ONE task from the plan, then exit.
|
|
4
|
+
|
|
5
|
+
## Phase 0: Orient
|
|
6
|
+
|
|
7
|
+
Study these files to understand context:
|
|
8
|
+
- @specs/* - All specification files
|
|
9
|
+
- @AGENTS.md - Operational commands (test/build/lint)
|
|
10
|
+
- @IMPLEMENTATION_PLAN.md - Current task list
|
|
11
|
+
|
|
12
|
+
## Phase 1: Select Task
|
|
13
|
+
|
|
14
|
+
1. Read IMPLEMENTATION_PLAN.md
|
|
15
|
+
2. Pick the first incomplete task (marked `- [ ]`)
|
|
16
|
+
3. Do NOT assume something is not implemented - search first
|
|
17
|
+
|
|
18
|
+
## Phase 2: Implement
|
|
19
|
+
|
|
20
|
+
1. Search codebase to understand existing patterns
|
|
21
|
+
2. Make the required changes
|
|
22
|
+
3. Follow existing code patterns exactly
|
|
23
|
+
4. Write tests alongside implementation
|
|
24
|
+
|
|
25
|
+
## Phase 3: Validate (Backpressure)
|
|
26
|
+
|
|
27
|
+
Run commands from AGENTS.md in order. ALL must pass:
|
|
28
|
+
1. Tests
|
|
29
|
+
2. Type check (if configured)
|
|
30
|
+
3. Lint (if configured)
|
|
31
|
+
|
|
32
|
+
If ANY fails: fix the issue, then re-run ALL validation from the beginning.
|
|
33
|
+
|
|
34
|
+
## Phase 4: Complete
|
|
35
|
+
|
|
36
|
+
1. Update IMPLEMENTATION_PLAN.md - mark task `- [x]`
|
|
37
|
+
2. Update AGENTS.md learnings if you discovered something useful
|
|
38
|
+
3. Commit changes with descriptive message
|
|
39
|
+
4. Exit
|
|
40
|
+
|
|
41
|
+
## Phase 999: Critical Rules
|
|
42
|
+
|
|
43
|
+
- Complete ONE task only per iteration
|
|
44
|
+
- Do NOT skip validation - all gates must pass
|
|
45
|
+
- Do NOT assume code doesn't exist - always search first
|
|
46
|
+
- Trust the tests - passing = correct
|
|
47
|
+
- Exit after committing so next iteration gets fresh context
|
|
@@ -1,84 +1,54 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
You are operating in **planning mode** - your job is to analyze specs versus existing code and create/update the implementation plan.
|
|
4
|
-
|
|
5
|
-
## Execution Flow
|
|
6
|
-
|
|
7
|
-
1. **Read Specs** - Understand all requirements from specs/*.md
|
|
8
|
-
2. **Analyze Code** - Search the codebase to understand current state
|
|
9
|
-
3. **Gap Analysis** - Identify what needs to be built vs. what exists
|
|
10
|
-
4. **Prioritize** - Order tasks by dependencies and criticality
|
|
11
|
-
5. **Generate Plan** - Create/update IMPLEMENTATION_PLAN.md
|
|
12
|
-
|
|
13
|
-
## Rules
|
|
14
|
-
|
|
15
|
-
### Spec Analysis
|
|
16
|
-
- Read each spec file completely
|
|
17
|
-
- Extract concrete requirements (must have, should have)
|
|
18
|
-
- Note acceptance criteria and constraints
|
|
19
|
-
- Identify dependencies between specs
|
|
20
|
-
|
|
21
|
-
### Code Analysis
|
|
22
|
-
- Search for existing implementations
|
|
23
|
-
- Understand current architecture and patterns
|
|
24
|
-
- Identify reusable components
|
|
25
|
-
- Note technical debt or issues
|
|
26
|
-
|
|
27
|
-
### Gap Analysis
|
|
28
|
-
For each requirement, determine:
|
|
29
|
-
- **Done**: Already implemented and tested
|
|
30
|
-
- **Partial**: Partially implemented, needs completion
|
|
31
|
-
- **Missing**: Not implemented at all
|
|
32
|
-
- **Blocked**: Depends on something not yet built
|
|
33
|
-
|
|
34
|
-
### Task Generation
|
|
35
|
-
Each task should be:
|
|
36
|
-
- **Atomic** - Completable in one focused session
|
|
37
|
-
- **Testable** - Has clear verification criteria
|
|
38
|
-
- **Scoped** - Affects 1-3 files typically
|
|
39
|
-
- **Independent** - Minimal dependencies on other tasks
|
|
40
|
-
|
|
41
|
-
Bad task: "Implement authentication"
|
|
42
|
-
Good task: "Implement user registration with email/password"
|
|
43
|
-
|
|
44
|
-
### Priority Rules
|
|
45
|
-
Order tasks by:
|
|
46
|
-
1. **Critical path** - What blocks other work?
|
|
47
|
-
2. **Dependencies** - What must be built first?
|
|
48
|
-
3. **Risk** - Tackle unknowns early
|
|
49
|
-
4. **Value** - Higher value tasks before nice-to-haves
|
|
1
|
+
# Planning Mode
|
|
50
2
|
|
|
51
|
-
|
|
3
|
+
You are in PLANNING MODE. Analyze specs vs existing code and create IMPLEMENTATION_PLAN.md.
|
|
52
4
|
|
|
53
|
-
|
|
5
|
+
## Phase 0: Orient
|
|
54
6
|
|
|
55
|
-
|
|
56
|
-
|
|
7
|
+
Study these files first:
|
|
8
|
+
- @specs/* - All specification files
|
|
9
|
+
- @AGENTS.md - Operational commands
|
|
10
|
+
- @IMPLEMENTATION_PLAN.md - Current plan (if exists)
|
|
11
|
+
|
|
12
|
+
## Phase 1: Gap Analysis
|
|
13
|
+
|
|
14
|
+
1. Read ALL spec files thoroughly
|
|
15
|
+
2. Search the codebase extensively - use parallel subagents
|
|
16
|
+
3. Do NOT assume something is missing - verify by searching
|
|
17
|
+
4. Compare specs vs existing code
|
|
18
|
+
5. Identify what's implemented vs what's missing
|
|
19
|
+
|
|
20
|
+
## Phase 2: Create Plan
|
|
57
21
|
|
|
58
|
-
|
|
59
|
-
Based on: specs/*.md
|
|
22
|
+
Write `IMPLEMENTATION_PLAN.md` with prioritized tasks:
|
|
60
23
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
- Completed: 0
|
|
64
|
-
- Remaining: N
|
|
24
|
+
```markdown
|
|
25
|
+
# Implementation Plan
|
|
65
26
|
|
|
66
27
|
## Tasks
|
|
67
28
|
|
|
68
|
-
|
|
69
|
-
Priority: Critical|High|Medium|Low
|
|
70
|
-
Files: {
|
|
71
|
-
|
|
72
|
-
Depends on: {task numbers if any}
|
|
29
|
+
- [ ] 1. {Task title}
|
|
30
|
+
Priority: Critical|High|Medium|Low
|
|
31
|
+
Files: {files to create/modify}
|
|
32
|
+
Why: {capture the reasoning}
|
|
73
33
|
|
|
74
|
-
|
|
75
|
-
...
|
|
34
|
+
- [ ] 2. {Next task}
|
|
35
|
+
...
|
|
76
36
|
```
|
|
77
37
|
|
|
78
|
-
|
|
38
|
+
Order tasks by:
|
|
39
|
+
1. Dependencies first (what blocks other work)
|
|
40
|
+
2. Critical path (what's essential for MVP)
|
|
41
|
+
3. Value (highest impact)
|
|
42
|
+
|
|
43
|
+
## Phase 3: Exit
|
|
44
|
+
|
|
45
|
+
After writing the plan, exit immediately.
|
|
46
|
+
|
|
47
|
+
## Phase 999: Critical Rules
|
|
79
48
|
|
|
80
|
-
- Do NOT
|
|
81
|
-
-
|
|
82
|
-
-
|
|
49
|
+
- Do NOT assume something is not implemented - search first
|
|
50
|
+
- Each task must be atomic (completable in one iteration)
|
|
51
|
+
- Do NOT modify any source code
|
|
52
|
+
- Do NOT implement anything - only create the plan
|
|
83
53
|
- Be thorough - missing tasks cause problems later
|
|
84
|
-
-
|
|
54
|
+
- Capture "the why" for each task
|