golem-cc 0.1.13 → 0.1.14

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.
Files changed (2) hide show
  1. package/bin/golem +106 -45
  2. package/package.json +1 -1
package/bin/golem CHANGED
@@ -275,30 +275,47 @@ run_plan_mode() {
275
275
  echo -e "${DIM}Analyzing specs and creating implementation plan.${NC}"
276
276
  echo ""
277
277
 
278
- # Build context
279
- local context=""
280
- context+="You are in PLANNING MODE. Analyze the specs and create IMPLEMENTATION_PLAN.md.\n\n"
281
- context+="DO NOT implement anything. Only create the plan.\n\n"
278
+ # Build prompt file (Ralph pattern: cat file | claude)
279
+ local prompt_file=$(mktemp)
280
+ trap "rm -f $prompt_file" EXIT
282
281
 
283
- # Add prompts if available
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
284
290
  if [[ -f ".golem/prompts/PROMPT_plan.md" ]]; then
285
- context+="$(cat .golem/prompts/PROMPT_plan.md)\n\n"
291
+ cat .golem/prompts/PROMPT_plan.md >> "$prompt_file"
292
+ echo "" >> "$prompt_file"
286
293
  fi
287
294
 
288
- context+="---\n\n# Specs\n\n"
295
+ echo "---" >> "$prompt_file"
296
+ echo "" >> "$prompt_file"
297
+ echo "# Specs" >> "$prompt_file"
298
+ echo "" >> "$prompt_file"
299
+
289
300
  for spec in specs/*.md; do
290
301
  if [[ -f "$spec" ]]; then
291
- context+="## $(basename "$spec" .md)\n\n"
292
- context+="$(cat "$spec")\n\n"
302
+ echo "## $(basename "$spec" .md)" >> "$prompt_file"
303
+ echo "" >> "$prompt_file"
304
+ cat "$spec" >> "$prompt_file"
305
+ echo "" >> "$prompt_file"
293
306
  fi
294
307
  done
295
308
 
296
309
  if [[ -f "AGENTS.md" ]]; then
297
- context+="\n---\n\n# Operational Guide\n\n$(cat AGENTS.md)\n"
310
+ echo "---" >> "$prompt_file"
311
+ echo "" >> "$prompt_file"
312
+ echo "# Operational Guide" >> "$prompt_file"
313
+ echo "" >> "$prompt_file"
314
+ cat AGENTS.md >> "$prompt_file"
298
315
  fi
299
316
 
300
- # Run single planning iteration
301
- echo -e "$context" | claude --print --dangerously-skip-permissions
317
+ # Run planning (Ralph pattern: cat PROMPT | claude -p)
318
+ cat "$prompt_file" | claude -p --allowedTools "Read,Write,Edit,Glob,Grep"
302
319
 
303
320
  echo ""
304
321
  echo -e "${GREEN}Planning complete.${NC}"
@@ -320,7 +337,7 @@ run_build_loop() {
320
337
 
321
338
  if [[ ! -d "specs" ]] || [[ -z "$(ls -A specs/*.md 2>/dev/null)" ]]; then
322
339
  echo -e "${YELLOW}No specs found.${NC}"
323
- echo -e "Run ${CYAN}golem spec${NC} first."
340
+ echo -e "Run ${CYAN}/golem:spec${NC} in Claude first."
324
341
  exit 1
325
342
  fi
326
343
 
@@ -333,6 +350,8 @@ run_build_loop() {
333
350
 
334
351
  local iteration=0
335
352
  local start_time=$(date +%s)
353
+ local prompt_file=$(mktemp)
354
+ trap "rm -f $prompt_file" EXIT
336
355
 
337
356
  while true; do
338
357
  iteration=$((iteration + 1))
@@ -355,41 +374,58 @@ run_build_loop() {
355
374
  echo -e "${BLUE} ITERATION $iteration │ $remaining tasks remaining${NC}"
356
375
  echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
357
376
 
358
- # Get the current task (first incomplete) for context
359
- local current_task=$(grep -A3 '^\- \[ \]' IMPLEMENTATION_PLAN.md 2>/dev/null | head -4)
360
-
361
377
  # ═══════════════════════════════════════════════════════════
362
378
  # STEP 1: IMPLEMENT
363
379
  # ═══════════════════════════════════════════════════════════
364
380
  echo ""
365
381
  echo -e "${GREEN}▶ Step 1: Implement${NC}"
366
382
 
367
- local context=""
368
- context+="You are in BUILD MODE. Complete ONE task from the plan.\n\n"
369
- context+="DO NOT commit - just implement, test, update plan, and stage changes.\n"
370
- context+="The commit will happen after simplification.\n\n"
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
371
391
 
372
392
  # Add build prompt if available
373
393
  if [[ -f ".golem/prompts/PROMPT_build.md" ]]; then
374
- context+="$(cat .golem/prompts/PROMPT_build.md)\n\n"
394
+ cat .golem/prompts/PROMPT_build.md >> "$prompt_file"
395
+ echo "" >> "$prompt_file"
375
396
  fi
376
397
 
377
- context+="---\n\n# Specs\n\n"
398
+ echo "---" >> "$prompt_file"
399
+ echo "" >> "$prompt_file"
400
+ echo "# Specs" >> "$prompt_file"
401
+ echo "" >> "$prompt_file"
402
+
378
403
  for spec in specs/*.md; do
379
404
  if [[ -f "$spec" ]]; then
380
- context+="## $(basename "$spec" .md)\n\n"
381
- context+="$(cat "$spec")\n\n"
405
+ echo "## $(basename "$spec" .md)" >> "$prompt_file"
406
+ echo "" >> "$prompt_file"
407
+ cat "$spec" >> "$prompt_file"
408
+ echo "" >> "$prompt_file"
382
409
  fi
383
410
  done
384
411
 
385
412
  if [[ -f "AGENTS.md" ]]; then
386
- context+="\n---\n\n# Operational Guide\n\n$(cat AGENTS.md)\n"
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"
387
419
  fi
388
420
 
389
- context+="\n---\n\n# Implementation Plan\n\n$(cat IMPLEMENTATION_PLAN.md)\n"
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"
390
426
 
391
- # Run implementation step
392
- echo -e "$context" | claude --print --dangerously-skip-permissions
427
+ # Run implementation (Ralph pattern: cat PROMPT | claude -p)
428
+ cat "$prompt_file" | claude -p --allowedTools "Read,Write,Edit,Glob,Grep,Bash"
393
429
 
394
430
  local exit_code=$?
395
431
  if [[ $exit_code -ne 0 ]]; then
@@ -403,38 +439,63 @@ run_build_loop() {
403
439
  echo -e "${GREEN}▶ Step 2: Simplify + Commit${NC}"
404
440
 
405
441
  # Get staged files
406
- local staged_files=$(git diff --cached --name-only 2>/dev/null | grep -E '\.(ts|tsx|js|jsx|py|go|rs)$' | grep -v '\.test\.' | grep -v '\.spec\.' | head -10)
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)
407
443
 
408
- local simplify_context=""
409
- simplify_context+="You are in SIMPLIFY + COMMIT MODE.\n\n"
444
+ # Build simplify prompt file
445
+ cat > "$prompt_file" << 'SIMPLIFY_HEADER'
446
+ You are in SIMPLIFY + COMMIT MODE.
447
+
448
+ SIMPLIFY_HEADER
410
449
 
411
450
  if [[ "$simplify" == "true" ]] && [[ -n "$staged_files" ]]; then
412
- simplify_context+="1. Simplify the staged source files (not tests)\n"
413
- simplify_context+="2. Run tests to verify no regressions\n"
414
- simplify_context+="3. Stage any changes from simplification\n"
415
- simplify_context+="4. Create a single commit with a comprehensive message\n\n"
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
416
458
 
417
459
  # Add code-simplifier agent if available
418
460
  if [[ -f ".golem/agents/code-simplifier.md" ]]; then
419
- simplify_context+="$(cat .golem/agents/code-simplifier.md)\n\n"
461
+ cat .golem/agents/code-simplifier.md >> "$prompt_file"
462
+ echo "" >> "$prompt_file"
420
463
  fi
421
464
 
422
- simplify_context+="---\n\n# Staged source files to simplify\n\n"
423
- simplify_context+="$staged_files\n\n"
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"
424
471
  else
425
- simplify_context+="No source files to simplify. Just create the commit.\n\n"
426
- simplify_context+="Use conventional commit format with a descriptive body.\n\n"
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
427
478
  fi
428
479
 
429
- simplify_context+="---\n\n# Task that was just completed\n\n"
430
- simplify_context+="$current_task\n\n"
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"
431
488
 
432
489
  if [[ -f "AGENTS.md" ]]; then
433
- simplify_context+="---\n\n# Operational Guide (for running tests)\n\n$(cat AGENTS.md)\n"
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"
434
495
  fi
435
496
 
436
- # Run simplification + commit step
437
- echo -e "$simplify_context" | claude --print --dangerously-skip-permissions
497
+ # Run simplify + commit (Ralph pattern)
498
+ cat "$prompt_file" | claude -p --allowedTools "Read,Write,Edit,Glob,Grep,Bash"
438
499
 
439
500
  exit_code=$?
440
501
  if [[ $exit_code -ne 0 ]]; then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "golem-cc",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Autonomous coding loop with Claude - structured specs, ralph loop execution, code simplification",
5
5
  "bin": {
6
6
  "golem-cc": "./bin/install.cjs"