Documentation
¶
Overview ¶
Package task defines backend-agnostic DTOs and interfaces for issue tracking. All UI, mode, and orchestration code consumes these types instead of beads-specific types. Backend implementations (beads, future linear/github/etc.) adapt their native types to these DTOs.
Index ¶
- type Backend
- type BackendCapabilities
- type BackendServices
- type Comment
- type CreateResult
- type DependencyEdge
- type DependencyGraph
- type Issue
- type IssueOption
- func WithAcceptanceCriteria(ac string) IssueOption
- func WithAssignee(a string) IssueOption
- func WithBlockedBy(ids ...string) IssueOption
- func WithBlocks(ids ...string) IssueOption
- func WithChildren(ids ...string) IssueOption
- func WithCloseReason(reason string) IssueOption
- func WithClosedAt(t time.Time) IssueOption
- func WithCommentCount(n int) IssueOption
- func WithComments(comments ...Comment) IssueOption
- func WithCreatedAt(t time.Time) IssueOption
- func WithDescription(desc string) IssueOption
- func WithDesign(design string) IssueOption
- func WithDiscovered(ids ...string) IssueOption
- func WithDiscoveredFrom(ids ...string) IssueOption
- func WithExtension(key string, value any) IssueOption
- func WithExtensions(ext map[string]any) IssueOption
- func WithLabels(labels ...string) IssueOption
- func WithNotes(notes string) IssueOption
- func WithParentID(id string) IssueOption
- func WithPriority(p Priority) IssueOption
- func WithStatus(s Status) IssueOption
- func WithTitle(title string) IssueOption
- func WithType(t IssueType) IssueOption
- func WithUpdatedAt(t time.Time) IssueOption
- type IssueType
- type Priority
- type QueryExecutor
- type QueryHelpers
- type ServerDownError
- type Status
- type SyntaxHighlighter
- type TaskExecutor
- type TaskReader
- type TaskWriter
- type UpdateOptions
- type VersionIncompatibleError
- type WatcherConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
// Services returns the task-layer services produced by this backend.
Services() BackendServices
// CheckCompatibility verifies that the backend's data store is compatible
// with this version of perles. Returns *VersionIncompatibleError if the
// data store version is too old, nil if compatible.
CheckCompatibility() error
// FlushCaches invalidates all internal caches so subsequent queries
// hit the data store instead of returning stale results.
FlushCaches(ctx context.Context) error
// Close releases all backend resources (database connections, etc.).
Close() error
}
Backend is the top-level interface for a task-tracking backend. Each backend (beads, github, linear, etc.) implements this interface. The composition root creates a Backend via a factory function and passes it to the application layer, which uses Services() for task operations and FlushCaches() when the underlying data store changes on disk.
type BackendCapabilities ¶
type BackendCapabilities struct {
SupportsQuery bool // Can execute structured queries
QueryLanguageName string // "BQL", "JQL", etc. — shown in UI
SupportsDependencies bool // BlockedBy/Blocks tracking
SupportsTree bool // Parent/child hierarchy
SupportsComments bool
SupportsLabels bool
SupportsPriority bool
SupportsDesignField bool
SupportsNotesField bool
}
BackendCapabilities describes what a backend supports. This lets the UI gracefully degrade for backends that lack certain features.
type BackendServices ¶
type BackendServices struct {
TaskExecutor TaskExecutor
QueryExecutor QueryExecutor
QueryHelpers QueryHelpers // nil if backend has no structured query language
SyntaxHighlighter SyntaxHighlighter // nil if backend has no query syntax highlighting
Capabilities BackendCapabilities // what the backend supports
WatcherConfig WatcherConfig // file watcher configuration
DBPath string // path to data store file (for watcher)
}
BackendServices holds all task-layer services produced by a backend. Each backend implementation (beads, etc.) constructs these internally and exposes them via a Services() method.
type Comment ¶
type Comment struct {
ID int `json:"id"`
Author string `json:"author"`
Text string `json:"text"`
CreatedAt time.Time `json:"created_at"`
}
Comment represents a comment on an issue.
type CreateResult ¶
CreateResult holds the result of a create operation.
type DependencyEdge ¶
type DependencyEdge struct {
TargetID string
Type string // "parent-child", "blocks", "discovered-from"
}
DependencyEdge represents one edge in a dependency graph.
type DependencyGraph ¶
type DependencyGraph struct {
Forward map[string][]DependencyEdge
Reverse map[string][]DependencyEdge
}
DependencyGraph holds the full dependency graph for all issues. Forward edges: issue_id -> depends_on_id Reverse edges: depends_on_id -> issue_id
type Issue ¶
type Issue struct {
ID string `json:"id"`
TitleText string `json:"title"`
DescriptionText string `json:"description"`
Design string `json:"design"`
AcceptanceCriteria string `json:"acceptance_criteria"`
Notes string `json:"notes"`
Status Status `json:"status"`
Priority Priority `json:"priority"`
Type IssueType `json:"type"`
Assignee string `json:"assignee"`
Labels []string `json:"labels"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ClosedAt time.Time `json:"closed_at"`
CloseReason string `json:"close_reason,omitempty"`
ParentID string `json:"parent_id"`
// Dependency tracking
BlockedBy []string `json:"blocked_by"`
Blocks []string `json:"blocks"`
Children []string `json:"children"`
DiscoveredFrom []string `json:"discovered_from"`
Discovered []string `json:"discovered"`
// Comments (populated on demand)
Comments []Comment `json:"comments,omitempty"`
CommentCount int `json:"comment_count,omitempty"`
// Extensions allows backends to carry provider-specific data without
// polluting the shared type. For example, beads agent fields (HookBead,
// RoleBead, etc.) are stored here for round-tripping. UI code should
// not read these directly.
Extensions map[string]any `json:"extensions,omitempty"`
}
Issue is the canonical task DTO used throughout the application. Backend implementations map their native types to this struct.
func BuildIssue ¶
func BuildIssue(id string, opts ...IssueOption) Issue
BuildIssue creates a task.Issue with sensible defaults and applies options. Defaults: TitleText="Issue {id}", Type=TypeTask, Priority=PriorityMedium, Status=StatusOpen.
Example:
issue := task.BuildIssue("bd-1",
task.WithTitle("Fix auth bug"),
task.WithType(task.TypeBug),
task.WithPriority(task.PriorityHigh),
task.WithLabels("security", "urgent"),
)
func BuildIssuePtr ¶
func BuildIssuePtr(id string, opts ...IssueOption) *Issue
BuildIssuePtr is like BuildIssue but returns a pointer.
type IssueOption ¶
type IssueOption func(*Issue)
IssueOption configures a task.Issue during construction.
func WithAcceptanceCriteria ¶
func WithAcceptanceCriteria(ac string) IssueOption
WithAcceptanceCriteria sets the acceptance criteria.
func WithBlockedBy ¶
func WithBlockedBy(ids ...string) IssueOption
WithBlockedBy sets the issue IDs that block this issue.
func WithBlocks ¶
func WithBlocks(ids ...string) IssueOption
WithBlocks sets the issue IDs that this issue blocks.
func WithChildren ¶
func WithChildren(ids ...string) IssueOption
WithChildren sets the child issue IDs.
func WithCloseReason ¶
func WithCloseReason(reason string) IssueOption
WithCloseReason sets the close reason.
func WithClosedAt ¶
func WithClosedAt(t time.Time) IssueOption
WithClosedAt sets the closed_at timestamp.
func WithCommentCount ¶
func WithCommentCount(n int) IssueOption
WithCommentCount sets the comment count without populating comments.
func WithComments ¶
func WithComments(comments ...Comment) IssueOption
WithComments sets the issue comments.
func WithCreatedAt ¶
func WithCreatedAt(t time.Time) IssueOption
WithCreatedAt sets the created_at timestamp.
func WithDescription ¶
func WithDescription(desc string) IssueOption
WithDescription sets the issue description.
func WithDesign ¶
func WithDesign(design string) IssueOption
WithDesign sets the issue design field.
func WithDiscovered ¶
func WithDiscovered(ids ...string) IssueOption
WithDiscovered sets the discovered issue IDs.
func WithDiscoveredFrom ¶
func WithDiscoveredFrom(ids ...string) IssueOption
WithDiscoveredFrom sets the discovered-from issue IDs.
func WithExtension ¶
func WithExtension(key string, value any) IssueOption
WithExtension sets a single extension key-value pair. Initializes the Extensions map if nil.
func WithExtensions ¶
func WithExtensions(ext map[string]any) IssueOption
WithExtensions sets the entire extensions map.
func WithUpdatedAt ¶
func WithUpdatedAt(t time.Time) IssueOption
WithUpdatedAt sets the updated_at timestamp.
type QueryExecutor ¶
QueryExecutor executes queries and returns matching issues. Each backend defines its own query language/strategy. The query string format is backend-dependent (BQL for beads, etc.).
type QueryHelpers ¶
type QueryHelpers interface {
// BuildIDQuery constructs a query to fetch issues by their IDs.
BuildIDQuery(ids []string) string
// IsStructuredQuery returns true if the input looks like a structured query
// (e.g. BQL) vs a plain text search.
IsStructuredQuery(input string) bool
// ValidateQuery validates a query string, returning an error if invalid.
ValidateQuery(query string) error
}
QueryHelpers provides optional utility functions that backends may implement. If a backend does not support structured queries, these methods should return sensible defaults or errors.
type ServerDownError ¶
ServerDownError indicates the backend's server is not reachable. This is used by backends that require an external server process (e.g., Dolt in server mode).
func (*ServerDownError) Error ¶
func (e *ServerDownError) Error() string
type SyntaxHighlighter ¶
type SyntaxHighlighter interface {
// NewSyntaxLexer returns a syntax lexer for highlighting query input.
// The returned value should implement the vimtextarea.SyntaxLexer interface.
NewSyntaxLexer() any
}
SyntaxHighlighter provides query syntax highlighting for the UI. Backends that support structured query languages implement this to provide syntax highlighting in the search input.
type TaskExecutor ¶
type TaskExecutor interface {
TaskReader
TaskWriter
}
TaskExecutor combines read and write operations on issues.
type TaskReader ¶
type TaskReader interface {
ShowIssue(issueID string) (*Issue, error)
GetComments(issueID string) ([]Comment, error)
}
TaskReader provides read access to individual issues and their comments.
type TaskWriter ¶
type TaskWriter interface {
UpdateStatus(issueID string, status Status) error
UpdatePriority(issueID string, priority Priority) error
UpdateType(issueID string, issueType IssueType) error
UpdateTitle(issueID, title string) error
UpdateDescription(issueID, description string) error
UpdateNotes(issueID, notes string) error
CloseIssue(issueID, reason string) error
ReopenIssue(issueID string) error
SetLabels(issueID string, labels []string) error
AddComment(issueID, author, text string) error
CreateEpic(title, description string, labels []string) (CreateResult, error)
CreateTask(title, description, parentID, assignee string, labels []string) (CreateResult, error)
DeleteIssues(issueIDs []string) error
AddDependency(taskID, dependsOnID string) error
UpdateIssue(issueID string, opts UpdateOptions) error
}
TaskWriter provides write access to issues.
type UpdateOptions ¶
type UpdateOptions struct {
Title *string
Description *string
Notes *string
Priority *Priority
Status *Status
Labels *[]string // nil = unchanged, &[]string{} = clear all
Assignee *string // nil = unchanged
Type *IssueType // nil = unchanged
}
UpdateOptions specifies which fields to update on an issue. Nil pointer fields are skipped (not sent to the backend).
type VersionIncompatibleError ¶
type VersionIncompatibleError struct {
Current string // version found in the data store (or "unknown")
Required string // minimum version required by this backend
}
VersionIncompatibleError indicates the backend data store version is too old for this version of perles.
func (*VersionIncompatibleError) Error ¶
func (e *VersionIncompatibleError) Error() string
type WatcherConfig ¶
type WatcherConfig struct {
// RelevantFiles lists the base filenames that should trigger a refresh.
// For example: ["beads.db", "beads.db-wal"] for SQLite backends.
RelevantFiles []string
// DebounceDuration is how long to wait after the last filesystem event
// before publishing a change notification. Zero means use default (100ms).
DebounceDuration time.Duration
}
WatcherConfig holds backend-specific file watcher configuration.