Documentation
¶
Index ¶
- Variables
- func AddCronJob(schedule, command, comment string) error
- func AddService(repoName, serviceName string, spec InfraService) error
- func AgentLastHeartbeat() string
- func AgentStatus() string
- func AllocatePort() (int, error)
- func BinaryLogs(repoName, serviceName string, lines int) (string, error)
- func BinaryName(repoName, serviceName string) string
- func BuildBinary(repoName, source string, serviceName string) error
- func BuildImage(contextPath, tag string, dockerfilePath ...string) error
- func CloneRepository(repoURL, name string) error
- func CoderExec(command string) (string, error)
- func CoderProxy() http.Handler
- func CoderRestart() error
- func CommitInfra(repoName, message string) error
- func ContainerLogs(name string, lines int) (string, error)
- func ContainerNameFor(repoName, serviceName string) string
- func CreateProject(name string, flags []string) error
- func DeleteRepository(name string) error
- func EnsureCoder() error
- func EnsureCronDaemon()
- func ImageNameFor(repoName, serviceName string) string
- func InfraSummary(cfg *InfraConfig) string
- func InitInfraCache()
- func InitRepository(name string) error
- func IsAgentAvailable() bool
- func IsBinaryRunning(repoName, serviceName string) bool
- func IsCoderRunning() bool
- func IsContainerRunning(name string) bool
- func LocalRepoPath(coderPath string) string
- func LogFile(repoName, serviceName string) string
- func PullRepository(repoName string) error
- func RefreshInfraCache(repoName string)
- func RemoveContainer(name string) error
- func RemoveCronJob(schedule, command string) error
- func RemoveService(repoName, serviceName string) error
- func RepoSlug(name string) string
- func RunAgentChat(message string) (string, error)
- func RunBinary(repoName, serviceName string, env map[string]string) error
- func RunContainer(name, image string, opts RunOptions) error
- func SetupDomain(domain string) error
- func StartContainer(name string) error
- func StopBinary(repoName, serviceName string) error
- func StopContainer(name string) error
- func SyncFromFilesystem()
- func SystemDomain() string
- func TriggerFilePath() string
- func UpdateService(repoName, serviceName string, spec InfraService) error
- func WriteProjectInfra(repoName string, cfg *InfraConfig) error
- type AgentManager
- type ContainerInfo
- type CronJob
- type DomainDNSStatus
- type InfraConfig
- type InfraInstance
- type InfraPlatform
- type InfraPort
- type InfraServer
- type InfraService
- type InfraVolume
- type InfraVolumeMount
- type LocalService
- type RunOptions
- type RunningContainer
- type SystemStats
Constants ¶
This section is empty.
Variables ¶
var DefaultAgent = &AgentManager{ stop: make(chan struct{}), done: make(chan struct{}), }
DefaultAgent is the singleton agent manager.
Functions ¶
func AddCronJob ¶
AddCronJob appends a new entry to the code-server crontab.
func AddService ¶
func AddService(repoName, serviceName string, spec InfraService) error
AddService adds a service to a project's infra.json.
func AgentLastHeartbeat ¶
func AgentLastHeartbeat() string
AgentLastHeartbeat returns when the last heartbeat was.
func AllocatePort ¶
AllocatePort finds the next available port starting at 5002. Scans running Docker containers for used host ports.
func BinaryLogs ¶
BinaryLogs returns recent log output from a binary service.
func BinaryName ¶
BinaryName returns the binary path inside code-server for a service.
func BuildBinary ¶
BuildBinary builds a Go binary inside code-server.
func BuildImage ¶
BuildImage builds a Docker image from a context path. If dockerfilePath is non-empty, it specifies the Dockerfile location relative to contextPath.
func CloneRepository ¶
CloneRepository clones a git repo into the code-server container.
func CoderProxy ¶
CoderProxy returns an HTTP reverse proxy to code-server.
func CoderRestart ¶
func CoderRestart() error
CoderRestart stops and starts the code-server container.
func CommitInfra ¶
CommitInfra commits infra.json changes in the project's git repo.
func ContainerLogs ¶
ContainerLogs returns recent log output.
func ContainerNameFor ¶
ContainerNameFor returns the Docker container name for a project service.
func CreateProject ¶
CreateProject runs `congo init` to scaffold a new project in the repos directory. Flags are passed directly to congo init (e.g., "--no-frontend", "--no-assistant").
func DeleteRepository ¶
DeleteRepository removes a repo from the filesystem and database.
func EnsureCoder ¶
func EnsureCoder() error
EnsureCoder starts the code-server container if it isn't already running. Non-critical tools (Go, Node, Claude) log warnings on failure but don't prevent startup. Only the container itself is critical.
func EnsureCronDaemon ¶
func EnsureCronDaemon()
EnsureCronDaemon installs cron if needed, starts the daemon, and restores persisted crontab from the data volume (survives container restarts).
func ImageNameFor ¶
ImageNameFor returns the Docker image name for a project service.
func InfraSummary ¶
func InfraSummary(cfg *InfraConfig) string
InfraSummary returns a brief human-readable summary of the infra config.
func InitInfraCache ¶
func InitInfraCache()
InitInfraCache loads all project infra.json files into memory. Call once at boot after code-server is ready.
func InitRepository ¶
InitRepository creates a new empty git repo.
func IsAgentAvailable ¶
func IsAgentAvailable() bool
IsAgentAvailable checks if Claude Code CLI is authenticated in the code-server.
func IsBinaryRunning ¶
IsBinaryRunning checks if a binary process is alive.
func IsCoderRunning ¶
func IsCoderRunning() bool
IsCoderRunning checks if the code-server container is running.
func IsContainerRunning ¶
IsContainerRunning checks if a container is in running state.
func LocalRepoPath ¶
LocalRepoPath translates a code-server repo path (/home/coder/repos/<name>) to the dev container's local path (DATA_DIR/repos/<name>). Docker operations (build, etc.) need paths accessible from this container.
func PullRepository ¶
PullRepository fetches latest changes.
func RefreshInfraCache ¶
func RefreshInfraCache(repoName string)
RefreshInfraCache reloads a single project's infra from disk into cache.
func RemoveCronJob ¶
RemoveCronJob removes a cron entry matching the given schedule and command.
func RemoveService ¶
RemoveService removes a service from a project's infra.json.
func RunAgentChat ¶
RunAgentChat sends a message to Claude Code CLI and returns the response. It builds context about the current infrastructure state and passes it along.
func RunBinary ¶
RunBinary starts a binary as a background process inside code-server. env is a map of environment variables to set (e.g., PORT).
func RunContainer ¶
func RunContainer(name, image string, opts RunOptions) error
RunContainer starts a new Docker container.
func SetupDomain ¶
SetupDomain registers a domain as a system route. System routes tell autocert to issue TLS certs and identify the app's own domain. Safe to call multiple times.
func StartContainer ¶
StartContainer starts a stopped container.
func StopBinary ¶
StopBinary kills a running binary process.
func SyncFromFilesystem ¶
func SyncFromFilesystem()
SyncFromFilesystem scans repos directory and syncs DB state.
func SystemDomain ¶
func SystemDomain() string
SystemDomain returns the primary system domain, if one exists.
func TriggerFilePath ¶
func TriggerFilePath() string
TriggerFilePath returns the path to the twin trigger file, accessible from both the dev container and the code-server container.
func UpdateService ¶
func UpdateService(repoName, serviceName string, spec InfraService) error
UpdateService updates a service in a project's infra.json.
func WriteProjectInfra ¶
func WriteProjectInfra(repoName string, cfg *InfraConfig) error
WriteProjectInfra writes infra.json to a project via the code-server container and updates the cache.
Types ¶
type AgentManager ¶
type AgentManager struct {
// contains filtered or unexported fields
}
AgentManager runs work cycles using Claude Code in print mode. Each cycle: check tasks → do work → log results → heartbeat. The Monitor goroutine runs cycles and restarts on failure.
func (*AgentManager) IsAlive ¶
func (m *AgentManager) IsAlive() bool
IsAlive returns whether a work cycle is currently running.
func (*AgentManager) Monitor ¶
func (m *AgentManager) Monitor()
Monitor waits for code-server to be ready, then runs work cycles. Call Stop() to gracefully shut down.
func (*AgentManager) Stop ¶
func (m *AgentManager) Stop()
Stop signals the monitor to shut down and waits for it to finish.
type ContainerInfo ¶
type ContainerInfo struct {
ID string `json:"ID"`
Name string `json:"Names"`
Image string `json:"Image"`
Status string `json:"Status"`
State string `json:"State"`
Ports string `json:"Ports"`
Created string `json:"CreatedAt"`
}
ContainerInfo holds Docker container details.
func InspectContainer ¶
func InspectContainer(name string) (*ContainerInfo, error)
InspectContainer returns container details.
func ListContainers ¶
func ListContainers() ([]*ContainerInfo, error)
ListContainers returns all Docker containers.
type CronJob ¶
type CronJob struct {
Schedule string // e.g. "*/5 * * * *"
Command string // e.g. "cd /home/coder/repos/myapp && go test ./..."
Comment string // from preceding # comment line
}
CronJob represents a parsed crontab entry.
func ListCronJobs ¶
func ListCronJobs() []CronJob
ListCronJobs reads cron entries from the code-server container.
type DomainDNSStatus ¶
type DomainDNSStatus struct {
Resolves bool // Domain resolves in DNS
PointsHere bool // Resolves to this server's IP
ResolvedIP string // What IP it resolved to
ServerIP string // This server's IP
}
DomainDNSStatus describes whether a domain resolves to this server.
func CheckDomainDNS ¶
func CheckDomainDNS(host string) *DomainDNSStatus
CheckDomainDNS verifies if a domain points to this server's IP.
type InfraConfig ¶
type InfraConfig struct {
Platforms map[string]InfraPlatform `json:"platforms,omitempty"`
Servers map[string]InfraServer `json:"servers,omitempty"`
Services map[string]InfraService `json:"services,omitempty"`
Instances map[string][]InfraInstance `json:"instances,omitempty"`
}
InfraConfig mirrors the CLI's infra.json structure. The dev platform uses this as the source of truth for service definitions.
func ReadProjectInfra ¶
func ReadProjectInfra(repoName string) (*InfraConfig, error)
ReadProjectInfra returns the cached infra config, falling back to disk.
type InfraInstance ¶
type InfraPlatform ¶
type InfraServer ¶
type InfraServer struct {
Platform string `json:"platform,omitempty"`
Size string `json:"size"`
Setup string `json:"setup,omitempty"`
Volumes []InfraVolume `json:"volumes,omitempty"`
Services []string `json:"services,omitempty"`
}
type InfraService ¶
type InfraService struct {
Image string `json:"image,omitempty"`
Source string `json:"source,omitempty"`
Setup string `json:"setup,omitempty"`
Command []string `json:"command,omitempty"`
Ports []InfraPort `json:"ports,omitempty"`
Volumes []InfraVolumeMount `json:"volumes,omitempty"`
Env map[string]string `json:"env,omitempty"`
EnvFiles map[string]string `json:"env_files,omitempty"`
Network string `json:"network,omitempty"`
Healthcheck string `json:"healthcheck,omitempty"`
Privileged bool `json:"privileged,omitempty"`
Domain string `json:"domain,omitempty"`
}
type InfraVolume ¶
type InfraVolumeMount ¶
type LocalService ¶
type LocalService struct {
RepoName string // project name
RepoID string // repository ID for linking
Name string // service name (key in infra.json services map)
Spec InfraService // full spec from infra.json
ContainerName string // Docker container name: "{repo}-{service}"
Status string // running/stopped/not_deployed (from Docker or binary process)
Mode string // "docker", "binary", or "" (not_deployed)
ContainerPort int // port the app listens on inside the container
ExposedPorts []InfraPort // explicit host port bindings (edge cases like SMTP)
Domain string // from Domain records
Image string // Docker image name
}
LocalService combines an infra.json service definition with runtime Docker state.
func AllLocalServices ¶
func AllLocalServices() []LocalService
AllLocalServices returns all services from all projects' cached infra configs combined with live Docker state.
func GetService ¶
func GetService(repoName, serviceName string) (*LocalService, error)
GetService returns a single service by repo name and service name from cache.
func ProjectServices ¶
func ProjectServices(repoName, repoID string) []LocalService
ProjectServices returns services for a specific project from cache.
func (*LocalService) Slug ¶
func (s *LocalService) Slug() string
Slug returns a URL-safe identifier for this service.
type RunOptions ¶
type RunOptions struct {
Network string
Ports map[int]int // host:container
Volumes map[string]string // host:container
Env map[string]string
Restart string // "always", "unless-stopped"
Detach bool
Command []string
}
RunOptions configures docker run.
type RunningContainer ¶
type RunningContainer struct {
Name string // container name
Image string // Docker image
Status string // human-readable uptime from docker ps
Ports string // raw port mapping string
Domain string // domain if mapped
RepoName string // project name, empty for standalone infrastructure
SvcName string // service name from infra.json, empty for standalone
}
RunningContainer represents a Docker container for dashboard display.
func AllRunningContainers ¶
func AllRunningContainers() []RunningContainer
AllRunningContainers returns all running Docker containers enriched with project and domain information for dashboard display.
func (RunningContainer) ShortPorts ¶
func (c RunningContainer) ShortPorts() string
ShortPorts formats the docker ps Ports field into a compact display. Deduplicates IPv4/IPv6 bindings (e.g. 0.0.0.0:5001->5000 and :::5001->5000).
type SystemStats ¶
type SystemStats struct {
Hostname string
OS string
Arch string
NumCPU int
CPUPercent int
MemTotal string
MemUsed string
MemPercent int
DiskTotal string
DiskUsed string
DiskPercent int
DataTotal string // data volume (if separate from root)
DataUsed string
DataPercent int
HasDataDisk bool // true when data dir is on a different filesystem
LoadAvg string
}
SystemStats holds system resource information.
func GetSystemStats ¶
func GetSystemStats() *SystemStats
GetSystemStats reads system metrics from /proc and syscall.