web

package
v0.0.0-...-74eca7e Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProjectNotFound = errors.New("project not found")

ErrProjectNotFound indicates the requested project ID is not in the registry.

Functions

func Export

func Export(cfg ExportConfig) error

Export generates a self-contained static site from task data.

func ExportWithFS

func ExportWithFS(cfg ExportConfig, embeddedFS fs.FS) error

ExportWithFS generates a static site using the provided embedded filesystem. This is separated from Export to allow tests to inject a mock FS.

func StaticFiles

func StaticFiles() fs.FS

StaticFiles returns an empty filesystem when web assets are not embedded.

Types

type Config

type Config struct {
	Port     int
	ScanDir  string
	Dev      bool
	Verbose  bool
	ReadOnly bool
	Version  string
	Phases   []PhaseInfo
	// Efforts is the project's effort vocabulary. The zero value means the
	// default small, medium, large.
	Efforts effort.Scale
	// Worktrees builds the cross-worktree overlay for the data layer. The
	// zero value disables it.
	Worktrees worktree.Builder

	// ListProjects returns registered projects from the global registry.
	// Nil means multi-project support is disabled.
	ListProjects func() ([]ProjectEntry, error)
	// ResolveProject resolves a project ID to its scan directory and phases.
	// Nil means multi-project support is disabled.
	ResolveProject ProjectResolverFunc
}

Config holds server configuration.

type ConfigResponse

type ConfigResponse struct {
	ReadOnly bool        `json:"readonly"`
	Version  string      `json:"version"`
	Phases   []PhaseInfo `json:"phases"`
	// Efforts is the project's effort vocabulary, lowest to highest. The web UI
	// uses it to populate the effort filter and the edit-form dropdown.
	Efforts []string `json:"efforts"`
	// Worktree describes the active worktree overlay; absent when inactive.
	Worktree *WorktreeOverlayInfo `json:"worktree,omitempty"`
}

ConfigResponse is the JSON response for GET /api/config.

type DataProvider

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

DataProvider caches scan results and invalidates on file changes. When a worktree overlay builder is configured, every rescan re-discovers sibling worktrees and rebuilds the merged view, so membership changes are picked up on any invalidation.

func NewDataProvider

func NewDataProvider(scanDir string, verbose bool) *DataProvider

NewDataProvider creates a DataProvider with the worktree overlay disabled.

func NewDataProviderWithWorktrees

func NewDataProviderWithWorktrees(scanDir string, verbose bool, wt worktree.Builder) *DataProvider

NewDataProviderWithWorktrees creates a DataProvider that builds the cross-worktree overlay per the given builder.

func (*DataProvider) GetArchivedTasks

func (dp *DataProvider) GetArchivedTasks() ([]*model.Task, error)

GetArchivedTasks scans archive directories for tasks used in dependency resolution.

func (*DataProvider) GetEffectiveTasks

func (dp *DataProvider) GetEffectiveTasks() ([]*model.Task, error)

GetEffectiveTasks returns the merged task list with effective statuses when the overlay is active, and the local tasks otherwise. Status-aggregating endpoints (board, graph, stats, next, tracks, validate, search) serve this.

func (*DataProvider) GetOverlay

func (dp *DataProvider) GetOverlay() (*worktree.Overlay, error)

GetOverlay returns the cached worktree overlay, or nil when it is inactive.

func (*DataProvider) GetTasks

func (dp *DataProvider) GetTasks() ([]*model.Task, error)

GetTasks returns the cached local tasks (after sibling-root attribution when the overlay is active), rescanning if dirty.

func (*DataProvider) Invalidate

func (dp *DataProvider) Invalidate()

Invalidate marks cached data as stale.

func (*DataProvider) OverlayInfo

func (dp *DataProvider) OverlayInfo() (*WorktreeOverlayInfo, error)

OverlayInfo reports the active overlay's shape for /api/config: the local worktree's name and the sibling worktree count. Nil when the overlay is inactive, so single-worktree responses are unchanged.

func (*DataProvider) ScanDir

func (dp *DataProvider) ScanDir() string

ScanDir returns the directory being scanned.

func (*DataProvider) WatchDirs

func (dp *DataProvider) WatchDirs() []string

WatchDirs returns the directories the live-refresh watcher should cover for markdown changes: the scan dir plus, with the overlay enabled, each sibling worktree's tasks dir.

func (*DataProvider) WatchMetaDirs

func (dp *DataProvider) WatchMetaDirs() []string

WatchMetaDirs returns directories whose any change (not just markdown) signals a worktree membership change: the repo's <common-dir>/worktrees. Empty when the overlay is disabled or the scan dir is not in a git repo.

type ErrorResponse

type ErrorResponse struct {
	Error   string   `json:"error"`
	Details []string `json:"details,omitempty"`
}

ErrorResponse is a structured JSON error response.

type ExportConfig

type ExportConfig struct {
	OutputDir string
	ScanDir   string
	BasePath  string
	Verbose   bool
	Version   string
	// Efforts is the project's effort vocabulary. The zero value means the
	// default small, medium, large.
	Efforts effort.Scale
	// Worktrees builds the cross-worktree overlay; the export bakes effective
	// status and provenance in at export time. The zero value disables it,
	// leaving single-worktree exports unchanged.
	Worktrees worktree.Builder
}

ExportConfig holds configuration for the static site export.

type PhaseInfo

type PhaseInfo struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

PhaseInfo holds phase metadata served to the frontend.

type ProjectEntry

type ProjectEntry struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Path string `json:"path"`
}

ProjectEntry represents a registered project for the API.

type ProjectResolver

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

ProjectResolver caches DataProviders per project ID.

func NewProjectResolver

func NewProjectResolver(resolve ProjectResolverFunc, verbose bool, wt worktree.Builder) *ProjectResolver

NewProjectResolver creates a resolver with lazy caching. Each project's DataProvider builds the worktree overlay for its own scan dir.

type ProjectResolverFunc

type ProjectResolverFunc func(id string) (scanDir string, phases []PhaseInfo, err error)

ProjectResolverFunc resolves a project ID to its task scan directory and phases.

type SSEBroker

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

SSEBroker manages Server-Sent Events connections.

func NewSSEBroker

func NewSSEBroker() *SSEBroker

NewSSEBroker creates a new SSE broker.

func (*SSEBroker) Broadcast

func (b *SSEBroker) Broadcast()

Broadcast sends a reload event to all connected clients.

func (*SSEBroker) ServeHTTP

func (b *SSEBroker) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles SSE connections at /api/events.

type Server

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

Server is the taskmd web server.

func NewServer

func NewServer(cfg Config) *Server

NewServer creates a new web server.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start starts the HTTP server. It blocks until ctx is cancelled.

type TaskDetail

type TaskDetail struct {
	*model.Task
	Body           string `json:"body"`
	WorklogEntries int    `json:"worklog_entries,omitempty"`
	WorklogUpdated string `json:"worklog_updated,omitempty"`

	EffectiveStatus string               `json:"effective_status,omitempty"`
	EffectiveOwner  string               `json:"effective_owner,omitempty"`
	Worktree        string               `json:"worktree,omitempty"`
	Branch          string               `json:"branch,omitempty"`
	RemoteOnly      bool                 `json:"remote_only,omitempty"`
	Worktrees       []worktree.CopyEntry `json:"worktrees,omitempty"`
}

TaskDetail includes the body field for individual task detail views. The provenance fields are populated only when the worktree overlay is active, keeping the shape unchanged otherwise.

type TaskUpdateRequest

type TaskUpdateRequest struct {
	Title    *string   `json:"title"`
	Status   *string   `json:"status"`
	Priority *string   `json:"priority"`
	Effort   *string   `json:"effort"`
	Type     *string   `json:"type"`
	Owner    *string   `json:"owner"`
	Parent   *string   `json:"parent"`
	Tags     *[]string `json:"tags"`
	Body     *string   `json:"body"`
}

TaskUpdateRequest is the JSON request body for PUT /api/tasks/{id}.

type WorklogEntryJSON

type WorklogEntryJSON struct {
	Timestamp string `json:"timestamp"`
	Content   string `json:"content"`
}

WorklogEntryJSON is a single worklog entry for the API.

type WorktreeOverlayInfo

type WorktreeOverlayInfo struct {
	// Name is the local worktree's directory basename ("" when the scan dir
	// cannot be resolved to a git worktree, e.g. injected test discovery).
	Name string `json:"name,omitempty"`
	// Siblings is the number of sibling worktrees merged into the view.
	Siblings int `json:"siblings"`
}

WorktreeOverlayInfo describes the active overlay on /api/config so the frontend can render the header indicator ("worktree agent-b — 3 siblings"). Absent from the response when the overlay is inactive.

Jump to

Keyboard shortcuts

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