Skip to content

Auto-spawn loops from GitHub events #32

@alexh

Description

@alexh

Summary

Trigger loops when issues are labeled, assigned, or commented on via GitHub webhooks.

Key Features

  • Local webhook receiver for GitHub events
  • Polling fallback when webhook server unavailable
  • Rule-based loop spawning (label triggers, assignee triggers)
  • Rate limiting to prevent spam loops

Implementation Phases

Phase 1: Webhook Configuration

  • Extend AppSettings in src/core/state.ts:
    webhooks?: {
      enabled: boolean;
      port?: number; // default 8787
      secret?: string; // GitHub webhook secret
      rules: WebhookRule[];
    }
  • WebhookRule type:
    {
      event: 'labeled' | 'assigned' | 'commented';
      match: { label?: string; assignee?: string; bodyPattern?: string };
      action: { agent: AgentType; autoStart: boolean };
    }

Phase 2: Webhook Server

  • Create src/core/webhooks.ts:
    • Bun.serve() HTTP listener on configured port
    • GitHub signature verification (HMAC SHA256)
    • Parse webhook payloads for issue events
    • Route to rule matcher

Phase 3: Rule Engine

  • Match incoming events against configured rules
  • On match: create loop via existing addLoop() in state
  • Emit event via loopEvents for UI notification
  • Log webhook activity to dedicated log file

Phase 4: Polling Fallback

  • CLI option: alex webhook --poll --interval 60
  • Use gh api to check recent issue events
  • Track last-seen event timestamp
  • Apply same rules as webhook mode

Phase 5: UI Integration

  • Add webhook status indicator in header
  • Show recent webhook activity in logs
  • Menu option to start/stop webhook server

Files to Create/Modify

  • src/core/webhooks.ts - New webhook server + rules
  • src/core/state.ts - Extend AppSettings
  • src/cli.ts - Add webhook subcommand
  • src/ui/layout.ts - Webhook status indicator

Example Config

webhooks:
  enabled: true
  port: 8787
  rules:
    - event: labeled
      match: { label: "ralph-loop" }
      action: { agent: claude, autoStart: true }
    - event: assigned
      match: { assignee: "alexh" }
      action: { agent: claude, autoStart: false }

Acceptance Criteria

  • Local webhook receiver (or polling fallback)
  • Configure rules: "on label:ralph-loop, spawn loop"
  • Event types: labeled, assigned, commented
  • Rate limiting to prevent spam

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions