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>
45 lines
1.4 KiB
Markdown
45 lines
1.4 KiB
Markdown
# Project Service
|
|
|
|
**Last Updated:** 2025-01
|
|
**Confidence:** High
|
|
|
|
## Summary
|
|
|
|
The ProjectService orchestrates all project-related operations: listing, getting, and executing commands. It coordinates between handlers, the Kubernetes adapter, audit logging, and webhook dispatch.
|
|
|
|
**Key Facts:**
|
|
- Lists projects from Kubernetes pods with label `rdev.orchard9.ai/project=true`
|
|
- Executes Claude, shell, and git commands asynchronously
|
|
- Logs all command executions to audit trail
|
|
- Dispatches webhook events on command completion
|
|
- Returns stream URLs for SSE-based output consumption
|
|
|
|
**File Pointers:**
|
|
- Service: `internal/service/project.go`
|
|
- Handler: `internal/handlers/projects.go`
|
|
- Port interfaces: `internal/port/project.go`
|
|
|
|
## Operations
|
|
|
|
| Method | Description |
|
|
|--------|-------------|
|
|
| `List(ctx)` | Returns all projects with current status |
|
|
| `Get(ctx, id)` | Returns single project by ID |
|
|
| `ExecuteClaude(ctx, project, prompt)` | Queues Claude command |
|
|
| `ExecuteShell(ctx, project, cmd)` | Queues shell command |
|
|
| `ExecuteGit(ctx, project, args)` | Queues git command |
|
|
|
|
## Execution Flow
|
|
|
|
1. Handler receives request
|
|
2. Service validates and creates Command
|
|
3. Command queued (postgres) or executed directly
|
|
4. Output streamed to StreamPublisher
|
|
5. Audit log entry created
|
|
6. Webhook events dispatched
|
|
|
|
## Related Topics
|
|
|
|
- [Command Execution](../features/command-execution.md)
|
|
- [SSE Streaming](../features/sse-streaming.md)
|