golem-cc 0.1.15 → 0.1.16

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 CHANGED
@@ -275,47 +275,23 @@ run_plan_mode() {
275
275
  echo -e "${DIM}Analyzing specs and creating implementation plan.${NC}"
276
276
  echo ""
277
277
 
278
- # Build prompt file (Ralph pattern: cat file | claude)
279
- local prompt_file=$(mktemp)
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
278
+ # Find prompt file (uses @file references for context)
279
+ local prompt_file=""
290
280
  if [[ -f ".golem/prompts/PROMPT_plan.md" ]]; then
291
- cat .golem/prompts/PROMPT_plan.md >> "$prompt_file"
292
- echo "" >> "$prompt_file"
293
- fi
294
-
295
- echo "---" >> "$prompt_file"
296
- echo "" >> "$prompt_file"
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"
281
+ prompt_file=".golem/prompts/PROMPT_plan.md"
282
+ elif [[ -f "$GOLEM_DIR/golem/prompts/PROMPT_plan.md" ]]; then
283
+ prompt_file="$GOLEM_DIR/golem/prompts/PROMPT_plan.md"
284
+ else
285
+ echo -e "${RED}No PROMPT_plan.md found. Run golem --install first.${NC}"
286
+ exit 1
315
287
  fi
316
288
 
317
- # Run planning (Ralph pattern: cat PROMPT | claude -p)
318
- cat "$prompt_file" | claude -p --allowedTools "Read,Write,Edit,Glob,Grep"
289
+ # Ralph pattern: cat PROMPT | claude -p
290
+ cat "$prompt_file" | claude -p \
291
+ --dangerously-skip-permissions \
292
+ --output-format stream-json \
293
+ --model opus \
294
+ --verbose
319
295
 
320
296
  echo ""
321
297
  echo -e "${GREEN}Planning complete.${NC}"
@@ -341,18 +317,25 @@ run_build_loop() {
341
317
  exit 1
342
318
  fi
343
319
 
320
+ # Find prompt file
321
+ local build_prompt=""
322
+ if [[ -f ".golem/prompts/PROMPT_build.md" ]]; then
323
+ build_prompt=".golem/prompts/PROMPT_build.md"
324
+ elif [[ -f "$GOLEM_DIR/golem/prompts/PROMPT_build.md" ]]; then
325
+ build_prompt="$GOLEM_DIR/golem/prompts/PROMPT_build.md"
326
+ else
327
+ echo -e "${RED}No PROMPT_build.md found. Run golem --install first.${NC}"
328
+ exit 1
329
+ fi
330
+
344
331
  echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
345
332
  echo -e "${CYAN} BUILD LOOP STARTED${NC}"
346
- if [[ "$simplify" == "true" ]]; then
347
- echo -e "${CYAN} Mode: Implement → Simplify (2 steps per iteration)${NC}"
348
- fi
349
333
  echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
350
334
 
351
335
  local iteration=0
352
336
  local start_time=$(date +%s)
353
- local prompt_file=$(mktemp)
354
- trap "rm -f $prompt_file" EXIT
355
337
 
338
+ # Ralph loop: while :; do cat PROMPT | claude -p; done
356
339
  while true; do
357
340
  iteration=$((iteration + 1))
358
341
 
@@ -374,132 +357,16 @@ run_build_loop() {
374
357
  echo -e "${BLUE} ITERATION $iteration │ $remaining tasks remaining${NC}"
375
358
  echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
376
359
 
377
- # ═══════════════════════════════════════════════════════════
378
- # STEP 1: IMPLEMENT
379
- # ═══════════════════════════════════════════════════════════
380
- echo ""
381
- echo -e "${GREEN}▶ Step 1: Implement${NC}"
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
360
+ # Ralph pattern: cat PROMPT | claude -p
361
+ cat "$build_prompt" | claude -p \
362
+ --dangerously-skip-permissions \
363
+ --output-format stream-json \
364
+ --model opus \
365
+ --verbose
429
366
 
430
367
  local exit_code=$?
431
368
  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
- # ═══════════════════════════════════════════════════════════
438
- 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}"
369
+ echo -e "${RED}Build step exited with error code $exit_code${NC}"
503
370
  fi
504
371
 
505
372
  # Brief pause between iterations
@@ -1,60 +1,47 @@
1
- # Ralph Build Mode
2
-
3
- You are operating in **build mode** - your job is to implement one task from the plan and validate it works.
4
-
5
- **Note:** Do NOT commit. Code simplification and commit happen in a separate step.
6
-
7
- ## Execution Flow
8
-
9
- 1. **Orient** - Read the specs and implementation plan below
10
- 2. **Select** - Pick the highest-priority incomplete task (marked `[ ]`)
11
- 3. **Investigate** - Search relevant source code to understand context
12
- 4. **Implement** - Make the changes required for this task
13
- 5. **Validate** - Run all backpressure gates (tests, typecheck, lint)
14
- 6. **Fix** - If validation fails, fix issues and re-validate
15
- 7. **Update Plan** - Mark task complete, add any discoveries
16
- 8. **Stage** - Run `git add` on changed files (but DO NOT commit)
17
-
18
- ## Rules
19
-
20
- ### Task Selection
21
- - Always pick the **first** incomplete task unless it has unmet dependencies
22
- - Never skip tasks or cherry-pick based on preference
23
- - If blocked, note the blocker and select the next available task
24
-
25
- ### Implementation
26
- - Implement ONLY what the task requires - no scope creep
27
- - Follow existing code patterns and conventions
28
- - Write tests alongside implementation code
29
- - Keep changes minimal and focused
30
-
31
- ### Validation (Backpressure)
32
- Run these commands in order. ALL must pass before proceeding:
33
- 1. Tests: `{test_command}`
34
- 2. Type check: `{typecheck_command}` (if configured)
35
- 3. Lint: `{lint_command}` (if configured)
36
- 4. Build: `{build_command}` (if configured)
37
-
38
- If any gate fails:
39
- - Read the error carefully
40
- - Fix the issue
41
- - Re-run ALL gates from the beginning
42
- - Repeat until all pass
43
-
44
- ### Plan Updates
45
- Edit `IMPLEMENTATION_PLAN.md`:
46
- - Change `[ ]` to `[x]` for completed task
47
- - Add notes about discoveries or blockers encountered
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
- # Ralph Planning Mode
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
- ### Plan Format
3
+ You are in PLANNING MODE. Analyze specs vs existing code and create IMPLEMENTATION_PLAN.md.
52
4
 
53
- Write `IMPLEMENTATION_PLAN.md` in this format:
5
+ ## Phase 0: Orient
54
6
 
55
- ```markdown
56
- # Implementation Plan
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
- Generated: {timestamp}
59
- Based on: specs/*.md
22
+ Write `IMPLEMENTATION_PLAN.md` with prioritized tasks:
60
23
 
61
- ## Status
62
- - Total tasks: N
63
- - Completed: 0
64
- - Remaining: N
24
+ ```markdown
25
+ # Implementation Plan
65
26
 
66
27
  ## Tasks
67
28
 
68
- ### [ ] 1. {Task title}
69
- Priority: Critical|High|Medium|Low
70
- Files: {expected files to create/modify}
71
- Notes: {implementation hints, constraints}
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
- ### [ ] 2. {Next task}
75
- ...
34
+ - [ ] 2. {Next task}
35
+ ...
76
36
  ```
77
37
 
78
- ## Important
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 implement anything in planning mode
81
- - Do NOT modify source code
82
- - ONLY create/update IMPLEMENTATION_PLAN.md
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
- - Be realistic - tasks should be achievable in one iteration
54
+ - Capture "the why" for each task
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "golem-cc",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
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"