wrkserver

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateOpRequest

type CreateOpRequest struct {
	Action   string `json:"action"`
	TargetID string `json:"target_id,omitempty"`
	Label    string `json:"label,omitempty"`
}

CreateOpRequest is the POST {base}/ops body.

type CreateOpResponse

type CreateOpResponse struct {
	OpID   string `json:"op_id"`
	Action string `json:"action"`
}

CreateOpResponse is returned when a mock op is started.

type CreateWorktreeRequest

type CreateWorktreeRequest struct {
	ProjectPath string `json:"project_path"`
	Task        string `json:"task,omitempty"`
}

CreateWorktreeRequest is the POST {base}/worktrees body.

type CreateWorktreeResponse

type CreateWorktreeResponse struct {
	Path   string `json:"path"`
	Branch string `json:"branch"`
}

CreateWorktreeResponse is the successful create payload.

type ErrorBody

type ErrorBody struct {
	Error string `json:"error"`
}

ErrorBody is the JSON error envelope for 4xx/5xx.

type ListProjectsResponse

type ListProjectsResponse struct {
	Projects []ProjectStatus `json:"projects"`
}

ListProjectsResponse is the GET {base}/projects envelope.

type LogLine

type LogLine struct {
	TS      string `json:"ts"`
	Level   string `json:"level"`
	Message string `json:"message"`
}

LogLine is one streamed log event payload.

type OpDonePayload

type OpDonePayload struct {
	OK      bool   `json:"ok"`
	Summary string `json:"summary,omitempty"`
	Error   string `json:"error,omitempty"`
}

OpDonePayload is the final SSE event.

type Options

type Options struct {
	// WrkHome is the wrk storage root (projects.json, worktrees/).
	// Empty resolves like the CLI (WRK_HOME or ~/.wrk).
	WrkHome string
}

Options configures a wrkserver instance.

type ProjectStatus

type ProjectStatus struct {
	Path      string           `json:"path"`
	Name      string           `json:"name"`
	Branch    string           `json:"branch,omitempty"`
	Commit    string           `json:"commit,omitempty"`
	Subject   string           `json:"subject,omitempty"`
	Clean     bool             `json:"clean"`
	Error     string           `json:"error,omitempty"`
	Worktrees []WorktreeStatus `json:"worktrees"`
}

ProjectStatus is one registered main repository and its linked worktrees.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server holds HTTP handlers for wrk project list and worktree create.

func New

func New(opts Options) *Server

New constructs a Server from Options.

func (*Server) CreateOp

func (s *Server) CreateOp(w http.ResponseWriter, r *http.Request)

CreateOp handles POST {base}/ops — starts a mock streaming operation.

func (*Server) CreateWorktree

func (s *Server) CreateWorktree(w http.ResponseWriter, r *http.Request)

CreateWorktree handles POST {base}/worktrees.

func (*Server) ListProjects

func (s *Server) ListProjects(w http.ResponseWriter, r *http.Request)

ListProjects handles GET {base}/projects.

func (*Server) Register

func (s *Server) Register(mux *http.ServeMux, base string)

Register mounts fixed leaves under base (trailing slash optional).

GET  {base}/projects           → ListProjects
POST {base}/worktrees          → CreateWorktree
POST {base}/ops                → CreateOp (mock streaming ops)
GET  {base}/ops/{id}/logs      → StreamOpLogs (SSE)

base is host-owned; wrkserver does not hardcode /api/wrk.

func (*Server) StreamOpLogs

func (s *Server) StreamOpLogs(w http.ResponseWriter, r *http.Request)

StreamOpLogs handles GET {base}/ops/{id}/logs as Server-Sent Events.

type WorktreeStatus

type WorktreeStatus struct {
	Path   string `json:"path"`
	Name   string `json:"name"`
	Branch string `json:"branch,omitempty"`
	Clean  bool   `json:"clean"`
	IsMain bool   `json:"is_main"`
	Error  string `json:"error,omitempty"`
}

WorktreeStatus is one linked worktree (main is not listed here).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL