rdev/internal/port/template_provider.go
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

34 lines
1.1 KiB
Go

// Package port defines interfaces (ports) for external dependencies.
package port
import "context"
// TemplateProvider seeds repositories with starter files.
type TemplateProvider interface {
// SeedRepo populates a repository with template files.
// templateName specifies which template to use (e.g., "default", "astro-landing").
// vars contains template variables for interpolation (e.g., PROJECT_NAME, DOMAIN).
SeedRepo(ctx context.Context, owner, repo, templateName string, vars map[string]string) error
// ListTemplates returns available templates.
ListTemplates(ctx context.Context) ([]TemplateInfo, error)
// GetTemplate returns info about a specific template.
GetTemplate(ctx context.Context, name string) (*TemplateInfo, error)
}
// TemplateInfo describes an available project template.
type TemplateInfo struct {
// Name is the template identifier (e.g., "astro-landing")
Name string
// Description explains what the template provides
Description string
// Stack indicates the technology stack (e.g., "astro", "go", "generic")
Stack string
// Files lists the files included in the template
Files []string
}