rdev/ai-lookup/services/ci-provider.md
jordan 39df51defd feat: Add multi-provider code agent interface with Claude Code and OpenCode adapters
Implements weeks 1-4 of the multi-provider architecture:

Week 1 - Foundation:
- Add domain models (AgentProvider, AgentRequest, AgentEvent, AgentResult)
- Define CodeAgent port interface with Execute, Cancel, Capabilities
- Create thread-safe provider registry with first-registered default

Week 2 - Claude Code Adapter:
- Extract kubectl exec logic into CodeAgent implementation
- Parse stream-json output format (init, message, tool_use, result)
- Support session continuation via --resume flag

Week 3 - OpenCode Adapter:
- HTTP/SSE client for opencode serve API
- Session management (create, send message, abort)
- Event streaming with documented buffer rationale

Week 4 - Quality & Polish:
- Fix race condition in OpenCode Cancel method
- Add AgentRequest.Validate() with ErrPromptRequired, ErrInvalidTimeout
- Document DefaultAvailabilityTimeout constants
- Add HTTP error context for debugging

Also includes:
- Work queue system with PostgreSQL adapter
- Credential store for infrastructure secrets
- Project templates with Woodpecker CI integration
- Comprehensive test coverage

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 09:25:51 -07:00

1.3 KiB

CI Provider (Woodpecker)

Last Updated: 2025-01 Confidence: High (Planned - see address-the-gaps.md)

Summary

CIProvider port enables automatic Woodpecker CI activation when projects are created. Eliminates manual UI clicks to activate repos.

Key Facts:

  • Activates repos via Woodpecker API on project creation
  • Can trigger manual builds
  • JWT token authentication
  • Graceful fallback if activation fails (logs warning, adds manual step)

File Pointers:

  • Port: internal/port/ci_provider.go
  • Adapter: internal/adapter/woodpecker/client.go
  • Integration: internal/service/project_infra.go

Port Interface

type CIProvider interface {
    ActivateRepo(ctx context.Context, forgeRemoteID int64) error
    DeactivateRepo(ctx context.Context, owner, name string) error
    TriggerBuild(ctx context.Context, owner, name, branch string) (int64, error)
}

Configuration

WOODPECKER_URL=https://ci.threesix.ai
WOODPECKER_API_TOKEN=<jwt token from .secrets>

Integration Flow

  1. ProjectInfraService.CreateProject() creates Gitea repo
  2. Gets repo ID from Gitea
  3. Calls ci.ActivateRepo(ctx, repoID)
  4. Woodpecker creates webhook in Gitea
  5. Future pushes trigger builds automatically