Skip to content

feat: implement iterate run + iterate watch (file-based persistence, agent invocation) #461

@emil07770

Description

@emil07770

Summary

iterate run and iterate watch are currently stubs. This issue tracks their full implementation.

What’s needed

iterate run

  • Load goals from ~/.sh1pt/iterate-goals.json
  • Determine metric signals from --scope (copy | pricing | onboarding | perf | bugs | all)
  • Capture/compare a MetricSnapshot stored in ~/.sh1pt/iterate-metrics.json
  • Build a structured agent prompt from goals + signals + scope
  • Invoke the configured agent (claude, codex, or qwen) via CLI with --print
  • Save a RunRecord (id, timestamps, agent, scope, goals, status, diff) to ~/.sh1pt/iterate-runs.json (capped at 100 entries, atomic writes)
  • --dry-run flag shows plan + prompt without invoking agent
  • --auto-apply skips confirmation prompt
  • --json emits machine-readable run record

iterate watch

  • Save/load WatchConfig to ~/.sh1pt/iterate-watch.json (atomic writes)
  • --status shows current config
  • --stop removes the config file
  • --cloud prints deployment instructions for sh1pt cloud
  • Local mode prints a ready-made crontab line using --interval and --agent
  • --quiet-hours <start-end> (e.g. 22-08) skips cycles during off-hours

Persistence pattern

All files use atomic write (write .tmp → rename) with mode: 0o600, same as existing goals implementation.

Acceptance criteria

  • sh1pt iterate run --dry-run shows plan + prompt, saves skipped RunRecord
  • sh1pt iterate run --agent claude invokes claude --print <prompt>, saves applied RunRecord
  • sh1pt iterate run --auto-apply skips confirmation
  • sh1pt iterate run --json emits JSON run record
  • sh1pt iterate watch saves WatchConfig, prints crontab line
  • sh1pt iterate watch --cloud prints cloud deployment info
  • sh1pt iterate watch --stop clears config
  • sh1pt iterate watch --status shows current config + quiet-hours state
  • All state files use atomic writes, mode 0o600

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions