@wavilikhin/ralph-wiggum 0.1.16 → 0.1.18

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/README.md CHANGED
@@ -109,6 +109,18 @@ tail -f .ralph/logs/ralph.log
109
109
  - Enforces one commit per iteration.
110
110
  - Requires a clean working tree after each iteration.
111
111
 
112
+ ### Permissions
113
+
114
+ Ralph Wiggum automatically allows `external_directory` permission to prevent OpenCode from blocking the autonomous loop with permission prompts. This setting is merged with your project's `opencode.json` — your other permissions remain intact.
115
+
116
+ If you need full permissive mode (allow all permissions), set the environment variable before running:
117
+
118
+ ```bash
119
+ OPENCODE_CONFIG_CONTENT='{"permission":"allow"}' .ralph/run.sh
120
+ ```
121
+
122
+ See [OpenCode Permissions](https://opencode.ai/docs/permissions) for details.
123
+
112
124
  <details>
113
125
  <summary><strong>AI agent appendix (full detail)</strong></summary>
114
126
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavilikhin/ralph-wiggum",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "Autonomous coding loop for OpenCode - one task, one commit, fresh context per iteration",
5
5
  "type": "module",
6
6
  "bin": {
@@ -30,4 +30,4 @@
30
30
  "publishConfig": {
31
31
  "access": "public"
32
32
  }
33
- }
33
+ }
@@ -18,6 +18,7 @@ MODEL="${RALPH_MODEL:-anthropic/claude-opus-4-20250514}"
18
18
  VARIANT=""
19
19
  VERBOSE=false
20
20
  LIVE=false
21
+ STRICT=false
21
22
  OPENCODE_ARGS=()
22
23
 
23
24
  # All ralph files are in .ralph/
@@ -118,6 +119,7 @@ print_usage() {
118
119
  echo " --variant NAME Variant name for opencode"
119
120
  echo " --verbose Save per-iteration logs (.ralph/logs/ralph_iter_N.log)"
120
121
  echo " --live Stream opencode output to terminal (requires --verbose)"
122
+ echo " --strict Exit on any iteration anomaly (multiple commits, no commit, dirty tree)"
121
123
  echo " --help Show this help"
122
124
  echo ""
123
125
  echo "Environment variables:"
@@ -211,6 +213,10 @@ while [[ $# -gt 0 ]]; do
211
213
  LIVE=true
212
214
  shift
213
215
  ;;
216
+ --strict)
217
+ STRICT=true
218
+ shift
219
+ ;;
214
220
  --help|-h)
215
221
  print_usage
216
222
  exit 0
@@ -243,6 +249,7 @@ echo -e " ${DIM}Max iterations:${NC} $MAX_ITERATIONS"
243
249
  echo -e " ${DIM}Model:${NC} $MODEL"
244
250
  echo -e " ${DIM}Verbose:${NC} $VERBOSE"
245
251
  echo -e " ${DIM}Live output:${NC} $LIVE"
252
+ echo -e " ${DIM}Strict mode:${NC} $STRICT"
246
253
  echo -e " ${DIM}Repo root:${NC} $REPO_ROOT"
247
254
  [[ -n "$VARIANT" ]] && echo -e " ${DIM}Variant:${NC} $VARIANT"
248
255
  echo ""
@@ -282,6 +289,11 @@ for i in $(seq 1 "$MAX_ITERATIONS"); do
282
289
  BEFORE_HEAD=$(git rev-parse HEAD)
283
290
  log_info "HEAD before: ${DIM}${BEFORE_HEAD:0:8}${NC}"
284
291
 
292
+ # Allow external_directory permission to prevent blocking prompts during autonomous execution.
293
+ # This merges with (not replaces) any existing opencode.json permissions in the project.
294
+ # See: https://opencode.ai/docs/permissions
295
+ export OPENCODE_CONFIG_CONTENT='{"permission":{"external_directory":"allow"}}'
296
+
285
297
  OPENCODE_CMD=(
286
298
  opencode run
287
299
  --model "$MODEL"
@@ -333,7 +345,12 @@ for i in $(seq 1 "$MAX_ITERATIONS"); do
333
345
  log_error "opencode exited with code $EXIT_CODE"
334
346
  log_error "Check log: $ITER_LOG_FILE"
335
347
  log_iteration_end "$i" "FAILED" "opencode error" "$ITER_DURATION" "$OPENCODE_DURATION"
336
- exit 1
348
+ if [[ "$STRICT" == true ]]; then
349
+ exit 1
350
+ fi
351
+ log_warn "Continuing despite error (use --strict to exit on errors)"
352
+ echo ""
353
+ continue
337
354
  fi
338
355
 
339
356
  if echo "$OUTPUT" | grep -q '<promise>COMPLETE</promise>'; then
@@ -350,26 +367,42 @@ for i in $(seq 1 "$MAX_ITERATIONS"); do
350
367
  log_info "HEAD after: ${DIM}${AFTER_HEAD:0:8}${NC}"
351
368
 
352
369
  if [[ "$BEFORE_HEAD" == "$AFTER_HEAD" ]]; then
353
- log_error "No commit was created in this iteration!"
354
- log_error "The agent must create exactly one commit per iteration."
355
- log_error "Check log: $ITER_LOG_FILE"
356
- log_iteration_end "$i" "FAILED" "no commit created" "$ITER_DURATION" "$OPENCODE_DURATION"
357
- exit 1
370
+ log_warn "No commit was created in this iteration."
371
+ log_iteration_end "$i" "WARN" "no commit created" "$ITER_DURATION" "$OPENCODE_DURATION"
372
+ if [[ "$STRICT" == true ]]; then
373
+ log_error "Exiting due to --strict mode"
374
+ exit 1
375
+ fi
376
+ echo ""
377
+ continue
358
378
  fi
359
379
 
360
380
  COMMIT_COUNT=$(git rev-list --count "$BEFORE_HEAD".."$AFTER_HEAD")
361
381
  if [[ "$COMMIT_COUNT" -ne 1 ]]; then
362
- log_error "Expected 1 commit, but $COMMIT_COUNT were created!"
363
- log_iteration_end "$i" "FAILED" "multiple commits" "$ITER_DURATION" "$OPENCODE_DURATION"
364
- exit 1
382
+ log_warn "Expected 1 commit, but $COMMIT_COUNT were created."
383
+ log_iteration_end "$i" "WARN" "$COMMIT_COUNT commits" "$ITER_DURATION" "$OPENCODE_DURATION"
384
+ if [[ "$STRICT" == true ]]; then
385
+ log_error "Exiting due to --strict mode"
386
+ exit 1
387
+ fi
388
+ # Still show the commits that were made
389
+ COMMIT_MSG=$(git log -1 --format='%s')
390
+ log_info "Latest commit: $COMMIT_MSG"
391
+ echo ""
392
+ continue
365
393
  fi
366
394
 
367
395
  if [[ -n "$(git status --porcelain)" ]]; then
368
- log_error "Working tree is not clean after iteration!"
396
+ log_warn "Working tree is not clean after iteration."
369
397
  echo ""
370
398
  git status --short
371
- log_iteration_end "$i" "FAILED" "dirty working tree" "$ITER_DURATION" "$OPENCODE_DURATION"
372
- exit 1
399
+ log_iteration_end "$i" "WARN" "dirty working tree" "$ITER_DURATION" "$OPENCODE_DURATION"
400
+ if [[ "$STRICT" == true ]]; then
401
+ log_error "Exiting due to --strict mode"
402
+ exit 1
403
+ fi
404
+ echo ""
405
+ continue
373
406
  fi
374
407
 
375
408
  COMMIT_MSG=$(git log -1 --format='%s')